ltmain.sh revision 5eefee25
15eefee25Smacallan# ltmain.sh - Provide generalized library-building support services.
25eefee25Smacallan# NOTE: Changing this file will not affect anything until you rerun configure.
35eefee25Smacallan#
45eefee25Smacallan# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005
55eefee25Smacallan# Free Software Foundation, Inc.
65eefee25Smacallan# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
75eefee25Smacallan#
85eefee25Smacallan# This program is free software; you can redistribute it and/or modify
95eefee25Smacallan# it under the terms of the GNU General Public License as published by
105eefee25Smacallan# the Free Software Foundation; either version 2 of the License, or
115eefee25Smacallan# (at your option) any later version.
125eefee25Smacallan#
135eefee25Smacallan# This program is distributed in the hope that it will be useful, but
145eefee25Smacallan# WITHOUT ANY WARRANTY; without even the implied warranty of
155eefee25Smacallan# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
165eefee25Smacallan# General Public License for more details.
175eefee25Smacallan#
185eefee25Smacallan# You should have received a copy of the GNU General Public License
195eefee25Smacallan# along with this program; if not, write to the Free Software
205eefee25Smacallan# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
215eefee25Smacallan#
225eefee25Smacallan# As a special exception to the GNU General Public License, if you
235eefee25Smacallan# distribute this file as part of a program that contains a
245eefee25Smacallan# configuration script generated by Autoconf, you may include it under
255eefee25Smacallan# the same distribution terms that you use for the rest of that program.
265eefee25Smacallan
275eefee25Smacallanbasename="s,^.*/,,g"
285eefee25Smacallan
295eefee25Smacallan# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
305eefee25Smacallan# is ksh but when the shell is invoked as "sh" and the current value of
315eefee25Smacallan# the _XPG environment variable is not equal to 1 (one), the special
325eefee25Smacallan# positional parameter $0, within a function call, is the name of the
335eefee25Smacallan# function.
345eefee25Smacallanprogpath="$0"
355eefee25Smacallan
365eefee25Smacallan# The name of this program:
375eefee25Smacallanprogname=`echo "$progpath" | $SED $basename`
385eefee25Smacallanmodename="$progname"
395eefee25Smacallan
405eefee25Smacallan# Global variables:
415eefee25SmacallanEXIT_SUCCESS=0
425eefee25SmacallanEXIT_FAILURE=1
435eefee25Smacallan
445eefee25SmacallanPROGRAM=ltmain.sh
455eefee25SmacallanPACKAGE=libtool
465eefee25SmacallanVERSION=1.5.22
475eefee25SmacallanTIMESTAMP=" (1.1220.2.365 2005/12/18 22:14:06)"
485eefee25Smacallan
495eefee25Smacallan# See if we are running on zsh, and set the options which allow our
505eefee25Smacallan# commands through without removal of \ escapes.
515eefee25Smacallanif test -n "${ZSH_VERSION+set}" ; then
525eefee25Smacallan  setopt NO_GLOB_SUBST
535eefee25Smacallanfi
545eefee25Smacallan
555eefee25Smacallan# Check that we have a working $echo.
565eefee25Smacallanif test "X$1" = X--no-reexec; then
575eefee25Smacallan  # Discard the --no-reexec flag, and continue.
585eefee25Smacallan  shift
595eefee25Smacallanelif test "X$1" = X--fallback-echo; then
605eefee25Smacallan  # Avoid inline document here, it may be left over
615eefee25Smacallan  :
625eefee25Smacallanelif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
635eefee25Smacallan  # Yippee, $echo works!
645eefee25Smacallan  :
655eefee25Smacallanelse
665eefee25Smacallan  # Restart under the correct shell, and then maybe $echo will work.
675eefee25Smacallan  exec $SHELL "$progpath" --no-reexec ${1+"$@"}
685eefee25Smacallanfi
695eefee25Smacallan
705eefee25Smacallanif test "X$1" = X--fallback-echo; then
715eefee25Smacallan  # used as fallback echo
725eefee25Smacallan  shift
735eefee25Smacallan  cat <<EOF
745eefee25Smacallan$*
755eefee25SmacallanEOF
765eefee25Smacallan  exit $EXIT_SUCCESS
775eefee25Smacallanfi
785eefee25Smacallan
795eefee25Smacallandefault_mode=
805eefee25Smacallanhelp="Try \`$progname --help' for more information."
815eefee25Smacallanmagic="%%%MAGIC variable%%%"
825eefee25Smacallanmkdir="mkdir"
835eefee25Smacallanmv="mv -f"
845eefee25Smacallanrm="rm -f"
855eefee25Smacallan
865eefee25Smacallan# Sed substitution that helps us do robust quoting.  It backslashifies
875eefee25Smacallan# metacharacters that are still active within double-quoted strings.
885eefee25SmacallanXsed="${SED}"' -e 1s/^X//'
895eefee25Smacallansed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
905eefee25Smacallan# test EBCDIC or ASCII
915eefee25Smacallancase `echo X|tr X '\101'` in
925eefee25Smacallan A) # ASCII based system
935eefee25Smacallan    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
945eefee25Smacallan  SP2NL='tr \040 \012'
955eefee25Smacallan  NL2SP='tr \015\012 \040\040'
965eefee25Smacallan  ;;
975eefee25Smacallan *) # EBCDIC based system
985eefee25Smacallan  SP2NL='tr \100 \n'
995eefee25Smacallan  NL2SP='tr \r\n \100\100'
1005eefee25Smacallan  ;;
1015eefee25Smacallanesac
1025eefee25Smacallan
1035eefee25Smacallan# NLS nuisances.
1045eefee25Smacallan# Only set LANG and LC_ALL to C if already set.
1055eefee25Smacallan# These must not be set unconditionally because not all systems understand
1065eefee25Smacallan# e.g. LANG=C (notably SCO).
1075eefee25Smacallan# We save the old values to restore during execute mode.
1085eefee25Smacallanif test "${LC_ALL+set}" = set; then
1095eefee25Smacallan  save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
1105eefee25Smacallanfi
1115eefee25Smacallanif test "${LANG+set}" = set; then
1125eefee25Smacallan  save_LANG="$LANG"; LANG=C; export LANG
1135eefee25Smacallanfi
1145eefee25Smacallan
1155eefee25Smacallan# Make sure IFS has a sensible default
1165eefee25Smacallanlt_nl='
1175eefee25Smacallan'
1185eefee25SmacallanIFS=" 	$lt_nl"
1195eefee25Smacallan
1205eefee25Smacallanif test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
1215eefee25Smacallan  $echo "$modename: not configured to build any kind of library" 1>&2
1225eefee25Smacallan  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
1235eefee25Smacallan  exit $EXIT_FAILURE
1245eefee25Smacallanfi
1255eefee25Smacallan
1265eefee25Smacallan# Global variables.
1275eefee25Smacallanmode=$default_mode
1285eefee25Smacallannonopt=
1295eefee25Smacallanprev=
1305eefee25Smacallanprevopt=
1315eefee25Smacallanrun=
1325eefee25Smacallanshow="$echo"
1335eefee25Smacallanshow_help=
1345eefee25Smacallanexecute_dlfiles=
1355eefee25Smacallanduplicate_deps=no
1365eefee25Smacallanpreserve_args=
1375eefee25Smacallanlo2o="s/\\.lo\$/.${objext}/"
1385eefee25Smacallano2lo="s/\\.${objext}\$/.lo/"
1395eefee25Smacallan
1405eefee25Smacallan#####################################
1415eefee25Smacallan# Shell function definitions:
1425eefee25Smacallan# This seems to be the best place for them
1435eefee25Smacallan
1445eefee25Smacallan# func_mktempdir [string]
1455eefee25Smacallan# Make a temporary directory that won't clash with other running
1465eefee25Smacallan# libtool processes, and avoids race conditions if possible.  If
1475eefee25Smacallan# given, STRING is the basename for that directory.
1485eefee25Smacallanfunc_mktempdir ()
1495eefee25Smacallan{
1505eefee25Smacallan    my_template="${TMPDIR-/tmp}/${1-$progname}"
1515eefee25Smacallan
1525eefee25Smacallan    if test "$run" = ":"; then
1535eefee25Smacallan      # Return a directory name, but don't create it in dry-run mode
1545eefee25Smacallan      my_tmpdir="${my_template}-$$"
1555eefee25Smacallan    else
1565eefee25Smacallan
1575eefee25Smacallan      # If mktemp works, use that first and foremost
1585eefee25Smacallan      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
1595eefee25Smacallan
1605eefee25Smacallan      if test ! -d "$my_tmpdir"; then
1615eefee25Smacallan	# Failing that, at least try and use $RANDOM to avoid a race
1625eefee25Smacallan	my_tmpdir="${my_template}-${RANDOM-0}$$"
1635eefee25Smacallan
1645eefee25Smacallan	save_mktempdir_umask=`umask`
1655eefee25Smacallan	umask 0077
1665eefee25Smacallan	$mkdir "$my_tmpdir"
1675eefee25Smacallan	umask $save_mktempdir_umask
1685eefee25Smacallan      fi
1695eefee25Smacallan
1705eefee25Smacallan      # If we're not in dry-run mode, bomb out on failure
1715eefee25Smacallan      test -d "$my_tmpdir" || {
1725eefee25Smacallan        $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
1735eefee25Smacallan	exit $EXIT_FAILURE
1745eefee25Smacallan      }
1755eefee25Smacallan    fi
1765eefee25Smacallan
1775eefee25Smacallan    $echo "X$my_tmpdir" | $Xsed
1785eefee25Smacallan}
1795eefee25Smacallan
1805eefee25Smacallan
1815eefee25Smacallan# func_win32_libid arg
1825eefee25Smacallan# return the library type of file 'arg'
1835eefee25Smacallan#
1845eefee25Smacallan# Need a lot of goo to handle *both* DLLs and import libs
1855eefee25Smacallan# Has to be a shell function in order to 'eat' the argument
1865eefee25Smacallan# that is supplied when $file_magic_command is called.
1875eefee25Smacallanfunc_win32_libid ()
1885eefee25Smacallan{
1895eefee25Smacallan  win32_libid_type="unknown"
1905eefee25Smacallan  win32_fileres=`file -L $1 2>/dev/null`
1915eefee25Smacallan  case $win32_fileres in
1925eefee25Smacallan  *ar\ archive\ import\ library*) # definitely import
1935eefee25Smacallan    win32_libid_type="x86 archive import"
1945eefee25Smacallan    ;;
1955eefee25Smacallan  *ar\ archive*) # could be an import, or static
1965eefee25Smacallan    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
1975eefee25Smacallan      $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
1985eefee25Smacallan      win32_nmres=`eval $NM -f posix -A $1 | \
1995eefee25Smacallan	$SED -n -e '1,100{/ I /{s,.*,import,;p;q;};}'`
2005eefee25Smacallan      case $win32_nmres in
2015eefee25Smacallan      import*)  win32_libid_type="x86 archive import";;
2025eefee25Smacallan      *)        win32_libid_type="x86 archive static";;
2035eefee25Smacallan      esac
2045eefee25Smacallan    fi
2055eefee25Smacallan    ;;
2065eefee25Smacallan  *DLL*)
2075eefee25Smacallan    win32_libid_type="x86 DLL"
2085eefee25Smacallan    ;;
2095eefee25Smacallan  *executable*) # but shell scripts are "executable" too...
2105eefee25Smacallan    case $win32_fileres in
2115eefee25Smacallan    *MS\ Windows\ PE\ Intel*)
2125eefee25Smacallan      win32_libid_type="x86 DLL"
2135eefee25Smacallan      ;;
2145eefee25Smacallan    esac
2155eefee25Smacallan    ;;
2165eefee25Smacallan  esac
2175eefee25Smacallan  $echo $win32_libid_type
2185eefee25Smacallan}
2195eefee25Smacallan
2205eefee25Smacallan
2215eefee25Smacallan# func_infer_tag arg
2225eefee25Smacallan# Infer tagged configuration to use if any are available and
2235eefee25Smacallan# if one wasn't chosen via the "--tag" command line option.
2245eefee25Smacallan# Only attempt this if the compiler in the base compile
2255eefee25Smacallan# command doesn't match the default compiler.
2265eefee25Smacallan# arg is usually of the form 'gcc ...'
2275eefee25Smacallanfunc_infer_tag ()
2285eefee25Smacallan{
2295eefee25Smacallan    if test -n "$available_tags" && test -z "$tagname"; then
2305eefee25Smacallan      CC_quoted=
2315eefee25Smacallan      for arg in $CC; do
2325eefee25Smacallan	case $arg in
2335eefee25Smacallan	  *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
2345eefee25Smacallan	  arg="\"$arg\""
2355eefee25Smacallan	  ;;
2365eefee25Smacallan	esac
2375eefee25Smacallan	CC_quoted="$CC_quoted $arg"
2385eefee25Smacallan      done
2395eefee25Smacallan      case $@ in
2405eefee25Smacallan      # Blanks in the command may have been stripped by the calling shell,
2415eefee25Smacallan      # but not from the CC environment variable when configure was run.
2425eefee25Smacallan      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
2435eefee25Smacallan      # Blanks at the start of $base_compile will cause this to fail
2445eefee25Smacallan      # if we don't check for them as well.
2455eefee25Smacallan      *)
2465eefee25Smacallan	for z in $available_tags; do
2475eefee25Smacallan	  if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
2485eefee25Smacallan	    # Evaluate the configuration.
2495eefee25Smacallan	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
2505eefee25Smacallan	    CC_quoted=
2515eefee25Smacallan	    for arg in $CC; do
2525eefee25Smacallan	    # Double-quote args containing other shell metacharacters.
2535eefee25Smacallan	    case $arg in
2545eefee25Smacallan	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
2555eefee25Smacallan	      arg="\"$arg\""
2565eefee25Smacallan	      ;;
2575eefee25Smacallan	    esac
2585eefee25Smacallan	    CC_quoted="$CC_quoted $arg"
2595eefee25Smacallan	  done
2605eefee25Smacallan	    case "$@ " in
2615eefee25Smacallan	      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
2625eefee25Smacallan	      # The compiler in the base compile command matches
2635eefee25Smacallan	      # the one in the tagged configuration.
2645eefee25Smacallan	      # Assume this is the tagged configuration we want.
2655eefee25Smacallan	      tagname=$z
2665eefee25Smacallan	      break
2675eefee25Smacallan	      ;;
2685eefee25Smacallan	    esac
2695eefee25Smacallan	  fi
2705eefee25Smacallan	done
2715eefee25Smacallan	# If $tagname still isn't set, then no tagged configuration
2725eefee25Smacallan	# was found and let the user know that the "--tag" command
2735eefee25Smacallan	# line option must be used.
2745eefee25Smacallan	if test -z "$tagname"; then
2755eefee25Smacallan	  $echo "$modename: unable to infer tagged configuration"
2765eefee25Smacallan	  $echo "$modename: specify a tag with \`--tag'" 1>&2
2775eefee25Smacallan	  exit $EXIT_FAILURE
2785eefee25Smacallan#        else
2795eefee25Smacallan#          $echo "$modename: using $tagname tagged configuration"
2805eefee25Smacallan	fi
2815eefee25Smacallan	;;
2825eefee25Smacallan      esac
2835eefee25Smacallan    fi
2845eefee25Smacallan}
2855eefee25Smacallan
2865eefee25Smacallan
2875eefee25Smacallan# func_extract_an_archive dir oldlib
2885eefee25Smacallanfunc_extract_an_archive ()
2895eefee25Smacallan{
2905eefee25Smacallan    f_ex_an_ar_dir="$1"; shift
2915eefee25Smacallan    f_ex_an_ar_oldlib="$1"
2925eefee25Smacallan
2935eefee25Smacallan    $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
2945eefee25Smacallan    $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
2955eefee25Smacallan    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
2965eefee25Smacallan     :
2975eefee25Smacallan    else
2985eefee25Smacallan      $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2
2995eefee25Smacallan      exit $EXIT_FAILURE
3005eefee25Smacallan    fi
3015eefee25Smacallan}
3025eefee25Smacallan
3035eefee25Smacallan# func_extract_archives gentop oldlib ...
3045eefee25Smacallanfunc_extract_archives ()
3055eefee25Smacallan{
3065eefee25Smacallan    my_gentop="$1"; shift
3075eefee25Smacallan    my_oldlibs=${1+"$@"}
3085eefee25Smacallan    my_oldobjs=""
3095eefee25Smacallan    my_xlib=""
3105eefee25Smacallan    my_xabs=""
3115eefee25Smacallan    my_xdir=""
3125eefee25Smacallan    my_status=""
3135eefee25Smacallan
3145eefee25Smacallan    $show "${rm}r $my_gentop"
3155eefee25Smacallan    $run ${rm}r "$my_gentop"
3165eefee25Smacallan    $show "$mkdir $my_gentop"
3175eefee25Smacallan    $run $mkdir "$my_gentop"
3185eefee25Smacallan    my_status=$?
3195eefee25Smacallan    if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
3205eefee25Smacallan      exit $my_status
3215eefee25Smacallan    fi
3225eefee25Smacallan
3235eefee25Smacallan    for my_xlib in $my_oldlibs; do
3245eefee25Smacallan      # Extract the objects.
3255eefee25Smacallan      case $my_xlib in
3265eefee25Smacallan	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
3275eefee25Smacallan	*) my_xabs=`pwd`"/$my_xlib" ;;
3285eefee25Smacallan      esac
3295eefee25Smacallan      my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
3305eefee25Smacallan      my_xdir="$my_gentop/$my_xlib"
3315eefee25Smacallan
3325eefee25Smacallan      $show "${rm}r $my_xdir"
3335eefee25Smacallan      $run ${rm}r "$my_xdir"
3345eefee25Smacallan      $show "$mkdir $my_xdir"
3355eefee25Smacallan      $run $mkdir "$my_xdir"
3365eefee25Smacallan      exit_status=$?
3375eefee25Smacallan      if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then
3385eefee25Smacallan	exit $exit_status
3395eefee25Smacallan      fi
3405eefee25Smacallan      case $host in
3415eefee25Smacallan      *-darwin*)
3425eefee25Smacallan	$show "Extracting $my_xabs"
3435eefee25Smacallan	# Do not bother doing anything if just a dry run
3445eefee25Smacallan	if test -z "$run"; then
3455eefee25Smacallan	  darwin_orig_dir=`pwd`
3465eefee25Smacallan	  cd $my_xdir || exit $?
3475eefee25Smacallan	  darwin_archive=$my_xabs
3485eefee25Smacallan	  darwin_curdir=`pwd`
3495eefee25Smacallan	  darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'`
3505eefee25Smacallan	  darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
3515eefee25Smacallan	  if test -n "$darwin_arches"; then 
3525eefee25Smacallan	    darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
3535eefee25Smacallan	    darwin_arch=
3545eefee25Smacallan	    $show "$darwin_base_archive has multiple architectures $darwin_arches"
3555eefee25Smacallan	    for darwin_arch in  $darwin_arches ; do
3565eefee25Smacallan	      mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3575eefee25Smacallan	      lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
3585eefee25Smacallan	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3595eefee25Smacallan	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
3605eefee25Smacallan	      cd "$darwin_curdir"
3615eefee25Smacallan	      $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
3625eefee25Smacallan	    done # $darwin_arches
3635eefee25Smacallan      ## Okay now we have a bunch of thin objects, gotta fatten them up :)
3645eefee25Smacallan	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP`
3655eefee25Smacallan	    darwin_file=
3665eefee25Smacallan	    darwin_files=
3675eefee25Smacallan	    for darwin_file in $darwin_filelist; do
3685eefee25Smacallan	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
3695eefee25Smacallan	      lipo -create -output "$darwin_file" $darwin_files
3705eefee25Smacallan	    done # $darwin_filelist
3715eefee25Smacallan	    ${rm}r unfat-$$
3725eefee25Smacallan	    cd "$darwin_orig_dir"
3735eefee25Smacallan	  else
3745eefee25Smacallan	    cd "$darwin_orig_dir"
3755eefee25Smacallan 	    func_extract_an_archive "$my_xdir" "$my_xabs"
3765eefee25Smacallan	  fi # $darwin_arches
3775eefee25Smacallan	fi # $run
3785eefee25Smacallan	;;
3795eefee25Smacallan      *)
3805eefee25Smacallan        func_extract_an_archive "$my_xdir" "$my_xabs"
3815eefee25Smacallan        ;;
3825eefee25Smacallan      esac
3835eefee25Smacallan      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
3845eefee25Smacallan    done
3855eefee25Smacallan    func_extract_archives_result="$my_oldobjs"
3865eefee25Smacallan}
3875eefee25Smacallan# End of Shell function definitions
3885eefee25Smacallan#####################################
3895eefee25Smacallan
3905eefee25Smacallan# Darwin sucks
3915eefee25Smacallaneval std_shrext=\"$shrext_cmds\"
3925eefee25Smacallan
3935eefee25Smacallandisable_libs=no
3945eefee25Smacallan
3955eefee25Smacallan# Parse our command line options once, thoroughly.
3965eefee25Smacallanwhile test "$#" -gt 0
3975eefee25Smacallando
3985eefee25Smacallan  arg="$1"
3995eefee25Smacallan  shift
4005eefee25Smacallan
4015eefee25Smacallan  case $arg in
4025eefee25Smacallan  -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
4035eefee25Smacallan  *) optarg= ;;
4045eefee25Smacallan  esac
4055eefee25Smacallan
4065eefee25Smacallan  # If the previous option needs an argument, assign it.
4075eefee25Smacallan  if test -n "$prev"; then
4085eefee25Smacallan    case $prev in
4095eefee25Smacallan    execute_dlfiles)
4105eefee25Smacallan      execute_dlfiles="$execute_dlfiles $arg"
4115eefee25Smacallan      ;;
4125eefee25Smacallan    tag)
4135eefee25Smacallan      tagname="$arg"
4145eefee25Smacallan      preserve_args="${preserve_args}=$arg"
4155eefee25Smacallan
4165eefee25Smacallan      # Check whether tagname contains only valid characters
4175eefee25Smacallan      case $tagname in
4185eefee25Smacallan      *[!-_A-Za-z0-9,/]*)
4195eefee25Smacallan	$echo "$progname: invalid tag name: $tagname" 1>&2
4205eefee25Smacallan	exit $EXIT_FAILURE
4215eefee25Smacallan	;;
4225eefee25Smacallan      esac
4235eefee25Smacallan
4245eefee25Smacallan      case $tagname in
4255eefee25Smacallan      CC)
4265eefee25Smacallan	# Don't test for the "default" C tag, as we know, it's there, but
4275eefee25Smacallan	# not specially marked.
4285eefee25Smacallan	;;
4295eefee25Smacallan      *)
4305eefee25Smacallan	if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then
4315eefee25Smacallan	  taglist="$taglist $tagname"
4325eefee25Smacallan	  # Evaluate the configuration.
4335eefee25Smacallan	  eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`"
4345eefee25Smacallan	else
4355eefee25Smacallan	  $echo "$progname: ignoring unknown tag $tagname" 1>&2
4365eefee25Smacallan	fi
4375eefee25Smacallan	;;
4385eefee25Smacallan      esac
4395eefee25Smacallan      ;;
4405eefee25Smacallan    *)
4415eefee25Smacallan      eval "$prev=\$arg"
4425eefee25Smacallan      ;;
4435eefee25Smacallan    esac
4445eefee25Smacallan
4455eefee25Smacallan    prev=
4465eefee25Smacallan    prevopt=
4475eefee25Smacallan    continue
4485eefee25Smacallan  fi
4495eefee25Smacallan
4505eefee25Smacallan  # Have we seen a non-optional argument yet?
4515eefee25Smacallan  case $arg in
4525eefee25Smacallan  --help)
4535eefee25Smacallan    show_help=yes
4545eefee25Smacallan    ;;
4555eefee25Smacallan
4565eefee25Smacallan  --version)
4575eefee25Smacallan    $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
4585eefee25Smacallan    $echo
4595eefee25Smacallan    $echo "Copyright (C) 2005  Free Software Foundation, Inc."
4605eefee25Smacallan    $echo "This is free software; see the source for copying conditions.  There is NO"
4615eefee25Smacallan    $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
4625eefee25Smacallan    exit $?
4635eefee25Smacallan    ;;
4645eefee25Smacallan
4655eefee25Smacallan  --config)
4665eefee25Smacallan    ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath
4675eefee25Smacallan    # Now print the configurations for the tags.
4685eefee25Smacallan    for tagname in $taglist; do
4695eefee25Smacallan      ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
4705eefee25Smacallan    done
4715eefee25Smacallan    exit $?
4725eefee25Smacallan    ;;
4735eefee25Smacallan
4745eefee25Smacallan  --debug)
4755eefee25Smacallan    $echo "$progname: enabling shell trace mode"
4765eefee25Smacallan    set -x
4775eefee25Smacallan    preserve_args="$preserve_args $arg"
4785eefee25Smacallan    ;;
4795eefee25Smacallan
4805eefee25Smacallan  --dry-run | -n)
4815eefee25Smacallan    run=:
4825eefee25Smacallan    ;;
4835eefee25Smacallan
4845eefee25Smacallan  --features)
4855eefee25Smacallan    $echo "host: $host"
4865eefee25Smacallan    if test "$build_libtool_libs" = yes; then
4875eefee25Smacallan      $echo "enable shared libraries"
4885eefee25Smacallan    else
4895eefee25Smacallan      $echo "disable shared libraries"
4905eefee25Smacallan    fi
4915eefee25Smacallan    if test "$build_old_libs" = yes; then
4925eefee25Smacallan      $echo "enable static libraries"
4935eefee25Smacallan    else
4945eefee25Smacallan      $echo "disable static libraries"
4955eefee25Smacallan    fi
4965eefee25Smacallan    exit $?
4975eefee25Smacallan    ;;
4985eefee25Smacallan
4995eefee25Smacallan  --finish) mode="finish" ;;
5005eefee25Smacallan
5015eefee25Smacallan  --mode) prevopt="--mode" prev=mode ;;
5025eefee25Smacallan  --mode=*) mode="$optarg" ;;
5035eefee25Smacallan
5045eefee25Smacallan  --preserve-dup-deps) duplicate_deps="yes" ;;
5055eefee25Smacallan
5065eefee25Smacallan  --quiet | --silent)
5075eefee25Smacallan    show=:
5085eefee25Smacallan    preserve_args="$preserve_args $arg"
5095eefee25Smacallan    ;;
5105eefee25Smacallan
5115eefee25Smacallan  --tag)
5125eefee25Smacallan    prevopt="--tag"
5135eefee25Smacallan    prev=tag
5145eefee25Smacallan    preserve_args="$preserve_args --tag"
5155eefee25Smacallan    ;;
5165eefee25Smacallan  --tag=*)
5175eefee25Smacallan    set tag "$optarg" ${1+"$@"}
5185eefee25Smacallan    shift
5195eefee25Smacallan    prev=tag
5205eefee25Smacallan    preserve_args="$preserve_args --tag"
5215eefee25Smacallan    ;;
5225eefee25Smacallan
5235eefee25Smacallan  -dlopen)
5245eefee25Smacallan    prevopt="-dlopen"
5255eefee25Smacallan    prev=execute_dlfiles
5265eefee25Smacallan    ;;
5275eefee25Smacallan
5285eefee25Smacallan  -*)
5295eefee25Smacallan    $echo "$modename: unrecognized option \`$arg'" 1>&2
5305eefee25Smacallan    $echo "$help" 1>&2
5315eefee25Smacallan    exit $EXIT_FAILURE
5325eefee25Smacallan    ;;
5335eefee25Smacallan
5345eefee25Smacallan  *)
5355eefee25Smacallan    nonopt="$arg"
5365eefee25Smacallan    break
5375eefee25Smacallan    ;;
5385eefee25Smacallan  esac
5395eefee25Smacallandone
5405eefee25Smacallan
5415eefee25Smacallanif test -n "$prevopt"; then
5425eefee25Smacallan  $echo "$modename: option \`$prevopt' requires an argument" 1>&2
5435eefee25Smacallan  $echo "$help" 1>&2
5445eefee25Smacallan  exit $EXIT_FAILURE
5455eefee25Smacallanfi
5465eefee25Smacallan
5475eefee25Smacallancase $disable_libs in
5485eefee25Smacallanno) 
5495eefee25Smacallan  ;;
5505eefee25Smacallanshared)
5515eefee25Smacallan  build_libtool_libs=no
5525eefee25Smacallan  build_old_libs=yes
5535eefee25Smacallan  ;;
5545eefee25Smacallanstatic)
5555eefee25Smacallan  build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
5565eefee25Smacallan  ;;
5575eefee25Smacallanesac
5585eefee25Smacallan
5595eefee25Smacallan# If this variable is set in any of the actions, the command in it
5605eefee25Smacallan# will be execed at the end.  This prevents here-documents from being
5615eefee25Smacallan# left over by shells.
5625eefee25Smacallanexec_cmd=
5635eefee25Smacallan
5645eefee25Smacallanif test -z "$show_help"; then
5655eefee25Smacallan
5665eefee25Smacallan  # Infer the operation mode.
5675eefee25Smacallan  if test -z "$mode"; then
5685eefee25Smacallan    $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
5695eefee25Smacallan    $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2
5705eefee25Smacallan    case $nonopt in
5715eefee25Smacallan    *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
5725eefee25Smacallan      mode=link
5735eefee25Smacallan      for arg
5745eefee25Smacallan      do
5755eefee25Smacallan	case $arg in
5765eefee25Smacallan	-c)
5775eefee25Smacallan	   mode=compile
5785eefee25Smacallan	   break
5795eefee25Smacallan	   ;;
5805eefee25Smacallan	esac
5815eefee25Smacallan      done
5825eefee25Smacallan      ;;
5835eefee25Smacallan    *db | *dbx | *strace | *truss)
5845eefee25Smacallan      mode=execute
5855eefee25Smacallan      ;;
5865eefee25Smacallan    *install*|cp|mv)
5875eefee25Smacallan      mode=install
5885eefee25Smacallan      ;;
5895eefee25Smacallan    *rm)
5905eefee25Smacallan      mode=uninstall
5915eefee25Smacallan      ;;
5925eefee25Smacallan    *)
5935eefee25Smacallan      # If we have no mode, but dlfiles were specified, then do execute mode.
5945eefee25Smacallan      test -n "$execute_dlfiles" && mode=execute
5955eefee25Smacallan
5965eefee25Smacallan      # Just use the default operation mode.
5975eefee25Smacallan      if test -z "$mode"; then
5985eefee25Smacallan	if test -n "$nonopt"; then
5995eefee25Smacallan	  $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
6005eefee25Smacallan	else
6015eefee25Smacallan	  $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
6025eefee25Smacallan	fi
6035eefee25Smacallan      fi
6045eefee25Smacallan      ;;
6055eefee25Smacallan    esac
6065eefee25Smacallan  fi
6075eefee25Smacallan
6085eefee25Smacallan  # Only execute mode is allowed to have -dlopen flags.
6095eefee25Smacallan  if test -n "$execute_dlfiles" && test "$mode" != execute; then
6105eefee25Smacallan    $echo "$modename: unrecognized option \`-dlopen'" 1>&2
6115eefee25Smacallan    $echo "$help" 1>&2
6125eefee25Smacallan    exit $EXIT_FAILURE
6135eefee25Smacallan  fi
6145eefee25Smacallan
6155eefee25Smacallan  # Change the help message to a mode-specific one.
6165eefee25Smacallan  generic_help="$help"
6175eefee25Smacallan  help="Try \`$modename --help --mode=$mode' for more information."
6185eefee25Smacallan
6195eefee25Smacallan  # These modes are in order of execution frequency so that they run quickly.
6205eefee25Smacallan  case $mode in
6215eefee25Smacallan  # libtool compile mode
6225eefee25Smacallan  compile)
6235eefee25Smacallan    modename="$modename: compile"
6245eefee25Smacallan    # Get the compilation command and the source file.
6255eefee25Smacallan    base_compile=
6265eefee25Smacallan    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
6275eefee25Smacallan    suppress_opt=yes
6285eefee25Smacallan    suppress_output=
6295eefee25Smacallan    arg_mode=normal
6305eefee25Smacallan    libobj=
6315eefee25Smacallan    later=
6325eefee25Smacallan
6335eefee25Smacallan    for arg
6345eefee25Smacallan    do
6355eefee25Smacallan      case $arg_mode in
6365eefee25Smacallan      arg  )
6375eefee25Smacallan	# do not "continue".  Instead, add this to base_compile
6385eefee25Smacallan	lastarg="$arg"
6395eefee25Smacallan	arg_mode=normal
6405eefee25Smacallan	;;
6415eefee25Smacallan
6425eefee25Smacallan      target )
6435eefee25Smacallan	libobj="$arg"
6445eefee25Smacallan	arg_mode=normal
6455eefee25Smacallan	continue
6465eefee25Smacallan	;;
6475eefee25Smacallan
6485eefee25Smacallan      normal )
6495eefee25Smacallan	# Accept any command-line options.
6505eefee25Smacallan	case $arg in
6515eefee25Smacallan	-o)
6525eefee25Smacallan	  if test -n "$libobj" ; then
6535eefee25Smacallan	    $echo "$modename: you cannot specify \`-o' more than once" 1>&2
6545eefee25Smacallan	    exit $EXIT_FAILURE
6555eefee25Smacallan	  fi
6565eefee25Smacallan	  arg_mode=target
6575eefee25Smacallan	  continue
6585eefee25Smacallan	  ;;
6595eefee25Smacallan
6605eefee25Smacallan	-static | -prefer-pic | -prefer-non-pic)
6615eefee25Smacallan	  later="$later $arg"
6625eefee25Smacallan	  continue
6635eefee25Smacallan	  ;;
6645eefee25Smacallan
6655eefee25Smacallan	-no-suppress)
6665eefee25Smacallan	  suppress_opt=no
6675eefee25Smacallan	  continue
6685eefee25Smacallan	  ;;
6695eefee25Smacallan
6705eefee25Smacallan	-Xcompiler)
6715eefee25Smacallan	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
6725eefee25Smacallan	  continue      #  The current "srcfile" will either be retained or
6735eefee25Smacallan	  ;;            #  replaced later.  I would guess that would be a bug.
6745eefee25Smacallan
6755eefee25Smacallan	-Wc,*)
6765eefee25Smacallan	  args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
6775eefee25Smacallan	  lastarg=
6785eefee25Smacallan	  save_ifs="$IFS"; IFS=','
6795eefee25Smacallan 	  for arg in $args; do
6805eefee25Smacallan	    IFS="$save_ifs"
6815eefee25Smacallan
6825eefee25Smacallan	    # Double-quote args containing other shell metacharacters.
6835eefee25Smacallan	    # Many Bourne shells cannot handle close brackets correctly
6845eefee25Smacallan	    # in scan sets, so we specify it separately.
6855eefee25Smacallan	    case $arg in
6865eefee25Smacallan	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
6875eefee25Smacallan	      arg="\"$arg\""
6885eefee25Smacallan	      ;;
6895eefee25Smacallan	    esac
6905eefee25Smacallan	    lastarg="$lastarg $arg"
6915eefee25Smacallan	  done
6925eefee25Smacallan	  IFS="$save_ifs"
6935eefee25Smacallan	  lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
6945eefee25Smacallan
6955eefee25Smacallan	  # Add the arguments to base_compile.
6965eefee25Smacallan	  base_compile="$base_compile $lastarg"
6975eefee25Smacallan	  continue
6985eefee25Smacallan	  ;;
6995eefee25Smacallan
7005eefee25Smacallan	* )
7015eefee25Smacallan	  # Accept the current argument as the source file.
7025eefee25Smacallan	  # The previous "srcfile" becomes the current argument.
7035eefee25Smacallan	  #
7045eefee25Smacallan	  lastarg="$srcfile"
7055eefee25Smacallan	  srcfile="$arg"
7065eefee25Smacallan	  ;;
7075eefee25Smacallan	esac  #  case $arg
7085eefee25Smacallan	;;
7095eefee25Smacallan      esac    #  case $arg_mode
7105eefee25Smacallan
7115eefee25Smacallan      # Aesthetically quote the previous argument.
7125eefee25Smacallan      lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
7135eefee25Smacallan
7145eefee25Smacallan      case $lastarg in
7155eefee25Smacallan      # Double-quote args containing other shell metacharacters.
7165eefee25Smacallan      # Many Bourne shells cannot handle close brackets correctly
7175eefee25Smacallan      # in scan sets, and some SunOS ksh mistreat backslash-escaping
7185eefee25Smacallan      # in scan sets (worked around with variable expansion),
7195eefee25Smacallan      # and furthermore cannot handle '|' '&' '(' ')' in scan sets 
7205eefee25Smacallan      # at all, so we specify them separately.
7215eefee25Smacallan      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
7225eefee25Smacallan	lastarg="\"$lastarg\""
7235eefee25Smacallan	;;
7245eefee25Smacallan      esac
7255eefee25Smacallan
7265eefee25Smacallan      base_compile="$base_compile $lastarg"
7275eefee25Smacallan    done # for arg
7285eefee25Smacallan
7295eefee25Smacallan    case $arg_mode in
7305eefee25Smacallan    arg)
7315eefee25Smacallan      $echo "$modename: you must specify an argument for -Xcompile"
7325eefee25Smacallan      exit $EXIT_FAILURE
7335eefee25Smacallan      ;;
7345eefee25Smacallan    target)
7355eefee25Smacallan      $echo "$modename: you must specify a target with \`-o'" 1>&2
7365eefee25Smacallan      exit $EXIT_FAILURE
7375eefee25Smacallan      ;;
7385eefee25Smacallan    *)
7395eefee25Smacallan      # Get the name of the library object.
7405eefee25Smacallan      [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
7415eefee25Smacallan      ;;
7425eefee25Smacallan    esac
7435eefee25Smacallan
7445eefee25Smacallan    # Recognize several different file suffixes.
7455eefee25Smacallan    # If the user specifies -o file.o, it is replaced with file.lo
7465eefee25Smacallan    xform='[cCFSifmso]'
7475eefee25Smacallan    case $libobj in
7485eefee25Smacallan    *.ada) xform=ada ;;
7495eefee25Smacallan    *.adb) xform=adb ;;
7505eefee25Smacallan    *.ads) xform=ads ;;
7515eefee25Smacallan    *.asm) xform=asm ;;
7525eefee25Smacallan    *.c++) xform=c++ ;;
7535eefee25Smacallan    *.cc) xform=cc ;;
7545eefee25Smacallan    *.ii) xform=ii ;;
7555eefee25Smacallan    *.class) xform=class ;;
7565eefee25Smacallan    *.cpp) xform=cpp ;;
7575eefee25Smacallan    *.cxx) xform=cxx ;;
7585eefee25Smacallan    *.f90) xform=f90 ;;
7595eefee25Smacallan    *.for) xform=for ;;
7605eefee25Smacallan    *.java) xform=java ;;
7615eefee25Smacallan    esac
7625eefee25Smacallan
7635eefee25Smacallan    libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
7645eefee25Smacallan
7655eefee25Smacallan    case $libobj in
7665eefee25Smacallan    *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
7675eefee25Smacallan    *)
7685eefee25Smacallan      $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
7695eefee25Smacallan      exit $EXIT_FAILURE
7705eefee25Smacallan      ;;
7715eefee25Smacallan    esac
7725eefee25Smacallan
7735eefee25Smacallan    func_infer_tag $base_compile
7745eefee25Smacallan
7755eefee25Smacallan    for arg in $later; do
7765eefee25Smacallan      case $arg in
7775eefee25Smacallan      -static)
7785eefee25Smacallan	build_old_libs=yes
7795eefee25Smacallan	continue
7805eefee25Smacallan	;;
7815eefee25Smacallan
7825eefee25Smacallan      -prefer-pic)
7835eefee25Smacallan	pic_mode=yes
7845eefee25Smacallan	continue
7855eefee25Smacallan	;;
7865eefee25Smacallan
7875eefee25Smacallan      -prefer-non-pic)
7885eefee25Smacallan	pic_mode=no
7895eefee25Smacallan	continue
7905eefee25Smacallan	;;
7915eefee25Smacallan      esac
7925eefee25Smacallan    done
7935eefee25Smacallan
7945eefee25Smacallan    qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"`
7955eefee25Smacallan    case $qlibobj in
7965eefee25Smacallan      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
7975eefee25Smacallan	qlibobj="\"$qlibobj\"" ;;
7985eefee25Smacallan    esac
7995eefee25Smacallan    test "X$libobj" != "X$qlibobj" \
8005eefee25Smacallan	&& $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"' 	&()|`$[]' \
8015eefee25Smacallan	&& $echo "$modename: libobj name \`$libobj' may not contain shell special characters."
8025eefee25Smacallan    objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
8035eefee25Smacallan    xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
8045eefee25Smacallan    if test "X$xdir" = "X$obj"; then
8055eefee25Smacallan      xdir=
8065eefee25Smacallan    else
8075eefee25Smacallan      xdir=$xdir/
8085eefee25Smacallan    fi
8095eefee25Smacallan    lobj=${xdir}$objdir/$objname
8105eefee25Smacallan
8115eefee25Smacallan    if test -z "$base_compile"; then
8125eefee25Smacallan      $echo "$modename: you must specify a compilation command" 1>&2
8135eefee25Smacallan      $echo "$help" 1>&2
8145eefee25Smacallan      exit $EXIT_FAILURE
8155eefee25Smacallan    fi
8165eefee25Smacallan
8175eefee25Smacallan    # Delete any leftover library objects.
8185eefee25Smacallan    if test "$build_old_libs" = yes; then
8195eefee25Smacallan      removelist="$obj $lobj $libobj ${libobj}T"
8205eefee25Smacallan    else
8215eefee25Smacallan      removelist="$lobj $libobj ${libobj}T"
8225eefee25Smacallan    fi
8235eefee25Smacallan
8245eefee25Smacallan    $run $rm $removelist
8255eefee25Smacallan    trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
8265eefee25Smacallan
8275eefee25Smacallan    # On Cygwin there's no "real" PIC flag so we must build both object types
8285eefee25Smacallan    case $host_os in
8295eefee25Smacallan    cygwin* | mingw* | pw32* | os2*)
8305eefee25Smacallan      pic_mode=default
8315eefee25Smacallan      ;;
8325eefee25Smacallan    esac
8335eefee25Smacallan    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
8345eefee25Smacallan      # non-PIC code in shared libraries is not supported
8355eefee25Smacallan      pic_mode=default
8365eefee25Smacallan    fi
8375eefee25Smacallan
8385eefee25Smacallan    # Calculate the filename of the output object if compiler does
8395eefee25Smacallan    # not support -o with -c
8405eefee25Smacallan    if test "$compiler_c_o" = no; then
8415eefee25Smacallan      output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
8425eefee25Smacallan      lockfile="$output_obj.lock"
8435eefee25Smacallan      removelist="$removelist $output_obj $lockfile"
8445eefee25Smacallan      trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
8455eefee25Smacallan    else
8465eefee25Smacallan      output_obj=
8475eefee25Smacallan      need_locks=no
8485eefee25Smacallan      lockfile=
8495eefee25Smacallan    fi
8505eefee25Smacallan
8515eefee25Smacallan    # Lock this critical section if it is needed
8525eefee25Smacallan    # We use this script file to make the link, it avoids creating a new file
8535eefee25Smacallan    if test "$need_locks" = yes; then
8545eefee25Smacallan      until $run ln "$progpath" "$lockfile" 2>/dev/null; do
8555eefee25Smacallan	$show "Waiting for $lockfile to be removed"
8565eefee25Smacallan	sleep 2
8575eefee25Smacallan      done
8585eefee25Smacallan    elif test "$need_locks" = warn; then
8595eefee25Smacallan      if test -f "$lockfile"; then
8605eefee25Smacallan	$echo "\
8615eefee25Smacallan*** ERROR, $lockfile exists and contains:
8625eefee25Smacallan`cat $lockfile 2>/dev/null`
8635eefee25Smacallan
8645eefee25SmacallanThis indicates that another process is trying to use the same
8655eefee25Smacallantemporary object file, and libtool could not work around it because
8665eefee25Smacallanyour compiler does not support \`-c' and \`-o' together.  If you
8675eefee25Smacallanrepeat this compilation, it may succeed, by chance, but you had better
8685eefee25Smacallanavoid parallel builds (make -j) in this platform, or get a better
8695eefee25Smacallancompiler."
8705eefee25Smacallan
8715eefee25Smacallan	$run $rm $removelist
8725eefee25Smacallan	exit $EXIT_FAILURE
8735eefee25Smacallan      fi
8745eefee25Smacallan      $echo "$srcfile" > "$lockfile"
8755eefee25Smacallan    fi
8765eefee25Smacallan
8775eefee25Smacallan    if test -n "$fix_srcfile_path"; then
8785eefee25Smacallan      eval srcfile=\"$fix_srcfile_path\"
8795eefee25Smacallan    fi
8805eefee25Smacallan    qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"`
8815eefee25Smacallan    case $qsrcfile in
8825eefee25Smacallan      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
8835eefee25Smacallan      qsrcfile="\"$qsrcfile\"" ;;
8845eefee25Smacallan    esac
8855eefee25Smacallan
8865eefee25Smacallan    $run $rm "$libobj" "${libobj}T"
8875eefee25Smacallan
8885eefee25Smacallan    # Create a libtool object file (analogous to a ".la" file),
8895eefee25Smacallan    # but don't create it if we're doing a dry run.
8905eefee25Smacallan    test -z "$run" && cat > ${libobj}T <<EOF
8915eefee25Smacallan# $libobj - a libtool object file
8925eefee25Smacallan# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
8935eefee25Smacallan#
8945eefee25Smacallan# Please DO NOT delete this file!
8955eefee25Smacallan# It is necessary for linking the library.
8965eefee25Smacallan
8975eefee25Smacallan# Name of the PIC object.
8985eefee25SmacallanEOF
8995eefee25Smacallan
9005eefee25Smacallan    # Only build a PIC object if we are building libtool libraries.
9015eefee25Smacallan    if test "$build_libtool_libs" = yes; then
9025eefee25Smacallan      # Without this assignment, base_compile gets emptied.
9035eefee25Smacallan      fbsd_hideous_sh_bug=$base_compile
9045eefee25Smacallan
9055eefee25Smacallan      if test "$pic_mode" != no; then
9065eefee25Smacallan	command="$base_compile $qsrcfile $pic_flag"
9075eefee25Smacallan      else
9085eefee25Smacallan	# Don't build PIC code
9095eefee25Smacallan	command="$base_compile $qsrcfile"
9105eefee25Smacallan      fi
9115eefee25Smacallan
9125eefee25Smacallan      if test ! -d "${xdir}$objdir"; then
9135eefee25Smacallan	$show "$mkdir ${xdir}$objdir"
9145eefee25Smacallan	$run $mkdir ${xdir}$objdir
9155eefee25Smacallan	exit_status=$?
9165eefee25Smacallan	if test "$exit_status" -ne 0 && test ! -d "${xdir}$objdir"; then
9175eefee25Smacallan	  exit $exit_status
9185eefee25Smacallan	fi
9195eefee25Smacallan      fi
9205eefee25Smacallan
9215eefee25Smacallan      if test -z "$output_obj"; then
9225eefee25Smacallan	# Place PIC objects in $objdir
9235eefee25Smacallan	command="$command -o $lobj"
9245eefee25Smacallan      fi
9255eefee25Smacallan
9265eefee25Smacallan      $run $rm "$lobj" "$output_obj"
9275eefee25Smacallan
9285eefee25Smacallan      $show "$command"
9295eefee25Smacallan      if $run eval "$command"; then :
9305eefee25Smacallan      else
9315eefee25Smacallan	test -n "$output_obj" && $run $rm $removelist
9325eefee25Smacallan	exit $EXIT_FAILURE
9335eefee25Smacallan      fi
9345eefee25Smacallan
9355eefee25Smacallan      if test "$need_locks" = warn &&
9365eefee25Smacallan	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
9375eefee25Smacallan	$echo "\
9385eefee25Smacallan*** ERROR, $lockfile contains:
9395eefee25Smacallan`cat $lockfile 2>/dev/null`
9405eefee25Smacallan
9415eefee25Smacallanbut it should contain:
9425eefee25Smacallan$srcfile
9435eefee25Smacallan
9445eefee25SmacallanThis indicates that another process is trying to use the same
9455eefee25Smacallantemporary object file, and libtool could not work around it because
9465eefee25Smacallanyour compiler does not support \`-c' and \`-o' together.  If you
9475eefee25Smacallanrepeat this compilation, it may succeed, by chance, but you had better
9485eefee25Smacallanavoid parallel builds (make -j) in this platform, or get a better
9495eefee25Smacallancompiler."
9505eefee25Smacallan
9515eefee25Smacallan	$run $rm $removelist
9525eefee25Smacallan	exit $EXIT_FAILURE
9535eefee25Smacallan      fi
9545eefee25Smacallan
9555eefee25Smacallan      # Just move the object if needed, then go on to compile the next one
9565eefee25Smacallan      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
9575eefee25Smacallan	$show "$mv $output_obj $lobj"
9585eefee25Smacallan	if $run $mv $output_obj $lobj; then :
9595eefee25Smacallan	else
9605eefee25Smacallan	  error=$?
9615eefee25Smacallan	  $run $rm $removelist
9625eefee25Smacallan	  exit $error
9635eefee25Smacallan	fi
9645eefee25Smacallan      fi
9655eefee25Smacallan
9665eefee25Smacallan      # Append the name of the PIC object to the libtool object file.
9675eefee25Smacallan      test -z "$run" && cat >> ${libobj}T <<EOF
9685eefee25Smacallanpic_object='$objdir/$objname'
9695eefee25Smacallan
9705eefee25SmacallanEOF
9715eefee25Smacallan
9725eefee25Smacallan      # Allow error messages only from the first compilation.
9735eefee25Smacallan      if test "$suppress_opt" = yes; then
9745eefee25Smacallan        suppress_output=' >/dev/null 2>&1'
9755eefee25Smacallan      fi
9765eefee25Smacallan    else
9775eefee25Smacallan      # No PIC object so indicate it doesn't exist in the libtool
9785eefee25Smacallan      # object file.
9795eefee25Smacallan      test -z "$run" && cat >> ${libobj}T <<EOF
9805eefee25Smacallanpic_object=none
9815eefee25Smacallan
9825eefee25SmacallanEOF
9835eefee25Smacallan    fi
9845eefee25Smacallan
9855eefee25Smacallan    # Only build a position-dependent object if we build old libraries.
9865eefee25Smacallan    if test "$build_old_libs" = yes; then
9875eefee25Smacallan      if test "$pic_mode" != yes; then
9885eefee25Smacallan	# Don't build PIC code
9895eefee25Smacallan	command="$base_compile $qsrcfile"
9905eefee25Smacallan      else
9915eefee25Smacallan	command="$base_compile $qsrcfile $pic_flag"
9925eefee25Smacallan      fi
9935eefee25Smacallan      if test "$compiler_c_o" = yes; then
9945eefee25Smacallan	command="$command -o $obj"
9955eefee25Smacallan      fi
9965eefee25Smacallan
9975eefee25Smacallan      # Suppress compiler output if we already did a PIC compilation.
9985eefee25Smacallan      command="$command$suppress_output"
9995eefee25Smacallan      $run $rm "$obj" "$output_obj"
10005eefee25Smacallan      $show "$command"
10015eefee25Smacallan      if $run eval "$command"; then :
10025eefee25Smacallan      else
10035eefee25Smacallan	$run $rm $removelist
10045eefee25Smacallan	exit $EXIT_FAILURE
10055eefee25Smacallan      fi
10065eefee25Smacallan
10075eefee25Smacallan      if test "$need_locks" = warn &&
10085eefee25Smacallan	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
10095eefee25Smacallan	$echo "\
10105eefee25Smacallan*** ERROR, $lockfile contains:
10115eefee25Smacallan`cat $lockfile 2>/dev/null`
10125eefee25Smacallan
10135eefee25Smacallanbut it should contain:
10145eefee25Smacallan$srcfile
10155eefee25Smacallan
10165eefee25SmacallanThis indicates that another process is trying to use the same
10175eefee25Smacallantemporary object file, and libtool could not work around it because
10185eefee25Smacallanyour compiler does not support \`-c' and \`-o' together.  If you
10195eefee25Smacallanrepeat this compilation, it may succeed, by chance, but you had better
10205eefee25Smacallanavoid parallel builds (make -j) in this platform, or get a better
10215eefee25Smacallancompiler."
10225eefee25Smacallan
10235eefee25Smacallan	$run $rm $removelist
10245eefee25Smacallan	exit $EXIT_FAILURE
10255eefee25Smacallan      fi
10265eefee25Smacallan
10275eefee25Smacallan      # Just move the object if needed
10285eefee25Smacallan      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
10295eefee25Smacallan	$show "$mv $output_obj $obj"
10305eefee25Smacallan	if $run $mv $output_obj $obj; then :
10315eefee25Smacallan	else
10325eefee25Smacallan	  error=$?
10335eefee25Smacallan	  $run $rm $removelist
10345eefee25Smacallan	  exit $error
10355eefee25Smacallan	fi
10365eefee25Smacallan      fi
10375eefee25Smacallan
10385eefee25Smacallan      # Append the name of the non-PIC object the libtool object file.
10395eefee25Smacallan      # Only append if the libtool object file exists.
10405eefee25Smacallan      test -z "$run" && cat >> ${libobj}T <<EOF
10415eefee25Smacallan# Name of the non-PIC object.
10425eefee25Smacallannon_pic_object='$objname'
10435eefee25Smacallan
10445eefee25SmacallanEOF
10455eefee25Smacallan    else
10465eefee25Smacallan      # Append the name of the non-PIC object the libtool object file.
10475eefee25Smacallan      # Only append if the libtool object file exists.
10485eefee25Smacallan      test -z "$run" && cat >> ${libobj}T <<EOF
10495eefee25Smacallan# Name of the non-PIC object.
10505eefee25Smacallannon_pic_object=none
10515eefee25Smacallan
10525eefee25SmacallanEOF
10535eefee25Smacallan    fi
10545eefee25Smacallan
10555eefee25Smacallan    $run $mv "${libobj}T" "${libobj}"
10565eefee25Smacallan
10575eefee25Smacallan    # Unlock the critical section if it was locked
10585eefee25Smacallan    if test "$need_locks" != no; then
10595eefee25Smacallan      $run $rm "$lockfile"
10605eefee25Smacallan    fi
10615eefee25Smacallan
10625eefee25Smacallan    exit $EXIT_SUCCESS
10635eefee25Smacallan    ;;
10645eefee25Smacallan
10655eefee25Smacallan  # libtool link mode
10665eefee25Smacallan  link | relink)
10675eefee25Smacallan    modename="$modename: link"
10685eefee25Smacallan    case $host in
10695eefee25Smacallan    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
10705eefee25Smacallan      # It is impossible to link a dll without this setting, and
10715eefee25Smacallan      # we shouldn't force the makefile maintainer to figure out
10725eefee25Smacallan      # which system we are compiling for in order to pass an extra
10735eefee25Smacallan      # flag for every libtool invocation.
10745eefee25Smacallan      # allow_undefined=no
10755eefee25Smacallan
10765eefee25Smacallan      # FIXME: Unfortunately, there are problems with the above when trying
10775eefee25Smacallan      # to make a dll which has undefined symbols, in which case not
10785eefee25Smacallan      # even a static library is built.  For now, we need to specify
10795eefee25Smacallan      # -no-undefined on the libtool link line when we can be certain
10805eefee25Smacallan      # that all symbols are satisfied, otherwise we get a static library.
10815eefee25Smacallan      allow_undefined=yes
10825eefee25Smacallan      ;;
10835eefee25Smacallan    *)
10845eefee25Smacallan      allow_undefined=yes
10855eefee25Smacallan      ;;
10865eefee25Smacallan    esac
10875eefee25Smacallan    libtool_args="$nonopt"
10885eefee25Smacallan    base_compile="$nonopt $@"
10895eefee25Smacallan    compile_command="$nonopt"
10905eefee25Smacallan    finalize_command="$nonopt"
10915eefee25Smacallan
10925eefee25Smacallan    compile_rpath=
10935eefee25Smacallan    finalize_rpath=
10945eefee25Smacallan    compile_shlibpath=
10955eefee25Smacallan    finalize_shlibpath=
10965eefee25Smacallan    convenience=
10975eefee25Smacallan    old_convenience=
10985eefee25Smacallan    deplibs=
10995eefee25Smacallan    old_deplibs=
11005eefee25Smacallan    compiler_flags=
11015eefee25Smacallan    linker_flags=
11025eefee25Smacallan    dllsearchpath=
11035eefee25Smacallan    lib_search_path=`pwd`
11045eefee25Smacallan    inst_prefix_dir=
11055eefee25Smacallan
11065eefee25Smacallan    avoid_version=no
11075eefee25Smacallan    dlfiles=
11085eefee25Smacallan    dlprefiles=
11095eefee25Smacallan    dlself=no
11105eefee25Smacallan    export_dynamic=no
11115eefee25Smacallan    export_symbols=
11125eefee25Smacallan    export_symbols_regex=
11135eefee25Smacallan    generated=
11145eefee25Smacallan    libobjs=
11155eefee25Smacallan    ltlibs=
11165eefee25Smacallan    module=no
11175eefee25Smacallan    no_install=no
11185eefee25Smacallan    objs=
11195eefee25Smacallan    non_pic_objects=
11205eefee25Smacallan    notinst_path= # paths that contain not-installed libtool libraries
11215eefee25Smacallan    precious_files_regex=
11225eefee25Smacallan    prefer_static_libs=no
11235eefee25Smacallan    preload=no
11245eefee25Smacallan    prev=
11255eefee25Smacallan    prevarg=
11265eefee25Smacallan    release=
11275eefee25Smacallan    rpath=
11285eefee25Smacallan    xrpath=
11295eefee25Smacallan    perm_rpath=
11305eefee25Smacallan    temp_rpath=
11315eefee25Smacallan    thread_safe=no
11325eefee25Smacallan    vinfo=
11335eefee25Smacallan    vinfo_number=no
11345eefee25Smacallan
11355eefee25Smacallan    func_infer_tag $base_compile
11365eefee25Smacallan
11375eefee25Smacallan    # We need to know -static, to get the right output filenames.
11385eefee25Smacallan    for arg
11395eefee25Smacallan    do
11405eefee25Smacallan      case $arg in
11415eefee25Smacallan      -all-static | -static)
11425eefee25Smacallan	if test "X$arg" = "X-all-static"; then
11435eefee25Smacallan	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
11445eefee25Smacallan	    $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
11455eefee25Smacallan	  fi
11465eefee25Smacallan	  if test -n "$link_static_flag"; then
11475eefee25Smacallan	    dlopen_self=$dlopen_self_static
11485eefee25Smacallan	  fi
11495eefee25Smacallan	  prefer_static_libs=yes
11505eefee25Smacallan	else
11515eefee25Smacallan	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
11525eefee25Smacallan	    dlopen_self=$dlopen_self_static
11535eefee25Smacallan	  fi
11545eefee25Smacallan	  prefer_static_libs=built
11555eefee25Smacallan	fi
11565eefee25Smacallan	build_libtool_libs=no
11575eefee25Smacallan	build_old_libs=yes
11585eefee25Smacallan	break
11595eefee25Smacallan	;;
11605eefee25Smacallan      esac
11615eefee25Smacallan    done
11625eefee25Smacallan
11635eefee25Smacallan    # See if our shared archives depend on static archives.
11645eefee25Smacallan    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
11655eefee25Smacallan
11665eefee25Smacallan    # Go through the arguments, transforming them on the way.
11675eefee25Smacallan    while test "$#" -gt 0; do
11685eefee25Smacallan      arg="$1"
11695eefee25Smacallan      shift
11705eefee25Smacallan      case $arg in
11715eefee25Smacallan      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
11725eefee25Smacallan	qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test
11735eefee25Smacallan	;;
11745eefee25Smacallan      *) qarg=$arg ;;
11755eefee25Smacallan      esac
11765eefee25Smacallan      libtool_args="$libtool_args $qarg"
11775eefee25Smacallan
11785eefee25Smacallan      # If the previous option needs an argument, assign it.
11795eefee25Smacallan      if test -n "$prev"; then
11805eefee25Smacallan	case $prev in
11815eefee25Smacallan	output)
11825eefee25Smacallan	  compile_command="$compile_command @OUTPUT@"
11835eefee25Smacallan	  finalize_command="$finalize_command @OUTPUT@"
11845eefee25Smacallan	  ;;
11855eefee25Smacallan	esac
11865eefee25Smacallan
11875eefee25Smacallan	case $prev in
11885eefee25Smacallan	dlfiles|dlprefiles)
11895eefee25Smacallan	  if test "$preload" = no; then
11905eefee25Smacallan	    # Add the symbol object into the linking commands.
11915eefee25Smacallan	    compile_command="$compile_command @SYMFILE@"
11925eefee25Smacallan	    finalize_command="$finalize_command @SYMFILE@"
11935eefee25Smacallan	    preload=yes
11945eefee25Smacallan	  fi
11955eefee25Smacallan	  case $arg in
11965eefee25Smacallan	  *.la | *.lo) ;;  # We handle these cases below.
11975eefee25Smacallan	  force)
11985eefee25Smacallan	    if test "$dlself" = no; then
11995eefee25Smacallan	      dlself=needless
12005eefee25Smacallan	      export_dynamic=yes
12015eefee25Smacallan	    fi
12025eefee25Smacallan	    prev=
12035eefee25Smacallan	    continue
12045eefee25Smacallan	    ;;
12055eefee25Smacallan	  self)
12065eefee25Smacallan	    if test "$prev" = dlprefiles; then
12075eefee25Smacallan	      dlself=yes
12085eefee25Smacallan	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
12095eefee25Smacallan	      dlself=yes
12105eefee25Smacallan	    else
12115eefee25Smacallan	      dlself=needless
12125eefee25Smacallan	      export_dynamic=yes
12135eefee25Smacallan	    fi
12145eefee25Smacallan	    prev=
12155eefee25Smacallan	    continue
12165eefee25Smacallan	    ;;
12175eefee25Smacallan	  *)
12185eefee25Smacallan	    if test "$prev" = dlfiles; then
12195eefee25Smacallan	      dlfiles="$dlfiles $arg"
12205eefee25Smacallan	    else
12215eefee25Smacallan	      dlprefiles="$dlprefiles $arg"
12225eefee25Smacallan	    fi
12235eefee25Smacallan	    prev=
12245eefee25Smacallan	    continue
12255eefee25Smacallan	    ;;
12265eefee25Smacallan	  esac
12275eefee25Smacallan	  ;;
12285eefee25Smacallan	expsyms)
12295eefee25Smacallan	  export_symbols="$arg"
12305eefee25Smacallan	  if test ! -f "$arg"; then
12315eefee25Smacallan	    $echo "$modename: symbol file \`$arg' does not exist"
12325eefee25Smacallan	    exit $EXIT_FAILURE
12335eefee25Smacallan	  fi
12345eefee25Smacallan	  prev=
12355eefee25Smacallan	  continue
12365eefee25Smacallan	  ;;
12375eefee25Smacallan	expsyms_regex)
12385eefee25Smacallan	  export_symbols_regex="$arg"
12395eefee25Smacallan	  prev=
12405eefee25Smacallan	  continue
12415eefee25Smacallan	  ;;
12425eefee25Smacallan	inst_prefix)
12435eefee25Smacallan	  inst_prefix_dir="$arg"
12445eefee25Smacallan	  prev=
12455eefee25Smacallan	  continue
12465eefee25Smacallan	  ;;
12475eefee25Smacallan	precious_regex)
12485eefee25Smacallan	  precious_files_regex="$arg"
12495eefee25Smacallan	  prev=
12505eefee25Smacallan	  continue
12515eefee25Smacallan	  ;;
12525eefee25Smacallan	release)
12535eefee25Smacallan	  release="-$arg"
12545eefee25Smacallan	  prev=
12555eefee25Smacallan	  continue
12565eefee25Smacallan	  ;;
12575eefee25Smacallan	objectlist)
12585eefee25Smacallan	  if test -f "$arg"; then
12595eefee25Smacallan	    save_arg=$arg
12605eefee25Smacallan	    moreargs=
12615eefee25Smacallan	    for fil in `cat $save_arg`
12625eefee25Smacallan	    do
12635eefee25Smacallan#	      moreargs="$moreargs $fil"
12645eefee25Smacallan	      arg=$fil
12655eefee25Smacallan	      # A libtool-controlled object.
12665eefee25Smacallan
12675eefee25Smacallan	      # Check to see that this really is a libtool object.
12685eefee25Smacallan	      if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
12695eefee25Smacallan		pic_object=
12705eefee25Smacallan		non_pic_object=
12715eefee25Smacallan
12725eefee25Smacallan		# Read the .lo file
12735eefee25Smacallan		# If there is no directory component, then add one.
12745eefee25Smacallan		case $arg in
12755eefee25Smacallan		*/* | *\\*) . $arg ;;
12765eefee25Smacallan		*) . ./$arg ;;
12775eefee25Smacallan		esac
12785eefee25Smacallan
12795eefee25Smacallan		if test -z "$pic_object" || \
12805eefee25Smacallan		   test -z "$non_pic_object" ||
12815eefee25Smacallan		   test "$pic_object" = none && \
12825eefee25Smacallan		   test "$non_pic_object" = none; then
12835eefee25Smacallan		  $echo "$modename: cannot find name of object for \`$arg'" 1>&2
12845eefee25Smacallan		  exit $EXIT_FAILURE
12855eefee25Smacallan		fi
12865eefee25Smacallan
12875eefee25Smacallan		# Extract subdirectory from the argument.
12885eefee25Smacallan		xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
12895eefee25Smacallan		if test "X$xdir" = "X$arg"; then
12905eefee25Smacallan		  xdir=
12915eefee25Smacallan		else
12925eefee25Smacallan		  xdir="$xdir/"
12935eefee25Smacallan		fi
12945eefee25Smacallan
12955eefee25Smacallan		if test "$pic_object" != none; then
12965eefee25Smacallan		  # Prepend the subdirectory the object is found in.
12975eefee25Smacallan		  pic_object="$xdir$pic_object"
12985eefee25Smacallan
12995eefee25Smacallan		  if test "$prev" = dlfiles; then
13005eefee25Smacallan		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
13015eefee25Smacallan		      dlfiles="$dlfiles $pic_object"
13025eefee25Smacallan		      prev=
13035eefee25Smacallan		      continue
13045eefee25Smacallan		    else
13055eefee25Smacallan		      # If libtool objects are unsupported, then we need to preload.
13065eefee25Smacallan		      prev=dlprefiles
13075eefee25Smacallan		    fi
13085eefee25Smacallan		  fi
13095eefee25Smacallan
13105eefee25Smacallan		  # CHECK ME:  I think I busted this.  -Ossama
13115eefee25Smacallan		  if test "$prev" = dlprefiles; then
13125eefee25Smacallan		    # Preload the old-style object.
13135eefee25Smacallan		    dlprefiles="$dlprefiles $pic_object"
13145eefee25Smacallan		    prev=
13155eefee25Smacallan		  fi
13165eefee25Smacallan
13175eefee25Smacallan		  # A PIC object.
13185eefee25Smacallan		  libobjs="$libobjs $pic_object"
13195eefee25Smacallan		  arg="$pic_object"
13205eefee25Smacallan		fi
13215eefee25Smacallan
13225eefee25Smacallan		# Non-PIC object.
13235eefee25Smacallan		if test "$non_pic_object" != none; then
13245eefee25Smacallan		  # Prepend the subdirectory the object is found in.
13255eefee25Smacallan		  non_pic_object="$xdir$non_pic_object"
13265eefee25Smacallan
13275eefee25Smacallan		  # A standard non-PIC object
13285eefee25Smacallan		  non_pic_objects="$non_pic_objects $non_pic_object"
13295eefee25Smacallan		  if test -z "$pic_object" || test "$pic_object" = none ; then
13305eefee25Smacallan		    arg="$non_pic_object"
13315eefee25Smacallan		  fi
13325eefee25Smacallan		else
13335eefee25Smacallan		  # If the PIC object exists, use it instead.
13345eefee25Smacallan		  # $xdir was prepended to $pic_object above.
13355eefee25Smacallan		  non_pic_object="$pic_object"
13365eefee25Smacallan		  non_pic_objects="$non_pic_objects $non_pic_object"
13375eefee25Smacallan		fi
13385eefee25Smacallan	      else
13395eefee25Smacallan		# Only an error if not doing a dry-run.
13405eefee25Smacallan		if test -z "$run"; then
13415eefee25Smacallan		  $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
13425eefee25Smacallan		  exit $EXIT_FAILURE
13435eefee25Smacallan		else
13445eefee25Smacallan		  # Dry-run case.
13455eefee25Smacallan
13465eefee25Smacallan		  # Extract subdirectory from the argument.
13475eefee25Smacallan		  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
13485eefee25Smacallan		  if test "X$xdir" = "X$arg"; then
13495eefee25Smacallan		    xdir=
13505eefee25Smacallan		  else
13515eefee25Smacallan		    xdir="$xdir/"
13525eefee25Smacallan		  fi
13535eefee25Smacallan
13545eefee25Smacallan		  pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
13555eefee25Smacallan		  non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
13565eefee25Smacallan		  libobjs="$libobjs $pic_object"
13575eefee25Smacallan		  non_pic_objects="$non_pic_objects $non_pic_object"
13585eefee25Smacallan		fi
13595eefee25Smacallan	      fi
13605eefee25Smacallan	    done
13615eefee25Smacallan	  else
13625eefee25Smacallan	    $echo "$modename: link input file \`$save_arg' does not exist"
13635eefee25Smacallan	    exit $EXIT_FAILURE
13645eefee25Smacallan	  fi
13655eefee25Smacallan	  arg=$save_arg
13665eefee25Smacallan	  prev=
13675eefee25Smacallan	  continue
13685eefee25Smacallan	  ;;
13695eefee25Smacallan	rpath | xrpath)
13705eefee25Smacallan	  # We need an absolute path.
13715eefee25Smacallan	  case $arg in
13725eefee25Smacallan	  [\\/]* | [A-Za-z]:[\\/]*) ;;
13735eefee25Smacallan	  *)
13745eefee25Smacallan	    $echo "$modename: only absolute run-paths are allowed" 1>&2
13755eefee25Smacallan	    exit $EXIT_FAILURE
13765eefee25Smacallan	    ;;
13775eefee25Smacallan	  esac
13785eefee25Smacallan	  if test "$prev" = rpath; then
13795eefee25Smacallan	    case "$rpath " in
13805eefee25Smacallan	    *" $arg "*) ;;
13815eefee25Smacallan	    *) rpath="$rpath $arg" ;;
13825eefee25Smacallan	    esac
13835eefee25Smacallan	  else
13845eefee25Smacallan	    case "$xrpath " in
13855eefee25Smacallan	    *" $arg "*) ;;
13865eefee25Smacallan	    *) xrpath="$xrpath $arg" ;;
13875eefee25Smacallan	    esac
13885eefee25Smacallan	  fi
13895eefee25Smacallan	  prev=
13905eefee25Smacallan	  continue
13915eefee25Smacallan	  ;;
13925eefee25Smacallan	xcompiler)
13935eefee25Smacallan	  compiler_flags="$compiler_flags $qarg"
13945eefee25Smacallan	  prev=
13955eefee25Smacallan	  compile_command="$compile_command $qarg"
13965eefee25Smacallan	  finalize_command="$finalize_command $qarg"
13975eefee25Smacallan	  continue
13985eefee25Smacallan	  ;;
13995eefee25Smacallan	xlinker)
14005eefee25Smacallan	  linker_flags="$linker_flags $qarg"
14015eefee25Smacallan	  compiler_flags="$compiler_flags $wl$qarg"
14025eefee25Smacallan	  prev=
14035eefee25Smacallan	  compile_command="$compile_command $wl$qarg"
14045eefee25Smacallan	  finalize_command="$finalize_command $wl$qarg"
14055eefee25Smacallan	  continue
14065eefee25Smacallan	  ;;
14075eefee25Smacallan	xcclinker)
14085eefee25Smacallan	  linker_flags="$linker_flags $qarg"
14095eefee25Smacallan	  compiler_flags="$compiler_flags $qarg"
14105eefee25Smacallan	  prev=
14115eefee25Smacallan	  compile_command="$compile_command $qarg"
14125eefee25Smacallan	  finalize_command="$finalize_command $qarg"
14135eefee25Smacallan	  continue
14145eefee25Smacallan	  ;;
14155eefee25Smacallan	shrext)
14165eefee25Smacallan  	  shrext_cmds="$arg"
14175eefee25Smacallan	  prev=
14185eefee25Smacallan	  continue
14195eefee25Smacallan	  ;;
14205eefee25Smacallan	darwin_framework|darwin_framework_skip)
14215eefee25Smacallan	  test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg"
14225eefee25Smacallan	  compile_command="$compile_command $arg"
14235eefee25Smacallan	  finalize_command="$finalize_command $arg"
14245eefee25Smacallan	  prev=
14255eefee25Smacallan	  continue
14265eefee25Smacallan	  ;;
14275eefee25Smacallan	*)
14285eefee25Smacallan	  eval "$prev=\"\$arg\""
14295eefee25Smacallan	  prev=
14305eefee25Smacallan	  continue
14315eefee25Smacallan	  ;;
14325eefee25Smacallan	esac
14335eefee25Smacallan      fi # test -n "$prev"
14345eefee25Smacallan
14355eefee25Smacallan      prevarg="$arg"
14365eefee25Smacallan
14375eefee25Smacallan      case $arg in
14385eefee25Smacallan      -all-static)
14395eefee25Smacallan	if test -n "$link_static_flag"; then
14405eefee25Smacallan	  compile_command="$compile_command $link_static_flag"
14415eefee25Smacallan	  finalize_command="$finalize_command $link_static_flag"
14425eefee25Smacallan	fi
14435eefee25Smacallan	continue
14445eefee25Smacallan	;;
14455eefee25Smacallan
14465eefee25Smacallan      -allow-undefined)
14475eefee25Smacallan	# FIXME: remove this flag sometime in the future.
14485eefee25Smacallan	$echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
14495eefee25Smacallan	continue
14505eefee25Smacallan	;;
14515eefee25Smacallan
14525eefee25Smacallan      -avoid-version)
14535eefee25Smacallan	avoid_version=yes
14545eefee25Smacallan	continue
14555eefee25Smacallan	;;
14565eefee25Smacallan
14575eefee25Smacallan      -dlopen)
14585eefee25Smacallan	prev=dlfiles
14595eefee25Smacallan	continue
14605eefee25Smacallan	;;
14615eefee25Smacallan
14625eefee25Smacallan      -dlpreopen)
14635eefee25Smacallan	prev=dlprefiles
14645eefee25Smacallan	continue
14655eefee25Smacallan	;;
14665eefee25Smacallan
14675eefee25Smacallan      -export-dynamic)
14685eefee25Smacallan	export_dynamic=yes
14695eefee25Smacallan	continue
14705eefee25Smacallan	;;
14715eefee25Smacallan
14725eefee25Smacallan      -export-symbols | -export-symbols-regex)
14735eefee25Smacallan	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
14745eefee25Smacallan	  $echo "$modename: more than one -exported-symbols argument is not allowed"
14755eefee25Smacallan	  exit $EXIT_FAILURE
14765eefee25Smacallan	fi
14775eefee25Smacallan	if test "X$arg" = "X-export-symbols"; then
14785eefee25Smacallan	  prev=expsyms
14795eefee25Smacallan	else
14805eefee25Smacallan	  prev=expsyms_regex
14815eefee25Smacallan	fi
14825eefee25Smacallan	continue
14835eefee25Smacallan	;;
14845eefee25Smacallan
14855eefee25Smacallan      -framework|-arch|-isysroot)
14865eefee25Smacallan	case " $CC " in
14875eefee25Smacallan	  *" ${arg} ${1} "* | *" ${arg}	${1} "*) 
14885eefee25Smacallan		prev=darwin_framework_skip ;;
14895eefee25Smacallan	  *) compiler_flags="$compiler_flags $arg"
14905eefee25Smacallan	     prev=darwin_framework ;;
14915eefee25Smacallan	esac
14925eefee25Smacallan	compile_command="$compile_command $arg"
14935eefee25Smacallan	finalize_command="$finalize_command $arg"
14945eefee25Smacallan	continue
14955eefee25Smacallan	;;
14965eefee25Smacallan
14975eefee25Smacallan      -inst-prefix-dir)
14985eefee25Smacallan	prev=inst_prefix
14995eefee25Smacallan	continue
15005eefee25Smacallan	;;
15015eefee25Smacallan
15025eefee25Smacallan      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
15035eefee25Smacallan      # so, if we see these flags be careful not to treat them like -L
15045eefee25Smacallan      -L[A-Z][A-Z]*:*)
15055eefee25Smacallan	case $with_gcc/$host in
15065eefee25Smacallan	no/*-*-irix* | /*-*-irix*)
15075eefee25Smacallan	  compile_command="$compile_command $arg"
15085eefee25Smacallan	  finalize_command="$finalize_command $arg"
15095eefee25Smacallan	  ;;
15105eefee25Smacallan	esac
15115eefee25Smacallan	continue
15125eefee25Smacallan	;;
15135eefee25Smacallan
15145eefee25Smacallan      -L*)
15155eefee25Smacallan	dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
15165eefee25Smacallan	# We need an absolute path.
15175eefee25Smacallan	case $dir in
15185eefee25Smacallan	[\\/]* | [A-Za-z]:[\\/]*) ;;
15195eefee25Smacallan	*)
15205eefee25Smacallan	  absdir=`cd "$dir" && pwd`
15215eefee25Smacallan	  if test -z "$absdir"; then
15225eefee25Smacallan	    $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
15235eefee25Smacallan	    absdir="$dir"
15245eefee25Smacallan	    notinst_path="$notinst_path $dir"
15255eefee25Smacallan	  fi
15265eefee25Smacallan	  dir="$absdir"
15275eefee25Smacallan	  ;;
15285eefee25Smacallan	esac
15295eefee25Smacallan	case "$deplibs " in
15305eefee25Smacallan	*" -L$dir "*) ;;
15315eefee25Smacallan	*)
15325eefee25Smacallan	  deplibs="$deplibs -L$dir"
15335eefee25Smacallan	  lib_search_path="$lib_search_path $dir"
15345eefee25Smacallan	  ;;
15355eefee25Smacallan	esac
15365eefee25Smacallan	case $host in
15375eefee25Smacallan	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
15385eefee25Smacallan	  testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'`
15395eefee25Smacallan	  case :$dllsearchpath: in
15405eefee25Smacallan	  *":$dir:"*) ;;
15415eefee25Smacallan	  *) dllsearchpath="$dllsearchpath:$dir";;
15425eefee25Smacallan	  esac
15435eefee25Smacallan	  case :$dllsearchpath: in
15445eefee25Smacallan	  *":$testbindir:"*) ;;
15455eefee25Smacallan	  *) dllsearchpath="$dllsearchpath:$testbindir";;
15465eefee25Smacallan	  esac
15475eefee25Smacallan	  ;;
15485eefee25Smacallan	esac
15495eefee25Smacallan	continue
15505eefee25Smacallan	;;
15515eefee25Smacallan
15525eefee25Smacallan      -l*)
15535eefee25Smacallan	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
15545eefee25Smacallan	  case $host in
15555eefee25Smacallan	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*)
15565eefee25Smacallan	    # These systems don't actually have a C or math library (as such)
15575eefee25Smacallan	    continue
15585eefee25Smacallan	    ;;
15595eefee25Smacallan	  *-*-os2*)
15605eefee25Smacallan	    # These systems don't actually have a C library (as such)
15615eefee25Smacallan	    test "X$arg" = "X-lc" && continue
15625eefee25Smacallan	    ;;
15635eefee25Smacallan	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
15645eefee25Smacallan	    # Do not include libc due to us having libc/libc_r.
15655eefee25Smacallan	    test "X$arg" = "X-lc" && continue
15665eefee25Smacallan	    ;;
15675eefee25Smacallan	  *-*-rhapsody* | *-*-darwin1.[012])
15685eefee25Smacallan	    # Rhapsody C and math libraries are in the System framework
15695eefee25Smacallan	    deplibs="$deplibs -framework System"
15705eefee25Smacallan	    continue
15715eefee25Smacallan	    ;;
15725eefee25Smacallan	  *-*-sco3.2v5* | *-*-sco5v6*)
15735eefee25Smacallan	    # Causes problems with __ctype
15745eefee25Smacallan	    test "X$arg" = "X-lc" && continue
15755eefee25Smacallan	    ;;
15765eefee25Smacallan	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
15775eefee25Smacallan	    # Compiler inserts libc in the correct place for threads to work
15785eefee25Smacallan	    test "X$arg" = "X-lc" && continue
15795eefee25Smacallan	    ;;
15805eefee25Smacallan	  esac
15815eefee25Smacallan	elif test "X$arg" = "X-lc_r"; then
15825eefee25Smacallan	 case $host in
15835eefee25Smacallan	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
15845eefee25Smacallan	   # Do not include libc_r directly, use -pthread flag.
15855eefee25Smacallan	   continue
15865eefee25Smacallan	   ;;
15875eefee25Smacallan	 esac
15885eefee25Smacallan	fi
15895eefee25Smacallan	deplibs="$deplibs $arg"
15905eefee25Smacallan	continue
15915eefee25Smacallan	;;
15925eefee25Smacallan
15935eefee25Smacallan      # Tru64 UNIX uses -model [arg] to determine the layout of C++
15945eefee25Smacallan      # classes, name mangling, and exception handling.
15955eefee25Smacallan      -model)
15965eefee25Smacallan	compile_command="$compile_command $arg"
15975eefee25Smacallan	compiler_flags="$compiler_flags $arg"
15985eefee25Smacallan	finalize_command="$finalize_command $arg"
15995eefee25Smacallan	prev=xcompiler
16005eefee25Smacallan	continue
16015eefee25Smacallan	;;
16025eefee25Smacallan
16035eefee25Smacallan     -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
16045eefee25Smacallan	compiler_flags="$compiler_flags $arg"
16055eefee25Smacallan	compile_command="$compile_command $arg"
16065eefee25Smacallan	finalize_command="$finalize_command $arg"
16075eefee25Smacallan	continue
16085eefee25Smacallan	;;
16095eefee25Smacallan
16105eefee25Smacallan      -module)
16115eefee25Smacallan	module=yes
16125eefee25Smacallan	continue
16135eefee25Smacallan	;;
16145eefee25Smacallan
16155eefee25Smacallan      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
16165eefee25Smacallan      # -r[0-9][0-9]* specifies the processor on the SGI compiler
16175eefee25Smacallan      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
16185eefee25Smacallan      # +DA*, +DD* enable 64-bit mode on the HP compiler
16195eefee25Smacallan      # -q* pass through compiler args for the IBM compiler
16205eefee25Smacallan      # -m* pass through architecture-specific compiler args for GCC
16215eefee25Smacallan      # -m*, -t[45]*, -txscale* pass through architecture-specific
16225eefee25Smacallan      # compiler args for GCC
16235eefee25Smacallan      # -pg pass through profiling flag for GCC
16245eefee25Smacallan      # @file GCC response files
16255eefee25Smacallan      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*|-pg| \
16265eefee25Smacallan      -t[45]*|-txscale*|@*)
16275eefee25Smacallan
16285eefee25Smacallan	# Unknown arguments in both finalize_command and compile_command need
16295eefee25Smacallan	# to be aesthetically quoted because they are evaled later.
16305eefee25Smacallan	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
16315eefee25Smacallan	case $arg in
16325eefee25Smacallan	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
16335eefee25Smacallan	  arg="\"$arg\""
16345eefee25Smacallan	  ;;
16355eefee25Smacallan	esac
16365eefee25Smacallan        compile_command="$compile_command $arg"
16375eefee25Smacallan        finalize_command="$finalize_command $arg"
16385eefee25Smacallan        compiler_flags="$compiler_flags $arg"
16395eefee25Smacallan        continue
16405eefee25Smacallan        ;;
16415eefee25Smacallan
16425eefee25Smacallan      -shrext)
16435eefee25Smacallan	prev=shrext
16445eefee25Smacallan	continue
16455eefee25Smacallan	;;
16465eefee25Smacallan
16475eefee25Smacallan      -no-fast-install)
16485eefee25Smacallan	fast_install=no
16495eefee25Smacallan	continue
16505eefee25Smacallan	;;
16515eefee25Smacallan
16525eefee25Smacallan      -no-install)
16535eefee25Smacallan	case $host in
16545eefee25Smacallan	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
16555eefee25Smacallan	  # The PATH hackery in wrapper scripts is required on Windows
16565eefee25Smacallan	  # in order for the loader to find any dlls it needs.
16575eefee25Smacallan	  $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2
16585eefee25Smacallan	  $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2
16595eefee25Smacallan	  fast_install=no
16605eefee25Smacallan	  ;;
16615eefee25Smacallan	*) no_install=yes ;;
16625eefee25Smacallan	esac
16635eefee25Smacallan	continue
16645eefee25Smacallan	;;
16655eefee25Smacallan
16665eefee25Smacallan      -no-undefined)
16675eefee25Smacallan	allow_undefined=no
16685eefee25Smacallan	continue
16695eefee25Smacallan	;;
16705eefee25Smacallan
16715eefee25Smacallan      -objectlist)
16725eefee25Smacallan	prev=objectlist
16735eefee25Smacallan	continue
16745eefee25Smacallan	;;
16755eefee25Smacallan
16765eefee25Smacallan      -o) prev=output ;;
16775eefee25Smacallan
16785eefee25Smacallan      -precious-files-regex)
16795eefee25Smacallan	prev=precious_regex
16805eefee25Smacallan	continue
16815eefee25Smacallan	;;
16825eefee25Smacallan
16835eefee25Smacallan      -release)
16845eefee25Smacallan	prev=release
16855eefee25Smacallan	continue
16865eefee25Smacallan	;;
16875eefee25Smacallan
16885eefee25Smacallan      -rpath)
16895eefee25Smacallan	prev=rpath
16905eefee25Smacallan	continue
16915eefee25Smacallan	;;
16925eefee25Smacallan
16935eefee25Smacallan      -R)
16945eefee25Smacallan	prev=xrpath
16955eefee25Smacallan	continue
16965eefee25Smacallan	;;
16975eefee25Smacallan
16985eefee25Smacallan      -R*)
16995eefee25Smacallan	dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
17005eefee25Smacallan	# We need an absolute path.
17015eefee25Smacallan	case $dir in
17025eefee25Smacallan	[\\/]* | [A-Za-z]:[\\/]*) ;;
17035eefee25Smacallan	*)
17045eefee25Smacallan	  $echo "$modename: only absolute run-paths are allowed" 1>&2
17055eefee25Smacallan	  exit $EXIT_FAILURE
17065eefee25Smacallan	  ;;
17075eefee25Smacallan	esac
17085eefee25Smacallan	case "$xrpath " in
17095eefee25Smacallan	*" $dir "*) ;;
17105eefee25Smacallan	*) xrpath="$xrpath $dir" ;;
17115eefee25Smacallan	esac
17125eefee25Smacallan	continue
17135eefee25Smacallan	;;
17145eefee25Smacallan
17155eefee25Smacallan      -static)
17165eefee25Smacallan	# The effects of -static are defined in a previous loop.
17175eefee25Smacallan	# We used to do the same as -all-static on platforms that
17185eefee25Smacallan	# didn't have a PIC flag, but the assumption that the effects
17195eefee25Smacallan	# would be equivalent was wrong.  It would break on at least
17205eefee25Smacallan	# Digital Unix and AIX.
17215eefee25Smacallan	continue
17225eefee25Smacallan	;;
17235eefee25Smacallan
17245eefee25Smacallan      -thread-safe)
17255eefee25Smacallan	thread_safe=yes
17265eefee25Smacallan	continue
17275eefee25Smacallan	;;
17285eefee25Smacallan
17295eefee25Smacallan      -version-info)
17305eefee25Smacallan	prev=vinfo
17315eefee25Smacallan	continue
17325eefee25Smacallan	;;
17335eefee25Smacallan      -version-number)
17345eefee25Smacallan	prev=vinfo
17355eefee25Smacallan	vinfo_number=yes
17365eefee25Smacallan	continue
17375eefee25Smacallan	;;
17385eefee25Smacallan
17395eefee25Smacallan      -Wc,*)
17405eefee25Smacallan	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'`
17415eefee25Smacallan	arg=
17425eefee25Smacallan	save_ifs="$IFS"; IFS=','
17435eefee25Smacallan	for flag in $args; do
17445eefee25Smacallan	  IFS="$save_ifs"
17455eefee25Smacallan	  case $flag in
17465eefee25Smacallan	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
17475eefee25Smacallan	    flag="\"$flag\""
17485eefee25Smacallan	    ;;
17495eefee25Smacallan	  esac
17505eefee25Smacallan	  arg="$arg $wl$flag"
17515eefee25Smacallan	  compiler_flags="$compiler_flags $flag"
17525eefee25Smacallan	done
17535eefee25Smacallan	IFS="$save_ifs"
17545eefee25Smacallan	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
17555eefee25Smacallan	;;
17565eefee25Smacallan
17575eefee25Smacallan      -Wl,*)
17585eefee25Smacallan	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'`
17595eefee25Smacallan	arg=
17605eefee25Smacallan	save_ifs="$IFS"; IFS=','
17615eefee25Smacallan	for flag in $args; do
17625eefee25Smacallan	  IFS="$save_ifs"
17635eefee25Smacallan	  case $flag in
17645eefee25Smacallan	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
17655eefee25Smacallan	    flag="\"$flag\""
17665eefee25Smacallan	    ;;
17675eefee25Smacallan	  esac
17685eefee25Smacallan	  arg="$arg $wl$flag"
17695eefee25Smacallan	  compiler_flags="$compiler_flags $wl$flag"
17705eefee25Smacallan	  linker_flags="$linker_flags $flag"
17715eefee25Smacallan	done
17725eefee25Smacallan	IFS="$save_ifs"
17735eefee25Smacallan	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
17745eefee25Smacallan	;;
17755eefee25Smacallan
17765eefee25Smacallan      -Xcompiler)
17775eefee25Smacallan	prev=xcompiler
17785eefee25Smacallan	continue
17795eefee25Smacallan	;;
17805eefee25Smacallan
17815eefee25Smacallan      -Xlinker)
17825eefee25Smacallan	prev=xlinker
17835eefee25Smacallan	continue
17845eefee25Smacallan	;;
17855eefee25Smacallan
17865eefee25Smacallan      -XCClinker)
17875eefee25Smacallan	prev=xcclinker
17885eefee25Smacallan	continue
17895eefee25Smacallan	;;
17905eefee25Smacallan
17915eefee25Smacallan      # Some other compiler flag.
17925eefee25Smacallan      -* | +*)
17935eefee25Smacallan	# Unknown arguments in both finalize_command and compile_command need
17945eefee25Smacallan	# to be aesthetically quoted because they are evaled later.
17955eefee25Smacallan	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
17965eefee25Smacallan	case $arg in
17975eefee25Smacallan	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
17985eefee25Smacallan	  arg="\"$arg\""
17995eefee25Smacallan	  ;;
18005eefee25Smacallan	esac
18015eefee25Smacallan	;;
18025eefee25Smacallan
18035eefee25Smacallan      *.$objext)
18045eefee25Smacallan	# A standard object.
18055eefee25Smacallan	objs="$objs $arg"
18065eefee25Smacallan	;;
18075eefee25Smacallan
18085eefee25Smacallan      *.lo)
18095eefee25Smacallan	# A libtool-controlled object.
18105eefee25Smacallan
18115eefee25Smacallan	# Check to see that this really is a libtool object.
18125eefee25Smacallan	if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
18135eefee25Smacallan	  pic_object=
18145eefee25Smacallan	  non_pic_object=
18155eefee25Smacallan
18165eefee25Smacallan	  # Read the .lo file
18175eefee25Smacallan	  # If there is no directory component, then add one.
18185eefee25Smacallan	  case $arg in
18195eefee25Smacallan	  */* | *\\*) . $arg ;;
18205eefee25Smacallan	  *) . ./$arg ;;
18215eefee25Smacallan	  esac
18225eefee25Smacallan
18235eefee25Smacallan	  if test -z "$pic_object" || \
18245eefee25Smacallan	     test -z "$non_pic_object" ||
18255eefee25Smacallan	     test "$pic_object" = none && \
18265eefee25Smacallan	     test "$non_pic_object" = none; then
18275eefee25Smacallan	    $echo "$modename: cannot find name of object for \`$arg'" 1>&2
18285eefee25Smacallan	    exit $EXIT_FAILURE
18295eefee25Smacallan	  fi
18305eefee25Smacallan
18315eefee25Smacallan	  # Extract subdirectory from the argument.
18325eefee25Smacallan	  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
18335eefee25Smacallan	  if test "X$xdir" = "X$arg"; then
18345eefee25Smacallan	    xdir=
18355eefee25Smacallan 	  else
18365eefee25Smacallan	    xdir="$xdir/"
18375eefee25Smacallan	  fi
18385eefee25Smacallan
18395eefee25Smacallan	  if test "$pic_object" != none; then
18405eefee25Smacallan	    # Prepend the subdirectory the object is found in.
18415eefee25Smacallan	    pic_object="$xdir$pic_object"
18425eefee25Smacallan
18435eefee25Smacallan	    if test "$prev" = dlfiles; then
18445eefee25Smacallan	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
18455eefee25Smacallan		dlfiles="$dlfiles $pic_object"
18465eefee25Smacallan		prev=
18475eefee25Smacallan		continue
18485eefee25Smacallan	      else
18495eefee25Smacallan		# If libtool objects are unsupported, then we need to preload.
18505eefee25Smacallan		prev=dlprefiles
18515eefee25Smacallan	      fi
18525eefee25Smacallan	    fi
18535eefee25Smacallan
18545eefee25Smacallan	    # CHECK ME:  I think I busted this.  -Ossama
18555eefee25Smacallan	    if test "$prev" = dlprefiles; then
18565eefee25Smacallan	      # Preload the old-style object.
18575eefee25Smacallan	      dlprefiles="$dlprefiles $pic_object"
18585eefee25Smacallan	      prev=
18595eefee25Smacallan	    fi
18605eefee25Smacallan
18615eefee25Smacallan	    # A PIC object.
18625eefee25Smacallan	    libobjs="$libobjs $pic_object"
18635eefee25Smacallan	    arg="$pic_object"
18645eefee25Smacallan	  fi
18655eefee25Smacallan
18665eefee25Smacallan	  # Non-PIC object.
18675eefee25Smacallan	  if test "$non_pic_object" != none; then
18685eefee25Smacallan	    # Prepend the subdirectory the object is found in.
18695eefee25Smacallan	    non_pic_object="$xdir$non_pic_object"
18705eefee25Smacallan
18715eefee25Smacallan	    # A standard non-PIC object
18725eefee25Smacallan	    non_pic_objects="$non_pic_objects $non_pic_object"
18735eefee25Smacallan	    if test -z "$pic_object" || test "$pic_object" = none ; then
18745eefee25Smacallan	      arg="$non_pic_object"
18755eefee25Smacallan	    fi
18765eefee25Smacallan	  else
18775eefee25Smacallan	    # If the PIC object exists, use it instead.
18785eefee25Smacallan	    # $xdir was prepended to $pic_object above.
18795eefee25Smacallan	    non_pic_object="$pic_object"
18805eefee25Smacallan	    non_pic_objects="$non_pic_objects $non_pic_object"
18815eefee25Smacallan	  fi
18825eefee25Smacallan	else
18835eefee25Smacallan	  # Only an error if not doing a dry-run.
18845eefee25Smacallan	  if test -z "$run"; then
18855eefee25Smacallan	    $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
18865eefee25Smacallan	    exit $EXIT_FAILURE
18875eefee25Smacallan	  else
18885eefee25Smacallan	    # Dry-run case.
18895eefee25Smacallan
18905eefee25Smacallan	    # Extract subdirectory from the argument.
18915eefee25Smacallan	    xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
18925eefee25Smacallan	    if test "X$xdir" = "X$arg"; then
18935eefee25Smacallan	      xdir=
18945eefee25Smacallan	    else
18955eefee25Smacallan	      xdir="$xdir/"
18965eefee25Smacallan	    fi
18975eefee25Smacallan
18985eefee25Smacallan	    pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
18995eefee25Smacallan	    non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
19005eefee25Smacallan	    libobjs="$libobjs $pic_object"
19015eefee25Smacallan	    non_pic_objects="$non_pic_objects $non_pic_object"
19025eefee25Smacallan	  fi
19035eefee25Smacallan	fi
19045eefee25Smacallan	;;
19055eefee25Smacallan
19065eefee25Smacallan      *.$libext)
19075eefee25Smacallan	# An archive.
19085eefee25Smacallan	deplibs="$deplibs $arg"
19095eefee25Smacallan	old_deplibs="$old_deplibs $arg"
19105eefee25Smacallan	continue
19115eefee25Smacallan	;;
19125eefee25Smacallan
19135eefee25Smacallan      *.la)
19145eefee25Smacallan	# A libtool-controlled library.
19155eefee25Smacallan
19165eefee25Smacallan	if test "$prev" = dlfiles; then
19175eefee25Smacallan	  # This library was specified with -dlopen.
19185eefee25Smacallan	  dlfiles="$dlfiles $arg"
19195eefee25Smacallan	  prev=
19205eefee25Smacallan	elif test "$prev" = dlprefiles; then
19215eefee25Smacallan	  # The library was specified with -dlpreopen.
19225eefee25Smacallan	  dlprefiles="$dlprefiles $arg"
19235eefee25Smacallan	  prev=
19245eefee25Smacallan	else
19255eefee25Smacallan	  deplibs="$deplibs $arg"
19265eefee25Smacallan	fi
19275eefee25Smacallan	continue
19285eefee25Smacallan	;;
19295eefee25Smacallan
19305eefee25Smacallan      # Some other compiler argument.
19315eefee25Smacallan      *)
19325eefee25Smacallan	# Unknown arguments in both finalize_command and compile_command need
19335eefee25Smacallan	# to be aesthetically quoted because they are evaled later.
19345eefee25Smacallan	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
19355eefee25Smacallan	case $arg in
19365eefee25Smacallan	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
19375eefee25Smacallan	  arg="\"$arg\""
19385eefee25Smacallan	  ;;
19395eefee25Smacallan	esac
19405eefee25Smacallan	;;
19415eefee25Smacallan      esac # arg
19425eefee25Smacallan
19435eefee25Smacallan      # Now actually substitute the argument into the commands.
19445eefee25Smacallan      if test -n "$arg"; then
19455eefee25Smacallan	compile_command="$compile_command $arg"
19465eefee25Smacallan	finalize_command="$finalize_command $arg"
19475eefee25Smacallan      fi
19485eefee25Smacallan    done # argument parsing loop
19495eefee25Smacallan
19505eefee25Smacallan    if test -n "$prev"; then
19515eefee25Smacallan      $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
19525eefee25Smacallan      $echo "$help" 1>&2
19535eefee25Smacallan      exit $EXIT_FAILURE
19545eefee25Smacallan    fi
19555eefee25Smacallan
19565eefee25Smacallan    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
19575eefee25Smacallan      eval arg=\"$export_dynamic_flag_spec\"
19585eefee25Smacallan      compile_command="$compile_command $arg"
19595eefee25Smacallan      finalize_command="$finalize_command $arg"
19605eefee25Smacallan    fi
19615eefee25Smacallan
19625eefee25Smacallan    oldlibs=
19635eefee25Smacallan    # calculate the name of the file, without its directory
19645eefee25Smacallan    outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
19655eefee25Smacallan    libobjs_save="$libobjs"
19665eefee25Smacallan
19675eefee25Smacallan    if test -n "$shlibpath_var"; then
19685eefee25Smacallan      # get the directories listed in $shlibpath_var
19695eefee25Smacallan      eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
19705eefee25Smacallan    else
19715eefee25Smacallan      shlib_search_path=
19725eefee25Smacallan    fi
19735eefee25Smacallan    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
19745eefee25Smacallan    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
19755eefee25Smacallan
19765eefee25Smacallan    output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
19775eefee25Smacallan    if test "X$output_objdir" = "X$output"; then
19785eefee25Smacallan      output_objdir="$objdir"
19795eefee25Smacallan    else
19805eefee25Smacallan      output_objdir="$output_objdir/$objdir"
19815eefee25Smacallan    fi
19825eefee25Smacallan    # Create the object directory.
19835eefee25Smacallan    if test ! -d "$output_objdir"; then
19845eefee25Smacallan      $show "$mkdir $output_objdir"
19855eefee25Smacallan      $run $mkdir $output_objdir
19865eefee25Smacallan      exit_status=$?
19875eefee25Smacallan      if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then
19885eefee25Smacallan	exit $exit_status
19895eefee25Smacallan      fi
19905eefee25Smacallan    fi
19915eefee25Smacallan
19925eefee25Smacallan    # Determine the type of output
19935eefee25Smacallan    case $output in
19945eefee25Smacallan    "")
19955eefee25Smacallan      $echo "$modename: you must specify an output file" 1>&2
19965eefee25Smacallan      $echo "$help" 1>&2
19975eefee25Smacallan      exit $EXIT_FAILURE
19985eefee25Smacallan      ;;
19995eefee25Smacallan    *.$libext) linkmode=oldlib ;;
20005eefee25Smacallan    *.lo | *.$objext) linkmode=obj ;;
20015eefee25Smacallan    *.la) linkmode=lib ;;
20025eefee25Smacallan    *) linkmode=prog ;; # Anything else should be a program.
20035eefee25Smacallan    esac
20045eefee25Smacallan
20055eefee25Smacallan    case $host in
20065eefee25Smacallan    *cygwin* | *mingw* | *pw32*)
20075eefee25Smacallan      # don't eliminate duplications in $postdeps and $predeps
20085eefee25Smacallan      duplicate_compiler_generated_deps=yes
20095eefee25Smacallan      ;;
20105eefee25Smacallan    *)
20115eefee25Smacallan      duplicate_compiler_generated_deps=$duplicate_deps
20125eefee25Smacallan      ;;
20135eefee25Smacallan    esac
20145eefee25Smacallan    specialdeplibs=
20155eefee25Smacallan
20165eefee25Smacallan    libs=
20175eefee25Smacallan    # Find all interdependent deplibs by searching for libraries
20185eefee25Smacallan    # that are linked more than once (e.g. -la -lb -la)
20195eefee25Smacallan    for deplib in $deplibs; do
20205eefee25Smacallan      if test "X$duplicate_deps" = "Xyes" ; then
20215eefee25Smacallan	case "$libs " in
20225eefee25Smacallan	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
20235eefee25Smacallan	esac
20245eefee25Smacallan      fi
20255eefee25Smacallan      libs="$libs $deplib"
20265eefee25Smacallan    done
20275eefee25Smacallan
20285eefee25Smacallan    if test "$linkmode" = lib; then
20295eefee25Smacallan      libs="$predeps $libs $compiler_lib_search_path $postdeps"
20305eefee25Smacallan
20315eefee25Smacallan      # Compute libraries that are listed more than once in $predeps
20325eefee25Smacallan      # $postdeps and mark them as special (i.e., whose duplicates are
20335eefee25Smacallan      # not to be eliminated).
20345eefee25Smacallan      pre_post_deps=
20355eefee25Smacallan      if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then
20365eefee25Smacallan	for pre_post_dep in $predeps $postdeps; do
20375eefee25Smacallan	  case "$pre_post_deps " in
20385eefee25Smacallan	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
20395eefee25Smacallan	  esac
20405eefee25Smacallan	  pre_post_deps="$pre_post_deps $pre_post_dep"
20415eefee25Smacallan	done
20425eefee25Smacallan      fi
20435eefee25Smacallan      pre_post_deps=
20445eefee25Smacallan    fi
20455eefee25Smacallan
20465eefee25Smacallan    deplibs=
20475eefee25Smacallan    newdependency_libs=
20485eefee25Smacallan    newlib_search_path=
20495eefee25Smacallan    need_relink=no # whether we're linking any uninstalled libtool libraries
20505eefee25Smacallan    notinst_deplibs= # not-installed libtool libraries
20515eefee25Smacallan    case $linkmode in
20525eefee25Smacallan    lib)
20535eefee25Smacallan	passes="conv link"
20545eefee25Smacallan	for file in $dlfiles $dlprefiles; do
20555eefee25Smacallan	  case $file in
20565eefee25Smacallan	  *.la) ;;
20575eefee25Smacallan	  *)
20585eefee25Smacallan	    $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2
20595eefee25Smacallan	    exit $EXIT_FAILURE
20605eefee25Smacallan	    ;;
20615eefee25Smacallan	  esac
20625eefee25Smacallan	done
20635eefee25Smacallan	;;
20645eefee25Smacallan    prog)
20655eefee25Smacallan	compile_deplibs=
20665eefee25Smacallan	finalize_deplibs=
20675eefee25Smacallan	alldeplibs=no
20685eefee25Smacallan	newdlfiles=
20695eefee25Smacallan	newdlprefiles=
20705eefee25Smacallan	passes="conv scan dlopen dlpreopen link"
20715eefee25Smacallan	;;
20725eefee25Smacallan    *)  passes="conv"
20735eefee25Smacallan	;;
20745eefee25Smacallan    esac
20755eefee25Smacallan    for pass in $passes; do
20765eefee25Smacallan      if test "$linkmode,$pass" = "lib,link" ||
20775eefee25Smacallan	 test "$linkmode,$pass" = "prog,scan"; then
20785eefee25Smacallan	libs="$deplibs"
20795eefee25Smacallan	deplibs=
20805eefee25Smacallan      fi
20815eefee25Smacallan      if test "$linkmode" = prog; then
20825eefee25Smacallan	case $pass in
20835eefee25Smacallan	dlopen) libs="$dlfiles" ;;
20845eefee25Smacallan	dlpreopen) libs="$dlprefiles" ;;
20855eefee25Smacallan	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
20865eefee25Smacallan	esac
20875eefee25Smacallan      fi
20885eefee25Smacallan      if test "$pass" = dlopen; then
20895eefee25Smacallan	# Collect dlpreopened libraries
20905eefee25Smacallan	save_deplibs="$deplibs"
20915eefee25Smacallan	deplibs=
20925eefee25Smacallan      fi
20935eefee25Smacallan      for deplib in $libs; do
20945eefee25Smacallan	lib=
20955eefee25Smacallan	found=no
20965eefee25Smacallan	case $deplib in
20975eefee25Smacallan	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
20985eefee25Smacallan	  if test "$linkmode,$pass" = "prog,link"; then
20995eefee25Smacallan	    compile_deplibs="$deplib $compile_deplibs"
21005eefee25Smacallan	    finalize_deplibs="$deplib $finalize_deplibs"
21015eefee25Smacallan	  else
21025eefee25Smacallan	    compiler_flags="$compiler_flags $deplib"
21035eefee25Smacallan	  fi
21045eefee25Smacallan	  continue
21055eefee25Smacallan	  ;;
21065eefee25Smacallan	-l*)
21075eefee25Smacallan	  if test "$linkmode" != lib && test "$linkmode" != prog; then
21085eefee25Smacallan	    $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2
21095eefee25Smacallan	    continue
21105eefee25Smacallan	  fi
21115eefee25Smacallan	  name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
21125eefee25Smacallan	  for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do
21135eefee25Smacallan	    for search_ext in .la $std_shrext .so .a; do
21145eefee25Smacallan	      # Search the libtool library
21155eefee25Smacallan	      lib="$searchdir/lib${name}${search_ext}"
21165eefee25Smacallan	      if test -f "$lib"; then
21175eefee25Smacallan		if test "$search_ext" = ".la"; then
21185eefee25Smacallan		  found=yes
21195eefee25Smacallan		else
21205eefee25Smacallan		  found=no
21215eefee25Smacallan		fi
21225eefee25Smacallan		break 2
21235eefee25Smacallan	      fi
21245eefee25Smacallan	    done
21255eefee25Smacallan	  done
21265eefee25Smacallan	  if test "$found" != yes; then
21275eefee25Smacallan	    # deplib doesn't seem to be a libtool library
21285eefee25Smacallan	    if test "$linkmode,$pass" = "prog,link"; then
21295eefee25Smacallan	      compile_deplibs="$deplib $compile_deplibs"
21305eefee25Smacallan	      finalize_deplibs="$deplib $finalize_deplibs"
21315eefee25Smacallan	    else
21325eefee25Smacallan	      deplibs="$deplib $deplibs"
21335eefee25Smacallan	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
21345eefee25Smacallan	    fi
21355eefee25Smacallan	    continue
21365eefee25Smacallan	  else # deplib is a libtool library
21375eefee25Smacallan	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
21385eefee25Smacallan	    # We need to do some special things here, and not later.
21395eefee25Smacallan	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
21405eefee25Smacallan	      case " $predeps $postdeps " in
21415eefee25Smacallan	      *" $deplib "*)
21425eefee25Smacallan		if (${SED} -e '2q' $lib |
21435eefee25Smacallan                    grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
21445eefee25Smacallan		  library_names=
21455eefee25Smacallan		  old_library=
21465eefee25Smacallan		  case $lib in
21475eefee25Smacallan		  */* | *\\*) . $lib ;;
21485eefee25Smacallan		  *) . ./$lib ;;
21495eefee25Smacallan		  esac
21505eefee25Smacallan		  for l in $old_library $library_names; do
21515eefee25Smacallan		    ll="$l"
21525eefee25Smacallan		  done
21535eefee25Smacallan		  if test "X$ll" = "X$old_library" ; then # only static version available
21545eefee25Smacallan		    found=no
21555eefee25Smacallan		    ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
21565eefee25Smacallan		    test "X$ladir" = "X$lib" && ladir="."
21575eefee25Smacallan		    lib=$ladir/$old_library
21585eefee25Smacallan		    if test "$linkmode,$pass" = "prog,link"; then
21595eefee25Smacallan		      compile_deplibs="$deplib $compile_deplibs"
21605eefee25Smacallan		      finalize_deplibs="$deplib $finalize_deplibs"
21615eefee25Smacallan		    else
21625eefee25Smacallan		      deplibs="$deplib $deplibs"
21635eefee25Smacallan		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
21645eefee25Smacallan		    fi
21655eefee25Smacallan		    continue
21665eefee25Smacallan		  fi
21675eefee25Smacallan		fi
21685eefee25Smacallan	        ;;
21695eefee25Smacallan	      *) ;;
21705eefee25Smacallan	      esac
21715eefee25Smacallan	    fi
21725eefee25Smacallan	  fi
21735eefee25Smacallan	  ;; # -l
21745eefee25Smacallan	-L*)
21755eefee25Smacallan	  case $linkmode in
21765eefee25Smacallan	  lib)
21775eefee25Smacallan	    deplibs="$deplib $deplibs"
21785eefee25Smacallan	    test "$pass" = conv && continue
21795eefee25Smacallan	    newdependency_libs="$deplib $newdependency_libs"
21805eefee25Smacallan	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
21815eefee25Smacallan	    ;;
21825eefee25Smacallan	  prog)
21835eefee25Smacallan	    if test "$pass" = conv; then
21845eefee25Smacallan	      deplibs="$deplib $deplibs"
21855eefee25Smacallan	      continue
21865eefee25Smacallan	    fi
21875eefee25Smacallan	    if test "$pass" = scan; then
21885eefee25Smacallan	      deplibs="$deplib $deplibs"
21895eefee25Smacallan	    else
21905eefee25Smacallan	      compile_deplibs="$deplib $compile_deplibs"
21915eefee25Smacallan	      finalize_deplibs="$deplib $finalize_deplibs"
21925eefee25Smacallan	    fi
21935eefee25Smacallan	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
21945eefee25Smacallan	    ;;
21955eefee25Smacallan	  *)
21965eefee25Smacallan	    $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2
21975eefee25Smacallan	    ;;
21985eefee25Smacallan	  esac # linkmode
21995eefee25Smacallan	  continue
22005eefee25Smacallan	  ;; # -L
22015eefee25Smacallan	-R*)
22025eefee25Smacallan	  if test "$pass" = link; then
22035eefee25Smacallan	    dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
22045eefee25Smacallan	    # Make sure the xrpath contains only unique directories.
22055eefee25Smacallan	    case "$xrpath " in
22065eefee25Smacallan	    *" $dir "*) ;;
22075eefee25Smacallan	    *) xrpath="$xrpath $dir" ;;
22085eefee25Smacallan	    esac
22095eefee25Smacallan	  fi
22105eefee25Smacallan	  deplibs="$deplib $deplibs"
22115eefee25Smacallan	  continue
22125eefee25Smacallan	  ;;
22135eefee25Smacallan	*.la) lib="$deplib" ;;
22145eefee25Smacallan	*.$libext)
22155eefee25Smacallan	  if test "$pass" = conv; then
22165eefee25Smacallan	    deplibs="$deplib $deplibs"
22175eefee25Smacallan	    continue
22185eefee25Smacallan	  fi
22195eefee25Smacallan	  case $linkmode in
22205eefee25Smacallan	  lib)
22215eefee25Smacallan	    valid_a_lib=no
22225eefee25Smacallan	    case $deplibs_check_method in
22235eefee25Smacallan	      match_pattern*)
22245eefee25Smacallan		set dummy $deplibs_check_method
22255eefee25Smacallan	        match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
22265eefee25Smacallan		if eval $echo \"$deplib\" 2>/dev/null \
22275eefee25Smacallan		    | $SED 10q \
22285eefee25Smacallan		    | $EGREP "$match_pattern_regex" > /dev/null; then
22295eefee25Smacallan		  valid_a_lib=yes
22305eefee25Smacallan		fi
22315eefee25Smacallan		;;
22325eefee25Smacallan	      pass_all)
22335eefee25Smacallan		valid_a_lib=yes
22345eefee25Smacallan		;;
22355eefee25Smacallan            esac
22365eefee25Smacallan	    if test "$valid_a_lib" != yes; then
22375eefee25Smacallan	      $echo
22385eefee25Smacallan	      $echo "*** Warning: Trying to link with static lib archive $deplib."
22395eefee25Smacallan	      $echo "*** I have the capability to make that library automatically link in when"
22405eefee25Smacallan	      $echo "*** you link to this library.  But I can only do this if you have a"
22415eefee25Smacallan	      $echo "*** shared version of the library, which you do not appear to have"
22425eefee25Smacallan	      $echo "*** because the file extensions .$libext of this argument makes me believe"
22435eefee25Smacallan	      $echo "*** that it is just a static archive that I should not used here."
22445eefee25Smacallan	    else
22455eefee25Smacallan	      $echo
22465eefee25Smacallan	      $echo "*** Warning: Linking the shared library $output against the"
22475eefee25Smacallan	      $echo "*** static library $deplib is not portable!"
22485eefee25Smacallan	      deplibs="$deplib $deplibs"
22495eefee25Smacallan	    fi
22505eefee25Smacallan	    continue
22515eefee25Smacallan	    ;;
22525eefee25Smacallan	  prog)
22535eefee25Smacallan	    if test "$pass" != link; then
22545eefee25Smacallan	      deplibs="$deplib $deplibs"
22555eefee25Smacallan	    else
22565eefee25Smacallan	      compile_deplibs="$deplib $compile_deplibs"
22575eefee25Smacallan	      finalize_deplibs="$deplib $finalize_deplibs"
22585eefee25Smacallan	    fi
22595eefee25Smacallan	    continue
22605eefee25Smacallan	    ;;
22615eefee25Smacallan	  esac # linkmode
22625eefee25Smacallan	  ;; # *.$libext
22635eefee25Smacallan	*.lo | *.$objext)
22645eefee25Smacallan	  if test "$pass" = conv; then
22655eefee25Smacallan	    deplibs="$deplib $deplibs"
22665eefee25Smacallan	  elif test "$linkmode" = prog; then
22675eefee25Smacallan	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
22685eefee25Smacallan	      # If there is no dlopen support or we're linking statically,
22695eefee25Smacallan	      # we need to preload.
22705eefee25Smacallan	      newdlprefiles="$newdlprefiles $deplib"
22715eefee25Smacallan	      compile_deplibs="$deplib $compile_deplibs"
22725eefee25Smacallan	      finalize_deplibs="$deplib $finalize_deplibs"
22735eefee25Smacallan	    else
22745eefee25Smacallan	      newdlfiles="$newdlfiles $deplib"
22755eefee25Smacallan	    fi
22765eefee25Smacallan	  fi
22775eefee25Smacallan	  continue
22785eefee25Smacallan	  ;;
22795eefee25Smacallan	%DEPLIBS%)
22805eefee25Smacallan	  alldeplibs=yes
22815eefee25Smacallan	  continue
22825eefee25Smacallan	  ;;
22835eefee25Smacallan	esac # case $deplib
22845eefee25Smacallan	if test "$found" = yes || test -f "$lib"; then :
22855eefee25Smacallan	else
22865eefee25Smacallan	  $echo "$modename: cannot find the library \`$lib' or unhandled argument \`$deplib'" 1>&2
22875eefee25Smacallan	  exit $EXIT_FAILURE
22885eefee25Smacallan	fi
22895eefee25Smacallan
22905eefee25Smacallan	# Check to see that this really is a libtool archive.
22915eefee25Smacallan	if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
22925eefee25Smacallan	else
22935eefee25Smacallan	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
22945eefee25Smacallan	  exit $EXIT_FAILURE
22955eefee25Smacallan	fi
22965eefee25Smacallan
22975eefee25Smacallan	ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
22985eefee25Smacallan	test "X$ladir" = "X$lib" && ladir="."
22995eefee25Smacallan
23005eefee25Smacallan	dlname=
23015eefee25Smacallan	dlopen=
23025eefee25Smacallan	dlpreopen=
23035eefee25Smacallan	libdir=
23045eefee25Smacallan	library_names=
23055eefee25Smacallan	old_library=
23065eefee25Smacallan	# If the library was installed with an old release of libtool,
23075eefee25Smacallan	# it will not redefine variables installed, or shouldnotlink
23085eefee25Smacallan	installed=yes
23095eefee25Smacallan	shouldnotlink=no
23105eefee25Smacallan	avoidtemprpath=
23115eefee25Smacallan
23125eefee25Smacallan
23135eefee25Smacallan	# Read the .la file
23145eefee25Smacallan	case $lib in
23155eefee25Smacallan	*/* | *\\*) . $lib ;;
23165eefee25Smacallan	*) . ./$lib ;;
23175eefee25Smacallan	esac
23185eefee25Smacallan
23195eefee25Smacallan	if test "$linkmode,$pass" = "lib,link" ||
23205eefee25Smacallan	   test "$linkmode,$pass" = "prog,scan" ||
23215eefee25Smacallan	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
23225eefee25Smacallan	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
23235eefee25Smacallan	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
23245eefee25Smacallan	fi
23255eefee25Smacallan
23265eefee25Smacallan	if test "$pass" = conv; then
23275eefee25Smacallan	  # Only check for convenience libraries
23285eefee25Smacallan	  deplibs="$lib $deplibs"
23295eefee25Smacallan	  if test -z "$libdir"; then
23305eefee25Smacallan	    if test -z "$old_library"; then
23315eefee25Smacallan	      $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
23325eefee25Smacallan	      exit $EXIT_FAILURE
23335eefee25Smacallan	    fi
23345eefee25Smacallan	    # It is a libtool convenience library, so add in its objects.
23355eefee25Smacallan	    convenience="$convenience $ladir/$objdir/$old_library"
23365eefee25Smacallan	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
23375eefee25Smacallan	    tmp_libs=
23385eefee25Smacallan	    for deplib in $dependency_libs; do
23395eefee25Smacallan	      deplibs="$deplib $deplibs"
23405eefee25Smacallan              if test "X$duplicate_deps" = "Xyes" ; then
23415eefee25Smacallan	        case "$tmp_libs " in
23425eefee25Smacallan	        *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
23435eefee25Smacallan	        esac
23445eefee25Smacallan              fi
23455eefee25Smacallan	      tmp_libs="$tmp_libs $deplib"
23465eefee25Smacallan	    done
23475eefee25Smacallan	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
23485eefee25Smacallan	    $echo "$modename: \`$lib' is not a convenience library" 1>&2
23495eefee25Smacallan	    exit $EXIT_FAILURE
23505eefee25Smacallan	  fi
23515eefee25Smacallan	  continue
23525eefee25Smacallan	fi # $pass = conv
23535eefee25Smacallan
23545eefee25Smacallan
23555eefee25Smacallan	# Get the name of the library we link against.
23565eefee25Smacallan	linklib=
23575eefee25Smacallan	for l in $old_library $library_names; do
23585eefee25Smacallan	  linklib="$l"
23595eefee25Smacallan	done
23605eefee25Smacallan	if test -z "$linklib"; then
23615eefee25Smacallan	  $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
23625eefee25Smacallan	  exit $EXIT_FAILURE
23635eefee25Smacallan	fi
23645eefee25Smacallan
23655eefee25Smacallan	# This library was specified with -dlopen.
23665eefee25Smacallan	if test "$pass" = dlopen; then
23675eefee25Smacallan	  if test -z "$libdir"; then
23685eefee25Smacallan	    $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2
23695eefee25Smacallan	    exit $EXIT_FAILURE
23705eefee25Smacallan	  fi
23715eefee25Smacallan	  if test -z "$dlname" ||
23725eefee25Smacallan	     test "$dlopen_support" != yes ||
23735eefee25Smacallan	     test "$build_libtool_libs" = no; then
23745eefee25Smacallan	    # If there is no dlname, no dlopen support or we're linking
23755eefee25Smacallan	    # statically, we need to preload.  We also need to preload any
23765eefee25Smacallan	    # dependent libraries so libltdl's deplib preloader doesn't
23775eefee25Smacallan	    # bomb out in the load deplibs phase.
23785eefee25Smacallan	    dlprefiles="$dlprefiles $lib $dependency_libs"
23795eefee25Smacallan	  else
23805eefee25Smacallan	    newdlfiles="$newdlfiles $lib"
23815eefee25Smacallan	  fi
23825eefee25Smacallan	  continue
23835eefee25Smacallan	fi # $pass = dlopen
23845eefee25Smacallan
23855eefee25Smacallan	# We need an absolute path.
23865eefee25Smacallan	case $ladir in
23875eefee25Smacallan	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
23885eefee25Smacallan	*)
23895eefee25Smacallan	  abs_ladir=`cd "$ladir" && pwd`
23905eefee25Smacallan	  if test -z "$abs_ladir"; then
23915eefee25Smacallan	    $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2
23925eefee25Smacallan	    $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
23935eefee25Smacallan	    abs_ladir="$ladir"
23945eefee25Smacallan	  fi
23955eefee25Smacallan	  ;;
23965eefee25Smacallan	esac
23975eefee25Smacallan	laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
23985eefee25Smacallan
23995eefee25Smacallan	# Find the relevant object directory and library name.
24005eefee25Smacallan	if test "X$installed" = Xyes; then
24015eefee25Smacallan	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
24025eefee25Smacallan	    $echo "$modename: warning: library \`$lib' was moved." 1>&2
24035eefee25Smacallan	    dir="$ladir"
24045eefee25Smacallan	    absdir="$abs_ladir"
24055eefee25Smacallan	    libdir="$abs_ladir"
24065eefee25Smacallan	  else
24075eefee25Smacallan	    dir="$libdir"
24085eefee25Smacallan	    absdir="$libdir"
24095eefee25Smacallan	  fi
24105eefee25Smacallan	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
24115eefee25Smacallan	else
24125eefee25Smacallan	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
24135eefee25Smacallan	    dir="$ladir"
24145eefee25Smacallan	    absdir="$abs_ladir"
24155eefee25Smacallan	    # Remove this search path later
24165eefee25Smacallan	    notinst_path="$notinst_path $abs_ladir"
24175eefee25Smacallan	  else
24185eefee25Smacallan	    dir="$ladir/$objdir"
24195eefee25Smacallan	    absdir="$abs_ladir/$objdir"
24205eefee25Smacallan	    # Remove this search path later
24215eefee25Smacallan	    notinst_path="$notinst_path $abs_ladir"
24225eefee25Smacallan	  fi
24235eefee25Smacallan	fi # $installed = yes
24245eefee25Smacallan	name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
24255eefee25Smacallan
24265eefee25Smacallan	# This library was specified with -dlpreopen.
24275eefee25Smacallan	if test "$pass" = dlpreopen; then
24285eefee25Smacallan	  if test -z "$libdir"; then
24295eefee25Smacallan	    $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2
24305eefee25Smacallan	    exit $EXIT_FAILURE
24315eefee25Smacallan	  fi
24325eefee25Smacallan	  # Prefer using a static library (so that no silly _DYNAMIC symbols
24335eefee25Smacallan	  # are required to link).
24345eefee25Smacallan	  if test -n "$old_library"; then
24355eefee25Smacallan	    newdlprefiles="$newdlprefiles $dir/$old_library"
24365eefee25Smacallan	  # Otherwise, use the dlname, so that lt_dlopen finds it.
24375eefee25Smacallan	  elif test -n "$dlname"; then
24385eefee25Smacallan	    newdlprefiles="$newdlprefiles $dir/$dlname"
24395eefee25Smacallan	  else
24405eefee25Smacallan	    newdlprefiles="$newdlprefiles $dir/$linklib"
24415eefee25Smacallan	  fi
24425eefee25Smacallan	fi # $pass = dlpreopen
24435eefee25Smacallan
24445eefee25Smacallan	if test -z "$libdir"; then
24455eefee25Smacallan	  # Link the convenience library
24465eefee25Smacallan	  if test "$linkmode" = lib; then
24475eefee25Smacallan	    deplibs="$dir/$old_library $deplibs"
24485eefee25Smacallan	  elif test "$linkmode,$pass" = "prog,link"; then
24495eefee25Smacallan	    compile_deplibs="$dir/$old_library $compile_deplibs"
24505eefee25Smacallan	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
24515eefee25Smacallan	  else
24525eefee25Smacallan	    deplibs="$lib $deplibs" # used for prog,scan pass
24535eefee25Smacallan	  fi
24545eefee25Smacallan	  continue
24555eefee25Smacallan	fi
24565eefee25Smacallan
24575eefee25Smacallan
24585eefee25Smacallan	if test "$linkmode" = prog && test "$pass" != link; then
24595eefee25Smacallan	  newlib_search_path="$newlib_search_path $ladir"
24605eefee25Smacallan	  deplibs="$lib $deplibs"
24615eefee25Smacallan
24625eefee25Smacallan	  linkalldeplibs=no
24635eefee25Smacallan	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
24645eefee25Smacallan	     test "$build_libtool_libs" = no; then
24655eefee25Smacallan	    linkalldeplibs=yes
24665eefee25Smacallan	  fi
24675eefee25Smacallan
24685eefee25Smacallan	  tmp_libs=
24695eefee25Smacallan	  for deplib in $dependency_libs; do
24705eefee25Smacallan	    case $deplib in
24715eefee25Smacallan	    -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test
24725eefee25Smacallan	    esac
24735eefee25Smacallan	    # Need to link against all dependency_libs?
24745eefee25Smacallan	    if test "$linkalldeplibs" = yes; then
24755eefee25Smacallan	      deplibs="$deplib $deplibs"
24765eefee25Smacallan	    else
24775eefee25Smacallan	      # Need to hardcode shared library paths
24785eefee25Smacallan	      # or/and link against static libraries
24795eefee25Smacallan	      newdependency_libs="$deplib $newdependency_libs"
24805eefee25Smacallan	    fi
24815eefee25Smacallan	    if test "X$duplicate_deps" = "Xyes" ; then
24825eefee25Smacallan	      case "$tmp_libs " in
24835eefee25Smacallan	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
24845eefee25Smacallan	      esac
24855eefee25Smacallan	    fi
24865eefee25Smacallan	    tmp_libs="$tmp_libs $deplib"
24875eefee25Smacallan	  done # for deplib
24885eefee25Smacallan	  continue
24895eefee25Smacallan	fi # $linkmode = prog...
24905eefee25Smacallan
24915eefee25Smacallan	if test "$linkmode,$pass" = "prog,link"; then
24925eefee25Smacallan	  if test -n "$library_names" &&
24935eefee25Smacallan	     { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
24945eefee25Smacallan	    # We need to hardcode the library path
24955eefee25Smacallan	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
24965eefee25Smacallan	      # Make sure the rpath contains only unique directories.
24975eefee25Smacallan	      case "$temp_rpath " in
24985eefee25Smacallan	      *" $dir "*) ;;
24995eefee25Smacallan	      *" $absdir "*) ;;
25005eefee25Smacallan	      *) temp_rpath="$temp_rpath $absdir" ;;
25015eefee25Smacallan	      esac
25025eefee25Smacallan	    fi
25035eefee25Smacallan
25045eefee25Smacallan	    # Hardcode the library path.
25055eefee25Smacallan	    # Skip directories that are in the system default run-time
25065eefee25Smacallan	    # search path.
25075eefee25Smacallan	    case " $sys_lib_dlsearch_path " in
25085eefee25Smacallan	    *" $absdir "*) ;;
25095eefee25Smacallan	    *)
25105eefee25Smacallan	      case "$compile_rpath " in
25115eefee25Smacallan	      *" $absdir "*) ;;
25125eefee25Smacallan	      *) compile_rpath="$compile_rpath $absdir"
25135eefee25Smacallan	      esac
25145eefee25Smacallan	      ;;
25155eefee25Smacallan	    esac
25165eefee25Smacallan	    case " $sys_lib_dlsearch_path " in
25175eefee25Smacallan	    *" $libdir "*) ;;
25185eefee25Smacallan	    *)
25195eefee25Smacallan	      case "$finalize_rpath " in
25205eefee25Smacallan	      *" $libdir "*) ;;
25215eefee25Smacallan	      *) finalize_rpath="$finalize_rpath $libdir"
25225eefee25Smacallan	      esac
25235eefee25Smacallan	      ;;
25245eefee25Smacallan	    esac
25255eefee25Smacallan	  fi # $linkmode,$pass = prog,link...
25265eefee25Smacallan
25275eefee25Smacallan	  if test "$alldeplibs" = yes &&
25285eefee25Smacallan	     { test "$deplibs_check_method" = pass_all ||
25295eefee25Smacallan	       { test "$build_libtool_libs" = yes &&
25305eefee25Smacallan		 test -n "$library_names"; }; }; then
25315eefee25Smacallan	    # We only need to search for static libraries
25325eefee25Smacallan	    continue
25335eefee25Smacallan	  fi
25345eefee25Smacallan	fi
25355eefee25Smacallan
25365eefee25Smacallan	link_static=no # Whether the deplib will be linked statically
25375eefee25Smacallan	use_static_libs=$prefer_static_libs
25385eefee25Smacallan	if test "$use_static_libs" = built && test "$installed" = yes ; then
25395eefee25Smacallan	  use_static_libs=no
25405eefee25Smacallan	fi
25415eefee25Smacallan	if test -n "$library_names" &&
25425eefee25Smacallan	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
25435eefee25Smacallan	  if test "$installed" = no; then
25445eefee25Smacallan	    notinst_deplibs="$notinst_deplibs $lib"
25455eefee25Smacallan	    need_relink=yes
25465eefee25Smacallan	  fi
25475eefee25Smacallan	  # This is a shared library
25485eefee25Smacallan
25495eefee25Smacallan	  # Warn about portability, can't link against -module's on
25505eefee25Smacallan	  # some systems (darwin)
25515eefee25Smacallan	  if test "$shouldnotlink" = yes && test "$pass" = link ; then
25525eefee25Smacallan	    $echo
25535eefee25Smacallan	    if test "$linkmode" = prog; then
25545eefee25Smacallan	      $echo "*** Warning: Linking the executable $output against the loadable module"
25555eefee25Smacallan	    else
25565eefee25Smacallan	      $echo "*** Warning: Linking the shared library $output against the loadable module"
25575eefee25Smacallan	    fi
25585eefee25Smacallan	    $echo "*** $linklib is not portable!"
25595eefee25Smacallan	  fi
25605eefee25Smacallan	  if test "$linkmode" = lib &&
25615eefee25Smacallan	     test "$hardcode_into_libs" = yes; then
25625eefee25Smacallan	    # Hardcode the library path.
25635eefee25Smacallan	    # Skip directories that are in the system default run-time
25645eefee25Smacallan	    # search path.
25655eefee25Smacallan	    case " $sys_lib_dlsearch_path " in
25665eefee25Smacallan	    *" $absdir "*) ;;
25675eefee25Smacallan	    *)
25685eefee25Smacallan	      case "$compile_rpath " in
25695eefee25Smacallan	      *" $absdir "*) ;;
25705eefee25Smacallan	      *) compile_rpath="$compile_rpath $absdir"
25715eefee25Smacallan	      esac
25725eefee25Smacallan	      ;;
25735eefee25Smacallan	    esac
25745eefee25Smacallan	    case " $sys_lib_dlsearch_path " in
25755eefee25Smacallan	    *" $libdir "*) ;;
25765eefee25Smacallan	    *)
25775eefee25Smacallan	      case "$finalize_rpath " in
25785eefee25Smacallan	      *" $libdir "*) ;;
25795eefee25Smacallan	      *) finalize_rpath="$finalize_rpath $libdir"
25805eefee25Smacallan	      esac
25815eefee25Smacallan	      ;;
25825eefee25Smacallan	    esac
25835eefee25Smacallan	  fi
25845eefee25Smacallan
25855eefee25Smacallan	  if test -n "$old_archive_from_expsyms_cmds"; then
25865eefee25Smacallan	    # figure out the soname
25875eefee25Smacallan	    set dummy $library_names
25885eefee25Smacallan	    realname="$2"
25895eefee25Smacallan	    shift; shift
25905eefee25Smacallan	    libname=`eval \\$echo \"$libname_spec\"`
25915eefee25Smacallan	    # use dlname if we got it. it's perfectly good, no?
25925eefee25Smacallan	    if test -n "$dlname"; then
25935eefee25Smacallan	      soname="$dlname"
25945eefee25Smacallan	    elif test -n "$soname_spec"; then
25955eefee25Smacallan	      # bleh windows
25965eefee25Smacallan	      case $host in
25975eefee25Smacallan	      *cygwin* | mingw*)
25985eefee25Smacallan		major=`expr $current - $age`
25995eefee25Smacallan		versuffix="-$major"
26005eefee25Smacallan		;;
26015eefee25Smacallan	      esac
26025eefee25Smacallan	      eval soname=\"$soname_spec\"
26035eefee25Smacallan	    else
26045eefee25Smacallan	      soname="$realname"
26055eefee25Smacallan	    fi
26065eefee25Smacallan
26075eefee25Smacallan	    # Make a new name for the extract_expsyms_cmds to use
26085eefee25Smacallan	    soroot="$soname"
26095eefee25Smacallan	    soname=`$echo $soroot | ${SED} -e 's/^.*\///'`
26105eefee25Smacallan	    newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a"
26115eefee25Smacallan
26125eefee25Smacallan	    # If the library has no export list, then create one now
26135eefee25Smacallan	    if test -f "$output_objdir/$soname-def"; then :
26145eefee25Smacallan	    else
26155eefee25Smacallan	      $show "extracting exported symbol list from \`$soname'"
26165eefee25Smacallan	      save_ifs="$IFS"; IFS='~'
26175eefee25Smacallan	      cmds=$extract_expsyms_cmds
26185eefee25Smacallan	      for cmd in $cmds; do
26195eefee25Smacallan		IFS="$save_ifs"
26205eefee25Smacallan		eval cmd=\"$cmd\"
26215eefee25Smacallan		$show "$cmd"
26225eefee25Smacallan		$run eval "$cmd" || exit $?
26235eefee25Smacallan	      done
26245eefee25Smacallan	      IFS="$save_ifs"
26255eefee25Smacallan	    fi
26265eefee25Smacallan
26275eefee25Smacallan	    # Create $newlib
26285eefee25Smacallan	    if test -f "$output_objdir/$newlib"; then :; else
26295eefee25Smacallan	      $show "generating import library for \`$soname'"
26305eefee25Smacallan	      save_ifs="$IFS"; IFS='~'
26315eefee25Smacallan	      cmds=$old_archive_from_expsyms_cmds
26325eefee25Smacallan	      for cmd in $cmds; do
26335eefee25Smacallan		IFS="$save_ifs"
26345eefee25Smacallan		eval cmd=\"$cmd\"
26355eefee25Smacallan		$show "$cmd"
26365eefee25Smacallan		$run eval "$cmd" || exit $?
26375eefee25Smacallan	      done
26385eefee25Smacallan	      IFS="$save_ifs"
26395eefee25Smacallan	    fi
26405eefee25Smacallan	    # make sure the library variables are pointing to the new library
26415eefee25Smacallan	    dir=$output_objdir
26425eefee25Smacallan	    linklib=$newlib
26435eefee25Smacallan	  fi # test -n "$old_archive_from_expsyms_cmds"
26445eefee25Smacallan
26455eefee25Smacallan	  if test "$linkmode" = prog || test "$mode" != relink; then
26465eefee25Smacallan	    add_shlibpath=
26475eefee25Smacallan	    add_dir=
26485eefee25Smacallan	    add=
26495eefee25Smacallan	    lib_linked=yes
26505eefee25Smacallan	    case $hardcode_action in
26515eefee25Smacallan	    immediate | unsupported)
26525eefee25Smacallan	      if test "$hardcode_direct" = no; then
26535eefee25Smacallan		add="$dir/$linklib"
26545eefee25Smacallan		case $host in
26555eefee25Smacallan		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
26565eefee25Smacallan		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
26575eefee25Smacallan		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
26585eefee25Smacallan		    *-*-unixware7*) add_dir="-L$dir" ;;
26595eefee25Smacallan		  *-*-darwin* )
26605eefee25Smacallan		    # if the lib is a module then we can not link against
26615eefee25Smacallan		    # it, someone is ignoring the new warnings I added
26625eefee25Smacallan		    if /usr/bin/file -L $add 2> /dev/null |
26635eefee25Smacallan                      $EGREP ": [^:]* bundle" >/dev/null ; then
26645eefee25Smacallan		      $echo "** Warning, lib $linklib is a module, not a shared library"
26655eefee25Smacallan		      if test -z "$old_library" ; then
26665eefee25Smacallan		        $echo
26675eefee25Smacallan		        $echo "** And there doesn't seem to be a static archive available"
26685eefee25Smacallan		        $echo "** The link will probably fail, sorry"
26695eefee25Smacallan		      else
26705eefee25Smacallan		        add="$dir/$old_library"
26715eefee25Smacallan		      fi
26725eefee25Smacallan		    fi
26735eefee25Smacallan		esac
26745eefee25Smacallan	      elif test "$hardcode_minus_L" = no; then
26755eefee25Smacallan		case $host in
26765eefee25Smacallan		*-*-sunos*) add_shlibpath="$dir" ;;
26775eefee25Smacallan		esac
26785eefee25Smacallan		add_dir="-L$dir"
26795eefee25Smacallan		add="-l$name"
26805eefee25Smacallan	      elif test "$hardcode_shlibpath_var" = no; then
26815eefee25Smacallan		add_shlibpath="$dir"
26825eefee25Smacallan		add="-l$name"
26835eefee25Smacallan	      else
26845eefee25Smacallan		lib_linked=no
26855eefee25Smacallan	      fi
26865eefee25Smacallan	      ;;
26875eefee25Smacallan	    relink)
26885eefee25Smacallan	      if test "$hardcode_direct" = yes; then
26895eefee25Smacallan		add="$dir/$linklib"
26905eefee25Smacallan	      elif test "$hardcode_minus_L" = yes; then
26915eefee25Smacallan		add_dir="-L$dir"
26925eefee25Smacallan		# Try looking first in the location we're being installed to.
26935eefee25Smacallan		if test -n "$inst_prefix_dir"; then
26945eefee25Smacallan		  case $libdir in
26955eefee25Smacallan		    [\\/]*)
26965eefee25Smacallan		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
26975eefee25Smacallan		      ;;
26985eefee25Smacallan		  esac
26995eefee25Smacallan		fi
27005eefee25Smacallan		add="-l$name"
27015eefee25Smacallan	      elif test "$hardcode_shlibpath_var" = yes; then
27025eefee25Smacallan		add_shlibpath="$dir"
27035eefee25Smacallan		add="-l$name"
27045eefee25Smacallan	      else
27055eefee25Smacallan		lib_linked=no
27065eefee25Smacallan	      fi
27075eefee25Smacallan	      ;;
27085eefee25Smacallan	    *) lib_linked=no ;;
27095eefee25Smacallan	    esac
27105eefee25Smacallan
27115eefee25Smacallan	    if test "$lib_linked" != yes; then
27125eefee25Smacallan	      $echo "$modename: configuration error: unsupported hardcode properties"
27135eefee25Smacallan	      exit $EXIT_FAILURE
27145eefee25Smacallan	    fi
27155eefee25Smacallan
27165eefee25Smacallan	    if test -n "$add_shlibpath"; then
27175eefee25Smacallan	      case :$compile_shlibpath: in
27185eefee25Smacallan	      *":$add_shlibpath:"*) ;;
27195eefee25Smacallan	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
27205eefee25Smacallan	      esac
27215eefee25Smacallan	    fi
27225eefee25Smacallan	    if test "$linkmode" = prog; then
27235eefee25Smacallan	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
27245eefee25Smacallan	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
27255eefee25Smacallan	    else
27265eefee25Smacallan	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
27275eefee25Smacallan	      test -n "$add" && deplibs="$add $deplibs"
27285eefee25Smacallan	      if test "$hardcode_direct" != yes && \
27295eefee25Smacallan		 test "$hardcode_minus_L" != yes && \
27305eefee25Smacallan		 test "$hardcode_shlibpath_var" = yes; then
27315eefee25Smacallan		case :$finalize_shlibpath: in
27325eefee25Smacallan		*":$libdir:"*) ;;
27335eefee25Smacallan		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
27345eefee25Smacallan		esac
27355eefee25Smacallan	      fi
27365eefee25Smacallan	    fi
27375eefee25Smacallan	  fi
27385eefee25Smacallan
27395eefee25Smacallan	  if test "$linkmode" = prog || test "$mode" = relink; then
27405eefee25Smacallan	    add_shlibpath=
27415eefee25Smacallan	    add_dir=
27425eefee25Smacallan	    add=
27435eefee25Smacallan	    # Finalize command for both is simple: just hardcode it.
27445eefee25Smacallan	    if test "$hardcode_direct" = yes; then
27455eefee25Smacallan	      add="$libdir/$linklib"
27465eefee25Smacallan	    elif test "$hardcode_minus_L" = yes; then
27475eefee25Smacallan	      add_dir="-L$libdir"
27485eefee25Smacallan	      add="-l$name"
27495eefee25Smacallan	    elif test "$hardcode_shlibpath_var" = yes; then
27505eefee25Smacallan	      case :$finalize_shlibpath: in
27515eefee25Smacallan	      *":$libdir:"*) ;;
27525eefee25Smacallan	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
27535eefee25Smacallan	      esac
27545eefee25Smacallan	      add="-l$name"
27555eefee25Smacallan	    elif test "$hardcode_automatic" = yes; then
27565eefee25Smacallan	      if test -n "$inst_prefix_dir" &&
27575eefee25Smacallan		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
27585eefee25Smacallan	        add="$inst_prefix_dir$libdir/$linklib"
27595eefee25Smacallan	      else
27605eefee25Smacallan	        add="$libdir/$linklib"
27615eefee25Smacallan	      fi
27625eefee25Smacallan	    else
27635eefee25Smacallan	      # We cannot seem to hardcode it, guess we'll fake it.
27645eefee25Smacallan	      add_dir="-L$libdir"
27655eefee25Smacallan	      # Try looking first in the location we're being installed to.
27665eefee25Smacallan	      if test -n "$inst_prefix_dir"; then
27675eefee25Smacallan		case $libdir in
27685eefee25Smacallan		  [\\/]*)
27695eefee25Smacallan		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
27705eefee25Smacallan		    ;;
27715eefee25Smacallan		esac
27725eefee25Smacallan	      fi
27735eefee25Smacallan	      add="-l$name"
27745eefee25Smacallan	    fi
27755eefee25Smacallan
27765eefee25Smacallan	    if test "$linkmode" = prog; then
27775eefee25Smacallan	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
27785eefee25Smacallan	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
27795eefee25Smacallan	    else
27805eefee25Smacallan	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
27815eefee25Smacallan	      test -n "$add" && deplibs="$add $deplibs"
27825eefee25Smacallan	    fi
27835eefee25Smacallan	  fi
27845eefee25Smacallan	elif test "$linkmode" = prog; then
27855eefee25Smacallan	  # Here we assume that one of hardcode_direct or hardcode_minus_L
27865eefee25Smacallan	  # is not unsupported.  This is valid on all known static and
27875eefee25Smacallan	  # shared platforms.
27885eefee25Smacallan	  if test "$hardcode_direct" != unsupported; then
27895eefee25Smacallan	    test -n "$old_library" && linklib="$old_library"
27905eefee25Smacallan	    compile_deplibs="$dir/$linklib $compile_deplibs"
27915eefee25Smacallan	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
27925eefee25Smacallan	  else
27935eefee25Smacallan	    compile_deplibs="-l$name -L$dir $compile_deplibs"
27945eefee25Smacallan	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
27955eefee25Smacallan	  fi
27965eefee25Smacallan	elif test "$build_libtool_libs" = yes; then
27975eefee25Smacallan	  # Not a shared library
27985eefee25Smacallan	  if test "$deplibs_check_method" != pass_all; then
27995eefee25Smacallan	    # We're trying link a shared library against a static one
28005eefee25Smacallan	    # but the system doesn't support it.
28015eefee25Smacallan
28025eefee25Smacallan	    # Just print a warning and add the library to dependency_libs so
28035eefee25Smacallan	    # that the program can be linked against the static library.
28045eefee25Smacallan	    $echo
28055eefee25Smacallan	    $echo "*** Warning: This system can not link to static lib archive $lib."
28065eefee25Smacallan	    $echo "*** I have the capability to make that library automatically link in when"
28075eefee25Smacallan	    $echo "*** you link to this library.  But I can only do this if you have a"
28085eefee25Smacallan	    $echo "*** shared version of the library, which you do not appear to have."
28095eefee25Smacallan	    if test "$module" = yes; then
28105eefee25Smacallan	      $echo "*** But as you try to build a module library, libtool will still create "
28115eefee25Smacallan	      $echo "*** a static module, that should work as long as the dlopening application"
28125eefee25Smacallan	      $echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
28135eefee25Smacallan	      if test -z "$global_symbol_pipe"; then
28145eefee25Smacallan		$echo
28155eefee25Smacallan		$echo "*** However, this would only work if libtool was able to extract symbol"
28165eefee25Smacallan		$echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
28175eefee25Smacallan		$echo "*** not find such a program.  So, this module is probably useless."
28185eefee25Smacallan		$echo "*** \`nm' from GNU binutils and a full rebuild may help."
28195eefee25Smacallan	      fi
28205eefee25Smacallan	      if test "$build_old_libs" = no; then
28215eefee25Smacallan		build_libtool_libs=module
28225eefee25Smacallan		build_old_libs=yes
28235eefee25Smacallan	      else
28245eefee25Smacallan		build_libtool_libs=no
28255eefee25Smacallan	      fi
28265eefee25Smacallan	    fi
28275eefee25Smacallan	  else
28285eefee25Smacallan	    deplibs="$dir/$old_library $deplibs"
28295eefee25Smacallan	    link_static=yes
28305eefee25Smacallan	  fi
28315eefee25Smacallan	fi # link shared/static library?
28325eefee25Smacallan
28335eefee25Smacallan	if test "$linkmode" = lib; then
28345eefee25Smacallan	  if test -n "$dependency_libs" &&
28355eefee25Smacallan	     { test "$hardcode_into_libs" != yes ||
28365eefee25Smacallan	       test "$build_old_libs" = yes ||
28375eefee25Smacallan	       test "$link_static" = yes; }; then
28385eefee25Smacallan	    # Extract -R from dependency_libs
28395eefee25Smacallan	    temp_deplibs=
28405eefee25Smacallan	    for libdir in $dependency_libs; do
28415eefee25Smacallan	      case $libdir in
28425eefee25Smacallan	      -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'`
28435eefee25Smacallan		   case " $xrpath " in
28445eefee25Smacallan		   *" $temp_xrpath "*) ;;
28455eefee25Smacallan		   *) xrpath="$xrpath $temp_xrpath";;
28465eefee25Smacallan		   esac;;
28475eefee25Smacallan	      *) temp_deplibs="$temp_deplibs $libdir";;
28485eefee25Smacallan	      esac
28495eefee25Smacallan	    done
28505eefee25Smacallan	    dependency_libs="$temp_deplibs"
28515eefee25Smacallan	  fi
28525eefee25Smacallan
28535eefee25Smacallan	  newlib_search_path="$newlib_search_path $absdir"
28545eefee25Smacallan	  # Link against this library
28555eefee25Smacallan	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
28565eefee25Smacallan	  # ... and its dependency_libs
28575eefee25Smacallan	  tmp_libs=
28585eefee25Smacallan	  for deplib in $dependency_libs; do
28595eefee25Smacallan	    newdependency_libs="$deplib $newdependency_libs"
28605eefee25Smacallan	    if test "X$duplicate_deps" = "Xyes" ; then
28615eefee25Smacallan	      case "$tmp_libs " in
28625eefee25Smacallan	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
28635eefee25Smacallan	      esac
28645eefee25Smacallan	    fi
28655eefee25Smacallan	    tmp_libs="$tmp_libs $deplib"
28665eefee25Smacallan	  done
28675eefee25Smacallan
28685eefee25Smacallan	  if test "$link_all_deplibs" != no; then
28695eefee25Smacallan	    # Add the search paths of all dependency libraries
28705eefee25Smacallan	    for deplib in $dependency_libs; do
28715eefee25Smacallan	      case $deplib in
28725eefee25Smacallan	      -L*) path="$deplib" ;;
28735eefee25Smacallan	      *.la)
28745eefee25Smacallan		dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'`
28755eefee25Smacallan		test "X$dir" = "X$deplib" && dir="."
28765eefee25Smacallan		# We need an absolute path.
28775eefee25Smacallan		case $dir in
28785eefee25Smacallan		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
28795eefee25Smacallan		*)
28805eefee25Smacallan		  absdir=`cd "$dir" && pwd`
28815eefee25Smacallan		  if test -z "$absdir"; then
28825eefee25Smacallan		    $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
28835eefee25Smacallan		    absdir="$dir"
28845eefee25Smacallan		  fi
28855eefee25Smacallan		  ;;
28865eefee25Smacallan		esac
28875eefee25Smacallan		if grep "^installed=no" $deplib > /dev/null; then
28885eefee25Smacallan		  path="$absdir/$objdir"
28895eefee25Smacallan		else
28905eefee25Smacallan		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
28915eefee25Smacallan		  if test -z "$libdir"; then
28925eefee25Smacallan		    $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
28935eefee25Smacallan		    exit $EXIT_FAILURE
28945eefee25Smacallan		  fi
28955eefee25Smacallan		  if test "$absdir" != "$libdir"; then
28965eefee25Smacallan		    $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2
28975eefee25Smacallan		  fi
28985eefee25Smacallan		  path="$absdir"
28995eefee25Smacallan		fi
29005eefee25Smacallan		depdepl=
29015eefee25Smacallan		case $host in
29025eefee25Smacallan		*-*-darwin*)
29035eefee25Smacallan		  # we do not want to link against static libs,
29045eefee25Smacallan		  # but need to link against shared
29055eefee25Smacallan		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
29065eefee25Smacallan		  if test -n "$deplibrary_names" ; then
29075eefee25Smacallan		    for tmp in $deplibrary_names ; do
29085eefee25Smacallan		      depdepl=$tmp
29095eefee25Smacallan		    done
29105eefee25Smacallan		    if test -f "$path/$depdepl" ; then
29115eefee25Smacallan		      depdepl="$path/$depdepl"
29125eefee25Smacallan		    fi
29135eefee25Smacallan		    # do not add paths which are already there
29145eefee25Smacallan		    case " $newlib_search_path " in
29155eefee25Smacallan		    *" $path "*) ;;
29165eefee25Smacallan		    *) newlib_search_path="$newlib_search_path $path";;
29175eefee25Smacallan		    esac
29185eefee25Smacallan		  fi
29195eefee25Smacallan		  path=""
29205eefee25Smacallan		  ;;
29215eefee25Smacallan		*)
29225eefee25Smacallan		  path="-L$path"
29235eefee25Smacallan		  ;;
29245eefee25Smacallan		esac
29255eefee25Smacallan		;;
29265eefee25Smacallan	      -l*)
29275eefee25Smacallan		case $host in
29285eefee25Smacallan		*-*-darwin*)
29295eefee25Smacallan		  # Again, we only want to link against shared libraries
29305eefee25Smacallan		  eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"`
29315eefee25Smacallan		  for tmp in $newlib_search_path ; do
29325eefee25Smacallan		    if test -f "$tmp/lib$tmp_libs.dylib" ; then
29335eefee25Smacallan		      eval depdepl="$tmp/lib$tmp_libs.dylib"
29345eefee25Smacallan		      break
29355eefee25Smacallan		    fi
29365eefee25Smacallan		  done
29375eefee25Smacallan		  path=""
29385eefee25Smacallan		  ;;
29395eefee25Smacallan		*) continue ;;
29405eefee25Smacallan		esac
29415eefee25Smacallan		;;
29425eefee25Smacallan	      *) continue ;;
29435eefee25Smacallan	      esac
29445eefee25Smacallan	      case " $deplibs " in
29455eefee25Smacallan	      *" $path "*) ;;
29465eefee25Smacallan	      *) deplibs="$path $deplibs" ;;
29475eefee25Smacallan	      esac
29485eefee25Smacallan	      case " $deplibs " in
29495eefee25Smacallan	      *" $depdepl "*) ;;
29505eefee25Smacallan	      *) deplibs="$depdepl $deplibs" ;;
29515eefee25Smacallan	      esac
29525eefee25Smacallan	    done
29535eefee25Smacallan	  fi # link_all_deplibs != no
29545eefee25Smacallan	fi # linkmode = lib
29555eefee25Smacallan      done # for deplib in $libs
29565eefee25Smacallan      dependency_libs="$newdependency_libs"
29575eefee25Smacallan      if test "$pass" = dlpreopen; then
29585eefee25Smacallan	# Link the dlpreopened libraries before other libraries
29595eefee25Smacallan	for deplib in $save_deplibs; do
29605eefee25Smacallan	  deplibs="$deplib $deplibs"
29615eefee25Smacallan	done
29625eefee25Smacallan      fi
29635eefee25Smacallan      if test "$pass" != dlopen; then
29645eefee25Smacallan	if test "$pass" != conv; then
29655eefee25Smacallan	  # Make sure lib_search_path contains only unique directories.
29665eefee25Smacallan	  lib_search_path=
29675eefee25Smacallan	  for dir in $newlib_search_path; do
29685eefee25Smacallan	    case "$lib_search_path " in
29695eefee25Smacallan	    *" $dir "*) ;;
29705eefee25Smacallan	    *) lib_search_path="$lib_search_path $dir" ;;
29715eefee25Smacallan	    esac
29725eefee25Smacallan	  done
29735eefee25Smacallan	  newlib_search_path=
29745eefee25Smacallan	fi
29755eefee25Smacallan
29765eefee25Smacallan	if test "$linkmode,$pass" != "prog,link"; then
29775eefee25Smacallan	  vars="deplibs"
29785eefee25Smacallan	else
29795eefee25Smacallan	  vars="compile_deplibs finalize_deplibs"
29805eefee25Smacallan	fi
29815eefee25Smacallan	for var in $vars dependency_libs; do
29825eefee25Smacallan	  # Add libraries to $var in reverse order
29835eefee25Smacallan	  eval tmp_libs=\"\$$var\"
29845eefee25Smacallan	  new_libs=
29855eefee25Smacallan	  for deplib in $tmp_libs; do
29865eefee25Smacallan	    # FIXME: Pedantically, this is the right thing to do, so
29875eefee25Smacallan	    #        that some nasty dependency loop isn't accidentally
29885eefee25Smacallan	    #        broken:
29895eefee25Smacallan	    #new_libs="$deplib $new_libs"
29905eefee25Smacallan	    # Pragmatically, this seems to cause very few problems in
29915eefee25Smacallan	    # practice:
29925eefee25Smacallan	    case $deplib in
29935eefee25Smacallan	    -L*) new_libs="$deplib $new_libs" ;;
29945eefee25Smacallan	    -R*) ;;
29955eefee25Smacallan	    *)
29965eefee25Smacallan	      # And here is the reason: when a library appears more
29975eefee25Smacallan	      # than once as an explicit dependence of a library, or
29985eefee25Smacallan	      # is implicitly linked in more than once by the
29995eefee25Smacallan	      # compiler, it is considered special, and multiple
30005eefee25Smacallan	      # occurrences thereof are not removed.  Compare this
30015eefee25Smacallan	      # with having the same library being listed as a
30025eefee25Smacallan	      # dependency of multiple other libraries: in this case,
30035eefee25Smacallan	      # we know (pedantically, we assume) the library does not
30045eefee25Smacallan	      # need to be listed more than once, so we keep only the
30055eefee25Smacallan	      # last copy.  This is not always right, but it is rare
30065eefee25Smacallan	      # enough that we require users that really mean to play
30075eefee25Smacallan	      # such unportable linking tricks to link the library
30085eefee25Smacallan	      # using -Wl,-lname, so that libtool does not consider it
30095eefee25Smacallan	      # for duplicate removal.
30105eefee25Smacallan	      case " $specialdeplibs " in
30115eefee25Smacallan	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
30125eefee25Smacallan	      *)
30135eefee25Smacallan		case " $new_libs " in
30145eefee25Smacallan		*" $deplib "*) ;;
30155eefee25Smacallan		*) new_libs="$deplib $new_libs" ;;
30165eefee25Smacallan		esac
30175eefee25Smacallan		;;
30185eefee25Smacallan	      esac
30195eefee25Smacallan	      ;;
30205eefee25Smacallan	    esac
30215eefee25Smacallan	  done
30225eefee25Smacallan	  tmp_libs=
30235eefee25Smacallan	  for deplib in $new_libs; do
30245eefee25Smacallan	    case $deplib in
30255eefee25Smacallan	    -L*)
30265eefee25Smacallan	      case " $tmp_libs " in
30275eefee25Smacallan	      *" $deplib "*) ;;
30285eefee25Smacallan	      *) tmp_libs="$tmp_libs $deplib" ;;
30295eefee25Smacallan	      esac
30305eefee25Smacallan	      ;;
30315eefee25Smacallan	    *) tmp_libs="$tmp_libs $deplib" ;;
30325eefee25Smacallan	    esac
30335eefee25Smacallan	  done
30345eefee25Smacallan	  eval $var=\"$tmp_libs\"
30355eefee25Smacallan	done # for var
30365eefee25Smacallan      fi
30375eefee25Smacallan      # Last step: remove runtime libs from dependency_libs
30385eefee25Smacallan      # (they stay in deplibs)
30395eefee25Smacallan      tmp_libs=
30405eefee25Smacallan      for i in $dependency_libs ; do
30415eefee25Smacallan	case " $predeps $postdeps $compiler_lib_search_path " in
30425eefee25Smacallan	*" $i "*)
30435eefee25Smacallan	  i=""
30445eefee25Smacallan	  ;;
30455eefee25Smacallan	esac
30465eefee25Smacallan	if test -n "$i" ; then
30475eefee25Smacallan	  tmp_libs="$tmp_libs $i"
30485eefee25Smacallan	fi
30495eefee25Smacallan      done
30505eefee25Smacallan      dependency_libs=$tmp_libs
30515eefee25Smacallan    done # for pass
30525eefee25Smacallan    if test "$linkmode" = prog; then
30535eefee25Smacallan      dlfiles="$newdlfiles"
30545eefee25Smacallan      dlprefiles="$newdlprefiles"
30555eefee25Smacallan    fi
30565eefee25Smacallan
30575eefee25Smacallan    case $linkmode in
30585eefee25Smacallan    oldlib)
30595eefee25Smacallan      if test -n "$deplibs"; then
30605eefee25Smacallan	$echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2
30615eefee25Smacallan      fi
30625eefee25Smacallan
30635eefee25Smacallan      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
30645eefee25Smacallan	$echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
30655eefee25Smacallan      fi
30665eefee25Smacallan
30675eefee25Smacallan      if test -n "$rpath"; then
30685eefee25Smacallan	$echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2
30695eefee25Smacallan      fi
30705eefee25Smacallan
30715eefee25Smacallan      if test -n "$xrpath"; then
30725eefee25Smacallan	$echo "$modename: warning: \`-R' is ignored for archives" 1>&2
30735eefee25Smacallan      fi
30745eefee25Smacallan
30755eefee25Smacallan      if test -n "$vinfo"; then
30765eefee25Smacallan	$echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2
30775eefee25Smacallan      fi
30785eefee25Smacallan
30795eefee25Smacallan      if test -n "$release"; then
30805eefee25Smacallan	$echo "$modename: warning: \`-release' is ignored for archives" 1>&2
30815eefee25Smacallan      fi
30825eefee25Smacallan
30835eefee25Smacallan      if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
30845eefee25Smacallan	$echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2
30855eefee25Smacallan      fi
30865eefee25Smacallan
30875eefee25Smacallan      # Now set the variables for building old libraries.
30885eefee25Smacallan      build_libtool_libs=no
30895eefee25Smacallan      oldlibs="$output"
30905eefee25Smacallan      objs="$objs$old_deplibs"
30915eefee25Smacallan      ;;
30925eefee25Smacallan
30935eefee25Smacallan    lib)
30945eefee25Smacallan      # Make sure we only generate libraries of the form `libNAME.la'.
30955eefee25Smacallan      case $outputname in
30965eefee25Smacallan      lib*)
30975eefee25Smacallan	name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
30985eefee25Smacallan	eval shared_ext=\"$shrext_cmds\"
30995eefee25Smacallan	eval libname=\"$libname_spec\"
31005eefee25Smacallan	;;
31015eefee25Smacallan      *)
31025eefee25Smacallan	if test "$module" = no; then
31035eefee25Smacallan	  $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
31045eefee25Smacallan	  $echo "$help" 1>&2
31055eefee25Smacallan	  exit $EXIT_FAILURE
31065eefee25Smacallan	fi
31075eefee25Smacallan	if test "$need_lib_prefix" != no; then
31085eefee25Smacallan	  # Add the "lib" prefix for modules if required
31095eefee25Smacallan	  name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
31105eefee25Smacallan	  eval shared_ext=\"$shrext_cmds\"
31115eefee25Smacallan	  eval libname=\"$libname_spec\"
31125eefee25Smacallan	else
31135eefee25Smacallan	  libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
31145eefee25Smacallan	fi
31155eefee25Smacallan	;;
31165eefee25Smacallan      esac
31175eefee25Smacallan
31185eefee25Smacallan      if test -n "$objs"; then
31195eefee25Smacallan	if test "$deplibs_check_method" != pass_all; then
31205eefee25Smacallan	  $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1
31215eefee25Smacallan	  exit $EXIT_FAILURE
31225eefee25Smacallan	else
31235eefee25Smacallan	  $echo
31245eefee25Smacallan	  $echo "*** Warning: Linking the shared library $output against the non-libtool"
31255eefee25Smacallan	  $echo "*** objects $objs is not portable!"
31265eefee25Smacallan	  libobjs="$libobjs $objs"
31275eefee25Smacallan	fi
31285eefee25Smacallan      fi
31295eefee25Smacallan
31305eefee25Smacallan      if test "$dlself" != no; then
31315eefee25Smacallan	$echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2
31325eefee25Smacallan      fi
31335eefee25Smacallan
31345eefee25Smacallan      set dummy $rpath
31355eefee25Smacallan      if test "$#" -gt 2; then
31365eefee25Smacallan	$echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
31375eefee25Smacallan      fi
31385eefee25Smacallan      install_libdir="$2"
31395eefee25Smacallan
31405eefee25Smacallan      oldlibs=
31415eefee25Smacallan      if test -z "$rpath"; then
31425eefee25Smacallan	if test "$build_libtool_libs" = yes; then
31435eefee25Smacallan	  # Building a libtool convenience library.
31445eefee25Smacallan	  # Some compilers have problems with a `.al' extension so
31455eefee25Smacallan	  # convenience libraries should have the same extension an
31465eefee25Smacallan	  # archive normally would.
31475eefee25Smacallan	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
31485eefee25Smacallan	  build_libtool_libs=convenience
31495eefee25Smacallan	  build_old_libs=yes
31505eefee25Smacallan	fi
31515eefee25Smacallan
31525eefee25Smacallan	if test -n "$vinfo"; then
31535eefee25Smacallan	  $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2
31545eefee25Smacallan	fi
31555eefee25Smacallan
31565eefee25Smacallan	if test -n "$release"; then
31575eefee25Smacallan	  $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2
31585eefee25Smacallan	fi
31595eefee25Smacallan      else
31605eefee25Smacallan
31615eefee25Smacallan	# Parse the version information argument.
31625eefee25Smacallan	save_ifs="$IFS"; IFS=':'
31635eefee25Smacallan	set dummy $vinfo 0 0 0
31645eefee25Smacallan	IFS="$save_ifs"
31655eefee25Smacallan
31665eefee25Smacallan	if test -n "$8"; then
31675eefee25Smacallan	  $echo "$modename: too many parameters to \`-version-info'" 1>&2
31685eefee25Smacallan	  $echo "$help" 1>&2
31695eefee25Smacallan	  exit $EXIT_FAILURE
31705eefee25Smacallan	fi
31715eefee25Smacallan
31725eefee25Smacallan	# convert absolute version numbers to libtool ages
31735eefee25Smacallan	# this retains compatibility with .la files and attempts
31745eefee25Smacallan	# to make the code below a bit more comprehensible
31755eefee25Smacallan
31765eefee25Smacallan	case $vinfo_number in
31775eefee25Smacallan	yes)
31785eefee25Smacallan	  number_major="$2"
31795eefee25Smacallan	  number_minor="$3"
31805eefee25Smacallan	  number_revision="$4"
31815eefee25Smacallan	  #
31825eefee25Smacallan	  # There are really only two kinds -- those that
31835eefee25Smacallan	  # use the current revision as the major version
31845eefee25Smacallan	  # and those that subtract age and use age as
31855eefee25Smacallan	  # a minor version.  But, then there is irix
31865eefee25Smacallan	  # which has an extra 1 added just for fun
31875eefee25Smacallan	  #
31885eefee25Smacallan	  case $version_type in
31895eefee25Smacallan	  darwin|linux|osf|windows)
31905eefee25Smacallan	    current=`expr $number_major + $number_minor`
31915eefee25Smacallan	    age="$number_minor"
31925eefee25Smacallan	    revision="$number_revision"
31935eefee25Smacallan	    ;;
31945eefee25Smacallan	  freebsd-aout|freebsd-elf|sunos)
31955eefee25Smacallan	    current="$number_major"
31965eefee25Smacallan	    revision="$number_minor"
31975eefee25Smacallan	    age="0"
31985eefee25Smacallan	    ;;
31995eefee25Smacallan	  irix|nonstopux)
32005eefee25Smacallan	    current=`expr $number_major + $number_minor - 1`
32015eefee25Smacallan	    age="$number_minor"
32025eefee25Smacallan	    revision="$number_minor"
32035eefee25Smacallan	    ;;
32045eefee25Smacallan	  esac
32055eefee25Smacallan	  ;;
32065eefee25Smacallan	no)
32075eefee25Smacallan	  current="$2"
32085eefee25Smacallan	  revision="$3"
32095eefee25Smacallan	  age="$4"
32105eefee25Smacallan	  ;;
32115eefee25Smacallan	esac
32125eefee25Smacallan
32135eefee25Smacallan	# Check that each of the things are valid numbers.
32145eefee25Smacallan	case $current in
32155eefee25Smacallan	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]) ;;
32165eefee25Smacallan	*)
32175eefee25Smacallan	  $echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2
32185eefee25Smacallan	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
32195eefee25Smacallan	  exit $EXIT_FAILURE
32205eefee25Smacallan	  ;;
32215eefee25Smacallan	esac
32225eefee25Smacallan
32235eefee25Smacallan	case $revision in
32245eefee25Smacallan	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]) ;;
32255eefee25Smacallan	*)
32265eefee25Smacallan	  $echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2
32275eefee25Smacallan	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
32285eefee25Smacallan	  exit $EXIT_FAILURE
32295eefee25Smacallan	  ;;
32305eefee25Smacallan	esac
32315eefee25Smacallan
32325eefee25Smacallan	case $age in
32335eefee25Smacallan	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]) ;;
32345eefee25Smacallan	*)
32355eefee25Smacallan	  $echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2
32365eefee25Smacallan	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
32375eefee25Smacallan	  exit $EXIT_FAILURE
32385eefee25Smacallan	  ;;
32395eefee25Smacallan	esac
32405eefee25Smacallan
32415eefee25Smacallan	if test "$age" -gt "$current"; then
32425eefee25Smacallan	  $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
32435eefee25Smacallan	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
32445eefee25Smacallan	  exit $EXIT_FAILURE
32455eefee25Smacallan	fi
32465eefee25Smacallan
32475eefee25Smacallan	# Calculate the version variables.
32485eefee25Smacallan	major=
32495eefee25Smacallan	versuffix=
32505eefee25Smacallan	verstring=
32515eefee25Smacallan	case $version_type in
32525eefee25Smacallan	none) ;;
32535eefee25Smacallan
32545eefee25Smacallan	darwin)
32555eefee25Smacallan	  # Like Linux, but with the current version available in
32565eefee25Smacallan	  # verstring for coding it into the library header
32575eefee25Smacallan	  major=.`expr $current - $age`
32585eefee25Smacallan	  versuffix="$major.$age.$revision"
32595eefee25Smacallan	  # Darwin ld doesn't like 0 for these options...
32605eefee25Smacallan	  minor_current=`expr $current + 1`
32615eefee25Smacallan	  verstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
32625eefee25Smacallan	  ;;
32635eefee25Smacallan
32645eefee25Smacallan	freebsd-aout)
32655eefee25Smacallan	  major=".$current"
32665eefee25Smacallan	  versuffix=".$current.$revision";
32675eefee25Smacallan	  ;;
32685eefee25Smacallan
32695eefee25Smacallan	freebsd-elf)
32705eefee25Smacallan	  major=".$current"
32715eefee25Smacallan	  versuffix=".$current";
32725eefee25Smacallan	  ;;
32735eefee25Smacallan
32745eefee25Smacallan	irix | nonstopux)
32755eefee25Smacallan	  major=`expr $current - $age + 1`
32765eefee25Smacallan
32775eefee25Smacallan	  case $version_type in
32785eefee25Smacallan	    nonstopux) verstring_prefix=nonstopux ;;
32795eefee25Smacallan	    *)         verstring_prefix=sgi ;;
32805eefee25Smacallan	  esac
32815eefee25Smacallan	  verstring="$verstring_prefix$major.$revision"
32825eefee25Smacallan
32835eefee25Smacallan	  # Add in all the interfaces that we are compatible with.
32845eefee25Smacallan	  loop=$revision
32855eefee25Smacallan	  while test "$loop" -ne 0; do
32865eefee25Smacallan	    iface=`expr $revision - $loop`
32875eefee25Smacallan	    loop=`expr $loop - 1`
32885eefee25Smacallan	    verstring="$verstring_prefix$major.$iface:$verstring"
32895eefee25Smacallan	  done
32905eefee25Smacallan
32915eefee25Smacallan	  # Before this point, $major must not contain `.'.
32925eefee25Smacallan	  major=.$major
32935eefee25Smacallan	  versuffix="$major.$revision"
32945eefee25Smacallan	  ;;
32955eefee25Smacallan
32965eefee25Smacallan	linux)
32975eefee25Smacallan	  major=.`expr $current - $age`
32985eefee25Smacallan	  versuffix="$major.$age.$revision"
32995eefee25Smacallan	  ;;
33005eefee25Smacallan
33015eefee25Smacallan	osf)
33025eefee25Smacallan	  major=.`expr $current - $age`
33035eefee25Smacallan	  versuffix=".$current.$age.$revision"
33045eefee25Smacallan	  verstring="$current.$age.$revision"
33055eefee25Smacallan
33065eefee25Smacallan	  # Add in all the interfaces that we are compatible with.
33075eefee25Smacallan	  loop=$age
33085eefee25Smacallan	  while test "$loop" -ne 0; do
33095eefee25Smacallan	    iface=`expr $current - $loop`
33105eefee25Smacallan	    loop=`expr $loop - 1`
33115eefee25Smacallan	    verstring="$verstring:${iface}.0"
33125eefee25Smacallan	  done
33135eefee25Smacallan
33145eefee25Smacallan	  # Make executables depend on our current version.
33155eefee25Smacallan	  verstring="$verstring:${current}.0"
33165eefee25Smacallan	  ;;
33175eefee25Smacallan
33185eefee25Smacallan	sunos)
33195eefee25Smacallan	  major=".$current"
33205eefee25Smacallan	  versuffix=".$current.$revision"
33215eefee25Smacallan	  ;;
33225eefee25Smacallan
33235eefee25Smacallan	windows)
33245eefee25Smacallan	  # Use '-' rather than '.', since we only want one
33255eefee25Smacallan	  # extension on DOS 8.3 filesystems.
33265eefee25Smacallan	  major=`expr $current - $age`
33275eefee25Smacallan	  versuffix="-$major"
33285eefee25Smacallan	  ;;
33295eefee25Smacallan
33305eefee25Smacallan	*)
33315eefee25Smacallan	  $echo "$modename: unknown library version type \`$version_type'" 1>&2
33325eefee25Smacallan	  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
33335eefee25Smacallan	  exit $EXIT_FAILURE
33345eefee25Smacallan	  ;;
33355eefee25Smacallan	esac
33365eefee25Smacallan
33375eefee25Smacallan	# Clear the version info if we defaulted, and they specified a release.
33385eefee25Smacallan	if test -z "$vinfo" && test -n "$release"; then
33395eefee25Smacallan	  major=
33405eefee25Smacallan	  case $version_type in
33415eefee25Smacallan	  darwin)
33425eefee25Smacallan	    # we can't check for "0.0" in archive_cmds due to quoting
33435eefee25Smacallan	    # problems, so we reset it completely
33445eefee25Smacallan	    verstring=
33455eefee25Smacallan	    ;;
33465eefee25Smacallan	  *)
33475eefee25Smacallan	    verstring="0.0"
33485eefee25Smacallan	    ;;
33495eefee25Smacallan	  esac
33505eefee25Smacallan	  if test "$need_version" = no; then
33515eefee25Smacallan	    versuffix=
33525eefee25Smacallan	  else
33535eefee25Smacallan	    versuffix=".0.0"
33545eefee25Smacallan	  fi
33555eefee25Smacallan	fi
33565eefee25Smacallan
33575eefee25Smacallan	# Remove version info from name if versioning should be avoided
33585eefee25Smacallan	if test "$avoid_version" = yes && test "$need_version" = no; then
33595eefee25Smacallan	  major=
33605eefee25Smacallan	  versuffix=
33615eefee25Smacallan	  verstring=""
33625eefee25Smacallan	fi
33635eefee25Smacallan
33645eefee25Smacallan	# Check to see if the archive will have undefined symbols.
33655eefee25Smacallan	if test "$allow_undefined" = yes; then
33665eefee25Smacallan	  if test "$allow_undefined_flag" = unsupported; then
33675eefee25Smacallan	    $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2
33685eefee25Smacallan	    build_libtool_libs=no
33695eefee25Smacallan	    build_old_libs=yes
33705eefee25Smacallan	  fi
33715eefee25Smacallan	else
33725eefee25Smacallan	  # Don't allow undefined symbols.
33735eefee25Smacallan	  allow_undefined_flag="$no_undefined_flag"
33745eefee25Smacallan	fi
33755eefee25Smacallan      fi
33765eefee25Smacallan
33775eefee25Smacallan      if test "$mode" != relink; then
33785eefee25Smacallan	# Remove our outputs, but don't remove object files since they
33795eefee25Smacallan	# may have been created when compiling PIC objects.
33805eefee25Smacallan	removelist=
33815eefee25Smacallan	tempremovelist=`$echo "$output_objdir/*"`
33825eefee25Smacallan	for p in $tempremovelist; do
33835eefee25Smacallan	  case $p in
33845eefee25Smacallan	    *.$objext)
33855eefee25Smacallan	       ;;
33865eefee25Smacallan	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
33875eefee25Smacallan	       if test "X$precious_files_regex" != "X"; then
33885eefee25Smacallan	         if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
33895eefee25Smacallan	         then
33905eefee25Smacallan		   continue
33915eefee25Smacallan		 fi
33925eefee25Smacallan	       fi
33935eefee25Smacallan	       removelist="$removelist $p"
33945eefee25Smacallan	       ;;
33955eefee25Smacallan	    *) ;;
33965eefee25Smacallan	  esac
33975eefee25Smacallan	done
33985eefee25Smacallan	if test -n "$removelist"; then
33995eefee25Smacallan	  $show "${rm}r $removelist"
34005eefee25Smacallan	  $run ${rm}r $removelist
34015eefee25Smacallan	fi
34025eefee25Smacallan      fi
34035eefee25Smacallan
34045eefee25Smacallan      # Now set the variables for building old libraries.
34055eefee25Smacallan      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
34065eefee25Smacallan	oldlibs="$oldlibs $output_objdir/$libname.$libext"
34075eefee25Smacallan
34085eefee25Smacallan	# Transform .lo files to .o files.
34095eefee25Smacallan	oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
34105eefee25Smacallan      fi
34115eefee25Smacallan
34125eefee25Smacallan      # Eliminate all temporary directories.
34135eefee25Smacallan      for path in $notinst_path; do
34145eefee25Smacallan	lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"`
34155eefee25Smacallan	deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"`
34165eefee25Smacallan	dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"`
34175eefee25Smacallan      done
34185eefee25Smacallan
34195eefee25Smacallan      if test -n "$xrpath"; then
34205eefee25Smacallan	# If the user specified any rpath flags, then add them.
34215eefee25Smacallan	temp_xrpath=
34225eefee25Smacallan	for libdir in $xrpath; do
34235eefee25Smacallan	  temp_xrpath="$temp_xrpath -R$libdir"
34245eefee25Smacallan	  case "$finalize_rpath " in
34255eefee25Smacallan	  *" $libdir "*) ;;
34265eefee25Smacallan	  *) finalize_rpath="$finalize_rpath $libdir" ;;
34275eefee25Smacallan	  esac
34285eefee25Smacallan	done
34295eefee25Smacallan	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
34305eefee25Smacallan	  dependency_libs="$temp_xrpath $dependency_libs"
34315eefee25Smacallan	fi
34325eefee25Smacallan      fi
34335eefee25Smacallan
34345eefee25Smacallan      # Make sure dlfiles contains only unique files that won't be dlpreopened
34355eefee25Smacallan      old_dlfiles="$dlfiles"
34365eefee25Smacallan      dlfiles=
34375eefee25Smacallan      for lib in $old_dlfiles; do
34385eefee25Smacallan	case " $dlprefiles $dlfiles " in
34395eefee25Smacallan	*" $lib "*) ;;
34405eefee25Smacallan	*) dlfiles="$dlfiles $lib" ;;
34415eefee25Smacallan	esac
34425eefee25Smacallan      done
34435eefee25Smacallan
34445eefee25Smacallan      # Make sure dlprefiles contains only unique files
34455eefee25Smacallan      old_dlprefiles="$dlprefiles"
34465eefee25Smacallan      dlprefiles=
34475eefee25Smacallan      for lib in $old_dlprefiles; do
34485eefee25Smacallan	case "$dlprefiles " in
34495eefee25Smacallan	*" $lib "*) ;;
34505eefee25Smacallan	*) dlprefiles="$dlprefiles $lib" ;;
34515eefee25Smacallan	esac
34525eefee25Smacallan      done
34535eefee25Smacallan
34545eefee25Smacallan      if test "$build_libtool_libs" = yes; then
34555eefee25Smacallan	if test -n "$rpath"; then
34565eefee25Smacallan	  case $host in
34575eefee25Smacallan	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*)
34585eefee25Smacallan	    # these systems don't actually have a c library (as such)!
34595eefee25Smacallan	    ;;
34605eefee25Smacallan	  *-*-rhapsody* | *-*-darwin1.[012])
34615eefee25Smacallan	    # Rhapsody C library is in the System framework
34625eefee25Smacallan	    deplibs="$deplibs -framework System"
34635eefee25Smacallan	    ;;
34645eefee25Smacallan	  *-*-netbsd*)
34655eefee25Smacallan	    # Don't link with libc until the a.out ld.so is fixed.
34665eefee25Smacallan	    ;;
34675eefee25Smacallan	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
34685eefee25Smacallan	    # Do not include libc due to us having libc/libc_r.
34695eefee25Smacallan	    ;;
34705eefee25Smacallan	  *-*-sco3.2v5* | *-*-sco5v6*)
34715eefee25Smacallan	    # Causes problems with __ctype
34725eefee25Smacallan	    ;;
34735eefee25Smacallan	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
34745eefee25Smacallan	    # Compiler inserts libc in the correct place for threads to work
34755eefee25Smacallan	    ;;
34765eefee25Smacallan 	  *)
34775eefee25Smacallan	    # Add libc to deplibs on all other systems if necessary.
34785eefee25Smacallan	    if test "$build_libtool_need_lc" = "yes"; then
34795eefee25Smacallan	      deplibs="$deplibs -lc"
34805eefee25Smacallan	    fi
34815eefee25Smacallan	    ;;
34825eefee25Smacallan	  esac
34835eefee25Smacallan	fi
34845eefee25Smacallan
34855eefee25Smacallan	# Transform deplibs into only deplibs that can be linked in shared.
34865eefee25Smacallan	name_save=$name
34875eefee25Smacallan	libname_save=$libname
34885eefee25Smacallan	release_save=$release
34895eefee25Smacallan	versuffix_save=$versuffix
34905eefee25Smacallan	major_save=$major
34915eefee25Smacallan	# I'm not sure if I'm treating the release correctly.  I think
34925eefee25Smacallan	# release should show up in the -l (ie -lgmp5) so we don't want to
34935eefee25Smacallan	# add it in twice.  Is that correct?
34945eefee25Smacallan	release=""
34955eefee25Smacallan	versuffix=""
34965eefee25Smacallan	major=""
34975eefee25Smacallan	newdeplibs=
34985eefee25Smacallan	droppeddeps=no
34995eefee25Smacallan	case $deplibs_check_method in
35005eefee25Smacallan	pass_all)
35015eefee25Smacallan	  # Don't check for shared/static.  Everything works.
35025eefee25Smacallan	  # This might be a little naive.  We might want to check
35035eefee25Smacallan	  # whether the library exists or not.  But this is on
35045eefee25Smacallan	  # osf3 & osf4 and I'm not really sure... Just
35055eefee25Smacallan	  # implementing what was already the behavior.
35065eefee25Smacallan	  newdeplibs=$deplibs
35075eefee25Smacallan	  ;;
35085eefee25Smacallan	test_compile)
35095eefee25Smacallan	  # This code stresses the "libraries are programs" paradigm to its
35105eefee25Smacallan	  # limits. Maybe even breaks it.  We compile a program, linking it
35115eefee25Smacallan	  # against the deplibs as a proxy for the library.  Then we can check
35125eefee25Smacallan	  # whether they linked in statically or dynamically with ldd.
35135eefee25Smacallan	  $rm conftest.c
35145eefee25Smacallan	  cat > conftest.c <<EOF
35155eefee25Smacallan	  int main() { return 0; }
35165eefee25SmacallanEOF
35175eefee25Smacallan	  $rm conftest
35185eefee25Smacallan	  $LTCC $LTCFLAGS -o conftest conftest.c $deplibs
35195eefee25Smacallan	  if test "$?" -eq 0 ; then
35205eefee25Smacallan	    ldd_output=`ldd conftest`
35215eefee25Smacallan	    for i in $deplibs; do
35225eefee25Smacallan	      name=`expr $i : '-l\(.*\)'`
35235eefee25Smacallan	      # If $name is empty we are operating on a -L argument.
35245eefee25Smacallan              if test "$name" != "" && test "$name" -ne "0"; then
35255eefee25Smacallan		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
35265eefee25Smacallan		  case " $predeps $postdeps " in
35275eefee25Smacallan		  *" $i "*)
35285eefee25Smacallan		    newdeplibs="$newdeplibs $i"
35295eefee25Smacallan		    i=""
35305eefee25Smacallan		    ;;
35315eefee25Smacallan		  esac
35325eefee25Smacallan	        fi
35335eefee25Smacallan		if test -n "$i" ; then
35345eefee25Smacallan		  libname=`eval \\$echo \"$libname_spec\"`
35355eefee25Smacallan		  deplib_matches=`eval \\$echo \"$library_names_spec\"`
35365eefee25Smacallan		  set dummy $deplib_matches
35375eefee25Smacallan		  deplib_match=$2
35385eefee25Smacallan		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
35395eefee25Smacallan		    newdeplibs="$newdeplibs $i"
35405eefee25Smacallan		  else
35415eefee25Smacallan		    droppeddeps=yes
35425eefee25Smacallan		    $echo
35435eefee25Smacallan		    $echo "*** Warning: dynamic linker does not accept needed library $i."
35445eefee25Smacallan		    $echo "*** I have the capability to make that library automatically link in when"
35455eefee25Smacallan		    $echo "*** you link to this library.  But I can only do this if you have a"
35465eefee25Smacallan		    $echo "*** shared version of the library, which I believe you do not have"
35475eefee25Smacallan		    $echo "*** because a test_compile did reveal that the linker did not use it for"
35485eefee25Smacallan		    $echo "*** its dynamic dependency list that programs get resolved with at runtime."
35495eefee25Smacallan		  fi
35505eefee25Smacallan		fi
35515eefee25Smacallan	      else
35525eefee25Smacallan		newdeplibs="$newdeplibs $i"
35535eefee25Smacallan	      fi
35545eefee25Smacallan	    done
35555eefee25Smacallan	  else
35565eefee25Smacallan	    # Error occurred in the first compile.  Let's try to salvage
35575eefee25Smacallan	    # the situation: Compile a separate program for each library.
35585eefee25Smacallan	    for i in $deplibs; do
35595eefee25Smacallan	      name=`expr $i : '-l\(.*\)'`
35605eefee25Smacallan	      # If $name is empty we are operating on a -L argument.
35615eefee25Smacallan              if test "$name" != "" && test "$name" != "0"; then
35625eefee25Smacallan		$rm conftest
35635eefee25Smacallan		$LTCC $LTCFLAGS -o conftest conftest.c $i
35645eefee25Smacallan		# Did it work?
35655eefee25Smacallan		if test "$?" -eq 0 ; then
35665eefee25Smacallan		  ldd_output=`ldd conftest`
35675eefee25Smacallan		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
35685eefee25Smacallan		    case " $predeps $postdeps " in
35695eefee25Smacallan		    *" $i "*)
35705eefee25Smacallan		      newdeplibs="$newdeplibs $i"
35715eefee25Smacallan		      i=""
35725eefee25Smacallan		      ;;
35735eefee25Smacallan		    esac
35745eefee25Smacallan		  fi
35755eefee25Smacallan		  if test -n "$i" ; then
35765eefee25Smacallan		    libname=`eval \\$echo \"$libname_spec\"`
35775eefee25Smacallan		    deplib_matches=`eval \\$echo \"$library_names_spec\"`
35785eefee25Smacallan		    set dummy $deplib_matches
35795eefee25Smacallan		    deplib_match=$2
35805eefee25Smacallan		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
35815eefee25Smacallan		      newdeplibs="$newdeplibs $i"
35825eefee25Smacallan		    else
35835eefee25Smacallan		      droppeddeps=yes
35845eefee25Smacallan		      $echo
35855eefee25Smacallan		      $echo "*** Warning: dynamic linker does not accept needed library $i."
35865eefee25Smacallan		      $echo "*** I have the capability to make that library automatically link in when"
35875eefee25Smacallan		      $echo "*** you link to this library.  But I can only do this if you have a"
35885eefee25Smacallan		      $echo "*** shared version of the library, which you do not appear to have"
35895eefee25Smacallan		      $echo "*** because a test_compile did reveal that the linker did not use this one"
35905eefee25Smacallan		      $echo "*** as a dynamic dependency that programs can get resolved with at runtime."
35915eefee25Smacallan		    fi
35925eefee25Smacallan		  fi
35935eefee25Smacallan		else
35945eefee25Smacallan		  droppeddeps=yes
35955eefee25Smacallan		  $echo
35965eefee25Smacallan		  $echo "*** Warning!  Library $i is needed by this library but I was not able to"
35975eefee25Smacallan		  $echo "***  make it link in!  You will probably need to install it or some"
35985eefee25Smacallan		  $echo "*** library that it depends on before this library will be fully"
35995eefee25Smacallan		  $echo "*** functional.  Installing it before continuing would be even better."
36005eefee25Smacallan		fi
36015eefee25Smacallan	      else
36025eefee25Smacallan		newdeplibs="$newdeplibs $i"
36035eefee25Smacallan	      fi
36045eefee25Smacallan	    done
36055eefee25Smacallan	  fi
36065eefee25Smacallan	  ;;
36075eefee25Smacallan	file_magic*)
36085eefee25Smacallan	  set dummy $deplibs_check_method
36095eefee25Smacallan	  file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
36105eefee25Smacallan	  for a_deplib in $deplibs; do
36115eefee25Smacallan	    name=`expr $a_deplib : '-l\(.*\)'`
36125eefee25Smacallan	    # If $name is empty we are operating on a -L argument.
36135eefee25Smacallan            if test "$name" != "" && test  "$name" != "0"; then
36145eefee25Smacallan	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
36155eefee25Smacallan		case " $predeps $postdeps " in
36165eefee25Smacallan		*" $a_deplib "*)
36175eefee25Smacallan		  newdeplibs="$newdeplibs $a_deplib"
36185eefee25Smacallan		  a_deplib=""
36195eefee25Smacallan		  ;;
36205eefee25Smacallan		esac
36215eefee25Smacallan	      fi
36225eefee25Smacallan	      if test -n "$a_deplib" ; then
36235eefee25Smacallan		libname=`eval \\$echo \"$libname_spec\"`
36245eefee25Smacallan		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
36255eefee25Smacallan		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
36265eefee25Smacallan		  for potent_lib in $potential_libs; do
36275eefee25Smacallan		      # Follow soft links.
36285eefee25Smacallan		      if ls -lLd "$potent_lib" 2>/dev/null \
36295eefee25Smacallan			 | grep " -> " >/dev/null; then
36305eefee25Smacallan			continue
36315eefee25Smacallan		      fi
36325eefee25Smacallan		      # The statement above tries to avoid entering an
36335eefee25Smacallan		      # endless loop below, in case of cyclic links.
36345eefee25Smacallan		      # We might still enter an endless loop, since a link
36355eefee25Smacallan		      # loop can be closed while we follow links,
36365eefee25Smacallan		      # but so what?
36375eefee25Smacallan		      potlib="$potent_lib"
36385eefee25Smacallan		      while test -h "$potlib" 2>/dev/null; do
36395eefee25Smacallan			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
36405eefee25Smacallan			case $potliblink in
36415eefee25Smacallan			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
36425eefee25Smacallan			*) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
36435eefee25Smacallan			esac
36445eefee25Smacallan		      done
36455eefee25Smacallan		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
36465eefee25Smacallan			 | ${SED} 10q \
36475eefee25Smacallan			 | $EGREP "$file_magic_regex" > /dev/null; then
36485eefee25Smacallan			newdeplibs="$newdeplibs $a_deplib"
36495eefee25Smacallan			a_deplib=""
36505eefee25Smacallan			break 2
36515eefee25Smacallan		      fi
36525eefee25Smacallan		  done
36535eefee25Smacallan		done
36545eefee25Smacallan	      fi
36555eefee25Smacallan	      if test -n "$a_deplib" ; then
36565eefee25Smacallan		droppeddeps=yes
36575eefee25Smacallan		$echo
36585eefee25Smacallan		$echo "*** Warning: linker path does not have real file for library $a_deplib."
36595eefee25Smacallan		$echo "*** I have the capability to make that library automatically link in when"
36605eefee25Smacallan		$echo "*** you link to this library.  But I can only do this if you have a"
36615eefee25Smacallan		$echo "*** shared version of the library, which you do not appear to have"
36625eefee25Smacallan		$echo "*** because I did check the linker path looking for a file starting"
36635eefee25Smacallan		if test -z "$potlib" ; then
36645eefee25Smacallan		  $echo "*** with $libname but no candidates were found. (...for file magic test)"
36655eefee25Smacallan		else
36665eefee25Smacallan		  $echo "*** with $libname and none of the candidates passed a file format test"
36675eefee25Smacallan		  $echo "*** using a file magic. Last file checked: $potlib"
36685eefee25Smacallan		fi
36695eefee25Smacallan	      fi
36705eefee25Smacallan	    else
36715eefee25Smacallan	      # Add a -L argument.
36725eefee25Smacallan	      newdeplibs="$newdeplibs $a_deplib"
36735eefee25Smacallan	    fi
36745eefee25Smacallan	  done # Gone through all deplibs.
36755eefee25Smacallan	  ;;
36765eefee25Smacallan	match_pattern*)
36775eefee25Smacallan	  set dummy $deplibs_check_method
36785eefee25Smacallan	  match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
36795eefee25Smacallan	  for a_deplib in $deplibs; do
36805eefee25Smacallan	    name=`expr $a_deplib : '-l\(.*\)'`
36815eefee25Smacallan	    # If $name is empty we are operating on a -L argument.
36825eefee25Smacallan	    if test -n "$name" && test "$name" != "0"; then
36835eefee25Smacallan	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
36845eefee25Smacallan		case " $predeps $postdeps " in
36855eefee25Smacallan		*" $a_deplib "*)
36865eefee25Smacallan		  newdeplibs="$newdeplibs $a_deplib"
36875eefee25Smacallan		  a_deplib=""
36885eefee25Smacallan		  ;;
36895eefee25Smacallan		esac
36905eefee25Smacallan	      fi
36915eefee25Smacallan	      if test -n "$a_deplib" ; then
36925eefee25Smacallan		libname=`eval \\$echo \"$libname_spec\"`
36935eefee25Smacallan		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
36945eefee25Smacallan		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
36955eefee25Smacallan		  for potent_lib in $potential_libs; do
36965eefee25Smacallan		    potlib="$potent_lib" # see symlink-check above in file_magic test
36975eefee25Smacallan		    if eval $echo \"$potent_lib\" 2>/dev/null \
36985eefee25Smacallan		        | ${SED} 10q \
36995eefee25Smacallan		        | $EGREP "$match_pattern_regex" > /dev/null; then
37005eefee25Smacallan		      newdeplibs="$newdeplibs $a_deplib"
37015eefee25Smacallan		      a_deplib=""
37025eefee25Smacallan		      break 2
37035eefee25Smacallan		    fi
37045eefee25Smacallan		  done
37055eefee25Smacallan		done
37065eefee25Smacallan	      fi
37075eefee25Smacallan	      if test -n "$a_deplib" ; then
37085eefee25Smacallan		droppeddeps=yes
37095eefee25Smacallan		$echo
37105eefee25Smacallan		$echo "*** Warning: linker path does not have real file for library $a_deplib."
37115eefee25Smacallan		$echo "*** I have the capability to make that library automatically link in when"
37125eefee25Smacallan		$echo "*** you link to this library.  But I can only do this if you have a"
37135eefee25Smacallan		$echo "*** shared version of the library, which you do not appear to have"
37145eefee25Smacallan		$echo "*** because I did check the linker path looking for a file starting"
37155eefee25Smacallan		if test -z "$potlib" ; then
37165eefee25Smacallan		  $echo "*** with $libname but no candidates were found. (...for regex pattern test)"
37175eefee25Smacallan		else
37185eefee25Smacallan		  $echo "*** with $libname and none of the candidates passed a file format test"
37195eefee25Smacallan		  $echo "*** using a regex pattern. Last file checked: $potlib"
37205eefee25Smacallan		fi
37215eefee25Smacallan	      fi
37225eefee25Smacallan	    else
37235eefee25Smacallan	      # Add a -L argument.
37245eefee25Smacallan	      newdeplibs="$newdeplibs $a_deplib"
37255eefee25Smacallan	    fi
37265eefee25Smacallan	  done # Gone through all deplibs.
37275eefee25Smacallan	  ;;
37285eefee25Smacallan	none | unknown | *)
37295eefee25Smacallan	  newdeplibs=""
37305eefee25Smacallan	  tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
37315eefee25Smacallan	    -e 's/ -[LR][^ ]*//g'`
37325eefee25Smacallan	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
37335eefee25Smacallan	    for i in $predeps $postdeps ; do
37345eefee25Smacallan	      # can't use Xsed below, because $i might contain '/'
37355eefee25Smacallan	      tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"`
37365eefee25Smacallan	    done
37375eefee25Smacallan	  fi
37385eefee25Smacallan	  if $echo "X $tmp_deplibs" | $Xsed -e 's/[ 	]//g' \
37395eefee25Smacallan	    | grep . >/dev/null; then
37405eefee25Smacallan	    $echo
37415eefee25Smacallan	    if test "X$deplibs_check_method" = "Xnone"; then
37425eefee25Smacallan	      $echo "*** Warning: inter-library dependencies are not supported in this platform."
37435eefee25Smacallan	    else
37445eefee25Smacallan	      $echo "*** Warning: inter-library dependencies are not known to be supported."
37455eefee25Smacallan	    fi
37465eefee25Smacallan	    $echo "*** All declared inter-library dependencies are being dropped."
37475eefee25Smacallan	    droppeddeps=yes
37485eefee25Smacallan	  fi
37495eefee25Smacallan	  ;;
37505eefee25Smacallan	esac
37515eefee25Smacallan	versuffix=$versuffix_save
37525eefee25Smacallan	major=$major_save
37535eefee25Smacallan	release=$release_save
37545eefee25Smacallan	libname=$libname_save
37555eefee25Smacallan	name=$name_save
37565eefee25Smacallan
37575eefee25Smacallan	case $host in
37585eefee25Smacallan	*-*-rhapsody* | *-*-darwin1.[012])
37595eefee25Smacallan	  # On Rhapsody replace the C library is the System framework
37605eefee25Smacallan	  newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'`
37615eefee25Smacallan	  ;;
37625eefee25Smacallan	esac
37635eefee25Smacallan
37645eefee25Smacallan	if test "$droppeddeps" = yes; then
37655eefee25Smacallan	  if test "$module" = yes; then
37665eefee25Smacallan	    $echo
37675eefee25Smacallan	    $echo "*** Warning: libtool could not satisfy all declared inter-library"
37685eefee25Smacallan	    $echo "*** dependencies of module $libname.  Therefore, libtool will create"
37695eefee25Smacallan	    $echo "*** a static module, that should work as long as the dlopening"
37705eefee25Smacallan	    $echo "*** application is linked with the -dlopen flag."
37715eefee25Smacallan	    if test -z "$global_symbol_pipe"; then
37725eefee25Smacallan	      $echo
37735eefee25Smacallan	      $echo "*** However, this would only work if libtool was able to extract symbol"
37745eefee25Smacallan	      $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
37755eefee25Smacallan	      $echo "*** not find such a program.  So, this module is probably useless."
37765eefee25Smacallan	      $echo "*** \`nm' from GNU binutils and a full rebuild may help."
37775eefee25Smacallan	    fi
37785eefee25Smacallan	    if test "$build_old_libs" = no; then
37795eefee25Smacallan	      oldlibs="$output_objdir/$libname.$libext"
37805eefee25Smacallan	      build_libtool_libs=module
37815eefee25Smacallan	      build_old_libs=yes
37825eefee25Smacallan	    else
37835eefee25Smacallan	      build_libtool_libs=no
37845eefee25Smacallan	    fi
37855eefee25Smacallan	  else
37865eefee25Smacallan	    $echo "*** The inter-library dependencies that have been dropped here will be"
37875eefee25Smacallan	    $echo "*** automatically added whenever a program is linked with this library"
37885eefee25Smacallan	    $echo "*** or is declared to -dlopen it."
37895eefee25Smacallan
37905eefee25Smacallan	    if test "$allow_undefined" = no; then
37915eefee25Smacallan	      $echo
37925eefee25Smacallan	      $echo "*** Since this library must not contain undefined symbols,"
37935eefee25Smacallan	      $echo "*** because either the platform does not support them or"
37945eefee25Smacallan	      $echo "*** it was explicitly requested with -no-undefined,"
37955eefee25Smacallan	      $echo "*** libtool will only create a static version of it."
37965eefee25Smacallan	      if test "$build_old_libs" = no; then
37975eefee25Smacallan		oldlibs="$output_objdir/$libname.$libext"
37985eefee25Smacallan		build_libtool_libs=module
37995eefee25Smacallan		build_old_libs=yes
38005eefee25Smacallan	      else
38015eefee25Smacallan		build_libtool_libs=no
38025eefee25Smacallan	      fi
38035eefee25Smacallan	    fi
38045eefee25Smacallan	  fi
38055eefee25Smacallan	fi
38065eefee25Smacallan	# Done checking deplibs!
38075eefee25Smacallan	deplibs=$newdeplibs
38085eefee25Smacallan      fi
38095eefee25Smacallan
38105eefee25Smacallan
38115eefee25Smacallan      # move library search paths that coincide with paths to not yet
38125eefee25Smacallan      # installed libraries to the beginning of the library search list
38135eefee25Smacallan      new_libs=
38145eefee25Smacallan      for path in $notinst_path; do
38155eefee25Smacallan	case " $new_libs " in
38165eefee25Smacallan	*" -L$path/$objdir "*) ;;
38175eefee25Smacallan	*)
38185eefee25Smacallan	  case " $deplibs " in
38195eefee25Smacallan	  *" -L$path/$objdir "*)
38205eefee25Smacallan	    new_libs="$new_libs -L$path/$objdir" ;;
38215eefee25Smacallan	  esac
38225eefee25Smacallan	  ;;
38235eefee25Smacallan	esac
38245eefee25Smacallan      done
38255eefee25Smacallan      for deplib in $deplibs; do
38265eefee25Smacallan	case $deplib in
38275eefee25Smacallan	-L*)
38285eefee25Smacallan	  case " $new_libs " in
38295eefee25Smacallan	  *" $deplib "*) ;;
38305eefee25Smacallan	  *) new_libs="$new_libs $deplib" ;;
38315eefee25Smacallan	  esac
38325eefee25Smacallan	  ;;
38335eefee25Smacallan	*) new_libs="$new_libs $deplib" ;;
38345eefee25Smacallan	esac
38355eefee25Smacallan      done
38365eefee25Smacallan      deplibs="$new_libs"
38375eefee25Smacallan
38385eefee25Smacallan
38395eefee25Smacallan      # All the library-specific variables (install_libdir is set above).
38405eefee25Smacallan      library_names=
38415eefee25Smacallan      old_library=
38425eefee25Smacallan      dlname=
38435eefee25Smacallan
38445eefee25Smacallan      # Test again, we may have decided not to build it any more
38455eefee25Smacallan      if test "$build_libtool_libs" = yes; then
38465eefee25Smacallan	if test "$hardcode_into_libs" = yes; then
38475eefee25Smacallan	  # Hardcode the library paths
38485eefee25Smacallan	  hardcode_libdirs=
38495eefee25Smacallan	  dep_rpath=
38505eefee25Smacallan	  rpath="$finalize_rpath"
38515eefee25Smacallan	  test "$mode" != relink && rpath="$compile_rpath$rpath"
38525eefee25Smacallan	  for libdir in $rpath; do
38535eefee25Smacallan	    if test -n "$hardcode_libdir_flag_spec"; then
38545eefee25Smacallan	      if test -n "$hardcode_libdir_separator"; then
38555eefee25Smacallan		if test -z "$hardcode_libdirs"; then
38565eefee25Smacallan		  hardcode_libdirs="$libdir"
38575eefee25Smacallan		else
38585eefee25Smacallan		  # Just accumulate the unique libdirs.
38595eefee25Smacallan		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
38605eefee25Smacallan		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
38615eefee25Smacallan		    ;;
38625eefee25Smacallan		  *)
38635eefee25Smacallan		    hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
38645eefee25Smacallan		    ;;
38655eefee25Smacallan		  esac
38665eefee25Smacallan		fi
38675eefee25Smacallan	      else
38685eefee25Smacallan		eval flag=\"$hardcode_libdir_flag_spec\"
38695eefee25Smacallan		dep_rpath="$dep_rpath $flag"
38705eefee25Smacallan	      fi
38715eefee25Smacallan	    elif test -n "$runpath_var"; then
38725eefee25Smacallan	      case "$perm_rpath " in
38735eefee25Smacallan	      *" $libdir "*) ;;
38745eefee25Smacallan	      *) perm_rpath="$perm_rpath $libdir" ;;
38755eefee25Smacallan	      esac
38765eefee25Smacallan	    fi
38775eefee25Smacallan	  done
38785eefee25Smacallan	  # Substitute the hardcoded libdirs into the rpath.
38795eefee25Smacallan	  if test -n "$hardcode_libdir_separator" &&
38805eefee25Smacallan	     test -n "$hardcode_libdirs"; then
38815eefee25Smacallan	    libdir="$hardcode_libdirs"
38825eefee25Smacallan	    if test -n "$hardcode_libdir_flag_spec_ld"; then
38835eefee25Smacallan	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
38845eefee25Smacallan	    else
38855eefee25Smacallan	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
38865eefee25Smacallan	    fi
38875eefee25Smacallan	  fi
38885eefee25Smacallan	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
38895eefee25Smacallan	    # We should set the runpath_var.
38905eefee25Smacallan	    rpath=
38915eefee25Smacallan	    for dir in $perm_rpath; do
38925eefee25Smacallan	      rpath="$rpath$dir:"
38935eefee25Smacallan	    done
38945eefee25Smacallan	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
38955eefee25Smacallan	  fi
38965eefee25Smacallan	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
38975eefee25Smacallan	fi
38985eefee25Smacallan
38995eefee25Smacallan	shlibpath="$finalize_shlibpath"
39005eefee25Smacallan	test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
39015eefee25Smacallan	if test -n "$shlibpath"; then
39025eefee25Smacallan	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
39035eefee25Smacallan	fi
39045eefee25Smacallan
39055eefee25Smacallan	# Get the real and link names of the library.
39065eefee25Smacallan	eval shared_ext=\"$shrext_cmds\"
39075eefee25Smacallan	eval library_names=\"$library_names_spec\"
39085eefee25Smacallan	set dummy $library_names
39095eefee25Smacallan	realname="$2"
39105eefee25Smacallan	shift; shift
39115eefee25Smacallan
39125eefee25Smacallan	if test -n "$soname_spec"; then
39135eefee25Smacallan	  eval soname=\"$soname_spec\"
39145eefee25Smacallan	else
39155eefee25Smacallan	  soname="$realname"
39165eefee25Smacallan	fi
39175eefee25Smacallan	if test -z "$dlname"; then
39185eefee25Smacallan	  dlname=$soname
39195eefee25Smacallan	fi
39205eefee25Smacallan
39215eefee25Smacallan	lib="$output_objdir/$realname"
39225eefee25Smacallan	linknames=
39235eefee25Smacallan	for link
39245eefee25Smacallan	do
39255eefee25Smacallan	  linknames="$linknames $link"
39265eefee25Smacallan	done
39275eefee25Smacallan
39285eefee25Smacallan	# Use standard objects if they are pic
39295eefee25Smacallan	test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
39305eefee25Smacallan
39315eefee25Smacallan	# Prepare the list of exported symbols
39325eefee25Smacallan	if test -z "$export_symbols"; then
39335eefee25Smacallan	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
39345eefee25Smacallan	    $show "generating symbol list for \`$libname.la'"
39355eefee25Smacallan	    export_symbols="$output_objdir/$libname.exp"
39365eefee25Smacallan	    $run $rm $export_symbols
39375eefee25Smacallan	    cmds=$export_symbols_cmds
39385eefee25Smacallan	    save_ifs="$IFS"; IFS='~'
39395eefee25Smacallan	    for cmd in $cmds; do
39405eefee25Smacallan	      IFS="$save_ifs"
39415eefee25Smacallan	      eval cmd=\"$cmd\"
39425eefee25Smacallan	      if len=`expr "X$cmd" : ".*"` &&
39435eefee25Smacallan	       test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
39445eefee25Smacallan	        $show "$cmd"
39455eefee25Smacallan	        $run eval "$cmd" || exit $?
39465eefee25Smacallan	        skipped_export=false
39475eefee25Smacallan	      else
39485eefee25Smacallan	        # The command line is too long to execute in one step.
39495eefee25Smacallan	        $show "using reloadable object file for export list..."
39505eefee25Smacallan	        skipped_export=:
39515eefee25Smacallan		# Break out early, otherwise skipped_export may be
39525eefee25Smacallan		# set to false by a later but shorter cmd.
39535eefee25Smacallan		break
39545eefee25Smacallan	      fi
39555eefee25Smacallan	    done
39565eefee25Smacallan	    IFS="$save_ifs"
39575eefee25Smacallan	    if test -n "$export_symbols_regex"; then
39585eefee25Smacallan	      $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""
39595eefee25Smacallan	      $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
39605eefee25Smacallan	      $show "$mv \"${export_symbols}T\" \"$export_symbols\""
39615eefee25Smacallan	      $run eval '$mv "${export_symbols}T" "$export_symbols"'
39625eefee25Smacallan	    fi
39635eefee25Smacallan	  fi
39645eefee25Smacallan	fi
39655eefee25Smacallan
39665eefee25Smacallan	if test -n "$export_symbols" && test -n "$include_expsyms"; then
39675eefee25Smacallan	  $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"'
39685eefee25Smacallan	fi
39695eefee25Smacallan
39705eefee25Smacallan	tmp_deplibs=
39715eefee25Smacallan	for test_deplib in $deplibs; do
39725eefee25Smacallan		case " $convenience " in
39735eefee25Smacallan		*" $test_deplib "*) ;;
39745eefee25Smacallan		*)
39755eefee25Smacallan			tmp_deplibs="$tmp_deplibs $test_deplib"
39765eefee25Smacallan			;;
39775eefee25Smacallan		esac
39785eefee25Smacallan	done
39795eefee25Smacallan	deplibs="$tmp_deplibs"
39805eefee25Smacallan
39815eefee25Smacallan	if test -n "$convenience"; then
39825eefee25Smacallan	  if test -n "$whole_archive_flag_spec"; then
39835eefee25Smacallan	    save_libobjs=$libobjs
39845eefee25Smacallan	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
39855eefee25Smacallan	  else
39865eefee25Smacallan	    gentop="$output_objdir/${outputname}x"
39875eefee25Smacallan	    generated="$generated $gentop"
39885eefee25Smacallan
39895eefee25Smacallan	    func_extract_archives $gentop $convenience
39905eefee25Smacallan	    libobjs="$libobjs $func_extract_archives_result"
39915eefee25Smacallan	  fi
39925eefee25Smacallan	fi
39935eefee25Smacallan	
39945eefee25Smacallan	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
39955eefee25Smacallan	  eval flag=\"$thread_safe_flag_spec\"
39965eefee25Smacallan	  linker_flags="$linker_flags $flag"
39975eefee25Smacallan	fi
39985eefee25Smacallan
39995eefee25Smacallan	# Make a backup of the uninstalled library when relinking
40005eefee25Smacallan	if test "$mode" = relink; then
40015eefee25Smacallan	  $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $?
40025eefee25Smacallan	fi
40035eefee25Smacallan
40045eefee25Smacallan	# Do each of the archive commands.
40055eefee25Smacallan	if test "$module" = yes && test -n "$module_cmds" ; then
40065eefee25Smacallan	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
40075eefee25Smacallan	    eval test_cmds=\"$module_expsym_cmds\"
40085eefee25Smacallan	    cmds=$module_expsym_cmds
40095eefee25Smacallan	  else
40105eefee25Smacallan	    eval test_cmds=\"$module_cmds\"
40115eefee25Smacallan	    cmds=$module_cmds
40125eefee25Smacallan	  fi
40135eefee25Smacallan	else
40145eefee25Smacallan	if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
40155eefee25Smacallan	  eval test_cmds=\"$archive_expsym_cmds\"
40165eefee25Smacallan	  cmds=$archive_expsym_cmds
40175eefee25Smacallan	else
40185eefee25Smacallan	  eval test_cmds=\"$archive_cmds\"
40195eefee25Smacallan	  cmds=$archive_cmds
40205eefee25Smacallan	  fi
40215eefee25Smacallan	fi
40225eefee25Smacallan
40235eefee25Smacallan	if test "X$skipped_export" != "X:" &&
40245eefee25Smacallan	   len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
40255eefee25Smacallan	   test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
40265eefee25Smacallan	  :
40275eefee25Smacallan	else
40285eefee25Smacallan	  # The command line is too long to link in one step, link piecewise.
40295eefee25Smacallan	  $echo "creating reloadable object files..."
40305eefee25Smacallan
40315eefee25Smacallan	  # Save the value of $output and $libobjs because we want to
40325eefee25Smacallan	  # use them later.  If we have whole_archive_flag_spec, we
40335eefee25Smacallan	  # want to use save_libobjs as it was before
40345eefee25Smacallan	  # whole_archive_flag_spec was expanded, because we can't
40355eefee25Smacallan	  # assume the linker understands whole_archive_flag_spec.
40365eefee25Smacallan	  # This may have to be revisited, in case too many
40375eefee25Smacallan	  # convenience libraries get linked in and end up exceeding
40385eefee25Smacallan	  # the spec.
40395eefee25Smacallan	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
40405eefee25Smacallan	    save_libobjs=$libobjs
40415eefee25Smacallan	  fi
40425eefee25Smacallan	  save_output=$output
40435eefee25Smacallan	  output_la=`$echo "X$output" | $Xsed -e "$basename"`
40445eefee25Smacallan
40455eefee25Smacallan	  # Clear the reloadable object creation command queue and
40465eefee25Smacallan	  # initialize k to one.
40475eefee25Smacallan	  test_cmds=
40485eefee25Smacallan	  concat_cmds=
40495eefee25Smacallan	  objlist=
40505eefee25Smacallan	  delfiles=
40515eefee25Smacallan	  last_robj=
40525eefee25Smacallan	  k=1
40535eefee25Smacallan	  output=$output_objdir/$output_la-${k}.$objext
40545eefee25Smacallan	  # Loop over the list of objects to be linked.
40555eefee25Smacallan	  for obj in $save_libobjs
40565eefee25Smacallan	  do
40575eefee25Smacallan	    eval test_cmds=\"$reload_cmds $objlist $last_robj\"
40585eefee25Smacallan	    if test "X$objlist" = X ||
40595eefee25Smacallan	       { len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
40605eefee25Smacallan		 test "$len" -le "$max_cmd_len"; }; then
40615eefee25Smacallan	      objlist="$objlist $obj"
40625eefee25Smacallan	    else
40635eefee25Smacallan	      # The command $test_cmds is almost too long, add a
40645eefee25Smacallan	      # command to the queue.
40655eefee25Smacallan	      if test "$k" -eq 1 ; then
40665eefee25Smacallan		# The first file doesn't have a previous command to add.
40675eefee25Smacallan		eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
40685eefee25Smacallan	      else
40695eefee25Smacallan		# All subsequent reloadable object files will link in
40705eefee25Smacallan		# the last one created.
40715eefee25Smacallan		eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\"
40725eefee25Smacallan	      fi
40735eefee25Smacallan	      last_robj=$output_objdir/$output_la-${k}.$objext
40745eefee25Smacallan	      k=`expr $k + 1`
40755eefee25Smacallan	      output=$output_objdir/$output_la-${k}.$objext
40765eefee25Smacallan	      objlist=$obj
40775eefee25Smacallan	      len=1
40785eefee25Smacallan	    fi
40795eefee25Smacallan	  done
40805eefee25Smacallan	  # Handle the remaining objects by creating one last
40815eefee25Smacallan	  # reloadable object file.  All subsequent reloadable object
40825eefee25Smacallan	  # files will link in the last one created.
40835eefee25Smacallan	  test -z "$concat_cmds" || concat_cmds=$concat_cmds~
40845eefee25Smacallan	  eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
40855eefee25Smacallan
40865eefee25Smacallan	  if ${skipped_export-false}; then
40875eefee25Smacallan	    $show "generating symbol list for \`$libname.la'"
40885eefee25Smacallan	    export_symbols="$output_objdir/$libname.exp"
40895eefee25Smacallan	    $run $rm $export_symbols
40905eefee25Smacallan	    libobjs=$output
40915eefee25Smacallan	    # Append the command to create the export file.
40925eefee25Smacallan	    eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\"
40935eefee25Smacallan          fi
40945eefee25Smacallan
40955eefee25Smacallan	  # Set up a command to remove the reloadable object files
40965eefee25Smacallan	  # after they are used.
40975eefee25Smacallan	  i=0
40985eefee25Smacallan	  while test "$i" -lt "$k"
40995eefee25Smacallan	  do
41005eefee25Smacallan	    i=`expr $i + 1`
41015eefee25Smacallan	    delfiles="$delfiles $output_objdir/$output_la-${i}.$objext"
41025eefee25Smacallan	  done
41035eefee25Smacallan
41045eefee25Smacallan	  $echo "creating a temporary reloadable object file: $output"
41055eefee25Smacallan
41065eefee25Smacallan	  # Loop through the commands generated above and execute them.
41075eefee25Smacallan	  save_ifs="$IFS"; IFS='~'
41085eefee25Smacallan	  for cmd in $concat_cmds; do
41095eefee25Smacallan	    IFS="$save_ifs"
41105eefee25Smacallan	    $show "$cmd"
41115eefee25Smacallan	    $run eval "$cmd" || exit $?
41125eefee25Smacallan	  done
41135eefee25Smacallan	  IFS="$save_ifs"
41145eefee25Smacallan
41155eefee25Smacallan	  libobjs=$output
41165eefee25Smacallan	  # Restore the value of output.
41175eefee25Smacallan	  output=$save_output
41185eefee25Smacallan
41195eefee25Smacallan	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
41205eefee25Smacallan	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
41215eefee25Smacallan	  fi
41225eefee25Smacallan	  # Expand the library linking commands again to reset the
41235eefee25Smacallan	  # value of $libobjs for piecewise linking.
41245eefee25Smacallan
41255eefee25Smacallan	  # Do each of the archive commands.
41265eefee25Smacallan	  if test "$module" = yes && test -n "$module_cmds" ; then
41275eefee25Smacallan	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
41285eefee25Smacallan	      cmds=$module_expsym_cmds
41295eefee25Smacallan	    else
41305eefee25Smacallan	      cmds=$module_cmds
41315eefee25Smacallan	    fi
41325eefee25Smacallan	  else
41335eefee25Smacallan	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
41345eefee25Smacallan	    cmds=$archive_expsym_cmds
41355eefee25Smacallan	  else
41365eefee25Smacallan	    cmds=$archive_cmds
41375eefee25Smacallan	    fi
41385eefee25Smacallan	  fi
41395eefee25Smacallan
41405eefee25Smacallan	  # Append the command to remove the reloadable object files
41415eefee25Smacallan	  # to the just-reset $cmds.
41425eefee25Smacallan	  eval cmds=\"\$cmds~\$rm $delfiles\"
41435eefee25Smacallan	fi
41445eefee25Smacallan	save_ifs="$IFS"; IFS='~'
41455eefee25Smacallan	for cmd in $cmds; do
41465eefee25Smacallan	  IFS="$save_ifs"
41475eefee25Smacallan	  eval cmd=\"$cmd\"
41485eefee25Smacallan	  $show "$cmd"
41495eefee25Smacallan	  $run eval "$cmd" || {
41505eefee25Smacallan	    lt_exit=$?
41515eefee25Smacallan
41525eefee25Smacallan	    # Restore the uninstalled library and exit
41535eefee25Smacallan	    if test "$mode" = relink; then
41545eefee25Smacallan	      $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
41555eefee25Smacallan	    fi
41565eefee25Smacallan
41575eefee25Smacallan	    exit $lt_exit
41585eefee25Smacallan	  }
41595eefee25Smacallan	done
41605eefee25Smacallan	IFS="$save_ifs"
41615eefee25Smacallan
41625eefee25Smacallan	# Restore the uninstalled library and exit
41635eefee25Smacallan	if test "$mode" = relink; then
41645eefee25Smacallan	  $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $?
41655eefee25Smacallan
41665eefee25Smacallan	  if test -n "$convenience"; then
41675eefee25Smacallan	    if test -z "$whole_archive_flag_spec"; then
41685eefee25Smacallan	      $show "${rm}r $gentop"
41695eefee25Smacallan	      $run ${rm}r "$gentop"
41705eefee25Smacallan	    fi
41715eefee25Smacallan	  fi
41725eefee25Smacallan
41735eefee25Smacallan	  exit $EXIT_SUCCESS
41745eefee25Smacallan	fi
41755eefee25Smacallan
41765eefee25Smacallan	# Create links to the real library.
41775eefee25Smacallan	for linkname in $linknames; do
41785eefee25Smacallan	  if test "$realname" != "$linkname"; then
41795eefee25Smacallan	    $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)"
41805eefee25Smacallan	    $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $?
41815eefee25Smacallan	  fi
41825eefee25Smacallan	done
41835eefee25Smacallan
41845eefee25Smacallan	# If -module or -export-dynamic was specified, set the dlname.
41855eefee25Smacallan	if test "$module" = yes || test "$export_dynamic" = yes; then
41865eefee25Smacallan	  # On all known operating systems, these are identical.
41875eefee25Smacallan	  dlname="$soname"
41885eefee25Smacallan	fi
41895eefee25Smacallan      fi
41905eefee25Smacallan      ;;
41915eefee25Smacallan
41925eefee25Smacallan    obj)
41935eefee25Smacallan      if test -n "$deplibs"; then
41945eefee25Smacallan	$echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2
41955eefee25Smacallan      fi
41965eefee25Smacallan
41975eefee25Smacallan      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
41985eefee25Smacallan	$echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
41995eefee25Smacallan      fi
42005eefee25Smacallan
42015eefee25Smacallan      if test -n "$rpath"; then
42025eefee25Smacallan	$echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2
42035eefee25Smacallan      fi
42045eefee25Smacallan
42055eefee25Smacallan      if test -n "$xrpath"; then
42065eefee25Smacallan	$echo "$modename: warning: \`-R' is ignored for objects" 1>&2
42075eefee25Smacallan      fi
42085eefee25Smacallan
42095eefee25Smacallan      if test -n "$vinfo"; then
42105eefee25Smacallan	$echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2
42115eefee25Smacallan      fi
42125eefee25Smacallan
42135eefee25Smacallan      if test -n "$release"; then
42145eefee25Smacallan	$echo "$modename: warning: \`-release' is ignored for objects" 1>&2
42155eefee25Smacallan      fi
42165eefee25Smacallan
42175eefee25Smacallan      case $output in
42185eefee25Smacallan      *.lo)
42195eefee25Smacallan	if test -n "$objs$old_deplibs"; then
42205eefee25Smacallan	  $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
42215eefee25Smacallan	  exit $EXIT_FAILURE
42225eefee25Smacallan	fi
42235eefee25Smacallan	libobj="$output"
42245eefee25Smacallan	obj=`$echo "X$output" | $Xsed -e "$lo2o"`
42255eefee25Smacallan	;;
42265eefee25Smacallan      *)
42275eefee25Smacallan	libobj=
42285eefee25Smacallan	obj="$output"
42295eefee25Smacallan	;;
42305eefee25Smacallan      esac
42315eefee25Smacallan
42325eefee25Smacallan      # Delete the old objects.
42335eefee25Smacallan      $run $rm $obj $libobj
42345eefee25Smacallan
42355eefee25Smacallan      # Objects from convenience libraries.  This assumes
42365eefee25Smacallan      # single-version convenience libraries.  Whenever we create
42375eefee25Smacallan      # different ones for PIC/non-PIC, this we'll have to duplicate
42385eefee25Smacallan      # the extraction.
42395eefee25Smacallan      reload_conv_objs=
42405eefee25Smacallan      gentop=
42415eefee25Smacallan      # reload_cmds runs $LD directly, so let us get rid of
42425eefee25Smacallan      # -Wl from whole_archive_flag_spec
42435eefee25Smacallan      wl=
42445eefee25Smacallan
42455eefee25Smacallan      if test -n "$convenience"; then
42465eefee25Smacallan	if test -n "$whole_archive_flag_spec"; then
42475eefee25Smacallan	  eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
42485eefee25Smacallan	else
42495eefee25Smacallan	  gentop="$output_objdir/${obj}x"
42505eefee25Smacallan	  generated="$generated $gentop"
42515eefee25Smacallan
42525eefee25Smacallan	  func_extract_archives $gentop $convenience
42535eefee25Smacallan	  reload_conv_objs="$reload_objs $func_extract_archives_result"
42545eefee25Smacallan	fi
42555eefee25Smacallan      fi
42565eefee25Smacallan
42575eefee25Smacallan      # Create the old-style object.
42585eefee25Smacallan      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
42595eefee25Smacallan
42605eefee25Smacallan      output="$obj"
42615eefee25Smacallan      cmds=$reload_cmds
42625eefee25Smacallan      save_ifs="$IFS"; IFS='~'
42635eefee25Smacallan      for cmd in $cmds; do
42645eefee25Smacallan	IFS="$save_ifs"
42655eefee25Smacallan	eval cmd=\"$cmd\"
42665eefee25Smacallan	$show "$cmd"
42675eefee25Smacallan	$run eval "$cmd" || exit $?
42685eefee25Smacallan      done
42695eefee25Smacallan      IFS="$save_ifs"
42705eefee25Smacallan
42715eefee25Smacallan      # Exit if we aren't doing a library object file.
42725eefee25Smacallan      if test -z "$libobj"; then
42735eefee25Smacallan	if test -n "$gentop"; then
42745eefee25Smacallan	  $show "${rm}r $gentop"
42755eefee25Smacallan	  $run ${rm}r $gentop
42765eefee25Smacallan	fi
42775eefee25Smacallan
42785eefee25Smacallan	exit $EXIT_SUCCESS
42795eefee25Smacallan      fi
42805eefee25Smacallan
42815eefee25Smacallan      if test "$build_libtool_libs" != yes; then
42825eefee25Smacallan	if test -n "$gentop"; then
42835eefee25Smacallan	  $show "${rm}r $gentop"
42845eefee25Smacallan	  $run ${rm}r $gentop
42855eefee25Smacallan	fi
42865eefee25Smacallan
42875eefee25Smacallan	# Create an invalid libtool object if no PIC, so that we don't
42885eefee25Smacallan	# accidentally link it into a program.
42895eefee25Smacallan	# $show "echo timestamp > $libobj"
42905eefee25Smacallan	# $run eval "echo timestamp > $libobj" || exit $?
42915eefee25Smacallan	exit $EXIT_SUCCESS
42925eefee25Smacallan      fi
42935eefee25Smacallan
42945eefee25Smacallan      if test -n "$pic_flag" || test "$pic_mode" != default; then
42955eefee25Smacallan	# Only do commands if we really have different PIC objects.
42965eefee25Smacallan	reload_objs="$libobjs $reload_conv_objs"
42975eefee25Smacallan	output="$libobj"
42985eefee25Smacallan	cmds=$reload_cmds
42995eefee25Smacallan	save_ifs="$IFS"; IFS='~'
43005eefee25Smacallan	for cmd in $cmds; do
43015eefee25Smacallan	  IFS="$save_ifs"
43025eefee25Smacallan	  eval cmd=\"$cmd\"
43035eefee25Smacallan	  $show "$cmd"
43045eefee25Smacallan	  $run eval "$cmd" || exit $?
43055eefee25Smacallan	done
43065eefee25Smacallan	IFS="$save_ifs"
43075eefee25Smacallan      fi
43085eefee25Smacallan
43095eefee25Smacallan      if test -n "$gentop"; then
43105eefee25Smacallan	$show "${rm}r $gentop"
43115eefee25Smacallan	$run ${rm}r $gentop
43125eefee25Smacallan      fi
43135eefee25Smacallan
43145eefee25Smacallan      exit $EXIT_SUCCESS
43155eefee25Smacallan      ;;
43165eefee25Smacallan
43175eefee25Smacallan    prog)
43185eefee25Smacallan      case $host in
43195eefee25Smacallan	*cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;
43205eefee25Smacallan      esac
43215eefee25Smacallan      if test -n "$vinfo"; then
43225eefee25Smacallan	$echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
43235eefee25Smacallan      fi
43245eefee25Smacallan
43255eefee25Smacallan      if test -n "$release"; then
43265eefee25Smacallan	$echo "$modename: warning: \`-release' is ignored for programs" 1>&2
43275eefee25Smacallan      fi
43285eefee25Smacallan
43295eefee25Smacallan      if test "$preload" = yes; then
43305eefee25Smacallan	if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown &&
43315eefee25Smacallan	   test "$dlopen_self_static" = unknown; then
43325eefee25Smacallan	  $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support."
43335eefee25Smacallan	fi
43345eefee25Smacallan      fi
43355eefee25Smacallan
43365eefee25Smacallan      case $host in
43375eefee25Smacallan      *-*-rhapsody* | *-*-darwin1.[012])
43385eefee25Smacallan	# On Rhapsody replace the C library is the System framework
43395eefee25Smacallan	compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
43405eefee25Smacallan	finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
43415eefee25Smacallan	;;
43425eefee25Smacallan      esac
43435eefee25Smacallan
43445eefee25Smacallan      case $host in
43455eefee25Smacallan      *darwin*)
43465eefee25Smacallan        # Don't allow lazy linking, it breaks C++ global constructors
43475eefee25Smacallan        if test "$tagname" = CXX ; then
43485eefee25Smacallan        compile_command="$compile_command ${wl}-bind_at_load"
43495eefee25Smacallan        finalize_command="$finalize_command ${wl}-bind_at_load"
43505eefee25Smacallan        fi
43515eefee25Smacallan        ;;
43525eefee25Smacallan      esac
43535eefee25Smacallan
43545eefee25Smacallan
43555eefee25Smacallan      # move library search paths that coincide with paths to not yet
43565eefee25Smacallan      # installed libraries to the beginning of the library search list
43575eefee25Smacallan      new_libs=
43585eefee25Smacallan      for path in $notinst_path; do
43595eefee25Smacallan	case " $new_libs " in
43605eefee25Smacallan	*" -L$path/$objdir "*) ;;
43615eefee25Smacallan	*)
43625eefee25Smacallan	  case " $compile_deplibs " in
43635eefee25Smacallan	  *" -L$path/$objdir "*)
43645eefee25Smacallan	    new_libs="$new_libs -L$path/$objdir" ;;
43655eefee25Smacallan	  esac
43665eefee25Smacallan	  ;;
43675eefee25Smacallan	esac
43685eefee25Smacallan      done
43695eefee25Smacallan      for deplib in $compile_deplibs; do
43705eefee25Smacallan	case $deplib in
43715eefee25Smacallan	-L*)
43725eefee25Smacallan	  case " $new_libs " in
43735eefee25Smacallan	  *" $deplib "*) ;;
43745eefee25Smacallan	  *) new_libs="$new_libs $deplib" ;;
43755eefee25Smacallan	  esac
43765eefee25Smacallan	  ;;
43775eefee25Smacallan	*) new_libs="$new_libs $deplib" ;;
43785eefee25Smacallan	esac
43795eefee25Smacallan      done
43805eefee25Smacallan      compile_deplibs="$new_libs"
43815eefee25Smacallan
43825eefee25Smacallan
43835eefee25Smacallan      compile_command="$compile_command $compile_deplibs"
43845eefee25Smacallan      finalize_command="$finalize_command $finalize_deplibs"
43855eefee25Smacallan
43865eefee25Smacallan      if test -n "$rpath$xrpath"; then
43875eefee25Smacallan	# If the user specified any rpath flags, then add them.
43885eefee25Smacallan	for libdir in $rpath $xrpath; do
43895eefee25Smacallan	  # This is the magic to use -rpath.
43905eefee25Smacallan	  case "$finalize_rpath " in
43915eefee25Smacallan	  *" $libdir "*) ;;
43925eefee25Smacallan	  *) finalize_rpath="$finalize_rpath $libdir" ;;
43935eefee25Smacallan	  esac
43945eefee25Smacallan	done
43955eefee25Smacallan      fi
43965eefee25Smacallan
43975eefee25Smacallan      # Now hardcode the library paths
43985eefee25Smacallan      rpath=
43995eefee25Smacallan      hardcode_libdirs=
44005eefee25Smacallan      for libdir in $compile_rpath $finalize_rpath; do
44015eefee25Smacallan	if test -n "$hardcode_libdir_flag_spec"; then
44025eefee25Smacallan	  if test -n "$hardcode_libdir_separator"; then
44035eefee25Smacallan	    if test -z "$hardcode_libdirs"; then
44045eefee25Smacallan	      hardcode_libdirs="$libdir"
44055eefee25Smacallan	    else
44065eefee25Smacallan	      # Just accumulate the unique libdirs.
44075eefee25Smacallan	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
44085eefee25Smacallan	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
44095eefee25Smacallan		;;
44105eefee25Smacallan	      *)
44115eefee25Smacallan		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
44125eefee25Smacallan		;;
44135eefee25Smacallan	      esac
44145eefee25Smacallan	    fi
44155eefee25Smacallan	  else
44165eefee25Smacallan	    eval flag=\"$hardcode_libdir_flag_spec\"
44175eefee25Smacallan	    rpath="$rpath $flag"
44185eefee25Smacallan	  fi
44195eefee25Smacallan	elif test -n "$runpath_var"; then
44205eefee25Smacallan	  case "$perm_rpath " in
44215eefee25Smacallan	  *" $libdir "*) ;;
44225eefee25Smacallan	  *) perm_rpath="$perm_rpath $libdir" ;;
44235eefee25Smacallan	  esac
44245eefee25Smacallan	fi
44255eefee25Smacallan	case $host in
44265eefee25Smacallan	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
44275eefee25Smacallan	  testbindir=`$echo "X$libdir" | $Xsed -e 's*/lib$*/bin*'`
44285eefee25Smacallan	  case :$dllsearchpath: in
44295eefee25Smacallan	  *":$libdir:"*) ;;
44305eefee25Smacallan	  *) dllsearchpath="$dllsearchpath:$libdir";;
44315eefee25Smacallan	  esac
44325eefee25Smacallan	  case :$dllsearchpath: in
44335eefee25Smacallan	  *":$testbindir:"*) ;;
44345eefee25Smacallan	  *) dllsearchpath="$dllsearchpath:$testbindir";;
44355eefee25Smacallan	  esac
44365eefee25Smacallan	  ;;
44375eefee25Smacallan	esac
44385eefee25Smacallan      done
44395eefee25Smacallan      # Substitute the hardcoded libdirs into the rpath.
44405eefee25Smacallan      if test -n "$hardcode_libdir_separator" &&
44415eefee25Smacallan	 test -n "$hardcode_libdirs"; then
44425eefee25Smacallan	libdir="$hardcode_libdirs"
44435eefee25Smacallan	eval rpath=\" $hardcode_libdir_flag_spec\"
44445eefee25Smacallan      fi
44455eefee25Smacallan      compile_rpath="$rpath"
44465eefee25Smacallan
44475eefee25Smacallan      rpath=
44485eefee25Smacallan      hardcode_libdirs=
44495eefee25Smacallan      for libdir in $finalize_rpath; do
44505eefee25Smacallan	if test -n "$hardcode_libdir_flag_spec"; then
44515eefee25Smacallan	  if test -n "$hardcode_libdir_separator"; then
44525eefee25Smacallan	    if test -z "$hardcode_libdirs"; then
44535eefee25Smacallan	      hardcode_libdirs="$libdir"
44545eefee25Smacallan	    else
44555eefee25Smacallan	      # Just accumulate the unique libdirs.
44565eefee25Smacallan	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
44575eefee25Smacallan	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
44585eefee25Smacallan		;;
44595eefee25Smacallan	      *)
44605eefee25Smacallan		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
44615eefee25Smacallan		;;
44625eefee25Smacallan	      esac
44635eefee25Smacallan	    fi
44645eefee25Smacallan	  else
44655eefee25Smacallan	    eval flag=\"$hardcode_libdir_flag_spec\"
44665eefee25Smacallan	    rpath="$rpath $flag"
44675eefee25Smacallan	  fi
44685eefee25Smacallan	elif test -n "$runpath_var"; then
44695eefee25Smacallan	  case "$finalize_perm_rpath " in
44705eefee25Smacallan	  *" $libdir "*) ;;
44715eefee25Smacallan	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
44725eefee25Smacallan	  esac
44735eefee25Smacallan	fi
44745eefee25Smacallan      done
44755eefee25Smacallan      # Substitute the hardcoded libdirs into the rpath.
44765eefee25Smacallan      if test -n "$hardcode_libdir_separator" &&
44775eefee25Smacallan	 test -n "$hardcode_libdirs"; then
44785eefee25Smacallan	libdir="$hardcode_libdirs"
44795eefee25Smacallan	eval rpath=\" $hardcode_libdir_flag_spec\"
44805eefee25Smacallan      fi
44815eefee25Smacallan      finalize_rpath="$rpath"
44825eefee25Smacallan
44835eefee25Smacallan      if test -n "$libobjs" && test "$build_old_libs" = yes; then
44845eefee25Smacallan	# Transform all the library objects into standard objects.
44855eefee25Smacallan	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
44865eefee25Smacallan	finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
44875eefee25Smacallan      fi
44885eefee25Smacallan
44895eefee25Smacallan      dlsyms=
44905eefee25Smacallan      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
44915eefee25Smacallan	if test -n "$NM" && test -n "$global_symbol_pipe"; then
44925eefee25Smacallan	  dlsyms="${outputname}S.c"
44935eefee25Smacallan	else
44945eefee25Smacallan	  $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2
44955eefee25Smacallan	fi
44965eefee25Smacallan      fi
44975eefee25Smacallan
44985eefee25Smacallan      if test -n "$dlsyms"; then
44995eefee25Smacallan	case $dlsyms in
45005eefee25Smacallan	"") ;;
45015eefee25Smacallan	*.c)
45025eefee25Smacallan	  # Discover the nlist of each of the dlfiles.
45035eefee25Smacallan	  nlist="$output_objdir/${outputname}.nm"
45045eefee25Smacallan
45055eefee25Smacallan	  $show "$rm $nlist ${nlist}S ${nlist}T"
45065eefee25Smacallan	  $run $rm "$nlist" "${nlist}S" "${nlist}T"
45075eefee25Smacallan
45085eefee25Smacallan	  # Parse the name list into a source file.
45095eefee25Smacallan	  $show "creating $output_objdir/$dlsyms"
45105eefee25Smacallan
45115eefee25Smacallan	  test -z "$run" && $echo > "$output_objdir/$dlsyms" "\
45125eefee25Smacallan/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */
45135eefee25Smacallan/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */
45145eefee25Smacallan
45155eefee25Smacallan#ifdef __cplusplus
45165eefee25Smacallanextern \"C\" {
45175eefee25Smacallan#endif
45185eefee25Smacallan
45195eefee25Smacallan/* Prevent the only kind of declaration conflicts we can make. */
45205eefee25Smacallan#define lt_preloaded_symbols some_other_symbol
45215eefee25Smacallan
45225eefee25Smacallan/* External symbol declarations for the compiler. */\
45235eefee25Smacallan"
45245eefee25Smacallan
45255eefee25Smacallan	  if test "$dlself" = yes; then
45265eefee25Smacallan	    $show "generating symbol list for \`$output'"
45275eefee25Smacallan
45285eefee25Smacallan	    test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist"
45295eefee25Smacallan
45305eefee25Smacallan	    # Add our own program objects to the symbol list.
45315eefee25Smacallan	    progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
45325eefee25Smacallan	    for arg in $progfiles; do
45335eefee25Smacallan	      $show "extracting global C symbols from \`$arg'"
45345eefee25Smacallan	      $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
45355eefee25Smacallan	    done
45365eefee25Smacallan
45375eefee25Smacallan	    if test -n "$exclude_expsyms"; then
45385eefee25Smacallan	      $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
45395eefee25Smacallan	      $run eval '$mv "$nlist"T "$nlist"'
45405eefee25Smacallan	    fi
45415eefee25Smacallan
45425eefee25Smacallan	    if test -n "$export_symbols_regex"; then
45435eefee25Smacallan	      $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
45445eefee25Smacallan	      $run eval '$mv "$nlist"T "$nlist"'
45455eefee25Smacallan	    fi
45465eefee25Smacallan
45475eefee25Smacallan	    # Prepare the list of exported symbols
45485eefee25Smacallan	    if test -z "$export_symbols"; then
45495eefee25Smacallan	      export_symbols="$output_objdir/$outputname.exp"
45505eefee25Smacallan	      $run $rm $export_symbols
45515eefee25Smacallan	      $run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
45525eefee25Smacallan              case $host in
45535eefee25Smacallan              *cygwin* | *mingw* )
45545eefee25Smacallan	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
45555eefee25Smacallan		$run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
45565eefee25Smacallan                ;;
45575eefee25Smacallan              esac
45585eefee25Smacallan	    else
45595eefee25Smacallan	      $run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
45605eefee25Smacallan	      $run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
45615eefee25Smacallan	      $run eval 'mv "$nlist"T "$nlist"'
45625eefee25Smacallan              case $host in
45635eefee25Smacallan              *cygwin* | *mingw* )
45645eefee25Smacallan	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
45655eefee25Smacallan		$run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
45665eefee25Smacallan                ;;
45675eefee25Smacallan              esac
45685eefee25Smacallan	    fi
45695eefee25Smacallan	  fi
45705eefee25Smacallan
45715eefee25Smacallan	  for arg in $dlprefiles; do
45725eefee25Smacallan	    $show "extracting global C symbols from \`$arg'"
45735eefee25Smacallan	    name=`$echo "$arg" | ${SED} -e 's%^.*/%%'`
45745eefee25Smacallan	    $run eval '$echo ": $name " >> "$nlist"'
45755eefee25Smacallan	    $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
45765eefee25Smacallan	  done
45775eefee25Smacallan
45785eefee25Smacallan	  if test -z "$run"; then
45795eefee25Smacallan	    # Make sure we have at least an empty file.
45805eefee25Smacallan	    test -f "$nlist" || : > "$nlist"
45815eefee25Smacallan
45825eefee25Smacallan	    if test -n "$exclude_expsyms"; then
45835eefee25Smacallan	      $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
45845eefee25Smacallan	      $mv "$nlist"T "$nlist"
45855eefee25Smacallan	    fi
45865eefee25Smacallan
45875eefee25Smacallan	    # Try sorting and uniquifying the output.
45885eefee25Smacallan	    if grep -v "^: " < "$nlist" |
45895eefee25Smacallan		if sort -k 3 </dev/null >/dev/null 2>&1; then
45905eefee25Smacallan		  sort -k 3
45915eefee25Smacallan		else
45925eefee25Smacallan		  sort +2
45935eefee25Smacallan		fi |
45945eefee25Smacallan		uniq > "$nlist"S; then
45955eefee25Smacallan	      :
45965eefee25Smacallan	    else
45975eefee25Smacallan	      grep -v "^: " < "$nlist" > "$nlist"S
45985eefee25Smacallan	    fi
45995eefee25Smacallan
46005eefee25Smacallan	    if test -f "$nlist"S; then
46015eefee25Smacallan	      eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"'
46025eefee25Smacallan	    else
46035eefee25Smacallan	      $echo '/* NONE */' >> "$output_objdir/$dlsyms"
46045eefee25Smacallan	    fi
46055eefee25Smacallan
46065eefee25Smacallan	    $echo >> "$output_objdir/$dlsyms" "\
46075eefee25Smacallan
46085eefee25Smacallan#undef lt_preloaded_symbols
46095eefee25Smacallan
46105eefee25Smacallan#if defined (__STDC__) && __STDC__
46115eefee25Smacallan# define lt_ptr void *
46125eefee25Smacallan#else
46135eefee25Smacallan# define lt_ptr char *
46145eefee25Smacallan# define const
46155eefee25Smacallan#endif
46165eefee25Smacallan
46175eefee25Smacallan/* The mapping between symbol names and symbols. */
46185eefee25Smacallan"
46195eefee25Smacallan
46205eefee25Smacallan	    case $host in
46215eefee25Smacallan	    *cygwin* | *mingw* )
46225eefee25Smacallan	  $echo >> "$output_objdir/$dlsyms" "\
46235eefee25Smacallan/* DATA imports from DLLs on WIN32 can't be const, because
46245eefee25Smacallan   runtime relocations are performed -- see ld's documentation
46255eefee25Smacallan   on pseudo-relocs */
46265eefee25Smacallanstruct {
46275eefee25Smacallan"
46285eefee25Smacallan	      ;;
46295eefee25Smacallan	    * )
46305eefee25Smacallan	  $echo >> "$output_objdir/$dlsyms" "\
46315eefee25Smacallanconst struct {
46325eefee25Smacallan"
46335eefee25Smacallan	      ;;
46345eefee25Smacallan	    esac
46355eefee25Smacallan
46365eefee25Smacallan
46375eefee25Smacallan	  $echo >> "$output_objdir/$dlsyms" "\
46385eefee25Smacallan  const char *name;
46395eefee25Smacallan  lt_ptr address;
46405eefee25Smacallan}
46415eefee25Smacallanlt_preloaded_symbols[] =
46425eefee25Smacallan{\
46435eefee25Smacallan"
46445eefee25Smacallan
46455eefee25Smacallan	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms"
46465eefee25Smacallan
46475eefee25Smacallan	    $echo >> "$output_objdir/$dlsyms" "\
46485eefee25Smacallan  {0, (lt_ptr) 0}
46495eefee25Smacallan};
46505eefee25Smacallan
46515eefee25Smacallan/* This works around a problem in FreeBSD linker */
46525eefee25Smacallan#ifdef FREEBSD_WORKAROUND
46535eefee25Smacallanstatic const void *lt_preloaded_setup() {
46545eefee25Smacallan  return lt_preloaded_symbols;
46555eefee25Smacallan}
46565eefee25Smacallan#endif
46575eefee25Smacallan
46585eefee25Smacallan#ifdef __cplusplus
46595eefee25Smacallan}
46605eefee25Smacallan#endif\
46615eefee25Smacallan"
46625eefee25Smacallan	  fi
46635eefee25Smacallan
46645eefee25Smacallan	  pic_flag_for_symtable=
46655eefee25Smacallan	  case $host in
46665eefee25Smacallan	  # compiling the symbol table file with pic_flag works around
46675eefee25Smacallan	  # a FreeBSD bug that causes programs to crash when -lm is
46685eefee25Smacallan	  # linked before any other PIC object.  But we must not use
46695eefee25Smacallan	  # pic_flag when linking with -static.  The problem exists in
46705eefee25Smacallan	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
46715eefee25Smacallan	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
46725eefee25Smacallan	    case "$compile_command " in
46735eefee25Smacallan	    *" -static "*) ;;
46745eefee25Smacallan	    *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";;
46755eefee25Smacallan	    esac;;
46765eefee25Smacallan	  *-*-hpux*)
46775eefee25Smacallan	    case "$compile_command " in
46785eefee25Smacallan	    *" -static "*) ;;
46795eefee25Smacallan	    *) pic_flag_for_symtable=" $pic_flag";;
46805eefee25Smacallan	    esac
46815eefee25Smacallan	  esac
46825eefee25Smacallan
46835eefee25Smacallan	  # Now compile the dynamic symbol file.
46845eefee25Smacallan	  $show "(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
46855eefee25Smacallan	  $run eval '(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
46865eefee25Smacallan
46875eefee25Smacallan	  # Clean up the generated files.
46885eefee25Smacallan	  $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
46895eefee25Smacallan	  $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
46905eefee25Smacallan
46915eefee25Smacallan	  # Transform the symbol file into the correct name.
46925eefee25Smacallan          case $host in
46935eefee25Smacallan          *cygwin* | *mingw* )
46945eefee25Smacallan            if test -f "$output_objdir/${outputname}.def" ; then
46955eefee25Smacallan              compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
46965eefee25Smacallan              finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
46975eefee25Smacallan            else
46985eefee25Smacallan              compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
46995eefee25Smacallan              finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
47005eefee25Smacallan             fi
47015eefee25Smacallan            ;;
47025eefee25Smacallan          * )
47035eefee25Smacallan            compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
47045eefee25Smacallan            finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
47055eefee25Smacallan            ;;
47065eefee25Smacallan          esac
47075eefee25Smacallan	  ;;
47085eefee25Smacallan	*)
47095eefee25Smacallan	  $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
47105eefee25Smacallan	  exit $EXIT_FAILURE
47115eefee25Smacallan	  ;;
47125eefee25Smacallan	esac
47135eefee25Smacallan      else
47145eefee25Smacallan	# We keep going just in case the user didn't refer to
47155eefee25Smacallan	# lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
47165eefee25Smacallan	# really was required.
47175eefee25Smacallan
47185eefee25Smacallan	# Nullify the symbol file.
47195eefee25Smacallan	compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
47205eefee25Smacallan	finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
47215eefee25Smacallan      fi
47225eefee25Smacallan
47235eefee25Smacallan      if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
47245eefee25Smacallan	# Replace the output file specification.
47255eefee25Smacallan	compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
47265eefee25Smacallan	link_command="$compile_command$compile_rpath"
47275eefee25Smacallan
47285eefee25Smacallan	# We have no uninstalled library dependencies, so finalize right now.
47295eefee25Smacallan	$show "$link_command"
47305eefee25Smacallan	$run eval "$link_command"
47315eefee25Smacallan	exit_status=$?
47325eefee25Smacallan
47335eefee25Smacallan	# Delete the generated files.
47345eefee25Smacallan	if test -n "$dlsyms"; then
47355eefee25Smacallan	  $show "$rm $output_objdir/${outputname}S.${objext}"
47365eefee25Smacallan	  $run $rm "$output_objdir/${outputname}S.${objext}"
47375eefee25Smacallan	fi
47385eefee25Smacallan
47395eefee25Smacallan	exit $exit_status
47405eefee25Smacallan      fi
47415eefee25Smacallan
47425eefee25Smacallan      if test -n "$shlibpath_var"; then
47435eefee25Smacallan	# We should set the shlibpath_var
47445eefee25Smacallan	rpath=
47455eefee25Smacallan	for dir in $temp_rpath; do
47465eefee25Smacallan	  case $dir in
47475eefee25Smacallan	  [\\/]* | [A-Za-z]:[\\/]*)
47485eefee25Smacallan	    # Absolute path.
47495eefee25Smacallan	    rpath="$rpath$dir:"
47505eefee25Smacallan	    ;;
47515eefee25Smacallan	  *)
47525eefee25Smacallan	    # Relative path: add a thisdir entry.
47535eefee25Smacallan	    rpath="$rpath\$thisdir/$dir:"
47545eefee25Smacallan	    ;;
47555eefee25Smacallan	  esac
47565eefee25Smacallan	done
47575eefee25Smacallan	temp_rpath="$rpath"
47585eefee25Smacallan      fi
47595eefee25Smacallan
47605eefee25Smacallan      if test -n "$compile_shlibpath$finalize_shlibpath"; then
47615eefee25Smacallan	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
47625eefee25Smacallan      fi
47635eefee25Smacallan      if test -n "$finalize_shlibpath"; then
47645eefee25Smacallan	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
47655eefee25Smacallan      fi
47665eefee25Smacallan
47675eefee25Smacallan      compile_var=
47685eefee25Smacallan      finalize_var=
47695eefee25Smacallan      if test -n "$runpath_var"; then
47705eefee25Smacallan	if test -n "$perm_rpath"; then
47715eefee25Smacallan	  # We should set the runpath_var.
47725eefee25Smacallan	  rpath=
47735eefee25Smacallan	  for dir in $perm_rpath; do
47745eefee25Smacallan	    rpath="$rpath$dir:"
47755eefee25Smacallan	  done
47765eefee25Smacallan	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
47775eefee25Smacallan	fi
47785eefee25Smacallan	if test -n "$finalize_perm_rpath"; then
47795eefee25Smacallan	  # We should set the runpath_var.
47805eefee25Smacallan	  rpath=
47815eefee25Smacallan	  for dir in $finalize_perm_rpath; do
47825eefee25Smacallan	    rpath="$rpath$dir:"
47835eefee25Smacallan	  done
47845eefee25Smacallan	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
47855eefee25Smacallan	fi
47865eefee25Smacallan      fi
47875eefee25Smacallan
47885eefee25Smacallan      if test "$no_install" = yes; then
47895eefee25Smacallan	# We don't need to create a wrapper script.
47905eefee25Smacallan	link_command="$compile_var$compile_command$compile_rpath"
47915eefee25Smacallan	# Replace the output file specification.
47925eefee25Smacallan	link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
47935eefee25Smacallan	# Delete the old output file.
47945eefee25Smacallan	$run $rm $output
47955eefee25Smacallan	# Link the executable and exit
47965eefee25Smacallan	$show "$link_command"
47975eefee25Smacallan	$run eval "$link_command" || exit $?
47985eefee25Smacallan	exit $EXIT_SUCCESS
47995eefee25Smacallan      fi
48005eefee25Smacallan
48015eefee25Smacallan      if test "$hardcode_action" = relink; then
48025eefee25Smacallan	# Fast installation is not supported
48035eefee25Smacallan	link_command="$compile_var$compile_command$compile_rpath"
48045eefee25Smacallan	relink_command="$finalize_var$finalize_command$finalize_rpath"
48055eefee25Smacallan
48065eefee25Smacallan	$echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2
48075eefee25Smacallan	$echo "$modename: \`$output' will be relinked during installation" 1>&2
48085eefee25Smacallan      else
48095eefee25Smacallan	if test "$fast_install" != no; then
48105eefee25Smacallan	  link_command="$finalize_var$compile_command$finalize_rpath"
48115eefee25Smacallan	  if test "$fast_install" = yes; then
48125eefee25Smacallan	    relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
48135eefee25Smacallan	  else
48145eefee25Smacallan	    # fast_install is set to needless
48155eefee25Smacallan	    relink_command=
48165eefee25Smacallan	  fi
48175eefee25Smacallan	else
48185eefee25Smacallan	  link_command="$compile_var$compile_command$compile_rpath"
48195eefee25Smacallan	  relink_command="$finalize_var$finalize_command$finalize_rpath"
48205eefee25Smacallan	fi
48215eefee25Smacallan      fi
48225eefee25Smacallan
48235eefee25Smacallan      # Replace the output file specification.
48245eefee25Smacallan      link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
48255eefee25Smacallan
48265eefee25Smacallan      # Delete the old output files.
48275eefee25Smacallan      $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname
48285eefee25Smacallan
48295eefee25Smacallan      $show "$link_command"
48305eefee25Smacallan      $run eval "$link_command" || exit $?
48315eefee25Smacallan
48325eefee25Smacallan      # Now create the wrapper script.
48335eefee25Smacallan      $show "creating $output"
48345eefee25Smacallan
48355eefee25Smacallan      # Quote the relink command for shipping.
48365eefee25Smacallan      if test -n "$relink_command"; then
48375eefee25Smacallan	# Preserve any variables that may affect compiler behavior
48385eefee25Smacallan	for var in $variables_saved_for_relink; do
48395eefee25Smacallan	  if eval test -z \"\${$var+set}\"; then
48405eefee25Smacallan	    relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
48415eefee25Smacallan	  elif eval var_value=\$$var; test -z "$var_value"; then
48425eefee25Smacallan	    relink_command="$var=; export $var; $relink_command"
48435eefee25Smacallan	  else
48445eefee25Smacallan	    var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
48455eefee25Smacallan	    relink_command="$var=\"$var_value\"; export $var; $relink_command"
48465eefee25Smacallan	  fi
48475eefee25Smacallan	done
48485eefee25Smacallan	relink_command="(cd `pwd`; $relink_command)"
48495eefee25Smacallan	relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
48505eefee25Smacallan      fi
48515eefee25Smacallan
48525eefee25Smacallan      # Quote $echo for shipping.
48535eefee25Smacallan      if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then
48545eefee25Smacallan	case $progpath in
48555eefee25Smacallan	[\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
48565eefee25Smacallan	*) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
48575eefee25Smacallan	esac
48585eefee25Smacallan	qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"`
48595eefee25Smacallan      else
48605eefee25Smacallan	qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"`
48615eefee25Smacallan      fi
48625eefee25Smacallan
48635eefee25Smacallan      # Only actually do things if our run command is non-null.
48645eefee25Smacallan      if test -z "$run"; then
48655eefee25Smacallan	# win32 will think the script is a binary if it has
48665eefee25Smacallan	# a .exe suffix, so we strip it off here.
48675eefee25Smacallan	case $output in
48685eefee25Smacallan	  *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;;
48695eefee25Smacallan	esac
48705eefee25Smacallan	# test for cygwin because mv fails w/o .exe extensions
48715eefee25Smacallan	case $host in
48725eefee25Smacallan	  *cygwin*)
48735eefee25Smacallan	    exeext=.exe
48745eefee25Smacallan	    outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;;
48755eefee25Smacallan	  *) exeext= ;;
48765eefee25Smacallan	esac
48775eefee25Smacallan	case $host in
48785eefee25Smacallan	  *cygwin* | *mingw* )
48795eefee25Smacallan            output_name=`basename $output`
48805eefee25Smacallan            output_path=`dirname $output`
48815eefee25Smacallan            cwrappersource="$output_path/$objdir/lt-$output_name.c"
48825eefee25Smacallan            cwrapper="$output_path/$output_name.exe"
48835eefee25Smacallan            $rm $cwrappersource $cwrapper
48845eefee25Smacallan            trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
48855eefee25Smacallan
48865eefee25Smacallan	    cat > $cwrappersource <<EOF
48875eefee25Smacallan
48885eefee25Smacallan/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
48895eefee25Smacallan   Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
48905eefee25Smacallan
48915eefee25Smacallan   The $output program cannot be directly executed until all the libtool
48925eefee25Smacallan   libraries that it depends on are installed.
48935eefee25Smacallan
48945eefee25Smacallan   This wrapper executable should never be moved out of the build directory.
48955eefee25Smacallan   If it is, it will not operate correctly.
48965eefee25Smacallan
48975eefee25Smacallan   Currently, it simply execs the wrapper *script* "/bin/sh $output",
48985eefee25Smacallan   but could eventually absorb all of the scripts functionality and
48995eefee25Smacallan   exec $objdir/$outputname directly.
49005eefee25Smacallan*/
49015eefee25SmacallanEOF
49025eefee25Smacallan	    cat >> $cwrappersource<<"EOF"
49035eefee25Smacallan#include <stdio.h>
49045eefee25Smacallan#include <stdlib.h>
49055eefee25Smacallan#include <unistd.h>
49065eefee25Smacallan#include <malloc.h>
49075eefee25Smacallan#include <stdarg.h>
49085eefee25Smacallan#include <assert.h>
49095eefee25Smacallan#include <string.h>
49105eefee25Smacallan#include <ctype.h>
49115eefee25Smacallan#include <sys/stat.h>
49125eefee25Smacallan
49135eefee25Smacallan#if defined(PATH_MAX)
49145eefee25Smacallan# define LT_PATHMAX PATH_MAX
49155eefee25Smacallan#elif defined(MAXPATHLEN)
49165eefee25Smacallan# define LT_PATHMAX MAXPATHLEN
49175eefee25Smacallan#else
49185eefee25Smacallan# define LT_PATHMAX 1024
49195eefee25Smacallan#endif
49205eefee25Smacallan
49215eefee25Smacallan#ifndef DIR_SEPARATOR
49225eefee25Smacallan# define DIR_SEPARATOR '/'
49235eefee25Smacallan# define PATH_SEPARATOR ':'
49245eefee25Smacallan#endif
49255eefee25Smacallan
49265eefee25Smacallan#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
49275eefee25Smacallan  defined (__OS2__)
49285eefee25Smacallan# define HAVE_DOS_BASED_FILE_SYSTEM
49295eefee25Smacallan# ifndef DIR_SEPARATOR_2
49305eefee25Smacallan#  define DIR_SEPARATOR_2 '\\'
49315eefee25Smacallan# endif
49325eefee25Smacallan# ifndef PATH_SEPARATOR_2
49335eefee25Smacallan#  define PATH_SEPARATOR_2 ';'
49345eefee25Smacallan# endif
49355eefee25Smacallan#endif
49365eefee25Smacallan
49375eefee25Smacallan#ifndef DIR_SEPARATOR_2
49385eefee25Smacallan# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
49395eefee25Smacallan#else /* DIR_SEPARATOR_2 */
49405eefee25Smacallan# define IS_DIR_SEPARATOR(ch) \
49415eefee25Smacallan        (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
49425eefee25Smacallan#endif /* DIR_SEPARATOR_2 */
49435eefee25Smacallan
49445eefee25Smacallan#ifndef PATH_SEPARATOR_2
49455eefee25Smacallan# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
49465eefee25Smacallan#else /* PATH_SEPARATOR_2 */
49475eefee25Smacallan# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
49485eefee25Smacallan#endif /* PATH_SEPARATOR_2 */
49495eefee25Smacallan
49505eefee25Smacallan#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
49515eefee25Smacallan#define XFREE(stale) do { \
49525eefee25Smacallan  if (stale) { free ((void *) stale); stale = 0; } \
49535eefee25Smacallan} while (0)
49545eefee25Smacallan
49555eefee25Smacallan/* -DDEBUG is fairly common in CFLAGS.  */
49565eefee25Smacallan#undef DEBUG
49575eefee25Smacallan#if defined DEBUGWRAPPER
49585eefee25Smacallan# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
49595eefee25Smacallan#else
49605eefee25Smacallan# define DEBUG(format, ...)
49615eefee25Smacallan#endif
49625eefee25Smacallan
49635eefee25Smacallanconst char *program_name = NULL;
49645eefee25Smacallan
49655eefee25Smacallanvoid * xmalloc (size_t num);
49665eefee25Smacallanchar * xstrdup (const char *string);
49675eefee25Smacallanconst char * base_name (const char *name);
49685eefee25Smacallanchar * find_executable(const char *wrapper);
49695eefee25Smacallanint    check_executable(const char *path);
49705eefee25Smacallanchar * strendzap(char *str, const char *pat);
49715eefee25Smacallanvoid lt_fatal (const char *message, ...);
49725eefee25Smacallan
49735eefee25Smacallanint
49745eefee25Smacallanmain (int argc, char *argv[])
49755eefee25Smacallan{
49765eefee25Smacallan  char **newargz;
49775eefee25Smacallan  int i;
49785eefee25Smacallan
49795eefee25Smacallan  program_name = (char *) xstrdup (base_name (argv[0]));
49805eefee25Smacallan  DEBUG("(main) argv[0]      : %s\n",argv[0]);
49815eefee25Smacallan  DEBUG("(main) program_name : %s\n",program_name);
49825eefee25Smacallan  newargz = XMALLOC(char *, argc+2);
49835eefee25SmacallanEOF
49845eefee25Smacallan
49855eefee25Smacallan            cat >> $cwrappersource <<EOF
49865eefee25Smacallan  newargz[0] = (char *) xstrdup("$SHELL");
49875eefee25SmacallanEOF
49885eefee25Smacallan
49895eefee25Smacallan            cat >> $cwrappersource <<"EOF"
49905eefee25Smacallan  newargz[1] = find_executable(argv[0]);
49915eefee25Smacallan  if (newargz[1] == NULL)
49925eefee25Smacallan    lt_fatal("Couldn't find %s", argv[0]);
49935eefee25Smacallan  DEBUG("(main) found exe at : %s\n",newargz[1]);
49945eefee25Smacallan  /* we know the script has the same name, without the .exe */
49955eefee25Smacallan  /* so make sure newargz[1] doesn't end in .exe */
49965eefee25Smacallan  strendzap(newargz[1],".exe");
49975eefee25Smacallan  for (i = 1; i < argc; i++)
49985eefee25Smacallan    newargz[i+1] = xstrdup(argv[i]);
49995eefee25Smacallan  newargz[argc+1] = NULL;
50005eefee25Smacallan
50015eefee25Smacallan  for (i=0; i<argc+1; i++)
50025eefee25Smacallan  {
50035eefee25Smacallan    DEBUG("(main) newargz[%d]   : %s\n",i,newargz[i]);
50045eefee25Smacallan    ;
50055eefee25Smacallan  }
50065eefee25Smacallan
50075eefee25SmacallanEOF
50085eefee25Smacallan
50095eefee25Smacallan            case $host_os in
50105eefee25Smacallan              mingw*)
50115eefee25Smacallan                cat >> $cwrappersource <<EOF
50125eefee25Smacallan  execv("$SHELL",(char const **)newargz);
50135eefee25SmacallanEOF
50145eefee25Smacallan              ;;
50155eefee25Smacallan              *)
50165eefee25Smacallan                cat >> $cwrappersource <<EOF
50175eefee25Smacallan  execv("$SHELL",newargz);
50185eefee25SmacallanEOF
50195eefee25Smacallan              ;;
50205eefee25Smacallan            esac
50215eefee25Smacallan
50225eefee25Smacallan            cat >> $cwrappersource <<"EOF"
50235eefee25Smacallan  return 127;
50245eefee25Smacallan}
50255eefee25Smacallan
50265eefee25Smacallanvoid *
50275eefee25Smacallanxmalloc (size_t num)
50285eefee25Smacallan{
50295eefee25Smacallan  void * p = (void *) malloc (num);
50305eefee25Smacallan  if (!p)
50315eefee25Smacallan    lt_fatal ("Memory exhausted");
50325eefee25Smacallan
50335eefee25Smacallan  return p;
50345eefee25Smacallan}
50355eefee25Smacallan
50365eefee25Smacallanchar *
50375eefee25Smacallanxstrdup (const char *string)
50385eefee25Smacallan{
50395eefee25Smacallan  return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL
50405eefee25Smacallan;
50415eefee25Smacallan}
50425eefee25Smacallan
50435eefee25Smacallanconst char *
50445eefee25Smacallanbase_name (const char *name)
50455eefee25Smacallan{
50465eefee25Smacallan  const char *base;
50475eefee25Smacallan
50485eefee25Smacallan#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
50495eefee25Smacallan  /* Skip over the disk name in MSDOS pathnames. */
50505eefee25Smacallan  if (isalpha ((unsigned char)name[0]) && name[1] == ':')
50515eefee25Smacallan    name += 2;
50525eefee25Smacallan#endif
50535eefee25Smacallan
50545eefee25Smacallan  for (base = name; *name; name++)
50555eefee25Smacallan    if (IS_DIR_SEPARATOR (*name))
50565eefee25Smacallan      base = name + 1;
50575eefee25Smacallan  return base;
50585eefee25Smacallan}
50595eefee25Smacallan
50605eefee25Smacallanint
50615eefee25Smacallancheck_executable(const char * path)
50625eefee25Smacallan{
50635eefee25Smacallan  struct stat st;
50645eefee25Smacallan
50655eefee25Smacallan  DEBUG("(check_executable)  : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!");
50665eefee25Smacallan  if ((!path) || (!*path))
50675eefee25Smacallan    return 0;
50685eefee25Smacallan
50695eefee25Smacallan  if ((stat (path, &st) >= 0) &&
50705eefee25Smacallan      (
50715eefee25Smacallan        /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */
50725eefee25Smacallan#if defined (S_IXOTH)
50735eefee25Smacallan       ((st.st_mode & S_IXOTH) == S_IXOTH) ||
50745eefee25Smacallan#endif
50755eefee25Smacallan#if defined (S_IXGRP)
50765eefee25Smacallan       ((st.st_mode & S_IXGRP) == S_IXGRP) ||
50775eefee25Smacallan#endif
50785eefee25Smacallan       ((st.st_mode & S_IXUSR) == S_IXUSR))
50795eefee25Smacallan      )
50805eefee25Smacallan    return 1;
50815eefee25Smacallan  else
50825eefee25Smacallan    return 0;
50835eefee25Smacallan}
50845eefee25Smacallan
50855eefee25Smacallan/* Searches for the full path of the wrapper.  Returns
50865eefee25Smacallan   newly allocated full path name if found, NULL otherwise */
50875eefee25Smacallanchar *
50885eefee25Smacallanfind_executable (const char* wrapper)
50895eefee25Smacallan{
50905eefee25Smacallan  int has_slash = 0;
50915eefee25Smacallan  const char* p;
50925eefee25Smacallan  const char* p_next;
50935eefee25Smacallan  /* static buffer for getcwd */
50945eefee25Smacallan  char tmp[LT_PATHMAX + 1];
50955eefee25Smacallan  int tmp_len;
50965eefee25Smacallan  char* concat_name;
50975eefee25Smacallan
50985eefee25Smacallan  DEBUG("(find_executable)  : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!");
50995eefee25Smacallan
51005eefee25Smacallan  if ((wrapper == NULL) || (*wrapper == '\0'))
51015eefee25Smacallan    return NULL;
51025eefee25Smacallan
51035eefee25Smacallan  /* Absolute path? */
51045eefee25Smacallan#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
51055eefee25Smacallan  if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':')
51065eefee25Smacallan  {
51075eefee25Smacallan    concat_name = xstrdup (wrapper);
51085eefee25Smacallan    if (check_executable(concat_name))
51095eefee25Smacallan      return concat_name;
51105eefee25Smacallan    XFREE(concat_name);
51115eefee25Smacallan  }
51125eefee25Smacallan  else
51135eefee25Smacallan  {
51145eefee25Smacallan#endif
51155eefee25Smacallan    if (IS_DIR_SEPARATOR (wrapper[0]))
51165eefee25Smacallan    {
51175eefee25Smacallan      concat_name = xstrdup (wrapper);
51185eefee25Smacallan      if (check_executable(concat_name))
51195eefee25Smacallan        return concat_name;
51205eefee25Smacallan      XFREE(concat_name);
51215eefee25Smacallan    }
51225eefee25Smacallan#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
51235eefee25Smacallan  }
51245eefee25Smacallan#endif
51255eefee25Smacallan
51265eefee25Smacallan  for (p = wrapper; *p; p++)
51275eefee25Smacallan    if (*p == '/')
51285eefee25Smacallan    {
51295eefee25Smacallan      has_slash = 1;
51305eefee25Smacallan      break;
51315eefee25Smacallan    }
51325eefee25Smacallan  if (!has_slash)
51335eefee25Smacallan  {
51345eefee25Smacallan    /* no slashes; search PATH */
51355eefee25Smacallan    const char* path = getenv ("PATH");
51365eefee25Smacallan    if (path != NULL)
51375eefee25Smacallan    {
51385eefee25Smacallan      for (p = path; *p; p = p_next)
51395eefee25Smacallan      {
51405eefee25Smacallan        const char* q;
51415eefee25Smacallan        size_t p_len;
51425eefee25Smacallan        for (q = p; *q; q++)
51435eefee25Smacallan          if (IS_PATH_SEPARATOR(*q))
51445eefee25Smacallan            break;
51455eefee25Smacallan        p_len = q - p;
51465eefee25Smacallan        p_next = (*q == '\0' ? q : q + 1);
51475eefee25Smacallan        if (p_len == 0)
51485eefee25Smacallan        {
51495eefee25Smacallan          /* empty path: current directory */
51505eefee25Smacallan          if (getcwd (tmp, LT_PATHMAX) == NULL)
51515eefee25Smacallan            lt_fatal ("getcwd failed");
51525eefee25Smacallan          tmp_len = strlen(tmp);
51535eefee25Smacallan          concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
51545eefee25Smacallan          memcpy (concat_name, tmp, tmp_len);
51555eefee25Smacallan          concat_name[tmp_len] = '/';
51565eefee25Smacallan          strcpy (concat_name + tmp_len + 1, wrapper);
51575eefee25Smacallan        }
51585eefee25Smacallan        else
51595eefee25Smacallan        {
51605eefee25Smacallan          concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1);
51615eefee25Smacallan          memcpy (concat_name, p, p_len);
51625eefee25Smacallan          concat_name[p_len] = '/';
51635eefee25Smacallan          strcpy (concat_name + p_len + 1, wrapper);
51645eefee25Smacallan        }
51655eefee25Smacallan        if (check_executable(concat_name))
51665eefee25Smacallan          return concat_name;
51675eefee25Smacallan        XFREE(concat_name);
51685eefee25Smacallan      }
51695eefee25Smacallan    }
51705eefee25Smacallan    /* not found in PATH; assume curdir */
51715eefee25Smacallan  }
51725eefee25Smacallan  /* Relative path | not found in path: prepend cwd */
51735eefee25Smacallan  if (getcwd (tmp, LT_PATHMAX) == NULL)
51745eefee25Smacallan    lt_fatal ("getcwd failed");
51755eefee25Smacallan  tmp_len = strlen(tmp);
51765eefee25Smacallan  concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
51775eefee25Smacallan  memcpy (concat_name, tmp, tmp_len);
51785eefee25Smacallan  concat_name[tmp_len] = '/';
51795eefee25Smacallan  strcpy (concat_name + tmp_len + 1, wrapper);
51805eefee25Smacallan
51815eefee25Smacallan  if (check_executable(concat_name))
51825eefee25Smacallan    return concat_name;
51835eefee25Smacallan  XFREE(concat_name);
51845eefee25Smacallan  return NULL;
51855eefee25Smacallan}
51865eefee25Smacallan
51875eefee25Smacallanchar *
51885eefee25Smacallanstrendzap(char *str, const char *pat)
51895eefee25Smacallan{
51905eefee25Smacallan  size_t len, patlen;
51915eefee25Smacallan
51925eefee25Smacallan  assert(str != NULL);
51935eefee25Smacallan  assert(pat != NULL);
51945eefee25Smacallan
51955eefee25Smacallan  len = strlen(str);
51965eefee25Smacallan  patlen = strlen(pat);
51975eefee25Smacallan
51985eefee25Smacallan  if (patlen <= len)
51995eefee25Smacallan  {
52005eefee25Smacallan    str += len - patlen;
52015eefee25Smacallan    if (strcmp(str, pat) == 0)
52025eefee25Smacallan      *str = '\0';
52035eefee25Smacallan  }
52045eefee25Smacallan  return str;
52055eefee25Smacallan}
52065eefee25Smacallan
52075eefee25Smacallanstatic void
52085eefee25Smacallanlt_error_core (int exit_status, const char * mode,
52095eefee25Smacallan          const char * message, va_list ap)
52105eefee25Smacallan{
52115eefee25Smacallan  fprintf (stderr, "%s: %s: ", program_name, mode);
52125eefee25Smacallan  vfprintf (stderr, message, ap);
52135eefee25Smacallan  fprintf (stderr, ".\n");
52145eefee25Smacallan
52155eefee25Smacallan  if (exit_status >= 0)
52165eefee25Smacallan    exit (exit_status);
52175eefee25Smacallan}
52185eefee25Smacallan
52195eefee25Smacallanvoid
52205eefee25Smacallanlt_fatal (const char *message, ...)
52215eefee25Smacallan{
52225eefee25Smacallan  va_list ap;
52235eefee25Smacallan  va_start (ap, message);
52245eefee25Smacallan  lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
52255eefee25Smacallan  va_end (ap);
52265eefee25Smacallan}
52275eefee25SmacallanEOF
52285eefee25Smacallan          # we should really use a build-platform specific compiler
52295eefee25Smacallan          # here, but OTOH, the wrappers (shell script and this C one)
52305eefee25Smacallan          # are only useful if you want to execute the "real" binary.
52315eefee25Smacallan          # Since the "real" binary is built for $host, then this
52325eefee25Smacallan          # wrapper might as well be built for $host, too.
52335eefee25Smacallan          $run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource
52345eefee25Smacallan          ;;
52355eefee25Smacallan        esac
52365eefee25Smacallan        $rm $output
52375eefee25Smacallan        trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
52385eefee25Smacallan
52395eefee25Smacallan	$echo > $output "\
52405eefee25Smacallan#! $SHELL
52415eefee25Smacallan
52425eefee25Smacallan# $output - temporary wrapper script for $objdir/$outputname
52435eefee25Smacallan# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
52445eefee25Smacallan#
52455eefee25Smacallan# The $output program cannot be directly executed until all the libtool
52465eefee25Smacallan# libraries that it depends on are installed.
52475eefee25Smacallan#
52485eefee25Smacallan# This wrapper script should never be moved out of the build directory.
52495eefee25Smacallan# If it is, it will not operate correctly.
52505eefee25Smacallan
52515eefee25Smacallan# Sed substitution that helps us do robust quoting.  It backslashifies
52525eefee25Smacallan# metacharacters that are still active within double-quoted strings.
52535eefee25SmacallanXsed='${SED} -e 1s/^X//'
52545eefee25Smacallansed_quote_subst='$sed_quote_subst'
52555eefee25Smacallan
52565eefee25Smacallan# The HP-UX ksh and POSIX shell print the target directory to stdout
52575eefee25Smacallan# if CDPATH is set.
52585eefee25Smacallan(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
52595eefee25Smacallan
52605eefee25Smacallanrelink_command=\"$relink_command\"
52615eefee25Smacallan
52625eefee25Smacallan# This environment variable determines our operation mode.
52635eefee25Smacallanif test \"\$libtool_install_magic\" = \"$magic\"; then
52645eefee25Smacallan  # install mode needs the following variable:
52655eefee25Smacallan  notinst_deplibs='$notinst_deplibs'
52665eefee25Smacallanelse
52675eefee25Smacallan  # When we are sourced in execute mode, \$file and \$echo are already set.
52685eefee25Smacallan  if test \"\$libtool_execute_magic\" != \"$magic\"; then
52695eefee25Smacallan    echo=\"$qecho\"
52705eefee25Smacallan    file=\"\$0\"
52715eefee25Smacallan    # Make sure echo works.
52725eefee25Smacallan    if test \"X\$1\" = X--no-reexec; then
52735eefee25Smacallan      # Discard the --no-reexec flag, and continue.
52745eefee25Smacallan      shift
52755eefee25Smacallan    elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then
52765eefee25Smacallan      # Yippee, \$echo works!
52775eefee25Smacallan      :
52785eefee25Smacallan    else
52795eefee25Smacallan      # Restart under the correct shell, and then maybe \$echo will work.
52805eefee25Smacallan      exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
52815eefee25Smacallan    fi
52825eefee25Smacallan  fi\
52835eefee25Smacallan"
52845eefee25Smacallan	$echo >> $output "\
52855eefee25Smacallan
52865eefee25Smacallan  # Find the directory that this script lives in.
52875eefee25Smacallan  thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
52885eefee25Smacallan  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
52895eefee25Smacallan
52905eefee25Smacallan  # Follow symbolic links until we get to the real thisdir.
52915eefee25Smacallan  file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
52925eefee25Smacallan  while test -n \"\$file\"; do
52935eefee25Smacallan    destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
52945eefee25Smacallan
52955eefee25Smacallan    # If there was a directory component, then change thisdir.
52965eefee25Smacallan    if test \"x\$destdir\" != \"x\$file\"; then
52975eefee25Smacallan      case \"\$destdir\" in
52985eefee25Smacallan      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
52995eefee25Smacallan      *) thisdir=\"\$thisdir/\$destdir\" ;;
53005eefee25Smacallan      esac
53015eefee25Smacallan    fi
53025eefee25Smacallan
53035eefee25Smacallan    file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
53045eefee25Smacallan    file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
53055eefee25Smacallan  done
53065eefee25Smacallan
53075eefee25Smacallan  # Try to get the absolute directory name.
53085eefee25Smacallan  absdir=\`cd \"\$thisdir\" && pwd\`
53095eefee25Smacallan  test -n \"\$absdir\" && thisdir=\"\$absdir\"
53105eefee25Smacallan"
53115eefee25Smacallan
53125eefee25Smacallan	if test "$fast_install" = yes; then
53135eefee25Smacallan	  $echo >> $output "\
53145eefee25Smacallan  program=lt-'$outputname'$exeext
53155eefee25Smacallan  progdir=\"\$thisdir/$objdir\"
53165eefee25Smacallan
53175eefee25Smacallan  if test ! -f \"\$progdir/\$program\" || \\
53185eefee25Smacallan     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
53195eefee25Smacallan       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
53205eefee25Smacallan
53215eefee25Smacallan    file=\"\$\$-\$program\"
53225eefee25Smacallan
53235eefee25Smacallan    if test ! -d \"\$progdir\"; then
53245eefee25Smacallan      $mkdir \"\$progdir\"
53255eefee25Smacallan    else
53265eefee25Smacallan      $rm \"\$progdir/\$file\"
53275eefee25Smacallan    fi"
53285eefee25Smacallan
53295eefee25Smacallan	  $echo >> $output "\
53305eefee25Smacallan
53315eefee25Smacallan    # relink executable if necessary
53325eefee25Smacallan    if test -n \"\$relink_command\"; then
53335eefee25Smacallan      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
53345eefee25Smacallan      else
53355eefee25Smacallan	$echo \"\$relink_command_output\" >&2
53365eefee25Smacallan	$rm \"\$progdir/\$file\"
53375eefee25Smacallan	exit $EXIT_FAILURE
53385eefee25Smacallan      fi
53395eefee25Smacallan    fi
53405eefee25Smacallan
53415eefee25Smacallan    $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
53425eefee25Smacallan    { $rm \"\$progdir/\$program\";
53435eefee25Smacallan      $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
53445eefee25Smacallan    $rm \"\$progdir/\$file\"
53455eefee25Smacallan  fi"
53465eefee25Smacallan	else
53475eefee25Smacallan	  $echo >> $output "\
53485eefee25Smacallan  program='$outputname'
53495eefee25Smacallan  progdir=\"\$thisdir/$objdir\"
53505eefee25Smacallan"
53515eefee25Smacallan	fi
53525eefee25Smacallan
53535eefee25Smacallan	$echo >> $output "\
53545eefee25Smacallan
53555eefee25Smacallan  if test -f \"\$progdir/\$program\"; then"
53565eefee25Smacallan
53575eefee25Smacallan	# Export our shlibpath_var if we have one.
53585eefee25Smacallan	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
53595eefee25Smacallan	  $echo >> $output "\
53605eefee25Smacallan    # Add our own library path to $shlibpath_var
53615eefee25Smacallan    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
53625eefee25Smacallan
53635eefee25Smacallan    # Some systems cannot cope with colon-terminated $shlibpath_var
53645eefee25Smacallan    # The second colon is a workaround for a bug in BeOS R4 sed
53655eefee25Smacallan    $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
53665eefee25Smacallan
53675eefee25Smacallan    export $shlibpath_var
53685eefee25Smacallan"
53695eefee25Smacallan	fi
53705eefee25Smacallan
53715eefee25Smacallan	# fixup the dll searchpath if we need to.
53725eefee25Smacallan	if test -n "$dllsearchpath"; then
53735eefee25Smacallan	  $echo >> $output "\
53745eefee25Smacallan    # Add the dll search path components to the executable PATH
53755eefee25Smacallan    PATH=$dllsearchpath:\$PATH
53765eefee25Smacallan"
53775eefee25Smacallan	fi
53785eefee25Smacallan
53795eefee25Smacallan	$echo >> $output "\
53805eefee25Smacallan    if test \"\$libtool_execute_magic\" != \"$magic\"; then
53815eefee25Smacallan      # Run the actual program with our arguments.
53825eefee25Smacallan"
53835eefee25Smacallan	case $host in
53845eefee25Smacallan	# Backslashes separate directories on plain windows
53855eefee25Smacallan	*-*-mingw | *-*-os2*)
53865eefee25Smacallan	  $echo >> $output "\
53875eefee25Smacallan      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
53885eefee25Smacallan"
53895eefee25Smacallan	  ;;
53905eefee25Smacallan
53915eefee25Smacallan	*)
53925eefee25Smacallan	  $echo >> $output "\
53935eefee25Smacallan      exec \"\$progdir/\$program\" \${1+\"\$@\"}
53945eefee25Smacallan"
53955eefee25Smacallan	  ;;
53965eefee25Smacallan	esac
53975eefee25Smacallan	$echo >> $output "\
53985eefee25Smacallan      \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\"
53995eefee25Smacallan      exit $EXIT_FAILURE
54005eefee25Smacallan    fi
54015eefee25Smacallan  else
54025eefee25Smacallan    # The program doesn't exist.
54035eefee25Smacallan    \$echo \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
54045eefee25Smacallan    \$echo \"This script is just a wrapper for \$program.\" 1>&2
54055eefee25Smacallan    $echo \"See the $PACKAGE documentation for more information.\" 1>&2
54065eefee25Smacallan    exit $EXIT_FAILURE
54075eefee25Smacallan  fi
54085eefee25Smacallanfi\
54095eefee25Smacallan"
54105eefee25Smacallan	chmod +x $output
54115eefee25Smacallan      fi
54125eefee25Smacallan      exit $EXIT_SUCCESS
54135eefee25Smacallan      ;;
54145eefee25Smacallan    esac
54155eefee25Smacallan
54165eefee25Smacallan    # See if we need to build an old-fashioned archive.
54175eefee25Smacallan    for oldlib in $oldlibs; do
54185eefee25Smacallan
54195eefee25Smacallan      if test "$build_libtool_libs" = convenience; then
54205eefee25Smacallan	oldobjs="$libobjs_save"
54215eefee25Smacallan	addlibs="$convenience"
54225eefee25Smacallan	build_libtool_libs=no
54235eefee25Smacallan      else
54245eefee25Smacallan	if test "$build_libtool_libs" = module; then
54255eefee25Smacallan	  oldobjs="$libobjs_save"
54265eefee25Smacallan	  build_libtool_libs=no
54275eefee25Smacallan	else
54285eefee25Smacallan	  oldobjs="$old_deplibs $non_pic_objects"
54295eefee25Smacallan	fi
54305eefee25Smacallan	addlibs="$old_convenience"
54315eefee25Smacallan      fi
54325eefee25Smacallan
54335eefee25Smacallan      if test -n "$addlibs"; then
54345eefee25Smacallan	gentop="$output_objdir/${outputname}x"
54355eefee25Smacallan	generated="$generated $gentop"
54365eefee25Smacallan
54375eefee25Smacallan	func_extract_archives $gentop $addlibs
54385eefee25Smacallan	oldobjs="$oldobjs $func_extract_archives_result"
54395eefee25Smacallan      fi
54405eefee25Smacallan
54415eefee25Smacallan      # Do each command in the archive commands.
54425eefee25Smacallan      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
54435eefee25Smacallan       cmds=$old_archive_from_new_cmds
54445eefee25Smacallan      else
54455eefee25Smacallan	# POSIX demands no paths to be encoded in archives.  We have
54465eefee25Smacallan	# to avoid creating archives with duplicate basenames if we
54475eefee25Smacallan	# might have to extract them afterwards, e.g., when creating a
54485eefee25Smacallan	# static archive out of a convenience library, or when linking
54495eefee25Smacallan	# the entirety of a libtool archive into another (currently
54505eefee25Smacallan	# not supported by libtool).
54515eefee25Smacallan	if (for obj in $oldobjs
54525eefee25Smacallan	    do
54535eefee25Smacallan	      $echo "X$obj" | $Xsed -e 's%^.*/%%'
54545eefee25Smacallan	    done | sort | sort -uc >/dev/null 2>&1); then
54555eefee25Smacallan	  :
54565eefee25Smacallan	else
54575eefee25Smacallan	  $echo "copying selected object files to avoid basename conflicts..."
54585eefee25Smacallan
54595eefee25Smacallan	  if test -z "$gentop"; then
54605eefee25Smacallan	    gentop="$output_objdir/${outputname}x"
54615eefee25Smacallan	    generated="$generated $gentop"
54625eefee25Smacallan
54635eefee25Smacallan	    $show "${rm}r $gentop"
54645eefee25Smacallan	    $run ${rm}r "$gentop"
54655eefee25Smacallan	    $show "$mkdir $gentop"
54665eefee25Smacallan	    $run $mkdir "$gentop"
54675eefee25Smacallan	    exit_status=$?
54685eefee25Smacallan	    if test "$exit_status" -ne 0 && test ! -d "$gentop"; then
54695eefee25Smacallan	      exit $exit_status
54705eefee25Smacallan	    fi
54715eefee25Smacallan	  fi
54725eefee25Smacallan
54735eefee25Smacallan	  save_oldobjs=$oldobjs
54745eefee25Smacallan	  oldobjs=
54755eefee25Smacallan	  counter=1
54765eefee25Smacallan	  for obj in $save_oldobjs
54775eefee25Smacallan	  do
54785eefee25Smacallan	    objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
54795eefee25Smacallan	    case " $oldobjs " in
54805eefee25Smacallan	    " ") oldobjs=$obj ;;
54815eefee25Smacallan	    *[\ /]"$objbase "*)
54825eefee25Smacallan	      while :; do
54835eefee25Smacallan		# Make sure we don't pick an alternate name that also
54845eefee25Smacallan		# overlaps.
54855eefee25Smacallan		newobj=lt$counter-$objbase
54865eefee25Smacallan		counter=`expr $counter + 1`
54875eefee25Smacallan		case " $oldobjs " in
54885eefee25Smacallan		*[\ /]"$newobj "*) ;;
54895eefee25Smacallan		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
54905eefee25Smacallan		esac
54915eefee25Smacallan	      done
54925eefee25Smacallan	      $show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
54935eefee25Smacallan	      $run ln "$obj" "$gentop/$newobj" ||
54945eefee25Smacallan	      $run cp "$obj" "$gentop/$newobj"
54955eefee25Smacallan	      oldobjs="$oldobjs $gentop/$newobj"
54965eefee25Smacallan	      ;;
54975eefee25Smacallan	    *) oldobjs="$oldobjs $obj" ;;
54985eefee25Smacallan	    esac
54995eefee25Smacallan	  done
55005eefee25Smacallan	fi
55015eefee25Smacallan
55025eefee25Smacallan	eval cmds=\"$old_archive_cmds\"
55035eefee25Smacallan
55045eefee25Smacallan	if len=`expr "X$cmds" : ".*"` &&
55055eefee25Smacallan	     test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
55065eefee25Smacallan	  cmds=$old_archive_cmds
55075eefee25Smacallan	else
55085eefee25Smacallan	  # the command line is too long to link in one step, link in parts
55095eefee25Smacallan	  $echo "using piecewise archive linking..."
55105eefee25Smacallan	  save_RANLIB=$RANLIB
55115eefee25Smacallan	  RANLIB=:
55125eefee25Smacallan	  objlist=
55135eefee25Smacallan	  concat_cmds=
55145eefee25Smacallan	  save_oldobjs=$oldobjs
55155eefee25Smacallan
55165eefee25Smacallan	  # Is there a better way of finding the last object in the list?
55175eefee25Smacallan	  for obj in $save_oldobjs
55185eefee25Smacallan	  do
55195eefee25Smacallan	    last_oldobj=$obj
55205eefee25Smacallan	  done
55215eefee25Smacallan	  for obj in $save_oldobjs
55225eefee25Smacallan	  do
55235eefee25Smacallan	    oldobjs="$objlist $obj"
55245eefee25Smacallan	    objlist="$objlist $obj"
55255eefee25Smacallan	    eval test_cmds=\"$old_archive_cmds\"
55265eefee25Smacallan	    if len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
55275eefee25Smacallan	       test "$len" -le "$max_cmd_len"; then
55285eefee25Smacallan	      :
55295eefee25Smacallan	    else
55305eefee25Smacallan	      # the above command should be used before it gets too long
55315eefee25Smacallan	      oldobjs=$objlist
55325eefee25Smacallan	      if test "$obj" = "$last_oldobj" ; then
55335eefee25Smacallan	        RANLIB=$save_RANLIB
55345eefee25Smacallan	      fi
55355eefee25Smacallan	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
55365eefee25Smacallan	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
55375eefee25Smacallan	      objlist=
55385eefee25Smacallan	    fi
55395eefee25Smacallan	  done
55405eefee25Smacallan	  RANLIB=$save_RANLIB
55415eefee25Smacallan	  oldobjs=$objlist
55425eefee25Smacallan	  if test "X$oldobjs" = "X" ; then
55435eefee25Smacallan	    eval cmds=\"\$concat_cmds\"
55445eefee25Smacallan	  else
55455eefee25Smacallan	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
55465eefee25Smacallan	  fi
55475eefee25Smacallan	fi
55485eefee25Smacallan      fi
55495eefee25Smacallan      save_ifs="$IFS"; IFS='~'
55505eefee25Smacallan      for cmd in $cmds; do
55515eefee25Smacallan        eval cmd=\"$cmd\"
55525eefee25Smacallan	IFS="$save_ifs"
55535eefee25Smacallan	$show "$cmd"
55545eefee25Smacallan	$run eval "$cmd" || exit $?
55555eefee25Smacallan      done
55565eefee25Smacallan      IFS="$save_ifs"
55575eefee25Smacallan    done
55585eefee25Smacallan
55595eefee25Smacallan    if test -n "$generated"; then
55605eefee25Smacallan      $show "${rm}r$generated"
55615eefee25Smacallan      $run ${rm}r$generated
55625eefee25Smacallan    fi
55635eefee25Smacallan
55645eefee25Smacallan    # Now create the libtool archive.
55655eefee25Smacallan    case $output in
55665eefee25Smacallan    *.la)
55675eefee25Smacallan      old_library=
55685eefee25Smacallan      test "$build_old_libs" = yes && old_library="$libname.$libext"
55695eefee25Smacallan      $show "creating $output"
55705eefee25Smacallan
55715eefee25Smacallan      # Preserve any variables that may affect compiler behavior
55725eefee25Smacallan      for var in $variables_saved_for_relink; do
55735eefee25Smacallan	if eval test -z \"\${$var+set}\"; then
55745eefee25Smacallan	  relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
55755eefee25Smacallan	elif eval var_value=\$$var; test -z "$var_value"; then
55765eefee25Smacallan	  relink_command="$var=; export $var; $relink_command"
55775eefee25Smacallan	else
55785eefee25Smacallan	  var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
55795eefee25Smacallan	  relink_command="$var=\"$var_value\"; export $var; $relink_command"
55805eefee25Smacallan	fi
55815eefee25Smacallan      done
55825eefee25Smacallan      # Quote the link command for shipping.
55835eefee25Smacallan      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
55845eefee25Smacallan      relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
55855eefee25Smacallan      if test "$hardcode_automatic" = yes ; then
55865eefee25Smacallan	relink_command=
55875eefee25Smacallan      fi
55885eefee25Smacallan
55895eefee25Smacallan
55905eefee25Smacallan      # Only create the output if not a dry run.
55915eefee25Smacallan      if test -z "$run"; then
55925eefee25Smacallan	for installed in no yes; do
55935eefee25Smacallan	  if test "$installed" = yes; then
55945eefee25Smacallan	    if test -z "$install_libdir"; then
55955eefee25Smacallan	      break
55965eefee25Smacallan	    fi
55975eefee25Smacallan	    output="$output_objdir/$outputname"i
55985eefee25Smacallan	    # Replace all uninstalled libtool libraries with the installed ones
55995eefee25Smacallan	    newdependency_libs=
56005eefee25Smacallan	    for deplib in $dependency_libs; do
56015eefee25Smacallan	      case $deplib in
56025eefee25Smacallan	      *.la)
56035eefee25Smacallan		name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'`
56045eefee25Smacallan		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
56055eefee25Smacallan		if test -z "$libdir"; then
56065eefee25Smacallan		  $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
56075eefee25Smacallan		  exit $EXIT_FAILURE
56085eefee25Smacallan		fi
56095eefee25Smacallan		newdependency_libs="$newdependency_libs $libdir/$name"
56105eefee25Smacallan		;;
56115eefee25Smacallan	      *) newdependency_libs="$newdependency_libs $deplib" ;;
56125eefee25Smacallan	      esac
56135eefee25Smacallan	    done
56145eefee25Smacallan	    dependency_libs="$newdependency_libs"
56155eefee25Smacallan	    newdlfiles=
56165eefee25Smacallan	    for lib in $dlfiles; do
56175eefee25Smacallan	      name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
56185eefee25Smacallan	      eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
56195eefee25Smacallan	      if test -z "$libdir"; then
56205eefee25Smacallan		$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
56215eefee25Smacallan		exit $EXIT_FAILURE
56225eefee25Smacallan	      fi
56235eefee25Smacallan	      newdlfiles="$newdlfiles $libdir/$name"
56245eefee25Smacallan	    done
56255eefee25Smacallan	    dlfiles="$newdlfiles"
56265eefee25Smacallan	    newdlprefiles=
56275eefee25Smacallan	    for lib in $dlprefiles; do
56285eefee25Smacallan	      name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
56295eefee25Smacallan	      eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
56305eefee25Smacallan	      if test -z "$libdir"; then
56315eefee25Smacallan		$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
56325eefee25Smacallan		exit $EXIT_FAILURE
56335eefee25Smacallan	      fi
56345eefee25Smacallan	      newdlprefiles="$newdlprefiles $libdir/$name"
56355eefee25Smacallan	    done
56365eefee25Smacallan	    dlprefiles="$newdlprefiles"
56375eefee25Smacallan	  else
56385eefee25Smacallan	    newdlfiles=
56395eefee25Smacallan	    for lib in $dlfiles; do
56405eefee25Smacallan	      case $lib in
56415eefee25Smacallan		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
56425eefee25Smacallan		*) abs=`pwd`"/$lib" ;;
56435eefee25Smacallan	      esac
56445eefee25Smacallan	      newdlfiles="$newdlfiles $abs"
56455eefee25Smacallan	    done
56465eefee25Smacallan	    dlfiles="$newdlfiles"
56475eefee25Smacallan	    newdlprefiles=
56485eefee25Smacallan	    for lib in $dlprefiles; do
56495eefee25Smacallan	      case $lib in
56505eefee25Smacallan		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
56515eefee25Smacallan		*) abs=`pwd`"/$lib" ;;
56525eefee25Smacallan	      esac
56535eefee25Smacallan	      newdlprefiles="$newdlprefiles $abs"
56545eefee25Smacallan	    done
56555eefee25Smacallan	    dlprefiles="$newdlprefiles"
56565eefee25Smacallan	  fi
56575eefee25Smacallan	  $rm $output
56585eefee25Smacallan	  # place dlname in correct position for cygwin
56595eefee25Smacallan	  tdlname=$dlname
56605eefee25Smacallan	  case $host,$output,$installed,$module,$dlname in
56615eefee25Smacallan	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
56625eefee25Smacallan	  esac
56635eefee25Smacallan	  $echo > $output "\
56645eefee25Smacallan# $outputname - a libtool library file
56655eefee25Smacallan# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
56665eefee25Smacallan#
56675eefee25Smacallan# Please DO NOT delete this file!
56685eefee25Smacallan# It is necessary for linking the library.
56695eefee25Smacallan
56705eefee25Smacallan# The name that we can dlopen(3).
56715eefee25Smacallandlname='$tdlname'
56725eefee25Smacallan
56735eefee25Smacallan# Names of this library.
56745eefee25Smacallanlibrary_names='$library_names'
56755eefee25Smacallan
56765eefee25Smacallan# The name of the static archive.
56775eefee25Smacallanold_library='$old_library'
56785eefee25Smacallan
56795eefee25Smacallan# Libraries that this one depends upon.
56805eefee25Smacallandependency_libs='$dependency_libs'
56815eefee25Smacallan
56825eefee25Smacallan# Version information for $libname.
56835eefee25Smacallancurrent=$current
56845eefee25Smacallanage=$age
56855eefee25Smacallanrevision=$revision
56865eefee25Smacallan
56875eefee25Smacallan# Is this an already installed library?
56885eefee25Smacallaninstalled=$installed
56895eefee25Smacallan
56905eefee25Smacallan# Should we warn about portability when linking against -modules?
56915eefee25Smacallanshouldnotlink=$module
56925eefee25Smacallan
56935eefee25Smacallan# Files to dlopen/dlpreopen
56945eefee25Smacallandlopen='$dlfiles'
56955eefee25Smacallandlpreopen='$dlprefiles'
56965eefee25Smacallan
56975eefee25Smacallan# Directory that this library needs to be installed in:
56985eefee25Smacallanlibdir='$install_libdir'"
56995eefee25Smacallan	  if test "$installed" = no && test "$need_relink" = yes; then
57005eefee25Smacallan	    $echo >> $output "\
57015eefee25Smacallanrelink_command=\"$relink_command\""
57025eefee25Smacallan	  fi
57035eefee25Smacallan	done
57045eefee25Smacallan      fi
57055eefee25Smacallan
57065eefee25Smacallan      # Do a symbolic link so that the libtool archive can be found in
57075eefee25Smacallan      # LD_LIBRARY_PATH before the program is installed.
57085eefee25Smacallan      $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)"
57095eefee25Smacallan      $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $?
57105eefee25Smacallan      ;;
57115eefee25Smacallan    esac
57125eefee25Smacallan    exit $EXIT_SUCCESS
57135eefee25Smacallan    ;;
57145eefee25Smacallan
57155eefee25Smacallan  # libtool install mode
57165eefee25Smacallan  install)
57175eefee25Smacallan    modename="$modename: install"
57185eefee25Smacallan
57195eefee25Smacallan    # There may be an optional sh(1) argument at the beginning of
57205eefee25Smacallan    # install_prog (especially on Windows NT).
57215eefee25Smacallan    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
57225eefee25Smacallan       # Allow the use of GNU shtool's install command.
57235eefee25Smacallan       $echo "X$nonopt" | grep shtool > /dev/null; then
57245eefee25Smacallan      # Aesthetically quote it.
57255eefee25Smacallan      arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"`
57265eefee25Smacallan      case $arg in
57275eefee25Smacallan      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
57285eefee25Smacallan	arg="\"$arg\""
57295eefee25Smacallan	;;
57305eefee25Smacallan      esac
57315eefee25Smacallan      install_prog="$arg "
57325eefee25Smacallan      arg="$1"
57335eefee25Smacallan      shift
57345eefee25Smacallan    else
57355eefee25Smacallan      install_prog=
57365eefee25Smacallan      arg=$nonopt
57375eefee25Smacallan    fi
57385eefee25Smacallan
57395eefee25Smacallan    # The real first argument should be the name of the installation program.
57405eefee25Smacallan    # Aesthetically quote it.
57415eefee25Smacallan    arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
57425eefee25Smacallan    case $arg in
57435eefee25Smacallan    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
57445eefee25Smacallan      arg="\"$arg\""
57455eefee25Smacallan      ;;
57465eefee25Smacallan    esac
57475eefee25Smacallan    install_prog="$install_prog$arg"
57485eefee25Smacallan
57495eefee25Smacallan    # We need to accept at least all the BSD install flags.
57505eefee25Smacallan    dest=
57515eefee25Smacallan    files=
57525eefee25Smacallan    opts=
57535eefee25Smacallan    prev=
57545eefee25Smacallan    install_type=
57555eefee25Smacallan    isdir=no
57565eefee25Smacallan    stripme=
57575eefee25Smacallan    for arg
57585eefee25Smacallan    do
57595eefee25Smacallan      if test -n "$dest"; then
57605eefee25Smacallan	files="$files $dest"
57615eefee25Smacallan	dest=$arg
57625eefee25Smacallan	continue
57635eefee25Smacallan      fi
57645eefee25Smacallan
57655eefee25Smacallan      case $arg in
57665eefee25Smacallan      -d) isdir=yes ;;
57675eefee25Smacallan      -f) 
57685eefee25Smacallan      	case " $install_prog " in
57695eefee25Smacallan	*[\\\ /]cp\ *) ;;
57705eefee25Smacallan	*) prev=$arg ;;
57715eefee25Smacallan	esac
57725eefee25Smacallan	;;
57735eefee25Smacallan      -g | -m | -o) prev=$arg ;;
57745eefee25Smacallan      -s)
57755eefee25Smacallan	stripme=" -s"
57765eefee25Smacallan	continue
57775eefee25Smacallan	;;
57785eefee25Smacallan      -*)
57795eefee25Smacallan	;;
57805eefee25Smacallan      *)
57815eefee25Smacallan	# If the previous option needed an argument, then skip it.
57825eefee25Smacallan	if test -n "$prev"; then
57835eefee25Smacallan	  prev=
57845eefee25Smacallan	else
57855eefee25Smacallan	  dest=$arg
57865eefee25Smacallan	  continue
57875eefee25Smacallan	fi
57885eefee25Smacallan	;;
57895eefee25Smacallan      esac
57905eefee25Smacallan
57915eefee25Smacallan      # Aesthetically quote the argument.
57925eefee25Smacallan      arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
57935eefee25Smacallan      case $arg in
57945eefee25Smacallan      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
57955eefee25Smacallan	arg="\"$arg\""
57965eefee25Smacallan	;;
57975eefee25Smacallan      esac
57985eefee25Smacallan      install_prog="$install_prog $arg"
57995eefee25Smacallan    done
58005eefee25Smacallan
58015eefee25Smacallan    if test -z "$install_prog"; then
58025eefee25Smacallan      $echo "$modename: you must specify an install program" 1>&2
58035eefee25Smacallan      $echo "$help" 1>&2
58045eefee25Smacallan      exit $EXIT_FAILURE
58055eefee25Smacallan    fi
58065eefee25Smacallan
58075eefee25Smacallan    if test -n "$prev"; then
58085eefee25Smacallan      $echo "$modename: the \`$prev' option requires an argument" 1>&2
58095eefee25Smacallan      $echo "$help" 1>&2
58105eefee25Smacallan      exit $EXIT_FAILURE
58115eefee25Smacallan    fi
58125eefee25Smacallan
58135eefee25Smacallan    if test -z "$files"; then
58145eefee25Smacallan      if test -z "$dest"; then
58155eefee25Smacallan	$echo "$modename: no file or destination specified" 1>&2
58165eefee25Smacallan      else
58175eefee25Smacallan	$echo "$modename: you must specify a destination" 1>&2
58185eefee25Smacallan      fi
58195eefee25Smacallan      $echo "$help" 1>&2
58205eefee25Smacallan      exit $EXIT_FAILURE
58215eefee25Smacallan    fi
58225eefee25Smacallan
58235eefee25Smacallan    # Strip any trailing slash from the destination.
58245eefee25Smacallan    dest=`$echo "X$dest" | $Xsed -e 's%/$%%'`
58255eefee25Smacallan
58265eefee25Smacallan    # Check to see that the destination is a directory.
58275eefee25Smacallan    test -d "$dest" && isdir=yes
58285eefee25Smacallan    if test "$isdir" = yes; then
58295eefee25Smacallan      destdir="$dest"
58305eefee25Smacallan      destname=
58315eefee25Smacallan    else
58325eefee25Smacallan      destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'`
58335eefee25Smacallan      test "X$destdir" = "X$dest" && destdir=.
58345eefee25Smacallan      destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'`
58355eefee25Smacallan
58365eefee25Smacallan      # Not a directory, so check to see that there is only one file specified.
58375eefee25Smacallan      set dummy $files
58385eefee25Smacallan      if test "$#" -gt 2; then
58395eefee25Smacallan	$echo "$modename: \`$dest' is not a directory" 1>&2
58405eefee25Smacallan	$echo "$help" 1>&2
58415eefee25Smacallan	exit $EXIT_FAILURE
58425eefee25Smacallan      fi
58435eefee25Smacallan    fi
58445eefee25Smacallan    case $destdir in
58455eefee25Smacallan    [\\/]* | [A-Za-z]:[\\/]*) ;;
58465eefee25Smacallan    *)
58475eefee25Smacallan      for file in $files; do
58485eefee25Smacallan	case $file in
58495eefee25Smacallan	*.lo) ;;
58505eefee25Smacallan	*)
58515eefee25Smacallan	  $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2
58525eefee25Smacallan	  $echo "$help" 1>&2
58535eefee25Smacallan	  exit $EXIT_FAILURE
58545eefee25Smacallan	  ;;
58555eefee25Smacallan	esac
58565eefee25Smacallan      done
58575eefee25Smacallan      ;;
58585eefee25Smacallan    esac
58595eefee25Smacallan
58605eefee25Smacallan    # This variable tells wrapper scripts just to set variables rather
58615eefee25Smacallan    # than running their programs.
58625eefee25Smacallan    libtool_install_magic="$magic"
58635eefee25Smacallan
58645eefee25Smacallan    staticlibs=
58655eefee25Smacallan    future_libdirs=
58665eefee25Smacallan    current_libdirs=
58675eefee25Smacallan    for file in $files; do
58685eefee25Smacallan
58695eefee25Smacallan      # Do each installation.
58705eefee25Smacallan      case $file in
58715eefee25Smacallan      *.$libext)
58725eefee25Smacallan	# Do the static libraries later.
58735eefee25Smacallan	staticlibs="$staticlibs $file"
58745eefee25Smacallan	;;
58755eefee25Smacallan
58765eefee25Smacallan      *.la)
58775eefee25Smacallan	# Check to see that this really is a libtool archive.
58785eefee25Smacallan	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
58795eefee25Smacallan	else
58805eefee25Smacallan	  $echo "$modename: \`$file' is not a valid libtool archive" 1>&2
58815eefee25Smacallan	  $echo "$help" 1>&2
58825eefee25Smacallan	  exit $EXIT_FAILURE
58835eefee25Smacallan	fi
58845eefee25Smacallan
58855eefee25Smacallan	library_names=
58865eefee25Smacallan	old_library=
58875eefee25Smacallan	relink_command=
58885eefee25Smacallan	# If there is no directory component, then add one.
58895eefee25Smacallan	case $file in
58905eefee25Smacallan	*/* | *\\*) . $file ;;
58915eefee25Smacallan	*) . ./$file ;;
58925eefee25Smacallan	esac
58935eefee25Smacallan
58945eefee25Smacallan	# Add the libdir to current_libdirs if it is the destination.
58955eefee25Smacallan	if test "X$destdir" = "X$libdir"; then
58965eefee25Smacallan	  case "$current_libdirs " in
58975eefee25Smacallan	  *" $libdir "*) ;;
58985eefee25Smacallan	  *) current_libdirs="$current_libdirs $libdir" ;;
58995eefee25Smacallan	  esac
59005eefee25Smacallan	else
59015eefee25Smacallan	  # Note the libdir as a future libdir.
59025eefee25Smacallan	  case "$future_libdirs " in
59035eefee25Smacallan	  *" $libdir "*) ;;
59045eefee25Smacallan	  *) future_libdirs="$future_libdirs $libdir" ;;
59055eefee25Smacallan	  esac
59065eefee25Smacallan	fi
59075eefee25Smacallan
59085eefee25Smacallan	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/
59095eefee25Smacallan	test "X$dir" = "X$file/" && dir=
59105eefee25Smacallan	dir="$dir$objdir"
59115eefee25Smacallan
59125eefee25Smacallan	if test -n "$relink_command"; then
59135eefee25Smacallan	  # Determine the prefix the user has applied to our future dir.
59145eefee25Smacallan	  inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"`
59155eefee25Smacallan
59165eefee25Smacallan	  # Don't allow the user to place us outside of our expected
59175eefee25Smacallan	  # location b/c this prevents finding dependent libraries that
59185eefee25Smacallan	  # are installed to the same prefix.
59195eefee25Smacallan	  # At present, this check doesn't affect windows .dll's that
59205eefee25Smacallan	  # are installed into $libdir/../bin (currently, that works fine)
59215eefee25Smacallan	  # but it's something to keep an eye on.
59225eefee25Smacallan	  if test "$inst_prefix_dir" = "$destdir"; then
59235eefee25Smacallan	    $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2
59245eefee25Smacallan	    exit $EXIT_FAILURE
59255eefee25Smacallan	  fi
59265eefee25Smacallan
59275eefee25Smacallan	  if test -n "$inst_prefix_dir"; then
59285eefee25Smacallan	    # Stick the inst_prefix_dir data into the link command.
59295eefee25Smacallan	    relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
59305eefee25Smacallan	  else
59315eefee25Smacallan	    relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
59325eefee25Smacallan	  fi
59335eefee25Smacallan
59345eefee25Smacallan	  $echo "$modename: warning: relinking \`$file'" 1>&2
59355eefee25Smacallan	  $show "$relink_command"
59365eefee25Smacallan	  if $run eval "$relink_command"; then :
59375eefee25Smacallan	  else
59385eefee25Smacallan	    $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
59395eefee25Smacallan	    exit $EXIT_FAILURE
59405eefee25Smacallan	  fi
59415eefee25Smacallan	fi
59425eefee25Smacallan
59435eefee25Smacallan	# See the names of the shared library.
59445eefee25Smacallan	set dummy $library_names
59455eefee25Smacallan	if test -n "$2"; then
59465eefee25Smacallan	  realname="$2"
59475eefee25Smacallan	  shift
59485eefee25Smacallan	  shift
59495eefee25Smacallan
59505eefee25Smacallan	  srcname="$realname"
59515eefee25Smacallan	  test -n "$relink_command" && srcname="$realname"T
59525eefee25Smacallan
59535eefee25Smacallan	  # Install the shared library and build the symlinks.
59545eefee25Smacallan	  $show "$install_prog $dir/$srcname $destdir/$realname"
59555eefee25Smacallan	  $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $?
59565eefee25Smacallan	  if test -n "$stripme" && test -n "$striplib"; then
59575eefee25Smacallan	    $show "$striplib $destdir/$realname"
59585eefee25Smacallan	    $run eval "$striplib $destdir/$realname" || exit $?
59595eefee25Smacallan	  fi
59605eefee25Smacallan
59615eefee25Smacallan	  if test "$#" -gt 0; then
59625eefee25Smacallan	    # Delete the old symlinks, and create new ones.
59635eefee25Smacallan	    # Try `ln -sf' first, because the `ln' binary might depend on
59645eefee25Smacallan	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
59655eefee25Smacallan	    # so we also need to try rm && ln -s.
59665eefee25Smacallan	    for linkname
59675eefee25Smacallan	    do
59685eefee25Smacallan	      if test "$linkname" != "$realname"; then
59695eefee25Smacallan                $show "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
59705eefee25Smacallan                $run eval "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
59715eefee25Smacallan	      fi
59725eefee25Smacallan	    done
59735eefee25Smacallan	  fi
59745eefee25Smacallan
59755eefee25Smacallan	  # Do each command in the postinstall commands.
59765eefee25Smacallan	  lib="$destdir/$realname"
59775eefee25Smacallan	  cmds=$postinstall_cmds
59785eefee25Smacallan	  save_ifs="$IFS"; IFS='~'
59795eefee25Smacallan	  for cmd in $cmds; do
59805eefee25Smacallan	    IFS="$save_ifs"
59815eefee25Smacallan	    eval cmd=\"$cmd\"
59825eefee25Smacallan	    $show "$cmd"
59835eefee25Smacallan	    $run eval "$cmd" || {
59845eefee25Smacallan	      lt_exit=$?
59855eefee25Smacallan
59865eefee25Smacallan	      # Restore the uninstalled library and exit
59875eefee25Smacallan	      if test "$mode" = relink; then
59885eefee25Smacallan		$run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
59895eefee25Smacallan	      fi
59905eefee25Smacallan
59915eefee25Smacallan	      exit $lt_exit
59925eefee25Smacallan	    }
59935eefee25Smacallan	  done
59945eefee25Smacallan	  IFS="$save_ifs"
59955eefee25Smacallan	fi
59965eefee25Smacallan
59975eefee25Smacallan	# Install the pseudo-library for information purposes.
59985eefee25Smacallan	name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
59995eefee25Smacallan	instname="$dir/$name"i
60005eefee25Smacallan	$show "$install_prog $instname $destdir/$name"
60015eefee25Smacallan	$run eval "$install_prog $instname $destdir/$name" || exit $?
60025eefee25Smacallan
60035eefee25Smacallan	# Maybe install the static library, too.
60045eefee25Smacallan	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
60055eefee25Smacallan	;;
60065eefee25Smacallan
60075eefee25Smacallan      *.lo)
60085eefee25Smacallan	# Install (i.e. copy) a libtool object.
60095eefee25Smacallan
60105eefee25Smacallan	# Figure out destination file name, if it wasn't already specified.
60115eefee25Smacallan	if test -n "$destname"; then
60125eefee25Smacallan	  destfile="$destdir/$destname"
60135eefee25Smacallan	else
60145eefee25Smacallan	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
60155eefee25Smacallan	  destfile="$destdir/$destfile"
60165eefee25Smacallan	fi
60175eefee25Smacallan
60185eefee25Smacallan	# Deduce the name of the destination old-style object file.
60195eefee25Smacallan	case $destfile in
60205eefee25Smacallan	*.lo)
60215eefee25Smacallan	  staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"`
60225eefee25Smacallan	  ;;
60235eefee25Smacallan	*.$objext)
60245eefee25Smacallan	  staticdest="$destfile"
60255eefee25Smacallan	  destfile=
60265eefee25Smacallan	  ;;
60275eefee25Smacallan	*)
60285eefee25Smacallan	  $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2
60295eefee25Smacallan	  $echo "$help" 1>&2
60305eefee25Smacallan	  exit $EXIT_FAILURE
60315eefee25Smacallan	  ;;
60325eefee25Smacallan	esac
60335eefee25Smacallan
60345eefee25Smacallan	# Install the libtool object if requested.
60355eefee25Smacallan	if test -n "$destfile"; then
60365eefee25Smacallan	  $show "$install_prog $file $destfile"
60375eefee25Smacallan	  $run eval "$install_prog $file $destfile" || exit $?
60385eefee25Smacallan	fi
60395eefee25Smacallan
60405eefee25Smacallan	# Install the old object if enabled.
60415eefee25Smacallan	if test "$build_old_libs" = yes; then
60425eefee25Smacallan	  # Deduce the name of the old-style object file.
60435eefee25Smacallan	  staticobj=`$echo "X$file" | $Xsed -e "$lo2o"`
60445eefee25Smacallan
60455eefee25Smacallan	  $show "$install_prog $staticobj $staticdest"
60465eefee25Smacallan	  $run eval "$install_prog \$staticobj \$staticdest" || exit $?
60475eefee25Smacallan	fi
60485eefee25Smacallan	exit $EXIT_SUCCESS
60495eefee25Smacallan	;;
60505eefee25Smacallan
60515eefee25Smacallan      *)
60525eefee25Smacallan	# Figure out destination file name, if it wasn't already specified.
60535eefee25Smacallan	if test -n "$destname"; then
60545eefee25Smacallan	  destfile="$destdir/$destname"
60555eefee25Smacallan	else
60565eefee25Smacallan	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
60575eefee25Smacallan	  destfile="$destdir/$destfile"
60585eefee25Smacallan	fi
60595eefee25Smacallan
60605eefee25Smacallan	# If the file is missing, and there is a .exe on the end, strip it
60615eefee25Smacallan	# because it is most likely a libtool script we actually want to
60625eefee25Smacallan	# install
60635eefee25Smacallan	stripped_ext=""
60645eefee25Smacallan	case $file in
60655eefee25Smacallan	  *.exe)
60665eefee25Smacallan	    if test ! -f "$file"; then
60675eefee25Smacallan	      file=`$echo $file|${SED} 's,.exe$,,'`
60685eefee25Smacallan	      stripped_ext=".exe"
60695eefee25Smacallan	    fi
60705eefee25Smacallan	    ;;
60715eefee25Smacallan	esac
60725eefee25Smacallan
60735eefee25Smacallan	# Do a test to see if this is really a libtool program.
60745eefee25Smacallan	case $host in
60755eefee25Smacallan	*cygwin*|*mingw*)
60765eefee25Smacallan	    wrapper=`$echo $file | ${SED} -e 's,.exe$,,'`
60775eefee25Smacallan	    ;;
60785eefee25Smacallan	*)
60795eefee25Smacallan	    wrapper=$file
60805eefee25Smacallan	    ;;
60815eefee25Smacallan	esac
60825eefee25Smacallan	if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then
60835eefee25Smacallan	  notinst_deplibs=
60845eefee25Smacallan	  relink_command=
60855eefee25Smacallan
60865eefee25Smacallan	  # Note that it is not necessary on cygwin/mingw to append a dot to
60875eefee25Smacallan	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
60885eefee25Smacallan	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
60895eefee25Smacallan	  # `FILE.' does not work on cygwin managed mounts.
60905eefee25Smacallan	  #
60915eefee25Smacallan	  # If there is no directory component, then add one.
60925eefee25Smacallan	  case $wrapper in
60935eefee25Smacallan	  */* | *\\*) . ${wrapper} ;;
60945eefee25Smacallan	  *) . ./${wrapper} ;;
60955eefee25Smacallan	  esac
60965eefee25Smacallan
60975eefee25Smacallan	  # Check the variables that should have been set.
60985eefee25Smacallan	  if test -z "$notinst_deplibs"; then
60995eefee25Smacallan	    $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2
61005eefee25Smacallan	    exit $EXIT_FAILURE
61015eefee25Smacallan	  fi
61025eefee25Smacallan
61035eefee25Smacallan	  finalize=yes
61045eefee25Smacallan	  for lib in $notinst_deplibs; do
61055eefee25Smacallan	    # Check to see that each library is installed.
61065eefee25Smacallan	    libdir=
61075eefee25Smacallan	    if test -f "$lib"; then
61085eefee25Smacallan	      # If there is no directory component, then add one.
61095eefee25Smacallan	      case $lib in
61105eefee25Smacallan	      */* | *\\*) . $lib ;;
61115eefee25Smacallan	      *) . ./$lib ;;
61125eefee25Smacallan	      esac
61135eefee25Smacallan	    fi
61145eefee25Smacallan	    libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
61155eefee25Smacallan	    if test -n "$libdir" && test ! -f "$libfile"; then
61165eefee25Smacallan	      $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2
61175eefee25Smacallan	      finalize=no
61185eefee25Smacallan	    fi
61195eefee25Smacallan	  done
61205eefee25Smacallan
61215eefee25Smacallan	  relink_command=
61225eefee25Smacallan	  # Note that it is not necessary on cygwin/mingw to append a dot to
61235eefee25Smacallan	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
61245eefee25Smacallan	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
61255eefee25Smacallan	  # `FILE.' does not work on cygwin managed mounts.
61265eefee25Smacallan	  #
61275eefee25Smacallan	  # If there is no directory component, then add one.
61285eefee25Smacallan	  case $wrapper in
61295eefee25Smacallan	  */* | *\\*) . ${wrapper} ;;
61305eefee25Smacallan	  *) . ./${wrapper} ;;
61315eefee25Smacallan	  esac
61325eefee25Smacallan
61335eefee25Smacallan	  outputname=
61345eefee25Smacallan	  if test "$fast_install" = no && test -n "$relink_command"; then
61355eefee25Smacallan	    if test "$finalize" = yes && test -z "$run"; then
61365eefee25Smacallan	      tmpdir=`func_mktempdir`
61375eefee25Smacallan	      file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
61385eefee25Smacallan	      outputname="$tmpdir/$file"
61395eefee25Smacallan	      # Replace the output file specification.
61405eefee25Smacallan	      relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
61415eefee25Smacallan
61425eefee25Smacallan	      $show "$relink_command"
61435eefee25Smacallan	      if $run eval "$relink_command"; then :
61445eefee25Smacallan	      else
61455eefee25Smacallan		$echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
61465eefee25Smacallan		${rm}r "$tmpdir"
61475eefee25Smacallan		continue
61485eefee25Smacallan	      fi
61495eefee25Smacallan	      file="$outputname"
61505eefee25Smacallan	    else
61515eefee25Smacallan	      $echo "$modename: warning: cannot relink \`$file'" 1>&2
61525eefee25Smacallan	    fi
61535eefee25Smacallan	  else
61545eefee25Smacallan	    # Install the binary that we compiled earlier.
61555eefee25Smacallan	    file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
61565eefee25Smacallan	  fi
61575eefee25Smacallan	fi
61585eefee25Smacallan
61595eefee25Smacallan	# remove .exe since cygwin /usr/bin/install will append another
61605eefee25Smacallan	# one anyway 
61615eefee25Smacallan	case $install_prog,$host in
61625eefee25Smacallan	*/usr/bin/install*,*cygwin*)
61635eefee25Smacallan	  case $file:$destfile in
61645eefee25Smacallan	  *.exe:*.exe)
61655eefee25Smacallan	    # this is ok
61665eefee25Smacallan	    ;;
61675eefee25Smacallan	  *.exe:*)
61685eefee25Smacallan	    destfile=$destfile.exe
61695eefee25Smacallan	    ;;
61705eefee25Smacallan	  *:*.exe)
61715eefee25Smacallan	    destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'`
61725eefee25Smacallan	    ;;
61735eefee25Smacallan	  esac
61745eefee25Smacallan	  ;;
61755eefee25Smacallan	esac
61765eefee25Smacallan	$show "$install_prog$stripme $file $destfile"
61775eefee25Smacallan	$run eval "$install_prog\$stripme \$file \$destfile" || exit $?
61785eefee25Smacallan	test -n "$outputname" && ${rm}r "$tmpdir"
61795eefee25Smacallan	;;
61805eefee25Smacallan      esac
61815eefee25Smacallan    done
61825eefee25Smacallan
61835eefee25Smacallan    for file in $staticlibs; do
61845eefee25Smacallan      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
61855eefee25Smacallan
61865eefee25Smacallan      # Set up the ranlib parameters.
61875eefee25Smacallan      oldlib="$destdir/$name"
61885eefee25Smacallan
61895eefee25Smacallan      $show "$install_prog $file $oldlib"
61905eefee25Smacallan      $run eval "$install_prog \$file \$oldlib" || exit $?
61915eefee25Smacallan
61925eefee25Smacallan      if test -n "$stripme" && test -n "$old_striplib"; then
61935eefee25Smacallan	$show "$old_striplib $oldlib"
61945eefee25Smacallan	$run eval "$old_striplib $oldlib" || exit $?
61955eefee25Smacallan      fi
61965eefee25Smacallan
61975eefee25Smacallan      # Do each command in the postinstall commands.
61985eefee25Smacallan      cmds=$old_postinstall_cmds
61995eefee25Smacallan      save_ifs="$IFS"; IFS='~'
62005eefee25Smacallan      for cmd in $cmds; do
62015eefee25Smacallan	IFS="$save_ifs"
62025eefee25Smacallan	eval cmd=\"$cmd\"
62035eefee25Smacallan	$show "$cmd"
62045eefee25Smacallan	$run eval "$cmd" || exit $?
62055eefee25Smacallan      done
62065eefee25Smacallan      IFS="$save_ifs"
62075eefee25Smacallan    done
62085eefee25Smacallan
62095eefee25Smacallan    if test -n "$future_libdirs"; then
62105eefee25Smacallan      $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2
62115eefee25Smacallan    fi
62125eefee25Smacallan
62135eefee25Smacallan    if test -n "$current_libdirs"; then
62145eefee25Smacallan      # Maybe just do a dry run.
62155eefee25Smacallan      test -n "$run" && current_libdirs=" -n$current_libdirs"
62165eefee25Smacallan      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
62175eefee25Smacallan    else
62185eefee25Smacallan      exit $EXIT_SUCCESS
62195eefee25Smacallan    fi
62205eefee25Smacallan    ;;
62215eefee25Smacallan
62225eefee25Smacallan  # libtool finish mode
62235eefee25Smacallan  finish)
62245eefee25Smacallan    modename="$modename: finish"
62255eefee25Smacallan    libdirs="$nonopt"
62265eefee25Smacallan    admincmds=
62275eefee25Smacallan
62285eefee25Smacallan    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
62295eefee25Smacallan      for dir
62305eefee25Smacallan      do
62315eefee25Smacallan	libdirs="$libdirs $dir"
62325eefee25Smacallan      done
62335eefee25Smacallan
62345eefee25Smacallan      for libdir in $libdirs; do
62355eefee25Smacallan	if test -n "$finish_cmds"; then
62365eefee25Smacallan	  # Do each command in the finish commands.
62375eefee25Smacallan	  cmds=$finish_cmds
62385eefee25Smacallan	  save_ifs="$IFS"; IFS='~'
62395eefee25Smacallan	  for cmd in $cmds; do
62405eefee25Smacallan	    IFS="$save_ifs"
62415eefee25Smacallan	    eval cmd=\"$cmd\"
62425eefee25Smacallan	    $show "$cmd"
62435eefee25Smacallan	    $run eval "$cmd" || admincmds="$admincmds
62445eefee25Smacallan       $cmd"
62455eefee25Smacallan	  done
62465eefee25Smacallan	  IFS="$save_ifs"
62475eefee25Smacallan	fi
62485eefee25Smacallan	if test -n "$finish_eval"; then
62495eefee25Smacallan	  # Do the single finish_eval.
62505eefee25Smacallan	  eval cmds=\"$finish_eval\"
62515eefee25Smacallan	  $run eval "$cmds" || admincmds="$admincmds
62525eefee25Smacallan       $cmds"
62535eefee25Smacallan	fi
62545eefee25Smacallan      done
62555eefee25Smacallan    fi
62565eefee25Smacallan
62575eefee25Smacallan    # Exit here if they wanted silent mode.
62585eefee25Smacallan    test "$show" = : && exit $EXIT_SUCCESS
62595eefee25Smacallan
62605eefee25Smacallan    $echo "X----------------------------------------------------------------------" | $Xsed
62615eefee25Smacallan    $echo "Libraries have been installed in:"
62625eefee25Smacallan    for libdir in $libdirs; do
62635eefee25Smacallan      $echo "   $libdir"
62645eefee25Smacallan    done
62655eefee25Smacallan    $echo
62665eefee25Smacallan    $echo "If you ever happen to want to link against installed libraries"
62675eefee25Smacallan    $echo "in a given directory, LIBDIR, you must either use libtool, and"
62685eefee25Smacallan    $echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
62695eefee25Smacallan    $echo "flag during linking and do at least one of the following:"
62705eefee25Smacallan    if test -n "$shlibpath_var"; then
62715eefee25Smacallan      $echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
62725eefee25Smacallan      $echo "     during execution"
62735eefee25Smacallan    fi
62745eefee25Smacallan    if test -n "$runpath_var"; then
62755eefee25Smacallan      $echo "   - add LIBDIR to the \`$runpath_var' environment variable"
62765eefee25Smacallan      $echo "     during linking"
62775eefee25Smacallan    fi
62785eefee25Smacallan    if test -n "$hardcode_libdir_flag_spec"; then
62795eefee25Smacallan      libdir=LIBDIR
62805eefee25Smacallan      eval flag=\"$hardcode_libdir_flag_spec\"
62815eefee25Smacallan
62825eefee25Smacallan      $echo "   - use the \`$flag' linker flag"
62835eefee25Smacallan    fi
62845eefee25Smacallan    if test -n "$admincmds"; then
62855eefee25Smacallan      $echo "   - have your system administrator run these commands:$admincmds"
62865eefee25Smacallan    fi
62875eefee25Smacallan    if test -f /etc/ld.so.conf; then
62885eefee25Smacallan      $echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
62895eefee25Smacallan    fi
62905eefee25Smacallan    $echo
62915eefee25Smacallan    $echo "See any operating system documentation about shared libraries for"
62925eefee25Smacallan    $echo "more information, such as the ld(1) and ld.so(8) manual pages."
62935eefee25Smacallan    $echo "X----------------------------------------------------------------------" | $Xsed
62945eefee25Smacallan    exit $EXIT_SUCCESS
62955eefee25Smacallan    ;;
62965eefee25Smacallan
62975eefee25Smacallan  # libtool execute mode
62985eefee25Smacallan  execute)
62995eefee25Smacallan    modename="$modename: execute"
63005eefee25Smacallan
63015eefee25Smacallan    # The first argument is the command name.
63025eefee25Smacallan    cmd="$nonopt"
63035eefee25Smacallan    if test -z "$cmd"; then
63045eefee25Smacallan      $echo "$modename: you must specify a COMMAND" 1>&2
63055eefee25Smacallan      $echo "$help"
63065eefee25Smacallan      exit $EXIT_FAILURE
63075eefee25Smacallan    fi
63085eefee25Smacallan
63095eefee25Smacallan    # Handle -dlopen flags immediately.
63105eefee25Smacallan    for file in $execute_dlfiles; do
63115eefee25Smacallan      if test ! -f "$file"; then
63125eefee25Smacallan	$echo "$modename: \`$file' is not a file" 1>&2
63135eefee25Smacallan	$echo "$help" 1>&2
63145eefee25Smacallan	exit $EXIT_FAILURE
63155eefee25Smacallan      fi
63165eefee25Smacallan
63175eefee25Smacallan      dir=
63185eefee25Smacallan      case $file in
63195eefee25Smacallan      *.la)
63205eefee25Smacallan	# Check to see that this really is a libtool archive.
63215eefee25Smacallan	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
63225eefee25Smacallan	else
63235eefee25Smacallan	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
63245eefee25Smacallan	  $echo "$help" 1>&2
63255eefee25Smacallan	  exit $EXIT_FAILURE
63265eefee25Smacallan	fi
63275eefee25Smacallan
63285eefee25Smacallan	# Read the libtool library.
63295eefee25Smacallan	dlname=
63305eefee25Smacallan	library_names=
63315eefee25Smacallan
63325eefee25Smacallan	# If there is no directory component, then add one.
63335eefee25Smacallan	case $file in
63345eefee25Smacallan	*/* | *\\*) . $file ;;
63355eefee25Smacallan	*) . ./$file ;;
63365eefee25Smacallan	esac
63375eefee25Smacallan
63385eefee25Smacallan	# Skip this library if it cannot be dlopened.
63395eefee25Smacallan	if test -z "$dlname"; then
63405eefee25Smacallan	  # Warn if it was a shared library.
63415eefee25Smacallan	  test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'"
63425eefee25Smacallan	  continue
63435eefee25Smacallan	fi
63445eefee25Smacallan
63455eefee25Smacallan	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
63465eefee25Smacallan	test "X$dir" = "X$file" && dir=.
63475eefee25Smacallan
63485eefee25Smacallan	if test -f "$dir/$objdir/$dlname"; then
63495eefee25Smacallan	  dir="$dir/$objdir"
63505eefee25Smacallan	else
63515eefee25Smacallan	  $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
63525eefee25Smacallan	  exit $EXIT_FAILURE
63535eefee25Smacallan	fi
63545eefee25Smacallan	;;
63555eefee25Smacallan
63565eefee25Smacallan      *.lo)
63575eefee25Smacallan	# Just add the directory containing the .lo file.
63585eefee25Smacallan	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
63595eefee25Smacallan	test "X$dir" = "X$file" && dir=.
63605eefee25Smacallan	;;
63615eefee25Smacallan
63625eefee25Smacallan      *)
63635eefee25Smacallan	$echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2
63645eefee25Smacallan	continue
63655eefee25Smacallan	;;
63665eefee25Smacallan      esac
63675eefee25Smacallan
63685eefee25Smacallan      # Get the absolute pathname.
63695eefee25Smacallan      absdir=`cd "$dir" && pwd`
63705eefee25Smacallan      test -n "$absdir" && dir="$absdir"
63715eefee25Smacallan
63725eefee25Smacallan      # Now add the directory to shlibpath_var.
63735eefee25Smacallan      if eval "test -z \"\$$shlibpath_var\""; then
63745eefee25Smacallan	eval "$shlibpath_var=\"\$dir\""
63755eefee25Smacallan      else
63765eefee25Smacallan	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
63775eefee25Smacallan      fi
63785eefee25Smacallan    done
63795eefee25Smacallan
63805eefee25Smacallan    # This variable tells wrapper scripts just to set shlibpath_var
63815eefee25Smacallan    # rather than running their programs.
63825eefee25Smacallan    libtool_execute_magic="$magic"
63835eefee25Smacallan
63845eefee25Smacallan    # Check if any of the arguments is a wrapper script.
63855eefee25Smacallan    args=
63865eefee25Smacallan    for file
63875eefee25Smacallan    do
63885eefee25Smacallan      case $file in
63895eefee25Smacallan      -*) ;;
63905eefee25Smacallan      *)
63915eefee25Smacallan	# Do a test to see if this is really a libtool program.
63925eefee25Smacallan	if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
63935eefee25Smacallan	  # If there is no directory component, then add one.
63945eefee25Smacallan	  case $file in
63955eefee25Smacallan	  */* | *\\*) . $file ;;
63965eefee25Smacallan	  *) . ./$file ;;
63975eefee25Smacallan	  esac
63985eefee25Smacallan
63995eefee25Smacallan	  # Transform arg to wrapped name.
64005eefee25Smacallan	  file="$progdir/$program"
64015eefee25Smacallan	fi
64025eefee25Smacallan	;;
64035eefee25Smacallan      esac
64045eefee25Smacallan      # Quote arguments (to preserve shell metacharacters).
64055eefee25Smacallan      file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"`
64065eefee25Smacallan      args="$args \"$file\""
64075eefee25Smacallan    done
64085eefee25Smacallan
64095eefee25Smacallan    if test -z "$run"; then
64105eefee25Smacallan      if test -n "$shlibpath_var"; then
64115eefee25Smacallan	# Export the shlibpath_var.
64125eefee25Smacallan	eval "export $shlibpath_var"
64135eefee25Smacallan      fi
64145eefee25Smacallan
64155eefee25Smacallan      # Restore saved environment variables
64165eefee25Smacallan      if test "${save_LC_ALL+set}" = set; then
64175eefee25Smacallan	LC_ALL="$save_LC_ALL"; export LC_ALL
64185eefee25Smacallan      fi
64195eefee25Smacallan      if test "${save_LANG+set}" = set; then
64205eefee25Smacallan	LANG="$save_LANG"; export LANG
64215eefee25Smacallan      fi
64225eefee25Smacallan
64235eefee25Smacallan      # Now prepare to actually exec the command.
64245eefee25Smacallan      exec_cmd="\$cmd$args"
64255eefee25Smacallan    else
64265eefee25Smacallan      # Display what would be done.
64275eefee25Smacallan      if test -n "$shlibpath_var"; then
64285eefee25Smacallan	eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\""
64295eefee25Smacallan	$echo "export $shlibpath_var"
64305eefee25Smacallan      fi
64315eefee25Smacallan      $echo "$cmd$args"
64325eefee25Smacallan      exit $EXIT_SUCCESS
64335eefee25Smacallan    fi
64345eefee25Smacallan    ;;
64355eefee25Smacallan
64365eefee25Smacallan  # libtool clean and uninstall mode
64375eefee25Smacallan  clean | uninstall)
64385eefee25Smacallan    modename="$modename: $mode"
64395eefee25Smacallan    rm="$nonopt"
64405eefee25Smacallan    files=
64415eefee25Smacallan    rmforce=
64425eefee25Smacallan    exit_status=0
64435eefee25Smacallan
64445eefee25Smacallan    # This variable tells wrapper scripts just to set variables rather
64455eefee25Smacallan    # than running their programs.
64465eefee25Smacallan    libtool_install_magic="$magic"
64475eefee25Smacallan
64485eefee25Smacallan    for arg
64495eefee25Smacallan    do
64505eefee25Smacallan      case $arg in
64515eefee25Smacallan      -f) rm="$rm $arg"; rmforce=yes ;;
64525eefee25Smacallan      -*) rm="$rm $arg" ;;
64535eefee25Smacallan      *) files="$files $arg" ;;
64545eefee25Smacallan      esac
64555eefee25Smacallan    done
64565eefee25Smacallan
64575eefee25Smacallan    if test -z "$rm"; then
64585eefee25Smacallan      $echo "$modename: you must specify an RM program" 1>&2
64595eefee25Smacallan      $echo "$help" 1>&2
64605eefee25Smacallan      exit $EXIT_FAILURE
64615eefee25Smacallan    fi
64625eefee25Smacallan
64635eefee25Smacallan    rmdirs=
64645eefee25Smacallan
64655eefee25Smacallan    origobjdir="$objdir"
64665eefee25Smacallan    for file in $files; do
64675eefee25Smacallan      dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
64685eefee25Smacallan      if test "X$dir" = "X$file"; then
64695eefee25Smacallan	dir=.
64705eefee25Smacallan	objdir="$origobjdir"
64715eefee25Smacallan      else
64725eefee25Smacallan	objdir="$dir/$origobjdir"
64735eefee25Smacallan      fi
64745eefee25Smacallan      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
64755eefee25Smacallan      test "$mode" = uninstall && objdir="$dir"
64765eefee25Smacallan
64775eefee25Smacallan      # Remember objdir for removal later, being careful to avoid duplicates
64785eefee25Smacallan      if test "$mode" = clean; then
64795eefee25Smacallan	case " $rmdirs " in
64805eefee25Smacallan	  *" $objdir "*) ;;
64815eefee25Smacallan	  *) rmdirs="$rmdirs $objdir" ;;
64825eefee25Smacallan	esac
64835eefee25Smacallan      fi
64845eefee25Smacallan
64855eefee25Smacallan      # Don't error if the file doesn't exist and rm -f was used.
64865eefee25Smacallan      if (test -L "$file") >/dev/null 2>&1 \
64875eefee25Smacallan	|| (test -h "$file") >/dev/null 2>&1 \
64885eefee25Smacallan	|| test -f "$file"; then
64895eefee25Smacallan	:
64905eefee25Smacallan      elif test -d "$file"; then
64915eefee25Smacallan	exit_status=1
64925eefee25Smacallan	continue
64935eefee25Smacallan      elif test "$rmforce" = yes; then
64945eefee25Smacallan	continue
64955eefee25Smacallan      fi
64965eefee25Smacallan
64975eefee25Smacallan      rmfiles="$file"
64985eefee25Smacallan
64995eefee25Smacallan      case $name in
65005eefee25Smacallan      *.la)
65015eefee25Smacallan	# Possibly a libtool archive, so verify it.
65025eefee25Smacallan	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
65035eefee25Smacallan	  . $dir/$name
65045eefee25Smacallan
65055eefee25Smacallan	  # Delete the libtool libraries and symlinks.
65065eefee25Smacallan	  for n in $library_names; do
65075eefee25Smacallan	    rmfiles="$rmfiles $objdir/$n"
65085eefee25Smacallan	  done
65095eefee25Smacallan	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
65105eefee25Smacallan
65115eefee25Smacallan	  case "$mode" in
65125eefee25Smacallan	  clean)
65135eefee25Smacallan	    case "  $library_names " in
65145eefee25Smacallan	    # "  " in the beginning catches empty $dlname
65155eefee25Smacallan	    *" $dlname "*) ;;
65165eefee25Smacallan	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
65175eefee25Smacallan	    esac
65185eefee25Smacallan	     test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
65195eefee25Smacallan	    ;;
65205eefee25Smacallan	  uninstall)
65215eefee25Smacallan	    if test -n "$library_names"; then
65225eefee25Smacallan	      # Do each command in the postuninstall commands.
65235eefee25Smacallan	      cmds=$postuninstall_cmds
65245eefee25Smacallan	      save_ifs="$IFS"; IFS='~'
65255eefee25Smacallan	      for cmd in $cmds; do
65265eefee25Smacallan		IFS="$save_ifs"
65275eefee25Smacallan		eval cmd=\"$cmd\"
65285eefee25Smacallan		$show "$cmd"
65295eefee25Smacallan		$run eval "$cmd"
65305eefee25Smacallan		if test "$?" -ne 0 && test "$rmforce" != yes; then
65315eefee25Smacallan		  exit_status=1
65325eefee25Smacallan		fi
65335eefee25Smacallan	      done
65345eefee25Smacallan	      IFS="$save_ifs"
65355eefee25Smacallan	    fi
65365eefee25Smacallan
65375eefee25Smacallan	    if test -n "$old_library"; then
65385eefee25Smacallan	      # Do each command in the old_postuninstall commands.
65395eefee25Smacallan	      cmds=$old_postuninstall_cmds
65405eefee25Smacallan	      save_ifs="$IFS"; IFS='~'
65415eefee25Smacallan	      for cmd in $cmds; do
65425eefee25Smacallan		IFS="$save_ifs"
65435eefee25Smacallan		eval cmd=\"$cmd\"
65445eefee25Smacallan		$show "$cmd"
65455eefee25Smacallan		$run eval "$cmd"
65465eefee25Smacallan		if test "$?" -ne 0 && test "$rmforce" != yes; then
65475eefee25Smacallan		  exit_status=1
65485eefee25Smacallan		fi
65495eefee25Smacallan	      done
65505eefee25Smacallan	      IFS="$save_ifs"
65515eefee25Smacallan	    fi
65525eefee25Smacallan	    # FIXME: should reinstall the best remaining shared library.
65535eefee25Smacallan	    ;;
65545eefee25Smacallan	  esac
65555eefee25Smacallan	fi
65565eefee25Smacallan	;;
65575eefee25Smacallan
65585eefee25Smacallan      *.lo)
65595eefee25Smacallan	# Possibly a libtool object, so verify it.
65605eefee25Smacallan	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
65615eefee25Smacallan
65625eefee25Smacallan	  # Read the .lo file
65635eefee25Smacallan	  . $dir/$name
65645eefee25Smacallan
65655eefee25Smacallan	  # Add PIC object to the list of files to remove.
65665eefee25Smacallan	  if test -n "$pic_object" \
65675eefee25Smacallan	     && test "$pic_object" != none; then
65685eefee25Smacallan	    rmfiles="$rmfiles $dir/$pic_object"
65695eefee25Smacallan	  fi
65705eefee25Smacallan
65715eefee25Smacallan	  # Add non-PIC object to the list of files to remove.
65725eefee25Smacallan	  if test -n "$non_pic_object" \
65735eefee25Smacallan	     && test "$non_pic_object" != none; then
65745eefee25Smacallan	    rmfiles="$rmfiles $dir/$non_pic_object"
65755eefee25Smacallan	  fi
65765eefee25Smacallan	fi
65775eefee25Smacallan	;;
65785eefee25Smacallan
65795eefee25Smacallan      *)
65805eefee25Smacallan	if test "$mode" = clean ; then
65815eefee25Smacallan	  noexename=$name
65825eefee25Smacallan	  case $file in
65835eefee25Smacallan	  *.exe)
65845eefee25Smacallan	    file=`$echo $file|${SED} 's,.exe$,,'`
65855eefee25Smacallan	    noexename=`$echo $name|${SED} 's,.exe$,,'`
65865eefee25Smacallan	    # $file with .exe has already been added to rmfiles,
65875eefee25Smacallan	    # add $file without .exe
65885eefee25Smacallan	    rmfiles="$rmfiles $file"
65895eefee25Smacallan	    ;;
65905eefee25Smacallan	  esac
65915eefee25Smacallan	  # Do a test to see if this is a libtool program.
65925eefee25Smacallan	  if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
65935eefee25Smacallan	    relink_command=
65945eefee25Smacallan	    . $dir/$noexename
65955eefee25Smacallan
65965eefee25Smacallan	    # note $name still contains .exe if it was in $file originally
65975eefee25Smacallan	    # as does the version of $file that was added into $rmfiles
65985eefee25Smacallan	    rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
65995eefee25Smacallan	    if test "$fast_install" = yes && test -n "$relink_command"; then
66005eefee25Smacallan	      rmfiles="$rmfiles $objdir/lt-$name"
66015eefee25Smacallan	    fi
66025eefee25Smacallan	    if test "X$noexename" != "X$name" ; then
66035eefee25Smacallan	      rmfiles="$rmfiles $objdir/lt-${noexename}.c"
66045eefee25Smacallan	    fi
66055eefee25Smacallan	  fi
66065eefee25Smacallan	fi
66075eefee25Smacallan	;;
66085eefee25Smacallan      esac
66095eefee25Smacallan      $show "$rm $rmfiles"
66105eefee25Smacallan      $run $rm $rmfiles || exit_status=1
66115eefee25Smacallan    done
66125eefee25Smacallan    objdir="$origobjdir"
66135eefee25Smacallan
66145eefee25Smacallan    # Try to remove the ${objdir}s in the directories where we deleted files
66155eefee25Smacallan    for dir in $rmdirs; do
66165eefee25Smacallan      if test -d "$dir"; then
66175eefee25Smacallan	$show "rmdir $dir"
66185eefee25Smacallan	$run rmdir $dir >/dev/null 2>&1
66195eefee25Smacallan      fi
66205eefee25Smacallan    done
66215eefee25Smacallan
66225eefee25Smacallan    exit $exit_status
66235eefee25Smacallan    ;;
66245eefee25Smacallan
66255eefee25Smacallan  "")
66265eefee25Smacallan    $echo "$modename: you must specify a MODE" 1>&2
66275eefee25Smacallan    $echo "$generic_help" 1>&2
66285eefee25Smacallan    exit $EXIT_FAILURE
66295eefee25Smacallan    ;;
66305eefee25Smacallan  esac
66315eefee25Smacallan
66325eefee25Smacallan  if test -z "$exec_cmd"; then
66335eefee25Smacallan    $echo "$modename: invalid operation mode \`$mode'" 1>&2
66345eefee25Smacallan    $echo "$generic_help" 1>&2
66355eefee25Smacallan    exit $EXIT_FAILURE
66365eefee25Smacallan  fi
66375eefee25Smacallanfi # test -z "$show_help"
66385eefee25Smacallan
66395eefee25Smacallanif test -n "$exec_cmd"; then
66405eefee25Smacallan  eval exec $exec_cmd
66415eefee25Smacallan  exit $EXIT_FAILURE
66425eefee25Smacallanfi
66435eefee25Smacallan
66445eefee25Smacallan# We need to display help for each of the modes.
66455eefee25Smacallancase $mode in
66465eefee25Smacallan"") $echo \
66475eefee25Smacallan"Usage: $modename [OPTION]... [MODE-ARG]...
66485eefee25Smacallan
66495eefee25SmacallanProvide generalized library-building support services.
66505eefee25Smacallan
66515eefee25Smacallan    --config          show all configuration variables
66525eefee25Smacallan    --debug           enable verbose shell tracing
66535eefee25Smacallan-n, --dry-run         display commands without modifying any files
66545eefee25Smacallan    --features        display basic configuration information and exit
66555eefee25Smacallan    --finish          same as \`--mode=finish'
66565eefee25Smacallan    --help            display this help message and exit
66575eefee25Smacallan    --mode=MODE       use operation mode MODE [default=inferred from MODE-ARGS]
66585eefee25Smacallan    --quiet           same as \`--silent'
66595eefee25Smacallan    --silent          don't print informational messages
66605eefee25Smacallan    --tag=TAG         use configuration variables from tag TAG
66615eefee25Smacallan    --version         print version information
66625eefee25Smacallan
66635eefee25SmacallanMODE must be one of the following:
66645eefee25Smacallan
66655eefee25Smacallan      clean           remove files from the build directory
66665eefee25Smacallan      compile         compile a source file into a libtool object
66675eefee25Smacallan      execute         automatically set library path, then run a program
66685eefee25Smacallan      finish          complete the installation of libtool libraries
66695eefee25Smacallan      install         install libraries or executables
66705eefee25Smacallan      link            create a library or an executable
66715eefee25Smacallan      uninstall       remove libraries from an installed directory
66725eefee25Smacallan
66735eefee25SmacallanMODE-ARGS vary depending on the MODE.  Try \`$modename --help --mode=MODE' for
66745eefee25Smacallana more detailed description of MODE.
66755eefee25Smacallan
66765eefee25SmacallanReport bugs to <bug-libtool@gnu.org>."
66775eefee25Smacallan  exit $EXIT_SUCCESS
66785eefee25Smacallan  ;;
66795eefee25Smacallan
66805eefee25Smacallanclean)
66815eefee25Smacallan  $echo \
66825eefee25Smacallan"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
66835eefee25Smacallan
66845eefee25SmacallanRemove files from the build directory.
66855eefee25Smacallan
66865eefee25SmacallanRM is the name of the program to use to delete files associated with each FILE
66875eefee25Smacallan(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
66885eefee25Smacallanto RM.
66895eefee25Smacallan
66905eefee25SmacallanIf FILE is a libtool library, object or program, all the files associated
66915eefee25Smacallanwith it are deleted. Otherwise, only FILE itself is deleted using RM."
66925eefee25Smacallan  ;;
66935eefee25Smacallan
66945eefee25Smacallancompile)
66955eefee25Smacallan  $echo \
66965eefee25Smacallan"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
66975eefee25Smacallan
66985eefee25SmacallanCompile a source file into a libtool library object.
66995eefee25Smacallan
67005eefee25SmacallanThis mode accepts the following additional options:
67015eefee25Smacallan
67025eefee25Smacallan  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
67035eefee25Smacallan  -prefer-pic       try to building PIC objects only
67045eefee25Smacallan  -prefer-non-pic   try to building non-PIC objects only
67055eefee25Smacallan  -static           always build a \`.o' file suitable for static linking
67065eefee25Smacallan
67075eefee25SmacallanCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
67085eefee25Smacallanfrom the given SOURCEFILE.
67095eefee25Smacallan
67105eefee25SmacallanThe output file name is determined by removing the directory component from
67115eefee25SmacallanSOURCEFILE, then substituting the C source code suffix \`.c' with the
67125eefee25Smacallanlibrary object suffix, \`.lo'."
67135eefee25Smacallan  ;;
67145eefee25Smacallan
67155eefee25Smacallanexecute)
67165eefee25Smacallan  $echo \
67175eefee25Smacallan"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]...
67185eefee25Smacallan
67195eefee25SmacallanAutomatically set library path, then run a program.
67205eefee25Smacallan
67215eefee25SmacallanThis mode accepts the following additional options:
67225eefee25Smacallan
67235eefee25Smacallan  -dlopen FILE      add the directory containing FILE to the library path
67245eefee25Smacallan
67255eefee25SmacallanThis mode sets the library path environment variable according to \`-dlopen'
67265eefee25Smacallanflags.
67275eefee25Smacallan
67285eefee25SmacallanIf any of the ARGS are libtool executable wrappers, then they are translated
67295eefee25Smacallaninto their corresponding uninstalled binary, and any of their required library
67305eefee25Smacallandirectories are added to the library path.
67315eefee25Smacallan
67325eefee25SmacallanThen, COMMAND is executed, with ARGS as arguments."
67335eefee25Smacallan  ;;
67345eefee25Smacallan
67355eefee25Smacallanfinish)
67365eefee25Smacallan  $echo \
67375eefee25Smacallan"Usage: $modename [OPTION]... --mode=finish [LIBDIR]...
67385eefee25Smacallan
67395eefee25SmacallanComplete the installation of libtool libraries.
67405eefee25Smacallan
67415eefee25SmacallanEach LIBDIR is a directory that contains libtool libraries.
67425eefee25Smacallan
67435eefee25SmacallanThe commands that this mode executes may require superuser privileges.  Use
67445eefee25Smacallanthe \`--dry-run' option if you just want to see what would be executed."
67455eefee25Smacallan  ;;
67465eefee25Smacallan
67475eefee25Smacallaninstall)
67485eefee25Smacallan  $echo \
67495eefee25Smacallan"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND...
67505eefee25Smacallan
67515eefee25SmacallanInstall executables or libraries.
67525eefee25Smacallan
67535eefee25SmacallanINSTALL-COMMAND is the installation command.  The first component should be
67545eefee25Smacallaneither the \`install' or \`cp' program.
67555eefee25Smacallan
67565eefee25SmacallanThe rest of the components are interpreted as arguments to that command (only
67575eefee25SmacallanBSD-compatible install options are recognized)."
67585eefee25Smacallan  ;;
67595eefee25Smacallan
67605eefee25Smacallanlink)
67615eefee25Smacallan  $echo \
67625eefee25Smacallan"Usage: $modename [OPTION]... --mode=link LINK-COMMAND...
67635eefee25Smacallan
67645eefee25SmacallanLink object files or libraries together to form another library, or to
67655eefee25Smacallancreate an executable program.
67665eefee25Smacallan
67675eefee25SmacallanLINK-COMMAND is a command using the C compiler that you would use to create
67685eefee25Smacallana program from several object files.
67695eefee25Smacallan
67705eefee25SmacallanThe following components of LINK-COMMAND are treated specially:
67715eefee25Smacallan
67725eefee25Smacallan  -all-static       do not do any dynamic linking at all
67735eefee25Smacallan  -avoid-version    do not add a version suffix if possible
67745eefee25Smacallan  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
67755eefee25Smacallan  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
67765eefee25Smacallan  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
67775eefee25Smacallan  -export-symbols SYMFILE
67785eefee25Smacallan		    try to export only the symbols listed in SYMFILE
67795eefee25Smacallan  -export-symbols-regex REGEX
67805eefee25Smacallan		    try to export only the symbols matching REGEX
67815eefee25Smacallan  -LLIBDIR          search LIBDIR for required installed libraries
67825eefee25Smacallan  -lNAME            OUTPUT-FILE requires the installed library libNAME
67835eefee25Smacallan  -module           build a library that can dlopened
67845eefee25Smacallan  -no-fast-install  disable the fast-install mode
67855eefee25Smacallan  -no-install       link a not-installable executable
67865eefee25Smacallan  -no-undefined     declare that a library does not refer to external symbols
67875eefee25Smacallan  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
67885eefee25Smacallan  -objectlist FILE  Use a list of object files found in FILE to specify objects
67895eefee25Smacallan  -precious-files-regex REGEX
67905eefee25Smacallan                    don't remove output files matching REGEX
67915eefee25Smacallan  -release RELEASE  specify package release information
67925eefee25Smacallan  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
67935eefee25Smacallan  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
67945eefee25Smacallan  -static           do not do any dynamic linking of libtool libraries
67955eefee25Smacallan  -version-info CURRENT[:REVISION[:AGE]]
67965eefee25Smacallan		    specify library version info [each variable defaults to 0]
67975eefee25Smacallan
67985eefee25SmacallanAll other options (arguments beginning with \`-') are ignored.
67995eefee25Smacallan
68005eefee25SmacallanEvery other argument is treated as a filename.  Files ending in \`.la' are
68015eefee25Smacallantreated as uninstalled libtool libraries, other files are standard or library
68025eefee25Smacallanobject files.
68035eefee25Smacallan
68045eefee25SmacallanIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
68055eefee25Smacallanonly library objects (\`.lo' files) may be specified, and \`-rpath' is
68065eefee25Smacallanrequired, except when creating a convenience library.
68075eefee25Smacallan
68085eefee25SmacallanIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
68095eefee25Smacallanusing \`ar' and \`ranlib', or on Windows using \`lib'.
68105eefee25Smacallan
68115eefee25SmacallanIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
68125eefee25Smacallanis created, otherwise an executable program is created."
68135eefee25Smacallan  ;;
68145eefee25Smacallan
68155eefee25Smacallanuninstall)
68165eefee25Smacallan  $echo \
68175eefee25Smacallan"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
68185eefee25Smacallan
68195eefee25SmacallanRemove libraries from an installation directory.
68205eefee25Smacallan
68215eefee25SmacallanRM is the name of the program to use to delete files associated with each FILE
68225eefee25Smacallan(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
68235eefee25Smacallanto RM.
68245eefee25Smacallan
68255eefee25SmacallanIf FILE is a libtool library, all the files associated with it are deleted.
68265eefee25SmacallanOtherwise, only FILE itself is deleted using RM."
68275eefee25Smacallan  ;;
68285eefee25Smacallan
68295eefee25Smacallan*)
68305eefee25Smacallan  $echo "$modename: invalid operation mode \`$mode'" 1>&2
68315eefee25Smacallan  $echo "$help" 1>&2
68325eefee25Smacallan  exit $EXIT_FAILURE
68335eefee25Smacallan  ;;
68345eefee25Smacallanesac
68355eefee25Smacallan
68365eefee25Smacallan$echo
68375eefee25Smacallan$echo "Try \`$modename --help' for more information about other modes."
68385eefee25Smacallan
68395eefee25Smacallanexit $?
68405eefee25Smacallan
68415eefee25Smacallan# The TAGs below are defined such that we never get into a situation
68425eefee25Smacallan# in which we disable both kinds of libraries.  Given conflicting
68435eefee25Smacallan# choices, we go for a static library, that is the most portable,
68445eefee25Smacallan# since we can't tell whether shared libraries were disabled because
68455eefee25Smacallan# the user asked for that or because the platform doesn't support
68465eefee25Smacallan# them.  This is particularly important on AIX, because we don't
68475eefee25Smacallan# support having both static and shared libraries enabled at the same
68485eefee25Smacallan# time on that platform, so we default to a shared-only configuration.
68495eefee25Smacallan# If a disable-shared tag is given, we'll fallback to a static-only
68505eefee25Smacallan# configuration.  But we'll never go from static-only to shared-only.
68515eefee25Smacallan
68525eefee25Smacallan# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
68535eefee25Smacallandisable_libs=shared
68545eefee25Smacallan# ### END LIBTOOL TAG CONFIG: disable-shared
68555eefee25Smacallan
68565eefee25Smacallan# ### BEGIN LIBTOOL TAG CONFIG: disable-static
68575eefee25Smacallandisable_libs=static
68585eefee25Smacallan# ### END LIBTOOL TAG CONFIG: disable-static
68595eefee25Smacallan
68605eefee25Smacallan# Local Variables:
68615eefee25Smacallan# mode:shell-script
68625eefee25Smacallan# sh-indentation:2
68635eefee25Smacallan# End:
6864