153e90a53Smrg# ltmain.sh - Provide generalized library-building support services.
253e90a53Smrg# NOTE: Changing this file will not affect anything until you rerun configure.
353e90a53Smrg#
453e90a53Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005
553e90a53Smrg# Free Software Foundation, Inc.
653e90a53Smrg# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
753e90a53Smrg#
853e90a53Smrg# This program is free software; you can redistribute it and/or modify
953e90a53Smrg# it under the terms of the GNU General Public License as published by
1053e90a53Smrg# the Free Software Foundation; either version 2 of the License, or
1153e90a53Smrg# (at your option) any later version.
1253e90a53Smrg#
1353e90a53Smrg# This program is distributed in the hope that it will be useful, but
1453e90a53Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
1553e90a53Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1653e90a53Smrg# General Public License for more details.
1753e90a53Smrg#
1853e90a53Smrg# You should have received a copy of the GNU General Public License
1953e90a53Smrg# along with this program; if not, write to the Free Software
2053e90a53Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2153e90a53Smrg#
2253e90a53Smrg# As a special exception to the GNU General Public License, if you
2353e90a53Smrg# distribute this file as part of a program that contains a
2453e90a53Smrg# configuration script generated by Autoconf, you may include it under
2553e90a53Smrg# the same distribution terms that you use for the rest of that program.
2653e90a53Smrg
2753e90a53Smrgbasename="s,^.*/,,g"
2853e90a53Smrg
2953e90a53Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
3053e90a53Smrg# is ksh but when the shell is invoked as "sh" and the current value of
3153e90a53Smrg# the _XPG environment variable is not equal to 1 (one), the special
3253e90a53Smrg# positional parameter $0, within a function call, is the name of the
3353e90a53Smrg# function.
3453e90a53Smrgprogpath="$0"
3553e90a53Smrg
3653e90a53Smrg# The name of this program:
3753e90a53Smrgprogname=`echo "$progpath" | $SED $basename`
3853e90a53Smrgmodename="$progname"
3953e90a53Smrg
4053e90a53Smrg# Global variables:
4153e90a53SmrgEXIT_SUCCESS=0
4253e90a53SmrgEXIT_FAILURE=1
4353e90a53Smrg
4453e90a53SmrgPROGRAM=ltmain.sh
4553e90a53SmrgPACKAGE=libtool
4653e90a53SmrgVERSION=1.5.22
4753e90a53SmrgTIMESTAMP=" (1.1220.2.365 2005/12/18 22:14:06)"
4853e90a53Smrg
4953e90a53Smrg# See if we are running on zsh, and set the options which allow our
5053e90a53Smrg# commands through without removal of \ escapes.
5153e90a53Smrgif test -n "${ZSH_VERSION+set}" ; then
5253e90a53Smrg  setopt NO_GLOB_SUBST
5353e90a53Smrgfi
5453e90a53Smrg
5553e90a53Smrg# Check that we have a working $echo.
5653e90a53Smrgif test "X$1" = X--no-reexec; then
5753e90a53Smrg  # Discard the --no-reexec flag, and continue.
5853e90a53Smrg  shift
5953e90a53Smrgelif test "X$1" = X--fallback-echo; then
6053e90a53Smrg  # Avoid inline document here, it may be left over
6153e90a53Smrg  :
6253e90a53Smrgelif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
6353e90a53Smrg  # Yippee, $echo works!
6453e90a53Smrg  :
6553e90a53Smrgelse
6653e90a53Smrg  # Restart under the correct shell, and then maybe $echo will work.
6753e90a53Smrg  exec $SHELL "$progpath" --no-reexec ${1+"$@"}
6853e90a53Smrgfi
6953e90a53Smrg
7053e90a53Smrgif test "X$1" = X--fallback-echo; then
7153e90a53Smrg  # used as fallback echo
7253e90a53Smrg  shift
7353e90a53Smrg  cat <<EOF
7453e90a53Smrg$*
7553e90a53SmrgEOF
7653e90a53Smrg  exit $EXIT_SUCCESS
7753e90a53Smrgfi
7853e90a53Smrg
7953e90a53Smrgdefault_mode=
8053e90a53Smrghelp="Try \`$progname --help' for more information."
8153e90a53Smrgmagic="%%%MAGIC variable%%%"
8253e90a53Smrgmkdir="mkdir"
8353e90a53Smrgmv="mv -f"
8453e90a53Smrgrm="rm -f"
8553e90a53Smrg
8653e90a53Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
8753e90a53Smrg# metacharacters that are still active within double-quoted strings.
8853e90a53SmrgXsed="${SED}"' -e 1s/^X//'
8953e90a53Smrgsed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
9053e90a53Smrg# test EBCDIC or ASCII
9153e90a53Smrgcase `echo X|tr X '\101'` in
9253e90a53Smrg A) # ASCII based system
9353e90a53Smrg    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
9453e90a53Smrg  SP2NL='tr \040 \012'
9553e90a53Smrg  NL2SP='tr \015\012 \040\040'
9653e90a53Smrg  ;;
9753e90a53Smrg *) # EBCDIC based system
9853e90a53Smrg  SP2NL='tr \100 \n'
9953e90a53Smrg  NL2SP='tr \r\n \100\100'
10053e90a53Smrg  ;;
10153e90a53Smrgesac
10253e90a53Smrg
10353e90a53Smrg# NLS nuisances.
10453e90a53Smrg# Only set LANG and LC_ALL to C if already set.
10553e90a53Smrg# These must not be set unconditionally because not all systems understand
10653e90a53Smrg# e.g. LANG=C (notably SCO).
10753e90a53Smrg# We save the old values to restore during execute mode.
10853e90a53Smrgif test "${LC_ALL+set}" = set; then
10953e90a53Smrg  save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
11053e90a53Smrgfi
11153e90a53Smrgif test "${LANG+set}" = set; then
11253e90a53Smrg  save_LANG="$LANG"; LANG=C; export LANG
11353e90a53Smrgfi
11453e90a53Smrg
11553e90a53Smrg# Make sure IFS has a sensible default
11653e90a53Smrglt_nl='
11753e90a53Smrg'
11853e90a53SmrgIFS=" 	$lt_nl"
11953e90a53Smrg
12053e90a53Smrgif test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
12153e90a53Smrg  $echo "$modename: not configured to build any kind of library" 1>&2
12253e90a53Smrg  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
12353e90a53Smrg  exit $EXIT_FAILURE
12453e90a53Smrgfi
12553e90a53Smrg
12653e90a53Smrg# Global variables.
12753e90a53Smrgmode=$default_mode
12853e90a53Smrgnonopt=
12953e90a53Smrgprev=
13053e90a53Smrgprevopt=
13153e90a53Smrgrun=
13253e90a53Smrgshow="$echo"
13353e90a53Smrgshow_help=
13453e90a53Smrgexecute_dlfiles=
13553e90a53Smrgduplicate_deps=no
13653e90a53Smrgpreserve_args=
13753e90a53Smrglo2o="s/\\.lo\$/.${objext}/"
13853e90a53Smrgo2lo="s/\\.${objext}\$/.lo/"
13953e90a53Smrg
14053e90a53Smrg#####################################
14153e90a53Smrg# Shell function definitions:
14253e90a53Smrg# This seems to be the best place for them
14353e90a53Smrg
14453e90a53Smrg# func_mktempdir [string]
14553e90a53Smrg# Make a temporary directory that won't clash with other running
14653e90a53Smrg# libtool processes, and avoids race conditions if possible.  If
14753e90a53Smrg# given, STRING is the basename for that directory.
14853e90a53Smrgfunc_mktempdir ()
14953e90a53Smrg{
15053e90a53Smrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
15153e90a53Smrg
15253e90a53Smrg    if test "$run" = ":"; then
15353e90a53Smrg      # Return a directory name, but don't create it in dry-run mode
15453e90a53Smrg      my_tmpdir="${my_template}-$$"
15553e90a53Smrg    else
15653e90a53Smrg
15753e90a53Smrg      # If mktemp works, use that first and foremost
15853e90a53Smrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
15953e90a53Smrg
16053e90a53Smrg      if test ! -d "$my_tmpdir"; then
16153e90a53Smrg	# Failing that, at least try and use $RANDOM to avoid a race
16253e90a53Smrg	my_tmpdir="${my_template}-${RANDOM-0}$$"
16353e90a53Smrg
16453e90a53Smrg	save_mktempdir_umask=`umask`
16553e90a53Smrg	umask 0077
16653e90a53Smrg	$mkdir "$my_tmpdir"
16753e90a53Smrg	umask $save_mktempdir_umask
16853e90a53Smrg      fi
16953e90a53Smrg
17053e90a53Smrg      # If we're not in dry-run mode, bomb out on failure
17153e90a53Smrg      test -d "$my_tmpdir" || {
17253e90a53Smrg        $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
17353e90a53Smrg	exit $EXIT_FAILURE
17453e90a53Smrg      }
17553e90a53Smrg    fi
17653e90a53Smrg
17753e90a53Smrg    $echo "X$my_tmpdir" | $Xsed
17853e90a53Smrg}
17953e90a53Smrg
18053e90a53Smrg
18153e90a53Smrg# func_win32_libid arg
18253e90a53Smrg# return the library type of file 'arg'
18353e90a53Smrg#
18453e90a53Smrg# Need a lot of goo to handle *both* DLLs and import libs
18553e90a53Smrg# Has to be a shell function in order to 'eat' the argument
18653e90a53Smrg# that is supplied when $file_magic_command is called.
18753e90a53Smrgfunc_win32_libid ()
18853e90a53Smrg{
18953e90a53Smrg  win32_libid_type="unknown"
19053e90a53Smrg  win32_fileres=`file -L $1 2>/dev/null`
19153e90a53Smrg  case $win32_fileres in
19253e90a53Smrg  *ar\ archive\ import\ library*) # definitely import
19353e90a53Smrg    win32_libid_type="x86 archive import"
19453e90a53Smrg    ;;
19553e90a53Smrg  *ar\ archive*) # could be an import, or static
19653e90a53Smrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
19753e90a53Smrg      $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
19853e90a53Smrg      win32_nmres=`eval $NM -f posix -A $1 | \
19953e90a53Smrg	$SED -n -e '1,100{/ I /{s,.*,import,;p;q;};}'`
20053e90a53Smrg      case $win32_nmres in
20153e90a53Smrg      import*)  win32_libid_type="x86 archive import";;
20253e90a53Smrg      *)        win32_libid_type="x86 archive static";;
20353e90a53Smrg      esac
20453e90a53Smrg    fi
20553e90a53Smrg    ;;
20653e90a53Smrg  *DLL*)
20753e90a53Smrg    win32_libid_type="x86 DLL"
20853e90a53Smrg    ;;
20953e90a53Smrg  *executable*) # but shell scripts are "executable" too...
21053e90a53Smrg    case $win32_fileres in
21153e90a53Smrg    *MS\ Windows\ PE\ Intel*)
21253e90a53Smrg      win32_libid_type="x86 DLL"
21353e90a53Smrg      ;;
21453e90a53Smrg    esac
21553e90a53Smrg    ;;
21653e90a53Smrg  esac
21753e90a53Smrg  $echo $win32_libid_type
21853e90a53Smrg}
21953e90a53Smrg
22053e90a53Smrg
22153e90a53Smrg# func_infer_tag arg
22253e90a53Smrg# Infer tagged configuration to use if any are available and
22353e90a53Smrg# if one wasn't chosen via the "--tag" command line option.
22453e90a53Smrg# Only attempt this if the compiler in the base compile
22553e90a53Smrg# command doesn't match the default compiler.
22653e90a53Smrg# arg is usually of the form 'gcc ...'
22753e90a53Smrgfunc_infer_tag ()
22853e90a53Smrg{
22953e90a53Smrg    if test -n "$available_tags" && test -z "$tagname"; then
23053e90a53Smrg      CC_quoted=
23153e90a53Smrg      for arg in $CC; do
23253e90a53Smrg	case $arg in
23353e90a53Smrg	  *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
23453e90a53Smrg	  arg="\"$arg\""
23553e90a53Smrg	  ;;
23653e90a53Smrg	esac
23753e90a53Smrg	CC_quoted="$CC_quoted $arg"
23853e90a53Smrg      done
23953e90a53Smrg      case $@ in
24053e90a53Smrg      # Blanks in the command may have been stripped by the calling shell,
24153e90a53Smrg      # but not from the CC environment variable when configure was run.
24253e90a53Smrg      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
24353e90a53Smrg      # Blanks at the start of $base_compile will cause this to fail
24453e90a53Smrg      # if we don't check for them as well.
24553e90a53Smrg      *)
24653e90a53Smrg	for z in $available_tags; do
24753e90a53Smrg	  if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
24853e90a53Smrg	    # Evaluate the configuration.
24953e90a53Smrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
25053e90a53Smrg	    CC_quoted=
25153e90a53Smrg	    for arg in $CC; do
25253e90a53Smrg	    # Double-quote args containing other shell metacharacters.
25353e90a53Smrg	    case $arg in
25453e90a53Smrg	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
25553e90a53Smrg	      arg="\"$arg\""
25653e90a53Smrg	      ;;
25753e90a53Smrg	    esac
25853e90a53Smrg	    CC_quoted="$CC_quoted $arg"
25953e90a53Smrg	  done
26053e90a53Smrg	    case "$@ " in
26153e90a53Smrg	      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
26253e90a53Smrg	      # The compiler in the base compile command matches
26353e90a53Smrg	      # the one in the tagged configuration.
26453e90a53Smrg	      # Assume this is the tagged configuration we want.
26553e90a53Smrg	      tagname=$z
26653e90a53Smrg	      break
26753e90a53Smrg	      ;;
26853e90a53Smrg	    esac
26953e90a53Smrg	  fi
27053e90a53Smrg	done
27153e90a53Smrg	# If $tagname still isn't set, then no tagged configuration
27253e90a53Smrg	# was found and let the user know that the "--tag" command
27353e90a53Smrg	# line option must be used.
27453e90a53Smrg	if test -z "$tagname"; then
27553e90a53Smrg	  $echo "$modename: unable to infer tagged configuration"
27653e90a53Smrg	  $echo "$modename: specify a tag with \`--tag'" 1>&2
27753e90a53Smrg	  exit $EXIT_FAILURE
27853e90a53Smrg#        else
27953e90a53Smrg#          $echo "$modename: using $tagname tagged configuration"
28053e90a53Smrg	fi
28153e90a53Smrg	;;
28253e90a53Smrg      esac
28353e90a53Smrg    fi
28453e90a53Smrg}
28553e90a53Smrg
28653e90a53Smrg
28753e90a53Smrg# func_extract_an_archive dir oldlib
28853e90a53Smrgfunc_extract_an_archive ()
28953e90a53Smrg{
29053e90a53Smrg    f_ex_an_ar_dir="$1"; shift
29153e90a53Smrg    f_ex_an_ar_oldlib="$1"
29253e90a53Smrg
29353e90a53Smrg    $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
29453e90a53Smrg    $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
29553e90a53Smrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
29653e90a53Smrg     :
29753e90a53Smrg    else
29853e90a53Smrg      $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2
29953e90a53Smrg      exit $EXIT_FAILURE
30053e90a53Smrg    fi
30153e90a53Smrg}
30253e90a53Smrg
30353e90a53Smrg# func_extract_archives gentop oldlib ...
30453e90a53Smrgfunc_extract_archives ()
30553e90a53Smrg{
30653e90a53Smrg    my_gentop="$1"; shift
30753e90a53Smrg    my_oldlibs=${1+"$@"}
30853e90a53Smrg    my_oldobjs=""
30953e90a53Smrg    my_xlib=""
31053e90a53Smrg    my_xabs=""
31153e90a53Smrg    my_xdir=""
31253e90a53Smrg    my_status=""
31353e90a53Smrg
31453e90a53Smrg    $show "${rm}r $my_gentop"
31553e90a53Smrg    $run ${rm}r "$my_gentop"
31653e90a53Smrg    $show "$mkdir $my_gentop"
31753e90a53Smrg    $run $mkdir "$my_gentop"
31853e90a53Smrg    my_status=$?
31953e90a53Smrg    if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
32053e90a53Smrg      exit $my_status
32153e90a53Smrg    fi
32253e90a53Smrg
32353e90a53Smrg    for my_xlib in $my_oldlibs; do
32453e90a53Smrg      # Extract the objects.
32553e90a53Smrg      case $my_xlib in
32653e90a53Smrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
32753e90a53Smrg	*) my_xabs=`pwd`"/$my_xlib" ;;
32853e90a53Smrg      esac
32953e90a53Smrg      my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
33053e90a53Smrg      my_xdir="$my_gentop/$my_xlib"
33153e90a53Smrg
33253e90a53Smrg      $show "${rm}r $my_xdir"
33353e90a53Smrg      $run ${rm}r "$my_xdir"
33453e90a53Smrg      $show "$mkdir $my_xdir"
33553e90a53Smrg      $run $mkdir "$my_xdir"
33653e90a53Smrg      exit_status=$?
33753e90a53Smrg      if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then
33853e90a53Smrg	exit $exit_status
33953e90a53Smrg      fi
34053e90a53Smrg      case $host in
34153e90a53Smrg      *-darwin*)
34253e90a53Smrg	$show "Extracting $my_xabs"
34353e90a53Smrg	# Do not bother doing anything if just a dry run
34453e90a53Smrg	if test -z "$run"; then
34553e90a53Smrg	  darwin_orig_dir=`pwd`
34653e90a53Smrg	  cd $my_xdir || exit $?
34753e90a53Smrg	  darwin_archive=$my_xabs
34853e90a53Smrg	  darwin_curdir=`pwd`
34953e90a53Smrg	  darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'`
35053e90a53Smrg	  darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
35153e90a53Smrg	  if test -n "$darwin_arches"; then 
35253e90a53Smrg	    darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
35353e90a53Smrg	    darwin_arch=
35453e90a53Smrg	    $show "$darwin_base_archive has multiple architectures $darwin_arches"
35553e90a53Smrg	    for darwin_arch in  $darwin_arches ; do
35653e90a53Smrg	      mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
35753e90a53Smrg	      lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
35853e90a53Smrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
35953e90a53Smrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
36053e90a53Smrg	      cd "$darwin_curdir"
36153e90a53Smrg	      $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
36253e90a53Smrg	    done # $darwin_arches
36353e90a53Smrg      ## Okay now we have a bunch of thin objects, gotta fatten them up :)
36453e90a53Smrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP`
36553e90a53Smrg	    darwin_file=
36653e90a53Smrg	    darwin_files=
36753e90a53Smrg	    for darwin_file in $darwin_filelist; do
36853e90a53Smrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
36953e90a53Smrg	      lipo -create -output "$darwin_file" $darwin_files
37053e90a53Smrg	    done # $darwin_filelist
37153e90a53Smrg	    ${rm}r unfat-$$
37253e90a53Smrg	    cd "$darwin_orig_dir"
37353e90a53Smrg	  else
37453e90a53Smrg	    cd "$darwin_orig_dir"
37553e90a53Smrg 	    func_extract_an_archive "$my_xdir" "$my_xabs"
37653e90a53Smrg	  fi # $darwin_arches
37753e90a53Smrg	fi # $run
37853e90a53Smrg	;;
37953e90a53Smrg      *)
38053e90a53Smrg        func_extract_an_archive "$my_xdir" "$my_xabs"
38153e90a53Smrg        ;;
38253e90a53Smrg      esac
38353e90a53Smrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
38453e90a53Smrg    done
38553e90a53Smrg    func_extract_archives_result="$my_oldobjs"
38653e90a53Smrg}
38753e90a53Smrg# End of Shell function definitions
38853e90a53Smrg#####################################
38953e90a53Smrg
39053e90a53Smrg# Darwin sucks
39153e90a53Smrgeval std_shrext=\"$shrext_cmds\"
39253e90a53Smrg
39353e90a53Smrgdisable_libs=no
39453e90a53Smrg
39553e90a53Smrg# Parse our command line options once, thoroughly.
39653e90a53Smrgwhile test "$#" -gt 0
39753e90a53Smrgdo
39853e90a53Smrg  arg="$1"
39953e90a53Smrg  shift
40053e90a53Smrg
40153e90a53Smrg  case $arg in
40253e90a53Smrg  -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
40353e90a53Smrg  *) optarg= ;;
40453e90a53Smrg  esac
40553e90a53Smrg
40653e90a53Smrg  # If the previous option needs an argument, assign it.
40753e90a53Smrg  if test -n "$prev"; then
40853e90a53Smrg    case $prev in
40953e90a53Smrg    execute_dlfiles)
41053e90a53Smrg      execute_dlfiles="$execute_dlfiles $arg"
41153e90a53Smrg      ;;
41253e90a53Smrg    tag)
41353e90a53Smrg      tagname="$arg"
41453e90a53Smrg      preserve_args="${preserve_args}=$arg"
41553e90a53Smrg
41653e90a53Smrg      # Check whether tagname contains only valid characters
41753e90a53Smrg      case $tagname in
41853e90a53Smrg      *[!-_A-Za-z0-9,/]*)
41953e90a53Smrg	$echo "$progname: invalid tag name: $tagname" 1>&2
42053e90a53Smrg	exit $EXIT_FAILURE
42153e90a53Smrg	;;
42253e90a53Smrg      esac
42353e90a53Smrg
42453e90a53Smrg      case $tagname in
42553e90a53Smrg      CC)
42653e90a53Smrg	# Don't test for the "default" C tag, as we know, it's there, but
42753e90a53Smrg	# not specially marked.
42853e90a53Smrg	;;
42953e90a53Smrg      *)
43053e90a53Smrg	if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then
43153e90a53Smrg	  taglist="$taglist $tagname"
43253e90a53Smrg	  # Evaluate the configuration.
43353e90a53Smrg	  eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`"
43453e90a53Smrg	else
43553e90a53Smrg	  $echo "$progname: ignoring unknown tag $tagname" 1>&2
43653e90a53Smrg	fi
43753e90a53Smrg	;;
43853e90a53Smrg      esac
43953e90a53Smrg      ;;
44053e90a53Smrg    *)
44153e90a53Smrg      eval "$prev=\$arg"
44253e90a53Smrg      ;;
44353e90a53Smrg    esac
44453e90a53Smrg
44553e90a53Smrg    prev=
44653e90a53Smrg    prevopt=
44753e90a53Smrg    continue
44853e90a53Smrg  fi
44953e90a53Smrg
45053e90a53Smrg  # Have we seen a non-optional argument yet?
45153e90a53Smrg  case $arg in
45253e90a53Smrg  --help)
45353e90a53Smrg    show_help=yes
45453e90a53Smrg    ;;
45553e90a53Smrg
45653e90a53Smrg  --version)
45753e90a53Smrg    $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
45853e90a53Smrg    $echo
45953e90a53Smrg    $echo "Copyright (C) 2005  Free Software Foundation, Inc."
46053e90a53Smrg    $echo "This is free software; see the source for copying conditions.  There is NO"
46153e90a53Smrg    $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
46253e90a53Smrg    exit $?
46353e90a53Smrg    ;;
46453e90a53Smrg
46553e90a53Smrg  --config)
46653e90a53Smrg    ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath
46753e90a53Smrg    # Now print the configurations for the tags.
46853e90a53Smrg    for tagname in $taglist; do
46953e90a53Smrg      ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
47053e90a53Smrg    done
47153e90a53Smrg    exit $?
47253e90a53Smrg    ;;
47353e90a53Smrg
47453e90a53Smrg  --debug)
47553e90a53Smrg    $echo "$progname: enabling shell trace mode"
47653e90a53Smrg    set -x
47753e90a53Smrg    preserve_args="$preserve_args $arg"
47853e90a53Smrg    ;;
47953e90a53Smrg
48053e90a53Smrg  --dry-run | -n)
48153e90a53Smrg    run=:
48253e90a53Smrg    ;;
48353e90a53Smrg
48453e90a53Smrg  --features)
48553e90a53Smrg    $echo "host: $host"
48653e90a53Smrg    if test "$build_libtool_libs" = yes; then
48753e90a53Smrg      $echo "enable shared libraries"
48853e90a53Smrg    else
48953e90a53Smrg      $echo "disable shared libraries"
49053e90a53Smrg    fi
49153e90a53Smrg    if test "$build_old_libs" = yes; then
49253e90a53Smrg      $echo "enable static libraries"
49353e90a53Smrg    else
49453e90a53Smrg      $echo "disable static libraries"
49553e90a53Smrg    fi
49653e90a53Smrg    exit $?
49753e90a53Smrg    ;;
49853e90a53Smrg
49953e90a53Smrg  --finish) mode="finish" ;;
50053e90a53Smrg
50153e90a53Smrg  --mode) prevopt="--mode" prev=mode ;;
50253e90a53Smrg  --mode=*) mode="$optarg" ;;
50353e90a53Smrg
50453e90a53Smrg  --preserve-dup-deps) duplicate_deps="yes" ;;
50553e90a53Smrg
50653e90a53Smrg  --quiet | --silent)
50753e90a53Smrg    show=:
50853e90a53Smrg    preserve_args="$preserve_args $arg"
50953e90a53Smrg    ;;
51053e90a53Smrg
51153e90a53Smrg  --tag)
51253e90a53Smrg    prevopt="--tag"
51353e90a53Smrg    prev=tag
51453e90a53Smrg    preserve_args="$preserve_args --tag"
51553e90a53Smrg    ;;
51653e90a53Smrg  --tag=*)
51753e90a53Smrg    set tag "$optarg" ${1+"$@"}
51853e90a53Smrg    shift
51953e90a53Smrg    prev=tag
52053e90a53Smrg    preserve_args="$preserve_args --tag"
52153e90a53Smrg    ;;
52253e90a53Smrg
52353e90a53Smrg  -dlopen)
52453e90a53Smrg    prevopt="-dlopen"
52553e90a53Smrg    prev=execute_dlfiles
52653e90a53Smrg    ;;
52753e90a53Smrg
52853e90a53Smrg  -*)
52953e90a53Smrg    $echo "$modename: unrecognized option \`$arg'" 1>&2
53053e90a53Smrg    $echo "$help" 1>&2
53153e90a53Smrg    exit $EXIT_FAILURE
53253e90a53Smrg    ;;
53353e90a53Smrg
53453e90a53Smrg  *)
53553e90a53Smrg    nonopt="$arg"
53653e90a53Smrg    break
53753e90a53Smrg    ;;
53853e90a53Smrg  esac
53953e90a53Smrgdone
54053e90a53Smrg
54153e90a53Smrgif test -n "$prevopt"; then
54253e90a53Smrg  $echo "$modename: option \`$prevopt' requires an argument" 1>&2
54353e90a53Smrg  $echo "$help" 1>&2
54453e90a53Smrg  exit $EXIT_FAILURE
54553e90a53Smrgfi
54653e90a53Smrg
54753e90a53Smrgcase $disable_libs in
54853e90a53Smrgno) 
54953e90a53Smrg  ;;
55053e90a53Smrgshared)
55153e90a53Smrg  build_libtool_libs=no
55253e90a53Smrg  build_old_libs=yes
55353e90a53Smrg  ;;
55453e90a53Smrgstatic)
55553e90a53Smrg  build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
55653e90a53Smrg  ;;
55753e90a53Smrgesac
55853e90a53Smrg
55953e90a53Smrg# If this variable is set in any of the actions, the command in it
56053e90a53Smrg# will be execed at the end.  This prevents here-documents from being
56153e90a53Smrg# left over by shells.
56253e90a53Smrgexec_cmd=
56353e90a53Smrg
56453e90a53Smrgif test -z "$show_help"; then
56553e90a53Smrg
56653e90a53Smrg  # Infer the operation mode.
56753e90a53Smrg  if test -z "$mode"; then
56853e90a53Smrg    $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
56953e90a53Smrg    $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2
57053e90a53Smrg    case $nonopt in
57153e90a53Smrg    *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
57253e90a53Smrg      mode=link
57353e90a53Smrg      for arg
57453e90a53Smrg      do
57553e90a53Smrg	case $arg in
57653e90a53Smrg	-c)
57753e90a53Smrg	   mode=compile
57853e90a53Smrg	   break
57953e90a53Smrg	   ;;
58053e90a53Smrg	esac
58153e90a53Smrg      done
58253e90a53Smrg      ;;
58353e90a53Smrg    *db | *dbx | *strace | *truss)
58453e90a53Smrg      mode=execute
58553e90a53Smrg      ;;
58653e90a53Smrg    *install*|cp|mv)
58753e90a53Smrg      mode=install
58853e90a53Smrg      ;;
58953e90a53Smrg    *rm)
59053e90a53Smrg      mode=uninstall
59153e90a53Smrg      ;;
59253e90a53Smrg    *)
59353e90a53Smrg      # If we have no mode, but dlfiles were specified, then do execute mode.
59453e90a53Smrg      test -n "$execute_dlfiles" && mode=execute
59553e90a53Smrg
59653e90a53Smrg      # Just use the default operation mode.
59753e90a53Smrg      if test -z "$mode"; then
59853e90a53Smrg	if test -n "$nonopt"; then
59953e90a53Smrg	  $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
60053e90a53Smrg	else
60153e90a53Smrg	  $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
60253e90a53Smrg	fi
60353e90a53Smrg      fi
60453e90a53Smrg      ;;
60553e90a53Smrg    esac
60653e90a53Smrg  fi
60753e90a53Smrg
60853e90a53Smrg  # Only execute mode is allowed to have -dlopen flags.
60953e90a53Smrg  if test -n "$execute_dlfiles" && test "$mode" != execute; then
61053e90a53Smrg    $echo "$modename: unrecognized option \`-dlopen'" 1>&2
61153e90a53Smrg    $echo "$help" 1>&2
61253e90a53Smrg    exit $EXIT_FAILURE
61353e90a53Smrg  fi
61453e90a53Smrg
61553e90a53Smrg  # Change the help message to a mode-specific one.
61653e90a53Smrg  generic_help="$help"
61753e90a53Smrg  help="Try \`$modename --help --mode=$mode' for more information."
61853e90a53Smrg
61953e90a53Smrg  # These modes are in order of execution frequency so that they run quickly.
62053e90a53Smrg  case $mode in
62153e90a53Smrg  # libtool compile mode
62253e90a53Smrg  compile)
62353e90a53Smrg    modename="$modename: compile"
62453e90a53Smrg    # Get the compilation command and the source file.
62553e90a53Smrg    base_compile=
62653e90a53Smrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
62753e90a53Smrg    suppress_opt=yes
62853e90a53Smrg    suppress_output=
62953e90a53Smrg    arg_mode=normal
63053e90a53Smrg    libobj=
63153e90a53Smrg    later=
63253e90a53Smrg
63353e90a53Smrg    for arg
63453e90a53Smrg    do
63553e90a53Smrg      case $arg_mode in
63653e90a53Smrg      arg  )
63753e90a53Smrg	# do not "continue".  Instead, add this to base_compile
63853e90a53Smrg	lastarg="$arg"
63953e90a53Smrg	arg_mode=normal
64053e90a53Smrg	;;
64153e90a53Smrg
64253e90a53Smrg      target )
64353e90a53Smrg	libobj="$arg"
64453e90a53Smrg	arg_mode=normal
64553e90a53Smrg	continue
64653e90a53Smrg	;;
64753e90a53Smrg
64853e90a53Smrg      normal )
64953e90a53Smrg	# Accept any command-line options.
65053e90a53Smrg	case $arg in
65153e90a53Smrg	-o)
65253e90a53Smrg	  if test -n "$libobj" ; then
65353e90a53Smrg	    $echo "$modename: you cannot specify \`-o' more than once" 1>&2
65453e90a53Smrg	    exit $EXIT_FAILURE
65553e90a53Smrg	  fi
65653e90a53Smrg	  arg_mode=target
65753e90a53Smrg	  continue
65853e90a53Smrg	  ;;
65953e90a53Smrg
66053e90a53Smrg	-static | -prefer-pic | -prefer-non-pic)
66153e90a53Smrg	  later="$later $arg"
66253e90a53Smrg	  continue
66353e90a53Smrg	  ;;
66453e90a53Smrg
66553e90a53Smrg	-no-suppress)
66653e90a53Smrg	  suppress_opt=no
66753e90a53Smrg	  continue
66853e90a53Smrg	  ;;
66953e90a53Smrg
67053e90a53Smrg	-Xcompiler)
67153e90a53Smrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
67253e90a53Smrg	  continue      #  The current "srcfile" will either be retained or
67353e90a53Smrg	  ;;            #  replaced later.  I would guess that would be a bug.
67453e90a53Smrg
67553e90a53Smrg	-Wc,*)
67653e90a53Smrg	  args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
67753e90a53Smrg	  lastarg=
67853e90a53Smrg	  save_ifs="$IFS"; IFS=','
67953e90a53Smrg 	  for arg in $args; do
68053e90a53Smrg	    IFS="$save_ifs"
68153e90a53Smrg
68253e90a53Smrg	    # Double-quote args containing other shell metacharacters.
68353e90a53Smrg	    # Many Bourne shells cannot handle close brackets correctly
68453e90a53Smrg	    # in scan sets, so we specify it separately.
68553e90a53Smrg	    case $arg in
68653e90a53Smrg	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
68753e90a53Smrg	      arg="\"$arg\""
68853e90a53Smrg	      ;;
68953e90a53Smrg	    esac
69053e90a53Smrg	    lastarg="$lastarg $arg"
69153e90a53Smrg	  done
69253e90a53Smrg	  IFS="$save_ifs"
69353e90a53Smrg	  lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
69453e90a53Smrg
69553e90a53Smrg	  # Add the arguments to base_compile.
69653e90a53Smrg	  base_compile="$base_compile $lastarg"
69753e90a53Smrg	  continue
69853e90a53Smrg	  ;;
69953e90a53Smrg
70053e90a53Smrg	* )
70153e90a53Smrg	  # Accept the current argument as the source file.
70253e90a53Smrg	  # The previous "srcfile" becomes the current argument.
70353e90a53Smrg	  #
70453e90a53Smrg	  lastarg="$srcfile"
70553e90a53Smrg	  srcfile="$arg"
70653e90a53Smrg	  ;;
70753e90a53Smrg	esac  #  case $arg
70853e90a53Smrg	;;
70953e90a53Smrg      esac    #  case $arg_mode
71053e90a53Smrg
71153e90a53Smrg      # Aesthetically quote the previous argument.
71253e90a53Smrg      lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
71353e90a53Smrg
71453e90a53Smrg      case $lastarg in
71553e90a53Smrg      # Double-quote args containing other shell metacharacters.
71653e90a53Smrg      # Many Bourne shells cannot handle close brackets correctly
71753e90a53Smrg      # in scan sets, and some SunOS ksh mistreat backslash-escaping
71853e90a53Smrg      # in scan sets (worked around with variable expansion),
71953e90a53Smrg      # and furthermore cannot handle '|' '&' '(' ')' in scan sets 
72053e90a53Smrg      # at all, so we specify them separately.
72153e90a53Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
72253e90a53Smrg	lastarg="\"$lastarg\""
72353e90a53Smrg	;;
72453e90a53Smrg      esac
72553e90a53Smrg
72653e90a53Smrg      base_compile="$base_compile $lastarg"
72753e90a53Smrg    done # for arg
72853e90a53Smrg
72953e90a53Smrg    case $arg_mode in
73053e90a53Smrg    arg)
73153e90a53Smrg      $echo "$modename: you must specify an argument for -Xcompile"
73253e90a53Smrg      exit $EXIT_FAILURE
73353e90a53Smrg      ;;
73453e90a53Smrg    target)
73553e90a53Smrg      $echo "$modename: you must specify a target with \`-o'" 1>&2
73653e90a53Smrg      exit $EXIT_FAILURE
73753e90a53Smrg      ;;
73853e90a53Smrg    *)
73953e90a53Smrg      # Get the name of the library object.
74053e90a53Smrg      [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
74153e90a53Smrg      ;;
74253e90a53Smrg    esac
74353e90a53Smrg
74453e90a53Smrg    # Recognize several different file suffixes.
74553e90a53Smrg    # If the user specifies -o file.o, it is replaced with file.lo
74653e90a53Smrg    xform='[cCFSifmso]'
74753e90a53Smrg    case $libobj in
74853e90a53Smrg    *.ada) xform=ada ;;
74953e90a53Smrg    *.adb) xform=adb ;;
75053e90a53Smrg    *.ads) xform=ads ;;
75153e90a53Smrg    *.asm) xform=asm ;;
75253e90a53Smrg    *.c++) xform=c++ ;;
75353e90a53Smrg    *.cc) xform=cc ;;
75453e90a53Smrg    *.ii) xform=ii ;;
75553e90a53Smrg    *.class) xform=class ;;
75653e90a53Smrg    *.cpp) xform=cpp ;;
75753e90a53Smrg    *.cxx) xform=cxx ;;
75853e90a53Smrg    *.f90) xform=f90 ;;
75953e90a53Smrg    *.for) xform=for ;;
76053e90a53Smrg    *.java) xform=java ;;
76153e90a53Smrg    esac
76253e90a53Smrg
76353e90a53Smrg    libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
76453e90a53Smrg
76553e90a53Smrg    case $libobj in
76653e90a53Smrg    *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
76753e90a53Smrg    *)
76853e90a53Smrg      $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
76953e90a53Smrg      exit $EXIT_FAILURE
77053e90a53Smrg      ;;
77153e90a53Smrg    esac
77253e90a53Smrg
77353e90a53Smrg    func_infer_tag $base_compile
77453e90a53Smrg
77553e90a53Smrg    for arg in $later; do
77653e90a53Smrg      case $arg in
77753e90a53Smrg      -static)
77853e90a53Smrg	build_old_libs=yes
77953e90a53Smrg	continue
78053e90a53Smrg	;;
78153e90a53Smrg
78253e90a53Smrg      -prefer-pic)
78353e90a53Smrg	pic_mode=yes
78453e90a53Smrg	continue
78553e90a53Smrg	;;
78653e90a53Smrg
78753e90a53Smrg      -prefer-non-pic)
78853e90a53Smrg	pic_mode=no
78953e90a53Smrg	continue
79053e90a53Smrg	;;
79153e90a53Smrg      esac
79253e90a53Smrg    done
79353e90a53Smrg
79453e90a53Smrg    qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"`
79553e90a53Smrg    case $qlibobj in
79653e90a53Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
79753e90a53Smrg	qlibobj="\"$qlibobj\"" ;;
79853e90a53Smrg    esac
79953e90a53Smrg    test "X$libobj" != "X$qlibobj" \
80053e90a53Smrg	&& $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"' 	&()|`$[]' \
80153e90a53Smrg	&& $echo "$modename: libobj name \`$libobj' may not contain shell special characters."
80253e90a53Smrg    objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
80353e90a53Smrg    xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
80453e90a53Smrg    if test "X$xdir" = "X$obj"; then
80553e90a53Smrg      xdir=
80653e90a53Smrg    else
80753e90a53Smrg      xdir=$xdir/
80853e90a53Smrg    fi
80953e90a53Smrg    lobj=${xdir}$objdir/$objname
81053e90a53Smrg
81153e90a53Smrg    if test -z "$base_compile"; then
81253e90a53Smrg      $echo "$modename: you must specify a compilation command" 1>&2
81353e90a53Smrg      $echo "$help" 1>&2
81453e90a53Smrg      exit $EXIT_FAILURE
81553e90a53Smrg    fi
81653e90a53Smrg
81753e90a53Smrg    # Delete any leftover library objects.
81853e90a53Smrg    if test "$build_old_libs" = yes; then
81953e90a53Smrg      removelist="$obj $lobj $libobj ${libobj}T"
82053e90a53Smrg    else
82153e90a53Smrg      removelist="$lobj $libobj ${libobj}T"
82253e90a53Smrg    fi
82353e90a53Smrg
82453e90a53Smrg    $run $rm $removelist
82553e90a53Smrg    trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
82653e90a53Smrg
82753e90a53Smrg    # On Cygwin there's no "real" PIC flag so we must build both object types
82853e90a53Smrg    case $host_os in
82953e90a53Smrg    cygwin* | mingw* | pw32* | os2*)
83053e90a53Smrg      pic_mode=default
83153e90a53Smrg      ;;
83253e90a53Smrg    esac
83353e90a53Smrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
83453e90a53Smrg      # non-PIC code in shared libraries is not supported
83553e90a53Smrg      pic_mode=default
83653e90a53Smrg    fi
83753e90a53Smrg
83853e90a53Smrg    # Calculate the filename of the output object if compiler does
83953e90a53Smrg    # not support -o with -c
84053e90a53Smrg    if test "$compiler_c_o" = no; then
84153e90a53Smrg      output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
84253e90a53Smrg      lockfile="$output_obj.lock"
84353e90a53Smrg      removelist="$removelist $output_obj $lockfile"
84453e90a53Smrg      trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
84553e90a53Smrg    else
84653e90a53Smrg      output_obj=
84753e90a53Smrg      need_locks=no
84853e90a53Smrg      lockfile=
84953e90a53Smrg    fi
85053e90a53Smrg
85153e90a53Smrg    # Lock this critical section if it is needed
85253e90a53Smrg    # We use this script file to make the link, it avoids creating a new file
85353e90a53Smrg    if test "$need_locks" = yes; then
85453e90a53Smrg      until $run ln "$progpath" "$lockfile" 2>/dev/null; do
85553e90a53Smrg	$show "Waiting for $lockfile to be removed"
85653e90a53Smrg	sleep 2
85753e90a53Smrg      done
85853e90a53Smrg    elif test "$need_locks" = warn; then
85953e90a53Smrg      if test -f "$lockfile"; then
86053e90a53Smrg	$echo "\
86153e90a53Smrg*** ERROR, $lockfile exists and contains:
86253e90a53Smrg`cat $lockfile 2>/dev/null`
86353e90a53Smrg
86453e90a53SmrgThis indicates that another process is trying to use the same
86553e90a53Smrgtemporary object file, and libtool could not work around it because
86653e90a53Smrgyour compiler does not support \`-c' and \`-o' together.  If you
86753e90a53Smrgrepeat this compilation, it may succeed, by chance, but you had better
86853e90a53Smrgavoid parallel builds (make -j) in this platform, or get a better
86953e90a53Smrgcompiler."
87053e90a53Smrg
87153e90a53Smrg	$run $rm $removelist
87253e90a53Smrg	exit $EXIT_FAILURE
87353e90a53Smrg      fi
87453e90a53Smrg      $echo "$srcfile" > "$lockfile"
87553e90a53Smrg    fi
87653e90a53Smrg
87753e90a53Smrg    if test -n "$fix_srcfile_path"; then
87853e90a53Smrg      eval srcfile=\"$fix_srcfile_path\"
87953e90a53Smrg    fi
88053e90a53Smrg    qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"`
88153e90a53Smrg    case $qsrcfile in
88253e90a53Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
88353e90a53Smrg      qsrcfile="\"$qsrcfile\"" ;;
88453e90a53Smrg    esac
88553e90a53Smrg
88653e90a53Smrg    $run $rm "$libobj" "${libobj}T"
88753e90a53Smrg
88853e90a53Smrg    # Create a libtool object file (analogous to a ".la" file),
88953e90a53Smrg    # but don't create it if we're doing a dry run.
89053e90a53Smrg    test -z "$run" && cat > ${libobj}T <<EOF
89153e90a53Smrg# $libobj - a libtool object file
89253e90a53Smrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
89353e90a53Smrg#
89453e90a53Smrg# Please DO NOT delete this file!
89553e90a53Smrg# It is necessary for linking the library.
89653e90a53Smrg
89753e90a53Smrg# Name of the PIC object.
89853e90a53SmrgEOF
89953e90a53Smrg
90053e90a53Smrg    # Only build a PIC object if we are building libtool libraries.
90153e90a53Smrg    if test "$build_libtool_libs" = yes; then
90253e90a53Smrg      # Without this assignment, base_compile gets emptied.
90353e90a53Smrg      fbsd_hideous_sh_bug=$base_compile
90453e90a53Smrg
90553e90a53Smrg      if test "$pic_mode" != no; then
90653e90a53Smrg	command="$base_compile $qsrcfile $pic_flag"
90753e90a53Smrg      else
90853e90a53Smrg	# Don't build PIC code
90953e90a53Smrg	command="$base_compile $qsrcfile"
91053e90a53Smrg      fi
91153e90a53Smrg
91253e90a53Smrg      if test ! -d "${xdir}$objdir"; then
91353e90a53Smrg	$show "$mkdir ${xdir}$objdir"
91453e90a53Smrg	$run $mkdir ${xdir}$objdir
91553e90a53Smrg	exit_status=$?
91653e90a53Smrg	if test "$exit_status" -ne 0 && test ! -d "${xdir}$objdir"; then
91753e90a53Smrg	  exit $exit_status
91853e90a53Smrg	fi
91953e90a53Smrg      fi
92053e90a53Smrg
92153e90a53Smrg      if test -z "$output_obj"; then
92253e90a53Smrg	# Place PIC objects in $objdir
92353e90a53Smrg	command="$command -o $lobj"
92453e90a53Smrg      fi
92553e90a53Smrg
92653e90a53Smrg      $run $rm "$lobj" "$output_obj"
92753e90a53Smrg
92853e90a53Smrg      $show "$command"
92953e90a53Smrg      if $run eval "$command"; then :
93053e90a53Smrg      else
93153e90a53Smrg	test -n "$output_obj" && $run $rm $removelist
93253e90a53Smrg	exit $EXIT_FAILURE
93353e90a53Smrg      fi
93453e90a53Smrg
93553e90a53Smrg      if test "$need_locks" = warn &&
93653e90a53Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
93753e90a53Smrg	$echo "\
93853e90a53Smrg*** ERROR, $lockfile contains:
93953e90a53Smrg`cat $lockfile 2>/dev/null`
94053e90a53Smrg
94153e90a53Smrgbut it should contain:
94253e90a53Smrg$srcfile
94353e90a53Smrg
94453e90a53SmrgThis indicates that another process is trying to use the same
94553e90a53Smrgtemporary object file, and libtool could not work around it because
94653e90a53Smrgyour compiler does not support \`-c' and \`-o' together.  If you
94753e90a53Smrgrepeat this compilation, it may succeed, by chance, but you had better
94853e90a53Smrgavoid parallel builds (make -j) in this platform, or get a better
94953e90a53Smrgcompiler."
95053e90a53Smrg
95153e90a53Smrg	$run $rm $removelist
95253e90a53Smrg	exit $EXIT_FAILURE
95353e90a53Smrg      fi
95453e90a53Smrg
95553e90a53Smrg      # Just move the object if needed, then go on to compile the next one
95653e90a53Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
95753e90a53Smrg	$show "$mv $output_obj $lobj"
95853e90a53Smrg	if $run $mv $output_obj $lobj; then :
95953e90a53Smrg	else
96053e90a53Smrg	  error=$?
96153e90a53Smrg	  $run $rm $removelist
96253e90a53Smrg	  exit $error
96353e90a53Smrg	fi
96453e90a53Smrg      fi
96553e90a53Smrg
96653e90a53Smrg      # Append the name of the PIC object to the libtool object file.
96753e90a53Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
96853e90a53Smrgpic_object='$objdir/$objname'
96953e90a53Smrg
97053e90a53SmrgEOF
97153e90a53Smrg
97253e90a53Smrg      # Allow error messages only from the first compilation.
97353e90a53Smrg      if test "$suppress_opt" = yes; then
97453e90a53Smrg        suppress_output=' >/dev/null 2>&1'
97553e90a53Smrg      fi
97653e90a53Smrg    else
97753e90a53Smrg      # No PIC object so indicate it doesn't exist in the libtool
97853e90a53Smrg      # object file.
97953e90a53Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
98053e90a53Smrgpic_object=none
98153e90a53Smrg
98253e90a53SmrgEOF
98353e90a53Smrg    fi
98453e90a53Smrg
98553e90a53Smrg    # Only build a position-dependent object if we build old libraries.
98653e90a53Smrg    if test "$build_old_libs" = yes; then
98753e90a53Smrg      if test "$pic_mode" != yes; then
98853e90a53Smrg	# Don't build PIC code
98953e90a53Smrg	command="$base_compile $qsrcfile"
99053e90a53Smrg      else
99153e90a53Smrg	command="$base_compile $qsrcfile $pic_flag"
99253e90a53Smrg      fi
99353e90a53Smrg      if test "$compiler_c_o" = yes; then
99453e90a53Smrg	command="$command -o $obj"
99553e90a53Smrg      fi
99653e90a53Smrg
99753e90a53Smrg      # Suppress compiler output if we already did a PIC compilation.
99853e90a53Smrg      command="$command$suppress_output"
99953e90a53Smrg      $run $rm "$obj" "$output_obj"
100053e90a53Smrg      $show "$command"
100153e90a53Smrg      if $run eval "$command"; then :
100253e90a53Smrg      else
100353e90a53Smrg	$run $rm $removelist
100453e90a53Smrg	exit $EXIT_FAILURE
100553e90a53Smrg      fi
100653e90a53Smrg
100753e90a53Smrg      if test "$need_locks" = warn &&
100853e90a53Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
100953e90a53Smrg	$echo "\
101053e90a53Smrg*** ERROR, $lockfile contains:
101153e90a53Smrg`cat $lockfile 2>/dev/null`
101253e90a53Smrg
101353e90a53Smrgbut it should contain:
101453e90a53Smrg$srcfile
101553e90a53Smrg
101653e90a53SmrgThis indicates that another process is trying to use the same
101753e90a53Smrgtemporary object file, and libtool could not work around it because
101853e90a53Smrgyour compiler does not support \`-c' and \`-o' together.  If you
101953e90a53Smrgrepeat this compilation, it may succeed, by chance, but you had better
102053e90a53Smrgavoid parallel builds (make -j) in this platform, or get a better
102153e90a53Smrgcompiler."
102253e90a53Smrg
102353e90a53Smrg	$run $rm $removelist
102453e90a53Smrg	exit $EXIT_FAILURE
102553e90a53Smrg      fi
102653e90a53Smrg
102753e90a53Smrg      # Just move the object if needed
102853e90a53Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
102953e90a53Smrg	$show "$mv $output_obj $obj"
103053e90a53Smrg	if $run $mv $output_obj $obj; then :
103153e90a53Smrg	else
103253e90a53Smrg	  error=$?
103353e90a53Smrg	  $run $rm $removelist
103453e90a53Smrg	  exit $error
103553e90a53Smrg	fi
103653e90a53Smrg      fi
103753e90a53Smrg
103853e90a53Smrg      # Append the name of the non-PIC object the libtool object file.
103953e90a53Smrg      # Only append if the libtool object file exists.
104053e90a53Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
104153e90a53Smrg# Name of the non-PIC object.
104253e90a53Smrgnon_pic_object='$objname'
104353e90a53Smrg
104453e90a53SmrgEOF
104553e90a53Smrg    else
104653e90a53Smrg      # Append the name of the non-PIC object the libtool object file.
104753e90a53Smrg      # Only append if the libtool object file exists.
104853e90a53Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
104953e90a53Smrg# Name of the non-PIC object.
105053e90a53Smrgnon_pic_object=none
105153e90a53Smrg
105253e90a53SmrgEOF
105353e90a53Smrg    fi
105453e90a53Smrg
105553e90a53Smrg    $run $mv "${libobj}T" "${libobj}"
105653e90a53Smrg
105753e90a53Smrg    # Unlock the critical section if it was locked
105853e90a53Smrg    if test "$need_locks" != no; then
105953e90a53Smrg      $run $rm "$lockfile"
106053e90a53Smrg    fi
106153e90a53Smrg
106253e90a53Smrg    exit $EXIT_SUCCESS
106353e90a53Smrg    ;;
106453e90a53Smrg
106553e90a53Smrg  # libtool link mode
106653e90a53Smrg  link | relink)
106753e90a53Smrg    modename="$modename: link"
106853e90a53Smrg    case $host in
106953e90a53Smrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
107053e90a53Smrg      # It is impossible to link a dll without this setting, and
107153e90a53Smrg      # we shouldn't force the makefile maintainer to figure out
107253e90a53Smrg      # which system we are compiling for in order to pass an extra
107353e90a53Smrg      # flag for every libtool invocation.
107453e90a53Smrg      # allow_undefined=no
107553e90a53Smrg
107653e90a53Smrg      # FIXME: Unfortunately, there are problems with the above when trying
107753e90a53Smrg      # to make a dll which has undefined symbols, in which case not
107853e90a53Smrg      # even a static library is built.  For now, we need to specify
107953e90a53Smrg      # -no-undefined on the libtool link line when we can be certain
108053e90a53Smrg      # that all symbols are satisfied, otherwise we get a static library.
108153e90a53Smrg      allow_undefined=yes
108253e90a53Smrg      ;;
108353e90a53Smrg    *)
108453e90a53Smrg      allow_undefined=yes
108553e90a53Smrg      ;;
108653e90a53Smrg    esac
108753e90a53Smrg    libtool_args="$nonopt"
108853e90a53Smrg    base_compile="$nonopt $@"
108953e90a53Smrg    compile_command="$nonopt"
109053e90a53Smrg    finalize_command="$nonopt"
109153e90a53Smrg
109253e90a53Smrg    compile_rpath=
109353e90a53Smrg    finalize_rpath=
109453e90a53Smrg    compile_shlibpath=
109553e90a53Smrg    finalize_shlibpath=
109653e90a53Smrg    convenience=
109753e90a53Smrg    old_convenience=
109853e90a53Smrg    deplibs=
109953e90a53Smrg    old_deplibs=
110053e90a53Smrg    compiler_flags=
110153e90a53Smrg    linker_flags=
110253e90a53Smrg    dllsearchpath=
110353e90a53Smrg    lib_search_path=`pwd`
110453e90a53Smrg    inst_prefix_dir=
110553e90a53Smrg
110653e90a53Smrg    avoid_version=no
110753e90a53Smrg    dlfiles=
110853e90a53Smrg    dlprefiles=
110953e90a53Smrg    dlself=no
111053e90a53Smrg    export_dynamic=no
111153e90a53Smrg    export_symbols=
111253e90a53Smrg    export_symbols_regex=
111353e90a53Smrg    generated=
111453e90a53Smrg    libobjs=
111553e90a53Smrg    ltlibs=
111653e90a53Smrg    module=no
111753e90a53Smrg    no_install=no
111853e90a53Smrg    objs=
111953e90a53Smrg    non_pic_objects=
112053e90a53Smrg    notinst_path= # paths that contain not-installed libtool libraries
112153e90a53Smrg    precious_files_regex=
112253e90a53Smrg    prefer_static_libs=no
112353e90a53Smrg    preload=no
112453e90a53Smrg    prev=
112553e90a53Smrg    prevarg=
112653e90a53Smrg    release=
112753e90a53Smrg    rpath=
112853e90a53Smrg    xrpath=
112953e90a53Smrg    perm_rpath=
113053e90a53Smrg    temp_rpath=
113153e90a53Smrg    thread_safe=no
113253e90a53Smrg    vinfo=
113353e90a53Smrg    vinfo_number=no
113453e90a53Smrg
113553e90a53Smrg    func_infer_tag $base_compile
113653e90a53Smrg
113753e90a53Smrg    # We need to know -static, to get the right output filenames.
113853e90a53Smrg    for arg
113953e90a53Smrg    do
114053e90a53Smrg      case $arg in
114153e90a53Smrg      -all-static | -static)
114253e90a53Smrg	if test "X$arg" = "X-all-static"; then
114353e90a53Smrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
114453e90a53Smrg	    $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
114553e90a53Smrg	  fi
114653e90a53Smrg	  if test -n "$link_static_flag"; then
114753e90a53Smrg	    dlopen_self=$dlopen_self_static
114853e90a53Smrg	  fi
114953e90a53Smrg	  prefer_static_libs=yes
115053e90a53Smrg	else
115153e90a53Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
115253e90a53Smrg	    dlopen_self=$dlopen_self_static
115353e90a53Smrg	  fi
115453e90a53Smrg	  prefer_static_libs=built
115553e90a53Smrg	fi
115653e90a53Smrg	build_libtool_libs=no
115753e90a53Smrg	build_old_libs=yes
115853e90a53Smrg	break
115953e90a53Smrg	;;
116053e90a53Smrg      esac
116153e90a53Smrg    done
116253e90a53Smrg
116353e90a53Smrg    # See if our shared archives depend on static archives.
116453e90a53Smrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
116553e90a53Smrg
116653e90a53Smrg    # Go through the arguments, transforming them on the way.
116753e90a53Smrg    while test "$#" -gt 0; do
116853e90a53Smrg      arg="$1"
116953e90a53Smrg      shift
117053e90a53Smrg      case $arg in
117153e90a53Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
117253e90a53Smrg	qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test
117353e90a53Smrg	;;
117453e90a53Smrg      *) qarg=$arg ;;
117553e90a53Smrg      esac
117653e90a53Smrg      libtool_args="$libtool_args $qarg"
117753e90a53Smrg
117853e90a53Smrg      # If the previous option needs an argument, assign it.
117953e90a53Smrg      if test -n "$prev"; then
118053e90a53Smrg	case $prev in
118153e90a53Smrg	output)
118253e90a53Smrg	  compile_command="$compile_command @OUTPUT@"
118353e90a53Smrg	  finalize_command="$finalize_command @OUTPUT@"
118453e90a53Smrg	  ;;
118553e90a53Smrg	esac
118653e90a53Smrg
118753e90a53Smrg	case $prev in
118853e90a53Smrg	dlfiles|dlprefiles)
118953e90a53Smrg	  if test "$preload" = no; then
119053e90a53Smrg	    # Add the symbol object into the linking commands.
119153e90a53Smrg	    compile_command="$compile_command @SYMFILE@"
119253e90a53Smrg	    finalize_command="$finalize_command @SYMFILE@"
119353e90a53Smrg	    preload=yes
119453e90a53Smrg	  fi
119553e90a53Smrg	  case $arg in
119653e90a53Smrg	  *.la | *.lo) ;;  # We handle these cases below.
119753e90a53Smrg	  force)
119853e90a53Smrg	    if test "$dlself" = no; then
119953e90a53Smrg	      dlself=needless
120053e90a53Smrg	      export_dynamic=yes
120153e90a53Smrg	    fi
120253e90a53Smrg	    prev=
120353e90a53Smrg	    continue
120453e90a53Smrg	    ;;
120553e90a53Smrg	  self)
120653e90a53Smrg	    if test "$prev" = dlprefiles; then
120753e90a53Smrg	      dlself=yes
120853e90a53Smrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
120953e90a53Smrg	      dlself=yes
121053e90a53Smrg	    else
121153e90a53Smrg	      dlself=needless
121253e90a53Smrg	      export_dynamic=yes
121353e90a53Smrg	    fi
121453e90a53Smrg	    prev=
121553e90a53Smrg	    continue
121653e90a53Smrg	    ;;
121753e90a53Smrg	  *)
121853e90a53Smrg	    if test "$prev" = dlfiles; then
121953e90a53Smrg	      dlfiles="$dlfiles $arg"
122053e90a53Smrg	    else
122153e90a53Smrg	      dlprefiles="$dlprefiles $arg"
122253e90a53Smrg	    fi
122353e90a53Smrg	    prev=
122453e90a53Smrg	    continue
122553e90a53Smrg	    ;;
122653e90a53Smrg	  esac
122753e90a53Smrg	  ;;
122853e90a53Smrg	expsyms)
122953e90a53Smrg	  export_symbols="$arg"
123053e90a53Smrg	  if test ! -f "$arg"; then
123153e90a53Smrg	    $echo "$modename: symbol file \`$arg' does not exist"
123253e90a53Smrg	    exit $EXIT_FAILURE
123353e90a53Smrg	  fi
123453e90a53Smrg	  prev=
123553e90a53Smrg	  continue
123653e90a53Smrg	  ;;
123753e90a53Smrg	expsyms_regex)
123853e90a53Smrg	  export_symbols_regex="$arg"
123953e90a53Smrg	  prev=
124053e90a53Smrg	  continue
124153e90a53Smrg	  ;;
124253e90a53Smrg	inst_prefix)
124353e90a53Smrg	  inst_prefix_dir="$arg"
124453e90a53Smrg	  prev=
124553e90a53Smrg	  continue
124653e90a53Smrg	  ;;
124753e90a53Smrg	precious_regex)
124853e90a53Smrg	  precious_files_regex="$arg"
124953e90a53Smrg	  prev=
125053e90a53Smrg	  continue
125153e90a53Smrg	  ;;
125253e90a53Smrg	release)
125353e90a53Smrg	  release="-$arg"
125453e90a53Smrg	  prev=
125553e90a53Smrg	  continue
125653e90a53Smrg	  ;;
125753e90a53Smrg	objectlist)
125853e90a53Smrg	  if test -f "$arg"; then
125953e90a53Smrg	    save_arg=$arg
126053e90a53Smrg	    moreargs=
126153e90a53Smrg	    for fil in `cat $save_arg`
126253e90a53Smrg	    do
126353e90a53Smrg#	      moreargs="$moreargs $fil"
126453e90a53Smrg	      arg=$fil
126553e90a53Smrg	      # A libtool-controlled object.
126653e90a53Smrg
126753e90a53Smrg	      # Check to see that this really is a libtool object.
126853e90a53Smrg	      if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
126953e90a53Smrg		pic_object=
127053e90a53Smrg		non_pic_object=
127153e90a53Smrg
127253e90a53Smrg		# Read the .lo file
127353e90a53Smrg		# If there is no directory component, then add one.
127453e90a53Smrg		case $arg in
127553e90a53Smrg		*/* | *\\*) . $arg ;;
127653e90a53Smrg		*) . ./$arg ;;
127753e90a53Smrg		esac
127853e90a53Smrg
127953e90a53Smrg		if test -z "$pic_object" || \
128053e90a53Smrg		   test -z "$non_pic_object" ||
128153e90a53Smrg		   test "$pic_object" = none && \
128253e90a53Smrg		   test "$non_pic_object" = none; then
128353e90a53Smrg		  $echo "$modename: cannot find name of object for \`$arg'" 1>&2
128453e90a53Smrg		  exit $EXIT_FAILURE
128553e90a53Smrg		fi
128653e90a53Smrg
128753e90a53Smrg		# Extract subdirectory from the argument.
128853e90a53Smrg		xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
128953e90a53Smrg		if test "X$xdir" = "X$arg"; then
129053e90a53Smrg		  xdir=
129153e90a53Smrg		else
129253e90a53Smrg		  xdir="$xdir/"
129353e90a53Smrg		fi
129453e90a53Smrg
129553e90a53Smrg		if test "$pic_object" != none; then
129653e90a53Smrg		  # Prepend the subdirectory the object is found in.
129753e90a53Smrg		  pic_object="$xdir$pic_object"
129853e90a53Smrg
129953e90a53Smrg		  if test "$prev" = dlfiles; then
130053e90a53Smrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
130153e90a53Smrg		      dlfiles="$dlfiles $pic_object"
130253e90a53Smrg		      prev=
130353e90a53Smrg		      continue
130453e90a53Smrg		    else
130553e90a53Smrg		      # If libtool objects are unsupported, then we need to preload.
130653e90a53Smrg		      prev=dlprefiles
130753e90a53Smrg		    fi
130853e90a53Smrg		  fi
130953e90a53Smrg
131053e90a53Smrg		  # CHECK ME:  I think I busted this.  -Ossama
131153e90a53Smrg		  if test "$prev" = dlprefiles; then
131253e90a53Smrg		    # Preload the old-style object.
131353e90a53Smrg		    dlprefiles="$dlprefiles $pic_object"
131453e90a53Smrg		    prev=
131553e90a53Smrg		  fi
131653e90a53Smrg
131753e90a53Smrg		  # A PIC object.
131853e90a53Smrg		  libobjs="$libobjs $pic_object"
131953e90a53Smrg		  arg="$pic_object"
132053e90a53Smrg		fi
132153e90a53Smrg
132253e90a53Smrg		# Non-PIC object.
132353e90a53Smrg		if test "$non_pic_object" != none; then
132453e90a53Smrg		  # Prepend the subdirectory the object is found in.
132553e90a53Smrg		  non_pic_object="$xdir$non_pic_object"
132653e90a53Smrg
132753e90a53Smrg		  # A standard non-PIC object
132853e90a53Smrg		  non_pic_objects="$non_pic_objects $non_pic_object"
132953e90a53Smrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
133053e90a53Smrg		    arg="$non_pic_object"
133153e90a53Smrg		  fi
133253e90a53Smrg		else
133353e90a53Smrg		  # If the PIC object exists, use it instead.
133453e90a53Smrg		  # $xdir was prepended to $pic_object above.
133553e90a53Smrg		  non_pic_object="$pic_object"
133653e90a53Smrg		  non_pic_objects="$non_pic_objects $non_pic_object"
133753e90a53Smrg		fi
133853e90a53Smrg	      else
133953e90a53Smrg		# Only an error if not doing a dry-run.
134053e90a53Smrg		if test -z "$run"; then
134153e90a53Smrg		  $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
134253e90a53Smrg		  exit $EXIT_FAILURE
134353e90a53Smrg		else
134453e90a53Smrg		  # Dry-run case.
134553e90a53Smrg
134653e90a53Smrg		  # Extract subdirectory from the argument.
134753e90a53Smrg		  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
134853e90a53Smrg		  if test "X$xdir" = "X$arg"; then
134953e90a53Smrg		    xdir=
135053e90a53Smrg		  else
135153e90a53Smrg		    xdir="$xdir/"
135253e90a53Smrg		  fi
135353e90a53Smrg
135453e90a53Smrg		  pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
135553e90a53Smrg		  non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
135653e90a53Smrg		  libobjs="$libobjs $pic_object"
135753e90a53Smrg		  non_pic_objects="$non_pic_objects $non_pic_object"
135853e90a53Smrg		fi
135953e90a53Smrg	      fi
136053e90a53Smrg	    done
136153e90a53Smrg	  else
136253e90a53Smrg	    $echo "$modename: link input file \`$save_arg' does not exist"
136353e90a53Smrg	    exit $EXIT_FAILURE
136453e90a53Smrg	  fi
136553e90a53Smrg	  arg=$save_arg
136653e90a53Smrg	  prev=
136753e90a53Smrg	  continue
136853e90a53Smrg	  ;;
136953e90a53Smrg	rpath | xrpath)
137053e90a53Smrg	  # We need an absolute path.
137153e90a53Smrg	  case $arg in
137253e90a53Smrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
137353e90a53Smrg	  *)
137453e90a53Smrg	    $echo "$modename: only absolute run-paths are allowed" 1>&2
137553e90a53Smrg	    exit $EXIT_FAILURE
137653e90a53Smrg	    ;;
137753e90a53Smrg	  esac
137853e90a53Smrg	  if test "$prev" = rpath; then
137953e90a53Smrg	    case "$rpath " in
138053e90a53Smrg	    *" $arg "*) ;;
138153e90a53Smrg	    *) rpath="$rpath $arg" ;;
138253e90a53Smrg	    esac
138353e90a53Smrg	  else
138453e90a53Smrg	    case "$xrpath " in
138553e90a53Smrg	    *" $arg "*) ;;
138653e90a53Smrg	    *) xrpath="$xrpath $arg" ;;
138753e90a53Smrg	    esac
138853e90a53Smrg	  fi
138953e90a53Smrg	  prev=
139053e90a53Smrg	  continue
139153e90a53Smrg	  ;;
139253e90a53Smrg	xcompiler)
139353e90a53Smrg	  compiler_flags="$compiler_flags $qarg"
139453e90a53Smrg	  prev=
139553e90a53Smrg	  compile_command="$compile_command $qarg"
139653e90a53Smrg	  finalize_command="$finalize_command $qarg"
139753e90a53Smrg	  continue
139853e90a53Smrg	  ;;
139953e90a53Smrg	xlinker)
140053e90a53Smrg	  linker_flags="$linker_flags $qarg"
140153e90a53Smrg	  compiler_flags="$compiler_flags $wl$qarg"
140253e90a53Smrg	  prev=
140353e90a53Smrg	  compile_command="$compile_command $wl$qarg"
140453e90a53Smrg	  finalize_command="$finalize_command $wl$qarg"
140553e90a53Smrg	  continue
140653e90a53Smrg	  ;;
140753e90a53Smrg	xcclinker)
140853e90a53Smrg	  linker_flags="$linker_flags $qarg"
140953e90a53Smrg	  compiler_flags="$compiler_flags $qarg"
141053e90a53Smrg	  prev=
141153e90a53Smrg	  compile_command="$compile_command $qarg"
141253e90a53Smrg	  finalize_command="$finalize_command $qarg"
141353e90a53Smrg	  continue
141453e90a53Smrg	  ;;
141553e90a53Smrg	shrext)
141653e90a53Smrg  	  shrext_cmds="$arg"
141753e90a53Smrg	  prev=
141853e90a53Smrg	  continue
141953e90a53Smrg	  ;;
142053e90a53Smrg	darwin_framework|darwin_framework_skip)
142153e90a53Smrg	  test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg"
142253e90a53Smrg	  compile_command="$compile_command $arg"
142353e90a53Smrg	  finalize_command="$finalize_command $arg"
142453e90a53Smrg	  prev=
142553e90a53Smrg	  continue
142653e90a53Smrg	  ;;
142753e90a53Smrg	*)
142853e90a53Smrg	  eval "$prev=\"\$arg\""
142953e90a53Smrg	  prev=
143053e90a53Smrg	  continue
143153e90a53Smrg	  ;;
143253e90a53Smrg	esac
143353e90a53Smrg      fi # test -n "$prev"
143453e90a53Smrg
143553e90a53Smrg      prevarg="$arg"
143653e90a53Smrg
143753e90a53Smrg      case $arg in
143853e90a53Smrg      -all-static)
143953e90a53Smrg	if test -n "$link_static_flag"; then
144053e90a53Smrg	  compile_command="$compile_command $link_static_flag"
144153e90a53Smrg	  finalize_command="$finalize_command $link_static_flag"
144253e90a53Smrg	fi
144353e90a53Smrg	continue
144453e90a53Smrg	;;
144553e90a53Smrg
144653e90a53Smrg      -allow-undefined)
144753e90a53Smrg	# FIXME: remove this flag sometime in the future.
144853e90a53Smrg	$echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
144953e90a53Smrg	continue
145053e90a53Smrg	;;
145153e90a53Smrg
145253e90a53Smrg      -avoid-version)
145353e90a53Smrg	avoid_version=yes
145453e90a53Smrg	continue
145553e90a53Smrg	;;
145653e90a53Smrg
145753e90a53Smrg      -dlopen)
145853e90a53Smrg	prev=dlfiles
145953e90a53Smrg	continue
146053e90a53Smrg	;;
146153e90a53Smrg
146253e90a53Smrg      -dlpreopen)
146353e90a53Smrg	prev=dlprefiles
146453e90a53Smrg	continue
146553e90a53Smrg	;;
146653e90a53Smrg
146753e90a53Smrg      -export-dynamic)
146853e90a53Smrg	export_dynamic=yes
146953e90a53Smrg	continue
147053e90a53Smrg	;;
147153e90a53Smrg
147253e90a53Smrg      -export-symbols | -export-symbols-regex)
147353e90a53Smrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
147453e90a53Smrg	  $echo "$modename: more than one -exported-symbols argument is not allowed"
147553e90a53Smrg	  exit $EXIT_FAILURE
147653e90a53Smrg	fi
147753e90a53Smrg	if test "X$arg" = "X-export-symbols"; then
147853e90a53Smrg	  prev=expsyms
147953e90a53Smrg	else
148053e90a53Smrg	  prev=expsyms_regex
148153e90a53Smrg	fi
148253e90a53Smrg	continue
148353e90a53Smrg	;;
148453e90a53Smrg
148553e90a53Smrg      -framework|-arch|-isysroot)
148653e90a53Smrg	case " $CC " in
148753e90a53Smrg	  *" ${arg} ${1} "* | *" ${arg}	${1} "*) 
148853e90a53Smrg		prev=darwin_framework_skip ;;
148953e90a53Smrg	  *) compiler_flags="$compiler_flags $arg"
149053e90a53Smrg	     prev=darwin_framework ;;
149153e90a53Smrg	esac
149253e90a53Smrg	compile_command="$compile_command $arg"
149353e90a53Smrg	finalize_command="$finalize_command $arg"
149453e90a53Smrg	continue
149553e90a53Smrg	;;
149653e90a53Smrg
149753e90a53Smrg      -inst-prefix-dir)
149853e90a53Smrg	prev=inst_prefix
149953e90a53Smrg	continue
150053e90a53Smrg	;;
150153e90a53Smrg
150253e90a53Smrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
150353e90a53Smrg      # so, if we see these flags be careful not to treat them like -L
150453e90a53Smrg      -L[A-Z][A-Z]*:*)
150553e90a53Smrg	case $with_gcc/$host in
150653e90a53Smrg	no/*-*-irix* | /*-*-irix*)
150753e90a53Smrg	  compile_command="$compile_command $arg"
150853e90a53Smrg	  finalize_command="$finalize_command $arg"
150953e90a53Smrg	  ;;
151053e90a53Smrg	esac
151153e90a53Smrg	continue
151253e90a53Smrg	;;
151353e90a53Smrg
151453e90a53Smrg      -L*)
151553e90a53Smrg	dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
151653e90a53Smrg	# We need an absolute path.
151753e90a53Smrg	case $dir in
151853e90a53Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
151953e90a53Smrg	*)
152053e90a53Smrg	  absdir=`cd "$dir" && pwd`
152153e90a53Smrg	  if test -z "$absdir"; then
152253e90a53Smrg	    $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
152353e90a53Smrg	    absdir="$dir"
152453e90a53Smrg	    notinst_path="$notinst_path $dir"
152553e90a53Smrg	  fi
152653e90a53Smrg	  dir="$absdir"
152753e90a53Smrg	  ;;
152853e90a53Smrg	esac
152953e90a53Smrg	case "$deplibs " in
153053e90a53Smrg	*" -L$dir "*) ;;
153153e90a53Smrg	*)
153253e90a53Smrg	  deplibs="$deplibs -L$dir"
153353e90a53Smrg	  lib_search_path="$lib_search_path $dir"
153453e90a53Smrg	  ;;
153553e90a53Smrg	esac
153653e90a53Smrg	case $host in
153753e90a53Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
153853e90a53Smrg	  testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'`
153953e90a53Smrg	  case :$dllsearchpath: in
154053e90a53Smrg	  *":$dir:"*) ;;
154153e90a53Smrg	  *) dllsearchpath="$dllsearchpath:$dir";;
154253e90a53Smrg	  esac
154353e90a53Smrg	  case :$dllsearchpath: in
154453e90a53Smrg	  *":$testbindir:"*) ;;
154553e90a53Smrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
154653e90a53Smrg	  esac
154753e90a53Smrg	  ;;
154853e90a53Smrg	esac
154953e90a53Smrg	continue
155053e90a53Smrg	;;
155153e90a53Smrg
155253e90a53Smrg      -l*)
155353e90a53Smrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
155453e90a53Smrg	  case $host in
155553e90a53Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*)
155653e90a53Smrg	    # These systems don't actually have a C or math library (as such)
155753e90a53Smrg	    continue
155853e90a53Smrg	    ;;
155953e90a53Smrg	  *-*-os2*)
156053e90a53Smrg	    # These systems don't actually have a C library (as such)
156153e90a53Smrg	    test "X$arg" = "X-lc" && continue
156253e90a53Smrg	    ;;
156353e90a53Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
156453e90a53Smrg	    # Do not include libc due to us having libc/libc_r.
156553e90a53Smrg	    test "X$arg" = "X-lc" && continue
156653e90a53Smrg	    ;;
156753e90a53Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
156853e90a53Smrg	    # Rhapsody C and math libraries are in the System framework
156953e90a53Smrg	    deplibs="$deplibs -framework System"
157053e90a53Smrg	    continue
157153e90a53Smrg	    ;;
157253e90a53Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
157353e90a53Smrg	    # Causes problems with __ctype
157453e90a53Smrg	    test "X$arg" = "X-lc" && continue
157553e90a53Smrg	    ;;
157653e90a53Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
157753e90a53Smrg	    # Compiler inserts libc in the correct place for threads to work
157853e90a53Smrg	    test "X$arg" = "X-lc" && continue
157953e90a53Smrg	    ;;
158053e90a53Smrg	  esac
158153e90a53Smrg	elif test "X$arg" = "X-lc_r"; then
158253e90a53Smrg	 case $host in
158353e90a53Smrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
158453e90a53Smrg	   # Do not include libc_r directly, use -pthread flag.
158553e90a53Smrg	   continue
158653e90a53Smrg	   ;;
158753e90a53Smrg	 esac
158853e90a53Smrg	fi
158953e90a53Smrg	deplibs="$deplibs $arg"
159053e90a53Smrg	continue
159153e90a53Smrg	;;
159253e90a53Smrg
159353e90a53Smrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
159453e90a53Smrg      # classes, name mangling, and exception handling.
159553e90a53Smrg      -model)
159653e90a53Smrg	compile_command="$compile_command $arg"
159753e90a53Smrg	compiler_flags="$compiler_flags $arg"
159853e90a53Smrg	finalize_command="$finalize_command $arg"
159953e90a53Smrg	prev=xcompiler
160053e90a53Smrg	continue
160153e90a53Smrg	;;
160253e90a53Smrg
160353e90a53Smrg     -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
160453e90a53Smrg	compiler_flags="$compiler_flags $arg"
160553e90a53Smrg	compile_command="$compile_command $arg"
160653e90a53Smrg	finalize_command="$finalize_command $arg"
160753e90a53Smrg	continue
160853e90a53Smrg	;;
160953e90a53Smrg
161053e90a53Smrg      -module)
161153e90a53Smrg	module=yes
161253e90a53Smrg	continue
161353e90a53Smrg	;;
161453e90a53Smrg
161553e90a53Smrg      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
161653e90a53Smrg      # -r[0-9][0-9]* specifies the processor on the SGI compiler
161753e90a53Smrg      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
161853e90a53Smrg      # +DA*, +DD* enable 64-bit mode on the HP compiler
161953e90a53Smrg      # -q* pass through compiler args for the IBM compiler
162053e90a53Smrg      # -m* pass through architecture-specific compiler args for GCC
162153e90a53Smrg      # -m*, -t[45]*, -txscale* pass through architecture-specific
162253e90a53Smrg      # compiler args for GCC
162353e90a53Smrg      # -pg pass through profiling flag for GCC
162453e90a53Smrg      # @file GCC response files
162553e90a53Smrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*|-pg| \
162653e90a53Smrg      -t[45]*|-txscale*|@*)
162753e90a53Smrg
162853e90a53Smrg	# Unknown arguments in both finalize_command and compile_command need
162953e90a53Smrg	# to be aesthetically quoted because they are evaled later.
163053e90a53Smrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
163153e90a53Smrg	case $arg in
163253e90a53Smrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
163353e90a53Smrg	  arg="\"$arg\""
163453e90a53Smrg	  ;;
163553e90a53Smrg	esac
163653e90a53Smrg        compile_command="$compile_command $arg"
163753e90a53Smrg        finalize_command="$finalize_command $arg"
163853e90a53Smrg        compiler_flags="$compiler_flags $arg"
163953e90a53Smrg        continue
164053e90a53Smrg        ;;
164153e90a53Smrg
164253e90a53Smrg      -shrext)
164353e90a53Smrg	prev=shrext
164453e90a53Smrg	continue
164553e90a53Smrg	;;
164653e90a53Smrg
164753e90a53Smrg      -no-fast-install)
164853e90a53Smrg	fast_install=no
164953e90a53Smrg	continue
165053e90a53Smrg	;;
165153e90a53Smrg
165253e90a53Smrg      -no-install)
165353e90a53Smrg	case $host in
165453e90a53Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
165553e90a53Smrg	  # The PATH hackery in wrapper scripts is required on Windows
165653e90a53Smrg	  # in order for the loader to find any dlls it needs.
165753e90a53Smrg	  $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2
165853e90a53Smrg	  $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2
165953e90a53Smrg	  fast_install=no
166053e90a53Smrg	  ;;
166153e90a53Smrg	*) no_install=yes ;;
166253e90a53Smrg	esac
166353e90a53Smrg	continue
166453e90a53Smrg	;;
166553e90a53Smrg
166653e90a53Smrg      -no-undefined)
166753e90a53Smrg	allow_undefined=no
166853e90a53Smrg	continue
166953e90a53Smrg	;;
167053e90a53Smrg
167153e90a53Smrg      -objectlist)
167253e90a53Smrg	prev=objectlist
167353e90a53Smrg	continue
167453e90a53Smrg	;;
167553e90a53Smrg
167653e90a53Smrg      -o) prev=output ;;
167753e90a53Smrg
167853e90a53Smrg      -precious-files-regex)
167953e90a53Smrg	prev=precious_regex
168053e90a53Smrg	continue
168153e90a53Smrg	;;
168253e90a53Smrg
168353e90a53Smrg      -release)
168453e90a53Smrg	prev=release
168553e90a53Smrg	continue
168653e90a53Smrg	;;
168753e90a53Smrg
168853e90a53Smrg      -rpath)
168953e90a53Smrg	prev=rpath
169053e90a53Smrg	continue
169153e90a53Smrg	;;
169253e90a53Smrg
169353e90a53Smrg      -R)
169453e90a53Smrg	prev=xrpath
169553e90a53Smrg	continue
169653e90a53Smrg	;;
169753e90a53Smrg
169853e90a53Smrg      -R*)
169953e90a53Smrg	dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
170053e90a53Smrg	# We need an absolute path.
170153e90a53Smrg	case $dir in
170253e90a53Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
170353e90a53Smrg	*)
170453e90a53Smrg	  $echo "$modename: only absolute run-paths are allowed" 1>&2
170553e90a53Smrg	  exit $EXIT_FAILURE
170653e90a53Smrg	  ;;
170753e90a53Smrg	esac
170853e90a53Smrg	case "$xrpath " in
170953e90a53Smrg	*" $dir "*) ;;
171053e90a53Smrg	*) xrpath="$xrpath $dir" ;;
171153e90a53Smrg	esac
171253e90a53Smrg	continue
171353e90a53Smrg	;;
171453e90a53Smrg
171553e90a53Smrg      -static)
171653e90a53Smrg	# The effects of -static are defined in a previous loop.
171753e90a53Smrg	# We used to do the same as -all-static on platforms that
171853e90a53Smrg	# didn't have a PIC flag, but the assumption that the effects
171953e90a53Smrg	# would be equivalent was wrong.  It would break on at least
172053e90a53Smrg	# Digital Unix and AIX.
172153e90a53Smrg	continue
172253e90a53Smrg	;;
172353e90a53Smrg
172453e90a53Smrg      -thread-safe)
172553e90a53Smrg	thread_safe=yes
172653e90a53Smrg	continue
172753e90a53Smrg	;;
172853e90a53Smrg
172953e90a53Smrg      -version-info)
173053e90a53Smrg	prev=vinfo
173153e90a53Smrg	continue
173253e90a53Smrg	;;
173353e90a53Smrg      -version-number)
173453e90a53Smrg	prev=vinfo
173553e90a53Smrg	vinfo_number=yes
173653e90a53Smrg	continue
173753e90a53Smrg	;;
173853e90a53Smrg
173953e90a53Smrg      -Wc,*)
174053e90a53Smrg	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'`
174153e90a53Smrg	arg=
174253e90a53Smrg	save_ifs="$IFS"; IFS=','
174353e90a53Smrg	for flag in $args; do
174453e90a53Smrg	  IFS="$save_ifs"
174553e90a53Smrg	  case $flag in
174653e90a53Smrg	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
174753e90a53Smrg	    flag="\"$flag\""
174853e90a53Smrg	    ;;
174953e90a53Smrg	  esac
175053e90a53Smrg	  arg="$arg $wl$flag"
175153e90a53Smrg	  compiler_flags="$compiler_flags $flag"
175253e90a53Smrg	done
175353e90a53Smrg	IFS="$save_ifs"
175453e90a53Smrg	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
175553e90a53Smrg	;;
175653e90a53Smrg
175753e90a53Smrg      -Wl,*)
175853e90a53Smrg	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'`
175953e90a53Smrg	arg=
176053e90a53Smrg	save_ifs="$IFS"; IFS=','
176153e90a53Smrg	for flag in $args; do
176253e90a53Smrg	  IFS="$save_ifs"
176353e90a53Smrg	  case $flag in
176453e90a53Smrg	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
176553e90a53Smrg	    flag="\"$flag\""
176653e90a53Smrg	    ;;
176753e90a53Smrg	  esac
176853e90a53Smrg	  arg="$arg $wl$flag"
176953e90a53Smrg	  compiler_flags="$compiler_flags $wl$flag"
177053e90a53Smrg	  linker_flags="$linker_flags $flag"
177153e90a53Smrg	done
177253e90a53Smrg	IFS="$save_ifs"
177353e90a53Smrg	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
177453e90a53Smrg	;;
177553e90a53Smrg
177653e90a53Smrg      -Xcompiler)
177753e90a53Smrg	prev=xcompiler
177853e90a53Smrg	continue
177953e90a53Smrg	;;
178053e90a53Smrg
178153e90a53Smrg      -Xlinker)
178253e90a53Smrg	prev=xlinker
178353e90a53Smrg	continue
178453e90a53Smrg	;;
178553e90a53Smrg
178653e90a53Smrg      -XCClinker)
178753e90a53Smrg	prev=xcclinker
178853e90a53Smrg	continue
178953e90a53Smrg	;;
179053e90a53Smrg
179153e90a53Smrg      # Some other compiler flag.
179253e90a53Smrg      -* | +*)
179353e90a53Smrg	# Unknown arguments in both finalize_command and compile_command need
179453e90a53Smrg	# to be aesthetically quoted because they are evaled later.
179553e90a53Smrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
179653e90a53Smrg	case $arg in
179753e90a53Smrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
179853e90a53Smrg	  arg="\"$arg\""
179953e90a53Smrg	  ;;
180053e90a53Smrg	esac
180153e90a53Smrg	;;
180253e90a53Smrg
180353e90a53Smrg      *.$objext)
180453e90a53Smrg	# A standard object.
180553e90a53Smrg	objs="$objs $arg"
180653e90a53Smrg	;;
180753e90a53Smrg
180853e90a53Smrg      *.lo)
180953e90a53Smrg	# A libtool-controlled object.
181053e90a53Smrg
181153e90a53Smrg	# Check to see that this really is a libtool object.
181253e90a53Smrg	if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
181353e90a53Smrg	  pic_object=
181453e90a53Smrg	  non_pic_object=
181553e90a53Smrg
181653e90a53Smrg	  # Read the .lo file
181753e90a53Smrg	  # If there is no directory component, then add one.
181853e90a53Smrg	  case $arg in
181953e90a53Smrg	  */* | *\\*) . $arg ;;
182053e90a53Smrg	  *) . ./$arg ;;
182153e90a53Smrg	  esac
182253e90a53Smrg
182353e90a53Smrg	  if test -z "$pic_object" || \
182453e90a53Smrg	     test -z "$non_pic_object" ||
182553e90a53Smrg	     test "$pic_object" = none && \
182653e90a53Smrg	     test "$non_pic_object" = none; then
182753e90a53Smrg	    $echo "$modename: cannot find name of object for \`$arg'" 1>&2
182853e90a53Smrg	    exit $EXIT_FAILURE
182953e90a53Smrg	  fi
183053e90a53Smrg
183153e90a53Smrg	  # Extract subdirectory from the argument.
183253e90a53Smrg	  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
183353e90a53Smrg	  if test "X$xdir" = "X$arg"; then
183453e90a53Smrg	    xdir=
183553e90a53Smrg 	  else
183653e90a53Smrg	    xdir="$xdir/"
183753e90a53Smrg	  fi
183853e90a53Smrg
183953e90a53Smrg	  if test "$pic_object" != none; then
184053e90a53Smrg	    # Prepend the subdirectory the object is found in.
184153e90a53Smrg	    pic_object="$xdir$pic_object"
184253e90a53Smrg
184353e90a53Smrg	    if test "$prev" = dlfiles; then
184453e90a53Smrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
184553e90a53Smrg		dlfiles="$dlfiles $pic_object"
184653e90a53Smrg		prev=
184753e90a53Smrg		continue
184853e90a53Smrg	      else
184953e90a53Smrg		# If libtool objects are unsupported, then we need to preload.
185053e90a53Smrg		prev=dlprefiles
185153e90a53Smrg	      fi
185253e90a53Smrg	    fi
185353e90a53Smrg
185453e90a53Smrg	    # CHECK ME:  I think I busted this.  -Ossama
185553e90a53Smrg	    if test "$prev" = dlprefiles; then
185653e90a53Smrg	      # Preload the old-style object.
185753e90a53Smrg	      dlprefiles="$dlprefiles $pic_object"
185853e90a53Smrg	      prev=
185953e90a53Smrg	    fi
186053e90a53Smrg
186153e90a53Smrg	    # A PIC object.
186253e90a53Smrg	    libobjs="$libobjs $pic_object"
186353e90a53Smrg	    arg="$pic_object"
186453e90a53Smrg	  fi
186553e90a53Smrg
186653e90a53Smrg	  # Non-PIC object.
186753e90a53Smrg	  if test "$non_pic_object" != none; then
186853e90a53Smrg	    # Prepend the subdirectory the object is found in.
186953e90a53Smrg	    non_pic_object="$xdir$non_pic_object"
187053e90a53Smrg
187153e90a53Smrg	    # A standard non-PIC object
187253e90a53Smrg	    non_pic_objects="$non_pic_objects $non_pic_object"
187353e90a53Smrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
187453e90a53Smrg	      arg="$non_pic_object"
187553e90a53Smrg	    fi
187653e90a53Smrg	  else
187753e90a53Smrg	    # If the PIC object exists, use it instead.
187853e90a53Smrg	    # $xdir was prepended to $pic_object above.
187953e90a53Smrg	    non_pic_object="$pic_object"
188053e90a53Smrg	    non_pic_objects="$non_pic_objects $non_pic_object"
188153e90a53Smrg	  fi
188253e90a53Smrg	else
188353e90a53Smrg	  # Only an error if not doing a dry-run.
188453e90a53Smrg	  if test -z "$run"; then
188553e90a53Smrg	    $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
188653e90a53Smrg	    exit $EXIT_FAILURE
188753e90a53Smrg	  else
188853e90a53Smrg	    # Dry-run case.
188953e90a53Smrg
189053e90a53Smrg	    # Extract subdirectory from the argument.
189153e90a53Smrg	    xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
189253e90a53Smrg	    if test "X$xdir" = "X$arg"; then
189353e90a53Smrg	      xdir=
189453e90a53Smrg	    else
189553e90a53Smrg	      xdir="$xdir/"
189653e90a53Smrg	    fi
189753e90a53Smrg
189853e90a53Smrg	    pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
189953e90a53Smrg	    non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
190053e90a53Smrg	    libobjs="$libobjs $pic_object"
190153e90a53Smrg	    non_pic_objects="$non_pic_objects $non_pic_object"
190253e90a53Smrg	  fi
190353e90a53Smrg	fi
190453e90a53Smrg	;;
190553e90a53Smrg
190653e90a53Smrg      *.$libext)
190753e90a53Smrg	# An archive.
190853e90a53Smrg	deplibs="$deplibs $arg"
190953e90a53Smrg	old_deplibs="$old_deplibs $arg"
191053e90a53Smrg	continue
191153e90a53Smrg	;;
191253e90a53Smrg
191353e90a53Smrg      *.la)
191453e90a53Smrg	# A libtool-controlled library.
191553e90a53Smrg
191653e90a53Smrg	if test "$prev" = dlfiles; then
191753e90a53Smrg	  # This library was specified with -dlopen.
191853e90a53Smrg	  dlfiles="$dlfiles $arg"
191953e90a53Smrg	  prev=
192053e90a53Smrg	elif test "$prev" = dlprefiles; then
192153e90a53Smrg	  # The library was specified with -dlpreopen.
192253e90a53Smrg	  dlprefiles="$dlprefiles $arg"
192353e90a53Smrg	  prev=
192453e90a53Smrg	else
192553e90a53Smrg	  deplibs="$deplibs $arg"
192653e90a53Smrg	fi
192753e90a53Smrg	continue
192853e90a53Smrg	;;
192953e90a53Smrg
193053e90a53Smrg      # Some other compiler argument.
193153e90a53Smrg      *)
193253e90a53Smrg	# Unknown arguments in both finalize_command and compile_command need
193353e90a53Smrg	# to be aesthetically quoted because they are evaled later.
193453e90a53Smrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
193553e90a53Smrg	case $arg in
193653e90a53Smrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
193753e90a53Smrg	  arg="\"$arg\""
193853e90a53Smrg	  ;;
193953e90a53Smrg	esac
194053e90a53Smrg	;;
194153e90a53Smrg      esac # arg
194253e90a53Smrg
194353e90a53Smrg      # Now actually substitute the argument into the commands.
194453e90a53Smrg      if test -n "$arg"; then
194553e90a53Smrg	compile_command="$compile_command $arg"
194653e90a53Smrg	finalize_command="$finalize_command $arg"
194753e90a53Smrg      fi
194853e90a53Smrg    done # argument parsing loop
194953e90a53Smrg
195053e90a53Smrg    if test -n "$prev"; then
195153e90a53Smrg      $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
195253e90a53Smrg      $echo "$help" 1>&2
195353e90a53Smrg      exit $EXIT_FAILURE
195453e90a53Smrg    fi
195553e90a53Smrg
195653e90a53Smrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
195753e90a53Smrg      eval arg=\"$export_dynamic_flag_spec\"
195853e90a53Smrg      compile_command="$compile_command $arg"
195953e90a53Smrg      finalize_command="$finalize_command $arg"
196053e90a53Smrg    fi
196153e90a53Smrg
196253e90a53Smrg    oldlibs=
196353e90a53Smrg    # calculate the name of the file, without its directory
196453e90a53Smrg    outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
196553e90a53Smrg    libobjs_save="$libobjs"
196653e90a53Smrg
196753e90a53Smrg    if test -n "$shlibpath_var"; then
196853e90a53Smrg      # get the directories listed in $shlibpath_var
196953e90a53Smrg      eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
197053e90a53Smrg    else
197153e90a53Smrg      shlib_search_path=
197253e90a53Smrg    fi
197353e90a53Smrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
197453e90a53Smrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
197553e90a53Smrg
197653e90a53Smrg    output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
197753e90a53Smrg    if test "X$output_objdir" = "X$output"; then
197853e90a53Smrg      output_objdir="$objdir"
197953e90a53Smrg    else
198053e90a53Smrg      output_objdir="$output_objdir/$objdir"
198153e90a53Smrg    fi
198253e90a53Smrg    # Create the object directory.
198353e90a53Smrg    if test ! -d "$output_objdir"; then
198453e90a53Smrg      $show "$mkdir $output_objdir"
198553e90a53Smrg      $run $mkdir $output_objdir
198653e90a53Smrg      exit_status=$?
198753e90a53Smrg      if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then
198853e90a53Smrg	exit $exit_status
198953e90a53Smrg      fi
199053e90a53Smrg    fi
199153e90a53Smrg
199253e90a53Smrg    # Determine the type of output
199353e90a53Smrg    case $output in
199453e90a53Smrg    "")
199553e90a53Smrg      $echo "$modename: you must specify an output file" 1>&2
199653e90a53Smrg      $echo "$help" 1>&2
199753e90a53Smrg      exit $EXIT_FAILURE
199853e90a53Smrg      ;;
199953e90a53Smrg    *.$libext) linkmode=oldlib ;;
200053e90a53Smrg    *.lo | *.$objext) linkmode=obj ;;
200153e90a53Smrg    *.la) linkmode=lib ;;
200253e90a53Smrg    *) linkmode=prog ;; # Anything else should be a program.
200353e90a53Smrg    esac
200453e90a53Smrg
200553e90a53Smrg    case $host in
200653e90a53Smrg    *cygwin* | *mingw* | *pw32*)
200753e90a53Smrg      # don't eliminate duplications in $postdeps and $predeps
200853e90a53Smrg      duplicate_compiler_generated_deps=yes
200953e90a53Smrg      ;;
201053e90a53Smrg    *)
201153e90a53Smrg      duplicate_compiler_generated_deps=$duplicate_deps
201253e90a53Smrg      ;;
201353e90a53Smrg    esac
201453e90a53Smrg    specialdeplibs=
201553e90a53Smrg
201653e90a53Smrg    libs=
201753e90a53Smrg    # Find all interdependent deplibs by searching for libraries
201853e90a53Smrg    # that are linked more than once (e.g. -la -lb -la)
201953e90a53Smrg    for deplib in $deplibs; do
202053e90a53Smrg      if test "X$duplicate_deps" = "Xyes" ; then
202153e90a53Smrg	case "$libs " in
202253e90a53Smrg	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
202353e90a53Smrg	esac
202453e90a53Smrg      fi
202553e90a53Smrg      libs="$libs $deplib"
202653e90a53Smrg    done
202753e90a53Smrg
202853e90a53Smrg    if test "$linkmode" = lib; then
202953e90a53Smrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
203053e90a53Smrg
203153e90a53Smrg      # Compute libraries that are listed more than once in $predeps
203253e90a53Smrg      # $postdeps and mark them as special (i.e., whose duplicates are
203353e90a53Smrg      # not to be eliminated).
203453e90a53Smrg      pre_post_deps=
203553e90a53Smrg      if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then
203653e90a53Smrg	for pre_post_dep in $predeps $postdeps; do
203753e90a53Smrg	  case "$pre_post_deps " in
203853e90a53Smrg	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
203953e90a53Smrg	  esac
204053e90a53Smrg	  pre_post_deps="$pre_post_deps $pre_post_dep"
204153e90a53Smrg	done
204253e90a53Smrg      fi
204353e90a53Smrg      pre_post_deps=
204453e90a53Smrg    fi
204553e90a53Smrg
204653e90a53Smrg    deplibs=
204753e90a53Smrg    newdependency_libs=
204853e90a53Smrg    newlib_search_path=
204953e90a53Smrg    need_relink=no # whether we're linking any uninstalled libtool libraries
205053e90a53Smrg    notinst_deplibs= # not-installed libtool libraries
205153e90a53Smrg    case $linkmode in
205253e90a53Smrg    lib)
205353e90a53Smrg	passes="conv link"
205453e90a53Smrg	for file in $dlfiles $dlprefiles; do
205553e90a53Smrg	  case $file in
205653e90a53Smrg	  *.la) ;;
205753e90a53Smrg	  *)
205853e90a53Smrg	    $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2
205953e90a53Smrg	    exit $EXIT_FAILURE
206053e90a53Smrg	    ;;
206153e90a53Smrg	  esac
206253e90a53Smrg	done
206353e90a53Smrg	;;
206453e90a53Smrg    prog)
206553e90a53Smrg	compile_deplibs=
206653e90a53Smrg	finalize_deplibs=
206753e90a53Smrg	alldeplibs=no
206853e90a53Smrg	newdlfiles=
206953e90a53Smrg	newdlprefiles=
207053e90a53Smrg	passes="conv scan dlopen dlpreopen link"
207153e90a53Smrg	;;
207253e90a53Smrg    *)  passes="conv"
207353e90a53Smrg	;;
207453e90a53Smrg    esac
207553e90a53Smrg    for pass in $passes; do
207653e90a53Smrg      if test "$linkmode,$pass" = "lib,link" ||
207753e90a53Smrg	 test "$linkmode,$pass" = "prog,scan"; then
207853e90a53Smrg	libs="$deplibs"
207953e90a53Smrg	deplibs=
208053e90a53Smrg      fi
208153e90a53Smrg      if test "$linkmode" = prog; then
208253e90a53Smrg	case $pass in
208353e90a53Smrg	dlopen) libs="$dlfiles" ;;
208453e90a53Smrg	dlpreopen) libs="$dlprefiles" ;;
208553e90a53Smrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
208653e90a53Smrg	esac
208753e90a53Smrg      fi
208853e90a53Smrg      if test "$pass" = dlopen; then
208953e90a53Smrg	# Collect dlpreopened libraries
209053e90a53Smrg	save_deplibs="$deplibs"
209153e90a53Smrg	deplibs=
209253e90a53Smrg      fi
209353e90a53Smrg      for deplib in $libs; do
209453e90a53Smrg	lib=
209553e90a53Smrg	found=no
209653e90a53Smrg	case $deplib in
209753e90a53Smrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
209853e90a53Smrg	  if test "$linkmode,$pass" = "prog,link"; then
209953e90a53Smrg	    compile_deplibs="$deplib $compile_deplibs"
210053e90a53Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
210153e90a53Smrg	  else
210253e90a53Smrg	    compiler_flags="$compiler_flags $deplib"
210353e90a53Smrg	  fi
210453e90a53Smrg	  continue
210553e90a53Smrg	  ;;
210653e90a53Smrg	-l*)
210753e90a53Smrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
210853e90a53Smrg	    $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2
210953e90a53Smrg	    continue
211053e90a53Smrg	  fi
211153e90a53Smrg	  name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
211253e90a53Smrg	  for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do
211353e90a53Smrg	    for search_ext in .la $std_shrext .so .a; do
211453e90a53Smrg	      # Search the libtool library
211553e90a53Smrg	      lib="$searchdir/lib${name}${search_ext}"
211653e90a53Smrg	      if test -f "$lib"; then
211753e90a53Smrg		if test "$search_ext" = ".la"; then
211853e90a53Smrg		  found=yes
211953e90a53Smrg		else
212053e90a53Smrg		  found=no
212153e90a53Smrg		fi
212253e90a53Smrg		break 2
212353e90a53Smrg	      fi
212453e90a53Smrg	    done
212553e90a53Smrg	  done
212653e90a53Smrg	  if test "$found" != yes; then
212753e90a53Smrg	    # deplib doesn't seem to be a libtool library
212853e90a53Smrg	    if test "$linkmode,$pass" = "prog,link"; then
212953e90a53Smrg	      compile_deplibs="$deplib $compile_deplibs"
213053e90a53Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
213153e90a53Smrg	    else
213253e90a53Smrg	      deplibs="$deplib $deplibs"
213353e90a53Smrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
213453e90a53Smrg	    fi
213553e90a53Smrg	    continue
213653e90a53Smrg	  else # deplib is a libtool library
213753e90a53Smrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
213853e90a53Smrg	    # We need to do some special things here, and not later.
213953e90a53Smrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
214053e90a53Smrg	      case " $predeps $postdeps " in
214153e90a53Smrg	      *" $deplib "*)
214253e90a53Smrg		if (${SED} -e '2q' $lib |
214353e90a53Smrg                    grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
214453e90a53Smrg		  library_names=
214553e90a53Smrg		  old_library=
214653e90a53Smrg		  case $lib in
214753e90a53Smrg		  */* | *\\*) . $lib ;;
214853e90a53Smrg		  *) . ./$lib ;;
214953e90a53Smrg		  esac
215053e90a53Smrg		  for l in $old_library $library_names; do
215153e90a53Smrg		    ll="$l"
215253e90a53Smrg		  done
215353e90a53Smrg		  if test "X$ll" = "X$old_library" ; then # only static version available
215453e90a53Smrg		    found=no
215553e90a53Smrg		    ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
215653e90a53Smrg		    test "X$ladir" = "X$lib" && ladir="."
215753e90a53Smrg		    lib=$ladir/$old_library
215853e90a53Smrg		    if test "$linkmode,$pass" = "prog,link"; then
215953e90a53Smrg		      compile_deplibs="$deplib $compile_deplibs"
216053e90a53Smrg		      finalize_deplibs="$deplib $finalize_deplibs"
216153e90a53Smrg		    else
216253e90a53Smrg		      deplibs="$deplib $deplibs"
216353e90a53Smrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
216453e90a53Smrg		    fi
216553e90a53Smrg		    continue
216653e90a53Smrg		  fi
216753e90a53Smrg		fi
216853e90a53Smrg	        ;;
216953e90a53Smrg	      *) ;;
217053e90a53Smrg	      esac
217153e90a53Smrg	    fi
217253e90a53Smrg	  fi
217353e90a53Smrg	  ;; # -l
217453e90a53Smrg	-L*)
217553e90a53Smrg	  case $linkmode in
217653e90a53Smrg	  lib)
217753e90a53Smrg	    deplibs="$deplib $deplibs"
217853e90a53Smrg	    test "$pass" = conv && continue
217953e90a53Smrg	    newdependency_libs="$deplib $newdependency_libs"
218053e90a53Smrg	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
218153e90a53Smrg	    ;;
218253e90a53Smrg	  prog)
218353e90a53Smrg	    if test "$pass" = conv; then
218453e90a53Smrg	      deplibs="$deplib $deplibs"
218553e90a53Smrg	      continue
218653e90a53Smrg	    fi
218753e90a53Smrg	    if test "$pass" = scan; then
218853e90a53Smrg	      deplibs="$deplib $deplibs"
218953e90a53Smrg	    else
219053e90a53Smrg	      compile_deplibs="$deplib $compile_deplibs"
219153e90a53Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
219253e90a53Smrg	    fi
219353e90a53Smrg	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
219453e90a53Smrg	    ;;
219553e90a53Smrg	  *)
219653e90a53Smrg	    $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2
219753e90a53Smrg	    ;;
219853e90a53Smrg	  esac # linkmode
219953e90a53Smrg	  continue
220053e90a53Smrg	  ;; # -L
220153e90a53Smrg	-R*)
220253e90a53Smrg	  if test "$pass" = link; then
220353e90a53Smrg	    dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
220453e90a53Smrg	    # Make sure the xrpath contains only unique directories.
220553e90a53Smrg	    case "$xrpath " in
220653e90a53Smrg	    *" $dir "*) ;;
220753e90a53Smrg	    *) xrpath="$xrpath $dir" ;;
220853e90a53Smrg	    esac
220953e90a53Smrg	  fi
221053e90a53Smrg	  deplibs="$deplib $deplibs"
221153e90a53Smrg	  continue
221253e90a53Smrg	  ;;
221353e90a53Smrg	*.la) lib="$deplib" ;;
221453e90a53Smrg	*.$libext)
221553e90a53Smrg	  if test "$pass" = conv; then
221653e90a53Smrg	    deplibs="$deplib $deplibs"
221753e90a53Smrg	    continue
221853e90a53Smrg	  fi
221953e90a53Smrg	  case $linkmode in
222053e90a53Smrg	  lib)
222153e90a53Smrg	    valid_a_lib=no
222253e90a53Smrg	    case $deplibs_check_method in
222353e90a53Smrg	      match_pattern*)
222453e90a53Smrg		set dummy $deplibs_check_method
222553e90a53Smrg	        match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
222653e90a53Smrg		if eval $echo \"$deplib\" 2>/dev/null \
222753e90a53Smrg		    | $SED 10q \
222853e90a53Smrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
222953e90a53Smrg		  valid_a_lib=yes
223053e90a53Smrg		fi
223153e90a53Smrg		;;
223253e90a53Smrg	      pass_all)
223353e90a53Smrg		valid_a_lib=yes
223453e90a53Smrg		;;
223553e90a53Smrg            esac
223653e90a53Smrg	    if test "$valid_a_lib" != yes; then
223753e90a53Smrg	      $echo
223853e90a53Smrg	      $echo "*** Warning: Trying to link with static lib archive $deplib."
223953e90a53Smrg	      $echo "*** I have the capability to make that library automatically link in when"
224053e90a53Smrg	      $echo "*** you link to this library.  But I can only do this if you have a"
224153e90a53Smrg	      $echo "*** shared version of the library, which you do not appear to have"
224253e90a53Smrg	      $echo "*** because the file extensions .$libext of this argument makes me believe"
224353e90a53Smrg	      $echo "*** that it is just a static archive that I should not used here."
224453e90a53Smrg	    else
224553e90a53Smrg	      $echo
224653e90a53Smrg	      $echo "*** Warning: Linking the shared library $output against the"
224753e90a53Smrg	      $echo "*** static library $deplib is not portable!"
224853e90a53Smrg	      deplibs="$deplib $deplibs"
224953e90a53Smrg	    fi
225053e90a53Smrg	    continue
225153e90a53Smrg	    ;;
225253e90a53Smrg	  prog)
225353e90a53Smrg	    if test "$pass" != link; then
225453e90a53Smrg	      deplibs="$deplib $deplibs"
225553e90a53Smrg	    else
225653e90a53Smrg	      compile_deplibs="$deplib $compile_deplibs"
225753e90a53Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
225853e90a53Smrg	    fi
225953e90a53Smrg	    continue
226053e90a53Smrg	    ;;
226153e90a53Smrg	  esac # linkmode
226253e90a53Smrg	  ;; # *.$libext
226353e90a53Smrg	*.lo | *.$objext)
226453e90a53Smrg	  if test "$pass" = conv; then
226553e90a53Smrg	    deplibs="$deplib $deplibs"
226653e90a53Smrg	  elif test "$linkmode" = prog; then
226753e90a53Smrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
226853e90a53Smrg	      # If there is no dlopen support or we're linking statically,
226953e90a53Smrg	      # we need to preload.
227053e90a53Smrg	      newdlprefiles="$newdlprefiles $deplib"
227153e90a53Smrg	      compile_deplibs="$deplib $compile_deplibs"
227253e90a53Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
227353e90a53Smrg	    else
227453e90a53Smrg	      newdlfiles="$newdlfiles $deplib"
227553e90a53Smrg	    fi
227653e90a53Smrg	  fi
227753e90a53Smrg	  continue
227853e90a53Smrg	  ;;
227953e90a53Smrg	%DEPLIBS%)
228053e90a53Smrg	  alldeplibs=yes
228153e90a53Smrg	  continue
228253e90a53Smrg	  ;;
228353e90a53Smrg	esac # case $deplib
228453e90a53Smrg	if test "$found" = yes || test -f "$lib"; then :
228553e90a53Smrg	else
228653e90a53Smrg	  $echo "$modename: cannot find the library \`$lib' or unhandled argument \`$deplib'" 1>&2
228753e90a53Smrg	  exit $EXIT_FAILURE
228853e90a53Smrg	fi
228953e90a53Smrg
229053e90a53Smrg	# Check to see that this really is a libtool archive.
229153e90a53Smrg	if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
229253e90a53Smrg	else
229353e90a53Smrg	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
229453e90a53Smrg	  exit $EXIT_FAILURE
229553e90a53Smrg	fi
229653e90a53Smrg
229753e90a53Smrg	ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
229853e90a53Smrg	test "X$ladir" = "X$lib" && ladir="."
229953e90a53Smrg
230053e90a53Smrg	dlname=
230153e90a53Smrg	dlopen=
230253e90a53Smrg	dlpreopen=
230353e90a53Smrg	libdir=
230453e90a53Smrg	library_names=
230553e90a53Smrg	old_library=
230653e90a53Smrg	# If the library was installed with an old release of libtool,
230753e90a53Smrg	# it will not redefine variables installed, or shouldnotlink
230853e90a53Smrg	installed=yes
230953e90a53Smrg	shouldnotlink=no
231053e90a53Smrg	avoidtemprpath=
231153e90a53Smrg
231253e90a53Smrg
231353e90a53Smrg	# Read the .la file
231453e90a53Smrg	case $lib in
231553e90a53Smrg	*/* | *\\*) . $lib ;;
231653e90a53Smrg	*) . ./$lib ;;
231753e90a53Smrg	esac
231853e90a53Smrg
231953e90a53Smrg	if test "$linkmode,$pass" = "lib,link" ||
232053e90a53Smrg	   test "$linkmode,$pass" = "prog,scan" ||
232153e90a53Smrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
232253e90a53Smrg	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
232353e90a53Smrg	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
232453e90a53Smrg	fi
232553e90a53Smrg
232653e90a53Smrg	if test "$pass" = conv; then
232753e90a53Smrg	  # Only check for convenience libraries
232853e90a53Smrg	  deplibs="$lib $deplibs"
232953e90a53Smrg	  if test -z "$libdir"; then
233053e90a53Smrg	    if test -z "$old_library"; then
233153e90a53Smrg	      $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
233253e90a53Smrg	      exit $EXIT_FAILURE
233353e90a53Smrg	    fi
233453e90a53Smrg	    # It is a libtool convenience library, so add in its objects.
233553e90a53Smrg	    convenience="$convenience $ladir/$objdir/$old_library"
233653e90a53Smrg	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
233753e90a53Smrg	    tmp_libs=
233853e90a53Smrg	    for deplib in $dependency_libs; do
233953e90a53Smrg	      deplibs="$deplib $deplibs"
234053e90a53Smrg              if test "X$duplicate_deps" = "Xyes" ; then
234153e90a53Smrg	        case "$tmp_libs " in
234253e90a53Smrg	        *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
234353e90a53Smrg	        esac
234453e90a53Smrg              fi
234553e90a53Smrg	      tmp_libs="$tmp_libs $deplib"
234653e90a53Smrg	    done
234753e90a53Smrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
234853e90a53Smrg	    $echo "$modename: \`$lib' is not a convenience library" 1>&2
234953e90a53Smrg	    exit $EXIT_FAILURE
235053e90a53Smrg	  fi
235153e90a53Smrg	  continue
235253e90a53Smrg	fi # $pass = conv
235353e90a53Smrg
235453e90a53Smrg
235553e90a53Smrg	# Get the name of the library we link against.
235653e90a53Smrg	linklib=
235753e90a53Smrg	for l in $old_library $library_names; do
235853e90a53Smrg	  linklib="$l"
235953e90a53Smrg	done
236053e90a53Smrg	if test -z "$linklib"; then
236153e90a53Smrg	  $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
236253e90a53Smrg	  exit $EXIT_FAILURE
236353e90a53Smrg	fi
236453e90a53Smrg
236553e90a53Smrg	# This library was specified with -dlopen.
236653e90a53Smrg	if test "$pass" = dlopen; then
236753e90a53Smrg	  if test -z "$libdir"; then
236853e90a53Smrg	    $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2
236953e90a53Smrg	    exit $EXIT_FAILURE
237053e90a53Smrg	  fi
237153e90a53Smrg	  if test -z "$dlname" ||
237253e90a53Smrg	     test "$dlopen_support" != yes ||
237353e90a53Smrg	     test "$build_libtool_libs" = no; then
237453e90a53Smrg	    # If there is no dlname, no dlopen support or we're linking
237553e90a53Smrg	    # statically, we need to preload.  We also need to preload any
237653e90a53Smrg	    # dependent libraries so libltdl's deplib preloader doesn't
237753e90a53Smrg	    # bomb out in the load deplibs phase.
237853e90a53Smrg	    dlprefiles="$dlprefiles $lib $dependency_libs"
237953e90a53Smrg	  else
238053e90a53Smrg	    newdlfiles="$newdlfiles $lib"
238153e90a53Smrg	  fi
238253e90a53Smrg	  continue
238353e90a53Smrg	fi # $pass = dlopen
238453e90a53Smrg
238553e90a53Smrg	# We need an absolute path.
238653e90a53Smrg	case $ladir in
238753e90a53Smrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
238853e90a53Smrg	*)
238953e90a53Smrg	  abs_ladir=`cd "$ladir" && pwd`
239053e90a53Smrg	  if test -z "$abs_ladir"; then
239153e90a53Smrg	    $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2
239253e90a53Smrg	    $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
239353e90a53Smrg	    abs_ladir="$ladir"
239453e90a53Smrg	  fi
239553e90a53Smrg	  ;;
239653e90a53Smrg	esac
239753e90a53Smrg	laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
239853e90a53Smrg
239953e90a53Smrg	# Find the relevant object directory and library name.
240053e90a53Smrg	if test "X$installed" = Xyes; then
240153e90a53Smrg	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
240253e90a53Smrg	    $echo "$modename: warning: library \`$lib' was moved." 1>&2
240353e90a53Smrg	    dir="$ladir"
240453e90a53Smrg	    absdir="$abs_ladir"
240553e90a53Smrg	    libdir="$abs_ladir"
240653e90a53Smrg	  else
240753e90a53Smrg	    dir="$libdir"
240853e90a53Smrg	    absdir="$libdir"
240953e90a53Smrg	  fi
241053e90a53Smrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
241153e90a53Smrg	else
241253e90a53Smrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
241353e90a53Smrg	    dir="$ladir"
241453e90a53Smrg	    absdir="$abs_ladir"
241553e90a53Smrg	    # Remove this search path later
241653e90a53Smrg	    notinst_path="$notinst_path $abs_ladir"
241753e90a53Smrg	  else
241853e90a53Smrg	    dir="$ladir/$objdir"
241953e90a53Smrg	    absdir="$abs_ladir/$objdir"
242053e90a53Smrg	    # Remove this search path later
242153e90a53Smrg	    notinst_path="$notinst_path $abs_ladir"
242253e90a53Smrg	  fi
242353e90a53Smrg	fi # $installed = yes
242453e90a53Smrg	name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
242553e90a53Smrg
242653e90a53Smrg	# This library was specified with -dlpreopen.
242753e90a53Smrg	if test "$pass" = dlpreopen; then
242853e90a53Smrg	  if test -z "$libdir"; then
242953e90a53Smrg	    $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2
243053e90a53Smrg	    exit $EXIT_FAILURE
243153e90a53Smrg	  fi
243253e90a53Smrg	  # Prefer using a static library (so that no silly _DYNAMIC symbols
243353e90a53Smrg	  # are required to link).
243453e90a53Smrg	  if test -n "$old_library"; then
243553e90a53Smrg	    newdlprefiles="$newdlprefiles $dir/$old_library"
243653e90a53Smrg	  # Otherwise, use the dlname, so that lt_dlopen finds it.
243753e90a53Smrg	  elif test -n "$dlname"; then
243853e90a53Smrg	    newdlprefiles="$newdlprefiles $dir/$dlname"
243953e90a53Smrg	  else
244053e90a53Smrg	    newdlprefiles="$newdlprefiles $dir/$linklib"
244153e90a53Smrg	  fi
244253e90a53Smrg	fi # $pass = dlpreopen
244353e90a53Smrg
244453e90a53Smrg	if test -z "$libdir"; then
244553e90a53Smrg	  # Link the convenience library
244653e90a53Smrg	  if test "$linkmode" = lib; then
244753e90a53Smrg	    deplibs="$dir/$old_library $deplibs"
244853e90a53Smrg	  elif test "$linkmode,$pass" = "prog,link"; then
244953e90a53Smrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
245053e90a53Smrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
245153e90a53Smrg	  else
245253e90a53Smrg	    deplibs="$lib $deplibs" # used for prog,scan pass
245353e90a53Smrg	  fi
245453e90a53Smrg	  continue
245553e90a53Smrg	fi
245653e90a53Smrg
245753e90a53Smrg
245853e90a53Smrg	if test "$linkmode" = prog && test "$pass" != link; then
245953e90a53Smrg	  newlib_search_path="$newlib_search_path $ladir"
246053e90a53Smrg	  deplibs="$lib $deplibs"
246153e90a53Smrg
246253e90a53Smrg	  linkalldeplibs=no
246353e90a53Smrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
246453e90a53Smrg	     test "$build_libtool_libs" = no; then
246553e90a53Smrg	    linkalldeplibs=yes
246653e90a53Smrg	  fi
246753e90a53Smrg
246853e90a53Smrg	  tmp_libs=
246953e90a53Smrg	  for deplib in $dependency_libs; do
247053e90a53Smrg	    case $deplib in
247153e90a53Smrg	    -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test
247253e90a53Smrg	    esac
247353e90a53Smrg	    # Need to link against all dependency_libs?
247453e90a53Smrg	    if test "$linkalldeplibs" = yes; then
247553e90a53Smrg	      deplibs="$deplib $deplibs"
247653e90a53Smrg	    else
247753e90a53Smrg	      # Need to hardcode shared library paths
247853e90a53Smrg	      # or/and link against static libraries
247953e90a53Smrg	      newdependency_libs="$deplib $newdependency_libs"
248053e90a53Smrg	    fi
248153e90a53Smrg	    if test "X$duplicate_deps" = "Xyes" ; then
248253e90a53Smrg	      case "$tmp_libs " in
248353e90a53Smrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
248453e90a53Smrg	      esac
248553e90a53Smrg	    fi
248653e90a53Smrg	    tmp_libs="$tmp_libs $deplib"
248753e90a53Smrg	  done # for deplib
248853e90a53Smrg	  continue
248953e90a53Smrg	fi # $linkmode = prog...
249053e90a53Smrg
249153e90a53Smrg	if test "$linkmode,$pass" = "prog,link"; then
249253e90a53Smrg	  if test -n "$library_names" &&
249353e90a53Smrg	     { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
249453e90a53Smrg	    # We need to hardcode the library path
249553e90a53Smrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
249653e90a53Smrg	      # Make sure the rpath contains only unique directories.
249753e90a53Smrg	      case "$temp_rpath " in
249853e90a53Smrg	      *" $dir "*) ;;
249953e90a53Smrg	      *" $absdir "*) ;;
250053e90a53Smrg	      *) temp_rpath="$temp_rpath $absdir" ;;
250153e90a53Smrg	      esac
250253e90a53Smrg	    fi
250353e90a53Smrg
250453e90a53Smrg	    # Hardcode the library path.
250553e90a53Smrg	    # Skip directories that are in the system default run-time
250653e90a53Smrg	    # search path.
250753e90a53Smrg	    case " $sys_lib_dlsearch_path " in
250853e90a53Smrg	    *" $absdir "*) ;;
250953e90a53Smrg	    *)
251053e90a53Smrg	      case "$compile_rpath " in
251153e90a53Smrg	      *" $absdir "*) ;;
251253e90a53Smrg	      *) compile_rpath="$compile_rpath $absdir"
251353e90a53Smrg	      esac
251453e90a53Smrg	      ;;
251553e90a53Smrg	    esac
251653e90a53Smrg	    case " $sys_lib_dlsearch_path " in
251753e90a53Smrg	    *" $libdir "*) ;;
251853e90a53Smrg	    *)
251953e90a53Smrg	      case "$finalize_rpath " in
252053e90a53Smrg	      *" $libdir "*) ;;
252153e90a53Smrg	      *) finalize_rpath="$finalize_rpath $libdir"
252253e90a53Smrg	      esac
252353e90a53Smrg	      ;;
252453e90a53Smrg	    esac
252553e90a53Smrg	  fi # $linkmode,$pass = prog,link...
252653e90a53Smrg
252753e90a53Smrg	  if test "$alldeplibs" = yes &&
252853e90a53Smrg	     { test "$deplibs_check_method" = pass_all ||
252953e90a53Smrg	       { test "$build_libtool_libs" = yes &&
253053e90a53Smrg		 test -n "$library_names"; }; }; then
253153e90a53Smrg	    # We only need to search for static libraries
253253e90a53Smrg	    continue
253353e90a53Smrg	  fi
253453e90a53Smrg	fi
253553e90a53Smrg
253653e90a53Smrg	link_static=no # Whether the deplib will be linked statically
253753e90a53Smrg	use_static_libs=$prefer_static_libs
253853e90a53Smrg	if test "$use_static_libs" = built && test "$installed" = yes ; then
253953e90a53Smrg	  use_static_libs=no
254053e90a53Smrg	fi
254153e90a53Smrg	if test -n "$library_names" &&
254253e90a53Smrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
254353e90a53Smrg	  if test "$installed" = no; then
254453e90a53Smrg	    notinst_deplibs="$notinst_deplibs $lib"
254553e90a53Smrg	    need_relink=yes
254653e90a53Smrg	  fi
254753e90a53Smrg	  # This is a shared library
254853e90a53Smrg
254953e90a53Smrg	  # Warn about portability, can't link against -module's on
255053e90a53Smrg	  # some systems (darwin)
255153e90a53Smrg	  if test "$shouldnotlink" = yes && test "$pass" = link ; then
255253e90a53Smrg	    $echo
255353e90a53Smrg	    if test "$linkmode" = prog; then
255453e90a53Smrg	      $echo "*** Warning: Linking the executable $output against the loadable module"
255553e90a53Smrg	    else
255653e90a53Smrg	      $echo "*** Warning: Linking the shared library $output against the loadable module"
255753e90a53Smrg	    fi
255853e90a53Smrg	    $echo "*** $linklib is not portable!"
255953e90a53Smrg	  fi
256053e90a53Smrg	  if test "$linkmode" = lib &&
256153e90a53Smrg	     test "$hardcode_into_libs" = yes; then
256253e90a53Smrg	    # Hardcode the library path.
256353e90a53Smrg	    # Skip directories that are in the system default run-time
256453e90a53Smrg	    # search path.
256553e90a53Smrg	    case " $sys_lib_dlsearch_path " in
256653e90a53Smrg	    *" $absdir "*) ;;
256753e90a53Smrg	    *)
256853e90a53Smrg	      case "$compile_rpath " in
256953e90a53Smrg	      *" $absdir "*) ;;
257053e90a53Smrg	      *) compile_rpath="$compile_rpath $absdir"
257153e90a53Smrg	      esac
257253e90a53Smrg	      ;;
257353e90a53Smrg	    esac
257453e90a53Smrg	    case " $sys_lib_dlsearch_path " in
257553e90a53Smrg	    *" $libdir "*) ;;
257653e90a53Smrg	    *)
257753e90a53Smrg	      case "$finalize_rpath " in
257853e90a53Smrg	      *" $libdir "*) ;;
257953e90a53Smrg	      *) finalize_rpath="$finalize_rpath $libdir"
258053e90a53Smrg	      esac
258153e90a53Smrg	      ;;
258253e90a53Smrg	    esac
258353e90a53Smrg	  fi
258453e90a53Smrg
258553e90a53Smrg	  if test -n "$old_archive_from_expsyms_cmds"; then
258653e90a53Smrg	    # figure out the soname
258753e90a53Smrg	    set dummy $library_names
258853e90a53Smrg	    realname="$2"
258953e90a53Smrg	    shift; shift
259053e90a53Smrg	    libname=`eval \\$echo \"$libname_spec\"`
259153e90a53Smrg	    # use dlname if we got it. it's perfectly good, no?
259253e90a53Smrg	    if test -n "$dlname"; then
259353e90a53Smrg	      soname="$dlname"
259453e90a53Smrg	    elif test -n "$soname_spec"; then
259553e90a53Smrg	      # bleh windows
259653e90a53Smrg	      case $host in
259753e90a53Smrg	      *cygwin* | mingw*)
259853e90a53Smrg		major=`expr $current - $age`
259953e90a53Smrg		versuffix="-$major"
260053e90a53Smrg		;;
260153e90a53Smrg	      esac
260253e90a53Smrg	      eval soname=\"$soname_spec\"
260353e90a53Smrg	    else
260453e90a53Smrg	      soname="$realname"
260553e90a53Smrg	    fi
260653e90a53Smrg
260753e90a53Smrg	    # Make a new name for the extract_expsyms_cmds to use
260853e90a53Smrg	    soroot="$soname"
260953e90a53Smrg	    soname=`$echo $soroot | ${SED} -e 's/^.*\///'`
261053e90a53Smrg	    newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a"
261153e90a53Smrg
261253e90a53Smrg	    # If the library has no export list, then create one now
261353e90a53Smrg	    if test -f "$output_objdir/$soname-def"; then :
261453e90a53Smrg	    else
261553e90a53Smrg	      $show "extracting exported symbol list from \`$soname'"
261653e90a53Smrg	      save_ifs="$IFS"; IFS='~'
261753e90a53Smrg	      cmds=$extract_expsyms_cmds
261853e90a53Smrg	      for cmd in $cmds; do
261953e90a53Smrg		IFS="$save_ifs"
262053e90a53Smrg		eval cmd=\"$cmd\"
262153e90a53Smrg		$show "$cmd"
262253e90a53Smrg		$run eval "$cmd" || exit $?
262353e90a53Smrg	      done
262453e90a53Smrg	      IFS="$save_ifs"
262553e90a53Smrg	    fi
262653e90a53Smrg
262753e90a53Smrg	    # Create $newlib
262853e90a53Smrg	    if test -f "$output_objdir/$newlib"; then :; else
262953e90a53Smrg	      $show "generating import library for \`$soname'"
263053e90a53Smrg	      save_ifs="$IFS"; IFS='~'
263153e90a53Smrg	      cmds=$old_archive_from_expsyms_cmds
263253e90a53Smrg	      for cmd in $cmds; do
263353e90a53Smrg		IFS="$save_ifs"
263453e90a53Smrg		eval cmd=\"$cmd\"
263553e90a53Smrg		$show "$cmd"
263653e90a53Smrg		$run eval "$cmd" || exit $?
263753e90a53Smrg	      done
263853e90a53Smrg	      IFS="$save_ifs"
263953e90a53Smrg	    fi
264053e90a53Smrg	    # make sure the library variables are pointing to the new library
264153e90a53Smrg	    dir=$output_objdir
264253e90a53Smrg	    linklib=$newlib
264353e90a53Smrg	  fi # test -n "$old_archive_from_expsyms_cmds"
264453e90a53Smrg
264553e90a53Smrg	  if test "$linkmode" = prog || test "$mode" != relink; then
264653e90a53Smrg	    add_shlibpath=
264753e90a53Smrg	    add_dir=
264853e90a53Smrg	    add=
264953e90a53Smrg	    lib_linked=yes
265053e90a53Smrg	    case $hardcode_action in
265153e90a53Smrg	    immediate | unsupported)
265253e90a53Smrg	      if test "$hardcode_direct" = no; then
265353e90a53Smrg		add="$dir/$linklib"
265453e90a53Smrg		case $host in
265553e90a53Smrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
265653e90a53Smrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
265753e90a53Smrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
265853e90a53Smrg		    *-*-unixware7*) add_dir="-L$dir" ;;
265953e90a53Smrg		  *-*-darwin* )
266053e90a53Smrg		    # if the lib is a module then we can not link against
266153e90a53Smrg		    # it, someone is ignoring the new warnings I added
266253e90a53Smrg		    if /usr/bin/file -L $add 2> /dev/null |
266353e90a53Smrg                      $EGREP ": [^:]* bundle" >/dev/null ; then
266453e90a53Smrg		      $echo "** Warning, lib $linklib is a module, not a shared library"
266553e90a53Smrg		      if test -z "$old_library" ; then
266653e90a53Smrg		        $echo
266753e90a53Smrg		        $echo "** And there doesn't seem to be a static archive available"
266853e90a53Smrg		        $echo "** The link will probably fail, sorry"
266953e90a53Smrg		      else
267053e90a53Smrg		        add="$dir/$old_library"
267153e90a53Smrg		      fi
267253e90a53Smrg		    fi
267353e90a53Smrg		esac
267453e90a53Smrg	      elif test "$hardcode_minus_L" = no; then
267553e90a53Smrg		case $host in
267653e90a53Smrg		*-*-sunos*) add_shlibpath="$dir" ;;
267753e90a53Smrg		esac
267853e90a53Smrg		add_dir="-L$dir"
267953e90a53Smrg		add="-l$name"
268053e90a53Smrg	      elif test "$hardcode_shlibpath_var" = no; then
268153e90a53Smrg		add_shlibpath="$dir"
268253e90a53Smrg		add="-l$name"
268353e90a53Smrg	      else
268453e90a53Smrg		lib_linked=no
268553e90a53Smrg	      fi
268653e90a53Smrg	      ;;
268753e90a53Smrg	    relink)
268853e90a53Smrg	      if test "$hardcode_direct" = yes; then
268953e90a53Smrg		add="$dir/$linklib"
269053e90a53Smrg	      elif test "$hardcode_minus_L" = yes; then
269153e90a53Smrg		add_dir="-L$dir"
269253e90a53Smrg		# Try looking first in the location we're being installed to.
269353e90a53Smrg		if test -n "$inst_prefix_dir"; then
269453e90a53Smrg		  case $libdir in
269553e90a53Smrg		    [\\/]*)
269653e90a53Smrg		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
269753e90a53Smrg		      ;;
269853e90a53Smrg		  esac
269953e90a53Smrg		fi
270053e90a53Smrg		add="-l$name"
270153e90a53Smrg	      elif test "$hardcode_shlibpath_var" = yes; then
270253e90a53Smrg		add_shlibpath="$dir"
270353e90a53Smrg		add="-l$name"
270453e90a53Smrg	      else
270553e90a53Smrg		lib_linked=no
270653e90a53Smrg	      fi
270753e90a53Smrg	      ;;
270853e90a53Smrg	    *) lib_linked=no ;;
270953e90a53Smrg	    esac
271053e90a53Smrg
271153e90a53Smrg	    if test "$lib_linked" != yes; then
271253e90a53Smrg	      $echo "$modename: configuration error: unsupported hardcode properties"
271353e90a53Smrg	      exit $EXIT_FAILURE
271453e90a53Smrg	    fi
271553e90a53Smrg
271653e90a53Smrg	    if test -n "$add_shlibpath"; then
271753e90a53Smrg	      case :$compile_shlibpath: in
271853e90a53Smrg	      *":$add_shlibpath:"*) ;;
271953e90a53Smrg	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
272053e90a53Smrg	      esac
272153e90a53Smrg	    fi
272253e90a53Smrg	    if test "$linkmode" = prog; then
272353e90a53Smrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
272453e90a53Smrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
272553e90a53Smrg	    else
272653e90a53Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
272753e90a53Smrg	      test -n "$add" && deplibs="$add $deplibs"
272853e90a53Smrg	      if test "$hardcode_direct" != yes && \
272953e90a53Smrg		 test "$hardcode_minus_L" != yes && \
273053e90a53Smrg		 test "$hardcode_shlibpath_var" = yes; then
273153e90a53Smrg		case :$finalize_shlibpath: in
273253e90a53Smrg		*":$libdir:"*) ;;
273353e90a53Smrg		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
273453e90a53Smrg		esac
273553e90a53Smrg	      fi
273653e90a53Smrg	    fi
273753e90a53Smrg	  fi
273853e90a53Smrg
273953e90a53Smrg	  if test "$linkmode" = prog || test "$mode" = relink; then
274053e90a53Smrg	    add_shlibpath=
274153e90a53Smrg	    add_dir=
274253e90a53Smrg	    add=
274353e90a53Smrg	    # Finalize command for both is simple: just hardcode it.
274453e90a53Smrg	    if test "$hardcode_direct" = yes; then
274553e90a53Smrg	      add="$libdir/$linklib"
274653e90a53Smrg	    elif test "$hardcode_minus_L" = yes; then
274753e90a53Smrg	      add_dir="-L$libdir"
274853e90a53Smrg	      add="-l$name"
274953e90a53Smrg	    elif test "$hardcode_shlibpath_var" = yes; then
275053e90a53Smrg	      case :$finalize_shlibpath: in
275153e90a53Smrg	      *":$libdir:"*) ;;
275253e90a53Smrg	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
275353e90a53Smrg	      esac
275453e90a53Smrg	      add="-l$name"
275553e90a53Smrg	    elif test "$hardcode_automatic" = yes; then
275653e90a53Smrg	      if test -n "$inst_prefix_dir" &&
275753e90a53Smrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
275853e90a53Smrg	        add="$inst_prefix_dir$libdir/$linklib"
275953e90a53Smrg	      else
276053e90a53Smrg	        add="$libdir/$linklib"
276153e90a53Smrg	      fi
276253e90a53Smrg	    else
276353e90a53Smrg	      # We cannot seem to hardcode it, guess we'll fake it.
276453e90a53Smrg	      add_dir="-L$libdir"
276553e90a53Smrg	      # Try looking first in the location we're being installed to.
276653e90a53Smrg	      if test -n "$inst_prefix_dir"; then
276753e90a53Smrg		case $libdir in
276853e90a53Smrg		  [\\/]*)
276953e90a53Smrg		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
277053e90a53Smrg		    ;;
277153e90a53Smrg		esac
277253e90a53Smrg	      fi
277353e90a53Smrg	      add="-l$name"
277453e90a53Smrg	    fi
277553e90a53Smrg
277653e90a53Smrg	    if test "$linkmode" = prog; then
277753e90a53Smrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
277853e90a53Smrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
277953e90a53Smrg	    else
278053e90a53Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
278153e90a53Smrg	      test -n "$add" && deplibs="$add $deplibs"
278253e90a53Smrg	    fi
278353e90a53Smrg	  fi
278453e90a53Smrg	elif test "$linkmode" = prog; then
278553e90a53Smrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
278653e90a53Smrg	  # is not unsupported.  This is valid on all known static and
278753e90a53Smrg	  # shared platforms.
278853e90a53Smrg	  if test "$hardcode_direct" != unsupported; then
278953e90a53Smrg	    test -n "$old_library" && linklib="$old_library"
279053e90a53Smrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
279153e90a53Smrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
279253e90a53Smrg	  else
279353e90a53Smrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
279453e90a53Smrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
279553e90a53Smrg	  fi
279653e90a53Smrg	elif test "$build_libtool_libs" = yes; then
279753e90a53Smrg	  # Not a shared library
279853e90a53Smrg	  if test "$deplibs_check_method" != pass_all; then
279953e90a53Smrg	    # We're trying link a shared library against a static one
280053e90a53Smrg	    # but the system doesn't support it.
280153e90a53Smrg
280253e90a53Smrg	    # Just print a warning and add the library to dependency_libs so
280353e90a53Smrg	    # that the program can be linked against the static library.
280453e90a53Smrg	    $echo
280553e90a53Smrg	    $echo "*** Warning: This system can not link to static lib archive $lib."
280653e90a53Smrg	    $echo "*** I have the capability to make that library automatically link in when"
280753e90a53Smrg	    $echo "*** you link to this library.  But I can only do this if you have a"
280853e90a53Smrg	    $echo "*** shared version of the library, which you do not appear to have."
280953e90a53Smrg	    if test "$module" = yes; then
281053e90a53Smrg	      $echo "*** But as you try to build a module library, libtool will still create "
281153e90a53Smrg	      $echo "*** a static module, that should work as long as the dlopening application"
281253e90a53Smrg	      $echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
281353e90a53Smrg	      if test -z "$global_symbol_pipe"; then
281453e90a53Smrg		$echo
281553e90a53Smrg		$echo "*** However, this would only work if libtool was able to extract symbol"
281653e90a53Smrg		$echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
281753e90a53Smrg		$echo "*** not find such a program.  So, this module is probably useless."
281853e90a53Smrg		$echo "*** \`nm' from GNU binutils and a full rebuild may help."
281953e90a53Smrg	      fi
282053e90a53Smrg	      if test "$build_old_libs" = no; then
282153e90a53Smrg		build_libtool_libs=module
282253e90a53Smrg		build_old_libs=yes
282353e90a53Smrg	      else
282453e90a53Smrg		build_libtool_libs=no
282553e90a53Smrg	      fi
282653e90a53Smrg	    fi
282753e90a53Smrg	  else
282853e90a53Smrg	    deplibs="$dir/$old_library $deplibs"
282953e90a53Smrg	    link_static=yes
283053e90a53Smrg	  fi
283153e90a53Smrg	fi # link shared/static library?
283253e90a53Smrg
283353e90a53Smrg	if test "$linkmode" = lib; then
283453e90a53Smrg	  if test -n "$dependency_libs" &&
283553e90a53Smrg	     { test "$hardcode_into_libs" != yes ||
283653e90a53Smrg	       test "$build_old_libs" = yes ||
283753e90a53Smrg	       test "$link_static" = yes; }; then
283853e90a53Smrg	    # Extract -R from dependency_libs
283953e90a53Smrg	    temp_deplibs=
284053e90a53Smrg	    for libdir in $dependency_libs; do
284153e90a53Smrg	      case $libdir in
284253e90a53Smrg	      -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'`
284353e90a53Smrg		   case " $xrpath " in
284453e90a53Smrg		   *" $temp_xrpath "*) ;;
284553e90a53Smrg		   *) xrpath="$xrpath $temp_xrpath";;
284653e90a53Smrg		   esac;;
284753e90a53Smrg	      *) temp_deplibs="$temp_deplibs $libdir";;
284853e90a53Smrg	      esac
284953e90a53Smrg	    done
285053e90a53Smrg	    dependency_libs="$temp_deplibs"
285153e90a53Smrg	  fi
285253e90a53Smrg
285353e90a53Smrg	  newlib_search_path="$newlib_search_path $absdir"
285453e90a53Smrg	  # Link against this library
285553e90a53Smrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
285653e90a53Smrg	  # ... and its dependency_libs
285753e90a53Smrg	  tmp_libs=
285853e90a53Smrg	  for deplib in $dependency_libs; do
285953e90a53Smrg	    newdependency_libs="$deplib $newdependency_libs"
286053e90a53Smrg	    if test "X$duplicate_deps" = "Xyes" ; then
286153e90a53Smrg	      case "$tmp_libs " in
286253e90a53Smrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
286353e90a53Smrg	      esac
286453e90a53Smrg	    fi
286553e90a53Smrg	    tmp_libs="$tmp_libs $deplib"
286653e90a53Smrg	  done
286753e90a53Smrg
286853e90a53Smrg	  if test "$link_all_deplibs" != no; then
286953e90a53Smrg	    # Add the search paths of all dependency libraries
287053e90a53Smrg	    for deplib in $dependency_libs; do
287153e90a53Smrg	      case $deplib in
287253e90a53Smrg	      -L*) path="$deplib" ;;
287353e90a53Smrg	      *.la)
287453e90a53Smrg		dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'`
287553e90a53Smrg		test "X$dir" = "X$deplib" && dir="."
287653e90a53Smrg		# We need an absolute path.
287753e90a53Smrg		case $dir in
287853e90a53Smrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
287953e90a53Smrg		*)
288053e90a53Smrg		  absdir=`cd "$dir" && pwd`
288153e90a53Smrg		  if test -z "$absdir"; then
288253e90a53Smrg		    $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
288353e90a53Smrg		    absdir="$dir"
288453e90a53Smrg		  fi
288553e90a53Smrg		  ;;
288653e90a53Smrg		esac
288753e90a53Smrg		if grep "^installed=no" $deplib > /dev/null; then
288853e90a53Smrg		  path="$absdir/$objdir"
288953e90a53Smrg		else
289053e90a53Smrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
289153e90a53Smrg		  if test -z "$libdir"; then
289253e90a53Smrg		    $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
289353e90a53Smrg		    exit $EXIT_FAILURE
289453e90a53Smrg		  fi
289553e90a53Smrg		  if test "$absdir" != "$libdir"; then
289653e90a53Smrg		    $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2
289753e90a53Smrg		  fi
289853e90a53Smrg		  path="$absdir"
289953e90a53Smrg		fi
290053e90a53Smrg		depdepl=
290153e90a53Smrg		case $host in
290253e90a53Smrg		*-*-darwin*)
290353e90a53Smrg		  # we do not want to link against static libs,
290453e90a53Smrg		  # but need to link against shared
290553e90a53Smrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
290653e90a53Smrg		  if test -n "$deplibrary_names" ; then
290753e90a53Smrg		    for tmp in $deplibrary_names ; do
290853e90a53Smrg		      depdepl=$tmp
290953e90a53Smrg		    done
291053e90a53Smrg		    if test -f "$path/$depdepl" ; then
291153e90a53Smrg		      depdepl="$path/$depdepl"
291253e90a53Smrg		    fi
291353e90a53Smrg		    # do not add paths which are already there
291453e90a53Smrg		    case " $newlib_search_path " in
291553e90a53Smrg		    *" $path "*) ;;
291653e90a53Smrg		    *) newlib_search_path="$newlib_search_path $path";;
291753e90a53Smrg		    esac
291853e90a53Smrg		  fi
291953e90a53Smrg		  path=""
292053e90a53Smrg		  ;;
292153e90a53Smrg		*)
292253e90a53Smrg		  path="-L$path"
292353e90a53Smrg		  ;;
292453e90a53Smrg		esac
292553e90a53Smrg		;;
292653e90a53Smrg	      -l*)
292753e90a53Smrg		case $host in
292853e90a53Smrg		*-*-darwin*)
292953e90a53Smrg		  # Again, we only want to link against shared libraries
293053e90a53Smrg		  eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"`
293153e90a53Smrg		  for tmp in $newlib_search_path ; do
293253e90a53Smrg		    if test -f "$tmp/lib$tmp_libs.dylib" ; then
293353e90a53Smrg		      eval depdepl="$tmp/lib$tmp_libs.dylib"
293453e90a53Smrg		      break
293553e90a53Smrg		    fi
293653e90a53Smrg		  done
293753e90a53Smrg		  path=""
293853e90a53Smrg		  ;;
293953e90a53Smrg		*) continue ;;
294053e90a53Smrg		esac
294153e90a53Smrg		;;
294253e90a53Smrg	      *) continue ;;
294353e90a53Smrg	      esac
294453e90a53Smrg	      case " $deplibs " in
294553e90a53Smrg	      *" $path "*) ;;
294653e90a53Smrg	      *) deplibs="$path $deplibs" ;;
294753e90a53Smrg	      esac
294853e90a53Smrg	      case " $deplibs " in
294953e90a53Smrg	      *" $depdepl "*) ;;
295053e90a53Smrg	      *) deplibs="$depdepl $deplibs" ;;
295153e90a53Smrg	      esac
295253e90a53Smrg	    done
295353e90a53Smrg	  fi # link_all_deplibs != no
295453e90a53Smrg	fi # linkmode = lib
295553e90a53Smrg      done # for deplib in $libs
295653e90a53Smrg      dependency_libs="$newdependency_libs"
295753e90a53Smrg      if test "$pass" = dlpreopen; then
295853e90a53Smrg	# Link the dlpreopened libraries before other libraries
295953e90a53Smrg	for deplib in $save_deplibs; do
296053e90a53Smrg	  deplibs="$deplib $deplibs"
296153e90a53Smrg	done
296253e90a53Smrg      fi
296353e90a53Smrg      if test "$pass" != dlopen; then
296453e90a53Smrg	if test "$pass" != conv; then
296553e90a53Smrg	  # Make sure lib_search_path contains only unique directories.
296653e90a53Smrg	  lib_search_path=
296753e90a53Smrg	  for dir in $newlib_search_path; do
296853e90a53Smrg	    case "$lib_search_path " in
296953e90a53Smrg	    *" $dir "*) ;;
297053e90a53Smrg	    *) lib_search_path="$lib_search_path $dir" ;;
297153e90a53Smrg	    esac
297253e90a53Smrg	  done
297353e90a53Smrg	  newlib_search_path=
297453e90a53Smrg	fi
297553e90a53Smrg
297653e90a53Smrg	if test "$linkmode,$pass" != "prog,link"; then
297753e90a53Smrg	  vars="deplibs"
297853e90a53Smrg	else
297953e90a53Smrg	  vars="compile_deplibs finalize_deplibs"
298053e90a53Smrg	fi
298153e90a53Smrg	for var in $vars dependency_libs; do
298253e90a53Smrg	  # Add libraries to $var in reverse order
298353e90a53Smrg	  eval tmp_libs=\"\$$var\"
298453e90a53Smrg	  new_libs=
298553e90a53Smrg	  for deplib in $tmp_libs; do
298653e90a53Smrg	    # FIXME: Pedantically, this is the right thing to do, so
298753e90a53Smrg	    #        that some nasty dependency loop isn't accidentally
298853e90a53Smrg	    #        broken:
298953e90a53Smrg	    #new_libs="$deplib $new_libs"
299053e90a53Smrg	    # Pragmatically, this seems to cause very few problems in
299153e90a53Smrg	    # practice:
299253e90a53Smrg	    case $deplib in
299353e90a53Smrg	    -L*) new_libs="$deplib $new_libs" ;;
299453e90a53Smrg	    -R*) ;;
299553e90a53Smrg	    *)
299653e90a53Smrg	      # And here is the reason: when a library appears more
299753e90a53Smrg	      # than once as an explicit dependence of a library, or
299853e90a53Smrg	      # is implicitly linked in more than once by the
299953e90a53Smrg	      # compiler, it is considered special, and multiple
300053e90a53Smrg	      # occurrences thereof are not removed.  Compare this
300153e90a53Smrg	      # with having the same library being listed as a
300253e90a53Smrg	      # dependency of multiple other libraries: in this case,
300353e90a53Smrg	      # we know (pedantically, we assume) the library does not
300453e90a53Smrg	      # need to be listed more than once, so we keep only the
300553e90a53Smrg	      # last copy.  This is not always right, but it is rare
300653e90a53Smrg	      # enough that we require users that really mean to play
300753e90a53Smrg	      # such unportable linking tricks to link the library
300853e90a53Smrg	      # using -Wl,-lname, so that libtool does not consider it
300953e90a53Smrg	      # for duplicate removal.
301053e90a53Smrg	      case " $specialdeplibs " in
301153e90a53Smrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
301253e90a53Smrg	      *)
301353e90a53Smrg		case " $new_libs " in
301453e90a53Smrg		*" $deplib "*) ;;
301553e90a53Smrg		*) new_libs="$deplib $new_libs" ;;
301653e90a53Smrg		esac
301753e90a53Smrg		;;
301853e90a53Smrg	      esac
301953e90a53Smrg	      ;;
302053e90a53Smrg	    esac
302153e90a53Smrg	  done
302253e90a53Smrg	  tmp_libs=
302353e90a53Smrg	  for deplib in $new_libs; do
302453e90a53Smrg	    case $deplib in
302553e90a53Smrg	    -L*)
302653e90a53Smrg	      case " $tmp_libs " in
302753e90a53Smrg	      *" $deplib "*) ;;
302853e90a53Smrg	      *) tmp_libs="$tmp_libs $deplib" ;;
302953e90a53Smrg	      esac
303053e90a53Smrg	      ;;
303153e90a53Smrg	    *) tmp_libs="$tmp_libs $deplib" ;;
303253e90a53Smrg	    esac
303353e90a53Smrg	  done
303453e90a53Smrg	  eval $var=\"$tmp_libs\"
303553e90a53Smrg	done # for var
303653e90a53Smrg      fi
303753e90a53Smrg      # Last step: remove runtime libs from dependency_libs
303853e90a53Smrg      # (they stay in deplibs)
303953e90a53Smrg      tmp_libs=
304053e90a53Smrg      for i in $dependency_libs ; do
304153e90a53Smrg	case " $predeps $postdeps $compiler_lib_search_path " in
304253e90a53Smrg	*" $i "*)
304353e90a53Smrg	  i=""
304453e90a53Smrg	  ;;
304553e90a53Smrg	esac
304653e90a53Smrg	if test -n "$i" ; then
304753e90a53Smrg	  tmp_libs="$tmp_libs $i"
304853e90a53Smrg	fi
304953e90a53Smrg      done
305053e90a53Smrg      dependency_libs=$tmp_libs
305153e90a53Smrg    done # for pass
305253e90a53Smrg    if test "$linkmode" = prog; then
305353e90a53Smrg      dlfiles="$newdlfiles"
305453e90a53Smrg      dlprefiles="$newdlprefiles"
305553e90a53Smrg    fi
305653e90a53Smrg
305753e90a53Smrg    case $linkmode in
305853e90a53Smrg    oldlib)
305953e90a53Smrg      if test -n "$deplibs"; then
306053e90a53Smrg	$echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2
306153e90a53Smrg      fi
306253e90a53Smrg
306353e90a53Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
306453e90a53Smrg	$echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
306553e90a53Smrg      fi
306653e90a53Smrg
306753e90a53Smrg      if test -n "$rpath"; then
306853e90a53Smrg	$echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2
306953e90a53Smrg      fi
307053e90a53Smrg
307153e90a53Smrg      if test -n "$xrpath"; then
307253e90a53Smrg	$echo "$modename: warning: \`-R' is ignored for archives" 1>&2
307353e90a53Smrg      fi
307453e90a53Smrg
307553e90a53Smrg      if test -n "$vinfo"; then
307653e90a53Smrg	$echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2
307753e90a53Smrg      fi
307853e90a53Smrg
307953e90a53Smrg      if test -n "$release"; then
308053e90a53Smrg	$echo "$modename: warning: \`-release' is ignored for archives" 1>&2
308153e90a53Smrg      fi
308253e90a53Smrg
308353e90a53Smrg      if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
308453e90a53Smrg	$echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2
308553e90a53Smrg      fi
308653e90a53Smrg
308753e90a53Smrg      # Now set the variables for building old libraries.
308853e90a53Smrg      build_libtool_libs=no
308953e90a53Smrg      oldlibs="$output"
309053e90a53Smrg      objs="$objs$old_deplibs"
309153e90a53Smrg      ;;
309253e90a53Smrg
309353e90a53Smrg    lib)
309453e90a53Smrg      # Make sure we only generate libraries of the form `libNAME.la'.
309553e90a53Smrg      case $outputname in
309653e90a53Smrg      lib*)
309753e90a53Smrg	name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
309853e90a53Smrg	eval shared_ext=\"$shrext_cmds\"
309953e90a53Smrg	eval libname=\"$libname_spec\"
310053e90a53Smrg	;;
310153e90a53Smrg      *)
310253e90a53Smrg	if test "$module" = no; then
310353e90a53Smrg	  $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
310453e90a53Smrg	  $echo "$help" 1>&2
310553e90a53Smrg	  exit $EXIT_FAILURE
310653e90a53Smrg	fi
310753e90a53Smrg	if test "$need_lib_prefix" != no; then
310853e90a53Smrg	  # Add the "lib" prefix for modules if required
310953e90a53Smrg	  name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
311053e90a53Smrg	  eval shared_ext=\"$shrext_cmds\"
311153e90a53Smrg	  eval libname=\"$libname_spec\"
311253e90a53Smrg	else
311353e90a53Smrg	  libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
311453e90a53Smrg	fi
311553e90a53Smrg	;;
311653e90a53Smrg      esac
311753e90a53Smrg
311853e90a53Smrg      if test -n "$objs"; then
311953e90a53Smrg	if test "$deplibs_check_method" != pass_all; then
312053e90a53Smrg	  $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1
312153e90a53Smrg	  exit $EXIT_FAILURE
312253e90a53Smrg	else
312353e90a53Smrg	  $echo
312453e90a53Smrg	  $echo "*** Warning: Linking the shared library $output against the non-libtool"
312553e90a53Smrg	  $echo "*** objects $objs is not portable!"
312653e90a53Smrg	  libobjs="$libobjs $objs"
312753e90a53Smrg	fi
312853e90a53Smrg      fi
312953e90a53Smrg
313053e90a53Smrg      if test "$dlself" != no; then
313153e90a53Smrg	$echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2
313253e90a53Smrg      fi
313353e90a53Smrg
313453e90a53Smrg      set dummy $rpath
313553e90a53Smrg      if test "$#" -gt 2; then
313653e90a53Smrg	$echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
313753e90a53Smrg      fi
313853e90a53Smrg      install_libdir="$2"
313953e90a53Smrg
314053e90a53Smrg      oldlibs=
314153e90a53Smrg      if test -z "$rpath"; then
314253e90a53Smrg	if test "$build_libtool_libs" = yes; then
314353e90a53Smrg	  # Building a libtool convenience library.
314453e90a53Smrg	  # Some compilers have problems with a `.al' extension so
314553e90a53Smrg	  # convenience libraries should have the same extension an
314653e90a53Smrg	  # archive normally would.
314753e90a53Smrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
314853e90a53Smrg	  build_libtool_libs=convenience
314953e90a53Smrg	  build_old_libs=yes
315053e90a53Smrg	fi
315153e90a53Smrg
315253e90a53Smrg	if test -n "$vinfo"; then
315353e90a53Smrg	  $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2
315453e90a53Smrg	fi
315553e90a53Smrg
315653e90a53Smrg	if test -n "$release"; then
315753e90a53Smrg	  $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2
315853e90a53Smrg	fi
315953e90a53Smrg      else
316053e90a53Smrg
316153e90a53Smrg	# Parse the version information argument.
316253e90a53Smrg	save_ifs="$IFS"; IFS=':'
316353e90a53Smrg	set dummy $vinfo 0 0 0
316453e90a53Smrg	IFS="$save_ifs"
316553e90a53Smrg
316653e90a53Smrg	if test -n "$8"; then
316753e90a53Smrg	  $echo "$modename: too many parameters to \`-version-info'" 1>&2
316853e90a53Smrg	  $echo "$help" 1>&2
316953e90a53Smrg	  exit $EXIT_FAILURE
317053e90a53Smrg	fi
317153e90a53Smrg
317253e90a53Smrg	# convert absolute version numbers to libtool ages
317353e90a53Smrg	# this retains compatibility with .la files and attempts
317453e90a53Smrg	# to make the code below a bit more comprehensible
317553e90a53Smrg
317653e90a53Smrg	case $vinfo_number in
317753e90a53Smrg	yes)
317853e90a53Smrg	  number_major="$2"
317953e90a53Smrg	  number_minor="$3"
318053e90a53Smrg	  number_revision="$4"
318153e90a53Smrg	  #
318253e90a53Smrg	  # There are really only two kinds -- those that
318353e90a53Smrg	  # use the current revision as the major version
318453e90a53Smrg	  # and those that subtract age and use age as
318553e90a53Smrg	  # a minor version.  But, then there is irix
318653e90a53Smrg	  # which has an extra 1 added just for fun
318753e90a53Smrg	  #
318853e90a53Smrg	  case $version_type in
318953e90a53Smrg	  darwin|linux|osf|windows)
319053e90a53Smrg	    current=`expr $number_major + $number_minor`
319153e90a53Smrg	    age="$number_minor"
319253e90a53Smrg	    revision="$number_revision"
319353e90a53Smrg	    ;;
319453e90a53Smrg	  freebsd-aout|freebsd-elf|sunos)
319553e90a53Smrg	    current="$number_major"
319653e90a53Smrg	    revision="$number_minor"
319753e90a53Smrg	    age="0"
319853e90a53Smrg	    ;;
319953e90a53Smrg	  irix|nonstopux)
320053e90a53Smrg	    current=`expr $number_major + $number_minor - 1`
320153e90a53Smrg	    age="$number_minor"
320253e90a53Smrg	    revision="$number_minor"
320353e90a53Smrg	    ;;
320453e90a53Smrg	  esac
320553e90a53Smrg	  ;;
320653e90a53Smrg	no)
320753e90a53Smrg	  current="$2"
320853e90a53Smrg	  revision="$3"
320953e90a53Smrg	  age="$4"
321053e90a53Smrg	  ;;
321153e90a53Smrg	esac
321253e90a53Smrg
321353e90a53Smrg	# Check that each of the things are valid numbers.
321453e90a53Smrg	case $current in
321553e90a53Smrg	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]) ;;
321653e90a53Smrg	*)
321753e90a53Smrg	  $echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2
321853e90a53Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
321953e90a53Smrg	  exit $EXIT_FAILURE
322053e90a53Smrg	  ;;
322153e90a53Smrg	esac
322253e90a53Smrg
322353e90a53Smrg	case $revision in
322453e90a53Smrg	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]) ;;
322553e90a53Smrg	*)
322653e90a53Smrg	  $echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2
322753e90a53Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
322853e90a53Smrg	  exit $EXIT_FAILURE
322953e90a53Smrg	  ;;
323053e90a53Smrg	esac
323153e90a53Smrg
323253e90a53Smrg	case $age in
323353e90a53Smrg	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]) ;;
323453e90a53Smrg	*)
323553e90a53Smrg	  $echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2
323653e90a53Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
323753e90a53Smrg	  exit $EXIT_FAILURE
323853e90a53Smrg	  ;;
323953e90a53Smrg	esac
324053e90a53Smrg
324153e90a53Smrg	if test "$age" -gt "$current"; then
324253e90a53Smrg	  $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
324353e90a53Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
324453e90a53Smrg	  exit $EXIT_FAILURE
324553e90a53Smrg	fi
324653e90a53Smrg
324753e90a53Smrg	# Calculate the version variables.
324853e90a53Smrg	major=
324953e90a53Smrg	versuffix=
325053e90a53Smrg	verstring=
325153e90a53Smrg	case $version_type in
325253e90a53Smrg	none) ;;
325353e90a53Smrg
325453e90a53Smrg	darwin)
325553e90a53Smrg	  # Like Linux, but with the current version available in
325653e90a53Smrg	  # verstring for coding it into the library header
325753e90a53Smrg	  major=.`expr $current - $age`
325853e90a53Smrg	  versuffix="$major.$age.$revision"
325953e90a53Smrg	  # Darwin ld doesn't like 0 for these options...
326053e90a53Smrg	  minor_current=`expr $current + 1`
326153e90a53Smrg	  verstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
326253e90a53Smrg	  ;;
326353e90a53Smrg
326453e90a53Smrg	freebsd-aout)
326553e90a53Smrg	  major=".$current"
326653e90a53Smrg	  versuffix=".$current.$revision";
326753e90a53Smrg	  ;;
326853e90a53Smrg
326953e90a53Smrg	freebsd-elf)
327053e90a53Smrg	  major=".$current"
327153e90a53Smrg	  versuffix=".$current";
327253e90a53Smrg	  ;;
327353e90a53Smrg
327453e90a53Smrg	irix | nonstopux)
327553e90a53Smrg	  major=`expr $current - $age + 1`
327653e90a53Smrg
327753e90a53Smrg	  case $version_type in
327853e90a53Smrg	    nonstopux) verstring_prefix=nonstopux ;;
327953e90a53Smrg	    *)         verstring_prefix=sgi ;;
328053e90a53Smrg	  esac
328153e90a53Smrg	  verstring="$verstring_prefix$major.$revision"
328253e90a53Smrg
328353e90a53Smrg	  # Add in all the interfaces that we are compatible with.
328453e90a53Smrg	  loop=$revision
328553e90a53Smrg	  while test "$loop" -ne 0; do
328653e90a53Smrg	    iface=`expr $revision - $loop`
328753e90a53Smrg	    loop=`expr $loop - 1`
328853e90a53Smrg	    verstring="$verstring_prefix$major.$iface:$verstring"
328953e90a53Smrg	  done
329053e90a53Smrg
329153e90a53Smrg	  # Before this point, $major must not contain `.'.
329253e90a53Smrg	  major=.$major
329353e90a53Smrg	  versuffix="$major.$revision"
329453e90a53Smrg	  ;;
329553e90a53Smrg
329653e90a53Smrg	linux)
329753e90a53Smrg	  major=.`expr $current - $age`
329853e90a53Smrg	  versuffix="$major.$age.$revision"
329953e90a53Smrg	  ;;
330053e90a53Smrg
330153e90a53Smrg	osf)
330253e90a53Smrg	  major=.`expr $current - $age`
330353e90a53Smrg	  versuffix=".$current.$age.$revision"
330453e90a53Smrg	  verstring="$current.$age.$revision"
330553e90a53Smrg
330653e90a53Smrg	  # Add in all the interfaces that we are compatible with.
330753e90a53Smrg	  loop=$age
330853e90a53Smrg	  while test "$loop" -ne 0; do
330953e90a53Smrg	    iface=`expr $current - $loop`
331053e90a53Smrg	    loop=`expr $loop - 1`
331153e90a53Smrg	    verstring="$verstring:${iface}.0"
331253e90a53Smrg	  done
331353e90a53Smrg
331453e90a53Smrg	  # Make executables depend on our current version.
331553e90a53Smrg	  verstring="$verstring:${current}.0"
331653e90a53Smrg	  ;;
331753e90a53Smrg
331853e90a53Smrg	sunos)
331953e90a53Smrg	  major=".$current"
332053e90a53Smrg	  versuffix=".$current.$revision"
332153e90a53Smrg	  ;;
332253e90a53Smrg
332353e90a53Smrg	windows)
332453e90a53Smrg	  # Use '-' rather than '.', since we only want one
332553e90a53Smrg	  # extension on DOS 8.3 filesystems.
332653e90a53Smrg	  major=`expr $current - $age`
332753e90a53Smrg	  versuffix="-$major"
332853e90a53Smrg	  ;;
332953e90a53Smrg
333053e90a53Smrg	*)
333153e90a53Smrg	  $echo "$modename: unknown library version type \`$version_type'" 1>&2
333253e90a53Smrg	  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
333353e90a53Smrg	  exit $EXIT_FAILURE
333453e90a53Smrg	  ;;
333553e90a53Smrg	esac
333653e90a53Smrg
333753e90a53Smrg	# Clear the version info if we defaulted, and they specified a release.
333853e90a53Smrg	if test -z "$vinfo" && test -n "$release"; then
333953e90a53Smrg	  major=
334053e90a53Smrg	  case $version_type in
334153e90a53Smrg	  darwin)
334253e90a53Smrg	    # we can't check for "0.0" in archive_cmds due to quoting
334353e90a53Smrg	    # problems, so we reset it completely
334453e90a53Smrg	    verstring=
334553e90a53Smrg	    ;;
334653e90a53Smrg	  *)
334753e90a53Smrg	    verstring="0.0"
334853e90a53Smrg	    ;;
334953e90a53Smrg	  esac
335053e90a53Smrg	  if test "$need_version" = no; then
335153e90a53Smrg	    versuffix=
335253e90a53Smrg	  else
335353e90a53Smrg	    versuffix=".0.0"
335453e90a53Smrg	  fi
335553e90a53Smrg	fi
335653e90a53Smrg
335753e90a53Smrg	# Remove version info from name if versioning should be avoided
335853e90a53Smrg	if test "$avoid_version" = yes && test "$need_version" = no; then
335953e90a53Smrg	  major=
336053e90a53Smrg	  versuffix=
336153e90a53Smrg	  verstring=""
336253e90a53Smrg	fi
336353e90a53Smrg
336453e90a53Smrg	# Check to see if the archive will have undefined symbols.
336553e90a53Smrg	if test "$allow_undefined" = yes; then
336653e90a53Smrg	  if test "$allow_undefined_flag" = unsupported; then
336753e90a53Smrg	    $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2
336853e90a53Smrg	    build_libtool_libs=no
336953e90a53Smrg	    build_old_libs=yes
337053e90a53Smrg	  fi
337153e90a53Smrg	else
337253e90a53Smrg	  # Don't allow undefined symbols.
337353e90a53Smrg	  allow_undefined_flag="$no_undefined_flag"
337453e90a53Smrg	fi
337553e90a53Smrg      fi
337653e90a53Smrg
337753e90a53Smrg      if test "$mode" != relink; then
337853e90a53Smrg	# Remove our outputs, but don't remove object files since they
337953e90a53Smrg	# may have been created when compiling PIC objects.
338053e90a53Smrg	removelist=
338153e90a53Smrg	tempremovelist=`$echo "$output_objdir/*"`
338253e90a53Smrg	for p in $tempremovelist; do
338353e90a53Smrg	  case $p in
338453e90a53Smrg	    *.$objext)
338553e90a53Smrg	       ;;
338653e90a53Smrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
338753e90a53Smrg	       if test "X$precious_files_regex" != "X"; then
338853e90a53Smrg	         if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
338953e90a53Smrg	         then
339053e90a53Smrg		   continue
339153e90a53Smrg		 fi
339253e90a53Smrg	       fi
339353e90a53Smrg	       removelist="$removelist $p"
339453e90a53Smrg	       ;;
339553e90a53Smrg	    *) ;;
339653e90a53Smrg	  esac
339753e90a53Smrg	done
339853e90a53Smrg	if test -n "$removelist"; then
339953e90a53Smrg	  $show "${rm}r $removelist"
340053e90a53Smrg	  $run ${rm}r $removelist
340153e90a53Smrg	fi
340253e90a53Smrg      fi
340353e90a53Smrg
340453e90a53Smrg      # Now set the variables for building old libraries.
340553e90a53Smrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
340653e90a53Smrg	oldlibs="$oldlibs $output_objdir/$libname.$libext"
340753e90a53Smrg
340853e90a53Smrg	# Transform .lo files to .o files.
340953e90a53Smrg	oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
341053e90a53Smrg      fi
341153e90a53Smrg
341253e90a53Smrg      # Eliminate all temporary directories.
341353e90a53Smrg      for path in $notinst_path; do
341453e90a53Smrg	lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"`
341553e90a53Smrg	deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"`
341653e90a53Smrg	dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"`
341753e90a53Smrg      done
341853e90a53Smrg
341953e90a53Smrg      if test -n "$xrpath"; then
342053e90a53Smrg	# If the user specified any rpath flags, then add them.
342153e90a53Smrg	temp_xrpath=
342253e90a53Smrg	for libdir in $xrpath; do
342353e90a53Smrg	  temp_xrpath="$temp_xrpath -R$libdir"
342453e90a53Smrg	  case "$finalize_rpath " in
342553e90a53Smrg	  *" $libdir "*) ;;
342653e90a53Smrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
342753e90a53Smrg	  esac
342853e90a53Smrg	done
342953e90a53Smrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
343053e90a53Smrg	  dependency_libs="$temp_xrpath $dependency_libs"
343153e90a53Smrg	fi
343253e90a53Smrg      fi
343353e90a53Smrg
343453e90a53Smrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
343553e90a53Smrg      old_dlfiles="$dlfiles"
343653e90a53Smrg      dlfiles=
343753e90a53Smrg      for lib in $old_dlfiles; do
343853e90a53Smrg	case " $dlprefiles $dlfiles " in
343953e90a53Smrg	*" $lib "*) ;;
344053e90a53Smrg	*) dlfiles="$dlfiles $lib" ;;
344153e90a53Smrg	esac
344253e90a53Smrg      done
344353e90a53Smrg
344453e90a53Smrg      # Make sure dlprefiles contains only unique files
344553e90a53Smrg      old_dlprefiles="$dlprefiles"
344653e90a53Smrg      dlprefiles=
344753e90a53Smrg      for lib in $old_dlprefiles; do
344853e90a53Smrg	case "$dlprefiles " in
344953e90a53Smrg	*" $lib "*) ;;
345053e90a53Smrg	*) dlprefiles="$dlprefiles $lib" ;;
345153e90a53Smrg	esac
345253e90a53Smrg      done
345353e90a53Smrg
345453e90a53Smrg      if test "$build_libtool_libs" = yes; then
345553e90a53Smrg	if test -n "$rpath"; then
345653e90a53Smrg	  case $host in
345753e90a53Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*)
345853e90a53Smrg	    # these systems don't actually have a c library (as such)!
345953e90a53Smrg	    ;;
346053e90a53Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
346153e90a53Smrg	    # Rhapsody C library is in the System framework
346253e90a53Smrg	    deplibs="$deplibs -framework System"
346353e90a53Smrg	    ;;
346453e90a53Smrg	  *-*-netbsd*)
346553e90a53Smrg	    # Don't link with libc until the a.out ld.so is fixed.
346653e90a53Smrg	    ;;
346753e90a53Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
346853e90a53Smrg	    # Do not include libc due to us having libc/libc_r.
346953e90a53Smrg	    ;;
347053e90a53Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
347153e90a53Smrg	    # Causes problems with __ctype
347253e90a53Smrg	    ;;
347353e90a53Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
347453e90a53Smrg	    # Compiler inserts libc in the correct place for threads to work
347553e90a53Smrg	    ;;
347653e90a53Smrg 	  *)
347753e90a53Smrg	    # Add libc to deplibs on all other systems if necessary.
347853e90a53Smrg	    if test "$build_libtool_need_lc" = "yes"; then
347953e90a53Smrg	      deplibs="$deplibs -lc"
348053e90a53Smrg	    fi
348153e90a53Smrg	    ;;
348253e90a53Smrg	  esac
348353e90a53Smrg	fi
348453e90a53Smrg
348553e90a53Smrg	# Transform deplibs into only deplibs that can be linked in shared.
348653e90a53Smrg	name_save=$name
348753e90a53Smrg	libname_save=$libname
348853e90a53Smrg	release_save=$release
348953e90a53Smrg	versuffix_save=$versuffix
349053e90a53Smrg	major_save=$major
349153e90a53Smrg	# I'm not sure if I'm treating the release correctly.  I think
349253e90a53Smrg	# release should show up in the -l (ie -lgmp5) so we don't want to
349353e90a53Smrg	# add it in twice.  Is that correct?
349453e90a53Smrg	release=""
349553e90a53Smrg	versuffix=""
349653e90a53Smrg	major=""
349753e90a53Smrg	newdeplibs=
349853e90a53Smrg	droppeddeps=no
349953e90a53Smrg	case $deplibs_check_method in
350053e90a53Smrg	pass_all)
350153e90a53Smrg	  # Don't check for shared/static.  Everything works.
350253e90a53Smrg	  # This might be a little naive.  We might want to check
350353e90a53Smrg	  # whether the library exists or not.  But this is on
350453e90a53Smrg	  # osf3 & osf4 and I'm not really sure... Just
350553e90a53Smrg	  # implementing what was already the behavior.
350653e90a53Smrg	  newdeplibs=$deplibs
350753e90a53Smrg	  ;;
350853e90a53Smrg	test_compile)
350953e90a53Smrg	  # This code stresses the "libraries are programs" paradigm to its
351053e90a53Smrg	  # limits. Maybe even breaks it.  We compile a program, linking it
351153e90a53Smrg	  # against the deplibs as a proxy for the library.  Then we can check
351253e90a53Smrg	  # whether they linked in statically or dynamically with ldd.
351353e90a53Smrg	  $rm conftest.c
351453e90a53Smrg	  cat > conftest.c <<EOF
351553e90a53Smrg	  int main() { return 0; }
351653e90a53SmrgEOF
351753e90a53Smrg	  $rm conftest
351853e90a53Smrg	  $LTCC $LTCFLAGS -o conftest conftest.c $deplibs
351953e90a53Smrg	  if test "$?" -eq 0 ; then
352053e90a53Smrg	    ldd_output=`ldd conftest`
352153e90a53Smrg	    for i in $deplibs; do
352253e90a53Smrg	      name=`expr $i : '-l\(.*\)'`
352353e90a53Smrg	      # If $name is empty we are operating on a -L argument.
352453e90a53Smrg              if test "$name" != "" && test "$name" -ne "0"; then
352553e90a53Smrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
352653e90a53Smrg		  case " $predeps $postdeps " in
352753e90a53Smrg		  *" $i "*)
352853e90a53Smrg		    newdeplibs="$newdeplibs $i"
352953e90a53Smrg		    i=""
353053e90a53Smrg		    ;;
353153e90a53Smrg		  esac
353253e90a53Smrg	        fi
353353e90a53Smrg		if test -n "$i" ; then
353453e90a53Smrg		  libname=`eval \\$echo \"$libname_spec\"`
353553e90a53Smrg		  deplib_matches=`eval \\$echo \"$library_names_spec\"`
353653e90a53Smrg		  set dummy $deplib_matches
353753e90a53Smrg		  deplib_match=$2
353853e90a53Smrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
353953e90a53Smrg		    newdeplibs="$newdeplibs $i"
354053e90a53Smrg		  else
354153e90a53Smrg		    droppeddeps=yes
354253e90a53Smrg		    $echo
354353e90a53Smrg		    $echo "*** Warning: dynamic linker does not accept needed library $i."
354453e90a53Smrg		    $echo "*** I have the capability to make that library automatically link in when"
354553e90a53Smrg		    $echo "*** you link to this library.  But I can only do this if you have a"
354653e90a53Smrg		    $echo "*** shared version of the library, which I believe you do not have"
354753e90a53Smrg		    $echo "*** because a test_compile did reveal that the linker did not use it for"
354853e90a53Smrg		    $echo "*** its dynamic dependency list that programs get resolved with at runtime."
354953e90a53Smrg		  fi
355053e90a53Smrg		fi
355153e90a53Smrg	      else
355253e90a53Smrg		newdeplibs="$newdeplibs $i"
355353e90a53Smrg	      fi
355453e90a53Smrg	    done
355553e90a53Smrg	  else
355653e90a53Smrg	    # Error occurred in the first compile.  Let's try to salvage
355753e90a53Smrg	    # the situation: Compile a separate program for each library.
355853e90a53Smrg	    for i in $deplibs; do
355953e90a53Smrg	      name=`expr $i : '-l\(.*\)'`
356053e90a53Smrg	      # If $name is empty we are operating on a -L argument.
356153e90a53Smrg              if test "$name" != "" && test "$name" != "0"; then
356253e90a53Smrg		$rm conftest
356353e90a53Smrg		$LTCC $LTCFLAGS -o conftest conftest.c $i
356453e90a53Smrg		# Did it work?
356553e90a53Smrg		if test "$?" -eq 0 ; then
356653e90a53Smrg		  ldd_output=`ldd conftest`
356753e90a53Smrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
356853e90a53Smrg		    case " $predeps $postdeps " in
356953e90a53Smrg		    *" $i "*)
357053e90a53Smrg		      newdeplibs="$newdeplibs $i"
357153e90a53Smrg		      i=""
357253e90a53Smrg		      ;;
357353e90a53Smrg		    esac
357453e90a53Smrg		  fi
357553e90a53Smrg		  if test -n "$i" ; then
357653e90a53Smrg		    libname=`eval \\$echo \"$libname_spec\"`
357753e90a53Smrg		    deplib_matches=`eval \\$echo \"$library_names_spec\"`
357853e90a53Smrg		    set dummy $deplib_matches
357953e90a53Smrg		    deplib_match=$2
358053e90a53Smrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
358153e90a53Smrg		      newdeplibs="$newdeplibs $i"
358253e90a53Smrg		    else
358353e90a53Smrg		      droppeddeps=yes
358453e90a53Smrg		      $echo
358553e90a53Smrg		      $echo "*** Warning: dynamic linker does not accept needed library $i."
358653e90a53Smrg		      $echo "*** I have the capability to make that library automatically link in when"
358753e90a53Smrg		      $echo "*** you link to this library.  But I can only do this if you have a"
358853e90a53Smrg		      $echo "*** shared version of the library, which you do not appear to have"
358953e90a53Smrg		      $echo "*** because a test_compile did reveal that the linker did not use this one"
359053e90a53Smrg		      $echo "*** as a dynamic dependency that programs can get resolved with at runtime."
359153e90a53Smrg		    fi
359253e90a53Smrg		  fi
359353e90a53Smrg		else
359453e90a53Smrg		  droppeddeps=yes
359553e90a53Smrg		  $echo
359653e90a53Smrg		  $echo "*** Warning!  Library $i is needed by this library but I was not able to"
359753e90a53Smrg		  $echo "***  make it link in!  You will probably need to install it or some"
359853e90a53Smrg		  $echo "*** library that it depends on before this library will be fully"
359953e90a53Smrg		  $echo "*** functional.  Installing it before continuing would be even better."
360053e90a53Smrg		fi
360153e90a53Smrg	      else
360253e90a53Smrg		newdeplibs="$newdeplibs $i"
360353e90a53Smrg	      fi
360453e90a53Smrg	    done
360553e90a53Smrg	  fi
360653e90a53Smrg	  ;;
360753e90a53Smrg	file_magic*)
360853e90a53Smrg	  set dummy $deplibs_check_method
360953e90a53Smrg	  file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
361053e90a53Smrg	  for a_deplib in $deplibs; do
361153e90a53Smrg	    name=`expr $a_deplib : '-l\(.*\)'`
361253e90a53Smrg	    # If $name is empty we are operating on a -L argument.
361353e90a53Smrg            if test "$name" != "" && test  "$name" != "0"; then
361453e90a53Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
361553e90a53Smrg		case " $predeps $postdeps " in
361653e90a53Smrg		*" $a_deplib "*)
361753e90a53Smrg		  newdeplibs="$newdeplibs $a_deplib"
361853e90a53Smrg		  a_deplib=""
361953e90a53Smrg		  ;;
362053e90a53Smrg		esac
362153e90a53Smrg	      fi
362253e90a53Smrg	      if test -n "$a_deplib" ; then
362353e90a53Smrg		libname=`eval \\$echo \"$libname_spec\"`
362453e90a53Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
362553e90a53Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
362653e90a53Smrg		  for potent_lib in $potential_libs; do
362753e90a53Smrg		      # Follow soft links.
362853e90a53Smrg		      if ls -lLd "$potent_lib" 2>/dev/null \
362953e90a53Smrg			 | grep " -> " >/dev/null; then
363053e90a53Smrg			continue
363153e90a53Smrg		      fi
363253e90a53Smrg		      # The statement above tries to avoid entering an
363353e90a53Smrg		      # endless loop below, in case of cyclic links.
363453e90a53Smrg		      # We might still enter an endless loop, since a link
363553e90a53Smrg		      # loop can be closed while we follow links,
363653e90a53Smrg		      # but so what?
363753e90a53Smrg		      potlib="$potent_lib"
363853e90a53Smrg		      while test -h "$potlib" 2>/dev/null; do
363953e90a53Smrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
364053e90a53Smrg			case $potliblink in
364153e90a53Smrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
364253e90a53Smrg			*) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
364353e90a53Smrg			esac
364453e90a53Smrg		      done
364553e90a53Smrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
364653e90a53Smrg			 | ${SED} 10q \
364753e90a53Smrg			 | $EGREP "$file_magic_regex" > /dev/null; then
364853e90a53Smrg			newdeplibs="$newdeplibs $a_deplib"
364953e90a53Smrg			a_deplib=""
365053e90a53Smrg			break 2
365153e90a53Smrg		      fi
365253e90a53Smrg		  done
365353e90a53Smrg		done
365453e90a53Smrg	      fi
365553e90a53Smrg	      if test -n "$a_deplib" ; then
365653e90a53Smrg		droppeddeps=yes
365753e90a53Smrg		$echo
365853e90a53Smrg		$echo "*** Warning: linker path does not have real file for library $a_deplib."
365953e90a53Smrg		$echo "*** I have the capability to make that library automatically link in when"
366053e90a53Smrg		$echo "*** you link to this library.  But I can only do this if you have a"
366153e90a53Smrg		$echo "*** shared version of the library, which you do not appear to have"
366253e90a53Smrg		$echo "*** because I did check the linker path looking for a file starting"
366353e90a53Smrg		if test -z "$potlib" ; then
366453e90a53Smrg		  $echo "*** with $libname but no candidates were found. (...for file magic test)"
366553e90a53Smrg		else
366653e90a53Smrg		  $echo "*** with $libname and none of the candidates passed a file format test"
366753e90a53Smrg		  $echo "*** using a file magic. Last file checked: $potlib"
366853e90a53Smrg		fi
366953e90a53Smrg	      fi
367053e90a53Smrg	    else
367153e90a53Smrg	      # Add a -L argument.
367253e90a53Smrg	      newdeplibs="$newdeplibs $a_deplib"
367353e90a53Smrg	    fi
367453e90a53Smrg	  done # Gone through all deplibs.
367553e90a53Smrg	  ;;
367653e90a53Smrg	match_pattern*)
367753e90a53Smrg	  set dummy $deplibs_check_method
367853e90a53Smrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
367953e90a53Smrg	  for a_deplib in $deplibs; do
368053e90a53Smrg	    name=`expr $a_deplib : '-l\(.*\)'`
368153e90a53Smrg	    # If $name is empty we are operating on a -L argument.
368253e90a53Smrg	    if test -n "$name" && test "$name" != "0"; then
368353e90a53Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
368453e90a53Smrg		case " $predeps $postdeps " in
368553e90a53Smrg		*" $a_deplib "*)
368653e90a53Smrg		  newdeplibs="$newdeplibs $a_deplib"
368753e90a53Smrg		  a_deplib=""
368853e90a53Smrg		  ;;
368953e90a53Smrg		esac
369053e90a53Smrg	      fi
369153e90a53Smrg	      if test -n "$a_deplib" ; then
369253e90a53Smrg		libname=`eval \\$echo \"$libname_spec\"`
369353e90a53Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
369453e90a53Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
369553e90a53Smrg		  for potent_lib in $potential_libs; do
369653e90a53Smrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
369753e90a53Smrg		    if eval $echo \"$potent_lib\" 2>/dev/null \
369853e90a53Smrg		        | ${SED} 10q \
369953e90a53Smrg		        | $EGREP "$match_pattern_regex" > /dev/null; then
370053e90a53Smrg		      newdeplibs="$newdeplibs $a_deplib"
370153e90a53Smrg		      a_deplib=""
370253e90a53Smrg		      break 2
370353e90a53Smrg		    fi
370453e90a53Smrg		  done
370553e90a53Smrg		done
370653e90a53Smrg	      fi
370753e90a53Smrg	      if test -n "$a_deplib" ; then
370853e90a53Smrg		droppeddeps=yes
370953e90a53Smrg		$echo
371053e90a53Smrg		$echo "*** Warning: linker path does not have real file for library $a_deplib."
371153e90a53Smrg		$echo "*** I have the capability to make that library automatically link in when"
371253e90a53Smrg		$echo "*** you link to this library.  But I can only do this if you have a"
371353e90a53Smrg		$echo "*** shared version of the library, which you do not appear to have"
371453e90a53Smrg		$echo "*** because I did check the linker path looking for a file starting"
371553e90a53Smrg		if test -z "$potlib" ; then
371653e90a53Smrg		  $echo "*** with $libname but no candidates were found. (...for regex pattern test)"
371753e90a53Smrg		else
371853e90a53Smrg		  $echo "*** with $libname and none of the candidates passed a file format test"
371953e90a53Smrg		  $echo "*** using a regex pattern. Last file checked: $potlib"
372053e90a53Smrg		fi
372153e90a53Smrg	      fi
372253e90a53Smrg	    else
372353e90a53Smrg	      # Add a -L argument.
372453e90a53Smrg	      newdeplibs="$newdeplibs $a_deplib"
372553e90a53Smrg	    fi
372653e90a53Smrg	  done # Gone through all deplibs.
372753e90a53Smrg	  ;;
372853e90a53Smrg	none | unknown | *)
372953e90a53Smrg	  newdeplibs=""
373053e90a53Smrg	  tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
373153e90a53Smrg	    -e 's/ -[LR][^ ]*//g'`
373253e90a53Smrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
373353e90a53Smrg	    for i in $predeps $postdeps ; do
373453e90a53Smrg	      # can't use Xsed below, because $i might contain '/'
373553e90a53Smrg	      tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"`
373653e90a53Smrg	    done
373753e90a53Smrg	  fi
373853e90a53Smrg	  if $echo "X $tmp_deplibs" | $Xsed -e 's/[ 	]//g' \
373953e90a53Smrg	    | grep . >/dev/null; then
374053e90a53Smrg	    $echo
374153e90a53Smrg	    if test "X$deplibs_check_method" = "Xnone"; then
374253e90a53Smrg	      $echo "*** Warning: inter-library dependencies are not supported in this platform."
374353e90a53Smrg	    else
374453e90a53Smrg	      $echo "*** Warning: inter-library dependencies are not known to be supported."
374553e90a53Smrg	    fi
374653e90a53Smrg	    $echo "*** All declared inter-library dependencies are being dropped."
374753e90a53Smrg	    droppeddeps=yes
374853e90a53Smrg	  fi
374953e90a53Smrg	  ;;
375053e90a53Smrg	esac
375153e90a53Smrg	versuffix=$versuffix_save
375253e90a53Smrg	major=$major_save
375353e90a53Smrg	release=$release_save
375453e90a53Smrg	libname=$libname_save
375553e90a53Smrg	name=$name_save
375653e90a53Smrg
375753e90a53Smrg	case $host in
375853e90a53Smrg	*-*-rhapsody* | *-*-darwin1.[012])
375953e90a53Smrg	  # On Rhapsody replace the C library is the System framework
376053e90a53Smrg	  newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'`
376153e90a53Smrg	  ;;
376253e90a53Smrg	esac
376353e90a53Smrg
376453e90a53Smrg	if test "$droppeddeps" = yes; then
376553e90a53Smrg	  if test "$module" = yes; then
376653e90a53Smrg	    $echo
376753e90a53Smrg	    $echo "*** Warning: libtool could not satisfy all declared inter-library"
376853e90a53Smrg	    $echo "*** dependencies of module $libname.  Therefore, libtool will create"
376953e90a53Smrg	    $echo "*** a static module, that should work as long as the dlopening"
377053e90a53Smrg	    $echo "*** application is linked with the -dlopen flag."
377153e90a53Smrg	    if test -z "$global_symbol_pipe"; then
377253e90a53Smrg	      $echo
377353e90a53Smrg	      $echo "*** However, this would only work if libtool was able to extract symbol"
377453e90a53Smrg	      $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
377553e90a53Smrg	      $echo "*** not find such a program.  So, this module is probably useless."
377653e90a53Smrg	      $echo "*** \`nm' from GNU binutils and a full rebuild may help."
377753e90a53Smrg	    fi
377853e90a53Smrg	    if test "$build_old_libs" = no; then
377953e90a53Smrg	      oldlibs="$output_objdir/$libname.$libext"
378053e90a53Smrg	      build_libtool_libs=module
378153e90a53Smrg	      build_old_libs=yes
378253e90a53Smrg	    else
378353e90a53Smrg	      build_libtool_libs=no
378453e90a53Smrg	    fi
378553e90a53Smrg	  else
378653e90a53Smrg	    $echo "*** The inter-library dependencies that have been dropped here will be"
378753e90a53Smrg	    $echo "*** automatically added whenever a program is linked with this library"
378853e90a53Smrg	    $echo "*** or is declared to -dlopen it."
378953e90a53Smrg
379053e90a53Smrg	    if test "$allow_undefined" = no; then
379153e90a53Smrg	      $echo
379253e90a53Smrg	      $echo "*** Since this library must not contain undefined symbols,"
379353e90a53Smrg	      $echo "*** because either the platform does not support them or"
379453e90a53Smrg	      $echo "*** it was explicitly requested with -no-undefined,"
379553e90a53Smrg	      $echo "*** libtool will only create a static version of it."
379653e90a53Smrg	      if test "$build_old_libs" = no; then
379753e90a53Smrg		oldlibs="$output_objdir/$libname.$libext"
379853e90a53Smrg		build_libtool_libs=module
379953e90a53Smrg		build_old_libs=yes
380053e90a53Smrg	      else
380153e90a53Smrg		build_libtool_libs=no
380253e90a53Smrg	      fi
380353e90a53Smrg	    fi
380453e90a53Smrg	  fi
380553e90a53Smrg	fi
380653e90a53Smrg	# Done checking deplibs!
380753e90a53Smrg	deplibs=$newdeplibs
380853e90a53Smrg      fi
380953e90a53Smrg
381053e90a53Smrg
381153e90a53Smrg      # move library search paths that coincide with paths to not yet
381253e90a53Smrg      # installed libraries to the beginning of the library search list
381353e90a53Smrg      new_libs=
381453e90a53Smrg      for path in $notinst_path; do
381553e90a53Smrg	case " $new_libs " in
381653e90a53Smrg	*" -L$path/$objdir "*) ;;
381753e90a53Smrg	*)
381853e90a53Smrg	  case " $deplibs " in
381953e90a53Smrg	  *" -L$path/$objdir "*)
382053e90a53Smrg	    new_libs="$new_libs -L$path/$objdir" ;;
382153e90a53Smrg	  esac
382253e90a53Smrg	  ;;
382353e90a53Smrg	esac
382453e90a53Smrg      done
382553e90a53Smrg      for deplib in $deplibs; do
382653e90a53Smrg	case $deplib in
382753e90a53Smrg	-L*)
382853e90a53Smrg	  case " $new_libs " in
382953e90a53Smrg	  *" $deplib "*) ;;
383053e90a53Smrg	  *) new_libs="$new_libs $deplib" ;;
383153e90a53Smrg	  esac
383253e90a53Smrg	  ;;
383353e90a53Smrg	*) new_libs="$new_libs $deplib" ;;
383453e90a53Smrg	esac
383553e90a53Smrg      done
383653e90a53Smrg      deplibs="$new_libs"
383753e90a53Smrg
383853e90a53Smrg
383953e90a53Smrg      # All the library-specific variables (install_libdir is set above).
384053e90a53Smrg      library_names=
384153e90a53Smrg      old_library=
384253e90a53Smrg      dlname=
384353e90a53Smrg
384453e90a53Smrg      # Test again, we may have decided not to build it any more
384553e90a53Smrg      if test "$build_libtool_libs" = yes; then
384653e90a53Smrg	if test "$hardcode_into_libs" = yes; then
384753e90a53Smrg	  # Hardcode the library paths
384853e90a53Smrg	  hardcode_libdirs=
384953e90a53Smrg	  dep_rpath=
385053e90a53Smrg	  rpath="$finalize_rpath"
385153e90a53Smrg	  test "$mode" != relink && rpath="$compile_rpath$rpath"
385253e90a53Smrg	  for libdir in $rpath; do
385353e90a53Smrg	    if test -n "$hardcode_libdir_flag_spec"; then
385453e90a53Smrg	      if test -n "$hardcode_libdir_separator"; then
385553e90a53Smrg		if test -z "$hardcode_libdirs"; then
385653e90a53Smrg		  hardcode_libdirs="$libdir"
385753e90a53Smrg		else
385853e90a53Smrg		  # Just accumulate the unique libdirs.
385953e90a53Smrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
386053e90a53Smrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
386153e90a53Smrg		    ;;
386253e90a53Smrg		  *)
386353e90a53Smrg		    hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
386453e90a53Smrg		    ;;
386553e90a53Smrg		  esac
386653e90a53Smrg		fi
386753e90a53Smrg	      else
386853e90a53Smrg		eval flag=\"$hardcode_libdir_flag_spec\"
386953e90a53Smrg		dep_rpath="$dep_rpath $flag"
387053e90a53Smrg	      fi
387153e90a53Smrg	    elif test -n "$runpath_var"; then
387253e90a53Smrg	      case "$perm_rpath " in
387353e90a53Smrg	      *" $libdir "*) ;;
387453e90a53Smrg	      *) perm_rpath="$perm_rpath $libdir" ;;
387553e90a53Smrg	      esac
387653e90a53Smrg	    fi
387753e90a53Smrg	  done
387853e90a53Smrg	  # Substitute the hardcoded libdirs into the rpath.
387953e90a53Smrg	  if test -n "$hardcode_libdir_separator" &&
388053e90a53Smrg	     test -n "$hardcode_libdirs"; then
388153e90a53Smrg	    libdir="$hardcode_libdirs"
388253e90a53Smrg	    if test -n "$hardcode_libdir_flag_spec_ld"; then
388353e90a53Smrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
388453e90a53Smrg	    else
388553e90a53Smrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
388653e90a53Smrg	    fi
388753e90a53Smrg	  fi
388853e90a53Smrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
388953e90a53Smrg	    # We should set the runpath_var.
389053e90a53Smrg	    rpath=
389153e90a53Smrg	    for dir in $perm_rpath; do
389253e90a53Smrg	      rpath="$rpath$dir:"
389353e90a53Smrg	    done
389453e90a53Smrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
389553e90a53Smrg	  fi
389653e90a53Smrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
389753e90a53Smrg	fi
389853e90a53Smrg
389953e90a53Smrg	shlibpath="$finalize_shlibpath"
390053e90a53Smrg	test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
390153e90a53Smrg	if test -n "$shlibpath"; then
390253e90a53Smrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
390353e90a53Smrg	fi
390453e90a53Smrg
390553e90a53Smrg	# Get the real and link names of the library.
390653e90a53Smrg	eval shared_ext=\"$shrext_cmds\"
390753e90a53Smrg	eval library_names=\"$library_names_spec\"
390853e90a53Smrg	set dummy $library_names
390953e90a53Smrg	realname="$2"
391053e90a53Smrg	shift; shift
391153e90a53Smrg
391253e90a53Smrg	if test -n "$soname_spec"; then
391353e90a53Smrg	  eval soname=\"$soname_spec\"
391453e90a53Smrg	else
391553e90a53Smrg	  soname="$realname"
391653e90a53Smrg	fi
391753e90a53Smrg	if test -z "$dlname"; then
391853e90a53Smrg	  dlname=$soname
391953e90a53Smrg	fi
392053e90a53Smrg
392153e90a53Smrg	lib="$output_objdir/$realname"
392253e90a53Smrg	linknames=
392353e90a53Smrg	for link
392453e90a53Smrg	do
392553e90a53Smrg	  linknames="$linknames $link"
392653e90a53Smrg	done
392753e90a53Smrg
392853e90a53Smrg	# Use standard objects if they are pic
392953e90a53Smrg	test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
393053e90a53Smrg
393153e90a53Smrg	# Prepare the list of exported symbols
393253e90a53Smrg	if test -z "$export_symbols"; then
393353e90a53Smrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
393453e90a53Smrg	    $show "generating symbol list for \`$libname.la'"
393553e90a53Smrg	    export_symbols="$output_objdir/$libname.exp"
393653e90a53Smrg	    $run $rm $export_symbols
393753e90a53Smrg	    cmds=$export_symbols_cmds
393853e90a53Smrg	    save_ifs="$IFS"; IFS='~'
393953e90a53Smrg	    for cmd in $cmds; do
394053e90a53Smrg	      IFS="$save_ifs"
394153e90a53Smrg	      eval cmd=\"$cmd\"
394253e90a53Smrg	      if len=`expr "X$cmd" : ".*"` &&
394353e90a53Smrg	       test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
394453e90a53Smrg	        $show "$cmd"
394553e90a53Smrg	        $run eval "$cmd" || exit $?
394653e90a53Smrg	        skipped_export=false
394753e90a53Smrg	      else
394853e90a53Smrg	        # The command line is too long to execute in one step.
394953e90a53Smrg	        $show "using reloadable object file for export list..."
395053e90a53Smrg	        skipped_export=:
395153e90a53Smrg		# Break out early, otherwise skipped_export may be
395253e90a53Smrg		# set to false by a later but shorter cmd.
395353e90a53Smrg		break
395453e90a53Smrg	      fi
395553e90a53Smrg	    done
395653e90a53Smrg	    IFS="$save_ifs"
395753e90a53Smrg	    if test -n "$export_symbols_regex"; then
395853e90a53Smrg	      $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""
395953e90a53Smrg	      $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
396053e90a53Smrg	      $show "$mv \"${export_symbols}T\" \"$export_symbols\""
396153e90a53Smrg	      $run eval '$mv "${export_symbols}T" "$export_symbols"'
396253e90a53Smrg	    fi
396353e90a53Smrg	  fi
396453e90a53Smrg	fi
396553e90a53Smrg
396653e90a53Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
396753e90a53Smrg	  $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"'
396853e90a53Smrg	fi
396953e90a53Smrg
397053e90a53Smrg	tmp_deplibs=
397153e90a53Smrg	for test_deplib in $deplibs; do
397253e90a53Smrg		case " $convenience " in
397353e90a53Smrg		*" $test_deplib "*) ;;
397453e90a53Smrg		*)
397553e90a53Smrg			tmp_deplibs="$tmp_deplibs $test_deplib"
397653e90a53Smrg			;;
397753e90a53Smrg		esac
397853e90a53Smrg	done
397953e90a53Smrg	deplibs="$tmp_deplibs"
398053e90a53Smrg
398153e90a53Smrg	if test -n "$convenience"; then
398253e90a53Smrg	  if test -n "$whole_archive_flag_spec"; then
398353e90a53Smrg	    save_libobjs=$libobjs
398453e90a53Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
398553e90a53Smrg	  else
398653e90a53Smrg	    gentop="$output_objdir/${outputname}x"
398753e90a53Smrg	    generated="$generated $gentop"
398853e90a53Smrg
398953e90a53Smrg	    func_extract_archives $gentop $convenience
399053e90a53Smrg	    libobjs="$libobjs $func_extract_archives_result"
399153e90a53Smrg	  fi
399253e90a53Smrg	fi
399353e90a53Smrg	
399453e90a53Smrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
399553e90a53Smrg	  eval flag=\"$thread_safe_flag_spec\"
399653e90a53Smrg	  linker_flags="$linker_flags $flag"
399753e90a53Smrg	fi
399853e90a53Smrg
399953e90a53Smrg	# Make a backup of the uninstalled library when relinking
400053e90a53Smrg	if test "$mode" = relink; then
400153e90a53Smrg	  $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $?
400253e90a53Smrg	fi
400353e90a53Smrg
400453e90a53Smrg	# Do each of the archive commands.
400553e90a53Smrg	if test "$module" = yes && test -n "$module_cmds" ; then
400653e90a53Smrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
400753e90a53Smrg	    eval test_cmds=\"$module_expsym_cmds\"
400853e90a53Smrg	    cmds=$module_expsym_cmds
400953e90a53Smrg	  else
401053e90a53Smrg	    eval test_cmds=\"$module_cmds\"
401153e90a53Smrg	    cmds=$module_cmds
401253e90a53Smrg	  fi
401353e90a53Smrg	else
401453e90a53Smrg	if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
401553e90a53Smrg	  eval test_cmds=\"$archive_expsym_cmds\"
401653e90a53Smrg	  cmds=$archive_expsym_cmds
401753e90a53Smrg	else
401853e90a53Smrg	  eval test_cmds=\"$archive_cmds\"
401953e90a53Smrg	  cmds=$archive_cmds
402053e90a53Smrg	  fi
402153e90a53Smrg	fi
402253e90a53Smrg
402353e90a53Smrg	if test "X$skipped_export" != "X:" &&
402453e90a53Smrg	   len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
402553e90a53Smrg	   test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
402653e90a53Smrg	  :
402753e90a53Smrg	else
402853e90a53Smrg	  # The command line is too long to link in one step, link piecewise.
402953e90a53Smrg	  $echo "creating reloadable object files..."
403053e90a53Smrg
403153e90a53Smrg	  # Save the value of $output and $libobjs because we want to
403253e90a53Smrg	  # use them later.  If we have whole_archive_flag_spec, we
403353e90a53Smrg	  # want to use save_libobjs as it was before
403453e90a53Smrg	  # whole_archive_flag_spec was expanded, because we can't
403553e90a53Smrg	  # assume the linker understands whole_archive_flag_spec.
403653e90a53Smrg	  # This may have to be revisited, in case too many
403753e90a53Smrg	  # convenience libraries get linked in and end up exceeding
403853e90a53Smrg	  # the spec.
403953e90a53Smrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
404053e90a53Smrg	    save_libobjs=$libobjs
404153e90a53Smrg	  fi
404253e90a53Smrg	  save_output=$output
404353e90a53Smrg	  output_la=`$echo "X$output" | $Xsed -e "$basename"`
404453e90a53Smrg
404553e90a53Smrg	  # Clear the reloadable object creation command queue and
404653e90a53Smrg	  # initialize k to one.
404753e90a53Smrg	  test_cmds=
404853e90a53Smrg	  concat_cmds=
404953e90a53Smrg	  objlist=
405053e90a53Smrg	  delfiles=
405153e90a53Smrg	  last_robj=
405253e90a53Smrg	  k=1
405353e90a53Smrg	  output=$output_objdir/$output_la-${k}.$objext
405453e90a53Smrg	  # Loop over the list of objects to be linked.
405553e90a53Smrg	  for obj in $save_libobjs
405653e90a53Smrg	  do
405753e90a53Smrg	    eval test_cmds=\"$reload_cmds $objlist $last_robj\"
405853e90a53Smrg	    if test "X$objlist" = X ||
405953e90a53Smrg	       { len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
406053e90a53Smrg		 test "$len" -le "$max_cmd_len"; }; then
406153e90a53Smrg	      objlist="$objlist $obj"
406253e90a53Smrg	    else
406353e90a53Smrg	      # The command $test_cmds is almost too long, add a
406453e90a53Smrg	      # command to the queue.
406553e90a53Smrg	      if test "$k" -eq 1 ; then
406653e90a53Smrg		# The first file doesn't have a previous command to add.
406753e90a53Smrg		eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
406853e90a53Smrg	      else
406953e90a53Smrg		# All subsequent reloadable object files will link in
407053e90a53Smrg		# the last one created.
407153e90a53Smrg		eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\"
407253e90a53Smrg	      fi
407353e90a53Smrg	      last_robj=$output_objdir/$output_la-${k}.$objext
407453e90a53Smrg	      k=`expr $k + 1`
407553e90a53Smrg	      output=$output_objdir/$output_la-${k}.$objext
407653e90a53Smrg	      objlist=$obj
407753e90a53Smrg	      len=1
407853e90a53Smrg	    fi
407953e90a53Smrg	  done
408053e90a53Smrg	  # Handle the remaining objects by creating one last
408153e90a53Smrg	  # reloadable object file.  All subsequent reloadable object
408253e90a53Smrg	  # files will link in the last one created.
408353e90a53Smrg	  test -z "$concat_cmds" || concat_cmds=$concat_cmds~
408453e90a53Smrg	  eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
408553e90a53Smrg
408653e90a53Smrg	  if ${skipped_export-false}; then
408753e90a53Smrg	    $show "generating symbol list for \`$libname.la'"
408853e90a53Smrg	    export_symbols="$output_objdir/$libname.exp"
408953e90a53Smrg	    $run $rm $export_symbols
409053e90a53Smrg	    libobjs=$output
409153e90a53Smrg	    # Append the command to create the export file.
409253e90a53Smrg	    eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\"
409353e90a53Smrg          fi
409453e90a53Smrg
409553e90a53Smrg	  # Set up a command to remove the reloadable object files
409653e90a53Smrg	  # after they are used.
409753e90a53Smrg	  i=0
409853e90a53Smrg	  while test "$i" -lt "$k"
409953e90a53Smrg	  do
410053e90a53Smrg	    i=`expr $i + 1`
410153e90a53Smrg	    delfiles="$delfiles $output_objdir/$output_la-${i}.$objext"
410253e90a53Smrg	  done
410353e90a53Smrg
410453e90a53Smrg	  $echo "creating a temporary reloadable object file: $output"
410553e90a53Smrg
410653e90a53Smrg	  # Loop through the commands generated above and execute them.
410753e90a53Smrg	  save_ifs="$IFS"; IFS='~'
410853e90a53Smrg	  for cmd in $concat_cmds; do
410953e90a53Smrg	    IFS="$save_ifs"
411053e90a53Smrg	    $show "$cmd"
411153e90a53Smrg	    $run eval "$cmd" || exit $?
411253e90a53Smrg	  done
411353e90a53Smrg	  IFS="$save_ifs"
411453e90a53Smrg
411553e90a53Smrg	  libobjs=$output
411653e90a53Smrg	  # Restore the value of output.
411753e90a53Smrg	  output=$save_output
411853e90a53Smrg
411953e90a53Smrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
412053e90a53Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
412153e90a53Smrg	  fi
412253e90a53Smrg	  # Expand the library linking commands again to reset the
412353e90a53Smrg	  # value of $libobjs for piecewise linking.
412453e90a53Smrg
412553e90a53Smrg	  # Do each of the archive commands.
412653e90a53Smrg	  if test "$module" = yes && test -n "$module_cmds" ; then
412753e90a53Smrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
412853e90a53Smrg	      cmds=$module_expsym_cmds
412953e90a53Smrg	    else
413053e90a53Smrg	      cmds=$module_cmds
413153e90a53Smrg	    fi
413253e90a53Smrg	  else
413353e90a53Smrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
413453e90a53Smrg	    cmds=$archive_expsym_cmds
413553e90a53Smrg	  else
413653e90a53Smrg	    cmds=$archive_cmds
413753e90a53Smrg	    fi
413853e90a53Smrg	  fi
413953e90a53Smrg
414053e90a53Smrg	  # Append the command to remove the reloadable object files
414153e90a53Smrg	  # to the just-reset $cmds.
414253e90a53Smrg	  eval cmds=\"\$cmds~\$rm $delfiles\"
414353e90a53Smrg	fi
414453e90a53Smrg	save_ifs="$IFS"; IFS='~'
414553e90a53Smrg	for cmd in $cmds; do
414653e90a53Smrg	  IFS="$save_ifs"
414753e90a53Smrg	  eval cmd=\"$cmd\"
414853e90a53Smrg	  $show "$cmd"
414953e90a53Smrg	  $run eval "$cmd" || {
415053e90a53Smrg	    lt_exit=$?
415153e90a53Smrg
415253e90a53Smrg	    # Restore the uninstalled library and exit
415353e90a53Smrg	    if test "$mode" = relink; then
415453e90a53Smrg	      $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
415553e90a53Smrg	    fi
415653e90a53Smrg
415753e90a53Smrg	    exit $lt_exit
415853e90a53Smrg	  }
415953e90a53Smrg	done
416053e90a53Smrg	IFS="$save_ifs"
416153e90a53Smrg
416253e90a53Smrg	# Restore the uninstalled library and exit
416353e90a53Smrg	if test "$mode" = relink; then
416453e90a53Smrg	  $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $?
416553e90a53Smrg
416653e90a53Smrg	  if test -n "$convenience"; then
416753e90a53Smrg	    if test -z "$whole_archive_flag_spec"; then
416853e90a53Smrg	      $show "${rm}r $gentop"
416953e90a53Smrg	      $run ${rm}r "$gentop"
417053e90a53Smrg	    fi
417153e90a53Smrg	  fi
417253e90a53Smrg
417353e90a53Smrg	  exit $EXIT_SUCCESS
417453e90a53Smrg	fi
417553e90a53Smrg
417653e90a53Smrg	# Create links to the real library.
417753e90a53Smrg	for linkname in $linknames; do
417853e90a53Smrg	  if test "$realname" != "$linkname"; then
417953e90a53Smrg	    $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)"
418053e90a53Smrg	    $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $?
418153e90a53Smrg	  fi
418253e90a53Smrg	done
418353e90a53Smrg
418453e90a53Smrg	# If -module or -export-dynamic was specified, set the dlname.
418553e90a53Smrg	if test "$module" = yes || test "$export_dynamic" = yes; then
418653e90a53Smrg	  # On all known operating systems, these are identical.
418753e90a53Smrg	  dlname="$soname"
418853e90a53Smrg	fi
418953e90a53Smrg      fi
419053e90a53Smrg      ;;
419153e90a53Smrg
419253e90a53Smrg    obj)
419353e90a53Smrg      if test -n "$deplibs"; then
419453e90a53Smrg	$echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2
419553e90a53Smrg      fi
419653e90a53Smrg
419753e90a53Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
419853e90a53Smrg	$echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
419953e90a53Smrg      fi
420053e90a53Smrg
420153e90a53Smrg      if test -n "$rpath"; then
420253e90a53Smrg	$echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2
420353e90a53Smrg      fi
420453e90a53Smrg
420553e90a53Smrg      if test -n "$xrpath"; then
420653e90a53Smrg	$echo "$modename: warning: \`-R' is ignored for objects" 1>&2
420753e90a53Smrg      fi
420853e90a53Smrg
420953e90a53Smrg      if test -n "$vinfo"; then
421053e90a53Smrg	$echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2
421153e90a53Smrg      fi
421253e90a53Smrg
421353e90a53Smrg      if test -n "$release"; then
421453e90a53Smrg	$echo "$modename: warning: \`-release' is ignored for objects" 1>&2
421553e90a53Smrg      fi
421653e90a53Smrg
421753e90a53Smrg      case $output in
421853e90a53Smrg      *.lo)
421953e90a53Smrg	if test -n "$objs$old_deplibs"; then
422053e90a53Smrg	  $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
422153e90a53Smrg	  exit $EXIT_FAILURE
422253e90a53Smrg	fi
422353e90a53Smrg	libobj="$output"
422453e90a53Smrg	obj=`$echo "X$output" | $Xsed -e "$lo2o"`
422553e90a53Smrg	;;
422653e90a53Smrg      *)
422753e90a53Smrg	libobj=
422853e90a53Smrg	obj="$output"
422953e90a53Smrg	;;
423053e90a53Smrg      esac
423153e90a53Smrg
423253e90a53Smrg      # Delete the old objects.
423353e90a53Smrg      $run $rm $obj $libobj
423453e90a53Smrg
423553e90a53Smrg      # Objects from convenience libraries.  This assumes
423653e90a53Smrg      # single-version convenience libraries.  Whenever we create
423753e90a53Smrg      # different ones for PIC/non-PIC, this we'll have to duplicate
423853e90a53Smrg      # the extraction.
423953e90a53Smrg      reload_conv_objs=
424053e90a53Smrg      gentop=
424153e90a53Smrg      # reload_cmds runs $LD directly, so let us get rid of
424253e90a53Smrg      # -Wl from whole_archive_flag_spec
424353e90a53Smrg      wl=
424453e90a53Smrg
424553e90a53Smrg      if test -n "$convenience"; then
424653e90a53Smrg	if test -n "$whole_archive_flag_spec"; then
424753e90a53Smrg	  eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
424853e90a53Smrg	else
424953e90a53Smrg	  gentop="$output_objdir/${obj}x"
425053e90a53Smrg	  generated="$generated $gentop"
425153e90a53Smrg
425253e90a53Smrg	  func_extract_archives $gentop $convenience
425353e90a53Smrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
425453e90a53Smrg	fi
425553e90a53Smrg      fi
425653e90a53Smrg
425753e90a53Smrg      # Create the old-style object.
425853e90a53Smrg      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
425953e90a53Smrg
426053e90a53Smrg      output="$obj"
426153e90a53Smrg      cmds=$reload_cmds
426253e90a53Smrg      save_ifs="$IFS"; IFS='~'
426353e90a53Smrg      for cmd in $cmds; do
426453e90a53Smrg	IFS="$save_ifs"
426553e90a53Smrg	eval cmd=\"$cmd\"
426653e90a53Smrg	$show "$cmd"
426753e90a53Smrg	$run eval "$cmd" || exit $?
426853e90a53Smrg      done
426953e90a53Smrg      IFS="$save_ifs"
427053e90a53Smrg
427153e90a53Smrg      # Exit if we aren't doing a library object file.
427253e90a53Smrg      if test -z "$libobj"; then
427353e90a53Smrg	if test -n "$gentop"; then
427453e90a53Smrg	  $show "${rm}r $gentop"
427553e90a53Smrg	  $run ${rm}r $gentop
427653e90a53Smrg	fi
427753e90a53Smrg
427853e90a53Smrg	exit $EXIT_SUCCESS
427953e90a53Smrg      fi
428053e90a53Smrg
428153e90a53Smrg      if test "$build_libtool_libs" != yes; then
428253e90a53Smrg	if test -n "$gentop"; then
428353e90a53Smrg	  $show "${rm}r $gentop"
428453e90a53Smrg	  $run ${rm}r $gentop
428553e90a53Smrg	fi
428653e90a53Smrg
428753e90a53Smrg	# Create an invalid libtool object if no PIC, so that we don't
428853e90a53Smrg	# accidentally link it into a program.
428953e90a53Smrg	# $show "echo timestamp > $libobj"
429053e90a53Smrg	# $run eval "echo timestamp > $libobj" || exit $?
429153e90a53Smrg	exit $EXIT_SUCCESS
429253e90a53Smrg      fi
429353e90a53Smrg
429453e90a53Smrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
429553e90a53Smrg	# Only do commands if we really have different PIC objects.
429653e90a53Smrg	reload_objs="$libobjs $reload_conv_objs"
429753e90a53Smrg	output="$libobj"
429853e90a53Smrg	cmds=$reload_cmds
429953e90a53Smrg	save_ifs="$IFS"; IFS='~'
430053e90a53Smrg	for cmd in $cmds; do
430153e90a53Smrg	  IFS="$save_ifs"
430253e90a53Smrg	  eval cmd=\"$cmd\"
430353e90a53Smrg	  $show "$cmd"
430453e90a53Smrg	  $run eval "$cmd" || exit $?
430553e90a53Smrg	done
430653e90a53Smrg	IFS="$save_ifs"
430753e90a53Smrg      fi
430853e90a53Smrg
430953e90a53Smrg      if test -n "$gentop"; then
431053e90a53Smrg	$show "${rm}r $gentop"
431153e90a53Smrg	$run ${rm}r $gentop
431253e90a53Smrg      fi
431353e90a53Smrg
431453e90a53Smrg      exit $EXIT_SUCCESS
431553e90a53Smrg      ;;
431653e90a53Smrg
431753e90a53Smrg    prog)
431853e90a53Smrg      case $host in
431953e90a53Smrg	*cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;
432053e90a53Smrg      esac
432153e90a53Smrg      if test -n "$vinfo"; then
432253e90a53Smrg	$echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
432353e90a53Smrg      fi
432453e90a53Smrg
432553e90a53Smrg      if test -n "$release"; then
432653e90a53Smrg	$echo "$modename: warning: \`-release' is ignored for programs" 1>&2
432753e90a53Smrg      fi
432853e90a53Smrg
432953e90a53Smrg      if test "$preload" = yes; then
433053e90a53Smrg	if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown &&
433153e90a53Smrg	   test "$dlopen_self_static" = unknown; then
433253e90a53Smrg	  $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support."
433353e90a53Smrg	fi
433453e90a53Smrg      fi
433553e90a53Smrg
433653e90a53Smrg      case $host in
433753e90a53Smrg      *-*-rhapsody* | *-*-darwin1.[012])
433853e90a53Smrg	# On Rhapsody replace the C library is the System framework
433953e90a53Smrg	compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
434053e90a53Smrg	finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
434153e90a53Smrg	;;
434253e90a53Smrg      esac
434353e90a53Smrg
434453e90a53Smrg      case $host in
434553e90a53Smrg      *darwin*)
434653e90a53Smrg        # Don't allow lazy linking, it breaks C++ global constructors
434753e90a53Smrg        if test "$tagname" = CXX ; then
434853e90a53Smrg        compile_command="$compile_command ${wl}-bind_at_load"
434953e90a53Smrg        finalize_command="$finalize_command ${wl}-bind_at_load"
435053e90a53Smrg        fi
435153e90a53Smrg        ;;
435253e90a53Smrg      esac
435353e90a53Smrg
435453e90a53Smrg
435553e90a53Smrg      # move library search paths that coincide with paths to not yet
435653e90a53Smrg      # installed libraries to the beginning of the library search list
435753e90a53Smrg      new_libs=
435853e90a53Smrg      for path in $notinst_path; do
435953e90a53Smrg	case " $new_libs " in
436053e90a53Smrg	*" -L$path/$objdir "*) ;;
436153e90a53Smrg	*)
436253e90a53Smrg	  case " $compile_deplibs " in
436353e90a53Smrg	  *" -L$path/$objdir "*)
436453e90a53Smrg	    new_libs="$new_libs -L$path/$objdir" ;;
436553e90a53Smrg	  esac
436653e90a53Smrg	  ;;
436753e90a53Smrg	esac
436853e90a53Smrg      done
436953e90a53Smrg      for deplib in $compile_deplibs; do
437053e90a53Smrg	case $deplib in
437153e90a53Smrg	-L*)
437253e90a53Smrg	  case " $new_libs " in
437353e90a53Smrg	  *" $deplib "*) ;;
437453e90a53Smrg	  *) new_libs="$new_libs $deplib" ;;
437553e90a53Smrg	  esac
437653e90a53Smrg	  ;;
437753e90a53Smrg	*) new_libs="$new_libs $deplib" ;;
437853e90a53Smrg	esac
437953e90a53Smrg      done
438053e90a53Smrg      compile_deplibs="$new_libs"
438153e90a53Smrg
438253e90a53Smrg
438353e90a53Smrg      compile_command="$compile_command $compile_deplibs"
438453e90a53Smrg      finalize_command="$finalize_command $finalize_deplibs"
438553e90a53Smrg
438653e90a53Smrg      if test -n "$rpath$xrpath"; then
438753e90a53Smrg	# If the user specified any rpath flags, then add them.
438853e90a53Smrg	for libdir in $rpath $xrpath; do
438953e90a53Smrg	  # This is the magic to use -rpath.
439053e90a53Smrg	  case "$finalize_rpath " in
439153e90a53Smrg	  *" $libdir "*) ;;
439253e90a53Smrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
439353e90a53Smrg	  esac
439453e90a53Smrg	done
439553e90a53Smrg      fi
439653e90a53Smrg
439753e90a53Smrg      # Now hardcode the library paths
439853e90a53Smrg      rpath=
439953e90a53Smrg      hardcode_libdirs=
440053e90a53Smrg      for libdir in $compile_rpath $finalize_rpath; do
440153e90a53Smrg	if test -n "$hardcode_libdir_flag_spec"; then
440253e90a53Smrg	  if test -n "$hardcode_libdir_separator"; then
440353e90a53Smrg	    if test -z "$hardcode_libdirs"; then
440453e90a53Smrg	      hardcode_libdirs="$libdir"
440553e90a53Smrg	    else
440653e90a53Smrg	      # Just accumulate the unique libdirs.
440753e90a53Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
440853e90a53Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
440953e90a53Smrg		;;
441053e90a53Smrg	      *)
441153e90a53Smrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
441253e90a53Smrg		;;
441353e90a53Smrg	      esac
441453e90a53Smrg	    fi
441553e90a53Smrg	  else
441653e90a53Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
441753e90a53Smrg	    rpath="$rpath $flag"
441853e90a53Smrg	  fi
441953e90a53Smrg	elif test -n "$runpath_var"; then
442053e90a53Smrg	  case "$perm_rpath " in
442153e90a53Smrg	  *" $libdir "*) ;;
442253e90a53Smrg	  *) perm_rpath="$perm_rpath $libdir" ;;
442353e90a53Smrg	  esac
442453e90a53Smrg	fi
442553e90a53Smrg	case $host in
442653e90a53Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
442753e90a53Smrg	  testbindir=`$echo "X$libdir" | $Xsed -e 's*/lib$*/bin*'`
442853e90a53Smrg	  case :$dllsearchpath: in
442953e90a53Smrg	  *":$libdir:"*) ;;
443053e90a53Smrg	  *) dllsearchpath="$dllsearchpath:$libdir";;
443153e90a53Smrg	  esac
443253e90a53Smrg	  case :$dllsearchpath: in
443353e90a53Smrg	  *":$testbindir:"*) ;;
443453e90a53Smrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
443553e90a53Smrg	  esac
443653e90a53Smrg	  ;;
443753e90a53Smrg	esac
443853e90a53Smrg      done
443953e90a53Smrg      # Substitute the hardcoded libdirs into the rpath.
444053e90a53Smrg      if test -n "$hardcode_libdir_separator" &&
444153e90a53Smrg	 test -n "$hardcode_libdirs"; then
444253e90a53Smrg	libdir="$hardcode_libdirs"
444353e90a53Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
444453e90a53Smrg      fi
444553e90a53Smrg      compile_rpath="$rpath"
444653e90a53Smrg
444753e90a53Smrg      rpath=
444853e90a53Smrg      hardcode_libdirs=
444953e90a53Smrg      for libdir in $finalize_rpath; do
445053e90a53Smrg	if test -n "$hardcode_libdir_flag_spec"; then
445153e90a53Smrg	  if test -n "$hardcode_libdir_separator"; then
445253e90a53Smrg	    if test -z "$hardcode_libdirs"; then
445353e90a53Smrg	      hardcode_libdirs="$libdir"
445453e90a53Smrg	    else
445553e90a53Smrg	      # Just accumulate the unique libdirs.
445653e90a53Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
445753e90a53Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
445853e90a53Smrg		;;
445953e90a53Smrg	      *)
446053e90a53Smrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
446153e90a53Smrg		;;
446253e90a53Smrg	      esac
446353e90a53Smrg	    fi
446453e90a53Smrg	  else
446553e90a53Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
446653e90a53Smrg	    rpath="$rpath $flag"
446753e90a53Smrg	  fi
446853e90a53Smrg	elif test -n "$runpath_var"; then
446953e90a53Smrg	  case "$finalize_perm_rpath " in
447053e90a53Smrg	  *" $libdir "*) ;;
447153e90a53Smrg	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
447253e90a53Smrg	  esac
447353e90a53Smrg	fi
447453e90a53Smrg      done
447553e90a53Smrg      # Substitute the hardcoded libdirs into the rpath.
447653e90a53Smrg      if test -n "$hardcode_libdir_separator" &&
447753e90a53Smrg	 test -n "$hardcode_libdirs"; then
447853e90a53Smrg	libdir="$hardcode_libdirs"
447953e90a53Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
448053e90a53Smrg      fi
448153e90a53Smrg      finalize_rpath="$rpath"
448253e90a53Smrg
448353e90a53Smrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
448453e90a53Smrg	# Transform all the library objects into standard objects.
448553e90a53Smrg	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
448653e90a53Smrg	finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
448753e90a53Smrg      fi
448853e90a53Smrg
448953e90a53Smrg      dlsyms=
449053e90a53Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
449153e90a53Smrg	if test -n "$NM" && test -n "$global_symbol_pipe"; then
449253e90a53Smrg	  dlsyms="${outputname}S.c"
449353e90a53Smrg	else
449453e90a53Smrg	  $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2
449553e90a53Smrg	fi
449653e90a53Smrg      fi
449753e90a53Smrg
449853e90a53Smrg      if test -n "$dlsyms"; then
449953e90a53Smrg	case $dlsyms in
450053e90a53Smrg	"") ;;
450153e90a53Smrg	*.c)
450253e90a53Smrg	  # Discover the nlist of each of the dlfiles.
450353e90a53Smrg	  nlist="$output_objdir/${outputname}.nm"
450453e90a53Smrg
450553e90a53Smrg	  $show "$rm $nlist ${nlist}S ${nlist}T"
450653e90a53Smrg	  $run $rm "$nlist" "${nlist}S" "${nlist}T"
450753e90a53Smrg
450853e90a53Smrg	  # Parse the name list into a source file.
450953e90a53Smrg	  $show "creating $output_objdir/$dlsyms"
451053e90a53Smrg
451153e90a53Smrg	  test -z "$run" && $echo > "$output_objdir/$dlsyms" "\
451253e90a53Smrg/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */
451353e90a53Smrg/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */
451453e90a53Smrg
451553e90a53Smrg#ifdef __cplusplus
451653e90a53Smrgextern \"C\" {
451753e90a53Smrg#endif
451853e90a53Smrg
451953e90a53Smrg/* Prevent the only kind of declaration conflicts we can make. */
452053e90a53Smrg#define lt_preloaded_symbols some_other_symbol
452153e90a53Smrg
452253e90a53Smrg/* External symbol declarations for the compiler. */\
452353e90a53Smrg"
452453e90a53Smrg
452553e90a53Smrg	  if test "$dlself" = yes; then
452653e90a53Smrg	    $show "generating symbol list for \`$output'"
452753e90a53Smrg
452853e90a53Smrg	    test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist"
452953e90a53Smrg
453053e90a53Smrg	    # Add our own program objects to the symbol list.
453153e90a53Smrg	    progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
453253e90a53Smrg	    for arg in $progfiles; do
453353e90a53Smrg	      $show "extracting global C symbols from \`$arg'"
453453e90a53Smrg	      $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
453553e90a53Smrg	    done
453653e90a53Smrg
453753e90a53Smrg	    if test -n "$exclude_expsyms"; then
453853e90a53Smrg	      $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
453953e90a53Smrg	      $run eval '$mv "$nlist"T "$nlist"'
454053e90a53Smrg	    fi
454153e90a53Smrg
454253e90a53Smrg	    if test -n "$export_symbols_regex"; then
454353e90a53Smrg	      $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
454453e90a53Smrg	      $run eval '$mv "$nlist"T "$nlist"'
454553e90a53Smrg	    fi
454653e90a53Smrg
454753e90a53Smrg	    # Prepare the list of exported symbols
454853e90a53Smrg	    if test -z "$export_symbols"; then
454953e90a53Smrg	      export_symbols="$output_objdir/$outputname.exp"
455053e90a53Smrg	      $run $rm $export_symbols
455153e90a53Smrg	      $run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
455253e90a53Smrg              case $host in
455353e90a53Smrg              *cygwin* | *mingw* )
455453e90a53Smrg	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
455553e90a53Smrg		$run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
455653e90a53Smrg                ;;
455753e90a53Smrg              esac
455853e90a53Smrg	    else
455953e90a53Smrg	      $run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
456053e90a53Smrg	      $run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
456153e90a53Smrg	      $run eval 'mv "$nlist"T "$nlist"'
456253e90a53Smrg              case $host in
456353e90a53Smrg              *cygwin* | *mingw* )
456453e90a53Smrg	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
456553e90a53Smrg		$run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
456653e90a53Smrg                ;;
456753e90a53Smrg              esac
456853e90a53Smrg	    fi
456953e90a53Smrg	  fi
457053e90a53Smrg
457153e90a53Smrg	  for arg in $dlprefiles; do
457253e90a53Smrg	    $show "extracting global C symbols from \`$arg'"
457353e90a53Smrg	    name=`$echo "$arg" | ${SED} -e 's%^.*/%%'`
457453e90a53Smrg	    $run eval '$echo ": $name " >> "$nlist"'
457553e90a53Smrg	    $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
457653e90a53Smrg	  done
457753e90a53Smrg
457853e90a53Smrg	  if test -z "$run"; then
457953e90a53Smrg	    # Make sure we have at least an empty file.
458053e90a53Smrg	    test -f "$nlist" || : > "$nlist"
458153e90a53Smrg
458253e90a53Smrg	    if test -n "$exclude_expsyms"; then
458353e90a53Smrg	      $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
458453e90a53Smrg	      $mv "$nlist"T "$nlist"
458553e90a53Smrg	    fi
458653e90a53Smrg
458753e90a53Smrg	    # Try sorting and uniquifying the output.
458853e90a53Smrg	    if grep -v "^: " < "$nlist" |
458953e90a53Smrg		if sort -k 3 </dev/null >/dev/null 2>&1; then
459053e90a53Smrg		  sort -k 3
459153e90a53Smrg		else
459253e90a53Smrg		  sort +2
459353e90a53Smrg		fi |
459453e90a53Smrg		uniq > "$nlist"S; then
459553e90a53Smrg	      :
459653e90a53Smrg	    else
459753e90a53Smrg	      grep -v "^: " < "$nlist" > "$nlist"S
459853e90a53Smrg	    fi
459953e90a53Smrg
460053e90a53Smrg	    if test -f "$nlist"S; then
460153e90a53Smrg	      eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"'
460253e90a53Smrg	    else
460353e90a53Smrg	      $echo '/* NONE */' >> "$output_objdir/$dlsyms"
460453e90a53Smrg	    fi
460553e90a53Smrg
460653e90a53Smrg	    $echo >> "$output_objdir/$dlsyms" "\
460753e90a53Smrg
460853e90a53Smrg#undef lt_preloaded_symbols
460953e90a53Smrg
461053e90a53Smrg#if defined (__STDC__) && __STDC__
461153e90a53Smrg# define lt_ptr void *
461253e90a53Smrg#else
461353e90a53Smrg# define lt_ptr char *
461453e90a53Smrg# define const
461553e90a53Smrg#endif
461653e90a53Smrg
461753e90a53Smrg/* The mapping between symbol names and symbols. */
461853e90a53Smrg"
461953e90a53Smrg
462053e90a53Smrg	    case $host in
462153e90a53Smrg	    *cygwin* | *mingw* )
462253e90a53Smrg	  $echo >> "$output_objdir/$dlsyms" "\
462353e90a53Smrg/* DATA imports from DLLs on WIN32 can't be const, because
462453e90a53Smrg   runtime relocations are performed -- see ld's documentation
462553e90a53Smrg   on pseudo-relocs */
462653e90a53Smrgstruct {
462753e90a53Smrg"
462853e90a53Smrg	      ;;
462953e90a53Smrg	    * )
463053e90a53Smrg	  $echo >> "$output_objdir/$dlsyms" "\
463153e90a53Smrgconst struct {
463253e90a53Smrg"
463353e90a53Smrg	      ;;
463453e90a53Smrg	    esac
463553e90a53Smrg
463653e90a53Smrg
463753e90a53Smrg	  $echo >> "$output_objdir/$dlsyms" "\
463853e90a53Smrg  const char *name;
463953e90a53Smrg  lt_ptr address;
464053e90a53Smrg}
464153e90a53Smrglt_preloaded_symbols[] =
464253e90a53Smrg{\
464353e90a53Smrg"
464453e90a53Smrg
464553e90a53Smrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms"
464653e90a53Smrg
464753e90a53Smrg	    $echo >> "$output_objdir/$dlsyms" "\
464853e90a53Smrg  {0, (lt_ptr) 0}
464953e90a53Smrg};
465053e90a53Smrg
465153e90a53Smrg/* This works around a problem in FreeBSD linker */
465253e90a53Smrg#ifdef FREEBSD_WORKAROUND
465353e90a53Smrgstatic const void *lt_preloaded_setup() {
465453e90a53Smrg  return lt_preloaded_symbols;
465553e90a53Smrg}
465653e90a53Smrg#endif
465753e90a53Smrg
465853e90a53Smrg#ifdef __cplusplus
465953e90a53Smrg}
466053e90a53Smrg#endif\
466153e90a53Smrg"
466253e90a53Smrg	  fi
466353e90a53Smrg
466453e90a53Smrg	  pic_flag_for_symtable=
466553e90a53Smrg	  case $host in
466653e90a53Smrg	  # compiling the symbol table file with pic_flag works around
466753e90a53Smrg	  # a FreeBSD bug that causes programs to crash when -lm is
466853e90a53Smrg	  # linked before any other PIC object.  But we must not use
466953e90a53Smrg	  # pic_flag when linking with -static.  The problem exists in
467053e90a53Smrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
467153e90a53Smrg	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
467253e90a53Smrg	    case "$compile_command " in
467353e90a53Smrg	    *" -static "*) ;;
467453e90a53Smrg	    *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";;
467553e90a53Smrg	    esac;;
467653e90a53Smrg	  *-*-hpux*)
467753e90a53Smrg	    case "$compile_command " in
467853e90a53Smrg	    *" -static "*) ;;
467953e90a53Smrg	    *) pic_flag_for_symtable=" $pic_flag";;
468053e90a53Smrg	    esac
468153e90a53Smrg	  esac
468253e90a53Smrg
468353e90a53Smrg	  # Now compile the dynamic symbol file.
468453e90a53Smrg	  $show "(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
468553e90a53Smrg	  $run eval '(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
468653e90a53Smrg
468753e90a53Smrg	  # Clean up the generated files.
468853e90a53Smrg	  $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
468953e90a53Smrg	  $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
469053e90a53Smrg
469153e90a53Smrg	  # Transform the symbol file into the correct name.
469253e90a53Smrg          case $host in
469353e90a53Smrg          *cygwin* | *mingw* )
469453e90a53Smrg            if test -f "$output_objdir/${outputname}.def" ; then
469553e90a53Smrg              compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
469653e90a53Smrg              finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
469753e90a53Smrg            else
469853e90a53Smrg              compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
469953e90a53Smrg              finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
470053e90a53Smrg             fi
470153e90a53Smrg            ;;
470253e90a53Smrg          * )
470353e90a53Smrg            compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
470453e90a53Smrg            finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
470553e90a53Smrg            ;;
470653e90a53Smrg          esac
470753e90a53Smrg	  ;;
470853e90a53Smrg	*)
470953e90a53Smrg	  $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
471053e90a53Smrg	  exit $EXIT_FAILURE
471153e90a53Smrg	  ;;
471253e90a53Smrg	esac
471353e90a53Smrg      else
471453e90a53Smrg	# We keep going just in case the user didn't refer to
471553e90a53Smrg	# lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
471653e90a53Smrg	# really was required.
471753e90a53Smrg
471853e90a53Smrg	# Nullify the symbol file.
471953e90a53Smrg	compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
472053e90a53Smrg	finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
472153e90a53Smrg      fi
472253e90a53Smrg
472353e90a53Smrg      if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
472453e90a53Smrg	# Replace the output file specification.
472553e90a53Smrg	compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
472653e90a53Smrg	link_command="$compile_command$compile_rpath"
472753e90a53Smrg
472853e90a53Smrg	# We have no uninstalled library dependencies, so finalize right now.
472953e90a53Smrg	$show "$link_command"
473053e90a53Smrg	$run eval "$link_command"
473153e90a53Smrg	exit_status=$?
473253e90a53Smrg
473353e90a53Smrg	# Delete the generated files.
473453e90a53Smrg	if test -n "$dlsyms"; then
473553e90a53Smrg	  $show "$rm $output_objdir/${outputname}S.${objext}"
473653e90a53Smrg	  $run $rm "$output_objdir/${outputname}S.${objext}"
473753e90a53Smrg	fi
473853e90a53Smrg
473953e90a53Smrg	exit $exit_status
474053e90a53Smrg      fi
474153e90a53Smrg
474253e90a53Smrg      if test -n "$shlibpath_var"; then
474353e90a53Smrg	# We should set the shlibpath_var
474453e90a53Smrg	rpath=
474553e90a53Smrg	for dir in $temp_rpath; do
474653e90a53Smrg	  case $dir in
474753e90a53Smrg	  [\\/]* | [A-Za-z]:[\\/]*)
474853e90a53Smrg	    # Absolute path.
474953e90a53Smrg	    rpath="$rpath$dir:"
475053e90a53Smrg	    ;;
475153e90a53Smrg	  *)
475253e90a53Smrg	    # Relative path: add a thisdir entry.
475353e90a53Smrg	    rpath="$rpath\$thisdir/$dir:"
475453e90a53Smrg	    ;;
475553e90a53Smrg	  esac
475653e90a53Smrg	done
475753e90a53Smrg	temp_rpath="$rpath"
475853e90a53Smrg      fi
475953e90a53Smrg
476053e90a53Smrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
476153e90a53Smrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
476253e90a53Smrg      fi
476353e90a53Smrg      if test -n "$finalize_shlibpath"; then
476453e90a53Smrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
476553e90a53Smrg      fi
476653e90a53Smrg
476753e90a53Smrg      compile_var=
476853e90a53Smrg      finalize_var=
476953e90a53Smrg      if test -n "$runpath_var"; then
477053e90a53Smrg	if test -n "$perm_rpath"; then
477153e90a53Smrg	  # We should set the runpath_var.
477253e90a53Smrg	  rpath=
477353e90a53Smrg	  for dir in $perm_rpath; do
477453e90a53Smrg	    rpath="$rpath$dir:"
477553e90a53Smrg	  done
477653e90a53Smrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
477753e90a53Smrg	fi
477853e90a53Smrg	if test -n "$finalize_perm_rpath"; then
477953e90a53Smrg	  # We should set the runpath_var.
478053e90a53Smrg	  rpath=
478153e90a53Smrg	  for dir in $finalize_perm_rpath; do
478253e90a53Smrg	    rpath="$rpath$dir:"
478353e90a53Smrg	  done
478453e90a53Smrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
478553e90a53Smrg	fi
478653e90a53Smrg      fi
478753e90a53Smrg
478853e90a53Smrg      if test "$no_install" = yes; then
478953e90a53Smrg	# We don't need to create a wrapper script.
479053e90a53Smrg	link_command="$compile_var$compile_command$compile_rpath"
479153e90a53Smrg	# Replace the output file specification.
479253e90a53Smrg	link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
479353e90a53Smrg	# Delete the old output file.
479453e90a53Smrg	$run $rm $output
479553e90a53Smrg	# Link the executable and exit
479653e90a53Smrg	$show "$link_command"
479753e90a53Smrg	$run eval "$link_command" || exit $?
479853e90a53Smrg	exit $EXIT_SUCCESS
479953e90a53Smrg      fi
480053e90a53Smrg
480153e90a53Smrg      if test "$hardcode_action" = relink; then
480253e90a53Smrg	# Fast installation is not supported
480353e90a53Smrg	link_command="$compile_var$compile_command$compile_rpath"
480453e90a53Smrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
480553e90a53Smrg
480653e90a53Smrg	$echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2
480753e90a53Smrg	$echo "$modename: \`$output' will be relinked during installation" 1>&2
480853e90a53Smrg      else
480953e90a53Smrg	if test "$fast_install" != no; then
481053e90a53Smrg	  link_command="$finalize_var$compile_command$finalize_rpath"
481153e90a53Smrg	  if test "$fast_install" = yes; then
481253e90a53Smrg	    relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
481353e90a53Smrg	  else
481453e90a53Smrg	    # fast_install is set to needless
481553e90a53Smrg	    relink_command=
481653e90a53Smrg	  fi
481753e90a53Smrg	else
481853e90a53Smrg	  link_command="$compile_var$compile_command$compile_rpath"
481953e90a53Smrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
482053e90a53Smrg	fi
482153e90a53Smrg      fi
482253e90a53Smrg
482353e90a53Smrg      # Replace the output file specification.
482453e90a53Smrg      link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
482553e90a53Smrg
482653e90a53Smrg      # Delete the old output files.
482753e90a53Smrg      $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname
482853e90a53Smrg
482953e90a53Smrg      $show "$link_command"
483053e90a53Smrg      $run eval "$link_command" || exit $?
483153e90a53Smrg
483253e90a53Smrg      # Now create the wrapper script.
483353e90a53Smrg      $show "creating $output"
483453e90a53Smrg
483553e90a53Smrg      # Quote the relink command for shipping.
483653e90a53Smrg      if test -n "$relink_command"; then
483753e90a53Smrg	# Preserve any variables that may affect compiler behavior
483853e90a53Smrg	for var in $variables_saved_for_relink; do
483953e90a53Smrg	  if eval test -z \"\${$var+set}\"; then
484053e90a53Smrg	    relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
484153e90a53Smrg	  elif eval var_value=\$$var; test -z "$var_value"; then
484253e90a53Smrg	    relink_command="$var=; export $var; $relink_command"
484353e90a53Smrg	  else
484453e90a53Smrg	    var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
484553e90a53Smrg	    relink_command="$var=\"$var_value\"; export $var; $relink_command"
484653e90a53Smrg	  fi
484753e90a53Smrg	done
484853e90a53Smrg	relink_command="(cd `pwd`; $relink_command)"
484953e90a53Smrg	relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
485053e90a53Smrg      fi
485153e90a53Smrg
485253e90a53Smrg      # Quote $echo for shipping.
485353e90a53Smrg      if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then
485453e90a53Smrg	case $progpath in
485553e90a53Smrg	[\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
485653e90a53Smrg	*) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
485753e90a53Smrg	esac
485853e90a53Smrg	qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"`
485953e90a53Smrg      else
486053e90a53Smrg	qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"`
486153e90a53Smrg      fi
486253e90a53Smrg
486353e90a53Smrg      # Only actually do things if our run command is non-null.
486453e90a53Smrg      if test -z "$run"; then
486553e90a53Smrg	# win32 will think the script is a binary if it has
486653e90a53Smrg	# a .exe suffix, so we strip it off here.
486753e90a53Smrg	case $output in
486853e90a53Smrg	  *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;;
486953e90a53Smrg	esac
487053e90a53Smrg	# test for cygwin because mv fails w/o .exe extensions
487153e90a53Smrg	case $host in
487253e90a53Smrg	  *cygwin*)
487353e90a53Smrg	    exeext=.exe
487453e90a53Smrg	    outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;;
487553e90a53Smrg	  *) exeext= ;;
487653e90a53Smrg	esac
487753e90a53Smrg	case $host in
487853e90a53Smrg	  *cygwin* | *mingw* )
487953e90a53Smrg            output_name=`basename $output`
488053e90a53Smrg            output_path=`dirname $output`
488153e90a53Smrg            cwrappersource="$output_path/$objdir/lt-$output_name.c"
488253e90a53Smrg            cwrapper="$output_path/$output_name.exe"
488353e90a53Smrg            $rm $cwrappersource $cwrapper
488453e90a53Smrg            trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
488553e90a53Smrg
488653e90a53Smrg	    cat > $cwrappersource <<EOF
488753e90a53Smrg
488853e90a53Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
488953e90a53Smrg   Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
489053e90a53Smrg
489153e90a53Smrg   The $output program cannot be directly executed until all the libtool
489253e90a53Smrg   libraries that it depends on are installed.
489353e90a53Smrg
489453e90a53Smrg   This wrapper executable should never be moved out of the build directory.
489553e90a53Smrg   If it is, it will not operate correctly.
489653e90a53Smrg
489753e90a53Smrg   Currently, it simply execs the wrapper *script* "/bin/sh $output",
489853e90a53Smrg   but could eventually absorb all of the scripts functionality and
489953e90a53Smrg   exec $objdir/$outputname directly.
490053e90a53Smrg*/
490153e90a53SmrgEOF
490253e90a53Smrg	    cat >> $cwrappersource<<"EOF"
490353e90a53Smrg#include <stdio.h>
490453e90a53Smrg#include <stdlib.h>
490553e90a53Smrg#include <unistd.h>
490653e90a53Smrg#include <malloc.h>
490753e90a53Smrg#include <stdarg.h>
490853e90a53Smrg#include <assert.h>
490953e90a53Smrg#include <string.h>
491053e90a53Smrg#include <ctype.h>
491153e90a53Smrg#include <sys/stat.h>
491253e90a53Smrg
491353e90a53Smrg#if defined(PATH_MAX)
491453e90a53Smrg# define LT_PATHMAX PATH_MAX
491553e90a53Smrg#elif defined(MAXPATHLEN)
491653e90a53Smrg# define LT_PATHMAX MAXPATHLEN
491753e90a53Smrg#else
491853e90a53Smrg# define LT_PATHMAX 1024
491953e90a53Smrg#endif
492053e90a53Smrg
492153e90a53Smrg#ifndef DIR_SEPARATOR
492253e90a53Smrg# define DIR_SEPARATOR '/'
492353e90a53Smrg# define PATH_SEPARATOR ':'
492453e90a53Smrg#endif
492553e90a53Smrg
492653e90a53Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
492753e90a53Smrg  defined (__OS2__)
492853e90a53Smrg# define HAVE_DOS_BASED_FILE_SYSTEM
492953e90a53Smrg# ifndef DIR_SEPARATOR_2
493053e90a53Smrg#  define DIR_SEPARATOR_2 '\\'
493153e90a53Smrg# endif
493253e90a53Smrg# ifndef PATH_SEPARATOR_2
493353e90a53Smrg#  define PATH_SEPARATOR_2 ';'
493453e90a53Smrg# endif
493553e90a53Smrg#endif
493653e90a53Smrg
493753e90a53Smrg#ifndef DIR_SEPARATOR_2
493853e90a53Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
493953e90a53Smrg#else /* DIR_SEPARATOR_2 */
494053e90a53Smrg# define IS_DIR_SEPARATOR(ch) \
494153e90a53Smrg        (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
494253e90a53Smrg#endif /* DIR_SEPARATOR_2 */
494353e90a53Smrg
494453e90a53Smrg#ifndef PATH_SEPARATOR_2
494553e90a53Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
494653e90a53Smrg#else /* PATH_SEPARATOR_2 */
494753e90a53Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
494853e90a53Smrg#endif /* PATH_SEPARATOR_2 */
494953e90a53Smrg
495053e90a53Smrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
495153e90a53Smrg#define XFREE(stale) do { \
495253e90a53Smrg  if (stale) { free ((void *) stale); stale = 0; } \
495353e90a53Smrg} while (0)
495453e90a53Smrg
495553e90a53Smrg/* -DDEBUG is fairly common in CFLAGS.  */
495653e90a53Smrg#undef DEBUG
495753e90a53Smrg#if defined DEBUGWRAPPER
495853e90a53Smrg# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
495953e90a53Smrg#else
496053e90a53Smrg# define DEBUG(format, ...)
496153e90a53Smrg#endif
496253e90a53Smrg
496353e90a53Smrgconst char *program_name = NULL;
496453e90a53Smrg
496553e90a53Smrgvoid * xmalloc (size_t num);
496653e90a53Smrgchar * xstrdup (const char *string);
496753e90a53Smrgconst char * base_name (const char *name);
496853e90a53Smrgchar * find_executable(const char *wrapper);
496953e90a53Smrgint    check_executable(const char *path);
497053e90a53Smrgchar * strendzap(char *str, const char *pat);
497153e90a53Smrgvoid lt_fatal (const char *message, ...);
497253e90a53Smrg
497353e90a53Smrgint
497453e90a53Smrgmain (int argc, char *argv[])
497553e90a53Smrg{
497653e90a53Smrg  char **newargz;
497753e90a53Smrg  int i;
497853e90a53Smrg
497953e90a53Smrg  program_name = (char *) xstrdup (base_name (argv[0]));
498053e90a53Smrg  DEBUG("(main) argv[0]      : %s\n",argv[0]);
498153e90a53Smrg  DEBUG("(main) program_name : %s\n",program_name);
498253e90a53Smrg  newargz = XMALLOC(char *, argc+2);
498353e90a53SmrgEOF
498453e90a53Smrg
498553e90a53Smrg            cat >> $cwrappersource <<EOF
498653e90a53Smrg  newargz[0] = (char *) xstrdup("$SHELL");
498753e90a53SmrgEOF
498853e90a53Smrg
498953e90a53Smrg            cat >> $cwrappersource <<"EOF"
499053e90a53Smrg  newargz[1] = find_executable(argv[0]);
499153e90a53Smrg  if (newargz[1] == NULL)
499253e90a53Smrg    lt_fatal("Couldn't find %s", argv[0]);
499353e90a53Smrg  DEBUG("(main) found exe at : %s\n",newargz[1]);
499453e90a53Smrg  /* we know the script has the same name, without the .exe */
499553e90a53Smrg  /* so make sure newargz[1] doesn't end in .exe */
499653e90a53Smrg  strendzap(newargz[1],".exe");
499753e90a53Smrg  for (i = 1; i < argc; i++)
499853e90a53Smrg    newargz[i+1] = xstrdup(argv[i]);
499953e90a53Smrg  newargz[argc+1] = NULL;
500053e90a53Smrg
500153e90a53Smrg  for (i=0; i<argc+1; i++)
500253e90a53Smrg  {
500353e90a53Smrg    DEBUG("(main) newargz[%d]   : %s\n",i,newargz[i]);
500453e90a53Smrg    ;
500553e90a53Smrg  }
500653e90a53Smrg
500753e90a53SmrgEOF
500853e90a53Smrg
500953e90a53Smrg            case $host_os in
501053e90a53Smrg              mingw*)
501153e90a53Smrg                cat >> $cwrappersource <<EOF
501253e90a53Smrg  execv("$SHELL",(char const **)newargz);
501353e90a53SmrgEOF
501453e90a53Smrg              ;;
501553e90a53Smrg              *)
501653e90a53Smrg                cat >> $cwrappersource <<EOF
501753e90a53Smrg  execv("$SHELL",newargz);
501853e90a53SmrgEOF
501953e90a53Smrg              ;;
502053e90a53Smrg            esac
502153e90a53Smrg
502253e90a53Smrg            cat >> $cwrappersource <<"EOF"
502353e90a53Smrg  return 127;
502453e90a53Smrg}
502553e90a53Smrg
502653e90a53Smrgvoid *
502753e90a53Smrgxmalloc (size_t num)
502853e90a53Smrg{
502953e90a53Smrg  void * p = (void *) malloc (num);
503053e90a53Smrg  if (!p)
503153e90a53Smrg    lt_fatal ("Memory exhausted");
503253e90a53Smrg
503353e90a53Smrg  return p;
503453e90a53Smrg}
503553e90a53Smrg
503653e90a53Smrgchar *
503753e90a53Smrgxstrdup (const char *string)
503853e90a53Smrg{
503953e90a53Smrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL
504053e90a53Smrg;
504153e90a53Smrg}
504253e90a53Smrg
504353e90a53Smrgconst char *
504453e90a53Smrgbase_name (const char *name)
504553e90a53Smrg{
504653e90a53Smrg  const char *base;
504753e90a53Smrg
504853e90a53Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
504953e90a53Smrg  /* Skip over the disk name in MSDOS pathnames. */
505053e90a53Smrg  if (isalpha ((unsigned char)name[0]) && name[1] == ':')
505153e90a53Smrg    name += 2;
505253e90a53Smrg#endif
505353e90a53Smrg
505453e90a53Smrg  for (base = name; *name; name++)
505553e90a53Smrg    if (IS_DIR_SEPARATOR (*name))
505653e90a53Smrg      base = name + 1;
505753e90a53Smrg  return base;
505853e90a53Smrg}
505953e90a53Smrg
506053e90a53Smrgint
506153e90a53Smrgcheck_executable(const char * path)
506253e90a53Smrg{
506353e90a53Smrg  struct stat st;
506453e90a53Smrg
506553e90a53Smrg  DEBUG("(check_executable)  : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!");
506653e90a53Smrg  if ((!path) || (!*path))
506753e90a53Smrg    return 0;
506853e90a53Smrg
506953e90a53Smrg  if ((stat (path, &st) >= 0) &&
507053e90a53Smrg      (
507153e90a53Smrg        /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */
507253e90a53Smrg#if defined (S_IXOTH)
507353e90a53Smrg       ((st.st_mode & S_IXOTH) == S_IXOTH) ||
507453e90a53Smrg#endif
507553e90a53Smrg#if defined (S_IXGRP)
507653e90a53Smrg       ((st.st_mode & S_IXGRP) == S_IXGRP) ||
507753e90a53Smrg#endif
507853e90a53Smrg       ((st.st_mode & S_IXUSR) == S_IXUSR))
507953e90a53Smrg      )
508053e90a53Smrg    return 1;
508153e90a53Smrg  else
508253e90a53Smrg    return 0;
508353e90a53Smrg}
508453e90a53Smrg
508553e90a53Smrg/* Searches for the full path of the wrapper.  Returns
508653e90a53Smrg   newly allocated full path name if found, NULL otherwise */
508753e90a53Smrgchar *
508853e90a53Smrgfind_executable (const char* wrapper)
508953e90a53Smrg{
509053e90a53Smrg  int has_slash = 0;
509153e90a53Smrg  const char* p;
509253e90a53Smrg  const char* p_next;
509353e90a53Smrg  /* static buffer for getcwd */
509453e90a53Smrg  char tmp[LT_PATHMAX + 1];
509553e90a53Smrg  int tmp_len;
509653e90a53Smrg  char* concat_name;
509753e90a53Smrg
509853e90a53Smrg  DEBUG("(find_executable)  : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!");
509953e90a53Smrg
510053e90a53Smrg  if ((wrapper == NULL) || (*wrapper == '\0'))
510153e90a53Smrg    return NULL;
510253e90a53Smrg
510353e90a53Smrg  /* Absolute path? */
510453e90a53Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
510553e90a53Smrg  if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':')
510653e90a53Smrg  {
510753e90a53Smrg    concat_name = xstrdup (wrapper);
510853e90a53Smrg    if (check_executable(concat_name))
510953e90a53Smrg      return concat_name;
511053e90a53Smrg    XFREE(concat_name);
511153e90a53Smrg  }
511253e90a53Smrg  else
511353e90a53Smrg  {
511453e90a53Smrg#endif
511553e90a53Smrg    if (IS_DIR_SEPARATOR (wrapper[0]))
511653e90a53Smrg    {
511753e90a53Smrg      concat_name = xstrdup (wrapper);
511853e90a53Smrg      if (check_executable(concat_name))
511953e90a53Smrg        return concat_name;
512053e90a53Smrg      XFREE(concat_name);
512153e90a53Smrg    }
512253e90a53Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
512353e90a53Smrg  }
512453e90a53Smrg#endif
512553e90a53Smrg
512653e90a53Smrg  for (p = wrapper; *p; p++)
512753e90a53Smrg    if (*p == '/')
512853e90a53Smrg    {
512953e90a53Smrg      has_slash = 1;
513053e90a53Smrg      break;
513153e90a53Smrg    }
513253e90a53Smrg  if (!has_slash)
513353e90a53Smrg  {
513453e90a53Smrg    /* no slashes; search PATH */
513553e90a53Smrg    const char* path = getenv ("PATH");
513653e90a53Smrg    if (path != NULL)
513753e90a53Smrg    {
513853e90a53Smrg      for (p = path; *p; p = p_next)
513953e90a53Smrg      {
514053e90a53Smrg        const char* q;
514153e90a53Smrg        size_t p_len;
514253e90a53Smrg        for (q = p; *q; q++)
514353e90a53Smrg          if (IS_PATH_SEPARATOR(*q))
514453e90a53Smrg            break;
514553e90a53Smrg        p_len = q - p;
514653e90a53Smrg        p_next = (*q == '\0' ? q : q + 1);
514753e90a53Smrg        if (p_len == 0)
514853e90a53Smrg        {
514953e90a53Smrg          /* empty path: current directory */
515053e90a53Smrg          if (getcwd (tmp, LT_PATHMAX) == NULL)
515153e90a53Smrg            lt_fatal ("getcwd failed");
515253e90a53Smrg          tmp_len = strlen(tmp);
515353e90a53Smrg          concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
515453e90a53Smrg          memcpy (concat_name, tmp, tmp_len);
515553e90a53Smrg          concat_name[tmp_len] = '/';
515653e90a53Smrg          strcpy (concat_name + tmp_len + 1, wrapper);
515753e90a53Smrg        }
515853e90a53Smrg        else
515953e90a53Smrg        {
516053e90a53Smrg          concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1);
516153e90a53Smrg          memcpy (concat_name, p, p_len);
516253e90a53Smrg          concat_name[p_len] = '/';
516353e90a53Smrg          strcpy (concat_name + p_len + 1, wrapper);
516453e90a53Smrg        }
516553e90a53Smrg        if (check_executable(concat_name))
516653e90a53Smrg          return concat_name;
516753e90a53Smrg        XFREE(concat_name);
516853e90a53Smrg      }
516953e90a53Smrg    }
517053e90a53Smrg    /* not found in PATH; assume curdir */
517153e90a53Smrg  }
517253e90a53Smrg  /* Relative path | not found in path: prepend cwd */
517353e90a53Smrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
517453e90a53Smrg    lt_fatal ("getcwd failed");
517553e90a53Smrg  tmp_len = strlen(tmp);
517653e90a53Smrg  concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
517753e90a53Smrg  memcpy (concat_name, tmp, tmp_len);
517853e90a53Smrg  concat_name[tmp_len] = '/';
517953e90a53Smrg  strcpy (concat_name + tmp_len + 1, wrapper);
518053e90a53Smrg
518153e90a53Smrg  if (check_executable(concat_name))
518253e90a53Smrg    return concat_name;
518353e90a53Smrg  XFREE(concat_name);
518453e90a53Smrg  return NULL;
518553e90a53Smrg}
518653e90a53Smrg
518753e90a53Smrgchar *
518853e90a53Smrgstrendzap(char *str, const char *pat)
518953e90a53Smrg{
519053e90a53Smrg  size_t len, patlen;
519153e90a53Smrg
519253e90a53Smrg  assert(str != NULL);
519353e90a53Smrg  assert(pat != NULL);
519453e90a53Smrg
519553e90a53Smrg  len = strlen(str);
519653e90a53Smrg  patlen = strlen(pat);
519753e90a53Smrg
519853e90a53Smrg  if (patlen <= len)
519953e90a53Smrg  {
520053e90a53Smrg    str += len - patlen;
520153e90a53Smrg    if (strcmp(str, pat) == 0)
520253e90a53Smrg      *str = '\0';
520353e90a53Smrg  }
520453e90a53Smrg  return str;
520553e90a53Smrg}
520653e90a53Smrg
520753e90a53Smrgstatic void
520853e90a53Smrglt_error_core (int exit_status, const char * mode,
520953e90a53Smrg          const char * message, va_list ap)
521053e90a53Smrg{
521153e90a53Smrg  fprintf (stderr, "%s: %s: ", program_name, mode);
521253e90a53Smrg  vfprintf (stderr, message, ap);
521353e90a53Smrg  fprintf (stderr, ".\n");
521453e90a53Smrg
521553e90a53Smrg  if (exit_status >= 0)
521653e90a53Smrg    exit (exit_status);
521753e90a53Smrg}
521853e90a53Smrg
521953e90a53Smrgvoid
522053e90a53Smrglt_fatal (const char *message, ...)
522153e90a53Smrg{
522253e90a53Smrg  va_list ap;
522353e90a53Smrg  va_start (ap, message);
522453e90a53Smrg  lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
522553e90a53Smrg  va_end (ap);
522653e90a53Smrg}
522753e90a53SmrgEOF
522853e90a53Smrg          # we should really use a build-platform specific compiler
522953e90a53Smrg          # here, but OTOH, the wrappers (shell script and this C one)
523053e90a53Smrg          # are only useful if you want to execute the "real" binary.
523153e90a53Smrg          # Since the "real" binary is built for $host, then this
523253e90a53Smrg          # wrapper might as well be built for $host, too.
523353e90a53Smrg          $run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource
523453e90a53Smrg          ;;
523553e90a53Smrg        esac
523653e90a53Smrg        $rm $output
523753e90a53Smrg        trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
523853e90a53Smrg
523953e90a53Smrg	$echo > $output "\
524053e90a53Smrg#! $SHELL
524153e90a53Smrg
524253e90a53Smrg# $output - temporary wrapper script for $objdir/$outputname
524353e90a53Smrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
524453e90a53Smrg#
524553e90a53Smrg# The $output program cannot be directly executed until all the libtool
524653e90a53Smrg# libraries that it depends on are installed.
524753e90a53Smrg#
524853e90a53Smrg# This wrapper script should never be moved out of the build directory.
524953e90a53Smrg# If it is, it will not operate correctly.
525053e90a53Smrg
525153e90a53Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
525253e90a53Smrg# metacharacters that are still active within double-quoted strings.
525353e90a53SmrgXsed='${SED} -e 1s/^X//'
525453e90a53Smrgsed_quote_subst='$sed_quote_subst'
525553e90a53Smrg
525653e90a53Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout
525753e90a53Smrg# if CDPATH is set.
525853e90a53Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
525953e90a53Smrg
526053e90a53Smrgrelink_command=\"$relink_command\"
526153e90a53Smrg
526253e90a53Smrg# This environment variable determines our operation mode.
526353e90a53Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then
526453e90a53Smrg  # install mode needs the following variable:
526553e90a53Smrg  notinst_deplibs='$notinst_deplibs'
526653e90a53Smrgelse
526753e90a53Smrg  # When we are sourced in execute mode, \$file and \$echo are already set.
526853e90a53Smrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
526953e90a53Smrg    echo=\"$qecho\"
527053e90a53Smrg    file=\"\$0\"
527153e90a53Smrg    # Make sure echo works.
527253e90a53Smrg    if test \"X\$1\" = X--no-reexec; then
527353e90a53Smrg      # Discard the --no-reexec flag, and continue.
527453e90a53Smrg      shift
527553e90a53Smrg    elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then
527653e90a53Smrg      # Yippee, \$echo works!
527753e90a53Smrg      :
527853e90a53Smrg    else
527953e90a53Smrg      # Restart under the correct shell, and then maybe \$echo will work.
528053e90a53Smrg      exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
528153e90a53Smrg    fi
528253e90a53Smrg  fi\
528353e90a53Smrg"
528453e90a53Smrg	$echo >> $output "\
528553e90a53Smrg
528653e90a53Smrg  # Find the directory that this script lives in.
528753e90a53Smrg  thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
528853e90a53Smrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
528953e90a53Smrg
529053e90a53Smrg  # Follow symbolic links until we get to the real thisdir.
529153e90a53Smrg  file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
529253e90a53Smrg  while test -n \"\$file\"; do
529353e90a53Smrg    destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
529453e90a53Smrg
529553e90a53Smrg    # If there was a directory component, then change thisdir.
529653e90a53Smrg    if test \"x\$destdir\" != \"x\$file\"; then
529753e90a53Smrg      case \"\$destdir\" in
529853e90a53Smrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
529953e90a53Smrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
530053e90a53Smrg      esac
530153e90a53Smrg    fi
530253e90a53Smrg
530353e90a53Smrg    file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
530453e90a53Smrg    file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
530553e90a53Smrg  done
530653e90a53Smrg
530753e90a53Smrg  # Try to get the absolute directory name.
530853e90a53Smrg  absdir=\`cd \"\$thisdir\" && pwd\`
530953e90a53Smrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
531053e90a53Smrg"
531153e90a53Smrg
531253e90a53Smrg	if test "$fast_install" = yes; then
531353e90a53Smrg	  $echo >> $output "\
531453e90a53Smrg  program=lt-'$outputname'$exeext
531553e90a53Smrg  progdir=\"\$thisdir/$objdir\"
531653e90a53Smrg
531753e90a53Smrg  if test ! -f \"\$progdir/\$program\" || \\
531853e90a53Smrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
531953e90a53Smrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
532053e90a53Smrg
532153e90a53Smrg    file=\"\$\$-\$program\"
532253e90a53Smrg
532353e90a53Smrg    if test ! -d \"\$progdir\"; then
532453e90a53Smrg      $mkdir \"\$progdir\"
532553e90a53Smrg    else
532653e90a53Smrg      $rm \"\$progdir/\$file\"
532753e90a53Smrg    fi"
532853e90a53Smrg
532953e90a53Smrg	  $echo >> $output "\
533053e90a53Smrg
533153e90a53Smrg    # relink executable if necessary
533253e90a53Smrg    if test -n \"\$relink_command\"; then
533353e90a53Smrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
533453e90a53Smrg      else
533553e90a53Smrg	$echo \"\$relink_command_output\" >&2
533653e90a53Smrg	$rm \"\$progdir/\$file\"
533753e90a53Smrg	exit $EXIT_FAILURE
533853e90a53Smrg      fi
533953e90a53Smrg    fi
534053e90a53Smrg
534153e90a53Smrg    $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
534253e90a53Smrg    { $rm \"\$progdir/\$program\";
534353e90a53Smrg      $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
534453e90a53Smrg    $rm \"\$progdir/\$file\"
534553e90a53Smrg  fi"
534653e90a53Smrg	else
534753e90a53Smrg	  $echo >> $output "\
534853e90a53Smrg  program='$outputname'
534953e90a53Smrg  progdir=\"\$thisdir/$objdir\"
535053e90a53Smrg"
535153e90a53Smrg	fi
535253e90a53Smrg
535353e90a53Smrg	$echo >> $output "\
535453e90a53Smrg
535553e90a53Smrg  if test -f \"\$progdir/\$program\"; then"
535653e90a53Smrg
535753e90a53Smrg	# Export our shlibpath_var if we have one.
535853e90a53Smrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
535953e90a53Smrg	  $echo >> $output "\
536053e90a53Smrg    # Add our own library path to $shlibpath_var
536153e90a53Smrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
536253e90a53Smrg
536353e90a53Smrg    # Some systems cannot cope with colon-terminated $shlibpath_var
536453e90a53Smrg    # The second colon is a workaround for a bug in BeOS R4 sed
536553e90a53Smrg    $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
536653e90a53Smrg
536753e90a53Smrg    export $shlibpath_var
536853e90a53Smrg"
536953e90a53Smrg	fi
537053e90a53Smrg
537153e90a53Smrg	# fixup the dll searchpath if we need to.
537253e90a53Smrg	if test -n "$dllsearchpath"; then
537353e90a53Smrg	  $echo >> $output "\
537453e90a53Smrg    # Add the dll search path components to the executable PATH
537553e90a53Smrg    PATH=$dllsearchpath:\$PATH
537653e90a53Smrg"
537753e90a53Smrg	fi
537853e90a53Smrg
537953e90a53Smrg	$echo >> $output "\
538053e90a53Smrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
538153e90a53Smrg      # Run the actual program with our arguments.
538253e90a53Smrg"
538353e90a53Smrg	case $host in
538453e90a53Smrg	# Backslashes separate directories on plain windows
538553e90a53Smrg	*-*-mingw | *-*-os2*)
538653e90a53Smrg	  $echo >> $output "\
538753e90a53Smrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
538853e90a53Smrg"
538953e90a53Smrg	  ;;
539053e90a53Smrg
539153e90a53Smrg	*)
539253e90a53Smrg	  $echo >> $output "\
539353e90a53Smrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
539453e90a53Smrg"
539553e90a53Smrg	  ;;
539653e90a53Smrg	esac
539753e90a53Smrg	$echo >> $output "\
539853e90a53Smrg      \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\"
539953e90a53Smrg      exit $EXIT_FAILURE
540053e90a53Smrg    fi
540153e90a53Smrg  else
540253e90a53Smrg    # The program doesn't exist.
540353e90a53Smrg    \$echo \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
540453e90a53Smrg    \$echo \"This script is just a wrapper for \$program.\" 1>&2
540553e90a53Smrg    $echo \"See the $PACKAGE documentation for more information.\" 1>&2
540653e90a53Smrg    exit $EXIT_FAILURE
540753e90a53Smrg  fi
540853e90a53Smrgfi\
540953e90a53Smrg"
541053e90a53Smrg	chmod +x $output
541153e90a53Smrg      fi
541253e90a53Smrg      exit $EXIT_SUCCESS
541353e90a53Smrg      ;;
541453e90a53Smrg    esac
541553e90a53Smrg
541653e90a53Smrg    # See if we need to build an old-fashioned archive.
541753e90a53Smrg    for oldlib in $oldlibs; do
541853e90a53Smrg
541953e90a53Smrg      if test "$build_libtool_libs" = convenience; then
542053e90a53Smrg	oldobjs="$libobjs_save"
542153e90a53Smrg	addlibs="$convenience"
542253e90a53Smrg	build_libtool_libs=no
542353e90a53Smrg      else
542453e90a53Smrg	if test "$build_libtool_libs" = module; then
542553e90a53Smrg	  oldobjs="$libobjs_save"
542653e90a53Smrg	  build_libtool_libs=no
542753e90a53Smrg	else
542853e90a53Smrg	  oldobjs="$old_deplibs $non_pic_objects"
542953e90a53Smrg	fi
543053e90a53Smrg	addlibs="$old_convenience"
543153e90a53Smrg      fi
543253e90a53Smrg
543353e90a53Smrg      if test -n "$addlibs"; then
543453e90a53Smrg	gentop="$output_objdir/${outputname}x"
543553e90a53Smrg	generated="$generated $gentop"
543653e90a53Smrg
543753e90a53Smrg	func_extract_archives $gentop $addlibs
543853e90a53Smrg	oldobjs="$oldobjs $func_extract_archives_result"
543953e90a53Smrg      fi
544053e90a53Smrg
544153e90a53Smrg      # Do each command in the archive commands.
544253e90a53Smrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
544353e90a53Smrg       cmds=$old_archive_from_new_cmds
544453e90a53Smrg      else
544553e90a53Smrg	# POSIX demands no paths to be encoded in archives.  We have
544653e90a53Smrg	# to avoid creating archives with duplicate basenames if we
544753e90a53Smrg	# might have to extract them afterwards, e.g., when creating a
544853e90a53Smrg	# static archive out of a convenience library, or when linking
544953e90a53Smrg	# the entirety of a libtool archive into another (currently
545053e90a53Smrg	# not supported by libtool).
545153e90a53Smrg	if (for obj in $oldobjs
545253e90a53Smrg	    do
545353e90a53Smrg	      $echo "X$obj" | $Xsed -e 's%^.*/%%'
545453e90a53Smrg	    done | sort | sort -uc >/dev/null 2>&1); then
545553e90a53Smrg	  :
545653e90a53Smrg	else
545753e90a53Smrg	  $echo "copying selected object files to avoid basename conflicts..."
545853e90a53Smrg
545953e90a53Smrg	  if test -z "$gentop"; then
546053e90a53Smrg	    gentop="$output_objdir/${outputname}x"
546153e90a53Smrg	    generated="$generated $gentop"
546253e90a53Smrg
546353e90a53Smrg	    $show "${rm}r $gentop"
546453e90a53Smrg	    $run ${rm}r "$gentop"
546553e90a53Smrg	    $show "$mkdir $gentop"
546653e90a53Smrg	    $run $mkdir "$gentop"
546753e90a53Smrg	    exit_status=$?
546853e90a53Smrg	    if test "$exit_status" -ne 0 && test ! -d "$gentop"; then
546953e90a53Smrg	      exit $exit_status
547053e90a53Smrg	    fi
547153e90a53Smrg	  fi
547253e90a53Smrg
547353e90a53Smrg	  save_oldobjs=$oldobjs
547453e90a53Smrg	  oldobjs=
547553e90a53Smrg	  counter=1
547653e90a53Smrg	  for obj in $save_oldobjs
547753e90a53Smrg	  do
547853e90a53Smrg	    objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
547953e90a53Smrg	    case " $oldobjs " in
548053e90a53Smrg	    " ") oldobjs=$obj ;;
548153e90a53Smrg	    *[\ /]"$objbase "*)
548253e90a53Smrg	      while :; do
548353e90a53Smrg		# Make sure we don't pick an alternate name that also
548453e90a53Smrg		# overlaps.
548553e90a53Smrg		newobj=lt$counter-$objbase
548653e90a53Smrg		counter=`expr $counter + 1`
548753e90a53Smrg		case " $oldobjs " in
548853e90a53Smrg		*[\ /]"$newobj "*) ;;
548953e90a53Smrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
549053e90a53Smrg		esac
549153e90a53Smrg	      done
549253e90a53Smrg	      $show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
549353e90a53Smrg	      $run ln "$obj" "$gentop/$newobj" ||
549453e90a53Smrg	      $run cp "$obj" "$gentop/$newobj"
549553e90a53Smrg	      oldobjs="$oldobjs $gentop/$newobj"
549653e90a53Smrg	      ;;
549753e90a53Smrg	    *) oldobjs="$oldobjs $obj" ;;
549853e90a53Smrg	    esac
549953e90a53Smrg	  done
550053e90a53Smrg	fi
550153e90a53Smrg
550253e90a53Smrg	eval cmds=\"$old_archive_cmds\"
550353e90a53Smrg
550453e90a53Smrg	if len=`expr "X$cmds" : ".*"` &&
550553e90a53Smrg	     test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
550653e90a53Smrg	  cmds=$old_archive_cmds
550753e90a53Smrg	else
550853e90a53Smrg	  # the command line is too long to link in one step, link in parts
550953e90a53Smrg	  $echo "using piecewise archive linking..."
551053e90a53Smrg	  save_RANLIB=$RANLIB
551153e90a53Smrg	  RANLIB=:
551253e90a53Smrg	  objlist=
551353e90a53Smrg	  concat_cmds=
551453e90a53Smrg	  save_oldobjs=$oldobjs
551553e90a53Smrg
551653e90a53Smrg	  # Is there a better way of finding the last object in the list?
551753e90a53Smrg	  for obj in $save_oldobjs
551853e90a53Smrg	  do
551953e90a53Smrg	    last_oldobj=$obj
552053e90a53Smrg	  done
552153e90a53Smrg	  for obj in $save_oldobjs
552253e90a53Smrg	  do
552353e90a53Smrg	    oldobjs="$objlist $obj"
552453e90a53Smrg	    objlist="$objlist $obj"
552553e90a53Smrg	    eval test_cmds=\"$old_archive_cmds\"
552653e90a53Smrg	    if len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
552753e90a53Smrg	       test "$len" -le "$max_cmd_len"; then
552853e90a53Smrg	      :
552953e90a53Smrg	    else
553053e90a53Smrg	      # the above command should be used before it gets too long
553153e90a53Smrg	      oldobjs=$objlist
553253e90a53Smrg	      if test "$obj" = "$last_oldobj" ; then
553353e90a53Smrg	        RANLIB=$save_RANLIB
553453e90a53Smrg	      fi
553553e90a53Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
553653e90a53Smrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
553753e90a53Smrg	      objlist=
553853e90a53Smrg	    fi
553953e90a53Smrg	  done
554053e90a53Smrg	  RANLIB=$save_RANLIB
554153e90a53Smrg	  oldobjs=$objlist
554253e90a53Smrg	  if test "X$oldobjs" = "X" ; then
554353e90a53Smrg	    eval cmds=\"\$concat_cmds\"
554453e90a53Smrg	  else
554553e90a53Smrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
554653e90a53Smrg	  fi
554753e90a53Smrg	fi
554853e90a53Smrg      fi
554953e90a53Smrg      save_ifs="$IFS"; IFS='~'
555053e90a53Smrg      for cmd in $cmds; do
555153e90a53Smrg        eval cmd=\"$cmd\"
555253e90a53Smrg	IFS="$save_ifs"
555353e90a53Smrg	$show "$cmd"
555453e90a53Smrg	$run eval "$cmd" || exit $?
555553e90a53Smrg      done
555653e90a53Smrg      IFS="$save_ifs"
555753e90a53Smrg    done
555853e90a53Smrg
555953e90a53Smrg    if test -n "$generated"; then
556053e90a53Smrg      $show "${rm}r$generated"
556153e90a53Smrg      $run ${rm}r$generated
556253e90a53Smrg    fi
556353e90a53Smrg
556453e90a53Smrg    # Now create the libtool archive.
556553e90a53Smrg    case $output in
556653e90a53Smrg    *.la)
556753e90a53Smrg      old_library=
556853e90a53Smrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
556953e90a53Smrg      $show "creating $output"
557053e90a53Smrg
557153e90a53Smrg      # Preserve any variables that may affect compiler behavior
557253e90a53Smrg      for var in $variables_saved_for_relink; do
557353e90a53Smrg	if eval test -z \"\${$var+set}\"; then
557453e90a53Smrg	  relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
557553e90a53Smrg	elif eval var_value=\$$var; test -z "$var_value"; then
557653e90a53Smrg	  relink_command="$var=; export $var; $relink_command"
557753e90a53Smrg	else
557853e90a53Smrg	  var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
557953e90a53Smrg	  relink_command="$var=\"$var_value\"; export $var; $relink_command"
558053e90a53Smrg	fi
558153e90a53Smrg      done
558253e90a53Smrg      # Quote the link command for shipping.
558353e90a53Smrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
558453e90a53Smrg      relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
558553e90a53Smrg      if test "$hardcode_automatic" = yes ; then
558653e90a53Smrg	relink_command=
558753e90a53Smrg      fi
558853e90a53Smrg
558953e90a53Smrg
559053e90a53Smrg      # Only create the output if not a dry run.
559153e90a53Smrg      if test -z "$run"; then
559253e90a53Smrg	for installed in no yes; do
559353e90a53Smrg	  if test "$installed" = yes; then
559453e90a53Smrg	    if test -z "$install_libdir"; then
559553e90a53Smrg	      break
559653e90a53Smrg	    fi
559753e90a53Smrg	    output="$output_objdir/$outputname"i
559853e90a53Smrg	    # Replace all uninstalled libtool libraries with the installed ones
559953e90a53Smrg	    newdependency_libs=
560053e90a53Smrg	    for deplib in $dependency_libs; do
560153e90a53Smrg	      case $deplib in
560253e90a53Smrg	      *.la)
560353e90a53Smrg		name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'`
560453e90a53Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
560553e90a53Smrg		if test -z "$libdir"; then
560653e90a53Smrg		  $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
560753e90a53Smrg		  exit $EXIT_FAILURE
560853e90a53Smrg		fi
560953e90a53Smrg		newdependency_libs="$newdependency_libs $libdir/$name"
561053e90a53Smrg		;;
561153e90a53Smrg	      *) newdependency_libs="$newdependency_libs $deplib" ;;
561253e90a53Smrg	      esac
561353e90a53Smrg	    done
561453e90a53Smrg	    dependency_libs="$newdependency_libs"
561553e90a53Smrg	    newdlfiles=
561653e90a53Smrg	    for lib in $dlfiles; do
561753e90a53Smrg	      name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
561853e90a53Smrg	      eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
561953e90a53Smrg	      if test -z "$libdir"; then
562053e90a53Smrg		$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
562153e90a53Smrg		exit $EXIT_FAILURE
562253e90a53Smrg	      fi
562353e90a53Smrg	      newdlfiles="$newdlfiles $libdir/$name"
562453e90a53Smrg	    done
562553e90a53Smrg	    dlfiles="$newdlfiles"
562653e90a53Smrg	    newdlprefiles=
562753e90a53Smrg	    for lib in $dlprefiles; do
562853e90a53Smrg	      name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
562953e90a53Smrg	      eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
563053e90a53Smrg	      if test -z "$libdir"; then
563153e90a53Smrg		$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
563253e90a53Smrg		exit $EXIT_FAILURE
563353e90a53Smrg	      fi
563453e90a53Smrg	      newdlprefiles="$newdlprefiles $libdir/$name"
563553e90a53Smrg	    done
563653e90a53Smrg	    dlprefiles="$newdlprefiles"
563753e90a53Smrg	  else
563853e90a53Smrg	    newdlfiles=
563953e90a53Smrg	    for lib in $dlfiles; do
564053e90a53Smrg	      case $lib in
564153e90a53Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
564253e90a53Smrg		*) abs=`pwd`"/$lib" ;;
564353e90a53Smrg	      esac
564453e90a53Smrg	      newdlfiles="$newdlfiles $abs"
564553e90a53Smrg	    done
564653e90a53Smrg	    dlfiles="$newdlfiles"
564753e90a53Smrg	    newdlprefiles=
564853e90a53Smrg	    for lib in $dlprefiles; do
564953e90a53Smrg	      case $lib in
565053e90a53Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
565153e90a53Smrg		*) abs=`pwd`"/$lib" ;;
565253e90a53Smrg	      esac
565353e90a53Smrg	      newdlprefiles="$newdlprefiles $abs"
565453e90a53Smrg	    done
565553e90a53Smrg	    dlprefiles="$newdlprefiles"
565653e90a53Smrg	  fi
565753e90a53Smrg	  $rm $output
565853e90a53Smrg	  # place dlname in correct position for cygwin
565953e90a53Smrg	  tdlname=$dlname
566053e90a53Smrg	  case $host,$output,$installed,$module,$dlname in
566153e90a53Smrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
566253e90a53Smrg	  esac
566353e90a53Smrg	  $echo > $output "\
566453e90a53Smrg# $outputname - a libtool library file
566553e90a53Smrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
566653e90a53Smrg#
566753e90a53Smrg# Please DO NOT delete this file!
566853e90a53Smrg# It is necessary for linking the library.
566953e90a53Smrg
567053e90a53Smrg# The name that we can dlopen(3).
567153e90a53Smrgdlname='$tdlname'
567253e90a53Smrg
567353e90a53Smrg# Names of this library.
567453e90a53Smrglibrary_names='$library_names'
567553e90a53Smrg
567653e90a53Smrg# The name of the static archive.
567753e90a53Smrgold_library='$old_library'
567853e90a53Smrg
567953e90a53Smrg# Libraries that this one depends upon.
568053e90a53Smrgdependency_libs='$dependency_libs'
568153e90a53Smrg
568253e90a53Smrg# Version information for $libname.
568353e90a53Smrgcurrent=$current
568453e90a53Smrgage=$age
568553e90a53Smrgrevision=$revision
568653e90a53Smrg
568753e90a53Smrg# Is this an already installed library?
568853e90a53Smrginstalled=$installed
568953e90a53Smrg
569053e90a53Smrg# Should we warn about portability when linking against -modules?
569153e90a53Smrgshouldnotlink=$module
569253e90a53Smrg
569353e90a53Smrg# Files to dlopen/dlpreopen
569453e90a53Smrgdlopen='$dlfiles'
569553e90a53Smrgdlpreopen='$dlprefiles'
569653e90a53Smrg
569753e90a53Smrg# Directory that this library needs to be installed in:
569853e90a53Smrglibdir='$install_libdir'"
569953e90a53Smrg	  if test "$installed" = no && test "$need_relink" = yes; then
570053e90a53Smrg	    $echo >> $output "\
570153e90a53Smrgrelink_command=\"$relink_command\""
570253e90a53Smrg	  fi
570353e90a53Smrg	done
570453e90a53Smrg      fi
570553e90a53Smrg
570653e90a53Smrg      # Do a symbolic link so that the libtool archive can be found in
570753e90a53Smrg      # LD_LIBRARY_PATH before the program is installed.
570853e90a53Smrg      $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)"
570953e90a53Smrg      $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $?
571053e90a53Smrg      ;;
571153e90a53Smrg    esac
571253e90a53Smrg    exit $EXIT_SUCCESS
571353e90a53Smrg    ;;
571453e90a53Smrg
571553e90a53Smrg  # libtool install mode
571653e90a53Smrg  install)
571753e90a53Smrg    modename="$modename: install"
571853e90a53Smrg
571953e90a53Smrg    # There may be an optional sh(1) argument at the beginning of
572053e90a53Smrg    # install_prog (especially on Windows NT).
572153e90a53Smrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
572253e90a53Smrg       # Allow the use of GNU shtool's install command.
572353e90a53Smrg       $echo "X$nonopt" | grep shtool > /dev/null; then
572453e90a53Smrg      # Aesthetically quote it.
572553e90a53Smrg      arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"`
572653e90a53Smrg      case $arg in
572753e90a53Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
572853e90a53Smrg	arg="\"$arg\""
572953e90a53Smrg	;;
573053e90a53Smrg      esac
573153e90a53Smrg      install_prog="$arg "
573253e90a53Smrg      arg="$1"
573353e90a53Smrg      shift
573453e90a53Smrg    else
573553e90a53Smrg      install_prog=
573653e90a53Smrg      arg=$nonopt
573753e90a53Smrg    fi
573853e90a53Smrg
573953e90a53Smrg    # The real first argument should be the name of the installation program.
574053e90a53Smrg    # Aesthetically quote it.
574153e90a53Smrg    arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
574253e90a53Smrg    case $arg in
574353e90a53Smrg    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
574453e90a53Smrg      arg="\"$arg\""
574553e90a53Smrg      ;;
574653e90a53Smrg    esac
574753e90a53Smrg    install_prog="$install_prog$arg"
574853e90a53Smrg
574953e90a53Smrg    # We need to accept at least all the BSD install flags.
575053e90a53Smrg    dest=
575153e90a53Smrg    files=
575253e90a53Smrg    opts=
575353e90a53Smrg    prev=
575453e90a53Smrg    install_type=
575553e90a53Smrg    isdir=no
575653e90a53Smrg    stripme=
575753e90a53Smrg    for arg
575853e90a53Smrg    do
575953e90a53Smrg      if test -n "$dest"; then
576053e90a53Smrg	files="$files $dest"
576153e90a53Smrg	dest=$arg
576253e90a53Smrg	continue
576353e90a53Smrg      fi
576453e90a53Smrg
576553e90a53Smrg      case $arg in
576653e90a53Smrg      -d) isdir=yes ;;
576753e90a53Smrg      -f) 
576853e90a53Smrg      	case " $install_prog " in
576953e90a53Smrg	*[\\\ /]cp\ *) ;;
577053e90a53Smrg	*) prev=$arg ;;
577153e90a53Smrg	esac
577253e90a53Smrg	;;
577353e90a53Smrg      -g | -m | -o) prev=$arg ;;
577453e90a53Smrg      -s)
577553e90a53Smrg	stripme=" -s"
577653e90a53Smrg	continue
577753e90a53Smrg	;;
577853e90a53Smrg      -*)
577953e90a53Smrg	;;
578053e90a53Smrg      *)
578153e90a53Smrg	# If the previous option needed an argument, then skip it.
578253e90a53Smrg	if test -n "$prev"; then
578353e90a53Smrg	  prev=
578453e90a53Smrg	else
578553e90a53Smrg	  dest=$arg
578653e90a53Smrg	  continue
578753e90a53Smrg	fi
578853e90a53Smrg	;;
578953e90a53Smrg      esac
579053e90a53Smrg
579153e90a53Smrg      # Aesthetically quote the argument.
579253e90a53Smrg      arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
579353e90a53Smrg      case $arg in
579453e90a53Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
579553e90a53Smrg	arg="\"$arg\""
579653e90a53Smrg	;;
579753e90a53Smrg      esac
579853e90a53Smrg      install_prog="$install_prog $arg"
579953e90a53Smrg    done
580053e90a53Smrg
580153e90a53Smrg    if test -z "$install_prog"; then
580253e90a53Smrg      $echo "$modename: you must specify an install program" 1>&2
580353e90a53Smrg      $echo "$help" 1>&2
580453e90a53Smrg      exit $EXIT_FAILURE
580553e90a53Smrg    fi
580653e90a53Smrg
580753e90a53Smrg    if test -n "$prev"; then
580853e90a53Smrg      $echo "$modename: the \`$prev' option requires an argument" 1>&2
580953e90a53Smrg      $echo "$help" 1>&2
581053e90a53Smrg      exit $EXIT_FAILURE
581153e90a53Smrg    fi
581253e90a53Smrg
581353e90a53Smrg    if test -z "$files"; then
581453e90a53Smrg      if test -z "$dest"; then
581553e90a53Smrg	$echo "$modename: no file or destination specified" 1>&2
581653e90a53Smrg      else
581753e90a53Smrg	$echo "$modename: you must specify a destination" 1>&2
581853e90a53Smrg      fi
581953e90a53Smrg      $echo "$help" 1>&2
582053e90a53Smrg      exit $EXIT_FAILURE
582153e90a53Smrg    fi
582253e90a53Smrg
582353e90a53Smrg    # Strip any trailing slash from the destination.
582453e90a53Smrg    dest=`$echo "X$dest" | $Xsed -e 's%/$%%'`
582553e90a53Smrg
582653e90a53Smrg    # Check to see that the destination is a directory.
582753e90a53Smrg    test -d "$dest" && isdir=yes
582853e90a53Smrg    if test "$isdir" = yes; then
582953e90a53Smrg      destdir="$dest"
583053e90a53Smrg      destname=
583153e90a53Smrg    else
583253e90a53Smrg      destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'`
583353e90a53Smrg      test "X$destdir" = "X$dest" && destdir=.
583453e90a53Smrg      destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'`
583553e90a53Smrg
583653e90a53Smrg      # Not a directory, so check to see that there is only one file specified.
583753e90a53Smrg      set dummy $files
583853e90a53Smrg      if test "$#" -gt 2; then
583953e90a53Smrg	$echo "$modename: \`$dest' is not a directory" 1>&2
584053e90a53Smrg	$echo "$help" 1>&2
584153e90a53Smrg	exit $EXIT_FAILURE
584253e90a53Smrg      fi
584353e90a53Smrg    fi
584453e90a53Smrg    case $destdir in
584553e90a53Smrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
584653e90a53Smrg    *)
584753e90a53Smrg      for file in $files; do
584853e90a53Smrg	case $file in
584953e90a53Smrg	*.lo) ;;
585053e90a53Smrg	*)
585153e90a53Smrg	  $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2
585253e90a53Smrg	  $echo "$help" 1>&2
585353e90a53Smrg	  exit $EXIT_FAILURE
585453e90a53Smrg	  ;;
585553e90a53Smrg	esac
585653e90a53Smrg      done
585753e90a53Smrg      ;;
585853e90a53Smrg    esac
585953e90a53Smrg
586053e90a53Smrg    # This variable tells wrapper scripts just to set variables rather
586153e90a53Smrg    # than running their programs.
586253e90a53Smrg    libtool_install_magic="$magic"
586353e90a53Smrg
586453e90a53Smrg    staticlibs=
586553e90a53Smrg    future_libdirs=
586653e90a53Smrg    current_libdirs=
586753e90a53Smrg    for file in $files; do
586853e90a53Smrg
586953e90a53Smrg      # Do each installation.
587053e90a53Smrg      case $file in
587153e90a53Smrg      *.$libext)
587253e90a53Smrg	# Do the static libraries later.
587353e90a53Smrg	staticlibs="$staticlibs $file"
587453e90a53Smrg	;;
587553e90a53Smrg
587653e90a53Smrg      *.la)
587753e90a53Smrg	# Check to see that this really is a libtool archive.
587853e90a53Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
587953e90a53Smrg	else
588053e90a53Smrg	  $echo "$modename: \`$file' is not a valid libtool archive" 1>&2
588153e90a53Smrg	  $echo "$help" 1>&2
588253e90a53Smrg	  exit $EXIT_FAILURE
588353e90a53Smrg	fi
588453e90a53Smrg
588553e90a53Smrg	library_names=
588653e90a53Smrg	old_library=
588753e90a53Smrg	relink_command=
588853e90a53Smrg	# If there is no directory component, then add one.
588953e90a53Smrg	case $file in
589053e90a53Smrg	*/* | *\\*) . $file ;;
589153e90a53Smrg	*) . ./$file ;;
589253e90a53Smrg	esac
589353e90a53Smrg
589453e90a53Smrg	# Add the libdir to current_libdirs if it is the destination.
589553e90a53Smrg	if test "X$destdir" = "X$libdir"; then
589653e90a53Smrg	  case "$current_libdirs " in
589753e90a53Smrg	  *" $libdir "*) ;;
589853e90a53Smrg	  *) current_libdirs="$current_libdirs $libdir" ;;
589953e90a53Smrg	  esac
590053e90a53Smrg	else
590153e90a53Smrg	  # Note the libdir as a future libdir.
590253e90a53Smrg	  case "$future_libdirs " in
590353e90a53Smrg	  *" $libdir "*) ;;
590453e90a53Smrg	  *) future_libdirs="$future_libdirs $libdir" ;;
590553e90a53Smrg	  esac
590653e90a53Smrg	fi
590753e90a53Smrg
590853e90a53Smrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/
590953e90a53Smrg	test "X$dir" = "X$file/" && dir=
591053e90a53Smrg	dir="$dir$objdir"
591153e90a53Smrg
591253e90a53Smrg	if test -n "$relink_command"; then
591353e90a53Smrg	  # Determine the prefix the user has applied to our future dir.
591453e90a53Smrg	  inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"`
591553e90a53Smrg
591653e90a53Smrg	  # Don't allow the user to place us outside of our expected
591753e90a53Smrg	  # location b/c this prevents finding dependent libraries that
591853e90a53Smrg	  # are installed to the same prefix.
591953e90a53Smrg	  # At present, this check doesn't affect windows .dll's that
592053e90a53Smrg	  # are installed into $libdir/../bin (currently, that works fine)
592153e90a53Smrg	  # but it's something to keep an eye on.
592253e90a53Smrg	  if test "$inst_prefix_dir" = "$destdir"; then
592353e90a53Smrg	    $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2
592453e90a53Smrg	    exit $EXIT_FAILURE
592553e90a53Smrg	  fi
592653e90a53Smrg
592753e90a53Smrg	  if test -n "$inst_prefix_dir"; then
592853e90a53Smrg	    # Stick the inst_prefix_dir data into the link command.
592953e90a53Smrg	    relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
593053e90a53Smrg	  else
593153e90a53Smrg	    relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
593253e90a53Smrg	  fi
593353e90a53Smrg
593453e90a53Smrg	  $echo "$modename: warning: relinking \`$file'" 1>&2
593553e90a53Smrg	  $show "$relink_command"
593653e90a53Smrg	  if $run eval "$relink_command"; then :
593753e90a53Smrg	  else
593853e90a53Smrg	    $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
593953e90a53Smrg	    exit $EXIT_FAILURE
594053e90a53Smrg	  fi
594153e90a53Smrg	fi
594253e90a53Smrg
594353e90a53Smrg	# See the names of the shared library.
594453e90a53Smrg	set dummy $library_names
594553e90a53Smrg	if test -n "$2"; then
594653e90a53Smrg	  realname="$2"
594753e90a53Smrg	  shift
594853e90a53Smrg	  shift
594953e90a53Smrg
595053e90a53Smrg	  srcname="$realname"
595153e90a53Smrg	  test -n "$relink_command" && srcname="$realname"T
595253e90a53Smrg
595353e90a53Smrg	  # Install the shared library and build the symlinks.
595453e90a53Smrg	  $show "$install_prog $dir/$srcname $destdir/$realname"
595553e90a53Smrg	  $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $?
595653e90a53Smrg	  if test -n "$stripme" && test -n "$striplib"; then
595753e90a53Smrg	    $show "$striplib $destdir/$realname"
595853e90a53Smrg	    $run eval "$striplib $destdir/$realname" || exit $?
595953e90a53Smrg	  fi
596053e90a53Smrg
596153e90a53Smrg	  if test "$#" -gt 0; then
596253e90a53Smrg	    # Delete the old symlinks, and create new ones.
596353e90a53Smrg	    # Try `ln -sf' first, because the `ln' binary might depend on
596453e90a53Smrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
596553e90a53Smrg	    # so we also need to try rm && ln -s.
596653e90a53Smrg	    for linkname
596753e90a53Smrg	    do
596853e90a53Smrg	      if test "$linkname" != "$realname"; then
596953e90a53Smrg                $show "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
597053e90a53Smrg                $run eval "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
597153e90a53Smrg	      fi
597253e90a53Smrg	    done
597353e90a53Smrg	  fi
597453e90a53Smrg
597553e90a53Smrg	  # Do each command in the postinstall commands.
597653e90a53Smrg	  lib="$destdir/$realname"
597753e90a53Smrg	  cmds=$postinstall_cmds
597853e90a53Smrg	  save_ifs="$IFS"; IFS='~'
597953e90a53Smrg	  for cmd in $cmds; do
598053e90a53Smrg	    IFS="$save_ifs"
598153e90a53Smrg	    eval cmd=\"$cmd\"
598253e90a53Smrg	    $show "$cmd"
598353e90a53Smrg	    $run eval "$cmd" || {
598453e90a53Smrg	      lt_exit=$?
598553e90a53Smrg
598653e90a53Smrg	      # Restore the uninstalled library and exit
598753e90a53Smrg	      if test "$mode" = relink; then
598853e90a53Smrg		$run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
598953e90a53Smrg	      fi
599053e90a53Smrg
599153e90a53Smrg	      exit $lt_exit
599253e90a53Smrg	    }
599353e90a53Smrg	  done
599453e90a53Smrg	  IFS="$save_ifs"
599553e90a53Smrg	fi
599653e90a53Smrg
599753e90a53Smrg	# Install the pseudo-library for information purposes.
599853e90a53Smrg	name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
599953e90a53Smrg	instname="$dir/$name"i
600053e90a53Smrg	$show "$install_prog $instname $destdir/$name"
600153e90a53Smrg	$run eval "$install_prog $instname $destdir/$name" || exit $?
600253e90a53Smrg
600353e90a53Smrg	# Maybe install the static library, too.
600453e90a53Smrg	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
600553e90a53Smrg	;;
600653e90a53Smrg
600753e90a53Smrg      *.lo)
600853e90a53Smrg	# Install (i.e. copy) a libtool object.
600953e90a53Smrg
601053e90a53Smrg	# Figure out destination file name, if it wasn't already specified.
601153e90a53Smrg	if test -n "$destname"; then
601253e90a53Smrg	  destfile="$destdir/$destname"
601353e90a53Smrg	else
601453e90a53Smrg	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
601553e90a53Smrg	  destfile="$destdir/$destfile"
601653e90a53Smrg	fi
601753e90a53Smrg
601853e90a53Smrg	# Deduce the name of the destination old-style object file.
601953e90a53Smrg	case $destfile in
602053e90a53Smrg	*.lo)
602153e90a53Smrg	  staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"`
602253e90a53Smrg	  ;;
602353e90a53Smrg	*.$objext)
602453e90a53Smrg	  staticdest="$destfile"
602553e90a53Smrg	  destfile=
602653e90a53Smrg	  ;;
602753e90a53Smrg	*)
602853e90a53Smrg	  $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2
602953e90a53Smrg	  $echo "$help" 1>&2
603053e90a53Smrg	  exit $EXIT_FAILURE
603153e90a53Smrg	  ;;
603253e90a53Smrg	esac
603353e90a53Smrg
603453e90a53Smrg	# Install the libtool object if requested.
603553e90a53Smrg	if test -n "$destfile"; then
603653e90a53Smrg	  $show "$install_prog $file $destfile"
603753e90a53Smrg	  $run eval "$install_prog $file $destfile" || exit $?
603853e90a53Smrg	fi
603953e90a53Smrg
604053e90a53Smrg	# Install the old object if enabled.
604153e90a53Smrg	if test "$build_old_libs" = yes; then
604253e90a53Smrg	  # Deduce the name of the old-style object file.
604353e90a53Smrg	  staticobj=`$echo "X$file" | $Xsed -e "$lo2o"`
604453e90a53Smrg
604553e90a53Smrg	  $show "$install_prog $staticobj $staticdest"
604653e90a53Smrg	  $run eval "$install_prog \$staticobj \$staticdest" || exit $?
604753e90a53Smrg	fi
604853e90a53Smrg	exit $EXIT_SUCCESS
604953e90a53Smrg	;;
605053e90a53Smrg
605153e90a53Smrg      *)
605253e90a53Smrg	# Figure out destination file name, if it wasn't already specified.
605353e90a53Smrg	if test -n "$destname"; then
605453e90a53Smrg	  destfile="$destdir/$destname"
605553e90a53Smrg	else
605653e90a53Smrg	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
605753e90a53Smrg	  destfile="$destdir/$destfile"
605853e90a53Smrg	fi
605953e90a53Smrg
606053e90a53Smrg	# If the file is missing, and there is a .exe on the end, strip it
606153e90a53Smrg	# because it is most likely a libtool script we actually want to
606253e90a53Smrg	# install
606353e90a53Smrg	stripped_ext=""
606453e90a53Smrg	case $file in
606553e90a53Smrg	  *.exe)
606653e90a53Smrg	    if test ! -f "$file"; then
606753e90a53Smrg	      file=`$echo $file|${SED} 's,.exe$,,'`
606853e90a53Smrg	      stripped_ext=".exe"
606953e90a53Smrg	    fi
607053e90a53Smrg	    ;;
607153e90a53Smrg	esac
607253e90a53Smrg
607353e90a53Smrg	# Do a test to see if this is really a libtool program.
607453e90a53Smrg	case $host in
607553e90a53Smrg	*cygwin*|*mingw*)
607653e90a53Smrg	    wrapper=`$echo $file | ${SED} -e 's,.exe$,,'`
607753e90a53Smrg	    ;;
607853e90a53Smrg	*)
607953e90a53Smrg	    wrapper=$file
608053e90a53Smrg	    ;;
608153e90a53Smrg	esac
608253e90a53Smrg	if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then
608353e90a53Smrg	  notinst_deplibs=
608453e90a53Smrg	  relink_command=
608553e90a53Smrg
608653e90a53Smrg	  # Note that it is not necessary on cygwin/mingw to append a dot to
608753e90a53Smrg	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
608853e90a53Smrg	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
608953e90a53Smrg	  # `FILE.' does not work on cygwin managed mounts.
609053e90a53Smrg	  #
609153e90a53Smrg	  # If there is no directory component, then add one.
609253e90a53Smrg	  case $wrapper in
609353e90a53Smrg	  */* | *\\*) . ${wrapper} ;;
609453e90a53Smrg	  *) . ./${wrapper} ;;
609553e90a53Smrg	  esac
609653e90a53Smrg
609753e90a53Smrg	  # Check the variables that should have been set.
609853e90a53Smrg	  if test -z "$notinst_deplibs"; then
609953e90a53Smrg	    $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2
610053e90a53Smrg	    exit $EXIT_FAILURE
610153e90a53Smrg	  fi
610253e90a53Smrg
610353e90a53Smrg	  finalize=yes
610453e90a53Smrg	  for lib in $notinst_deplibs; do
610553e90a53Smrg	    # Check to see that each library is installed.
610653e90a53Smrg	    libdir=
610753e90a53Smrg	    if test -f "$lib"; then
610853e90a53Smrg	      # If there is no directory component, then add one.
610953e90a53Smrg	      case $lib in
611053e90a53Smrg	      */* | *\\*) . $lib ;;
611153e90a53Smrg	      *) . ./$lib ;;
611253e90a53Smrg	      esac
611353e90a53Smrg	    fi
611453e90a53Smrg	    libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
611553e90a53Smrg	    if test -n "$libdir" && test ! -f "$libfile"; then
611653e90a53Smrg	      $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2
611753e90a53Smrg	      finalize=no
611853e90a53Smrg	    fi
611953e90a53Smrg	  done
612053e90a53Smrg
612153e90a53Smrg	  relink_command=
612253e90a53Smrg	  # Note that it is not necessary on cygwin/mingw to append a dot to
612353e90a53Smrg	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
612453e90a53Smrg	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
612553e90a53Smrg	  # `FILE.' does not work on cygwin managed mounts.
612653e90a53Smrg	  #
612753e90a53Smrg	  # If there is no directory component, then add one.
612853e90a53Smrg	  case $wrapper in
612953e90a53Smrg	  */* | *\\*) . ${wrapper} ;;
613053e90a53Smrg	  *) . ./${wrapper} ;;
613153e90a53Smrg	  esac
613253e90a53Smrg
613353e90a53Smrg	  outputname=
613453e90a53Smrg	  if test "$fast_install" = no && test -n "$relink_command"; then
613553e90a53Smrg	    if test "$finalize" = yes && test -z "$run"; then
613653e90a53Smrg	      tmpdir=`func_mktempdir`
613753e90a53Smrg	      file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
613853e90a53Smrg	      outputname="$tmpdir/$file"
613953e90a53Smrg	      # Replace the output file specification.
614053e90a53Smrg	      relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
614153e90a53Smrg
614253e90a53Smrg	      $show "$relink_command"
614353e90a53Smrg	      if $run eval "$relink_command"; then :
614453e90a53Smrg	      else
614553e90a53Smrg		$echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
614653e90a53Smrg		${rm}r "$tmpdir"
614753e90a53Smrg		continue
614853e90a53Smrg	      fi
614953e90a53Smrg	      file="$outputname"
615053e90a53Smrg	    else
615153e90a53Smrg	      $echo "$modename: warning: cannot relink \`$file'" 1>&2
615253e90a53Smrg	    fi
615353e90a53Smrg	  else
615453e90a53Smrg	    # Install the binary that we compiled earlier.
615553e90a53Smrg	    file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
615653e90a53Smrg	  fi
615753e90a53Smrg	fi
615853e90a53Smrg
615953e90a53Smrg	# remove .exe since cygwin /usr/bin/install will append another
616053e90a53Smrg	# one anyway 
616153e90a53Smrg	case $install_prog,$host in
616253e90a53Smrg	*/usr/bin/install*,*cygwin*)
616353e90a53Smrg	  case $file:$destfile in
616453e90a53Smrg	  *.exe:*.exe)
616553e90a53Smrg	    # this is ok
616653e90a53Smrg	    ;;
616753e90a53Smrg	  *.exe:*)
616853e90a53Smrg	    destfile=$destfile.exe
616953e90a53Smrg	    ;;
617053e90a53Smrg	  *:*.exe)
617153e90a53Smrg	    destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'`
617253e90a53Smrg	    ;;
617353e90a53Smrg	  esac
617453e90a53Smrg	  ;;
617553e90a53Smrg	esac
617653e90a53Smrg	$show "$install_prog$stripme $file $destfile"
617753e90a53Smrg	$run eval "$install_prog\$stripme \$file \$destfile" || exit $?
617853e90a53Smrg	test -n "$outputname" && ${rm}r "$tmpdir"
617953e90a53Smrg	;;
618053e90a53Smrg      esac
618153e90a53Smrg    done
618253e90a53Smrg
618353e90a53Smrg    for file in $staticlibs; do
618453e90a53Smrg      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
618553e90a53Smrg
618653e90a53Smrg      # Set up the ranlib parameters.
618753e90a53Smrg      oldlib="$destdir/$name"
618853e90a53Smrg
618953e90a53Smrg      $show "$install_prog $file $oldlib"
619053e90a53Smrg      $run eval "$install_prog \$file \$oldlib" || exit $?
619153e90a53Smrg
619253e90a53Smrg      if test -n "$stripme" && test -n "$old_striplib"; then
619353e90a53Smrg	$show "$old_striplib $oldlib"
619453e90a53Smrg	$run eval "$old_striplib $oldlib" || exit $?
619553e90a53Smrg      fi
619653e90a53Smrg
619753e90a53Smrg      # Do each command in the postinstall commands.
619853e90a53Smrg      cmds=$old_postinstall_cmds
619953e90a53Smrg      save_ifs="$IFS"; IFS='~'
620053e90a53Smrg      for cmd in $cmds; do
620153e90a53Smrg	IFS="$save_ifs"
620253e90a53Smrg	eval cmd=\"$cmd\"
620353e90a53Smrg	$show "$cmd"
620453e90a53Smrg	$run eval "$cmd" || exit $?
620553e90a53Smrg      done
620653e90a53Smrg      IFS="$save_ifs"
620753e90a53Smrg    done
620853e90a53Smrg
620953e90a53Smrg    if test -n "$future_libdirs"; then
621053e90a53Smrg      $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2
621153e90a53Smrg    fi
621253e90a53Smrg
621353e90a53Smrg    if test -n "$current_libdirs"; then
621453e90a53Smrg      # Maybe just do a dry run.
621553e90a53Smrg      test -n "$run" && current_libdirs=" -n$current_libdirs"
621653e90a53Smrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
621753e90a53Smrg    else
621853e90a53Smrg      exit $EXIT_SUCCESS
621953e90a53Smrg    fi
622053e90a53Smrg    ;;
622153e90a53Smrg
622253e90a53Smrg  # libtool finish mode
622353e90a53Smrg  finish)
622453e90a53Smrg    modename="$modename: finish"
622553e90a53Smrg    libdirs="$nonopt"
622653e90a53Smrg    admincmds=
622753e90a53Smrg
622853e90a53Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
622953e90a53Smrg      for dir
623053e90a53Smrg      do
623153e90a53Smrg	libdirs="$libdirs $dir"
623253e90a53Smrg      done
623353e90a53Smrg
623453e90a53Smrg      for libdir in $libdirs; do
623553e90a53Smrg	if test -n "$finish_cmds"; then
623653e90a53Smrg	  # Do each command in the finish commands.
623753e90a53Smrg	  cmds=$finish_cmds
623853e90a53Smrg	  save_ifs="$IFS"; IFS='~'
623953e90a53Smrg	  for cmd in $cmds; do
624053e90a53Smrg	    IFS="$save_ifs"
624153e90a53Smrg	    eval cmd=\"$cmd\"
624253e90a53Smrg	    $show "$cmd"
624353e90a53Smrg	    $run eval "$cmd" || admincmds="$admincmds
624453e90a53Smrg       $cmd"
624553e90a53Smrg	  done
624653e90a53Smrg	  IFS="$save_ifs"
624753e90a53Smrg	fi
624853e90a53Smrg	if test -n "$finish_eval"; then
624953e90a53Smrg	  # Do the single finish_eval.
625053e90a53Smrg	  eval cmds=\"$finish_eval\"
625153e90a53Smrg	  $run eval "$cmds" || admincmds="$admincmds
625253e90a53Smrg       $cmds"
625353e90a53Smrg	fi
625453e90a53Smrg      done
625553e90a53Smrg    fi
625653e90a53Smrg
625753e90a53Smrg    # Exit here if they wanted silent mode.
625853e90a53Smrg    test "$show" = : && exit $EXIT_SUCCESS
625953e90a53Smrg
626053e90a53Smrg    $echo "X----------------------------------------------------------------------" | $Xsed
626153e90a53Smrg    $echo "Libraries have been installed in:"
626253e90a53Smrg    for libdir in $libdirs; do
626353e90a53Smrg      $echo "   $libdir"
626453e90a53Smrg    done
626553e90a53Smrg    $echo
626653e90a53Smrg    $echo "If you ever happen to want to link against installed libraries"
626753e90a53Smrg    $echo "in a given directory, LIBDIR, you must either use libtool, and"
626853e90a53Smrg    $echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
626953e90a53Smrg    $echo "flag during linking and do at least one of the following:"
627053e90a53Smrg    if test -n "$shlibpath_var"; then
627153e90a53Smrg      $echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
627253e90a53Smrg      $echo "     during execution"
627353e90a53Smrg    fi
627453e90a53Smrg    if test -n "$runpath_var"; then
627553e90a53Smrg      $echo "   - add LIBDIR to the \`$runpath_var' environment variable"
627653e90a53Smrg      $echo "     during linking"
627753e90a53Smrg    fi
627853e90a53Smrg    if test -n "$hardcode_libdir_flag_spec"; then
627953e90a53Smrg      libdir=LIBDIR
628053e90a53Smrg      eval flag=\"$hardcode_libdir_flag_spec\"
628153e90a53Smrg
628253e90a53Smrg      $echo "   - use the \`$flag' linker flag"
628353e90a53Smrg    fi
628453e90a53Smrg    if test -n "$admincmds"; then
628553e90a53Smrg      $echo "   - have your system administrator run these commands:$admincmds"
628653e90a53Smrg    fi
628753e90a53Smrg    if test -f /etc/ld.so.conf; then
628853e90a53Smrg      $echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
628953e90a53Smrg    fi
629053e90a53Smrg    $echo
629153e90a53Smrg    $echo "See any operating system documentation about shared libraries for"
629253e90a53Smrg    $echo "more information, such as the ld(1) and ld.so(8) manual pages."
629353e90a53Smrg    $echo "X----------------------------------------------------------------------" | $Xsed
629453e90a53Smrg    exit $EXIT_SUCCESS
629553e90a53Smrg    ;;
629653e90a53Smrg
629753e90a53Smrg  # libtool execute mode
629853e90a53Smrg  execute)
629953e90a53Smrg    modename="$modename: execute"
630053e90a53Smrg
630153e90a53Smrg    # The first argument is the command name.
630253e90a53Smrg    cmd="$nonopt"
630353e90a53Smrg    if test -z "$cmd"; then
630453e90a53Smrg      $echo "$modename: you must specify a COMMAND" 1>&2
630553e90a53Smrg      $echo "$help"
630653e90a53Smrg      exit $EXIT_FAILURE
630753e90a53Smrg    fi
630853e90a53Smrg
630953e90a53Smrg    # Handle -dlopen flags immediately.
631053e90a53Smrg    for file in $execute_dlfiles; do
631153e90a53Smrg      if test ! -f "$file"; then
631253e90a53Smrg	$echo "$modename: \`$file' is not a file" 1>&2
631353e90a53Smrg	$echo "$help" 1>&2
631453e90a53Smrg	exit $EXIT_FAILURE
631553e90a53Smrg      fi
631653e90a53Smrg
631753e90a53Smrg      dir=
631853e90a53Smrg      case $file in
631953e90a53Smrg      *.la)
632053e90a53Smrg	# Check to see that this really is a libtool archive.
632153e90a53Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
632253e90a53Smrg	else
632353e90a53Smrg	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
632453e90a53Smrg	  $echo "$help" 1>&2
632553e90a53Smrg	  exit $EXIT_FAILURE
632653e90a53Smrg	fi
632753e90a53Smrg
632853e90a53Smrg	# Read the libtool library.
632953e90a53Smrg	dlname=
633053e90a53Smrg	library_names=
633153e90a53Smrg
633253e90a53Smrg	# If there is no directory component, then add one.
633353e90a53Smrg	case $file in
633453e90a53Smrg	*/* | *\\*) . $file ;;
633553e90a53Smrg	*) . ./$file ;;
633653e90a53Smrg	esac
633753e90a53Smrg
633853e90a53Smrg	# Skip this library if it cannot be dlopened.
633953e90a53Smrg	if test -z "$dlname"; then
634053e90a53Smrg	  # Warn if it was a shared library.
634153e90a53Smrg	  test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'"
634253e90a53Smrg	  continue
634353e90a53Smrg	fi
634453e90a53Smrg
634553e90a53Smrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
634653e90a53Smrg	test "X$dir" = "X$file" && dir=.
634753e90a53Smrg
634853e90a53Smrg	if test -f "$dir/$objdir/$dlname"; then
634953e90a53Smrg	  dir="$dir/$objdir"
635053e90a53Smrg	else
635153e90a53Smrg	  $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
635253e90a53Smrg	  exit $EXIT_FAILURE
635353e90a53Smrg	fi
635453e90a53Smrg	;;
635553e90a53Smrg
635653e90a53Smrg      *.lo)
635753e90a53Smrg	# Just add the directory containing the .lo file.
635853e90a53Smrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
635953e90a53Smrg	test "X$dir" = "X$file" && dir=.
636053e90a53Smrg	;;
636153e90a53Smrg
636253e90a53Smrg      *)
636353e90a53Smrg	$echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2
636453e90a53Smrg	continue
636553e90a53Smrg	;;
636653e90a53Smrg      esac
636753e90a53Smrg
636853e90a53Smrg      # Get the absolute pathname.
636953e90a53Smrg      absdir=`cd "$dir" && pwd`
637053e90a53Smrg      test -n "$absdir" && dir="$absdir"
637153e90a53Smrg
637253e90a53Smrg      # Now add the directory to shlibpath_var.
637353e90a53Smrg      if eval "test -z \"\$$shlibpath_var\""; then
637453e90a53Smrg	eval "$shlibpath_var=\"\$dir\""
637553e90a53Smrg      else
637653e90a53Smrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
637753e90a53Smrg      fi
637853e90a53Smrg    done
637953e90a53Smrg
638053e90a53Smrg    # This variable tells wrapper scripts just to set shlibpath_var
638153e90a53Smrg    # rather than running their programs.
638253e90a53Smrg    libtool_execute_magic="$magic"
638353e90a53Smrg
638453e90a53Smrg    # Check if any of the arguments is a wrapper script.
638553e90a53Smrg    args=
638653e90a53Smrg    for file
638753e90a53Smrg    do
638853e90a53Smrg      case $file in
638953e90a53Smrg      -*) ;;
639053e90a53Smrg      *)
639153e90a53Smrg	# Do a test to see if this is really a libtool program.
639253e90a53Smrg	if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
639353e90a53Smrg	  # If there is no directory component, then add one.
639453e90a53Smrg	  case $file in
639553e90a53Smrg	  */* | *\\*) . $file ;;
639653e90a53Smrg	  *) . ./$file ;;
639753e90a53Smrg	  esac
639853e90a53Smrg
639953e90a53Smrg	  # Transform arg to wrapped name.
640053e90a53Smrg	  file="$progdir/$program"
640153e90a53Smrg	fi
640253e90a53Smrg	;;
640353e90a53Smrg      esac
640453e90a53Smrg      # Quote arguments (to preserve shell metacharacters).
640553e90a53Smrg      file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"`
640653e90a53Smrg      args="$args \"$file\""
640753e90a53Smrg    done
640853e90a53Smrg
640953e90a53Smrg    if test -z "$run"; then
641053e90a53Smrg      if test -n "$shlibpath_var"; then
641153e90a53Smrg	# Export the shlibpath_var.
641253e90a53Smrg	eval "export $shlibpath_var"
641353e90a53Smrg      fi
641453e90a53Smrg
641553e90a53Smrg      # Restore saved environment variables
641653e90a53Smrg      if test "${save_LC_ALL+set}" = set; then
641753e90a53Smrg	LC_ALL="$save_LC_ALL"; export LC_ALL
641853e90a53Smrg      fi
641953e90a53Smrg      if test "${save_LANG+set}" = set; then
642053e90a53Smrg	LANG="$save_LANG"; export LANG
642153e90a53Smrg      fi
642253e90a53Smrg
642353e90a53Smrg      # Now prepare to actually exec the command.
642453e90a53Smrg      exec_cmd="\$cmd$args"
642553e90a53Smrg    else
642653e90a53Smrg      # Display what would be done.
642753e90a53Smrg      if test -n "$shlibpath_var"; then
642853e90a53Smrg	eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\""
642953e90a53Smrg	$echo "export $shlibpath_var"
643053e90a53Smrg      fi
643153e90a53Smrg      $echo "$cmd$args"
643253e90a53Smrg      exit $EXIT_SUCCESS
643353e90a53Smrg    fi
643453e90a53Smrg    ;;
643553e90a53Smrg
643653e90a53Smrg  # libtool clean and uninstall mode
643753e90a53Smrg  clean | uninstall)
643853e90a53Smrg    modename="$modename: $mode"
643953e90a53Smrg    rm="$nonopt"
644053e90a53Smrg    files=
644153e90a53Smrg    rmforce=
644253e90a53Smrg    exit_status=0
644353e90a53Smrg
644453e90a53Smrg    # This variable tells wrapper scripts just to set variables rather
644553e90a53Smrg    # than running their programs.
644653e90a53Smrg    libtool_install_magic="$magic"
644753e90a53Smrg
644853e90a53Smrg    for arg
644953e90a53Smrg    do
645053e90a53Smrg      case $arg in
645153e90a53Smrg      -f) rm="$rm $arg"; rmforce=yes ;;
645253e90a53Smrg      -*) rm="$rm $arg" ;;
645353e90a53Smrg      *) files="$files $arg" ;;
645453e90a53Smrg      esac
645553e90a53Smrg    done
645653e90a53Smrg
645753e90a53Smrg    if test -z "$rm"; then
645853e90a53Smrg      $echo "$modename: you must specify an RM program" 1>&2
645953e90a53Smrg      $echo "$help" 1>&2
646053e90a53Smrg      exit $EXIT_FAILURE
646153e90a53Smrg    fi
646253e90a53Smrg
646353e90a53Smrg    rmdirs=
646453e90a53Smrg
646553e90a53Smrg    origobjdir="$objdir"
646653e90a53Smrg    for file in $files; do
646753e90a53Smrg      dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
646853e90a53Smrg      if test "X$dir" = "X$file"; then
646953e90a53Smrg	dir=.
647053e90a53Smrg	objdir="$origobjdir"
647153e90a53Smrg      else
647253e90a53Smrg	objdir="$dir/$origobjdir"
647353e90a53Smrg      fi
647453e90a53Smrg      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
647553e90a53Smrg      test "$mode" = uninstall && objdir="$dir"
647653e90a53Smrg
647753e90a53Smrg      # Remember objdir for removal later, being careful to avoid duplicates
647853e90a53Smrg      if test "$mode" = clean; then
647953e90a53Smrg	case " $rmdirs " in
648053e90a53Smrg	  *" $objdir "*) ;;
648153e90a53Smrg	  *) rmdirs="$rmdirs $objdir" ;;
648253e90a53Smrg	esac
648353e90a53Smrg      fi
648453e90a53Smrg
648553e90a53Smrg      # Don't error if the file doesn't exist and rm -f was used.
648653e90a53Smrg      if (test -L "$file") >/dev/null 2>&1 \
648753e90a53Smrg	|| (test -h "$file") >/dev/null 2>&1 \
648853e90a53Smrg	|| test -f "$file"; then
648953e90a53Smrg	:
649053e90a53Smrg      elif test -d "$file"; then
649153e90a53Smrg	exit_status=1
649253e90a53Smrg	continue
649353e90a53Smrg      elif test "$rmforce" = yes; then
649453e90a53Smrg	continue
649553e90a53Smrg      fi
649653e90a53Smrg
649753e90a53Smrg      rmfiles="$file"
649853e90a53Smrg
649953e90a53Smrg      case $name in
650053e90a53Smrg      *.la)
650153e90a53Smrg	# Possibly a libtool archive, so verify it.
650253e90a53Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
650353e90a53Smrg	  . $dir/$name
650453e90a53Smrg
650553e90a53Smrg	  # Delete the libtool libraries and symlinks.
650653e90a53Smrg	  for n in $library_names; do
650753e90a53Smrg	    rmfiles="$rmfiles $objdir/$n"
650853e90a53Smrg	  done
650953e90a53Smrg	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
651053e90a53Smrg
651153e90a53Smrg	  case "$mode" in
651253e90a53Smrg	  clean)
651353e90a53Smrg	    case "  $library_names " in
651453e90a53Smrg	    # "  " in the beginning catches empty $dlname
651553e90a53Smrg	    *" $dlname "*) ;;
651653e90a53Smrg	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
651753e90a53Smrg	    esac
651853e90a53Smrg	     test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
651953e90a53Smrg	    ;;
652053e90a53Smrg	  uninstall)
652153e90a53Smrg	    if test -n "$library_names"; then
652253e90a53Smrg	      # Do each command in the postuninstall commands.
652353e90a53Smrg	      cmds=$postuninstall_cmds
652453e90a53Smrg	      save_ifs="$IFS"; IFS='~'
652553e90a53Smrg	      for cmd in $cmds; do
652653e90a53Smrg		IFS="$save_ifs"
652753e90a53Smrg		eval cmd=\"$cmd\"
652853e90a53Smrg		$show "$cmd"
652953e90a53Smrg		$run eval "$cmd"
653053e90a53Smrg		if test "$?" -ne 0 && test "$rmforce" != yes; then
653153e90a53Smrg		  exit_status=1
653253e90a53Smrg		fi
653353e90a53Smrg	      done
653453e90a53Smrg	      IFS="$save_ifs"
653553e90a53Smrg	    fi
653653e90a53Smrg
653753e90a53Smrg	    if test -n "$old_library"; then
653853e90a53Smrg	      # Do each command in the old_postuninstall commands.
653953e90a53Smrg	      cmds=$old_postuninstall_cmds
654053e90a53Smrg	      save_ifs="$IFS"; IFS='~'
654153e90a53Smrg	      for cmd in $cmds; do
654253e90a53Smrg		IFS="$save_ifs"
654353e90a53Smrg		eval cmd=\"$cmd\"
654453e90a53Smrg		$show "$cmd"
654553e90a53Smrg		$run eval "$cmd"
654653e90a53Smrg		if test "$?" -ne 0 && test "$rmforce" != yes; then
654753e90a53Smrg		  exit_status=1
654853e90a53Smrg		fi
654953e90a53Smrg	      done
655053e90a53Smrg	      IFS="$save_ifs"
655153e90a53Smrg	    fi
655253e90a53Smrg	    # FIXME: should reinstall the best remaining shared library.
655353e90a53Smrg	    ;;
655453e90a53Smrg	  esac
655553e90a53Smrg	fi
655653e90a53Smrg	;;
655753e90a53Smrg
655853e90a53Smrg      *.lo)
655953e90a53Smrg	# Possibly a libtool object, so verify it.
656053e90a53Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
656153e90a53Smrg
656253e90a53Smrg	  # Read the .lo file
656353e90a53Smrg	  . $dir/$name
656453e90a53Smrg
656553e90a53Smrg	  # Add PIC object to the list of files to remove.
656653e90a53Smrg	  if test -n "$pic_object" \
656753e90a53Smrg	     && test "$pic_object" != none; then
656853e90a53Smrg	    rmfiles="$rmfiles $dir/$pic_object"
656953e90a53Smrg	  fi
657053e90a53Smrg
657153e90a53Smrg	  # Add non-PIC object to the list of files to remove.
657253e90a53Smrg	  if test -n "$non_pic_object" \
657353e90a53Smrg	     && test "$non_pic_object" != none; then
657453e90a53Smrg	    rmfiles="$rmfiles $dir/$non_pic_object"
657553e90a53Smrg	  fi
657653e90a53Smrg	fi
657753e90a53Smrg	;;
657853e90a53Smrg
657953e90a53Smrg      *)
658053e90a53Smrg	if test "$mode" = clean ; then
658153e90a53Smrg	  noexename=$name
658253e90a53Smrg	  case $file in
658353e90a53Smrg	  *.exe)
658453e90a53Smrg	    file=`$echo $file|${SED} 's,.exe$,,'`
658553e90a53Smrg	    noexename=`$echo $name|${SED} 's,.exe$,,'`
658653e90a53Smrg	    # $file with .exe has already been added to rmfiles,
658753e90a53Smrg	    # add $file without .exe
658853e90a53Smrg	    rmfiles="$rmfiles $file"
658953e90a53Smrg	    ;;
659053e90a53Smrg	  esac
659153e90a53Smrg	  # Do a test to see if this is a libtool program.
659253e90a53Smrg	  if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
659353e90a53Smrg	    relink_command=
659453e90a53Smrg	    . $dir/$noexename
659553e90a53Smrg
659653e90a53Smrg	    # note $name still contains .exe if it was in $file originally
659753e90a53Smrg	    # as does the version of $file that was added into $rmfiles
659853e90a53Smrg	    rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
659953e90a53Smrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
660053e90a53Smrg	      rmfiles="$rmfiles $objdir/lt-$name"
660153e90a53Smrg	    fi
660253e90a53Smrg	    if test "X$noexename" != "X$name" ; then
660353e90a53Smrg	      rmfiles="$rmfiles $objdir/lt-${noexename}.c"
660453e90a53Smrg	    fi
660553e90a53Smrg	  fi
660653e90a53Smrg	fi
660753e90a53Smrg	;;
660853e90a53Smrg      esac
660953e90a53Smrg      $show "$rm $rmfiles"
661053e90a53Smrg      $run $rm $rmfiles || exit_status=1
661153e90a53Smrg    done
661253e90a53Smrg    objdir="$origobjdir"
661353e90a53Smrg
661453e90a53Smrg    # Try to remove the ${objdir}s in the directories where we deleted files
661553e90a53Smrg    for dir in $rmdirs; do
661653e90a53Smrg      if test -d "$dir"; then
661753e90a53Smrg	$show "rmdir $dir"
661853e90a53Smrg	$run rmdir $dir >/dev/null 2>&1
661953e90a53Smrg      fi
662053e90a53Smrg    done
662153e90a53Smrg
662253e90a53Smrg    exit $exit_status
662353e90a53Smrg    ;;
662453e90a53Smrg
662553e90a53Smrg  "")
662653e90a53Smrg    $echo "$modename: you must specify a MODE" 1>&2
662753e90a53Smrg    $echo "$generic_help" 1>&2
662853e90a53Smrg    exit $EXIT_FAILURE
662953e90a53Smrg    ;;
663053e90a53Smrg  esac
663153e90a53Smrg
663253e90a53Smrg  if test -z "$exec_cmd"; then
663353e90a53Smrg    $echo "$modename: invalid operation mode \`$mode'" 1>&2
663453e90a53Smrg    $echo "$generic_help" 1>&2
663553e90a53Smrg    exit $EXIT_FAILURE
663653e90a53Smrg  fi
663753e90a53Smrgfi # test -z "$show_help"
663853e90a53Smrg
663953e90a53Smrgif test -n "$exec_cmd"; then
664053e90a53Smrg  eval exec $exec_cmd
664153e90a53Smrg  exit $EXIT_FAILURE
664253e90a53Smrgfi
664353e90a53Smrg
664453e90a53Smrg# We need to display help for each of the modes.
664553e90a53Smrgcase $mode in
664653e90a53Smrg"") $echo \
664753e90a53Smrg"Usage: $modename [OPTION]... [MODE-ARG]...
664853e90a53Smrg
664953e90a53SmrgProvide generalized library-building support services.
665053e90a53Smrg
665153e90a53Smrg    --config          show all configuration variables
665253e90a53Smrg    --debug           enable verbose shell tracing
665353e90a53Smrg-n, --dry-run         display commands without modifying any files
665453e90a53Smrg    --features        display basic configuration information and exit
665553e90a53Smrg    --finish          same as \`--mode=finish'
665653e90a53Smrg    --help            display this help message and exit
665753e90a53Smrg    --mode=MODE       use operation mode MODE [default=inferred from MODE-ARGS]
665853e90a53Smrg    --quiet           same as \`--silent'
665953e90a53Smrg    --silent          don't print informational messages
666053e90a53Smrg    --tag=TAG         use configuration variables from tag TAG
666153e90a53Smrg    --version         print version information
666253e90a53Smrg
666353e90a53SmrgMODE must be one of the following:
666453e90a53Smrg
666553e90a53Smrg      clean           remove files from the build directory
666653e90a53Smrg      compile         compile a source file into a libtool object
666753e90a53Smrg      execute         automatically set library path, then run a program
666853e90a53Smrg      finish          complete the installation of libtool libraries
666953e90a53Smrg      install         install libraries or executables
667053e90a53Smrg      link            create a library or an executable
667153e90a53Smrg      uninstall       remove libraries from an installed directory
667253e90a53Smrg
667353e90a53SmrgMODE-ARGS vary depending on the MODE.  Try \`$modename --help --mode=MODE' for
667453e90a53Smrga more detailed description of MODE.
667553e90a53Smrg
667653e90a53SmrgReport bugs to <bug-libtool@gnu.org>."
667753e90a53Smrg  exit $EXIT_SUCCESS
667853e90a53Smrg  ;;
667953e90a53Smrg
668053e90a53Smrgclean)
668153e90a53Smrg  $echo \
668253e90a53Smrg"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
668353e90a53Smrg
668453e90a53SmrgRemove files from the build directory.
668553e90a53Smrg
668653e90a53SmrgRM is the name of the program to use to delete files associated with each FILE
668753e90a53Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
668853e90a53Smrgto RM.
668953e90a53Smrg
669053e90a53SmrgIf FILE is a libtool library, object or program, all the files associated
669153e90a53Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
669253e90a53Smrg  ;;
669353e90a53Smrg
669453e90a53Smrgcompile)
669553e90a53Smrg  $echo \
669653e90a53Smrg"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
669753e90a53Smrg
669853e90a53SmrgCompile a source file into a libtool library object.
669953e90a53Smrg
670053e90a53SmrgThis mode accepts the following additional options:
670153e90a53Smrg
670253e90a53Smrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
670353e90a53Smrg  -prefer-pic       try to building PIC objects only
670453e90a53Smrg  -prefer-non-pic   try to building non-PIC objects only
670553e90a53Smrg  -static           always build a \`.o' file suitable for static linking
670653e90a53Smrg
670753e90a53SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
670853e90a53Smrgfrom the given SOURCEFILE.
670953e90a53Smrg
671053e90a53SmrgThe output file name is determined by removing the directory component from
671153e90a53SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
671253e90a53Smrglibrary object suffix, \`.lo'."
671353e90a53Smrg  ;;
671453e90a53Smrg
671553e90a53Smrgexecute)
671653e90a53Smrg  $echo \
671753e90a53Smrg"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]...
671853e90a53Smrg
671953e90a53SmrgAutomatically set library path, then run a program.
672053e90a53Smrg
672153e90a53SmrgThis mode accepts the following additional options:
672253e90a53Smrg
672353e90a53Smrg  -dlopen FILE      add the directory containing FILE to the library path
672453e90a53Smrg
672553e90a53SmrgThis mode sets the library path environment variable according to \`-dlopen'
672653e90a53Smrgflags.
672753e90a53Smrg
672853e90a53SmrgIf any of the ARGS are libtool executable wrappers, then they are translated
672953e90a53Smrginto their corresponding uninstalled binary, and any of their required library
673053e90a53Smrgdirectories are added to the library path.
673153e90a53Smrg
673253e90a53SmrgThen, COMMAND is executed, with ARGS as arguments."
673353e90a53Smrg  ;;
673453e90a53Smrg
673553e90a53Smrgfinish)
673653e90a53Smrg  $echo \
673753e90a53Smrg"Usage: $modename [OPTION]... --mode=finish [LIBDIR]...
673853e90a53Smrg
673953e90a53SmrgComplete the installation of libtool libraries.
674053e90a53Smrg
674153e90a53SmrgEach LIBDIR is a directory that contains libtool libraries.
674253e90a53Smrg
674353e90a53SmrgThe commands that this mode executes may require superuser privileges.  Use
674453e90a53Smrgthe \`--dry-run' option if you just want to see what would be executed."
674553e90a53Smrg  ;;
674653e90a53Smrg
674753e90a53Smrginstall)
674853e90a53Smrg  $echo \
674953e90a53Smrg"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND...
675053e90a53Smrg
675153e90a53SmrgInstall executables or libraries.
675253e90a53Smrg
675353e90a53SmrgINSTALL-COMMAND is the installation command.  The first component should be
675453e90a53Smrgeither the \`install' or \`cp' program.
675553e90a53Smrg
675653e90a53SmrgThe rest of the components are interpreted as arguments to that command (only
675753e90a53SmrgBSD-compatible install options are recognized)."
675853e90a53Smrg  ;;
675953e90a53Smrg
676053e90a53Smrglink)
676153e90a53Smrg  $echo \
676253e90a53Smrg"Usage: $modename [OPTION]... --mode=link LINK-COMMAND...
676353e90a53Smrg
676453e90a53SmrgLink object files or libraries together to form another library, or to
676553e90a53Smrgcreate an executable program.
676653e90a53Smrg
676753e90a53SmrgLINK-COMMAND is a command using the C compiler that you would use to create
676853e90a53Smrga program from several object files.
676953e90a53Smrg
677053e90a53SmrgThe following components of LINK-COMMAND are treated specially:
677153e90a53Smrg
677253e90a53Smrg  -all-static       do not do any dynamic linking at all
677353e90a53Smrg  -avoid-version    do not add a version suffix if possible
677453e90a53Smrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
677553e90a53Smrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
677653e90a53Smrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
677753e90a53Smrg  -export-symbols SYMFILE
677853e90a53Smrg		    try to export only the symbols listed in SYMFILE
677953e90a53Smrg  -export-symbols-regex REGEX
678053e90a53Smrg		    try to export only the symbols matching REGEX
678153e90a53Smrg  -LLIBDIR          search LIBDIR for required installed libraries
678253e90a53Smrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
678353e90a53Smrg  -module           build a library that can dlopened
678453e90a53Smrg  -no-fast-install  disable the fast-install mode
678553e90a53Smrg  -no-install       link a not-installable executable
678653e90a53Smrg  -no-undefined     declare that a library does not refer to external symbols
678753e90a53Smrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
678853e90a53Smrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
678953e90a53Smrg  -precious-files-regex REGEX
679053e90a53Smrg                    don't remove output files matching REGEX
679153e90a53Smrg  -release RELEASE  specify package release information
679253e90a53Smrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
679353e90a53Smrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
679453e90a53Smrg  -static           do not do any dynamic linking of libtool libraries
679553e90a53Smrg  -version-info CURRENT[:REVISION[:AGE]]
679653e90a53Smrg		    specify library version info [each variable defaults to 0]
679753e90a53Smrg
679853e90a53SmrgAll other options (arguments beginning with \`-') are ignored.
679953e90a53Smrg
680053e90a53SmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
680153e90a53Smrgtreated as uninstalled libtool libraries, other files are standard or library
680253e90a53Smrgobject files.
680353e90a53Smrg
680453e90a53SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
680553e90a53Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
680653e90a53Smrgrequired, except when creating a convenience library.
680753e90a53Smrg
680853e90a53SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
680953e90a53Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
681053e90a53Smrg
681153e90a53SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
681253e90a53Smrgis created, otherwise an executable program is created."
681353e90a53Smrg  ;;
681453e90a53Smrg
681553e90a53Smrguninstall)
681653e90a53Smrg  $echo \
681753e90a53Smrg"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
681853e90a53Smrg
681953e90a53SmrgRemove libraries from an installation directory.
682053e90a53Smrg
682153e90a53SmrgRM is the name of the program to use to delete files associated with each FILE
682253e90a53Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
682353e90a53Smrgto RM.
682453e90a53Smrg
682553e90a53SmrgIf FILE is a libtool library, all the files associated with it are deleted.
682653e90a53SmrgOtherwise, only FILE itself is deleted using RM."
682753e90a53Smrg  ;;
682853e90a53Smrg
682953e90a53Smrg*)
683053e90a53Smrg  $echo "$modename: invalid operation mode \`$mode'" 1>&2
683153e90a53Smrg  $echo "$help" 1>&2
683253e90a53Smrg  exit $EXIT_FAILURE
683353e90a53Smrg  ;;
683453e90a53Smrgesac
683553e90a53Smrg
683653e90a53Smrg$echo
683753e90a53Smrg$echo "Try \`$modename --help' for more information about other modes."
683853e90a53Smrg
683953e90a53Smrgexit $?
684053e90a53Smrg
684153e90a53Smrg# The TAGs below are defined such that we never get into a situation
684253e90a53Smrg# in which we disable both kinds of libraries.  Given conflicting
684353e90a53Smrg# choices, we go for a static library, that is the most portable,
684453e90a53Smrg# since we can't tell whether shared libraries were disabled because
684553e90a53Smrg# the user asked for that or because the platform doesn't support
684653e90a53Smrg# them.  This is particularly important on AIX, because we don't
684753e90a53Smrg# support having both static and shared libraries enabled at the same
684853e90a53Smrg# time on that platform, so we default to a shared-only configuration.
684953e90a53Smrg# If a disable-shared tag is given, we'll fallback to a static-only
685053e90a53Smrg# configuration.  But we'll never go from static-only to shared-only.
685153e90a53Smrg
685253e90a53Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
685353e90a53Smrgdisable_libs=shared
685453e90a53Smrg# ### END LIBTOOL TAG CONFIG: disable-shared
685553e90a53Smrg
685653e90a53Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
685753e90a53Smrgdisable_libs=static
685853e90a53Smrg# ### END LIBTOOL TAG CONFIG: disable-static
685953e90a53Smrg
686053e90a53Smrg# Local Variables:
686153e90a53Smrg# mode:shell-script
686253e90a53Smrg# sh-indentation:2
686353e90a53Smrg# End:
6864