ltmain.sh revision 9f606849
19f606849Smrg# ltmain.sh - Provide generalized library-building support services.
29f606849Smrg# NOTE: Changing this file will not affect anything until you rerun configure.
39f606849Smrg#
49f606849Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005
59f606849Smrg# Free Software Foundation, Inc.
69f606849Smrg# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
79f606849Smrg#
89f606849Smrg# This program is free software; you can redistribute it and/or modify
99f606849Smrg# it under the terms of the GNU General Public License as published by
109f606849Smrg# the Free Software Foundation; either version 2 of the License, or
119f606849Smrg# (at your option) any later version.
129f606849Smrg#
139f606849Smrg# This program is distributed in the hope that it will be useful, but
149f606849Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
159f606849Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
169f606849Smrg# General Public License for more details.
179f606849Smrg#
189f606849Smrg# You should have received a copy of the GNU General Public License
199f606849Smrg# along with this program; if not, write to the Free Software
209f606849Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
219f606849Smrg#
229f606849Smrg# As a special exception to the GNU General Public License, if you
239f606849Smrg# distribute this file as part of a program that contains a
249f606849Smrg# configuration script generated by Autoconf, you may include it under
259f606849Smrg# the same distribution terms that you use for the rest of that program.
269f606849Smrg
279f606849Smrgbasename="s,^.*/,,g"
289f606849Smrg
299f606849Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
309f606849Smrg# is ksh but when the shell is invoked as "sh" and the current value of
319f606849Smrg# the _XPG environment variable is not equal to 1 (one), the special
329f606849Smrg# positional parameter $0, within a function call, is the name of the
339f606849Smrg# function.
349f606849Smrgprogpath="$0"
359f606849Smrg
369f606849Smrg# The name of this program:
379f606849Smrgprogname=`echo "$progpath" | $SED $basename`
389f606849Smrgmodename="$progname"
399f606849Smrg
409f606849Smrg# Global variables:
419f606849SmrgEXIT_SUCCESS=0
429f606849SmrgEXIT_FAILURE=1
439f606849Smrg
449f606849SmrgPROGRAM=ltmain.sh
459f606849SmrgPACKAGE=libtool
469f606849SmrgVERSION=1.5.22
479f606849SmrgTIMESTAMP=" (1.1220.2.365 2005/12/18 22:14:06)"
489f606849Smrg
499f606849Smrg# See if we are running on zsh, and set the options which allow our
509f606849Smrg# commands through without removal of \ escapes.
519f606849Smrgif test -n "${ZSH_VERSION+set}" ; then
529f606849Smrg  setopt NO_GLOB_SUBST
539f606849Smrgfi
549f606849Smrg
559f606849Smrg# Check that we have a working $echo.
569f606849Smrgif test "X$1" = X--no-reexec; then
579f606849Smrg  # Discard the --no-reexec flag, and continue.
589f606849Smrg  shift
599f606849Smrgelif test "X$1" = X--fallback-echo; then
609f606849Smrg  # Avoid inline document here, it may be left over
619f606849Smrg  :
629f606849Smrgelif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
639f606849Smrg  # Yippee, $echo works!
649f606849Smrg  :
659f606849Smrgelse
669f606849Smrg  # Restart under the correct shell, and then maybe $echo will work.
679f606849Smrg  exec $SHELL "$progpath" --no-reexec ${1+"$@"}
689f606849Smrgfi
699f606849Smrg
709f606849Smrgif test "X$1" = X--fallback-echo; then
719f606849Smrg  # used as fallback echo
729f606849Smrg  shift
739f606849Smrg  cat <<EOF
749f606849Smrg$*
759f606849SmrgEOF
769f606849Smrg  exit $EXIT_SUCCESS
779f606849Smrgfi
789f606849Smrg
799f606849Smrgdefault_mode=
809f606849Smrghelp="Try \`$progname --help' for more information."
819f606849Smrgmagic="%%%MAGIC variable%%%"
829f606849Smrgmkdir="mkdir"
839f606849Smrgmv="mv -f"
849f606849Smrgrm="rm -f"
859f606849Smrg
869f606849Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
879f606849Smrg# metacharacters that are still active within double-quoted strings.
889f606849SmrgXsed="${SED}"' -e 1s/^X//'
899f606849Smrgsed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
909f606849Smrg# test EBCDIC or ASCII
919f606849Smrgcase `echo X|tr X '\101'` in
929f606849Smrg A) # ASCII based system
939f606849Smrg    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
949f606849Smrg  SP2NL='tr \040 \012'
959f606849Smrg  NL2SP='tr \015\012 \040\040'
969f606849Smrg  ;;
979f606849Smrg *) # EBCDIC based system
989f606849Smrg  SP2NL='tr \100 \n'
999f606849Smrg  NL2SP='tr \r\n \100\100'
1009f606849Smrg  ;;
1019f606849Smrgesac
1029f606849Smrg
1039f606849Smrg# NLS nuisances.
1049f606849Smrg# Only set LANG and LC_ALL to C if already set.
1059f606849Smrg# These must not be set unconditionally because not all systems understand
1069f606849Smrg# e.g. LANG=C (notably SCO).
1079f606849Smrg# We save the old values to restore during execute mode.
1089f606849Smrgif test "${LC_ALL+set}" = set; then
1099f606849Smrg  save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
1109f606849Smrgfi
1119f606849Smrgif test "${LANG+set}" = set; then
1129f606849Smrg  save_LANG="$LANG"; LANG=C; export LANG
1139f606849Smrgfi
1149f606849Smrg
1159f606849Smrg# Make sure IFS has a sensible default
1169f606849Smrglt_nl='
1179f606849Smrg'
1189f606849SmrgIFS=" 	$lt_nl"
1199f606849Smrg
1209f606849Smrgif test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
1219f606849Smrg  $echo "$modename: not configured to build any kind of library" 1>&2
1229f606849Smrg  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
1239f606849Smrg  exit $EXIT_FAILURE
1249f606849Smrgfi
1259f606849Smrg
1269f606849Smrg# Global variables.
1279f606849Smrgmode=$default_mode
1289f606849Smrgnonopt=
1299f606849Smrgprev=
1309f606849Smrgprevopt=
1319f606849Smrgrun=
1329f606849Smrgshow="$echo"
1339f606849Smrgshow_help=
1349f606849Smrgexecute_dlfiles=
1359f606849Smrgduplicate_deps=no
1369f606849Smrgpreserve_args=
1379f606849Smrglo2o="s/\\.lo\$/.${objext}/"
1389f606849Smrgo2lo="s/\\.${objext}\$/.lo/"
1399f606849Smrg
1409f606849Smrg#####################################
1419f606849Smrg# Shell function definitions:
1429f606849Smrg# This seems to be the best place for them
1439f606849Smrg
1449f606849Smrg# func_mktempdir [string]
1459f606849Smrg# Make a temporary directory that won't clash with other running
1469f606849Smrg# libtool processes, and avoids race conditions if possible.  If
1479f606849Smrg# given, STRING is the basename for that directory.
1489f606849Smrgfunc_mktempdir ()
1499f606849Smrg{
1509f606849Smrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
1519f606849Smrg
1529f606849Smrg    if test "$run" = ":"; then
1539f606849Smrg      # Return a directory name, but don't create it in dry-run mode
1549f606849Smrg      my_tmpdir="${my_template}-$$"
1559f606849Smrg    else
1569f606849Smrg
1579f606849Smrg      # If mktemp works, use that first and foremost
1589f606849Smrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
1599f606849Smrg
1609f606849Smrg      if test ! -d "$my_tmpdir"; then
1619f606849Smrg	# Failing that, at least try and use $RANDOM to avoid a race
1629f606849Smrg	my_tmpdir="${my_template}-${RANDOM-0}$$"
1639f606849Smrg
1649f606849Smrg	save_mktempdir_umask=`umask`
1659f606849Smrg	umask 0077
1669f606849Smrg	$mkdir "$my_tmpdir"
1679f606849Smrg	umask $save_mktempdir_umask
1689f606849Smrg      fi
1699f606849Smrg
1709f606849Smrg      # If we're not in dry-run mode, bomb out on failure
1719f606849Smrg      test -d "$my_tmpdir" || {
1729f606849Smrg        $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
1739f606849Smrg	exit $EXIT_FAILURE
1749f606849Smrg      }
1759f606849Smrg    fi
1769f606849Smrg
1779f606849Smrg    $echo "X$my_tmpdir" | $Xsed
1789f606849Smrg}
1799f606849Smrg
1809f606849Smrg
1819f606849Smrg# func_win32_libid arg
1829f606849Smrg# return the library type of file 'arg'
1839f606849Smrg#
1849f606849Smrg# Need a lot of goo to handle *both* DLLs and import libs
1859f606849Smrg# Has to be a shell function in order to 'eat' the argument
1869f606849Smrg# that is supplied when $file_magic_command is called.
1879f606849Smrgfunc_win32_libid ()
1889f606849Smrg{
1899f606849Smrg  win32_libid_type="unknown"
1909f606849Smrg  win32_fileres=`file -L $1 2>/dev/null`
1919f606849Smrg  case $win32_fileres in
1929f606849Smrg  *ar\ archive\ import\ library*) # definitely import
1939f606849Smrg    win32_libid_type="x86 archive import"
1949f606849Smrg    ;;
1959f606849Smrg  *ar\ archive*) # could be an import, or static
1969f606849Smrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
1979f606849Smrg      $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
1989f606849Smrg      win32_nmres=`eval $NM -f posix -A $1 | \
1999f606849Smrg	$SED -n -e '1,100{/ I /{s,.*,import,;p;q;};}'`
2009f606849Smrg      case $win32_nmres in
2019f606849Smrg      import*)  win32_libid_type="x86 archive import";;
2029f606849Smrg      *)        win32_libid_type="x86 archive static";;
2039f606849Smrg      esac
2049f606849Smrg    fi
2059f606849Smrg    ;;
2069f606849Smrg  *DLL*)
2079f606849Smrg    win32_libid_type="x86 DLL"
2089f606849Smrg    ;;
2099f606849Smrg  *executable*) # but shell scripts are "executable" too...
2109f606849Smrg    case $win32_fileres in
2119f606849Smrg    *MS\ Windows\ PE\ Intel*)
2129f606849Smrg      win32_libid_type="x86 DLL"
2139f606849Smrg      ;;
2149f606849Smrg    esac
2159f606849Smrg    ;;
2169f606849Smrg  esac
2179f606849Smrg  $echo $win32_libid_type
2189f606849Smrg}
2199f606849Smrg
2209f606849Smrg
2219f606849Smrg# func_infer_tag arg
2229f606849Smrg# Infer tagged configuration to use if any are available and
2239f606849Smrg# if one wasn't chosen via the "--tag" command line option.
2249f606849Smrg# Only attempt this if the compiler in the base compile
2259f606849Smrg# command doesn't match the default compiler.
2269f606849Smrg# arg is usually of the form 'gcc ...'
2279f606849Smrgfunc_infer_tag ()
2289f606849Smrg{
2299f606849Smrg    if test -n "$available_tags" && test -z "$tagname"; then
2309f606849Smrg      CC_quoted=
2319f606849Smrg      for arg in $CC; do
2329f606849Smrg	case $arg in
2339f606849Smrg	  *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
2349f606849Smrg	  arg="\"$arg\""
2359f606849Smrg	  ;;
2369f606849Smrg	esac
2379f606849Smrg	CC_quoted="$CC_quoted $arg"
2389f606849Smrg      done
2399f606849Smrg      case $@ in
2409f606849Smrg      # Blanks in the command may have been stripped by the calling shell,
2419f606849Smrg      # but not from the CC environment variable when configure was run.
2429f606849Smrg      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
2439f606849Smrg      # Blanks at the start of $base_compile will cause this to fail
2449f606849Smrg      # if we don't check for them as well.
2459f606849Smrg      *)
2469f606849Smrg	for z in $available_tags; do
2479f606849Smrg	  if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
2489f606849Smrg	    # Evaluate the configuration.
2499f606849Smrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
2509f606849Smrg	    CC_quoted=
2519f606849Smrg	    for arg in $CC; do
2529f606849Smrg	    # Double-quote args containing other shell metacharacters.
2539f606849Smrg	    case $arg in
2549f606849Smrg	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
2559f606849Smrg	      arg="\"$arg\""
2569f606849Smrg	      ;;
2579f606849Smrg	    esac
2589f606849Smrg	    CC_quoted="$CC_quoted $arg"
2599f606849Smrg	  done
2609f606849Smrg	    case "$@ " in
2619f606849Smrg	      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
2629f606849Smrg	      # The compiler in the base compile command matches
2639f606849Smrg	      # the one in the tagged configuration.
2649f606849Smrg	      # Assume this is the tagged configuration we want.
2659f606849Smrg	      tagname=$z
2669f606849Smrg	      break
2679f606849Smrg	      ;;
2689f606849Smrg	    esac
2699f606849Smrg	  fi
2709f606849Smrg	done
2719f606849Smrg	# If $tagname still isn't set, then no tagged configuration
2729f606849Smrg	# was found and let the user know that the "--tag" command
2739f606849Smrg	# line option must be used.
2749f606849Smrg	if test -z "$tagname"; then
2759f606849Smrg	  $echo "$modename: unable to infer tagged configuration"
2769f606849Smrg	  $echo "$modename: specify a tag with \`--tag'" 1>&2
2779f606849Smrg	  exit $EXIT_FAILURE
2789f606849Smrg#        else
2799f606849Smrg#          $echo "$modename: using $tagname tagged configuration"
2809f606849Smrg	fi
2819f606849Smrg	;;
2829f606849Smrg      esac
2839f606849Smrg    fi
2849f606849Smrg}
2859f606849Smrg
2869f606849Smrg
2879f606849Smrg# func_extract_an_archive dir oldlib
2889f606849Smrgfunc_extract_an_archive ()
2899f606849Smrg{
2909f606849Smrg    f_ex_an_ar_dir="$1"; shift
2919f606849Smrg    f_ex_an_ar_oldlib="$1"
2929f606849Smrg
2939f606849Smrg    $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
2949f606849Smrg    $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
2959f606849Smrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
2969f606849Smrg     :
2979f606849Smrg    else
2989f606849Smrg      $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2
2999f606849Smrg      exit $EXIT_FAILURE
3009f606849Smrg    fi
3019f606849Smrg}
3029f606849Smrg
3039f606849Smrg# func_extract_archives gentop oldlib ...
3049f606849Smrgfunc_extract_archives ()
3059f606849Smrg{
3069f606849Smrg    my_gentop="$1"; shift
3079f606849Smrg    my_oldlibs=${1+"$@"}
3089f606849Smrg    my_oldobjs=""
3099f606849Smrg    my_xlib=""
3109f606849Smrg    my_xabs=""
3119f606849Smrg    my_xdir=""
3129f606849Smrg    my_status=""
3139f606849Smrg
3149f606849Smrg    $show "${rm}r $my_gentop"
3159f606849Smrg    $run ${rm}r "$my_gentop"
3169f606849Smrg    $show "$mkdir $my_gentop"
3179f606849Smrg    $run $mkdir "$my_gentop"
3189f606849Smrg    my_status=$?
3199f606849Smrg    if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
3209f606849Smrg      exit $my_status
3219f606849Smrg    fi
3229f606849Smrg
3239f606849Smrg    for my_xlib in $my_oldlibs; do
3249f606849Smrg      # Extract the objects.
3259f606849Smrg      case $my_xlib in
3269f606849Smrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
3279f606849Smrg	*) my_xabs=`pwd`"/$my_xlib" ;;
3289f606849Smrg      esac
3299f606849Smrg      my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
3309f606849Smrg      my_xdir="$my_gentop/$my_xlib"
3319f606849Smrg
3329f606849Smrg      $show "${rm}r $my_xdir"
3339f606849Smrg      $run ${rm}r "$my_xdir"
3349f606849Smrg      $show "$mkdir $my_xdir"
3359f606849Smrg      $run $mkdir "$my_xdir"
3369f606849Smrg      exit_status=$?
3379f606849Smrg      if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then
3389f606849Smrg	exit $exit_status
3399f606849Smrg      fi
3409f606849Smrg      case $host in
3419f606849Smrg      *-darwin*)
3429f606849Smrg	$show "Extracting $my_xabs"
3439f606849Smrg	# Do not bother doing anything if just a dry run
3449f606849Smrg	if test -z "$run"; then
3459f606849Smrg	  darwin_orig_dir=`pwd`
3469f606849Smrg	  cd $my_xdir || exit $?
3479f606849Smrg	  darwin_archive=$my_xabs
3489f606849Smrg	  darwin_curdir=`pwd`
3499f606849Smrg	  darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'`
3509f606849Smrg	  darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
3519f606849Smrg	  if test -n "$darwin_arches"; then 
3529f606849Smrg	    darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
3539f606849Smrg	    darwin_arch=
3549f606849Smrg	    $show "$darwin_base_archive has multiple architectures $darwin_arches"
3559f606849Smrg	    for darwin_arch in  $darwin_arches ; do
3569f606849Smrg	      mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3579f606849Smrg	      lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
3589f606849Smrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3599f606849Smrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
3609f606849Smrg	      cd "$darwin_curdir"
3619f606849Smrg	      $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
3629f606849Smrg	    done # $darwin_arches
3639f606849Smrg      ## Okay now we have a bunch of thin objects, gotta fatten them up :)
3649f606849Smrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP`
3659f606849Smrg	    darwin_file=
3669f606849Smrg	    darwin_files=
3679f606849Smrg	    for darwin_file in $darwin_filelist; do
3689f606849Smrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
3699f606849Smrg	      lipo -create -output "$darwin_file" $darwin_files
3709f606849Smrg	    done # $darwin_filelist
3719f606849Smrg	    ${rm}r unfat-$$
3729f606849Smrg	    cd "$darwin_orig_dir"
3739f606849Smrg	  else
3749f606849Smrg	    cd "$darwin_orig_dir"
3759f606849Smrg 	    func_extract_an_archive "$my_xdir" "$my_xabs"
3769f606849Smrg	  fi # $darwin_arches
3779f606849Smrg	fi # $run
3789f606849Smrg	;;
3799f606849Smrg      *)
3809f606849Smrg        func_extract_an_archive "$my_xdir" "$my_xabs"
3819f606849Smrg        ;;
3829f606849Smrg      esac
3839f606849Smrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
3849f606849Smrg    done
3859f606849Smrg    func_extract_archives_result="$my_oldobjs"
3869f606849Smrg}
3879f606849Smrg# End of Shell function definitions
3889f606849Smrg#####################################
3899f606849Smrg
3909f606849Smrg# Darwin sucks
3919f606849Smrgeval std_shrext=\"$shrext_cmds\"
3929f606849Smrg
3939f606849Smrgdisable_libs=no
3949f606849Smrg
3959f606849Smrg# Parse our command line options once, thoroughly.
3969f606849Smrgwhile test "$#" -gt 0
3979f606849Smrgdo
3989f606849Smrg  arg="$1"
3999f606849Smrg  shift
4009f606849Smrg
4019f606849Smrg  case $arg in
4029f606849Smrg  -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
4039f606849Smrg  *) optarg= ;;
4049f606849Smrg  esac
4059f606849Smrg
4069f606849Smrg  # If the previous option needs an argument, assign it.
4079f606849Smrg  if test -n "$prev"; then
4089f606849Smrg    case $prev in
4099f606849Smrg    execute_dlfiles)
4109f606849Smrg      execute_dlfiles="$execute_dlfiles $arg"
4119f606849Smrg      ;;
4129f606849Smrg    tag)
4139f606849Smrg      tagname="$arg"
4149f606849Smrg      preserve_args="${preserve_args}=$arg"
4159f606849Smrg
4169f606849Smrg      # Check whether tagname contains only valid characters
4179f606849Smrg      case $tagname in
4189f606849Smrg      *[!-_A-Za-z0-9,/]*)
4199f606849Smrg	$echo "$progname: invalid tag name: $tagname" 1>&2
4209f606849Smrg	exit $EXIT_FAILURE
4219f606849Smrg	;;
4229f606849Smrg      esac
4239f606849Smrg
4249f606849Smrg      case $tagname in
4259f606849Smrg      CC)
4269f606849Smrg	# Don't test for the "default" C tag, as we know, it's there, but
4279f606849Smrg	# not specially marked.
4289f606849Smrg	;;
4299f606849Smrg      *)
4309f606849Smrg	if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then
4319f606849Smrg	  taglist="$taglist $tagname"
4329f606849Smrg	  # Evaluate the configuration.
4339f606849Smrg	  eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`"
4349f606849Smrg	else
4359f606849Smrg	  $echo "$progname: ignoring unknown tag $tagname" 1>&2
4369f606849Smrg	fi
4379f606849Smrg	;;
4389f606849Smrg      esac
4399f606849Smrg      ;;
4409f606849Smrg    *)
4419f606849Smrg      eval "$prev=\$arg"
4429f606849Smrg      ;;
4439f606849Smrg    esac
4449f606849Smrg
4459f606849Smrg    prev=
4469f606849Smrg    prevopt=
4479f606849Smrg    continue
4489f606849Smrg  fi
4499f606849Smrg
4509f606849Smrg  # Have we seen a non-optional argument yet?
4519f606849Smrg  case $arg in
4529f606849Smrg  --help)
4539f606849Smrg    show_help=yes
4549f606849Smrg    ;;
4559f606849Smrg
4569f606849Smrg  --version)
4579f606849Smrg    $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
4589f606849Smrg    $echo
4599f606849Smrg    $echo "Copyright (C) 2005  Free Software Foundation, Inc."
4609f606849Smrg    $echo "This is free software; see the source for copying conditions.  There is NO"
4619f606849Smrg    $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
4629f606849Smrg    exit $?
4639f606849Smrg    ;;
4649f606849Smrg
4659f606849Smrg  --config)
4669f606849Smrg    ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath
4679f606849Smrg    # Now print the configurations for the tags.
4689f606849Smrg    for tagname in $taglist; do
4699f606849Smrg      ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
4709f606849Smrg    done
4719f606849Smrg    exit $?
4729f606849Smrg    ;;
4739f606849Smrg
4749f606849Smrg  --debug)
4759f606849Smrg    $echo "$progname: enabling shell trace mode"
4769f606849Smrg    set -x
4779f606849Smrg    preserve_args="$preserve_args $arg"
4789f606849Smrg    ;;
4799f606849Smrg
4809f606849Smrg  --dry-run | -n)
4819f606849Smrg    run=:
4829f606849Smrg    ;;
4839f606849Smrg
4849f606849Smrg  --features)
4859f606849Smrg    $echo "host: $host"
4869f606849Smrg    if test "$build_libtool_libs" = yes; then
4879f606849Smrg      $echo "enable shared libraries"
4889f606849Smrg    else
4899f606849Smrg      $echo "disable shared libraries"
4909f606849Smrg    fi
4919f606849Smrg    if test "$build_old_libs" = yes; then
4929f606849Smrg      $echo "enable static libraries"
4939f606849Smrg    else
4949f606849Smrg      $echo "disable static libraries"
4959f606849Smrg    fi
4969f606849Smrg    exit $?
4979f606849Smrg    ;;
4989f606849Smrg
4999f606849Smrg  --finish) mode="finish" ;;
5009f606849Smrg
5019f606849Smrg  --mode) prevopt="--mode" prev=mode ;;
5029f606849Smrg  --mode=*) mode="$optarg" ;;
5039f606849Smrg
5049f606849Smrg  --preserve-dup-deps) duplicate_deps="yes" ;;
5059f606849Smrg
5069f606849Smrg  --quiet | --silent)
5079f606849Smrg    show=:
5089f606849Smrg    preserve_args="$preserve_args $arg"
5099f606849Smrg    ;;
5109f606849Smrg
5119f606849Smrg  --tag)
5129f606849Smrg    prevopt="--tag"
5139f606849Smrg    prev=tag
5149f606849Smrg    preserve_args="$preserve_args --tag"
5159f606849Smrg    ;;
5169f606849Smrg  --tag=*)
5179f606849Smrg    set tag "$optarg" ${1+"$@"}
5189f606849Smrg    shift
5199f606849Smrg    prev=tag
5209f606849Smrg    preserve_args="$preserve_args --tag"
5219f606849Smrg    ;;
5229f606849Smrg
5239f606849Smrg  -dlopen)
5249f606849Smrg    prevopt="-dlopen"
5259f606849Smrg    prev=execute_dlfiles
5269f606849Smrg    ;;
5279f606849Smrg
5289f606849Smrg  -*)
5299f606849Smrg    $echo "$modename: unrecognized option \`$arg'" 1>&2
5309f606849Smrg    $echo "$help" 1>&2
5319f606849Smrg    exit $EXIT_FAILURE
5329f606849Smrg    ;;
5339f606849Smrg
5349f606849Smrg  *)
5359f606849Smrg    nonopt="$arg"
5369f606849Smrg    break
5379f606849Smrg    ;;
5389f606849Smrg  esac
5399f606849Smrgdone
5409f606849Smrg
5419f606849Smrgif test -n "$prevopt"; then
5429f606849Smrg  $echo "$modename: option \`$prevopt' requires an argument" 1>&2
5439f606849Smrg  $echo "$help" 1>&2
5449f606849Smrg  exit $EXIT_FAILURE
5459f606849Smrgfi
5469f606849Smrg
5479f606849Smrgcase $disable_libs in
5489f606849Smrgno) 
5499f606849Smrg  ;;
5509f606849Smrgshared)
5519f606849Smrg  build_libtool_libs=no
5529f606849Smrg  build_old_libs=yes
5539f606849Smrg  ;;
5549f606849Smrgstatic)
5559f606849Smrg  build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
5569f606849Smrg  ;;
5579f606849Smrgesac
5589f606849Smrg
5599f606849Smrg# If this variable is set in any of the actions, the command in it
5609f606849Smrg# will be execed at the end.  This prevents here-documents from being
5619f606849Smrg# left over by shells.
5629f606849Smrgexec_cmd=
5639f606849Smrg
5649f606849Smrgif test -z "$show_help"; then
5659f606849Smrg
5669f606849Smrg  # Infer the operation mode.
5679f606849Smrg  if test -z "$mode"; then
5689f606849Smrg    $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
5699f606849Smrg    $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2
5709f606849Smrg    case $nonopt in
5719f606849Smrg    *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
5729f606849Smrg      mode=link
5739f606849Smrg      for arg
5749f606849Smrg      do
5759f606849Smrg	case $arg in
5769f606849Smrg	-c)
5779f606849Smrg	   mode=compile
5789f606849Smrg	   break
5799f606849Smrg	   ;;
5809f606849Smrg	esac
5819f606849Smrg      done
5829f606849Smrg      ;;
5839f606849Smrg    *db | *dbx | *strace | *truss)
5849f606849Smrg      mode=execute
5859f606849Smrg      ;;
5869f606849Smrg    *install*|cp|mv)
5879f606849Smrg      mode=install
5889f606849Smrg      ;;
5899f606849Smrg    *rm)
5909f606849Smrg      mode=uninstall
5919f606849Smrg      ;;
5929f606849Smrg    *)
5939f606849Smrg      # If we have no mode, but dlfiles were specified, then do execute mode.
5949f606849Smrg      test -n "$execute_dlfiles" && mode=execute
5959f606849Smrg
5969f606849Smrg      # Just use the default operation mode.
5979f606849Smrg      if test -z "$mode"; then
5989f606849Smrg	if test -n "$nonopt"; then
5999f606849Smrg	  $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
6009f606849Smrg	else
6019f606849Smrg	  $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
6029f606849Smrg	fi
6039f606849Smrg      fi
6049f606849Smrg      ;;
6059f606849Smrg    esac
6069f606849Smrg  fi
6079f606849Smrg
6089f606849Smrg  # Only execute mode is allowed to have -dlopen flags.
6099f606849Smrg  if test -n "$execute_dlfiles" && test "$mode" != execute; then
6109f606849Smrg    $echo "$modename: unrecognized option \`-dlopen'" 1>&2
6119f606849Smrg    $echo "$help" 1>&2
6129f606849Smrg    exit $EXIT_FAILURE
6139f606849Smrg  fi
6149f606849Smrg
6159f606849Smrg  # Change the help message to a mode-specific one.
6169f606849Smrg  generic_help="$help"
6179f606849Smrg  help="Try \`$modename --help --mode=$mode' for more information."
6189f606849Smrg
6199f606849Smrg  # These modes are in order of execution frequency so that they run quickly.
6209f606849Smrg  case $mode in
6219f606849Smrg  # libtool compile mode
6229f606849Smrg  compile)
6239f606849Smrg    modename="$modename: compile"
6249f606849Smrg    # Get the compilation command and the source file.
6259f606849Smrg    base_compile=
6269f606849Smrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
6279f606849Smrg    suppress_opt=yes
6289f606849Smrg    suppress_output=
6299f606849Smrg    arg_mode=normal
6309f606849Smrg    libobj=
6319f606849Smrg    later=
6329f606849Smrg
6339f606849Smrg    for arg
6349f606849Smrg    do
6359f606849Smrg      case $arg_mode in
6369f606849Smrg      arg  )
6379f606849Smrg	# do not "continue".  Instead, add this to base_compile
6389f606849Smrg	lastarg="$arg"
6399f606849Smrg	arg_mode=normal
6409f606849Smrg	;;
6419f606849Smrg
6429f606849Smrg      target )
6439f606849Smrg	libobj="$arg"
6449f606849Smrg	arg_mode=normal
6459f606849Smrg	continue
6469f606849Smrg	;;
6479f606849Smrg
6489f606849Smrg      normal )
6499f606849Smrg	# Accept any command-line options.
6509f606849Smrg	case $arg in
6519f606849Smrg	-o)
6529f606849Smrg	  if test -n "$libobj" ; then
6539f606849Smrg	    $echo "$modename: you cannot specify \`-o' more than once" 1>&2
6549f606849Smrg	    exit $EXIT_FAILURE
6559f606849Smrg	  fi
6569f606849Smrg	  arg_mode=target
6579f606849Smrg	  continue
6589f606849Smrg	  ;;
6599f606849Smrg
6609f606849Smrg	-static | -prefer-pic | -prefer-non-pic)
6619f606849Smrg	  later="$later $arg"
6629f606849Smrg	  continue
6639f606849Smrg	  ;;
6649f606849Smrg
6659f606849Smrg	-no-suppress)
6669f606849Smrg	  suppress_opt=no
6679f606849Smrg	  continue
6689f606849Smrg	  ;;
6699f606849Smrg
6709f606849Smrg	-Xcompiler)
6719f606849Smrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
6729f606849Smrg	  continue      #  The current "srcfile" will either be retained or
6739f606849Smrg	  ;;            #  replaced later.  I would guess that would be a bug.
6749f606849Smrg
6759f606849Smrg	-Wc,*)
6769f606849Smrg	  args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
6779f606849Smrg	  lastarg=
6789f606849Smrg	  save_ifs="$IFS"; IFS=','
6799f606849Smrg 	  for arg in $args; do
6809f606849Smrg	    IFS="$save_ifs"
6819f606849Smrg
6829f606849Smrg	    # Double-quote args containing other shell metacharacters.
6839f606849Smrg	    # Many Bourne shells cannot handle close brackets correctly
6849f606849Smrg	    # in scan sets, so we specify it separately.
6859f606849Smrg	    case $arg in
6869f606849Smrg	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
6879f606849Smrg	      arg="\"$arg\""
6889f606849Smrg	      ;;
6899f606849Smrg	    esac
6909f606849Smrg	    lastarg="$lastarg $arg"
6919f606849Smrg	  done
6929f606849Smrg	  IFS="$save_ifs"
6939f606849Smrg	  lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
6949f606849Smrg
6959f606849Smrg	  # Add the arguments to base_compile.
6969f606849Smrg	  base_compile="$base_compile $lastarg"
6979f606849Smrg	  continue
6989f606849Smrg	  ;;
6999f606849Smrg
7009f606849Smrg	* )
7019f606849Smrg	  # Accept the current argument as the source file.
7029f606849Smrg	  # The previous "srcfile" becomes the current argument.
7039f606849Smrg	  #
7049f606849Smrg	  lastarg="$srcfile"
7059f606849Smrg	  srcfile="$arg"
7069f606849Smrg	  ;;
7079f606849Smrg	esac  #  case $arg
7089f606849Smrg	;;
7099f606849Smrg      esac    #  case $arg_mode
7109f606849Smrg
7119f606849Smrg      # Aesthetically quote the previous argument.
7129f606849Smrg      lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
7139f606849Smrg
7149f606849Smrg      case $lastarg in
7159f606849Smrg      # Double-quote args containing other shell metacharacters.
7169f606849Smrg      # Many Bourne shells cannot handle close brackets correctly
7179f606849Smrg      # in scan sets, and some SunOS ksh mistreat backslash-escaping
7189f606849Smrg      # in scan sets (worked around with variable expansion),
7199f606849Smrg      # and furthermore cannot handle '|' '&' '(' ')' in scan sets 
7209f606849Smrg      # at all, so we specify them separately.
7219f606849Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
7229f606849Smrg	lastarg="\"$lastarg\""
7239f606849Smrg	;;
7249f606849Smrg      esac
7259f606849Smrg
7269f606849Smrg      base_compile="$base_compile $lastarg"
7279f606849Smrg    done # for arg
7289f606849Smrg
7299f606849Smrg    case $arg_mode in
7309f606849Smrg    arg)
7319f606849Smrg      $echo "$modename: you must specify an argument for -Xcompile"
7329f606849Smrg      exit $EXIT_FAILURE
7339f606849Smrg      ;;
7349f606849Smrg    target)
7359f606849Smrg      $echo "$modename: you must specify a target with \`-o'" 1>&2
7369f606849Smrg      exit $EXIT_FAILURE
7379f606849Smrg      ;;
7389f606849Smrg    *)
7399f606849Smrg      # Get the name of the library object.
7409f606849Smrg      [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
7419f606849Smrg      ;;
7429f606849Smrg    esac
7439f606849Smrg
7449f606849Smrg    # Recognize several different file suffixes.
7459f606849Smrg    # If the user specifies -o file.o, it is replaced with file.lo
7469f606849Smrg    xform='[cCFSifmso]'
7479f606849Smrg    case $libobj in
7489f606849Smrg    *.ada) xform=ada ;;
7499f606849Smrg    *.adb) xform=adb ;;
7509f606849Smrg    *.ads) xform=ads ;;
7519f606849Smrg    *.asm) xform=asm ;;
7529f606849Smrg    *.c++) xform=c++ ;;
7539f606849Smrg    *.cc) xform=cc ;;
7549f606849Smrg    *.ii) xform=ii ;;
7559f606849Smrg    *.class) xform=class ;;
7569f606849Smrg    *.cpp) xform=cpp ;;
7579f606849Smrg    *.cxx) xform=cxx ;;
7589f606849Smrg    *.f90) xform=f90 ;;
7599f606849Smrg    *.for) xform=for ;;
7609f606849Smrg    *.java) xform=java ;;
7619f606849Smrg    esac
7629f606849Smrg
7639f606849Smrg    libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
7649f606849Smrg
7659f606849Smrg    case $libobj in
7669f606849Smrg    *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
7679f606849Smrg    *)
7689f606849Smrg      $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
7699f606849Smrg      exit $EXIT_FAILURE
7709f606849Smrg      ;;
7719f606849Smrg    esac
7729f606849Smrg
7739f606849Smrg    func_infer_tag $base_compile
7749f606849Smrg
7759f606849Smrg    for arg in $later; do
7769f606849Smrg      case $arg in
7779f606849Smrg      -static)
7789f606849Smrg	build_old_libs=yes
7799f606849Smrg	continue
7809f606849Smrg	;;
7819f606849Smrg
7829f606849Smrg      -prefer-pic)
7839f606849Smrg	pic_mode=yes
7849f606849Smrg	continue
7859f606849Smrg	;;
7869f606849Smrg
7879f606849Smrg      -prefer-non-pic)
7889f606849Smrg	pic_mode=no
7899f606849Smrg	continue
7909f606849Smrg	;;
7919f606849Smrg      esac
7929f606849Smrg    done
7939f606849Smrg
7949f606849Smrg    qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"`
7959f606849Smrg    case $qlibobj in
7969f606849Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
7979f606849Smrg	qlibobj="\"$qlibobj\"" ;;
7989f606849Smrg    esac
7999f606849Smrg    test "X$libobj" != "X$qlibobj" \
8009f606849Smrg	&& $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"' 	&()|`$[]' \
8019f606849Smrg	&& $echo "$modename: libobj name \`$libobj' may not contain shell special characters."
8029f606849Smrg    objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
8039f606849Smrg    xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
8049f606849Smrg    if test "X$xdir" = "X$obj"; then
8059f606849Smrg      xdir=
8069f606849Smrg    else
8079f606849Smrg      xdir=$xdir/
8089f606849Smrg    fi
8099f606849Smrg    lobj=${xdir}$objdir/$objname
8109f606849Smrg
8119f606849Smrg    if test -z "$base_compile"; then
8129f606849Smrg      $echo "$modename: you must specify a compilation command" 1>&2
8139f606849Smrg      $echo "$help" 1>&2
8149f606849Smrg      exit $EXIT_FAILURE
8159f606849Smrg    fi
8169f606849Smrg
8179f606849Smrg    # Delete any leftover library objects.
8189f606849Smrg    if test "$build_old_libs" = yes; then
8199f606849Smrg      removelist="$obj $lobj $libobj ${libobj}T"
8209f606849Smrg    else
8219f606849Smrg      removelist="$lobj $libobj ${libobj}T"
8229f606849Smrg    fi
8239f606849Smrg
8249f606849Smrg    $run $rm $removelist
8259f606849Smrg    trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
8269f606849Smrg
8279f606849Smrg    # On Cygwin there's no "real" PIC flag so we must build both object types
8289f606849Smrg    case $host_os in
8299f606849Smrg    cygwin* | mingw* | pw32* | os2*)
8309f606849Smrg      pic_mode=default
8319f606849Smrg      ;;
8329f606849Smrg    esac
8339f606849Smrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
8349f606849Smrg      # non-PIC code in shared libraries is not supported
8359f606849Smrg      pic_mode=default
8369f606849Smrg    fi
8379f606849Smrg
8389f606849Smrg    # Calculate the filename of the output object if compiler does
8399f606849Smrg    # not support -o with -c
8409f606849Smrg    if test "$compiler_c_o" = no; then
8419f606849Smrg      output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
8429f606849Smrg      lockfile="$output_obj.lock"
8439f606849Smrg      removelist="$removelist $output_obj $lockfile"
8449f606849Smrg      trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
8459f606849Smrg    else
8469f606849Smrg      output_obj=
8479f606849Smrg      need_locks=no
8489f606849Smrg      lockfile=
8499f606849Smrg    fi
8509f606849Smrg
8519f606849Smrg    # Lock this critical section if it is needed
8529f606849Smrg    # We use this script file to make the link, it avoids creating a new file
8539f606849Smrg    if test "$need_locks" = yes; then
8549f606849Smrg      until $run ln "$progpath" "$lockfile" 2>/dev/null; do
8559f606849Smrg	$show "Waiting for $lockfile to be removed"
8569f606849Smrg	sleep 2
8579f606849Smrg      done
8589f606849Smrg    elif test "$need_locks" = warn; then
8599f606849Smrg      if test -f "$lockfile"; then
8609f606849Smrg	$echo "\
8619f606849Smrg*** ERROR, $lockfile exists and contains:
8629f606849Smrg`cat $lockfile 2>/dev/null`
8639f606849Smrg
8649f606849SmrgThis indicates that another process is trying to use the same
8659f606849Smrgtemporary object file, and libtool could not work around it because
8669f606849Smrgyour compiler does not support \`-c' and \`-o' together.  If you
8679f606849Smrgrepeat this compilation, it may succeed, by chance, but you had better
8689f606849Smrgavoid parallel builds (make -j) in this platform, or get a better
8699f606849Smrgcompiler."
8709f606849Smrg
8719f606849Smrg	$run $rm $removelist
8729f606849Smrg	exit $EXIT_FAILURE
8739f606849Smrg      fi
8749f606849Smrg      $echo "$srcfile" > "$lockfile"
8759f606849Smrg    fi
8769f606849Smrg
8779f606849Smrg    if test -n "$fix_srcfile_path"; then
8789f606849Smrg      eval srcfile=\"$fix_srcfile_path\"
8799f606849Smrg    fi
8809f606849Smrg    qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"`
8819f606849Smrg    case $qsrcfile in
8829f606849Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
8839f606849Smrg      qsrcfile="\"$qsrcfile\"" ;;
8849f606849Smrg    esac
8859f606849Smrg
8869f606849Smrg    $run $rm "$libobj" "${libobj}T"
8879f606849Smrg
8889f606849Smrg    # Create a libtool object file (analogous to a ".la" file),
8899f606849Smrg    # but don't create it if we're doing a dry run.
8909f606849Smrg    test -z "$run" && cat > ${libobj}T <<EOF
8919f606849Smrg# $libobj - a libtool object file
8929f606849Smrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
8939f606849Smrg#
8949f606849Smrg# Please DO NOT delete this file!
8959f606849Smrg# It is necessary for linking the library.
8969f606849Smrg
8979f606849Smrg# Name of the PIC object.
8989f606849SmrgEOF
8999f606849Smrg
9009f606849Smrg    # Only build a PIC object if we are building libtool libraries.
9019f606849Smrg    if test "$build_libtool_libs" = yes; then
9029f606849Smrg      # Without this assignment, base_compile gets emptied.
9039f606849Smrg      fbsd_hideous_sh_bug=$base_compile
9049f606849Smrg
9059f606849Smrg      if test "$pic_mode" != no; then
9069f606849Smrg	command="$base_compile $qsrcfile $pic_flag"
9079f606849Smrg      else
9089f606849Smrg	# Don't build PIC code
9099f606849Smrg	command="$base_compile $qsrcfile"
9109f606849Smrg      fi
9119f606849Smrg
9129f606849Smrg      if test ! -d "${xdir}$objdir"; then
9139f606849Smrg	$show "$mkdir ${xdir}$objdir"
9149f606849Smrg	$run $mkdir ${xdir}$objdir
9159f606849Smrg	exit_status=$?
9169f606849Smrg	if test "$exit_status" -ne 0 && test ! -d "${xdir}$objdir"; then
9179f606849Smrg	  exit $exit_status
9189f606849Smrg	fi
9199f606849Smrg      fi
9209f606849Smrg
9219f606849Smrg      if test -z "$output_obj"; then
9229f606849Smrg	# Place PIC objects in $objdir
9239f606849Smrg	command="$command -o $lobj"
9249f606849Smrg      fi
9259f606849Smrg
9269f606849Smrg      $run $rm "$lobj" "$output_obj"
9279f606849Smrg
9289f606849Smrg      $show "$command"
9299f606849Smrg      if $run eval "$command"; then :
9309f606849Smrg      else
9319f606849Smrg	test -n "$output_obj" && $run $rm $removelist
9329f606849Smrg	exit $EXIT_FAILURE
9339f606849Smrg      fi
9349f606849Smrg
9359f606849Smrg      if test "$need_locks" = warn &&
9369f606849Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
9379f606849Smrg	$echo "\
9389f606849Smrg*** ERROR, $lockfile contains:
9399f606849Smrg`cat $lockfile 2>/dev/null`
9409f606849Smrg
9419f606849Smrgbut it should contain:
9429f606849Smrg$srcfile
9439f606849Smrg
9449f606849SmrgThis indicates that another process is trying to use the same
9459f606849Smrgtemporary object file, and libtool could not work around it because
9469f606849Smrgyour compiler does not support \`-c' and \`-o' together.  If you
9479f606849Smrgrepeat this compilation, it may succeed, by chance, but you had better
9489f606849Smrgavoid parallel builds (make -j) in this platform, or get a better
9499f606849Smrgcompiler."
9509f606849Smrg
9519f606849Smrg	$run $rm $removelist
9529f606849Smrg	exit $EXIT_FAILURE
9539f606849Smrg      fi
9549f606849Smrg
9559f606849Smrg      # Just move the object if needed, then go on to compile the next one
9569f606849Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
9579f606849Smrg	$show "$mv $output_obj $lobj"
9589f606849Smrg	if $run $mv $output_obj $lobj; then :
9599f606849Smrg	else
9609f606849Smrg	  error=$?
9619f606849Smrg	  $run $rm $removelist
9629f606849Smrg	  exit $error
9639f606849Smrg	fi
9649f606849Smrg      fi
9659f606849Smrg
9669f606849Smrg      # Append the name of the PIC object to the libtool object file.
9679f606849Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
9689f606849Smrgpic_object='$objdir/$objname'
9699f606849Smrg
9709f606849SmrgEOF
9719f606849Smrg
9729f606849Smrg      # Allow error messages only from the first compilation.
9739f606849Smrg      if test "$suppress_opt" = yes; then
9749f606849Smrg        suppress_output=' >/dev/null 2>&1'
9759f606849Smrg      fi
9769f606849Smrg    else
9779f606849Smrg      # No PIC object so indicate it doesn't exist in the libtool
9789f606849Smrg      # object file.
9799f606849Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
9809f606849Smrgpic_object=none
9819f606849Smrg
9829f606849SmrgEOF
9839f606849Smrg    fi
9849f606849Smrg
9859f606849Smrg    # Only build a position-dependent object if we build old libraries.
9869f606849Smrg    if test "$build_old_libs" = yes; then
9879f606849Smrg      if test "$pic_mode" != yes; then
9889f606849Smrg	# Don't build PIC code
9899f606849Smrg	command="$base_compile $qsrcfile"
9909f606849Smrg      else
9919f606849Smrg	command="$base_compile $qsrcfile $pic_flag"
9929f606849Smrg      fi
9939f606849Smrg      if test "$compiler_c_o" = yes; then
9949f606849Smrg	command="$command -o $obj"
9959f606849Smrg      fi
9969f606849Smrg
9979f606849Smrg      # Suppress compiler output if we already did a PIC compilation.
9989f606849Smrg      command="$command$suppress_output"
9999f606849Smrg      $run $rm "$obj" "$output_obj"
10009f606849Smrg      $show "$command"
10019f606849Smrg      if $run eval "$command"; then :
10029f606849Smrg      else
10039f606849Smrg	$run $rm $removelist
10049f606849Smrg	exit $EXIT_FAILURE
10059f606849Smrg      fi
10069f606849Smrg
10079f606849Smrg      if test "$need_locks" = warn &&
10089f606849Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
10099f606849Smrg	$echo "\
10109f606849Smrg*** ERROR, $lockfile contains:
10119f606849Smrg`cat $lockfile 2>/dev/null`
10129f606849Smrg
10139f606849Smrgbut it should contain:
10149f606849Smrg$srcfile
10159f606849Smrg
10169f606849SmrgThis indicates that another process is trying to use the same
10179f606849Smrgtemporary object file, and libtool could not work around it because
10189f606849Smrgyour compiler does not support \`-c' and \`-o' together.  If you
10199f606849Smrgrepeat this compilation, it may succeed, by chance, but you had better
10209f606849Smrgavoid parallel builds (make -j) in this platform, or get a better
10219f606849Smrgcompiler."
10229f606849Smrg
10239f606849Smrg	$run $rm $removelist
10249f606849Smrg	exit $EXIT_FAILURE
10259f606849Smrg      fi
10269f606849Smrg
10279f606849Smrg      # Just move the object if needed
10289f606849Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
10299f606849Smrg	$show "$mv $output_obj $obj"
10309f606849Smrg	if $run $mv $output_obj $obj; then :
10319f606849Smrg	else
10329f606849Smrg	  error=$?
10339f606849Smrg	  $run $rm $removelist
10349f606849Smrg	  exit $error
10359f606849Smrg	fi
10369f606849Smrg      fi
10379f606849Smrg
10389f606849Smrg      # Append the name of the non-PIC object the libtool object file.
10399f606849Smrg      # Only append if the libtool object file exists.
10409f606849Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
10419f606849Smrg# Name of the non-PIC object.
10429f606849Smrgnon_pic_object='$objname'
10439f606849Smrg
10449f606849SmrgEOF
10459f606849Smrg    else
10469f606849Smrg      # Append the name of the non-PIC object the libtool object file.
10479f606849Smrg      # Only append if the libtool object file exists.
10489f606849Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
10499f606849Smrg# Name of the non-PIC object.
10509f606849Smrgnon_pic_object=none
10519f606849Smrg
10529f606849SmrgEOF
10539f606849Smrg    fi
10549f606849Smrg
10559f606849Smrg    $run $mv "${libobj}T" "${libobj}"
10569f606849Smrg
10579f606849Smrg    # Unlock the critical section if it was locked
10589f606849Smrg    if test "$need_locks" != no; then
10599f606849Smrg      $run $rm "$lockfile"
10609f606849Smrg    fi
10619f606849Smrg
10629f606849Smrg    exit $EXIT_SUCCESS
10639f606849Smrg    ;;
10649f606849Smrg
10659f606849Smrg  # libtool link mode
10669f606849Smrg  link | relink)
10679f606849Smrg    modename="$modename: link"
10689f606849Smrg    case $host in
10699f606849Smrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
10709f606849Smrg      # It is impossible to link a dll without this setting, and
10719f606849Smrg      # we shouldn't force the makefile maintainer to figure out
10729f606849Smrg      # which system we are compiling for in order to pass an extra
10739f606849Smrg      # flag for every libtool invocation.
10749f606849Smrg      # allow_undefined=no
10759f606849Smrg
10769f606849Smrg      # FIXME: Unfortunately, there are problems with the above when trying
10779f606849Smrg      # to make a dll which has undefined symbols, in which case not
10789f606849Smrg      # even a static library is built.  For now, we need to specify
10799f606849Smrg      # -no-undefined on the libtool link line when we can be certain
10809f606849Smrg      # that all symbols are satisfied, otherwise we get a static library.
10819f606849Smrg      allow_undefined=yes
10829f606849Smrg      ;;
10839f606849Smrg    *)
10849f606849Smrg      allow_undefined=yes
10859f606849Smrg      ;;
10869f606849Smrg    esac
10879f606849Smrg    libtool_args="$nonopt"
10889f606849Smrg    base_compile="$nonopt $@"
10899f606849Smrg    compile_command="$nonopt"
10909f606849Smrg    finalize_command="$nonopt"
10919f606849Smrg
10929f606849Smrg    compile_rpath=
10939f606849Smrg    finalize_rpath=
10949f606849Smrg    compile_shlibpath=
10959f606849Smrg    finalize_shlibpath=
10969f606849Smrg    convenience=
10979f606849Smrg    old_convenience=
10989f606849Smrg    deplibs=
10999f606849Smrg    old_deplibs=
11009f606849Smrg    compiler_flags=
11019f606849Smrg    linker_flags=
11029f606849Smrg    dllsearchpath=
11039f606849Smrg    lib_search_path=`pwd`
11049f606849Smrg    inst_prefix_dir=
11059f606849Smrg
11069f606849Smrg    avoid_version=no
11079f606849Smrg    dlfiles=
11089f606849Smrg    dlprefiles=
11099f606849Smrg    dlself=no
11109f606849Smrg    export_dynamic=no
11119f606849Smrg    export_symbols=
11129f606849Smrg    export_symbols_regex=
11139f606849Smrg    generated=
11149f606849Smrg    libobjs=
11159f606849Smrg    ltlibs=
11169f606849Smrg    module=no
11179f606849Smrg    no_install=no
11189f606849Smrg    objs=
11199f606849Smrg    non_pic_objects=
11209f606849Smrg    notinst_path= # paths that contain not-installed libtool libraries
11219f606849Smrg    precious_files_regex=
11229f606849Smrg    prefer_static_libs=no
11239f606849Smrg    preload=no
11249f606849Smrg    prev=
11259f606849Smrg    prevarg=
11269f606849Smrg    release=
11279f606849Smrg    rpath=
11289f606849Smrg    xrpath=
11299f606849Smrg    perm_rpath=
11309f606849Smrg    temp_rpath=
11319f606849Smrg    thread_safe=no
11329f606849Smrg    vinfo=
11339f606849Smrg    vinfo_number=no
11349f606849Smrg
11359f606849Smrg    func_infer_tag $base_compile
11369f606849Smrg
11379f606849Smrg    # We need to know -static, to get the right output filenames.
11389f606849Smrg    for arg
11399f606849Smrg    do
11409f606849Smrg      case $arg in
11419f606849Smrg      -all-static | -static)
11429f606849Smrg	if test "X$arg" = "X-all-static"; then
11439f606849Smrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
11449f606849Smrg	    $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
11459f606849Smrg	  fi
11469f606849Smrg	  if test -n "$link_static_flag"; then
11479f606849Smrg	    dlopen_self=$dlopen_self_static
11489f606849Smrg	  fi
11499f606849Smrg	  prefer_static_libs=yes
11509f606849Smrg	else
11519f606849Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
11529f606849Smrg	    dlopen_self=$dlopen_self_static
11539f606849Smrg	  fi
11549f606849Smrg	  prefer_static_libs=built
11559f606849Smrg	fi
11569f606849Smrg	build_libtool_libs=no
11579f606849Smrg	build_old_libs=yes
11589f606849Smrg	break
11599f606849Smrg	;;
11609f606849Smrg      esac
11619f606849Smrg    done
11629f606849Smrg
11639f606849Smrg    # See if our shared archives depend on static archives.
11649f606849Smrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
11659f606849Smrg
11669f606849Smrg    # Go through the arguments, transforming them on the way.
11679f606849Smrg    while test "$#" -gt 0; do
11689f606849Smrg      arg="$1"
11699f606849Smrg      shift
11709f606849Smrg      case $arg in
11719f606849Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
11729f606849Smrg	qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test
11739f606849Smrg	;;
11749f606849Smrg      *) qarg=$arg ;;
11759f606849Smrg      esac
11769f606849Smrg      libtool_args="$libtool_args $qarg"
11779f606849Smrg
11789f606849Smrg      # If the previous option needs an argument, assign it.
11799f606849Smrg      if test -n "$prev"; then
11809f606849Smrg	case $prev in
11819f606849Smrg	output)
11829f606849Smrg	  compile_command="$compile_command @OUTPUT@"
11839f606849Smrg	  finalize_command="$finalize_command @OUTPUT@"
11849f606849Smrg	  ;;
11859f606849Smrg	esac
11869f606849Smrg
11879f606849Smrg	case $prev in
11889f606849Smrg	dlfiles|dlprefiles)
11899f606849Smrg	  if test "$preload" = no; then
11909f606849Smrg	    # Add the symbol object into the linking commands.
11919f606849Smrg	    compile_command="$compile_command @SYMFILE@"
11929f606849Smrg	    finalize_command="$finalize_command @SYMFILE@"
11939f606849Smrg	    preload=yes
11949f606849Smrg	  fi
11959f606849Smrg	  case $arg in
11969f606849Smrg	  *.la | *.lo) ;;  # We handle these cases below.
11979f606849Smrg	  force)
11989f606849Smrg	    if test "$dlself" = no; then
11999f606849Smrg	      dlself=needless
12009f606849Smrg	      export_dynamic=yes
12019f606849Smrg	    fi
12029f606849Smrg	    prev=
12039f606849Smrg	    continue
12049f606849Smrg	    ;;
12059f606849Smrg	  self)
12069f606849Smrg	    if test "$prev" = dlprefiles; then
12079f606849Smrg	      dlself=yes
12089f606849Smrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
12099f606849Smrg	      dlself=yes
12109f606849Smrg	    else
12119f606849Smrg	      dlself=needless
12129f606849Smrg	      export_dynamic=yes
12139f606849Smrg	    fi
12149f606849Smrg	    prev=
12159f606849Smrg	    continue
12169f606849Smrg	    ;;
12179f606849Smrg	  *)
12189f606849Smrg	    if test "$prev" = dlfiles; then
12199f606849Smrg	      dlfiles="$dlfiles $arg"
12209f606849Smrg	    else
12219f606849Smrg	      dlprefiles="$dlprefiles $arg"
12229f606849Smrg	    fi
12239f606849Smrg	    prev=
12249f606849Smrg	    continue
12259f606849Smrg	    ;;
12269f606849Smrg	  esac
12279f606849Smrg	  ;;
12289f606849Smrg	expsyms)
12299f606849Smrg	  export_symbols="$arg"
12309f606849Smrg	  if test ! -f "$arg"; then
12319f606849Smrg	    $echo "$modename: symbol file \`$arg' does not exist"
12329f606849Smrg	    exit $EXIT_FAILURE
12339f606849Smrg	  fi
12349f606849Smrg	  prev=
12359f606849Smrg	  continue
12369f606849Smrg	  ;;
12379f606849Smrg	expsyms_regex)
12389f606849Smrg	  export_symbols_regex="$arg"
12399f606849Smrg	  prev=
12409f606849Smrg	  continue
12419f606849Smrg	  ;;
12429f606849Smrg	inst_prefix)
12439f606849Smrg	  inst_prefix_dir="$arg"
12449f606849Smrg	  prev=
12459f606849Smrg	  continue
12469f606849Smrg	  ;;
12479f606849Smrg	precious_regex)
12489f606849Smrg	  precious_files_regex="$arg"
12499f606849Smrg	  prev=
12509f606849Smrg	  continue
12519f606849Smrg	  ;;
12529f606849Smrg	release)
12539f606849Smrg	  release="-$arg"
12549f606849Smrg	  prev=
12559f606849Smrg	  continue
12569f606849Smrg	  ;;
12579f606849Smrg	objectlist)
12589f606849Smrg	  if test -f "$arg"; then
12599f606849Smrg	    save_arg=$arg
12609f606849Smrg	    moreargs=
12619f606849Smrg	    for fil in `cat $save_arg`
12629f606849Smrg	    do
12639f606849Smrg#	      moreargs="$moreargs $fil"
12649f606849Smrg	      arg=$fil
12659f606849Smrg	      # A libtool-controlled object.
12669f606849Smrg
12679f606849Smrg	      # Check to see that this really is a libtool object.
12689f606849Smrg	      if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
12699f606849Smrg		pic_object=
12709f606849Smrg		non_pic_object=
12719f606849Smrg
12729f606849Smrg		# Read the .lo file
12739f606849Smrg		# If there is no directory component, then add one.
12749f606849Smrg		case $arg in
12759f606849Smrg		*/* | *\\*) . $arg ;;
12769f606849Smrg		*) . ./$arg ;;
12779f606849Smrg		esac
12789f606849Smrg
12799f606849Smrg		if test -z "$pic_object" || \
12809f606849Smrg		   test -z "$non_pic_object" ||
12819f606849Smrg		   test "$pic_object" = none && \
12829f606849Smrg		   test "$non_pic_object" = none; then
12839f606849Smrg		  $echo "$modename: cannot find name of object for \`$arg'" 1>&2
12849f606849Smrg		  exit $EXIT_FAILURE
12859f606849Smrg		fi
12869f606849Smrg
12879f606849Smrg		# Extract subdirectory from the argument.
12889f606849Smrg		xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
12899f606849Smrg		if test "X$xdir" = "X$arg"; then
12909f606849Smrg		  xdir=
12919f606849Smrg		else
12929f606849Smrg		  xdir="$xdir/"
12939f606849Smrg		fi
12949f606849Smrg
12959f606849Smrg		if test "$pic_object" != none; then
12969f606849Smrg		  # Prepend the subdirectory the object is found in.
12979f606849Smrg		  pic_object="$xdir$pic_object"
12989f606849Smrg
12999f606849Smrg		  if test "$prev" = dlfiles; then
13009f606849Smrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
13019f606849Smrg		      dlfiles="$dlfiles $pic_object"
13029f606849Smrg		      prev=
13039f606849Smrg		      continue
13049f606849Smrg		    else
13059f606849Smrg		      # If libtool objects are unsupported, then we need to preload.
13069f606849Smrg		      prev=dlprefiles
13079f606849Smrg		    fi
13089f606849Smrg		  fi
13099f606849Smrg
13109f606849Smrg		  # CHECK ME:  I think I busted this.  -Ossama
13119f606849Smrg		  if test "$prev" = dlprefiles; then
13129f606849Smrg		    # Preload the old-style object.
13139f606849Smrg		    dlprefiles="$dlprefiles $pic_object"
13149f606849Smrg		    prev=
13159f606849Smrg		  fi
13169f606849Smrg
13179f606849Smrg		  # A PIC object.
13189f606849Smrg		  libobjs="$libobjs $pic_object"
13199f606849Smrg		  arg="$pic_object"
13209f606849Smrg		fi
13219f606849Smrg
13229f606849Smrg		# Non-PIC object.
13239f606849Smrg		if test "$non_pic_object" != none; then
13249f606849Smrg		  # Prepend the subdirectory the object is found in.
13259f606849Smrg		  non_pic_object="$xdir$non_pic_object"
13269f606849Smrg
13279f606849Smrg		  # A standard non-PIC object
13289f606849Smrg		  non_pic_objects="$non_pic_objects $non_pic_object"
13299f606849Smrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
13309f606849Smrg		    arg="$non_pic_object"
13319f606849Smrg		  fi
13329f606849Smrg		else
13339f606849Smrg		  # If the PIC object exists, use it instead.
13349f606849Smrg		  # $xdir was prepended to $pic_object above.
13359f606849Smrg		  non_pic_object="$pic_object"
13369f606849Smrg		  non_pic_objects="$non_pic_objects $non_pic_object"
13379f606849Smrg		fi
13389f606849Smrg	      else
13399f606849Smrg		# Only an error if not doing a dry-run.
13409f606849Smrg		if test -z "$run"; then
13419f606849Smrg		  $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
13429f606849Smrg		  exit $EXIT_FAILURE
13439f606849Smrg		else
13449f606849Smrg		  # Dry-run case.
13459f606849Smrg
13469f606849Smrg		  # Extract subdirectory from the argument.
13479f606849Smrg		  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
13489f606849Smrg		  if test "X$xdir" = "X$arg"; then
13499f606849Smrg		    xdir=
13509f606849Smrg		  else
13519f606849Smrg		    xdir="$xdir/"
13529f606849Smrg		  fi
13539f606849Smrg
13549f606849Smrg		  pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
13559f606849Smrg		  non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
13569f606849Smrg		  libobjs="$libobjs $pic_object"
13579f606849Smrg		  non_pic_objects="$non_pic_objects $non_pic_object"
13589f606849Smrg		fi
13599f606849Smrg	      fi
13609f606849Smrg	    done
13619f606849Smrg	  else
13629f606849Smrg	    $echo "$modename: link input file \`$save_arg' does not exist"
13639f606849Smrg	    exit $EXIT_FAILURE
13649f606849Smrg	  fi
13659f606849Smrg	  arg=$save_arg
13669f606849Smrg	  prev=
13679f606849Smrg	  continue
13689f606849Smrg	  ;;
13699f606849Smrg	rpath | xrpath)
13709f606849Smrg	  # We need an absolute path.
13719f606849Smrg	  case $arg in
13729f606849Smrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
13739f606849Smrg	  *)
13749f606849Smrg	    $echo "$modename: only absolute run-paths are allowed" 1>&2
13759f606849Smrg	    exit $EXIT_FAILURE
13769f606849Smrg	    ;;
13779f606849Smrg	  esac
13789f606849Smrg	  if test "$prev" = rpath; then
13799f606849Smrg	    case "$rpath " in
13809f606849Smrg	    *" $arg "*) ;;
13819f606849Smrg	    *) rpath="$rpath $arg" ;;
13829f606849Smrg	    esac
13839f606849Smrg	  else
13849f606849Smrg	    case "$xrpath " in
13859f606849Smrg	    *" $arg "*) ;;
13869f606849Smrg	    *) xrpath="$xrpath $arg" ;;
13879f606849Smrg	    esac
13889f606849Smrg	  fi
13899f606849Smrg	  prev=
13909f606849Smrg	  continue
13919f606849Smrg	  ;;
13929f606849Smrg	xcompiler)
13939f606849Smrg	  compiler_flags="$compiler_flags $qarg"
13949f606849Smrg	  prev=
13959f606849Smrg	  compile_command="$compile_command $qarg"
13969f606849Smrg	  finalize_command="$finalize_command $qarg"
13979f606849Smrg	  continue
13989f606849Smrg	  ;;
13999f606849Smrg	xlinker)
14009f606849Smrg	  linker_flags="$linker_flags $qarg"
14019f606849Smrg	  compiler_flags="$compiler_flags $wl$qarg"
14029f606849Smrg	  prev=
14039f606849Smrg	  compile_command="$compile_command $wl$qarg"
14049f606849Smrg	  finalize_command="$finalize_command $wl$qarg"
14059f606849Smrg	  continue
14069f606849Smrg	  ;;
14079f606849Smrg	xcclinker)
14089f606849Smrg	  linker_flags="$linker_flags $qarg"
14099f606849Smrg	  compiler_flags="$compiler_flags $qarg"
14109f606849Smrg	  prev=
14119f606849Smrg	  compile_command="$compile_command $qarg"
14129f606849Smrg	  finalize_command="$finalize_command $qarg"
14139f606849Smrg	  continue
14149f606849Smrg	  ;;
14159f606849Smrg	shrext)
14169f606849Smrg  	  shrext_cmds="$arg"
14179f606849Smrg	  prev=
14189f606849Smrg	  continue
14199f606849Smrg	  ;;
14209f606849Smrg	darwin_framework|darwin_framework_skip)
14219f606849Smrg	  test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg"
14229f606849Smrg	  compile_command="$compile_command $arg"
14239f606849Smrg	  finalize_command="$finalize_command $arg"
14249f606849Smrg	  prev=
14259f606849Smrg	  continue
14269f606849Smrg	  ;;
14279f606849Smrg	*)
14289f606849Smrg	  eval "$prev=\"\$arg\""
14299f606849Smrg	  prev=
14309f606849Smrg	  continue
14319f606849Smrg	  ;;
14329f606849Smrg	esac
14339f606849Smrg      fi # test -n "$prev"
14349f606849Smrg
14359f606849Smrg      prevarg="$arg"
14369f606849Smrg
14379f606849Smrg      case $arg in
14389f606849Smrg      -all-static)
14399f606849Smrg	if test -n "$link_static_flag"; then
14409f606849Smrg	  compile_command="$compile_command $link_static_flag"
14419f606849Smrg	  finalize_command="$finalize_command $link_static_flag"
14429f606849Smrg	fi
14439f606849Smrg	continue
14449f606849Smrg	;;
14459f606849Smrg
14469f606849Smrg      -allow-undefined)
14479f606849Smrg	# FIXME: remove this flag sometime in the future.
14489f606849Smrg	$echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
14499f606849Smrg	continue
14509f606849Smrg	;;
14519f606849Smrg
14529f606849Smrg      -avoid-version)
14539f606849Smrg	avoid_version=yes
14549f606849Smrg	continue
14559f606849Smrg	;;
14569f606849Smrg
14579f606849Smrg      -dlopen)
14589f606849Smrg	prev=dlfiles
14599f606849Smrg	continue
14609f606849Smrg	;;
14619f606849Smrg
14629f606849Smrg      -dlpreopen)
14639f606849Smrg	prev=dlprefiles
14649f606849Smrg	continue
14659f606849Smrg	;;
14669f606849Smrg
14679f606849Smrg      -export-dynamic)
14689f606849Smrg	export_dynamic=yes
14699f606849Smrg	continue
14709f606849Smrg	;;
14719f606849Smrg
14729f606849Smrg      -export-symbols | -export-symbols-regex)
14739f606849Smrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
14749f606849Smrg	  $echo "$modename: more than one -exported-symbols argument is not allowed"
14759f606849Smrg	  exit $EXIT_FAILURE
14769f606849Smrg	fi
14779f606849Smrg	if test "X$arg" = "X-export-symbols"; then
14789f606849Smrg	  prev=expsyms
14799f606849Smrg	else
14809f606849Smrg	  prev=expsyms_regex
14819f606849Smrg	fi
14829f606849Smrg	continue
14839f606849Smrg	;;
14849f606849Smrg
14859f606849Smrg      -framework|-arch|-isysroot)
14869f606849Smrg	case " $CC " in
14879f606849Smrg	  *" ${arg} ${1} "* | *" ${arg}	${1} "*) 
14889f606849Smrg		prev=darwin_framework_skip ;;
14899f606849Smrg	  *) compiler_flags="$compiler_flags $arg"
14909f606849Smrg	     prev=darwin_framework ;;
14919f606849Smrg	esac
14929f606849Smrg	compile_command="$compile_command $arg"
14939f606849Smrg	finalize_command="$finalize_command $arg"
14949f606849Smrg	continue
14959f606849Smrg	;;
14969f606849Smrg
14979f606849Smrg      -inst-prefix-dir)
14989f606849Smrg	prev=inst_prefix
14999f606849Smrg	continue
15009f606849Smrg	;;
15019f606849Smrg
15029f606849Smrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
15039f606849Smrg      # so, if we see these flags be careful not to treat them like -L
15049f606849Smrg      -L[A-Z][A-Z]*:*)
15059f606849Smrg	case $with_gcc/$host in
15069f606849Smrg	no/*-*-irix* | /*-*-irix*)
15079f606849Smrg	  compile_command="$compile_command $arg"
15089f606849Smrg	  finalize_command="$finalize_command $arg"
15099f606849Smrg	  ;;
15109f606849Smrg	esac
15119f606849Smrg	continue
15129f606849Smrg	;;
15139f606849Smrg
15149f606849Smrg      -L*)
15159f606849Smrg	dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
15169f606849Smrg	# We need an absolute path.
15179f606849Smrg	case $dir in
15189f606849Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
15199f606849Smrg	*)
15209f606849Smrg	  absdir=`cd "$dir" && pwd`
15219f606849Smrg	  if test -z "$absdir"; then
15229f606849Smrg	    $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
15239f606849Smrg	    absdir="$dir"
15249f606849Smrg	    notinst_path="$notinst_path $dir"
15259f606849Smrg	  fi
15269f606849Smrg	  dir="$absdir"
15279f606849Smrg	  ;;
15289f606849Smrg	esac
15299f606849Smrg	case "$deplibs " in
15309f606849Smrg	*" -L$dir "*) ;;
15319f606849Smrg	*)
15329f606849Smrg	  deplibs="$deplibs -L$dir"
15339f606849Smrg	  lib_search_path="$lib_search_path $dir"
15349f606849Smrg	  ;;
15359f606849Smrg	esac
15369f606849Smrg	case $host in
15379f606849Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
15389f606849Smrg	  testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'`
15399f606849Smrg	  case :$dllsearchpath: in
15409f606849Smrg	  *":$dir:"*) ;;
15419f606849Smrg	  *) dllsearchpath="$dllsearchpath:$dir";;
15429f606849Smrg	  esac
15439f606849Smrg	  case :$dllsearchpath: in
15449f606849Smrg	  *":$testbindir:"*) ;;
15459f606849Smrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
15469f606849Smrg	  esac
15479f606849Smrg	  ;;
15489f606849Smrg	esac
15499f606849Smrg	continue
15509f606849Smrg	;;
15519f606849Smrg
15529f606849Smrg      -l*)
15539f606849Smrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
15549f606849Smrg	  case $host in
15559f606849Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*)
15569f606849Smrg	    # These systems don't actually have a C or math library (as such)
15579f606849Smrg	    continue
15589f606849Smrg	    ;;
15599f606849Smrg	  *-*-os2*)
15609f606849Smrg	    # These systems don't actually have a C library (as such)
15619f606849Smrg	    test "X$arg" = "X-lc" && continue
15629f606849Smrg	    ;;
15639f606849Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
15649f606849Smrg	    # Do not include libc due to us having libc/libc_r.
15659f606849Smrg	    test "X$arg" = "X-lc" && continue
15669f606849Smrg	    ;;
15679f606849Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
15689f606849Smrg	    # Rhapsody C and math libraries are in the System framework
15699f606849Smrg	    deplibs="$deplibs -framework System"
15709f606849Smrg	    continue
15719f606849Smrg	    ;;
15729f606849Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
15739f606849Smrg	    # Causes problems with __ctype
15749f606849Smrg	    test "X$arg" = "X-lc" && continue
15759f606849Smrg	    ;;
15769f606849Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
15779f606849Smrg	    # Compiler inserts libc in the correct place for threads to work
15789f606849Smrg	    test "X$arg" = "X-lc" && continue
15799f606849Smrg	    ;;
15809f606849Smrg	  esac
15819f606849Smrg	elif test "X$arg" = "X-lc_r"; then
15829f606849Smrg	 case $host in
15839f606849Smrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
15849f606849Smrg	   # Do not include libc_r directly, use -pthread flag.
15859f606849Smrg	   continue
15869f606849Smrg	   ;;
15879f606849Smrg	 esac
15889f606849Smrg	fi
15899f606849Smrg	deplibs="$deplibs $arg"
15909f606849Smrg	continue
15919f606849Smrg	;;
15929f606849Smrg
15939f606849Smrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
15949f606849Smrg      # classes, name mangling, and exception handling.
15959f606849Smrg      -model)
15969f606849Smrg	compile_command="$compile_command $arg"
15979f606849Smrg	compiler_flags="$compiler_flags $arg"
15989f606849Smrg	finalize_command="$finalize_command $arg"
15999f606849Smrg	prev=xcompiler
16009f606849Smrg	continue
16019f606849Smrg	;;
16029f606849Smrg
16039f606849Smrg     -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
16049f606849Smrg	compiler_flags="$compiler_flags $arg"
16059f606849Smrg	compile_command="$compile_command $arg"
16069f606849Smrg	finalize_command="$finalize_command $arg"
16079f606849Smrg	continue
16089f606849Smrg	;;
16099f606849Smrg
16109f606849Smrg      -module)
16119f606849Smrg	module=yes
16129f606849Smrg	continue
16139f606849Smrg	;;
16149f606849Smrg
16159f606849Smrg      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
16169f606849Smrg      # -r[0-9][0-9]* specifies the processor on the SGI compiler
16179f606849Smrg      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
16189f606849Smrg      # +DA*, +DD* enable 64-bit mode on the HP compiler
16199f606849Smrg      # -q* pass through compiler args for the IBM compiler
16209f606849Smrg      # -m* pass through architecture-specific compiler args for GCC
16219f606849Smrg      # -m*, -t[45]*, -txscale* pass through architecture-specific
16229f606849Smrg      # compiler args for GCC
16239f606849Smrg      # -pg pass through profiling flag for GCC
16249f606849Smrg      # @file GCC response files
16259f606849Smrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*|-pg| \
16269f606849Smrg      -t[45]*|-txscale*|@*)
16279f606849Smrg
16289f606849Smrg	# Unknown arguments in both finalize_command and compile_command need
16299f606849Smrg	# to be aesthetically quoted because they are evaled later.
16309f606849Smrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
16319f606849Smrg	case $arg in
16329f606849Smrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
16339f606849Smrg	  arg="\"$arg\""
16349f606849Smrg	  ;;
16359f606849Smrg	esac
16369f606849Smrg        compile_command="$compile_command $arg"
16379f606849Smrg        finalize_command="$finalize_command $arg"
16389f606849Smrg        compiler_flags="$compiler_flags $arg"
16399f606849Smrg        continue
16409f606849Smrg        ;;
16419f606849Smrg
16429f606849Smrg      -shrext)
16439f606849Smrg	prev=shrext
16449f606849Smrg	continue
16459f606849Smrg	;;
16469f606849Smrg
16479f606849Smrg      -no-fast-install)
16489f606849Smrg	fast_install=no
16499f606849Smrg	continue
16509f606849Smrg	;;
16519f606849Smrg
16529f606849Smrg      -no-install)
16539f606849Smrg	case $host in
16549f606849Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
16559f606849Smrg	  # The PATH hackery in wrapper scripts is required on Windows
16569f606849Smrg	  # in order for the loader to find any dlls it needs.
16579f606849Smrg	  $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2
16589f606849Smrg	  $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2
16599f606849Smrg	  fast_install=no
16609f606849Smrg	  ;;
16619f606849Smrg	*) no_install=yes ;;
16629f606849Smrg	esac
16639f606849Smrg	continue
16649f606849Smrg	;;
16659f606849Smrg
16669f606849Smrg      -no-undefined)
16679f606849Smrg	allow_undefined=no
16689f606849Smrg	continue
16699f606849Smrg	;;
16709f606849Smrg
16719f606849Smrg      -objectlist)
16729f606849Smrg	prev=objectlist
16739f606849Smrg	continue
16749f606849Smrg	;;
16759f606849Smrg
16769f606849Smrg      -o) prev=output ;;
16779f606849Smrg
16789f606849Smrg      -precious-files-regex)
16799f606849Smrg	prev=precious_regex
16809f606849Smrg	continue
16819f606849Smrg	;;
16829f606849Smrg
16839f606849Smrg      -release)
16849f606849Smrg	prev=release
16859f606849Smrg	continue
16869f606849Smrg	;;
16879f606849Smrg
16889f606849Smrg      -rpath)
16899f606849Smrg	prev=rpath
16909f606849Smrg	continue
16919f606849Smrg	;;
16929f606849Smrg
16939f606849Smrg      -R)
16949f606849Smrg	prev=xrpath
16959f606849Smrg	continue
16969f606849Smrg	;;
16979f606849Smrg
16989f606849Smrg      -R*)
16999f606849Smrg	dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
17009f606849Smrg	# We need an absolute path.
17019f606849Smrg	case $dir in
17029f606849Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
17039f606849Smrg	*)
17049f606849Smrg	  $echo "$modename: only absolute run-paths are allowed" 1>&2
17059f606849Smrg	  exit $EXIT_FAILURE
17069f606849Smrg	  ;;
17079f606849Smrg	esac
17089f606849Smrg	case "$xrpath " in
17099f606849Smrg	*" $dir "*) ;;
17109f606849Smrg	*) xrpath="$xrpath $dir" ;;
17119f606849Smrg	esac
17129f606849Smrg	continue
17139f606849Smrg	;;
17149f606849Smrg
17159f606849Smrg      -static)
17169f606849Smrg	# The effects of -static are defined in a previous loop.
17179f606849Smrg	# We used to do the same as -all-static on platforms that
17189f606849Smrg	# didn't have a PIC flag, but the assumption that the effects
17199f606849Smrg	# would be equivalent was wrong.  It would break on at least
17209f606849Smrg	# Digital Unix and AIX.
17219f606849Smrg	continue
17229f606849Smrg	;;
17239f606849Smrg
17249f606849Smrg      -thread-safe)
17259f606849Smrg	thread_safe=yes
17269f606849Smrg	continue
17279f606849Smrg	;;
17289f606849Smrg
17299f606849Smrg      -version-info)
17309f606849Smrg	prev=vinfo
17319f606849Smrg	continue
17329f606849Smrg	;;
17339f606849Smrg      -version-number)
17349f606849Smrg	prev=vinfo
17359f606849Smrg	vinfo_number=yes
17369f606849Smrg	continue
17379f606849Smrg	;;
17389f606849Smrg
17399f606849Smrg      -Wc,*)
17409f606849Smrg	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'`
17419f606849Smrg	arg=
17429f606849Smrg	save_ifs="$IFS"; IFS=','
17439f606849Smrg	for flag in $args; do
17449f606849Smrg	  IFS="$save_ifs"
17459f606849Smrg	  case $flag in
17469f606849Smrg	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
17479f606849Smrg	    flag="\"$flag\""
17489f606849Smrg	    ;;
17499f606849Smrg	  esac
17509f606849Smrg	  arg="$arg $wl$flag"
17519f606849Smrg	  compiler_flags="$compiler_flags $flag"
17529f606849Smrg	done
17539f606849Smrg	IFS="$save_ifs"
17549f606849Smrg	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
17559f606849Smrg	;;
17569f606849Smrg
17579f606849Smrg      -Wl,*)
17589f606849Smrg	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'`
17599f606849Smrg	arg=
17609f606849Smrg	save_ifs="$IFS"; IFS=','
17619f606849Smrg	for flag in $args; do
17629f606849Smrg	  IFS="$save_ifs"
17639f606849Smrg	  case $flag in
17649f606849Smrg	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
17659f606849Smrg	    flag="\"$flag\""
17669f606849Smrg	    ;;
17679f606849Smrg	  esac
17689f606849Smrg	  arg="$arg $wl$flag"
17699f606849Smrg	  compiler_flags="$compiler_flags $wl$flag"
17709f606849Smrg	  linker_flags="$linker_flags $flag"
17719f606849Smrg	done
17729f606849Smrg	IFS="$save_ifs"
17739f606849Smrg	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
17749f606849Smrg	;;
17759f606849Smrg
17769f606849Smrg      -Xcompiler)
17779f606849Smrg	prev=xcompiler
17789f606849Smrg	continue
17799f606849Smrg	;;
17809f606849Smrg
17819f606849Smrg      -Xlinker)
17829f606849Smrg	prev=xlinker
17839f606849Smrg	continue
17849f606849Smrg	;;
17859f606849Smrg
17869f606849Smrg      -XCClinker)
17879f606849Smrg	prev=xcclinker
17889f606849Smrg	continue
17899f606849Smrg	;;
17909f606849Smrg
17919f606849Smrg      # Some other compiler flag.
17929f606849Smrg      -* | +*)
17939f606849Smrg	# Unknown arguments in both finalize_command and compile_command need
17949f606849Smrg	# to be aesthetically quoted because they are evaled later.
17959f606849Smrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
17969f606849Smrg	case $arg in
17979f606849Smrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
17989f606849Smrg	  arg="\"$arg\""
17999f606849Smrg	  ;;
18009f606849Smrg	esac
18019f606849Smrg	;;
18029f606849Smrg
18039f606849Smrg      *.$objext)
18049f606849Smrg	# A standard object.
18059f606849Smrg	objs="$objs $arg"
18069f606849Smrg	;;
18079f606849Smrg
18089f606849Smrg      *.lo)
18099f606849Smrg	# A libtool-controlled object.
18109f606849Smrg
18119f606849Smrg	# Check to see that this really is a libtool object.
18129f606849Smrg	if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
18139f606849Smrg	  pic_object=
18149f606849Smrg	  non_pic_object=
18159f606849Smrg
18169f606849Smrg	  # Read the .lo file
18179f606849Smrg	  # If there is no directory component, then add one.
18189f606849Smrg	  case $arg in
18199f606849Smrg	  */* | *\\*) . $arg ;;
18209f606849Smrg	  *) . ./$arg ;;
18219f606849Smrg	  esac
18229f606849Smrg
18239f606849Smrg	  if test -z "$pic_object" || \
18249f606849Smrg	     test -z "$non_pic_object" ||
18259f606849Smrg	     test "$pic_object" = none && \
18269f606849Smrg	     test "$non_pic_object" = none; then
18279f606849Smrg	    $echo "$modename: cannot find name of object for \`$arg'" 1>&2
18289f606849Smrg	    exit $EXIT_FAILURE
18299f606849Smrg	  fi
18309f606849Smrg
18319f606849Smrg	  # Extract subdirectory from the argument.
18329f606849Smrg	  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
18339f606849Smrg	  if test "X$xdir" = "X$arg"; then
18349f606849Smrg	    xdir=
18359f606849Smrg 	  else
18369f606849Smrg	    xdir="$xdir/"
18379f606849Smrg	  fi
18389f606849Smrg
18399f606849Smrg	  if test "$pic_object" != none; then
18409f606849Smrg	    # Prepend the subdirectory the object is found in.
18419f606849Smrg	    pic_object="$xdir$pic_object"
18429f606849Smrg
18439f606849Smrg	    if test "$prev" = dlfiles; then
18449f606849Smrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
18459f606849Smrg		dlfiles="$dlfiles $pic_object"
18469f606849Smrg		prev=
18479f606849Smrg		continue
18489f606849Smrg	      else
18499f606849Smrg		# If libtool objects are unsupported, then we need to preload.
18509f606849Smrg		prev=dlprefiles
18519f606849Smrg	      fi
18529f606849Smrg	    fi
18539f606849Smrg
18549f606849Smrg	    # CHECK ME:  I think I busted this.  -Ossama
18559f606849Smrg	    if test "$prev" = dlprefiles; then
18569f606849Smrg	      # Preload the old-style object.
18579f606849Smrg	      dlprefiles="$dlprefiles $pic_object"
18589f606849Smrg	      prev=
18599f606849Smrg	    fi
18609f606849Smrg
18619f606849Smrg	    # A PIC object.
18629f606849Smrg	    libobjs="$libobjs $pic_object"
18639f606849Smrg	    arg="$pic_object"
18649f606849Smrg	  fi
18659f606849Smrg
18669f606849Smrg	  # Non-PIC object.
18679f606849Smrg	  if test "$non_pic_object" != none; then
18689f606849Smrg	    # Prepend the subdirectory the object is found in.
18699f606849Smrg	    non_pic_object="$xdir$non_pic_object"
18709f606849Smrg
18719f606849Smrg	    # A standard non-PIC object
18729f606849Smrg	    non_pic_objects="$non_pic_objects $non_pic_object"
18739f606849Smrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
18749f606849Smrg	      arg="$non_pic_object"
18759f606849Smrg	    fi
18769f606849Smrg	  else
18779f606849Smrg	    # If the PIC object exists, use it instead.
18789f606849Smrg	    # $xdir was prepended to $pic_object above.
18799f606849Smrg	    non_pic_object="$pic_object"
18809f606849Smrg	    non_pic_objects="$non_pic_objects $non_pic_object"
18819f606849Smrg	  fi
18829f606849Smrg	else
18839f606849Smrg	  # Only an error if not doing a dry-run.
18849f606849Smrg	  if test -z "$run"; then
18859f606849Smrg	    $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
18869f606849Smrg	    exit $EXIT_FAILURE
18879f606849Smrg	  else
18889f606849Smrg	    # Dry-run case.
18899f606849Smrg
18909f606849Smrg	    # Extract subdirectory from the argument.
18919f606849Smrg	    xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
18929f606849Smrg	    if test "X$xdir" = "X$arg"; then
18939f606849Smrg	      xdir=
18949f606849Smrg	    else
18959f606849Smrg	      xdir="$xdir/"
18969f606849Smrg	    fi
18979f606849Smrg
18989f606849Smrg	    pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
18999f606849Smrg	    non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
19009f606849Smrg	    libobjs="$libobjs $pic_object"
19019f606849Smrg	    non_pic_objects="$non_pic_objects $non_pic_object"
19029f606849Smrg	  fi
19039f606849Smrg	fi
19049f606849Smrg	;;
19059f606849Smrg
19069f606849Smrg      *.$libext)
19079f606849Smrg	# An archive.
19089f606849Smrg	deplibs="$deplibs $arg"
19099f606849Smrg	old_deplibs="$old_deplibs $arg"
19109f606849Smrg	continue
19119f606849Smrg	;;
19129f606849Smrg
19139f606849Smrg      *.la)
19149f606849Smrg	# A libtool-controlled library.
19159f606849Smrg
19169f606849Smrg	if test "$prev" = dlfiles; then
19179f606849Smrg	  # This library was specified with -dlopen.
19189f606849Smrg	  dlfiles="$dlfiles $arg"
19199f606849Smrg	  prev=
19209f606849Smrg	elif test "$prev" = dlprefiles; then
19219f606849Smrg	  # The library was specified with -dlpreopen.
19229f606849Smrg	  dlprefiles="$dlprefiles $arg"
19239f606849Smrg	  prev=
19249f606849Smrg	else
19259f606849Smrg	  deplibs="$deplibs $arg"
19269f606849Smrg	fi
19279f606849Smrg	continue
19289f606849Smrg	;;
19299f606849Smrg
19309f606849Smrg      # Some other compiler argument.
19319f606849Smrg      *)
19329f606849Smrg	# Unknown arguments in both finalize_command and compile_command need
19339f606849Smrg	# to be aesthetically quoted because they are evaled later.
19349f606849Smrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
19359f606849Smrg	case $arg in
19369f606849Smrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
19379f606849Smrg	  arg="\"$arg\""
19389f606849Smrg	  ;;
19399f606849Smrg	esac
19409f606849Smrg	;;
19419f606849Smrg      esac # arg
19429f606849Smrg
19439f606849Smrg      # Now actually substitute the argument into the commands.
19449f606849Smrg      if test -n "$arg"; then
19459f606849Smrg	compile_command="$compile_command $arg"
19469f606849Smrg	finalize_command="$finalize_command $arg"
19479f606849Smrg      fi
19489f606849Smrg    done # argument parsing loop
19499f606849Smrg
19509f606849Smrg    if test -n "$prev"; then
19519f606849Smrg      $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
19529f606849Smrg      $echo "$help" 1>&2
19539f606849Smrg      exit $EXIT_FAILURE
19549f606849Smrg    fi
19559f606849Smrg
19569f606849Smrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
19579f606849Smrg      eval arg=\"$export_dynamic_flag_spec\"
19589f606849Smrg      compile_command="$compile_command $arg"
19599f606849Smrg      finalize_command="$finalize_command $arg"
19609f606849Smrg    fi
19619f606849Smrg
19629f606849Smrg    oldlibs=
19639f606849Smrg    # calculate the name of the file, without its directory
19649f606849Smrg    outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
19659f606849Smrg    libobjs_save="$libobjs"
19669f606849Smrg
19679f606849Smrg    if test -n "$shlibpath_var"; then
19689f606849Smrg      # get the directories listed in $shlibpath_var
19699f606849Smrg      eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
19709f606849Smrg    else
19719f606849Smrg      shlib_search_path=
19729f606849Smrg    fi
19739f606849Smrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
19749f606849Smrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
19759f606849Smrg
19769f606849Smrg    output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
19779f606849Smrg    if test "X$output_objdir" = "X$output"; then
19789f606849Smrg      output_objdir="$objdir"
19799f606849Smrg    else
19809f606849Smrg      output_objdir="$output_objdir/$objdir"
19819f606849Smrg    fi
19829f606849Smrg    # Create the object directory.
19839f606849Smrg    if test ! -d "$output_objdir"; then
19849f606849Smrg      $show "$mkdir $output_objdir"
19859f606849Smrg      $run $mkdir $output_objdir
19869f606849Smrg      exit_status=$?
19879f606849Smrg      if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then
19889f606849Smrg	exit $exit_status
19899f606849Smrg      fi
19909f606849Smrg    fi
19919f606849Smrg
19929f606849Smrg    # Determine the type of output
19939f606849Smrg    case $output in
19949f606849Smrg    "")
19959f606849Smrg      $echo "$modename: you must specify an output file" 1>&2
19969f606849Smrg      $echo "$help" 1>&2
19979f606849Smrg      exit $EXIT_FAILURE
19989f606849Smrg      ;;
19999f606849Smrg    *.$libext) linkmode=oldlib ;;
20009f606849Smrg    *.lo | *.$objext) linkmode=obj ;;
20019f606849Smrg    *.la) linkmode=lib ;;
20029f606849Smrg    *) linkmode=prog ;; # Anything else should be a program.
20039f606849Smrg    esac
20049f606849Smrg
20059f606849Smrg    case $host in
20069f606849Smrg    *cygwin* | *mingw* | *pw32*)
20079f606849Smrg      # don't eliminate duplications in $postdeps and $predeps
20089f606849Smrg      duplicate_compiler_generated_deps=yes
20099f606849Smrg      ;;
20109f606849Smrg    *)
20119f606849Smrg      duplicate_compiler_generated_deps=$duplicate_deps
20129f606849Smrg      ;;
20139f606849Smrg    esac
20149f606849Smrg    specialdeplibs=
20159f606849Smrg
20169f606849Smrg    libs=
20179f606849Smrg    # Find all interdependent deplibs by searching for libraries
20189f606849Smrg    # that are linked more than once (e.g. -la -lb -la)
20199f606849Smrg    for deplib in $deplibs; do
20209f606849Smrg      if test "X$duplicate_deps" = "Xyes" ; then
20219f606849Smrg	case "$libs " in
20229f606849Smrg	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
20239f606849Smrg	esac
20249f606849Smrg      fi
20259f606849Smrg      libs="$libs $deplib"
20269f606849Smrg    done
20279f606849Smrg
20289f606849Smrg    if test "$linkmode" = lib; then
20299f606849Smrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
20309f606849Smrg
20319f606849Smrg      # Compute libraries that are listed more than once in $predeps
20329f606849Smrg      # $postdeps and mark them as special (i.e., whose duplicates are
20339f606849Smrg      # not to be eliminated).
20349f606849Smrg      pre_post_deps=
20359f606849Smrg      if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then
20369f606849Smrg	for pre_post_dep in $predeps $postdeps; do
20379f606849Smrg	  case "$pre_post_deps " in
20389f606849Smrg	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
20399f606849Smrg	  esac
20409f606849Smrg	  pre_post_deps="$pre_post_deps $pre_post_dep"
20419f606849Smrg	done
20429f606849Smrg      fi
20439f606849Smrg      pre_post_deps=
20449f606849Smrg    fi
20459f606849Smrg
20469f606849Smrg    deplibs=
20479f606849Smrg    newdependency_libs=
20489f606849Smrg    newlib_search_path=
20499f606849Smrg    need_relink=no # whether we're linking any uninstalled libtool libraries
20509f606849Smrg    notinst_deplibs= # not-installed libtool libraries
20519f606849Smrg    case $linkmode in
20529f606849Smrg    lib)
20539f606849Smrg	passes="conv link"
20549f606849Smrg	for file in $dlfiles $dlprefiles; do
20559f606849Smrg	  case $file in
20569f606849Smrg	  *.la) ;;
20579f606849Smrg	  *)
20589f606849Smrg	    $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2
20599f606849Smrg	    exit $EXIT_FAILURE
20609f606849Smrg	    ;;
20619f606849Smrg	  esac
20629f606849Smrg	done
20639f606849Smrg	;;
20649f606849Smrg    prog)
20659f606849Smrg	compile_deplibs=
20669f606849Smrg	finalize_deplibs=
20679f606849Smrg	alldeplibs=no
20689f606849Smrg	newdlfiles=
20699f606849Smrg	newdlprefiles=
20709f606849Smrg	passes="conv scan dlopen dlpreopen link"
20719f606849Smrg	;;
20729f606849Smrg    *)  passes="conv"
20739f606849Smrg	;;
20749f606849Smrg    esac
20759f606849Smrg    for pass in $passes; do
20769f606849Smrg      if test "$linkmode,$pass" = "lib,link" ||
20779f606849Smrg	 test "$linkmode,$pass" = "prog,scan"; then
20789f606849Smrg	libs="$deplibs"
20799f606849Smrg	deplibs=
20809f606849Smrg      fi
20819f606849Smrg      if test "$linkmode" = prog; then
20829f606849Smrg	case $pass in
20839f606849Smrg	dlopen) libs="$dlfiles" ;;
20849f606849Smrg	dlpreopen) libs="$dlprefiles" ;;
20859f606849Smrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
20869f606849Smrg	esac
20879f606849Smrg      fi
20889f606849Smrg      if test "$pass" = dlopen; then
20899f606849Smrg	# Collect dlpreopened libraries
20909f606849Smrg	save_deplibs="$deplibs"
20919f606849Smrg	deplibs=
20929f606849Smrg      fi
20939f606849Smrg      for deplib in $libs; do
20949f606849Smrg	lib=
20959f606849Smrg	found=no
20969f606849Smrg	case $deplib in
20979f606849Smrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
20989f606849Smrg	  if test "$linkmode,$pass" = "prog,link"; then
20999f606849Smrg	    compile_deplibs="$deplib $compile_deplibs"
21009f606849Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
21019f606849Smrg	  else
21029f606849Smrg	    compiler_flags="$compiler_flags $deplib"
21039f606849Smrg	  fi
21049f606849Smrg	  continue
21059f606849Smrg	  ;;
21069f606849Smrg	-l*)
21079f606849Smrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
21089f606849Smrg	    $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2
21099f606849Smrg	    continue
21109f606849Smrg	  fi
21119f606849Smrg	  name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
21129f606849Smrg	  for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do
21139f606849Smrg	    for search_ext in .la $std_shrext .so .a; do
21149f606849Smrg	      # Search the libtool library
21159f606849Smrg	      lib="$searchdir/lib${name}${search_ext}"
21169f606849Smrg	      if test -f "$lib"; then
21179f606849Smrg		if test "$search_ext" = ".la"; then
21189f606849Smrg		  found=yes
21199f606849Smrg		else
21209f606849Smrg		  found=no
21219f606849Smrg		fi
21229f606849Smrg		break 2
21239f606849Smrg	      fi
21249f606849Smrg	    done
21259f606849Smrg	  done
21269f606849Smrg	  if test "$found" != yes; then
21279f606849Smrg	    # deplib doesn't seem to be a libtool library
21289f606849Smrg	    if test "$linkmode,$pass" = "prog,link"; then
21299f606849Smrg	      compile_deplibs="$deplib $compile_deplibs"
21309f606849Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
21319f606849Smrg	    else
21329f606849Smrg	      deplibs="$deplib $deplibs"
21339f606849Smrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
21349f606849Smrg	    fi
21359f606849Smrg	    continue
21369f606849Smrg	  else # deplib is a libtool library
21379f606849Smrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
21389f606849Smrg	    # We need to do some special things here, and not later.
21399f606849Smrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
21409f606849Smrg	      case " $predeps $postdeps " in
21419f606849Smrg	      *" $deplib "*)
21429f606849Smrg		if (${SED} -e '2q' $lib |
21439f606849Smrg                    grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
21449f606849Smrg		  library_names=
21459f606849Smrg		  old_library=
21469f606849Smrg		  case $lib in
21479f606849Smrg		  */* | *\\*) . $lib ;;
21489f606849Smrg		  *) . ./$lib ;;
21499f606849Smrg		  esac
21509f606849Smrg		  for l in $old_library $library_names; do
21519f606849Smrg		    ll="$l"
21529f606849Smrg		  done
21539f606849Smrg		  if test "X$ll" = "X$old_library" ; then # only static version available
21549f606849Smrg		    found=no
21559f606849Smrg		    ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
21569f606849Smrg		    test "X$ladir" = "X$lib" && ladir="."
21579f606849Smrg		    lib=$ladir/$old_library
21589f606849Smrg		    if test "$linkmode,$pass" = "prog,link"; then
21599f606849Smrg		      compile_deplibs="$deplib $compile_deplibs"
21609f606849Smrg		      finalize_deplibs="$deplib $finalize_deplibs"
21619f606849Smrg		    else
21629f606849Smrg		      deplibs="$deplib $deplibs"
21639f606849Smrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
21649f606849Smrg		    fi
21659f606849Smrg		    continue
21669f606849Smrg		  fi
21679f606849Smrg		fi
21689f606849Smrg	        ;;
21699f606849Smrg	      *) ;;
21709f606849Smrg	      esac
21719f606849Smrg	    fi
21729f606849Smrg	  fi
21739f606849Smrg	  ;; # -l
21749f606849Smrg	-L*)
21759f606849Smrg	  case $linkmode in
21769f606849Smrg	  lib)
21779f606849Smrg	    deplibs="$deplib $deplibs"
21789f606849Smrg	    test "$pass" = conv && continue
21799f606849Smrg	    newdependency_libs="$deplib $newdependency_libs"
21809f606849Smrg	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
21819f606849Smrg	    ;;
21829f606849Smrg	  prog)
21839f606849Smrg	    if test "$pass" = conv; then
21849f606849Smrg	      deplibs="$deplib $deplibs"
21859f606849Smrg	      continue
21869f606849Smrg	    fi
21879f606849Smrg	    if test "$pass" = scan; then
21889f606849Smrg	      deplibs="$deplib $deplibs"
21899f606849Smrg	    else
21909f606849Smrg	      compile_deplibs="$deplib $compile_deplibs"
21919f606849Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
21929f606849Smrg	    fi
21939f606849Smrg	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
21949f606849Smrg	    ;;
21959f606849Smrg	  *)
21969f606849Smrg	    $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2
21979f606849Smrg	    ;;
21989f606849Smrg	  esac # linkmode
21999f606849Smrg	  continue
22009f606849Smrg	  ;; # -L
22019f606849Smrg	-R*)
22029f606849Smrg	  if test "$pass" = link; then
22039f606849Smrg	    dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
22049f606849Smrg	    # Make sure the xrpath contains only unique directories.
22059f606849Smrg	    case "$xrpath " in
22069f606849Smrg	    *" $dir "*) ;;
22079f606849Smrg	    *) xrpath="$xrpath $dir" ;;
22089f606849Smrg	    esac
22099f606849Smrg	  fi
22109f606849Smrg	  deplibs="$deplib $deplibs"
22119f606849Smrg	  continue
22129f606849Smrg	  ;;
22139f606849Smrg	*.la) lib="$deplib" ;;
22149f606849Smrg	*.$libext)
22159f606849Smrg	  if test "$pass" = conv; then
22169f606849Smrg	    deplibs="$deplib $deplibs"
22179f606849Smrg	    continue
22189f606849Smrg	  fi
22199f606849Smrg	  case $linkmode in
22209f606849Smrg	  lib)
22219f606849Smrg	    valid_a_lib=no
22229f606849Smrg	    case $deplibs_check_method in
22239f606849Smrg	      match_pattern*)
22249f606849Smrg		set dummy $deplibs_check_method
22259f606849Smrg	        match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
22269f606849Smrg		if eval $echo \"$deplib\" 2>/dev/null \
22279f606849Smrg		    | $SED 10q \
22289f606849Smrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
22299f606849Smrg		  valid_a_lib=yes
22309f606849Smrg		fi
22319f606849Smrg		;;
22329f606849Smrg	      pass_all)
22339f606849Smrg		valid_a_lib=yes
22349f606849Smrg		;;
22359f606849Smrg            esac
22369f606849Smrg	    if test "$valid_a_lib" != yes; then
22379f606849Smrg	      $echo
22389f606849Smrg	      $echo "*** Warning: Trying to link with static lib archive $deplib."
22399f606849Smrg	      $echo "*** I have the capability to make that library automatically link in when"
22409f606849Smrg	      $echo "*** you link to this library.  But I can only do this if you have a"
22419f606849Smrg	      $echo "*** shared version of the library, which you do not appear to have"
22429f606849Smrg	      $echo "*** because the file extensions .$libext of this argument makes me believe"
22439f606849Smrg	      $echo "*** that it is just a static archive that I should not used here."
22449f606849Smrg	    else
22459f606849Smrg	      $echo
22469f606849Smrg	      $echo "*** Warning: Linking the shared library $output against the"
22479f606849Smrg	      $echo "*** static library $deplib is not portable!"
22489f606849Smrg	      deplibs="$deplib $deplibs"
22499f606849Smrg	    fi
22509f606849Smrg	    continue
22519f606849Smrg	    ;;
22529f606849Smrg	  prog)
22539f606849Smrg	    if test "$pass" != link; then
22549f606849Smrg	      deplibs="$deplib $deplibs"
22559f606849Smrg	    else
22569f606849Smrg	      compile_deplibs="$deplib $compile_deplibs"
22579f606849Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
22589f606849Smrg	    fi
22599f606849Smrg	    continue
22609f606849Smrg	    ;;
22619f606849Smrg	  esac # linkmode
22629f606849Smrg	  ;; # *.$libext
22639f606849Smrg	*.lo | *.$objext)
22649f606849Smrg	  if test "$pass" = conv; then
22659f606849Smrg	    deplibs="$deplib $deplibs"
22669f606849Smrg	  elif test "$linkmode" = prog; then
22679f606849Smrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
22689f606849Smrg	      # If there is no dlopen support or we're linking statically,
22699f606849Smrg	      # we need to preload.
22709f606849Smrg	      newdlprefiles="$newdlprefiles $deplib"
22719f606849Smrg	      compile_deplibs="$deplib $compile_deplibs"
22729f606849Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
22739f606849Smrg	    else
22749f606849Smrg	      newdlfiles="$newdlfiles $deplib"
22759f606849Smrg	    fi
22769f606849Smrg	  fi
22779f606849Smrg	  continue
22789f606849Smrg	  ;;
22799f606849Smrg	%DEPLIBS%)
22809f606849Smrg	  alldeplibs=yes
22819f606849Smrg	  continue
22829f606849Smrg	  ;;
22839f606849Smrg	esac # case $deplib
22849f606849Smrg	if test "$found" = yes || test -f "$lib"; then :
22859f606849Smrg	else
22869f606849Smrg	  $echo "$modename: cannot find the library \`$lib' or unhandled argument \`$deplib'" 1>&2
22879f606849Smrg	  exit $EXIT_FAILURE
22889f606849Smrg	fi
22899f606849Smrg
22909f606849Smrg	# Check to see that this really is a libtool archive.
22919f606849Smrg	if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
22929f606849Smrg	else
22939f606849Smrg	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
22949f606849Smrg	  exit $EXIT_FAILURE
22959f606849Smrg	fi
22969f606849Smrg
22979f606849Smrg	ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
22989f606849Smrg	test "X$ladir" = "X$lib" && ladir="."
22999f606849Smrg
23009f606849Smrg	dlname=
23019f606849Smrg	dlopen=
23029f606849Smrg	dlpreopen=
23039f606849Smrg	libdir=
23049f606849Smrg	library_names=
23059f606849Smrg	old_library=
23069f606849Smrg	# If the library was installed with an old release of libtool,
23079f606849Smrg	# it will not redefine variables installed, or shouldnotlink
23089f606849Smrg	installed=yes
23099f606849Smrg	shouldnotlink=no
23109f606849Smrg	avoidtemprpath=
23119f606849Smrg
23129f606849Smrg
23139f606849Smrg	# Read the .la file
23149f606849Smrg	case $lib in
23159f606849Smrg	*/* | *\\*) . $lib ;;
23169f606849Smrg	*) . ./$lib ;;
23179f606849Smrg	esac
23189f606849Smrg
23199f606849Smrg	if test "$linkmode,$pass" = "lib,link" ||
23209f606849Smrg	   test "$linkmode,$pass" = "prog,scan" ||
23219f606849Smrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
23229f606849Smrg	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
23239f606849Smrg	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
23249f606849Smrg	fi
23259f606849Smrg
23269f606849Smrg	if test "$pass" = conv; then
23279f606849Smrg	  # Only check for convenience libraries
23289f606849Smrg	  deplibs="$lib $deplibs"
23299f606849Smrg	  if test -z "$libdir"; then
23309f606849Smrg	    if test -z "$old_library"; then
23319f606849Smrg	      $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
23329f606849Smrg	      exit $EXIT_FAILURE
23339f606849Smrg	    fi
23349f606849Smrg	    # It is a libtool convenience library, so add in its objects.
23359f606849Smrg	    convenience="$convenience $ladir/$objdir/$old_library"
23369f606849Smrg	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
23379f606849Smrg	    tmp_libs=
23389f606849Smrg	    for deplib in $dependency_libs; do
23399f606849Smrg	      deplibs="$deplib $deplibs"
23409f606849Smrg              if test "X$duplicate_deps" = "Xyes" ; then
23419f606849Smrg	        case "$tmp_libs " in
23429f606849Smrg	        *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
23439f606849Smrg	        esac
23449f606849Smrg              fi
23459f606849Smrg	      tmp_libs="$tmp_libs $deplib"
23469f606849Smrg	    done
23479f606849Smrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
23489f606849Smrg	    $echo "$modename: \`$lib' is not a convenience library" 1>&2
23499f606849Smrg	    exit $EXIT_FAILURE
23509f606849Smrg	  fi
23519f606849Smrg	  continue
23529f606849Smrg	fi # $pass = conv
23539f606849Smrg
23549f606849Smrg
23559f606849Smrg	# Get the name of the library we link against.
23569f606849Smrg	linklib=
23579f606849Smrg	for l in $old_library $library_names; do
23589f606849Smrg	  linklib="$l"
23599f606849Smrg	done
23609f606849Smrg	if test -z "$linklib"; then
23619f606849Smrg	  $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
23629f606849Smrg	  exit $EXIT_FAILURE
23639f606849Smrg	fi
23649f606849Smrg
23659f606849Smrg	# This library was specified with -dlopen.
23669f606849Smrg	if test "$pass" = dlopen; then
23679f606849Smrg	  if test -z "$libdir"; then
23689f606849Smrg	    $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2
23699f606849Smrg	    exit $EXIT_FAILURE
23709f606849Smrg	  fi
23719f606849Smrg	  if test -z "$dlname" ||
23729f606849Smrg	     test "$dlopen_support" != yes ||
23739f606849Smrg	     test "$build_libtool_libs" = no; then
23749f606849Smrg	    # If there is no dlname, no dlopen support or we're linking
23759f606849Smrg	    # statically, we need to preload.  We also need to preload any
23769f606849Smrg	    # dependent libraries so libltdl's deplib preloader doesn't
23779f606849Smrg	    # bomb out in the load deplibs phase.
23789f606849Smrg	    dlprefiles="$dlprefiles $lib $dependency_libs"
23799f606849Smrg	  else
23809f606849Smrg	    newdlfiles="$newdlfiles $lib"
23819f606849Smrg	  fi
23829f606849Smrg	  continue
23839f606849Smrg	fi # $pass = dlopen
23849f606849Smrg
23859f606849Smrg	# We need an absolute path.
23869f606849Smrg	case $ladir in
23879f606849Smrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
23889f606849Smrg	*)
23899f606849Smrg	  abs_ladir=`cd "$ladir" && pwd`
23909f606849Smrg	  if test -z "$abs_ladir"; then
23919f606849Smrg	    $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2
23929f606849Smrg	    $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
23939f606849Smrg	    abs_ladir="$ladir"
23949f606849Smrg	  fi
23959f606849Smrg	  ;;
23969f606849Smrg	esac
23979f606849Smrg	laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
23989f606849Smrg
23999f606849Smrg	# Find the relevant object directory and library name.
24009f606849Smrg	if test "X$installed" = Xyes; then
24019f606849Smrg	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
24029f606849Smrg	    $echo "$modename: warning: library \`$lib' was moved." 1>&2
24039f606849Smrg	    dir="$ladir"
24049f606849Smrg	    absdir="$abs_ladir"
24059f606849Smrg	    libdir="$abs_ladir"
24069f606849Smrg	  else
24079f606849Smrg	    dir="$libdir"
24089f606849Smrg	    absdir="$libdir"
24099f606849Smrg	  fi
24109f606849Smrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
24119f606849Smrg	else
24129f606849Smrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
24139f606849Smrg	    dir="$ladir"
24149f606849Smrg	    absdir="$abs_ladir"
24159f606849Smrg	    # Remove this search path later
24169f606849Smrg	    notinst_path="$notinst_path $abs_ladir"
24179f606849Smrg	  else
24189f606849Smrg	    dir="$ladir/$objdir"
24199f606849Smrg	    absdir="$abs_ladir/$objdir"
24209f606849Smrg	    # Remove this search path later
24219f606849Smrg	    notinst_path="$notinst_path $abs_ladir"
24229f606849Smrg	  fi
24239f606849Smrg	fi # $installed = yes
24249f606849Smrg	name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
24259f606849Smrg
24269f606849Smrg	# This library was specified with -dlpreopen.
24279f606849Smrg	if test "$pass" = dlpreopen; then
24289f606849Smrg	  if test -z "$libdir"; then
24299f606849Smrg	    $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2
24309f606849Smrg	    exit $EXIT_FAILURE
24319f606849Smrg	  fi
24329f606849Smrg	  # Prefer using a static library (so that no silly _DYNAMIC symbols
24339f606849Smrg	  # are required to link).
24349f606849Smrg	  if test -n "$old_library"; then
24359f606849Smrg	    newdlprefiles="$newdlprefiles $dir/$old_library"
24369f606849Smrg	  # Otherwise, use the dlname, so that lt_dlopen finds it.
24379f606849Smrg	  elif test -n "$dlname"; then
24389f606849Smrg	    newdlprefiles="$newdlprefiles $dir/$dlname"
24399f606849Smrg	  else
24409f606849Smrg	    newdlprefiles="$newdlprefiles $dir/$linklib"
24419f606849Smrg	  fi
24429f606849Smrg	fi # $pass = dlpreopen
24439f606849Smrg
24449f606849Smrg	if test -z "$libdir"; then
24459f606849Smrg	  # Link the convenience library
24469f606849Smrg	  if test "$linkmode" = lib; then
24479f606849Smrg	    deplibs="$dir/$old_library $deplibs"
24489f606849Smrg	  elif test "$linkmode,$pass" = "prog,link"; then
24499f606849Smrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
24509f606849Smrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
24519f606849Smrg	  else
24529f606849Smrg	    deplibs="$lib $deplibs" # used for prog,scan pass
24539f606849Smrg	  fi
24549f606849Smrg	  continue
24559f606849Smrg	fi
24569f606849Smrg
24579f606849Smrg
24589f606849Smrg	if test "$linkmode" = prog && test "$pass" != link; then
24599f606849Smrg	  newlib_search_path="$newlib_search_path $ladir"
24609f606849Smrg	  deplibs="$lib $deplibs"
24619f606849Smrg
24629f606849Smrg	  linkalldeplibs=no
24639f606849Smrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
24649f606849Smrg	     test "$build_libtool_libs" = no; then
24659f606849Smrg	    linkalldeplibs=yes
24669f606849Smrg	  fi
24679f606849Smrg
24689f606849Smrg	  tmp_libs=
24699f606849Smrg	  for deplib in $dependency_libs; do
24709f606849Smrg	    case $deplib in
24719f606849Smrg	    -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test
24729f606849Smrg	    esac
24739f606849Smrg	    # Need to link against all dependency_libs?
24749f606849Smrg	    if test "$linkalldeplibs" = yes; then
24759f606849Smrg	      deplibs="$deplib $deplibs"
24769f606849Smrg	    else
24779f606849Smrg	      # Need to hardcode shared library paths
24789f606849Smrg	      # or/and link against static libraries
24799f606849Smrg	      newdependency_libs="$deplib $newdependency_libs"
24809f606849Smrg	    fi
24819f606849Smrg	    if test "X$duplicate_deps" = "Xyes" ; then
24829f606849Smrg	      case "$tmp_libs " in
24839f606849Smrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
24849f606849Smrg	      esac
24859f606849Smrg	    fi
24869f606849Smrg	    tmp_libs="$tmp_libs $deplib"
24879f606849Smrg	  done # for deplib
24889f606849Smrg	  continue
24899f606849Smrg	fi # $linkmode = prog...
24909f606849Smrg
24919f606849Smrg	if test "$linkmode,$pass" = "prog,link"; then
24929f606849Smrg	  if test -n "$library_names" &&
24939f606849Smrg	     { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
24949f606849Smrg	    # We need to hardcode the library path
24959f606849Smrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
24969f606849Smrg	      # Make sure the rpath contains only unique directories.
24979f606849Smrg	      case "$temp_rpath " in
24989f606849Smrg	      *" $dir "*) ;;
24999f606849Smrg	      *" $absdir "*) ;;
25009f606849Smrg	      *) temp_rpath="$temp_rpath $absdir" ;;
25019f606849Smrg	      esac
25029f606849Smrg	    fi
25039f606849Smrg
25049f606849Smrg	    # Hardcode the library path.
25059f606849Smrg	    # Skip directories that are in the system default run-time
25069f606849Smrg	    # search path.
25079f606849Smrg	    case " $sys_lib_dlsearch_path " in
25089f606849Smrg	    *" $absdir "*) ;;
25099f606849Smrg	    *)
25109f606849Smrg	      case "$compile_rpath " in
25119f606849Smrg	      *" $absdir "*) ;;
25129f606849Smrg	      *) compile_rpath="$compile_rpath $absdir"
25139f606849Smrg	      esac
25149f606849Smrg	      ;;
25159f606849Smrg	    esac
25169f606849Smrg	    case " $sys_lib_dlsearch_path " in
25179f606849Smrg	    *" $libdir "*) ;;
25189f606849Smrg	    *)
25199f606849Smrg	      case "$finalize_rpath " in
25209f606849Smrg	      *" $libdir "*) ;;
25219f606849Smrg	      *) finalize_rpath="$finalize_rpath $libdir"
25229f606849Smrg	      esac
25239f606849Smrg	      ;;
25249f606849Smrg	    esac
25259f606849Smrg	  fi # $linkmode,$pass = prog,link...
25269f606849Smrg
25279f606849Smrg	  if test "$alldeplibs" = yes &&
25289f606849Smrg	     { test "$deplibs_check_method" = pass_all ||
25299f606849Smrg	       { test "$build_libtool_libs" = yes &&
25309f606849Smrg		 test -n "$library_names"; }; }; then
25319f606849Smrg	    # We only need to search for static libraries
25329f606849Smrg	    continue
25339f606849Smrg	  fi
25349f606849Smrg	fi
25359f606849Smrg
25369f606849Smrg	link_static=no # Whether the deplib will be linked statically
25379f606849Smrg	use_static_libs=$prefer_static_libs
25389f606849Smrg	if test "$use_static_libs" = built && test "$installed" = yes ; then
25399f606849Smrg	  use_static_libs=no
25409f606849Smrg	fi
25419f606849Smrg	if test -n "$library_names" &&
25429f606849Smrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
25439f606849Smrg	  if test "$installed" = no; then
25449f606849Smrg	    notinst_deplibs="$notinst_deplibs $lib"
25459f606849Smrg	    need_relink=yes
25469f606849Smrg	  fi
25479f606849Smrg	  # This is a shared library
25489f606849Smrg
25499f606849Smrg	  # Warn about portability, can't link against -module's on
25509f606849Smrg	  # some systems (darwin)
25519f606849Smrg	  if test "$shouldnotlink" = yes && test "$pass" = link ; then
25529f606849Smrg	    $echo
25539f606849Smrg	    if test "$linkmode" = prog; then
25549f606849Smrg	      $echo "*** Warning: Linking the executable $output against the loadable module"
25559f606849Smrg	    else
25569f606849Smrg	      $echo "*** Warning: Linking the shared library $output against the loadable module"
25579f606849Smrg	    fi
25589f606849Smrg	    $echo "*** $linklib is not portable!"
25599f606849Smrg	  fi
25609f606849Smrg	  if test "$linkmode" = lib &&
25619f606849Smrg	     test "$hardcode_into_libs" = yes; then
25629f606849Smrg	    # Hardcode the library path.
25639f606849Smrg	    # Skip directories that are in the system default run-time
25649f606849Smrg	    # search path.
25659f606849Smrg	    case " $sys_lib_dlsearch_path " in
25669f606849Smrg	    *" $absdir "*) ;;
25679f606849Smrg	    *)
25689f606849Smrg	      case "$compile_rpath " in
25699f606849Smrg	      *" $absdir "*) ;;
25709f606849Smrg	      *) compile_rpath="$compile_rpath $absdir"
25719f606849Smrg	      esac
25729f606849Smrg	      ;;
25739f606849Smrg	    esac
25749f606849Smrg	    case " $sys_lib_dlsearch_path " in
25759f606849Smrg	    *" $libdir "*) ;;
25769f606849Smrg	    *)
25779f606849Smrg	      case "$finalize_rpath " in
25789f606849Smrg	      *" $libdir "*) ;;
25799f606849Smrg	      *) finalize_rpath="$finalize_rpath $libdir"
25809f606849Smrg	      esac
25819f606849Smrg	      ;;
25829f606849Smrg	    esac
25839f606849Smrg	  fi
25849f606849Smrg
25859f606849Smrg	  if test -n "$old_archive_from_expsyms_cmds"; then
25869f606849Smrg	    # figure out the soname
25879f606849Smrg	    set dummy $library_names
25889f606849Smrg	    realname="$2"
25899f606849Smrg	    shift; shift
25909f606849Smrg	    libname=`eval \\$echo \"$libname_spec\"`
25919f606849Smrg	    # use dlname if we got it. it's perfectly good, no?
25929f606849Smrg	    if test -n "$dlname"; then
25939f606849Smrg	      soname="$dlname"
25949f606849Smrg	    elif test -n "$soname_spec"; then
25959f606849Smrg	      # bleh windows
25969f606849Smrg	      case $host in
25979f606849Smrg	      *cygwin* | mingw*)
25989f606849Smrg		major=`expr $current - $age`
25999f606849Smrg		versuffix="-$major"
26009f606849Smrg		;;
26019f606849Smrg	      esac
26029f606849Smrg	      eval soname=\"$soname_spec\"
26039f606849Smrg	    else
26049f606849Smrg	      soname="$realname"
26059f606849Smrg	    fi
26069f606849Smrg
26079f606849Smrg	    # Make a new name for the extract_expsyms_cmds to use
26089f606849Smrg	    soroot="$soname"
26099f606849Smrg	    soname=`$echo $soroot | ${SED} -e 's/^.*\///'`
26109f606849Smrg	    newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a"
26119f606849Smrg
26129f606849Smrg	    # If the library has no export list, then create one now
26139f606849Smrg	    if test -f "$output_objdir/$soname-def"; then :
26149f606849Smrg	    else
26159f606849Smrg	      $show "extracting exported symbol list from \`$soname'"
26169f606849Smrg	      save_ifs="$IFS"; IFS='~'
26179f606849Smrg	      cmds=$extract_expsyms_cmds
26189f606849Smrg	      for cmd in $cmds; do
26199f606849Smrg		IFS="$save_ifs"
26209f606849Smrg		eval cmd=\"$cmd\"
26219f606849Smrg		$show "$cmd"
26229f606849Smrg		$run eval "$cmd" || exit $?
26239f606849Smrg	      done
26249f606849Smrg	      IFS="$save_ifs"
26259f606849Smrg	    fi
26269f606849Smrg
26279f606849Smrg	    # Create $newlib
26289f606849Smrg	    if test -f "$output_objdir/$newlib"; then :; else
26299f606849Smrg	      $show "generating import library for \`$soname'"
26309f606849Smrg	      save_ifs="$IFS"; IFS='~'
26319f606849Smrg	      cmds=$old_archive_from_expsyms_cmds
26329f606849Smrg	      for cmd in $cmds; do
26339f606849Smrg		IFS="$save_ifs"
26349f606849Smrg		eval cmd=\"$cmd\"
26359f606849Smrg		$show "$cmd"
26369f606849Smrg		$run eval "$cmd" || exit $?
26379f606849Smrg	      done
26389f606849Smrg	      IFS="$save_ifs"
26399f606849Smrg	    fi
26409f606849Smrg	    # make sure the library variables are pointing to the new library
26419f606849Smrg	    dir=$output_objdir
26429f606849Smrg	    linklib=$newlib
26439f606849Smrg	  fi # test -n "$old_archive_from_expsyms_cmds"
26449f606849Smrg
26459f606849Smrg	  if test "$linkmode" = prog || test "$mode" != relink; then
26469f606849Smrg	    add_shlibpath=
26479f606849Smrg	    add_dir=
26489f606849Smrg	    add=
26499f606849Smrg	    lib_linked=yes
26509f606849Smrg	    case $hardcode_action in
26519f606849Smrg	    immediate | unsupported)
26529f606849Smrg	      if test "$hardcode_direct" = no; then
26539f606849Smrg		add="$dir/$linklib"
26549f606849Smrg		case $host in
26559f606849Smrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
26569f606849Smrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
26579f606849Smrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
26589f606849Smrg		    *-*-unixware7*) add_dir="-L$dir" ;;
26599f606849Smrg		  *-*-darwin* )
26609f606849Smrg		    # if the lib is a module then we can not link against
26619f606849Smrg		    # it, someone is ignoring the new warnings I added
26629f606849Smrg		    if /usr/bin/file -L $add 2> /dev/null |
26639f606849Smrg                      $EGREP ": [^:]* bundle" >/dev/null ; then
26649f606849Smrg		      $echo "** Warning, lib $linklib is a module, not a shared library"
26659f606849Smrg		      if test -z "$old_library" ; then
26669f606849Smrg		        $echo
26679f606849Smrg		        $echo "** And there doesn't seem to be a static archive available"
26689f606849Smrg		        $echo "** The link will probably fail, sorry"
26699f606849Smrg		      else
26709f606849Smrg		        add="$dir/$old_library"
26719f606849Smrg		      fi
26729f606849Smrg		    fi
26739f606849Smrg		esac
26749f606849Smrg	      elif test "$hardcode_minus_L" = no; then
26759f606849Smrg		case $host in
26769f606849Smrg		*-*-sunos*) add_shlibpath="$dir" ;;
26779f606849Smrg		esac
26789f606849Smrg		add_dir="-L$dir"
26799f606849Smrg		add="-l$name"
26809f606849Smrg	      elif test "$hardcode_shlibpath_var" = no; then
26819f606849Smrg		add_shlibpath="$dir"
26829f606849Smrg		add="-l$name"
26839f606849Smrg	      else
26849f606849Smrg		lib_linked=no
26859f606849Smrg	      fi
26869f606849Smrg	      ;;
26879f606849Smrg	    relink)
26889f606849Smrg	      if test "$hardcode_direct" = yes; then
26899f606849Smrg		add="$dir/$linklib"
26909f606849Smrg	      elif test "$hardcode_minus_L" = yes; then
26919f606849Smrg		add_dir="-L$dir"
26929f606849Smrg		# Try looking first in the location we're being installed to.
26939f606849Smrg		if test -n "$inst_prefix_dir"; then
26949f606849Smrg		  case $libdir in
26959f606849Smrg		    [\\/]*)
26969f606849Smrg		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
26979f606849Smrg		      ;;
26989f606849Smrg		  esac
26999f606849Smrg		fi
27009f606849Smrg		add="-l$name"
27019f606849Smrg	      elif test "$hardcode_shlibpath_var" = yes; then
27029f606849Smrg		add_shlibpath="$dir"
27039f606849Smrg		add="-l$name"
27049f606849Smrg	      else
27059f606849Smrg		lib_linked=no
27069f606849Smrg	      fi
27079f606849Smrg	      ;;
27089f606849Smrg	    *) lib_linked=no ;;
27099f606849Smrg	    esac
27109f606849Smrg
27119f606849Smrg	    if test "$lib_linked" != yes; then
27129f606849Smrg	      $echo "$modename: configuration error: unsupported hardcode properties"
27139f606849Smrg	      exit $EXIT_FAILURE
27149f606849Smrg	    fi
27159f606849Smrg
27169f606849Smrg	    if test -n "$add_shlibpath"; then
27179f606849Smrg	      case :$compile_shlibpath: in
27189f606849Smrg	      *":$add_shlibpath:"*) ;;
27199f606849Smrg	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
27209f606849Smrg	      esac
27219f606849Smrg	    fi
27229f606849Smrg	    if test "$linkmode" = prog; then
27239f606849Smrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
27249f606849Smrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
27259f606849Smrg	    else
27269f606849Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
27279f606849Smrg	      test -n "$add" && deplibs="$add $deplibs"
27289f606849Smrg	      if test "$hardcode_direct" != yes && \
27299f606849Smrg		 test "$hardcode_minus_L" != yes && \
27309f606849Smrg		 test "$hardcode_shlibpath_var" = yes; then
27319f606849Smrg		case :$finalize_shlibpath: in
27329f606849Smrg		*":$libdir:"*) ;;
27339f606849Smrg		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
27349f606849Smrg		esac
27359f606849Smrg	      fi
27369f606849Smrg	    fi
27379f606849Smrg	  fi
27389f606849Smrg
27399f606849Smrg	  if test "$linkmode" = prog || test "$mode" = relink; then
27409f606849Smrg	    add_shlibpath=
27419f606849Smrg	    add_dir=
27429f606849Smrg	    add=
27439f606849Smrg	    # Finalize command for both is simple: just hardcode it.
27449f606849Smrg	    if test "$hardcode_direct" = yes; then
27459f606849Smrg	      add="$libdir/$linklib"
27469f606849Smrg	    elif test "$hardcode_minus_L" = yes; then
27479f606849Smrg	      add_dir="-L$libdir"
27489f606849Smrg	      add="-l$name"
27499f606849Smrg	    elif test "$hardcode_shlibpath_var" = yes; then
27509f606849Smrg	      case :$finalize_shlibpath: in
27519f606849Smrg	      *":$libdir:"*) ;;
27529f606849Smrg	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
27539f606849Smrg	      esac
27549f606849Smrg	      add="-l$name"
27559f606849Smrg	    elif test "$hardcode_automatic" = yes; then
27569f606849Smrg	      if test -n "$inst_prefix_dir" &&
27579f606849Smrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
27589f606849Smrg	        add="$inst_prefix_dir$libdir/$linklib"
27599f606849Smrg	      else
27609f606849Smrg	        add="$libdir/$linklib"
27619f606849Smrg	      fi
27629f606849Smrg	    else
27639f606849Smrg	      # We cannot seem to hardcode it, guess we'll fake it.
27649f606849Smrg	      add_dir="-L$libdir"
27659f606849Smrg	      # Try looking first in the location we're being installed to.
27669f606849Smrg	      if test -n "$inst_prefix_dir"; then
27679f606849Smrg		case $libdir in
27689f606849Smrg		  [\\/]*)
27699f606849Smrg		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
27709f606849Smrg		    ;;
27719f606849Smrg		esac
27729f606849Smrg	      fi
27739f606849Smrg	      add="-l$name"
27749f606849Smrg	    fi
27759f606849Smrg
27769f606849Smrg	    if test "$linkmode" = prog; then
27779f606849Smrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
27789f606849Smrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
27799f606849Smrg	    else
27809f606849Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
27819f606849Smrg	      test -n "$add" && deplibs="$add $deplibs"
27829f606849Smrg	    fi
27839f606849Smrg	  fi
27849f606849Smrg	elif test "$linkmode" = prog; then
27859f606849Smrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
27869f606849Smrg	  # is not unsupported.  This is valid on all known static and
27879f606849Smrg	  # shared platforms.
27889f606849Smrg	  if test "$hardcode_direct" != unsupported; then
27899f606849Smrg	    test -n "$old_library" && linklib="$old_library"
27909f606849Smrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
27919f606849Smrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
27929f606849Smrg	  else
27939f606849Smrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
27949f606849Smrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
27959f606849Smrg	  fi
27969f606849Smrg	elif test "$build_libtool_libs" = yes; then
27979f606849Smrg	  # Not a shared library
27989f606849Smrg	  if test "$deplibs_check_method" != pass_all; then
27999f606849Smrg	    # We're trying link a shared library against a static one
28009f606849Smrg	    # but the system doesn't support it.
28019f606849Smrg
28029f606849Smrg	    # Just print a warning and add the library to dependency_libs so
28039f606849Smrg	    # that the program can be linked against the static library.
28049f606849Smrg	    $echo
28059f606849Smrg	    $echo "*** Warning: This system can not link to static lib archive $lib."
28069f606849Smrg	    $echo "*** I have the capability to make that library automatically link in when"
28079f606849Smrg	    $echo "*** you link to this library.  But I can only do this if you have a"
28089f606849Smrg	    $echo "*** shared version of the library, which you do not appear to have."
28099f606849Smrg	    if test "$module" = yes; then
28109f606849Smrg	      $echo "*** But as you try to build a module library, libtool will still create "
28119f606849Smrg	      $echo "*** a static module, that should work as long as the dlopening application"
28129f606849Smrg	      $echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
28139f606849Smrg	      if test -z "$global_symbol_pipe"; then
28149f606849Smrg		$echo
28159f606849Smrg		$echo "*** However, this would only work if libtool was able to extract symbol"
28169f606849Smrg		$echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
28179f606849Smrg		$echo "*** not find such a program.  So, this module is probably useless."
28189f606849Smrg		$echo "*** \`nm' from GNU binutils and a full rebuild may help."
28199f606849Smrg	      fi
28209f606849Smrg	      if test "$build_old_libs" = no; then
28219f606849Smrg		build_libtool_libs=module
28229f606849Smrg		build_old_libs=yes
28239f606849Smrg	      else
28249f606849Smrg		build_libtool_libs=no
28259f606849Smrg	      fi
28269f606849Smrg	    fi
28279f606849Smrg	  else
28289f606849Smrg	    deplibs="$dir/$old_library $deplibs"
28299f606849Smrg	    link_static=yes
28309f606849Smrg	  fi
28319f606849Smrg	fi # link shared/static library?
28329f606849Smrg
28339f606849Smrg	if test "$linkmode" = lib; then
28349f606849Smrg	  if test -n "$dependency_libs" &&
28359f606849Smrg	     { test "$hardcode_into_libs" != yes ||
28369f606849Smrg	       test "$build_old_libs" = yes ||
28379f606849Smrg	       test "$link_static" = yes; }; then
28389f606849Smrg	    # Extract -R from dependency_libs
28399f606849Smrg	    temp_deplibs=
28409f606849Smrg	    for libdir in $dependency_libs; do
28419f606849Smrg	      case $libdir in
28429f606849Smrg	      -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'`
28439f606849Smrg		   case " $xrpath " in
28449f606849Smrg		   *" $temp_xrpath "*) ;;
28459f606849Smrg		   *) xrpath="$xrpath $temp_xrpath";;
28469f606849Smrg		   esac;;
28479f606849Smrg	      *) temp_deplibs="$temp_deplibs $libdir";;
28489f606849Smrg	      esac
28499f606849Smrg	    done
28509f606849Smrg	    dependency_libs="$temp_deplibs"
28519f606849Smrg	  fi
28529f606849Smrg
28539f606849Smrg	  newlib_search_path="$newlib_search_path $absdir"
28549f606849Smrg	  # Link against this library
28559f606849Smrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
28569f606849Smrg	  # ... and its dependency_libs
28579f606849Smrg	  tmp_libs=
28589f606849Smrg	  for deplib in $dependency_libs; do
28599f606849Smrg	    newdependency_libs="$deplib $newdependency_libs"
28609f606849Smrg	    if test "X$duplicate_deps" = "Xyes" ; then
28619f606849Smrg	      case "$tmp_libs " in
28629f606849Smrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
28639f606849Smrg	      esac
28649f606849Smrg	    fi
28659f606849Smrg	    tmp_libs="$tmp_libs $deplib"
28669f606849Smrg	  done
28679f606849Smrg
28689f606849Smrg	  if test "$link_all_deplibs" != no; then
28699f606849Smrg	    # Add the search paths of all dependency libraries
28709f606849Smrg	    for deplib in $dependency_libs; do
28719f606849Smrg	      case $deplib in
28729f606849Smrg	      -L*) path="$deplib" ;;
28739f606849Smrg	      *.la)
28749f606849Smrg		dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'`
28759f606849Smrg		test "X$dir" = "X$deplib" && dir="."
28769f606849Smrg		# We need an absolute path.
28779f606849Smrg		case $dir in
28789f606849Smrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
28799f606849Smrg		*)
28809f606849Smrg		  absdir=`cd "$dir" && pwd`
28819f606849Smrg		  if test -z "$absdir"; then
28829f606849Smrg		    $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
28839f606849Smrg		    absdir="$dir"
28849f606849Smrg		  fi
28859f606849Smrg		  ;;
28869f606849Smrg		esac
28879f606849Smrg		if grep "^installed=no" $deplib > /dev/null; then
28889f606849Smrg		  path="$absdir/$objdir"
28899f606849Smrg		else
28909f606849Smrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
28919f606849Smrg		  if test -z "$libdir"; then
28929f606849Smrg		    $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
28939f606849Smrg		    exit $EXIT_FAILURE
28949f606849Smrg		  fi
28959f606849Smrg		  if test "$absdir" != "$libdir"; then
28969f606849Smrg		    $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2
28979f606849Smrg		  fi
28989f606849Smrg		  path="$absdir"
28999f606849Smrg		fi
29009f606849Smrg		depdepl=
29019f606849Smrg		case $host in
29029f606849Smrg		*-*-darwin*)
29039f606849Smrg		  # we do not want to link against static libs,
29049f606849Smrg		  # but need to link against shared
29059f606849Smrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
29069f606849Smrg		  if test -n "$deplibrary_names" ; then
29079f606849Smrg		    for tmp in $deplibrary_names ; do
29089f606849Smrg		      depdepl=$tmp
29099f606849Smrg		    done
29109f606849Smrg		    if test -f "$path/$depdepl" ; then
29119f606849Smrg		      depdepl="$path/$depdepl"
29129f606849Smrg		    fi
29139f606849Smrg		    # do not add paths which are already there
29149f606849Smrg		    case " $newlib_search_path " in
29159f606849Smrg		    *" $path "*) ;;
29169f606849Smrg		    *) newlib_search_path="$newlib_search_path $path";;
29179f606849Smrg		    esac
29189f606849Smrg		  fi
29199f606849Smrg		  path=""
29209f606849Smrg		  ;;
29219f606849Smrg		*)
29229f606849Smrg		  path="-L$path"
29239f606849Smrg		  ;;
29249f606849Smrg		esac
29259f606849Smrg		;;
29269f606849Smrg	      -l*)
29279f606849Smrg		case $host in
29289f606849Smrg		*-*-darwin*)
29299f606849Smrg		  # Again, we only want to link against shared libraries
29309f606849Smrg		  eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"`
29319f606849Smrg		  for tmp in $newlib_search_path ; do
29329f606849Smrg		    if test -f "$tmp/lib$tmp_libs.dylib" ; then
29339f606849Smrg		      eval depdepl="$tmp/lib$tmp_libs.dylib"
29349f606849Smrg		      break
29359f606849Smrg		    fi
29369f606849Smrg		  done
29379f606849Smrg		  path=""
29389f606849Smrg		  ;;
29399f606849Smrg		*) continue ;;
29409f606849Smrg		esac
29419f606849Smrg		;;
29429f606849Smrg	      *) continue ;;
29439f606849Smrg	      esac
29449f606849Smrg	      case " $deplibs " in
29459f606849Smrg	      *" $path "*) ;;
29469f606849Smrg	      *) deplibs="$path $deplibs" ;;
29479f606849Smrg	      esac
29489f606849Smrg	      case " $deplibs " in
29499f606849Smrg	      *" $depdepl "*) ;;
29509f606849Smrg	      *) deplibs="$depdepl $deplibs" ;;
29519f606849Smrg	      esac
29529f606849Smrg	    done
29539f606849Smrg	  fi # link_all_deplibs != no
29549f606849Smrg	fi # linkmode = lib
29559f606849Smrg      done # for deplib in $libs
29569f606849Smrg      dependency_libs="$newdependency_libs"
29579f606849Smrg      if test "$pass" = dlpreopen; then
29589f606849Smrg	# Link the dlpreopened libraries before other libraries
29599f606849Smrg	for deplib in $save_deplibs; do
29609f606849Smrg	  deplibs="$deplib $deplibs"
29619f606849Smrg	done
29629f606849Smrg      fi
29639f606849Smrg      if test "$pass" != dlopen; then
29649f606849Smrg	if test "$pass" != conv; then
29659f606849Smrg	  # Make sure lib_search_path contains only unique directories.
29669f606849Smrg	  lib_search_path=
29679f606849Smrg	  for dir in $newlib_search_path; do
29689f606849Smrg	    case "$lib_search_path " in
29699f606849Smrg	    *" $dir "*) ;;
29709f606849Smrg	    *) lib_search_path="$lib_search_path $dir" ;;
29719f606849Smrg	    esac
29729f606849Smrg	  done
29739f606849Smrg	  newlib_search_path=
29749f606849Smrg	fi
29759f606849Smrg
29769f606849Smrg	if test "$linkmode,$pass" != "prog,link"; then
29779f606849Smrg	  vars="deplibs"
29789f606849Smrg	else
29799f606849Smrg	  vars="compile_deplibs finalize_deplibs"
29809f606849Smrg	fi
29819f606849Smrg	for var in $vars dependency_libs; do
29829f606849Smrg	  # Add libraries to $var in reverse order
29839f606849Smrg	  eval tmp_libs=\"\$$var\"
29849f606849Smrg	  new_libs=
29859f606849Smrg	  for deplib in $tmp_libs; do
29869f606849Smrg	    # FIXME: Pedantically, this is the right thing to do, so
29879f606849Smrg	    #        that some nasty dependency loop isn't accidentally
29889f606849Smrg	    #        broken:
29899f606849Smrg	    #new_libs="$deplib $new_libs"
29909f606849Smrg	    # Pragmatically, this seems to cause very few problems in
29919f606849Smrg	    # practice:
29929f606849Smrg	    case $deplib in
29939f606849Smrg	    -L*) new_libs="$deplib $new_libs" ;;
29949f606849Smrg	    -R*) ;;
29959f606849Smrg	    *)
29969f606849Smrg	      # And here is the reason: when a library appears more
29979f606849Smrg	      # than once as an explicit dependence of a library, or
29989f606849Smrg	      # is implicitly linked in more than once by the
29999f606849Smrg	      # compiler, it is considered special, and multiple
30009f606849Smrg	      # occurrences thereof are not removed.  Compare this
30019f606849Smrg	      # with having the same library being listed as a
30029f606849Smrg	      # dependency of multiple other libraries: in this case,
30039f606849Smrg	      # we know (pedantically, we assume) the library does not
30049f606849Smrg	      # need to be listed more than once, so we keep only the
30059f606849Smrg	      # last copy.  This is not always right, but it is rare
30069f606849Smrg	      # enough that we require users that really mean to play
30079f606849Smrg	      # such unportable linking tricks to link the library
30089f606849Smrg	      # using -Wl,-lname, so that libtool does not consider it
30099f606849Smrg	      # for duplicate removal.
30109f606849Smrg	      case " $specialdeplibs " in
30119f606849Smrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
30129f606849Smrg	      *)
30139f606849Smrg		case " $new_libs " in
30149f606849Smrg		*" $deplib "*) ;;
30159f606849Smrg		*) new_libs="$deplib $new_libs" ;;
30169f606849Smrg		esac
30179f606849Smrg		;;
30189f606849Smrg	      esac
30199f606849Smrg	      ;;
30209f606849Smrg	    esac
30219f606849Smrg	  done
30229f606849Smrg	  tmp_libs=
30239f606849Smrg	  for deplib in $new_libs; do
30249f606849Smrg	    case $deplib in
30259f606849Smrg	    -L*)
30269f606849Smrg	      case " $tmp_libs " in
30279f606849Smrg	      *" $deplib "*) ;;
30289f606849Smrg	      *) tmp_libs="$tmp_libs $deplib" ;;
30299f606849Smrg	      esac
30309f606849Smrg	      ;;
30319f606849Smrg	    *) tmp_libs="$tmp_libs $deplib" ;;
30329f606849Smrg	    esac
30339f606849Smrg	  done
30349f606849Smrg	  eval $var=\"$tmp_libs\"
30359f606849Smrg	done # for var
30369f606849Smrg      fi
30379f606849Smrg      # Last step: remove runtime libs from dependency_libs
30389f606849Smrg      # (they stay in deplibs)
30399f606849Smrg      tmp_libs=
30409f606849Smrg      for i in $dependency_libs ; do
30419f606849Smrg	case " $predeps $postdeps $compiler_lib_search_path " in
30429f606849Smrg	*" $i "*)
30439f606849Smrg	  i=""
30449f606849Smrg	  ;;
30459f606849Smrg	esac
30469f606849Smrg	if test -n "$i" ; then
30479f606849Smrg	  tmp_libs="$tmp_libs $i"
30489f606849Smrg	fi
30499f606849Smrg      done
30509f606849Smrg      dependency_libs=$tmp_libs
30519f606849Smrg    done # for pass
30529f606849Smrg    if test "$linkmode" = prog; then
30539f606849Smrg      dlfiles="$newdlfiles"
30549f606849Smrg      dlprefiles="$newdlprefiles"
30559f606849Smrg    fi
30569f606849Smrg
30579f606849Smrg    case $linkmode in
30589f606849Smrg    oldlib)
30599f606849Smrg      if test -n "$deplibs"; then
30609f606849Smrg	$echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2
30619f606849Smrg      fi
30629f606849Smrg
30639f606849Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
30649f606849Smrg	$echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
30659f606849Smrg      fi
30669f606849Smrg
30679f606849Smrg      if test -n "$rpath"; then
30689f606849Smrg	$echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2
30699f606849Smrg      fi
30709f606849Smrg
30719f606849Smrg      if test -n "$xrpath"; then
30729f606849Smrg	$echo "$modename: warning: \`-R' is ignored for archives" 1>&2
30739f606849Smrg      fi
30749f606849Smrg
30759f606849Smrg      if test -n "$vinfo"; then
30769f606849Smrg	$echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2
30779f606849Smrg      fi
30789f606849Smrg
30799f606849Smrg      if test -n "$release"; then
30809f606849Smrg	$echo "$modename: warning: \`-release' is ignored for archives" 1>&2
30819f606849Smrg      fi
30829f606849Smrg
30839f606849Smrg      if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
30849f606849Smrg	$echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2
30859f606849Smrg      fi
30869f606849Smrg
30879f606849Smrg      # Now set the variables for building old libraries.
30889f606849Smrg      build_libtool_libs=no
30899f606849Smrg      oldlibs="$output"
30909f606849Smrg      objs="$objs$old_deplibs"
30919f606849Smrg      ;;
30929f606849Smrg
30939f606849Smrg    lib)
30949f606849Smrg      # Make sure we only generate libraries of the form `libNAME.la'.
30959f606849Smrg      case $outputname in
30969f606849Smrg      lib*)
30979f606849Smrg	name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
30989f606849Smrg	eval shared_ext=\"$shrext_cmds\"
30999f606849Smrg	eval libname=\"$libname_spec\"
31009f606849Smrg	;;
31019f606849Smrg      *)
31029f606849Smrg	if test "$module" = no; then
31039f606849Smrg	  $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
31049f606849Smrg	  $echo "$help" 1>&2
31059f606849Smrg	  exit $EXIT_FAILURE
31069f606849Smrg	fi
31079f606849Smrg	if test "$need_lib_prefix" != no; then
31089f606849Smrg	  # Add the "lib" prefix for modules if required
31099f606849Smrg	  name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
31109f606849Smrg	  eval shared_ext=\"$shrext_cmds\"
31119f606849Smrg	  eval libname=\"$libname_spec\"
31129f606849Smrg	else
31139f606849Smrg	  libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
31149f606849Smrg	fi
31159f606849Smrg	;;
31169f606849Smrg      esac
31179f606849Smrg
31189f606849Smrg      if test -n "$objs"; then
31199f606849Smrg	if test "$deplibs_check_method" != pass_all; then
31209f606849Smrg	  $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1
31219f606849Smrg	  exit $EXIT_FAILURE
31229f606849Smrg	else
31239f606849Smrg	  $echo
31249f606849Smrg	  $echo "*** Warning: Linking the shared library $output against the non-libtool"
31259f606849Smrg	  $echo "*** objects $objs is not portable!"
31269f606849Smrg	  libobjs="$libobjs $objs"
31279f606849Smrg	fi
31289f606849Smrg      fi
31299f606849Smrg
31309f606849Smrg      if test "$dlself" != no; then
31319f606849Smrg	$echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2
31329f606849Smrg      fi
31339f606849Smrg
31349f606849Smrg      set dummy $rpath
31359f606849Smrg      if test "$#" -gt 2; then
31369f606849Smrg	$echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
31379f606849Smrg      fi
31389f606849Smrg      install_libdir="$2"
31399f606849Smrg
31409f606849Smrg      oldlibs=
31419f606849Smrg      if test -z "$rpath"; then
31429f606849Smrg	if test "$build_libtool_libs" = yes; then
31439f606849Smrg	  # Building a libtool convenience library.
31449f606849Smrg	  # Some compilers have problems with a `.al' extension so
31459f606849Smrg	  # convenience libraries should have the same extension an
31469f606849Smrg	  # archive normally would.
31479f606849Smrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
31489f606849Smrg	  build_libtool_libs=convenience
31499f606849Smrg	  build_old_libs=yes
31509f606849Smrg	fi
31519f606849Smrg
31529f606849Smrg	if test -n "$vinfo"; then
31539f606849Smrg	  $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2
31549f606849Smrg	fi
31559f606849Smrg
31569f606849Smrg	if test -n "$release"; then
31579f606849Smrg	  $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2
31589f606849Smrg	fi
31599f606849Smrg      else
31609f606849Smrg
31619f606849Smrg	# Parse the version information argument.
31629f606849Smrg	save_ifs="$IFS"; IFS=':'
31639f606849Smrg	set dummy $vinfo 0 0 0
31649f606849Smrg	IFS="$save_ifs"
31659f606849Smrg
31669f606849Smrg	if test -n "$8"; then
31679f606849Smrg	  $echo "$modename: too many parameters to \`-version-info'" 1>&2
31689f606849Smrg	  $echo "$help" 1>&2
31699f606849Smrg	  exit $EXIT_FAILURE
31709f606849Smrg	fi
31719f606849Smrg
31729f606849Smrg	# convert absolute version numbers to libtool ages
31739f606849Smrg	# this retains compatibility with .la files and attempts
31749f606849Smrg	# to make the code below a bit more comprehensible
31759f606849Smrg
31769f606849Smrg	case $vinfo_number in
31779f606849Smrg	yes)
31789f606849Smrg	  number_major="$2"
31799f606849Smrg	  number_minor="$3"
31809f606849Smrg	  number_revision="$4"
31819f606849Smrg	  #
31829f606849Smrg	  # There are really only two kinds -- those that
31839f606849Smrg	  # use the current revision as the major version
31849f606849Smrg	  # and those that subtract age and use age as
31859f606849Smrg	  # a minor version.  But, then there is irix
31869f606849Smrg	  # which has an extra 1 added just for fun
31879f606849Smrg	  #
31889f606849Smrg	  case $version_type in
31899f606849Smrg	  darwin|linux|osf|windows)
31909f606849Smrg	    current=`expr $number_major + $number_minor`
31919f606849Smrg	    age="$number_minor"
31929f606849Smrg	    revision="$number_revision"
31939f606849Smrg	    ;;
31949f606849Smrg	  freebsd-aout|freebsd-elf|sunos)
31959f606849Smrg	    current="$number_major"
31969f606849Smrg	    revision="$number_minor"
31979f606849Smrg	    age="0"
31989f606849Smrg	    ;;
31999f606849Smrg	  irix|nonstopux)
32009f606849Smrg	    current=`expr $number_major + $number_minor - 1`
32019f606849Smrg	    age="$number_minor"
32029f606849Smrg	    revision="$number_minor"
32039f606849Smrg	    ;;
32049f606849Smrg	  esac
32059f606849Smrg	  ;;
32069f606849Smrg	no)
32079f606849Smrg	  current="$2"
32089f606849Smrg	  revision="$3"
32099f606849Smrg	  age="$4"
32109f606849Smrg	  ;;
32119f606849Smrg	esac
32129f606849Smrg
32139f606849Smrg	# Check that each of the things are valid numbers.
32149f606849Smrg	case $current in
32159f606849Smrg	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]) ;;
32169f606849Smrg	*)
32179f606849Smrg	  $echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2
32189f606849Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
32199f606849Smrg	  exit $EXIT_FAILURE
32209f606849Smrg	  ;;
32219f606849Smrg	esac
32229f606849Smrg
32239f606849Smrg	case $revision in
32249f606849Smrg	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]) ;;
32259f606849Smrg	*)
32269f606849Smrg	  $echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2
32279f606849Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
32289f606849Smrg	  exit $EXIT_FAILURE
32299f606849Smrg	  ;;
32309f606849Smrg	esac
32319f606849Smrg
32329f606849Smrg	case $age in
32339f606849Smrg	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]) ;;
32349f606849Smrg	*)
32359f606849Smrg	  $echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2
32369f606849Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
32379f606849Smrg	  exit $EXIT_FAILURE
32389f606849Smrg	  ;;
32399f606849Smrg	esac
32409f606849Smrg
32419f606849Smrg	if test "$age" -gt "$current"; then
32429f606849Smrg	  $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
32439f606849Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
32449f606849Smrg	  exit $EXIT_FAILURE
32459f606849Smrg	fi
32469f606849Smrg
32479f606849Smrg	# Calculate the version variables.
32489f606849Smrg	major=
32499f606849Smrg	versuffix=
32509f606849Smrg	verstring=
32519f606849Smrg	case $version_type in
32529f606849Smrg	none) ;;
32539f606849Smrg
32549f606849Smrg	darwin)
32559f606849Smrg	  # Like Linux, but with the current version available in
32569f606849Smrg	  # verstring for coding it into the library header
32579f606849Smrg	  major=.`expr $current - $age`
32589f606849Smrg	  versuffix="$major.$age.$revision"
32599f606849Smrg	  # Darwin ld doesn't like 0 for these options...
32609f606849Smrg	  minor_current=`expr $current + 1`
32619f606849Smrg	  verstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
32629f606849Smrg	  ;;
32639f606849Smrg
32649f606849Smrg	freebsd-aout)
32659f606849Smrg	  major=".$current"
32669f606849Smrg	  versuffix=".$current.$revision";
32679f606849Smrg	  ;;
32689f606849Smrg
32699f606849Smrg	freebsd-elf)
32709f606849Smrg	  major=".$current"
32719f606849Smrg	  versuffix=".$current";
32729f606849Smrg	  ;;
32739f606849Smrg
32749f606849Smrg	irix | nonstopux)
32759f606849Smrg	  major=`expr $current - $age + 1`
32769f606849Smrg
32779f606849Smrg	  case $version_type in
32789f606849Smrg	    nonstopux) verstring_prefix=nonstopux ;;
32799f606849Smrg	    *)         verstring_prefix=sgi ;;
32809f606849Smrg	  esac
32819f606849Smrg	  verstring="$verstring_prefix$major.$revision"
32829f606849Smrg
32839f606849Smrg	  # Add in all the interfaces that we are compatible with.
32849f606849Smrg	  loop=$revision
32859f606849Smrg	  while test "$loop" -ne 0; do
32869f606849Smrg	    iface=`expr $revision - $loop`
32879f606849Smrg	    loop=`expr $loop - 1`
32889f606849Smrg	    verstring="$verstring_prefix$major.$iface:$verstring"
32899f606849Smrg	  done
32909f606849Smrg
32919f606849Smrg	  # Before this point, $major must not contain `.'.
32929f606849Smrg	  major=.$major
32939f606849Smrg	  versuffix="$major.$revision"
32949f606849Smrg	  ;;
32959f606849Smrg
32969f606849Smrg	linux)
32979f606849Smrg	  major=.`expr $current - $age`
32989f606849Smrg	  versuffix="$major.$age.$revision"
32999f606849Smrg	  ;;
33009f606849Smrg
33019f606849Smrg	osf)
33029f606849Smrg	  major=.`expr $current - $age`
33039f606849Smrg	  versuffix=".$current.$age.$revision"
33049f606849Smrg	  verstring="$current.$age.$revision"
33059f606849Smrg
33069f606849Smrg	  # Add in all the interfaces that we are compatible with.
33079f606849Smrg	  loop=$age
33089f606849Smrg	  while test "$loop" -ne 0; do
33099f606849Smrg	    iface=`expr $current - $loop`
33109f606849Smrg	    loop=`expr $loop - 1`
33119f606849Smrg	    verstring="$verstring:${iface}.0"
33129f606849Smrg	  done
33139f606849Smrg
33149f606849Smrg	  # Make executables depend on our current version.
33159f606849Smrg	  verstring="$verstring:${current}.0"
33169f606849Smrg	  ;;
33179f606849Smrg
33189f606849Smrg	sunos)
33199f606849Smrg	  major=".$current"
33209f606849Smrg	  versuffix=".$current.$revision"
33219f606849Smrg	  ;;
33229f606849Smrg
33239f606849Smrg	windows)
33249f606849Smrg	  # Use '-' rather than '.', since we only want one
33259f606849Smrg	  # extension on DOS 8.3 filesystems.
33269f606849Smrg	  major=`expr $current - $age`
33279f606849Smrg	  versuffix="-$major"
33289f606849Smrg	  ;;
33299f606849Smrg
33309f606849Smrg	*)
33319f606849Smrg	  $echo "$modename: unknown library version type \`$version_type'" 1>&2
33329f606849Smrg	  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
33339f606849Smrg	  exit $EXIT_FAILURE
33349f606849Smrg	  ;;
33359f606849Smrg	esac
33369f606849Smrg
33379f606849Smrg	# Clear the version info if we defaulted, and they specified a release.
33389f606849Smrg	if test -z "$vinfo" && test -n "$release"; then
33399f606849Smrg	  major=
33409f606849Smrg	  case $version_type in
33419f606849Smrg	  darwin)
33429f606849Smrg	    # we can't check for "0.0" in archive_cmds due to quoting
33439f606849Smrg	    # problems, so we reset it completely
33449f606849Smrg	    verstring=
33459f606849Smrg	    ;;
33469f606849Smrg	  *)
33479f606849Smrg	    verstring="0.0"
33489f606849Smrg	    ;;
33499f606849Smrg	  esac
33509f606849Smrg	  if test "$need_version" = no; then
33519f606849Smrg	    versuffix=
33529f606849Smrg	  else
33539f606849Smrg	    versuffix=".0.0"
33549f606849Smrg	  fi
33559f606849Smrg	fi
33569f606849Smrg
33579f606849Smrg	# Remove version info from name if versioning should be avoided
33589f606849Smrg	if test "$avoid_version" = yes && test "$need_version" = no; then
33599f606849Smrg	  major=
33609f606849Smrg	  versuffix=
33619f606849Smrg	  verstring=""
33629f606849Smrg	fi
33639f606849Smrg
33649f606849Smrg	# Check to see if the archive will have undefined symbols.
33659f606849Smrg	if test "$allow_undefined" = yes; then
33669f606849Smrg	  if test "$allow_undefined_flag" = unsupported; then
33679f606849Smrg	    $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2
33689f606849Smrg	    build_libtool_libs=no
33699f606849Smrg	    build_old_libs=yes
33709f606849Smrg	  fi
33719f606849Smrg	else
33729f606849Smrg	  # Don't allow undefined symbols.
33739f606849Smrg	  allow_undefined_flag="$no_undefined_flag"
33749f606849Smrg	fi
33759f606849Smrg      fi
33769f606849Smrg
33779f606849Smrg      if test "$mode" != relink; then
33789f606849Smrg	# Remove our outputs, but don't remove object files since they
33799f606849Smrg	# may have been created when compiling PIC objects.
33809f606849Smrg	removelist=
33819f606849Smrg	tempremovelist=`$echo "$output_objdir/*"`
33829f606849Smrg	for p in $tempremovelist; do
33839f606849Smrg	  case $p in
33849f606849Smrg	    *.$objext)
33859f606849Smrg	       ;;
33869f606849Smrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
33879f606849Smrg	       if test "X$precious_files_regex" != "X"; then
33889f606849Smrg	         if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
33899f606849Smrg	         then
33909f606849Smrg		   continue
33919f606849Smrg		 fi
33929f606849Smrg	       fi
33939f606849Smrg	       removelist="$removelist $p"
33949f606849Smrg	       ;;
33959f606849Smrg	    *) ;;
33969f606849Smrg	  esac
33979f606849Smrg	done
33989f606849Smrg	if test -n "$removelist"; then
33999f606849Smrg	  $show "${rm}r $removelist"
34009f606849Smrg	  $run ${rm}r $removelist
34019f606849Smrg	fi
34029f606849Smrg      fi
34039f606849Smrg
34049f606849Smrg      # Now set the variables for building old libraries.
34059f606849Smrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
34069f606849Smrg	oldlibs="$oldlibs $output_objdir/$libname.$libext"
34079f606849Smrg
34089f606849Smrg	# Transform .lo files to .o files.
34099f606849Smrg	oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
34109f606849Smrg      fi
34119f606849Smrg
34129f606849Smrg      # Eliminate all temporary directories.
34139f606849Smrg      for path in $notinst_path; do
34149f606849Smrg	lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"`
34159f606849Smrg	deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"`
34169f606849Smrg	dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"`
34179f606849Smrg      done
34189f606849Smrg
34199f606849Smrg      if test -n "$xrpath"; then
34209f606849Smrg	# If the user specified any rpath flags, then add them.
34219f606849Smrg	temp_xrpath=
34229f606849Smrg	for libdir in $xrpath; do
34239f606849Smrg	  temp_xrpath="$temp_xrpath -R$libdir"
34249f606849Smrg	  case "$finalize_rpath " in
34259f606849Smrg	  *" $libdir "*) ;;
34269f606849Smrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
34279f606849Smrg	  esac
34289f606849Smrg	done
34299f606849Smrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
34309f606849Smrg	  dependency_libs="$temp_xrpath $dependency_libs"
34319f606849Smrg	fi
34329f606849Smrg      fi
34339f606849Smrg
34349f606849Smrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
34359f606849Smrg      old_dlfiles="$dlfiles"
34369f606849Smrg      dlfiles=
34379f606849Smrg      for lib in $old_dlfiles; do
34389f606849Smrg	case " $dlprefiles $dlfiles " in
34399f606849Smrg	*" $lib "*) ;;
34409f606849Smrg	*) dlfiles="$dlfiles $lib" ;;
34419f606849Smrg	esac
34429f606849Smrg      done
34439f606849Smrg
34449f606849Smrg      # Make sure dlprefiles contains only unique files
34459f606849Smrg      old_dlprefiles="$dlprefiles"
34469f606849Smrg      dlprefiles=
34479f606849Smrg      for lib in $old_dlprefiles; do
34489f606849Smrg	case "$dlprefiles " in
34499f606849Smrg	*" $lib "*) ;;
34509f606849Smrg	*) dlprefiles="$dlprefiles $lib" ;;
34519f606849Smrg	esac
34529f606849Smrg      done
34539f606849Smrg
34549f606849Smrg      if test "$build_libtool_libs" = yes; then
34559f606849Smrg	if test -n "$rpath"; then
34569f606849Smrg	  case $host in
34579f606849Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*)
34589f606849Smrg	    # these systems don't actually have a c library (as such)!
34599f606849Smrg	    ;;
34609f606849Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
34619f606849Smrg	    # Rhapsody C library is in the System framework
34629f606849Smrg	    deplibs="$deplibs -framework System"
34639f606849Smrg	    ;;
34649f606849Smrg	  *-*-netbsd*)
34659f606849Smrg	    # Don't link with libc until the a.out ld.so is fixed.
34669f606849Smrg	    ;;
34679f606849Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
34689f606849Smrg	    # Do not include libc due to us having libc/libc_r.
34699f606849Smrg	    ;;
34709f606849Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
34719f606849Smrg	    # Causes problems with __ctype
34729f606849Smrg	    ;;
34739f606849Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
34749f606849Smrg	    # Compiler inserts libc in the correct place for threads to work
34759f606849Smrg	    ;;
34769f606849Smrg 	  *)
34779f606849Smrg	    # Add libc to deplibs on all other systems if necessary.
34789f606849Smrg	    if test "$build_libtool_need_lc" = "yes"; then
34799f606849Smrg	      deplibs="$deplibs -lc"
34809f606849Smrg	    fi
34819f606849Smrg	    ;;
34829f606849Smrg	  esac
34839f606849Smrg	fi
34849f606849Smrg
34859f606849Smrg	# Transform deplibs into only deplibs that can be linked in shared.
34869f606849Smrg	name_save=$name
34879f606849Smrg	libname_save=$libname
34889f606849Smrg	release_save=$release
34899f606849Smrg	versuffix_save=$versuffix
34909f606849Smrg	major_save=$major
34919f606849Smrg	# I'm not sure if I'm treating the release correctly.  I think
34929f606849Smrg	# release should show up in the -l (ie -lgmp5) so we don't want to
34939f606849Smrg	# add it in twice.  Is that correct?
34949f606849Smrg	release=""
34959f606849Smrg	versuffix=""
34969f606849Smrg	major=""
34979f606849Smrg	newdeplibs=
34989f606849Smrg	droppeddeps=no
34999f606849Smrg	case $deplibs_check_method in
35009f606849Smrg	pass_all)
35019f606849Smrg	  # Don't check for shared/static.  Everything works.
35029f606849Smrg	  # This might be a little naive.  We might want to check
35039f606849Smrg	  # whether the library exists or not.  But this is on
35049f606849Smrg	  # osf3 & osf4 and I'm not really sure... Just
35059f606849Smrg	  # implementing what was already the behavior.
35069f606849Smrg	  newdeplibs=$deplibs
35079f606849Smrg	  ;;
35089f606849Smrg	test_compile)
35099f606849Smrg	  # This code stresses the "libraries are programs" paradigm to its
35109f606849Smrg	  # limits. Maybe even breaks it.  We compile a program, linking it
35119f606849Smrg	  # against the deplibs as a proxy for the library.  Then we can check
35129f606849Smrg	  # whether they linked in statically or dynamically with ldd.
35139f606849Smrg	  $rm conftest.c
35149f606849Smrg	  cat > conftest.c <<EOF
35159f606849Smrg	  int main() { return 0; }
35169f606849SmrgEOF
35179f606849Smrg	  $rm conftest
35189f606849Smrg	  $LTCC $LTCFLAGS -o conftest conftest.c $deplibs
35199f606849Smrg	  if test "$?" -eq 0 ; then
35209f606849Smrg	    ldd_output=`ldd conftest`
35219f606849Smrg	    for i in $deplibs; do
35229f606849Smrg	      name=`expr $i : '-l\(.*\)'`
35239f606849Smrg	      # If $name is empty we are operating on a -L argument.
35249f606849Smrg              if test "$name" != "" && test "$name" -ne "0"; then
35259f606849Smrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
35269f606849Smrg		  case " $predeps $postdeps " in
35279f606849Smrg		  *" $i "*)
35289f606849Smrg		    newdeplibs="$newdeplibs $i"
35299f606849Smrg		    i=""
35309f606849Smrg		    ;;
35319f606849Smrg		  esac
35329f606849Smrg	        fi
35339f606849Smrg		if test -n "$i" ; then
35349f606849Smrg		  libname=`eval \\$echo \"$libname_spec\"`
35359f606849Smrg		  deplib_matches=`eval \\$echo \"$library_names_spec\"`
35369f606849Smrg		  set dummy $deplib_matches
35379f606849Smrg		  deplib_match=$2
35389f606849Smrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
35399f606849Smrg		    newdeplibs="$newdeplibs $i"
35409f606849Smrg		  else
35419f606849Smrg		    droppeddeps=yes
35429f606849Smrg		    $echo
35439f606849Smrg		    $echo "*** Warning: dynamic linker does not accept needed library $i."
35449f606849Smrg		    $echo "*** I have the capability to make that library automatically link in when"
35459f606849Smrg		    $echo "*** you link to this library.  But I can only do this if you have a"
35469f606849Smrg		    $echo "*** shared version of the library, which I believe you do not have"
35479f606849Smrg		    $echo "*** because a test_compile did reveal that the linker did not use it for"
35489f606849Smrg		    $echo "*** its dynamic dependency list that programs get resolved with at runtime."
35499f606849Smrg		  fi
35509f606849Smrg		fi
35519f606849Smrg	      else
35529f606849Smrg		newdeplibs="$newdeplibs $i"
35539f606849Smrg	      fi
35549f606849Smrg	    done
35559f606849Smrg	  else
35569f606849Smrg	    # Error occurred in the first compile.  Let's try to salvage
35579f606849Smrg	    # the situation: Compile a separate program for each library.
35589f606849Smrg	    for i in $deplibs; do
35599f606849Smrg	      name=`expr $i : '-l\(.*\)'`
35609f606849Smrg	      # If $name is empty we are operating on a -L argument.
35619f606849Smrg              if test "$name" != "" && test "$name" != "0"; then
35629f606849Smrg		$rm conftest
35639f606849Smrg		$LTCC $LTCFLAGS -o conftest conftest.c $i
35649f606849Smrg		# Did it work?
35659f606849Smrg		if test "$?" -eq 0 ; then
35669f606849Smrg		  ldd_output=`ldd conftest`
35679f606849Smrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
35689f606849Smrg		    case " $predeps $postdeps " in
35699f606849Smrg		    *" $i "*)
35709f606849Smrg		      newdeplibs="$newdeplibs $i"
35719f606849Smrg		      i=""
35729f606849Smrg		      ;;
35739f606849Smrg		    esac
35749f606849Smrg		  fi
35759f606849Smrg		  if test -n "$i" ; then
35769f606849Smrg		    libname=`eval \\$echo \"$libname_spec\"`
35779f606849Smrg		    deplib_matches=`eval \\$echo \"$library_names_spec\"`
35789f606849Smrg		    set dummy $deplib_matches
35799f606849Smrg		    deplib_match=$2
35809f606849Smrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
35819f606849Smrg		      newdeplibs="$newdeplibs $i"
35829f606849Smrg		    else
35839f606849Smrg		      droppeddeps=yes
35849f606849Smrg		      $echo
35859f606849Smrg		      $echo "*** Warning: dynamic linker does not accept needed library $i."
35869f606849Smrg		      $echo "*** I have the capability to make that library automatically link in when"
35879f606849Smrg		      $echo "*** you link to this library.  But I can only do this if you have a"
35889f606849Smrg		      $echo "*** shared version of the library, which you do not appear to have"
35899f606849Smrg		      $echo "*** because a test_compile did reveal that the linker did not use this one"
35909f606849Smrg		      $echo "*** as a dynamic dependency that programs can get resolved with at runtime."
35919f606849Smrg		    fi
35929f606849Smrg		  fi
35939f606849Smrg		else
35949f606849Smrg		  droppeddeps=yes
35959f606849Smrg		  $echo
35969f606849Smrg		  $echo "*** Warning!  Library $i is needed by this library but I was not able to"
35979f606849Smrg		  $echo "***  make it link in!  You will probably need to install it or some"
35989f606849Smrg		  $echo "*** library that it depends on before this library will be fully"
35999f606849Smrg		  $echo "*** functional.  Installing it before continuing would be even better."
36009f606849Smrg		fi
36019f606849Smrg	      else
36029f606849Smrg		newdeplibs="$newdeplibs $i"
36039f606849Smrg	      fi
36049f606849Smrg	    done
36059f606849Smrg	  fi
36069f606849Smrg	  ;;
36079f606849Smrg	file_magic*)
36089f606849Smrg	  set dummy $deplibs_check_method
36099f606849Smrg	  file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
36109f606849Smrg	  for a_deplib in $deplibs; do
36119f606849Smrg	    name=`expr $a_deplib : '-l\(.*\)'`
36129f606849Smrg	    # If $name is empty we are operating on a -L argument.
36139f606849Smrg            if test "$name" != "" && test  "$name" != "0"; then
36149f606849Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
36159f606849Smrg		case " $predeps $postdeps " in
36169f606849Smrg		*" $a_deplib "*)
36179f606849Smrg		  newdeplibs="$newdeplibs $a_deplib"
36189f606849Smrg		  a_deplib=""
36199f606849Smrg		  ;;
36209f606849Smrg		esac
36219f606849Smrg	      fi
36229f606849Smrg	      if test -n "$a_deplib" ; then
36239f606849Smrg		libname=`eval \\$echo \"$libname_spec\"`
36249f606849Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
36259f606849Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
36269f606849Smrg		  for potent_lib in $potential_libs; do
36279f606849Smrg		      # Follow soft links.
36289f606849Smrg		      if ls -lLd "$potent_lib" 2>/dev/null \
36299f606849Smrg			 | grep " -> " >/dev/null; then
36309f606849Smrg			continue
36319f606849Smrg		      fi
36329f606849Smrg		      # The statement above tries to avoid entering an
36339f606849Smrg		      # endless loop below, in case of cyclic links.
36349f606849Smrg		      # We might still enter an endless loop, since a link
36359f606849Smrg		      # loop can be closed while we follow links,
36369f606849Smrg		      # but so what?
36379f606849Smrg		      potlib="$potent_lib"
36389f606849Smrg		      while test -h "$potlib" 2>/dev/null; do
36399f606849Smrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
36409f606849Smrg			case $potliblink in
36419f606849Smrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
36429f606849Smrg			*) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
36439f606849Smrg			esac
36449f606849Smrg		      done
36459f606849Smrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
36469f606849Smrg			 | ${SED} 10q \
36479f606849Smrg			 | $EGREP "$file_magic_regex" > /dev/null; then
36489f606849Smrg			newdeplibs="$newdeplibs $a_deplib"
36499f606849Smrg			a_deplib=""
36509f606849Smrg			break 2
36519f606849Smrg		      fi
36529f606849Smrg		  done
36539f606849Smrg		done
36549f606849Smrg	      fi
36559f606849Smrg	      if test -n "$a_deplib" ; then
36569f606849Smrg		droppeddeps=yes
36579f606849Smrg		$echo
36589f606849Smrg		$echo "*** Warning: linker path does not have real file for library $a_deplib."
36599f606849Smrg		$echo "*** I have the capability to make that library automatically link in when"
36609f606849Smrg		$echo "*** you link to this library.  But I can only do this if you have a"
36619f606849Smrg		$echo "*** shared version of the library, which you do not appear to have"
36629f606849Smrg		$echo "*** because I did check the linker path looking for a file starting"
36639f606849Smrg		if test -z "$potlib" ; then
36649f606849Smrg		  $echo "*** with $libname but no candidates were found. (...for file magic test)"
36659f606849Smrg		else
36669f606849Smrg		  $echo "*** with $libname and none of the candidates passed a file format test"
36679f606849Smrg		  $echo "*** using a file magic. Last file checked: $potlib"
36689f606849Smrg		fi
36699f606849Smrg	      fi
36709f606849Smrg	    else
36719f606849Smrg	      # Add a -L argument.
36729f606849Smrg	      newdeplibs="$newdeplibs $a_deplib"
36739f606849Smrg	    fi
36749f606849Smrg	  done # Gone through all deplibs.
36759f606849Smrg	  ;;
36769f606849Smrg	match_pattern*)
36779f606849Smrg	  set dummy $deplibs_check_method
36789f606849Smrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
36799f606849Smrg	  for a_deplib in $deplibs; do
36809f606849Smrg	    name=`expr $a_deplib : '-l\(.*\)'`
36819f606849Smrg	    # If $name is empty we are operating on a -L argument.
36829f606849Smrg	    if test -n "$name" && test "$name" != "0"; then
36839f606849Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
36849f606849Smrg		case " $predeps $postdeps " in
36859f606849Smrg		*" $a_deplib "*)
36869f606849Smrg		  newdeplibs="$newdeplibs $a_deplib"
36879f606849Smrg		  a_deplib=""
36889f606849Smrg		  ;;
36899f606849Smrg		esac
36909f606849Smrg	      fi
36919f606849Smrg	      if test -n "$a_deplib" ; then
36929f606849Smrg		libname=`eval \\$echo \"$libname_spec\"`
36939f606849Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
36949f606849Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
36959f606849Smrg		  for potent_lib in $potential_libs; do
36969f606849Smrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
36979f606849Smrg		    if eval $echo \"$potent_lib\" 2>/dev/null \
36989f606849Smrg		        | ${SED} 10q \
36999f606849Smrg		        | $EGREP "$match_pattern_regex" > /dev/null; then
37009f606849Smrg		      newdeplibs="$newdeplibs $a_deplib"
37019f606849Smrg		      a_deplib=""
37029f606849Smrg		      break 2
37039f606849Smrg		    fi
37049f606849Smrg		  done
37059f606849Smrg		done
37069f606849Smrg	      fi
37079f606849Smrg	      if test -n "$a_deplib" ; then
37089f606849Smrg		droppeddeps=yes
37099f606849Smrg		$echo
37109f606849Smrg		$echo "*** Warning: linker path does not have real file for library $a_deplib."
37119f606849Smrg		$echo "*** I have the capability to make that library automatically link in when"
37129f606849Smrg		$echo "*** you link to this library.  But I can only do this if you have a"
37139f606849Smrg		$echo "*** shared version of the library, which you do not appear to have"
37149f606849Smrg		$echo "*** because I did check the linker path looking for a file starting"
37159f606849Smrg		if test -z "$potlib" ; then
37169f606849Smrg		  $echo "*** with $libname but no candidates were found. (...for regex pattern test)"
37179f606849Smrg		else
37189f606849Smrg		  $echo "*** with $libname and none of the candidates passed a file format test"
37199f606849Smrg		  $echo "*** using a regex pattern. Last file checked: $potlib"
37209f606849Smrg		fi
37219f606849Smrg	      fi
37229f606849Smrg	    else
37239f606849Smrg	      # Add a -L argument.
37249f606849Smrg	      newdeplibs="$newdeplibs $a_deplib"
37259f606849Smrg	    fi
37269f606849Smrg	  done # Gone through all deplibs.
37279f606849Smrg	  ;;
37289f606849Smrg	none | unknown | *)
37299f606849Smrg	  newdeplibs=""
37309f606849Smrg	  tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
37319f606849Smrg	    -e 's/ -[LR][^ ]*//g'`
37329f606849Smrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
37339f606849Smrg	    for i in $predeps $postdeps ; do
37349f606849Smrg	      # can't use Xsed below, because $i might contain '/'
37359f606849Smrg	      tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"`
37369f606849Smrg	    done
37379f606849Smrg	  fi
37389f606849Smrg	  if $echo "X $tmp_deplibs" | $Xsed -e 's/[ 	]//g' \
37399f606849Smrg	    | grep . >/dev/null; then
37409f606849Smrg	    $echo
37419f606849Smrg	    if test "X$deplibs_check_method" = "Xnone"; then
37429f606849Smrg	      $echo "*** Warning: inter-library dependencies are not supported in this platform."
37439f606849Smrg	    else
37449f606849Smrg	      $echo "*** Warning: inter-library dependencies are not known to be supported."
37459f606849Smrg	    fi
37469f606849Smrg	    $echo "*** All declared inter-library dependencies are being dropped."
37479f606849Smrg	    droppeddeps=yes
37489f606849Smrg	  fi
37499f606849Smrg	  ;;
37509f606849Smrg	esac
37519f606849Smrg	versuffix=$versuffix_save
37529f606849Smrg	major=$major_save
37539f606849Smrg	release=$release_save
37549f606849Smrg	libname=$libname_save
37559f606849Smrg	name=$name_save
37569f606849Smrg
37579f606849Smrg	case $host in
37589f606849Smrg	*-*-rhapsody* | *-*-darwin1.[012])
37599f606849Smrg	  # On Rhapsody replace the C library is the System framework
37609f606849Smrg	  newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'`
37619f606849Smrg	  ;;
37629f606849Smrg	esac
37639f606849Smrg
37649f606849Smrg	if test "$droppeddeps" = yes; then
37659f606849Smrg	  if test "$module" = yes; then
37669f606849Smrg	    $echo
37679f606849Smrg	    $echo "*** Warning: libtool could not satisfy all declared inter-library"
37689f606849Smrg	    $echo "*** dependencies of module $libname.  Therefore, libtool will create"
37699f606849Smrg	    $echo "*** a static module, that should work as long as the dlopening"
37709f606849Smrg	    $echo "*** application is linked with the -dlopen flag."
37719f606849Smrg	    if test -z "$global_symbol_pipe"; then
37729f606849Smrg	      $echo
37739f606849Smrg	      $echo "*** However, this would only work if libtool was able to extract symbol"
37749f606849Smrg	      $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
37759f606849Smrg	      $echo "*** not find such a program.  So, this module is probably useless."
37769f606849Smrg	      $echo "*** \`nm' from GNU binutils and a full rebuild may help."
37779f606849Smrg	    fi
37789f606849Smrg	    if test "$build_old_libs" = no; then
37799f606849Smrg	      oldlibs="$output_objdir/$libname.$libext"
37809f606849Smrg	      build_libtool_libs=module
37819f606849Smrg	      build_old_libs=yes
37829f606849Smrg	    else
37839f606849Smrg	      build_libtool_libs=no
37849f606849Smrg	    fi
37859f606849Smrg	  else
37869f606849Smrg	    $echo "*** The inter-library dependencies that have been dropped here will be"
37879f606849Smrg	    $echo "*** automatically added whenever a program is linked with this library"
37889f606849Smrg	    $echo "*** or is declared to -dlopen it."
37899f606849Smrg
37909f606849Smrg	    if test "$allow_undefined" = no; then
37919f606849Smrg	      $echo
37929f606849Smrg	      $echo "*** Since this library must not contain undefined symbols,"
37939f606849Smrg	      $echo "*** because either the platform does not support them or"
37949f606849Smrg	      $echo "*** it was explicitly requested with -no-undefined,"
37959f606849Smrg	      $echo "*** libtool will only create a static version of it."
37969f606849Smrg	      if test "$build_old_libs" = no; then
37979f606849Smrg		oldlibs="$output_objdir/$libname.$libext"
37989f606849Smrg		build_libtool_libs=module
37999f606849Smrg		build_old_libs=yes
38009f606849Smrg	      else
38019f606849Smrg		build_libtool_libs=no
38029f606849Smrg	      fi
38039f606849Smrg	    fi
38049f606849Smrg	  fi
38059f606849Smrg	fi
38069f606849Smrg	# Done checking deplibs!
38079f606849Smrg	deplibs=$newdeplibs
38089f606849Smrg      fi
38099f606849Smrg
38109f606849Smrg
38119f606849Smrg      # move library search paths that coincide with paths to not yet
38129f606849Smrg      # installed libraries to the beginning of the library search list
38139f606849Smrg      new_libs=
38149f606849Smrg      for path in $notinst_path; do
38159f606849Smrg	case " $new_libs " in
38169f606849Smrg	*" -L$path/$objdir "*) ;;
38179f606849Smrg	*)
38189f606849Smrg	  case " $deplibs " in
38199f606849Smrg	  *" -L$path/$objdir "*)
38209f606849Smrg	    new_libs="$new_libs -L$path/$objdir" ;;
38219f606849Smrg	  esac
38229f606849Smrg	  ;;
38239f606849Smrg	esac
38249f606849Smrg      done
38259f606849Smrg      for deplib in $deplibs; do
38269f606849Smrg	case $deplib in
38279f606849Smrg	-L*)
38289f606849Smrg	  case " $new_libs " in
38299f606849Smrg	  *" $deplib "*) ;;
38309f606849Smrg	  *) new_libs="$new_libs $deplib" ;;
38319f606849Smrg	  esac
38329f606849Smrg	  ;;
38339f606849Smrg	*) new_libs="$new_libs $deplib" ;;
38349f606849Smrg	esac
38359f606849Smrg      done
38369f606849Smrg      deplibs="$new_libs"
38379f606849Smrg
38389f606849Smrg
38399f606849Smrg      # All the library-specific variables (install_libdir is set above).
38409f606849Smrg      library_names=
38419f606849Smrg      old_library=
38429f606849Smrg      dlname=
38439f606849Smrg
38449f606849Smrg      # Test again, we may have decided not to build it any more
38459f606849Smrg      if test "$build_libtool_libs" = yes; then
38469f606849Smrg	if test "$hardcode_into_libs" = yes; then
38479f606849Smrg	  # Hardcode the library paths
38489f606849Smrg	  hardcode_libdirs=
38499f606849Smrg	  dep_rpath=
38509f606849Smrg	  rpath="$finalize_rpath"
38519f606849Smrg	  test "$mode" != relink && rpath="$compile_rpath$rpath"
38529f606849Smrg	  for libdir in $rpath; do
38539f606849Smrg	    if test -n "$hardcode_libdir_flag_spec"; then
38549f606849Smrg	      if test -n "$hardcode_libdir_separator"; then
38559f606849Smrg		if test -z "$hardcode_libdirs"; then
38569f606849Smrg		  hardcode_libdirs="$libdir"
38579f606849Smrg		else
38589f606849Smrg		  # Just accumulate the unique libdirs.
38599f606849Smrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
38609f606849Smrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
38619f606849Smrg		    ;;
38629f606849Smrg		  *)
38639f606849Smrg		    hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
38649f606849Smrg		    ;;
38659f606849Smrg		  esac
38669f606849Smrg		fi
38679f606849Smrg	      else
38689f606849Smrg		eval flag=\"$hardcode_libdir_flag_spec\"
38699f606849Smrg		dep_rpath="$dep_rpath $flag"
38709f606849Smrg	      fi
38719f606849Smrg	    elif test -n "$runpath_var"; then
38729f606849Smrg	      case "$perm_rpath " in
38739f606849Smrg	      *" $libdir "*) ;;
38749f606849Smrg	      *) perm_rpath="$perm_rpath $libdir" ;;
38759f606849Smrg	      esac
38769f606849Smrg	    fi
38779f606849Smrg	  done
38789f606849Smrg	  # Substitute the hardcoded libdirs into the rpath.
38799f606849Smrg	  if test -n "$hardcode_libdir_separator" &&
38809f606849Smrg	     test -n "$hardcode_libdirs"; then
38819f606849Smrg	    libdir="$hardcode_libdirs"
38829f606849Smrg	    if test -n "$hardcode_libdir_flag_spec_ld"; then
38839f606849Smrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
38849f606849Smrg	    else
38859f606849Smrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
38869f606849Smrg	    fi
38879f606849Smrg	  fi
38889f606849Smrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
38899f606849Smrg	    # We should set the runpath_var.
38909f606849Smrg	    rpath=
38919f606849Smrg	    for dir in $perm_rpath; do
38929f606849Smrg	      rpath="$rpath$dir:"
38939f606849Smrg	    done
38949f606849Smrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
38959f606849Smrg	  fi
38969f606849Smrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
38979f606849Smrg	fi
38989f606849Smrg
38999f606849Smrg	shlibpath="$finalize_shlibpath"
39009f606849Smrg	test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
39019f606849Smrg	if test -n "$shlibpath"; then
39029f606849Smrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
39039f606849Smrg	fi
39049f606849Smrg
39059f606849Smrg	# Get the real and link names of the library.
39069f606849Smrg	eval shared_ext=\"$shrext_cmds\"
39079f606849Smrg	eval library_names=\"$library_names_spec\"
39089f606849Smrg	set dummy $library_names
39099f606849Smrg	realname="$2"
39109f606849Smrg	shift; shift
39119f606849Smrg
39129f606849Smrg	if test -n "$soname_spec"; then
39139f606849Smrg	  eval soname=\"$soname_spec\"
39149f606849Smrg	else
39159f606849Smrg	  soname="$realname"
39169f606849Smrg	fi
39179f606849Smrg	if test -z "$dlname"; then
39189f606849Smrg	  dlname=$soname
39199f606849Smrg	fi
39209f606849Smrg
39219f606849Smrg	lib="$output_objdir/$realname"
39229f606849Smrg	linknames=
39239f606849Smrg	for link
39249f606849Smrg	do
39259f606849Smrg	  linknames="$linknames $link"
39269f606849Smrg	done
39279f606849Smrg
39289f606849Smrg	# Use standard objects if they are pic
39299f606849Smrg	test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
39309f606849Smrg
39319f606849Smrg	# Prepare the list of exported symbols
39329f606849Smrg	if test -z "$export_symbols"; then
39339f606849Smrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
39349f606849Smrg	    $show "generating symbol list for \`$libname.la'"
39359f606849Smrg	    export_symbols="$output_objdir/$libname.exp"
39369f606849Smrg	    $run $rm $export_symbols
39379f606849Smrg	    cmds=$export_symbols_cmds
39389f606849Smrg	    save_ifs="$IFS"; IFS='~'
39399f606849Smrg	    for cmd in $cmds; do
39409f606849Smrg	      IFS="$save_ifs"
39419f606849Smrg	      eval cmd=\"$cmd\"
39429f606849Smrg	      if len=`expr "X$cmd" : ".*"` &&
39439f606849Smrg	       test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
39449f606849Smrg	        $show "$cmd"
39459f606849Smrg	        $run eval "$cmd" || exit $?
39469f606849Smrg	        skipped_export=false
39479f606849Smrg	      else
39489f606849Smrg	        # The command line is too long to execute in one step.
39499f606849Smrg	        $show "using reloadable object file for export list..."
39509f606849Smrg	        skipped_export=:
39519f606849Smrg		# Break out early, otherwise skipped_export may be
39529f606849Smrg		# set to false by a later but shorter cmd.
39539f606849Smrg		break
39549f606849Smrg	      fi
39559f606849Smrg	    done
39569f606849Smrg	    IFS="$save_ifs"
39579f606849Smrg	    if test -n "$export_symbols_regex"; then
39589f606849Smrg	      $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""
39599f606849Smrg	      $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
39609f606849Smrg	      $show "$mv \"${export_symbols}T\" \"$export_symbols\""
39619f606849Smrg	      $run eval '$mv "${export_symbols}T" "$export_symbols"'
39629f606849Smrg	    fi
39639f606849Smrg	  fi
39649f606849Smrg	fi
39659f606849Smrg
39669f606849Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
39679f606849Smrg	  $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"'
39689f606849Smrg	fi
39699f606849Smrg
39709f606849Smrg	tmp_deplibs=
39719f606849Smrg	for test_deplib in $deplibs; do
39729f606849Smrg		case " $convenience " in
39739f606849Smrg		*" $test_deplib "*) ;;
39749f606849Smrg		*)
39759f606849Smrg			tmp_deplibs="$tmp_deplibs $test_deplib"
39769f606849Smrg			;;
39779f606849Smrg		esac
39789f606849Smrg	done
39799f606849Smrg	deplibs="$tmp_deplibs"
39809f606849Smrg
39819f606849Smrg	if test -n "$convenience"; then
39829f606849Smrg	  if test -n "$whole_archive_flag_spec"; then
39839f606849Smrg	    save_libobjs=$libobjs
39849f606849Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
39859f606849Smrg	  else
39869f606849Smrg	    gentop="$output_objdir/${outputname}x"
39879f606849Smrg	    generated="$generated $gentop"
39889f606849Smrg
39899f606849Smrg	    func_extract_archives $gentop $convenience
39909f606849Smrg	    libobjs="$libobjs $func_extract_archives_result"
39919f606849Smrg	  fi
39929f606849Smrg	fi
39939f606849Smrg	
39949f606849Smrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
39959f606849Smrg	  eval flag=\"$thread_safe_flag_spec\"
39969f606849Smrg	  linker_flags="$linker_flags $flag"
39979f606849Smrg	fi
39989f606849Smrg
39999f606849Smrg	# Make a backup of the uninstalled library when relinking
40009f606849Smrg	if test "$mode" = relink; then
40019f606849Smrg	  $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $?
40029f606849Smrg	fi
40039f606849Smrg
40049f606849Smrg	# Do each of the archive commands.
40059f606849Smrg	if test "$module" = yes && test -n "$module_cmds" ; then
40069f606849Smrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
40079f606849Smrg	    eval test_cmds=\"$module_expsym_cmds\"
40089f606849Smrg	    cmds=$module_expsym_cmds
40099f606849Smrg	  else
40109f606849Smrg	    eval test_cmds=\"$module_cmds\"
40119f606849Smrg	    cmds=$module_cmds
40129f606849Smrg	  fi
40139f606849Smrg	else
40149f606849Smrg	if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
40159f606849Smrg	  eval test_cmds=\"$archive_expsym_cmds\"
40169f606849Smrg	  cmds=$archive_expsym_cmds
40179f606849Smrg	else
40189f606849Smrg	  eval test_cmds=\"$archive_cmds\"
40199f606849Smrg	  cmds=$archive_cmds
40209f606849Smrg	  fi
40219f606849Smrg	fi
40229f606849Smrg
40239f606849Smrg	if test "X$skipped_export" != "X:" &&
40249f606849Smrg	   len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
40259f606849Smrg	   test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
40269f606849Smrg	  :
40279f606849Smrg	else
40289f606849Smrg	  # The command line is too long to link in one step, link piecewise.
40299f606849Smrg	  $echo "creating reloadable object files..."
40309f606849Smrg
40319f606849Smrg	  # Save the value of $output and $libobjs because we want to
40329f606849Smrg	  # use them later.  If we have whole_archive_flag_spec, we
40339f606849Smrg	  # want to use save_libobjs as it was before
40349f606849Smrg	  # whole_archive_flag_spec was expanded, because we can't
40359f606849Smrg	  # assume the linker understands whole_archive_flag_spec.
40369f606849Smrg	  # This may have to be revisited, in case too many
40379f606849Smrg	  # convenience libraries get linked in and end up exceeding
40389f606849Smrg	  # the spec.
40399f606849Smrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
40409f606849Smrg	    save_libobjs=$libobjs
40419f606849Smrg	  fi
40429f606849Smrg	  save_output=$output
40439f606849Smrg	  output_la=`$echo "X$output" | $Xsed -e "$basename"`
40449f606849Smrg
40459f606849Smrg	  # Clear the reloadable object creation command queue and
40469f606849Smrg	  # initialize k to one.
40479f606849Smrg	  test_cmds=
40489f606849Smrg	  concat_cmds=
40499f606849Smrg	  objlist=
40509f606849Smrg	  delfiles=
40519f606849Smrg	  last_robj=
40529f606849Smrg	  k=1
40539f606849Smrg	  output=$output_objdir/$output_la-${k}.$objext
40549f606849Smrg	  # Loop over the list of objects to be linked.
40559f606849Smrg	  for obj in $save_libobjs
40569f606849Smrg	  do
40579f606849Smrg	    eval test_cmds=\"$reload_cmds $objlist $last_robj\"
40589f606849Smrg	    if test "X$objlist" = X ||
40599f606849Smrg	       { len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
40609f606849Smrg		 test "$len" -le "$max_cmd_len"; }; then
40619f606849Smrg	      objlist="$objlist $obj"
40629f606849Smrg	    else
40639f606849Smrg	      # The command $test_cmds is almost too long, add a
40649f606849Smrg	      # command to the queue.
40659f606849Smrg	      if test "$k" -eq 1 ; then
40669f606849Smrg		# The first file doesn't have a previous command to add.
40679f606849Smrg		eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
40689f606849Smrg	      else
40699f606849Smrg		# All subsequent reloadable object files will link in
40709f606849Smrg		# the last one created.
40719f606849Smrg		eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\"
40729f606849Smrg	      fi
40739f606849Smrg	      last_robj=$output_objdir/$output_la-${k}.$objext
40749f606849Smrg	      k=`expr $k + 1`
40759f606849Smrg	      output=$output_objdir/$output_la-${k}.$objext
40769f606849Smrg	      objlist=$obj
40779f606849Smrg	      len=1
40789f606849Smrg	    fi
40799f606849Smrg	  done
40809f606849Smrg	  # Handle the remaining objects by creating one last
40819f606849Smrg	  # reloadable object file.  All subsequent reloadable object
40829f606849Smrg	  # files will link in the last one created.
40839f606849Smrg	  test -z "$concat_cmds" || concat_cmds=$concat_cmds~
40849f606849Smrg	  eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
40859f606849Smrg
40869f606849Smrg	  if ${skipped_export-false}; then
40879f606849Smrg	    $show "generating symbol list for \`$libname.la'"
40889f606849Smrg	    export_symbols="$output_objdir/$libname.exp"
40899f606849Smrg	    $run $rm $export_symbols
40909f606849Smrg	    libobjs=$output
40919f606849Smrg	    # Append the command to create the export file.
40929f606849Smrg	    eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\"
40939f606849Smrg          fi
40949f606849Smrg
40959f606849Smrg	  # Set up a command to remove the reloadable object files
40969f606849Smrg	  # after they are used.
40979f606849Smrg	  i=0
40989f606849Smrg	  while test "$i" -lt "$k"
40999f606849Smrg	  do
41009f606849Smrg	    i=`expr $i + 1`
41019f606849Smrg	    delfiles="$delfiles $output_objdir/$output_la-${i}.$objext"
41029f606849Smrg	  done
41039f606849Smrg
41049f606849Smrg	  $echo "creating a temporary reloadable object file: $output"
41059f606849Smrg
41069f606849Smrg	  # Loop through the commands generated above and execute them.
41079f606849Smrg	  save_ifs="$IFS"; IFS='~'
41089f606849Smrg	  for cmd in $concat_cmds; do
41099f606849Smrg	    IFS="$save_ifs"
41109f606849Smrg	    $show "$cmd"
41119f606849Smrg	    $run eval "$cmd" || exit $?
41129f606849Smrg	  done
41139f606849Smrg	  IFS="$save_ifs"
41149f606849Smrg
41159f606849Smrg	  libobjs=$output
41169f606849Smrg	  # Restore the value of output.
41179f606849Smrg	  output=$save_output
41189f606849Smrg
41199f606849Smrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
41209f606849Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
41219f606849Smrg	  fi
41229f606849Smrg	  # Expand the library linking commands again to reset the
41239f606849Smrg	  # value of $libobjs for piecewise linking.
41249f606849Smrg
41259f606849Smrg	  # Do each of the archive commands.
41269f606849Smrg	  if test "$module" = yes && test -n "$module_cmds" ; then
41279f606849Smrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
41289f606849Smrg	      cmds=$module_expsym_cmds
41299f606849Smrg	    else
41309f606849Smrg	      cmds=$module_cmds
41319f606849Smrg	    fi
41329f606849Smrg	  else
41339f606849Smrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
41349f606849Smrg	    cmds=$archive_expsym_cmds
41359f606849Smrg	  else
41369f606849Smrg	    cmds=$archive_cmds
41379f606849Smrg	    fi
41389f606849Smrg	  fi
41399f606849Smrg
41409f606849Smrg	  # Append the command to remove the reloadable object files
41419f606849Smrg	  # to the just-reset $cmds.
41429f606849Smrg	  eval cmds=\"\$cmds~\$rm $delfiles\"
41439f606849Smrg	fi
41449f606849Smrg	save_ifs="$IFS"; IFS='~'
41459f606849Smrg	for cmd in $cmds; do
41469f606849Smrg	  IFS="$save_ifs"
41479f606849Smrg	  eval cmd=\"$cmd\"
41489f606849Smrg	  $show "$cmd"
41499f606849Smrg	  $run eval "$cmd" || {
41509f606849Smrg	    lt_exit=$?
41519f606849Smrg
41529f606849Smrg	    # Restore the uninstalled library and exit
41539f606849Smrg	    if test "$mode" = relink; then
41549f606849Smrg	      $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
41559f606849Smrg	    fi
41569f606849Smrg
41579f606849Smrg	    exit $lt_exit
41589f606849Smrg	  }
41599f606849Smrg	done
41609f606849Smrg	IFS="$save_ifs"
41619f606849Smrg
41629f606849Smrg	# Restore the uninstalled library and exit
41639f606849Smrg	if test "$mode" = relink; then
41649f606849Smrg	  $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $?
41659f606849Smrg
41669f606849Smrg	  if test -n "$convenience"; then
41679f606849Smrg	    if test -z "$whole_archive_flag_spec"; then
41689f606849Smrg	      $show "${rm}r $gentop"
41699f606849Smrg	      $run ${rm}r "$gentop"
41709f606849Smrg	    fi
41719f606849Smrg	  fi
41729f606849Smrg
41739f606849Smrg	  exit $EXIT_SUCCESS
41749f606849Smrg	fi
41759f606849Smrg
41769f606849Smrg	# Create links to the real library.
41779f606849Smrg	for linkname in $linknames; do
41789f606849Smrg	  if test "$realname" != "$linkname"; then
41799f606849Smrg	    $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)"
41809f606849Smrg	    $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $?
41819f606849Smrg	  fi
41829f606849Smrg	done
41839f606849Smrg
41849f606849Smrg	# If -module or -export-dynamic was specified, set the dlname.
41859f606849Smrg	if test "$module" = yes || test "$export_dynamic" = yes; then
41869f606849Smrg	  # On all known operating systems, these are identical.
41879f606849Smrg	  dlname="$soname"
41889f606849Smrg	fi
41899f606849Smrg      fi
41909f606849Smrg      ;;
41919f606849Smrg
41929f606849Smrg    obj)
41939f606849Smrg      if test -n "$deplibs"; then
41949f606849Smrg	$echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2
41959f606849Smrg      fi
41969f606849Smrg
41979f606849Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
41989f606849Smrg	$echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
41999f606849Smrg      fi
42009f606849Smrg
42019f606849Smrg      if test -n "$rpath"; then
42029f606849Smrg	$echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2
42039f606849Smrg      fi
42049f606849Smrg
42059f606849Smrg      if test -n "$xrpath"; then
42069f606849Smrg	$echo "$modename: warning: \`-R' is ignored for objects" 1>&2
42079f606849Smrg      fi
42089f606849Smrg
42099f606849Smrg      if test -n "$vinfo"; then
42109f606849Smrg	$echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2
42119f606849Smrg      fi
42129f606849Smrg
42139f606849Smrg      if test -n "$release"; then
42149f606849Smrg	$echo "$modename: warning: \`-release' is ignored for objects" 1>&2
42159f606849Smrg      fi
42169f606849Smrg
42179f606849Smrg      case $output in
42189f606849Smrg      *.lo)
42199f606849Smrg	if test -n "$objs$old_deplibs"; then
42209f606849Smrg	  $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
42219f606849Smrg	  exit $EXIT_FAILURE
42229f606849Smrg	fi
42239f606849Smrg	libobj="$output"
42249f606849Smrg	obj=`$echo "X$output" | $Xsed -e "$lo2o"`
42259f606849Smrg	;;
42269f606849Smrg      *)
42279f606849Smrg	libobj=
42289f606849Smrg	obj="$output"
42299f606849Smrg	;;
42309f606849Smrg      esac
42319f606849Smrg
42329f606849Smrg      # Delete the old objects.
42339f606849Smrg      $run $rm $obj $libobj
42349f606849Smrg
42359f606849Smrg      # Objects from convenience libraries.  This assumes
42369f606849Smrg      # single-version convenience libraries.  Whenever we create
42379f606849Smrg      # different ones for PIC/non-PIC, this we'll have to duplicate
42389f606849Smrg      # the extraction.
42399f606849Smrg      reload_conv_objs=
42409f606849Smrg      gentop=
42419f606849Smrg      # reload_cmds runs $LD directly, so let us get rid of
42429f606849Smrg      # -Wl from whole_archive_flag_spec
42439f606849Smrg      wl=
42449f606849Smrg
42459f606849Smrg      if test -n "$convenience"; then
42469f606849Smrg	if test -n "$whole_archive_flag_spec"; then
42479f606849Smrg	  eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
42489f606849Smrg	else
42499f606849Smrg	  gentop="$output_objdir/${obj}x"
42509f606849Smrg	  generated="$generated $gentop"
42519f606849Smrg
42529f606849Smrg	  func_extract_archives $gentop $convenience
42539f606849Smrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
42549f606849Smrg	fi
42559f606849Smrg      fi
42569f606849Smrg
42579f606849Smrg      # Create the old-style object.
42589f606849Smrg      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
42599f606849Smrg
42609f606849Smrg      output="$obj"
42619f606849Smrg      cmds=$reload_cmds
42629f606849Smrg      save_ifs="$IFS"; IFS='~'
42639f606849Smrg      for cmd in $cmds; do
42649f606849Smrg	IFS="$save_ifs"
42659f606849Smrg	eval cmd=\"$cmd\"
42669f606849Smrg	$show "$cmd"
42679f606849Smrg	$run eval "$cmd" || exit $?
42689f606849Smrg      done
42699f606849Smrg      IFS="$save_ifs"
42709f606849Smrg
42719f606849Smrg      # Exit if we aren't doing a library object file.
42729f606849Smrg      if test -z "$libobj"; then
42739f606849Smrg	if test -n "$gentop"; then
42749f606849Smrg	  $show "${rm}r $gentop"
42759f606849Smrg	  $run ${rm}r $gentop
42769f606849Smrg	fi
42779f606849Smrg
42789f606849Smrg	exit $EXIT_SUCCESS
42799f606849Smrg      fi
42809f606849Smrg
42819f606849Smrg      if test "$build_libtool_libs" != yes; then
42829f606849Smrg	if test -n "$gentop"; then
42839f606849Smrg	  $show "${rm}r $gentop"
42849f606849Smrg	  $run ${rm}r $gentop
42859f606849Smrg	fi
42869f606849Smrg
42879f606849Smrg	# Create an invalid libtool object if no PIC, so that we don't
42889f606849Smrg	# accidentally link it into a program.
42899f606849Smrg	# $show "echo timestamp > $libobj"
42909f606849Smrg	# $run eval "echo timestamp > $libobj" || exit $?
42919f606849Smrg	exit $EXIT_SUCCESS
42929f606849Smrg      fi
42939f606849Smrg
42949f606849Smrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
42959f606849Smrg	# Only do commands if we really have different PIC objects.
42969f606849Smrg	reload_objs="$libobjs $reload_conv_objs"
42979f606849Smrg	output="$libobj"
42989f606849Smrg	cmds=$reload_cmds
42999f606849Smrg	save_ifs="$IFS"; IFS='~'
43009f606849Smrg	for cmd in $cmds; do
43019f606849Smrg	  IFS="$save_ifs"
43029f606849Smrg	  eval cmd=\"$cmd\"
43039f606849Smrg	  $show "$cmd"
43049f606849Smrg	  $run eval "$cmd" || exit $?
43059f606849Smrg	done
43069f606849Smrg	IFS="$save_ifs"
43079f606849Smrg      fi
43089f606849Smrg
43099f606849Smrg      if test -n "$gentop"; then
43109f606849Smrg	$show "${rm}r $gentop"
43119f606849Smrg	$run ${rm}r $gentop
43129f606849Smrg      fi
43139f606849Smrg
43149f606849Smrg      exit $EXIT_SUCCESS
43159f606849Smrg      ;;
43169f606849Smrg
43179f606849Smrg    prog)
43189f606849Smrg      case $host in
43199f606849Smrg	*cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;
43209f606849Smrg      esac
43219f606849Smrg      if test -n "$vinfo"; then
43229f606849Smrg	$echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
43239f606849Smrg      fi
43249f606849Smrg
43259f606849Smrg      if test -n "$release"; then
43269f606849Smrg	$echo "$modename: warning: \`-release' is ignored for programs" 1>&2
43279f606849Smrg      fi
43289f606849Smrg
43299f606849Smrg      if test "$preload" = yes; then
43309f606849Smrg	if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown &&
43319f606849Smrg	   test "$dlopen_self_static" = unknown; then
43329f606849Smrg	  $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support."
43339f606849Smrg	fi
43349f606849Smrg      fi
43359f606849Smrg
43369f606849Smrg      case $host in
43379f606849Smrg      *-*-rhapsody* | *-*-darwin1.[012])
43389f606849Smrg	# On Rhapsody replace the C library is the System framework
43399f606849Smrg	compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
43409f606849Smrg	finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
43419f606849Smrg	;;
43429f606849Smrg      esac
43439f606849Smrg
43449f606849Smrg      case $host in
43459f606849Smrg      *darwin*)
43469f606849Smrg        # Don't allow lazy linking, it breaks C++ global constructors
43479f606849Smrg        if test "$tagname" = CXX ; then
43489f606849Smrg        compile_command="$compile_command ${wl}-bind_at_load"
43499f606849Smrg        finalize_command="$finalize_command ${wl}-bind_at_load"
43509f606849Smrg        fi
43519f606849Smrg        ;;
43529f606849Smrg      esac
43539f606849Smrg
43549f606849Smrg
43559f606849Smrg      # move library search paths that coincide with paths to not yet
43569f606849Smrg      # installed libraries to the beginning of the library search list
43579f606849Smrg      new_libs=
43589f606849Smrg      for path in $notinst_path; do
43599f606849Smrg	case " $new_libs " in
43609f606849Smrg	*" -L$path/$objdir "*) ;;
43619f606849Smrg	*)
43629f606849Smrg	  case " $compile_deplibs " in
43639f606849Smrg	  *" -L$path/$objdir "*)
43649f606849Smrg	    new_libs="$new_libs -L$path/$objdir" ;;
43659f606849Smrg	  esac
43669f606849Smrg	  ;;
43679f606849Smrg	esac
43689f606849Smrg      done
43699f606849Smrg      for deplib in $compile_deplibs; do
43709f606849Smrg	case $deplib in
43719f606849Smrg	-L*)
43729f606849Smrg	  case " $new_libs " in
43739f606849Smrg	  *" $deplib "*) ;;
43749f606849Smrg	  *) new_libs="$new_libs $deplib" ;;
43759f606849Smrg	  esac
43769f606849Smrg	  ;;
43779f606849Smrg	*) new_libs="$new_libs $deplib" ;;
43789f606849Smrg	esac
43799f606849Smrg      done
43809f606849Smrg      compile_deplibs="$new_libs"
43819f606849Smrg
43829f606849Smrg
43839f606849Smrg      compile_command="$compile_command $compile_deplibs"
43849f606849Smrg      finalize_command="$finalize_command $finalize_deplibs"
43859f606849Smrg
43869f606849Smrg      if test -n "$rpath$xrpath"; then
43879f606849Smrg	# If the user specified any rpath flags, then add them.
43889f606849Smrg	for libdir in $rpath $xrpath; do
43899f606849Smrg	  # This is the magic to use -rpath.
43909f606849Smrg	  case "$finalize_rpath " in
43919f606849Smrg	  *" $libdir "*) ;;
43929f606849Smrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
43939f606849Smrg	  esac
43949f606849Smrg	done
43959f606849Smrg      fi
43969f606849Smrg
43979f606849Smrg      # Now hardcode the library paths
43989f606849Smrg      rpath=
43999f606849Smrg      hardcode_libdirs=
44009f606849Smrg      for libdir in $compile_rpath $finalize_rpath; do
44019f606849Smrg	if test -n "$hardcode_libdir_flag_spec"; then
44029f606849Smrg	  if test -n "$hardcode_libdir_separator"; then
44039f606849Smrg	    if test -z "$hardcode_libdirs"; then
44049f606849Smrg	      hardcode_libdirs="$libdir"
44059f606849Smrg	    else
44069f606849Smrg	      # Just accumulate the unique libdirs.
44079f606849Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
44089f606849Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
44099f606849Smrg		;;
44109f606849Smrg	      *)
44119f606849Smrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
44129f606849Smrg		;;
44139f606849Smrg	      esac
44149f606849Smrg	    fi
44159f606849Smrg	  else
44169f606849Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
44179f606849Smrg	    rpath="$rpath $flag"
44189f606849Smrg	  fi
44199f606849Smrg	elif test -n "$runpath_var"; then
44209f606849Smrg	  case "$perm_rpath " in
44219f606849Smrg	  *" $libdir "*) ;;
44229f606849Smrg	  *) perm_rpath="$perm_rpath $libdir" ;;
44239f606849Smrg	  esac
44249f606849Smrg	fi
44259f606849Smrg	case $host in
44269f606849Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
44279f606849Smrg	  testbindir=`$echo "X$libdir" | $Xsed -e 's*/lib$*/bin*'`
44289f606849Smrg	  case :$dllsearchpath: in
44299f606849Smrg	  *":$libdir:"*) ;;
44309f606849Smrg	  *) dllsearchpath="$dllsearchpath:$libdir";;
44319f606849Smrg	  esac
44329f606849Smrg	  case :$dllsearchpath: in
44339f606849Smrg	  *":$testbindir:"*) ;;
44349f606849Smrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
44359f606849Smrg	  esac
44369f606849Smrg	  ;;
44379f606849Smrg	esac
44389f606849Smrg      done
44399f606849Smrg      # Substitute the hardcoded libdirs into the rpath.
44409f606849Smrg      if test -n "$hardcode_libdir_separator" &&
44419f606849Smrg	 test -n "$hardcode_libdirs"; then
44429f606849Smrg	libdir="$hardcode_libdirs"
44439f606849Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
44449f606849Smrg      fi
44459f606849Smrg      compile_rpath="$rpath"
44469f606849Smrg
44479f606849Smrg      rpath=
44489f606849Smrg      hardcode_libdirs=
44499f606849Smrg      for libdir in $finalize_rpath; do
44509f606849Smrg	if test -n "$hardcode_libdir_flag_spec"; then
44519f606849Smrg	  if test -n "$hardcode_libdir_separator"; then
44529f606849Smrg	    if test -z "$hardcode_libdirs"; then
44539f606849Smrg	      hardcode_libdirs="$libdir"
44549f606849Smrg	    else
44559f606849Smrg	      # Just accumulate the unique libdirs.
44569f606849Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
44579f606849Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
44589f606849Smrg		;;
44599f606849Smrg	      *)
44609f606849Smrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
44619f606849Smrg		;;
44629f606849Smrg	      esac
44639f606849Smrg	    fi
44649f606849Smrg	  else
44659f606849Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
44669f606849Smrg	    rpath="$rpath $flag"
44679f606849Smrg	  fi
44689f606849Smrg	elif test -n "$runpath_var"; then
44699f606849Smrg	  case "$finalize_perm_rpath " in
44709f606849Smrg	  *" $libdir "*) ;;
44719f606849Smrg	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
44729f606849Smrg	  esac
44739f606849Smrg	fi
44749f606849Smrg      done
44759f606849Smrg      # Substitute the hardcoded libdirs into the rpath.
44769f606849Smrg      if test -n "$hardcode_libdir_separator" &&
44779f606849Smrg	 test -n "$hardcode_libdirs"; then
44789f606849Smrg	libdir="$hardcode_libdirs"
44799f606849Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
44809f606849Smrg      fi
44819f606849Smrg      finalize_rpath="$rpath"
44829f606849Smrg
44839f606849Smrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
44849f606849Smrg	# Transform all the library objects into standard objects.
44859f606849Smrg	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
44869f606849Smrg	finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
44879f606849Smrg      fi
44889f606849Smrg
44899f606849Smrg      dlsyms=
44909f606849Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
44919f606849Smrg	if test -n "$NM" && test -n "$global_symbol_pipe"; then
44929f606849Smrg	  dlsyms="${outputname}S.c"
44939f606849Smrg	else
44949f606849Smrg	  $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2
44959f606849Smrg	fi
44969f606849Smrg      fi
44979f606849Smrg
44989f606849Smrg      if test -n "$dlsyms"; then
44999f606849Smrg	case $dlsyms in
45009f606849Smrg	"") ;;
45019f606849Smrg	*.c)
45029f606849Smrg	  # Discover the nlist of each of the dlfiles.
45039f606849Smrg	  nlist="$output_objdir/${outputname}.nm"
45049f606849Smrg
45059f606849Smrg	  $show "$rm $nlist ${nlist}S ${nlist}T"
45069f606849Smrg	  $run $rm "$nlist" "${nlist}S" "${nlist}T"
45079f606849Smrg
45089f606849Smrg	  # Parse the name list into a source file.
45099f606849Smrg	  $show "creating $output_objdir/$dlsyms"
45109f606849Smrg
45119f606849Smrg	  test -z "$run" && $echo > "$output_objdir/$dlsyms" "\
45129f606849Smrg/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */
45139f606849Smrg/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */
45149f606849Smrg
45159f606849Smrg#ifdef __cplusplus
45169f606849Smrgextern \"C\" {
45179f606849Smrg#endif
45189f606849Smrg
45199f606849Smrg/* Prevent the only kind of declaration conflicts we can make. */
45209f606849Smrg#define lt_preloaded_symbols some_other_symbol
45219f606849Smrg
45229f606849Smrg/* External symbol declarations for the compiler. */\
45239f606849Smrg"
45249f606849Smrg
45259f606849Smrg	  if test "$dlself" = yes; then
45269f606849Smrg	    $show "generating symbol list for \`$output'"
45279f606849Smrg
45289f606849Smrg	    test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist"
45299f606849Smrg
45309f606849Smrg	    # Add our own program objects to the symbol list.
45319f606849Smrg	    progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
45329f606849Smrg	    for arg in $progfiles; do
45339f606849Smrg	      $show "extracting global C symbols from \`$arg'"
45349f606849Smrg	      $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
45359f606849Smrg	    done
45369f606849Smrg
45379f606849Smrg	    if test -n "$exclude_expsyms"; then
45389f606849Smrg	      $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
45399f606849Smrg	      $run eval '$mv "$nlist"T "$nlist"'
45409f606849Smrg	    fi
45419f606849Smrg
45429f606849Smrg	    if test -n "$export_symbols_regex"; then
45439f606849Smrg	      $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
45449f606849Smrg	      $run eval '$mv "$nlist"T "$nlist"'
45459f606849Smrg	    fi
45469f606849Smrg
45479f606849Smrg	    # Prepare the list of exported symbols
45489f606849Smrg	    if test -z "$export_symbols"; then
45499f606849Smrg	      export_symbols="$output_objdir/$outputname.exp"
45509f606849Smrg	      $run $rm $export_symbols
45519f606849Smrg	      $run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
45529f606849Smrg              case $host in
45539f606849Smrg              *cygwin* | *mingw* )
45549f606849Smrg	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
45559f606849Smrg		$run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
45569f606849Smrg                ;;
45579f606849Smrg              esac
45589f606849Smrg	    else
45599f606849Smrg	      $run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
45609f606849Smrg	      $run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
45619f606849Smrg	      $run eval 'mv "$nlist"T "$nlist"'
45629f606849Smrg              case $host in
45639f606849Smrg              *cygwin* | *mingw* )
45649f606849Smrg	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
45659f606849Smrg		$run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
45669f606849Smrg                ;;
45679f606849Smrg              esac
45689f606849Smrg	    fi
45699f606849Smrg	  fi
45709f606849Smrg
45719f606849Smrg	  for arg in $dlprefiles; do
45729f606849Smrg	    $show "extracting global C symbols from \`$arg'"
45739f606849Smrg	    name=`$echo "$arg" | ${SED} -e 's%^.*/%%'`
45749f606849Smrg	    $run eval '$echo ": $name " >> "$nlist"'
45759f606849Smrg	    $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
45769f606849Smrg	  done
45779f606849Smrg
45789f606849Smrg	  if test -z "$run"; then
45799f606849Smrg	    # Make sure we have at least an empty file.
45809f606849Smrg	    test -f "$nlist" || : > "$nlist"
45819f606849Smrg
45829f606849Smrg	    if test -n "$exclude_expsyms"; then
45839f606849Smrg	      $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
45849f606849Smrg	      $mv "$nlist"T "$nlist"
45859f606849Smrg	    fi
45869f606849Smrg
45879f606849Smrg	    # Try sorting and uniquifying the output.
45889f606849Smrg	    if grep -v "^: " < "$nlist" |
45899f606849Smrg		if sort -k 3 </dev/null >/dev/null 2>&1; then
45909f606849Smrg		  sort -k 3
45919f606849Smrg		else
45929f606849Smrg		  sort +2
45939f606849Smrg		fi |
45949f606849Smrg		uniq > "$nlist"S; then
45959f606849Smrg	      :
45969f606849Smrg	    else
45979f606849Smrg	      grep -v "^: " < "$nlist" > "$nlist"S
45989f606849Smrg	    fi
45999f606849Smrg
46009f606849Smrg	    if test -f "$nlist"S; then
46019f606849Smrg	      eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"'
46029f606849Smrg	    else
46039f606849Smrg	      $echo '/* NONE */' >> "$output_objdir/$dlsyms"
46049f606849Smrg	    fi
46059f606849Smrg
46069f606849Smrg	    $echo >> "$output_objdir/$dlsyms" "\
46079f606849Smrg
46089f606849Smrg#undef lt_preloaded_symbols
46099f606849Smrg
46109f606849Smrg#if defined (__STDC__) && __STDC__
46119f606849Smrg# define lt_ptr void *
46129f606849Smrg#else
46139f606849Smrg# define lt_ptr char *
46149f606849Smrg# define const
46159f606849Smrg#endif
46169f606849Smrg
46179f606849Smrg/* The mapping between symbol names and symbols. */
46189f606849Smrg"
46199f606849Smrg
46209f606849Smrg	    case $host in
46219f606849Smrg	    *cygwin* | *mingw* )
46229f606849Smrg	  $echo >> "$output_objdir/$dlsyms" "\
46239f606849Smrg/* DATA imports from DLLs on WIN32 can't be const, because
46249f606849Smrg   runtime relocations are performed -- see ld's documentation
46259f606849Smrg   on pseudo-relocs */
46269f606849Smrgstruct {
46279f606849Smrg"
46289f606849Smrg	      ;;
46299f606849Smrg	    * )
46309f606849Smrg	  $echo >> "$output_objdir/$dlsyms" "\
46319f606849Smrgconst struct {
46329f606849Smrg"
46339f606849Smrg	      ;;
46349f606849Smrg	    esac
46359f606849Smrg
46369f606849Smrg
46379f606849Smrg	  $echo >> "$output_objdir/$dlsyms" "\
46389f606849Smrg  const char *name;
46399f606849Smrg  lt_ptr address;
46409f606849Smrg}
46419f606849Smrglt_preloaded_symbols[] =
46429f606849Smrg{\
46439f606849Smrg"
46449f606849Smrg
46459f606849Smrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms"
46469f606849Smrg
46479f606849Smrg	    $echo >> "$output_objdir/$dlsyms" "\
46489f606849Smrg  {0, (lt_ptr) 0}
46499f606849Smrg};
46509f606849Smrg
46519f606849Smrg/* This works around a problem in FreeBSD linker */
46529f606849Smrg#ifdef FREEBSD_WORKAROUND
46539f606849Smrgstatic const void *lt_preloaded_setup() {
46549f606849Smrg  return lt_preloaded_symbols;
46559f606849Smrg}
46569f606849Smrg#endif
46579f606849Smrg
46589f606849Smrg#ifdef __cplusplus
46599f606849Smrg}
46609f606849Smrg#endif\
46619f606849Smrg"
46629f606849Smrg	  fi
46639f606849Smrg
46649f606849Smrg	  pic_flag_for_symtable=
46659f606849Smrg	  case $host in
46669f606849Smrg	  # compiling the symbol table file with pic_flag works around
46679f606849Smrg	  # a FreeBSD bug that causes programs to crash when -lm is
46689f606849Smrg	  # linked before any other PIC object.  But we must not use
46699f606849Smrg	  # pic_flag when linking with -static.  The problem exists in
46709f606849Smrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
46719f606849Smrg	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
46729f606849Smrg	    case "$compile_command " in
46739f606849Smrg	    *" -static "*) ;;
46749f606849Smrg	    *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";;
46759f606849Smrg	    esac;;
46769f606849Smrg	  *-*-hpux*)
46779f606849Smrg	    case "$compile_command " in
46789f606849Smrg	    *" -static "*) ;;
46799f606849Smrg	    *) pic_flag_for_symtable=" $pic_flag";;
46809f606849Smrg	    esac
46819f606849Smrg	  esac
46829f606849Smrg
46839f606849Smrg	  # Now compile the dynamic symbol file.
46849f606849Smrg	  $show "(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
46859f606849Smrg	  $run eval '(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
46869f606849Smrg
46879f606849Smrg	  # Clean up the generated files.
46889f606849Smrg	  $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
46899f606849Smrg	  $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
46909f606849Smrg
46919f606849Smrg	  # Transform the symbol file into the correct name.
46929f606849Smrg          case $host in
46939f606849Smrg          *cygwin* | *mingw* )
46949f606849Smrg            if test -f "$output_objdir/${outputname}.def" ; then
46959f606849Smrg              compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
46969f606849Smrg              finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
46979f606849Smrg            else
46989f606849Smrg              compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
46999f606849Smrg              finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
47009f606849Smrg             fi
47019f606849Smrg            ;;
47029f606849Smrg          * )
47039f606849Smrg            compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
47049f606849Smrg            finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
47059f606849Smrg            ;;
47069f606849Smrg          esac
47079f606849Smrg	  ;;
47089f606849Smrg	*)
47099f606849Smrg	  $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
47109f606849Smrg	  exit $EXIT_FAILURE
47119f606849Smrg	  ;;
47129f606849Smrg	esac
47139f606849Smrg      else
47149f606849Smrg	# We keep going just in case the user didn't refer to
47159f606849Smrg	# lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
47169f606849Smrg	# really was required.
47179f606849Smrg
47189f606849Smrg	# Nullify the symbol file.
47199f606849Smrg	compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
47209f606849Smrg	finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
47219f606849Smrg      fi
47229f606849Smrg
47239f606849Smrg      if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
47249f606849Smrg	# Replace the output file specification.
47259f606849Smrg	compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
47269f606849Smrg	link_command="$compile_command$compile_rpath"
47279f606849Smrg
47289f606849Smrg	# We have no uninstalled library dependencies, so finalize right now.
47299f606849Smrg	$show "$link_command"
47309f606849Smrg	$run eval "$link_command"
47319f606849Smrg	exit_status=$?
47329f606849Smrg
47339f606849Smrg	# Delete the generated files.
47349f606849Smrg	if test -n "$dlsyms"; then
47359f606849Smrg	  $show "$rm $output_objdir/${outputname}S.${objext}"
47369f606849Smrg	  $run $rm "$output_objdir/${outputname}S.${objext}"
47379f606849Smrg	fi
47389f606849Smrg
47399f606849Smrg	exit $exit_status
47409f606849Smrg      fi
47419f606849Smrg
47429f606849Smrg      if test -n "$shlibpath_var"; then
47439f606849Smrg	# We should set the shlibpath_var
47449f606849Smrg	rpath=
47459f606849Smrg	for dir in $temp_rpath; do
47469f606849Smrg	  case $dir in
47479f606849Smrg	  [\\/]* | [A-Za-z]:[\\/]*)
47489f606849Smrg	    # Absolute path.
47499f606849Smrg	    rpath="$rpath$dir:"
47509f606849Smrg	    ;;
47519f606849Smrg	  *)
47529f606849Smrg	    # Relative path: add a thisdir entry.
47539f606849Smrg	    rpath="$rpath\$thisdir/$dir:"
47549f606849Smrg	    ;;
47559f606849Smrg	  esac
47569f606849Smrg	done
47579f606849Smrg	temp_rpath="$rpath"
47589f606849Smrg      fi
47599f606849Smrg
47609f606849Smrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
47619f606849Smrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
47629f606849Smrg      fi
47639f606849Smrg      if test -n "$finalize_shlibpath"; then
47649f606849Smrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
47659f606849Smrg      fi
47669f606849Smrg
47679f606849Smrg      compile_var=
47689f606849Smrg      finalize_var=
47699f606849Smrg      if test -n "$runpath_var"; then
47709f606849Smrg	if test -n "$perm_rpath"; then
47719f606849Smrg	  # We should set the runpath_var.
47729f606849Smrg	  rpath=
47739f606849Smrg	  for dir in $perm_rpath; do
47749f606849Smrg	    rpath="$rpath$dir:"
47759f606849Smrg	  done
47769f606849Smrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
47779f606849Smrg	fi
47789f606849Smrg	if test -n "$finalize_perm_rpath"; then
47799f606849Smrg	  # We should set the runpath_var.
47809f606849Smrg	  rpath=
47819f606849Smrg	  for dir in $finalize_perm_rpath; do
47829f606849Smrg	    rpath="$rpath$dir:"
47839f606849Smrg	  done
47849f606849Smrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
47859f606849Smrg	fi
47869f606849Smrg      fi
47879f606849Smrg
47889f606849Smrg      if test "$no_install" = yes; then
47899f606849Smrg	# We don't need to create a wrapper script.
47909f606849Smrg	link_command="$compile_var$compile_command$compile_rpath"
47919f606849Smrg	# Replace the output file specification.
47929f606849Smrg	link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
47939f606849Smrg	# Delete the old output file.
47949f606849Smrg	$run $rm $output
47959f606849Smrg	# Link the executable and exit
47969f606849Smrg	$show "$link_command"
47979f606849Smrg	$run eval "$link_command" || exit $?
47989f606849Smrg	exit $EXIT_SUCCESS
47999f606849Smrg      fi
48009f606849Smrg
48019f606849Smrg      if test "$hardcode_action" = relink; then
48029f606849Smrg	# Fast installation is not supported
48039f606849Smrg	link_command="$compile_var$compile_command$compile_rpath"
48049f606849Smrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
48059f606849Smrg
48069f606849Smrg	$echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2
48079f606849Smrg	$echo "$modename: \`$output' will be relinked during installation" 1>&2
48089f606849Smrg      else
48099f606849Smrg	if test "$fast_install" != no; then
48109f606849Smrg	  link_command="$finalize_var$compile_command$finalize_rpath"
48119f606849Smrg	  if test "$fast_install" = yes; then
48129f606849Smrg	    relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
48139f606849Smrg	  else
48149f606849Smrg	    # fast_install is set to needless
48159f606849Smrg	    relink_command=
48169f606849Smrg	  fi
48179f606849Smrg	else
48189f606849Smrg	  link_command="$compile_var$compile_command$compile_rpath"
48199f606849Smrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
48209f606849Smrg	fi
48219f606849Smrg      fi
48229f606849Smrg
48239f606849Smrg      # Replace the output file specification.
48249f606849Smrg      link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
48259f606849Smrg
48269f606849Smrg      # Delete the old output files.
48279f606849Smrg      $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname
48289f606849Smrg
48299f606849Smrg      $show "$link_command"
48309f606849Smrg      $run eval "$link_command" || exit $?
48319f606849Smrg
48329f606849Smrg      # Now create the wrapper script.
48339f606849Smrg      $show "creating $output"
48349f606849Smrg
48359f606849Smrg      # Quote the relink command for shipping.
48369f606849Smrg      if test -n "$relink_command"; then
48379f606849Smrg	# Preserve any variables that may affect compiler behavior
48389f606849Smrg	for var in $variables_saved_for_relink; do
48399f606849Smrg	  if eval test -z \"\${$var+set}\"; then
48409f606849Smrg	    relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
48419f606849Smrg	  elif eval var_value=\$$var; test -z "$var_value"; then
48429f606849Smrg	    relink_command="$var=; export $var; $relink_command"
48439f606849Smrg	  else
48449f606849Smrg	    var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
48459f606849Smrg	    relink_command="$var=\"$var_value\"; export $var; $relink_command"
48469f606849Smrg	  fi
48479f606849Smrg	done
48489f606849Smrg	relink_command="(cd `pwd`; $relink_command)"
48499f606849Smrg	relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
48509f606849Smrg      fi
48519f606849Smrg
48529f606849Smrg      # Quote $echo for shipping.
48539f606849Smrg      if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then
48549f606849Smrg	case $progpath in
48559f606849Smrg	[\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
48569f606849Smrg	*) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
48579f606849Smrg	esac
48589f606849Smrg	qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"`
48599f606849Smrg      else
48609f606849Smrg	qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"`
48619f606849Smrg      fi
48629f606849Smrg
48639f606849Smrg      # Only actually do things if our run command is non-null.
48649f606849Smrg      if test -z "$run"; then
48659f606849Smrg	# win32 will think the script is a binary if it has
48669f606849Smrg	# a .exe suffix, so we strip it off here.
48679f606849Smrg	case $output in
48689f606849Smrg	  *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;;
48699f606849Smrg	esac
48709f606849Smrg	# test for cygwin because mv fails w/o .exe extensions
48719f606849Smrg	case $host in
48729f606849Smrg	  *cygwin*)
48739f606849Smrg	    exeext=.exe
48749f606849Smrg	    outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;;
48759f606849Smrg	  *) exeext= ;;
48769f606849Smrg	esac
48779f606849Smrg	case $host in
48789f606849Smrg	  *cygwin* | *mingw* )
48799f606849Smrg            output_name=`basename $output`
48809f606849Smrg            output_path=`dirname $output`
48819f606849Smrg            cwrappersource="$output_path/$objdir/lt-$output_name.c"
48829f606849Smrg            cwrapper="$output_path/$output_name.exe"
48839f606849Smrg            $rm $cwrappersource $cwrapper
48849f606849Smrg            trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
48859f606849Smrg
48869f606849Smrg	    cat > $cwrappersource <<EOF
48879f606849Smrg
48889f606849Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
48899f606849Smrg   Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
48909f606849Smrg
48919f606849Smrg   The $output program cannot be directly executed until all the libtool
48929f606849Smrg   libraries that it depends on are installed.
48939f606849Smrg
48949f606849Smrg   This wrapper executable should never be moved out of the build directory.
48959f606849Smrg   If it is, it will not operate correctly.
48969f606849Smrg
48979f606849Smrg   Currently, it simply execs the wrapper *script* "/bin/sh $output",
48989f606849Smrg   but could eventually absorb all of the scripts functionality and
48999f606849Smrg   exec $objdir/$outputname directly.
49009f606849Smrg*/
49019f606849SmrgEOF
49029f606849Smrg	    cat >> $cwrappersource<<"EOF"
49039f606849Smrg#include <stdio.h>
49049f606849Smrg#include <stdlib.h>
49059f606849Smrg#include <unistd.h>
49069f606849Smrg#include <malloc.h>
49079f606849Smrg#include <stdarg.h>
49089f606849Smrg#include <assert.h>
49099f606849Smrg#include <string.h>
49109f606849Smrg#include <ctype.h>
49119f606849Smrg#include <sys/stat.h>
49129f606849Smrg
49139f606849Smrg#if defined(PATH_MAX)
49149f606849Smrg# define LT_PATHMAX PATH_MAX
49159f606849Smrg#elif defined(MAXPATHLEN)
49169f606849Smrg# define LT_PATHMAX MAXPATHLEN
49179f606849Smrg#else
49189f606849Smrg# define LT_PATHMAX 1024
49199f606849Smrg#endif
49209f606849Smrg
49219f606849Smrg#ifndef DIR_SEPARATOR
49229f606849Smrg# define DIR_SEPARATOR '/'
49239f606849Smrg# define PATH_SEPARATOR ':'
49249f606849Smrg#endif
49259f606849Smrg
49269f606849Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
49279f606849Smrg  defined (__OS2__)
49289f606849Smrg# define HAVE_DOS_BASED_FILE_SYSTEM
49299f606849Smrg# ifndef DIR_SEPARATOR_2
49309f606849Smrg#  define DIR_SEPARATOR_2 '\\'
49319f606849Smrg# endif
49329f606849Smrg# ifndef PATH_SEPARATOR_2
49339f606849Smrg#  define PATH_SEPARATOR_2 ';'
49349f606849Smrg# endif
49359f606849Smrg#endif
49369f606849Smrg
49379f606849Smrg#ifndef DIR_SEPARATOR_2
49389f606849Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
49399f606849Smrg#else /* DIR_SEPARATOR_2 */
49409f606849Smrg# define IS_DIR_SEPARATOR(ch) \
49419f606849Smrg        (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
49429f606849Smrg#endif /* DIR_SEPARATOR_2 */
49439f606849Smrg
49449f606849Smrg#ifndef PATH_SEPARATOR_2
49459f606849Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
49469f606849Smrg#else /* PATH_SEPARATOR_2 */
49479f606849Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
49489f606849Smrg#endif /* PATH_SEPARATOR_2 */
49499f606849Smrg
49509f606849Smrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
49519f606849Smrg#define XFREE(stale) do { \
49529f606849Smrg  if (stale) { free ((void *) stale); stale = 0; } \
49539f606849Smrg} while (0)
49549f606849Smrg
49559f606849Smrg/* -DDEBUG is fairly common in CFLAGS.  */
49569f606849Smrg#undef DEBUG
49579f606849Smrg#if defined DEBUGWRAPPER
49589f606849Smrg# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
49599f606849Smrg#else
49609f606849Smrg# define DEBUG(format, ...)
49619f606849Smrg#endif
49629f606849Smrg
49639f606849Smrgconst char *program_name = NULL;
49649f606849Smrg
49659f606849Smrgvoid * xmalloc (size_t num);
49669f606849Smrgchar * xstrdup (const char *string);
49679f606849Smrgconst char * base_name (const char *name);
49689f606849Smrgchar * find_executable(const char *wrapper);
49699f606849Smrgint    check_executable(const char *path);
49709f606849Smrgchar * strendzap(char *str, const char *pat);
49719f606849Smrgvoid lt_fatal (const char *message, ...);
49729f606849Smrg
49739f606849Smrgint
49749f606849Smrgmain (int argc, char *argv[])
49759f606849Smrg{
49769f606849Smrg  char **newargz;
49779f606849Smrg  int i;
49789f606849Smrg
49799f606849Smrg  program_name = (char *) xstrdup (base_name (argv[0]));
49809f606849Smrg  DEBUG("(main) argv[0]      : %s\n",argv[0]);
49819f606849Smrg  DEBUG("(main) program_name : %s\n",program_name);
49829f606849Smrg  newargz = XMALLOC(char *, argc+2);
49839f606849SmrgEOF
49849f606849Smrg
49859f606849Smrg            cat >> $cwrappersource <<EOF
49869f606849Smrg  newargz[0] = (char *) xstrdup("$SHELL");
49879f606849SmrgEOF
49889f606849Smrg
49899f606849Smrg            cat >> $cwrappersource <<"EOF"
49909f606849Smrg  newargz[1] = find_executable(argv[0]);
49919f606849Smrg  if (newargz[1] == NULL)
49929f606849Smrg    lt_fatal("Couldn't find %s", argv[0]);
49939f606849Smrg  DEBUG("(main) found exe at : %s\n",newargz[1]);
49949f606849Smrg  /* we know the script has the same name, without the .exe */
49959f606849Smrg  /* so make sure newargz[1] doesn't end in .exe */
49969f606849Smrg  strendzap(newargz[1],".exe");
49979f606849Smrg  for (i = 1; i < argc; i++)
49989f606849Smrg    newargz[i+1] = xstrdup(argv[i]);
49999f606849Smrg  newargz[argc+1] = NULL;
50009f606849Smrg
50019f606849Smrg  for (i=0; i<argc+1; i++)
50029f606849Smrg  {
50039f606849Smrg    DEBUG("(main) newargz[%d]   : %s\n",i,newargz[i]);
50049f606849Smrg    ;
50059f606849Smrg  }
50069f606849Smrg
50079f606849SmrgEOF
50089f606849Smrg
50099f606849Smrg            case $host_os in
50109f606849Smrg              mingw*)
50119f606849Smrg                cat >> $cwrappersource <<EOF
50129f606849Smrg  execv("$SHELL",(char const **)newargz);
50139f606849SmrgEOF
50149f606849Smrg              ;;
50159f606849Smrg              *)
50169f606849Smrg                cat >> $cwrappersource <<EOF
50179f606849Smrg  execv("$SHELL",newargz);
50189f606849SmrgEOF
50199f606849Smrg              ;;
50209f606849Smrg            esac
50219f606849Smrg
50229f606849Smrg            cat >> $cwrappersource <<"EOF"
50239f606849Smrg  return 127;
50249f606849Smrg}
50259f606849Smrg
50269f606849Smrgvoid *
50279f606849Smrgxmalloc (size_t num)
50289f606849Smrg{
50299f606849Smrg  void * p = (void *) malloc (num);
50309f606849Smrg  if (!p)
50319f606849Smrg    lt_fatal ("Memory exhausted");
50329f606849Smrg
50339f606849Smrg  return p;
50349f606849Smrg}
50359f606849Smrg
50369f606849Smrgchar *
50379f606849Smrgxstrdup (const char *string)
50389f606849Smrg{
50399f606849Smrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL
50409f606849Smrg;
50419f606849Smrg}
50429f606849Smrg
50439f606849Smrgconst char *
50449f606849Smrgbase_name (const char *name)
50459f606849Smrg{
50469f606849Smrg  const char *base;
50479f606849Smrg
50489f606849Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
50499f606849Smrg  /* Skip over the disk name in MSDOS pathnames. */
50509f606849Smrg  if (isalpha ((unsigned char)name[0]) && name[1] == ':')
50519f606849Smrg    name += 2;
50529f606849Smrg#endif
50539f606849Smrg
50549f606849Smrg  for (base = name; *name; name++)
50559f606849Smrg    if (IS_DIR_SEPARATOR (*name))
50569f606849Smrg      base = name + 1;
50579f606849Smrg  return base;
50589f606849Smrg}
50599f606849Smrg
50609f606849Smrgint
50619f606849Smrgcheck_executable(const char * path)
50629f606849Smrg{
50639f606849Smrg  struct stat st;
50649f606849Smrg
50659f606849Smrg  DEBUG("(check_executable)  : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!");
50669f606849Smrg  if ((!path) || (!*path))
50679f606849Smrg    return 0;
50689f606849Smrg
50699f606849Smrg  if ((stat (path, &st) >= 0) &&
50709f606849Smrg      (
50719f606849Smrg        /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */
50729f606849Smrg#if defined (S_IXOTH)
50739f606849Smrg       ((st.st_mode & S_IXOTH) == S_IXOTH) ||
50749f606849Smrg#endif
50759f606849Smrg#if defined (S_IXGRP)
50769f606849Smrg       ((st.st_mode & S_IXGRP) == S_IXGRP) ||
50779f606849Smrg#endif
50789f606849Smrg       ((st.st_mode & S_IXUSR) == S_IXUSR))
50799f606849Smrg      )
50809f606849Smrg    return 1;
50819f606849Smrg  else
50829f606849Smrg    return 0;
50839f606849Smrg}
50849f606849Smrg
50859f606849Smrg/* Searches for the full path of the wrapper.  Returns
50869f606849Smrg   newly allocated full path name if found, NULL otherwise */
50879f606849Smrgchar *
50889f606849Smrgfind_executable (const char* wrapper)
50899f606849Smrg{
50909f606849Smrg  int has_slash = 0;
50919f606849Smrg  const char* p;
50929f606849Smrg  const char* p_next;
50939f606849Smrg  /* static buffer for getcwd */
50949f606849Smrg  char tmp[LT_PATHMAX + 1];
50959f606849Smrg  int tmp_len;
50969f606849Smrg  char* concat_name;
50979f606849Smrg
50989f606849Smrg  DEBUG("(find_executable)  : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!");
50999f606849Smrg
51009f606849Smrg  if ((wrapper == NULL) || (*wrapper == '\0'))
51019f606849Smrg    return NULL;
51029f606849Smrg
51039f606849Smrg  /* Absolute path? */
51049f606849Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
51059f606849Smrg  if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':')
51069f606849Smrg  {
51079f606849Smrg    concat_name = xstrdup (wrapper);
51089f606849Smrg    if (check_executable(concat_name))
51099f606849Smrg      return concat_name;
51109f606849Smrg    XFREE(concat_name);
51119f606849Smrg  }
51129f606849Smrg  else
51139f606849Smrg  {
51149f606849Smrg#endif
51159f606849Smrg    if (IS_DIR_SEPARATOR (wrapper[0]))
51169f606849Smrg    {
51179f606849Smrg      concat_name = xstrdup (wrapper);
51189f606849Smrg      if (check_executable(concat_name))
51199f606849Smrg        return concat_name;
51209f606849Smrg      XFREE(concat_name);
51219f606849Smrg    }
51229f606849Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
51239f606849Smrg  }
51249f606849Smrg#endif
51259f606849Smrg
51269f606849Smrg  for (p = wrapper; *p; p++)
51279f606849Smrg    if (*p == '/')
51289f606849Smrg    {
51299f606849Smrg      has_slash = 1;
51309f606849Smrg      break;
51319f606849Smrg    }
51329f606849Smrg  if (!has_slash)
51339f606849Smrg  {
51349f606849Smrg    /* no slashes; search PATH */
51359f606849Smrg    const char* path = getenv ("PATH");
51369f606849Smrg    if (path != NULL)
51379f606849Smrg    {
51389f606849Smrg      for (p = path; *p; p = p_next)
51399f606849Smrg      {
51409f606849Smrg        const char* q;
51419f606849Smrg        size_t p_len;
51429f606849Smrg        for (q = p; *q; q++)
51439f606849Smrg          if (IS_PATH_SEPARATOR(*q))
51449f606849Smrg            break;
51459f606849Smrg        p_len = q - p;
51469f606849Smrg        p_next = (*q == '\0' ? q : q + 1);
51479f606849Smrg        if (p_len == 0)
51489f606849Smrg        {
51499f606849Smrg          /* empty path: current directory */
51509f606849Smrg          if (getcwd (tmp, LT_PATHMAX) == NULL)
51519f606849Smrg            lt_fatal ("getcwd failed");
51529f606849Smrg          tmp_len = strlen(tmp);
51539f606849Smrg          concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
51549f606849Smrg          memcpy (concat_name, tmp, tmp_len);
51559f606849Smrg          concat_name[tmp_len] = '/';
51569f606849Smrg          strcpy (concat_name + tmp_len + 1, wrapper);
51579f606849Smrg        }
51589f606849Smrg        else
51599f606849Smrg        {
51609f606849Smrg          concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1);
51619f606849Smrg          memcpy (concat_name, p, p_len);
51629f606849Smrg          concat_name[p_len] = '/';
51639f606849Smrg          strcpy (concat_name + p_len + 1, wrapper);
51649f606849Smrg        }
51659f606849Smrg        if (check_executable(concat_name))
51669f606849Smrg          return concat_name;
51679f606849Smrg        XFREE(concat_name);
51689f606849Smrg      }
51699f606849Smrg    }
51709f606849Smrg    /* not found in PATH; assume curdir */
51719f606849Smrg  }
51729f606849Smrg  /* Relative path | not found in path: prepend cwd */
51739f606849Smrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
51749f606849Smrg    lt_fatal ("getcwd failed");
51759f606849Smrg  tmp_len = strlen(tmp);
51769f606849Smrg  concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
51779f606849Smrg  memcpy (concat_name, tmp, tmp_len);
51789f606849Smrg  concat_name[tmp_len] = '/';
51799f606849Smrg  strcpy (concat_name + tmp_len + 1, wrapper);
51809f606849Smrg
51819f606849Smrg  if (check_executable(concat_name))
51829f606849Smrg    return concat_name;
51839f606849Smrg  XFREE(concat_name);
51849f606849Smrg  return NULL;
51859f606849Smrg}
51869f606849Smrg
51879f606849Smrgchar *
51889f606849Smrgstrendzap(char *str, const char *pat)
51899f606849Smrg{
51909f606849Smrg  size_t len, patlen;
51919f606849Smrg
51929f606849Smrg  assert(str != NULL);
51939f606849Smrg  assert(pat != NULL);
51949f606849Smrg
51959f606849Smrg  len = strlen(str);
51969f606849Smrg  patlen = strlen(pat);
51979f606849Smrg
51989f606849Smrg  if (patlen <= len)
51999f606849Smrg  {
52009f606849Smrg    str += len - patlen;
52019f606849Smrg    if (strcmp(str, pat) == 0)
52029f606849Smrg      *str = '\0';
52039f606849Smrg  }
52049f606849Smrg  return str;
52059f606849Smrg}
52069f606849Smrg
52079f606849Smrgstatic void
52089f606849Smrglt_error_core (int exit_status, const char * mode,
52099f606849Smrg          const char * message, va_list ap)
52109f606849Smrg{
52119f606849Smrg  fprintf (stderr, "%s: %s: ", program_name, mode);
52129f606849Smrg  vfprintf (stderr, message, ap);
52139f606849Smrg  fprintf (stderr, ".\n");
52149f606849Smrg
52159f606849Smrg  if (exit_status >= 0)
52169f606849Smrg    exit (exit_status);
52179f606849Smrg}
52189f606849Smrg
52199f606849Smrgvoid
52209f606849Smrglt_fatal (const char *message, ...)
52219f606849Smrg{
52229f606849Smrg  va_list ap;
52239f606849Smrg  va_start (ap, message);
52249f606849Smrg  lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
52259f606849Smrg  va_end (ap);
52269f606849Smrg}
52279f606849SmrgEOF
52289f606849Smrg          # we should really use a build-platform specific compiler
52299f606849Smrg          # here, but OTOH, the wrappers (shell script and this C one)
52309f606849Smrg          # are only useful if you want to execute the "real" binary.
52319f606849Smrg          # Since the "real" binary is built for $host, then this
52329f606849Smrg          # wrapper might as well be built for $host, too.
52339f606849Smrg          $run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource
52349f606849Smrg          ;;
52359f606849Smrg        esac
52369f606849Smrg        $rm $output
52379f606849Smrg        trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
52389f606849Smrg
52399f606849Smrg	$echo > $output "\
52409f606849Smrg#! $SHELL
52419f606849Smrg
52429f606849Smrg# $output - temporary wrapper script for $objdir/$outputname
52439f606849Smrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
52449f606849Smrg#
52459f606849Smrg# The $output program cannot be directly executed until all the libtool
52469f606849Smrg# libraries that it depends on are installed.
52479f606849Smrg#
52489f606849Smrg# This wrapper script should never be moved out of the build directory.
52499f606849Smrg# If it is, it will not operate correctly.
52509f606849Smrg
52519f606849Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
52529f606849Smrg# metacharacters that are still active within double-quoted strings.
52539f606849SmrgXsed='${SED} -e 1s/^X//'
52549f606849Smrgsed_quote_subst='$sed_quote_subst'
52559f606849Smrg
52569f606849Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout
52579f606849Smrg# if CDPATH is set.
52589f606849Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
52599f606849Smrg
52609f606849Smrgrelink_command=\"$relink_command\"
52619f606849Smrg
52629f606849Smrg# This environment variable determines our operation mode.
52639f606849Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then
52649f606849Smrg  # install mode needs the following variable:
52659f606849Smrg  notinst_deplibs='$notinst_deplibs'
52669f606849Smrgelse
52679f606849Smrg  # When we are sourced in execute mode, \$file and \$echo are already set.
52689f606849Smrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
52699f606849Smrg    echo=\"$qecho\"
52709f606849Smrg    file=\"\$0\"
52719f606849Smrg    # Make sure echo works.
52729f606849Smrg    if test \"X\$1\" = X--no-reexec; then
52739f606849Smrg      # Discard the --no-reexec flag, and continue.
52749f606849Smrg      shift
52759f606849Smrg    elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then
52769f606849Smrg      # Yippee, \$echo works!
52779f606849Smrg      :
52789f606849Smrg    else
52799f606849Smrg      # Restart under the correct shell, and then maybe \$echo will work.
52809f606849Smrg      exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
52819f606849Smrg    fi
52829f606849Smrg  fi\
52839f606849Smrg"
52849f606849Smrg	$echo >> $output "\
52859f606849Smrg
52869f606849Smrg  # Find the directory that this script lives in.
52879f606849Smrg  thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
52889f606849Smrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
52899f606849Smrg
52909f606849Smrg  # Follow symbolic links until we get to the real thisdir.
52919f606849Smrg  file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
52929f606849Smrg  while test -n \"\$file\"; do
52939f606849Smrg    destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
52949f606849Smrg
52959f606849Smrg    # If there was a directory component, then change thisdir.
52969f606849Smrg    if test \"x\$destdir\" != \"x\$file\"; then
52979f606849Smrg      case \"\$destdir\" in
52989f606849Smrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
52999f606849Smrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
53009f606849Smrg      esac
53019f606849Smrg    fi
53029f606849Smrg
53039f606849Smrg    file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
53049f606849Smrg    file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
53059f606849Smrg  done
53069f606849Smrg
53079f606849Smrg  # Try to get the absolute directory name.
53089f606849Smrg  absdir=\`cd \"\$thisdir\" && pwd\`
53099f606849Smrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
53109f606849Smrg"
53119f606849Smrg
53129f606849Smrg	if test "$fast_install" = yes; then
53139f606849Smrg	  $echo >> $output "\
53149f606849Smrg  program=lt-'$outputname'$exeext
53159f606849Smrg  progdir=\"\$thisdir/$objdir\"
53169f606849Smrg
53179f606849Smrg  if test ! -f \"\$progdir/\$program\" || \\
53189f606849Smrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
53199f606849Smrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
53209f606849Smrg
53219f606849Smrg    file=\"\$\$-\$program\"
53229f606849Smrg
53239f606849Smrg    if test ! -d \"\$progdir\"; then
53249f606849Smrg      $mkdir \"\$progdir\"
53259f606849Smrg    else
53269f606849Smrg      $rm \"\$progdir/\$file\"
53279f606849Smrg    fi"
53289f606849Smrg
53299f606849Smrg	  $echo >> $output "\
53309f606849Smrg
53319f606849Smrg    # relink executable if necessary
53329f606849Smrg    if test -n \"\$relink_command\"; then
53339f606849Smrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
53349f606849Smrg      else
53359f606849Smrg	$echo \"\$relink_command_output\" >&2
53369f606849Smrg	$rm \"\$progdir/\$file\"
53379f606849Smrg	exit $EXIT_FAILURE
53389f606849Smrg      fi
53399f606849Smrg    fi
53409f606849Smrg
53419f606849Smrg    $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
53429f606849Smrg    { $rm \"\$progdir/\$program\";
53439f606849Smrg      $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
53449f606849Smrg    $rm \"\$progdir/\$file\"
53459f606849Smrg  fi"
53469f606849Smrg	else
53479f606849Smrg	  $echo >> $output "\
53489f606849Smrg  program='$outputname'
53499f606849Smrg  progdir=\"\$thisdir/$objdir\"
53509f606849Smrg"
53519f606849Smrg	fi
53529f606849Smrg
53539f606849Smrg	$echo >> $output "\
53549f606849Smrg
53559f606849Smrg  if test -f \"\$progdir/\$program\"; then"
53569f606849Smrg
53579f606849Smrg	# Export our shlibpath_var if we have one.
53589f606849Smrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
53599f606849Smrg	  $echo >> $output "\
53609f606849Smrg    # Add our own library path to $shlibpath_var
53619f606849Smrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
53629f606849Smrg
53639f606849Smrg    # Some systems cannot cope with colon-terminated $shlibpath_var
53649f606849Smrg    # The second colon is a workaround for a bug in BeOS R4 sed
53659f606849Smrg    $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
53669f606849Smrg
53679f606849Smrg    export $shlibpath_var
53689f606849Smrg"
53699f606849Smrg	fi
53709f606849Smrg
53719f606849Smrg	# fixup the dll searchpath if we need to.
53729f606849Smrg	if test -n "$dllsearchpath"; then
53739f606849Smrg	  $echo >> $output "\
53749f606849Smrg    # Add the dll search path components to the executable PATH
53759f606849Smrg    PATH=$dllsearchpath:\$PATH
53769f606849Smrg"
53779f606849Smrg	fi
53789f606849Smrg
53799f606849Smrg	$echo >> $output "\
53809f606849Smrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
53819f606849Smrg      # Run the actual program with our arguments.
53829f606849Smrg"
53839f606849Smrg	case $host in
53849f606849Smrg	# Backslashes separate directories on plain windows
53859f606849Smrg	*-*-mingw | *-*-os2*)
53869f606849Smrg	  $echo >> $output "\
53879f606849Smrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
53889f606849Smrg"
53899f606849Smrg	  ;;
53909f606849Smrg
53919f606849Smrg	*)
53929f606849Smrg	  $echo >> $output "\
53939f606849Smrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
53949f606849Smrg"
53959f606849Smrg	  ;;
53969f606849Smrg	esac
53979f606849Smrg	$echo >> $output "\
53989f606849Smrg      \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\"
53999f606849Smrg      exit $EXIT_FAILURE
54009f606849Smrg    fi
54019f606849Smrg  else
54029f606849Smrg    # The program doesn't exist.
54039f606849Smrg    \$echo \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
54049f606849Smrg    \$echo \"This script is just a wrapper for \$program.\" 1>&2
54059f606849Smrg    $echo \"See the $PACKAGE documentation for more information.\" 1>&2
54069f606849Smrg    exit $EXIT_FAILURE
54079f606849Smrg  fi
54089f606849Smrgfi\
54099f606849Smrg"
54109f606849Smrg	chmod +x $output
54119f606849Smrg      fi
54129f606849Smrg      exit $EXIT_SUCCESS
54139f606849Smrg      ;;
54149f606849Smrg    esac
54159f606849Smrg
54169f606849Smrg    # See if we need to build an old-fashioned archive.
54179f606849Smrg    for oldlib in $oldlibs; do
54189f606849Smrg
54199f606849Smrg      if test "$build_libtool_libs" = convenience; then
54209f606849Smrg	oldobjs="$libobjs_save"
54219f606849Smrg	addlibs="$convenience"
54229f606849Smrg	build_libtool_libs=no
54239f606849Smrg      else
54249f606849Smrg	if test "$build_libtool_libs" = module; then
54259f606849Smrg	  oldobjs="$libobjs_save"
54269f606849Smrg	  build_libtool_libs=no
54279f606849Smrg	else
54289f606849Smrg	  oldobjs="$old_deplibs $non_pic_objects"
54299f606849Smrg	fi
54309f606849Smrg	addlibs="$old_convenience"
54319f606849Smrg      fi
54329f606849Smrg
54339f606849Smrg      if test -n "$addlibs"; then
54349f606849Smrg	gentop="$output_objdir/${outputname}x"
54359f606849Smrg	generated="$generated $gentop"
54369f606849Smrg
54379f606849Smrg	func_extract_archives $gentop $addlibs
54389f606849Smrg	oldobjs="$oldobjs $func_extract_archives_result"
54399f606849Smrg      fi
54409f606849Smrg
54419f606849Smrg      # Do each command in the archive commands.
54429f606849Smrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
54439f606849Smrg       cmds=$old_archive_from_new_cmds
54449f606849Smrg      else
54459f606849Smrg	# POSIX demands no paths to be encoded in archives.  We have
54469f606849Smrg	# to avoid creating archives with duplicate basenames if we
54479f606849Smrg	# might have to extract them afterwards, e.g., when creating a
54489f606849Smrg	# static archive out of a convenience library, or when linking
54499f606849Smrg	# the entirety of a libtool archive into another (currently
54509f606849Smrg	# not supported by libtool).
54519f606849Smrg	if (for obj in $oldobjs
54529f606849Smrg	    do
54539f606849Smrg	      $echo "X$obj" | $Xsed -e 's%^.*/%%'
54549f606849Smrg	    done | sort | sort -uc >/dev/null 2>&1); then
54559f606849Smrg	  :
54569f606849Smrg	else
54579f606849Smrg	  $echo "copying selected object files to avoid basename conflicts..."
54589f606849Smrg
54599f606849Smrg	  if test -z "$gentop"; then
54609f606849Smrg	    gentop="$output_objdir/${outputname}x"
54619f606849Smrg	    generated="$generated $gentop"
54629f606849Smrg
54639f606849Smrg	    $show "${rm}r $gentop"
54649f606849Smrg	    $run ${rm}r "$gentop"
54659f606849Smrg	    $show "$mkdir $gentop"
54669f606849Smrg	    $run $mkdir "$gentop"
54679f606849Smrg	    exit_status=$?
54689f606849Smrg	    if test "$exit_status" -ne 0 && test ! -d "$gentop"; then
54699f606849Smrg	      exit $exit_status
54709f606849Smrg	    fi
54719f606849Smrg	  fi
54729f606849Smrg
54739f606849Smrg	  save_oldobjs=$oldobjs
54749f606849Smrg	  oldobjs=
54759f606849Smrg	  counter=1
54769f606849Smrg	  for obj in $save_oldobjs
54779f606849Smrg	  do
54789f606849Smrg	    objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
54799f606849Smrg	    case " $oldobjs " in
54809f606849Smrg	    " ") oldobjs=$obj ;;
54819f606849Smrg	    *[\ /]"$objbase "*)
54829f606849Smrg	      while :; do
54839f606849Smrg		# Make sure we don't pick an alternate name that also
54849f606849Smrg		# overlaps.
54859f606849Smrg		newobj=lt$counter-$objbase
54869f606849Smrg		counter=`expr $counter + 1`
54879f606849Smrg		case " $oldobjs " in
54889f606849Smrg		*[\ /]"$newobj "*) ;;
54899f606849Smrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
54909f606849Smrg		esac
54919f606849Smrg	      done
54929f606849Smrg	      $show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
54939f606849Smrg	      $run ln "$obj" "$gentop/$newobj" ||
54949f606849Smrg	      $run cp "$obj" "$gentop/$newobj"
54959f606849Smrg	      oldobjs="$oldobjs $gentop/$newobj"
54969f606849Smrg	      ;;
54979f606849Smrg	    *) oldobjs="$oldobjs $obj" ;;
54989f606849Smrg	    esac
54999f606849Smrg	  done
55009f606849Smrg	fi
55019f606849Smrg
55029f606849Smrg	eval cmds=\"$old_archive_cmds\"
55039f606849Smrg
55049f606849Smrg	if len=`expr "X$cmds" : ".*"` &&
55059f606849Smrg	     test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
55069f606849Smrg	  cmds=$old_archive_cmds
55079f606849Smrg	else
55089f606849Smrg	  # the command line is too long to link in one step, link in parts
55099f606849Smrg	  $echo "using piecewise archive linking..."
55109f606849Smrg	  save_RANLIB=$RANLIB
55119f606849Smrg	  RANLIB=:
55129f606849Smrg	  objlist=
55139f606849Smrg	  concat_cmds=
55149f606849Smrg	  save_oldobjs=$oldobjs
55159f606849Smrg
55169f606849Smrg	  # Is there a better way of finding the last object in the list?
55179f606849Smrg	  for obj in $save_oldobjs
55189f606849Smrg	  do
55199f606849Smrg	    last_oldobj=$obj
55209f606849Smrg	  done
55219f606849Smrg	  for obj in $save_oldobjs
55229f606849Smrg	  do
55239f606849Smrg	    oldobjs="$objlist $obj"
55249f606849Smrg	    objlist="$objlist $obj"
55259f606849Smrg	    eval test_cmds=\"$old_archive_cmds\"
55269f606849Smrg	    if len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
55279f606849Smrg	       test "$len" -le "$max_cmd_len"; then
55289f606849Smrg	      :
55299f606849Smrg	    else
55309f606849Smrg	      # the above command should be used before it gets too long
55319f606849Smrg	      oldobjs=$objlist
55329f606849Smrg	      if test "$obj" = "$last_oldobj" ; then
55339f606849Smrg	        RANLIB=$save_RANLIB
55349f606849Smrg	      fi
55359f606849Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
55369f606849Smrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
55379f606849Smrg	      objlist=
55389f606849Smrg	    fi
55399f606849Smrg	  done
55409f606849Smrg	  RANLIB=$save_RANLIB
55419f606849Smrg	  oldobjs=$objlist
55429f606849Smrg	  if test "X$oldobjs" = "X" ; then
55439f606849Smrg	    eval cmds=\"\$concat_cmds\"
55449f606849Smrg	  else
55459f606849Smrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
55469f606849Smrg	  fi
55479f606849Smrg	fi
55489f606849Smrg      fi
55499f606849Smrg      save_ifs="$IFS"; IFS='~'
55509f606849Smrg      for cmd in $cmds; do
55519f606849Smrg        eval cmd=\"$cmd\"
55529f606849Smrg	IFS="$save_ifs"
55539f606849Smrg	$show "$cmd"
55549f606849Smrg	$run eval "$cmd" || exit $?
55559f606849Smrg      done
55569f606849Smrg      IFS="$save_ifs"
55579f606849Smrg    done
55589f606849Smrg
55599f606849Smrg    if test -n "$generated"; then
55609f606849Smrg      $show "${rm}r$generated"
55619f606849Smrg      $run ${rm}r$generated
55629f606849Smrg    fi
55639f606849Smrg
55649f606849Smrg    # Now create the libtool archive.
55659f606849Smrg    case $output in
55669f606849Smrg    *.la)
55679f606849Smrg      old_library=
55689f606849Smrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
55699f606849Smrg      $show "creating $output"
55709f606849Smrg
55719f606849Smrg      # Preserve any variables that may affect compiler behavior
55729f606849Smrg      for var in $variables_saved_for_relink; do
55739f606849Smrg	if eval test -z \"\${$var+set}\"; then
55749f606849Smrg	  relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
55759f606849Smrg	elif eval var_value=\$$var; test -z "$var_value"; then
55769f606849Smrg	  relink_command="$var=; export $var; $relink_command"
55779f606849Smrg	else
55789f606849Smrg	  var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
55799f606849Smrg	  relink_command="$var=\"$var_value\"; export $var; $relink_command"
55809f606849Smrg	fi
55819f606849Smrg      done
55829f606849Smrg      # Quote the link command for shipping.
55839f606849Smrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
55849f606849Smrg      relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
55859f606849Smrg      if test "$hardcode_automatic" = yes ; then
55869f606849Smrg	relink_command=
55879f606849Smrg      fi
55889f606849Smrg
55899f606849Smrg
55909f606849Smrg      # Only create the output if not a dry run.
55919f606849Smrg      if test -z "$run"; then
55929f606849Smrg	for installed in no yes; do
55939f606849Smrg	  if test "$installed" = yes; then
55949f606849Smrg	    if test -z "$install_libdir"; then
55959f606849Smrg	      break
55969f606849Smrg	    fi
55979f606849Smrg	    output="$output_objdir/$outputname"i
55989f606849Smrg	    # Replace all uninstalled libtool libraries with the installed ones
55999f606849Smrg	    newdependency_libs=
56009f606849Smrg	    for deplib in $dependency_libs; do
56019f606849Smrg	      case $deplib in
56029f606849Smrg	      *.la)
56039f606849Smrg		name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'`
56049f606849Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
56059f606849Smrg		if test -z "$libdir"; then
56069f606849Smrg		  $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
56079f606849Smrg		  exit $EXIT_FAILURE
56089f606849Smrg		fi
56099f606849Smrg		newdependency_libs="$newdependency_libs $libdir/$name"
56109f606849Smrg		;;
56119f606849Smrg	      *) newdependency_libs="$newdependency_libs $deplib" ;;
56129f606849Smrg	      esac
56139f606849Smrg	    done
56149f606849Smrg	    dependency_libs="$newdependency_libs"
56159f606849Smrg	    newdlfiles=
56169f606849Smrg	    for lib in $dlfiles; do
56179f606849Smrg	      name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
56189f606849Smrg	      eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
56199f606849Smrg	      if test -z "$libdir"; then
56209f606849Smrg		$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
56219f606849Smrg		exit $EXIT_FAILURE
56229f606849Smrg	      fi
56239f606849Smrg	      newdlfiles="$newdlfiles $libdir/$name"
56249f606849Smrg	    done
56259f606849Smrg	    dlfiles="$newdlfiles"
56269f606849Smrg	    newdlprefiles=
56279f606849Smrg	    for lib in $dlprefiles; do
56289f606849Smrg	      name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
56299f606849Smrg	      eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
56309f606849Smrg	      if test -z "$libdir"; then
56319f606849Smrg		$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
56329f606849Smrg		exit $EXIT_FAILURE
56339f606849Smrg	      fi
56349f606849Smrg	      newdlprefiles="$newdlprefiles $libdir/$name"
56359f606849Smrg	    done
56369f606849Smrg	    dlprefiles="$newdlprefiles"
56379f606849Smrg	  else
56389f606849Smrg	    newdlfiles=
56399f606849Smrg	    for lib in $dlfiles; do
56409f606849Smrg	      case $lib in
56419f606849Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
56429f606849Smrg		*) abs=`pwd`"/$lib" ;;
56439f606849Smrg	      esac
56449f606849Smrg	      newdlfiles="$newdlfiles $abs"
56459f606849Smrg	    done
56469f606849Smrg	    dlfiles="$newdlfiles"
56479f606849Smrg	    newdlprefiles=
56489f606849Smrg	    for lib in $dlprefiles; do
56499f606849Smrg	      case $lib in
56509f606849Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
56519f606849Smrg		*) abs=`pwd`"/$lib" ;;
56529f606849Smrg	      esac
56539f606849Smrg	      newdlprefiles="$newdlprefiles $abs"
56549f606849Smrg	    done
56559f606849Smrg	    dlprefiles="$newdlprefiles"
56569f606849Smrg	  fi
56579f606849Smrg	  $rm $output
56589f606849Smrg	  # place dlname in correct position for cygwin
56599f606849Smrg	  tdlname=$dlname
56609f606849Smrg	  case $host,$output,$installed,$module,$dlname in
56619f606849Smrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
56629f606849Smrg	  esac
56639f606849Smrg	  $echo > $output "\
56649f606849Smrg# $outputname - a libtool library file
56659f606849Smrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
56669f606849Smrg#
56679f606849Smrg# Please DO NOT delete this file!
56689f606849Smrg# It is necessary for linking the library.
56699f606849Smrg
56709f606849Smrg# The name that we can dlopen(3).
56719f606849Smrgdlname='$tdlname'
56729f606849Smrg
56739f606849Smrg# Names of this library.
56749f606849Smrglibrary_names='$library_names'
56759f606849Smrg
56769f606849Smrg# The name of the static archive.
56779f606849Smrgold_library='$old_library'
56789f606849Smrg
56799f606849Smrg# Libraries that this one depends upon.
56809f606849Smrgdependency_libs='$dependency_libs'
56819f606849Smrg
56829f606849Smrg# Version information for $libname.
56839f606849Smrgcurrent=$current
56849f606849Smrgage=$age
56859f606849Smrgrevision=$revision
56869f606849Smrg
56879f606849Smrg# Is this an already installed library?
56889f606849Smrginstalled=$installed
56899f606849Smrg
56909f606849Smrg# Should we warn about portability when linking against -modules?
56919f606849Smrgshouldnotlink=$module
56929f606849Smrg
56939f606849Smrg# Files to dlopen/dlpreopen
56949f606849Smrgdlopen='$dlfiles'
56959f606849Smrgdlpreopen='$dlprefiles'
56969f606849Smrg
56979f606849Smrg# Directory that this library needs to be installed in:
56989f606849Smrglibdir='$install_libdir'"
56999f606849Smrg	  if test "$installed" = no && test "$need_relink" = yes; then
57009f606849Smrg	    $echo >> $output "\
57019f606849Smrgrelink_command=\"$relink_command\""
57029f606849Smrg	  fi
57039f606849Smrg	done
57049f606849Smrg      fi
57059f606849Smrg
57069f606849Smrg      # Do a symbolic link so that the libtool archive can be found in
57079f606849Smrg      # LD_LIBRARY_PATH before the program is installed.
57089f606849Smrg      $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)"
57099f606849Smrg      $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $?
57109f606849Smrg      ;;
57119f606849Smrg    esac
57129f606849Smrg    exit $EXIT_SUCCESS
57139f606849Smrg    ;;
57149f606849Smrg
57159f606849Smrg  # libtool install mode
57169f606849Smrg  install)
57179f606849Smrg    modename="$modename: install"
57189f606849Smrg
57199f606849Smrg    # There may be an optional sh(1) argument at the beginning of
57209f606849Smrg    # install_prog (especially on Windows NT).
57219f606849Smrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
57229f606849Smrg       # Allow the use of GNU shtool's install command.
57239f606849Smrg       $echo "X$nonopt" | grep shtool > /dev/null; then
57249f606849Smrg      # Aesthetically quote it.
57259f606849Smrg      arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"`
57269f606849Smrg      case $arg in
57279f606849Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
57289f606849Smrg	arg="\"$arg\""
57299f606849Smrg	;;
57309f606849Smrg      esac
57319f606849Smrg      install_prog="$arg "
57329f606849Smrg      arg="$1"
57339f606849Smrg      shift
57349f606849Smrg    else
57359f606849Smrg      install_prog=
57369f606849Smrg      arg=$nonopt
57379f606849Smrg    fi
57389f606849Smrg
57399f606849Smrg    # The real first argument should be the name of the installation program.
57409f606849Smrg    # Aesthetically quote it.
57419f606849Smrg    arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
57429f606849Smrg    case $arg in
57439f606849Smrg    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
57449f606849Smrg      arg="\"$arg\""
57459f606849Smrg      ;;
57469f606849Smrg    esac
57479f606849Smrg    install_prog="$install_prog$arg"
57489f606849Smrg
57499f606849Smrg    # We need to accept at least all the BSD install flags.
57509f606849Smrg    dest=
57519f606849Smrg    files=
57529f606849Smrg    opts=
57539f606849Smrg    prev=
57549f606849Smrg    install_type=
57559f606849Smrg    isdir=no
57569f606849Smrg    stripme=
57579f606849Smrg    for arg
57589f606849Smrg    do
57599f606849Smrg      if test -n "$dest"; then
57609f606849Smrg	files="$files $dest"
57619f606849Smrg	dest=$arg
57629f606849Smrg	continue
57639f606849Smrg      fi
57649f606849Smrg
57659f606849Smrg      case $arg in
57669f606849Smrg      -d) isdir=yes ;;
57679f606849Smrg      -f) 
57689f606849Smrg      	case " $install_prog " in
57699f606849Smrg	*[\\\ /]cp\ *) ;;
57709f606849Smrg	*) prev=$arg ;;
57719f606849Smrg	esac
57729f606849Smrg	;;
57739f606849Smrg      -g | -m | -o) prev=$arg ;;
57749f606849Smrg      -s)
57759f606849Smrg	stripme=" -s"
57769f606849Smrg	continue
57779f606849Smrg	;;
57789f606849Smrg      -*)
57799f606849Smrg	;;
57809f606849Smrg      *)
57819f606849Smrg	# If the previous option needed an argument, then skip it.
57829f606849Smrg	if test -n "$prev"; then
57839f606849Smrg	  prev=
57849f606849Smrg	else
57859f606849Smrg	  dest=$arg
57869f606849Smrg	  continue
57879f606849Smrg	fi
57889f606849Smrg	;;
57899f606849Smrg      esac
57909f606849Smrg
57919f606849Smrg      # Aesthetically quote the argument.
57929f606849Smrg      arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
57939f606849Smrg      case $arg in
57949f606849Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
57959f606849Smrg	arg="\"$arg\""
57969f606849Smrg	;;
57979f606849Smrg      esac
57989f606849Smrg      install_prog="$install_prog $arg"
57999f606849Smrg    done
58009f606849Smrg
58019f606849Smrg    if test -z "$install_prog"; then
58029f606849Smrg      $echo "$modename: you must specify an install program" 1>&2
58039f606849Smrg      $echo "$help" 1>&2
58049f606849Smrg      exit $EXIT_FAILURE
58059f606849Smrg    fi
58069f606849Smrg
58079f606849Smrg    if test -n "$prev"; then
58089f606849Smrg      $echo "$modename: the \`$prev' option requires an argument" 1>&2
58099f606849Smrg      $echo "$help" 1>&2
58109f606849Smrg      exit $EXIT_FAILURE
58119f606849Smrg    fi
58129f606849Smrg
58139f606849Smrg    if test -z "$files"; then
58149f606849Smrg      if test -z "$dest"; then
58159f606849Smrg	$echo "$modename: no file or destination specified" 1>&2
58169f606849Smrg      else
58179f606849Smrg	$echo "$modename: you must specify a destination" 1>&2
58189f606849Smrg      fi
58199f606849Smrg      $echo "$help" 1>&2
58209f606849Smrg      exit $EXIT_FAILURE
58219f606849Smrg    fi
58229f606849Smrg
58239f606849Smrg    # Strip any trailing slash from the destination.
58249f606849Smrg    dest=`$echo "X$dest" | $Xsed -e 's%/$%%'`
58259f606849Smrg
58269f606849Smrg    # Check to see that the destination is a directory.
58279f606849Smrg    test -d "$dest" && isdir=yes
58289f606849Smrg    if test "$isdir" = yes; then
58299f606849Smrg      destdir="$dest"
58309f606849Smrg      destname=
58319f606849Smrg    else
58329f606849Smrg      destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'`
58339f606849Smrg      test "X$destdir" = "X$dest" && destdir=.
58349f606849Smrg      destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'`
58359f606849Smrg
58369f606849Smrg      # Not a directory, so check to see that there is only one file specified.
58379f606849Smrg      set dummy $files
58389f606849Smrg      if test "$#" -gt 2; then
58399f606849Smrg	$echo "$modename: \`$dest' is not a directory" 1>&2
58409f606849Smrg	$echo "$help" 1>&2
58419f606849Smrg	exit $EXIT_FAILURE
58429f606849Smrg      fi
58439f606849Smrg    fi
58449f606849Smrg    case $destdir in
58459f606849Smrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
58469f606849Smrg    *)
58479f606849Smrg      for file in $files; do
58489f606849Smrg	case $file in
58499f606849Smrg	*.lo) ;;
58509f606849Smrg	*)
58519f606849Smrg	  $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2
58529f606849Smrg	  $echo "$help" 1>&2
58539f606849Smrg	  exit $EXIT_FAILURE
58549f606849Smrg	  ;;
58559f606849Smrg	esac
58569f606849Smrg      done
58579f606849Smrg      ;;
58589f606849Smrg    esac
58599f606849Smrg
58609f606849Smrg    # This variable tells wrapper scripts just to set variables rather
58619f606849Smrg    # than running their programs.
58629f606849Smrg    libtool_install_magic="$magic"
58639f606849Smrg
58649f606849Smrg    staticlibs=
58659f606849Smrg    future_libdirs=
58669f606849Smrg    current_libdirs=
58679f606849Smrg    for file in $files; do
58689f606849Smrg
58699f606849Smrg      # Do each installation.
58709f606849Smrg      case $file in
58719f606849Smrg      *.$libext)
58729f606849Smrg	# Do the static libraries later.
58739f606849Smrg	staticlibs="$staticlibs $file"
58749f606849Smrg	;;
58759f606849Smrg
58769f606849Smrg      *.la)
58779f606849Smrg	# Check to see that this really is a libtool archive.
58789f606849Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
58799f606849Smrg	else
58809f606849Smrg	  $echo "$modename: \`$file' is not a valid libtool archive" 1>&2
58819f606849Smrg	  $echo "$help" 1>&2
58829f606849Smrg	  exit $EXIT_FAILURE
58839f606849Smrg	fi
58849f606849Smrg
58859f606849Smrg	library_names=
58869f606849Smrg	old_library=
58879f606849Smrg	relink_command=
58889f606849Smrg	# If there is no directory component, then add one.
58899f606849Smrg	case $file in
58909f606849Smrg	*/* | *\\*) . $file ;;
58919f606849Smrg	*) . ./$file ;;
58929f606849Smrg	esac
58939f606849Smrg
58949f606849Smrg	# Add the libdir to current_libdirs if it is the destination.
58959f606849Smrg	if test "X$destdir" = "X$libdir"; then
58969f606849Smrg	  case "$current_libdirs " in
58979f606849Smrg	  *" $libdir "*) ;;
58989f606849Smrg	  *) current_libdirs="$current_libdirs $libdir" ;;
58999f606849Smrg	  esac
59009f606849Smrg	else
59019f606849Smrg	  # Note the libdir as a future libdir.
59029f606849Smrg	  case "$future_libdirs " in
59039f606849Smrg	  *" $libdir "*) ;;
59049f606849Smrg	  *) future_libdirs="$future_libdirs $libdir" ;;
59059f606849Smrg	  esac
59069f606849Smrg	fi
59079f606849Smrg
59089f606849Smrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/
59099f606849Smrg	test "X$dir" = "X$file/" && dir=
59109f606849Smrg	dir="$dir$objdir"
59119f606849Smrg
59129f606849Smrg	if test -n "$relink_command"; then
59139f606849Smrg	  # Determine the prefix the user has applied to our future dir.
59149f606849Smrg	  inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"`
59159f606849Smrg
59169f606849Smrg	  # Don't allow the user to place us outside of our expected
59179f606849Smrg	  # location b/c this prevents finding dependent libraries that
59189f606849Smrg	  # are installed to the same prefix.
59199f606849Smrg	  # At present, this check doesn't affect windows .dll's that
59209f606849Smrg	  # are installed into $libdir/../bin (currently, that works fine)
59219f606849Smrg	  # but it's something to keep an eye on.
59229f606849Smrg	  if test "$inst_prefix_dir" = "$destdir"; then
59239f606849Smrg	    $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2
59249f606849Smrg	    exit $EXIT_FAILURE
59259f606849Smrg	  fi
59269f606849Smrg
59279f606849Smrg	  if test -n "$inst_prefix_dir"; then
59289f606849Smrg	    # Stick the inst_prefix_dir data into the link command.
59299f606849Smrg	    relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
59309f606849Smrg	  else
59319f606849Smrg	    relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
59329f606849Smrg	  fi
59339f606849Smrg
59349f606849Smrg	  $echo "$modename: warning: relinking \`$file'" 1>&2
59359f606849Smrg	  $show "$relink_command"
59369f606849Smrg	  if $run eval "$relink_command"; then :
59379f606849Smrg	  else
59389f606849Smrg	    $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
59399f606849Smrg	    exit $EXIT_FAILURE
59409f606849Smrg	  fi
59419f606849Smrg	fi
59429f606849Smrg
59439f606849Smrg	# See the names of the shared library.
59449f606849Smrg	set dummy $library_names
59459f606849Smrg	if test -n "$2"; then
59469f606849Smrg	  realname="$2"
59479f606849Smrg	  shift
59489f606849Smrg	  shift
59499f606849Smrg
59509f606849Smrg	  srcname="$realname"
59519f606849Smrg	  test -n "$relink_command" && srcname="$realname"T
59529f606849Smrg
59539f606849Smrg	  # Install the shared library and build the symlinks.
59549f606849Smrg	  $show "$install_prog $dir/$srcname $destdir/$realname"
59559f606849Smrg	  $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $?
59569f606849Smrg	  if test -n "$stripme" && test -n "$striplib"; then
59579f606849Smrg	    $show "$striplib $destdir/$realname"
59589f606849Smrg	    $run eval "$striplib $destdir/$realname" || exit $?
59599f606849Smrg	  fi
59609f606849Smrg
59619f606849Smrg	  if test "$#" -gt 0; then
59629f606849Smrg	    # Delete the old symlinks, and create new ones.
59639f606849Smrg	    # Try `ln -sf' first, because the `ln' binary might depend on
59649f606849Smrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
59659f606849Smrg	    # so we also need to try rm && ln -s.
59669f606849Smrg	    for linkname
59679f606849Smrg	    do
59689f606849Smrg	      if test "$linkname" != "$realname"; then
59699f606849Smrg                $show "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
59709f606849Smrg                $run eval "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
59719f606849Smrg	      fi
59729f606849Smrg	    done
59739f606849Smrg	  fi
59749f606849Smrg
59759f606849Smrg	  # Do each command in the postinstall commands.
59769f606849Smrg	  lib="$destdir/$realname"
59779f606849Smrg	  cmds=$postinstall_cmds
59789f606849Smrg	  save_ifs="$IFS"; IFS='~'
59799f606849Smrg	  for cmd in $cmds; do
59809f606849Smrg	    IFS="$save_ifs"
59819f606849Smrg	    eval cmd=\"$cmd\"
59829f606849Smrg	    $show "$cmd"
59839f606849Smrg	    $run eval "$cmd" || {
59849f606849Smrg	      lt_exit=$?
59859f606849Smrg
59869f606849Smrg	      # Restore the uninstalled library and exit
59879f606849Smrg	      if test "$mode" = relink; then
59889f606849Smrg		$run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
59899f606849Smrg	      fi
59909f606849Smrg
59919f606849Smrg	      exit $lt_exit
59929f606849Smrg	    }
59939f606849Smrg	  done
59949f606849Smrg	  IFS="$save_ifs"
59959f606849Smrg	fi
59969f606849Smrg
59979f606849Smrg	# Install the pseudo-library for information purposes.
59989f606849Smrg	name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
59999f606849Smrg	instname="$dir/$name"i
60009f606849Smrg	$show "$install_prog $instname $destdir/$name"
60019f606849Smrg	$run eval "$install_prog $instname $destdir/$name" || exit $?
60029f606849Smrg
60039f606849Smrg	# Maybe install the static library, too.
60049f606849Smrg	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
60059f606849Smrg	;;
60069f606849Smrg
60079f606849Smrg      *.lo)
60089f606849Smrg	# Install (i.e. copy) a libtool object.
60099f606849Smrg
60109f606849Smrg	# Figure out destination file name, if it wasn't already specified.
60119f606849Smrg	if test -n "$destname"; then
60129f606849Smrg	  destfile="$destdir/$destname"
60139f606849Smrg	else
60149f606849Smrg	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
60159f606849Smrg	  destfile="$destdir/$destfile"
60169f606849Smrg	fi
60179f606849Smrg
60189f606849Smrg	# Deduce the name of the destination old-style object file.
60199f606849Smrg	case $destfile in
60209f606849Smrg	*.lo)
60219f606849Smrg	  staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"`
60229f606849Smrg	  ;;
60239f606849Smrg	*.$objext)
60249f606849Smrg	  staticdest="$destfile"
60259f606849Smrg	  destfile=
60269f606849Smrg	  ;;
60279f606849Smrg	*)
60289f606849Smrg	  $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2
60299f606849Smrg	  $echo "$help" 1>&2
60309f606849Smrg	  exit $EXIT_FAILURE
60319f606849Smrg	  ;;
60329f606849Smrg	esac
60339f606849Smrg
60349f606849Smrg	# Install the libtool object if requested.
60359f606849Smrg	if test -n "$destfile"; then
60369f606849Smrg	  $show "$install_prog $file $destfile"
60379f606849Smrg	  $run eval "$install_prog $file $destfile" || exit $?
60389f606849Smrg	fi
60399f606849Smrg
60409f606849Smrg	# Install the old object if enabled.
60419f606849Smrg	if test "$build_old_libs" = yes; then
60429f606849Smrg	  # Deduce the name of the old-style object file.
60439f606849Smrg	  staticobj=`$echo "X$file" | $Xsed -e "$lo2o"`
60449f606849Smrg
60459f606849Smrg	  $show "$install_prog $staticobj $staticdest"
60469f606849Smrg	  $run eval "$install_prog \$staticobj \$staticdest" || exit $?
60479f606849Smrg	fi
60489f606849Smrg	exit $EXIT_SUCCESS
60499f606849Smrg	;;
60509f606849Smrg
60519f606849Smrg      *)
60529f606849Smrg	# Figure out destination file name, if it wasn't already specified.
60539f606849Smrg	if test -n "$destname"; then
60549f606849Smrg	  destfile="$destdir/$destname"
60559f606849Smrg	else
60569f606849Smrg	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
60579f606849Smrg	  destfile="$destdir/$destfile"
60589f606849Smrg	fi
60599f606849Smrg
60609f606849Smrg	# If the file is missing, and there is a .exe on the end, strip it
60619f606849Smrg	# because it is most likely a libtool script we actually want to
60629f606849Smrg	# install
60639f606849Smrg	stripped_ext=""
60649f606849Smrg	case $file in
60659f606849Smrg	  *.exe)
60669f606849Smrg	    if test ! -f "$file"; then
60679f606849Smrg	      file=`$echo $file|${SED} 's,.exe$,,'`
60689f606849Smrg	      stripped_ext=".exe"
60699f606849Smrg	    fi
60709f606849Smrg	    ;;
60719f606849Smrg	esac
60729f606849Smrg
60739f606849Smrg	# Do a test to see if this is really a libtool program.
60749f606849Smrg	case $host in
60759f606849Smrg	*cygwin*|*mingw*)
60769f606849Smrg	    wrapper=`$echo $file | ${SED} -e 's,.exe$,,'`
60779f606849Smrg	    ;;
60789f606849Smrg	*)
60799f606849Smrg	    wrapper=$file
60809f606849Smrg	    ;;
60819f606849Smrg	esac
60829f606849Smrg	if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then
60839f606849Smrg	  notinst_deplibs=
60849f606849Smrg	  relink_command=
60859f606849Smrg
60869f606849Smrg	  # Note that it is not necessary on cygwin/mingw to append a dot to
60879f606849Smrg	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
60889f606849Smrg	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
60899f606849Smrg	  # `FILE.' does not work on cygwin managed mounts.
60909f606849Smrg	  #
60919f606849Smrg	  # If there is no directory component, then add one.
60929f606849Smrg	  case $wrapper in
60939f606849Smrg	  */* | *\\*) . ${wrapper} ;;
60949f606849Smrg	  *) . ./${wrapper} ;;
60959f606849Smrg	  esac
60969f606849Smrg
60979f606849Smrg	  # Check the variables that should have been set.
60989f606849Smrg	  if test -z "$notinst_deplibs"; then
60999f606849Smrg	    $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2
61009f606849Smrg	    exit $EXIT_FAILURE
61019f606849Smrg	  fi
61029f606849Smrg
61039f606849Smrg	  finalize=yes
61049f606849Smrg	  for lib in $notinst_deplibs; do
61059f606849Smrg	    # Check to see that each library is installed.
61069f606849Smrg	    libdir=
61079f606849Smrg	    if test -f "$lib"; then
61089f606849Smrg	      # If there is no directory component, then add one.
61099f606849Smrg	      case $lib in
61109f606849Smrg	      */* | *\\*) . $lib ;;
61119f606849Smrg	      *) . ./$lib ;;
61129f606849Smrg	      esac
61139f606849Smrg	    fi
61149f606849Smrg	    libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
61159f606849Smrg	    if test -n "$libdir" && test ! -f "$libfile"; then
61169f606849Smrg	      $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2
61179f606849Smrg	      finalize=no
61189f606849Smrg	    fi
61199f606849Smrg	  done
61209f606849Smrg
61219f606849Smrg	  relink_command=
61229f606849Smrg	  # Note that it is not necessary on cygwin/mingw to append a dot to
61239f606849Smrg	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
61249f606849Smrg	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
61259f606849Smrg	  # `FILE.' does not work on cygwin managed mounts.
61269f606849Smrg	  #
61279f606849Smrg	  # If there is no directory component, then add one.
61289f606849Smrg	  case $wrapper in
61299f606849Smrg	  */* | *\\*) . ${wrapper} ;;
61309f606849Smrg	  *) . ./${wrapper} ;;
61319f606849Smrg	  esac
61329f606849Smrg
61339f606849Smrg	  outputname=
61349f606849Smrg	  if test "$fast_install" = no && test -n "$relink_command"; then
61359f606849Smrg	    if test "$finalize" = yes && test -z "$run"; then
61369f606849Smrg	      tmpdir=`func_mktempdir`
61379f606849Smrg	      file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
61389f606849Smrg	      outputname="$tmpdir/$file"
61399f606849Smrg	      # Replace the output file specification.
61409f606849Smrg	      relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
61419f606849Smrg
61429f606849Smrg	      $show "$relink_command"
61439f606849Smrg	      if $run eval "$relink_command"; then :
61449f606849Smrg	      else
61459f606849Smrg		$echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
61469f606849Smrg		${rm}r "$tmpdir"
61479f606849Smrg		continue
61489f606849Smrg	      fi
61499f606849Smrg	      file="$outputname"
61509f606849Smrg	    else
61519f606849Smrg	      $echo "$modename: warning: cannot relink \`$file'" 1>&2
61529f606849Smrg	    fi
61539f606849Smrg	  else
61549f606849Smrg	    # Install the binary that we compiled earlier.
61559f606849Smrg	    file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
61569f606849Smrg	  fi
61579f606849Smrg	fi
61589f606849Smrg
61599f606849Smrg	# remove .exe since cygwin /usr/bin/install will append another
61609f606849Smrg	# one anyway 
61619f606849Smrg	case $install_prog,$host in
61629f606849Smrg	*/usr/bin/install*,*cygwin*)
61639f606849Smrg	  case $file:$destfile in
61649f606849Smrg	  *.exe:*.exe)
61659f606849Smrg	    # this is ok
61669f606849Smrg	    ;;
61679f606849Smrg	  *.exe:*)
61689f606849Smrg	    destfile=$destfile.exe
61699f606849Smrg	    ;;
61709f606849Smrg	  *:*.exe)
61719f606849Smrg	    destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'`
61729f606849Smrg	    ;;
61739f606849Smrg	  esac
61749f606849Smrg	  ;;
61759f606849Smrg	esac
61769f606849Smrg	$show "$install_prog$stripme $file $destfile"
61779f606849Smrg	$run eval "$install_prog\$stripme \$file \$destfile" || exit $?
61789f606849Smrg	test -n "$outputname" && ${rm}r "$tmpdir"
61799f606849Smrg	;;
61809f606849Smrg      esac
61819f606849Smrg    done
61829f606849Smrg
61839f606849Smrg    for file in $staticlibs; do
61849f606849Smrg      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
61859f606849Smrg
61869f606849Smrg      # Set up the ranlib parameters.
61879f606849Smrg      oldlib="$destdir/$name"
61889f606849Smrg
61899f606849Smrg      $show "$install_prog $file $oldlib"
61909f606849Smrg      $run eval "$install_prog \$file \$oldlib" || exit $?
61919f606849Smrg
61929f606849Smrg      if test -n "$stripme" && test -n "$old_striplib"; then
61939f606849Smrg	$show "$old_striplib $oldlib"
61949f606849Smrg	$run eval "$old_striplib $oldlib" || exit $?
61959f606849Smrg      fi
61969f606849Smrg
61979f606849Smrg      # Do each command in the postinstall commands.
61989f606849Smrg      cmds=$old_postinstall_cmds
61999f606849Smrg      save_ifs="$IFS"; IFS='~'
62009f606849Smrg      for cmd in $cmds; do
62019f606849Smrg	IFS="$save_ifs"
62029f606849Smrg	eval cmd=\"$cmd\"
62039f606849Smrg	$show "$cmd"
62049f606849Smrg	$run eval "$cmd" || exit $?
62059f606849Smrg      done
62069f606849Smrg      IFS="$save_ifs"
62079f606849Smrg    done
62089f606849Smrg
62099f606849Smrg    if test -n "$future_libdirs"; then
62109f606849Smrg      $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2
62119f606849Smrg    fi
62129f606849Smrg
62139f606849Smrg    if test -n "$current_libdirs"; then
62149f606849Smrg      # Maybe just do a dry run.
62159f606849Smrg      test -n "$run" && current_libdirs=" -n$current_libdirs"
62169f606849Smrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
62179f606849Smrg    else
62189f606849Smrg      exit $EXIT_SUCCESS
62199f606849Smrg    fi
62209f606849Smrg    ;;
62219f606849Smrg
62229f606849Smrg  # libtool finish mode
62239f606849Smrg  finish)
62249f606849Smrg    modename="$modename: finish"
62259f606849Smrg    libdirs="$nonopt"
62269f606849Smrg    admincmds=
62279f606849Smrg
62289f606849Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
62299f606849Smrg      for dir
62309f606849Smrg      do
62319f606849Smrg	libdirs="$libdirs $dir"
62329f606849Smrg      done
62339f606849Smrg
62349f606849Smrg      for libdir in $libdirs; do
62359f606849Smrg	if test -n "$finish_cmds"; then
62369f606849Smrg	  # Do each command in the finish commands.
62379f606849Smrg	  cmds=$finish_cmds
62389f606849Smrg	  save_ifs="$IFS"; IFS='~'
62399f606849Smrg	  for cmd in $cmds; do
62409f606849Smrg	    IFS="$save_ifs"
62419f606849Smrg	    eval cmd=\"$cmd\"
62429f606849Smrg	    $show "$cmd"
62439f606849Smrg	    $run eval "$cmd" || admincmds="$admincmds
62449f606849Smrg       $cmd"
62459f606849Smrg	  done
62469f606849Smrg	  IFS="$save_ifs"
62479f606849Smrg	fi
62489f606849Smrg	if test -n "$finish_eval"; then
62499f606849Smrg	  # Do the single finish_eval.
62509f606849Smrg	  eval cmds=\"$finish_eval\"
62519f606849Smrg	  $run eval "$cmds" || admincmds="$admincmds
62529f606849Smrg       $cmds"
62539f606849Smrg	fi
62549f606849Smrg      done
62559f606849Smrg    fi
62569f606849Smrg
62579f606849Smrg    # Exit here if they wanted silent mode.
62589f606849Smrg    test "$show" = : && exit $EXIT_SUCCESS
62599f606849Smrg
62609f606849Smrg    $echo "X----------------------------------------------------------------------" | $Xsed
62619f606849Smrg    $echo "Libraries have been installed in:"
62629f606849Smrg    for libdir in $libdirs; do
62639f606849Smrg      $echo "   $libdir"
62649f606849Smrg    done
62659f606849Smrg    $echo
62669f606849Smrg    $echo "If you ever happen to want to link against installed libraries"
62679f606849Smrg    $echo "in a given directory, LIBDIR, you must either use libtool, and"
62689f606849Smrg    $echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
62699f606849Smrg    $echo "flag during linking and do at least one of the following:"
62709f606849Smrg    if test -n "$shlibpath_var"; then
62719f606849Smrg      $echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
62729f606849Smrg      $echo "     during execution"
62739f606849Smrg    fi
62749f606849Smrg    if test -n "$runpath_var"; then
62759f606849Smrg      $echo "   - add LIBDIR to the \`$runpath_var' environment variable"
62769f606849Smrg      $echo "     during linking"
62779f606849Smrg    fi
62789f606849Smrg    if test -n "$hardcode_libdir_flag_spec"; then
62799f606849Smrg      libdir=LIBDIR
62809f606849Smrg      eval flag=\"$hardcode_libdir_flag_spec\"
62819f606849Smrg
62829f606849Smrg      $echo "   - use the \`$flag' linker flag"
62839f606849Smrg    fi
62849f606849Smrg    if test -n "$admincmds"; then
62859f606849Smrg      $echo "   - have your system administrator run these commands:$admincmds"
62869f606849Smrg    fi
62879f606849Smrg    if test -f /etc/ld.so.conf; then
62889f606849Smrg      $echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
62899f606849Smrg    fi
62909f606849Smrg    $echo
62919f606849Smrg    $echo "See any operating system documentation about shared libraries for"
62929f606849Smrg    $echo "more information, such as the ld(1) and ld.so(8) manual pages."
62939f606849Smrg    $echo "X----------------------------------------------------------------------" | $Xsed
62949f606849Smrg    exit $EXIT_SUCCESS
62959f606849Smrg    ;;
62969f606849Smrg
62979f606849Smrg  # libtool execute mode
62989f606849Smrg  execute)
62999f606849Smrg    modename="$modename: execute"
63009f606849Smrg
63019f606849Smrg    # The first argument is the command name.
63029f606849Smrg    cmd="$nonopt"
63039f606849Smrg    if test -z "$cmd"; then
63049f606849Smrg      $echo "$modename: you must specify a COMMAND" 1>&2
63059f606849Smrg      $echo "$help"
63069f606849Smrg      exit $EXIT_FAILURE
63079f606849Smrg    fi
63089f606849Smrg
63099f606849Smrg    # Handle -dlopen flags immediately.
63109f606849Smrg    for file in $execute_dlfiles; do
63119f606849Smrg      if test ! -f "$file"; then
63129f606849Smrg	$echo "$modename: \`$file' is not a file" 1>&2
63139f606849Smrg	$echo "$help" 1>&2
63149f606849Smrg	exit $EXIT_FAILURE
63159f606849Smrg      fi
63169f606849Smrg
63179f606849Smrg      dir=
63189f606849Smrg      case $file in
63199f606849Smrg      *.la)
63209f606849Smrg	# Check to see that this really is a libtool archive.
63219f606849Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
63229f606849Smrg	else
63239f606849Smrg	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
63249f606849Smrg	  $echo "$help" 1>&2
63259f606849Smrg	  exit $EXIT_FAILURE
63269f606849Smrg	fi
63279f606849Smrg
63289f606849Smrg	# Read the libtool library.
63299f606849Smrg	dlname=
63309f606849Smrg	library_names=
63319f606849Smrg
63329f606849Smrg	# If there is no directory component, then add one.
63339f606849Smrg	case $file in
63349f606849Smrg	*/* | *\\*) . $file ;;
63359f606849Smrg	*) . ./$file ;;
63369f606849Smrg	esac
63379f606849Smrg
63389f606849Smrg	# Skip this library if it cannot be dlopened.
63399f606849Smrg	if test -z "$dlname"; then
63409f606849Smrg	  # Warn if it was a shared library.
63419f606849Smrg	  test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'"
63429f606849Smrg	  continue
63439f606849Smrg	fi
63449f606849Smrg
63459f606849Smrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
63469f606849Smrg	test "X$dir" = "X$file" && dir=.
63479f606849Smrg
63489f606849Smrg	if test -f "$dir/$objdir/$dlname"; then
63499f606849Smrg	  dir="$dir/$objdir"
63509f606849Smrg	else
63519f606849Smrg	  $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
63529f606849Smrg	  exit $EXIT_FAILURE
63539f606849Smrg	fi
63549f606849Smrg	;;
63559f606849Smrg
63569f606849Smrg      *.lo)
63579f606849Smrg	# Just add the directory containing the .lo file.
63589f606849Smrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
63599f606849Smrg	test "X$dir" = "X$file" && dir=.
63609f606849Smrg	;;
63619f606849Smrg
63629f606849Smrg      *)
63639f606849Smrg	$echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2
63649f606849Smrg	continue
63659f606849Smrg	;;
63669f606849Smrg      esac
63679f606849Smrg
63689f606849Smrg      # Get the absolute pathname.
63699f606849Smrg      absdir=`cd "$dir" && pwd`
63709f606849Smrg      test -n "$absdir" && dir="$absdir"
63719f606849Smrg
63729f606849Smrg      # Now add the directory to shlibpath_var.
63739f606849Smrg      if eval "test -z \"\$$shlibpath_var\""; then
63749f606849Smrg	eval "$shlibpath_var=\"\$dir\""
63759f606849Smrg      else
63769f606849Smrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
63779f606849Smrg      fi
63789f606849Smrg    done
63799f606849Smrg
63809f606849Smrg    # This variable tells wrapper scripts just to set shlibpath_var
63819f606849Smrg    # rather than running their programs.
63829f606849Smrg    libtool_execute_magic="$magic"
63839f606849Smrg
63849f606849Smrg    # Check if any of the arguments is a wrapper script.
63859f606849Smrg    args=
63869f606849Smrg    for file
63879f606849Smrg    do
63889f606849Smrg      case $file in
63899f606849Smrg      -*) ;;
63909f606849Smrg      *)
63919f606849Smrg	# Do a test to see if this is really a libtool program.
63929f606849Smrg	if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
63939f606849Smrg	  # If there is no directory component, then add one.
63949f606849Smrg	  case $file in
63959f606849Smrg	  */* | *\\*) . $file ;;
63969f606849Smrg	  *) . ./$file ;;
63979f606849Smrg	  esac
63989f606849Smrg
63999f606849Smrg	  # Transform arg to wrapped name.
64009f606849Smrg	  file="$progdir/$program"
64019f606849Smrg	fi
64029f606849Smrg	;;
64039f606849Smrg      esac
64049f606849Smrg      # Quote arguments (to preserve shell metacharacters).
64059f606849Smrg      file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"`
64069f606849Smrg      args="$args \"$file\""
64079f606849Smrg    done
64089f606849Smrg
64099f606849Smrg    if test -z "$run"; then
64109f606849Smrg      if test -n "$shlibpath_var"; then
64119f606849Smrg	# Export the shlibpath_var.
64129f606849Smrg	eval "export $shlibpath_var"
64139f606849Smrg      fi
64149f606849Smrg
64159f606849Smrg      # Restore saved environment variables
64169f606849Smrg      if test "${save_LC_ALL+set}" = set; then
64179f606849Smrg	LC_ALL="$save_LC_ALL"; export LC_ALL
64189f606849Smrg      fi
64199f606849Smrg      if test "${save_LANG+set}" = set; then
64209f606849Smrg	LANG="$save_LANG"; export LANG
64219f606849Smrg      fi
64229f606849Smrg
64239f606849Smrg      # Now prepare to actually exec the command.
64249f606849Smrg      exec_cmd="\$cmd$args"
64259f606849Smrg    else
64269f606849Smrg      # Display what would be done.
64279f606849Smrg      if test -n "$shlibpath_var"; then
64289f606849Smrg	eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\""
64299f606849Smrg	$echo "export $shlibpath_var"
64309f606849Smrg      fi
64319f606849Smrg      $echo "$cmd$args"
64329f606849Smrg      exit $EXIT_SUCCESS
64339f606849Smrg    fi
64349f606849Smrg    ;;
64359f606849Smrg
64369f606849Smrg  # libtool clean and uninstall mode
64379f606849Smrg  clean | uninstall)
64389f606849Smrg    modename="$modename: $mode"
64399f606849Smrg    rm="$nonopt"
64409f606849Smrg    files=
64419f606849Smrg    rmforce=
64429f606849Smrg    exit_status=0
64439f606849Smrg
64449f606849Smrg    # This variable tells wrapper scripts just to set variables rather
64459f606849Smrg    # than running their programs.
64469f606849Smrg    libtool_install_magic="$magic"
64479f606849Smrg
64489f606849Smrg    for arg
64499f606849Smrg    do
64509f606849Smrg      case $arg in
64519f606849Smrg      -f) rm="$rm $arg"; rmforce=yes ;;
64529f606849Smrg      -*) rm="$rm $arg" ;;
64539f606849Smrg      *) files="$files $arg" ;;
64549f606849Smrg      esac
64559f606849Smrg    done
64569f606849Smrg
64579f606849Smrg    if test -z "$rm"; then
64589f606849Smrg      $echo "$modename: you must specify an RM program" 1>&2
64599f606849Smrg      $echo "$help" 1>&2
64609f606849Smrg      exit $EXIT_FAILURE
64619f606849Smrg    fi
64629f606849Smrg
64639f606849Smrg    rmdirs=
64649f606849Smrg
64659f606849Smrg    origobjdir="$objdir"
64669f606849Smrg    for file in $files; do
64679f606849Smrg      dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
64689f606849Smrg      if test "X$dir" = "X$file"; then
64699f606849Smrg	dir=.
64709f606849Smrg	objdir="$origobjdir"
64719f606849Smrg      else
64729f606849Smrg	objdir="$dir/$origobjdir"
64739f606849Smrg      fi
64749f606849Smrg      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
64759f606849Smrg      test "$mode" = uninstall && objdir="$dir"
64769f606849Smrg
64779f606849Smrg      # Remember objdir for removal later, being careful to avoid duplicates
64789f606849Smrg      if test "$mode" = clean; then
64799f606849Smrg	case " $rmdirs " in
64809f606849Smrg	  *" $objdir "*) ;;
64819f606849Smrg	  *) rmdirs="$rmdirs $objdir" ;;
64829f606849Smrg	esac
64839f606849Smrg      fi
64849f606849Smrg
64859f606849Smrg      # Don't error if the file doesn't exist and rm -f was used.
64869f606849Smrg      if (test -L "$file") >/dev/null 2>&1 \
64879f606849Smrg	|| (test -h "$file") >/dev/null 2>&1 \
64889f606849Smrg	|| test -f "$file"; then
64899f606849Smrg	:
64909f606849Smrg      elif test -d "$file"; then
64919f606849Smrg	exit_status=1
64929f606849Smrg	continue
64939f606849Smrg      elif test "$rmforce" = yes; then
64949f606849Smrg	continue
64959f606849Smrg      fi
64969f606849Smrg
64979f606849Smrg      rmfiles="$file"
64989f606849Smrg
64999f606849Smrg      case $name in
65009f606849Smrg      *.la)
65019f606849Smrg	# Possibly a libtool archive, so verify it.
65029f606849Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
65039f606849Smrg	  . $dir/$name
65049f606849Smrg
65059f606849Smrg	  # Delete the libtool libraries and symlinks.
65069f606849Smrg	  for n in $library_names; do
65079f606849Smrg	    rmfiles="$rmfiles $objdir/$n"
65089f606849Smrg	  done
65099f606849Smrg	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
65109f606849Smrg
65119f606849Smrg	  case "$mode" in
65129f606849Smrg	  clean)
65139f606849Smrg	    case "  $library_names " in
65149f606849Smrg	    # "  " in the beginning catches empty $dlname
65159f606849Smrg	    *" $dlname "*) ;;
65169f606849Smrg	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
65179f606849Smrg	    esac
65189f606849Smrg	     test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
65199f606849Smrg	    ;;
65209f606849Smrg	  uninstall)
65219f606849Smrg	    if test -n "$library_names"; then
65229f606849Smrg	      # Do each command in the postuninstall commands.
65239f606849Smrg	      cmds=$postuninstall_cmds
65249f606849Smrg	      save_ifs="$IFS"; IFS='~'
65259f606849Smrg	      for cmd in $cmds; do
65269f606849Smrg		IFS="$save_ifs"
65279f606849Smrg		eval cmd=\"$cmd\"
65289f606849Smrg		$show "$cmd"
65299f606849Smrg		$run eval "$cmd"
65309f606849Smrg		if test "$?" -ne 0 && test "$rmforce" != yes; then
65319f606849Smrg		  exit_status=1
65329f606849Smrg		fi
65339f606849Smrg	      done
65349f606849Smrg	      IFS="$save_ifs"
65359f606849Smrg	    fi
65369f606849Smrg
65379f606849Smrg	    if test -n "$old_library"; then
65389f606849Smrg	      # Do each command in the old_postuninstall commands.
65399f606849Smrg	      cmds=$old_postuninstall_cmds
65409f606849Smrg	      save_ifs="$IFS"; IFS='~'
65419f606849Smrg	      for cmd in $cmds; do
65429f606849Smrg		IFS="$save_ifs"
65439f606849Smrg		eval cmd=\"$cmd\"
65449f606849Smrg		$show "$cmd"
65459f606849Smrg		$run eval "$cmd"
65469f606849Smrg		if test "$?" -ne 0 && test "$rmforce" != yes; then
65479f606849Smrg		  exit_status=1
65489f606849Smrg		fi
65499f606849Smrg	      done
65509f606849Smrg	      IFS="$save_ifs"
65519f606849Smrg	    fi
65529f606849Smrg	    # FIXME: should reinstall the best remaining shared library.
65539f606849Smrg	    ;;
65549f606849Smrg	  esac
65559f606849Smrg	fi
65569f606849Smrg	;;
65579f606849Smrg
65589f606849Smrg      *.lo)
65599f606849Smrg	# Possibly a libtool object, so verify it.
65609f606849Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
65619f606849Smrg
65629f606849Smrg	  # Read the .lo file
65639f606849Smrg	  . $dir/$name
65649f606849Smrg
65659f606849Smrg	  # Add PIC object to the list of files to remove.
65669f606849Smrg	  if test -n "$pic_object" \
65679f606849Smrg	     && test "$pic_object" != none; then
65689f606849Smrg	    rmfiles="$rmfiles $dir/$pic_object"
65699f606849Smrg	  fi
65709f606849Smrg
65719f606849Smrg	  # Add non-PIC object to the list of files to remove.
65729f606849Smrg	  if test -n "$non_pic_object" \
65739f606849Smrg	     && test "$non_pic_object" != none; then
65749f606849Smrg	    rmfiles="$rmfiles $dir/$non_pic_object"
65759f606849Smrg	  fi
65769f606849Smrg	fi
65779f606849Smrg	;;
65789f606849Smrg
65799f606849Smrg      *)
65809f606849Smrg	if test "$mode" = clean ; then
65819f606849Smrg	  noexename=$name
65829f606849Smrg	  case $file in
65839f606849Smrg	  *.exe)
65849f606849Smrg	    file=`$echo $file|${SED} 's,.exe$,,'`
65859f606849Smrg	    noexename=`$echo $name|${SED} 's,.exe$,,'`
65869f606849Smrg	    # $file with .exe has already been added to rmfiles,
65879f606849Smrg	    # add $file without .exe
65889f606849Smrg	    rmfiles="$rmfiles $file"
65899f606849Smrg	    ;;
65909f606849Smrg	  esac
65919f606849Smrg	  # Do a test to see if this is a libtool program.
65929f606849Smrg	  if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
65939f606849Smrg	    relink_command=
65949f606849Smrg	    . $dir/$noexename
65959f606849Smrg
65969f606849Smrg	    # note $name still contains .exe if it was in $file originally
65979f606849Smrg	    # as does the version of $file that was added into $rmfiles
65989f606849Smrg	    rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
65999f606849Smrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
66009f606849Smrg	      rmfiles="$rmfiles $objdir/lt-$name"
66019f606849Smrg	    fi
66029f606849Smrg	    if test "X$noexename" != "X$name" ; then
66039f606849Smrg	      rmfiles="$rmfiles $objdir/lt-${noexename}.c"
66049f606849Smrg	    fi
66059f606849Smrg	  fi
66069f606849Smrg	fi
66079f606849Smrg	;;
66089f606849Smrg      esac
66099f606849Smrg      $show "$rm $rmfiles"
66109f606849Smrg      $run $rm $rmfiles || exit_status=1
66119f606849Smrg    done
66129f606849Smrg    objdir="$origobjdir"
66139f606849Smrg
66149f606849Smrg    # Try to remove the ${objdir}s in the directories where we deleted files
66159f606849Smrg    for dir in $rmdirs; do
66169f606849Smrg      if test -d "$dir"; then
66179f606849Smrg	$show "rmdir $dir"
66189f606849Smrg	$run rmdir $dir >/dev/null 2>&1
66199f606849Smrg      fi
66209f606849Smrg    done
66219f606849Smrg
66229f606849Smrg    exit $exit_status
66239f606849Smrg    ;;
66249f606849Smrg
66259f606849Smrg  "")
66269f606849Smrg    $echo "$modename: you must specify a MODE" 1>&2
66279f606849Smrg    $echo "$generic_help" 1>&2
66289f606849Smrg    exit $EXIT_FAILURE
66299f606849Smrg    ;;
66309f606849Smrg  esac
66319f606849Smrg
66329f606849Smrg  if test -z "$exec_cmd"; then
66339f606849Smrg    $echo "$modename: invalid operation mode \`$mode'" 1>&2
66349f606849Smrg    $echo "$generic_help" 1>&2
66359f606849Smrg    exit $EXIT_FAILURE
66369f606849Smrg  fi
66379f606849Smrgfi # test -z "$show_help"
66389f606849Smrg
66399f606849Smrgif test -n "$exec_cmd"; then
66409f606849Smrg  eval exec $exec_cmd
66419f606849Smrg  exit $EXIT_FAILURE
66429f606849Smrgfi
66439f606849Smrg
66449f606849Smrg# We need to display help for each of the modes.
66459f606849Smrgcase $mode in
66469f606849Smrg"") $echo \
66479f606849Smrg"Usage: $modename [OPTION]... [MODE-ARG]...
66489f606849Smrg
66499f606849SmrgProvide generalized library-building support services.
66509f606849Smrg
66519f606849Smrg    --config          show all configuration variables
66529f606849Smrg    --debug           enable verbose shell tracing
66539f606849Smrg-n, --dry-run         display commands without modifying any files
66549f606849Smrg    --features        display basic configuration information and exit
66559f606849Smrg    --finish          same as \`--mode=finish'
66569f606849Smrg    --help            display this help message and exit
66579f606849Smrg    --mode=MODE       use operation mode MODE [default=inferred from MODE-ARGS]
66589f606849Smrg    --quiet           same as \`--silent'
66599f606849Smrg    --silent          don't print informational messages
66609f606849Smrg    --tag=TAG         use configuration variables from tag TAG
66619f606849Smrg    --version         print version information
66629f606849Smrg
66639f606849SmrgMODE must be one of the following:
66649f606849Smrg
66659f606849Smrg      clean           remove files from the build directory
66669f606849Smrg      compile         compile a source file into a libtool object
66679f606849Smrg      execute         automatically set library path, then run a program
66689f606849Smrg      finish          complete the installation of libtool libraries
66699f606849Smrg      install         install libraries or executables
66709f606849Smrg      link            create a library or an executable
66719f606849Smrg      uninstall       remove libraries from an installed directory
66729f606849Smrg
66739f606849SmrgMODE-ARGS vary depending on the MODE.  Try \`$modename --help --mode=MODE' for
66749f606849Smrga more detailed description of MODE.
66759f606849Smrg
66769f606849SmrgReport bugs to <bug-libtool@gnu.org>."
66779f606849Smrg  exit $EXIT_SUCCESS
66789f606849Smrg  ;;
66799f606849Smrg
66809f606849Smrgclean)
66819f606849Smrg  $echo \
66829f606849Smrg"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
66839f606849Smrg
66849f606849SmrgRemove files from the build directory.
66859f606849Smrg
66869f606849SmrgRM is the name of the program to use to delete files associated with each FILE
66879f606849Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
66889f606849Smrgto RM.
66899f606849Smrg
66909f606849SmrgIf FILE is a libtool library, object or program, all the files associated
66919f606849Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
66929f606849Smrg  ;;
66939f606849Smrg
66949f606849Smrgcompile)
66959f606849Smrg  $echo \
66969f606849Smrg"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
66979f606849Smrg
66989f606849SmrgCompile a source file into a libtool library object.
66999f606849Smrg
67009f606849SmrgThis mode accepts the following additional options:
67019f606849Smrg
67029f606849Smrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
67039f606849Smrg  -prefer-pic       try to building PIC objects only
67049f606849Smrg  -prefer-non-pic   try to building non-PIC objects only
67059f606849Smrg  -static           always build a \`.o' file suitable for static linking
67069f606849Smrg
67079f606849SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
67089f606849Smrgfrom the given SOURCEFILE.
67099f606849Smrg
67109f606849SmrgThe output file name is determined by removing the directory component from
67119f606849SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
67129f606849Smrglibrary object suffix, \`.lo'."
67139f606849Smrg  ;;
67149f606849Smrg
67159f606849Smrgexecute)
67169f606849Smrg  $echo \
67179f606849Smrg"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]...
67189f606849Smrg
67199f606849SmrgAutomatically set library path, then run a program.
67209f606849Smrg
67219f606849SmrgThis mode accepts the following additional options:
67229f606849Smrg
67239f606849Smrg  -dlopen FILE      add the directory containing FILE to the library path
67249f606849Smrg
67259f606849SmrgThis mode sets the library path environment variable according to \`-dlopen'
67269f606849Smrgflags.
67279f606849Smrg
67289f606849SmrgIf any of the ARGS are libtool executable wrappers, then they are translated
67299f606849Smrginto their corresponding uninstalled binary, and any of their required library
67309f606849Smrgdirectories are added to the library path.
67319f606849Smrg
67329f606849SmrgThen, COMMAND is executed, with ARGS as arguments."
67339f606849Smrg  ;;
67349f606849Smrg
67359f606849Smrgfinish)
67369f606849Smrg  $echo \
67379f606849Smrg"Usage: $modename [OPTION]... --mode=finish [LIBDIR]...
67389f606849Smrg
67399f606849SmrgComplete the installation of libtool libraries.
67409f606849Smrg
67419f606849SmrgEach LIBDIR is a directory that contains libtool libraries.
67429f606849Smrg
67439f606849SmrgThe commands that this mode executes may require superuser privileges.  Use
67449f606849Smrgthe \`--dry-run' option if you just want to see what would be executed."
67459f606849Smrg  ;;
67469f606849Smrg
67479f606849Smrginstall)
67489f606849Smrg  $echo \
67499f606849Smrg"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND...
67509f606849Smrg
67519f606849SmrgInstall executables or libraries.
67529f606849Smrg
67539f606849SmrgINSTALL-COMMAND is the installation command.  The first component should be
67549f606849Smrgeither the \`install' or \`cp' program.
67559f606849Smrg
67569f606849SmrgThe rest of the components are interpreted as arguments to that command (only
67579f606849SmrgBSD-compatible install options are recognized)."
67589f606849Smrg  ;;
67599f606849Smrg
67609f606849Smrglink)
67619f606849Smrg  $echo \
67629f606849Smrg"Usage: $modename [OPTION]... --mode=link LINK-COMMAND...
67639f606849Smrg
67649f606849SmrgLink object files or libraries together to form another library, or to
67659f606849Smrgcreate an executable program.
67669f606849Smrg
67679f606849SmrgLINK-COMMAND is a command using the C compiler that you would use to create
67689f606849Smrga program from several object files.
67699f606849Smrg
67709f606849SmrgThe following components of LINK-COMMAND are treated specially:
67719f606849Smrg
67729f606849Smrg  -all-static       do not do any dynamic linking at all
67739f606849Smrg  -avoid-version    do not add a version suffix if possible
67749f606849Smrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
67759f606849Smrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
67769f606849Smrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
67779f606849Smrg  -export-symbols SYMFILE
67789f606849Smrg		    try to export only the symbols listed in SYMFILE
67799f606849Smrg  -export-symbols-regex REGEX
67809f606849Smrg		    try to export only the symbols matching REGEX
67819f606849Smrg  -LLIBDIR          search LIBDIR for required installed libraries
67829f606849Smrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
67839f606849Smrg  -module           build a library that can dlopened
67849f606849Smrg  -no-fast-install  disable the fast-install mode
67859f606849Smrg  -no-install       link a not-installable executable
67869f606849Smrg  -no-undefined     declare that a library does not refer to external symbols
67879f606849Smrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
67889f606849Smrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
67899f606849Smrg  -precious-files-regex REGEX
67909f606849Smrg                    don't remove output files matching REGEX
67919f606849Smrg  -release RELEASE  specify package release information
67929f606849Smrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
67939f606849Smrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
67949f606849Smrg  -static           do not do any dynamic linking of libtool libraries
67959f606849Smrg  -version-info CURRENT[:REVISION[:AGE]]
67969f606849Smrg		    specify library version info [each variable defaults to 0]
67979f606849Smrg
67989f606849SmrgAll other options (arguments beginning with \`-') are ignored.
67999f606849Smrg
68009f606849SmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
68019f606849Smrgtreated as uninstalled libtool libraries, other files are standard or library
68029f606849Smrgobject files.
68039f606849Smrg
68049f606849SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
68059f606849Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
68069f606849Smrgrequired, except when creating a convenience library.
68079f606849Smrg
68089f606849SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
68099f606849Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
68109f606849Smrg
68119f606849SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
68129f606849Smrgis created, otherwise an executable program is created."
68139f606849Smrg  ;;
68149f606849Smrg
68159f606849Smrguninstall)
68169f606849Smrg  $echo \
68179f606849Smrg"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
68189f606849Smrg
68199f606849SmrgRemove libraries from an installation directory.
68209f606849Smrg
68219f606849SmrgRM is the name of the program to use to delete files associated with each FILE
68229f606849Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
68239f606849Smrgto RM.
68249f606849Smrg
68259f606849SmrgIf FILE is a libtool library, all the files associated with it are deleted.
68269f606849SmrgOtherwise, only FILE itself is deleted using RM."
68279f606849Smrg  ;;
68289f606849Smrg
68299f606849Smrg*)
68309f606849Smrg  $echo "$modename: invalid operation mode \`$mode'" 1>&2
68319f606849Smrg  $echo "$help" 1>&2
68329f606849Smrg  exit $EXIT_FAILURE
68339f606849Smrg  ;;
68349f606849Smrgesac
68359f606849Smrg
68369f606849Smrg$echo
68379f606849Smrg$echo "Try \`$modename --help' for more information about other modes."
68389f606849Smrg
68399f606849Smrgexit $?
68409f606849Smrg
68419f606849Smrg# The TAGs below are defined such that we never get into a situation
68429f606849Smrg# in which we disable both kinds of libraries.  Given conflicting
68439f606849Smrg# choices, we go for a static library, that is the most portable,
68449f606849Smrg# since we can't tell whether shared libraries were disabled because
68459f606849Smrg# the user asked for that or because the platform doesn't support
68469f606849Smrg# them.  This is particularly important on AIX, because we don't
68479f606849Smrg# support having both static and shared libraries enabled at the same
68489f606849Smrg# time on that platform, so we default to a shared-only configuration.
68499f606849Smrg# If a disable-shared tag is given, we'll fallback to a static-only
68509f606849Smrg# configuration.  But we'll never go from static-only to shared-only.
68519f606849Smrg
68529f606849Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
68539f606849Smrgdisable_libs=shared
68549f606849Smrg# ### END LIBTOOL TAG CONFIG: disable-shared
68559f606849Smrg
68569f606849Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
68579f606849Smrgdisable_libs=static
68589f606849Smrg# ### END LIBTOOL TAG CONFIG: disable-static
68599f606849Smrg
68609f606849Smrg# Local Variables:
68619f606849Smrg# mode:shell-script
68629f606849Smrg# sh-indentation:2
68639f606849Smrg# End:
6864