ltmain.sh revision 7914d74b
17914d74bSmrg# ltmain.sh - Provide generalized library-building support services.
27914d74bSmrg# NOTE: Changing this file will not affect anything until you rerun configure.
37914d74bSmrg#
47914d74bSmrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005
57914d74bSmrg# Free Software Foundation, Inc.
67914d74bSmrg# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
77914d74bSmrg#
87914d74bSmrg# This program is free software; you can redistribute it and/or modify
97914d74bSmrg# it under the terms of the GNU General Public License as published by
107914d74bSmrg# the Free Software Foundation; either version 2 of the License, or
117914d74bSmrg# (at your option) any later version.
127914d74bSmrg#
137914d74bSmrg# This program is distributed in the hope that it will be useful, but
147914d74bSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
157914d74bSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
167914d74bSmrg# General Public License for more details.
177914d74bSmrg#
187914d74bSmrg# You should have received a copy of the GNU General Public License
197914d74bSmrg# along with this program; if not, write to the Free Software
207914d74bSmrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
217914d74bSmrg#
227914d74bSmrg# As a special exception to the GNU General Public License, if you
237914d74bSmrg# distribute this file as part of a program that contains a
247914d74bSmrg# configuration script generated by Autoconf, you may include it under
257914d74bSmrg# the same distribution terms that you use for the rest of that program.
267914d74bSmrg
277914d74bSmrgbasename="s,^.*/,,g"
287914d74bSmrg
297914d74bSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
307914d74bSmrg# is ksh but when the shell is invoked as "sh" and the current value of
317914d74bSmrg# the _XPG environment variable is not equal to 1 (one), the special
327914d74bSmrg# positional parameter $0, within a function call, is the name of the
337914d74bSmrg# function.
347914d74bSmrgprogpath="$0"
357914d74bSmrg
367914d74bSmrg# The name of this program:
377914d74bSmrgprogname=`echo "$progpath" | $SED $basename`
387914d74bSmrgmodename="$progname"
397914d74bSmrg
407914d74bSmrg# Global variables:
417914d74bSmrgEXIT_SUCCESS=0
427914d74bSmrgEXIT_FAILURE=1
437914d74bSmrg
447914d74bSmrgPROGRAM=ltmain.sh
457914d74bSmrgPACKAGE=libtool
467914d74bSmrgVERSION=1.5.22
477914d74bSmrgTIMESTAMP=" (1.1220.2.365 2005/12/18 22:14:06)"
487914d74bSmrg
497914d74bSmrg# See if we are running on zsh, and set the options which allow our
507914d74bSmrg# commands through without removal of \ escapes.
517914d74bSmrgif test -n "${ZSH_VERSION+set}" ; then
527914d74bSmrg  setopt NO_GLOB_SUBST
537914d74bSmrgfi
547914d74bSmrg
557914d74bSmrg# Check that we have a working $echo.
567914d74bSmrgif test "X$1" = X--no-reexec; then
577914d74bSmrg  # Discard the --no-reexec flag, and continue.
587914d74bSmrg  shift
597914d74bSmrgelif test "X$1" = X--fallback-echo; then
607914d74bSmrg  # Avoid inline document here, it may be left over
617914d74bSmrg  :
627914d74bSmrgelif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
637914d74bSmrg  # Yippee, $echo works!
647914d74bSmrg  :
657914d74bSmrgelse
667914d74bSmrg  # Restart under the correct shell, and then maybe $echo will work.
677914d74bSmrg  exec $SHELL "$progpath" --no-reexec ${1+"$@"}
687914d74bSmrgfi
697914d74bSmrg
707914d74bSmrgif test "X$1" = X--fallback-echo; then
717914d74bSmrg  # used as fallback echo
727914d74bSmrg  shift
737914d74bSmrg  cat <<EOF
747914d74bSmrg$*
757914d74bSmrgEOF
767914d74bSmrg  exit $EXIT_SUCCESS
777914d74bSmrgfi
787914d74bSmrg
797914d74bSmrgdefault_mode=
807914d74bSmrghelp="Try \`$progname --help' for more information."
817914d74bSmrgmagic="%%%MAGIC variable%%%"
827914d74bSmrgmkdir="mkdir"
837914d74bSmrgmv="mv -f"
847914d74bSmrgrm="rm -f"
857914d74bSmrg
867914d74bSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
877914d74bSmrg# metacharacters that are still active within double-quoted strings.
887914d74bSmrgXsed="${SED}"' -e 1s/^X//'
897914d74bSmrgsed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
907914d74bSmrg# test EBCDIC or ASCII
917914d74bSmrgcase `echo X|tr X '\101'` in
927914d74bSmrg A) # ASCII based system
937914d74bSmrg    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
947914d74bSmrg  SP2NL='tr \040 \012'
957914d74bSmrg  NL2SP='tr \015\012 \040\040'
967914d74bSmrg  ;;
977914d74bSmrg *) # EBCDIC based system
987914d74bSmrg  SP2NL='tr \100 \n'
997914d74bSmrg  NL2SP='tr \r\n \100\100'
1007914d74bSmrg  ;;
1017914d74bSmrgesac
1027914d74bSmrg
1037914d74bSmrg# NLS nuisances.
1047914d74bSmrg# Only set LANG and LC_ALL to C if already set.
1057914d74bSmrg# These must not be set unconditionally because not all systems understand
1067914d74bSmrg# e.g. LANG=C (notably SCO).
1077914d74bSmrg# We save the old values to restore during execute mode.
1087914d74bSmrgif test "${LC_ALL+set}" = set; then
1097914d74bSmrg  save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
1107914d74bSmrgfi
1117914d74bSmrgif test "${LANG+set}" = set; then
1127914d74bSmrg  save_LANG="$LANG"; LANG=C; export LANG
1137914d74bSmrgfi
1147914d74bSmrg
1157914d74bSmrg# Make sure IFS has a sensible default
1167914d74bSmrglt_nl='
1177914d74bSmrg'
1187914d74bSmrgIFS=" 	$lt_nl"
1197914d74bSmrg
1207914d74bSmrgif test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
1217914d74bSmrg  $echo "$modename: not configured to build any kind of library" 1>&2
1227914d74bSmrg  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
1237914d74bSmrg  exit $EXIT_FAILURE
1247914d74bSmrgfi
1257914d74bSmrg
1267914d74bSmrg# Global variables.
1277914d74bSmrgmode=$default_mode
1287914d74bSmrgnonopt=
1297914d74bSmrgprev=
1307914d74bSmrgprevopt=
1317914d74bSmrgrun=
1327914d74bSmrgshow="$echo"
1337914d74bSmrgshow_help=
1347914d74bSmrgexecute_dlfiles=
1357914d74bSmrgduplicate_deps=no
1367914d74bSmrgpreserve_args=
1377914d74bSmrglo2o="s/\\.lo\$/.${objext}/"
1387914d74bSmrgo2lo="s/\\.${objext}\$/.lo/"
1397914d74bSmrg
1407914d74bSmrg#####################################
1417914d74bSmrg# Shell function definitions:
1427914d74bSmrg# This seems to be the best place for them
1437914d74bSmrg
1447914d74bSmrg# func_mktempdir [string]
1457914d74bSmrg# Make a temporary directory that won't clash with other running
1467914d74bSmrg# libtool processes, and avoids race conditions if possible.  If
1477914d74bSmrg# given, STRING is the basename for that directory.
1487914d74bSmrgfunc_mktempdir ()
1497914d74bSmrg{
1507914d74bSmrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
1517914d74bSmrg
1527914d74bSmrg    if test "$run" = ":"; then
1537914d74bSmrg      # Return a directory name, but don't create it in dry-run mode
1547914d74bSmrg      my_tmpdir="${my_template}-$$"
1557914d74bSmrg    else
1567914d74bSmrg
1577914d74bSmrg      # If mktemp works, use that first and foremost
1587914d74bSmrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
1597914d74bSmrg
1607914d74bSmrg      if test ! -d "$my_tmpdir"; then
1617914d74bSmrg	# Failing that, at least try and use $RANDOM to avoid a race
1627914d74bSmrg	my_tmpdir="${my_template}-${RANDOM-0}$$"
1637914d74bSmrg
1647914d74bSmrg	save_mktempdir_umask=`umask`
1657914d74bSmrg	umask 0077
1667914d74bSmrg	$mkdir "$my_tmpdir"
1677914d74bSmrg	umask $save_mktempdir_umask
1687914d74bSmrg      fi
1697914d74bSmrg
1707914d74bSmrg      # If we're not in dry-run mode, bomb out on failure
1717914d74bSmrg      test -d "$my_tmpdir" || {
1727914d74bSmrg        $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
1737914d74bSmrg	exit $EXIT_FAILURE
1747914d74bSmrg      }
1757914d74bSmrg    fi
1767914d74bSmrg
1777914d74bSmrg    $echo "X$my_tmpdir" | $Xsed
1787914d74bSmrg}
1797914d74bSmrg
1807914d74bSmrg
1817914d74bSmrg# func_win32_libid arg
1827914d74bSmrg# return the library type of file 'arg'
1837914d74bSmrg#
1847914d74bSmrg# Need a lot of goo to handle *both* DLLs and import libs
1857914d74bSmrg# Has to be a shell function in order to 'eat' the argument
1867914d74bSmrg# that is supplied when $file_magic_command is called.
1877914d74bSmrgfunc_win32_libid ()
1887914d74bSmrg{
1897914d74bSmrg  win32_libid_type="unknown"
1907914d74bSmrg  win32_fileres=`file -L $1 2>/dev/null`
1917914d74bSmrg  case $win32_fileres in
1927914d74bSmrg  *ar\ archive\ import\ library*) # definitely import
1937914d74bSmrg    win32_libid_type="x86 archive import"
1947914d74bSmrg    ;;
1957914d74bSmrg  *ar\ archive*) # could be an import, or static
1967914d74bSmrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
1977914d74bSmrg      $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
1987914d74bSmrg      win32_nmres=`eval $NM -f posix -A $1 | \
1997914d74bSmrg	$SED -n -e '1,100{/ I /{s,.*,import,;p;q;};}'`
2007914d74bSmrg      case $win32_nmres in
2017914d74bSmrg      import*)  win32_libid_type="x86 archive import";;
2027914d74bSmrg      *)        win32_libid_type="x86 archive static";;
2037914d74bSmrg      esac
2047914d74bSmrg    fi
2057914d74bSmrg    ;;
2067914d74bSmrg  *DLL*)
2077914d74bSmrg    win32_libid_type="x86 DLL"
2087914d74bSmrg    ;;
2097914d74bSmrg  *executable*) # but shell scripts are "executable" too...
2107914d74bSmrg    case $win32_fileres in
2117914d74bSmrg    *MS\ Windows\ PE\ Intel*)
2127914d74bSmrg      win32_libid_type="x86 DLL"
2137914d74bSmrg      ;;
2147914d74bSmrg    esac
2157914d74bSmrg    ;;
2167914d74bSmrg  esac
2177914d74bSmrg  $echo $win32_libid_type
2187914d74bSmrg}
2197914d74bSmrg
2207914d74bSmrg
2217914d74bSmrg# func_infer_tag arg
2227914d74bSmrg# Infer tagged configuration to use if any are available and
2237914d74bSmrg# if one wasn't chosen via the "--tag" command line option.
2247914d74bSmrg# Only attempt this if the compiler in the base compile
2257914d74bSmrg# command doesn't match the default compiler.
2267914d74bSmrg# arg is usually of the form 'gcc ...'
2277914d74bSmrgfunc_infer_tag ()
2287914d74bSmrg{
2297914d74bSmrg    if test -n "$available_tags" && test -z "$tagname"; then
2307914d74bSmrg      CC_quoted=
2317914d74bSmrg      for arg in $CC; do
2327914d74bSmrg	case $arg in
2337914d74bSmrg	  *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
2347914d74bSmrg	  arg="\"$arg\""
2357914d74bSmrg	  ;;
2367914d74bSmrg	esac
2377914d74bSmrg	CC_quoted="$CC_quoted $arg"
2387914d74bSmrg      done
2397914d74bSmrg      case $@ in
2407914d74bSmrg      # Blanks in the command may have been stripped by the calling shell,
2417914d74bSmrg      # but not from the CC environment variable when configure was run.
2427914d74bSmrg      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
2437914d74bSmrg      # Blanks at the start of $base_compile will cause this to fail
2447914d74bSmrg      # if we don't check for them as well.
2457914d74bSmrg      *)
2467914d74bSmrg	for z in $available_tags; do
2477914d74bSmrg	  if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
2487914d74bSmrg	    # Evaluate the configuration.
2497914d74bSmrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
2507914d74bSmrg	    CC_quoted=
2517914d74bSmrg	    for arg in $CC; do
2527914d74bSmrg	    # Double-quote args containing other shell metacharacters.
2537914d74bSmrg	    case $arg in
2547914d74bSmrg	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
2557914d74bSmrg	      arg="\"$arg\""
2567914d74bSmrg	      ;;
2577914d74bSmrg	    esac
2587914d74bSmrg	    CC_quoted="$CC_quoted $arg"
2597914d74bSmrg	  done
2607914d74bSmrg	    case "$@ " in
2617914d74bSmrg	      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
2627914d74bSmrg	      # The compiler in the base compile command matches
2637914d74bSmrg	      # the one in the tagged configuration.
2647914d74bSmrg	      # Assume this is the tagged configuration we want.
2657914d74bSmrg	      tagname=$z
2667914d74bSmrg	      break
2677914d74bSmrg	      ;;
2687914d74bSmrg	    esac
2697914d74bSmrg	  fi
2707914d74bSmrg	done
2717914d74bSmrg	# If $tagname still isn't set, then no tagged configuration
2727914d74bSmrg	# was found and let the user know that the "--tag" command
2737914d74bSmrg	# line option must be used.
2747914d74bSmrg	if test -z "$tagname"; then
2757914d74bSmrg	  $echo "$modename: unable to infer tagged configuration"
2767914d74bSmrg	  $echo "$modename: specify a tag with \`--tag'" 1>&2
2777914d74bSmrg	  exit $EXIT_FAILURE
2787914d74bSmrg#        else
2797914d74bSmrg#          $echo "$modename: using $tagname tagged configuration"
2807914d74bSmrg	fi
2817914d74bSmrg	;;
2827914d74bSmrg      esac
2837914d74bSmrg    fi
2847914d74bSmrg}
2857914d74bSmrg
2867914d74bSmrg
2877914d74bSmrg# func_extract_an_archive dir oldlib
2887914d74bSmrgfunc_extract_an_archive ()
2897914d74bSmrg{
2907914d74bSmrg    f_ex_an_ar_dir="$1"; shift
2917914d74bSmrg    f_ex_an_ar_oldlib="$1"
2927914d74bSmrg
2937914d74bSmrg    $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
2947914d74bSmrg    $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
2957914d74bSmrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
2967914d74bSmrg     :
2977914d74bSmrg    else
2987914d74bSmrg      $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2
2997914d74bSmrg      exit $EXIT_FAILURE
3007914d74bSmrg    fi
3017914d74bSmrg}
3027914d74bSmrg
3037914d74bSmrg# func_extract_archives gentop oldlib ...
3047914d74bSmrgfunc_extract_archives ()
3057914d74bSmrg{
3067914d74bSmrg    my_gentop="$1"; shift
3077914d74bSmrg    my_oldlibs=${1+"$@"}
3087914d74bSmrg    my_oldobjs=""
3097914d74bSmrg    my_xlib=""
3107914d74bSmrg    my_xabs=""
3117914d74bSmrg    my_xdir=""
3127914d74bSmrg    my_status=""
3137914d74bSmrg
3147914d74bSmrg    $show "${rm}r $my_gentop"
3157914d74bSmrg    $run ${rm}r "$my_gentop"
3167914d74bSmrg    $show "$mkdir $my_gentop"
3177914d74bSmrg    $run $mkdir "$my_gentop"
3187914d74bSmrg    my_status=$?
3197914d74bSmrg    if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
3207914d74bSmrg      exit $my_status
3217914d74bSmrg    fi
3227914d74bSmrg
3237914d74bSmrg    for my_xlib in $my_oldlibs; do
3247914d74bSmrg      # Extract the objects.
3257914d74bSmrg      case $my_xlib in
3267914d74bSmrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
3277914d74bSmrg	*) my_xabs=`pwd`"/$my_xlib" ;;
3287914d74bSmrg      esac
3297914d74bSmrg      my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
3307914d74bSmrg      my_xdir="$my_gentop/$my_xlib"
3317914d74bSmrg
3327914d74bSmrg      $show "${rm}r $my_xdir"
3337914d74bSmrg      $run ${rm}r "$my_xdir"
3347914d74bSmrg      $show "$mkdir $my_xdir"
3357914d74bSmrg      $run $mkdir "$my_xdir"
3367914d74bSmrg      exit_status=$?
3377914d74bSmrg      if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then
3387914d74bSmrg	exit $exit_status
3397914d74bSmrg      fi
3407914d74bSmrg      case $host in
3417914d74bSmrg      *-darwin*)
3427914d74bSmrg	$show "Extracting $my_xabs"
3437914d74bSmrg	# Do not bother doing anything if just a dry run
3447914d74bSmrg	if test -z "$run"; then
3457914d74bSmrg	  darwin_orig_dir=`pwd`
3467914d74bSmrg	  cd $my_xdir || exit $?
3477914d74bSmrg	  darwin_archive=$my_xabs
3487914d74bSmrg	  darwin_curdir=`pwd`
3497914d74bSmrg	  darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'`
3507914d74bSmrg	  darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
3517914d74bSmrg	  if test -n "$darwin_arches"; then 
3527914d74bSmrg	    darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
3537914d74bSmrg	    darwin_arch=
3547914d74bSmrg	    $show "$darwin_base_archive has multiple architectures $darwin_arches"
3557914d74bSmrg	    for darwin_arch in  $darwin_arches ; do
3567914d74bSmrg	      mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3577914d74bSmrg	      lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
3587914d74bSmrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3597914d74bSmrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
3607914d74bSmrg	      cd "$darwin_curdir"
3617914d74bSmrg	      $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
3627914d74bSmrg	    done # $darwin_arches
3637914d74bSmrg      ## Okay now we have a bunch of thin objects, gotta fatten them up :)
3647914d74bSmrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP`
3657914d74bSmrg	    darwin_file=
3667914d74bSmrg	    darwin_files=
3677914d74bSmrg	    for darwin_file in $darwin_filelist; do
3687914d74bSmrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
3697914d74bSmrg	      lipo -create -output "$darwin_file" $darwin_files
3707914d74bSmrg	    done # $darwin_filelist
3717914d74bSmrg	    ${rm}r unfat-$$
3727914d74bSmrg	    cd "$darwin_orig_dir"
3737914d74bSmrg	  else
3747914d74bSmrg	    cd "$darwin_orig_dir"
3757914d74bSmrg 	    func_extract_an_archive "$my_xdir" "$my_xabs"
3767914d74bSmrg	  fi # $darwin_arches
3777914d74bSmrg	fi # $run
3787914d74bSmrg	;;
3797914d74bSmrg      *)
3807914d74bSmrg        func_extract_an_archive "$my_xdir" "$my_xabs"
3817914d74bSmrg        ;;
3827914d74bSmrg      esac
3837914d74bSmrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
3847914d74bSmrg    done
3857914d74bSmrg    func_extract_archives_result="$my_oldobjs"
3867914d74bSmrg}
3877914d74bSmrg# End of Shell function definitions
3887914d74bSmrg#####################################
3897914d74bSmrg
3907914d74bSmrg# Darwin sucks
3917914d74bSmrgeval std_shrext=\"$shrext_cmds\"
3927914d74bSmrg
3937914d74bSmrgdisable_libs=no
3947914d74bSmrg
3957914d74bSmrg# Parse our command line options once, thoroughly.
3967914d74bSmrgwhile test "$#" -gt 0
3977914d74bSmrgdo
3987914d74bSmrg  arg="$1"
3997914d74bSmrg  shift
4007914d74bSmrg
4017914d74bSmrg  case $arg in
4027914d74bSmrg  -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
4037914d74bSmrg  *) optarg= ;;
4047914d74bSmrg  esac
4057914d74bSmrg
4067914d74bSmrg  # If the previous option needs an argument, assign it.
4077914d74bSmrg  if test -n "$prev"; then
4087914d74bSmrg    case $prev in
4097914d74bSmrg    execute_dlfiles)
4107914d74bSmrg      execute_dlfiles="$execute_dlfiles $arg"
4117914d74bSmrg      ;;
4127914d74bSmrg    tag)
4137914d74bSmrg      tagname="$arg"
4147914d74bSmrg      preserve_args="${preserve_args}=$arg"
4157914d74bSmrg
4167914d74bSmrg      # Check whether tagname contains only valid characters
4177914d74bSmrg      case $tagname in
4187914d74bSmrg      *[!-_A-Za-z0-9,/]*)
4197914d74bSmrg	$echo "$progname: invalid tag name: $tagname" 1>&2
4207914d74bSmrg	exit $EXIT_FAILURE
4217914d74bSmrg	;;
4227914d74bSmrg      esac
4237914d74bSmrg
4247914d74bSmrg      case $tagname in
4257914d74bSmrg      CC)
4267914d74bSmrg	# Don't test for the "default" C tag, as we know, it's there, but
4277914d74bSmrg	# not specially marked.
4287914d74bSmrg	;;
4297914d74bSmrg      *)
4307914d74bSmrg	if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then
4317914d74bSmrg	  taglist="$taglist $tagname"
4327914d74bSmrg	  # Evaluate the configuration.
4337914d74bSmrg	  eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`"
4347914d74bSmrg	else
4357914d74bSmrg	  $echo "$progname: ignoring unknown tag $tagname" 1>&2
4367914d74bSmrg	fi
4377914d74bSmrg	;;
4387914d74bSmrg      esac
4397914d74bSmrg      ;;
4407914d74bSmrg    *)
4417914d74bSmrg      eval "$prev=\$arg"
4427914d74bSmrg      ;;
4437914d74bSmrg    esac
4447914d74bSmrg
4457914d74bSmrg    prev=
4467914d74bSmrg    prevopt=
4477914d74bSmrg    continue
4487914d74bSmrg  fi
4497914d74bSmrg
4507914d74bSmrg  # Have we seen a non-optional argument yet?
4517914d74bSmrg  case $arg in
4527914d74bSmrg  --help)
4537914d74bSmrg    show_help=yes
4547914d74bSmrg    ;;
4557914d74bSmrg
4567914d74bSmrg  --version)
4577914d74bSmrg    $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
4587914d74bSmrg    $echo
4597914d74bSmrg    $echo "Copyright (C) 2005  Free Software Foundation, Inc."
4607914d74bSmrg    $echo "This is free software; see the source for copying conditions.  There is NO"
4617914d74bSmrg    $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
4627914d74bSmrg    exit $?
4637914d74bSmrg    ;;
4647914d74bSmrg
4657914d74bSmrg  --config)
4667914d74bSmrg    ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath
4677914d74bSmrg    # Now print the configurations for the tags.
4687914d74bSmrg    for tagname in $taglist; do
4697914d74bSmrg      ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
4707914d74bSmrg    done
4717914d74bSmrg    exit $?
4727914d74bSmrg    ;;
4737914d74bSmrg
4747914d74bSmrg  --debug)
4757914d74bSmrg    $echo "$progname: enabling shell trace mode"
4767914d74bSmrg    set -x
4777914d74bSmrg    preserve_args="$preserve_args $arg"
4787914d74bSmrg    ;;
4797914d74bSmrg
4807914d74bSmrg  --dry-run | -n)
4817914d74bSmrg    run=:
4827914d74bSmrg    ;;
4837914d74bSmrg
4847914d74bSmrg  --features)
4857914d74bSmrg    $echo "host: $host"
4867914d74bSmrg    if test "$build_libtool_libs" = yes; then
4877914d74bSmrg      $echo "enable shared libraries"
4887914d74bSmrg    else
4897914d74bSmrg      $echo "disable shared libraries"
4907914d74bSmrg    fi
4917914d74bSmrg    if test "$build_old_libs" = yes; then
4927914d74bSmrg      $echo "enable static libraries"
4937914d74bSmrg    else
4947914d74bSmrg      $echo "disable static libraries"
4957914d74bSmrg    fi
4967914d74bSmrg    exit $?
4977914d74bSmrg    ;;
4987914d74bSmrg
4997914d74bSmrg  --finish) mode="finish" ;;
5007914d74bSmrg
5017914d74bSmrg  --mode) prevopt="--mode" prev=mode ;;
5027914d74bSmrg  --mode=*) mode="$optarg" ;;
5037914d74bSmrg
5047914d74bSmrg  --preserve-dup-deps) duplicate_deps="yes" ;;
5057914d74bSmrg
5067914d74bSmrg  --quiet | --silent)
5077914d74bSmrg    show=:
5087914d74bSmrg    preserve_args="$preserve_args $arg"
5097914d74bSmrg    ;;
5107914d74bSmrg
5117914d74bSmrg  --tag)
5127914d74bSmrg    prevopt="--tag"
5137914d74bSmrg    prev=tag
5147914d74bSmrg    preserve_args="$preserve_args --tag"
5157914d74bSmrg    ;;
5167914d74bSmrg  --tag=*)
5177914d74bSmrg    set tag "$optarg" ${1+"$@"}
5187914d74bSmrg    shift
5197914d74bSmrg    prev=tag
5207914d74bSmrg    preserve_args="$preserve_args --tag"
5217914d74bSmrg    ;;
5227914d74bSmrg
5237914d74bSmrg  -dlopen)
5247914d74bSmrg    prevopt="-dlopen"
5257914d74bSmrg    prev=execute_dlfiles
5267914d74bSmrg    ;;
5277914d74bSmrg
5287914d74bSmrg  -*)
5297914d74bSmrg    $echo "$modename: unrecognized option \`$arg'" 1>&2
5307914d74bSmrg    $echo "$help" 1>&2
5317914d74bSmrg    exit $EXIT_FAILURE
5327914d74bSmrg    ;;
5337914d74bSmrg
5347914d74bSmrg  *)
5357914d74bSmrg    nonopt="$arg"
5367914d74bSmrg    break
5377914d74bSmrg    ;;
5387914d74bSmrg  esac
5397914d74bSmrgdone
5407914d74bSmrg
5417914d74bSmrgif test -n "$prevopt"; then
5427914d74bSmrg  $echo "$modename: option \`$prevopt' requires an argument" 1>&2
5437914d74bSmrg  $echo "$help" 1>&2
5447914d74bSmrg  exit $EXIT_FAILURE
5457914d74bSmrgfi
5467914d74bSmrg
5477914d74bSmrgcase $disable_libs in
5487914d74bSmrgno) 
5497914d74bSmrg  ;;
5507914d74bSmrgshared)
5517914d74bSmrg  build_libtool_libs=no
5527914d74bSmrg  build_old_libs=yes
5537914d74bSmrg  ;;
5547914d74bSmrgstatic)
5557914d74bSmrg  build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
5567914d74bSmrg  ;;
5577914d74bSmrgesac
5587914d74bSmrg
5597914d74bSmrg# If this variable is set in any of the actions, the command in it
5607914d74bSmrg# will be execed at the end.  This prevents here-documents from being
5617914d74bSmrg# left over by shells.
5627914d74bSmrgexec_cmd=
5637914d74bSmrg
5647914d74bSmrgif test -z "$show_help"; then
5657914d74bSmrg
5667914d74bSmrg  # Infer the operation mode.
5677914d74bSmrg  if test -z "$mode"; then
5687914d74bSmrg    $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
5697914d74bSmrg    $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2
5707914d74bSmrg    case $nonopt in
5717914d74bSmrg    *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
5727914d74bSmrg      mode=link
5737914d74bSmrg      for arg
5747914d74bSmrg      do
5757914d74bSmrg	case $arg in
5767914d74bSmrg	-c)
5777914d74bSmrg	   mode=compile
5787914d74bSmrg	   break
5797914d74bSmrg	   ;;
5807914d74bSmrg	esac
5817914d74bSmrg      done
5827914d74bSmrg      ;;
5837914d74bSmrg    *db | *dbx | *strace | *truss)
5847914d74bSmrg      mode=execute
5857914d74bSmrg      ;;
5867914d74bSmrg    *install*|cp|mv)
5877914d74bSmrg      mode=install
5887914d74bSmrg      ;;
5897914d74bSmrg    *rm)
5907914d74bSmrg      mode=uninstall
5917914d74bSmrg      ;;
5927914d74bSmrg    *)
5937914d74bSmrg      # If we have no mode, but dlfiles were specified, then do execute mode.
5947914d74bSmrg      test -n "$execute_dlfiles" && mode=execute
5957914d74bSmrg
5967914d74bSmrg      # Just use the default operation mode.
5977914d74bSmrg      if test -z "$mode"; then
5987914d74bSmrg	if test -n "$nonopt"; then
5997914d74bSmrg	  $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
6007914d74bSmrg	else
6017914d74bSmrg	  $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
6027914d74bSmrg	fi
6037914d74bSmrg      fi
6047914d74bSmrg      ;;
6057914d74bSmrg    esac
6067914d74bSmrg  fi
6077914d74bSmrg
6087914d74bSmrg  # Only execute mode is allowed to have -dlopen flags.
6097914d74bSmrg  if test -n "$execute_dlfiles" && test "$mode" != execute; then
6107914d74bSmrg    $echo "$modename: unrecognized option \`-dlopen'" 1>&2
6117914d74bSmrg    $echo "$help" 1>&2
6127914d74bSmrg    exit $EXIT_FAILURE
6137914d74bSmrg  fi
6147914d74bSmrg
6157914d74bSmrg  # Change the help message to a mode-specific one.
6167914d74bSmrg  generic_help="$help"
6177914d74bSmrg  help="Try \`$modename --help --mode=$mode' for more information."
6187914d74bSmrg
6197914d74bSmrg  # These modes are in order of execution frequency so that they run quickly.
6207914d74bSmrg  case $mode in
6217914d74bSmrg  # libtool compile mode
6227914d74bSmrg  compile)
6237914d74bSmrg    modename="$modename: compile"
6247914d74bSmrg    # Get the compilation command and the source file.
6257914d74bSmrg    base_compile=
6267914d74bSmrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
6277914d74bSmrg    suppress_opt=yes
6287914d74bSmrg    suppress_output=
6297914d74bSmrg    arg_mode=normal
6307914d74bSmrg    libobj=
6317914d74bSmrg    later=
6327914d74bSmrg
6337914d74bSmrg    for arg
6347914d74bSmrg    do
6357914d74bSmrg      case $arg_mode in
6367914d74bSmrg      arg  )
6377914d74bSmrg	# do not "continue".  Instead, add this to base_compile
6387914d74bSmrg	lastarg="$arg"
6397914d74bSmrg	arg_mode=normal
6407914d74bSmrg	;;
6417914d74bSmrg
6427914d74bSmrg      target )
6437914d74bSmrg	libobj="$arg"
6447914d74bSmrg	arg_mode=normal
6457914d74bSmrg	continue
6467914d74bSmrg	;;
6477914d74bSmrg
6487914d74bSmrg      normal )
6497914d74bSmrg	# Accept any command-line options.
6507914d74bSmrg	case $arg in
6517914d74bSmrg	-o)
6527914d74bSmrg	  if test -n "$libobj" ; then
6537914d74bSmrg	    $echo "$modename: you cannot specify \`-o' more than once" 1>&2
6547914d74bSmrg	    exit $EXIT_FAILURE
6557914d74bSmrg	  fi
6567914d74bSmrg	  arg_mode=target
6577914d74bSmrg	  continue
6587914d74bSmrg	  ;;
6597914d74bSmrg
6607914d74bSmrg	-static | -prefer-pic | -prefer-non-pic)
6617914d74bSmrg	  later="$later $arg"
6627914d74bSmrg	  continue
6637914d74bSmrg	  ;;
6647914d74bSmrg
6657914d74bSmrg	-no-suppress)
6667914d74bSmrg	  suppress_opt=no
6677914d74bSmrg	  continue
6687914d74bSmrg	  ;;
6697914d74bSmrg
6707914d74bSmrg	-Xcompiler)
6717914d74bSmrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
6727914d74bSmrg	  continue      #  The current "srcfile" will either be retained or
6737914d74bSmrg	  ;;            #  replaced later.  I would guess that would be a bug.
6747914d74bSmrg
6757914d74bSmrg	-Wc,*)
6767914d74bSmrg	  args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
6777914d74bSmrg	  lastarg=
6787914d74bSmrg	  save_ifs="$IFS"; IFS=','
6797914d74bSmrg 	  for arg in $args; do
6807914d74bSmrg	    IFS="$save_ifs"
6817914d74bSmrg
6827914d74bSmrg	    # Double-quote args containing other shell metacharacters.
6837914d74bSmrg	    # Many Bourne shells cannot handle close brackets correctly
6847914d74bSmrg	    # in scan sets, so we specify it separately.
6857914d74bSmrg	    case $arg in
6867914d74bSmrg	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
6877914d74bSmrg	      arg="\"$arg\""
6887914d74bSmrg	      ;;
6897914d74bSmrg	    esac
6907914d74bSmrg	    lastarg="$lastarg $arg"
6917914d74bSmrg	  done
6927914d74bSmrg	  IFS="$save_ifs"
6937914d74bSmrg	  lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
6947914d74bSmrg
6957914d74bSmrg	  # Add the arguments to base_compile.
6967914d74bSmrg	  base_compile="$base_compile $lastarg"
6977914d74bSmrg	  continue
6987914d74bSmrg	  ;;
6997914d74bSmrg
7007914d74bSmrg	* )
7017914d74bSmrg	  # Accept the current argument as the source file.
7027914d74bSmrg	  # The previous "srcfile" becomes the current argument.
7037914d74bSmrg	  #
7047914d74bSmrg	  lastarg="$srcfile"
7057914d74bSmrg	  srcfile="$arg"
7067914d74bSmrg	  ;;
7077914d74bSmrg	esac  #  case $arg
7087914d74bSmrg	;;
7097914d74bSmrg      esac    #  case $arg_mode
7107914d74bSmrg
7117914d74bSmrg      # Aesthetically quote the previous argument.
7127914d74bSmrg      lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
7137914d74bSmrg
7147914d74bSmrg      case $lastarg in
7157914d74bSmrg      # Double-quote args containing other shell metacharacters.
7167914d74bSmrg      # Many Bourne shells cannot handle close brackets correctly
7177914d74bSmrg      # in scan sets, and some SunOS ksh mistreat backslash-escaping
7187914d74bSmrg      # in scan sets (worked around with variable expansion),
7197914d74bSmrg      # and furthermore cannot handle '|' '&' '(' ')' in scan sets 
7207914d74bSmrg      # at all, so we specify them separately.
7217914d74bSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
7227914d74bSmrg	lastarg="\"$lastarg\""
7237914d74bSmrg	;;
7247914d74bSmrg      esac
7257914d74bSmrg
7267914d74bSmrg      base_compile="$base_compile $lastarg"
7277914d74bSmrg    done # for arg
7287914d74bSmrg
7297914d74bSmrg    case $arg_mode in
7307914d74bSmrg    arg)
7317914d74bSmrg      $echo "$modename: you must specify an argument for -Xcompile"
7327914d74bSmrg      exit $EXIT_FAILURE
7337914d74bSmrg      ;;
7347914d74bSmrg    target)
7357914d74bSmrg      $echo "$modename: you must specify a target with \`-o'" 1>&2
7367914d74bSmrg      exit $EXIT_FAILURE
7377914d74bSmrg      ;;
7387914d74bSmrg    *)
7397914d74bSmrg      # Get the name of the library object.
7407914d74bSmrg      [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
7417914d74bSmrg      ;;
7427914d74bSmrg    esac
7437914d74bSmrg
7447914d74bSmrg    # Recognize several different file suffixes.
7457914d74bSmrg    # If the user specifies -o file.o, it is replaced with file.lo
7467914d74bSmrg    xform='[cCFSifmso]'
7477914d74bSmrg    case $libobj in
7487914d74bSmrg    *.ada) xform=ada ;;
7497914d74bSmrg    *.adb) xform=adb ;;
7507914d74bSmrg    *.ads) xform=ads ;;
7517914d74bSmrg    *.asm) xform=asm ;;
7527914d74bSmrg    *.c++) xform=c++ ;;
7537914d74bSmrg    *.cc) xform=cc ;;
7547914d74bSmrg    *.ii) xform=ii ;;
7557914d74bSmrg    *.class) xform=class ;;
7567914d74bSmrg    *.cpp) xform=cpp ;;
7577914d74bSmrg    *.cxx) xform=cxx ;;
7587914d74bSmrg    *.f90) xform=f90 ;;
7597914d74bSmrg    *.for) xform=for ;;
7607914d74bSmrg    *.java) xform=java ;;
7617914d74bSmrg    esac
7627914d74bSmrg
7637914d74bSmrg    libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
7647914d74bSmrg
7657914d74bSmrg    case $libobj in
7667914d74bSmrg    *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
7677914d74bSmrg    *)
7687914d74bSmrg      $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
7697914d74bSmrg      exit $EXIT_FAILURE
7707914d74bSmrg      ;;
7717914d74bSmrg    esac
7727914d74bSmrg
7737914d74bSmrg    func_infer_tag $base_compile
7747914d74bSmrg
7757914d74bSmrg    for arg in $later; do
7767914d74bSmrg      case $arg in
7777914d74bSmrg      -static)
7787914d74bSmrg	build_old_libs=yes
7797914d74bSmrg	continue
7807914d74bSmrg	;;
7817914d74bSmrg
7827914d74bSmrg      -prefer-pic)
7837914d74bSmrg	pic_mode=yes
7847914d74bSmrg	continue
7857914d74bSmrg	;;
7867914d74bSmrg
7877914d74bSmrg      -prefer-non-pic)
7887914d74bSmrg	pic_mode=no
7897914d74bSmrg	continue
7907914d74bSmrg	;;
7917914d74bSmrg      esac
7927914d74bSmrg    done
7937914d74bSmrg
7947914d74bSmrg    qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"`
7957914d74bSmrg    case $qlibobj in
7967914d74bSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
7977914d74bSmrg	qlibobj="\"$qlibobj\"" ;;
7987914d74bSmrg    esac
7997914d74bSmrg    test "X$libobj" != "X$qlibobj" \
8007914d74bSmrg	&& $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"' 	&()|`$[]' \
8017914d74bSmrg	&& $echo "$modename: libobj name \`$libobj' may not contain shell special characters."
8027914d74bSmrg    objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
8037914d74bSmrg    xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
8047914d74bSmrg    if test "X$xdir" = "X$obj"; then
8057914d74bSmrg      xdir=
8067914d74bSmrg    else
8077914d74bSmrg      xdir=$xdir/
8087914d74bSmrg    fi
8097914d74bSmrg    lobj=${xdir}$objdir/$objname
8107914d74bSmrg
8117914d74bSmrg    if test -z "$base_compile"; then
8127914d74bSmrg      $echo "$modename: you must specify a compilation command" 1>&2
8137914d74bSmrg      $echo "$help" 1>&2
8147914d74bSmrg      exit $EXIT_FAILURE
8157914d74bSmrg    fi
8167914d74bSmrg
8177914d74bSmrg    # Delete any leftover library objects.
8187914d74bSmrg    if test "$build_old_libs" = yes; then
8197914d74bSmrg      removelist="$obj $lobj $libobj ${libobj}T"
8207914d74bSmrg    else
8217914d74bSmrg      removelist="$lobj $libobj ${libobj}T"
8227914d74bSmrg    fi
8237914d74bSmrg
8247914d74bSmrg    $run $rm $removelist
8257914d74bSmrg    trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
8267914d74bSmrg
8277914d74bSmrg    # On Cygwin there's no "real" PIC flag so we must build both object types
8287914d74bSmrg    case $host_os in
8297914d74bSmrg    cygwin* | mingw* | pw32* | os2*)
8307914d74bSmrg      pic_mode=default
8317914d74bSmrg      ;;
8327914d74bSmrg    esac
8337914d74bSmrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
8347914d74bSmrg      # non-PIC code in shared libraries is not supported
8357914d74bSmrg      pic_mode=default
8367914d74bSmrg    fi
8377914d74bSmrg
8387914d74bSmrg    # Calculate the filename of the output object if compiler does
8397914d74bSmrg    # not support -o with -c
8407914d74bSmrg    if test "$compiler_c_o" = no; then
8417914d74bSmrg      output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
8427914d74bSmrg      lockfile="$output_obj.lock"
8437914d74bSmrg      removelist="$removelist $output_obj $lockfile"
8447914d74bSmrg      trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
8457914d74bSmrg    else
8467914d74bSmrg      output_obj=
8477914d74bSmrg      need_locks=no
8487914d74bSmrg      lockfile=
8497914d74bSmrg    fi
8507914d74bSmrg
8517914d74bSmrg    # Lock this critical section if it is needed
8527914d74bSmrg    # We use this script file to make the link, it avoids creating a new file
8537914d74bSmrg    if test "$need_locks" = yes; then
8547914d74bSmrg      until $run ln "$progpath" "$lockfile" 2>/dev/null; do
8557914d74bSmrg	$show "Waiting for $lockfile to be removed"
8567914d74bSmrg	sleep 2
8577914d74bSmrg      done
8587914d74bSmrg    elif test "$need_locks" = warn; then
8597914d74bSmrg      if test -f "$lockfile"; then
8607914d74bSmrg	$echo "\
8617914d74bSmrg*** ERROR, $lockfile exists and contains:
8627914d74bSmrg`cat $lockfile 2>/dev/null`
8637914d74bSmrg
8647914d74bSmrgThis indicates that another process is trying to use the same
8657914d74bSmrgtemporary object file, and libtool could not work around it because
8667914d74bSmrgyour compiler does not support \`-c' and \`-o' together.  If you
8677914d74bSmrgrepeat this compilation, it may succeed, by chance, but you had better
8687914d74bSmrgavoid parallel builds (make -j) in this platform, or get a better
8697914d74bSmrgcompiler."
8707914d74bSmrg
8717914d74bSmrg	$run $rm $removelist
8727914d74bSmrg	exit $EXIT_FAILURE
8737914d74bSmrg      fi
8747914d74bSmrg      $echo "$srcfile" > "$lockfile"
8757914d74bSmrg    fi
8767914d74bSmrg
8777914d74bSmrg    if test -n "$fix_srcfile_path"; then
8787914d74bSmrg      eval srcfile=\"$fix_srcfile_path\"
8797914d74bSmrg    fi
8807914d74bSmrg    qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"`
8817914d74bSmrg    case $qsrcfile in
8827914d74bSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
8837914d74bSmrg      qsrcfile="\"$qsrcfile\"" ;;
8847914d74bSmrg    esac
8857914d74bSmrg
8867914d74bSmrg    $run $rm "$libobj" "${libobj}T"
8877914d74bSmrg
8887914d74bSmrg    # Create a libtool object file (analogous to a ".la" file),
8897914d74bSmrg    # but don't create it if we're doing a dry run.
8907914d74bSmrg    test -z "$run" && cat > ${libobj}T <<EOF
8917914d74bSmrg# $libobj - a libtool object file
8927914d74bSmrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
8937914d74bSmrg#
8947914d74bSmrg# Please DO NOT delete this file!
8957914d74bSmrg# It is necessary for linking the library.
8967914d74bSmrg
8977914d74bSmrg# Name of the PIC object.
8987914d74bSmrgEOF
8997914d74bSmrg
9007914d74bSmrg    # Only build a PIC object if we are building libtool libraries.
9017914d74bSmrg    if test "$build_libtool_libs" = yes; then
9027914d74bSmrg      # Without this assignment, base_compile gets emptied.
9037914d74bSmrg      fbsd_hideous_sh_bug=$base_compile
9047914d74bSmrg
9057914d74bSmrg      if test "$pic_mode" != no; then
9067914d74bSmrg	command="$base_compile $qsrcfile $pic_flag"
9077914d74bSmrg      else
9087914d74bSmrg	# Don't build PIC code
9097914d74bSmrg	command="$base_compile $qsrcfile"
9107914d74bSmrg      fi
9117914d74bSmrg
9127914d74bSmrg      if test ! -d "${xdir}$objdir"; then
9137914d74bSmrg	$show "$mkdir ${xdir}$objdir"
9147914d74bSmrg	$run $mkdir ${xdir}$objdir
9157914d74bSmrg	exit_status=$?
9167914d74bSmrg	if test "$exit_status" -ne 0 && test ! -d "${xdir}$objdir"; then
9177914d74bSmrg	  exit $exit_status
9187914d74bSmrg	fi
9197914d74bSmrg      fi
9207914d74bSmrg
9217914d74bSmrg      if test -z "$output_obj"; then
9227914d74bSmrg	# Place PIC objects in $objdir
9237914d74bSmrg	command="$command -o $lobj"
9247914d74bSmrg      fi
9257914d74bSmrg
9267914d74bSmrg      $run $rm "$lobj" "$output_obj"
9277914d74bSmrg
9287914d74bSmrg      $show "$command"
9297914d74bSmrg      if $run eval "$command"; then :
9307914d74bSmrg      else
9317914d74bSmrg	test -n "$output_obj" && $run $rm $removelist
9327914d74bSmrg	exit $EXIT_FAILURE
9337914d74bSmrg      fi
9347914d74bSmrg
9357914d74bSmrg      if test "$need_locks" = warn &&
9367914d74bSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
9377914d74bSmrg	$echo "\
9387914d74bSmrg*** ERROR, $lockfile contains:
9397914d74bSmrg`cat $lockfile 2>/dev/null`
9407914d74bSmrg
9417914d74bSmrgbut it should contain:
9427914d74bSmrg$srcfile
9437914d74bSmrg
9447914d74bSmrgThis indicates that another process is trying to use the same
9457914d74bSmrgtemporary object file, and libtool could not work around it because
9467914d74bSmrgyour compiler does not support \`-c' and \`-o' together.  If you
9477914d74bSmrgrepeat this compilation, it may succeed, by chance, but you had better
9487914d74bSmrgavoid parallel builds (make -j) in this platform, or get a better
9497914d74bSmrgcompiler."
9507914d74bSmrg
9517914d74bSmrg	$run $rm $removelist
9527914d74bSmrg	exit $EXIT_FAILURE
9537914d74bSmrg      fi
9547914d74bSmrg
9557914d74bSmrg      # Just move the object if needed, then go on to compile the next one
9567914d74bSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
9577914d74bSmrg	$show "$mv $output_obj $lobj"
9587914d74bSmrg	if $run $mv $output_obj $lobj; then :
9597914d74bSmrg	else
9607914d74bSmrg	  error=$?
9617914d74bSmrg	  $run $rm $removelist
9627914d74bSmrg	  exit $error
9637914d74bSmrg	fi
9647914d74bSmrg      fi
9657914d74bSmrg
9667914d74bSmrg      # Append the name of the PIC object to the libtool object file.
9677914d74bSmrg      test -z "$run" && cat >> ${libobj}T <<EOF
9687914d74bSmrgpic_object='$objdir/$objname'
9697914d74bSmrg
9707914d74bSmrgEOF
9717914d74bSmrg
9727914d74bSmrg      # Allow error messages only from the first compilation.
9737914d74bSmrg      if test "$suppress_opt" = yes; then
9747914d74bSmrg        suppress_output=' >/dev/null 2>&1'
9757914d74bSmrg      fi
9767914d74bSmrg    else
9777914d74bSmrg      # No PIC object so indicate it doesn't exist in the libtool
9787914d74bSmrg      # object file.
9797914d74bSmrg      test -z "$run" && cat >> ${libobj}T <<EOF
9807914d74bSmrgpic_object=none
9817914d74bSmrg
9827914d74bSmrgEOF
9837914d74bSmrg    fi
9847914d74bSmrg
9857914d74bSmrg    # Only build a position-dependent object if we build old libraries.
9867914d74bSmrg    if test "$build_old_libs" = yes; then
9877914d74bSmrg      if test "$pic_mode" != yes; then
9887914d74bSmrg	# Don't build PIC code
9897914d74bSmrg	command="$base_compile $qsrcfile"
9907914d74bSmrg      else
9917914d74bSmrg	command="$base_compile $qsrcfile $pic_flag"
9927914d74bSmrg      fi
9937914d74bSmrg      if test "$compiler_c_o" = yes; then
9947914d74bSmrg	command="$command -o $obj"
9957914d74bSmrg      fi
9967914d74bSmrg
9977914d74bSmrg      # Suppress compiler output if we already did a PIC compilation.
9987914d74bSmrg      command="$command$suppress_output"
9997914d74bSmrg      $run $rm "$obj" "$output_obj"
10007914d74bSmrg      $show "$command"
10017914d74bSmrg      if $run eval "$command"; then :
10027914d74bSmrg      else
10037914d74bSmrg	$run $rm $removelist
10047914d74bSmrg	exit $EXIT_FAILURE
10057914d74bSmrg      fi
10067914d74bSmrg
10077914d74bSmrg      if test "$need_locks" = warn &&
10087914d74bSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
10097914d74bSmrg	$echo "\
10107914d74bSmrg*** ERROR, $lockfile contains:
10117914d74bSmrg`cat $lockfile 2>/dev/null`
10127914d74bSmrg
10137914d74bSmrgbut it should contain:
10147914d74bSmrg$srcfile
10157914d74bSmrg
10167914d74bSmrgThis indicates that another process is trying to use the same
10177914d74bSmrgtemporary object file, and libtool could not work around it because
10187914d74bSmrgyour compiler does not support \`-c' and \`-o' together.  If you
10197914d74bSmrgrepeat this compilation, it may succeed, by chance, but you had better
10207914d74bSmrgavoid parallel builds (make -j) in this platform, or get a better
10217914d74bSmrgcompiler."
10227914d74bSmrg
10237914d74bSmrg	$run $rm $removelist
10247914d74bSmrg	exit $EXIT_FAILURE
10257914d74bSmrg      fi
10267914d74bSmrg
10277914d74bSmrg      # Just move the object if needed
10287914d74bSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
10297914d74bSmrg	$show "$mv $output_obj $obj"
10307914d74bSmrg	if $run $mv $output_obj $obj; then :
10317914d74bSmrg	else
10327914d74bSmrg	  error=$?
10337914d74bSmrg	  $run $rm $removelist
10347914d74bSmrg	  exit $error
10357914d74bSmrg	fi
10367914d74bSmrg      fi
10377914d74bSmrg
10387914d74bSmrg      # Append the name of the non-PIC object the libtool object file.
10397914d74bSmrg      # Only append if the libtool object file exists.
10407914d74bSmrg      test -z "$run" && cat >> ${libobj}T <<EOF
10417914d74bSmrg# Name of the non-PIC object.
10427914d74bSmrgnon_pic_object='$objname'
10437914d74bSmrg
10447914d74bSmrgEOF
10457914d74bSmrg    else
10467914d74bSmrg      # Append the name of the non-PIC object the libtool object file.
10477914d74bSmrg      # Only append if the libtool object file exists.
10487914d74bSmrg      test -z "$run" && cat >> ${libobj}T <<EOF
10497914d74bSmrg# Name of the non-PIC object.
10507914d74bSmrgnon_pic_object=none
10517914d74bSmrg
10527914d74bSmrgEOF
10537914d74bSmrg    fi
10547914d74bSmrg
10557914d74bSmrg    $run $mv "${libobj}T" "${libobj}"
10567914d74bSmrg
10577914d74bSmrg    # Unlock the critical section if it was locked
10587914d74bSmrg    if test "$need_locks" != no; then
10597914d74bSmrg      $run $rm "$lockfile"
10607914d74bSmrg    fi
10617914d74bSmrg
10627914d74bSmrg    exit $EXIT_SUCCESS
10637914d74bSmrg    ;;
10647914d74bSmrg
10657914d74bSmrg  # libtool link mode
10667914d74bSmrg  link | relink)
10677914d74bSmrg    modename="$modename: link"
10687914d74bSmrg    case $host in
10697914d74bSmrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
10707914d74bSmrg      # It is impossible to link a dll without this setting, and
10717914d74bSmrg      # we shouldn't force the makefile maintainer to figure out
10727914d74bSmrg      # which system we are compiling for in order to pass an extra
10737914d74bSmrg      # flag for every libtool invocation.
10747914d74bSmrg      # allow_undefined=no
10757914d74bSmrg
10767914d74bSmrg      # FIXME: Unfortunately, there are problems with the above when trying
10777914d74bSmrg      # to make a dll which has undefined symbols, in which case not
10787914d74bSmrg      # even a static library is built.  For now, we need to specify
10797914d74bSmrg      # -no-undefined on the libtool link line when we can be certain
10807914d74bSmrg      # that all symbols are satisfied, otherwise we get a static library.
10817914d74bSmrg      allow_undefined=yes
10827914d74bSmrg      ;;
10837914d74bSmrg    *)
10847914d74bSmrg      allow_undefined=yes
10857914d74bSmrg      ;;
10867914d74bSmrg    esac
10877914d74bSmrg    libtool_args="$nonopt"
10887914d74bSmrg    base_compile="$nonopt $@"
10897914d74bSmrg    compile_command="$nonopt"
10907914d74bSmrg    finalize_command="$nonopt"
10917914d74bSmrg
10927914d74bSmrg    compile_rpath=
10937914d74bSmrg    finalize_rpath=
10947914d74bSmrg    compile_shlibpath=
10957914d74bSmrg    finalize_shlibpath=
10967914d74bSmrg    convenience=
10977914d74bSmrg    old_convenience=
10987914d74bSmrg    deplibs=
10997914d74bSmrg    old_deplibs=
11007914d74bSmrg    compiler_flags=
11017914d74bSmrg    linker_flags=
11027914d74bSmrg    dllsearchpath=
11037914d74bSmrg    lib_search_path=`pwd`
11047914d74bSmrg    inst_prefix_dir=
11057914d74bSmrg
11067914d74bSmrg    avoid_version=no
11077914d74bSmrg    dlfiles=
11087914d74bSmrg    dlprefiles=
11097914d74bSmrg    dlself=no
11107914d74bSmrg    export_dynamic=no
11117914d74bSmrg    export_symbols=
11127914d74bSmrg    export_symbols_regex=
11137914d74bSmrg    generated=
11147914d74bSmrg    libobjs=
11157914d74bSmrg    ltlibs=
11167914d74bSmrg    module=no
11177914d74bSmrg    no_install=no
11187914d74bSmrg    objs=
11197914d74bSmrg    non_pic_objects=
11207914d74bSmrg    notinst_path= # paths that contain not-installed libtool libraries
11217914d74bSmrg    precious_files_regex=
11227914d74bSmrg    prefer_static_libs=no
11237914d74bSmrg    preload=no
11247914d74bSmrg    prev=
11257914d74bSmrg    prevarg=
11267914d74bSmrg    release=
11277914d74bSmrg    rpath=
11287914d74bSmrg    xrpath=
11297914d74bSmrg    perm_rpath=
11307914d74bSmrg    temp_rpath=
11317914d74bSmrg    thread_safe=no
11327914d74bSmrg    vinfo=
11337914d74bSmrg    vinfo_number=no
11347914d74bSmrg
11357914d74bSmrg    func_infer_tag $base_compile
11367914d74bSmrg
11377914d74bSmrg    # We need to know -static, to get the right output filenames.
11387914d74bSmrg    for arg
11397914d74bSmrg    do
11407914d74bSmrg      case $arg in
11417914d74bSmrg      -all-static | -static)
11427914d74bSmrg	if test "X$arg" = "X-all-static"; then
11437914d74bSmrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
11447914d74bSmrg	    $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
11457914d74bSmrg	  fi
11467914d74bSmrg	  if test -n "$link_static_flag"; then
11477914d74bSmrg	    dlopen_self=$dlopen_self_static
11487914d74bSmrg	  fi
11497914d74bSmrg	  prefer_static_libs=yes
11507914d74bSmrg	else
11517914d74bSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
11527914d74bSmrg	    dlopen_self=$dlopen_self_static
11537914d74bSmrg	  fi
11547914d74bSmrg	  prefer_static_libs=built
11557914d74bSmrg	fi
11567914d74bSmrg	build_libtool_libs=no
11577914d74bSmrg	build_old_libs=yes
11587914d74bSmrg	break
11597914d74bSmrg	;;
11607914d74bSmrg      esac
11617914d74bSmrg    done
11627914d74bSmrg
11637914d74bSmrg    # See if our shared archives depend on static archives.
11647914d74bSmrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
11657914d74bSmrg
11667914d74bSmrg    # Go through the arguments, transforming them on the way.
11677914d74bSmrg    while test "$#" -gt 0; do
11687914d74bSmrg      arg="$1"
11697914d74bSmrg      shift
11707914d74bSmrg      case $arg in
11717914d74bSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
11727914d74bSmrg	qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test
11737914d74bSmrg	;;
11747914d74bSmrg      *) qarg=$arg ;;
11757914d74bSmrg      esac
11767914d74bSmrg      libtool_args="$libtool_args $qarg"
11777914d74bSmrg
11787914d74bSmrg      # If the previous option needs an argument, assign it.
11797914d74bSmrg      if test -n "$prev"; then
11807914d74bSmrg	case $prev in
11817914d74bSmrg	output)
11827914d74bSmrg	  compile_command="$compile_command @OUTPUT@"
11837914d74bSmrg	  finalize_command="$finalize_command @OUTPUT@"
11847914d74bSmrg	  ;;
11857914d74bSmrg	esac
11867914d74bSmrg
11877914d74bSmrg	case $prev in
11887914d74bSmrg	dlfiles|dlprefiles)
11897914d74bSmrg	  if test "$preload" = no; then
11907914d74bSmrg	    # Add the symbol object into the linking commands.
11917914d74bSmrg	    compile_command="$compile_command @SYMFILE@"
11927914d74bSmrg	    finalize_command="$finalize_command @SYMFILE@"
11937914d74bSmrg	    preload=yes
11947914d74bSmrg	  fi
11957914d74bSmrg	  case $arg in
11967914d74bSmrg	  *.la | *.lo) ;;  # We handle these cases below.
11977914d74bSmrg	  force)
11987914d74bSmrg	    if test "$dlself" = no; then
11997914d74bSmrg	      dlself=needless
12007914d74bSmrg	      export_dynamic=yes
12017914d74bSmrg	    fi
12027914d74bSmrg	    prev=
12037914d74bSmrg	    continue
12047914d74bSmrg	    ;;
12057914d74bSmrg	  self)
12067914d74bSmrg	    if test "$prev" = dlprefiles; then
12077914d74bSmrg	      dlself=yes
12087914d74bSmrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
12097914d74bSmrg	      dlself=yes
12107914d74bSmrg	    else
12117914d74bSmrg	      dlself=needless
12127914d74bSmrg	      export_dynamic=yes
12137914d74bSmrg	    fi
12147914d74bSmrg	    prev=
12157914d74bSmrg	    continue
12167914d74bSmrg	    ;;
12177914d74bSmrg	  *)
12187914d74bSmrg	    if test "$prev" = dlfiles; then
12197914d74bSmrg	      dlfiles="$dlfiles $arg"
12207914d74bSmrg	    else
12217914d74bSmrg	      dlprefiles="$dlprefiles $arg"
12227914d74bSmrg	    fi
12237914d74bSmrg	    prev=
12247914d74bSmrg	    continue
12257914d74bSmrg	    ;;
12267914d74bSmrg	  esac
12277914d74bSmrg	  ;;
12287914d74bSmrg	expsyms)
12297914d74bSmrg	  export_symbols="$arg"
12307914d74bSmrg	  if test ! -f "$arg"; then
12317914d74bSmrg	    $echo "$modename: symbol file \`$arg' does not exist"
12327914d74bSmrg	    exit $EXIT_FAILURE
12337914d74bSmrg	  fi
12347914d74bSmrg	  prev=
12357914d74bSmrg	  continue
12367914d74bSmrg	  ;;
12377914d74bSmrg	expsyms_regex)
12387914d74bSmrg	  export_symbols_regex="$arg"
12397914d74bSmrg	  prev=
12407914d74bSmrg	  continue
12417914d74bSmrg	  ;;
12427914d74bSmrg	inst_prefix)
12437914d74bSmrg	  inst_prefix_dir="$arg"
12447914d74bSmrg	  prev=
12457914d74bSmrg	  continue
12467914d74bSmrg	  ;;
12477914d74bSmrg	precious_regex)
12487914d74bSmrg	  precious_files_regex="$arg"
12497914d74bSmrg	  prev=
12507914d74bSmrg	  continue
12517914d74bSmrg	  ;;
12527914d74bSmrg	release)
12537914d74bSmrg	  release="-$arg"
12547914d74bSmrg	  prev=
12557914d74bSmrg	  continue
12567914d74bSmrg	  ;;
12577914d74bSmrg	objectlist)
12587914d74bSmrg	  if test -f "$arg"; then
12597914d74bSmrg	    save_arg=$arg
12607914d74bSmrg	    moreargs=
12617914d74bSmrg	    for fil in `cat $save_arg`
12627914d74bSmrg	    do
12637914d74bSmrg#	      moreargs="$moreargs $fil"
12647914d74bSmrg	      arg=$fil
12657914d74bSmrg	      # A libtool-controlled object.
12667914d74bSmrg
12677914d74bSmrg	      # Check to see that this really is a libtool object.
12687914d74bSmrg	      if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
12697914d74bSmrg		pic_object=
12707914d74bSmrg		non_pic_object=
12717914d74bSmrg
12727914d74bSmrg		# Read the .lo file
12737914d74bSmrg		# If there is no directory component, then add one.
12747914d74bSmrg		case $arg in
12757914d74bSmrg		*/* | *\\*) . $arg ;;
12767914d74bSmrg		*) . ./$arg ;;
12777914d74bSmrg		esac
12787914d74bSmrg
12797914d74bSmrg		if test -z "$pic_object" || \
12807914d74bSmrg		   test -z "$non_pic_object" ||
12817914d74bSmrg		   test "$pic_object" = none && \
12827914d74bSmrg		   test "$non_pic_object" = none; then
12837914d74bSmrg		  $echo "$modename: cannot find name of object for \`$arg'" 1>&2
12847914d74bSmrg		  exit $EXIT_FAILURE
12857914d74bSmrg		fi
12867914d74bSmrg
12877914d74bSmrg		# Extract subdirectory from the argument.
12887914d74bSmrg		xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
12897914d74bSmrg		if test "X$xdir" = "X$arg"; then
12907914d74bSmrg		  xdir=
12917914d74bSmrg		else
12927914d74bSmrg		  xdir="$xdir/"
12937914d74bSmrg		fi
12947914d74bSmrg
12957914d74bSmrg		if test "$pic_object" != none; then
12967914d74bSmrg		  # Prepend the subdirectory the object is found in.
12977914d74bSmrg		  pic_object="$xdir$pic_object"
12987914d74bSmrg
12997914d74bSmrg		  if test "$prev" = dlfiles; then
13007914d74bSmrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
13017914d74bSmrg		      dlfiles="$dlfiles $pic_object"
13027914d74bSmrg		      prev=
13037914d74bSmrg		      continue
13047914d74bSmrg		    else
13057914d74bSmrg		      # If libtool objects are unsupported, then we need to preload.
13067914d74bSmrg		      prev=dlprefiles
13077914d74bSmrg		    fi
13087914d74bSmrg		  fi
13097914d74bSmrg
13107914d74bSmrg		  # CHECK ME:  I think I busted this.  -Ossama
13117914d74bSmrg		  if test "$prev" = dlprefiles; then
13127914d74bSmrg		    # Preload the old-style object.
13137914d74bSmrg		    dlprefiles="$dlprefiles $pic_object"
13147914d74bSmrg		    prev=
13157914d74bSmrg		  fi
13167914d74bSmrg
13177914d74bSmrg		  # A PIC object.
13187914d74bSmrg		  libobjs="$libobjs $pic_object"
13197914d74bSmrg		  arg="$pic_object"
13207914d74bSmrg		fi
13217914d74bSmrg
13227914d74bSmrg		# Non-PIC object.
13237914d74bSmrg		if test "$non_pic_object" != none; then
13247914d74bSmrg		  # Prepend the subdirectory the object is found in.
13257914d74bSmrg		  non_pic_object="$xdir$non_pic_object"
13267914d74bSmrg
13277914d74bSmrg		  # A standard non-PIC object
13287914d74bSmrg		  non_pic_objects="$non_pic_objects $non_pic_object"
13297914d74bSmrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
13307914d74bSmrg		    arg="$non_pic_object"
13317914d74bSmrg		  fi
13327914d74bSmrg		else
13337914d74bSmrg		  # If the PIC object exists, use it instead.
13347914d74bSmrg		  # $xdir was prepended to $pic_object above.
13357914d74bSmrg		  non_pic_object="$pic_object"
13367914d74bSmrg		  non_pic_objects="$non_pic_objects $non_pic_object"
13377914d74bSmrg		fi
13387914d74bSmrg	      else
13397914d74bSmrg		# Only an error if not doing a dry-run.
13407914d74bSmrg		if test -z "$run"; then
13417914d74bSmrg		  $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
13427914d74bSmrg		  exit $EXIT_FAILURE
13437914d74bSmrg		else
13447914d74bSmrg		  # Dry-run case.
13457914d74bSmrg
13467914d74bSmrg		  # Extract subdirectory from the argument.
13477914d74bSmrg		  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
13487914d74bSmrg		  if test "X$xdir" = "X$arg"; then
13497914d74bSmrg		    xdir=
13507914d74bSmrg		  else
13517914d74bSmrg		    xdir="$xdir/"
13527914d74bSmrg		  fi
13537914d74bSmrg
13547914d74bSmrg		  pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
13557914d74bSmrg		  non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
13567914d74bSmrg		  libobjs="$libobjs $pic_object"
13577914d74bSmrg		  non_pic_objects="$non_pic_objects $non_pic_object"
13587914d74bSmrg		fi
13597914d74bSmrg	      fi
13607914d74bSmrg	    done
13617914d74bSmrg	  else
13627914d74bSmrg	    $echo "$modename: link input file \`$save_arg' does not exist"
13637914d74bSmrg	    exit $EXIT_FAILURE
13647914d74bSmrg	  fi
13657914d74bSmrg	  arg=$save_arg
13667914d74bSmrg	  prev=
13677914d74bSmrg	  continue
13687914d74bSmrg	  ;;
13697914d74bSmrg	rpath | xrpath)
13707914d74bSmrg	  # We need an absolute path.
13717914d74bSmrg	  case $arg in
13727914d74bSmrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
13737914d74bSmrg	  *)
13747914d74bSmrg	    $echo "$modename: only absolute run-paths are allowed" 1>&2
13757914d74bSmrg	    exit $EXIT_FAILURE
13767914d74bSmrg	    ;;
13777914d74bSmrg	  esac
13787914d74bSmrg	  if test "$prev" = rpath; then
13797914d74bSmrg	    case "$rpath " in
13807914d74bSmrg	    *" $arg "*) ;;
13817914d74bSmrg	    *) rpath="$rpath $arg" ;;
13827914d74bSmrg	    esac
13837914d74bSmrg	  else
13847914d74bSmrg	    case "$xrpath " in
13857914d74bSmrg	    *" $arg "*) ;;
13867914d74bSmrg	    *) xrpath="$xrpath $arg" ;;
13877914d74bSmrg	    esac
13887914d74bSmrg	  fi
13897914d74bSmrg	  prev=
13907914d74bSmrg	  continue
13917914d74bSmrg	  ;;
13927914d74bSmrg	xcompiler)
13937914d74bSmrg	  compiler_flags="$compiler_flags $qarg"
13947914d74bSmrg	  prev=
13957914d74bSmrg	  compile_command="$compile_command $qarg"
13967914d74bSmrg	  finalize_command="$finalize_command $qarg"
13977914d74bSmrg	  continue
13987914d74bSmrg	  ;;
13997914d74bSmrg	xlinker)
14007914d74bSmrg	  linker_flags="$linker_flags $qarg"
14017914d74bSmrg	  compiler_flags="$compiler_flags $wl$qarg"
14027914d74bSmrg	  prev=
14037914d74bSmrg	  compile_command="$compile_command $wl$qarg"
14047914d74bSmrg	  finalize_command="$finalize_command $wl$qarg"
14057914d74bSmrg	  continue
14067914d74bSmrg	  ;;
14077914d74bSmrg	xcclinker)
14087914d74bSmrg	  linker_flags="$linker_flags $qarg"
14097914d74bSmrg	  compiler_flags="$compiler_flags $qarg"
14107914d74bSmrg	  prev=
14117914d74bSmrg	  compile_command="$compile_command $qarg"
14127914d74bSmrg	  finalize_command="$finalize_command $qarg"
14137914d74bSmrg	  continue
14147914d74bSmrg	  ;;
14157914d74bSmrg	shrext)
14167914d74bSmrg  	  shrext_cmds="$arg"
14177914d74bSmrg	  prev=
14187914d74bSmrg	  continue
14197914d74bSmrg	  ;;
14207914d74bSmrg	darwin_framework|darwin_framework_skip)
14217914d74bSmrg	  test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg"
14227914d74bSmrg	  compile_command="$compile_command $arg"
14237914d74bSmrg	  finalize_command="$finalize_command $arg"
14247914d74bSmrg	  prev=
14257914d74bSmrg	  continue
14267914d74bSmrg	  ;;
14277914d74bSmrg	*)
14287914d74bSmrg	  eval "$prev=\"\$arg\""
14297914d74bSmrg	  prev=
14307914d74bSmrg	  continue
14317914d74bSmrg	  ;;
14327914d74bSmrg	esac
14337914d74bSmrg      fi # test -n "$prev"
14347914d74bSmrg
14357914d74bSmrg      prevarg="$arg"
14367914d74bSmrg
14377914d74bSmrg      case $arg in
14387914d74bSmrg      -all-static)
14397914d74bSmrg	if test -n "$link_static_flag"; then
14407914d74bSmrg	  compile_command="$compile_command $link_static_flag"
14417914d74bSmrg	  finalize_command="$finalize_command $link_static_flag"
14427914d74bSmrg	fi
14437914d74bSmrg	continue
14447914d74bSmrg	;;
14457914d74bSmrg
14467914d74bSmrg      -allow-undefined)
14477914d74bSmrg	# FIXME: remove this flag sometime in the future.
14487914d74bSmrg	$echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
14497914d74bSmrg	continue
14507914d74bSmrg	;;
14517914d74bSmrg
14527914d74bSmrg      -avoid-version)
14537914d74bSmrg	avoid_version=yes
14547914d74bSmrg	continue
14557914d74bSmrg	;;
14567914d74bSmrg
14577914d74bSmrg      -dlopen)
14587914d74bSmrg	prev=dlfiles
14597914d74bSmrg	continue
14607914d74bSmrg	;;
14617914d74bSmrg
14627914d74bSmrg      -dlpreopen)
14637914d74bSmrg	prev=dlprefiles
14647914d74bSmrg	continue
14657914d74bSmrg	;;
14667914d74bSmrg
14677914d74bSmrg      -export-dynamic)
14687914d74bSmrg	export_dynamic=yes
14697914d74bSmrg	continue
14707914d74bSmrg	;;
14717914d74bSmrg
14727914d74bSmrg      -export-symbols | -export-symbols-regex)
14737914d74bSmrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
14747914d74bSmrg	  $echo "$modename: more than one -exported-symbols argument is not allowed"
14757914d74bSmrg	  exit $EXIT_FAILURE
14767914d74bSmrg	fi
14777914d74bSmrg	if test "X$arg" = "X-export-symbols"; then
14787914d74bSmrg	  prev=expsyms
14797914d74bSmrg	else
14807914d74bSmrg	  prev=expsyms_regex
14817914d74bSmrg	fi
14827914d74bSmrg	continue
14837914d74bSmrg	;;
14847914d74bSmrg
14857914d74bSmrg      -framework|-arch|-isysroot)
14867914d74bSmrg	case " $CC " in
14877914d74bSmrg	  *" ${arg} ${1} "* | *" ${arg}	${1} "*) 
14887914d74bSmrg		prev=darwin_framework_skip ;;
14897914d74bSmrg	  *) compiler_flags="$compiler_flags $arg"
14907914d74bSmrg	     prev=darwin_framework ;;
14917914d74bSmrg	esac
14927914d74bSmrg	compile_command="$compile_command $arg"
14937914d74bSmrg	finalize_command="$finalize_command $arg"
14947914d74bSmrg	continue
14957914d74bSmrg	;;
14967914d74bSmrg
14977914d74bSmrg      -inst-prefix-dir)
14987914d74bSmrg	prev=inst_prefix
14997914d74bSmrg	continue
15007914d74bSmrg	;;
15017914d74bSmrg
15027914d74bSmrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
15037914d74bSmrg      # so, if we see these flags be careful not to treat them like -L
15047914d74bSmrg      -L[A-Z][A-Z]*:*)
15057914d74bSmrg	case $with_gcc/$host in
15067914d74bSmrg	no/*-*-irix* | /*-*-irix*)
15077914d74bSmrg	  compile_command="$compile_command $arg"
15087914d74bSmrg	  finalize_command="$finalize_command $arg"
15097914d74bSmrg	  ;;
15107914d74bSmrg	esac
15117914d74bSmrg	continue
15127914d74bSmrg	;;
15137914d74bSmrg
15147914d74bSmrg      -L*)
15157914d74bSmrg	dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
15167914d74bSmrg	# We need an absolute path.
15177914d74bSmrg	case $dir in
15187914d74bSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
15197914d74bSmrg	*)
15207914d74bSmrg	  absdir=`cd "$dir" && pwd`
15217914d74bSmrg	  if test -z "$absdir"; then
15227914d74bSmrg	    $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
15237914d74bSmrg	    absdir="$dir"
15247914d74bSmrg	    notinst_path="$notinst_path $dir"
15257914d74bSmrg	  fi
15267914d74bSmrg	  dir="$absdir"
15277914d74bSmrg	  ;;
15287914d74bSmrg	esac
15297914d74bSmrg	case "$deplibs " in
15307914d74bSmrg	*" -L$dir "*) ;;
15317914d74bSmrg	*)
15327914d74bSmrg	  deplibs="$deplibs -L$dir"
15337914d74bSmrg	  lib_search_path="$lib_search_path $dir"
15347914d74bSmrg	  ;;
15357914d74bSmrg	esac
15367914d74bSmrg	case $host in
15377914d74bSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
15387914d74bSmrg	  testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'`
15397914d74bSmrg	  case :$dllsearchpath: in
15407914d74bSmrg	  *":$dir:"*) ;;
15417914d74bSmrg	  *) dllsearchpath="$dllsearchpath:$dir";;
15427914d74bSmrg	  esac
15437914d74bSmrg	  case :$dllsearchpath: in
15447914d74bSmrg	  *":$testbindir:"*) ;;
15457914d74bSmrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
15467914d74bSmrg	  esac
15477914d74bSmrg	  ;;
15487914d74bSmrg	esac
15497914d74bSmrg	continue
15507914d74bSmrg	;;
15517914d74bSmrg
15527914d74bSmrg      -l*)
15537914d74bSmrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
15547914d74bSmrg	  case $host in
15557914d74bSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*)
15567914d74bSmrg	    # These systems don't actually have a C or math library (as such)
15577914d74bSmrg	    continue
15587914d74bSmrg	    ;;
15597914d74bSmrg	  *-*-os2*)
15607914d74bSmrg	    # These systems don't actually have a C library (as such)
15617914d74bSmrg	    test "X$arg" = "X-lc" && continue
15627914d74bSmrg	    ;;
15637914d74bSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
15647914d74bSmrg	    # Do not include libc due to us having libc/libc_r.
15657914d74bSmrg	    test "X$arg" = "X-lc" && continue
15667914d74bSmrg	    ;;
15677914d74bSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
15687914d74bSmrg	    # Rhapsody C and math libraries are in the System framework
15697914d74bSmrg	    deplibs="$deplibs -framework System"
15707914d74bSmrg	    continue
15717914d74bSmrg	    ;;
15727914d74bSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
15737914d74bSmrg	    # Causes problems with __ctype
15747914d74bSmrg	    test "X$arg" = "X-lc" && continue
15757914d74bSmrg	    ;;
15767914d74bSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
15777914d74bSmrg	    # Compiler inserts libc in the correct place for threads to work
15787914d74bSmrg	    test "X$arg" = "X-lc" && continue
15797914d74bSmrg	    ;;
15807914d74bSmrg	  esac
15817914d74bSmrg	elif test "X$arg" = "X-lc_r"; then
15827914d74bSmrg	 case $host in
15837914d74bSmrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
15847914d74bSmrg	   # Do not include libc_r directly, use -pthread flag.
15857914d74bSmrg	   continue
15867914d74bSmrg	   ;;
15877914d74bSmrg	 esac
15887914d74bSmrg	fi
15897914d74bSmrg	deplibs="$deplibs $arg"
15907914d74bSmrg	continue
15917914d74bSmrg	;;
15927914d74bSmrg
15937914d74bSmrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
15947914d74bSmrg      # classes, name mangling, and exception handling.
15957914d74bSmrg      -model)
15967914d74bSmrg	compile_command="$compile_command $arg"
15977914d74bSmrg	compiler_flags="$compiler_flags $arg"
15987914d74bSmrg	finalize_command="$finalize_command $arg"
15997914d74bSmrg	prev=xcompiler
16007914d74bSmrg	continue
16017914d74bSmrg	;;
16027914d74bSmrg
16037914d74bSmrg     -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
16047914d74bSmrg	compiler_flags="$compiler_flags $arg"
16057914d74bSmrg	compile_command="$compile_command $arg"
16067914d74bSmrg	finalize_command="$finalize_command $arg"
16077914d74bSmrg	continue
16087914d74bSmrg	;;
16097914d74bSmrg
16107914d74bSmrg      -module)
16117914d74bSmrg	module=yes
16127914d74bSmrg	continue
16137914d74bSmrg	;;
16147914d74bSmrg
16157914d74bSmrg      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
16167914d74bSmrg      # -r[0-9][0-9]* specifies the processor on the SGI compiler
16177914d74bSmrg      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
16187914d74bSmrg      # +DA*, +DD* enable 64-bit mode on the HP compiler
16197914d74bSmrg      # -q* pass through compiler args for the IBM compiler
16207914d74bSmrg      # -m* pass through architecture-specific compiler args for GCC
16217914d74bSmrg      # -m*, -t[45]*, -txscale* pass through architecture-specific
16227914d74bSmrg      # compiler args for GCC
16237914d74bSmrg      # -pg pass through profiling flag for GCC
16247914d74bSmrg      # @file GCC response files
16257914d74bSmrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*|-pg| \
16267914d74bSmrg      -t[45]*|-txscale*|@*)
16277914d74bSmrg
16287914d74bSmrg	# Unknown arguments in both finalize_command and compile_command need
16297914d74bSmrg	# to be aesthetically quoted because they are evaled later.
16307914d74bSmrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
16317914d74bSmrg	case $arg in
16327914d74bSmrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
16337914d74bSmrg	  arg="\"$arg\""
16347914d74bSmrg	  ;;
16357914d74bSmrg	esac
16367914d74bSmrg        compile_command="$compile_command $arg"
16377914d74bSmrg        finalize_command="$finalize_command $arg"
16387914d74bSmrg        compiler_flags="$compiler_flags $arg"
16397914d74bSmrg        continue
16407914d74bSmrg        ;;
16417914d74bSmrg
16427914d74bSmrg      -shrext)
16437914d74bSmrg	prev=shrext
16447914d74bSmrg	continue
16457914d74bSmrg	;;
16467914d74bSmrg
16477914d74bSmrg      -no-fast-install)
16487914d74bSmrg	fast_install=no
16497914d74bSmrg	continue
16507914d74bSmrg	;;
16517914d74bSmrg
16527914d74bSmrg      -no-install)
16537914d74bSmrg	case $host in
16547914d74bSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
16557914d74bSmrg	  # The PATH hackery in wrapper scripts is required on Windows
16567914d74bSmrg	  # in order for the loader to find any dlls it needs.
16577914d74bSmrg	  $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2
16587914d74bSmrg	  $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2
16597914d74bSmrg	  fast_install=no
16607914d74bSmrg	  ;;
16617914d74bSmrg	*) no_install=yes ;;
16627914d74bSmrg	esac
16637914d74bSmrg	continue
16647914d74bSmrg	;;
16657914d74bSmrg
16667914d74bSmrg      -no-undefined)
16677914d74bSmrg	allow_undefined=no
16687914d74bSmrg	continue
16697914d74bSmrg	;;
16707914d74bSmrg
16717914d74bSmrg      -objectlist)
16727914d74bSmrg	prev=objectlist
16737914d74bSmrg	continue
16747914d74bSmrg	;;
16757914d74bSmrg
16767914d74bSmrg      -o) prev=output ;;
16777914d74bSmrg
16787914d74bSmrg      -precious-files-regex)
16797914d74bSmrg	prev=precious_regex
16807914d74bSmrg	continue
16817914d74bSmrg	;;
16827914d74bSmrg
16837914d74bSmrg      -release)
16847914d74bSmrg	prev=release
16857914d74bSmrg	continue
16867914d74bSmrg	;;
16877914d74bSmrg
16887914d74bSmrg      -rpath)
16897914d74bSmrg	prev=rpath
16907914d74bSmrg	continue
16917914d74bSmrg	;;
16927914d74bSmrg
16937914d74bSmrg      -R)
16947914d74bSmrg	prev=xrpath
16957914d74bSmrg	continue
16967914d74bSmrg	;;
16977914d74bSmrg
16987914d74bSmrg      -R*)
16997914d74bSmrg	dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
17007914d74bSmrg	# We need an absolute path.
17017914d74bSmrg	case $dir in
17027914d74bSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
17037914d74bSmrg	*)
17047914d74bSmrg	  $echo "$modename: only absolute run-paths are allowed" 1>&2
17057914d74bSmrg	  exit $EXIT_FAILURE
17067914d74bSmrg	  ;;
17077914d74bSmrg	esac
17087914d74bSmrg	case "$xrpath " in
17097914d74bSmrg	*" $dir "*) ;;
17107914d74bSmrg	*) xrpath="$xrpath $dir" ;;
17117914d74bSmrg	esac
17127914d74bSmrg	continue
17137914d74bSmrg	;;
17147914d74bSmrg
17157914d74bSmrg      -static)
17167914d74bSmrg	# The effects of -static are defined in a previous loop.
17177914d74bSmrg	# We used to do the same as -all-static on platforms that
17187914d74bSmrg	# didn't have a PIC flag, but the assumption that the effects
17197914d74bSmrg	# would be equivalent was wrong.  It would break on at least
17207914d74bSmrg	# Digital Unix and AIX.
17217914d74bSmrg	continue
17227914d74bSmrg	;;
17237914d74bSmrg
17247914d74bSmrg      -thread-safe)
17257914d74bSmrg	thread_safe=yes
17267914d74bSmrg	continue
17277914d74bSmrg	;;
17287914d74bSmrg
17297914d74bSmrg      -version-info)
17307914d74bSmrg	prev=vinfo
17317914d74bSmrg	continue
17327914d74bSmrg	;;
17337914d74bSmrg      -version-number)
17347914d74bSmrg	prev=vinfo
17357914d74bSmrg	vinfo_number=yes
17367914d74bSmrg	continue
17377914d74bSmrg	;;
17387914d74bSmrg
17397914d74bSmrg      -Wc,*)
17407914d74bSmrg	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'`
17417914d74bSmrg	arg=
17427914d74bSmrg	save_ifs="$IFS"; IFS=','
17437914d74bSmrg	for flag in $args; do
17447914d74bSmrg	  IFS="$save_ifs"
17457914d74bSmrg	  case $flag in
17467914d74bSmrg	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
17477914d74bSmrg	    flag="\"$flag\""
17487914d74bSmrg	    ;;
17497914d74bSmrg	  esac
17507914d74bSmrg	  arg="$arg $wl$flag"
17517914d74bSmrg	  compiler_flags="$compiler_flags $flag"
17527914d74bSmrg	done
17537914d74bSmrg	IFS="$save_ifs"
17547914d74bSmrg	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
17557914d74bSmrg	;;
17567914d74bSmrg
17577914d74bSmrg      -Wl,*)
17587914d74bSmrg	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'`
17597914d74bSmrg	arg=
17607914d74bSmrg	save_ifs="$IFS"; IFS=','
17617914d74bSmrg	for flag in $args; do
17627914d74bSmrg	  IFS="$save_ifs"
17637914d74bSmrg	  case $flag in
17647914d74bSmrg	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
17657914d74bSmrg	    flag="\"$flag\""
17667914d74bSmrg	    ;;
17677914d74bSmrg	  esac
17687914d74bSmrg	  arg="$arg $wl$flag"
17697914d74bSmrg	  compiler_flags="$compiler_flags $wl$flag"
17707914d74bSmrg	  linker_flags="$linker_flags $flag"
17717914d74bSmrg	done
17727914d74bSmrg	IFS="$save_ifs"
17737914d74bSmrg	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
17747914d74bSmrg	;;
17757914d74bSmrg
17767914d74bSmrg      -Xcompiler)
17777914d74bSmrg	prev=xcompiler
17787914d74bSmrg	continue
17797914d74bSmrg	;;
17807914d74bSmrg
17817914d74bSmrg      -Xlinker)
17827914d74bSmrg	prev=xlinker
17837914d74bSmrg	continue
17847914d74bSmrg	;;
17857914d74bSmrg
17867914d74bSmrg      -XCClinker)
17877914d74bSmrg	prev=xcclinker
17887914d74bSmrg	continue
17897914d74bSmrg	;;
17907914d74bSmrg
17917914d74bSmrg      # Some other compiler flag.
17927914d74bSmrg      -* | +*)
17937914d74bSmrg	# Unknown arguments in both finalize_command and compile_command need
17947914d74bSmrg	# to be aesthetically quoted because they are evaled later.
17957914d74bSmrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
17967914d74bSmrg	case $arg in
17977914d74bSmrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
17987914d74bSmrg	  arg="\"$arg\""
17997914d74bSmrg	  ;;
18007914d74bSmrg	esac
18017914d74bSmrg	;;
18027914d74bSmrg
18037914d74bSmrg      *.$objext)
18047914d74bSmrg	# A standard object.
18057914d74bSmrg	objs="$objs $arg"
18067914d74bSmrg	;;
18077914d74bSmrg
18087914d74bSmrg      *.lo)
18097914d74bSmrg	# A libtool-controlled object.
18107914d74bSmrg
18117914d74bSmrg	# Check to see that this really is a libtool object.
18127914d74bSmrg	if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
18137914d74bSmrg	  pic_object=
18147914d74bSmrg	  non_pic_object=
18157914d74bSmrg
18167914d74bSmrg	  # Read the .lo file
18177914d74bSmrg	  # If there is no directory component, then add one.
18187914d74bSmrg	  case $arg in
18197914d74bSmrg	  */* | *\\*) . $arg ;;
18207914d74bSmrg	  *) . ./$arg ;;
18217914d74bSmrg	  esac
18227914d74bSmrg
18237914d74bSmrg	  if test -z "$pic_object" || \
18247914d74bSmrg	     test -z "$non_pic_object" ||
18257914d74bSmrg	     test "$pic_object" = none && \
18267914d74bSmrg	     test "$non_pic_object" = none; then
18277914d74bSmrg	    $echo "$modename: cannot find name of object for \`$arg'" 1>&2
18287914d74bSmrg	    exit $EXIT_FAILURE
18297914d74bSmrg	  fi
18307914d74bSmrg
18317914d74bSmrg	  # Extract subdirectory from the argument.
18327914d74bSmrg	  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
18337914d74bSmrg	  if test "X$xdir" = "X$arg"; then
18347914d74bSmrg	    xdir=
18357914d74bSmrg 	  else
18367914d74bSmrg	    xdir="$xdir/"
18377914d74bSmrg	  fi
18387914d74bSmrg
18397914d74bSmrg	  if test "$pic_object" != none; then
18407914d74bSmrg	    # Prepend the subdirectory the object is found in.
18417914d74bSmrg	    pic_object="$xdir$pic_object"
18427914d74bSmrg
18437914d74bSmrg	    if test "$prev" = dlfiles; then
18447914d74bSmrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
18457914d74bSmrg		dlfiles="$dlfiles $pic_object"
18467914d74bSmrg		prev=
18477914d74bSmrg		continue
18487914d74bSmrg	      else
18497914d74bSmrg		# If libtool objects are unsupported, then we need to preload.
18507914d74bSmrg		prev=dlprefiles
18517914d74bSmrg	      fi
18527914d74bSmrg	    fi
18537914d74bSmrg
18547914d74bSmrg	    # CHECK ME:  I think I busted this.  -Ossama
18557914d74bSmrg	    if test "$prev" = dlprefiles; then
18567914d74bSmrg	      # Preload the old-style object.
18577914d74bSmrg	      dlprefiles="$dlprefiles $pic_object"
18587914d74bSmrg	      prev=
18597914d74bSmrg	    fi
18607914d74bSmrg
18617914d74bSmrg	    # A PIC object.
18627914d74bSmrg	    libobjs="$libobjs $pic_object"
18637914d74bSmrg	    arg="$pic_object"
18647914d74bSmrg	  fi
18657914d74bSmrg
18667914d74bSmrg	  # Non-PIC object.
18677914d74bSmrg	  if test "$non_pic_object" != none; then
18687914d74bSmrg	    # Prepend the subdirectory the object is found in.
18697914d74bSmrg	    non_pic_object="$xdir$non_pic_object"
18707914d74bSmrg
18717914d74bSmrg	    # A standard non-PIC object
18727914d74bSmrg	    non_pic_objects="$non_pic_objects $non_pic_object"
18737914d74bSmrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
18747914d74bSmrg	      arg="$non_pic_object"
18757914d74bSmrg	    fi
18767914d74bSmrg	  else
18777914d74bSmrg	    # If the PIC object exists, use it instead.
18787914d74bSmrg	    # $xdir was prepended to $pic_object above.
18797914d74bSmrg	    non_pic_object="$pic_object"
18807914d74bSmrg	    non_pic_objects="$non_pic_objects $non_pic_object"
18817914d74bSmrg	  fi
18827914d74bSmrg	else
18837914d74bSmrg	  # Only an error if not doing a dry-run.
18847914d74bSmrg	  if test -z "$run"; then
18857914d74bSmrg	    $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
18867914d74bSmrg	    exit $EXIT_FAILURE
18877914d74bSmrg	  else
18887914d74bSmrg	    # Dry-run case.
18897914d74bSmrg
18907914d74bSmrg	    # Extract subdirectory from the argument.
18917914d74bSmrg	    xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
18927914d74bSmrg	    if test "X$xdir" = "X$arg"; then
18937914d74bSmrg	      xdir=
18947914d74bSmrg	    else
18957914d74bSmrg	      xdir="$xdir/"
18967914d74bSmrg	    fi
18977914d74bSmrg
18987914d74bSmrg	    pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
18997914d74bSmrg	    non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
19007914d74bSmrg	    libobjs="$libobjs $pic_object"
19017914d74bSmrg	    non_pic_objects="$non_pic_objects $non_pic_object"
19027914d74bSmrg	  fi
19037914d74bSmrg	fi
19047914d74bSmrg	;;
19057914d74bSmrg
19067914d74bSmrg      *.$libext)
19077914d74bSmrg	# An archive.
19087914d74bSmrg	deplibs="$deplibs $arg"
19097914d74bSmrg	old_deplibs="$old_deplibs $arg"
19107914d74bSmrg	continue
19117914d74bSmrg	;;
19127914d74bSmrg
19137914d74bSmrg      *.la)
19147914d74bSmrg	# A libtool-controlled library.
19157914d74bSmrg
19167914d74bSmrg	if test "$prev" = dlfiles; then
19177914d74bSmrg	  # This library was specified with -dlopen.
19187914d74bSmrg	  dlfiles="$dlfiles $arg"
19197914d74bSmrg	  prev=
19207914d74bSmrg	elif test "$prev" = dlprefiles; then
19217914d74bSmrg	  # The library was specified with -dlpreopen.
19227914d74bSmrg	  dlprefiles="$dlprefiles $arg"
19237914d74bSmrg	  prev=
19247914d74bSmrg	else
19257914d74bSmrg	  deplibs="$deplibs $arg"
19267914d74bSmrg	fi
19277914d74bSmrg	continue
19287914d74bSmrg	;;
19297914d74bSmrg
19307914d74bSmrg      # Some other compiler argument.
19317914d74bSmrg      *)
19327914d74bSmrg	# Unknown arguments in both finalize_command and compile_command need
19337914d74bSmrg	# to be aesthetically quoted because they are evaled later.
19347914d74bSmrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
19357914d74bSmrg	case $arg in
19367914d74bSmrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
19377914d74bSmrg	  arg="\"$arg\""
19387914d74bSmrg	  ;;
19397914d74bSmrg	esac
19407914d74bSmrg	;;
19417914d74bSmrg      esac # arg
19427914d74bSmrg
19437914d74bSmrg      # Now actually substitute the argument into the commands.
19447914d74bSmrg      if test -n "$arg"; then
19457914d74bSmrg	compile_command="$compile_command $arg"
19467914d74bSmrg	finalize_command="$finalize_command $arg"
19477914d74bSmrg      fi
19487914d74bSmrg    done # argument parsing loop
19497914d74bSmrg
19507914d74bSmrg    if test -n "$prev"; then
19517914d74bSmrg      $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
19527914d74bSmrg      $echo "$help" 1>&2
19537914d74bSmrg      exit $EXIT_FAILURE
19547914d74bSmrg    fi
19557914d74bSmrg
19567914d74bSmrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
19577914d74bSmrg      eval arg=\"$export_dynamic_flag_spec\"
19587914d74bSmrg      compile_command="$compile_command $arg"
19597914d74bSmrg      finalize_command="$finalize_command $arg"
19607914d74bSmrg    fi
19617914d74bSmrg
19627914d74bSmrg    oldlibs=
19637914d74bSmrg    # calculate the name of the file, without its directory
19647914d74bSmrg    outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
19657914d74bSmrg    libobjs_save="$libobjs"
19667914d74bSmrg
19677914d74bSmrg    if test -n "$shlibpath_var"; then
19687914d74bSmrg      # get the directories listed in $shlibpath_var
19697914d74bSmrg      eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
19707914d74bSmrg    else
19717914d74bSmrg      shlib_search_path=
19727914d74bSmrg    fi
19737914d74bSmrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
19747914d74bSmrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
19757914d74bSmrg
19767914d74bSmrg    output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
19777914d74bSmrg    if test "X$output_objdir" = "X$output"; then
19787914d74bSmrg      output_objdir="$objdir"
19797914d74bSmrg    else
19807914d74bSmrg      output_objdir="$output_objdir/$objdir"
19817914d74bSmrg    fi
19827914d74bSmrg    # Create the object directory.
19837914d74bSmrg    if test ! -d "$output_objdir"; then
19847914d74bSmrg      $show "$mkdir $output_objdir"
19857914d74bSmrg      $run $mkdir $output_objdir
19867914d74bSmrg      exit_status=$?
19877914d74bSmrg      if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then
19887914d74bSmrg	exit $exit_status
19897914d74bSmrg      fi
19907914d74bSmrg    fi
19917914d74bSmrg
19927914d74bSmrg    # Determine the type of output
19937914d74bSmrg    case $output in
19947914d74bSmrg    "")
19957914d74bSmrg      $echo "$modename: you must specify an output file" 1>&2
19967914d74bSmrg      $echo "$help" 1>&2
19977914d74bSmrg      exit $EXIT_FAILURE
19987914d74bSmrg      ;;
19997914d74bSmrg    *.$libext) linkmode=oldlib ;;
20007914d74bSmrg    *.lo | *.$objext) linkmode=obj ;;
20017914d74bSmrg    *.la) linkmode=lib ;;
20027914d74bSmrg    *) linkmode=prog ;; # Anything else should be a program.
20037914d74bSmrg    esac
20047914d74bSmrg
20057914d74bSmrg    case $host in
20067914d74bSmrg    *cygwin* | *mingw* | *pw32*)
20077914d74bSmrg      # don't eliminate duplications in $postdeps and $predeps
20087914d74bSmrg      duplicate_compiler_generated_deps=yes
20097914d74bSmrg      ;;
20107914d74bSmrg    *)
20117914d74bSmrg      duplicate_compiler_generated_deps=$duplicate_deps
20127914d74bSmrg      ;;
20137914d74bSmrg    esac
20147914d74bSmrg    specialdeplibs=
20157914d74bSmrg
20167914d74bSmrg    libs=
20177914d74bSmrg    # Find all interdependent deplibs by searching for libraries
20187914d74bSmrg    # that are linked more than once (e.g. -la -lb -la)
20197914d74bSmrg    for deplib in $deplibs; do
20207914d74bSmrg      if test "X$duplicate_deps" = "Xyes" ; then
20217914d74bSmrg	case "$libs " in
20227914d74bSmrg	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
20237914d74bSmrg	esac
20247914d74bSmrg      fi
20257914d74bSmrg      libs="$libs $deplib"
20267914d74bSmrg    done
20277914d74bSmrg
20287914d74bSmrg    if test "$linkmode" = lib; then
20297914d74bSmrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
20307914d74bSmrg
20317914d74bSmrg      # Compute libraries that are listed more than once in $predeps
20327914d74bSmrg      # $postdeps and mark them as special (i.e., whose duplicates are
20337914d74bSmrg      # not to be eliminated).
20347914d74bSmrg      pre_post_deps=
20357914d74bSmrg      if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then
20367914d74bSmrg	for pre_post_dep in $predeps $postdeps; do
20377914d74bSmrg	  case "$pre_post_deps " in
20387914d74bSmrg	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
20397914d74bSmrg	  esac
20407914d74bSmrg	  pre_post_deps="$pre_post_deps $pre_post_dep"
20417914d74bSmrg	done
20427914d74bSmrg      fi
20437914d74bSmrg      pre_post_deps=
20447914d74bSmrg    fi
20457914d74bSmrg
20467914d74bSmrg    deplibs=
20477914d74bSmrg    newdependency_libs=
20487914d74bSmrg    newlib_search_path=
20497914d74bSmrg    need_relink=no # whether we're linking any uninstalled libtool libraries
20507914d74bSmrg    notinst_deplibs= # not-installed libtool libraries
20517914d74bSmrg    case $linkmode in
20527914d74bSmrg    lib)
20537914d74bSmrg	passes="conv link"
20547914d74bSmrg	for file in $dlfiles $dlprefiles; do
20557914d74bSmrg	  case $file in
20567914d74bSmrg	  *.la) ;;
20577914d74bSmrg	  *)
20587914d74bSmrg	    $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2
20597914d74bSmrg	    exit $EXIT_FAILURE
20607914d74bSmrg	    ;;
20617914d74bSmrg	  esac
20627914d74bSmrg	done
20637914d74bSmrg	;;
20647914d74bSmrg    prog)
20657914d74bSmrg	compile_deplibs=
20667914d74bSmrg	finalize_deplibs=
20677914d74bSmrg	alldeplibs=no
20687914d74bSmrg	newdlfiles=
20697914d74bSmrg	newdlprefiles=
20707914d74bSmrg	passes="conv scan dlopen dlpreopen link"
20717914d74bSmrg	;;
20727914d74bSmrg    *)  passes="conv"
20737914d74bSmrg	;;
20747914d74bSmrg    esac
20757914d74bSmrg    for pass in $passes; do
20767914d74bSmrg      if test "$linkmode,$pass" = "lib,link" ||
20777914d74bSmrg	 test "$linkmode,$pass" = "prog,scan"; then
20787914d74bSmrg	libs="$deplibs"
20797914d74bSmrg	deplibs=
20807914d74bSmrg      fi
20817914d74bSmrg      if test "$linkmode" = prog; then
20827914d74bSmrg	case $pass in
20837914d74bSmrg	dlopen) libs="$dlfiles" ;;
20847914d74bSmrg	dlpreopen) libs="$dlprefiles" ;;
20857914d74bSmrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
20867914d74bSmrg	esac
20877914d74bSmrg      fi
20887914d74bSmrg      if test "$pass" = dlopen; then
20897914d74bSmrg	# Collect dlpreopened libraries
20907914d74bSmrg	save_deplibs="$deplibs"
20917914d74bSmrg	deplibs=
20927914d74bSmrg      fi
20937914d74bSmrg      for deplib in $libs; do
20947914d74bSmrg	lib=
20957914d74bSmrg	found=no
20967914d74bSmrg	case $deplib in
20977914d74bSmrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
20987914d74bSmrg	  if test "$linkmode,$pass" = "prog,link"; then
20997914d74bSmrg	    compile_deplibs="$deplib $compile_deplibs"
21007914d74bSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
21017914d74bSmrg	  else
21027914d74bSmrg	    compiler_flags="$compiler_flags $deplib"
21037914d74bSmrg	  fi
21047914d74bSmrg	  continue
21057914d74bSmrg	  ;;
21067914d74bSmrg	-l*)
21077914d74bSmrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
21087914d74bSmrg	    $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2
21097914d74bSmrg	    continue
21107914d74bSmrg	  fi
21117914d74bSmrg	  name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
21127914d74bSmrg	  for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do
21137914d74bSmrg	    for search_ext in .la $std_shrext .so .a; do
21147914d74bSmrg	      # Search the libtool library
21157914d74bSmrg	      lib="$searchdir/lib${name}${search_ext}"
21167914d74bSmrg	      if test -f "$lib"; then
21177914d74bSmrg		if test "$search_ext" = ".la"; then
21187914d74bSmrg		  found=yes
21197914d74bSmrg		else
21207914d74bSmrg		  found=no
21217914d74bSmrg		fi
21227914d74bSmrg		break 2
21237914d74bSmrg	      fi
21247914d74bSmrg	    done
21257914d74bSmrg	  done
21267914d74bSmrg	  if test "$found" != yes; then
21277914d74bSmrg	    # deplib doesn't seem to be a libtool library
21287914d74bSmrg	    if test "$linkmode,$pass" = "prog,link"; then
21297914d74bSmrg	      compile_deplibs="$deplib $compile_deplibs"
21307914d74bSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
21317914d74bSmrg	    else
21327914d74bSmrg	      deplibs="$deplib $deplibs"
21337914d74bSmrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
21347914d74bSmrg	    fi
21357914d74bSmrg	    continue
21367914d74bSmrg	  else # deplib is a libtool library
21377914d74bSmrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
21387914d74bSmrg	    # We need to do some special things here, and not later.
21397914d74bSmrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
21407914d74bSmrg	      case " $predeps $postdeps " in
21417914d74bSmrg	      *" $deplib "*)
21427914d74bSmrg		if (${SED} -e '2q' $lib |
21437914d74bSmrg                    grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
21447914d74bSmrg		  library_names=
21457914d74bSmrg		  old_library=
21467914d74bSmrg		  case $lib in
21477914d74bSmrg		  */* | *\\*) . $lib ;;
21487914d74bSmrg		  *) . ./$lib ;;
21497914d74bSmrg		  esac
21507914d74bSmrg		  for l in $old_library $library_names; do
21517914d74bSmrg		    ll="$l"
21527914d74bSmrg		  done
21537914d74bSmrg		  if test "X$ll" = "X$old_library" ; then # only static version available
21547914d74bSmrg		    found=no
21557914d74bSmrg		    ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
21567914d74bSmrg		    test "X$ladir" = "X$lib" && ladir="."
21577914d74bSmrg		    lib=$ladir/$old_library
21587914d74bSmrg		    if test "$linkmode,$pass" = "prog,link"; then
21597914d74bSmrg		      compile_deplibs="$deplib $compile_deplibs"
21607914d74bSmrg		      finalize_deplibs="$deplib $finalize_deplibs"
21617914d74bSmrg		    else
21627914d74bSmrg		      deplibs="$deplib $deplibs"
21637914d74bSmrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
21647914d74bSmrg		    fi
21657914d74bSmrg		    continue
21667914d74bSmrg		  fi
21677914d74bSmrg		fi
21687914d74bSmrg	        ;;
21697914d74bSmrg	      *) ;;
21707914d74bSmrg	      esac
21717914d74bSmrg	    fi
21727914d74bSmrg	  fi
21737914d74bSmrg	  ;; # -l
21747914d74bSmrg	-L*)
21757914d74bSmrg	  case $linkmode in
21767914d74bSmrg	  lib)
21777914d74bSmrg	    deplibs="$deplib $deplibs"
21787914d74bSmrg	    test "$pass" = conv && continue
21797914d74bSmrg	    newdependency_libs="$deplib $newdependency_libs"
21807914d74bSmrg	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
21817914d74bSmrg	    ;;
21827914d74bSmrg	  prog)
21837914d74bSmrg	    if test "$pass" = conv; then
21847914d74bSmrg	      deplibs="$deplib $deplibs"
21857914d74bSmrg	      continue
21867914d74bSmrg	    fi
21877914d74bSmrg	    if test "$pass" = scan; then
21887914d74bSmrg	      deplibs="$deplib $deplibs"
21897914d74bSmrg	    else
21907914d74bSmrg	      compile_deplibs="$deplib $compile_deplibs"
21917914d74bSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
21927914d74bSmrg	    fi
21937914d74bSmrg	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
21947914d74bSmrg	    ;;
21957914d74bSmrg	  *)
21967914d74bSmrg	    $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2
21977914d74bSmrg	    ;;
21987914d74bSmrg	  esac # linkmode
21997914d74bSmrg	  continue
22007914d74bSmrg	  ;; # -L
22017914d74bSmrg	-R*)
22027914d74bSmrg	  if test "$pass" = link; then
22037914d74bSmrg	    dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
22047914d74bSmrg	    # Make sure the xrpath contains only unique directories.
22057914d74bSmrg	    case "$xrpath " in
22067914d74bSmrg	    *" $dir "*) ;;
22077914d74bSmrg	    *) xrpath="$xrpath $dir" ;;
22087914d74bSmrg	    esac
22097914d74bSmrg	  fi
22107914d74bSmrg	  deplibs="$deplib $deplibs"
22117914d74bSmrg	  continue
22127914d74bSmrg	  ;;
22137914d74bSmrg	*.la) lib="$deplib" ;;
22147914d74bSmrg	*.$libext)
22157914d74bSmrg	  if test "$pass" = conv; then
22167914d74bSmrg	    deplibs="$deplib $deplibs"
22177914d74bSmrg	    continue
22187914d74bSmrg	  fi
22197914d74bSmrg	  case $linkmode in
22207914d74bSmrg	  lib)
22217914d74bSmrg	    valid_a_lib=no
22227914d74bSmrg	    case $deplibs_check_method in
22237914d74bSmrg	      match_pattern*)
22247914d74bSmrg		set dummy $deplibs_check_method
22257914d74bSmrg	        match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
22267914d74bSmrg		if eval $echo \"$deplib\" 2>/dev/null \
22277914d74bSmrg		    | $SED 10q \
22287914d74bSmrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
22297914d74bSmrg		  valid_a_lib=yes
22307914d74bSmrg		fi
22317914d74bSmrg		;;
22327914d74bSmrg	      pass_all)
22337914d74bSmrg		valid_a_lib=yes
22347914d74bSmrg		;;
22357914d74bSmrg            esac
22367914d74bSmrg	    if test "$valid_a_lib" != yes; then
22377914d74bSmrg	      $echo
22387914d74bSmrg	      $echo "*** Warning: Trying to link with static lib archive $deplib."
22397914d74bSmrg	      $echo "*** I have the capability to make that library automatically link in when"
22407914d74bSmrg	      $echo "*** you link to this library.  But I can only do this if you have a"
22417914d74bSmrg	      $echo "*** shared version of the library, which you do not appear to have"
22427914d74bSmrg	      $echo "*** because the file extensions .$libext of this argument makes me believe"
22437914d74bSmrg	      $echo "*** that it is just a static archive that I should not used here."
22447914d74bSmrg	    else
22457914d74bSmrg	      $echo
22467914d74bSmrg	      $echo "*** Warning: Linking the shared library $output against the"
22477914d74bSmrg	      $echo "*** static library $deplib is not portable!"
22487914d74bSmrg	      deplibs="$deplib $deplibs"
22497914d74bSmrg	    fi
22507914d74bSmrg	    continue
22517914d74bSmrg	    ;;
22527914d74bSmrg	  prog)
22537914d74bSmrg	    if test "$pass" != link; then
22547914d74bSmrg	      deplibs="$deplib $deplibs"
22557914d74bSmrg	    else
22567914d74bSmrg	      compile_deplibs="$deplib $compile_deplibs"
22577914d74bSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
22587914d74bSmrg	    fi
22597914d74bSmrg	    continue
22607914d74bSmrg	    ;;
22617914d74bSmrg	  esac # linkmode
22627914d74bSmrg	  ;; # *.$libext
22637914d74bSmrg	*.lo | *.$objext)
22647914d74bSmrg	  if test "$pass" = conv; then
22657914d74bSmrg	    deplibs="$deplib $deplibs"
22667914d74bSmrg	  elif test "$linkmode" = prog; then
22677914d74bSmrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
22687914d74bSmrg	      # If there is no dlopen support or we're linking statically,
22697914d74bSmrg	      # we need to preload.
22707914d74bSmrg	      newdlprefiles="$newdlprefiles $deplib"
22717914d74bSmrg	      compile_deplibs="$deplib $compile_deplibs"
22727914d74bSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
22737914d74bSmrg	    else
22747914d74bSmrg	      newdlfiles="$newdlfiles $deplib"
22757914d74bSmrg	    fi
22767914d74bSmrg	  fi
22777914d74bSmrg	  continue
22787914d74bSmrg	  ;;
22797914d74bSmrg	%DEPLIBS%)
22807914d74bSmrg	  alldeplibs=yes
22817914d74bSmrg	  continue
22827914d74bSmrg	  ;;
22837914d74bSmrg	esac # case $deplib
22847914d74bSmrg	if test "$found" = yes || test -f "$lib"; then :
22857914d74bSmrg	else
22867914d74bSmrg	  $echo "$modename: cannot find the library \`$lib' or unhandled argument \`$deplib'" 1>&2
22877914d74bSmrg	  exit $EXIT_FAILURE
22887914d74bSmrg	fi
22897914d74bSmrg
22907914d74bSmrg	# Check to see that this really is a libtool archive.
22917914d74bSmrg	if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
22927914d74bSmrg	else
22937914d74bSmrg	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
22947914d74bSmrg	  exit $EXIT_FAILURE
22957914d74bSmrg	fi
22967914d74bSmrg
22977914d74bSmrg	ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
22987914d74bSmrg	test "X$ladir" = "X$lib" && ladir="."
22997914d74bSmrg
23007914d74bSmrg	dlname=
23017914d74bSmrg	dlopen=
23027914d74bSmrg	dlpreopen=
23037914d74bSmrg	libdir=
23047914d74bSmrg	library_names=
23057914d74bSmrg	old_library=
23067914d74bSmrg	# If the library was installed with an old release of libtool,
23077914d74bSmrg	# it will not redefine variables installed, or shouldnotlink
23087914d74bSmrg	installed=yes
23097914d74bSmrg	shouldnotlink=no
23107914d74bSmrg	avoidtemprpath=
23117914d74bSmrg
23127914d74bSmrg
23137914d74bSmrg	# Read the .la file
23147914d74bSmrg	case $lib in
23157914d74bSmrg	*/* | *\\*) . $lib ;;
23167914d74bSmrg	*) . ./$lib ;;
23177914d74bSmrg	esac
23187914d74bSmrg
23197914d74bSmrg	if test "$linkmode,$pass" = "lib,link" ||
23207914d74bSmrg	   test "$linkmode,$pass" = "prog,scan" ||
23217914d74bSmrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
23227914d74bSmrg	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
23237914d74bSmrg	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
23247914d74bSmrg	fi
23257914d74bSmrg
23267914d74bSmrg	if test "$pass" = conv; then
23277914d74bSmrg	  # Only check for convenience libraries
23287914d74bSmrg	  deplibs="$lib $deplibs"
23297914d74bSmrg	  if test -z "$libdir"; then
23307914d74bSmrg	    if test -z "$old_library"; then
23317914d74bSmrg	      $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
23327914d74bSmrg	      exit $EXIT_FAILURE
23337914d74bSmrg	    fi
23347914d74bSmrg	    # It is a libtool convenience library, so add in its objects.
23357914d74bSmrg	    convenience="$convenience $ladir/$objdir/$old_library"
23367914d74bSmrg	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
23377914d74bSmrg	    tmp_libs=
23387914d74bSmrg	    for deplib in $dependency_libs; do
23397914d74bSmrg	      deplibs="$deplib $deplibs"
23407914d74bSmrg              if test "X$duplicate_deps" = "Xyes" ; then
23417914d74bSmrg	        case "$tmp_libs " in
23427914d74bSmrg	        *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
23437914d74bSmrg	        esac
23447914d74bSmrg              fi
23457914d74bSmrg	      tmp_libs="$tmp_libs $deplib"
23467914d74bSmrg	    done
23477914d74bSmrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
23487914d74bSmrg	    $echo "$modename: \`$lib' is not a convenience library" 1>&2
23497914d74bSmrg	    exit $EXIT_FAILURE
23507914d74bSmrg	  fi
23517914d74bSmrg	  continue
23527914d74bSmrg	fi # $pass = conv
23537914d74bSmrg
23547914d74bSmrg
23557914d74bSmrg	# Get the name of the library we link against.
23567914d74bSmrg	linklib=
23577914d74bSmrg	for l in $old_library $library_names; do
23587914d74bSmrg	  linklib="$l"
23597914d74bSmrg	done
23607914d74bSmrg	if test -z "$linklib"; then
23617914d74bSmrg	  $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
23627914d74bSmrg	  exit $EXIT_FAILURE
23637914d74bSmrg	fi
23647914d74bSmrg
23657914d74bSmrg	# This library was specified with -dlopen.
23667914d74bSmrg	if test "$pass" = dlopen; then
23677914d74bSmrg	  if test -z "$libdir"; then
23687914d74bSmrg	    $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2
23697914d74bSmrg	    exit $EXIT_FAILURE
23707914d74bSmrg	  fi
23717914d74bSmrg	  if test -z "$dlname" ||
23727914d74bSmrg	     test "$dlopen_support" != yes ||
23737914d74bSmrg	     test "$build_libtool_libs" = no; then
23747914d74bSmrg	    # If there is no dlname, no dlopen support or we're linking
23757914d74bSmrg	    # statically, we need to preload.  We also need to preload any
23767914d74bSmrg	    # dependent libraries so libltdl's deplib preloader doesn't
23777914d74bSmrg	    # bomb out in the load deplibs phase.
23787914d74bSmrg	    dlprefiles="$dlprefiles $lib $dependency_libs"
23797914d74bSmrg	  else
23807914d74bSmrg	    newdlfiles="$newdlfiles $lib"
23817914d74bSmrg	  fi
23827914d74bSmrg	  continue
23837914d74bSmrg	fi # $pass = dlopen
23847914d74bSmrg
23857914d74bSmrg	# We need an absolute path.
23867914d74bSmrg	case $ladir in
23877914d74bSmrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
23887914d74bSmrg	*)
23897914d74bSmrg	  abs_ladir=`cd "$ladir" && pwd`
23907914d74bSmrg	  if test -z "$abs_ladir"; then
23917914d74bSmrg	    $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2
23927914d74bSmrg	    $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
23937914d74bSmrg	    abs_ladir="$ladir"
23947914d74bSmrg	  fi
23957914d74bSmrg	  ;;
23967914d74bSmrg	esac
23977914d74bSmrg	laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
23987914d74bSmrg
23997914d74bSmrg	# Find the relevant object directory and library name.
24007914d74bSmrg	if test "X$installed" = Xyes; then
24017914d74bSmrg	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
24027914d74bSmrg	    $echo "$modename: warning: library \`$lib' was moved." 1>&2
24037914d74bSmrg	    dir="$ladir"
24047914d74bSmrg	    absdir="$abs_ladir"
24057914d74bSmrg	    libdir="$abs_ladir"
24067914d74bSmrg	  else
24077914d74bSmrg	    dir="$libdir"
24087914d74bSmrg	    absdir="$libdir"
24097914d74bSmrg	  fi
24107914d74bSmrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
24117914d74bSmrg	else
24127914d74bSmrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
24137914d74bSmrg	    dir="$ladir"
24147914d74bSmrg	    absdir="$abs_ladir"
24157914d74bSmrg	    # Remove this search path later
24167914d74bSmrg	    notinst_path="$notinst_path $abs_ladir"
24177914d74bSmrg	  else
24187914d74bSmrg	    dir="$ladir/$objdir"
24197914d74bSmrg	    absdir="$abs_ladir/$objdir"
24207914d74bSmrg	    # Remove this search path later
24217914d74bSmrg	    notinst_path="$notinst_path $abs_ladir"
24227914d74bSmrg	  fi
24237914d74bSmrg	fi # $installed = yes
24247914d74bSmrg	name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
24257914d74bSmrg
24267914d74bSmrg	# This library was specified with -dlpreopen.
24277914d74bSmrg	if test "$pass" = dlpreopen; then
24287914d74bSmrg	  if test -z "$libdir"; then
24297914d74bSmrg	    $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2
24307914d74bSmrg	    exit $EXIT_FAILURE
24317914d74bSmrg	  fi
24327914d74bSmrg	  # Prefer using a static library (so that no silly _DYNAMIC symbols
24337914d74bSmrg	  # are required to link).
24347914d74bSmrg	  if test -n "$old_library"; then
24357914d74bSmrg	    newdlprefiles="$newdlprefiles $dir/$old_library"
24367914d74bSmrg	  # Otherwise, use the dlname, so that lt_dlopen finds it.
24377914d74bSmrg	  elif test -n "$dlname"; then
24387914d74bSmrg	    newdlprefiles="$newdlprefiles $dir/$dlname"
24397914d74bSmrg	  else
24407914d74bSmrg	    newdlprefiles="$newdlprefiles $dir/$linklib"
24417914d74bSmrg	  fi
24427914d74bSmrg	fi # $pass = dlpreopen
24437914d74bSmrg
24447914d74bSmrg	if test -z "$libdir"; then
24457914d74bSmrg	  # Link the convenience library
24467914d74bSmrg	  if test "$linkmode" = lib; then
24477914d74bSmrg	    deplibs="$dir/$old_library $deplibs"
24487914d74bSmrg	  elif test "$linkmode,$pass" = "prog,link"; then
24497914d74bSmrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
24507914d74bSmrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
24517914d74bSmrg	  else
24527914d74bSmrg	    deplibs="$lib $deplibs" # used for prog,scan pass
24537914d74bSmrg	  fi
24547914d74bSmrg	  continue
24557914d74bSmrg	fi
24567914d74bSmrg
24577914d74bSmrg
24587914d74bSmrg	if test "$linkmode" = prog && test "$pass" != link; then
24597914d74bSmrg	  newlib_search_path="$newlib_search_path $ladir"
24607914d74bSmrg	  deplibs="$lib $deplibs"
24617914d74bSmrg
24627914d74bSmrg	  linkalldeplibs=no
24637914d74bSmrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
24647914d74bSmrg	     test "$build_libtool_libs" = no; then
24657914d74bSmrg	    linkalldeplibs=yes
24667914d74bSmrg	  fi
24677914d74bSmrg
24687914d74bSmrg	  tmp_libs=
24697914d74bSmrg	  for deplib in $dependency_libs; do
24707914d74bSmrg	    case $deplib in
24717914d74bSmrg	    -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test
24727914d74bSmrg	    esac
24737914d74bSmrg	    # Need to link against all dependency_libs?
24747914d74bSmrg	    if test "$linkalldeplibs" = yes; then
24757914d74bSmrg	      deplibs="$deplib $deplibs"
24767914d74bSmrg	    else
24777914d74bSmrg	      # Need to hardcode shared library paths
24787914d74bSmrg	      # or/and link against static libraries
24797914d74bSmrg	      newdependency_libs="$deplib $newdependency_libs"
24807914d74bSmrg	    fi
24817914d74bSmrg	    if test "X$duplicate_deps" = "Xyes" ; then
24827914d74bSmrg	      case "$tmp_libs " in
24837914d74bSmrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
24847914d74bSmrg	      esac
24857914d74bSmrg	    fi
24867914d74bSmrg	    tmp_libs="$tmp_libs $deplib"
24877914d74bSmrg	  done # for deplib
24887914d74bSmrg	  continue
24897914d74bSmrg	fi # $linkmode = prog...
24907914d74bSmrg
24917914d74bSmrg	if test "$linkmode,$pass" = "prog,link"; then
24927914d74bSmrg	  if test -n "$library_names" &&
24937914d74bSmrg	     { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
24947914d74bSmrg	    # We need to hardcode the library path
24957914d74bSmrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
24967914d74bSmrg	      # Make sure the rpath contains only unique directories.
24977914d74bSmrg	      case "$temp_rpath " in
24987914d74bSmrg	      *" $dir "*) ;;
24997914d74bSmrg	      *" $absdir "*) ;;
25007914d74bSmrg	      *) temp_rpath="$temp_rpath $absdir" ;;
25017914d74bSmrg	      esac
25027914d74bSmrg	    fi
25037914d74bSmrg
25047914d74bSmrg	    # Hardcode the library path.
25057914d74bSmrg	    # Skip directories that are in the system default run-time
25067914d74bSmrg	    # search path.
25077914d74bSmrg	    case " $sys_lib_dlsearch_path " in
25087914d74bSmrg	    *" $absdir "*) ;;
25097914d74bSmrg	    *)
25107914d74bSmrg	      case "$compile_rpath " in
25117914d74bSmrg	      *" $absdir "*) ;;
25127914d74bSmrg	      *) compile_rpath="$compile_rpath $absdir"
25137914d74bSmrg	      esac
25147914d74bSmrg	      ;;
25157914d74bSmrg	    esac
25167914d74bSmrg	    case " $sys_lib_dlsearch_path " in
25177914d74bSmrg	    *" $libdir "*) ;;
25187914d74bSmrg	    *)
25197914d74bSmrg	      case "$finalize_rpath " in
25207914d74bSmrg	      *" $libdir "*) ;;
25217914d74bSmrg	      *) finalize_rpath="$finalize_rpath $libdir"
25227914d74bSmrg	      esac
25237914d74bSmrg	      ;;
25247914d74bSmrg	    esac
25257914d74bSmrg	  fi # $linkmode,$pass = prog,link...
25267914d74bSmrg
25277914d74bSmrg	  if test "$alldeplibs" = yes &&
25287914d74bSmrg	     { test "$deplibs_check_method" = pass_all ||
25297914d74bSmrg	       { test "$build_libtool_libs" = yes &&
25307914d74bSmrg		 test -n "$library_names"; }; }; then
25317914d74bSmrg	    # We only need to search for static libraries
25327914d74bSmrg	    continue
25337914d74bSmrg	  fi
25347914d74bSmrg	fi
25357914d74bSmrg
25367914d74bSmrg	link_static=no # Whether the deplib will be linked statically
25377914d74bSmrg	use_static_libs=$prefer_static_libs
25387914d74bSmrg	if test "$use_static_libs" = built && test "$installed" = yes ; then
25397914d74bSmrg	  use_static_libs=no
25407914d74bSmrg	fi
25417914d74bSmrg	if test -n "$library_names" &&
25427914d74bSmrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
25437914d74bSmrg	  if test "$installed" = no; then
25447914d74bSmrg	    notinst_deplibs="$notinst_deplibs $lib"
25457914d74bSmrg	    need_relink=yes
25467914d74bSmrg	  fi
25477914d74bSmrg	  # This is a shared library
25487914d74bSmrg
25497914d74bSmrg	  # Warn about portability, can't link against -module's on
25507914d74bSmrg	  # some systems (darwin)
25517914d74bSmrg	  if test "$shouldnotlink" = yes && test "$pass" = link ; then
25527914d74bSmrg	    $echo
25537914d74bSmrg	    if test "$linkmode" = prog; then
25547914d74bSmrg	      $echo "*** Warning: Linking the executable $output against the loadable module"
25557914d74bSmrg	    else
25567914d74bSmrg	      $echo "*** Warning: Linking the shared library $output against the loadable module"
25577914d74bSmrg	    fi
25587914d74bSmrg	    $echo "*** $linklib is not portable!"
25597914d74bSmrg	  fi
25607914d74bSmrg	  if test "$linkmode" = lib &&
25617914d74bSmrg	     test "$hardcode_into_libs" = yes; then
25627914d74bSmrg	    # Hardcode the library path.
25637914d74bSmrg	    # Skip directories that are in the system default run-time
25647914d74bSmrg	    # search path.
25657914d74bSmrg	    case " $sys_lib_dlsearch_path " in
25667914d74bSmrg	    *" $absdir "*) ;;
25677914d74bSmrg	    *)
25687914d74bSmrg	      case "$compile_rpath " in
25697914d74bSmrg	      *" $absdir "*) ;;
25707914d74bSmrg	      *) compile_rpath="$compile_rpath $absdir"
25717914d74bSmrg	      esac
25727914d74bSmrg	      ;;
25737914d74bSmrg	    esac
25747914d74bSmrg	    case " $sys_lib_dlsearch_path " in
25757914d74bSmrg	    *" $libdir "*) ;;
25767914d74bSmrg	    *)
25777914d74bSmrg	      case "$finalize_rpath " in
25787914d74bSmrg	      *" $libdir "*) ;;
25797914d74bSmrg	      *) finalize_rpath="$finalize_rpath $libdir"
25807914d74bSmrg	      esac
25817914d74bSmrg	      ;;
25827914d74bSmrg	    esac
25837914d74bSmrg	  fi
25847914d74bSmrg
25857914d74bSmrg	  if test -n "$old_archive_from_expsyms_cmds"; then
25867914d74bSmrg	    # figure out the soname
25877914d74bSmrg	    set dummy $library_names
25887914d74bSmrg	    realname="$2"
25897914d74bSmrg	    shift; shift
25907914d74bSmrg	    libname=`eval \\$echo \"$libname_spec\"`
25917914d74bSmrg	    # use dlname if we got it. it's perfectly good, no?
25927914d74bSmrg	    if test -n "$dlname"; then
25937914d74bSmrg	      soname="$dlname"
25947914d74bSmrg	    elif test -n "$soname_spec"; then
25957914d74bSmrg	      # bleh windows
25967914d74bSmrg	      case $host in
25977914d74bSmrg	      *cygwin* | mingw*)
25987914d74bSmrg		major=`expr $current - $age`
25997914d74bSmrg		versuffix="-$major"
26007914d74bSmrg		;;
26017914d74bSmrg	      esac
26027914d74bSmrg	      eval soname=\"$soname_spec\"
26037914d74bSmrg	    else
26047914d74bSmrg	      soname="$realname"
26057914d74bSmrg	    fi
26067914d74bSmrg
26077914d74bSmrg	    # Make a new name for the extract_expsyms_cmds to use
26087914d74bSmrg	    soroot="$soname"
26097914d74bSmrg	    soname=`$echo $soroot | ${SED} -e 's/^.*\///'`
26107914d74bSmrg	    newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a"
26117914d74bSmrg
26127914d74bSmrg	    # If the library has no export list, then create one now
26137914d74bSmrg	    if test -f "$output_objdir/$soname-def"; then :
26147914d74bSmrg	    else
26157914d74bSmrg	      $show "extracting exported symbol list from \`$soname'"
26167914d74bSmrg	      save_ifs="$IFS"; IFS='~'
26177914d74bSmrg	      cmds=$extract_expsyms_cmds
26187914d74bSmrg	      for cmd in $cmds; do
26197914d74bSmrg		IFS="$save_ifs"
26207914d74bSmrg		eval cmd=\"$cmd\"
26217914d74bSmrg		$show "$cmd"
26227914d74bSmrg		$run eval "$cmd" || exit $?
26237914d74bSmrg	      done
26247914d74bSmrg	      IFS="$save_ifs"
26257914d74bSmrg	    fi
26267914d74bSmrg
26277914d74bSmrg	    # Create $newlib
26287914d74bSmrg	    if test -f "$output_objdir/$newlib"; then :; else
26297914d74bSmrg	      $show "generating import library for \`$soname'"
26307914d74bSmrg	      save_ifs="$IFS"; IFS='~'
26317914d74bSmrg	      cmds=$old_archive_from_expsyms_cmds
26327914d74bSmrg	      for cmd in $cmds; do
26337914d74bSmrg		IFS="$save_ifs"
26347914d74bSmrg		eval cmd=\"$cmd\"
26357914d74bSmrg		$show "$cmd"
26367914d74bSmrg		$run eval "$cmd" || exit $?
26377914d74bSmrg	      done
26387914d74bSmrg	      IFS="$save_ifs"
26397914d74bSmrg	    fi
26407914d74bSmrg	    # make sure the library variables are pointing to the new library
26417914d74bSmrg	    dir=$output_objdir
26427914d74bSmrg	    linklib=$newlib
26437914d74bSmrg	  fi # test -n "$old_archive_from_expsyms_cmds"
26447914d74bSmrg
26457914d74bSmrg	  if test "$linkmode" = prog || test "$mode" != relink; then
26467914d74bSmrg	    add_shlibpath=
26477914d74bSmrg	    add_dir=
26487914d74bSmrg	    add=
26497914d74bSmrg	    lib_linked=yes
26507914d74bSmrg	    case $hardcode_action in
26517914d74bSmrg	    immediate | unsupported)
26527914d74bSmrg	      if test "$hardcode_direct" = no; then
26537914d74bSmrg		add="$dir/$linklib"
26547914d74bSmrg		case $host in
26557914d74bSmrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
26567914d74bSmrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
26577914d74bSmrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
26587914d74bSmrg		    *-*-unixware7*) add_dir="-L$dir" ;;
26597914d74bSmrg		  *-*-darwin* )
26607914d74bSmrg		    # if the lib is a module then we can not link against
26617914d74bSmrg		    # it, someone is ignoring the new warnings I added
26627914d74bSmrg		    if /usr/bin/file -L $add 2> /dev/null |
26637914d74bSmrg                      $EGREP ": [^:]* bundle" >/dev/null ; then
26647914d74bSmrg		      $echo "** Warning, lib $linklib is a module, not a shared library"
26657914d74bSmrg		      if test -z "$old_library" ; then
26667914d74bSmrg		        $echo
26677914d74bSmrg		        $echo "** And there doesn't seem to be a static archive available"
26687914d74bSmrg		        $echo "** The link will probably fail, sorry"
26697914d74bSmrg		      else
26707914d74bSmrg		        add="$dir/$old_library"
26717914d74bSmrg		      fi
26727914d74bSmrg		    fi
26737914d74bSmrg		esac
26747914d74bSmrg	      elif test "$hardcode_minus_L" = no; then
26757914d74bSmrg		case $host in
26767914d74bSmrg		*-*-sunos*) add_shlibpath="$dir" ;;
26777914d74bSmrg		esac
26787914d74bSmrg		add_dir="-L$dir"
26797914d74bSmrg		add="-l$name"
26807914d74bSmrg	      elif test "$hardcode_shlibpath_var" = no; then
26817914d74bSmrg		add_shlibpath="$dir"
26827914d74bSmrg		add="-l$name"
26837914d74bSmrg	      else
26847914d74bSmrg		lib_linked=no
26857914d74bSmrg	      fi
26867914d74bSmrg	      ;;
26877914d74bSmrg	    relink)
26887914d74bSmrg	      if test "$hardcode_direct" = yes; then
26897914d74bSmrg		add="$dir/$linklib"
26907914d74bSmrg	      elif test "$hardcode_minus_L" = yes; then
26917914d74bSmrg		add_dir="-L$dir"
26927914d74bSmrg		# Try looking first in the location we're being installed to.
26937914d74bSmrg		if test -n "$inst_prefix_dir"; then
26947914d74bSmrg		  case $libdir in
26957914d74bSmrg		    [\\/]*)
26967914d74bSmrg		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
26977914d74bSmrg		      ;;
26987914d74bSmrg		  esac
26997914d74bSmrg		fi
27007914d74bSmrg		add="-l$name"
27017914d74bSmrg	      elif test "$hardcode_shlibpath_var" = yes; then
27027914d74bSmrg		add_shlibpath="$dir"
27037914d74bSmrg		add="-l$name"
27047914d74bSmrg	      else
27057914d74bSmrg		lib_linked=no
27067914d74bSmrg	      fi
27077914d74bSmrg	      ;;
27087914d74bSmrg	    *) lib_linked=no ;;
27097914d74bSmrg	    esac
27107914d74bSmrg
27117914d74bSmrg	    if test "$lib_linked" != yes; then
27127914d74bSmrg	      $echo "$modename: configuration error: unsupported hardcode properties"
27137914d74bSmrg	      exit $EXIT_FAILURE
27147914d74bSmrg	    fi
27157914d74bSmrg
27167914d74bSmrg	    if test -n "$add_shlibpath"; then
27177914d74bSmrg	      case :$compile_shlibpath: in
27187914d74bSmrg	      *":$add_shlibpath:"*) ;;
27197914d74bSmrg	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
27207914d74bSmrg	      esac
27217914d74bSmrg	    fi
27227914d74bSmrg	    if test "$linkmode" = prog; then
27237914d74bSmrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
27247914d74bSmrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
27257914d74bSmrg	    else
27267914d74bSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
27277914d74bSmrg	      test -n "$add" && deplibs="$add $deplibs"
27287914d74bSmrg	      if test "$hardcode_direct" != yes && \
27297914d74bSmrg		 test "$hardcode_minus_L" != yes && \
27307914d74bSmrg		 test "$hardcode_shlibpath_var" = yes; then
27317914d74bSmrg		case :$finalize_shlibpath: in
27327914d74bSmrg		*":$libdir:"*) ;;
27337914d74bSmrg		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
27347914d74bSmrg		esac
27357914d74bSmrg	      fi
27367914d74bSmrg	    fi
27377914d74bSmrg	  fi
27387914d74bSmrg
27397914d74bSmrg	  if test "$linkmode" = prog || test "$mode" = relink; then
27407914d74bSmrg	    add_shlibpath=
27417914d74bSmrg	    add_dir=
27427914d74bSmrg	    add=
27437914d74bSmrg	    # Finalize command for both is simple: just hardcode it.
27447914d74bSmrg	    if test "$hardcode_direct" = yes; then
27457914d74bSmrg	      add="$libdir/$linklib"
27467914d74bSmrg	    elif test "$hardcode_minus_L" = yes; then
27477914d74bSmrg	      add_dir="-L$libdir"
27487914d74bSmrg	      add="-l$name"
27497914d74bSmrg	    elif test "$hardcode_shlibpath_var" = yes; then
27507914d74bSmrg	      case :$finalize_shlibpath: in
27517914d74bSmrg	      *":$libdir:"*) ;;
27527914d74bSmrg	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
27537914d74bSmrg	      esac
27547914d74bSmrg	      add="-l$name"
27557914d74bSmrg	    elif test "$hardcode_automatic" = yes; then
27567914d74bSmrg	      if test -n "$inst_prefix_dir" &&
27577914d74bSmrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
27587914d74bSmrg	        add="$inst_prefix_dir$libdir/$linklib"
27597914d74bSmrg	      else
27607914d74bSmrg	        add="$libdir/$linklib"
27617914d74bSmrg	      fi
27627914d74bSmrg	    else
27637914d74bSmrg	      # We cannot seem to hardcode it, guess we'll fake it.
27647914d74bSmrg	      add_dir="-L$libdir"
27657914d74bSmrg	      # Try looking first in the location we're being installed to.
27667914d74bSmrg	      if test -n "$inst_prefix_dir"; then
27677914d74bSmrg		case $libdir in
27687914d74bSmrg		  [\\/]*)
27697914d74bSmrg		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
27707914d74bSmrg		    ;;
27717914d74bSmrg		esac
27727914d74bSmrg	      fi
27737914d74bSmrg	      add="-l$name"
27747914d74bSmrg	    fi
27757914d74bSmrg
27767914d74bSmrg	    if test "$linkmode" = prog; then
27777914d74bSmrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
27787914d74bSmrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
27797914d74bSmrg	    else
27807914d74bSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
27817914d74bSmrg	      test -n "$add" && deplibs="$add $deplibs"
27827914d74bSmrg	    fi
27837914d74bSmrg	  fi
27847914d74bSmrg	elif test "$linkmode" = prog; then
27857914d74bSmrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
27867914d74bSmrg	  # is not unsupported.  This is valid on all known static and
27877914d74bSmrg	  # shared platforms.
27887914d74bSmrg	  if test "$hardcode_direct" != unsupported; then
27897914d74bSmrg	    test -n "$old_library" && linklib="$old_library"
27907914d74bSmrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
27917914d74bSmrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
27927914d74bSmrg	  else
27937914d74bSmrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
27947914d74bSmrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
27957914d74bSmrg	  fi
27967914d74bSmrg	elif test "$build_libtool_libs" = yes; then
27977914d74bSmrg	  # Not a shared library
27987914d74bSmrg	  if test "$deplibs_check_method" != pass_all; then
27997914d74bSmrg	    # We're trying link a shared library against a static one
28007914d74bSmrg	    # but the system doesn't support it.
28017914d74bSmrg
28027914d74bSmrg	    # Just print a warning and add the library to dependency_libs so
28037914d74bSmrg	    # that the program can be linked against the static library.
28047914d74bSmrg	    $echo
28057914d74bSmrg	    $echo "*** Warning: This system can not link to static lib archive $lib."
28067914d74bSmrg	    $echo "*** I have the capability to make that library automatically link in when"
28077914d74bSmrg	    $echo "*** you link to this library.  But I can only do this if you have a"
28087914d74bSmrg	    $echo "*** shared version of the library, which you do not appear to have."
28097914d74bSmrg	    if test "$module" = yes; then
28107914d74bSmrg	      $echo "*** But as you try to build a module library, libtool will still create "
28117914d74bSmrg	      $echo "*** a static module, that should work as long as the dlopening application"
28127914d74bSmrg	      $echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
28137914d74bSmrg	      if test -z "$global_symbol_pipe"; then
28147914d74bSmrg		$echo
28157914d74bSmrg		$echo "*** However, this would only work if libtool was able to extract symbol"
28167914d74bSmrg		$echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
28177914d74bSmrg		$echo "*** not find such a program.  So, this module is probably useless."
28187914d74bSmrg		$echo "*** \`nm' from GNU binutils and a full rebuild may help."
28197914d74bSmrg	      fi
28207914d74bSmrg	      if test "$build_old_libs" = no; then
28217914d74bSmrg		build_libtool_libs=module
28227914d74bSmrg		build_old_libs=yes
28237914d74bSmrg	      else
28247914d74bSmrg		build_libtool_libs=no
28257914d74bSmrg	      fi
28267914d74bSmrg	    fi
28277914d74bSmrg	  else
28287914d74bSmrg	    deplibs="$dir/$old_library $deplibs"
28297914d74bSmrg	    link_static=yes
28307914d74bSmrg	  fi
28317914d74bSmrg	fi # link shared/static library?
28327914d74bSmrg
28337914d74bSmrg	if test "$linkmode" = lib; then
28347914d74bSmrg	  if test -n "$dependency_libs" &&
28357914d74bSmrg	     { test "$hardcode_into_libs" != yes ||
28367914d74bSmrg	       test "$build_old_libs" = yes ||
28377914d74bSmrg	       test "$link_static" = yes; }; then
28387914d74bSmrg	    # Extract -R from dependency_libs
28397914d74bSmrg	    temp_deplibs=
28407914d74bSmrg	    for libdir in $dependency_libs; do
28417914d74bSmrg	      case $libdir in
28427914d74bSmrg	      -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'`
28437914d74bSmrg		   case " $xrpath " in
28447914d74bSmrg		   *" $temp_xrpath "*) ;;
28457914d74bSmrg		   *) xrpath="$xrpath $temp_xrpath";;
28467914d74bSmrg		   esac;;
28477914d74bSmrg	      *) temp_deplibs="$temp_deplibs $libdir";;
28487914d74bSmrg	      esac
28497914d74bSmrg	    done
28507914d74bSmrg	    dependency_libs="$temp_deplibs"
28517914d74bSmrg	  fi
28527914d74bSmrg
28537914d74bSmrg	  newlib_search_path="$newlib_search_path $absdir"
28547914d74bSmrg	  # Link against this library
28557914d74bSmrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
28567914d74bSmrg	  # ... and its dependency_libs
28577914d74bSmrg	  tmp_libs=
28587914d74bSmrg	  for deplib in $dependency_libs; do
28597914d74bSmrg	    newdependency_libs="$deplib $newdependency_libs"
28607914d74bSmrg	    if test "X$duplicate_deps" = "Xyes" ; then
28617914d74bSmrg	      case "$tmp_libs " in
28627914d74bSmrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
28637914d74bSmrg	      esac
28647914d74bSmrg	    fi
28657914d74bSmrg	    tmp_libs="$tmp_libs $deplib"
28667914d74bSmrg	  done
28677914d74bSmrg
28687914d74bSmrg	  if test "$link_all_deplibs" != no; then
28697914d74bSmrg	    # Add the search paths of all dependency libraries
28707914d74bSmrg	    for deplib in $dependency_libs; do
28717914d74bSmrg	      case $deplib in
28727914d74bSmrg	      -L*) path="$deplib" ;;
28737914d74bSmrg	      *.la)
28747914d74bSmrg		dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'`
28757914d74bSmrg		test "X$dir" = "X$deplib" && dir="."
28767914d74bSmrg		# We need an absolute path.
28777914d74bSmrg		case $dir in
28787914d74bSmrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
28797914d74bSmrg		*)
28807914d74bSmrg		  absdir=`cd "$dir" && pwd`
28817914d74bSmrg		  if test -z "$absdir"; then
28827914d74bSmrg		    $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
28837914d74bSmrg		    absdir="$dir"
28847914d74bSmrg		  fi
28857914d74bSmrg		  ;;
28867914d74bSmrg		esac
28877914d74bSmrg		if grep "^installed=no" $deplib > /dev/null; then
28887914d74bSmrg		  path="$absdir/$objdir"
28897914d74bSmrg		else
28907914d74bSmrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
28917914d74bSmrg		  if test -z "$libdir"; then
28927914d74bSmrg		    $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
28937914d74bSmrg		    exit $EXIT_FAILURE
28947914d74bSmrg		  fi
28957914d74bSmrg		  if test "$absdir" != "$libdir"; then
28967914d74bSmrg		    $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2
28977914d74bSmrg		  fi
28987914d74bSmrg		  path="$absdir"
28997914d74bSmrg		fi
29007914d74bSmrg		depdepl=
29017914d74bSmrg		case $host in
29027914d74bSmrg		*-*-darwin*)
29037914d74bSmrg		  # we do not want to link against static libs,
29047914d74bSmrg		  # but need to link against shared
29057914d74bSmrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
29067914d74bSmrg		  if test -n "$deplibrary_names" ; then
29077914d74bSmrg		    for tmp in $deplibrary_names ; do
29087914d74bSmrg		      depdepl=$tmp
29097914d74bSmrg		    done
29107914d74bSmrg		    if test -f "$path/$depdepl" ; then
29117914d74bSmrg		      depdepl="$path/$depdepl"
29127914d74bSmrg		    fi
29137914d74bSmrg		    # do not add paths which are already there
29147914d74bSmrg		    case " $newlib_search_path " in
29157914d74bSmrg		    *" $path "*) ;;
29167914d74bSmrg		    *) newlib_search_path="$newlib_search_path $path";;
29177914d74bSmrg		    esac
29187914d74bSmrg		  fi
29197914d74bSmrg		  path=""
29207914d74bSmrg		  ;;
29217914d74bSmrg		*)
29227914d74bSmrg		  path="-L$path"
29237914d74bSmrg		  ;;
29247914d74bSmrg		esac
29257914d74bSmrg		;;
29267914d74bSmrg	      -l*)
29277914d74bSmrg		case $host in
29287914d74bSmrg		*-*-darwin*)
29297914d74bSmrg		  # Again, we only want to link against shared libraries
29307914d74bSmrg		  eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"`
29317914d74bSmrg		  for tmp in $newlib_search_path ; do
29327914d74bSmrg		    if test -f "$tmp/lib$tmp_libs.dylib" ; then
29337914d74bSmrg		      eval depdepl="$tmp/lib$tmp_libs.dylib"
29347914d74bSmrg		      break
29357914d74bSmrg		    fi
29367914d74bSmrg		  done
29377914d74bSmrg		  path=""
29387914d74bSmrg		  ;;
29397914d74bSmrg		*) continue ;;
29407914d74bSmrg		esac
29417914d74bSmrg		;;
29427914d74bSmrg	      *) continue ;;
29437914d74bSmrg	      esac
29447914d74bSmrg	      case " $deplibs " in
29457914d74bSmrg	      *" $path "*) ;;
29467914d74bSmrg	      *) deplibs="$path $deplibs" ;;
29477914d74bSmrg	      esac
29487914d74bSmrg	      case " $deplibs " in
29497914d74bSmrg	      *" $depdepl "*) ;;
29507914d74bSmrg	      *) deplibs="$depdepl $deplibs" ;;
29517914d74bSmrg	      esac
29527914d74bSmrg	    done
29537914d74bSmrg	  fi # link_all_deplibs != no
29547914d74bSmrg	fi # linkmode = lib
29557914d74bSmrg      done # for deplib in $libs
29567914d74bSmrg      dependency_libs="$newdependency_libs"
29577914d74bSmrg      if test "$pass" = dlpreopen; then
29587914d74bSmrg	# Link the dlpreopened libraries before other libraries
29597914d74bSmrg	for deplib in $save_deplibs; do
29607914d74bSmrg	  deplibs="$deplib $deplibs"
29617914d74bSmrg	done
29627914d74bSmrg      fi
29637914d74bSmrg      if test "$pass" != dlopen; then
29647914d74bSmrg	if test "$pass" != conv; then
29657914d74bSmrg	  # Make sure lib_search_path contains only unique directories.
29667914d74bSmrg	  lib_search_path=
29677914d74bSmrg	  for dir in $newlib_search_path; do
29687914d74bSmrg	    case "$lib_search_path " in
29697914d74bSmrg	    *" $dir "*) ;;
29707914d74bSmrg	    *) lib_search_path="$lib_search_path $dir" ;;
29717914d74bSmrg	    esac
29727914d74bSmrg	  done
29737914d74bSmrg	  newlib_search_path=
29747914d74bSmrg	fi
29757914d74bSmrg
29767914d74bSmrg	if test "$linkmode,$pass" != "prog,link"; then
29777914d74bSmrg	  vars="deplibs"
29787914d74bSmrg	else
29797914d74bSmrg	  vars="compile_deplibs finalize_deplibs"
29807914d74bSmrg	fi
29817914d74bSmrg	for var in $vars dependency_libs; do
29827914d74bSmrg	  # Add libraries to $var in reverse order
29837914d74bSmrg	  eval tmp_libs=\"\$$var\"
29847914d74bSmrg	  new_libs=
29857914d74bSmrg	  for deplib in $tmp_libs; do
29867914d74bSmrg	    # FIXME: Pedantically, this is the right thing to do, so
29877914d74bSmrg	    #        that some nasty dependency loop isn't accidentally
29887914d74bSmrg	    #        broken:
29897914d74bSmrg	    #new_libs="$deplib $new_libs"
29907914d74bSmrg	    # Pragmatically, this seems to cause very few problems in
29917914d74bSmrg	    # practice:
29927914d74bSmrg	    case $deplib in
29937914d74bSmrg	    -L*) new_libs="$deplib $new_libs" ;;
29947914d74bSmrg	    -R*) ;;
29957914d74bSmrg	    *)
29967914d74bSmrg	      # And here is the reason: when a library appears more
29977914d74bSmrg	      # than once as an explicit dependence of a library, or
29987914d74bSmrg	      # is implicitly linked in more than once by the
29997914d74bSmrg	      # compiler, it is considered special, and multiple
30007914d74bSmrg	      # occurrences thereof are not removed.  Compare this
30017914d74bSmrg	      # with having the same library being listed as a
30027914d74bSmrg	      # dependency of multiple other libraries: in this case,
30037914d74bSmrg	      # we know (pedantically, we assume) the library does not
30047914d74bSmrg	      # need to be listed more than once, so we keep only the
30057914d74bSmrg	      # last copy.  This is not always right, but it is rare
30067914d74bSmrg	      # enough that we require users that really mean to play
30077914d74bSmrg	      # such unportable linking tricks to link the library
30087914d74bSmrg	      # using -Wl,-lname, so that libtool does not consider it
30097914d74bSmrg	      # for duplicate removal.
30107914d74bSmrg	      case " $specialdeplibs " in
30117914d74bSmrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
30127914d74bSmrg	      *)
30137914d74bSmrg		case " $new_libs " in
30147914d74bSmrg		*" $deplib "*) ;;
30157914d74bSmrg		*) new_libs="$deplib $new_libs" ;;
30167914d74bSmrg		esac
30177914d74bSmrg		;;
30187914d74bSmrg	      esac
30197914d74bSmrg	      ;;
30207914d74bSmrg	    esac
30217914d74bSmrg	  done
30227914d74bSmrg	  tmp_libs=
30237914d74bSmrg	  for deplib in $new_libs; do
30247914d74bSmrg	    case $deplib in
30257914d74bSmrg	    -L*)
30267914d74bSmrg	      case " $tmp_libs " in
30277914d74bSmrg	      *" $deplib "*) ;;
30287914d74bSmrg	      *) tmp_libs="$tmp_libs $deplib" ;;
30297914d74bSmrg	      esac
30307914d74bSmrg	      ;;
30317914d74bSmrg	    *) tmp_libs="$tmp_libs $deplib" ;;
30327914d74bSmrg	    esac
30337914d74bSmrg	  done
30347914d74bSmrg	  eval $var=\"$tmp_libs\"
30357914d74bSmrg	done # for var
30367914d74bSmrg      fi
30377914d74bSmrg      # Last step: remove runtime libs from dependency_libs
30387914d74bSmrg      # (they stay in deplibs)
30397914d74bSmrg      tmp_libs=
30407914d74bSmrg      for i in $dependency_libs ; do
30417914d74bSmrg	case " $predeps $postdeps $compiler_lib_search_path " in
30427914d74bSmrg	*" $i "*)
30437914d74bSmrg	  i=""
30447914d74bSmrg	  ;;
30457914d74bSmrg	esac
30467914d74bSmrg	if test -n "$i" ; then
30477914d74bSmrg	  tmp_libs="$tmp_libs $i"
30487914d74bSmrg	fi
30497914d74bSmrg      done
30507914d74bSmrg      dependency_libs=$tmp_libs
30517914d74bSmrg    done # for pass
30527914d74bSmrg    if test "$linkmode" = prog; then
30537914d74bSmrg      dlfiles="$newdlfiles"
30547914d74bSmrg      dlprefiles="$newdlprefiles"
30557914d74bSmrg    fi
30567914d74bSmrg
30577914d74bSmrg    case $linkmode in
30587914d74bSmrg    oldlib)
30597914d74bSmrg      if test -n "$deplibs"; then
30607914d74bSmrg	$echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2
30617914d74bSmrg      fi
30627914d74bSmrg
30637914d74bSmrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
30647914d74bSmrg	$echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
30657914d74bSmrg      fi
30667914d74bSmrg
30677914d74bSmrg      if test -n "$rpath"; then
30687914d74bSmrg	$echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2
30697914d74bSmrg      fi
30707914d74bSmrg
30717914d74bSmrg      if test -n "$xrpath"; then
30727914d74bSmrg	$echo "$modename: warning: \`-R' is ignored for archives" 1>&2
30737914d74bSmrg      fi
30747914d74bSmrg
30757914d74bSmrg      if test -n "$vinfo"; then
30767914d74bSmrg	$echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2
30777914d74bSmrg      fi
30787914d74bSmrg
30797914d74bSmrg      if test -n "$release"; then
30807914d74bSmrg	$echo "$modename: warning: \`-release' is ignored for archives" 1>&2
30817914d74bSmrg      fi
30827914d74bSmrg
30837914d74bSmrg      if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
30847914d74bSmrg	$echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2
30857914d74bSmrg      fi
30867914d74bSmrg
30877914d74bSmrg      # Now set the variables for building old libraries.
30887914d74bSmrg      build_libtool_libs=no
30897914d74bSmrg      oldlibs="$output"
30907914d74bSmrg      objs="$objs$old_deplibs"
30917914d74bSmrg      ;;
30927914d74bSmrg
30937914d74bSmrg    lib)
30947914d74bSmrg      # Make sure we only generate libraries of the form `libNAME.la'.
30957914d74bSmrg      case $outputname in
30967914d74bSmrg      lib*)
30977914d74bSmrg	name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
30987914d74bSmrg	eval shared_ext=\"$shrext_cmds\"
30997914d74bSmrg	eval libname=\"$libname_spec\"
31007914d74bSmrg	;;
31017914d74bSmrg      *)
31027914d74bSmrg	if test "$module" = no; then
31037914d74bSmrg	  $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
31047914d74bSmrg	  $echo "$help" 1>&2
31057914d74bSmrg	  exit $EXIT_FAILURE
31067914d74bSmrg	fi
31077914d74bSmrg	if test "$need_lib_prefix" != no; then
31087914d74bSmrg	  # Add the "lib" prefix for modules if required
31097914d74bSmrg	  name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
31107914d74bSmrg	  eval shared_ext=\"$shrext_cmds\"
31117914d74bSmrg	  eval libname=\"$libname_spec\"
31127914d74bSmrg	else
31137914d74bSmrg	  libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
31147914d74bSmrg	fi
31157914d74bSmrg	;;
31167914d74bSmrg      esac
31177914d74bSmrg
31187914d74bSmrg      if test -n "$objs"; then
31197914d74bSmrg	if test "$deplibs_check_method" != pass_all; then
31207914d74bSmrg	  $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1
31217914d74bSmrg	  exit $EXIT_FAILURE
31227914d74bSmrg	else
31237914d74bSmrg	  $echo
31247914d74bSmrg	  $echo "*** Warning: Linking the shared library $output against the non-libtool"
31257914d74bSmrg	  $echo "*** objects $objs is not portable!"
31267914d74bSmrg	  libobjs="$libobjs $objs"
31277914d74bSmrg	fi
31287914d74bSmrg      fi
31297914d74bSmrg
31307914d74bSmrg      if test "$dlself" != no; then
31317914d74bSmrg	$echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2
31327914d74bSmrg      fi
31337914d74bSmrg
31347914d74bSmrg      set dummy $rpath
31357914d74bSmrg      if test "$#" -gt 2; then
31367914d74bSmrg	$echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
31377914d74bSmrg      fi
31387914d74bSmrg      install_libdir="$2"
31397914d74bSmrg
31407914d74bSmrg      oldlibs=
31417914d74bSmrg      if test -z "$rpath"; then
31427914d74bSmrg	if test "$build_libtool_libs" = yes; then
31437914d74bSmrg	  # Building a libtool convenience library.
31447914d74bSmrg	  # Some compilers have problems with a `.al' extension so
31457914d74bSmrg	  # convenience libraries should have the same extension an
31467914d74bSmrg	  # archive normally would.
31477914d74bSmrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
31487914d74bSmrg	  build_libtool_libs=convenience
31497914d74bSmrg	  build_old_libs=yes
31507914d74bSmrg	fi
31517914d74bSmrg
31527914d74bSmrg	if test -n "$vinfo"; then
31537914d74bSmrg	  $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2
31547914d74bSmrg	fi
31557914d74bSmrg
31567914d74bSmrg	if test -n "$release"; then
31577914d74bSmrg	  $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2
31587914d74bSmrg	fi
31597914d74bSmrg      else
31607914d74bSmrg
31617914d74bSmrg	# Parse the version information argument.
31627914d74bSmrg	save_ifs="$IFS"; IFS=':'
31637914d74bSmrg	set dummy $vinfo 0 0 0
31647914d74bSmrg	IFS="$save_ifs"
31657914d74bSmrg
31667914d74bSmrg	if test -n "$8"; then
31677914d74bSmrg	  $echo "$modename: too many parameters to \`-version-info'" 1>&2
31687914d74bSmrg	  $echo "$help" 1>&2
31697914d74bSmrg	  exit $EXIT_FAILURE
31707914d74bSmrg	fi
31717914d74bSmrg
31727914d74bSmrg	# convert absolute version numbers to libtool ages
31737914d74bSmrg	# this retains compatibility with .la files and attempts
31747914d74bSmrg	# to make the code below a bit more comprehensible
31757914d74bSmrg
31767914d74bSmrg	case $vinfo_number in
31777914d74bSmrg	yes)
31787914d74bSmrg	  number_major="$2"
31797914d74bSmrg	  number_minor="$3"
31807914d74bSmrg	  number_revision="$4"
31817914d74bSmrg	  #
31827914d74bSmrg	  # There are really only two kinds -- those that
31837914d74bSmrg	  # use the current revision as the major version
31847914d74bSmrg	  # and those that subtract age and use age as
31857914d74bSmrg	  # a minor version.  But, then there is irix
31867914d74bSmrg	  # which has an extra 1 added just for fun
31877914d74bSmrg	  #
31887914d74bSmrg	  case $version_type in
31897914d74bSmrg	  darwin|linux|osf|windows)
31907914d74bSmrg	    current=`expr $number_major + $number_minor`
31917914d74bSmrg	    age="$number_minor"
31927914d74bSmrg	    revision="$number_revision"
31937914d74bSmrg	    ;;
31947914d74bSmrg	  freebsd-aout|freebsd-elf|sunos)
31957914d74bSmrg	    current="$number_major"
31967914d74bSmrg	    revision="$number_minor"
31977914d74bSmrg	    age="0"
31987914d74bSmrg	    ;;
31997914d74bSmrg	  irix|nonstopux)
32007914d74bSmrg	    current=`expr $number_major + $number_minor - 1`
32017914d74bSmrg	    age="$number_minor"
32027914d74bSmrg	    revision="$number_minor"
32037914d74bSmrg	    ;;
32047914d74bSmrg	  esac
32057914d74bSmrg	  ;;
32067914d74bSmrg	no)
32077914d74bSmrg	  current="$2"
32087914d74bSmrg	  revision="$3"
32097914d74bSmrg	  age="$4"
32107914d74bSmrg	  ;;
32117914d74bSmrg	esac
32127914d74bSmrg
32137914d74bSmrg	# Check that each of the things are valid numbers.
32147914d74bSmrg	case $current in
32157914d74bSmrg	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]) ;;
32167914d74bSmrg	*)
32177914d74bSmrg	  $echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2
32187914d74bSmrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
32197914d74bSmrg	  exit $EXIT_FAILURE
32207914d74bSmrg	  ;;
32217914d74bSmrg	esac
32227914d74bSmrg
32237914d74bSmrg	case $revision in
32247914d74bSmrg	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]) ;;
32257914d74bSmrg	*)
32267914d74bSmrg	  $echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2
32277914d74bSmrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
32287914d74bSmrg	  exit $EXIT_FAILURE
32297914d74bSmrg	  ;;
32307914d74bSmrg	esac
32317914d74bSmrg
32327914d74bSmrg	case $age in
32337914d74bSmrg	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]) ;;
32347914d74bSmrg	*)
32357914d74bSmrg	  $echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2
32367914d74bSmrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
32377914d74bSmrg	  exit $EXIT_FAILURE
32387914d74bSmrg	  ;;
32397914d74bSmrg	esac
32407914d74bSmrg
32417914d74bSmrg	if test "$age" -gt "$current"; then
32427914d74bSmrg	  $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
32437914d74bSmrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
32447914d74bSmrg	  exit $EXIT_FAILURE
32457914d74bSmrg	fi
32467914d74bSmrg
32477914d74bSmrg	# Calculate the version variables.
32487914d74bSmrg	major=
32497914d74bSmrg	versuffix=
32507914d74bSmrg	verstring=
32517914d74bSmrg	case $version_type in
32527914d74bSmrg	none) ;;
32537914d74bSmrg
32547914d74bSmrg	darwin)
32557914d74bSmrg	  # Like Linux, but with the current version available in
32567914d74bSmrg	  # verstring for coding it into the library header
32577914d74bSmrg	  major=.`expr $current - $age`
32587914d74bSmrg	  versuffix="$major.$age.$revision"
32597914d74bSmrg	  # Darwin ld doesn't like 0 for these options...
32607914d74bSmrg	  minor_current=`expr $current + 1`
32617914d74bSmrg	  verstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
32627914d74bSmrg	  ;;
32637914d74bSmrg
32647914d74bSmrg	freebsd-aout)
32657914d74bSmrg	  major=".$current"
32667914d74bSmrg	  versuffix=".$current.$revision";
32677914d74bSmrg	  ;;
32687914d74bSmrg
32697914d74bSmrg	freebsd-elf)
32707914d74bSmrg	  major=".$current"
32717914d74bSmrg	  versuffix=".$current";
32727914d74bSmrg	  ;;
32737914d74bSmrg
32747914d74bSmrg	irix | nonstopux)
32757914d74bSmrg	  major=`expr $current - $age + 1`
32767914d74bSmrg
32777914d74bSmrg	  case $version_type in
32787914d74bSmrg	    nonstopux) verstring_prefix=nonstopux ;;
32797914d74bSmrg	    *)         verstring_prefix=sgi ;;
32807914d74bSmrg	  esac
32817914d74bSmrg	  verstring="$verstring_prefix$major.$revision"
32827914d74bSmrg
32837914d74bSmrg	  # Add in all the interfaces that we are compatible with.
32847914d74bSmrg	  loop=$revision
32857914d74bSmrg	  while test "$loop" -ne 0; do
32867914d74bSmrg	    iface=`expr $revision - $loop`
32877914d74bSmrg	    loop=`expr $loop - 1`
32887914d74bSmrg	    verstring="$verstring_prefix$major.$iface:$verstring"
32897914d74bSmrg	  done
32907914d74bSmrg
32917914d74bSmrg	  # Before this point, $major must not contain `.'.
32927914d74bSmrg	  major=.$major
32937914d74bSmrg	  versuffix="$major.$revision"
32947914d74bSmrg	  ;;
32957914d74bSmrg
32967914d74bSmrg	linux)
32977914d74bSmrg	  major=.`expr $current - $age`
32987914d74bSmrg	  versuffix="$major.$age.$revision"
32997914d74bSmrg	  ;;
33007914d74bSmrg
33017914d74bSmrg	osf)
33027914d74bSmrg	  major=.`expr $current - $age`
33037914d74bSmrg	  versuffix=".$current.$age.$revision"
33047914d74bSmrg	  verstring="$current.$age.$revision"
33057914d74bSmrg
33067914d74bSmrg	  # Add in all the interfaces that we are compatible with.
33077914d74bSmrg	  loop=$age
33087914d74bSmrg	  while test "$loop" -ne 0; do
33097914d74bSmrg	    iface=`expr $current - $loop`
33107914d74bSmrg	    loop=`expr $loop - 1`
33117914d74bSmrg	    verstring="$verstring:${iface}.0"
33127914d74bSmrg	  done
33137914d74bSmrg
33147914d74bSmrg	  # Make executables depend on our current version.
33157914d74bSmrg	  verstring="$verstring:${current}.0"
33167914d74bSmrg	  ;;
33177914d74bSmrg
33187914d74bSmrg	sunos)
33197914d74bSmrg	  major=".$current"
33207914d74bSmrg	  versuffix=".$current.$revision"
33217914d74bSmrg	  ;;
33227914d74bSmrg
33237914d74bSmrg	windows)
33247914d74bSmrg	  # Use '-' rather than '.', since we only want one
33257914d74bSmrg	  # extension on DOS 8.3 filesystems.
33267914d74bSmrg	  major=`expr $current - $age`
33277914d74bSmrg	  versuffix="-$major"
33287914d74bSmrg	  ;;
33297914d74bSmrg
33307914d74bSmrg	*)
33317914d74bSmrg	  $echo "$modename: unknown library version type \`$version_type'" 1>&2
33327914d74bSmrg	  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
33337914d74bSmrg	  exit $EXIT_FAILURE
33347914d74bSmrg	  ;;
33357914d74bSmrg	esac
33367914d74bSmrg
33377914d74bSmrg	# Clear the version info if we defaulted, and they specified a release.
33387914d74bSmrg	if test -z "$vinfo" && test -n "$release"; then
33397914d74bSmrg	  major=
33407914d74bSmrg	  case $version_type in
33417914d74bSmrg	  darwin)
33427914d74bSmrg	    # we can't check for "0.0" in archive_cmds due to quoting
33437914d74bSmrg	    # problems, so we reset it completely
33447914d74bSmrg	    verstring=
33457914d74bSmrg	    ;;
33467914d74bSmrg	  *)
33477914d74bSmrg	    verstring="0.0"
33487914d74bSmrg	    ;;
33497914d74bSmrg	  esac
33507914d74bSmrg	  if test "$need_version" = no; then
33517914d74bSmrg	    versuffix=
33527914d74bSmrg	  else
33537914d74bSmrg	    versuffix=".0.0"
33547914d74bSmrg	  fi
33557914d74bSmrg	fi
33567914d74bSmrg
33577914d74bSmrg	# Remove version info from name if versioning should be avoided
33587914d74bSmrg	if test "$avoid_version" = yes && test "$need_version" = no; then
33597914d74bSmrg	  major=
33607914d74bSmrg	  versuffix=
33617914d74bSmrg	  verstring=""
33627914d74bSmrg	fi
33637914d74bSmrg
33647914d74bSmrg	# Check to see if the archive will have undefined symbols.
33657914d74bSmrg	if test "$allow_undefined" = yes; then
33667914d74bSmrg	  if test "$allow_undefined_flag" = unsupported; then
33677914d74bSmrg	    $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2
33687914d74bSmrg	    build_libtool_libs=no
33697914d74bSmrg	    build_old_libs=yes
33707914d74bSmrg	  fi
33717914d74bSmrg	else
33727914d74bSmrg	  # Don't allow undefined symbols.
33737914d74bSmrg	  allow_undefined_flag="$no_undefined_flag"
33747914d74bSmrg	fi
33757914d74bSmrg      fi
33767914d74bSmrg
33777914d74bSmrg      if test "$mode" != relink; then
33787914d74bSmrg	# Remove our outputs, but don't remove object files since they
33797914d74bSmrg	# may have been created when compiling PIC objects.
33807914d74bSmrg	removelist=
33817914d74bSmrg	tempremovelist=`$echo "$output_objdir/*"`
33827914d74bSmrg	for p in $tempremovelist; do
33837914d74bSmrg	  case $p in
33847914d74bSmrg	    *.$objext)
33857914d74bSmrg	       ;;
33867914d74bSmrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
33877914d74bSmrg	       if test "X$precious_files_regex" != "X"; then
33887914d74bSmrg	         if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
33897914d74bSmrg	         then
33907914d74bSmrg		   continue
33917914d74bSmrg		 fi
33927914d74bSmrg	       fi
33937914d74bSmrg	       removelist="$removelist $p"
33947914d74bSmrg	       ;;
33957914d74bSmrg	    *) ;;
33967914d74bSmrg	  esac
33977914d74bSmrg	done
33987914d74bSmrg	if test -n "$removelist"; then
33997914d74bSmrg	  $show "${rm}r $removelist"
34007914d74bSmrg	  $run ${rm}r $removelist
34017914d74bSmrg	fi
34027914d74bSmrg      fi
34037914d74bSmrg
34047914d74bSmrg      # Now set the variables for building old libraries.
34057914d74bSmrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
34067914d74bSmrg	oldlibs="$oldlibs $output_objdir/$libname.$libext"
34077914d74bSmrg
34087914d74bSmrg	# Transform .lo files to .o files.
34097914d74bSmrg	oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
34107914d74bSmrg      fi
34117914d74bSmrg
34127914d74bSmrg      # Eliminate all temporary directories.
34137914d74bSmrg      for path in $notinst_path; do
34147914d74bSmrg	lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"`
34157914d74bSmrg	deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"`
34167914d74bSmrg	dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"`
34177914d74bSmrg      done
34187914d74bSmrg
34197914d74bSmrg      if test -n "$xrpath"; then
34207914d74bSmrg	# If the user specified any rpath flags, then add them.
34217914d74bSmrg	temp_xrpath=
34227914d74bSmrg	for libdir in $xrpath; do
34237914d74bSmrg	  temp_xrpath="$temp_xrpath -R$libdir"
34247914d74bSmrg	  case "$finalize_rpath " in
34257914d74bSmrg	  *" $libdir "*) ;;
34267914d74bSmrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
34277914d74bSmrg	  esac
34287914d74bSmrg	done
34297914d74bSmrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
34307914d74bSmrg	  dependency_libs="$temp_xrpath $dependency_libs"
34317914d74bSmrg	fi
34327914d74bSmrg      fi
34337914d74bSmrg
34347914d74bSmrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
34357914d74bSmrg      old_dlfiles="$dlfiles"
34367914d74bSmrg      dlfiles=
34377914d74bSmrg      for lib in $old_dlfiles; do
34387914d74bSmrg	case " $dlprefiles $dlfiles " in
34397914d74bSmrg	*" $lib "*) ;;
34407914d74bSmrg	*) dlfiles="$dlfiles $lib" ;;
34417914d74bSmrg	esac
34427914d74bSmrg      done
34437914d74bSmrg
34447914d74bSmrg      # Make sure dlprefiles contains only unique files
34457914d74bSmrg      old_dlprefiles="$dlprefiles"
34467914d74bSmrg      dlprefiles=
34477914d74bSmrg      for lib in $old_dlprefiles; do
34487914d74bSmrg	case "$dlprefiles " in
34497914d74bSmrg	*" $lib "*) ;;
34507914d74bSmrg	*) dlprefiles="$dlprefiles $lib" ;;
34517914d74bSmrg	esac
34527914d74bSmrg      done
34537914d74bSmrg
34547914d74bSmrg      if test "$build_libtool_libs" = yes; then
34557914d74bSmrg	if test -n "$rpath"; then
34567914d74bSmrg	  case $host in
34577914d74bSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*)
34587914d74bSmrg	    # these systems don't actually have a c library (as such)!
34597914d74bSmrg	    ;;
34607914d74bSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
34617914d74bSmrg	    # Rhapsody C library is in the System framework
34627914d74bSmrg	    deplibs="$deplibs -framework System"
34637914d74bSmrg	    ;;
34647914d74bSmrg	  *-*-netbsd*)
34657914d74bSmrg	    # Don't link with libc until the a.out ld.so is fixed.
34667914d74bSmrg	    ;;
34677914d74bSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
34687914d74bSmrg	    # Do not include libc due to us having libc/libc_r.
34697914d74bSmrg	    ;;
34707914d74bSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
34717914d74bSmrg	    # Causes problems with __ctype
34727914d74bSmrg	    ;;
34737914d74bSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
34747914d74bSmrg	    # Compiler inserts libc in the correct place for threads to work
34757914d74bSmrg	    ;;
34767914d74bSmrg 	  *)
34777914d74bSmrg	    # Add libc to deplibs on all other systems if necessary.
34787914d74bSmrg	    if test "$build_libtool_need_lc" = "yes"; then
34797914d74bSmrg	      deplibs="$deplibs -lc"
34807914d74bSmrg	    fi
34817914d74bSmrg	    ;;
34827914d74bSmrg	  esac
34837914d74bSmrg	fi
34847914d74bSmrg
34857914d74bSmrg	# Transform deplibs into only deplibs that can be linked in shared.
34867914d74bSmrg	name_save=$name
34877914d74bSmrg	libname_save=$libname
34887914d74bSmrg	release_save=$release
34897914d74bSmrg	versuffix_save=$versuffix
34907914d74bSmrg	major_save=$major
34917914d74bSmrg	# I'm not sure if I'm treating the release correctly.  I think
34927914d74bSmrg	# release should show up in the -l (ie -lgmp5) so we don't want to
34937914d74bSmrg	# add it in twice.  Is that correct?
34947914d74bSmrg	release=""
34957914d74bSmrg	versuffix=""
34967914d74bSmrg	major=""
34977914d74bSmrg	newdeplibs=
34987914d74bSmrg	droppeddeps=no
34997914d74bSmrg	case $deplibs_check_method in
35007914d74bSmrg	pass_all)
35017914d74bSmrg	  # Don't check for shared/static.  Everything works.
35027914d74bSmrg	  # This might be a little naive.  We might want to check
35037914d74bSmrg	  # whether the library exists or not.  But this is on
35047914d74bSmrg	  # osf3 & osf4 and I'm not really sure... Just
35057914d74bSmrg	  # implementing what was already the behavior.
35067914d74bSmrg	  newdeplibs=$deplibs
35077914d74bSmrg	  ;;
35087914d74bSmrg	test_compile)
35097914d74bSmrg	  # This code stresses the "libraries are programs" paradigm to its
35107914d74bSmrg	  # limits. Maybe even breaks it.  We compile a program, linking it
35117914d74bSmrg	  # against the deplibs as a proxy for the library.  Then we can check
35127914d74bSmrg	  # whether they linked in statically or dynamically with ldd.
35137914d74bSmrg	  $rm conftest.c
35147914d74bSmrg	  cat > conftest.c <<EOF
35157914d74bSmrg	  int main() { return 0; }
35167914d74bSmrgEOF
35177914d74bSmrg	  $rm conftest
35187914d74bSmrg	  $LTCC $LTCFLAGS -o conftest conftest.c $deplibs
35197914d74bSmrg	  if test "$?" -eq 0 ; then
35207914d74bSmrg	    ldd_output=`ldd conftest`
35217914d74bSmrg	    for i in $deplibs; do
35227914d74bSmrg	      name=`expr $i : '-l\(.*\)'`
35237914d74bSmrg	      # If $name is empty we are operating on a -L argument.
35247914d74bSmrg              if test "$name" != "" && test "$name" -ne "0"; then
35257914d74bSmrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
35267914d74bSmrg		  case " $predeps $postdeps " in
35277914d74bSmrg		  *" $i "*)
35287914d74bSmrg		    newdeplibs="$newdeplibs $i"
35297914d74bSmrg		    i=""
35307914d74bSmrg		    ;;
35317914d74bSmrg		  esac
35327914d74bSmrg	        fi
35337914d74bSmrg		if test -n "$i" ; then
35347914d74bSmrg		  libname=`eval \\$echo \"$libname_spec\"`
35357914d74bSmrg		  deplib_matches=`eval \\$echo \"$library_names_spec\"`
35367914d74bSmrg		  set dummy $deplib_matches
35377914d74bSmrg		  deplib_match=$2
35387914d74bSmrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
35397914d74bSmrg		    newdeplibs="$newdeplibs $i"
35407914d74bSmrg		  else
35417914d74bSmrg		    droppeddeps=yes
35427914d74bSmrg		    $echo
35437914d74bSmrg		    $echo "*** Warning: dynamic linker does not accept needed library $i."
35447914d74bSmrg		    $echo "*** I have the capability to make that library automatically link in when"
35457914d74bSmrg		    $echo "*** you link to this library.  But I can only do this if you have a"
35467914d74bSmrg		    $echo "*** shared version of the library, which I believe you do not have"
35477914d74bSmrg		    $echo "*** because a test_compile did reveal that the linker did not use it for"
35487914d74bSmrg		    $echo "*** its dynamic dependency list that programs get resolved with at runtime."
35497914d74bSmrg		  fi
35507914d74bSmrg		fi
35517914d74bSmrg	      else
35527914d74bSmrg		newdeplibs="$newdeplibs $i"
35537914d74bSmrg	      fi
35547914d74bSmrg	    done
35557914d74bSmrg	  else
35567914d74bSmrg	    # Error occurred in the first compile.  Let's try to salvage
35577914d74bSmrg	    # the situation: Compile a separate program for each library.
35587914d74bSmrg	    for i in $deplibs; do
35597914d74bSmrg	      name=`expr $i : '-l\(.*\)'`
35607914d74bSmrg	      # If $name is empty we are operating on a -L argument.
35617914d74bSmrg              if test "$name" != "" && test "$name" != "0"; then
35627914d74bSmrg		$rm conftest
35637914d74bSmrg		$LTCC $LTCFLAGS -o conftest conftest.c $i
35647914d74bSmrg		# Did it work?
35657914d74bSmrg		if test "$?" -eq 0 ; then
35667914d74bSmrg		  ldd_output=`ldd conftest`
35677914d74bSmrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
35687914d74bSmrg		    case " $predeps $postdeps " in
35697914d74bSmrg		    *" $i "*)
35707914d74bSmrg		      newdeplibs="$newdeplibs $i"
35717914d74bSmrg		      i=""
35727914d74bSmrg		      ;;
35737914d74bSmrg		    esac
35747914d74bSmrg		  fi
35757914d74bSmrg		  if test -n "$i" ; then
35767914d74bSmrg		    libname=`eval \\$echo \"$libname_spec\"`
35777914d74bSmrg		    deplib_matches=`eval \\$echo \"$library_names_spec\"`
35787914d74bSmrg		    set dummy $deplib_matches
35797914d74bSmrg		    deplib_match=$2
35807914d74bSmrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
35817914d74bSmrg		      newdeplibs="$newdeplibs $i"
35827914d74bSmrg		    else
35837914d74bSmrg		      droppeddeps=yes
35847914d74bSmrg		      $echo
35857914d74bSmrg		      $echo "*** Warning: dynamic linker does not accept needed library $i."
35867914d74bSmrg		      $echo "*** I have the capability to make that library automatically link in when"
35877914d74bSmrg		      $echo "*** you link to this library.  But I can only do this if you have a"
35887914d74bSmrg		      $echo "*** shared version of the library, which you do not appear to have"
35897914d74bSmrg		      $echo "*** because a test_compile did reveal that the linker did not use this one"
35907914d74bSmrg		      $echo "*** as a dynamic dependency that programs can get resolved with at runtime."
35917914d74bSmrg		    fi
35927914d74bSmrg		  fi
35937914d74bSmrg		else
35947914d74bSmrg		  droppeddeps=yes
35957914d74bSmrg		  $echo
35967914d74bSmrg		  $echo "*** Warning!  Library $i is needed by this library but I was not able to"
35977914d74bSmrg		  $echo "***  make it link in!  You will probably need to install it or some"
35987914d74bSmrg		  $echo "*** library that it depends on before this library will be fully"
35997914d74bSmrg		  $echo "*** functional.  Installing it before continuing would be even better."
36007914d74bSmrg		fi
36017914d74bSmrg	      else
36027914d74bSmrg		newdeplibs="$newdeplibs $i"
36037914d74bSmrg	      fi
36047914d74bSmrg	    done
36057914d74bSmrg	  fi
36067914d74bSmrg	  ;;
36077914d74bSmrg	file_magic*)
36087914d74bSmrg	  set dummy $deplibs_check_method
36097914d74bSmrg	  file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
36107914d74bSmrg	  for a_deplib in $deplibs; do
36117914d74bSmrg	    name=`expr $a_deplib : '-l\(.*\)'`
36127914d74bSmrg	    # If $name is empty we are operating on a -L argument.
36137914d74bSmrg            if test "$name" != "" && test  "$name" != "0"; then
36147914d74bSmrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
36157914d74bSmrg		case " $predeps $postdeps " in
36167914d74bSmrg		*" $a_deplib "*)
36177914d74bSmrg		  newdeplibs="$newdeplibs $a_deplib"
36187914d74bSmrg		  a_deplib=""
36197914d74bSmrg		  ;;
36207914d74bSmrg		esac
36217914d74bSmrg	      fi
36227914d74bSmrg	      if test -n "$a_deplib" ; then
36237914d74bSmrg		libname=`eval \\$echo \"$libname_spec\"`
36247914d74bSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
36257914d74bSmrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
36267914d74bSmrg		  for potent_lib in $potential_libs; do
36277914d74bSmrg		      # Follow soft links.
36287914d74bSmrg		      if ls -lLd "$potent_lib" 2>/dev/null \
36297914d74bSmrg			 | grep " -> " >/dev/null; then
36307914d74bSmrg			continue
36317914d74bSmrg		      fi
36327914d74bSmrg		      # The statement above tries to avoid entering an
36337914d74bSmrg		      # endless loop below, in case of cyclic links.
36347914d74bSmrg		      # We might still enter an endless loop, since a link
36357914d74bSmrg		      # loop can be closed while we follow links,
36367914d74bSmrg		      # but so what?
36377914d74bSmrg		      potlib="$potent_lib"
36387914d74bSmrg		      while test -h "$potlib" 2>/dev/null; do
36397914d74bSmrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
36407914d74bSmrg			case $potliblink in
36417914d74bSmrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
36427914d74bSmrg			*) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
36437914d74bSmrg			esac
36447914d74bSmrg		      done
36457914d74bSmrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
36467914d74bSmrg			 | ${SED} 10q \
36477914d74bSmrg			 | $EGREP "$file_magic_regex" > /dev/null; then
36487914d74bSmrg			newdeplibs="$newdeplibs $a_deplib"
36497914d74bSmrg			a_deplib=""
36507914d74bSmrg			break 2
36517914d74bSmrg		      fi
36527914d74bSmrg		  done
36537914d74bSmrg		done
36547914d74bSmrg	      fi
36557914d74bSmrg	      if test -n "$a_deplib" ; then
36567914d74bSmrg		droppeddeps=yes
36577914d74bSmrg		$echo
36587914d74bSmrg		$echo "*** Warning: linker path does not have real file for library $a_deplib."
36597914d74bSmrg		$echo "*** I have the capability to make that library automatically link in when"
36607914d74bSmrg		$echo "*** you link to this library.  But I can only do this if you have a"
36617914d74bSmrg		$echo "*** shared version of the library, which you do not appear to have"
36627914d74bSmrg		$echo "*** because I did check the linker path looking for a file starting"
36637914d74bSmrg		if test -z "$potlib" ; then
36647914d74bSmrg		  $echo "*** with $libname but no candidates were found. (...for file magic test)"
36657914d74bSmrg		else
36667914d74bSmrg		  $echo "*** with $libname and none of the candidates passed a file format test"
36677914d74bSmrg		  $echo "*** using a file magic. Last file checked: $potlib"
36687914d74bSmrg		fi
36697914d74bSmrg	      fi
36707914d74bSmrg	    else
36717914d74bSmrg	      # Add a -L argument.
36727914d74bSmrg	      newdeplibs="$newdeplibs $a_deplib"
36737914d74bSmrg	    fi
36747914d74bSmrg	  done # Gone through all deplibs.
36757914d74bSmrg	  ;;
36767914d74bSmrg	match_pattern*)
36777914d74bSmrg	  set dummy $deplibs_check_method
36787914d74bSmrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
36797914d74bSmrg	  for a_deplib in $deplibs; do
36807914d74bSmrg	    name=`expr $a_deplib : '-l\(.*\)'`
36817914d74bSmrg	    # If $name is empty we are operating on a -L argument.
36827914d74bSmrg	    if test -n "$name" && test "$name" != "0"; then
36837914d74bSmrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
36847914d74bSmrg		case " $predeps $postdeps " in
36857914d74bSmrg		*" $a_deplib "*)
36867914d74bSmrg		  newdeplibs="$newdeplibs $a_deplib"
36877914d74bSmrg		  a_deplib=""
36887914d74bSmrg		  ;;
36897914d74bSmrg		esac
36907914d74bSmrg	      fi
36917914d74bSmrg	      if test -n "$a_deplib" ; then
36927914d74bSmrg		libname=`eval \\$echo \"$libname_spec\"`
36937914d74bSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
36947914d74bSmrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
36957914d74bSmrg		  for potent_lib in $potential_libs; do
36967914d74bSmrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
36977914d74bSmrg		    if eval $echo \"$potent_lib\" 2>/dev/null \
36987914d74bSmrg		        | ${SED} 10q \
36997914d74bSmrg		        | $EGREP "$match_pattern_regex" > /dev/null; then
37007914d74bSmrg		      newdeplibs="$newdeplibs $a_deplib"
37017914d74bSmrg		      a_deplib=""
37027914d74bSmrg		      break 2
37037914d74bSmrg		    fi
37047914d74bSmrg		  done
37057914d74bSmrg		done
37067914d74bSmrg	      fi
37077914d74bSmrg	      if test -n "$a_deplib" ; then
37087914d74bSmrg		droppeddeps=yes
37097914d74bSmrg		$echo
37107914d74bSmrg		$echo "*** Warning: linker path does not have real file for library $a_deplib."
37117914d74bSmrg		$echo "*** I have the capability to make that library automatically link in when"
37127914d74bSmrg		$echo "*** you link to this library.  But I can only do this if you have a"
37137914d74bSmrg		$echo "*** shared version of the library, which you do not appear to have"
37147914d74bSmrg		$echo "*** because I did check the linker path looking for a file starting"
37157914d74bSmrg		if test -z "$potlib" ; then
37167914d74bSmrg		  $echo "*** with $libname but no candidates were found. (...for regex pattern test)"
37177914d74bSmrg		else
37187914d74bSmrg		  $echo "*** with $libname and none of the candidates passed a file format test"
37197914d74bSmrg		  $echo "*** using a regex pattern. Last file checked: $potlib"
37207914d74bSmrg		fi
37217914d74bSmrg	      fi
37227914d74bSmrg	    else
37237914d74bSmrg	      # Add a -L argument.
37247914d74bSmrg	      newdeplibs="$newdeplibs $a_deplib"
37257914d74bSmrg	    fi
37267914d74bSmrg	  done # Gone through all deplibs.
37277914d74bSmrg	  ;;
37287914d74bSmrg	none | unknown | *)
37297914d74bSmrg	  newdeplibs=""
37307914d74bSmrg	  tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
37317914d74bSmrg	    -e 's/ -[LR][^ ]*//g'`
37327914d74bSmrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
37337914d74bSmrg	    for i in $predeps $postdeps ; do
37347914d74bSmrg	      # can't use Xsed below, because $i might contain '/'
37357914d74bSmrg	      tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"`
37367914d74bSmrg	    done
37377914d74bSmrg	  fi
37387914d74bSmrg	  if $echo "X $tmp_deplibs" | $Xsed -e 's/[ 	]//g' \
37397914d74bSmrg	    | grep . >/dev/null; then
37407914d74bSmrg	    $echo
37417914d74bSmrg	    if test "X$deplibs_check_method" = "Xnone"; then
37427914d74bSmrg	      $echo "*** Warning: inter-library dependencies are not supported in this platform."
37437914d74bSmrg	    else
37447914d74bSmrg	      $echo "*** Warning: inter-library dependencies are not known to be supported."
37457914d74bSmrg	    fi
37467914d74bSmrg	    $echo "*** All declared inter-library dependencies are being dropped."
37477914d74bSmrg	    droppeddeps=yes
37487914d74bSmrg	  fi
37497914d74bSmrg	  ;;
37507914d74bSmrg	esac
37517914d74bSmrg	versuffix=$versuffix_save
37527914d74bSmrg	major=$major_save
37537914d74bSmrg	release=$release_save
37547914d74bSmrg	libname=$libname_save
37557914d74bSmrg	name=$name_save
37567914d74bSmrg
37577914d74bSmrg	case $host in
37587914d74bSmrg	*-*-rhapsody* | *-*-darwin1.[012])
37597914d74bSmrg	  # On Rhapsody replace the C library is the System framework
37607914d74bSmrg	  newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'`
37617914d74bSmrg	  ;;
37627914d74bSmrg	esac
37637914d74bSmrg
37647914d74bSmrg	if test "$droppeddeps" = yes; then
37657914d74bSmrg	  if test "$module" = yes; then
37667914d74bSmrg	    $echo
37677914d74bSmrg	    $echo "*** Warning: libtool could not satisfy all declared inter-library"
37687914d74bSmrg	    $echo "*** dependencies of module $libname.  Therefore, libtool will create"
37697914d74bSmrg	    $echo "*** a static module, that should work as long as the dlopening"
37707914d74bSmrg	    $echo "*** application is linked with the -dlopen flag."
37717914d74bSmrg	    if test -z "$global_symbol_pipe"; then
37727914d74bSmrg	      $echo
37737914d74bSmrg	      $echo "*** However, this would only work if libtool was able to extract symbol"
37747914d74bSmrg	      $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
37757914d74bSmrg	      $echo "*** not find such a program.  So, this module is probably useless."
37767914d74bSmrg	      $echo "*** \`nm' from GNU binutils and a full rebuild may help."
37777914d74bSmrg	    fi
37787914d74bSmrg	    if test "$build_old_libs" = no; then
37797914d74bSmrg	      oldlibs="$output_objdir/$libname.$libext"
37807914d74bSmrg	      build_libtool_libs=module
37817914d74bSmrg	      build_old_libs=yes
37827914d74bSmrg	    else
37837914d74bSmrg	      build_libtool_libs=no
37847914d74bSmrg	    fi
37857914d74bSmrg	  else
37867914d74bSmrg	    $echo "*** The inter-library dependencies that have been dropped here will be"
37877914d74bSmrg	    $echo "*** automatically added whenever a program is linked with this library"
37887914d74bSmrg	    $echo "*** or is declared to -dlopen it."
37897914d74bSmrg
37907914d74bSmrg	    if test "$allow_undefined" = no; then
37917914d74bSmrg	      $echo
37927914d74bSmrg	      $echo "*** Since this library must not contain undefined symbols,"
37937914d74bSmrg	      $echo "*** because either the platform does not support them or"
37947914d74bSmrg	      $echo "*** it was explicitly requested with -no-undefined,"
37957914d74bSmrg	      $echo "*** libtool will only create a static version of it."
37967914d74bSmrg	      if test "$build_old_libs" = no; then
37977914d74bSmrg		oldlibs="$output_objdir/$libname.$libext"
37987914d74bSmrg		build_libtool_libs=module
37997914d74bSmrg		build_old_libs=yes
38007914d74bSmrg	      else
38017914d74bSmrg		build_libtool_libs=no
38027914d74bSmrg	      fi
38037914d74bSmrg	    fi
38047914d74bSmrg	  fi
38057914d74bSmrg	fi
38067914d74bSmrg	# Done checking deplibs!
38077914d74bSmrg	deplibs=$newdeplibs
38087914d74bSmrg      fi
38097914d74bSmrg
38107914d74bSmrg
38117914d74bSmrg      # move library search paths that coincide with paths to not yet
38127914d74bSmrg      # installed libraries to the beginning of the library search list
38137914d74bSmrg      new_libs=
38147914d74bSmrg      for path in $notinst_path; do
38157914d74bSmrg	case " $new_libs " in
38167914d74bSmrg	*" -L$path/$objdir "*) ;;
38177914d74bSmrg	*)
38187914d74bSmrg	  case " $deplibs " in
38197914d74bSmrg	  *" -L$path/$objdir "*)
38207914d74bSmrg	    new_libs="$new_libs -L$path/$objdir" ;;
38217914d74bSmrg	  esac
38227914d74bSmrg	  ;;
38237914d74bSmrg	esac
38247914d74bSmrg      done
38257914d74bSmrg      for deplib in $deplibs; do
38267914d74bSmrg	case $deplib in
38277914d74bSmrg	-L*)
38287914d74bSmrg	  case " $new_libs " in
38297914d74bSmrg	  *" $deplib "*) ;;
38307914d74bSmrg	  *) new_libs="$new_libs $deplib" ;;
38317914d74bSmrg	  esac
38327914d74bSmrg	  ;;
38337914d74bSmrg	*) new_libs="$new_libs $deplib" ;;
38347914d74bSmrg	esac
38357914d74bSmrg      done
38367914d74bSmrg      deplibs="$new_libs"
38377914d74bSmrg
38387914d74bSmrg
38397914d74bSmrg      # All the library-specific variables (install_libdir is set above).
38407914d74bSmrg      library_names=
38417914d74bSmrg      old_library=
38427914d74bSmrg      dlname=
38437914d74bSmrg
38447914d74bSmrg      # Test again, we may have decided not to build it any more
38457914d74bSmrg      if test "$build_libtool_libs" = yes; then
38467914d74bSmrg	if test "$hardcode_into_libs" = yes; then
38477914d74bSmrg	  # Hardcode the library paths
38487914d74bSmrg	  hardcode_libdirs=
38497914d74bSmrg	  dep_rpath=
38507914d74bSmrg	  rpath="$finalize_rpath"
38517914d74bSmrg	  test "$mode" != relink && rpath="$compile_rpath$rpath"
38527914d74bSmrg	  for libdir in $rpath; do
38537914d74bSmrg	    if test -n "$hardcode_libdir_flag_spec"; then
38547914d74bSmrg	      if test -n "$hardcode_libdir_separator"; then
38557914d74bSmrg		if test -z "$hardcode_libdirs"; then
38567914d74bSmrg		  hardcode_libdirs="$libdir"
38577914d74bSmrg		else
38587914d74bSmrg		  # Just accumulate the unique libdirs.
38597914d74bSmrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
38607914d74bSmrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
38617914d74bSmrg		    ;;
38627914d74bSmrg		  *)
38637914d74bSmrg		    hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
38647914d74bSmrg		    ;;
38657914d74bSmrg		  esac
38667914d74bSmrg		fi
38677914d74bSmrg	      else
38687914d74bSmrg		eval flag=\"$hardcode_libdir_flag_spec\"
38697914d74bSmrg		dep_rpath="$dep_rpath $flag"
38707914d74bSmrg	      fi
38717914d74bSmrg	    elif test -n "$runpath_var"; then
38727914d74bSmrg	      case "$perm_rpath " in
38737914d74bSmrg	      *" $libdir "*) ;;
38747914d74bSmrg	      *) perm_rpath="$perm_rpath $libdir" ;;
38757914d74bSmrg	      esac
38767914d74bSmrg	    fi
38777914d74bSmrg	  done
38787914d74bSmrg	  # Substitute the hardcoded libdirs into the rpath.
38797914d74bSmrg	  if test -n "$hardcode_libdir_separator" &&
38807914d74bSmrg	     test -n "$hardcode_libdirs"; then
38817914d74bSmrg	    libdir="$hardcode_libdirs"
38827914d74bSmrg	    if test -n "$hardcode_libdir_flag_spec_ld"; then
38837914d74bSmrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
38847914d74bSmrg	    else
38857914d74bSmrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
38867914d74bSmrg	    fi
38877914d74bSmrg	  fi
38887914d74bSmrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
38897914d74bSmrg	    # We should set the runpath_var.
38907914d74bSmrg	    rpath=
38917914d74bSmrg	    for dir in $perm_rpath; do
38927914d74bSmrg	      rpath="$rpath$dir:"
38937914d74bSmrg	    done
38947914d74bSmrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
38957914d74bSmrg	  fi
38967914d74bSmrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
38977914d74bSmrg	fi
38987914d74bSmrg
38997914d74bSmrg	shlibpath="$finalize_shlibpath"
39007914d74bSmrg	test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
39017914d74bSmrg	if test -n "$shlibpath"; then
39027914d74bSmrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
39037914d74bSmrg	fi
39047914d74bSmrg
39057914d74bSmrg	# Get the real and link names of the library.
39067914d74bSmrg	eval shared_ext=\"$shrext_cmds\"
39077914d74bSmrg	eval library_names=\"$library_names_spec\"
39087914d74bSmrg	set dummy $library_names
39097914d74bSmrg	realname="$2"
39107914d74bSmrg	shift; shift
39117914d74bSmrg
39127914d74bSmrg	if test -n "$soname_spec"; then
39137914d74bSmrg	  eval soname=\"$soname_spec\"
39147914d74bSmrg	else
39157914d74bSmrg	  soname="$realname"
39167914d74bSmrg	fi
39177914d74bSmrg	if test -z "$dlname"; then
39187914d74bSmrg	  dlname=$soname
39197914d74bSmrg	fi
39207914d74bSmrg
39217914d74bSmrg	lib="$output_objdir/$realname"
39227914d74bSmrg	linknames=
39237914d74bSmrg	for link
39247914d74bSmrg	do
39257914d74bSmrg	  linknames="$linknames $link"
39267914d74bSmrg	done
39277914d74bSmrg
39287914d74bSmrg	# Use standard objects if they are pic
39297914d74bSmrg	test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
39307914d74bSmrg
39317914d74bSmrg	# Prepare the list of exported symbols
39327914d74bSmrg	if test -z "$export_symbols"; then
39337914d74bSmrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
39347914d74bSmrg	    $show "generating symbol list for \`$libname.la'"
39357914d74bSmrg	    export_symbols="$output_objdir/$libname.exp"
39367914d74bSmrg	    $run $rm $export_symbols
39377914d74bSmrg	    cmds=$export_symbols_cmds
39387914d74bSmrg	    save_ifs="$IFS"; IFS='~'
39397914d74bSmrg	    for cmd in $cmds; do
39407914d74bSmrg	      IFS="$save_ifs"
39417914d74bSmrg	      eval cmd=\"$cmd\"
39427914d74bSmrg	      if len=`expr "X$cmd" : ".*"` &&
39437914d74bSmrg	       test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
39447914d74bSmrg	        $show "$cmd"
39457914d74bSmrg	        $run eval "$cmd" || exit $?
39467914d74bSmrg	        skipped_export=false
39477914d74bSmrg	      else
39487914d74bSmrg	        # The command line is too long to execute in one step.
39497914d74bSmrg	        $show "using reloadable object file for export list..."
39507914d74bSmrg	        skipped_export=:
39517914d74bSmrg		# Break out early, otherwise skipped_export may be
39527914d74bSmrg		# set to false by a later but shorter cmd.
39537914d74bSmrg		break
39547914d74bSmrg	      fi
39557914d74bSmrg	    done
39567914d74bSmrg	    IFS="$save_ifs"
39577914d74bSmrg	    if test -n "$export_symbols_regex"; then
39587914d74bSmrg	      $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""
39597914d74bSmrg	      $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
39607914d74bSmrg	      $show "$mv \"${export_symbols}T\" \"$export_symbols\""
39617914d74bSmrg	      $run eval '$mv "${export_symbols}T" "$export_symbols"'
39627914d74bSmrg	    fi
39637914d74bSmrg	  fi
39647914d74bSmrg	fi
39657914d74bSmrg
39667914d74bSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
39677914d74bSmrg	  $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"'
39687914d74bSmrg	fi
39697914d74bSmrg
39707914d74bSmrg	tmp_deplibs=
39717914d74bSmrg	for test_deplib in $deplibs; do
39727914d74bSmrg		case " $convenience " in
39737914d74bSmrg		*" $test_deplib "*) ;;
39747914d74bSmrg		*)
39757914d74bSmrg			tmp_deplibs="$tmp_deplibs $test_deplib"
39767914d74bSmrg			;;
39777914d74bSmrg		esac
39787914d74bSmrg	done
39797914d74bSmrg	deplibs="$tmp_deplibs"
39807914d74bSmrg
39817914d74bSmrg	if test -n "$convenience"; then
39827914d74bSmrg	  if test -n "$whole_archive_flag_spec"; then
39837914d74bSmrg	    save_libobjs=$libobjs
39847914d74bSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
39857914d74bSmrg	  else
39867914d74bSmrg	    gentop="$output_objdir/${outputname}x"
39877914d74bSmrg	    generated="$generated $gentop"
39887914d74bSmrg
39897914d74bSmrg	    func_extract_archives $gentop $convenience
39907914d74bSmrg	    libobjs="$libobjs $func_extract_archives_result"
39917914d74bSmrg	  fi
39927914d74bSmrg	fi
39937914d74bSmrg	
39947914d74bSmrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
39957914d74bSmrg	  eval flag=\"$thread_safe_flag_spec\"
39967914d74bSmrg	  linker_flags="$linker_flags $flag"
39977914d74bSmrg	fi
39987914d74bSmrg
39997914d74bSmrg	# Make a backup of the uninstalled library when relinking
40007914d74bSmrg	if test "$mode" = relink; then
40017914d74bSmrg	  $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $?
40027914d74bSmrg	fi
40037914d74bSmrg
40047914d74bSmrg	# Do each of the archive commands.
40057914d74bSmrg	if test "$module" = yes && test -n "$module_cmds" ; then
40067914d74bSmrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
40077914d74bSmrg	    eval test_cmds=\"$module_expsym_cmds\"
40087914d74bSmrg	    cmds=$module_expsym_cmds
40097914d74bSmrg	  else
40107914d74bSmrg	    eval test_cmds=\"$module_cmds\"
40117914d74bSmrg	    cmds=$module_cmds
40127914d74bSmrg	  fi
40137914d74bSmrg	else
40147914d74bSmrg	if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
40157914d74bSmrg	  eval test_cmds=\"$archive_expsym_cmds\"
40167914d74bSmrg	  cmds=$archive_expsym_cmds
40177914d74bSmrg	else
40187914d74bSmrg	  eval test_cmds=\"$archive_cmds\"
40197914d74bSmrg	  cmds=$archive_cmds
40207914d74bSmrg	  fi
40217914d74bSmrg	fi
40227914d74bSmrg
40237914d74bSmrg	if test "X$skipped_export" != "X:" &&
40247914d74bSmrg	   len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
40257914d74bSmrg	   test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
40267914d74bSmrg	  :
40277914d74bSmrg	else
40287914d74bSmrg	  # The command line is too long to link in one step, link piecewise.
40297914d74bSmrg	  $echo "creating reloadable object files..."
40307914d74bSmrg
40317914d74bSmrg	  # Save the value of $output and $libobjs because we want to
40327914d74bSmrg	  # use them later.  If we have whole_archive_flag_spec, we
40337914d74bSmrg	  # want to use save_libobjs as it was before
40347914d74bSmrg	  # whole_archive_flag_spec was expanded, because we can't
40357914d74bSmrg	  # assume the linker understands whole_archive_flag_spec.
40367914d74bSmrg	  # This may have to be revisited, in case too many
40377914d74bSmrg	  # convenience libraries get linked in and end up exceeding
40387914d74bSmrg	  # the spec.
40397914d74bSmrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
40407914d74bSmrg	    save_libobjs=$libobjs
40417914d74bSmrg	  fi
40427914d74bSmrg	  save_output=$output
40437914d74bSmrg	  output_la=`$echo "X$output" | $Xsed -e "$basename"`
40447914d74bSmrg
40457914d74bSmrg	  # Clear the reloadable object creation command queue and
40467914d74bSmrg	  # initialize k to one.
40477914d74bSmrg	  test_cmds=
40487914d74bSmrg	  concat_cmds=
40497914d74bSmrg	  objlist=
40507914d74bSmrg	  delfiles=
40517914d74bSmrg	  last_robj=
40527914d74bSmrg	  k=1
40537914d74bSmrg	  output=$output_objdir/$output_la-${k}.$objext
40547914d74bSmrg	  # Loop over the list of objects to be linked.
40557914d74bSmrg	  for obj in $save_libobjs
40567914d74bSmrg	  do
40577914d74bSmrg	    eval test_cmds=\"$reload_cmds $objlist $last_robj\"
40587914d74bSmrg	    if test "X$objlist" = X ||
40597914d74bSmrg	       { len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
40607914d74bSmrg		 test "$len" -le "$max_cmd_len"; }; then
40617914d74bSmrg	      objlist="$objlist $obj"
40627914d74bSmrg	    else
40637914d74bSmrg	      # The command $test_cmds is almost too long, add a
40647914d74bSmrg	      # command to the queue.
40657914d74bSmrg	      if test "$k" -eq 1 ; then
40667914d74bSmrg		# The first file doesn't have a previous command to add.
40677914d74bSmrg		eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
40687914d74bSmrg	      else
40697914d74bSmrg		# All subsequent reloadable object files will link in
40707914d74bSmrg		# the last one created.
40717914d74bSmrg		eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\"
40727914d74bSmrg	      fi
40737914d74bSmrg	      last_robj=$output_objdir/$output_la-${k}.$objext
40747914d74bSmrg	      k=`expr $k + 1`
40757914d74bSmrg	      output=$output_objdir/$output_la-${k}.$objext
40767914d74bSmrg	      objlist=$obj
40777914d74bSmrg	      len=1
40787914d74bSmrg	    fi
40797914d74bSmrg	  done
40807914d74bSmrg	  # Handle the remaining objects by creating one last
40817914d74bSmrg	  # reloadable object file.  All subsequent reloadable object
40827914d74bSmrg	  # files will link in the last one created.
40837914d74bSmrg	  test -z "$concat_cmds" || concat_cmds=$concat_cmds~
40847914d74bSmrg	  eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
40857914d74bSmrg
40867914d74bSmrg	  if ${skipped_export-false}; then
40877914d74bSmrg	    $show "generating symbol list for \`$libname.la'"
40887914d74bSmrg	    export_symbols="$output_objdir/$libname.exp"
40897914d74bSmrg	    $run $rm $export_symbols
40907914d74bSmrg	    libobjs=$output
40917914d74bSmrg	    # Append the command to create the export file.
40927914d74bSmrg	    eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\"
40937914d74bSmrg          fi
40947914d74bSmrg
40957914d74bSmrg	  # Set up a command to remove the reloadable object files
40967914d74bSmrg	  # after they are used.
40977914d74bSmrg	  i=0
40987914d74bSmrg	  while test "$i" -lt "$k"
40997914d74bSmrg	  do
41007914d74bSmrg	    i=`expr $i + 1`
41017914d74bSmrg	    delfiles="$delfiles $output_objdir/$output_la-${i}.$objext"
41027914d74bSmrg	  done
41037914d74bSmrg
41047914d74bSmrg	  $echo "creating a temporary reloadable object file: $output"
41057914d74bSmrg
41067914d74bSmrg	  # Loop through the commands generated above and execute them.
41077914d74bSmrg	  save_ifs="$IFS"; IFS='~'
41087914d74bSmrg	  for cmd in $concat_cmds; do
41097914d74bSmrg	    IFS="$save_ifs"
41107914d74bSmrg	    $show "$cmd"
41117914d74bSmrg	    $run eval "$cmd" || exit $?
41127914d74bSmrg	  done
41137914d74bSmrg	  IFS="$save_ifs"
41147914d74bSmrg
41157914d74bSmrg	  libobjs=$output
41167914d74bSmrg	  # Restore the value of output.
41177914d74bSmrg	  output=$save_output
41187914d74bSmrg
41197914d74bSmrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
41207914d74bSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
41217914d74bSmrg	  fi
41227914d74bSmrg	  # Expand the library linking commands again to reset the
41237914d74bSmrg	  # value of $libobjs for piecewise linking.
41247914d74bSmrg
41257914d74bSmrg	  # Do each of the archive commands.
41267914d74bSmrg	  if test "$module" = yes && test -n "$module_cmds" ; then
41277914d74bSmrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
41287914d74bSmrg	      cmds=$module_expsym_cmds
41297914d74bSmrg	    else
41307914d74bSmrg	      cmds=$module_cmds
41317914d74bSmrg	    fi
41327914d74bSmrg	  else
41337914d74bSmrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
41347914d74bSmrg	    cmds=$archive_expsym_cmds
41357914d74bSmrg	  else
41367914d74bSmrg	    cmds=$archive_cmds
41377914d74bSmrg	    fi
41387914d74bSmrg	  fi
41397914d74bSmrg
41407914d74bSmrg	  # Append the command to remove the reloadable object files
41417914d74bSmrg	  # to the just-reset $cmds.
41427914d74bSmrg	  eval cmds=\"\$cmds~\$rm $delfiles\"
41437914d74bSmrg	fi
41447914d74bSmrg	save_ifs="$IFS"; IFS='~'
41457914d74bSmrg	for cmd in $cmds; do
41467914d74bSmrg	  IFS="$save_ifs"
41477914d74bSmrg	  eval cmd=\"$cmd\"
41487914d74bSmrg	  $show "$cmd"
41497914d74bSmrg	  $run eval "$cmd" || {
41507914d74bSmrg	    lt_exit=$?
41517914d74bSmrg
41527914d74bSmrg	    # Restore the uninstalled library and exit
41537914d74bSmrg	    if test "$mode" = relink; then
41547914d74bSmrg	      $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
41557914d74bSmrg	    fi
41567914d74bSmrg
41577914d74bSmrg	    exit $lt_exit
41587914d74bSmrg	  }
41597914d74bSmrg	done
41607914d74bSmrg	IFS="$save_ifs"
41617914d74bSmrg
41627914d74bSmrg	# Restore the uninstalled library and exit
41637914d74bSmrg	if test "$mode" = relink; then
41647914d74bSmrg	  $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $?
41657914d74bSmrg
41667914d74bSmrg	  if test -n "$convenience"; then
41677914d74bSmrg	    if test -z "$whole_archive_flag_spec"; then
41687914d74bSmrg	      $show "${rm}r $gentop"
41697914d74bSmrg	      $run ${rm}r "$gentop"
41707914d74bSmrg	    fi
41717914d74bSmrg	  fi
41727914d74bSmrg
41737914d74bSmrg	  exit $EXIT_SUCCESS
41747914d74bSmrg	fi
41757914d74bSmrg
41767914d74bSmrg	# Create links to the real library.
41777914d74bSmrg	for linkname in $linknames; do
41787914d74bSmrg	  if test "$realname" != "$linkname"; then
41797914d74bSmrg	    $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)"
41807914d74bSmrg	    $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $?
41817914d74bSmrg	  fi
41827914d74bSmrg	done
41837914d74bSmrg
41847914d74bSmrg	# If -module or -export-dynamic was specified, set the dlname.
41857914d74bSmrg	if test "$module" = yes || test "$export_dynamic" = yes; then
41867914d74bSmrg	  # On all known operating systems, these are identical.
41877914d74bSmrg	  dlname="$soname"
41887914d74bSmrg	fi
41897914d74bSmrg      fi
41907914d74bSmrg      ;;
41917914d74bSmrg
41927914d74bSmrg    obj)
41937914d74bSmrg      if test -n "$deplibs"; then
41947914d74bSmrg	$echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2
41957914d74bSmrg      fi
41967914d74bSmrg
41977914d74bSmrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
41987914d74bSmrg	$echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
41997914d74bSmrg      fi
42007914d74bSmrg
42017914d74bSmrg      if test -n "$rpath"; then
42027914d74bSmrg	$echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2
42037914d74bSmrg      fi
42047914d74bSmrg
42057914d74bSmrg      if test -n "$xrpath"; then
42067914d74bSmrg	$echo "$modename: warning: \`-R' is ignored for objects" 1>&2
42077914d74bSmrg      fi
42087914d74bSmrg
42097914d74bSmrg      if test -n "$vinfo"; then
42107914d74bSmrg	$echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2
42117914d74bSmrg      fi
42127914d74bSmrg
42137914d74bSmrg      if test -n "$release"; then
42147914d74bSmrg	$echo "$modename: warning: \`-release' is ignored for objects" 1>&2
42157914d74bSmrg      fi
42167914d74bSmrg
42177914d74bSmrg      case $output in
42187914d74bSmrg      *.lo)
42197914d74bSmrg	if test -n "$objs$old_deplibs"; then
42207914d74bSmrg	  $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
42217914d74bSmrg	  exit $EXIT_FAILURE
42227914d74bSmrg	fi
42237914d74bSmrg	libobj="$output"
42247914d74bSmrg	obj=`$echo "X$output" | $Xsed -e "$lo2o"`
42257914d74bSmrg	;;
42267914d74bSmrg      *)
42277914d74bSmrg	libobj=
42287914d74bSmrg	obj="$output"
42297914d74bSmrg	;;
42307914d74bSmrg      esac
42317914d74bSmrg
42327914d74bSmrg      # Delete the old objects.
42337914d74bSmrg      $run $rm $obj $libobj
42347914d74bSmrg
42357914d74bSmrg      # Objects from convenience libraries.  This assumes
42367914d74bSmrg      # single-version convenience libraries.  Whenever we create
42377914d74bSmrg      # different ones for PIC/non-PIC, this we'll have to duplicate
42387914d74bSmrg      # the extraction.
42397914d74bSmrg      reload_conv_objs=
42407914d74bSmrg      gentop=
42417914d74bSmrg      # reload_cmds runs $LD directly, so let us get rid of
42427914d74bSmrg      # -Wl from whole_archive_flag_spec
42437914d74bSmrg      wl=
42447914d74bSmrg
42457914d74bSmrg      if test -n "$convenience"; then
42467914d74bSmrg	if test -n "$whole_archive_flag_spec"; then
42477914d74bSmrg	  eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
42487914d74bSmrg	else
42497914d74bSmrg	  gentop="$output_objdir/${obj}x"
42507914d74bSmrg	  generated="$generated $gentop"
42517914d74bSmrg
42527914d74bSmrg	  func_extract_archives $gentop $convenience
42537914d74bSmrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
42547914d74bSmrg	fi
42557914d74bSmrg      fi
42567914d74bSmrg
42577914d74bSmrg      # Create the old-style object.
42587914d74bSmrg      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
42597914d74bSmrg
42607914d74bSmrg      output="$obj"
42617914d74bSmrg      cmds=$reload_cmds
42627914d74bSmrg      save_ifs="$IFS"; IFS='~'
42637914d74bSmrg      for cmd in $cmds; do
42647914d74bSmrg	IFS="$save_ifs"
42657914d74bSmrg	eval cmd=\"$cmd\"
42667914d74bSmrg	$show "$cmd"
42677914d74bSmrg	$run eval "$cmd" || exit $?
42687914d74bSmrg      done
42697914d74bSmrg      IFS="$save_ifs"
42707914d74bSmrg
42717914d74bSmrg      # Exit if we aren't doing a library object file.
42727914d74bSmrg      if test -z "$libobj"; then
42737914d74bSmrg	if test -n "$gentop"; then
42747914d74bSmrg	  $show "${rm}r $gentop"
42757914d74bSmrg	  $run ${rm}r $gentop
42767914d74bSmrg	fi
42777914d74bSmrg
42787914d74bSmrg	exit $EXIT_SUCCESS
42797914d74bSmrg      fi
42807914d74bSmrg
42817914d74bSmrg      if test "$build_libtool_libs" != yes; then
42827914d74bSmrg	if test -n "$gentop"; then
42837914d74bSmrg	  $show "${rm}r $gentop"
42847914d74bSmrg	  $run ${rm}r $gentop
42857914d74bSmrg	fi
42867914d74bSmrg
42877914d74bSmrg	# Create an invalid libtool object if no PIC, so that we don't
42887914d74bSmrg	# accidentally link it into a program.
42897914d74bSmrg	# $show "echo timestamp > $libobj"
42907914d74bSmrg	# $run eval "echo timestamp > $libobj" || exit $?
42917914d74bSmrg	exit $EXIT_SUCCESS
42927914d74bSmrg      fi
42937914d74bSmrg
42947914d74bSmrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
42957914d74bSmrg	# Only do commands if we really have different PIC objects.
42967914d74bSmrg	reload_objs="$libobjs $reload_conv_objs"
42977914d74bSmrg	output="$libobj"
42987914d74bSmrg	cmds=$reload_cmds
42997914d74bSmrg	save_ifs="$IFS"; IFS='~'
43007914d74bSmrg	for cmd in $cmds; do
43017914d74bSmrg	  IFS="$save_ifs"
43027914d74bSmrg	  eval cmd=\"$cmd\"
43037914d74bSmrg	  $show "$cmd"
43047914d74bSmrg	  $run eval "$cmd" || exit $?
43057914d74bSmrg	done
43067914d74bSmrg	IFS="$save_ifs"
43077914d74bSmrg      fi
43087914d74bSmrg
43097914d74bSmrg      if test -n "$gentop"; then
43107914d74bSmrg	$show "${rm}r $gentop"
43117914d74bSmrg	$run ${rm}r $gentop
43127914d74bSmrg      fi
43137914d74bSmrg
43147914d74bSmrg      exit $EXIT_SUCCESS
43157914d74bSmrg      ;;
43167914d74bSmrg
43177914d74bSmrg    prog)
43187914d74bSmrg      case $host in
43197914d74bSmrg	*cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;
43207914d74bSmrg      esac
43217914d74bSmrg      if test -n "$vinfo"; then
43227914d74bSmrg	$echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
43237914d74bSmrg      fi
43247914d74bSmrg
43257914d74bSmrg      if test -n "$release"; then
43267914d74bSmrg	$echo "$modename: warning: \`-release' is ignored for programs" 1>&2
43277914d74bSmrg      fi
43287914d74bSmrg
43297914d74bSmrg      if test "$preload" = yes; then
43307914d74bSmrg	if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown &&
43317914d74bSmrg	   test "$dlopen_self_static" = unknown; then
43327914d74bSmrg	  $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support."
43337914d74bSmrg	fi
43347914d74bSmrg      fi
43357914d74bSmrg
43367914d74bSmrg      case $host in
43377914d74bSmrg      *-*-rhapsody* | *-*-darwin1.[012])
43387914d74bSmrg	# On Rhapsody replace the C library is the System framework
43397914d74bSmrg	compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
43407914d74bSmrg	finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
43417914d74bSmrg	;;
43427914d74bSmrg      esac
43437914d74bSmrg
43447914d74bSmrg      case $host in
43457914d74bSmrg      *darwin*)
43467914d74bSmrg        # Don't allow lazy linking, it breaks C++ global constructors
43477914d74bSmrg        if test "$tagname" = CXX ; then
43487914d74bSmrg        compile_command="$compile_command ${wl}-bind_at_load"
43497914d74bSmrg        finalize_command="$finalize_command ${wl}-bind_at_load"
43507914d74bSmrg        fi
43517914d74bSmrg        ;;
43527914d74bSmrg      esac
43537914d74bSmrg
43547914d74bSmrg
43557914d74bSmrg      # move library search paths that coincide with paths to not yet
43567914d74bSmrg      # installed libraries to the beginning of the library search list
43577914d74bSmrg      new_libs=
43587914d74bSmrg      for path in $notinst_path; do
43597914d74bSmrg	case " $new_libs " in
43607914d74bSmrg	*" -L$path/$objdir "*) ;;
43617914d74bSmrg	*)
43627914d74bSmrg	  case " $compile_deplibs " in
43637914d74bSmrg	  *" -L$path/$objdir "*)
43647914d74bSmrg	    new_libs="$new_libs -L$path/$objdir" ;;
43657914d74bSmrg	  esac
43667914d74bSmrg	  ;;
43677914d74bSmrg	esac
43687914d74bSmrg      done
43697914d74bSmrg      for deplib in $compile_deplibs; do
43707914d74bSmrg	case $deplib in
43717914d74bSmrg	-L*)
43727914d74bSmrg	  case " $new_libs " in
43737914d74bSmrg	  *" $deplib "*) ;;
43747914d74bSmrg	  *) new_libs="$new_libs $deplib" ;;
43757914d74bSmrg	  esac
43767914d74bSmrg	  ;;
43777914d74bSmrg	*) new_libs="$new_libs $deplib" ;;
43787914d74bSmrg	esac
43797914d74bSmrg      done
43807914d74bSmrg      compile_deplibs="$new_libs"
43817914d74bSmrg
43827914d74bSmrg
43837914d74bSmrg      compile_command="$compile_command $compile_deplibs"
43847914d74bSmrg      finalize_command="$finalize_command $finalize_deplibs"
43857914d74bSmrg
43867914d74bSmrg      if test -n "$rpath$xrpath"; then
43877914d74bSmrg	# If the user specified any rpath flags, then add them.
43887914d74bSmrg	for libdir in $rpath $xrpath; do
43897914d74bSmrg	  # This is the magic to use -rpath.
43907914d74bSmrg	  case "$finalize_rpath " in
43917914d74bSmrg	  *" $libdir "*) ;;
43927914d74bSmrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
43937914d74bSmrg	  esac
43947914d74bSmrg	done
43957914d74bSmrg      fi
43967914d74bSmrg
43977914d74bSmrg      # Now hardcode the library paths
43987914d74bSmrg      rpath=
43997914d74bSmrg      hardcode_libdirs=
44007914d74bSmrg      for libdir in $compile_rpath $finalize_rpath; do
44017914d74bSmrg	if test -n "$hardcode_libdir_flag_spec"; then
44027914d74bSmrg	  if test -n "$hardcode_libdir_separator"; then
44037914d74bSmrg	    if test -z "$hardcode_libdirs"; then
44047914d74bSmrg	      hardcode_libdirs="$libdir"
44057914d74bSmrg	    else
44067914d74bSmrg	      # Just accumulate the unique libdirs.
44077914d74bSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
44087914d74bSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
44097914d74bSmrg		;;
44107914d74bSmrg	      *)
44117914d74bSmrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
44127914d74bSmrg		;;
44137914d74bSmrg	      esac
44147914d74bSmrg	    fi
44157914d74bSmrg	  else
44167914d74bSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
44177914d74bSmrg	    rpath="$rpath $flag"
44187914d74bSmrg	  fi
44197914d74bSmrg	elif test -n "$runpath_var"; then
44207914d74bSmrg	  case "$perm_rpath " in
44217914d74bSmrg	  *" $libdir "*) ;;
44227914d74bSmrg	  *) perm_rpath="$perm_rpath $libdir" ;;
44237914d74bSmrg	  esac
44247914d74bSmrg	fi
44257914d74bSmrg	case $host in
44267914d74bSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
44277914d74bSmrg	  testbindir=`$echo "X$libdir" | $Xsed -e 's*/lib$*/bin*'`
44287914d74bSmrg	  case :$dllsearchpath: in
44297914d74bSmrg	  *":$libdir:"*) ;;
44307914d74bSmrg	  *) dllsearchpath="$dllsearchpath:$libdir";;
44317914d74bSmrg	  esac
44327914d74bSmrg	  case :$dllsearchpath: in
44337914d74bSmrg	  *":$testbindir:"*) ;;
44347914d74bSmrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
44357914d74bSmrg	  esac
44367914d74bSmrg	  ;;
44377914d74bSmrg	esac
44387914d74bSmrg      done
44397914d74bSmrg      # Substitute the hardcoded libdirs into the rpath.
44407914d74bSmrg      if test -n "$hardcode_libdir_separator" &&
44417914d74bSmrg	 test -n "$hardcode_libdirs"; then
44427914d74bSmrg	libdir="$hardcode_libdirs"
44437914d74bSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
44447914d74bSmrg      fi
44457914d74bSmrg      compile_rpath="$rpath"
44467914d74bSmrg
44477914d74bSmrg      rpath=
44487914d74bSmrg      hardcode_libdirs=
44497914d74bSmrg      for libdir in $finalize_rpath; do
44507914d74bSmrg	if test -n "$hardcode_libdir_flag_spec"; then
44517914d74bSmrg	  if test -n "$hardcode_libdir_separator"; then
44527914d74bSmrg	    if test -z "$hardcode_libdirs"; then
44537914d74bSmrg	      hardcode_libdirs="$libdir"
44547914d74bSmrg	    else
44557914d74bSmrg	      # Just accumulate the unique libdirs.
44567914d74bSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
44577914d74bSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
44587914d74bSmrg		;;
44597914d74bSmrg	      *)
44607914d74bSmrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
44617914d74bSmrg		;;
44627914d74bSmrg	      esac
44637914d74bSmrg	    fi
44647914d74bSmrg	  else
44657914d74bSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
44667914d74bSmrg	    rpath="$rpath $flag"
44677914d74bSmrg	  fi
44687914d74bSmrg	elif test -n "$runpath_var"; then
44697914d74bSmrg	  case "$finalize_perm_rpath " in
44707914d74bSmrg	  *" $libdir "*) ;;
44717914d74bSmrg	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
44727914d74bSmrg	  esac
44737914d74bSmrg	fi
44747914d74bSmrg      done
44757914d74bSmrg      # Substitute the hardcoded libdirs into the rpath.
44767914d74bSmrg      if test -n "$hardcode_libdir_separator" &&
44777914d74bSmrg	 test -n "$hardcode_libdirs"; then
44787914d74bSmrg	libdir="$hardcode_libdirs"
44797914d74bSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
44807914d74bSmrg      fi
44817914d74bSmrg      finalize_rpath="$rpath"
44827914d74bSmrg
44837914d74bSmrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
44847914d74bSmrg	# Transform all the library objects into standard objects.
44857914d74bSmrg	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
44867914d74bSmrg	finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
44877914d74bSmrg      fi
44887914d74bSmrg
44897914d74bSmrg      dlsyms=
44907914d74bSmrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
44917914d74bSmrg	if test -n "$NM" && test -n "$global_symbol_pipe"; then
44927914d74bSmrg	  dlsyms="${outputname}S.c"
44937914d74bSmrg	else
44947914d74bSmrg	  $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2
44957914d74bSmrg	fi
44967914d74bSmrg      fi
44977914d74bSmrg
44987914d74bSmrg      if test -n "$dlsyms"; then
44997914d74bSmrg	case $dlsyms in
45007914d74bSmrg	"") ;;
45017914d74bSmrg	*.c)
45027914d74bSmrg	  # Discover the nlist of each of the dlfiles.
45037914d74bSmrg	  nlist="$output_objdir/${outputname}.nm"
45047914d74bSmrg
45057914d74bSmrg	  $show "$rm $nlist ${nlist}S ${nlist}T"
45067914d74bSmrg	  $run $rm "$nlist" "${nlist}S" "${nlist}T"
45077914d74bSmrg
45087914d74bSmrg	  # Parse the name list into a source file.
45097914d74bSmrg	  $show "creating $output_objdir/$dlsyms"
45107914d74bSmrg
45117914d74bSmrg	  test -z "$run" && $echo > "$output_objdir/$dlsyms" "\
45127914d74bSmrg/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */
45137914d74bSmrg/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */
45147914d74bSmrg
45157914d74bSmrg#ifdef __cplusplus
45167914d74bSmrgextern \"C\" {
45177914d74bSmrg#endif
45187914d74bSmrg
45197914d74bSmrg/* Prevent the only kind of declaration conflicts we can make. */
45207914d74bSmrg#define lt_preloaded_symbols some_other_symbol
45217914d74bSmrg
45227914d74bSmrg/* External symbol declarations for the compiler. */\
45237914d74bSmrg"
45247914d74bSmrg
45257914d74bSmrg	  if test "$dlself" = yes; then
45267914d74bSmrg	    $show "generating symbol list for \`$output'"
45277914d74bSmrg
45287914d74bSmrg	    test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist"
45297914d74bSmrg
45307914d74bSmrg	    # Add our own program objects to the symbol list.
45317914d74bSmrg	    progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
45327914d74bSmrg	    for arg in $progfiles; do
45337914d74bSmrg	      $show "extracting global C symbols from \`$arg'"
45347914d74bSmrg	      $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
45357914d74bSmrg	    done
45367914d74bSmrg
45377914d74bSmrg	    if test -n "$exclude_expsyms"; then
45387914d74bSmrg	      $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
45397914d74bSmrg	      $run eval '$mv "$nlist"T "$nlist"'
45407914d74bSmrg	    fi
45417914d74bSmrg
45427914d74bSmrg	    if test -n "$export_symbols_regex"; then
45437914d74bSmrg	      $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
45447914d74bSmrg	      $run eval '$mv "$nlist"T "$nlist"'
45457914d74bSmrg	    fi
45467914d74bSmrg
45477914d74bSmrg	    # Prepare the list of exported symbols
45487914d74bSmrg	    if test -z "$export_symbols"; then
45497914d74bSmrg	      export_symbols="$output_objdir/$outputname.exp"
45507914d74bSmrg	      $run $rm $export_symbols
45517914d74bSmrg	      $run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
45527914d74bSmrg              case $host in
45537914d74bSmrg              *cygwin* | *mingw* )
45547914d74bSmrg	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
45557914d74bSmrg		$run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
45567914d74bSmrg                ;;
45577914d74bSmrg              esac
45587914d74bSmrg	    else
45597914d74bSmrg	      $run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
45607914d74bSmrg	      $run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
45617914d74bSmrg	      $run eval 'mv "$nlist"T "$nlist"'
45627914d74bSmrg              case $host in
45637914d74bSmrg              *cygwin* | *mingw* )
45647914d74bSmrg	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
45657914d74bSmrg		$run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
45667914d74bSmrg                ;;
45677914d74bSmrg              esac
45687914d74bSmrg	    fi
45697914d74bSmrg	  fi
45707914d74bSmrg
45717914d74bSmrg	  for arg in $dlprefiles; do
45727914d74bSmrg	    $show "extracting global C symbols from \`$arg'"
45737914d74bSmrg	    name=`$echo "$arg" | ${SED} -e 's%^.*/%%'`
45747914d74bSmrg	    $run eval '$echo ": $name " >> "$nlist"'
45757914d74bSmrg	    $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
45767914d74bSmrg	  done
45777914d74bSmrg
45787914d74bSmrg	  if test -z "$run"; then
45797914d74bSmrg	    # Make sure we have at least an empty file.
45807914d74bSmrg	    test -f "$nlist" || : > "$nlist"
45817914d74bSmrg
45827914d74bSmrg	    if test -n "$exclude_expsyms"; then
45837914d74bSmrg	      $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
45847914d74bSmrg	      $mv "$nlist"T "$nlist"
45857914d74bSmrg	    fi
45867914d74bSmrg
45877914d74bSmrg	    # Try sorting and uniquifying the output.
45887914d74bSmrg	    if grep -v "^: " < "$nlist" |
45897914d74bSmrg		if sort -k 3 </dev/null >/dev/null 2>&1; then
45907914d74bSmrg		  sort -k 3
45917914d74bSmrg		else
45927914d74bSmrg		  sort +2
45937914d74bSmrg		fi |
45947914d74bSmrg		uniq > "$nlist"S; then
45957914d74bSmrg	      :
45967914d74bSmrg	    else
45977914d74bSmrg	      grep -v "^: " < "$nlist" > "$nlist"S
45987914d74bSmrg	    fi
45997914d74bSmrg
46007914d74bSmrg	    if test -f "$nlist"S; then
46017914d74bSmrg	      eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"'
46027914d74bSmrg	    else
46037914d74bSmrg	      $echo '/* NONE */' >> "$output_objdir/$dlsyms"
46047914d74bSmrg	    fi
46057914d74bSmrg
46067914d74bSmrg	    $echo >> "$output_objdir/$dlsyms" "\
46077914d74bSmrg
46087914d74bSmrg#undef lt_preloaded_symbols
46097914d74bSmrg
46107914d74bSmrg#if defined (__STDC__) && __STDC__
46117914d74bSmrg# define lt_ptr void *
46127914d74bSmrg#else
46137914d74bSmrg# define lt_ptr char *
46147914d74bSmrg# define const
46157914d74bSmrg#endif
46167914d74bSmrg
46177914d74bSmrg/* The mapping between symbol names and symbols. */
46187914d74bSmrg"
46197914d74bSmrg
46207914d74bSmrg	    case $host in
46217914d74bSmrg	    *cygwin* | *mingw* )
46227914d74bSmrg	  $echo >> "$output_objdir/$dlsyms" "\
46237914d74bSmrg/* DATA imports from DLLs on WIN32 can't be const, because
46247914d74bSmrg   runtime relocations are performed -- see ld's documentation
46257914d74bSmrg   on pseudo-relocs */
46267914d74bSmrgstruct {
46277914d74bSmrg"
46287914d74bSmrg	      ;;
46297914d74bSmrg	    * )
46307914d74bSmrg	  $echo >> "$output_objdir/$dlsyms" "\
46317914d74bSmrgconst struct {
46327914d74bSmrg"
46337914d74bSmrg	      ;;
46347914d74bSmrg	    esac
46357914d74bSmrg
46367914d74bSmrg
46377914d74bSmrg	  $echo >> "$output_objdir/$dlsyms" "\
46387914d74bSmrg  const char *name;
46397914d74bSmrg  lt_ptr address;
46407914d74bSmrg}
46417914d74bSmrglt_preloaded_symbols[] =
46427914d74bSmrg{\
46437914d74bSmrg"
46447914d74bSmrg
46457914d74bSmrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms"
46467914d74bSmrg
46477914d74bSmrg	    $echo >> "$output_objdir/$dlsyms" "\
46487914d74bSmrg  {0, (lt_ptr) 0}
46497914d74bSmrg};
46507914d74bSmrg
46517914d74bSmrg/* This works around a problem in FreeBSD linker */
46527914d74bSmrg#ifdef FREEBSD_WORKAROUND
46537914d74bSmrgstatic const void *lt_preloaded_setup() {
46547914d74bSmrg  return lt_preloaded_symbols;
46557914d74bSmrg}
46567914d74bSmrg#endif
46577914d74bSmrg
46587914d74bSmrg#ifdef __cplusplus
46597914d74bSmrg}
46607914d74bSmrg#endif\
46617914d74bSmrg"
46627914d74bSmrg	  fi
46637914d74bSmrg
46647914d74bSmrg	  pic_flag_for_symtable=
46657914d74bSmrg	  case $host in
46667914d74bSmrg	  # compiling the symbol table file with pic_flag works around
46677914d74bSmrg	  # a FreeBSD bug that causes programs to crash when -lm is
46687914d74bSmrg	  # linked before any other PIC object.  But we must not use
46697914d74bSmrg	  # pic_flag when linking with -static.  The problem exists in
46707914d74bSmrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
46717914d74bSmrg	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
46727914d74bSmrg	    case "$compile_command " in
46737914d74bSmrg	    *" -static "*) ;;
46747914d74bSmrg	    *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";;
46757914d74bSmrg	    esac;;
46767914d74bSmrg	  *-*-hpux*)
46777914d74bSmrg	    case "$compile_command " in
46787914d74bSmrg	    *" -static "*) ;;
46797914d74bSmrg	    *) pic_flag_for_symtable=" $pic_flag";;
46807914d74bSmrg	    esac
46817914d74bSmrg	  esac
46827914d74bSmrg
46837914d74bSmrg	  # Now compile the dynamic symbol file.
46847914d74bSmrg	  $show "(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
46857914d74bSmrg	  $run eval '(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
46867914d74bSmrg
46877914d74bSmrg	  # Clean up the generated files.
46887914d74bSmrg	  $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
46897914d74bSmrg	  $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
46907914d74bSmrg
46917914d74bSmrg	  # Transform the symbol file into the correct name.
46927914d74bSmrg          case $host in
46937914d74bSmrg          *cygwin* | *mingw* )
46947914d74bSmrg            if test -f "$output_objdir/${outputname}.def" ; then
46957914d74bSmrg              compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
46967914d74bSmrg              finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
46977914d74bSmrg            else
46987914d74bSmrg              compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
46997914d74bSmrg              finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
47007914d74bSmrg             fi
47017914d74bSmrg            ;;
47027914d74bSmrg          * )
47037914d74bSmrg            compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
47047914d74bSmrg            finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
47057914d74bSmrg            ;;
47067914d74bSmrg          esac
47077914d74bSmrg	  ;;
47087914d74bSmrg	*)
47097914d74bSmrg	  $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
47107914d74bSmrg	  exit $EXIT_FAILURE
47117914d74bSmrg	  ;;
47127914d74bSmrg	esac
47137914d74bSmrg      else
47147914d74bSmrg	# We keep going just in case the user didn't refer to
47157914d74bSmrg	# lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
47167914d74bSmrg	# really was required.
47177914d74bSmrg
47187914d74bSmrg	# Nullify the symbol file.
47197914d74bSmrg	compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
47207914d74bSmrg	finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
47217914d74bSmrg      fi
47227914d74bSmrg
47237914d74bSmrg      if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
47247914d74bSmrg	# Replace the output file specification.
47257914d74bSmrg	compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
47267914d74bSmrg	link_command="$compile_command$compile_rpath"
47277914d74bSmrg
47287914d74bSmrg	# We have no uninstalled library dependencies, so finalize right now.
47297914d74bSmrg	$show "$link_command"
47307914d74bSmrg	$run eval "$link_command"
47317914d74bSmrg	exit_status=$?
47327914d74bSmrg
47337914d74bSmrg	# Delete the generated files.
47347914d74bSmrg	if test -n "$dlsyms"; then
47357914d74bSmrg	  $show "$rm $output_objdir/${outputname}S.${objext}"
47367914d74bSmrg	  $run $rm "$output_objdir/${outputname}S.${objext}"
47377914d74bSmrg	fi
47387914d74bSmrg
47397914d74bSmrg	exit $exit_status
47407914d74bSmrg      fi
47417914d74bSmrg
47427914d74bSmrg      if test -n "$shlibpath_var"; then
47437914d74bSmrg	# We should set the shlibpath_var
47447914d74bSmrg	rpath=
47457914d74bSmrg	for dir in $temp_rpath; do
47467914d74bSmrg	  case $dir in
47477914d74bSmrg	  [\\/]* | [A-Za-z]:[\\/]*)
47487914d74bSmrg	    # Absolute path.
47497914d74bSmrg	    rpath="$rpath$dir:"
47507914d74bSmrg	    ;;
47517914d74bSmrg	  *)
47527914d74bSmrg	    # Relative path: add a thisdir entry.
47537914d74bSmrg	    rpath="$rpath\$thisdir/$dir:"
47547914d74bSmrg	    ;;
47557914d74bSmrg	  esac
47567914d74bSmrg	done
47577914d74bSmrg	temp_rpath="$rpath"
47587914d74bSmrg      fi
47597914d74bSmrg
47607914d74bSmrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
47617914d74bSmrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
47627914d74bSmrg      fi
47637914d74bSmrg      if test -n "$finalize_shlibpath"; then
47647914d74bSmrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
47657914d74bSmrg      fi
47667914d74bSmrg
47677914d74bSmrg      compile_var=
47687914d74bSmrg      finalize_var=
47697914d74bSmrg      if test -n "$runpath_var"; then
47707914d74bSmrg	if test -n "$perm_rpath"; then
47717914d74bSmrg	  # We should set the runpath_var.
47727914d74bSmrg	  rpath=
47737914d74bSmrg	  for dir in $perm_rpath; do
47747914d74bSmrg	    rpath="$rpath$dir:"
47757914d74bSmrg	  done
47767914d74bSmrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
47777914d74bSmrg	fi
47787914d74bSmrg	if test -n "$finalize_perm_rpath"; then
47797914d74bSmrg	  # We should set the runpath_var.
47807914d74bSmrg	  rpath=
47817914d74bSmrg	  for dir in $finalize_perm_rpath; do
47827914d74bSmrg	    rpath="$rpath$dir:"
47837914d74bSmrg	  done
47847914d74bSmrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
47857914d74bSmrg	fi
47867914d74bSmrg      fi
47877914d74bSmrg
47887914d74bSmrg      if test "$no_install" = yes; then
47897914d74bSmrg	# We don't need to create a wrapper script.
47907914d74bSmrg	link_command="$compile_var$compile_command$compile_rpath"
47917914d74bSmrg	# Replace the output file specification.
47927914d74bSmrg	link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
47937914d74bSmrg	# Delete the old output file.
47947914d74bSmrg	$run $rm $output
47957914d74bSmrg	# Link the executable and exit
47967914d74bSmrg	$show "$link_command"
47977914d74bSmrg	$run eval "$link_command" || exit $?
47987914d74bSmrg	exit $EXIT_SUCCESS
47997914d74bSmrg      fi
48007914d74bSmrg
48017914d74bSmrg      if test "$hardcode_action" = relink; then
48027914d74bSmrg	# Fast installation is not supported
48037914d74bSmrg	link_command="$compile_var$compile_command$compile_rpath"
48047914d74bSmrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
48057914d74bSmrg
48067914d74bSmrg	$echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2
48077914d74bSmrg	$echo "$modename: \`$output' will be relinked during installation" 1>&2
48087914d74bSmrg      else
48097914d74bSmrg	if test "$fast_install" != no; then
48107914d74bSmrg	  link_command="$finalize_var$compile_command$finalize_rpath"
48117914d74bSmrg	  if test "$fast_install" = yes; then
48127914d74bSmrg	    relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
48137914d74bSmrg	  else
48147914d74bSmrg	    # fast_install is set to needless
48157914d74bSmrg	    relink_command=
48167914d74bSmrg	  fi
48177914d74bSmrg	else
48187914d74bSmrg	  link_command="$compile_var$compile_command$compile_rpath"
48197914d74bSmrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
48207914d74bSmrg	fi
48217914d74bSmrg      fi
48227914d74bSmrg
48237914d74bSmrg      # Replace the output file specification.
48247914d74bSmrg      link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
48257914d74bSmrg
48267914d74bSmrg      # Delete the old output files.
48277914d74bSmrg      $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname
48287914d74bSmrg
48297914d74bSmrg      $show "$link_command"
48307914d74bSmrg      $run eval "$link_command" || exit $?
48317914d74bSmrg
48327914d74bSmrg      # Now create the wrapper script.
48337914d74bSmrg      $show "creating $output"
48347914d74bSmrg
48357914d74bSmrg      # Quote the relink command for shipping.
48367914d74bSmrg      if test -n "$relink_command"; then
48377914d74bSmrg	# Preserve any variables that may affect compiler behavior
48387914d74bSmrg	for var in $variables_saved_for_relink; do
48397914d74bSmrg	  if eval test -z \"\${$var+set}\"; then
48407914d74bSmrg	    relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
48417914d74bSmrg	  elif eval var_value=\$$var; test -z "$var_value"; then
48427914d74bSmrg	    relink_command="$var=; export $var; $relink_command"
48437914d74bSmrg	  else
48447914d74bSmrg	    var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
48457914d74bSmrg	    relink_command="$var=\"$var_value\"; export $var; $relink_command"
48467914d74bSmrg	  fi
48477914d74bSmrg	done
48487914d74bSmrg	relink_command="(cd `pwd`; $relink_command)"
48497914d74bSmrg	relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
48507914d74bSmrg      fi
48517914d74bSmrg
48527914d74bSmrg      # Quote $echo for shipping.
48537914d74bSmrg      if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then
48547914d74bSmrg	case $progpath in
48557914d74bSmrg	[\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
48567914d74bSmrg	*) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
48577914d74bSmrg	esac
48587914d74bSmrg	qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"`
48597914d74bSmrg      else
48607914d74bSmrg	qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"`
48617914d74bSmrg      fi
48627914d74bSmrg
48637914d74bSmrg      # Only actually do things if our run command is non-null.
48647914d74bSmrg      if test -z "$run"; then
48657914d74bSmrg	# win32 will think the script is a binary if it has
48667914d74bSmrg	# a .exe suffix, so we strip it off here.
48677914d74bSmrg	case $output in
48687914d74bSmrg	  *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;;
48697914d74bSmrg	esac
48707914d74bSmrg	# test for cygwin because mv fails w/o .exe extensions
48717914d74bSmrg	case $host in
48727914d74bSmrg	  *cygwin*)
48737914d74bSmrg	    exeext=.exe
48747914d74bSmrg	    outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;;
48757914d74bSmrg	  *) exeext= ;;
48767914d74bSmrg	esac
48777914d74bSmrg	case $host in
48787914d74bSmrg	  *cygwin* | *mingw* )
48797914d74bSmrg            output_name=`basename $output`
48807914d74bSmrg            output_path=`dirname $output`
48817914d74bSmrg            cwrappersource="$output_path/$objdir/lt-$output_name.c"
48827914d74bSmrg            cwrapper="$output_path/$output_name.exe"
48837914d74bSmrg            $rm $cwrappersource $cwrapper
48847914d74bSmrg            trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
48857914d74bSmrg
48867914d74bSmrg	    cat > $cwrappersource <<EOF
48877914d74bSmrg
48887914d74bSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
48897914d74bSmrg   Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
48907914d74bSmrg
48917914d74bSmrg   The $output program cannot be directly executed until all the libtool
48927914d74bSmrg   libraries that it depends on are installed.
48937914d74bSmrg
48947914d74bSmrg   This wrapper executable should never be moved out of the build directory.
48957914d74bSmrg   If it is, it will not operate correctly.
48967914d74bSmrg
48977914d74bSmrg   Currently, it simply execs the wrapper *script* "/bin/sh $output",
48987914d74bSmrg   but could eventually absorb all of the scripts functionality and
48997914d74bSmrg   exec $objdir/$outputname directly.
49007914d74bSmrg*/
49017914d74bSmrgEOF
49027914d74bSmrg	    cat >> $cwrappersource<<"EOF"
49037914d74bSmrg#include <stdio.h>
49047914d74bSmrg#include <stdlib.h>
49057914d74bSmrg#include <unistd.h>
49067914d74bSmrg#include <malloc.h>
49077914d74bSmrg#include <stdarg.h>
49087914d74bSmrg#include <assert.h>
49097914d74bSmrg#include <string.h>
49107914d74bSmrg#include <ctype.h>
49117914d74bSmrg#include <sys/stat.h>
49127914d74bSmrg
49137914d74bSmrg#if defined(PATH_MAX)
49147914d74bSmrg# define LT_PATHMAX PATH_MAX
49157914d74bSmrg#elif defined(MAXPATHLEN)
49167914d74bSmrg# define LT_PATHMAX MAXPATHLEN
49177914d74bSmrg#else
49187914d74bSmrg# define LT_PATHMAX 1024
49197914d74bSmrg#endif
49207914d74bSmrg
49217914d74bSmrg#ifndef DIR_SEPARATOR
49227914d74bSmrg# define DIR_SEPARATOR '/'
49237914d74bSmrg# define PATH_SEPARATOR ':'
49247914d74bSmrg#endif
49257914d74bSmrg
49267914d74bSmrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
49277914d74bSmrg  defined (__OS2__)
49287914d74bSmrg# define HAVE_DOS_BASED_FILE_SYSTEM
49297914d74bSmrg# ifndef DIR_SEPARATOR_2
49307914d74bSmrg#  define DIR_SEPARATOR_2 '\\'
49317914d74bSmrg# endif
49327914d74bSmrg# ifndef PATH_SEPARATOR_2
49337914d74bSmrg#  define PATH_SEPARATOR_2 ';'
49347914d74bSmrg# endif
49357914d74bSmrg#endif
49367914d74bSmrg
49377914d74bSmrg#ifndef DIR_SEPARATOR_2
49387914d74bSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
49397914d74bSmrg#else /* DIR_SEPARATOR_2 */
49407914d74bSmrg# define IS_DIR_SEPARATOR(ch) \
49417914d74bSmrg        (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
49427914d74bSmrg#endif /* DIR_SEPARATOR_2 */
49437914d74bSmrg
49447914d74bSmrg#ifndef PATH_SEPARATOR_2
49457914d74bSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
49467914d74bSmrg#else /* PATH_SEPARATOR_2 */
49477914d74bSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
49487914d74bSmrg#endif /* PATH_SEPARATOR_2 */
49497914d74bSmrg
49507914d74bSmrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
49517914d74bSmrg#define XFREE(stale) do { \
49527914d74bSmrg  if (stale) { free ((void *) stale); stale = 0; } \
49537914d74bSmrg} while (0)
49547914d74bSmrg
49557914d74bSmrg/* -DDEBUG is fairly common in CFLAGS.  */
49567914d74bSmrg#undef DEBUG
49577914d74bSmrg#if defined DEBUGWRAPPER
49587914d74bSmrg# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
49597914d74bSmrg#else
49607914d74bSmrg# define DEBUG(format, ...)
49617914d74bSmrg#endif
49627914d74bSmrg
49637914d74bSmrgconst char *program_name = NULL;
49647914d74bSmrg
49657914d74bSmrgvoid * xmalloc (size_t num);
49667914d74bSmrgchar * xstrdup (const char *string);
49677914d74bSmrgconst char * base_name (const char *name);
49687914d74bSmrgchar * find_executable(const char *wrapper);
49697914d74bSmrgint    check_executable(const char *path);
49707914d74bSmrgchar * strendzap(char *str, const char *pat);
49717914d74bSmrgvoid lt_fatal (const char *message, ...);
49727914d74bSmrg
49737914d74bSmrgint
49747914d74bSmrgmain (int argc, char *argv[])
49757914d74bSmrg{
49767914d74bSmrg  char **newargz;
49777914d74bSmrg  int i;
49787914d74bSmrg
49797914d74bSmrg  program_name = (char *) xstrdup (base_name (argv[0]));
49807914d74bSmrg  DEBUG("(main) argv[0]      : %s\n",argv[0]);
49817914d74bSmrg  DEBUG("(main) program_name : %s\n",program_name);
49827914d74bSmrg  newargz = XMALLOC(char *, argc+2);
49837914d74bSmrgEOF
49847914d74bSmrg
49857914d74bSmrg            cat >> $cwrappersource <<EOF
49867914d74bSmrg  newargz[0] = (char *) xstrdup("$SHELL");
49877914d74bSmrgEOF
49887914d74bSmrg
49897914d74bSmrg            cat >> $cwrappersource <<"EOF"
49907914d74bSmrg  newargz[1] = find_executable(argv[0]);
49917914d74bSmrg  if (newargz[1] == NULL)
49927914d74bSmrg    lt_fatal("Couldn't find %s", argv[0]);
49937914d74bSmrg  DEBUG("(main) found exe at : %s\n",newargz[1]);
49947914d74bSmrg  /* we know the script has the same name, without the .exe */
49957914d74bSmrg  /* so make sure newargz[1] doesn't end in .exe */
49967914d74bSmrg  strendzap(newargz[1],".exe");
49977914d74bSmrg  for (i = 1; i < argc; i++)
49987914d74bSmrg    newargz[i+1] = xstrdup(argv[i]);
49997914d74bSmrg  newargz[argc+1] = NULL;
50007914d74bSmrg
50017914d74bSmrg  for (i=0; i<argc+1; i++)
50027914d74bSmrg  {
50037914d74bSmrg    DEBUG("(main) newargz[%d]   : %s\n",i,newargz[i]);
50047914d74bSmrg    ;
50057914d74bSmrg  }
50067914d74bSmrg
50077914d74bSmrgEOF
50087914d74bSmrg
50097914d74bSmrg            case $host_os in
50107914d74bSmrg              mingw*)
50117914d74bSmrg                cat >> $cwrappersource <<EOF
50127914d74bSmrg  execv("$SHELL",(char const **)newargz);
50137914d74bSmrgEOF
50147914d74bSmrg              ;;
50157914d74bSmrg              *)
50167914d74bSmrg                cat >> $cwrappersource <<EOF
50177914d74bSmrg  execv("$SHELL",newargz);
50187914d74bSmrgEOF
50197914d74bSmrg              ;;
50207914d74bSmrg            esac
50217914d74bSmrg
50227914d74bSmrg            cat >> $cwrappersource <<"EOF"
50237914d74bSmrg  return 127;
50247914d74bSmrg}
50257914d74bSmrg
50267914d74bSmrgvoid *
50277914d74bSmrgxmalloc (size_t num)
50287914d74bSmrg{
50297914d74bSmrg  void * p = (void *) malloc (num);
50307914d74bSmrg  if (!p)
50317914d74bSmrg    lt_fatal ("Memory exhausted");
50327914d74bSmrg
50337914d74bSmrg  return p;
50347914d74bSmrg}
50357914d74bSmrg
50367914d74bSmrgchar *
50377914d74bSmrgxstrdup (const char *string)
50387914d74bSmrg{
50397914d74bSmrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL
50407914d74bSmrg;
50417914d74bSmrg}
50427914d74bSmrg
50437914d74bSmrgconst char *
50447914d74bSmrgbase_name (const char *name)
50457914d74bSmrg{
50467914d74bSmrg  const char *base;
50477914d74bSmrg
50487914d74bSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
50497914d74bSmrg  /* Skip over the disk name in MSDOS pathnames. */
50507914d74bSmrg  if (isalpha ((unsigned char)name[0]) && name[1] == ':')
50517914d74bSmrg    name += 2;
50527914d74bSmrg#endif
50537914d74bSmrg
50547914d74bSmrg  for (base = name; *name; name++)
50557914d74bSmrg    if (IS_DIR_SEPARATOR (*name))
50567914d74bSmrg      base = name + 1;
50577914d74bSmrg  return base;
50587914d74bSmrg}
50597914d74bSmrg
50607914d74bSmrgint
50617914d74bSmrgcheck_executable(const char * path)
50627914d74bSmrg{
50637914d74bSmrg  struct stat st;
50647914d74bSmrg
50657914d74bSmrg  DEBUG("(check_executable)  : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!");
50667914d74bSmrg  if ((!path) || (!*path))
50677914d74bSmrg    return 0;
50687914d74bSmrg
50697914d74bSmrg  if ((stat (path, &st) >= 0) &&
50707914d74bSmrg      (
50717914d74bSmrg        /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */
50727914d74bSmrg#if defined (S_IXOTH)
50737914d74bSmrg       ((st.st_mode & S_IXOTH) == S_IXOTH) ||
50747914d74bSmrg#endif
50757914d74bSmrg#if defined (S_IXGRP)
50767914d74bSmrg       ((st.st_mode & S_IXGRP) == S_IXGRP) ||
50777914d74bSmrg#endif
50787914d74bSmrg       ((st.st_mode & S_IXUSR) == S_IXUSR))
50797914d74bSmrg      )
50807914d74bSmrg    return 1;
50817914d74bSmrg  else
50827914d74bSmrg    return 0;
50837914d74bSmrg}
50847914d74bSmrg
50857914d74bSmrg/* Searches for the full path of the wrapper.  Returns
50867914d74bSmrg   newly allocated full path name if found, NULL otherwise */
50877914d74bSmrgchar *
50887914d74bSmrgfind_executable (const char* wrapper)
50897914d74bSmrg{
50907914d74bSmrg  int has_slash = 0;
50917914d74bSmrg  const char* p;
50927914d74bSmrg  const char* p_next;
50937914d74bSmrg  /* static buffer for getcwd */
50947914d74bSmrg  char tmp[LT_PATHMAX + 1];
50957914d74bSmrg  int tmp_len;
50967914d74bSmrg  char* concat_name;
50977914d74bSmrg
50987914d74bSmrg  DEBUG("(find_executable)  : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!");
50997914d74bSmrg
51007914d74bSmrg  if ((wrapper == NULL) || (*wrapper == '\0'))
51017914d74bSmrg    return NULL;
51027914d74bSmrg
51037914d74bSmrg  /* Absolute path? */
51047914d74bSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
51057914d74bSmrg  if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':')
51067914d74bSmrg  {
51077914d74bSmrg    concat_name = xstrdup (wrapper);
51087914d74bSmrg    if (check_executable(concat_name))
51097914d74bSmrg      return concat_name;
51107914d74bSmrg    XFREE(concat_name);
51117914d74bSmrg  }
51127914d74bSmrg  else
51137914d74bSmrg  {
51147914d74bSmrg#endif
51157914d74bSmrg    if (IS_DIR_SEPARATOR (wrapper[0]))
51167914d74bSmrg    {
51177914d74bSmrg      concat_name = xstrdup (wrapper);
51187914d74bSmrg      if (check_executable(concat_name))
51197914d74bSmrg        return concat_name;
51207914d74bSmrg      XFREE(concat_name);
51217914d74bSmrg    }
51227914d74bSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
51237914d74bSmrg  }
51247914d74bSmrg#endif
51257914d74bSmrg
51267914d74bSmrg  for (p = wrapper; *p; p++)
51277914d74bSmrg    if (*p == '/')
51287914d74bSmrg    {
51297914d74bSmrg      has_slash = 1;
51307914d74bSmrg      break;
51317914d74bSmrg    }
51327914d74bSmrg  if (!has_slash)
51337914d74bSmrg  {
51347914d74bSmrg    /* no slashes; search PATH */
51357914d74bSmrg    const char* path = getenv ("PATH");
51367914d74bSmrg    if (path != NULL)
51377914d74bSmrg    {
51387914d74bSmrg      for (p = path; *p; p = p_next)
51397914d74bSmrg      {
51407914d74bSmrg        const char* q;
51417914d74bSmrg        size_t p_len;
51427914d74bSmrg        for (q = p; *q; q++)
51437914d74bSmrg          if (IS_PATH_SEPARATOR(*q))
51447914d74bSmrg            break;
51457914d74bSmrg        p_len = q - p;
51467914d74bSmrg        p_next = (*q == '\0' ? q : q + 1);
51477914d74bSmrg        if (p_len == 0)
51487914d74bSmrg        {
51497914d74bSmrg          /* empty path: current directory */
51507914d74bSmrg          if (getcwd (tmp, LT_PATHMAX) == NULL)
51517914d74bSmrg            lt_fatal ("getcwd failed");
51527914d74bSmrg          tmp_len = strlen(tmp);
51537914d74bSmrg          concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
51547914d74bSmrg          memcpy (concat_name, tmp, tmp_len);
51557914d74bSmrg          concat_name[tmp_len] = '/';
51567914d74bSmrg          strcpy (concat_name + tmp_len + 1, wrapper);
51577914d74bSmrg        }
51587914d74bSmrg        else
51597914d74bSmrg        {
51607914d74bSmrg          concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1);
51617914d74bSmrg          memcpy (concat_name, p, p_len);
51627914d74bSmrg          concat_name[p_len] = '/';
51637914d74bSmrg          strcpy (concat_name + p_len + 1, wrapper);
51647914d74bSmrg        }
51657914d74bSmrg        if (check_executable(concat_name))
51667914d74bSmrg          return concat_name;
51677914d74bSmrg        XFREE(concat_name);
51687914d74bSmrg      }
51697914d74bSmrg    }
51707914d74bSmrg    /* not found in PATH; assume curdir */
51717914d74bSmrg  }
51727914d74bSmrg  /* Relative path | not found in path: prepend cwd */
51737914d74bSmrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
51747914d74bSmrg    lt_fatal ("getcwd failed");
51757914d74bSmrg  tmp_len = strlen(tmp);
51767914d74bSmrg  concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
51777914d74bSmrg  memcpy (concat_name, tmp, tmp_len);
51787914d74bSmrg  concat_name[tmp_len] = '/';
51797914d74bSmrg  strcpy (concat_name + tmp_len + 1, wrapper);
51807914d74bSmrg
51817914d74bSmrg  if (check_executable(concat_name))
51827914d74bSmrg    return concat_name;
51837914d74bSmrg  XFREE(concat_name);
51847914d74bSmrg  return NULL;
51857914d74bSmrg}
51867914d74bSmrg
51877914d74bSmrgchar *
51887914d74bSmrgstrendzap(char *str, const char *pat)
51897914d74bSmrg{
51907914d74bSmrg  size_t len, patlen;
51917914d74bSmrg
51927914d74bSmrg  assert(str != NULL);
51937914d74bSmrg  assert(pat != NULL);
51947914d74bSmrg
51957914d74bSmrg  len = strlen(str);
51967914d74bSmrg  patlen = strlen(pat);
51977914d74bSmrg
51987914d74bSmrg  if (patlen <= len)
51997914d74bSmrg  {
52007914d74bSmrg    str += len - patlen;
52017914d74bSmrg    if (strcmp(str, pat) == 0)
52027914d74bSmrg      *str = '\0';
52037914d74bSmrg  }
52047914d74bSmrg  return str;
52057914d74bSmrg}
52067914d74bSmrg
52077914d74bSmrgstatic void
52087914d74bSmrglt_error_core (int exit_status, const char * mode,
52097914d74bSmrg          const char * message, va_list ap)
52107914d74bSmrg{
52117914d74bSmrg  fprintf (stderr, "%s: %s: ", program_name, mode);
52127914d74bSmrg  vfprintf (stderr, message, ap);
52137914d74bSmrg  fprintf (stderr, ".\n");
52147914d74bSmrg
52157914d74bSmrg  if (exit_status >= 0)
52167914d74bSmrg    exit (exit_status);
52177914d74bSmrg}
52187914d74bSmrg
52197914d74bSmrgvoid
52207914d74bSmrglt_fatal (const char *message, ...)
52217914d74bSmrg{
52227914d74bSmrg  va_list ap;
52237914d74bSmrg  va_start (ap, message);
52247914d74bSmrg  lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
52257914d74bSmrg  va_end (ap);
52267914d74bSmrg}
52277914d74bSmrgEOF
52287914d74bSmrg          # we should really use a build-platform specific compiler
52297914d74bSmrg          # here, but OTOH, the wrappers (shell script and this C one)
52307914d74bSmrg          # are only useful if you want to execute the "real" binary.
52317914d74bSmrg          # Since the "real" binary is built for $host, then this
52327914d74bSmrg          # wrapper might as well be built for $host, too.
52337914d74bSmrg          $run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource
52347914d74bSmrg          ;;
52357914d74bSmrg        esac
52367914d74bSmrg        $rm $output
52377914d74bSmrg        trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
52387914d74bSmrg
52397914d74bSmrg	$echo > $output "\
52407914d74bSmrg#! $SHELL
52417914d74bSmrg
52427914d74bSmrg# $output - temporary wrapper script for $objdir/$outputname
52437914d74bSmrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
52447914d74bSmrg#
52457914d74bSmrg# The $output program cannot be directly executed until all the libtool
52467914d74bSmrg# libraries that it depends on are installed.
52477914d74bSmrg#
52487914d74bSmrg# This wrapper script should never be moved out of the build directory.
52497914d74bSmrg# If it is, it will not operate correctly.
52507914d74bSmrg
52517914d74bSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
52527914d74bSmrg# metacharacters that are still active within double-quoted strings.
52537914d74bSmrgXsed='${SED} -e 1s/^X//'
52547914d74bSmrgsed_quote_subst='$sed_quote_subst'
52557914d74bSmrg
52567914d74bSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout
52577914d74bSmrg# if CDPATH is set.
52587914d74bSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
52597914d74bSmrg
52607914d74bSmrgrelink_command=\"$relink_command\"
52617914d74bSmrg
52627914d74bSmrg# This environment variable determines our operation mode.
52637914d74bSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then
52647914d74bSmrg  # install mode needs the following variable:
52657914d74bSmrg  notinst_deplibs='$notinst_deplibs'
52667914d74bSmrgelse
52677914d74bSmrg  # When we are sourced in execute mode, \$file and \$echo are already set.
52687914d74bSmrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
52697914d74bSmrg    echo=\"$qecho\"
52707914d74bSmrg    file=\"\$0\"
52717914d74bSmrg    # Make sure echo works.
52727914d74bSmrg    if test \"X\$1\" = X--no-reexec; then
52737914d74bSmrg      # Discard the --no-reexec flag, and continue.
52747914d74bSmrg      shift
52757914d74bSmrg    elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then
52767914d74bSmrg      # Yippee, \$echo works!
52777914d74bSmrg      :
52787914d74bSmrg    else
52797914d74bSmrg      # Restart under the correct shell, and then maybe \$echo will work.
52807914d74bSmrg      exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
52817914d74bSmrg    fi
52827914d74bSmrg  fi\
52837914d74bSmrg"
52847914d74bSmrg	$echo >> $output "\
52857914d74bSmrg
52867914d74bSmrg  # Find the directory that this script lives in.
52877914d74bSmrg  thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
52887914d74bSmrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
52897914d74bSmrg
52907914d74bSmrg  # Follow symbolic links until we get to the real thisdir.
52917914d74bSmrg  file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
52927914d74bSmrg  while test -n \"\$file\"; do
52937914d74bSmrg    destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
52947914d74bSmrg
52957914d74bSmrg    # If there was a directory component, then change thisdir.
52967914d74bSmrg    if test \"x\$destdir\" != \"x\$file\"; then
52977914d74bSmrg      case \"\$destdir\" in
52987914d74bSmrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
52997914d74bSmrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
53007914d74bSmrg      esac
53017914d74bSmrg    fi
53027914d74bSmrg
53037914d74bSmrg    file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
53047914d74bSmrg    file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
53057914d74bSmrg  done
53067914d74bSmrg
53077914d74bSmrg  # Try to get the absolute directory name.
53087914d74bSmrg  absdir=\`cd \"\$thisdir\" && pwd\`
53097914d74bSmrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
53107914d74bSmrg"
53117914d74bSmrg
53127914d74bSmrg	if test "$fast_install" = yes; then
53137914d74bSmrg	  $echo >> $output "\
53147914d74bSmrg  program=lt-'$outputname'$exeext
53157914d74bSmrg  progdir=\"\$thisdir/$objdir\"
53167914d74bSmrg
53177914d74bSmrg  if test ! -f \"\$progdir/\$program\" || \\
53187914d74bSmrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
53197914d74bSmrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
53207914d74bSmrg
53217914d74bSmrg    file=\"\$\$-\$program\"
53227914d74bSmrg
53237914d74bSmrg    if test ! -d \"\$progdir\"; then
53247914d74bSmrg      $mkdir \"\$progdir\"
53257914d74bSmrg    else
53267914d74bSmrg      $rm \"\$progdir/\$file\"
53277914d74bSmrg    fi"
53287914d74bSmrg
53297914d74bSmrg	  $echo >> $output "\
53307914d74bSmrg
53317914d74bSmrg    # relink executable if necessary
53327914d74bSmrg    if test -n \"\$relink_command\"; then
53337914d74bSmrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
53347914d74bSmrg      else
53357914d74bSmrg	$echo \"\$relink_command_output\" >&2
53367914d74bSmrg	$rm \"\$progdir/\$file\"
53377914d74bSmrg	exit $EXIT_FAILURE
53387914d74bSmrg      fi
53397914d74bSmrg    fi
53407914d74bSmrg
53417914d74bSmrg    $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
53427914d74bSmrg    { $rm \"\$progdir/\$program\";
53437914d74bSmrg      $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
53447914d74bSmrg    $rm \"\$progdir/\$file\"
53457914d74bSmrg  fi"
53467914d74bSmrg	else
53477914d74bSmrg	  $echo >> $output "\
53487914d74bSmrg  program='$outputname'
53497914d74bSmrg  progdir=\"\$thisdir/$objdir\"
53507914d74bSmrg"
53517914d74bSmrg	fi
53527914d74bSmrg
53537914d74bSmrg	$echo >> $output "\
53547914d74bSmrg
53557914d74bSmrg  if test -f \"\$progdir/\$program\"; then"
53567914d74bSmrg
53577914d74bSmrg	# Export our shlibpath_var if we have one.
53587914d74bSmrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
53597914d74bSmrg	  $echo >> $output "\
53607914d74bSmrg    # Add our own library path to $shlibpath_var
53617914d74bSmrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
53627914d74bSmrg
53637914d74bSmrg    # Some systems cannot cope with colon-terminated $shlibpath_var
53647914d74bSmrg    # The second colon is a workaround for a bug in BeOS R4 sed
53657914d74bSmrg    $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
53667914d74bSmrg
53677914d74bSmrg    export $shlibpath_var
53687914d74bSmrg"
53697914d74bSmrg	fi
53707914d74bSmrg
53717914d74bSmrg	# fixup the dll searchpath if we need to.
53727914d74bSmrg	if test -n "$dllsearchpath"; then
53737914d74bSmrg	  $echo >> $output "\
53747914d74bSmrg    # Add the dll search path components to the executable PATH
53757914d74bSmrg    PATH=$dllsearchpath:\$PATH
53767914d74bSmrg"
53777914d74bSmrg	fi
53787914d74bSmrg
53797914d74bSmrg	$echo >> $output "\
53807914d74bSmrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
53817914d74bSmrg      # Run the actual program with our arguments.
53827914d74bSmrg"
53837914d74bSmrg	case $host in
53847914d74bSmrg	# Backslashes separate directories on plain windows
53857914d74bSmrg	*-*-mingw | *-*-os2*)
53867914d74bSmrg	  $echo >> $output "\
53877914d74bSmrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
53887914d74bSmrg"
53897914d74bSmrg	  ;;
53907914d74bSmrg
53917914d74bSmrg	*)
53927914d74bSmrg	  $echo >> $output "\
53937914d74bSmrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
53947914d74bSmrg"
53957914d74bSmrg	  ;;
53967914d74bSmrg	esac
53977914d74bSmrg	$echo >> $output "\
53987914d74bSmrg      \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\"
53997914d74bSmrg      exit $EXIT_FAILURE
54007914d74bSmrg    fi
54017914d74bSmrg  else
54027914d74bSmrg    # The program doesn't exist.
54037914d74bSmrg    \$echo \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
54047914d74bSmrg    \$echo \"This script is just a wrapper for \$program.\" 1>&2
54057914d74bSmrg    $echo \"See the $PACKAGE documentation for more information.\" 1>&2
54067914d74bSmrg    exit $EXIT_FAILURE
54077914d74bSmrg  fi
54087914d74bSmrgfi\
54097914d74bSmrg"
54107914d74bSmrg	chmod +x $output
54117914d74bSmrg      fi
54127914d74bSmrg      exit $EXIT_SUCCESS
54137914d74bSmrg      ;;
54147914d74bSmrg    esac
54157914d74bSmrg
54167914d74bSmrg    # See if we need to build an old-fashioned archive.
54177914d74bSmrg    for oldlib in $oldlibs; do
54187914d74bSmrg
54197914d74bSmrg      if test "$build_libtool_libs" = convenience; then
54207914d74bSmrg	oldobjs="$libobjs_save"
54217914d74bSmrg	addlibs="$convenience"
54227914d74bSmrg	build_libtool_libs=no
54237914d74bSmrg      else
54247914d74bSmrg	if test "$build_libtool_libs" = module; then
54257914d74bSmrg	  oldobjs="$libobjs_save"
54267914d74bSmrg	  build_libtool_libs=no
54277914d74bSmrg	else
54287914d74bSmrg	  oldobjs="$old_deplibs $non_pic_objects"
54297914d74bSmrg	fi
54307914d74bSmrg	addlibs="$old_convenience"
54317914d74bSmrg      fi
54327914d74bSmrg
54337914d74bSmrg      if test -n "$addlibs"; then
54347914d74bSmrg	gentop="$output_objdir/${outputname}x"
54357914d74bSmrg	generated="$generated $gentop"
54367914d74bSmrg
54377914d74bSmrg	func_extract_archives $gentop $addlibs
54387914d74bSmrg	oldobjs="$oldobjs $func_extract_archives_result"
54397914d74bSmrg      fi
54407914d74bSmrg
54417914d74bSmrg      # Do each command in the archive commands.
54427914d74bSmrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
54437914d74bSmrg       cmds=$old_archive_from_new_cmds
54447914d74bSmrg      else
54457914d74bSmrg	# POSIX demands no paths to be encoded in archives.  We have
54467914d74bSmrg	# to avoid creating archives with duplicate basenames if we
54477914d74bSmrg	# might have to extract them afterwards, e.g., when creating a
54487914d74bSmrg	# static archive out of a convenience library, or when linking
54497914d74bSmrg	# the entirety of a libtool archive into another (currently
54507914d74bSmrg	# not supported by libtool).
54517914d74bSmrg	if (for obj in $oldobjs
54527914d74bSmrg	    do
54537914d74bSmrg	      $echo "X$obj" | $Xsed -e 's%^.*/%%'
54547914d74bSmrg	    done | sort | sort -uc >/dev/null 2>&1); then
54557914d74bSmrg	  :
54567914d74bSmrg	else
54577914d74bSmrg	  $echo "copying selected object files to avoid basename conflicts..."
54587914d74bSmrg
54597914d74bSmrg	  if test -z "$gentop"; then
54607914d74bSmrg	    gentop="$output_objdir/${outputname}x"
54617914d74bSmrg	    generated="$generated $gentop"
54627914d74bSmrg
54637914d74bSmrg	    $show "${rm}r $gentop"
54647914d74bSmrg	    $run ${rm}r "$gentop"
54657914d74bSmrg	    $show "$mkdir $gentop"
54667914d74bSmrg	    $run $mkdir "$gentop"
54677914d74bSmrg	    exit_status=$?
54687914d74bSmrg	    if test "$exit_status" -ne 0 && test ! -d "$gentop"; then
54697914d74bSmrg	      exit $exit_status
54707914d74bSmrg	    fi
54717914d74bSmrg	  fi
54727914d74bSmrg
54737914d74bSmrg	  save_oldobjs=$oldobjs
54747914d74bSmrg	  oldobjs=
54757914d74bSmrg	  counter=1
54767914d74bSmrg	  for obj in $save_oldobjs
54777914d74bSmrg	  do
54787914d74bSmrg	    objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
54797914d74bSmrg	    case " $oldobjs " in
54807914d74bSmrg	    " ") oldobjs=$obj ;;
54817914d74bSmrg	    *[\ /]"$objbase "*)
54827914d74bSmrg	      while :; do
54837914d74bSmrg		# Make sure we don't pick an alternate name that also
54847914d74bSmrg		# overlaps.
54857914d74bSmrg		newobj=lt$counter-$objbase
54867914d74bSmrg		counter=`expr $counter + 1`
54877914d74bSmrg		case " $oldobjs " in
54887914d74bSmrg		*[\ /]"$newobj "*) ;;
54897914d74bSmrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
54907914d74bSmrg		esac
54917914d74bSmrg	      done
54927914d74bSmrg	      $show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
54937914d74bSmrg	      $run ln "$obj" "$gentop/$newobj" ||
54947914d74bSmrg	      $run cp "$obj" "$gentop/$newobj"
54957914d74bSmrg	      oldobjs="$oldobjs $gentop/$newobj"
54967914d74bSmrg	      ;;
54977914d74bSmrg	    *) oldobjs="$oldobjs $obj" ;;
54987914d74bSmrg	    esac
54997914d74bSmrg	  done
55007914d74bSmrg	fi
55017914d74bSmrg
55027914d74bSmrg	eval cmds=\"$old_archive_cmds\"
55037914d74bSmrg
55047914d74bSmrg	if len=`expr "X$cmds" : ".*"` &&
55057914d74bSmrg	     test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
55067914d74bSmrg	  cmds=$old_archive_cmds
55077914d74bSmrg	else
55087914d74bSmrg	  # the command line is too long to link in one step, link in parts
55097914d74bSmrg	  $echo "using piecewise archive linking..."
55107914d74bSmrg	  save_RANLIB=$RANLIB
55117914d74bSmrg	  RANLIB=:
55127914d74bSmrg	  objlist=
55137914d74bSmrg	  concat_cmds=
55147914d74bSmrg	  save_oldobjs=$oldobjs
55157914d74bSmrg
55167914d74bSmrg	  # Is there a better way of finding the last object in the list?
55177914d74bSmrg	  for obj in $save_oldobjs
55187914d74bSmrg	  do
55197914d74bSmrg	    last_oldobj=$obj
55207914d74bSmrg	  done
55217914d74bSmrg	  for obj in $save_oldobjs
55227914d74bSmrg	  do
55237914d74bSmrg	    oldobjs="$objlist $obj"
55247914d74bSmrg	    objlist="$objlist $obj"
55257914d74bSmrg	    eval test_cmds=\"$old_archive_cmds\"
55267914d74bSmrg	    if len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
55277914d74bSmrg	       test "$len" -le "$max_cmd_len"; then
55287914d74bSmrg	      :
55297914d74bSmrg	    else
55307914d74bSmrg	      # the above command should be used before it gets too long
55317914d74bSmrg	      oldobjs=$objlist
55327914d74bSmrg	      if test "$obj" = "$last_oldobj" ; then
55337914d74bSmrg	        RANLIB=$save_RANLIB
55347914d74bSmrg	      fi
55357914d74bSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
55367914d74bSmrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
55377914d74bSmrg	      objlist=
55387914d74bSmrg	    fi
55397914d74bSmrg	  done
55407914d74bSmrg	  RANLIB=$save_RANLIB
55417914d74bSmrg	  oldobjs=$objlist
55427914d74bSmrg	  if test "X$oldobjs" = "X" ; then
55437914d74bSmrg	    eval cmds=\"\$concat_cmds\"
55447914d74bSmrg	  else
55457914d74bSmrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
55467914d74bSmrg	  fi
55477914d74bSmrg	fi
55487914d74bSmrg      fi
55497914d74bSmrg      save_ifs="$IFS"; IFS='~'
55507914d74bSmrg      for cmd in $cmds; do
55517914d74bSmrg        eval cmd=\"$cmd\"
55527914d74bSmrg	IFS="$save_ifs"
55537914d74bSmrg	$show "$cmd"
55547914d74bSmrg	$run eval "$cmd" || exit $?
55557914d74bSmrg      done
55567914d74bSmrg      IFS="$save_ifs"
55577914d74bSmrg    done
55587914d74bSmrg
55597914d74bSmrg    if test -n "$generated"; then
55607914d74bSmrg      $show "${rm}r$generated"
55617914d74bSmrg      $run ${rm}r$generated
55627914d74bSmrg    fi
55637914d74bSmrg
55647914d74bSmrg    # Now create the libtool archive.
55657914d74bSmrg    case $output in
55667914d74bSmrg    *.la)
55677914d74bSmrg      old_library=
55687914d74bSmrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
55697914d74bSmrg      $show "creating $output"
55707914d74bSmrg
55717914d74bSmrg      # Preserve any variables that may affect compiler behavior
55727914d74bSmrg      for var in $variables_saved_for_relink; do
55737914d74bSmrg	if eval test -z \"\${$var+set}\"; then
55747914d74bSmrg	  relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
55757914d74bSmrg	elif eval var_value=\$$var; test -z "$var_value"; then
55767914d74bSmrg	  relink_command="$var=; export $var; $relink_command"
55777914d74bSmrg	else
55787914d74bSmrg	  var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
55797914d74bSmrg	  relink_command="$var=\"$var_value\"; export $var; $relink_command"
55807914d74bSmrg	fi
55817914d74bSmrg      done
55827914d74bSmrg      # Quote the link command for shipping.
55837914d74bSmrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
55847914d74bSmrg      relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
55857914d74bSmrg      if test "$hardcode_automatic" = yes ; then
55867914d74bSmrg	relink_command=
55877914d74bSmrg      fi
55887914d74bSmrg
55897914d74bSmrg
55907914d74bSmrg      # Only create the output if not a dry run.
55917914d74bSmrg      if test -z "$run"; then
55927914d74bSmrg	for installed in no yes; do
55937914d74bSmrg	  if test "$installed" = yes; then
55947914d74bSmrg	    if test -z "$install_libdir"; then
55957914d74bSmrg	      break
55967914d74bSmrg	    fi
55977914d74bSmrg	    output="$output_objdir/$outputname"i
55987914d74bSmrg	    # Replace all uninstalled libtool libraries with the installed ones
55997914d74bSmrg	    newdependency_libs=
56007914d74bSmrg	    for deplib in $dependency_libs; do
56017914d74bSmrg	      case $deplib in
56027914d74bSmrg	      *.la)
56037914d74bSmrg		name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'`
56047914d74bSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
56057914d74bSmrg		if test -z "$libdir"; then
56067914d74bSmrg		  $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
56077914d74bSmrg		  exit $EXIT_FAILURE
56087914d74bSmrg		fi
56097914d74bSmrg		newdependency_libs="$newdependency_libs $libdir/$name"
56107914d74bSmrg		;;
56117914d74bSmrg	      *) newdependency_libs="$newdependency_libs $deplib" ;;
56127914d74bSmrg	      esac
56137914d74bSmrg	    done
56147914d74bSmrg	    dependency_libs="$newdependency_libs"
56157914d74bSmrg	    newdlfiles=
56167914d74bSmrg	    for lib in $dlfiles; do
56177914d74bSmrg	      name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
56187914d74bSmrg	      eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
56197914d74bSmrg	      if test -z "$libdir"; then
56207914d74bSmrg		$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
56217914d74bSmrg		exit $EXIT_FAILURE
56227914d74bSmrg	      fi
56237914d74bSmrg	      newdlfiles="$newdlfiles $libdir/$name"
56247914d74bSmrg	    done
56257914d74bSmrg	    dlfiles="$newdlfiles"
56267914d74bSmrg	    newdlprefiles=
56277914d74bSmrg	    for lib in $dlprefiles; do
56287914d74bSmrg	      name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
56297914d74bSmrg	      eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
56307914d74bSmrg	      if test -z "$libdir"; then
56317914d74bSmrg		$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
56327914d74bSmrg		exit $EXIT_FAILURE
56337914d74bSmrg	      fi
56347914d74bSmrg	      newdlprefiles="$newdlprefiles $libdir/$name"
56357914d74bSmrg	    done
56367914d74bSmrg	    dlprefiles="$newdlprefiles"
56377914d74bSmrg	  else
56387914d74bSmrg	    newdlfiles=
56397914d74bSmrg	    for lib in $dlfiles; do
56407914d74bSmrg	      case $lib in
56417914d74bSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
56427914d74bSmrg		*) abs=`pwd`"/$lib" ;;
56437914d74bSmrg	      esac
56447914d74bSmrg	      newdlfiles="$newdlfiles $abs"
56457914d74bSmrg	    done
56467914d74bSmrg	    dlfiles="$newdlfiles"
56477914d74bSmrg	    newdlprefiles=
56487914d74bSmrg	    for lib in $dlprefiles; do
56497914d74bSmrg	      case $lib in
56507914d74bSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
56517914d74bSmrg		*) abs=`pwd`"/$lib" ;;
56527914d74bSmrg	      esac
56537914d74bSmrg	      newdlprefiles="$newdlprefiles $abs"
56547914d74bSmrg	    done
56557914d74bSmrg	    dlprefiles="$newdlprefiles"
56567914d74bSmrg	  fi
56577914d74bSmrg	  $rm $output
56587914d74bSmrg	  # place dlname in correct position for cygwin
56597914d74bSmrg	  tdlname=$dlname
56607914d74bSmrg	  case $host,$output,$installed,$module,$dlname in
56617914d74bSmrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
56627914d74bSmrg	  esac
56637914d74bSmrg	  $echo > $output "\
56647914d74bSmrg# $outputname - a libtool library file
56657914d74bSmrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
56667914d74bSmrg#
56677914d74bSmrg# Please DO NOT delete this file!
56687914d74bSmrg# It is necessary for linking the library.
56697914d74bSmrg
56707914d74bSmrg# The name that we can dlopen(3).
56717914d74bSmrgdlname='$tdlname'
56727914d74bSmrg
56737914d74bSmrg# Names of this library.
56747914d74bSmrglibrary_names='$library_names'
56757914d74bSmrg
56767914d74bSmrg# The name of the static archive.
56777914d74bSmrgold_library='$old_library'
56787914d74bSmrg
56797914d74bSmrg# Libraries that this one depends upon.
56807914d74bSmrgdependency_libs='$dependency_libs'
56817914d74bSmrg
56827914d74bSmrg# Version information for $libname.
56837914d74bSmrgcurrent=$current
56847914d74bSmrgage=$age
56857914d74bSmrgrevision=$revision
56867914d74bSmrg
56877914d74bSmrg# Is this an already installed library?
56887914d74bSmrginstalled=$installed
56897914d74bSmrg
56907914d74bSmrg# Should we warn about portability when linking against -modules?
56917914d74bSmrgshouldnotlink=$module
56927914d74bSmrg
56937914d74bSmrg# Files to dlopen/dlpreopen
56947914d74bSmrgdlopen='$dlfiles'
56957914d74bSmrgdlpreopen='$dlprefiles'
56967914d74bSmrg
56977914d74bSmrg# Directory that this library needs to be installed in:
56987914d74bSmrglibdir='$install_libdir'"
56997914d74bSmrg	  if test "$installed" = no && test "$need_relink" = yes; then
57007914d74bSmrg	    $echo >> $output "\
57017914d74bSmrgrelink_command=\"$relink_command\""
57027914d74bSmrg	  fi
57037914d74bSmrg	done
57047914d74bSmrg      fi
57057914d74bSmrg
57067914d74bSmrg      # Do a symbolic link so that the libtool archive can be found in
57077914d74bSmrg      # LD_LIBRARY_PATH before the program is installed.
57087914d74bSmrg      $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)"
57097914d74bSmrg      $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $?
57107914d74bSmrg      ;;
57117914d74bSmrg    esac
57127914d74bSmrg    exit $EXIT_SUCCESS
57137914d74bSmrg    ;;
57147914d74bSmrg
57157914d74bSmrg  # libtool install mode
57167914d74bSmrg  install)
57177914d74bSmrg    modename="$modename: install"
57187914d74bSmrg
57197914d74bSmrg    # There may be an optional sh(1) argument at the beginning of
57207914d74bSmrg    # install_prog (especially on Windows NT).
57217914d74bSmrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
57227914d74bSmrg       # Allow the use of GNU shtool's install command.
57237914d74bSmrg       $echo "X$nonopt" | grep shtool > /dev/null; then
57247914d74bSmrg      # Aesthetically quote it.
57257914d74bSmrg      arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"`
57267914d74bSmrg      case $arg in
57277914d74bSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
57287914d74bSmrg	arg="\"$arg\""
57297914d74bSmrg	;;
57307914d74bSmrg      esac
57317914d74bSmrg      install_prog="$arg "
57327914d74bSmrg      arg="$1"
57337914d74bSmrg      shift
57347914d74bSmrg    else
57357914d74bSmrg      install_prog=
57367914d74bSmrg      arg=$nonopt
57377914d74bSmrg    fi
57387914d74bSmrg
57397914d74bSmrg    # The real first argument should be the name of the installation program.
57407914d74bSmrg    # Aesthetically quote it.
57417914d74bSmrg    arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
57427914d74bSmrg    case $arg in
57437914d74bSmrg    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
57447914d74bSmrg      arg="\"$arg\""
57457914d74bSmrg      ;;
57467914d74bSmrg    esac
57477914d74bSmrg    install_prog="$install_prog$arg"
57487914d74bSmrg
57497914d74bSmrg    # We need to accept at least all the BSD install flags.
57507914d74bSmrg    dest=
57517914d74bSmrg    files=
57527914d74bSmrg    opts=
57537914d74bSmrg    prev=
57547914d74bSmrg    install_type=
57557914d74bSmrg    isdir=no
57567914d74bSmrg    stripme=
57577914d74bSmrg    for arg
57587914d74bSmrg    do
57597914d74bSmrg      if test -n "$dest"; then
57607914d74bSmrg	files="$files $dest"
57617914d74bSmrg	dest=$arg
57627914d74bSmrg	continue
57637914d74bSmrg      fi
57647914d74bSmrg
57657914d74bSmrg      case $arg in
57667914d74bSmrg      -d) isdir=yes ;;
57677914d74bSmrg      -f) 
57687914d74bSmrg      	case " $install_prog " in
57697914d74bSmrg	*[\\\ /]cp\ *) ;;
57707914d74bSmrg	*) prev=$arg ;;
57717914d74bSmrg	esac
57727914d74bSmrg	;;
57737914d74bSmrg      -g | -m | -o) prev=$arg ;;
57747914d74bSmrg      -s)
57757914d74bSmrg	stripme=" -s"
57767914d74bSmrg	continue
57777914d74bSmrg	;;
57787914d74bSmrg      -*)
57797914d74bSmrg	;;
57807914d74bSmrg      *)
57817914d74bSmrg	# If the previous option needed an argument, then skip it.
57827914d74bSmrg	if test -n "$prev"; then
57837914d74bSmrg	  prev=
57847914d74bSmrg	else
57857914d74bSmrg	  dest=$arg
57867914d74bSmrg	  continue
57877914d74bSmrg	fi
57887914d74bSmrg	;;
57897914d74bSmrg      esac
57907914d74bSmrg
57917914d74bSmrg      # Aesthetically quote the argument.
57927914d74bSmrg      arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
57937914d74bSmrg      case $arg in
57947914d74bSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
57957914d74bSmrg	arg="\"$arg\""
57967914d74bSmrg	;;
57977914d74bSmrg      esac
57987914d74bSmrg      install_prog="$install_prog $arg"
57997914d74bSmrg    done
58007914d74bSmrg
58017914d74bSmrg    if test -z "$install_prog"; then
58027914d74bSmrg      $echo "$modename: you must specify an install program" 1>&2
58037914d74bSmrg      $echo "$help" 1>&2
58047914d74bSmrg      exit $EXIT_FAILURE
58057914d74bSmrg    fi
58067914d74bSmrg
58077914d74bSmrg    if test -n "$prev"; then
58087914d74bSmrg      $echo "$modename: the \`$prev' option requires an argument" 1>&2
58097914d74bSmrg      $echo "$help" 1>&2
58107914d74bSmrg      exit $EXIT_FAILURE
58117914d74bSmrg    fi
58127914d74bSmrg
58137914d74bSmrg    if test -z "$files"; then
58147914d74bSmrg      if test -z "$dest"; then
58157914d74bSmrg	$echo "$modename: no file or destination specified" 1>&2
58167914d74bSmrg      else
58177914d74bSmrg	$echo "$modename: you must specify a destination" 1>&2
58187914d74bSmrg      fi
58197914d74bSmrg      $echo "$help" 1>&2
58207914d74bSmrg      exit $EXIT_FAILURE
58217914d74bSmrg    fi
58227914d74bSmrg
58237914d74bSmrg    # Strip any trailing slash from the destination.
58247914d74bSmrg    dest=`$echo "X$dest" | $Xsed -e 's%/$%%'`
58257914d74bSmrg
58267914d74bSmrg    # Check to see that the destination is a directory.
58277914d74bSmrg    test -d "$dest" && isdir=yes
58287914d74bSmrg    if test "$isdir" = yes; then
58297914d74bSmrg      destdir="$dest"
58307914d74bSmrg      destname=
58317914d74bSmrg    else
58327914d74bSmrg      destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'`
58337914d74bSmrg      test "X$destdir" = "X$dest" && destdir=.
58347914d74bSmrg      destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'`
58357914d74bSmrg
58367914d74bSmrg      # Not a directory, so check to see that there is only one file specified.
58377914d74bSmrg      set dummy $files
58387914d74bSmrg      if test "$#" -gt 2; then
58397914d74bSmrg	$echo "$modename: \`$dest' is not a directory" 1>&2
58407914d74bSmrg	$echo "$help" 1>&2
58417914d74bSmrg	exit $EXIT_FAILURE
58427914d74bSmrg      fi
58437914d74bSmrg    fi
58447914d74bSmrg    case $destdir in
58457914d74bSmrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
58467914d74bSmrg    *)
58477914d74bSmrg      for file in $files; do
58487914d74bSmrg	case $file in
58497914d74bSmrg	*.lo) ;;
58507914d74bSmrg	*)
58517914d74bSmrg	  $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2
58527914d74bSmrg	  $echo "$help" 1>&2
58537914d74bSmrg	  exit $EXIT_FAILURE
58547914d74bSmrg	  ;;
58557914d74bSmrg	esac
58567914d74bSmrg      done
58577914d74bSmrg      ;;
58587914d74bSmrg    esac
58597914d74bSmrg
58607914d74bSmrg    # This variable tells wrapper scripts just to set variables rather
58617914d74bSmrg    # than running their programs.
58627914d74bSmrg    libtool_install_magic="$magic"
58637914d74bSmrg
58647914d74bSmrg    staticlibs=
58657914d74bSmrg    future_libdirs=
58667914d74bSmrg    current_libdirs=
58677914d74bSmrg    for file in $files; do
58687914d74bSmrg
58697914d74bSmrg      # Do each installation.
58707914d74bSmrg      case $file in
58717914d74bSmrg      *.$libext)
58727914d74bSmrg	# Do the static libraries later.
58737914d74bSmrg	staticlibs="$staticlibs $file"
58747914d74bSmrg	;;
58757914d74bSmrg
58767914d74bSmrg      *.la)
58777914d74bSmrg	# Check to see that this really is a libtool archive.
58787914d74bSmrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
58797914d74bSmrg	else
58807914d74bSmrg	  $echo "$modename: \`$file' is not a valid libtool archive" 1>&2
58817914d74bSmrg	  $echo "$help" 1>&2
58827914d74bSmrg	  exit $EXIT_FAILURE
58837914d74bSmrg	fi
58847914d74bSmrg
58857914d74bSmrg	library_names=
58867914d74bSmrg	old_library=
58877914d74bSmrg	relink_command=
58887914d74bSmrg	# If there is no directory component, then add one.
58897914d74bSmrg	case $file in
58907914d74bSmrg	*/* | *\\*) . $file ;;
58917914d74bSmrg	*) . ./$file ;;
58927914d74bSmrg	esac
58937914d74bSmrg
58947914d74bSmrg	# Add the libdir to current_libdirs if it is the destination.
58957914d74bSmrg	if test "X$destdir" = "X$libdir"; then
58967914d74bSmrg	  case "$current_libdirs " in
58977914d74bSmrg	  *" $libdir "*) ;;
58987914d74bSmrg	  *) current_libdirs="$current_libdirs $libdir" ;;
58997914d74bSmrg	  esac
59007914d74bSmrg	else
59017914d74bSmrg	  # Note the libdir as a future libdir.
59027914d74bSmrg	  case "$future_libdirs " in
59037914d74bSmrg	  *" $libdir "*) ;;
59047914d74bSmrg	  *) future_libdirs="$future_libdirs $libdir" ;;
59057914d74bSmrg	  esac
59067914d74bSmrg	fi
59077914d74bSmrg
59087914d74bSmrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/
59097914d74bSmrg	test "X$dir" = "X$file/" && dir=
59107914d74bSmrg	dir="$dir$objdir"
59117914d74bSmrg
59127914d74bSmrg	if test -n "$relink_command"; then
59137914d74bSmrg	  # Determine the prefix the user has applied to our future dir.
59147914d74bSmrg	  inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"`
59157914d74bSmrg
59167914d74bSmrg	  # Don't allow the user to place us outside of our expected
59177914d74bSmrg	  # location b/c this prevents finding dependent libraries that
59187914d74bSmrg	  # are installed to the same prefix.
59197914d74bSmrg	  # At present, this check doesn't affect windows .dll's that
59207914d74bSmrg	  # are installed into $libdir/../bin (currently, that works fine)
59217914d74bSmrg	  # but it's something to keep an eye on.
59227914d74bSmrg	  if test "$inst_prefix_dir" = "$destdir"; then
59237914d74bSmrg	    $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2
59247914d74bSmrg	    exit $EXIT_FAILURE
59257914d74bSmrg	  fi
59267914d74bSmrg
59277914d74bSmrg	  if test -n "$inst_prefix_dir"; then
59287914d74bSmrg	    # Stick the inst_prefix_dir data into the link command.
59297914d74bSmrg	    relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
59307914d74bSmrg	  else
59317914d74bSmrg	    relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
59327914d74bSmrg	  fi
59337914d74bSmrg
59347914d74bSmrg	  $echo "$modename: warning: relinking \`$file'" 1>&2
59357914d74bSmrg	  $show "$relink_command"
59367914d74bSmrg	  if $run eval "$relink_command"; then :
59377914d74bSmrg	  else
59387914d74bSmrg	    $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
59397914d74bSmrg	    exit $EXIT_FAILURE
59407914d74bSmrg	  fi
59417914d74bSmrg	fi
59427914d74bSmrg
59437914d74bSmrg	# See the names of the shared library.
59447914d74bSmrg	set dummy $library_names
59457914d74bSmrg	if test -n "$2"; then
59467914d74bSmrg	  realname="$2"
59477914d74bSmrg	  shift
59487914d74bSmrg	  shift
59497914d74bSmrg
59507914d74bSmrg	  srcname="$realname"
59517914d74bSmrg	  test -n "$relink_command" && srcname="$realname"T
59527914d74bSmrg
59537914d74bSmrg	  # Install the shared library and build the symlinks.
59547914d74bSmrg	  $show "$install_prog $dir/$srcname $destdir/$realname"
59557914d74bSmrg	  $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $?
59567914d74bSmrg	  if test -n "$stripme" && test -n "$striplib"; then
59577914d74bSmrg	    $show "$striplib $destdir/$realname"
59587914d74bSmrg	    $run eval "$striplib $destdir/$realname" || exit $?
59597914d74bSmrg	  fi
59607914d74bSmrg
59617914d74bSmrg	  if test "$#" -gt 0; then
59627914d74bSmrg	    # Delete the old symlinks, and create new ones.
59637914d74bSmrg	    # Try `ln -sf' first, because the `ln' binary might depend on
59647914d74bSmrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
59657914d74bSmrg	    # so we also need to try rm && ln -s.
59667914d74bSmrg	    for linkname
59677914d74bSmrg	    do
59687914d74bSmrg	      if test "$linkname" != "$realname"; then
59697914d74bSmrg                $show "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
59707914d74bSmrg                $run eval "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
59717914d74bSmrg	      fi
59727914d74bSmrg	    done
59737914d74bSmrg	  fi
59747914d74bSmrg
59757914d74bSmrg	  # Do each command in the postinstall commands.
59767914d74bSmrg	  lib="$destdir/$realname"
59777914d74bSmrg	  cmds=$postinstall_cmds
59787914d74bSmrg	  save_ifs="$IFS"; IFS='~'
59797914d74bSmrg	  for cmd in $cmds; do
59807914d74bSmrg	    IFS="$save_ifs"
59817914d74bSmrg	    eval cmd=\"$cmd\"
59827914d74bSmrg	    $show "$cmd"
59837914d74bSmrg	    $run eval "$cmd" || {
59847914d74bSmrg	      lt_exit=$?
59857914d74bSmrg
59867914d74bSmrg	      # Restore the uninstalled library and exit
59877914d74bSmrg	      if test "$mode" = relink; then
59887914d74bSmrg		$run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
59897914d74bSmrg	      fi
59907914d74bSmrg
59917914d74bSmrg	      exit $lt_exit
59927914d74bSmrg	    }
59937914d74bSmrg	  done
59947914d74bSmrg	  IFS="$save_ifs"
59957914d74bSmrg	fi
59967914d74bSmrg
59977914d74bSmrg	# Install the pseudo-library for information purposes.
59987914d74bSmrg	name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
59997914d74bSmrg	instname="$dir/$name"i
60007914d74bSmrg	$show "$install_prog $instname $destdir/$name"
60017914d74bSmrg	$run eval "$install_prog $instname $destdir/$name" || exit $?
60027914d74bSmrg
60037914d74bSmrg	# Maybe install the static library, too.
60047914d74bSmrg	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
60057914d74bSmrg	;;
60067914d74bSmrg
60077914d74bSmrg      *.lo)
60087914d74bSmrg	# Install (i.e. copy) a libtool object.
60097914d74bSmrg
60107914d74bSmrg	# Figure out destination file name, if it wasn't already specified.
60117914d74bSmrg	if test -n "$destname"; then
60127914d74bSmrg	  destfile="$destdir/$destname"
60137914d74bSmrg	else
60147914d74bSmrg	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
60157914d74bSmrg	  destfile="$destdir/$destfile"
60167914d74bSmrg	fi
60177914d74bSmrg
60187914d74bSmrg	# Deduce the name of the destination old-style object file.
60197914d74bSmrg	case $destfile in
60207914d74bSmrg	*.lo)
60217914d74bSmrg	  staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"`
60227914d74bSmrg	  ;;
60237914d74bSmrg	*.$objext)
60247914d74bSmrg	  staticdest="$destfile"
60257914d74bSmrg	  destfile=
60267914d74bSmrg	  ;;
60277914d74bSmrg	*)
60287914d74bSmrg	  $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2
60297914d74bSmrg	  $echo "$help" 1>&2
60307914d74bSmrg	  exit $EXIT_FAILURE
60317914d74bSmrg	  ;;
60327914d74bSmrg	esac
60337914d74bSmrg
60347914d74bSmrg	# Install the libtool object if requested.
60357914d74bSmrg	if test -n "$destfile"; then
60367914d74bSmrg	  $show "$install_prog $file $destfile"
60377914d74bSmrg	  $run eval "$install_prog $file $destfile" || exit $?
60387914d74bSmrg	fi
60397914d74bSmrg
60407914d74bSmrg	# Install the old object if enabled.
60417914d74bSmrg	if test "$build_old_libs" = yes; then
60427914d74bSmrg	  # Deduce the name of the old-style object file.
60437914d74bSmrg	  staticobj=`$echo "X$file" | $Xsed -e "$lo2o"`
60447914d74bSmrg
60457914d74bSmrg	  $show "$install_prog $staticobj $staticdest"
60467914d74bSmrg	  $run eval "$install_prog \$staticobj \$staticdest" || exit $?
60477914d74bSmrg	fi
60487914d74bSmrg	exit $EXIT_SUCCESS
60497914d74bSmrg	;;
60507914d74bSmrg
60517914d74bSmrg      *)
60527914d74bSmrg	# Figure out destination file name, if it wasn't already specified.
60537914d74bSmrg	if test -n "$destname"; then
60547914d74bSmrg	  destfile="$destdir/$destname"
60557914d74bSmrg	else
60567914d74bSmrg	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
60577914d74bSmrg	  destfile="$destdir/$destfile"
60587914d74bSmrg	fi
60597914d74bSmrg
60607914d74bSmrg	# If the file is missing, and there is a .exe on the end, strip it
60617914d74bSmrg	# because it is most likely a libtool script we actually want to
60627914d74bSmrg	# install
60637914d74bSmrg	stripped_ext=""
60647914d74bSmrg	case $file in
60657914d74bSmrg	  *.exe)
60667914d74bSmrg	    if test ! -f "$file"; then
60677914d74bSmrg	      file=`$echo $file|${SED} 's,.exe$,,'`
60687914d74bSmrg	      stripped_ext=".exe"
60697914d74bSmrg	    fi
60707914d74bSmrg	    ;;
60717914d74bSmrg	esac
60727914d74bSmrg
60737914d74bSmrg	# Do a test to see if this is really a libtool program.
60747914d74bSmrg	case $host in
60757914d74bSmrg	*cygwin*|*mingw*)
60767914d74bSmrg	    wrapper=`$echo $file | ${SED} -e 's,.exe$,,'`
60777914d74bSmrg	    ;;
60787914d74bSmrg	*)
60797914d74bSmrg	    wrapper=$file
60807914d74bSmrg	    ;;
60817914d74bSmrg	esac
60827914d74bSmrg	if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then
60837914d74bSmrg	  notinst_deplibs=
60847914d74bSmrg	  relink_command=
60857914d74bSmrg
60867914d74bSmrg	  # Note that it is not necessary on cygwin/mingw to append a dot to
60877914d74bSmrg	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
60887914d74bSmrg	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
60897914d74bSmrg	  # `FILE.' does not work on cygwin managed mounts.
60907914d74bSmrg	  #
60917914d74bSmrg	  # If there is no directory component, then add one.
60927914d74bSmrg	  case $wrapper in
60937914d74bSmrg	  */* | *\\*) . ${wrapper} ;;
60947914d74bSmrg	  *) . ./${wrapper} ;;
60957914d74bSmrg	  esac
60967914d74bSmrg
60977914d74bSmrg	  # Check the variables that should have been set.
60987914d74bSmrg	  if test -z "$notinst_deplibs"; then
60997914d74bSmrg	    $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2
61007914d74bSmrg	    exit $EXIT_FAILURE
61017914d74bSmrg	  fi
61027914d74bSmrg
61037914d74bSmrg	  finalize=yes
61047914d74bSmrg	  for lib in $notinst_deplibs; do
61057914d74bSmrg	    # Check to see that each library is installed.
61067914d74bSmrg	    libdir=
61077914d74bSmrg	    if test -f "$lib"; then
61087914d74bSmrg	      # If there is no directory component, then add one.
61097914d74bSmrg	      case $lib in
61107914d74bSmrg	      */* | *\\*) . $lib ;;
61117914d74bSmrg	      *) . ./$lib ;;
61127914d74bSmrg	      esac
61137914d74bSmrg	    fi
61147914d74bSmrg	    libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
61157914d74bSmrg	    if test -n "$libdir" && test ! -f "$libfile"; then
61167914d74bSmrg	      $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2
61177914d74bSmrg	      finalize=no
61187914d74bSmrg	    fi
61197914d74bSmrg	  done
61207914d74bSmrg
61217914d74bSmrg	  relink_command=
61227914d74bSmrg	  # Note that it is not necessary on cygwin/mingw to append a dot to
61237914d74bSmrg	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
61247914d74bSmrg	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
61257914d74bSmrg	  # `FILE.' does not work on cygwin managed mounts.
61267914d74bSmrg	  #
61277914d74bSmrg	  # If there is no directory component, then add one.
61287914d74bSmrg	  case $wrapper in
61297914d74bSmrg	  */* | *\\*) . ${wrapper} ;;
61307914d74bSmrg	  *) . ./${wrapper} ;;
61317914d74bSmrg	  esac
61327914d74bSmrg
61337914d74bSmrg	  outputname=
61347914d74bSmrg	  if test "$fast_install" = no && test -n "$relink_command"; then
61357914d74bSmrg	    if test "$finalize" = yes && test -z "$run"; then
61367914d74bSmrg	      tmpdir=`func_mktempdir`
61377914d74bSmrg	      file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
61387914d74bSmrg	      outputname="$tmpdir/$file"
61397914d74bSmrg	      # Replace the output file specification.
61407914d74bSmrg	      relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
61417914d74bSmrg
61427914d74bSmrg	      $show "$relink_command"
61437914d74bSmrg	      if $run eval "$relink_command"; then :
61447914d74bSmrg	      else
61457914d74bSmrg		$echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
61467914d74bSmrg		${rm}r "$tmpdir"
61477914d74bSmrg		continue
61487914d74bSmrg	      fi
61497914d74bSmrg	      file="$outputname"
61507914d74bSmrg	    else
61517914d74bSmrg	      $echo "$modename: warning: cannot relink \`$file'" 1>&2
61527914d74bSmrg	    fi
61537914d74bSmrg	  else
61547914d74bSmrg	    # Install the binary that we compiled earlier.
61557914d74bSmrg	    file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
61567914d74bSmrg	  fi
61577914d74bSmrg	fi
61587914d74bSmrg
61597914d74bSmrg	# remove .exe since cygwin /usr/bin/install will append another
61607914d74bSmrg	# one anyway 
61617914d74bSmrg	case $install_prog,$host in
61627914d74bSmrg	*/usr/bin/install*,*cygwin*)
61637914d74bSmrg	  case $file:$destfile in
61647914d74bSmrg	  *.exe:*.exe)
61657914d74bSmrg	    # this is ok
61667914d74bSmrg	    ;;
61677914d74bSmrg	  *.exe:*)
61687914d74bSmrg	    destfile=$destfile.exe
61697914d74bSmrg	    ;;
61707914d74bSmrg	  *:*.exe)
61717914d74bSmrg	    destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'`
61727914d74bSmrg	    ;;
61737914d74bSmrg	  esac
61747914d74bSmrg	  ;;
61757914d74bSmrg	esac
61767914d74bSmrg	$show "$install_prog$stripme $file $destfile"
61777914d74bSmrg	$run eval "$install_prog\$stripme \$file \$destfile" || exit $?
61787914d74bSmrg	test -n "$outputname" && ${rm}r "$tmpdir"
61797914d74bSmrg	;;
61807914d74bSmrg      esac
61817914d74bSmrg    done
61827914d74bSmrg
61837914d74bSmrg    for file in $staticlibs; do
61847914d74bSmrg      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
61857914d74bSmrg
61867914d74bSmrg      # Set up the ranlib parameters.
61877914d74bSmrg      oldlib="$destdir/$name"
61887914d74bSmrg
61897914d74bSmrg      $show "$install_prog $file $oldlib"
61907914d74bSmrg      $run eval "$install_prog \$file \$oldlib" || exit $?
61917914d74bSmrg
61927914d74bSmrg      if test -n "$stripme" && test -n "$old_striplib"; then
61937914d74bSmrg	$show "$old_striplib $oldlib"
61947914d74bSmrg	$run eval "$old_striplib $oldlib" || exit $?
61957914d74bSmrg      fi
61967914d74bSmrg
61977914d74bSmrg      # Do each command in the postinstall commands.
61987914d74bSmrg      cmds=$old_postinstall_cmds
61997914d74bSmrg      save_ifs="$IFS"; IFS='~'
62007914d74bSmrg      for cmd in $cmds; do
62017914d74bSmrg	IFS="$save_ifs"
62027914d74bSmrg	eval cmd=\"$cmd\"
62037914d74bSmrg	$show "$cmd"
62047914d74bSmrg	$run eval "$cmd" || exit $?
62057914d74bSmrg      done
62067914d74bSmrg      IFS="$save_ifs"
62077914d74bSmrg    done
62087914d74bSmrg
62097914d74bSmrg    if test -n "$future_libdirs"; then
62107914d74bSmrg      $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2
62117914d74bSmrg    fi
62127914d74bSmrg
62137914d74bSmrg    if test -n "$current_libdirs"; then
62147914d74bSmrg      # Maybe just do a dry run.
62157914d74bSmrg      test -n "$run" && current_libdirs=" -n$current_libdirs"
62167914d74bSmrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
62177914d74bSmrg    else
62187914d74bSmrg      exit $EXIT_SUCCESS
62197914d74bSmrg    fi
62207914d74bSmrg    ;;
62217914d74bSmrg
62227914d74bSmrg  # libtool finish mode
62237914d74bSmrg  finish)
62247914d74bSmrg    modename="$modename: finish"
62257914d74bSmrg    libdirs="$nonopt"
62267914d74bSmrg    admincmds=
62277914d74bSmrg
62287914d74bSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
62297914d74bSmrg      for dir
62307914d74bSmrg      do
62317914d74bSmrg	libdirs="$libdirs $dir"
62327914d74bSmrg      done
62337914d74bSmrg
62347914d74bSmrg      for libdir in $libdirs; do
62357914d74bSmrg	if test -n "$finish_cmds"; then
62367914d74bSmrg	  # Do each command in the finish commands.
62377914d74bSmrg	  cmds=$finish_cmds
62387914d74bSmrg	  save_ifs="$IFS"; IFS='~'
62397914d74bSmrg	  for cmd in $cmds; do
62407914d74bSmrg	    IFS="$save_ifs"
62417914d74bSmrg	    eval cmd=\"$cmd\"
62427914d74bSmrg	    $show "$cmd"
62437914d74bSmrg	    $run eval "$cmd" || admincmds="$admincmds
62447914d74bSmrg       $cmd"
62457914d74bSmrg	  done
62467914d74bSmrg	  IFS="$save_ifs"
62477914d74bSmrg	fi
62487914d74bSmrg	if test -n "$finish_eval"; then
62497914d74bSmrg	  # Do the single finish_eval.
62507914d74bSmrg	  eval cmds=\"$finish_eval\"
62517914d74bSmrg	  $run eval "$cmds" || admincmds="$admincmds
62527914d74bSmrg       $cmds"
62537914d74bSmrg	fi
62547914d74bSmrg      done
62557914d74bSmrg    fi
62567914d74bSmrg
62577914d74bSmrg    # Exit here if they wanted silent mode.
62587914d74bSmrg    test "$show" = : && exit $EXIT_SUCCESS
62597914d74bSmrg
62607914d74bSmrg    $echo "X----------------------------------------------------------------------" | $Xsed
62617914d74bSmrg    $echo "Libraries have been installed in:"
62627914d74bSmrg    for libdir in $libdirs; do
62637914d74bSmrg      $echo "   $libdir"
62647914d74bSmrg    done
62657914d74bSmrg    $echo
62667914d74bSmrg    $echo "If you ever happen to want to link against installed libraries"
62677914d74bSmrg    $echo "in a given directory, LIBDIR, you must either use libtool, and"
62687914d74bSmrg    $echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
62697914d74bSmrg    $echo "flag during linking and do at least one of the following:"
62707914d74bSmrg    if test -n "$shlibpath_var"; then
62717914d74bSmrg      $echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
62727914d74bSmrg      $echo "     during execution"
62737914d74bSmrg    fi
62747914d74bSmrg    if test -n "$runpath_var"; then
62757914d74bSmrg      $echo "   - add LIBDIR to the \`$runpath_var' environment variable"
62767914d74bSmrg      $echo "     during linking"
62777914d74bSmrg    fi
62787914d74bSmrg    if test -n "$hardcode_libdir_flag_spec"; then
62797914d74bSmrg      libdir=LIBDIR
62807914d74bSmrg      eval flag=\"$hardcode_libdir_flag_spec\"
62817914d74bSmrg
62827914d74bSmrg      $echo "   - use the \`$flag' linker flag"
62837914d74bSmrg    fi
62847914d74bSmrg    if test -n "$admincmds"; then
62857914d74bSmrg      $echo "   - have your system administrator run these commands:$admincmds"
62867914d74bSmrg    fi
62877914d74bSmrg    if test -f /etc/ld.so.conf; then
62887914d74bSmrg      $echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
62897914d74bSmrg    fi
62907914d74bSmrg    $echo
62917914d74bSmrg    $echo "See any operating system documentation about shared libraries for"
62927914d74bSmrg    $echo "more information, such as the ld(1) and ld.so(8) manual pages."
62937914d74bSmrg    $echo "X----------------------------------------------------------------------" | $Xsed
62947914d74bSmrg    exit $EXIT_SUCCESS
62957914d74bSmrg    ;;
62967914d74bSmrg
62977914d74bSmrg  # libtool execute mode
62987914d74bSmrg  execute)
62997914d74bSmrg    modename="$modename: execute"
63007914d74bSmrg
63017914d74bSmrg    # The first argument is the command name.
63027914d74bSmrg    cmd="$nonopt"
63037914d74bSmrg    if test -z "$cmd"; then
63047914d74bSmrg      $echo "$modename: you must specify a COMMAND" 1>&2
63057914d74bSmrg      $echo "$help"
63067914d74bSmrg      exit $EXIT_FAILURE
63077914d74bSmrg    fi
63087914d74bSmrg
63097914d74bSmrg    # Handle -dlopen flags immediately.
63107914d74bSmrg    for file in $execute_dlfiles; do
63117914d74bSmrg      if test ! -f "$file"; then
63127914d74bSmrg	$echo "$modename: \`$file' is not a file" 1>&2
63137914d74bSmrg	$echo "$help" 1>&2
63147914d74bSmrg	exit $EXIT_FAILURE
63157914d74bSmrg      fi
63167914d74bSmrg
63177914d74bSmrg      dir=
63187914d74bSmrg      case $file in
63197914d74bSmrg      *.la)
63207914d74bSmrg	# Check to see that this really is a libtool archive.
63217914d74bSmrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
63227914d74bSmrg	else
63237914d74bSmrg	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
63247914d74bSmrg	  $echo "$help" 1>&2
63257914d74bSmrg	  exit $EXIT_FAILURE
63267914d74bSmrg	fi
63277914d74bSmrg
63287914d74bSmrg	# Read the libtool library.
63297914d74bSmrg	dlname=
63307914d74bSmrg	library_names=
63317914d74bSmrg
63327914d74bSmrg	# If there is no directory component, then add one.
63337914d74bSmrg	case $file in
63347914d74bSmrg	*/* | *\\*) . $file ;;
63357914d74bSmrg	*) . ./$file ;;
63367914d74bSmrg	esac
63377914d74bSmrg
63387914d74bSmrg	# Skip this library if it cannot be dlopened.
63397914d74bSmrg	if test -z "$dlname"; then
63407914d74bSmrg	  # Warn if it was a shared library.
63417914d74bSmrg	  test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'"
63427914d74bSmrg	  continue
63437914d74bSmrg	fi
63447914d74bSmrg
63457914d74bSmrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
63467914d74bSmrg	test "X$dir" = "X$file" && dir=.
63477914d74bSmrg
63487914d74bSmrg	if test -f "$dir/$objdir/$dlname"; then
63497914d74bSmrg	  dir="$dir/$objdir"
63507914d74bSmrg	else
63517914d74bSmrg	  $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
63527914d74bSmrg	  exit $EXIT_FAILURE
63537914d74bSmrg	fi
63547914d74bSmrg	;;
63557914d74bSmrg
63567914d74bSmrg      *.lo)
63577914d74bSmrg	# Just add the directory containing the .lo file.
63587914d74bSmrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
63597914d74bSmrg	test "X$dir" = "X$file" && dir=.
63607914d74bSmrg	;;
63617914d74bSmrg
63627914d74bSmrg      *)
63637914d74bSmrg	$echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2
63647914d74bSmrg	continue
63657914d74bSmrg	;;
63667914d74bSmrg      esac
63677914d74bSmrg
63687914d74bSmrg      # Get the absolute pathname.
63697914d74bSmrg      absdir=`cd "$dir" && pwd`
63707914d74bSmrg      test -n "$absdir" && dir="$absdir"
63717914d74bSmrg
63727914d74bSmrg      # Now add the directory to shlibpath_var.
63737914d74bSmrg      if eval "test -z \"\$$shlibpath_var\""; then
63747914d74bSmrg	eval "$shlibpath_var=\"\$dir\""
63757914d74bSmrg      else
63767914d74bSmrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
63777914d74bSmrg      fi
63787914d74bSmrg    done
63797914d74bSmrg
63807914d74bSmrg    # This variable tells wrapper scripts just to set shlibpath_var
63817914d74bSmrg    # rather than running their programs.
63827914d74bSmrg    libtool_execute_magic="$magic"
63837914d74bSmrg
63847914d74bSmrg    # Check if any of the arguments is a wrapper script.
63857914d74bSmrg    args=
63867914d74bSmrg    for file
63877914d74bSmrg    do
63887914d74bSmrg      case $file in
63897914d74bSmrg      -*) ;;
63907914d74bSmrg      *)
63917914d74bSmrg	# Do a test to see if this is really a libtool program.
63927914d74bSmrg	if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
63937914d74bSmrg	  # If there is no directory component, then add one.
63947914d74bSmrg	  case $file in
63957914d74bSmrg	  */* | *\\*) . $file ;;
63967914d74bSmrg	  *) . ./$file ;;
63977914d74bSmrg	  esac
63987914d74bSmrg
63997914d74bSmrg	  # Transform arg to wrapped name.
64007914d74bSmrg	  file="$progdir/$program"
64017914d74bSmrg	fi
64027914d74bSmrg	;;
64037914d74bSmrg      esac
64047914d74bSmrg      # Quote arguments (to preserve shell metacharacters).
64057914d74bSmrg      file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"`
64067914d74bSmrg      args="$args \"$file\""
64077914d74bSmrg    done
64087914d74bSmrg
64097914d74bSmrg    if test -z "$run"; then
64107914d74bSmrg      if test -n "$shlibpath_var"; then
64117914d74bSmrg	# Export the shlibpath_var.
64127914d74bSmrg	eval "export $shlibpath_var"
64137914d74bSmrg      fi
64147914d74bSmrg
64157914d74bSmrg      # Restore saved environment variables
64167914d74bSmrg      if test "${save_LC_ALL+set}" = set; then
64177914d74bSmrg	LC_ALL="$save_LC_ALL"; export LC_ALL
64187914d74bSmrg      fi
64197914d74bSmrg      if test "${save_LANG+set}" = set; then
64207914d74bSmrg	LANG="$save_LANG"; export LANG
64217914d74bSmrg      fi
64227914d74bSmrg
64237914d74bSmrg      # Now prepare to actually exec the command.
64247914d74bSmrg      exec_cmd="\$cmd$args"
64257914d74bSmrg    else
64267914d74bSmrg      # Display what would be done.
64277914d74bSmrg      if test -n "$shlibpath_var"; then
64287914d74bSmrg	eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\""
64297914d74bSmrg	$echo "export $shlibpath_var"
64307914d74bSmrg      fi
64317914d74bSmrg      $echo "$cmd$args"
64327914d74bSmrg      exit $EXIT_SUCCESS
64337914d74bSmrg    fi
64347914d74bSmrg    ;;
64357914d74bSmrg
64367914d74bSmrg  # libtool clean and uninstall mode
64377914d74bSmrg  clean | uninstall)
64387914d74bSmrg    modename="$modename: $mode"
64397914d74bSmrg    rm="$nonopt"
64407914d74bSmrg    files=
64417914d74bSmrg    rmforce=
64427914d74bSmrg    exit_status=0
64437914d74bSmrg
64447914d74bSmrg    # This variable tells wrapper scripts just to set variables rather
64457914d74bSmrg    # than running their programs.
64467914d74bSmrg    libtool_install_magic="$magic"
64477914d74bSmrg
64487914d74bSmrg    for arg
64497914d74bSmrg    do
64507914d74bSmrg      case $arg in
64517914d74bSmrg      -f) rm="$rm $arg"; rmforce=yes ;;
64527914d74bSmrg      -*) rm="$rm $arg" ;;
64537914d74bSmrg      *) files="$files $arg" ;;
64547914d74bSmrg      esac
64557914d74bSmrg    done
64567914d74bSmrg
64577914d74bSmrg    if test -z "$rm"; then
64587914d74bSmrg      $echo "$modename: you must specify an RM program" 1>&2
64597914d74bSmrg      $echo "$help" 1>&2
64607914d74bSmrg      exit $EXIT_FAILURE
64617914d74bSmrg    fi
64627914d74bSmrg
64637914d74bSmrg    rmdirs=
64647914d74bSmrg
64657914d74bSmrg    origobjdir="$objdir"
64667914d74bSmrg    for file in $files; do
64677914d74bSmrg      dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
64687914d74bSmrg      if test "X$dir" = "X$file"; then
64697914d74bSmrg	dir=.
64707914d74bSmrg	objdir="$origobjdir"
64717914d74bSmrg      else
64727914d74bSmrg	objdir="$dir/$origobjdir"
64737914d74bSmrg      fi
64747914d74bSmrg      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
64757914d74bSmrg      test "$mode" = uninstall && objdir="$dir"
64767914d74bSmrg
64777914d74bSmrg      # Remember objdir for removal later, being careful to avoid duplicates
64787914d74bSmrg      if test "$mode" = clean; then
64797914d74bSmrg	case " $rmdirs " in
64807914d74bSmrg	  *" $objdir "*) ;;
64817914d74bSmrg	  *) rmdirs="$rmdirs $objdir" ;;
64827914d74bSmrg	esac
64837914d74bSmrg      fi
64847914d74bSmrg
64857914d74bSmrg      # Don't error if the file doesn't exist and rm -f was used.
64867914d74bSmrg      if (test -L "$file") >/dev/null 2>&1 \
64877914d74bSmrg	|| (test -h "$file") >/dev/null 2>&1 \
64887914d74bSmrg	|| test -f "$file"; then
64897914d74bSmrg	:
64907914d74bSmrg      elif test -d "$file"; then
64917914d74bSmrg	exit_status=1
64927914d74bSmrg	continue
64937914d74bSmrg      elif test "$rmforce" = yes; then
64947914d74bSmrg	continue
64957914d74bSmrg      fi
64967914d74bSmrg
64977914d74bSmrg      rmfiles="$file"
64987914d74bSmrg
64997914d74bSmrg      case $name in
65007914d74bSmrg      *.la)
65017914d74bSmrg	# Possibly a libtool archive, so verify it.
65027914d74bSmrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
65037914d74bSmrg	  . $dir/$name
65047914d74bSmrg
65057914d74bSmrg	  # Delete the libtool libraries and symlinks.
65067914d74bSmrg	  for n in $library_names; do
65077914d74bSmrg	    rmfiles="$rmfiles $objdir/$n"
65087914d74bSmrg	  done
65097914d74bSmrg	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
65107914d74bSmrg
65117914d74bSmrg	  case "$mode" in
65127914d74bSmrg	  clean)
65137914d74bSmrg	    case "  $library_names " in
65147914d74bSmrg	    # "  " in the beginning catches empty $dlname
65157914d74bSmrg	    *" $dlname "*) ;;
65167914d74bSmrg	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
65177914d74bSmrg	    esac
65187914d74bSmrg	     test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
65197914d74bSmrg	    ;;
65207914d74bSmrg	  uninstall)
65217914d74bSmrg	    if test -n "$library_names"; then
65227914d74bSmrg	      # Do each command in the postuninstall commands.
65237914d74bSmrg	      cmds=$postuninstall_cmds
65247914d74bSmrg	      save_ifs="$IFS"; IFS='~'
65257914d74bSmrg	      for cmd in $cmds; do
65267914d74bSmrg		IFS="$save_ifs"
65277914d74bSmrg		eval cmd=\"$cmd\"
65287914d74bSmrg		$show "$cmd"
65297914d74bSmrg		$run eval "$cmd"
65307914d74bSmrg		if test "$?" -ne 0 && test "$rmforce" != yes; then
65317914d74bSmrg		  exit_status=1
65327914d74bSmrg		fi
65337914d74bSmrg	      done
65347914d74bSmrg	      IFS="$save_ifs"
65357914d74bSmrg	    fi
65367914d74bSmrg
65377914d74bSmrg	    if test -n "$old_library"; then
65387914d74bSmrg	      # Do each command in the old_postuninstall commands.
65397914d74bSmrg	      cmds=$old_postuninstall_cmds
65407914d74bSmrg	      save_ifs="$IFS"; IFS='~'
65417914d74bSmrg	      for cmd in $cmds; do
65427914d74bSmrg		IFS="$save_ifs"
65437914d74bSmrg		eval cmd=\"$cmd\"
65447914d74bSmrg		$show "$cmd"
65457914d74bSmrg		$run eval "$cmd"
65467914d74bSmrg		if test "$?" -ne 0 && test "$rmforce" != yes; then
65477914d74bSmrg		  exit_status=1
65487914d74bSmrg		fi
65497914d74bSmrg	      done
65507914d74bSmrg	      IFS="$save_ifs"
65517914d74bSmrg	    fi
65527914d74bSmrg	    # FIXME: should reinstall the best remaining shared library.
65537914d74bSmrg	    ;;
65547914d74bSmrg	  esac
65557914d74bSmrg	fi
65567914d74bSmrg	;;
65577914d74bSmrg
65587914d74bSmrg      *.lo)
65597914d74bSmrg	# Possibly a libtool object, so verify it.
65607914d74bSmrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
65617914d74bSmrg
65627914d74bSmrg	  # Read the .lo file
65637914d74bSmrg	  . $dir/$name
65647914d74bSmrg
65657914d74bSmrg	  # Add PIC object to the list of files to remove.
65667914d74bSmrg	  if test -n "$pic_object" \
65677914d74bSmrg	     && test "$pic_object" != none; then
65687914d74bSmrg	    rmfiles="$rmfiles $dir/$pic_object"
65697914d74bSmrg	  fi
65707914d74bSmrg
65717914d74bSmrg	  # Add non-PIC object to the list of files to remove.
65727914d74bSmrg	  if test -n "$non_pic_object" \
65737914d74bSmrg	     && test "$non_pic_object" != none; then
65747914d74bSmrg	    rmfiles="$rmfiles $dir/$non_pic_object"
65757914d74bSmrg	  fi
65767914d74bSmrg	fi
65777914d74bSmrg	;;
65787914d74bSmrg
65797914d74bSmrg      *)
65807914d74bSmrg	if test "$mode" = clean ; then
65817914d74bSmrg	  noexename=$name
65827914d74bSmrg	  case $file in
65837914d74bSmrg	  *.exe)
65847914d74bSmrg	    file=`$echo $file|${SED} 's,.exe$,,'`
65857914d74bSmrg	    noexename=`$echo $name|${SED} 's,.exe$,,'`
65867914d74bSmrg	    # $file with .exe has already been added to rmfiles,
65877914d74bSmrg	    # add $file without .exe
65887914d74bSmrg	    rmfiles="$rmfiles $file"
65897914d74bSmrg	    ;;
65907914d74bSmrg	  esac
65917914d74bSmrg	  # Do a test to see if this is a libtool program.
65927914d74bSmrg	  if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
65937914d74bSmrg	    relink_command=
65947914d74bSmrg	    . $dir/$noexename
65957914d74bSmrg
65967914d74bSmrg	    # note $name still contains .exe if it was in $file originally
65977914d74bSmrg	    # as does the version of $file that was added into $rmfiles
65987914d74bSmrg	    rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
65997914d74bSmrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
66007914d74bSmrg	      rmfiles="$rmfiles $objdir/lt-$name"
66017914d74bSmrg	    fi
66027914d74bSmrg	    if test "X$noexename" != "X$name" ; then
66037914d74bSmrg	      rmfiles="$rmfiles $objdir/lt-${noexename}.c"
66047914d74bSmrg	    fi
66057914d74bSmrg	  fi
66067914d74bSmrg	fi
66077914d74bSmrg	;;
66087914d74bSmrg      esac
66097914d74bSmrg      $show "$rm $rmfiles"
66107914d74bSmrg      $run $rm $rmfiles || exit_status=1
66117914d74bSmrg    done
66127914d74bSmrg    objdir="$origobjdir"
66137914d74bSmrg
66147914d74bSmrg    # Try to remove the ${objdir}s in the directories where we deleted files
66157914d74bSmrg    for dir in $rmdirs; do
66167914d74bSmrg      if test -d "$dir"; then
66177914d74bSmrg	$show "rmdir $dir"
66187914d74bSmrg	$run rmdir $dir >/dev/null 2>&1
66197914d74bSmrg      fi
66207914d74bSmrg    done
66217914d74bSmrg
66227914d74bSmrg    exit $exit_status
66237914d74bSmrg    ;;
66247914d74bSmrg
66257914d74bSmrg  "")
66267914d74bSmrg    $echo "$modename: you must specify a MODE" 1>&2
66277914d74bSmrg    $echo "$generic_help" 1>&2
66287914d74bSmrg    exit $EXIT_FAILURE
66297914d74bSmrg    ;;
66307914d74bSmrg  esac
66317914d74bSmrg
66327914d74bSmrg  if test -z "$exec_cmd"; then
66337914d74bSmrg    $echo "$modename: invalid operation mode \`$mode'" 1>&2
66347914d74bSmrg    $echo "$generic_help" 1>&2
66357914d74bSmrg    exit $EXIT_FAILURE
66367914d74bSmrg  fi
66377914d74bSmrgfi # test -z "$show_help"
66387914d74bSmrg
66397914d74bSmrgif test -n "$exec_cmd"; then
66407914d74bSmrg  eval exec $exec_cmd
66417914d74bSmrg  exit $EXIT_FAILURE
66427914d74bSmrgfi
66437914d74bSmrg
66447914d74bSmrg# We need to display help for each of the modes.
66457914d74bSmrgcase $mode in
66467914d74bSmrg"") $echo \
66477914d74bSmrg"Usage: $modename [OPTION]... [MODE-ARG]...
66487914d74bSmrg
66497914d74bSmrgProvide generalized library-building support services.
66507914d74bSmrg
66517914d74bSmrg    --config          show all configuration variables
66527914d74bSmrg    --debug           enable verbose shell tracing
66537914d74bSmrg-n, --dry-run         display commands without modifying any files
66547914d74bSmrg    --features        display basic configuration information and exit
66557914d74bSmrg    --finish          same as \`--mode=finish'
66567914d74bSmrg    --help            display this help message and exit
66577914d74bSmrg    --mode=MODE       use operation mode MODE [default=inferred from MODE-ARGS]
66587914d74bSmrg    --quiet           same as \`--silent'
66597914d74bSmrg    --silent          don't print informational messages
66607914d74bSmrg    --tag=TAG         use configuration variables from tag TAG
66617914d74bSmrg    --version         print version information
66627914d74bSmrg
66637914d74bSmrgMODE must be one of the following:
66647914d74bSmrg
66657914d74bSmrg      clean           remove files from the build directory
66667914d74bSmrg      compile         compile a source file into a libtool object
66677914d74bSmrg      execute         automatically set library path, then run a program
66687914d74bSmrg      finish          complete the installation of libtool libraries
66697914d74bSmrg      install         install libraries or executables
66707914d74bSmrg      link            create a library or an executable
66717914d74bSmrg      uninstall       remove libraries from an installed directory
66727914d74bSmrg
66737914d74bSmrgMODE-ARGS vary depending on the MODE.  Try \`$modename --help --mode=MODE' for
66747914d74bSmrga more detailed description of MODE.
66757914d74bSmrg
66767914d74bSmrgReport bugs to <bug-libtool@gnu.org>."
66777914d74bSmrg  exit $EXIT_SUCCESS
66787914d74bSmrg  ;;
66797914d74bSmrg
66807914d74bSmrgclean)
66817914d74bSmrg  $echo \
66827914d74bSmrg"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
66837914d74bSmrg
66847914d74bSmrgRemove files from the build directory.
66857914d74bSmrg
66867914d74bSmrgRM is the name of the program to use to delete files associated with each FILE
66877914d74bSmrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
66887914d74bSmrgto RM.
66897914d74bSmrg
66907914d74bSmrgIf FILE is a libtool library, object or program, all the files associated
66917914d74bSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
66927914d74bSmrg  ;;
66937914d74bSmrg
66947914d74bSmrgcompile)
66957914d74bSmrg  $echo \
66967914d74bSmrg"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
66977914d74bSmrg
66987914d74bSmrgCompile a source file into a libtool library object.
66997914d74bSmrg
67007914d74bSmrgThis mode accepts the following additional options:
67017914d74bSmrg
67027914d74bSmrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
67037914d74bSmrg  -prefer-pic       try to building PIC objects only
67047914d74bSmrg  -prefer-non-pic   try to building non-PIC objects only
67057914d74bSmrg  -static           always build a \`.o' file suitable for static linking
67067914d74bSmrg
67077914d74bSmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
67087914d74bSmrgfrom the given SOURCEFILE.
67097914d74bSmrg
67107914d74bSmrgThe output file name is determined by removing the directory component from
67117914d74bSmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
67127914d74bSmrglibrary object suffix, \`.lo'."
67137914d74bSmrg  ;;
67147914d74bSmrg
67157914d74bSmrgexecute)
67167914d74bSmrg  $echo \
67177914d74bSmrg"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]...
67187914d74bSmrg
67197914d74bSmrgAutomatically set library path, then run a program.
67207914d74bSmrg
67217914d74bSmrgThis mode accepts the following additional options:
67227914d74bSmrg
67237914d74bSmrg  -dlopen FILE      add the directory containing FILE to the library path
67247914d74bSmrg
67257914d74bSmrgThis mode sets the library path environment variable according to \`-dlopen'
67267914d74bSmrgflags.
67277914d74bSmrg
67287914d74bSmrgIf any of the ARGS are libtool executable wrappers, then they are translated
67297914d74bSmrginto their corresponding uninstalled binary, and any of their required library
67307914d74bSmrgdirectories are added to the library path.
67317914d74bSmrg
67327914d74bSmrgThen, COMMAND is executed, with ARGS as arguments."
67337914d74bSmrg  ;;
67347914d74bSmrg
67357914d74bSmrgfinish)
67367914d74bSmrg  $echo \
67377914d74bSmrg"Usage: $modename [OPTION]... --mode=finish [LIBDIR]...
67387914d74bSmrg
67397914d74bSmrgComplete the installation of libtool libraries.
67407914d74bSmrg
67417914d74bSmrgEach LIBDIR is a directory that contains libtool libraries.
67427914d74bSmrg
67437914d74bSmrgThe commands that this mode executes may require superuser privileges.  Use
67447914d74bSmrgthe \`--dry-run' option if you just want to see what would be executed."
67457914d74bSmrg  ;;
67467914d74bSmrg
67477914d74bSmrginstall)
67487914d74bSmrg  $echo \
67497914d74bSmrg"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND...
67507914d74bSmrg
67517914d74bSmrgInstall executables or libraries.
67527914d74bSmrg
67537914d74bSmrgINSTALL-COMMAND is the installation command.  The first component should be
67547914d74bSmrgeither the \`install' or \`cp' program.
67557914d74bSmrg
67567914d74bSmrgThe rest of the components are interpreted as arguments to that command (only
67577914d74bSmrgBSD-compatible install options are recognized)."
67587914d74bSmrg  ;;
67597914d74bSmrg
67607914d74bSmrglink)
67617914d74bSmrg  $echo \
67627914d74bSmrg"Usage: $modename [OPTION]... --mode=link LINK-COMMAND...
67637914d74bSmrg
67647914d74bSmrgLink object files or libraries together to form another library, or to
67657914d74bSmrgcreate an executable program.
67667914d74bSmrg
67677914d74bSmrgLINK-COMMAND is a command using the C compiler that you would use to create
67687914d74bSmrga program from several object files.
67697914d74bSmrg
67707914d74bSmrgThe following components of LINK-COMMAND are treated specially:
67717914d74bSmrg
67727914d74bSmrg  -all-static       do not do any dynamic linking at all
67737914d74bSmrg  -avoid-version    do not add a version suffix if possible
67747914d74bSmrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
67757914d74bSmrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
67767914d74bSmrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
67777914d74bSmrg  -export-symbols SYMFILE
67787914d74bSmrg		    try to export only the symbols listed in SYMFILE
67797914d74bSmrg  -export-symbols-regex REGEX
67807914d74bSmrg		    try to export only the symbols matching REGEX
67817914d74bSmrg  -LLIBDIR          search LIBDIR for required installed libraries
67827914d74bSmrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
67837914d74bSmrg  -module           build a library that can dlopened
67847914d74bSmrg  -no-fast-install  disable the fast-install mode
67857914d74bSmrg  -no-install       link a not-installable executable
67867914d74bSmrg  -no-undefined     declare that a library does not refer to external symbols
67877914d74bSmrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
67887914d74bSmrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
67897914d74bSmrg  -precious-files-regex REGEX
67907914d74bSmrg                    don't remove output files matching REGEX
67917914d74bSmrg  -release RELEASE  specify package release information
67927914d74bSmrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
67937914d74bSmrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
67947914d74bSmrg  -static           do not do any dynamic linking of libtool libraries
67957914d74bSmrg  -version-info CURRENT[:REVISION[:AGE]]
67967914d74bSmrg		    specify library version info [each variable defaults to 0]
67977914d74bSmrg
67987914d74bSmrgAll other options (arguments beginning with \`-') are ignored.
67997914d74bSmrg
68007914d74bSmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
68017914d74bSmrgtreated as uninstalled libtool libraries, other files are standard or library
68027914d74bSmrgobject files.
68037914d74bSmrg
68047914d74bSmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
68057914d74bSmrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
68067914d74bSmrgrequired, except when creating a convenience library.
68077914d74bSmrg
68087914d74bSmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
68097914d74bSmrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
68107914d74bSmrg
68117914d74bSmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
68127914d74bSmrgis created, otherwise an executable program is created."
68137914d74bSmrg  ;;
68147914d74bSmrg
68157914d74bSmrguninstall)
68167914d74bSmrg  $echo \
68177914d74bSmrg"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
68187914d74bSmrg
68197914d74bSmrgRemove libraries from an installation directory.
68207914d74bSmrg
68217914d74bSmrgRM is the name of the program to use to delete files associated with each FILE
68227914d74bSmrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
68237914d74bSmrgto RM.
68247914d74bSmrg
68257914d74bSmrgIf FILE is a libtool library, all the files associated with it are deleted.
68267914d74bSmrgOtherwise, only FILE itself is deleted using RM."
68277914d74bSmrg  ;;
68287914d74bSmrg
68297914d74bSmrg*)
68307914d74bSmrg  $echo "$modename: invalid operation mode \`$mode'" 1>&2
68317914d74bSmrg  $echo "$help" 1>&2
68327914d74bSmrg  exit $EXIT_FAILURE
68337914d74bSmrg  ;;
68347914d74bSmrgesac
68357914d74bSmrg
68367914d74bSmrg$echo
68377914d74bSmrg$echo "Try \`$modename --help' for more information about other modes."
68387914d74bSmrg
68397914d74bSmrgexit $?
68407914d74bSmrg
68417914d74bSmrg# The TAGs below are defined such that we never get into a situation
68427914d74bSmrg# in which we disable both kinds of libraries.  Given conflicting
68437914d74bSmrg# choices, we go for a static library, that is the most portable,
68447914d74bSmrg# since we can't tell whether shared libraries were disabled because
68457914d74bSmrg# the user asked for that or because the platform doesn't support
68467914d74bSmrg# them.  This is particularly important on AIX, because we don't
68477914d74bSmrg# support having both static and shared libraries enabled at the same
68487914d74bSmrg# time on that platform, so we default to a shared-only configuration.
68497914d74bSmrg# If a disable-shared tag is given, we'll fallback to a static-only
68507914d74bSmrg# configuration.  But we'll never go from static-only to shared-only.
68517914d74bSmrg
68527914d74bSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
68537914d74bSmrgdisable_libs=shared
68547914d74bSmrg# ### END LIBTOOL TAG CONFIG: disable-shared
68557914d74bSmrg
68567914d74bSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
68577914d74bSmrgdisable_libs=static
68587914d74bSmrg# ### END LIBTOOL TAG CONFIG: disable-static
68597914d74bSmrg
68607914d74bSmrg# Local Variables:
68617914d74bSmrg# mode:shell-script
68627914d74bSmrg# sh-indentation:2
68637914d74bSmrg# End:
6864