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