ltmain.sh revision 76888252
176888252Smrg# ltmain.sh - Provide generalized library-building support services.
276888252Smrg# NOTE: Changing this file will not affect anything until you rerun configure.
376888252Smrg#
476888252Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005
576888252Smrg# Free Software Foundation, Inc.
676888252Smrg# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
776888252Smrg#
876888252Smrg# This program is free software; you can redistribute it and/or modify
976888252Smrg# it under the terms of the GNU General Public License as published by
1076888252Smrg# the Free Software Foundation; either version 2 of the License, or
1176888252Smrg# (at your option) any later version.
1276888252Smrg#
1376888252Smrg# This program is distributed in the hope that it will be useful, but
1476888252Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
1576888252Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1676888252Smrg# General Public License for more details.
1776888252Smrg#
1876888252Smrg# You should have received a copy of the GNU General Public License
1976888252Smrg# along with this program; if not, write to the Free Software
2076888252Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2176888252Smrg#
2276888252Smrg# As a special exception to the GNU General Public License, if you
2376888252Smrg# distribute this file as part of a program that contains a
2476888252Smrg# configuration script generated by Autoconf, you may include it under
2576888252Smrg# the same distribution terms that you use for the rest of that program.
2676888252Smrg
2776888252Smrgbasename="s,^.*/,,g"
2876888252Smrg
2976888252Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
3076888252Smrg# is ksh but when the shell is invoked as "sh" and the current value of
3176888252Smrg# the _XPG environment variable is not equal to 1 (one), the special
3276888252Smrg# positional parameter $0, within a function call, is the name of the
3376888252Smrg# function.
3476888252Smrgprogpath="$0"
3576888252Smrg
3676888252Smrg# The name of this program:
3776888252Smrgprogname=`echo "$progpath" | $SED $basename`
3876888252Smrgmodename="$progname"
3976888252Smrg
4076888252Smrg# Global variables:
4176888252SmrgEXIT_SUCCESS=0
4276888252SmrgEXIT_FAILURE=1
4376888252Smrg
4476888252SmrgPROGRAM=ltmain.sh
4576888252SmrgPACKAGE=libtool
4676888252SmrgVERSION=1.5.22
4776888252SmrgTIMESTAMP=" (1.1220.2.365 2005/12/18 22:14:06)"
4876888252Smrg
4976888252Smrg# See if we are running on zsh, and set the options which allow our
5076888252Smrg# commands through without removal of \ escapes.
5176888252Smrgif test -n "${ZSH_VERSION+set}" ; then
5276888252Smrg  setopt NO_GLOB_SUBST
5376888252Smrgfi
5476888252Smrg
5576888252Smrg# Check that we have a working $echo.
5676888252Smrgif test "X$1" = X--no-reexec; then
5776888252Smrg  # Discard the --no-reexec flag, and continue.
5876888252Smrg  shift
5976888252Smrgelif test "X$1" = X--fallback-echo; then
6076888252Smrg  # Avoid inline document here, it may be left over
6176888252Smrg  :
6276888252Smrgelif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
6376888252Smrg  # Yippee, $echo works!
6476888252Smrg  :
6576888252Smrgelse
6676888252Smrg  # Restart under the correct shell, and then maybe $echo will work.
6776888252Smrg  exec $SHELL "$progpath" --no-reexec ${1+"$@"}
6876888252Smrgfi
6976888252Smrg
7076888252Smrgif test "X$1" = X--fallback-echo; then
7176888252Smrg  # used as fallback echo
7276888252Smrg  shift
7376888252Smrg  cat <<EOF
7476888252Smrg$*
7576888252SmrgEOF
7676888252Smrg  exit $EXIT_SUCCESS
7776888252Smrgfi
7876888252Smrg
7976888252Smrgdefault_mode=
8076888252Smrghelp="Try \`$progname --help' for more information."
8176888252Smrgmagic="%%%MAGIC variable%%%"
8276888252Smrgmkdir="mkdir"
8376888252Smrgmv="mv -f"
8476888252Smrgrm="rm -f"
8576888252Smrg
8676888252Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
8776888252Smrg# metacharacters that are still active within double-quoted strings.
8876888252SmrgXsed="${SED}"' -e 1s/^X//'
8976888252Smrgsed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
9076888252Smrg# test EBCDIC or ASCII
9176888252Smrgcase `echo X|tr X '\101'` in
9276888252Smrg A) # ASCII based system
9376888252Smrg    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
9476888252Smrg  SP2NL='tr \040 \012'
9576888252Smrg  NL2SP='tr \015\012 \040\040'
9676888252Smrg  ;;
9776888252Smrg *) # EBCDIC based system
9876888252Smrg  SP2NL='tr \100 \n'
9976888252Smrg  NL2SP='tr \r\n \100\100'
10076888252Smrg  ;;
10176888252Smrgesac
10276888252Smrg
10376888252Smrg# NLS nuisances.
10476888252Smrg# Only set LANG and LC_ALL to C if already set.
10576888252Smrg# These must not be set unconditionally because not all systems understand
10676888252Smrg# e.g. LANG=C (notably SCO).
10776888252Smrg# We save the old values to restore during execute mode.
10876888252Smrgif test "${LC_ALL+set}" = set; then
10976888252Smrg  save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
11076888252Smrgfi
11176888252Smrgif test "${LANG+set}" = set; then
11276888252Smrg  save_LANG="$LANG"; LANG=C; export LANG
11376888252Smrgfi
11476888252Smrg
11576888252Smrg# Make sure IFS has a sensible default
11676888252Smrglt_nl='
11776888252Smrg'
11876888252SmrgIFS=" 	$lt_nl"
11976888252Smrg
12076888252Smrgif test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
12176888252Smrg  $echo "$modename: not configured to build any kind of library" 1>&2
12276888252Smrg  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
12376888252Smrg  exit $EXIT_FAILURE
12476888252Smrgfi
12576888252Smrg
12676888252Smrg# Global variables.
12776888252Smrgmode=$default_mode
12876888252Smrgnonopt=
12976888252Smrgprev=
13076888252Smrgprevopt=
13176888252Smrgrun=
13276888252Smrgshow="$echo"
13376888252Smrgshow_help=
13476888252Smrgexecute_dlfiles=
13576888252Smrgduplicate_deps=no
13676888252Smrgpreserve_args=
13776888252Smrglo2o="s/\\.lo\$/.${objext}/"
13876888252Smrgo2lo="s/\\.${objext}\$/.lo/"
13976888252Smrg
14076888252Smrg#####################################
14176888252Smrg# Shell function definitions:
14276888252Smrg# This seems to be the best place for them
14376888252Smrg
14476888252Smrg# func_mktempdir [string]
14576888252Smrg# Make a temporary directory that won't clash with other running
14676888252Smrg# libtool processes, and avoids race conditions if possible.  If
14776888252Smrg# given, STRING is the basename for that directory.
14876888252Smrgfunc_mktempdir ()
14976888252Smrg{
15076888252Smrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
15176888252Smrg
15276888252Smrg    if test "$run" = ":"; then
15376888252Smrg      # Return a directory name, but don't create it in dry-run mode
15476888252Smrg      my_tmpdir="${my_template}-$$"
15576888252Smrg    else
15676888252Smrg
15776888252Smrg      # If mktemp works, use that first and foremost
15876888252Smrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
15976888252Smrg
16076888252Smrg      if test ! -d "$my_tmpdir"; then
16176888252Smrg	# Failing that, at least try and use $RANDOM to avoid a race
16276888252Smrg	my_tmpdir="${my_template}-${RANDOM-0}$$"
16376888252Smrg
16476888252Smrg	save_mktempdir_umask=`umask`
16576888252Smrg	umask 0077
16676888252Smrg	$mkdir "$my_tmpdir"
16776888252Smrg	umask $save_mktempdir_umask
16876888252Smrg      fi
16976888252Smrg
17076888252Smrg      # If we're not in dry-run mode, bomb out on failure
17176888252Smrg      test -d "$my_tmpdir" || {
17276888252Smrg        $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
17376888252Smrg	exit $EXIT_FAILURE
17476888252Smrg      }
17576888252Smrg    fi
17676888252Smrg
17776888252Smrg    $echo "X$my_tmpdir" | $Xsed
17876888252Smrg}
17976888252Smrg
18076888252Smrg
18176888252Smrg# func_win32_libid arg
18276888252Smrg# return the library type of file 'arg'
18376888252Smrg#
18476888252Smrg# Need a lot of goo to handle *both* DLLs and import libs
18576888252Smrg# Has to be a shell function in order to 'eat' the argument
18676888252Smrg# that is supplied when $file_magic_command is called.
18776888252Smrgfunc_win32_libid ()
18876888252Smrg{
18976888252Smrg  win32_libid_type="unknown"
19076888252Smrg  win32_fileres=`file -L $1 2>/dev/null`
19176888252Smrg  case $win32_fileres in
19276888252Smrg  *ar\ archive\ import\ library*) # definitely import
19376888252Smrg    win32_libid_type="x86 archive import"
19476888252Smrg    ;;
19576888252Smrg  *ar\ archive*) # could be an import, or static
19676888252Smrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
19776888252Smrg      $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
19876888252Smrg      win32_nmres=`eval $NM -f posix -A $1 | \
19976888252Smrg	$SED -n -e '1,100{/ I /{s,.*,import,;p;q;};}'`
20076888252Smrg      case $win32_nmres in
20176888252Smrg      import*)  win32_libid_type="x86 archive import";;
20276888252Smrg      *)        win32_libid_type="x86 archive static";;
20376888252Smrg      esac
20476888252Smrg    fi
20576888252Smrg    ;;
20676888252Smrg  *DLL*)
20776888252Smrg    win32_libid_type="x86 DLL"
20876888252Smrg    ;;
20976888252Smrg  *executable*) # but shell scripts are "executable" too...
21076888252Smrg    case $win32_fileres in
21176888252Smrg    *MS\ Windows\ PE\ Intel*)
21276888252Smrg      win32_libid_type="x86 DLL"
21376888252Smrg      ;;
21476888252Smrg    esac
21576888252Smrg    ;;
21676888252Smrg  esac
21776888252Smrg  $echo $win32_libid_type
21876888252Smrg}
21976888252Smrg
22076888252Smrg
22176888252Smrg# func_infer_tag arg
22276888252Smrg# Infer tagged configuration to use if any are available and
22376888252Smrg# if one wasn't chosen via the "--tag" command line option.
22476888252Smrg# Only attempt this if the compiler in the base compile
22576888252Smrg# command doesn't match the default compiler.
22676888252Smrg# arg is usually of the form 'gcc ...'
22776888252Smrgfunc_infer_tag ()
22876888252Smrg{
22976888252Smrg    if test -n "$available_tags" && test -z "$tagname"; then
23076888252Smrg      CC_quoted=
23176888252Smrg      for arg in $CC; do
23276888252Smrg	case $arg in
23376888252Smrg	  *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
23476888252Smrg	  arg="\"$arg\""
23576888252Smrg	  ;;
23676888252Smrg	esac
23776888252Smrg	CC_quoted="$CC_quoted $arg"
23876888252Smrg      done
23976888252Smrg      case $@ in
24076888252Smrg      # Blanks in the command may have been stripped by the calling shell,
24176888252Smrg      # but not from the CC environment variable when configure was run.
24276888252Smrg      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
24376888252Smrg      # Blanks at the start of $base_compile will cause this to fail
24476888252Smrg      # if we don't check for them as well.
24576888252Smrg      *)
24676888252Smrg	for z in $available_tags; do
24776888252Smrg	  if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
24876888252Smrg	    # Evaluate the configuration.
24976888252Smrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
25076888252Smrg	    CC_quoted=
25176888252Smrg	    for arg in $CC; do
25276888252Smrg	    # Double-quote args containing other shell metacharacters.
25376888252Smrg	    case $arg in
25476888252Smrg	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
25576888252Smrg	      arg="\"$arg\""
25676888252Smrg	      ;;
25776888252Smrg	    esac
25876888252Smrg	    CC_quoted="$CC_quoted $arg"
25976888252Smrg	  done
26076888252Smrg	    case "$@ " in
26176888252Smrg	      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
26276888252Smrg	      # The compiler in the base compile command matches
26376888252Smrg	      # the one in the tagged configuration.
26476888252Smrg	      # Assume this is the tagged configuration we want.
26576888252Smrg	      tagname=$z
26676888252Smrg	      break
26776888252Smrg	      ;;
26876888252Smrg	    esac
26976888252Smrg	  fi
27076888252Smrg	done
27176888252Smrg	# If $tagname still isn't set, then no tagged configuration
27276888252Smrg	# was found and let the user know that the "--tag" command
27376888252Smrg	# line option must be used.
27476888252Smrg	if test -z "$tagname"; then
27576888252Smrg	  $echo "$modename: unable to infer tagged configuration"
27676888252Smrg	  $echo "$modename: specify a tag with \`--tag'" 1>&2
27776888252Smrg	  exit $EXIT_FAILURE
27876888252Smrg#        else
27976888252Smrg#          $echo "$modename: using $tagname tagged configuration"
28076888252Smrg	fi
28176888252Smrg	;;
28276888252Smrg      esac
28376888252Smrg    fi
28476888252Smrg}
28576888252Smrg
28676888252Smrg
28776888252Smrg# func_extract_an_archive dir oldlib
28876888252Smrgfunc_extract_an_archive ()
28976888252Smrg{
29076888252Smrg    f_ex_an_ar_dir="$1"; shift
29176888252Smrg    f_ex_an_ar_oldlib="$1"
29276888252Smrg
29376888252Smrg    $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
29476888252Smrg    $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
29576888252Smrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
29676888252Smrg     :
29776888252Smrg    else
29876888252Smrg      $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2
29976888252Smrg      exit $EXIT_FAILURE
30076888252Smrg    fi
30176888252Smrg}
30276888252Smrg
30376888252Smrg# func_extract_archives gentop oldlib ...
30476888252Smrgfunc_extract_archives ()
30576888252Smrg{
30676888252Smrg    my_gentop="$1"; shift
30776888252Smrg    my_oldlibs=${1+"$@"}
30876888252Smrg    my_oldobjs=""
30976888252Smrg    my_xlib=""
31076888252Smrg    my_xabs=""
31176888252Smrg    my_xdir=""
31276888252Smrg    my_status=""
31376888252Smrg
31476888252Smrg    $show "${rm}r $my_gentop"
31576888252Smrg    $run ${rm}r "$my_gentop"
31676888252Smrg    $show "$mkdir $my_gentop"
31776888252Smrg    $run $mkdir "$my_gentop"
31876888252Smrg    my_status=$?
31976888252Smrg    if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
32076888252Smrg      exit $my_status
32176888252Smrg    fi
32276888252Smrg
32376888252Smrg    for my_xlib in $my_oldlibs; do
32476888252Smrg      # Extract the objects.
32576888252Smrg      case $my_xlib in
32676888252Smrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
32776888252Smrg	*) my_xabs=`pwd`"/$my_xlib" ;;
32876888252Smrg      esac
32976888252Smrg      my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
33076888252Smrg      my_xdir="$my_gentop/$my_xlib"
33176888252Smrg
33276888252Smrg      $show "${rm}r $my_xdir"
33376888252Smrg      $run ${rm}r "$my_xdir"
33476888252Smrg      $show "$mkdir $my_xdir"
33576888252Smrg      $run $mkdir "$my_xdir"
33676888252Smrg      exit_status=$?
33776888252Smrg      if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then
33876888252Smrg	exit $exit_status
33976888252Smrg      fi
34076888252Smrg      case $host in
34176888252Smrg      *-darwin*)
34276888252Smrg	$show "Extracting $my_xabs"
34376888252Smrg	# Do not bother doing anything if just a dry run
34476888252Smrg	if test -z "$run"; then
34576888252Smrg	  darwin_orig_dir=`pwd`
34676888252Smrg	  cd $my_xdir || exit $?
34776888252Smrg	  darwin_archive=$my_xabs
34876888252Smrg	  darwin_curdir=`pwd`
34976888252Smrg	  darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'`
35076888252Smrg	  darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
35176888252Smrg	  if test -n "$darwin_arches"; then 
35276888252Smrg	    darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
35376888252Smrg	    darwin_arch=
35476888252Smrg	    $show "$darwin_base_archive has multiple architectures $darwin_arches"
35576888252Smrg	    for darwin_arch in  $darwin_arches ; do
35676888252Smrg	      mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
35776888252Smrg	      lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
35876888252Smrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
35976888252Smrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
36076888252Smrg	      cd "$darwin_curdir"
36176888252Smrg	      $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
36276888252Smrg	    done # $darwin_arches
36376888252Smrg      ## Okay now we have a bunch of thin objects, gotta fatten them up :)
36476888252Smrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP`
36576888252Smrg	    darwin_file=
36676888252Smrg	    darwin_files=
36776888252Smrg	    for darwin_file in $darwin_filelist; do
36876888252Smrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
36976888252Smrg	      lipo -create -output "$darwin_file" $darwin_files
37076888252Smrg	    done # $darwin_filelist
37176888252Smrg	    ${rm}r unfat-$$
37276888252Smrg	    cd "$darwin_orig_dir"
37376888252Smrg	  else
37476888252Smrg	    cd "$darwin_orig_dir"
37576888252Smrg 	    func_extract_an_archive "$my_xdir" "$my_xabs"
37676888252Smrg	  fi # $darwin_arches
37776888252Smrg	fi # $run
37876888252Smrg	;;
37976888252Smrg      *)
38076888252Smrg        func_extract_an_archive "$my_xdir" "$my_xabs"
38176888252Smrg        ;;
38276888252Smrg      esac
38376888252Smrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
38476888252Smrg    done
38576888252Smrg    func_extract_archives_result="$my_oldobjs"
38676888252Smrg}
38776888252Smrg# End of Shell function definitions
38876888252Smrg#####################################
38976888252Smrg
39076888252Smrg# Darwin sucks
39176888252Smrgeval std_shrext=\"$shrext_cmds\"
39276888252Smrg
39376888252Smrgdisable_libs=no
39476888252Smrg
39576888252Smrg# Parse our command line options once, thoroughly.
39676888252Smrgwhile test "$#" -gt 0
39776888252Smrgdo
39876888252Smrg  arg="$1"
39976888252Smrg  shift
40076888252Smrg
40176888252Smrg  case $arg in
40276888252Smrg  -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
40376888252Smrg  *) optarg= ;;
40476888252Smrg  esac
40576888252Smrg
40676888252Smrg  # If the previous option needs an argument, assign it.
40776888252Smrg  if test -n "$prev"; then
40876888252Smrg    case $prev in
40976888252Smrg    execute_dlfiles)
41076888252Smrg      execute_dlfiles="$execute_dlfiles $arg"
41176888252Smrg      ;;
41276888252Smrg    tag)
41376888252Smrg      tagname="$arg"
41476888252Smrg      preserve_args="${preserve_args}=$arg"
41576888252Smrg
41676888252Smrg      # Check whether tagname contains only valid characters
41776888252Smrg      case $tagname in
41876888252Smrg      *[!-_A-Za-z0-9,/]*)
41976888252Smrg	$echo "$progname: invalid tag name: $tagname" 1>&2
42076888252Smrg	exit $EXIT_FAILURE
42176888252Smrg	;;
42276888252Smrg      esac
42376888252Smrg
42476888252Smrg      case $tagname in
42576888252Smrg      CC)
42676888252Smrg	# Don't test for the "default" C tag, as we know, it's there, but
42776888252Smrg	# not specially marked.
42876888252Smrg	;;
42976888252Smrg      *)
43076888252Smrg	if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then
43176888252Smrg	  taglist="$taglist $tagname"
43276888252Smrg	  # Evaluate the configuration.
43376888252Smrg	  eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`"
43476888252Smrg	else
43576888252Smrg	  $echo "$progname: ignoring unknown tag $tagname" 1>&2
43676888252Smrg	fi
43776888252Smrg	;;
43876888252Smrg      esac
43976888252Smrg      ;;
44076888252Smrg    *)
44176888252Smrg      eval "$prev=\$arg"
44276888252Smrg      ;;
44376888252Smrg    esac
44476888252Smrg
44576888252Smrg    prev=
44676888252Smrg    prevopt=
44776888252Smrg    continue
44876888252Smrg  fi
44976888252Smrg
45076888252Smrg  # Have we seen a non-optional argument yet?
45176888252Smrg  case $arg in
45276888252Smrg  --help)
45376888252Smrg    show_help=yes
45476888252Smrg    ;;
45576888252Smrg
45676888252Smrg  --version)
45776888252Smrg    $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
45876888252Smrg    $echo
45976888252Smrg    $echo "Copyright (C) 2005  Free Software Foundation, Inc."
46076888252Smrg    $echo "This is free software; see the source for copying conditions.  There is NO"
46176888252Smrg    $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
46276888252Smrg    exit $?
46376888252Smrg    ;;
46476888252Smrg
46576888252Smrg  --config)
46676888252Smrg    ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath
46776888252Smrg    # Now print the configurations for the tags.
46876888252Smrg    for tagname in $taglist; do
46976888252Smrg      ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
47076888252Smrg    done
47176888252Smrg    exit $?
47276888252Smrg    ;;
47376888252Smrg
47476888252Smrg  --debug)
47576888252Smrg    $echo "$progname: enabling shell trace mode"
47676888252Smrg    set -x
47776888252Smrg    preserve_args="$preserve_args $arg"
47876888252Smrg    ;;
47976888252Smrg
48076888252Smrg  --dry-run | -n)
48176888252Smrg    run=:
48276888252Smrg    ;;
48376888252Smrg
48476888252Smrg  --features)
48576888252Smrg    $echo "host: $host"
48676888252Smrg    if test "$build_libtool_libs" = yes; then
48776888252Smrg      $echo "enable shared libraries"
48876888252Smrg    else
48976888252Smrg      $echo "disable shared libraries"
49076888252Smrg    fi
49176888252Smrg    if test "$build_old_libs" = yes; then
49276888252Smrg      $echo "enable static libraries"
49376888252Smrg    else
49476888252Smrg      $echo "disable static libraries"
49576888252Smrg    fi
49676888252Smrg    exit $?
49776888252Smrg    ;;
49876888252Smrg
49976888252Smrg  --finish) mode="finish" ;;
50076888252Smrg
50176888252Smrg  --mode) prevopt="--mode" prev=mode ;;
50276888252Smrg  --mode=*) mode="$optarg" ;;
50376888252Smrg
50476888252Smrg  --preserve-dup-deps) duplicate_deps="yes" ;;
50576888252Smrg
50676888252Smrg  --quiet | --silent)
50776888252Smrg    show=:
50876888252Smrg    preserve_args="$preserve_args $arg"
50976888252Smrg    ;;
51076888252Smrg
51176888252Smrg  --tag)
51276888252Smrg    prevopt="--tag"
51376888252Smrg    prev=tag
51476888252Smrg    preserve_args="$preserve_args --tag"
51576888252Smrg    ;;
51676888252Smrg  --tag=*)
51776888252Smrg    set tag "$optarg" ${1+"$@"}
51876888252Smrg    shift
51976888252Smrg    prev=tag
52076888252Smrg    preserve_args="$preserve_args --tag"
52176888252Smrg    ;;
52276888252Smrg
52376888252Smrg  -dlopen)
52476888252Smrg    prevopt="-dlopen"
52576888252Smrg    prev=execute_dlfiles
52676888252Smrg    ;;
52776888252Smrg
52876888252Smrg  -*)
52976888252Smrg    $echo "$modename: unrecognized option \`$arg'" 1>&2
53076888252Smrg    $echo "$help" 1>&2
53176888252Smrg    exit $EXIT_FAILURE
53276888252Smrg    ;;
53376888252Smrg
53476888252Smrg  *)
53576888252Smrg    nonopt="$arg"
53676888252Smrg    break
53776888252Smrg    ;;
53876888252Smrg  esac
53976888252Smrgdone
54076888252Smrg
54176888252Smrgif test -n "$prevopt"; then
54276888252Smrg  $echo "$modename: option \`$prevopt' requires an argument" 1>&2
54376888252Smrg  $echo "$help" 1>&2
54476888252Smrg  exit $EXIT_FAILURE
54576888252Smrgfi
54676888252Smrg
54776888252Smrgcase $disable_libs in
54876888252Smrgno) 
54976888252Smrg  ;;
55076888252Smrgshared)
55176888252Smrg  build_libtool_libs=no
55276888252Smrg  build_old_libs=yes
55376888252Smrg  ;;
55476888252Smrgstatic)
55576888252Smrg  build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
55676888252Smrg  ;;
55776888252Smrgesac
55876888252Smrg
55976888252Smrg# If this variable is set in any of the actions, the command in it
56076888252Smrg# will be execed at the end.  This prevents here-documents from being
56176888252Smrg# left over by shells.
56276888252Smrgexec_cmd=
56376888252Smrg
56476888252Smrgif test -z "$show_help"; then
56576888252Smrg
56676888252Smrg  # Infer the operation mode.
56776888252Smrg  if test -z "$mode"; then
56876888252Smrg    $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
56976888252Smrg    $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2
57076888252Smrg    case $nonopt in
57176888252Smrg    *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
57276888252Smrg      mode=link
57376888252Smrg      for arg
57476888252Smrg      do
57576888252Smrg	case $arg in
57676888252Smrg	-c)
57776888252Smrg	   mode=compile
57876888252Smrg	   break
57976888252Smrg	   ;;
58076888252Smrg	esac
58176888252Smrg      done
58276888252Smrg      ;;
58376888252Smrg    *db | *dbx | *strace | *truss)
58476888252Smrg      mode=execute
58576888252Smrg      ;;
58676888252Smrg    *install*|cp|mv)
58776888252Smrg      mode=install
58876888252Smrg      ;;
58976888252Smrg    *rm)
59076888252Smrg      mode=uninstall
59176888252Smrg      ;;
59276888252Smrg    *)
59376888252Smrg      # If we have no mode, but dlfiles were specified, then do execute mode.
59476888252Smrg      test -n "$execute_dlfiles" && mode=execute
59576888252Smrg
59676888252Smrg      # Just use the default operation mode.
59776888252Smrg      if test -z "$mode"; then
59876888252Smrg	if test -n "$nonopt"; then
59976888252Smrg	  $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
60076888252Smrg	else
60176888252Smrg	  $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
60276888252Smrg	fi
60376888252Smrg      fi
60476888252Smrg      ;;
60576888252Smrg    esac
60676888252Smrg  fi
60776888252Smrg
60876888252Smrg  # Only execute mode is allowed to have -dlopen flags.
60976888252Smrg  if test -n "$execute_dlfiles" && test "$mode" != execute; then
61076888252Smrg    $echo "$modename: unrecognized option \`-dlopen'" 1>&2
61176888252Smrg    $echo "$help" 1>&2
61276888252Smrg    exit $EXIT_FAILURE
61376888252Smrg  fi
61476888252Smrg
61576888252Smrg  # Change the help message to a mode-specific one.
61676888252Smrg  generic_help="$help"
61776888252Smrg  help="Try \`$modename --help --mode=$mode' for more information."
61876888252Smrg
61976888252Smrg  # These modes are in order of execution frequency so that they run quickly.
62076888252Smrg  case $mode in
62176888252Smrg  # libtool compile mode
62276888252Smrg  compile)
62376888252Smrg    modename="$modename: compile"
62476888252Smrg    # Get the compilation command and the source file.
62576888252Smrg    base_compile=
62676888252Smrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
62776888252Smrg    suppress_opt=yes
62876888252Smrg    suppress_output=
62976888252Smrg    arg_mode=normal
63076888252Smrg    libobj=
63176888252Smrg    later=
63276888252Smrg
63376888252Smrg    for arg
63476888252Smrg    do
63576888252Smrg      case $arg_mode in
63676888252Smrg      arg  )
63776888252Smrg	# do not "continue".  Instead, add this to base_compile
63876888252Smrg	lastarg="$arg"
63976888252Smrg	arg_mode=normal
64076888252Smrg	;;
64176888252Smrg
64276888252Smrg      target )
64376888252Smrg	libobj="$arg"
64476888252Smrg	arg_mode=normal
64576888252Smrg	continue
64676888252Smrg	;;
64776888252Smrg
64876888252Smrg      normal )
64976888252Smrg	# Accept any command-line options.
65076888252Smrg	case $arg in
65176888252Smrg	-o)
65276888252Smrg	  if test -n "$libobj" ; then
65376888252Smrg	    $echo "$modename: you cannot specify \`-o' more than once" 1>&2
65476888252Smrg	    exit $EXIT_FAILURE
65576888252Smrg	  fi
65676888252Smrg	  arg_mode=target
65776888252Smrg	  continue
65876888252Smrg	  ;;
65976888252Smrg
66076888252Smrg	-static | -prefer-pic | -prefer-non-pic)
66176888252Smrg	  later="$later $arg"
66276888252Smrg	  continue
66376888252Smrg	  ;;
66476888252Smrg
66576888252Smrg	-no-suppress)
66676888252Smrg	  suppress_opt=no
66776888252Smrg	  continue
66876888252Smrg	  ;;
66976888252Smrg
67076888252Smrg	-Xcompiler)
67176888252Smrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
67276888252Smrg	  continue      #  The current "srcfile" will either be retained or
67376888252Smrg	  ;;            #  replaced later.  I would guess that would be a bug.
67476888252Smrg
67576888252Smrg	-Wc,*)
67676888252Smrg	  args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
67776888252Smrg	  lastarg=
67876888252Smrg	  save_ifs="$IFS"; IFS=','
67976888252Smrg 	  for arg in $args; do
68076888252Smrg	    IFS="$save_ifs"
68176888252Smrg
68276888252Smrg	    # Double-quote args containing other shell metacharacters.
68376888252Smrg	    # Many Bourne shells cannot handle close brackets correctly
68476888252Smrg	    # in scan sets, so we specify it separately.
68576888252Smrg	    case $arg in
68676888252Smrg	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
68776888252Smrg	      arg="\"$arg\""
68876888252Smrg	      ;;
68976888252Smrg	    esac
69076888252Smrg	    lastarg="$lastarg $arg"
69176888252Smrg	  done
69276888252Smrg	  IFS="$save_ifs"
69376888252Smrg	  lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
69476888252Smrg
69576888252Smrg	  # Add the arguments to base_compile.
69676888252Smrg	  base_compile="$base_compile $lastarg"
69776888252Smrg	  continue
69876888252Smrg	  ;;
69976888252Smrg
70076888252Smrg	* )
70176888252Smrg	  # Accept the current argument as the source file.
70276888252Smrg	  # The previous "srcfile" becomes the current argument.
70376888252Smrg	  #
70476888252Smrg	  lastarg="$srcfile"
70576888252Smrg	  srcfile="$arg"
70676888252Smrg	  ;;
70776888252Smrg	esac  #  case $arg
70876888252Smrg	;;
70976888252Smrg      esac    #  case $arg_mode
71076888252Smrg
71176888252Smrg      # Aesthetically quote the previous argument.
71276888252Smrg      lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
71376888252Smrg
71476888252Smrg      case $lastarg in
71576888252Smrg      # Double-quote args containing other shell metacharacters.
71676888252Smrg      # Many Bourne shells cannot handle close brackets correctly
71776888252Smrg      # in scan sets, and some SunOS ksh mistreat backslash-escaping
71876888252Smrg      # in scan sets (worked around with variable expansion),
71976888252Smrg      # and furthermore cannot handle '|' '&' '(' ')' in scan sets 
72076888252Smrg      # at all, so we specify them separately.
72176888252Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
72276888252Smrg	lastarg="\"$lastarg\""
72376888252Smrg	;;
72476888252Smrg      esac
72576888252Smrg
72676888252Smrg      base_compile="$base_compile $lastarg"
72776888252Smrg    done # for arg
72876888252Smrg
72976888252Smrg    case $arg_mode in
73076888252Smrg    arg)
73176888252Smrg      $echo "$modename: you must specify an argument for -Xcompile"
73276888252Smrg      exit $EXIT_FAILURE
73376888252Smrg      ;;
73476888252Smrg    target)
73576888252Smrg      $echo "$modename: you must specify a target with \`-o'" 1>&2
73676888252Smrg      exit $EXIT_FAILURE
73776888252Smrg      ;;
73876888252Smrg    *)
73976888252Smrg      # Get the name of the library object.
74076888252Smrg      [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
74176888252Smrg      ;;
74276888252Smrg    esac
74376888252Smrg
74476888252Smrg    # Recognize several different file suffixes.
74576888252Smrg    # If the user specifies -o file.o, it is replaced with file.lo
74676888252Smrg    xform='[cCFSifmso]'
74776888252Smrg    case $libobj in
74876888252Smrg    *.ada) xform=ada ;;
74976888252Smrg    *.adb) xform=adb ;;
75076888252Smrg    *.ads) xform=ads ;;
75176888252Smrg    *.asm) xform=asm ;;
75276888252Smrg    *.c++) xform=c++ ;;
75376888252Smrg    *.cc) xform=cc ;;
75476888252Smrg    *.ii) xform=ii ;;
75576888252Smrg    *.class) xform=class ;;
75676888252Smrg    *.cpp) xform=cpp ;;
75776888252Smrg    *.cxx) xform=cxx ;;
75876888252Smrg    *.f90) xform=f90 ;;
75976888252Smrg    *.for) xform=for ;;
76076888252Smrg    *.java) xform=java ;;
76176888252Smrg    esac
76276888252Smrg
76376888252Smrg    libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
76476888252Smrg
76576888252Smrg    case $libobj in
76676888252Smrg    *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
76776888252Smrg    *)
76876888252Smrg      $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
76976888252Smrg      exit $EXIT_FAILURE
77076888252Smrg      ;;
77176888252Smrg    esac
77276888252Smrg
77376888252Smrg    func_infer_tag $base_compile
77476888252Smrg
77576888252Smrg    for arg in $later; do
77676888252Smrg      case $arg in
77776888252Smrg      -static)
77876888252Smrg	build_old_libs=yes
77976888252Smrg	continue
78076888252Smrg	;;
78176888252Smrg
78276888252Smrg      -prefer-pic)
78376888252Smrg	pic_mode=yes
78476888252Smrg	continue
78576888252Smrg	;;
78676888252Smrg
78776888252Smrg      -prefer-non-pic)
78876888252Smrg	pic_mode=no
78976888252Smrg	continue
79076888252Smrg	;;
79176888252Smrg      esac
79276888252Smrg    done
79376888252Smrg
79476888252Smrg    qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"`
79576888252Smrg    case $qlibobj in
79676888252Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
79776888252Smrg	qlibobj="\"$qlibobj\"" ;;
79876888252Smrg    esac
79976888252Smrg    test "X$libobj" != "X$qlibobj" \
80076888252Smrg	&& $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"' 	&()|`$[]' \
80176888252Smrg	&& $echo "$modename: libobj name \`$libobj' may not contain shell special characters."
80276888252Smrg    objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
80376888252Smrg    xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
80476888252Smrg    if test "X$xdir" = "X$obj"; then
80576888252Smrg      xdir=
80676888252Smrg    else
80776888252Smrg      xdir=$xdir/
80876888252Smrg    fi
80976888252Smrg    lobj=${xdir}$objdir/$objname
81076888252Smrg
81176888252Smrg    if test -z "$base_compile"; then
81276888252Smrg      $echo "$modename: you must specify a compilation command" 1>&2
81376888252Smrg      $echo "$help" 1>&2
81476888252Smrg      exit $EXIT_FAILURE
81576888252Smrg    fi
81676888252Smrg
81776888252Smrg    # Delete any leftover library objects.
81876888252Smrg    if test "$build_old_libs" = yes; then
81976888252Smrg      removelist="$obj $lobj $libobj ${libobj}T"
82076888252Smrg    else
82176888252Smrg      removelist="$lobj $libobj ${libobj}T"
82276888252Smrg    fi
82376888252Smrg
82476888252Smrg    $run $rm $removelist
82576888252Smrg    trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
82676888252Smrg
82776888252Smrg    # On Cygwin there's no "real" PIC flag so we must build both object types
82876888252Smrg    case $host_os in
82976888252Smrg    cygwin* | mingw* | pw32* | os2*)
83076888252Smrg      pic_mode=default
83176888252Smrg      ;;
83276888252Smrg    esac
83376888252Smrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
83476888252Smrg      # non-PIC code in shared libraries is not supported
83576888252Smrg      pic_mode=default
83676888252Smrg    fi
83776888252Smrg
83876888252Smrg    # Calculate the filename of the output object if compiler does
83976888252Smrg    # not support -o with -c
84076888252Smrg    if test "$compiler_c_o" = no; then
84176888252Smrg      output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
84276888252Smrg      lockfile="$output_obj.lock"
84376888252Smrg      removelist="$removelist $output_obj $lockfile"
84476888252Smrg      trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
84576888252Smrg    else
84676888252Smrg      output_obj=
84776888252Smrg      need_locks=no
84876888252Smrg      lockfile=
84976888252Smrg    fi
85076888252Smrg
85176888252Smrg    # Lock this critical section if it is needed
85276888252Smrg    # We use this script file to make the link, it avoids creating a new file
85376888252Smrg    if test "$need_locks" = yes; then
85476888252Smrg      until $run ln "$progpath" "$lockfile" 2>/dev/null; do
85576888252Smrg	$show "Waiting for $lockfile to be removed"
85676888252Smrg	sleep 2
85776888252Smrg      done
85876888252Smrg    elif test "$need_locks" = warn; then
85976888252Smrg      if test -f "$lockfile"; then
86076888252Smrg	$echo "\
86176888252Smrg*** ERROR, $lockfile exists and contains:
86276888252Smrg`cat $lockfile 2>/dev/null`
86376888252Smrg
86476888252SmrgThis indicates that another process is trying to use the same
86576888252Smrgtemporary object file, and libtool could not work around it because
86676888252Smrgyour compiler does not support \`-c' and \`-o' together.  If you
86776888252Smrgrepeat this compilation, it may succeed, by chance, but you had better
86876888252Smrgavoid parallel builds (make -j) in this platform, or get a better
86976888252Smrgcompiler."
87076888252Smrg
87176888252Smrg	$run $rm $removelist
87276888252Smrg	exit $EXIT_FAILURE
87376888252Smrg      fi
87476888252Smrg      $echo "$srcfile" > "$lockfile"
87576888252Smrg    fi
87676888252Smrg
87776888252Smrg    if test -n "$fix_srcfile_path"; then
87876888252Smrg      eval srcfile=\"$fix_srcfile_path\"
87976888252Smrg    fi
88076888252Smrg    qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"`
88176888252Smrg    case $qsrcfile in
88276888252Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
88376888252Smrg      qsrcfile="\"$qsrcfile\"" ;;
88476888252Smrg    esac
88576888252Smrg
88676888252Smrg    $run $rm "$libobj" "${libobj}T"
88776888252Smrg
88876888252Smrg    # Create a libtool object file (analogous to a ".la" file),
88976888252Smrg    # but don't create it if we're doing a dry run.
89076888252Smrg    test -z "$run" && cat > ${libobj}T <<EOF
89176888252Smrg# $libobj - a libtool object file
89276888252Smrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
89376888252Smrg#
89476888252Smrg# Please DO NOT delete this file!
89576888252Smrg# It is necessary for linking the library.
89676888252Smrg
89776888252Smrg# Name of the PIC object.
89876888252SmrgEOF
89976888252Smrg
90076888252Smrg    # Only build a PIC object if we are building libtool libraries.
90176888252Smrg    if test "$build_libtool_libs" = yes; then
90276888252Smrg      # Without this assignment, base_compile gets emptied.
90376888252Smrg      fbsd_hideous_sh_bug=$base_compile
90476888252Smrg
90576888252Smrg      if test "$pic_mode" != no; then
90676888252Smrg	command="$base_compile $qsrcfile $pic_flag"
90776888252Smrg      else
90876888252Smrg	# Don't build PIC code
90976888252Smrg	command="$base_compile $qsrcfile"
91076888252Smrg      fi
91176888252Smrg
91276888252Smrg      if test ! -d "${xdir}$objdir"; then
91376888252Smrg	$show "$mkdir ${xdir}$objdir"
91476888252Smrg	$run $mkdir ${xdir}$objdir
91576888252Smrg	exit_status=$?
91676888252Smrg	if test "$exit_status" -ne 0 && test ! -d "${xdir}$objdir"; then
91776888252Smrg	  exit $exit_status
91876888252Smrg	fi
91976888252Smrg      fi
92076888252Smrg
92176888252Smrg      if test -z "$output_obj"; then
92276888252Smrg	# Place PIC objects in $objdir
92376888252Smrg	command="$command -o $lobj"
92476888252Smrg      fi
92576888252Smrg
92676888252Smrg      $run $rm "$lobj" "$output_obj"
92776888252Smrg
92876888252Smrg      $show "$command"
92976888252Smrg      if $run eval "$command"; then :
93076888252Smrg      else
93176888252Smrg	test -n "$output_obj" && $run $rm $removelist
93276888252Smrg	exit $EXIT_FAILURE
93376888252Smrg      fi
93476888252Smrg
93576888252Smrg      if test "$need_locks" = warn &&
93676888252Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
93776888252Smrg	$echo "\
93876888252Smrg*** ERROR, $lockfile contains:
93976888252Smrg`cat $lockfile 2>/dev/null`
94076888252Smrg
94176888252Smrgbut it should contain:
94276888252Smrg$srcfile
94376888252Smrg
94476888252SmrgThis indicates that another process is trying to use the same
94576888252Smrgtemporary object file, and libtool could not work around it because
94676888252Smrgyour compiler does not support \`-c' and \`-o' together.  If you
94776888252Smrgrepeat this compilation, it may succeed, by chance, but you had better
94876888252Smrgavoid parallel builds (make -j) in this platform, or get a better
94976888252Smrgcompiler."
95076888252Smrg
95176888252Smrg	$run $rm $removelist
95276888252Smrg	exit $EXIT_FAILURE
95376888252Smrg      fi
95476888252Smrg
95576888252Smrg      # Just move the object if needed, then go on to compile the next one
95676888252Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
95776888252Smrg	$show "$mv $output_obj $lobj"
95876888252Smrg	if $run $mv $output_obj $lobj; then :
95976888252Smrg	else
96076888252Smrg	  error=$?
96176888252Smrg	  $run $rm $removelist
96276888252Smrg	  exit $error
96376888252Smrg	fi
96476888252Smrg      fi
96576888252Smrg
96676888252Smrg      # Append the name of the PIC object to the libtool object file.
96776888252Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
96876888252Smrgpic_object='$objdir/$objname'
96976888252Smrg
97076888252SmrgEOF
97176888252Smrg
97276888252Smrg      # Allow error messages only from the first compilation.
97376888252Smrg      if test "$suppress_opt" = yes; then
97476888252Smrg        suppress_output=' >/dev/null 2>&1'
97576888252Smrg      fi
97676888252Smrg    else
97776888252Smrg      # No PIC object so indicate it doesn't exist in the libtool
97876888252Smrg      # object file.
97976888252Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
98076888252Smrgpic_object=none
98176888252Smrg
98276888252SmrgEOF
98376888252Smrg    fi
98476888252Smrg
98576888252Smrg    # Only build a position-dependent object if we build old libraries.
98676888252Smrg    if test "$build_old_libs" = yes; then
98776888252Smrg      if test "$pic_mode" != yes; then
98876888252Smrg	# Don't build PIC code
98976888252Smrg	command="$base_compile $qsrcfile"
99076888252Smrg      else
99176888252Smrg	command="$base_compile $qsrcfile $pic_flag"
99276888252Smrg      fi
99376888252Smrg      if test "$compiler_c_o" = yes; then
99476888252Smrg	command="$command -o $obj"
99576888252Smrg      fi
99676888252Smrg
99776888252Smrg      # Suppress compiler output if we already did a PIC compilation.
99876888252Smrg      command="$command$suppress_output"
99976888252Smrg      $run $rm "$obj" "$output_obj"
100076888252Smrg      $show "$command"
100176888252Smrg      if $run eval "$command"; then :
100276888252Smrg      else
100376888252Smrg	$run $rm $removelist
100476888252Smrg	exit $EXIT_FAILURE
100576888252Smrg      fi
100676888252Smrg
100776888252Smrg      if test "$need_locks" = warn &&
100876888252Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
100976888252Smrg	$echo "\
101076888252Smrg*** ERROR, $lockfile contains:
101176888252Smrg`cat $lockfile 2>/dev/null`
101276888252Smrg
101376888252Smrgbut it should contain:
101476888252Smrg$srcfile
101576888252Smrg
101676888252SmrgThis indicates that another process is trying to use the same
101776888252Smrgtemporary object file, and libtool could not work around it because
101876888252Smrgyour compiler does not support \`-c' and \`-o' together.  If you
101976888252Smrgrepeat this compilation, it may succeed, by chance, but you had better
102076888252Smrgavoid parallel builds (make -j) in this platform, or get a better
102176888252Smrgcompiler."
102276888252Smrg
102376888252Smrg	$run $rm $removelist
102476888252Smrg	exit $EXIT_FAILURE
102576888252Smrg      fi
102676888252Smrg
102776888252Smrg      # Just move the object if needed
102876888252Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
102976888252Smrg	$show "$mv $output_obj $obj"
103076888252Smrg	if $run $mv $output_obj $obj; then :
103176888252Smrg	else
103276888252Smrg	  error=$?
103376888252Smrg	  $run $rm $removelist
103476888252Smrg	  exit $error
103576888252Smrg	fi
103676888252Smrg      fi
103776888252Smrg
103876888252Smrg      # Append the name of the non-PIC object the libtool object file.
103976888252Smrg      # Only append if the libtool object file exists.
104076888252Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
104176888252Smrg# Name of the non-PIC object.
104276888252Smrgnon_pic_object='$objname'
104376888252Smrg
104476888252SmrgEOF
104576888252Smrg    else
104676888252Smrg      # Append the name of the non-PIC object the libtool object file.
104776888252Smrg      # Only append if the libtool object file exists.
104876888252Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
104976888252Smrg# Name of the non-PIC object.
105076888252Smrgnon_pic_object=none
105176888252Smrg
105276888252SmrgEOF
105376888252Smrg    fi
105476888252Smrg
105576888252Smrg    $run $mv "${libobj}T" "${libobj}"
105676888252Smrg
105776888252Smrg    # Unlock the critical section if it was locked
105876888252Smrg    if test "$need_locks" != no; then
105976888252Smrg      $run $rm "$lockfile"
106076888252Smrg    fi
106176888252Smrg
106276888252Smrg    exit $EXIT_SUCCESS
106376888252Smrg    ;;
106476888252Smrg
106576888252Smrg  # libtool link mode
106676888252Smrg  link | relink)
106776888252Smrg    modename="$modename: link"
106876888252Smrg    case $host in
106976888252Smrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
107076888252Smrg      # It is impossible to link a dll without this setting, and
107176888252Smrg      # we shouldn't force the makefile maintainer to figure out
107276888252Smrg      # which system we are compiling for in order to pass an extra
107376888252Smrg      # flag for every libtool invocation.
107476888252Smrg      # allow_undefined=no
107576888252Smrg
107676888252Smrg      # FIXME: Unfortunately, there are problems with the above when trying
107776888252Smrg      # to make a dll which has undefined symbols, in which case not
107876888252Smrg      # even a static library is built.  For now, we need to specify
107976888252Smrg      # -no-undefined on the libtool link line when we can be certain
108076888252Smrg      # that all symbols are satisfied, otherwise we get a static library.
108176888252Smrg      allow_undefined=yes
108276888252Smrg      ;;
108376888252Smrg    *)
108476888252Smrg      allow_undefined=yes
108576888252Smrg      ;;
108676888252Smrg    esac
108776888252Smrg    libtool_args="$nonopt"
108876888252Smrg    base_compile="$nonopt $@"
108976888252Smrg    compile_command="$nonopt"
109076888252Smrg    finalize_command="$nonopt"
109176888252Smrg
109276888252Smrg    compile_rpath=
109376888252Smrg    finalize_rpath=
109476888252Smrg    compile_shlibpath=
109576888252Smrg    finalize_shlibpath=
109676888252Smrg    convenience=
109776888252Smrg    old_convenience=
109876888252Smrg    deplibs=
109976888252Smrg    old_deplibs=
110076888252Smrg    compiler_flags=
110176888252Smrg    linker_flags=
110276888252Smrg    dllsearchpath=
110376888252Smrg    lib_search_path=`pwd`
110476888252Smrg    inst_prefix_dir=
110576888252Smrg
110676888252Smrg    avoid_version=no
110776888252Smrg    dlfiles=
110876888252Smrg    dlprefiles=
110976888252Smrg    dlself=no
111076888252Smrg    export_dynamic=no
111176888252Smrg    export_symbols=
111276888252Smrg    export_symbols_regex=
111376888252Smrg    generated=
111476888252Smrg    libobjs=
111576888252Smrg    ltlibs=
111676888252Smrg    module=no
111776888252Smrg    no_install=no
111876888252Smrg    objs=
111976888252Smrg    non_pic_objects=
112076888252Smrg    notinst_path= # paths that contain not-installed libtool libraries
112176888252Smrg    precious_files_regex=
112276888252Smrg    prefer_static_libs=no
112376888252Smrg    preload=no
112476888252Smrg    prev=
112576888252Smrg    prevarg=
112676888252Smrg    release=
112776888252Smrg    rpath=
112876888252Smrg    xrpath=
112976888252Smrg    perm_rpath=
113076888252Smrg    temp_rpath=
113176888252Smrg    thread_safe=no
113276888252Smrg    vinfo=
113376888252Smrg    vinfo_number=no
113476888252Smrg
113576888252Smrg    func_infer_tag $base_compile
113676888252Smrg
113776888252Smrg    # We need to know -static, to get the right output filenames.
113876888252Smrg    for arg
113976888252Smrg    do
114076888252Smrg      case $arg in
114176888252Smrg      -all-static | -static)
114276888252Smrg	if test "X$arg" = "X-all-static"; then
114376888252Smrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
114476888252Smrg	    $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
114576888252Smrg	  fi
114676888252Smrg	  if test -n "$link_static_flag"; then
114776888252Smrg	    dlopen_self=$dlopen_self_static
114876888252Smrg	  fi
114976888252Smrg	  prefer_static_libs=yes
115076888252Smrg	else
115176888252Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
115276888252Smrg	    dlopen_self=$dlopen_self_static
115376888252Smrg	  fi
115476888252Smrg	  prefer_static_libs=built
115576888252Smrg	fi
115676888252Smrg	build_libtool_libs=no
115776888252Smrg	build_old_libs=yes
115876888252Smrg	break
115976888252Smrg	;;
116076888252Smrg      esac
116176888252Smrg    done
116276888252Smrg
116376888252Smrg    # See if our shared archives depend on static archives.
116476888252Smrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
116576888252Smrg
116676888252Smrg    # Go through the arguments, transforming them on the way.
116776888252Smrg    while test "$#" -gt 0; do
116876888252Smrg      arg="$1"
116976888252Smrg      shift
117076888252Smrg      case $arg in
117176888252Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
117276888252Smrg	qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test
117376888252Smrg	;;
117476888252Smrg      *) qarg=$arg ;;
117576888252Smrg      esac
117676888252Smrg      libtool_args="$libtool_args $qarg"
117776888252Smrg
117876888252Smrg      # If the previous option needs an argument, assign it.
117976888252Smrg      if test -n "$prev"; then
118076888252Smrg	case $prev in
118176888252Smrg	output)
118276888252Smrg	  compile_command="$compile_command @OUTPUT@"
118376888252Smrg	  finalize_command="$finalize_command @OUTPUT@"
118476888252Smrg	  ;;
118576888252Smrg	esac
118676888252Smrg
118776888252Smrg	case $prev in
118876888252Smrg	dlfiles|dlprefiles)
118976888252Smrg	  if test "$preload" = no; then
119076888252Smrg	    # Add the symbol object into the linking commands.
119176888252Smrg	    compile_command="$compile_command @SYMFILE@"
119276888252Smrg	    finalize_command="$finalize_command @SYMFILE@"
119376888252Smrg	    preload=yes
119476888252Smrg	  fi
119576888252Smrg	  case $arg in
119676888252Smrg	  *.la | *.lo) ;;  # We handle these cases below.
119776888252Smrg	  force)
119876888252Smrg	    if test "$dlself" = no; then
119976888252Smrg	      dlself=needless
120076888252Smrg	      export_dynamic=yes
120176888252Smrg	    fi
120276888252Smrg	    prev=
120376888252Smrg	    continue
120476888252Smrg	    ;;
120576888252Smrg	  self)
120676888252Smrg	    if test "$prev" = dlprefiles; then
120776888252Smrg	      dlself=yes
120876888252Smrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
120976888252Smrg	      dlself=yes
121076888252Smrg	    else
121176888252Smrg	      dlself=needless
121276888252Smrg	      export_dynamic=yes
121376888252Smrg	    fi
121476888252Smrg	    prev=
121576888252Smrg	    continue
121676888252Smrg	    ;;
121776888252Smrg	  *)
121876888252Smrg	    if test "$prev" = dlfiles; then
121976888252Smrg	      dlfiles="$dlfiles $arg"
122076888252Smrg	    else
122176888252Smrg	      dlprefiles="$dlprefiles $arg"
122276888252Smrg	    fi
122376888252Smrg	    prev=
122476888252Smrg	    continue
122576888252Smrg	    ;;
122676888252Smrg	  esac
122776888252Smrg	  ;;
122876888252Smrg	expsyms)
122976888252Smrg	  export_symbols="$arg"
123076888252Smrg	  if test ! -f "$arg"; then
123176888252Smrg	    $echo "$modename: symbol file \`$arg' does not exist"
123276888252Smrg	    exit $EXIT_FAILURE
123376888252Smrg	  fi
123476888252Smrg	  prev=
123576888252Smrg	  continue
123676888252Smrg	  ;;
123776888252Smrg	expsyms_regex)
123876888252Smrg	  export_symbols_regex="$arg"
123976888252Smrg	  prev=
124076888252Smrg	  continue
124176888252Smrg	  ;;
124276888252Smrg	inst_prefix)
124376888252Smrg	  inst_prefix_dir="$arg"
124476888252Smrg	  prev=
124576888252Smrg	  continue
124676888252Smrg	  ;;
124776888252Smrg	precious_regex)
124876888252Smrg	  precious_files_regex="$arg"
124976888252Smrg	  prev=
125076888252Smrg	  continue
125176888252Smrg	  ;;
125276888252Smrg	release)
125376888252Smrg	  release="-$arg"
125476888252Smrg	  prev=
125576888252Smrg	  continue
125676888252Smrg	  ;;
125776888252Smrg	objectlist)
125876888252Smrg	  if test -f "$arg"; then
125976888252Smrg	    save_arg=$arg
126076888252Smrg	    moreargs=
126176888252Smrg	    for fil in `cat $save_arg`
126276888252Smrg	    do
126376888252Smrg#	      moreargs="$moreargs $fil"
126476888252Smrg	      arg=$fil
126576888252Smrg	      # A libtool-controlled object.
126676888252Smrg
126776888252Smrg	      # Check to see that this really is a libtool object.
126876888252Smrg	      if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
126976888252Smrg		pic_object=
127076888252Smrg		non_pic_object=
127176888252Smrg
127276888252Smrg		# Read the .lo file
127376888252Smrg		# If there is no directory component, then add one.
127476888252Smrg		case $arg in
127576888252Smrg		*/* | *\\*) . $arg ;;
127676888252Smrg		*) . ./$arg ;;
127776888252Smrg		esac
127876888252Smrg
127976888252Smrg		if test -z "$pic_object" || \
128076888252Smrg		   test -z "$non_pic_object" ||
128176888252Smrg		   test "$pic_object" = none && \
128276888252Smrg		   test "$non_pic_object" = none; then
128376888252Smrg		  $echo "$modename: cannot find name of object for \`$arg'" 1>&2
128476888252Smrg		  exit $EXIT_FAILURE
128576888252Smrg		fi
128676888252Smrg
128776888252Smrg		# Extract subdirectory from the argument.
128876888252Smrg		xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
128976888252Smrg		if test "X$xdir" = "X$arg"; then
129076888252Smrg		  xdir=
129176888252Smrg		else
129276888252Smrg		  xdir="$xdir/"
129376888252Smrg		fi
129476888252Smrg
129576888252Smrg		if test "$pic_object" != none; then
129676888252Smrg		  # Prepend the subdirectory the object is found in.
129776888252Smrg		  pic_object="$xdir$pic_object"
129876888252Smrg
129976888252Smrg		  if test "$prev" = dlfiles; then
130076888252Smrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
130176888252Smrg		      dlfiles="$dlfiles $pic_object"
130276888252Smrg		      prev=
130376888252Smrg		      continue
130476888252Smrg		    else
130576888252Smrg		      # If libtool objects are unsupported, then we need to preload.
130676888252Smrg		      prev=dlprefiles
130776888252Smrg		    fi
130876888252Smrg		  fi
130976888252Smrg
131076888252Smrg		  # CHECK ME:  I think I busted this.  -Ossama
131176888252Smrg		  if test "$prev" = dlprefiles; then
131276888252Smrg		    # Preload the old-style object.
131376888252Smrg		    dlprefiles="$dlprefiles $pic_object"
131476888252Smrg		    prev=
131576888252Smrg		  fi
131676888252Smrg
131776888252Smrg		  # A PIC object.
131876888252Smrg		  libobjs="$libobjs $pic_object"
131976888252Smrg		  arg="$pic_object"
132076888252Smrg		fi
132176888252Smrg
132276888252Smrg		# Non-PIC object.
132376888252Smrg		if test "$non_pic_object" != none; then
132476888252Smrg		  # Prepend the subdirectory the object is found in.
132576888252Smrg		  non_pic_object="$xdir$non_pic_object"
132676888252Smrg
132776888252Smrg		  # A standard non-PIC object
132876888252Smrg		  non_pic_objects="$non_pic_objects $non_pic_object"
132976888252Smrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
133076888252Smrg		    arg="$non_pic_object"
133176888252Smrg		  fi
133276888252Smrg		else
133376888252Smrg		  # If the PIC object exists, use it instead.
133476888252Smrg		  # $xdir was prepended to $pic_object above.
133576888252Smrg		  non_pic_object="$pic_object"
133676888252Smrg		  non_pic_objects="$non_pic_objects $non_pic_object"
133776888252Smrg		fi
133876888252Smrg	      else
133976888252Smrg		# Only an error if not doing a dry-run.
134076888252Smrg		if test -z "$run"; then
134176888252Smrg		  $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
134276888252Smrg		  exit $EXIT_FAILURE
134376888252Smrg		else
134476888252Smrg		  # Dry-run case.
134576888252Smrg
134676888252Smrg		  # Extract subdirectory from the argument.
134776888252Smrg		  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
134876888252Smrg		  if test "X$xdir" = "X$arg"; then
134976888252Smrg		    xdir=
135076888252Smrg		  else
135176888252Smrg		    xdir="$xdir/"
135276888252Smrg		  fi
135376888252Smrg
135476888252Smrg		  pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
135576888252Smrg		  non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
135676888252Smrg		  libobjs="$libobjs $pic_object"
135776888252Smrg		  non_pic_objects="$non_pic_objects $non_pic_object"
135876888252Smrg		fi
135976888252Smrg	      fi
136076888252Smrg	    done
136176888252Smrg	  else
136276888252Smrg	    $echo "$modename: link input file \`$save_arg' does not exist"
136376888252Smrg	    exit $EXIT_FAILURE
136476888252Smrg	  fi
136576888252Smrg	  arg=$save_arg
136676888252Smrg	  prev=
136776888252Smrg	  continue
136876888252Smrg	  ;;
136976888252Smrg	rpath | xrpath)
137076888252Smrg	  # We need an absolute path.
137176888252Smrg	  case $arg in
137276888252Smrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
137376888252Smrg	  *)
137476888252Smrg	    $echo "$modename: only absolute run-paths are allowed" 1>&2
137576888252Smrg	    exit $EXIT_FAILURE
137676888252Smrg	    ;;
137776888252Smrg	  esac
137876888252Smrg	  if test "$prev" = rpath; then
137976888252Smrg	    case "$rpath " in
138076888252Smrg	    *" $arg "*) ;;
138176888252Smrg	    *) rpath="$rpath $arg" ;;
138276888252Smrg	    esac
138376888252Smrg	  else
138476888252Smrg	    case "$xrpath " in
138576888252Smrg	    *" $arg "*) ;;
138676888252Smrg	    *) xrpath="$xrpath $arg" ;;
138776888252Smrg	    esac
138876888252Smrg	  fi
138976888252Smrg	  prev=
139076888252Smrg	  continue
139176888252Smrg	  ;;
139276888252Smrg	xcompiler)
139376888252Smrg	  compiler_flags="$compiler_flags $qarg"
139476888252Smrg	  prev=
139576888252Smrg	  compile_command="$compile_command $qarg"
139676888252Smrg	  finalize_command="$finalize_command $qarg"
139776888252Smrg	  continue
139876888252Smrg	  ;;
139976888252Smrg	xlinker)
140076888252Smrg	  linker_flags="$linker_flags $qarg"
140176888252Smrg	  compiler_flags="$compiler_flags $wl$qarg"
140276888252Smrg	  prev=
140376888252Smrg	  compile_command="$compile_command $wl$qarg"
140476888252Smrg	  finalize_command="$finalize_command $wl$qarg"
140576888252Smrg	  continue
140676888252Smrg	  ;;
140776888252Smrg	xcclinker)
140876888252Smrg	  linker_flags="$linker_flags $qarg"
140976888252Smrg	  compiler_flags="$compiler_flags $qarg"
141076888252Smrg	  prev=
141176888252Smrg	  compile_command="$compile_command $qarg"
141276888252Smrg	  finalize_command="$finalize_command $qarg"
141376888252Smrg	  continue
141476888252Smrg	  ;;
141576888252Smrg	shrext)
141676888252Smrg  	  shrext_cmds="$arg"
141776888252Smrg	  prev=
141876888252Smrg	  continue
141976888252Smrg	  ;;
142076888252Smrg	darwin_framework|darwin_framework_skip)
142176888252Smrg	  test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg"
142276888252Smrg	  compile_command="$compile_command $arg"
142376888252Smrg	  finalize_command="$finalize_command $arg"
142476888252Smrg	  prev=
142576888252Smrg	  continue
142676888252Smrg	  ;;
142776888252Smrg	*)
142876888252Smrg	  eval "$prev=\"\$arg\""
142976888252Smrg	  prev=
143076888252Smrg	  continue
143176888252Smrg	  ;;
143276888252Smrg	esac
143376888252Smrg      fi # test -n "$prev"
143476888252Smrg
143576888252Smrg      prevarg="$arg"
143676888252Smrg
143776888252Smrg      case $arg in
143876888252Smrg      -all-static)
143976888252Smrg	if test -n "$link_static_flag"; then
144076888252Smrg	  compile_command="$compile_command $link_static_flag"
144176888252Smrg	  finalize_command="$finalize_command $link_static_flag"
144276888252Smrg	fi
144376888252Smrg	continue
144476888252Smrg	;;
144576888252Smrg
144676888252Smrg      -allow-undefined)
144776888252Smrg	# FIXME: remove this flag sometime in the future.
144876888252Smrg	$echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
144976888252Smrg	continue
145076888252Smrg	;;
145176888252Smrg
145276888252Smrg      -avoid-version)
145376888252Smrg	avoid_version=yes
145476888252Smrg	continue
145576888252Smrg	;;
145676888252Smrg
145776888252Smrg      -dlopen)
145876888252Smrg	prev=dlfiles
145976888252Smrg	continue
146076888252Smrg	;;
146176888252Smrg
146276888252Smrg      -dlpreopen)
146376888252Smrg	prev=dlprefiles
146476888252Smrg	continue
146576888252Smrg	;;
146676888252Smrg
146776888252Smrg      -export-dynamic)
146876888252Smrg	export_dynamic=yes
146976888252Smrg	continue
147076888252Smrg	;;
147176888252Smrg
147276888252Smrg      -export-symbols | -export-symbols-regex)
147376888252Smrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
147476888252Smrg	  $echo "$modename: more than one -exported-symbols argument is not allowed"
147576888252Smrg	  exit $EXIT_FAILURE
147676888252Smrg	fi
147776888252Smrg	if test "X$arg" = "X-export-symbols"; then
147876888252Smrg	  prev=expsyms
147976888252Smrg	else
148076888252Smrg	  prev=expsyms_regex
148176888252Smrg	fi
148276888252Smrg	continue
148376888252Smrg	;;
148476888252Smrg
148576888252Smrg      -framework|-arch|-isysroot)
148676888252Smrg	case " $CC " in
148776888252Smrg	  *" ${arg} ${1} "* | *" ${arg}	${1} "*) 
148876888252Smrg		prev=darwin_framework_skip ;;
148976888252Smrg	  *) compiler_flags="$compiler_flags $arg"
149076888252Smrg	     prev=darwin_framework ;;
149176888252Smrg	esac
149276888252Smrg	compile_command="$compile_command $arg"
149376888252Smrg	finalize_command="$finalize_command $arg"
149476888252Smrg	continue
149576888252Smrg	;;
149676888252Smrg
149776888252Smrg      -inst-prefix-dir)
149876888252Smrg	prev=inst_prefix
149976888252Smrg	continue
150076888252Smrg	;;
150176888252Smrg
150276888252Smrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
150376888252Smrg      # so, if we see these flags be careful not to treat them like -L
150476888252Smrg      -L[A-Z][A-Z]*:*)
150576888252Smrg	case $with_gcc/$host in
150676888252Smrg	no/*-*-irix* | /*-*-irix*)
150776888252Smrg	  compile_command="$compile_command $arg"
150876888252Smrg	  finalize_command="$finalize_command $arg"
150976888252Smrg	  ;;
151076888252Smrg	esac
151176888252Smrg	continue
151276888252Smrg	;;
151376888252Smrg
151476888252Smrg      -L*)
151576888252Smrg	dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
151676888252Smrg	# We need an absolute path.
151776888252Smrg	case $dir in
151876888252Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
151976888252Smrg	*)
152076888252Smrg	  absdir=`cd "$dir" && pwd`
152176888252Smrg	  if test -z "$absdir"; then
152276888252Smrg	    $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
152376888252Smrg	    absdir="$dir"
152476888252Smrg	    notinst_path="$notinst_path $dir"
152576888252Smrg	  fi
152676888252Smrg	  dir="$absdir"
152776888252Smrg	  ;;
152876888252Smrg	esac
152976888252Smrg	case "$deplibs " in
153076888252Smrg	*" -L$dir "*) ;;
153176888252Smrg	*)
153276888252Smrg	  deplibs="$deplibs -L$dir"
153376888252Smrg	  lib_search_path="$lib_search_path $dir"
153476888252Smrg	  ;;
153576888252Smrg	esac
153676888252Smrg	case $host in
153776888252Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
153876888252Smrg	  testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'`
153976888252Smrg	  case :$dllsearchpath: in
154076888252Smrg	  *":$dir:"*) ;;
154176888252Smrg	  *) dllsearchpath="$dllsearchpath:$dir";;
154276888252Smrg	  esac
154376888252Smrg	  case :$dllsearchpath: in
154476888252Smrg	  *":$testbindir:"*) ;;
154576888252Smrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
154676888252Smrg	  esac
154776888252Smrg	  ;;
154876888252Smrg	esac
154976888252Smrg	continue
155076888252Smrg	;;
155176888252Smrg
155276888252Smrg      -l*)
155376888252Smrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
155476888252Smrg	  case $host in
155576888252Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*)
155676888252Smrg	    # These systems don't actually have a C or math library (as such)
155776888252Smrg	    continue
155876888252Smrg	    ;;
155976888252Smrg	  *-*-os2*)
156076888252Smrg	    # These systems don't actually have a C library (as such)
156176888252Smrg	    test "X$arg" = "X-lc" && continue
156276888252Smrg	    ;;
156376888252Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
156476888252Smrg	    # Do not include libc due to us having libc/libc_r.
156576888252Smrg	    test "X$arg" = "X-lc" && continue
156676888252Smrg	    ;;
156776888252Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
156876888252Smrg	    # Rhapsody C and math libraries are in the System framework
156976888252Smrg	    deplibs="$deplibs -framework System"
157076888252Smrg	    continue
157176888252Smrg	    ;;
157276888252Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
157376888252Smrg	    # Causes problems with __ctype
157476888252Smrg	    test "X$arg" = "X-lc" && continue
157576888252Smrg	    ;;
157676888252Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
157776888252Smrg	    # Compiler inserts libc in the correct place for threads to work
157876888252Smrg	    test "X$arg" = "X-lc" && continue
157976888252Smrg	    ;;
158076888252Smrg	  esac
158176888252Smrg	elif test "X$arg" = "X-lc_r"; then
158276888252Smrg	 case $host in
158376888252Smrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
158476888252Smrg	   # Do not include libc_r directly, use -pthread flag.
158576888252Smrg	   continue
158676888252Smrg	   ;;
158776888252Smrg	 esac
158876888252Smrg	fi
158976888252Smrg	deplibs="$deplibs $arg"
159076888252Smrg	continue
159176888252Smrg	;;
159276888252Smrg
159376888252Smrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
159476888252Smrg      # classes, name mangling, and exception handling.
159576888252Smrg      -model)
159676888252Smrg	compile_command="$compile_command $arg"
159776888252Smrg	compiler_flags="$compiler_flags $arg"
159876888252Smrg	finalize_command="$finalize_command $arg"
159976888252Smrg	prev=xcompiler
160076888252Smrg	continue
160176888252Smrg	;;
160276888252Smrg
160376888252Smrg     -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
160476888252Smrg	compiler_flags="$compiler_flags $arg"
160576888252Smrg	compile_command="$compile_command $arg"
160676888252Smrg	finalize_command="$finalize_command $arg"
160776888252Smrg	continue
160876888252Smrg	;;
160976888252Smrg
161076888252Smrg      -module)
161176888252Smrg	module=yes
161276888252Smrg	continue
161376888252Smrg	;;
161476888252Smrg
161576888252Smrg      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
161676888252Smrg      # -r[0-9][0-9]* specifies the processor on the SGI compiler
161776888252Smrg      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
161876888252Smrg      # +DA*, +DD* enable 64-bit mode on the HP compiler
161976888252Smrg      # -q* pass through compiler args for the IBM compiler
162076888252Smrg      # -m* pass through architecture-specific compiler args for GCC
162176888252Smrg      # -m*, -t[45]*, -txscale* pass through architecture-specific
162276888252Smrg      # compiler args for GCC
162376888252Smrg      # -pg pass through profiling flag for GCC
162476888252Smrg      # @file GCC response files
162576888252Smrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*|-pg| \
162676888252Smrg      -t[45]*|-txscale*|@*)
162776888252Smrg
162876888252Smrg	# Unknown arguments in both finalize_command and compile_command need
162976888252Smrg	# to be aesthetically quoted because they are evaled later.
163076888252Smrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
163176888252Smrg	case $arg in
163276888252Smrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
163376888252Smrg	  arg="\"$arg\""
163476888252Smrg	  ;;
163576888252Smrg	esac
163676888252Smrg        compile_command="$compile_command $arg"
163776888252Smrg        finalize_command="$finalize_command $arg"
163876888252Smrg        compiler_flags="$compiler_flags $arg"
163976888252Smrg        continue
164076888252Smrg        ;;
164176888252Smrg
164276888252Smrg      -shrext)
164376888252Smrg	prev=shrext
164476888252Smrg	continue
164576888252Smrg	;;
164676888252Smrg
164776888252Smrg      -no-fast-install)
164876888252Smrg	fast_install=no
164976888252Smrg	continue
165076888252Smrg	;;
165176888252Smrg
165276888252Smrg      -no-install)
165376888252Smrg	case $host in
165476888252Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
165576888252Smrg	  # The PATH hackery in wrapper scripts is required on Windows
165676888252Smrg	  # in order for the loader to find any dlls it needs.
165776888252Smrg	  $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2
165876888252Smrg	  $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2
165976888252Smrg	  fast_install=no
166076888252Smrg	  ;;
166176888252Smrg	*) no_install=yes ;;
166276888252Smrg	esac
166376888252Smrg	continue
166476888252Smrg	;;
166576888252Smrg
166676888252Smrg      -no-undefined)
166776888252Smrg	allow_undefined=no
166876888252Smrg	continue
166976888252Smrg	;;
167076888252Smrg
167176888252Smrg      -objectlist)
167276888252Smrg	prev=objectlist
167376888252Smrg	continue
167476888252Smrg	;;
167576888252Smrg
167676888252Smrg      -o) prev=output ;;
167776888252Smrg
167876888252Smrg      -precious-files-regex)
167976888252Smrg	prev=precious_regex
168076888252Smrg	continue
168176888252Smrg	;;
168276888252Smrg
168376888252Smrg      -release)
168476888252Smrg	prev=release
168576888252Smrg	continue
168676888252Smrg	;;
168776888252Smrg
168876888252Smrg      -rpath)
168976888252Smrg	prev=rpath
169076888252Smrg	continue
169176888252Smrg	;;
169276888252Smrg
169376888252Smrg      -R)
169476888252Smrg	prev=xrpath
169576888252Smrg	continue
169676888252Smrg	;;
169776888252Smrg
169876888252Smrg      -R*)
169976888252Smrg	dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
170076888252Smrg	# We need an absolute path.
170176888252Smrg	case $dir in
170276888252Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
170376888252Smrg	*)
170476888252Smrg	  $echo "$modename: only absolute run-paths are allowed" 1>&2
170576888252Smrg	  exit $EXIT_FAILURE
170676888252Smrg	  ;;
170776888252Smrg	esac
170876888252Smrg	case "$xrpath " in
170976888252Smrg	*" $dir "*) ;;
171076888252Smrg	*) xrpath="$xrpath $dir" ;;
171176888252Smrg	esac
171276888252Smrg	continue
171376888252Smrg	;;
171476888252Smrg
171576888252Smrg      -static)
171676888252Smrg	# The effects of -static are defined in a previous loop.
171776888252Smrg	# We used to do the same as -all-static on platforms that
171876888252Smrg	# didn't have a PIC flag, but the assumption that the effects
171976888252Smrg	# would be equivalent was wrong.  It would break on at least
172076888252Smrg	# Digital Unix and AIX.
172176888252Smrg	continue
172276888252Smrg	;;
172376888252Smrg
172476888252Smrg      -thread-safe)
172576888252Smrg	thread_safe=yes
172676888252Smrg	continue
172776888252Smrg	;;
172876888252Smrg
172976888252Smrg      -version-info)
173076888252Smrg	prev=vinfo
173176888252Smrg	continue
173276888252Smrg	;;
173376888252Smrg      -version-number)
173476888252Smrg	prev=vinfo
173576888252Smrg	vinfo_number=yes
173676888252Smrg	continue
173776888252Smrg	;;
173876888252Smrg
173976888252Smrg      -Wc,*)
174076888252Smrg	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'`
174176888252Smrg	arg=
174276888252Smrg	save_ifs="$IFS"; IFS=','
174376888252Smrg	for flag in $args; do
174476888252Smrg	  IFS="$save_ifs"
174576888252Smrg	  case $flag in
174676888252Smrg	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
174776888252Smrg	    flag="\"$flag\""
174876888252Smrg	    ;;
174976888252Smrg	  esac
175076888252Smrg	  arg="$arg $wl$flag"
175176888252Smrg	  compiler_flags="$compiler_flags $flag"
175276888252Smrg	done
175376888252Smrg	IFS="$save_ifs"
175476888252Smrg	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
175576888252Smrg	;;
175676888252Smrg
175776888252Smrg      -Wl,*)
175876888252Smrg	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'`
175976888252Smrg	arg=
176076888252Smrg	save_ifs="$IFS"; IFS=','
176176888252Smrg	for flag in $args; do
176276888252Smrg	  IFS="$save_ifs"
176376888252Smrg	  case $flag in
176476888252Smrg	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
176576888252Smrg	    flag="\"$flag\""
176676888252Smrg	    ;;
176776888252Smrg	  esac
176876888252Smrg	  arg="$arg $wl$flag"
176976888252Smrg	  compiler_flags="$compiler_flags $wl$flag"
177076888252Smrg	  linker_flags="$linker_flags $flag"
177176888252Smrg	done
177276888252Smrg	IFS="$save_ifs"
177376888252Smrg	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
177476888252Smrg	;;
177576888252Smrg
177676888252Smrg      -Xcompiler)
177776888252Smrg	prev=xcompiler
177876888252Smrg	continue
177976888252Smrg	;;
178076888252Smrg
178176888252Smrg      -Xlinker)
178276888252Smrg	prev=xlinker
178376888252Smrg	continue
178476888252Smrg	;;
178576888252Smrg
178676888252Smrg      -XCClinker)
178776888252Smrg	prev=xcclinker
178876888252Smrg	continue
178976888252Smrg	;;
179076888252Smrg
179176888252Smrg      # Some other compiler flag.
179276888252Smrg      -* | +*)
179376888252Smrg	# Unknown arguments in both finalize_command and compile_command need
179476888252Smrg	# to be aesthetically quoted because they are evaled later.
179576888252Smrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
179676888252Smrg	case $arg in
179776888252Smrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
179876888252Smrg	  arg="\"$arg\""
179976888252Smrg	  ;;
180076888252Smrg	esac
180176888252Smrg	;;
180276888252Smrg
180376888252Smrg      *.$objext)
180476888252Smrg	# A standard object.
180576888252Smrg	objs="$objs $arg"
180676888252Smrg	;;
180776888252Smrg
180876888252Smrg      *.lo)
180976888252Smrg	# A libtool-controlled object.
181076888252Smrg
181176888252Smrg	# Check to see that this really is a libtool object.
181276888252Smrg	if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
181376888252Smrg	  pic_object=
181476888252Smrg	  non_pic_object=
181576888252Smrg
181676888252Smrg	  # Read the .lo file
181776888252Smrg	  # If there is no directory component, then add one.
181876888252Smrg	  case $arg in
181976888252Smrg	  */* | *\\*) . $arg ;;
182076888252Smrg	  *) . ./$arg ;;
182176888252Smrg	  esac
182276888252Smrg
182376888252Smrg	  if test -z "$pic_object" || \
182476888252Smrg	     test -z "$non_pic_object" ||
182576888252Smrg	     test "$pic_object" = none && \
182676888252Smrg	     test "$non_pic_object" = none; then
182776888252Smrg	    $echo "$modename: cannot find name of object for \`$arg'" 1>&2
182876888252Smrg	    exit $EXIT_FAILURE
182976888252Smrg	  fi
183076888252Smrg
183176888252Smrg	  # Extract subdirectory from the argument.
183276888252Smrg	  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
183376888252Smrg	  if test "X$xdir" = "X$arg"; then
183476888252Smrg	    xdir=
183576888252Smrg 	  else
183676888252Smrg	    xdir="$xdir/"
183776888252Smrg	  fi
183876888252Smrg
183976888252Smrg	  if test "$pic_object" != none; then
184076888252Smrg	    # Prepend the subdirectory the object is found in.
184176888252Smrg	    pic_object="$xdir$pic_object"
184276888252Smrg
184376888252Smrg	    if test "$prev" = dlfiles; then
184476888252Smrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
184576888252Smrg		dlfiles="$dlfiles $pic_object"
184676888252Smrg		prev=
184776888252Smrg		continue
184876888252Smrg	      else
184976888252Smrg		# If libtool objects are unsupported, then we need to preload.
185076888252Smrg		prev=dlprefiles
185176888252Smrg	      fi
185276888252Smrg	    fi
185376888252Smrg
185476888252Smrg	    # CHECK ME:  I think I busted this.  -Ossama
185576888252Smrg	    if test "$prev" = dlprefiles; then
185676888252Smrg	      # Preload the old-style object.
185776888252Smrg	      dlprefiles="$dlprefiles $pic_object"
185876888252Smrg	      prev=
185976888252Smrg	    fi
186076888252Smrg
186176888252Smrg	    # A PIC object.
186276888252Smrg	    libobjs="$libobjs $pic_object"
186376888252Smrg	    arg="$pic_object"
186476888252Smrg	  fi
186576888252Smrg
186676888252Smrg	  # Non-PIC object.
186776888252Smrg	  if test "$non_pic_object" != none; then
186876888252Smrg	    # Prepend the subdirectory the object is found in.
186976888252Smrg	    non_pic_object="$xdir$non_pic_object"
187076888252Smrg
187176888252Smrg	    # A standard non-PIC object
187276888252Smrg	    non_pic_objects="$non_pic_objects $non_pic_object"
187376888252Smrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
187476888252Smrg	      arg="$non_pic_object"
187576888252Smrg	    fi
187676888252Smrg	  else
187776888252Smrg	    # If the PIC object exists, use it instead.
187876888252Smrg	    # $xdir was prepended to $pic_object above.
187976888252Smrg	    non_pic_object="$pic_object"
188076888252Smrg	    non_pic_objects="$non_pic_objects $non_pic_object"
188176888252Smrg	  fi
188276888252Smrg	else
188376888252Smrg	  # Only an error if not doing a dry-run.
188476888252Smrg	  if test -z "$run"; then
188576888252Smrg	    $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
188676888252Smrg	    exit $EXIT_FAILURE
188776888252Smrg	  else
188876888252Smrg	    # Dry-run case.
188976888252Smrg
189076888252Smrg	    # Extract subdirectory from the argument.
189176888252Smrg	    xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
189276888252Smrg	    if test "X$xdir" = "X$arg"; then
189376888252Smrg	      xdir=
189476888252Smrg	    else
189576888252Smrg	      xdir="$xdir/"
189676888252Smrg	    fi
189776888252Smrg
189876888252Smrg	    pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
189976888252Smrg	    non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
190076888252Smrg	    libobjs="$libobjs $pic_object"
190176888252Smrg	    non_pic_objects="$non_pic_objects $non_pic_object"
190276888252Smrg	  fi
190376888252Smrg	fi
190476888252Smrg	;;
190576888252Smrg
190676888252Smrg      *.$libext)
190776888252Smrg	# An archive.
190876888252Smrg	deplibs="$deplibs $arg"
190976888252Smrg	old_deplibs="$old_deplibs $arg"
191076888252Smrg	continue
191176888252Smrg	;;
191276888252Smrg
191376888252Smrg      *.la)
191476888252Smrg	# A libtool-controlled library.
191576888252Smrg
191676888252Smrg	if test "$prev" = dlfiles; then
191776888252Smrg	  # This library was specified with -dlopen.
191876888252Smrg	  dlfiles="$dlfiles $arg"
191976888252Smrg	  prev=
192076888252Smrg	elif test "$prev" = dlprefiles; then
192176888252Smrg	  # The library was specified with -dlpreopen.
192276888252Smrg	  dlprefiles="$dlprefiles $arg"
192376888252Smrg	  prev=
192476888252Smrg	else
192576888252Smrg	  deplibs="$deplibs $arg"
192676888252Smrg	fi
192776888252Smrg	continue
192876888252Smrg	;;
192976888252Smrg
193076888252Smrg      # Some other compiler argument.
193176888252Smrg      *)
193276888252Smrg	# Unknown arguments in both finalize_command and compile_command need
193376888252Smrg	# to be aesthetically quoted because they are evaled later.
193476888252Smrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
193576888252Smrg	case $arg in
193676888252Smrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
193776888252Smrg	  arg="\"$arg\""
193876888252Smrg	  ;;
193976888252Smrg	esac
194076888252Smrg	;;
194176888252Smrg      esac # arg
194276888252Smrg
194376888252Smrg      # Now actually substitute the argument into the commands.
194476888252Smrg      if test -n "$arg"; then
194576888252Smrg	compile_command="$compile_command $arg"
194676888252Smrg	finalize_command="$finalize_command $arg"
194776888252Smrg      fi
194876888252Smrg    done # argument parsing loop
194976888252Smrg
195076888252Smrg    if test -n "$prev"; then
195176888252Smrg      $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
195276888252Smrg      $echo "$help" 1>&2
195376888252Smrg      exit $EXIT_FAILURE
195476888252Smrg    fi
195576888252Smrg
195676888252Smrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
195776888252Smrg      eval arg=\"$export_dynamic_flag_spec\"
195876888252Smrg      compile_command="$compile_command $arg"
195976888252Smrg      finalize_command="$finalize_command $arg"
196076888252Smrg    fi
196176888252Smrg
196276888252Smrg    oldlibs=
196376888252Smrg    # calculate the name of the file, without its directory
196476888252Smrg    outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
196576888252Smrg    libobjs_save="$libobjs"
196676888252Smrg
196776888252Smrg    if test -n "$shlibpath_var"; then
196876888252Smrg      # get the directories listed in $shlibpath_var
196976888252Smrg      eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
197076888252Smrg    else
197176888252Smrg      shlib_search_path=
197276888252Smrg    fi
197376888252Smrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
197476888252Smrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
197576888252Smrg
197676888252Smrg    output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
197776888252Smrg    if test "X$output_objdir" = "X$output"; then
197876888252Smrg      output_objdir="$objdir"
197976888252Smrg    else
198076888252Smrg      output_objdir="$output_objdir/$objdir"
198176888252Smrg    fi
198276888252Smrg    # Create the object directory.
198376888252Smrg    if test ! -d "$output_objdir"; then
198476888252Smrg      $show "$mkdir $output_objdir"
198576888252Smrg      $run $mkdir $output_objdir
198676888252Smrg      exit_status=$?
198776888252Smrg      if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then
198876888252Smrg	exit $exit_status
198976888252Smrg      fi
199076888252Smrg    fi
199176888252Smrg
199276888252Smrg    # Determine the type of output
199376888252Smrg    case $output in
199476888252Smrg    "")
199576888252Smrg      $echo "$modename: you must specify an output file" 1>&2
199676888252Smrg      $echo "$help" 1>&2
199776888252Smrg      exit $EXIT_FAILURE
199876888252Smrg      ;;
199976888252Smrg    *.$libext) linkmode=oldlib ;;
200076888252Smrg    *.lo | *.$objext) linkmode=obj ;;
200176888252Smrg    *.la) linkmode=lib ;;
200276888252Smrg    *) linkmode=prog ;; # Anything else should be a program.
200376888252Smrg    esac
200476888252Smrg
200576888252Smrg    case $host in
200676888252Smrg    *cygwin* | *mingw* | *pw32*)
200776888252Smrg      # don't eliminate duplications in $postdeps and $predeps
200876888252Smrg      duplicate_compiler_generated_deps=yes
200976888252Smrg      ;;
201076888252Smrg    *)
201176888252Smrg      duplicate_compiler_generated_deps=$duplicate_deps
201276888252Smrg      ;;
201376888252Smrg    esac
201476888252Smrg    specialdeplibs=
201576888252Smrg
201676888252Smrg    libs=
201776888252Smrg    # Find all interdependent deplibs by searching for libraries
201876888252Smrg    # that are linked more than once (e.g. -la -lb -la)
201976888252Smrg    for deplib in $deplibs; do
202076888252Smrg      if test "X$duplicate_deps" = "Xyes" ; then
202176888252Smrg	case "$libs " in
202276888252Smrg	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
202376888252Smrg	esac
202476888252Smrg      fi
202576888252Smrg      libs="$libs $deplib"
202676888252Smrg    done
202776888252Smrg
202876888252Smrg    if test "$linkmode" = lib; then
202976888252Smrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
203076888252Smrg
203176888252Smrg      # Compute libraries that are listed more than once in $predeps
203276888252Smrg      # $postdeps and mark them as special (i.e., whose duplicates are
203376888252Smrg      # not to be eliminated).
203476888252Smrg      pre_post_deps=
203576888252Smrg      if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then
203676888252Smrg	for pre_post_dep in $predeps $postdeps; do
203776888252Smrg	  case "$pre_post_deps " in
203876888252Smrg	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
203976888252Smrg	  esac
204076888252Smrg	  pre_post_deps="$pre_post_deps $pre_post_dep"
204176888252Smrg	done
204276888252Smrg      fi
204376888252Smrg      pre_post_deps=
204476888252Smrg    fi
204576888252Smrg
204676888252Smrg    deplibs=
204776888252Smrg    newdependency_libs=
204876888252Smrg    newlib_search_path=
204976888252Smrg    need_relink=no # whether we're linking any uninstalled libtool libraries
205076888252Smrg    notinst_deplibs= # not-installed libtool libraries
205176888252Smrg    case $linkmode in
205276888252Smrg    lib)
205376888252Smrg	passes="conv link"
205476888252Smrg	for file in $dlfiles $dlprefiles; do
205576888252Smrg	  case $file in
205676888252Smrg	  *.la) ;;
205776888252Smrg	  *)
205876888252Smrg	    $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2
205976888252Smrg	    exit $EXIT_FAILURE
206076888252Smrg	    ;;
206176888252Smrg	  esac
206276888252Smrg	done
206376888252Smrg	;;
206476888252Smrg    prog)
206576888252Smrg	compile_deplibs=
206676888252Smrg	finalize_deplibs=
206776888252Smrg	alldeplibs=no
206876888252Smrg	newdlfiles=
206976888252Smrg	newdlprefiles=
207076888252Smrg	passes="conv scan dlopen dlpreopen link"
207176888252Smrg	;;
207276888252Smrg    *)  passes="conv"
207376888252Smrg	;;
207476888252Smrg    esac
207576888252Smrg    for pass in $passes; do
207676888252Smrg      if test "$linkmode,$pass" = "lib,link" ||
207776888252Smrg	 test "$linkmode,$pass" = "prog,scan"; then
207876888252Smrg	libs="$deplibs"
207976888252Smrg	deplibs=
208076888252Smrg      fi
208176888252Smrg      if test "$linkmode" = prog; then
208276888252Smrg	case $pass in
208376888252Smrg	dlopen) libs="$dlfiles" ;;
208476888252Smrg	dlpreopen) libs="$dlprefiles" ;;
208576888252Smrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
208676888252Smrg	esac
208776888252Smrg      fi
208876888252Smrg      if test "$pass" = dlopen; then
208976888252Smrg	# Collect dlpreopened libraries
209076888252Smrg	save_deplibs="$deplibs"
209176888252Smrg	deplibs=
209276888252Smrg      fi
209376888252Smrg      for deplib in $libs; do
209476888252Smrg	lib=
209576888252Smrg	found=no
209676888252Smrg	case $deplib in
209776888252Smrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
209876888252Smrg	  if test "$linkmode,$pass" = "prog,link"; then
209976888252Smrg	    compile_deplibs="$deplib $compile_deplibs"
210076888252Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
210176888252Smrg	  else
210276888252Smrg	    compiler_flags="$compiler_flags $deplib"
210376888252Smrg	  fi
210476888252Smrg	  continue
210576888252Smrg	  ;;
210676888252Smrg	-l*)
210776888252Smrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
210876888252Smrg	    $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2
210976888252Smrg	    continue
211076888252Smrg	  fi
211176888252Smrg	  name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
211276888252Smrg	  for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do
211376888252Smrg	    for search_ext in .la $std_shrext .so .a; do
211476888252Smrg	      # Search the libtool library
211576888252Smrg	      lib="$searchdir/lib${name}${search_ext}"
211676888252Smrg	      if test -f "$lib"; then
211776888252Smrg		if test "$search_ext" = ".la"; then
211876888252Smrg		  found=yes
211976888252Smrg		else
212076888252Smrg		  found=no
212176888252Smrg		fi
212276888252Smrg		break 2
212376888252Smrg	      fi
212476888252Smrg	    done
212576888252Smrg	  done
212676888252Smrg	  if test "$found" != yes; then
212776888252Smrg	    # deplib doesn't seem to be a libtool library
212876888252Smrg	    if test "$linkmode,$pass" = "prog,link"; then
212976888252Smrg	      compile_deplibs="$deplib $compile_deplibs"
213076888252Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
213176888252Smrg	    else
213276888252Smrg	      deplibs="$deplib $deplibs"
213376888252Smrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
213476888252Smrg	    fi
213576888252Smrg	    continue
213676888252Smrg	  else # deplib is a libtool library
213776888252Smrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
213876888252Smrg	    # We need to do some special things here, and not later.
213976888252Smrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
214076888252Smrg	      case " $predeps $postdeps " in
214176888252Smrg	      *" $deplib "*)
214276888252Smrg		if (${SED} -e '2q' $lib |
214376888252Smrg                    grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
214476888252Smrg		  library_names=
214576888252Smrg		  old_library=
214676888252Smrg		  case $lib in
214776888252Smrg		  */* | *\\*) . $lib ;;
214876888252Smrg		  *) . ./$lib ;;
214976888252Smrg		  esac
215076888252Smrg		  for l in $old_library $library_names; do
215176888252Smrg		    ll="$l"
215276888252Smrg		  done
215376888252Smrg		  if test "X$ll" = "X$old_library" ; then # only static version available
215476888252Smrg		    found=no
215576888252Smrg		    ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
215676888252Smrg		    test "X$ladir" = "X$lib" && ladir="."
215776888252Smrg		    lib=$ladir/$old_library
215876888252Smrg		    if test "$linkmode,$pass" = "prog,link"; then
215976888252Smrg		      compile_deplibs="$deplib $compile_deplibs"
216076888252Smrg		      finalize_deplibs="$deplib $finalize_deplibs"
216176888252Smrg		    else
216276888252Smrg		      deplibs="$deplib $deplibs"
216376888252Smrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
216476888252Smrg		    fi
216576888252Smrg		    continue
216676888252Smrg		  fi
216776888252Smrg		fi
216876888252Smrg	        ;;
216976888252Smrg	      *) ;;
217076888252Smrg	      esac
217176888252Smrg	    fi
217276888252Smrg	  fi
217376888252Smrg	  ;; # -l
217476888252Smrg	-L*)
217576888252Smrg	  case $linkmode in
217676888252Smrg	  lib)
217776888252Smrg	    deplibs="$deplib $deplibs"
217876888252Smrg	    test "$pass" = conv && continue
217976888252Smrg	    newdependency_libs="$deplib $newdependency_libs"
218076888252Smrg	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
218176888252Smrg	    ;;
218276888252Smrg	  prog)
218376888252Smrg	    if test "$pass" = conv; then
218476888252Smrg	      deplibs="$deplib $deplibs"
218576888252Smrg	      continue
218676888252Smrg	    fi
218776888252Smrg	    if test "$pass" = scan; then
218876888252Smrg	      deplibs="$deplib $deplibs"
218976888252Smrg	    else
219076888252Smrg	      compile_deplibs="$deplib $compile_deplibs"
219176888252Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
219276888252Smrg	    fi
219376888252Smrg	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
219476888252Smrg	    ;;
219576888252Smrg	  *)
219676888252Smrg	    $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2
219776888252Smrg	    ;;
219876888252Smrg	  esac # linkmode
219976888252Smrg	  continue
220076888252Smrg	  ;; # -L
220176888252Smrg	-R*)
220276888252Smrg	  if test "$pass" = link; then
220376888252Smrg	    dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
220476888252Smrg	    # Make sure the xrpath contains only unique directories.
220576888252Smrg	    case "$xrpath " in
220676888252Smrg	    *" $dir "*) ;;
220776888252Smrg	    *) xrpath="$xrpath $dir" ;;
220876888252Smrg	    esac
220976888252Smrg	  fi
221076888252Smrg	  deplibs="$deplib $deplibs"
221176888252Smrg	  continue
221276888252Smrg	  ;;
221376888252Smrg	*.la) lib="$deplib" ;;
221476888252Smrg	*.$libext)
221576888252Smrg	  if test "$pass" = conv; then
221676888252Smrg	    deplibs="$deplib $deplibs"
221776888252Smrg	    continue
221876888252Smrg	  fi
221976888252Smrg	  case $linkmode in
222076888252Smrg	  lib)
222176888252Smrg	    valid_a_lib=no
222276888252Smrg	    case $deplibs_check_method in
222376888252Smrg	      match_pattern*)
222476888252Smrg		set dummy $deplibs_check_method
222576888252Smrg	        match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
222676888252Smrg		if eval $echo \"$deplib\" 2>/dev/null \
222776888252Smrg		    | $SED 10q \
222876888252Smrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
222976888252Smrg		  valid_a_lib=yes
223076888252Smrg		fi
223176888252Smrg		;;
223276888252Smrg	      pass_all)
223376888252Smrg		valid_a_lib=yes
223476888252Smrg		;;
223576888252Smrg            esac
223676888252Smrg	    if test "$valid_a_lib" != yes; then
223776888252Smrg	      $echo
223876888252Smrg	      $echo "*** Warning: Trying to link with static lib archive $deplib."
223976888252Smrg	      $echo "*** I have the capability to make that library automatically link in when"
224076888252Smrg	      $echo "*** you link to this library.  But I can only do this if you have a"
224176888252Smrg	      $echo "*** shared version of the library, which you do not appear to have"
224276888252Smrg	      $echo "*** because the file extensions .$libext of this argument makes me believe"
224376888252Smrg	      $echo "*** that it is just a static archive that I should not used here."
224476888252Smrg	    else
224576888252Smrg	      $echo
224676888252Smrg	      $echo "*** Warning: Linking the shared library $output against the"
224776888252Smrg	      $echo "*** static library $deplib is not portable!"
224876888252Smrg	      deplibs="$deplib $deplibs"
224976888252Smrg	    fi
225076888252Smrg	    continue
225176888252Smrg	    ;;
225276888252Smrg	  prog)
225376888252Smrg	    if test "$pass" != link; then
225476888252Smrg	      deplibs="$deplib $deplibs"
225576888252Smrg	    else
225676888252Smrg	      compile_deplibs="$deplib $compile_deplibs"
225776888252Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
225876888252Smrg	    fi
225976888252Smrg	    continue
226076888252Smrg	    ;;
226176888252Smrg	  esac # linkmode
226276888252Smrg	  ;; # *.$libext
226376888252Smrg	*.lo | *.$objext)
226476888252Smrg	  if test "$pass" = conv; then
226576888252Smrg	    deplibs="$deplib $deplibs"
226676888252Smrg	  elif test "$linkmode" = prog; then
226776888252Smrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
226876888252Smrg	      # If there is no dlopen support or we're linking statically,
226976888252Smrg	      # we need to preload.
227076888252Smrg	      newdlprefiles="$newdlprefiles $deplib"
227176888252Smrg	      compile_deplibs="$deplib $compile_deplibs"
227276888252Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
227376888252Smrg	    else
227476888252Smrg	      newdlfiles="$newdlfiles $deplib"
227576888252Smrg	    fi
227676888252Smrg	  fi
227776888252Smrg	  continue
227876888252Smrg	  ;;
227976888252Smrg	%DEPLIBS%)
228076888252Smrg	  alldeplibs=yes
228176888252Smrg	  continue
228276888252Smrg	  ;;
228376888252Smrg	esac # case $deplib
228476888252Smrg	if test "$found" = yes || test -f "$lib"; then :
228576888252Smrg	else
228676888252Smrg	  $echo "$modename: cannot find the library \`$lib' or unhandled argument \`$deplib'" 1>&2
228776888252Smrg	  exit $EXIT_FAILURE
228876888252Smrg	fi
228976888252Smrg
229076888252Smrg	# Check to see that this really is a libtool archive.
229176888252Smrg	if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
229276888252Smrg	else
229376888252Smrg	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
229476888252Smrg	  exit $EXIT_FAILURE
229576888252Smrg	fi
229676888252Smrg
229776888252Smrg	ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
229876888252Smrg	test "X$ladir" = "X$lib" && ladir="."
229976888252Smrg
230076888252Smrg	dlname=
230176888252Smrg	dlopen=
230276888252Smrg	dlpreopen=
230376888252Smrg	libdir=
230476888252Smrg	library_names=
230576888252Smrg	old_library=
230676888252Smrg	# If the library was installed with an old release of libtool,
230776888252Smrg	# it will not redefine variables installed, or shouldnotlink
230876888252Smrg	installed=yes
230976888252Smrg	shouldnotlink=no
231076888252Smrg	avoidtemprpath=
231176888252Smrg
231276888252Smrg
231376888252Smrg	# Read the .la file
231476888252Smrg	case $lib in
231576888252Smrg	*/* | *\\*) . $lib ;;
231676888252Smrg	*) . ./$lib ;;
231776888252Smrg	esac
231876888252Smrg
231976888252Smrg	if test "$linkmode,$pass" = "lib,link" ||
232076888252Smrg	   test "$linkmode,$pass" = "prog,scan" ||
232176888252Smrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
232276888252Smrg	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
232376888252Smrg	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
232476888252Smrg	fi
232576888252Smrg
232676888252Smrg	if test "$pass" = conv; then
232776888252Smrg	  # Only check for convenience libraries
232876888252Smrg	  deplibs="$lib $deplibs"
232976888252Smrg	  if test -z "$libdir"; then
233076888252Smrg	    if test -z "$old_library"; then
233176888252Smrg	      $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
233276888252Smrg	      exit $EXIT_FAILURE
233376888252Smrg	    fi
233476888252Smrg	    # It is a libtool convenience library, so add in its objects.
233576888252Smrg	    convenience="$convenience $ladir/$objdir/$old_library"
233676888252Smrg	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
233776888252Smrg	    tmp_libs=
233876888252Smrg	    for deplib in $dependency_libs; do
233976888252Smrg	      deplibs="$deplib $deplibs"
234076888252Smrg              if test "X$duplicate_deps" = "Xyes" ; then
234176888252Smrg	        case "$tmp_libs " in
234276888252Smrg	        *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
234376888252Smrg	        esac
234476888252Smrg              fi
234576888252Smrg	      tmp_libs="$tmp_libs $deplib"
234676888252Smrg	    done
234776888252Smrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
234876888252Smrg	    $echo "$modename: \`$lib' is not a convenience library" 1>&2
234976888252Smrg	    exit $EXIT_FAILURE
235076888252Smrg	  fi
235176888252Smrg	  continue
235276888252Smrg	fi # $pass = conv
235376888252Smrg
235476888252Smrg
235576888252Smrg	# Get the name of the library we link against.
235676888252Smrg	linklib=
235776888252Smrg	for l in $old_library $library_names; do
235876888252Smrg	  linklib="$l"
235976888252Smrg	done
236076888252Smrg	if test -z "$linklib"; then
236176888252Smrg	  $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
236276888252Smrg	  exit $EXIT_FAILURE
236376888252Smrg	fi
236476888252Smrg
236576888252Smrg	# This library was specified with -dlopen.
236676888252Smrg	if test "$pass" = dlopen; then
236776888252Smrg	  if test -z "$libdir"; then
236876888252Smrg	    $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2
236976888252Smrg	    exit $EXIT_FAILURE
237076888252Smrg	  fi
237176888252Smrg	  if test -z "$dlname" ||
237276888252Smrg	     test "$dlopen_support" != yes ||
237376888252Smrg	     test "$build_libtool_libs" = no; then
237476888252Smrg	    # If there is no dlname, no dlopen support or we're linking
237576888252Smrg	    # statically, we need to preload.  We also need to preload any
237676888252Smrg	    # dependent libraries so libltdl's deplib preloader doesn't
237776888252Smrg	    # bomb out in the load deplibs phase.
237876888252Smrg	    dlprefiles="$dlprefiles $lib $dependency_libs"
237976888252Smrg	  else
238076888252Smrg	    newdlfiles="$newdlfiles $lib"
238176888252Smrg	  fi
238276888252Smrg	  continue
238376888252Smrg	fi # $pass = dlopen
238476888252Smrg
238576888252Smrg	# We need an absolute path.
238676888252Smrg	case $ladir in
238776888252Smrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
238876888252Smrg	*)
238976888252Smrg	  abs_ladir=`cd "$ladir" && pwd`
239076888252Smrg	  if test -z "$abs_ladir"; then
239176888252Smrg	    $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2
239276888252Smrg	    $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
239376888252Smrg	    abs_ladir="$ladir"
239476888252Smrg	  fi
239576888252Smrg	  ;;
239676888252Smrg	esac
239776888252Smrg	laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
239876888252Smrg
239976888252Smrg	# Find the relevant object directory and library name.
240076888252Smrg	if test "X$installed" = Xyes; then
240176888252Smrg	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
240276888252Smrg	    $echo "$modename: warning: library \`$lib' was moved." 1>&2
240376888252Smrg	    dir="$ladir"
240476888252Smrg	    absdir="$abs_ladir"
240576888252Smrg	    libdir="$abs_ladir"
240676888252Smrg	  else
240776888252Smrg	    dir="$libdir"
240876888252Smrg	    absdir="$libdir"
240976888252Smrg	  fi
241076888252Smrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
241176888252Smrg	else
241276888252Smrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
241376888252Smrg	    dir="$ladir"
241476888252Smrg	    absdir="$abs_ladir"
241576888252Smrg	    # Remove this search path later
241676888252Smrg	    notinst_path="$notinst_path $abs_ladir"
241776888252Smrg	  else
241876888252Smrg	    dir="$ladir/$objdir"
241976888252Smrg	    absdir="$abs_ladir/$objdir"
242076888252Smrg	    # Remove this search path later
242176888252Smrg	    notinst_path="$notinst_path $abs_ladir"
242276888252Smrg	  fi
242376888252Smrg	fi # $installed = yes
242476888252Smrg	name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
242576888252Smrg
242676888252Smrg	# This library was specified with -dlpreopen.
242776888252Smrg	if test "$pass" = dlpreopen; then
242876888252Smrg	  if test -z "$libdir"; then
242976888252Smrg	    $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2
243076888252Smrg	    exit $EXIT_FAILURE
243176888252Smrg	  fi
243276888252Smrg	  # Prefer using a static library (so that no silly _DYNAMIC symbols
243376888252Smrg	  # are required to link).
243476888252Smrg	  if test -n "$old_library"; then
243576888252Smrg	    newdlprefiles="$newdlprefiles $dir/$old_library"
243676888252Smrg	  # Otherwise, use the dlname, so that lt_dlopen finds it.
243776888252Smrg	  elif test -n "$dlname"; then
243876888252Smrg	    newdlprefiles="$newdlprefiles $dir/$dlname"
243976888252Smrg	  else
244076888252Smrg	    newdlprefiles="$newdlprefiles $dir/$linklib"
244176888252Smrg	  fi
244276888252Smrg	fi # $pass = dlpreopen
244376888252Smrg
244476888252Smrg	if test -z "$libdir"; then
244576888252Smrg	  # Link the convenience library
244676888252Smrg	  if test "$linkmode" = lib; then
244776888252Smrg	    deplibs="$dir/$old_library $deplibs"
244876888252Smrg	  elif test "$linkmode,$pass" = "prog,link"; then
244976888252Smrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
245076888252Smrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
245176888252Smrg	  else
245276888252Smrg	    deplibs="$lib $deplibs" # used for prog,scan pass
245376888252Smrg	  fi
245476888252Smrg	  continue
245576888252Smrg	fi
245676888252Smrg
245776888252Smrg
245876888252Smrg	if test "$linkmode" = prog && test "$pass" != link; then
245976888252Smrg	  newlib_search_path="$newlib_search_path $ladir"
246076888252Smrg	  deplibs="$lib $deplibs"
246176888252Smrg
246276888252Smrg	  linkalldeplibs=no
246376888252Smrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
246476888252Smrg	     test "$build_libtool_libs" = no; then
246576888252Smrg	    linkalldeplibs=yes
246676888252Smrg	  fi
246776888252Smrg
246876888252Smrg	  tmp_libs=
246976888252Smrg	  for deplib in $dependency_libs; do
247076888252Smrg	    case $deplib in
247176888252Smrg	    -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test
247276888252Smrg	    esac
247376888252Smrg	    # Need to link against all dependency_libs?
247476888252Smrg	    if test "$linkalldeplibs" = yes; then
247576888252Smrg	      deplibs="$deplib $deplibs"
247676888252Smrg	    else
247776888252Smrg	      # Need to hardcode shared library paths
247876888252Smrg	      # or/and link against static libraries
247976888252Smrg	      newdependency_libs="$deplib $newdependency_libs"
248076888252Smrg	    fi
248176888252Smrg	    if test "X$duplicate_deps" = "Xyes" ; then
248276888252Smrg	      case "$tmp_libs " in
248376888252Smrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
248476888252Smrg	      esac
248576888252Smrg	    fi
248676888252Smrg	    tmp_libs="$tmp_libs $deplib"
248776888252Smrg	  done # for deplib
248876888252Smrg	  continue
248976888252Smrg	fi # $linkmode = prog...
249076888252Smrg
249176888252Smrg	if test "$linkmode,$pass" = "prog,link"; then
249276888252Smrg	  if test -n "$library_names" &&
249376888252Smrg	     { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
249476888252Smrg	    # We need to hardcode the library path
249576888252Smrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
249676888252Smrg	      # Make sure the rpath contains only unique directories.
249776888252Smrg	      case "$temp_rpath " in
249876888252Smrg	      *" $dir "*) ;;
249976888252Smrg	      *" $absdir "*) ;;
250076888252Smrg	      *) temp_rpath="$temp_rpath $absdir" ;;
250176888252Smrg	      esac
250276888252Smrg	    fi
250376888252Smrg
250476888252Smrg	    # Hardcode the library path.
250576888252Smrg	    # Skip directories that are in the system default run-time
250676888252Smrg	    # search path.
250776888252Smrg	    case " $sys_lib_dlsearch_path " in
250876888252Smrg	    *" $absdir "*) ;;
250976888252Smrg	    *)
251076888252Smrg	      case "$compile_rpath " in
251176888252Smrg	      *" $absdir "*) ;;
251276888252Smrg	      *) compile_rpath="$compile_rpath $absdir"
251376888252Smrg	      esac
251476888252Smrg	      ;;
251576888252Smrg	    esac
251676888252Smrg	    case " $sys_lib_dlsearch_path " in
251776888252Smrg	    *" $libdir "*) ;;
251876888252Smrg	    *)
251976888252Smrg	      case "$finalize_rpath " in
252076888252Smrg	      *" $libdir "*) ;;
252176888252Smrg	      *) finalize_rpath="$finalize_rpath $libdir"
252276888252Smrg	      esac
252376888252Smrg	      ;;
252476888252Smrg	    esac
252576888252Smrg	  fi # $linkmode,$pass = prog,link...
252676888252Smrg
252776888252Smrg	  if test "$alldeplibs" = yes &&
252876888252Smrg	     { test "$deplibs_check_method" = pass_all ||
252976888252Smrg	       { test "$build_libtool_libs" = yes &&
253076888252Smrg		 test -n "$library_names"; }; }; then
253176888252Smrg	    # We only need to search for static libraries
253276888252Smrg	    continue
253376888252Smrg	  fi
253476888252Smrg	fi
253576888252Smrg
253676888252Smrg	link_static=no # Whether the deplib will be linked statically
253776888252Smrg	use_static_libs=$prefer_static_libs
253876888252Smrg	if test "$use_static_libs" = built && test "$installed" = yes ; then
253976888252Smrg	  use_static_libs=no
254076888252Smrg	fi
254176888252Smrg	if test -n "$library_names" &&
254276888252Smrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
254376888252Smrg	  if test "$installed" = no; then
254476888252Smrg	    notinst_deplibs="$notinst_deplibs $lib"
254576888252Smrg	    need_relink=yes
254676888252Smrg	  fi
254776888252Smrg	  # This is a shared library
254876888252Smrg
254976888252Smrg	  # Warn about portability, can't link against -module's on
255076888252Smrg	  # some systems (darwin)
255176888252Smrg	  if test "$shouldnotlink" = yes && test "$pass" = link ; then
255276888252Smrg	    $echo
255376888252Smrg	    if test "$linkmode" = prog; then
255476888252Smrg	      $echo "*** Warning: Linking the executable $output against the loadable module"
255576888252Smrg	    else
255676888252Smrg	      $echo "*** Warning: Linking the shared library $output against the loadable module"
255776888252Smrg	    fi
255876888252Smrg	    $echo "*** $linklib is not portable!"
255976888252Smrg	  fi
256076888252Smrg	  if test "$linkmode" = lib &&
256176888252Smrg	     test "$hardcode_into_libs" = yes; then
256276888252Smrg	    # Hardcode the library path.
256376888252Smrg	    # Skip directories that are in the system default run-time
256476888252Smrg	    # search path.
256576888252Smrg	    case " $sys_lib_dlsearch_path " in
256676888252Smrg	    *" $absdir "*) ;;
256776888252Smrg	    *)
256876888252Smrg	      case "$compile_rpath " in
256976888252Smrg	      *" $absdir "*) ;;
257076888252Smrg	      *) compile_rpath="$compile_rpath $absdir"
257176888252Smrg	      esac
257276888252Smrg	      ;;
257376888252Smrg	    esac
257476888252Smrg	    case " $sys_lib_dlsearch_path " in
257576888252Smrg	    *" $libdir "*) ;;
257676888252Smrg	    *)
257776888252Smrg	      case "$finalize_rpath " in
257876888252Smrg	      *" $libdir "*) ;;
257976888252Smrg	      *) finalize_rpath="$finalize_rpath $libdir"
258076888252Smrg	      esac
258176888252Smrg	      ;;
258276888252Smrg	    esac
258376888252Smrg	  fi
258476888252Smrg
258576888252Smrg	  if test -n "$old_archive_from_expsyms_cmds"; then
258676888252Smrg	    # figure out the soname
258776888252Smrg	    set dummy $library_names
258876888252Smrg	    realname="$2"
258976888252Smrg	    shift; shift
259076888252Smrg	    libname=`eval \\$echo \"$libname_spec\"`
259176888252Smrg	    # use dlname if we got it. it's perfectly good, no?
259276888252Smrg	    if test -n "$dlname"; then
259376888252Smrg	      soname="$dlname"
259476888252Smrg	    elif test -n "$soname_spec"; then
259576888252Smrg	      # bleh windows
259676888252Smrg	      case $host in
259776888252Smrg	      *cygwin* | mingw*)
259876888252Smrg		major=`expr $current - $age`
259976888252Smrg		versuffix="-$major"
260076888252Smrg		;;
260176888252Smrg	      esac
260276888252Smrg	      eval soname=\"$soname_spec\"
260376888252Smrg	    else
260476888252Smrg	      soname="$realname"
260576888252Smrg	    fi
260676888252Smrg
260776888252Smrg	    # Make a new name for the extract_expsyms_cmds to use
260876888252Smrg	    soroot="$soname"
260976888252Smrg	    soname=`$echo $soroot | ${SED} -e 's/^.*\///'`
261076888252Smrg	    newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a"
261176888252Smrg
261276888252Smrg	    # If the library has no export list, then create one now
261376888252Smrg	    if test -f "$output_objdir/$soname-def"; then :
261476888252Smrg	    else
261576888252Smrg	      $show "extracting exported symbol list from \`$soname'"
261676888252Smrg	      save_ifs="$IFS"; IFS='~'
261776888252Smrg	      cmds=$extract_expsyms_cmds
261876888252Smrg	      for cmd in $cmds; do
261976888252Smrg		IFS="$save_ifs"
262076888252Smrg		eval cmd=\"$cmd\"
262176888252Smrg		$show "$cmd"
262276888252Smrg		$run eval "$cmd" || exit $?
262376888252Smrg	      done
262476888252Smrg	      IFS="$save_ifs"
262576888252Smrg	    fi
262676888252Smrg
262776888252Smrg	    # Create $newlib
262876888252Smrg	    if test -f "$output_objdir/$newlib"; then :; else
262976888252Smrg	      $show "generating import library for \`$soname'"
263076888252Smrg	      save_ifs="$IFS"; IFS='~'
263176888252Smrg	      cmds=$old_archive_from_expsyms_cmds
263276888252Smrg	      for cmd in $cmds; do
263376888252Smrg		IFS="$save_ifs"
263476888252Smrg		eval cmd=\"$cmd\"
263576888252Smrg		$show "$cmd"
263676888252Smrg		$run eval "$cmd" || exit $?
263776888252Smrg	      done
263876888252Smrg	      IFS="$save_ifs"
263976888252Smrg	    fi
264076888252Smrg	    # make sure the library variables are pointing to the new library
264176888252Smrg	    dir=$output_objdir
264276888252Smrg	    linklib=$newlib
264376888252Smrg	  fi # test -n "$old_archive_from_expsyms_cmds"
264476888252Smrg
264576888252Smrg	  if test "$linkmode" = prog || test "$mode" != relink; then
264676888252Smrg	    add_shlibpath=
264776888252Smrg	    add_dir=
264876888252Smrg	    add=
264976888252Smrg	    lib_linked=yes
265076888252Smrg	    case $hardcode_action in
265176888252Smrg	    immediate | unsupported)
265276888252Smrg	      if test "$hardcode_direct" = no; then
265376888252Smrg		add="$dir/$linklib"
265476888252Smrg		case $host in
265576888252Smrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
265676888252Smrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
265776888252Smrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
265876888252Smrg		    *-*-unixware7*) add_dir="-L$dir" ;;
265976888252Smrg		  *-*-darwin* )
266076888252Smrg		    # if the lib is a module then we can not link against
266176888252Smrg		    # it, someone is ignoring the new warnings I added
266276888252Smrg		    if /usr/bin/file -L $add 2> /dev/null |
266376888252Smrg                      $EGREP ": [^:]* bundle" >/dev/null ; then
266476888252Smrg		      $echo "** Warning, lib $linklib is a module, not a shared library"
266576888252Smrg		      if test -z "$old_library" ; then
266676888252Smrg		        $echo
266776888252Smrg		        $echo "** And there doesn't seem to be a static archive available"
266876888252Smrg		        $echo "** The link will probably fail, sorry"
266976888252Smrg		      else
267076888252Smrg		        add="$dir/$old_library"
267176888252Smrg		      fi
267276888252Smrg		    fi
267376888252Smrg		esac
267476888252Smrg	      elif test "$hardcode_minus_L" = no; then
267576888252Smrg		case $host in
267676888252Smrg		*-*-sunos*) add_shlibpath="$dir" ;;
267776888252Smrg		esac
267876888252Smrg		add_dir="-L$dir"
267976888252Smrg		add="-l$name"
268076888252Smrg	      elif test "$hardcode_shlibpath_var" = no; then
268176888252Smrg		add_shlibpath="$dir"
268276888252Smrg		add="-l$name"
268376888252Smrg	      else
268476888252Smrg		lib_linked=no
268576888252Smrg	      fi
268676888252Smrg	      ;;
268776888252Smrg	    relink)
268876888252Smrg	      if test "$hardcode_direct" = yes; then
268976888252Smrg		add="$dir/$linklib"
269076888252Smrg	      elif test "$hardcode_minus_L" = yes; then
269176888252Smrg		add_dir="-L$dir"
269276888252Smrg		# Try looking first in the location we're being installed to.
269376888252Smrg		if test -n "$inst_prefix_dir"; then
269476888252Smrg		  case $libdir in
269576888252Smrg		    [\\/]*)
269676888252Smrg		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
269776888252Smrg		      ;;
269876888252Smrg		  esac
269976888252Smrg		fi
270076888252Smrg		add="-l$name"
270176888252Smrg	      elif test "$hardcode_shlibpath_var" = yes; then
270276888252Smrg		add_shlibpath="$dir"
270376888252Smrg		add="-l$name"
270476888252Smrg	      else
270576888252Smrg		lib_linked=no
270676888252Smrg	      fi
270776888252Smrg	      ;;
270876888252Smrg	    *) lib_linked=no ;;
270976888252Smrg	    esac
271076888252Smrg
271176888252Smrg	    if test "$lib_linked" != yes; then
271276888252Smrg	      $echo "$modename: configuration error: unsupported hardcode properties"
271376888252Smrg	      exit $EXIT_FAILURE
271476888252Smrg	    fi
271576888252Smrg
271676888252Smrg	    if test -n "$add_shlibpath"; then
271776888252Smrg	      case :$compile_shlibpath: in
271876888252Smrg	      *":$add_shlibpath:"*) ;;
271976888252Smrg	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
272076888252Smrg	      esac
272176888252Smrg	    fi
272276888252Smrg	    if test "$linkmode" = prog; then
272376888252Smrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
272476888252Smrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
272576888252Smrg	    else
272676888252Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
272776888252Smrg	      test -n "$add" && deplibs="$add $deplibs"
272876888252Smrg	      if test "$hardcode_direct" != yes && \
272976888252Smrg		 test "$hardcode_minus_L" != yes && \
273076888252Smrg		 test "$hardcode_shlibpath_var" = yes; then
273176888252Smrg		case :$finalize_shlibpath: in
273276888252Smrg		*":$libdir:"*) ;;
273376888252Smrg		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
273476888252Smrg		esac
273576888252Smrg	      fi
273676888252Smrg	    fi
273776888252Smrg	  fi
273876888252Smrg
273976888252Smrg	  if test "$linkmode" = prog || test "$mode" = relink; then
274076888252Smrg	    add_shlibpath=
274176888252Smrg	    add_dir=
274276888252Smrg	    add=
274376888252Smrg	    # Finalize command for both is simple: just hardcode it.
274476888252Smrg	    if test "$hardcode_direct" = yes; then
274576888252Smrg	      add="$libdir/$linklib"
274676888252Smrg	    elif test "$hardcode_minus_L" = yes; then
274776888252Smrg	      add_dir="-L$libdir"
274876888252Smrg	      add="-l$name"
274976888252Smrg	    elif test "$hardcode_shlibpath_var" = yes; then
275076888252Smrg	      case :$finalize_shlibpath: in
275176888252Smrg	      *":$libdir:"*) ;;
275276888252Smrg	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
275376888252Smrg	      esac
275476888252Smrg	      add="-l$name"
275576888252Smrg	    elif test "$hardcode_automatic" = yes; then
275676888252Smrg	      if test -n "$inst_prefix_dir" &&
275776888252Smrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
275876888252Smrg	        add="$inst_prefix_dir$libdir/$linklib"
275976888252Smrg	      else
276076888252Smrg	        add="$libdir/$linklib"
276176888252Smrg	      fi
276276888252Smrg	    else
276376888252Smrg	      # We cannot seem to hardcode it, guess we'll fake it.
276476888252Smrg	      add_dir="-L$libdir"
276576888252Smrg	      # Try looking first in the location we're being installed to.
276676888252Smrg	      if test -n "$inst_prefix_dir"; then
276776888252Smrg		case $libdir in
276876888252Smrg		  [\\/]*)
276976888252Smrg		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
277076888252Smrg		    ;;
277176888252Smrg		esac
277276888252Smrg	      fi
277376888252Smrg	      add="-l$name"
277476888252Smrg	    fi
277576888252Smrg
277676888252Smrg	    if test "$linkmode" = prog; then
277776888252Smrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
277876888252Smrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
277976888252Smrg	    else
278076888252Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
278176888252Smrg	      test -n "$add" && deplibs="$add $deplibs"
278276888252Smrg	    fi
278376888252Smrg	  fi
278476888252Smrg	elif test "$linkmode" = prog; then
278576888252Smrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
278676888252Smrg	  # is not unsupported.  This is valid on all known static and
278776888252Smrg	  # shared platforms.
278876888252Smrg	  if test "$hardcode_direct" != unsupported; then
278976888252Smrg	    test -n "$old_library" && linklib="$old_library"
279076888252Smrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
279176888252Smrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
279276888252Smrg	  else
279376888252Smrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
279476888252Smrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
279576888252Smrg	  fi
279676888252Smrg	elif test "$build_libtool_libs" = yes; then
279776888252Smrg	  # Not a shared library
279876888252Smrg	  if test "$deplibs_check_method" != pass_all; then
279976888252Smrg	    # We're trying link a shared library against a static one
280076888252Smrg	    # but the system doesn't support it.
280176888252Smrg
280276888252Smrg	    # Just print a warning and add the library to dependency_libs so
280376888252Smrg	    # that the program can be linked against the static library.
280476888252Smrg	    $echo
280576888252Smrg	    $echo "*** Warning: This system can not link to static lib archive $lib."
280676888252Smrg	    $echo "*** I have the capability to make that library automatically link in when"
280776888252Smrg	    $echo "*** you link to this library.  But I can only do this if you have a"
280876888252Smrg	    $echo "*** shared version of the library, which you do not appear to have."
280976888252Smrg	    if test "$module" = yes; then
281076888252Smrg	      $echo "*** But as you try to build a module library, libtool will still create "
281176888252Smrg	      $echo "*** a static module, that should work as long as the dlopening application"
281276888252Smrg	      $echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
281376888252Smrg	      if test -z "$global_symbol_pipe"; then
281476888252Smrg		$echo
281576888252Smrg		$echo "*** However, this would only work if libtool was able to extract symbol"
281676888252Smrg		$echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
281776888252Smrg		$echo "*** not find such a program.  So, this module is probably useless."
281876888252Smrg		$echo "*** \`nm' from GNU binutils and a full rebuild may help."
281976888252Smrg	      fi
282076888252Smrg	      if test "$build_old_libs" = no; then
282176888252Smrg		build_libtool_libs=module
282276888252Smrg		build_old_libs=yes
282376888252Smrg	      else
282476888252Smrg		build_libtool_libs=no
282576888252Smrg	      fi
282676888252Smrg	    fi
282776888252Smrg	  else
282876888252Smrg	    deplibs="$dir/$old_library $deplibs"
282976888252Smrg	    link_static=yes
283076888252Smrg	  fi
283176888252Smrg	fi # link shared/static library?
283276888252Smrg
283376888252Smrg	if test "$linkmode" = lib; then
283476888252Smrg	  if test -n "$dependency_libs" &&
283576888252Smrg	     { test "$hardcode_into_libs" != yes ||
283676888252Smrg	       test "$build_old_libs" = yes ||
283776888252Smrg	       test "$link_static" = yes; }; then
283876888252Smrg	    # Extract -R from dependency_libs
283976888252Smrg	    temp_deplibs=
284076888252Smrg	    for libdir in $dependency_libs; do
284176888252Smrg	      case $libdir in
284276888252Smrg	      -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'`
284376888252Smrg		   case " $xrpath " in
284476888252Smrg		   *" $temp_xrpath "*) ;;
284576888252Smrg		   *) xrpath="$xrpath $temp_xrpath";;
284676888252Smrg		   esac;;
284776888252Smrg	      *) temp_deplibs="$temp_deplibs $libdir";;
284876888252Smrg	      esac
284976888252Smrg	    done
285076888252Smrg	    dependency_libs="$temp_deplibs"
285176888252Smrg	  fi
285276888252Smrg
285376888252Smrg	  newlib_search_path="$newlib_search_path $absdir"
285476888252Smrg	  # Link against this library
285576888252Smrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
285676888252Smrg	  # ... and its dependency_libs
285776888252Smrg	  tmp_libs=
285876888252Smrg	  for deplib in $dependency_libs; do
285976888252Smrg	    newdependency_libs="$deplib $newdependency_libs"
286076888252Smrg	    if test "X$duplicate_deps" = "Xyes" ; then
286176888252Smrg	      case "$tmp_libs " in
286276888252Smrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
286376888252Smrg	      esac
286476888252Smrg	    fi
286576888252Smrg	    tmp_libs="$tmp_libs $deplib"
286676888252Smrg	  done
286776888252Smrg
286876888252Smrg	  if test "$link_all_deplibs" != no; then
286976888252Smrg	    # Add the search paths of all dependency libraries
287076888252Smrg	    for deplib in $dependency_libs; do
287176888252Smrg	      case $deplib in
287276888252Smrg	      -L*) path="$deplib" ;;
287376888252Smrg	      *.la)
287476888252Smrg		dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'`
287576888252Smrg		test "X$dir" = "X$deplib" && dir="."
287676888252Smrg		# We need an absolute path.
287776888252Smrg		case $dir in
287876888252Smrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
287976888252Smrg		*)
288076888252Smrg		  absdir=`cd "$dir" && pwd`
288176888252Smrg		  if test -z "$absdir"; then
288276888252Smrg		    $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
288376888252Smrg		    absdir="$dir"
288476888252Smrg		  fi
288576888252Smrg		  ;;
288676888252Smrg		esac
288776888252Smrg		if grep "^installed=no" $deplib > /dev/null; then
288876888252Smrg		  path="$absdir/$objdir"
288976888252Smrg		else
289076888252Smrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
289176888252Smrg		  if test -z "$libdir"; then
289276888252Smrg		    $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
289376888252Smrg		    exit $EXIT_FAILURE
289476888252Smrg		  fi
289576888252Smrg		  if test "$absdir" != "$libdir"; then
289676888252Smrg		    $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2
289776888252Smrg		  fi
289876888252Smrg		  path="$absdir"
289976888252Smrg		fi
290076888252Smrg		depdepl=
290176888252Smrg		case $host in
290276888252Smrg		*-*-darwin*)
290376888252Smrg		  # we do not want to link against static libs,
290476888252Smrg		  # but need to link against shared
290576888252Smrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
290676888252Smrg		  if test -n "$deplibrary_names" ; then
290776888252Smrg		    for tmp in $deplibrary_names ; do
290876888252Smrg		      depdepl=$tmp
290976888252Smrg		    done
291076888252Smrg		    if test -f "$path/$depdepl" ; then
291176888252Smrg		      depdepl="$path/$depdepl"
291276888252Smrg		    fi
291376888252Smrg		    # do not add paths which are already there
291476888252Smrg		    case " $newlib_search_path " in
291576888252Smrg		    *" $path "*) ;;
291676888252Smrg		    *) newlib_search_path="$newlib_search_path $path";;
291776888252Smrg		    esac
291876888252Smrg		  fi
291976888252Smrg		  path=""
292076888252Smrg		  ;;
292176888252Smrg		*)
292276888252Smrg		  path="-L$path"
292376888252Smrg		  ;;
292476888252Smrg		esac
292576888252Smrg		;;
292676888252Smrg	      -l*)
292776888252Smrg		case $host in
292876888252Smrg		*-*-darwin*)
292976888252Smrg		  # Again, we only want to link against shared libraries
293076888252Smrg		  eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"`
293176888252Smrg		  for tmp in $newlib_search_path ; do
293276888252Smrg		    if test -f "$tmp/lib$tmp_libs.dylib" ; then
293376888252Smrg		      eval depdepl="$tmp/lib$tmp_libs.dylib"
293476888252Smrg		      break
293576888252Smrg		    fi
293676888252Smrg		  done
293776888252Smrg		  path=""
293876888252Smrg		  ;;
293976888252Smrg		*) continue ;;
294076888252Smrg		esac
294176888252Smrg		;;
294276888252Smrg	      *) continue ;;
294376888252Smrg	      esac
294476888252Smrg	      case " $deplibs " in
294576888252Smrg	      *" $path "*) ;;
294676888252Smrg	      *) deplibs="$path $deplibs" ;;
294776888252Smrg	      esac
294876888252Smrg	      case " $deplibs " in
294976888252Smrg	      *" $depdepl "*) ;;
295076888252Smrg	      *) deplibs="$depdepl $deplibs" ;;
295176888252Smrg	      esac
295276888252Smrg	    done
295376888252Smrg	  fi # link_all_deplibs != no
295476888252Smrg	fi # linkmode = lib
295576888252Smrg      done # for deplib in $libs
295676888252Smrg      dependency_libs="$newdependency_libs"
295776888252Smrg      if test "$pass" = dlpreopen; then
295876888252Smrg	# Link the dlpreopened libraries before other libraries
295976888252Smrg	for deplib in $save_deplibs; do
296076888252Smrg	  deplibs="$deplib $deplibs"
296176888252Smrg	done
296276888252Smrg      fi
296376888252Smrg      if test "$pass" != dlopen; then
296476888252Smrg	if test "$pass" != conv; then
296576888252Smrg	  # Make sure lib_search_path contains only unique directories.
296676888252Smrg	  lib_search_path=
296776888252Smrg	  for dir in $newlib_search_path; do
296876888252Smrg	    case "$lib_search_path " in
296976888252Smrg	    *" $dir "*) ;;
297076888252Smrg	    *) lib_search_path="$lib_search_path $dir" ;;
297176888252Smrg	    esac
297276888252Smrg	  done
297376888252Smrg	  newlib_search_path=
297476888252Smrg	fi
297576888252Smrg
297676888252Smrg	if test "$linkmode,$pass" != "prog,link"; then
297776888252Smrg	  vars="deplibs"
297876888252Smrg	else
297976888252Smrg	  vars="compile_deplibs finalize_deplibs"
298076888252Smrg	fi
298176888252Smrg	for var in $vars dependency_libs; do
298276888252Smrg	  # Add libraries to $var in reverse order
298376888252Smrg	  eval tmp_libs=\"\$$var\"
298476888252Smrg	  new_libs=
298576888252Smrg	  for deplib in $tmp_libs; do
298676888252Smrg	    # FIXME: Pedantically, this is the right thing to do, so
298776888252Smrg	    #        that some nasty dependency loop isn't accidentally
298876888252Smrg	    #        broken:
298976888252Smrg	    #new_libs="$deplib $new_libs"
299076888252Smrg	    # Pragmatically, this seems to cause very few problems in
299176888252Smrg	    # practice:
299276888252Smrg	    case $deplib in
299376888252Smrg	    -L*) new_libs="$deplib $new_libs" ;;
299476888252Smrg	    -R*) ;;
299576888252Smrg	    *)
299676888252Smrg	      # And here is the reason: when a library appears more
299776888252Smrg	      # than once as an explicit dependence of a library, or
299876888252Smrg	      # is implicitly linked in more than once by the
299976888252Smrg	      # compiler, it is considered special, and multiple
300076888252Smrg	      # occurrences thereof are not removed.  Compare this
300176888252Smrg	      # with having the same library being listed as a
300276888252Smrg	      # dependency of multiple other libraries: in this case,
300376888252Smrg	      # we know (pedantically, we assume) the library does not
300476888252Smrg	      # need to be listed more than once, so we keep only the
300576888252Smrg	      # last copy.  This is not always right, but it is rare
300676888252Smrg	      # enough that we require users that really mean to play
300776888252Smrg	      # such unportable linking tricks to link the library
300876888252Smrg	      # using -Wl,-lname, so that libtool does not consider it
300976888252Smrg	      # for duplicate removal.
301076888252Smrg	      case " $specialdeplibs " in
301176888252Smrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
301276888252Smrg	      *)
301376888252Smrg		case " $new_libs " in
301476888252Smrg		*" $deplib "*) ;;
301576888252Smrg		*) new_libs="$deplib $new_libs" ;;
301676888252Smrg		esac
301776888252Smrg		;;
301876888252Smrg	      esac
301976888252Smrg	      ;;
302076888252Smrg	    esac
302176888252Smrg	  done
302276888252Smrg	  tmp_libs=
302376888252Smrg	  for deplib in $new_libs; do
302476888252Smrg	    case $deplib in
302576888252Smrg	    -L*)
302676888252Smrg	      case " $tmp_libs " in
302776888252Smrg	      *" $deplib "*) ;;
302876888252Smrg	      *) tmp_libs="$tmp_libs $deplib" ;;
302976888252Smrg	      esac
303076888252Smrg	      ;;
303176888252Smrg	    *) tmp_libs="$tmp_libs $deplib" ;;
303276888252Smrg	    esac
303376888252Smrg	  done
303476888252Smrg	  eval $var=\"$tmp_libs\"
303576888252Smrg	done # for var
303676888252Smrg      fi
303776888252Smrg      # Last step: remove runtime libs from dependency_libs
303876888252Smrg      # (they stay in deplibs)
303976888252Smrg      tmp_libs=
304076888252Smrg      for i in $dependency_libs ; do
304176888252Smrg	case " $predeps $postdeps $compiler_lib_search_path " in
304276888252Smrg	*" $i "*)
304376888252Smrg	  i=""
304476888252Smrg	  ;;
304576888252Smrg	esac
304676888252Smrg	if test -n "$i" ; then
304776888252Smrg	  tmp_libs="$tmp_libs $i"
304876888252Smrg	fi
304976888252Smrg      done
305076888252Smrg      dependency_libs=$tmp_libs
305176888252Smrg    done # for pass
305276888252Smrg    if test "$linkmode" = prog; then
305376888252Smrg      dlfiles="$newdlfiles"
305476888252Smrg      dlprefiles="$newdlprefiles"
305576888252Smrg    fi
305676888252Smrg
305776888252Smrg    case $linkmode in
305876888252Smrg    oldlib)
305976888252Smrg      if test -n "$deplibs"; then
306076888252Smrg	$echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2
306176888252Smrg      fi
306276888252Smrg
306376888252Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
306476888252Smrg	$echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
306576888252Smrg      fi
306676888252Smrg
306776888252Smrg      if test -n "$rpath"; then
306876888252Smrg	$echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2
306976888252Smrg      fi
307076888252Smrg
307176888252Smrg      if test -n "$xrpath"; then
307276888252Smrg	$echo "$modename: warning: \`-R' is ignored for archives" 1>&2
307376888252Smrg      fi
307476888252Smrg
307576888252Smrg      if test -n "$vinfo"; then
307676888252Smrg	$echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2
307776888252Smrg      fi
307876888252Smrg
307976888252Smrg      if test -n "$release"; then
308076888252Smrg	$echo "$modename: warning: \`-release' is ignored for archives" 1>&2
308176888252Smrg      fi
308276888252Smrg
308376888252Smrg      if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
308476888252Smrg	$echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2
308576888252Smrg      fi
308676888252Smrg
308776888252Smrg      # Now set the variables for building old libraries.
308876888252Smrg      build_libtool_libs=no
308976888252Smrg      oldlibs="$output"
309076888252Smrg      objs="$objs$old_deplibs"
309176888252Smrg      ;;
309276888252Smrg
309376888252Smrg    lib)
309476888252Smrg      # Make sure we only generate libraries of the form `libNAME.la'.
309576888252Smrg      case $outputname in
309676888252Smrg      lib*)
309776888252Smrg	name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
309876888252Smrg	eval shared_ext=\"$shrext_cmds\"
309976888252Smrg	eval libname=\"$libname_spec\"
310076888252Smrg	;;
310176888252Smrg      *)
310276888252Smrg	if test "$module" = no; then
310376888252Smrg	  $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
310476888252Smrg	  $echo "$help" 1>&2
310576888252Smrg	  exit $EXIT_FAILURE
310676888252Smrg	fi
310776888252Smrg	if test "$need_lib_prefix" != no; then
310876888252Smrg	  # Add the "lib" prefix for modules if required
310976888252Smrg	  name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
311076888252Smrg	  eval shared_ext=\"$shrext_cmds\"
311176888252Smrg	  eval libname=\"$libname_spec\"
311276888252Smrg	else
311376888252Smrg	  libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
311476888252Smrg	fi
311576888252Smrg	;;
311676888252Smrg      esac
311776888252Smrg
311876888252Smrg      if test -n "$objs"; then
311976888252Smrg	if test "$deplibs_check_method" != pass_all; then
312076888252Smrg	  $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1
312176888252Smrg	  exit $EXIT_FAILURE
312276888252Smrg	else
312376888252Smrg	  $echo
312476888252Smrg	  $echo "*** Warning: Linking the shared library $output against the non-libtool"
312576888252Smrg	  $echo "*** objects $objs is not portable!"
312676888252Smrg	  libobjs="$libobjs $objs"
312776888252Smrg	fi
312876888252Smrg      fi
312976888252Smrg
313076888252Smrg      if test "$dlself" != no; then
313176888252Smrg	$echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2
313276888252Smrg      fi
313376888252Smrg
313476888252Smrg      set dummy $rpath
313576888252Smrg      if test "$#" -gt 2; then
313676888252Smrg	$echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
313776888252Smrg      fi
313876888252Smrg      install_libdir="$2"
313976888252Smrg
314076888252Smrg      oldlibs=
314176888252Smrg      if test -z "$rpath"; then
314276888252Smrg	if test "$build_libtool_libs" = yes; then
314376888252Smrg	  # Building a libtool convenience library.
314476888252Smrg	  # Some compilers have problems with a `.al' extension so
314576888252Smrg	  # convenience libraries should have the same extension an
314676888252Smrg	  # archive normally would.
314776888252Smrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
314876888252Smrg	  build_libtool_libs=convenience
314976888252Smrg	  build_old_libs=yes
315076888252Smrg	fi
315176888252Smrg
315276888252Smrg	if test -n "$vinfo"; then
315376888252Smrg	  $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2
315476888252Smrg	fi
315576888252Smrg
315676888252Smrg	if test -n "$release"; then
315776888252Smrg	  $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2
315876888252Smrg	fi
315976888252Smrg      else
316076888252Smrg
316176888252Smrg	# Parse the version information argument.
316276888252Smrg	save_ifs="$IFS"; IFS=':'
316376888252Smrg	set dummy $vinfo 0 0 0
316476888252Smrg	IFS="$save_ifs"
316576888252Smrg
316676888252Smrg	if test -n "$8"; then
316776888252Smrg	  $echo "$modename: too many parameters to \`-version-info'" 1>&2
316876888252Smrg	  $echo "$help" 1>&2
316976888252Smrg	  exit $EXIT_FAILURE
317076888252Smrg	fi
317176888252Smrg
317276888252Smrg	# convert absolute version numbers to libtool ages
317376888252Smrg	# this retains compatibility with .la files and attempts
317476888252Smrg	# to make the code below a bit more comprehensible
317576888252Smrg
317676888252Smrg	case $vinfo_number in
317776888252Smrg	yes)
317876888252Smrg	  number_major="$2"
317976888252Smrg	  number_minor="$3"
318076888252Smrg	  number_revision="$4"
318176888252Smrg	  #
318276888252Smrg	  # There are really only two kinds -- those that
318376888252Smrg	  # use the current revision as the major version
318476888252Smrg	  # and those that subtract age and use age as
318576888252Smrg	  # a minor version.  But, then there is irix
318676888252Smrg	  # which has an extra 1 added just for fun
318776888252Smrg	  #
318876888252Smrg	  case $version_type in
318976888252Smrg	  darwin|linux|osf|windows)
319076888252Smrg	    current=`expr $number_major + $number_minor`
319176888252Smrg	    age="$number_minor"
319276888252Smrg	    revision="$number_revision"
319376888252Smrg	    ;;
319476888252Smrg	  freebsd-aout|freebsd-elf|sunos)
319576888252Smrg	    current="$number_major"
319676888252Smrg	    revision="$number_minor"
319776888252Smrg	    age="0"
319876888252Smrg	    ;;
319976888252Smrg	  irix|nonstopux)
320076888252Smrg	    current=`expr $number_major + $number_minor - 1`
320176888252Smrg	    age="$number_minor"
320276888252Smrg	    revision="$number_minor"
320376888252Smrg	    ;;
320476888252Smrg	  esac
320576888252Smrg	  ;;
320676888252Smrg	no)
320776888252Smrg	  current="$2"
320876888252Smrg	  revision="$3"
320976888252Smrg	  age="$4"
321076888252Smrg	  ;;
321176888252Smrg	esac
321276888252Smrg
321376888252Smrg	# Check that each of the things are valid numbers.
321476888252Smrg	case $current in
321576888252Smrg	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]) ;;
321676888252Smrg	*)
321776888252Smrg	  $echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2
321876888252Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
321976888252Smrg	  exit $EXIT_FAILURE
322076888252Smrg	  ;;
322176888252Smrg	esac
322276888252Smrg
322376888252Smrg	case $revision in
322476888252Smrg	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]) ;;
322576888252Smrg	*)
322676888252Smrg	  $echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2
322776888252Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
322876888252Smrg	  exit $EXIT_FAILURE
322976888252Smrg	  ;;
323076888252Smrg	esac
323176888252Smrg
323276888252Smrg	case $age in
323376888252Smrg	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]) ;;
323476888252Smrg	*)
323576888252Smrg	  $echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2
323676888252Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
323776888252Smrg	  exit $EXIT_FAILURE
323876888252Smrg	  ;;
323976888252Smrg	esac
324076888252Smrg
324176888252Smrg	if test "$age" -gt "$current"; then
324276888252Smrg	  $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
324376888252Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
324476888252Smrg	  exit $EXIT_FAILURE
324576888252Smrg	fi
324676888252Smrg
324776888252Smrg	# Calculate the version variables.
324876888252Smrg	major=
324976888252Smrg	versuffix=
325076888252Smrg	verstring=
325176888252Smrg	case $version_type in
325276888252Smrg	none) ;;
325376888252Smrg
325476888252Smrg	darwin)
325576888252Smrg	  # Like Linux, but with the current version available in
325676888252Smrg	  # verstring for coding it into the library header
325776888252Smrg	  major=.`expr $current - $age`
325876888252Smrg	  versuffix="$major.$age.$revision"
325976888252Smrg	  # Darwin ld doesn't like 0 for these options...
326076888252Smrg	  minor_current=`expr $current + 1`
326176888252Smrg	  verstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
326276888252Smrg	  ;;
326376888252Smrg
326476888252Smrg	freebsd-aout)
326576888252Smrg	  major=".$current"
326676888252Smrg	  versuffix=".$current.$revision";
326776888252Smrg	  ;;
326876888252Smrg
326976888252Smrg	freebsd-elf)
327076888252Smrg	  major=".$current"
327176888252Smrg	  versuffix=".$current";
327276888252Smrg	  ;;
327376888252Smrg
327476888252Smrg	irix | nonstopux)
327576888252Smrg	  major=`expr $current - $age + 1`
327676888252Smrg
327776888252Smrg	  case $version_type in
327876888252Smrg	    nonstopux) verstring_prefix=nonstopux ;;
327976888252Smrg	    *)         verstring_prefix=sgi ;;
328076888252Smrg	  esac
328176888252Smrg	  verstring="$verstring_prefix$major.$revision"
328276888252Smrg
328376888252Smrg	  # Add in all the interfaces that we are compatible with.
328476888252Smrg	  loop=$revision
328576888252Smrg	  while test "$loop" -ne 0; do
328676888252Smrg	    iface=`expr $revision - $loop`
328776888252Smrg	    loop=`expr $loop - 1`
328876888252Smrg	    verstring="$verstring_prefix$major.$iface:$verstring"
328976888252Smrg	  done
329076888252Smrg
329176888252Smrg	  # Before this point, $major must not contain `.'.
329276888252Smrg	  major=.$major
329376888252Smrg	  versuffix="$major.$revision"
329476888252Smrg	  ;;
329576888252Smrg
329676888252Smrg	linux)
329776888252Smrg	  major=.`expr $current - $age`
329876888252Smrg	  versuffix="$major.$age.$revision"
329976888252Smrg	  ;;
330076888252Smrg
330176888252Smrg	osf)
330276888252Smrg	  major=.`expr $current - $age`
330376888252Smrg	  versuffix=".$current.$age.$revision"
330476888252Smrg	  verstring="$current.$age.$revision"
330576888252Smrg
330676888252Smrg	  # Add in all the interfaces that we are compatible with.
330776888252Smrg	  loop=$age
330876888252Smrg	  while test "$loop" -ne 0; do
330976888252Smrg	    iface=`expr $current - $loop`
331076888252Smrg	    loop=`expr $loop - 1`
331176888252Smrg	    verstring="$verstring:${iface}.0"
331276888252Smrg	  done
331376888252Smrg
331476888252Smrg	  # Make executables depend on our current version.
331576888252Smrg	  verstring="$verstring:${current}.0"
331676888252Smrg	  ;;
331776888252Smrg
331876888252Smrg	sunos)
331976888252Smrg	  major=".$current"
332076888252Smrg	  versuffix=".$current.$revision"
332176888252Smrg	  ;;
332276888252Smrg
332376888252Smrg	windows)
332476888252Smrg	  # Use '-' rather than '.', since we only want one
332576888252Smrg	  # extension on DOS 8.3 filesystems.
332676888252Smrg	  major=`expr $current - $age`
332776888252Smrg	  versuffix="-$major"
332876888252Smrg	  ;;
332976888252Smrg
333076888252Smrg	*)
333176888252Smrg	  $echo "$modename: unknown library version type \`$version_type'" 1>&2
333276888252Smrg	  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
333376888252Smrg	  exit $EXIT_FAILURE
333476888252Smrg	  ;;
333576888252Smrg	esac
333676888252Smrg
333776888252Smrg	# Clear the version info if we defaulted, and they specified a release.
333876888252Smrg	if test -z "$vinfo" && test -n "$release"; then
333976888252Smrg	  major=
334076888252Smrg	  case $version_type in
334176888252Smrg	  darwin)
334276888252Smrg	    # we can't check for "0.0" in archive_cmds due to quoting
334376888252Smrg	    # problems, so we reset it completely
334476888252Smrg	    verstring=
334576888252Smrg	    ;;
334676888252Smrg	  *)
334776888252Smrg	    verstring="0.0"
334876888252Smrg	    ;;
334976888252Smrg	  esac
335076888252Smrg	  if test "$need_version" = no; then
335176888252Smrg	    versuffix=
335276888252Smrg	  else
335376888252Smrg	    versuffix=".0.0"
335476888252Smrg	  fi
335576888252Smrg	fi
335676888252Smrg
335776888252Smrg	# Remove version info from name if versioning should be avoided
335876888252Smrg	if test "$avoid_version" = yes && test "$need_version" = no; then
335976888252Smrg	  major=
336076888252Smrg	  versuffix=
336176888252Smrg	  verstring=""
336276888252Smrg	fi
336376888252Smrg
336476888252Smrg	# Check to see if the archive will have undefined symbols.
336576888252Smrg	if test "$allow_undefined" = yes; then
336676888252Smrg	  if test "$allow_undefined_flag" = unsupported; then
336776888252Smrg	    $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2
336876888252Smrg	    build_libtool_libs=no
336976888252Smrg	    build_old_libs=yes
337076888252Smrg	  fi
337176888252Smrg	else
337276888252Smrg	  # Don't allow undefined symbols.
337376888252Smrg	  allow_undefined_flag="$no_undefined_flag"
337476888252Smrg	fi
337576888252Smrg      fi
337676888252Smrg
337776888252Smrg      if test "$mode" != relink; then
337876888252Smrg	# Remove our outputs, but don't remove object files since they
337976888252Smrg	# may have been created when compiling PIC objects.
338076888252Smrg	removelist=
338176888252Smrg	tempremovelist=`$echo "$output_objdir/*"`
338276888252Smrg	for p in $tempremovelist; do
338376888252Smrg	  case $p in
338476888252Smrg	    *.$objext)
338576888252Smrg	       ;;
338676888252Smrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
338776888252Smrg	       if test "X$precious_files_regex" != "X"; then
338876888252Smrg	         if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
338976888252Smrg	         then
339076888252Smrg		   continue
339176888252Smrg		 fi
339276888252Smrg	       fi
339376888252Smrg	       removelist="$removelist $p"
339476888252Smrg	       ;;
339576888252Smrg	    *) ;;
339676888252Smrg	  esac
339776888252Smrg	done
339876888252Smrg	if test -n "$removelist"; then
339976888252Smrg	  $show "${rm}r $removelist"
340076888252Smrg	  $run ${rm}r $removelist
340176888252Smrg	fi
340276888252Smrg      fi
340376888252Smrg
340476888252Smrg      # Now set the variables for building old libraries.
340576888252Smrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
340676888252Smrg	oldlibs="$oldlibs $output_objdir/$libname.$libext"
340776888252Smrg
340876888252Smrg	# Transform .lo files to .o files.
340976888252Smrg	oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
341076888252Smrg      fi
341176888252Smrg
341276888252Smrg      # Eliminate all temporary directories.
341376888252Smrg      for path in $notinst_path; do
341476888252Smrg	lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"`
341576888252Smrg	deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"`
341676888252Smrg	dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"`
341776888252Smrg      done
341876888252Smrg
341976888252Smrg      if test -n "$xrpath"; then
342076888252Smrg	# If the user specified any rpath flags, then add them.
342176888252Smrg	temp_xrpath=
342276888252Smrg	for libdir in $xrpath; do
342376888252Smrg	  temp_xrpath="$temp_xrpath -R$libdir"
342476888252Smrg	  case "$finalize_rpath " in
342576888252Smrg	  *" $libdir "*) ;;
342676888252Smrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
342776888252Smrg	  esac
342876888252Smrg	done
342976888252Smrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
343076888252Smrg	  dependency_libs="$temp_xrpath $dependency_libs"
343176888252Smrg	fi
343276888252Smrg      fi
343376888252Smrg
343476888252Smrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
343576888252Smrg      old_dlfiles="$dlfiles"
343676888252Smrg      dlfiles=
343776888252Smrg      for lib in $old_dlfiles; do
343876888252Smrg	case " $dlprefiles $dlfiles " in
343976888252Smrg	*" $lib "*) ;;
344076888252Smrg	*) dlfiles="$dlfiles $lib" ;;
344176888252Smrg	esac
344276888252Smrg      done
344376888252Smrg
344476888252Smrg      # Make sure dlprefiles contains only unique files
344576888252Smrg      old_dlprefiles="$dlprefiles"
344676888252Smrg      dlprefiles=
344776888252Smrg      for lib in $old_dlprefiles; do
344876888252Smrg	case "$dlprefiles " in
344976888252Smrg	*" $lib "*) ;;
345076888252Smrg	*) dlprefiles="$dlprefiles $lib" ;;
345176888252Smrg	esac
345276888252Smrg      done
345376888252Smrg
345476888252Smrg      if test "$build_libtool_libs" = yes; then
345576888252Smrg	if test -n "$rpath"; then
345676888252Smrg	  case $host in
345776888252Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*)
345876888252Smrg	    # these systems don't actually have a c library (as such)!
345976888252Smrg	    ;;
346076888252Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
346176888252Smrg	    # Rhapsody C library is in the System framework
346276888252Smrg	    deplibs="$deplibs -framework System"
346376888252Smrg	    ;;
346476888252Smrg	  *-*-netbsd*)
346576888252Smrg	    # Don't link with libc until the a.out ld.so is fixed.
346676888252Smrg	    ;;
346776888252Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
346876888252Smrg	    # Do not include libc due to us having libc/libc_r.
346976888252Smrg	    ;;
347076888252Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
347176888252Smrg	    # Causes problems with __ctype
347276888252Smrg	    ;;
347376888252Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
347476888252Smrg	    # Compiler inserts libc in the correct place for threads to work
347576888252Smrg	    ;;
347676888252Smrg 	  *)
347776888252Smrg	    # Add libc to deplibs on all other systems if necessary.
347876888252Smrg	    if test "$build_libtool_need_lc" = "yes"; then
347976888252Smrg	      deplibs="$deplibs -lc"
348076888252Smrg	    fi
348176888252Smrg	    ;;
348276888252Smrg	  esac
348376888252Smrg	fi
348476888252Smrg
348576888252Smrg	# Transform deplibs into only deplibs that can be linked in shared.
348676888252Smrg	name_save=$name
348776888252Smrg	libname_save=$libname
348876888252Smrg	release_save=$release
348976888252Smrg	versuffix_save=$versuffix
349076888252Smrg	major_save=$major
349176888252Smrg	# I'm not sure if I'm treating the release correctly.  I think
349276888252Smrg	# release should show up in the -l (ie -lgmp5) so we don't want to
349376888252Smrg	# add it in twice.  Is that correct?
349476888252Smrg	release=""
349576888252Smrg	versuffix=""
349676888252Smrg	major=""
349776888252Smrg	newdeplibs=
349876888252Smrg	droppeddeps=no
349976888252Smrg	case $deplibs_check_method in
350076888252Smrg	pass_all)
350176888252Smrg	  # Don't check for shared/static.  Everything works.
350276888252Smrg	  # This might be a little naive.  We might want to check
350376888252Smrg	  # whether the library exists or not.  But this is on
350476888252Smrg	  # osf3 & osf4 and I'm not really sure... Just
350576888252Smrg	  # implementing what was already the behavior.
350676888252Smrg	  newdeplibs=$deplibs
350776888252Smrg	  ;;
350876888252Smrg	test_compile)
350976888252Smrg	  # This code stresses the "libraries are programs" paradigm to its
351076888252Smrg	  # limits. Maybe even breaks it.  We compile a program, linking it
351176888252Smrg	  # against the deplibs as a proxy for the library.  Then we can check
351276888252Smrg	  # whether they linked in statically or dynamically with ldd.
351376888252Smrg	  $rm conftest.c
351476888252Smrg	  cat > conftest.c <<EOF
351576888252Smrg	  int main() { return 0; }
351676888252SmrgEOF
351776888252Smrg	  $rm conftest
351876888252Smrg	  $LTCC $LTCFLAGS -o conftest conftest.c $deplibs
351976888252Smrg	  if test "$?" -eq 0 ; then
352076888252Smrg	    ldd_output=`ldd conftest`
352176888252Smrg	    for i in $deplibs; do
352276888252Smrg	      name=`expr $i : '-l\(.*\)'`
352376888252Smrg	      # If $name is empty we are operating on a -L argument.
352476888252Smrg              if test "$name" != "" && test "$name" -ne "0"; then
352576888252Smrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
352676888252Smrg		  case " $predeps $postdeps " in
352776888252Smrg		  *" $i "*)
352876888252Smrg		    newdeplibs="$newdeplibs $i"
352976888252Smrg		    i=""
353076888252Smrg		    ;;
353176888252Smrg		  esac
353276888252Smrg	        fi
353376888252Smrg		if test -n "$i" ; then
353476888252Smrg		  libname=`eval \\$echo \"$libname_spec\"`
353576888252Smrg		  deplib_matches=`eval \\$echo \"$library_names_spec\"`
353676888252Smrg		  set dummy $deplib_matches
353776888252Smrg		  deplib_match=$2
353876888252Smrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
353976888252Smrg		    newdeplibs="$newdeplibs $i"
354076888252Smrg		  else
354176888252Smrg		    droppeddeps=yes
354276888252Smrg		    $echo
354376888252Smrg		    $echo "*** Warning: dynamic linker does not accept needed library $i."
354476888252Smrg		    $echo "*** I have the capability to make that library automatically link in when"
354576888252Smrg		    $echo "*** you link to this library.  But I can only do this if you have a"
354676888252Smrg		    $echo "*** shared version of the library, which I believe you do not have"
354776888252Smrg		    $echo "*** because a test_compile did reveal that the linker did not use it for"
354876888252Smrg		    $echo "*** its dynamic dependency list that programs get resolved with at runtime."
354976888252Smrg		  fi
355076888252Smrg		fi
355176888252Smrg	      else
355276888252Smrg		newdeplibs="$newdeplibs $i"
355376888252Smrg	      fi
355476888252Smrg	    done
355576888252Smrg	  else
355676888252Smrg	    # Error occurred in the first compile.  Let's try to salvage
355776888252Smrg	    # the situation: Compile a separate program for each library.
355876888252Smrg	    for i in $deplibs; do
355976888252Smrg	      name=`expr $i : '-l\(.*\)'`
356076888252Smrg	      # If $name is empty we are operating on a -L argument.
356176888252Smrg              if test "$name" != "" && test "$name" != "0"; then
356276888252Smrg		$rm conftest
356376888252Smrg		$LTCC $LTCFLAGS -o conftest conftest.c $i
356476888252Smrg		# Did it work?
356576888252Smrg		if test "$?" -eq 0 ; then
356676888252Smrg		  ldd_output=`ldd conftest`
356776888252Smrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
356876888252Smrg		    case " $predeps $postdeps " in
356976888252Smrg		    *" $i "*)
357076888252Smrg		      newdeplibs="$newdeplibs $i"
357176888252Smrg		      i=""
357276888252Smrg		      ;;
357376888252Smrg		    esac
357476888252Smrg		  fi
357576888252Smrg		  if test -n "$i" ; then
357676888252Smrg		    libname=`eval \\$echo \"$libname_spec\"`
357776888252Smrg		    deplib_matches=`eval \\$echo \"$library_names_spec\"`
357876888252Smrg		    set dummy $deplib_matches
357976888252Smrg		    deplib_match=$2
358076888252Smrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
358176888252Smrg		      newdeplibs="$newdeplibs $i"
358276888252Smrg		    else
358376888252Smrg		      droppeddeps=yes
358476888252Smrg		      $echo
358576888252Smrg		      $echo "*** Warning: dynamic linker does not accept needed library $i."
358676888252Smrg		      $echo "*** I have the capability to make that library automatically link in when"
358776888252Smrg		      $echo "*** you link to this library.  But I can only do this if you have a"
358876888252Smrg		      $echo "*** shared version of the library, which you do not appear to have"
358976888252Smrg		      $echo "*** because a test_compile did reveal that the linker did not use this one"
359076888252Smrg		      $echo "*** as a dynamic dependency that programs can get resolved with at runtime."
359176888252Smrg		    fi
359276888252Smrg		  fi
359376888252Smrg		else
359476888252Smrg		  droppeddeps=yes
359576888252Smrg		  $echo
359676888252Smrg		  $echo "*** Warning!  Library $i is needed by this library but I was not able to"
359776888252Smrg		  $echo "***  make it link in!  You will probably need to install it or some"
359876888252Smrg		  $echo "*** library that it depends on before this library will be fully"
359976888252Smrg		  $echo "*** functional.  Installing it before continuing would be even better."
360076888252Smrg		fi
360176888252Smrg	      else
360276888252Smrg		newdeplibs="$newdeplibs $i"
360376888252Smrg	      fi
360476888252Smrg	    done
360576888252Smrg	  fi
360676888252Smrg	  ;;
360776888252Smrg	file_magic*)
360876888252Smrg	  set dummy $deplibs_check_method
360976888252Smrg	  file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
361076888252Smrg	  for a_deplib in $deplibs; do
361176888252Smrg	    name=`expr $a_deplib : '-l\(.*\)'`
361276888252Smrg	    # If $name is empty we are operating on a -L argument.
361376888252Smrg            if test "$name" != "" && test  "$name" != "0"; then
361476888252Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
361576888252Smrg		case " $predeps $postdeps " in
361676888252Smrg		*" $a_deplib "*)
361776888252Smrg		  newdeplibs="$newdeplibs $a_deplib"
361876888252Smrg		  a_deplib=""
361976888252Smrg		  ;;
362076888252Smrg		esac
362176888252Smrg	      fi
362276888252Smrg	      if test -n "$a_deplib" ; then
362376888252Smrg		libname=`eval \\$echo \"$libname_spec\"`
362476888252Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
362576888252Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
362676888252Smrg		  for potent_lib in $potential_libs; do
362776888252Smrg		      # Follow soft links.
362876888252Smrg		      if ls -lLd "$potent_lib" 2>/dev/null \
362976888252Smrg			 | grep " -> " >/dev/null; then
363076888252Smrg			continue
363176888252Smrg		      fi
363276888252Smrg		      # The statement above tries to avoid entering an
363376888252Smrg		      # endless loop below, in case of cyclic links.
363476888252Smrg		      # We might still enter an endless loop, since a link
363576888252Smrg		      # loop can be closed while we follow links,
363676888252Smrg		      # but so what?
363776888252Smrg		      potlib="$potent_lib"
363876888252Smrg		      while test -h "$potlib" 2>/dev/null; do
363976888252Smrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
364076888252Smrg			case $potliblink in
364176888252Smrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
364276888252Smrg			*) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
364376888252Smrg			esac
364476888252Smrg		      done
364576888252Smrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
364676888252Smrg			 | ${SED} 10q \
364776888252Smrg			 | $EGREP "$file_magic_regex" > /dev/null; then
364876888252Smrg			newdeplibs="$newdeplibs $a_deplib"
364976888252Smrg			a_deplib=""
365076888252Smrg			break 2
365176888252Smrg		      fi
365276888252Smrg		  done
365376888252Smrg		done
365476888252Smrg	      fi
365576888252Smrg	      if test -n "$a_deplib" ; then
365676888252Smrg		droppeddeps=yes
365776888252Smrg		$echo
365876888252Smrg		$echo "*** Warning: linker path does not have real file for library $a_deplib."
365976888252Smrg		$echo "*** I have the capability to make that library automatically link in when"
366076888252Smrg		$echo "*** you link to this library.  But I can only do this if you have a"
366176888252Smrg		$echo "*** shared version of the library, which you do not appear to have"
366276888252Smrg		$echo "*** because I did check the linker path looking for a file starting"
366376888252Smrg		if test -z "$potlib" ; then
366476888252Smrg		  $echo "*** with $libname but no candidates were found. (...for file magic test)"
366576888252Smrg		else
366676888252Smrg		  $echo "*** with $libname and none of the candidates passed a file format test"
366776888252Smrg		  $echo "*** using a file magic. Last file checked: $potlib"
366876888252Smrg		fi
366976888252Smrg	      fi
367076888252Smrg	    else
367176888252Smrg	      # Add a -L argument.
367276888252Smrg	      newdeplibs="$newdeplibs $a_deplib"
367376888252Smrg	    fi
367476888252Smrg	  done # Gone through all deplibs.
367576888252Smrg	  ;;
367676888252Smrg	match_pattern*)
367776888252Smrg	  set dummy $deplibs_check_method
367876888252Smrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
367976888252Smrg	  for a_deplib in $deplibs; do
368076888252Smrg	    name=`expr $a_deplib : '-l\(.*\)'`
368176888252Smrg	    # If $name is empty we are operating on a -L argument.
368276888252Smrg	    if test -n "$name" && test "$name" != "0"; then
368376888252Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
368476888252Smrg		case " $predeps $postdeps " in
368576888252Smrg		*" $a_deplib "*)
368676888252Smrg		  newdeplibs="$newdeplibs $a_deplib"
368776888252Smrg		  a_deplib=""
368876888252Smrg		  ;;
368976888252Smrg		esac
369076888252Smrg	      fi
369176888252Smrg	      if test -n "$a_deplib" ; then
369276888252Smrg		libname=`eval \\$echo \"$libname_spec\"`
369376888252Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
369476888252Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
369576888252Smrg		  for potent_lib in $potential_libs; do
369676888252Smrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
369776888252Smrg		    if eval $echo \"$potent_lib\" 2>/dev/null \
369876888252Smrg		        | ${SED} 10q \
369976888252Smrg		        | $EGREP "$match_pattern_regex" > /dev/null; then
370076888252Smrg		      newdeplibs="$newdeplibs $a_deplib"
370176888252Smrg		      a_deplib=""
370276888252Smrg		      break 2
370376888252Smrg		    fi
370476888252Smrg		  done
370576888252Smrg		done
370676888252Smrg	      fi
370776888252Smrg	      if test -n "$a_deplib" ; then
370876888252Smrg		droppeddeps=yes
370976888252Smrg		$echo
371076888252Smrg		$echo "*** Warning: linker path does not have real file for library $a_deplib."
371176888252Smrg		$echo "*** I have the capability to make that library automatically link in when"
371276888252Smrg		$echo "*** you link to this library.  But I can only do this if you have a"
371376888252Smrg		$echo "*** shared version of the library, which you do not appear to have"
371476888252Smrg		$echo "*** because I did check the linker path looking for a file starting"
371576888252Smrg		if test -z "$potlib" ; then
371676888252Smrg		  $echo "*** with $libname but no candidates were found. (...for regex pattern test)"
371776888252Smrg		else
371876888252Smrg		  $echo "*** with $libname and none of the candidates passed a file format test"
371976888252Smrg		  $echo "*** using a regex pattern. Last file checked: $potlib"
372076888252Smrg		fi
372176888252Smrg	      fi
372276888252Smrg	    else
372376888252Smrg	      # Add a -L argument.
372476888252Smrg	      newdeplibs="$newdeplibs $a_deplib"
372576888252Smrg	    fi
372676888252Smrg	  done # Gone through all deplibs.
372776888252Smrg	  ;;
372876888252Smrg	none | unknown | *)
372976888252Smrg	  newdeplibs=""
373076888252Smrg	  tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
373176888252Smrg	    -e 's/ -[LR][^ ]*//g'`
373276888252Smrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
373376888252Smrg	    for i in $predeps $postdeps ; do
373476888252Smrg	      # can't use Xsed below, because $i might contain '/'
373576888252Smrg	      tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"`
373676888252Smrg	    done
373776888252Smrg	  fi
373876888252Smrg	  if $echo "X $tmp_deplibs" | $Xsed -e 's/[ 	]//g' \
373976888252Smrg	    | grep . >/dev/null; then
374076888252Smrg	    $echo
374176888252Smrg	    if test "X$deplibs_check_method" = "Xnone"; then
374276888252Smrg	      $echo "*** Warning: inter-library dependencies are not supported in this platform."
374376888252Smrg	    else
374476888252Smrg	      $echo "*** Warning: inter-library dependencies are not known to be supported."
374576888252Smrg	    fi
374676888252Smrg	    $echo "*** All declared inter-library dependencies are being dropped."
374776888252Smrg	    droppeddeps=yes
374876888252Smrg	  fi
374976888252Smrg	  ;;
375076888252Smrg	esac
375176888252Smrg	versuffix=$versuffix_save
375276888252Smrg	major=$major_save
375376888252Smrg	release=$release_save
375476888252Smrg	libname=$libname_save
375576888252Smrg	name=$name_save
375676888252Smrg
375776888252Smrg	case $host in
375876888252Smrg	*-*-rhapsody* | *-*-darwin1.[012])
375976888252Smrg	  # On Rhapsody replace the C library is the System framework
376076888252Smrg	  newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'`
376176888252Smrg	  ;;
376276888252Smrg	esac
376376888252Smrg
376476888252Smrg	if test "$droppeddeps" = yes; then
376576888252Smrg	  if test "$module" = yes; then
376676888252Smrg	    $echo
376776888252Smrg	    $echo "*** Warning: libtool could not satisfy all declared inter-library"
376876888252Smrg	    $echo "*** dependencies of module $libname.  Therefore, libtool will create"
376976888252Smrg	    $echo "*** a static module, that should work as long as the dlopening"
377076888252Smrg	    $echo "*** application is linked with the -dlopen flag."
377176888252Smrg	    if test -z "$global_symbol_pipe"; then
377276888252Smrg	      $echo
377376888252Smrg	      $echo "*** However, this would only work if libtool was able to extract symbol"
377476888252Smrg	      $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
377576888252Smrg	      $echo "*** not find such a program.  So, this module is probably useless."
377676888252Smrg	      $echo "*** \`nm' from GNU binutils and a full rebuild may help."
377776888252Smrg	    fi
377876888252Smrg	    if test "$build_old_libs" = no; then
377976888252Smrg	      oldlibs="$output_objdir/$libname.$libext"
378076888252Smrg	      build_libtool_libs=module
378176888252Smrg	      build_old_libs=yes
378276888252Smrg	    else
378376888252Smrg	      build_libtool_libs=no
378476888252Smrg	    fi
378576888252Smrg	  else
378676888252Smrg	    $echo "*** The inter-library dependencies that have been dropped here will be"
378776888252Smrg	    $echo "*** automatically added whenever a program is linked with this library"
378876888252Smrg	    $echo "*** or is declared to -dlopen it."
378976888252Smrg
379076888252Smrg	    if test "$allow_undefined" = no; then
379176888252Smrg	      $echo
379276888252Smrg	      $echo "*** Since this library must not contain undefined symbols,"
379376888252Smrg	      $echo "*** because either the platform does not support them or"
379476888252Smrg	      $echo "*** it was explicitly requested with -no-undefined,"
379576888252Smrg	      $echo "*** libtool will only create a static version of it."
379676888252Smrg	      if test "$build_old_libs" = no; then
379776888252Smrg		oldlibs="$output_objdir/$libname.$libext"
379876888252Smrg		build_libtool_libs=module
379976888252Smrg		build_old_libs=yes
380076888252Smrg	      else
380176888252Smrg		build_libtool_libs=no
380276888252Smrg	      fi
380376888252Smrg	    fi
380476888252Smrg	  fi
380576888252Smrg	fi
380676888252Smrg	# Done checking deplibs!
380776888252Smrg	deplibs=$newdeplibs
380876888252Smrg      fi
380976888252Smrg
381076888252Smrg
381176888252Smrg      # move library search paths that coincide with paths to not yet
381276888252Smrg      # installed libraries to the beginning of the library search list
381376888252Smrg      new_libs=
381476888252Smrg      for path in $notinst_path; do
381576888252Smrg	case " $new_libs " in
381676888252Smrg	*" -L$path/$objdir "*) ;;
381776888252Smrg	*)
381876888252Smrg	  case " $deplibs " in
381976888252Smrg	  *" -L$path/$objdir "*)
382076888252Smrg	    new_libs="$new_libs -L$path/$objdir" ;;
382176888252Smrg	  esac
382276888252Smrg	  ;;
382376888252Smrg	esac
382476888252Smrg      done
382576888252Smrg      for deplib in $deplibs; do
382676888252Smrg	case $deplib in
382776888252Smrg	-L*)
382876888252Smrg	  case " $new_libs " in
382976888252Smrg	  *" $deplib "*) ;;
383076888252Smrg	  *) new_libs="$new_libs $deplib" ;;
383176888252Smrg	  esac
383276888252Smrg	  ;;
383376888252Smrg	*) new_libs="$new_libs $deplib" ;;
383476888252Smrg	esac
383576888252Smrg      done
383676888252Smrg      deplibs="$new_libs"
383776888252Smrg
383876888252Smrg
383976888252Smrg      # All the library-specific variables (install_libdir is set above).
384076888252Smrg      library_names=
384176888252Smrg      old_library=
384276888252Smrg      dlname=
384376888252Smrg
384476888252Smrg      # Test again, we may have decided not to build it any more
384576888252Smrg      if test "$build_libtool_libs" = yes; then
384676888252Smrg	if test "$hardcode_into_libs" = yes; then
384776888252Smrg	  # Hardcode the library paths
384876888252Smrg	  hardcode_libdirs=
384976888252Smrg	  dep_rpath=
385076888252Smrg	  rpath="$finalize_rpath"
385176888252Smrg	  test "$mode" != relink && rpath="$compile_rpath$rpath"
385276888252Smrg	  for libdir in $rpath; do
385376888252Smrg	    if test -n "$hardcode_libdir_flag_spec"; then
385476888252Smrg	      if test -n "$hardcode_libdir_separator"; then
385576888252Smrg		if test -z "$hardcode_libdirs"; then
385676888252Smrg		  hardcode_libdirs="$libdir"
385776888252Smrg		else
385876888252Smrg		  # Just accumulate the unique libdirs.
385976888252Smrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
386076888252Smrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
386176888252Smrg		    ;;
386276888252Smrg		  *)
386376888252Smrg		    hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
386476888252Smrg		    ;;
386576888252Smrg		  esac
386676888252Smrg		fi
386776888252Smrg	      else
386876888252Smrg		eval flag=\"$hardcode_libdir_flag_spec\"
386976888252Smrg		dep_rpath="$dep_rpath $flag"
387076888252Smrg	      fi
387176888252Smrg	    elif test -n "$runpath_var"; then
387276888252Smrg	      case "$perm_rpath " in
387376888252Smrg	      *" $libdir "*) ;;
387476888252Smrg	      *) perm_rpath="$perm_rpath $libdir" ;;
387576888252Smrg	      esac
387676888252Smrg	    fi
387776888252Smrg	  done
387876888252Smrg	  # Substitute the hardcoded libdirs into the rpath.
387976888252Smrg	  if test -n "$hardcode_libdir_separator" &&
388076888252Smrg	     test -n "$hardcode_libdirs"; then
388176888252Smrg	    libdir="$hardcode_libdirs"
388276888252Smrg	    if test -n "$hardcode_libdir_flag_spec_ld"; then
388376888252Smrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
388476888252Smrg	    else
388576888252Smrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
388676888252Smrg	    fi
388776888252Smrg	  fi
388876888252Smrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
388976888252Smrg	    # We should set the runpath_var.
389076888252Smrg	    rpath=
389176888252Smrg	    for dir in $perm_rpath; do
389276888252Smrg	      rpath="$rpath$dir:"
389376888252Smrg	    done
389476888252Smrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
389576888252Smrg	  fi
389676888252Smrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
389776888252Smrg	fi
389876888252Smrg
389976888252Smrg	shlibpath="$finalize_shlibpath"
390076888252Smrg	test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
390176888252Smrg	if test -n "$shlibpath"; then
390276888252Smrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
390376888252Smrg	fi
390476888252Smrg
390576888252Smrg	# Get the real and link names of the library.
390676888252Smrg	eval shared_ext=\"$shrext_cmds\"
390776888252Smrg	eval library_names=\"$library_names_spec\"
390876888252Smrg	set dummy $library_names
390976888252Smrg	realname="$2"
391076888252Smrg	shift; shift
391176888252Smrg
391276888252Smrg	if test -n "$soname_spec"; then
391376888252Smrg	  eval soname=\"$soname_spec\"
391476888252Smrg	else
391576888252Smrg	  soname="$realname"
391676888252Smrg	fi
391776888252Smrg	if test -z "$dlname"; then
391876888252Smrg	  dlname=$soname
391976888252Smrg	fi
392076888252Smrg
392176888252Smrg	lib="$output_objdir/$realname"
392276888252Smrg	linknames=
392376888252Smrg	for link
392476888252Smrg	do
392576888252Smrg	  linknames="$linknames $link"
392676888252Smrg	done
392776888252Smrg
392876888252Smrg	# Use standard objects if they are pic
392976888252Smrg	test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
393076888252Smrg
393176888252Smrg	# Prepare the list of exported symbols
393276888252Smrg	if test -z "$export_symbols"; then
393376888252Smrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
393476888252Smrg	    $show "generating symbol list for \`$libname.la'"
393576888252Smrg	    export_symbols="$output_objdir/$libname.exp"
393676888252Smrg	    $run $rm $export_symbols
393776888252Smrg	    cmds=$export_symbols_cmds
393876888252Smrg	    save_ifs="$IFS"; IFS='~'
393976888252Smrg	    for cmd in $cmds; do
394076888252Smrg	      IFS="$save_ifs"
394176888252Smrg	      eval cmd=\"$cmd\"
394276888252Smrg	      if len=`expr "X$cmd" : ".*"` &&
394376888252Smrg	       test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
394476888252Smrg	        $show "$cmd"
394576888252Smrg	        $run eval "$cmd" || exit $?
394676888252Smrg	        skipped_export=false
394776888252Smrg	      else
394876888252Smrg	        # The command line is too long to execute in one step.
394976888252Smrg	        $show "using reloadable object file for export list..."
395076888252Smrg	        skipped_export=:
395176888252Smrg		# Break out early, otherwise skipped_export may be
395276888252Smrg		# set to false by a later but shorter cmd.
395376888252Smrg		break
395476888252Smrg	      fi
395576888252Smrg	    done
395676888252Smrg	    IFS="$save_ifs"
395776888252Smrg	    if test -n "$export_symbols_regex"; then
395876888252Smrg	      $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""
395976888252Smrg	      $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
396076888252Smrg	      $show "$mv \"${export_symbols}T\" \"$export_symbols\""
396176888252Smrg	      $run eval '$mv "${export_symbols}T" "$export_symbols"'
396276888252Smrg	    fi
396376888252Smrg	  fi
396476888252Smrg	fi
396576888252Smrg
396676888252Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
396776888252Smrg	  $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"'
396876888252Smrg	fi
396976888252Smrg
397076888252Smrg	tmp_deplibs=
397176888252Smrg	for test_deplib in $deplibs; do
397276888252Smrg		case " $convenience " in
397376888252Smrg		*" $test_deplib "*) ;;
397476888252Smrg		*)
397576888252Smrg			tmp_deplibs="$tmp_deplibs $test_deplib"
397676888252Smrg			;;
397776888252Smrg		esac
397876888252Smrg	done
397976888252Smrg	deplibs="$tmp_deplibs"
398076888252Smrg
398176888252Smrg	if test -n "$convenience"; then
398276888252Smrg	  if test -n "$whole_archive_flag_spec"; then
398376888252Smrg	    save_libobjs=$libobjs
398476888252Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
398576888252Smrg	  else
398676888252Smrg	    gentop="$output_objdir/${outputname}x"
398776888252Smrg	    generated="$generated $gentop"
398876888252Smrg
398976888252Smrg	    func_extract_archives $gentop $convenience
399076888252Smrg	    libobjs="$libobjs $func_extract_archives_result"
399176888252Smrg	  fi
399276888252Smrg	fi
399376888252Smrg	
399476888252Smrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
399576888252Smrg	  eval flag=\"$thread_safe_flag_spec\"
399676888252Smrg	  linker_flags="$linker_flags $flag"
399776888252Smrg	fi
399876888252Smrg
399976888252Smrg	# Make a backup of the uninstalled library when relinking
400076888252Smrg	if test "$mode" = relink; then
400176888252Smrg	  $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $?
400276888252Smrg	fi
400376888252Smrg
400476888252Smrg	# Do each of the archive commands.
400576888252Smrg	if test "$module" = yes && test -n "$module_cmds" ; then
400676888252Smrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
400776888252Smrg	    eval test_cmds=\"$module_expsym_cmds\"
400876888252Smrg	    cmds=$module_expsym_cmds
400976888252Smrg	  else
401076888252Smrg	    eval test_cmds=\"$module_cmds\"
401176888252Smrg	    cmds=$module_cmds
401276888252Smrg	  fi
401376888252Smrg	else
401476888252Smrg	if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
401576888252Smrg	  eval test_cmds=\"$archive_expsym_cmds\"
401676888252Smrg	  cmds=$archive_expsym_cmds
401776888252Smrg	else
401876888252Smrg	  eval test_cmds=\"$archive_cmds\"
401976888252Smrg	  cmds=$archive_cmds
402076888252Smrg	  fi
402176888252Smrg	fi
402276888252Smrg
402376888252Smrg	if test "X$skipped_export" != "X:" &&
402476888252Smrg	   len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
402576888252Smrg	   test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
402676888252Smrg	  :
402776888252Smrg	else
402876888252Smrg	  # The command line is too long to link in one step, link piecewise.
402976888252Smrg	  $echo "creating reloadable object files..."
403076888252Smrg
403176888252Smrg	  # Save the value of $output and $libobjs because we want to
403276888252Smrg	  # use them later.  If we have whole_archive_flag_spec, we
403376888252Smrg	  # want to use save_libobjs as it was before
403476888252Smrg	  # whole_archive_flag_spec was expanded, because we can't
403576888252Smrg	  # assume the linker understands whole_archive_flag_spec.
403676888252Smrg	  # This may have to be revisited, in case too many
403776888252Smrg	  # convenience libraries get linked in and end up exceeding
403876888252Smrg	  # the spec.
403976888252Smrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
404076888252Smrg	    save_libobjs=$libobjs
404176888252Smrg	  fi
404276888252Smrg	  save_output=$output
404376888252Smrg	  output_la=`$echo "X$output" | $Xsed -e "$basename"`
404476888252Smrg
404576888252Smrg	  # Clear the reloadable object creation command queue and
404676888252Smrg	  # initialize k to one.
404776888252Smrg	  test_cmds=
404876888252Smrg	  concat_cmds=
404976888252Smrg	  objlist=
405076888252Smrg	  delfiles=
405176888252Smrg	  last_robj=
405276888252Smrg	  k=1
405376888252Smrg	  output=$output_objdir/$output_la-${k}.$objext
405476888252Smrg	  # Loop over the list of objects to be linked.
405576888252Smrg	  for obj in $save_libobjs
405676888252Smrg	  do
405776888252Smrg	    eval test_cmds=\"$reload_cmds $objlist $last_robj\"
405876888252Smrg	    if test "X$objlist" = X ||
405976888252Smrg	       { len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
406076888252Smrg		 test "$len" -le "$max_cmd_len"; }; then
406176888252Smrg	      objlist="$objlist $obj"
406276888252Smrg	    else
406376888252Smrg	      # The command $test_cmds is almost too long, add a
406476888252Smrg	      # command to the queue.
406576888252Smrg	      if test "$k" -eq 1 ; then
406676888252Smrg		# The first file doesn't have a previous command to add.
406776888252Smrg		eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
406876888252Smrg	      else
406976888252Smrg		# All subsequent reloadable object files will link in
407076888252Smrg		# the last one created.
407176888252Smrg		eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\"
407276888252Smrg	      fi
407376888252Smrg	      last_robj=$output_objdir/$output_la-${k}.$objext
407476888252Smrg	      k=`expr $k + 1`
407576888252Smrg	      output=$output_objdir/$output_la-${k}.$objext
407676888252Smrg	      objlist=$obj
407776888252Smrg	      len=1
407876888252Smrg	    fi
407976888252Smrg	  done
408076888252Smrg	  # Handle the remaining objects by creating one last
408176888252Smrg	  # reloadable object file.  All subsequent reloadable object
408276888252Smrg	  # files will link in the last one created.
408376888252Smrg	  test -z "$concat_cmds" || concat_cmds=$concat_cmds~
408476888252Smrg	  eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
408576888252Smrg
408676888252Smrg	  if ${skipped_export-false}; then
408776888252Smrg	    $show "generating symbol list for \`$libname.la'"
408876888252Smrg	    export_symbols="$output_objdir/$libname.exp"
408976888252Smrg	    $run $rm $export_symbols
409076888252Smrg	    libobjs=$output
409176888252Smrg	    # Append the command to create the export file.
409276888252Smrg	    eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\"
409376888252Smrg          fi
409476888252Smrg
409576888252Smrg	  # Set up a command to remove the reloadable object files
409676888252Smrg	  # after they are used.
409776888252Smrg	  i=0
409876888252Smrg	  while test "$i" -lt "$k"
409976888252Smrg	  do
410076888252Smrg	    i=`expr $i + 1`
410176888252Smrg	    delfiles="$delfiles $output_objdir/$output_la-${i}.$objext"
410276888252Smrg	  done
410376888252Smrg
410476888252Smrg	  $echo "creating a temporary reloadable object file: $output"
410576888252Smrg
410676888252Smrg	  # Loop through the commands generated above and execute them.
410776888252Smrg	  save_ifs="$IFS"; IFS='~'
410876888252Smrg	  for cmd in $concat_cmds; do
410976888252Smrg	    IFS="$save_ifs"
411076888252Smrg	    $show "$cmd"
411176888252Smrg	    $run eval "$cmd" || exit $?
411276888252Smrg	  done
411376888252Smrg	  IFS="$save_ifs"
411476888252Smrg
411576888252Smrg	  libobjs=$output
411676888252Smrg	  # Restore the value of output.
411776888252Smrg	  output=$save_output
411876888252Smrg
411976888252Smrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
412076888252Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
412176888252Smrg	  fi
412276888252Smrg	  # Expand the library linking commands again to reset the
412376888252Smrg	  # value of $libobjs for piecewise linking.
412476888252Smrg
412576888252Smrg	  # Do each of the archive commands.
412676888252Smrg	  if test "$module" = yes && test -n "$module_cmds" ; then
412776888252Smrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
412876888252Smrg	      cmds=$module_expsym_cmds
412976888252Smrg	    else
413076888252Smrg	      cmds=$module_cmds
413176888252Smrg	    fi
413276888252Smrg	  else
413376888252Smrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
413476888252Smrg	    cmds=$archive_expsym_cmds
413576888252Smrg	  else
413676888252Smrg	    cmds=$archive_cmds
413776888252Smrg	    fi
413876888252Smrg	  fi
413976888252Smrg
414076888252Smrg	  # Append the command to remove the reloadable object files
414176888252Smrg	  # to the just-reset $cmds.
414276888252Smrg	  eval cmds=\"\$cmds~\$rm $delfiles\"
414376888252Smrg	fi
414476888252Smrg	save_ifs="$IFS"; IFS='~'
414576888252Smrg	for cmd in $cmds; do
414676888252Smrg	  IFS="$save_ifs"
414776888252Smrg	  eval cmd=\"$cmd\"
414876888252Smrg	  $show "$cmd"
414976888252Smrg	  $run eval "$cmd" || {
415076888252Smrg	    lt_exit=$?
415176888252Smrg
415276888252Smrg	    # Restore the uninstalled library and exit
415376888252Smrg	    if test "$mode" = relink; then
415476888252Smrg	      $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
415576888252Smrg	    fi
415676888252Smrg
415776888252Smrg	    exit $lt_exit
415876888252Smrg	  }
415976888252Smrg	done
416076888252Smrg	IFS="$save_ifs"
416176888252Smrg
416276888252Smrg	# Restore the uninstalled library and exit
416376888252Smrg	if test "$mode" = relink; then
416476888252Smrg	  $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $?
416576888252Smrg
416676888252Smrg	  if test -n "$convenience"; then
416776888252Smrg	    if test -z "$whole_archive_flag_spec"; then
416876888252Smrg	      $show "${rm}r $gentop"
416976888252Smrg	      $run ${rm}r "$gentop"
417076888252Smrg	    fi
417176888252Smrg	  fi
417276888252Smrg
417376888252Smrg	  exit $EXIT_SUCCESS
417476888252Smrg	fi
417576888252Smrg
417676888252Smrg	# Create links to the real library.
417776888252Smrg	for linkname in $linknames; do
417876888252Smrg	  if test "$realname" != "$linkname"; then
417976888252Smrg	    $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)"
418076888252Smrg	    $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $?
418176888252Smrg	  fi
418276888252Smrg	done
418376888252Smrg
418476888252Smrg	# If -module or -export-dynamic was specified, set the dlname.
418576888252Smrg	if test "$module" = yes || test "$export_dynamic" = yes; then
418676888252Smrg	  # On all known operating systems, these are identical.
418776888252Smrg	  dlname="$soname"
418876888252Smrg	fi
418976888252Smrg      fi
419076888252Smrg      ;;
419176888252Smrg
419276888252Smrg    obj)
419376888252Smrg      if test -n "$deplibs"; then
419476888252Smrg	$echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2
419576888252Smrg      fi
419676888252Smrg
419776888252Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
419876888252Smrg	$echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
419976888252Smrg      fi
420076888252Smrg
420176888252Smrg      if test -n "$rpath"; then
420276888252Smrg	$echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2
420376888252Smrg      fi
420476888252Smrg
420576888252Smrg      if test -n "$xrpath"; then
420676888252Smrg	$echo "$modename: warning: \`-R' is ignored for objects" 1>&2
420776888252Smrg      fi
420876888252Smrg
420976888252Smrg      if test -n "$vinfo"; then
421076888252Smrg	$echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2
421176888252Smrg      fi
421276888252Smrg
421376888252Smrg      if test -n "$release"; then
421476888252Smrg	$echo "$modename: warning: \`-release' is ignored for objects" 1>&2
421576888252Smrg      fi
421676888252Smrg
421776888252Smrg      case $output in
421876888252Smrg      *.lo)
421976888252Smrg	if test -n "$objs$old_deplibs"; then
422076888252Smrg	  $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
422176888252Smrg	  exit $EXIT_FAILURE
422276888252Smrg	fi
422376888252Smrg	libobj="$output"
422476888252Smrg	obj=`$echo "X$output" | $Xsed -e "$lo2o"`
422576888252Smrg	;;
422676888252Smrg      *)
422776888252Smrg	libobj=
422876888252Smrg	obj="$output"
422976888252Smrg	;;
423076888252Smrg      esac
423176888252Smrg
423276888252Smrg      # Delete the old objects.
423376888252Smrg      $run $rm $obj $libobj
423476888252Smrg
423576888252Smrg      # Objects from convenience libraries.  This assumes
423676888252Smrg      # single-version convenience libraries.  Whenever we create
423776888252Smrg      # different ones for PIC/non-PIC, this we'll have to duplicate
423876888252Smrg      # the extraction.
423976888252Smrg      reload_conv_objs=
424076888252Smrg      gentop=
424176888252Smrg      # reload_cmds runs $LD directly, so let us get rid of
424276888252Smrg      # -Wl from whole_archive_flag_spec
424376888252Smrg      wl=
424476888252Smrg
424576888252Smrg      if test -n "$convenience"; then
424676888252Smrg	if test -n "$whole_archive_flag_spec"; then
424776888252Smrg	  eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
424876888252Smrg	else
424976888252Smrg	  gentop="$output_objdir/${obj}x"
425076888252Smrg	  generated="$generated $gentop"
425176888252Smrg
425276888252Smrg	  func_extract_archives $gentop $convenience
425376888252Smrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
425476888252Smrg	fi
425576888252Smrg      fi
425676888252Smrg
425776888252Smrg      # Create the old-style object.
425876888252Smrg      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
425976888252Smrg
426076888252Smrg      output="$obj"
426176888252Smrg      cmds=$reload_cmds
426276888252Smrg      save_ifs="$IFS"; IFS='~'
426376888252Smrg      for cmd in $cmds; do
426476888252Smrg	IFS="$save_ifs"
426576888252Smrg	eval cmd=\"$cmd\"
426676888252Smrg	$show "$cmd"
426776888252Smrg	$run eval "$cmd" || exit $?
426876888252Smrg      done
426976888252Smrg      IFS="$save_ifs"
427076888252Smrg
427176888252Smrg      # Exit if we aren't doing a library object file.
427276888252Smrg      if test -z "$libobj"; then
427376888252Smrg	if test -n "$gentop"; then
427476888252Smrg	  $show "${rm}r $gentop"
427576888252Smrg	  $run ${rm}r $gentop
427676888252Smrg	fi
427776888252Smrg
427876888252Smrg	exit $EXIT_SUCCESS
427976888252Smrg      fi
428076888252Smrg
428176888252Smrg      if test "$build_libtool_libs" != yes; then
428276888252Smrg	if test -n "$gentop"; then
428376888252Smrg	  $show "${rm}r $gentop"
428476888252Smrg	  $run ${rm}r $gentop
428576888252Smrg	fi
428676888252Smrg
428776888252Smrg	# Create an invalid libtool object if no PIC, so that we don't
428876888252Smrg	# accidentally link it into a program.
428976888252Smrg	# $show "echo timestamp > $libobj"
429076888252Smrg	# $run eval "echo timestamp > $libobj" || exit $?
429176888252Smrg	exit $EXIT_SUCCESS
429276888252Smrg      fi
429376888252Smrg
429476888252Smrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
429576888252Smrg	# Only do commands if we really have different PIC objects.
429676888252Smrg	reload_objs="$libobjs $reload_conv_objs"
429776888252Smrg	output="$libobj"
429876888252Smrg	cmds=$reload_cmds
429976888252Smrg	save_ifs="$IFS"; IFS='~'
430076888252Smrg	for cmd in $cmds; do
430176888252Smrg	  IFS="$save_ifs"
430276888252Smrg	  eval cmd=\"$cmd\"
430376888252Smrg	  $show "$cmd"
430476888252Smrg	  $run eval "$cmd" || exit $?
430576888252Smrg	done
430676888252Smrg	IFS="$save_ifs"
430776888252Smrg      fi
430876888252Smrg
430976888252Smrg      if test -n "$gentop"; then
431076888252Smrg	$show "${rm}r $gentop"
431176888252Smrg	$run ${rm}r $gentop
431276888252Smrg      fi
431376888252Smrg
431476888252Smrg      exit $EXIT_SUCCESS
431576888252Smrg      ;;
431676888252Smrg
431776888252Smrg    prog)
431876888252Smrg      case $host in
431976888252Smrg	*cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;
432076888252Smrg      esac
432176888252Smrg      if test -n "$vinfo"; then
432276888252Smrg	$echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
432376888252Smrg      fi
432476888252Smrg
432576888252Smrg      if test -n "$release"; then
432676888252Smrg	$echo "$modename: warning: \`-release' is ignored for programs" 1>&2
432776888252Smrg      fi
432876888252Smrg
432976888252Smrg      if test "$preload" = yes; then
433076888252Smrg	if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown &&
433176888252Smrg	   test "$dlopen_self_static" = unknown; then
433276888252Smrg	  $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support."
433376888252Smrg	fi
433476888252Smrg      fi
433576888252Smrg
433676888252Smrg      case $host in
433776888252Smrg      *-*-rhapsody* | *-*-darwin1.[012])
433876888252Smrg	# On Rhapsody replace the C library is the System framework
433976888252Smrg	compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
434076888252Smrg	finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
434176888252Smrg	;;
434276888252Smrg      esac
434376888252Smrg
434476888252Smrg      case $host in
434576888252Smrg      *darwin*)
434676888252Smrg        # Don't allow lazy linking, it breaks C++ global constructors
434776888252Smrg        if test "$tagname" = CXX ; then
434876888252Smrg        compile_command="$compile_command ${wl}-bind_at_load"
434976888252Smrg        finalize_command="$finalize_command ${wl}-bind_at_load"
435076888252Smrg        fi
435176888252Smrg        ;;
435276888252Smrg      esac
435376888252Smrg
435476888252Smrg
435576888252Smrg      # move library search paths that coincide with paths to not yet
435676888252Smrg      # installed libraries to the beginning of the library search list
435776888252Smrg      new_libs=
435876888252Smrg      for path in $notinst_path; do
435976888252Smrg	case " $new_libs " in
436076888252Smrg	*" -L$path/$objdir "*) ;;
436176888252Smrg	*)
436276888252Smrg	  case " $compile_deplibs " in
436376888252Smrg	  *" -L$path/$objdir "*)
436476888252Smrg	    new_libs="$new_libs -L$path/$objdir" ;;
436576888252Smrg	  esac
436676888252Smrg	  ;;
436776888252Smrg	esac
436876888252Smrg      done
436976888252Smrg      for deplib in $compile_deplibs; do
437076888252Smrg	case $deplib in
437176888252Smrg	-L*)
437276888252Smrg	  case " $new_libs " in
437376888252Smrg	  *" $deplib "*) ;;
437476888252Smrg	  *) new_libs="$new_libs $deplib" ;;
437576888252Smrg	  esac
437676888252Smrg	  ;;
437776888252Smrg	*) new_libs="$new_libs $deplib" ;;
437876888252Smrg	esac
437976888252Smrg      done
438076888252Smrg      compile_deplibs="$new_libs"
438176888252Smrg
438276888252Smrg
438376888252Smrg      compile_command="$compile_command $compile_deplibs"
438476888252Smrg      finalize_command="$finalize_command $finalize_deplibs"
438576888252Smrg
438676888252Smrg      if test -n "$rpath$xrpath"; then
438776888252Smrg	# If the user specified any rpath flags, then add them.
438876888252Smrg	for libdir in $rpath $xrpath; do
438976888252Smrg	  # This is the magic to use -rpath.
439076888252Smrg	  case "$finalize_rpath " in
439176888252Smrg	  *" $libdir "*) ;;
439276888252Smrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
439376888252Smrg	  esac
439476888252Smrg	done
439576888252Smrg      fi
439676888252Smrg
439776888252Smrg      # Now hardcode the library paths
439876888252Smrg      rpath=
439976888252Smrg      hardcode_libdirs=
440076888252Smrg      for libdir in $compile_rpath $finalize_rpath; do
440176888252Smrg	if test -n "$hardcode_libdir_flag_spec"; then
440276888252Smrg	  if test -n "$hardcode_libdir_separator"; then
440376888252Smrg	    if test -z "$hardcode_libdirs"; then
440476888252Smrg	      hardcode_libdirs="$libdir"
440576888252Smrg	    else
440676888252Smrg	      # Just accumulate the unique libdirs.
440776888252Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
440876888252Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
440976888252Smrg		;;
441076888252Smrg	      *)
441176888252Smrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
441276888252Smrg		;;
441376888252Smrg	      esac
441476888252Smrg	    fi
441576888252Smrg	  else
441676888252Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
441776888252Smrg	    rpath="$rpath $flag"
441876888252Smrg	  fi
441976888252Smrg	elif test -n "$runpath_var"; then
442076888252Smrg	  case "$perm_rpath " in
442176888252Smrg	  *" $libdir "*) ;;
442276888252Smrg	  *) perm_rpath="$perm_rpath $libdir" ;;
442376888252Smrg	  esac
442476888252Smrg	fi
442576888252Smrg	case $host in
442676888252Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
442776888252Smrg	  testbindir=`$echo "X$libdir" | $Xsed -e 's*/lib$*/bin*'`
442876888252Smrg	  case :$dllsearchpath: in
442976888252Smrg	  *":$libdir:"*) ;;
443076888252Smrg	  *) dllsearchpath="$dllsearchpath:$libdir";;
443176888252Smrg	  esac
443276888252Smrg	  case :$dllsearchpath: in
443376888252Smrg	  *":$testbindir:"*) ;;
443476888252Smrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
443576888252Smrg	  esac
443676888252Smrg	  ;;
443776888252Smrg	esac
443876888252Smrg      done
443976888252Smrg      # Substitute the hardcoded libdirs into the rpath.
444076888252Smrg      if test -n "$hardcode_libdir_separator" &&
444176888252Smrg	 test -n "$hardcode_libdirs"; then
444276888252Smrg	libdir="$hardcode_libdirs"
444376888252Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
444476888252Smrg      fi
444576888252Smrg      compile_rpath="$rpath"
444676888252Smrg
444776888252Smrg      rpath=
444876888252Smrg      hardcode_libdirs=
444976888252Smrg      for libdir in $finalize_rpath; do
445076888252Smrg	if test -n "$hardcode_libdir_flag_spec"; then
445176888252Smrg	  if test -n "$hardcode_libdir_separator"; then
445276888252Smrg	    if test -z "$hardcode_libdirs"; then
445376888252Smrg	      hardcode_libdirs="$libdir"
445476888252Smrg	    else
445576888252Smrg	      # Just accumulate the unique libdirs.
445676888252Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
445776888252Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
445876888252Smrg		;;
445976888252Smrg	      *)
446076888252Smrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
446176888252Smrg		;;
446276888252Smrg	      esac
446376888252Smrg	    fi
446476888252Smrg	  else
446576888252Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
446676888252Smrg	    rpath="$rpath $flag"
446776888252Smrg	  fi
446876888252Smrg	elif test -n "$runpath_var"; then
446976888252Smrg	  case "$finalize_perm_rpath " in
447076888252Smrg	  *" $libdir "*) ;;
447176888252Smrg	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
447276888252Smrg	  esac
447376888252Smrg	fi
447476888252Smrg      done
447576888252Smrg      # Substitute the hardcoded libdirs into the rpath.
447676888252Smrg      if test -n "$hardcode_libdir_separator" &&
447776888252Smrg	 test -n "$hardcode_libdirs"; then
447876888252Smrg	libdir="$hardcode_libdirs"
447976888252Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
448076888252Smrg      fi
448176888252Smrg      finalize_rpath="$rpath"
448276888252Smrg
448376888252Smrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
448476888252Smrg	# Transform all the library objects into standard objects.
448576888252Smrg	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
448676888252Smrg	finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
448776888252Smrg      fi
448876888252Smrg
448976888252Smrg      dlsyms=
449076888252Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
449176888252Smrg	if test -n "$NM" && test -n "$global_symbol_pipe"; then
449276888252Smrg	  dlsyms="${outputname}S.c"
449376888252Smrg	else
449476888252Smrg	  $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2
449576888252Smrg	fi
449676888252Smrg      fi
449776888252Smrg
449876888252Smrg      if test -n "$dlsyms"; then
449976888252Smrg	case $dlsyms in
450076888252Smrg	"") ;;
450176888252Smrg	*.c)
450276888252Smrg	  # Discover the nlist of each of the dlfiles.
450376888252Smrg	  nlist="$output_objdir/${outputname}.nm"
450476888252Smrg
450576888252Smrg	  $show "$rm $nlist ${nlist}S ${nlist}T"
450676888252Smrg	  $run $rm "$nlist" "${nlist}S" "${nlist}T"
450776888252Smrg
450876888252Smrg	  # Parse the name list into a source file.
450976888252Smrg	  $show "creating $output_objdir/$dlsyms"
451076888252Smrg
451176888252Smrg	  test -z "$run" && $echo > "$output_objdir/$dlsyms" "\
451276888252Smrg/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */
451376888252Smrg/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */
451476888252Smrg
451576888252Smrg#ifdef __cplusplus
451676888252Smrgextern \"C\" {
451776888252Smrg#endif
451876888252Smrg
451976888252Smrg/* Prevent the only kind of declaration conflicts we can make. */
452076888252Smrg#define lt_preloaded_symbols some_other_symbol
452176888252Smrg
452276888252Smrg/* External symbol declarations for the compiler. */\
452376888252Smrg"
452476888252Smrg
452576888252Smrg	  if test "$dlself" = yes; then
452676888252Smrg	    $show "generating symbol list for \`$output'"
452776888252Smrg
452876888252Smrg	    test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist"
452976888252Smrg
453076888252Smrg	    # Add our own program objects to the symbol list.
453176888252Smrg	    progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
453276888252Smrg	    for arg in $progfiles; do
453376888252Smrg	      $show "extracting global C symbols from \`$arg'"
453476888252Smrg	      $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
453576888252Smrg	    done
453676888252Smrg
453776888252Smrg	    if test -n "$exclude_expsyms"; then
453876888252Smrg	      $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
453976888252Smrg	      $run eval '$mv "$nlist"T "$nlist"'
454076888252Smrg	    fi
454176888252Smrg
454276888252Smrg	    if test -n "$export_symbols_regex"; then
454376888252Smrg	      $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
454476888252Smrg	      $run eval '$mv "$nlist"T "$nlist"'
454576888252Smrg	    fi
454676888252Smrg
454776888252Smrg	    # Prepare the list of exported symbols
454876888252Smrg	    if test -z "$export_symbols"; then
454976888252Smrg	      export_symbols="$output_objdir/$outputname.exp"
455076888252Smrg	      $run $rm $export_symbols
455176888252Smrg	      $run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
455276888252Smrg              case $host in
455376888252Smrg              *cygwin* | *mingw* )
455476888252Smrg	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
455576888252Smrg		$run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
455676888252Smrg                ;;
455776888252Smrg              esac
455876888252Smrg	    else
455976888252Smrg	      $run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
456076888252Smrg	      $run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
456176888252Smrg	      $run eval 'mv "$nlist"T "$nlist"'
456276888252Smrg              case $host in
456376888252Smrg              *cygwin* | *mingw* )
456476888252Smrg	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
456576888252Smrg		$run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
456676888252Smrg                ;;
456776888252Smrg              esac
456876888252Smrg	    fi
456976888252Smrg	  fi
457076888252Smrg
457176888252Smrg	  for arg in $dlprefiles; do
457276888252Smrg	    $show "extracting global C symbols from \`$arg'"
457376888252Smrg	    name=`$echo "$arg" | ${SED} -e 's%^.*/%%'`
457476888252Smrg	    $run eval '$echo ": $name " >> "$nlist"'
457576888252Smrg	    $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
457676888252Smrg	  done
457776888252Smrg
457876888252Smrg	  if test -z "$run"; then
457976888252Smrg	    # Make sure we have at least an empty file.
458076888252Smrg	    test -f "$nlist" || : > "$nlist"
458176888252Smrg
458276888252Smrg	    if test -n "$exclude_expsyms"; then
458376888252Smrg	      $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
458476888252Smrg	      $mv "$nlist"T "$nlist"
458576888252Smrg	    fi
458676888252Smrg
458776888252Smrg	    # Try sorting and uniquifying the output.
458876888252Smrg	    if grep -v "^: " < "$nlist" |
458976888252Smrg		if sort -k 3 </dev/null >/dev/null 2>&1; then
459076888252Smrg		  sort -k 3
459176888252Smrg		else
459276888252Smrg		  sort +2
459376888252Smrg		fi |
459476888252Smrg		uniq > "$nlist"S; then
459576888252Smrg	      :
459676888252Smrg	    else
459776888252Smrg	      grep -v "^: " < "$nlist" > "$nlist"S
459876888252Smrg	    fi
459976888252Smrg
460076888252Smrg	    if test -f "$nlist"S; then
460176888252Smrg	      eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"'
460276888252Smrg	    else
460376888252Smrg	      $echo '/* NONE */' >> "$output_objdir/$dlsyms"
460476888252Smrg	    fi
460576888252Smrg
460676888252Smrg	    $echo >> "$output_objdir/$dlsyms" "\
460776888252Smrg
460876888252Smrg#undef lt_preloaded_symbols
460976888252Smrg
461076888252Smrg#if defined (__STDC__) && __STDC__
461176888252Smrg# define lt_ptr void *
461276888252Smrg#else
461376888252Smrg# define lt_ptr char *
461476888252Smrg# define const
461576888252Smrg#endif
461676888252Smrg
461776888252Smrg/* The mapping between symbol names and symbols. */
461876888252Smrg"
461976888252Smrg
462076888252Smrg	    case $host in
462176888252Smrg	    *cygwin* | *mingw* )
462276888252Smrg	  $echo >> "$output_objdir/$dlsyms" "\
462376888252Smrg/* DATA imports from DLLs on WIN32 can't be const, because
462476888252Smrg   runtime relocations are performed -- see ld's documentation
462576888252Smrg   on pseudo-relocs */
462676888252Smrgstruct {
462776888252Smrg"
462876888252Smrg	      ;;
462976888252Smrg	    * )
463076888252Smrg	  $echo >> "$output_objdir/$dlsyms" "\
463176888252Smrgconst struct {
463276888252Smrg"
463376888252Smrg	      ;;
463476888252Smrg	    esac
463576888252Smrg
463676888252Smrg
463776888252Smrg	  $echo >> "$output_objdir/$dlsyms" "\
463876888252Smrg  const char *name;
463976888252Smrg  lt_ptr address;
464076888252Smrg}
464176888252Smrglt_preloaded_symbols[] =
464276888252Smrg{\
464376888252Smrg"
464476888252Smrg
464576888252Smrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms"
464676888252Smrg
464776888252Smrg	    $echo >> "$output_objdir/$dlsyms" "\
464876888252Smrg  {0, (lt_ptr) 0}
464976888252Smrg};
465076888252Smrg
465176888252Smrg/* This works around a problem in FreeBSD linker */
465276888252Smrg#ifdef FREEBSD_WORKAROUND
465376888252Smrgstatic const void *lt_preloaded_setup() {
465476888252Smrg  return lt_preloaded_symbols;
465576888252Smrg}
465676888252Smrg#endif
465776888252Smrg
465876888252Smrg#ifdef __cplusplus
465976888252Smrg}
466076888252Smrg#endif\
466176888252Smrg"
466276888252Smrg	  fi
466376888252Smrg
466476888252Smrg	  pic_flag_for_symtable=
466576888252Smrg	  case $host in
466676888252Smrg	  # compiling the symbol table file with pic_flag works around
466776888252Smrg	  # a FreeBSD bug that causes programs to crash when -lm is
466876888252Smrg	  # linked before any other PIC object.  But we must not use
466976888252Smrg	  # pic_flag when linking with -static.  The problem exists in
467076888252Smrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
467176888252Smrg	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
467276888252Smrg	    case "$compile_command " in
467376888252Smrg	    *" -static "*) ;;
467476888252Smrg	    *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";;
467576888252Smrg	    esac;;
467676888252Smrg	  *-*-hpux*)
467776888252Smrg	    case "$compile_command " in
467876888252Smrg	    *" -static "*) ;;
467976888252Smrg	    *) pic_flag_for_symtable=" $pic_flag";;
468076888252Smrg	    esac
468176888252Smrg	  esac
468276888252Smrg
468376888252Smrg	  # Now compile the dynamic symbol file.
468476888252Smrg	  $show "(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
468576888252Smrg	  $run eval '(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
468676888252Smrg
468776888252Smrg	  # Clean up the generated files.
468876888252Smrg	  $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
468976888252Smrg	  $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
469076888252Smrg
469176888252Smrg	  # Transform the symbol file into the correct name.
469276888252Smrg          case $host in
469376888252Smrg          *cygwin* | *mingw* )
469476888252Smrg            if test -f "$output_objdir/${outputname}.def" ; then
469576888252Smrg              compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
469676888252Smrg              finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
469776888252Smrg            else
469876888252Smrg              compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
469976888252Smrg              finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
470076888252Smrg             fi
470176888252Smrg            ;;
470276888252Smrg          * )
470376888252Smrg            compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
470476888252Smrg            finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
470576888252Smrg            ;;
470676888252Smrg          esac
470776888252Smrg	  ;;
470876888252Smrg	*)
470976888252Smrg	  $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
471076888252Smrg	  exit $EXIT_FAILURE
471176888252Smrg	  ;;
471276888252Smrg	esac
471376888252Smrg      else
471476888252Smrg	# We keep going just in case the user didn't refer to
471576888252Smrg	# lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
471676888252Smrg	# really was required.
471776888252Smrg
471876888252Smrg	# Nullify the symbol file.
471976888252Smrg	compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
472076888252Smrg	finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
472176888252Smrg      fi
472276888252Smrg
472376888252Smrg      if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
472476888252Smrg	# Replace the output file specification.
472576888252Smrg	compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
472676888252Smrg	link_command="$compile_command$compile_rpath"
472776888252Smrg
472876888252Smrg	# We have no uninstalled library dependencies, so finalize right now.
472976888252Smrg	$show "$link_command"
473076888252Smrg	$run eval "$link_command"
473176888252Smrg	exit_status=$?
473276888252Smrg
473376888252Smrg	# Delete the generated files.
473476888252Smrg	if test -n "$dlsyms"; then
473576888252Smrg	  $show "$rm $output_objdir/${outputname}S.${objext}"
473676888252Smrg	  $run $rm "$output_objdir/${outputname}S.${objext}"
473776888252Smrg	fi
473876888252Smrg
473976888252Smrg	exit $exit_status
474076888252Smrg      fi
474176888252Smrg
474276888252Smrg      if test -n "$shlibpath_var"; then
474376888252Smrg	# We should set the shlibpath_var
474476888252Smrg	rpath=
474576888252Smrg	for dir in $temp_rpath; do
474676888252Smrg	  case $dir in
474776888252Smrg	  [\\/]* | [A-Za-z]:[\\/]*)
474876888252Smrg	    # Absolute path.
474976888252Smrg	    rpath="$rpath$dir:"
475076888252Smrg	    ;;
475176888252Smrg	  *)
475276888252Smrg	    # Relative path: add a thisdir entry.
475376888252Smrg	    rpath="$rpath\$thisdir/$dir:"
475476888252Smrg	    ;;
475576888252Smrg	  esac
475676888252Smrg	done
475776888252Smrg	temp_rpath="$rpath"
475876888252Smrg      fi
475976888252Smrg
476076888252Smrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
476176888252Smrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
476276888252Smrg      fi
476376888252Smrg      if test -n "$finalize_shlibpath"; then
476476888252Smrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
476576888252Smrg      fi
476676888252Smrg
476776888252Smrg      compile_var=
476876888252Smrg      finalize_var=
476976888252Smrg      if test -n "$runpath_var"; then
477076888252Smrg	if test -n "$perm_rpath"; then
477176888252Smrg	  # We should set the runpath_var.
477276888252Smrg	  rpath=
477376888252Smrg	  for dir in $perm_rpath; do
477476888252Smrg	    rpath="$rpath$dir:"
477576888252Smrg	  done
477676888252Smrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
477776888252Smrg	fi
477876888252Smrg	if test -n "$finalize_perm_rpath"; then
477976888252Smrg	  # We should set the runpath_var.
478076888252Smrg	  rpath=
478176888252Smrg	  for dir in $finalize_perm_rpath; do
478276888252Smrg	    rpath="$rpath$dir:"
478376888252Smrg	  done
478476888252Smrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
478576888252Smrg	fi
478676888252Smrg      fi
478776888252Smrg
478876888252Smrg      if test "$no_install" = yes; then
478976888252Smrg	# We don't need to create a wrapper script.
479076888252Smrg	link_command="$compile_var$compile_command$compile_rpath"
479176888252Smrg	# Replace the output file specification.
479276888252Smrg	link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
479376888252Smrg	# Delete the old output file.
479476888252Smrg	$run $rm $output
479576888252Smrg	# Link the executable and exit
479676888252Smrg	$show "$link_command"
479776888252Smrg	$run eval "$link_command" || exit $?
479876888252Smrg	exit $EXIT_SUCCESS
479976888252Smrg      fi
480076888252Smrg
480176888252Smrg      if test "$hardcode_action" = relink; then
480276888252Smrg	# Fast installation is not supported
480376888252Smrg	link_command="$compile_var$compile_command$compile_rpath"
480476888252Smrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
480576888252Smrg
480676888252Smrg	$echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2
480776888252Smrg	$echo "$modename: \`$output' will be relinked during installation" 1>&2
480876888252Smrg      else
480976888252Smrg	if test "$fast_install" != no; then
481076888252Smrg	  link_command="$finalize_var$compile_command$finalize_rpath"
481176888252Smrg	  if test "$fast_install" = yes; then
481276888252Smrg	    relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
481376888252Smrg	  else
481476888252Smrg	    # fast_install is set to needless
481576888252Smrg	    relink_command=
481676888252Smrg	  fi
481776888252Smrg	else
481876888252Smrg	  link_command="$compile_var$compile_command$compile_rpath"
481976888252Smrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
482076888252Smrg	fi
482176888252Smrg      fi
482276888252Smrg
482376888252Smrg      # Replace the output file specification.
482476888252Smrg      link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
482576888252Smrg
482676888252Smrg      # Delete the old output files.
482776888252Smrg      $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname
482876888252Smrg
482976888252Smrg      $show "$link_command"
483076888252Smrg      $run eval "$link_command" || exit $?
483176888252Smrg
483276888252Smrg      # Now create the wrapper script.
483376888252Smrg      $show "creating $output"
483476888252Smrg
483576888252Smrg      # Quote the relink command for shipping.
483676888252Smrg      if test -n "$relink_command"; then
483776888252Smrg	# Preserve any variables that may affect compiler behavior
483876888252Smrg	for var in $variables_saved_for_relink; do
483976888252Smrg	  if eval test -z \"\${$var+set}\"; then
484076888252Smrg	    relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
484176888252Smrg	  elif eval var_value=\$$var; test -z "$var_value"; then
484276888252Smrg	    relink_command="$var=; export $var; $relink_command"
484376888252Smrg	  else
484476888252Smrg	    var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
484576888252Smrg	    relink_command="$var=\"$var_value\"; export $var; $relink_command"
484676888252Smrg	  fi
484776888252Smrg	done
484876888252Smrg	relink_command="(cd `pwd`; $relink_command)"
484976888252Smrg	relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
485076888252Smrg      fi
485176888252Smrg
485276888252Smrg      # Quote $echo for shipping.
485376888252Smrg      if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then
485476888252Smrg	case $progpath in
485576888252Smrg	[\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
485676888252Smrg	*) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
485776888252Smrg	esac
485876888252Smrg	qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"`
485976888252Smrg      else
486076888252Smrg	qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"`
486176888252Smrg      fi
486276888252Smrg
486376888252Smrg      # Only actually do things if our run command is non-null.
486476888252Smrg      if test -z "$run"; then
486576888252Smrg	# win32 will think the script is a binary if it has
486676888252Smrg	# a .exe suffix, so we strip it off here.
486776888252Smrg	case $output in
486876888252Smrg	  *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;;
486976888252Smrg	esac
487076888252Smrg	# test for cygwin because mv fails w/o .exe extensions
487176888252Smrg	case $host in
487276888252Smrg	  *cygwin*)
487376888252Smrg	    exeext=.exe
487476888252Smrg	    outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;;
487576888252Smrg	  *) exeext= ;;
487676888252Smrg	esac
487776888252Smrg	case $host in
487876888252Smrg	  *cygwin* | *mingw* )
487976888252Smrg            output_name=`basename $output`
488076888252Smrg            output_path=`dirname $output`
488176888252Smrg            cwrappersource="$output_path/$objdir/lt-$output_name.c"
488276888252Smrg            cwrapper="$output_path/$output_name.exe"
488376888252Smrg            $rm $cwrappersource $cwrapper
488476888252Smrg            trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
488576888252Smrg
488676888252Smrg	    cat > $cwrappersource <<EOF
488776888252Smrg
488876888252Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
488976888252Smrg   Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
489076888252Smrg
489176888252Smrg   The $output program cannot be directly executed until all the libtool
489276888252Smrg   libraries that it depends on are installed.
489376888252Smrg
489476888252Smrg   This wrapper executable should never be moved out of the build directory.
489576888252Smrg   If it is, it will not operate correctly.
489676888252Smrg
489776888252Smrg   Currently, it simply execs the wrapper *script* "/bin/sh $output",
489876888252Smrg   but could eventually absorb all of the scripts functionality and
489976888252Smrg   exec $objdir/$outputname directly.
490076888252Smrg*/
490176888252SmrgEOF
490276888252Smrg	    cat >> $cwrappersource<<"EOF"
490376888252Smrg#include <stdio.h>
490476888252Smrg#include <stdlib.h>
490576888252Smrg#include <unistd.h>
490676888252Smrg#include <malloc.h>
490776888252Smrg#include <stdarg.h>
490876888252Smrg#include <assert.h>
490976888252Smrg#include <string.h>
491076888252Smrg#include <ctype.h>
491176888252Smrg#include <sys/stat.h>
491276888252Smrg
491376888252Smrg#if defined(PATH_MAX)
491476888252Smrg# define LT_PATHMAX PATH_MAX
491576888252Smrg#elif defined(MAXPATHLEN)
491676888252Smrg# define LT_PATHMAX MAXPATHLEN
491776888252Smrg#else
491876888252Smrg# define LT_PATHMAX 1024
491976888252Smrg#endif
492076888252Smrg
492176888252Smrg#ifndef DIR_SEPARATOR
492276888252Smrg# define DIR_SEPARATOR '/'
492376888252Smrg# define PATH_SEPARATOR ':'
492476888252Smrg#endif
492576888252Smrg
492676888252Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
492776888252Smrg  defined (__OS2__)
492876888252Smrg# define HAVE_DOS_BASED_FILE_SYSTEM
492976888252Smrg# ifndef DIR_SEPARATOR_2
493076888252Smrg#  define DIR_SEPARATOR_2 '\\'
493176888252Smrg# endif
493276888252Smrg# ifndef PATH_SEPARATOR_2
493376888252Smrg#  define PATH_SEPARATOR_2 ';'
493476888252Smrg# endif
493576888252Smrg#endif
493676888252Smrg
493776888252Smrg#ifndef DIR_SEPARATOR_2
493876888252Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
493976888252Smrg#else /* DIR_SEPARATOR_2 */
494076888252Smrg# define IS_DIR_SEPARATOR(ch) \
494176888252Smrg        (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
494276888252Smrg#endif /* DIR_SEPARATOR_2 */
494376888252Smrg
494476888252Smrg#ifndef PATH_SEPARATOR_2
494576888252Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
494676888252Smrg#else /* PATH_SEPARATOR_2 */
494776888252Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
494876888252Smrg#endif /* PATH_SEPARATOR_2 */
494976888252Smrg
495076888252Smrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
495176888252Smrg#define XFREE(stale) do { \
495276888252Smrg  if (stale) { free ((void *) stale); stale = 0; } \
495376888252Smrg} while (0)
495476888252Smrg
495576888252Smrg/* -DDEBUG is fairly common in CFLAGS.  */
495676888252Smrg#undef DEBUG
495776888252Smrg#if defined DEBUGWRAPPER
495876888252Smrg# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
495976888252Smrg#else
496076888252Smrg# define DEBUG(format, ...)
496176888252Smrg#endif
496276888252Smrg
496376888252Smrgconst char *program_name = NULL;
496476888252Smrg
496576888252Smrgvoid * xmalloc (size_t num);
496676888252Smrgchar * xstrdup (const char *string);
496776888252Smrgconst char * base_name (const char *name);
496876888252Smrgchar * find_executable(const char *wrapper);
496976888252Smrgint    check_executable(const char *path);
497076888252Smrgchar * strendzap(char *str, const char *pat);
497176888252Smrgvoid lt_fatal (const char *message, ...);
497276888252Smrg
497376888252Smrgint
497476888252Smrgmain (int argc, char *argv[])
497576888252Smrg{
497676888252Smrg  char **newargz;
497776888252Smrg  int i;
497876888252Smrg
497976888252Smrg  program_name = (char *) xstrdup (base_name (argv[0]));
498076888252Smrg  DEBUG("(main) argv[0]      : %s\n",argv[0]);
498176888252Smrg  DEBUG("(main) program_name : %s\n",program_name);
498276888252Smrg  newargz = XMALLOC(char *, argc+2);
498376888252SmrgEOF
498476888252Smrg
498576888252Smrg            cat >> $cwrappersource <<EOF
498676888252Smrg  newargz[0] = (char *) xstrdup("$SHELL");
498776888252SmrgEOF
498876888252Smrg
498976888252Smrg            cat >> $cwrappersource <<"EOF"
499076888252Smrg  newargz[1] = find_executable(argv[0]);
499176888252Smrg  if (newargz[1] == NULL)
499276888252Smrg    lt_fatal("Couldn't find %s", argv[0]);
499376888252Smrg  DEBUG("(main) found exe at : %s\n",newargz[1]);
499476888252Smrg  /* we know the script has the same name, without the .exe */
499576888252Smrg  /* so make sure newargz[1] doesn't end in .exe */
499676888252Smrg  strendzap(newargz[1],".exe");
499776888252Smrg  for (i = 1; i < argc; i++)
499876888252Smrg    newargz[i+1] = xstrdup(argv[i]);
499976888252Smrg  newargz[argc+1] = NULL;
500076888252Smrg
500176888252Smrg  for (i=0; i<argc+1; i++)
500276888252Smrg  {
500376888252Smrg    DEBUG("(main) newargz[%d]   : %s\n",i,newargz[i]);
500476888252Smrg    ;
500576888252Smrg  }
500676888252Smrg
500776888252SmrgEOF
500876888252Smrg
500976888252Smrg            case $host_os in
501076888252Smrg              mingw*)
501176888252Smrg                cat >> $cwrappersource <<EOF
501276888252Smrg  execv("$SHELL",(char const **)newargz);
501376888252SmrgEOF
501476888252Smrg              ;;
501576888252Smrg              *)
501676888252Smrg                cat >> $cwrappersource <<EOF
501776888252Smrg  execv("$SHELL",newargz);
501876888252SmrgEOF
501976888252Smrg              ;;
502076888252Smrg            esac
502176888252Smrg
502276888252Smrg            cat >> $cwrappersource <<"EOF"
502376888252Smrg  return 127;
502476888252Smrg}
502576888252Smrg
502676888252Smrgvoid *
502776888252Smrgxmalloc (size_t num)
502876888252Smrg{
502976888252Smrg  void * p = (void *) malloc (num);
503076888252Smrg  if (!p)
503176888252Smrg    lt_fatal ("Memory exhausted");
503276888252Smrg
503376888252Smrg  return p;
503476888252Smrg}
503576888252Smrg
503676888252Smrgchar *
503776888252Smrgxstrdup (const char *string)
503876888252Smrg{
503976888252Smrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL
504076888252Smrg;
504176888252Smrg}
504276888252Smrg
504376888252Smrgconst char *
504476888252Smrgbase_name (const char *name)
504576888252Smrg{
504676888252Smrg  const char *base;
504776888252Smrg
504876888252Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
504976888252Smrg  /* Skip over the disk name in MSDOS pathnames. */
505076888252Smrg  if (isalpha ((unsigned char)name[0]) && name[1] == ':')
505176888252Smrg    name += 2;
505276888252Smrg#endif
505376888252Smrg
505476888252Smrg  for (base = name; *name; name++)
505576888252Smrg    if (IS_DIR_SEPARATOR (*name))
505676888252Smrg      base = name + 1;
505776888252Smrg  return base;
505876888252Smrg}
505976888252Smrg
506076888252Smrgint
506176888252Smrgcheck_executable(const char * path)
506276888252Smrg{
506376888252Smrg  struct stat st;
506476888252Smrg
506576888252Smrg  DEBUG("(check_executable)  : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!");
506676888252Smrg  if ((!path) || (!*path))
506776888252Smrg    return 0;
506876888252Smrg
506976888252Smrg  if ((stat (path, &st) >= 0) &&
507076888252Smrg      (
507176888252Smrg        /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */
507276888252Smrg#if defined (S_IXOTH)
507376888252Smrg       ((st.st_mode & S_IXOTH) == S_IXOTH) ||
507476888252Smrg#endif
507576888252Smrg#if defined (S_IXGRP)
507676888252Smrg       ((st.st_mode & S_IXGRP) == S_IXGRP) ||
507776888252Smrg#endif
507876888252Smrg       ((st.st_mode & S_IXUSR) == S_IXUSR))
507976888252Smrg      )
508076888252Smrg    return 1;
508176888252Smrg  else
508276888252Smrg    return 0;
508376888252Smrg}
508476888252Smrg
508576888252Smrg/* Searches for the full path of the wrapper.  Returns
508676888252Smrg   newly allocated full path name if found, NULL otherwise */
508776888252Smrgchar *
508876888252Smrgfind_executable (const char* wrapper)
508976888252Smrg{
509076888252Smrg  int has_slash = 0;
509176888252Smrg  const char* p;
509276888252Smrg  const char* p_next;
509376888252Smrg  /* static buffer for getcwd */
509476888252Smrg  char tmp[LT_PATHMAX + 1];
509576888252Smrg  int tmp_len;
509676888252Smrg  char* concat_name;
509776888252Smrg
509876888252Smrg  DEBUG("(find_executable)  : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!");
509976888252Smrg
510076888252Smrg  if ((wrapper == NULL) || (*wrapper == '\0'))
510176888252Smrg    return NULL;
510276888252Smrg
510376888252Smrg  /* Absolute path? */
510476888252Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
510576888252Smrg  if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':')
510676888252Smrg  {
510776888252Smrg    concat_name = xstrdup (wrapper);
510876888252Smrg    if (check_executable(concat_name))
510976888252Smrg      return concat_name;
511076888252Smrg    XFREE(concat_name);
511176888252Smrg  }
511276888252Smrg  else
511376888252Smrg  {
511476888252Smrg#endif
511576888252Smrg    if (IS_DIR_SEPARATOR (wrapper[0]))
511676888252Smrg    {
511776888252Smrg      concat_name = xstrdup (wrapper);
511876888252Smrg      if (check_executable(concat_name))
511976888252Smrg        return concat_name;
512076888252Smrg      XFREE(concat_name);
512176888252Smrg    }
512276888252Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
512376888252Smrg  }
512476888252Smrg#endif
512576888252Smrg
512676888252Smrg  for (p = wrapper; *p; p++)
512776888252Smrg    if (*p == '/')
512876888252Smrg    {
512976888252Smrg      has_slash = 1;
513076888252Smrg      break;
513176888252Smrg    }
513276888252Smrg  if (!has_slash)
513376888252Smrg  {
513476888252Smrg    /* no slashes; search PATH */
513576888252Smrg    const char* path = getenv ("PATH");
513676888252Smrg    if (path != NULL)
513776888252Smrg    {
513876888252Smrg      for (p = path; *p; p = p_next)
513976888252Smrg      {
514076888252Smrg        const char* q;
514176888252Smrg        size_t p_len;
514276888252Smrg        for (q = p; *q; q++)
514376888252Smrg          if (IS_PATH_SEPARATOR(*q))
514476888252Smrg            break;
514576888252Smrg        p_len = q - p;
514676888252Smrg        p_next = (*q == '\0' ? q : q + 1);
514776888252Smrg        if (p_len == 0)
514876888252Smrg        {
514976888252Smrg          /* empty path: current directory */
515076888252Smrg          if (getcwd (tmp, LT_PATHMAX) == NULL)
515176888252Smrg            lt_fatal ("getcwd failed");
515276888252Smrg          tmp_len = strlen(tmp);
515376888252Smrg          concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
515476888252Smrg          memcpy (concat_name, tmp, tmp_len);
515576888252Smrg          concat_name[tmp_len] = '/';
515676888252Smrg          strcpy (concat_name + tmp_len + 1, wrapper);
515776888252Smrg        }
515876888252Smrg        else
515976888252Smrg        {
516076888252Smrg          concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1);
516176888252Smrg          memcpy (concat_name, p, p_len);
516276888252Smrg          concat_name[p_len] = '/';
516376888252Smrg          strcpy (concat_name + p_len + 1, wrapper);
516476888252Smrg        }
516576888252Smrg        if (check_executable(concat_name))
516676888252Smrg          return concat_name;
516776888252Smrg        XFREE(concat_name);
516876888252Smrg      }
516976888252Smrg    }
517076888252Smrg    /* not found in PATH; assume curdir */
517176888252Smrg  }
517276888252Smrg  /* Relative path | not found in path: prepend cwd */
517376888252Smrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
517476888252Smrg    lt_fatal ("getcwd failed");
517576888252Smrg  tmp_len = strlen(tmp);
517676888252Smrg  concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
517776888252Smrg  memcpy (concat_name, tmp, tmp_len);
517876888252Smrg  concat_name[tmp_len] = '/';
517976888252Smrg  strcpy (concat_name + tmp_len + 1, wrapper);
518076888252Smrg
518176888252Smrg  if (check_executable(concat_name))
518276888252Smrg    return concat_name;
518376888252Smrg  XFREE(concat_name);
518476888252Smrg  return NULL;
518576888252Smrg}
518676888252Smrg
518776888252Smrgchar *
518876888252Smrgstrendzap(char *str, const char *pat)
518976888252Smrg{
519076888252Smrg  size_t len, patlen;
519176888252Smrg
519276888252Smrg  assert(str != NULL);
519376888252Smrg  assert(pat != NULL);
519476888252Smrg
519576888252Smrg  len = strlen(str);
519676888252Smrg  patlen = strlen(pat);
519776888252Smrg
519876888252Smrg  if (patlen <= len)
519976888252Smrg  {
520076888252Smrg    str += len - patlen;
520176888252Smrg    if (strcmp(str, pat) == 0)
520276888252Smrg      *str = '\0';
520376888252Smrg  }
520476888252Smrg  return str;
520576888252Smrg}
520676888252Smrg
520776888252Smrgstatic void
520876888252Smrglt_error_core (int exit_status, const char * mode,
520976888252Smrg          const char * message, va_list ap)
521076888252Smrg{
521176888252Smrg  fprintf (stderr, "%s: %s: ", program_name, mode);
521276888252Smrg  vfprintf (stderr, message, ap);
521376888252Smrg  fprintf (stderr, ".\n");
521476888252Smrg
521576888252Smrg  if (exit_status >= 0)
521676888252Smrg    exit (exit_status);
521776888252Smrg}
521876888252Smrg
521976888252Smrgvoid
522076888252Smrglt_fatal (const char *message, ...)
522176888252Smrg{
522276888252Smrg  va_list ap;
522376888252Smrg  va_start (ap, message);
522476888252Smrg  lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
522576888252Smrg  va_end (ap);
522676888252Smrg}
522776888252SmrgEOF
522876888252Smrg          # we should really use a build-platform specific compiler
522976888252Smrg          # here, but OTOH, the wrappers (shell script and this C one)
523076888252Smrg          # are only useful if you want to execute the "real" binary.
523176888252Smrg          # Since the "real" binary is built for $host, then this
523276888252Smrg          # wrapper might as well be built for $host, too.
523376888252Smrg          $run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource
523476888252Smrg          ;;
523576888252Smrg        esac
523676888252Smrg        $rm $output
523776888252Smrg        trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
523876888252Smrg
523976888252Smrg	$echo > $output "\
524076888252Smrg#! $SHELL
524176888252Smrg
524276888252Smrg# $output - temporary wrapper script for $objdir/$outputname
524376888252Smrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
524476888252Smrg#
524576888252Smrg# The $output program cannot be directly executed until all the libtool
524676888252Smrg# libraries that it depends on are installed.
524776888252Smrg#
524876888252Smrg# This wrapper script should never be moved out of the build directory.
524976888252Smrg# If it is, it will not operate correctly.
525076888252Smrg
525176888252Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
525276888252Smrg# metacharacters that are still active within double-quoted strings.
525376888252SmrgXsed='${SED} -e 1s/^X//'
525476888252Smrgsed_quote_subst='$sed_quote_subst'
525576888252Smrg
525676888252Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout
525776888252Smrg# if CDPATH is set.
525876888252Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
525976888252Smrg
526076888252Smrgrelink_command=\"$relink_command\"
526176888252Smrg
526276888252Smrg# This environment variable determines our operation mode.
526376888252Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then
526476888252Smrg  # install mode needs the following variable:
526576888252Smrg  notinst_deplibs='$notinst_deplibs'
526676888252Smrgelse
526776888252Smrg  # When we are sourced in execute mode, \$file and \$echo are already set.
526876888252Smrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
526976888252Smrg    echo=\"$qecho\"
527076888252Smrg    file=\"\$0\"
527176888252Smrg    # Make sure echo works.
527276888252Smrg    if test \"X\$1\" = X--no-reexec; then
527376888252Smrg      # Discard the --no-reexec flag, and continue.
527476888252Smrg      shift
527576888252Smrg    elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then
527676888252Smrg      # Yippee, \$echo works!
527776888252Smrg      :
527876888252Smrg    else
527976888252Smrg      # Restart under the correct shell, and then maybe \$echo will work.
528076888252Smrg      exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
528176888252Smrg    fi
528276888252Smrg  fi\
528376888252Smrg"
528476888252Smrg	$echo >> $output "\
528576888252Smrg
528676888252Smrg  # Find the directory that this script lives in.
528776888252Smrg  thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
528876888252Smrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
528976888252Smrg
529076888252Smrg  # Follow symbolic links until we get to the real thisdir.
529176888252Smrg  file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
529276888252Smrg  while test -n \"\$file\"; do
529376888252Smrg    destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
529476888252Smrg
529576888252Smrg    # If there was a directory component, then change thisdir.
529676888252Smrg    if test \"x\$destdir\" != \"x\$file\"; then
529776888252Smrg      case \"\$destdir\" in
529876888252Smrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
529976888252Smrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
530076888252Smrg      esac
530176888252Smrg    fi
530276888252Smrg
530376888252Smrg    file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
530476888252Smrg    file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
530576888252Smrg  done
530676888252Smrg
530776888252Smrg  # Try to get the absolute directory name.
530876888252Smrg  absdir=\`cd \"\$thisdir\" && pwd\`
530976888252Smrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
531076888252Smrg"
531176888252Smrg
531276888252Smrg	if test "$fast_install" = yes; then
531376888252Smrg	  $echo >> $output "\
531476888252Smrg  program=lt-'$outputname'$exeext
531576888252Smrg  progdir=\"\$thisdir/$objdir\"
531676888252Smrg
531776888252Smrg  if test ! -f \"\$progdir/\$program\" || \\
531876888252Smrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
531976888252Smrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
532076888252Smrg
532176888252Smrg    file=\"\$\$-\$program\"
532276888252Smrg
532376888252Smrg    if test ! -d \"\$progdir\"; then
532476888252Smrg      $mkdir \"\$progdir\"
532576888252Smrg    else
532676888252Smrg      $rm \"\$progdir/\$file\"
532776888252Smrg    fi"
532876888252Smrg
532976888252Smrg	  $echo >> $output "\
533076888252Smrg
533176888252Smrg    # relink executable if necessary
533276888252Smrg    if test -n \"\$relink_command\"; then
533376888252Smrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
533476888252Smrg      else
533576888252Smrg	$echo \"\$relink_command_output\" >&2
533676888252Smrg	$rm \"\$progdir/\$file\"
533776888252Smrg	exit $EXIT_FAILURE
533876888252Smrg      fi
533976888252Smrg    fi
534076888252Smrg
534176888252Smrg    $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
534276888252Smrg    { $rm \"\$progdir/\$program\";
534376888252Smrg      $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
534476888252Smrg    $rm \"\$progdir/\$file\"
534576888252Smrg  fi"
534676888252Smrg	else
534776888252Smrg	  $echo >> $output "\
534876888252Smrg  program='$outputname'
534976888252Smrg  progdir=\"\$thisdir/$objdir\"
535076888252Smrg"
535176888252Smrg	fi
535276888252Smrg
535376888252Smrg	$echo >> $output "\
535476888252Smrg
535576888252Smrg  if test -f \"\$progdir/\$program\"; then"
535676888252Smrg
535776888252Smrg	# Export our shlibpath_var if we have one.
535876888252Smrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
535976888252Smrg	  $echo >> $output "\
536076888252Smrg    # Add our own library path to $shlibpath_var
536176888252Smrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
536276888252Smrg
536376888252Smrg    # Some systems cannot cope with colon-terminated $shlibpath_var
536476888252Smrg    # The second colon is a workaround for a bug in BeOS R4 sed
536576888252Smrg    $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
536676888252Smrg
536776888252Smrg    export $shlibpath_var
536876888252Smrg"
536976888252Smrg	fi
537076888252Smrg
537176888252Smrg	# fixup the dll searchpath if we need to.
537276888252Smrg	if test -n "$dllsearchpath"; then
537376888252Smrg	  $echo >> $output "\
537476888252Smrg    # Add the dll search path components to the executable PATH
537576888252Smrg    PATH=$dllsearchpath:\$PATH
537676888252Smrg"
537776888252Smrg	fi
537876888252Smrg
537976888252Smrg	$echo >> $output "\
538076888252Smrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
538176888252Smrg      # Run the actual program with our arguments.
538276888252Smrg"
538376888252Smrg	case $host in
538476888252Smrg	# Backslashes separate directories on plain windows
538576888252Smrg	*-*-mingw | *-*-os2*)
538676888252Smrg	  $echo >> $output "\
538776888252Smrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
538876888252Smrg"
538976888252Smrg	  ;;
539076888252Smrg
539176888252Smrg	*)
539276888252Smrg	  $echo >> $output "\
539376888252Smrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
539476888252Smrg"
539576888252Smrg	  ;;
539676888252Smrg	esac
539776888252Smrg	$echo >> $output "\
539876888252Smrg      \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\"
539976888252Smrg      exit $EXIT_FAILURE
540076888252Smrg    fi
540176888252Smrg  else
540276888252Smrg    # The program doesn't exist.
540376888252Smrg    \$echo \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
540476888252Smrg    \$echo \"This script is just a wrapper for \$program.\" 1>&2
540576888252Smrg    $echo \"See the $PACKAGE documentation for more information.\" 1>&2
540676888252Smrg    exit $EXIT_FAILURE
540776888252Smrg  fi
540876888252Smrgfi\
540976888252Smrg"
541076888252Smrg	chmod +x $output
541176888252Smrg      fi
541276888252Smrg      exit $EXIT_SUCCESS
541376888252Smrg      ;;
541476888252Smrg    esac
541576888252Smrg
541676888252Smrg    # See if we need to build an old-fashioned archive.
541776888252Smrg    for oldlib in $oldlibs; do
541876888252Smrg
541976888252Smrg      if test "$build_libtool_libs" = convenience; then
542076888252Smrg	oldobjs="$libobjs_save"
542176888252Smrg	addlibs="$convenience"
542276888252Smrg	build_libtool_libs=no
542376888252Smrg      else
542476888252Smrg	if test "$build_libtool_libs" = module; then
542576888252Smrg	  oldobjs="$libobjs_save"
542676888252Smrg	  build_libtool_libs=no
542776888252Smrg	else
542876888252Smrg	  oldobjs="$old_deplibs $non_pic_objects"
542976888252Smrg	fi
543076888252Smrg	addlibs="$old_convenience"
543176888252Smrg      fi
543276888252Smrg
543376888252Smrg      if test -n "$addlibs"; then
543476888252Smrg	gentop="$output_objdir/${outputname}x"
543576888252Smrg	generated="$generated $gentop"
543676888252Smrg
543776888252Smrg	func_extract_archives $gentop $addlibs
543876888252Smrg	oldobjs="$oldobjs $func_extract_archives_result"
543976888252Smrg      fi
544076888252Smrg
544176888252Smrg      # Do each command in the archive commands.
544276888252Smrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
544376888252Smrg       cmds=$old_archive_from_new_cmds
544476888252Smrg      else
544576888252Smrg	# POSIX demands no paths to be encoded in archives.  We have
544676888252Smrg	# to avoid creating archives with duplicate basenames if we
544776888252Smrg	# might have to extract them afterwards, e.g., when creating a
544876888252Smrg	# static archive out of a convenience library, or when linking
544976888252Smrg	# the entirety of a libtool archive into another (currently
545076888252Smrg	# not supported by libtool).
545176888252Smrg	if (for obj in $oldobjs
545276888252Smrg	    do
545376888252Smrg	      $echo "X$obj" | $Xsed -e 's%^.*/%%'
545476888252Smrg	    done | sort | sort -uc >/dev/null 2>&1); then
545576888252Smrg	  :
545676888252Smrg	else
545776888252Smrg	  $echo "copying selected object files to avoid basename conflicts..."
545876888252Smrg
545976888252Smrg	  if test -z "$gentop"; then
546076888252Smrg	    gentop="$output_objdir/${outputname}x"
546176888252Smrg	    generated="$generated $gentop"
546276888252Smrg
546376888252Smrg	    $show "${rm}r $gentop"
546476888252Smrg	    $run ${rm}r "$gentop"
546576888252Smrg	    $show "$mkdir $gentop"
546676888252Smrg	    $run $mkdir "$gentop"
546776888252Smrg	    exit_status=$?
546876888252Smrg	    if test "$exit_status" -ne 0 && test ! -d "$gentop"; then
546976888252Smrg	      exit $exit_status
547076888252Smrg	    fi
547176888252Smrg	  fi
547276888252Smrg
547376888252Smrg	  save_oldobjs=$oldobjs
547476888252Smrg	  oldobjs=
547576888252Smrg	  counter=1
547676888252Smrg	  for obj in $save_oldobjs
547776888252Smrg	  do
547876888252Smrg	    objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
547976888252Smrg	    case " $oldobjs " in
548076888252Smrg	    " ") oldobjs=$obj ;;
548176888252Smrg	    *[\ /]"$objbase "*)
548276888252Smrg	      while :; do
548376888252Smrg		# Make sure we don't pick an alternate name that also
548476888252Smrg		# overlaps.
548576888252Smrg		newobj=lt$counter-$objbase
548676888252Smrg		counter=`expr $counter + 1`
548776888252Smrg		case " $oldobjs " in
548876888252Smrg		*[\ /]"$newobj "*) ;;
548976888252Smrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
549076888252Smrg		esac
549176888252Smrg	      done
549276888252Smrg	      $show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
549376888252Smrg	      $run ln "$obj" "$gentop/$newobj" ||
549476888252Smrg	      $run cp "$obj" "$gentop/$newobj"
549576888252Smrg	      oldobjs="$oldobjs $gentop/$newobj"
549676888252Smrg	      ;;
549776888252Smrg	    *) oldobjs="$oldobjs $obj" ;;
549876888252Smrg	    esac
549976888252Smrg	  done
550076888252Smrg	fi
550176888252Smrg
550276888252Smrg	eval cmds=\"$old_archive_cmds\"
550376888252Smrg
550476888252Smrg	if len=`expr "X$cmds" : ".*"` &&
550576888252Smrg	     test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
550676888252Smrg	  cmds=$old_archive_cmds
550776888252Smrg	else
550876888252Smrg	  # the command line is too long to link in one step, link in parts
550976888252Smrg	  $echo "using piecewise archive linking..."
551076888252Smrg	  save_RANLIB=$RANLIB
551176888252Smrg	  RANLIB=:
551276888252Smrg	  objlist=
551376888252Smrg	  concat_cmds=
551476888252Smrg	  save_oldobjs=$oldobjs
551576888252Smrg
551676888252Smrg	  # Is there a better way of finding the last object in the list?
551776888252Smrg	  for obj in $save_oldobjs
551876888252Smrg	  do
551976888252Smrg	    last_oldobj=$obj
552076888252Smrg	  done
552176888252Smrg	  for obj in $save_oldobjs
552276888252Smrg	  do
552376888252Smrg	    oldobjs="$objlist $obj"
552476888252Smrg	    objlist="$objlist $obj"
552576888252Smrg	    eval test_cmds=\"$old_archive_cmds\"
552676888252Smrg	    if len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
552776888252Smrg	       test "$len" -le "$max_cmd_len"; then
552876888252Smrg	      :
552976888252Smrg	    else
553076888252Smrg	      # the above command should be used before it gets too long
553176888252Smrg	      oldobjs=$objlist
553276888252Smrg	      if test "$obj" = "$last_oldobj" ; then
553376888252Smrg	        RANLIB=$save_RANLIB
553476888252Smrg	      fi
553576888252Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
553676888252Smrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
553776888252Smrg	      objlist=
553876888252Smrg	    fi
553976888252Smrg	  done
554076888252Smrg	  RANLIB=$save_RANLIB
554176888252Smrg	  oldobjs=$objlist
554276888252Smrg	  if test "X$oldobjs" = "X" ; then
554376888252Smrg	    eval cmds=\"\$concat_cmds\"
554476888252Smrg	  else
554576888252Smrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
554676888252Smrg	  fi
554776888252Smrg	fi
554876888252Smrg      fi
554976888252Smrg      save_ifs="$IFS"; IFS='~'
555076888252Smrg      for cmd in $cmds; do
555176888252Smrg        eval cmd=\"$cmd\"
555276888252Smrg	IFS="$save_ifs"
555376888252Smrg	$show "$cmd"
555476888252Smrg	$run eval "$cmd" || exit $?
555576888252Smrg      done
555676888252Smrg      IFS="$save_ifs"
555776888252Smrg    done
555876888252Smrg
555976888252Smrg    if test -n "$generated"; then
556076888252Smrg      $show "${rm}r$generated"
556176888252Smrg      $run ${rm}r$generated
556276888252Smrg    fi
556376888252Smrg
556476888252Smrg    # Now create the libtool archive.
556576888252Smrg    case $output in
556676888252Smrg    *.la)
556776888252Smrg      old_library=
556876888252Smrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
556976888252Smrg      $show "creating $output"
557076888252Smrg
557176888252Smrg      # Preserve any variables that may affect compiler behavior
557276888252Smrg      for var in $variables_saved_for_relink; do
557376888252Smrg	if eval test -z \"\${$var+set}\"; then
557476888252Smrg	  relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
557576888252Smrg	elif eval var_value=\$$var; test -z "$var_value"; then
557676888252Smrg	  relink_command="$var=; export $var; $relink_command"
557776888252Smrg	else
557876888252Smrg	  var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
557976888252Smrg	  relink_command="$var=\"$var_value\"; export $var; $relink_command"
558076888252Smrg	fi
558176888252Smrg      done
558276888252Smrg      # Quote the link command for shipping.
558376888252Smrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
558476888252Smrg      relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
558576888252Smrg      if test "$hardcode_automatic" = yes ; then
558676888252Smrg	relink_command=
558776888252Smrg      fi
558876888252Smrg
558976888252Smrg
559076888252Smrg      # Only create the output if not a dry run.
559176888252Smrg      if test -z "$run"; then
559276888252Smrg	for installed in no yes; do
559376888252Smrg	  if test "$installed" = yes; then
559476888252Smrg	    if test -z "$install_libdir"; then
559576888252Smrg	      break
559676888252Smrg	    fi
559776888252Smrg	    output="$output_objdir/$outputname"i
559876888252Smrg	    # Replace all uninstalled libtool libraries with the installed ones
559976888252Smrg	    newdependency_libs=
560076888252Smrg	    for deplib in $dependency_libs; do
560176888252Smrg	      case $deplib in
560276888252Smrg	      *.la)
560376888252Smrg		name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'`
560476888252Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
560576888252Smrg		if test -z "$libdir"; then
560676888252Smrg		  $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
560776888252Smrg		  exit $EXIT_FAILURE
560876888252Smrg		fi
560976888252Smrg		newdependency_libs="$newdependency_libs $libdir/$name"
561076888252Smrg		;;
561176888252Smrg	      *) newdependency_libs="$newdependency_libs $deplib" ;;
561276888252Smrg	      esac
561376888252Smrg	    done
561476888252Smrg	    dependency_libs="$newdependency_libs"
561576888252Smrg	    newdlfiles=
561676888252Smrg	    for lib in $dlfiles; do
561776888252Smrg	      name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
561876888252Smrg	      eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
561976888252Smrg	      if test -z "$libdir"; then
562076888252Smrg		$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
562176888252Smrg		exit $EXIT_FAILURE
562276888252Smrg	      fi
562376888252Smrg	      newdlfiles="$newdlfiles $libdir/$name"
562476888252Smrg	    done
562576888252Smrg	    dlfiles="$newdlfiles"
562676888252Smrg	    newdlprefiles=
562776888252Smrg	    for lib in $dlprefiles; do
562876888252Smrg	      name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
562976888252Smrg	      eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
563076888252Smrg	      if test -z "$libdir"; then
563176888252Smrg		$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
563276888252Smrg		exit $EXIT_FAILURE
563376888252Smrg	      fi
563476888252Smrg	      newdlprefiles="$newdlprefiles $libdir/$name"
563576888252Smrg	    done
563676888252Smrg	    dlprefiles="$newdlprefiles"
563776888252Smrg	  else
563876888252Smrg	    newdlfiles=
563976888252Smrg	    for lib in $dlfiles; do
564076888252Smrg	      case $lib in
564176888252Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
564276888252Smrg		*) abs=`pwd`"/$lib" ;;
564376888252Smrg	      esac
564476888252Smrg	      newdlfiles="$newdlfiles $abs"
564576888252Smrg	    done
564676888252Smrg	    dlfiles="$newdlfiles"
564776888252Smrg	    newdlprefiles=
564876888252Smrg	    for lib in $dlprefiles; do
564976888252Smrg	      case $lib in
565076888252Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
565176888252Smrg		*) abs=`pwd`"/$lib" ;;
565276888252Smrg	      esac
565376888252Smrg	      newdlprefiles="$newdlprefiles $abs"
565476888252Smrg	    done
565576888252Smrg	    dlprefiles="$newdlprefiles"
565676888252Smrg	  fi
565776888252Smrg	  $rm $output
565876888252Smrg	  # place dlname in correct position for cygwin
565976888252Smrg	  tdlname=$dlname
566076888252Smrg	  case $host,$output,$installed,$module,$dlname in
566176888252Smrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
566276888252Smrg	  esac
566376888252Smrg	  $echo > $output "\
566476888252Smrg# $outputname - a libtool library file
566576888252Smrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
566676888252Smrg#
566776888252Smrg# Please DO NOT delete this file!
566876888252Smrg# It is necessary for linking the library.
566976888252Smrg
567076888252Smrg# The name that we can dlopen(3).
567176888252Smrgdlname='$tdlname'
567276888252Smrg
567376888252Smrg# Names of this library.
567476888252Smrglibrary_names='$library_names'
567576888252Smrg
567676888252Smrg# The name of the static archive.
567776888252Smrgold_library='$old_library'
567876888252Smrg
567976888252Smrg# Libraries that this one depends upon.
568076888252Smrgdependency_libs='$dependency_libs'
568176888252Smrg
568276888252Smrg# Version information for $libname.
568376888252Smrgcurrent=$current
568476888252Smrgage=$age
568576888252Smrgrevision=$revision
568676888252Smrg
568776888252Smrg# Is this an already installed library?
568876888252Smrginstalled=$installed
568976888252Smrg
569076888252Smrg# Should we warn about portability when linking against -modules?
569176888252Smrgshouldnotlink=$module
569276888252Smrg
569376888252Smrg# Files to dlopen/dlpreopen
569476888252Smrgdlopen='$dlfiles'
569576888252Smrgdlpreopen='$dlprefiles'
569676888252Smrg
569776888252Smrg# Directory that this library needs to be installed in:
569876888252Smrglibdir='$install_libdir'"
569976888252Smrg	  if test "$installed" = no && test "$need_relink" = yes; then
570076888252Smrg	    $echo >> $output "\
570176888252Smrgrelink_command=\"$relink_command\""
570276888252Smrg	  fi
570376888252Smrg	done
570476888252Smrg      fi
570576888252Smrg
570676888252Smrg      # Do a symbolic link so that the libtool archive can be found in
570776888252Smrg      # LD_LIBRARY_PATH before the program is installed.
570876888252Smrg      $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)"
570976888252Smrg      $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $?
571076888252Smrg      ;;
571176888252Smrg    esac
571276888252Smrg    exit $EXIT_SUCCESS
571376888252Smrg    ;;
571476888252Smrg
571576888252Smrg  # libtool install mode
571676888252Smrg  install)
571776888252Smrg    modename="$modename: install"
571876888252Smrg
571976888252Smrg    # There may be an optional sh(1) argument at the beginning of
572076888252Smrg    # install_prog (especially on Windows NT).
572176888252Smrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
572276888252Smrg       # Allow the use of GNU shtool's install command.
572376888252Smrg       $echo "X$nonopt" | grep shtool > /dev/null; then
572476888252Smrg      # Aesthetically quote it.
572576888252Smrg      arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"`
572676888252Smrg      case $arg in
572776888252Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
572876888252Smrg	arg="\"$arg\""
572976888252Smrg	;;
573076888252Smrg      esac
573176888252Smrg      install_prog="$arg "
573276888252Smrg      arg="$1"
573376888252Smrg      shift
573476888252Smrg    else
573576888252Smrg      install_prog=
573676888252Smrg      arg=$nonopt
573776888252Smrg    fi
573876888252Smrg
573976888252Smrg    # The real first argument should be the name of the installation program.
574076888252Smrg    # Aesthetically quote it.
574176888252Smrg    arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
574276888252Smrg    case $arg in
574376888252Smrg    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
574476888252Smrg      arg="\"$arg\""
574576888252Smrg      ;;
574676888252Smrg    esac
574776888252Smrg    install_prog="$install_prog$arg"
574876888252Smrg
574976888252Smrg    # We need to accept at least all the BSD install flags.
575076888252Smrg    dest=
575176888252Smrg    files=
575276888252Smrg    opts=
575376888252Smrg    prev=
575476888252Smrg    install_type=
575576888252Smrg    isdir=no
575676888252Smrg    stripme=
575776888252Smrg    for arg
575876888252Smrg    do
575976888252Smrg      if test -n "$dest"; then
576076888252Smrg	files="$files $dest"
576176888252Smrg	dest=$arg
576276888252Smrg	continue
576376888252Smrg      fi
576476888252Smrg
576576888252Smrg      case $arg in
576676888252Smrg      -d) isdir=yes ;;
576776888252Smrg      -f) 
576876888252Smrg      	case " $install_prog " in
576976888252Smrg	*[\\\ /]cp\ *) ;;
577076888252Smrg	*) prev=$arg ;;
577176888252Smrg	esac
577276888252Smrg	;;
577376888252Smrg      -g | -m | -o) prev=$arg ;;
577476888252Smrg      -s)
577576888252Smrg	stripme=" -s"
577676888252Smrg	continue
577776888252Smrg	;;
577876888252Smrg      -*)
577976888252Smrg	;;
578076888252Smrg      *)
578176888252Smrg	# If the previous option needed an argument, then skip it.
578276888252Smrg	if test -n "$prev"; then
578376888252Smrg	  prev=
578476888252Smrg	else
578576888252Smrg	  dest=$arg
578676888252Smrg	  continue
578776888252Smrg	fi
578876888252Smrg	;;
578976888252Smrg      esac
579076888252Smrg
579176888252Smrg      # Aesthetically quote the argument.
579276888252Smrg      arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
579376888252Smrg      case $arg in
579476888252Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
579576888252Smrg	arg="\"$arg\""
579676888252Smrg	;;
579776888252Smrg      esac
579876888252Smrg      install_prog="$install_prog $arg"
579976888252Smrg    done
580076888252Smrg
580176888252Smrg    if test -z "$install_prog"; then
580276888252Smrg      $echo "$modename: you must specify an install program" 1>&2
580376888252Smrg      $echo "$help" 1>&2
580476888252Smrg      exit $EXIT_FAILURE
580576888252Smrg    fi
580676888252Smrg
580776888252Smrg    if test -n "$prev"; then
580876888252Smrg      $echo "$modename: the \`$prev' option requires an argument" 1>&2
580976888252Smrg      $echo "$help" 1>&2
581076888252Smrg      exit $EXIT_FAILURE
581176888252Smrg    fi
581276888252Smrg
581376888252Smrg    if test -z "$files"; then
581476888252Smrg      if test -z "$dest"; then
581576888252Smrg	$echo "$modename: no file or destination specified" 1>&2
581676888252Smrg      else
581776888252Smrg	$echo "$modename: you must specify a destination" 1>&2
581876888252Smrg      fi
581976888252Smrg      $echo "$help" 1>&2
582076888252Smrg      exit $EXIT_FAILURE
582176888252Smrg    fi
582276888252Smrg
582376888252Smrg    # Strip any trailing slash from the destination.
582476888252Smrg    dest=`$echo "X$dest" | $Xsed -e 's%/$%%'`
582576888252Smrg
582676888252Smrg    # Check to see that the destination is a directory.
582776888252Smrg    test -d "$dest" && isdir=yes
582876888252Smrg    if test "$isdir" = yes; then
582976888252Smrg      destdir="$dest"
583076888252Smrg      destname=
583176888252Smrg    else
583276888252Smrg      destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'`
583376888252Smrg      test "X$destdir" = "X$dest" && destdir=.
583476888252Smrg      destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'`
583576888252Smrg
583676888252Smrg      # Not a directory, so check to see that there is only one file specified.
583776888252Smrg      set dummy $files
583876888252Smrg      if test "$#" -gt 2; then
583976888252Smrg	$echo "$modename: \`$dest' is not a directory" 1>&2
584076888252Smrg	$echo "$help" 1>&2
584176888252Smrg	exit $EXIT_FAILURE
584276888252Smrg      fi
584376888252Smrg    fi
584476888252Smrg    case $destdir in
584576888252Smrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
584676888252Smrg    *)
584776888252Smrg      for file in $files; do
584876888252Smrg	case $file in
584976888252Smrg	*.lo) ;;
585076888252Smrg	*)
585176888252Smrg	  $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2
585276888252Smrg	  $echo "$help" 1>&2
585376888252Smrg	  exit $EXIT_FAILURE
585476888252Smrg	  ;;
585576888252Smrg	esac
585676888252Smrg      done
585776888252Smrg      ;;
585876888252Smrg    esac
585976888252Smrg
586076888252Smrg    # This variable tells wrapper scripts just to set variables rather
586176888252Smrg    # than running their programs.
586276888252Smrg    libtool_install_magic="$magic"
586376888252Smrg
586476888252Smrg    staticlibs=
586576888252Smrg    future_libdirs=
586676888252Smrg    current_libdirs=
586776888252Smrg    for file in $files; do
586876888252Smrg
586976888252Smrg      # Do each installation.
587076888252Smrg      case $file in
587176888252Smrg      *.$libext)
587276888252Smrg	# Do the static libraries later.
587376888252Smrg	staticlibs="$staticlibs $file"
587476888252Smrg	;;
587576888252Smrg
587676888252Smrg      *.la)
587776888252Smrg	# Check to see that this really is a libtool archive.
587876888252Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
587976888252Smrg	else
588076888252Smrg	  $echo "$modename: \`$file' is not a valid libtool archive" 1>&2
588176888252Smrg	  $echo "$help" 1>&2
588276888252Smrg	  exit $EXIT_FAILURE
588376888252Smrg	fi
588476888252Smrg
588576888252Smrg	library_names=
588676888252Smrg	old_library=
588776888252Smrg	relink_command=
588876888252Smrg	# If there is no directory component, then add one.
588976888252Smrg	case $file in
589076888252Smrg	*/* | *\\*) . $file ;;
589176888252Smrg	*) . ./$file ;;
589276888252Smrg	esac
589376888252Smrg
589476888252Smrg	# Add the libdir to current_libdirs if it is the destination.
589576888252Smrg	if test "X$destdir" = "X$libdir"; then
589676888252Smrg	  case "$current_libdirs " in
589776888252Smrg	  *" $libdir "*) ;;
589876888252Smrg	  *) current_libdirs="$current_libdirs $libdir" ;;
589976888252Smrg	  esac
590076888252Smrg	else
590176888252Smrg	  # Note the libdir as a future libdir.
590276888252Smrg	  case "$future_libdirs " in
590376888252Smrg	  *" $libdir "*) ;;
590476888252Smrg	  *) future_libdirs="$future_libdirs $libdir" ;;
590576888252Smrg	  esac
590676888252Smrg	fi
590776888252Smrg
590876888252Smrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/
590976888252Smrg	test "X$dir" = "X$file/" && dir=
591076888252Smrg	dir="$dir$objdir"
591176888252Smrg
591276888252Smrg	if test -n "$relink_command"; then
591376888252Smrg	  # Determine the prefix the user has applied to our future dir.
591476888252Smrg	  inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"`
591576888252Smrg
591676888252Smrg	  # Don't allow the user to place us outside of our expected
591776888252Smrg	  # location b/c this prevents finding dependent libraries that
591876888252Smrg	  # are installed to the same prefix.
591976888252Smrg	  # At present, this check doesn't affect windows .dll's that
592076888252Smrg	  # are installed into $libdir/../bin (currently, that works fine)
592176888252Smrg	  # but it's something to keep an eye on.
592276888252Smrg	  if test "$inst_prefix_dir" = "$destdir"; then
592376888252Smrg	    $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2
592476888252Smrg	    exit $EXIT_FAILURE
592576888252Smrg	  fi
592676888252Smrg
592776888252Smrg	  if test -n "$inst_prefix_dir"; then
592876888252Smrg	    # Stick the inst_prefix_dir data into the link command.
592976888252Smrg	    relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
593076888252Smrg	  else
593176888252Smrg	    relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
593276888252Smrg	  fi
593376888252Smrg
593476888252Smrg	  $echo "$modename: warning: relinking \`$file'" 1>&2
593576888252Smrg	  $show "$relink_command"
593676888252Smrg	  if $run eval "$relink_command"; then :
593776888252Smrg	  else
593876888252Smrg	    $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
593976888252Smrg	    exit $EXIT_FAILURE
594076888252Smrg	  fi
594176888252Smrg	fi
594276888252Smrg
594376888252Smrg	# See the names of the shared library.
594476888252Smrg	set dummy $library_names
594576888252Smrg	if test -n "$2"; then
594676888252Smrg	  realname="$2"
594776888252Smrg	  shift
594876888252Smrg	  shift
594976888252Smrg
595076888252Smrg	  srcname="$realname"
595176888252Smrg	  test -n "$relink_command" && srcname="$realname"T
595276888252Smrg
595376888252Smrg	  # Install the shared library and build the symlinks.
595476888252Smrg	  $show "$install_prog $dir/$srcname $destdir/$realname"
595576888252Smrg	  $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $?
595676888252Smrg	  if test -n "$stripme" && test -n "$striplib"; then
595776888252Smrg	    $show "$striplib $destdir/$realname"
595876888252Smrg	    $run eval "$striplib $destdir/$realname" || exit $?
595976888252Smrg	  fi
596076888252Smrg
596176888252Smrg	  if test "$#" -gt 0; then
596276888252Smrg	    # Delete the old symlinks, and create new ones.
596376888252Smrg	    # Try `ln -sf' first, because the `ln' binary might depend on
596476888252Smrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
596576888252Smrg	    # so we also need to try rm && ln -s.
596676888252Smrg	    for linkname
596776888252Smrg	    do
596876888252Smrg	      if test "$linkname" != "$realname"; then
596976888252Smrg                $show "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
597076888252Smrg                $run eval "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
597176888252Smrg	      fi
597276888252Smrg	    done
597376888252Smrg	  fi
597476888252Smrg
597576888252Smrg	  # Do each command in the postinstall commands.
597676888252Smrg	  lib="$destdir/$realname"
597776888252Smrg	  cmds=$postinstall_cmds
597876888252Smrg	  save_ifs="$IFS"; IFS='~'
597976888252Smrg	  for cmd in $cmds; do
598076888252Smrg	    IFS="$save_ifs"
598176888252Smrg	    eval cmd=\"$cmd\"
598276888252Smrg	    $show "$cmd"
598376888252Smrg	    $run eval "$cmd" || {
598476888252Smrg	      lt_exit=$?
598576888252Smrg
598676888252Smrg	      # Restore the uninstalled library and exit
598776888252Smrg	      if test "$mode" = relink; then
598876888252Smrg		$run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
598976888252Smrg	      fi
599076888252Smrg
599176888252Smrg	      exit $lt_exit
599276888252Smrg	    }
599376888252Smrg	  done
599476888252Smrg	  IFS="$save_ifs"
599576888252Smrg	fi
599676888252Smrg
599776888252Smrg	# Install the pseudo-library for information purposes.
599876888252Smrg	name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
599976888252Smrg	instname="$dir/$name"i
600076888252Smrg	$show "$install_prog $instname $destdir/$name"
600176888252Smrg	$run eval "$install_prog $instname $destdir/$name" || exit $?
600276888252Smrg
600376888252Smrg	# Maybe install the static library, too.
600476888252Smrg	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
600576888252Smrg	;;
600676888252Smrg
600776888252Smrg      *.lo)
600876888252Smrg	# Install (i.e. copy) a libtool object.
600976888252Smrg
601076888252Smrg	# Figure out destination file name, if it wasn't already specified.
601176888252Smrg	if test -n "$destname"; then
601276888252Smrg	  destfile="$destdir/$destname"
601376888252Smrg	else
601476888252Smrg	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
601576888252Smrg	  destfile="$destdir/$destfile"
601676888252Smrg	fi
601776888252Smrg
601876888252Smrg	# Deduce the name of the destination old-style object file.
601976888252Smrg	case $destfile in
602076888252Smrg	*.lo)
602176888252Smrg	  staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"`
602276888252Smrg	  ;;
602376888252Smrg	*.$objext)
602476888252Smrg	  staticdest="$destfile"
602576888252Smrg	  destfile=
602676888252Smrg	  ;;
602776888252Smrg	*)
602876888252Smrg	  $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2
602976888252Smrg	  $echo "$help" 1>&2
603076888252Smrg	  exit $EXIT_FAILURE
603176888252Smrg	  ;;
603276888252Smrg	esac
603376888252Smrg
603476888252Smrg	# Install the libtool object if requested.
603576888252Smrg	if test -n "$destfile"; then
603676888252Smrg	  $show "$install_prog $file $destfile"
603776888252Smrg	  $run eval "$install_prog $file $destfile" || exit $?
603876888252Smrg	fi
603976888252Smrg
604076888252Smrg	# Install the old object if enabled.
604176888252Smrg	if test "$build_old_libs" = yes; then
604276888252Smrg	  # Deduce the name of the old-style object file.
604376888252Smrg	  staticobj=`$echo "X$file" | $Xsed -e "$lo2o"`
604476888252Smrg
604576888252Smrg	  $show "$install_prog $staticobj $staticdest"
604676888252Smrg	  $run eval "$install_prog \$staticobj \$staticdest" || exit $?
604776888252Smrg	fi
604876888252Smrg	exit $EXIT_SUCCESS
604976888252Smrg	;;
605076888252Smrg
605176888252Smrg      *)
605276888252Smrg	# Figure out destination file name, if it wasn't already specified.
605376888252Smrg	if test -n "$destname"; then
605476888252Smrg	  destfile="$destdir/$destname"
605576888252Smrg	else
605676888252Smrg	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
605776888252Smrg	  destfile="$destdir/$destfile"
605876888252Smrg	fi
605976888252Smrg
606076888252Smrg	# If the file is missing, and there is a .exe on the end, strip it
606176888252Smrg	# because it is most likely a libtool script we actually want to
606276888252Smrg	# install
606376888252Smrg	stripped_ext=""
606476888252Smrg	case $file in
606576888252Smrg	  *.exe)
606676888252Smrg	    if test ! -f "$file"; then
606776888252Smrg	      file=`$echo $file|${SED} 's,.exe$,,'`
606876888252Smrg	      stripped_ext=".exe"
606976888252Smrg	    fi
607076888252Smrg	    ;;
607176888252Smrg	esac
607276888252Smrg
607376888252Smrg	# Do a test to see if this is really a libtool program.
607476888252Smrg	case $host in
607576888252Smrg	*cygwin*|*mingw*)
607676888252Smrg	    wrapper=`$echo $file | ${SED} -e 's,.exe$,,'`
607776888252Smrg	    ;;
607876888252Smrg	*)
607976888252Smrg	    wrapper=$file
608076888252Smrg	    ;;
608176888252Smrg	esac
608276888252Smrg	if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then
608376888252Smrg	  notinst_deplibs=
608476888252Smrg	  relink_command=
608576888252Smrg
608676888252Smrg	  # Note that it is not necessary on cygwin/mingw to append a dot to
608776888252Smrg	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
608876888252Smrg	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
608976888252Smrg	  # `FILE.' does not work on cygwin managed mounts.
609076888252Smrg	  #
609176888252Smrg	  # If there is no directory component, then add one.
609276888252Smrg	  case $wrapper in
609376888252Smrg	  */* | *\\*) . ${wrapper} ;;
609476888252Smrg	  *) . ./${wrapper} ;;
609576888252Smrg	  esac
609676888252Smrg
609776888252Smrg	  # Check the variables that should have been set.
609876888252Smrg	  if test -z "$notinst_deplibs"; then
609976888252Smrg	    $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2
610076888252Smrg	    exit $EXIT_FAILURE
610176888252Smrg	  fi
610276888252Smrg
610376888252Smrg	  finalize=yes
610476888252Smrg	  for lib in $notinst_deplibs; do
610576888252Smrg	    # Check to see that each library is installed.
610676888252Smrg	    libdir=
610776888252Smrg	    if test -f "$lib"; then
610876888252Smrg	      # If there is no directory component, then add one.
610976888252Smrg	      case $lib in
611076888252Smrg	      */* | *\\*) . $lib ;;
611176888252Smrg	      *) . ./$lib ;;
611276888252Smrg	      esac
611376888252Smrg	    fi
611476888252Smrg	    libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
611576888252Smrg	    if test -n "$libdir" && test ! -f "$libfile"; then
611676888252Smrg	      $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2
611776888252Smrg	      finalize=no
611876888252Smrg	    fi
611976888252Smrg	  done
612076888252Smrg
612176888252Smrg	  relink_command=
612276888252Smrg	  # Note that it is not necessary on cygwin/mingw to append a dot to
612376888252Smrg	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
612476888252Smrg	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
612576888252Smrg	  # `FILE.' does not work on cygwin managed mounts.
612676888252Smrg	  #
612776888252Smrg	  # If there is no directory component, then add one.
612876888252Smrg	  case $wrapper in
612976888252Smrg	  */* | *\\*) . ${wrapper} ;;
613076888252Smrg	  *) . ./${wrapper} ;;
613176888252Smrg	  esac
613276888252Smrg
613376888252Smrg	  outputname=
613476888252Smrg	  if test "$fast_install" = no && test -n "$relink_command"; then
613576888252Smrg	    if test "$finalize" = yes && test -z "$run"; then
613676888252Smrg	      tmpdir=`func_mktempdir`
613776888252Smrg	      file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
613876888252Smrg	      outputname="$tmpdir/$file"
613976888252Smrg	      # Replace the output file specification.
614076888252Smrg	      relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
614176888252Smrg
614276888252Smrg	      $show "$relink_command"
614376888252Smrg	      if $run eval "$relink_command"; then :
614476888252Smrg	      else
614576888252Smrg		$echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
614676888252Smrg		${rm}r "$tmpdir"
614776888252Smrg		continue
614876888252Smrg	      fi
614976888252Smrg	      file="$outputname"
615076888252Smrg	    else
615176888252Smrg	      $echo "$modename: warning: cannot relink \`$file'" 1>&2
615276888252Smrg	    fi
615376888252Smrg	  else
615476888252Smrg	    # Install the binary that we compiled earlier.
615576888252Smrg	    file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
615676888252Smrg	  fi
615776888252Smrg	fi
615876888252Smrg
615976888252Smrg	# remove .exe since cygwin /usr/bin/install will append another
616076888252Smrg	# one anyway 
616176888252Smrg	case $install_prog,$host in
616276888252Smrg	*/usr/bin/install*,*cygwin*)
616376888252Smrg	  case $file:$destfile in
616476888252Smrg	  *.exe:*.exe)
616576888252Smrg	    # this is ok
616676888252Smrg	    ;;
616776888252Smrg	  *.exe:*)
616876888252Smrg	    destfile=$destfile.exe
616976888252Smrg	    ;;
617076888252Smrg	  *:*.exe)
617176888252Smrg	    destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'`
617276888252Smrg	    ;;
617376888252Smrg	  esac
617476888252Smrg	  ;;
617576888252Smrg	esac
617676888252Smrg	$show "$install_prog$stripme $file $destfile"
617776888252Smrg	$run eval "$install_prog\$stripme \$file \$destfile" || exit $?
617876888252Smrg	test -n "$outputname" && ${rm}r "$tmpdir"
617976888252Smrg	;;
618076888252Smrg      esac
618176888252Smrg    done
618276888252Smrg
618376888252Smrg    for file in $staticlibs; do
618476888252Smrg      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
618576888252Smrg
618676888252Smrg      # Set up the ranlib parameters.
618776888252Smrg      oldlib="$destdir/$name"
618876888252Smrg
618976888252Smrg      $show "$install_prog $file $oldlib"
619076888252Smrg      $run eval "$install_prog \$file \$oldlib" || exit $?
619176888252Smrg
619276888252Smrg      if test -n "$stripme" && test -n "$old_striplib"; then
619376888252Smrg	$show "$old_striplib $oldlib"
619476888252Smrg	$run eval "$old_striplib $oldlib" || exit $?
619576888252Smrg      fi
619676888252Smrg
619776888252Smrg      # Do each command in the postinstall commands.
619876888252Smrg      cmds=$old_postinstall_cmds
619976888252Smrg      save_ifs="$IFS"; IFS='~'
620076888252Smrg      for cmd in $cmds; do
620176888252Smrg	IFS="$save_ifs"
620276888252Smrg	eval cmd=\"$cmd\"
620376888252Smrg	$show "$cmd"
620476888252Smrg	$run eval "$cmd" || exit $?
620576888252Smrg      done
620676888252Smrg      IFS="$save_ifs"
620776888252Smrg    done
620876888252Smrg
620976888252Smrg    if test -n "$future_libdirs"; then
621076888252Smrg      $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2
621176888252Smrg    fi
621276888252Smrg
621376888252Smrg    if test -n "$current_libdirs"; then
621476888252Smrg      # Maybe just do a dry run.
621576888252Smrg      test -n "$run" && current_libdirs=" -n$current_libdirs"
621676888252Smrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
621776888252Smrg    else
621876888252Smrg      exit $EXIT_SUCCESS
621976888252Smrg    fi
622076888252Smrg    ;;
622176888252Smrg
622276888252Smrg  # libtool finish mode
622376888252Smrg  finish)
622476888252Smrg    modename="$modename: finish"
622576888252Smrg    libdirs="$nonopt"
622676888252Smrg    admincmds=
622776888252Smrg
622876888252Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
622976888252Smrg      for dir
623076888252Smrg      do
623176888252Smrg	libdirs="$libdirs $dir"
623276888252Smrg      done
623376888252Smrg
623476888252Smrg      for libdir in $libdirs; do
623576888252Smrg	if test -n "$finish_cmds"; then
623676888252Smrg	  # Do each command in the finish commands.
623776888252Smrg	  cmds=$finish_cmds
623876888252Smrg	  save_ifs="$IFS"; IFS='~'
623976888252Smrg	  for cmd in $cmds; do
624076888252Smrg	    IFS="$save_ifs"
624176888252Smrg	    eval cmd=\"$cmd\"
624276888252Smrg	    $show "$cmd"
624376888252Smrg	    $run eval "$cmd" || admincmds="$admincmds
624476888252Smrg       $cmd"
624576888252Smrg	  done
624676888252Smrg	  IFS="$save_ifs"
624776888252Smrg	fi
624876888252Smrg	if test -n "$finish_eval"; then
624976888252Smrg	  # Do the single finish_eval.
625076888252Smrg	  eval cmds=\"$finish_eval\"
625176888252Smrg	  $run eval "$cmds" || admincmds="$admincmds
625276888252Smrg       $cmds"
625376888252Smrg	fi
625476888252Smrg      done
625576888252Smrg    fi
625676888252Smrg
625776888252Smrg    # Exit here if they wanted silent mode.
625876888252Smrg    test "$show" = : && exit $EXIT_SUCCESS
625976888252Smrg
626076888252Smrg    $echo "X----------------------------------------------------------------------" | $Xsed
626176888252Smrg    $echo "Libraries have been installed in:"
626276888252Smrg    for libdir in $libdirs; do
626376888252Smrg      $echo "   $libdir"
626476888252Smrg    done
626576888252Smrg    $echo
626676888252Smrg    $echo "If you ever happen to want to link against installed libraries"
626776888252Smrg    $echo "in a given directory, LIBDIR, you must either use libtool, and"
626876888252Smrg    $echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
626976888252Smrg    $echo "flag during linking and do at least one of the following:"
627076888252Smrg    if test -n "$shlibpath_var"; then
627176888252Smrg      $echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
627276888252Smrg      $echo "     during execution"
627376888252Smrg    fi
627476888252Smrg    if test -n "$runpath_var"; then
627576888252Smrg      $echo "   - add LIBDIR to the \`$runpath_var' environment variable"
627676888252Smrg      $echo "     during linking"
627776888252Smrg    fi
627876888252Smrg    if test -n "$hardcode_libdir_flag_spec"; then
627976888252Smrg      libdir=LIBDIR
628076888252Smrg      eval flag=\"$hardcode_libdir_flag_spec\"
628176888252Smrg
628276888252Smrg      $echo "   - use the \`$flag' linker flag"
628376888252Smrg    fi
628476888252Smrg    if test -n "$admincmds"; then
628576888252Smrg      $echo "   - have your system administrator run these commands:$admincmds"
628676888252Smrg    fi
628776888252Smrg    if test -f /etc/ld.so.conf; then
628876888252Smrg      $echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
628976888252Smrg    fi
629076888252Smrg    $echo
629176888252Smrg    $echo "See any operating system documentation about shared libraries for"
629276888252Smrg    $echo "more information, such as the ld(1) and ld.so(8) manual pages."
629376888252Smrg    $echo "X----------------------------------------------------------------------" | $Xsed
629476888252Smrg    exit $EXIT_SUCCESS
629576888252Smrg    ;;
629676888252Smrg
629776888252Smrg  # libtool execute mode
629876888252Smrg  execute)
629976888252Smrg    modename="$modename: execute"
630076888252Smrg
630176888252Smrg    # The first argument is the command name.
630276888252Smrg    cmd="$nonopt"
630376888252Smrg    if test -z "$cmd"; then
630476888252Smrg      $echo "$modename: you must specify a COMMAND" 1>&2
630576888252Smrg      $echo "$help"
630676888252Smrg      exit $EXIT_FAILURE
630776888252Smrg    fi
630876888252Smrg
630976888252Smrg    # Handle -dlopen flags immediately.
631076888252Smrg    for file in $execute_dlfiles; do
631176888252Smrg      if test ! -f "$file"; then
631276888252Smrg	$echo "$modename: \`$file' is not a file" 1>&2
631376888252Smrg	$echo "$help" 1>&2
631476888252Smrg	exit $EXIT_FAILURE
631576888252Smrg      fi
631676888252Smrg
631776888252Smrg      dir=
631876888252Smrg      case $file in
631976888252Smrg      *.la)
632076888252Smrg	# Check to see that this really is a libtool archive.
632176888252Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
632276888252Smrg	else
632376888252Smrg	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
632476888252Smrg	  $echo "$help" 1>&2
632576888252Smrg	  exit $EXIT_FAILURE
632676888252Smrg	fi
632776888252Smrg
632876888252Smrg	# Read the libtool library.
632976888252Smrg	dlname=
633076888252Smrg	library_names=
633176888252Smrg
633276888252Smrg	# If there is no directory component, then add one.
633376888252Smrg	case $file in
633476888252Smrg	*/* | *\\*) . $file ;;
633576888252Smrg	*) . ./$file ;;
633676888252Smrg	esac
633776888252Smrg
633876888252Smrg	# Skip this library if it cannot be dlopened.
633976888252Smrg	if test -z "$dlname"; then
634076888252Smrg	  # Warn if it was a shared library.
634176888252Smrg	  test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'"
634276888252Smrg	  continue
634376888252Smrg	fi
634476888252Smrg
634576888252Smrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
634676888252Smrg	test "X$dir" = "X$file" && dir=.
634776888252Smrg
634876888252Smrg	if test -f "$dir/$objdir/$dlname"; then
634976888252Smrg	  dir="$dir/$objdir"
635076888252Smrg	else
635176888252Smrg	  $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
635276888252Smrg	  exit $EXIT_FAILURE
635376888252Smrg	fi
635476888252Smrg	;;
635576888252Smrg
635676888252Smrg      *.lo)
635776888252Smrg	# Just add the directory containing the .lo file.
635876888252Smrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
635976888252Smrg	test "X$dir" = "X$file" && dir=.
636076888252Smrg	;;
636176888252Smrg
636276888252Smrg      *)
636376888252Smrg	$echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2
636476888252Smrg	continue
636576888252Smrg	;;
636676888252Smrg      esac
636776888252Smrg
636876888252Smrg      # Get the absolute pathname.
636976888252Smrg      absdir=`cd "$dir" && pwd`
637076888252Smrg      test -n "$absdir" && dir="$absdir"
637176888252Smrg
637276888252Smrg      # Now add the directory to shlibpath_var.
637376888252Smrg      if eval "test -z \"\$$shlibpath_var\""; then
637476888252Smrg	eval "$shlibpath_var=\"\$dir\""
637576888252Smrg      else
637676888252Smrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
637776888252Smrg      fi
637876888252Smrg    done
637976888252Smrg
638076888252Smrg    # This variable tells wrapper scripts just to set shlibpath_var
638176888252Smrg    # rather than running their programs.
638276888252Smrg    libtool_execute_magic="$magic"
638376888252Smrg
638476888252Smrg    # Check if any of the arguments is a wrapper script.
638576888252Smrg    args=
638676888252Smrg    for file
638776888252Smrg    do
638876888252Smrg      case $file in
638976888252Smrg      -*) ;;
639076888252Smrg      *)
639176888252Smrg	# Do a test to see if this is really a libtool program.
639276888252Smrg	if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
639376888252Smrg	  # If there is no directory component, then add one.
639476888252Smrg	  case $file in
639576888252Smrg	  */* | *\\*) . $file ;;
639676888252Smrg	  *) . ./$file ;;
639776888252Smrg	  esac
639876888252Smrg
639976888252Smrg	  # Transform arg to wrapped name.
640076888252Smrg	  file="$progdir/$program"
640176888252Smrg	fi
640276888252Smrg	;;
640376888252Smrg      esac
640476888252Smrg      # Quote arguments (to preserve shell metacharacters).
640576888252Smrg      file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"`
640676888252Smrg      args="$args \"$file\""
640776888252Smrg    done
640876888252Smrg
640976888252Smrg    if test -z "$run"; then
641076888252Smrg      if test -n "$shlibpath_var"; then
641176888252Smrg	# Export the shlibpath_var.
641276888252Smrg	eval "export $shlibpath_var"
641376888252Smrg      fi
641476888252Smrg
641576888252Smrg      # Restore saved environment variables
641676888252Smrg      if test "${save_LC_ALL+set}" = set; then
641776888252Smrg	LC_ALL="$save_LC_ALL"; export LC_ALL
641876888252Smrg      fi
641976888252Smrg      if test "${save_LANG+set}" = set; then
642076888252Smrg	LANG="$save_LANG"; export LANG
642176888252Smrg      fi
642276888252Smrg
642376888252Smrg      # Now prepare to actually exec the command.
642476888252Smrg      exec_cmd="\$cmd$args"
642576888252Smrg    else
642676888252Smrg      # Display what would be done.
642776888252Smrg      if test -n "$shlibpath_var"; then
642876888252Smrg	eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\""
642976888252Smrg	$echo "export $shlibpath_var"
643076888252Smrg      fi
643176888252Smrg      $echo "$cmd$args"
643276888252Smrg      exit $EXIT_SUCCESS
643376888252Smrg    fi
643476888252Smrg    ;;
643576888252Smrg
643676888252Smrg  # libtool clean and uninstall mode
643776888252Smrg  clean | uninstall)
643876888252Smrg    modename="$modename: $mode"
643976888252Smrg    rm="$nonopt"
644076888252Smrg    files=
644176888252Smrg    rmforce=
644276888252Smrg    exit_status=0
644376888252Smrg
644476888252Smrg    # This variable tells wrapper scripts just to set variables rather
644576888252Smrg    # than running their programs.
644676888252Smrg    libtool_install_magic="$magic"
644776888252Smrg
644876888252Smrg    for arg
644976888252Smrg    do
645076888252Smrg      case $arg in
645176888252Smrg      -f) rm="$rm $arg"; rmforce=yes ;;
645276888252Smrg      -*) rm="$rm $arg" ;;
645376888252Smrg      *) files="$files $arg" ;;
645476888252Smrg      esac
645576888252Smrg    done
645676888252Smrg
645776888252Smrg    if test -z "$rm"; then
645876888252Smrg      $echo "$modename: you must specify an RM program" 1>&2
645976888252Smrg      $echo "$help" 1>&2
646076888252Smrg      exit $EXIT_FAILURE
646176888252Smrg    fi
646276888252Smrg
646376888252Smrg    rmdirs=
646476888252Smrg
646576888252Smrg    origobjdir="$objdir"
646676888252Smrg    for file in $files; do
646776888252Smrg      dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
646876888252Smrg      if test "X$dir" = "X$file"; then
646976888252Smrg	dir=.
647076888252Smrg	objdir="$origobjdir"
647176888252Smrg      else
647276888252Smrg	objdir="$dir/$origobjdir"
647376888252Smrg      fi
647476888252Smrg      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
647576888252Smrg      test "$mode" = uninstall && objdir="$dir"
647676888252Smrg
647776888252Smrg      # Remember objdir for removal later, being careful to avoid duplicates
647876888252Smrg      if test "$mode" = clean; then
647976888252Smrg	case " $rmdirs " in
648076888252Smrg	  *" $objdir "*) ;;
648176888252Smrg	  *) rmdirs="$rmdirs $objdir" ;;
648276888252Smrg	esac
648376888252Smrg      fi
648476888252Smrg
648576888252Smrg      # Don't error if the file doesn't exist and rm -f was used.
648676888252Smrg      if (test -L "$file") >/dev/null 2>&1 \
648776888252Smrg	|| (test -h "$file") >/dev/null 2>&1 \
648876888252Smrg	|| test -f "$file"; then
648976888252Smrg	:
649076888252Smrg      elif test -d "$file"; then
649176888252Smrg	exit_status=1
649276888252Smrg	continue
649376888252Smrg      elif test "$rmforce" = yes; then
649476888252Smrg	continue
649576888252Smrg      fi
649676888252Smrg
649776888252Smrg      rmfiles="$file"
649876888252Smrg
649976888252Smrg      case $name in
650076888252Smrg      *.la)
650176888252Smrg	# Possibly a libtool archive, so verify it.
650276888252Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
650376888252Smrg	  . $dir/$name
650476888252Smrg
650576888252Smrg	  # Delete the libtool libraries and symlinks.
650676888252Smrg	  for n in $library_names; do
650776888252Smrg	    rmfiles="$rmfiles $objdir/$n"
650876888252Smrg	  done
650976888252Smrg	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
651076888252Smrg
651176888252Smrg	  case "$mode" in
651276888252Smrg	  clean)
651376888252Smrg	    case "  $library_names " in
651476888252Smrg	    # "  " in the beginning catches empty $dlname
651576888252Smrg	    *" $dlname "*) ;;
651676888252Smrg	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
651776888252Smrg	    esac
651876888252Smrg	     test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
651976888252Smrg	    ;;
652076888252Smrg	  uninstall)
652176888252Smrg	    if test -n "$library_names"; then
652276888252Smrg	      # Do each command in the postuninstall commands.
652376888252Smrg	      cmds=$postuninstall_cmds
652476888252Smrg	      save_ifs="$IFS"; IFS='~'
652576888252Smrg	      for cmd in $cmds; do
652676888252Smrg		IFS="$save_ifs"
652776888252Smrg		eval cmd=\"$cmd\"
652876888252Smrg		$show "$cmd"
652976888252Smrg		$run eval "$cmd"
653076888252Smrg		if test "$?" -ne 0 && test "$rmforce" != yes; then
653176888252Smrg		  exit_status=1
653276888252Smrg		fi
653376888252Smrg	      done
653476888252Smrg	      IFS="$save_ifs"
653576888252Smrg	    fi
653676888252Smrg
653776888252Smrg	    if test -n "$old_library"; then
653876888252Smrg	      # Do each command in the old_postuninstall commands.
653976888252Smrg	      cmds=$old_postuninstall_cmds
654076888252Smrg	      save_ifs="$IFS"; IFS='~'
654176888252Smrg	      for cmd in $cmds; do
654276888252Smrg		IFS="$save_ifs"
654376888252Smrg		eval cmd=\"$cmd\"
654476888252Smrg		$show "$cmd"
654576888252Smrg		$run eval "$cmd"
654676888252Smrg		if test "$?" -ne 0 && test "$rmforce" != yes; then
654776888252Smrg		  exit_status=1
654876888252Smrg		fi
654976888252Smrg	      done
655076888252Smrg	      IFS="$save_ifs"
655176888252Smrg	    fi
655276888252Smrg	    # FIXME: should reinstall the best remaining shared library.
655376888252Smrg	    ;;
655476888252Smrg	  esac
655576888252Smrg	fi
655676888252Smrg	;;
655776888252Smrg
655876888252Smrg      *.lo)
655976888252Smrg	# Possibly a libtool object, so verify it.
656076888252Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
656176888252Smrg
656276888252Smrg	  # Read the .lo file
656376888252Smrg	  . $dir/$name
656476888252Smrg
656576888252Smrg	  # Add PIC object to the list of files to remove.
656676888252Smrg	  if test -n "$pic_object" \
656776888252Smrg	     && test "$pic_object" != none; then
656876888252Smrg	    rmfiles="$rmfiles $dir/$pic_object"
656976888252Smrg	  fi
657076888252Smrg
657176888252Smrg	  # Add non-PIC object to the list of files to remove.
657276888252Smrg	  if test -n "$non_pic_object" \
657376888252Smrg	     && test "$non_pic_object" != none; then
657476888252Smrg	    rmfiles="$rmfiles $dir/$non_pic_object"
657576888252Smrg	  fi
657676888252Smrg	fi
657776888252Smrg	;;
657876888252Smrg
657976888252Smrg      *)
658076888252Smrg	if test "$mode" = clean ; then
658176888252Smrg	  noexename=$name
658276888252Smrg	  case $file in
658376888252Smrg	  *.exe)
658476888252Smrg	    file=`$echo $file|${SED} 's,.exe$,,'`
658576888252Smrg	    noexename=`$echo $name|${SED} 's,.exe$,,'`
658676888252Smrg	    # $file with .exe has already been added to rmfiles,
658776888252Smrg	    # add $file without .exe
658876888252Smrg	    rmfiles="$rmfiles $file"
658976888252Smrg	    ;;
659076888252Smrg	  esac
659176888252Smrg	  # Do a test to see if this is a libtool program.
659276888252Smrg	  if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
659376888252Smrg	    relink_command=
659476888252Smrg	    . $dir/$noexename
659576888252Smrg
659676888252Smrg	    # note $name still contains .exe if it was in $file originally
659776888252Smrg	    # as does the version of $file that was added into $rmfiles
659876888252Smrg	    rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
659976888252Smrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
660076888252Smrg	      rmfiles="$rmfiles $objdir/lt-$name"
660176888252Smrg	    fi
660276888252Smrg	    if test "X$noexename" != "X$name" ; then
660376888252Smrg	      rmfiles="$rmfiles $objdir/lt-${noexename}.c"
660476888252Smrg	    fi
660576888252Smrg	  fi
660676888252Smrg	fi
660776888252Smrg	;;
660876888252Smrg      esac
660976888252Smrg      $show "$rm $rmfiles"
661076888252Smrg      $run $rm $rmfiles || exit_status=1
661176888252Smrg    done
661276888252Smrg    objdir="$origobjdir"
661376888252Smrg
661476888252Smrg    # Try to remove the ${objdir}s in the directories where we deleted files
661576888252Smrg    for dir in $rmdirs; do
661676888252Smrg      if test -d "$dir"; then
661776888252Smrg	$show "rmdir $dir"
661876888252Smrg	$run rmdir $dir >/dev/null 2>&1
661976888252Smrg      fi
662076888252Smrg    done
662176888252Smrg
662276888252Smrg    exit $exit_status
662376888252Smrg    ;;
662476888252Smrg
662576888252Smrg  "")
662676888252Smrg    $echo "$modename: you must specify a MODE" 1>&2
662776888252Smrg    $echo "$generic_help" 1>&2
662876888252Smrg    exit $EXIT_FAILURE
662976888252Smrg    ;;
663076888252Smrg  esac
663176888252Smrg
663276888252Smrg  if test -z "$exec_cmd"; then
663376888252Smrg    $echo "$modename: invalid operation mode \`$mode'" 1>&2
663476888252Smrg    $echo "$generic_help" 1>&2
663576888252Smrg    exit $EXIT_FAILURE
663676888252Smrg  fi
663776888252Smrgfi # test -z "$show_help"
663876888252Smrg
663976888252Smrgif test -n "$exec_cmd"; then
664076888252Smrg  eval exec $exec_cmd
664176888252Smrg  exit $EXIT_FAILURE
664276888252Smrgfi
664376888252Smrg
664476888252Smrg# We need to display help for each of the modes.
664576888252Smrgcase $mode in
664676888252Smrg"") $echo \
664776888252Smrg"Usage: $modename [OPTION]... [MODE-ARG]...
664876888252Smrg
664976888252SmrgProvide generalized library-building support services.
665076888252Smrg
665176888252Smrg    --config          show all configuration variables
665276888252Smrg    --debug           enable verbose shell tracing
665376888252Smrg-n, --dry-run         display commands without modifying any files
665476888252Smrg    --features        display basic configuration information and exit
665576888252Smrg    --finish          same as \`--mode=finish'
665676888252Smrg    --help            display this help message and exit
665776888252Smrg    --mode=MODE       use operation mode MODE [default=inferred from MODE-ARGS]
665876888252Smrg    --quiet           same as \`--silent'
665976888252Smrg    --silent          don't print informational messages
666076888252Smrg    --tag=TAG         use configuration variables from tag TAG
666176888252Smrg    --version         print version information
666276888252Smrg
666376888252SmrgMODE must be one of the following:
666476888252Smrg
666576888252Smrg      clean           remove files from the build directory
666676888252Smrg      compile         compile a source file into a libtool object
666776888252Smrg      execute         automatically set library path, then run a program
666876888252Smrg      finish          complete the installation of libtool libraries
666976888252Smrg      install         install libraries or executables
667076888252Smrg      link            create a library or an executable
667176888252Smrg      uninstall       remove libraries from an installed directory
667276888252Smrg
667376888252SmrgMODE-ARGS vary depending on the MODE.  Try \`$modename --help --mode=MODE' for
667476888252Smrga more detailed description of MODE.
667576888252Smrg
667676888252SmrgReport bugs to <bug-libtool@gnu.org>."
667776888252Smrg  exit $EXIT_SUCCESS
667876888252Smrg  ;;
667976888252Smrg
668076888252Smrgclean)
668176888252Smrg  $echo \
668276888252Smrg"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
668376888252Smrg
668476888252SmrgRemove files from the build directory.
668576888252Smrg
668676888252SmrgRM is the name of the program to use to delete files associated with each FILE
668776888252Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
668876888252Smrgto RM.
668976888252Smrg
669076888252SmrgIf FILE is a libtool library, object or program, all the files associated
669176888252Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
669276888252Smrg  ;;
669376888252Smrg
669476888252Smrgcompile)
669576888252Smrg  $echo \
669676888252Smrg"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
669776888252Smrg
669876888252SmrgCompile a source file into a libtool library object.
669976888252Smrg
670076888252SmrgThis mode accepts the following additional options:
670176888252Smrg
670276888252Smrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
670376888252Smrg  -prefer-pic       try to building PIC objects only
670476888252Smrg  -prefer-non-pic   try to building non-PIC objects only
670576888252Smrg  -static           always build a \`.o' file suitable for static linking
670676888252Smrg
670776888252SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
670876888252Smrgfrom the given SOURCEFILE.
670976888252Smrg
671076888252SmrgThe output file name is determined by removing the directory component from
671176888252SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
671276888252Smrglibrary object suffix, \`.lo'."
671376888252Smrg  ;;
671476888252Smrg
671576888252Smrgexecute)
671676888252Smrg  $echo \
671776888252Smrg"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]...
671876888252Smrg
671976888252SmrgAutomatically set library path, then run a program.
672076888252Smrg
672176888252SmrgThis mode accepts the following additional options:
672276888252Smrg
672376888252Smrg  -dlopen FILE      add the directory containing FILE to the library path
672476888252Smrg
672576888252SmrgThis mode sets the library path environment variable according to \`-dlopen'
672676888252Smrgflags.
672776888252Smrg
672876888252SmrgIf any of the ARGS are libtool executable wrappers, then they are translated
672976888252Smrginto their corresponding uninstalled binary, and any of their required library
673076888252Smrgdirectories are added to the library path.
673176888252Smrg
673276888252SmrgThen, COMMAND is executed, with ARGS as arguments."
673376888252Smrg  ;;
673476888252Smrg
673576888252Smrgfinish)
673676888252Smrg  $echo \
673776888252Smrg"Usage: $modename [OPTION]... --mode=finish [LIBDIR]...
673876888252Smrg
673976888252SmrgComplete the installation of libtool libraries.
674076888252Smrg
674176888252SmrgEach LIBDIR is a directory that contains libtool libraries.
674276888252Smrg
674376888252SmrgThe commands that this mode executes may require superuser privileges.  Use
674476888252Smrgthe \`--dry-run' option if you just want to see what would be executed."
674576888252Smrg  ;;
674676888252Smrg
674776888252Smrginstall)
674876888252Smrg  $echo \
674976888252Smrg"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND...
675076888252Smrg
675176888252SmrgInstall executables or libraries.
675276888252Smrg
675376888252SmrgINSTALL-COMMAND is the installation command.  The first component should be
675476888252Smrgeither the \`install' or \`cp' program.
675576888252Smrg
675676888252SmrgThe rest of the components are interpreted as arguments to that command (only
675776888252SmrgBSD-compatible install options are recognized)."
675876888252Smrg  ;;
675976888252Smrg
676076888252Smrglink)
676176888252Smrg  $echo \
676276888252Smrg"Usage: $modename [OPTION]... --mode=link LINK-COMMAND...
676376888252Smrg
676476888252SmrgLink object files or libraries together to form another library, or to
676576888252Smrgcreate an executable program.
676676888252Smrg
676776888252SmrgLINK-COMMAND is a command using the C compiler that you would use to create
676876888252Smrga program from several object files.
676976888252Smrg
677076888252SmrgThe following components of LINK-COMMAND are treated specially:
677176888252Smrg
677276888252Smrg  -all-static       do not do any dynamic linking at all
677376888252Smrg  -avoid-version    do not add a version suffix if possible
677476888252Smrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
677576888252Smrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
677676888252Smrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
677776888252Smrg  -export-symbols SYMFILE
677876888252Smrg		    try to export only the symbols listed in SYMFILE
677976888252Smrg  -export-symbols-regex REGEX
678076888252Smrg		    try to export only the symbols matching REGEX
678176888252Smrg  -LLIBDIR          search LIBDIR for required installed libraries
678276888252Smrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
678376888252Smrg  -module           build a library that can dlopened
678476888252Smrg  -no-fast-install  disable the fast-install mode
678576888252Smrg  -no-install       link a not-installable executable
678676888252Smrg  -no-undefined     declare that a library does not refer to external symbols
678776888252Smrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
678876888252Smrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
678976888252Smrg  -precious-files-regex REGEX
679076888252Smrg                    don't remove output files matching REGEX
679176888252Smrg  -release RELEASE  specify package release information
679276888252Smrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
679376888252Smrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
679476888252Smrg  -static           do not do any dynamic linking of libtool libraries
679576888252Smrg  -version-info CURRENT[:REVISION[:AGE]]
679676888252Smrg		    specify library version info [each variable defaults to 0]
679776888252Smrg
679876888252SmrgAll other options (arguments beginning with \`-') are ignored.
679976888252Smrg
680076888252SmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
680176888252Smrgtreated as uninstalled libtool libraries, other files are standard or library
680276888252Smrgobject files.
680376888252Smrg
680476888252SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
680576888252Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
680676888252Smrgrequired, except when creating a convenience library.
680776888252Smrg
680876888252SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
680976888252Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
681076888252Smrg
681176888252SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
681276888252Smrgis created, otherwise an executable program is created."
681376888252Smrg  ;;
681476888252Smrg
681576888252Smrguninstall)
681676888252Smrg  $echo \
681776888252Smrg"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
681876888252Smrg
681976888252SmrgRemove libraries from an installation directory.
682076888252Smrg
682176888252SmrgRM is the name of the program to use to delete files associated with each FILE
682276888252Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
682376888252Smrgto RM.
682476888252Smrg
682576888252SmrgIf FILE is a libtool library, all the files associated with it are deleted.
682676888252SmrgOtherwise, only FILE itself is deleted using RM."
682776888252Smrg  ;;
682876888252Smrg
682976888252Smrg*)
683076888252Smrg  $echo "$modename: invalid operation mode \`$mode'" 1>&2
683176888252Smrg  $echo "$help" 1>&2
683276888252Smrg  exit $EXIT_FAILURE
683376888252Smrg  ;;
683476888252Smrgesac
683576888252Smrg
683676888252Smrg$echo
683776888252Smrg$echo "Try \`$modename --help' for more information about other modes."
683876888252Smrg
683976888252Smrgexit $?
684076888252Smrg
684176888252Smrg# The TAGs below are defined such that we never get into a situation
684276888252Smrg# in which we disable both kinds of libraries.  Given conflicting
684376888252Smrg# choices, we go for a static library, that is the most portable,
684476888252Smrg# since we can't tell whether shared libraries were disabled because
684576888252Smrg# the user asked for that or because the platform doesn't support
684676888252Smrg# them.  This is particularly important on AIX, because we don't
684776888252Smrg# support having both static and shared libraries enabled at the same
684876888252Smrg# time on that platform, so we default to a shared-only configuration.
684976888252Smrg# If a disable-shared tag is given, we'll fallback to a static-only
685076888252Smrg# configuration.  But we'll never go from static-only to shared-only.
685176888252Smrg
685276888252Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
685376888252Smrgdisable_libs=shared
685476888252Smrg# ### END LIBTOOL TAG CONFIG: disable-shared
685576888252Smrg
685676888252Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
685776888252Smrgdisable_libs=static
685876888252Smrg# ### END LIBTOOL TAG CONFIG: disable-static
685976888252Smrg
686076888252Smrg# Local Variables:
686176888252Smrg# mode:shell-script
686276888252Smrg# sh-indentation:2
686376888252Smrg# End:
6864