ltmain.sh revision b698ba48
1b698ba48Smrg# ltmain.sh - Provide generalized library-building support services.
2b698ba48Smrg# NOTE: Changing this file will not affect anything until you rerun configure.
3b698ba48Smrg#
4b698ba48Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
5b698ba48Smrg# 2007, 2008  Free Software Foundation, Inc.
6b698ba48Smrg# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
7b698ba48Smrg#
8b698ba48Smrg# This program is free software; you can redistribute it and/or modify
909885543Smrg# it under the terms of the GNU General Public License as published by
1009885543Smrg# the Free Software Foundation; either version 2 of the License, or
1109885543Smrg# (at your option) any later version.
1209885543Smrg#
13b698ba48Smrg# This program is distributed in the hope that it will be useful, but
1409885543Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
1509885543Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1609885543Smrg# General Public License for more details.
1709885543Smrg#
1809885543Smrg# You should have received a copy of the GNU General Public License
19b698ba48Smrg# along with this program; if not, write to the Free Software
20b698ba48Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
212ec8c4b4Smrg#
22b698ba48Smrg# As a special exception to the GNU General Public License, if you
23b698ba48Smrg# distribute this file as part of a program that contains a
24b698ba48Smrg# configuration script generated by Autoconf, you may include it under
25b698ba48Smrg# the same distribution terms that you use for the rest of that program.
26b698ba48Smrg
27b698ba48Smrgbasename="s,^.*/,,g"
28b698ba48Smrg
29b698ba48Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
30b698ba48Smrg# is ksh but when the shell is invoked as "sh" and the current value of
31b698ba48Smrg# the _XPG environment variable is not equal to 1 (one), the special
32b698ba48Smrg# positional parameter $0, within a function call, is the name of the
33b698ba48Smrg# function.
34b698ba48Smrgprogpath="$0"
35b698ba48Smrg
36b698ba48Smrg# The name of this program:
37b698ba48Smrgprogname=`echo "$progpath" | $SED $basename`
38b698ba48Smrgmodename="$progname"
39b698ba48Smrg
40b698ba48Smrg# Global variables:
41b698ba48SmrgEXIT_SUCCESS=0
42b698ba48SmrgEXIT_FAILURE=1
4309885543Smrg
4409885543SmrgPROGRAM=ltmain.sh
4509885543SmrgPACKAGE=libtool
46b698ba48SmrgVERSION=1.5.26
47b698ba48SmrgTIMESTAMP=" (1.1220.2.493 2008/02/01 16:58:18)"
487104f784Smrg
49b698ba48Smrg# Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE).
507104f784Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
517104f784Smrg  emulate sh
527104f784Smrg  NULLCMD=:
537104f784Smrg  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
547104f784Smrg  # is contrary to our usage.  Disable this feature.
557104f784Smrg  alias -g '${1+"$@"}'='"$@"'
5609885543Smrg  setopt NO_GLOB_SUBST
577104f784Smrgelse
587104f784Smrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
5909885543Smrgfi
607104f784SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
617104f784SmrgDUALCASE=1; export DUALCASE # for MKS sh
6209885543Smrg
63b698ba48Smrg# Check that we have a working $echo.
64b698ba48Smrgif test "X$1" = X--no-reexec; then
65b698ba48Smrg  # Discard the --no-reexec flag, and continue.
66b698ba48Smrg  shift
67b698ba48Smrgelif test "X$1" = X--fallback-echo; then
68b698ba48Smrg  # Avoid inline document here, it may be left over
69b698ba48Smrg  :
70b698ba48Smrgelif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
71b698ba48Smrg  # Yippee, $echo works!
72b698ba48Smrg  :
73b698ba48Smrgelse
74b698ba48Smrg  # Restart under the correct shell, and then maybe $echo will work.
75b698ba48Smrg  exec $SHELL "$progpath" --no-reexec ${1+"$@"}
76b698ba48Smrgfi
77b698ba48Smrg
78b698ba48Smrgif test "X$1" = X--fallback-echo; then
79b698ba48Smrg  # used as fallback echo
80b698ba48Smrg  shift
81b698ba48Smrg  cat <<EOF
82b698ba48Smrg$*
83b698ba48SmrgEOF
84b698ba48Smrg  exit $EXIT_SUCCESS
85b698ba48Smrgfi
86b698ba48Smrg
87b698ba48Smrgdefault_mode=
88b698ba48Smrghelp="Try \`$progname --help' for more information."
89b698ba48Smrgmagic="%%%MAGIC variable%%%"
90b698ba48Smrgmkdir="mkdir"
91b698ba48Smrgmv="mv -f"
92b698ba48Smrgrm="rm -f"
93b698ba48Smrg
94b698ba48Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
95b698ba48Smrg# metacharacters that are still active within double-quoted strings.
96b698ba48SmrgXsed="${SED}"' -e 1s/^X//'
97b698ba48Smrgsed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
98b698ba48Smrg# test EBCDIC or ASCII
99b698ba48Smrgcase `echo X|tr X '\101'` in
100b698ba48Smrg A) # ASCII based system
101b698ba48Smrg    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
102b698ba48Smrg  SP2NL='tr \040 \012'
103b698ba48Smrg  NL2SP='tr \015\012 \040\040'
104b698ba48Smrg  ;;
105b698ba48Smrg *) # EBCDIC based system
106b698ba48Smrg  SP2NL='tr \100 \n'
107b698ba48Smrg  NL2SP='tr \r\n \100\100'
108b698ba48Smrg  ;;
109b698ba48Smrgesac
110b698ba48Smrg
111b698ba48Smrg# NLS nuisances.
11209885543Smrg# Only set LANG and LC_ALL to C if already set.
11309885543Smrg# These must not be set unconditionally because not all systems understand
11409885543Smrg# e.g. LANG=C (notably SCO).
115b698ba48Smrg# We save the old values to restore during execute mode.
116b698ba48Smrglt_env=
1177104f784Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
1187104f784Smrgdo
1197104f784Smrg  eval "if test \"\${$lt_var+set}\" = set; then
120b698ba48Smrg	  save_$lt_var=\$$lt_var
121b698ba48Smrg	  lt_env=\"$lt_var=\$$lt_var \$lt_env\"
122b698ba48Smrg	  $lt_var=C
1237104f784Smrg	  export $lt_var
1247104f784Smrg	fi"
1257104f784Smrgdone
1267104f784Smrg
127b698ba48Smrgif test -n "$lt_env"; then
128b698ba48Smrg  lt_env="env $lt_env"
129b698ba48Smrgfi
13009885543Smrg
13109885543Smrg# Make sure IFS has a sensible default
13209885543Smrglt_nl='
13309885543Smrg'
13409885543SmrgIFS=" 	$lt_nl"
13509885543Smrg
136b698ba48Smrgif test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
137b698ba48Smrg  $echo "$modename: not configured to build any kind of library" 1>&2
138b698ba48Smrg  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
139b698ba48Smrg  exit $EXIT_FAILURE
140b698ba48Smrgfi
1412ec8c4b4Smrg
142b698ba48Smrg# Global variables.
143b698ba48Smrgmode=$default_mode
144b698ba48Smrgnonopt=
145b698ba48Smrgprev=
146b698ba48Smrgprevopt=
147b698ba48Smrgrun=
148b698ba48Smrgshow="$echo"
149b698ba48Smrgshow_help=
150b698ba48Smrgexecute_dlfiles=
151b698ba48Smrgduplicate_deps=no
152b698ba48Smrgpreserve_args=
153b698ba48Smrglo2o="s/\\.lo\$/.${objext}/"
154b698ba48Smrgo2lo="s/\\.${objext}\$/.lo/"
155b698ba48Smrgextracted_archives=
156b698ba48Smrgextracted_serial=0
15709885543Smrg
158b698ba48Smrg#####################################
159b698ba48Smrg# Shell function definitions:
160b698ba48Smrg# This seems to be the best place for them
16109885543Smrg
16209885543Smrg# func_mktempdir [string]
16309885543Smrg# Make a temporary directory that won't clash with other running
16409885543Smrg# libtool processes, and avoids race conditions if possible.  If
16509885543Smrg# given, STRING is the basename for that directory.
16609885543Smrgfunc_mktempdir ()
16709885543Smrg{
16809885543Smrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
16909885543Smrg
170b698ba48Smrg    if test "$run" = ":"; then
17109885543Smrg      # Return a directory name, but don't create it in dry-run mode
17209885543Smrg      my_tmpdir="${my_template}-$$"
17309885543Smrg    else
17409885543Smrg
17509885543Smrg      # If mktemp works, use that first and foremost
17609885543Smrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
17709885543Smrg
17809885543Smrg      if test ! -d "$my_tmpdir"; then
179b698ba48Smrg	# Failing that, at least try and use $RANDOM to avoid a race
180b698ba48Smrg	my_tmpdir="${my_template}-${RANDOM-0}$$"
18109885543Smrg
182b698ba48Smrg	save_mktempdir_umask=`umask`
183b698ba48Smrg	umask 0077
184b698ba48Smrg	$mkdir "$my_tmpdir"
185b698ba48Smrg	umask $save_mktempdir_umask
18609885543Smrg      fi
18709885543Smrg
18809885543Smrg      # If we're not in dry-run mode, bomb out on failure
189b698ba48Smrg      test -d "$my_tmpdir" || {
190b698ba48Smrg        $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
191b698ba48Smrg	exit $EXIT_FAILURE
192b698ba48Smrg      }
19309885543Smrg    fi
19409885543Smrg
195b698ba48Smrg    $echo "X$my_tmpdir" | $Xsed
19609885543Smrg}
19709885543Smrg
19809885543Smrg
199b698ba48Smrg# func_win32_libid arg
200b698ba48Smrg# return the library type of file 'arg'
201b698ba48Smrg#
202b698ba48Smrg# Need a lot of goo to handle *both* DLLs and import libs
203b698ba48Smrg# Has to be a shell function in order to 'eat' the argument
204b698ba48Smrg# that is supplied when $file_magic_command is called.
205b698ba48Smrgfunc_win32_libid ()
20609885543Smrg{
207b698ba48Smrg  win32_libid_type="unknown"
208b698ba48Smrg  win32_fileres=`file -L $1 2>/dev/null`
209b698ba48Smrg  case $win32_fileres in
210b698ba48Smrg  *ar\ archive\ import\ library*) # definitely import
211b698ba48Smrg    win32_libid_type="x86 archive import"
212b698ba48Smrg    ;;
213b698ba48Smrg  *ar\ archive*) # could be an import, or static
214b698ba48Smrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
215b698ba48Smrg      $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
216b698ba48Smrg      win32_nmres=`eval $NM -f posix -A $1 | \
217b698ba48Smrg	$SED -n -e '1,100{
218b698ba48Smrg		/ I /{
219b698ba48Smrg			s,.*,import,
220b698ba48Smrg			p
221b698ba48Smrg			q
222b698ba48Smrg			}
223b698ba48Smrg		}'`
224b698ba48Smrg      case $win32_nmres in
225b698ba48Smrg      import*)  win32_libid_type="x86 archive import";;
226b698ba48Smrg      *)        win32_libid_type="x86 archive static";;
227b698ba48Smrg      esac
228b698ba48Smrg    fi
229b698ba48Smrg    ;;
230b698ba48Smrg  *DLL*)
231b698ba48Smrg    win32_libid_type="x86 DLL"
232b698ba48Smrg    ;;
233b698ba48Smrg  *executable*) # but shell scripts are "executable" too...
234b698ba48Smrg    case $win32_fileres in
235b698ba48Smrg    *MS\ Windows\ PE\ Intel*)
236b698ba48Smrg      win32_libid_type="x86 DLL"
237b698ba48Smrg      ;;
23809885543Smrg    esac
239b698ba48Smrg    ;;
240b698ba48Smrg  esac
241b698ba48Smrg  $echo $win32_libid_type
24209885543Smrg}
24309885543Smrg
24409885543Smrg
245b698ba48Smrg# func_infer_tag arg
246b698ba48Smrg# Infer tagged configuration to use if any are available and
247b698ba48Smrg# if one wasn't chosen via the "--tag" command line option.
248b698ba48Smrg# Only attempt this if the compiler in the base compile
249b698ba48Smrg# command doesn't match the default compiler.
250b698ba48Smrg# arg is usually of the form 'gcc ...'
251b698ba48Smrgfunc_infer_tag ()
25209885543Smrg{
253b698ba48Smrg    if test -n "$available_tags" && test -z "$tagname"; then
254b698ba48Smrg      CC_quoted=
255b698ba48Smrg      for arg in $CC; do
256b698ba48Smrg	case $arg in
257b698ba48Smrg	  *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
258b698ba48Smrg	  arg="\"$arg\""
259b698ba48Smrg	  ;;
260b698ba48Smrg	esac
261b698ba48Smrg	CC_quoted="$CC_quoted $arg"
262b698ba48Smrg      done
263b698ba48Smrg      case $@ in
264b698ba48Smrg      # Blanks in the command may have been stripped by the calling shell,
265b698ba48Smrg      # but not from the CC environment variable when configure was run.
266b698ba48Smrg      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
267b698ba48Smrg      # Blanks at the start of $base_compile will cause this to fail
268b698ba48Smrg      # if we don't check for them as well.
26909885543Smrg      *)
270b698ba48Smrg	for z in $available_tags; do
271b698ba48Smrg	  if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
272b698ba48Smrg	    # Evaluate the configuration.
273b698ba48Smrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
274b698ba48Smrg	    CC_quoted=
275b698ba48Smrg	    for arg in $CC; do
276b698ba48Smrg	    # Double-quote args containing other shell metacharacters.
277b698ba48Smrg	    case $arg in
278b698ba48Smrg	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
279b698ba48Smrg	      arg="\"$arg\""
280b698ba48Smrg	      ;;
281b698ba48Smrg	    esac
282b698ba48Smrg	    CC_quoted="$CC_quoted $arg"
283b698ba48Smrg	  done
284b698ba48Smrg	    case "$@ " in
285b698ba48Smrg	      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
286b698ba48Smrg	      # The compiler in the base compile command matches
287b698ba48Smrg	      # the one in the tagged configuration.
288b698ba48Smrg	      # Assume this is the tagged configuration we want.
289b698ba48Smrg	      tagname=$z
290b698ba48Smrg	      break
291b698ba48Smrg	      ;;
292b698ba48Smrg	    esac
293b698ba48Smrg	  fi
294b698ba48Smrg	done
295b698ba48Smrg	# If $tagname still isn't set, then no tagged configuration
296b698ba48Smrg	# was found and let the user know that the "--tag" command
297b698ba48Smrg	# line option must be used.
298b698ba48Smrg	if test -z "$tagname"; then
299b698ba48Smrg	  $echo "$modename: unable to infer tagged configuration"
300b698ba48Smrg	  $echo "$modename: specify a tag with \`--tag'" 1>&2
301b698ba48Smrg	  exit $EXIT_FAILURE
302b698ba48Smrg#        else
303b698ba48Smrg#          $echo "$modename: using $tagname tagged configuration"
304b698ba48Smrg	fi
305b698ba48Smrg	;;
306b698ba48Smrg      esac
307b698ba48Smrg    fi
30809885543Smrg}
30909885543Smrg
31009885543Smrg
311b698ba48Smrg# func_extract_an_archive dir oldlib
312b698ba48Smrgfunc_extract_an_archive ()
31309885543Smrg{
314b698ba48Smrg    f_ex_an_ar_dir="$1"; shift
315b698ba48Smrg    f_ex_an_ar_oldlib="$1"
3162ec8c4b4Smrg
317b698ba48Smrg    $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
318b698ba48Smrg    $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
319b698ba48Smrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
320b698ba48Smrg     :
321b698ba48Smrg    else
322b698ba48Smrg      $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2
323b698ba48Smrg      exit $EXIT_FAILURE
32409885543Smrg    fi
32509885543Smrg}
32609885543Smrg
327b698ba48Smrg# func_extract_archives gentop oldlib ...
328b698ba48Smrgfunc_extract_archives ()
32909885543Smrg{
330b698ba48Smrg    my_gentop="$1"; shift
331b698ba48Smrg    my_oldlibs=${1+"$@"}
332b698ba48Smrg    my_oldobjs=""
333b698ba48Smrg    my_xlib=""
334b698ba48Smrg    my_xabs=""
335b698ba48Smrg    my_xdir=""
336b698ba48Smrg    my_status=""
337b698ba48Smrg
338b698ba48Smrg    $show "${rm}r $my_gentop"
339b698ba48Smrg    $run ${rm}r "$my_gentop"
340b698ba48Smrg    $show "$mkdir $my_gentop"
341b698ba48Smrg    $run $mkdir "$my_gentop"
342b698ba48Smrg    my_status=$?
343b698ba48Smrg    if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
344b698ba48Smrg      exit $my_status
34509885543Smrg    fi
34609885543Smrg
347b698ba48Smrg    for my_xlib in $my_oldlibs; do
348b698ba48Smrg      # Extract the objects.
349b698ba48Smrg      case $my_xlib in
350b698ba48Smrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
351b698ba48Smrg	*) my_xabs=`pwd`"/$my_xlib" ;;
352b698ba48Smrg      esac
353b698ba48Smrg      my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
354b698ba48Smrg      my_xlib_u=$my_xlib
355b698ba48Smrg      while :; do
356b698ba48Smrg        case " $extracted_archives " in
357b698ba48Smrg	*" $my_xlib_u "*)
358b698ba48Smrg	  extracted_serial=`expr $extracted_serial + 1`
359b698ba48Smrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
360b698ba48Smrg	*) break ;;
361b698ba48Smrg	esac
362b698ba48Smrg      done
363b698ba48Smrg      extracted_archives="$extracted_archives $my_xlib_u"
364b698ba48Smrg      my_xdir="$my_gentop/$my_xlib_u"
3652ec8c4b4Smrg
366b698ba48Smrg      $show "${rm}r $my_xdir"
367b698ba48Smrg      $run ${rm}r "$my_xdir"
368b698ba48Smrg      $show "$mkdir $my_xdir"
369b698ba48Smrg      $run $mkdir "$my_xdir"
370b698ba48Smrg      exit_status=$?
371b698ba48Smrg      if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then
372b698ba48Smrg	exit $exit_status
373b698ba48Smrg      fi
374b698ba48Smrg      case $host in
375b698ba48Smrg      *-darwin*)
376b698ba48Smrg	$show "Extracting $my_xabs"
377b698ba48Smrg	# Do not bother doing anything if just a dry run
378b698ba48Smrg	if test -z "$run"; then
379b698ba48Smrg	  darwin_orig_dir=`pwd`
380b698ba48Smrg	  cd $my_xdir || exit $?
381b698ba48Smrg	  darwin_archive=$my_xabs
382b698ba48Smrg	  darwin_curdir=`pwd`
383b698ba48Smrg	  darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'`
384b698ba48Smrg	  darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
385b698ba48Smrg	  if test -n "$darwin_arches"; then 
386b698ba48Smrg	    darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
387b698ba48Smrg	    darwin_arch=
388b698ba48Smrg	    $show "$darwin_base_archive has multiple architectures $darwin_arches"
389b698ba48Smrg	    for darwin_arch in  $darwin_arches ; do
390b698ba48Smrg	      mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
391b698ba48Smrg	      lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
392b698ba48Smrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
393b698ba48Smrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
394b698ba48Smrg	      cd "$darwin_curdir"
395b698ba48Smrg	      $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
396b698ba48Smrg	    done # $darwin_arches
397b698ba48Smrg      ## Okay now we have a bunch of thin objects, gotta fatten them up :)
398b698ba48Smrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP`
399b698ba48Smrg	    darwin_file=
400b698ba48Smrg	    darwin_files=
401b698ba48Smrg	    for darwin_file in $darwin_filelist; do
402b698ba48Smrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
403b698ba48Smrg	      lipo -create -output "$darwin_file" $darwin_files
404b698ba48Smrg	    done # $darwin_filelist
405b698ba48Smrg	    ${rm}r unfat-$$
406b698ba48Smrg	    cd "$darwin_orig_dir"
407b698ba48Smrg	  else
408b698ba48Smrg	    cd "$darwin_orig_dir"
409b698ba48Smrg 	    func_extract_an_archive "$my_xdir" "$my_xabs"
410b698ba48Smrg	  fi # $darwin_arches
411b698ba48Smrg	fi # $run
412b698ba48Smrg	;;
413b698ba48Smrg      *)
414b698ba48Smrg        func_extract_an_archive "$my_xdir" "$my_xabs"
415b698ba48Smrg        ;;
416b698ba48Smrg      esac
417b698ba48Smrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
418b698ba48Smrg    done
419b698ba48Smrg    func_extract_archives_result="$my_oldobjs"
42009885543Smrg}
421b698ba48Smrg# End of Shell function definitions
422b698ba48Smrg#####################################
42309885543Smrg
424b698ba48Smrg# Darwin sucks
425b698ba48Smrgeval std_shrext=\"$shrext_cmds\"
4262ec8c4b4Smrg
427b698ba48Smrgdisable_libs=no
4282ec8c4b4Smrg
429b698ba48Smrg# Parse our command line options once, thoroughly.
430b698ba48Smrgwhile test "$#" -gt 0
431b698ba48Smrgdo
432b698ba48Smrg  arg="$1"
4332ec8c4b4Smrg  shift
43409885543Smrg
435b698ba48Smrg  case $arg in
436b698ba48Smrg  -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
437b698ba48Smrg  *) optarg= ;;
438b698ba48Smrg  esac
43909885543Smrg
440b698ba48Smrg  # If the previous option needs an argument, assign it.
441b698ba48Smrg  if test -n "$prev"; then
442b698ba48Smrg    case $prev in
443b698ba48Smrg    execute_dlfiles)
444b698ba48Smrg      execute_dlfiles="$execute_dlfiles $arg"
445b698ba48Smrg      ;;
446b698ba48Smrg    tag)
447b698ba48Smrg      tagname="$arg"
448b698ba48Smrg      preserve_args="${preserve_args}=$arg"
449b698ba48Smrg
450b698ba48Smrg      # Check whether tagname contains only valid characters
451b698ba48Smrg      case $tagname in
452b698ba48Smrg      *[!-_A-Za-z0-9,/]*)
453b698ba48Smrg	$echo "$progname: invalid tag name: $tagname" 1>&2
454b698ba48Smrg	exit $EXIT_FAILURE
455b698ba48Smrg	;;
456b698ba48Smrg      esac
45709885543Smrg
458b698ba48Smrg      case $tagname in
459b698ba48Smrg      CC)
460b698ba48Smrg	# Don't test for the "default" C tag, as we know, it's there, but
461b698ba48Smrg	# not specially marked.
462b698ba48Smrg	;;
463b698ba48Smrg      *)
464b698ba48Smrg	if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then
465b698ba48Smrg	  taglist="$taglist $tagname"
466b698ba48Smrg	  # Evaluate the configuration.
467b698ba48Smrg	  eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`"
468b698ba48Smrg	else
469b698ba48Smrg	  $echo "$progname: ignoring unknown tag $tagname" 1>&2
470b698ba48Smrg	fi
471b698ba48Smrg	;;
472b698ba48Smrg      esac
473b698ba48Smrg      ;;
474b698ba48Smrg    *)
475b698ba48Smrg      eval "$prev=\$arg"
476b698ba48Smrg      ;;
477b698ba48Smrg    esac
4782ec8c4b4Smrg
479b698ba48Smrg    prev=
480b698ba48Smrg    prevopt=
481b698ba48Smrg    continue
482b698ba48Smrg  fi
48309885543Smrg
484b698ba48Smrg  # Have we seen a non-optional argument yet?
485b698ba48Smrg  case $arg in
486b698ba48Smrg  --help)
487b698ba48Smrg    show_help=yes
488b698ba48Smrg    ;;
4897104f784Smrg
490b698ba48Smrg  --version)
491b698ba48Smrg    echo "\
492b698ba48Smrg$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP
4932ec8c4b4Smrg
494b698ba48SmrgCopyright (C) 2008  Free Software Foundation, Inc.
495b698ba48SmrgThis is free software; see the source for copying conditions.  There is NO
496b698ba48Smrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
497b698ba48Smrg    exit $?
498b698ba48Smrg    ;;
49909885543Smrg
500b698ba48Smrg  --config)
501b698ba48Smrg    ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath
50209885543Smrg    # Now print the configurations for the tags.
50309885543Smrg    for tagname in $taglist; do
504b698ba48Smrg      ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
50509885543Smrg    done
5062ec8c4b4Smrg    exit $?
507b698ba48Smrg    ;;
50809885543Smrg
509b698ba48Smrg  --debug)
510b698ba48Smrg    $echo "$progname: enabling shell trace mode"
511b698ba48Smrg    set -x
512b698ba48Smrg    preserve_args="$preserve_args $arg"
513b698ba48Smrg    ;;
514b698ba48Smrg
515b698ba48Smrg  --dry-run | -n)
516b698ba48Smrg    run=:
517b698ba48Smrg    ;;
518b698ba48Smrg
519b698ba48Smrg  --features)
520b698ba48Smrg    $echo "host: $host"
52109885543Smrg    if test "$build_libtool_libs" = yes; then
522b698ba48Smrg      $echo "enable shared libraries"
52309885543Smrg    else
524b698ba48Smrg      $echo "disable shared libraries"
52509885543Smrg    fi
52609885543Smrg    if test "$build_old_libs" = yes; then
527b698ba48Smrg      $echo "enable static libraries"
52809885543Smrg    else
529b698ba48Smrg      $echo "disable static libraries"
53009885543Smrg    fi
53109885543Smrg    exit $?
532b698ba48Smrg    ;;
53309885543Smrg
534b698ba48Smrg  --finish) mode="finish" ;;
53509885543Smrg
536b698ba48Smrg  --mode) prevopt="--mode" prev=mode ;;
537b698ba48Smrg  --mode=*) mode="$optarg" ;;
5382ec8c4b4Smrg
539b698ba48Smrg  --preserve-dup-deps) duplicate_deps="yes" ;;
54009885543Smrg
541b698ba48Smrg  --quiet | --silent)
542b698ba48Smrg    show=:
543b698ba48Smrg    preserve_args="$preserve_args $arg"
54409885543Smrg    ;;
545b698ba48Smrg
546b698ba48Smrg  --tag)
547b698ba48Smrg    prevopt="--tag"
548b698ba48Smrg    prev=tag
549b698ba48Smrg    preserve_args="$preserve_args --tag"
55009885543Smrg    ;;
551b698ba48Smrg  --tag=*)
552b698ba48Smrg    set tag "$optarg" ${1+"$@"}
553b698ba48Smrg    shift
554b698ba48Smrg    prev=tag
555b698ba48Smrg    preserve_args="$preserve_args --tag"
55609885543Smrg    ;;
557b698ba48Smrg
558b698ba48Smrg  -dlopen)
559b698ba48Smrg    prevopt="-dlopen"
560b698ba48Smrg    prev=execute_dlfiles
5612ec8c4b4Smrg    ;;
562b698ba48Smrg
563b698ba48Smrg  -*)
564b698ba48Smrg    $echo "$modename: unrecognized option \`$arg'" 1>&2
565b698ba48Smrg    $echo "$help" 1>&2
566b698ba48Smrg    exit $EXIT_FAILURE
5672ec8c4b4Smrg    ;;
568b698ba48Smrg
569b698ba48Smrg  *)
570b698ba48Smrg    nonopt="$arg"
571b698ba48Smrg    break
57209885543Smrg    ;;
57309885543Smrg  esac
574b698ba48Smrgdone
57509885543Smrg
576b698ba48Smrgif test -n "$prevopt"; then
577b698ba48Smrg  $echo "$modename: option \`$prevopt' requires an argument" 1>&2
578b698ba48Smrg  $echo "$help" 1>&2
579b698ba48Smrg  exit $EXIT_FAILURE
580b698ba48Smrgfi
5812ec8c4b4Smrg
582b698ba48Smrgcase $disable_libs in
583b698ba48Smrgno) 
584b698ba48Smrg  ;;
585b698ba48Smrgshared)
586b698ba48Smrg  build_libtool_libs=no
587b698ba48Smrg  build_old_libs=yes
588b698ba48Smrg  ;;
589b698ba48Smrgstatic)
590b698ba48Smrg  build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
591b698ba48Smrg  ;;
592b698ba48Smrgesac
5932ec8c4b4Smrg
594b698ba48Smrg# If this variable is set in any of the actions, the command in it
595b698ba48Smrg# will be execed at the end.  This prevents here-documents from being
596b698ba48Smrg# left over by shells.
597b698ba48Smrgexec_cmd=
5982ec8c4b4Smrg
599b698ba48Smrgif test -z "$show_help"; then
6002ec8c4b4Smrg
601b698ba48Smrg  # Infer the operation mode.
602b698ba48Smrg  if test -z "$mode"; then
603b698ba48Smrg    $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
604b698ba48Smrg    $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2
605b698ba48Smrg    case $nonopt in
606b698ba48Smrg    *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
607b698ba48Smrg      mode=link
608b698ba48Smrg      for arg
609b698ba48Smrg      do
610b698ba48Smrg	case $arg in
611b698ba48Smrg	-c)
612b698ba48Smrg	   mode=compile
613b698ba48Smrg	   break
614b698ba48Smrg	   ;;
615b698ba48Smrg	esac
616b698ba48Smrg      done
61709885543Smrg      ;;
618b698ba48Smrg    *db | *dbx | *strace | *truss)
619b698ba48Smrg      mode=execute
6202ec8c4b4Smrg      ;;
621b698ba48Smrg    *install*|cp|mv)
622b698ba48Smrg      mode=install
623b698ba48Smrg      ;;
624b698ba48Smrg    *rm)
625b698ba48Smrg      mode=uninstall
626b698ba48Smrg      ;;
627b698ba48Smrg    *)
628b698ba48Smrg      # If we have no mode, but dlfiles were specified, then do execute mode.
629b698ba48Smrg      test -n "$execute_dlfiles" && mode=execute
6302ec8c4b4Smrg
631b698ba48Smrg      # Just use the default operation mode.
632b698ba48Smrg      if test -z "$mode"; then
633b698ba48Smrg	if test -n "$nonopt"; then
634b698ba48Smrg	  $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
635b698ba48Smrg	else
636b698ba48Smrg	  $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
637b698ba48Smrg	fi
63809885543Smrg      fi
639b698ba48Smrg      ;;
640b698ba48Smrg    esac
64109885543Smrg  fi
64209885543Smrg
64309885543Smrg  # Only execute mode is allowed to have -dlopen flags.
64409885543Smrg  if test -n "$execute_dlfiles" && test "$mode" != execute; then
645b698ba48Smrg    $echo "$modename: unrecognized option \`-dlopen'" 1>&2
646b698ba48Smrg    $echo "$help" 1>&2
64709885543Smrg    exit $EXIT_FAILURE
64809885543Smrg  fi
64909885543Smrg
65009885543Smrg  # Change the help message to a mode-specific one.
65109885543Smrg  generic_help="$help"
652b698ba48Smrg  help="Try \`$modename --help --mode=$mode' for more information."
65309885543Smrg
654b698ba48Smrg  # These modes are in order of execution frequency so that they run quickly.
655b698ba48Smrg  case $mode in
656b698ba48Smrg  # libtool compile mode
657b698ba48Smrg  compile)
658b698ba48Smrg    modename="$modename: compile"
659b698ba48Smrg    # Get the compilation command and the source file.
660b698ba48Smrg    base_compile=
661b698ba48Smrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
662b698ba48Smrg    suppress_opt=yes
663b698ba48Smrg    suppress_output=
664b698ba48Smrg    arg_mode=normal
665b698ba48Smrg    libobj=
666b698ba48Smrg    later=
66709885543Smrg
668b698ba48Smrg    for arg
669b698ba48Smrg    do
670b698ba48Smrg      case $arg_mode in
671b698ba48Smrg      arg  )
672b698ba48Smrg	# do not "continue".  Instead, add this to base_compile
673b698ba48Smrg	lastarg="$arg"
674b698ba48Smrg	arg_mode=normal
675b698ba48Smrg	;;
67609885543Smrg
677b698ba48Smrg      target )
678b698ba48Smrg	libobj="$arg"
679b698ba48Smrg	arg_mode=normal
680b698ba48Smrg	continue
681b698ba48Smrg	;;
68209885543Smrg
683b698ba48Smrg      normal )
684b698ba48Smrg	# Accept any command-line options.
685b698ba48Smrg	case $arg in
686b698ba48Smrg	-o)
687b698ba48Smrg	  if test -n "$libobj" ; then
688b698ba48Smrg	    $echo "$modename: you cannot specify \`-o' more than once" 1>&2
689b698ba48Smrg	    exit $EXIT_FAILURE
690b698ba48Smrg	  fi
691b698ba48Smrg	  arg_mode=target
692b698ba48Smrg	  continue
693b698ba48Smrg	  ;;
69409885543Smrg
695b698ba48Smrg	-static | -prefer-pic | -prefer-non-pic)
696b698ba48Smrg	  later="$later $arg"
697b698ba48Smrg	  continue
698b698ba48Smrg	  ;;
6992ec8c4b4Smrg
7002ec8c4b4Smrg	-no-suppress)
70109885543Smrg	  suppress_opt=no
70209885543Smrg	  continue
70309885543Smrg	  ;;
70409885543Smrg
70509885543Smrg	-Xcompiler)
70609885543Smrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
70709885543Smrg	  continue      #  The current "srcfile" will either be retained or
70809885543Smrg	  ;;            #  replaced later.  I would guess that would be a bug.
70909885543Smrg
71009885543Smrg	-Wc,*)
711b698ba48Smrg	  args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
71209885543Smrg	  lastarg=
71309885543Smrg	  save_ifs="$IFS"; IFS=','
714b698ba48Smrg 	  for arg in $args; do
71509885543Smrg	    IFS="$save_ifs"
716b698ba48Smrg
717b698ba48Smrg	    # Double-quote args containing other shell metacharacters.
718b698ba48Smrg	    # Many Bourne shells cannot handle close brackets correctly
719b698ba48Smrg	    # in scan sets, so we specify it separately.
720b698ba48Smrg	    case $arg in
721b698ba48Smrg	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
722b698ba48Smrg	      arg="\"$arg\""
723b698ba48Smrg	      ;;
724b698ba48Smrg	    esac
725b698ba48Smrg	    lastarg="$lastarg $arg"
72609885543Smrg	  done
72709885543Smrg	  IFS="$save_ifs"
728b698ba48Smrg	  lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
72909885543Smrg
73009885543Smrg	  # Add the arguments to base_compile.
73109885543Smrg	  base_compile="$base_compile $lastarg"
73209885543Smrg	  continue
73309885543Smrg	  ;;
73409885543Smrg
735b698ba48Smrg	* )
73609885543Smrg	  # Accept the current argument as the source file.
73709885543Smrg	  # The previous "srcfile" becomes the current argument.
73809885543Smrg	  #
73909885543Smrg	  lastarg="$srcfile"
74009885543Smrg	  srcfile="$arg"
74109885543Smrg	  ;;
74209885543Smrg	esac  #  case $arg
74309885543Smrg	;;
74409885543Smrg      esac    #  case $arg_mode
74509885543Smrg
74609885543Smrg      # Aesthetically quote the previous argument.
747b698ba48Smrg      lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
748b698ba48Smrg
749b698ba48Smrg      case $lastarg in
750b698ba48Smrg      # Double-quote args containing other shell metacharacters.
751b698ba48Smrg      # Many Bourne shells cannot handle close brackets correctly
752b698ba48Smrg      # in scan sets, and some SunOS ksh mistreat backslash-escaping
753b698ba48Smrg      # in scan sets (worked around with variable expansion),
754b698ba48Smrg      # and furthermore cannot handle '|' '&' '(' ')' in scan sets 
755b698ba48Smrg      # at all, so we specify them separately.
756b698ba48Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
757b698ba48Smrg	lastarg="\"$lastarg\""
758b698ba48Smrg	;;
759b698ba48Smrg      esac
760b698ba48Smrg
761b698ba48Smrg      base_compile="$base_compile $lastarg"
76209885543Smrg    done # for arg
76309885543Smrg
76409885543Smrg    case $arg_mode in
76509885543Smrg    arg)
766b698ba48Smrg      $echo "$modename: you must specify an argument for -Xcompile"
767b698ba48Smrg      exit $EXIT_FAILURE
76809885543Smrg      ;;
76909885543Smrg    target)
770b698ba48Smrg      $echo "$modename: you must specify a target with \`-o'" 1>&2
771b698ba48Smrg      exit $EXIT_FAILURE
77209885543Smrg      ;;
77309885543Smrg    *)
77409885543Smrg      # Get the name of the library object.
775b698ba48Smrg      [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
77609885543Smrg      ;;
77709885543Smrg    esac
77809885543Smrg
77909885543Smrg    # Recognize several different file suffixes.
78009885543Smrg    # If the user specifies -o file.o, it is replaced with file.lo
781b698ba48Smrg    xform='[cCFSifmso]'
78209885543Smrg    case $libobj in
783b698ba48Smrg    *.ada) xform=ada ;;
784b698ba48Smrg    *.adb) xform=adb ;;
785b698ba48Smrg    *.ads) xform=ads ;;
786b698ba48Smrg    *.asm) xform=asm ;;
787b698ba48Smrg    *.c++) xform=c++ ;;
788b698ba48Smrg    *.cc) xform=cc ;;
789b698ba48Smrg    *.ii) xform=ii ;;
790b698ba48Smrg    *.class) xform=class ;;
791b698ba48Smrg    *.cpp) xform=cpp ;;
792b698ba48Smrg    *.cxx) xform=cxx ;;
793b698ba48Smrg    *.[fF][09]?) xform=[fF][09]. ;;
794b698ba48Smrg    *.for) xform=for ;;
795b698ba48Smrg    *.java) xform=java ;;
796b698ba48Smrg    *.obj) xform=obj ;;
797b698ba48Smrg    *.sx) xform=sx ;;
79809885543Smrg    esac
79909885543Smrg
800b698ba48Smrg    libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
801b698ba48Smrg
80209885543Smrg    case $libobj in
803b698ba48Smrg    *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
80409885543Smrg    *)
805b698ba48Smrg      $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
806b698ba48Smrg      exit $EXIT_FAILURE
80709885543Smrg      ;;
80809885543Smrg    esac
80909885543Smrg
81009885543Smrg    func_infer_tag $base_compile
81109885543Smrg
81209885543Smrg    for arg in $later; do
81309885543Smrg      case $arg in
81409885543Smrg      -static)
81509885543Smrg	build_old_libs=yes
81609885543Smrg	continue
81709885543Smrg	;;
81809885543Smrg
81909885543Smrg      -prefer-pic)
82009885543Smrg	pic_mode=yes
82109885543Smrg	continue
82209885543Smrg	;;
82309885543Smrg
82409885543Smrg      -prefer-non-pic)
82509885543Smrg	pic_mode=no
82609885543Smrg	continue
82709885543Smrg	;;
82809885543Smrg      esac
82909885543Smrg    done
83009885543Smrg
831b698ba48Smrg    qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"`
832b698ba48Smrg    case $qlibobj in
833b698ba48Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
834b698ba48Smrg	qlibobj="\"$qlibobj\"" ;;
835b698ba48Smrg    esac
836b698ba48Smrg    test "X$libobj" != "X$qlibobj" \
837b698ba48Smrg	&& $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"' 	&()|`$[]' \
838b698ba48Smrg	&& $echo "$modename: libobj name \`$libobj' may not contain shell special characters."
839b698ba48Smrg    objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
840b698ba48Smrg    xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
841b698ba48Smrg    if test "X$xdir" = "X$obj"; then
842b698ba48Smrg      xdir=
843b698ba48Smrg    else
844b698ba48Smrg      xdir=$xdir/
845b698ba48Smrg    fi
84609885543Smrg    lobj=${xdir}$objdir/$objname
84709885543Smrg
848b698ba48Smrg    if test -z "$base_compile"; then
849b698ba48Smrg      $echo "$modename: you must specify a compilation command" 1>&2
850b698ba48Smrg      $echo "$help" 1>&2
851b698ba48Smrg      exit $EXIT_FAILURE
852b698ba48Smrg    fi
85309885543Smrg
85409885543Smrg    # Delete any leftover library objects.
85509885543Smrg    if test "$build_old_libs" = yes; then
85609885543Smrg      removelist="$obj $lobj $libobj ${libobj}T"
85709885543Smrg    else
85809885543Smrg      removelist="$lobj $libobj ${libobj}T"
85909885543Smrg    fi
86009885543Smrg
861b698ba48Smrg    $run $rm $removelist
862b698ba48Smrg    trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
863b698ba48Smrg
86409885543Smrg    # On Cygwin there's no "real" PIC flag so we must build both object types
86509885543Smrg    case $host_os in
866b698ba48Smrg    cygwin* | mingw* | pw32* | os2*)
86709885543Smrg      pic_mode=default
86809885543Smrg      ;;
86909885543Smrg    esac
87009885543Smrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
87109885543Smrg      # non-PIC code in shared libraries is not supported
87209885543Smrg      pic_mode=default
87309885543Smrg    fi
87409885543Smrg
87509885543Smrg    # Calculate the filename of the output object if compiler does
87609885543Smrg    # not support -o with -c
87709885543Smrg    if test "$compiler_c_o" = no; then
878b698ba48Smrg      output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
87909885543Smrg      lockfile="$output_obj.lock"
880b698ba48Smrg      removelist="$removelist $output_obj $lockfile"
881b698ba48Smrg      trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
88209885543Smrg    else
88309885543Smrg      output_obj=
88409885543Smrg      need_locks=no
88509885543Smrg      lockfile=
88609885543Smrg    fi
88709885543Smrg
88809885543Smrg    # Lock this critical section if it is needed
88909885543Smrg    # We use this script file to make the link, it avoids creating a new file
89009885543Smrg    if test "$need_locks" = yes; then
891b698ba48Smrg      until $run ln "$progpath" "$lockfile" 2>/dev/null; do
892b698ba48Smrg	$show "Waiting for $lockfile to be removed"
89309885543Smrg	sleep 2
89409885543Smrg      done
89509885543Smrg    elif test "$need_locks" = warn; then
89609885543Smrg      if test -f "$lockfile"; then
897b698ba48Smrg	$echo "\
89809885543Smrg*** ERROR, $lockfile exists and contains:
89909885543Smrg`cat $lockfile 2>/dev/null`
90009885543Smrg
90109885543SmrgThis indicates that another process is trying to use the same
90209885543Smrgtemporary object file, and libtool could not work around it because
90309885543Smrgyour compiler does not support \`-c' and \`-o' together.  If you
90409885543Smrgrepeat this compilation, it may succeed, by chance, but you had better
90509885543Smrgavoid parallel builds (make -j) in this platform, or get a better
90609885543Smrgcompiler."
90709885543Smrg
908b698ba48Smrg	$run $rm $removelist
90909885543Smrg	exit $EXIT_FAILURE
91009885543Smrg      fi
911b698ba48Smrg      $echo "$srcfile" > "$lockfile"
91209885543Smrg    fi
91309885543Smrg
91409885543Smrg    if test -n "$fix_srcfile_path"; then
91509885543Smrg      eval srcfile=\"$fix_srcfile_path\"
91609885543Smrg    fi
917b698ba48Smrg    qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"`
918b698ba48Smrg    case $qsrcfile in
919b698ba48Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
920b698ba48Smrg      qsrcfile="\"$qsrcfile\"" ;;
921b698ba48Smrg    esac
922b698ba48Smrg
923b698ba48Smrg    $run $rm "$libobj" "${libobj}T"
924b698ba48Smrg
925b698ba48Smrg    # Create a libtool object file (analogous to a ".la" file),
926b698ba48Smrg    # but don't create it if we're doing a dry run.
927b698ba48Smrg    test -z "$run" && cat > ${libobj}T <<EOF
928b698ba48Smrg# $libobj - a libtool object file
929b698ba48Smrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
930b698ba48Smrg#
931b698ba48Smrg# Please DO NOT delete this file!
932b698ba48Smrg# It is necessary for linking the library.
933b698ba48Smrg
934b698ba48Smrg# Name of the PIC object.
935b698ba48SmrgEOF
93609885543Smrg
93709885543Smrg    # Only build a PIC object if we are building libtool libraries.
93809885543Smrg    if test "$build_libtool_libs" = yes; then
93909885543Smrg      # Without this assignment, base_compile gets emptied.
94009885543Smrg      fbsd_hideous_sh_bug=$base_compile
94109885543Smrg
94209885543Smrg      if test "$pic_mode" != no; then
94309885543Smrg	command="$base_compile $qsrcfile $pic_flag"
94409885543Smrg      else
94509885543Smrg	# Don't build PIC code
94609885543Smrg	command="$base_compile $qsrcfile"
94709885543Smrg      fi
94809885543Smrg
949b698ba48Smrg      if test ! -d "${xdir}$objdir"; then
950b698ba48Smrg	$show "$mkdir ${xdir}$objdir"
951b698ba48Smrg	$run $mkdir ${xdir}$objdir
952b698ba48Smrg	exit_status=$?
953b698ba48Smrg	if test "$exit_status" -ne 0 && test ! -d "${xdir}$objdir"; then
954b698ba48Smrg	  exit $exit_status
955b698ba48Smrg	fi
956b698ba48Smrg      fi
95709885543Smrg
95809885543Smrg      if test -z "$output_obj"; then
95909885543Smrg	# Place PIC objects in $objdir
96009885543Smrg	command="$command -o $lobj"
96109885543Smrg      fi
96209885543Smrg
963b698ba48Smrg      $run $rm "$lobj" "$output_obj"
964b698ba48Smrg
965b698ba48Smrg      $show "$command"
966b698ba48Smrg      if $run eval $lt_env "$command"; then :
967b698ba48Smrg      else
968b698ba48Smrg	test -n "$output_obj" && $run $rm $removelist
969b698ba48Smrg	exit $EXIT_FAILURE
970b698ba48Smrg      fi
97109885543Smrg
97209885543Smrg      if test "$need_locks" = warn &&
97309885543Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
974b698ba48Smrg	$echo "\
97509885543Smrg*** ERROR, $lockfile contains:
97609885543Smrg`cat $lockfile 2>/dev/null`
97709885543Smrg
97809885543Smrgbut it should contain:
97909885543Smrg$srcfile
98009885543Smrg
98109885543SmrgThis indicates that another process is trying to use the same
98209885543Smrgtemporary object file, and libtool could not work around it because
98309885543Smrgyour compiler does not support \`-c' and \`-o' together.  If you
98409885543Smrgrepeat this compilation, it may succeed, by chance, but you had better
98509885543Smrgavoid parallel builds (make -j) in this platform, or get a better
98609885543Smrgcompiler."
98709885543Smrg
988b698ba48Smrg	$run $rm $removelist
98909885543Smrg	exit $EXIT_FAILURE
99009885543Smrg      fi
99109885543Smrg
99209885543Smrg      # Just move the object if needed, then go on to compile the next one
99309885543Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
994b698ba48Smrg	$show "$mv $output_obj $lobj"
995b698ba48Smrg	if $run $mv $output_obj $lobj; then :
996b698ba48Smrg	else
997b698ba48Smrg	  error=$?
998b698ba48Smrg	  $run $rm $removelist
999b698ba48Smrg	  exit $error
1000b698ba48Smrg	fi
100109885543Smrg      fi
100209885543Smrg
1003b698ba48Smrg      # Append the name of the PIC object to the libtool object file.
1004b698ba48Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
1005b698ba48Smrgpic_object='$objdir/$objname'
1006b698ba48Smrg
1007b698ba48SmrgEOF
1008b698ba48Smrg
100909885543Smrg      # Allow error messages only from the first compilation.
101009885543Smrg      if test "$suppress_opt" = yes; then
1011b698ba48Smrg        suppress_output=' >/dev/null 2>&1'
101209885543Smrg      fi
1013b698ba48Smrg    else
1014b698ba48Smrg      # No PIC object so indicate it doesn't exist in the libtool
1015b698ba48Smrg      # object file.
1016b698ba48Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
1017b698ba48Smrgpic_object=none
1018b698ba48Smrg
1019b698ba48SmrgEOF
102009885543Smrg    fi
102109885543Smrg
102209885543Smrg    # Only build a position-dependent object if we build old libraries.
102309885543Smrg    if test "$build_old_libs" = yes; then
102409885543Smrg      if test "$pic_mode" != yes; then
102509885543Smrg	# Don't build PIC code
1026b698ba48Smrg	command="$base_compile $qsrcfile"
102709885543Smrg      else
102809885543Smrg	command="$base_compile $qsrcfile $pic_flag"
102909885543Smrg      fi
103009885543Smrg      if test "$compiler_c_o" = yes; then
103109885543Smrg	command="$command -o $obj"
103209885543Smrg      fi
103309885543Smrg
103409885543Smrg      # Suppress compiler output if we already did a PIC compilation.
103509885543Smrg      command="$command$suppress_output"
1036b698ba48Smrg      $run $rm "$obj" "$output_obj"
1037b698ba48Smrg      $show "$command"
1038b698ba48Smrg      if $run eval $lt_env "$command"; then :
1039b698ba48Smrg      else
1040b698ba48Smrg	$run $rm $removelist
1041b698ba48Smrg	exit $EXIT_FAILURE
1042b698ba48Smrg      fi
104309885543Smrg
104409885543Smrg      if test "$need_locks" = warn &&
104509885543Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
1046b698ba48Smrg	$echo "\
104709885543Smrg*** ERROR, $lockfile contains:
104809885543Smrg`cat $lockfile 2>/dev/null`
104909885543Smrg
105009885543Smrgbut it should contain:
105109885543Smrg$srcfile
105209885543Smrg
105309885543SmrgThis indicates that another process is trying to use the same
105409885543Smrgtemporary object file, and libtool could not work around it because
105509885543Smrgyour compiler does not support \`-c' and \`-o' together.  If you
105609885543Smrgrepeat this compilation, it may succeed, by chance, but you had better
105709885543Smrgavoid parallel builds (make -j) in this platform, or get a better
105809885543Smrgcompiler."
105909885543Smrg
1060b698ba48Smrg	$run $rm $removelist
106109885543Smrg	exit $EXIT_FAILURE
106209885543Smrg      fi
106309885543Smrg
106409885543Smrg      # Just move the object if needed
106509885543Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
1066b698ba48Smrg	$show "$mv $output_obj $obj"
1067b698ba48Smrg	if $run $mv $output_obj $obj; then :
1068b698ba48Smrg	else
1069b698ba48Smrg	  error=$?
1070b698ba48Smrg	  $run $rm $removelist
1071b698ba48Smrg	  exit $error
1072b698ba48Smrg	fi
107309885543Smrg      fi
1074b698ba48Smrg
1075b698ba48Smrg      # Append the name of the non-PIC object the libtool object file.
1076b698ba48Smrg      # Only append if the libtool object file exists.
1077b698ba48Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
1078b698ba48Smrg# Name of the non-PIC object.
1079b698ba48Smrgnon_pic_object='$objname'
1080b698ba48Smrg
1081b698ba48SmrgEOF
1082b698ba48Smrg    else
1083b698ba48Smrg      # Append the name of the non-PIC object the libtool object file.
1084b698ba48Smrg      # Only append if the libtool object file exists.
1085b698ba48Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
1086b698ba48Smrg# Name of the non-PIC object.
1087b698ba48Smrgnon_pic_object=none
1088b698ba48Smrg
1089b698ba48SmrgEOF
109009885543Smrg    fi
109109885543Smrg
1092b698ba48Smrg    $run $mv "${libobj}T" "${libobj}"
109309885543Smrg
1094b698ba48Smrg    # Unlock the critical section if it was locked
1095b698ba48Smrg    if test "$need_locks" != no; then
1096b698ba48Smrg      $run $rm "$lockfile"
1097b698ba48Smrg    fi
109809885543Smrg
109909885543Smrg    exit $EXIT_SUCCESS
1100b698ba48Smrg    ;;
110109885543Smrg
1102b698ba48Smrg  # libtool link mode
1103b698ba48Smrg  link | relink)
1104b698ba48Smrg    modename="$modename: link"
1105b698ba48Smrg    case $host in
1106b698ba48Smrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
1107b698ba48Smrg      # It is impossible to link a dll without this setting, and
1108b698ba48Smrg      # we shouldn't force the makefile maintainer to figure out
1109b698ba48Smrg      # which system we are compiling for in order to pass an extra
1110b698ba48Smrg      # flag for every libtool invocation.
1111b698ba48Smrg      # allow_undefined=no
111209885543Smrg
1113b698ba48Smrg      # FIXME: Unfortunately, there are problems with the above when trying
1114b698ba48Smrg      # to make a dll which has undefined symbols, in which case not
1115b698ba48Smrg      # even a static library is built.  For now, we need to specify
1116b698ba48Smrg      # -no-undefined on the libtool link line when we can be certain
1117b698ba48Smrg      # that all symbols are satisfied, otherwise we get a static library.
1118b698ba48Smrg      allow_undefined=yes
1119b698ba48Smrg      ;;
1120b698ba48Smrg    *)
1121b698ba48Smrg      allow_undefined=yes
1122b698ba48Smrg      ;;
1123b698ba48Smrg    esac
1124b698ba48Smrg    libtool_args="$nonopt"
1125b698ba48Smrg    base_compile="$nonopt $@"
1126b698ba48Smrg    compile_command="$nonopt"
1127b698ba48Smrg    finalize_command="$nonopt"
112809885543Smrg
1129b698ba48Smrg    compile_rpath=
1130b698ba48Smrg    finalize_rpath=
1131b698ba48Smrg    compile_shlibpath=
1132b698ba48Smrg    finalize_shlibpath=
1133b698ba48Smrg    convenience=
1134b698ba48Smrg    old_convenience=
1135b698ba48Smrg    deplibs=
1136b698ba48Smrg    old_deplibs=
1137b698ba48Smrg    compiler_flags=
1138b698ba48Smrg    linker_flags=
1139b698ba48Smrg    dllsearchpath=
1140b698ba48Smrg    lib_search_path=`pwd`
1141b698ba48Smrg    inst_prefix_dir=
114209885543Smrg
1143b698ba48Smrg    avoid_version=no
1144b698ba48Smrg    dlfiles=
1145b698ba48Smrg    dlprefiles=
1146b698ba48Smrg    dlself=no
1147b698ba48Smrg    export_dynamic=no
1148b698ba48Smrg    export_symbols=
1149b698ba48Smrg    export_symbols_regex=
1150b698ba48Smrg    generated=
1151b698ba48Smrg    libobjs=
1152b698ba48Smrg    ltlibs=
1153b698ba48Smrg    module=no
1154b698ba48Smrg    no_install=no
1155b698ba48Smrg    objs=
1156b698ba48Smrg    non_pic_objects=
1157b698ba48Smrg    notinst_path= # paths that contain not-installed libtool libraries
1158b698ba48Smrg    precious_files_regex=
1159b698ba48Smrg    prefer_static_libs=no
1160b698ba48Smrg    preload=no
1161b698ba48Smrg    prev=
1162b698ba48Smrg    prevarg=
1163b698ba48Smrg    release=
1164b698ba48Smrg    rpath=
1165b698ba48Smrg    xrpath=
1166b698ba48Smrg    perm_rpath=
1167b698ba48Smrg    temp_rpath=
1168b698ba48Smrg    thread_safe=no
1169b698ba48Smrg    vinfo=
1170b698ba48Smrg    vinfo_number=no
1171b698ba48Smrg    single_module="${wl}-single_module"
117209885543Smrg
1173b698ba48Smrg    func_infer_tag $base_compile
117409885543Smrg
1175b698ba48Smrg    # We need to know -static, to get the right output filenames.
1176b698ba48Smrg    for arg
1177b698ba48Smrg    do
1178b698ba48Smrg      case $arg in
1179b698ba48Smrg      -all-static | -static | -static-libtool-libs)
1180b698ba48Smrg	case $arg in
1181b698ba48Smrg	-all-static)
1182b698ba48Smrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
1183b698ba48Smrg	    $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
1184b698ba48Smrg	  fi
1185b698ba48Smrg	  if test -n "$link_static_flag"; then
1186b698ba48Smrg	    dlopen_self=$dlopen_self_static
1187b698ba48Smrg	  fi
1188b698ba48Smrg	  prefer_static_libs=yes
1189b698ba48Smrg	  ;;
1190b698ba48Smrg	-static)
1191b698ba48Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
1192b698ba48Smrg	    dlopen_self=$dlopen_self_static
1193b698ba48Smrg	  fi
1194b698ba48Smrg	  prefer_static_libs=built
1195b698ba48Smrg	  ;;
1196b698ba48Smrg	-static-libtool-libs)
1197b698ba48Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
1198b698ba48Smrg	    dlopen_self=$dlopen_self_static
1199b698ba48Smrg	  fi
1200b698ba48Smrg	  prefer_static_libs=yes
1201b698ba48Smrg	  ;;
1202b698ba48Smrg	esac
1203b698ba48Smrg	build_libtool_libs=no
1204b698ba48Smrg	build_old_libs=yes
1205b698ba48Smrg	break
1206b698ba48Smrg	;;
1207b698ba48Smrg      esac
1208b698ba48Smrg    done
120909885543Smrg
1210b698ba48Smrg    # See if our shared archives depend on static archives.
1211b698ba48Smrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
121209885543Smrg
1213b698ba48Smrg    # Go through the arguments, transforming them on the way.
1214b698ba48Smrg    while test "$#" -gt 0; do
1215b698ba48Smrg      arg="$1"
1216b698ba48Smrg      shift
1217b698ba48Smrg      case $arg in
1218b698ba48Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1219b698ba48Smrg	qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test
1220b698ba48Smrg	;;
1221b698ba48Smrg      *) qarg=$arg ;;
1222b698ba48Smrg      esac
1223b698ba48Smrg      libtool_args="$libtool_args $qarg"
122409885543Smrg
1225b698ba48Smrg      # If the previous option needs an argument, assign it.
1226b698ba48Smrg      if test -n "$prev"; then
1227b698ba48Smrg	case $prev in
1228b698ba48Smrg	output)
1229b698ba48Smrg	  compile_command="$compile_command @OUTPUT@"
1230b698ba48Smrg	  finalize_command="$finalize_command @OUTPUT@"
1231b698ba48Smrg	  ;;
1232b698ba48Smrg	esac
123309885543Smrg
1234b698ba48Smrg	case $prev in
1235b698ba48Smrg	dlfiles|dlprefiles)
1236b698ba48Smrg	  if test "$preload" = no; then
1237b698ba48Smrg	    # Add the symbol object into the linking commands.
1238b698ba48Smrg	    compile_command="$compile_command @SYMFILE@"
1239b698ba48Smrg	    finalize_command="$finalize_command @SYMFILE@"
1240b698ba48Smrg	    preload=yes
1241b698ba48Smrg	  fi
1242b698ba48Smrg	  case $arg in
1243b698ba48Smrg	  *.la | *.lo) ;;  # We handle these cases below.
1244b698ba48Smrg	  force)
1245b698ba48Smrg	    if test "$dlself" = no; then
1246b698ba48Smrg	      dlself=needless
1247b698ba48Smrg	      export_dynamic=yes
1248b698ba48Smrg	    fi
1249b698ba48Smrg	    prev=
1250b698ba48Smrg	    continue
1251b698ba48Smrg	    ;;
1252b698ba48Smrg	  self)
1253b698ba48Smrg	    if test "$prev" = dlprefiles; then
1254b698ba48Smrg	      dlself=yes
1255b698ba48Smrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
1256b698ba48Smrg	      dlself=yes
1257b698ba48Smrg	    else
1258b698ba48Smrg	      dlself=needless
1259b698ba48Smrg	      export_dynamic=yes
1260b698ba48Smrg	    fi
1261b698ba48Smrg	    prev=
1262b698ba48Smrg	    continue
1263b698ba48Smrg	    ;;
1264b698ba48Smrg	  *)
1265b698ba48Smrg	    if test "$prev" = dlfiles; then
1266b698ba48Smrg	      dlfiles="$dlfiles $arg"
1267b698ba48Smrg	    else
1268b698ba48Smrg	      dlprefiles="$dlprefiles $arg"
1269b698ba48Smrg	    fi
1270b698ba48Smrg	    prev=
1271b698ba48Smrg	    continue
1272b698ba48Smrg	    ;;
1273b698ba48Smrg	  esac
1274b698ba48Smrg	  ;;
1275b698ba48Smrg	expsyms)
1276b698ba48Smrg	  export_symbols="$arg"
1277b698ba48Smrg	  if test ! -f "$arg"; then
1278b698ba48Smrg	    $echo "$modename: symbol file \`$arg' does not exist"
1279b698ba48Smrg	    exit $EXIT_FAILURE
1280b698ba48Smrg	  fi
1281b698ba48Smrg	  prev=
1282b698ba48Smrg	  continue
1283b698ba48Smrg	  ;;
1284b698ba48Smrg	expsyms_regex)
1285b698ba48Smrg	  export_symbols_regex="$arg"
1286b698ba48Smrg	  prev=
1287b698ba48Smrg	  continue
1288b698ba48Smrg	  ;;
1289b698ba48Smrg	inst_prefix)
1290b698ba48Smrg	  inst_prefix_dir="$arg"
1291b698ba48Smrg	  prev=
1292b698ba48Smrg	  continue
1293b698ba48Smrg	  ;;
1294b698ba48Smrg	precious_regex)
1295b698ba48Smrg	  precious_files_regex="$arg"
1296b698ba48Smrg	  prev=
1297b698ba48Smrg	  continue
1298b698ba48Smrg	  ;;
1299b698ba48Smrg	release)
1300b698ba48Smrg	  release="-$arg"
1301b698ba48Smrg	  prev=
1302b698ba48Smrg	  continue
1303b698ba48Smrg	  ;;
1304b698ba48Smrg	objectlist)
1305b698ba48Smrg	  if test -f "$arg"; then
1306b698ba48Smrg	    save_arg=$arg
1307b698ba48Smrg	    moreargs=
1308b698ba48Smrg	    for fil in `cat $save_arg`
1309b698ba48Smrg	    do
1310b698ba48Smrg#	      moreargs="$moreargs $fil"
1311b698ba48Smrg	      arg=$fil
1312b698ba48Smrg	      # A libtool-controlled object.
131309885543Smrg
1314b698ba48Smrg	      # Check to see that this really is a libtool object.
1315b698ba48Smrg	      if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
1316b698ba48Smrg		pic_object=
1317b698ba48Smrg		non_pic_object=
131809885543Smrg
1319b698ba48Smrg		# Read the .lo file
1320b698ba48Smrg		# If there is no directory component, then add one.
1321b698ba48Smrg		case $arg in
1322b698ba48Smrg		*/* | *\\*) . $arg ;;
1323b698ba48Smrg		*) . ./$arg ;;
1324b698ba48Smrg		esac
132509885543Smrg
1326b698ba48Smrg		if test -z "$pic_object" || \
1327b698ba48Smrg		   test -z "$non_pic_object" ||
1328b698ba48Smrg		   test "$pic_object" = none && \
1329b698ba48Smrg		   test "$non_pic_object" = none; then
1330b698ba48Smrg		  $echo "$modename: cannot find name of object for \`$arg'" 1>&2
1331b698ba48Smrg		  exit $EXIT_FAILURE
1332b698ba48Smrg		fi
133309885543Smrg
1334b698ba48Smrg		# Extract subdirectory from the argument.
1335b698ba48Smrg		xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1336b698ba48Smrg		if test "X$xdir" = "X$arg"; then
1337b698ba48Smrg		  xdir=
1338b698ba48Smrg		else
1339b698ba48Smrg		  xdir="$xdir/"
1340b698ba48Smrg		fi
134109885543Smrg
1342b698ba48Smrg		if test "$pic_object" != none; then
1343b698ba48Smrg		  # Prepend the subdirectory the object is found in.
1344b698ba48Smrg		  pic_object="$xdir$pic_object"
134509885543Smrg
1346b698ba48Smrg		  if test "$prev" = dlfiles; then
1347b698ba48Smrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
1348b698ba48Smrg		      dlfiles="$dlfiles $pic_object"
1349b698ba48Smrg		      prev=
1350b698ba48Smrg		      continue
1351b698ba48Smrg		    else
1352b698ba48Smrg		      # If libtool objects are unsupported, then we need to preload.
1353b698ba48Smrg		      prev=dlprefiles
1354b698ba48Smrg		    fi
1355b698ba48Smrg		  fi
135609885543Smrg
1357b698ba48Smrg		  # CHECK ME:  I think I busted this.  -Ossama
1358b698ba48Smrg		  if test "$prev" = dlprefiles; then
1359b698ba48Smrg		    # Preload the old-style object.
1360b698ba48Smrg		    dlprefiles="$dlprefiles $pic_object"
1361b698ba48Smrg		    prev=
1362b698ba48Smrg		  fi
136309885543Smrg
1364b698ba48Smrg		  # A PIC object.
1365b698ba48Smrg		  libobjs="$libobjs $pic_object"
1366b698ba48Smrg		  arg="$pic_object"
1367b698ba48Smrg		fi
136809885543Smrg
1369b698ba48Smrg		# Non-PIC object.
1370b698ba48Smrg		if test "$non_pic_object" != none; then
1371b698ba48Smrg		  # Prepend the subdirectory the object is found in.
1372b698ba48Smrg		  non_pic_object="$xdir$non_pic_object"
137309885543Smrg
1374b698ba48Smrg		  # A standard non-PIC object
1375b698ba48Smrg		  non_pic_objects="$non_pic_objects $non_pic_object"
1376b698ba48Smrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
1377b698ba48Smrg		    arg="$non_pic_object"
1378b698ba48Smrg		  fi
1379b698ba48Smrg		else
1380b698ba48Smrg		  # If the PIC object exists, use it instead.
1381b698ba48Smrg		  # $xdir was prepended to $pic_object above.
1382b698ba48Smrg		  non_pic_object="$pic_object"
1383b698ba48Smrg		  non_pic_objects="$non_pic_objects $non_pic_object"
1384b698ba48Smrg		fi
1385b698ba48Smrg	      else
1386b698ba48Smrg		# Only an error if not doing a dry-run.
1387b698ba48Smrg		if test -z "$run"; then
1388b698ba48Smrg		  $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
1389b698ba48Smrg		  exit $EXIT_FAILURE
1390b698ba48Smrg		else
1391b698ba48Smrg		  # Dry-run case.
139209885543Smrg
1393b698ba48Smrg		  # Extract subdirectory from the argument.
1394b698ba48Smrg		  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1395b698ba48Smrg		  if test "X$xdir" = "X$arg"; then
1396b698ba48Smrg		    xdir=
1397b698ba48Smrg		  else
1398b698ba48Smrg		    xdir="$xdir/"
1399b698ba48Smrg		  fi
140009885543Smrg
1401b698ba48Smrg		  pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
1402b698ba48Smrg		  non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
1403b698ba48Smrg		  libobjs="$libobjs $pic_object"
1404b698ba48Smrg		  non_pic_objects="$non_pic_objects $non_pic_object"
1405b698ba48Smrg		fi
1406b698ba48Smrg	      fi
1407b698ba48Smrg	    done
1408b698ba48Smrg	  else
1409b698ba48Smrg	    $echo "$modename: link input file \`$save_arg' does not exist"
1410b698ba48Smrg	    exit $EXIT_FAILURE
1411b698ba48Smrg	  fi
1412b698ba48Smrg	  arg=$save_arg
1413b698ba48Smrg	  prev=
1414b698ba48Smrg	  continue
1415b698ba48Smrg	  ;;
1416b698ba48Smrg	rpath | xrpath)
1417b698ba48Smrg	  # We need an absolute path.
1418b698ba48Smrg	  case $arg in
1419b698ba48Smrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
1420b698ba48Smrg	  *)
1421b698ba48Smrg	    $echo "$modename: only absolute run-paths are allowed" 1>&2
1422b698ba48Smrg	    exit $EXIT_FAILURE
1423b698ba48Smrg	    ;;
1424b698ba48Smrg	  esac
1425b698ba48Smrg	  if test "$prev" = rpath; then
1426b698ba48Smrg	    case "$rpath " in
1427b698ba48Smrg	    *" $arg "*) ;;
1428b698ba48Smrg	    *) rpath="$rpath $arg" ;;
1429b698ba48Smrg	    esac
1430b698ba48Smrg	  else
1431b698ba48Smrg	    case "$xrpath " in
1432b698ba48Smrg	    *" $arg "*) ;;
1433b698ba48Smrg	    *) xrpath="$xrpath $arg" ;;
1434b698ba48Smrg	    esac
1435b698ba48Smrg	  fi
1436b698ba48Smrg	  prev=
1437b698ba48Smrg	  continue
1438b698ba48Smrg	  ;;
1439b698ba48Smrg	xcompiler)
1440b698ba48Smrg	  compiler_flags="$compiler_flags $qarg"
1441b698ba48Smrg	  prev=
1442b698ba48Smrg	  compile_command="$compile_command $qarg"
1443b698ba48Smrg	  finalize_command="$finalize_command $qarg"
1444b698ba48Smrg	  continue
1445b698ba48Smrg	  ;;
1446b698ba48Smrg	xlinker)
1447b698ba48Smrg	  linker_flags="$linker_flags $qarg"
1448b698ba48Smrg	  compiler_flags="$compiler_flags $wl$qarg"
1449b698ba48Smrg	  prev=
1450b698ba48Smrg	  compile_command="$compile_command $wl$qarg"
1451b698ba48Smrg	  finalize_command="$finalize_command $wl$qarg"
1452b698ba48Smrg	  continue
1453b698ba48Smrg	  ;;
1454b698ba48Smrg	xcclinker)
1455b698ba48Smrg	  linker_flags="$linker_flags $qarg"
1456b698ba48Smrg	  compiler_flags="$compiler_flags $qarg"
1457b698ba48Smrg	  prev=
1458b698ba48Smrg	  compile_command="$compile_command $qarg"
1459b698ba48Smrg	  finalize_command="$finalize_command $qarg"
1460b698ba48Smrg	  continue
1461b698ba48Smrg	  ;;
1462b698ba48Smrg	shrext)
1463b698ba48Smrg  	  shrext_cmds="$arg"
1464b698ba48Smrg	  prev=
1465b698ba48Smrg	  continue
1466b698ba48Smrg	  ;;
1467b698ba48Smrg	darwin_framework|darwin_framework_skip)
1468b698ba48Smrg	  test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg"
1469b698ba48Smrg	  compile_command="$compile_command $arg"
1470b698ba48Smrg	  finalize_command="$finalize_command $arg"
1471b698ba48Smrg	  prev=
1472b698ba48Smrg	  continue
1473b698ba48Smrg	  ;;
1474b698ba48Smrg	*)
1475b698ba48Smrg	  eval "$prev=\"\$arg\""
1476b698ba48Smrg	  prev=
1477b698ba48Smrg	  continue
1478b698ba48Smrg	  ;;
1479b698ba48Smrg	esac
1480b698ba48Smrg      fi # test -n "$prev"
148109885543Smrg
1482b698ba48Smrg      prevarg="$arg"
148309885543Smrg
1484b698ba48Smrg      case $arg in
1485b698ba48Smrg      -all-static)
1486b698ba48Smrg	if test -n "$link_static_flag"; then
1487b698ba48Smrg	  compile_command="$compile_command $link_static_flag"
1488b698ba48Smrg	  finalize_command="$finalize_command $link_static_flag"
1489b698ba48Smrg	fi
1490b698ba48Smrg	continue
1491b698ba48Smrg	;;
149209885543Smrg
1493b698ba48Smrg      -allow-undefined)
1494b698ba48Smrg	# FIXME: remove this flag sometime in the future.
1495b698ba48Smrg	$echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
1496b698ba48Smrg	continue
1497b698ba48Smrg	;;
149809885543Smrg
1499b698ba48Smrg      -avoid-version)
1500b698ba48Smrg	avoid_version=yes
1501b698ba48Smrg	continue
1502b698ba48Smrg	;;
150309885543Smrg
1504b698ba48Smrg      -dlopen)
1505b698ba48Smrg	prev=dlfiles
1506b698ba48Smrg	continue
1507b698ba48Smrg	;;
150809885543Smrg
1509b698ba48Smrg      -dlpreopen)
1510b698ba48Smrg	prev=dlprefiles
1511b698ba48Smrg	continue
1512b698ba48Smrg	;;
151309885543Smrg
1514b698ba48Smrg      -export-dynamic)
1515b698ba48Smrg	export_dynamic=yes
1516b698ba48Smrg	continue
1517b698ba48Smrg	;;
151809885543Smrg
1519b698ba48Smrg      -export-symbols | -export-symbols-regex)
1520b698ba48Smrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
1521b698ba48Smrg	  $echo "$modename: more than one -exported-symbols argument is not allowed"
1522b698ba48Smrg	  exit $EXIT_FAILURE
1523b698ba48Smrg	fi
1524b698ba48Smrg	if test "X$arg" = "X-export-symbols"; then
1525b698ba48Smrg	  prev=expsyms
1526b698ba48Smrg	else
1527b698ba48Smrg	  prev=expsyms_regex
1528b698ba48Smrg	fi
1529b698ba48Smrg	continue
1530b698ba48Smrg	;;
153109885543Smrg
1532b698ba48Smrg      -framework|-arch|-isysroot)
1533b698ba48Smrg	case " $CC " in
1534b698ba48Smrg	  *" ${arg} ${1} "* | *" ${arg}	${1} "*) 
1535b698ba48Smrg		prev=darwin_framework_skip ;;
1536b698ba48Smrg	  *) compiler_flags="$compiler_flags $arg"
1537b698ba48Smrg	     prev=darwin_framework ;;
1538b698ba48Smrg	esac
1539b698ba48Smrg	compile_command="$compile_command $arg"
1540b698ba48Smrg	finalize_command="$finalize_command $arg"
1541b698ba48Smrg	continue
1542b698ba48Smrg	;;
154309885543Smrg
1544b698ba48Smrg      -inst-prefix-dir)
1545b698ba48Smrg	prev=inst_prefix
1546b698ba48Smrg	continue
1547b698ba48Smrg	;;
154809885543Smrg
1549b698ba48Smrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
1550b698ba48Smrg      # so, if we see these flags be careful not to treat them like -L
1551b698ba48Smrg      -L[A-Z][A-Z]*:*)
1552b698ba48Smrg	case $with_gcc/$host in
1553b698ba48Smrg	no/*-*-irix* | /*-*-irix*)
1554b698ba48Smrg	  compile_command="$compile_command $arg"
1555b698ba48Smrg	  finalize_command="$finalize_command $arg"
1556b698ba48Smrg	  ;;
1557b698ba48Smrg	esac
1558b698ba48Smrg	continue
1559b698ba48Smrg	;;
156009885543Smrg
1561b698ba48Smrg      -L*)
1562b698ba48Smrg	dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
1563b698ba48Smrg	# We need an absolute path.
1564b698ba48Smrg	case $dir in
1565b698ba48Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
1566b698ba48Smrg	*)
1567b698ba48Smrg	  absdir=`cd "$dir" && pwd`
1568b698ba48Smrg	  if test -z "$absdir"; then
1569b698ba48Smrg	    $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
1570b698ba48Smrg	    absdir="$dir"
1571b698ba48Smrg	    notinst_path="$notinst_path $dir"
1572b698ba48Smrg	  fi
1573b698ba48Smrg	  dir="$absdir"
1574b698ba48Smrg	  ;;
1575b698ba48Smrg	esac
1576b698ba48Smrg	case "$deplibs " in
1577b698ba48Smrg	*" -L$dir "*) ;;
1578b698ba48Smrg	*)
1579b698ba48Smrg	  deplibs="$deplibs -L$dir"
1580b698ba48Smrg	  lib_search_path="$lib_search_path $dir"
1581b698ba48Smrg	  ;;
1582b698ba48Smrg	esac
1583b698ba48Smrg	case $host in
1584b698ba48Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
1585b698ba48Smrg	  testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'`
1586b698ba48Smrg	  case :$dllsearchpath: in
1587b698ba48Smrg	  *":$dir:"*) ;;
1588b698ba48Smrg	  *) dllsearchpath="$dllsearchpath:$dir";;
1589b698ba48Smrg	  esac
1590b698ba48Smrg	  case :$dllsearchpath: in
1591b698ba48Smrg	  *":$testbindir:"*) ;;
1592b698ba48Smrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
1593b698ba48Smrg	  esac
1594b698ba48Smrg	  ;;
1595b698ba48Smrg	esac
1596b698ba48Smrg	continue
1597b698ba48Smrg	;;
159809885543Smrg
1599b698ba48Smrg      -l*)
1600b698ba48Smrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
1601b698ba48Smrg	  case $host in
1602b698ba48Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*)
1603b698ba48Smrg	    # These systems don't actually have a C or math library (as such)
1604b698ba48Smrg	    continue
1605b698ba48Smrg	    ;;
1606b698ba48Smrg	  *-*-os2*)
1607b698ba48Smrg	    # These systems don't actually have a C library (as such)
1608b698ba48Smrg	    test "X$arg" = "X-lc" && continue
1609b698ba48Smrg	    ;;
1610b698ba48Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
1611b698ba48Smrg	    # Do not include libc due to us having libc/libc_r.
1612b698ba48Smrg	    test "X$arg" = "X-lc" && continue
1613b698ba48Smrg	    ;;
1614b698ba48Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
1615b698ba48Smrg	    # Rhapsody C and math libraries are in the System framework
1616b698ba48Smrg	    deplibs="$deplibs -framework System"
1617b698ba48Smrg	    continue
1618b698ba48Smrg	    ;;
1619b698ba48Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
1620b698ba48Smrg	    # Causes problems with __ctype
1621b698ba48Smrg	    test "X$arg" = "X-lc" && continue
1622b698ba48Smrg	    ;;
1623b698ba48Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
1624b698ba48Smrg	    # Compiler inserts libc in the correct place for threads to work
1625b698ba48Smrg	    test "X$arg" = "X-lc" && continue
1626b698ba48Smrg	    ;;
1627b698ba48Smrg	  esac
1628b698ba48Smrg	elif test "X$arg" = "X-lc_r"; then
1629b698ba48Smrg	 case $host in
1630b698ba48Smrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
1631b698ba48Smrg	   # Do not include libc_r directly, use -pthread flag.
1632b698ba48Smrg	   continue
1633b698ba48Smrg	   ;;
1634b698ba48Smrg	 esac
16352ec8c4b4Smrg	fi
1636b698ba48Smrg	deplibs="$deplibs $arg"
1637b698ba48Smrg	continue
1638b698ba48Smrg	;;
163909885543Smrg
1640b698ba48Smrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
1641b698ba48Smrg      # classes, name mangling, and exception handling.
1642b698ba48Smrg      -model)
1643b698ba48Smrg	compile_command="$compile_command $arg"
1644b698ba48Smrg	compiler_flags="$compiler_flags $arg"
1645b698ba48Smrg	finalize_command="$finalize_command $arg"
1646b698ba48Smrg	prev=xcompiler
1647b698ba48Smrg	continue
164809885543Smrg	;;
164909885543Smrg
1650b698ba48Smrg     -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
1651b698ba48Smrg	compiler_flags="$compiler_flags $arg"
1652b698ba48Smrg	compile_command="$compile_command $arg"
1653b698ba48Smrg	finalize_command="$finalize_command $arg"
1654b698ba48Smrg	continue
165509885543Smrg	;;
165609885543Smrg
1657b698ba48Smrg      -multi_module)
1658b698ba48Smrg	single_module="${wl}-multi_module"
165909885543Smrg	continue
166009885543Smrg	;;
166109885543Smrg
1662b698ba48Smrg      -module)
1663b698ba48Smrg	module=yes
1664b698ba48Smrg	continue
1665b698ba48Smrg	;;
166609885543Smrg
1667b698ba48Smrg      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
1668b698ba48Smrg      # -r[0-9][0-9]* specifies the processor on the SGI compiler
1669b698ba48Smrg      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
1670b698ba48Smrg      # +DA*, +DD* enable 64-bit mode on the HP compiler
1671b698ba48Smrg      # -q* pass through compiler args for the IBM compiler
1672b698ba48Smrg      # -m* pass through architecture-specific compiler args for GCC
1673b698ba48Smrg      # -m*, -t[45]*, -txscale* pass through architecture-specific
1674b698ba48Smrg      # compiler args for GCC
1675b698ba48Smrg      # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
1676b698ba48Smrg      # -F/path gives path to uninstalled frameworks, gcc on darwin
1677b698ba48Smrg      # @file GCC response files
1678b698ba48Smrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
1679b698ba48Smrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*)
168009885543Smrg
1681b698ba48Smrg	# Unknown arguments in both finalize_command and compile_command need
1682b698ba48Smrg	# to be aesthetically quoted because they are evaled later.
1683b698ba48Smrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1684b698ba48Smrg	case $arg in
1685b698ba48Smrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1686b698ba48Smrg	  arg="\"$arg\""
1687b698ba48Smrg	  ;;
1688b698ba48Smrg	esac
1689b698ba48Smrg        compile_command="$compile_command $arg"
1690b698ba48Smrg        finalize_command="$finalize_command $arg"
1691b698ba48Smrg        compiler_flags="$compiler_flags $arg"
1692b698ba48Smrg        continue
1693b698ba48Smrg        ;;
169409885543Smrg
1695b698ba48Smrg      -shrext)
1696b698ba48Smrg	prev=shrext
1697b698ba48Smrg	continue
16982ec8c4b4Smrg	;;
169909885543Smrg
1700b698ba48Smrg      -no-fast-install)
1701b698ba48Smrg	fast_install=no
1702b698ba48Smrg	continue
1703b698ba48Smrg	;;
170409885543Smrg
1705b698ba48Smrg      -no-install)
1706b698ba48Smrg	case $host in
1707b698ba48Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin*)
1708b698ba48Smrg	  # The PATH hackery in wrapper scripts is required on Windows
1709b698ba48Smrg	  # and Darwin in order for the loader to find any dlls it needs.
1710b698ba48Smrg	  $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2
1711b698ba48Smrg	  $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2
1712b698ba48Smrg	  fast_install=no
1713b698ba48Smrg	  ;;
1714b698ba48Smrg	*) no_install=yes ;;
1715b698ba48Smrg	esac
1716b698ba48Smrg	continue
1717b698ba48Smrg	;;
17182ec8c4b4Smrg
1719b698ba48Smrg      -no-undefined)
1720b698ba48Smrg	allow_undefined=no
1721b698ba48Smrg	continue
1722b698ba48Smrg	;;
17232ec8c4b4Smrg
1724b698ba48Smrg      -objectlist)
1725b698ba48Smrg	prev=objectlist
1726b698ba48Smrg	continue
17272ec8c4b4Smrg	;;
17282ec8c4b4Smrg
1729b698ba48Smrg      -o) prev=output ;;
17302ec8c4b4Smrg
1731b698ba48Smrg      -precious-files-regex)
1732b698ba48Smrg	prev=precious_regex
1733b698ba48Smrg	continue
1734b698ba48Smrg	;;
17352ec8c4b4Smrg
1736b698ba48Smrg      -release)
1737b698ba48Smrg	prev=release
1738b698ba48Smrg	continue
1739b698ba48Smrg	;;
17402ec8c4b4Smrg
1741b698ba48Smrg      -rpath)
1742b698ba48Smrg	prev=rpath
1743b698ba48Smrg	continue
1744b698ba48Smrg	;;
17452ec8c4b4Smrg
1746b698ba48Smrg      -R)
1747b698ba48Smrg	prev=xrpath
17482ec8c4b4Smrg	continue
1749b698ba48Smrg	;;
17502ec8c4b4Smrg
1751b698ba48Smrg      -R*)
1752b698ba48Smrg	dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
1753b698ba48Smrg	# We need an absolute path.
1754b698ba48Smrg	case $dir in
1755b698ba48Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
1756b698ba48Smrg	*)
1757b698ba48Smrg	  $echo "$modename: only absolute run-paths are allowed" 1>&2
1758b698ba48Smrg	  exit $EXIT_FAILURE
1759b698ba48Smrg	  ;;
1760b698ba48Smrg	esac
1761b698ba48Smrg	case "$xrpath " in
1762b698ba48Smrg	*" $dir "*) ;;
1763b698ba48Smrg	*) xrpath="$xrpath $dir" ;;
17642ec8c4b4Smrg	esac
1765b698ba48Smrg	continue
17662ec8c4b4Smrg	;;
1767b698ba48Smrg
1768b698ba48Smrg      -static | -static-libtool-libs)
1769b698ba48Smrg	# The effects of -static are defined in a previous loop.
1770b698ba48Smrg	# We used to do the same as -all-static on platforms that
1771b698ba48Smrg	# didn't have a PIC flag, but the assumption that the effects
1772b698ba48Smrg	# would be equivalent was wrong.  It would break on at least
1773b698ba48Smrg	# Digital Unix and AIX.
1774b698ba48Smrg	continue
17752ec8c4b4Smrg	;;
1776b698ba48Smrg
1777b698ba48Smrg      -thread-safe)
1778b698ba48Smrg	thread_safe=yes
17792ec8c4b4Smrg	continue
17802ec8c4b4Smrg	;;
1781b698ba48Smrg
1782b698ba48Smrg      -version-info)
1783b698ba48Smrg	prev=vinfo
1784b698ba48Smrg	continue
17852ec8c4b4Smrg	;;
1786b698ba48Smrg      -version-number)
1787b698ba48Smrg	prev=vinfo
1788b698ba48Smrg	vinfo_number=yes
1789b698ba48Smrg	continue
179009885543Smrg	;;
179109885543Smrg
1792b698ba48Smrg      -Wc,*)
1793b698ba48Smrg	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'`
1794b698ba48Smrg	arg=
1795b698ba48Smrg	save_ifs="$IFS"; IFS=','
1796b698ba48Smrg	for flag in $args; do
1797b698ba48Smrg	  IFS="$save_ifs"
1798b698ba48Smrg	  case $flag in
1799b698ba48Smrg	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1800b698ba48Smrg	    flag="\"$flag\""
1801b698ba48Smrg	    ;;
1802b698ba48Smrg	  esac
1803b698ba48Smrg	  arg="$arg $wl$flag"
1804b698ba48Smrg	  compiler_flags="$compiler_flags $flag"
1805b698ba48Smrg	done
1806b698ba48Smrg	IFS="$save_ifs"
1807b698ba48Smrg	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
1808b698ba48Smrg	;;
180909885543Smrg
1810b698ba48Smrg      -Wl,*)
1811b698ba48Smrg	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'`
1812b698ba48Smrg	arg=
1813b698ba48Smrg	save_ifs="$IFS"; IFS=','
1814b698ba48Smrg	for flag in $args; do
1815b698ba48Smrg	  IFS="$save_ifs"
1816b698ba48Smrg	  case $flag in
1817b698ba48Smrg	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1818b698ba48Smrg	    flag="\"$flag\""
1819b698ba48Smrg	    ;;
1820b698ba48Smrg	  esac
1821b698ba48Smrg	  arg="$arg $wl$flag"
1822b698ba48Smrg	  compiler_flags="$compiler_flags $wl$flag"
1823b698ba48Smrg	  linker_flags="$linker_flags $flag"
1824b698ba48Smrg	done
1825b698ba48Smrg	IFS="$save_ifs"
1826b698ba48Smrg	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
1827b698ba48Smrg	;;
182809885543Smrg
1829b698ba48Smrg      -Xcompiler)
1830b698ba48Smrg	prev=xcompiler
1831b698ba48Smrg	continue
1832b698ba48Smrg	;;
183309885543Smrg
1834b698ba48Smrg      -Xlinker)
1835b698ba48Smrg	prev=xlinker
1836b698ba48Smrg	continue
1837b698ba48Smrg	;;
183809885543Smrg
1839b698ba48Smrg      -XCClinker)
1840b698ba48Smrg	prev=xcclinker
1841b698ba48Smrg	continue
1842b698ba48Smrg	;;
184309885543Smrg
1844b698ba48Smrg      # Some other compiler flag.
1845b698ba48Smrg      -* | +*)
1846b698ba48Smrg	# Unknown arguments in both finalize_command and compile_command need
1847b698ba48Smrg	# to be aesthetically quoted because they are evaled later.
1848b698ba48Smrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1849b698ba48Smrg	case $arg in
1850b698ba48Smrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1851b698ba48Smrg	  arg="\"$arg\""
18522ec8c4b4Smrg	  ;;
18532ec8c4b4Smrg	esac
1854b698ba48Smrg	;;
185509885543Smrg
1856b698ba48Smrg      *.$objext)
1857b698ba48Smrg	# A standard object.
1858b698ba48Smrg	objs="$objs $arg"
18592ec8c4b4Smrg	;;
18602ec8c4b4Smrg
1861b698ba48Smrg      *.lo)
1862b698ba48Smrg	# A libtool-controlled object.
18632ec8c4b4Smrg
1864b698ba48Smrg	# Check to see that this really is a libtool object.
1865b698ba48Smrg	if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
1866b698ba48Smrg	  pic_object=
1867b698ba48Smrg	  non_pic_object=
18682ec8c4b4Smrg
1869b698ba48Smrg	  # Read the .lo file
1870b698ba48Smrg	  # If there is no directory component, then add one.
1871b698ba48Smrg	  case $arg in
1872b698ba48Smrg	  */* | *\\*) . $arg ;;
1873b698ba48Smrg	  *) . ./$arg ;;
18742ec8c4b4Smrg	  esac
18752ec8c4b4Smrg
1876b698ba48Smrg	  if test -z "$pic_object" || \
1877b698ba48Smrg	     test -z "$non_pic_object" ||
1878b698ba48Smrg	     test "$pic_object" = none && \
1879b698ba48Smrg	     test "$non_pic_object" = none; then
1880b698ba48Smrg	    $echo "$modename: cannot find name of object for \`$arg'" 1>&2
1881b698ba48Smrg	    exit $EXIT_FAILURE
1882b698ba48Smrg	  fi
18832ec8c4b4Smrg
1884b698ba48Smrg	  # Extract subdirectory from the argument.
1885b698ba48Smrg	  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1886b698ba48Smrg	  if test "X$xdir" = "X$arg"; then
1887b698ba48Smrg	    xdir=
1888b698ba48Smrg 	  else
1889b698ba48Smrg	    xdir="$xdir/"
18902ec8c4b4Smrg	  fi
18912ec8c4b4Smrg
1892b698ba48Smrg	  if test "$pic_object" != none; then
1893b698ba48Smrg	    # Prepend the subdirectory the object is found in.
1894b698ba48Smrg	    pic_object="$xdir$pic_object"
18952ec8c4b4Smrg
1896b698ba48Smrg	    if test "$prev" = dlfiles; then
1897b698ba48Smrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
1898b698ba48Smrg		dlfiles="$dlfiles $pic_object"
1899b698ba48Smrg		prev=
1900b698ba48Smrg		continue
1901b698ba48Smrg	      else
1902b698ba48Smrg		# If libtool objects are unsupported, then we need to preload.
1903b698ba48Smrg		prev=dlprefiles
1904b698ba48Smrg	      fi
1905b698ba48Smrg	    fi
19062ec8c4b4Smrg
1907b698ba48Smrg	    # CHECK ME:  I think I busted this.  -Ossama
1908b698ba48Smrg	    if test "$prev" = dlprefiles; then
1909b698ba48Smrg	      # Preload the old-style object.
1910b698ba48Smrg	      dlprefiles="$dlprefiles $pic_object"
1911b698ba48Smrg	      prev=
1912b698ba48Smrg	    fi
19132ec8c4b4Smrg
1914b698ba48Smrg	    # A PIC object.
1915b698ba48Smrg	    libobjs="$libobjs $pic_object"
1916b698ba48Smrg	    arg="$pic_object"
191709885543Smrg	  fi
19182ec8c4b4Smrg
1919b698ba48Smrg	  # Non-PIC object.
1920b698ba48Smrg	  if test "$non_pic_object" != none; then
1921b698ba48Smrg	    # Prepend the subdirectory the object is found in.
1922b698ba48Smrg	    non_pic_object="$xdir$non_pic_object"
1923b698ba48Smrg
1924b698ba48Smrg	    # A standard non-PIC object
1925b698ba48Smrg	    non_pic_objects="$non_pic_objects $non_pic_object"
1926b698ba48Smrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
1927b698ba48Smrg	      arg="$non_pic_object"
1928b698ba48Smrg	    fi
1929b698ba48Smrg	  else
1930b698ba48Smrg	    # If the PIC object exists, use it instead.
1931b698ba48Smrg	    # $xdir was prepended to $pic_object above.
1932b698ba48Smrg	    non_pic_object="$pic_object"
1933b698ba48Smrg	    non_pic_objects="$non_pic_objects $non_pic_object"
193409885543Smrg	  fi
1935b698ba48Smrg	else
1936b698ba48Smrg	  # Only an error if not doing a dry-run.
1937b698ba48Smrg	  if test -z "$run"; then
1938b698ba48Smrg	    $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
1939b698ba48Smrg	    exit $EXIT_FAILURE
1940b698ba48Smrg	  else
1941b698ba48Smrg	    # Dry-run case.
194209885543Smrg
1943b698ba48Smrg	    # Extract subdirectory from the argument.
1944b698ba48Smrg	    xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1945b698ba48Smrg	    if test "X$xdir" = "X$arg"; then
1946b698ba48Smrg	      xdir=
1947b698ba48Smrg	    else
1948b698ba48Smrg	      xdir="$xdir/"
1949b698ba48Smrg	    fi
195009885543Smrg
1951b698ba48Smrg	    pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
1952b698ba48Smrg	    non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
1953b698ba48Smrg	    libobjs="$libobjs $pic_object"
1954b698ba48Smrg	    non_pic_objects="$non_pic_objects $non_pic_object"
1955b698ba48Smrg	  fi
1956b698ba48Smrg	fi
1957b698ba48Smrg	;;
195809885543Smrg
1959b698ba48Smrg      *.$libext)
1960b698ba48Smrg	# An archive.
1961b698ba48Smrg	deplibs="$deplibs $arg"
1962b698ba48Smrg	old_deplibs="$old_deplibs $arg"
1963b698ba48Smrg	continue
19642ec8c4b4Smrg	;;
196509885543Smrg
1966b698ba48Smrg      *.la)
1967b698ba48Smrg	# A libtool-controlled library.
196809885543Smrg
1969b698ba48Smrg	if test "$prev" = dlfiles; then
1970b698ba48Smrg	  # This library was specified with -dlopen.
1971b698ba48Smrg	  dlfiles="$dlfiles $arg"
1972b698ba48Smrg	  prev=
1973b698ba48Smrg	elif test "$prev" = dlprefiles; then
1974b698ba48Smrg	  # The library was specified with -dlpreopen.
1975b698ba48Smrg	  dlprefiles="$dlprefiles $arg"
1976b698ba48Smrg	  prev=
19772ec8c4b4Smrg	else
1978b698ba48Smrg	  deplibs="$deplibs $arg"
197909885543Smrg	fi
1980b698ba48Smrg	continue
1981b698ba48Smrg	;;
198209885543Smrg
1983b698ba48Smrg      # Some other compiler argument.
1984b698ba48Smrg      *)
1985b698ba48Smrg	# Unknown arguments in both finalize_command and compile_command need
1986b698ba48Smrg	# to be aesthetically quoted because they are evaled later.
1987b698ba48Smrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1988b698ba48Smrg	case $arg in
1989b698ba48Smrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1990b698ba48Smrg	  arg="\"$arg\""
19912ec8c4b4Smrg	  ;;
19922ec8c4b4Smrg	esac
19932ec8c4b4Smrg	;;
1994b698ba48Smrg      esac # arg
199509885543Smrg
1996b698ba48Smrg      # Now actually substitute the argument into the commands.
1997b698ba48Smrg      if test -n "$arg"; then
1998b698ba48Smrg	compile_command="$compile_command $arg"
1999b698ba48Smrg	finalize_command="$finalize_command $arg"
2000b698ba48Smrg      fi
2001b698ba48Smrg    done # argument parsing loop
200209885543Smrg
2003b698ba48Smrg    if test -n "$prev"; then
2004b698ba48Smrg      $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
2005b698ba48Smrg      $echo "$help" 1>&2
2006b698ba48Smrg      exit $EXIT_FAILURE
2007b698ba48Smrg    fi
20082ec8c4b4Smrg
2009b698ba48Smrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
2010b698ba48Smrg      eval arg=\"$export_dynamic_flag_spec\"
2011b698ba48Smrg      compile_command="$compile_command $arg"
2012b698ba48Smrg      finalize_command="$finalize_command $arg"
2013b698ba48Smrg    fi
20142ec8c4b4Smrg
2015b698ba48Smrg    oldlibs=
2016b698ba48Smrg    # calculate the name of the file, without its directory
2017b698ba48Smrg    outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
2018b698ba48Smrg    libobjs_save="$libobjs"
20192ec8c4b4Smrg
2020b698ba48Smrg    if test -n "$shlibpath_var"; then
2021b698ba48Smrg      # get the directories listed in $shlibpath_var
2022b698ba48Smrg      eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
2023b698ba48Smrg    else
2024b698ba48Smrg      shlib_search_path=
2025b698ba48Smrg    fi
2026b698ba48Smrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
2027b698ba48Smrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
20282ec8c4b4Smrg
2029b698ba48Smrg    output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
2030b698ba48Smrg    if test "X$output_objdir" = "X$output"; then
2031b698ba48Smrg      output_objdir="$objdir"
20322ec8c4b4Smrg    else
2033b698ba48Smrg      output_objdir="$output_objdir/$objdir"
20342ec8c4b4Smrg    fi
2035b698ba48Smrg    # Create the object directory.
2036b698ba48Smrg    if test ! -d "$output_objdir"; then
2037b698ba48Smrg      $show "$mkdir $output_objdir"
2038b698ba48Smrg      $run $mkdir $output_objdir
2039b698ba48Smrg      exit_status=$?
2040b698ba48Smrg      if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then
2041b698ba48Smrg	exit $exit_status
20422ec8c4b4Smrg      fi
20432ec8c4b4Smrg    fi
20442ec8c4b4Smrg
2045b698ba48Smrg    # Determine the type of output
2046b698ba48Smrg    case $output in
2047b698ba48Smrg    "")
2048b698ba48Smrg      $echo "$modename: you must specify an output file" 1>&2
2049b698ba48Smrg      $echo "$help" 1>&2
2050b698ba48Smrg      exit $EXIT_FAILURE
2051b698ba48Smrg      ;;
2052b698ba48Smrg    *.$libext) linkmode=oldlib ;;
2053b698ba48Smrg    *.lo | *.$objext) linkmode=obj ;;
2054b698ba48Smrg    *.la) linkmode=lib ;;
2055b698ba48Smrg    *) linkmode=prog ;; # Anything else should be a program.
2056b698ba48Smrg    esac
205709885543Smrg
2058b698ba48Smrg    case $host in
2059b698ba48Smrg    *cygwin* | *mingw* | *pw32*)
2060b698ba48Smrg      # don't eliminate duplications in $postdeps and $predeps
2061b698ba48Smrg      duplicate_compiler_generated_deps=yes
2062b698ba48Smrg      ;;
2063b698ba48Smrg    *)
2064b698ba48Smrg      duplicate_compiler_generated_deps=$duplicate_deps
2065b698ba48Smrg      ;;
2066b698ba48Smrg    esac
2067b698ba48Smrg    specialdeplibs=
206809885543Smrg
2069b698ba48Smrg    libs=
2070b698ba48Smrg    # Find all interdependent deplibs by searching for libraries
2071b698ba48Smrg    # that are linked more than once (e.g. -la -lb -la)
2072b698ba48Smrg    for deplib in $deplibs; do
2073b698ba48Smrg      if test "X$duplicate_deps" = "Xyes" ; then
2074b698ba48Smrg	case "$libs " in
2075b698ba48Smrg	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2076b698ba48Smrg	esac
2077b698ba48Smrg      fi
2078b698ba48Smrg      libs="$libs $deplib"
2079b698ba48Smrg    done
208009885543Smrg
2081b698ba48Smrg    if test "$linkmode" = lib; then
2082b698ba48Smrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
208309885543Smrg
2084b698ba48Smrg      # Compute libraries that are listed more than once in $predeps
2085b698ba48Smrg      # $postdeps and mark them as special (i.e., whose duplicates are
2086b698ba48Smrg      # not to be eliminated).
2087b698ba48Smrg      pre_post_deps=
2088b698ba48Smrg      if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then
2089b698ba48Smrg	for pre_post_dep in $predeps $postdeps; do
2090b698ba48Smrg	  case "$pre_post_deps " in
2091b698ba48Smrg	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
20922ec8c4b4Smrg	  esac
2093b698ba48Smrg	  pre_post_deps="$pre_post_deps $pre_post_dep"
2094b698ba48Smrg	done
2095b698ba48Smrg      fi
2096b698ba48Smrg      pre_post_deps=
2097b698ba48Smrg    fi
20982ec8c4b4Smrg
2099b698ba48Smrg    deplibs=
2100b698ba48Smrg    newdependency_libs=
2101b698ba48Smrg    newlib_search_path=
2102b698ba48Smrg    need_relink=no # whether we're linking any uninstalled libtool libraries
2103b698ba48Smrg    notinst_deplibs= # not-installed libtool libraries
2104b698ba48Smrg    case $linkmode in
2105b698ba48Smrg    lib)
2106b698ba48Smrg	passes="conv link"
2107b698ba48Smrg	for file in $dlfiles $dlprefiles; do
2108b698ba48Smrg	  case $file in
2109b698ba48Smrg	  *.la) ;;
21102ec8c4b4Smrg	  *)
2111b698ba48Smrg	    $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2
2112b698ba48Smrg	    exit $EXIT_FAILURE
21132ec8c4b4Smrg	    ;;
21142ec8c4b4Smrg	  esac
21152ec8c4b4Smrg	done
21162ec8c4b4Smrg	;;
2117b698ba48Smrg    prog)
2118b698ba48Smrg	compile_deplibs=
2119b698ba48Smrg	finalize_deplibs=
2120b698ba48Smrg	alldeplibs=no
2121b698ba48Smrg	newdlfiles=
2122b698ba48Smrg	newdlprefiles=
2123b698ba48Smrg	passes="conv scan dlopen dlpreopen link"
2124b698ba48Smrg	;;
2125b698ba48Smrg    *)  passes="conv"
21262ec8c4b4Smrg	;;
21272ec8c4b4Smrg    esac
2128b698ba48Smrg    for pass in $passes; do
2129b698ba48Smrg      if test "$linkmode,$pass" = "lib,link" ||
2130b698ba48Smrg	 test "$linkmode,$pass" = "prog,scan"; then
2131b698ba48Smrg	libs="$deplibs"
2132b698ba48Smrg	deplibs=
2133b698ba48Smrg      fi
2134b698ba48Smrg      if test "$linkmode" = prog; then
2135b698ba48Smrg	case $pass in
2136b698ba48Smrg	dlopen) libs="$dlfiles" ;;
2137b698ba48Smrg	dlpreopen) libs="$dlprefiles" ;;
2138b698ba48Smrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
2139b698ba48Smrg	esac
2140b698ba48Smrg      fi
2141b698ba48Smrg      if test "$pass" = dlopen; then
2142b698ba48Smrg	# Collect dlpreopened libraries
2143b698ba48Smrg	save_deplibs="$deplibs"
2144b698ba48Smrg	deplibs=
2145b698ba48Smrg      fi
2146b698ba48Smrg      for deplib in $libs; do
2147b698ba48Smrg	lib=
2148b698ba48Smrg	found=no
2149b698ba48Smrg	case $deplib in
2150b698ba48Smrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
2151b698ba48Smrg	  if test "$linkmode,$pass" = "prog,link"; then
2152b698ba48Smrg	    compile_deplibs="$deplib $compile_deplibs"
2153b698ba48Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
2154b698ba48Smrg	  else
2155b698ba48Smrg	    compiler_flags="$compiler_flags $deplib"
2156b698ba48Smrg	  fi
2157b698ba48Smrg	  continue
2158b698ba48Smrg	  ;;
2159b698ba48Smrg	-l*)
2160b698ba48Smrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
2161b698ba48Smrg	    $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2
2162b698ba48Smrg	    continue
2163b698ba48Smrg	  fi
2164b698ba48Smrg	  name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
2165b698ba48Smrg	  if test "$linkmode" = lib; then
2166b698ba48Smrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
2167b698ba48Smrg	  else
2168b698ba48Smrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
2169b698ba48Smrg	  fi
2170b698ba48Smrg	  for searchdir in $searchdirs; do
2171b698ba48Smrg	    for search_ext in .la $std_shrext .so .a; do
2172b698ba48Smrg	      # Search the libtool library
2173b698ba48Smrg	      lib="$searchdir/lib${name}${search_ext}"
2174b698ba48Smrg	      if test -f "$lib"; then
2175b698ba48Smrg		if test "$search_ext" = ".la"; then
2176b698ba48Smrg		  found=yes
2177b698ba48Smrg		else
2178b698ba48Smrg		  found=no
2179b698ba48Smrg		fi
2180b698ba48Smrg		break 2
2181b698ba48Smrg	      fi
2182b698ba48Smrg	    done
2183b698ba48Smrg	  done
2184b698ba48Smrg	  if test "$found" != yes; then
2185b698ba48Smrg	    # deplib doesn't seem to be a libtool library
2186b698ba48Smrg	    if test "$linkmode,$pass" = "prog,link"; then
2187b698ba48Smrg	      compile_deplibs="$deplib $compile_deplibs"
2188b698ba48Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
2189b698ba48Smrg	    else
2190b698ba48Smrg	      deplibs="$deplib $deplibs"
2191b698ba48Smrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
2192b698ba48Smrg	    fi
2193b698ba48Smrg	    continue
2194b698ba48Smrg	  else # deplib is a libtool library
2195b698ba48Smrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
2196b698ba48Smrg	    # We need to do some special things here, and not later.
2197b698ba48Smrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
2198b698ba48Smrg	      case " $predeps $postdeps " in
2199b698ba48Smrg	      *" $deplib "*)
2200b698ba48Smrg		if (${SED} -e '2q' $lib |
2201b698ba48Smrg                    grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
2202b698ba48Smrg		  library_names=
2203b698ba48Smrg		  old_library=
2204b698ba48Smrg		  case $lib in
2205b698ba48Smrg		  */* | *\\*) . $lib ;;
2206b698ba48Smrg		  *) . ./$lib ;;
2207b698ba48Smrg		  esac
2208b698ba48Smrg		  for l in $old_library $library_names; do
2209b698ba48Smrg		    ll="$l"
2210b698ba48Smrg		  done
2211b698ba48Smrg		  if test "X$ll" = "X$old_library" ; then # only static version available
2212b698ba48Smrg		    found=no
2213b698ba48Smrg		    ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
2214b698ba48Smrg		    test "X$ladir" = "X$lib" && ladir="."
2215b698ba48Smrg		    lib=$ladir/$old_library
2216b698ba48Smrg		    if test "$linkmode,$pass" = "prog,link"; then
2217b698ba48Smrg		      compile_deplibs="$deplib $compile_deplibs"
2218b698ba48Smrg		      finalize_deplibs="$deplib $finalize_deplibs"
2219b698ba48Smrg		    else
2220b698ba48Smrg		      deplibs="$deplib $deplibs"
2221b698ba48Smrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
2222b698ba48Smrg		    fi
2223b698ba48Smrg		    continue
2224b698ba48Smrg		  fi
2225b698ba48Smrg		fi
2226b698ba48Smrg	        ;;
2227b698ba48Smrg	      *) ;;
2228b698ba48Smrg	      esac
2229b698ba48Smrg	    fi
2230b698ba48Smrg	  fi
2231b698ba48Smrg	  ;; # -l
2232b698ba48Smrg	-L*)
2233b698ba48Smrg	  case $linkmode in
2234b698ba48Smrg	  lib)
2235b698ba48Smrg	    deplibs="$deplib $deplibs"
2236b698ba48Smrg	    test "$pass" = conv && continue
2237b698ba48Smrg	    newdependency_libs="$deplib $newdependency_libs"
2238b698ba48Smrg	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
2239b698ba48Smrg	    ;;
2240b698ba48Smrg	  prog)
2241b698ba48Smrg	    if test "$pass" = conv; then
2242b698ba48Smrg	      deplibs="$deplib $deplibs"
2243b698ba48Smrg	      continue
2244b698ba48Smrg	    fi
2245b698ba48Smrg	    if test "$pass" = scan; then
2246b698ba48Smrg	      deplibs="$deplib $deplibs"
2247b698ba48Smrg	    else
2248b698ba48Smrg	      compile_deplibs="$deplib $compile_deplibs"
2249b698ba48Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
2250b698ba48Smrg	    fi
2251b698ba48Smrg	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
2252b698ba48Smrg	    ;;
2253b698ba48Smrg	  *)
2254b698ba48Smrg	    $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2
2255b698ba48Smrg	    ;;
2256b698ba48Smrg	  esac # linkmode
2257b698ba48Smrg	  continue
2258b698ba48Smrg	  ;; # -L
2259b698ba48Smrg	-R*)
2260b698ba48Smrg	  if test "$pass" = link; then
2261b698ba48Smrg	    dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
2262b698ba48Smrg	    # Make sure the xrpath contains only unique directories.
2263b698ba48Smrg	    case "$xrpath " in
2264b698ba48Smrg	    *" $dir "*) ;;
2265b698ba48Smrg	    *) xrpath="$xrpath $dir" ;;
2266b698ba48Smrg	    esac
2267b698ba48Smrg	  fi
2268b698ba48Smrg	  deplibs="$deplib $deplibs"
2269b698ba48Smrg	  continue
2270b698ba48Smrg	  ;;
2271b698ba48Smrg	*.la) lib="$deplib" ;;
2272b698ba48Smrg	*.$libext)
2273b698ba48Smrg	  if test "$pass" = conv; then
2274b698ba48Smrg	    deplibs="$deplib $deplibs"
2275b698ba48Smrg	    continue
2276b698ba48Smrg	  fi
2277b698ba48Smrg	  case $linkmode in
2278b698ba48Smrg	  lib)
2279b698ba48Smrg	    valid_a_lib=no
2280b698ba48Smrg	    case $deplibs_check_method in
2281b698ba48Smrg	      match_pattern*)
2282b698ba48Smrg		set dummy $deplibs_check_method
2283b698ba48Smrg	        match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
2284b698ba48Smrg		if eval $echo \"$deplib\" 2>/dev/null \
2285b698ba48Smrg		    | $SED 10q \
2286b698ba48Smrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
2287b698ba48Smrg		  valid_a_lib=yes
2288b698ba48Smrg		fi
2289b698ba48Smrg		;;
2290b698ba48Smrg	      pass_all)
2291b698ba48Smrg		valid_a_lib=yes
2292b698ba48Smrg		;;
2293b698ba48Smrg            esac
2294b698ba48Smrg	    if test "$valid_a_lib" != yes; then
2295b698ba48Smrg	      $echo
2296b698ba48Smrg	      $echo "*** Warning: Trying to link with static lib archive $deplib."
2297b698ba48Smrg	      $echo "*** I have the capability to make that library automatically link in when"
2298b698ba48Smrg	      $echo "*** you link to this library.  But I can only do this if you have a"
2299b698ba48Smrg	      $echo "*** shared version of the library, which you do not appear to have"
2300b698ba48Smrg	      $echo "*** because the file extensions .$libext of this argument makes me believe"
2301b698ba48Smrg	      $echo "*** that it is just a static archive that I should not used here."
2302b698ba48Smrg	    else
2303b698ba48Smrg	      $echo
2304b698ba48Smrg	      $echo "*** Warning: Linking the shared library $output against the"
2305b698ba48Smrg	      $echo "*** static library $deplib is not portable!"
2306b698ba48Smrg	      deplibs="$deplib $deplibs"
2307b698ba48Smrg	    fi
2308b698ba48Smrg	    continue
2309b698ba48Smrg	    ;;
2310b698ba48Smrg	  prog)
2311b698ba48Smrg	    if test "$pass" != link; then
2312b698ba48Smrg	      deplibs="$deplib $deplibs"
2313b698ba48Smrg	    else
2314b698ba48Smrg	      compile_deplibs="$deplib $compile_deplibs"
2315b698ba48Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
2316b698ba48Smrg	    fi
2317b698ba48Smrg	    continue
2318b698ba48Smrg	    ;;
2319b698ba48Smrg	  esac # linkmode
2320b698ba48Smrg	  ;; # *.$libext
2321b698ba48Smrg	*.lo | *.$objext)
2322b698ba48Smrg	  if test "$pass" = conv; then
2323b698ba48Smrg	    deplibs="$deplib $deplibs"
2324b698ba48Smrg	  elif test "$linkmode" = prog; then
2325b698ba48Smrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
2326b698ba48Smrg	      # If there is no dlopen support or we're linking statically,
2327b698ba48Smrg	      # we need to preload.
2328b698ba48Smrg	      newdlprefiles="$newdlprefiles $deplib"
2329b698ba48Smrg	      compile_deplibs="$deplib $compile_deplibs"
2330b698ba48Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
2331b698ba48Smrg	    else
2332b698ba48Smrg	      newdlfiles="$newdlfiles $deplib"
2333b698ba48Smrg	    fi
2334b698ba48Smrg	  fi
2335b698ba48Smrg	  continue
2336b698ba48Smrg	  ;;
2337b698ba48Smrg	%DEPLIBS%)
2338b698ba48Smrg	  alldeplibs=yes
2339b698ba48Smrg	  continue
2340b698ba48Smrg	  ;;
2341b698ba48Smrg	esac # case $deplib
2342b698ba48Smrg	if test "$found" = yes || test -f "$lib"; then :
2343b698ba48Smrg	else
2344b698ba48Smrg	  $echo "$modename: cannot find the library \`$lib' or unhandled argument \`$deplib'" 1>&2
2345b698ba48Smrg	  exit $EXIT_FAILURE
2346b698ba48Smrg	fi
234709885543Smrg
2348b698ba48Smrg	# Check to see that this really is a libtool archive.
2349b698ba48Smrg	if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
2350b698ba48Smrg	else
2351b698ba48Smrg	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
2352b698ba48Smrg	  exit $EXIT_FAILURE
2353b698ba48Smrg	fi
235409885543Smrg
2355b698ba48Smrg	ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
2356b698ba48Smrg	test "X$ladir" = "X$lib" && ladir="."
235709885543Smrg
2358b698ba48Smrg	dlname=
2359b698ba48Smrg	dlopen=
2360b698ba48Smrg	dlpreopen=
2361b698ba48Smrg	libdir=
2362b698ba48Smrg	library_names=
2363b698ba48Smrg	old_library=
2364b698ba48Smrg	# If the library was installed with an old release of libtool,
2365b698ba48Smrg	# it will not redefine variables installed, or shouldnotlink
2366b698ba48Smrg	installed=yes
2367b698ba48Smrg	shouldnotlink=no
2368b698ba48Smrg	avoidtemprpath=
236909885543Smrg
237009885543Smrg
2371b698ba48Smrg	# Read the .la file
2372b698ba48Smrg	case $lib in
2373b698ba48Smrg	*/* | *\\*) . $lib ;;
2374b698ba48Smrg	*) . ./$lib ;;
23752ec8c4b4Smrg	esac
237609885543Smrg
2377b698ba48Smrg	if test "$linkmode,$pass" = "lib,link" ||
2378b698ba48Smrg	   test "$linkmode,$pass" = "prog,scan" ||
2379b698ba48Smrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
2380b698ba48Smrg	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
2381b698ba48Smrg	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
2382b698ba48Smrg	fi
238309885543Smrg
2384b698ba48Smrg	if test "$pass" = conv; then
2385b698ba48Smrg	  # Only check for convenience libraries
2386b698ba48Smrg	  deplibs="$lib $deplibs"
2387b698ba48Smrg	  if test -z "$libdir"; then
2388b698ba48Smrg	    if test -z "$old_library"; then
2389b698ba48Smrg	      $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
2390b698ba48Smrg	      exit $EXIT_FAILURE
2391b698ba48Smrg	    fi
2392b698ba48Smrg	    # It is a libtool convenience library, so add in its objects.
2393b698ba48Smrg	    convenience="$convenience $ladir/$objdir/$old_library"
2394b698ba48Smrg	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
2395b698ba48Smrg	    tmp_libs=
2396b698ba48Smrg	    for deplib in $dependency_libs; do
2397b698ba48Smrg	      deplibs="$deplib $deplibs"
2398b698ba48Smrg              if test "X$duplicate_deps" = "Xyes" ; then
2399b698ba48Smrg	        case "$tmp_libs " in
2400b698ba48Smrg	        *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2401b698ba48Smrg	        esac
2402b698ba48Smrg              fi
2403b698ba48Smrg	      tmp_libs="$tmp_libs $deplib"
2404b698ba48Smrg	    done
2405b698ba48Smrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
2406b698ba48Smrg	    $echo "$modename: \`$lib' is not a convenience library" 1>&2
2407b698ba48Smrg	    exit $EXIT_FAILURE
2408b698ba48Smrg	  fi
2409b698ba48Smrg	  continue
2410b698ba48Smrg	fi # $pass = conv
241109885543Smrg
241209885543Smrg
2413b698ba48Smrg	# Get the name of the library we link against.
2414b698ba48Smrg	linklib=
2415b698ba48Smrg	for l in $old_library $library_names; do
2416b698ba48Smrg	  linklib="$l"
2417b698ba48Smrg	done
2418b698ba48Smrg	if test -z "$linklib"; then
2419b698ba48Smrg	  $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
2420b698ba48Smrg	  exit $EXIT_FAILURE
242109885543Smrg	fi
242209885543Smrg
2423b698ba48Smrg	# This library was specified with -dlopen.
2424b698ba48Smrg	if test "$pass" = dlopen; then
2425b698ba48Smrg	  if test -z "$libdir"; then
2426b698ba48Smrg	    $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2
2427b698ba48Smrg	    exit $EXIT_FAILURE
2428b698ba48Smrg	  fi
2429b698ba48Smrg	  if test -z "$dlname" ||
2430b698ba48Smrg	     test "$dlopen_support" != yes ||
2431b698ba48Smrg	     test "$build_libtool_libs" = no; then
2432b698ba48Smrg	    # If there is no dlname, no dlopen support or we're linking
2433b698ba48Smrg	    # statically, we need to preload.  We also need to preload any
2434b698ba48Smrg	    # dependent libraries so libltdl's deplib preloader doesn't
2435b698ba48Smrg	    # bomb out in the load deplibs phase.
2436b698ba48Smrg	    dlprefiles="$dlprefiles $lib $dependency_libs"
2437b698ba48Smrg	  else
2438b698ba48Smrg	    newdlfiles="$newdlfiles $lib"
2439b698ba48Smrg	  fi
2440b698ba48Smrg	  continue
2441b698ba48Smrg	fi # $pass = dlopen
244209885543Smrg
2443b698ba48Smrg	# We need an absolute path.
2444b698ba48Smrg	case $ladir in
2445b698ba48Smrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
2446b698ba48Smrg	*)
2447b698ba48Smrg	  abs_ladir=`cd "$ladir" && pwd`
2448b698ba48Smrg	  if test -z "$abs_ladir"; then
2449b698ba48Smrg	    $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2
2450b698ba48Smrg	    $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
2451b698ba48Smrg	    abs_ladir="$ladir"
2452b698ba48Smrg	  fi
2453b698ba48Smrg	  ;;
2454b698ba48Smrg	esac
2455b698ba48Smrg	laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
245609885543Smrg
2457b698ba48Smrg	# Find the relevant object directory and library name.
2458b698ba48Smrg	if test "X$installed" = Xyes; then
2459b698ba48Smrg	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
2460b698ba48Smrg	    $echo "$modename: warning: library \`$lib' was moved." 1>&2
2461b698ba48Smrg	    dir="$ladir"
2462b698ba48Smrg	    absdir="$abs_ladir"
2463b698ba48Smrg	    libdir="$abs_ladir"
2464b698ba48Smrg	  else
2465b698ba48Smrg	    dir="$libdir"
2466b698ba48Smrg	    absdir="$libdir"
2467b698ba48Smrg	  fi
2468b698ba48Smrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
2469b698ba48Smrg	else
2470b698ba48Smrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
2471b698ba48Smrg	    dir="$ladir"
2472b698ba48Smrg	    absdir="$abs_ladir"
2473b698ba48Smrg	    # Remove this search path later
2474b698ba48Smrg	    notinst_path="$notinst_path $abs_ladir"
2475b698ba48Smrg	  else
2476b698ba48Smrg	    dir="$ladir/$objdir"
2477b698ba48Smrg	    absdir="$abs_ladir/$objdir"
2478b698ba48Smrg	    # Remove this search path later
2479b698ba48Smrg	    notinst_path="$notinst_path $abs_ladir"
2480b698ba48Smrg	  fi
2481b698ba48Smrg	fi # $installed = yes
2482b698ba48Smrg	name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
248309885543Smrg
2484b698ba48Smrg	# This library was specified with -dlpreopen.
2485b698ba48Smrg	if test "$pass" = dlpreopen; then
2486b698ba48Smrg	  if test -z "$libdir"; then
2487b698ba48Smrg	    $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2
2488b698ba48Smrg	    exit $EXIT_FAILURE
2489b698ba48Smrg	  fi
2490b698ba48Smrg	  # Prefer using a static library (so that no silly _DYNAMIC symbols
2491b698ba48Smrg	  # are required to link).
2492b698ba48Smrg	  if test -n "$old_library"; then
2493b698ba48Smrg	    newdlprefiles="$newdlprefiles $dir/$old_library"
2494b698ba48Smrg	  # Otherwise, use the dlname, so that lt_dlopen finds it.
2495b698ba48Smrg	  elif test -n "$dlname"; then
2496b698ba48Smrg	    newdlprefiles="$newdlprefiles $dir/$dlname"
2497b698ba48Smrg	  else
2498b698ba48Smrg	    newdlprefiles="$newdlprefiles $dir/$linklib"
2499b698ba48Smrg	  fi
2500b698ba48Smrg	fi # $pass = dlpreopen
250109885543Smrg
2502b698ba48Smrg	if test -z "$libdir"; then
2503b698ba48Smrg	  # Link the convenience library
2504b698ba48Smrg	  if test "$linkmode" = lib; then
2505b698ba48Smrg	    deplibs="$dir/$old_library $deplibs"
2506b698ba48Smrg	  elif test "$linkmode,$pass" = "prog,link"; then
2507b698ba48Smrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
2508b698ba48Smrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
2509b698ba48Smrg	  else
2510b698ba48Smrg	    deplibs="$lib $deplibs" # used for prog,scan pass
2511b698ba48Smrg	  fi
2512b698ba48Smrg	  continue
2513b698ba48Smrg	fi
251409885543Smrg
251509885543Smrg
2516b698ba48Smrg	if test "$linkmode" = prog && test "$pass" != link; then
2517b698ba48Smrg	  newlib_search_path="$newlib_search_path $ladir"
2518b698ba48Smrg	  deplibs="$lib $deplibs"
251909885543Smrg
2520b698ba48Smrg	  linkalldeplibs=no
2521b698ba48Smrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
2522b698ba48Smrg	     test "$build_libtool_libs" = no; then
2523b698ba48Smrg	    linkalldeplibs=yes
2524b698ba48Smrg	  fi
252509885543Smrg
2526b698ba48Smrg	  tmp_libs=
2527b698ba48Smrg	  for deplib in $dependency_libs; do
2528b698ba48Smrg	    case $deplib in
2529b698ba48Smrg	    -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test
2530b698ba48Smrg	    esac
2531b698ba48Smrg	    # Need to link against all dependency_libs?
2532b698ba48Smrg	    if test "$linkalldeplibs" = yes; then
2533b698ba48Smrg	      deplibs="$deplib $deplibs"
2534b698ba48Smrg	    else
2535b698ba48Smrg	      # Need to hardcode shared library paths
2536b698ba48Smrg	      # or/and link against static libraries
2537b698ba48Smrg	      newdependency_libs="$deplib $newdependency_libs"
2538b698ba48Smrg	    fi
2539b698ba48Smrg	    if test "X$duplicate_deps" = "Xyes" ; then
2540b698ba48Smrg	      case "$tmp_libs " in
2541b698ba48Smrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2542b698ba48Smrg	      esac
2543b698ba48Smrg	    fi
2544b698ba48Smrg	    tmp_libs="$tmp_libs $deplib"
2545b698ba48Smrg	  done # for deplib
2546b698ba48Smrg	  continue
2547b698ba48Smrg	fi # $linkmode = prog...
254809885543Smrg
2549b698ba48Smrg	if test "$linkmode,$pass" = "prog,link"; then
2550b698ba48Smrg	  if test -n "$library_names" &&
2551b698ba48Smrg	     { { test "$prefer_static_libs" = no ||
2552b698ba48Smrg		 test "$prefer_static_libs,$installed" = "built,yes"; } ||
2553b698ba48Smrg	       test -z "$old_library"; }; then
2554b698ba48Smrg	    # We need to hardcode the library path
2555b698ba48Smrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
2556b698ba48Smrg	      # Make sure the rpath contains only unique directories.
2557b698ba48Smrg	      case "$temp_rpath " in
2558b698ba48Smrg	      *" $dir "*) ;;
2559b698ba48Smrg	      *" $absdir "*) ;;
2560b698ba48Smrg	      *) temp_rpath="$temp_rpath $absdir" ;;
2561b698ba48Smrg	      esac
2562b698ba48Smrg	    fi
256309885543Smrg
2564b698ba48Smrg	    # Hardcode the library path.
2565b698ba48Smrg	    # Skip directories that are in the system default run-time
2566b698ba48Smrg	    # search path.
2567b698ba48Smrg	    case " $sys_lib_dlsearch_path " in
2568b698ba48Smrg	    *" $absdir "*) ;;
2569b698ba48Smrg	    *)
2570b698ba48Smrg	      case "$compile_rpath " in
2571b698ba48Smrg	      *" $absdir "*) ;;
2572b698ba48Smrg	      *) compile_rpath="$compile_rpath $absdir"
2573b698ba48Smrg	      esac
2574b698ba48Smrg	      ;;
2575b698ba48Smrg	    esac
2576b698ba48Smrg	    case " $sys_lib_dlsearch_path " in
2577b698ba48Smrg	    *" $libdir "*) ;;
2578b698ba48Smrg	    *)
2579b698ba48Smrg	      case "$finalize_rpath " in
2580b698ba48Smrg	      *" $libdir "*) ;;
2581b698ba48Smrg	      *) finalize_rpath="$finalize_rpath $libdir"
2582b698ba48Smrg	      esac
2583b698ba48Smrg	      ;;
2584b698ba48Smrg	    esac
2585b698ba48Smrg	  fi # $linkmode,$pass = prog,link...
25862ec8c4b4Smrg
2587b698ba48Smrg	  if test "$alldeplibs" = yes &&
2588b698ba48Smrg	     { test "$deplibs_check_method" = pass_all ||
2589b698ba48Smrg	       { test "$build_libtool_libs" = yes &&
2590b698ba48Smrg		 test -n "$library_names"; }; }; then
2591b698ba48Smrg	    # We only need to search for static libraries
2592b698ba48Smrg	    continue
2593b698ba48Smrg	  fi
259409885543Smrg	fi
259509885543Smrg
2596b698ba48Smrg	link_static=no # Whether the deplib will be linked statically
2597b698ba48Smrg	use_static_libs=$prefer_static_libs
2598b698ba48Smrg	if test "$use_static_libs" = built && test "$installed" = yes ; then
2599b698ba48Smrg	  use_static_libs=no
2600b698ba48Smrg	fi
2601b698ba48Smrg	if test -n "$library_names" &&
2602b698ba48Smrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
2603b698ba48Smrg	  if test "$installed" = no; then
2604b698ba48Smrg	    notinst_deplibs="$notinst_deplibs $lib"
2605b698ba48Smrg	    need_relink=yes
2606b698ba48Smrg	  fi
2607b698ba48Smrg	  # This is a shared library
260809885543Smrg
2609b698ba48Smrg	  # Warn about portability, can't link against -module's on
2610b698ba48Smrg	  # some systems (darwin)
2611b698ba48Smrg	  if test "$shouldnotlink" = yes && test "$pass" = link ; then
2612b698ba48Smrg	    $echo
2613b698ba48Smrg	    if test "$linkmode" = prog; then
2614b698ba48Smrg	      $echo "*** Warning: Linking the executable $output against the loadable module"
2615b698ba48Smrg	    else
2616b698ba48Smrg	      $echo "*** Warning: Linking the shared library $output against the loadable module"
2617b698ba48Smrg	    fi
2618b698ba48Smrg	    $echo "*** $linklib is not portable!"
2619b698ba48Smrg	  fi
2620b698ba48Smrg	  if test "$linkmode" = lib &&
2621b698ba48Smrg	     test "$hardcode_into_libs" = yes; then
2622b698ba48Smrg	    # Hardcode the library path.
2623b698ba48Smrg	    # Skip directories that are in the system default run-time
2624b698ba48Smrg	    # search path.
2625b698ba48Smrg	    case " $sys_lib_dlsearch_path " in
2626b698ba48Smrg	    *" $absdir "*) ;;
2627b698ba48Smrg	    *)
2628b698ba48Smrg	      case "$compile_rpath " in
2629b698ba48Smrg	      *" $absdir "*) ;;
2630b698ba48Smrg	      *) compile_rpath="$compile_rpath $absdir"
2631b698ba48Smrg	      esac
2632b698ba48Smrg	      ;;
2633b698ba48Smrg	    esac
2634b698ba48Smrg	    case " $sys_lib_dlsearch_path " in
2635b698ba48Smrg	    *" $libdir "*) ;;
2636b698ba48Smrg	    *)
2637b698ba48Smrg	      case "$finalize_rpath " in
2638b698ba48Smrg	      *" $libdir "*) ;;
2639b698ba48Smrg	      *) finalize_rpath="$finalize_rpath $libdir"
2640b698ba48Smrg	      esac
2641b698ba48Smrg	      ;;
2642b698ba48Smrg	    esac
2643b698ba48Smrg	  fi
26442ec8c4b4Smrg
2645b698ba48Smrg	  if test -n "$old_archive_from_expsyms_cmds"; then
2646b698ba48Smrg	    # figure out the soname
2647b698ba48Smrg	    set dummy $library_names
2648b698ba48Smrg	    realname="$2"
2649b698ba48Smrg	    shift; shift
2650b698ba48Smrg	    libname=`eval \\$echo \"$libname_spec\"`
2651b698ba48Smrg	    # use dlname if we got it. it's perfectly good, no?
2652b698ba48Smrg	    if test -n "$dlname"; then
2653b698ba48Smrg	      soname="$dlname"
2654b698ba48Smrg	    elif test -n "$soname_spec"; then
2655b698ba48Smrg	      # bleh windows
2656b698ba48Smrg	      case $host in
2657b698ba48Smrg	      *cygwin* | mingw*)
2658b698ba48Smrg		major=`expr $current - $age`
2659b698ba48Smrg		versuffix="-$major"
2660b698ba48Smrg		;;
2661b698ba48Smrg	      esac
2662b698ba48Smrg	      eval soname=\"$soname_spec\"
2663b698ba48Smrg	    else
2664b698ba48Smrg	      soname="$realname"
2665b698ba48Smrg	    fi
26662ec8c4b4Smrg
2667b698ba48Smrg	    # Make a new name for the extract_expsyms_cmds to use
2668b698ba48Smrg	    soroot="$soname"
2669b698ba48Smrg	    soname=`$echo $soroot | ${SED} -e 's/^.*\///'`
2670b698ba48Smrg	    newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a"
26712ec8c4b4Smrg
2672b698ba48Smrg	    # If the library has no export list, then create one now
2673b698ba48Smrg	    if test -f "$output_objdir/$soname-def"; then :
2674b698ba48Smrg	    else
2675b698ba48Smrg	      $show "extracting exported symbol list from \`$soname'"
2676b698ba48Smrg	      save_ifs="$IFS"; IFS='~'
2677b698ba48Smrg	      cmds=$extract_expsyms_cmds
2678b698ba48Smrg	      for cmd in $cmds; do
2679b698ba48Smrg		IFS="$save_ifs"
2680b698ba48Smrg		eval cmd=\"$cmd\"
2681b698ba48Smrg		$show "$cmd"
2682b698ba48Smrg		$run eval "$cmd" || exit $?
2683b698ba48Smrg	      done
2684b698ba48Smrg	      IFS="$save_ifs"
2685b698ba48Smrg	    fi
26862ec8c4b4Smrg
2687b698ba48Smrg	    # Create $newlib
2688b698ba48Smrg	    if test -f "$output_objdir/$newlib"; then :; else
2689b698ba48Smrg	      $show "generating import library for \`$soname'"
2690b698ba48Smrg	      save_ifs="$IFS"; IFS='~'
2691b698ba48Smrg	      cmds=$old_archive_from_expsyms_cmds
2692b698ba48Smrg	      for cmd in $cmds; do
2693b698ba48Smrg		IFS="$save_ifs"
2694b698ba48Smrg		eval cmd=\"$cmd\"
2695b698ba48Smrg		$show "$cmd"
2696b698ba48Smrg		$run eval "$cmd" || exit $?
2697b698ba48Smrg	      done
2698b698ba48Smrg	      IFS="$save_ifs"
2699b698ba48Smrg	    fi
2700b698ba48Smrg	    # make sure the library variables are pointing to the new library
2701b698ba48Smrg	    dir=$output_objdir
2702b698ba48Smrg	    linklib=$newlib
2703b698ba48Smrg	  fi # test -n "$old_archive_from_expsyms_cmds"
270409885543Smrg
2705b698ba48Smrg	  if test "$linkmode" = prog || test "$mode" != relink; then
2706b698ba48Smrg	    add_shlibpath=
2707b698ba48Smrg	    add_dir=
2708b698ba48Smrg	    add=
2709b698ba48Smrg	    lib_linked=yes
2710b698ba48Smrg	    case $hardcode_action in
2711b698ba48Smrg	    immediate | unsupported)
2712b698ba48Smrg	      if test "$hardcode_direct" = no; then
2713b698ba48Smrg		add="$dir/$linklib"
2714b698ba48Smrg		case $host in
2715b698ba48Smrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
2716b698ba48Smrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
2717b698ba48Smrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
2718b698ba48Smrg		    *-*-unixware7*) add_dir="-L$dir" ;;
2719b698ba48Smrg		  *-*-darwin* )
2720b698ba48Smrg		    # if the lib is a module then we can not link against
2721b698ba48Smrg		    # it, someone is ignoring the new warnings I added
2722b698ba48Smrg		    if /usr/bin/file -L $add 2> /dev/null |
2723b698ba48Smrg                      $EGREP ": [^:]* bundle" >/dev/null ; then
2724b698ba48Smrg		      $echo "** Warning, lib $linklib is a module, not a shared library"
2725b698ba48Smrg		      if test -z "$old_library" ; then
2726b698ba48Smrg		        $echo
2727b698ba48Smrg		        $echo "** And there doesn't seem to be a static archive available"
2728b698ba48Smrg		        $echo "** The link will probably fail, sorry"
2729b698ba48Smrg		      else
2730b698ba48Smrg		        add="$dir/$old_library"
2731b698ba48Smrg		      fi
2732b698ba48Smrg		    fi
2733b698ba48Smrg		esac
2734b698ba48Smrg	      elif test "$hardcode_minus_L" = no; then
2735b698ba48Smrg		case $host in
2736b698ba48Smrg		*-*-sunos*) add_shlibpath="$dir" ;;
2737b698ba48Smrg		esac
2738b698ba48Smrg		add_dir="-L$dir"
2739b698ba48Smrg		add="-l$name"
2740b698ba48Smrg	      elif test "$hardcode_shlibpath_var" = no; then
2741b698ba48Smrg		add_shlibpath="$dir"
2742b698ba48Smrg		add="-l$name"
2743b698ba48Smrg	      else
2744b698ba48Smrg		lib_linked=no
2745b698ba48Smrg	      fi
2746b698ba48Smrg	      ;;
2747b698ba48Smrg	    relink)
2748b698ba48Smrg	      if test "$hardcode_direct" = yes; then
2749b698ba48Smrg		add="$dir/$linklib"
2750b698ba48Smrg	      elif test "$hardcode_minus_L" = yes; then
2751b698ba48Smrg		add_dir="-L$dir"
2752b698ba48Smrg		# Try looking first in the location we're being installed to.
2753b698ba48Smrg		if test -n "$inst_prefix_dir"; then
2754b698ba48Smrg		  case $libdir in
2755b698ba48Smrg		    [\\/]*)
2756b698ba48Smrg		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
2757b698ba48Smrg		      ;;
2758b698ba48Smrg		  esac
2759b698ba48Smrg		fi
2760b698ba48Smrg		add="-l$name"
2761b698ba48Smrg	      elif test "$hardcode_shlibpath_var" = yes; then
2762b698ba48Smrg		add_shlibpath="$dir"
2763b698ba48Smrg		add="-l$name"
2764b698ba48Smrg	      else
2765b698ba48Smrg		lib_linked=no
2766b698ba48Smrg	      fi
2767b698ba48Smrg	      ;;
2768b698ba48Smrg	    *) lib_linked=no ;;
2769b698ba48Smrg	    esac
277009885543Smrg
2771b698ba48Smrg	    if test "$lib_linked" != yes; then
2772b698ba48Smrg	      $echo "$modename: configuration error: unsupported hardcode properties"
2773b698ba48Smrg	      exit $EXIT_FAILURE
2774b698ba48Smrg	    fi
277509885543Smrg
2776b698ba48Smrg	    if test -n "$add_shlibpath"; then
2777b698ba48Smrg	      case :$compile_shlibpath: in
2778b698ba48Smrg	      *":$add_shlibpath:"*) ;;
2779b698ba48Smrg	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
2780b698ba48Smrg	      esac
2781b698ba48Smrg	    fi
2782b698ba48Smrg	    if test "$linkmode" = prog; then
2783b698ba48Smrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
2784b698ba48Smrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
2785b698ba48Smrg	    else
2786b698ba48Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
2787b698ba48Smrg	      test -n "$add" && deplibs="$add $deplibs"
2788b698ba48Smrg	      if test "$hardcode_direct" != yes && \
2789b698ba48Smrg		 test "$hardcode_minus_L" != yes && \
2790b698ba48Smrg		 test "$hardcode_shlibpath_var" = yes; then
2791b698ba48Smrg		case :$finalize_shlibpath: in
2792b698ba48Smrg		*":$libdir:"*) ;;
2793b698ba48Smrg		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
2794b698ba48Smrg		esac
2795b698ba48Smrg	      fi
2796b698ba48Smrg	    fi
2797b698ba48Smrg	  fi
279809885543Smrg
2799b698ba48Smrg	  if test "$linkmode" = prog || test "$mode" = relink; then
2800b698ba48Smrg	    add_shlibpath=
2801b698ba48Smrg	    add_dir=
2802b698ba48Smrg	    add=
2803b698ba48Smrg	    # Finalize command for both is simple: just hardcode it.
2804b698ba48Smrg	    if test "$hardcode_direct" = yes; then
2805b698ba48Smrg	      add="$libdir/$linklib"
2806b698ba48Smrg	    elif test "$hardcode_minus_L" = yes; then
2807b698ba48Smrg	      add_dir="-L$libdir"
2808b698ba48Smrg	      add="-l$name"
2809b698ba48Smrg	    elif test "$hardcode_shlibpath_var" = yes; then
2810b698ba48Smrg	      case :$finalize_shlibpath: in
2811b698ba48Smrg	      *":$libdir:"*) ;;
2812b698ba48Smrg	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
2813b698ba48Smrg	      esac
2814b698ba48Smrg	      add="-l$name"
2815b698ba48Smrg	    elif test "$hardcode_automatic" = yes; then
2816b698ba48Smrg	      if test -n "$inst_prefix_dir" &&
2817b698ba48Smrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
2818b698ba48Smrg	        add="$inst_prefix_dir$libdir/$linklib"
2819b698ba48Smrg	      else
2820b698ba48Smrg	        add="$libdir/$linklib"
2821b698ba48Smrg	      fi
2822b698ba48Smrg	    else
2823b698ba48Smrg	      # We cannot seem to hardcode it, guess we'll fake it.
2824b698ba48Smrg	      add_dir="-L$libdir"
2825b698ba48Smrg	      # Try looking first in the location we're being installed to.
2826b698ba48Smrg	      if test -n "$inst_prefix_dir"; then
2827b698ba48Smrg		case $libdir in
2828b698ba48Smrg		  [\\/]*)
2829b698ba48Smrg		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
2830b698ba48Smrg		    ;;
2831b698ba48Smrg		esac
2832b698ba48Smrg	      fi
2833b698ba48Smrg	      add="-l$name"
2834b698ba48Smrg	    fi
28352ec8c4b4Smrg
2836b698ba48Smrg	    if test "$linkmode" = prog; then
2837b698ba48Smrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
2838b698ba48Smrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
2839b698ba48Smrg	    else
2840b698ba48Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
2841b698ba48Smrg	      test -n "$add" && deplibs="$add $deplibs"
2842b698ba48Smrg	    fi
2843b698ba48Smrg	  fi
2844b698ba48Smrg	elif test "$linkmode" = prog; then
2845b698ba48Smrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
2846b698ba48Smrg	  # is not unsupported.  This is valid on all known static and
2847b698ba48Smrg	  # shared platforms.
2848b698ba48Smrg	  if test "$hardcode_direct" != unsupported; then
2849b698ba48Smrg	    test -n "$old_library" && linklib="$old_library"
2850b698ba48Smrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
2851b698ba48Smrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
2852b698ba48Smrg	  else
2853b698ba48Smrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
2854b698ba48Smrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
2855b698ba48Smrg	  fi
2856b698ba48Smrg	elif test "$build_libtool_libs" = yes; then
2857b698ba48Smrg	  # Not a shared library
2858b698ba48Smrg	  if test "$deplibs_check_method" != pass_all; then
2859b698ba48Smrg	    # We're trying link a shared library against a static one
2860b698ba48Smrg	    # but the system doesn't support it.
286109885543Smrg
2862b698ba48Smrg	    # Just print a warning and add the library to dependency_libs so
2863b698ba48Smrg	    # that the program can be linked against the static library.
2864b698ba48Smrg	    $echo
2865b698ba48Smrg	    $echo "*** Warning: This system can not link to static lib archive $lib."
2866b698ba48Smrg	    $echo "*** I have the capability to make that library automatically link in when"
2867b698ba48Smrg	    $echo "*** you link to this library.  But I can only do this if you have a"
2868b698ba48Smrg	    $echo "*** shared version of the library, which you do not appear to have."
2869b698ba48Smrg	    if test "$module" = yes; then
2870b698ba48Smrg	      $echo "*** But as you try to build a module library, libtool will still create "
2871b698ba48Smrg	      $echo "*** a static module, that should work as long as the dlopening application"
2872b698ba48Smrg	      $echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
2873b698ba48Smrg	      if test -z "$global_symbol_pipe"; then
2874b698ba48Smrg		$echo
2875b698ba48Smrg		$echo "*** However, this would only work if libtool was able to extract symbol"
2876b698ba48Smrg		$echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
2877b698ba48Smrg		$echo "*** not find such a program.  So, this module is probably useless."
2878b698ba48Smrg		$echo "*** \`nm' from GNU binutils and a full rebuild may help."
2879b698ba48Smrg	      fi
2880b698ba48Smrg	      if test "$build_old_libs" = no; then
2881b698ba48Smrg		build_libtool_libs=module
2882b698ba48Smrg		build_old_libs=yes
2883b698ba48Smrg	      else
2884b698ba48Smrg		build_libtool_libs=no
2885b698ba48Smrg	      fi
2886b698ba48Smrg	    fi
2887b698ba48Smrg	  else
2888b698ba48Smrg	    deplibs="$dir/$old_library $deplibs"
2889b698ba48Smrg	    link_static=yes
2890b698ba48Smrg	  fi
2891b698ba48Smrg	fi # link shared/static library?
289209885543Smrg
2893b698ba48Smrg	if test "$linkmode" = lib; then
2894b698ba48Smrg	  if test -n "$dependency_libs" &&
2895b698ba48Smrg	     { test "$hardcode_into_libs" != yes ||
2896b698ba48Smrg	       test "$build_old_libs" = yes ||
2897b698ba48Smrg	       test "$link_static" = yes; }; then
2898b698ba48Smrg	    # Extract -R from dependency_libs
2899b698ba48Smrg	    temp_deplibs=
2900b698ba48Smrg	    for libdir in $dependency_libs; do
2901b698ba48Smrg	      case $libdir in
2902b698ba48Smrg	      -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'`
2903b698ba48Smrg		   case " $xrpath " in
2904b698ba48Smrg		   *" $temp_xrpath "*) ;;
2905b698ba48Smrg		   *) xrpath="$xrpath $temp_xrpath";;
2906b698ba48Smrg		   esac;;
2907b698ba48Smrg	      *) temp_deplibs="$temp_deplibs $libdir";;
2908b698ba48Smrg	      esac
2909b698ba48Smrg	    done
2910b698ba48Smrg	    dependency_libs="$temp_deplibs"
2911b698ba48Smrg	  fi
291209885543Smrg
2913b698ba48Smrg	  newlib_search_path="$newlib_search_path $absdir"
2914b698ba48Smrg	  # Link against this library
2915b698ba48Smrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
2916b698ba48Smrg	  # ... and its dependency_libs
2917b698ba48Smrg	  tmp_libs=
2918b698ba48Smrg	  for deplib in $dependency_libs; do
2919b698ba48Smrg	    newdependency_libs="$deplib $newdependency_libs"
2920b698ba48Smrg	    if test "X$duplicate_deps" = "Xyes" ; then
2921b698ba48Smrg	      case "$tmp_libs " in
2922b698ba48Smrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2923b698ba48Smrg	      esac
2924b698ba48Smrg	    fi
2925b698ba48Smrg	    tmp_libs="$tmp_libs $deplib"
2926b698ba48Smrg	  done
292709885543Smrg
2928b698ba48Smrg	  if test "$link_all_deplibs" != no; then
2929b698ba48Smrg	    # Add the search paths of all dependency libraries
2930b698ba48Smrg	    for deplib in $dependency_libs; do
2931b698ba48Smrg	      case $deplib in
2932b698ba48Smrg	      -L*) path="$deplib" ;;
2933b698ba48Smrg	      *.la)
2934b698ba48Smrg		dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'`
2935b698ba48Smrg		test "X$dir" = "X$deplib" && dir="."
2936b698ba48Smrg		# We need an absolute path.
2937b698ba48Smrg		case $dir in
2938b698ba48Smrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
2939b698ba48Smrg		*)
2940b698ba48Smrg		  absdir=`cd "$dir" && pwd`
2941b698ba48Smrg		  if test -z "$absdir"; then
2942b698ba48Smrg		    $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
2943b698ba48Smrg		    absdir="$dir"
2944b698ba48Smrg		  fi
2945b698ba48Smrg		  ;;
2946b698ba48Smrg		esac
2947b698ba48Smrg		if grep "^installed=no" $deplib > /dev/null; then
2948b698ba48Smrg		  path="$absdir/$objdir"
2949b698ba48Smrg		else
2950b698ba48Smrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
2951b698ba48Smrg		  if test -z "$libdir"; then
2952b698ba48Smrg		    $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
2953b698ba48Smrg		    exit $EXIT_FAILURE
2954b698ba48Smrg		  fi
2955b698ba48Smrg		  if test "$absdir" != "$libdir"; then
2956b698ba48Smrg		    $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2
2957b698ba48Smrg		  fi
2958b698ba48Smrg		  path="$absdir"
2959b698ba48Smrg		fi
2960b698ba48Smrg		depdepl=
2961b698ba48Smrg		case $host in
2962b698ba48Smrg		*-*-darwin*)
2963b698ba48Smrg		  # we do not want to link against static libs,
2964b698ba48Smrg		  # but need to link against shared
2965b698ba48Smrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
2966b698ba48Smrg		  eval deplibdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
2967b698ba48Smrg		  if test -n "$deplibrary_names" ; then
2968b698ba48Smrg		    for tmp in $deplibrary_names ; do
2969b698ba48Smrg		      depdepl=$tmp
2970b698ba48Smrg		    done
2971b698ba48Smrg		    if test -f "$deplibdir/$depdepl" ; then
2972b698ba48Smrg		      depdepl="$deplibdir/$depdepl"
2973b698ba48Smrg	      	    elif test -f "$path/$depdepl" ; then
2974b698ba48Smrg		      depdepl="$path/$depdepl"
2975b698ba48Smrg		    else
2976b698ba48Smrg		      # Can't find it, oh well...
2977b698ba48Smrg		      depdepl=
2978b698ba48Smrg		    fi
2979b698ba48Smrg		    # do not add paths which are already there
2980b698ba48Smrg		    case " $newlib_search_path " in
2981b698ba48Smrg		    *" $path "*) ;;
2982b698ba48Smrg		    *) newlib_search_path="$newlib_search_path $path";;
2983b698ba48Smrg		    esac
2984b698ba48Smrg		  fi
2985b698ba48Smrg		  path=""
2986b698ba48Smrg		  ;;
2987b698ba48Smrg		*)
2988b698ba48Smrg		  path="-L$path"
2989b698ba48Smrg		  ;;
2990b698ba48Smrg		esac
2991b698ba48Smrg		;;
2992b698ba48Smrg	      -l*)
2993b698ba48Smrg		case $host in
2994b698ba48Smrg		*-*-darwin*)
2995b698ba48Smrg		  # Again, we only want to link against shared libraries
2996b698ba48Smrg		  eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"`
2997b698ba48Smrg		  for tmp in $newlib_search_path ; do
2998b698ba48Smrg		    if test -f "$tmp/lib$tmp_libs.dylib" ; then
2999b698ba48Smrg		      eval depdepl="$tmp/lib$tmp_libs.dylib"
3000b698ba48Smrg		      break
3001b698ba48Smrg		    fi
3002b698ba48Smrg		  done
3003b698ba48Smrg		  path=""
3004b698ba48Smrg		  ;;
3005b698ba48Smrg		*) continue ;;
3006b698ba48Smrg		esac
3007b698ba48Smrg		;;
3008b698ba48Smrg	      *) continue ;;
3009b698ba48Smrg	      esac
3010b698ba48Smrg	      case " $deplibs " in
3011b698ba48Smrg	      *" $path "*) ;;
3012b698ba48Smrg	      *) deplibs="$path $deplibs" ;;
3013b698ba48Smrg	      esac
3014b698ba48Smrg	      case " $deplibs " in
3015b698ba48Smrg	      *" $depdepl "*) ;;
3016b698ba48Smrg	      *) deplibs="$depdepl $deplibs" ;;
3017b698ba48Smrg	      esac
3018b698ba48Smrg	    done
3019b698ba48Smrg	  fi # link_all_deplibs != no
3020b698ba48Smrg	fi # linkmode = lib
3021b698ba48Smrg      done # for deplib in $libs
3022b698ba48Smrg      dependency_libs="$newdependency_libs"
3023b698ba48Smrg      if test "$pass" = dlpreopen; then
3024b698ba48Smrg	# Link the dlpreopened libraries before other libraries
3025b698ba48Smrg	for deplib in $save_deplibs; do
3026b698ba48Smrg	  deplibs="$deplib $deplibs"
3027b698ba48Smrg	done
3028b698ba48Smrg      fi
3029b698ba48Smrg      if test "$pass" != dlopen; then
3030b698ba48Smrg	if test "$pass" != conv; then
3031b698ba48Smrg	  # Make sure lib_search_path contains only unique directories.
3032b698ba48Smrg	  lib_search_path=
3033b698ba48Smrg	  for dir in $newlib_search_path; do
3034b698ba48Smrg	    case "$lib_search_path " in
3035b698ba48Smrg	    *" $dir "*) ;;
3036b698ba48Smrg	    *) lib_search_path="$lib_search_path $dir" ;;
3037b698ba48Smrg	    esac
3038b698ba48Smrg	  done
3039b698ba48Smrg	  newlib_search_path=
3040b698ba48Smrg	fi
3041b698ba48Smrg
3042b698ba48Smrg	if test "$linkmode,$pass" != "prog,link"; then
3043b698ba48Smrg	  vars="deplibs"
3044b698ba48Smrg	else
3045b698ba48Smrg	  vars="compile_deplibs finalize_deplibs"
3046b698ba48Smrg	fi
3047b698ba48Smrg	for var in $vars dependency_libs; do
3048b698ba48Smrg	  # Add libraries to $var in reverse order
3049b698ba48Smrg	  eval tmp_libs=\"\$$var\"
3050b698ba48Smrg	  new_libs=
3051b698ba48Smrg	  for deplib in $tmp_libs; do
3052b698ba48Smrg	    # FIXME: Pedantically, this is the right thing to do, so
3053b698ba48Smrg	    #        that some nasty dependency loop isn't accidentally
3054b698ba48Smrg	    #        broken:
3055b698ba48Smrg	    #new_libs="$deplib $new_libs"
3056b698ba48Smrg	    # Pragmatically, this seems to cause very few problems in
3057b698ba48Smrg	    # practice:
3058b698ba48Smrg	    case $deplib in
3059b698ba48Smrg	    -L*) new_libs="$deplib $new_libs" ;;
3060b698ba48Smrg	    -R*) ;;
3061b698ba48Smrg	    *)
3062b698ba48Smrg	      # And here is the reason: when a library appears more
3063b698ba48Smrg	      # than once as an explicit dependence of a library, or
3064b698ba48Smrg	      # is implicitly linked in more than once by the
3065b698ba48Smrg	      # compiler, it is considered special, and multiple
3066b698ba48Smrg	      # occurrences thereof are not removed.  Compare this
3067b698ba48Smrg	      # with having the same library being listed as a
3068b698ba48Smrg	      # dependency of multiple other libraries: in this case,
3069b698ba48Smrg	      # we know (pedantically, we assume) the library does not
3070b698ba48Smrg	      # need to be listed more than once, so we keep only the
3071b698ba48Smrg	      # last copy.  This is not always right, but it is rare
3072b698ba48Smrg	      # enough that we require users that really mean to play
3073b698ba48Smrg	      # such unportable linking tricks to link the library
3074b698ba48Smrg	      # using -Wl,-lname, so that libtool does not consider it
3075b698ba48Smrg	      # for duplicate removal.
3076b698ba48Smrg	      case " $specialdeplibs " in
3077b698ba48Smrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
3078b698ba48Smrg	      *)
3079b698ba48Smrg		case " $new_libs " in
3080b698ba48Smrg		*" $deplib "*) ;;
3081b698ba48Smrg		*) new_libs="$deplib $new_libs" ;;
3082b698ba48Smrg		esac
3083b698ba48Smrg		;;
3084b698ba48Smrg	      esac
3085b698ba48Smrg	      ;;
3086b698ba48Smrg	    esac
3087b698ba48Smrg	  done
3088b698ba48Smrg	  tmp_libs=
3089b698ba48Smrg	  for deplib in $new_libs; do
3090b698ba48Smrg	    case $deplib in
3091b698ba48Smrg	    -L*)
3092b698ba48Smrg	      case " $tmp_libs " in
3093b698ba48Smrg	      *" $deplib "*) ;;
3094b698ba48Smrg	      *) tmp_libs="$tmp_libs $deplib" ;;
3095b698ba48Smrg	      esac
3096b698ba48Smrg	      ;;
3097b698ba48Smrg	    *) tmp_libs="$tmp_libs $deplib" ;;
3098b698ba48Smrg	    esac
3099b698ba48Smrg	  done
3100b698ba48Smrg	  eval $var=\"$tmp_libs\"
3101b698ba48Smrg	done # for var
3102b698ba48Smrg      fi
3103b698ba48Smrg      # Last step: remove runtime libs from dependency_libs
3104b698ba48Smrg      # (they stay in deplibs)
3105b698ba48Smrg      tmp_libs=
3106b698ba48Smrg      for i in $dependency_libs ; do
3107b698ba48Smrg	case " $predeps $postdeps $compiler_lib_search_path " in
3108b698ba48Smrg	*" $i "*)
3109b698ba48Smrg	  i=""
311009885543Smrg	  ;;
311109885543Smrg	esac
3112b698ba48Smrg	if test -n "$i" ; then
3113b698ba48Smrg	  tmp_libs="$tmp_libs $i"
3114b698ba48Smrg	fi
3115b698ba48Smrg      done
3116b698ba48Smrg      dependency_libs=$tmp_libs
3117b698ba48Smrg    done # for pass
3118b698ba48Smrg    if test "$linkmode" = prog; then
3119b698ba48Smrg      dlfiles="$newdlfiles"
3120b698ba48Smrg      dlprefiles="$newdlprefiles"
31212ec8c4b4Smrg    fi
312209885543Smrg
3123b698ba48Smrg    case $linkmode in
3124b698ba48Smrg    oldlib)
3125b698ba48Smrg      case " $deplibs" in
3126b698ba48Smrg      *\ -l* | *\ -L*)
3127b698ba48Smrg	$echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2 ;;
3128b698ba48Smrg      esac
312909885543Smrg
3130b698ba48Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
3131b698ba48Smrg	$echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
3132b698ba48Smrg      fi
313309885543Smrg
3134b698ba48Smrg      if test -n "$rpath"; then
3135b698ba48Smrg	$echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2
3136b698ba48Smrg      fi
313709885543Smrg
3138b698ba48Smrg      if test -n "$xrpath"; then
3139b698ba48Smrg	$echo "$modename: warning: \`-R' is ignored for archives" 1>&2
3140b698ba48Smrg      fi
314109885543Smrg
3142b698ba48Smrg      if test -n "$vinfo"; then
3143b698ba48Smrg	$echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2
3144b698ba48Smrg      fi
314509885543Smrg
3146b698ba48Smrg      if test -n "$release"; then
3147b698ba48Smrg	$echo "$modename: warning: \`-release' is ignored for archives" 1>&2
3148b698ba48Smrg      fi
314909885543Smrg
3150b698ba48Smrg      if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
3151b698ba48Smrg	$echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2
3152b698ba48Smrg      fi
315309885543Smrg
3154b698ba48Smrg      # Now set the variables for building old libraries.
3155b698ba48Smrg      build_libtool_libs=no
3156b698ba48Smrg      oldlibs="$output"
3157b698ba48Smrg      objs="$objs$old_deplibs"
3158b698ba48Smrg      ;;
315909885543Smrg
3160b698ba48Smrg    lib)
3161b698ba48Smrg      # Make sure we only generate libraries of the form `libNAME.la'.
3162b698ba48Smrg      case $outputname in
3163b698ba48Smrg      lib*)
3164b698ba48Smrg	name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
3165b698ba48Smrg	eval shared_ext=\"$shrext_cmds\"
3166b698ba48Smrg	eval libname=\"$libname_spec\"
3167b698ba48Smrg	;;
3168b698ba48Smrg      *)
3169b698ba48Smrg	if test "$module" = no; then
3170b698ba48Smrg	  $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
3171b698ba48Smrg	  $echo "$help" 1>&2
3172b698ba48Smrg	  exit $EXIT_FAILURE
3173b698ba48Smrg	fi
3174b698ba48Smrg	if test "$need_lib_prefix" != no; then
3175b698ba48Smrg	  # Add the "lib" prefix for modules if required
3176b698ba48Smrg	  name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
3177b698ba48Smrg	  eval shared_ext=\"$shrext_cmds\"
3178b698ba48Smrg	  eval libname=\"$libname_spec\"
3179b698ba48Smrg	else
3180b698ba48Smrg	  libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
3181b698ba48Smrg	fi
3182b698ba48Smrg	;;
3183b698ba48Smrg      esac
318409885543Smrg
3185b698ba48Smrg      if test -n "$objs"; then
3186b698ba48Smrg	if test "$deplibs_check_method" != pass_all; then
3187b698ba48Smrg	  $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1
3188b698ba48Smrg	  exit $EXIT_FAILURE
3189b698ba48Smrg	else
3190b698ba48Smrg	  $echo
3191b698ba48Smrg	  $echo "*** Warning: Linking the shared library $output against the non-libtool"
3192b698ba48Smrg	  $echo "*** objects $objs is not portable!"
3193b698ba48Smrg	  libobjs="$libobjs $objs"
3194b698ba48Smrg	fi
3195b698ba48Smrg      fi
319609885543Smrg
3197b698ba48Smrg      if test "$dlself" != no; then
3198b698ba48Smrg	$echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2
3199b698ba48Smrg      fi
320009885543Smrg
3201b698ba48Smrg      set dummy $rpath
3202b698ba48Smrg      if test "$#" -gt 2; then
3203b698ba48Smrg	$echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
3204b698ba48Smrg      fi
3205b698ba48Smrg      install_libdir="$2"
320609885543Smrg
3207b698ba48Smrg      oldlibs=
3208b698ba48Smrg      if test -z "$rpath"; then
3209b698ba48Smrg	if test "$build_libtool_libs" = yes; then
3210b698ba48Smrg	  # Building a libtool convenience library.
3211b698ba48Smrg	  # Some compilers have problems with a `.al' extension so
3212b698ba48Smrg	  # convenience libraries should have the same extension an
3213b698ba48Smrg	  # archive normally would.
3214b698ba48Smrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
3215b698ba48Smrg	  build_libtool_libs=convenience
3216b698ba48Smrg	  build_old_libs=yes
3217b698ba48Smrg	fi
321809885543Smrg
3219b698ba48Smrg	if test -n "$vinfo"; then
3220b698ba48Smrg	  $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2
3221b698ba48Smrg	fi
322209885543Smrg
3223b698ba48Smrg	if test -n "$release"; then
3224b698ba48Smrg	  $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2
3225b698ba48Smrg	fi
3226b698ba48Smrg      else
322709885543Smrg
3228b698ba48Smrg	# Parse the version information argument.
3229b698ba48Smrg	save_ifs="$IFS"; IFS=':'
3230b698ba48Smrg	set dummy $vinfo 0 0 0
3231b698ba48Smrg	IFS="$save_ifs"
323209885543Smrg
3233b698ba48Smrg	if test -n "$8"; then
3234b698ba48Smrg	  $echo "$modename: too many parameters to \`-version-info'" 1>&2
3235b698ba48Smrg	  $echo "$help" 1>&2
3236b698ba48Smrg	  exit $EXIT_FAILURE
3237b698ba48Smrg	fi
323809885543Smrg
3239b698ba48Smrg	# convert absolute version numbers to libtool ages
3240b698ba48Smrg	# this retains compatibility with .la files and attempts
3241b698ba48Smrg	# to make the code below a bit more comprehensible
324209885543Smrg
3243b698ba48Smrg	case $vinfo_number in
3244b698ba48Smrg	yes)
3245b698ba48Smrg	  number_major="$2"
3246b698ba48Smrg	  number_minor="$3"
3247b698ba48Smrg	  number_revision="$4"
3248b698ba48Smrg	  #
3249b698ba48Smrg	  # There are really only two kinds -- those that
3250b698ba48Smrg	  # use the current revision as the major version
3251b698ba48Smrg	  # and those that subtract age and use age as
3252b698ba48Smrg	  # a minor version.  But, then there is irix
3253b698ba48Smrg	  # which has an extra 1 added just for fun
3254b698ba48Smrg	  #
3255b698ba48Smrg	  case $version_type in
3256b698ba48Smrg	  darwin|linux|osf|windows|none)
3257b698ba48Smrg	    current=`expr $number_major + $number_minor`
3258b698ba48Smrg	    age="$number_minor"
3259b698ba48Smrg	    revision="$number_revision"
3260b698ba48Smrg	    ;;
3261b698ba48Smrg	  freebsd-aout|freebsd-elf|sunos)
3262b698ba48Smrg	    current="$number_major"
3263b698ba48Smrg	    revision="$number_minor"
3264b698ba48Smrg	    age="0"
3265b698ba48Smrg	    ;;
3266b698ba48Smrg	  irix|nonstopux)
3267b698ba48Smrg	    current=`expr $number_major + $number_minor`
3268b698ba48Smrg	    age="$number_minor"
3269b698ba48Smrg	    revision="$number_minor"
3270b698ba48Smrg	    lt_irix_increment=no
3271b698ba48Smrg	    ;;
3272b698ba48Smrg	  esac
3273b698ba48Smrg	  ;;
3274b698ba48Smrg	no)
3275b698ba48Smrg	  current="$2"
3276b698ba48Smrg	  revision="$3"
3277b698ba48Smrg	  age="$4"
3278b698ba48Smrg	  ;;
3279b698ba48Smrg	esac
328009885543Smrg
3281b698ba48Smrg	# Check that each of the things are valid numbers.
3282b698ba48Smrg	case $current in
3283b698ba48Smrg	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
3284b698ba48Smrg	*)
3285b698ba48Smrg	  $echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2
3286b698ba48Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3287b698ba48Smrg	  exit $EXIT_FAILURE
3288b698ba48Smrg	  ;;
3289b698ba48Smrg	esac
329009885543Smrg
3291b698ba48Smrg	case $revision in
3292b698ba48Smrg	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
3293b698ba48Smrg	*)
3294b698ba48Smrg	  $echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2
3295b698ba48Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3296b698ba48Smrg	  exit $EXIT_FAILURE
3297b698ba48Smrg	  ;;
3298b698ba48Smrg	esac
329909885543Smrg
3300b698ba48Smrg	case $age in
3301b698ba48Smrg	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
3302b698ba48Smrg	*)
3303b698ba48Smrg	  $echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2
3304b698ba48Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3305b698ba48Smrg	  exit $EXIT_FAILURE
3306b698ba48Smrg	  ;;
3307b698ba48Smrg	esac
330809885543Smrg
3309b698ba48Smrg	if test "$age" -gt "$current"; then
3310b698ba48Smrg	  $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
3311b698ba48Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3312b698ba48Smrg	  exit $EXIT_FAILURE
3313b698ba48Smrg	fi
331409885543Smrg
3315b698ba48Smrg	# Calculate the version variables.
3316b698ba48Smrg	major=
3317b698ba48Smrg	versuffix=
3318b698ba48Smrg	verstring=
3319b698ba48Smrg	case $version_type in
3320b698ba48Smrg	none) ;;
332109885543Smrg
3322b698ba48Smrg	darwin)
3323b698ba48Smrg	  # Like Linux, but with the current version available in
3324b698ba48Smrg	  # verstring for coding it into the library header
3325b698ba48Smrg	  major=.`expr $current - $age`
3326b698ba48Smrg	  versuffix="$major.$age.$revision"
3327b698ba48Smrg	  # Darwin ld doesn't like 0 for these options...
3328b698ba48Smrg	  minor_current=`expr $current + 1`
3329b698ba48Smrg	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
3330b698ba48Smrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
3331b698ba48Smrg	  ;;
333209885543Smrg
3333b698ba48Smrg	freebsd-aout)
3334b698ba48Smrg	  major=".$current"
3335b698ba48Smrg	  versuffix=".$current.$revision";
3336b698ba48Smrg	  ;;
333709885543Smrg
3338b698ba48Smrg	freebsd-elf)
3339b698ba48Smrg	  major=".$current"
3340b698ba48Smrg	  versuffix=".$current";
3341b698ba48Smrg	  ;;
33422ec8c4b4Smrg
3343b698ba48Smrg	irix | nonstopux)
3344b698ba48Smrg	  if test "X$lt_irix_increment" = "Xno"; then
3345b698ba48Smrg	    major=`expr $current - $age`
3346b698ba48Smrg	  else
3347b698ba48Smrg	    major=`expr $current - $age + 1`
3348b698ba48Smrg	  fi
3349b698ba48Smrg	  case $version_type in
3350b698ba48Smrg	    nonstopux) verstring_prefix=nonstopux ;;
3351b698ba48Smrg	    *)         verstring_prefix=sgi ;;
3352b698ba48Smrg	  esac
3353b698ba48Smrg	  verstring="$verstring_prefix$major.$revision"
335409885543Smrg
3355b698ba48Smrg	  # Add in all the interfaces that we are compatible with.
3356b698ba48Smrg	  loop=$revision
3357b698ba48Smrg	  while test "$loop" -ne 0; do
3358b698ba48Smrg	    iface=`expr $revision - $loop`
3359b698ba48Smrg	    loop=`expr $loop - 1`
3360b698ba48Smrg	    verstring="$verstring_prefix$major.$iface:$verstring"
3361b698ba48Smrg	  done
336209885543Smrg
3363b698ba48Smrg	  # Before this point, $major must not contain `.'.
3364b698ba48Smrg	  major=.$major
3365b698ba48Smrg	  versuffix="$major.$revision"
3366b698ba48Smrg	  ;;
336709885543Smrg
3368b698ba48Smrg	linux)
3369b698ba48Smrg	  major=.`expr $current - $age`
3370b698ba48Smrg	  versuffix="$major.$age.$revision"
3371b698ba48Smrg	  ;;
337209885543Smrg
3373b698ba48Smrg	osf)
3374b698ba48Smrg	  major=.`expr $current - $age`
3375b698ba48Smrg	  versuffix=".$current.$age.$revision"
3376b698ba48Smrg	  verstring="$current.$age.$revision"
337709885543Smrg
3378b698ba48Smrg	  # Add in all the interfaces that we are compatible with.
3379b698ba48Smrg	  loop=$age
3380b698ba48Smrg	  while test "$loop" -ne 0; do
3381b698ba48Smrg	    iface=`expr $current - $loop`
3382b698ba48Smrg	    loop=`expr $loop - 1`
3383b698ba48Smrg	    verstring="$verstring:${iface}.0"
3384b698ba48Smrg	  done
338509885543Smrg
3386b698ba48Smrg	  # Make executables depend on our current version.
3387b698ba48Smrg	  verstring="$verstring:${current}.0"
3388b698ba48Smrg	  ;;
338909885543Smrg
3390b698ba48Smrg	sunos)
3391b698ba48Smrg	  major=".$current"
3392b698ba48Smrg	  versuffix=".$current.$revision"
3393b698ba48Smrg	  ;;
339409885543Smrg
3395b698ba48Smrg	windows)
3396b698ba48Smrg	  # Use '-' rather than '.', since we only want one
3397b698ba48Smrg	  # extension on DOS 8.3 filesystems.
3398b698ba48Smrg	  major=`expr $current - $age`
3399b698ba48Smrg	  versuffix="-$major"
3400b698ba48Smrg	  ;;
340109885543Smrg
3402b698ba48Smrg	*)
3403b698ba48Smrg	  $echo "$modename: unknown library version type \`$version_type'" 1>&2
3404b698ba48Smrg	  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
3405b698ba48Smrg	  exit $EXIT_FAILURE
3406b698ba48Smrg	  ;;
3407b698ba48Smrg	esac
340809885543Smrg
3409b698ba48Smrg	# Clear the version info if we defaulted, and they specified a release.
3410b698ba48Smrg	if test -z "$vinfo" && test -n "$release"; then
3411b698ba48Smrg	  major=
3412b698ba48Smrg	  case $version_type in
3413b698ba48Smrg	  darwin)
3414b698ba48Smrg	    # we can't check for "0.0" in archive_cmds due to quoting
3415b698ba48Smrg	    # problems, so we reset it completely
3416b698ba48Smrg	    verstring=
34172ec8c4b4Smrg	    ;;
3418b698ba48Smrg	  *)
3419b698ba48Smrg	    verstring="0.0"
3420b698ba48Smrg	    ;;
3421b698ba48Smrg	  esac
3422b698ba48Smrg	  if test "$need_version" = no; then
3423b698ba48Smrg	    versuffix=
3424b698ba48Smrg	  else
3425b698ba48Smrg	    versuffix=".0.0"
3426b698ba48Smrg	  fi
3427b698ba48Smrg	fi
342809885543Smrg
3429b698ba48Smrg	# Remove version info from name if versioning should be avoided
3430b698ba48Smrg	if test "$avoid_version" = yes && test "$need_version" = no; then
3431b698ba48Smrg	  major=
3432b698ba48Smrg	  versuffix=
3433b698ba48Smrg	  verstring=""
3434b698ba48Smrg	fi
343509885543Smrg
3436b698ba48Smrg	# Check to see if the archive will have undefined symbols.
3437b698ba48Smrg	if test "$allow_undefined" = yes; then
3438b698ba48Smrg	  if test "$allow_undefined_flag" = unsupported; then
3439b698ba48Smrg	    $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2
3440b698ba48Smrg	    build_libtool_libs=no
3441b698ba48Smrg	    build_old_libs=yes
3442b698ba48Smrg	  fi
3443b698ba48Smrg	else
3444b698ba48Smrg	  # Don't allow undefined symbols.
3445b698ba48Smrg	  allow_undefined_flag="$no_undefined_flag"
3446b698ba48Smrg	fi
3447b698ba48Smrg      fi
344809885543Smrg
3449b698ba48Smrg      if test "$mode" != relink; then
3450b698ba48Smrg	# Remove our outputs, but don't remove object files since they
3451b698ba48Smrg	# may have been created when compiling PIC objects.
3452b698ba48Smrg	removelist=
3453b698ba48Smrg	tempremovelist=`$echo "$output_objdir/*"`
3454b698ba48Smrg	for p in $tempremovelist; do
3455b698ba48Smrg	  case $p in
3456b698ba48Smrg	    *.$objext)
3457b698ba48Smrg	       ;;
3458b698ba48Smrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
3459b698ba48Smrg	       if test "X$precious_files_regex" != "X"; then
3460b698ba48Smrg	         if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
3461b698ba48Smrg	         then
3462b698ba48Smrg		   continue
3463b698ba48Smrg		 fi
3464b698ba48Smrg	       fi
3465b698ba48Smrg	       removelist="$removelist $p"
3466b698ba48Smrg	       ;;
3467b698ba48Smrg	    *) ;;
3468b698ba48Smrg	  esac
3469b698ba48Smrg	done
3470b698ba48Smrg	if test -n "$removelist"; then
3471b698ba48Smrg	  $show "${rm}r $removelist"
3472b698ba48Smrg	  $run ${rm}r $removelist
3473b698ba48Smrg	fi
3474b698ba48Smrg      fi
347509885543Smrg
3476b698ba48Smrg      # Now set the variables for building old libraries.
3477b698ba48Smrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
3478b698ba48Smrg	oldlibs="$oldlibs $output_objdir/$libname.$libext"
347909885543Smrg
3480b698ba48Smrg	# Transform .lo files to .o files.
3481b698ba48Smrg	oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
3482b698ba48Smrg      fi
348309885543Smrg
3484b698ba48Smrg      # Eliminate all temporary directories.
3485b698ba48Smrg      #for path in $notinst_path; do
3486b698ba48Smrg      #	lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"`
3487b698ba48Smrg      #	deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"`
3488b698ba48Smrg      #	dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"`
3489b698ba48Smrg      #done
349009885543Smrg
3491b698ba48Smrg      if test -n "$xrpath"; then
3492b698ba48Smrg	# If the user specified any rpath flags, then add them.
3493b698ba48Smrg	temp_xrpath=
3494b698ba48Smrg	for libdir in $xrpath; do
3495b698ba48Smrg	  temp_xrpath="$temp_xrpath -R$libdir"
3496b698ba48Smrg	  case "$finalize_rpath " in
3497b698ba48Smrg	  *" $libdir "*) ;;
3498b698ba48Smrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
3499b698ba48Smrg	  esac
3500b698ba48Smrg	done
3501b698ba48Smrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
3502b698ba48Smrg	  dependency_libs="$temp_xrpath $dependency_libs"
3503b698ba48Smrg	fi
3504b698ba48Smrg      fi
350509885543Smrg
3506b698ba48Smrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
3507b698ba48Smrg      old_dlfiles="$dlfiles"
3508b698ba48Smrg      dlfiles=
3509b698ba48Smrg      for lib in $old_dlfiles; do
3510b698ba48Smrg	case " $dlprefiles $dlfiles " in
3511b698ba48Smrg	*" $lib "*) ;;
3512b698ba48Smrg	*) dlfiles="$dlfiles $lib" ;;
3513b698ba48Smrg	esac
3514b698ba48Smrg      done
351509885543Smrg
3516b698ba48Smrg      # Make sure dlprefiles contains only unique files
3517b698ba48Smrg      old_dlprefiles="$dlprefiles"
3518b698ba48Smrg      dlprefiles=
3519b698ba48Smrg      for lib in $old_dlprefiles; do
3520b698ba48Smrg	case "$dlprefiles " in
3521b698ba48Smrg	*" $lib "*) ;;
3522b698ba48Smrg	*) dlprefiles="$dlprefiles $lib" ;;
3523b698ba48Smrg	esac
3524b698ba48Smrg      done
352509885543Smrg
3526b698ba48Smrg      if test "$build_libtool_libs" = yes; then
3527b698ba48Smrg	if test -n "$rpath"; then
3528b698ba48Smrg	  case $host in
3529b698ba48Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*)
3530b698ba48Smrg	    # these systems don't actually have a c library (as such)!
3531b698ba48Smrg	    ;;
3532b698ba48Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
3533b698ba48Smrg	    # Rhapsody C library is in the System framework
3534b698ba48Smrg	    deplibs="$deplibs -framework System"
3535b698ba48Smrg	    ;;
3536b698ba48Smrg	  *-*-netbsd*)
3537b698ba48Smrg	    # Don't link with libc until the a.out ld.so is fixed.
3538b698ba48Smrg	    ;;
3539b698ba48Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
3540b698ba48Smrg	    # Do not include libc due to us having libc/libc_r.
3541b698ba48Smrg	    ;;
3542b698ba48Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
3543b698ba48Smrg	    # Causes problems with __ctype
3544b698ba48Smrg	    ;;
3545b698ba48Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
3546b698ba48Smrg	    # Compiler inserts libc in the correct place for threads to work
3547b698ba48Smrg	    ;;
3548b698ba48Smrg 	  *)
3549b698ba48Smrg	    # Add libc to deplibs on all other systems if necessary.
3550b698ba48Smrg	    if test "$build_libtool_need_lc" = "yes"; then
3551b698ba48Smrg	      deplibs="$deplibs -lc"
3552b698ba48Smrg	    fi
3553b698ba48Smrg	    ;;
3554b698ba48Smrg	  esac
3555b698ba48Smrg	fi
355609885543Smrg
3557b698ba48Smrg	# Transform deplibs into only deplibs that can be linked in shared.
3558b698ba48Smrg	name_save=$name
3559b698ba48Smrg	libname_save=$libname
3560b698ba48Smrg	release_save=$release
3561b698ba48Smrg	versuffix_save=$versuffix
3562b698ba48Smrg	major_save=$major
3563b698ba48Smrg	# I'm not sure if I'm treating the release correctly.  I think
3564b698ba48Smrg	# release should show up in the -l (ie -lgmp5) so we don't want to
3565b698ba48Smrg	# add it in twice.  Is that correct?
3566b698ba48Smrg	release=""
3567b698ba48Smrg	versuffix=""
3568b698ba48Smrg	major=""
3569b698ba48Smrg	newdeplibs=
3570b698ba48Smrg	droppeddeps=no
3571b698ba48Smrg	case $deplibs_check_method in
3572b698ba48Smrg	pass_all)
3573b698ba48Smrg	  # Don't check for shared/static.  Everything works.
3574b698ba48Smrg	  # This might be a little naive.  We might want to check
3575b698ba48Smrg	  # whether the library exists or not.  But this is on
3576b698ba48Smrg	  # osf3 & osf4 and I'm not really sure... Just
3577b698ba48Smrg	  # implementing what was already the behavior.
3578b698ba48Smrg	  newdeplibs=$deplibs
3579b698ba48Smrg	  ;;
3580b698ba48Smrg	test_compile)
3581b698ba48Smrg	  # This code stresses the "libraries are programs" paradigm to its
3582b698ba48Smrg	  # limits. Maybe even breaks it.  We compile a program, linking it
3583b698ba48Smrg	  # against the deplibs as a proxy for the library.  Then we can check
3584b698ba48Smrg	  # whether they linked in statically or dynamically with ldd.
3585b698ba48Smrg	  $rm conftest.c
3586b698ba48Smrg	  cat > conftest.c <<EOF
3587b698ba48Smrg	  int main() { return 0; }
3588b698ba48SmrgEOF
3589b698ba48Smrg	  $rm conftest
3590b698ba48Smrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
3591b698ba48Smrg	    ldd_output=`ldd conftest`
3592b698ba48Smrg	    for i in $deplibs; do
3593b698ba48Smrg	      name=`expr $i : '-l\(.*\)'`
3594b698ba48Smrg	      # If $name is empty we are operating on a -L argument.
3595b698ba48Smrg              if test "$name" != "" && test "$name" != "0"; then
3596b698ba48Smrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3597b698ba48Smrg		  case " $predeps $postdeps " in
3598b698ba48Smrg		  *" $i "*)
3599b698ba48Smrg		    newdeplibs="$newdeplibs $i"
3600b698ba48Smrg		    i=""
3601b698ba48Smrg		    ;;
3602b698ba48Smrg		  esac
3603b698ba48Smrg	        fi
3604b698ba48Smrg		if test -n "$i" ; then
3605b698ba48Smrg		  libname=`eval \\$echo \"$libname_spec\"`
3606b698ba48Smrg		  deplib_matches=`eval \\$echo \"$library_names_spec\"`
3607b698ba48Smrg		  set dummy $deplib_matches
3608b698ba48Smrg		  deplib_match=$2
3609b698ba48Smrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
3610b698ba48Smrg		    newdeplibs="$newdeplibs $i"
3611b698ba48Smrg		  else
3612b698ba48Smrg		    droppeddeps=yes
3613b698ba48Smrg		    $echo
3614b698ba48Smrg		    $echo "*** Warning: dynamic linker does not accept needed library $i."
3615b698ba48Smrg		    $echo "*** I have the capability to make that library automatically link in when"
3616b698ba48Smrg		    $echo "*** you link to this library.  But I can only do this if you have a"
3617b698ba48Smrg		    $echo "*** shared version of the library, which I believe you do not have"
3618b698ba48Smrg		    $echo "*** because a test_compile did reveal that the linker did not use it for"
3619b698ba48Smrg		    $echo "*** its dynamic dependency list that programs get resolved with at runtime."
3620b698ba48Smrg		  fi
3621b698ba48Smrg		fi
3622b698ba48Smrg	      else
3623b698ba48Smrg		newdeplibs="$newdeplibs $i"
3624b698ba48Smrg	      fi
3625b698ba48Smrg	    done
3626b698ba48Smrg	  else
3627b698ba48Smrg	    # Error occurred in the first compile.  Let's try to salvage
3628b698ba48Smrg	    # the situation: Compile a separate program for each library.
3629b698ba48Smrg	    for i in $deplibs; do
3630b698ba48Smrg	      name=`expr $i : '-l\(.*\)'`
3631b698ba48Smrg	      # If $name is empty we are operating on a -L argument.
3632b698ba48Smrg              if test "$name" != "" && test "$name" != "0"; then
3633b698ba48Smrg		$rm conftest
3634b698ba48Smrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
3635b698ba48Smrg		  ldd_output=`ldd conftest`
3636b698ba48Smrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3637b698ba48Smrg		    case " $predeps $postdeps " in
3638b698ba48Smrg		    *" $i "*)
3639b698ba48Smrg		      newdeplibs="$newdeplibs $i"
3640b698ba48Smrg		      i=""
3641b698ba48Smrg		      ;;
3642b698ba48Smrg		    esac
3643b698ba48Smrg		  fi
3644b698ba48Smrg		  if test -n "$i" ; then
3645b698ba48Smrg		    libname=`eval \\$echo \"$libname_spec\"`
3646b698ba48Smrg		    deplib_matches=`eval \\$echo \"$library_names_spec\"`
3647b698ba48Smrg		    set dummy $deplib_matches
3648b698ba48Smrg		    deplib_match=$2
3649b698ba48Smrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
3650b698ba48Smrg		      newdeplibs="$newdeplibs $i"
3651b698ba48Smrg		    else
3652b698ba48Smrg		      droppeddeps=yes
3653b698ba48Smrg		      $echo
3654b698ba48Smrg		      $echo "*** Warning: dynamic linker does not accept needed library $i."
3655b698ba48Smrg		      $echo "*** I have the capability to make that library automatically link in when"
3656b698ba48Smrg		      $echo "*** you link to this library.  But I can only do this if you have a"
3657b698ba48Smrg		      $echo "*** shared version of the library, which you do not appear to have"
3658b698ba48Smrg		      $echo "*** because a test_compile did reveal that the linker did not use this one"
3659b698ba48Smrg		      $echo "*** as a dynamic dependency that programs can get resolved with at runtime."
3660b698ba48Smrg		    fi
3661b698ba48Smrg		  fi
3662b698ba48Smrg		else
3663b698ba48Smrg		  droppeddeps=yes
3664b698ba48Smrg		  $echo
3665b698ba48Smrg		  $echo "*** Warning!  Library $i is needed by this library but I was not able to"
3666b698ba48Smrg		  $echo "*** make it link in!  You will probably need to install it or some"
3667b698ba48Smrg		  $echo "*** library that it depends on before this library will be fully"
3668b698ba48Smrg		  $echo "*** functional.  Installing it before continuing would be even better."
3669b698ba48Smrg		fi
3670b698ba48Smrg	      else
3671b698ba48Smrg		newdeplibs="$newdeplibs $i"
3672b698ba48Smrg	      fi
3673b698ba48Smrg	    done
3674b698ba48Smrg	  fi
3675b698ba48Smrg	  ;;
3676b698ba48Smrg	file_magic*)
3677b698ba48Smrg	  set dummy $deplibs_check_method
3678b698ba48Smrg	  file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
3679b698ba48Smrg	  for a_deplib in $deplibs; do
3680b698ba48Smrg	    name=`expr $a_deplib : '-l\(.*\)'`
3681b698ba48Smrg	    # If $name is empty we are operating on a -L argument.
3682b698ba48Smrg            if test "$name" != "" && test  "$name" != "0"; then
3683b698ba48Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3684b698ba48Smrg		case " $predeps $postdeps " in
3685b698ba48Smrg		*" $a_deplib "*)
3686b698ba48Smrg		  newdeplibs="$newdeplibs $a_deplib"
3687b698ba48Smrg		  a_deplib=""
3688b698ba48Smrg		  ;;
3689b698ba48Smrg		esac
3690b698ba48Smrg	      fi
3691b698ba48Smrg	      if test -n "$a_deplib" ; then
3692b698ba48Smrg		libname=`eval \\$echo \"$libname_spec\"`
3693b698ba48Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
3694b698ba48Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
3695b698ba48Smrg		  for potent_lib in $potential_libs; do
3696b698ba48Smrg		      # Follow soft links.
3697b698ba48Smrg		      if ls -lLd "$potent_lib" 2>/dev/null \
3698b698ba48Smrg			 | grep " -> " >/dev/null; then
3699b698ba48Smrg			continue
3700b698ba48Smrg		      fi
3701b698ba48Smrg		      # The statement above tries to avoid entering an
3702b698ba48Smrg		      # endless loop below, in case of cyclic links.
3703b698ba48Smrg		      # We might still enter an endless loop, since a link
3704b698ba48Smrg		      # loop can be closed while we follow links,
3705b698ba48Smrg		      # but so what?
3706b698ba48Smrg		      potlib="$potent_lib"
3707b698ba48Smrg		      while test -h "$potlib" 2>/dev/null; do
3708b698ba48Smrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
3709b698ba48Smrg			case $potliblink in
3710b698ba48Smrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
3711b698ba48Smrg			*) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
3712b698ba48Smrg			esac
3713b698ba48Smrg		      done
3714b698ba48Smrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
3715b698ba48Smrg			 | ${SED} 10q \
3716b698ba48Smrg			 | $EGREP "$file_magic_regex" > /dev/null; then
3717b698ba48Smrg			newdeplibs="$newdeplibs $a_deplib"
3718b698ba48Smrg			a_deplib=""
3719b698ba48Smrg			break 2
3720b698ba48Smrg		      fi
3721b698ba48Smrg		  done
3722b698ba48Smrg		done
3723b698ba48Smrg	      fi
3724b698ba48Smrg	      if test -n "$a_deplib" ; then
3725b698ba48Smrg		droppeddeps=yes
3726b698ba48Smrg		$echo
3727b698ba48Smrg		$echo "*** Warning: linker path does not have real file for library $a_deplib."
3728b698ba48Smrg		$echo "*** I have the capability to make that library automatically link in when"
3729b698ba48Smrg		$echo "*** you link to this library.  But I can only do this if you have a"
3730b698ba48Smrg		$echo "*** shared version of the library, which you do not appear to have"
3731b698ba48Smrg		$echo "*** because I did check the linker path looking for a file starting"
3732b698ba48Smrg		if test -z "$potlib" ; then
3733b698ba48Smrg		  $echo "*** with $libname but no candidates were found. (...for file magic test)"
3734b698ba48Smrg		else
3735b698ba48Smrg		  $echo "*** with $libname and none of the candidates passed a file format test"
3736b698ba48Smrg		  $echo "*** using a file magic. Last file checked: $potlib"
3737b698ba48Smrg		fi
3738b698ba48Smrg	      fi
3739b698ba48Smrg	    else
3740b698ba48Smrg	      # Add a -L argument.
3741b698ba48Smrg	      newdeplibs="$newdeplibs $a_deplib"
3742b698ba48Smrg	    fi
3743b698ba48Smrg	  done # Gone through all deplibs.
3744b698ba48Smrg	  ;;
3745b698ba48Smrg	match_pattern*)
3746b698ba48Smrg	  set dummy $deplibs_check_method
3747b698ba48Smrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
3748b698ba48Smrg	  for a_deplib in $deplibs; do
3749b698ba48Smrg	    name=`expr $a_deplib : '-l\(.*\)'`
3750b698ba48Smrg	    # If $name is empty we are operating on a -L argument.
3751b698ba48Smrg	    if test -n "$name" && test "$name" != "0"; then
3752b698ba48Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3753b698ba48Smrg		case " $predeps $postdeps " in
3754b698ba48Smrg		*" $a_deplib "*)
3755b698ba48Smrg		  newdeplibs="$newdeplibs $a_deplib"
3756b698ba48Smrg		  a_deplib=""
3757b698ba48Smrg		  ;;
3758b698ba48Smrg		esac
3759b698ba48Smrg	      fi
3760b698ba48Smrg	      if test -n "$a_deplib" ; then
3761b698ba48Smrg		libname=`eval \\$echo \"$libname_spec\"`
3762b698ba48Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
3763b698ba48Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
3764b698ba48Smrg		  for potent_lib in $potential_libs; do
3765b698ba48Smrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
3766b698ba48Smrg		    if eval $echo \"$potent_lib\" 2>/dev/null \
3767b698ba48Smrg		        | ${SED} 10q \
3768b698ba48Smrg		        | $EGREP "$match_pattern_regex" > /dev/null; then
3769b698ba48Smrg		      newdeplibs="$newdeplibs $a_deplib"
3770b698ba48Smrg		      a_deplib=""
3771b698ba48Smrg		      break 2
3772b698ba48Smrg		    fi
3773b698ba48Smrg		  done
3774b698ba48Smrg		done
3775b698ba48Smrg	      fi
3776b698ba48Smrg	      if test -n "$a_deplib" ; then
3777b698ba48Smrg		droppeddeps=yes
3778b698ba48Smrg		$echo
3779b698ba48Smrg		$echo "*** Warning: linker path does not have real file for library $a_deplib."
3780b698ba48Smrg		$echo "*** I have the capability to make that library automatically link in when"
3781b698ba48Smrg		$echo "*** you link to this library.  But I can only do this if you have a"
3782b698ba48Smrg		$echo "*** shared version of the library, which you do not appear to have"
3783b698ba48Smrg		$echo "*** because I did check the linker path looking for a file starting"
3784b698ba48Smrg		if test -z "$potlib" ; then
3785b698ba48Smrg		  $echo "*** with $libname but no candidates were found. (...for regex pattern test)"
3786b698ba48Smrg		else
3787b698ba48Smrg		  $echo "*** with $libname and none of the candidates passed a file format test"
3788b698ba48Smrg		  $echo "*** using a regex pattern. Last file checked: $potlib"
3789b698ba48Smrg		fi
3790b698ba48Smrg	      fi
3791b698ba48Smrg	    else
3792b698ba48Smrg	      # Add a -L argument.
3793b698ba48Smrg	      newdeplibs="$newdeplibs $a_deplib"
3794b698ba48Smrg	    fi
3795b698ba48Smrg	  done # Gone through all deplibs.
3796b698ba48Smrg	  ;;
3797b698ba48Smrg	none | unknown | *)
3798b698ba48Smrg	  newdeplibs=""
3799b698ba48Smrg	  tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
3800b698ba48Smrg	    -e 's/ -[LR][^ ]*//g'`
3801b698ba48Smrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3802b698ba48Smrg	    for i in $predeps $postdeps ; do
3803b698ba48Smrg	      # can't use Xsed below, because $i might contain '/'
3804b698ba48Smrg	      tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"`
3805b698ba48Smrg	    done
3806b698ba48Smrg	  fi
3807b698ba48Smrg	  if $echo "X $tmp_deplibs" | $Xsed -e 's/[ 	]//g' \
3808b698ba48Smrg	    | grep . >/dev/null; then
3809b698ba48Smrg	    $echo
3810b698ba48Smrg	    if test "X$deplibs_check_method" = "Xnone"; then
3811b698ba48Smrg	      $echo "*** Warning: inter-library dependencies are not supported in this platform."
3812b698ba48Smrg	    else
3813b698ba48Smrg	      $echo "*** Warning: inter-library dependencies are not known to be supported."
3814b698ba48Smrg	    fi
3815b698ba48Smrg	    $echo "*** All declared inter-library dependencies are being dropped."
3816b698ba48Smrg	    droppeddeps=yes
3817b698ba48Smrg	  fi
3818b698ba48Smrg	  ;;
3819b698ba48Smrg	esac
3820b698ba48Smrg	versuffix=$versuffix_save
3821b698ba48Smrg	major=$major_save
3822b698ba48Smrg	release=$release_save
3823b698ba48Smrg	libname=$libname_save
3824b698ba48Smrg	name=$name_save
382509885543Smrg
3826b698ba48Smrg	case $host in
3827b698ba48Smrg	*-*-rhapsody* | *-*-darwin1.[012])
3828b698ba48Smrg	  # On Rhapsody replace the C library is the System framework
3829b698ba48Smrg	  newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'`
3830b698ba48Smrg	  ;;
3831b698ba48Smrg	esac
383209885543Smrg
3833b698ba48Smrg	if test "$droppeddeps" = yes; then
3834b698ba48Smrg	  if test "$module" = yes; then
3835b698ba48Smrg	    $echo
3836b698ba48Smrg	    $echo "*** Warning: libtool could not satisfy all declared inter-library"
3837b698ba48Smrg	    $echo "*** dependencies of module $libname.  Therefore, libtool will create"
3838b698ba48Smrg	    $echo "*** a static module, that should work as long as the dlopening"
3839b698ba48Smrg	    $echo "*** application is linked with the -dlopen flag."
3840b698ba48Smrg	    if test -z "$global_symbol_pipe"; then
3841b698ba48Smrg	      $echo
3842b698ba48Smrg	      $echo "*** However, this would only work if libtool was able to extract symbol"
3843b698ba48Smrg	      $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
3844b698ba48Smrg	      $echo "*** not find such a program.  So, this module is probably useless."
3845b698ba48Smrg	      $echo "*** \`nm' from GNU binutils and a full rebuild may help."
3846b698ba48Smrg	    fi
3847b698ba48Smrg	    if test "$build_old_libs" = no; then
3848b698ba48Smrg	      oldlibs="$output_objdir/$libname.$libext"
3849b698ba48Smrg	      build_libtool_libs=module
3850b698ba48Smrg	      build_old_libs=yes
3851b698ba48Smrg	    else
3852b698ba48Smrg	      build_libtool_libs=no
3853b698ba48Smrg	    fi
3854b698ba48Smrg	  else
3855b698ba48Smrg	    $echo "*** The inter-library dependencies that have been dropped here will be"
3856b698ba48Smrg	    $echo "*** automatically added whenever a program is linked with this library"
3857b698ba48Smrg	    $echo "*** or is declared to -dlopen it."
385809885543Smrg
3859b698ba48Smrg	    if test "$allow_undefined" = no; then
3860b698ba48Smrg	      $echo
3861b698ba48Smrg	      $echo "*** Since this library must not contain undefined symbols,"
3862b698ba48Smrg	      $echo "*** because either the platform does not support them or"
3863b698ba48Smrg	      $echo "*** it was explicitly requested with -no-undefined,"
3864b698ba48Smrg	      $echo "*** libtool will only create a static version of it."
3865b698ba48Smrg	      if test "$build_old_libs" = no; then
3866b698ba48Smrg		oldlibs="$output_objdir/$libname.$libext"
3867b698ba48Smrg		build_libtool_libs=module
3868b698ba48Smrg		build_old_libs=yes
3869b698ba48Smrg	      else
3870b698ba48Smrg		build_libtool_libs=no
3871b698ba48Smrg	      fi
3872b698ba48Smrg	    fi
3873b698ba48Smrg	  fi
3874b698ba48Smrg	fi
3875b698ba48Smrg	# Done checking deplibs!
3876b698ba48Smrg	deplibs=$newdeplibs
3877b698ba48Smrg      fi
387809885543Smrg
387909885543Smrg
3880b698ba48Smrg      # move library search paths that coincide with paths to not yet
3881b698ba48Smrg      # installed libraries to the beginning of the library search list
3882b698ba48Smrg      new_libs=
3883b698ba48Smrg      for path in $notinst_path; do
3884b698ba48Smrg	case " $new_libs " in
3885b698ba48Smrg	*" -L$path/$objdir "*) ;;
3886b698ba48Smrg	*)
3887b698ba48Smrg	  case " $deplibs " in
3888b698ba48Smrg	  *" -L$path/$objdir "*)
3889b698ba48Smrg	    new_libs="$new_libs -L$path/$objdir" ;;
3890b698ba48Smrg	  esac
3891b698ba48Smrg	  ;;
3892b698ba48Smrg	esac
3893b698ba48Smrg      done
3894b698ba48Smrg      for deplib in $deplibs; do
3895b698ba48Smrg	case $deplib in
3896b698ba48Smrg	-L*)
3897b698ba48Smrg	  case " $new_libs " in
3898b698ba48Smrg	  *" $deplib "*) ;;
3899b698ba48Smrg	  *) new_libs="$new_libs $deplib" ;;
3900b698ba48Smrg	  esac
3901b698ba48Smrg	  ;;
3902b698ba48Smrg	*) new_libs="$new_libs $deplib" ;;
3903b698ba48Smrg	esac
3904b698ba48Smrg      done
3905b698ba48Smrg      deplibs="$new_libs"
390609885543Smrg
390709885543Smrg
3908b698ba48Smrg      # All the library-specific variables (install_libdir is set above).
3909b698ba48Smrg      library_names=
3910b698ba48Smrg      old_library=
3911b698ba48Smrg      dlname=
391209885543Smrg
3913b698ba48Smrg      # Test again, we may have decided not to build it any more
3914b698ba48Smrg      if test "$build_libtool_libs" = yes; then
3915b698ba48Smrg	if test "$hardcode_into_libs" = yes; then
3916b698ba48Smrg	  # Hardcode the library paths
3917b698ba48Smrg	  hardcode_libdirs=
3918b698ba48Smrg	  dep_rpath=
3919b698ba48Smrg	  rpath="$finalize_rpath"
3920b698ba48Smrg	  test "$mode" != relink && rpath="$compile_rpath$rpath"
3921b698ba48Smrg	  for libdir in $rpath; do
3922b698ba48Smrg	    if test -n "$hardcode_libdir_flag_spec"; then
3923b698ba48Smrg	      if test -n "$hardcode_libdir_separator"; then
3924b698ba48Smrg		if test -z "$hardcode_libdirs"; then
3925b698ba48Smrg		  hardcode_libdirs="$libdir"
3926b698ba48Smrg		else
3927b698ba48Smrg		  # Just accumulate the unique libdirs.
3928b698ba48Smrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
3929b698ba48Smrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
3930b698ba48Smrg		    ;;
3931b698ba48Smrg		  *)
3932b698ba48Smrg		    hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
3933b698ba48Smrg		    ;;
3934b698ba48Smrg		  esac
3935b698ba48Smrg		fi
3936b698ba48Smrg	      else
3937b698ba48Smrg		eval flag=\"$hardcode_libdir_flag_spec\"
3938b698ba48Smrg		dep_rpath="$dep_rpath $flag"
3939b698ba48Smrg	      fi
3940b698ba48Smrg	    elif test -n "$runpath_var"; then
3941b698ba48Smrg	      case "$perm_rpath " in
3942b698ba48Smrg	      *" $libdir "*) ;;
3943b698ba48Smrg	      *) perm_rpath="$perm_rpath $libdir" ;;
3944b698ba48Smrg	      esac
3945b698ba48Smrg	    fi
3946b698ba48Smrg	  done
3947b698ba48Smrg	  # Substitute the hardcoded libdirs into the rpath.
3948b698ba48Smrg	  if test -n "$hardcode_libdir_separator" &&
3949b698ba48Smrg	     test -n "$hardcode_libdirs"; then
3950b698ba48Smrg	    libdir="$hardcode_libdirs"
3951b698ba48Smrg	    if test -n "$hardcode_libdir_flag_spec_ld"; then
3952b698ba48Smrg	      case $archive_cmds in
3953b698ba48Smrg	      *\$LD*) eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" ;;
3954b698ba48Smrg	      *)      eval dep_rpath=\"$hardcode_libdir_flag_spec\" ;;
3955b698ba48Smrg	      esac
3956b698ba48Smrg	    else
3957b698ba48Smrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
3958b698ba48Smrg	    fi
3959b698ba48Smrg	  fi
3960b698ba48Smrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
3961b698ba48Smrg	    # We should set the runpath_var.
3962b698ba48Smrg	    rpath=
3963b698ba48Smrg	    for dir in $perm_rpath; do
3964b698ba48Smrg	      rpath="$rpath$dir:"
3965b698ba48Smrg	    done
3966b698ba48Smrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
3967b698ba48Smrg	  fi
3968b698ba48Smrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
3969b698ba48Smrg	fi
397009885543Smrg
3971b698ba48Smrg	shlibpath="$finalize_shlibpath"
3972b698ba48Smrg	test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
3973b698ba48Smrg	if test -n "$shlibpath"; then
3974b698ba48Smrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
3975b698ba48Smrg	fi
397609885543Smrg
3977b698ba48Smrg	# Get the real and link names of the library.
3978b698ba48Smrg	eval shared_ext=\"$shrext_cmds\"
3979b698ba48Smrg	eval library_names=\"$library_names_spec\"
3980b698ba48Smrg	set dummy $library_names
3981b698ba48Smrg	realname="$2"
3982b698ba48Smrg	shift; shift
398309885543Smrg
3984b698ba48Smrg	if test -n "$soname_spec"; then
3985b698ba48Smrg	  eval soname=\"$soname_spec\"
3986b698ba48Smrg	else
3987b698ba48Smrg	  soname="$realname"
3988b698ba48Smrg	fi
3989b698ba48Smrg	if test -z "$dlname"; then
3990b698ba48Smrg	  dlname=$soname
3991b698ba48Smrg	fi
399209885543Smrg
3993b698ba48Smrg	lib="$output_objdir/$realname"
3994b698ba48Smrg	linknames=
3995b698ba48Smrg	for link
3996b698ba48Smrg	do
3997b698ba48Smrg	  linknames="$linknames $link"
3998b698ba48Smrg	done
399909885543Smrg
4000b698ba48Smrg	# Use standard objects if they are pic
4001b698ba48Smrg	test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
400209885543Smrg
4003b698ba48Smrg	# Prepare the list of exported symbols
4004b698ba48Smrg	if test -z "$export_symbols"; then
4005b698ba48Smrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
4006b698ba48Smrg	    $show "generating symbol list for \`$libname.la'"
4007b698ba48Smrg	    export_symbols="$output_objdir/$libname.exp"
4008b698ba48Smrg	    $run $rm $export_symbols
4009b698ba48Smrg	    cmds=$export_symbols_cmds
4010b698ba48Smrg	    save_ifs="$IFS"; IFS='~'
4011b698ba48Smrg	    for cmd in $cmds; do
4012b698ba48Smrg	      IFS="$save_ifs"
4013b698ba48Smrg	      eval cmd=\"$cmd\"
4014b698ba48Smrg	      if len=`expr "X$cmd" : ".*"` &&
4015b698ba48Smrg	       test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
4016b698ba48Smrg	        $show "$cmd"
4017b698ba48Smrg	        $run eval "$cmd" || exit $?
4018b698ba48Smrg	        skipped_export=false
4019b698ba48Smrg	      else
4020b698ba48Smrg	        # The command line is too long to execute in one step.
4021b698ba48Smrg	        $show "using reloadable object file for export list..."
4022b698ba48Smrg	        skipped_export=:
4023b698ba48Smrg		# Break out early, otherwise skipped_export may be
4024b698ba48Smrg		# set to false by a later but shorter cmd.
4025b698ba48Smrg		break
4026b698ba48Smrg	      fi
4027b698ba48Smrg	    done
4028b698ba48Smrg	    IFS="$save_ifs"
4029b698ba48Smrg	    if test -n "$export_symbols_regex"; then
4030b698ba48Smrg	      $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""
4031b698ba48Smrg	      $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
4032b698ba48Smrg	      $show "$mv \"${export_symbols}T\" \"$export_symbols\""
4033b698ba48Smrg	      $run eval '$mv "${export_symbols}T" "$export_symbols"'
4034b698ba48Smrg	    fi
4035b698ba48Smrg	  fi
4036b698ba48Smrg	fi
403709885543Smrg
4038b698ba48Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
4039b698ba48Smrg	  $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"'
4040b698ba48Smrg	fi
404109885543Smrg
4042b698ba48Smrg	tmp_deplibs=
4043b698ba48Smrg	for test_deplib in $deplibs; do
4044b698ba48Smrg		case " $convenience " in
4045b698ba48Smrg		*" $test_deplib "*) ;;
4046b698ba48Smrg		*)
4047b698ba48Smrg			tmp_deplibs="$tmp_deplibs $test_deplib"
4048b698ba48Smrg			;;
4049b698ba48Smrg		esac
4050b698ba48Smrg	done
4051b698ba48Smrg	deplibs="$tmp_deplibs"
405209885543Smrg
4053b698ba48Smrg	if test -n "$convenience"; then
4054b698ba48Smrg	  if test -n "$whole_archive_flag_spec"; then
4055b698ba48Smrg	    save_libobjs=$libobjs
4056b698ba48Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
4057b698ba48Smrg	  else
4058b698ba48Smrg	    gentop="$output_objdir/${outputname}x"
4059b698ba48Smrg	    generated="$generated $gentop"
406009885543Smrg
4061b698ba48Smrg	    func_extract_archives $gentop $convenience
4062b698ba48Smrg	    libobjs="$libobjs $func_extract_archives_result"
4063b698ba48Smrg	  fi
4064b698ba48Smrg	fi
4065b698ba48Smrg	
4066b698ba48Smrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
4067b698ba48Smrg	  eval flag=\"$thread_safe_flag_spec\"
4068b698ba48Smrg	  linker_flags="$linker_flags $flag"
4069b698ba48Smrg	fi
407009885543Smrg
4071b698ba48Smrg	# Make a backup of the uninstalled library when relinking
4072b698ba48Smrg	if test "$mode" = relink; then
4073b698ba48Smrg	  $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $?
4074b698ba48Smrg	fi
407509885543Smrg
4076b698ba48Smrg	# Do each of the archive commands.
4077b698ba48Smrg	if test "$module" = yes && test -n "$module_cmds" ; then
4078b698ba48Smrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
4079b698ba48Smrg	    eval test_cmds=\"$module_expsym_cmds\"
4080b698ba48Smrg	    cmds=$module_expsym_cmds
4081b698ba48Smrg	  else
4082b698ba48Smrg	    eval test_cmds=\"$module_cmds\"
4083b698ba48Smrg	    cmds=$module_cmds
4084b698ba48Smrg	  fi
4085b698ba48Smrg	else
4086b698ba48Smrg	if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
4087b698ba48Smrg	  eval test_cmds=\"$archive_expsym_cmds\"
4088b698ba48Smrg	  cmds=$archive_expsym_cmds
4089b698ba48Smrg	else
4090b698ba48Smrg	  eval test_cmds=\"$archive_cmds\"
4091b698ba48Smrg	  cmds=$archive_cmds
4092b698ba48Smrg	  fi
4093b698ba48Smrg	fi
409409885543Smrg
4095b698ba48Smrg	if test "X$skipped_export" != "X:" &&
4096b698ba48Smrg	   len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
4097b698ba48Smrg	   test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
4098b698ba48Smrg	  :
4099b698ba48Smrg	else
4100b698ba48Smrg	  # The command line is too long to link in one step, link piecewise.
4101b698ba48Smrg	  $echo "creating reloadable object files..."
410209885543Smrg
4103b698ba48Smrg	  # Save the value of $output and $libobjs because we want to
4104b698ba48Smrg	  # use them later.  If we have whole_archive_flag_spec, we
4105b698ba48Smrg	  # want to use save_libobjs as it was before
4106b698ba48Smrg	  # whole_archive_flag_spec was expanded, because we can't
4107b698ba48Smrg	  # assume the linker understands whole_archive_flag_spec.
4108b698ba48Smrg	  # This may have to be revisited, in case too many
4109b698ba48Smrg	  # convenience libraries get linked in and end up exceeding
4110b698ba48Smrg	  # the spec.
4111b698ba48Smrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
4112b698ba48Smrg	    save_libobjs=$libobjs
4113b698ba48Smrg	  fi
4114b698ba48Smrg	  save_output=$output
4115b698ba48Smrg	  output_la=`$echo "X$output" | $Xsed -e "$basename"`
411609885543Smrg
4117b698ba48Smrg	  # Clear the reloadable object creation command queue and
4118b698ba48Smrg	  # initialize k to one.
4119b698ba48Smrg	  test_cmds=
4120b698ba48Smrg	  concat_cmds=
4121b698ba48Smrg	  objlist=
4122b698ba48Smrg	  delfiles=
4123b698ba48Smrg	  last_robj=
4124b698ba48Smrg	  k=1
4125b698ba48Smrg	  output=$output_objdir/$output_la-${k}.$objext
4126b698ba48Smrg	  # Loop over the list of objects to be linked.
4127b698ba48Smrg	  for obj in $save_libobjs
4128b698ba48Smrg	  do
4129b698ba48Smrg	    eval test_cmds=\"$reload_cmds $objlist $last_robj\"
4130b698ba48Smrg	    if test "X$objlist" = X ||
4131b698ba48Smrg	       { len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
4132b698ba48Smrg		 test "$len" -le "$max_cmd_len"; }; then
4133b698ba48Smrg	      objlist="$objlist $obj"
4134b698ba48Smrg	    else
4135b698ba48Smrg	      # The command $test_cmds is almost too long, add a
4136b698ba48Smrg	      # command to the queue.
4137b698ba48Smrg	      if test "$k" -eq 1 ; then
4138b698ba48Smrg		# The first file doesn't have a previous command to add.
4139b698ba48Smrg		eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
4140b698ba48Smrg	      else
4141b698ba48Smrg		# All subsequent reloadable object files will link in
4142b698ba48Smrg		# the last one created.
4143b698ba48Smrg		eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\"
4144b698ba48Smrg	      fi
4145b698ba48Smrg	      last_robj=$output_objdir/$output_la-${k}.$objext
4146b698ba48Smrg	      k=`expr $k + 1`
4147b698ba48Smrg	      output=$output_objdir/$output_la-${k}.$objext
4148b698ba48Smrg	      objlist=$obj
4149b698ba48Smrg	      len=1
4150b698ba48Smrg	    fi
4151b698ba48Smrg	  done
4152b698ba48Smrg	  # Handle the remaining objects by creating one last
4153b698ba48Smrg	  # reloadable object file.  All subsequent reloadable object
4154b698ba48Smrg	  # files will link in the last one created.
4155b698ba48Smrg	  test -z "$concat_cmds" || concat_cmds=$concat_cmds~
4156b698ba48Smrg	  eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
4157b698ba48Smrg
4158b698ba48Smrg	  if ${skipped_export-false}; then
4159b698ba48Smrg	    $show "generating symbol list for \`$libname.la'"
4160b698ba48Smrg	    export_symbols="$output_objdir/$libname.exp"
4161b698ba48Smrg	    $run $rm $export_symbols
4162b698ba48Smrg	    libobjs=$output
4163b698ba48Smrg	    # Append the command to create the export file.
4164b698ba48Smrg	    eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\"
4165b698ba48Smrg          fi
4166b698ba48Smrg
4167b698ba48Smrg	  # Set up a command to remove the reloadable object files
4168b698ba48Smrg	  # after they are used.
4169b698ba48Smrg	  i=0
4170b698ba48Smrg	  while test "$i" -lt "$k"
4171b698ba48Smrg	  do
4172b698ba48Smrg	    i=`expr $i + 1`
4173b698ba48Smrg	    delfiles="$delfiles $output_objdir/$output_la-${i}.$objext"
4174b698ba48Smrg	  done
417509885543Smrg
4176b698ba48Smrg	  $echo "creating a temporary reloadable object file: $output"
417709885543Smrg
4178b698ba48Smrg	  # Loop through the commands generated above and execute them.
4179b698ba48Smrg	  save_ifs="$IFS"; IFS='~'
4180b698ba48Smrg	  for cmd in $concat_cmds; do
4181b698ba48Smrg	    IFS="$save_ifs"
4182b698ba48Smrg	    $show "$cmd"
4183b698ba48Smrg	    $run eval "$cmd" || exit $?
4184b698ba48Smrg	  done
4185b698ba48Smrg	  IFS="$save_ifs"
418609885543Smrg
4187b698ba48Smrg	  libobjs=$output
4188b698ba48Smrg	  # Restore the value of output.
4189b698ba48Smrg	  output=$save_output
419009885543Smrg
4191b698ba48Smrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
4192b698ba48Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
4193b698ba48Smrg	  fi
4194b698ba48Smrg	  # Expand the library linking commands again to reset the
4195b698ba48Smrg	  # value of $libobjs for piecewise linking.
419609885543Smrg
4197b698ba48Smrg	  # Do each of the archive commands.
4198b698ba48Smrg	  if test "$module" = yes && test -n "$module_cmds" ; then
4199b698ba48Smrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
4200b698ba48Smrg	      cmds=$module_expsym_cmds
4201b698ba48Smrg	    else
4202b698ba48Smrg	      cmds=$module_cmds
4203b698ba48Smrg	    fi
4204b698ba48Smrg	  else
4205b698ba48Smrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
4206b698ba48Smrg	    cmds=$archive_expsym_cmds
4207b698ba48Smrg	  else
4208b698ba48Smrg	    cmds=$archive_cmds
4209b698ba48Smrg	    fi
4210b698ba48Smrg	  fi
421109885543Smrg
4212b698ba48Smrg	  # Append the command to remove the reloadable object files
4213b698ba48Smrg	  # to the just-reset $cmds.
4214b698ba48Smrg	  eval cmds=\"\$cmds~\$rm $delfiles\"
4215b698ba48Smrg	fi
4216b698ba48Smrg	save_ifs="$IFS"; IFS='~'
4217b698ba48Smrg	for cmd in $cmds; do
4218b698ba48Smrg	  IFS="$save_ifs"
4219b698ba48Smrg	  eval cmd=\"$cmd\"
4220b698ba48Smrg	  $show "$cmd"
4221b698ba48Smrg	  $run eval "$cmd" || {
4222b698ba48Smrg	    lt_exit=$?
422309885543Smrg
4224b698ba48Smrg	    # Restore the uninstalled library and exit
4225b698ba48Smrg	    if test "$mode" = relink; then
4226b698ba48Smrg	      $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
4227b698ba48Smrg	    fi
422809885543Smrg
4229b698ba48Smrg	    exit $lt_exit
4230b698ba48Smrg	  }
4231b698ba48Smrg	done
4232b698ba48Smrg	IFS="$save_ifs"
4233b698ba48Smrg
4234b698ba48Smrg	# Restore the uninstalled library and exit
4235b698ba48Smrg	if test "$mode" = relink; then
4236b698ba48Smrg	  $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $?
4237b698ba48Smrg
4238b698ba48Smrg	  if test -n "$convenience"; then
4239b698ba48Smrg	    if test -z "$whole_archive_flag_spec"; then
4240b698ba48Smrg	      $show "${rm}r $gentop"
4241b698ba48Smrg	      $run ${rm}r "$gentop"
4242b698ba48Smrg	    fi
4243b698ba48Smrg	  fi
4244b698ba48Smrg
4245b698ba48Smrg	  exit $EXIT_SUCCESS
4246b698ba48Smrg	fi
4247b698ba48Smrg
4248b698ba48Smrg	# Create links to the real library.
4249b698ba48Smrg	for linkname in $linknames; do
4250b698ba48Smrg	  if test "$realname" != "$linkname"; then
4251b698ba48Smrg	    $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)"
4252b698ba48Smrg	    $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $?
4253b698ba48Smrg	  fi
4254b698ba48Smrg	done
4255b698ba48Smrg
4256b698ba48Smrg	# If -module or -export-dynamic was specified, set the dlname.
4257b698ba48Smrg	if test "$module" = yes || test "$export_dynamic" = yes; then
4258b698ba48Smrg	  # On all known operating systems, these are identical.
4259b698ba48Smrg	  dlname="$soname"
4260b698ba48Smrg	fi
4261b698ba48Smrg      fi
42622ec8c4b4Smrg      ;;
426309885543Smrg
4264b698ba48Smrg    obj)
4265b698ba48Smrg      case " $deplibs" in
4266b698ba48Smrg      *\ -l* | *\ -L*)
4267b698ba48Smrg	$echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2 ;;
4268b698ba48Smrg      esac
426909885543Smrg
4270b698ba48Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
4271b698ba48Smrg	$echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
4272b698ba48Smrg      fi
42732ec8c4b4Smrg
4274b698ba48Smrg      if test -n "$rpath"; then
4275b698ba48Smrg	$echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2
4276b698ba48Smrg      fi
4277b698ba48Smrg
4278b698ba48Smrg      if test -n "$xrpath"; then
4279b698ba48Smrg	$echo "$modename: warning: \`-R' is ignored for objects" 1>&2
4280b698ba48Smrg      fi
4281b698ba48Smrg
4282b698ba48Smrg      if test -n "$vinfo"; then
4283b698ba48Smrg	$echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2
4284b698ba48Smrg      fi
4285b698ba48Smrg
4286b698ba48Smrg      if test -n "$release"; then
4287b698ba48Smrg	$echo "$modename: warning: \`-release' is ignored for objects" 1>&2
4288b698ba48Smrg      fi
4289b698ba48Smrg
4290b698ba48Smrg      case $output in
4291b698ba48Smrg      *.lo)
4292b698ba48Smrg	if test -n "$objs$old_deplibs"; then
4293b698ba48Smrg	  $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
4294b698ba48Smrg	  exit $EXIT_FAILURE
4295b698ba48Smrg	fi
4296b698ba48Smrg	libobj="$output"
4297b698ba48Smrg	obj=`$echo "X$output" | $Xsed -e "$lo2o"`
42982ec8c4b4Smrg	;;
4299b698ba48Smrg      *)
4300b698ba48Smrg	libobj=
4301b698ba48Smrg	obj="$output"
43022ec8c4b4Smrg	;;
43032ec8c4b4Smrg      esac
430409885543Smrg
4305b698ba48Smrg      # Delete the old objects.
4306b698ba48Smrg      $run $rm $obj $libobj
430709885543Smrg
4308b698ba48Smrg      # Objects from convenience libraries.  This assumes
4309b698ba48Smrg      # single-version convenience libraries.  Whenever we create
4310b698ba48Smrg      # different ones for PIC/non-PIC, this we'll have to duplicate
4311b698ba48Smrg      # the extraction.
4312b698ba48Smrg      reload_conv_objs=
4313b698ba48Smrg      gentop=
4314b698ba48Smrg      # reload_cmds runs $LD directly, so let us get rid of
4315b698ba48Smrg      # -Wl from whole_archive_flag_spec and hope we can get by with
4316b698ba48Smrg      # turning comma into space..
4317b698ba48Smrg      wl=
431809885543Smrg
4319b698ba48Smrg      if test -n "$convenience"; then
4320b698ba48Smrg	if test -n "$whole_archive_flag_spec"; then
4321b698ba48Smrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
4322b698ba48Smrg	  reload_conv_objs=$reload_objs\ `$echo "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'`
4323b698ba48Smrg	else
4324b698ba48Smrg	  gentop="$output_objdir/${obj}x"
4325b698ba48Smrg	  generated="$generated $gentop"
432609885543Smrg
4327b698ba48Smrg	  func_extract_archives $gentop $convenience
4328b698ba48Smrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
4329b698ba48Smrg	fi
4330b698ba48Smrg      fi
433109885543Smrg
4332b698ba48Smrg      # Create the old-style object.
4333b698ba48Smrg      reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
433409885543Smrg
4335b698ba48Smrg      output="$obj"
4336b698ba48Smrg      cmds=$reload_cmds
4337b698ba48Smrg      save_ifs="$IFS"; IFS='~'
4338b698ba48Smrg      for cmd in $cmds; do
4339b698ba48Smrg	IFS="$save_ifs"
4340b698ba48Smrg	eval cmd=\"$cmd\"
4341b698ba48Smrg	$show "$cmd"
4342b698ba48Smrg	$run eval "$cmd" || exit $?
4343b698ba48Smrg      done
4344b698ba48Smrg      IFS="$save_ifs"
434509885543Smrg
4346b698ba48Smrg      # Exit if we aren't doing a library object file.
4347b698ba48Smrg      if test -z "$libobj"; then
4348b698ba48Smrg	if test -n "$gentop"; then
4349b698ba48Smrg	  $show "${rm}r $gentop"
4350b698ba48Smrg	  $run ${rm}r $gentop
4351b698ba48Smrg	fi
435209885543Smrg
4353b698ba48Smrg	exit $EXIT_SUCCESS
4354b698ba48Smrg      fi
435509885543Smrg
4356b698ba48Smrg      if test "$build_libtool_libs" != yes; then
4357b698ba48Smrg	if test -n "$gentop"; then
4358b698ba48Smrg	  $show "${rm}r $gentop"
4359b698ba48Smrg	  $run ${rm}r $gentop
4360b698ba48Smrg	fi
436109885543Smrg
4362b698ba48Smrg	# Create an invalid libtool object if no PIC, so that we don't
4363b698ba48Smrg	# accidentally link it into a program.
4364b698ba48Smrg	# $show "echo timestamp > $libobj"
4365b698ba48Smrg	# $run eval "echo timestamp > $libobj" || exit $?
4366b698ba48Smrg	exit $EXIT_SUCCESS
4367b698ba48Smrg      fi
436809885543Smrg
4369b698ba48Smrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
4370b698ba48Smrg	# Only do commands if we really have different PIC objects.
4371b698ba48Smrg	reload_objs="$libobjs $reload_conv_objs"
4372b698ba48Smrg	output="$libobj"
4373b698ba48Smrg	cmds=$reload_cmds
4374b698ba48Smrg	save_ifs="$IFS"; IFS='~'
4375b698ba48Smrg	for cmd in $cmds; do
4376b698ba48Smrg	  IFS="$save_ifs"
4377b698ba48Smrg	  eval cmd=\"$cmd\"
4378b698ba48Smrg	  $show "$cmd"
4379b698ba48Smrg	  $run eval "$cmd" || exit $?
4380b698ba48Smrg	done
4381b698ba48Smrg	IFS="$save_ifs"
4382b698ba48Smrg      fi
438309885543Smrg
4384b698ba48Smrg      if test -n "$gentop"; then
4385b698ba48Smrg	$show "${rm}r $gentop"
4386b698ba48Smrg	$run ${rm}r $gentop
4387b698ba48Smrg      fi
438809885543Smrg
4389b698ba48Smrg      exit $EXIT_SUCCESS
4390b698ba48Smrg      ;;
439109885543Smrg
4392b698ba48Smrg    prog)
4393b698ba48Smrg      case $host in
4394b698ba48Smrg	*cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;
4395b698ba48Smrg      esac
4396b698ba48Smrg      if test -n "$vinfo"; then
4397b698ba48Smrg	$echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
4398b698ba48Smrg      fi
439909885543Smrg
4400b698ba48Smrg      if test -n "$release"; then
4401b698ba48Smrg	$echo "$modename: warning: \`-release' is ignored for programs" 1>&2
4402b698ba48Smrg      fi
440309885543Smrg
4404b698ba48Smrg      if test "$preload" = yes; then
4405b698ba48Smrg	if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown &&
4406b698ba48Smrg	   test "$dlopen_self_static" = unknown; then
4407b698ba48Smrg	  $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support."
44082ec8c4b4Smrg	fi
4409b698ba48Smrg      fi
441009885543Smrg
4411b698ba48Smrg      case $host in
4412b698ba48Smrg      *-*-rhapsody* | *-*-darwin1.[012])
4413b698ba48Smrg	# On Rhapsody replace the C library is the System framework
4414b698ba48Smrg	compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
4415b698ba48Smrg	finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
44162ec8c4b4Smrg	;;
4417b698ba48Smrg      esac
441809885543Smrg
4419b698ba48Smrg      case $host in
4420b698ba48Smrg      *darwin*)
4421b698ba48Smrg        # Don't allow lazy linking, it breaks C++ global constructors
4422b698ba48Smrg        if test "$tagname" = CXX ; then
4423b698ba48Smrg        compile_command="$compile_command ${wl}-bind_at_load"
4424b698ba48Smrg        finalize_command="$finalize_command ${wl}-bind_at_load"
4425b698ba48Smrg        fi
4426b698ba48Smrg        ;;
4427b698ba48Smrg      esac
442809885543Smrg
442909885543Smrg
4430b698ba48Smrg      # move library search paths that coincide with paths to not yet
4431b698ba48Smrg      # installed libraries to the beginning of the library search list
4432b698ba48Smrg      new_libs=
4433b698ba48Smrg      for path in $notinst_path; do
4434b698ba48Smrg	case " $new_libs " in
4435b698ba48Smrg	*" -L$path/$objdir "*) ;;
4436b698ba48Smrg	*)
4437b698ba48Smrg	  case " $compile_deplibs " in
4438b698ba48Smrg	  *" -L$path/$objdir "*)
4439b698ba48Smrg	    new_libs="$new_libs -L$path/$objdir" ;;
4440b698ba48Smrg	  esac
4441b698ba48Smrg	  ;;
4442b698ba48Smrg	esac
4443b698ba48Smrg      done
4444b698ba48Smrg      for deplib in $compile_deplibs; do
4445b698ba48Smrg	case $deplib in
4446b698ba48Smrg	-L*)
4447b698ba48Smrg	  case " $new_libs " in
4448b698ba48Smrg	  *" $deplib "*) ;;
4449b698ba48Smrg	  *) new_libs="$new_libs $deplib" ;;
4450b698ba48Smrg	  esac
4451b698ba48Smrg	  ;;
4452b698ba48Smrg	*) new_libs="$new_libs $deplib" ;;
4453b698ba48Smrg	esac
4454b698ba48Smrg      done
4455b698ba48Smrg      compile_deplibs="$new_libs"
445609885543Smrg
445709885543Smrg
4458b698ba48Smrg      compile_command="$compile_command $compile_deplibs"
4459b698ba48Smrg      finalize_command="$finalize_command $finalize_deplibs"
446009885543Smrg
4461b698ba48Smrg      if test -n "$rpath$xrpath"; then
4462b698ba48Smrg	# If the user specified any rpath flags, then add them.
4463b698ba48Smrg	for libdir in $rpath $xrpath; do
4464b698ba48Smrg	  # This is the magic to use -rpath.
4465b698ba48Smrg	  case "$finalize_rpath " in
4466b698ba48Smrg	  *" $libdir "*) ;;
4467b698ba48Smrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
4468b698ba48Smrg	  esac
4469b698ba48Smrg	done
4470b698ba48Smrg      fi
447109885543Smrg
4472b698ba48Smrg      # Now hardcode the library paths
4473b698ba48Smrg      rpath=
4474b698ba48Smrg      hardcode_libdirs=
4475b698ba48Smrg      for libdir in $compile_rpath $finalize_rpath; do
4476b698ba48Smrg	if test -n "$hardcode_libdir_flag_spec"; then
4477b698ba48Smrg	  if test -n "$hardcode_libdir_separator"; then
4478b698ba48Smrg	    if test -z "$hardcode_libdirs"; then
4479b698ba48Smrg	      hardcode_libdirs="$libdir"
4480b698ba48Smrg	    else
4481b698ba48Smrg	      # Just accumulate the unique libdirs.
4482b698ba48Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
4483b698ba48Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
4484b698ba48Smrg		;;
4485b698ba48Smrg	      *)
4486b698ba48Smrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
4487b698ba48Smrg		;;
4488b698ba48Smrg	      esac
4489b698ba48Smrg	    fi
44902ec8c4b4Smrg	  else
4491b698ba48Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
4492b698ba48Smrg	    rpath="$rpath $flag"
44932ec8c4b4Smrg	  fi
4494b698ba48Smrg	elif test -n "$runpath_var"; then
4495b698ba48Smrg	  case "$perm_rpath " in
4496b698ba48Smrg	  *" $libdir "*) ;;
4497b698ba48Smrg	  *) perm_rpath="$perm_rpath $libdir" ;;
4498b698ba48Smrg	  esac
44992ec8c4b4Smrg	fi
45002ec8c4b4Smrg	case $host in
4501b698ba48Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
4502b698ba48Smrg	  testbindir=`$echo "X$libdir" | $Xsed -e 's*/lib$*/bin*'`
45032ec8c4b4Smrg	  case :$dllsearchpath: in
4504b698ba48Smrg	  *":$libdir:"*) ;;
4505b698ba48Smrg	  *) dllsearchpath="$dllsearchpath:$libdir";;
45062ec8c4b4Smrg	  esac
45072ec8c4b4Smrg	  case :$dllsearchpath: in
45082ec8c4b4Smrg	  *":$testbindir:"*) ;;
45092ec8c4b4Smrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
45102ec8c4b4Smrg	  esac
45112ec8c4b4Smrg	  ;;
45122ec8c4b4Smrg	esac
4513b698ba48Smrg      done
4514b698ba48Smrg      # Substitute the hardcoded libdirs into the rpath.
4515b698ba48Smrg      if test -n "$hardcode_libdir_separator" &&
4516b698ba48Smrg	 test -n "$hardcode_libdirs"; then
4517b698ba48Smrg	libdir="$hardcode_libdirs"
4518b698ba48Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
4519b698ba48Smrg      fi
4520b698ba48Smrg      compile_rpath="$rpath"
452109885543Smrg
4522b698ba48Smrg      rpath=
4523b698ba48Smrg      hardcode_libdirs=
4524b698ba48Smrg      for libdir in $finalize_rpath; do
4525b698ba48Smrg	if test -n "$hardcode_libdir_flag_spec"; then
4526b698ba48Smrg	  if test -n "$hardcode_libdir_separator"; then
4527b698ba48Smrg	    if test -z "$hardcode_libdirs"; then
4528b698ba48Smrg	      hardcode_libdirs="$libdir"
4529b698ba48Smrg	    else
4530b698ba48Smrg	      # Just accumulate the unique libdirs.
4531b698ba48Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
4532b698ba48Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
4533b698ba48Smrg		;;
4534b698ba48Smrg	      *)
4535b698ba48Smrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
4536b698ba48Smrg		;;
4537b698ba48Smrg	      esac
4538b698ba48Smrg	    fi
4539b698ba48Smrg	  else
4540b698ba48Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
4541b698ba48Smrg	    rpath="$rpath $flag"
4542b698ba48Smrg	  fi
4543b698ba48Smrg	elif test -n "$runpath_var"; then
4544b698ba48Smrg	  case "$finalize_perm_rpath " in
4545b698ba48Smrg	  *" $libdir "*) ;;
4546b698ba48Smrg	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
45472ec8c4b4Smrg	  esac
45482ec8c4b4Smrg	fi
4549b698ba48Smrg      done
4550b698ba48Smrg      # Substitute the hardcoded libdirs into the rpath.
4551b698ba48Smrg      if test -n "$hardcode_libdir_separator" &&
4552b698ba48Smrg	 test -n "$hardcode_libdirs"; then
4553b698ba48Smrg	libdir="$hardcode_libdirs"
4554b698ba48Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
4555b698ba48Smrg      fi
4556b698ba48Smrg      finalize_rpath="$rpath"
455709885543Smrg
4558b698ba48Smrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
4559b698ba48Smrg	# Transform all the library objects into standard objects.
4560b698ba48Smrg	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
4561b698ba48Smrg	finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
4562b698ba48Smrg      fi
456309885543Smrg
4564b698ba48Smrg      dlsyms=
4565b698ba48Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
4566b698ba48Smrg	if test -n "$NM" && test -n "$global_symbol_pipe"; then
4567b698ba48Smrg	  dlsyms="${outputname}S.c"
4568b698ba48Smrg	else
4569b698ba48Smrg	  $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2
4570b698ba48Smrg	fi
4571b698ba48Smrg      fi
457209885543Smrg
4573b698ba48Smrg      if test -n "$dlsyms"; then
4574b698ba48Smrg	case $dlsyms in
4575b698ba48Smrg	"") ;;
4576b698ba48Smrg	*.c)
4577b698ba48Smrg	  # Discover the nlist of each of the dlfiles.
4578b698ba48Smrg	  nlist="$output_objdir/${outputname}.nm"
457909885543Smrg
4580b698ba48Smrg	  $show "$rm $nlist ${nlist}S ${nlist}T"
4581b698ba48Smrg	  $run $rm "$nlist" "${nlist}S" "${nlist}T"
458209885543Smrg
4583b698ba48Smrg	  # Parse the name list into a source file.
4584b698ba48Smrg	  $show "creating $output_objdir/$dlsyms"
458509885543Smrg
4586b698ba48Smrg	  test -z "$run" && $echo > "$output_objdir/$dlsyms" "\
4587b698ba48Smrg/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */
4588b698ba48Smrg/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */
458909885543Smrg
4590b698ba48Smrg#ifdef __cplusplus
4591b698ba48Smrgextern \"C\" {
4592b698ba48Smrg#endif
459309885543Smrg
4594b698ba48Smrg/* Prevent the only kind of declaration conflicts we can make. */
4595b698ba48Smrg#define lt_preloaded_symbols some_other_symbol
459609885543Smrg
4597b698ba48Smrg/* External symbol declarations for the compiler. */\
4598b698ba48Smrg"
459909885543Smrg
4600b698ba48Smrg	  if test "$dlself" = yes; then
4601b698ba48Smrg	    $show "generating symbol list for \`$output'"
460209885543Smrg
4603b698ba48Smrg	    test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist"
460409885543Smrg
4605b698ba48Smrg	    # Add our own program objects to the symbol list.
4606b698ba48Smrg	    progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
4607b698ba48Smrg	    for arg in $progfiles; do
4608b698ba48Smrg	      $show "extracting global C symbols from \`$arg'"
4609b698ba48Smrg	      $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
4610b698ba48Smrg	    done
461109885543Smrg
4612b698ba48Smrg	    if test -n "$exclude_expsyms"; then
4613b698ba48Smrg	      $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
4614b698ba48Smrg	      $run eval '$mv "$nlist"T "$nlist"'
4615b698ba48Smrg	    fi
461609885543Smrg
4617b698ba48Smrg	    if test -n "$export_symbols_regex"; then
4618b698ba48Smrg	      $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
4619b698ba48Smrg	      $run eval '$mv "$nlist"T "$nlist"'
4620b698ba48Smrg	    fi
462109885543Smrg
4622b698ba48Smrg	    # Prepare the list of exported symbols
4623b698ba48Smrg	    if test -z "$export_symbols"; then
4624b698ba48Smrg	      export_symbols="$output_objdir/$outputname.exp"
4625b698ba48Smrg	      $run $rm $export_symbols
4626b698ba48Smrg	      $run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
4627b698ba48Smrg              case $host in
4628b698ba48Smrg              *cygwin* | *mingw* )
4629b698ba48Smrg	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4630b698ba48Smrg		$run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
4631b698ba48Smrg                ;;
4632b698ba48Smrg              esac
4633b698ba48Smrg	    else
4634b698ba48Smrg	      $run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
4635b698ba48Smrg	      $run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
4636b698ba48Smrg	      $run eval 'mv "$nlist"T "$nlist"'
4637b698ba48Smrg              case $host in
4638b698ba48Smrg              *cygwin* | *mingw* )
4639b698ba48Smrg	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4640b698ba48Smrg		$run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
4641b698ba48Smrg                ;;
4642b698ba48Smrg              esac
4643b698ba48Smrg	    fi
4644b698ba48Smrg	  fi
464509885543Smrg
4646b698ba48Smrg	  for arg in $dlprefiles; do
4647b698ba48Smrg	    $show "extracting global C symbols from \`$arg'"
4648b698ba48Smrg	    name=`$echo "$arg" | ${SED} -e 's%^.*/%%'`
4649b698ba48Smrg	    $run eval '$echo ": $name " >> "$nlist"'
4650b698ba48Smrg	    $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
4651b698ba48Smrg	  done
465209885543Smrg
4653b698ba48Smrg	  if test -z "$run"; then
4654b698ba48Smrg	    # Make sure we have at least an empty file.
4655b698ba48Smrg	    test -f "$nlist" || : > "$nlist"
465609885543Smrg
4657b698ba48Smrg	    if test -n "$exclude_expsyms"; then
4658b698ba48Smrg	      $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
4659b698ba48Smrg	      $mv "$nlist"T "$nlist"
4660b698ba48Smrg	    fi
466109885543Smrg
4662b698ba48Smrg	    # Try sorting and uniquifying the output.
4663b698ba48Smrg	    if grep -v "^: " < "$nlist" |
4664b698ba48Smrg		if sort -k 3 </dev/null >/dev/null 2>&1; then
4665b698ba48Smrg		  sort -k 3
4666b698ba48Smrg		else
4667b698ba48Smrg		  sort +2
4668b698ba48Smrg		fi |
4669b698ba48Smrg		uniq > "$nlist"S; then
4670b698ba48Smrg	      :
4671b698ba48Smrg	    else
4672b698ba48Smrg	      grep -v "^: " < "$nlist" > "$nlist"S
4673b698ba48Smrg	    fi
467409885543Smrg
4675b698ba48Smrg	    if test -f "$nlist"S; then
4676b698ba48Smrg	      eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"'
4677b698ba48Smrg	    else
4678b698ba48Smrg	      $echo '/* NONE */' >> "$output_objdir/$dlsyms"
4679b698ba48Smrg	    fi
468009885543Smrg
4681b698ba48Smrg	    $echo >> "$output_objdir/$dlsyms" "\
468209885543Smrg
4683b698ba48Smrg#undef lt_preloaded_symbols
468409885543Smrg
4685b698ba48Smrg#if defined (__STDC__) && __STDC__
4686b698ba48Smrg# define lt_ptr void *
4687b698ba48Smrg#else
4688b698ba48Smrg# define lt_ptr char *
4689b698ba48Smrg# define const
4690b698ba48Smrg#endif
469109885543Smrg
4692b698ba48Smrg/* The mapping between symbol names and symbols. */
4693b698ba48Smrg"
469409885543Smrg
4695b698ba48Smrg	    case $host in
4696b698ba48Smrg	    *cygwin* | *mingw* )
4697b698ba48Smrg	  $echo >> "$output_objdir/$dlsyms" "\
4698b698ba48Smrg/* DATA imports from DLLs on WIN32 can't be const, because
4699b698ba48Smrg   runtime relocations are performed -- see ld's documentation
4700b698ba48Smrg   on pseudo-relocs */
4701b698ba48Smrgstruct {
4702b698ba48Smrg"
4703b698ba48Smrg	      ;;
4704b698ba48Smrg	    * )
4705b698ba48Smrg	  $echo >> "$output_objdir/$dlsyms" "\
4706b698ba48Smrgconst struct {
4707b698ba48Smrg"
4708b698ba48Smrg	      ;;
4709b698ba48Smrg	    esac
471009885543Smrg
471109885543Smrg
4712b698ba48Smrg	  $echo >> "$output_objdir/$dlsyms" "\
4713b698ba48Smrg  const char *name;
4714b698ba48Smrg  lt_ptr address;
4715b698ba48Smrg}
4716b698ba48Smrglt_preloaded_symbols[] =
4717b698ba48Smrg{\
4718b698ba48Smrg"
471909885543Smrg
4720b698ba48Smrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms"
472109885543Smrg
4722b698ba48Smrg	    $echo >> "$output_objdir/$dlsyms" "\
4723b698ba48Smrg  {0, (lt_ptr) 0}
4724b698ba48Smrg};
472509885543Smrg
4726b698ba48Smrg/* This works around a problem in FreeBSD linker */
4727b698ba48Smrg#ifdef FREEBSD_WORKAROUND
4728b698ba48Smrgstatic const void *lt_preloaded_setup() {
4729b698ba48Smrg  return lt_preloaded_symbols;
4730b698ba48Smrg}
4731b698ba48Smrg#endif
473209885543Smrg
4733b698ba48Smrg#ifdef __cplusplus
4734b698ba48Smrg}
4735b698ba48Smrg#endif\
4736b698ba48Smrg"
47372ec8c4b4Smrg	  fi
47387104f784Smrg
4739b698ba48Smrg	  pic_flag_for_symtable=
4740b698ba48Smrg	  case $host in
4741b698ba48Smrg	  # compiling the symbol table file with pic_flag works around
4742b698ba48Smrg	  # a FreeBSD bug that causes programs to crash when -lm is
4743b698ba48Smrg	  # linked before any other PIC object.  But we must not use
4744b698ba48Smrg	  # pic_flag when linking with -static.  The problem exists in
4745b698ba48Smrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
4746b698ba48Smrg	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
4747b698ba48Smrg	    case "$compile_command " in
4748b698ba48Smrg	    *" -static "*) ;;
4749b698ba48Smrg	    *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";;
4750b698ba48Smrg	    esac;;
4751b698ba48Smrg	  *-*-hpux*)
4752b698ba48Smrg	    case "$compile_command " in
4753b698ba48Smrg	    *" -static "*) ;;
4754b698ba48Smrg	    *) pic_flag_for_symtable=" $pic_flag";;
4755b698ba48Smrg	    esac
4756b698ba48Smrg	  esac
475709885543Smrg
4758b698ba48Smrg	  # Now compile the dynamic symbol file.
4759b698ba48Smrg	  $show "(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
4760b698ba48Smrg	  $run eval '(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
476109885543Smrg
4762b698ba48Smrg	  # Clean up the generated files.
4763b698ba48Smrg	  $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
4764b698ba48Smrg	  $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
476509885543Smrg
4766b698ba48Smrg	  # Transform the symbol file into the correct name.
4767b698ba48Smrg          case $host in
4768b698ba48Smrg          *cygwin* | *mingw* )
4769b698ba48Smrg            if test -f "$output_objdir/${outputname}.def" ; then
4770b698ba48Smrg              compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%" | $NL2SP`
4771b698ba48Smrg              finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%" | $NL2SP`
4772b698ba48Smrg            else
4773b698ba48Smrg              compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
4774b698ba48Smrg              finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
4775b698ba48Smrg             fi
4776b698ba48Smrg            ;;
4777b698ba48Smrg          * )
4778b698ba48Smrg            compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
4779b698ba48Smrg            finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
4780b698ba48Smrg            ;;
4781b698ba48Smrg          esac
4782b698ba48Smrg	  ;;
4783b698ba48Smrg	*)
4784b698ba48Smrg	  $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
4785b698ba48Smrg	  exit $EXIT_FAILURE
4786b698ba48Smrg	  ;;
4787b698ba48Smrg	esac
4788b698ba48Smrg      else
4789b698ba48Smrg	# We keep going just in case the user didn't refer to
4790b698ba48Smrg	# lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
4791b698ba48Smrg	# really was required.
479209885543Smrg
4793b698ba48Smrg	# Nullify the symbol file.
4794b698ba48Smrg	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s% @SYMFILE@%%" | $NL2SP`
4795b698ba48Smrg	finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s% @SYMFILE@%%" | $NL2SP`
4796b698ba48Smrg      fi
479709885543Smrg
4798b698ba48Smrg      if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
4799b698ba48Smrg	# Replace the output file specification.
4800b698ba48Smrg	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e 's%@OUTPUT@%'"$output"'%g' | $NL2SP`
4801b698ba48Smrg	link_command="$compile_command$compile_rpath"
480209885543Smrg
4803b698ba48Smrg	# We have no uninstalled library dependencies, so finalize right now.
4804b698ba48Smrg	$show "$link_command"
4805b698ba48Smrg	$run eval "$link_command"
4806b698ba48Smrg	exit_status=$?
480709885543Smrg
4808b698ba48Smrg	# Delete the generated files.
4809b698ba48Smrg	if test -n "$dlsyms"; then
4810b698ba48Smrg	  $show "$rm $output_objdir/${outputname}S.${objext}"
4811b698ba48Smrg	  $run $rm "$output_objdir/${outputname}S.${objext}"
48122ec8c4b4Smrg	fi
481309885543Smrg
4814b698ba48Smrg	exit $exit_status
4815b698ba48Smrg      fi
48162ec8c4b4Smrg
4817b698ba48Smrg      if test -n "$shlibpath_var"; then
4818b698ba48Smrg	# We should set the shlibpath_var
4819b698ba48Smrg	rpath=
4820b698ba48Smrg	for dir in $temp_rpath; do
4821b698ba48Smrg	  case $dir in
4822b698ba48Smrg	  [\\/]* | [A-Za-z]:[\\/]*)
4823b698ba48Smrg	    # Absolute path.
4824b698ba48Smrg	    rpath="$rpath$dir:"
4825b698ba48Smrg	    ;;
4826b698ba48Smrg	  *)
4827b698ba48Smrg	    # Relative path: add a thisdir entry.
4828b698ba48Smrg	    rpath="$rpath\$thisdir/$dir:"
4829b698ba48Smrg	    ;;
4830b698ba48Smrg	  esac
4831b698ba48Smrg	done
4832b698ba48Smrg	temp_rpath="$rpath"
48332ec8c4b4Smrg      fi
48342ec8c4b4Smrg
4835b698ba48Smrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
4836b698ba48Smrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
4837b698ba48Smrg      fi
4838b698ba48Smrg      if test -n "$finalize_shlibpath"; then
4839b698ba48Smrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
4840b698ba48Smrg      fi
48412ec8c4b4Smrg
4842b698ba48Smrg      compile_var=
4843b698ba48Smrg      finalize_var=
4844b698ba48Smrg      if test -n "$runpath_var"; then
4845b698ba48Smrg	if test -n "$perm_rpath"; then
4846b698ba48Smrg	  # We should set the runpath_var.
4847b698ba48Smrg	  rpath=
4848b698ba48Smrg	  for dir in $perm_rpath; do
4849b698ba48Smrg	    rpath="$rpath$dir:"
4850b698ba48Smrg	  done
4851b698ba48Smrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
4852b698ba48Smrg	fi
4853b698ba48Smrg	if test -n "$finalize_perm_rpath"; then
4854b698ba48Smrg	  # We should set the runpath_var.
4855b698ba48Smrg	  rpath=
4856b698ba48Smrg	  for dir in $finalize_perm_rpath; do
4857b698ba48Smrg	    rpath="$rpath$dir:"
4858b698ba48Smrg	  done
4859b698ba48Smrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
4860b698ba48Smrg	fi
4861b698ba48Smrg      fi
48622ec8c4b4Smrg
4863b698ba48Smrg      if test "$no_install" = yes; then
4864b698ba48Smrg	# We don't need to create a wrapper script.
4865b698ba48Smrg	link_command="$compile_var$compile_command$compile_rpath"
4866b698ba48Smrg	# Replace the output file specification.
4867b698ba48Smrg	link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
4868b698ba48Smrg	# Delete the old output file.
4869b698ba48Smrg	$run $rm $output
4870b698ba48Smrg	# Link the executable and exit
4871b698ba48Smrg	$show "$link_command"
4872b698ba48Smrg	$run eval "$link_command" || exit $?
4873b698ba48Smrg	exit $EXIT_SUCCESS
4874b698ba48Smrg      fi
48752ec8c4b4Smrg
4876b698ba48Smrg      if test "$hardcode_action" = relink; then
4877b698ba48Smrg	# Fast installation is not supported
4878b698ba48Smrg	link_command="$compile_var$compile_command$compile_rpath"
4879b698ba48Smrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
48802ec8c4b4Smrg
4881b698ba48Smrg	$echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2
4882b698ba48Smrg	$echo "$modename: \`$output' will be relinked during installation" 1>&2
4883b698ba48Smrg      else
4884b698ba48Smrg	if test "$fast_install" != no; then
4885b698ba48Smrg	  link_command="$finalize_var$compile_command$finalize_rpath"
4886b698ba48Smrg	  if test "$fast_install" = yes; then
4887b698ba48Smrg	    relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $SP2NL | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g' | $NL2SP`
4888b698ba48Smrg	  else
4889b698ba48Smrg	    # fast_install is set to needless
4890b698ba48Smrg	    relink_command=
4891b698ba48Smrg	  fi
4892b698ba48Smrg	else
4893b698ba48Smrg	  link_command="$compile_var$compile_command$compile_rpath"
4894b698ba48Smrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
4895b698ba48Smrg	fi
48962ec8c4b4Smrg      fi
48972ec8c4b4Smrg
4898b698ba48Smrg      # Replace the output file specification.
4899b698ba48Smrg      link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
49002ec8c4b4Smrg
4901b698ba48Smrg      # Delete the old output files.
4902b698ba48Smrg      $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname
49032ec8c4b4Smrg
4904b698ba48Smrg      $show "$link_command"
4905b698ba48Smrg      $run eval "$link_command" || exit $?
49062ec8c4b4Smrg
4907b698ba48Smrg      # Now create the wrapper script.
4908b698ba48Smrg      $show "creating $output"
49092ec8c4b4Smrg
4910b698ba48Smrg      # Quote the relink command for shipping.
4911b698ba48Smrg      if test -n "$relink_command"; then
4912b698ba48Smrg	# Preserve any variables that may affect compiler behavior
4913b698ba48Smrg	for var in $variables_saved_for_relink; do
4914b698ba48Smrg	  if eval test -z \"\${$var+set}\"; then
4915b698ba48Smrg	    relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
4916b698ba48Smrg	  elif eval var_value=\$$var; test -z "$var_value"; then
4917b698ba48Smrg	    relink_command="$var=; export $var; $relink_command"
4918b698ba48Smrg	  else
4919b698ba48Smrg	    var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
4920b698ba48Smrg	    relink_command="$var=\"$var_value\"; export $var; $relink_command"
4921b698ba48Smrg	  fi
49222ec8c4b4Smrg	done
4923b698ba48Smrg	relink_command="(cd `pwd`; $relink_command)"
4924b698ba48Smrg	relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e "$sed_quote_subst" | $NL2SP`
49252ec8c4b4Smrg      fi
49262ec8c4b4Smrg
4927b698ba48Smrg      # Quote $echo for shipping.
4928b698ba48Smrg      if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then
4929b698ba48Smrg	case $progpath in
4930b698ba48Smrg	[\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
4931b698ba48Smrg	*) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
49322ec8c4b4Smrg	esac
4933b698ba48Smrg	qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"`
4934b698ba48Smrg      else
4935b698ba48Smrg	qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"`
49362ec8c4b4Smrg      fi
49372ec8c4b4Smrg
4938b698ba48Smrg      # Only actually do things if our run command is non-null.
4939b698ba48Smrg      if test -z "$run"; then
4940b698ba48Smrg	# win32 will think the script is a binary if it has
4941b698ba48Smrg	# a .exe suffix, so we strip it off here.
4942b698ba48Smrg	case $output in
4943b698ba48Smrg	  *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;;
4944b698ba48Smrg	esac
4945b698ba48Smrg	# test for cygwin because mv fails w/o .exe extensions
4946b698ba48Smrg	case $host in
4947b698ba48Smrg	  *cygwin*)
4948b698ba48Smrg	    exeext=.exe
4949b698ba48Smrg	    outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;;
4950b698ba48Smrg	  *) exeext= ;;
4951b698ba48Smrg	esac
4952b698ba48Smrg	case $host in
4953b698ba48Smrg	  *cygwin* | *mingw* )
4954b698ba48Smrg            output_name=`basename $output`
4955b698ba48Smrg            output_path=`dirname $output`
4956b698ba48Smrg            cwrappersource="$output_path/$objdir/lt-$output_name.c"
4957b698ba48Smrg            cwrapper="$output_path/$output_name.exe"
4958b698ba48Smrg            $rm $cwrappersource $cwrapper
4959b698ba48Smrg            trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
49602ec8c4b4Smrg
4961b698ba48Smrg	    cat > $cwrappersource <<EOF
49622ec8c4b4Smrg
4963b698ba48Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
4964b698ba48Smrg   Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
49652ec8c4b4Smrg
4966b698ba48Smrg   The $output program cannot be directly executed until all the libtool
4967b698ba48Smrg   libraries that it depends on are installed.
49682ec8c4b4Smrg
4969b698ba48Smrg   This wrapper executable should never be moved out of the build directory.
4970b698ba48Smrg   If it is, it will not operate correctly.
49712ec8c4b4Smrg
4972b698ba48Smrg   Currently, it simply execs the wrapper *script* "/bin/sh $output",
4973b698ba48Smrg   but could eventually absorb all of the scripts functionality and
4974b698ba48Smrg   exec $objdir/$outputname directly.
4975b698ba48Smrg*/
4976b698ba48SmrgEOF
4977b698ba48Smrg	    cat >> $cwrappersource<<"EOF"
4978b698ba48Smrg#include <stdio.h>
4979b698ba48Smrg#include <stdlib.h>
4980b698ba48Smrg#include <unistd.h>
4981b698ba48Smrg#include <malloc.h>
4982b698ba48Smrg#include <stdarg.h>
4983b698ba48Smrg#include <assert.h>
4984b698ba48Smrg#include <string.h>
4985b698ba48Smrg#include <ctype.h>
4986b698ba48Smrg#include <sys/stat.h>
49872ec8c4b4Smrg
4988b698ba48Smrg#if defined(PATH_MAX)
4989b698ba48Smrg# define LT_PATHMAX PATH_MAX
4990b698ba48Smrg#elif defined(MAXPATHLEN)
4991b698ba48Smrg# define LT_PATHMAX MAXPATHLEN
4992b698ba48Smrg#else
4993b698ba48Smrg# define LT_PATHMAX 1024
4994b698ba48Smrg#endif
49952ec8c4b4Smrg
4996b698ba48Smrg#ifndef DIR_SEPARATOR
4997b698ba48Smrg# define DIR_SEPARATOR '/'
4998b698ba48Smrg# define PATH_SEPARATOR ':'
4999b698ba48Smrg#endif
50002ec8c4b4Smrg
5001b698ba48Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
5002b698ba48Smrg  defined (__OS2__)
5003b698ba48Smrg# define HAVE_DOS_BASED_FILE_SYSTEM
5004b698ba48Smrg# ifndef DIR_SEPARATOR_2
5005b698ba48Smrg#  define DIR_SEPARATOR_2 '\\'
5006b698ba48Smrg# endif
5007b698ba48Smrg# ifndef PATH_SEPARATOR_2
5008b698ba48Smrg#  define PATH_SEPARATOR_2 ';'
5009b698ba48Smrg# endif
5010b698ba48Smrg#endif
50112ec8c4b4Smrg
5012b698ba48Smrg#ifndef DIR_SEPARATOR_2
5013b698ba48Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
5014b698ba48Smrg#else /* DIR_SEPARATOR_2 */
5015b698ba48Smrg# define IS_DIR_SEPARATOR(ch) \
5016b698ba48Smrg        (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
5017b698ba48Smrg#endif /* DIR_SEPARATOR_2 */
50182ec8c4b4Smrg
5019b698ba48Smrg#ifndef PATH_SEPARATOR_2
5020b698ba48Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
5021b698ba48Smrg#else /* PATH_SEPARATOR_2 */
5022b698ba48Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
5023b698ba48Smrg#endif /* PATH_SEPARATOR_2 */
50242ec8c4b4Smrg
5025b698ba48Smrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
5026b698ba48Smrg#define XFREE(stale) do { \
5027b698ba48Smrg  if (stale) { free ((void *) stale); stale = 0; } \
5028b698ba48Smrg} while (0)
50292ec8c4b4Smrg
5030b698ba48Smrg/* -DDEBUG is fairly common in CFLAGS.  */
5031b698ba48Smrg#undef DEBUG
5032b698ba48Smrg#if defined DEBUGWRAPPER
5033b698ba48Smrg# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
5034b698ba48Smrg#else
5035b698ba48Smrg# define DEBUG(format, ...)
5036b698ba48Smrg#endif
50372ec8c4b4Smrg
5038b698ba48Smrgconst char *program_name = NULL;
50392ec8c4b4Smrg
5040b698ba48Smrgvoid * xmalloc (size_t num);
5041b698ba48Smrgchar * xstrdup (const char *string);
5042b698ba48Smrgconst char * base_name (const char *name);
5043b698ba48Smrgchar * find_executable(const char *wrapper);
5044b698ba48Smrgint    check_executable(const char *path);
5045b698ba48Smrgchar * strendzap(char *str, const char *pat);
5046b698ba48Smrgvoid lt_fatal (const char *message, ...);
50472ec8c4b4Smrg
5048b698ba48Smrgint
5049b698ba48Smrgmain (int argc, char *argv[])
5050b698ba48Smrg{
5051b698ba48Smrg  char **newargz;
5052b698ba48Smrg  int i;
50532ec8c4b4Smrg
5054b698ba48Smrg  program_name = (char *) xstrdup (base_name (argv[0]));
5055b698ba48Smrg  DEBUG("(main) argv[0]      : %s\n",argv[0]);
5056b698ba48Smrg  DEBUG("(main) program_name : %s\n",program_name);
5057b698ba48Smrg  newargz = XMALLOC(char *, argc+2);
5058b698ba48SmrgEOF
50592ec8c4b4Smrg
5060b698ba48Smrg            cat >> $cwrappersource <<EOF
5061b698ba48Smrg  newargz[0] = (char *) xstrdup("$SHELL");
5062b698ba48SmrgEOF
50632ec8c4b4Smrg
5064b698ba48Smrg            cat >> $cwrappersource <<"EOF"
5065b698ba48Smrg  newargz[1] = find_executable(argv[0]);
5066b698ba48Smrg  if (newargz[1] == NULL)
5067b698ba48Smrg    lt_fatal("Couldn't find %s", argv[0]);
5068b698ba48Smrg  DEBUG("(main) found exe at : %s\n",newargz[1]);
5069b698ba48Smrg  /* we know the script has the same name, without the .exe */
5070b698ba48Smrg  /* so make sure newargz[1] doesn't end in .exe */
5071b698ba48Smrg  strendzap(newargz[1],".exe");
5072b698ba48Smrg  for (i = 1; i < argc; i++)
5073b698ba48Smrg    newargz[i+1] = xstrdup(argv[i]);
5074b698ba48Smrg  newargz[argc+1] = NULL;
50752ec8c4b4Smrg
5076b698ba48Smrg  for (i=0; i<argc+1; i++)
5077b698ba48Smrg  {
5078b698ba48Smrg    DEBUG("(main) newargz[%d]   : %s\n",i,newargz[i]);
5079b698ba48Smrg    ;
5080b698ba48Smrg  }
50812ec8c4b4Smrg
5082b698ba48SmrgEOF
50832ec8c4b4Smrg
5084b698ba48Smrg            case $host_os in
5085b698ba48Smrg              mingw*)
5086b698ba48Smrg                cat >> $cwrappersource <<EOF
5087b698ba48Smrg  execv("$SHELL",(char const **)newargz);
5088b698ba48SmrgEOF
5089b698ba48Smrg              ;;
5090b698ba48Smrg              *)
5091b698ba48Smrg                cat >> $cwrappersource <<EOF
5092b698ba48Smrg  execv("$SHELL",newargz);
5093b698ba48SmrgEOF
5094b698ba48Smrg              ;;
5095b698ba48Smrg            esac
50962ec8c4b4Smrg
5097b698ba48Smrg            cat >> $cwrappersource <<"EOF"
5098b698ba48Smrg  return 127;
5099b698ba48Smrg}
51002ec8c4b4Smrg
5101b698ba48Smrgvoid *
5102b698ba48Smrgxmalloc (size_t num)
5103b698ba48Smrg{
5104b698ba48Smrg  void * p = (void *) malloc (num);
5105b698ba48Smrg  if (!p)
5106b698ba48Smrg    lt_fatal ("Memory exhausted");
51072ec8c4b4Smrg
5108b698ba48Smrg  return p;
5109b698ba48Smrg}
51102ec8c4b4Smrg
5111b698ba48Smrgchar *
5112b698ba48Smrgxstrdup (const char *string)
5113b698ba48Smrg{
5114b698ba48Smrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL
5115b698ba48Smrg;
5116b698ba48Smrg}
51172ec8c4b4Smrg
5118b698ba48Smrgconst char *
5119b698ba48Smrgbase_name (const char *name)
5120b698ba48Smrg{
5121b698ba48Smrg  const char *base;
51222ec8c4b4Smrg
5123b698ba48Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
5124b698ba48Smrg  /* Skip over the disk name in MSDOS pathnames. */
5125b698ba48Smrg  if (isalpha ((unsigned char)name[0]) && name[1] == ':')
5126b698ba48Smrg    name += 2;
5127b698ba48Smrg#endif
51282ec8c4b4Smrg
5129b698ba48Smrg  for (base = name; *name; name++)
5130b698ba48Smrg    if (IS_DIR_SEPARATOR (*name))
5131b698ba48Smrg      base = name + 1;
5132b698ba48Smrg  return base;
5133b698ba48Smrg}
51342ec8c4b4Smrg
5135b698ba48Smrgint
5136b698ba48Smrgcheck_executable(const char * path)
5137b698ba48Smrg{
5138b698ba48Smrg  struct stat st;
51392ec8c4b4Smrg
5140b698ba48Smrg  DEBUG("(check_executable)  : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!");
5141b698ba48Smrg  if ((!path) || (!*path))
5142b698ba48Smrg    return 0;
51432ec8c4b4Smrg
5144b698ba48Smrg  if ((stat (path, &st) >= 0) &&
5145b698ba48Smrg      (
5146b698ba48Smrg        /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */
5147b698ba48Smrg#if defined (S_IXOTH)
5148b698ba48Smrg       ((st.st_mode & S_IXOTH) == S_IXOTH) ||
5149b698ba48Smrg#endif
5150b698ba48Smrg#if defined (S_IXGRP)
5151b698ba48Smrg       ((st.st_mode & S_IXGRP) == S_IXGRP) ||
5152b698ba48Smrg#endif
5153b698ba48Smrg       ((st.st_mode & S_IXUSR) == S_IXUSR))
5154b698ba48Smrg      )
5155b698ba48Smrg    return 1;
5156b698ba48Smrg  else
5157b698ba48Smrg    return 0;
5158b698ba48Smrg}
51592ec8c4b4Smrg
5160b698ba48Smrg/* Searches for the full path of the wrapper.  Returns
5161b698ba48Smrg   newly allocated full path name if found, NULL otherwise */
5162b698ba48Smrgchar *
5163b698ba48Smrgfind_executable (const char* wrapper)
5164b698ba48Smrg{
5165b698ba48Smrg  int has_slash = 0;
5166b698ba48Smrg  const char* p;
5167b698ba48Smrg  const char* p_next;
5168b698ba48Smrg  /* static buffer for getcwd */
5169b698ba48Smrg  char tmp[LT_PATHMAX + 1];
5170b698ba48Smrg  int tmp_len;
5171b698ba48Smrg  char* concat_name;
51722ec8c4b4Smrg
5173b698ba48Smrg  DEBUG("(find_executable)  : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!");
517409885543Smrg
5175b698ba48Smrg  if ((wrapper == NULL) || (*wrapper == '\0'))
5176b698ba48Smrg    return NULL;
517709885543Smrg
5178b698ba48Smrg  /* Absolute path? */
5179b698ba48Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
5180b698ba48Smrg  if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':')
5181b698ba48Smrg  {
5182b698ba48Smrg    concat_name = xstrdup (wrapper);
5183b698ba48Smrg    if (check_executable(concat_name))
5184b698ba48Smrg      return concat_name;
5185b698ba48Smrg    XFREE(concat_name);
5186b698ba48Smrg  }
5187b698ba48Smrg  else
5188b698ba48Smrg  {
5189b698ba48Smrg#endif
5190b698ba48Smrg    if (IS_DIR_SEPARATOR (wrapper[0]))
5191b698ba48Smrg    {
5192b698ba48Smrg      concat_name = xstrdup (wrapper);
5193b698ba48Smrg      if (check_executable(concat_name))
5194b698ba48Smrg        return concat_name;
5195b698ba48Smrg      XFREE(concat_name);
5196b698ba48Smrg    }
5197b698ba48Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
5198b698ba48Smrg  }
5199b698ba48Smrg#endif
5200b698ba48Smrg
5201b698ba48Smrg  for (p = wrapper; *p; p++)
5202b698ba48Smrg    if (*p == '/')
5203b698ba48Smrg    {
5204b698ba48Smrg      has_slash = 1;
5205b698ba48Smrg      break;
5206b698ba48Smrg    }
5207b698ba48Smrg  if (!has_slash)
5208b698ba48Smrg  {
5209b698ba48Smrg    /* no slashes; search PATH */
5210b698ba48Smrg    const char* path = getenv ("PATH");
5211b698ba48Smrg    if (path != NULL)
5212b698ba48Smrg    {
5213b698ba48Smrg      for (p = path; *p; p = p_next)
5214b698ba48Smrg      {
5215b698ba48Smrg        const char* q;
5216b698ba48Smrg        size_t p_len;
5217b698ba48Smrg        for (q = p; *q; q++)
5218b698ba48Smrg          if (IS_PATH_SEPARATOR(*q))
5219b698ba48Smrg            break;
5220b698ba48Smrg        p_len = q - p;
5221b698ba48Smrg        p_next = (*q == '\0' ? q : q + 1);
5222b698ba48Smrg        if (p_len == 0)
5223b698ba48Smrg        {
5224b698ba48Smrg          /* empty path: current directory */
5225b698ba48Smrg          if (getcwd (tmp, LT_PATHMAX) == NULL)
5226b698ba48Smrg            lt_fatal ("getcwd failed");
5227b698ba48Smrg          tmp_len = strlen(tmp);
5228b698ba48Smrg          concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
5229b698ba48Smrg          memcpy (concat_name, tmp, tmp_len);
5230b698ba48Smrg          concat_name[tmp_len] = '/';
5231b698ba48Smrg          strcpy (concat_name + tmp_len + 1, wrapper);
5232b698ba48Smrg        }
5233b698ba48Smrg        else
5234b698ba48Smrg        {
5235b698ba48Smrg          concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1);
5236b698ba48Smrg          memcpy (concat_name, p, p_len);
5237b698ba48Smrg          concat_name[p_len] = '/';
5238b698ba48Smrg          strcpy (concat_name + p_len + 1, wrapper);
5239b698ba48Smrg        }
5240b698ba48Smrg        if (check_executable(concat_name))
5241b698ba48Smrg          return concat_name;
5242b698ba48Smrg        XFREE(concat_name);
5243b698ba48Smrg      }
5244b698ba48Smrg    }
5245b698ba48Smrg    /* not found in PATH; assume curdir */
5246b698ba48Smrg  }
5247b698ba48Smrg  /* Relative path | not found in path: prepend cwd */
5248b698ba48Smrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
5249b698ba48Smrg    lt_fatal ("getcwd failed");
5250b698ba48Smrg  tmp_len = strlen(tmp);
5251b698ba48Smrg  concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
5252b698ba48Smrg  memcpy (concat_name, tmp, tmp_len);
5253b698ba48Smrg  concat_name[tmp_len] = '/';
5254b698ba48Smrg  strcpy (concat_name + tmp_len + 1, wrapper);
5255b698ba48Smrg
5256b698ba48Smrg  if (check_executable(concat_name))
5257b698ba48Smrg    return concat_name;
5258b698ba48Smrg  XFREE(concat_name);
5259b698ba48Smrg  return NULL;
5260b698ba48Smrg}
5261b698ba48Smrg
5262b698ba48Smrgchar *
5263b698ba48Smrgstrendzap(char *str, const char *pat)
5264b698ba48Smrg{
5265b698ba48Smrg  size_t len, patlen;
5266b698ba48Smrg
5267b698ba48Smrg  assert(str != NULL);
5268b698ba48Smrg  assert(pat != NULL);
5269b698ba48Smrg
5270b698ba48Smrg  len = strlen(str);
5271b698ba48Smrg  patlen = strlen(pat);
5272b698ba48Smrg
5273b698ba48Smrg  if (patlen <= len)
5274b698ba48Smrg  {
5275b698ba48Smrg    str += len - patlen;
5276b698ba48Smrg    if (strcmp(str, pat) == 0)
5277b698ba48Smrg      *str = '\0';
5278b698ba48Smrg  }
5279b698ba48Smrg  return str;
5280b698ba48Smrg}
5281b698ba48Smrg
5282b698ba48Smrgstatic void
5283b698ba48Smrglt_error_core (int exit_status, const char * mode,
5284b698ba48Smrg          const char * message, va_list ap)
5285b698ba48Smrg{
5286b698ba48Smrg  fprintf (stderr, "%s: %s: ", program_name, mode);
5287b698ba48Smrg  vfprintf (stderr, message, ap);
5288b698ba48Smrg  fprintf (stderr, ".\n");
5289b698ba48Smrg
5290b698ba48Smrg  if (exit_status >= 0)
5291b698ba48Smrg    exit (exit_status);
5292b698ba48Smrg}
5293b698ba48Smrg
5294b698ba48Smrgvoid
5295b698ba48Smrglt_fatal (const char *message, ...)
5296b698ba48Smrg{
5297b698ba48Smrg  va_list ap;
5298b698ba48Smrg  va_start (ap, message);
5299b698ba48Smrg  lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
5300b698ba48Smrg  va_end (ap);
5301b698ba48Smrg}
5302b698ba48SmrgEOF
5303b698ba48Smrg          # we should really use a build-platform specific compiler
5304b698ba48Smrg          # here, but OTOH, the wrappers (shell script and this C one)
5305b698ba48Smrg          # are only useful if you want to execute the "real" binary.
5306b698ba48Smrg          # Since the "real" binary is built for $host, then this
5307b698ba48Smrg          # wrapper might as well be built for $host, too.
5308b698ba48Smrg          $run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource
5309b698ba48Smrg          ;;
5310b698ba48Smrg        esac
5311b698ba48Smrg        $rm $output
5312b698ba48Smrg        trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
5313b698ba48Smrg
5314b698ba48Smrg	$echo > $output "\
5315b698ba48Smrg#! $SHELL
5316b698ba48Smrg
5317b698ba48Smrg# $output - temporary wrapper script for $objdir/$outputname
5318b698ba48Smrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
5319b698ba48Smrg#
5320b698ba48Smrg# The $output program cannot be directly executed until all the libtool
5321b698ba48Smrg# libraries that it depends on are installed.
5322b698ba48Smrg#
5323b698ba48Smrg# This wrapper script should never be moved out of the build directory.
5324b698ba48Smrg# If it is, it will not operate correctly.
5325b698ba48Smrg
5326b698ba48Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
5327b698ba48Smrg# metacharacters that are still active within double-quoted strings.
5328b698ba48SmrgXsed='${SED} -e 1s/^X//'
5329b698ba48Smrgsed_quote_subst='$sed_quote_subst'
5330b698ba48Smrg
5331b698ba48Smrg# Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE).
5332b698ba48Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
5333b698ba48Smrg  emulate sh
5334b698ba48Smrg  NULLCMD=:
5335b698ba48Smrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
5336b698ba48Smrg  # is contrary to our usage.  Disable this feature.
5337b698ba48Smrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
5338b698ba48Smrg  setopt NO_GLOB_SUBST
5339b698ba48Smrgelse
5340b698ba48Smrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
5341b698ba48Smrgfi
5342b698ba48SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
5343b698ba48SmrgDUALCASE=1; export DUALCASE # for MKS sh
5344b698ba48Smrg
5345b698ba48Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout
5346b698ba48Smrg# if CDPATH is set.
5347b698ba48Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
5348b698ba48Smrg
5349b698ba48Smrgrelink_command=\"$relink_command\"
5350b698ba48Smrg
5351b698ba48Smrg# This environment variable determines our operation mode.
5352b698ba48Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then
5353b698ba48Smrg  # install mode needs the following variable:
5354b698ba48Smrg  notinst_deplibs='$notinst_deplibs'
5355b698ba48Smrgelse
5356b698ba48Smrg  # When we are sourced in execute mode, \$file and \$echo are already set.
5357b698ba48Smrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
5358b698ba48Smrg    echo=\"$qecho\"
5359b698ba48Smrg    file=\"\$0\"
5360b698ba48Smrg    # Make sure echo works.
5361b698ba48Smrg    if test \"X\$1\" = X--no-reexec; then
5362b698ba48Smrg      # Discard the --no-reexec flag, and continue.
5363b698ba48Smrg      shift
5364b698ba48Smrg    elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then
5365b698ba48Smrg      # Yippee, \$echo works!
5366b698ba48Smrg      :
5367b698ba48Smrg    else
5368b698ba48Smrg      # Restart under the correct shell, and then maybe \$echo will work.
5369b698ba48Smrg      exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
5370b698ba48Smrg    fi
5371b698ba48Smrg  fi\
5372b698ba48Smrg"
5373b698ba48Smrg	$echo >> $output "\
537409885543Smrg
5375b698ba48Smrg  # Find the directory that this script lives in.
5376b698ba48Smrg  thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
5377b698ba48Smrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
537809885543Smrg
5379b698ba48Smrg  # Follow symbolic links until we get to the real thisdir.
5380b698ba48Smrg  file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
5381b698ba48Smrg  while test -n \"\$file\"; do
5382b698ba48Smrg    destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
538309885543Smrg
5384b698ba48Smrg    # If there was a directory component, then change thisdir.
5385b698ba48Smrg    if test \"x\$destdir\" != \"x\$file\"; then
5386b698ba48Smrg      case \"\$destdir\" in
5387b698ba48Smrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
5388b698ba48Smrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
5389b698ba48Smrg      esac
5390b698ba48Smrg    fi
539109885543Smrg
5392b698ba48Smrg    file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
5393b698ba48Smrg    file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
5394b698ba48Smrg  done
539509885543Smrg
5396b698ba48Smrg  # Try to get the absolute directory name.
5397b698ba48Smrg  absdir=\`cd \"\$thisdir\" && pwd\`
5398b698ba48Smrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
5399b698ba48Smrg"
540009885543Smrg
5401b698ba48Smrg	if test "$fast_install" = yes; then
5402b698ba48Smrg	  $echo >> $output "\
5403b698ba48Smrg  program=lt-'$outputname'$exeext
5404b698ba48Smrg  progdir=\"\$thisdir/$objdir\"
540509885543Smrg
5406b698ba48Smrg  if test ! -f \"\$progdir/\$program\" || \\
5407b698ba48Smrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
5408b698ba48Smrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
540909885543Smrg
5410b698ba48Smrg    file=\"\$\$-\$program\"
541109885543Smrg
5412b698ba48Smrg    if test ! -d \"\$progdir\"; then
5413b698ba48Smrg      $mkdir \"\$progdir\"
5414b698ba48Smrg    else
5415b698ba48Smrg      $rm \"\$progdir/\$file\"
5416b698ba48Smrg    fi"
54177104f784Smrg
5418b698ba48Smrg	  $echo >> $output "\
541909885543Smrg
5420b698ba48Smrg    # relink executable if necessary
5421b698ba48Smrg    if test -n \"\$relink_command\"; then
5422b698ba48Smrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
5423b698ba48Smrg      else
5424b698ba48Smrg	$echo \"\$relink_command_output\" >&2
5425b698ba48Smrg	$rm \"\$progdir/\$file\"
5426b698ba48Smrg	exit $EXIT_FAILURE
5427b698ba48Smrg      fi
5428b698ba48Smrg    fi
542909885543Smrg
5430b698ba48Smrg    $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
5431b698ba48Smrg    { $rm \"\$progdir/\$program\";
5432b698ba48Smrg      $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
5433b698ba48Smrg    $rm \"\$progdir/\$file\"
5434b698ba48Smrg  fi"
5435b698ba48Smrg	else
5436b698ba48Smrg	  $echo >> $output "\
5437b698ba48Smrg  program='$outputname'
5438b698ba48Smrg  progdir=\"\$thisdir/$objdir\"
5439b698ba48Smrg"
54402ec8c4b4Smrg	fi
544109885543Smrg
5442b698ba48Smrg	$echo >> $output "\
544309885543Smrg
5444b698ba48Smrg  if test -f \"\$progdir/\$program\"; then"
544509885543Smrg
5446b698ba48Smrg	# Export our shlibpath_var if we have one.
5447b698ba48Smrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
5448b698ba48Smrg	  $echo >> $output "\
5449b698ba48Smrg    # Add our own library path to $shlibpath_var
5450b698ba48Smrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
545109885543Smrg
5452b698ba48Smrg    # Some systems cannot cope with colon-terminated $shlibpath_var
5453b698ba48Smrg    # The second colon is a workaround for a bug in BeOS R4 sed
5454b698ba48Smrg    $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
54552ec8c4b4Smrg
5456b698ba48Smrg    export $shlibpath_var
5457b698ba48Smrg"
5458b698ba48Smrg	fi
54592ec8c4b4Smrg
5460b698ba48Smrg	# fixup the dll searchpath if we need to.
5461b698ba48Smrg	if test -n "$dllsearchpath"; then
5462b698ba48Smrg	  $echo >> $output "\
5463b698ba48Smrg    # Add the dll search path components to the executable PATH
5464b698ba48Smrg    PATH=$dllsearchpath:\$PATH
5465b698ba48Smrg"
5466b698ba48Smrg	fi
54672ec8c4b4Smrg
5468b698ba48Smrg	$echo >> $output "\
5469b698ba48Smrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
5470b698ba48Smrg      # Run the actual program with our arguments.
5471b698ba48Smrg"
5472b698ba48Smrg	case $host in
5473b698ba48Smrg	# Backslashes separate directories on plain windows
5474b698ba48Smrg	*-*-mingw | *-*-os2*)
5475b698ba48Smrg	  $echo >> $output "\
5476b698ba48Smrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
5477b698ba48Smrg"
5478b698ba48Smrg	  ;;
547909885543Smrg
5480b698ba48Smrg	*)
5481b698ba48Smrg	  $echo >> $output "\
5482b698ba48Smrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
5483b698ba48Smrg"
5484b698ba48Smrg	  ;;
5485b698ba48Smrg	esac
5486b698ba48Smrg	$echo >> $output "\
5487b698ba48Smrg      \$echo \"\$0: cannot exec \$program \$*\"
5488b698ba48Smrg      exit $EXIT_FAILURE
5489b698ba48Smrg    fi
5490b698ba48Smrg  else
5491b698ba48Smrg    # The program doesn't exist.
5492b698ba48Smrg    \$echo \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
5493b698ba48Smrg    \$echo \"This script is just a wrapper for \$program.\" 1>&2
5494b698ba48Smrg    $echo \"See the $PACKAGE documentation for more information.\" 1>&2
5495b698ba48Smrg    exit $EXIT_FAILURE
5496b698ba48Smrg  fi
5497b698ba48Smrgfi\
5498b698ba48Smrg"
5499b698ba48Smrg	chmod +x $output
5500b698ba48Smrg      fi
5501b698ba48Smrg      exit $EXIT_SUCCESS
5502b698ba48Smrg      ;;
5503b698ba48Smrg    esac
550409885543Smrg
5505b698ba48Smrg    # See if we need to build an old-fashioned archive.
5506b698ba48Smrg    for oldlib in $oldlibs; do
550709885543Smrg
5508b698ba48Smrg      if test "$build_libtool_libs" = convenience; then
5509b698ba48Smrg	oldobjs="$libobjs_save"
5510b698ba48Smrg	addlibs="$convenience"
5511b698ba48Smrg	build_libtool_libs=no
5512b698ba48Smrg      else
5513b698ba48Smrg	if test "$build_libtool_libs" = module; then
5514b698ba48Smrg	  oldobjs="$libobjs_save"
5515b698ba48Smrg	  build_libtool_libs=no
5516b698ba48Smrg	else
5517b698ba48Smrg	  oldobjs="$old_deplibs $non_pic_objects"
5518b698ba48Smrg	fi
5519b698ba48Smrg	addlibs="$old_convenience"
5520b698ba48Smrg      fi
552109885543Smrg
5522b698ba48Smrg      if test -n "$addlibs"; then
5523b698ba48Smrg	gentop="$output_objdir/${outputname}x"
5524b698ba48Smrg	generated="$generated $gentop"
552509885543Smrg
5526b698ba48Smrg	func_extract_archives $gentop $addlibs
5527b698ba48Smrg	oldobjs="$oldobjs $func_extract_archives_result"
5528b698ba48Smrg      fi
552909885543Smrg
5530b698ba48Smrg      # Do each command in the archive commands.
5531b698ba48Smrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
5532b698ba48Smrg       cmds=$old_archive_from_new_cmds
5533b698ba48Smrg      else
5534b698ba48Smrg	# POSIX demands no paths to be encoded in archives.  We have
5535b698ba48Smrg	# to avoid creating archives with duplicate basenames if we
5536b698ba48Smrg	# might have to extract them afterwards, e.g., when creating a
5537b698ba48Smrg	# static archive out of a convenience library, or when linking
5538b698ba48Smrg	# the entirety of a libtool archive into another (currently
5539b698ba48Smrg	# not supported by libtool).
5540b698ba48Smrg	if (for obj in $oldobjs
5541b698ba48Smrg	    do
5542b698ba48Smrg	      $echo "X$obj" | $Xsed -e 's%^.*/%%'
5543b698ba48Smrg	    done | sort | sort -uc >/dev/null 2>&1); then
5544b698ba48Smrg	  :
5545b698ba48Smrg	else
5546b698ba48Smrg	  $echo "copying selected object files to avoid basename conflicts..."
554709885543Smrg
5548b698ba48Smrg	  if test -z "$gentop"; then
5549b698ba48Smrg	    gentop="$output_objdir/${outputname}x"
5550b698ba48Smrg	    generated="$generated $gentop"
555109885543Smrg
5552b698ba48Smrg	    $show "${rm}r $gentop"
5553b698ba48Smrg	    $run ${rm}r "$gentop"
5554b698ba48Smrg	    $show "$mkdir $gentop"
5555b698ba48Smrg	    $run $mkdir "$gentop"
5556b698ba48Smrg	    exit_status=$?
5557b698ba48Smrg	    if test "$exit_status" -ne 0 && test ! -d "$gentop"; then
5558b698ba48Smrg	      exit $exit_status
55592ec8c4b4Smrg	    fi
55602ec8c4b4Smrg	  fi
556109885543Smrg
5562b698ba48Smrg	  save_oldobjs=$oldobjs
5563b698ba48Smrg	  oldobjs=
5564b698ba48Smrg	  counter=1
5565b698ba48Smrg	  for obj in $save_oldobjs
5566b698ba48Smrg	  do
5567b698ba48Smrg	    objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
5568b698ba48Smrg	    case " $oldobjs " in
5569b698ba48Smrg	    " ") oldobjs=$obj ;;
5570b698ba48Smrg	    *[\ /]"$objbase "*)
5571b698ba48Smrg	      while :; do
5572b698ba48Smrg		# Make sure we don't pick an alternate name that also
5573b698ba48Smrg		# overlaps.
5574b698ba48Smrg		newobj=lt$counter-$objbase
5575b698ba48Smrg		counter=`expr $counter + 1`
5576b698ba48Smrg		case " $oldobjs " in
5577b698ba48Smrg		*[\ /]"$newobj "*) ;;
5578b698ba48Smrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
5579b698ba48Smrg		esac
5580b698ba48Smrg	      done
5581b698ba48Smrg	      $show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
5582b698ba48Smrg	      $run ln "$obj" "$gentop/$newobj" ||
5583b698ba48Smrg	      $run cp "$obj" "$gentop/$newobj"
5584b698ba48Smrg	      oldobjs="$oldobjs $gentop/$newobj"
5585b698ba48Smrg	      ;;
5586b698ba48Smrg	    *) oldobjs="$oldobjs $obj" ;;
5587b698ba48Smrg	    esac
5588b698ba48Smrg	  done
5589b698ba48Smrg	fi
559009885543Smrg
5591b698ba48Smrg	eval cmds=\"$old_archive_cmds\"
559209885543Smrg
5593b698ba48Smrg	if len=`expr "X$cmds" : ".*"` &&
5594b698ba48Smrg	     test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
5595b698ba48Smrg	  cmds=$old_archive_cmds
5596b698ba48Smrg	else
5597b698ba48Smrg	  # the command line is too long to link in one step, link in parts
5598b698ba48Smrg	  $echo "using piecewise archive linking..."
5599b698ba48Smrg	  save_RANLIB=$RANLIB
5600b698ba48Smrg	  RANLIB=:
5601b698ba48Smrg	  objlist=
5602b698ba48Smrg	  concat_cmds=
5603b698ba48Smrg	  save_oldobjs=$oldobjs
5604b698ba48Smrg
5605b698ba48Smrg	  # Is there a better way of finding the last object in the list?
5606b698ba48Smrg	  for obj in $save_oldobjs
5607b698ba48Smrg	  do
5608b698ba48Smrg	    last_oldobj=$obj
5609b698ba48Smrg	  done
5610b698ba48Smrg	  for obj in $save_oldobjs
5611b698ba48Smrg	  do
5612b698ba48Smrg	    oldobjs="$objlist $obj"
5613b698ba48Smrg	    objlist="$objlist $obj"
5614b698ba48Smrg	    eval test_cmds=\"$old_archive_cmds\"
5615b698ba48Smrg	    if len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
5616b698ba48Smrg	       test "$len" -le "$max_cmd_len"; then
5617b698ba48Smrg	      :
56182ec8c4b4Smrg	    else
5619b698ba48Smrg	      # the above command should be used before it gets too long
5620b698ba48Smrg	      oldobjs=$objlist
5621b698ba48Smrg	      if test "$obj" = "$last_oldobj" ; then
5622b698ba48Smrg	        RANLIB=$save_RANLIB
5623b698ba48Smrg	      fi
5624b698ba48Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
5625b698ba48Smrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
5626b698ba48Smrg	      objlist=
562709885543Smrg	    fi
5628b698ba48Smrg	  done
5629b698ba48Smrg	  RANLIB=$save_RANLIB
5630b698ba48Smrg	  oldobjs=$objlist
5631b698ba48Smrg	  if test "X$oldobjs" = "X" ; then
5632b698ba48Smrg	    eval cmds=\"\$concat_cmds\"
563309885543Smrg	  else
5634b698ba48Smrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
563509885543Smrg	  fi
56362ec8c4b4Smrg	fi
5637b698ba48Smrg      fi
5638b698ba48Smrg      save_ifs="$IFS"; IFS='~'
5639b698ba48Smrg      for cmd in $cmds; do
5640b698ba48Smrg        eval cmd=\"$cmd\"
56412ec8c4b4Smrg	IFS="$save_ifs"
5642b698ba48Smrg	$show "$cmd"
5643b698ba48Smrg	$run eval "$cmd" || exit $?
5644b698ba48Smrg      done
5645b698ba48Smrg      IFS="$save_ifs"
5646b698ba48Smrg    done
564709885543Smrg
5648b698ba48Smrg    if test -n "$generated"; then
5649b698ba48Smrg      $show "${rm}r$generated"
5650b698ba48Smrg      $run ${rm}r$generated
5651b698ba48Smrg    fi
56522ec8c4b4Smrg
5653b698ba48Smrg    # Now create the libtool archive.
5654b698ba48Smrg    case $output in
5655b698ba48Smrg    *.la)
5656b698ba48Smrg      old_library=
5657b698ba48Smrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
5658b698ba48Smrg      $show "creating $output"
565909885543Smrg
5660b698ba48Smrg      # Preserve any variables that may affect compiler behavior
5661b698ba48Smrg      for var in $variables_saved_for_relink; do
5662b698ba48Smrg	if eval test -z \"\${$var+set}\"; then
5663b698ba48Smrg	  relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
5664b698ba48Smrg	elif eval var_value=\$$var; test -z "$var_value"; then
5665b698ba48Smrg	  relink_command="$var=; export $var; $relink_command"
5666b698ba48Smrg	else
5667b698ba48Smrg	  var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
5668b698ba48Smrg	  relink_command="$var=\"$var_value\"; export $var; $relink_command"
56692ec8c4b4Smrg	fi
5670b698ba48Smrg      done
5671b698ba48Smrg      # Quote the link command for shipping.
5672b698ba48Smrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
5673b698ba48Smrg      relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e "$sed_quote_subst" | $NL2SP`
5674b698ba48Smrg      if test "$hardcode_automatic" = yes ; then
5675b698ba48Smrg	relink_command=
56762ec8c4b4Smrg      fi
567709885543Smrg
567809885543Smrg
5679b698ba48Smrg      # Only create the output if not a dry run.
5680b698ba48Smrg      if test -z "$run"; then
5681b698ba48Smrg	for installed in no yes; do
5682b698ba48Smrg	  if test "$installed" = yes; then
5683b698ba48Smrg	    if test -z "$install_libdir"; then
5684b698ba48Smrg	      break
5685b698ba48Smrg	    fi
5686b698ba48Smrg	    output="$output_objdir/$outputname"i
5687b698ba48Smrg	    # Replace all uninstalled libtool libraries with the installed ones
5688b698ba48Smrg	    newdependency_libs=
5689b698ba48Smrg	    for deplib in $dependency_libs; do
5690b698ba48Smrg	      case $deplib in
5691b698ba48Smrg	      *.la)
5692b698ba48Smrg		name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'`
5693b698ba48Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
5694b698ba48Smrg		if test -z "$libdir"; then
5695b698ba48Smrg		  $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
5696b698ba48Smrg		  exit $EXIT_FAILURE
5697b698ba48Smrg		fi
5698b698ba48Smrg		newdependency_libs="$newdependency_libs $libdir/$name"
5699b698ba48Smrg		;;
5700b698ba48Smrg	      *) newdependency_libs="$newdependency_libs $deplib" ;;
5701b698ba48Smrg	      esac
5702b698ba48Smrg	    done
5703b698ba48Smrg	    dependency_libs="$newdependency_libs"
5704b698ba48Smrg	    newdlfiles=
5705b698ba48Smrg	    for lib in $dlfiles; do
5706b698ba48Smrg	      name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
5707b698ba48Smrg	      eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
5708b698ba48Smrg	      if test -z "$libdir"; then
5709b698ba48Smrg		$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
5710b698ba48Smrg		exit $EXIT_FAILURE
5711b698ba48Smrg	      fi
5712b698ba48Smrg	      newdlfiles="$newdlfiles $libdir/$name"
5713b698ba48Smrg	    done
5714b698ba48Smrg	    dlfiles="$newdlfiles"
5715b698ba48Smrg	    newdlprefiles=
5716b698ba48Smrg	    for lib in $dlprefiles; do
5717b698ba48Smrg	      name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
5718b698ba48Smrg	      eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
5719b698ba48Smrg	      if test -z "$libdir"; then
5720b698ba48Smrg		$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
5721b698ba48Smrg		exit $EXIT_FAILURE
5722b698ba48Smrg	      fi
5723b698ba48Smrg	      newdlprefiles="$newdlprefiles $libdir/$name"
5724b698ba48Smrg	    done
5725b698ba48Smrg	    dlprefiles="$newdlprefiles"
5726b698ba48Smrg	  else
5727b698ba48Smrg	    newdlfiles=
5728b698ba48Smrg	    for lib in $dlfiles; do
5729b698ba48Smrg	      case $lib in
5730b698ba48Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
5731b698ba48Smrg		*) abs=`pwd`"/$lib" ;;
5732b698ba48Smrg	      esac
5733b698ba48Smrg	      newdlfiles="$newdlfiles $abs"
5734b698ba48Smrg	    done
5735b698ba48Smrg	    dlfiles="$newdlfiles"
5736b698ba48Smrg	    newdlprefiles=
5737b698ba48Smrg	    for lib in $dlprefiles; do
5738b698ba48Smrg	      case $lib in
5739b698ba48Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
5740b698ba48Smrg		*) abs=`pwd`"/$lib" ;;
5741b698ba48Smrg	      esac
5742b698ba48Smrg	      newdlprefiles="$newdlprefiles $abs"
5743b698ba48Smrg	    done
5744b698ba48Smrg	    dlprefiles="$newdlprefiles"
5745b698ba48Smrg	  fi
5746b698ba48Smrg	  $rm $output
5747b698ba48Smrg	  # place dlname in correct position for cygwin
5748b698ba48Smrg	  tdlname=$dlname
5749b698ba48Smrg	  case $host,$output,$installed,$module,$dlname in
5750b698ba48Smrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
5751b698ba48Smrg	  esac
5752b698ba48Smrg	  $echo > $output "\
5753b698ba48Smrg# $outputname - a libtool library file
5754b698ba48Smrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
5755b698ba48Smrg#
5756b698ba48Smrg# Please DO NOT delete this file!
5757b698ba48Smrg# It is necessary for linking the library.
575809885543Smrg
5759b698ba48Smrg# The name that we can dlopen(3).
5760b698ba48Smrgdlname='$tdlname'
576109885543Smrg
5762b698ba48Smrg# Names of this library.
5763b698ba48Smrglibrary_names='$library_names'
576409885543Smrg
5765b698ba48Smrg# The name of the static archive.
5766b698ba48Smrgold_library='$old_library'
576709885543Smrg
5768b698ba48Smrg# Libraries that this one depends upon.
5769b698ba48Smrgdependency_libs='$dependency_libs'
57702ec8c4b4Smrg
5771b698ba48Smrg# Version information for $libname.
5772b698ba48Smrgcurrent=$current
5773b698ba48Smrgage=$age
5774b698ba48Smrgrevision=$revision
57752ec8c4b4Smrg
5776b698ba48Smrg# Is this an already installed library?
5777b698ba48Smrginstalled=$installed
57782ec8c4b4Smrg
5779b698ba48Smrg# Should we warn about portability when linking against -modules?
5780b698ba48Smrgshouldnotlink=$module
57812ec8c4b4Smrg
5782b698ba48Smrg# Files to dlopen/dlpreopen
5783b698ba48Smrgdlopen='$dlfiles'
5784b698ba48Smrgdlpreopen='$dlprefiles'
57852ec8c4b4Smrg
5786b698ba48Smrg# Directory that this library needs to be installed in:
5787b698ba48Smrglibdir='$install_libdir'"
5788b698ba48Smrg	  if test "$installed" = no && test "$need_relink" = yes; then
5789b698ba48Smrg	    $echo >> $output "\
5790b698ba48Smrgrelink_command=\"$relink_command\""
5791b698ba48Smrg	  fi
5792b698ba48Smrg	done
57932ec8c4b4Smrg      fi
57942ec8c4b4Smrg
5795b698ba48Smrg      # Do a symbolic link so that the libtool archive can be found in
5796b698ba48Smrg      # LD_LIBRARY_PATH before the program is installed.
5797b698ba48Smrg      $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)"
5798b698ba48Smrg      $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $?
579909885543Smrg      ;;
5800b698ba48Smrg    esac
5801b698ba48Smrg    exit $EXIT_SUCCESS
5802b698ba48Smrg    ;;
580309885543Smrg
5804b698ba48Smrg  # libtool install mode
5805b698ba48Smrg  install)
5806b698ba48Smrg    modename="$modename: install"
5807b698ba48Smrg
5808b698ba48Smrg    # There may be an optional sh(1) argument at the beginning of
5809b698ba48Smrg    # install_prog (especially on Windows NT).
5810b698ba48Smrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
5811b698ba48Smrg       # Allow the use of GNU shtool's install command.
5812b698ba48Smrg       $echo "X$nonopt" | grep shtool > /dev/null; then
5813b698ba48Smrg      # Aesthetically quote it.
5814b698ba48Smrg      arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"`
5815b698ba48Smrg      case $arg in
5816b698ba48Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
5817b698ba48Smrg	arg="\"$arg\""
5818b698ba48Smrg	;;
58192ec8c4b4Smrg      esac
5820b698ba48Smrg      install_prog="$arg "
5821b698ba48Smrg      arg="$1"
5822b698ba48Smrg      shift
5823b698ba48Smrg    else
5824b698ba48Smrg      install_prog=
5825b698ba48Smrg      arg=$nonopt
5826b698ba48Smrg    fi
582709885543Smrg
5828b698ba48Smrg    # The real first argument should be the name of the installation program.
5829b698ba48Smrg    # Aesthetically quote it.
5830b698ba48Smrg    arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
5831b698ba48Smrg    case $arg in
5832b698ba48Smrg    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
5833b698ba48Smrg      arg="\"$arg\""
5834b698ba48Smrg      ;;
5835b698ba48Smrg    esac
5836b698ba48Smrg    install_prog="$install_prog$arg"
583709885543Smrg
5838b698ba48Smrg    # We need to accept at least all the BSD install flags.
5839b698ba48Smrg    dest=
5840b698ba48Smrg    files=
5841b698ba48Smrg    opts=
5842b698ba48Smrg    prev=
5843b698ba48Smrg    install_type=
5844b698ba48Smrg    isdir=no
5845b698ba48Smrg    stripme=
5846b698ba48Smrg    for arg
5847b698ba48Smrg    do
5848b698ba48Smrg      if test -n "$dest"; then
5849b698ba48Smrg	files="$files $dest"
5850b698ba48Smrg	dest=$arg
5851b698ba48Smrg	continue
5852b698ba48Smrg      fi
58532ec8c4b4Smrg
5854b698ba48Smrg      case $arg in
5855b698ba48Smrg      -d) isdir=yes ;;
5856b698ba48Smrg      -f) 
5857b698ba48Smrg      	case " $install_prog " in
5858b698ba48Smrg	*[\\\ /]cp\ *) ;;
5859b698ba48Smrg	*) prev=$arg ;;
5860b698ba48Smrg	esac
5861b698ba48Smrg	;;
5862b698ba48Smrg      -g | -m | -o) prev=$arg ;;
5863b698ba48Smrg      -s)
5864b698ba48Smrg	stripme=" -s"
5865b698ba48Smrg	continue
5866b698ba48Smrg	;;
5867b698ba48Smrg      -*)
5868b698ba48Smrg	;;
5869b698ba48Smrg      *)
5870b698ba48Smrg	# If the previous option needed an argument, then skip it.
5871b698ba48Smrg	if test -n "$prev"; then
5872b698ba48Smrg	  prev=
5873b698ba48Smrg	else
5874b698ba48Smrg	  dest=$arg
5875b698ba48Smrg	  continue
5876b698ba48Smrg	fi
587709885543Smrg	;;
58782ec8c4b4Smrg      esac
587909885543Smrg
5880b698ba48Smrg      # Aesthetically quote the argument.
5881b698ba48Smrg      arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
5882b698ba48Smrg      case $arg in
5883b698ba48Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
5884b698ba48Smrg	arg="\"$arg\""
58852ec8c4b4Smrg	;;
58862ec8c4b4Smrg      esac
5887b698ba48Smrg      install_prog="$install_prog $arg"
5888b698ba48Smrg    done
588909885543Smrg
5890b698ba48Smrg    if test -z "$install_prog"; then
5891b698ba48Smrg      $echo "$modename: you must specify an install program" 1>&2
5892b698ba48Smrg      $echo "$help" 1>&2
5893b698ba48Smrg      exit $EXIT_FAILURE
5894b698ba48Smrg    fi
589509885543Smrg
5896b698ba48Smrg    if test -n "$prev"; then
5897b698ba48Smrg      $echo "$modename: the \`$prev' option requires an argument" 1>&2
5898b698ba48Smrg      $echo "$help" 1>&2
5899b698ba48Smrg      exit $EXIT_FAILURE
5900b698ba48Smrg    fi
5901b698ba48Smrg
5902b698ba48Smrg    if test -z "$files"; then
5903b698ba48Smrg      if test -z "$dest"; then
5904b698ba48Smrg	$echo "$modename: no file or destination specified" 1>&2
5905b698ba48Smrg      else
5906b698ba48Smrg	$echo "$modename: you must specify a destination" 1>&2
5907b698ba48Smrg      fi
5908b698ba48Smrg      $echo "$help" 1>&2
5909b698ba48Smrg      exit $EXIT_FAILURE
5910b698ba48Smrg    fi
5911b698ba48Smrg
5912b698ba48Smrg    # Strip any trailing slash from the destination.
5913b698ba48Smrg    dest=`$echo "X$dest" | $Xsed -e 's%/$%%'`
5914b698ba48Smrg
5915b698ba48Smrg    # Check to see that the destination is a directory.
5916b698ba48Smrg    test -d "$dest" && isdir=yes
5917b698ba48Smrg    if test "$isdir" = yes; then
5918b698ba48Smrg      destdir="$dest"
5919b698ba48Smrg      destname=
5920b698ba48Smrg    else
5921b698ba48Smrg      destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'`
5922b698ba48Smrg      test "X$destdir" = "X$dest" && destdir=.
5923b698ba48Smrg      destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'`
5924b698ba48Smrg
5925b698ba48Smrg      # Not a directory, so check to see that there is only one file specified.
5926b698ba48Smrg      set dummy $files
5927b698ba48Smrg      if test "$#" -gt 2; then
5928b698ba48Smrg	$echo "$modename: \`$dest' is not a directory" 1>&2
5929b698ba48Smrg	$echo "$help" 1>&2
5930b698ba48Smrg	exit $EXIT_FAILURE
5931b698ba48Smrg      fi
5932b698ba48Smrg    fi
5933b698ba48Smrg    case $destdir in
5934b698ba48Smrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
5935b698ba48Smrg    *)
5936b698ba48Smrg      for file in $files; do
5937b698ba48Smrg	case $file in
5938b698ba48Smrg	*.lo) ;;
59392ec8c4b4Smrg	*)
5940b698ba48Smrg	  $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2
5941b698ba48Smrg	  $echo "$help" 1>&2
5942b698ba48Smrg	  exit $EXIT_FAILURE
59432ec8c4b4Smrg	  ;;
59442ec8c4b4Smrg	esac
59452ec8c4b4Smrg      done
5946b698ba48Smrg      ;;
5947b698ba48Smrg    esac
594809885543Smrg
5949b698ba48Smrg    # This variable tells wrapper scripts just to set variables rather
5950b698ba48Smrg    # than running their programs.
5951b698ba48Smrg    libtool_install_magic="$magic"
595209885543Smrg
5953b698ba48Smrg    staticlibs=
5954b698ba48Smrg    future_libdirs=
5955b698ba48Smrg    current_libdirs=
5956b698ba48Smrg    for file in $files; do
595709885543Smrg
5958b698ba48Smrg      # Do each installation.
5959b698ba48Smrg      case $file in
5960b698ba48Smrg      *.$libext)
5961b698ba48Smrg	# Do the static libraries later.
5962b698ba48Smrg	staticlibs="$staticlibs $file"
5963b698ba48Smrg	;;
5964b698ba48Smrg
5965b698ba48Smrg      *.la)
5966b698ba48Smrg	# Check to see that this really is a libtool archive.
5967b698ba48Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
5968b698ba48Smrg	else
5969b698ba48Smrg	  $echo "$modename: \`$file' is not a valid libtool archive" 1>&2
5970b698ba48Smrg	  $echo "$help" 1>&2
5971b698ba48Smrg	  exit $EXIT_FAILURE
5972b698ba48Smrg	fi
5973b698ba48Smrg
5974b698ba48Smrg	library_names=
5975b698ba48Smrg	old_library=
5976b698ba48Smrg	relink_command=
5977b698ba48Smrg	# If there is no directory component, then add one.
5978b698ba48Smrg	case $file in
5979b698ba48Smrg	*/* | *\\*) . $file ;;
5980b698ba48Smrg	*) . ./$file ;;
5981b698ba48Smrg	esac
5982b698ba48Smrg
5983b698ba48Smrg	# Add the libdir to current_libdirs if it is the destination.
5984b698ba48Smrg	if test "X$destdir" = "X$libdir"; then
5985b698ba48Smrg	  case "$current_libdirs " in
59862ec8c4b4Smrg	  *" $libdir "*) ;;
5987b698ba48Smrg	  *) current_libdirs="$current_libdirs $libdir" ;;
59882ec8c4b4Smrg	  esac
5989b698ba48Smrg	else
5990b698ba48Smrg	  # Note the libdir as a future libdir.
5991b698ba48Smrg	  case "$future_libdirs " in
59922ec8c4b4Smrg	  *" $libdir "*) ;;
5993b698ba48Smrg	  *) future_libdirs="$future_libdirs $libdir" ;;
59942ec8c4b4Smrg	  esac
59952ec8c4b4Smrg	fi
599609885543Smrg
5997b698ba48Smrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/
5998b698ba48Smrg	test "X$dir" = "X$file/" && dir=
5999b698ba48Smrg	dir="$dir$objdir"
6000b698ba48Smrg
6001b698ba48Smrg	if test -n "$relink_command"; then
6002b698ba48Smrg	  # Determine the prefix the user has applied to our future dir.
6003b698ba48Smrg	  inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"`
6004b698ba48Smrg
6005b698ba48Smrg	  # Don't allow the user to place us outside of our expected
6006b698ba48Smrg	  # location b/c this prevents finding dependent libraries that
6007b698ba48Smrg	  # are installed to the same prefix.
6008b698ba48Smrg	  # At present, this check doesn't affect windows .dll's that
6009b698ba48Smrg	  # are installed into $libdir/../bin (currently, that works fine)
6010b698ba48Smrg	  # but it's something to keep an eye on.
6011b698ba48Smrg	  if test "$inst_prefix_dir" = "$destdir"; then
6012b698ba48Smrg	    $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2
6013b698ba48Smrg	    exit $EXIT_FAILURE
6014b698ba48Smrg	  fi
6015b698ba48Smrg
6016b698ba48Smrg	  if test -n "$inst_prefix_dir"; then
6017b698ba48Smrg	    # Stick the inst_prefix_dir data into the link command.
6018b698ba48Smrg	    relink_command=`$echo "$relink_command" | $SP2NL | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%" | $NL2SP`
6019b698ba48Smrg	  else
6020b698ba48Smrg	    relink_command=`$echo "$relink_command" | $SP2NL | $SED "s%@inst_prefix_dir@%%" | $NL2SP`
6021b698ba48Smrg	  fi
6022b698ba48Smrg
6023b698ba48Smrg	  $echo "$modename: warning: relinking \`$file'" 1>&2
6024b698ba48Smrg	  $show "$relink_command"
6025b698ba48Smrg	  if $run eval "$relink_command"; then :
602609885543Smrg	  else
6027b698ba48Smrg	    $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
6028b698ba48Smrg	    exit $EXIT_FAILURE
602909885543Smrg	  fi
603009885543Smrg	fi
603109885543Smrg
6032b698ba48Smrg	# See the names of the shared library.
6033b698ba48Smrg	set dummy $library_names
6034b698ba48Smrg	if test -n "$2"; then
6035b698ba48Smrg	  realname="$2"
6036b698ba48Smrg	  shift
6037b698ba48Smrg	  shift
603809885543Smrg
6039b698ba48Smrg	  srcname="$realname"
6040b698ba48Smrg	  test -n "$relink_command" && srcname="$realname"T
604109885543Smrg
6042b698ba48Smrg	  # Install the shared library and build the symlinks.
6043b698ba48Smrg	  $show "$install_prog $dir/$srcname $destdir/$realname"
6044b698ba48Smrg	  $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $?
6045b698ba48Smrg	  if test -n "$stripme" && test -n "$striplib"; then
6046b698ba48Smrg	    $show "$striplib $destdir/$realname"
6047b698ba48Smrg	    $run eval "$striplib $destdir/$realname" || exit $?
6048b698ba48Smrg	  fi
604909885543Smrg
6050b698ba48Smrg	  if test "$#" -gt 0; then
6051b698ba48Smrg	    # Delete the old symlinks, and create new ones.
6052b698ba48Smrg	    # Try `ln -sf' first, because the `ln' binary might depend on
6053b698ba48Smrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
6054b698ba48Smrg	    # so we also need to try rm && ln -s.
6055b698ba48Smrg	    for linkname
6056b698ba48Smrg	    do
6057b698ba48Smrg	      if test "$linkname" != "$realname"; then
6058b698ba48Smrg                $show "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
6059b698ba48Smrg                $run eval "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
6060b698ba48Smrg	      fi
6061b698ba48Smrg	    done
6062b698ba48Smrg	  fi
606309885543Smrg
6064b698ba48Smrg	  # Do each command in the postinstall commands.
6065b698ba48Smrg	  lib="$destdir/$realname"
6066b698ba48Smrg	  cmds=$postinstall_cmds
6067b698ba48Smrg	  save_ifs="$IFS"; IFS='~'
6068b698ba48Smrg	  for cmd in $cmds; do
6069b698ba48Smrg	    IFS="$save_ifs"
6070b698ba48Smrg	    eval cmd=\"$cmd\"
6071b698ba48Smrg	    $show "$cmd"
6072b698ba48Smrg	    $run eval "$cmd" || {
6073b698ba48Smrg	      lt_exit=$?
6074b698ba48Smrg
6075b698ba48Smrg	      # Restore the uninstalled library and exit
6076b698ba48Smrg	      if test "$mode" = relink; then
6077b698ba48Smrg		$run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
6078b698ba48Smrg	      fi
607909885543Smrg
6080b698ba48Smrg	      exit $lt_exit
6081b698ba48Smrg	    }
6082b698ba48Smrg	  done
6083b698ba48Smrg	  IFS="$save_ifs"
608409885543Smrg	fi
608509885543Smrg
6086b698ba48Smrg	# Install the pseudo-library for information purposes.
6087b698ba48Smrg	name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
6088b698ba48Smrg	instname="$dir/$name"i
6089b698ba48Smrg	$show "$install_prog $instname $destdir/$name"
6090b698ba48Smrg	$run eval "$install_prog $instname $destdir/$name" || exit $?
609109885543Smrg
6092b698ba48Smrg	# Maybe install the static library, too.
6093b698ba48Smrg	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
6094b698ba48Smrg	;;
609509885543Smrg
6096b698ba48Smrg      *.lo)
6097b698ba48Smrg	# Install (i.e. copy) a libtool object.
6098b698ba48Smrg
6099b698ba48Smrg	# Figure out destination file name, if it wasn't already specified.
6100b698ba48Smrg	if test -n "$destname"; then
6101b698ba48Smrg	  destfile="$destdir/$destname"
6102b698ba48Smrg	else
6103b698ba48Smrg	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
6104b698ba48Smrg	  destfile="$destdir/$destfile"
610509885543Smrg	fi
6106b698ba48Smrg
6107b698ba48Smrg	# Deduce the name of the destination old-style object file.
6108b698ba48Smrg	case $destfile in
6109b698ba48Smrg	*.lo)
6110b698ba48Smrg	  staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"`
6111b698ba48Smrg	  ;;
6112b698ba48Smrg	*.$objext)
6113b698ba48Smrg	  staticdest="$destfile"
6114b698ba48Smrg	  destfile=
6115b698ba48Smrg	  ;;
6116b698ba48Smrg	*)
6117b698ba48Smrg	  $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2
6118b698ba48Smrg	  $echo "$help" 1>&2
6119b698ba48Smrg	  exit $EXIT_FAILURE
6120b698ba48Smrg	  ;;
6121b698ba48Smrg	esac
6122b698ba48Smrg
6123b698ba48Smrg	# Install the libtool object if requested.
6124b698ba48Smrg	if test -n "$destfile"; then
6125b698ba48Smrg	  $show "$install_prog $file $destfile"
6126b698ba48Smrg	  $run eval "$install_prog $file $destfile" || exit $?
612709885543Smrg	fi
612809885543Smrg
6129b698ba48Smrg	# Install the old object if enabled.
6130b698ba48Smrg	if test "$build_old_libs" = yes; then
6131b698ba48Smrg	  # Deduce the name of the old-style object file.
6132b698ba48Smrg	  staticobj=`$echo "X$file" | $Xsed -e "$lo2o"`
613309885543Smrg
6134b698ba48Smrg	  $show "$install_prog $staticobj $staticdest"
6135b698ba48Smrg	  $run eval "$install_prog \$staticobj \$staticdest" || exit $?
6136b698ba48Smrg	fi
6137b698ba48Smrg	exit $EXIT_SUCCESS
6138b698ba48Smrg	;;
61392ec8c4b4Smrg
6140b698ba48Smrg      *)
6141b698ba48Smrg	# Figure out destination file name, if it wasn't already specified.
6142b698ba48Smrg	if test -n "$destname"; then
6143b698ba48Smrg	  destfile="$destdir/$destname"
614409885543Smrg	else
6145b698ba48Smrg	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
6146b698ba48Smrg	  destfile="$destdir/$destfile"
614709885543Smrg	fi
614809885543Smrg
6149b698ba48Smrg	# If the file is missing, and there is a .exe on the end, strip it
6150b698ba48Smrg	# because it is most likely a libtool script we actually want to
6151b698ba48Smrg	# install
6152b698ba48Smrg	stripped_ext=""
6153b698ba48Smrg	case $file in
6154b698ba48Smrg	  *.exe)
6155b698ba48Smrg	    if test ! -f "$file"; then
6156b698ba48Smrg	      file=`$echo $file|${SED} 's,.exe$,,'`
6157b698ba48Smrg	      stripped_ext=".exe"
6158b698ba48Smrg	    fi
6159b698ba48Smrg	    ;;
6160b698ba48Smrg	esac
616109885543Smrg
6162b698ba48Smrg	# Do a test to see if this is really a libtool program.
6163b698ba48Smrg	case $host in
6164b698ba48Smrg	*cygwin*|*mingw*)
6165b698ba48Smrg	    wrapper=`$echo $file | ${SED} -e 's,.exe$,,'`
6166b698ba48Smrg	    ;;
6167b698ba48Smrg	*)
6168b698ba48Smrg	    wrapper=$file
6169b698ba48Smrg	    ;;
6170b698ba48Smrg	esac
6171b698ba48Smrg	if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then
6172b698ba48Smrg	  notinst_deplibs=
6173b698ba48Smrg	  relink_command=
617409885543Smrg
6175b698ba48Smrg	  # Note that it is not necessary on cygwin/mingw to append a dot to
6176b698ba48Smrg	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
6177b698ba48Smrg	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
6178b698ba48Smrg	  # `FILE.' does not work on cygwin managed mounts.
6179b698ba48Smrg	  #
6180b698ba48Smrg	  # If there is no directory component, then add one.
6181b698ba48Smrg	  case $wrapper in
6182b698ba48Smrg	  */* | *\\*) . ${wrapper} ;;
6183b698ba48Smrg	  *) . ./${wrapper} ;;
6184b698ba48Smrg	  esac
618509885543Smrg
6186b698ba48Smrg	  # Check the variables that should have been set.
6187b698ba48Smrg	  if test -z "$notinst_deplibs"; then
6188b698ba48Smrg	    $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2
6189b698ba48Smrg	    exit $EXIT_FAILURE
6190b698ba48Smrg	  fi
619109885543Smrg
6192b698ba48Smrg	  finalize=yes
6193b698ba48Smrg	  for lib in $notinst_deplibs; do
6194b698ba48Smrg	    # Check to see that each library is installed.
6195b698ba48Smrg	    libdir=
6196b698ba48Smrg	    if test -f "$lib"; then
6197b698ba48Smrg	      # If there is no directory component, then add one.
6198b698ba48Smrg	      case $lib in
6199b698ba48Smrg	      */* | *\\*) . $lib ;;
6200b698ba48Smrg	      *) . ./$lib ;;
6201b698ba48Smrg	      esac
6202b698ba48Smrg	    fi
6203b698ba48Smrg	    libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
6204b698ba48Smrg	    if test -n "$libdir" && test ! -f "$libfile"; then
6205b698ba48Smrg	      $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2
6206b698ba48Smrg	      finalize=no
6207b698ba48Smrg	    fi
6208b698ba48Smrg	  done
6209b698ba48Smrg
6210b698ba48Smrg	  relink_command=
6211b698ba48Smrg	  # Note that it is not necessary on cygwin/mingw to append a dot to
6212b698ba48Smrg	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
6213b698ba48Smrg	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
6214b698ba48Smrg	  # `FILE.' does not work on cygwin managed mounts.
6215b698ba48Smrg	  #
6216b698ba48Smrg	  # If there is no directory component, then add one.
6217b698ba48Smrg	  case $wrapper in
6218b698ba48Smrg	  */* | *\\*) . ${wrapper} ;;
6219b698ba48Smrg	  *) . ./${wrapper} ;;
6220b698ba48Smrg	  esac
6221b698ba48Smrg
6222b698ba48Smrg	  outputname=
6223b698ba48Smrg	  if test "$fast_install" = no && test -n "$relink_command"; then
6224b698ba48Smrg	    if test "$finalize" = yes && test -z "$run"; then
6225b698ba48Smrg	      tmpdir=`func_mktempdir`
6226b698ba48Smrg	      file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
6227b698ba48Smrg	      outputname="$tmpdir/$file"
6228b698ba48Smrg	      # Replace the output file specification.
6229b698ba48Smrg	      relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g' | $NL2SP`
6230b698ba48Smrg
6231b698ba48Smrg	      $show "$relink_command"
6232b698ba48Smrg	      if $run eval "$relink_command"; then :
6233b698ba48Smrg	      else
6234b698ba48Smrg		$echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
6235b698ba48Smrg		${rm}r "$tmpdir"
6236b698ba48Smrg		continue
6237b698ba48Smrg	      fi
6238b698ba48Smrg	      file="$outputname"
6239b698ba48Smrg	    else
6240b698ba48Smrg	      $echo "$modename: warning: cannot relink \`$file'" 1>&2
6241b698ba48Smrg	    fi
624209885543Smrg	  else
6243b698ba48Smrg	    # Install the binary that we compiled earlier.
6244b698ba48Smrg	    file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
624509885543Smrg	  fi
6246b698ba48Smrg	fi
62472ec8c4b4Smrg
6248b698ba48Smrg	# remove .exe since cygwin /usr/bin/install will append another
6249b698ba48Smrg	# one anyway 
6250b698ba48Smrg	case $install_prog,$host in
6251b698ba48Smrg	*/usr/bin/install*,*cygwin*)
6252b698ba48Smrg	  case $file:$destfile in
6253b698ba48Smrg	  *.exe:*.exe)
6254b698ba48Smrg	    # this is ok
6255b698ba48Smrg	    ;;
6256b698ba48Smrg	  *.exe:*)
6257b698ba48Smrg	    destfile=$destfile.exe
6258b698ba48Smrg	    ;;
6259b698ba48Smrg	  *:*.exe)
6260b698ba48Smrg	    destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'`
6261b698ba48Smrg	    ;;
6262b698ba48Smrg	  esac
6263b698ba48Smrg	  ;;
626409885543Smrg	esac
6265b698ba48Smrg	$show "$install_prog$stripme $file $destfile"
6266b698ba48Smrg	$run eval "$install_prog\$stripme \$file \$destfile" || exit $?
6267b698ba48Smrg	test -n "$outputname" && ${rm}r "$tmpdir"
6268b698ba48Smrg	;;
6269b698ba48Smrg      esac
6270b698ba48Smrg    done
627109885543Smrg
6272b698ba48Smrg    for file in $staticlibs; do
6273b698ba48Smrg      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
627409885543Smrg
6275b698ba48Smrg      # Set up the ranlib parameters.
6276b698ba48Smrg      oldlib="$destdir/$name"
627709885543Smrg
6278b698ba48Smrg      $show "$install_prog $file $oldlib"
6279b698ba48Smrg      $run eval "$install_prog \$file \$oldlib" || exit $?
628009885543Smrg
6281b698ba48Smrg      if test -n "$stripme" && test -n "$old_striplib"; then
6282b698ba48Smrg	$show "$old_striplib $oldlib"
6283b698ba48Smrg	$run eval "$old_striplib $oldlib" || exit $?
628409885543Smrg      fi
628509885543Smrg
6286b698ba48Smrg      # Do each command in the postinstall commands.
6287b698ba48Smrg      cmds=$old_postinstall_cmds
6288b698ba48Smrg      save_ifs="$IFS"; IFS='~'
6289b698ba48Smrg      for cmd in $cmds; do
6290b698ba48Smrg	IFS="$save_ifs"
6291b698ba48Smrg	eval cmd=\"$cmd\"
6292b698ba48Smrg	$show "$cmd"
6293b698ba48Smrg	$run eval "$cmd" || exit $?
6294b698ba48Smrg      done
6295b698ba48Smrg      IFS="$save_ifs"
6296b698ba48Smrg    done
629709885543Smrg
6298b698ba48Smrg    if test -n "$future_libdirs"; then
6299b698ba48Smrg      $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2
6300b698ba48Smrg    fi
630109885543Smrg
6302b698ba48Smrg    if test -n "$current_libdirs"; then
6303b698ba48Smrg      # Maybe just do a dry run.
6304b698ba48Smrg      test -n "$run" && current_libdirs=" -n$current_libdirs"
6305b698ba48Smrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
6306b698ba48Smrg    else
6307b698ba48Smrg      exit $EXIT_SUCCESS
6308b698ba48Smrg    fi
6309b698ba48Smrg    ;;
631009885543Smrg
6311b698ba48Smrg  # libtool finish mode
6312b698ba48Smrg  finish)
6313b698ba48Smrg    modename="$modename: finish"
6314b698ba48Smrg    libdirs="$nonopt"
6315b698ba48Smrg    admincmds=
631609885543Smrg
6317b698ba48Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
6318b698ba48Smrg      for dir
6319b698ba48Smrg      do
6320b698ba48Smrg	libdirs="$libdirs $dir"
6321b698ba48Smrg      done
632209885543Smrg
6323b698ba48Smrg      for libdir in $libdirs; do
6324b698ba48Smrg	if test -n "$finish_cmds"; then
6325b698ba48Smrg	  # Do each command in the finish commands.
6326b698ba48Smrg	  cmds=$finish_cmds
6327b698ba48Smrg	  save_ifs="$IFS"; IFS='~'
6328b698ba48Smrg	  for cmd in $cmds; do
6329b698ba48Smrg	    IFS="$save_ifs"
6330b698ba48Smrg	    eval cmd=\"$cmd\"
6331b698ba48Smrg	    $show "$cmd"
6332b698ba48Smrg	    $run eval "$cmd" || admincmds="$admincmds
6333b698ba48Smrg       $cmd"
633409885543Smrg	  done
6335b698ba48Smrg	  IFS="$save_ifs"
633609885543Smrg	fi
6337b698ba48Smrg	if test -n "$finish_eval"; then
6338b698ba48Smrg	  # Do the single finish_eval.
6339b698ba48Smrg	  eval cmds=\"$finish_eval\"
6340b698ba48Smrg	  $run eval "$cmds" || admincmds="$admincmds
6341b698ba48Smrg       $cmds"
63422ec8c4b4Smrg	fi
6343b698ba48Smrg      done
6344b698ba48Smrg    fi
6345b698ba48Smrg
6346b698ba48Smrg    # Exit here if they wanted silent mode.
6347b698ba48Smrg    test "$show" = : && exit $EXIT_SUCCESS
6348b698ba48Smrg
6349b698ba48Smrg    $echo "X----------------------------------------------------------------------" | $Xsed
6350b698ba48Smrg    $echo "Libraries have been installed in:"
6351b698ba48Smrg    for libdir in $libdirs; do
6352b698ba48Smrg      $echo "   $libdir"
635309885543Smrg    done
6354b698ba48Smrg    $echo
6355b698ba48Smrg    $echo "If you ever happen to want to link against installed libraries"
6356b698ba48Smrg    $echo "in a given directory, LIBDIR, you must either use libtool, and"
6357b698ba48Smrg    $echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
6358b698ba48Smrg    $echo "flag during linking and do at least one of the following:"
6359b698ba48Smrg    if test -n "$shlibpath_var"; then
6360b698ba48Smrg      $echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
6361b698ba48Smrg      $echo "     during execution"
6362b698ba48Smrg    fi
6363b698ba48Smrg    if test -n "$runpath_var"; then
6364b698ba48Smrg      $echo "   - add LIBDIR to the \`$runpath_var' environment variable"
6365b698ba48Smrg      $echo "     during linking"
6366b698ba48Smrg    fi
6367b698ba48Smrg    if test -n "$hardcode_libdir_flag_spec"; then
6368b698ba48Smrg      libdir=LIBDIR
6369b698ba48Smrg      eval flag=\"$hardcode_libdir_flag_spec\"
637009885543Smrg
6371b698ba48Smrg      $echo "   - use the \`$flag' linker flag"
6372b698ba48Smrg    fi
6373b698ba48Smrg    if test -n "$admincmds"; then
6374b698ba48Smrg      $echo "   - have your system administrator run these commands:$admincmds"
6375b698ba48Smrg    fi
6376b698ba48Smrg    if test -f /etc/ld.so.conf; then
6377b698ba48Smrg      $echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
6378b698ba48Smrg    fi
6379b698ba48Smrg    $echo
6380b698ba48Smrg    $echo "See any operating system documentation about shared libraries for"
6381b698ba48Smrg    $echo "more information, such as the ld(1) and ld.so(8) manual pages."
6382b698ba48Smrg    $echo "X----------------------------------------------------------------------" | $Xsed
6383b698ba48Smrg    exit $EXIT_SUCCESS
6384b698ba48Smrg    ;;
638509885543Smrg
6386b698ba48Smrg  # libtool execute mode
6387b698ba48Smrg  execute)
6388b698ba48Smrg    modename="$modename: execute"
638909885543Smrg
6390b698ba48Smrg    # The first argument is the command name.
6391b698ba48Smrg    cmd="$nonopt"
6392b698ba48Smrg    if test -z "$cmd"; then
6393b698ba48Smrg      $echo "$modename: you must specify a COMMAND" 1>&2
6394b698ba48Smrg      $echo "$help"
6395b698ba48Smrg      exit $EXIT_FAILURE
6396b698ba48Smrg    fi
639709885543Smrg
6398b698ba48Smrg    # Handle -dlopen flags immediately.
6399b698ba48Smrg    for file in $execute_dlfiles; do
6400b698ba48Smrg      if test ! -f "$file"; then
6401b698ba48Smrg	$echo "$modename: \`$file' is not a file" 1>&2
6402b698ba48Smrg	$echo "$help" 1>&2
6403b698ba48Smrg	exit $EXIT_FAILURE
6404b698ba48Smrg      fi
64052ec8c4b4Smrg
6406b698ba48Smrg      dir=
6407b698ba48Smrg      case $file in
6408b698ba48Smrg      *.la)
6409b698ba48Smrg	# Check to see that this really is a libtool archive.
6410b698ba48Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
6411b698ba48Smrg	else
6412b698ba48Smrg	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
6413b698ba48Smrg	  $echo "$help" 1>&2
6414b698ba48Smrg	  exit $EXIT_FAILURE
6415b698ba48Smrg	fi
641609885543Smrg
6417b698ba48Smrg	# Read the libtool library.
6418b698ba48Smrg	dlname=
6419b698ba48Smrg	library_names=
642009885543Smrg
6421b698ba48Smrg	# If there is no directory component, then add one.
6422b698ba48Smrg	case $file in
6423b698ba48Smrg	*/* | *\\*) . $file ;;
6424b698ba48Smrg	*) . ./$file ;;
6425b698ba48Smrg	esac
642609885543Smrg
6427b698ba48Smrg	# Skip this library if it cannot be dlopened.
6428b698ba48Smrg	if test -z "$dlname"; then
6429b698ba48Smrg	  # Warn if it was a shared library.
6430b698ba48Smrg	  test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'"
6431b698ba48Smrg	  continue
6432b698ba48Smrg	fi
643309885543Smrg
6434b698ba48Smrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
6435b698ba48Smrg	test "X$dir" = "X$file" && dir=.
643609885543Smrg
6437b698ba48Smrg	if test -f "$dir/$objdir/$dlname"; then
6438b698ba48Smrg	  dir="$dir/$objdir"
6439b698ba48Smrg	else
6440b698ba48Smrg	  if test ! -f "$dir/$dlname"; then
6441b698ba48Smrg	    $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
6442b698ba48Smrg	    exit $EXIT_FAILURE
6443b698ba48Smrg	  fi
6444b698ba48Smrg	fi
6445b698ba48Smrg	;;
644609885543Smrg
6447b698ba48Smrg      *.lo)
6448b698ba48Smrg	# Just add the directory containing the .lo file.
6449b698ba48Smrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
6450b698ba48Smrg	test "X$dir" = "X$file" && dir=.
6451b698ba48Smrg	;;
645209885543Smrg
6453b698ba48Smrg      *)
6454b698ba48Smrg	$echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2
6455b698ba48Smrg	continue
6456b698ba48Smrg	;;
6457b698ba48Smrg      esac
645809885543Smrg
6459b698ba48Smrg      # Get the absolute pathname.
6460b698ba48Smrg      absdir=`cd "$dir" && pwd`
6461b698ba48Smrg      test -n "$absdir" && dir="$absdir"
646209885543Smrg
6463b698ba48Smrg      # Now add the directory to shlibpath_var.
6464b698ba48Smrg      if eval "test -z \"\$$shlibpath_var\""; then
6465b698ba48Smrg	eval "$shlibpath_var=\"\$dir\""
6466b698ba48Smrg      else
6467b698ba48Smrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
6468b698ba48Smrg      fi
6469b698ba48Smrg    done
647009885543Smrg
6471b698ba48Smrg    # This variable tells wrapper scripts just to set shlibpath_var
6472b698ba48Smrg    # rather than running their programs.
6473b698ba48Smrg    libtool_execute_magic="$magic"
647409885543Smrg
6475b698ba48Smrg    # Check if any of the arguments is a wrapper script.
6476b698ba48Smrg    args=
6477b698ba48Smrg    for file
6478b698ba48Smrg    do
6479b698ba48Smrg      case $file in
6480b698ba48Smrg      -*) ;;
6481b698ba48Smrg      *)
6482b698ba48Smrg	# Do a test to see if this is really a libtool program.
6483b698ba48Smrg	if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
6484b698ba48Smrg	  # If there is no directory component, then add one.
6485b698ba48Smrg	  case $file in
6486b698ba48Smrg	  */* | *\\*) . $file ;;
6487b698ba48Smrg	  *) . ./$file ;;
6488b698ba48Smrg	  esac
648909885543Smrg
6490b698ba48Smrg	  # Transform arg to wrapped name.
6491b698ba48Smrg	  file="$progdir/$program"
6492b698ba48Smrg	fi
6493b698ba48Smrg	;;
6494b698ba48Smrg      esac
6495b698ba48Smrg      # Quote arguments (to preserve shell metacharacters).
6496b698ba48Smrg      file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"`
6497b698ba48Smrg      args="$args \"$file\""
6498b698ba48Smrg    done
649909885543Smrg
6500b698ba48Smrg    if test -z "$run"; then
6501b698ba48Smrg      if test -n "$shlibpath_var"; then
6502b698ba48Smrg	# Export the shlibpath_var.
6503b698ba48Smrg	eval "export $shlibpath_var"
6504b698ba48Smrg      fi
6505b698ba48Smrg
6506b698ba48Smrg      # Restore saved environment variables
6507b698ba48Smrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
6508b698ba48Smrg      do
6509b698ba48Smrg	eval "if test \"\${save_$lt_var+set}\" = set; then
6510b698ba48Smrg		$lt_var=\$save_$lt_var; export $lt_var
6511b698ba48Smrg	      fi"
6512b698ba48Smrg      done
651309885543Smrg
6514b698ba48Smrg      # Now prepare to actually exec the command.
6515b698ba48Smrg      exec_cmd="\$cmd$args"
6516b698ba48Smrg    else
6517b698ba48Smrg      # Display what would be done.
6518b698ba48Smrg      if test -n "$shlibpath_var"; then
6519b698ba48Smrg	eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\""
6520b698ba48Smrg	$echo "export $shlibpath_var"
6521b698ba48Smrg      fi
6522b698ba48Smrg      $echo "$cmd$args"
6523b698ba48Smrg      exit $EXIT_SUCCESS
6524b698ba48Smrg    fi
6525b698ba48Smrg    ;;
652609885543Smrg
6527b698ba48Smrg  # libtool clean and uninstall mode
6528b698ba48Smrg  clean | uninstall)
6529b698ba48Smrg    modename="$modename: $mode"
6530b698ba48Smrg    rm="$nonopt"
653109885543Smrg    files=
653209885543Smrg    rmforce=
653309885543Smrg    exit_status=0
653409885543Smrg
653509885543Smrg    # This variable tells wrapper scripts just to set variables rather
653609885543Smrg    # than running their programs.
653709885543Smrg    libtool_install_magic="$magic"
653809885543Smrg
653909885543Smrg    for arg
654009885543Smrg    do
654109885543Smrg      case $arg in
6542b698ba48Smrg      -f) rm="$rm $arg"; rmforce=yes ;;
6543b698ba48Smrg      -*) rm="$rm $arg" ;;
654409885543Smrg      *) files="$files $arg" ;;
654509885543Smrg      esac
654609885543Smrg    done
654709885543Smrg
6548b698ba48Smrg    if test -z "$rm"; then
6549b698ba48Smrg      $echo "$modename: you must specify an RM program" 1>&2
6550b698ba48Smrg      $echo "$help" 1>&2
6551b698ba48Smrg      exit $EXIT_FAILURE
6552b698ba48Smrg    fi
655309885543Smrg
655409885543Smrg    rmdirs=
655509885543Smrg
655609885543Smrg    origobjdir="$objdir"
655709885543Smrg    for file in $files; do
6558b698ba48Smrg      dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
6559b698ba48Smrg      if test "X$dir" = "X$file"; then
6560b698ba48Smrg	dir=.
656109885543Smrg	objdir="$origobjdir"
656209885543Smrg      else
656309885543Smrg	objdir="$dir/$origobjdir"
656409885543Smrg      fi
6565b698ba48Smrg      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
656609885543Smrg      test "$mode" = uninstall && objdir="$dir"
656709885543Smrg
656809885543Smrg      # Remember objdir for removal later, being careful to avoid duplicates
656909885543Smrg      if test "$mode" = clean; then
657009885543Smrg	case " $rmdirs " in
657109885543Smrg	  *" $objdir "*) ;;
657209885543Smrg	  *) rmdirs="$rmdirs $objdir" ;;
657309885543Smrg	esac
657409885543Smrg      fi
657509885543Smrg
657609885543Smrg      # Don't error if the file doesn't exist and rm -f was used.
6577b698ba48Smrg      if (test -L "$file") >/dev/null 2>&1 \
6578b698ba48Smrg	|| (test -h "$file") >/dev/null 2>&1 \
6579b698ba48Smrg	|| test -f "$file"; then
658009885543Smrg	:
658109885543Smrg      elif test -d "$file"; then
658209885543Smrg	exit_status=1
658309885543Smrg	continue
658409885543Smrg      elif test "$rmforce" = yes; then
658509885543Smrg	continue
658609885543Smrg      fi
658709885543Smrg
658809885543Smrg      rmfiles="$file"
658909885543Smrg
659009885543Smrg      case $name in
659109885543Smrg      *.la)
659209885543Smrg	# Possibly a libtool archive, so verify it.
6593b698ba48Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
6594b698ba48Smrg	  . $dir/$name
659509885543Smrg
659609885543Smrg	  # Delete the libtool libraries and symlinks.
659709885543Smrg	  for n in $library_names; do
659809885543Smrg	    rmfiles="$rmfiles $objdir/$n"
659909885543Smrg	  done
660009885543Smrg	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
660109885543Smrg
660209885543Smrg	  case "$mode" in
660309885543Smrg	  clean)
660409885543Smrg	    case "  $library_names " in
660509885543Smrg	    # "  " in the beginning catches empty $dlname
660609885543Smrg	    *" $dlname "*) ;;
660709885543Smrg	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
660809885543Smrg	    esac
6609b698ba48Smrg	     test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
661009885543Smrg	    ;;
661109885543Smrg	  uninstall)
661209885543Smrg	    if test -n "$library_names"; then
661309885543Smrg	      # Do each command in the postuninstall commands.
6614b698ba48Smrg	      cmds=$postuninstall_cmds
6615b698ba48Smrg	      save_ifs="$IFS"; IFS='~'
6616b698ba48Smrg	      for cmd in $cmds; do
6617b698ba48Smrg		IFS="$save_ifs"
6618b698ba48Smrg		eval cmd=\"$cmd\"
6619b698ba48Smrg		$show "$cmd"
6620b698ba48Smrg		$run eval "$cmd"
6621b698ba48Smrg		if test "$?" -ne 0 && test "$rmforce" != yes; then
6622b698ba48Smrg		  exit_status=1
6623b698ba48Smrg		fi
6624b698ba48Smrg	      done
6625b698ba48Smrg	      IFS="$save_ifs"
662609885543Smrg	    fi
662709885543Smrg
662809885543Smrg	    if test -n "$old_library"; then
662909885543Smrg	      # Do each command in the old_postuninstall commands.
6630b698ba48Smrg	      cmds=$old_postuninstall_cmds
6631b698ba48Smrg	      save_ifs="$IFS"; IFS='~'
6632b698ba48Smrg	      for cmd in $cmds; do
6633b698ba48Smrg		IFS="$save_ifs"
6634b698ba48Smrg		eval cmd=\"$cmd\"
6635b698ba48Smrg		$show "$cmd"
6636b698ba48Smrg		$run eval "$cmd"
6637b698ba48Smrg		if test "$?" -ne 0 && test "$rmforce" != yes; then
6638b698ba48Smrg		  exit_status=1
6639b698ba48Smrg		fi
6640b698ba48Smrg	      done
6641b698ba48Smrg	      IFS="$save_ifs"
664209885543Smrg	    fi
664309885543Smrg	    # FIXME: should reinstall the best remaining shared library.
664409885543Smrg	    ;;
664509885543Smrg	  esac
664609885543Smrg	fi
664709885543Smrg	;;
664809885543Smrg
664909885543Smrg      *.lo)
665009885543Smrg	# Possibly a libtool object, so verify it.
6651b698ba48Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
665209885543Smrg
665309885543Smrg	  # Read the .lo file
6654b698ba48Smrg	  . $dir/$name
665509885543Smrg
665609885543Smrg	  # Add PIC object to the list of files to remove.
6657b698ba48Smrg	  if test -n "$pic_object" \
6658b698ba48Smrg	     && test "$pic_object" != none; then
665909885543Smrg	    rmfiles="$rmfiles $dir/$pic_object"
666009885543Smrg	  fi
666109885543Smrg
666209885543Smrg	  # Add non-PIC object to the list of files to remove.
6663b698ba48Smrg	  if test -n "$non_pic_object" \
6664b698ba48Smrg	     && test "$non_pic_object" != none; then
666509885543Smrg	    rmfiles="$rmfiles $dir/$non_pic_object"
666609885543Smrg	  fi
666709885543Smrg	fi
666809885543Smrg	;;
666909885543Smrg
667009885543Smrg      *)
667109885543Smrg	if test "$mode" = clean ; then
667209885543Smrg	  noexename=$name
667309885543Smrg	  case $file in
667409885543Smrg	  *.exe)
6675b698ba48Smrg	    file=`$echo $file|${SED} 's,.exe$,,'`
6676b698ba48Smrg	    noexename=`$echo $name|${SED} 's,.exe$,,'`
667709885543Smrg	    # $file with .exe has already been added to rmfiles,
667809885543Smrg	    # add $file without .exe
667909885543Smrg	    rmfiles="$rmfiles $file"
668009885543Smrg	    ;;
668109885543Smrg	  esac
668209885543Smrg	  # Do a test to see if this is a libtool program.
6683b698ba48Smrg	  if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
6684b698ba48Smrg	    relink_command=
6685b698ba48Smrg	    . $dir/$noexename
668609885543Smrg
668709885543Smrg	    # note $name still contains .exe if it was in $file originally
668809885543Smrg	    # as does the version of $file that was added into $rmfiles
668909885543Smrg	    rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
669009885543Smrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
669109885543Smrg	      rmfiles="$rmfiles $objdir/lt-$name"
669209885543Smrg	    fi
669309885543Smrg	    if test "X$noexename" != "X$name" ; then
669409885543Smrg	      rmfiles="$rmfiles $objdir/lt-${noexename}.c"
669509885543Smrg	    fi
669609885543Smrg	  fi
669709885543Smrg	fi
669809885543Smrg	;;
669909885543Smrg      esac
6700b698ba48Smrg      $show "$rm $rmfiles"
6701b698ba48Smrg      $run $rm $rmfiles || exit_status=1
670209885543Smrg    done
670309885543Smrg    objdir="$origobjdir"
670409885543Smrg
670509885543Smrg    # Try to remove the ${objdir}s in the directories where we deleted files
670609885543Smrg    for dir in $rmdirs; do
670709885543Smrg      if test -d "$dir"; then
6708b698ba48Smrg	$show "rmdir $dir"
6709b698ba48Smrg	$run rmdir $dir >/dev/null 2>&1
671009885543Smrg      fi
671109885543Smrg    done
671209885543Smrg
671309885543Smrg    exit $exit_status
6714b698ba48Smrg    ;;
671509885543Smrg
6716b698ba48Smrg  "")
6717b698ba48Smrg    $echo "$modename: you must specify a MODE" 1>&2
6718b698ba48Smrg    $echo "$generic_help" 1>&2
6719b698ba48Smrg    exit $EXIT_FAILURE
6720b698ba48Smrg    ;;
6721b698ba48Smrg  esac
67222ec8c4b4Smrg
6723b698ba48Smrg  if test -z "$exec_cmd"; then
6724b698ba48Smrg    $echo "$modename: invalid operation mode \`$mode'" 1>&2
6725b698ba48Smrg    $echo "$generic_help" 1>&2
6726b698ba48Smrg    exit $EXIT_FAILURE
6727b698ba48Smrg  fi
6728b698ba48Smrgfi # test -z "$show_help"
672909885543Smrg
673009885543Smrgif test -n "$exec_cmd"; then
6731b698ba48Smrg  eval exec $exec_cmd
673209885543Smrg  exit $EXIT_FAILURE
673309885543Smrgfi
673409885543Smrg
6735b698ba48Smrg# We need to display help for each of the modes.
6736b698ba48Smrgcase $mode in
6737b698ba48Smrg"") $echo \
6738b698ba48Smrg"Usage: $modename [OPTION]... [MODE-ARG]...
6739b698ba48Smrg
6740b698ba48SmrgProvide generalized library-building support services.
6741b698ba48Smrg
6742b698ba48Smrg    --config          show all configuration variables
6743b698ba48Smrg    --debug           enable verbose shell tracing
6744b698ba48Smrg-n, --dry-run         display commands without modifying any files
6745b698ba48Smrg    --features        display basic configuration information and exit
6746b698ba48Smrg    --finish          same as \`--mode=finish'
6747b698ba48Smrg    --help            display this help message and exit
6748b698ba48Smrg    --mode=MODE       use operation mode MODE [default=inferred from MODE-ARGS]
6749b698ba48Smrg    --quiet           same as \`--silent'
6750b698ba48Smrg    --silent          don't print informational messages
6751b698ba48Smrg    --tag=TAG         use configuration variables from tag TAG
6752b698ba48Smrg    --version         print version information
6753b698ba48Smrg
6754b698ba48SmrgMODE must be one of the following:
6755b698ba48Smrg
6756b698ba48Smrg      clean           remove files from the build directory
6757b698ba48Smrg      compile         compile a source file into a libtool object
6758b698ba48Smrg      execute         automatically set library path, then run a program
6759b698ba48Smrg      finish          complete the installation of libtool libraries
6760b698ba48Smrg      install         install libraries or executables
6761b698ba48Smrg      link            create a library or an executable
6762b698ba48Smrg      uninstall       remove libraries from an installed directory
6763b698ba48Smrg
6764b698ba48SmrgMODE-ARGS vary depending on the MODE.  Try \`$modename --help --mode=MODE' for
6765b698ba48Smrga more detailed description of MODE.
6766b698ba48Smrg
6767b698ba48SmrgReport bugs to <bug-libtool@gnu.org>."
6768b698ba48Smrg  exit $EXIT_SUCCESS
6769b698ba48Smrg  ;;
6770b698ba48Smrg
6771b698ba48Smrgclean)
6772b698ba48Smrg  $echo \
6773b698ba48Smrg"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
6774b698ba48Smrg
6775b698ba48SmrgRemove files from the build directory.
6776b698ba48Smrg
6777b698ba48SmrgRM is the name of the program to use to delete files associated with each FILE
6778b698ba48Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
6779b698ba48Smrgto RM.
6780b698ba48Smrg
6781b698ba48SmrgIf FILE is a libtool library, object or program, all the files associated
6782b698ba48Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
6783b698ba48Smrg  ;;
6784b698ba48Smrg
6785b698ba48Smrgcompile)
6786b698ba48Smrg  $echo \
6787b698ba48Smrg"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
6788b698ba48Smrg
6789b698ba48SmrgCompile a source file into a libtool library object.
6790b698ba48Smrg
6791b698ba48SmrgThis mode accepts the following additional options:
6792b698ba48Smrg
6793b698ba48Smrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
6794b698ba48Smrg  -prefer-pic       try to building PIC objects only
6795b698ba48Smrg  -prefer-non-pic   try to building non-PIC objects only
6796b698ba48Smrg  -static           always build a \`.o' file suitable for static linking
6797b698ba48Smrg
6798b698ba48SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
6799b698ba48Smrgfrom the given SOURCEFILE.
6800b698ba48Smrg
6801b698ba48SmrgThe output file name is determined by removing the directory component from
6802b698ba48SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
6803b698ba48Smrglibrary object suffix, \`.lo'."
6804b698ba48Smrg  ;;
6805b698ba48Smrg
6806b698ba48Smrgexecute)
6807b698ba48Smrg  $echo \
6808b698ba48Smrg"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]...
6809b698ba48Smrg
6810b698ba48SmrgAutomatically set library path, then run a program.
6811b698ba48Smrg
6812b698ba48SmrgThis mode accepts the following additional options:
6813b698ba48Smrg
6814b698ba48Smrg  -dlopen FILE      add the directory containing FILE to the library path
6815b698ba48Smrg
6816b698ba48SmrgThis mode sets the library path environment variable according to \`-dlopen'
6817b698ba48Smrgflags.
6818b698ba48Smrg
6819b698ba48SmrgIf any of the ARGS are libtool executable wrappers, then they are translated
6820b698ba48Smrginto their corresponding uninstalled binary, and any of their required library
6821b698ba48Smrgdirectories are added to the library path.
6822b698ba48Smrg
6823b698ba48SmrgThen, COMMAND is executed, with ARGS as arguments."
6824b698ba48Smrg  ;;
6825b698ba48Smrg
6826b698ba48Smrgfinish)
6827b698ba48Smrg  $echo \
6828b698ba48Smrg"Usage: $modename [OPTION]... --mode=finish [LIBDIR]...
6829b698ba48Smrg
6830b698ba48SmrgComplete the installation of libtool libraries.
6831b698ba48Smrg
6832b698ba48SmrgEach LIBDIR is a directory that contains libtool libraries.
6833b698ba48Smrg
6834b698ba48SmrgThe commands that this mode executes may require superuser privileges.  Use
6835b698ba48Smrgthe \`--dry-run' option if you just want to see what would be executed."
6836b698ba48Smrg  ;;
6837b698ba48Smrg
6838b698ba48Smrginstall)
6839b698ba48Smrg  $echo \
6840b698ba48Smrg"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND...
6841b698ba48Smrg
6842b698ba48SmrgInstall executables or libraries.
6843b698ba48Smrg
6844b698ba48SmrgINSTALL-COMMAND is the installation command.  The first component should be
6845b698ba48Smrgeither the \`install' or \`cp' program.
6846b698ba48Smrg
6847b698ba48SmrgThe rest of the components are interpreted as arguments to that command (only
6848b698ba48SmrgBSD-compatible install options are recognized)."
6849b698ba48Smrg  ;;
6850b698ba48Smrg
6851b698ba48Smrglink)
6852b698ba48Smrg  $echo \
6853b698ba48Smrg"Usage: $modename [OPTION]... --mode=link LINK-COMMAND...
6854b698ba48Smrg
6855b698ba48SmrgLink object files or libraries together to form another library, or to
6856b698ba48Smrgcreate an executable program.
685709885543Smrg
6858b698ba48SmrgLINK-COMMAND is a command using the C compiler that you would use to create
6859b698ba48Smrga program from several object files.
6860b698ba48Smrg
6861b698ba48SmrgThe following components of LINK-COMMAND are treated specially:
6862b698ba48Smrg
6863b698ba48Smrg  -all-static       do not do any dynamic linking at all
6864b698ba48Smrg  -avoid-version    do not add a version suffix if possible
6865b698ba48Smrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
6866b698ba48Smrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
6867b698ba48Smrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
6868b698ba48Smrg  -export-symbols SYMFILE
6869b698ba48Smrg                    try to export only the symbols listed in SYMFILE
6870b698ba48Smrg  -export-symbols-regex REGEX
6871b698ba48Smrg                    try to export only the symbols matching REGEX
6872b698ba48Smrg  -LLIBDIR          search LIBDIR for required installed libraries
6873b698ba48Smrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
6874b698ba48Smrg  -module           build a library that can dlopened
6875b698ba48Smrg  -no-fast-install  disable the fast-install mode
6876b698ba48Smrg  -no-install       link a not-installable executable
6877b698ba48Smrg  -no-undefined     declare that a library does not refer to external symbols
6878b698ba48Smrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
6879b698ba48Smrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
6880b698ba48Smrg  -precious-files-regex REGEX
6881b698ba48Smrg                    don't remove output files matching REGEX
6882b698ba48Smrg  -release RELEASE  specify package release information
6883b698ba48Smrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
6884b698ba48Smrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
6885b698ba48Smrg  -static           do not do any dynamic linking of uninstalled libtool libraries
6886b698ba48Smrg  -static-libtool-libs
6887b698ba48Smrg                    do not do any dynamic linking of libtool libraries
6888b698ba48Smrg  -version-info CURRENT[:REVISION[:AGE]]
6889b698ba48Smrg                    specify library version info [each variable defaults to 0]
6890b698ba48Smrg
6891b698ba48SmrgAll other options (arguments beginning with \`-') are ignored.
6892b698ba48Smrg
6893b698ba48SmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
6894b698ba48Smrgtreated as uninstalled libtool libraries, other files are standard or library
6895b698ba48Smrgobject files.
6896b698ba48Smrg
6897b698ba48SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
6898b698ba48Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
6899b698ba48Smrgrequired, except when creating a convenience library.
6900b698ba48Smrg
6901b698ba48SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
6902b698ba48Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
6903b698ba48Smrg
6904b698ba48SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
6905b698ba48Smrgis created, otherwise an executable program is created."
6906b698ba48Smrg  ;;
6907b698ba48Smrg
6908b698ba48Smrguninstall)
6909b698ba48Smrg  $echo \
6910b698ba48Smrg"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
6911b698ba48Smrg
6912b698ba48SmrgRemove libraries from an installation directory.
6913b698ba48Smrg
6914b698ba48SmrgRM is the name of the program to use to delete files associated with each FILE
6915b698ba48Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
6916b698ba48Smrgto RM.
6917b698ba48Smrg
6918b698ba48SmrgIf FILE is a libtool library, all the files associated with it are deleted.
6919b698ba48SmrgOtherwise, only FILE itself is deleted using RM."
6920b698ba48Smrg  ;;
6921b698ba48Smrg
6922b698ba48Smrg*)
6923b698ba48Smrg  $echo "$modename: invalid operation mode \`$mode'" 1>&2
6924b698ba48Smrg  $echo "$help" 1>&2
6925b698ba48Smrg  exit $EXIT_FAILURE
6926b698ba48Smrg  ;;
6927b698ba48Smrgesac
6928b698ba48Smrg
6929b698ba48Smrg$echo
6930b698ba48Smrg$echo "Try \`$modename --help' for more information about other modes."
6931b698ba48Smrg
6932b698ba48Smrgexit $?
693309885543Smrg
693409885543Smrg# The TAGs below are defined such that we never get into a situation
693509885543Smrg# in which we disable both kinds of libraries.  Given conflicting
693609885543Smrg# choices, we go for a static library, that is the most portable,
693709885543Smrg# since we can't tell whether shared libraries were disabled because
693809885543Smrg# the user asked for that or because the platform doesn't support
693909885543Smrg# them.  This is particularly important on AIX, because we don't
694009885543Smrg# support having both static and shared libraries enabled at the same
694109885543Smrg# time on that platform, so we default to a shared-only configuration.
694209885543Smrg# If a disable-shared tag is given, we'll fallback to a static-only
694309885543Smrg# configuration.  But we'll never go from static-only to shared-only.
694409885543Smrg
694509885543Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
6946b698ba48Smrgdisable_libs=shared
694709885543Smrg# ### END LIBTOOL TAG CONFIG: disable-shared
694809885543Smrg
694909885543Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
6950b698ba48Smrgdisable_libs=static
695109885543Smrg# ### END LIBTOOL TAG CONFIG: disable-static
695209885543Smrg
695309885543Smrg# Local Variables:
695409885543Smrg# mode:shell-script
695509885543Smrg# sh-indentation:2
695609885543Smrg# End:
6957