ltmain.sh revision 17a48c7c
117a48c7cSmrg# ltmain.sh - Provide generalized library-building support services.
217a48c7cSmrg# NOTE: Changing this file will not affect anything until you rerun configure.
317a48c7cSmrg#
417a48c7cSmrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005
517a48c7cSmrg# Free Software Foundation, Inc.
617a48c7cSmrg# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
717a48c7cSmrg#
817a48c7cSmrg# This program is free software; you can redistribute it and/or modify
917a48c7cSmrg# it under the terms of the GNU General Public License as published by
1017a48c7cSmrg# the Free Software Foundation; either version 2 of the License, or
1117a48c7cSmrg# (at your option) any later version.
1217a48c7cSmrg#
1317a48c7cSmrg# This program is distributed in the hope that it will be useful, but
1417a48c7cSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
1517a48c7cSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1617a48c7cSmrg# General Public License for more details.
1717a48c7cSmrg#
1817a48c7cSmrg# You should have received a copy of the GNU General Public License
1917a48c7cSmrg# along with this program; if not, write to the Free Software
2017a48c7cSmrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2117a48c7cSmrg#
2217a48c7cSmrg# As a special exception to the GNU General Public License, if you
2317a48c7cSmrg# distribute this file as part of a program that contains a
2417a48c7cSmrg# configuration script generated by Autoconf, you may include it under
2517a48c7cSmrg# the same distribution terms that you use for the rest of that program.
2617a48c7cSmrg
2717a48c7cSmrgbasename="s,^.*/,,g"
2817a48c7cSmrg
2917a48c7cSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
3017a48c7cSmrg# is ksh but when the shell is invoked as "sh" and the current value of
3117a48c7cSmrg# the _XPG environment variable is not equal to 1 (one), the special
3217a48c7cSmrg# positional parameter $0, within a function call, is the name of the
3317a48c7cSmrg# function.
3417a48c7cSmrgprogpath="$0"
3517a48c7cSmrg
3617a48c7cSmrg# The name of this program:
3717a48c7cSmrgprogname=`echo "$progpath" | $SED $basename`
3817a48c7cSmrgmodename="$progname"
3917a48c7cSmrg
4017a48c7cSmrg# Global variables:
4117a48c7cSmrgEXIT_SUCCESS=0
4217a48c7cSmrgEXIT_FAILURE=1
4317a48c7cSmrg
4417a48c7cSmrgPROGRAM=ltmain.sh
4517a48c7cSmrgPACKAGE=libtool
4617a48c7cSmrgVERSION=1.5.22
4717a48c7cSmrgTIMESTAMP=" (1.1220.2.365 2005/12/18 22:14:06)"
4817a48c7cSmrg
4917a48c7cSmrg# See if we are running on zsh, and set the options which allow our
5017a48c7cSmrg# commands through without removal of \ escapes.
5117a48c7cSmrgif test -n "${ZSH_VERSION+set}" ; then
5217a48c7cSmrg  setopt NO_GLOB_SUBST
5317a48c7cSmrgfi
5417a48c7cSmrg
5517a48c7cSmrg# Check that we have a working $echo.
5617a48c7cSmrgif test "X$1" = X--no-reexec; then
5717a48c7cSmrg  # Discard the --no-reexec flag, and continue.
5817a48c7cSmrg  shift
5917a48c7cSmrgelif test "X$1" = X--fallback-echo; then
6017a48c7cSmrg  # Avoid inline document here, it may be left over
6117a48c7cSmrg  :
6217a48c7cSmrgelif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
6317a48c7cSmrg  # Yippee, $echo works!
6417a48c7cSmrg  :
6517a48c7cSmrgelse
6617a48c7cSmrg  # Restart under the correct shell, and then maybe $echo will work.
6717a48c7cSmrg  exec $SHELL "$progpath" --no-reexec ${1+"$@"}
6817a48c7cSmrgfi
6917a48c7cSmrg
7017a48c7cSmrgif test "X$1" = X--fallback-echo; then
7117a48c7cSmrg  # used as fallback echo
7217a48c7cSmrg  shift
7317a48c7cSmrg  cat <<EOF
7417a48c7cSmrg$*
7517a48c7cSmrgEOF
7617a48c7cSmrg  exit $EXIT_SUCCESS
7717a48c7cSmrgfi
7817a48c7cSmrg
7917a48c7cSmrgdefault_mode=
8017a48c7cSmrghelp="Try \`$progname --help' for more information."
8117a48c7cSmrgmagic="%%%MAGIC variable%%%"
8217a48c7cSmrgmkdir="mkdir"
8317a48c7cSmrgmv="mv -f"
8417a48c7cSmrgrm="rm -f"
8517a48c7cSmrg
8617a48c7cSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
8717a48c7cSmrg# metacharacters that are still active within double-quoted strings.
8817a48c7cSmrgXsed="${SED}"' -e 1s/^X//'
8917a48c7cSmrgsed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
9017a48c7cSmrg# test EBCDIC or ASCII
9117a48c7cSmrgcase `echo X|tr X '\101'` in
9217a48c7cSmrg A) # ASCII based system
9317a48c7cSmrg    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
9417a48c7cSmrg  SP2NL='tr \040 \012'
9517a48c7cSmrg  NL2SP='tr \015\012 \040\040'
9617a48c7cSmrg  ;;
9717a48c7cSmrg *) # EBCDIC based system
9817a48c7cSmrg  SP2NL='tr \100 \n'
9917a48c7cSmrg  NL2SP='tr \r\n \100\100'
10017a48c7cSmrg  ;;
10117a48c7cSmrgesac
10217a48c7cSmrg
10317a48c7cSmrg# NLS nuisances.
10417a48c7cSmrg# Only set LANG and LC_ALL to C if already set.
10517a48c7cSmrg# These must not be set unconditionally because not all systems understand
10617a48c7cSmrg# e.g. LANG=C (notably SCO).
10717a48c7cSmrg# We save the old values to restore during execute mode.
10817a48c7cSmrgif test "${LC_ALL+set}" = set; then
10917a48c7cSmrg  save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
11017a48c7cSmrgfi
11117a48c7cSmrgif test "${LANG+set}" = set; then
11217a48c7cSmrg  save_LANG="$LANG"; LANG=C; export LANG
11317a48c7cSmrgfi
11417a48c7cSmrg
11517a48c7cSmrg# Make sure IFS has a sensible default
11617a48c7cSmrglt_nl='
11717a48c7cSmrg'
11817a48c7cSmrgIFS=" 	$lt_nl"
11917a48c7cSmrg
12017a48c7cSmrgif test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
12117a48c7cSmrg  $echo "$modename: not configured to build any kind of library" 1>&2
12217a48c7cSmrg  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
12317a48c7cSmrg  exit $EXIT_FAILURE
12417a48c7cSmrgfi
12517a48c7cSmrg
12617a48c7cSmrg# Global variables.
12717a48c7cSmrgmode=$default_mode
12817a48c7cSmrgnonopt=
12917a48c7cSmrgprev=
13017a48c7cSmrgprevopt=
13117a48c7cSmrgrun=
13217a48c7cSmrgshow="$echo"
13317a48c7cSmrgshow_help=
13417a48c7cSmrgexecute_dlfiles=
13517a48c7cSmrgduplicate_deps=no
13617a48c7cSmrgpreserve_args=
13717a48c7cSmrglo2o="s/\\.lo\$/.${objext}/"
13817a48c7cSmrgo2lo="s/\\.${objext}\$/.lo/"
13917a48c7cSmrg
14017a48c7cSmrg#####################################
14117a48c7cSmrg# Shell function definitions:
14217a48c7cSmrg# This seems to be the best place for them
14317a48c7cSmrg
14417a48c7cSmrg# func_mktempdir [string]
14517a48c7cSmrg# Make a temporary directory that won't clash with other running
14617a48c7cSmrg# libtool processes, and avoids race conditions if possible.  If
14717a48c7cSmrg# given, STRING is the basename for that directory.
14817a48c7cSmrgfunc_mktempdir ()
14917a48c7cSmrg{
15017a48c7cSmrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
15117a48c7cSmrg
15217a48c7cSmrg    if test "$run" = ":"; then
15317a48c7cSmrg      # Return a directory name, but don't create it in dry-run mode
15417a48c7cSmrg      my_tmpdir="${my_template}-$$"
15517a48c7cSmrg    else
15617a48c7cSmrg
15717a48c7cSmrg      # If mktemp works, use that first and foremost
15817a48c7cSmrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
15917a48c7cSmrg
16017a48c7cSmrg      if test ! -d "$my_tmpdir"; then
16117a48c7cSmrg	# Failing that, at least try and use $RANDOM to avoid a race
16217a48c7cSmrg	my_tmpdir="${my_template}-${RANDOM-0}$$"
16317a48c7cSmrg
16417a48c7cSmrg	save_mktempdir_umask=`umask`
16517a48c7cSmrg	umask 0077
16617a48c7cSmrg	$mkdir "$my_tmpdir"
16717a48c7cSmrg	umask $save_mktempdir_umask
16817a48c7cSmrg      fi
16917a48c7cSmrg
17017a48c7cSmrg      # If we're not in dry-run mode, bomb out on failure
17117a48c7cSmrg      test -d "$my_tmpdir" || {
17217a48c7cSmrg        $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
17317a48c7cSmrg	exit $EXIT_FAILURE
17417a48c7cSmrg      }
17517a48c7cSmrg    fi
17617a48c7cSmrg
17717a48c7cSmrg    $echo "X$my_tmpdir" | $Xsed
17817a48c7cSmrg}
17917a48c7cSmrg
18017a48c7cSmrg
18117a48c7cSmrg# func_win32_libid arg
18217a48c7cSmrg# return the library type of file 'arg'
18317a48c7cSmrg#
18417a48c7cSmrg# Need a lot of goo to handle *both* DLLs and import libs
18517a48c7cSmrg# Has to be a shell function in order to 'eat' the argument
18617a48c7cSmrg# that is supplied when $file_magic_command is called.
18717a48c7cSmrgfunc_win32_libid ()
18817a48c7cSmrg{
18917a48c7cSmrg  win32_libid_type="unknown"
19017a48c7cSmrg  win32_fileres=`file -L $1 2>/dev/null`
19117a48c7cSmrg  case $win32_fileres in
19217a48c7cSmrg  *ar\ archive\ import\ library*) # definitely import
19317a48c7cSmrg    win32_libid_type="x86 archive import"
19417a48c7cSmrg    ;;
19517a48c7cSmrg  *ar\ archive*) # could be an import, or static
19617a48c7cSmrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
19717a48c7cSmrg      $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
19817a48c7cSmrg      win32_nmres=`eval $NM -f posix -A $1 | \
19917a48c7cSmrg	$SED -n -e '1,100{/ I /{s,.*,import,;p;q;};}'`
20017a48c7cSmrg      case $win32_nmres in
20117a48c7cSmrg      import*)  win32_libid_type="x86 archive import";;
20217a48c7cSmrg      *)        win32_libid_type="x86 archive static";;
20317a48c7cSmrg      esac
20417a48c7cSmrg    fi
20517a48c7cSmrg    ;;
20617a48c7cSmrg  *DLL*)
20717a48c7cSmrg    win32_libid_type="x86 DLL"
20817a48c7cSmrg    ;;
20917a48c7cSmrg  *executable*) # but shell scripts are "executable" too...
21017a48c7cSmrg    case $win32_fileres in
21117a48c7cSmrg    *MS\ Windows\ PE\ Intel*)
21217a48c7cSmrg      win32_libid_type="x86 DLL"
21317a48c7cSmrg      ;;
21417a48c7cSmrg    esac
21517a48c7cSmrg    ;;
21617a48c7cSmrg  esac
21717a48c7cSmrg  $echo $win32_libid_type
21817a48c7cSmrg}
21917a48c7cSmrg
22017a48c7cSmrg
22117a48c7cSmrg# func_infer_tag arg
22217a48c7cSmrg# Infer tagged configuration to use if any are available and
22317a48c7cSmrg# if one wasn't chosen via the "--tag" command line option.
22417a48c7cSmrg# Only attempt this if the compiler in the base compile
22517a48c7cSmrg# command doesn't match the default compiler.
22617a48c7cSmrg# arg is usually of the form 'gcc ...'
22717a48c7cSmrgfunc_infer_tag ()
22817a48c7cSmrg{
22917a48c7cSmrg    if test -n "$available_tags" && test -z "$tagname"; then
23017a48c7cSmrg      CC_quoted=
23117a48c7cSmrg      for arg in $CC; do
23217a48c7cSmrg	case $arg in
23317a48c7cSmrg	  *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
23417a48c7cSmrg	  arg="\"$arg\""
23517a48c7cSmrg	  ;;
23617a48c7cSmrg	esac
23717a48c7cSmrg	CC_quoted="$CC_quoted $arg"
23817a48c7cSmrg      done
23917a48c7cSmrg      case $@ in
24017a48c7cSmrg      # Blanks in the command may have been stripped by the calling shell,
24117a48c7cSmrg      # but not from the CC environment variable when configure was run.
24217a48c7cSmrg      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
24317a48c7cSmrg      # Blanks at the start of $base_compile will cause this to fail
24417a48c7cSmrg      # if we don't check for them as well.
24517a48c7cSmrg      *)
24617a48c7cSmrg	for z in $available_tags; do
24717a48c7cSmrg	  if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
24817a48c7cSmrg	    # Evaluate the configuration.
24917a48c7cSmrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
25017a48c7cSmrg	    CC_quoted=
25117a48c7cSmrg	    for arg in $CC; do
25217a48c7cSmrg	    # Double-quote args containing other shell metacharacters.
25317a48c7cSmrg	    case $arg in
25417a48c7cSmrg	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
25517a48c7cSmrg	      arg="\"$arg\""
25617a48c7cSmrg	      ;;
25717a48c7cSmrg	    esac
25817a48c7cSmrg	    CC_quoted="$CC_quoted $arg"
25917a48c7cSmrg	  done
26017a48c7cSmrg	    case "$@ " in
26117a48c7cSmrg	      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
26217a48c7cSmrg	      # The compiler in the base compile command matches
26317a48c7cSmrg	      # the one in the tagged configuration.
26417a48c7cSmrg	      # Assume this is the tagged configuration we want.
26517a48c7cSmrg	      tagname=$z
26617a48c7cSmrg	      break
26717a48c7cSmrg	      ;;
26817a48c7cSmrg	    esac
26917a48c7cSmrg	  fi
27017a48c7cSmrg	done
27117a48c7cSmrg	# If $tagname still isn't set, then no tagged configuration
27217a48c7cSmrg	# was found and let the user know that the "--tag" command
27317a48c7cSmrg	# line option must be used.
27417a48c7cSmrg	if test -z "$tagname"; then
27517a48c7cSmrg	  $echo "$modename: unable to infer tagged configuration"
27617a48c7cSmrg	  $echo "$modename: specify a tag with \`--tag'" 1>&2
27717a48c7cSmrg	  exit $EXIT_FAILURE
27817a48c7cSmrg#        else
27917a48c7cSmrg#          $echo "$modename: using $tagname tagged configuration"
28017a48c7cSmrg	fi
28117a48c7cSmrg	;;
28217a48c7cSmrg      esac
28317a48c7cSmrg    fi
28417a48c7cSmrg}
28517a48c7cSmrg
28617a48c7cSmrg
28717a48c7cSmrg# func_extract_an_archive dir oldlib
28817a48c7cSmrgfunc_extract_an_archive ()
28917a48c7cSmrg{
29017a48c7cSmrg    f_ex_an_ar_dir="$1"; shift
29117a48c7cSmrg    f_ex_an_ar_oldlib="$1"
29217a48c7cSmrg
29317a48c7cSmrg    $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
29417a48c7cSmrg    $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
29517a48c7cSmrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
29617a48c7cSmrg     :
29717a48c7cSmrg    else
29817a48c7cSmrg      $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2
29917a48c7cSmrg      exit $EXIT_FAILURE
30017a48c7cSmrg    fi
30117a48c7cSmrg}
30217a48c7cSmrg
30317a48c7cSmrg# func_extract_archives gentop oldlib ...
30417a48c7cSmrgfunc_extract_archives ()
30517a48c7cSmrg{
30617a48c7cSmrg    my_gentop="$1"; shift
30717a48c7cSmrg    my_oldlibs=${1+"$@"}
30817a48c7cSmrg    my_oldobjs=""
30917a48c7cSmrg    my_xlib=""
31017a48c7cSmrg    my_xabs=""
31117a48c7cSmrg    my_xdir=""
31217a48c7cSmrg    my_status=""
31317a48c7cSmrg
31417a48c7cSmrg    $show "${rm}r $my_gentop"
31517a48c7cSmrg    $run ${rm}r "$my_gentop"
31617a48c7cSmrg    $show "$mkdir $my_gentop"
31717a48c7cSmrg    $run $mkdir "$my_gentop"
31817a48c7cSmrg    my_status=$?
31917a48c7cSmrg    if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
32017a48c7cSmrg      exit $my_status
32117a48c7cSmrg    fi
32217a48c7cSmrg
32317a48c7cSmrg    for my_xlib in $my_oldlibs; do
32417a48c7cSmrg      # Extract the objects.
32517a48c7cSmrg      case $my_xlib in
32617a48c7cSmrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
32717a48c7cSmrg	*) my_xabs=`pwd`"/$my_xlib" ;;
32817a48c7cSmrg      esac
32917a48c7cSmrg      my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
33017a48c7cSmrg      my_xdir="$my_gentop/$my_xlib"
33117a48c7cSmrg
33217a48c7cSmrg      $show "${rm}r $my_xdir"
33317a48c7cSmrg      $run ${rm}r "$my_xdir"
33417a48c7cSmrg      $show "$mkdir $my_xdir"
33517a48c7cSmrg      $run $mkdir "$my_xdir"
33617a48c7cSmrg      exit_status=$?
33717a48c7cSmrg      if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then
33817a48c7cSmrg	exit $exit_status
33917a48c7cSmrg      fi
34017a48c7cSmrg      case $host in
34117a48c7cSmrg      *-darwin*)
34217a48c7cSmrg	$show "Extracting $my_xabs"
34317a48c7cSmrg	# Do not bother doing anything if just a dry run
34417a48c7cSmrg	if test -z "$run"; then
34517a48c7cSmrg	  darwin_orig_dir=`pwd`
34617a48c7cSmrg	  cd $my_xdir || exit $?
34717a48c7cSmrg	  darwin_archive=$my_xabs
34817a48c7cSmrg	  darwin_curdir=`pwd`
34917a48c7cSmrg	  darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'`
35017a48c7cSmrg	  darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
35117a48c7cSmrg	  if test -n "$darwin_arches"; then 
35217a48c7cSmrg	    darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
35317a48c7cSmrg	    darwin_arch=
35417a48c7cSmrg	    $show "$darwin_base_archive has multiple architectures $darwin_arches"
35517a48c7cSmrg	    for darwin_arch in  $darwin_arches ; do
35617a48c7cSmrg	      mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
35717a48c7cSmrg	      lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
35817a48c7cSmrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
35917a48c7cSmrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
36017a48c7cSmrg	      cd "$darwin_curdir"
36117a48c7cSmrg	      $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
36217a48c7cSmrg	    done # $darwin_arches
36317a48c7cSmrg      ## Okay now we have a bunch of thin objects, gotta fatten them up :)
36417a48c7cSmrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP`
36517a48c7cSmrg	    darwin_file=
36617a48c7cSmrg	    darwin_files=
36717a48c7cSmrg	    for darwin_file in $darwin_filelist; do
36817a48c7cSmrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
36917a48c7cSmrg	      lipo -create -output "$darwin_file" $darwin_files
37017a48c7cSmrg	    done # $darwin_filelist
37117a48c7cSmrg	    ${rm}r unfat-$$
37217a48c7cSmrg	    cd "$darwin_orig_dir"
37317a48c7cSmrg	  else
37417a48c7cSmrg	    cd "$darwin_orig_dir"
37517a48c7cSmrg 	    func_extract_an_archive "$my_xdir" "$my_xabs"
37617a48c7cSmrg	  fi # $darwin_arches
37717a48c7cSmrg	fi # $run
37817a48c7cSmrg	;;
37917a48c7cSmrg      *)
38017a48c7cSmrg        func_extract_an_archive "$my_xdir" "$my_xabs"
38117a48c7cSmrg        ;;
38217a48c7cSmrg      esac
38317a48c7cSmrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
38417a48c7cSmrg    done
38517a48c7cSmrg    func_extract_archives_result="$my_oldobjs"
38617a48c7cSmrg}
38717a48c7cSmrg# End of Shell function definitions
38817a48c7cSmrg#####################################
38917a48c7cSmrg
39017a48c7cSmrg# Darwin sucks
39117a48c7cSmrgeval std_shrext=\"$shrext_cmds\"
39217a48c7cSmrg
39317a48c7cSmrgdisable_libs=no
39417a48c7cSmrg
39517a48c7cSmrg# Parse our command line options once, thoroughly.
39617a48c7cSmrgwhile test "$#" -gt 0
39717a48c7cSmrgdo
39817a48c7cSmrg  arg="$1"
39917a48c7cSmrg  shift
40017a48c7cSmrg
40117a48c7cSmrg  case $arg in
40217a48c7cSmrg  -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
40317a48c7cSmrg  *) optarg= ;;
40417a48c7cSmrg  esac
40517a48c7cSmrg
40617a48c7cSmrg  # If the previous option needs an argument, assign it.
40717a48c7cSmrg  if test -n "$prev"; then
40817a48c7cSmrg    case $prev in
40917a48c7cSmrg    execute_dlfiles)
41017a48c7cSmrg      execute_dlfiles="$execute_dlfiles $arg"
41117a48c7cSmrg      ;;
41217a48c7cSmrg    tag)
41317a48c7cSmrg      tagname="$arg"
41417a48c7cSmrg      preserve_args="${preserve_args}=$arg"
41517a48c7cSmrg
41617a48c7cSmrg      # Check whether tagname contains only valid characters
41717a48c7cSmrg      case $tagname in
41817a48c7cSmrg      *[!-_A-Za-z0-9,/]*)
41917a48c7cSmrg	$echo "$progname: invalid tag name: $tagname" 1>&2
42017a48c7cSmrg	exit $EXIT_FAILURE
42117a48c7cSmrg	;;
42217a48c7cSmrg      esac
42317a48c7cSmrg
42417a48c7cSmrg      case $tagname in
42517a48c7cSmrg      CC)
42617a48c7cSmrg	# Don't test for the "default" C tag, as we know, it's there, but
42717a48c7cSmrg	# not specially marked.
42817a48c7cSmrg	;;
42917a48c7cSmrg      *)
43017a48c7cSmrg	if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then
43117a48c7cSmrg	  taglist="$taglist $tagname"
43217a48c7cSmrg	  # Evaluate the configuration.
43317a48c7cSmrg	  eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`"
43417a48c7cSmrg	else
43517a48c7cSmrg	  $echo "$progname: ignoring unknown tag $tagname" 1>&2
43617a48c7cSmrg	fi
43717a48c7cSmrg	;;
43817a48c7cSmrg      esac
43917a48c7cSmrg      ;;
44017a48c7cSmrg    *)
44117a48c7cSmrg      eval "$prev=\$arg"
44217a48c7cSmrg      ;;
44317a48c7cSmrg    esac
44417a48c7cSmrg
44517a48c7cSmrg    prev=
44617a48c7cSmrg    prevopt=
44717a48c7cSmrg    continue
44817a48c7cSmrg  fi
44917a48c7cSmrg
45017a48c7cSmrg  # Have we seen a non-optional argument yet?
45117a48c7cSmrg  case $arg in
45217a48c7cSmrg  --help)
45317a48c7cSmrg    show_help=yes
45417a48c7cSmrg    ;;
45517a48c7cSmrg
45617a48c7cSmrg  --version)
45717a48c7cSmrg    $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
45817a48c7cSmrg    $echo
45917a48c7cSmrg    $echo "Copyright (C) 2005  Free Software Foundation, Inc."
46017a48c7cSmrg    $echo "This is free software; see the source for copying conditions.  There is NO"
46117a48c7cSmrg    $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
46217a48c7cSmrg    exit $?
46317a48c7cSmrg    ;;
46417a48c7cSmrg
46517a48c7cSmrg  --config)
46617a48c7cSmrg    ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath
46717a48c7cSmrg    # Now print the configurations for the tags.
46817a48c7cSmrg    for tagname in $taglist; do
46917a48c7cSmrg      ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
47017a48c7cSmrg    done
47117a48c7cSmrg    exit $?
47217a48c7cSmrg    ;;
47317a48c7cSmrg
47417a48c7cSmrg  --debug)
47517a48c7cSmrg    $echo "$progname: enabling shell trace mode"
47617a48c7cSmrg    set -x
47717a48c7cSmrg    preserve_args="$preserve_args $arg"
47817a48c7cSmrg    ;;
47917a48c7cSmrg
48017a48c7cSmrg  --dry-run | -n)
48117a48c7cSmrg    run=:
48217a48c7cSmrg    ;;
48317a48c7cSmrg
48417a48c7cSmrg  --features)
48517a48c7cSmrg    $echo "host: $host"
48617a48c7cSmrg    if test "$build_libtool_libs" = yes; then
48717a48c7cSmrg      $echo "enable shared libraries"
48817a48c7cSmrg    else
48917a48c7cSmrg      $echo "disable shared libraries"
49017a48c7cSmrg    fi
49117a48c7cSmrg    if test "$build_old_libs" = yes; then
49217a48c7cSmrg      $echo "enable static libraries"
49317a48c7cSmrg    else
49417a48c7cSmrg      $echo "disable static libraries"
49517a48c7cSmrg    fi
49617a48c7cSmrg    exit $?
49717a48c7cSmrg    ;;
49817a48c7cSmrg
49917a48c7cSmrg  --finish) mode="finish" ;;
50017a48c7cSmrg
50117a48c7cSmrg  --mode) prevopt="--mode" prev=mode ;;
50217a48c7cSmrg  --mode=*) mode="$optarg" ;;
50317a48c7cSmrg
50417a48c7cSmrg  --preserve-dup-deps) duplicate_deps="yes" ;;
50517a48c7cSmrg
50617a48c7cSmrg  --quiet | --silent)
50717a48c7cSmrg    show=:
50817a48c7cSmrg    preserve_args="$preserve_args $arg"
50917a48c7cSmrg    ;;
51017a48c7cSmrg
51117a48c7cSmrg  --tag)
51217a48c7cSmrg    prevopt="--tag"
51317a48c7cSmrg    prev=tag
51417a48c7cSmrg    preserve_args="$preserve_args --tag"
51517a48c7cSmrg    ;;
51617a48c7cSmrg  --tag=*)
51717a48c7cSmrg    set tag "$optarg" ${1+"$@"}
51817a48c7cSmrg    shift
51917a48c7cSmrg    prev=tag
52017a48c7cSmrg    preserve_args="$preserve_args --tag"
52117a48c7cSmrg    ;;
52217a48c7cSmrg
52317a48c7cSmrg  -dlopen)
52417a48c7cSmrg    prevopt="-dlopen"
52517a48c7cSmrg    prev=execute_dlfiles
52617a48c7cSmrg    ;;
52717a48c7cSmrg
52817a48c7cSmrg  -*)
52917a48c7cSmrg    $echo "$modename: unrecognized option \`$arg'" 1>&2
53017a48c7cSmrg    $echo "$help" 1>&2
53117a48c7cSmrg    exit $EXIT_FAILURE
53217a48c7cSmrg    ;;
53317a48c7cSmrg
53417a48c7cSmrg  *)
53517a48c7cSmrg    nonopt="$arg"
53617a48c7cSmrg    break
53717a48c7cSmrg    ;;
53817a48c7cSmrg  esac
53917a48c7cSmrgdone
54017a48c7cSmrg
54117a48c7cSmrgif test -n "$prevopt"; then
54217a48c7cSmrg  $echo "$modename: option \`$prevopt' requires an argument" 1>&2
54317a48c7cSmrg  $echo "$help" 1>&2
54417a48c7cSmrg  exit $EXIT_FAILURE
54517a48c7cSmrgfi
54617a48c7cSmrg
54717a48c7cSmrgcase $disable_libs in
54817a48c7cSmrgno) 
54917a48c7cSmrg  ;;
55017a48c7cSmrgshared)
55117a48c7cSmrg  build_libtool_libs=no
55217a48c7cSmrg  build_old_libs=yes
55317a48c7cSmrg  ;;
55417a48c7cSmrgstatic)
55517a48c7cSmrg  build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
55617a48c7cSmrg  ;;
55717a48c7cSmrgesac
55817a48c7cSmrg
55917a48c7cSmrg# If this variable is set in any of the actions, the command in it
56017a48c7cSmrg# will be execed at the end.  This prevents here-documents from being
56117a48c7cSmrg# left over by shells.
56217a48c7cSmrgexec_cmd=
56317a48c7cSmrg
56417a48c7cSmrgif test -z "$show_help"; then
56517a48c7cSmrg
56617a48c7cSmrg  # Infer the operation mode.
56717a48c7cSmrg  if test -z "$mode"; then
56817a48c7cSmrg    $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
56917a48c7cSmrg    $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2
57017a48c7cSmrg    case $nonopt in
57117a48c7cSmrg    *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
57217a48c7cSmrg      mode=link
57317a48c7cSmrg      for arg
57417a48c7cSmrg      do
57517a48c7cSmrg	case $arg in
57617a48c7cSmrg	-c)
57717a48c7cSmrg	   mode=compile
57817a48c7cSmrg	   break
57917a48c7cSmrg	   ;;
58017a48c7cSmrg	esac
58117a48c7cSmrg      done
58217a48c7cSmrg      ;;
58317a48c7cSmrg    *db | *dbx | *strace | *truss)
58417a48c7cSmrg      mode=execute
58517a48c7cSmrg      ;;
58617a48c7cSmrg    *install*|cp|mv)
58717a48c7cSmrg      mode=install
58817a48c7cSmrg      ;;
58917a48c7cSmrg    *rm)
59017a48c7cSmrg      mode=uninstall
59117a48c7cSmrg      ;;
59217a48c7cSmrg    *)
59317a48c7cSmrg      # If we have no mode, but dlfiles were specified, then do execute mode.
59417a48c7cSmrg      test -n "$execute_dlfiles" && mode=execute
59517a48c7cSmrg
59617a48c7cSmrg      # Just use the default operation mode.
59717a48c7cSmrg      if test -z "$mode"; then
59817a48c7cSmrg	if test -n "$nonopt"; then
59917a48c7cSmrg	  $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
60017a48c7cSmrg	else
60117a48c7cSmrg	  $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
60217a48c7cSmrg	fi
60317a48c7cSmrg      fi
60417a48c7cSmrg      ;;
60517a48c7cSmrg    esac
60617a48c7cSmrg  fi
60717a48c7cSmrg
60817a48c7cSmrg  # Only execute mode is allowed to have -dlopen flags.
60917a48c7cSmrg  if test -n "$execute_dlfiles" && test "$mode" != execute; then
61017a48c7cSmrg    $echo "$modename: unrecognized option \`-dlopen'" 1>&2
61117a48c7cSmrg    $echo "$help" 1>&2
61217a48c7cSmrg    exit $EXIT_FAILURE
61317a48c7cSmrg  fi
61417a48c7cSmrg
61517a48c7cSmrg  # Change the help message to a mode-specific one.
61617a48c7cSmrg  generic_help="$help"
61717a48c7cSmrg  help="Try \`$modename --help --mode=$mode' for more information."
61817a48c7cSmrg
61917a48c7cSmrg  # These modes are in order of execution frequency so that they run quickly.
62017a48c7cSmrg  case $mode in
62117a48c7cSmrg  # libtool compile mode
62217a48c7cSmrg  compile)
62317a48c7cSmrg    modename="$modename: compile"
62417a48c7cSmrg    # Get the compilation command and the source file.
62517a48c7cSmrg    base_compile=
62617a48c7cSmrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
62717a48c7cSmrg    suppress_opt=yes
62817a48c7cSmrg    suppress_output=
62917a48c7cSmrg    arg_mode=normal
63017a48c7cSmrg    libobj=
63117a48c7cSmrg    later=
63217a48c7cSmrg
63317a48c7cSmrg    for arg
63417a48c7cSmrg    do
63517a48c7cSmrg      case $arg_mode in
63617a48c7cSmrg      arg  )
63717a48c7cSmrg	# do not "continue".  Instead, add this to base_compile
63817a48c7cSmrg	lastarg="$arg"
63917a48c7cSmrg	arg_mode=normal
64017a48c7cSmrg	;;
64117a48c7cSmrg
64217a48c7cSmrg      target )
64317a48c7cSmrg	libobj="$arg"
64417a48c7cSmrg	arg_mode=normal
64517a48c7cSmrg	continue
64617a48c7cSmrg	;;
64717a48c7cSmrg
64817a48c7cSmrg      normal )
64917a48c7cSmrg	# Accept any command-line options.
65017a48c7cSmrg	case $arg in
65117a48c7cSmrg	-o)
65217a48c7cSmrg	  if test -n "$libobj" ; then
65317a48c7cSmrg	    $echo "$modename: you cannot specify \`-o' more than once" 1>&2
65417a48c7cSmrg	    exit $EXIT_FAILURE
65517a48c7cSmrg	  fi
65617a48c7cSmrg	  arg_mode=target
65717a48c7cSmrg	  continue
65817a48c7cSmrg	  ;;
65917a48c7cSmrg
66017a48c7cSmrg	-static | -prefer-pic | -prefer-non-pic)
66117a48c7cSmrg	  later="$later $arg"
66217a48c7cSmrg	  continue
66317a48c7cSmrg	  ;;
66417a48c7cSmrg
66517a48c7cSmrg	-no-suppress)
66617a48c7cSmrg	  suppress_opt=no
66717a48c7cSmrg	  continue
66817a48c7cSmrg	  ;;
66917a48c7cSmrg
67017a48c7cSmrg	-Xcompiler)
67117a48c7cSmrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
67217a48c7cSmrg	  continue      #  The current "srcfile" will either be retained or
67317a48c7cSmrg	  ;;            #  replaced later.  I would guess that would be a bug.
67417a48c7cSmrg
67517a48c7cSmrg	-Wc,*)
67617a48c7cSmrg	  args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
67717a48c7cSmrg	  lastarg=
67817a48c7cSmrg	  save_ifs="$IFS"; IFS=','
67917a48c7cSmrg 	  for arg in $args; do
68017a48c7cSmrg	    IFS="$save_ifs"
68117a48c7cSmrg
68217a48c7cSmrg	    # Double-quote args containing other shell metacharacters.
68317a48c7cSmrg	    # Many Bourne shells cannot handle close brackets correctly
68417a48c7cSmrg	    # in scan sets, so we specify it separately.
68517a48c7cSmrg	    case $arg in
68617a48c7cSmrg	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
68717a48c7cSmrg	      arg="\"$arg\""
68817a48c7cSmrg	      ;;
68917a48c7cSmrg	    esac
69017a48c7cSmrg	    lastarg="$lastarg $arg"
69117a48c7cSmrg	  done
69217a48c7cSmrg	  IFS="$save_ifs"
69317a48c7cSmrg	  lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
69417a48c7cSmrg
69517a48c7cSmrg	  # Add the arguments to base_compile.
69617a48c7cSmrg	  base_compile="$base_compile $lastarg"
69717a48c7cSmrg	  continue
69817a48c7cSmrg	  ;;
69917a48c7cSmrg
70017a48c7cSmrg	* )
70117a48c7cSmrg	  # Accept the current argument as the source file.
70217a48c7cSmrg	  # The previous "srcfile" becomes the current argument.
70317a48c7cSmrg	  #
70417a48c7cSmrg	  lastarg="$srcfile"
70517a48c7cSmrg	  srcfile="$arg"
70617a48c7cSmrg	  ;;
70717a48c7cSmrg	esac  #  case $arg
70817a48c7cSmrg	;;
70917a48c7cSmrg      esac    #  case $arg_mode
71017a48c7cSmrg
71117a48c7cSmrg      # Aesthetically quote the previous argument.
71217a48c7cSmrg      lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
71317a48c7cSmrg
71417a48c7cSmrg      case $lastarg in
71517a48c7cSmrg      # Double-quote args containing other shell metacharacters.
71617a48c7cSmrg      # Many Bourne shells cannot handle close brackets correctly
71717a48c7cSmrg      # in scan sets, and some SunOS ksh mistreat backslash-escaping
71817a48c7cSmrg      # in scan sets (worked around with variable expansion),
71917a48c7cSmrg      # and furthermore cannot handle '|' '&' '(' ')' in scan sets 
72017a48c7cSmrg      # at all, so we specify them separately.
72117a48c7cSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
72217a48c7cSmrg	lastarg="\"$lastarg\""
72317a48c7cSmrg	;;
72417a48c7cSmrg      esac
72517a48c7cSmrg
72617a48c7cSmrg      base_compile="$base_compile $lastarg"
72717a48c7cSmrg    done # for arg
72817a48c7cSmrg
72917a48c7cSmrg    case $arg_mode in
73017a48c7cSmrg    arg)
73117a48c7cSmrg      $echo "$modename: you must specify an argument for -Xcompile"
73217a48c7cSmrg      exit $EXIT_FAILURE
73317a48c7cSmrg      ;;
73417a48c7cSmrg    target)
73517a48c7cSmrg      $echo "$modename: you must specify a target with \`-o'" 1>&2
73617a48c7cSmrg      exit $EXIT_FAILURE
73717a48c7cSmrg      ;;
73817a48c7cSmrg    *)
73917a48c7cSmrg      # Get the name of the library object.
74017a48c7cSmrg      [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
74117a48c7cSmrg      ;;
74217a48c7cSmrg    esac
74317a48c7cSmrg
74417a48c7cSmrg    # Recognize several different file suffixes.
74517a48c7cSmrg    # If the user specifies -o file.o, it is replaced with file.lo
74617a48c7cSmrg    xform='[cCFSifmso]'
74717a48c7cSmrg    case $libobj in
74817a48c7cSmrg    *.ada) xform=ada ;;
74917a48c7cSmrg    *.adb) xform=adb ;;
75017a48c7cSmrg    *.ads) xform=ads ;;
75117a48c7cSmrg    *.asm) xform=asm ;;
75217a48c7cSmrg    *.c++) xform=c++ ;;
75317a48c7cSmrg    *.cc) xform=cc ;;
75417a48c7cSmrg    *.ii) xform=ii ;;
75517a48c7cSmrg    *.class) xform=class ;;
75617a48c7cSmrg    *.cpp) xform=cpp ;;
75717a48c7cSmrg    *.cxx) xform=cxx ;;
75817a48c7cSmrg    *.f90) xform=f90 ;;
75917a48c7cSmrg    *.for) xform=for ;;
76017a48c7cSmrg    *.java) xform=java ;;
76117a48c7cSmrg    esac
76217a48c7cSmrg
76317a48c7cSmrg    libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
76417a48c7cSmrg
76517a48c7cSmrg    case $libobj in
76617a48c7cSmrg    *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
76717a48c7cSmrg    *)
76817a48c7cSmrg      $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
76917a48c7cSmrg      exit $EXIT_FAILURE
77017a48c7cSmrg      ;;
77117a48c7cSmrg    esac
77217a48c7cSmrg
77317a48c7cSmrg    func_infer_tag $base_compile
77417a48c7cSmrg
77517a48c7cSmrg    for arg in $later; do
77617a48c7cSmrg      case $arg in
77717a48c7cSmrg      -static)
77817a48c7cSmrg	build_old_libs=yes
77917a48c7cSmrg	continue
78017a48c7cSmrg	;;
78117a48c7cSmrg
78217a48c7cSmrg      -prefer-pic)
78317a48c7cSmrg	pic_mode=yes
78417a48c7cSmrg	continue
78517a48c7cSmrg	;;
78617a48c7cSmrg
78717a48c7cSmrg      -prefer-non-pic)
78817a48c7cSmrg	pic_mode=no
78917a48c7cSmrg	continue
79017a48c7cSmrg	;;
79117a48c7cSmrg      esac
79217a48c7cSmrg    done
79317a48c7cSmrg
79417a48c7cSmrg    qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"`
79517a48c7cSmrg    case $qlibobj in
79617a48c7cSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
79717a48c7cSmrg	qlibobj="\"$qlibobj\"" ;;
79817a48c7cSmrg    esac
79917a48c7cSmrg    test "X$libobj" != "X$qlibobj" \
80017a48c7cSmrg	&& $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"' 	&()|`$[]' \
80117a48c7cSmrg	&& $echo "$modename: libobj name \`$libobj' may not contain shell special characters."
80217a48c7cSmrg    objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
80317a48c7cSmrg    xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
80417a48c7cSmrg    if test "X$xdir" = "X$obj"; then
80517a48c7cSmrg      xdir=
80617a48c7cSmrg    else
80717a48c7cSmrg      xdir=$xdir/
80817a48c7cSmrg    fi
80917a48c7cSmrg    lobj=${xdir}$objdir/$objname
81017a48c7cSmrg
81117a48c7cSmrg    if test -z "$base_compile"; then
81217a48c7cSmrg      $echo "$modename: you must specify a compilation command" 1>&2
81317a48c7cSmrg      $echo "$help" 1>&2
81417a48c7cSmrg      exit $EXIT_FAILURE
81517a48c7cSmrg    fi
81617a48c7cSmrg
81717a48c7cSmrg    # Delete any leftover library objects.
81817a48c7cSmrg    if test "$build_old_libs" = yes; then
81917a48c7cSmrg      removelist="$obj $lobj $libobj ${libobj}T"
82017a48c7cSmrg    else
82117a48c7cSmrg      removelist="$lobj $libobj ${libobj}T"
82217a48c7cSmrg    fi
82317a48c7cSmrg
82417a48c7cSmrg    $run $rm $removelist
82517a48c7cSmrg    trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
82617a48c7cSmrg
82717a48c7cSmrg    # On Cygwin there's no "real" PIC flag so we must build both object types
82817a48c7cSmrg    case $host_os in
82917a48c7cSmrg    cygwin* | mingw* | pw32* | os2*)
83017a48c7cSmrg      pic_mode=default
83117a48c7cSmrg      ;;
83217a48c7cSmrg    esac
83317a48c7cSmrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
83417a48c7cSmrg      # non-PIC code in shared libraries is not supported
83517a48c7cSmrg      pic_mode=default
83617a48c7cSmrg    fi
83717a48c7cSmrg
83817a48c7cSmrg    # Calculate the filename of the output object if compiler does
83917a48c7cSmrg    # not support -o with -c
84017a48c7cSmrg    if test "$compiler_c_o" = no; then
84117a48c7cSmrg      output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
84217a48c7cSmrg      lockfile="$output_obj.lock"
84317a48c7cSmrg      removelist="$removelist $output_obj $lockfile"
84417a48c7cSmrg      trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
84517a48c7cSmrg    else
84617a48c7cSmrg      output_obj=
84717a48c7cSmrg      need_locks=no
84817a48c7cSmrg      lockfile=
84917a48c7cSmrg    fi
85017a48c7cSmrg
85117a48c7cSmrg    # Lock this critical section if it is needed
85217a48c7cSmrg    # We use this script file to make the link, it avoids creating a new file
85317a48c7cSmrg    if test "$need_locks" = yes; then
85417a48c7cSmrg      until $run ln "$progpath" "$lockfile" 2>/dev/null; do
85517a48c7cSmrg	$show "Waiting for $lockfile to be removed"
85617a48c7cSmrg	sleep 2
85717a48c7cSmrg      done
85817a48c7cSmrg    elif test "$need_locks" = warn; then
85917a48c7cSmrg      if test -f "$lockfile"; then
86017a48c7cSmrg	$echo "\
86117a48c7cSmrg*** ERROR, $lockfile exists and contains:
86217a48c7cSmrg`cat $lockfile 2>/dev/null`
86317a48c7cSmrg
86417a48c7cSmrgThis indicates that another process is trying to use the same
86517a48c7cSmrgtemporary object file, and libtool could not work around it because
86617a48c7cSmrgyour compiler does not support \`-c' and \`-o' together.  If you
86717a48c7cSmrgrepeat this compilation, it may succeed, by chance, but you had better
86817a48c7cSmrgavoid parallel builds (make -j) in this platform, or get a better
86917a48c7cSmrgcompiler."
87017a48c7cSmrg
87117a48c7cSmrg	$run $rm $removelist
87217a48c7cSmrg	exit $EXIT_FAILURE
87317a48c7cSmrg      fi
87417a48c7cSmrg      $echo "$srcfile" > "$lockfile"
87517a48c7cSmrg    fi
87617a48c7cSmrg
87717a48c7cSmrg    if test -n "$fix_srcfile_path"; then
87817a48c7cSmrg      eval srcfile=\"$fix_srcfile_path\"
87917a48c7cSmrg    fi
88017a48c7cSmrg    qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"`
88117a48c7cSmrg    case $qsrcfile in
88217a48c7cSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
88317a48c7cSmrg      qsrcfile="\"$qsrcfile\"" ;;
88417a48c7cSmrg    esac
88517a48c7cSmrg
88617a48c7cSmrg    $run $rm "$libobj" "${libobj}T"
88717a48c7cSmrg
88817a48c7cSmrg    # Create a libtool object file (analogous to a ".la" file),
88917a48c7cSmrg    # but don't create it if we're doing a dry run.
89017a48c7cSmrg    test -z "$run" && cat > ${libobj}T <<EOF
89117a48c7cSmrg# $libobj - a libtool object file
89217a48c7cSmrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
89317a48c7cSmrg#
89417a48c7cSmrg# Please DO NOT delete this file!
89517a48c7cSmrg# It is necessary for linking the library.
89617a48c7cSmrg
89717a48c7cSmrg# Name of the PIC object.
89817a48c7cSmrgEOF
89917a48c7cSmrg
90017a48c7cSmrg    # Only build a PIC object if we are building libtool libraries.
90117a48c7cSmrg    if test "$build_libtool_libs" = yes; then
90217a48c7cSmrg      # Without this assignment, base_compile gets emptied.
90317a48c7cSmrg      fbsd_hideous_sh_bug=$base_compile
90417a48c7cSmrg
90517a48c7cSmrg      if test "$pic_mode" != no; then
90617a48c7cSmrg	command="$base_compile $qsrcfile $pic_flag"
90717a48c7cSmrg      else
90817a48c7cSmrg	# Don't build PIC code
90917a48c7cSmrg	command="$base_compile $qsrcfile"
91017a48c7cSmrg      fi
91117a48c7cSmrg
91217a48c7cSmrg      if test ! -d "${xdir}$objdir"; then
91317a48c7cSmrg	$show "$mkdir ${xdir}$objdir"
91417a48c7cSmrg	$run $mkdir ${xdir}$objdir
91517a48c7cSmrg	exit_status=$?
91617a48c7cSmrg	if test "$exit_status" -ne 0 && test ! -d "${xdir}$objdir"; then
91717a48c7cSmrg	  exit $exit_status
91817a48c7cSmrg	fi
91917a48c7cSmrg      fi
92017a48c7cSmrg
92117a48c7cSmrg      if test -z "$output_obj"; then
92217a48c7cSmrg	# Place PIC objects in $objdir
92317a48c7cSmrg	command="$command -o $lobj"
92417a48c7cSmrg      fi
92517a48c7cSmrg
92617a48c7cSmrg      $run $rm "$lobj" "$output_obj"
92717a48c7cSmrg
92817a48c7cSmrg      $show "$command"
92917a48c7cSmrg      if $run eval "$command"; then :
93017a48c7cSmrg      else
93117a48c7cSmrg	test -n "$output_obj" && $run $rm $removelist
93217a48c7cSmrg	exit $EXIT_FAILURE
93317a48c7cSmrg      fi
93417a48c7cSmrg
93517a48c7cSmrg      if test "$need_locks" = warn &&
93617a48c7cSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
93717a48c7cSmrg	$echo "\
93817a48c7cSmrg*** ERROR, $lockfile contains:
93917a48c7cSmrg`cat $lockfile 2>/dev/null`
94017a48c7cSmrg
94117a48c7cSmrgbut it should contain:
94217a48c7cSmrg$srcfile
94317a48c7cSmrg
94417a48c7cSmrgThis indicates that another process is trying to use the same
94517a48c7cSmrgtemporary object file, and libtool could not work around it because
94617a48c7cSmrgyour compiler does not support \`-c' and \`-o' together.  If you
94717a48c7cSmrgrepeat this compilation, it may succeed, by chance, but you had better
94817a48c7cSmrgavoid parallel builds (make -j) in this platform, or get a better
94917a48c7cSmrgcompiler."
95017a48c7cSmrg
95117a48c7cSmrg	$run $rm $removelist
95217a48c7cSmrg	exit $EXIT_FAILURE
95317a48c7cSmrg      fi
95417a48c7cSmrg
95517a48c7cSmrg      # Just move the object if needed, then go on to compile the next one
95617a48c7cSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
95717a48c7cSmrg	$show "$mv $output_obj $lobj"
95817a48c7cSmrg	if $run $mv $output_obj $lobj; then :
95917a48c7cSmrg	else
96017a48c7cSmrg	  error=$?
96117a48c7cSmrg	  $run $rm $removelist
96217a48c7cSmrg	  exit $error
96317a48c7cSmrg	fi
96417a48c7cSmrg      fi
96517a48c7cSmrg
96617a48c7cSmrg      # Append the name of the PIC object to the libtool object file.
96717a48c7cSmrg      test -z "$run" && cat >> ${libobj}T <<EOF
96817a48c7cSmrgpic_object='$objdir/$objname'
96917a48c7cSmrg
97017a48c7cSmrgEOF
97117a48c7cSmrg
97217a48c7cSmrg      # Allow error messages only from the first compilation.
97317a48c7cSmrg      if test "$suppress_opt" = yes; then
97417a48c7cSmrg        suppress_output=' >/dev/null 2>&1'
97517a48c7cSmrg      fi
97617a48c7cSmrg    else
97717a48c7cSmrg      # No PIC object so indicate it doesn't exist in the libtool
97817a48c7cSmrg      # object file.
97917a48c7cSmrg      test -z "$run" && cat >> ${libobj}T <<EOF
98017a48c7cSmrgpic_object=none
98117a48c7cSmrg
98217a48c7cSmrgEOF
98317a48c7cSmrg    fi
98417a48c7cSmrg
98517a48c7cSmrg    # Only build a position-dependent object if we build old libraries.
98617a48c7cSmrg    if test "$build_old_libs" = yes; then
98717a48c7cSmrg      if test "$pic_mode" != yes; then
98817a48c7cSmrg	# Don't build PIC code
98917a48c7cSmrg	command="$base_compile $qsrcfile"
99017a48c7cSmrg      else
99117a48c7cSmrg	command="$base_compile $qsrcfile $pic_flag"
99217a48c7cSmrg      fi
99317a48c7cSmrg      if test "$compiler_c_o" = yes; then
99417a48c7cSmrg	command="$command -o $obj"
99517a48c7cSmrg      fi
99617a48c7cSmrg
99717a48c7cSmrg      # Suppress compiler output if we already did a PIC compilation.
99817a48c7cSmrg      command="$command$suppress_output"
99917a48c7cSmrg      $run $rm "$obj" "$output_obj"
100017a48c7cSmrg      $show "$command"
100117a48c7cSmrg      if $run eval "$command"; then :
100217a48c7cSmrg      else
100317a48c7cSmrg	$run $rm $removelist
100417a48c7cSmrg	exit $EXIT_FAILURE
100517a48c7cSmrg      fi
100617a48c7cSmrg
100717a48c7cSmrg      if test "$need_locks" = warn &&
100817a48c7cSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
100917a48c7cSmrg	$echo "\
101017a48c7cSmrg*** ERROR, $lockfile contains:
101117a48c7cSmrg`cat $lockfile 2>/dev/null`
101217a48c7cSmrg
101317a48c7cSmrgbut it should contain:
101417a48c7cSmrg$srcfile
101517a48c7cSmrg
101617a48c7cSmrgThis indicates that another process is trying to use the same
101717a48c7cSmrgtemporary object file, and libtool could not work around it because
101817a48c7cSmrgyour compiler does not support \`-c' and \`-o' together.  If you
101917a48c7cSmrgrepeat this compilation, it may succeed, by chance, but you had better
102017a48c7cSmrgavoid parallel builds (make -j) in this platform, or get a better
102117a48c7cSmrgcompiler."
102217a48c7cSmrg
102317a48c7cSmrg	$run $rm $removelist
102417a48c7cSmrg	exit $EXIT_FAILURE
102517a48c7cSmrg      fi
102617a48c7cSmrg
102717a48c7cSmrg      # Just move the object if needed
102817a48c7cSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
102917a48c7cSmrg	$show "$mv $output_obj $obj"
103017a48c7cSmrg	if $run $mv $output_obj $obj; then :
103117a48c7cSmrg	else
103217a48c7cSmrg	  error=$?
103317a48c7cSmrg	  $run $rm $removelist
103417a48c7cSmrg	  exit $error
103517a48c7cSmrg	fi
103617a48c7cSmrg      fi
103717a48c7cSmrg
103817a48c7cSmrg      # Append the name of the non-PIC object the libtool object file.
103917a48c7cSmrg      # Only append if the libtool object file exists.
104017a48c7cSmrg      test -z "$run" && cat >> ${libobj}T <<EOF
104117a48c7cSmrg# Name of the non-PIC object.
104217a48c7cSmrgnon_pic_object='$objname'
104317a48c7cSmrg
104417a48c7cSmrgEOF
104517a48c7cSmrg    else
104617a48c7cSmrg      # Append the name of the non-PIC object the libtool object file.
104717a48c7cSmrg      # Only append if the libtool object file exists.
104817a48c7cSmrg      test -z "$run" && cat >> ${libobj}T <<EOF
104917a48c7cSmrg# Name of the non-PIC object.
105017a48c7cSmrgnon_pic_object=none
105117a48c7cSmrg
105217a48c7cSmrgEOF
105317a48c7cSmrg    fi
105417a48c7cSmrg
105517a48c7cSmrg    $run $mv "${libobj}T" "${libobj}"
105617a48c7cSmrg
105717a48c7cSmrg    # Unlock the critical section if it was locked
105817a48c7cSmrg    if test "$need_locks" != no; then
105917a48c7cSmrg      $run $rm "$lockfile"
106017a48c7cSmrg    fi
106117a48c7cSmrg
106217a48c7cSmrg    exit $EXIT_SUCCESS
106317a48c7cSmrg    ;;
106417a48c7cSmrg
106517a48c7cSmrg  # libtool link mode
106617a48c7cSmrg  link | relink)
106717a48c7cSmrg    modename="$modename: link"
106817a48c7cSmrg    case $host in
106917a48c7cSmrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
107017a48c7cSmrg      # It is impossible to link a dll without this setting, and
107117a48c7cSmrg      # we shouldn't force the makefile maintainer to figure out
107217a48c7cSmrg      # which system we are compiling for in order to pass an extra
107317a48c7cSmrg      # flag for every libtool invocation.
107417a48c7cSmrg      # allow_undefined=no
107517a48c7cSmrg
107617a48c7cSmrg      # FIXME: Unfortunately, there are problems with the above when trying
107717a48c7cSmrg      # to make a dll which has undefined symbols, in which case not
107817a48c7cSmrg      # even a static library is built.  For now, we need to specify
107917a48c7cSmrg      # -no-undefined on the libtool link line when we can be certain
108017a48c7cSmrg      # that all symbols are satisfied, otherwise we get a static library.
108117a48c7cSmrg      allow_undefined=yes
108217a48c7cSmrg      ;;
108317a48c7cSmrg    *)
108417a48c7cSmrg      allow_undefined=yes
108517a48c7cSmrg      ;;
108617a48c7cSmrg    esac
108717a48c7cSmrg    libtool_args="$nonopt"
108817a48c7cSmrg    base_compile="$nonopt $@"
108917a48c7cSmrg    compile_command="$nonopt"
109017a48c7cSmrg    finalize_command="$nonopt"
109117a48c7cSmrg
109217a48c7cSmrg    compile_rpath=
109317a48c7cSmrg    finalize_rpath=
109417a48c7cSmrg    compile_shlibpath=
109517a48c7cSmrg    finalize_shlibpath=
109617a48c7cSmrg    convenience=
109717a48c7cSmrg    old_convenience=
109817a48c7cSmrg    deplibs=
109917a48c7cSmrg    old_deplibs=
110017a48c7cSmrg    compiler_flags=
110117a48c7cSmrg    linker_flags=
110217a48c7cSmrg    dllsearchpath=
110317a48c7cSmrg    lib_search_path=`pwd`
110417a48c7cSmrg    inst_prefix_dir=
110517a48c7cSmrg
110617a48c7cSmrg    avoid_version=no
110717a48c7cSmrg    dlfiles=
110817a48c7cSmrg    dlprefiles=
110917a48c7cSmrg    dlself=no
111017a48c7cSmrg    export_dynamic=no
111117a48c7cSmrg    export_symbols=
111217a48c7cSmrg    export_symbols_regex=
111317a48c7cSmrg    generated=
111417a48c7cSmrg    libobjs=
111517a48c7cSmrg    ltlibs=
111617a48c7cSmrg    module=no
111717a48c7cSmrg    no_install=no
111817a48c7cSmrg    objs=
111917a48c7cSmrg    non_pic_objects=
112017a48c7cSmrg    notinst_path= # paths that contain not-installed libtool libraries
112117a48c7cSmrg    precious_files_regex=
112217a48c7cSmrg    prefer_static_libs=no
112317a48c7cSmrg    preload=no
112417a48c7cSmrg    prev=
112517a48c7cSmrg    prevarg=
112617a48c7cSmrg    release=
112717a48c7cSmrg    rpath=
112817a48c7cSmrg    xrpath=
112917a48c7cSmrg    perm_rpath=
113017a48c7cSmrg    temp_rpath=
113117a48c7cSmrg    thread_safe=no
113217a48c7cSmrg    vinfo=
113317a48c7cSmrg    vinfo_number=no
113417a48c7cSmrg
113517a48c7cSmrg    func_infer_tag $base_compile
113617a48c7cSmrg
113717a48c7cSmrg    # We need to know -static, to get the right output filenames.
113817a48c7cSmrg    for arg
113917a48c7cSmrg    do
114017a48c7cSmrg      case $arg in
114117a48c7cSmrg      -all-static | -static)
114217a48c7cSmrg	if test "X$arg" = "X-all-static"; then
114317a48c7cSmrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
114417a48c7cSmrg	    $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
114517a48c7cSmrg	  fi
114617a48c7cSmrg	  if test -n "$link_static_flag"; then
114717a48c7cSmrg	    dlopen_self=$dlopen_self_static
114817a48c7cSmrg	  fi
114917a48c7cSmrg	  prefer_static_libs=yes
115017a48c7cSmrg	else
115117a48c7cSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
115217a48c7cSmrg	    dlopen_self=$dlopen_self_static
115317a48c7cSmrg	  fi
115417a48c7cSmrg	  prefer_static_libs=built
115517a48c7cSmrg	fi
115617a48c7cSmrg	build_libtool_libs=no
115717a48c7cSmrg	build_old_libs=yes
115817a48c7cSmrg	break
115917a48c7cSmrg	;;
116017a48c7cSmrg      esac
116117a48c7cSmrg    done
116217a48c7cSmrg
116317a48c7cSmrg    # See if our shared archives depend on static archives.
116417a48c7cSmrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
116517a48c7cSmrg
116617a48c7cSmrg    # Go through the arguments, transforming them on the way.
116717a48c7cSmrg    while test "$#" -gt 0; do
116817a48c7cSmrg      arg="$1"
116917a48c7cSmrg      shift
117017a48c7cSmrg      case $arg in
117117a48c7cSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
117217a48c7cSmrg	qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test
117317a48c7cSmrg	;;
117417a48c7cSmrg      *) qarg=$arg ;;
117517a48c7cSmrg      esac
117617a48c7cSmrg      libtool_args="$libtool_args $qarg"
117717a48c7cSmrg
117817a48c7cSmrg      # If the previous option needs an argument, assign it.
117917a48c7cSmrg      if test -n "$prev"; then
118017a48c7cSmrg	case $prev in
118117a48c7cSmrg	output)
118217a48c7cSmrg	  compile_command="$compile_command @OUTPUT@"
118317a48c7cSmrg	  finalize_command="$finalize_command @OUTPUT@"
118417a48c7cSmrg	  ;;
118517a48c7cSmrg	esac
118617a48c7cSmrg
118717a48c7cSmrg	case $prev in
118817a48c7cSmrg	dlfiles|dlprefiles)
118917a48c7cSmrg	  if test "$preload" = no; then
119017a48c7cSmrg	    # Add the symbol object into the linking commands.
119117a48c7cSmrg	    compile_command="$compile_command @SYMFILE@"
119217a48c7cSmrg	    finalize_command="$finalize_command @SYMFILE@"
119317a48c7cSmrg	    preload=yes
119417a48c7cSmrg	  fi
119517a48c7cSmrg	  case $arg in
119617a48c7cSmrg	  *.la | *.lo) ;;  # We handle these cases below.
119717a48c7cSmrg	  force)
119817a48c7cSmrg	    if test "$dlself" = no; then
119917a48c7cSmrg	      dlself=needless
120017a48c7cSmrg	      export_dynamic=yes
120117a48c7cSmrg	    fi
120217a48c7cSmrg	    prev=
120317a48c7cSmrg	    continue
120417a48c7cSmrg	    ;;
120517a48c7cSmrg	  self)
120617a48c7cSmrg	    if test "$prev" = dlprefiles; then
120717a48c7cSmrg	      dlself=yes
120817a48c7cSmrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
120917a48c7cSmrg	      dlself=yes
121017a48c7cSmrg	    else
121117a48c7cSmrg	      dlself=needless
121217a48c7cSmrg	      export_dynamic=yes
121317a48c7cSmrg	    fi
121417a48c7cSmrg	    prev=
121517a48c7cSmrg	    continue
121617a48c7cSmrg	    ;;
121717a48c7cSmrg	  *)
121817a48c7cSmrg	    if test "$prev" = dlfiles; then
121917a48c7cSmrg	      dlfiles="$dlfiles $arg"
122017a48c7cSmrg	    else
122117a48c7cSmrg	      dlprefiles="$dlprefiles $arg"
122217a48c7cSmrg	    fi
122317a48c7cSmrg	    prev=
122417a48c7cSmrg	    continue
122517a48c7cSmrg	    ;;
122617a48c7cSmrg	  esac
122717a48c7cSmrg	  ;;
122817a48c7cSmrg	expsyms)
122917a48c7cSmrg	  export_symbols="$arg"
123017a48c7cSmrg	  if test ! -f "$arg"; then
123117a48c7cSmrg	    $echo "$modename: symbol file \`$arg' does not exist"
123217a48c7cSmrg	    exit $EXIT_FAILURE
123317a48c7cSmrg	  fi
123417a48c7cSmrg	  prev=
123517a48c7cSmrg	  continue
123617a48c7cSmrg	  ;;
123717a48c7cSmrg	expsyms_regex)
123817a48c7cSmrg	  export_symbols_regex="$arg"
123917a48c7cSmrg	  prev=
124017a48c7cSmrg	  continue
124117a48c7cSmrg	  ;;
124217a48c7cSmrg	inst_prefix)
124317a48c7cSmrg	  inst_prefix_dir="$arg"
124417a48c7cSmrg	  prev=
124517a48c7cSmrg	  continue
124617a48c7cSmrg	  ;;
124717a48c7cSmrg	precious_regex)
124817a48c7cSmrg	  precious_files_regex="$arg"
124917a48c7cSmrg	  prev=
125017a48c7cSmrg	  continue
125117a48c7cSmrg	  ;;
125217a48c7cSmrg	release)
125317a48c7cSmrg	  release="-$arg"
125417a48c7cSmrg	  prev=
125517a48c7cSmrg	  continue
125617a48c7cSmrg	  ;;
125717a48c7cSmrg	objectlist)
125817a48c7cSmrg	  if test -f "$arg"; then
125917a48c7cSmrg	    save_arg=$arg
126017a48c7cSmrg	    moreargs=
126117a48c7cSmrg	    for fil in `cat $save_arg`
126217a48c7cSmrg	    do
126317a48c7cSmrg#	      moreargs="$moreargs $fil"
126417a48c7cSmrg	      arg=$fil
126517a48c7cSmrg	      # A libtool-controlled object.
126617a48c7cSmrg
126717a48c7cSmrg	      # Check to see that this really is a libtool object.
126817a48c7cSmrg	      if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
126917a48c7cSmrg		pic_object=
127017a48c7cSmrg		non_pic_object=
127117a48c7cSmrg
127217a48c7cSmrg		# Read the .lo file
127317a48c7cSmrg		# If there is no directory component, then add one.
127417a48c7cSmrg		case $arg in
127517a48c7cSmrg		*/* | *\\*) . $arg ;;
127617a48c7cSmrg		*) . ./$arg ;;
127717a48c7cSmrg		esac
127817a48c7cSmrg
127917a48c7cSmrg		if test -z "$pic_object" || \
128017a48c7cSmrg		   test -z "$non_pic_object" ||
128117a48c7cSmrg		   test "$pic_object" = none && \
128217a48c7cSmrg		   test "$non_pic_object" = none; then
128317a48c7cSmrg		  $echo "$modename: cannot find name of object for \`$arg'" 1>&2
128417a48c7cSmrg		  exit $EXIT_FAILURE
128517a48c7cSmrg		fi
128617a48c7cSmrg
128717a48c7cSmrg		# Extract subdirectory from the argument.
128817a48c7cSmrg		xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
128917a48c7cSmrg		if test "X$xdir" = "X$arg"; then
129017a48c7cSmrg		  xdir=
129117a48c7cSmrg		else
129217a48c7cSmrg		  xdir="$xdir/"
129317a48c7cSmrg		fi
129417a48c7cSmrg
129517a48c7cSmrg		if test "$pic_object" != none; then
129617a48c7cSmrg		  # Prepend the subdirectory the object is found in.
129717a48c7cSmrg		  pic_object="$xdir$pic_object"
129817a48c7cSmrg
129917a48c7cSmrg		  if test "$prev" = dlfiles; then
130017a48c7cSmrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
130117a48c7cSmrg		      dlfiles="$dlfiles $pic_object"
130217a48c7cSmrg		      prev=
130317a48c7cSmrg		      continue
130417a48c7cSmrg		    else
130517a48c7cSmrg		      # If libtool objects are unsupported, then we need to preload.
130617a48c7cSmrg		      prev=dlprefiles
130717a48c7cSmrg		    fi
130817a48c7cSmrg		  fi
130917a48c7cSmrg
131017a48c7cSmrg		  # CHECK ME:  I think I busted this.  -Ossama
131117a48c7cSmrg		  if test "$prev" = dlprefiles; then
131217a48c7cSmrg		    # Preload the old-style object.
131317a48c7cSmrg		    dlprefiles="$dlprefiles $pic_object"
131417a48c7cSmrg		    prev=
131517a48c7cSmrg		  fi
131617a48c7cSmrg
131717a48c7cSmrg		  # A PIC object.
131817a48c7cSmrg		  libobjs="$libobjs $pic_object"
131917a48c7cSmrg		  arg="$pic_object"
132017a48c7cSmrg		fi
132117a48c7cSmrg
132217a48c7cSmrg		# Non-PIC object.
132317a48c7cSmrg		if test "$non_pic_object" != none; then
132417a48c7cSmrg		  # Prepend the subdirectory the object is found in.
132517a48c7cSmrg		  non_pic_object="$xdir$non_pic_object"
132617a48c7cSmrg
132717a48c7cSmrg		  # A standard non-PIC object
132817a48c7cSmrg		  non_pic_objects="$non_pic_objects $non_pic_object"
132917a48c7cSmrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
133017a48c7cSmrg		    arg="$non_pic_object"
133117a48c7cSmrg		  fi
133217a48c7cSmrg		else
133317a48c7cSmrg		  # If the PIC object exists, use it instead.
133417a48c7cSmrg		  # $xdir was prepended to $pic_object above.
133517a48c7cSmrg		  non_pic_object="$pic_object"
133617a48c7cSmrg		  non_pic_objects="$non_pic_objects $non_pic_object"
133717a48c7cSmrg		fi
133817a48c7cSmrg	      else
133917a48c7cSmrg		# Only an error if not doing a dry-run.
134017a48c7cSmrg		if test -z "$run"; then
134117a48c7cSmrg		  $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
134217a48c7cSmrg		  exit $EXIT_FAILURE
134317a48c7cSmrg		else
134417a48c7cSmrg		  # Dry-run case.
134517a48c7cSmrg
134617a48c7cSmrg		  # Extract subdirectory from the argument.
134717a48c7cSmrg		  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
134817a48c7cSmrg		  if test "X$xdir" = "X$arg"; then
134917a48c7cSmrg		    xdir=
135017a48c7cSmrg		  else
135117a48c7cSmrg		    xdir="$xdir/"
135217a48c7cSmrg		  fi
135317a48c7cSmrg
135417a48c7cSmrg		  pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
135517a48c7cSmrg		  non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
135617a48c7cSmrg		  libobjs="$libobjs $pic_object"
135717a48c7cSmrg		  non_pic_objects="$non_pic_objects $non_pic_object"
135817a48c7cSmrg		fi
135917a48c7cSmrg	      fi
136017a48c7cSmrg	    done
136117a48c7cSmrg	  else
136217a48c7cSmrg	    $echo "$modename: link input file \`$save_arg' does not exist"
136317a48c7cSmrg	    exit $EXIT_FAILURE
136417a48c7cSmrg	  fi
136517a48c7cSmrg	  arg=$save_arg
136617a48c7cSmrg	  prev=
136717a48c7cSmrg	  continue
136817a48c7cSmrg	  ;;
136917a48c7cSmrg	rpath | xrpath)
137017a48c7cSmrg	  # We need an absolute path.
137117a48c7cSmrg	  case $arg in
137217a48c7cSmrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
137317a48c7cSmrg	  *)
137417a48c7cSmrg	    $echo "$modename: only absolute run-paths are allowed" 1>&2
137517a48c7cSmrg	    exit $EXIT_FAILURE
137617a48c7cSmrg	    ;;
137717a48c7cSmrg	  esac
137817a48c7cSmrg	  if test "$prev" = rpath; then
137917a48c7cSmrg	    case "$rpath " in
138017a48c7cSmrg	    *" $arg "*) ;;
138117a48c7cSmrg	    *) rpath="$rpath $arg" ;;
138217a48c7cSmrg	    esac
138317a48c7cSmrg	  else
138417a48c7cSmrg	    case "$xrpath " in
138517a48c7cSmrg	    *" $arg "*) ;;
138617a48c7cSmrg	    *) xrpath="$xrpath $arg" ;;
138717a48c7cSmrg	    esac
138817a48c7cSmrg	  fi
138917a48c7cSmrg	  prev=
139017a48c7cSmrg	  continue
139117a48c7cSmrg	  ;;
139217a48c7cSmrg	xcompiler)
139317a48c7cSmrg	  compiler_flags="$compiler_flags $qarg"
139417a48c7cSmrg	  prev=
139517a48c7cSmrg	  compile_command="$compile_command $qarg"
139617a48c7cSmrg	  finalize_command="$finalize_command $qarg"
139717a48c7cSmrg	  continue
139817a48c7cSmrg	  ;;
139917a48c7cSmrg	xlinker)
140017a48c7cSmrg	  linker_flags="$linker_flags $qarg"
140117a48c7cSmrg	  compiler_flags="$compiler_flags $wl$qarg"
140217a48c7cSmrg	  prev=
140317a48c7cSmrg	  compile_command="$compile_command $wl$qarg"
140417a48c7cSmrg	  finalize_command="$finalize_command $wl$qarg"
140517a48c7cSmrg	  continue
140617a48c7cSmrg	  ;;
140717a48c7cSmrg	xcclinker)
140817a48c7cSmrg	  linker_flags="$linker_flags $qarg"
140917a48c7cSmrg	  compiler_flags="$compiler_flags $qarg"
141017a48c7cSmrg	  prev=
141117a48c7cSmrg	  compile_command="$compile_command $qarg"
141217a48c7cSmrg	  finalize_command="$finalize_command $qarg"
141317a48c7cSmrg	  continue
141417a48c7cSmrg	  ;;
141517a48c7cSmrg	shrext)
141617a48c7cSmrg  	  shrext_cmds="$arg"
141717a48c7cSmrg	  prev=
141817a48c7cSmrg	  continue
141917a48c7cSmrg	  ;;
142017a48c7cSmrg	darwin_framework|darwin_framework_skip)
142117a48c7cSmrg	  test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg"
142217a48c7cSmrg	  compile_command="$compile_command $arg"
142317a48c7cSmrg	  finalize_command="$finalize_command $arg"
142417a48c7cSmrg	  prev=
142517a48c7cSmrg	  continue
142617a48c7cSmrg	  ;;
142717a48c7cSmrg	*)
142817a48c7cSmrg	  eval "$prev=\"\$arg\""
142917a48c7cSmrg	  prev=
143017a48c7cSmrg	  continue
143117a48c7cSmrg	  ;;
143217a48c7cSmrg	esac
143317a48c7cSmrg      fi # test -n "$prev"
143417a48c7cSmrg
143517a48c7cSmrg      prevarg="$arg"
143617a48c7cSmrg
143717a48c7cSmrg      case $arg in
143817a48c7cSmrg      -all-static)
143917a48c7cSmrg	if test -n "$link_static_flag"; then
144017a48c7cSmrg	  compile_command="$compile_command $link_static_flag"
144117a48c7cSmrg	  finalize_command="$finalize_command $link_static_flag"
144217a48c7cSmrg	fi
144317a48c7cSmrg	continue
144417a48c7cSmrg	;;
144517a48c7cSmrg
144617a48c7cSmrg      -allow-undefined)
144717a48c7cSmrg	# FIXME: remove this flag sometime in the future.
144817a48c7cSmrg	$echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
144917a48c7cSmrg	continue
145017a48c7cSmrg	;;
145117a48c7cSmrg
145217a48c7cSmrg      -avoid-version)
145317a48c7cSmrg	avoid_version=yes
145417a48c7cSmrg	continue
145517a48c7cSmrg	;;
145617a48c7cSmrg
145717a48c7cSmrg      -dlopen)
145817a48c7cSmrg	prev=dlfiles
145917a48c7cSmrg	continue
146017a48c7cSmrg	;;
146117a48c7cSmrg
146217a48c7cSmrg      -dlpreopen)
146317a48c7cSmrg	prev=dlprefiles
146417a48c7cSmrg	continue
146517a48c7cSmrg	;;
146617a48c7cSmrg
146717a48c7cSmrg      -export-dynamic)
146817a48c7cSmrg	export_dynamic=yes
146917a48c7cSmrg	continue
147017a48c7cSmrg	;;
147117a48c7cSmrg
147217a48c7cSmrg      -export-symbols | -export-symbols-regex)
147317a48c7cSmrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
147417a48c7cSmrg	  $echo "$modename: more than one -exported-symbols argument is not allowed"
147517a48c7cSmrg	  exit $EXIT_FAILURE
147617a48c7cSmrg	fi
147717a48c7cSmrg	if test "X$arg" = "X-export-symbols"; then
147817a48c7cSmrg	  prev=expsyms
147917a48c7cSmrg	else
148017a48c7cSmrg	  prev=expsyms_regex
148117a48c7cSmrg	fi
148217a48c7cSmrg	continue
148317a48c7cSmrg	;;
148417a48c7cSmrg
148517a48c7cSmrg      -framework|-arch|-isysroot)
148617a48c7cSmrg	case " $CC " in
148717a48c7cSmrg	  *" ${arg} ${1} "* | *" ${arg}	${1} "*) 
148817a48c7cSmrg		prev=darwin_framework_skip ;;
148917a48c7cSmrg	  *) compiler_flags="$compiler_flags $arg"
149017a48c7cSmrg	     prev=darwin_framework ;;
149117a48c7cSmrg	esac
149217a48c7cSmrg	compile_command="$compile_command $arg"
149317a48c7cSmrg	finalize_command="$finalize_command $arg"
149417a48c7cSmrg	continue
149517a48c7cSmrg	;;
149617a48c7cSmrg
149717a48c7cSmrg      -inst-prefix-dir)
149817a48c7cSmrg	prev=inst_prefix
149917a48c7cSmrg	continue
150017a48c7cSmrg	;;
150117a48c7cSmrg
150217a48c7cSmrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
150317a48c7cSmrg      # so, if we see these flags be careful not to treat them like -L
150417a48c7cSmrg      -L[A-Z][A-Z]*:*)
150517a48c7cSmrg	case $with_gcc/$host in
150617a48c7cSmrg	no/*-*-irix* | /*-*-irix*)
150717a48c7cSmrg	  compile_command="$compile_command $arg"
150817a48c7cSmrg	  finalize_command="$finalize_command $arg"
150917a48c7cSmrg	  ;;
151017a48c7cSmrg	esac
151117a48c7cSmrg	continue
151217a48c7cSmrg	;;
151317a48c7cSmrg
151417a48c7cSmrg      -L*)
151517a48c7cSmrg	dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
151617a48c7cSmrg	# We need an absolute path.
151717a48c7cSmrg	case $dir in
151817a48c7cSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
151917a48c7cSmrg	*)
152017a48c7cSmrg	  absdir=`cd "$dir" && pwd`
152117a48c7cSmrg	  if test -z "$absdir"; then
152217a48c7cSmrg	    $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
152317a48c7cSmrg	    absdir="$dir"
152417a48c7cSmrg	    notinst_path="$notinst_path $dir"
152517a48c7cSmrg	  fi
152617a48c7cSmrg	  dir="$absdir"
152717a48c7cSmrg	  ;;
152817a48c7cSmrg	esac
152917a48c7cSmrg	case "$deplibs " in
153017a48c7cSmrg	*" -L$dir "*) ;;
153117a48c7cSmrg	*)
153217a48c7cSmrg	  deplibs="$deplibs -L$dir"
153317a48c7cSmrg	  lib_search_path="$lib_search_path $dir"
153417a48c7cSmrg	  ;;
153517a48c7cSmrg	esac
153617a48c7cSmrg	case $host in
153717a48c7cSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
153817a48c7cSmrg	  testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'`
153917a48c7cSmrg	  case :$dllsearchpath: in
154017a48c7cSmrg	  *":$dir:"*) ;;
154117a48c7cSmrg	  *) dllsearchpath="$dllsearchpath:$dir";;
154217a48c7cSmrg	  esac
154317a48c7cSmrg	  case :$dllsearchpath: in
154417a48c7cSmrg	  *":$testbindir:"*) ;;
154517a48c7cSmrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
154617a48c7cSmrg	  esac
154717a48c7cSmrg	  ;;
154817a48c7cSmrg	esac
154917a48c7cSmrg	continue
155017a48c7cSmrg	;;
155117a48c7cSmrg
155217a48c7cSmrg      -l*)
155317a48c7cSmrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
155417a48c7cSmrg	  case $host in
155517a48c7cSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*)
155617a48c7cSmrg	    # These systems don't actually have a C or math library (as such)
155717a48c7cSmrg	    continue
155817a48c7cSmrg	    ;;
155917a48c7cSmrg	  *-*-os2*)
156017a48c7cSmrg	    # These systems don't actually have a C library (as such)
156117a48c7cSmrg	    test "X$arg" = "X-lc" && continue
156217a48c7cSmrg	    ;;
156317a48c7cSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
156417a48c7cSmrg	    # Do not include libc due to us having libc/libc_r.
156517a48c7cSmrg	    test "X$arg" = "X-lc" && continue
156617a48c7cSmrg	    ;;
156717a48c7cSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
156817a48c7cSmrg	    # Rhapsody C and math libraries are in the System framework
156917a48c7cSmrg	    deplibs="$deplibs -framework System"
157017a48c7cSmrg	    continue
157117a48c7cSmrg	    ;;
157217a48c7cSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
157317a48c7cSmrg	    # Causes problems with __ctype
157417a48c7cSmrg	    test "X$arg" = "X-lc" && continue
157517a48c7cSmrg	    ;;
157617a48c7cSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
157717a48c7cSmrg	    # Compiler inserts libc in the correct place for threads to work
157817a48c7cSmrg	    test "X$arg" = "X-lc" && continue
157917a48c7cSmrg	    ;;
158017a48c7cSmrg	  esac
158117a48c7cSmrg	elif test "X$arg" = "X-lc_r"; then
158217a48c7cSmrg	 case $host in
158317a48c7cSmrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
158417a48c7cSmrg	   # Do not include libc_r directly, use -pthread flag.
158517a48c7cSmrg	   continue
158617a48c7cSmrg	   ;;
158717a48c7cSmrg	 esac
158817a48c7cSmrg	fi
158917a48c7cSmrg	deplibs="$deplibs $arg"
159017a48c7cSmrg	continue
159117a48c7cSmrg	;;
159217a48c7cSmrg
159317a48c7cSmrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
159417a48c7cSmrg      # classes, name mangling, and exception handling.
159517a48c7cSmrg      -model)
159617a48c7cSmrg	compile_command="$compile_command $arg"
159717a48c7cSmrg	compiler_flags="$compiler_flags $arg"
159817a48c7cSmrg	finalize_command="$finalize_command $arg"
159917a48c7cSmrg	prev=xcompiler
160017a48c7cSmrg	continue
160117a48c7cSmrg	;;
160217a48c7cSmrg
160317a48c7cSmrg     -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
160417a48c7cSmrg	compiler_flags="$compiler_flags $arg"
160517a48c7cSmrg	compile_command="$compile_command $arg"
160617a48c7cSmrg	finalize_command="$finalize_command $arg"
160717a48c7cSmrg	continue
160817a48c7cSmrg	;;
160917a48c7cSmrg
161017a48c7cSmrg      -module)
161117a48c7cSmrg	module=yes
161217a48c7cSmrg	continue
161317a48c7cSmrg	;;
161417a48c7cSmrg
161517a48c7cSmrg      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
161617a48c7cSmrg      # -r[0-9][0-9]* specifies the processor on the SGI compiler
161717a48c7cSmrg      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
161817a48c7cSmrg      # +DA*, +DD* enable 64-bit mode on the HP compiler
161917a48c7cSmrg      # -q* pass through compiler args for the IBM compiler
162017a48c7cSmrg      # -m* pass through architecture-specific compiler args for GCC
162117a48c7cSmrg      # -m*, -t[45]*, -txscale* pass through architecture-specific
162217a48c7cSmrg      # compiler args for GCC
162317a48c7cSmrg      # -pg pass through profiling flag for GCC
162417a48c7cSmrg      # @file GCC response files
162517a48c7cSmrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*|-pg| \
162617a48c7cSmrg      -t[45]*|-txscale*|@*)
162717a48c7cSmrg
162817a48c7cSmrg	# Unknown arguments in both finalize_command and compile_command need
162917a48c7cSmrg	# to be aesthetically quoted because they are evaled later.
163017a48c7cSmrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
163117a48c7cSmrg	case $arg in
163217a48c7cSmrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
163317a48c7cSmrg	  arg="\"$arg\""
163417a48c7cSmrg	  ;;
163517a48c7cSmrg	esac
163617a48c7cSmrg        compile_command="$compile_command $arg"
163717a48c7cSmrg        finalize_command="$finalize_command $arg"
163817a48c7cSmrg        compiler_flags="$compiler_flags $arg"
163917a48c7cSmrg        continue
164017a48c7cSmrg        ;;
164117a48c7cSmrg
164217a48c7cSmrg      -shrext)
164317a48c7cSmrg	prev=shrext
164417a48c7cSmrg	continue
164517a48c7cSmrg	;;
164617a48c7cSmrg
164717a48c7cSmrg      -no-fast-install)
164817a48c7cSmrg	fast_install=no
164917a48c7cSmrg	continue
165017a48c7cSmrg	;;
165117a48c7cSmrg
165217a48c7cSmrg      -no-install)
165317a48c7cSmrg	case $host in
165417a48c7cSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
165517a48c7cSmrg	  # The PATH hackery in wrapper scripts is required on Windows
165617a48c7cSmrg	  # in order for the loader to find any dlls it needs.
165717a48c7cSmrg	  $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2
165817a48c7cSmrg	  $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2
165917a48c7cSmrg	  fast_install=no
166017a48c7cSmrg	  ;;
166117a48c7cSmrg	*) no_install=yes ;;
166217a48c7cSmrg	esac
166317a48c7cSmrg	continue
166417a48c7cSmrg	;;
166517a48c7cSmrg
166617a48c7cSmrg      -no-undefined)
166717a48c7cSmrg	allow_undefined=no
166817a48c7cSmrg	continue
166917a48c7cSmrg	;;
167017a48c7cSmrg
167117a48c7cSmrg      -objectlist)
167217a48c7cSmrg	prev=objectlist
167317a48c7cSmrg	continue
167417a48c7cSmrg	;;
167517a48c7cSmrg
167617a48c7cSmrg      -o) prev=output ;;
167717a48c7cSmrg
167817a48c7cSmrg      -precious-files-regex)
167917a48c7cSmrg	prev=precious_regex
168017a48c7cSmrg	continue
168117a48c7cSmrg	;;
168217a48c7cSmrg
168317a48c7cSmrg      -release)
168417a48c7cSmrg	prev=release
168517a48c7cSmrg	continue
168617a48c7cSmrg	;;
168717a48c7cSmrg
168817a48c7cSmrg      -rpath)
168917a48c7cSmrg	prev=rpath
169017a48c7cSmrg	continue
169117a48c7cSmrg	;;
169217a48c7cSmrg
169317a48c7cSmrg      -R)
169417a48c7cSmrg	prev=xrpath
169517a48c7cSmrg	continue
169617a48c7cSmrg	;;
169717a48c7cSmrg
169817a48c7cSmrg      -R*)
169917a48c7cSmrg	dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
170017a48c7cSmrg	# We need an absolute path.
170117a48c7cSmrg	case $dir in
170217a48c7cSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
170317a48c7cSmrg	*)
170417a48c7cSmrg	  $echo "$modename: only absolute run-paths are allowed" 1>&2
170517a48c7cSmrg	  exit $EXIT_FAILURE
170617a48c7cSmrg	  ;;
170717a48c7cSmrg	esac
170817a48c7cSmrg	case "$xrpath " in
170917a48c7cSmrg	*" $dir "*) ;;
171017a48c7cSmrg	*) xrpath="$xrpath $dir" ;;
171117a48c7cSmrg	esac
171217a48c7cSmrg	continue
171317a48c7cSmrg	;;
171417a48c7cSmrg
171517a48c7cSmrg      -static)
171617a48c7cSmrg	# The effects of -static are defined in a previous loop.
171717a48c7cSmrg	# We used to do the same as -all-static on platforms that
171817a48c7cSmrg	# didn't have a PIC flag, but the assumption that the effects
171917a48c7cSmrg	# would be equivalent was wrong.  It would break on at least
172017a48c7cSmrg	# Digital Unix and AIX.
172117a48c7cSmrg	continue
172217a48c7cSmrg	;;
172317a48c7cSmrg
172417a48c7cSmrg      -thread-safe)
172517a48c7cSmrg	thread_safe=yes
172617a48c7cSmrg	continue
172717a48c7cSmrg	;;
172817a48c7cSmrg
172917a48c7cSmrg      -version-info)
173017a48c7cSmrg	prev=vinfo
173117a48c7cSmrg	continue
173217a48c7cSmrg	;;
173317a48c7cSmrg      -version-number)
173417a48c7cSmrg	prev=vinfo
173517a48c7cSmrg	vinfo_number=yes
173617a48c7cSmrg	continue
173717a48c7cSmrg	;;
173817a48c7cSmrg
173917a48c7cSmrg      -Wc,*)
174017a48c7cSmrg	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'`
174117a48c7cSmrg	arg=
174217a48c7cSmrg	save_ifs="$IFS"; IFS=','
174317a48c7cSmrg	for flag in $args; do
174417a48c7cSmrg	  IFS="$save_ifs"
174517a48c7cSmrg	  case $flag in
174617a48c7cSmrg	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
174717a48c7cSmrg	    flag="\"$flag\""
174817a48c7cSmrg	    ;;
174917a48c7cSmrg	  esac
175017a48c7cSmrg	  arg="$arg $wl$flag"
175117a48c7cSmrg	  compiler_flags="$compiler_flags $flag"
175217a48c7cSmrg	done
175317a48c7cSmrg	IFS="$save_ifs"
175417a48c7cSmrg	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
175517a48c7cSmrg	;;
175617a48c7cSmrg
175717a48c7cSmrg      -Wl,*)
175817a48c7cSmrg	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'`
175917a48c7cSmrg	arg=
176017a48c7cSmrg	save_ifs="$IFS"; IFS=','
176117a48c7cSmrg	for flag in $args; do
176217a48c7cSmrg	  IFS="$save_ifs"
176317a48c7cSmrg	  case $flag in
176417a48c7cSmrg	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
176517a48c7cSmrg	    flag="\"$flag\""
176617a48c7cSmrg	    ;;
176717a48c7cSmrg	  esac
176817a48c7cSmrg	  arg="$arg $wl$flag"
176917a48c7cSmrg	  compiler_flags="$compiler_flags $wl$flag"
177017a48c7cSmrg	  linker_flags="$linker_flags $flag"
177117a48c7cSmrg	done
177217a48c7cSmrg	IFS="$save_ifs"
177317a48c7cSmrg	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
177417a48c7cSmrg	;;
177517a48c7cSmrg
177617a48c7cSmrg      -Xcompiler)
177717a48c7cSmrg	prev=xcompiler
177817a48c7cSmrg	continue
177917a48c7cSmrg	;;
178017a48c7cSmrg
178117a48c7cSmrg      -Xlinker)
178217a48c7cSmrg	prev=xlinker
178317a48c7cSmrg	continue
178417a48c7cSmrg	;;
178517a48c7cSmrg
178617a48c7cSmrg      -XCClinker)
178717a48c7cSmrg	prev=xcclinker
178817a48c7cSmrg	continue
178917a48c7cSmrg	;;
179017a48c7cSmrg
179117a48c7cSmrg      # Some other compiler flag.
179217a48c7cSmrg      -* | +*)
179317a48c7cSmrg	# Unknown arguments in both finalize_command and compile_command need
179417a48c7cSmrg	# to be aesthetically quoted because they are evaled later.
179517a48c7cSmrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
179617a48c7cSmrg	case $arg in
179717a48c7cSmrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
179817a48c7cSmrg	  arg="\"$arg\""
179917a48c7cSmrg	  ;;
180017a48c7cSmrg	esac
180117a48c7cSmrg	;;
180217a48c7cSmrg
180317a48c7cSmrg      *.$objext)
180417a48c7cSmrg	# A standard object.
180517a48c7cSmrg	objs="$objs $arg"
180617a48c7cSmrg	;;
180717a48c7cSmrg
180817a48c7cSmrg      *.lo)
180917a48c7cSmrg	# A libtool-controlled object.
181017a48c7cSmrg
181117a48c7cSmrg	# Check to see that this really is a libtool object.
181217a48c7cSmrg	if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
181317a48c7cSmrg	  pic_object=
181417a48c7cSmrg	  non_pic_object=
181517a48c7cSmrg
181617a48c7cSmrg	  # Read the .lo file
181717a48c7cSmrg	  # If there is no directory component, then add one.
181817a48c7cSmrg	  case $arg in
181917a48c7cSmrg	  */* | *\\*) . $arg ;;
182017a48c7cSmrg	  *) . ./$arg ;;
182117a48c7cSmrg	  esac
182217a48c7cSmrg
182317a48c7cSmrg	  if test -z "$pic_object" || \
182417a48c7cSmrg	     test -z "$non_pic_object" ||
182517a48c7cSmrg	     test "$pic_object" = none && \
182617a48c7cSmrg	     test "$non_pic_object" = none; then
182717a48c7cSmrg	    $echo "$modename: cannot find name of object for \`$arg'" 1>&2
182817a48c7cSmrg	    exit $EXIT_FAILURE
182917a48c7cSmrg	  fi
183017a48c7cSmrg
183117a48c7cSmrg	  # Extract subdirectory from the argument.
183217a48c7cSmrg	  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
183317a48c7cSmrg	  if test "X$xdir" = "X$arg"; then
183417a48c7cSmrg	    xdir=
183517a48c7cSmrg 	  else
183617a48c7cSmrg	    xdir="$xdir/"
183717a48c7cSmrg	  fi
183817a48c7cSmrg
183917a48c7cSmrg	  if test "$pic_object" != none; then
184017a48c7cSmrg	    # Prepend the subdirectory the object is found in.
184117a48c7cSmrg	    pic_object="$xdir$pic_object"
184217a48c7cSmrg
184317a48c7cSmrg	    if test "$prev" = dlfiles; then
184417a48c7cSmrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
184517a48c7cSmrg		dlfiles="$dlfiles $pic_object"
184617a48c7cSmrg		prev=
184717a48c7cSmrg		continue
184817a48c7cSmrg	      else
184917a48c7cSmrg		# If libtool objects are unsupported, then we need to preload.
185017a48c7cSmrg		prev=dlprefiles
185117a48c7cSmrg	      fi
185217a48c7cSmrg	    fi
185317a48c7cSmrg
185417a48c7cSmrg	    # CHECK ME:  I think I busted this.  -Ossama
185517a48c7cSmrg	    if test "$prev" = dlprefiles; then
185617a48c7cSmrg	      # Preload the old-style object.
185717a48c7cSmrg	      dlprefiles="$dlprefiles $pic_object"
185817a48c7cSmrg	      prev=
185917a48c7cSmrg	    fi
186017a48c7cSmrg
186117a48c7cSmrg	    # A PIC object.
186217a48c7cSmrg	    libobjs="$libobjs $pic_object"
186317a48c7cSmrg	    arg="$pic_object"
186417a48c7cSmrg	  fi
186517a48c7cSmrg
186617a48c7cSmrg	  # Non-PIC object.
186717a48c7cSmrg	  if test "$non_pic_object" != none; then
186817a48c7cSmrg	    # Prepend the subdirectory the object is found in.
186917a48c7cSmrg	    non_pic_object="$xdir$non_pic_object"
187017a48c7cSmrg
187117a48c7cSmrg	    # A standard non-PIC object
187217a48c7cSmrg	    non_pic_objects="$non_pic_objects $non_pic_object"
187317a48c7cSmrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
187417a48c7cSmrg	      arg="$non_pic_object"
187517a48c7cSmrg	    fi
187617a48c7cSmrg	  else
187717a48c7cSmrg	    # If the PIC object exists, use it instead.
187817a48c7cSmrg	    # $xdir was prepended to $pic_object above.
187917a48c7cSmrg	    non_pic_object="$pic_object"
188017a48c7cSmrg	    non_pic_objects="$non_pic_objects $non_pic_object"
188117a48c7cSmrg	  fi
188217a48c7cSmrg	else
188317a48c7cSmrg	  # Only an error if not doing a dry-run.
188417a48c7cSmrg	  if test -z "$run"; then
188517a48c7cSmrg	    $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
188617a48c7cSmrg	    exit $EXIT_FAILURE
188717a48c7cSmrg	  else
188817a48c7cSmrg	    # Dry-run case.
188917a48c7cSmrg
189017a48c7cSmrg	    # Extract subdirectory from the argument.
189117a48c7cSmrg	    xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
189217a48c7cSmrg	    if test "X$xdir" = "X$arg"; then
189317a48c7cSmrg	      xdir=
189417a48c7cSmrg	    else
189517a48c7cSmrg	      xdir="$xdir/"
189617a48c7cSmrg	    fi
189717a48c7cSmrg
189817a48c7cSmrg	    pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
189917a48c7cSmrg	    non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
190017a48c7cSmrg	    libobjs="$libobjs $pic_object"
190117a48c7cSmrg	    non_pic_objects="$non_pic_objects $non_pic_object"
190217a48c7cSmrg	  fi
190317a48c7cSmrg	fi
190417a48c7cSmrg	;;
190517a48c7cSmrg
190617a48c7cSmrg      *.$libext)
190717a48c7cSmrg	# An archive.
190817a48c7cSmrg	deplibs="$deplibs $arg"
190917a48c7cSmrg	old_deplibs="$old_deplibs $arg"
191017a48c7cSmrg	continue
191117a48c7cSmrg	;;
191217a48c7cSmrg
191317a48c7cSmrg      *.la)
191417a48c7cSmrg	# A libtool-controlled library.
191517a48c7cSmrg
191617a48c7cSmrg	if test "$prev" = dlfiles; then
191717a48c7cSmrg	  # This library was specified with -dlopen.
191817a48c7cSmrg	  dlfiles="$dlfiles $arg"
191917a48c7cSmrg	  prev=
192017a48c7cSmrg	elif test "$prev" = dlprefiles; then
192117a48c7cSmrg	  # The library was specified with -dlpreopen.
192217a48c7cSmrg	  dlprefiles="$dlprefiles $arg"
192317a48c7cSmrg	  prev=
192417a48c7cSmrg	else
192517a48c7cSmrg	  deplibs="$deplibs $arg"
192617a48c7cSmrg	fi
192717a48c7cSmrg	continue
192817a48c7cSmrg	;;
192917a48c7cSmrg
193017a48c7cSmrg      # Some other compiler argument.
193117a48c7cSmrg      *)
193217a48c7cSmrg	# Unknown arguments in both finalize_command and compile_command need
193317a48c7cSmrg	# to be aesthetically quoted because they are evaled later.
193417a48c7cSmrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
193517a48c7cSmrg	case $arg in
193617a48c7cSmrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
193717a48c7cSmrg	  arg="\"$arg\""
193817a48c7cSmrg	  ;;
193917a48c7cSmrg	esac
194017a48c7cSmrg	;;
194117a48c7cSmrg      esac # arg
194217a48c7cSmrg
194317a48c7cSmrg      # Now actually substitute the argument into the commands.
194417a48c7cSmrg      if test -n "$arg"; then
194517a48c7cSmrg	compile_command="$compile_command $arg"
194617a48c7cSmrg	finalize_command="$finalize_command $arg"
194717a48c7cSmrg      fi
194817a48c7cSmrg    done # argument parsing loop
194917a48c7cSmrg
195017a48c7cSmrg    if test -n "$prev"; then
195117a48c7cSmrg      $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
195217a48c7cSmrg      $echo "$help" 1>&2
195317a48c7cSmrg      exit $EXIT_FAILURE
195417a48c7cSmrg    fi
195517a48c7cSmrg
195617a48c7cSmrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
195717a48c7cSmrg      eval arg=\"$export_dynamic_flag_spec\"
195817a48c7cSmrg      compile_command="$compile_command $arg"
195917a48c7cSmrg      finalize_command="$finalize_command $arg"
196017a48c7cSmrg    fi
196117a48c7cSmrg
196217a48c7cSmrg    oldlibs=
196317a48c7cSmrg    # calculate the name of the file, without its directory
196417a48c7cSmrg    outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
196517a48c7cSmrg    libobjs_save="$libobjs"
196617a48c7cSmrg
196717a48c7cSmrg    if test -n "$shlibpath_var"; then
196817a48c7cSmrg      # get the directories listed in $shlibpath_var
196917a48c7cSmrg      eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
197017a48c7cSmrg    else
197117a48c7cSmrg      shlib_search_path=
197217a48c7cSmrg    fi
197317a48c7cSmrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
197417a48c7cSmrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
197517a48c7cSmrg
197617a48c7cSmrg    output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
197717a48c7cSmrg    if test "X$output_objdir" = "X$output"; then
197817a48c7cSmrg      output_objdir="$objdir"
197917a48c7cSmrg    else
198017a48c7cSmrg      output_objdir="$output_objdir/$objdir"
198117a48c7cSmrg    fi
198217a48c7cSmrg    # Create the object directory.
198317a48c7cSmrg    if test ! -d "$output_objdir"; then
198417a48c7cSmrg      $show "$mkdir $output_objdir"
198517a48c7cSmrg      $run $mkdir $output_objdir
198617a48c7cSmrg      exit_status=$?
198717a48c7cSmrg      if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then
198817a48c7cSmrg	exit $exit_status
198917a48c7cSmrg      fi
199017a48c7cSmrg    fi
199117a48c7cSmrg
199217a48c7cSmrg    # Determine the type of output
199317a48c7cSmrg    case $output in
199417a48c7cSmrg    "")
199517a48c7cSmrg      $echo "$modename: you must specify an output file" 1>&2
199617a48c7cSmrg      $echo "$help" 1>&2
199717a48c7cSmrg      exit $EXIT_FAILURE
199817a48c7cSmrg      ;;
199917a48c7cSmrg    *.$libext) linkmode=oldlib ;;
200017a48c7cSmrg    *.lo | *.$objext) linkmode=obj ;;
200117a48c7cSmrg    *.la) linkmode=lib ;;
200217a48c7cSmrg    *) linkmode=prog ;; # Anything else should be a program.
200317a48c7cSmrg    esac
200417a48c7cSmrg
200517a48c7cSmrg    case $host in
200617a48c7cSmrg    *cygwin* | *mingw* | *pw32*)
200717a48c7cSmrg      # don't eliminate duplications in $postdeps and $predeps
200817a48c7cSmrg      duplicate_compiler_generated_deps=yes
200917a48c7cSmrg      ;;
201017a48c7cSmrg    *)
201117a48c7cSmrg      duplicate_compiler_generated_deps=$duplicate_deps
201217a48c7cSmrg      ;;
201317a48c7cSmrg    esac
201417a48c7cSmrg    specialdeplibs=
201517a48c7cSmrg
201617a48c7cSmrg    libs=
201717a48c7cSmrg    # Find all interdependent deplibs by searching for libraries
201817a48c7cSmrg    # that are linked more than once (e.g. -la -lb -la)
201917a48c7cSmrg    for deplib in $deplibs; do
202017a48c7cSmrg      if test "X$duplicate_deps" = "Xyes" ; then
202117a48c7cSmrg	case "$libs " in
202217a48c7cSmrg	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
202317a48c7cSmrg	esac
202417a48c7cSmrg      fi
202517a48c7cSmrg      libs="$libs $deplib"
202617a48c7cSmrg    done
202717a48c7cSmrg
202817a48c7cSmrg    if test "$linkmode" = lib; then
202917a48c7cSmrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
203017a48c7cSmrg
203117a48c7cSmrg      # Compute libraries that are listed more than once in $predeps
203217a48c7cSmrg      # $postdeps and mark them as special (i.e., whose duplicates are
203317a48c7cSmrg      # not to be eliminated).
203417a48c7cSmrg      pre_post_deps=
203517a48c7cSmrg      if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then
203617a48c7cSmrg	for pre_post_dep in $predeps $postdeps; do
203717a48c7cSmrg	  case "$pre_post_deps " in
203817a48c7cSmrg	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
203917a48c7cSmrg	  esac
204017a48c7cSmrg	  pre_post_deps="$pre_post_deps $pre_post_dep"
204117a48c7cSmrg	done
204217a48c7cSmrg      fi
204317a48c7cSmrg      pre_post_deps=
204417a48c7cSmrg    fi
204517a48c7cSmrg
204617a48c7cSmrg    deplibs=
204717a48c7cSmrg    newdependency_libs=
204817a48c7cSmrg    newlib_search_path=
204917a48c7cSmrg    need_relink=no # whether we're linking any uninstalled libtool libraries
205017a48c7cSmrg    notinst_deplibs= # not-installed libtool libraries
205117a48c7cSmrg    case $linkmode in
205217a48c7cSmrg    lib)
205317a48c7cSmrg	passes="conv link"
205417a48c7cSmrg	for file in $dlfiles $dlprefiles; do
205517a48c7cSmrg	  case $file in
205617a48c7cSmrg	  *.la) ;;
205717a48c7cSmrg	  *)
205817a48c7cSmrg	    $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2
205917a48c7cSmrg	    exit $EXIT_FAILURE
206017a48c7cSmrg	    ;;
206117a48c7cSmrg	  esac
206217a48c7cSmrg	done
206317a48c7cSmrg	;;
206417a48c7cSmrg    prog)
206517a48c7cSmrg	compile_deplibs=
206617a48c7cSmrg	finalize_deplibs=
206717a48c7cSmrg	alldeplibs=no
206817a48c7cSmrg	newdlfiles=
206917a48c7cSmrg	newdlprefiles=
207017a48c7cSmrg	passes="conv scan dlopen dlpreopen link"
207117a48c7cSmrg	;;
207217a48c7cSmrg    *)  passes="conv"
207317a48c7cSmrg	;;
207417a48c7cSmrg    esac
207517a48c7cSmrg    for pass in $passes; do
207617a48c7cSmrg      if test "$linkmode,$pass" = "lib,link" ||
207717a48c7cSmrg	 test "$linkmode,$pass" = "prog,scan"; then
207817a48c7cSmrg	libs="$deplibs"
207917a48c7cSmrg	deplibs=
208017a48c7cSmrg      fi
208117a48c7cSmrg      if test "$linkmode" = prog; then
208217a48c7cSmrg	case $pass in
208317a48c7cSmrg	dlopen) libs="$dlfiles" ;;
208417a48c7cSmrg	dlpreopen) libs="$dlprefiles" ;;
208517a48c7cSmrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
208617a48c7cSmrg	esac
208717a48c7cSmrg      fi
208817a48c7cSmrg      if test "$pass" = dlopen; then
208917a48c7cSmrg	# Collect dlpreopened libraries
209017a48c7cSmrg	save_deplibs="$deplibs"
209117a48c7cSmrg	deplibs=
209217a48c7cSmrg      fi
209317a48c7cSmrg      for deplib in $libs; do
209417a48c7cSmrg	lib=
209517a48c7cSmrg	found=no
209617a48c7cSmrg	case $deplib in
209717a48c7cSmrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
209817a48c7cSmrg	  if test "$linkmode,$pass" = "prog,link"; then
209917a48c7cSmrg	    compile_deplibs="$deplib $compile_deplibs"
210017a48c7cSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
210117a48c7cSmrg	  else
210217a48c7cSmrg	    compiler_flags="$compiler_flags $deplib"
210317a48c7cSmrg	  fi
210417a48c7cSmrg	  continue
210517a48c7cSmrg	  ;;
210617a48c7cSmrg	-l*)
210717a48c7cSmrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
210817a48c7cSmrg	    $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2
210917a48c7cSmrg	    continue
211017a48c7cSmrg	  fi
211117a48c7cSmrg	  name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
211217a48c7cSmrg	  for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do
211317a48c7cSmrg	    for search_ext in .la $std_shrext .so .a; do
211417a48c7cSmrg	      # Search the libtool library
211517a48c7cSmrg	      lib="$searchdir/lib${name}${search_ext}"
211617a48c7cSmrg	      if test -f "$lib"; then
211717a48c7cSmrg		if test "$search_ext" = ".la"; then
211817a48c7cSmrg		  found=yes
211917a48c7cSmrg		else
212017a48c7cSmrg		  found=no
212117a48c7cSmrg		fi
212217a48c7cSmrg		break 2
212317a48c7cSmrg	      fi
212417a48c7cSmrg	    done
212517a48c7cSmrg	  done
212617a48c7cSmrg	  if test "$found" != yes; then
212717a48c7cSmrg	    # deplib doesn't seem to be a libtool library
212817a48c7cSmrg	    if test "$linkmode,$pass" = "prog,link"; then
212917a48c7cSmrg	      compile_deplibs="$deplib $compile_deplibs"
213017a48c7cSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
213117a48c7cSmrg	    else
213217a48c7cSmrg	      deplibs="$deplib $deplibs"
213317a48c7cSmrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
213417a48c7cSmrg	    fi
213517a48c7cSmrg	    continue
213617a48c7cSmrg	  else # deplib is a libtool library
213717a48c7cSmrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
213817a48c7cSmrg	    # We need to do some special things here, and not later.
213917a48c7cSmrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
214017a48c7cSmrg	      case " $predeps $postdeps " in
214117a48c7cSmrg	      *" $deplib "*)
214217a48c7cSmrg		if (${SED} -e '2q' $lib |
214317a48c7cSmrg                    grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
214417a48c7cSmrg		  library_names=
214517a48c7cSmrg		  old_library=
214617a48c7cSmrg		  case $lib in
214717a48c7cSmrg		  */* | *\\*) . $lib ;;
214817a48c7cSmrg		  *) . ./$lib ;;
214917a48c7cSmrg		  esac
215017a48c7cSmrg		  for l in $old_library $library_names; do
215117a48c7cSmrg		    ll="$l"
215217a48c7cSmrg		  done
215317a48c7cSmrg		  if test "X$ll" = "X$old_library" ; then # only static version available
215417a48c7cSmrg		    found=no
215517a48c7cSmrg		    ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
215617a48c7cSmrg		    test "X$ladir" = "X$lib" && ladir="."
215717a48c7cSmrg		    lib=$ladir/$old_library
215817a48c7cSmrg		    if test "$linkmode,$pass" = "prog,link"; then
215917a48c7cSmrg		      compile_deplibs="$deplib $compile_deplibs"
216017a48c7cSmrg		      finalize_deplibs="$deplib $finalize_deplibs"
216117a48c7cSmrg		    else
216217a48c7cSmrg		      deplibs="$deplib $deplibs"
216317a48c7cSmrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
216417a48c7cSmrg		    fi
216517a48c7cSmrg		    continue
216617a48c7cSmrg		  fi
216717a48c7cSmrg		fi
216817a48c7cSmrg	        ;;
216917a48c7cSmrg	      *) ;;
217017a48c7cSmrg	      esac
217117a48c7cSmrg	    fi
217217a48c7cSmrg	  fi
217317a48c7cSmrg	  ;; # -l
217417a48c7cSmrg	-L*)
217517a48c7cSmrg	  case $linkmode in
217617a48c7cSmrg	  lib)
217717a48c7cSmrg	    deplibs="$deplib $deplibs"
217817a48c7cSmrg	    test "$pass" = conv && continue
217917a48c7cSmrg	    newdependency_libs="$deplib $newdependency_libs"
218017a48c7cSmrg	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
218117a48c7cSmrg	    ;;
218217a48c7cSmrg	  prog)
218317a48c7cSmrg	    if test "$pass" = conv; then
218417a48c7cSmrg	      deplibs="$deplib $deplibs"
218517a48c7cSmrg	      continue
218617a48c7cSmrg	    fi
218717a48c7cSmrg	    if test "$pass" = scan; then
218817a48c7cSmrg	      deplibs="$deplib $deplibs"
218917a48c7cSmrg	    else
219017a48c7cSmrg	      compile_deplibs="$deplib $compile_deplibs"
219117a48c7cSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
219217a48c7cSmrg	    fi
219317a48c7cSmrg	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
219417a48c7cSmrg	    ;;
219517a48c7cSmrg	  *)
219617a48c7cSmrg	    $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2
219717a48c7cSmrg	    ;;
219817a48c7cSmrg	  esac # linkmode
219917a48c7cSmrg	  continue
220017a48c7cSmrg	  ;; # -L
220117a48c7cSmrg	-R*)
220217a48c7cSmrg	  if test "$pass" = link; then
220317a48c7cSmrg	    dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
220417a48c7cSmrg	    # Make sure the xrpath contains only unique directories.
220517a48c7cSmrg	    case "$xrpath " in
220617a48c7cSmrg	    *" $dir "*) ;;
220717a48c7cSmrg	    *) xrpath="$xrpath $dir" ;;
220817a48c7cSmrg	    esac
220917a48c7cSmrg	  fi
221017a48c7cSmrg	  deplibs="$deplib $deplibs"
221117a48c7cSmrg	  continue
221217a48c7cSmrg	  ;;
221317a48c7cSmrg	*.la) lib="$deplib" ;;
221417a48c7cSmrg	*.$libext)
221517a48c7cSmrg	  if test "$pass" = conv; then
221617a48c7cSmrg	    deplibs="$deplib $deplibs"
221717a48c7cSmrg	    continue
221817a48c7cSmrg	  fi
221917a48c7cSmrg	  case $linkmode in
222017a48c7cSmrg	  lib)
222117a48c7cSmrg	    valid_a_lib=no
222217a48c7cSmrg	    case $deplibs_check_method in
222317a48c7cSmrg	      match_pattern*)
222417a48c7cSmrg		set dummy $deplibs_check_method
222517a48c7cSmrg	        match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
222617a48c7cSmrg		if eval $echo \"$deplib\" 2>/dev/null \
222717a48c7cSmrg		    | $SED 10q \
222817a48c7cSmrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
222917a48c7cSmrg		  valid_a_lib=yes
223017a48c7cSmrg		fi
223117a48c7cSmrg		;;
223217a48c7cSmrg	      pass_all)
223317a48c7cSmrg		valid_a_lib=yes
223417a48c7cSmrg		;;
223517a48c7cSmrg            esac
223617a48c7cSmrg	    if test "$valid_a_lib" != yes; then
223717a48c7cSmrg	      $echo
223817a48c7cSmrg	      $echo "*** Warning: Trying to link with static lib archive $deplib."
223917a48c7cSmrg	      $echo "*** I have the capability to make that library automatically link in when"
224017a48c7cSmrg	      $echo "*** you link to this library.  But I can only do this if you have a"
224117a48c7cSmrg	      $echo "*** shared version of the library, which you do not appear to have"
224217a48c7cSmrg	      $echo "*** because the file extensions .$libext of this argument makes me believe"
224317a48c7cSmrg	      $echo "*** that it is just a static archive that I should not used here."
224417a48c7cSmrg	    else
224517a48c7cSmrg	      $echo
224617a48c7cSmrg	      $echo "*** Warning: Linking the shared library $output against the"
224717a48c7cSmrg	      $echo "*** static library $deplib is not portable!"
224817a48c7cSmrg	      deplibs="$deplib $deplibs"
224917a48c7cSmrg	    fi
225017a48c7cSmrg	    continue
225117a48c7cSmrg	    ;;
225217a48c7cSmrg	  prog)
225317a48c7cSmrg	    if test "$pass" != link; then
225417a48c7cSmrg	      deplibs="$deplib $deplibs"
225517a48c7cSmrg	    else
225617a48c7cSmrg	      compile_deplibs="$deplib $compile_deplibs"
225717a48c7cSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
225817a48c7cSmrg	    fi
225917a48c7cSmrg	    continue
226017a48c7cSmrg	    ;;
226117a48c7cSmrg	  esac # linkmode
226217a48c7cSmrg	  ;; # *.$libext
226317a48c7cSmrg	*.lo | *.$objext)
226417a48c7cSmrg	  if test "$pass" = conv; then
226517a48c7cSmrg	    deplibs="$deplib $deplibs"
226617a48c7cSmrg	  elif test "$linkmode" = prog; then
226717a48c7cSmrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
226817a48c7cSmrg	      # If there is no dlopen support or we're linking statically,
226917a48c7cSmrg	      # we need to preload.
227017a48c7cSmrg	      newdlprefiles="$newdlprefiles $deplib"
227117a48c7cSmrg	      compile_deplibs="$deplib $compile_deplibs"
227217a48c7cSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
227317a48c7cSmrg	    else
227417a48c7cSmrg	      newdlfiles="$newdlfiles $deplib"
227517a48c7cSmrg	    fi
227617a48c7cSmrg	  fi
227717a48c7cSmrg	  continue
227817a48c7cSmrg	  ;;
227917a48c7cSmrg	%DEPLIBS%)
228017a48c7cSmrg	  alldeplibs=yes
228117a48c7cSmrg	  continue
228217a48c7cSmrg	  ;;
228317a48c7cSmrg	esac # case $deplib
228417a48c7cSmrg	if test "$found" = yes || test -f "$lib"; then :
228517a48c7cSmrg	else
228617a48c7cSmrg	  $echo "$modename: cannot find the library \`$lib' or unhandled argument \`$deplib'" 1>&2
228717a48c7cSmrg	  exit $EXIT_FAILURE
228817a48c7cSmrg	fi
228917a48c7cSmrg
229017a48c7cSmrg	# Check to see that this really is a libtool archive.
229117a48c7cSmrg	if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
229217a48c7cSmrg	else
229317a48c7cSmrg	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
229417a48c7cSmrg	  exit $EXIT_FAILURE
229517a48c7cSmrg	fi
229617a48c7cSmrg
229717a48c7cSmrg	ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
229817a48c7cSmrg	test "X$ladir" = "X$lib" && ladir="."
229917a48c7cSmrg
230017a48c7cSmrg	dlname=
230117a48c7cSmrg	dlopen=
230217a48c7cSmrg	dlpreopen=
230317a48c7cSmrg	libdir=
230417a48c7cSmrg	library_names=
230517a48c7cSmrg	old_library=
230617a48c7cSmrg	# If the library was installed with an old release of libtool,
230717a48c7cSmrg	# it will not redefine variables installed, or shouldnotlink
230817a48c7cSmrg	installed=yes
230917a48c7cSmrg	shouldnotlink=no
231017a48c7cSmrg	avoidtemprpath=
231117a48c7cSmrg
231217a48c7cSmrg
231317a48c7cSmrg	# Read the .la file
231417a48c7cSmrg	case $lib in
231517a48c7cSmrg	*/* | *\\*) . $lib ;;
231617a48c7cSmrg	*) . ./$lib ;;
231717a48c7cSmrg	esac
231817a48c7cSmrg
231917a48c7cSmrg	if test "$linkmode,$pass" = "lib,link" ||
232017a48c7cSmrg	   test "$linkmode,$pass" = "prog,scan" ||
232117a48c7cSmrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
232217a48c7cSmrg	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
232317a48c7cSmrg	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
232417a48c7cSmrg	fi
232517a48c7cSmrg
232617a48c7cSmrg	if test "$pass" = conv; then
232717a48c7cSmrg	  # Only check for convenience libraries
232817a48c7cSmrg	  deplibs="$lib $deplibs"
232917a48c7cSmrg	  if test -z "$libdir"; then
233017a48c7cSmrg	    if test -z "$old_library"; then
233117a48c7cSmrg	      $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
233217a48c7cSmrg	      exit $EXIT_FAILURE
233317a48c7cSmrg	    fi
233417a48c7cSmrg	    # It is a libtool convenience library, so add in its objects.
233517a48c7cSmrg	    convenience="$convenience $ladir/$objdir/$old_library"
233617a48c7cSmrg	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
233717a48c7cSmrg	    tmp_libs=
233817a48c7cSmrg	    for deplib in $dependency_libs; do
233917a48c7cSmrg	      deplibs="$deplib $deplibs"
234017a48c7cSmrg              if test "X$duplicate_deps" = "Xyes" ; then
234117a48c7cSmrg	        case "$tmp_libs " in
234217a48c7cSmrg	        *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
234317a48c7cSmrg	        esac
234417a48c7cSmrg              fi
234517a48c7cSmrg	      tmp_libs="$tmp_libs $deplib"
234617a48c7cSmrg	    done
234717a48c7cSmrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
234817a48c7cSmrg	    $echo "$modename: \`$lib' is not a convenience library" 1>&2
234917a48c7cSmrg	    exit $EXIT_FAILURE
235017a48c7cSmrg	  fi
235117a48c7cSmrg	  continue
235217a48c7cSmrg	fi # $pass = conv
235317a48c7cSmrg
235417a48c7cSmrg
235517a48c7cSmrg	# Get the name of the library we link against.
235617a48c7cSmrg	linklib=
235717a48c7cSmrg	for l in $old_library $library_names; do
235817a48c7cSmrg	  linklib="$l"
235917a48c7cSmrg	done
236017a48c7cSmrg	if test -z "$linklib"; then
236117a48c7cSmrg	  $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
236217a48c7cSmrg	  exit $EXIT_FAILURE
236317a48c7cSmrg	fi
236417a48c7cSmrg
236517a48c7cSmrg	# This library was specified with -dlopen.
236617a48c7cSmrg	if test "$pass" = dlopen; then
236717a48c7cSmrg	  if test -z "$libdir"; then
236817a48c7cSmrg	    $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2
236917a48c7cSmrg	    exit $EXIT_FAILURE
237017a48c7cSmrg	  fi
237117a48c7cSmrg	  if test -z "$dlname" ||
237217a48c7cSmrg	     test "$dlopen_support" != yes ||
237317a48c7cSmrg	     test "$build_libtool_libs" = no; then
237417a48c7cSmrg	    # If there is no dlname, no dlopen support or we're linking
237517a48c7cSmrg	    # statically, we need to preload.  We also need to preload any
237617a48c7cSmrg	    # dependent libraries so libltdl's deplib preloader doesn't
237717a48c7cSmrg	    # bomb out in the load deplibs phase.
237817a48c7cSmrg	    dlprefiles="$dlprefiles $lib $dependency_libs"
237917a48c7cSmrg	  else
238017a48c7cSmrg	    newdlfiles="$newdlfiles $lib"
238117a48c7cSmrg	  fi
238217a48c7cSmrg	  continue
238317a48c7cSmrg	fi # $pass = dlopen
238417a48c7cSmrg
238517a48c7cSmrg	# We need an absolute path.
238617a48c7cSmrg	case $ladir in
238717a48c7cSmrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
238817a48c7cSmrg	*)
238917a48c7cSmrg	  abs_ladir=`cd "$ladir" && pwd`
239017a48c7cSmrg	  if test -z "$abs_ladir"; then
239117a48c7cSmrg	    $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2
239217a48c7cSmrg	    $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
239317a48c7cSmrg	    abs_ladir="$ladir"
239417a48c7cSmrg	  fi
239517a48c7cSmrg	  ;;
239617a48c7cSmrg	esac
239717a48c7cSmrg	laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
239817a48c7cSmrg
239917a48c7cSmrg	# Find the relevant object directory and library name.
240017a48c7cSmrg	if test "X$installed" = Xyes; then
240117a48c7cSmrg	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
240217a48c7cSmrg	    $echo "$modename: warning: library \`$lib' was moved." 1>&2
240317a48c7cSmrg	    dir="$ladir"
240417a48c7cSmrg	    absdir="$abs_ladir"
240517a48c7cSmrg	    libdir="$abs_ladir"
240617a48c7cSmrg	  else
240717a48c7cSmrg	    dir="$libdir"
240817a48c7cSmrg	    absdir="$libdir"
240917a48c7cSmrg	  fi
241017a48c7cSmrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
241117a48c7cSmrg	else
241217a48c7cSmrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
241317a48c7cSmrg	    dir="$ladir"
241417a48c7cSmrg	    absdir="$abs_ladir"
241517a48c7cSmrg	    # Remove this search path later
241617a48c7cSmrg	    notinst_path="$notinst_path $abs_ladir"
241717a48c7cSmrg	  else
241817a48c7cSmrg	    dir="$ladir/$objdir"
241917a48c7cSmrg	    absdir="$abs_ladir/$objdir"
242017a48c7cSmrg	    # Remove this search path later
242117a48c7cSmrg	    notinst_path="$notinst_path $abs_ladir"
242217a48c7cSmrg	  fi
242317a48c7cSmrg	fi # $installed = yes
242417a48c7cSmrg	name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
242517a48c7cSmrg
242617a48c7cSmrg	# This library was specified with -dlpreopen.
242717a48c7cSmrg	if test "$pass" = dlpreopen; then
242817a48c7cSmrg	  if test -z "$libdir"; then
242917a48c7cSmrg	    $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2
243017a48c7cSmrg	    exit $EXIT_FAILURE
243117a48c7cSmrg	  fi
243217a48c7cSmrg	  # Prefer using a static library (so that no silly _DYNAMIC symbols
243317a48c7cSmrg	  # are required to link).
243417a48c7cSmrg	  if test -n "$old_library"; then
243517a48c7cSmrg	    newdlprefiles="$newdlprefiles $dir/$old_library"
243617a48c7cSmrg	  # Otherwise, use the dlname, so that lt_dlopen finds it.
243717a48c7cSmrg	  elif test -n "$dlname"; then
243817a48c7cSmrg	    newdlprefiles="$newdlprefiles $dir/$dlname"
243917a48c7cSmrg	  else
244017a48c7cSmrg	    newdlprefiles="$newdlprefiles $dir/$linklib"
244117a48c7cSmrg	  fi
244217a48c7cSmrg	fi # $pass = dlpreopen
244317a48c7cSmrg
244417a48c7cSmrg	if test -z "$libdir"; then
244517a48c7cSmrg	  # Link the convenience library
244617a48c7cSmrg	  if test "$linkmode" = lib; then
244717a48c7cSmrg	    deplibs="$dir/$old_library $deplibs"
244817a48c7cSmrg	  elif test "$linkmode,$pass" = "prog,link"; then
244917a48c7cSmrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
245017a48c7cSmrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
245117a48c7cSmrg	  else
245217a48c7cSmrg	    deplibs="$lib $deplibs" # used for prog,scan pass
245317a48c7cSmrg	  fi
245417a48c7cSmrg	  continue
245517a48c7cSmrg	fi
245617a48c7cSmrg
245717a48c7cSmrg
245817a48c7cSmrg	if test "$linkmode" = prog && test "$pass" != link; then
245917a48c7cSmrg	  newlib_search_path="$newlib_search_path $ladir"
246017a48c7cSmrg	  deplibs="$lib $deplibs"
246117a48c7cSmrg
246217a48c7cSmrg	  linkalldeplibs=no
246317a48c7cSmrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
246417a48c7cSmrg	     test "$build_libtool_libs" = no; then
246517a48c7cSmrg	    linkalldeplibs=yes
246617a48c7cSmrg	  fi
246717a48c7cSmrg
246817a48c7cSmrg	  tmp_libs=
246917a48c7cSmrg	  for deplib in $dependency_libs; do
247017a48c7cSmrg	    case $deplib in
247117a48c7cSmrg	    -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test
247217a48c7cSmrg	    esac
247317a48c7cSmrg	    # Need to link against all dependency_libs?
247417a48c7cSmrg	    if test "$linkalldeplibs" = yes; then
247517a48c7cSmrg	      deplibs="$deplib $deplibs"
247617a48c7cSmrg	    else
247717a48c7cSmrg	      # Need to hardcode shared library paths
247817a48c7cSmrg	      # or/and link against static libraries
247917a48c7cSmrg	      newdependency_libs="$deplib $newdependency_libs"
248017a48c7cSmrg	    fi
248117a48c7cSmrg	    if test "X$duplicate_deps" = "Xyes" ; then
248217a48c7cSmrg	      case "$tmp_libs " in
248317a48c7cSmrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
248417a48c7cSmrg	      esac
248517a48c7cSmrg	    fi
248617a48c7cSmrg	    tmp_libs="$tmp_libs $deplib"
248717a48c7cSmrg	  done # for deplib
248817a48c7cSmrg	  continue
248917a48c7cSmrg	fi # $linkmode = prog...
249017a48c7cSmrg
249117a48c7cSmrg	if test "$linkmode,$pass" = "prog,link"; then
249217a48c7cSmrg	  if test -n "$library_names" &&
249317a48c7cSmrg	     { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
249417a48c7cSmrg	    # We need to hardcode the library path
249517a48c7cSmrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
249617a48c7cSmrg	      # Make sure the rpath contains only unique directories.
249717a48c7cSmrg	      case "$temp_rpath " in
249817a48c7cSmrg	      *" $dir "*) ;;
249917a48c7cSmrg	      *" $absdir "*) ;;
250017a48c7cSmrg	      *) temp_rpath="$temp_rpath $absdir" ;;
250117a48c7cSmrg	      esac
250217a48c7cSmrg	    fi
250317a48c7cSmrg
250417a48c7cSmrg	    # Hardcode the library path.
250517a48c7cSmrg	    # Skip directories that are in the system default run-time
250617a48c7cSmrg	    # search path.
250717a48c7cSmrg	    case " $sys_lib_dlsearch_path " in
250817a48c7cSmrg	    *" $absdir "*) ;;
250917a48c7cSmrg	    *)
251017a48c7cSmrg	      case "$compile_rpath " in
251117a48c7cSmrg	      *" $absdir "*) ;;
251217a48c7cSmrg	      *) compile_rpath="$compile_rpath $absdir"
251317a48c7cSmrg	      esac
251417a48c7cSmrg	      ;;
251517a48c7cSmrg	    esac
251617a48c7cSmrg	    case " $sys_lib_dlsearch_path " in
251717a48c7cSmrg	    *" $libdir "*) ;;
251817a48c7cSmrg	    *)
251917a48c7cSmrg	      case "$finalize_rpath " in
252017a48c7cSmrg	      *" $libdir "*) ;;
252117a48c7cSmrg	      *) finalize_rpath="$finalize_rpath $libdir"
252217a48c7cSmrg	      esac
252317a48c7cSmrg	      ;;
252417a48c7cSmrg	    esac
252517a48c7cSmrg	  fi # $linkmode,$pass = prog,link...
252617a48c7cSmrg
252717a48c7cSmrg	  if test "$alldeplibs" = yes &&
252817a48c7cSmrg	     { test "$deplibs_check_method" = pass_all ||
252917a48c7cSmrg	       { test "$build_libtool_libs" = yes &&
253017a48c7cSmrg		 test -n "$library_names"; }; }; then
253117a48c7cSmrg	    # We only need to search for static libraries
253217a48c7cSmrg	    continue
253317a48c7cSmrg	  fi
253417a48c7cSmrg	fi
253517a48c7cSmrg
253617a48c7cSmrg	link_static=no # Whether the deplib will be linked statically
253717a48c7cSmrg	use_static_libs=$prefer_static_libs
253817a48c7cSmrg	if test "$use_static_libs" = built && test "$installed" = yes ; then
253917a48c7cSmrg	  use_static_libs=no
254017a48c7cSmrg	fi
254117a48c7cSmrg	if test -n "$library_names" &&
254217a48c7cSmrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
254317a48c7cSmrg	  if test "$installed" = no; then
254417a48c7cSmrg	    notinst_deplibs="$notinst_deplibs $lib"
254517a48c7cSmrg	    need_relink=yes
254617a48c7cSmrg	  fi
254717a48c7cSmrg	  # This is a shared library
254817a48c7cSmrg
254917a48c7cSmrg	  # Warn about portability, can't link against -module's on
255017a48c7cSmrg	  # some systems (darwin)
255117a48c7cSmrg	  if test "$shouldnotlink" = yes && test "$pass" = link ; then
255217a48c7cSmrg	    $echo
255317a48c7cSmrg	    if test "$linkmode" = prog; then
255417a48c7cSmrg	      $echo "*** Warning: Linking the executable $output against the loadable module"
255517a48c7cSmrg	    else
255617a48c7cSmrg	      $echo "*** Warning: Linking the shared library $output against the loadable module"
255717a48c7cSmrg	    fi
255817a48c7cSmrg	    $echo "*** $linklib is not portable!"
255917a48c7cSmrg	  fi
256017a48c7cSmrg	  if test "$linkmode" = lib &&
256117a48c7cSmrg	     test "$hardcode_into_libs" = yes; then
256217a48c7cSmrg	    # Hardcode the library path.
256317a48c7cSmrg	    # Skip directories that are in the system default run-time
256417a48c7cSmrg	    # search path.
256517a48c7cSmrg	    case " $sys_lib_dlsearch_path " in
256617a48c7cSmrg	    *" $absdir "*) ;;
256717a48c7cSmrg	    *)
256817a48c7cSmrg	      case "$compile_rpath " in
256917a48c7cSmrg	      *" $absdir "*) ;;
257017a48c7cSmrg	      *) compile_rpath="$compile_rpath $absdir"
257117a48c7cSmrg	      esac
257217a48c7cSmrg	      ;;
257317a48c7cSmrg	    esac
257417a48c7cSmrg	    case " $sys_lib_dlsearch_path " in
257517a48c7cSmrg	    *" $libdir "*) ;;
257617a48c7cSmrg	    *)
257717a48c7cSmrg	      case "$finalize_rpath " in
257817a48c7cSmrg	      *" $libdir "*) ;;
257917a48c7cSmrg	      *) finalize_rpath="$finalize_rpath $libdir"
258017a48c7cSmrg	      esac
258117a48c7cSmrg	      ;;
258217a48c7cSmrg	    esac
258317a48c7cSmrg	  fi
258417a48c7cSmrg
258517a48c7cSmrg	  if test -n "$old_archive_from_expsyms_cmds"; then
258617a48c7cSmrg	    # figure out the soname
258717a48c7cSmrg	    set dummy $library_names
258817a48c7cSmrg	    realname="$2"
258917a48c7cSmrg	    shift; shift
259017a48c7cSmrg	    libname=`eval \\$echo \"$libname_spec\"`
259117a48c7cSmrg	    # use dlname if we got it. it's perfectly good, no?
259217a48c7cSmrg	    if test -n "$dlname"; then
259317a48c7cSmrg	      soname="$dlname"
259417a48c7cSmrg	    elif test -n "$soname_spec"; then
259517a48c7cSmrg	      # bleh windows
259617a48c7cSmrg	      case $host in
259717a48c7cSmrg	      *cygwin* | mingw*)
259817a48c7cSmrg		major=`expr $current - $age`
259917a48c7cSmrg		versuffix="-$major"
260017a48c7cSmrg		;;
260117a48c7cSmrg	      esac
260217a48c7cSmrg	      eval soname=\"$soname_spec\"
260317a48c7cSmrg	    else
260417a48c7cSmrg	      soname="$realname"
260517a48c7cSmrg	    fi
260617a48c7cSmrg
260717a48c7cSmrg	    # Make a new name for the extract_expsyms_cmds to use
260817a48c7cSmrg	    soroot="$soname"
260917a48c7cSmrg	    soname=`$echo $soroot | ${SED} -e 's/^.*\///'`
261017a48c7cSmrg	    newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a"
261117a48c7cSmrg
261217a48c7cSmrg	    # If the library has no export list, then create one now
261317a48c7cSmrg	    if test -f "$output_objdir/$soname-def"; then :
261417a48c7cSmrg	    else
261517a48c7cSmrg	      $show "extracting exported symbol list from \`$soname'"
261617a48c7cSmrg	      save_ifs="$IFS"; IFS='~'
261717a48c7cSmrg	      cmds=$extract_expsyms_cmds
261817a48c7cSmrg	      for cmd in $cmds; do
261917a48c7cSmrg		IFS="$save_ifs"
262017a48c7cSmrg		eval cmd=\"$cmd\"
262117a48c7cSmrg		$show "$cmd"
262217a48c7cSmrg		$run eval "$cmd" || exit $?
262317a48c7cSmrg	      done
262417a48c7cSmrg	      IFS="$save_ifs"
262517a48c7cSmrg	    fi
262617a48c7cSmrg
262717a48c7cSmrg	    # Create $newlib
262817a48c7cSmrg	    if test -f "$output_objdir/$newlib"; then :; else
262917a48c7cSmrg	      $show "generating import library for \`$soname'"
263017a48c7cSmrg	      save_ifs="$IFS"; IFS='~'
263117a48c7cSmrg	      cmds=$old_archive_from_expsyms_cmds
263217a48c7cSmrg	      for cmd in $cmds; do
263317a48c7cSmrg		IFS="$save_ifs"
263417a48c7cSmrg		eval cmd=\"$cmd\"
263517a48c7cSmrg		$show "$cmd"
263617a48c7cSmrg		$run eval "$cmd" || exit $?
263717a48c7cSmrg	      done
263817a48c7cSmrg	      IFS="$save_ifs"
263917a48c7cSmrg	    fi
264017a48c7cSmrg	    # make sure the library variables are pointing to the new library
264117a48c7cSmrg	    dir=$output_objdir
264217a48c7cSmrg	    linklib=$newlib
264317a48c7cSmrg	  fi # test -n "$old_archive_from_expsyms_cmds"
264417a48c7cSmrg
264517a48c7cSmrg	  if test "$linkmode" = prog || test "$mode" != relink; then
264617a48c7cSmrg	    add_shlibpath=
264717a48c7cSmrg	    add_dir=
264817a48c7cSmrg	    add=
264917a48c7cSmrg	    lib_linked=yes
265017a48c7cSmrg	    case $hardcode_action in
265117a48c7cSmrg	    immediate | unsupported)
265217a48c7cSmrg	      if test "$hardcode_direct" = no; then
265317a48c7cSmrg		add="$dir/$linklib"
265417a48c7cSmrg		case $host in
265517a48c7cSmrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
265617a48c7cSmrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
265717a48c7cSmrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
265817a48c7cSmrg		    *-*-unixware7*) add_dir="-L$dir" ;;
265917a48c7cSmrg		  *-*-darwin* )
266017a48c7cSmrg		    # if the lib is a module then we can not link against
266117a48c7cSmrg		    # it, someone is ignoring the new warnings I added
266217a48c7cSmrg		    if /usr/bin/file -L $add 2> /dev/null |
266317a48c7cSmrg                      $EGREP ": [^:]* bundle" >/dev/null ; then
266417a48c7cSmrg		      $echo "** Warning, lib $linklib is a module, not a shared library"
266517a48c7cSmrg		      if test -z "$old_library" ; then
266617a48c7cSmrg		        $echo
266717a48c7cSmrg		        $echo "** And there doesn't seem to be a static archive available"
266817a48c7cSmrg		        $echo "** The link will probably fail, sorry"
266917a48c7cSmrg		      else
267017a48c7cSmrg		        add="$dir/$old_library"
267117a48c7cSmrg		      fi
267217a48c7cSmrg		    fi
267317a48c7cSmrg		esac
267417a48c7cSmrg	      elif test "$hardcode_minus_L" = no; then
267517a48c7cSmrg		case $host in
267617a48c7cSmrg		*-*-sunos*) add_shlibpath="$dir" ;;
267717a48c7cSmrg		esac
267817a48c7cSmrg		add_dir="-L$dir"
267917a48c7cSmrg		add="-l$name"
268017a48c7cSmrg	      elif test "$hardcode_shlibpath_var" = no; then
268117a48c7cSmrg		add_shlibpath="$dir"
268217a48c7cSmrg		add="-l$name"
268317a48c7cSmrg	      else
268417a48c7cSmrg		lib_linked=no
268517a48c7cSmrg	      fi
268617a48c7cSmrg	      ;;
268717a48c7cSmrg	    relink)
268817a48c7cSmrg	      if test "$hardcode_direct" = yes; then
268917a48c7cSmrg		add="$dir/$linklib"
269017a48c7cSmrg	      elif test "$hardcode_minus_L" = yes; then
269117a48c7cSmrg		add_dir="-L$dir"
269217a48c7cSmrg		# Try looking first in the location we're being installed to.
269317a48c7cSmrg		if test -n "$inst_prefix_dir"; then
269417a48c7cSmrg		  case $libdir in
269517a48c7cSmrg		    [\\/]*)
269617a48c7cSmrg		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
269717a48c7cSmrg		      ;;
269817a48c7cSmrg		  esac
269917a48c7cSmrg		fi
270017a48c7cSmrg		add="-l$name"
270117a48c7cSmrg	      elif test "$hardcode_shlibpath_var" = yes; then
270217a48c7cSmrg		add_shlibpath="$dir"
270317a48c7cSmrg		add="-l$name"
270417a48c7cSmrg	      else
270517a48c7cSmrg		lib_linked=no
270617a48c7cSmrg	      fi
270717a48c7cSmrg	      ;;
270817a48c7cSmrg	    *) lib_linked=no ;;
270917a48c7cSmrg	    esac
271017a48c7cSmrg
271117a48c7cSmrg	    if test "$lib_linked" != yes; then
271217a48c7cSmrg	      $echo "$modename: configuration error: unsupported hardcode properties"
271317a48c7cSmrg	      exit $EXIT_FAILURE
271417a48c7cSmrg	    fi
271517a48c7cSmrg
271617a48c7cSmrg	    if test -n "$add_shlibpath"; then
271717a48c7cSmrg	      case :$compile_shlibpath: in
271817a48c7cSmrg	      *":$add_shlibpath:"*) ;;
271917a48c7cSmrg	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
272017a48c7cSmrg	      esac
272117a48c7cSmrg	    fi
272217a48c7cSmrg	    if test "$linkmode" = prog; then
272317a48c7cSmrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
272417a48c7cSmrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
272517a48c7cSmrg	    else
272617a48c7cSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
272717a48c7cSmrg	      test -n "$add" && deplibs="$add $deplibs"
272817a48c7cSmrg	      if test "$hardcode_direct" != yes && \
272917a48c7cSmrg		 test "$hardcode_minus_L" != yes && \
273017a48c7cSmrg		 test "$hardcode_shlibpath_var" = yes; then
273117a48c7cSmrg		case :$finalize_shlibpath: in
273217a48c7cSmrg		*":$libdir:"*) ;;
273317a48c7cSmrg		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
273417a48c7cSmrg		esac
273517a48c7cSmrg	      fi
273617a48c7cSmrg	    fi
273717a48c7cSmrg	  fi
273817a48c7cSmrg
273917a48c7cSmrg	  if test "$linkmode" = prog || test "$mode" = relink; then
274017a48c7cSmrg	    add_shlibpath=
274117a48c7cSmrg	    add_dir=
274217a48c7cSmrg	    add=
274317a48c7cSmrg	    # Finalize command for both is simple: just hardcode it.
274417a48c7cSmrg	    if test "$hardcode_direct" = yes; then
274517a48c7cSmrg	      add="$libdir/$linklib"
274617a48c7cSmrg	    elif test "$hardcode_minus_L" = yes; then
274717a48c7cSmrg	      add_dir="-L$libdir"
274817a48c7cSmrg	      add="-l$name"
274917a48c7cSmrg	    elif test "$hardcode_shlibpath_var" = yes; then
275017a48c7cSmrg	      case :$finalize_shlibpath: in
275117a48c7cSmrg	      *":$libdir:"*) ;;
275217a48c7cSmrg	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
275317a48c7cSmrg	      esac
275417a48c7cSmrg	      add="-l$name"
275517a48c7cSmrg	    elif test "$hardcode_automatic" = yes; then
275617a48c7cSmrg	      if test -n "$inst_prefix_dir" &&
275717a48c7cSmrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
275817a48c7cSmrg	        add="$inst_prefix_dir$libdir/$linklib"
275917a48c7cSmrg	      else
276017a48c7cSmrg	        add="$libdir/$linklib"
276117a48c7cSmrg	      fi
276217a48c7cSmrg	    else
276317a48c7cSmrg	      # We cannot seem to hardcode it, guess we'll fake it.
276417a48c7cSmrg	      add_dir="-L$libdir"
276517a48c7cSmrg	      # Try looking first in the location we're being installed to.
276617a48c7cSmrg	      if test -n "$inst_prefix_dir"; then
276717a48c7cSmrg		case $libdir in
276817a48c7cSmrg		  [\\/]*)
276917a48c7cSmrg		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
277017a48c7cSmrg		    ;;
277117a48c7cSmrg		esac
277217a48c7cSmrg	      fi
277317a48c7cSmrg	      add="-l$name"
277417a48c7cSmrg	    fi
277517a48c7cSmrg
277617a48c7cSmrg	    if test "$linkmode" = prog; then
277717a48c7cSmrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
277817a48c7cSmrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
277917a48c7cSmrg	    else
278017a48c7cSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
278117a48c7cSmrg	      test -n "$add" && deplibs="$add $deplibs"
278217a48c7cSmrg	    fi
278317a48c7cSmrg	  fi
278417a48c7cSmrg	elif test "$linkmode" = prog; then
278517a48c7cSmrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
278617a48c7cSmrg	  # is not unsupported.  This is valid on all known static and
278717a48c7cSmrg	  # shared platforms.
278817a48c7cSmrg	  if test "$hardcode_direct" != unsupported; then
278917a48c7cSmrg	    test -n "$old_library" && linklib="$old_library"
279017a48c7cSmrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
279117a48c7cSmrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
279217a48c7cSmrg	  else
279317a48c7cSmrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
279417a48c7cSmrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
279517a48c7cSmrg	  fi
279617a48c7cSmrg	elif test "$build_libtool_libs" = yes; then
279717a48c7cSmrg	  # Not a shared library
279817a48c7cSmrg	  if test "$deplibs_check_method" != pass_all; then
279917a48c7cSmrg	    # We're trying link a shared library against a static one
280017a48c7cSmrg	    # but the system doesn't support it.
280117a48c7cSmrg
280217a48c7cSmrg	    # Just print a warning and add the library to dependency_libs so
280317a48c7cSmrg	    # that the program can be linked against the static library.
280417a48c7cSmrg	    $echo
280517a48c7cSmrg	    $echo "*** Warning: This system can not link to static lib archive $lib."
280617a48c7cSmrg	    $echo "*** I have the capability to make that library automatically link in when"
280717a48c7cSmrg	    $echo "*** you link to this library.  But I can only do this if you have a"
280817a48c7cSmrg	    $echo "*** shared version of the library, which you do not appear to have."
280917a48c7cSmrg	    if test "$module" = yes; then
281017a48c7cSmrg	      $echo "*** But as you try to build a module library, libtool will still create "
281117a48c7cSmrg	      $echo "*** a static module, that should work as long as the dlopening application"
281217a48c7cSmrg	      $echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
281317a48c7cSmrg	      if test -z "$global_symbol_pipe"; then
281417a48c7cSmrg		$echo
281517a48c7cSmrg		$echo "*** However, this would only work if libtool was able to extract symbol"
281617a48c7cSmrg		$echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
281717a48c7cSmrg		$echo "*** not find such a program.  So, this module is probably useless."
281817a48c7cSmrg		$echo "*** \`nm' from GNU binutils and a full rebuild may help."
281917a48c7cSmrg	      fi
282017a48c7cSmrg	      if test "$build_old_libs" = no; then
282117a48c7cSmrg		build_libtool_libs=module
282217a48c7cSmrg		build_old_libs=yes
282317a48c7cSmrg	      else
282417a48c7cSmrg		build_libtool_libs=no
282517a48c7cSmrg	      fi
282617a48c7cSmrg	    fi
282717a48c7cSmrg	  else
282817a48c7cSmrg	    deplibs="$dir/$old_library $deplibs"
282917a48c7cSmrg	    link_static=yes
283017a48c7cSmrg	  fi
283117a48c7cSmrg	fi # link shared/static library?
283217a48c7cSmrg
283317a48c7cSmrg	if test "$linkmode" = lib; then
283417a48c7cSmrg	  if test -n "$dependency_libs" &&
283517a48c7cSmrg	     { test "$hardcode_into_libs" != yes ||
283617a48c7cSmrg	       test "$build_old_libs" = yes ||
283717a48c7cSmrg	       test "$link_static" = yes; }; then
283817a48c7cSmrg	    # Extract -R from dependency_libs
283917a48c7cSmrg	    temp_deplibs=
284017a48c7cSmrg	    for libdir in $dependency_libs; do
284117a48c7cSmrg	      case $libdir in
284217a48c7cSmrg	      -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'`
284317a48c7cSmrg		   case " $xrpath " in
284417a48c7cSmrg		   *" $temp_xrpath "*) ;;
284517a48c7cSmrg		   *) xrpath="$xrpath $temp_xrpath";;
284617a48c7cSmrg		   esac;;
284717a48c7cSmrg	      *) temp_deplibs="$temp_deplibs $libdir";;
284817a48c7cSmrg	      esac
284917a48c7cSmrg	    done
285017a48c7cSmrg	    dependency_libs="$temp_deplibs"
285117a48c7cSmrg	  fi
285217a48c7cSmrg
285317a48c7cSmrg	  newlib_search_path="$newlib_search_path $absdir"
285417a48c7cSmrg	  # Link against this library
285517a48c7cSmrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
285617a48c7cSmrg	  # ... and its dependency_libs
285717a48c7cSmrg	  tmp_libs=
285817a48c7cSmrg	  for deplib in $dependency_libs; do
285917a48c7cSmrg	    newdependency_libs="$deplib $newdependency_libs"
286017a48c7cSmrg	    if test "X$duplicate_deps" = "Xyes" ; then
286117a48c7cSmrg	      case "$tmp_libs " in
286217a48c7cSmrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
286317a48c7cSmrg	      esac
286417a48c7cSmrg	    fi
286517a48c7cSmrg	    tmp_libs="$tmp_libs $deplib"
286617a48c7cSmrg	  done
286717a48c7cSmrg
286817a48c7cSmrg	  if test "$link_all_deplibs" != no; then
286917a48c7cSmrg	    # Add the search paths of all dependency libraries
287017a48c7cSmrg	    for deplib in $dependency_libs; do
287117a48c7cSmrg	      case $deplib in
287217a48c7cSmrg	      -L*) path="$deplib" ;;
287317a48c7cSmrg	      *.la)
287417a48c7cSmrg		dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'`
287517a48c7cSmrg		test "X$dir" = "X$deplib" && dir="."
287617a48c7cSmrg		# We need an absolute path.
287717a48c7cSmrg		case $dir in
287817a48c7cSmrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
287917a48c7cSmrg		*)
288017a48c7cSmrg		  absdir=`cd "$dir" && pwd`
288117a48c7cSmrg		  if test -z "$absdir"; then
288217a48c7cSmrg		    $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
288317a48c7cSmrg		    absdir="$dir"
288417a48c7cSmrg		  fi
288517a48c7cSmrg		  ;;
288617a48c7cSmrg		esac
288717a48c7cSmrg		if grep "^installed=no" $deplib > /dev/null; then
288817a48c7cSmrg		  path="$absdir/$objdir"
288917a48c7cSmrg		else
289017a48c7cSmrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
289117a48c7cSmrg		  if test -z "$libdir"; then
289217a48c7cSmrg		    $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
289317a48c7cSmrg		    exit $EXIT_FAILURE
289417a48c7cSmrg		  fi
289517a48c7cSmrg		  if test "$absdir" != "$libdir"; then
289617a48c7cSmrg		    $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2
289717a48c7cSmrg		  fi
289817a48c7cSmrg		  path="$absdir"
289917a48c7cSmrg		fi
290017a48c7cSmrg		depdepl=
290117a48c7cSmrg		case $host in
290217a48c7cSmrg		*-*-darwin*)
290317a48c7cSmrg		  # we do not want to link against static libs,
290417a48c7cSmrg		  # but need to link against shared
290517a48c7cSmrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
290617a48c7cSmrg		  if test -n "$deplibrary_names" ; then
290717a48c7cSmrg		    for tmp in $deplibrary_names ; do
290817a48c7cSmrg		      depdepl=$tmp
290917a48c7cSmrg		    done
291017a48c7cSmrg		    if test -f "$path/$depdepl" ; then
291117a48c7cSmrg		      depdepl="$path/$depdepl"
291217a48c7cSmrg		    fi
291317a48c7cSmrg		    # do not add paths which are already there
291417a48c7cSmrg		    case " $newlib_search_path " in
291517a48c7cSmrg		    *" $path "*) ;;
291617a48c7cSmrg		    *) newlib_search_path="$newlib_search_path $path";;
291717a48c7cSmrg		    esac
291817a48c7cSmrg		  fi
291917a48c7cSmrg		  path=""
292017a48c7cSmrg		  ;;
292117a48c7cSmrg		*)
292217a48c7cSmrg		  path="-L$path"
292317a48c7cSmrg		  ;;
292417a48c7cSmrg		esac
292517a48c7cSmrg		;;
292617a48c7cSmrg	      -l*)
292717a48c7cSmrg		case $host in
292817a48c7cSmrg		*-*-darwin*)
292917a48c7cSmrg		  # Again, we only want to link against shared libraries
293017a48c7cSmrg		  eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"`
293117a48c7cSmrg		  for tmp in $newlib_search_path ; do
293217a48c7cSmrg		    if test -f "$tmp/lib$tmp_libs.dylib" ; then
293317a48c7cSmrg		      eval depdepl="$tmp/lib$tmp_libs.dylib"
293417a48c7cSmrg		      break
293517a48c7cSmrg		    fi
293617a48c7cSmrg		  done
293717a48c7cSmrg		  path=""
293817a48c7cSmrg		  ;;
293917a48c7cSmrg		*) continue ;;
294017a48c7cSmrg		esac
294117a48c7cSmrg		;;
294217a48c7cSmrg	      *) continue ;;
294317a48c7cSmrg	      esac
294417a48c7cSmrg	      case " $deplibs " in
294517a48c7cSmrg	      *" $path "*) ;;
294617a48c7cSmrg	      *) deplibs="$path $deplibs" ;;
294717a48c7cSmrg	      esac
294817a48c7cSmrg	      case " $deplibs " in
294917a48c7cSmrg	      *" $depdepl "*) ;;
295017a48c7cSmrg	      *) deplibs="$depdepl $deplibs" ;;
295117a48c7cSmrg	      esac
295217a48c7cSmrg	    done
295317a48c7cSmrg	  fi # link_all_deplibs != no
295417a48c7cSmrg	fi # linkmode = lib
295517a48c7cSmrg      done # for deplib in $libs
295617a48c7cSmrg      dependency_libs="$newdependency_libs"
295717a48c7cSmrg      if test "$pass" = dlpreopen; then
295817a48c7cSmrg	# Link the dlpreopened libraries before other libraries
295917a48c7cSmrg	for deplib in $save_deplibs; do
296017a48c7cSmrg	  deplibs="$deplib $deplibs"
296117a48c7cSmrg	done
296217a48c7cSmrg      fi
296317a48c7cSmrg      if test "$pass" != dlopen; then
296417a48c7cSmrg	if test "$pass" != conv; then
296517a48c7cSmrg	  # Make sure lib_search_path contains only unique directories.
296617a48c7cSmrg	  lib_search_path=
296717a48c7cSmrg	  for dir in $newlib_search_path; do
296817a48c7cSmrg	    case "$lib_search_path " in
296917a48c7cSmrg	    *" $dir "*) ;;
297017a48c7cSmrg	    *) lib_search_path="$lib_search_path $dir" ;;
297117a48c7cSmrg	    esac
297217a48c7cSmrg	  done
297317a48c7cSmrg	  newlib_search_path=
297417a48c7cSmrg	fi
297517a48c7cSmrg
297617a48c7cSmrg	if test "$linkmode,$pass" != "prog,link"; then
297717a48c7cSmrg	  vars="deplibs"
297817a48c7cSmrg	else
297917a48c7cSmrg	  vars="compile_deplibs finalize_deplibs"
298017a48c7cSmrg	fi
298117a48c7cSmrg	for var in $vars dependency_libs; do
298217a48c7cSmrg	  # Add libraries to $var in reverse order
298317a48c7cSmrg	  eval tmp_libs=\"\$$var\"
298417a48c7cSmrg	  new_libs=
298517a48c7cSmrg	  for deplib in $tmp_libs; do
298617a48c7cSmrg	    # FIXME: Pedantically, this is the right thing to do, so
298717a48c7cSmrg	    #        that some nasty dependency loop isn't accidentally
298817a48c7cSmrg	    #        broken:
298917a48c7cSmrg	    #new_libs="$deplib $new_libs"
299017a48c7cSmrg	    # Pragmatically, this seems to cause very few problems in
299117a48c7cSmrg	    # practice:
299217a48c7cSmrg	    case $deplib in
299317a48c7cSmrg	    -L*) new_libs="$deplib $new_libs" ;;
299417a48c7cSmrg	    -R*) ;;
299517a48c7cSmrg	    *)
299617a48c7cSmrg	      # And here is the reason: when a library appears more
299717a48c7cSmrg	      # than once as an explicit dependence of a library, or
299817a48c7cSmrg	      # is implicitly linked in more than once by the
299917a48c7cSmrg	      # compiler, it is considered special, and multiple
300017a48c7cSmrg	      # occurrences thereof are not removed.  Compare this
300117a48c7cSmrg	      # with having the same library being listed as a
300217a48c7cSmrg	      # dependency of multiple other libraries: in this case,
300317a48c7cSmrg	      # we know (pedantically, we assume) the library does not
300417a48c7cSmrg	      # need to be listed more than once, so we keep only the
300517a48c7cSmrg	      # last copy.  This is not always right, but it is rare
300617a48c7cSmrg	      # enough that we require users that really mean to play
300717a48c7cSmrg	      # such unportable linking tricks to link the library
300817a48c7cSmrg	      # using -Wl,-lname, so that libtool does not consider it
300917a48c7cSmrg	      # for duplicate removal.
301017a48c7cSmrg	      case " $specialdeplibs " in
301117a48c7cSmrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
301217a48c7cSmrg	      *)
301317a48c7cSmrg		case " $new_libs " in
301417a48c7cSmrg		*" $deplib "*) ;;
301517a48c7cSmrg		*) new_libs="$deplib $new_libs" ;;
301617a48c7cSmrg		esac
301717a48c7cSmrg		;;
301817a48c7cSmrg	      esac
301917a48c7cSmrg	      ;;
302017a48c7cSmrg	    esac
302117a48c7cSmrg	  done
302217a48c7cSmrg	  tmp_libs=
302317a48c7cSmrg	  for deplib in $new_libs; do
302417a48c7cSmrg	    case $deplib in
302517a48c7cSmrg	    -L*)
302617a48c7cSmrg	      case " $tmp_libs " in
302717a48c7cSmrg	      *" $deplib "*) ;;
302817a48c7cSmrg	      *) tmp_libs="$tmp_libs $deplib" ;;
302917a48c7cSmrg	      esac
303017a48c7cSmrg	      ;;
303117a48c7cSmrg	    *) tmp_libs="$tmp_libs $deplib" ;;
303217a48c7cSmrg	    esac
303317a48c7cSmrg	  done
303417a48c7cSmrg	  eval $var=\"$tmp_libs\"
303517a48c7cSmrg	done # for var
303617a48c7cSmrg      fi
303717a48c7cSmrg      # Last step: remove runtime libs from dependency_libs
303817a48c7cSmrg      # (they stay in deplibs)
303917a48c7cSmrg      tmp_libs=
304017a48c7cSmrg      for i in $dependency_libs ; do
304117a48c7cSmrg	case " $predeps $postdeps $compiler_lib_search_path " in
304217a48c7cSmrg	*" $i "*)
304317a48c7cSmrg	  i=""
304417a48c7cSmrg	  ;;
304517a48c7cSmrg	esac
304617a48c7cSmrg	if test -n "$i" ; then
304717a48c7cSmrg	  tmp_libs="$tmp_libs $i"
304817a48c7cSmrg	fi
304917a48c7cSmrg      done
305017a48c7cSmrg      dependency_libs=$tmp_libs
305117a48c7cSmrg    done # for pass
305217a48c7cSmrg    if test "$linkmode" = prog; then
305317a48c7cSmrg      dlfiles="$newdlfiles"
305417a48c7cSmrg      dlprefiles="$newdlprefiles"
305517a48c7cSmrg    fi
305617a48c7cSmrg
305717a48c7cSmrg    case $linkmode in
305817a48c7cSmrg    oldlib)
305917a48c7cSmrg      if test -n "$deplibs"; then
306017a48c7cSmrg	$echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2
306117a48c7cSmrg      fi
306217a48c7cSmrg
306317a48c7cSmrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
306417a48c7cSmrg	$echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
306517a48c7cSmrg      fi
306617a48c7cSmrg
306717a48c7cSmrg      if test -n "$rpath"; then
306817a48c7cSmrg	$echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2
306917a48c7cSmrg      fi
307017a48c7cSmrg
307117a48c7cSmrg      if test -n "$xrpath"; then
307217a48c7cSmrg	$echo "$modename: warning: \`-R' is ignored for archives" 1>&2
307317a48c7cSmrg      fi
307417a48c7cSmrg
307517a48c7cSmrg      if test -n "$vinfo"; then
307617a48c7cSmrg	$echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2
307717a48c7cSmrg      fi
307817a48c7cSmrg
307917a48c7cSmrg      if test -n "$release"; then
308017a48c7cSmrg	$echo "$modename: warning: \`-release' is ignored for archives" 1>&2
308117a48c7cSmrg      fi
308217a48c7cSmrg
308317a48c7cSmrg      if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
308417a48c7cSmrg	$echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2
308517a48c7cSmrg      fi
308617a48c7cSmrg
308717a48c7cSmrg      # Now set the variables for building old libraries.
308817a48c7cSmrg      build_libtool_libs=no
308917a48c7cSmrg      oldlibs="$output"
309017a48c7cSmrg      objs="$objs$old_deplibs"
309117a48c7cSmrg      ;;
309217a48c7cSmrg
309317a48c7cSmrg    lib)
309417a48c7cSmrg      # Make sure we only generate libraries of the form `libNAME.la'.
309517a48c7cSmrg      case $outputname in
309617a48c7cSmrg      lib*)
309717a48c7cSmrg	name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
309817a48c7cSmrg	eval shared_ext=\"$shrext_cmds\"
309917a48c7cSmrg	eval libname=\"$libname_spec\"
310017a48c7cSmrg	;;
310117a48c7cSmrg      *)
310217a48c7cSmrg	if test "$module" = no; then
310317a48c7cSmrg	  $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
310417a48c7cSmrg	  $echo "$help" 1>&2
310517a48c7cSmrg	  exit $EXIT_FAILURE
310617a48c7cSmrg	fi
310717a48c7cSmrg	if test "$need_lib_prefix" != no; then
310817a48c7cSmrg	  # Add the "lib" prefix for modules if required
310917a48c7cSmrg	  name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
311017a48c7cSmrg	  eval shared_ext=\"$shrext_cmds\"
311117a48c7cSmrg	  eval libname=\"$libname_spec\"
311217a48c7cSmrg	else
311317a48c7cSmrg	  libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
311417a48c7cSmrg	fi
311517a48c7cSmrg	;;
311617a48c7cSmrg      esac
311717a48c7cSmrg
311817a48c7cSmrg      if test -n "$objs"; then
311917a48c7cSmrg	if test "$deplibs_check_method" != pass_all; then
312017a48c7cSmrg	  $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1
312117a48c7cSmrg	  exit $EXIT_FAILURE
312217a48c7cSmrg	else
312317a48c7cSmrg	  $echo
312417a48c7cSmrg	  $echo "*** Warning: Linking the shared library $output against the non-libtool"
312517a48c7cSmrg	  $echo "*** objects $objs is not portable!"
312617a48c7cSmrg	  libobjs="$libobjs $objs"
312717a48c7cSmrg	fi
312817a48c7cSmrg      fi
312917a48c7cSmrg
313017a48c7cSmrg      if test "$dlself" != no; then
313117a48c7cSmrg	$echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2
313217a48c7cSmrg      fi
313317a48c7cSmrg
313417a48c7cSmrg      set dummy $rpath
313517a48c7cSmrg      if test "$#" -gt 2; then
313617a48c7cSmrg	$echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
313717a48c7cSmrg      fi
313817a48c7cSmrg      install_libdir="$2"
313917a48c7cSmrg
314017a48c7cSmrg      oldlibs=
314117a48c7cSmrg      if test -z "$rpath"; then
314217a48c7cSmrg	if test "$build_libtool_libs" = yes; then
314317a48c7cSmrg	  # Building a libtool convenience library.
314417a48c7cSmrg	  # Some compilers have problems with a `.al' extension so
314517a48c7cSmrg	  # convenience libraries should have the same extension an
314617a48c7cSmrg	  # archive normally would.
314717a48c7cSmrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
314817a48c7cSmrg	  build_libtool_libs=convenience
314917a48c7cSmrg	  build_old_libs=yes
315017a48c7cSmrg	fi
315117a48c7cSmrg
315217a48c7cSmrg	if test -n "$vinfo"; then
315317a48c7cSmrg	  $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2
315417a48c7cSmrg	fi
315517a48c7cSmrg
315617a48c7cSmrg	if test -n "$release"; then
315717a48c7cSmrg	  $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2
315817a48c7cSmrg	fi
315917a48c7cSmrg      else
316017a48c7cSmrg
316117a48c7cSmrg	# Parse the version information argument.
316217a48c7cSmrg	save_ifs="$IFS"; IFS=':'
316317a48c7cSmrg	set dummy $vinfo 0 0 0
316417a48c7cSmrg	IFS="$save_ifs"
316517a48c7cSmrg
316617a48c7cSmrg	if test -n "$8"; then
316717a48c7cSmrg	  $echo "$modename: too many parameters to \`-version-info'" 1>&2
316817a48c7cSmrg	  $echo "$help" 1>&2
316917a48c7cSmrg	  exit $EXIT_FAILURE
317017a48c7cSmrg	fi
317117a48c7cSmrg
317217a48c7cSmrg	# convert absolute version numbers to libtool ages
317317a48c7cSmrg	# this retains compatibility with .la files and attempts
317417a48c7cSmrg	# to make the code below a bit more comprehensible
317517a48c7cSmrg
317617a48c7cSmrg	case $vinfo_number in
317717a48c7cSmrg	yes)
317817a48c7cSmrg	  number_major="$2"
317917a48c7cSmrg	  number_minor="$3"
318017a48c7cSmrg	  number_revision="$4"
318117a48c7cSmrg	  #
318217a48c7cSmrg	  # There are really only two kinds -- those that
318317a48c7cSmrg	  # use the current revision as the major version
318417a48c7cSmrg	  # and those that subtract age and use age as
318517a48c7cSmrg	  # a minor version.  But, then there is irix
318617a48c7cSmrg	  # which has an extra 1 added just for fun
318717a48c7cSmrg	  #
318817a48c7cSmrg	  case $version_type in
318917a48c7cSmrg	  darwin|linux|osf|windows)
319017a48c7cSmrg	    current=`expr $number_major + $number_minor`
319117a48c7cSmrg	    age="$number_minor"
319217a48c7cSmrg	    revision="$number_revision"
319317a48c7cSmrg	    ;;
319417a48c7cSmrg	  freebsd-aout|freebsd-elf|sunos)
319517a48c7cSmrg	    current="$number_major"
319617a48c7cSmrg	    revision="$number_minor"
319717a48c7cSmrg	    age="0"
319817a48c7cSmrg	    ;;
319917a48c7cSmrg	  irix|nonstopux)
320017a48c7cSmrg	    current=`expr $number_major + $number_minor - 1`
320117a48c7cSmrg	    age="$number_minor"
320217a48c7cSmrg	    revision="$number_minor"
320317a48c7cSmrg	    ;;
320417a48c7cSmrg	  esac
320517a48c7cSmrg	  ;;
320617a48c7cSmrg	no)
320717a48c7cSmrg	  current="$2"
320817a48c7cSmrg	  revision="$3"
320917a48c7cSmrg	  age="$4"
321017a48c7cSmrg	  ;;
321117a48c7cSmrg	esac
321217a48c7cSmrg
321317a48c7cSmrg	# Check that each of the things are valid numbers.
321417a48c7cSmrg	case $current in
321517a48c7cSmrg	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]) ;;
321617a48c7cSmrg	*)
321717a48c7cSmrg	  $echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2
321817a48c7cSmrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
321917a48c7cSmrg	  exit $EXIT_FAILURE
322017a48c7cSmrg	  ;;
322117a48c7cSmrg	esac
322217a48c7cSmrg
322317a48c7cSmrg	case $revision in
322417a48c7cSmrg	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]) ;;
322517a48c7cSmrg	*)
322617a48c7cSmrg	  $echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2
322717a48c7cSmrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
322817a48c7cSmrg	  exit $EXIT_FAILURE
322917a48c7cSmrg	  ;;
323017a48c7cSmrg	esac
323117a48c7cSmrg
323217a48c7cSmrg	case $age in
323317a48c7cSmrg	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]) ;;
323417a48c7cSmrg	*)
323517a48c7cSmrg	  $echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2
323617a48c7cSmrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
323717a48c7cSmrg	  exit $EXIT_FAILURE
323817a48c7cSmrg	  ;;
323917a48c7cSmrg	esac
324017a48c7cSmrg
324117a48c7cSmrg	if test "$age" -gt "$current"; then
324217a48c7cSmrg	  $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
324317a48c7cSmrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
324417a48c7cSmrg	  exit $EXIT_FAILURE
324517a48c7cSmrg	fi
324617a48c7cSmrg
324717a48c7cSmrg	# Calculate the version variables.
324817a48c7cSmrg	major=
324917a48c7cSmrg	versuffix=
325017a48c7cSmrg	verstring=
325117a48c7cSmrg	case $version_type in
325217a48c7cSmrg	none) ;;
325317a48c7cSmrg
325417a48c7cSmrg	darwin)
325517a48c7cSmrg	  # Like Linux, but with the current version available in
325617a48c7cSmrg	  # verstring for coding it into the library header
325717a48c7cSmrg	  major=.`expr $current - $age`
325817a48c7cSmrg	  versuffix="$major.$age.$revision"
325917a48c7cSmrg	  # Darwin ld doesn't like 0 for these options...
326017a48c7cSmrg	  minor_current=`expr $current + 1`
326117a48c7cSmrg	  verstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
326217a48c7cSmrg	  ;;
326317a48c7cSmrg
326417a48c7cSmrg	freebsd-aout)
326517a48c7cSmrg	  major=".$current"
326617a48c7cSmrg	  versuffix=".$current.$revision";
326717a48c7cSmrg	  ;;
326817a48c7cSmrg
326917a48c7cSmrg	freebsd-elf)
327017a48c7cSmrg	  major=".$current"
327117a48c7cSmrg	  versuffix=".$current";
327217a48c7cSmrg	  ;;
327317a48c7cSmrg
327417a48c7cSmrg	irix | nonstopux)
327517a48c7cSmrg	  major=`expr $current - $age + 1`
327617a48c7cSmrg
327717a48c7cSmrg	  case $version_type in
327817a48c7cSmrg	    nonstopux) verstring_prefix=nonstopux ;;
327917a48c7cSmrg	    *)         verstring_prefix=sgi ;;
328017a48c7cSmrg	  esac
328117a48c7cSmrg	  verstring="$verstring_prefix$major.$revision"
328217a48c7cSmrg
328317a48c7cSmrg	  # Add in all the interfaces that we are compatible with.
328417a48c7cSmrg	  loop=$revision
328517a48c7cSmrg	  while test "$loop" -ne 0; do
328617a48c7cSmrg	    iface=`expr $revision - $loop`
328717a48c7cSmrg	    loop=`expr $loop - 1`
328817a48c7cSmrg	    verstring="$verstring_prefix$major.$iface:$verstring"
328917a48c7cSmrg	  done
329017a48c7cSmrg
329117a48c7cSmrg	  # Before this point, $major must not contain `.'.
329217a48c7cSmrg	  major=.$major
329317a48c7cSmrg	  versuffix="$major.$revision"
329417a48c7cSmrg	  ;;
329517a48c7cSmrg
329617a48c7cSmrg	linux)
329717a48c7cSmrg	  major=.`expr $current - $age`
329817a48c7cSmrg	  versuffix="$major.$age.$revision"
329917a48c7cSmrg	  ;;
330017a48c7cSmrg
330117a48c7cSmrg	osf)
330217a48c7cSmrg	  major=.`expr $current - $age`
330317a48c7cSmrg	  versuffix=".$current.$age.$revision"
330417a48c7cSmrg	  verstring="$current.$age.$revision"
330517a48c7cSmrg
330617a48c7cSmrg	  # Add in all the interfaces that we are compatible with.
330717a48c7cSmrg	  loop=$age
330817a48c7cSmrg	  while test "$loop" -ne 0; do
330917a48c7cSmrg	    iface=`expr $current - $loop`
331017a48c7cSmrg	    loop=`expr $loop - 1`
331117a48c7cSmrg	    verstring="$verstring:${iface}.0"
331217a48c7cSmrg	  done
331317a48c7cSmrg
331417a48c7cSmrg	  # Make executables depend on our current version.
331517a48c7cSmrg	  verstring="$verstring:${current}.0"
331617a48c7cSmrg	  ;;
331717a48c7cSmrg
331817a48c7cSmrg	sunos)
331917a48c7cSmrg	  major=".$current"
332017a48c7cSmrg	  versuffix=".$current.$revision"
332117a48c7cSmrg	  ;;
332217a48c7cSmrg
332317a48c7cSmrg	windows)
332417a48c7cSmrg	  # Use '-' rather than '.', since we only want one
332517a48c7cSmrg	  # extension on DOS 8.3 filesystems.
332617a48c7cSmrg	  major=`expr $current - $age`
332717a48c7cSmrg	  versuffix="-$major"
332817a48c7cSmrg	  ;;
332917a48c7cSmrg
333017a48c7cSmrg	*)
333117a48c7cSmrg	  $echo "$modename: unknown library version type \`$version_type'" 1>&2
333217a48c7cSmrg	  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
333317a48c7cSmrg	  exit $EXIT_FAILURE
333417a48c7cSmrg	  ;;
333517a48c7cSmrg	esac
333617a48c7cSmrg
333717a48c7cSmrg	# Clear the version info if we defaulted, and they specified a release.
333817a48c7cSmrg	if test -z "$vinfo" && test -n "$release"; then
333917a48c7cSmrg	  major=
334017a48c7cSmrg	  case $version_type in
334117a48c7cSmrg	  darwin)
334217a48c7cSmrg	    # we can't check for "0.0" in archive_cmds due to quoting
334317a48c7cSmrg	    # problems, so we reset it completely
334417a48c7cSmrg	    verstring=
334517a48c7cSmrg	    ;;
334617a48c7cSmrg	  *)
334717a48c7cSmrg	    verstring="0.0"
334817a48c7cSmrg	    ;;
334917a48c7cSmrg	  esac
335017a48c7cSmrg	  if test "$need_version" = no; then
335117a48c7cSmrg	    versuffix=
335217a48c7cSmrg	  else
335317a48c7cSmrg	    versuffix=".0.0"
335417a48c7cSmrg	  fi
335517a48c7cSmrg	fi
335617a48c7cSmrg
335717a48c7cSmrg	# Remove version info from name if versioning should be avoided
335817a48c7cSmrg	if test "$avoid_version" = yes && test "$need_version" = no; then
335917a48c7cSmrg	  major=
336017a48c7cSmrg	  versuffix=
336117a48c7cSmrg	  verstring=""
336217a48c7cSmrg	fi
336317a48c7cSmrg
336417a48c7cSmrg	# Check to see if the archive will have undefined symbols.
336517a48c7cSmrg	if test "$allow_undefined" = yes; then
336617a48c7cSmrg	  if test "$allow_undefined_flag" = unsupported; then
336717a48c7cSmrg	    $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2
336817a48c7cSmrg	    build_libtool_libs=no
336917a48c7cSmrg	    build_old_libs=yes
337017a48c7cSmrg	  fi
337117a48c7cSmrg	else
337217a48c7cSmrg	  # Don't allow undefined symbols.
337317a48c7cSmrg	  allow_undefined_flag="$no_undefined_flag"
337417a48c7cSmrg	fi
337517a48c7cSmrg      fi
337617a48c7cSmrg
337717a48c7cSmrg      if test "$mode" != relink; then
337817a48c7cSmrg	# Remove our outputs, but don't remove object files since they
337917a48c7cSmrg	# may have been created when compiling PIC objects.
338017a48c7cSmrg	removelist=
338117a48c7cSmrg	tempremovelist=`$echo "$output_objdir/*"`
338217a48c7cSmrg	for p in $tempremovelist; do
338317a48c7cSmrg	  case $p in
338417a48c7cSmrg	    *.$objext)
338517a48c7cSmrg	       ;;
338617a48c7cSmrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
338717a48c7cSmrg	       if test "X$precious_files_regex" != "X"; then
338817a48c7cSmrg	         if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
338917a48c7cSmrg	         then
339017a48c7cSmrg		   continue
339117a48c7cSmrg		 fi
339217a48c7cSmrg	       fi
339317a48c7cSmrg	       removelist="$removelist $p"
339417a48c7cSmrg	       ;;
339517a48c7cSmrg	    *) ;;
339617a48c7cSmrg	  esac
339717a48c7cSmrg	done
339817a48c7cSmrg	if test -n "$removelist"; then
339917a48c7cSmrg	  $show "${rm}r $removelist"
340017a48c7cSmrg	  $run ${rm}r $removelist
340117a48c7cSmrg	fi
340217a48c7cSmrg      fi
340317a48c7cSmrg
340417a48c7cSmrg      # Now set the variables for building old libraries.
340517a48c7cSmrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
340617a48c7cSmrg	oldlibs="$oldlibs $output_objdir/$libname.$libext"
340717a48c7cSmrg
340817a48c7cSmrg	# Transform .lo files to .o files.
340917a48c7cSmrg	oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
341017a48c7cSmrg      fi
341117a48c7cSmrg
341217a48c7cSmrg      # Eliminate all temporary directories.
341317a48c7cSmrg      for path in $notinst_path; do
341417a48c7cSmrg	lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"`
341517a48c7cSmrg	deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"`
341617a48c7cSmrg	dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"`
341717a48c7cSmrg      done
341817a48c7cSmrg
341917a48c7cSmrg      if test -n "$xrpath"; then
342017a48c7cSmrg	# If the user specified any rpath flags, then add them.
342117a48c7cSmrg	temp_xrpath=
342217a48c7cSmrg	for libdir in $xrpath; do
342317a48c7cSmrg	  temp_xrpath="$temp_xrpath -R$libdir"
342417a48c7cSmrg	  case "$finalize_rpath " in
342517a48c7cSmrg	  *" $libdir "*) ;;
342617a48c7cSmrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
342717a48c7cSmrg	  esac
342817a48c7cSmrg	done
342917a48c7cSmrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
343017a48c7cSmrg	  dependency_libs="$temp_xrpath $dependency_libs"
343117a48c7cSmrg	fi
343217a48c7cSmrg      fi
343317a48c7cSmrg
343417a48c7cSmrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
343517a48c7cSmrg      old_dlfiles="$dlfiles"
343617a48c7cSmrg      dlfiles=
343717a48c7cSmrg      for lib in $old_dlfiles; do
343817a48c7cSmrg	case " $dlprefiles $dlfiles " in
343917a48c7cSmrg	*" $lib "*) ;;
344017a48c7cSmrg	*) dlfiles="$dlfiles $lib" ;;
344117a48c7cSmrg	esac
344217a48c7cSmrg      done
344317a48c7cSmrg
344417a48c7cSmrg      # Make sure dlprefiles contains only unique files
344517a48c7cSmrg      old_dlprefiles="$dlprefiles"
344617a48c7cSmrg      dlprefiles=
344717a48c7cSmrg      for lib in $old_dlprefiles; do
344817a48c7cSmrg	case "$dlprefiles " in
344917a48c7cSmrg	*" $lib "*) ;;
345017a48c7cSmrg	*) dlprefiles="$dlprefiles $lib" ;;
345117a48c7cSmrg	esac
345217a48c7cSmrg      done
345317a48c7cSmrg
345417a48c7cSmrg      if test "$build_libtool_libs" = yes; then
345517a48c7cSmrg	if test -n "$rpath"; then
345617a48c7cSmrg	  case $host in
345717a48c7cSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*)
345817a48c7cSmrg	    # these systems don't actually have a c library (as such)!
345917a48c7cSmrg	    ;;
346017a48c7cSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
346117a48c7cSmrg	    # Rhapsody C library is in the System framework
346217a48c7cSmrg	    deplibs="$deplibs -framework System"
346317a48c7cSmrg	    ;;
346417a48c7cSmrg	  *-*-netbsd*)
346517a48c7cSmrg	    # Don't link with libc until the a.out ld.so is fixed.
346617a48c7cSmrg	    ;;
346717a48c7cSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
346817a48c7cSmrg	    # Do not include libc due to us having libc/libc_r.
346917a48c7cSmrg	    ;;
347017a48c7cSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
347117a48c7cSmrg	    # Causes problems with __ctype
347217a48c7cSmrg	    ;;
347317a48c7cSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
347417a48c7cSmrg	    # Compiler inserts libc in the correct place for threads to work
347517a48c7cSmrg	    ;;
347617a48c7cSmrg 	  *)
347717a48c7cSmrg	    # Add libc to deplibs on all other systems if necessary.
347817a48c7cSmrg	    if test "$build_libtool_need_lc" = "yes"; then
347917a48c7cSmrg	      deplibs="$deplibs -lc"
348017a48c7cSmrg	    fi
348117a48c7cSmrg	    ;;
348217a48c7cSmrg	  esac
348317a48c7cSmrg	fi
348417a48c7cSmrg
348517a48c7cSmrg	# Transform deplibs into only deplibs that can be linked in shared.
348617a48c7cSmrg	name_save=$name
348717a48c7cSmrg	libname_save=$libname
348817a48c7cSmrg	release_save=$release
348917a48c7cSmrg	versuffix_save=$versuffix
349017a48c7cSmrg	major_save=$major
349117a48c7cSmrg	# I'm not sure if I'm treating the release correctly.  I think
349217a48c7cSmrg	# release should show up in the -l (ie -lgmp5) so we don't want to
349317a48c7cSmrg	# add it in twice.  Is that correct?
349417a48c7cSmrg	release=""
349517a48c7cSmrg	versuffix=""
349617a48c7cSmrg	major=""
349717a48c7cSmrg	newdeplibs=
349817a48c7cSmrg	droppeddeps=no
349917a48c7cSmrg	case $deplibs_check_method in
350017a48c7cSmrg	pass_all)
350117a48c7cSmrg	  # Don't check for shared/static.  Everything works.
350217a48c7cSmrg	  # This might be a little naive.  We might want to check
350317a48c7cSmrg	  # whether the library exists or not.  But this is on
350417a48c7cSmrg	  # osf3 & osf4 and I'm not really sure... Just
350517a48c7cSmrg	  # implementing what was already the behavior.
350617a48c7cSmrg	  newdeplibs=$deplibs
350717a48c7cSmrg	  ;;
350817a48c7cSmrg	test_compile)
350917a48c7cSmrg	  # This code stresses the "libraries are programs" paradigm to its
351017a48c7cSmrg	  # limits. Maybe even breaks it.  We compile a program, linking it
351117a48c7cSmrg	  # against the deplibs as a proxy for the library.  Then we can check
351217a48c7cSmrg	  # whether they linked in statically or dynamically with ldd.
351317a48c7cSmrg	  $rm conftest.c
351417a48c7cSmrg	  cat > conftest.c <<EOF
351517a48c7cSmrg	  int main() { return 0; }
351617a48c7cSmrgEOF
351717a48c7cSmrg	  $rm conftest
351817a48c7cSmrg	  $LTCC $LTCFLAGS -o conftest conftest.c $deplibs
351917a48c7cSmrg	  if test "$?" -eq 0 ; then
352017a48c7cSmrg	    ldd_output=`ldd conftest`
352117a48c7cSmrg	    for i in $deplibs; do
352217a48c7cSmrg	      name=`expr $i : '-l\(.*\)'`
352317a48c7cSmrg	      # If $name is empty we are operating on a -L argument.
352417a48c7cSmrg              if test "$name" != "" && test "$name" -ne "0"; then
352517a48c7cSmrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
352617a48c7cSmrg		  case " $predeps $postdeps " in
352717a48c7cSmrg		  *" $i "*)
352817a48c7cSmrg		    newdeplibs="$newdeplibs $i"
352917a48c7cSmrg		    i=""
353017a48c7cSmrg		    ;;
353117a48c7cSmrg		  esac
353217a48c7cSmrg	        fi
353317a48c7cSmrg		if test -n "$i" ; then
353417a48c7cSmrg		  libname=`eval \\$echo \"$libname_spec\"`
353517a48c7cSmrg		  deplib_matches=`eval \\$echo \"$library_names_spec\"`
353617a48c7cSmrg		  set dummy $deplib_matches
353717a48c7cSmrg		  deplib_match=$2
353817a48c7cSmrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
353917a48c7cSmrg		    newdeplibs="$newdeplibs $i"
354017a48c7cSmrg		  else
354117a48c7cSmrg		    droppeddeps=yes
354217a48c7cSmrg		    $echo
354317a48c7cSmrg		    $echo "*** Warning: dynamic linker does not accept needed library $i."
354417a48c7cSmrg		    $echo "*** I have the capability to make that library automatically link in when"
354517a48c7cSmrg		    $echo "*** you link to this library.  But I can only do this if you have a"
354617a48c7cSmrg		    $echo "*** shared version of the library, which I believe you do not have"
354717a48c7cSmrg		    $echo "*** because a test_compile did reveal that the linker did not use it for"
354817a48c7cSmrg		    $echo "*** its dynamic dependency list that programs get resolved with at runtime."
354917a48c7cSmrg		  fi
355017a48c7cSmrg		fi
355117a48c7cSmrg	      else
355217a48c7cSmrg		newdeplibs="$newdeplibs $i"
355317a48c7cSmrg	      fi
355417a48c7cSmrg	    done
355517a48c7cSmrg	  else
355617a48c7cSmrg	    # Error occurred in the first compile.  Let's try to salvage
355717a48c7cSmrg	    # the situation: Compile a separate program for each library.
355817a48c7cSmrg	    for i in $deplibs; do
355917a48c7cSmrg	      name=`expr $i : '-l\(.*\)'`
356017a48c7cSmrg	      # If $name is empty we are operating on a -L argument.
356117a48c7cSmrg              if test "$name" != "" && test "$name" != "0"; then
356217a48c7cSmrg		$rm conftest
356317a48c7cSmrg		$LTCC $LTCFLAGS -o conftest conftest.c $i
356417a48c7cSmrg		# Did it work?
356517a48c7cSmrg		if test "$?" -eq 0 ; then
356617a48c7cSmrg		  ldd_output=`ldd conftest`
356717a48c7cSmrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
356817a48c7cSmrg		    case " $predeps $postdeps " in
356917a48c7cSmrg		    *" $i "*)
357017a48c7cSmrg		      newdeplibs="$newdeplibs $i"
357117a48c7cSmrg		      i=""
357217a48c7cSmrg		      ;;
357317a48c7cSmrg		    esac
357417a48c7cSmrg		  fi
357517a48c7cSmrg		  if test -n "$i" ; then
357617a48c7cSmrg		    libname=`eval \\$echo \"$libname_spec\"`
357717a48c7cSmrg		    deplib_matches=`eval \\$echo \"$library_names_spec\"`
357817a48c7cSmrg		    set dummy $deplib_matches
357917a48c7cSmrg		    deplib_match=$2
358017a48c7cSmrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
358117a48c7cSmrg		      newdeplibs="$newdeplibs $i"
358217a48c7cSmrg		    else
358317a48c7cSmrg		      droppeddeps=yes
358417a48c7cSmrg		      $echo
358517a48c7cSmrg		      $echo "*** Warning: dynamic linker does not accept needed library $i."
358617a48c7cSmrg		      $echo "*** I have the capability to make that library automatically link in when"
358717a48c7cSmrg		      $echo "*** you link to this library.  But I can only do this if you have a"
358817a48c7cSmrg		      $echo "*** shared version of the library, which you do not appear to have"
358917a48c7cSmrg		      $echo "*** because a test_compile did reveal that the linker did not use this one"
359017a48c7cSmrg		      $echo "*** as a dynamic dependency that programs can get resolved with at runtime."
359117a48c7cSmrg		    fi
359217a48c7cSmrg		  fi
359317a48c7cSmrg		else
359417a48c7cSmrg		  droppeddeps=yes
359517a48c7cSmrg		  $echo
359617a48c7cSmrg		  $echo "*** Warning!  Library $i is needed by this library but I was not able to"
359717a48c7cSmrg		  $echo "***  make it link in!  You will probably need to install it or some"
359817a48c7cSmrg		  $echo "*** library that it depends on before this library will be fully"
359917a48c7cSmrg		  $echo "*** functional.  Installing it before continuing would be even better."
360017a48c7cSmrg		fi
360117a48c7cSmrg	      else
360217a48c7cSmrg		newdeplibs="$newdeplibs $i"
360317a48c7cSmrg	      fi
360417a48c7cSmrg	    done
360517a48c7cSmrg	  fi
360617a48c7cSmrg	  ;;
360717a48c7cSmrg	file_magic*)
360817a48c7cSmrg	  set dummy $deplibs_check_method
360917a48c7cSmrg	  file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
361017a48c7cSmrg	  for a_deplib in $deplibs; do
361117a48c7cSmrg	    name=`expr $a_deplib : '-l\(.*\)'`
361217a48c7cSmrg	    # If $name is empty we are operating on a -L argument.
361317a48c7cSmrg            if test "$name" != "" && test  "$name" != "0"; then
361417a48c7cSmrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
361517a48c7cSmrg		case " $predeps $postdeps " in
361617a48c7cSmrg		*" $a_deplib "*)
361717a48c7cSmrg		  newdeplibs="$newdeplibs $a_deplib"
361817a48c7cSmrg		  a_deplib=""
361917a48c7cSmrg		  ;;
362017a48c7cSmrg		esac
362117a48c7cSmrg	      fi
362217a48c7cSmrg	      if test -n "$a_deplib" ; then
362317a48c7cSmrg		libname=`eval \\$echo \"$libname_spec\"`
362417a48c7cSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
362517a48c7cSmrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
362617a48c7cSmrg		  for potent_lib in $potential_libs; do
362717a48c7cSmrg		      # Follow soft links.
362817a48c7cSmrg		      if ls -lLd "$potent_lib" 2>/dev/null \
362917a48c7cSmrg			 | grep " -> " >/dev/null; then
363017a48c7cSmrg			continue
363117a48c7cSmrg		      fi
363217a48c7cSmrg		      # The statement above tries to avoid entering an
363317a48c7cSmrg		      # endless loop below, in case of cyclic links.
363417a48c7cSmrg		      # We might still enter an endless loop, since a link
363517a48c7cSmrg		      # loop can be closed while we follow links,
363617a48c7cSmrg		      # but so what?
363717a48c7cSmrg		      potlib="$potent_lib"
363817a48c7cSmrg		      while test -h "$potlib" 2>/dev/null; do
363917a48c7cSmrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
364017a48c7cSmrg			case $potliblink in
364117a48c7cSmrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
364217a48c7cSmrg			*) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
364317a48c7cSmrg			esac
364417a48c7cSmrg		      done
364517a48c7cSmrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
364617a48c7cSmrg			 | ${SED} 10q \
364717a48c7cSmrg			 | $EGREP "$file_magic_regex" > /dev/null; then
364817a48c7cSmrg			newdeplibs="$newdeplibs $a_deplib"
364917a48c7cSmrg			a_deplib=""
365017a48c7cSmrg			break 2
365117a48c7cSmrg		      fi
365217a48c7cSmrg		  done
365317a48c7cSmrg		done
365417a48c7cSmrg	      fi
365517a48c7cSmrg	      if test -n "$a_deplib" ; then
365617a48c7cSmrg		droppeddeps=yes
365717a48c7cSmrg		$echo
365817a48c7cSmrg		$echo "*** Warning: linker path does not have real file for library $a_deplib."
365917a48c7cSmrg		$echo "*** I have the capability to make that library automatically link in when"
366017a48c7cSmrg		$echo "*** you link to this library.  But I can only do this if you have a"
366117a48c7cSmrg		$echo "*** shared version of the library, which you do not appear to have"
366217a48c7cSmrg		$echo "*** because I did check the linker path looking for a file starting"
366317a48c7cSmrg		if test -z "$potlib" ; then
366417a48c7cSmrg		  $echo "*** with $libname but no candidates were found. (...for file magic test)"
366517a48c7cSmrg		else
366617a48c7cSmrg		  $echo "*** with $libname and none of the candidates passed a file format test"
366717a48c7cSmrg		  $echo "*** using a file magic. Last file checked: $potlib"
366817a48c7cSmrg		fi
366917a48c7cSmrg	      fi
367017a48c7cSmrg	    else
367117a48c7cSmrg	      # Add a -L argument.
367217a48c7cSmrg	      newdeplibs="$newdeplibs $a_deplib"
367317a48c7cSmrg	    fi
367417a48c7cSmrg	  done # Gone through all deplibs.
367517a48c7cSmrg	  ;;
367617a48c7cSmrg	match_pattern*)
367717a48c7cSmrg	  set dummy $deplibs_check_method
367817a48c7cSmrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
367917a48c7cSmrg	  for a_deplib in $deplibs; do
368017a48c7cSmrg	    name=`expr $a_deplib : '-l\(.*\)'`
368117a48c7cSmrg	    # If $name is empty we are operating on a -L argument.
368217a48c7cSmrg	    if test -n "$name" && test "$name" != "0"; then
368317a48c7cSmrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
368417a48c7cSmrg		case " $predeps $postdeps " in
368517a48c7cSmrg		*" $a_deplib "*)
368617a48c7cSmrg		  newdeplibs="$newdeplibs $a_deplib"
368717a48c7cSmrg		  a_deplib=""
368817a48c7cSmrg		  ;;
368917a48c7cSmrg		esac
369017a48c7cSmrg	      fi
369117a48c7cSmrg	      if test -n "$a_deplib" ; then
369217a48c7cSmrg		libname=`eval \\$echo \"$libname_spec\"`
369317a48c7cSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
369417a48c7cSmrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
369517a48c7cSmrg		  for potent_lib in $potential_libs; do
369617a48c7cSmrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
369717a48c7cSmrg		    if eval $echo \"$potent_lib\" 2>/dev/null \
369817a48c7cSmrg		        | ${SED} 10q \
369917a48c7cSmrg		        | $EGREP "$match_pattern_regex" > /dev/null; then
370017a48c7cSmrg		      newdeplibs="$newdeplibs $a_deplib"
370117a48c7cSmrg		      a_deplib=""
370217a48c7cSmrg		      break 2
370317a48c7cSmrg		    fi
370417a48c7cSmrg		  done
370517a48c7cSmrg		done
370617a48c7cSmrg	      fi
370717a48c7cSmrg	      if test -n "$a_deplib" ; then
370817a48c7cSmrg		droppeddeps=yes
370917a48c7cSmrg		$echo
371017a48c7cSmrg		$echo "*** Warning: linker path does not have real file for library $a_deplib."
371117a48c7cSmrg		$echo "*** I have the capability to make that library automatically link in when"
371217a48c7cSmrg		$echo "*** you link to this library.  But I can only do this if you have a"
371317a48c7cSmrg		$echo "*** shared version of the library, which you do not appear to have"
371417a48c7cSmrg		$echo "*** because I did check the linker path looking for a file starting"
371517a48c7cSmrg		if test -z "$potlib" ; then
371617a48c7cSmrg		  $echo "*** with $libname but no candidates were found. (...for regex pattern test)"
371717a48c7cSmrg		else
371817a48c7cSmrg		  $echo "*** with $libname and none of the candidates passed a file format test"
371917a48c7cSmrg		  $echo "*** using a regex pattern. Last file checked: $potlib"
372017a48c7cSmrg		fi
372117a48c7cSmrg	      fi
372217a48c7cSmrg	    else
372317a48c7cSmrg	      # Add a -L argument.
372417a48c7cSmrg	      newdeplibs="$newdeplibs $a_deplib"
372517a48c7cSmrg	    fi
372617a48c7cSmrg	  done # Gone through all deplibs.
372717a48c7cSmrg	  ;;
372817a48c7cSmrg	none | unknown | *)
372917a48c7cSmrg	  newdeplibs=""
373017a48c7cSmrg	  tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
373117a48c7cSmrg	    -e 's/ -[LR][^ ]*//g'`
373217a48c7cSmrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
373317a48c7cSmrg	    for i in $predeps $postdeps ; do
373417a48c7cSmrg	      # can't use Xsed below, because $i might contain '/'
373517a48c7cSmrg	      tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"`
373617a48c7cSmrg	    done
373717a48c7cSmrg	  fi
373817a48c7cSmrg	  if $echo "X $tmp_deplibs" | $Xsed -e 's/[ 	]//g' \
373917a48c7cSmrg	    | grep . >/dev/null; then
374017a48c7cSmrg	    $echo
374117a48c7cSmrg	    if test "X$deplibs_check_method" = "Xnone"; then
374217a48c7cSmrg	      $echo "*** Warning: inter-library dependencies are not supported in this platform."
374317a48c7cSmrg	    else
374417a48c7cSmrg	      $echo "*** Warning: inter-library dependencies are not known to be supported."
374517a48c7cSmrg	    fi
374617a48c7cSmrg	    $echo "*** All declared inter-library dependencies are being dropped."
374717a48c7cSmrg	    droppeddeps=yes
374817a48c7cSmrg	  fi
374917a48c7cSmrg	  ;;
375017a48c7cSmrg	esac
375117a48c7cSmrg	versuffix=$versuffix_save
375217a48c7cSmrg	major=$major_save
375317a48c7cSmrg	release=$release_save
375417a48c7cSmrg	libname=$libname_save
375517a48c7cSmrg	name=$name_save
375617a48c7cSmrg
375717a48c7cSmrg	case $host in
375817a48c7cSmrg	*-*-rhapsody* | *-*-darwin1.[012])
375917a48c7cSmrg	  # On Rhapsody replace the C library is the System framework
376017a48c7cSmrg	  newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'`
376117a48c7cSmrg	  ;;
376217a48c7cSmrg	esac
376317a48c7cSmrg
376417a48c7cSmrg	if test "$droppeddeps" = yes; then
376517a48c7cSmrg	  if test "$module" = yes; then
376617a48c7cSmrg	    $echo
376717a48c7cSmrg	    $echo "*** Warning: libtool could not satisfy all declared inter-library"
376817a48c7cSmrg	    $echo "*** dependencies of module $libname.  Therefore, libtool will create"
376917a48c7cSmrg	    $echo "*** a static module, that should work as long as the dlopening"
377017a48c7cSmrg	    $echo "*** application is linked with the -dlopen flag."
377117a48c7cSmrg	    if test -z "$global_symbol_pipe"; then
377217a48c7cSmrg	      $echo
377317a48c7cSmrg	      $echo "*** However, this would only work if libtool was able to extract symbol"
377417a48c7cSmrg	      $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
377517a48c7cSmrg	      $echo "*** not find such a program.  So, this module is probably useless."
377617a48c7cSmrg	      $echo "*** \`nm' from GNU binutils and a full rebuild may help."
377717a48c7cSmrg	    fi
377817a48c7cSmrg	    if test "$build_old_libs" = no; then
377917a48c7cSmrg	      oldlibs="$output_objdir/$libname.$libext"
378017a48c7cSmrg	      build_libtool_libs=module
378117a48c7cSmrg	      build_old_libs=yes
378217a48c7cSmrg	    else
378317a48c7cSmrg	      build_libtool_libs=no
378417a48c7cSmrg	    fi
378517a48c7cSmrg	  else
378617a48c7cSmrg	    $echo "*** The inter-library dependencies that have been dropped here will be"
378717a48c7cSmrg	    $echo "*** automatically added whenever a program is linked with this library"
378817a48c7cSmrg	    $echo "*** or is declared to -dlopen it."
378917a48c7cSmrg
379017a48c7cSmrg	    if test "$allow_undefined" = no; then
379117a48c7cSmrg	      $echo
379217a48c7cSmrg	      $echo "*** Since this library must not contain undefined symbols,"
379317a48c7cSmrg	      $echo "*** because either the platform does not support them or"
379417a48c7cSmrg	      $echo "*** it was explicitly requested with -no-undefined,"
379517a48c7cSmrg	      $echo "*** libtool will only create a static version of it."
379617a48c7cSmrg	      if test "$build_old_libs" = no; then
379717a48c7cSmrg		oldlibs="$output_objdir/$libname.$libext"
379817a48c7cSmrg		build_libtool_libs=module
379917a48c7cSmrg		build_old_libs=yes
380017a48c7cSmrg	      else
380117a48c7cSmrg		build_libtool_libs=no
380217a48c7cSmrg	      fi
380317a48c7cSmrg	    fi
380417a48c7cSmrg	  fi
380517a48c7cSmrg	fi
380617a48c7cSmrg	# Done checking deplibs!
380717a48c7cSmrg	deplibs=$newdeplibs
380817a48c7cSmrg      fi
380917a48c7cSmrg
381017a48c7cSmrg
381117a48c7cSmrg      # move library search paths that coincide with paths to not yet
381217a48c7cSmrg      # installed libraries to the beginning of the library search list
381317a48c7cSmrg      new_libs=
381417a48c7cSmrg      for path in $notinst_path; do
381517a48c7cSmrg	case " $new_libs " in
381617a48c7cSmrg	*" -L$path/$objdir "*) ;;
381717a48c7cSmrg	*)
381817a48c7cSmrg	  case " $deplibs " in
381917a48c7cSmrg	  *" -L$path/$objdir "*)
382017a48c7cSmrg	    new_libs="$new_libs -L$path/$objdir" ;;
382117a48c7cSmrg	  esac
382217a48c7cSmrg	  ;;
382317a48c7cSmrg	esac
382417a48c7cSmrg      done
382517a48c7cSmrg      for deplib in $deplibs; do
382617a48c7cSmrg	case $deplib in
382717a48c7cSmrg	-L*)
382817a48c7cSmrg	  case " $new_libs " in
382917a48c7cSmrg	  *" $deplib "*) ;;
383017a48c7cSmrg	  *) new_libs="$new_libs $deplib" ;;
383117a48c7cSmrg	  esac
383217a48c7cSmrg	  ;;
383317a48c7cSmrg	*) new_libs="$new_libs $deplib" ;;
383417a48c7cSmrg	esac
383517a48c7cSmrg      done
383617a48c7cSmrg      deplibs="$new_libs"
383717a48c7cSmrg
383817a48c7cSmrg
383917a48c7cSmrg      # All the library-specific variables (install_libdir is set above).
384017a48c7cSmrg      library_names=
384117a48c7cSmrg      old_library=
384217a48c7cSmrg      dlname=
384317a48c7cSmrg
384417a48c7cSmrg      # Test again, we may have decided not to build it any more
384517a48c7cSmrg      if test "$build_libtool_libs" = yes; then
384617a48c7cSmrg	if test "$hardcode_into_libs" = yes; then
384717a48c7cSmrg	  # Hardcode the library paths
384817a48c7cSmrg	  hardcode_libdirs=
384917a48c7cSmrg	  dep_rpath=
385017a48c7cSmrg	  rpath="$finalize_rpath"
385117a48c7cSmrg	  test "$mode" != relink && rpath="$compile_rpath$rpath"
385217a48c7cSmrg	  for libdir in $rpath; do
385317a48c7cSmrg	    if test -n "$hardcode_libdir_flag_spec"; then
385417a48c7cSmrg	      if test -n "$hardcode_libdir_separator"; then
385517a48c7cSmrg		if test -z "$hardcode_libdirs"; then
385617a48c7cSmrg		  hardcode_libdirs="$libdir"
385717a48c7cSmrg		else
385817a48c7cSmrg		  # Just accumulate the unique libdirs.
385917a48c7cSmrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
386017a48c7cSmrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
386117a48c7cSmrg		    ;;
386217a48c7cSmrg		  *)
386317a48c7cSmrg		    hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
386417a48c7cSmrg		    ;;
386517a48c7cSmrg		  esac
386617a48c7cSmrg		fi
386717a48c7cSmrg	      else
386817a48c7cSmrg		eval flag=\"$hardcode_libdir_flag_spec\"
386917a48c7cSmrg		dep_rpath="$dep_rpath $flag"
387017a48c7cSmrg	      fi
387117a48c7cSmrg	    elif test -n "$runpath_var"; then
387217a48c7cSmrg	      case "$perm_rpath " in
387317a48c7cSmrg	      *" $libdir "*) ;;
387417a48c7cSmrg	      *) perm_rpath="$perm_rpath $libdir" ;;
387517a48c7cSmrg	      esac
387617a48c7cSmrg	    fi
387717a48c7cSmrg	  done
387817a48c7cSmrg	  # Substitute the hardcoded libdirs into the rpath.
387917a48c7cSmrg	  if test -n "$hardcode_libdir_separator" &&
388017a48c7cSmrg	     test -n "$hardcode_libdirs"; then
388117a48c7cSmrg	    libdir="$hardcode_libdirs"
388217a48c7cSmrg	    if test -n "$hardcode_libdir_flag_spec_ld"; then
388317a48c7cSmrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
388417a48c7cSmrg	    else
388517a48c7cSmrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
388617a48c7cSmrg	    fi
388717a48c7cSmrg	  fi
388817a48c7cSmrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
388917a48c7cSmrg	    # We should set the runpath_var.
389017a48c7cSmrg	    rpath=
389117a48c7cSmrg	    for dir in $perm_rpath; do
389217a48c7cSmrg	      rpath="$rpath$dir:"
389317a48c7cSmrg	    done
389417a48c7cSmrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
389517a48c7cSmrg	  fi
389617a48c7cSmrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
389717a48c7cSmrg	fi
389817a48c7cSmrg
389917a48c7cSmrg	shlibpath="$finalize_shlibpath"
390017a48c7cSmrg	test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
390117a48c7cSmrg	if test -n "$shlibpath"; then
390217a48c7cSmrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
390317a48c7cSmrg	fi
390417a48c7cSmrg
390517a48c7cSmrg	# Get the real and link names of the library.
390617a48c7cSmrg	eval shared_ext=\"$shrext_cmds\"
390717a48c7cSmrg	eval library_names=\"$library_names_spec\"
390817a48c7cSmrg	set dummy $library_names
390917a48c7cSmrg	realname="$2"
391017a48c7cSmrg	shift; shift
391117a48c7cSmrg
391217a48c7cSmrg	if test -n "$soname_spec"; then
391317a48c7cSmrg	  eval soname=\"$soname_spec\"
391417a48c7cSmrg	else
391517a48c7cSmrg	  soname="$realname"
391617a48c7cSmrg	fi
391717a48c7cSmrg	if test -z "$dlname"; then
391817a48c7cSmrg	  dlname=$soname
391917a48c7cSmrg	fi
392017a48c7cSmrg
392117a48c7cSmrg	lib="$output_objdir/$realname"
392217a48c7cSmrg	linknames=
392317a48c7cSmrg	for link
392417a48c7cSmrg	do
392517a48c7cSmrg	  linknames="$linknames $link"
392617a48c7cSmrg	done
392717a48c7cSmrg
392817a48c7cSmrg	# Use standard objects if they are pic
392917a48c7cSmrg	test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
393017a48c7cSmrg
393117a48c7cSmrg	# Prepare the list of exported symbols
393217a48c7cSmrg	if test -z "$export_symbols"; then
393317a48c7cSmrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
393417a48c7cSmrg	    $show "generating symbol list for \`$libname.la'"
393517a48c7cSmrg	    export_symbols="$output_objdir/$libname.exp"
393617a48c7cSmrg	    $run $rm $export_symbols
393717a48c7cSmrg	    cmds=$export_symbols_cmds
393817a48c7cSmrg	    save_ifs="$IFS"; IFS='~'
393917a48c7cSmrg	    for cmd in $cmds; do
394017a48c7cSmrg	      IFS="$save_ifs"
394117a48c7cSmrg	      eval cmd=\"$cmd\"
394217a48c7cSmrg	      if len=`expr "X$cmd" : ".*"` &&
394317a48c7cSmrg	       test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
394417a48c7cSmrg	        $show "$cmd"
394517a48c7cSmrg	        $run eval "$cmd" || exit $?
394617a48c7cSmrg	        skipped_export=false
394717a48c7cSmrg	      else
394817a48c7cSmrg	        # The command line is too long to execute in one step.
394917a48c7cSmrg	        $show "using reloadable object file for export list..."
395017a48c7cSmrg	        skipped_export=:
395117a48c7cSmrg		# Break out early, otherwise skipped_export may be
395217a48c7cSmrg		# set to false by a later but shorter cmd.
395317a48c7cSmrg		break
395417a48c7cSmrg	      fi
395517a48c7cSmrg	    done
395617a48c7cSmrg	    IFS="$save_ifs"
395717a48c7cSmrg	    if test -n "$export_symbols_regex"; then
395817a48c7cSmrg	      $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""
395917a48c7cSmrg	      $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
396017a48c7cSmrg	      $show "$mv \"${export_symbols}T\" \"$export_symbols\""
396117a48c7cSmrg	      $run eval '$mv "${export_symbols}T" "$export_symbols"'
396217a48c7cSmrg	    fi
396317a48c7cSmrg	  fi
396417a48c7cSmrg	fi
396517a48c7cSmrg
396617a48c7cSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
396717a48c7cSmrg	  $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"'
396817a48c7cSmrg	fi
396917a48c7cSmrg
397017a48c7cSmrg	tmp_deplibs=
397117a48c7cSmrg	for test_deplib in $deplibs; do
397217a48c7cSmrg		case " $convenience " in
397317a48c7cSmrg		*" $test_deplib "*) ;;
397417a48c7cSmrg		*)
397517a48c7cSmrg			tmp_deplibs="$tmp_deplibs $test_deplib"
397617a48c7cSmrg			;;
397717a48c7cSmrg		esac
397817a48c7cSmrg	done
397917a48c7cSmrg	deplibs="$tmp_deplibs"
398017a48c7cSmrg
398117a48c7cSmrg	if test -n "$convenience"; then
398217a48c7cSmrg	  if test -n "$whole_archive_flag_spec"; then
398317a48c7cSmrg	    save_libobjs=$libobjs
398417a48c7cSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
398517a48c7cSmrg	  else
398617a48c7cSmrg	    gentop="$output_objdir/${outputname}x"
398717a48c7cSmrg	    generated="$generated $gentop"
398817a48c7cSmrg
398917a48c7cSmrg	    func_extract_archives $gentop $convenience
399017a48c7cSmrg	    libobjs="$libobjs $func_extract_archives_result"
399117a48c7cSmrg	  fi
399217a48c7cSmrg	fi
399317a48c7cSmrg	
399417a48c7cSmrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
399517a48c7cSmrg	  eval flag=\"$thread_safe_flag_spec\"
399617a48c7cSmrg	  linker_flags="$linker_flags $flag"
399717a48c7cSmrg	fi
399817a48c7cSmrg
399917a48c7cSmrg	# Make a backup of the uninstalled library when relinking
400017a48c7cSmrg	if test "$mode" = relink; then
400117a48c7cSmrg	  $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $?
400217a48c7cSmrg	fi
400317a48c7cSmrg
400417a48c7cSmrg	# Do each of the archive commands.
400517a48c7cSmrg	if test "$module" = yes && test -n "$module_cmds" ; then
400617a48c7cSmrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
400717a48c7cSmrg	    eval test_cmds=\"$module_expsym_cmds\"
400817a48c7cSmrg	    cmds=$module_expsym_cmds
400917a48c7cSmrg	  else
401017a48c7cSmrg	    eval test_cmds=\"$module_cmds\"
401117a48c7cSmrg	    cmds=$module_cmds
401217a48c7cSmrg	  fi
401317a48c7cSmrg	else
401417a48c7cSmrg	if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
401517a48c7cSmrg	  eval test_cmds=\"$archive_expsym_cmds\"
401617a48c7cSmrg	  cmds=$archive_expsym_cmds
401717a48c7cSmrg	else
401817a48c7cSmrg	  eval test_cmds=\"$archive_cmds\"
401917a48c7cSmrg	  cmds=$archive_cmds
402017a48c7cSmrg	  fi
402117a48c7cSmrg	fi
402217a48c7cSmrg
402317a48c7cSmrg	if test "X$skipped_export" != "X:" &&
402417a48c7cSmrg	   len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
402517a48c7cSmrg	   test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
402617a48c7cSmrg	  :
402717a48c7cSmrg	else
402817a48c7cSmrg	  # The command line is too long to link in one step, link piecewise.
402917a48c7cSmrg	  $echo "creating reloadable object files..."
403017a48c7cSmrg
403117a48c7cSmrg	  # Save the value of $output and $libobjs because we want to
403217a48c7cSmrg	  # use them later.  If we have whole_archive_flag_spec, we
403317a48c7cSmrg	  # want to use save_libobjs as it was before
403417a48c7cSmrg	  # whole_archive_flag_spec was expanded, because we can't
403517a48c7cSmrg	  # assume the linker understands whole_archive_flag_spec.
403617a48c7cSmrg	  # This may have to be revisited, in case too many
403717a48c7cSmrg	  # convenience libraries get linked in and end up exceeding
403817a48c7cSmrg	  # the spec.
403917a48c7cSmrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
404017a48c7cSmrg	    save_libobjs=$libobjs
404117a48c7cSmrg	  fi
404217a48c7cSmrg	  save_output=$output
404317a48c7cSmrg	  output_la=`$echo "X$output" | $Xsed -e "$basename"`
404417a48c7cSmrg
404517a48c7cSmrg	  # Clear the reloadable object creation command queue and
404617a48c7cSmrg	  # initialize k to one.
404717a48c7cSmrg	  test_cmds=
404817a48c7cSmrg	  concat_cmds=
404917a48c7cSmrg	  objlist=
405017a48c7cSmrg	  delfiles=
405117a48c7cSmrg	  last_robj=
405217a48c7cSmrg	  k=1
405317a48c7cSmrg	  output=$output_objdir/$output_la-${k}.$objext
405417a48c7cSmrg	  # Loop over the list of objects to be linked.
405517a48c7cSmrg	  for obj in $save_libobjs
405617a48c7cSmrg	  do
405717a48c7cSmrg	    eval test_cmds=\"$reload_cmds $objlist $last_robj\"
405817a48c7cSmrg	    if test "X$objlist" = X ||
405917a48c7cSmrg	       { len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
406017a48c7cSmrg		 test "$len" -le "$max_cmd_len"; }; then
406117a48c7cSmrg	      objlist="$objlist $obj"
406217a48c7cSmrg	    else
406317a48c7cSmrg	      # The command $test_cmds is almost too long, add a
406417a48c7cSmrg	      # command to the queue.
406517a48c7cSmrg	      if test "$k" -eq 1 ; then
406617a48c7cSmrg		# The first file doesn't have a previous command to add.
406717a48c7cSmrg		eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
406817a48c7cSmrg	      else
406917a48c7cSmrg		# All subsequent reloadable object files will link in
407017a48c7cSmrg		# the last one created.
407117a48c7cSmrg		eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\"
407217a48c7cSmrg	      fi
407317a48c7cSmrg	      last_robj=$output_objdir/$output_la-${k}.$objext
407417a48c7cSmrg	      k=`expr $k + 1`
407517a48c7cSmrg	      output=$output_objdir/$output_la-${k}.$objext
407617a48c7cSmrg	      objlist=$obj
407717a48c7cSmrg	      len=1
407817a48c7cSmrg	    fi
407917a48c7cSmrg	  done
408017a48c7cSmrg	  # Handle the remaining objects by creating one last
408117a48c7cSmrg	  # reloadable object file.  All subsequent reloadable object
408217a48c7cSmrg	  # files will link in the last one created.
408317a48c7cSmrg	  test -z "$concat_cmds" || concat_cmds=$concat_cmds~
408417a48c7cSmrg	  eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
408517a48c7cSmrg
408617a48c7cSmrg	  if ${skipped_export-false}; then
408717a48c7cSmrg	    $show "generating symbol list for \`$libname.la'"
408817a48c7cSmrg	    export_symbols="$output_objdir/$libname.exp"
408917a48c7cSmrg	    $run $rm $export_symbols
409017a48c7cSmrg	    libobjs=$output
409117a48c7cSmrg	    # Append the command to create the export file.
409217a48c7cSmrg	    eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\"
409317a48c7cSmrg          fi
409417a48c7cSmrg
409517a48c7cSmrg	  # Set up a command to remove the reloadable object files
409617a48c7cSmrg	  # after they are used.
409717a48c7cSmrg	  i=0
409817a48c7cSmrg	  while test "$i" -lt "$k"
409917a48c7cSmrg	  do
410017a48c7cSmrg	    i=`expr $i + 1`
410117a48c7cSmrg	    delfiles="$delfiles $output_objdir/$output_la-${i}.$objext"
410217a48c7cSmrg	  done
410317a48c7cSmrg
410417a48c7cSmrg	  $echo "creating a temporary reloadable object file: $output"
410517a48c7cSmrg
410617a48c7cSmrg	  # Loop through the commands generated above and execute them.
410717a48c7cSmrg	  save_ifs="$IFS"; IFS='~'
410817a48c7cSmrg	  for cmd in $concat_cmds; do
410917a48c7cSmrg	    IFS="$save_ifs"
411017a48c7cSmrg	    $show "$cmd"
411117a48c7cSmrg	    $run eval "$cmd" || exit $?
411217a48c7cSmrg	  done
411317a48c7cSmrg	  IFS="$save_ifs"
411417a48c7cSmrg
411517a48c7cSmrg	  libobjs=$output
411617a48c7cSmrg	  # Restore the value of output.
411717a48c7cSmrg	  output=$save_output
411817a48c7cSmrg
411917a48c7cSmrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
412017a48c7cSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
412117a48c7cSmrg	  fi
412217a48c7cSmrg	  # Expand the library linking commands again to reset the
412317a48c7cSmrg	  # value of $libobjs for piecewise linking.
412417a48c7cSmrg
412517a48c7cSmrg	  # Do each of the archive commands.
412617a48c7cSmrg	  if test "$module" = yes && test -n "$module_cmds" ; then
412717a48c7cSmrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
412817a48c7cSmrg	      cmds=$module_expsym_cmds
412917a48c7cSmrg	    else
413017a48c7cSmrg	      cmds=$module_cmds
413117a48c7cSmrg	    fi
413217a48c7cSmrg	  else
413317a48c7cSmrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
413417a48c7cSmrg	    cmds=$archive_expsym_cmds
413517a48c7cSmrg	  else
413617a48c7cSmrg	    cmds=$archive_cmds
413717a48c7cSmrg	    fi
413817a48c7cSmrg	  fi
413917a48c7cSmrg
414017a48c7cSmrg	  # Append the command to remove the reloadable object files
414117a48c7cSmrg	  # to the just-reset $cmds.
414217a48c7cSmrg	  eval cmds=\"\$cmds~\$rm $delfiles\"
414317a48c7cSmrg	fi
414417a48c7cSmrg	save_ifs="$IFS"; IFS='~'
414517a48c7cSmrg	for cmd in $cmds; do
414617a48c7cSmrg	  IFS="$save_ifs"
414717a48c7cSmrg	  eval cmd=\"$cmd\"
414817a48c7cSmrg	  $show "$cmd"
414917a48c7cSmrg	  $run eval "$cmd" || {
415017a48c7cSmrg	    lt_exit=$?
415117a48c7cSmrg
415217a48c7cSmrg	    # Restore the uninstalled library and exit
415317a48c7cSmrg	    if test "$mode" = relink; then
415417a48c7cSmrg	      $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
415517a48c7cSmrg	    fi
415617a48c7cSmrg
415717a48c7cSmrg	    exit $lt_exit
415817a48c7cSmrg	  }
415917a48c7cSmrg	done
416017a48c7cSmrg	IFS="$save_ifs"
416117a48c7cSmrg
416217a48c7cSmrg	# Restore the uninstalled library and exit
416317a48c7cSmrg	if test "$mode" = relink; then
416417a48c7cSmrg	  $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $?
416517a48c7cSmrg
416617a48c7cSmrg	  if test -n "$convenience"; then
416717a48c7cSmrg	    if test -z "$whole_archive_flag_spec"; then
416817a48c7cSmrg	      $show "${rm}r $gentop"
416917a48c7cSmrg	      $run ${rm}r "$gentop"
417017a48c7cSmrg	    fi
417117a48c7cSmrg	  fi
417217a48c7cSmrg
417317a48c7cSmrg	  exit $EXIT_SUCCESS
417417a48c7cSmrg	fi
417517a48c7cSmrg
417617a48c7cSmrg	# Create links to the real library.
417717a48c7cSmrg	for linkname in $linknames; do
417817a48c7cSmrg	  if test "$realname" != "$linkname"; then
417917a48c7cSmrg	    $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)"
418017a48c7cSmrg	    $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $?
418117a48c7cSmrg	  fi
418217a48c7cSmrg	done
418317a48c7cSmrg
418417a48c7cSmrg	# If -module or -export-dynamic was specified, set the dlname.
418517a48c7cSmrg	if test "$module" = yes || test "$export_dynamic" = yes; then
418617a48c7cSmrg	  # On all known operating systems, these are identical.
418717a48c7cSmrg	  dlname="$soname"
418817a48c7cSmrg	fi
418917a48c7cSmrg      fi
419017a48c7cSmrg      ;;
419117a48c7cSmrg
419217a48c7cSmrg    obj)
419317a48c7cSmrg      if test -n "$deplibs"; then
419417a48c7cSmrg	$echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2
419517a48c7cSmrg      fi
419617a48c7cSmrg
419717a48c7cSmrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
419817a48c7cSmrg	$echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
419917a48c7cSmrg      fi
420017a48c7cSmrg
420117a48c7cSmrg      if test -n "$rpath"; then
420217a48c7cSmrg	$echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2
420317a48c7cSmrg      fi
420417a48c7cSmrg
420517a48c7cSmrg      if test -n "$xrpath"; then
420617a48c7cSmrg	$echo "$modename: warning: \`-R' is ignored for objects" 1>&2
420717a48c7cSmrg      fi
420817a48c7cSmrg
420917a48c7cSmrg      if test -n "$vinfo"; then
421017a48c7cSmrg	$echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2
421117a48c7cSmrg      fi
421217a48c7cSmrg
421317a48c7cSmrg      if test -n "$release"; then
421417a48c7cSmrg	$echo "$modename: warning: \`-release' is ignored for objects" 1>&2
421517a48c7cSmrg      fi
421617a48c7cSmrg
421717a48c7cSmrg      case $output in
421817a48c7cSmrg      *.lo)
421917a48c7cSmrg	if test -n "$objs$old_deplibs"; then
422017a48c7cSmrg	  $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
422117a48c7cSmrg	  exit $EXIT_FAILURE
422217a48c7cSmrg	fi
422317a48c7cSmrg	libobj="$output"
422417a48c7cSmrg	obj=`$echo "X$output" | $Xsed -e "$lo2o"`
422517a48c7cSmrg	;;
422617a48c7cSmrg      *)
422717a48c7cSmrg	libobj=
422817a48c7cSmrg	obj="$output"
422917a48c7cSmrg	;;
423017a48c7cSmrg      esac
423117a48c7cSmrg
423217a48c7cSmrg      # Delete the old objects.
423317a48c7cSmrg      $run $rm $obj $libobj
423417a48c7cSmrg
423517a48c7cSmrg      # Objects from convenience libraries.  This assumes
423617a48c7cSmrg      # single-version convenience libraries.  Whenever we create
423717a48c7cSmrg      # different ones for PIC/non-PIC, this we'll have to duplicate
423817a48c7cSmrg      # the extraction.
423917a48c7cSmrg      reload_conv_objs=
424017a48c7cSmrg      gentop=
424117a48c7cSmrg      # reload_cmds runs $LD directly, so let us get rid of
424217a48c7cSmrg      # -Wl from whole_archive_flag_spec
424317a48c7cSmrg      wl=
424417a48c7cSmrg
424517a48c7cSmrg      if test -n "$convenience"; then
424617a48c7cSmrg	if test -n "$whole_archive_flag_spec"; then
424717a48c7cSmrg	  eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
424817a48c7cSmrg	else
424917a48c7cSmrg	  gentop="$output_objdir/${obj}x"
425017a48c7cSmrg	  generated="$generated $gentop"
425117a48c7cSmrg
425217a48c7cSmrg	  func_extract_archives $gentop $convenience
425317a48c7cSmrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
425417a48c7cSmrg	fi
425517a48c7cSmrg      fi
425617a48c7cSmrg
425717a48c7cSmrg      # Create the old-style object.
425817a48c7cSmrg      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
425917a48c7cSmrg
426017a48c7cSmrg      output="$obj"
426117a48c7cSmrg      cmds=$reload_cmds
426217a48c7cSmrg      save_ifs="$IFS"; IFS='~'
426317a48c7cSmrg      for cmd in $cmds; do
426417a48c7cSmrg	IFS="$save_ifs"
426517a48c7cSmrg	eval cmd=\"$cmd\"
426617a48c7cSmrg	$show "$cmd"
426717a48c7cSmrg	$run eval "$cmd" || exit $?
426817a48c7cSmrg      done
426917a48c7cSmrg      IFS="$save_ifs"
427017a48c7cSmrg
427117a48c7cSmrg      # Exit if we aren't doing a library object file.
427217a48c7cSmrg      if test -z "$libobj"; then
427317a48c7cSmrg	if test -n "$gentop"; then
427417a48c7cSmrg	  $show "${rm}r $gentop"
427517a48c7cSmrg	  $run ${rm}r $gentop
427617a48c7cSmrg	fi
427717a48c7cSmrg
427817a48c7cSmrg	exit $EXIT_SUCCESS
427917a48c7cSmrg      fi
428017a48c7cSmrg
428117a48c7cSmrg      if test "$build_libtool_libs" != yes; then
428217a48c7cSmrg	if test -n "$gentop"; then
428317a48c7cSmrg	  $show "${rm}r $gentop"
428417a48c7cSmrg	  $run ${rm}r $gentop
428517a48c7cSmrg	fi
428617a48c7cSmrg
428717a48c7cSmrg	# Create an invalid libtool object if no PIC, so that we don't
428817a48c7cSmrg	# accidentally link it into a program.
428917a48c7cSmrg	# $show "echo timestamp > $libobj"
429017a48c7cSmrg	# $run eval "echo timestamp > $libobj" || exit $?
429117a48c7cSmrg	exit $EXIT_SUCCESS
429217a48c7cSmrg      fi
429317a48c7cSmrg
429417a48c7cSmrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
429517a48c7cSmrg	# Only do commands if we really have different PIC objects.
429617a48c7cSmrg	reload_objs="$libobjs $reload_conv_objs"
429717a48c7cSmrg	output="$libobj"
429817a48c7cSmrg	cmds=$reload_cmds
429917a48c7cSmrg	save_ifs="$IFS"; IFS='~'
430017a48c7cSmrg	for cmd in $cmds; do
430117a48c7cSmrg	  IFS="$save_ifs"
430217a48c7cSmrg	  eval cmd=\"$cmd\"
430317a48c7cSmrg	  $show "$cmd"
430417a48c7cSmrg	  $run eval "$cmd" || exit $?
430517a48c7cSmrg	done
430617a48c7cSmrg	IFS="$save_ifs"
430717a48c7cSmrg      fi
430817a48c7cSmrg
430917a48c7cSmrg      if test -n "$gentop"; then
431017a48c7cSmrg	$show "${rm}r $gentop"
431117a48c7cSmrg	$run ${rm}r $gentop
431217a48c7cSmrg      fi
431317a48c7cSmrg
431417a48c7cSmrg      exit $EXIT_SUCCESS
431517a48c7cSmrg      ;;
431617a48c7cSmrg
431717a48c7cSmrg    prog)
431817a48c7cSmrg      case $host in
431917a48c7cSmrg	*cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;
432017a48c7cSmrg      esac
432117a48c7cSmrg      if test -n "$vinfo"; then
432217a48c7cSmrg	$echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
432317a48c7cSmrg      fi
432417a48c7cSmrg
432517a48c7cSmrg      if test -n "$release"; then
432617a48c7cSmrg	$echo "$modename: warning: \`-release' is ignored for programs" 1>&2
432717a48c7cSmrg      fi
432817a48c7cSmrg
432917a48c7cSmrg      if test "$preload" = yes; then
433017a48c7cSmrg	if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown &&
433117a48c7cSmrg	   test "$dlopen_self_static" = unknown; then
433217a48c7cSmrg	  $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support."
433317a48c7cSmrg	fi
433417a48c7cSmrg      fi
433517a48c7cSmrg
433617a48c7cSmrg      case $host in
433717a48c7cSmrg      *-*-rhapsody* | *-*-darwin1.[012])
433817a48c7cSmrg	# On Rhapsody replace the C library is the System framework
433917a48c7cSmrg	compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
434017a48c7cSmrg	finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
434117a48c7cSmrg	;;
434217a48c7cSmrg      esac
434317a48c7cSmrg
434417a48c7cSmrg      case $host in
434517a48c7cSmrg      *darwin*)
434617a48c7cSmrg        # Don't allow lazy linking, it breaks C++ global constructors
434717a48c7cSmrg        if test "$tagname" = CXX ; then
434817a48c7cSmrg        compile_command="$compile_command ${wl}-bind_at_load"
434917a48c7cSmrg        finalize_command="$finalize_command ${wl}-bind_at_load"
435017a48c7cSmrg        fi
435117a48c7cSmrg        ;;
435217a48c7cSmrg      esac
435317a48c7cSmrg
435417a48c7cSmrg
435517a48c7cSmrg      # move library search paths that coincide with paths to not yet
435617a48c7cSmrg      # installed libraries to the beginning of the library search list
435717a48c7cSmrg      new_libs=
435817a48c7cSmrg      for path in $notinst_path; do
435917a48c7cSmrg	case " $new_libs " in
436017a48c7cSmrg	*" -L$path/$objdir "*) ;;
436117a48c7cSmrg	*)
436217a48c7cSmrg	  case " $compile_deplibs " in
436317a48c7cSmrg	  *" -L$path/$objdir "*)
436417a48c7cSmrg	    new_libs="$new_libs -L$path/$objdir" ;;
436517a48c7cSmrg	  esac
436617a48c7cSmrg	  ;;
436717a48c7cSmrg	esac
436817a48c7cSmrg      done
436917a48c7cSmrg      for deplib in $compile_deplibs; do
437017a48c7cSmrg	case $deplib in
437117a48c7cSmrg	-L*)
437217a48c7cSmrg	  case " $new_libs " in
437317a48c7cSmrg	  *" $deplib "*) ;;
437417a48c7cSmrg	  *) new_libs="$new_libs $deplib" ;;
437517a48c7cSmrg	  esac
437617a48c7cSmrg	  ;;
437717a48c7cSmrg	*) new_libs="$new_libs $deplib" ;;
437817a48c7cSmrg	esac
437917a48c7cSmrg      done
438017a48c7cSmrg      compile_deplibs="$new_libs"
438117a48c7cSmrg
438217a48c7cSmrg
438317a48c7cSmrg      compile_command="$compile_command $compile_deplibs"
438417a48c7cSmrg      finalize_command="$finalize_command $finalize_deplibs"
438517a48c7cSmrg
438617a48c7cSmrg      if test -n "$rpath$xrpath"; then
438717a48c7cSmrg	# If the user specified any rpath flags, then add them.
438817a48c7cSmrg	for libdir in $rpath $xrpath; do
438917a48c7cSmrg	  # This is the magic to use -rpath.
439017a48c7cSmrg	  case "$finalize_rpath " in
439117a48c7cSmrg	  *" $libdir "*) ;;
439217a48c7cSmrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
439317a48c7cSmrg	  esac
439417a48c7cSmrg	done
439517a48c7cSmrg      fi
439617a48c7cSmrg
439717a48c7cSmrg      # Now hardcode the library paths
439817a48c7cSmrg      rpath=
439917a48c7cSmrg      hardcode_libdirs=
440017a48c7cSmrg      for libdir in $compile_rpath $finalize_rpath; do
440117a48c7cSmrg	if test -n "$hardcode_libdir_flag_spec"; then
440217a48c7cSmrg	  if test -n "$hardcode_libdir_separator"; then
440317a48c7cSmrg	    if test -z "$hardcode_libdirs"; then
440417a48c7cSmrg	      hardcode_libdirs="$libdir"
440517a48c7cSmrg	    else
440617a48c7cSmrg	      # Just accumulate the unique libdirs.
440717a48c7cSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
440817a48c7cSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
440917a48c7cSmrg		;;
441017a48c7cSmrg	      *)
441117a48c7cSmrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
441217a48c7cSmrg		;;
441317a48c7cSmrg	      esac
441417a48c7cSmrg	    fi
441517a48c7cSmrg	  else
441617a48c7cSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
441717a48c7cSmrg	    rpath="$rpath $flag"
441817a48c7cSmrg	  fi
441917a48c7cSmrg	elif test -n "$runpath_var"; then
442017a48c7cSmrg	  case "$perm_rpath " in
442117a48c7cSmrg	  *" $libdir "*) ;;
442217a48c7cSmrg	  *) perm_rpath="$perm_rpath $libdir" ;;
442317a48c7cSmrg	  esac
442417a48c7cSmrg	fi
442517a48c7cSmrg	case $host in
442617a48c7cSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
442717a48c7cSmrg	  testbindir=`$echo "X$libdir" | $Xsed -e 's*/lib$*/bin*'`
442817a48c7cSmrg	  case :$dllsearchpath: in
442917a48c7cSmrg	  *":$libdir:"*) ;;
443017a48c7cSmrg	  *) dllsearchpath="$dllsearchpath:$libdir";;
443117a48c7cSmrg	  esac
443217a48c7cSmrg	  case :$dllsearchpath: in
443317a48c7cSmrg	  *":$testbindir:"*) ;;
443417a48c7cSmrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
443517a48c7cSmrg	  esac
443617a48c7cSmrg	  ;;
443717a48c7cSmrg	esac
443817a48c7cSmrg      done
443917a48c7cSmrg      # Substitute the hardcoded libdirs into the rpath.
444017a48c7cSmrg      if test -n "$hardcode_libdir_separator" &&
444117a48c7cSmrg	 test -n "$hardcode_libdirs"; then
444217a48c7cSmrg	libdir="$hardcode_libdirs"
444317a48c7cSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
444417a48c7cSmrg      fi
444517a48c7cSmrg      compile_rpath="$rpath"
444617a48c7cSmrg
444717a48c7cSmrg      rpath=
444817a48c7cSmrg      hardcode_libdirs=
444917a48c7cSmrg      for libdir in $finalize_rpath; do
445017a48c7cSmrg	if test -n "$hardcode_libdir_flag_spec"; then
445117a48c7cSmrg	  if test -n "$hardcode_libdir_separator"; then
445217a48c7cSmrg	    if test -z "$hardcode_libdirs"; then
445317a48c7cSmrg	      hardcode_libdirs="$libdir"
445417a48c7cSmrg	    else
445517a48c7cSmrg	      # Just accumulate the unique libdirs.
445617a48c7cSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
445717a48c7cSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
445817a48c7cSmrg		;;
445917a48c7cSmrg	      *)
446017a48c7cSmrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
446117a48c7cSmrg		;;
446217a48c7cSmrg	      esac
446317a48c7cSmrg	    fi
446417a48c7cSmrg	  else
446517a48c7cSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
446617a48c7cSmrg	    rpath="$rpath $flag"
446717a48c7cSmrg	  fi
446817a48c7cSmrg	elif test -n "$runpath_var"; then
446917a48c7cSmrg	  case "$finalize_perm_rpath " in
447017a48c7cSmrg	  *" $libdir "*) ;;
447117a48c7cSmrg	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
447217a48c7cSmrg	  esac
447317a48c7cSmrg	fi
447417a48c7cSmrg      done
447517a48c7cSmrg      # Substitute the hardcoded libdirs into the rpath.
447617a48c7cSmrg      if test -n "$hardcode_libdir_separator" &&
447717a48c7cSmrg	 test -n "$hardcode_libdirs"; then
447817a48c7cSmrg	libdir="$hardcode_libdirs"
447917a48c7cSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
448017a48c7cSmrg      fi
448117a48c7cSmrg      finalize_rpath="$rpath"
448217a48c7cSmrg
448317a48c7cSmrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
448417a48c7cSmrg	# Transform all the library objects into standard objects.
448517a48c7cSmrg	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
448617a48c7cSmrg	finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
448717a48c7cSmrg      fi
448817a48c7cSmrg
448917a48c7cSmrg      dlsyms=
449017a48c7cSmrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
449117a48c7cSmrg	if test -n "$NM" && test -n "$global_symbol_pipe"; then
449217a48c7cSmrg	  dlsyms="${outputname}S.c"
449317a48c7cSmrg	else
449417a48c7cSmrg	  $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2
449517a48c7cSmrg	fi
449617a48c7cSmrg      fi
449717a48c7cSmrg
449817a48c7cSmrg      if test -n "$dlsyms"; then
449917a48c7cSmrg	case $dlsyms in
450017a48c7cSmrg	"") ;;
450117a48c7cSmrg	*.c)
450217a48c7cSmrg	  # Discover the nlist of each of the dlfiles.
450317a48c7cSmrg	  nlist="$output_objdir/${outputname}.nm"
450417a48c7cSmrg
450517a48c7cSmrg	  $show "$rm $nlist ${nlist}S ${nlist}T"
450617a48c7cSmrg	  $run $rm "$nlist" "${nlist}S" "${nlist}T"
450717a48c7cSmrg
450817a48c7cSmrg	  # Parse the name list into a source file.
450917a48c7cSmrg	  $show "creating $output_objdir/$dlsyms"
451017a48c7cSmrg
451117a48c7cSmrg	  test -z "$run" && $echo > "$output_objdir/$dlsyms" "\
451217a48c7cSmrg/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */
451317a48c7cSmrg/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */
451417a48c7cSmrg
451517a48c7cSmrg#ifdef __cplusplus
451617a48c7cSmrgextern \"C\" {
451717a48c7cSmrg#endif
451817a48c7cSmrg
451917a48c7cSmrg/* Prevent the only kind of declaration conflicts we can make. */
452017a48c7cSmrg#define lt_preloaded_symbols some_other_symbol
452117a48c7cSmrg
452217a48c7cSmrg/* External symbol declarations for the compiler. */\
452317a48c7cSmrg"
452417a48c7cSmrg
452517a48c7cSmrg	  if test "$dlself" = yes; then
452617a48c7cSmrg	    $show "generating symbol list for \`$output'"
452717a48c7cSmrg
452817a48c7cSmrg	    test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist"
452917a48c7cSmrg
453017a48c7cSmrg	    # Add our own program objects to the symbol list.
453117a48c7cSmrg	    progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
453217a48c7cSmrg	    for arg in $progfiles; do
453317a48c7cSmrg	      $show "extracting global C symbols from \`$arg'"
453417a48c7cSmrg	      $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
453517a48c7cSmrg	    done
453617a48c7cSmrg
453717a48c7cSmrg	    if test -n "$exclude_expsyms"; then
453817a48c7cSmrg	      $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
453917a48c7cSmrg	      $run eval '$mv "$nlist"T "$nlist"'
454017a48c7cSmrg	    fi
454117a48c7cSmrg
454217a48c7cSmrg	    if test -n "$export_symbols_regex"; then
454317a48c7cSmrg	      $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
454417a48c7cSmrg	      $run eval '$mv "$nlist"T "$nlist"'
454517a48c7cSmrg	    fi
454617a48c7cSmrg
454717a48c7cSmrg	    # Prepare the list of exported symbols
454817a48c7cSmrg	    if test -z "$export_symbols"; then
454917a48c7cSmrg	      export_symbols="$output_objdir/$outputname.exp"
455017a48c7cSmrg	      $run $rm $export_symbols
455117a48c7cSmrg	      $run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
455217a48c7cSmrg              case $host in
455317a48c7cSmrg              *cygwin* | *mingw* )
455417a48c7cSmrg	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
455517a48c7cSmrg		$run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
455617a48c7cSmrg                ;;
455717a48c7cSmrg              esac
455817a48c7cSmrg	    else
455917a48c7cSmrg	      $run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
456017a48c7cSmrg	      $run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
456117a48c7cSmrg	      $run eval 'mv "$nlist"T "$nlist"'
456217a48c7cSmrg              case $host in
456317a48c7cSmrg              *cygwin* | *mingw* )
456417a48c7cSmrg	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
456517a48c7cSmrg		$run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
456617a48c7cSmrg                ;;
456717a48c7cSmrg              esac
456817a48c7cSmrg	    fi
456917a48c7cSmrg	  fi
457017a48c7cSmrg
457117a48c7cSmrg	  for arg in $dlprefiles; do
457217a48c7cSmrg	    $show "extracting global C symbols from \`$arg'"
457317a48c7cSmrg	    name=`$echo "$arg" | ${SED} -e 's%^.*/%%'`
457417a48c7cSmrg	    $run eval '$echo ": $name " >> "$nlist"'
457517a48c7cSmrg	    $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
457617a48c7cSmrg	  done
457717a48c7cSmrg
457817a48c7cSmrg	  if test -z "$run"; then
457917a48c7cSmrg	    # Make sure we have at least an empty file.
458017a48c7cSmrg	    test -f "$nlist" || : > "$nlist"
458117a48c7cSmrg
458217a48c7cSmrg	    if test -n "$exclude_expsyms"; then
458317a48c7cSmrg	      $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
458417a48c7cSmrg	      $mv "$nlist"T "$nlist"
458517a48c7cSmrg	    fi
458617a48c7cSmrg
458717a48c7cSmrg	    # Try sorting and uniquifying the output.
458817a48c7cSmrg	    if grep -v "^: " < "$nlist" |
458917a48c7cSmrg		if sort -k 3 </dev/null >/dev/null 2>&1; then
459017a48c7cSmrg		  sort -k 3
459117a48c7cSmrg		else
459217a48c7cSmrg		  sort +2
459317a48c7cSmrg		fi |
459417a48c7cSmrg		uniq > "$nlist"S; then
459517a48c7cSmrg	      :
459617a48c7cSmrg	    else
459717a48c7cSmrg	      grep -v "^: " < "$nlist" > "$nlist"S
459817a48c7cSmrg	    fi
459917a48c7cSmrg
460017a48c7cSmrg	    if test -f "$nlist"S; then
460117a48c7cSmrg	      eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"'
460217a48c7cSmrg	    else
460317a48c7cSmrg	      $echo '/* NONE */' >> "$output_objdir/$dlsyms"
460417a48c7cSmrg	    fi
460517a48c7cSmrg
460617a48c7cSmrg	    $echo >> "$output_objdir/$dlsyms" "\
460717a48c7cSmrg
460817a48c7cSmrg#undef lt_preloaded_symbols
460917a48c7cSmrg
461017a48c7cSmrg#if defined (__STDC__) && __STDC__
461117a48c7cSmrg# define lt_ptr void *
461217a48c7cSmrg#else
461317a48c7cSmrg# define lt_ptr char *
461417a48c7cSmrg# define const
461517a48c7cSmrg#endif
461617a48c7cSmrg
461717a48c7cSmrg/* The mapping between symbol names and symbols. */
461817a48c7cSmrg"
461917a48c7cSmrg
462017a48c7cSmrg	    case $host in
462117a48c7cSmrg	    *cygwin* | *mingw* )
462217a48c7cSmrg	  $echo >> "$output_objdir/$dlsyms" "\
462317a48c7cSmrg/* DATA imports from DLLs on WIN32 can't be const, because
462417a48c7cSmrg   runtime relocations are performed -- see ld's documentation
462517a48c7cSmrg   on pseudo-relocs */
462617a48c7cSmrgstruct {
462717a48c7cSmrg"
462817a48c7cSmrg	      ;;
462917a48c7cSmrg	    * )
463017a48c7cSmrg	  $echo >> "$output_objdir/$dlsyms" "\
463117a48c7cSmrgconst struct {
463217a48c7cSmrg"
463317a48c7cSmrg	      ;;
463417a48c7cSmrg	    esac
463517a48c7cSmrg
463617a48c7cSmrg
463717a48c7cSmrg	  $echo >> "$output_objdir/$dlsyms" "\
463817a48c7cSmrg  const char *name;
463917a48c7cSmrg  lt_ptr address;
464017a48c7cSmrg}
464117a48c7cSmrglt_preloaded_symbols[] =
464217a48c7cSmrg{\
464317a48c7cSmrg"
464417a48c7cSmrg
464517a48c7cSmrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms"
464617a48c7cSmrg
464717a48c7cSmrg	    $echo >> "$output_objdir/$dlsyms" "\
464817a48c7cSmrg  {0, (lt_ptr) 0}
464917a48c7cSmrg};
465017a48c7cSmrg
465117a48c7cSmrg/* This works around a problem in FreeBSD linker */
465217a48c7cSmrg#ifdef FREEBSD_WORKAROUND
465317a48c7cSmrgstatic const void *lt_preloaded_setup() {
465417a48c7cSmrg  return lt_preloaded_symbols;
465517a48c7cSmrg}
465617a48c7cSmrg#endif
465717a48c7cSmrg
465817a48c7cSmrg#ifdef __cplusplus
465917a48c7cSmrg}
466017a48c7cSmrg#endif\
466117a48c7cSmrg"
466217a48c7cSmrg	  fi
466317a48c7cSmrg
466417a48c7cSmrg	  pic_flag_for_symtable=
466517a48c7cSmrg	  case $host in
466617a48c7cSmrg	  # compiling the symbol table file with pic_flag works around
466717a48c7cSmrg	  # a FreeBSD bug that causes programs to crash when -lm is
466817a48c7cSmrg	  # linked before any other PIC object.  But we must not use
466917a48c7cSmrg	  # pic_flag when linking with -static.  The problem exists in
467017a48c7cSmrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
467117a48c7cSmrg	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
467217a48c7cSmrg	    case "$compile_command " in
467317a48c7cSmrg	    *" -static "*) ;;
467417a48c7cSmrg	    *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";;
467517a48c7cSmrg	    esac;;
467617a48c7cSmrg	  *-*-hpux*)
467717a48c7cSmrg	    case "$compile_command " in
467817a48c7cSmrg	    *" -static "*) ;;
467917a48c7cSmrg	    *) pic_flag_for_symtable=" $pic_flag";;
468017a48c7cSmrg	    esac
468117a48c7cSmrg	  esac
468217a48c7cSmrg
468317a48c7cSmrg	  # Now compile the dynamic symbol file.
468417a48c7cSmrg	  $show "(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
468517a48c7cSmrg	  $run eval '(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
468617a48c7cSmrg
468717a48c7cSmrg	  # Clean up the generated files.
468817a48c7cSmrg	  $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
468917a48c7cSmrg	  $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
469017a48c7cSmrg
469117a48c7cSmrg	  # Transform the symbol file into the correct name.
469217a48c7cSmrg          case $host in
469317a48c7cSmrg          *cygwin* | *mingw* )
469417a48c7cSmrg            if test -f "$output_objdir/${outputname}.def" ; then
469517a48c7cSmrg              compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
469617a48c7cSmrg              finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
469717a48c7cSmrg            else
469817a48c7cSmrg              compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
469917a48c7cSmrg              finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
470017a48c7cSmrg             fi
470117a48c7cSmrg            ;;
470217a48c7cSmrg          * )
470317a48c7cSmrg            compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
470417a48c7cSmrg            finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
470517a48c7cSmrg            ;;
470617a48c7cSmrg          esac
470717a48c7cSmrg	  ;;
470817a48c7cSmrg	*)
470917a48c7cSmrg	  $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
471017a48c7cSmrg	  exit $EXIT_FAILURE
471117a48c7cSmrg	  ;;
471217a48c7cSmrg	esac
471317a48c7cSmrg      else
471417a48c7cSmrg	# We keep going just in case the user didn't refer to
471517a48c7cSmrg	# lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
471617a48c7cSmrg	# really was required.
471717a48c7cSmrg
471817a48c7cSmrg	# Nullify the symbol file.
471917a48c7cSmrg	compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
472017a48c7cSmrg	finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
472117a48c7cSmrg      fi
472217a48c7cSmrg
472317a48c7cSmrg      if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
472417a48c7cSmrg	# Replace the output file specification.
472517a48c7cSmrg	compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
472617a48c7cSmrg	link_command="$compile_command$compile_rpath"
472717a48c7cSmrg
472817a48c7cSmrg	# We have no uninstalled library dependencies, so finalize right now.
472917a48c7cSmrg	$show "$link_command"
473017a48c7cSmrg	$run eval "$link_command"
473117a48c7cSmrg	exit_status=$?
473217a48c7cSmrg
473317a48c7cSmrg	# Delete the generated files.
473417a48c7cSmrg	if test -n "$dlsyms"; then
473517a48c7cSmrg	  $show "$rm $output_objdir/${outputname}S.${objext}"
473617a48c7cSmrg	  $run $rm "$output_objdir/${outputname}S.${objext}"
473717a48c7cSmrg	fi
473817a48c7cSmrg
473917a48c7cSmrg	exit $exit_status
474017a48c7cSmrg      fi
474117a48c7cSmrg
474217a48c7cSmrg      if test -n "$shlibpath_var"; then
474317a48c7cSmrg	# We should set the shlibpath_var
474417a48c7cSmrg	rpath=
474517a48c7cSmrg	for dir in $temp_rpath; do
474617a48c7cSmrg	  case $dir in
474717a48c7cSmrg	  [\\/]* | [A-Za-z]:[\\/]*)
474817a48c7cSmrg	    # Absolute path.
474917a48c7cSmrg	    rpath="$rpath$dir:"
475017a48c7cSmrg	    ;;
475117a48c7cSmrg	  *)
475217a48c7cSmrg	    # Relative path: add a thisdir entry.
475317a48c7cSmrg	    rpath="$rpath\$thisdir/$dir:"
475417a48c7cSmrg	    ;;
475517a48c7cSmrg	  esac
475617a48c7cSmrg	done
475717a48c7cSmrg	temp_rpath="$rpath"
475817a48c7cSmrg      fi
475917a48c7cSmrg
476017a48c7cSmrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
476117a48c7cSmrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
476217a48c7cSmrg      fi
476317a48c7cSmrg      if test -n "$finalize_shlibpath"; then
476417a48c7cSmrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
476517a48c7cSmrg      fi
476617a48c7cSmrg
476717a48c7cSmrg      compile_var=
476817a48c7cSmrg      finalize_var=
476917a48c7cSmrg      if test -n "$runpath_var"; then
477017a48c7cSmrg	if test -n "$perm_rpath"; then
477117a48c7cSmrg	  # We should set the runpath_var.
477217a48c7cSmrg	  rpath=
477317a48c7cSmrg	  for dir in $perm_rpath; do
477417a48c7cSmrg	    rpath="$rpath$dir:"
477517a48c7cSmrg	  done
477617a48c7cSmrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
477717a48c7cSmrg	fi
477817a48c7cSmrg	if test -n "$finalize_perm_rpath"; then
477917a48c7cSmrg	  # We should set the runpath_var.
478017a48c7cSmrg	  rpath=
478117a48c7cSmrg	  for dir in $finalize_perm_rpath; do
478217a48c7cSmrg	    rpath="$rpath$dir:"
478317a48c7cSmrg	  done
478417a48c7cSmrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
478517a48c7cSmrg	fi
478617a48c7cSmrg      fi
478717a48c7cSmrg
478817a48c7cSmrg      if test "$no_install" = yes; then
478917a48c7cSmrg	# We don't need to create a wrapper script.
479017a48c7cSmrg	link_command="$compile_var$compile_command$compile_rpath"
479117a48c7cSmrg	# Replace the output file specification.
479217a48c7cSmrg	link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
479317a48c7cSmrg	# Delete the old output file.
479417a48c7cSmrg	$run $rm $output
479517a48c7cSmrg	# Link the executable and exit
479617a48c7cSmrg	$show "$link_command"
479717a48c7cSmrg	$run eval "$link_command" || exit $?
479817a48c7cSmrg	exit $EXIT_SUCCESS
479917a48c7cSmrg      fi
480017a48c7cSmrg
480117a48c7cSmrg      if test "$hardcode_action" = relink; then
480217a48c7cSmrg	# Fast installation is not supported
480317a48c7cSmrg	link_command="$compile_var$compile_command$compile_rpath"
480417a48c7cSmrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
480517a48c7cSmrg
480617a48c7cSmrg	$echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2
480717a48c7cSmrg	$echo "$modename: \`$output' will be relinked during installation" 1>&2
480817a48c7cSmrg      else
480917a48c7cSmrg	if test "$fast_install" != no; then
481017a48c7cSmrg	  link_command="$finalize_var$compile_command$finalize_rpath"
481117a48c7cSmrg	  if test "$fast_install" = yes; then
481217a48c7cSmrg	    relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
481317a48c7cSmrg	  else
481417a48c7cSmrg	    # fast_install is set to needless
481517a48c7cSmrg	    relink_command=
481617a48c7cSmrg	  fi
481717a48c7cSmrg	else
481817a48c7cSmrg	  link_command="$compile_var$compile_command$compile_rpath"
481917a48c7cSmrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
482017a48c7cSmrg	fi
482117a48c7cSmrg      fi
482217a48c7cSmrg
482317a48c7cSmrg      # Replace the output file specification.
482417a48c7cSmrg      link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
482517a48c7cSmrg
482617a48c7cSmrg      # Delete the old output files.
482717a48c7cSmrg      $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname
482817a48c7cSmrg
482917a48c7cSmrg      $show "$link_command"
483017a48c7cSmrg      $run eval "$link_command" || exit $?
483117a48c7cSmrg
483217a48c7cSmrg      # Now create the wrapper script.
483317a48c7cSmrg      $show "creating $output"
483417a48c7cSmrg
483517a48c7cSmrg      # Quote the relink command for shipping.
483617a48c7cSmrg      if test -n "$relink_command"; then
483717a48c7cSmrg	# Preserve any variables that may affect compiler behavior
483817a48c7cSmrg	for var in $variables_saved_for_relink; do
483917a48c7cSmrg	  if eval test -z \"\${$var+set}\"; then
484017a48c7cSmrg	    relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
484117a48c7cSmrg	  elif eval var_value=\$$var; test -z "$var_value"; then
484217a48c7cSmrg	    relink_command="$var=; export $var; $relink_command"
484317a48c7cSmrg	  else
484417a48c7cSmrg	    var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
484517a48c7cSmrg	    relink_command="$var=\"$var_value\"; export $var; $relink_command"
484617a48c7cSmrg	  fi
484717a48c7cSmrg	done
484817a48c7cSmrg	relink_command="(cd `pwd`; $relink_command)"
484917a48c7cSmrg	relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
485017a48c7cSmrg      fi
485117a48c7cSmrg
485217a48c7cSmrg      # Quote $echo for shipping.
485317a48c7cSmrg      if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then
485417a48c7cSmrg	case $progpath in
485517a48c7cSmrg	[\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
485617a48c7cSmrg	*) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
485717a48c7cSmrg	esac
485817a48c7cSmrg	qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"`
485917a48c7cSmrg      else
486017a48c7cSmrg	qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"`
486117a48c7cSmrg      fi
486217a48c7cSmrg
486317a48c7cSmrg      # Only actually do things if our run command is non-null.
486417a48c7cSmrg      if test -z "$run"; then
486517a48c7cSmrg	# win32 will think the script is a binary if it has
486617a48c7cSmrg	# a .exe suffix, so we strip it off here.
486717a48c7cSmrg	case $output in
486817a48c7cSmrg	  *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;;
486917a48c7cSmrg	esac
487017a48c7cSmrg	# test for cygwin because mv fails w/o .exe extensions
487117a48c7cSmrg	case $host in
487217a48c7cSmrg	  *cygwin*)
487317a48c7cSmrg	    exeext=.exe
487417a48c7cSmrg	    outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;;
487517a48c7cSmrg	  *) exeext= ;;
487617a48c7cSmrg	esac
487717a48c7cSmrg	case $host in
487817a48c7cSmrg	  *cygwin* | *mingw* )
487917a48c7cSmrg            output_name=`basename $output`
488017a48c7cSmrg            output_path=`dirname $output`
488117a48c7cSmrg            cwrappersource="$output_path/$objdir/lt-$output_name.c"
488217a48c7cSmrg            cwrapper="$output_path/$output_name.exe"
488317a48c7cSmrg            $rm $cwrappersource $cwrapper
488417a48c7cSmrg            trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
488517a48c7cSmrg
488617a48c7cSmrg	    cat > $cwrappersource <<EOF
488717a48c7cSmrg
488817a48c7cSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
488917a48c7cSmrg   Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
489017a48c7cSmrg
489117a48c7cSmrg   The $output program cannot be directly executed until all the libtool
489217a48c7cSmrg   libraries that it depends on are installed.
489317a48c7cSmrg
489417a48c7cSmrg   This wrapper executable should never be moved out of the build directory.
489517a48c7cSmrg   If it is, it will not operate correctly.
489617a48c7cSmrg
489717a48c7cSmrg   Currently, it simply execs the wrapper *script* "/bin/sh $output",
489817a48c7cSmrg   but could eventually absorb all of the scripts functionality and
489917a48c7cSmrg   exec $objdir/$outputname directly.
490017a48c7cSmrg*/
490117a48c7cSmrgEOF
490217a48c7cSmrg	    cat >> $cwrappersource<<"EOF"
490317a48c7cSmrg#include <stdio.h>
490417a48c7cSmrg#include <stdlib.h>
490517a48c7cSmrg#include <unistd.h>
490617a48c7cSmrg#include <malloc.h>
490717a48c7cSmrg#include <stdarg.h>
490817a48c7cSmrg#include <assert.h>
490917a48c7cSmrg#include <string.h>
491017a48c7cSmrg#include <ctype.h>
491117a48c7cSmrg#include <sys/stat.h>
491217a48c7cSmrg
491317a48c7cSmrg#if defined(PATH_MAX)
491417a48c7cSmrg# define LT_PATHMAX PATH_MAX
491517a48c7cSmrg#elif defined(MAXPATHLEN)
491617a48c7cSmrg# define LT_PATHMAX MAXPATHLEN
491717a48c7cSmrg#else
491817a48c7cSmrg# define LT_PATHMAX 1024
491917a48c7cSmrg#endif
492017a48c7cSmrg
492117a48c7cSmrg#ifndef DIR_SEPARATOR
492217a48c7cSmrg# define DIR_SEPARATOR '/'
492317a48c7cSmrg# define PATH_SEPARATOR ':'
492417a48c7cSmrg#endif
492517a48c7cSmrg
492617a48c7cSmrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
492717a48c7cSmrg  defined (__OS2__)
492817a48c7cSmrg# define HAVE_DOS_BASED_FILE_SYSTEM
492917a48c7cSmrg# ifndef DIR_SEPARATOR_2
493017a48c7cSmrg#  define DIR_SEPARATOR_2 '\\'
493117a48c7cSmrg# endif
493217a48c7cSmrg# ifndef PATH_SEPARATOR_2
493317a48c7cSmrg#  define PATH_SEPARATOR_2 ';'
493417a48c7cSmrg# endif
493517a48c7cSmrg#endif
493617a48c7cSmrg
493717a48c7cSmrg#ifndef DIR_SEPARATOR_2
493817a48c7cSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
493917a48c7cSmrg#else /* DIR_SEPARATOR_2 */
494017a48c7cSmrg# define IS_DIR_SEPARATOR(ch) \
494117a48c7cSmrg        (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
494217a48c7cSmrg#endif /* DIR_SEPARATOR_2 */
494317a48c7cSmrg
494417a48c7cSmrg#ifndef PATH_SEPARATOR_2
494517a48c7cSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
494617a48c7cSmrg#else /* PATH_SEPARATOR_2 */
494717a48c7cSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
494817a48c7cSmrg#endif /* PATH_SEPARATOR_2 */
494917a48c7cSmrg
495017a48c7cSmrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
495117a48c7cSmrg#define XFREE(stale) do { \
495217a48c7cSmrg  if (stale) { free ((void *) stale); stale = 0; } \
495317a48c7cSmrg} while (0)
495417a48c7cSmrg
495517a48c7cSmrg/* -DDEBUG is fairly common in CFLAGS.  */
495617a48c7cSmrg#undef DEBUG
495717a48c7cSmrg#if defined DEBUGWRAPPER
495817a48c7cSmrg# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
495917a48c7cSmrg#else
496017a48c7cSmrg# define DEBUG(format, ...)
496117a48c7cSmrg#endif
496217a48c7cSmrg
496317a48c7cSmrgconst char *program_name = NULL;
496417a48c7cSmrg
496517a48c7cSmrgvoid * xmalloc (size_t num);
496617a48c7cSmrgchar * xstrdup (const char *string);
496717a48c7cSmrgconst char * base_name (const char *name);
496817a48c7cSmrgchar * find_executable(const char *wrapper);
496917a48c7cSmrgint    check_executable(const char *path);
497017a48c7cSmrgchar * strendzap(char *str, const char *pat);
497117a48c7cSmrgvoid lt_fatal (const char *message, ...);
497217a48c7cSmrg
497317a48c7cSmrgint
497417a48c7cSmrgmain (int argc, char *argv[])
497517a48c7cSmrg{
497617a48c7cSmrg  char **newargz;
497717a48c7cSmrg  int i;
497817a48c7cSmrg
497917a48c7cSmrg  program_name = (char *) xstrdup (base_name (argv[0]));
498017a48c7cSmrg  DEBUG("(main) argv[0]      : %s\n",argv[0]);
498117a48c7cSmrg  DEBUG("(main) program_name : %s\n",program_name);
498217a48c7cSmrg  newargz = XMALLOC(char *, argc+2);
498317a48c7cSmrgEOF
498417a48c7cSmrg
498517a48c7cSmrg            cat >> $cwrappersource <<EOF
498617a48c7cSmrg  newargz[0] = (char *) xstrdup("$SHELL");
498717a48c7cSmrgEOF
498817a48c7cSmrg
498917a48c7cSmrg            cat >> $cwrappersource <<"EOF"
499017a48c7cSmrg  newargz[1] = find_executable(argv[0]);
499117a48c7cSmrg  if (newargz[1] == NULL)
499217a48c7cSmrg    lt_fatal("Couldn't find %s", argv[0]);
499317a48c7cSmrg  DEBUG("(main) found exe at : %s\n",newargz[1]);
499417a48c7cSmrg  /* we know the script has the same name, without the .exe */
499517a48c7cSmrg  /* so make sure newargz[1] doesn't end in .exe */
499617a48c7cSmrg  strendzap(newargz[1],".exe");
499717a48c7cSmrg  for (i = 1; i < argc; i++)
499817a48c7cSmrg    newargz[i+1] = xstrdup(argv[i]);
499917a48c7cSmrg  newargz[argc+1] = NULL;
500017a48c7cSmrg
500117a48c7cSmrg  for (i=0; i<argc+1; i++)
500217a48c7cSmrg  {
500317a48c7cSmrg    DEBUG("(main) newargz[%d]   : %s\n",i,newargz[i]);
500417a48c7cSmrg    ;
500517a48c7cSmrg  }
500617a48c7cSmrg
500717a48c7cSmrgEOF
500817a48c7cSmrg
500917a48c7cSmrg            case $host_os in
501017a48c7cSmrg              mingw*)
501117a48c7cSmrg                cat >> $cwrappersource <<EOF
501217a48c7cSmrg  execv("$SHELL",(char const **)newargz);
501317a48c7cSmrgEOF
501417a48c7cSmrg              ;;
501517a48c7cSmrg              *)
501617a48c7cSmrg                cat >> $cwrappersource <<EOF
501717a48c7cSmrg  execv("$SHELL",newargz);
501817a48c7cSmrgEOF
501917a48c7cSmrg              ;;
502017a48c7cSmrg            esac
502117a48c7cSmrg
502217a48c7cSmrg            cat >> $cwrappersource <<"EOF"
502317a48c7cSmrg  return 127;
502417a48c7cSmrg}
502517a48c7cSmrg
502617a48c7cSmrgvoid *
502717a48c7cSmrgxmalloc (size_t num)
502817a48c7cSmrg{
502917a48c7cSmrg  void * p = (void *) malloc (num);
503017a48c7cSmrg  if (!p)
503117a48c7cSmrg    lt_fatal ("Memory exhausted");
503217a48c7cSmrg
503317a48c7cSmrg  return p;
503417a48c7cSmrg}
503517a48c7cSmrg
503617a48c7cSmrgchar *
503717a48c7cSmrgxstrdup (const char *string)
503817a48c7cSmrg{
503917a48c7cSmrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL
504017a48c7cSmrg;
504117a48c7cSmrg}
504217a48c7cSmrg
504317a48c7cSmrgconst char *
504417a48c7cSmrgbase_name (const char *name)
504517a48c7cSmrg{
504617a48c7cSmrg  const char *base;
504717a48c7cSmrg
504817a48c7cSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
504917a48c7cSmrg  /* Skip over the disk name in MSDOS pathnames. */
505017a48c7cSmrg  if (isalpha ((unsigned char)name[0]) && name[1] == ':')
505117a48c7cSmrg    name += 2;
505217a48c7cSmrg#endif
505317a48c7cSmrg
505417a48c7cSmrg  for (base = name; *name; name++)
505517a48c7cSmrg    if (IS_DIR_SEPARATOR (*name))
505617a48c7cSmrg      base = name + 1;
505717a48c7cSmrg  return base;
505817a48c7cSmrg}
505917a48c7cSmrg
506017a48c7cSmrgint
506117a48c7cSmrgcheck_executable(const char * path)
506217a48c7cSmrg{
506317a48c7cSmrg  struct stat st;
506417a48c7cSmrg
506517a48c7cSmrg  DEBUG("(check_executable)  : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!");
506617a48c7cSmrg  if ((!path) || (!*path))
506717a48c7cSmrg    return 0;
506817a48c7cSmrg
506917a48c7cSmrg  if ((stat (path, &st) >= 0) &&
507017a48c7cSmrg      (
507117a48c7cSmrg        /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */
507217a48c7cSmrg#if defined (S_IXOTH)
507317a48c7cSmrg       ((st.st_mode & S_IXOTH) == S_IXOTH) ||
507417a48c7cSmrg#endif
507517a48c7cSmrg#if defined (S_IXGRP)
507617a48c7cSmrg       ((st.st_mode & S_IXGRP) == S_IXGRP) ||
507717a48c7cSmrg#endif
507817a48c7cSmrg       ((st.st_mode & S_IXUSR) == S_IXUSR))
507917a48c7cSmrg      )
508017a48c7cSmrg    return 1;
508117a48c7cSmrg  else
508217a48c7cSmrg    return 0;
508317a48c7cSmrg}
508417a48c7cSmrg
508517a48c7cSmrg/* Searches for the full path of the wrapper.  Returns
508617a48c7cSmrg   newly allocated full path name if found, NULL otherwise */
508717a48c7cSmrgchar *
508817a48c7cSmrgfind_executable (const char* wrapper)
508917a48c7cSmrg{
509017a48c7cSmrg  int has_slash = 0;
509117a48c7cSmrg  const char* p;
509217a48c7cSmrg  const char* p_next;
509317a48c7cSmrg  /* static buffer for getcwd */
509417a48c7cSmrg  char tmp[LT_PATHMAX + 1];
509517a48c7cSmrg  int tmp_len;
509617a48c7cSmrg  char* concat_name;
509717a48c7cSmrg
509817a48c7cSmrg  DEBUG("(find_executable)  : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!");
509917a48c7cSmrg
510017a48c7cSmrg  if ((wrapper == NULL) || (*wrapper == '\0'))
510117a48c7cSmrg    return NULL;
510217a48c7cSmrg
510317a48c7cSmrg  /* Absolute path? */
510417a48c7cSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
510517a48c7cSmrg  if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':')
510617a48c7cSmrg  {
510717a48c7cSmrg    concat_name = xstrdup (wrapper);
510817a48c7cSmrg    if (check_executable(concat_name))
510917a48c7cSmrg      return concat_name;
511017a48c7cSmrg    XFREE(concat_name);
511117a48c7cSmrg  }
511217a48c7cSmrg  else
511317a48c7cSmrg  {
511417a48c7cSmrg#endif
511517a48c7cSmrg    if (IS_DIR_SEPARATOR (wrapper[0]))
511617a48c7cSmrg    {
511717a48c7cSmrg      concat_name = xstrdup (wrapper);
511817a48c7cSmrg      if (check_executable(concat_name))
511917a48c7cSmrg        return concat_name;
512017a48c7cSmrg      XFREE(concat_name);
512117a48c7cSmrg    }
512217a48c7cSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
512317a48c7cSmrg  }
512417a48c7cSmrg#endif
512517a48c7cSmrg
512617a48c7cSmrg  for (p = wrapper; *p; p++)
512717a48c7cSmrg    if (*p == '/')
512817a48c7cSmrg    {
512917a48c7cSmrg      has_slash = 1;
513017a48c7cSmrg      break;
513117a48c7cSmrg    }
513217a48c7cSmrg  if (!has_slash)
513317a48c7cSmrg  {
513417a48c7cSmrg    /* no slashes; search PATH */
513517a48c7cSmrg    const char* path = getenv ("PATH");
513617a48c7cSmrg    if (path != NULL)
513717a48c7cSmrg    {
513817a48c7cSmrg      for (p = path; *p; p = p_next)
513917a48c7cSmrg      {
514017a48c7cSmrg        const char* q;
514117a48c7cSmrg        size_t p_len;
514217a48c7cSmrg        for (q = p; *q; q++)
514317a48c7cSmrg          if (IS_PATH_SEPARATOR(*q))
514417a48c7cSmrg            break;
514517a48c7cSmrg        p_len = q - p;
514617a48c7cSmrg        p_next = (*q == '\0' ? q : q + 1);
514717a48c7cSmrg        if (p_len == 0)
514817a48c7cSmrg        {
514917a48c7cSmrg          /* empty path: current directory */
515017a48c7cSmrg          if (getcwd (tmp, LT_PATHMAX) == NULL)
515117a48c7cSmrg            lt_fatal ("getcwd failed");
515217a48c7cSmrg          tmp_len = strlen(tmp);
515317a48c7cSmrg          concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
515417a48c7cSmrg          memcpy (concat_name, tmp, tmp_len);
515517a48c7cSmrg          concat_name[tmp_len] = '/';
515617a48c7cSmrg          strcpy (concat_name + tmp_len + 1, wrapper);
515717a48c7cSmrg        }
515817a48c7cSmrg        else
515917a48c7cSmrg        {
516017a48c7cSmrg          concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1);
516117a48c7cSmrg          memcpy (concat_name, p, p_len);
516217a48c7cSmrg          concat_name[p_len] = '/';
516317a48c7cSmrg          strcpy (concat_name + p_len + 1, wrapper);
516417a48c7cSmrg        }
516517a48c7cSmrg        if (check_executable(concat_name))
516617a48c7cSmrg          return concat_name;
516717a48c7cSmrg        XFREE(concat_name);
516817a48c7cSmrg      }
516917a48c7cSmrg    }
517017a48c7cSmrg    /* not found in PATH; assume curdir */
517117a48c7cSmrg  }
517217a48c7cSmrg  /* Relative path | not found in path: prepend cwd */
517317a48c7cSmrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
517417a48c7cSmrg    lt_fatal ("getcwd failed");
517517a48c7cSmrg  tmp_len = strlen(tmp);
517617a48c7cSmrg  concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
517717a48c7cSmrg  memcpy (concat_name, tmp, tmp_len);
517817a48c7cSmrg  concat_name[tmp_len] = '/';
517917a48c7cSmrg  strcpy (concat_name + tmp_len + 1, wrapper);
518017a48c7cSmrg
518117a48c7cSmrg  if (check_executable(concat_name))
518217a48c7cSmrg    return concat_name;
518317a48c7cSmrg  XFREE(concat_name);
518417a48c7cSmrg  return NULL;
518517a48c7cSmrg}
518617a48c7cSmrg
518717a48c7cSmrgchar *
518817a48c7cSmrgstrendzap(char *str, const char *pat)
518917a48c7cSmrg{
519017a48c7cSmrg  size_t len, patlen;
519117a48c7cSmrg
519217a48c7cSmrg  assert(str != NULL);
519317a48c7cSmrg  assert(pat != NULL);
519417a48c7cSmrg
519517a48c7cSmrg  len = strlen(str);
519617a48c7cSmrg  patlen = strlen(pat);
519717a48c7cSmrg
519817a48c7cSmrg  if (patlen <= len)
519917a48c7cSmrg  {
520017a48c7cSmrg    str += len - patlen;
520117a48c7cSmrg    if (strcmp(str, pat) == 0)
520217a48c7cSmrg      *str = '\0';
520317a48c7cSmrg  }
520417a48c7cSmrg  return str;
520517a48c7cSmrg}
520617a48c7cSmrg
520717a48c7cSmrgstatic void
520817a48c7cSmrglt_error_core (int exit_status, const char * mode,
520917a48c7cSmrg          const char * message, va_list ap)
521017a48c7cSmrg{
521117a48c7cSmrg  fprintf (stderr, "%s: %s: ", program_name, mode);
521217a48c7cSmrg  vfprintf (stderr, message, ap);
521317a48c7cSmrg  fprintf (stderr, ".\n");
521417a48c7cSmrg
521517a48c7cSmrg  if (exit_status >= 0)
521617a48c7cSmrg    exit (exit_status);
521717a48c7cSmrg}
521817a48c7cSmrg
521917a48c7cSmrgvoid
522017a48c7cSmrglt_fatal (const char *message, ...)
522117a48c7cSmrg{
522217a48c7cSmrg  va_list ap;
522317a48c7cSmrg  va_start (ap, message);
522417a48c7cSmrg  lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
522517a48c7cSmrg  va_end (ap);
522617a48c7cSmrg}
522717a48c7cSmrgEOF
522817a48c7cSmrg          # we should really use a build-platform specific compiler
522917a48c7cSmrg          # here, but OTOH, the wrappers (shell script and this C one)
523017a48c7cSmrg          # are only useful if you want to execute the "real" binary.
523117a48c7cSmrg          # Since the "real" binary is built for $host, then this
523217a48c7cSmrg          # wrapper might as well be built for $host, too.
523317a48c7cSmrg          $run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource
523417a48c7cSmrg          ;;
523517a48c7cSmrg        esac
523617a48c7cSmrg        $rm $output
523717a48c7cSmrg        trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
523817a48c7cSmrg
523917a48c7cSmrg	$echo > $output "\
524017a48c7cSmrg#! $SHELL
524117a48c7cSmrg
524217a48c7cSmrg# $output - temporary wrapper script for $objdir/$outputname
524317a48c7cSmrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
524417a48c7cSmrg#
524517a48c7cSmrg# The $output program cannot be directly executed until all the libtool
524617a48c7cSmrg# libraries that it depends on are installed.
524717a48c7cSmrg#
524817a48c7cSmrg# This wrapper script should never be moved out of the build directory.
524917a48c7cSmrg# If it is, it will not operate correctly.
525017a48c7cSmrg
525117a48c7cSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
525217a48c7cSmrg# metacharacters that are still active within double-quoted strings.
525317a48c7cSmrgXsed='${SED} -e 1s/^X//'
525417a48c7cSmrgsed_quote_subst='$sed_quote_subst'
525517a48c7cSmrg
525617a48c7cSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout
525717a48c7cSmrg# if CDPATH is set.
525817a48c7cSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
525917a48c7cSmrg
526017a48c7cSmrgrelink_command=\"$relink_command\"
526117a48c7cSmrg
526217a48c7cSmrg# This environment variable determines our operation mode.
526317a48c7cSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then
526417a48c7cSmrg  # install mode needs the following variable:
526517a48c7cSmrg  notinst_deplibs='$notinst_deplibs'
526617a48c7cSmrgelse
526717a48c7cSmrg  # When we are sourced in execute mode, \$file and \$echo are already set.
526817a48c7cSmrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
526917a48c7cSmrg    echo=\"$qecho\"
527017a48c7cSmrg    file=\"\$0\"
527117a48c7cSmrg    # Make sure echo works.
527217a48c7cSmrg    if test \"X\$1\" = X--no-reexec; then
527317a48c7cSmrg      # Discard the --no-reexec flag, and continue.
527417a48c7cSmrg      shift
527517a48c7cSmrg    elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then
527617a48c7cSmrg      # Yippee, \$echo works!
527717a48c7cSmrg      :
527817a48c7cSmrg    else
527917a48c7cSmrg      # Restart under the correct shell, and then maybe \$echo will work.
528017a48c7cSmrg      exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
528117a48c7cSmrg    fi
528217a48c7cSmrg  fi\
528317a48c7cSmrg"
528417a48c7cSmrg	$echo >> $output "\
528517a48c7cSmrg
528617a48c7cSmrg  # Find the directory that this script lives in.
528717a48c7cSmrg  thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
528817a48c7cSmrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
528917a48c7cSmrg
529017a48c7cSmrg  # Follow symbolic links until we get to the real thisdir.
529117a48c7cSmrg  file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
529217a48c7cSmrg  while test -n \"\$file\"; do
529317a48c7cSmrg    destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
529417a48c7cSmrg
529517a48c7cSmrg    # If there was a directory component, then change thisdir.
529617a48c7cSmrg    if test \"x\$destdir\" != \"x\$file\"; then
529717a48c7cSmrg      case \"\$destdir\" in
529817a48c7cSmrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
529917a48c7cSmrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
530017a48c7cSmrg      esac
530117a48c7cSmrg    fi
530217a48c7cSmrg
530317a48c7cSmrg    file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
530417a48c7cSmrg    file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
530517a48c7cSmrg  done
530617a48c7cSmrg
530717a48c7cSmrg  # Try to get the absolute directory name.
530817a48c7cSmrg  absdir=\`cd \"\$thisdir\" && pwd\`
530917a48c7cSmrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
531017a48c7cSmrg"
531117a48c7cSmrg
531217a48c7cSmrg	if test "$fast_install" = yes; then
531317a48c7cSmrg	  $echo >> $output "\
531417a48c7cSmrg  program=lt-'$outputname'$exeext
531517a48c7cSmrg  progdir=\"\$thisdir/$objdir\"
531617a48c7cSmrg
531717a48c7cSmrg  if test ! -f \"\$progdir/\$program\" || \\
531817a48c7cSmrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
531917a48c7cSmrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
532017a48c7cSmrg
532117a48c7cSmrg    file=\"\$\$-\$program\"
532217a48c7cSmrg
532317a48c7cSmrg    if test ! -d \"\$progdir\"; then
532417a48c7cSmrg      $mkdir \"\$progdir\"
532517a48c7cSmrg    else
532617a48c7cSmrg      $rm \"\$progdir/\$file\"
532717a48c7cSmrg    fi"
532817a48c7cSmrg
532917a48c7cSmrg	  $echo >> $output "\
533017a48c7cSmrg
533117a48c7cSmrg    # relink executable if necessary
533217a48c7cSmrg    if test -n \"\$relink_command\"; then
533317a48c7cSmrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
533417a48c7cSmrg      else
533517a48c7cSmrg	$echo \"\$relink_command_output\" >&2
533617a48c7cSmrg	$rm \"\$progdir/\$file\"
533717a48c7cSmrg	exit $EXIT_FAILURE
533817a48c7cSmrg      fi
533917a48c7cSmrg    fi
534017a48c7cSmrg
534117a48c7cSmrg    $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
534217a48c7cSmrg    { $rm \"\$progdir/\$program\";
534317a48c7cSmrg      $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
534417a48c7cSmrg    $rm \"\$progdir/\$file\"
534517a48c7cSmrg  fi"
534617a48c7cSmrg	else
534717a48c7cSmrg	  $echo >> $output "\
534817a48c7cSmrg  program='$outputname'
534917a48c7cSmrg  progdir=\"\$thisdir/$objdir\"
535017a48c7cSmrg"
535117a48c7cSmrg	fi
535217a48c7cSmrg
535317a48c7cSmrg	$echo >> $output "\
535417a48c7cSmrg
535517a48c7cSmrg  if test -f \"\$progdir/\$program\"; then"
535617a48c7cSmrg
535717a48c7cSmrg	# Export our shlibpath_var if we have one.
535817a48c7cSmrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
535917a48c7cSmrg	  $echo >> $output "\
536017a48c7cSmrg    # Add our own library path to $shlibpath_var
536117a48c7cSmrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
536217a48c7cSmrg
536317a48c7cSmrg    # Some systems cannot cope with colon-terminated $shlibpath_var
536417a48c7cSmrg    # The second colon is a workaround for a bug in BeOS R4 sed
536517a48c7cSmrg    $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
536617a48c7cSmrg
536717a48c7cSmrg    export $shlibpath_var
536817a48c7cSmrg"
536917a48c7cSmrg	fi
537017a48c7cSmrg
537117a48c7cSmrg	# fixup the dll searchpath if we need to.
537217a48c7cSmrg	if test -n "$dllsearchpath"; then
537317a48c7cSmrg	  $echo >> $output "\
537417a48c7cSmrg    # Add the dll search path components to the executable PATH
537517a48c7cSmrg    PATH=$dllsearchpath:\$PATH
537617a48c7cSmrg"
537717a48c7cSmrg	fi
537817a48c7cSmrg
537917a48c7cSmrg	$echo >> $output "\
538017a48c7cSmrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
538117a48c7cSmrg      # Run the actual program with our arguments.
538217a48c7cSmrg"
538317a48c7cSmrg	case $host in
538417a48c7cSmrg	# Backslashes separate directories on plain windows
538517a48c7cSmrg	*-*-mingw | *-*-os2*)
538617a48c7cSmrg	  $echo >> $output "\
538717a48c7cSmrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
538817a48c7cSmrg"
538917a48c7cSmrg	  ;;
539017a48c7cSmrg
539117a48c7cSmrg	*)
539217a48c7cSmrg	  $echo >> $output "\
539317a48c7cSmrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
539417a48c7cSmrg"
539517a48c7cSmrg	  ;;
539617a48c7cSmrg	esac
539717a48c7cSmrg	$echo >> $output "\
539817a48c7cSmrg      \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\"
539917a48c7cSmrg      exit $EXIT_FAILURE
540017a48c7cSmrg    fi
540117a48c7cSmrg  else
540217a48c7cSmrg    # The program doesn't exist.
540317a48c7cSmrg    \$echo \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
540417a48c7cSmrg    \$echo \"This script is just a wrapper for \$program.\" 1>&2
540517a48c7cSmrg    $echo \"See the $PACKAGE documentation for more information.\" 1>&2
540617a48c7cSmrg    exit $EXIT_FAILURE
540717a48c7cSmrg  fi
540817a48c7cSmrgfi\
540917a48c7cSmrg"
541017a48c7cSmrg	chmod +x $output
541117a48c7cSmrg      fi
541217a48c7cSmrg      exit $EXIT_SUCCESS
541317a48c7cSmrg      ;;
541417a48c7cSmrg    esac
541517a48c7cSmrg
541617a48c7cSmrg    # See if we need to build an old-fashioned archive.
541717a48c7cSmrg    for oldlib in $oldlibs; do
541817a48c7cSmrg
541917a48c7cSmrg      if test "$build_libtool_libs" = convenience; then
542017a48c7cSmrg	oldobjs="$libobjs_save"
542117a48c7cSmrg	addlibs="$convenience"
542217a48c7cSmrg	build_libtool_libs=no
542317a48c7cSmrg      else
542417a48c7cSmrg	if test "$build_libtool_libs" = module; then
542517a48c7cSmrg	  oldobjs="$libobjs_save"
542617a48c7cSmrg	  build_libtool_libs=no
542717a48c7cSmrg	else
542817a48c7cSmrg	  oldobjs="$old_deplibs $non_pic_objects"
542917a48c7cSmrg	fi
543017a48c7cSmrg	addlibs="$old_convenience"
543117a48c7cSmrg      fi
543217a48c7cSmrg
543317a48c7cSmrg      if test -n "$addlibs"; then
543417a48c7cSmrg	gentop="$output_objdir/${outputname}x"
543517a48c7cSmrg	generated="$generated $gentop"
543617a48c7cSmrg
543717a48c7cSmrg	func_extract_archives $gentop $addlibs
543817a48c7cSmrg	oldobjs="$oldobjs $func_extract_archives_result"
543917a48c7cSmrg      fi
544017a48c7cSmrg
544117a48c7cSmrg      # Do each command in the archive commands.
544217a48c7cSmrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
544317a48c7cSmrg       cmds=$old_archive_from_new_cmds
544417a48c7cSmrg      else
544517a48c7cSmrg	# POSIX demands no paths to be encoded in archives.  We have
544617a48c7cSmrg	# to avoid creating archives with duplicate basenames if we
544717a48c7cSmrg	# might have to extract them afterwards, e.g., when creating a
544817a48c7cSmrg	# static archive out of a convenience library, or when linking
544917a48c7cSmrg	# the entirety of a libtool archive into another (currently
545017a48c7cSmrg	# not supported by libtool).
545117a48c7cSmrg	if (for obj in $oldobjs
545217a48c7cSmrg	    do
545317a48c7cSmrg	      $echo "X$obj" | $Xsed -e 's%^.*/%%'
545417a48c7cSmrg	    done | sort | sort -uc >/dev/null 2>&1); then
545517a48c7cSmrg	  :
545617a48c7cSmrg	else
545717a48c7cSmrg	  $echo "copying selected object files to avoid basename conflicts..."
545817a48c7cSmrg
545917a48c7cSmrg	  if test -z "$gentop"; then
546017a48c7cSmrg	    gentop="$output_objdir/${outputname}x"
546117a48c7cSmrg	    generated="$generated $gentop"
546217a48c7cSmrg
546317a48c7cSmrg	    $show "${rm}r $gentop"
546417a48c7cSmrg	    $run ${rm}r "$gentop"
546517a48c7cSmrg	    $show "$mkdir $gentop"
546617a48c7cSmrg	    $run $mkdir "$gentop"
546717a48c7cSmrg	    exit_status=$?
546817a48c7cSmrg	    if test "$exit_status" -ne 0 && test ! -d "$gentop"; then
546917a48c7cSmrg	      exit $exit_status
547017a48c7cSmrg	    fi
547117a48c7cSmrg	  fi
547217a48c7cSmrg
547317a48c7cSmrg	  save_oldobjs=$oldobjs
547417a48c7cSmrg	  oldobjs=
547517a48c7cSmrg	  counter=1
547617a48c7cSmrg	  for obj in $save_oldobjs
547717a48c7cSmrg	  do
547817a48c7cSmrg	    objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
547917a48c7cSmrg	    case " $oldobjs " in
548017a48c7cSmrg	    " ") oldobjs=$obj ;;
548117a48c7cSmrg	    *[\ /]"$objbase "*)
548217a48c7cSmrg	      while :; do
548317a48c7cSmrg		# Make sure we don't pick an alternate name that also
548417a48c7cSmrg		# overlaps.
548517a48c7cSmrg		newobj=lt$counter-$objbase
548617a48c7cSmrg		counter=`expr $counter + 1`
548717a48c7cSmrg		case " $oldobjs " in
548817a48c7cSmrg		*[\ /]"$newobj "*) ;;
548917a48c7cSmrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
549017a48c7cSmrg		esac
549117a48c7cSmrg	      done
549217a48c7cSmrg	      $show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
549317a48c7cSmrg	      $run ln "$obj" "$gentop/$newobj" ||
549417a48c7cSmrg	      $run cp "$obj" "$gentop/$newobj"
549517a48c7cSmrg	      oldobjs="$oldobjs $gentop/$newobj"
549617a48c7cSmrg	      ;;
549717a48c7cSmrg	    *) oldobjs="$oldobjs $obj" ;;
549817a48c7cSmrg	    esac
549917a48c7cSmrg	  done
550017a48c7cSmrg	fi
550117a48c7cSmrg
550217a48c7cSmrg	eval cmds=\"$old_archive_cmds\"
550317a48c7cSmrg
550417a48c7cSmrg	if len=`expr "X$cmds" : ".*"` &&
550517a48c7cSmrg	     test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
550617a48c7cSmrg	  cmds=$old_archive_cmds
550717a48c7cSmrg	else
550817a48c7cSmrg	  # the command line is too long to link in one step, link in parts
550917a48c7cSmrg	  $echo "using piecewise archive linking..."
551017a48c7cSmrg	  save_RANLIB=$RANLIB
551117a48c7cSmrg	  RANLIB=:
551217a48c7cSmrg	  objlist=
551317a48c7cSmrg	  concat_cmds=
551417a48c7cSmrg	  save_oldobjs=$oldobjs
551517a48c7cSmrg
551617a48c7cSmrg	  # Is there a better way of finding the last object in the list?
551717a48c7cSmrg	  for obj in $save_oldobjs
551817a48c7cSmrg	  do
551917a48c7cSmrg	    last_oldobj=$obj
552017a48c7cSmrg	  done
552117a48c7cSmrg	  for obj in $save_oldobjs
552217a48c7cSmrg	  do
552317a48c7cSmrg	    oldobjs="$objlist $obj"
552417a48c7cSmrg	    objlist="$objlist $obj"
552517a48c7cSmrg	    eval test_cmds=\"$old_archive_cmds\"
552617a48c7cSmrg	    if len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
552717a48c7cSmrg	       test "$len" -le "$max_cmd_len"; then
552817a48c7cSmrg	      :
552917a48c7cSmrg	    else
553017a48c7cSmrg	      # the above command should be used before it gets too long
553117a48c7cSmrg	      oldobjs=$objlist
553217a48c7cSmrg	      if test "$obj" = "$last_oldobj" ; then
553317a48c7cSmrg	        RANLIB=$save_RANLIB
553417a48c7cSmrg	      fi
553517a48c7cSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
553617a48c7cSmrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
553717a48c7cSmrg	      objlist=
553817a48c7cSmrg	    fi
553917a48c7cSmrg	  done
554017a48c7cSmrg	  RANLIB=$save_RANLIB
554117a48c7cSmrg	  oldobjs=$objlist
554217a48c7cSmrg	  if test "X$oldobjs" = "X" ; then
554317a48c7cSmrg	    eval cmds=\"\$concat_cmds\"
554417a48c7cSmrg	  else
554517a48c7cSmrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
554617a48c7cSmrg	  fi
554717a48c7cSmrg	fi
554817a48c7cSmrg      fi
554917a48c7cSmrg      save_ifs="$IFS"; IFS='~'
555017a48c7cSmrg      for cmd in $cmds; do
555117a48c7cSmrg        eval cmd=\"$cmd\"
555217a48c7cSmrg	IFS="$save_ifs"
555317a48c7cSmrg	$show "$cmd"
555417a48c7cSmrg	$run eval "$cmd" || exit $?
555517a48c7cSmrg      done
555617a48c7cSmrg      IFS="$save_ifs"
555717a48c7cSmrg    done
555817a48c7cSmrg
555917a48c7cSmrg    if test -n "$generated"; then
556017a48c7cSmrg      $show "${rm}r$generated"
556117a48c7cSmrg      $run ${rm}r$generated
556217a48c7cSmrg    fi
556317a48c7cSmrg
556417a48c7cSmrg    # Now create the libtool archive.
556517a48c7cSmrg    case $output in
556617a48c7cSmrg    *.la)
556717a48c7cSmrg      old_library=
556817a48c7cSmrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
556917a48c7cSmrg      $show "creating $output"
557017a48c7cSmrg
557117a48c7cSmrg      # Preserve any variables that may affect compiler behavior
557217a48c7cSmrg      for var in $variables_saved_for_relink; do
557317a48c7cSmrg	if eval test -z \"\${$var+set}\"; then
557417a48c7cSmrg	  relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
557517a48c7cSmrg	elif eval var_value=\$$var; test -z "$var_value"; then
557617a48c7cSmrg	  relink_command="$var=; export $var; $relink_command"
557717a48c7cSmrg	else
557817a48c7cSmrg	  var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
557917a48c7cSmrg	  relink_command="$var=\"$var_value\"; export $var; $relink_command"
558017a48c7cSmrg	fi
558117a48c7cSmrg      done
558217a48c7cSmrg      # Quote the link command for shipping.
558317a48c7cSmrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
558417a48c7cSmrg      relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
558517a48c7cSmrg      if test "$hardcode_automatic" = yes ; then
558617a48c7cSmrg	relink_command=
558717a48c7cSmrg      fi
558817a48c7cSmrg
558917a48c7cSmrg
559017a48c7cSmrg      # Only create the output if not a dry run.
559117a48c7cSmrg      if test -z "$run"; then
559217a48c7cSmrg	for installed in no yes; do
559317a48c7cSmrg	  if test "$installed" = yes; then
559417a48c7cSmrg	    if test -z "$install_libdir"; then
559517a48c7cSmrg	      break
559617a48c7cSmrg	    fi
559717a48c7cSmrg	    output="$output_objdir/$outputname"i
559817a48c7cSmrg	    # Replace all uninstalled libtool libraries with the installed ones
559917a48c7cSmrg	    newdependency_libs=
560017a48c7cSmrg	    for deplib in $dependency_libs; do
560117a48c7cSmrg	      case $deplib in
560217a48c7cSmrg	      *.la)
560317a48c7cSmrg		name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'`
560417a48c7cSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
560517a48c7cSmrg		if test -z "$libdir"; then
560617a48c7cSmrg		  $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
560717a48c7cSmrg		  exit $EXIT_FAILURE
560817a48c7cSmrg		fi
560917a48c7cSmrg		newdependency_libs="$newdependency_libs $libdir/$name"
561017a48c7cSmrg		;;
561117a48c7cSmrg	      *) newdependency_libs="$newdependency_libs $deplib" ;;
561217a48c7cSmrg	      esac
561317a48c7cSmrg	    done
561417a48c7cSmrg	    dependency_libs="$newdependency_libs"
561517a48c7cSmrg	    newdlfiles=
561617a48c7cSmrg	    for lib in $dlfiles; do
561717a48c7cSmrg	      name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
561817a48c7cSmrg	      eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
561917a48c7cSmrg	      if test -z "$libdir"; then
562017a48c7cSmrg		$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
562117a48c7cSmrg		exit $EXIT_FAILURE
562217a48c7cSmrg	      fi
562317a48c7cSmrg	      newdlfiles="$newdlfiles $libdir/$name"
562417a48c7cSmrg	    done
562517a48c7cSmrg	    dlfiles="$newdlfiles"
562617a48c7cSmrg	    newdlprefiles=
562717a48c7cSmrg	    for lib in $dlprefiles; do
562817a48c7cSmrg	      name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
562917a48c7cSmrg	      eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
563017a48c7cSmrg	      if test -z "$libdir"; then
563117a48c7cSmrg		$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
563217a48c7cSmrg		exit $EXIT_FAILURE
563317a48c7cSmrg	      fi
563417a48c7cSmrg	      newdlprefiles="$newdlprefiles $libdir/$name"
563517a48c7cSmrg	    done
563617a48c7cSmrg	    dlprefiles="$newdlprefiles"
563717a48c7cSmrg	  else
563817a48c7cSmrg	    newdlfiles=
563917a48c7cSmrg	    for lib in $dlfiles; do
564017a48c7cSmrg	      case $lib in
564117a48c7cSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
564217a48c7cSmrg		*) abs=`pwd`"/$lib" ;;
564317a48c7cSmrg	      esac
564417a48c7cSmrg	      newdlfiles="$newdlfiles $abs"
564517a48c7cSmrg	    done
564617a48c7cSmrg	    dlfiles="$newdlfiles"
564717a48c7cSmrg	    newdlprefiles=
564817a48c7cSmrg	    for lib in $dlprefiles; do
564917a48c7cSmrg	      case $lib in
565017a48c7cSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
565117a48c7cSmrg		*) abs=`pwd`"/$lib" ;;
565217a48c7cSmrg	      esac
565317a48c7cSmrg	      newdlprefiles="$newdlprefiles $abs"
565417a48c7cSmrg	    done
565517a48c7cSmrg	    dlprefiles="$newdlprefiles"
565617a48c7cSmrg	  fi
565717a48c7cSmrg	  $rm $output
565817a48c7cSmrg	  # place dlname in correct position for cygwin
565917a48c7cSmrg	  tdlname=$dlname
566017a48c7cSmrg	  case $host,$output,$installed,$module,$dlname in
566117a48c7cSmrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
566217a48c7cSmrg	  esac
566317a48c7cSmrg	  $echo > $output "\
566417a48c7cSmrg# $outputname - a libtool library file
566517a48c7cSmrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
566617a48c7cSmrg#
566717a48c7cSmrg# Please DO NOT delete this file!
566817a48c7cSmrg# It is necessary for linking the library.
566917a48c7cSmrg
567017a48c7cSmrg# The name that we can dlopen(3).
567117a48c7cSmrgdlname='$tdlname'
567217a48c7cSmrg
567317a48c7cSmrg# Names of this library.
567417a48c7cSmrglibrary_names='$library_names'
567517a48c7cSmrg
567617a48c7cSmrg# The name of the static archive.
567717a48c7cSmrgold_library='$old_library'
567817a48c7cSmrg
567917a48c7cSmrg# Libraries that this one depends upon.
568017a48c7cSmrgdependency_libs='$dependency_libs'
568117a48c7cSmrg
568217a48c7cSmrg# Version information for $libname.
568317a48c7cSmrgcurrent=$current
568417a48c7cSmrgage=$age
568517a48c7cSmrgrevision=$revision
568617a48c7cSmrg
568717a48c7cSmrg# Is this an already installed library?
568817a48c7cSmrginstalled=$installed
568917a48c7cSmrg
569017a48c7cSmrg# Should we warn about portability when linking against -modules?
569117a48c7cSmrgshouldnotlink=$module
569217a48c7cSmrg
569317a48c7cSmrg# Files to dlopen/dlpreopen
569417a48c7cSmrgdlopen='$dlfiles'
569517a48c7cSmrgdlpreopen='$dlprefiles'
569617a48c7cSmrg
569717a48c7cSmrg# Directory that this library needs to be installed in:
569817a48c7cSmrglibdir='$install_libdir'"
569917a48c7cSmrg	  if test "$installed" = no && test "$need_relink" = yes; then
570017a48c7cSmrg	    $echo >> $output "\
570117a48c7cSmrgrelink_command=\"$relink_command\""
570217a48c7cSmrg	  fi
570317a48c7cSmrg	done
570417a48c7cSmrg      fi
570517a48c7cSmrg
570617a48c7cSmrg      # Do a symbolic link so that the libtool archive can be found in
570717a48c7cSmrg      # LD_LIBRARY_PATH before the program is installed.
570817a48c7cSmrg      $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)"
570917a48c7cSmrg      $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $?
571017a48c7cSmrg      ;;
571117a48c7cSmrg    esac
571217a48c7cSmrg    exit $EXIT_SUCCESS
571317a48c7cSmrg    ;;
571417a48c7cSmrg
571517a48c7cSmrg  # libtool install mode
571617a48c7cSmrg  install)
571717a48c7cSmrg    modename="$modename: install"
571817a48c7cSmrg
571917a48c7cSmrg    # There may be an optional sh(1) argument at the beginning of
572017a48c7cSmrg    # install_prog (especially on Windows NT).
572117a48c7cSmrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
572217a48c7cSmrg       # Allow the use of GNU shtool's install command.
572317a48c7cSmrg       $echo "X$nonopt" | grep shtool > /dev/null; then
572417a48c7cSmrg      # Aesthetically quote it.
572517a48c7cSmrg      arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"`
572617a48c7cSmrg      case $arg in
572717a48c7cSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
572817a48c7cSmrg	arg="\"$arg\""
572917a48c7cSmrg	;;
573017a48c7cSmrg      esac
573117a48c7cSmrg      install_prog="$arg "
573217a48c7cSmrg      arg="$1"
573317a48c7cSmrg      shift
573417a48c7cSmrg    else
573517a48c7cSmrg      install_prog=
573617a48c7cSmrg      arg=$nonopt
573717a48c7cSmrg    fi
573817a48c7cSmrg
573917a48c7cSmrg    # The real first argument should be the name of the installation program.
574017a48c7cSmrg    # Aesthetically quote it.
574117a48c7cSmrg    arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
574217a48c7cSmrg    case $arg in
574317a48c7cSmrg    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
574417a48c7cSmrg      arg="\"$arg\""
574517a48c7cSmrg      ;;
574617a48c7cSmrg    esac
574717a48c7cSmrg    install_prog="$install_prog$arg"
574817a48c7cSmrg
574917a48c7cSmrg    # We need to accept at least all the BSD install flags.
575017a48c7cSmrg    dest=
575117a48c7cSmrg    files=
575217a48c7cSmrg    opts=
575317a48c7cSmrg    prev=
575417a48c7cSmrg    install_type=
575517a48c7cSmrg    isdir=no
575617a48c7cSmrg    stripme=
575717a48c7cSmrg    for arg
575817a48c7cSmrg    do
575917a48c7cSmrg      if test -n "$dest"; then
576017a48c7cSmrg	files="$files $dest"
576117a48c7cSmrg	dest=$arg
576217a48c7cSmrg	continue
576317a48c7cSmrg      fi
576417a48c7cSmrg
576517a48c7cSmrg      case $arg in
576617a48c7cSmrg      -d) isdir=yes ;;
576717a48c7cSmrg      -f) 
576817a48c7cSmrg      	case " $install_prog " in
576917a48c7cSmrg	*[\\\ /]cp\ *) ;;
577017a48c7cSmrg	*) prev=$arg ;;
577117a48c7cSmrg	esac
577217a48c7cSmrg	;;
577317a48c7cSmrg      -g | -m | -o) prev=$arg ;;
577417a48c7cSmrg      -s)
577517a48c7cSmrg	stripme=" -s"
577617a48c7cSmrg	continue
577717a48c7cSmrg	;;
577817a48c7cSmrg      -*)
577917a48c7cSmrg	;;
578017a48c7cSmrg      *)
578117a48c7cSmrg	# If the previous option needed an argument, then skip it.
578217a48c7cSmrg	if test -n "$prev"; then
578317a48c7cSmrg	  prev=
578417a48c7cSmrg	else
578517a48c7cSmrg	  dest=$arg
578617a48c7cSmrg	  continue
578717a48c7cSmrg	fi
578817a48c7cSmrg	;;
578917a48c7cSmrg      esac
579017a48c7cSmrg
579117a48c7cSmrg      # Aesthetically quote the argument.
579217a48c7cSmrg      arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
579317a48c7cSmrg      case $arg in
579417a48c7cSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
579517a48c7cSmrg	arg="\"$arg\""
579617a48c7cSmrg	;;
579717a48c7cSmrg      esac
579817a48c7cSmrg      install_prog="$install_prog $arg"
579917a48c7cSmrg    done
580017a48c7cSmrg
580117a48c7cSmrg    if test -z "$install_prog"; then
580217a48c7cSmrg      $echo "$modename: you must specify an install program" 1>&2
580317a48c7cSmrg      $echo "$help" 1>&2
580417a48c7cSmrg      exit $EXIT_FAILURE
580517a48c7cSmrg    fi
580617a48c7cSmrg
580717a48c7cSmrg    if test -n "$prev"; then
580817a48c7cSmrg      $echo "$modename: the \`$prev' option requires an argument" 1>&2
580917a48c7cSmrg      $echo "$help" 1>&2
581017a48c7cSmrg      exit $EXIT_FAILURE
581117a48c7cSmrg    fi
581217a48c7cSmrg
581317a48c7cSmrg    if test -z "$files"; then
581417a48c7cSmrg      if test -z "$dest"; then
581517a48c7cSmrg	$echo "$modename: no file or destination specified" 1>&2
581617a48c7cSmrg      else
581717a48c7cSmrg	$echo "$modename: you must specify a destination" 1>&2
581817a48c7cSmrg      fi
581917a48c7cSmrg      $echo "$help" 1>&2
582017a48c7cSmrg      exit $EXIT_FAILURE
582117a48c7cSmrg    fi
582217a48c7cSmrg
582317a48c7cSmrg    # Strip any trailing slash from the destination.
582417a48c7cSmrg    dest=`$echo "X$dest" | $Xsed -e 's%/$%%'`
582517a48c7cSmrg
582617a48c7cSmrg    # Check to see that the destination is a directory.
582717a48c7cSmrg    test -d "$dest" && isdir=yes
582817a48c7cSmrg    if test "$isdir" = yes; then
582917a48c7cSmrg      destdir="$dest"
583017a48c7cSmrg      destname=
583117a48c7cSmrg    else
583217a48c7cSmrg      destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'`
583317a48c7cSmrg      test "X$destdir" = "X$dest" && destdir=.
583417a48c7cSmrg      destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'`
583517a48c7cSmrg
583617a48c7cSmrg      # Not a directory, so check to see that there is only one file specified.
583717a48c7cSmrg      set dummy $files
583817a48c7cSmrg      if test "$#" -gt 2; then
583917a48c7cSmrg	$echo "$modename: \`$dest' is not a directory" 1>&2
584017a48c7cSmrg	$echo "$help" 1>&2
584117a48c7cSmrg	exit $EXIT_FAILURE
584217a48c7cSmrg      fi
584317a48c7cSmrg    fi
584417a48c7cSmrg    case $destdir in
584517a48c7cSmrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
584617a48c7cSmrg    *)
584717a48c7cSmrg      for file in $files; do
584817a48c7cSmrg	case $file in
584917a48c7cSmrg	*.lo) ;;
585017a48c7cSmrg	*)
585117a48c7cSmrg	  $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2
585217a48c7cSmrg	  $echo "$help" 1>&2
585317a48c7cSmrg	  exit $EXIT_FAILURE
585417a48c7cSmrg	  ;;
585517a48c7cSmrg	esac
585617a48c7cSmrg      done
585717a48c7cSmrg      ;;
585817a48c7cSmrg    esac
585917a48c7cSmrg
586017a48c7cSmrg    # This variable tells wrapper scripts just to set variables rather
586117a48c7cSmrg    # than running their programs.
586217a48c7cSmrg    libtool_install_magic="$magic"
586317a48c7cSmrg
586417a48c7cSmrg    staticlibs=
586517a48c7cSmrg    future_libdirs=
586617a48c7cSmrg    current_libdirs=
586717a48c7cSmrg    for file in $files; do
586817a48c7cSmrg
586917a48c7cSmrg      # Do each installation.
587017a48c7cSmrg      case $file in
587117a48c7cSmrg      *.$libext)
587217a48c7cSmrg	# Do the static libraries later.
587317a48c7cSmrg	staticlibs="$staticlibs $file"
587417a48c7cSmrg	;;
587517a48c7cSmrg
587617a48c7cSmrg      *.la)
587717a48c7cSmrg	# Check to see that this really is a libtool archive.
587817a48c7cSmrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
587917a48c7cSmrg	else
588017a48c7cSmrg	  $echo "$modename: \`$file' is not a valid libtool archive" 1>&2
588117a48c7cSmrg	  $echo "$help" 1>&2
588217a48c7cSmrg	  exit $EXIT_FAILURE
588317a48c7cSmrg	fi
588417a48c7cSmrg
588517a48c7cSmrg	library_names=
588617a48c7cSmrg	old_library=
588717a48c7cSmrg	relink_command=
588817a48c7cSmrg	# If there is no directory component, then add one.
588917a48c7cSmrg	case $file in
589017a48c7cSmrg	*/* | *\\*) . $file ;;
589117a48c7cSmrg	*) . ./$file ;;
589217a48c7cSmrg	esac
589317a48c7cSmrg
589417a48c7cSmrg	# Add the libdir to current_libdirs if it is the destination.
589517a48c7cSmrg	if test "X$destdir" = "X$libdir"; then
589617a48c7cSmrg	  case "$current_libdirs " in
589717a48c7cSmrg	  *" $libdir "*) ;;
589817a48c7cSmrg	  *) current_libdirs="$current_libdirs $libdir" ;;
589917a48c7cSmrg	  esac
590017a48c7cSmrg	else
590117a48c7cSmrg	  # Note the libdir as a future libdir.
590217a48c7cSmrg	  case "$future_libdirs " in
590317a48c7cSmrg	  *" $libdir "*) ;;
590417a48c7cSmrg	  *) future_libdirs="$future_libdirs $libdir" ;;
590517a48c7cSmrg	  esac
590617a48c7cSmrg	fi
590717a48c7cSmrg
590817a48c7cSmrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/
590917a48c7cSmrg	test "X$dir" = "X$file/" && dir=
591017a48c7cSmrg	dir="$dir$objdir"
591117a48c7cSmrg
591217a48c7cSmrg	if test -n "$relink_command"; then
591317a48c7cSmrg	  # Determine the prefix the user has applied to our future dir.
591417a48c7cSmrg	  inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"`
591517a48c7cSmrg
591617a48c7cSmrg	  # Don't allow the user to place us outside of our expected
591717a48c7cSmrg	  # location b/c this prevents finding dependent libraries that
591817a48c7cSmrg	  # are installed to the same prefix.
591917a48c7cSmrg	  # At present, this check doesn't affect windows .dll's that
592017a48c7cSmrg	  # are installed into $libdir/../bin (currently, that works fine)
592117a48c7cSmrg	  # but it's something to keep an eye on.
592217a48c7cSmrg	  if test "$inst_prefix_dir" = "$destdir"; then
592317a48c7cSmrg	    $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2
592417a48c7cSmrg	    exit $EXIT_FAILURE
592517a48c7cSmrg	  fi
592617a48c7cSmrg
592717a48c7cSmrg	  if test -n "$inst_prefix_dir"; then
592817a48c7cSmrg	    # Stick the inst_prefix_dir data into the link command.
592917a48c7cSmrg	    relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
593017a48c7cSmrg	  else
593117a48c7cSmrg	    relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
593217a48c7cSmrg	  fi
593317a48c7cSmrg
593417a48c7cSmrg	  $echo "$modename: warning: relinking \`$file'" 1>&2
593517a48c7cSmrg	  $show "$relink_command"
593617a48c7cSmrg	  if $run eval "$relink_command"; then :
593717a48c7cSmrg	  else
593817a48c7cSmrg	    $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
593917a48c7cSmrg	    exit $EXIT_FAILURE
594017a48c7cSmrg	  fi
594117a48c7cSmrg	fi
594217a48c7cSmrg
594317a48c7cSmrg	# See the names of the shared library.
594417a48c7cSmrg	set dummy $library_names
594517a48c7cSmrg	if test -n "$2"; then
594617a48c7cSmrg	  realname="$2"
594717a48c7cSmrg	  shift
594817a48c7cSmrg	  shift
594917a48c7cSmrg
595017a48c7cSmrg	  srcname="$realname"
595117a48c7cSmrg	  test -n "$relink_command" && srcname="$realname"T
595217a48c7cSmrg
595317a48c7cSmrg	  # Install the shared library and build the symlinks.
595417a48c7cSmrg	  $show "$install_prog $dir/$srcname $destdir/$realname"
595517a48c7cSmrg	  $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $?
595617a48c7cSmrg	  if test -n "$stripme" && test -n "$striplib"; then
595717a48c7cSmrg	    $show "$striplib $destdir/$realname"
595817a48c7cSmrg	    $run eval "$striplib $destdir/$realname" || exit $?
595917a48c7cSmrg	  fi
596017a48c7cSmrg
596117a48c7cSmrg	  if test "$#" -gt 0; then
596217a48c7cSmrg	    # Delete the old symlinks, and create new ones.
596317a48c7cSmrg	    # Try `ln -sf' first, because the `ln' binary might depend on
596417a48c7cSmrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
596517a48c7cSmrg	    # so we also need to try rm && ln -s.
596617a48c7cSmrg	    for linkname
596717a48c7cSmrg	    do
596817a48c7cSmrg	      if test "$linkname" != "$realname"; then
596917a48c7cSmrg                $show "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
597017a48c7cSmrg                $run eval "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
597117a48c7cSmrg	      fi
597217a48c7cSmrg	    done
597317a48c7cSmrg	  fi
597417a48c7cSmrg
597517a48c7cSmrg	  # Do each command in the postinstall commands.
597617a48c7cSmrg	  lib="$destdir/$realname"
597717a48c7cSmrg	  cmds=$postinstall_cmds
597817a48c7cSmrg	  save_ifs="$IFS"; IFS='~'
597917a48c7cSmrg	  for cmd in $cmds; do
598017a48c7cSmrg	    IFS="$save_ifs"
598117a48c7cSmrg	    eval cmd=\"$cmd\"
598217a48c7cSmrg	    $show "$cmd"
598317a48c7cSmrg	    $run eval "$cmd" || {
598417a48c7cSmrg	      lt_exit=$?
598517a48c7cSmrg
598617a48c7cSmrg	      # Restore the uninstalled library and exit
598717a48c7cSmrg	      if test "$mode" = relink; then
598817a48c7cSmrg		$run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
598917a48c7cSmrg	      fi
599017a48c7cSmrg
599117a48c7cSmrg	      exit $lt_exit
599217a48c7cSmrg	    }
599317a48c7cSmrg	  done
599417a48c7cSmrg	  IFS="$save_ifs"
599517a48c7cSmrg	fi
599617a48c7cSmrg
599717a48c7cSmrg	# Install the pseudo-library for information purposes.
599817a48c7cSmrg	name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
599917a48c7cSmrg	instname="$dir/$name"i
600017a48c7cSmrg	$show "$install_prog $instname $destdir/$name"
600117a48c7cSmrg	$run eval "$install_prog $instname $destdir/$name" || exit $?
600217a48c7cSmrg
600317a48c7cSmrg	# Maybe install the static library, too.
600417a48c7cSmrg	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
600517a48c7cSmrg	;;
600617a48c7cSmrg
600717a48c7cSmrg      *.lo)
600817a48c7cSmrg	# Install (i.e. copy) a libtool object.
600917a48c7cSmrg
601017a48c7cSmrg	# Figure out destination file name, if it wasn't already specified.
601117a48c7cSmrg	if test -n "$destname"; then
601217a48c7cSmrg	  destfile="$destdir/$destname"
601317a48c7cSmrg	else
601417a48c7cSmrg	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
601517a48c7cSmrg	  destfile="$destdir/$destfile"
601617a48c7cSmrg	fi
601717a48c7cSmrg
601817a48c7cSmrg	# Deduce the name of the destination old-style object file.
601917a48c7cSmrg	case $destfile in
602017a48c7cSmrg	*.lo)
602117a48c7cSmrg	  staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"`
602217a48c7cSmrg	  ;;
602317a48c7cSmrg	*.$objext)
602417a48c7cSmrg	  staticdest="$destfile"
602517a48c7cSmrg	  destfile=
602617a48c7cSmrg	  ;;
602717a48c7cSmrg	*)
602817a48c7cSmrg	  $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2
602917a48c7cSmrg	  $echo "$help" 1>&2
603017a48c7cSmrg	  exit $EXIT_FAILURE
603117a48c7cSmrg	  ;;
603217a48c7cSmrg	esac
603317a48c7cSmrg
603417a48c7cSmrg	# Install the libtool object if requested.
603517a48c7cSmrg	if test -n "$destfile"; then
603617a48c7cSmrg	  $show "$install_prog $file $destfile"
603717a48c7cSmrg	  $run eval "$install_prog $file $destfile" || exit $?
603817a48c7cSmrg	fi
603917a48c7cSmrg
604017a48c7cSmrg	# Install the old object if enabled.
604117a48c7cSmrg	if test "$build_old_libs" = yes; then
604217a48c7cSmrg	  # Deduce the name of the old-style object file.
604317a48c7cSmrg	  staticobj=`$echo "X$file" | $Xsed -e "$lo2o"`
604417a48c7cSmrg
604517a48c7cSmrg	  $show "$install_prog $staticobj $staticdest"
604617a48c7cSmrg	  $run eval "$install_prog \$staticobj \$staticdest" || exit $?
604717a48c7cSmrg	fi
604817a48c7cSmrg	exit $EXIT_SUCCESS
604917a48c7cSmrg	;;
605017a48c7cSmrg
605117a48c7cSmrg      *)
605217a48c7cSmrg	# Figure out destination file name, if it wasn't already specified.
605317a48c7cSmrg	if test -n "$destname"; then
605417a48c7cSmrg	  destfile="$destdir/$destname"
605517a48c7cSmrg	else
605617a48c7cSmrg	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
605717a48c7cSmrg	  destfile="$destdir/$destfile"
605817a48c7cSmrg	fi
605917a48c7cSmrg
606017a48c7cSmrg	# If the file is missing, and there is a .exe on the end, strip it
606117a48c7cSmrg	# because it is most likely a libtool script we actually want to
606217a48c7cSmrg	# install
606317a48c7cSmrg	stripped_ext=""
606417a48c7cSmrg	case $file in
606517a48c7cSmrg	  *.exe)
606617a48c7cSmrg	    if test ! -f "$file"; then
606717a48c7cSmrg	      file=`$echo $file|${SED} 's,.exe$,,'`
606817a48c7cSmrg	      stripped_ext=".exe"
606917a48c7cSmrg	    fi
607017a48c7cSmrg	    ;;
607117a48c7cSmrg	esac
607217a48c7cSmrg
607317a48c7cSmrg	# Do a test to see if this is really a libtool program.
607417a48c7cSmrg	case $host in
607517a48c7cSmrg	*cygwin*|*mingw*)
607617a48c7cSmrg	    wrapper=`$echo $file | ${SED} -e 's,.exe$,,'`
607717a48c7cSmrg	    ;;
607817a48c7cSmrg	*)
607917a48c7cSmrg	    wrapper=$file
608017a48c7cSmrg	    ;;
608117a48c7cSmrg	esac
608217a48c7cSmrg	if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then
608317a48c7cSmrg	  notinst_deplibs=
608417a48c7cSmrg	  relink_command=
608517a48c7cSmrg
608617a48c7cSmrg	  # Note that it is not necessary on cygwin/mingw to append a dot to
608717a48c7cSmrg	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
608817a48c7cSmrg	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
608917a48c7cSmrg	  # `FILE.' does not work on cygwin managed mounts.
609017a48c7cSmrg	  #
609117a48c7cSmrg	  # If there is no directory component, then add one.
609217a48c7cSmrg	  case $wrapper in
609317a48c7cSmrg	  */* | *\\*) . ${wrapper} ;;
609417a48c7cSmrg	  *) . ./${wrapper} ;;
609517a48c7cSmrg	  esac
609617a48c7cSmrg
609717a48c7cSmrg	  # Check the variables that should have been set.
609817a48c7cSmrg	  if test -z "$notinst_deplibs"; then
609917a48c7cSmrg	    $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2
610017a48c7cSmrg	    exit $EXIT_FAILURE
610117a48c7cSmrg	  fi
610217a48c7cSmrg
610317a48c7cSmrg	  finalize=yes
610417a48c7cSmrg	  for lib in $notinst_deplibs; do
610517a48c7cSmrg	    # Check to see that each library is installed.
610617a48c7cSmrg	    libdir=
610717a48c7cSmrg	    if test -f "$lib"; then
610817a48c7cSmrg	      # If there is no directory component, then add one.
610917a48c7cSmrg	      case $lib in
611017a48c7cSmrg	      */* | *\\*) . $lib ;;
611117a48c7cSmrg	      *) . ./$lib ;;
611217a48c7cSmrg	      esac
611317a48c7cSmrg	    fi
611417a48c7cSmrg	    libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
611517a48c7cSmrg	    if test -n "$libdir" && test ! -f "$libfile"; then
611617a48c7cSmrg	      $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2
611717a48c7cSmrg	      finalize=no
611817a48c7cSmrg	    fi
611917a48c7cSmrg	  done
612017a48c7cSmrg
612117a48c7cSmrg	  relink_command=
612217a48c7cSmrg	  # Note that it is not necessary on cygwin/mingw to append a dot to
612317a48c7cSmrg	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
612417a48c7cSmrg	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
612517a48c7cSmrg	  # `FILE.' does not work on cygwin managed mounts.
612617a48c7cSmrg	  #
612717a48c7cSmrg	  # If there is no directory component, then add one.
612817a48c7cSmrg	  case $wrapper in
612917a48c7cSmrg	  */* | *\\*) . ${wrapper} ;;
613017a48c7cSmrg	  *) . ./${wrapper} ;;
613117a48c7cSmrg	  esac
613217a48c7cSmrg
613317a48c7cSmrg	  outputname=
613417a48c7cSmrg	  if test "$fast_install" = no && test -n "$relink_command"; then
613517a48c7cSmrg	    if test "$finalize" = yes && test -z "$run"; then
613617a48c7cSmrg	      tmpdir=`func_mktempdir`
613717a48c7cSmrg	      file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
613817a48c7cSmrg	      outputname="$tmpdir/$file"
613917a48c7cSmrg	      # Replace the output file specification.
614017a48c7cSmrg	      relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
614117a48c7cSmrg
614217a48c7cSmrg	      $show "$relink_command"
614317a48c7cSmrg	      if $run eval "$relink_command"; then :
614417a48c7cSmrg	      else
614517a48c7cSmrg		$echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
614617a48c7cSmrg		${rm}r "$tmpdir"
614717a48c7cSmrg		continue
614817a48c7cSmrg	      fi
614917a48c7cSmrg	      file="$outputname"
615017a48c7cSmrg	    else
615117a48c7cSmrg	      $echo "$modename: warning: cannot relink \`$file'" 1>&2
615217a48c7cSmrg	    fi
615317a48c7cSmrg	  else
615417a48c7cSmrg	    # Install the binary that we compiled earlier.
615517a48c7cSmrg	    file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
615617a48c7cSmrg	  fi
615717a48c7cSmrg	fi
615817a48c7cSmrg
615917a48c7cSmrg	# remove .exe since cygwin /usr/bin/install will append another
616017a48c7cSmrg	# one anyway 
616117a48c7cSmrg	case $install_prog,$host in
616217a48c7cSmrg	*/usr/bin/install*,*cygwin*)
616317a48c7cSmrg	  case $file:$destfile in
616417a48c7cSmrg	  *.exe:*.exe)
616517a48c7cSmrg	    # this is ok
616617a48c7cSmrg	    ;;
616717a48c7cSmrg	  *.exe:*)
616817a48c7cSmrg	    destfile=$destfile.exe
616917a48c7cSmrg	    ;;
617017a48c7cSmrg	  *:*.exe)
617117a48c7cSmrg	    destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'`
617217a48c7cSmrg	    ;;
617317a48c7cSmrg	  esac
617417a48c7cSmrg	  ;;
617517a48c7cSmrg	esac
617617a48c7cSmrg	$show "$install_prog$stripme $file $destfile"
617717a48c7cSmrg	$run eval "$install_prog\$stripme \$file \$destfile" || exit $?
617817a48c7cSmrg	test -n "$outputname" && ${rm}r "$tmpdir"
617917a48c7cSmrg	;;
618017a48c7cSmrg      esac
618117a48c7cSmrg    done
618217a48c7cSmrg
618317a48c7cSmrg    for file in $staticlibs; do
618417a48c7cSmrg      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
618517a48c7cSmrg
618617a48c7cSmrg      # Set up the ranlib parameters.
618717a48c7cSmrg      oldlib="$destdir/$name"
618817a48c7cSmrg
618917a48c7cSmrg      $show "$install_prog $file $oldlib"
619017a48c7cSmrg      $run eval "$install_prog \$file \$oldlib" || exit $?
619117a48c7cSmrg
619217a48c7cSmrg      if test -n "$stripme" && test -n "$old_striplib"; then
619317a48c7cSmrg	$show "$old_striplib $oldlib"
619417a48c7cSmrg	$run eval "$old_striplib $oldlib" || exit $?
619517a48c7cSmrg      fi
619617a48c7cSmrg
619717a48c7cSmrg      # Do each command in the postinstall commands.
619817a48c7cSmrg      cmds=$old_postinstall_cmds
619917a48c7cSmrg      save_ifs="$IFS"; IFS='~'
620017a48c7cSmrg      for cmd in $cmds; do
620117a48c7cSmrg	IFS="$save_ifs"
620217a48c7cSmrg	eval cmd=\"$cmd\"
620317a48c7cSmrg	$show "$cmd"
620417a48c7cSmrg	$run eval "$cmd" || exit $?
620517a48c7cSmrg      done
620617a48c7cSmrg      IFS="$save_ifs"
620717a48c7cSmrg    done
620817a48c7cSmrg
620917a48c7cSmrg    if test -n "$future_libdirs"; then
621017a48c7cSmrg      $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2
621117a48c7cSmrg    fi
621217a48c7cSmrg
621317a48c7cSmrg    if test -n "$current_libdirs"; then
621417a48c7cSmrg      # Maybe just do a dry run.
621517a48c7cSmrg      test -n "$run" && current_libdirs=" -n$current_libdirs"
621617a48c7cSmrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
621717a48c7cSmrg    else
621817a48c7cSmrg      exit $EXIT_SUCCESS
621917a48c7cSmrg    fi
622017a48c7cSmrg    ;;
622117a48c7cSmrg
622217a48c7cSmrg  # libtool finish mode
622317a48c7cSmrg  finish)
622417a48c7cSmrg    modename="$modename: finish"
622517a48c7cSmrg    libdirs="$nonopt"
622617a48c7cSmrg    admincmds=
622717a48c7cSmrg
622817a48c7cSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
622917a48c7cSmrg      for dir
623017a48c7cSmrg      do
623117a48c7cSmrg	libdirs="$libdirs $dir"
623217a48c7cSmrg      done
623317a48c7cSmrg
623417a48c7cSmrg      for libdir in $libdirs; do
623517a48c7cSmrg	if test -n "$finish_cmds"; then
623617a48c7cSmrg	  # Do each command in the finish commands.
623717a48c7cSmrg	  cmds=$finish_cmds
623817a48c7cSmrg	  save_ifs="$IFS"; IFS='~'
623917a48c7cSmrg	  for cmd in $cmds; do
624017a48c7cSmrg	    IFS="$save_ifs"
624117a48c7cSmrg	    eval cmd=\"$cmd\"
624217a48c7cSmrg	    $show "$cmd"
624317a48c7cSmrg	    $run eval "$cmd" || admincmds="$admincmds
624417a48c7cSmrg       $cmd"
624517a48c7cSmrg	  done
624617a48c7cSmrg	  IFS="$save_ifs"
624717a48c7cSmrg	fi
624817a48c7cSmrg	if test -n "$finish_eval"; then
624917a48c7cSmrg	  # Do the single finish_eval.
625017a48c7cSmrg	  eval cmds=\"$finish_eval\"
625117a48c7cSmrg	  $run eval "$cmds" || admincmds="$admincmds
625217a48c7cSmrg       $cmds"
625317a48c7cSmrg	fi
625417a48c7cSmrg      done
625517a48c7cSmrg    fi
625617a48c7cSmrg
625717a48c7cSmrg    # Exit here if they wanted silent mode.
625817a48c7cSmrg    test "$show" = : && exit $EXIT_SUCCESS
625917a48c7cSmrg
626017a48c7cSmrg    $echo "X----------------------------------------------------------------------" | $Xsed
626117a48c7cSmrg    $echo "Libraries have been installed in:"
626217a48c7cSmrg    for libdir in $libdirs; do
626317a48c7cSmrg      $echo "   $libdir"
626417a48c7cSmrg    done
626517a48c7cSmrg    $echo
626617a48c7cSmrg    $echo "If you ever happen to want to link against installed libraries"
626717a48c7cSmrg    $echo "in a given directory, LIBDIR, you must either use libtool, and"
626817a48c7cSmrg    $echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
626917a48c7cSmrg    $echo "flag during linking and do at least one of the following:"
627017a48c7cSmrg    if test -n "$shlibpath_var"; then
627117a48c7cSmrg      $echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
627217a48c7cSmrg      $echo "     during execution"
627317a48c7cSmrg    fi
627417a48c7cSmrg    if test -n "$runpath_var"; then
627517a48c7cSmrg      $echo "   - add LIBDIR to the \`$runpath_var' environment variable"
627617a48c7cSmrg      $echo "     during linking"
627717a48c7cSmrg    fi
627817a48c7cSmrg    if test -n "$hardcode_libdir_flag_spec"; then
627917a48c7cSmrg      libdir=LIBDIR
628017a48c7cSmrg      eval flag=\"$hardcode_libdir_flag_spec\"
628117a48c7cSmrg
628217a48c7cSmrg      $echo "   - use the \`$flag' linker flag"
628317a48c7cSmrg    fi
628417a48c7cSmrg    if test -n "$admincmds"; then
628517a48c7cSmrg      $echo "   - have your system administrator run these commands:$admincmds"
628617a48c7cSmrg    fi
628717a48c7cSmrg    if test -f /etc/ld.so.conf; then
628817a48c7cSmrg      $echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
628917a48c7cSmrg    fi
629017a48c7cSmrg    $echo
629117a48c7cSmrg    $echo "See any operating system documentation about shared libraries for"
629217a48c7cSmrg    $echo "more information, such as the ld(1) and ld.so(8) manual pages."
629317a48c7cSmrg    $echo "X----------------------------------------------------------------------" | $Xsed
629417a48c7cSmrg    exit $EXIT_SUCCESS
629517a48c7cSmrg    ;;
629617a48c7cSmrg
629717a48c7cSmrg  # libtool execute mode
629817a48c7cSmrg  execute)
629917a48c7cSmrg    modename="$modename: execute"
630017a48c7cSmrg
630117a48c7cSmrg    # The first argument is the command name.
630217a48c7cSmrg    cmd="$nonopt"
630317a48c7cSmrg    if test -z "$cmd"; then
630417a48c7cSmrg      $echo "$modename: you must specify a COMMAND" 1>&2
630517a48c7cSmrg      $echo "$help"
630617a48c7cSmrg      exit $EXIT_FAILURE
630717a48c7cSmrg    fi
630817a48c7cSmrg
630917a48c7cSmrg    # Handle -dlopen flags immediately.
631017a48c7cSmrg    for file in $execute_dlfiles; do
631117a48c7cSmrg      if test ! -f "$file"; then
631217a48c7cSmrg	$echo "$modename: \`$file' is not a file" 1>&2
631317a48c7cSmrg	$echo "$help" 1>&2
631417a48c7cSmrg	exit $EXIT_FAILURE
631517a48c7cSmrg      fi
631617a48c7cSmrg
631717a48c7cSmrg      dir=
631817a48c7cSmrg      case $file in
631917a48c7cSmrg      *.la)
632017a48c7cSmrg	# Check to see that this really is a libtool archive.
632117a48c7cSmrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
632217a48c7cSmrg	else
632317a48c7cSmrg	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
632417a48c7cSmrg	  $echo "$help" 1>&2
632517a48c7cSmrg	  exit $EXIT_FAILURE
632617a48c7cSmrg	fi
632717a48c7cSmrg
632817a48c7cSmrg	# Read the libtool library.
632917a48c7cSmrg	dlname=
633017a48c7cSmrg	library_names=
633117a48c7cSmrg
633217a48c7cSmrg	# If there is no directory component, then add one.
633317a48c7cSmrg	case $file in
633417a48c7cSmrg	*/* | *\\*) . $file ;;
633517a48c7cSmrg	*) . ./$file ;;
633617a48c7cSmrg	esac
633717a48c7cSmrg
633817a48c7cSmrg	# Skip this library if it cannot be dlopened.
633917a48c7cSmrg	if test -z "$dlname"; then
634017a48c7cSmrg	  # Warn if it was a shared library.
634117a48c7cSmrg	  test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'"
634217a48c7cSmrg	  continue
634317a48c7cSmrg	fi
634417a48c7cSmrg
634517a48c7cSmrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
634617a48c7cSmrg	test "X$dir" = "X$file" && dir=.
634717a48c7cSmrg
634817a48c7cSmrg	if test -f "$dir/$objdir/$dlname"; then
634917a48c7cSmrg	  dir="$dir/$objdir"
635017a48c7cSmrg	else
635117a48c7cSmrg	  $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
635217a48c7cSmrg	  exit $EXIT_FAILURE
635317a48c7cSmrg	fi
635417a48c7cSmrg	;;
635517a48c7cSmrg
635617a48c7cSmrg      *.lo)
635717a48c7cSmrg	# Just add the directory containing the .lo file.
635817a48c7cSmrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
635917a48c7cSmrg	test "X$dir" = "X$file" && dir=.
636017a48c7cSmrg	;;
636117a48c7cSmrg
636217a48c7cSmrg      *)
636317a48c7cSmrg	$echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2
636417a48c7cSmrg	continue
636517a48c7cSmrg	;;
636617a48c7cSmrg      esac
636717a48c7cSmrg
636817a48c7cSmrg      # Get the absolute pathname.
636917a48c7cSmrg      absdir=`cd "$dir" && pwd`
637017a48c7cSmrg      test -n "$absdir" && dir="$absdir"
637117a48c7cSmrg
637217a48c7cSmrg      # Now add the directory to shlibpath_var.
637317a48c7cSmrg      if eval "test -z \"\$$shlibpath_var\""; then
637417a48c7cSmrg	eval "$shlibpath_var=\"\$dir\""
637517a48c7cSmrg      else
637617a48c7cSmrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
637717a48c7cSmrg      fi
637817a48c7cSmrg    done
637917a48c7cSmrg
638017a48c7cSmrg    # This variable tells wrapper scripts just to set shlibpath_var
638117a48c7cSmrg    # rather than running their programs.
638217a48c7cSmrg    libtool_execute_magic="$magic"
638317a48c7cSmrg
638417a48c7cSmrg    # Check if any of the arguments is a wrapper script.
638517a48c7cSmrg    args=
638617a48c7cSmrg    for file
638717a48c7cSmrg    do
638817a48c7cSmrg      case $file in
638917a48c7cSmrg      -*) ;;
639017a48c7cSmrg      *)
639117a48c7cSmrg	# Do a test to see if this is really a libtool program.
639217a48c7cSmrg	if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
639317a48c7cSmrg	  # If there is no directory component, then add one.
639417a48c7cSmrg	  case $file in
639517a48c7cSmrg	  */* | *\\*) . $file ;;
639617a48c7cSmrg	  *) . ./$file ;;
639717a48c7cSmrg	  esac
639817a48c7cSmrg
639917a48c7cSmrg	  # Transform arg to wrapped name.
640017a48c7cSmrg	  file="$progdir/$program"
640117a48c7cSmrg	fi
640217a48c7cSmrg	;;
640317a48c7cSmrg      esac
640417a48c7cSmrg      # Quote arguments (to preserve shell metacharacters).
640517a48c7cSmrg      file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"`
640617a48c7cSmrg      args="$args \"$file\""
640717a48c7cSmrg    done
640817a48c7cSmrg
640917a48c7cSmrg    if test -z "$run"; then
641017a48c7cSmrg      if test -n "$shlibpath_var"; then
641117a48c7cSmrg	# Export the shlibpath_var.
641217a48c7cSmrg	eval "export $shlibpath_var"
641317a48c7cSmrg      fi
641417a48c7cSmrg
641517a48c7cSmrg      # Restore saved environment variables
641617a48c7cSmrg      if test "${save_LC_ALL+set}" = set; then
641717a48c7cSmrg	LC_ALL="$save_LC_ALL"; export LC_ALL
641817a48c7cSmrg      fi
641917a48c7cSmrg      if test "${save_LANG+set}" = set; then
642017a48c7cSmrg	LANG="$save_LANG"; export LANG
642117a48c7cSmrg      fi
642217a48c7cSmrg
642317a48c7cSmrg      # Now prepare to actually exec the command.
642417a48c7cSmrg      exec_cmd="\$cmd$args"
642517a48c7cSmrg    else
642617a48c7cSmrg      # Display what would be done.
642717a48c7cSmrg      if test -n "$shlibpath_var"; then
642817a48c7cSmrg	eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\""
642917a48c7cSmrg	$echo "export $shlibpath_var"
643017a48c7cSmrg      fi
643117a48c7cSmrg      $echo "$cmd$args"
643217a48c7cSmrg      exit $EXIT_SUCCESS
643317a48c7cSmrg    fi
643417a48c7cSmrg    ;;
643517a48c7cSmrg
643617a48c7cSmrg  # libtool clean and uninstall mode
643717a48c7cSmrg  clean | uninstall)
643817a48c7cSmrg    modename="$modename: $mode"
643917a48c7cSmrg    rm="$nonopt"
644017a48c7cSmrg    files=
644117a48c7cSmrg    rmforce=
644217a48c7cSmrg    exit_status=0
644317a48c7cSmrg
644417a48c7cSmrg    # This variable tells wrapper scripts just to set variables rather
644517a48c7cSmrg    # than running their programs.
644617a48c7cSmrg    libtool_install_magic="$magic"
644717a48c7cSmrg
644817a48c7cSmrg    for arg
644917a48c7cSmrg    do
645017a48c7cSmrg      case $arg in
645117a48c7cSmrg      -f) rm="$rm $arg"; rmforce=yes ;;
645217a48c7cSmrg      -*) rm="$rm $arg" ;;
645317a48c7cSmrg      *) files="$files $arg" ;;
645417a48c7cSmrg      esac
645517a48c7cSmrg    done
645617a48c7cSmrg
645717a48c7cSmrg    if test -z "$rm"; then
645817a48c7cSmrg      $echo "$modename: you must specify an RM program" 1>&2
645917a48c7cSmrg      $echo "$help" 1>&2
646017a48c7cSmrg      exit $EXIT_FAILURE
646117a48c7cSmrg    fi
646217a48c7cSmrg
646317a48c7cSmrg    rmdirs=
646417a48c7cSmrg
646517a48c7cSmrg    origobjdir="$objdir"
646617a48c7cSmrg    for file in $files; do
646717a48c7cSmrg      dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
646817a48c7cSmrg      if test "X$dir" = "X$file"; then
646917a48c7cSmrg	dir=.
647017a48c7cSmrg	objdir="$origobjdir"
647117a48c7cSmrg      else
647217a48c7cSmrg	objdir="$dir/$origobjdir"
647317a48c7cSmrg      fi
647417a48c7cSmrg      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
647517a48c7cSmrg      test "$mode" = uninstall && objdir="$dir"
647617a48c7cSmrg
647717a48c7cSmrg      # Remember objdir for removal later, being careful to avoid duplicates
647817a48c7cSmrg      if test "$mode" = clean; then
647917a48c7cSmrg	case " $rmdirs " in
648017a48c7cSmrg	  *" $objdir "*) ;;
648117a48c7cSmrg	  *) rmdirs="$rmdirs $objdir" ;;
648217a48c7cSmrg	esac
648317a48c7cSmrg      fi
648417a48c7cSmrg
648517a48c7cSmrg      # Don't error if the file doesn't exist and rm -f was used.
648617a48c7cSmrg      if (test -L "$file") >/dev/null 2>&1 \
648717a48c7cSmrg	|| (test -h "$file") >/dev/null 2>&1 \
648817a48c7cSmrg	|| test -f "$file"; then
648917a48c7cSmrg	:
649017a48c7cSmrg      elif test -d "$file"; then
649117a48c7cSmrg	exit_status=1
649217a48c7cSmrg	continue
649317a48c7cSmrg      elif test "$rmforce" = yes; then
649417a48c7cSmrg	continue
649517a48c7cSmrg      fi
649617a48c7cSmrg
649717a48c7cSmrg      rmfiles="$file"
649817a48c7cSmrg
649917a48c7cSmrg      case $name in
650017a48c7cSmrg      *.la)
650117a48c7cSmrg	# Possibly a libtool archive, so verify it.
650217a48c7cSmrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
650317a48c7cSmrg	  . $dir/$name
650417a48c7cSmrg
650517a48c7cSmrg	  # Delete the libtool libraries and symlinks.
650617a48c7cSmrg	  for n in $library_names; do
650717a48c7cSmrg	    rmfiles="$rmfiles $objdir/$n"
650817a48c7cSmrg	  done
650917a48c7cSmrg	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
651017a48c7cSmrg
651117a48c7cSmrg	  case "$mode" in
651217a48c7cSmrg	  clean)
651317a48c7cSmrg	    case "  $library_names " in
651417a48c7cSmrg	    # "  " in the beginning catches empty $dlname
651517a48c7cSmrg	    *" $dlname "*) ;;
651617a48c7cSmrg	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
651717a48c7cSmrg	    esac
651817a48c7cSmrg	     test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
651917a48c7cSmrg	    ;;
652017a48c7cSmrg	  uninstall)
652117a48c7cSmrg	    if test -n "$library_names"; then
652217a48c7cSmrg	      # Do each command in the postuninstall commands.
652317a48c7cSmrg	      cmds=$postuninstall_cmds
652417a48c7cSmrg	      save_ifs="$IFS"; IFS='~'
652517a48c7cSmrg	      for cmd in $cmds; do
652617a48c7cSmrg		IFS="$save_ifs"
652717a48c7cSmrg		eval cmd=\"$cmd\"
652817a48c7cSmrg		$show "$cmd"
652917a48c7cSmrg		$run eval "$cmd"
653017a48c7cSmrg		if test "$?" -ne 0 && test "$rmforce" != yes; then
653117a48c7cSmrg		  exit_status=1
653217a48c7cSmrg		fi
653317a48c7cSmrg	      done
653417a48c7cSmrg	      IFS="$save_ifs"
653517a48c7cSmrg	    fi
653617a48c7cSmrg
653717a48c7cSmrg	    if test -n "$old_library"; then
653817a48c7cSmrg	      # Do each command in the old_postuninstall commands.
653917a48c7cSmrg	      cmds=$old_postuninstall_cmds
654017a48c7cSmrg	      save_ifs="$IFS"; IFS='~'
654117a48c7cSmrg	      for cmd in $cmds; do
654217a48c7cSmrg		IFS="$save_ifs"
654317a48c7cSmrg		eval cmd=\"$cmd\"
654417a48c7cSmrg		$show "$cmd"
654517a48c7cSmrg		$run eval "$cmd"
654617a48c7cSmrg		if test "$?" -ne 0 && test "$rmforce" != yes; then
654717a48c7cSmrg		  exit_status=1
654817a48c7cSmrg		fi
654917a48c7cSmrg	      done
655017a48c7cSmrg	      IFS="$save_ifs"
655117a48c7cSmrg	    fi
655217a48c7cSmrg	    # FIXME: should reinstall the best remaining shared library.
655317a48c7cSmrg	    ;;
655417a48c7cSmrg	  esac
655517a48c7cSmrg	fi
655617a48c7cSmrg	;;
655717a48c7cSmrg
655817a48c7cSmrg      *.lo)
655917a48c7cSmrg	# Possibly a libtool object, so verify it.
656017a48c7cSmrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
656117a48c7cSmrg
656217a48c7cSmrg	  # Read the .lo file
656317a48c7cSmrg	  . $dir/$name
656417a48c7cSmrg
656517a48c7cSmrg	  # Add PIC object to the list of files to remove.
656617a48c7cSmrg	  if test -n "$pic_object" \
656717a48c7cSmrg	     && test "$pic_object" != none; then
656817a48c7cSmrg	    rmfiles="$rmfiles $dir/$pic_object"
656917a48c7cSmrg	  fi
657017a48c7cSmrg
657117a48c7cSmrg	  # Add non-PIC object to the list of files to remove.
657217a48c7cSmrg	  if test -n "$non_pic_object" \
657317a48c7cSmrg	     && test "$non_pic_object" != none; then
657417a48c7cSmrg	    rmfiles="$rmfiles $dir/$non_pic_object"
657517a48c7cSmrg	  fi
657617a48c7cSmrg	fi
657717a48c7cSmrg	;;
657817a48c7cSmrg
657917a48c7cSmrg      *)
658017a48c7cSmrg	if test "$mode" = clean ; then
658117a48c7cSmrg	  noexename=$name
658217a48c7cSmrg	  case $file in
658317a48c7cSmrg	  *.exe)
658417a48c7cSmrg	    file=`$echo $file|${SED} 's,.exe$,,'`
658517a48c7cSmrg	    noexename=`$echo $name|${SED} 's,.exe$,,'`
658617a48c7cSmrg	    # $file with .exe has already been added to rmfiles,
658717a48c7cSmrg	    # add $file without .exe
658817a48c7cSmrg	    rmfiles="$rmfiles $file"
658917a48c7cSmrg	    ;;
659017a48c7cSmrg	  esac
659117a48c7cSmrg	  # Do a test to see if this is a libtool program.
659217a48c7cSmrg	  if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
659317a48c7cSmrg	    relink_command=
659417a48c7cSmrg	    . $dir/$noexename
659517a48c7cSmrg
659617a48c7cSmrg	    # note $name still contains .exe if it was in $file originally
659717a48c7cSmrg	    # as does the version of $file that was added into $rmfiles
659817a48c7cSmrg	    rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
659917a48c7cSmrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
660017a48c7cSmrg	      rmfiles="$rmfiles $objdir/lt-$name"
660117a48c7cSmrg	    fi
660217a48c7cSmrg	    if test "X$noexename" != "X$name" ; then
660317a48c7cSmrg	      rmfiles="$rmfiles $objdir/lt-${noexename}.c"
660417a48c7cSmrg	    fi
660517a48c7cSmrg	  fi
660617a48c7cSmrg	fi
660717a48c7cSmrg	;;
660817a48c7cSmrg      esac
660917a48c7cSmrg      $show "$rm $rmfiles"
661017a48c7cSmrg      $run $rm $rmfiles || exit_status=1
661117a48c7cSmrg    done
661217a48c7cSmrg    objdir="$origobjdir"
661317a48c7cSmrg
661417a48c7cSmrg    # Try to remove the ${objdir}s in the directories where we deleted files
661517a48c7cSmrg    for dir in $rmdirs; do
661617a48c7cSmrg      if test -d "$dir"; then
661717a48c7cSmrg	$show "rmdir $dir"
661817a48c7cSmrg	$run rmdir $dir >/dev/null 2>&1
661917a48c7cSmrg      fi
662017a48c7cSmrg    done
662117a48c7cSmrg
662217a48c7cSmrg    exit $exit_status
662317a48c7cSmrg    ;;
662417a48c7cSmrg
662517a48c7cSmrg  "")
662617a48c7cSmrg    $echo "$modename: you must specify a MODE" 1>&2
662717a48c7cSmrg    $echo "$generic_help" 1>&2
662817a48c7cSmrg    exit $EXIT_FAILURE
662917a48c7cSmrg    ;;
663017a48c7cSmrg  esac
663117a48c7cSmrg
663217a48c7cSmrg  if test -z "$exec_cmd"; then
663317a48c7cSmrg    $echo "$modename: invalid operation mode \`$mode'" 1>&2
663417a48c7cSmrg    $echo "$generic_help" 1>&2
663517a48c7cSmrg    exit $EXIT_FAILURE
663617a48c7cSmrg  fi
663717a48c7cSmrgfi # test -z "$show_help"
663817a48c7cSmrg
663917a48c7cSmrgif test -n "$exec_cmd"; then
664017a48c7cSmrg  eval exec $exec_cmd
664117a48c7cSmrg  exit $EXIT_FAILURE
664217a48c7cSmrgfi
664317a48c7cSmrg
664417a48c7cSmrg# We need to display help for each of the modes.
664517a48c7cSmrgcase $mode in
664617a48c7cSmrg"") $echo \
664717a48c7cSmrg"Usage: $modename [OPTION]... [MODE-ARG]...
664817a48c7cSmrg
664917a48c7cSmrgProvide generalized library-building support services.
665017a48c7cSmrg
665117a48c7cSmrg    --config          show all configuration variables
665217a48c7cSmrg    --debug           enable verbose shell tracing
665317a48c7cSmrg-n, --dry-run         display commands without modifying any files
665417a48c7cSmrg    --features        display basic configuration information and exit
665517a48c7cSmrg    --finish          same as \`--mode=finish'
665617a48c7cSmrg    --help            display this help message and exit
665717a48c7cSmrg    --mode=MODE       use operation mode MODE [default=inferred from MODE-ARGS]
665817a48c7cSmrg    --quiet           same as \`--silent'
665917a48c7cSmrg    --silent          don't print informational messages
666017a48c7cSmrg    --tag=TAG         use configuration variables from tag TAG
666117a48c7cSmrg    --version         print version information
666217a48c7cSmrg
666317a48c7cSmrgMODE must be one of the following:
666417a48c7cSmrg
666517a48c7cSmrg      clean           remove files from the build directory
666617a48c7cSmrg      compile         compile a source file into a libtool object
666717a48c7cSmrg      execute         automatically set library path, then run a program
666817a48c7cSmrg      finish          complete the installation of libtool libraries
666917a48c7cSmrg      install         install libraries or executables
667017a48c7cSmrg      link            create a library or an executable
667117a48c7cSmrg      uninstall       remove libraries from an installed directory
667217a48c7cSmrg
667317a48c7cSmrgMODE-ARGS vary depending on the MODE.  Try \`$modename --help --mode=MODE' for
667417a48c7cSmrga more detailed description of MODE.
667517a48c7cSmrg
667617a48c7cSmrgReport bugs to <bug-libtool@gnu.org>."
667717a48c7cSmrg  exit $EXIT_SUCCESS
667817a48c7cSmrg  ;;
667917a48c7cSmrg
668017a48c7cSmrgclean)
668117a48c7cSmrg  $echo \
668217a48c7cSmrg"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
668317a48c7cSmrg
668417a48c7cSmrgRemove files from the build directory.
668517a48c7cSmrg
668617a48c7cSmrgRM is the name of the program to use to delete files associated with each FILE
668717a48c7cSmrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
668817a48c7cSmrgto RM.
668917a48c7cSmrg
669017a48c7cSmrgIf FILE is a libtool library, object or program, all the files associated
669117a48c7cSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
669217a48c7cSmrg  ;;
669317a48c7cSmrg
669417a48c7cSmrgcompile)
669517a48c7cSmrg  $echo \
669617a48c7cSmrg"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
669717a48c7cSmrg
669817a48c7cSmrgCompile a source file into a libtool library object.
669917a48c7cSmrg
670017a48c7cSmrgThis mode accepts the following additional options:
670117a48c7cSmrg
670217a48c7cSmrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
670317a48c7cSmrg  -prefer-pic       try to building PIC objects only
670417a48c7cSmrg  -prefer-non-pic   try to building non-PIC objects only
670517a48c7cSmrg  -static           always build a \`.o' file suitable for static linking
670617a48c7cSmrg
670717a48c7cSmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
670817a48c7cSmrgfrom the given SOURCEFILE.
670917a48c7cSmrg
671017a48c7cSmrgThe output file name is determined by removing the directory component from
671117a48c7cSmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
671217a48c7cSmrglibrary object suffix, \`.lo'."
671317a48c7cSmrg  ;;
671417a48c7cSmrg
671517a48c7cSmrgexecute)
671617a48c7cSmrg  $echo \
671717a48c7cSmrg"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]...
671817a48c7cSmrg
671917a48c7cSmrgAutomatically set library path, then run a program.
672017a48c7cSmrg
672117a48c7cSmrgThis mode accepts the following additional options:
672217a48c7cSmrg
672317a48c7cSmrg  -dlopen FILE      add the directory containing FILE to the library path
672417a48c7cSmrg
672517a48c7cSmrgThis mode sets the library path environment variable according to \`-dlopen'
672617a48c7cSmrgflags.
672717a48c7cSmrg
672817a48c7cSmrgIf any of the ARGS are libtool executable wrappers, then they are translated
672917a48c7cSmrginto their corresponding uninstalled binary, and any of their required library
673017a48c7cSmrgdirectories are added to the library path.
673117a48c7cSmrg
673217a48c7cSmrgThen, COMMAND is executed, with ARGS as arguments."
673317a48c7cSmrg  ;;
673417a48c7cSmrg
673517a48c7cSmrgfinish)
673617a48c7cSmrg  $echo \
673717a48c7cSmrg"Usage: $modename [OPTION]... --mode=finish [LIBDIR]...
673817a48c7cSmrg
673917a48c7cSmrgComplete the installation of libtool libraries.
674017a48c7cSmrg
674117a48c7cSmrgEach LIBDIR is a directory that contains libtool libraries.
674217a48c7cSmrg
674317a48c7cSmrgThe commands that this mode executes may require superuser privileges.  Use
674417a48c7cSmrgthe \`--dry-run' option if you just want to see what would be executed."
674517a48c7cSmrg  ;;
674617a48c7cSmrg
674717a48c7cSmrginstall)
674817a48c7cSmrg  $echo \
674917a48c7cSmrg"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND...
675017a48c7cSmrg
675117a48c7cSmrgInstall executables or libraries.
675217a48c7cSmrg
675317a48c7cSmrgINSTALL-COMMAND is the installation command.  The first component should be
675417a48c7cSmrgeither the \`install' or \`cp' program.
675517a48c7cSmrg
675617a48c7cSmrgThe rest of the components are interpreted as arguments to that command (only
675717a48c7cSmrgBSD-compatible install options are recognized)."
675817a48c7cSmrg  ;;
675917a48c7cSmrg
676017a48c7cSmrglink)
676117a48c7cSmrg  $echo \
676217a48c7cSmrg"Usage: $modename [OPTION]... --mode=link LINK-COMMAND...
676317a48c7cSmrg
676417a48c7cSmrgLink object files or libraries together to form another library, or to
676517a48c7cSmrgcreate an executable program.
676617a48c7cSmrg
676717a48c7cSmrgLINK-COMMAND is a command using the C compiler that you would use to create
676817a48c7cSmrga program from several object files.
676917a48c7cSmrg
677017a48c7cSmrgThe following components of LINK-COMMAND are treated specially:
677117a48c7cSmrg
677217a48c7cSmrg  -all-static       do not do any dynamic linking at all
677317a48c7cSmrg  -avoid-version    do not add a version suffix if possible
677417a48c7cSmrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
677517a48c7cSmrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
677617a48c7cSmrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
677717a48c7cSmrg  -export-symbols SYMFILE
677817a48c7cSmrg		    try to export only the symbols listed in SYMFILE
677917a48c7cSmrg  -export-symbols-regex REGEX
678017a48c7cSmrg		    try to export only the symbols matching REGEX
678117a48c7cSmrg  -LLIBDIR          search LIBDIR for required installed libraries
678217a48c7cSmrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
678317a48c7cSmrg  -module           build a library that can dlopened
678417a48c7cSmrg  -no-fast-install  disable the fast-install mode
678517a48c7cSmrg  -no-install       link a not-installable executable
678617a48c7cSmrg  -no-undefined     declare that a library does not refer to external symbols
678717a48c7cSmrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
678817a48c7cSmrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
678917a48c7cSmrg  -precious-files-regex REGEX
679017a48c7cSmrg                    don't remove output files matching REGEX
679117a48c7cSmrg  -release RELEASE  specify package release information
679217a48c7cSmrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
679317a48c7cSmrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
679417a48c7cSmrg  -static           do not do any dynamic linking of libtool libraries
679517a48c7cSmrg  -version-info CURRENT[:REVISION[:AGE]]
679617a48c7cSmrg		    specify library version info [each variable defaults to 0]
679717a48c7cSmrg
679817a48c7cSmrgAll other options (arguments beginning with \`-') are ignored.
679917a48c7cSmrg
680017a48c7cSmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
680117a48c7cSmrgtreated as uninstalled libtool libraries, other files are standard or library
680217a48c7cSmrgobject files.
680317a48c7cSmrg
680417a48c7cSmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
680517a48c7cSmrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
680617a48c7cSmrgrequired, except when creating a convenience library.
680717a48c7cSmrg
680817a48c7cSmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
680917a48c7cSmrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
681017a48c7cSmrg
681117a48c7cSmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
681217a48c7cSmrgis created, otherwise an executable program is created."
681317a48c7cSmrg  ;;
681417a48c7cSmrg
681517a48c7cSmrguninstall)
681617a48c7cSmrg  $echo \
681717a48c7cSmrg"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
681817a48c7cSmrg
681917a48c7cSmrgRemove libraries from an installation directory.
682017a48c7cSmrg
682117a48c7cSmrgRM is the name of the program to use to delete files associated with each FILE
682217a48c7cSmrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
682317a48c7cSmrgto RM.
682417a48c7cSmrg
682517a48c7cSmrgIf FILE is a libtool library, all the files associated with it are deleted.
682617a48c7cSmrgOtherwise, only FILE itself is deleted using RM."
682717a48c7cSmrg  ;;
682817a48c7cSmrg
682917a48c7cSmrg*)
683017a48c7cSmrg  $echo "$modename: invalid operation mode \`$mode'" 1>&2
683117a48c7cSmrg  $echo "$help" 1>&2
683217a48c7cSmrg  exit $EXIT_FAILURE
683317a48c7cSmrg  ;;
683417a48c7cSmrgesac
683517a48c7cSmrg
683617a48c7cSmrg$echo
683717a48c7cSmrg$echo "Try \`$modename --help' for more information about other modes."
683817a48c7cSmrg
683917a48c7cSmrgexit $?
684017a48c7cSmrg
684117a48c7cSmrg# The TAGs below are defined such that we never get into a situation
684217a48c7cSmrg# in which we disable both kinds of libraries.  Given conflicting
684317a48c7cSmrg# choices, we go for a static library, that is the most portable,
684417a48c7cSmrg# since we can't tell whether shared libraries were disabled because
684517a48c7cSmrg# the user asked for that or because the platform doesn't support
684617a48c7cSmrg# them.  This is particularly important on AIX, because we don't
684717a48c7cSmrg# support having both static and shared libraries enabled at the same
684817a48c7cSmrg# time on that platform, so we default to a shared-only configuration.
684917a48c7cSmrg# If a disable-shared tag is given, we'll fallback to a static-only
685017a48c7cSmrg# configuration.  But we'll never go from static-only to shared-only.
685117a48c7cSmrg
685217a48c7cSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
685317a48c7cSmrgdisable_libs=shared
685417a48c7cSmrg# ### END LIBTOOL TAG CONFIG: disable-shared
685517a48c7cSmrg
685617a48c7cSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
685717a48c7cSmrgdisable_libs=static
685817a48c7cSmrg# ### END LIBTOOL TAG CONFIG: disable-static
685917a48c7cSmrg
686017a48c7cSmrg# Local Variables:
686117a48c7cSmrg# mode:shell-script
686217a48c7cSmrg# sh-indentation:2
686317a48c7cSmrg# End:
6864