ltmain.sh revision 1ab64890
11ab64890Smrg# ltmain.sh - Provide generalized library-building support services.
21ab64890Smrg# NOTE: Changing this file will not affect anything until you rerun configure.
31ab64890Smrg#
41ab64890Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
51ab64890Smrg# 2007  Free Software Foundation, Inc.
61ab64890Smrg# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
71ab64890Smrg#
81ab64890Smrg# This program is free software; you can redistribute it and/or modify
91ab64890Smrg# it under the terms of the GNU General Public License as published by
101ab64890Smrg# the Free Software Foundation; either version 2 of the License, or
111ab64890Smrg# (at your option) any later version.
121ab64890Smrg#
131ab64890Smrg# This program is distributed in the hope that it will be useful, but
141ab64890Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
151ab64890Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
161ab64890Smrg# General Public License for more details.
171ab64890Smrg#
181ab64890Smrg# You should have received a copy of the GNU General Public License
191ab64890Smrg# along with this program; if not, write to the Free Software
201ab64890Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
211ab64890Smrg#
221ab64890Smrg# As a special exception to the GNU General Public License, if you
231ab64890Smrg# distribute this file as part of a program that contains a
241ab64890Smrg# configuration script generated by Autoconf, you may include it under
251ab64890Smrg# the same distribution terms that you use for the rest of that program.
261ab64890Smrg
271ab64890Smrgbasename="s,^.*/,,g"
281ab64890Smrg
291ab64890Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
301ab64890Smrg# is ksh but when the shell is invoked as "sh" and the current value of
311ab64890Smrg# the _XPG environment variable is not equal to 1 (one), the special
321ab64890Smrg# positional parameter $0, within a function call, is the name of the
331ab64890Smrg# function.
341ab64890Smrgprogpath="$0"
351ab64890Smrg
361ab64890Smrg# The name of this program:
371ab64890Smrgprogname=`echo "$progpath" | $SED $basename`
381ab64890Smrgmodename="$progname"
391ab64890Smrg
401ab64890Smrg# Global variables:
411ab64890SmrgEXIT_SUCCESS=0
421ab64890SmrgEXIT_FAILURE=1
431ab64890Smrg
441ab64890SmrgPROGRAM=ltmain.sh
451ab64890SmrgPACKAGE=libtool
461ab64890SmrgVERSION=1.5.24
471ab64890SmrgTIMESTAMP=" (1.1220.2.456 2007/06/24 02:25:32)"
481ab64890Smrg
491ab64890Smrg# Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE).
501ab64890Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
511ab64890Smrg  emulate sh
521ab64890Smrg  NULLCMD=:
531ab64890Smrg  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
541ab64890Smrg  # is contrary to our usage.  Disable this feature.
551ab64890Smrg  alias -g '${1+"$@"}'='"$@"'
561ab64890Smrg  setopt NO_GLOB_SUBST
571ab64890Smrgelse
581ab64890Smrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
591ab64890Smrgfi
601ab64890SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
611ab64890SmrgDUALCASE=1; export DUALCASE # for MKS sh
621ab64890Smrg
631ab64890Smrg# Check that we have a working $echo.
641ab64890Smrgif test "X$1" = X--no-reexec; then
651ab64890Smrg  # Discard the --no-reexec flag, and continue.
661ab64890Smrg  shift
671ab64890Smrgelif test "X$1" = X--fallback-echo; then
681ab64890Smrg  # Avoid inline document here, it may be left over
691ab64890Smrg  :
701ab64890Smrgelif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
711ab64890Smrg  # Yippee, $echo works!
721ab64890Smrg  :
731ab64890Smrgelse
741ab64890Smrg  # Restart under the correct shell, and then maybe $echo will work.
751ab64890Smrg  exec $SHELL "$progpath" --no-reexec ${1+"$@"}
761ab64890Smrgfi
771ab64890Smrg
781ab64890Smrgif test "X$1" = X--fallback-echo; then
791ab64890Smrg  # used as fallback echo
801ab64890Smrg  shift
811ab64890Smrg  cat <<EOF
821ab64890Smrg$*
831ab64890SmrgEOF
841ab64890Smrg  exit $EXIT_SUCCESS
851ab64890Smrgfi
861ab64890Smrg
871ab64890Smrgdefault_mode=
881ab64890Smrghelp="Try \`$progname --help' for more information."
891ab64890Smrgmagic="%%%MAGIC variable%%%"
901ab64890Smrgmkdir="mkdir"
911ab64890Smrgmv="mv -f"
921ab64890Smrgrm="rm -f"
931ab64890Smrg
941ab64890Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
951ab64890Smrg# metacharacters that are still active within double-quoted strings.
961ab64890SmrgXsed="${SED}"' -e 1s/^X//'
971ab64890Smrgsed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
981ab64890Smrg# test EBCDIC or ASCII
991ab64890Smrgcase `echo X|tr X '\101'` in
1001ab64890Smrg A) # ASCII based system
1011ab64890Smrg    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
1021ab64890Smrg  SP2NL='tr \040 \012'
1031ab64890Smrg  NL2SP='tr \015\012 \040\040'
1041ab64890Smrg  ;;
1051ab64890Smrg *) # EBCDIC based system
1061ab64890Smrg  SP2NL='tr \100 \n'
1071ab64890Smrg  NL2SP='tr \r\n \100\100'
1081ab64890Smrg  ;;
1091ab64890Smrgesac
1101ab64890Smrg
1111ab64890Smrg# NLS nuisances.
1121ab64890Smrg# Only set LANG and LC_ALL to C if already set.
1131ab64890Smrg# These must not be set unconditionally because not all systems understand
1141ab64890Smrg# e.g. LANG=C (notably SCO).
1151ab64890Smrg# We save the old values to restore during execute mode.
1161ab64890Smrgfor lt_var in LANG LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
1171ab64890Smrgdo
1181ab64890Smrg  eval "if test \"\${$lt_var+set}\" = set; then
1191ab64890Smrg	  save_$lt_var=\$$lt_var
1201ab64890Smrg	  $lt_var=C
1211ab64890Smrg	  export $lt_var
1221ab64890Smrg	fi"
1231ab64890Smrgdone
1241ab64890Smrg
1251ab64890Smrg# Make sure IFS has a sensible default
1261ab64890Smrglt_nl='
1271ab64890Smrg'
1281ab64890SmrgIFS=" 	$lt_nl"
1291ab64890Smrg
1301ab64890Smrgif test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
1311ab64890Smrg  $echo "$modename: not configured to build any kind of library" 1>&2
1321ab64890Smrg  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
1331ab64890Smrg  exit $EXIT_FAILURE
1341ab64890Smrgfi
1351ab64890Smrg
1361ab64890Smrg# Global variables.
1371ab64890Smrgmode=$default_mode
1381ab64890Smrgnonopt=
1391ab64890Smrgprev=
1401ab64890Smrgprevopt=
1411ab64890Smrgrun=
1421ab64890Smrgshow="$echo"
1431ab64890Smrgshow_help=
1441ab64890Smrgexecute_dlfiles=
1451ab64890Smrgduplicate_deps=no
1461ab64890Smrgpreserve_args=
1471ab64890Smrglo2o="s/\\.lo\$/.${objext}/"
1481ab64890Smrgo2lo="s/\\.${objext}\$/.lo/"
1491ab64890Smrgextracted_archives=
1501ab64890Smrgextracted_serial=0
1511ab64890Smrg
1521ab64890Smrg#####################################
1531ab64890Smrg# Shell function definitions:
1541ab64890Smrg# This seems to be the best place for them
1551ab64890Smrg
1561ab64890Smrg# func_mktempdir [string]
1571ab64890Smrg# Make a temporary directory that won't clash with other running
1581ab64890Smrg# libtool processes, and avoids race conditions if possible.  If
1591ab64890Smrg# given, STRING is the basename for that directory.
1601ab64890Smrgfunc_mktempdir ()
1611ab64890Smrg{
1621ab64890Smrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
1631ab64890Smrg
1641ab64890Smrg    if test "$run" = ":"; then
1651ab64890Smrg      # Return a directory name, but don't create it in dry-run mode
1661ab64890Smrg      my_tmpdir="${my_template}-$$"
1671ab64890Smrg    else
1681ab64890Smrg
1691ab64890Smrg      # If mktemp works, use that first and foremost
1701ab64890Smrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
1711ab64890Smrg
1721ab64890Smrg      if test ! -d "$my_tmpdir"; then
1731ab64890Smrg	# Failing that, at least try and use $RANDOM to avoid a race
1741ab64890Smrg	my_tmpdir="${my_template}-${RANDOM-0}$$"
1751ab64890Smrg
1761ab64890Smrg	save_mktempdir_umask=`umask`
1771ab64890Smrg	umask 0077
1781ab64890Smrg	$mkdir "$my_tmpdir"
1791ab64890Smrg	umask $save_mktempdir_umask
1801ab64890Smrg      fi
1811ab64890Smrg
1821ab64890Smrg      # If we're not in dry-run mode, bomb out on failure
1831ab64890Smrg      test -d "$my_tmpdir" || {
1841ab64890Smrg        $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
1851ab64890Smrg	exit $EXIT_FAILURE
1861ab64890Smrg      }
1871ab64890Smrg    fi
1881ab64890Smrg
1891ab64890Smrg    $echo "X$my_tmpdir" | $Xsed
1901ab64890Smrg}
1911ab64890Smrg
1921ab64890Smrg
1931ab64890Smrg# func_win32_libid arg
1941ab64890Smrg# return the library type of file 'arg'
1951ab64890Smrg#
1961ab64890Smrg# Need a lot of goo to handle *both* DLLs and import libs
1971ab64890Smrg# Has to be a shell function in order to 'eat' the argument
1981ab64890Smrg# that is supplied when $file_magic_command is called.
1991ab64890Smrgfunc_win32_libid ()
2001ab64890Smrg{
2011ab64890Smrg  win32_libid_type="unknown"
2021ab64890Smrg  win32_fileres=`file -L $1 2>/dev/null`
2031ab64890Smrg  case $win32_fileres in
2041ab64890Smrg  *ar\ archive\ import\ library*) # definitely import
2051ab64890Smrg    win32_libid_type="x86 archive import"
2061ab64890Smrg    ;;
2071ab64890Smrg  *ar\ archive*) # could be an import, or static
2081ab64890Smrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
2091ab64890Smrg      $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
2101ab64890Smrg      win32_nmres=`eval $NM -f posix -A $1 | \
2111ab64890Smrg	$SED -n -e '1,100{
2121ab64890Smrg		/ I /{
2131ab64890Smrg			s,.*,import,
2141ab64890Smrg			p
2151ab64890Smrg			q
2161ab64890Smrg			}
2171ab64890Smrg		}'`
2181ab64890Smrg      case $win32_nmres in
2191ab64890Smrg      import*)  win32_libid_type="x86 archive import";;
2201ab64890Smrg      *)        win32_libid_type="x86 archive static";;
2211ab64890Smrg      esac
2221ab64890Smrg    fi
2231ab64890Smrg    ;;
2241ab64890Smrg  *DLL*)
2251ab64890Smrg    win32_libid_type="x86 DLL"
2261ab64890Smrg    ;;
2271ab64890Smrg  *executable*) # but shell scripts are "executable" too...
2281ab64890Smrg    case $win32_fileres in
2291ab64890Smrg    *MS\ Windows\ PE\ Intel*)
2301ab64890Smrg      win32_libid_type="x86 DLL"
2311ab64890Smrg      ;;
2321ab64890Smrg    esac
2331ab64890Smrg    ;;
2341ab64890Smrg  esac
2351ab64890Smrg  $echo $win32_libid_type
2361ab64890Smrg}
2371ab64890Smrg
2381ab64890Smrg
2391ab64890Smrg# func_infer_tag arg
2401ab64890Smrg# Infer tagged configuration to use if any are available and
2411ab64890Smrg# if one wasn't chosen via the "--tag" command line option.
2421ab64890Smrg# Only attempt this if the compiler in the base compile
2431ab64890Smrg# command doesn't match the default compiler.
2441ab64890Smrg# arg is usually of the form 'gcc ...'
2451ab64890Smrgfunc_infer_tag ()
2461ab64890Smrg{
2471ab64890Smrg    if test -n "$available_tags" && test -z "$tagname"; then
2481ab64890Smrg      CC_quoted=
2491ab64890Smrg      for arg in $CC; do
2501ab64890Smrg	case $arg in
2511ab64890Smrg	  *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
2521ab64890Smrg	  arg="\"$arg\""
2531ab64890Smrg	  ;;
2541ab64890Smrg	esac
2551ab64890Smrg	CC_quoted="$CC_quoted $arg"
2561ab64890Smrg      done
2571ab64890Smrg      case $@ in
2581ab64890Smrg      # Blanks in the command may have been stripped by the calling shell,
2591ab64890Smrg      # but not from the CC environment variable when configure was run.
2601ab64890Smrg      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
2611ab64890Smrg      # Blanks at the start of $base_compile will cause this to fail
2621ab64890Smrg      # if we don't check for them as well.
2631ab64890Smrg      *)
2641ab64890Smrg	for z in $available_tags; do
2651ab64890Smrg	  if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
2661ab64890Smrg	    # Evaluate the configuration.
2671ab64890Smrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
2681ab64890Smrg	    CC_quoted=
2691ab64890Smrg	    for arg in $CC; do
2701ab64890Smrg	    # Double-quote args containing other shell metacharacters.
2711ab64890Smrg	    case $arg in
2721ab64890Smrg	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
2731ab64890Smrg	      arg="\"$arg\""
2741ab64890Smrg	      ;;
2751ab64890Smrg	    esac
2761ab64890Smrg	    CC_quoted="$CC_quoted $arg"
2771ab64890Smrg	  done
2781ab64890Smrg	    case "$@ " in
2791ab64890Smrg	      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
2801ab64890Smrg	      # The compiler in the base compile command matches
2811ab64890Smrg	      # the one in the tagged configuration.
2821ab64890Smrg	      # Assume this is the tagged configuration we want.
2831ab64890Smrg	      tagname=$z
2841ab64890Smrg	      break
2851ab64890Smrg	      ;;
2861ab64890Smrg	    esac
2871ab64890Smrg	  fi
2881ab64890Smrg	done
2891ab64890Smrg	# If $tagname still isn't set, then no tagged configuration
2901ab64890Smrg	# was found and let the user know that the "--tag" command
2911ab64890Smrg	# line option must be used.
2921ab64890Smrg	if test -z "$tagname"; then
2931ab64890Smrg	  $echo "$modename: unable to infer tagged configuration"
2941ab64890Smrg	  $echo "$modename: specify a tag with \`--tag'" 1>&2
2951ab64890Smrg	  exit $EXIT_FAILURE
2961ab64890Smrg#        else
2971ab64890Smrg#          $echo "$modename: using $tagname tagged configuration"
2981ab64890Smrg	fi
2991ab64890Smrg	;;
3001ab64890Smrg      esac
3011ab64890Smrg    fi
3021ab64890Smrg}
3031ab64890Smrg
3041ab64890Smrg
3051ab64890Smrg# func_extract_an_archive dir oldlib
3061ab64890Smrgfunc_extract_an_archive ()
3071ab64890Smrg{
3081ab64890Smrg    f_ex_an_ar_dir="$1"; shift
3091ab64890Smrg    f_ex_an_ar_oldlib="$1"
3101ab64890Smrg
3111ab64890Smrg    $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
3121ab64890Smrg    $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
3131ab64890Smrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
3141ab64890Smrg     :
3151ab64890Smrg    else
3161ab64890Smrg      $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2
3171ab64890Smrg      exit $EXIT_FAILURE
3181ab64890Smrg    fi
3191ab64890Smrg}
3201ab64890Smrg
3211ab64890Smrg# func_extract_archives gentop oldlib ...
3221ab64890Smrgfunc_extract_archives ()
3231ab64890Smrg{
3241ab64890Smrg    my_gentop="$1"; shift
3251ab64890Smrg    my_oldlibs=${1+"$@"}
3261ab64890Smrg    my_oldobjs=""
3271ab64890Smrg    my_xlib=""
3281ab64890Smrg    my_xabs=""
3291ab64890Smrg    my_xdir=""
3301ab64890Smrg    my_status=""
3311ab64890Smrg
3321ab64890Smrg    $show "${rm}r $my_gentop"
3331ab64890Smrg    $run ${rm}r "$my_gentop"
3341ab64890Smrg    $show "$mkdir $my_gentop"
3351ab64890Smrg    $run $mkdir "$my_gentop"
3361ab64890Smrg    my_status=$?
3371ab64890Smrg    if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
3381ab64890Smrg      exit $my_status
3391ab64890Smrg    fi
3401ab64890Smrg
3411ab64890Smrg    for my_xlib in $my_oldlibs; do
3421ab64890Smrg      # Extract the objects.
3431ab64890Smrg      case $my_xlib in
3441ab64890Smrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
3451ab64890Smrg	*) my_xabs=`pwd`"/$my_xlib" ;;
3461ab64890Smrg      esac
3471ab64890Smrg      my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
3481ab64890Smrg      my_xlib_u=$my_xlib
3491ab64890Smrg      while :; do
3501ab64890Smrg        case " $extracted_archives " in
3511ab64890Smrg	*" $my_xlib_u "*)
3521ab64890Smrg	  extracted_serial=`expr $extracted_serial + 1`
3531ab64890Smrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
3541ab64890Smrg	*) break ;;
3551ab64890Smrg	esac
3561ab64890Smrg      done
3571ab64890Smrg      extracted_archives="$extracted_archives $my_xlib_u"
3581ab64890Smrg      my_xdir="$my_gentop/$my_xlib_u"
3591ab64890Smrg
3601ab64890Smrg      $show "${rm}r $my_xdir"
3611ab64890Smrg      $run ${rm}r "$my_xdir"
3621ab64890Smrg      $show "$mkdir $my_xdir"
3631ab64890Smrg      $run $mkdir "$my_xdir"
3641ab64890Smrg      exit_status=$?
3651ab64890Smrg      if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then
3661ab64890Smrg	exit $exit_status
3671ab64890Smrg      fi
3681ab64890Smrg      case $host in
3691ab64890Smrg      *-darwin*)
3701ab64890Smrg	$show "Extracting $my_xabs"
3711ab64890Smrg	# Do not bother doing anything if just a dry run
3721ab64890Smrg	if test -z "$run"; then
3731ab64890Smrg	  darwin_orig_dir=`pwd`
3741ab64890Smrg	  cd $my_xdir || exit $?
3751ab64890Smrg	  darwin_archive=$my_xabs
3761ab64890Smrg	  darwin_curdir=`pwd`
3771ab64890Smrg	  darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'`
3781ab64890Smrg	  darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
3791ab64890Smrg	  if test -n "$darwin_arches"; then 
3801ab64890Smrg	    darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
3811ab64890Smrg	    darwin_arch=
3821ab64890Smrg	    $show "$darwin_base_archive has multiple architectures $darwin_arches"
3831ab64890Smrg	    for darwin_arch in  $darwin_arches ; do
3841ab64890Smrg	      mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3851ab64890Smrg	      lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
3861ab64890Smrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3871ab64890Smrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
3881ab64890Smrg	      cd "$darwin_curdir"
3891ab64890Smrg	      $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
3901ab64890Smrg	    done # $darwin_arches
3911ab64890Smrg      ## Okay now we have a bunch of thin objects, gotta fatten them up :)
3921ab64890Smrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP`
3931ab64890Smrg	    darwin_file=
3941ab64890Smrg	    darwin_files=
3951ab64890Smrg	    for darwin_file in $darwin_filelist; do
3961ab64890Smrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
3971ab64890Smrg	      lipo -create -output "$darwin_file" $darwin_files
3981ab64890Smrg	    done # $darwin_filelist
3991ab64890Smrg	    ${rm}r unfat-$$
4001ab64890Smrg	    cd "$darwin_orig_dir"
4011ab64890Smrg	  else
4021ab64890Smrg	    cd "$darwin_orig_dir"
4031ab64890Smrg 	    func_extract_an_archive "$my_xdir" "$my_xabs"
4041ab64890Smrg	  fi # $darwin_arches
4051ab64890Smrg	fi # $run
4061ab64890Smrg	;;
4071ab64890Smrg      *)
4081ab64890Smrg        func_extract_an_archive "$my_xdir" "$my_xabs"
4091ab64890Smrg        ;;
4101ab64890Smrg      esac
4111ab64890Smrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
4121ab64890Smrg    done
4131ab64890Smrg    func_extract_archives_result="$my_oldobjs"
4141ab64890Smrg}
4151ab64890Smrg# End of Shell function definitions
4161ab64890Smrg#####################################
4171ab64890Smrg
4181ab64890Smrg# Darwin sucks
4191ab64890Smrgeval std_shrext=\"$shrext_cmds\"
4201ab64890Smrg
4211ab64890Smrgdisable_libs=no
4221ab64890Smrg
4231ab64890Smrg# Parse our command line options once, thoroughly.
4241ab64890Smrgwhile test "$#" -gt 0
4251ab64890Smrgdo
4261ab64890Smrg  arg="$1"
4271ab64890Smrg  shift
4281ab64890Smrg
4291ab64890Smrg  case $arg in
4301ab64890Smrg  -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
4311ab64890Smrg  *) optarg= ;;
4321ab64890Smrg  esac
4331ab64890Smrg
4341ab64890Smrg  # If the previous option needs an argument, assign it.
4351ab64890Smrg  if test -n "$prev"; then
4361ab64890Smrg    case $prev in
4371ab64890Smrg    execute_dlfiles)
4381ab64890Smrg      execute_dlfiles="$execute_dlfiles $arg"
4391ab64890Smrg      ;;
4401ab64890Smrg    tag)
4411ab64890Smrg      tagname="$arg"
4421ab64890Smrg      preserve_args="${preserve_args}=$arg"
4431ab64890Smrg
4441ab64890Smrg      # Check whether tagname contains only valid characters
4451ab64890Smrg      case $tagname in
4461ab64890Smrg      *[!-_A-Za-z0-9,/]*)
4471ab64890Smrg	$echo "$progname: invalid tag name: $tagname" 1>&2
4481ab64890Smrg	exit $EXIT_FAILURE
4491ab64890Smrg	;;
4501ab64890Smrg      esac
4511ab64890Smrg
4521ab64890Smrg      case $tagname in
4531ab64890Smrg      CC)
4541ab64890Smrg	# Don't test for the "default" C tag, as we know, it's there, but
4551ab64890Smrg	# not specially marked.
4561ab64890Smrg	;;
4571ab64890Smrg      *)
4581ab64890Smrg	if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then
4591ab64890Smrg	  taglist="$taglist $tagname"
4601ab64890Smrg	  # Evaluate the configuration.
4611ab64890Smrg	  eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`"
4621ab64890Smrg	else
4631ab64890Smrg	  $echo "$progname: ignoring unknown tag $tagname" 1>&2
4641ab64890Smrg	fi
4651ab64890Smrg	;;
4661ab64890Smrg      esac
4671ab64890Smrg      ;;
4681ab64890Smrg    *)
4691ab64890Smrg      eval "$prev=\$arg"
4701ab64890Smrg      ;;
4711ab64890Smrg    esac
4721ab64890Smrg
4731ab64890Smrg    prev=
4741ab64890Smrg    prevopt=
4751ab64890Smrg    continue
4761ab64890Smrg  fi
4771ab64890Smrg
4781ab64890Smrg  # Have we seen a non-optional argument yet?
4791ab64890Smrg  case $arg in
4801ab64890Smrg  --help)
4811ab64890Smrg    show_help=yes
4821ab64890Smrg    ;;
4831ab64890Smrg
4841ab64890Smrg  --version)
4851ab64890Smrg    echo "\
4861ab64890Smrg$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP
4871ab64890Smrg
4881ab64890SmrgCopyright (C) 2007  Free Software Foundation, Inc.
4891ab64890SmrgThis is free software; see the source for copying conditions.  There is NO
4901ab64890Smrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
4911ab64890Smrg    exit $?
4921ab64890Smrg    ;;
4931ab64890Smrg
4941ab64890Smrg  --config)
4951ab64890Smrg    ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath
4961ab64890Smrg    # Now print the configurations for the tags.
4971ab64890Smrg    for tagname in $taglist; do
4981ab64890Smrg      ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
4991ab64890Smrg    done
5001ab64890Smrg    exit $?
5011ab64890Smrg    ;;
5021ab64890Smrg
5031ab64890Smrg  --debug)
5041ab64890Smrg    $echo "$progname: enabling shell trace mode"
5051ab64890Smrg    set -x
5061ab64890Smrg    preserve_args="$preserve_args $arg"
5071ab64890Smrg    ;;
5081ab64890Smrg
5091ab64890Smrg  --dry-run | -n)
5101ab64890Smrg    run=:
5111ab64890Smrg    ;;
5121ab64890Smrg
5131ab64890Smrg  --features)
5141ab64890Smrg    $echo "host: $host"
5151ab64890Smrg    if test "$build_libtool_libs" = yes; then
5161ab64890Smrg      $echo "enable shared libraries"
5171ab64890Smrg    else
5181ab64890Smrg      $echo "disable shared libraries"
5191ab64890Smrg    fi
5201ab64890Smrg    if test "$build_old_libs" = yes; then
5211ab64890Smrg      $echo "enable static libraries"
5221ab64890Smrg    else
5231ab64890Smrg      $echo "disable static libraries"
5241ab64890Smrg    fi
5251ab64890Smrg    exit $?
5261ab64890Smrg    ;;
5271ab64890Smrg
5281ab64890Smrg  --finish) mode="finish" ;;
5291ab64890Smrg
5301ab64890Smrg  --mode) prevopt="--mode" prev=mode ;;
5311ab64890Smrg  --mode=*) mode="$optarg" ;;
5321ab64890Smrg
5331ab64890Smrg  --preserve-dup-deps) duplicate_deps="yes" ;;
5341ab64890Smrg
5351ab64890Smrg  --quiet | --silent)
5361ab64890Smrg    show=:
5371ab64890Smrg    preserve_args="$preserve_args $arg"
5381ab64890Smrg    ;;
5391ab64890Smrg
5401ab64890Smrg  --tag)
5411ab64890Smrg    prevopt="--tag"
5421ab64890Smrg    prev=tag
5431ab64890Smrg    preserve_args="$preserve_args --tag"
5441ab64890Smrg    ;;
5451ab64890Smrg  --tag=*)
5461ab64890Smrg    set tag "$optarg" ${1+"$@"}
5471ab64890Smrg    shift
5481ab64890Smrg    prev=tag
5491ab64890Smrg    preserve_args="$preserve_args --tag"
5501ab64890Smrg    ;;
5511ab64890Smrg
5521ab64890Smrg  -dlopen)
5531ab64890Smrg    prevopt="-dlopen"
5541ab64890Smrg    prev=execute_dlfiles
5551ab64890Smrg    ;;
5561ab64890Smrg
5571ab64890Smrg  -*)
5581ab64890Smrg    $echo "$modename: unrecognized option \`$arg'" 1>&2
5591ab64890Smrg    $echo "$help" 1>&2
5601ab64890Smrg    exit $EXIT_FAILURE
5611ab64890Smrg    ;;
5621ab64890Smrg
5631ab64890Smrg  *)
5641ab64890Smrg    nonopt="$arg"
5651ab64890Smrg    break
5661ab64890Smrg    ;;
5671ab64890Smrg  esac
5681ab64890Smrgdone
5691ab64890Smrg
5701ab64890Smrgif test -n "$prevopt"; then
5711ab64890Smrg  $echo "$modename: option \`$prevopt' requires an argument" 1>&2
5721ab64890Smrg  $echo "$help" 1>&2
5731ab64890Smrg  exit $EXIT_FAILURE
5741ab64890Smrgfi
5751ab64890Smrg
5761ab64890Smrgcase $disable_libs in
5771ab64890Smrgno) 
5781ab64890Smrg  ;;
5791ab64890Smrgshared)
5801ab64890Smrg  build_libtool_libs=no
5811ab64890Smrg  build_old_libs=yes
5821ab64890Smrg  ;;
5831ab64890Smrgstatic)
5841ab64890Smrg  build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
5851ab64890Smrg  ;;
5861ab64890Smrgesac
5871ab64890Smrg
5881ab64890Smrg# If this variable is set in any of the actions, the command in it
5891ab64890Smrg# will be execed at the end.  This prevents here-documents from being
5901ab64890Smrg# left over by shells.
5911ab64890Smrgexec_cmd=
5921ab64890Smrg
5931ab64890Smrgif test -z "$show_help"; then
5941ab64890Smrg
5951ab64890Smrg  # Infer the operation mode.
5961ab64890Smrg  if test -z "$mode"; then
5971ab64890Smrg    $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
5981ab64890Smrg    $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2
5991ab64890Smrg    case $nonopt in
6001ab64890Smrg    *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
6011ab64890Smrg      mode=link
6021ab64890Smrg      for arg
6031ab64890Smrg      do
6041ab64890Smrg	case $arg in
6051ab64890Smrg	-c)
6061ab64890Smrg	   mode=compile
6071ab64890Smrg	   break
6081ab64890Smrg	   ;;
6091ab64890Smrg	esac
6101ab64890Smrg      done
6111ab64890Smrg      ;;
6121ab64890Smrg    *db | *dbx | *strace | *truss)
6131ab64890Smrg      mode=execute
6141ab64890Smrg      ;;
6151ab64890Smrg    *install*|cp|mv)
6161ab64890Smrg      mode=install
6171ab64890Smrg      ;;
6181ab64890Smrg    *rm)
6191ab64890Smrg      mode=uninstall
6201ab64890Smrg      ;;
6211ab64890Smrg    *)
6221ab64890Smrg      # If we have no mode, but dlfiles were specified, then do execute mode.
6231ab64890Smrg      test -n "$execute_dlfiles" && mode=execute
6241ab64890Smrg
6251ab64890Smrg      # Just use the default operation mode.
6261ab64890Smrg      if test -z "$mode"; then
6271ab64890Smrg	if test -n "$nonopt"; then
6281ab64890Smrg	  $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
6291ab64890Smrg	else
6301ab64890Smrg	  $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
6311ab64890Smrg	fi
6321ab64890Smrg      fi
6331ab64890Smrg      ;;
6341ab64890Smrg    esac
6351ab64890Smrg  fi
6361ab64890Smrg
6371ab64890Smrg  # Only execute mode is allowed to have -dlopen flags.
6381ab64890Smrg  if test -n "$execute_dlfiles" && test "$mode" != execute; then
6391ab64890Smrg    $echo "$modename: unrecognized option \`-dlopen'" 1>&2
6401ab64890Smrg    $echo "$help" 1>&2
6411ab64890Smrg    exit $EXIT_FAILURE
6421ab64890Smrg  fi
6431ab64890Smrg
6441ab64890Smrg  # Change the help message to a mode-specific one.
6451ab64890Smrg  generic_help="$help"
6461ab64890Smrg  help="Try \`$modename --help --mode=$mode' for more information."
6471ab64890Smrg
6481ab64890Smrg  # These modes are in order of execution frequency so that they run quickly.
6491ab64890Smrg  case $mode in
6501ab64890Smrg  # libtool compile mode
6511ab64890Smrg  compile)
6521ab64890Smrg    modename="$modename: compile"
6531ab64890Smrg    # Get the compilation command and the source file.
6541ab64890Smrg    base_compile=
6551ab64890Smrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
6561ab64890Smrg    suppress_opt=yes
6571ab64890Smrg    suppress_output=
6581ab64890Smrg    arg_mode=normal
6591ab64890Smrg    libobj=
6601ab64890Smrg    later=
6611ab64890Smrg
6621ab64890Smrg    for arg
6631ab64890Smrg    do
6641ab64890Smrg      case $arg_mode in
6651ab64890Smrg      arg  )
6661ab64890Smrg	# do not "continue".  Instead, add this to base_compile
6671ab64890Smrg	lastarg="$arg"
6681ab64890Smrg	arg_mode=normal
6691ab64890Smrg	;;
6701ab64890Smrg
6711ab64890Smrg      target )
6721ab64890Smrg	libobj="$arg"
6731ab64890Smrg	arg_mode=normal
6741ab64890Smrg	continue
6751ab64890Smrg	;;
6761ab64890Smrg
6771ab64890Smrg      normal )
6781ab64890Smrg	# Accept any command-line options.
6791ab64890Smrg	case $arg in
6801ab64890Smrg	-o)
6811ab64890Smrg	  if test -n "$libobj" ; then
6821ab64890Smrg	    $echo "$modename: you cannot specify \`-o' more than once" 1>&2
6831ab64890Smrg	    exit $EXIT_FAILURE
6841ab64890Smrg	  fi
6851ab64890Smrg	  arg_mode=target
6861ab64890Smrg	  continue
6871ab64890Smrg	  ;;
6881ab64890Smrg
6891ab64890Smrg	-static | -prefer-pic | -prefer-non-pic)
6901ab64890Smrg	  later="$later $arg"
6911ab64890Smrg	  continue
6921ab64890Smrg	  ;;
6931ab64890Smrg
6941ab64890Smrg	-no-suppress)
6951ab64890Smrg	  suppress_opt=no
6961ab64890Smrg	  continue
6971ab64890Smrg	  ;;
6981ab64890Smrg
6991ab64890Smrg	-Xcompiler)
7001ab64890Smrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
7011ab64890Smrg	  continue      #  The current "srcfile" will either be retained or
7021ab64890Smrg	  ;;            #  replaced later.  I would guess that would be a bug.
7031ab64890Smrg
7041ab64890Smrg	-Wc,*)
7051ab64890Smrg	  args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
7061ab64890Smrg	  lastarg=
7071ab64890Smrg	  save_ifs="$IFS"; IFS=','
7081ab64890Smrg 	  for arg in $args; do
7091ab64890Smrg	    IFS="$save_ifs"
7101ab64890Smrg
7111ab64890Smrg	    # Double-quote args containing other shell metacharacters.
7121ab64890Smrg	    # Many Bourne shells cannot handle close brackets correctly
7131ab64890Smrg	    # in scan sets, so we specify it separately.
7141ab64890Smrg	    case $arg in
7151ab64890Smrg	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
7161ab64890Smrg	      arg="\"$arg\""
7171ab64890Smrg	      ;;
7181ab64890Smrg	    esac
7191ab64890Smrg	    lastarg="$lastarg $arg"
7201ab64890Smrg	  done
7211ab64890Smrg	  IFS="$save_ifs"
7221ab64890Smrg	  lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
7231ab64890Smrg
7241ab64890Smrg	  # Add the arguments to base_compile.
7251ab64890Smrg	  base_compile="$base_compile $lastarg"
7261ab64890Smrg	  continue
7271ab64890Smrg	  ;;
7281ab64890Smrg
7291ab64890Smrg	* )
7301ab64890Smrg	  # Accept the current argument as the source file.
7311ab64890Smrg	  # The previous "srcfile" becomes the current argument.
7321ab64890Smrg	  #
7331ab64890Smrg	  lastarg="$srcfile"
7341ab64890Smrg	  srcfile="$arg"
7351ab64890Smrg	  ;;
7361ab64890Smrg	esac  #  case $arg
7371ab64890Smrg	;;
7381ab64890Smrg      esac    #  case $arg_mode
7391ab64890Smrg
7401ab64890Smrg      # Aesthetically quote the previous argument.
7411ab64890Smrg      lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
7421ab64890Smrg
7431ab64890Smrg      case $lastarg in
7441ab64890Smrg      # Double-quote args containing other shell metacharacters.
7451ab64890Smrg      # Many Bourne shells cannot handle close brackets correctly
7461ab64890Smrg      # in scan sets, and some SunOS ksh mistreat backslash-escaping
7471ab64890Smrg      # in scan sets (worked around with variable expansion),
7481ab64890Smrg      # and furthermore cannot handle '|' '&' '(' ')' in scan sets 
7491ab64890Smrg      # at all, so we specify them separately.
7501ab64890Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
7511ab64890Smrg	lastarg="\"$lastarg\""
7521ab64890Smrg	;;
7531ab64890Smrg      esac
7541ab64890Smrg
7551ab64890Smrg      base_compile="$base_compile $lastarg"
7561ab64890Smrg    done # for arg
7571ab64890Smrg
7581ab64890Smrg    case $arg_mode in
7591ab64890Smrg    arg)
7601ab64890Smrg      $echo "$modename: you must specify an argument for -Xcompile"
7611ab64890Smrg      exit $EXIT_FAILURE
7621ab64890Smrg      ;;
7631ab64890Smrg    target)
7641ab64890Smrg      $echo "$modename: you must specify a target with \`-o'" 1>&2
7651ab64890Smrg      exit $EXIT_FAILURE
7661ab64890Smrg      ;;
7671ab64890Smrg    *)
7681ab64890Smrg      # Get the name of the library object.
7691ab64890Smrg      [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
7701ab64890Smrg      ;;
7711ab64890Smrg    esac
7721ab64890Smrg
7731ab64890Smrg    # Recognize several different file suffixes.
7741ab64890Smrg    # If the user specifies -o file.o, it is replaced with file.lo
7751ab64890Smrg    xform='[cCFSifmso]'
7761ab64890Smrg    case $libobj in
7771ab64890Smrg    *.ada) xform=ada ;;
7781ab64890Smrg    *.adb) xform=adb ;;
7791ab64890Smrg    *.ads) xform=ads ;;
7801ab64890Smrg    *.asm) xform=asm ;;
7811ab64890Smrg    *.c++) xform=c++ ;;
7821ab64890Smrg    *.cc) xform=cc ;;
7831ab64890Smrg    *.ii) xform=ii ;;
7841ab64890Smrg    *.class) xform=class ;;
7851ab64890Smrg    *.cpp) xform=cpp ;;
7861ab64890Smrg    *.cxx) xform=cxx ;;
7871ab64890Smrg    *.[fF][09]?) xform=[fF][09]. ;;
7881ab64890Smrg    *.for) xform=for ;;
7891ab64890Smrg    *.java) xform=java ;;
7901ab64890Smrg    *.obj) xform=obj ;;
7911ab64890Smrg    esac
7921ab64890Smrg
7931ab64890Smrg    libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
7941ab64890Smrg
7951ab64890Smrg    case $libobj in
7961ab64890Smrg    *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
7971ab64890Smrg    *)
7981ab64890Smrg      $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
7991ab64890Smrg      exit $EXIT_FAILURE
8001ab64890Smrg      ;;
8011ab64890Smrg    esac
8021ab64890Smrg
8031ab64890Smrg    func_infer_tag $base_compile
8041ab64890Smrg
8051ab64890Smrg    for arg in $later; do
8061ab64890Smrg      case $arg in
8071ab64890Smrg      -static)
8081ab64890Smrg	build_old_libs=yes
8091ab64890Smrg	continue
8101ab64890Smrg	;;
8111ab64890Smrg
8121ab64890Smrg      -prefer-pic)
8131ab64890Smrg	pic_mode=yes
8141ab64890Smrg	continue
8151ab64890Smrg	;;
8161ab64890Smrg
8171ab64890Smrg      -prefer-non-pic)
8181ab64890Smrg	pic_mode=no
8191ab64890Smrg	continue
8201ab64890Smrg	;;
8211ab64890Smrg      esac
8221ab64890Smrg    done
8231ab64890Smrg
8241ab64890Smrg    qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"`
8251ab64890Smrg    case $qlibobj in
8261ab64890Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
8271ab64890Smrg	qlibobj="\"$qlibobj\"" ;;
8281ab64890Smrg    esac
8291ab64890Smrg    test "X$libobj" != "X$qlibobj" \
8301ab64890Smrg	&& $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"' 	&()|`$[]' \
8311ab64890Smrg	&& $echo "$modename: libobj name \`$libobj' may not contain shell special characters."
8321ab64890Smrg    objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
8331ab64890Smrg    xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
8341ab64890Smrg    if test "X$xdir" = "X$obj"; then
8351ab64890Smrg      xdir=
8361ab64890Smrg    else
8371ab64890Smrg      xdir=$xdir/
8381ab64890Smrg    fi
8391ab64890Smrg    lobj=${xdir}$objdir/$objname
8401ab64890Smrg
8411ab64890Smrg    if test -z "$base_compile"; then
8421ab64890Smrg      $echo "$modename: you must specify a compilation command" 1>&2
8431ab64890Smrg      $echo "$help" 1>&2
8441ab64890Smrg      exit $EXIT_FAILURE
8451ab64890Smrg    fi
8461ab64890Smrg
8471ab64890Smrg    # Delete any leftover library objects.
8481ab64890Smrg    if test "$build_old_libs" = yes; then
8491ab64890Smrg      removelist="$obj $lobj $libobj ${libobj}T"
8501ab64890Smrg    else
8511ab64890Smrg      removelist="$lobj $libobj ${libobj}T"
8521ab64890Smrg    fi
8531ab64890Smrg
8541ab64890Smrg    $run $rm $removelist
8551ab64890Smrg    trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
8561ab64890Smrg
8571ab64890Smrg    # On Cygwin there's no "real" PIC flag so we must build both object types
8581ab64890Smrg    case $host_os in
8591ab64890Smrg    cygwin* | mingw* | pw32* | os2*)
8601ab64890Smrg      pic_mode=default
8611ab64890Smrg      ;;
8621ab64890Smrg    esac
8631ab64890Smrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
8641ab64890Smrg      # non-PIC code in shared libraries is not supported
8651ab64890Smrg      pic_mode=default
8661ab64890Smrg    fi
8671ab64890Smrg
8681ab64890Smrg    # Calculate the filename of the output object if compiler does
8691ab64890Smrg    # not support -o with -c
8701ab64890Smrg    if test "$compiler_c_o" = no; then
8711ab64890Smrg      output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
8721ab64890Smrg      lockfile="$output_obj.lock"
8731ab64890Smrg      removelist="$removelist $output_obj $lockfile"
8741ab64890Smrg      trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
8751ab64890Smrg    else
8761ab64890Smrg      output_obj=
8771ab64890Smrg      need_locks=no
8781ab64890Smrg      lockfile=
8791ab64890Smrg    fi
8801ab64890Smrg
8811ab64890Smrg    # Lock this critical section if it is needed
8821ab64890Smrg    # We use this script file to make the link, it avoids creating a new file
8831ab64890Smrg    if test "$need_locks" = yes; then
8841ab64890Smrg      until $run ln "$progpath" "$lockfile" 2>/dev/null; do
8851ab64890Smrg	$show "Waiting for $lockfile to be removed"
8861ab64890Smrg	sleep 2
8871ab64890Smrg      done
8881ab64890Smrg    elif test "$need_locks" = warn; then
8891ab64890Smrg      if test -f "$lockfile"; then
8901ab64890Smrg	$echo "\
8911ab64890Smrg*** ERROR, $lockfile exists and contains:
8921ab64890Smrg`cat $lockfile 2>/dev/null`
8931ab64890Smrg
8941ab64890SmrgThis indicates that another process is trying to use the same
8951ab64890Smrgtemporary object file, and libtool could not work around it because
8961ab64890Smrgyour compiler does not support \`-c' and \`-o' together.  If you
8971ab64890Smrgrepeat this compilation, it may succeed, by chance, but you had better
8981ab64890Smrgavoid parallel builds (make -j) in this platform, or get a better
8991ab64890Smrgcompiler."
9001ab64890Smrg
9011ab64890Smrg	$run $rm $removelist
9021ab64890Smrg	exit $EXIT_FAILURE
9031ab64890Smrg      fi
9041ab64890Smrg      $echo "$srcfile" > "$lockfile"
9051ab64890Smrg    fi
9061ab64890Smrg
9071ab64890Smrg    if test -n "$fix_srcfile_path"; then
9081ab64890Smrg      eval srcfile=\"$fix_srcfile_path\"
9091ab64890Smrg    fi
9101ab64890Smrg    qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"`
9111ab64890Smrg    case $qsrcfile in
9121ab64890Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
9131ab64890Smrg      qsrcfile="\"$qsrcfile\"" ;;
9141ab64890Smrg    esac
9151ab64890Smrg
9161ab64890Smrg    $run $rm "$libobj" "${libobj}T"
9171ab64890Smrg
9181ab64890Smrg    # Create a libtool object file (analogous to a ".la" file),
9191ab64890Smrg    # but don't create it if we're doing a dry run.
9201ab64890Smrg    test -z "$run" && cat > ${libobj}T <<EOF
9211ab64890Smrg# $libobj - a libtool object file
9221ab64890Smrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
9231ab64890Smrg#
9241ab64890Smrg# Please DO NOT delete this file!
9251ab64890Smrg# It is necessary for linking the library.
9261ab64890Smrg
9271ab64890Smrg# Name of the PIC object.
9281ab64890SmrgEOF
9291ab64890Smrg
9301ab64890Smrg    # Only build a PIC object if we are building libtool libraries.
9311ab64890Smrg    if test "$build_libtool_libs" = yes; then
9321ab64890Smrg      # Without this assignment, base_compile gets emptied.
9331ab64890Smrg      fbsd_hideous_sh_bug=$base_compile
9341ab64890Smrg
9351ab64890Smrg      if test "$pic_mode" != no; then
9361ab64890Smrg	command="$base_compile $qsrcfile $pic_flag"
9371ab64890Smrg      else
9381ab64890Smrg	# Don't build PIC code
9391ab64890Smrg	command="$base_compile $qsrcfile"
9401ab64890Smrg      fi
9411ab64890Smrg
9421ab64890Smrg      if test ! -d "${xdir}$objdir"; then
9431ab64890Smrg	$show "$mkdir ${xdir}$objdir"
9441ab64890Smrg	$run $mkdir ${xdir}$objdir
9451ab64890Smrg	exit_status=$?
9461ab64890Smrg	if test "$exit_status" -ne 0 && test ! -d "${xdir}$objdir"; then
9471ab64890Smrg	  exit $exit_status
9481ab64890Smrg	fi
9491ab64890Smrg      fi
9501ab64890Smrg
9511ab64890Smrg      if test -z "$output_obj"; then
9521ab64890Smrg	# Place PIC objects in $objdir
9531ab64890Smrg	command="$command -o $lobj"
9541ab64890Smrg      fi
9551ab64890Smrg
9561ab64890Smrg      $run $rm "$lobj" "$output_obj"
9571ab64890Smrg
9581ab64890Smrg      $show "$command"
9591ab64890Smrg      if $run eval "$command"; then :
9601ab64890Smrg      else
9611ab64890Smrg	test -n "$output_obj" && $run $rm $removelist
9621ab64890Smrg	exit $EXIT_FAILURE
9631ab64890Smrg      fi
9641ab64890Smrg
9651ab64890Smrg      if test "$need_locks" = warn &&
9661ab64890Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
9671ab64890Smrg	$echo "\
9681ab64890Smrg*** ERROR, $lockfile contains:
9691ab64890Smrg`cat $lockfile 2>/dev/null`
9701ab64890Smrg
9711ab64890Smrgbut it should contain:
9721ab64890Smrg$srcfile
9731ab64890Smrg
9741ab64890SmrgThis indicates that another process is trying to use the same
9751ab64890Smrgtemporary object file, and libtool could not work around it because
9761ab64890Smrgyour compiler does not support \`-c' and \`-o' together.  If you
9771ab64890Smrgrepeat this compilation, it may succeed, by chance, but you had better
9781ab64890Smrgavoid parallel builds (make -j) in this platform, or get a better
9791ab64890Smrgcompiler."
9801ab64890Smrg
9811ab64890Smrg	$run $rm $removelist
9821ab64890Smrg	exit $EXIT_FAILURE
9831ab64890Smrg      fi
9841ab64890Smrg
9851ab64890Smrg      # Just move the object if needed, then go on to compile the next one
9861ab64890Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
9871ab64890Smrg	$show "$mv $output_obj $lobj"
9881ab64890Smrg	if $run $mv $output_obj $lobj; then :
9891ab64890Smrg	else
9901ab64890Smrg	  error=$?
9911ab64890Smrg	  $run $rm $removelist
9921ab64890Smrg	  exit $error
9931ab64890Smrg	fi
9941ab64890Smrg      fi
9951ab64890Smrg
9961ab64890Smrg      # Append the name of the PIC object to the libtool object file.
9971ab64890Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
9981ab64890Smrgpic_object='$objdir/$objname'
9991ab64890Smrg
10001ab64890SmrgEOF
10011ab64890Smrg
10021ab64890Smrg      # Allow error messages only from the first compilation.
10031ab64890Smrg      if test "$suppress_opt" = yes; then
10041ab64890Smrg        suppress_output=' >/dev/null 2>&1'
10051ab64890Smrg      fi
10061ab64890Smrg    else
10071ab64890Smrg      # No PIC object so indicate it doesn't exist in the libtool
10081ab64890Smrg      # object file.
10091ab64890Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
10101ab64890Smrgpic_object=none
10111ab64890Smrg
10121ab64890SmrgEOF
10131ab64890Smrg    fi
10141ab64890Smrg
10151ab64890Smrg    # Only build a position-dependent object if we build old libraries.
10161ab64890Smrg    if test "$build_old_libs" = yes; then
10171ab64890Smrg      if test "$pic_mode" != yes; then
10181ab64890Smrg	# Don't build PIC code
10191ab64890Smrg	command="$base_compile $qsrcfile"
10201ab64890Smrg      else
10211ab64890Smrg	command="$base_compile $qsrcfile $pic_flag"
10221ab64890Smrg      fi
10231ab64890Smrg      if test "$compiler_c_o" = yes; then
10241ab64890Smrg	command="$command -o $obj"
10251ab64890Smrg      fi
10261ab64890Smrg
10271ab64890Smrg      # Suppress compiler output if we already did a PIC compilation.
10281ab64890Smrg      command="$command$suppress_output"
10291ab64890Smrg      $run $rm "$obj" "$output_obj"
10301ab64890Smrg      $show "$command"
10311ab64890Smrg      if $run eval "$command"; then :
10321ab64890Smrg      else
10331ab64890Smrg	$run $rm $removelist
10341ab64890Smrg	exit $EXIT_FAILURE
10351ab64890Smrg      fi
10361ab64890Smrg
10371ab64890Smrg      if test "$need_locks" = warn &&
10381ab64890Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
10391ab64890Smrg	$echo "\
10401ab64890Smrg*** ERROR, $lockfile contains:
10411ab64890Smrg`cat $lockfile 2>/dev/null`
10421ab64890Smrg
10431ab64890Smrgbut it should contain:
10441ab64890Smrg$srcfile
10451ab64890Smrg
10461ab64890SmrgThis indicates that another process is trying to use the same
10471ab64890Smrgtemporary object file, and libtool could not work around it because
10481ab64890Smrgyour compiler does not support \`-c' and \`-o' together.  If you
10491ab64890Smrgrepeat this compilation, it may succeed, by chance, but you had better
10501ab64890Smrgavoid parallel builds (make -j) in this platform, or get a better
10511ab64890Smrgcompiler."
10521ab64890Smrg
10531ab64890Smrg	$run $rm $removelist
10541ab64890Smrg	exit $EXIT_FAILURE
10551ab64890Smrg      fi
10561ab64890Smrg
10571ab64890Smrg      # Just move the object if needed
10581ab64890Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
10591ab64890Smrg	$show "$mv $output_obj $obj"
10601ab64890Smrg	if $run $mv $output_obj $obj; then :
10611ab64890Smrg	else
10621ab64890Smrg	  error=$?
10631ab64890Smrg	  $run $rm $removelist
10641ab64890Smrg	  exit $error
10651ab64890Smrg	fi
10661ab64890Smrg      fi
10671ab64890Smrg
10681ab64890Smrg      # Append the name of the non-PIC object the libtool object file.
10691ab64890Smrg      # Only append if the libtool object file exists.
10701ab64890Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
10711ab64890Smrg# Name of the non-PIC object.
10721ab64890Smrgnon_pic_object='$objname'
10731ab64890Smrg
10741ab64890SmrgEOF
10751ab64890Smrg    else
10761ab64890Smrg      # Append the name of the non-PIC object the libtool object file.
10771ab64890Smrg      # Only append if the libtool object file exists.
10781ab64890Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
10791ab64890Smrg# Name of the non-PIC object.
10801ab64890Smrgnon_pic_object=none
10811ab64890Smrg
10821ab64890SmrgEOF
10831ab64890Smrg    fi
10841ab64890Smrg
10851ab64890Smrg    $run $mv "${libobj}T" "${libobj}"
10861ab64890Smrg
10871ab64890Smrg    # Unlock the critical section if it was locked
10881ab64890Smrg    if test "$need_locks" != no; then
10891ab64890Smrg      $run $rm "$lockfile"
10901ab64890Smrg    fi
10911ab64890Smrg
10921ab64890Smrg    exit $EXIT_SUCCESS
10931ab64890Smrg    ;;
10941ab64890Smrg
10951ab64890Smrg  # libtool link mode
10961ab64890Smrg  link | relink)
10971ab64890Smrg    modename="$modename: link"
10981ab64890Smrg    case $host in
10991ab64890Smrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
11001ab64890Smrg      # It is impossible to link a dll without this setting, and
11011ab64890Smrg      # we shouldn't force the makefile maintainer to figure out
11021ab64890Smrg      # which system we are compiling for in order to pass an extra
11031ab64890Smrg      # flag for every libtool invocation.
11041ab64890Smrg      # allow_undefined=no
11051ab64890Smrg
11061ab64890Smrg      # FIXME: Unfortunately, there are problems with the above when trying
11071ab64890Smrg      # to make a dll which has undefined symbols, in which case not
11081ab64890Smrg      # even a static library is built.  For now, we need to specify
11091ab64890Smrg      # -no-undefined on the libtool link line when we can be certain
11101ab64890Smrg      # that all symbols are satisfied, otherwise we get a static library.
11111ab64890Smrg      allow_undefined=yes
11121ab64890Smrg      ;;
11131ab64890Smrg    *)
11141ab64890Smrg      allow_undefined=yes
11151ab64890Smrg      ;;
11161ab64890Smrg    esac
11171ab64890Smrg    libtool_args="$nonopt"
11181ab64890Smrg    base_compile="$nonopt $@"
11191ab64890Smrg    compile_command="$nonopt"
11201ab64890Smrg    finalize_command="$nonopt"
11211ab64890Smrg
11221ab64890Smrg    compile_rpath=
11231ab64890Smrg    finalize_rpath=
11241ab64890Smrg    compile_shlibpath=
11251ab64890Smrg    finalize_shlibpath=
11261ab64890Smrg    convenience=
11271ab64890Smrg    old_convenience=
11281ab64890Smrg    deplibs=
11291ab64890Smrg    old_deplibs=
11301ab64890Smrg    compiler_flags=
11311ab64890Smrg    linker_flags=
11321ab64890Smrg    dllsearchpath=
11331ab64890Smrg    lib_search_path=`pwd`
11341ab64890Smrg    inst_prefix_dir=
11351ab64890Smrg
11361ab64890Smrg    avoid_version=no
11371ab64890Smrg    dlfiles=
11381ab64890Smrg    dlprefiles=
11391ab64890Smrg    dlself=no
11401ab64890Smrg    export_dynamic=no
11411ab64890Smrg    export_symbols=
11421ab64890Smrg    export_symbols_regex=
11431ab64890Smrg    generated=
11441ab64890Smrg    libobjs=
11451ab64890Smrg    ltlibs=
11461ab64890Smrg    module=no
11471ab64890Smrg    no_install=no
11481ab64890Smrg    objs=
11491ab64890Smrg    non_pic_objects=
11501ab64890Smrg    notinst_path= # paths that contain not-installed libtool libraries
11511ab64890Smrg    precious_files_regex=
11521ab64890Smrg    prefer_static_libs=no
11531ab64890Smrg    preload=no
11541ab64890Smrg    prev=
11551ab64890Smrg    prevarg=
11561ab64890Smrg    release=
11571ab64890Smrg    rpath=
11581ab64890Smrg    xrpath=
11591ab64890Smrg    perm_rpath=
11601ab64890Smrg    temp_rpath=
11611ab64890Smrg    thread_safe=no
11621ab64890Smrg    vinfo=
11631ab64890Smrg    vinfo_number=no
11641ab64890Smrg
11651ab64890Smrg    func_infer_tag $base_compile
11661ab64890Smrg
11671ab64890Smrg    # We need to know -static, to get the right output filenames.
11681ab64890Smrg    for arg
11691ab64890Smrg    do
11701ab64890Smrg      case $arg in
11711ab64890Smrg      -all-static | -static | -static-libtool-libs)
11721ab64890Smrg	case $arg in
11731ab64890Smrg	-all-static)
11741ab64890Smrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
11751ab64890Smrg	    $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
11761ab64890Smrg	  fi
11771ab64890Smrg	  if test -n "$link_static_flag"; then
11781ab64890Smrg	    dlopen_self=$dlopen_self_static
11791ab64890Smrg	  fi
11801ab64890Smrg	  prefer_static_libs=yes
11811ab64890Smrg	  ;;
11821ab64890Smrg	-static)
11831ab64890Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
11841ab64890Smrg	    dlopen_self=$dlopen_self_static
11851ab64890Smrg	  fi
11861ab64890Smrg	  prefer_static_libs=built
11871ab64890Smrg	  ;;
11881ab64890Smrg	-static-libtool-libs)
11891ab64890Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
11901ab64890Smrg	    dlopen_self=$dlopen_self_static
11911ab64890Smrg	  fi
11921ab64890Smrg	  prefer_static_libs=yes
11931ab64890Smrg	  ;;
11941ab64890Smrg	esac
11951ab64890Smrg	build_libtool_libs=no
11961ab64890Smrg	build_old_libs=yes
11971ab64890Smrg	break
11981ab64890Smrg	;;
11991ab64890Smrg      esac
12001ab64890Smrg    done
12011ab64890Smrg
12021ab64890Smrg    # See if our shared archives depend on static archives.
12031ab64890Smrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
12041ab64890Smrg
12051ab64890Smrg    # Go through the arguments, transforming them on the way.
12061ab64890Smrg    while test "$#" -gt 0; do
12071ab64890Smrg      arg="$1"
12081ab64890Smrg      shift
12091ab64890Smrg      case $arg in
12101ab64890Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
12111ab64890Smrg	qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test
12121ab64890Smrg	;;
12131ab64890Smrg      *) qarg=$arg ;;
12141ab64890Smrg      esac
12151ab64890Smrg      libtool_args="$libtool_args $qarg"
12161ab64890Smrg
12171ab64890Smrg      # If the previous option needs an argument, assign it.
12181ab64890Smrg      if test -n "$prev"; then
12191ab64890Smrg	case $prev in
12201ab64890Smrg	output)
12211ab64890Smrg	  compile_command="$compile_command @OUTPUT@"
12221ab64890Smrg	  finalize_command="$finalize_command @OUTPUT@"
12231ab64890Smrg	  ;;
12241ab64890Smrg	esac
12251ab64890Smrg
12261ab64890Smrg	case $prev in
12271ab64890Smrg	dlfiles|dlprefiles)
12281ab64890Smrg	  if test "$preload" = no; then
12291ab64890Smrg	    # Add the symbol object into the linking commands.
12301ab64890Smrg	    compile_command="$compile_command @SYMFILE@"
12311ab64890Smrg	    finalize_command="$finalize_command @SYMFILE@"
12321ab64890Smrg	    preload=yes
12331ab64890Smrg	  fi
12341ab64890Smrg	  case $arg in
12351ab64890Smrg	  *.la | *.lo) ;;  # We handle these cases below.
12361ab64890Smrg	  force)
12371ab64890Smrg	    if test "$dlself" = no; then
12381ab64890Smrg	      dlself=needless
12391ab64890Smrg	      export_dynamic=yes
12401ab64890Smrg	    fi
12411ab64890Smrg	    prev=
12421ab64890Smrg	    continue
12431ab64890Smrg	    ;;
12441ab64890Smrg	  self)
12451ab64890Smrg	    if test "$prev" = dlprefiles; then
12461ab64890Smrg	      dlself=yes
12471ab64890Smrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
12481ab64890Smrg	      dlself=yes
12491ab64890Smrg	    else
12501ab64890Smrg	      dlself=needless
12511ab64890Smrg	      export_dynamic=yes
12521ab64890Smrg	    fi
12531ab64890Smrg	    prev=
12541ab64890Smrg	    continue
12551ab64890Smrg	    ;;
12561ab64890Smrg	  *)
12571ab64890Smrg	    if test "$prev" = dlfiles; then
12581ab64890Smrg	      dlfiles="$dlfiles $arg"
12591ab64890Smrg	    else
12601ab64890Smrg	      dlprefiles="$dlprefiles $arg"
12611ab64890Smrg	    fi
12621ab64890Smrg	    prev=
12631ab64890Smrg	    continue
12641ab64890Smrg	    ;;
12651ab64890Smrg	  esac
12661ab64890Smrg	  ;;
12671ab64890Smrg	expsyms)
12681ab64890Smrg	  export_symbols="$arg"
12691ab64890Smrg	  if test ! -f "$arg"; then
12701ab64890Smrg	    $echo "$modename: symbol file \`$arg' does not exist"
12711ab64890Smrg	    exit $EXIT_FAILURE
12721ab64890Smrg	  fi
12731ab64890Smrg	  prev=
12741ab64890Smrg	  continue
12751ab64890Smrg	  ;;
12761ab64890Smrg	expsyms_regex)
12771ab64890Smrg	  export_symbols_regex="$arg"
12781ab64890Smrg	  prev=
12791ab64890Smrg	  continue
12801ab64890Smrg	  ;;
12811ab64890Smrg	inst_prefix)
12821ab64890Smrg	  inst_prefix_dir="$arg"
12831ab64890Smrg	  prev=
12841ab64890Smrg	  continue
12851ab64890Smrg	  ;;
12861ab64890Smrg	precious_regex)
12871ab64890Smrg	  precious_files_regex="$arg"
12881ab64890Smrg	  prev=
12891ab64890Smrg	  continue
12901ab64890Smrg	  ;;
12911ab64890Smrg	release)
12921ab64890Smrg	  release="-$arg"
12931ab64890Smrg	  prev=
12941ab64890Smrg	  continue
12951ab64890Smrg	  ;;
12961ab64890Smrg	objectlist)
12971ab64890Smrg	  if test -f "$arg"; then
12981ab64890Smrg	    save_arg=$arg
12991ab64890Smrg	    moreargs=
13001ab64890Smrg	    for fil in `cat $save_arg`
13011ab64890Smrg	    do
13021ab64890Smrg#	      moreargs="$moreargs $fil"
13031ab64890Smrg	      arg=$fil
13041ab64890Smrg	      # A libtool-controlled object.
13051ab64890Smrg
13061ab64890Smrg	      # Check to see that this really is a libtool object.
13071ab64890Smrg	      if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
13081ab64890Smrg		pic_object=
13091ab64890Smrg		non_pic_object=
13101ab64890Smrg
13111ab64890Smrg		# Read the .lo file
13121ab64890Smrg		# If there is no directory component, then add one.
13131ab64890Smrg		case $arg in
13141ab64890Smrg		*/* | *\\*) . $arg ;;
13151ab64890Smrg		*) . ./$arg ;;
13161ab64890Smrg		esac
13171ab64890Smrg
13181ab64890Smrg		if test -z "$pic_object" || \
13191ab64890Smrg		   test -z "$non_pic_object" ||
13201ab64890Smrg		   test "$pic_object" = none && \
13211ab64890Smrg		   test "$non_pic_object" = none; then
13221ab64890Smrg		  $echo "$modename: cannot find name of object for \`$arg'" 1>&2
13231ab64890Smrg		  exit $EXIT_FAILURE
13241ab64890Smrg		fi
13251ab64890Smrg
13261ab64890Smrg		# Extract subdirectory from the argument.
13271ab64890Smrg		xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
13281ab64890Smrg		if test "X$xdir" = "X$arg"; then
13291ab64890Smrg		  xdir=
13301ab64890Smrg		else
13311ab64890Smrg		  xdir="$xdir/"
13321ab64890Smrg		fi
13331ab64890Smrg
13341ab64890Smrg		if test "$pic_object" != none; then
13351ab64890Smrg		  # Prepend the subdirectory the object is found in.
13361ab64890Smrg		  pic_object="$xdir$pic_object"
13371ab64890Smrg
13381ab64890Smrg		  if test "$prev" = dlfiles; then
13391ab64890Smrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
13401ab64890Smrg		      dlfiles="$dlfiles $pic_object"
13411ab64890Smrg		      prev=
13421ab64890Smrg		      continue
13431ab64890Smrg		    else
13441ab64890Smrg		      # If libtool objects are unsupported, then we need to preload.
13451ab64890Smrg		      prev=dlprefiles
13461ab64890Smrg		    fi
13471ab64890Smrg		  fi
13481ab64890Smrg
13491ab64890Smrg		  # CHECK ME:  I think I busted this.  -Ossama
13501ab64890Smrg		  if test "$prev" = dlprefiles; then
13511ab64890Smrg		    # Preload the old-style object.
13521ab64890Smrg		    dlprefiles="$dlprefiles $pic_object"
13531ab64890Smrg		    prev=
13541ab64890Smrg		  fi
13551ab64890Smrg
13561ab64890Smrg		  # A PIC object.
13571ab64890Smrg		  libobjs="$libobjs $pic_object"
13581ab64890Smrg		  arg="$pic_object"
13591ab64890Smrg		fi
13601ab64890Smrg
13611ab64890Smrg		# Non-PIC object.
13621ab64890Smrg		if test "$non_pic_object" != none; then
13631ab64890Smrg		  # Prepend the subdirectory the object is found in.
13641ab64890Smrg		  non_pic_object="$xdir$non_pic_object"
13651ab64890Smrg
13661ab64890Smrg		  # A standard non-PIC object
13671ab64890Smrg		  non_pic_objects="$non_pic_objects $non_pic_object"
13681ab64890Smrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
13691ab64890Smrg		    arg="$non_pic_object"
13701ab64890Smrg		  fi
13711ab64890Smrg		else
13721ab64890Smrg		  # If the PIC object exists, use it instead.
13731ab64890Smrg		  # $xdir was prepended to $pic_object above.
13741ab64890Smrg		  non_pic_object="$pic_object"
13751ab64890Smrg		  non_pic_objects="$non_pic_objects $non_pic_object"
13761ab64890Smrg		fi
13771ab64890Smrg	      else
13781ab64890Smrg		# Only an error if not doing a dry-run.
13791ab64890Smrg		if test -z "$run"; then
13801ab64890Smrg		  $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
13811ab64890Smrg		  exit $EXIT_FAILURE
13821ab64890Smrg		else
13831ab64890Smrg		  # Dry-run case.
13841ab64890Smrg
13851ab64890Smrg		  # Extract subdirectory from the argument.
13861ab64890Smrg		  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
13871ab64890Smrg		  if test "X$xdir" = "X$arg"; then
13881ab64890Smrg		    xdir=
13891ab64890Smrg		  else
13901ab64890Smrg		    xdir="$xdir/"
13911ab64890Smrg		  fi
13921ab64890Smrg
13931ab64890Smrg		  pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
13941ab64890Smrg		  non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
13951ab64890Smrg		  libobjs="$libobjs $pic_object"
13961ab64890Smrg		  non_pic_objects="$non_pic_objects $non_pic_object"
13971ab64890Smrg		fi
13981ab64890Smrg	      fi
13991ab64890Smrg	    done
14001ab64890Smrg	  else
14011ab64890Smrg	    $echo "$modename: link input file \`$save_arg' does not exist"
14021ab64890Smrg	    exit $EXIT_FAILURE
14031ab64890Smrg	  fi
14041ab64890Smrg	  arg=$save_arg
14051ab64890Smrg	  prev=
14061ab64890Smrg	  continue
14071ab64890Smrg	  ;;
14081ab64890Smrg	rpath | xrpath)
14091ab64890Smrg	  # We need an absolute path.
14101ab64890Smrg	  case $arg in
14111ab64890Smrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
14121ab64890Smrg	  *)
14131ab64890Smrg	    $echo "$modename: only absolute run-paths are allowed" 1>&2
14141ab64890Smrg	    exit $EXIT_FAILURE
14151ab64890Smrg	    ;;
14161ab64890Smrg	  esac
14171ab64890Smrg	  if test "$prev" = rpath; then
14181ab64890Smrg	    case "$rpath " in
14191ab64890Smrg	    *" $arg "*) ;;
14201ab64890Smrg	    *) rpath="$rpath $arg" ;;
14211ab64890Smrg	    esac
14221ab64890Smrg	  else
14231ab64890Smrg	    case "$xrpath " in
14241ab64890Smrg	    *" $arg "*) ;;
14251ab64890Smrg	    *) xrpath="$xrpath $arg" ;;
14261ab64890Smrg	    esac
14271ab64890Smrg	  fi
14281ab64890Smrg	  prev=
14291ab64890Smrg	  continue
14301ab64890Smrg	  ;;
14311ab64890Smrg	xcompiler)
14321ab64890Smrg	  compiler_flags="$compiler_flags $qarg"
14331ab64890Smrg	  prev=
14341ab64890Smrg	  compile_command="$compile_command $qarg"
14351ab64890Smrg	  finalize_command="$finalize_command $qarg"
14361ab64890Smrg	  continue
14371ab64890Smrg	  ;;
14381ab64890Smrg	xlinker)
14391ab64890Smrg	  linker_flags="$linker_flags $qarg"
14401ab64890Smrg	  compiler_flags="$compiler_flags $wl$qarg"
14411ab64890Smrg	  prev=
14421ab64890Smrg	  compile_command="$compile_command $wl$qarg"
14431ab64890Smrg	  finalize_command="$finalize_command $wl$qarg"
14441ab64890Smrg	  continue
14451ab64890Smrg	  ;;
14461ab64890Smrg	xcclinker)
14471ab64890Smrg	  linker_flags="$linker_flags $qarg"
14481ab64890Smrg	  compiler_flags="$compiler_flags $qarg"
14491ab64890Smrg	  prev=
14501ab64890Smrg	  compile_command="$compile_command $qarg"
14511ab64890Smrg	  finalize_command="$finalize_command $qarg"
14521ab64890Smrg	  continue
14531ab64890Smrg	  ;;
14541ab64890Smrg	shrext)
14551ab64890Smrg  	  shrext_cmds="$arg"
14561ab64890Smrg	  prev=
14571ab64890Smrg	  continue
14581ab64890Smrg	  ;;
14591ab64890Smrg	darwin_framework|darwin_framework_skip)
14601ab64890Smrg	  test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg"
14611ab64890Smrg	  compile_command="$compile_command $arg"
14621ab64890Smrg	  finalize_command="$finalize_command $arg"
14631ab64890Smrg	  prev=
14641ab64890Smrg	  continue
14651ab64890Smrg	  ;;
14661ab64890Smrg	*)
14671ab64890Smrg	  eval "$prev=\"\$arg\""
14681ab64890Smrg	  prev=
14691ab64890Smrg	  continue
14701ab64890Smrg	  ;;
14711ab64890Smrg	esac
14721ab64890Smrg      fi # test -n "$prev"
14731ab64890Smrg
14741ab64890Smrg      prevarg="$arg"
14751ab64890Smrg
14761ab64890Smrg      case $arg in
14771ab64890Smrg      -all-static)
14781ab64890Smrg	if test -n "$link_static_flag"; then
14791ab64890Smrg	  compile_command="$compile_command $link_static_flag"
14801ab64890Smrg	  finalize_command="$finalize_command $link_static_flag"
14811ab64890Smrg	fi
14821ab64890Smrg	continue
14831ab64890Smrg	;;
14841ab64890Smrg
14851ab64890Smrg      -allow-undefined)
14861ab64890Smrg	# FIXME: remove this flag sometime in the future.
14871ab64890Smrg	$echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
14881ab64890Smrg	continue
14891ab64890Smrg	;;
14901ab64890Smrg
14911ab64890Smrg      -avoid-version)
14921ab64890Smrg	avoid_version=yes
14931ab64890Smrg	continue
14941ab64890Smrg	;;
14951ab64890Smrg
14961ab64890Smrg      -dlopen)
14971ab64890Smrg	prev=dlfiles
14981ab64890Smrg	continue
14991ab64890Smrg	;;
15001ab64890Smrg
15011ab64890Smrg      -dlpreopen)
15021ab64890Smrg	prev=dlprefiles
15031ab64890Smrg	continue
15041ab64890Smrg	;;
15051ab64890Smrg
15061ab64890Smrg      -export-dynamic)
15071ab64890Smrg	export_dynamic=yes
15081ab64890Smrg	continue
15091ab64890Smrg	;;
15101ab64890Smrg
15111ab64890Smrg      -export-symbols | -export-symbols-regex)
15121ab64890Smrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
15131ab64890Smrg	  $echo "$modename: more than one -exported-symbols argument is not allowed"
15141ab64890Smrg	  exit $EXIT_FAILURE
15151ab64890Smrg	fi
15161ab64890Smrg	if test "X$arg" = "X-export-symbols"; then
15171ab64890Smrg	  prev=expsyms
15181ab64890Smrg	else
15191ab64890Smrg	  prev=expsyms_regex
15201ab64890Smrg	fi
15211ab64890Smrg	continue
15221ab64890Smrg	;;
15231ab64890Smrg
15241ab64890Smrg      -framework|-arch|-isysroot)
15251ab64890Smrg	case " $CC " in
15261ab64890Smrg	  *" ${arg} ${1} "* | *" ${arg}	${1} "*) 
15271ab64890Smrg		prev=darwin_framework_skip ;;
15281ab64890Smrg	  *) compiler_flags="$compiler_flags $arg"
15291ab64890Smrg	     prev=darwin_framework ;;
15301ab64890Smrg	esac
15311ab64890Smrg	compile_command="$compile_command $arg"
15321ab64890Smrg	finalize_command="$finalize_command $arg"
15331ab64890Smrg	continue
15341ab64890Smrg	;;
15351ab64890Smrg
15361ab64890Smrg      -inst-prefix-dir)
15371ab64890Smrg	prev=inst_prefix
15381ab64890Smrg	continue
15391ab64890Smrg	;;
15401ab64890Smrg
15411ab64890Smrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
15421ab64890Smrg      # so, if we see these flags be careful not to treat them like -L
15431ab64890Smrg      -L[A-Z][A-Z]*:*)
15441ab64890Smrg	case $with_gcc/$host in
15451ab64890Smrg	no/*-*-irix* | /*-*-irix*)
15461ab64890Smrg	  compile_command="$compile_command $arg"
15471ab64890Smrg	  finalize_command="$finalize_command $arg"
15481ab64890Smrg	  ;;
15491ab64890Smrg	esac
15501ab64890Smrg	continue
15511ab64890Smrg	;;
15521ab64890Smrg
15531ab64890Smrg      -L*)
15541ab64890Smrg	dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
15551ab64890Smrg	# We need an absolute path.
15561ab64890Smrg	case $dir in
15571ab64890Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
15581ab64890Smrg	*)
15591ab64890Smrg	  absdir=`cd "$dir" && pwd`
15601ab64890Smrg	  if test -z "$absdir"; then
15611ab64890Smrg	    $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
15621ab64890Smrg	    absdir="$dir"
15631ab64890Smrg	    notinst_path="$notinst_path $dir"
15641ab64890Smrg	  fi
15651ab64890Smrg	  dir="$absdir"
15661ab64890Smrg	  ;;
15671ab64890Smrg	esac
15681ab64890Smrg	case "$deplibs " in
15691ab64890Smrg	*" -L$dir "*) ;;
15701ab64890Smrg	*)
15711ab64890Smrg	  deplibs="$deplibs -L$dir"
15721ab64890Smrg	  lib_search_path="$lib_search_path $dir"
15731ab64890Smrg	  ;;
15741ab64890Smrg	esac
15751ab64890Smrg	case $host in
15761ab64890Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
15771ab64890Smrg	  testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'`
15781ab64890Smrg	  case :$dllsearchpath: in
15791ab64890Smrg	  *":$dir:"*) ;;
15801ab64890Smrg	  *) dllsearchpath="$dllsearchpath:$dir";;
15811ab64890Smrg	  esac
15821ab64890Smrg	  case :$dllsearchpath: in
15831ab64890Smrg	  *":$testbindir:"*) ;;
15841ab64890Smrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
15851ab64890Smrg	  esac
15861ab64890Smrg	  ;;
15871ab64890Smrg	esac
15881ab64890Smrg	continue
15891ab64890Smrg	;;
15901ab64890Smrg
15911ab64890Smrg      -l*)
15921ab64890Smrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
15931ab64890Smrg	  case $host in
15941ab64890Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*)
15951ab64890Smrg	    # These systems don't actually have a C or math library (as such)
15961ab64890Smrg	    continue
15971ab64890Smrg	    ;;
15981ab64890Smrg	  *-*-os2*)
15991ab64890Smrg	    # These systems don't actually have a C library (as such)
16001ab64890Smrg	    test "X$arg" = "X-lc" && continue
16011ab64890Smrg	    ;;
16021ab64890Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
16031ab64890Smrg	    # Do not include libc due to us having libc/libc_r.
16041ab64890Smrg	    test "X$arg" = "X-lc" && continue
16051ab64890Smrg	    ;;
16061ab64890Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
16071ab64890Smrg	    # Rhapsody C and math libraries are in the System framework
16081ab64890Smrg	    deplibs="$deplibs -framework System"
16091ab64890Smrg	    continue
16101ab64890Smrg	    ;;
16111ab64890Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
16121ab64890Smrg	    # Causes problems with __ctype
16131ab64890Smrg	    test "X$arg" = "X-lc" && continue
16141ab64890Smrg	    ;;
16151ab64890Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
16161ab64890Smrg	    # Compiler inserts libc in the correct place for threads to work
16171ab64890Smrg	    test "X$arg" = "X-lc" && continue
16181ab64890Smrg	    ;;
16191ab64890Smrg	  esac
16201ab64890Smrg	elif test "X$arg" = "X-lc_r"; then
16211ab64890Smrg	 case $host in
16221ab64890Smrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
16231ab64890Smrg	   # Do not include libc_r directly, use -pthread flag.
16241ab64890Smrg	   continue
16251ab64890Smrg	   ;;
16261ab64890Smrg	 esac
16271ab64890Smrg	fi
16281ab64890Smrg	deplibs="$deplibs $arg"
16291ab64890Smrg	continue
16301ab64890Smrg	;;
16311ab64890Smrg
16321ab64890Smrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
16331ab64890Smrg      # classes, name mangling, and exception handling.
16341ab64890Smrg      -model)
16351ab64890Smrg	compile_command="$compile_command $arg"
16361ab64890Smrg	compiler_flags="$compiler_flags $arg"
16371ab64890Smrg	finalize_command="$finalize_command $arg"
16381ab64890Smrg	prev=xcompiler
16391ab64890Smrg	continue
16401ab64890Smrg	;;
16411ab64890Smrg
16421ab64890Smrg     -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
16431ab64890Smrg	compiler_flags="$compiler_flags $arg"
16441ab64890Smrg	compile_command="$compile_command $arg"
16451ab64890Smrg	finalize_command="$finalize_command $arg"
16461ab64890Smrg	continue
16471ab64890Smrg	;;
16481ab64890Smrg
16491ab64890Smrg      -module)
16501ab64890Smrg	module=yes
16511ab64890Smrg	continue
16521ab64890Smrg	;;
16531ab64890Smrg
16541ab64890Smrg      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
16551ab64890Smrg      # -r[0-9][0-9]* specifies the processor on the SGI compiler
16561ab64890Smrg      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
16571ab64890Smrg      # +DA*, +DD* enable 64-bit mode on the HP compiler
16581ab64890Smrg      # -q* pass through compiler args for the IBM compiler
16591ab64890Smrg      # -m* pass through architecture-specific compiler args for GCC
16601ab64890Smrg      # -m*, -t[45]*, -txscale* pass through architecture-specific
16611ab64890Smrg      # compiler args for GCC
16621ab64890Smrg      # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
16631ab64890Smrg      # -F/path gives path to uninstalled frameworks, gcc on darwin
16641ab64890Smrg      # @file GCC response files
16651ab64890Smrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
16661ab64890Smrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*)
16671ab64890Smrg
16681ab64890Smrg	# Unknown arguments in both finalize_command and compile_command need
16691ab64890Smrg	# to be aesthetically quoted because they are evaled later.
16701ab64890Smrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
16711ab64890Smrg	case $arg in
16721ab64890Smrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
16731ab64890Smrg	  arg="\"$arg\""
16741ab64890Smrg	  ;;
16751ab64890Smrg	esac
16761ab64890Smrg        compile_command="$compile_command $arg"
16771ab64890Smrg        finalize_command="$finalize_command $arg"
16781ab64890Smrg        compiler_flags="$compiler_flags $arg"
16791ab64890Smrg        continue
16801ab64890Smrg        ;;
16811ab64890Smrg
16821ab64890Smrg      -shrext)
16831ab64890Smrg	prev=shrext
16841ab64890Smrg	continue
16851ab64890Smrg	;;
16861ab64890Smrg
16871ab64890Smrg      -no-fast-install)
16881ab64890Smrg	fast_install=no
16891ab64890Smrg	continue
16901ab64890Smrg	;;
16911ab64890Smrg
16921ab64890Smrg      -no-install)
16931ab64890Smrg	case $host in
16941ab64890Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin*)
16951ab64890Smrg	  # The PATH hackery in wrapper scripts is required on Windows
16961ab64890Smrg	  # and Darwin in order for the loader to find any dlls it needs.
16971ab64890Smrg	  $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2
16981ab64890Smrg	  $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2
16991ab64890Smrg	  fast_install=no
17001ab64890Smrg	  ;;
17011ab64890Smrg	*) no_install=yes ;;
17021ab64890Smrg	esac
17031ab64890Smrg	continue
17041ab64890Smrg	;;
17051ab64890Smrg
17061ab64890Smrg      -no-undefined)
17071ab64890Smrg	allow_undefined=no
17081ab64890Smrg	continue
17091ab64890Smrg	;;
17101ab64890Smrg
17111ab64890Smrg      -objectlist)
17121ab64890Smrg	prev=objectlist
17131ab64890Smrg	continue
17141ab64890Smrg	;;
17151ab64890Smrg
17161ab64890Smrg      -o) prev=output ;;
17171ab64890Smrg
17181ab64890Smrg      -precious-files-regex)
17191ab64890Smrg	prev=precious_regex
17201ab64890Smrg	continue
17211ab64890Smrg	;;
17221ab64890Smrg
17231ab64890Smrg      -release)
17241ab64890Smrg	prev=release
17251ab64890Smrg	continue
17261ab64890Smrg	;;
17271ab64890Smrg
17281ab64890Smrg      -rpath)
17291ab64890Smrg	prev=rpath
17301ab64890Smrg	continue
17311ab64890Smrg	;;
17321ab64890Smrg
17331ab64890Smrg      -R)
17341ab64890Smrg	prev=xrpath
17351ab64890Smrg	continue
17361ab64890Smrg	;;
17371ab64890Smrg
17381ab64890Smrg      -R*)
17391ab64890Smrg	dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
17401ab64890Smrg	# We need an absolute path.
17411ab64890Smrg	case $dir in
17421ab64890Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
17431ab64890Smrg	*)
17441ab64890Smrg	  $echo "$modename: only absolute run-paths are allowed" 1>&2
17451ab64890Smrg	  exit $EXIT_FAILURE
17461ab64890Smrg	  ;;
17471ab64890Smrg	esac
17481ab64890Smrg	case "$xrpath " in
17491ab64890Smrg	*" $dir "*) ;;
17501ab64890Smrg	*) xrpath="$xrpath $dir" ;;
17511ab64890Smrg	esac
17521ab64890Smrg	continue
17531ab64890Smrg	;;
17541ab64890Smrg
17551ab64890Smrg      -static | -static-libtool-libs)
17561ab64890Smrg	# The effects of -static are defined in a previous loop.
17571ab64890Smrg	# We used to do the same as -all-static on platforms that
17581ab64890Smrg	# didn't have a PIC flag, but the assumption that the effects
17591ab64890Smrg	# would be equivalent was wrong.  It would break on at least
17601ab64890Smrg	# Digital Unix and AIX.
17611ab64890Smrg	continue
17621ab64890Smrg	;;
17631ab64890Smrg
17641ab64890Smrg      -thread-safe)
17651ab64890Smrg	thread_safe=yes
17661ab64890Smrg	continue
17671ab64890Smrg	;;
17681ab64890Smrg
17691ab64890Smrg      -version-info)
17701ab64890Smrg	prev=vinfo
17711ab64890Smrg	continue
17721ab64890Smrg	;;
17731ab64890Smrg      -version-number)
17741ab64890Smrg	prev=vinfo
17751ab64890Smrg	vinfo_number=yes
17761ab64890Smrg	continue
17771ab64890Smrg	;;
17781ab64890Smrg
17791ab64890Smrg      -Wc,*)
17801ab64890Smrg	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'`
17811ab64890Smrg	arg=
17821ab64890Smrg	save_ifs="$IFS"; IFS=','
17831ab64890Smrg	for flag in $args; do
17841ab64890Smrg	  IFS="$save_ifs"
17851ab64890Smrg	  case $flag in
17861ab64890Smrg	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
17871ab64890Smrg	    flag="\"$flag\""
17881ab64890Smrg	    ;;
17891ab64890Smrg	  esac
17901ab64890Smrg	  arg="$arg $wl$flag"
17911ab64890Smrg	  compiler_flags="$compiler_flags $flag"
17921ab64890Smrg	done
17931ab64890Smrg	IFS="$save_ifs"
17941ab64890Smrg	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
17951ab64890Smrg	;;
17961ab64890Smrg
17971ab64890Smrg      -Wl,*)
17981ab64890Smrg	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'`
17991ab64890Smrg	arg=
18001ab64890Smrg	save_ifs="$IFS"; IFS=','
18011ab64890Smrg	for flag in $args; do
18021ab64890Smrg	  IFS="$save_ifs"
18031ab64890Smrg	  case $flag in
18041ab64890Smrg	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
18051ab64890Smrg	    flag="\"$flag\""
18061ab64890Smrg	    ;;
18071ab64890Smrg	  esac
18081ab64890Smrg	  arg="$arg $wl$flag"
18091ab64890Smrg	  compiler_flags="$compiler_flags $wl$flag"
18101ab64890Smrg	  linker_flags="$linker_flags $flag"
18111ab64890Smrg	done
18121ab64890Smrg	IFS="$save_ifs"
18131ab64890Smrg	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
18141ab64890Smrg	;;
18151ab64890Smrg
18161ab64890Smrg      -Xcompiler)
18171ab64890Smrg	prev=xcompiler
18181ab64890Smrg	continue
18191ab64890Smrg	;;
18201ab64890Smrg
18211ab64890Smrg      -Xlinker)
18221ab64890Smrg	prev=xlinker
18231ab64890Smrg	continue
18241ab64890Smrg	;;
18251ab64890Smrg
18261ab64890Smrg      -XCClinker)
18271ab64890Smrg	prev=xcclinker
18281ab64890Smrg	continue
18291ab64890Smrg	;;
18301ab64890Smrg
18311ab64890Smrg      # Some other compiler flag.
18321ab64890Smrg      -* | +*)
18331ab64890Smrg	# Unknown arguments in both finalize_command and compile_command need
18341ab64890Smrg	# to be aesthetically quoted because they are evaled later.
18351ab64890Smrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
18361ab64890Smrg	case $arg in
18371ab64890Smrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
18381ab64890Smrg	  arg="\"$arg\""
18391ab64890Smrg	  ;;
18401ab64890Smrg	esac
18411ab64890Smrg	;;
18421ab64890Smrg
18431ab64890Smrg      *.$objext)
18441ab64890Smrg	# A standard object.
18451ab64890Smrg	objs="$objs $arg"
18461ab64890Smrg	;;
18471ab64890Smrg
18481ab64890Smrg      *.lo)
18491ab64890Smrg	# A libtool-controlled object.
18501ab64890Smrg
18511ab64890Smrg	# Check to see that this really is a libtool object.
18521ab64890Smrg	if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
18531ab64890Smrg	  pic_object=
18541ab64890Smrg	  non_pic_object=
18551ab64890Smrg
18561ab64890Smrg	  # Read the .lo file
18571ab64890Smrg	  # If there is no directory component, then add one.
18581ab64890Smrg	  case $arg in
18591ab64890Smrg	  */* | *\\*) . $arg ;;
18601ab64890Smrg	  *) . ./$arg ;;
18611ab64890Smrg	  esac
18621ab64890Smrg
18631ab64890Smrg	  if test -z "$pic_object" || \
18641ab64890Smrg	     test -z "$non_pic_object" ||
18651ab64890Smrg	     test "$pic_object" = none && \
18661ab64890Smrg	     test "$non_pic_object" = none; then
18671ab64890Smrg	    $echo "$modename: cannot find name of object for \`$arg'" 1>&2
18681ab64890Smrg	    exit $EXIT_FAILURE
18691ab64890Smrg	  fi
18701ab64890Smrg
18711ab64890Smrg	  # Extract subdirectory from the argument.
18721ab64890Smrg	  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
18731ab64890Smrg	  if test "X$xdir" = "X$arg"; then
18741ab64890Smrg	    xdir=
18751ab64890Smrg 	  else
18761ab64890Smrg	    xdir="$xdir/"
18771ab64890Smrg	  fi
18781ab64890Smrg
18791ab64890Smrg	  if test "$pic_object" != none; then
18801ab64890Smrg	    # Prepend the subdirectory the object is found in.
18811ab64890Smrg	    pic_object="$xdir$pic_object"
18821ab64890Smrg
18831ab64890Smrg	    if test "$prev" = dlfiles; then
18841ab64890Smrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
18851ab64890Smrg		dlfiles="$dlfiles $pic_object"
18861ab64890Smrg		prev=
18871ab64890Smrg		continue
18881ab64890Smrg	      else
18891ab64890Smrg		# If libtool objects are unsupported, then we need to preload.
18901ab64890Smrg		prev=dlprefiles
18911ab64890Smrg	      fi
18921ab64890Smrg	    fi
18931ab64890Smrg
18941ab64890Smrg	    # CHECK ME:  I think I busted this.  -Ossama
18951ab64890Smrg	    if test "$prev" = dlprefiles; then
18961ab64890Smrg	      # Preload the old-style object.
18971ab64890Smrg	      dlprefiles="$dlprefiles $pic_object"
18981ab64890Smrg	      prev=
18991ab64890Smrg	    fi
19001ab64890Smrg
19011ab64890Smrg	    # A PIC object.
19021ab64890Smrg	    libobjs="$libobjs $pic_object"
19031ab64890Smrg	    arg="$pic_object"
19041ab64890Smrg	  fi
19051ab64890Smrg
19061ab64890Smrg	  # Non-PIC object.
19071ab64890Smrg	  if test "$non_pic_object" != none; then
19081ab64890Smrg	    # Prepend the subdirectory the object is found in.
19091ab64890Smrg	    non_pic_object="$xdir$non_pic_object"
19101ab64890Smrg
19111ab64890Smrg	    # A standard non-PIC object
19121ab64890Smrg	    non_pic_objects="$non_pic_objects $non_pic_object"
19131ab64890Smrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
19141ab64890Smrg	      arg="$non_pic_object"
19151ab64890Smrg	    fi
19161ab64890Smrg	  else
19171ab64890Smrg	    # If the PIC object exists, use it instead.
19181ab64890Smrg	    # $xdir was prepended to $pic_object above.
19191ab64890Smrg	    non_pic_object="$pic_object"
19201ab64890Smrg	    non_pic_objects="$non_pic_objects $non_pic_object"
19211ab64890Smrg	  fi
19221ab64890Smrg	else
19231ab64890Smrg	  # Only an error if not doing a dry-run.
19241ab64890Smrg	  if test -z "$run"; then
19251ab64890Smrg	    $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
19261ab64890Smrg	    exit $EXIT_FAILURE
19271ab64890Smrg	  else
19281ab64890Smrg	    # Dry-run case.
19291ab64890Smrg
19301ab64890Smrg	    # Extract subdirectory from the argument.
19311ab64890Smrg	    xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
19321ab64890Smrg	    if test "X$xdir" = "X$arg"; then
19331ab64890Smrg	      xdir=
19341ab64890Smrg	    else
19351ab64890Smrg	      xdir="$xdir/"
19361ab64890Smrg	    fi
19371ab64890Smrg
19381ab64890Smrg	    pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
19391ab64890Smrg	    non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
19401ab64890Smrg	    libobjs="$libobjs $pic_object"
19411ab64890Smrg	    non_pic_objects="$non_pic_objects $non_pic_object"
19421ab64890Smrg	  fi
19431ab64890Smrg	fi
19441ab64890Smrg	;;
19451ab64890Smrg
19461ab64890Smrg      *.$libext)
19471ab64890Smrg	# An archive.
19481ab64890Smrg	deplibs="$deplibs $arg"
19491ab64890Smrg	old_deplibs="$old_deplibs $arg"
19501ab64890Smrg	continue
19511ab64890Smrg	;;
19521ab64890Smrg
19531ab64890Smrg      *.la)
19541ab64890Smrg	# A libtool-controlled library.
19551ab64890Smrg
19561ab64890Smrg	if test "$prev" = dlfiles; then
19571ab64890Smrg	  # This library was specified with -dlopen.
19581ab64890Smrg	  dlfiles="$dlfiles $arg"
19591ab64890Smrg	  prev=
19601ab64890Smrg	elif test "$prev" = dlprefiles; then
19611ab64890Smrg	  # The library was specified with -dlpreopen.
19621ab64890Smrg	  dlprefiles="$dlprefiles $arg"
19631ab64890Smrg	  prev=
19641ab64890Smrg	else
19651ab64890Smrg	  deplibs="$deplibs $arg"
19661ab64890Smrg	fi
19671ab64890Smrg	continue
19681ab64890Smrg	;;
19691ab64890Smrg
19701ab64890Smrg      # Some other compiler argument.
19711ab64890Smrg      *)
19721ab64890Smrg	# Unknown arguments in both finalize_command and compile_command need
19731ab64890Smrg	# to be aesthetically quoted because they are evaled later.
19741ab64890Smrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
19751ab64890Smrg	case $arg in
19761ab64890Smrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
19771ab64890Smrg	  arg="\"$arg\""
19781ab64890Smrg	  ;;
19791ab64890Smrg	esac
19801ab64890Smrg	;;
19811ab64890Smrg      esac # arg
19821ab64890Smrg
19831ab64890Smrg      # Now actually substitute the argument into the commands.
19841ab64890Smrg      if test -n "$arg"; then
19851ab64890Smrg	compile_command="$compile_command $arg"
19861ab64890Smrg	finalize_command="$finalize_command $arg"
19871ab64890Smrg      fi
19881ab64890Smrg    done # argument parsing loop
19891ab64890Smrg
19901ab64890Smrg    if test -n "$prev"; then
19911ab64890Smrg      $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
19921ab64890Smrg      $echo "$help" 1>&2
19931ab64890Smrg      exit $EXIT_FAILURE
19941ab64890Smrg    fi
19951ab64890Smrg
19961ab64890Smrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
19971ab64890Smrg      eval arg=\"$export_dynamic_flag_spec\"
19981ab64890Smrg      compile_command="$compile_command $arg"
19991ab64890Smrg      finalize_command="$finalize_command $arg"
20001ab64890Smrg    fi
20011ab64890Smrg
20021ab64890Smrg    oldlibs=
20031ab64890Smrg    # calculate the name of the file, without its directory
20041ab64890Smrg    outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
20051ab64890Smrg    libobjs_save="$libobjs"
20061ab64890Smrg
20071ab64890Smrg    if test -n "$shlibpath_var"; then
20081ab64890Smrg      # get the directories listed in $shlibpath_var
20091ab64890Smrg      eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
20101ab64890Smrg    else
20111ab64890Smrg      shlib_search_path=
20121ab64890Smrg    fi
20131ab64890Smrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
20141ab64890Smrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
20151ab64890Smrg
20161ab64890Smrg    output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
20171ab64890Smrg    if test "X$output_objdir" = "X$output"; then
20181ab64890Smrg      output_objdir="$objdir"
20191ab64890Smrg    else
20201ab64890Smrg      output_objdir="$output_objdir/$objdir"
20211ab64890Smrg    fi
20221ab64890Smrg    # Create the object directory.
20231ab64890Smrg    if test ! -d "$output_objdir"; then
20241ab64890Smrg      $show "$mkdir $output_objdir"
20251ab64890Smrg      $run $mkdir $output_objdir
20261ab64890Smrg      exit_status=$?
20271ab64890Smrg      if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then
20281ab64890Smrg	exit $exit_status
20291ab64890Smrg      fi
20301ab64890Smrg    fi
20311ab64890Smrg
20321ab64890Smrg    # Determine the type of output
20331ab64890Smrg    case $output in
20341ab64890Smrg    "")
20351ab64890Smrg      $echo "$modename: you must specify an output file" 1>&2
20361ab64890Smrg      $echo "$help" 1>&2
20371ab64890Smrg      exit $EXIT_FAILURE
20381ab64890Smrg      ;;
20391ab64890Smrg    *.$libext) linkmode=oldlib ;;
20401ab64890Smrg    *.lo | *.$objext) linkmode=obj ;;
20411ab64890Smrg    *.la) linkmode=lib ;;
20421ab64890Smrg    *) linkmode=prog ;; # Anything else should be a program.
20431ab64890Smrg    esac
20441ab64890Smrg
20451ab64890Smrg    case $host in
20461ab64890Smrg    *cygwin* | *mingw* | *pw32*)
20471ab64890Smrg      # don't eliminate duplications in $postdeps and $predeps
20481ab64890Smrg      duplicate_compiler_generated_deps=yes
20491ab64890Smrg      ;;
20501ab64890Smrg    *)
20511ab64890Smrg      duplicate_compiler_generated_deps=$duplicate_deps
20521ab64890Smrg      ;;
20531ab64890Smrg    esac
20541ab64890Smrg    specialdeplibs=
20551ab64890Smrg
20561ab64890Smrg    libs=
20571ab64890Smrg    # Find all interdependent deplibs by searching for libraries
20581ab64890Smrg    # that are linked more than once (e.g. -la -lb -la)
20591ab64890Smrg    for deplib in $deplibs; do
20601ab64890Smrg      if test "X$duplicate_deps" = "Xyes" ; then
20611ab64890Smrg	case "$libs " in
20621ab64890Smrg	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
20631ab64890Smrg	esac
20641ab64890Smrg      fi
20651ab64890Smrg      libs="$libs $deplib"
20661ab64890Smrg    done
20671ab64890Smrg
20681ab64890Smrg    if test "$linkmode" = lib; then
20691ab64890Smrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
20701ab64890Smrg
20711ab64890Smrg      # Compute libraries that are listed more than once in $predeps
20721ab64890Smrg      # $postdeps and mark them as special (i.e., whose duplicates are
20731ab64890Smrg      # not to be eliminated).
20741ab64890Smrg      pre_post_deps=
20751ab64890Smrg      if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then
20761ab64890Smrg	for pre_post_dep in $predeps $postdeps; do
20771ab64890Smrg	  case "$pre_post_deps " in
20781ab64890Smrg	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
20791ab64890Smrg	  esac
20801ab64890Smrg	  pre_post_deps="$pre_post_deps $pre_post_dep"
20811ab64890Smrg	done
20821ab64890Smrg      fi
20831ab64890Smrg      pre_post_deps=
20841ab64890Smrg    fi
20851ab64890Smrg
20861ab64890Smrg    deplibs=
20871ab64890Smrg    newdependency_libs=
20881ab64890Smrg    newlib_search_path=
20891ab64890Smrg    need_relink=no # whether we're linking any uninstalled libtool libraries
20901ab64890Smrg    notinst_deplibs= # not-installed libtool libraries
20911ab64890Smrg    case $linkmode in
20921ab64890Smrg    lib)
20931ab64890Smrg	passes="conv link"
20941ab64890Smrg	for file in $dlfiles $dlprefiles; do
20951ab64890Smrg	  case $file in
20961ab64890Smrg	  *.la) ;;
20971ab64890Smrg	  *)
20981ab64890Smrg	    $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2
20991ab64890Smrg	    exit $EXIT_FAILURE
21001ab64890Smrg	    ;;
21011ab64890Smrg	  esac
21021ab64890Smrg	done
21031ab64890Smrg	;;
21041ab64890Smrg    prog)
21051ab64890Smrg	compile_deplibs=
21061ab64890Smrg	finalize_deplibs=
21071ab64890Smrg	alldeplibs=no
21081ab64890Smrg	newdlfiles=
21091ab64890Smrg	newdlprefiles=
21101ab64890Smrg	passes="conv scan dlopen dlpreopen link"
21111ab64890Smrg	;;
21121ab64890Smrg    *)  passes="conv"
21131ab64890Smrg	;;
21141ab64890Smrg    esac
21151ab64890Smrg    for pass in $passes; do
21161ab64890Smrg      if test "$linkmode,$pass" = "lib,link" ||
21171ab64890Smrg	 test "$linkmode,$pass" = "prog,scan"; then
21181ab64890Smrg	libs="$deplibs"
21191ab64890Smrg	deplibs=
21201ab64890Smrg      fi
21211ab64890Smrg      if test "$linkmode" = prog; then
21221ab64890Smrg	case $pass in
21231ab64890Smrg	dlopen) libs="$dlfiles" ;;
21241ab64890Smrg	dlpreopen) libs="$dlprefiles" ;;
21251ab64890Smrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
21261ab64890Smrg	esac
21271ab64890Smrg      fi
21281ab64890Smrg      if test "$pass" = dlopen; then
21291ab64890Smrg	# Collect dlpreopened libraries
21301ab64890Smrg	save_deplibs="$deplibs"
21311ab64890Smrg	deplibs=
21321ab64890Smrg      fi
21331ab64890Smrg      for deplib in $libs; do
21341ab64890Smrg	lib=
21351ab64890Smrg	found=no
21361ab64890Smrg	case $deplib in
21371ab64890Smrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
21381ab64890Smrg	  if test "$linkmode,$pass" = "prog,link"; then
21391ab64890Smrg	    compile_deplibs="$deplib $compile_deplibs"
21401ab64890Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
21411ab64890Smrg	  else
21421ab64890Smrg	    compiler_flags="$compiler_flags $deplib"
21431ab64890Smrg	  fi
21441ab64890Smrg	  continue
21451ab64890Smrg	  ;;
21461ab64890Smrg	-l*)
21471ab64890Smrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
21481ab64890Smrg	    $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2
21491ab64890Smrg	    continue
21501ab64890Smrg	  fi
21511ab64890Smrg	  name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
21521ab64890Smrg	  for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do
21531ab64890Smrg	    for search_ext in .la $std_shrext .so .a; do
21541ab64890Smrg	      # Search the libtool library
21551ab64890Smrg	      lib="$searchdir/lib${name}${search_ext}"
21561ab64890Smrg	      if test -f "$lib"; then
21571ab64890Smrg		if test "$search_ext" = ".la"; then
21581ab64890Smrg		  found=yes
21591ab64890Smrg		else
21601ab64890Smrg		  found=no
21611ab64890Smrg		fi
21621ab64890Smrg		break 2
21631ab64890Smrg	      fi
21641ab64890Smrg	    done
21651ab64890Smrg	  done
21661ab64890Smrg	  if test "$found" != yes; then
21671ab64890Smrg	    # deplib doesn't seem to be a libtool library
21681ab64890Smrg	    if test "$linkmode,$pass" = "prog,link"; then
21691ab64890Smrg	      compile_deplibs="$deplib $compile_deplibs"
21701ab64890Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
21711ab64890Smrg	    else
21721ab64890Smrg	      deplibs="$deplib $deplibs"
21731ab64890Smrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
21741ab64890Smrg	    fi
21751ab64890Smrg	    continue
21761ab64890Smrg	  else # deplib is a libtool library
21771ab64890Smrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
21781ab64890Smrg	    # We need to do some special things here, and not later.
21791ab64890Smrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
21801ab64890Smrg	      case " $predeps $postdeps " in
21811ab64890Smrg	      *" $deplib "*)
21821ab64890Smrg		if (${SED} -e '2q' $lib |
21831ab64890Smrg                    grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
21841ab64890Smrg		  library_names=
21851ab64890Smrg		  old_library=
21861ab64890Smrg		  case $lib in
21871ab64890Smrg		  */* | *\\*) . $lib ;;
21881ab64890Smrg		  *) . ./$lib ;;
21891ab64890Smrg		  esac
21901ab64890Smrg		  for l in $old_library $library_names; do
21911ab64890Smrg		    ll="$l"
21921ab64890Smrg		  done
21931ab64890Smrg		  if test "X$ll" = "X$old_library" ; then # only static version available
21941ab64890Smrg		    found=no
21951ab64890Smrg		    ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
21961ab64890Smrg		    test "X$ladir" = "X$lib" && ladir="."
21971ab64890Smrg		    lib=$ladir/$old_library
21981ab64890Smrg		    if test "$linkmode,$pass" = "prog,link"; then
21991ab64890Smrg		      compile_deplibs="$deplib $compile_deplibs"
22001ab64890Smrg		      finalize_deplibs="$deplib $finalize_deplibs"
22011ab64890Smrg		    else
22021ab64890Smrg		      deplibs="$deplib $deplibs"
22031ab64890Smrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
22041ab64890Smrg		    fi
22051ab64890Smrg		    continue
22061ab64890Smrg		  fi
22071ab64890Smrg		fi
22081ab64890Smrg	        ;;
22091ab64890Smrg	      *) ;;
22101ab64890Smrg	      esac
22111ab64890Smrg	    fi
22121ab64890Smrg	  fi
22131ab64890Smrg	  ;; # -l
22141ab64890Smrg	-L*)
22151ab64890Smrg	  case $linkmode in
22161ab64890Smrg	  lib)
22171ab64890Smrg	    deplibs="$deplib $deplibs"
22181ab64890Smrg	    test "$pass" = conv && continue
22191ab64890Smrg	    newdependency_libs="$deplib $newdependency_libs"
22201ab64890Smrg	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
22211ab64890Smrg	    ;;
22221ab64890Smrg	  prog)
22231ab64890Smrg	    if test "$pass" = conv; then
22241ab64890Smrg	      deplibs="$deplib $deplibs"
22251ab64890Smrg	      continue
22261ab64890Smrg	    fi
22271ab64890Smrg	    if test "$pass" = scan; then
22281ab64890Smrg	      deplibs="$deplib $deplibs"
22291ab64890Smrg	    else
22301ab64890Smrg	      compile_deplibs="$deplib $compile_deplibs"
22311ab64890Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
22321ab64890Smrg	    fi
22331ab64890Smrg	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
22341ab64890Smrg	    ;;
22351ab64890Smrg	  *)
22361ab64890Smrg	    $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2
22371ab64890Smrg	    ;;
22381ab64890Smrg	  esac # linkmode
22391ab64890Smrg	  continue
22401ab64890Smrg	  ;; # -L
22411ab64890Smrg	-R*)
22421ab64890Smrg	  if test "$pass" = link; then
22431ab64890Smrg	    dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
22441ab64890Smrg	    # Make sure the xrpath contains only unique directories.
22451ab64890Smrg	    case "$xrpath " in
22461ab64890Smrg	    *" $dir "*) ;;
22471ab64890Smrg	    *) xrpath="$xrpath $dir" ;;
22481ab64890Smrg	    esac
22491ab64890Smrg	  fi
22501ab64890Smrg	  deplibs="$deplib $deplibs"
22511ab64890Smrg	  continue
22521ab64890Smrg	  ;;
22531ab64890Smrg	*.la) lib="$deplib" ;;
22541ab64890Smrg	*.$libext)
22551ab64890Smrg	  if test "$pass" = conv; then
22561ab64890Smrg	    deplibs="$deplib $deplibs"
22571ab64890Smrg	    continue
22581ab64890Smrg	  fi
22591ab64890Smrg	  case $linkmode in
22601ab64890Smrg	  lib)
22611ab64890Smrg	    valid_a_lib=no
22621ab64890Smrg	    case $deplibs_check_method in
22631ab64890Smrg	      match_pattern*)
22641ab64890Smrg		set dummy $deplibs_check_method
22651ab64890Smrg	        match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
22661ab64890Smrg		if eval $echo \"$deplib\" 2>/dev/null \
22671ab64890Smrg		    | $SED 10q \
22681ab64890Smrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
22691ab64890Smrg		  valid_a_lib=yes
22701ab64890Smrg		fi
22711ab64890Smrg		;;
22721ab64890Smrg	      pass_all)
22731ab64890Smrg		valid_a_lib=yes
22741ab64890Smrg		;;
22751ab64890Smrg            esac
22761ab64890Smrg	    if test "$valid_a_lib" != yes; then
22771ab64890Smrg	      $echo
22781ab64890Smrg	      $echo "*** Warning: Trying to link with static lib archive $deplib."
22791ab64890Smrg	      $echo "*** I have the capability to make that library automatically link in when"
22801ab64890Smrg	      $echo "*** you link to this library.  But I can only do this if you have a"
22811ab64890Smrg	      $echo "*** shared version of the library, which you do not appear to have"
22821ab64890Smrg	      $echo "*** because the file extensions .$libext of this argument makes me believe"
22831ab64890Smrg	      $echo "*** that it is just a static archive that I should not used here."
22841ab64890Smrg	    else
22851ab64890Smrg	      $echo
22861ab64890Smrg	      $echo "*** Warning: Linking the shared library $output against the"
22871ab64890Smrg	      $echo "*** static library $deplib is not portable!"
22881ab64890Smrg	      deplibs="$deplib $deplibs"
22891ab64890Smrg	    fi
22901ab64890Smrg	    continue
22911ab64890Smrg	    ;;
22921ab64890Smrg	  prog)
22931ab64890Smrg	    if test "$pass" != link; then
22941ab64890Smrg	      deplibs="$deplib $deplibs"
22951ab64890Smrg	    else
22961ab64890Smrg	      compile_deplibs="$deplib $compile_deplibs"
22971ab64890Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
22981ab64890Smrg	    fi
22991ab64890Smrg	    continue
23001ab64890Smrg	    ;;
23011ab64890Smrg	  esac # linkmode
23021ab64890Smrg	  ;; # *.$libext
23031ab64890Smrg	*.lo | *.$objext)
23041ab64890Smrg	  if test "$pass" = conv; then
23051ab64890Smrg	    deplibs="$deplib $deplibs"
23061ab64890Smrg	  elif test "$linkmode" = prog; then
23071ab64890Smrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
23081ab64890Smrg	      # If there is no dlopen support or we're linking statically,
23091ab64890Smrg	      # we need to preload.
23101ab64890Smrg	      newdlprefiles="$newdlprefiles $deplib"
23111ab64890Smrg	      compile_deplibs="$deplib $compile_deplibs"
23121ab64890Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
23131ab64890Smrg	    else
23141ab64890Smrg	      newdlfiles="$newdlfiles $deplib"
23151ab64890Smrg	    fi
23161ab64890Smrg	  fi
23171ab64890Smrg	  continue
23181ab64890Smrg	  ;;
23191ab64890Smrg	%DEPLIBS%)
23201ab64890Smrg	  alldeplibs=yes
23211ab64890Smrg	  continue
23221ab64890Smrg	  ;;
23231ab64890Smrg	esac # case $deplib
23241ab64890Smrg	if test "$found" = yes || test -f "$lib"; then :
23251ab64890Smrg	else
23261ab64890Smrg	  $echo "$modename: cannot find the library \`$lib' or unhandled argument \`$deplib'" 1>&2
23271ab64890Smrg	  exit $EXIT_FAILURE
23281ab64890Smrg	fi
23291ab64890Smrg
23301ab64890Smrg	# Check to see that this really is a libtool archive.
23311ab64890Smrg	if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
23321ab64890Smrg	else
23331ab64890Smrg	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
23341ab64890Smrg	  exit $EXIT_FAILURE
23351ab64890Smrg	fi
23361ab64890Smrg
23371ab64890Smrg	ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
23381ab64890Smrg	test "X$ladir" = "X$lib" && ladir="."
23391ab64890Smrg
23401ab64890Smrg	dlname=
23411ab64890Smrg	dlopen=
23421ab64890Smrg	dlpreopen=
23431ab64890Smrg	libdir=
23441ab64890Smrg	library_names=
23451ab64890Smrg	old_library=
23461ab64890Smrg	# If the library was installed with an old release of libtool,
23471ab64890Smrg	# it will not redefine variables installed, or shouldnotlink
23481ab64890Smrg	installed=yes
23491ab64890Smrg	shouldnotlink=no
23501ab64890Smrg	avoidtemprpath=
23511ab64890Smrg
23521ab64890Smrg
23531ab64890Smrg	# Read the .la file
23541ab64890Smrg	case $lib in
23551ab64890Smrg	*/* | *\\*) . $lib ;;
23561ab64890Smrg	*) . ./$lib ;;
23571ab64890Smrg	esac
23581ab64890Smrg
23591ab64890Smrg	if test "$linkmode,$pass" = "lib,link" ||
23601ab64890Smrg	   test "$linkmode,$pass" = "prog,scan" ||
23611ab64890Smrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
23621ab64890Smrg	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
23631ab64890Smrg	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
23641ab64890Smrg	fi
23651ab64890Smrg
23661ab64890Smrg	if test "$pass" = conv; then
23671ab64890Smrg	  # Only check for convenience libraries
23681ab64890Smrg	  deplibs="$lib $deplibs"
23691ab64890Smrg	  if test -z "$libdir"; then
23701ab64890Smrg	    if test -z "$old_library"; then
23711ab64890Smrg	      $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
23721ab64890Smrg	      exit $EXIT_FAILURE
23731ab64890Smrg	    fi
23741ab64890Smrg	    # It is a libtool convenience library, so add in its objects.
23751ab64890Smrg	    convenience="$convenience $ladir/$objdir/$old_library"
23761ab64890Smrg	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
23771ab64890Smrg	    tmp_libs=
23781ab64890Smrg	    for deplib in $dependency_libs; do
23791ab64890Smrg	      deplibs="$deplib $deplibs"
23801ab64890Smrg              if test "X$duplicate_deps" = "Xyes" ; then
23811ab64890Smrg	        case "$tmp_libs " in
23821ab64890Smrg	        *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
23831ab64890Smrg	        esac
23841ab64890Smrg              fi
23851ab64890Smrg	      tmp_libs="$tmp_libs $deplib"
23861ab64890Smrg	    done
23871ab64890Smrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
23881ab64890Smrg	    $echo "$modename: \`$lib' is not a convenience library" 1>&2
23891ab64890Smrg	    exit $EXIT_FAILURE
23901ab64890Smrg	  fi
23911ab64890Smrg	  continue
23921ab64890Smrg	fi # $pass = conv
23931ab64890Smrg
23941ab64890Smrg
23951ab64890Smrg	# Get the name of the library we link against.
23961ab64890Smrg	linklib=
23971ab64890Smrg	for l in $old_library $library_names; do
23981ab64890Smrg	  linklib="$l"
23991ab64890Smrg	done
24001ab64890Smrg	if test -z "$linklib"; then
24011ab64890Smrg	  $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
24021ab64890Smrg	  exit $EXIT_FAILURE
24031ab64890Smrg	fi
24041ab64890Smrg
24051ab64890Smrg	# This library was specified with -dlopen.
24061ab64890Smrg	if test "$pass" = dlopen; then
24071ab64890Smrg	  if test -z "$libdir"; then
24081ab64890Smrg	    $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2
24091ab64890Smrg	    exit $EXIT_FAILURE
24101ab64890Smrg	  fi
24111ab64890Smrg	  if test -z "$dlname" ||
24121ab64890Smrg	     test "$dlopen_support" != yes ||
24131ab64890Smrg	     test "$build_libtool_libs" = no; then
24141ab64890Smrg	    # If there is no dlname, no dlopen support or we're linking
24151ab64890Smrg	    # statically, we need to preload.  We also need to preload any
24161ab64890Smrg	    # dependent libraries so libltdl's deplib preloader doesn't
24171ab64890Smrg	    # bomb out in the load deplibs phase.
24181ab64890Smrg	    dlprefiles="$dlprefiles $lib $dependency_libs"
24191ab64890Smrg	  else
24201ab64890Smrg	    newdlfiles="$newdlfiles $lib"
24211ab64890Smrg	  fi
24221ab64890Smrg	  continue
24231ab64890Smrg	fi # $pass = dlopen
24241ab64890Smrg
24251ab64890Smrg	# We need an absolute path.
24261ab64890Smrg	case $ladir in
24271ab64890Smrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
24281ab64890Smrg	*)
24291ab64890Smrg	  abs_ladir=`cd "$ladir" && pwd`
24301ab64890Smrg	  if test -z "$abs_ladir"; then
24311ab64890Smrg	    $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2
24321ab64890Smrg	    $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
24331ab64890Smrg	    abs_ladir="$ladir"
24341ab64890Smrg	  fi
24351ab64890Smrg	  ;;
24361ab64890Smrg	esac
24371ab64890Smrg	laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
24381ab64890Smrg
24391ab64890Smrg	# Find the relevant object directory and library name.
24401ab64890Smrg	if test "X$installed" = Xyes; then
24411ab64890Smrg	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
24421ab64890Smrg	    $echo "$modename: warning: library \`$lib' was moved." 1>&2
24431ab64890Smrg	    dir="$ladir"
24441ab64890Smrg	    absdir="$abs_ladir"
24451ab64890Smrg	    libdir="$abs_ladir"
24461ab64890Smrg	  else
24471ab64890Smrg	    dir="$libdir"
24481ab64890Smrg	    absdir="$libdir"
24491ab64890Smrg	  fi
24501ab64890Smrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
24511ab64890Smrg	else
24521ab64890Smrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
24531ab64890Smrg	    dir="$ladir"
24541ab64890Smrg	    absdir="$abs_ladir"
24551ab64890Smrg	    # Remove this search path later
24561ab64890Smrg	    notinst_path="$notinst_path $abs_ladir"
24571ab64890Smrg	  else
24581ab64890Smrg	    dir="$ladir/$objdir"
24591ab64890Smrg	    absdir="$abs_ladir/$objdir"
24601ab64890Smrg	    # Remove this search path later
24611ab64890Smrg	    notinst_path="$notinst_path $abs_ladir"
24621ab64890Smrg	  fi
24631ab64890Smrg	fi # $installed = yes
24641ab64890Smrg	name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
24651ab64890Smrg
24661ab64890Smrg	# This library was specified with -dlpreopen.
24671ab64890Smrg	if test "$pass" = dlpreopen; then
24681ab64890Smrg	  if test -z "$libdir"; then
24691ab64890Smrg	    $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2
24701ab64890Smrg	    exit $EXIT_FAILURE
24711ab64890Smrg	  fi
24721ab64890Smrg	  # Prefer using a static library (so that no silly _DYNAMIC symbols
24731ab64890Smrg	  # are required to link).
24741ab64890Smrg	  if test -n "$old_library"; then
24751ab64890Smrg	    newdlprefiles="$newdlprefiles $dir/$old_library"
24761ab64890Smrg	  # Otherwise, use the dlname, so that lt_dlopen finds it.
24771ab64890Smrg	  elif test -n "$dlname"; then
24781ab64890Smrg	    newdlprefiles="$newdlprefiles $dir/$dlname"
24791ab64890Smrg	  else
24801ab64890Smrg	    newdlprefiles="$newdlprefiles $dir/$linklib"
24811ab64890Smrg	  fi
24821ab64890Smrg	fi # $pass = dlpreopen
24831ab64890Smrg
24841ab64890Smrg	if test -z "$libdir"; then
24851ab64890Smrg	  # Link the convenience library
24861ab64890Smrg	  if test "$linkmode" = lib; then
24871ab64890Smrg	    deplibs="$dir/$old_library $deplibs"
24881ab64890Smrg	  elif test "$linkmode,$pass" = "prog,link"; then
24891ab64890Smrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
24901ab64890Smrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
24911ab64890Smrg	  else
24921ab64890Smrg	    deplibs="$lib $deplibs" # used for prog,scan pass
24931ab64890Smrg	  fi
24941ab64890Smrg	  continue
24951ab64890Smrg	fi
24961ab64890Smrg
24971ab64890Smrg
24981ab64890Smrg	if test "$linkmode" = prog && test "$pass" != link; then
24991ab64890Smrg	  newlib_search_path="$newlib_search_path $ladir"
25001ab64890Smrg	  deplibs="$lib $deplibs"
25011ab64890Smrg
25021ab64890Smrg	  linkalldeplibs=no
25031ab64890Smrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
25041ab64890Smrg	     test "$build_libtool_libs" = no; then
25051ab64890Smrg	    linkalldeplibs=yes
25061ab64890Smrg	  fi
25071ab64890Smrg
25081ab64890Smrg	  tmp_libs=
25091ab64890Smrg	  for deplib in $dependency_libs; do
25101ab64890Smrg	    case $deplib in
25111ab64890Smrg	    -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test
25121ab64890Smrg	    esac
25131ab64890Smrg	    # Need to link against all dependency_libs?
25141ab64890Smrg	    if test "$linkalldeplibs" = yes; then
25151ab64890Smrg	      deplibs="$deplib $deplibs"
25161ab64890Smrg	    else
25171ab64890Smrg	      # Need to hardcode shared library paths
25181ab64890Smrg	      # or/and link against static libraries
25191ab64890Smrg	      newdependency_libs="$deplib $newdependency_libs"
25201ab64890Smrg	    fi
25211ab64890Smrg	    if test "X$duplicate_deps" = "Xyes" ; then
25221ab64890Smrg	      case "$tmp_libs " in
25231ab64890Smrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
25241ab64890Smrg	      esac
25251ab64890Smrg	    fi
25261ab64890Smrg	    tmp_libs="$tmp_libs $deplib"
25271ab64890Smrg	  done # for deplib
25281ab64890Smrg	  continue
25291ab64890Smrg	fi # $linkmode = prog...
25301ab64890Smrg
25311ab64890Smrg	if test "$linkmode,$pass" = "prog,link"; then
25321ab64890Smrg	  if test -n "$library_names" &&
25331ab64890Smrg	     { { test "$prefer_static_libs" = no ||
25341ab64890Smrg		 test "$prefer_static_libs,$installed" = "built,yes"; } ||
25351ab64890Smrg	       test -z "$old_library"; }; then
25361ab64890Smrg	    # We need to hardcode the library path
25371ab64890Smrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
25381ab64890Smrg	      # Make sure the rpath contains only unique directories.
25391ab64890Smrg	      case "$temp_rpath " in
25401ab64890Smrg	      *" $dir "*) ;;
25411ab64890Smrg	      *" $absdir "*) ;;
25421ab64890Smrg	      *) temp_rpath="$temp_rpath $absdir" ;;
25431ab64890Smrg	      esac
25441ab64890Smrg	    fi
25451ab64890Smrg
25461ab64890Smrg	    # Hardcode the library path.
25471ab64890Smrg	    # Skip directories that are in the system default run-time
25481ab64890Smrg	    # search path.
25491ab64890Smrg	    case " $sys_lib_dlsearch_path " in
25501ab64890Smrg	    *" $absdir "*) ;;
25511ab64890Smrg	    *)
25521ab64890Smrg	      case "$compile_rpath " in
25531ab64890Smrg	      *" $absdir "*) ;;
25541ab64890Smrg	      *) compile_rpath="$compile_rpath $absdir"
25551ab64890Smrg	      esac
25561ab64890Smrg	      ;;
25571ab64890Smrg	    esac
25581ab64890Smrg	    case " $sys_lib_dlsearch_path " in
25591ab64890Smrg	    *" $libdir "*) ;;
25601ab64890Smrg	    *)
25611ab64890Smrg	      case "$finalize_rpath " in
25621ab64890Smrg	      *" $libdir "*) ;;
25631ab64890Smrg	      *) finalize_rpath="$finalize_rpath $libdir"
25641ab64890Smrg	      esac
25651ab64890Smrg	      ;;
25661ab64890Smrg	    esac
25671ab64890Smrg	  fi # $linkmode,$pass = prog,link...
25681ab64890Smrg
25691ab64890Smrg	  if test "$alldeplibs" = yes &&
25701ab64890Smrg	     { test "$deplibs_check_method" = pass_all ||
25711ab64890Smrg	       { test "$build_libtool_libs" = yes &&
25721ab64890Smrg		 test -n "$library_names"; }; }; then
25731ab64890Smrg	    # We only need to search for static libraries
25741ab64890Smrg	    continue
25751ab64890Smrg	  fi
25761ab64890Smrg	fi
25771ab64890Smrg
25781ab64890Smrg	link_static=no # Whether the deplib will be linked statically
25791ab64890Smrg	use_static_libs=$prefer_static_libs
25801ab64890Smrg	if test "$use_static_libs" = built && test "$installed" = yes ; then
25811ab64890Smrg	  use_static_libs=no
25821ab64890Smrg	fi
25831ab64890Smrg	if test -n "$library_names" &&
25841ab64890Smrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
25851ab64890Smrg	  if test "$installed" = no; then
25861ab64890Smrg	    notinst_deplibs="$notinst_deplibs $lib"
25871ab64890Smrg	    need_relink=yes
25881ab64890Smrg	  fi
25891ab64890Smrg	  # This is a shared library
25901ab64890Smrg
25911ab64890Smrg	  # Warn about portability, can't link against -module's on
25921ab64890Smrg	  # some systems (darwin)
25931ab64890Smrg	  if test "$shouldnotlink" = yes && test "$pass" = link ; then
25941ab64890Smrg	    $echo
25951ab64890Smrg	    if test "$linkmode" = prog; then
25961ab64890Smrg	      $echo "*** Warning: Linking the executable $output against the loadable module"
25971ab64890Smrg	    else
25981ab64890Smrg	      $echo "*** Warning: Linking the shared library $output against the loadable module"
25991ab64890Smrg	    fi
26001ab64890Smrg	    $echo "*** $linklib is not portable!"
26011ab64890Smrg	  fi
26021ab64890Smrg	  if test "$linkmode" = lib &&
26031ab64890Smrg	     test "$hardcode_into_libs" = yes; then
26041ab64890Smrg	    # Hardcode the library path.
26051ab64890Smrg	    # Skip directories that are in the system default run-time
26061ab64890Smrg	    # search path.
26071ab64890Smrg	    case " $sys_lib_dlsearch_path " in
26081ab64890Smrg	    *" $absdir "*) ;;
26091ab64890Smrg	    *)
26101ab64890Smrg	      case "$compile_rpath " in
26111ab64890Smrg	      *" $absdir "*) ;;
26121ab64890Smrg	      *) compile_rpath="$compile_rpath $absdir"
26131ab64890Smrg	      esac
26141ab64890Smrg	      ;;
26151ab64890Smrg	    esac
26161ab64890Smrg	    case " $sys_lib_dlsearch_path " in
26171ab64890Smrg	    *" $libdir "*) ;;
26181ab64890Smrg	    *)
26191ab64890Smrg	      case "$finalize_rpath " in
26201ab64890Smrg	      *" $libdir "*) ;;
26211ab64890Smrg	      *) finalize_rpath="$finalize_rpath $libdir"
26221ab64890Smrg	      esac
26231ab64890Smrg	      ;;
26241ab64890Smrg	    esac
26251ab64890Smrg	  fi
26261ab64890Smrg
26271ab64890Smrg	  if test -n "$old_archive_from_expsyms_cmds"; then
26281ab64890Smrg	    # figure out the soname
26291ab64890Smrg	    set dummy $library_names
26301ab64890Smrg	    realname="$2"
26311ab64890Smrg	    shift; shift
26321ab64890Smrg	    libname=`eval \\$echo \"$libname_spec\"`
26331ab64890Smrg	    # use dlname if we got it. it's perfectly good, no?
26341ab64890Smrg	    if test -n "$dlname"; then
26351ab64890Smrg	      soname="$dlname"
26361ab64890Smrg	    elif test -n "$soname_spec"; then
26371ab64890Smrg	      # bleh windows
26381ab64890Smrg	      case $host in
26391ab64890Smrg	      *cygwin* | mingw*)
26401ab64890Smrg		major=`expr $current - $age`
26411ab64890Smrg		versuffix="-$major"
26421ab64890Smrg		;;
26431ab64890Smrg	      esac
26441ab64890Smrg	      eval soname=\"$soname_spec\"
26451ab64890Smrg	    else
26461ab64890Smrg	      soname="$realname"
26471ab64890Smrg	    fi
26481ab64890Smrg
26491ab64890Smrg	    # Make a new name for the extract_expsyms_cmds to use
26501ab64890Smrg	    soroot="$soname"
26511ab64890Smrg	    soname=`$echo $soroot | ${SED} -e 's/^.*\///'`
26521ab64890Smrg	    newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a"
26531ab64890Smrg
26541ab64890Smrg	    # If the library has no export list, then create one now
26551ab64890Smrg	    if test -f "$output_objdir/$soname-def"; then :
26561ab64890Smrg	    else
26571ab64890Smrg	      $show "extracting exported symbol list from \`$soname'"
26581ab64890Smrg	      save_ifs="$IFS"; IFS='~'
26591ab64890Smrg	      cmds=$extract_expsyms_cmds
26601ab64890Smrg	      for cmd in $cmds; do
26611ab64890Smrg		IFS="$save_ifs"
26621ab64890Smrg		eval cmd=\"$cmd\"
26631ab64890Smrg		$show "$cmd"
26641ab64890Smrg		$run eval "$cmd" || exit $?
26651ab64890Smrg	      done
26661ab64890Smrg	      IFS="$save_ifs"
26671ab64890Smrg	    fi
26681ab64890Smrg
26691ab64890Smrg	    # Create $newlib
26701ab64890Smrg	    if test -f "$output_objdir/$newlib"; then :; else
26711ab64890Smrg	      $show "generating import library for \`$soname'"
26721ab64890Smrg	      save_ifs="$IFS"; IFS='~'
26731ab64890Smrg	      cmds=$old_archive_from_expsyms_cmds
26741ab64890Smrg	      for cmd in $cmds; do
26751ab64890Smrg		IFS="$save_ifs"
26761ab64890Smrg		eval cmd=\"$cmd\"
26771ab64890Smrg		$show "$cmd"
26781ab64890Smrg		$run eval "$cmd" || exit $?
26791ab64890Smrg	      done
26801ab64890Smrg	      IFS="$save_ifs"
26811ab64890Smrg	    fi
26821ab64890Smrg	    # make sure the library variables are pointing to the new library
26831ab64890Smrg	    dir=$output_objdir
26841ab64890Smrg	    linklib=$newlib
26851ab64890Smrg	  fi # test -n "$old_archive_from_expsyms_cmds"
26861ab64890Smrg
26871ab64890Smrg	  if test "$linkmode" = prog || test "$mode" != relink; then
26881ab64890Smrg	    add_shlibpath=
26891ab64890Smrg	    add_dir=
26901ab64890Smrg	    add=
26911ab64890Smrg	    lib_linked=yes
26921ab64890Smrg	    case $hardcode_action in
26931ab64890Smrg	    immediate | unsupported)
26941ab64890Smrg	      if test "$hardcode_direct" = no; then
26951ab64890Smrg		add="$dir/$linklib"
26961ab64890Smrg		case $host in
26971ab64890Smrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
26981ab64890Smrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
26991ab64890Smrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
27001ab64890Smrg		    *-*-unixware7*) add_dir="-L$dir" ;;
27011ab64890Smrg		  *-*-darwin* )
27021ab64890Smrg		    # if the lib is a module then we can not link against
27031ab64890Smrg		    # it, someone is ignoring the new warnings I added
27041ab64890Smrg		    if /usr/bin/file -L $add 2> /dev/null |
27051ab64890Smrg                      $EGREP ": [^:]* bundle" >/dev/null ; then
27061ab64890Smrg		      $echo "** Warning, lib $linklib is a module, not a shared library"
27071ab64890Smrg		      if test -z "$old_library" ; then
27081ab64890Smrg		        $echo
27091ab64890Smrg		        $echo "** And there doesn't seem to be a static archive available"
27101ab64890Smrg		        $echo "** The link will probably fail, sorry"
27111ab64890Smrg		      else
27121ab64890Smrg		        add="$dir/$old_library"
27131ab64890Smrg		      fi
27141ab64890Smrg		    fi
27151ab64890Smrg		esac
27161ab64890Smrg	      elif test "$hardcode_minus_L" = no; then
27171ab64890Smrg		case $host in
27181ab64890Smrg		*-*-sunos*) add_shlibpath="$dir" ;;
27191ab64890Smrg		esac
27201ab64890Smrg		add_dir="-L$dir"
27211ab64890Smrg		add="-l$name"
27221ab64890Smrg	      elif test "$hardcode_shlibpath_var" = no; then
27231ab64890Smrg		add_shlibpath="$dir"
27241ab64890Smrg		add="-l$name"
27251ab64890Smrg	      else
27261ab64890Smrg		lib_linked=no
27271ab64890Smrg	      fi
27281ab64890Smrg	      ;;
27291ab64890Smrg	    relink)
27301ab64890Smrg	      if test "$hardcode_direct" = yes; then
27311ab64890Smrg		add="$dir/$linklib"
27321ab64890Smrg	      elif test "$hardcode_minus_L" = yes; then
27331ab64890Smrg		add_dir="-L$dir"
27341ab64890Smrg		# Try looking first in the location we're being installed to.
27351ab64890Smrg		if test -n "$inst_prefix_dir"; then
27361ab64890Smrg		  case $libdir in
27371ab64890Smrg		    [\\/]*)
27381ab64890Smrg		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
27391ab64890Smrg		      ;;
27401ab64890Smrg		  esac
27411ab64890Smrg		fi
27421ab64890Smrg		add="-l$name"
27431ab64890Smrg	      elif test "$hardcode_shlibpath_var" = yes; then
27441ab64890Smrg		add_shlibpath="$dir"
27451ab64890Smrg		add="-l$name"
27461ab64890Smrg	      else
27471ab64890Smrg		lib_linked=no
27481ab64890Smrg	      fi
27491ab64890Smrg	      ;;
27501ab64890Smrg	    *) lib_linked=no ;;
27511ab64890Smrg	    esac
27521ab64890Smrg
27531ab64890Smrg	    if test "$lib_linked" != yes; then
27541ab64890Smrg	      $echo "$modename: configuration error: unsupported hardcode properties"
27551ab64890Smrg	      exit $EXIT_FAILURE
27561ab64890Smrg	    fi
27571ab64890Smrg
27581ab64890Smrg	    if test -n "$add_shlibpath"; then
27591ab64890Smrg	      case :$compile_shlibpath: in
27601ab64890Smrg	      *":$add_shlibpath:"*) ;;
27611ab64890Smrg	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
27621ab64890Smrg	      esac
27631ab64890Smrg	    fi
27641ab64890Smrg	    if test "$linkmode" = prog; then
27651ab64890Smrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
27661ab64890Smrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
27671ab64890Smrg	    else
27681ab64890Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
27691ab64890Smrg	      test -n "$add" && deplibs="$add $deplibs"
27701ab64890Smrg	      if test "$hardcode_direct" != yes && \
27711ab64890Smrg		 test "$hardcode_minus_L" != yes && \
27721ab64890Smrg		 test "$hardcode_shlibpath_var" = yes; then
27731ab64890Smrg		case :$finalize_shlibpath: in
27741ab64890Smrg		*":$libdir:"*) ;;
27751ab64890Smrg		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
27761ab64890Smrg		esac
27771ab64890Smrg	      fi
27781ab64890Smrg	    fi
27791ab64890Smrg	  fi
27801ab64890Smrg
27811ab64890Smrg	  if test "$linkmode" = prog || test "$mode" = relink; then
27821ab64890Smrg	    add_shlibpath=
27831ab64890Smrg	    add_dir=
27841ab64890Smrg	    add=
27851ab64890Smrg	    # Finalize command for both is simple: just hardcode it.
27861ab64890Smrg	    if test "$hardcode_direct" = yes; then
27871ab64890Smrg	      add="$libdir/$linklib"
27881ab64890Smrg	    elif test "$hardcode_minus_L" = yes; then
27891ab64890Smrg	      add_dir="-L$libdir"
27901ab64890Smrg	      add="-l$name"
27911ab64890Smrg	    elif test "$hardcode_shlibpath_var" = yes; then
27921ab64890Smrg	      case :$finalize_shlibpath: in
27931ab64890Smrg	      *":$libdir:"*) ;;
27941ab64890Smrg	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
27951ab64890Smrg	      esac
27961ab64890Smrg	      add="-l$name"
27971ab64890Smrg	    elif test "$hardcode_automatic" = yes; then
27981ab64890Smrg	      if test -n "$inst_prefix_dir" &&
27991ab64890Smrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
28001ab64890Smrg	        add="$inst_prefix_dir$libdir/$linklib"
28011ab64890Smrg	      else
28021ab64890Smrg	        add="$libdir/$linklib"
28031ab64890Smrg	      fi
28041ab64890Smrg	    else
28051ab64890Smrg	      # We cannot seem to hardcode it, guess we'll fake it.
28061ab64890Smrg	      add_dir="-L$libdir"
28071ab64890Smrg	      # Try looking first in the location we're being installed to.
28081ab64890Smrg	      if test -n "$inst_prefix_dir"; then
28091ab64890Smrg		case $libdir in
28101ab64890Smrg		  [\\/]*)
28111ab64890Smrg		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
28121ab64890Smrg		    ;;
28131ab64890Smrg		esac
28141ab64890Smrg	      fi
28151ab64890Smrg	      add="-l$name"
28161ab64890Smrg	    fi
28171ab64890Smrg
28181ab64890Smrg	    if test "$linkmode" = prog; then
28191ab64890Smrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
28201ab64890Smrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
28211ab64890Smrg	    else
28221ab64890Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
28231ab64890Smrg	      test -n "$add" && deplibs="$add $deplibs"
28241ab64890Smrg	    fi
28251ab64890Smrg	  fi
28261ab64890Smrg	elif test "$linkmode" = prog; then
28271ab64890Smrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
28281ab64890Smrg	  # is not unsupported.  This is valid on all known static and
28291ab64890Smrg	  # shared platforms.
28301ab64890Smrg	  if test "$hardcode_direct" != unsupported; then
28311ab64890Smrg	    test -n "$old_library" && linklib="$old_library"
28321ab64890Smrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
28331ab64890Smrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
28341ab64890Smrg	  else
28351ab64890Smrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
28361ab64890Smrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
28371ab64890Smrg	  fi
28381ab64890Smrg	elif test "$build_libtool_libs" = yes; then
28391ab64890Smrg	  # Not a shared library
28401ab64890Smrg	  if test "$deplibs_check_method" != pass_all; then
28411ab64890Smrg	    # We're trying link a shared library against a static one
28421ab64890Smrg	    # but the system doesn't support it.
28431ab64890Smrg
28441ab64890Smrg	    # Just print a warning and add the library to dependency_libs so
28451ab64890Smrg	    # that the program can be linked against the static library.
28461ab64890Smrg	    $echo
28471ab64890Smrg	    $echo "*** Warning: This system can not link to static lib archive $lib."
28481ab64890Smrg	    $echo "*** I have the capability to make that library automatically link in when"
28491ab64890Smrg	    $echo "*** you link to this library.  But I can only do this if you have a"
28501ab64890Smrg	    $echo "*** shared version of the library, which you do not appear to have."
28511ab64890Smrg	    if test "$module" = yes; then
28521ab64890Smrg	      $echo "*** But as you try to build a module library, libtool will still create "
28531ab64890Smrg	      $echo "*** a static module, that should work as long as the dlopening application"
28541ab64890Smrg	      $echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
28551ab64890Smrg	      if test -z "$global_symbol_pipe"; then
28561ab64890Smrg		$echo
28571ab64890Smrg		$echo "*** However, this would only work if libtool was able to extract symbol"
28581ab64890Smrg		$echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
28591ab64890Smrg		$echo "*** not find such a program.  So, this module is probably useless."
28601ab64890Smrg		$echo "*** \`nm' from GNU binutils and a full rebuild may help."
28611ab64890Smrg	      fi
28621ab64890Smrg	      if test "$build_old_libs" = no; then
28631ab64890Smrg		build_libtool_libs=module
28641ab64890Smrg		build_old_libs=yes
28651ab64890Smrg	      else
28661ab64890Smrg		build_libtool_libs=no
28671ab64890Smrg	      fi
28681ab64890Smrg	    fi
28691ab64890Smrg	  else
28701ab64890Smrg	    deplibs="$dir/$old_library $deplibs"
28711ab64890Smrg	    link_static=yes
28721ab64890Smrg	  fi
28731ab64890Smrg	fi # link shared/static library?
28741ab64890Smrg
28751ab64890Smrg	if test "$linkmode" = lib; then
28761ab64890Smrg	  if test -n "$dependency_libs" &&
28771ab64890Smrg	     { test "$hardcode_into_libs" != yes ||
28781ab64890Smrg	       test "$build_old_libs" = yes ||
28791ab64890Smrg	       test "$link_static" = yes; }; then
28801ab64890Smrg	    # Extract -R from dependency_libs
28811ab64890Smrg	    temp_deplibs=
28821ab64890Smrg	    for libdir in $dependency_libs; do
28831ab64890Smrg	      case $libdir in
28841ab64890Smrg	      -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'`
28851ab64890Smrg		   case " $xrpath " in
28861ab64890Smrg		   *" $temp_xrpath "*) ;;
28871ab64890Smrg		   *) xrpath="$xrpath $temp_xrpath";;
28881ab64890Smrg		   esac;;
28891ab64890Smrg	      *) temp_deplibs="$temp_deplibs $libdir";;
28901ab64890Smrg	      esac
28911ab64890Smrg	    done
28921ab64890Smrg	    dependency_libs="$temp_deplibs"
28931ab64890Smrg	  fi
28941ab64890Smrg
28951ab64890Smrg	  newlib_search_path="$newlib_search_path $absdir"
28961ab64890Smrg	  # Link against this library
28971ab64890Smrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
28981ab64890Smrg	  # ... and its dependency_libs
28991ab64890Smrg	  tmp_libs=
29001ab64890Smrg	  for deplib in $dependency_libs; do
29011ab64890Smrg	    newdependency_libs="$deplib $newdependency_libs"
29021ab64890Smrg	    if test "X$duplicate_deps" = "Xyes" ; then
29031ab64890Smrg	      case "$tmp_libs " in
29041ab64890Smrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
29051ab64890Smrg	      esac
29061ab64890Smrg	    fi
29071ab64890Smrg	    tmp_libs="$tmp_libs $deplib"
29081ab64890Smrg	  done
29091ab64890Smrg
29101ab64890Smrg	  if test "$link_all_deplibs" != no; then
29111ab64890Smrg	    # Add the search paths of all dependency libraries
29121ab64890Smrg	    for deplib in $dependency_libs; do
29131ab64890Smrg	      case $deplib in
29141ab64890Smrg	      -L*) path="$deplib" ;;
29151ab64890Smrg	      *.la)
29161ab64890Smrg		dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'`
29171ab64890Smrg		test "X$dir" = "X$deplib" && dir="."
29181ab64890Smrg		# We need an absolute path.
29191ab64890Smrg		case $dir in
29201ab64890Smrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
29211ab64890Smrg		*)
29221ab64890Smrg		  absdir=`cd "$dir" && pwd`
29231ab64890Smrg		  if test -z "$absdir"; then
29241ab64890Smrg		    $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
29251ab64890Smrg		    absdir="$dir"
29261ab64890Smrg		  fi
29271ab64890Smrg		  ;;
29281ab64890Smrg		esac
29291ab64890Smrg		if grep "^installed=no" $deplib > /dev/null; then
29301ab64890Smrg		  path="$absdir/$objdir"
29311ab64890Smrg		else
29321ab64890Smrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
29331ab64890Smrg		  if test -z "$libdir"; then
29341ab64890Smrg		    $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
29351ab64890Smrg		    exit $EXIT_FAILURE
29361ab64890Smrg		  fi
29371ab64890Smrg		  if test "$absdir" != "$libdir"; then
29381ab64890Smrg		    $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2
29391ab64890Smrg		  fi
29401ab64890Smrg		  path="$absdir"
29411ab64890Smrg		fi
29421ab64890Smrg		depdepl=
29431ab64890Smrg		case $host in
29441ab64890Smrg		*-*-darwin*)
29451ab64890Smrg		  # we do not want to link against static libs,
29461ab64890Smrg		  # but need to link against shared
29471ab64890Smrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
29481ab64890Smrg		  if test -n "$deplibrary_names" ; then
29491ab64890Smrg		    for tmp in $deplibrary_names ; do
29501ab64890Smrg		      depdepl=$tmp
29511ab64890Smrg		    done
29521ab64890Smrg		    if test -f "$path/$depdepl" ; then
29531ab64890Smrg		      depdepl="$path/$depdepl"
29541ab64890Smrg		    fi
29551ab64890Smrg		    # do not add paths which are already there
29561ab64890Smrg		    case " $newlib_search_path " in
29571ab64890Smrg		    *" $path "*) ;;
29581ab64890Smrg		    *) newlib_search_path="$newlib_search_path $path";;
29591ab64890Smrg		    esac
29601ab64890Smrg		  fi
29611ab64890Smrg		  path=""
29621ab64890Smrg		  ;;
29631ab64890Smrg		*)
29641ab64890Smrg		  path="-L$path"
29651ab64890Smrg		  ;;
29661ab64890Smrg		esac
29671ab64890Smrg		;;
29681ab64890Smrg	      -l*)
29691ab64890Smrg		case $host in
29701ab64890Smrg		*-*-darwin*)
29711ab64890Smrg		  # Again, we only want to link against shared libraries
29721ab64890Smrg		  eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"`
29731ab64890Smrg		  for tmp in $newlib_search_path ; do
29741ab64890Smrg		    if test -f "$tmp/lib$tmp_libs.dylib" ; then
29751ab64890Smrg		      eval depdepl="$tmp/lib$tmp_libs.dylib"
29761ab64890Smrg		      break
29771ab64890Smrg		    fi
29781ab64890Smrg		  done
29791ab64890Smrg		  path=""
29801ab64890Smrg		  ;;
29811ab64890Smrg		*) continue ;;
29821ab64890Smrg		esac
29831ab64890Smrg		;;
29841ab64890Smrg	      *) continue ;;
29851ab64890Smrg	      esac
29861ab64890Smrg	      case " $deplibs " in
29871ab64890Smrg	      *" $path "*) ;;
29881ab64890Smrg	      *) deplibs="$path $deplibs" ;;
29891ab64890Smrg	      esac
29901ab64890Smrg	      case " $deplibs " in
29911ab64890Smrg	      *" $depdepl "*) ;;
29921ab64890Smrg	      *) deplibs="$depdepl $deplibs" ;;
29931ab64890Smrg	      esac
29941ab64890Smrg	    done
29951ab64890Smrg	  fi # link_all_deplibs != no
29961ab64890Smrg	fi # linkmode = lib
29971ab64890Smrg      done # for deplib in $libs
29981ab64890Smrg      dependency_libs="$newdependency_libs"
29991ab64890Smrg      if test "$pass" = dlpreopen; then
30001ab64890Smrg	# Link the dlpreopened libraries before other libraries
30011ab64890Smrg	for deplib in $save_deplibs; do
30021ab64890Smrg	  deplibs="$deplib $deplibs"
30031ab64890Smrg	done
30041ab64890Smrg      fi
30051ab64890Smrg      if test "$pass" != dlopen; then
30061ab64890Smrg	if test "$pass" != conv; then
30071ab64890Smrg	  # Make sure lib_search_path contains only unique directories.
30081ab64890Smrg	  lib_search_path=
30091ab64890Smrg	  for dir in $newlib_search_path; do
30101ab64890Smrg	    case "$lib_search_path " in
30111ab64890Smrg	    *" $dir "*) ;;
30121ab64890Smrg	    *) lib_search_path="$lib_search_path $dir" ;;
30131ab64890Smrg	    esac
30141ab64890Smrg	  done
30151ab64890Smrg	  newlib_search_path=
30161ab64890Smrg	fi
30171ab64890Smrg
30181ab64890Smrg	if test "$linkmode,$pass" != "prog,link"; then
30191ab64890Smrg	  vars="deplibs"
30201ab64890Smrg	else
30211ab64890Smrg	  vars="compile_deplibs finalize_deplibs"
30221ab64890Smrg	fi
30231ab64890Smrg	for var in $vars dependency_libs; do
30241ab64890Smrg	  # Add libraries to $var in reverse order
30251ab64890Smrg	  eval tmp_libs=\"\$$var\"
30261ab64890Smrg	  new_libs=
30271ab64890Smrg	  for deplib in $tmp_libs; do
30281ab64890Smrg	    # FIXME: Pedantically, this is the right thing to do, so
30291ab64890Smrg	    #        that some nasty dependency loop isn't accidentally
30301ab64890Smrg	    #        broken:
30311ab64890Smrg	    #new_libs="$deplib $new_libs"
30321ab64890Smrg	    # Pragmatically, this seems to cause very few problems in
30331ab64890Smrg	    # practice:
30341ab64890Smrg	    case $deplib in
30351ab64890Smrg	    -L*) new_libs="$deplib $new_libs" ;;
30361ab64890Smrg	    -R*) ;;
30371ab64890Smrg	    *)
30381ab64890Smrg	      # And here is the reason: when a library appears more
30391ab64890Smrg	      # than once as an explicit dependence of a library, or
30401ab64890Smrg	      # is implicitly linked in more than once by the
30411ab64890Smrg	      # compiler, it is considered special, and multiple
30421ab64890Smrg	      # occurrences thereof are not removed.  Compare this
30431ab64890Smrg	      # with having the same library being listed as a
30441ab64890Smrg	      # dependency of multiple other libraries: in this case,
30451ab64890Smrg	      # we know (pedantically, we assume) the library does not
30461ab64890Smrg	      # need to be listed more than once, so we keep only the
30471ab64890Smrg	      # last copy.  This is not always right, but it is rare
30481ab64890Smrg	      # enough that we require users that really mean to play
30491ab64890Smrg	      # such unportable linking tricks to link the library
30501ab64890Smrg	      # using -Wl,-lname, so that libtool does not consider it
30511ab64890Smrg	      # for duplicate removal.
30521ab64890Smrg	      case " $specialdeplibs " in
30531ab64890Smrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
30541ab64890Smrg	      *)
30551ab64890Smrg		case " $new_libs " in
30561ab64890Smrg		*" $deplib "*) ;;
30571ab64890Smrg		*) new_libs="$deplib $new_libs" ;;
30581ab64890Smrg		esac
30591ab64890Smrg		;;
30601ab64890Smrg	      esac
30611ab64890Smrg	      ;;
30621ab64890Smrg	    esac
30631ab64890Smrg	  done
30641ab64890Smrg	  tmp_libs=
30651ab64890Smrg	  for deplib in $new_libs; do
30661ab64890Smrg	    case $deplib in
30671ab64890Smrg	    -L*)
30681ab64890Smrg	      case " $tmp_libs " in
30691ab64890Smrg	      *" $deplib "*) ;;
30701ab64890Smrg	      *) tmp_libs="$tmp_libs $deplib" ;;
30711ab64890Smrg	      esac
30721ab64890Smrg	      ;;
30731ab64890Smrg	    *) tmp_libs="$tmp_libs $deplib" ;;
30741ab64890Smrg	    esac
30751ab64890Smrg	  done
30761ab64890Smrg	  eval $var=\"$tmp_libs\"
30771ab64890Smrg	done # for var
30781ab64890Smrg      fi
30791ab64890Smrg      # Last step: remove runtime libs from dependency_libs
30801ab64890Smrg      # (they stay in deplibs)
30811ab64890Smrg      tmp_libs=
30821ab64890Smrg      for i in $dependency_libs ; do
30831ab64890Smrg	case " $predeps $postdeps $compiler_lib_search_path " in
30841ab64890Smrg	*" $i "*)
30851ab64890Smrg	  i=""
30861ab64890Smrg	  ;;
30871ab64890Smrg	esac
30881ab64890Smrg	if test -n "$i" ; then
30891ab64890Smrg	  tmp_libs="$tmp_libs $i"
30901ab64890Smrg	fi
30911ab64890Smrg      done
30921ab64890Smrg      dependency_libs=$tmp_libs
30931ab64890Smrg    done # for pass
30941ab64890Smrg    if test "$linkmode" = prog; then
30951ab64890Smrg      dlfiles="$newdlfiles"
30961ab64890Smrg      dlprefiles="$newdlprefiles"
30971ab64890Smrg    fi
30981ab64890Smrg
30991ab64890Smrg    case $linkmode in
31001ab64890Smrg    oldlib)
31011ab64890Smrg      if test -n "$deplibs"; then
31021ab64890Smrg	$echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2
31031ab64890Smrg      fi
31041ab64890Smrg
31051ab64890Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
31061ab64890Smrg	$echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
31071ab64890Smrg      fi
31081ab64890Smrg
31091ab64890Smrg      if test -n "$rpath"; then
31101ab64890Smrg	$echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2
31111ab64890Smrg      fi
31121ab64890Smrg
31131ab64890Smrg      if test -n "$xrpath"; then
31141ab64890Smrg	$echo "$modename: warning: \`-R' is ignored for archives" 1>&2
31151ab64890Smrg      fi
31161ab64890Smrg
31171ab64890Smrg      if test -n "$vinfo"; then
31181ab64890Smrg	$echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2
31191ab64890Smrg      fi
31201ab64890Smrg
31211ab64890Smrg      if test -n "$release"; then
31221ab64890Smrg	$echo "$modename: warning: \`-release' is ignored for archives" 1>&2
31231ab64890Smrg      fi
31241ab64890Smrg
31251ab64890Smrg      if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
31261ab64890Smrg	$echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2
31271ab64890Smrg      fi
31281ab64890Smrg
31291ab64890Smrg      # Now set the variables for building old libraries.
31301ab64890Smrg      build_libtool_libs=no
31311ab64890Smrg      oldlibs="$output"
31321ab64890Smrg      objs="$objs$old_deplibs"
31331ab64890Smrg      ;;
31341ab64890Smrg
31351ab64890Smrg    lib)
31361ab64890Smrg      # Make sure we only generate libraries of the form `libNAME.la'.
31371ab64890Smrg      case $outputname in
31381ab64890Smrg      lib*)
31391ab64890Smrg	name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
31401ab64890Smrg	eval shared_ext=\"$shrext_cmds\"
31411ab64890Smrg	eval libname=\"$libname_spec\"
31421ab64890Smrg	;;
31431ab64890Smrg      *)
31441ab64890Smrg	if test "$module" = no; then
31451ab64890Smrg	  $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
31461ab64890Smrg	  $echo "$help" 1>&2
31471ab64890Smrg	  exit $EXIT_FAILURE
31481ab64890Smrg	fi
31491ab64890Smrg	if test "$need_lib_prefix" != no; then
31501ab64890Smrg	  # Add the "lib" prefix for modules if required
31511ab64890Smrg	  name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
31521ab64890Smrg	  eval shared_ext=\"$shrext_cmds\"
31531ab64890Smrg	  eval libname=\"$libname_spec\"
31541ab64890Smrg	else
31551ab64890Smrg	  libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
31561ab64890Smrg	fi
31571ab64890Smrg	;;
31581ab64890Smrg      esac
31591ab64890Smrg
31601ab64890Smrg      if test -n "$objs"; then
31611ab64890Smrg	if test "$deplibs_check_method" != pass_all; then
31621ab64890Smrg	  $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1
31631ab64890Smrg	  exit $EXIT_FAILURE
31641ab64890Smrg	else
31651ab64890Smrg	  $echo
31661ab64890Smrg	  $echo "*** Warning: Linking the shared library $output against the non-libtool"
31671ab64890Smrg	  $echo "*** objects $objs is not portable!"
31681ab64890Smrg	  libobjs="$libobjs $objs"
31691ab64890Smrg	fi
31701ab64890Smrg      fi
31711ab64890Smrg
31721ab64890Smrg      if test "$dlself" != no; then
31731ab64890Smrg	$echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2
31741ab64890Smrg      fi
31751ab64890Smrg
31761ab64890Smrg      set dummy $rpath
31771ab64890Smrg      if test "$#" -gt 2; then
31781ab64890Smrg	$echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
31791ab64890Smrg      fi
31801ab64890Smrg      install_libdir="$2"
31811ab64890Smrg
31821ab64890Smrg      oldlibs=
31831ab64890Smrg      if test -z "$rpath"; then
31841ab64890Smrg	if test "$build_libtool_libs" = yes; then
31851ab64890Smrg	  # Building a libtool convenience library.
31861ab64890Smrg	  # Some compilers have problems with a `.al' extension so
31871ab64890Smrg	  # convenience libraries should have the same extension an
31881ab64890Smrg	  # archive normally would.
31891ab64890Smrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
31901ab64890Smrg	  build_libtool_libs=convenience
31911ab64890Smrg	  build_old_libs=yes
31921ab64890Smrg	fi
31931ab64890Smrg
31941ab64890Smrg	if test -n "$vinfo"; then
31951ab64890Smrg	  $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2
31961ab64890Smrg	fi
31971ab64890Smrg
31981ab64890Smrg	if test -n "$release"; then
31991ab64890Smrg	  $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2
32001ab64890Smrg	fi
32011ab64890Smrg      else
32021ab64890Smrg
32031ab64890Smrg	# Parse the version information argument.
32041ab64890Smrg	save_ifs="$IFS"; IFS=':'
32051ab64890Smrg	set dummy $vinfo 0 0 0
32061ab64890Smrg	IFS="$save_ifs"
32071ab64890Smrg
32081ab64890Smrg	if test -n "$8"; then
32091ab64890Smrg	  $echo "$modename: too many parameters to \`-version-info'" 1>&2
32101ab64890Smrg	  $echo "$help" 1>&2
32111ab64890Smrg	  exit $EXIT_FAILURE
32121ab64890Smrg	fi
32131ab64890Smrg
32141ab64890Smrg	# convert absolute version numbers to libtool ages
32151ab64890Smrg	# this retains compatibility with .la files and attempts
32161ab64890Smrg	# to make the code below a bit more comprehensible
32171ab64890Smrg
32181ab64890Smrg	case $vinfo_number in
32191ab64890Smrg	yes)
32201ab64890Smrg	  number_major="$2"
32211ab64890Smrg	  number_minor="$3"
32221ab64890Smrg	  number_revision="$4"
32231ab64890Smrg	  #
32241ab64890Smrg	  # There are really only two kinds -- those that
32251ab64890Smrg	  # use the current revision as the major version
32261ab64890Smrg	  # and those that subtract age and use age as
32271ab64890Smrg	  # a minor version.  But, then there is irix
32281ab64890Smrg	  # which has an extra 1 added just for fun
32291ab64890Smrg	  #
32301ab64890Smrg	  case $version_type in
32311ab64890Smrg	  darwin|linux|osf|windows|none)
32321ab64890Smrg	    current=`expr $number_major + $number_minor`
32331ab64890Smrg	    age="$number_minor"
32341ab64890Smrg	    revision="$number_revision"
32351ab64890Smrg	    ;;
32361ab64890Smrg	  freebsd-aout|freebsd-elf|sunos)
32371ab64890Smrg	    current="$number_major"
32381ab64890Smrg	    revision="$number_minor"
32391ab64890Smrg	    age="0"
32401ab64890Smrg	    ;;
32411ab64890Smrg	  irix|nonstopux)
32421ab64890Smrg	    current=`expr $number_major + $number_minor`
32431ab64890Smrg	    age="$number_minor"
32441ab64890Smrg	    revision="$number_minor"
32451ab64890Smrg	    lt_irix_increment=no
32461ab64890Smrg	    ;;
32471ab64890Smrg	  esac
32481ab64890Smrg	  ;;
32491ab64890Smrg	no)
32501ab64890Smrg	  current="$2"
32511ab64890Smrg	  revision="$3"
32521ab64890Smrg	  age="$4"
32531ab64890Smrg	  ;;
32541ab64890Smrg	esac
32551ab64890Smrg
32561ab64890Smrg	# Check that each of the things are valid numbers.
32571ab64890Smrg	case $current in
32581ab64890Smrg	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]) ;;
32591ab64890Smrg	*)
32601ab64890Smrg	  $echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2
32611ab64890Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
32621ab64890Smrg	  exit $EXIT_FAILURE
32631ab64890Smrg	  ;;
32641ab64890Smrg	esac
32651ab64890Smrg
32661ab64890Smrg	case $revision in
32671ab64890Smrg	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]) ;;
32681ab64890Smrg	*)
32691ab64890Smrg	  $echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2
32701ab64890Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
32711ab64890Smrg	  exit $EXIT_FAILURE
32721ab64890Smrg	  ;;
32731ab64890Smrg	esac
32741ab64890Smrg
32751ab64890Smrg	case $age in
32761ab64890Smrg	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]) ;;
32771ab64890Smrg	*)
32781ab64890Smrg	  $echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2
32791ab64890Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
32801ab64890Smrg	  exit $EXIT_FAILURE
32811ab64890Smrg	  ;;
32821ab64890Smrg	esac
32831ab64890Smrg
32841ab64890Smrg	if test "$age" -gt "$current"; then
32851ab64890Smrg	  $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
32861ab64890Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
32871ab64890Smrg	  exit $EXIT_FAILURE
32881ab64890Smrg	fi
32891ab64890Smrg
32901ab64890Smrg	# Calculate the version variables.
32911ab64890Smrg	major=
32921ab64890Smrg	versuffix=
32931ab64890Smrg	verstring=
32941ab64890Smrg	case $version_type in
32951ab64890Smrg	none) ;;
32961ab64890Smrg
32971ab64890Smrg	darwin)
32981ab64890Smrg	  # Like Linux, but with the current version available in
32991ab64890Smrg	  # verstring for coding it into the library header
33001ab64890Smrg	  major=.`expr $current - $age`
33011ab64890Smrg	  versuffix="$major.$age.$revision"
33021ab64890Smrg	  # Darwin ld doesn't like 0 for these options...
33031ab64890Smrg	  minor_current=`expr $current + 1`
33041ab64890Smrg	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
33051ab64890Smrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
33061ab64890Smrg	  ;;
33071ab64890Smrg
33081ab64890Smrg	freebsd-aout)
33091ab64890Smrg	  major=".$current"
33101ab64890Smrg	  versuffix=".$current.$revision";
33111ab64890Smrg	  ;;
33121ab64890Smrg
33131ab64890Smrg	freebsd-elf)
33141ab64890Smrg	  major=".$current"
33151ab64890Smrg	  versuffix=".$current";
33161ab64890Smrg	  ;;
33171ab64890Smrg
33181ab64890Smrg	irix | nonstopux)
33191ab64890Smrg	  if test "X$lt_irix_increment" = "Xno"; then
33201ab64890Smrg	    major=`expr $current - $age`
33211ab64890Smrg	  else
33221ab64890Smrg	    major=`expr $current - $age + 1`
33231ab64890Smrg	  fi
33241ab64890Smrg	  case $version_type in
33251ab64890Smrg	    nonstopux) verstring_prefix=nonstopux ;;
33261ab64890Smrg	    *)         verstring_prefix=sgi ;;
33271ab64890Smrg	  esac
33281ab64890Smrg	  verstring="$verstring_prefix$major.$revision"
33291ab64890Smrg
33301ab64890Smrg	  # Add in all the interfaces that we are compatible with.
33311ab64890Smrg	  loop=$revision
33321ab64890Smrg	  while test "$loop" -ne 0; do
33331ab64890Smrg	    iface=`expr $revision - $loop`
33341ab64890Smrg	    loop=`expr $loop - 1`
33351ab64890Smrg	    verstring="$verstring_prefix$major.$iface:$verstring"
33361ab64890Smrg	  done
33371ab64890Smrg
33381ab64890Smrg	  # Before this point, $major must not contain `.'.
33391ab64890Smrg	  major=.$major
33401ab64890Smrg	  versuffix="$major.$revision"
33411ab64890Smrg	  ;;
33421ab64890Smrg
33431ab64890Smrg	linux)
33441ab64890Smrg	  major=.`expr $current - $age`
33451ab64890Smrg	  versuffix="$major.$age.$revision"
33461ab64890Smrg	  ;;
33471ab64890Smrg
33481ab64890Smrg	osf)
33491ab64890Smrg	  major=.`expr $current - $age`
33501ab64890Smrg	  versuffix=".$current.$age.$revision"
33511ab64890Smrg	  verstring="$current.$age.$revision"
33521ab64890Smrg
33531ab64890Smrg	  # Add in all the interfaces that we are compatible with.
33541ab64890Smrg	  loop=$age
33551ab64890Smrg	  while test "$loop" -ne 0; do
33561ab64890Smrg	    iface=`expr $current - $loop`
33571ab64890Smrg	    loop=`expr $loop - 1`
33581ab64890Smrg	    verstring="$verstring:${iface}.0"
33591ab64890Smrg	  done
33601ab64890Smrg
33611ab64890Smrg	  # Make executables depend on our current version.
33621ab64890Smrg	  verstring="$verstring:${current}.0"
33631ab64890Smrg	  ;;
33641ab64890Smrg
33651ab64890Smrg	sunos)
33661ab64890Smrg	  major=".$current"
33671ab64890Smrg	  versuffix=".$current.$revision"
33681ab64890Smrg	  ;;
33691ab64890Smrg
33701ab64890Smrg	windows)
33711ab64890Smrg	  # Use '-' rather than '.', since we only want one
33721ab64890Smrg	  # extension on DOS 8.3 filesystems.
33731ab64890Smrg	  major=`expr $current - $age`
33741ab64890Smrg	  versuffix="-$major"
33751ab64890Smrg	  ;;
33761ab64890Smrg
33771ab64890Smrg	*)
33781ab64890Smrg	  $echo "$modename: unknown library version type \`$version_type'" 1>&2
33791ab64890Smrg	  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
33801ab64890Smrg	  exit $EXIT_FAILURE
33811ab64890Smrg	  ;;
33821ab64890Smrg	esac
33831ab64890Smrg
33841ab64890Smrg	# Clear the version info if we defaulted, and they specified a release.
33851ab64890Smrg	if test -z "$vinfo" && test -n "$release"; then
33861ab64890Smrg	  major=
33871ab64890Smrg	  case $version_type in
33881ab64890Smrg	  darwin)
33891ab64890Smrg	    # we can't check for "0.0" in archive_cmds due to quoting
33901ab64890Smrg	    # problems, so we reset it completely
33911ab64890Smrg	    verstring=
33921ab64890Smrg	    ;;
33931ab64890Smrg	  *)
33941ab64890Smrg	    verstring="0.0"
33951ab64890Smrg	    ;;
33961ab64890Smrg	  esac
33971ab64890Smrg	  if test "$need_version" = no; then
33981ab64890Smrg	    versuffix=
33991ab64890Smrg	  else
34001ab64890Smrg	    versuffix=".0.0"
34011ab64890Smrg	  fi
34021ab64890Smrg	fi
34031ab64890Smrg
34041ab64890Smrg	# Remove version info from name if versioning should be avoided
34051ab64890Smrg	if test "$avoid_version" = yes && test "$need_version" = no; then
34061ab64890Smrg	  major=
34071ab64890Smrg	  versuffix=
34081ab64890Smrg	  verstring=""
34091ab64890Smrg	fi
34101ab64890Smrg
34111ab64890Smrg	# Check to see if the archive will have undefined symbols.
34121ab64890Smrg	if test "$allow_undefined" = yes; then
34131ab64890Smrg	  if test "$allow_undefined_flag" = unsupported; then
34141ab64890Smrg	    $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2
34151ab64890Smrg	    build_libtool_libs=no
34161ab64890Smrg	    build_old_libs=yes
34171ab64890Smrg	  fi
34181ab64890Smrg	else
34191ab64890Smrg	  # Don't allow undefined symbols.
34201ab64890Smrg	  allow_undefined_flag="$no_undefined_flag"
34211ab64890Smrg	fi
34221ab64890Smrg      fi
34231ab64890Smrg
34241ab64890Smrg      if test "$mode" != relink; then
34251ab64890Smrg	# Remove our outputs, but don't remove object files since they
34261ab64890Smrg	# may have been created when compiling PIC objects.
34271ab64890Smrg	removelist=
34281ab64890Smrg	tempremovelist=`$echo "$output_objdir/*"`
34291ab64890Smrg	for p in $tempremovelist; do
34301ab64890Smrg	  case $p in
34311ab64890Smrg	    *.$objext)
34321ab64890Smrg	       ;;
34331ab64890Smrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
34341ab64890Smrg	       if test "X$precious_files_regex" != "X"; then
34351ab64890Smrg	         if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
34361ab64890Smrg	         then
34371ab64890Smrg		   continue
34381ab64890Smrg		 fi
34391ab64890Smrg	       fi
34401ab64890Smrg	       removelist="$removelist $p"
34411ab64890Smrg	       ;;
34421ab64890Smrg	    *) ;;
34431ab64890Smrg	  esac
34441ab64890Smrg	done
34451ab64890Smrg	if test -n "$removelist"; then
34461ab64890Smrg	  $show "${rm}r $removelist"
34471ab64890Smrg	  $run ${rm}r $removelist
34481ab64890Smrg	fi
34491ab64890Smrg      fi
34501ab64890Smrg
34511ab64890Smrg      # Now set the variables for building old libraries.
34521ab64890Smrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
34531ab64890Smrg	oldlibs="$oldlibs $output_objdir/$libname.$libext"
34541ab64890Smrg
34551ab64890Smrg	# Transform .lo files to .o files.
34561ab64890Smrg	oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
34571ab64890Smrg      fi
34581ab64890Smrg
34591ab64890Smrg      # Eliminate all temporary directories.
34601ab64890Smrg      #for path in $notinst_path; do
34611ab64890Smrg      #	lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"`
34621ab64890Smrg      #	deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"`
34631ab64890Smrg      #	dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"`
34641ab64890Smrg      #done
34651ab64890Smrg
34661ab64890Smrg      if test -n "$xrpath"; then
34671ab64890Smrg	# If the user specified any rpath flags, then add them.
34681ab64890Smrg	temp_xrpath=
34691ab64890Smrg	for libdir in $xrpath; do
34701ab64890Smrg	  temp_xrpath="$temp_xrpath -R$libdir"
34711ab64890Smrg	  case "$finalize_rpath " in
34721ab64890Smrg	  *" $libdir "*) ;;
34731ab64890Smrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
34741ab64890Smrg	  esac
34751ab64890Smrg	done
34761ab64890Smrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
34771ab64890Smrg	  dependency_libs="$temp_xrpath $dependency_libs"
34781ab64890Smrg	fi
34791ab64890Smrg      fi
34801ab64890Smrg
34811ab64890Smrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
34821ab64890Smrg      old_dlfiles="$dlfiles"
34831ab64890Smrg      dlfiles=
34841ab64890Smrg      for lib in $old_dlfiles; do
34851ab64890Smrg	case " $dlprefiles $dlfiles " in
34861ab64890Smrg	*" $lib "*) ;;
34871ab64890Smrg	*) dlfiles="$dlfiles $lib" ;;
34881ab64890Smrg	esac
34891ab64890Smrg      done
34901ab64890Smrg
34911ab64890Smrg      # Make sure dlprefiles contains only unique files
34921ab64890Smrg      old_dlprefiles="$dlprefiles"
34931ab64890Smrg      dlprefiles=
34941ab64890Smrg      for lib in $old_dlprefiles; do
34951ab64890Smrg	case "$dlprefiles " in
34961ab64890Smrg	*" $lib "*) ;;
34971ab64890Smrg	*) dlprefiles="$dlprefiles $lib" ;;
34981ab64890Smrg	esac
34991ab64890Smrg      done
35001ab64890Smrg
35011ab64890Smrg      if test "$build_libtool_libs" = yes; then
35021ab64890Smrg	if test -n "$rpath"; then
35031ab64890Smrg	  case $host in
35041ab64890Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*)
35051ab64890Smrg	    # these systems don't actually have a c library (as such)!
35061ab64890Smrg	    ;;
35071ab64890Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
35081ab64890Smrg	    # Rhapsody C library is in the System framework
35091ab64890Smrg	    deplibs="$deplibs -framework System"
35101ab64890Smrg	    ;;
35111ab64890Smrg	  *-*-netbsd*)
35121ab64890Smrg	    # Don't link with libc until the a.out ld.so is fixed.
35131ab64890Smrg	    ;;
35141ab64890Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
35151ab64890Smrg	    # Do not include libc due to us having libc/libc_r.
35161ab64890Smrg	    ;;
35171ab64890Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
35181ab64890Smrg	    # Causes problems with __ctype
35191ab64890Smrg	    ;;
35201ab64890Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
35211ab64890Smrg	    # Compiler inserts libc in the correct place for threads to work
35221ab64890Smrg	    ;;
35231ab64890Smrg 	  *)
35241ab64890Smrg	    # Add libc to deplibs on all other systems if necessary.
35251ab64890Smrg	    if test "$build_libtool_need_lc" = "yes"; then
35261ab64890Smrg	      deplibs="$deplibs -lc"
35271ab64890Smrg	    fi
35281ab64890Smrg	    ;;
35291ab64890Smrg	  esac
35301ab64890Smrg	fi
35311ab64890Smrg
35321ab64890Smrg	# Transform deplibs into only deplibs that can be linked in shared.
35331ab64890Smrg	name_save=$name
35341ab64890Smrg	libname_save=$libname
35351ab64890Smrg	release_save=$release
35361ab64890Smrg	versuffix_save=$versuffix
35371ab64890Smrg	major_save=$major
35381ab64890Smrg	# I'm not sure if I'm treating the release correctly.  I think
35391ab64890Smrg	# release should show up in the -l (ie -lgmp5) so we don't want to
35401ab64890Smrg	# add it in twice.  Is that correct?
35411ab64890Smrg	release=""
35421ab64890Smrg	versuffix=""
35431ab64890Smrg	major=""
35441ab64890Smrg	newdeplibs=
35451ab64890Smrg	droppeddeps=no
35461ab64890Smrg	case $deplibs_check_method in
35471ab64890Smrg	pass_all)
35481ab64890Smrg	  # Don't check for shared/static.  Everything works.
35491ab64890Smrg	  # This might be a little naive.  We might want to check
35501ab64890Smrg	  # whether the library exists or not.  But this is on
35511ab64890Smrg	  # osf3 & osf4 and I'm not really sure... Just
35521ab64890Smrg	  # implementing what was already the behavior.
35531ab64890Smrg	  newdeplibs=$deplibs
35541ab64890Smrg	  ;;
35551ab64890Smrg	test_compile)
35561ab64890Smrg	  # This code stresses the "libraries are programs" paradigm to its
35571ab64890Smrg	  # limits. Maybe even breaks it.  We compile a program, linking it
35581ab64890Smrg	  # against the deplibs as a proxy for the library.  Then we can check
35591ab64890Smrg	  # whether they linked in statically or dynamically with ldd.
35601ab64890Smrg	  $rm conftest.c
35611ab64890Smrg	  cat > conftest.c <<EOF
35621ab64890Smrg	  int main() { return 0; }
35631ab64890SmrgEOF
35641ab64890Smrg	  $rm conftest
35651ab64890Smrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
35661ab64890Smrg	    ldd_output=`ldd conftest`
35671ab64890Smrg	    for i in $deplibs; do
35681ab64890Smrg	      name=`expr $i : '-l\(.*\)'`
35691ab64890Smrg	      # If $name is empty we are operating on a -L argument.
35701ab64890Smrg              if test "$name" != "" && test "$name" != "0"; then
35711ab64890Smrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
35721ab64890Smrg		  case " $predeps $postdeps " in
35731ab64890Smrg		  *" $i "*)
35741ab64890Smrg		    newdeplibs="$newdeplibs $i"
35751ab64890Smrg		    i=""
35761ab64890Smrg		    ;;
35771ab64890Smrg		  esac
35781ab64890Smrg	        fi
35791ab64890Smrg		if test -n "$i" ; then
35801ab64890Smrg		  libname=`eval \\$echo \"$libname_spec\"`
35811ab64890Smrg		  deplib_matches=`eval \\$echo \"$library_names_spec\"`
35821ab64890Smrg		  set dummy $deplib_matches
35831ab64890Smrg		  deplib_match=$2
35841ab64890Smrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
35851ab64890Smrg		    newdeplibs="$newdeplibs $i"
35861ab64890Smrg		  else
35871ab64890Smrg		    droppeddeps=yes
35881ab64890Smrg		    $echo
35891ab64890Smrg		    $echo "*** Warning: dynamic linker does not accept needed library $i."
35901ab64890Smrg		    $echo "*** I have the capability to make that library automatically link in when"
35911ab64890Smrg		    $echo "*** you link to this library.  But I can only do this if you have a"
35921ab64890Smrg		    $echo "*** shared version of the library, which I believe you do not have"
35931ab64890Smrg		    $echo "*** because a test_compile did reveal that the linker did not use it for"
35941ab64890Smrg		    $echo "*** its dynamic dependency list that programs get resolved with at runtime."
35951ab64890Smrg		  fi
35961ab64890Smrg		fi
35971ab64890Smrg	      else
35981ab64890Smrg		newdeplibs="$newdeplibs $i"
35991ab64890Smrg	      fi
36001ab64890Smrg	    done
36011ab64890Smrg	  else
36021ab64890Smrg	    # Error occurred in the first compile.  Let's try to salvage
36031ab64890Smrg	    # the situation: Compile a separate program for each library.
36041ab64890Smrg	    for i in $deplibs; do
36051ab64890Smrg	      name=`expr $i : '-l\(.*\)'`
36061ab64890Smrg	      # If $name is empty we are operating on a -L argument.
36071ab64890Smrg              if test "$name" != "" && test "$name" != "0"; then
36081ab64890Smrg		$rm conftest
36091ab64890Smrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
36101ab64890Smrg		  ldd_output=`ldd conftest`
36111ab64890Smrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
36121ab64890Smrg		    case " $predeps $postdeps " in
36131ab64890Smrg		    *" $i "*)
36141ab64890Smrg		      newdeplibs="$newdeplibs $i"
36151ab64890Smrg		      i=""
36161ab64890Smrg		      ;;
36171ab64890Smrg		    esac
36181ab64890Smrg		  fi
36191ab64890Smrg		  if test -n "$i" ; then
36201ab64890Smrg		    libname=`eval \\$echo \"$libname_spec\"`
36211ab64890Smrg		    deplib_matches=`eval \\$echo \"$library_names_spec\"`
36221ab64890Smrg		    set dummy $deplib_matches
36231ab64890Smrg		    deplib_match=$2
36241ab64890Smrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
36251ab64890Smrg		      newdeplibs="$newdeplibs $i"
36261ab64890Smrg		    else
36271ab64890Smrg		      droppeddeps=yes
36281ab64890Smrg		      $echo
36291ab64890Smrg		      $echo "*** Warning: dynamic linker does not accept needed library $i."
36301ab64890Smrg		      $echo "*** I have the capability to make that library automatically link in when"
36311ab64890Smrg		      $echo "*** you link to this library.  But I can only do this if you have a"
36321ab64890Smrg		      $echo "*** shared version of the library, which you do not appear to have"
36331ab64890Smrg		      $echo "*** because a test_compile did reveal that the linker did not use this one"
36341ab64890Smrg		      $echo "*** as a dynamic dependency that programs can get resolved with at runtime."
36351ab64890Smrg		    fi
36361ab64890Smrg		  fi
36371ab64890Smrg		else
36381ab64890Smrg		  droppeddeps=yes
36391ab64890Smrg		  $echo
36401ab64890Smrg		  $echo "*** Warning!  Library $i is needed by this library but I was not able to"
36411ab64890Smrg		  $echo "*** make it link in!  You will probably need to install it or some"
36421ab64890Smrg		  $echo "*** library that it depends on before this library will be fully"
36431ab64890Smrg		  $echo "*** functional.  Installing it before continuing would be even better."
36441ab64890Smrg		fi
36451ab64890Smrg	      else
36461ab64890Smrg		newdeplibs="$newdeplibs $i"
36471ab64890Smrg	      fi
36481ab64890Smrg	    done
36491ab64890Smrg	  fi
36501ab64890Smrg	  ;;
36511ab64890Smrg	file_magic*)
36521ab64890Smrg	  set dummy $deplibs_check_method
36531ab64890Smrg	  file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
36541ab64890Smrg	  for a_deplib in $deplibs; do
36551ab64890Smrg	    name=`expr $a_deplib : '-l\(.*\)'`
36561ab64890Smrg	    # If $name is empty we are operating on a -L argument.
36571ab64890Smrg            if test "$name" != "" && test  "$name" != "0"; then
36581ab64890Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
36591ab64890Smrg		case " $predeps $postdeps " in
36601ab64890Smrg		*" $a_deplib "*)
36611ab64890Smrg		  newdeplibs="$newdeplibs $a_deplib"
36621ab64890Smrg		  a_deplib=""
36631ab64890Smrg		  ;;
36641ab64890Smrg		esac
36651ab64890Smrg	      fi
36661ab64890Smrg	      if test -n "$a_deplib" ; then
36671ab64890Smrg		libname=`eval \\$echo \"$libname_spec\"`
36681ab64890Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
36691ab64890Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
36701ab64890Smrg		  for potent_lib in $potential_libs; do
36711ab64890Smrg		      # Follow soft links.
36721ab64890Smrg		      if ls -lLd "$potent_lib" 2>/dev/null \
36731ab64890Smrg			 | grep " -> " >/dev/null; then
36741ab64890Smrg			continue
36751ab64890Smrg		      fi
36761ab64890Smrg		      # The statement above tries to avoid entering an
36771ab64890Smrg		      # endless loop below, in case of cyclic links.
36781ab64890Smrg		      # We might still enter an endless loop, since a link
36791ab64890Smrg		      # loop can be closed while we follow links,
36801ab64890Smrg		      # but so what?
36811ab64890Smrg		      potlib="$potent_lib"
36821ab64890Smrg		      while test -h "$potlib" 2>/dev/null; do
36831ab64890Smrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
36841ab64890Smrg			case $potliblink in
36851ab64890Smrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
36861ab64890Smrg			*) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
36871ab64890Smrg			esac
36881ab64890Smrg		      done
36891ab64890Smrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
36901ab64890Smrg			 | ${SED} 10q \
36911ab64890Smrg			 | $EGREP "$file_magic_regex" > /dev/null; then
36921ab64890Smrg			newdeplibs="$newdeplibs $a_deplib"
36931ab64890Smrg			a_deplib=""
36941ab64890Smrg			break 2
36951ab64890Smrg		      fi
36961ab64890Smrg		  done
36971ab64890Smrg		done
36981ab64890Smrg	      fi
36991ab64890Smrg	      if test -n "$a_deplib" ; then
37001ab64890Smrg		droppeddeps=yes
37011ab64890Smrg		$echo
37021ab64890Smrg		$echo "*** Warning: linker path does not have real file for library $a_deplib."
37031ab64890Smrg		$echo "*** I have the capability to make that library automatically link in when"
37041ab64890Smrg		$echo "*** you link to this library.  But I can only do this if you have a"
37051ab64890Smrg		$echo "*** shared version of the library, which you do not appear to have"
37061ab64890Smrg		$echo "*** because I did check the linker path looking for a file starting"
37071ab64890Smrg		if test -z "$potlib" ; then
37081ab64890Smrg		  $echo "*** with $libname but no candidates were found. (...for file magic test)"
37091ab64890Smrg		else
37101ab64890Smrg		  $echo "*** with $libname and none of the candidates passed a file format test"
37111ab64890Smrg		  $echo "*** using a file magic. Last file checked: $potlib"
37121ab64890Smrg		fi
37131ab64890Smrg	      fi
37141ab64890Smrg	    else
37151ab64890Smrg	      # Add a -L argument.
37161ab64890Smrg	      newdeplibs="$newdeplibs $a_deplib"
37171ab64890Smrg	    fi
37181ab64890Smrg	  done # Gone through all deplibs.
37191ab64890Smrg	  ;;
37201ab64890Smrg	match_pattern*)
37211ab64890Smrg	  set dummy $deplibs_check_method
37221ab64890Smrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
37231ab64890Smrg	  for a_deplib in $deplibs; do
37241ab64890Smrg	    name=`expr $a_deplib : '-l\(.*\)'`
37251ab64890Smrg	    # If $name is empty we are operating on a -L argument.
37261ab64890Smrg	    if test -n "$name" && test "$name" != "0"; then
37271ab64890Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
37281ab64890Smrg		case " $predeps $postdeps " in
37291ab64890Smrg		*" $a_deplib "*)
37301ab64890Smrg		  newdeplibs="$newdeplibs $a_deplib"
37311ab64890Smrg		  a_deplib=""
37321ab64890Smrg		  ;;
37331ab64890Smrg		esac
37341ab64890Smrg	      fi
37351ab64890Smrg	      if test -n "$a_deplib" ; then
37361ab64890Smrg		libname=`eval \\$echo \"$libname_spec\"`
37371ab64890Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
37381ab64890Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
37391ab64890Smrg		  for potent_lib in $potential_libs; do
37401ab64890Smrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
37411ab64890Smrg		    if eval $echo \"$potent_lib\" 2>/dev/null \
37421ab64890Smrg		        | ${SED} 10q \
37431ab64890Smrg		        | $EGREP "$match_pattern_regex" > /dev/null; then
37441ab64890Smrg		      newdeplibs="$newdeplibs $a_deplib"
37451ab64890Smrg		      a_deplib=""
37461ab64890Smrg		      break 2
37471ab64890Smrg		    fi
37481ab64890Smrg		  done
37491ab64890Smrg		done
37501ab64890Smrg	      fi
37511ab64890Smrg	      if test -n "$a_deplib" ; then
37521ab64890Smrg		droppeddeps=yes
37531ab64890Smrg		$echo
37541ab64890Smrg		$echo "*** Warning: linker path does not have real file for library $a_deplib."
37551ab64890Smrg		$echo "*** I have the capability to make that library automatically link in when"
37561ab64890Smrg		$echo "*** you link to this library.  But I can only do this if you have a"
37571ab64890Smrg		$echo "*** shared version of the library, which you do not appear to have"
37581ab64890Smrg		$echo "*** because I did check the linker path looking for a file starting"
37591ab64890Smrg		if test -z "$potlib" ; then
37601ab64890Smrg		  $echo "*** with $libname but no candidates were found. (...for regex pattern test)"
37611ab64890Smrg		else
37621ab64890Smrg		  $echo "*** with $libname and none of the candidates passed a file format test"
37631ab64890Smrg		  $echo "*** using a regex pattern. Last file checked: $potlib"
37641ab64890Smrg		fi
37651ab64890Smrg	      fi
37661ab64890Smrg	    else
37671ab64890Smrg	      # Add a -L argument.
37681ab64890Smrg	      newdeplibs="$newdeplibs $a_deplib"
37691ab64890Smrg	    fi
37701ab64890Smrg	  done # Gone through all deplibs.
37711ab64890Smrg	  ;;
37721ab64890Smrg	none | unknown | *)
37731ab64890Smrg	  newdeplibs=""
37741ab64890Smrg	  tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
37751ab64890Smrg	    -e 's/ -[LR][^ ]*//g'`
37761ab64890Smrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
37771ab64890Smrg	    for i in $predeps $postdeps ; do
37781ab64890Smrg	      # can't use Xsed below, because $i might contain '/'
37791ab64890Smrg	      tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"`
37801ab64890Smrg	    done
37811ab64890Smrg	  fi
37821ab64890Smrg	  if $echo "X $tmp_deplibs" | $Xsed -e 's/[ 	]//g' \
37831ab64890Smrg	    | grep . >/dev/null; then
37841ab64890Smrg	    $echo
37851ab64890Smrg	    if test "X$deplibs_check_method" = "Xnone"; then
37861ab64890Smrg	      $echo "*** Warning: inter-library dependencies are not supported in this platform."
37871ab64890Smrg	    else
37881ab64890Smrg	      $echo "*** Warning: inter-library dependencies are not known to be supported."
37891ab64890Smrg	    fi
37901ab64890Smrg	    $echo "*** All declared inter-library dependencies are being dropped."
37911ab64890Smrg	    droppeddeps=yes
37921ab64890Smrg	  fi
37931ab64890Smrg	  ;;
37941ab64890Smrg	esac
37951ab64890Smrg	versuffix=$versuffix_save
37961ab64890Smrg	major=$major_save
37971ab64890Smrg	release=$release_save
37981ab64890Smrg	libname=$libname_save
37991ab64890Smrg	name=$name_save
38001ab64890Smrg
38011ab64890Smrg	case $host in
38021ab64890Smrg	*-*-rhapsody* | *-*-darwin1.[012])
38031ab64890Smrg	  # On Rhapsody replace the C library is the System framework
38041ab64890Smrg	  newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'`
38051ab64890Smrg	  ;;
38061ab64890Smrg	esac
38071ab64890Smrg
38081ab64890Smrg	if test "$droppeddeps" = yes; then
38091ab64890Smrg	  if test "$module" = yes; then
38101ab64890Smrg	    $echo
38111ab64890Smrg	    $echo "*** Warning: libtool could not satisfy all declared inter-library"
38121ab64890Smrg	    $echo "*** dependencies of module $libname.  Therefore, libtool will create"
38131ab64890Smrg	    $echo "*** a static module, that should work as long as the dlopening"
38141ab64890Smrg	    $echo "*** application is linked with the -dlopen flag."
38151ab64890Smrg	    if test -z "$global_symbol_pipe"; then
38161ab64890Smrg	      $echo
38171ab64890Smrg	      $echo "*** However, this would only work if libtool was able to extract symbol"
38181ab64890Smrg	      $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
38191ab64890Smrg	      $echo "*** not find such a program.  So, this module is probably useless."
38201ab64890Smrg	      $echo "*** \`nm' from GNU binutils and a full rebuild may help."
38211ab64890Smrg	    fi
38221ab64890Smrg	    if test "$build_old_libs" = no; then
38231ab64890Smrg	      oldlibs="$output_objdir/$libname.$libext"
38241ab64890Smrg	      build_libtool_libs=module
38251ab64890Smrg	      build_old_libs=yes
38261ab64890Smrg	    else
38271ab64890Smrg	      build_libtool_libs=no
38281ab64890Smrg	    fi
38291ab64890Smrg	  else
38301ab64890Smrg	    $echo "*** The inter-library dependencies that have been dropped here will be"
38311ab64890Smrg	    $echo "*** automatically added whenever a program is linked with this library"
38321ab64890Smrg	    $echo "*** or is declared to -dlopen it."
38331ab64890Smrg
38341ab64890Smrg	    if test "$allow_undefined" = no; then
38351ab64890Smrg	      $echo
38361ab64890Smrg	      $echo "*** Since this library must not contain undefined symbols,"
38371ab64890Smrg	      $echo "*** because either the platform does not support them or"
38381ab64890Smrg	      $echo "*** it was explicitly requested with -no-undefined,"
38391ab64890Smrg	      $echo "*** libtool will only create a static version of it."
38401ab64890Smrg	      if test "$build_old_libs" = no; then
38411ab64890Smrg		oldlibs="$output_objdir/$libname.$libext"
38421ab64890Smrg		build_libtool_libs=module
38431ab64890Smrg		build_old_libs=yes
38441ab64890Smrg	      else
38451ab64890Smrg		build_libtool_libs=no
38461ab64890Smrg	      fi
38471ab64890Smrg	    fi
38481ab64890Smrg	  fi
38491ab64890Smrg	fi
38501ab64890Smrg	# Done checking deplibs!
38511ab64890Smrg	deplibs=$newdeplibs
38521ab64890Smrg      fi
38531ab64890Smrg
38541ab64890Smrg
38551ab64890Smrg      # move library search paths that coincide with paths to not yet
38561ab64890Smrg      # installed libraries to the beginning of the library search list
38571ab64890Smrg      new_libs=
38581ab64890Smrg      for path in $notinst_path; do
38591ab64890Smrg	case " $new_libs " in
38601ab64890Smrg	*" -L$path/$objdir "*) ;;
38611ab64890Smrg	*)
38621ab64890Smrg	  case " $deplibs " in
38631ab64890Smrg	  *" -L$path/$objdir "*)
38641ab64890Smrg	    new_libs="$new_libs -L$path/$objdir" ;;
38651ab64890Smrg	  esac
38661ab64890Smrg	  ;;
38671ab64890Smrg	esac
38681ab64890Smrg      done
38691ab64890Smrg      for deplib in $deplibs; do
38701ab64890Smrg	case $deplib in
38711ab64890Smrg	-L*)
38721ab64890Smrg	  case " $new_libs " in
38731ab64890Smrg	  *" $deplib "*) ;;
38741ab64890Smrg	  *) new_libs="$new_libs $deplib" ;;
38751ab64890Smrg	  esac
38761ab64890Smrg	  ;;
38771ab64890Smrg	*) new_libs="$new_libs $deplib" ;;
38781ab64890Smrg	esac
38791ab64890Smrg      done
38801ab64890Smrg      deplibs="$new_libs"
38811ab64890Smrg
38821ab64890Smrg
38831ab64890Smrg      # All the library-specific variables (install_libdir is set above).
38841ab64890Smrg      library_names=
38851ab64890Smrg      old_library=
38861ab64890Smrg      dlname=
38871ab64890Smrg
38881ab64890Smrg      # Test again, we may have decided not to build it any more
38891ab64890Smrg      if test "$build_libtool_libs" = yes; then
38901ab64890Smrg	if test "$hardcode_into_libs" = yes; then
38911ab64890Smrg	  # Hardcode the library paths
38921ab64890Smrg	  hardcode_libdirs=
38931ab64890Smrg	  dep_rpath=
38941ab64890Smrg	  rpath="$finalize_rpath"
38951ab64890Smrg	  test "$mode" != relink && rpath="$compile_rpath$rpath"
38961ab64890Smrg	  for libdir in $rpath; do
38971ab64890Smrg	    if test -n "$hardcode_libdir_flag_spec"; then
38981ab64890Smrg	      if test -n "$hardcode_libdir_separator"; then
38991ab64890Smrg		if test -z "$hardcode_libdirs"; then
39001ab64890Smrg		  hardcode_libdirs="$libdir"
39011ab64890Smrg		else
39021ab64890Smrg		  # Just accumulate the unique libdirs.
39031ab64890Smrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
39041ab64890Smrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
39051ab64890Smrg		    ;;
39061ab64890Smrg		  *)
39071ab64890Smrg		    hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
39081ab64890Smrg		    ;;
39091ab64890Smrg		  esac
39101ab64890Smrg		fi
39111ab64890Smrg	      else
39121ab64890Smrg		eval flag=\"$hardcode_libdir_flag_spec\"
39131ab64890Smrg		dep_rpath="$dep_rpath $flag"
39141ab64890Smrg	      fi
39151ab64890Smrg	    elif test -n "$runpath_var"; then
39161ab64890Smrg	      case "$perm_rpath " in
39171ab64890Smrg	      *" $libdir "*) ;;
39181ab64890Smrg	      *) perm_rpath="$perm_rpath $libdir" ;;
39191ab64890Smrg	      esac
39201ab64890Smrg	    fi
39211ab64890Smrg	  done
39221ab64890Smrg	  # Substitute the hardcoded libdirs into the rpath.
39231ab64890Smrg	  if test -n "$hardcode_libdir_separator" &&
39241ab64890Smrg	     test -n "$hardcode_libdirs"; then
39251ab64890Smrg	    libdir="$hardcode_libdirs"
39261ab64890Smrg	    if test -n "$hardcode_libdir_flag_spec_ld"; then
39271ab64890Smrg	      case $archive_cmds in
39281ab64890Smrg	      *\$LD*) eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" ;;
39291ab64890Smrg	      *)      eval dep_rpath=\"$hardcode_libdir_flag_spec\" ;;
39301ab64890Smrg	      esac
39311ab64890Smrg	    else
39321ab64890Smrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
39331ab64890Smrg	    fi
39341ab64890Smrg	  fi
39351ab64890Smrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
39361ab64890Smrg	    # We should set the runpath_var.
39371ab64890Smrg	    rpath=
39381ab64890Smrg	    for dir in $perm_rpath; do
39391ab64890Smrg	      rpath="$rpath$dir:"
39401ab64890Smrg	    done
39411ab64890Smrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
39421ab64890Smrg	  fi
39431ab64890Smrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
39441ab64890Smrg	fi
39451ab64890Smrg
39461ab64890Smrg	shlibpath="$finalize_shlibpath"
39471ab64890Smrg	test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
39481ab64890Smrg	if test -n "$shlibpath"; then
39491ab64890Smrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
39501ab64890Smrg	fi
39511ab64890Smrg
39521ab64890Smrg	# Get the real and link names of the library.
39531ab64890Smrg	eval shared_ext=\"$shrext_cmds\"
39541ab64890Smrg	eval library_names=\"$library_names_spec\"
39551ab64890Smrg	set dummy $library_names
39561ab64890Smrg	realname="$2"
39571ab64890Smrg	shift; shift
39581ab64890Smrg
39591ab64890Smrg	if test -n "$soname_spec"; then
39601ab64890Smrg	  eval soname=\"$soname_spec\"
39611ab64890Smrg	else
39621ab64890Smrg	  soname="$realname"
39631ab64890Smrg	fi
39641ab64890Smrg	if test -z "$dlname"; then
39651ab64890Smrg	  dlname=$soname
39661ab64890Smrg	fi
39671ab64890Smrg
39681ab64890Smrg	lib="$output_objdir/$realname"
39691ab64890Smrg	linknames=
39701ab64890Smrg	for link
39711ab64890Smrg	do
39721ab64890Smrg	  linknames="$linknames $link"
39731ab64890Smrg	done
39741ab64890Smrg
39751ab64890Smrg	# Use standard objects if they are pic
39761ab64890Smrg	test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
39771ab64890Smrg
39781ab64890Smrg	# Prepare the list of exported symbols
39791ab64890Smrg	if test -z "$export_symbols"; then
39801ab64890Smrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
39811ab64890Smrg	    $show "generating symbol list for \`$libname.la'"
39821ab64890Smrg	    export_symbols="$output_objdir/$libname.exp"
39831ab64890Smrg	    $run $rm $export_symbols
39841ab64890Smrg	    cmds=$export_symbols_cmds
39851ab64890Smrg	    save_ifs="$IFS"; IFS='~'
39861ab64890Smrg	    for cmd in $cmds; do
39871ab64890Smrg	      IFS="$save_ifs"
39881ab64890Smrg	      eval cmd=\"$cmd\"
39891ab64890Smrg	      if len=`expr "X$cmd" : ".*"` &&
39901ab64890Smrg	       test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
39911ab64890Smrg	        $show "$cmd"
39921ab64890Smrg	        $run eval "$cmd" || exit $?
39931ab64890Smrg	        skipped_export=false
39941ab64890Smrg	      else
39951ab64890Smrg	        # The command line is too long to execute in one step.
39961ab64890Smrg	        $show "using reloadable object file for export list..."
39971ab64890Smrg	        skipped_export=:
39981ab64890Smrg		# Break out early, otherwise skipped_export may be
39991ab64890Smrg		# set to false by a later but shorter cmd.
40001ab64890Smrg		break
40011ab64890Smrg	      fi
40021ab64890Smrg	    done
40031ab64890Smrg	    IFS="$save_ifs"
40041ab64890Smrg	    if test -n "$export_symbols_regex"; then
40051ab64890Smrg	      $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""
40061ab64890Smrg	      $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
40071ab64890Smrg	      $show "$mv \"${export_symbols}T\" \"$export_symbols\""
40081ab64890Smrg	      $run eval '$mv "${export_symbols}T" "$export_symbols"'
40091ab64890Smrg	    fi
40101ab64890Smrg	  fi
40111ab64890Smrg	fi
40121ab64890Smrg
40131ab64890Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
40141ab64890Smrg	  $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"'
40151ab64890Smrg	fi
40161ab64890Smrg
40171ab64890Smrg	tmp_deplibs=
40181ab64890Smrg	for test_deplib in $deplibs; do
40191ab64890Smrg		case " $convenience " in
40201ab64890Smrg		*" $test_deplib "*) ;;
40211ab64890Smrg		*)
40221ab64890Smrg			tmp_deplibs="$tmp_deplibs $test_deplib"
40231ab64890Smrg			;;
40241ab64890Smrg		esac
40251ab64890Smrg	done
40261ab64890Smrg	deplibs="$tmp_deplibs"
40271ab64890Smrg
40281ab64890Smrg	if test -n "$convenience"; then
40291ab64890Smrg	  if test -n "$whole_archive_flag_spec"; then
40301ab64890Smrg	    save_libobjs=$libobjs
40311ab64890Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
40321ab64890Smrg	  else
40331ab64890Smrg	    gentop="$output_objdir/${outputname}x"
40341ab64890Smrg	    generated="$generated $gentop"
40351ab64890Smrg
40361ab64890Smrg	    func_extract_archives $gentop $convenience
40371ab64890Smrg	    libobjs="$libobjs $func_extract_archives_result"
40381ab64890Smrg	  fi
40391ab64890Smrg	fi
40401ab64890Smrg	
40411ab64890Smrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
40421ab64890Smrg	  eval flag=\"$thread_safe_flag_spec\"
40431ab64890Smrg	  linker_flags="$linker_flags $flag"
40441ab64890Smrg	fi
40451ab64890Smrg
40461ab64890Smrg	# Make a backup of the uninstalled library when relinking
40471ab64890Smrg	if test "$mode" = relink; then
40481ab64890Smrg	  $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $?
40491ab64890Smrg	fi
40501ab64890Smrg
40511ab64890Smrg	# Do each of the archive commands.
40521ab64890Smrg	if test "$module" = yes && test -n "$module_cmds" ; then
40531ab64890Smrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
40541ab64890Smrg	    eval test_cmds=\"$module_expsym_cmds\"
40551ab64890Smrg	    cmds=$module_expsym_cmds
40561ab64890Smrg	  else
40571ab64890Smrg	    eval test_cmds=\"$module_cmds\"
40581ab64890Smrg	    cmds=$module_cmds
40591ab64890Smrg	  fi
40601ab64890Smrg	else
40611ab64890Smrg	if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
40621ab64890Smrg	  eval test_cmds=\"$archive_expsym_cmds\"
40631ab64890Smrg	  cmds=$archive_expsym_cmds
40641ab64890Smrg	else
40651ab64890Smrg	  eval test_cmds=\"$archive_cmds\"
40661ab64890Smrg	  cmds=$archive_cmds
40671ab64890Smrg	  fi
40681ab64890Smrg	fi
40691ab64890Smrg
40701ab64890Smrg	if test "X$skipped_export" != "X:" &&
40711ab64890Smrg	   len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
40721ab64890Smrg	   test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
40731ab64890Smrg	  :
40741ab64890Smrg	else
40751ab64890Smrg	  # The command line is too long to link in one step, link piecewise.
40761ab64890Smrg	  $echo "creating reloadable object files..."
40771ab64890Smrg
40781ab64890Smrg	  # Save the value of $output and $libobjs because we want to
40791ab64890Smrg	  # use them later.  If we have whole_archive_flag_spec, we
40801ab64890Smrg	  # want to use save_libobjs as it was before
40811ab64890Smrg	  # whole_archive_flag_spec was expanded, because we can't
40821ab64890Smrg	  # assume the linker understands whole_archive_flag_spec.
40831ab64890Smrg	  # This may have to be revisited, in case too many
40841ab64890Smrg	  # convenience libraries get linked in and end up exceeding
40851ab64890Smrg	  # the spec.
40861ab64890Smrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
40871ab64890Smrg	    save_libobjs=$libobjs
40881ab64890Smrg	  fi
40891ab64890Smrg	  save_output=$output
40901ab64890Smrg	  output_la=`$echo "X$output" | $Xsed -e "$basename"`
40911ab64890Smrg
40921ab64890Smrg	  # Clear the reloadable object creation command queue and
40931ab64890Smrg	  # initialize k to one.
40941ab64890Smrg	  test_cmds=
40951ab64890Smrg	  concat_cmds=
40961ab64890Smrg	  objlist=
40971ab64890Smrg	  delfiles=
40981ab64890Smrg	  last_robj=
40991ab64890Smrg	  k=1
41001ab64890Smrg	  output=$output_objdir/$output_la-${k}.$objext
41011ab64890Smrg	  # Loop over the list of objects to be linked.
41021ab64890Smrg	  for obj in $save_libobjs
41031ab64890Smrg	  do
41041ab64890Smrg	    eval test_cmds=\"$reload_cmds $objlist $last_robj\"
41051ab64890Smrg	    if test "X$objlist" = X ||
41061ab64890Smrg	       { len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
41071ab64890Smrg		 test "$len" -le "$max_cmd_len"; }; then
41081ab64890Smrg	      objlist="$objlist $obj"
41091ab64890Smrg	    else
41101ab64890Smrg	      # The command $test_cmds is almost too long, add a
41111ab64890Smrg	      # command to the queue.
41121ab64890Smrg	      if test "$k" -eq 1 ; then
41131ab64890Smrg		# The first file doesn't have a previous command to add.
41141ab64890Smrg		eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
41151ab64890Smrg	      else
41161ab64890Smrg		# All subsequent reloadable object files will link in
41171ab64890Smrg		# the last one created.
41181ab64890Smrg		eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\"
41191ab64890Smrg	      fi
41201ab64890Smrg	      last_robj=$output_objdir/$output_la-${k}.$objext
41211ab64890Smrg	      k=`expr $k + 1`
41221ab64890Smrg	      output=$output_objdir/$output_la-${k}.$objext
41231ab64890Smrg	      objlist=$obj
41241ab64890Smrg	      len=1
41251ab64890Smrg	    fi
41261ab64890Smrg	  done
41271ab64890Smrg	  # Handle the remaining objects by creating one last
41281ab64890Smrg	  # reloadable object file.  All subsequent reloadable object
41291ab64890Smrg	  # files will link in the last one created.
41301ab64890Smrg	  test -z "$concat_cmds" || concat_cmds=$concat_cmds~
41311ab64890Smrg	  eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
41321ab64890Smrg
41331ab64890Smrg	  if ${skipped_export-false}; then
41341ab64890Smrg	    $show "generating symbol list for \`$libname.la'"
41351ab64890Smrg	    export_symbols="$output_objdir/$libname.exp"
41361ab64890Smrg	    $run $rm $export_symbols
41371ab64890Smrg	    libobjs=$output
41381ab64890Smrg	    # Append the command to create the export file.
41391ab64890Smrg	    eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\"
41401ab64890Smrg          fi
41411ab64890Smrg
41421ab64890Smrg	  # Set up a command to remove the reloadable object files
41431ab64890Smrg	  # after they are used.
41441ab64890Smrg	  i=0
41451ab64890Smrg	  while test "$i" -lt "$k"
41461ab64890Smrg	  do
41471ab64890Smrg	    i=`expr $i + 1`
41481ab64890Smrg	    delfiles="$delfiles $output_objdir/$output_la-${i}.$objext"
41491ab64890Smrg	  done
41501ab64890Smrg
41511ab64890Smrg	  $echo "creating a temporary reloadable object file: $output"
41521ab64890Smrg
41531ab64890Smrg	  # Loop through the commands generated above and execute them.
41541ab64890Smrg	  save_ifs="$IFS"; IFS='~'
41551ab64890Smrg	  for cmd in $concat_cmds; do
41561ab64890Smrg	    IFS="$save_ifs"
41571ab64890Smrg	    $show "$cmd"
41581ab64890Smrg	    $run eval "$cmd" || exit $?
41591ab64890Smrg	  done
41601ab64890Smrg	  IFS="$save_ifs"
41611ab64890Smrg
41621ab64890Smrg	  libobjs=$output
41631ab64890Smrg	  # Restore the value of output.
41641ab64890Smrg	  output=$save_output
41651ab64890Smrg
41661ab64890Smrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
41671ab64890Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
41681ab64890Smrg	  fi
41691ab64890Smrg	  # Expand the library linking commands again to reset the
41701ab64890Smrg	  # value of $libobjs for piecewise linking.
41711ab64890Smrg
41721ab64890Smrg	  # Do each of the archive commands.
41731ab64890Smrg	  if test "$module" = yes && test -n "$module_cmds" ; then
41741ab64890Smrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
41751ab64890Smrg	      cmds=$module_expsym_cmds
41761ab64890Smrg	    else
41771ab64890Smrg	      cmds=$module_cmds
41781ab64890Smrg	    fi
41791ab64890Smrg	  else
41801ab64890Smrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
41811ab64890Smrg	    cmds=$archive_expsym_cmds
41821ab64890Smrg	  else
41831ab64890Smrg	    cmds=$archive_cmds
41841ab64890Smrg	    fi
41851ab64890Smrg	  fi
41861ab64890Smrg
41871ab64890Smrg	  # Append the command to remove the reloadable object files
41881ab64890Smrg	  # to the just-reset $cmds.
41891ab64890Smrg	  eval cmds=\"\$cmds~\$rm $delfiles\"
41901ab64890Smrg	fi
41911ab64890Smrg	save_ifs="$IFS"; IFS='~'
41921ab64890Smrg	for cmd in $cmds; do
41931ab64890Smrg	  IFS="$save_ifs"
41941ab64890Smrg	  eval cmd=\"$cmd\"
41951ab64890Smrg	  $show "$cmd"
41961ab64890Smrg	  $run eval "$cmd" || {
41971ab64890Smrg	    lt_exit=$?
41981ab64890Smrg
41991ab64890Smrg	    # Restore the uninstalled library and exit
42001ab64890Smrg	    if test "$mode" = relink; then
42011ab64890Smrg	      $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
42021ab64890Smrg	    fi
42031ab64890Smrg
42041ab64890Smrg	    exit $lt_exit
42051ab64890Smrg	  }
42061ab64890Smrg	done
42071ab64890Smrg	IFS="$save_ifs"
42081ab64890Smrg
42091ab64890Smrg	# Restore the uninstalled library and exit
42101ab64890Smrg	if test "$mode" = relink; then
42111ab64890Smrg	  $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $?
42121ab64890Smrg
42131ab64890Smrg	  if test -n "$convenience"; then
42141ab64890Smrg	    if test -z "$whole_archive_flag_spec"; then
42151ab64890Smrg	      $show "${rm}r $gentop"
42161ab64890Smrg	      $run ${rm}r "$gentop"
42171ab64890Smrg	    fi
42181ab64890Smrg	  fi
42191ab64890Smrg
42201ab64890Smrg	  exit $EXIT_SUCCESS
42211ab64890Smrg	fi
42221ab64890Smrg
42231ab64890Smrg	# Create links to the real library.
42241ab64890Smrg	for linkname in $linknames; do
42251ab64890Smrg	  if test "$realname" != "$linkname"; then
42261ab64890Smrg	    $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)"
42271ab64890Smrg	    $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $?
42281ab64890Smrg	  fi
42291ab64890Smrg	done
42301ab64890Smrg
42311ab64890Smrg	# If -module or -export-dynamic was specified, set the dlname.
42321ab64890Smrg	if test "$module" = yes || test "$export_dynamic" = yes; then
42331ab64890Smrg	  # On all known operating systems, these are identical.
42341ab64890Smrg	  dlname="$soname"
42351ab64890Smrg	fi
42361ab64890Smrg      fi
42371ab64890Smrg      ;;
42381ab64890Smrg
42391ab64890Smrg    obj)
42401ab64890Smrg      if test -n "$deplibs"; then
42411ab64890Smrg	$echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2
42421ab64890Smrg      fi
42431ab64890Smrg
42441ab64890Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
42451ab64890Smrg	$echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
42461ab64890Smrg      fi
42471ab64890Smrg
42481ab64890Smrg      if test -n "$rpath"; then
42491ab64890Smrg	$echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2
42501ab64890Smrg      fi
42511ab64890Smrg
42521ab64890Smrg      if test -n "$xrpath"; then
42531ab64890Smrg	$echo "$modename: warning: \`-R' is ignored for objects" 1>&2
42541ab64890Smrg      fi
42551ab64890Smrg
42561ab64890Smrg      if test -n "$vinfo"; then
42571ab64890Smrg	$echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2
42581ab64890Smrg      fi
42591ab64890Smrg
42601ab64890Smrg      if test -n "$release"; then
42611ab64890Smrg	$echo "$modename: warning: \`-release' is ignored for objects" 1>&2
42621ab64890Smrg      fi
42631ab64890Smrg
42641ab64890Smrg      case $output in
42651ab64890Smrg      *.lo)
42661ab64890Smrg	if test -n "$objs$old_deplibs"; then
42671ab64890Smrg	  $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
42681ab64890Smrg	  exit $EXIT_FAILURE
42691ab64890Smrg	fi
42701ab64890Smrg	libobj="$output"
42711ab64890Smrg	obj=`$echo "X$output" | $Xsed -e "$lo2o"`
42721ab64890Smrg	;;
42731ab64890Smrg      *)
42741ab64890Smrg	libobj=
42751ab64890Smrg	obj="$output"
42761ab64890Smrg	;;
42771ab64890Smrg      esac
42781ab64890Smrg
42791ab64890Smrg      # Delete the old objects.
42801ab64890Smrg      $run $rm $obj $libobj
42811ab64890Smrg
42821ab64890Smrg      # Objects from convenience libraries.  This assumes
42831ab64890Smrg      # single-version convenience libraries.  Whenever we create
42841ab64890Smrg      # different ones for PIC/non-PIC, this we'll have to duplicate
42851ab64890Smrg      # the extraction.
42861ab64890Smrg      reload_conv_objs=
42871ab64890Smrg      gentop=
42881ab64890Smrg      # reload_cmds runs $LD directly, so let us get rid of
42891ab64890Smrg      # -Wl from whole_archive_flag_spec and hope we can get by with
42901ab64890Smrg      # turning comma into space..
42911ab64890Smrg      wl=
42921ab64890Smrg
42931ab64890Smrg      if test -n "$convenience"; then
42941ab64890Smrg	if test -n "$whole_archive_flag_spec"; then
42951ab64890Smrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
42961ab64890Smrg	  reload_conv_objs=$reload_objs\ `$echo "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'`
42971ab64890Smrg	else
42981ab64890Smrg	  gentop="$output_objdir/${obj}x"
42991ab64890Smrg	  generated="$generated $gentop"
43001ab64890Smrg
43011ab64890Smrg	  func_extract_archives $gentop $convenience
43021ab64890Smrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
43031ab64890Smrg	fi
43041ab64890Smrg      fi
43051ab64890Smrg
43061ab64890Smrg      # Create the old-style object.
43071ab64890Smrg      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
43081ab64890Smrg
43091ab64890Smrg      output="$obj"
43101ab64890Smrg      cmds=$reload_cmds
43111ab64890Smrg      save_ifs="$IFS"; IFS='~'
43121ab64890Smrg      for cmd in $cmds; do
43131ab64890Smrg	IFS="$save_ifs"
43141ab64890Smrg	eval cmd=\"$cmd\"
43151ab64890Smrg	$show "$cmd"
43161ab64890Smrg	$run eval "$cmd" || exit $?
43171ab64890Smrg      done
43181ab64890Smrg      IFS="$save_ifs"
43191ab64890Smrg
43201ab64890Smrg      # Exit if we aren't doing a library object file.
43211ab64890Smrg      if test -z "$libobj"; then
43221ab64890Smrg	if test -n "$gentop"; then
43231ab64890Smrg	  $show "${rm}r $gentop"
43241ab64890Smrg	  $run ${rm}r $gentop
43251ab64890Smrg	fi
43261ab64890Smrg
43271ab64890Smrg	exit $EXIT_SUCCESS
43281ab64890Smrg      fi
43291ab64890Smrg
43301ab64890Smrg      if test "$build_libtool_libs" != yes; then
43311ab64890Smrg	if test -n "$gentop"; then
43321ab64890Smrg	  $show "${rm}r $gentop"
43331ab64890Smrg	  $run ${rm}r $gentop
43341ab64890Smrg	fi
43351ab64890Smrg
43361ab64890Smrg	# Create an invalid libtool object if no PIC, so that we don't
43371ab64890Smrg	# accidentally link it into a program.
43381ab64890Smrg	# $show "echo timestamp > $libobj"
43391ab64890Smrg	# $run eval "echo timestamp > $libobj" || exit $?
43401ab64890Smrg	exit $EXIT_SUCCESS
43411ab64890Smrg      fi
43421ab64890Smrg
43431ab64890Smrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
43441ab64890Smrg	# Only do commands if we really have different PIC objects.
43451ab64890Smrg	reload_objs="$libobjs $reload_conv_objs"
43461ab64890Smrg	output="$libobj"
43471ab64890Smrg	cmds=$reload_cmds
43481ab64890Smrg	save_ifs="$IFS"; IFS='~'
43491ab64890Smrg	for cmd in $cmds; do
43501ab64890Smrg	  IFS="$save_ifs"
43511ab64890Smrg	  eval cmd=\"$cmd\"
43521ab64890Smrg	  $show "$cmd"
43531ab64890Smrg	  $run eval "$cmd" || exit $?
43541ab64890Smrg	done
43551ab64890Smrg	IFS="$save_ifs"
43561ab64890Smrg      fi
43571ab64890Smrg
43581ab64890Smrg      if test -n "$gentop"; then
43591ab64890Smrg	$show "${rm}r $gentop"
43601ab64890Smrg	$run ${rm}r $gentop
43611ab64890Smrg      fi
43621ab64890Smrg
43631ab64890Smrg      exit $EXIT_SUCCESS
43641ab64890Smrg      ;;
43651ab64890Smrg
43661ab64890Smrg    prog)
43671ab64890Smrg      case $host in
43681ab64890Smrg	*cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;
43691ab64890Smrg      esac
43701ab64890Smrg      if test -n "$vinfo"; then
43711ab64890Smrg	$echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
43721ab64890Smrg      fi
43731ab64890Smrg
43741ab64890Smrg      if test -n "$release"; then
43751ab64890Smrg	$echo "$modename: warning: \`-release' is ignored for programs" 1>&2
43761ab64890Smrg      fi
43771ab64890Smrg
43781ab64890Smrg      if test "$preload" = yes; then
43791ab64890Smrg	if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown &&
43801ab64890Smrg	   test "$dlopen_self_static" = unknown; then
43811ab64890Smrg	  $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support."
43821ab64890Smrg	fi
43831ab64890Smrg      fi
43841ab64890Smrg
43851ab64890Smrg      case $host in
43861ab64890Smrg      *-*-rhapsody* | *-*-darwin1.[012])
43871ab64890Smrg	# On Rhapsody replace the C library is the System framework
43881ab64890Smrg	compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
43891ab64890Smrg	finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
43901ab64890Smrg	;;
43911ab64890Smrg      esac
43921ab64890Smrg
43931ab64890Smrg      case $host in
43941ab64890Smrg      *darwin*)
43951ab64890Smrg        # Don't allow lazy linking, it breaks C++ global constructors
43961ab64890Smrg        if test "$tagname" = CXX ; then
43971ab64890Smrg        compile_command="$compile_command ${wl}-bind_at_load"
43981ab64890Smrg        finalize_command="$finalize_command ${wl}-bind_at_load"
43991ab64890Smrg        fi
44001ab64890Smrg        ;;
44011ab64890Smrg      esac
44021ab64890Smrg
44031ab64890Smrg
44041ab64890Smrg      # move library search paths that coincide with paths to not yet
44051ab64890Smrg      # installed libraries to the beginning of the library search list
44061ab64890Smrg      new_libs=
44071ab64890Smrg      for path in $notinst_path; do
44081ab64890Smrg	case " $new_libs " in
44091ab64890Smrg	*" -L$path/$objdir "*) ;;
44101ab64890Smrg	*)
44111ab64890Smrg	  case " $compile_deplibs " in
44121ab64890Smrg	  *" -L$path/$objdir "*)
44131ab64890Smrg	    new_libs="$new_libs -L$path/$objdir" ;;
44141ab64890Smrg	  esac
44151ab64890Smrg	  ;;
44161ab64890Smrg	esac
44171ab64890Smrg      done
44181ab64890Smrg      for deplib in $compile_deplibs; do
44191ab64890Smrg	case $deplib in
44201ab64890Smrg	-L*)
44211ab64890Smrg	  case " $new_libs " in
44221ab64890Smrg	  *" $deplib "*) ;;
44231ab64890Smrg	  *) new_libs="$new_libs $deplib" ;;
44241ab64890Smrg	  esac
44251ab64890Smrg	  ;;
44261ab64890Smrg	*) new_libs="$new_libs $deplib" ;;
44271ab64890Smrg	esac
44281ab64890Smrg      done
44291ab64890Smrg      compile_deplibs="$new_libs"
44301ab64890Smrg
44311ab64890Smrg
44321ab64890Smrg      compile_command="$compile_command $compile_deplibs"
44331ab64890Smrg      finalize_command="$finalize_command $finalize_deplibs"
44341ab64890Smrg
44351ab64890Smrg      if test -n "$rpath$xrpath"; then
44361ab64890Smrg	# If the user specified any rpath flags, then add them.
44371ab64890Smrg	for libdir in $rpath $xrpath; do
44381ab64890Smrg	  # This is the magic to use -rpath.
44391ab64890Smrg	  case "$finalize_rpath " in
44401ab64890Smrg	  *" $libdir "*) ;;
44411ab64890Smrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
44421ab64890Smrg	  esac
44431ab64890Smrg	done
44441ab64890Smrg      fi
44451ab64890Smrg
44461ab64890Smrg      # Now hardcode the library paths
44471ab64890Smrg      rpath=
44481ab64890Smrg      hardcode_libdirs=
44491ab64890Smrg      for libdir in $compile_rpath $finalize_rpath; do
44501ab64890Smrg	if test -n "$hardcode_libdir_flag_spec"; then
44511ab64890Smrg	  if test -n "$hardcode_libdir_separator"; then
44521ab64890Smrg	    if test -z "$hardcode_libdirs"; then
44531ab64890Smrg	      hardcode_libdirs="$libdir"
44541ab64890Smrg	    else
44551ab64890Smrg	      # Just accumulate the unique libdirs.
44561ab64890Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
44571ab64890Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
44581ab64890Smrg		;;
44591ab64890Smrg	      *)
44601ab64890Smrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
44611ab64890Smrg		;;
44621ab64890Smrg	      esac
44631ab64890Smrg	    fi
44641ab64890Smrg	  else
44651ab64890Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
44661ab64890Smrg	    rpath="$rpath $flag"
44671ab64890Smrg	  fi
44681ab64890Smrg	elif test -n "$runpath_var"; then
44691ab64890Smrg	  case "$perm_rpath " in
44701ab64890Smrg	  *" $libdir "*) ;;
44711ab64890Smrg	  *) perm_rpath="$perm_rpath $libdir" ;;
44721ab64890Smrg	  esac
44731ab64890Smrg	fi
44741ab64890Smrg	case $host in
44751ab64890Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
44761ab64890Smrg	  testbindir=`$echo "X$libdir" | $Xsed -e 's*/lib$*/bin*'`
44771ab64890Smrg	  case :$dllsearchpath: in
44781ab64890Smrg	  *":$libdir:"*) ;;
44791ab64890Smrg	  *) dllsearchpath="$dllsearchpath:$libdir";;
44801ab64890Smrg	  esac
44811ab64890Smrg	  case :$dllsearchpath: in
44821ab64890Smrg	  *":$testbindir:"*) ;;
44831ab64890Smrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
44841ab64890Smrg	  esac
44851ab64890Smrg	  ;;
44861ab64890Smrg	esac
44871ab64890Smrg      done
44881ab64890Smrg      # Substitute the hardcoded libdirs into the rpath.
44891ab64890Smrg      if test -n "$hardcode_libdir_separator" &&
44901ab64890Smrg	 test -n "$hardcode_libdirs"; then
44911ab64890Smrg	libdir="$hardcode_libdirs"
44921ab64890Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
44931ab64890Smrg      fi
44941ab64890Smrg      compile_rpath="$rpath"
44951ab64890Smrg
44961ab64890Smrg      rpath=
44971ab64890Smrg      hardcode_libdirs=
44981ab64890Smrg      for libdir in $finalize_rpath; do
44991ab64890Smrg	if test -n "$hardcode_libdir_flag_spec"; then
45001ab64890Smrg	  if test -n "$hardcode_libdir_separator"; then
45011ab64890Smrg	    if test -z "$hardcode_libdirs"; then
45021ab64890Smrg	      hardcode_libdirs="$libdir"
45031ab64890Smrg	    else
45041ab64890Smrg	      # Just accumulate the unique libdirs.
45051ab64890Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
45061ab64890Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
45071ab64890Smrg		;;
45081ab64890Smrg	      *)
45091ab64890Smrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
45101ab64890Smrg		;;
45111ab64890Smrg	      esac
45121ab64890Smrg	    fi
45131ab64890Smrg	  else
45141ab64890Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
45151ab64890Smrg	    rpath="$rpath $flag"
45161ab64890Smrg	  fi
45171ab64890Smrg	elif test -n "$runpath_var"; then
45181ab64890Smrg	  case "$finalize_perm_rpath " in
45191ab64890Smrg	  *" $libdir "*) ;;
45201ab64890Smrg	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
45211ab64890Smrg	  esac
45221ab64890Smrg	fi
45231ab64890Smrg      done
45241ab64890Smrg      # Substitute the hardcoded libdirs into the rpath.
45251ab64890Smrg      if test -n "$hardcode_libdir_separator" &&
45261ab64890Smrg	 test -n "$hardcode_libdirs"; then
45271ab64890Smrg	libdir="$hardcode_libdirs"
45281ab64890Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
45291ab64890Smrg      fi
45301ab64890Smrg      finalize_rpath="$rpath"
45311ab64890Smrg
45321ab64890Smrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
45331ab64890Smrg	# Transform all the library objects into standard objects.
45341ab64890Smrg	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
45351ab64890Smrg	finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
45361ab64890Smrg      fi
45371ab64890Smrg
45381ab64890Smrg      dlsyms=
45391ab64890Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
45401ab64890Smrg	if test -n "$NM" && test -n "$global_symbol_pipe"; then
45411ab64890Smrg	  dlsyms="${outputname}S.c"
45421ab64890Smrg	else
45431ab64890Smrg	  $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2
45441ab64890Smrg	fi
45451ab64890Smrg      fi
45461ab64890Smrg
45471ab64890Smrg      if test -n "$dlsyms"; then
45481ab64890Smrg	case $dlsyms in
45491ab64890Smrg	"") ;;
45501ab64890Smrg	*.c)
45511ab64890Smrg	  # Discover the nlist of each of the dlfiles.
45521ab64890Smrg	  nlist="$output_objdir/${outputname}.nm"
45531ab64890Smrg
45541ab64890Smrg	  $show "$rm $nlist ${nlist}S ${nlist}T"
45551ab64890Smrg	  $run $rm "$nlist" "${nlist}S" "${nlist}T"
45561ab64890Smrg
45571ab64890Smrg	  # Parse the name list into a source file.
45581ab64890Smrg	  $show "creating $output_objdir/$dlsyms"
45591ab64890Smrg
45601ab64890Smrg	  test -z "$run" && $echo > "$output_objdir/$dlsyms" "\
45611ab64890Smrg/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */
45621ab64890Smrg/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */
45631ab64890Smrg
45641ab64890Smrg#ifdef __cplusplus
45651ab64890Smrgextern \"C\" {
45661ab64890Smrg#endif
45671ab64890Smrg
45681ab64890Smrg/* Prevent the only kind of declaration conflicts we can make. */
45691ab64890Smrg#define lt_preloaded_symbols some_other_symbol
45701ab64890Smrg
45711ab64890Smrg/* External symbol declarations for the compiler. */\
45721ab64890Smrg"
45731ab64890Smrg
45741ab64890Smrg	  if test "$dlself" = yes; then
45751ab64890Smrg	    $show "generating symbol list for \`$output'"
45761ab64890Smrg
45771ab64890Smrg	    test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist"
45781ab64890Smrg
45791ab64890Smrg	    # Add our own program objects to the symbol list.
45801ab64890Smrg	    progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
45811ab64890Smrg	    for arg in $progfiles; do
45821ab64890Smrg	      $show "extracting global C symbols from \`$arg'"
45831ab64890Smrg	      $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
45841ab64890Smrg	    done
45851ab64890Smrg
45861ab64890Smrg	    if test -n "$exclude_expsyms"; then
45871ab64890Smrg	      $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
45881ab64890Smrg	      $run eval '$mv "$nlist"T "$nlist"'
45891ab64890Smrg	    fi
45901ab64890Smrg
45911ab64890Smrg	    if test -n "$export_symbols_regex"; then
45921ab64890Smrg	      $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
45931ab64890Smrg	      $run eval '$mv "$nlist"T "$nlist"'
45941ab64890Smrg	    fi
45951ab64890Smrg
45961ab64890Smrg	    # Prepare the list of exported symbols
45971ab64890Smrg	    if test -z "$export_symbols"; then
45981ab64890Smrg	      export_symbols="$output_objdir/$outputname.exp"
45991ab64890Smrg	      $run $rm $export_symbols
46001ab64890Smrg	      $run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
46011ab64890Smrg              case $host in
46021ab64890Smrg              *cygwin* | *mingw* )
46031ab64890Smrg	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
46041ab64890Smrg		$run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
46051ab64890Smrg                ;;
46061ab64890Smrg              esac
46071ab64890Smrg	    else
46081ab64890Smrg	      $run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
46091ab64890Smrg	      $run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
46101ab64890Smrg	      $run eval 'mv "$nlist"T "$nlist"'
46111ab64890Smrg              case $host in
46121ab64890Smrg              *cygwin* | *mingw* )
46131ab64890Smrg	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
46141ab64890Smrg		$run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
46151ab64890Smrg                ;;
46161ab64890Smrg              esac
46171ab64890Smrg	    fi
46181ab64890Smrg	  fi
46191ab64890Smrg
46201ab64890Smrg	  for arg in $dlprefiles; do
46211ab64890Smrg	    $show "extracting global C symbols from \`$arg'"
46221ab64890Smrg	    name=`$echo "$arg" | ${SED} -e 's%^.*/%%'`
46231ab64890Smrg	    $run eval '$echo ": $name " >> "$nlist"'
46241ab64890Smrg	    $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
46251ab64890Smrg	  done
46261ab64890Smrg
46271ab64890Smrg	  if test -z "$run"; then
46281ab64890Smrg	    # Make sure we have at least an empty file.
46291ab64890Smrg	    test -f "$nlist" || : > "$nlist"
46301ab64890Smrg
46311ab64890Smrg	    if test -n "$exclude_expsyms"; then
46321ab64890Smrg	      $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
46331ab64890Smrg	      $mv "$nlist"T "$nlist"
46341ab64890Smrg	    fi
46351ab64890Smrg
46361ab64890Smrg	    # Try sorting and uniquifying the output.
46371ab64890Smrg	    if grep -v "^: " < "$nlist" |
46381ab64890Smrg		if sort -k 3 </dev/null >/dev/null 2>&1; then
46391ab64890Smrg		  sort -k 3
46401ab64890Smrg		else
46411ab64890Smrg		  sort +2
46421ab64890Smrg		fi |
46431ab64890Smrg		uniq > "$nlist"S; then
46441ab64890Smrg	      :
46451ab64890Smrg	    else
46461ab64890Smrg	      grep -v "^: " < "$nlist" > "$nlist"S
46471ab64890Smrg	    fi
46481ab64890Smrg
46491ab64890Smrg	    if test -f "$nlist"S; then
46501ab64890Smrg	      eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"'
46511ab64890Smrg	    else
46521ab64890Smrg	      $echo '/* NONE */' >> "$output_objdir/$dlsyms"
46531ab64890Smrg	    fi
46541ab64890Smrg
46551ab64890Smrg	    $echo >> "$output_objdir/$dlsyms" "\
46561ab64890Smrg
46571ab64890Smrg#undef lt_preloaded_symbols
46581ab64890Smrg
46591ab64890Smrg#if defined (__STDC__) && __STDC__
46601ab64890Smrg# define lt_ptr void *
46611ab64890Smrg#else
46621ab64890Smrg# define lt_ptr char *
46631ab64890Smrg# define const
46641ab64890Smrg#endif
46651ab64890Smrg
46661ab64890Smrg/* The mapping between symbol names and symbols. */
46671ab64890Smrg"
46681ab64890Smrg
46691ab64890Smrg	    case $host in
46701ab64890Smrg	    *cygwin* | *mingw* )
46711ab64890Smrg	  $echo >> "$output_objdir/$dlsyms" "\
46721ab64890Smrg/* DATA imports from DLLs on WIN32 can't be const, because
46731ab64890Smrg   runtime relocations are performed -- see ld's documentation
46741ab64890Smrg   on pseudo-relocs */
46751ab64890Smrgstruct {
46761ab64890Smrg"
46771ab64890Smrg	      ;;
46781ab64890Smrg	    * )
46791ab64890Smrg	  $echo >> "$output_objdir/$dlsyms" "\
46801ab64890Smrgconst struct {
46811ab64890Smrg"
46821ab64890Smrg	      ;;
46831ab64890Smrg	    esac
46841ab64890Smrg
46851ab64890Smrg
46861ab64890Smrg	  $echo >> "$output_objdir/$dlsyms" "\
46871ab64890Smrg  const char *name;
46881ab64890Smrg  lt_ptr address;
46891ab64890Smrg}
46901ab64890Smrglt_preloaded_symbols[] =
46911ab64890Smrg{\
46921ab64890Smrg"
46931ab64890Smrg
46941ab64890Smrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms"
46951ab64890Smrg
46961ab64890Smrg	    $echo >> "$output_objdir/$dlsyms" "\
46971ab64890Smrg  {0, (lt_ptr) 0}
46981ab64890Smrg};
46991ab64890Smrg
47001ab64890Smrg/* This works around a problem in FreeBSD linker */
47011ab64890Smrg#ifdef FREEBSD_WORKAROUND
47021ab64890Smrgstatic const void *lt_preloaded_setup() {
47031ab64890Smrg  return lt_preloaded_symbols;
47041ab64890Smrg}
47051ab64890Smrg#endif
47061ab64890Smrg
47071ab64890Smrg#ifdef __cplusplus
47081ab64890Smrg}
47091ab64890Smrg#endif\
47101ab64890Smrg"
47111ab64890Smrg	  fi
47121ab64890Smrg
47131ab64890Smrg	  pic_flag_for_symtable=
47141ab64890Smrg	  case $host in
47151ab64890Smrg	  # compiling the symbol table file with pic_flag works around
47161ab64890Smrg	  # a FreeBSD bug that causes programs to crash when -lm is
47171ab64890Smrg	  # linked before any other PIC object.  But we must not use
47181ab64890Smrg	  # pic_flag when linking with -static.  The problem exists in
47191ab64890Smrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
47201ab64890Smrg	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
47211ab64890Smrg	    case "$compile_command " in
47221ab64890Smrg	    *" -static "*) ;;
47231ab64890Smrg	    *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";;
47241ab64890Smrg	    esac;;
47251ab64890Smrg	  *-*-hpux*)
47261ab64890Smrg	    case "$compile_command " in
47271ab64890Smrg	    *" -static "*) ;;
47281ab64890Smrg	    *) pic_flag_for_symtable=" $pic_flag";;
47291ab64890Smrg	    esac
47301ab64890Smrg	  esac
47311ab64890Smrg
47321ab64890Smrg	  # Now compile the dynamic symbol file.
47331ab64890Smrg	  $show "(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
47341ab64890Smrg	  $run eval '(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
47351ab64890Smrg
47361ab64890Smrg	  # Clean up the generated files.
47371ab64890Smrg	  $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
47381ab64890Smrg	  $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
47391ab64890Smrg
47401ab64890Smrg	  # Transform the symbol file into the correct name.
47411ab64890Smrg          case $host in
47421ab64890Smrg          *cygwin* | *mingw* )
47431ab64890Smrg            if test -f "$output_objdir/${outputname}.def" ; then
47441ab64890Smrg              compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%" | $NL2SP`
47451ab64890Smrg              finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%" | $NL2SP`
47461ab64890Smrg            else
47471ab64890Smrg              compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
47481ab64890Smrg              finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
47491ab64890Smrg             fi
47501ab64890Smrg            ;;
47511ab64890Smrg          * )
47521ab64890Smrg            compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
47531ab64890Smrg            finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
47541ab64890Smrg            ;;
47551ab64890Smrg          esac
47561ab64890Smrg	  ;;
47571ab64890Smrg	*)
47581ab64890Smrg	  $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
47591ab64890Smrg	  exit $EXIT_FAILURE
47601ab64890Smrg	  ;;
47611ab64890Smrg	esac
47621ab64890Smrg      else
47631ab64890Smrg	# We keep going just in case the user didn't refer to
47641ab64890Smrg	# lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
47651ab64890Smrg	# really was required.
47661ab64890Smrg
47671ab64890Smrg	# Nullify the symbol file.
47681ab64890Smrg	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s% @SYMFILE@%%" | $NL2SP`
47691ab64890Smrg	finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s% @SYMFILE@%%" | $NL2SP`
47701ab64890Smrg      fi
47711ab64890Smrg
47721ab64890Smrg      if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
47731ab64890Smrg	# Replace the output file specification.
47741ab64890Smrg	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e 's%@OUTPUT@%'"$output"'%g' | $NL2SP`
47751ab64890Smrg	link_command="$compile_command$compile_rpath"
47761ab64890Smrg
47771ab64890Smrg	# We have no uninstalled library dependencies, so finalize right now.
47781ab64890Smrg	$show "$link_command"
47791ab64890Smrg	$run eval "$link_command"
47801ab64890Smrg	exit_status=$?
47811ab64890Smrg
47821ab64890Smrg	# Delete the generated files.
47831ab64890Smrg	if test -n "$dlsyms"; then
47841ab64890Smrg	  $show "$rm $output_objdir/${outputname}S.${objext}"
47851ab64890Smrg	  $run $rm "$output_objdir/${outputname}S.${objext}"
47861ab64890Smrg	fi
47871ab64890Smrg
47881ab64890Smrg	exit $exit_status
47891ab64890Smrg      fi
47901ab64890Smrg
47911ab64890Smrg      if test -n "$shlibpath_var"; then
47921ab64890Smrg	# We should set the shlibpath_var
47931ab64890Smrg	rpath=
47941ab64890Smrg	for dir in $temp_rpath; do
47951ab64890Smrg	  case $dir in
47961ab64890Smrg	  [\\/]* | [A-Za-z]:[\\/]*)
47971ab64890Smrg	    # Absolute path.
47981ab64890Smrg	    rpath="$rpath$dir:"
47991ab64890Smrg	    ;;
48001ab64890Smrg	  *)
48011ab64890Smrg	    # Relative path: add a thisdir entry.
48021ab64890Smrg	    rpath="$rpath\$thisdir/$dir:"
48031ab64890Smrg	    ;;
48041ab64890Smrg	  esac
48051ab64890Smrg	done
48061ab64890Smrg	temp_rpath="$rpath"
48071ab64890Smrg      fi
48081ab64890Smrg
48091ab64890Smrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
48101ab64890Smrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
48111ab64890Smrg      fi
48121ab64890Smrg      if test -n "$finalize_shlibpath"; then
48131ab64890Smrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
48141ab64890Smrg      fi
48151ab64890Smrg
48161ab64890Smrg      compile_var=
48171ab64890Smrg      finalize_var=
48181ab64890Smrg      if test -n "$runpath_var"; then
48191ab64890Smrg	if test -n "$perm_rpath"; then
48201ab64890Smrg	  # We should set the runpath_var.
48211ab64890Smrg	  rpath=
48221ab64890Smrg	  for dir in $perm_rpath; do
48231ab64890Smrg	    rpath="$rpath$dir:"
48241ab64890Smrg	  done
48251ab64890Smrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
48261ab64890Smrg	fi
48271ab64890Smrg	if test -n "$finalize_perm_rpath"; then
48281ab64890Smrg	  # We should set the runpath_var.
48291ab64890Smrg	  rpath=
48301ab64890Smrg	  for dir in $finalize_perm_rpath; do
48311ab64890Smrg	    rpath="$rpath$dir:"
48321ab64890Smrg	  done
48331ab64890Smrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
48341ab64890Smrg	fi
48351ab64890Smrg      fi
48361ab64890Smrg
48371ab64890Smrg      if test "$no_install" = yes; then
48381ab64890Smrg	# We don't need to create a wrapper script.
48391ab64890Smrg	link_command="$compile_var$compile_command$compile_rpath"
48401ab64890Smrg	# Replace the output file specification.
48411ab64890Smrg	link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
48421ab64890Smrg	# Delete the old output file.
48431ab64890Smrg	$run $rm $output
48441ab64890Smrg	# Link the executable and exit
48451ab64890Smrg	$show "$link_command"
48461ab64890Smrg	$run eval "$link_command" || exit $?
48471ab64890Smrg	exit $EXIT_SUCCESS
48481ab64890Smrg      fi
48491ab64890Smrg
48501ab64890Smrg      if test "$hardcode_action" = relink; then
48511ab64890Smrg	# Fast installation is not supported
48521ab64890Smrg	link_command="$compile_var$compile_command$compile_rpath"
48531ab64890Smrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
48541ab64890Smrg
48551ab64890Smrg	$echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2
48561ab64890Smrg	$echo "$modename: \`$output' will be relinked during installation" 1>&2
48571ab64890Smrg      else
48581ab64890Smrg	if test "$fast_install" != no; then
48591ab64890Smrg	  link_command="$finalize_var$compile_command$finalize_rpath"
48601ab64890Smrg	  if test "$fast_install" = yes; then
48611ab64890Smrg	    relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $SP2NL | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g' | $NL2SP`
48621ab64890Smrg	  else
48631ab64890Smrg	    # fast_install is set to needless
48641ab64890Smrg	    relink_command=
48651ab64890Smrg	  fi
48661ab64890Smrg	else
48671ab64890Smrg	  link_command="$compile_var$compile_command$compile_rpath"
48681ab64890Smrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
48691ab64890Smrg	fi
48701ab64890Smrg      fi
48711ab64890Smrg
48721ab64890Smrg      # Replace the output file specification.
48731ab64890Smrg      link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
48741ab64890Smrg
48751ab64890Smrg      # Delete the old output files.
48761ab64890Smrg      $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname
48771ab64890Smrg
48781ab64890Smrg      $show "$link_command"
48791ab64890Smrg      $run eval "$link_command" || exit $?
48801ab64890Smrg
48811ab64890Smrg      # Now create the wrapper script.
48821ab64890Smrg      $show "creating $output"
48831ab64890Smrg
48841ab64890Smrg      # Quote the relink command for shipping.
48851ab64890Smrg      if test -n "$relink_command"; then
48861ab64890Smrg	# Preserve any variables that may affect compiler behavior
48871ab64890Smrg	for var in $variables_saved_for_relink; do
48881ab64890Smrg	  if eval test -z \"\${$var+set}\"; then
48891ab64890Smrg	    relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
48901ab64890Smrg	  elif eval var_value=\$$var; test -z "$var_value"; then
48911ab64890Smrg	    relink_command="$var=; export $var; $relink_command"
48921ab64890Smrg	  else
48931ab64890Smrg	    var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
48941ab64890Smrg	    relink_command="$var=\"$var_value\"; export $var; $relink_command"
48951ab64890Smrg	  fi
48961ab64890Smrg	done
48971ab64890Smrg	relink_command="(cd `pwd`; $relink_command)"
48981ab64890Smrg	relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e "$sed_quote_subst" | $NL2SP`
48991ab64890Smrg      fi
49001ab64890Smrg
49011ab64890Smrg      # Quote $echo for shipping.
49021ab64890Smrg      if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then
49031ab64890Smrg	case $progpath in
49041ab64890Smrg	[\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
49051ab64890Smrg	*) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
49061ab64890Smrg	esac
49071ab64890Smrg	qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"`
49081ab64890Smrg      else
49091ab64890Smrg	qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"`
49101ab64890Smrg      fi
49111ab64890Smrg
49121ab64890Smrg      # Only actually do things if our run command is non-null.
49131ab64890Smrg      if test -z "$run"; then
49141ab64890Smrg	# win32 will think the script is a binary if it has
49151ab64890Smrg	# a .exe suffix, so we strip it off here.
49161ab64890Smrg	case $output in
49171ab64890Smrg	  *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;;
49181ab64890Smrg	esac
49191ab64890Smrg	# test for cygwin because mv fails w/o .exe extensions
49201ab64890Smrg	case $host in
49211ab64890Smrg	  *cygwin*)
49221ab64890Smrg	    exeext=.exe
49231ab64890Smrg	    outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;;
49241ab64890Smrg	  *) exeext= ;;
49251ab64890Smrg	esac
49261ab64890Smrg	case $host in
49271ab64890Smrg	  *cygwin* | *mingw* )
49281ab64890Smrg            output_name=`basename $output`
49291ab64890Smrg            output_path=`dirname $output`
49301ab64890Smrg            cwrappersource="$output_path/$objdir/lt-$output_name.c"
49311ab64890Smrg            cwrapper="$output_path/$output_name.exe"
49321ab64890Smrg            $rm $cwrappersource $cwrapper
49331ab64890Smrg            trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
49341ab64890Smrg
49351ab64890Smrg	    cat > $cwrappersource <<EOF
49361ab64890Smrg
49371ab64890Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
49381ab64890Smrg   Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
49391ab64890Smrg
49401ab64890Smrg   The $output program cannot be directly executed until all the libtool
49411ab64890Smrg   libraries that it depends on are installed.
49421ab64890Smrg
49431ab64890Smrg   This wrapper executable should never be moved out of the build directory.
49441ab64890Smrg   If it is, it will not operate correctly.
49451ab64890Smrg
49461ab64890Smrg   Currently, it simply execs the wrapper *script* "/bin/sh $output",
49471ab64890Smrg   but could eventually absorb all of the scripts functionality and
49481ab64890Smrg   exec $objdir/$outputname directly.
49491ab64890Smrg*/
49501ab64890SmrgEOF
49511ab64890Smrg	    cat >> $cwrappersource<<"EOF"
49521ab64890Smrg#include <stdio.h>
49531ab64890Smrg#include <stdlib.h>
49541ab64890Smrg#include <unistd.h>
49551ab64890Smrg#include <malloc.h>
49561ab64890Smrg#include <stdarg.h>
49571ab64890Smrg#include <assert.h>
49581ab64890Smrg#include <string.h>
49591ab64890Smrg#include <ctype.h>
49601ab64890Smrg#include <sys/stat.h>
49611ab64890Smrg
49621ab64890Smrg#if defined(PATH_MAX)
49631ab64890Smrg# define LT_PATHMAX PATH_MAX
49641ab64890Smrg#elif defined(MAXPATHLEN)
49651ab64890Smrg# define LT_PATHMAX MAXPATHLEN
49661ab64890Smrg#else
49671ab64890Smrg# define LT_PATHMAX 1024
49681ab64890Smrg#endif
49691ab64890Smrg
49701ab64890Smrg#ifndef DIR_SEPARATOR
49711ab64890Smrg# define DIR_SEPARATOR '/'
49721ab64890Smrg# define PATH_SEPARATOR ':'
49731ab64890Smrg#endif
49741ab64890Smrg
49751ab64890Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
49761ab64890Smrg  defined (__OS2__)
49771ab64890Smrg# define HAVE_DOS_BASED_FILE_SYSTEM
49781ab64890Smrg# ifndef DIR_SEPARATOR_2
49791ab64890Smrg#  define DIR_SEPARATOR_2 '\\'
49801ab64890Smrg# endif
49811ab64890Smrg# ifndef PATH_SEPARATOR_2
49821ab64890Smrg#  define PATH_SEPARATOR_2 ';'
49831ab64890Smrg# endif
49841ab64890Smrg#endif
49851ab64890Smrg
49861ab64890Smrg#ifndef DIR_SEPARATOR_2
49871ab64890Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
49881ab64890Smrg#else /* DIR_SEPARATOR_2 */
49891ab64890Smrg# define IS_DIR_SEPARATOR(ch) \
49901ab64890Smrg        (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
49911ab64890Smrg#endif /* DIR_SEPARATOR_2 */
49921ab64890Smrg
49931ab64890Smrg#ifndef PATH_SEPARATOR_2
49941ab64890Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
49951ab64890Smrg#else /* PATH_SEPARATOR_2 */
49961ab64890Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
49971ab64890Smrg#endif /* PATH_SEPARATOR_2 */
49981ab64890Smrg
49991ab64890Smrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
50001ab64890Smrg#define XFREE(stale) do { \
50011ab64890Smrg  if (stale) { free ((void *) stale); stale = 0; } \
50021ab64890Smrg} while (0)
50031ab64890Smrg
50041ab64890Smrg/* -DDEBUG is fairly common in CFLAGS.  */
50051ab64890Smrg#undef DEBUG
50061ab64890Smrg#if defined DEBUGWRAPPER
50071ab64890Smrg# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
50081ab64890Smrg#else
50091ab64890Smrg# define DEBUG(format, ...)
50101ab64890Smrg#endif
50111ab64890Smrg
50121ab64890Smrgconst char *program_name = NULL;
50131ab64890Smrg
50141ab64890Smrgvoid * xmalloc (size_t num);
50151ab64890Smrgchar * xstrdup (const char *string);
50161ab64890Smrgconst char * base_name (const char *name);
50171ab64890Smrgchar * find_executable(const char *wrapper);
50181ab64890Smrgint    check_executable(const char *path);
50191ab64890Smrgchar * strendzap(char *str, const char *pat);
50201ab64890Smrgvoid lt_fatal (const char *message, ...);
50211ab64890Smrg
50221ab64890Smrgint
50231ab64890Smrgmain (int argc, char *argv[])
50241ab64890Smrg{
50251ab64890Smrg  char **newargz;
50261ab64890Smrg  int i;
50271ab64890Smrg
50281ab64890Smrg  program_name = (char *) xstrdup (base_name (argv[0]));
50291ab64890Smrg  DEBUG("(main) argv[0]      : %s\n",argv[0]);
50301ab64890Smrg  DEBUG("(main) program_name : %s\n",program_name);
50311ab64890Smrg  newargz = XMALLOC(char *, argc+2);
50321ab64890SmrgEOF
50331ab64890Smrg
50341ab64890Smrg            cat >> $cwrappersource <<EOF
50351ab64890Smrg  newargz[0] = (char *) xstrdup("$SHELL");
50361ab64890SmrgEOF
50371ab64890Smrg
50381ab64890Smrg            cat >> $cwrappersource <<"EOF"
50391ab64890Smrg  newargz[1] = find_executable(argv[0]);
50401ab64890Smrg  if (newargz[1] == NULL)
50411ab64890Smrg    lt_fatal("Couldn't find %s", argv[0]);
50421ab64890Smrg  DEBUG("(main) found exe at : %s\n",newargz[1]);
50431ab64890Smrg  /* we know the script has the same name, without the .exe */
50441ab64890Smrg  /* so make sure newargz[1] doesn't end in .exe */
50451ab64890Smrg  strendzap(newargz[1],".exe");
50461ab64890Smrg  for (i = 1; i < argc; i++)
50471ab64890Smrg    newargz[i+1] = xstrdup(argv[i]);
50481ab64890Smrg  newargz[argc+1] = NULL;
50491ab64890Smrg
50501ab64890Smrg  for (i=0; i<argc+1; i++)
50511ab64890Smrg  {
50521ab64890Smrg    DEBUG("(main) newargz[%d]   : %s\n",i,newargz[i]);
50531ab64890Smrg    ;
50541ab64890Smrg  }
50551ab64890Smrg
50561ab64890SmrgEOF
50571ab64890Smrg
50581ab64890Smrg            case $host_os in
50591ab64890Smrg              mingw*)
50601ab64890Smrg                cat >> $cwrappersource <<EOF
50611ab64890Smrg  execv("$SHELL",(char const **)newargz);
50621ab64890SmrgEOF
50631ab64890Smrg              ;;
50641ab64890Smrg              *)
50651ab64890Smrg                cat >> $cwrappersource <<EOF
50661ab64890Smrg  execv("$SHELL",newargz);
50671ab64890SmrgEOF
50681ab64890Smrg              ;;
50691ab64890Smrg            esac
50701ab64890Smrg
50711ab64890Smrg            cat >> $cwrappersource <<"EOF"
50721ab64890Smrg  return 127;
50731ab64890Smrg}
50741ab64890Smrg
50751ab64890Smrgvoid *
50761ab64890Smrgxmalloc (size_t num)
50771ab64890Smrg{
50781ab64890Smrg  void * p = (void *) malloc (num);
50791ab64890Smrg  if (!p)
50801ab64890Smrg    lt_fatal ("Memory exhausted");
50811ab64890Smrg
50821ab64890Smrg  return p;
50831ab64890Smrg}
50841ab64890Smrg
50851ab64890Smrgchar *
50861ab64890Smrgxstrdup (const char *string)
50871ab64890Smrg{
50881ab64890Smrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL
50891ab64890Smrg;
50901ab64890Smrg}
50911ab64890Smrg
50921ab64890Smrgconst char *
50931ab64890Smrgbase_name (const char *name)
50941ab64890Smrg{
50951ab64890Smrg  const char *base;
50961ab64890Smrg
50971ab64890Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
50981ab64890Smrg  /* Skip over the disk name in MSDOS pathnames. */
50991ab64890Smrg  if (isalpha ((unsigned char)name[0]) && name[1] == ':')
51001ab64890Smrg    name += 2;
51011ab64890Smrg#endif
51021ab64890Smrg
51031ab64890Smrg  for (base = name; *name; name++)
51041ab64890Smrg    if (IS_DIR_SEPARATOR (*name))
51051ab64890Smrg      base = name + 1;
51061ab64890Smrg  return base;
51071ab64890Smrg}
51081ab64890Smrg
51091ab64890Smrgint
51101ab64890Smrgcheck_executable(const char * path)
51111ab64890Smrg{
51121ab64890Smrg  struct stat st;
51131ab64890Smrg
51141ab64890Smrg  DEBUG("(check_executable)  : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!");
51151ab64890Smrg  if ((!path) || (!*path))
51161ab64890Smrg    return 0;
51171ab64890Smrg
51181ab64890Smrg  if ((stat (path, &st) >= 0) &&
51191ab64890Smrg      (
51201ab64890Smrg        /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */
51211ab64890Smrg#if defined (S_IXOTH)
51221ab64890Smrg       ((st.st_mode & S_IXOTH) == S_IXOTH) ||
51231ab64890Smrg#endif
51241ab64890Smrg#if defined (S_IXGRP)
51251ab64890Smrg       ((st.st_mode & S_IXGRP) == S_IXGRP) ||
51261ab64890Smrg#endif
51271ab64890Smrg       ((st.st_mode & S_IXUSR) == S_IXUSR))
51281ab64890Smrg      )
51291ab64890Smrg    return 1;
51301ab64890Smrg  else
51311ab64890Smrg    return 0;
51321ab64890Smrg}
51331ab64890Smrg
51341ab64890Smrg/* Searches for the full path of the wrapper.  Returns
51351ab64890Smrg   newly allocated full path name if found, NULL otherwise */
51361ab64890Smrgchar *
51371ab64890Smrgfind_executable (const char* wrapper)
51381ab64890Smrg{
51391ab64890Smrg  int has_slash = 0;
51401ab64890Smrg  const char* p;
51411ab64890Smrg  const char* p_next;
51421ab64890Smrg  /* static buffer for getcwd */
51431ab64890Smrg  char tmp[LT_PATHMAX + 1];
51441ab64890Smrg  int tmp_len;
51451ab64890Smrg  char* concat_name;
51461ab64890Smrg
51471ab64890Smrg  DEBUG("(find_executable)  : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!");
51481ab64890Smrg
51491ab64890Smrg  if ((wrapper == NULL) || (*wrapper == '\0'))
51501ab64890Smrg    return NULL;
51511ab64890Smrg
51521ab64890Smrg  /* Absolute path? */
51531ab64890Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
51541ab64890Smrg  if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':')
51551ab64890Smrg  {
51561ab64890Smrg    concat_name = xstrdup (wrapper);
51571ab64890Smrg    if (check_executable(concat_name))
51581ab64890Smrg      return concat_name;
51591ab64890Smrg    XFREE(concat_name);
51601ab64890Smrg  }
51611ab64890Smrg  else
51621ab64890Smrg  {
51631ab64890Smrg#endif
51641ab64890Smrg    if (IS_DIR_SEPARATOR (wrapper[0]))
51651ab64890Smrg    {
51661ab64890Smrg      concat_name = xstrdup (wrapper);
51671ab64890Smrg      if (check_executable(concat_name))
51681ab64890Smrg        return concat_name;
51691ab64890Smrg      XFREE(concat_name);
51701ab64890Smrg    }
51711ab64890Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
51721ab64890Smrg  }
51731ab64890Smrg#endif
51741ab64890Smrg
51751ab64890Smrg  for (p = wrapper; *p; p++)
51761ab64890Smrg    if (*p == '/')
51771ab64890Smrg    {
51781ab64890Smrg      has_slash = 1;
51791ab64890Smrg      break;
51801ab64890Smrg    }
51811ab64890Smrg  if (!has_slash)
51821ab64890Smrg  {
51831ab64890Smrg    /* no slashes; search PATH */
51841ab64890Smrg    const char* path = getenv ("PATH");
51851ab64890Smrg    if (path != NULL)
51861ab64890Smrg    {
51871ab64890Smrg      for (p = path; *p; p = p_next)
51881ab64890Smrg      {
51891ab64890Smrg        const char* q;
51901ab64890Smrg        size_t p_len;
51911ab64890Smrg        for (q = p; *q; q++)
51921ab64890Smrg          if (IS_PATH_SEPARATOR(*q))
51931ab64890Smrg            break;
51941ab64890Smrg        p_len = q - p;
51951ab64890Smrg        p_next = (*q == '\0' ? q : q + 1);
51961ab64890Smrg        if (p_len == 0)
51971ab64890Smrg        {
51981ab64890Smrg          /* empty path: current directory */
51991ab64890Smrg          if (getcwd (tmp, LT_PATHMAX) == NULL)
52001ab64890Smrg            lt_fatal ("getcwd failed");
52011ab64890Smrg          tmp_len = strlen(tmp);
52021ab64890Smrg          concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
52031ab64890Smrg          memcpy (concat_name, tmp, tmp_len);
52041ab64890Smrg          concat_name[tmp_len] = '/';
52051ab64890Smrg          strcpy (concat_name + tmp_len + 1, wrapper);
52061ab64890Smrg        }
52071ab64890Smrg        else
52081ab64890Smrg        {
52091ab64890Smrg          concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1);
52101ab64890Smrg          memcpy (concat_name, p, p_len);
52111ab64890Smrg          concat_name[p_len] = '/';
52121ab64890Smrg          strcpy (concat_name + p_len + 1, wrapper);
52131ab64890Smrg        }
52141ab64890Smrg        if (check_executable(concat_name))
52151ab64890Smrg          return concat_name;
52161ab64890Smrg        XFREE(concat_name);
52171ab64890Smrg      }
52181ab64890Smrg    }
52191ab64890Smrg    /* not found in PATH; assume curdir */
52201ab64890Smrg  }
52211ab64890Smrg  /* Relative path | not found in path: prepend cwd */
52221ab64890Smrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
52231ab64890Smrg    lt_fatal ("getcwd failed");
52241ab64890Smrg  tmp_len = strlen(tmp);
52251ab64890Smrg  concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
52261ab64890Smrg  memcpy (concat_name, tmp, tmp_len);
52271ab64890Smrg  concat_name[tmp_len] = '/';
52281ab64890Smrg  strcpy (concat_name + tmp_len + 1, wrapper);
52291ab64890Smrg
52301ab64890Smrg  if (check_executable(concat_name))
52311ab64890Smrg    return concat_name;
52321ab64890Smrg  XFREE(concat_name);
52331ab64890Smrg  return NULL;
52341ab64890Smrg}
52351ab64890Smrg
52361ab64890Smrgchar *
52371ab64890Smrgstrendzap(char *str, const char *pat)
52381ab64890Smrg{
52391ab64890Smrg  size_t len, patlen;
52401ab64890Smrg
52411ab64890Smrg  assert(str != NULL);
52421ab64890Smrg  assert(pat != NULL);
52431ab64890Smrg
52441ab64890Smrg  len = strlen(str);
52451ab64890Smrg  patlen = strlen(pat);
52461ab64890Smrg
52471ab64890Smrg  if (patlen <= len)
52481ab64890Smrg  {
52491ab64890Smrg    str += len - patlen;
52501ab64890Smrg    if (strcmp(str, pat) == 0)
52511ab64890Smrg      *str = '\0';
52521ab64890Smrg  }
52531ab64890Smrg  return str;
52541ab64890Smrg}
52551ab64890Smrg
52561ab64890Smrgstatic void
52571ab64890Smrglt_error_core (int exit_status, const char * mode,
52581ab64890Smrg          const char * message, va_list ap)
52591ab64890Smrg{
52601ab64890Smrg  fprintf (stderr, "%s: %s: ", program_name, mode);
52611ab64890Smrg  vfprintf (stderr, message, ap);
52621ab64890Smrg  fprintf (stderr, ".\n");
52631ab64890Smrg
52641ab64890Smrg  if (exit_status >= 0)
52651ab64890Smrg    exit (exit_status);
52661ab64890Smrg}
52671ab64890Smrg
52681ab64890Smrgvoid
52691ab64890Smrglt_fatal (const char *message, ...)
52701ab64890Smrg{
52711ab64890Smrg  va_list ap;
52721ab64890Smrg  va_start (ap, message);
52731ab64890Smrg  lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
52741ab64890Smrg  va_end (ap);
52751ab64890Smrg}
52761ab64890SmrgEOF
52771ab64890Smrg          # we should really use a build-platform specific compiler
52781ab64890Smrg          # here, but OTOH, the wrappers (shell script and this C one)
52791ab64890Smrg          # are only useful if you want to execute the "real" binary.
52801ab64890Smrg          # Since the "real" binary is built for $host, then this
52811ab64890Smrg          # wrapper might as well be built for $host, too.
52821ab64890Smrg          $run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource
52831ab64890Smrg          ;;
52841ab64890Smrg        esac
52851ab64890Smrg        $rm $output
52861ab64890Smrg        trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
52871ab64890Smrg
52881ab64890Smrg	$echo > $output "\
52891ab64890Smrg#! $SHELL
52901ab64890Smrg
52911ab64890Smrg# $output - temporary wrapper script for $objdir/$outputname
52921ab64890Smrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
52931ab64890Smrg#
52941ab64890Smrg# The $output program cannot be directly executed until all the libtool
52951ab64890Smrg# libraries that it depends on are installed.
52961ab64890Smrg#
52971ab64890Smrg# This wrapper script should never be moved out of the build directory.
52981ab64890Smrg# If it is, it will not operate correctly.
52991ab64890Smrg
53001ab64890Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
53011ab64890Smrg# metacharacters that are still active within double-quoted strings.
53021ab64890SmrgXsed='${SED} -e 1s/^X//'
53031ab64890Smrgsed_quote_subst='$sed_quote_subst'
53041ab64890Smrg
53051ab64890Smrg# Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE).
53061ab64890Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
53071ab64890Smrg  emulate sh
53081ab64890Smrg  NULLCMD=:
53091ab64890Smrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
53101ab64890Smrg  # is contrary to our usage.  Disable this feature.
53111ab64890Smrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
53121ab64890Smrg  setopt NO_GLOB_SUBST
53131ab64890Smrgelse
53141ab64890Smrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
53151ab64890Smrgfi
53161ab64890SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
53171ab64890SmrgDUALCASE=1; export DUALCASE # for MKS sh
53181ab64890Smrg
53191ab64890Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout
53201ab64890Smrg# if CDPATH is set.
53211ab64890Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
53221ab64890Smrg
53231ab64890Smrgrelink_command=\"$relink_command\"
53241ab64890Smrg
53251ab64890Smrg# This environment variable determines our operation mode.
53261ab64890Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then
53271ab64890Smrg  # install mode needs the following variable:
53281ab64890Smrg  notinst_deplibs='$notinst_deplibs'
53291ab64890Smrgelse
53301ab64890Smrg  # When we are sourced in execute mode, \$file and \$echo are already set.
53311ab64890Smrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
53321ab64890Smrg    echo=\"$qecho\"
53331ab64890Smrg    file=\"\$0\"
53341ab64890Smrg    # Make sure echo works.
53351ab64890Smrg    if test \"X\$1\" = X--no-reexec; then
53361ab64890Smrg      # Discard the --no-reexec flag, and continue.
53371ab64890Smrg      shift
53381ab64890Smrg    elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then
53391ab64890Smrg      # Yippee, \$echo works!
53401ab64890Smrg      :
53411ab64890Smrg    else
53421ab64890Smrg      # Restart under the correct shell, and then maybe \$echo will work.
53431ab64890Smrg      exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
53441ab64890Smrg    fi
53451ab64890Smrg  fi\
53461ab64890Smrg"
53471ab64890Smrg	$echo >> $output "\
53481ab64890Smrg
53491ab64890Smrg  # Find the directory that this script lives in.
53501ab64890Smrg  thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
53511ab64890Smrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
53521ab64890Smrg
53531ab64890Smrg  # Follow symbolic links until we get to the real thisdir.
53541ab64890Smrg  file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
53551ab64890Smrg  while test -n \"\$file\"; do
53561ab64890Smrg    destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
53571ab64890Smrg
53581ab64890Smrg    # If there was a directory component, then change thisdir.
53591ab64890Smrg    if test \"x\$destdir\" != \"x\$file\"; then
53601ab64890Smrg      case \"\$destdir\" in
53611ab64890Smrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
53621ab64890Smrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
53631ab64890Smrg      esac
53641ab64890Smrg    fi
53651ab64890Smrg
53661ab64890Smrg    file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
53671ab64890Smrg    file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
53681ab64890Smrg  done
53691ab64890Smrg
53701ab64890Smrg  # Try to get the absolute directory name.
53711ab64890Smrg  absdir=\`cd \"\$thisdir\" && pwd\`
53721ab64890Smrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
53731ab64890Smrg"
53741ab64890Smrg
53751ab64890Smrg	if test "$fast_install" = yes; then
53761ab64890Smrg	  $echo >> $output "\
53771ab64890Smrg  program=lt-'$outputname'$exeext
53781ab64890Smrg  progdir=\"\$thisdir/$objdir\"
53791ab64890Smrg
53801ab64890Smrg  if test ! -f \"\$progdir/\$program\" || \\
53811ab64890Smrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
53821ab64890Smrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
53831ab64890Smrg
53841ab64890Smrg    file=\"\$\$-\$program\"
53851ab64890Smrg
53861ab64890Smrg    if test ! -d \"\$progdir\"; then
53871ab64890Smrg      $mkdir \"\$progdir\"
53881ab64890Smrg    else
53891ab64890Smrg      $rm \"\$progdir/\$file\"
53901ab64890Smrg    fi"
53911ab64890Smrg
53921ab64890Smrg	  $echo >> $output "\
53931ab64890Smrg
53941ab64890Smrg    # relink executable if necessary
53951ab64890Smrg    if test -n \"\$relink_command\"; then
53961ab64890Smrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
53971ab64890Smrg      else
53981ab64890Smrg	$echo \"\$relink_command_output\" >&2
53991ab64890Smrg	$rm \"\$progdir/\$file\"
54001ab64890Smrg	exit $EXIT_FAILURE
54011ab64890Smrg      fi
54021ab64890Smrg    fi
54031ab64890Smrg
54041ab64890Smrg    $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
54051ab64890Smrg    { $rm \"\$progdir/\$program\";
54061ab64890Smrg      $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
54071ab64890Smrg    $rm \"\$progdir/\$file\"
54081ab64890Smrg  fi"
54091ab64890Smrg	else
54101ab64890Smrg	  $echo >> $output "\
54111ab64890Smrg  program='$outputname'
54121ab64890Smrg  progdir=\"\$thisdir/$objdir\"
54131ab64890Smrg"
54141ab64890Smrg	fi
54151ab64890Smrg
54161ab64890Smrg	$echo >> $output "\
54171ab64890Smrg
54181ab64890Smrg  if test -f \"\$progdir/\$program\"; then"
54191ab64890Smrg
54201ab64890Smrg	# Export our shlibpath_var if we have one.
54211ab64890Smrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
54221ab64890Smrg	  $echo >> $output "\
54231ab64890Smrg    # Add our own library path to $shlibpath_var
54241ab64890Smrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
54251ab64890Smrg
54261ab64890Smrg    # Some systems cannot cope with colon-terminated $shlibpath_var
54271ab64890Smrg    # The second colon is a workaround for a bug in BeOS R4 sed
54281ab64890Smrg    $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
54291ab64890Smrg
54301ab64890Smrg    export $shlibpath_var
54311ab64890Smrg"
54321ab64890Smrg	fi
54331ab64890Smrg
54341ab64890Smrg	# fixup the dll searchpath if we need to.
54351ab64890Smrg	if test -n "$dllsearchpath"; then
54361ab64890Smrg	  $echo >> $output "\
54371ab64890Smrg    # Add the dll search path components to the executable PATH
54381ab64890Smrg    PATH=$dllsearchpath:\$PATH
54391ab64890Smrg"
54401ab64890Smrg	fi
54411ab64890Smrg
54421ab64890Smrg	$echo >> $output "\
54431ab64890Smrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
54441ab64890Smrg      # Run the actual program with our arguments.
54451ab64890Smrg"
54461ab64890Smrg	case $host in
54471ab64890Smrg	# Backslashes separate directories on plain windows
54481ab64890Smrg	*-*-mingw | *-*-os2*)
54491ab64890Smrg	  $echo >> $output "\
54501ab64890Smrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
54511ab64890Smrg"
54521ab64890Smrg	  ;;
54531ab64890Smrg
54541ab64890Smrg	*)
54551ab64890Smrg	  $echo >> $output "\
54561ab64890Smrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
54571ab64890Smrg"
54581ab64890Smrg	  ;;
54591ab64890Smrg	esac
54601ab64890Smrg	$echo >> $output "\
54611ab64890Smrg      \$echo \"\$0: cannot exec \$program \$*\"
54621ab64890Smrg      exit $EXIT_FAILURE
54631ab64890Smrg    fi
54641ab64890Smrg  else
54651ab64890Smrg    # The program doesn't exist.
54661ab64890Smrg    \$echo \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
54671ab64890Smrg    \$echo \"This script is just a wrapper for \$program.\" 1>&2
54681ab64890Smrg    $echo \"See the $PACKAGE documentation for more information.\" 1>&2
54691ab64890Smrg    exit $EXIT_FAILURE
54701ab64890Smrg  fi
54711ab64890Smrgfi\
54721ab64890Smrg"
54731ab64890Smrg	chmod +x $output
54741ab64890Smrg      fi
54751ab64890Smrg      exit $EXIT_SUCCESS
54761ab64890Smrg      ;;
54771ab64890Smrg    esac
54781ab64890Smrg
54791ab64890Smrg    # See if we need to build an old-fashioned archive.
54801ab64890Smrg    for oldlib in $oldlibs; do
54811ab64890Smrg
54821ab64890Smrg      if test "$build_libtool_libs" = convenience; then
54831ab64890Smrg	oldobjs="$libobjs_save"
54841ab64890Smrg	addlibs="$convenience"
54851ab64890Smrg	build_libtool_libs=no
54861ab64890Smrg      else
54871ab64890Smrg	if test "$build_libtool_libs" = module; then
54881ab64890Smrg	  oldobjs="$libobjs_save"
54891ab64890Smrg	  build_libtool_libs=no
54901ab64890Smrg	else
54911ab64890Smrg	  oldobjs="$old_deplibs $non_pic_objects"
54921ab64890Smrg	fi
54931ab64890Smrg	addlibs="$old_convenience"
54941ab64890Smrg      fi
54951ab64890Smrg
54961ab64890Smrg      if test -n "$addlibs"; then
54971ab64890Smrg	gentop="$output_objdir/${outputname}x"
54981ab64890Smrg	generated="$generated $gentop"
54991ab64890Smrg
55001ab64890Smrg	func_extract_archives $gentop $addlibs
55011ab64890Smrg	oldobjs="$oldobjs $func_extract_archives_result"
55021ab64890Smrg      fi
55031ab64890Smrg
55041ab64890Smrg      # Do each command in the archive commands.
55051ab64890Smrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
55061ab64890Smrg       cmds=$old_archive_from_new_cmds
55071ab64890Smrg      else
55081ab64890Smrg	# POSIX demands no paths to be encoded in archives.  We have
55091ab64890Smrg	# to avoid creating archives with duplicate basenames if we
55101ab64890Smrg	# might have to extract them afterwards, e.g., when creating a
55111ab64890Smrg	# static archive out of a convenience library, or when linking
55121ab64890Smrg	# the entirety of a libtool archive into another (currently
55131ab64890Smrg	# not supported by libtool).
55141ab64890Smrg	if (for obj in $oldobjs
55151ab64890Smrg	    do
55161ab64890Smrg	      $echo "X$obj" | $Xsed -e 's%^.*/%%'
55171ab64890Smrg	    done | sort | sort -uc >/dev/null 2>&1); then
55181ab64890Smrg	  :
55191ab64890Smrg	else
55201ab64890Smrg	  $echo "copying selected object files to avoid basename conflicts..."
55211ab64890Smrg
55221ab64890Smrg	  if test -z "$gentop"; then
55231ab64890Smrg	    gentop="$output_objdir/${outputname}x"
55241ab64890Smrg	    generated="$generated $gentop"
55251ab64890Smrg
55261ab64890Smrg	    $show "${rm}r $gentop"
55271ab64890Smrg	    $run ${rm}r "$gentop"
55281ab64890Smrg	    $show "$mkdir $gentop"
55291ab64890Smrg	    $run $mkdir "$gentop"
55301ab64890Smrg	    exit_status=$?
55311ab64890Smrg	    if test "$exit_status" -ne 0 && test ! -d "$gentop"; then
55321ab64890Smrg	      exit $exit_status
55331ab64890Smrg	    fi
55341ab64890Smrg	  fi
55351ab64890Smrg
55361ab64890Smrg	  save_oldobjs=$oldobjs
55371ab64890Smrg	  oldobjs=
55381ab64890Smrg	  counter=1
55391ab64890Smrg	  for obj in $save_oldobjs
55401ab64890Smrg	  do
55411ab64890Smrg	    objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
55421ab64890Smrg	    case " $oldobjs " in
55431ab64890Smrg	    " ") oldobjs=$obj ;;
55441ab64890Smrg	    *[\ /]"$objbase "*)
55451ab64890Smrg	      while :; do
55461ab64890Smrg		# Make sure we don't pick an alternate name that also
55471ab64890Smrg		# overlaps.
55481ab64890Smrg		newobj=lt$counter-$objbase
55491ab64890Smrg		counter=`expr $counter + 1`
55501ab64890Smrg		case " $oldobjs " in
55511ab64890Smrg		*[\ /]"$newobj "*) ;;
55521ab64890Smrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
55531ab64890Smrg		esac
55541ab64890Smrg	      done
55551ab64890Smrg	      $show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
55561ab64890Smrg	      $run ln "$obj" "$gentop/$newobj" ||
55571ab64890Smrg	      $run cp "$obj" "$gentop/$newobj"
55581ab64890Smrg	      oldobjs="$oldobjs $gentop/$newobj"
55591ab64890Smrg	      ;;
55601ab64890Smrg	    *) oldobjs="$oldobjs $obj" ;;
55611ab64890Smrg	    esac
55621ab64890Smrg	  done
55631ab64890Smrg	fi
55641ab64890Smrg
55651ab64890Smrg	eval cmds=\"$old_archive_cmds\"
55661ab64890Smrg
55671ab64890Smrg	if len=`expr "X$cmds" : ".*"` &&
55681ab64890Smrg	     test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
55691ab64890Smrg	  cmds=$old_archive_cmds
55701ab64890Smrg	else
55711ab64890Smrg	  # the command line is too long to link in one step, link in parts
55721ab64890Smrg	  $echo "using piecewise archive linking..."
55731ab64890Smrg	  save_RANLIB=$RANLIB
55741ab64890Smrg	  RANLIB=:
55751ab64890Smrg	  objlist=
55761ab64890Smrg	  concat_cmds=
55771ab64890Smrg	  save_oldobjs=$oldobjs
55781ab64890Smrg
55791ab64890Smrg	  # Is there a better way of finding the last object in the list?
55801ab64890Smrg	  for obj in $save_oldobjs
55811ab64890Smrg	  do
55821ab64890Smrg	    last_oldobj=$obj
55831ab64890Smrg	  done
55841ab64890Smrg	  for obj in $save_oldobjs
55851ab64890Smrg	  do
55861ab64890Smrg	    oldobjs="$objlist $obj"
55871ab64890Smrg	    objlist="$objlist $obj"
55881ab64890Smrg	    eval test_cmds=\"$old_archive_cmds\"
55891ab64890Smrg	    if len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
55901ab64890Smrg	       test "$len" -le "$max_cmd_len"; then
55911ab64890Smrg	      :
55921ab64890Smrg	    else
55931ab64890Smrg	      # the above command should be used before it gets too long
55941ab64890Smrg	      oldobjs=$objlist
55951ab64890Smrg	      if test "$obj" = "$last_oldobj" ; then
55961ab64890Smrg	        RANLIB=$save_RANLIB
55971ab64890Smrg	      fi
55981ab64890Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
55991ab64890Smrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
56001ab64890Smrg	      objlist=
56011ab64890Smrg	    fi
56021ab64890Smrg	  done
56031ab64890Smrg	  RANLIB=$save_RANLIB
56041ab64890Smrg	  oldobjs=$objlist
56051ab64890Smrg	  if test "X$oldobjs" = "X" ; then
56061ab64890Smrg	    eval cmds=\"\$concat_cmds\"
56071ab64890Smrg	  else
56081ab64890Smrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
56091ab64890Smrg	  fi
56101ab64890Smrg	fi
56111ab64890Smrg      fi
56121ab64890Smrg      save_ifs="$IFS"; IFS='~'
56131ab64890Smrg      for cmd in $cmds; do
56141ab64890Smrg        eval cmd=\"$cmd\"
56151ab64890Smrg	IFS="$save_ifs"
56161ab64890Smrg	$show "$cmd"
56171ab64890Smrg	$run eval "$cmd" || exit $?
56181ab64890Smrg      done
56191ab64890Smrg      IFS="$save_ifs"
56201ab64890Smrg    done
56211ab64890Smrg
56221ab64890Smrg    if test -n "$generated"; then
56231ab64890Smrg      $show "${rm}r$generated"
56241ab64890Smrg      $run ${rm}r$generated
56251ab64890Smrg    fi
56261ab64890Smrg
56271ab64890Smrg    # Now create the libtool archive.
56281ab64890Smrg    case $output in
56291ab64890Smrg    *.la)
56301ab64890Smrg      old_library=
56311ab64890Smrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
56321ab64890Smrg      $show "creating $output"
56331ab64890Smrg
56341ab64890Smrg      # Preserve any variables that may affect compiler behavior
56351ab64890Smrg      for var in $variables_saved_for_relink; do
56361ab64890Smrg	if eval test -z \"\${$var+set}\"; then
56371ab64890Smrg	  relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
56381ab64890Smrg	elif eval var_value=\$$var; test -z "$var_value"; then
56391ab64890Smrg	  relink_command="$var=; export $var; $relink_command"
56401ab64890Smrg	else
56411ab64890Smrg	  var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
56421ab64890Smrg	  relink_command="$var=\"$var_value\"; export $var; $relink_command"
56431ab64890Smrg	fi
56441ab64890Smrg      done
56451ab64890Smrg      # Quote the link command for shipping.
56461ab64890Smrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
56471ab64890Smrg      relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e "$sed_quote_subst" | $NL2SP`
56481ab64890Smrg      if test "$hardcode_automatic" = yes ; then
56491ab64890Smrg	relink_command=
56501ab64890Smrg      fi
56511ab64890Smrg
56521ab64890Smrg
56531ab64890Smrg      # Only create the output if not a dry run.
56541ab64890Smrg      if test -z "$run"; then
56551ab64890Smrg	for installed in no yes; do
56561ab64890Smrg	  if test "$installed" = yes; then
56571ab64890Smrg	    if test -z "$install_libdir"; then
56581ab64890Smrg	      break
56591ab64890Smrg	    fi
56601ab64890Smrg	    output="$output_objdir/$outputname"i
56611ab64890Smrg	    # Replace all uninstalled libtool libraries with the installed ones
56621ab64890Smrg	    newdependency_libs=
56631ab64890Smrg	    for deplib in $dependency_libs; do
56641ab64890Smrg	      case $deplib in
56651ab64890Smrg	      *.la)
56661ab64890Smrg		name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'`
56671ab64890Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
56681ab64890Smrg		if test -z "$libdir"; then
56691ab64890Smrg		  $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
56701ab64890Smrg		  exit $EXIT_FAILURE
56711ab64890Smrg		fi
56721ab64890Smrg		newdependency_libs="$newdependency_libs $libdir/$name"
56731ab64890Smrg		;;
56741ab64890Smrg	      *) newdependency_libs="$newdependency_libs $deplib" ;;
56751ab64890Smrg	      esac
56761ab64890Smrg	    done
56771ab64890Smrg	    dependency_libs="$newdependency_libs"
56781ab64890Smrg	    newdlfiles=
56791ab64890Smrg	    for lib in $dlfiles; do
56801ab64890Smrg	      name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
56811ab64890Smrg	      eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
56821ab64890Smrg	      if test -z "$libdir"; then
56831ab64890Smrg		$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
56841ab64890Smrg		exit $EXIT_FAILURE
56851ab64890Smrg	      fi
56861ab64890Smrg	      newdlfiles="$newdlfiles $libdir/$name"
56871ab64890Smrg	    done
56881ab64890Smrg	    dlfiles="$newdlfiles"
56891ab64890Smrg	    newdlprefiles=
56901ab64890Smrg	    for lib in $dlprefiles; do
56911ab64890Smrg	      name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
56921ab64890Smrg	      eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
56931ab64890Smrg	      if test -z "$libdir"; then
56941ab64890Smrg		$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
56951ab64890Smrg		exit $EXIT_FAILURE
56961ab64890Smrg	      fi
56971ab64890Smrg	      newdlprefiles="$newdlprefiles $libdir/$name"
56981ab64890Smrg	    done
56991ab64890Smrg	    dlprefiles="$newdlprefiles"
57001ab64890Smrg	  else
57011ab64890Smrg	    newdlfiles=
57021ab64890Smrg	    for lib in $dlfiles; do
57031ab64890Smrg	      case $lib in
57041ab64890Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
57051ab64890Smrg		*) abs=`pwd`"/$lib" ;;
57061ab64890Smrg	      esac
57071ab64890Smrg	      newdlfiles="$newdlfiles $abs"
57081ab64890Smrg	    done
57091ab64890Smrg	    dlfiles="$newdlfiles"
57101ab64890Smrg	    newdlprefiles=
57111ab64890Smrg	    for lib in $dlprefiles; do
57121ab64890Smrg	      case $lib in
57131ab64890Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
57141ab64890Smrg		*) abs=`pwd`"/$lib" ;;
57151ab64890Smrg	      esac
57161ab64890Smrg	      newdlprefiles="$newdlprefiles $abs"
57171ab64890Smrg	    done
57181ab64890Smrg	    dlprefiles="$newdlprefiles"
57191ab64890Smrg	  fi
57201ab64890Smrg	  $rm $output
57211ab64890Smrg	  # place dlname in correct position for cygwin
57221ab64890Smrg	  tdlname=$dlname
57231ab64890Smrg	  case $host,$output,$installed,$module,$dlname in
57241ab64890Smrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
57251ab64890Smrg	  esac
57261ab64890Smrg	  $echo > $output "\
57271ab64890Smrg# $outputname - a libtool library file
57281ab64890Smrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
57291ab64890Smrg#
57301ab64890Smrg# Please DO NOT delete this file!
57311ab64890Smrg# It is necessary for linking the library.
57321ab64890Smrg
57331ab64890Smrg# The name that we can dlopen(3).
57341ab64890Smrgdlname='$tdlname'
57351ab64890Smrg
57361ab64890Smrg# Names of this library.
57371ab64890Smrglibrary_names='$library_names'
57381ab64890Smrg
57391ab64890Smrg# The name of the static archive.
57401ab64890Smrgold_library='$old_library'
57411ab64890Smrg
57421ab64890Smrg# Libraries that this one depends upon.
57431ab64890Smrgdependency_libs='$dependency_libs'
57441ab64890Smrg
57451ab64890Smrg# Version information for $libname.
57461ab64890Smrgcurrent=$current
57471ab64890Smrgage=$age
57481ab64890Smrgrevision=$revision
57491ab64890Smrg
57501ab64890Smrg# Is this an already installed library?
57511ab64890Smrginstalled=$installed
57521ab64890Smrg
57531ab64890Smrg# Should we warn about portability when linking against -modules?
57541ab64890Smrgshouldnotlink=$module
57551ab64890Smrg
57561ab64890Smrg# Files to dlopen/dlpreopen
57571ab64890Smrgdlopen='$dlfiles'
57581ab64890Smrgdlpreopen='$dlprefiles'
57591ab64890Smrg
57601ab64890Smrg# Directory that this library needs to be installed in:
57611ab64890Smrglibdir='$install_libdir'"
57621ab64890Smrg	  if test "$installed" = no && test "$need_relink" = yes; then
57631ab64890Smrg	    $echo >> $output "\
57641ab64890Smrgrelink_command=\"$relink_command\""
57651ab64890Smrg	  fi
57661ab64890Smrg	done
57671ab64890Smrg      fi
57681ab64890Smrg
57691ab64890Smrg      # Do a symbolic link so that the libtool archive can be found in
57701ab64890Smrg      # LD_LIBRARY_PATH before the program is installed.
57711ab64890Smrg      $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)"
57721ab64890Smrg      $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $?
57731ab64890Smrg      ;;
57741ab64890Smrg    esac
57751ab64890Smrg    exit $EXIT_SUCCESS
57761ab64890Smrg    ;;
57771ab64890Smrg
57781ab64890Smrg  # libtool install mode
57791ab64890Smrg  install)
57801ab64890Smrg    modename="$modename: install"
57811ab64890Smrg
57821ab64890Smrg    # There may be an optional sh(1) argument at the beginning of
57831ab64890Smrg    # install_prog (especially on Windows NT).
57841ab64890Smrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
57851ab64890Smrg       # Allow the use of GNU shtool's install command.
57861ab64890Smrg       $echo "X$nonopt" | grep shtool > /dev/null; then
57871ab64890Smrg      # Aesthetically quote it.
57881ab64890Smrg      arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"`
57891ab64890Smrg      case $arg in
57901ab64890Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
57911ab64890Smrg	arg="\"$arg\""
57921ab64890Smrg	;;
57931ab64890Smrg      esac
57941ab64890Smrg      install_prog="$arg "
57951ab64890Smrg      arg="$1"
57961ab64890Smrg      shift
57971ab64890Smrg    else
57981ab64890Smrg      install_prog=
57991ab64890Smrg      arg=$nonopt
58001ab64890Smrg    fi
58011ab64890Smrg
58021ab64890Smrg    # The real first argument should be the name of the installation program.
58031ab64890Smrg    # Aesthetically quote it.
58041ab64890Smrg    arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
58051ab64890Smrg    case $arg in
58061ab64890Smrg    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
58071ab64890Smrg      arg="\"$arg\""
58081ab64890Smrg      ;;
58091ab64890Smrg    esac
58101ab64890Smrg    install_prog="$install_prog$arg"
58111ab64890Smrg
58121ab64890Smrg    # We need to accept at least all the BSD install flags.
58131ab64890Smrg    dest=
58141ab64890Smrg    files=
58151ab64890Smrg    opts=
58161ab64890Smrg    prev=
58171ab64890Smrg    install_type=
58181ab64890Smrg    isdir=no
58191ab64890Smrg    stripme=
58201ab64890Smrg    for arg
58211ab64890Smrg    do
58221ab64890Smrg      if test -n "$dest"; then
58231ab64890Smrg	files="$files $dest"
58241ab64890Smrg	dest=$arg
58251ab64890Smrg	continue
58261ab64890Smrg      fi
58271ab64890Smrg
58281ab64890Smrg      case $arg in
58291ab64890Smrg      -d) isdir=yes ;;
58301ab64890Smrg      -f) 
58311ab64890Smrg      	case " $install_prog " in
58321ab64890Smrg	*[\\\ /]cp\ *) ;;
58331ab64890Smrg	*) prev=$arg ;;
58341ab64890Smrg	esac
58351ab64890Smrg	;;
58361ab64890Smrg      -g | -m | -o) prev=$arg ;;
58371ab64890Smrg      -s)
58381ab64890Smrg	stripme=" -s"
58391ab64890Smrg	continue
58401ab64890Smrg	;;
58411ab64890Smrg      -*)
58421ab64890Smrg	;;
58431ab64890Smrg      *)
58441ab64890Smrg	# If the previous option needed an argument, then skip it.
58451ab64890Smrg	if test -n "$prev"; then
58461ab64890Smrg	  prev=
58471ab64890Smrg	else
58481ab64890Smrg	  dest=$arg
58491ab64890Smrg	  continue
58501ab64890Smrg	fi
58511ab64890Smrg	;;
58521ab64890Smrg      esac
58531ab64890Smrg
58541ab64890Smrg      # Aesthetically quote the argument.
58551ab64890Smrg      arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
58561ab64890Smrg      case $arg in
58571ab64890Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
58581ab64890Smrg	arg="\"$arg\""
58591ab64890Smrg	;;
58601ab64890Smrg      esac
58611ab64890Smrg      install_prog="$install_prog $arg"
58621ab64890Smrg    done
58631ab64890Smrg
58641ab64890Smrg    if test -z "$install_prog"; then
58651ab64890Smrg      $echo "$modename: you must specify an install program" 1>&2
58661ab64890Smrg      $echo "$help" 1>&2
58671ab64890Smrg      exit $EXIT_FAILURE
58681ab64890Smrg    fi
58691ab64890Smrg
58701ab64890Smrg    if test -n "$prev"; then
58711ab64890Smrg      $echo "$modename: the \`$prev' option requires an argument" 1>&2
58721ab64890Smrg      $echo "$help" 1>&2
58731ab64890Smrg      exit $EXIT_FAILURE
58741ab64890Smrg    fi
58751ab64890Smrg
58761ab64890Smrg    if test -z "$files"; then
58771ab64890Smrg      if test -z "$dest"; then
58781ab64890Smrg	$echo "$modename: no file or destination specified" 1>&2
58791ab64890Smrg      else
58801ab64890Smrg	$echo "$modename: you must specify a destination" 1>&2
58811ab64890Smrg      fi
58821ab64890Smrg      $echo "$help" 1>&2
58831ab64890Smrg      exit $EXIT_FAILURE
58841ab64890Smrg    fi
58851ab64890Smrg
58861ab64890Smrg    # Strip any trailing slash from the destination.
58871ab64890Smrg    dest=`$echo "X$dest" | $Xsed -e 's%/$%%'`
58881ab64890Smrg
58891ab64890Smrg    # Check to see that the destination is a directory.
58901ab64890Smrg    test -d "$dest" && isdir=yes
58911ab64890Smrg    if test "$isdir" = yes; then
58921ab64890Smrg      destdir="$dest"
58931ab64890Smrg      destname=
58941ab64890Smrg    else
58951ab64890Smrg      destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'`
58961ab64890Smrg      test "X$destdir" = "X$dest" && destdir=.
58971ab64890Smrg      destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'`
58981ab64890Smrg
58991ab64890Smrg      # Not a directory, so check to see that there is only one file specified.
59001ab64890Smrg      set dummy $files
59011ab64890Smrg      if test "$#" -gt 2; then
59021ab64890Smrg	$echo "$modename: \`$dest' is not a directory" 1>&2
59031ab64890Smrg	$echo "$help" 1>&2
59041ab64890Smrg	exit $EXIT_FAILURE
59051ab64890Smrg      fi
59061ab64890Smrg    fi
59071ab64890Smrg    case $destdir in
59081ab64890Smrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
59091ab64890Smrg    *)
59101ab64890Smrg      for file in $files; do
59111ab64890Smrg	case $file in
59121ab64890Smrg	*.lo) ;;
59131ab64890Smrg	*)
59141ab64890Smrg	  $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2
59151ab64890Smrg	  $echo "$help" 1>&2
59161ab64890Smrg	  exit $EXIT_FAILURE
59171ab64890Smrg	  ;;
59181ab64890Smrg	esac
59191ab64890Smrg      done
59201ab64890Smrg      ;;
59211ab64890Smrg    esac
59221ab64890Smrg
59231ab64890Smrg    # This variable tells wrapper scripts just to set variables rather
59241ab64890Smrg    # than running their programs.
59251ab64890Smrg    libtool_install_magic="$magic"
59261ab64890Smrg
59271ab64890Smrg    staticlibs=
59281ab64890Smrg    future_libdirs=
59291ab64890Smrg    current_libdirs=
59301ab64890Smrg    for file in $files; do
59311ab64890Smrg
59321ab64890Smrg      # Do each installation.
59331ab64890Smrg      case $file in
59341ab64890Smrg      *.$libext)
59351ab64890Smrg	# Do the static libraries later.
59361ab64890Smrg	staticlibs="$staticlibs $file"
59371ab64890Smrg	;;
59381ab64890Smrg
59391ab64890Smrg      *.la)
59401ab64890Smrg	# Check to see that this really is a libtool archive.
59411ab64890Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
59421ab64890Smrg	else
59431ab64890Smrg	  $echo "$modename: \`$file' is not a valid libtool archive" 1>&2
59441ab64890Smrg	  $echo "$help" 1>&2
59451ab64890Smrg	  exit $EXIT_FAILURE
59461ab64890Smrg	fi
59471ab64890Smrg
59481ab64890Smrg	library_names=
59491ab64890Smrg	old_library=
59501ab64890Smrg	relink_command=
59511ab64890Smrg	# If there is no directory component, then add one.
59521ab64890Smrg	case $file in
59531ab64890Smrg	*/* | *\\*) . $file ;;
59541ab64890Smrg	*) . ./$file ;;
59551ab64890Smrg	esac
59561ab64890Smrg
59571ab64890Smrg	# Add the libdir to current_libdirs if it is the destination.
59581ab64890Smrg	if test "X$destdir" = "X$libdir"; then
59591ab64890Smrg	  case "$current_libdirs " in
59601ab64890Smrg	  *" $libdir "*) ;;
59611ab64890Smrg	  *) current_libdirs="$current_libdirs $libdir" ;;
59621ab64890Smrg	  esac
59631ab64890Smrg	else
59641ab64890Smrg	  # Note the libdir as a future libdir.
59651ab64890Smrg	  case "$future_libdirs " in
59661ab64890Smrg	  *" $libdir "*) ;;
59671ab64890Smrg	  *) future_libdirs="$future_libdirs $libdir" ;;
59681ab64890Smrg	  esac
59691ab64890Smrg	fi
59701ab64890Smrg
59711ab64890Smrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/
59721ab64890Smrg	test "X$dir" = "X$file/" && dir=
59731ab64890Smrg	dir="$dir$objdir"
59741ab64890Smrg
59751ab64890Smrg	if test -n "$relink_command"; then
59761ab64890Smrg	  # Determine the prefix the user has applied to our future dir.
59771ab64890Smrg	  inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"`
59781ab64890Smrg
59791ab64890Smrg	  # Don't allow the user to place us outside of our expected
59801ab64890Smrg	  # location b/c this prevents finding dependent libraries that
59811ab64890Smrg	  # are installed to the same prefix.
59821ab64890Smrg	  # At present, this check doesn't affect windows .dll's that
59831ab64890Smrg	  # are installed into $libdir/../bin (currently, that works fine)
59841ab64890Smrg	  # but it's something to keep an eye on.
59851ab64890Smrg	  if test "$inst_prefix_dir" = "$destdir"; then
59861ab64890Smrg	    $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2
59871ab64890Smrg	    exit $EXIT_FAILURE
59881ab64890Smrg	  fi
59891ab64890Smrg
59901ab64890Smrg	  if test -n "$inst_prefix_dir"; then
59911ab64890Smrg	    # Stick the inst_prefix_dir data into the link command.
59921ab64890Smrg	    relink_command=`$echo "$relink_command" | $SP2NL | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%" | $NL2SP`
59931ab64890Smrg	  else
59941ab64890Smrg	    relink_command=`$echo "$relink_command" | $SP2NL | $SED "s%@inst_prefix_dir@%%" | $NL2SP`
59951ab64890Smrg	  fi
59961ab64890Smrg
59971ab64890Smrg	  $echo "$modename: warning: relinking \`$file'" 1>&2
59981ab64890Smrg	  $show "$relink_command"
59991ab64890Smrg	  if $run eval "$relink_command"; then :
60001ab64890Smrg	  else
60011ab64890Smrg	    $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
60021ab64890Smrg	    exit $EXIT_FAILURE
60031ab64890Smrg	  fi
60041ab64890Smrg	fi
60051ab64890Smrg
60061ab64890Smrg	# See the names of the shared library.
60071ab64890Smrg	set dummy $library_names
60081ab64890Smrg	if test -n "$2"; then
60091ab64890Smrg	  realname="$2"
60101ab64890Smrg	  shift
60111ab64890Smrg	  shift
60121ab64890Smrg
60131ab64890Smrg	  srcname="$realname"
60141ab64890Smrg	  test -n "$relink_command" && srcname="$realname"T
60151ab64890Smrg
60161ab64890Smrg	  # Install the shared library and build the symlinks.
60171ab64890Smrg	  $show "$install_prog $dir/$srcname $destdir/$realname"
60181ab64890Smrg	  $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $?
60191ab64890Smrg	  if test -n "$stripme" && test -n "$striplib"; then
60201ab64890Smrg	    $show "$striplib $destdir/$realname"
60211ab64890Smrg	    $run eval "$striplib $destdir/$realname" || exit $?
60221ab64890Smrg	  fi
60231ab64890Smrg
60241ab64890Smrg	  if test "$#" -gt 0; then
60251ab64890Smrg	    # Delete the old symlinks, and create new ones.
60261ab64890Smrg	    # Try `ln -sf' first, because the `ln' binary might depend on
60271ab64890Smrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
60281ab64890Smrg	    # so we also need to try rm && ln -s.
60291ab64890Smrg	    for linkname
60301ab64890Smrg	    do
60311ab64890Smrg	      if test "$linkname" != "$realname"; then
60321ab64890Smrg                $show "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
60331ab64890Smrg                $run eval "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
60341ab64890Smrg	      fi
60351ab64890Smrg	    done
60361ab64890Smrg	  fi
60371ab64890Smrg
60381ab64890Smrg	  # Do each command in the postinstall commands.
60391ab64890Smrg	  lib="$destdir/$realname"
60401ab64890Smrg	  cmds=$postinstall_cmds
60411ab64890Smrg	  save_ifs="$IFS"; IFS='~'
60421ab64890Smrg	  for cmd in $cmds; do
60431ab64890Smrg	    IFS="$save_ifs"
60441ab64890Smrg	    eval cmd=\"$cmd\"
60451ab64890Smrg	    $show "$cmd"
60461ab64890Smrg	    $run eval "$cmd" || {
60471ab64890Smrg	      lt_exit=$?
60481ab64890Smrg
60491ab64890Smrg	      # Restore the uninstalled library and exit
60501ab64890Smrg	      if test "$mode" = relink; then
60511ab64890Smrg		$run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
60521ab64890Smrg	      fi
60531ab64890Smrg
60541ab64890Smrg	      exit $lt_exit
60551ab64890Smrg	    }
60561ab64890Smrg	  done
60571ab64890Smrg	  IFS="$save_ifs"
60581ab64890Smrg	fi
60591ab64890Smrg
60601ab64890Smrg	# Install the pseudo-library for information purposes.
60611ab64890Smrg	name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
60621ab64890Smrg	instname="$dir/$name"i
60631ab64890Smrg	$show "$install_prog $instname $destdir/$name"
60641ab64890Smrg	$run eval "$install_prog $instname $destdir/$name" || exit $?
60651ab64890Smrg
60661ab64890Smrg	# Maybe install the static library, too.
60671ab64890Smrg	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
60681ab64890Smrg	;;
60691ab64890Smrg
60701ab64890Smrg      *.lo)
60711ab64890Smrg	# Install (i.e. copy) a libtool object.
60721ab64890Smrg
60731ab64890Smrg	# Figure out destination file name, if it wasn't already specified.
60741ab64890Smrg	if test -n "$destname"; then
60751ab64890Smrg	  destfile="$destdir/$destname"
60761ab64890Smrg	else
60771ab64890Smrg	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
60781ab64890Smrg	  destfile="$destdir/$destfile"
60791ab64890Smrg	fi
60801ab64890Smrg
60811ab64890Smrg	# Deduce the name of the destination old-style object file.
60821ab64890Smrg	case $destfile in
60831ab64890Smrg	*.lo)
60841ab64890Smrg	  staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"`
60851ab64890Smrg	  ;;
60861ab64890Smrg	*.$objext)
60871ab64890Smrg	  staticdest="$destfile"
60881ab64890Smrg	  destfile=
60891ab64890Smrg	  ;;
60901ab64890Smrg	*)
60911ab64890Smrg	  $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2
60921ab64890Smrg	  $echo "$help" 1>&2
60931ab64890Smrg	  exit $EXIT_FAILURE
60941ab64890Smrg	  ;;
60951ab64890Smrg	esac
60961ab64890Smrg
60971ab64890Smrg	# Install the libtool object if requested.
60981ab64890Smrg	if test -n "$destfile"; then
60991ab64890Smrg	  $show "$install_prog $file $destfile"
61001ab64890Smrg	  $run eval "$install_prog $file $destfile" || exit $?
61011ab64890Smrg	fi
61021ab64890Smrg
61031ab64890Smrg	# Install the old object if enabled.
61041ab64890Smrg	if test "$build_old_libs" = yes; then
61051ab64890Smrg	  # Deduce the name of the old-style object file.
61061ab64890Smrg	  staticobj=`$echo "X$file" | $Xsed -e "$lo2o"`
61071ab64890Smrg
61081ab64890Smrg	  $show "$install_prog $staticobj $staticdest"
61091ab64890Smrg	  $run eval "$install_prog \$staticobj \$staticdest" || exit $?
61101ab64890Smrg	fi
61111ab64890Smrg	exit $EXIT_SUCCESS
61121ab64890Smrg	;;
61131ab64890Smrg
61141ab64890Smrg      *)
61151ab64890Smrg	# Figure out destination file name, if it wasn't already specified.
61161ab64890Smrg	if test -n "$destname"; then
61171ab64890Smrg	  destfile="$destdir/$destname"
61181ab64890Smrg	else
61191ab64890Smrg	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
61201ab64890Smrg	  destfile="$destdir/$destfile"
61211ab64890Smrg	fi
61221ab64890Smrg
61231ab64890Smrg	# If the file is missing, and there is a .exe on the end, strip it
61241ab64890Smrg	# because it is most likely a libtool script we actually want to
61251ab64890Smrg	# install
61261ab64890Smrg	stripped_ext=""
61271ab64890Smrg	case $file in
61281ab64890Smrg	  *.exe)
61291ab64890Smrg	    if test ! -f "$file"; then
61301ab64890Smrg	      file=`$echo $file|${SED} 's,.exe$,,'`
61311ab64890Smrg	      stripped_ext=".exe"
61321ab64890Smrg	    fi
61331ab64890Smrg	    ;;
61341ab64890Smrg	esac
61351ab64890Smrg
61361ab64890Smrg	# Do a test to see if this is really a libtool program.
61371ab64890Smrg	case $host in
61381ab64890Smrg	*cygwin*|*mingw*)
61391ab64890Smrg	    wrapper=`$echo $file | ${SED} -e 's,.exe$,,'`
61401ab64890Smrg	    ;;
61411ab64890Smrg	*)
61421ab64890Smrg	    wrapper=$file
61431ab64890Smrg	    ;;
61441ab64890Smrg	esac
61451ab64890Smrg	if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then
61461ab64890Smrg	  notinst_deplibs=
61471ab64890Smrg	  relink_command=
61481ab64890Smrg
61491ab64890Smrg	  # Note that it is not necessary on cygwin/mingw to append a dot to
61501ab64890Smrg	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
61511ab64890Smrg	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
61521ab64890Smrg	  # `FILE.' does not work on cygwin managed mounts.
61531ab64890Smrg	  #
61541ab64890Smrg	  # If there is no directory component, then add one.
61551ab64890Smrg	  case $wrapper in
61561ab64890Smrg	  */* | *\\*) . ${wrapper} ;;
61571ab64890Smrg	  *) . ./${wrapper} ;;
61581ab64890Smrg	  esac
61591ab64890Smrg
61601ab64890Smrg	  # Check the variables that should have been set.
61611ab64890Smrg	  if test -z "$notinst_deplibs"; then
61621ab64890Smrg	    $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2
61631ab64890Smrg	    exit $EXIT_FAILURE
61641ab64890Smrg	  fi
61651ab64890Smrg
61661ab64890Smrg	  finalize=yes
61671ab64890Smrg	  for lib in $notinst_deplibs; do
61681ab64890Smrg	    # Check to see that each library is installed.
61691ab64890Smrg	    libdir=
61701ab64890Smrg	    if test -f "$lib"; then
61711ab64890Smrg	      # If there is no directory component, then add one.
61721ab64890Smrg	      case $lib in
61731ab64890Smrg	      */* | *\\*) . $lib ;;
61741ab64890Smrg	      *) . ./$lib ;;
61751ab64890Smrg	      esac
61761ab64890Smrg	    fi
61771ab64890Smrg	    libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
61781ab64890Smrg	    if test -n "$libdir" && test ! -f "$libfile"; then
61791ab64890Smrg	      $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2
61801ab64890Smrg	      finalize=no
61811ab64890Smrg	    fi
61821ab64890Smrg	  done
61831ab64890Smrg
61841ab64890Smrg	  relink_command=
61851ab64890Smrg	  # Note that it is not necessary on cygwin/mingw to append a dot to
61861ab64890Smrg	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
61871ab64890Smrg	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
61881ab64890Smrg	  # `FILE.' does not work on cygwin managed mounts.
61891ab64890Smrg	  #
61901ab64890Smrg	  # If there is no directory component, then add one.
61911ab64890Smrg	  case $wrapper in
61921ab64890Smrg	  */* | *\\*) . ${wrapper} ;;
61931ab64890Smrg	  *) . ./${wrapper} ;;
61941ab64890Smrg	  esac
61951ab64890Smrg
61961ab64890Smrg	  outputname=
61971ab64890Smrg	  if test "$fast_install" = no && test -n "$relink_command"; then
61981ab64890Smrg	    if test "$finalize" = yes && test -z "$run"; then
61991ab64890Smrg	      tmpdir=`func_mktempdir`
62001ab64890Smrg	      file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
62011ab64890Smrg	      outputname="$tmpdir/$file"
62021ab64890Smrg	      # Replace the output file specification.
62031ab64890Smrg	      relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g' | $NL2SP`
62041ab64890Smrg
62051ab64890Smrg	      $show "$relink_command"
62061ab64890Smrg	      if $run eval "$relink_command"; then :
62071ab64890Smrg	      else
62081ab64890Smrg		$echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
62091ab64890Smrg		${rm}r "$tmpdir"
62101ab64890Smrg		continue
62111ab64890Smrg	      fi
62121ab64890Smrg	      file="$outputname"
62131ab64890Smrg	    else
62141ab64890Smrg	      $echo "$modename: warning: cannot relink \`$file'" 1>&2
62151ab64890Smrg	    fi
62161ab64890Smrg	  else
62171ab64890Smrg	    # Install the binary that we compiled earlier.
62181ab64890Smrg	    file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
62191ab64890Smrg	  fi
62201ab64890Smrg	fi
62211ab64890Smrg
62221ab64890Smrg	# remove .exe since cygwin /usr/bin/install will append another
62231ab64890Smrg	# one anyway 
62241ab64890Smrg	case $install_prog,$host in
62251ab64890Smrg	*/usr/bin/install*,*cygwin*)
62261ab64890Smrg	  case $file:$destfile in
62271ab64890Smrg	  *.exe:*.exe)
62281ab64890Smrg	    # this is ok
62291ab64890Smrg	    ;;
62301ab64890Smrg	  *.exe:*)
62311ab64890Smrg	    destfile=$destfile.exe
62321ab64890Smrg	    ;;
62331ab64890Smrg	  *:*.exe)
62341ab64890Smrg	    destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'`
62351ab64890Smrg	    ;;
62361ab64890Smrg	  esac
62371ab64890Smrg	  ;;
62381ab64890Smrg	esac
62391ab64890Smrg	$show "$install_prog$stripme $file $destfile"
62401ab64890Smrg	$run eval "$install_prog\$stripme \$file \$destfile" || exit $?
62411ab64890Smrg	test -n "$outputname" && ${rm}r "$tmpdir"
62421ab64890Smrg	;;
62431ab64890Smrg      esac
62441ab64890Smrg    done
62451ab64890Smrg
62461ab64890Smrg    for file in $staticlibs; do
62471ab64890Smrg      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
62481ab64890Smrg
62491ab64890Smrg      # Set up the ranlib parameters.
62501ab64890Smrg      oldlib="$destdir/$name"
62511ab64890Smrg
62521ab64890Smrg      $show "$install_prog $file $oldlib"
62531ab64890Smrg      $run eval "$install_prog \$file \$oldlib" || exit $?
62541ab64890Smrg
62551ab64890Smrg      if test -n "$stripme" && test -n "$old_striplib"; then
62561ab64890Smrg	$show "$old_striplib $oldlib"
62571ab64890Smrg	$run eval "$old_striplib $oldlib" || exit $?
62581ab64890Smrg      fi
62591ab64890Smrg
62601ab64890Smrg      # Do each command in the postinstall commands.
62611ab64890Smrg      cmds=$old_postinstall_cmds
62621ab64890Smrg      save_ifs="$IFS"; IFS='~'
62631ab64890Smrg      for cmd in $cmds; do
62641ab64890Smrg	IFS="$save_ifs"
62651ab64890Smrg	eval cmd=\"$cmd\"
62661ab64890Smrg	$show "$cmd"
62671ab64890Smrg	$run eval "$cmd" || exit $?
62681ab64890Smrg      done
62691ab64890Smrg      IFS="$save_ifs"
62701ab64890Smrg    done
62711ab64890Smrg
62721ab64890Smrg    if test -n "$future_libdirs"; then
62731ab64890Smrg      $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2
62741ab64890Smrg    fi
62751ab64890Smrg
62761ab64890Smrg    if test -n "$current_libdirs"; then
62771ab64890Smrg      # Maybe just do a dry run.
62781ab64890Smrg      test -n "$run" && current_libdirs=" -n$current_libdirs"
62791ab64890Smrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
62801ab64890Smrg    else
62811ab64890Smrg      exit $EXIT_SUCCESS
62821ab64890Smrg    fi
62831ab64890Smrg    ;;
62841ab64890Smrg
62851ab64890Smrg  # libtool finish mode
62861ab64890Smrg  finish)
62871ab64890Smrg    modename="$modename: finish"
62881ab64890Smrg    libdirs="$nonopt"
62891ab64890Smrg    admincmds=
62901ab64890Smrg
62911ab64890Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
62921ab64890Smrg      for dir
62931ab64890Smrg      do
62941ab64890Smrg	libdirs="$libdirs $dir"
62951ab64890Smrg      done
62961ab64890Smrg
62971ab64890Smrg      for libdir in $libdirs; do
62981ab64890Smrg	if test -n "$finish_cmds"; then
62991ab64890Smrg	  # Do each command in the finish commands.
63001ab64890Smrg	  cmds=$finish_cmds
63011ab64890Smrg	  save_ifs="$IFS"; IFS='~'
63021ab64890Smrg	  for cmd in $cmds; do
63031ab64890Smrg	    IFS="$save_ifs"
63041ab64890Smrg	    eval cmd=\"$cmd\"
63051ab64890Smrg	    $show "$cmd"
63061ab64890Smrg	    $run eval "$cmd" || admincmds="$admincmds
63071ab64890Smrg       $cmd"
63081ab64890Smrg	  done
63091ab64890Smrg	  IFS="$save_ifs"
63101ab64890Smrg	fi
63111ab64890Smrg	if test -n "$finish_eval"; then
63121ab64890Smrg	  # Do the single finish_eval.
63131ab64890Smrg	  eval cmds=\"$finish_eval\"
63141ab64890Smrg	  $run eval "$cmds" || admincmds="$admincmds
63151ab64890Smrg       $cmds"
63161ab64890Smrg	fi
63171ab64890Smrg      done
63181ab64890Smrg    fi
63191ab64890Smrg
63201ab64890Smrg    # Exit here if they wanted silent mode.
63211ab64890Smrg    test "$show" = : && exit $EXIT_SUCCESS
63221ab64890Smrg
63231ab64890Smrg    $echo "X----------------------------------------------------------------------" | $Xsed
63241ab64890Smrg    $echo "Libraries have been installed in:"
63251ab64890Smrg    for libdir in $libdirs; do
63261ab64890Smrg      $echo "   $libdir"
63271ab64890Smrg    done
63281ab64890Smrg    $echo
63291ab64890Smrg    $echo "If you ever happen to want to link against installed libraries"
63301ab64890Smrg    $echo "in a given directory, LIBDIR, you must either use libtool, and"
63311ab64890Smrg    $echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
63321ab64890Smrg    $echo "flag during linking and do at least one of the following:"
63331ab64890Smrg    if test -n "$shlibpath_var"; then
63341ab64890Smrg      $echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
63351ab64890Smrg      $echo "     during execution"
63361ab64890Smrg    fi
63371ab64890Smrg    if test -n "$runpath_var"; then
63381ab64890Smrg      $echo "   - add LIBDIR to the \`$runpath_var' environment variable"
63391ab64890Smrg      $echo "     during linking"
63401ab64890Smrg    fi
63411ab64890Smrg    if test -n "$hardcode_libdir_flag_spec"; then
63421ab64890Smrg      libdir=LIBDIR
63431ab64890Smrg      eval flag=\"$hardcode_libdir_flag_spec\"
63441ab64890Smrg
63451ab64890Smrg      $echo "   - use the \`$flag' linker flag"
63461ab64890Smrg    fi
63471ab64890Smrg    if test -n "$admincmds"; then
63481ab64890Smrg      $echo "   - have your system administrator run these commands:$admincmds"
63491ab64890Smrg    fi
63501ab64890Smrg    if test -f /etc/ld.so.conf; then
63511ab64890Smrg      $echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
63521ab64890Smrg    fi
63531ab64890Smrg    $echo
63541ab64890Smrg    $echo "See any operating system documentation about shared libraries for"
63551ab64890Smrg    $echo "more information, such as the ld(1) and ld.so(8) manual pages."
63561ab64890Smrg    $echo "X----------------------------------------------------------------------" | $Xsed
63571ab64890Smrg    exit $EXIT_SUCCESS
63581ab64890Smrg    ;;
63591ab64890Smrg
63601ab64890Smrg  # libtool execute mode
63611ab64890Smrg  execute)
63621ab64890Smrg    modename="$modename: execute"
63631ab64890Smrg
63641ab64890Smrg    # The first argument is the command name.
63651ab64890Smrg    cmd="$nonopt"
63661ab64890Smrg    if test -z "$cmd"; then
63671ab64890Smrg      $echo "$modename: you must specify a COMMAND" 1>&2
63681ab64890Smrg      $echo "$help"
63691ab64890Smrg      exit $EXIT_FAILURE
63701ab64890Smrg    fi
63711ab64890Smrg
63721ab64890Smrg    # Handle -dlopen flags immediately.
63731ab64890Smrg    for file in $execute_dlfiles; do
63741ab64890Smrg      if test ! -f "$file"; then
63751ab64890Smrg	$echo "$modename: \`$file' is not a file" 1>&2
63761ab64890Smrg	$echo "$help" 1>&2
63771ab64890Smrg	exit $EXIT_FAILURE
63781ab64890Smrg      fi
63791ab64890Smrg
63801ab64890Smrg      dir=
63811ab64890Smrg      case $file in
63821ab64890Smrg      *.la)
63831ab64890Smrg	# Check to see that this really is a libtool archive.
63841ab64890Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
63851ab64890Smrg	else
63861ab64890Smrg	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
63871ab64890Smrg	  $echo "$help" 1>&2
63881ab64890Smrg	  exit $EXIT_FAILURE
63891ab64890Smrg	fi
63901ab64890Smrg
63911ab64890Smrg	# Read the libtool library.
63921ab64890Smrg	dlname=
63931ab64890Smrg	library_names=
63941ab64890Smrg
63951ab64890Smrg	# If there is no directory component, then add one.
63961ab64890Smrg	case $file in
63971ab64890Smrg	*/* | *\\*) . $file ;;
63981ab64890Smrg	*) . ./$file ;;
63991ab64890Smrg	esac
64001ab64890Smrg
64011ab64890Smrg	# Skip this library if it cannot be dlopened.
64021ab64890Smrg	if test -z "$dlname"; then
64031ab64890Smrg	  # Warn if it was a shared library.
64041ab64890Smrg	  test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'"
64051ab64890Smrg	  continue
64061ab64890Smrg	fi
64071ab64890Smrg
64081ab64890Smrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
64091ab64890Smrg	test "X$dir" = "X$file" && dir=.
64101ab64890Smrg
64111ab64890Smrg	if test -f "$dir/$objdir/$dlname"; then
64121ab64890Smrg	  dir="$dir/$objdir"
64131ab64890Smrg	else
64141ab64890Smrg	  if test ! -f "$dir/$dlname"; then
64151ab64890Smrg	    $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
64161ab64890Smrg	    exit $EXIT_FAILURE
64171ab64890Smrg	  fi
64181ab64890Smrg	fi
64191ab64890Smrg	;;
64201ab64890Smrg
64211ab64890Smrg      *.lo)
64221ab64890Smrg	# Just add the directory containing the .lo file.
64231ab64890Smrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
64241ab64890Smrg	test "X$dir" = "X$file" && dir=.
64251ab64890Smrg	;;
64261ab64890Smrg
64271ab64890Smrg      *)
64281ab64890Smrg	$echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2
64291ab64890Smrg	continue
64301ab64890Smrg	;;
64311ab64890Smrg      esac
64321ab64890Smrg
64331ab64890Smrg      # Get the absolute pathname.
64341ab64890Smrg      absdir=`cd "$dir" && pwd`
64351ab64890Smrg      test -n "$absdir" && dir="$absdir"
64361ab64890Smrg
64371ab64890Smrg      # Now add the directory to shlibpath_var.
64381ab64890Smrg      if eval "test -z \"\$$shlibpath_var\""; then
64391ab64890Smrg	eval "$shlibpath_var=\"\$dir\""
64401ab64890Smrg      else
64411ab64890Smrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
64421ab64890Smrg      fi
64431ab64890Smrg    done
64441ab64890Smrg
64451ab64890Smrg    # This variable tells wrapper scripts just to set shlibpath_var
64461ab64890Smrg    # rather than running their programs.
64471ab64890Smrg    libtool_execute_magic="$magic"
64481ab64890Smrg
64491ab64890Smrg    # Check if any of the arguments is a wrapper script.
64501ab64890Smrg    args=
64511ab64890Smrg    for file
64521ab64890Smrg    do
64531ab64890Smrg      case $file in
64541ab64890Smrg      -*) ;;
64551ab64890Smrg      *)
64561ab64890Smrg	# Do a test to see if this is really a libtool program.
64571ab64890Smrg	if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
64581ab64890Smrg	  # If there is no directory component, then add one.
64591ab64890Smrg	  case $file in
64601ab64890Smrg	  */* | *\\*) . $file ;;
64611ab64890Smrg	  *) . ./$file ;;
64621ab64890Smrg	  esac
64631ab64890Smrg
64641ab64890Smrg	  # Transform arg to wrapped name.
64651ab64890Smrg	  file="$progdir/$program"
64661ab64890Smrg	fi
64671ab64890Smrg	;;
64681ab64890Smrg      esac
64691ab64890Smrg      # Quote arguments (to preserve shell metacharacters).
64701ab64890Smrg      file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"`
64711ab64890Smrg      args="$args \"$file\""
64721ab64890Smrg    done
64731ab64890Smrg
64741ab64890Smrg    if test -z "$run"; then
64751ab64890Smrg      if test -n "$shlibpath_var"; then
64761ab64890Smrg	# Export the shlibpath_var.
64771ab64890Smrg	eval "export $shlibpath_var"
64781ab64890Smrg      fi
64791ab64890Smrg
64801ab64890Smrg      # Restore saved environment variables
64811ab64890Smrg      for lt_var in LANG LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
64821ab64890Smrg      do
64831ab64890Smrg	eval "if test \"\${save_$lt_var+set}\" = set; then
64841ab64890Smrg		$lt_var=\$save_$lt_var; export $lt_var
64851ab64890Smrg	      fi"
64861ab64890Smrg      done
64871ab64890Smrg
64881ab64890Smrg      # Now prepare to actually exec the command.
64891ab64890Smrg      exec_cmd="\$cmd$args"
64901ab64890Smrg    else
64911ab64890Smrg      # Display what would be done.
64921ab64890Smrg      if test -n "$shlibpath_var"; then
64931ab64890Smrg	eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\""
64941ab64890Smrg	$echo "export $shlibpath_var"
64951ab64890Smrg      fi
64961ab64890Smrg      $echo "$cmd$args"
64971ab64890Smrg      exit $EXIT_SUCCESS
64981ab64890Smrg    fi
64991ab64890Smrg    ;;
65001ab64890Smrg
65011ab64890Smrg  # libtool clean and uninstall mode
65021ab64890Smrg  clean | uninstall)
65031ab64890Smrg    modename="$modename: $mode"
65041ab64890Smrg    rm="$nonopt"
65051ab64890Smrg    files=
65061ab64890Smrg    rmforce=
65071ab64890Smrg    exit_status=0
65081ab64890Smrg
65091ab64890Smrg    # This variable tells wrapper scripts just to set variables rather
65101ab64890Smrg    # than running their programs.
65111ab64890Smrg    libtool_install_magic="$magic"
65121ab64890Smrg
65131ab64890Smrg    for arg
65141ab64890Smrg    do
65151ab64890Smrg      case $arg in
65161ab64890Smrg      -f) rm="$rm $arg"; rmforce=yes ;;
65171ab64890Smrg      -*) rm="$rm $arg" ;;
65181ab64890Smrg      *) files="$files $arg" ;;
65191ab64890Smrg      esac
65201ab64890Smrg    done
65211ab64890Smrg
65221ab64890Smrg    if test -z "$rm"; then
65231ab64890Smrg      $echo "$modename: you must specify an RM program" 1>&2
65241ab64890Smrg      $echo "$help" 1>&2
65251ab64890Smrg      exit $EXIT_FAILURE
65261ab64890Smrg    fi
65271ab64890Smrg
65281ab64890Smrg    rmdirs=
65291ab64890Smrg
65301ab64890Smrg    origobjdir="$objdir"
65311ab64890Smrg    for file in $files; do
65321ab64890Smrg      dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
65331ab64890Smrg      if test "X$dir" = "X$file"; then
65341ab64890Smrg	dir=.
65351ab64890Smrg	objdir="$origobjdir"
65361ab64890Smrg      else
65371ab64890Smrg	objdir="$dir/$origobjdir"
65381ab64890Smrg      fi
65391ab64890Smrg      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
65401ab64890Smrg      test "$mode" = uninstall && objdir="$dir"
65411ab64890Smrg
65421ab64890Smrg      # Remember objdir for removal later, being careful to avoid duplicates
65431ab64890Smrg      if test "$mode" = clean; then
65441ab64890Smrg	case " $rmdirs " in
65451ab64890Smrg	  *" $objdir "*) ;;
65461ab64890Smrg	  *) rmdirs="$rmdirs $objdir" ;;
65471ab64890Smrg	esac
65481ab64890Smrg      fi
65491ab64890Smrg
65501ab64890Smrg      # Don't error if the file doesn't exist and rm -f was used.
65511ab64890Smrg      if (test -L "$file") >/dev/null 2>&1 \
65521ab64890Smrg	|| (test -h "$file") >/dev/null 2>&1 \
65531ab64890Smrg	|| test -f "$file"; then
65541ab64890Smrg	:
65551ab64890Smrg      elif test -d "$file"; then
65561ab64890Smrg	exit_status=1
65571ab64890Smrg	continue
65581ab64890Smrg      elif test "$rmforce" = yes; then
65591ab64890Smrg	continue
65601ab64890Smrg      fi
65611ab64890Smrg
65621ab64890Smrg      rmfiles="$file"
65631ab64890Smrg
65641ab64890Smrg      case $name in
65651ab64890Smrg      *.la)
65661ab64890Smrg	# Possibly a libtool archive, so verify it.
65671ab64890Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
65681ab64890Smrg	  . $dir/$name
65691ab64890Smrg
65701ab64890Smrg	  # Delete the libtool libraries and symlinks.
65711ab64890Smrg	  for n in $library_names; do
65721ab64890Smrg	    rmfiles="$rmfiles $objdir/$n"
65731ab64890Smrg	  done
65741ab64890Smrg	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
65751ab64890Smrg
65761ab64890Smrg	  case "$mode" in
65771ab64890Smrg	  clean)
65781ab64890Smrg	    case "  $library_names " in
65791ab64890Smrg	    # "  " in the beginning catches empty $dlname
65801ab64890Smrg	    *" $dlname "*) ;;
65811ab64890Smrg	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
65821ab64890Smrg	    esac
65831ab64890Smrg	     test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
65841ab64890Smrg	    ;;
65851ab64890Smrg	  uninstall)
65861ab64890Smrg	    if test -n "$library_names"; then
65871ab64890Smrg	      # Do each command in the postuninstall commands.
65881ab64890Smrg	      cmds=$postuninstall_cmds
65891ab64890Smrg	      save_ifs="$IFS"; IFS='~'
65901ab64890Smrg	      for cmd in $cmds; do
65911ab64890Smrg		IFS="$save_ifs"
65921ab64890Smrg		eval cmd=\"$cmd\"
65931ab64890Smrg		$show "$cmd"
65941ab64890Smrg		$run eval "$cmd"
65951ab64890Smrg		if test "$?" -ne 0 && test "$rmforce" != yes; then
65961ab64890Smrg		  exit_status=1
65971ab64890Smrg		fi
65981ab64890Smrg	      done
65991ab64890Smrg	      IFS="$save_ifs"
66001ab64890Smrg	    fi
66011ab64890Smrg
66021ab64890Smrg	    if test -n "$old_library"; then
66031ab64890Smrg	      # Do each command in the old_postuninstall commands.
66041ab64890Smrg	      cmds=$old_postuninstall_cmds
66051ab64890Smrg	      save_ifs="$IFS"; IFS='~'
66061ab64890Smrg	      for cmd in $cmds; do
66071ab64890Smrg		IFS="$save_ifs"
66081ab64890Smrg		eval cmd=\"$cmd\"
66091ab64890Smrg		$show "$cmd"
66101ab64890Smrg		$run eval "$cmd"
66111ab64890Smrg		if test "$?" -ne 0 && test "$rmforce" != yes; then
66121ab64890Smrg		  exit_status=1
66131ab64890Smrg		fi
66141ab64890Smrg	      done
66151ab64890Smrg	      IFS="$save_ifs"
66161ab64890Smrg	    fi
66171ab64890Smrg	    # FIXME: should reinstall the best remaining shared library.
66181ab64890Smrg	    ;;
66191ab64890Smrg	  esac
66201ab64890Smrg	fi
66211ab64890Smrg	;;
66221ab64890Smrg
66231ab64890Smrg      *.lo)
66241ab64890Smrg	# Possibly a libtool object, so verify it.
66251ab64890Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
66261ab64890Smrg
66271ab64890Smrg	  # Read the .lo file
66281ab64890Smrg	  . $dir/$name
66291ab64890Smrg
66301ab64890Smrg	  # Add PIC object to the list of files to remove.
66311ab64890Smrg	  if test -n "$pic_object" \
66321ab64890Smrg	     && test "$pic_object" != none; then
66331ab64890Smrg	    rmfiles="$rmfiles $dir/$pic_object"
66341ab64890Smrg	  fi
66351ab64890Smrg
66361ab64890Smrg	  # Add non-PIC object to the list of files to remove.
66371ab64890Smrg	  if test -n "$non_pic_object" \
66381ab64890Smrg	     && test "$non_pic_object" != none; then
66391ab64890Smrg	    rmfiles="$rmfiles $dir/$non_pic_object"
66401ab64890Smrg	  fi
66411ab64890Smrg	fi
66421ab64890Smrg	;;
66431ab64890Smrg
66441ab64890Smrg      *)
66451ab64890Smrg	if test "$mode" = clean ; then
66461ab64890Smrg	  noexename=$name
66471ab64890Smrg	  case $file in
66481ab64890Smrg	  *.exe)
66491ab64890Smrg	    file=`$echo $file|${SED} 's,.exe$,,'`
66501ab64890Smrg	    noexename=`$echo $name|${SED} 's,.exe$,,'`
66511ab64890Smrg	    # $file with .exe has already been added to rmfiles,
66521ab64890Smrg	    # add $file without .exe
66531ab64890Smrg	    rmfiles="$rmfiles $file"
66541ab64890Smrg	    ;;
66551ab64890Smrg	  esac
66561ab64890Smrg	  # Do a test to see if this is a libtool program.
66571ab64890Smrg	  if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
66581ab64890Smrg	    relink_command=
66591ab64890Smrg	    . $dir/$noexename
66601ab64890Smrg
66611ab64890Smrg	    # note $name still contains .exe if it was in $file originally
66621ab64890Smrg	    # as does the version of $file that was added into $rmfiles
66631ab64890Smrg	    rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
66641ab64890Smrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
66651ab64890Smrg	      rmfiles="$rmfiles $objdir/lt-$name"
66661ab64890Smrg	    fi
66671ab64890Smrg	    if test "X$noexename" != "X$name" ; then
66681ab64890Smrg	      rmfiles="$rmfiles $objdir/lt-${noexename}.c"
66691ab64890Smrg	    fi
66701ab64890Smrg	  fi
66711ab64890Smrg	fi
66721ab64890Smrg	;;
66731ab64890Smrg      esac
66741ab64890Smrg      $show "$rm $rmfiles"
66751ab64890Smrg      $run $rm $rmfiles || exit_status=1
66761ab64890Smrg    done
66771ab64890Smrg    objdir="$origobjdir"
66781ab64890Smrg
66791ab64890Smrg    # Try to remove the ${objdir}s in the directories where we deleted files
66801ab64890Smrg    for dir in $rmdirs; do
66811ab64890Smrg      if test -d "$dir"; then
66821ab64890Smrg	$show "rmdir $dir"
66831ab64890Smrg	$run rmdir $dir >/dev/null 2>&1
66841ab64890Smrg      fi
66851ab64890Smrg    done
66861ab64890Smrg
66871ab64890Smrg    exit $exit_status
66881ab64890Smrg    ;;
66891ab64890Smrg
66901ab64890Smrg  "")
66911ab64890Smrg    $echo "$modename: you must specify a MODE" 1>&2
66921ab64890Smrg    $echo "$generic_help" 1>&2
66931ab64890Smrg    exit $EXIT_FAILURE
66941ab64890Smrg    ;;
66951ab64890Smrg  esac
66961ab64890Smrg
66971ab64890Smrg  if test -z "$exec_cmd"; then
66981ab64890Smrg    $echo "$modename: invalid operation mode \`$mode'" 1>&2
66991ab64890Smrg    $echo "$generic_help" 1>&2
67001ab64890Smrg    exit $EXIT_FAILURE
67011ab64890Smrg  fi
67021ab64890Smrgfi # test -z "$show_help"
67031ab64890Smrg
67041ab64890Smrgif test -n "$exec_cmd"; then
67051ab64890Smrg  eval exec $exec_cmd
67061ab64890Smrg  exit $EXIT_FAILURE
67071ab64890Smrgfi
67081ab64890Smrg
67091ab64890Smrg# We need to display help for each of the modes.
67101ab64890Smrgcase $mode in
67111ab64890Smrg"") $echo \
67121ab64890Smrg"Usage: $modename [OPTION]... [MODE-ARG]...
67131ab64890Smrg
67141ab64890SmrgProvide generalized library-building support services.
67151ab64890Smrg
67161ab64890Smrg    --config          show all configuration variables
67171ab64890Smrg    --debug           enable verbose shell tracing
67181ab64890Smrg-n, --dry-run         display commands without modifying any files
67191ab64890Smrg    --features        display basic configuration information and exit
67201ab64890Smrg    --finish          same as \`--mode=finish'
67211ab64890Smrg    --help            display this help message and exit
67221ab64890Smrg    --mode=MODE       use operation mode MODE [default=inferred from MODE-ARGS]
67231ab64890Smrg    --quiet           same as \`--silent'
67241ab64890Smrg    --silent          don't print informational messages
67251ab64890Smrg    --tag=TAG         use configuration variables from tag TAG
67261ab64890Smrg    --version         print version information
67271ab64890Smrg
67281ab64890SmrgMODE must be one of the following:
67291ab64890Smrg
67301ab64890Smrg      clean           remove files from the build directory
67311ab64890Smrg      compile         compile a source file into a libtool object
67321ab64890Smrg      execute         automatically set library path, then run a program
67331ab64890Smrg      finish          complete the installation of libtool libraries
67341ab64890Smrg      install         install libraries or executables
67351ab64890Smrg      link            create a library or an executable
67361ab64890Smrg      uninstall       remove libraries from an installed directory
67371ab64890Smrg
67381ab64890SmrgMODE-ARGS vary depending on the MODE.  Try \`$modename --help --mode=MODE' for
67391ab64890Smrga more detailed description of MODE.
67401ab64890Smrg
67411ab64890SmrgReport bugs to <bug-libtool@gnu.org>."
67421ab64890Smrg  exit $EXIT_SUCCESS
67431ab64890Smrg  ;;
67441ab64890Smrg
67451ab64890Smrgclean)
67461ab64890Smrg  $echo \
67471ab64890Smrg"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
67481ab64890Smrg
67491ab64890SmrgRemove files from the build directory.
67501ab64890Smrg
67511ab64890SmrgRM is the name of the program to use to delete files associated with each FILE
67521ab64890Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
67531ab64890Smrgto RM.
67541ab64890Smrg
67551ab64890SmrgIf FILE is a libtool library, object or program, all the files associated
67561ab64890Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
67571ab64890Smrg  ;;
67581ab64890Smrg
67591ab64890Smrgcompile)
67601ab64890Smrg  $echo \
67611ab64890Smrg"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
67621ab64890Smrg
67631ab64890SmrgCompile a source file into a libtool library object.
67641ab64890Smrg
67651ab64890SmrgThis mode accepts the following additional options:
67661ab64890Smrg
67671ab64890Smrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
67681ab64890Smrg  -prefer-pic       try to building PIC objects only
67691ab64890Smrg  -prefer-non-pic   try to building non-PIC objects only
67701ab64890Smrg  -static           always build a \`.o' file suitable for static linking
67711ab64890Smrg
67721ab64890SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
67731ab64890Smrgfrom the given SOURCEFILE.
67741ab64890Smrg
67751ab64890SmrgThe output file name is determined by removing the directory component from
67761ab64890SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
67771ab64890Smrglibrary object suffix, \`.lo'."
67781ab64890Smrg  ;;
67791ab64890Smrg
67801ab64890Smrgexecute)
67811ab64890Smrg  $echo \
67821ab64890Smrg"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]...
67831ab64890Smrg
67841ab64890SmrgAutomatically set library path, then run a program.
67851ab64890Smrg
67861ab64890SmrgThis mode accepts the following additional options:
67871ab64890Smrg
67881ab64890Smrg  -dlopen FILE      add the directory containing FILE to the library path
67891ab64890Smrg
67901ab64890SmrgThis mode sets the library path environment variable according to \`-dlopen'
67911ab64890Smrgflags.
67921ab64890Smrg
67931ab64890SmrgIf any of the ARGS are libtool executable wrappers, then they are translated
67941ab64890Smrginto their corresponding uninstalled binary, and any of their required library
67951ab64890Smrgdirectories are added to the library path.
67961ab64890Smrg
67971ab64890SmrgThen, COMMAND is executed, with ARGS as arguments."
67981ab64890Smrg  ;;
67991ab64890Smrg
68001ab64890Smrgfinish)
68011ab64890Smrg  $echo \
68021ab64890Smrg"Usage: $modename [OPTION]... --mode=finish [LIBDIR]...
68031ab64890Smrg
68041ab64890SmrgComplete the installation of libtool libraries.
68051ab64890Smrg
68061ab64890SmrgEach LIBDIR is a directory that contains libtool libraries.
68071ab64890Smrg
68081ab64890SmrgThe commands that this mode executes may require superuser privileges.  Use
68091ab64890Smrgthe \`--dry-run' option if you just want to see what would be executed."
68101ab64890Smrg  ;;
68111ab64890Smrg
68121ab64890Smrginstall)
68131ab64890Smrg  $echo \
68141ab64890Smrg"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND...
68151ab64890Smrg
68161ab64890SmrgInstall executables or libraries.
68171ab64890Smrg
68181ab64890SmrgINSTALL-COMMAND is the installation command.  The first component should be
68191ab64890Smrgeither the \`install' or \`cp' program.
68201ab64890Smrg
68211ab64890SmrgThe rest of the components are interpreted as arguments to that command (only
68221ab64890SmrgBSD-compatible install options are recognized)."
68231ab64890Smrg  ;;
68241ab64890Smrg
68251ab64890Smrglink)
68261ab64890Smrg  $echo \
68271ab64890Smrg"Usage: $modename [OPTION]... --mode=link LINK-COMMAND...
68281ab64890Smrg
68291ab64890SmrgLink object files or libraries together to form another library, or to
68301ab64890Smrgcreate an executable program.
68311ab64890Smrg
68321ab64890SmrgLINK-COMMAND is a command using the C compiler that you would use to create
68331ab64890Smrga program from several object files.
68341ab64890Smrg
68351ab64890SmrgThe following components of LINK-COMMAND are treated specially:
68361ab64890Smrg
68371ab64890Smrg  -all-static       do not do any dynamic linking at all
68381ab64890Smrg  -avoid-version    do not add a version suffix if possible
68391ab64890Smrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
68401ab64890Smrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
68411ab64890Smrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
68421ab64890Smrg  -export-symbols SYMFILE
68431ab64890Smrg                    try to export only the symbols listed in SYMFILE
68441ab64890Smrg  -export-symbols-regex REGEX
68451ab64890Smrg                    try to export only the symbols matching REGEX
68461ab64890Smrg  -LLIBDIR          search LIBDIR for required installed libraries
68471ab64890Smrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
68481ab64890Smrg  -module           build a library that can dlopened
68491ab64890Smrg  -no-fast-install  disable the fast-install mode
68501ab64890Smrg  -no-install       link a not-installable executable
68511ab64890Smrg  -no-undefined     declare that a library does not refer to external symbols
68521ab64890Smrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
68531ab64890Smrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
68541ab64890Smrg  -precious-files-regex REGEX
68551ab64890Smrg                    don't remove output files matching REGEX
68561ab64890Smrg  -release RELEASE  specify package release information
68571ab64890Smrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
68581ab64890Smrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
68591ab64890Smrg  -static           do not do any dynamic linking of uninstalled libtool libraries
68601ab64890Smrg  -static-libtool-libs
68611ab64890Smrg                    do not do any dynamic linking of libtool libraries
68621ab64890Smrg  -version-info CURRENT[:REVISION[:AGE]]
68631ab64890Smrg                    specify library version info [each variable defaults to 0]
68641ab64890Smrg
68651ab64890SmrgAll other options (arguments beginning with \`-') are ignored.
68661ab64890Smrg
68671ab64890SmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
68681ab64890Smrgtreated as uninstalled libtool libraries, other files are standard or library
68691ab64890Smrgobject files.
68701ab64890Smrg
68711ab64890SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
68721ab64890Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
68731ab64890Smrgrequired, except when creating a convenience library.
68741ab64890Smrg
68751ab64890SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
68761ab64890Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
68771ab64890Smrg
68781ab64890SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
68791ab64890Smrgis created, otherwise an executable program is created."
68801ab64890Smrg  ;;
68811ab64890Smrg
68821ab64890Smrguninstall)
68831ab64890Smrg  $echo \
68841ab64890Smrg"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
68851ab64890Smrg
68861ab64890SmrgRemove libraries from an installation directory.
68871ab64890Smrg
68881ab64890SmrgRM is the name of the program to use to delete files associated with each FILE
68891ab64890Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
68901ab64890Smrgto RM.
68911ab64890Smrg
68921ab64890SmrgIf FILE is a libtool library, all the files associated with it are deleted.
68931ab64890SmrgOtherwise, only FILE itself is deleted using RM."
68941ab64890Smrg  ;;
68951ab64890Smrg
68961ab64890Smrg*)
68971ab64890Smrg  $echo "$modename: invalid operation mode \`$mode'" 1>&2
68981ab64890Smrg  $echo "$help" 1>&2
68991ab64890Smrg  exit $EXIT_FAILURE
69001ab64890Smrg  ;;
69011ab64890Smrgesac
69021ab64890Smrg
69031ab64890Smrg$echo
69041ab64890Smrg$echo "Try \`$modename --help' for more information about other modes."
69051ab64890Smrg
69061ab64890Smrgexit $?
69071ab64890Smrg
69081ab64890Smrg# The TAGs below are defined such that we never get into a situation
69091ab64890Smrg# in which we disable both kinds of libraries.  Given conflicting
69101ab64890Smrg# choices, we go for a static library, that is the most portable,
69111ab64890Smrg# since we can't tell whether shared libraries were disabled because
69121ab64890Smrg# the user asked for that or because the platform doesn't support
69131ab64890Smrg# them.  This is particularly important on AIX, because we don't
69141ab64890Smrg# support having both static and shared libraries enabled at the same
69151ab64890Smrg# time on that platform, so we default to a shared-only configuration.
69161ab64890Smrg# If a disable-shared tag is given, we'll fallback to a static-only
69171ab64890Smrg# configuration.  But we'll never go from static-only to shared-only.
69181ab64890Smrg
69191ab64890Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
69201ab64890Smrgdisable_libs=shared
69211ab64890Smrg# ### END LIBTOOL TAG CONFIG: disable-shared
69221ab64890Smrg
69231ab64890Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
69241ab64890Smrgdisable_libs=static
69251ab64890Smrg# ### END LIBTOOL TAG CONFIG: disable-static
69261ab64890Smrg
69271ab64890Smrg# Local Variables:
69281ab64890Smrg# mode:shell-script
69291ab64890Smrg# sh-indentation:2
69301ab64890Smrg# End:
6931