ltmain.sh revision 09885543
109885543Smrg# ltmain.sh - Provide generalized library-building support services.
209885543Smrg# NOTE: Changing this file will not affect anything until you rerun configure.
309885543Smrg#
409885543Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005
509885543Smrg# Free Software Foundation, Inc.
609885543Smrg# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
709885543Smrg#
809885543Smrg# This program is free software; you can redistribute it and/or modify
909885543Smrg# it under the terms of the GNU General Public License as published by
1009885543Smrg# the Free Software Foundation; either version 2 of the License, or
1109885543Smrg# (at your option) any later version.
1209885543Smrg#
1309885543Smrg# This program is distributed in the hope that it will be useful, but
1409885543Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
1509885543Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1609885543Smrg# General Public License for more details.
1709885543Smrg#
1809885543Smrg# You should have received a copy of the GNU General Public License
1909885543Smrg# along with this program; if not, write to the Free Software
2009885543Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2109885543Smrg#
2209885543Smrg# As a special exception to the GNU General Public License, if you
2309885543Smrg# distribute this file as part of a program that contains a
2409885543Smrg# configuration script generated by Autoconf, you may include it under
2509885543Smrg# the same distribution terms that you use for the rest of that program.
2609885543Smrg
2709885543Smrgbasename="s,^.*/,,g"
2809885543Smrg
2909885543Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
3009885543Smrg# is ksh but when the shell is invoked as "sh" and the current value of
3109885543Smrg# the _XPG environment variable is not equal to 1 (one), the special
3209885543Smrg# positional parameter $0, within a function call, is the name of the
3309885543Smrg# function.
3409885543Smrgprogpath="$0"
3509885543Smrg
3609885543Smrg# The name of this program:
3709885543Smrgprogname=`echo "$progpath" | $SED $basename`
3809885543Smrgmodename="$progname"
3909885543Smrg
4009885543Smrg# Global variables:
4109885543SmrgEXIT_SUCCESS=0
4209885543SmrgEXIT_FAILURE=1
4309885543Smrg
4409885543SmrgPROGRAM=ltmain.sh
4509885543SmrgPACKAGE=libtool
4609885543SmrgVERSION="1.5.22 Debian 1.5.22-4"
4709885543SmrgTIMESTAMP=" (1.1220.2.365 2005/12/18 22:14:06)"
4809885543Smrg
4909885543Smrg# See if we are running on zsh, and set the options which allow our
5009885543Smrg# commands through without removal of \ escapes.
5109885543Smrgif test -n "${ZSH_VERSION+set}" ; then
5209885543Smrg  setopt NO_GLOB_SUBST
5309885543Smrgfi
5409885543Smrg
5509885543Smrg# Check that we have a working $echo.
5609885543Smrgif test "X$1" = X--no-reexec; then
5709885543Smrg  # Discard the --no-reexec flag, and continue.
5809885543Smrg  shift
5909885543Smrgelif test "X$1" = X--fallback-echo; then
6009885543Smrg  # Avoid inline document here, it may be left over
6109885543Smrg  :
6209885543Smrgelif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
6309885543Smrg  # Yippee, $echo works!
6409885543Smrg  :
6509885543Smrgelse
6609885543Smrg  # Restart under the correct shell, and then maybe $echo will work.
6709885543Smrg  exec $SHELL "$progpath" --no-reexec ${1+"$@"}
6809885543Smrgfi
6909885543Smrg
7009885543Smrgif test "X$1" = X--fallback-echo; then
7109885543Smrg  # used as fallback echo
7209885543Smrg  shift
7309885543Smrg  cat <<EOF
7409885543Smrg$*
7509885543SmrgEOF
7609885543Smrg  exit $EXIT_SUCCESS
7709885543Smrgfi
7809885543Smrg
7909885543Smrgdefault_mode=
8009885543Smrghelp="Try \`$progname --help' for more information."
8109885543Smrgmagic="%%%MAGIC variable%%%"
8209885543Smrgmkdir="mkdir"
8309885543Smrgmv="mv -f"
8409885543Smrgrm="rm -f"
8509885543Smrg
8609885543Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
8709885543Smrg# metacharacters that are still active within double-quoted strings.
8809885543SmrgXsed="${SED}"' -e 1s/^X//'
8909885543Smrgsed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
9009885543Smrg# test EBCDIC or ASCII
9109885543Smrgcase `echo X|tr X '\101'` in
9209885543Smrg A) # ASCII based system
9309885543Smrg    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
9409885543Smrg  SP2NL='tr \040 \012'
9509885543Smrg  NL2SP='tr \015\012 \040\040'
9609885543Smrg  ;;
9709885543Smrg *) # EBCDIC based system
9809885543Smrg  SP2NL='tr \100 \n'
9909885543Smrg  NL2SP='tr \r\n \100\100'
10009885543Smrg  ;;
10109885543Smrgesac
10209885543Smrg
10309885543Smrg# NLS nuisances.
10409885543Smrg# Only set LANG and LC_ALL to C if already set.
10509885543Smrg# These must not be set unconditionally because not all systems understand
10609885543Smrg# e.g. LANG=C (notably SCO).
10709885543Smrg# We save the old values to restore during execute mode.
10809885543Smrgif test "${LC_ALL+set}" = set; then
10909885543Smrg  save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
11009885543Smrgfi
11109885543Smrgif test "${LANG+set}" = set; then
11209885543Smrg  save_LANG="$LANG"; LANG=C; export LANG
11309885543Smrgfi
11409885543Smrg
11509885543Smrg# Make sure IFS has a sensible default
11609885543Smrglt_nl='
11709885543Smrg'
11809885543SmrgIFS=" 	$lt_nl"
11909885543Smrg
12009885543Smrgif test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
12109885543Smrg  $echo "$modename: not configured to build any kind of library" 1>&2
12209885543Smrg  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
12309885543Smrg  exit $EXIT_FAILURE
12409885543Smrgfi
12509885543Smrg
12609885543Smrg# Global variables.
12709885543Smrgmode=$default_mode
12809885543Smrgnonopt=
12909885543Smrgprev=
13009885543Smrgprevopt=
13109885543Smrgrun=
13209885543Smrgshow="$echo"
13309885543Smrgshow_help=
13409885543Smrgexecute_dlfiles=
13509885543Smrgduplicate_deps=no
13609885543Smrgpreserve_args=
13709885543Smrglo2o="s/\\.lo\$/.${objext}/"
13809885543Smrgo2lo="s/\\.${objext}\$/.lo/"
13909885543Smrg
14009885543Smrg#####################################
14109885543Smrg# Shell function definitions:
14209885543Smrg# This seems to be the best place for them
14309885543Smrg
14409885543Smrg# func_mktempdir [string]
14509885543Smrg# Make a temporary directory that won't clash with other running
14609885543Smrg# libtool processes, and avoids race conditions if possible.  If
14709885543Smrg# given, STRING is the basename for that directory.
14809885543Smrgfunc_mktempdir ()
14909885543Smrg{
15009885543Smrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
15109885543Smrg
15209885543Smrg    if test "$run" = ":"; then
15309885543Smrg      # Return a directory name, but don't create it in dry-run mode
15409885543Smrg      my_tmpdir="${my_template}-$$"
15509885543Smrg    else
15609885543Smrg
15709885543Smrg      # If mktemp works, use that first and foremost
15809885543Smrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
15909885543Smrg
16009885543Smrg      if test ! -d "$my_tmpdir"; then
16109885543Smrg	# Failing that, at least try and use $RANDOM to avoid a race
16209885543Smrg	my_tmpdir="${my_template}-${RANDOM-0}$$"
16309885543Smrg
16409885543Smrg	save_mktempdir_umask=`umask`
16509885543Smrg	umask 0077
16609885543Smrg	$mkdir "$my_tmpdir"
16709885543Smrg	umask $save_mktempdir_umask
16809885543Smrg      fi
16909885543Smrg
17009885543Smrg      # If we're not in dry-run mode, bomb out on failure
17109885543Smrg      test -d "$my_tmpdir" || {
17209885543Smrg        $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
17309885543Smrg	exit $EXIT_FAILURE
17409885543Smrg      }
17509885543Smrg    fi
17609885543Smrg
17709885543Smrg    $echo "X$my_tmpdir" | $Xsed
17809885543Smrg}
17909885543Smrg
18009885543Smrg
18109885543Smrg# func_win32_libid arg
18209885543Smrg# return the library type of file 'arg'
18309885543Smrg#
18409885543Smrg# Need a lot of goo to handle *both* DLLs and import libs
18509885543Smrg# Has to be a shell function in order to 'eat' the argument
18609885543Smrg# that is supplied when $file_magic_command is called.
18709885543Smrgfunc_win32_libid ()
18809885543Smrg{
18909885543Smrg  win32_libid_type="unknown"
19009885543Smrg  win32_fileres=`file -L $1 2>/dev/null`
19109885543Smrg  case $win32_fileres in
19209885543Smrg  *ar\ archive\ import\ library*) # definitely import
19309885543Smrg    win32_libid_type="x86 archive import"
19409885543Smrg    ;;
19509885543Smrg  *ar\ archive*) # could be an import, or static
19609885543Smrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
19709885543Smrg      $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
19809885543Smrg      win32_nmres=`eval $NM -f posix -A $1 | \
19909885543Smrg	$SED -n -e '1,100{/ I /{s,.*,import,;p;q;};}'`
20009885543Smrg      case $win32_nmres in
20109885543Smrg      import*)  win32_libid_type="x86 archive import";;
20209885543Smrg      *)        win32_libid_type="x86 archive static";;
20309885543Smrg      esac
20409885543Smrg    fi
20509885543Smrg    ;;
20609885543Smrg  *DLL*)
20709885543Smrg    win32_libid_type="x86 DLL"
20809885543Smrg    ;;
20909885543Smrg  *executable*) # but shell scripts are "executable" too...
21009885543Smrg    case $win32_fileres in
21109885543Smrg    *MS\ Windows\ PE\ Intel*)
21209885543Smrg      win32_libid_type="x86 DLL"
21309885543Smrg      ;;
21409885543Smrg    esac
21509885543Smrg    ;;
21609885543Smrg  esac
21709885543Smrg  $echo $win32_libid_type
21809885543Smrg}
21909885543Smrg
22009885543Smrg
22109885543Smrg# func_infer_tag arg
22209885543Smrg# Infer tagged configuration to use if any are available and
22309885543Smrg# if one wasn't chosen via the "--tag" command line option.
22409885543Smrg# Only attempt this if the compiler in the base compile
22509885543Smrg# command doesn't match the default compiler.
22609885543Smrg# arg is usually of the form 'gcc ...'
22709885543Smrgfunc_infer_tag ()
22809885543Smrg{
22909885543Smrg    if test -n "$available_tags" && test -z "$tagname"; then
23009885543Smrg      CC_quoted=
23109885543Smrg      for arg in $CC; do
23209885543Smrg	case $arg in
23309885543Smrg	  *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
23409885543Smrg	  arg="\"$arg\""
23509885543Smrg	  ;;
23609885543Smrg	esac
23709885543Smrg	CC_quoted="$CC_quoted $arg"
23809885543Smrg      done
23909885543Smrg      case $@ in
24009885543Smrg      # Blanks in the command may have been stripped by the calling shell,
24109885543Smrg      # but not from the CC environment variable when configure was run.
24209885543Smrg      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
24309885543Smrg      # Blanks at the start of $base_compile will cause this to fail
24409885543Smrg      # if we don't check for them as well.
24509885543Smrg      *)
24609885543Smrg	for z in $available_tags; do
24709885543Smrg	  if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
24809885543Smrg	    # Evaluate the configuration.
24909885543Smrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
25009885543Smrg	    CC_quoted=
25109885543Smrg	    for arg in $CC; do
25209885543Smrg	    # Double-quote args containing other shell metacharacters.
25309885543Smrg	    case $arg in
25409885543Smrg	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
25509885543Smrg	      arg="\"$arg\""
25609885543Smrg	      ;;
25709885543Smrg	    esac
25809885543Smrg	    CC_quoted="$CC_quoted $arg"
25909885543Smrg	  done
26009885543Smrg	    case "$@ " in
26109885543Smrg	      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
26209885543Smrg	      # The compiler in the base compile command matches
26309885543Smrg	      # the one in the tagged configuration.
26409885543Smrg	      # Assume this is the tagged configuration we want.
26509885543Smrg	      tagname=$z
26609885543Smrg	      break
26709885543Smrg	      ;;
26809885543Smrg	    esac
26909885543Smrg	  fi
27009885543Smrg	done
27109885543Smrg	# If $tagname still isn't set, then no tagged configuration
27209885543Smrg	# was found and let the user know that the "--tag" command
27309885543Smrg	# line option must be used.
27409885543Smrg	if test -z "$tagname"; then
27509885543Smrg	  $echo "$modename: unable to infer tagged configuration"
27609885543Smrg	  $echo "$modename: specify a tag with \`--tag'" 1>&2
27709885543Smrg	  exit $EXIT_FAILURE
27809885543Smrg#        else
27909885543Smrg#          $echo "$modename: using $tagname tagged configuration"
28009885543Smrg	fi
28109885543Smrg	;;
28209885543Smrg      esac
28309885543Smrg    fi
28409885543Smrg}
28509885543Smrg
28609885543Smrg
28709885543Smrg# func_extract_an_archive dir oldlib
28809885543Smrgfunc_extract_an_archive ()
28909885543Smrg{
29009885543Smrg    f_ex_an_ar_dir="$1"; shift
29109885543Smrg    f_ex_an_ar_oldlib="$1"
29209885543Smrg
29309885543Smrg    $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
29409885543Smrg    $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
29509885543Smrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
29609885543Smrg     :
29709885543Smrg    else
29809885543Smrg      $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2
29909885543Smrg      exit $EXIT_FAILURE
30009885543Smrg    fi
30109885543Smrg}
30209885543Smrg
30309885543Smrg# func_extract_archives gentop oldlib ...
30409885543Smrgfunc_extract_archives ()
30509885543Smrg{
30609885543Smrg    my_gentop="$1"; shift
30709885543Smrg    my_oldlibs=${1+"$@"}
30809885543Smrg    my_oldobjs=""
30909885543Smrg    my_xlib=""
31009885543Smrg    my_xabs=""
31109885543Smrg    my_xdir=""
31209885543Smrg    my_status=""
31309885543Smrg
31409885543Smrg    $show "${rm}r $my_gentop"
31509885543Smrg    $run ${rm}r "$my_gentop"
31609885543Smrg    $show "$mkdir $my_gentop"
31709885543Smrg    $run $mkdir "$my_gentop"
31809885543Smrg    my_status=$?
31909885543Smrg    if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
32009885543Smrg      exit $my_status
32109885543Smrg    fi
32209885543Smrg
32309885543Smrg    for my_xlib in $my_oldlibs; do
32409885543Smrg      # Extract the objects.
32509885543Smrg      case $my_xlib in
32609885543Smrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
32709885543Smrg	*) my_xabs=`pwd`"/$my_xlib" ;;
32809885543Smrg      esac
32909885543Smrg      my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
33009885543Smrg      my_xdir="$my_gentop/$my_xlib"
33109885543Smrg
33209885543Smrg      $show "${rm}r $my_xdir"
33309885543Smrg      $run ${rm}r "$my_xdir"
33409885543Smrg      $show "$mkdir $my_xdir"
33509885543Smrg      $run $mkdir "$my_xdir"
33609885543Smrg      exit_status=$?
33709885543Smrg      if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then
33809885543Smrg	exit $exit_status
33909885543Smrg      fi
34009885543Smrg      case $host in
34109885543Smrg      *-darwin*)
34209885543Smrg	$show "Extracting $my_xabs"
34309885543Smrg	# Do not bother doing anything if just a dry run
34409885543Smrg	if test -z "$run"; then
34509885543Smrg	  darwin_orig_dir=`pwd`
34609885543Smrg	  cd $my_xdir || exit $?
34709885543Smrg	  darwin_archive=$my_xabs
34809885543Smrg	  darwin_curdir=`pwd`
34909885543Smrg	  darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'`
35009885543Smrg	  darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
35109885543Smrg	  if test -n "$darwin_arches"; then 
35209885543Smrg	    darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
35309885543Smrg	    darwin_arch=
35409885543Smrg	    $show "$darwin_base_archive has multiple architectures $darwin_arches"
35509885543Smrg	    for darwin_arch in  $darwin_arches ; do
35609885543Smrg	      mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
35709885543Smrg	      lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
35809885543Smrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
35909885543Smrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
36009885543Smrg	      cd "$darwin_curdir"
36109885543Smrg	      $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
36209885543Smrg	    done # $darwin_arches
36309885543Smrg      ## Okay now we have a bunch of thin objects, gotta fatten them up :)
36409885543Smrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP`
36509885543Smrg	    darwin_file=
36609885543Smrg	    darwin_files=
36709885543Smrg	    for darwin_file in $darwin_filelist; do
36809885543Smrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
36909885543Smrg	      lipo -create -output "$darwin_file" $darwin_files
37009885543Smrg	    done # $darwin_filelist
37109885543Smrg	    ${rm}r unfat-$$
37209885543Smrg	    cd "$darwin_orig_dir"
37309885543Smrg	  else
37409885543Smrg	    cd "$darwin_orig_dir"
37509885543Smrg 	    func_extract_an_archive "$my_xdir" "$my_xabs"
37609885543Smrg	  fi # $darwin_arches
37709885543Smrg	fi # $run
37809885543Smrg	;;
37909885543Smrg      *)
38009885543Smrg        func_extract_an_archive "$my_xdir" "$my_xabs"
38109885543Smrg        ;;
38209885543Smrg      esac
38309885543Smrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
38409885543Smrg    done
38509885543Smrg    func_extract_archives_result="$my_oldobjs"
38609885543Smrg}
38709885543Smrg# End of Shell function definitions
38809885543Smrg#####################################
38909885543Smrg
39009885543Smrg# Darwin sucks
39109885543Smrgeval std_shrext=\"$shrext_cmds\"
39209885543Smrg
39309885543Smrgdisable_libs=no
39409885543Smrg
39509885543Smrg# Parse our command line options once, thoroughly.
39609885543Smrgwhile test "$#" -gt 0
39709885543Smrgdo
39809885543Smrg  arg="$1"
39909885543Smrg  shift
40009885543Smrg
40109885543Smrg  case $arg in
40209885543Smrg  -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
40309885543Smrg  *) optarg= ;;
40409885543Smrg  esac
40509885543Smrg
40609885543Smrg  # If the previous option needs an argument, assign it.
40709885543Smrg  if test -n "$prev"; then
40809885543Smrg    case $prev in
40909885543Smrg    execute_dlfiles)
41009885543Smrg      execute_dlfiles="$execute_dlfiles $arg"
41109885543Smrg      ;;
41209885543Smrg    tag)
41309885543Smrg      tagname="$arg"
41409885543Smrg      preserve_args="${preserve_args}=$arg"
41509885543Smrg
41609885543Smrg      # Check whether tagname contains only valid characters
41709885543Smrg      case $tagname in
41809885543Smrg      *[!-_A-Za-z0-9,/]*)
41909885543Smrg	$echo "$progname: invalid tag name: $tagname" 1>&2
42009885543Smrg	exit $EXIT_FAILURE
42109885543Smrg	;;
42209885543Smrg      esac
42309885543Smrg
42409885543Smrg      case $tagname in
42509885543Smrg      CC)
42609885543Smrg	# Don't test for the "default" C tag, as we know, it's there, but
42709885543Smrg	# not specially marked.
42809885543Smrg	;;
42909885543Smrg      *)
43009885543Smrg	if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then
43109885543Smrg	  taglist="$taglist $tagname"
43209885543Smrg	  # Evaluate the configuration.
43309885543Smrg	  eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`"
43409885543Smrg	else
43509885543Smrg	  $echo "$progname: ignoring unknown tag $tagname" 1>&2
43609885543Smrg	fi
43709885543Smrg	;;
43809885543Smrg      esac
43909885543Smrg      ;;
44009885543Smrg    *)
44109885543Smrg      eval "$prev=\$arg"
44209885543Smrg      ;;
44309885543Smrg    esac
44409885543Smrg
44509885543Smrg    prev=
44609885543Smrg    prevopt=
44709885543Smrg    continue
44809885543Smrg  fi
44909885543Smrg
45009885543Smrg  # Have we seen a non-optional argument yet?
45109885543Smrg  case $arg in
45209885543Smrg  --help)
45309885543Smrg    show_help=yes
45409885543Smrg    ;;
45509885543Smrg
45609885543Smrg  --version)
45709885543Smrg    $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
45809885543Smrg    $echo
45909885543Smrg    $echo "Copyright (C) 2005  Free Software Foundation, Inc."
46009885543Smrg    $echo "This is free software; see the source for copying conditions.  There is NO"
46109885543Smrg    $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
46209885543Smrg    exit $?
46309885543Smrg    ;;
46409885543Smrg
46509885543Smrg  --config)
46609885543Smrg    ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath
46709885543Smrg    # Now print the configurations for the tags.
46809885543Smrg    for tagname in $taglist; do
46909885543Smrg      ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
47009885543Smrg    done
47109885543Smrg    exit $?
47209885543Smrg    ;;
47309885543Smrg
47409885543Smrg  --debug)
47509885543Smrg    $echo "$progname: enabling shell trace mode"
47609885543Smrg    set -x
47709885543Smrg    preserve_args="$preserve_args $arg"
47809885543Smrg    ;;
47909885543Smrg
48009885543Smrg  --dry-run | -n)
48109885543Smrg    run=:
48209885543Smrg    ;;
48309885543Smrg
48409885543Smrg  --features)
48509885543Smrg    $echo "host: $host"
48609885543Smrg    if test "$build_libtool_libs" = yes; then
48709885543Smrg      $echo "enable shared libraries"
48809885543Smrg    else
48909885543Smrg      $echo "disable shared libraries"
49009885543Smrg    fi
49109885543Smrg    if test "$build_old_libs" = yes; then
49209885543Smrg      $echo "enable static libraries"
49309885543Smrg    else
49409885543Smrg      $echo "disable static libraries"
49509885543Smrg    fi
49609885543Smrg    exit $?
49709885543Smrg    ;;
49809885543Smrg
49909885543Smrg  --finish) mode="finish" ;;
50009885543Smrg
50109885543Smrg  --mode) prevopt="--mode" prev=mode ;;
50209885543Smrg  --mode=*) mode="$optarg" ;;
50309885543Smrg
50409885543Smrg  --preserve-dup-deps) duplicate_deps="yes" ;;
50509885543Smrg
50609885543Smrg  --quiet | --silent)
50709885543Smrg    show=:
50809885543Smrg    preserve_args="$preserve_args $arg"
50909885543Smrg    ;;
51009885543Smrg
51109885543Smrg  --tag)
51209885543Smrg    prevopt="--tag"
51309885543Smrg    prev=tag
51409885543Smrg    preserve_args="$preserve_args --tag"
51509885543Smrg    ;;
51609885543Smrg  --tag=*)
51709885543Smrg    set tag "$optarg" ${1+"$@"}
51809885543Smrg    shift
51909885543Smrg    prev=tag
52009885543Smrg    preserve_args="$preserve_args --tag"
52109885543Smrg    ;;
52209885543Smrg
52309885543Smrg  -dlopen)
52409885543Smrg    prevopt="-dlopen"
52509885543Smrg    prev=execute_dlfiles
52609885543Smrg    ;;
52709885543Smrg
52809885543Smrg  -*)
52909885543Smrg    $echo "$modename: unrecognized option \`$arg'" 1>&2
53009885543Smrg    $echo "$help" 1>&2
53109885543Smrg    exit $EXIT_FAILURE
53209885543Smrg    ;;
53309885543Smrg
53409885543Smrg  *)
53509885543Smrg    nonopt="$arg"
53609885543Smrg    break
53709885543Smrg    ;;
53809885543Smrg  esac
53909885543Smrgdone
54009885543Smrg
54109885543Smrgif test -n "$prevopt"; then
54209885543Smrg  $echo "$modename: option \`$prevopt' requires an argument" 1>&2
54309885543Smrg  $echo "$help" 1>&2
54409885543Smrg  exit $EXIT_FAILURE
54509885543Smrgfi
54609885543Smrg
54709885543Smrgcase $disable_libs in
54809885543Smrgno) 
54909885543Smrg  ;;
55009885543Smrgshared)
55109885543Smrg  build_libtool_libs=no
55209885543Smrg  build_old_libs=yes
55309885543Smrg  ;;
55409885543Smrgstatic)
55509885543Smrg  build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
55609885543Smrg  ;;
55709885543Smrgesac
55809885543Smrg
55909885543Smrg# If this variable is set in any of the actions, the command in it
56009885543Smrg# will be execed at the end.  This prevents here-documents from being
56109885543Smrg# left over by shells.
56209885543Smrgexec_cmd=
56309885543Smrg
56409885543Smrgif test -z "$show_help"; then
56509885543Smrg
56609885543Smrg  # Infer the operation mode.
56709885543Smrg  if test -z "$mode"; then
56809885543Smrg    $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
56909885543Smrg    $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2
57009885543Smrg    case $nonopt in
57109885543Smrg    *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
57209885543Smrg      mode=link
57309885543Smrg      for arg
57409885543Smrg      do
57509885543Smrg	case $arg in
57609885543Smrg	-c)
57709885543Smrg	   mode=compile
57809885543Smrg	   break
57909885543Smrg	   ;;
58009885543Smrg	esac
58109885543Smrg      done
58209885543Smrg      ;;
58309885543Smrg    *db | *dbx | *strace | *truss)
58409885543Smrg      mode=execute
58509885543Smrg      ;;
58609885543Smrg    *install*|cp|mv)
58709885543Smrg      mode=install
58809885543Smrg      ;;
58909885543Smrg    *rm)
59009885543Smrg      mode=uninstall
59109885543Smrg      ;;
59209885543Smrg    *)
59309885543Smrg      # If we have no mode, but dlfiles were specified, then do execute mode.
59409885543Smrg      test -n "$execute_dlfiles" && mode=execute
59509885543Smrg
59609885543Smrg      # Just use the default operation mode.
59709885543Smrg      if test -z "$mode"; then
59809885543Smrg	if test -n "$nonopt"; then
59909885543Smrg	  $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
60009885543Smrg	else
60109885543Smrg	  $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
60209885543Smrg	fi
60309885543Smrg      fi
60409885543Smrg      ;;
60509885543Smrg    esac
60609885543Smrg  fi
60709885543Smrg
60809885543Smrg  # Only execute mode is allowed to have -dlopen flags.
60909885543Smrg  if test -n "$execute_dlfiles" && test "$mode" != execute; then
61009885543Smrg    $echo "$modename: unrecognized option \`-dlopen'" 1>&2
61109885543Smrg    $echo "$help" 1>&2
61209885543Smrg    exit $EXIT_FAILURE
61309885543Smrg  fi
61409885543Smrg
61509885543Smrg  # Change the help message to a mode-specific one.
61609885543Smrg  generic_help="$help"
61709885543Smrg  help="Try \`$modename --help --mode=$mode' for more information."
61809885543Smrg
61909885543Smrg  # These modes are in order of execution frequency so that they run quickly.
62009885543Smrg  case $mode in
62109885543Smrg  # libtool compile mode
62209885543Smrg  compile)
62309885543Smrg    modename="$modename: compile"
62409885543Smrg    # Get the compilation command and the source file.
62509885543Smrg    base_compile=
62609885543Smrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
62709885543Smrg    suppress_opt=yes
62809885543Smrg    suppress_output=
62909885543Smrg    arg_mode=normal
63009885543Smrg    libobj=
63109885543Smrg    later=
63209885543Smrg
63309885543Smrg    for arg
63409885543Smrg    do
63509885543Smrg      case $arg_mode in
63609885543Smrg      arg  )
63709885543Smrg	# do not "continue".  Instead, add this to base_compile
63809885543Smrg	lastarg="$arg"
63909885543Smrg	arg_mode=normal
64009885543Smrg	;;
64109885543Smrg
64209885543Smrg      target )
64309885543Smrg	libobj="$arg"
64409885543Smrg	arg_mode=normal
64509885543Smrg	continue
64609885543Smrg	;;
64709885543Smrg
64809885543Smrg      normal )
64909885543Smrg	# Accept any command-line options.
65009885543Smrg	case $arg in
65109885543Smrg	-o)
65209885543Smrg	  if test -n "$libobj" ; then
65309885543Smrg	    $echo "$modename: you cannot specify \`-o' more than once" 1>&2
65409885543Smrg	    exit $EXIT_FAILURE
65509885543Smrg	  fi
65609885543Smrg	  arg_mode=target
65709885543Smrg	  continue
65809885543Smrg	  ;;
65909885543Smrg
66009885543Smrg	-static | -prefer-pic | -prefer-non-pic)
66109885543Smrg	  later="$later $arg"
66209885543Smrg	  continue
66309885543Smrg	  ;;
66409885543Smrg
66509885543Smrg	-no-suppress)
66609885543Smrg	  suppress_opt=no
66709885543Smrg	  continue
66809885543Smrg	  ;;
66909885543Smrg
67009885543Smrg	-Xcompiler)
67109885543Smrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
67209885543Smrg	  continue      #  The current "srcfile" will either be retained or
67309885543Smrg	  ;;            #  replaced later.  I would guess that would be a bug.
67409885543Smrg
67509885543Smrg	-Wc,*)
67609885543Smrg	  args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
67709885543Smrg	  lastarg=
67809885543Smrg	  save_ifs="$IFS"; IFS=','
67909885543Smrg 	  for arg in $args; do
68009885543Smrg	    IFS="$save_ifs"
68109885543Smrg
68209885543Smrg	    # Double-quote args containing other shell metacharacters.
68309885543Smrg	    # Many Bourne shells cannot handle close brackets correctly
68409885543Smrg	    # in scan sets, so we specify it separately.
68509885543Smrg	    case $arg in
68609885543Smrg	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
68709885543Smrg	      arg="\"$arg\""
68809885543Smrg	      ;;
68909885543Smrg	    esac
69009885543Smrg	    lastarg="$lastarg $arg"
69109885543Smrg	  done
69209885543Smrg	  IFS="$save_ifs"
69309885543Smrg	  lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
69409885543Smrg
69509885543Smrg	  # Add the arguments to base_compile.
69609885543Smrg	  base_compile="$base_compile $lastarg"
69709885543Smrg	  continue
69809885543Smrg	  ;;
69909885543Smrg
70009885543Smrg	* )
70109885543Smrg	  # Accept the current argument as the source file.
70209885543Smrg	  # The previous "srcfile" becomes the current argument.
70309885543Smrg	  #
70409885543Smrg	  lastarg="$srcfile"
70509885543Smrg	  srcfile="$arg"
70609885543Smrg	  ;;
70709885543Smrg	esac  #  case $arg
70809885543Smrg	;;
70909885543Smrg      esac    #  case $arg_mode
71009885543Smrg
71109885543Smrg      # Aesthetically quote the previous argument.
71209885543Smrg      lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
71309885543Smrg
71409885543Smrg      case $lastarg in
71509885543Smrg      # Double-quote args containing other shell metacharacters.
71609885543Smrg      # Many Bourne shells cannot handle close brackets correctly
71709885543Smrg      # in scan sets, and some SunOS ksh mistreat backslash-escaping
71809885543Smrg      # in scan sets (worked around with variable expansion),
71909885543Smrg      # and furthermore cannot handle '|' '&' '(' ')' in scan sets 
72009885543Smrg      # at all, so we specify them separately.
72109885543Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
72209885543Smrg	lastarg="\"$lastarg\""
72309885543Smrg	;;
72409885543Smrg      esac
72509885543Smrg
72609885543Smrg      base_compile="$base_compile $lastarg"
72709885543Smrg    done # for arg
72809885543Smrg
72909885543Smrg    case $arg_mode in
73009885543Smrg    arg)
73109885543Smrg      $echo "$modename: you must specify an argument for -Xcompile"
73209885543Smrg      exit $EXIT_FAILURE
73309885543Smrg      ;;
73409885543Smrg    target)
73509885543Smrg      $echo "$modename: you must specify a target with \`-o'" 1>&2
73609885543Smrg      exit $EXIT_FAILURE
73709885543Smrg      ;;
73809885543Smrg    *)
73909885543Smrg      # Get the name of the library object.
74009885543Smrg      [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
74109885543Smrg      ;;
74209885543Smrg    esac
74309885543Smrg
74409885543Smrg    # Recognize several different file suffixes.
74509885543Smrg    # If the user specifies -o file.o, it is replaced with file.lo
74609885543Smrg    xform='[cCFSifmso]'
74709885543Smrg    case $libobj in
74809885543Smrg    *.ada) xform=ada ;;
74909885543Smrg    *.adb) xform=adb ;;
75009885543Smrg    *.ads) xform=ads ;;
75109885543Smrg    *.asm) xform=asm ;;
75209885543Smrg    *.c++) xform=c++ ;;
75309885543Smrg    *.cc) xform=cc ;;
75409885543Smrg    *.ii) xform=ii ;;
75509885543Smrg    *.class) xform=class ;;
75609885543Smrg    *.cpp) xform=cpp ;;
75709885543Smrg    *.cxx) xform=cxx ;;
75809885543Smrg    *.f90) xform=f90 ;;
75909885543Smrg    *.for) xform=for ;;
76009885543Smrg    *.java) xform=java ;;
76109885543Smrg    esac
76209885543Smrg
76309885543Smrg    libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
76409885543Smrg
76509885543Smrg    case $libobj in
76609885543Smrg    *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
76709885543Smrg    *)
76809885543Smrg      $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
76909885543Smrg      exit $EXIT_FAILURE
77009885543Smrg      ;;
77109885543Smrg    esac
77209885543Smrg
77309885543Smrg    func_infer_tag $base_compile
77409885543Smrg
77509885543Smrg    for arg in $later; do
77609885543Smrg      case $arg in
77709885543Smrg      -static)
77809885543Smrg	build_old_libs=yes
77909885543Smrg	continue
78009885543Smrg	;;
78109885543Smrg
78209885543Smrg      -prefer-pic)
78309885543Smrg	pic_mode=yes
78409885543Smrg	continue
78509885543Smrg	;;
78609885543Smrg
78709885543Smrg      -prefer-non-pic)
78809885543Smrg	pic_mode=no
78909885543Smrg	continue
79009885543Smrg	;;
79109885543Smrg      esac
79209885543Smrg    done
79309885543Smrg
79409885543Smrg    qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"`
79509885543Smrg    case $qlibobj in
79609885543Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
79709885543Smrg	qlibobj="\"$qlibobj\"" ;;
79809885543Smrg    esac
79909885543Smrg    test "X$libobj" != "X$qlibobj" \
80009885543Smrg	&& $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"' 	&()|`$[]' \
80109885543Smrg	&& $echo "$modename: libobj name \`$libobj' may not contain shell special characters."
80209885543Smrg    objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
80309885543Smrg    xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
80409885543Smrg    if test "X$xdir" = "X$obj"; then
80509885543Smrg      xdir=
80609885543Smrg    else
80709885543Smrg      xdir=$xdir/
80809885543Smrg    fi
80909885543Smrg    lobj=${xdir}$objdir/$objname
81009885543Smrg
81109885543Smrg    if test -z "$base_compile"; then
81209885543Smrg      $echo "$modename: you must specify a compilation command" 1>&2
81309885543Smrg      $echo "$help" 1>&2
81409885543Smrg      exit $EXIT_FAILURE
81509885543Smrg    fi
81609885543Smrg
81709885543Smrg    # Delete any leftover library objects.
81809885543Smrg    if test "$build_old_libs" = yes; then
81909885543Smrg      removelist="$obj $lobj $libobj ${libobj}T"
82009885543Smrg    else
82109885543Smrg      removelist="$lobj $libobj ${libobj}T"
82209885543Smrg    fi
82309885543Smrg
82409885543Smrg    $run $rm $removelist
82509885543Smrg    trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
82609885543Smrg
82709885543Smrg    # On Cygwin there's no "real" PIC flag so we must build both object types
82809885543Smrg    case $host_os in
82909885543Smrg    cygwin* | mingw* | pw32* | os2*)
83009885543Smrg      pic_mode=default
83109885543Smrg      ;;
83209885543Smrg    esac
83309885543Smrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
83409885543Smrg      # non-PIC code in shared libraries is not supported
83509885543Smrg      pic_mode=default
83609885543Smrg    fi
83709885543Smrg
83809885543Smrg    # Calculate the filename of the output object if compiler does
83909885543Smrg    # not support -o with -c
84009885543Smrg    if test "$compiler_c_o" = no; then
84109885543Smrg      output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
84209885543Smrg      lockfile="$output_obj.lock"
84309885543Smrg      removelist="$removelist $output_obj $lockfile"
84409885543Smrg      trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
84509885543Smrg    else
84609885543Smrg      output_obj=
84709885543Smrg      need_locks=no
84809885543Smrg      lockfile=
84909885543Smrg    fi
85009885543Smrg
85109885543Smrg    # Lock this critical section if it is needed
85209885543Smrg    # We use this script file to make the link, it avoids creating a new file
85309885543Smrg    if test "$need_locks" = yes; then
85409885543Smrg      until $run ln "$progpath" "$lockfile" 2>/dev/null; do
85509885543Smrg	$show "Waiting for $lockfile to be removed"
85609885543Smrg	sleep 2
85709885543Smrg      done
85809885543Smrg    elif test "$need_locks" = warn; then
85909885543Smrg      if test -f "$lockfile"; then
86009885543Smrg	$echo "\
86109885543Smrg*** ERROR, $lockfile exists and contains:
86209885543Smrg`cat $lockfile 2>/dev/null`
86309885543Smrg
86409885543SmrgThis indicates that another process is trying to use the same
86509885543Smrgtemporary object file, and libtool could not work around it because
86609885543Smrgyour compiler does not support \`-c' and \`-o' together.  If you
86709885543Smrgrepeat this compilation, it may succeed, by chance, but you had better
86809885543Smrgavoid parallel builds (make -j) in this platform, or get a better
86909885543Smrgcompiler."
87009885543Smrg
87109885543Smrg	$run $rm $removelist
87209885543Smrg	exit $EXIT_FAILURE
87309885543Smrg      fi
87409885543Smrg      $echo "$srcfile" > "$lockfile"
87509885543Smrg    fi
87609885543Smrg
87709885543Smrg    if test -n "$fix_srcfile_path"; then
87809885543Smrg      eval srcfile=\"$fix_srcfile_path\"
87909885543Smrg    fi
88009885543Smrg    qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"`
88109885543Smrg    case $qsrcfile in
88209885543Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
88309885543Smrg      qsrcfile="\"$qsrcfile\"" ;;
88409885543Smrg    esac
88509885543Smrg
88609885543Smrg    $run $rm "$libobj" "${libobj}T"
88709885543Smrg
88809885543Smrg    # Create a libtool object file (analogous to a ".la" file),
88909885543Smrg    # but don't create it if we're doing a dry run.
89009885543Smrg    test -z "$run" && cat > ${libobj}T <<EOF
89109885543Smrg# $libobj - a libtool object file
89209885543Smrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
89309885543Smrg#
89409885543Smrg# Please DO NOT delete this file!
89509885543Smrg# It is necessary for linking the library.
89609885543Smrg
89709885543Smrg# Name of the PIC object.
89809885543SmrgEOF
89909885543Smrg
90009885543Smrg    # Only build a PIC object if we are building libtool libraries.
90109885543Smrg    if test "$build_libtool_libs" = yes; then
90209885543Smrg      # Without this assignment, base_compile gets emptied.
90309885543Smrg      fbsd_hideous_sh_bug=$base_compile
90409885543Smrg
90509885543Smrg      if test "$pic_mode" != no; then
90609885543Smrg	command="$base_compile $qsrcfile $pic_flag"
90709885543Smrg      else
90809885543Smrg	# Don't build PIC code
90909885543Smrg	command="$base_compile $qsrcfile"
91009885543Smrg      fi
91109885543Smrg
91209885543Smrg      if test ! -d "${xdir}$objdir"; then
91309885543Smrg	$show "$mkdir ${xdir}$objdir"
91409885543Smrg	$run $mkdir ${xdir}$objdir
91509885543Smrg	exit_status=$?
91609885543Smrg	if test "$exit_status" -ne 0 && test ! -d "${xdir}$objdir"; then
91709885543Smrg	  exit $exit_status
91809885543Smrg	fi
91909885543Smrg      fi
92009885543Smrg
92109885543Smrg      if test -z "$output_obj"; then
92209885543Smrg	# Place PIC objects in $objdir
92309885543Smrg	command="$command -o $lobj"
92409885543Smrg      fi
92509885543Smrg
92609885543Smrg      $run $rm "$lobj" "$output_obj"
92709885543Smrg
92809885543Smrg      $show "$command"
92909885543Smrg      if $run eval "$command"; then :
93009885543Smrg      else
93109885543Smrg	test -n "$output_obj" && $run $rm $removelist
93209885543Smrg	exit $EXIT_FAILURE
93309885543Smrg      fi
93409885543Smrg
93509885543Smrg      if test "$need_locks" = warn &&
93609885543Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
93709885543Smrg	$echo "\
93809885543Smrg*** ERROR, $lockfile contains:
93909885543Smrg`cat $lockfile 2>/dev/null`
94009885543Smrg
94109885543Smrgbut it should contain:
94209885543Smrg$srcfile
94309885543Smrg
94409885543SmrgThis indicates that another process is trying to use the same
94509885543Smrgtemporary object file, and libtool could not work around it because
94609885543Smrgyour compiler does not support \`-c' and \`-o' together.  If you
94709885543Smrgrepeat this compilation, it may succeed, by chance, but you had better
94809885543Smrgavoid parallel builds (make -j) in this platform, or get a better
94909885543Smrgcompiler."
95009885543Smrg
95109885543Smrg	$run $rm $removelist
95209885543Smrg	exit $EXIT_FAILURE
95309885543Smrg      fi
95409885543Smrg
95509885543Smrg      # Just move the object if needed, then go on to compile the next one
95609885543Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
95709885543Smrg	$show "$mv $output_obj $lobj"
95809885543Smrg	if $run $mv $output_obj $lobj; then :
95909885543Smrg	else
96009885543Smrg	  error=$?
96109885543Smrg	  $run $rm $removelist
96209885543Smrg	  exit $error
96309885543Smrg	fi
96409885543Smrg      fi
96509885543Smrg
96609885543Smrg      # Append the name of the PIC object to the libtool object file.
96709885543Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
96809885543Smrgpic_object='$objdir/$objname'
96909885543Smrg
97009885543SmrgEOF
97109885543Smrg
97209885543Smrg      # Allow error messages only from the first compilation.
97309885543Smrg      if test "$suppress_opt" = yes; then
97409885543Smrg        suppress_output=' >/dev/null 2>&1'
97509885543Smrg      fi
97609885543Smrg    else
97709885543Smrg      # No PIC object so indicate it doesn't exist in the libtool
97809885543Smrg      # object file.
97909885543Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
98009885543Smrgpic_object=none
98109885543Smrg
98209885543SmrgEOF
98309885543Smrg    fi
98409885543Smrg
98509885543Smrg    # Only build a position-dependent object if we build old libraries.
98609885543Smrg    if test "$build_old_libs" = yes; then
98709885543Smrg      if test "$pic_mode" != yes; then
98809885543Smrg	# Don't build PIC code
98909885543Smrg	command="$base_compile $qsrcfile"
99009885543Smrg      else
99109885543Smrg	command="$base_compile $qsrcfile $pic_flag"
99209885543Smrg      fi
99309885543Smrg      if test "$compiler_c_o" = yes; then
99409885543Smrg	command="$command -o $obj"
99509885543Smrg      fi
99609885543Smrg
99709885543Smrg      # Suppress compiler output if we already did a PIC compilation.
99809885543Smrg      command="$command$suppress_output"
99909885543Smrg      $run $rm "$obj" "$output_obj"
100009885543Smrg      $show "$command"
100109885543Smrg      if $run eval "$command"; then :
100209885543Smrg      else
100309885543Smrg	$run $rm $removelist
100409885543Smrg	exit $EXIT_FAILURE
100509885543Smrg      fi
100609885543Smrg
100709885543Smrg      if test "$need_locks" = warn &&
100809885543Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
100909885543Smrg	$echo "\
101009885543Smrg*** ERROR, $lockfile contains:
101109885543Smrg`cat $lockfile 2>/dev/null`
101209885543Smrg
101309885543Smrgbut it should contain:
101409885543Smrg$srcfile
101509885543Smrg
101609885543SmrgThis indicates that another process is trying to use the same
101709885543Smrgtemporary object file, and libtool could not work around it because
101809885543Smrgyour compiler does not support \`-c' and \`-o' together.  If you
101909885543Smrgrepeat this compilation, it may succeed, by chance, but you had better
102009885543Smrgavoid parallel builds (make -j) in this platform, or get a better
102109885543Smrgcompiler."
102209885543Smrg
102309885543Smrg	$run $rm $removelist
102409885543Smrg	exit $EXIT_FAILURE
102509885543Smrg      fi
102609885543Smrg
102709885543Smrg      # Just move the object if needed
102809885543Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
102909885543Smrg	$show "$mv $output_obj $obj"
103009885543Smrg	if $run $mv $output_obj $obj; then :
103109885543Smrg	else
103209885543Smrg	  error=$?
103309885543Smrg	  $run $rm $removelist
103409885543Smrg	  exit $error
103509885543Smrg	fi
103609885543Smrg      fi
103709885543Smrg
103809885543Smrg      # Append the name of the non-PIC object the libtool object file.
103909885543Smrg      # Only append if the libtool object file exists.
104009885543Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
104109885543Smrg# Name of the non-PIC object.
104209885543Smrgnon_pic_object='$objname'
104309885543Smrg
104409885543SmrgEOF
104509885543Smrg    else
104609885543Smrg      # Append the name of the non-PIC object the libtool object file.
104709885543Smrg      # Only append if the libtool object file exists.
104809885543Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
104909885543Smrg# Name of the non-PIC object.
105009885543Smrgnon_pic_object=none
105109885543Smrg
105209885543SmrgEOF
105309885543Smrg    fi
105409885543Smrg
105509885543Smrg    $run $mv "${libobj}T" "${libobj}"
105609885543Smrg
105709885543Smrg    # Unlock the critical section if it was locked
105809885543Smrg    if test "$need_locks" != no; then
105909885543Smrg      $run $rm "$lockfile"
106009885543Smrg    fi
106109885543Smrg
106209885543Smrg    exit $EXIT_SUCCESS
106309885543Smrg    ;;
106409885543Smrg
106509885543Smrg  # libtool link mode
106609885543Smrg  link | relink)
106709885543Smrg    modename="$modename: link"
106809885543Smrg    case $host in
106909885543Smrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
107009885543Smrg      # It is impossible to link a dll without this setting, and
107109885543Smrg      # we shouldn't force the makefile maintainer to figure out
107209885543Smrg      # which system we are compiling for in order to pass an extra
107309885543Smrg      # flag for every libtool invocation.
107409885543Smrg      # allow_undefined=no
107509885543Smrg
107609885543Smrg      # FIXME: Unfortunately, there are problems with the above when trying
107709885543Smrg      # to make a dll which has undefined symbols, in which case not
107809885543Smrg      # even a static library is built.  For now, we need to specify
107909885543Smrg      # -no-undefined on the libtool link line when we can be certain
108009885543Smrg      # that all symbols are satisfied, otherwise we get a static library.
108109885543Smrg      allow_undefined=yes
108209885543Smrg      ;;
108309885543Smrg    *)
108409885543Smrg      allow_undefined=yes
108509885543Smrg      ;;
108609885543Smrg    esac
108709885543Smrg    libtool_args="$nonopt"
108809885543Smrg    base_compile="$nonopt $@"
108909885543Smrg    compile_command="$nonopt"
109009885543Smrg    finalize_command="$nonopt"
109109885543Smrg
109209885543Smrg    compile_rpath=
109309885543Smrg    finalize_rpath=
109409885543Smrg    compile_shlibpath=
109509885543Smrg    finalize_shlibpath=
109609885543Smrg    convenience=
109709885543Smrg    old_convenience=
109809885543Smrg    deplibs=
109909885543Smrg    old_deplibs=
110009885543Smrg    compiler_flags=
110109885543Smrg    linker_flags=
110209885543Smrg    dllsearchpath=
110309885543Smrg    lib_search_path=`pwd`
110409885543Smrg    inst_prefix_dir=
110509885543Smrg
110609885543Smrg    avoid_version=no
110709885543Smrg    dlfiles=
110809885543Smrg    dlprefiles=
110909885543Smrg    dlself=no
111009885543Smrg    export_dynamic=no
111109885543Smrg    export_symbols=
111209885543Smrg    export_symbols_regex=
111309885543Smrg    generated=
111409885543Smrg    libobjs=
111509885543Smrg    ltlibs=
111609885543Smrg    module=no
111709885543Smrg    no_install=no
111809885543Smrg    objs=
111909885543Smrg    non_pic_objects=
112009885543Smrg    notinst_path= # paths that contain not-installed libtool libraries
112109885543Smrg    precious_files_regex=
112209885543Smrg    prefer_static_libs=no
112309885543Smrg    preload=no
112409885543Smrg    prev=
112509885543Smrg    prevarg=
112609885543Smrg    release=
112709885543Smrg    rpath=
112809885543Smrg    xrpath=
112909885543Smrg    perm_rpath=
113009885543Smrg    temp_rpath=
113109885543Smrg    thread_safe=no
113209885543Smrg    vinfo=
113309885543Smrg    vinfo_number=no
113409885543Smrg
113509885543Smrg    func_infer_tag $base_compile
113609885543Smrg
113709885543Smrg    # We need to know -static, to get the right output filenames.
113809885543Smrg    for arg
113909885543Smrg    do
114009885543Smrg      case $arg in
114109885543Smrg      -all-static | -static)
114209885543Smrg	if test "X$arg" = "X-all-static"; then
114309885543Smrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
114409885543Smrg	    $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
114509885543Smrg	  fi
114609885543Smrg	  if test -n "$link_static_flag"; then
114709885543Smrg	    dlopen_self=$dlopen_self_static
114809885543Smrg	  fi
114909885543Smrg	  prefer_static_libs=yes
115009885543Smrg	else
115109885543Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
115209885543Smrg	    dlopen_self=$dlopen_self_static
115309885543Smrg	  fi
115409885543Smrg	  prefer_static_libs=built
115509885543Smrg	fi
115609885543Smrg	build_libtool_libs=no
115709885543Smrg	build_old_libs=yes
115809885543Smrg	break
115909885543Smrg	;;
116009885543Smrg      esac
116109885543Smrg    done
116209885543Smrg
116309885543Smrg    # See if our shared archives depend on static archives.
116409885543Smrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
116509885543Smrg
116609885543Smrg    # Go through the arguments, transforming them on the way.
116709885543Smrg    while test "$#" -gt 0; do
116809885543Smrg      arg="$1"
116909885543Smrg      shift
117009885543Smrg      case $arg in
117109885543Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
117209885543Smrg	qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test
117309885543Smrg	;;
117409885543Smrg      *) qarg=$arg ;;
117509885543Smrg      esac
117609885543Smrg      libtool_args="$libtool_args $qarg"
117709885543Smrg
117809885543Smrg      # If the previous option needs an argument, assign it.
117909885543Smrg      if test -n "$prev"; then
118009885543Smrg	case $prev in
118109885543Smrg	output)
118209885543Smrg	  compile_command="$compile_command @OUTPUT@"
118309885543Smrg	  finalize_command="$finalize_command @OUTPUT@"
118409885543Smrg	  ;;
118509885543Smrg	esac
118609885543Smrg
118709885543Smrg	case $prev in
118809885543Smrg	dlfiles|dlprefiles)
118909885543Smrg	  if test "$preload" = no; then
119009885543Smrg	    # Add the symbol object into the linking commands.
119109885543Smrg	    compile_command="$compile_command @SYMFILE@"
119209885543Smrg	    finalize_command="$finalize_command @SYMFILE@"
119309885543Smrg	    preload=yes
119409885543Smrg	  fi
119509885543Smrg	  case $arg in
119609885543Smrg	  *.la | *.lo) ;;  # We handle these cases below.
119709885543Smrg	  force)
119809885543Smrg	    if test "$dlself" = no; then
119909885543Smrg	      dlself=needless
120009885543Smrg	      export_dynamic=yes
120109885543Smrg	    fi
120209885543Smrg	    prev=
120309885543Smrg	    continue
120409885543Smrg	    ;;
120509885543Smrg	  self)
120609885543Smrg	    if test "$prev" = dlprefiles; then
120709885543Smrg	      dlself=yes
120809885543Smrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
120909885543Smrg	      dlself=yes
121009885543Smrg	    else
121109885543Smrg	      dlself=needless
121209885543Smrg	      export_dynamic=yes
121309885543Smrg	    fi
121409885543Smrg	    prev=
121509885543Smrg	    continue
121609885543Smrg	    ;;
121709885543Smrg	  *)
121809885543Smrg	    if test "$prev" = dlfiles; then
121909885543Smrg	      dlfiles="$dlfiles $arg"
122009885543Smrg	    else
122109885543Smrg	      dlprefiles="$dlprefiles $arg"
122209885543Smrg	    fi
122309885543Smrg	    prev=
122409885543Smrg	    continue
122509885543Smrg	    ;;
122609885543Smrg	  esac
122709885543Smrg	  ;;
122809885543Smrg	expsyms)
122909885543Smrg	  export_symbols="$arg"
123009885543Smrg	  if test ! -f "$arg"; then
123109885543Smrg	    $echo "$modename: symbol file \`$arg' does not exist"
123209885543Smrg	    exit $EXIT_FAILURE
123309885543Smrg	  fi
123409885543Smrg	  prev=
123509885543Smrg	  continue
123609885543Smrg	  ;;
123709885543Smrg	expsyms_regex)
123809885543Smrg	  export_symbols_regex="$arg"
123909885543Smrg	  prev=
124009885543Smrg	  continue
124109885543Smrg	  ;;
124209885543Smrg	inst_prefix)
124309885543Smrg	  inst_prefix_dir="$arg"
124409885543Smrg	  prev=
124509885543Smrg	  continue
124609885543Smrg	  ;;
124709885543Smrg	precious_regex)
124809885543Smrg	  precious_files_regex="$arg"
124909885543Smrg	  prev=
125009885543Smrg	  continue
125109885543Smrg	  ;;
125209885543Smrg	release)
125309885543Smrg	  release="-$arg"
125409885543Smrg	  prev=
125509885543Smrg	  continue
125609885543Smrg	  ;;
125709885543Smrg	objectlist)
125809885543Smrg	  if test -f "$arg"; then
125909885543Smrg	    save_arg=$arg
126009885543Smrg	    moreargs=
126109885543Smrg	    for fil in `cat $save_arg`
126209885543Smrg	    do
126309885543Smrg#	      moreargs="$moreargs $fil"
126409885543Smrg	      arg=$fil
126509885543Smrg	      # A libtool-controlled object.
126609885543Smrg
126709885543Smrg	      # Check to see that this really is a libtool object.
126809885543Smrg	      if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
126909885543Smrg		pic_object=
127009885543Smrg		non_pic_object=
127109885543Smrg
127209885543Smrg		# Read the .lo file
127309885543Smrg		# If there is no directory component, then add one.
127409885543Smrg		case $arg in
127509885543Smrg		*/* | *\\*) . $arg ;;
127609885543Smrg		*) . ./$arg ;;
127709885543Smrg		esac
127809885543Smrg
127909885543Smrg		if test -z "$pic_object" || \
128009885543Smrg		   test -z "$non_pic_object" ||
128109885543Smrg		   test "$pic_object" = none && \
128209885543Smrg		   test "$non_pic_object" = none; then
128309885543Smrg		  $echo "$modename: cannot find name of object for \`$arg'" 1>&2
128409885543Smrg		  exit $EXIT_FAILURE
128509885543Smrg		fi
128609885543Smrg
128709885543Smrg		# Extract subdirectory from the argument.
128809885543Smrg		xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
128909885543Smrg		if test "X$xdir" = "X$arg"; then
129009885543Smrg		  xdir=
129109885543Smrg		else
129209885543Smrg		  xdir="$xdir/"
129309885543Smrg		fi
129409885543Smrg
129509885543Smrg		if test "$pic_object" != none; then
129609885543Smrg		  # Prepend the subdirectory the object is found in.
129709885543Smrg		  pic_object="$xdir$pic_object"
129809885543Smrg
129909885543Smrg		  if test "$prev" = dlfiles; then
130009885543Smrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
130109885543Smrg		      dlfiles="$dlfiles $pic_object"
130209885543Smrg		      prev=
130309885543Smrg		      continue
130409885543Smrg		    else
130509885543Smrg		      # If libtool objects are unsupported, then we need to preload.
130609885543Smrg		      prev=dlprefiles
130709885543Smrg		    fi
130809885543Smrg		  fi
130909885543Smrg
131009885543Smrg		  # CHECK ME:  I think I busted this.  -Ossama
131109885543Smrg		  if test "$prev" = dlprefiles; then
131209885543Smrg		    # Preload the old-style object.
131309885543Smrg		    dlprefiles="$dlprefiles $pic_object"
131409885543Smrg		    prev=
131509885543Smrg		  fi
131609885543Smrg
131709885543Smrg		  # A PIC object.
131809885543Smrg		  libobjs="$libobjs $pic_object"
131909885543Smrg		  arg="$pic_object"
132009885543Smrg		fi
132109885543Smrg
132209885543Smrg		# Non-PIC object.
132309885543Smrg		if test "$non_pic_object" != none; then
132409885543Smrg		  # Prepend the subdirectory the object is found in.
132509885543Smrg		  non_pic_object="$xdir$non_pic_object"
132609885543Smrg
132709885543Smrg		  # A standard non-PIC object
132809885543Smrg		  non_pic_objects="$non_pic_objects $non_pic_object"
132909885543Smrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
133009885543Smrg		    arg="$non_pic_object"
133109885543Smrg		  fi
133209885543Smrg		else
133309885543Smrg		  # If the PIC object exists, use it instead.
133409885543Smrg		  # $xdir was prepended to $pic_object above.
133509885543Smrg		  non_pic_object="$pic_object"
133609885543Smrg		  non_pic_objects="$non_pic_objects $non_pic_object"
133709885543Smrg		fi
133809885543Smrg	      else
133909885543Smrg		# Only an error if not doing a dry-run.
134009885543Smrg		if test -z "$run"; then
134109885543Smrg		  $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
134209885543Smrg		  exit $EXIT_FAILURE
134309885543Smrg		else
134409885543Smrg		  # Dry-run case.
134509885543Smrg
134609885543Smrg		  # Extract subdirectory from the argument.
134709885543Smrg		  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
134809885543Smrg		  if test "X$xdir" = "X$arg"; then
134909885543Smrg		    xdir=
135009885543Smrg		  else
135109885543Smrg		    xdir="$xdir/"
135209885543Smrg		  fi
135309885543Smrg
135409885543Smrg		  pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
135509885543Smrg		  non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
135609885543Smrg		  libobjs="$libobjs $pic_object"
135709885543Smrg		  non_pic_objects="$non_pic_objects $non_pic_object"
135809885543Smrg		fi
135909885543Smrg	      fi
136009885543Smrg	    done
136109885543Smrg	  else
136209885543Smrg	    $echo "$modename: link input file \`$save_arg' does not exist"
136309885543Smrg	    exit $EXIT_FAILURE
136409885543Smrg	  fi
136509885543Smrg	  arg=$save_arg
136609885543Smrg	  prev=
136709885543Smrg	  continue
136809885543Smrg	  ;;
136909885543Smrg	rpath | xrpath)
137009885543Smrg	  # We need an absolute path.
137109885543Smrg	  case $arg in
137209885543Smrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
137309885543Smrg	  *)
137409885543Smrg	    $echo "$modename: only absolute run-paths are allowed" 1>&2
137509885543Smrg	    exit $EXIT_FAILURE
137609885543Smrg	    ;;
137709885543Smrg	  esac
137809885543Smrg	  if test "$prev" = rpath; then
137909885543Smrg	    case "$rpath " in
138009885543Smrg	    *" $arg "*) ;;
138109885543Smrg	    *) rpath="$rpath $arg" ;;
138209885543Smrg	    esac
138309885543Smrg	  else
138409885543Smrg	    case "$xrpath " in
138509885543Smrg	    *" $arg "*) ;;
138609885543Smrg	    *) xrpath="$xrpath $arg" ;;
138709885543Smrg	    esac
138809885543Smrg	  fi
138909885543Smrg	  prev=
139009885543Smrg	  continue
139109885543Smrg	  ;;
139209885543Smrg	xcompiler)
139309885543Smrg	  compiler_flags="$compiler_flags $qarg"
139409885543Smrg	  prev=
139509885543Smrg	  compile_command="$compile_command $qarg"
139609885543Smrg	  finalize_command="$finalize_command $qarg"
139709885543Smrg	  continue
139809885543Smrg	  ;;
139909885543Smrg	xlinker)
140009885543Smrg	  linker_flags="$linker_flags $qarg"
140109885543Smrg	  compiler_flags="$compiler_flags $wl$qarg"
140209885543Smrg	  prev=
140309885543Smrg	  compile_command="$compile_command $wl$qarg"
140409885543Smrg	  finalize_command="$finalize_command $wl$qarg"
140509885543Smrg	  continue
140609885543Smrg	  ;;
140709885543Smrg	xcclinker)
140809885543Smrg	  linker_flags="$linker_flags $qarg"
140909885543Smrg	  compiler_flags="$compiler_flags $qarg"
141009885543Smrg	  prev=
141109885543Smrg	  compile_command="$compile_command $qarg"
141209885543Smrg	  finalize_command="$finalize_command $qarg"
141309885543Smrg	  continue
141409885543Smrg	  ;;
141509885543Smrg	shrext)
141609885543Smrg  	  shrext_cmds="$arg"
141709885543Smrg	  prev=
141809885543Smrg	  continue
141909885543Smrg	  ;;
142009885543Smrg	darwin_framework|darwin_framework_skip)
142109885543Smrg	  test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg"
142209885543Smrg	  compile_command="$compile_command $arg"
142309885543Smrg	  finalize_command="$finalize_command $arg"
142409885543Smrg	  prev=
142509885543Smrg	  continue
142609885543Smrg	  ;;
142709885543Smrg	*)
142809885543Smrg	  eval "$prev=\"\$arg\""
142909885543Smrg	  prev=
143009885543Smrg	  continue
143109885543Smrg	  ;;
143209885543Smrg	esac
143309885543Smrg      fi # test -n "$prev"
143409885543Smrg
143509885543Smrg      prevarg="$arg"
143609885543Smrg
143709885543Smrg      case $arg in
143809885543Smrg      -all-static)
143909885543Smrg	if test -n "$link_static_flag"; then
144009885543Smrg	  compile_command="$compile_command $link_static_flag"
144109885543Smrg	  finalize_command="$finalize_command $link_static_flag"
144209885543Smrg	fi
144309885543Smrg	continue
144409885543Smrg	;;
144509885543Smrg
144609885543Smrg      -allow-undefined)
144709885543Smrg	# FIXME: remove this flag sometime in the future.
144809885543Smrg	$echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
144909885543Smrg	continue
145009885543Smrg	;;
145109885543Smrg
145209885543Smrg      -avoid-version)
145309885543Smrg	avoid_version=yes
145409885543Smrg	continue
145509885543Smrg	;;
145609885543Smrg
145709885543Smrg      -dlopen)
145809885543Smrg	prev=dlfiles
145909885543Smrg	continue
146009885543Smrg	;;
146109885543Smrg
146209885543Smrg      -dlpreopen)
146309885543Smrg	prev=dlprefiles
146409885543Smrg	continue
146509885543Smrg	;;
146609885543Smrg
146709885543Smrg      -export-dynamic)
146809885543Smrg	export_dynamic=yes
146909885543Smrg	continue
147009885543Smrg	;;
147109885543Smrg
147209885543Smrg      -export-symbols | -export-symbols-regex)
147309885543Smrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
147409885543Smrg	  $echo "$modename: more than one -exported-symbols argument is not allowed"
147509885543Smrg	  exit $EXIT_FAILURE
147609885543Smrg	fi
147709885543Smrg	if test "X$arg" = "X-export-symbols"; then
147809885543Smrg	  prev=expsyms
147909885543Smrg	else
148009885543Smrg	  prev=expsyms_regex
148109885543Smrg	fi
148209885543Smrg	continue
148309885543Smrg	;;
148409885543Smrg
148509885543Smrg      -framework|-arch|-isysroot)
148609885543Smrg	case " $CC " in
148709885543Smrg	  *" ${arg} ${1} "* | *" ${arg}	${1} "*) 
148809885543Smrg		prev=darwin_framework_skip ;;
148909885543Smrg	  *) compiler_flags="$compiler_flags $arg"
149009885543Smrg	     prev=darwin_framework ;;
149109885543Smrg	esac
149209885543Smrg	compile_command="$compile_command $arg"
149309885543Smrg	finalize_command="$finalize_command $arg"
149409885543Smrg	continue
149509885543Smrg	;;
149609885543Smrg
149709885543Smrg      -inst-prefix-dir)
149809885543Smrg	prev=inst_prefix
149909885543Smrg	continue
150009885543Smrg	;;
150109885543Smrg
150209885543Smrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
150309885543Smrg      # so, if we see these flags be careful not to treat them like -L
150409885543Smrg      -L[A-Z][A-Z]*:*)
150509885543Smrg	case $with_gcc/$host in
150609885543Smrg	no/*-*-irix* | /*-*-irix*)
150709885543Smrg	  compile_command="$compile_command $arg"
150809885543Smrg	  finalize_command="$finalize_command $arg"
150909885543Smrg	  ;;
151009885543Smrg	esac
151109885543Smrg	continue
151209885543Smrg	;;
151309885543Smrg
151409885543Smrg      -L*)
151509885543Smrg	dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
151609885543Smrg	# We need an absolute path.
151709885543Smrg	case $dir in
151809885543Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
151909885543Smrg	*)
152009885543Smrg	  absdir=`cd "$dir" && pwd`
152109885543Smrg	  if test -z "$absdir"; then
152209885543Smrg	    $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
152309885543Smrg	    absdir="$dir"
152409885543Smrg	    notinst_path="$notinst_path $dir"
152509885543Smrg	  fi
152609885543Smrg	  dir="$absdir"
152709885543Smrg	  ;;
152809885543Smrg	esac
152909885543Smrg	case "$deplibs " in
153009885543Smrg	*" -L$dir "*) ;;
153109885543Smrg	*)
153209885543Smrg	  deplibs="$deplibs -L$dir"
153309885543Smrg	  lib_search_path="$lib_search_path $dir"
153409885543Smrg	  ;;
153509885543Smrg	esac
153609885543Smrg	case $host in
153709885543Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
153809885543Smrg	  testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'`
153909885543Smrg	  case :$dllsearchpath: in
154009885543Smrg	  *":$dir:"*) ;;
154109885543Smrg	  *) dllsearchpath="$dllsearchpath:$dir";;
154209885543Smrg	  esac
154309885543Smrg	  case :$dllsearchpath: in
154409885543Smrg	  *":$testbindir:"*) ;;
154509885543Smrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
154609885543Smrg	  esac
154709885543Smrg	  ;;
154809885543Smrg	esac
154909885543Smrg	continue
155009885543Smrg	;;
155109885543Smrg
155209885543Smrg      -l*)
155309885543Smrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
155409885543Smrg	  case $host in
155509885543Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*)
155609885543Smrg	    # These systems don't actually have a C or math library (as such)
155709885543Smrg	    continue
155809885543Smrg	    ;;
155909885543Smrg	  *-*-os2*)
156009885543Smrg	    # These systems don't actually have a C library (as such)
156109885543Smrg	    test "X$arg" = "X-lc" && continue
156209885543Smrg	    ;;
156309885543Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
156409885543Smrg	    # Do not include libc due to us having libc/libc_r.
156509885543Smrg	    test "X$arg" = "X-lc" && continue
156609885543Smrg	    ;;
156709885543Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
156809885543Smrg	    # Rhapsody C and math libraries are in the System framework
156909885543Smrg	    deplibs="$deplibs -framework System"
157009885543Smrg	    continue
157109885543Smrg	    ;;
157209885543Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
157309885543Smrg	    # Causes problems with __ctype
157409885543Smrg	    test "X$arg" = "X-lc" && continue
157509885543Smrg	    ;;
157609885543Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
157709885543Smrg	    # Compiler inserts libc in the correct place for threads to work
157809885543Smrg	    test "X$arg" = "X-lc" && continue
157909885543Smrg	    ;;
158009885543Smrg	  esac
158109885543Smrg	elif test "X$arg" = "X-lc_r"; then
158209885543Smrg	 case $host in
158309885543Smrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
158409885543Smrg	   # Do not include libc_r directly, use -pthread flag.
158509885543Smrg	   continue
158609885543Smrg	   ;;
158709885543Smrg	 esac
158809885543Smrg	fi
158909885543Smrg	deplibs="$deplibs $arg"
159009885543Smrg	continue
159109885543Smrg	;;
159209885543Smrg
159309885543Smrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
159409885543Smrg      # classes, name mangling, and exception handling.
159509885543Smrg      -model)
159609885543Smrg	compile_command="$compile_command $arg"
159709885543Smrg	compiler_flags="$compiler_flags $arg"
159809885543Smrg	finalize_command="$finalize_command $arg"
159909885543Smrg	prev=xcompiler
160009885543Smrg	continue
160109885543Smrg	;;
160209885543Smrg
160309885543Smrg     -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
160409885543Smrg	compiler_flags="$compiler_flags $arg"
160509885543Smrg	compile_command="$compile_command $arg"
160609885543Smrg	finalize_command="$finalize_command $arg"
160709885543Smrg	continue
160809885543Smrg	;;
160909885543Smrg
161009885543Smrg      -module)
161109885543Smrg	module=yes
161209885543Smrg	continue
161309885543Smrg	;;
161409885543Smrg
161509885543Smrg      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
161609885543Smrg      # -r[0-9][0-9]* specifies the processor on the SGI compiler
161709885543Smrg      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
161809885543Smrg      # +DA*, +DD* enable 64-bit mode on the HP compiler
161909885543Smrg      # -q* pass through compiler args for the IBM compiler
162009885543Smrg      # -m* pass through architecture-specific compiler args for GCC
162109885543Smrg      # -m*, -t[45]*, -txscale* pass through architecture-specific
162209885543Smrg      # compiler args for GCC
162309885543Smrg      # -pg pass through profiling flag for GCC
162409885543Smrg      # @file GCC response files
162509885543Smrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*|-pg| \
162609885543Smrg      -t[45]*|-txscale*|@*)
162709885543Smrg
162809885543Smrg	# Unknown arguments in both finalize_command and compile_command need
162909885543Smrg	# to be aesthetically quoted because they are evaled later.
163009885543Smrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
163109885543Smrg	case $arg in
163209885543Smrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
163309885543Smrg	  arg="\"$arg\""
163409885543Smrg	  ;;
163509885543Smrg	esac
163609885543Smrg        compile_command="$compile_command $arg"
163709885543Smrg        finalize_command="$finalize_command $arg"
163809885543Smrg        compiler_flags="$compiler_flags $arg"
163909885543Smrg        continue
164009885543Smrg        ;;
164109885543Smrg
164209885543Smrg      -shrext)
164309885543Smrg	prev=shrext
164409885543Smrg	continue
164509885543Smrg	;;
164609885543Smrg
164709885543Smrg      -no-fast-install)
164809885543Smrg	fast_install=no
164909885543Smrg	continue
165009885543Smrg	;;
165109885543Smrg
165209885543Smrg      -no-install)
165309885543Smrg	case $host in
165409885543Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
165509885543Smrg	  # The PATH hackery in wrapper scripts is required on Windows
165609885543Smrg	  # in order for the loader to find any dlls it needs.
165709885543Smrg	  $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2
165809885543Smrg	  $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2
165909885543Smrg	  fast_install=no
166009885543Smrg	  ;;
166109885543Smrg	*) no_install=yes ;;
166209885543Smrg	esac
166309885543Smrg	continue
166409885543Smrg	;;
166509885543Smrg
166609885543Smrg      -no-undefined)
166709885543Smrg	allow_undefined=no
166809885543Smrg	continue
166909885543Smrg	;;
167009885543Smrg
167109885543Smrg      -objectlist)
167209885543Smrg	prev=objectlist
167309885543Smrg	continue
167409885543Smrg	;;
167509885543Smrg
167609885543Smrg      -o) prev=output ;;
167709885543Smrg
167809885543Smrg      -precious-files-regex)
167909885543Smrg	prev=precious_regex
168009885543Smrg	continue
168109885543Smrg	;;
168209885543Smrg
168309885543Smrg      -release)
168409885543Smrg	prev=release
168509885543Smrg	continue
168609885543Smrg	;;
168709885543Smrg
168809885543Smrg      -rpath)
168909885543Smrg	prev=rpath
169009885543Smrg	continue
169109885543Smrg	;;
169209885543Smrg
169309885543Smrg      -R)
169409885543Smrg	prev=xrpath
169509885543Smrg	continue
169609885543Smrg	;;
169709885543Smrg
169809885543Smrg      -R*)
169909885543Smrg	dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
170009885543Smrg	# We need an absolute path.
170109885543Smrg	case $dir in
170209885543Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
170309885543Smrg	*)
170409885543Smrg	  $echo "$modename: only absolute run-paths are allowed" 1>&2
170509885543Smrg	  exit $EXIT_FAILURE
170609885543Smrg	  ;;
170709885543Smrg	esac
170809885543Smrg	case "$xrpath " in
170909885543Smrg	*" $dir "*) ;;
171009885543Smrg	*) xrpath="$xrpath $dir" ;;
171109885543Smrg	esac
171209885543Smrg	continue
171309885543Smrg	;;
171409885543Smrg
171509885543Smrg      -static)
171609885543Smrg	# The effects of -static are defined in a previous loop.
171709885543Smrg	# We used to do the same as -all-static on platforms that
171809885543Smrg	# didn't have a PIC flag, but the assumption that the effects
171909885543Smrg	# would be equivalent was wrong.  It would break on at least
172009885543Smrg	# Digital Unix and AIX.
172109885543Smrg	continue
172209885543Smrg	;;
172309885543Smrg
172409885543Smrg      -thread-safe)
172509885543Smrg	thread_safe=yes
172609885543Smrg	continue
172709885543Smrg	;;
172809885543Smrg
172909885543Smrg      -version-info)
173009885543Smrg	prev=vinfo
173109885543Smrg	continue
173209885543Smrg	;;
173309885543Smrg      -version-number)
173409885543Smrg	prev=vinfo
173509885543Smrg	vinfo_number=yes
173609885543Smrg	continue
173709885543Smrg	;;
173809885543Smrg
173909885543Smrg      -Wc,*)
174009885543Smrg	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'`
174109885543Smrg	arg=
174209885543Smrg	save_ifs="$IFS"; IFS=','
174309885543Smrg	for flag in $args; do
174409885543Smrg	  IFS="$save_ifs"
174509885543Smrg	  case $flag in
174609885543Smrg	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
174709885543Smrg	    flag="\"$flag\""
174809885543Smrg	    ;;
174909885543Smrg	  esac
175009885543Smrg	  arg="$arg $wl$flag"
175109885543Smrg	  compiler_flags="$compiler_flags $flag"
175209885543Smrg	done
175309885543Smrg	IFS="$save_ifs"
175409885543Smrg	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
175509885543Smrg	;;
175609885543Smrg
175709885543Smrg      -Wl,*)
175809885543Smrg	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'`
175909885543Smrg	arg=
176009885543Smrg	save_ifs="$IFS"; IFS=','
176109885543Smrg	for flag in $args; do
176209885543Smrg	  IFS="$save_ifs"
176309885543Smrg	  case $flag in
176409885543Smrg	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
176509885543Smrg	    flag="\"$flag\""
176609885543Smrg	    ;;
176709885543Smrg	  esac
176809885543Smrg	  arg="$arg $wl$flag"
176909885543Smrg	  compiler_flags="$compiler_flags $wl$flag"
177009885543Smrg	  linker_flags="$linker_flags $flag"
177109885543Smrg	done
177209885543Smrg	IFS="$save_ifs"
177309885543Smrg	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
177409885543Smrg	;;
177509885543Smrg
177609885543Smrg      -Xcompiler)
177709885543Smrg	prev=xcompiler
177809885543Smrg	continue
177909885543Smrg	;;
178009885543Smrg
178109885543Smrg      -Xlinker)
178209885543Smrg	prev=xlinker
178309885543Smrg	continue
178409885543Smrg	;;
178509885543Smrg
178609885543Smrg      -XCClinker)
178709885543Smrg	prev=xcclinker
178809885543Smrg	continue
178909885543Smrg	;;
179009885543Smrg
179109885543Smrg      # Some other compiler flag.
179209885543Smrg      -* | +*)
179309885543Smrg	# Unknown arguments in both finalize_command and compile_command need
179409885543Smrg	# to be aesthetically quoted because they are evaled later.
179509885543Smrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
179609885543Smrg	case $arg in
179709885543Smrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
179809885543Smrg	  arg="\"$arg\""
179909885543Smrg	  ;;
180009885543Smrg	esac
180109885543Smrg	;;
180209885543Smrg
180309885543Smrg      *.$objext)
180409885543Smrg	# A standard object.
180509885543Smrg	objs="$objs $arg"
180609885543Smrg	;;
180709885543Smrg
180809885543Smrg      *.lo)
180909885543Smrg	# A libtool-controlled object.
181009885543Smrg
181109885543Smrg	# Check to see that this really is a libtool object.
181209885543Smrg	if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
181309885543Smrg	  pic_object=
181409885543Smrg	  non_pic_object=
181509885543Smrg
181609885543Smrg	  # Read the .lo file
181709885543Smrg	  # If there is no directory component, then add one.
181809885543Smrg	  case $arg in
181909885543Smrg	  */* | *\\*) . $arg ;;
182009885543Smrg	  *) . ./$arg ;;
182109885543Smrg	  esac
182209885543Smrg
182309885543Smrg	  if test -z "$pic_object" || \
182409885543Smrg	     test -z "$non_pic_object" ||
182509885543Smrg	     test "$pic_object" = none && \
182609885543Smrg	     test "$non_pic_object" = none; then
182709885543Smrg	    $echo "$modename: cannot find name of object for \`$arg'" 1>&2
182809885543Smrg	    exit $EXIT_FAILURE
182909885543Smrg	  fi
183009885543Smrg
183109885543Smrg	  # Extract subdirectory from the argument.
183209885543Smrg	  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
183309885543Smrg	  if test "X$xdir" = "X$arg"; then
183409885543Smrg	    xdir=
183509885543Smrg 	  else
183609885543Smrg	    xdir="$xdir/"
183709885543Smrg	  fi
183809885543Smrg
183909885543Smrg	  if test "$pic_object" != none; then
184009885543Smrg	    # Prepend the subdirectory the object is found in.
184109885543Smrg	    pic_object="$xdir$pic_object"
184209885543Smrg
184309885543Smrg	    if test "$prev" = dlfiles; then
184409885543Smrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
184509885543Smrg		dlfiles="$dlfiles $pic_object"
184609885543Smrg		prev=
184709885543Smrg		continue
184809885543Smrg	      else
184909885543Smrg		# If libtool objects are unsupported, then we need to preload.
185009885543Smrg		prev=dlprefiles
185109885543Smrg	      fi
185209885543Smrg	    fi
185309885543Smrg
185409885543Smrg	    # CHECK ME:  I think I busted this.  -Ossama
185509885543Smrg	    if test "$prev" = dlprefiles; then
185609885543Smrg	      # Preload the old-style object.
185709885543Smrg	      dlprefiles="$dlprefiles $pic_object"
185809885543Smrg	      prev=
185909885543Smrg	    fi
186009885543Smrg
186109885543Smrg	    # A PIC object.
186209885543Smrg	    libobjs="$libobjs $pic_object"
186309885543Smrg	    arg="$pic_object"
186409885543Smrg	  fi
186509885543Smrg
186609885543Smrg	  # Non-PIC object.
186709885543Smrg	  if test "$non_pic_object" != none; then
186809885543Smrg	    # Prepend the subdirectory the object is found in.
186909885543Smrg	    non_pic_object="$xdir$non_pic_object"
187009885543Smrg
187109885543Smrg	    # A standard non-PIC object
187209885543Smrg	    non_pic_objects="$non_pic_objects $non_pic_object"
187309885543Smrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
187409885543Smrg	      arg="$non_pic_object"
187509885543Smrg	    fi
187609885543Smrg	  else
187709885543Smrg	    # If the PIC object exists, use it instead.
187809885543Smrg	    # $xdir was prepended to $pic_object above.
187909885543Smrg	    non_pic_object="$pic_object"
188009885543Smrg	    non_pic_objects="$non_pic_objects $non_pic_object"
188109885543Smrg	  fi
188209885543Smrg	else
188309885543Smrg	  # Only an error if not doing a dry-run.
188409885543Smrg	  if test -z "$run"; then
188509885543Smrg	    $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
188609885543Smrg	    exit $EXIT_FAILURE
188709885543Smrg	  else
188809885543Smrg	    # Dry-run case.
188909885543Smrg
189009885543Smrg	    # Extract subdirectory from the argument.
189109885543Smrg	    xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
189209885543Smrg	    if test "X$xdir" = "X$arg"; then
189309885543Smrg	      xdir=
189409885543Smrg	    else
189509885543Smrg	      xdir="$xdir/"
189609885543Smrg	    fi
189709885543Smrg
189809885543Smrg	    pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
189909885543Smrg	    non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
190009885543Smrg	    libobjs="$libobjs $pic_object"
190109885543Smrg	    non_pic_objects="$non_pic_objects $non_pic_object"
190209885543Smrg	  fi
190309885543Smrg	fi
190409885543Smrg	;;
190509885543Smrg
190609885543Smrg      *.$libext)
190709885543Smrg	# An archive.
190809885543Smrg	deplibs="$deplibs $arg"
190909885543Smrg	old_deplibs="$old_deplibs $arg"
191009885543Smrg	continue
191109885543Smrg	;;
191209885543Smrg
191309885543Smrg      *.la)
191409885543Smrg	# A libtool-controlled library.
191509885543Smrg
191609885543Smrg	if test "$prev" = dlfiles; then
191709885543Smrg	  # This library was specified with -dlopen.
191809885543Smrg	  dlfiles="$dlfiles $arg"
191909885543Smrg	  prev=
192009885543Smrg	elif test "$prev" = dlprefiles; then
192109885543Smrg	  # The library was specified with -dlpreopen.
192209885543Smrg	  dlprefiles="$dlprefiles $arg"
192309885543Smrg	  prev=
192409885543Smrg	else
192509885543Smrg	  deplibs="$deplibs $arg"
192609885543Smrg	fi
192709885543Smrg	continue
192809885543Smrg	;;
192909885543Smrg
193009885543Smrg      # Some other compiler argument.
193109885543Smrg      *)
193209885543Smrg	# Unknown arguments in both finalize_command and compile_command need
193309885543Smrg	# to be aesthetically quoted because they are evaled later.
193409885543Smrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
193509885543Smrg	case $arg in
193609885543Smrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
193709885543Smrg	  arg="\"$arg\""
193809885543Smrg	  ;;
193909885543Smrg	esac
194009885543Smrg	;;
194109885543Smrg      esac # arg
194209885543Smrg
194309885543Smrg      # Now actually substitute the argument into the commands.
194409885543Smrg      if test -n "$arg"; then
194509885543Smrg	compile_command="$compile_command $arg"
194609885543Smrg	finalize_command="$finalize_command $arg"
194709885543Smrg      fi
194809885543Smrg    done # argument parsing loop
194909885543Smrg
195009885543Smrg    if test -n "$prev"; then
195109885543Smrg      $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
195209885543Smrg      $echo "$help" 1>&2
195309885543Smrg      exit $EXIT_FAILURE
195409885543Smrg    fi
195509885543Smrg
195609885543Smrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
195709885543Smrg      eval arg=\"$export_dynamic_flag_spec\"
195809885543Smrg      compile_command="$compile_command $arg"
195909885543Smrg      finalize_command="$finalize_command $arg"
196009885543Smrg    fi
196109885543Smrg
196209885543Smrg    oldlibs=
196309885543Smrg    # calculate the name of the file, without its directory
196409885543Smrg    outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
196509885543Smrg    libobjs_save="$libobjs"
196609885543Smrg
196709885543Smrg    if test -n "$shlibpath_var"; then
196809885543Smrg      # get the directories listed in $shlibpath_var
196909885543Smrg      eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
197009885543Smrg    else
197109885543Smrg      shlib_search_path=
197209885543Smrg    fi
197309885543Smrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
197409885543Smrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
197509885543Smrg
197609885543Smrg    output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
197709885543Smrg    if test "X$output_objdir" = "X$output"; then
197809885543Smrg      output_objdir="$objdir"
197909885543Smrg    else
198009885543Smrg      output_objdir="$output_objdir/$objdir"
198109885543Smrg    fi
198209885543Smrg    # Create the object directory.
198309885543Smrg    if test ! -d "$output_objdir"; then
198409885543Smrg      $show "$mkdir $output_objdir"
198509885543Smrg      $run $mkdir $output_objdir
198609885543Smrg      exit_status=$?
198709885543Smrg      if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then
198809885543Smrg	exit $exit_status
198909885543Smrg      fi
199009885543Smrg    fi
199109885543Smrg
199209885543Smrg    # Determine the type of output
199309885543Smrg    case $output in
199409885543Smrg    "")
199509885543Smrg      $echo "$modename: you must specify an output file" 1>&2
199609885543Smrg      $echo "$help" 1>&2
199709885543Smrg      exit $EXIT_FAILURE
199809885543Smrg      ;;
199909885543Smrg    *.$libext) linkmode=oldlib ;;
200009885543Smrg    *.lo | *.$objext) linkmode=obj ;;
200109885543Smrg    *.la) linkmode=lib ;;
200209885543Smrg    *) linkmode=prog ;; # Anything else should be a program.
200309885543Smrg    esac
200409885543Smrg
200509885543Smrg    case $host in
200609885543Smrg    *cygwin* | *mingw* | *pw32*)
200709885543Smrg      # don't eliminate duplications in $postdeps and $predeps
200809885543Smrg      duplicate_compiler_generated_deps=yes
200909885543Smrg      ;;
201009885543Smrg    *)
201109885543Smrg      duplicate_compiler_generated_deps=$duplicate_deps
201209885543Smrg      ;;
201309885543Smrg    esac
201409885543Smrg    specialdeplibs=
201509885543Smrg
201609885543Smrg    libs=
201709885543Smrg    # Find all interdependent deplibs by searching for libraries
201809885543Smrg    # that are linked more than once (e.g. -la -lb -la)
201909885543Smrg    for deplib in $deplibs; do
202009885543Smrg      if test "X$duplicate_deps" = "Xyes" ; then
202109885543Smrg	case "$libs " in
202209885543Smrg	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
202309885543Smrg	esac
202409885543Smrg      fi
202509885543Smrg      libs="$libs $deplib"
202609885543Smrg    done
202709885543Smrg
202809885543Smrg    if test "$linkmode" = lib; then
202909885543Smrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
203009885543Smrg
203109885543Smrg      # Compute libraries that are listed more than once in $predeps
203209885543Smrg      # $postdeps and mark them as special (i.e., whose duplicates are
203309885543Smrg      # not to be eliminated).
203409885543Smrg      pre_post_deps=
203509885543Smrg      if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then
203609885543Smrg	for pre_post_dep in $predeps $postdeps; do
203709885543Smrg	  case "$pre_post_deps " in
203809885543Smrg	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
203909885543Smrg	  esac
204009885543Smrg	  pre_post_deps="$pre_post_deps $pre_post_dep"
204109885543Smrg	done
204209885543Smrg      fi
204309885543Smrg      pre_post_deps=
204409885543Smrg    fi
204509885543Smrg
204609885543Smrg    deplibs=
204709885543Smrg    newdependency_libs=
204809885543Smrg    newlib_search_path=
204909885543Smrg    need_relink=no # whether we're linking any uninstalled libtool libraries
205009885543Smrg    notinst_deplibs= # not-installed libtool libraries
205109885543Smrg    case $linkmode in
205209885543Smrg    lib)
205309885543Smrg	passes="conv link"
205409885543Smrg	for file in $dlfiles $dlprefiles; do
205509885543Smrg	  case $file in
205609885543Smrg	  *.la) ;;
205709885543Smrg	  *)
205809885543Smrg	    $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2
205909885543Smrg	    exit $EXIT_FAILURE
206009885543Smrg	    ;;
206109885543Smrg	  esac
206209885543Smrg	done
206309885543Smrg	;;
206409885543Smrg    prog)
206509885543Smrg	compile_deplibs=
206609885543Smrg	finalize_deplibs=
206709885543Smrg	alldeplibs=no
206809885543Smrg	newdlfiles=
206909885543Smrg	newdlprefiles=
207009885543Smrg	passes="conv scan dlopen dlpreopen link"
207109885543Smrg	;;
207209885543Smrg    *)  passes="conv"
207309885543Smrg	;;
207409885543Smrg    esac
207509885543Smrg    for pass in $passes; do
207609885543Smrg      if test "$linkmode,$pass" = "lib,link" ||
207709885543Smrg	 test "$linkmode,$pass" = "prog,scan"; then
207809885543Smrg	libs="$deplibs"
207909885543Smrg	deplibs=
208009885543Smrg      fi
208109885543Smrg      if test "$linkmode" = prog; then
208209885543Smrg	case $pass in
208309885543Smrg	dlopen) libs="$dlfiles" ;;
208409885543Smrg	dlpreopen) libs="$dlprefiles" ;;
208509885543Smrg	link)
208609885543Smrg	  libs="$deplibs %DEPLIBS%"
208709885543Smrg	  test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
208809885543Smrg	  ;;
208909885543Smrg	esac
209009885543Smrg      fi
209109885543Smrg      if test "$pass" = dlopen; then
209209885543Smrg	# Collect dlpreopened libraries
209309885543Smrg	save_deplibs="$deplibs"
209409885543Smrg	deplibs=
209509885543Smrg      fi
209609885543Smrg      for deplib in $libs; do
209709885543Smrg	lib=
209809885543Smrg	found=no
209909885543Smrg	case $deplib in
210009885543Smrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
210109885543Smrg	  if test "$linkmode,$pass" = "prog,link"; then
210209885543Smrg	    compile_deplibs="$deplib $compile_deplibs"
210309885543Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
210409885543Smrg	  else
210509885543Smrg	    compiler_flags="$compiler_flags $deplib"
210609885543Smrg	  fi
210709885543Smrg	  continue
210809885543Smrg	  ;;
210909885543Smrg	-l*)
211009885543Smrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
211109885543Smrg	    $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2
211209885543Smrg	    continue
211309885543Smrg	  fi
211409885543Smrg	  name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
211509885543Smrg	  for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do
211609885543Smrg	    for search_ext in .la $std_shrext .so .a; do
211709885543Smrg	      # Search the libtool library
211809885543Smrg	      lib="$searchdir/lib${name}${search_ext}"
211909885543Smrg	      if test -f "$lib"; then
212009885543Smrg		if test "$search_ext" = ".la"; then
212109885543Smrg		  found=yes
212209885543Smrg		else
212309885543Smrg		  found=no
212409885543Smrg		fi
212509885543Smrg		break 2
212609885543Smrg	      fi
212709885543Smrg	    done
212809885543Smrg	  done
212909885543Smrg	  if test "$found" != yes; then
213009885543Smrg	    # deplib doesn't seem to be a libtool library
213109885543Smrg	    if test "$linkmode,$pass" = "prog,link"; then
213209885543Smrg	      compile_deplibs="$deplib $compile_deplibs"
213309885543Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
213409885543Smrg	    else
213509885543Smrg	      deplibs="$deplib $deplibs"
213609885543Smrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
213709885543Smrg	    fi
213809885543Smrg	    continue
213909885543Smrg	  else # deplib is a libtool library
214009885543Smrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
214109885543Smrg	    # We need to do some special things here, and not later.
214209885543Smrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
214309885543Smrg	      case " $predeps $postdeps " in
214409885543Smrg	      *" $deplib "*)
214509885543Smrg		if (${SED} -e '2q' $lib |
214609885543Smrg                    grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
214709885543Smrg		  library_names=
214809885543Smrg		  old_library=
214909885543Smrg		  case $lib in
215009885543Smrg		  */* | *\\*) . $lib ;;
215109885543Smrg		  *) . ./$lib ;;
215209885543Smrg		  esac
215309885543Smrg		  for l in $old_library $library_names; do
215409885543Smrg		    ll="$l"
215509885543Smrg		  done
215609885543Smrg		  if test "X$ll" = "X$old_library" ; then # only static version available
215709885543Smrg		    found=no
215809885543Smrg		    ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
215909885543Smrg		    test "X$ladir" = "X$lib" && ladir="."
216009885543Smrg		    lib=$ladir/$old_library
216109885543Smrg		    if test "$linkmode,$pass" = "prog,link"; then
216209885543Smrg		      compile_deplibs="$deplib $compile_deplibs"
216309885543Smrg		      finalize_deplibs="$deplib $finalize_deplibs"
216409885543Smrg		    else
216509885543Smrg		      deplibs="$deplib $deplibs"
216609885543Smrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
216709885543Smrg		    fi
216809885543Smrg		    continue
216909885543Smrg		  fi
217009885543Smrg		fi
217109885543Smrg	        ;;
217209885543Smrg	      *) ;;
217309885543Smrg	      esac
217409885543Smrg	    fi
217509885543Smrg	  fi
217609885543Smrg	  ;; # -l
217709885543Smrg	-L*)
217809885543Smrg	  case $linkmode in
217909885543Smrg	  lib)
218009885543Smrg	    deplibs="$deplib $deplibs"
218109885543Smrg	    test "$pass" = conv && continue
218209885543Smrg	    newdependency_libs="$deplib $newdependency_libs"
218309885543Smrg	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
218409885543Smrg	    ;;
218509885543Smrg	  prog)
218609885543Smrg	    if test "$pass" = conv; then
218709885543Smrg	      deplibs="$deplib $deplibs"
218809885543Smrg	      continue
218909885543Smrg	    fi
219009885543Smrg	    if test "$pass" = scan; then
219109885543Smrg	      deplibs="$deplib $deplibs"
219209885543Smrg	    else
219309885543Smrg	      compile_deplibs="$deplib $compile_deplibs"
219409885543Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
219509885543Smrg	    fi
219609885543Smrg	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
219709885543Smrg	    ;;
219809885543Smrg	  *)
219909885543Smrg	    $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2
220009885543Smrg	    ;;
220109885543Smrg	  esac # linkmode
220209885543Smrg	  continue
220309885543Smrg	  ;; # -L
220409885543Smrg	-R*)
220509885543Smrg	  if test "$pass" = link; then
220609885543Smrg	    dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
220709885543Smrg	    # Make sure the xrpath contains only unique directories.
220809885543Smrg	    case "$xrpath " in
220909885543Smrg	    *" $dir "*) ;;
221009885543Smrg	    *) xrpath="$xrpath $dir" ;;
221109885543Smrg	    esac
221209885543Smrg	  fi
221309885543Smrg	  deplibs="$deplib $deplibs"
221409885543Smrg	  continue
221509885543Smrg	  ;;
221609885543Smrg	*.la) lib="$deplib" ;;
221709885543Smrg	*.$libext)
221809885543Smrg	  if test "$pass" = conv; then
221909885543Smrg	    deplibs="$deplib $deplibs"
222009885543Smrg	    continue
222109885543Smrg	  fi
222209885543Smrg	  case $linkmode in
222309885543Smrg	  lib)
222409885543Smrg	    valid_a_lib=no
222509885543Smrg	    case $deplibs_check_method in
222609885543Smrg	      match_pattern*)
222709885543Smrg		set dummy $deplibs_check_method
222809885543Smrg	        match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
222909885543Smrg		if eval $echo \"$deplib\" 2>/dev/null \
223009885543Smrg		    | $SED 10q \
223109885543Smrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
223209885543Smrg		  valid_a_lib=yes
223309885543Smrg		fi
223409885543Smrg		;;
223509885543Smrg	      pass_all)
223609885543Smrg		valid_a_lib=yes
223709885543Smrg		;;
223809885543Smrg            esac
223909885543Smrg	    if test "$valid_a_lib" != yes; then
224009885543Smrg	      $echo
224109885543Smrg	      $echo "*** Warning: Trying to link with static lib archive $deplib."
224209885543Smrg	      $echo "*** I have the capability to make that library automatically link in when"
224309885543Smrg	      $echo "*** you link to this library.  But I can only do this if you have a"
224409885543Smrg	      $echo "*** shared version of the library, which you do not appear to have"
224509885543Smrg	      $echo "*** because the file extensions .$libext of this argument makes me believe"
224609885543Smrg	      $echo "*** that it is just a static archive that I should not used here."
224709885543Smrg	    else
224809885543Smrg	      $echo
224909885543Smrg	      $echo "*** Warning: Linking the shared library $output against the"
225009885543Smrg	      $echo "*** static library $deplib is not portable!"
225109885543Smrg	      deplibs="$deplib $deplibs"
225209885543Smrg	    fi
225309885543Smrg	    continue
225409885543Smrg	    ;;
225509885543Smrg	  prog)
225609885543Smrg	    if test "$pass" != link; then
225709885543Smrg	      deplibs="$deplib $deplibs"
225809885543Smrg	    else
225909885543Smrg	      compile_deplibs="$deplib $compile_deplibs"
226009885543Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
226109885543Smrg	    fi
226209885543Smrg	    continue
226309885543Smrg	    ;;
226409885543Smrg	  esac # linkmode
226509885543Smrg	  ;; # *.$libext
226609885543Smrg	*.lo | *.$objext)
226709885543Smrg	  if test "$pass" = conv; then
226809885543Smrg	    deplibs="$deplib $deplibs"
226909885543Smrg	  elif test "$linkmode" = prog; then
227009885543Smrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
227109885543Smrg	      # If there is no dlopen support or we're linking statically,
227209885543Smrg	      # we need to preload.
227309885543Smrg	      newdlprefiles="$newdlprefiles $deplib"
227409885543Smrg	      compile_deplibs="$deplib $compile_deplibs"
227509885543Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
227609885543Smrg	    else
227709885543Smrg	      newdlfiles="$newdlfiles $deplib"
227809885543Smrg	    fi
227909885543Smrg	  fi
228009885543Smrg	  continue
228109885543Smrg	  ;;
228209885543Smrg	%DEPLIBS%)
228309885543Smrg	  alldeplibs=yes
228409885543Smrg	  continue
228509885543Smrg	  ;;
228609885543Smrg	esac # case $deplib
228709885543Smrg	if test "$found" = yes || test -f "$lib"; then :
228809885543Smrg	else
228909885543Smrg	  $echo "$modename: cannot find the library \`$lib' or unhandled argument \`$deplib'" 1>&2
229009885543Smrg	  exit $EXIT_FAILURE
229109885543Smrg	fi
229209885543Smrg
229309885543Smrg	# Check to see that this really is a libtool archive.
229409885543Smrg	if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
229509885543Smrg	else
229609885543Smrg	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
229709885543Smrg	  exit $EXIT_FAILURE
229809885543Smrg	fi
229909885543Smrg
230009885543Smrg	ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
230109885543Smrg	test "X$ladir" = "X$lib" && ladir="."
230209885543Smrg
230309885543Smrg	dlname=
230409885543Smrg	dlopen=
230509885543Smrg	dlpreopen=
230609885543Smrg	libdir=
230709885543Smrg	library_names=
230809885543Smrg	old_library=
230909885543Smrg	# If the library was installed with an old release of libtool,
231009885543Smrg	# it will not redefine variables installed, or shouldnotlink
231109885543Smrg	installed=yes
231209885543Smrg	shouldnotlink=no
231309885543Smrg	avoidtemprpath=
231409885543Smrg
231509885543Smrg
231609885543Smrg	# Read the .la file
231709885543Smrg	case $lib in
231809885543Smrg	*/* | *\\*) . $lib ;;
231909885543Smrg	*) . ./$lib ;;
232009885543Smrg	esac
232109885543Smrg
232209885543Smrg	if test "$linkmode,$pass" = "lib,link" ||
232309885543Smrg	   test "$linkmode,$pass" = "prog,scan" ||
232409885543Smrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
232509885543Smrg	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
232609885543Smrg	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
232709885543Smrg	fi
232809885543Smrg
232909885543Smrg	if test "$pass" = conv; then
233009885543Smrg	  # Only check for convenience libraries
233109885543Smrg	  deplibs="$lib $deplibs"
233209885543Smrg	  if test -z "$libdir"; then
233309885543Smrg	    if test -z "$old_library"; then
233409885543Smrg	      $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
233509885543Smrg	      exit $EXIT_FAILURE
233609885543Smrg	    fi
233709885543Smrg	    # It is a libtool convenience library, so add in its objects.
233809885543Smrg	    convenience="$convenience $ladir/$objdir/$old_library"
233909885543Smrg	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
234009885543Smrg	    tmp_libs=
234109885543Smrg	    for deplib in $dependency_libs; do
234209885543Smrg	      deplibs="$deplib $deplibs"
234309885543Smrg              if test "X$duplicate_deps" = "Xyes" ; then
234409885543Smrg	        case "$tmp_libs " in
234509885543Smrg	        *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
234609885543Smrg	        esac
234709885543Smrg              fi
234809885543Smrg	      tmp_libs="$tmp_libs $deplib"
234909885543Smrg	    done
235009885543Smrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
235109885543Smrg	    $echo "$modename: \`$lib' is not a convenience library" 1>&2
235209885543Smrg	    exit $EXIT_FAILURE
235309885543Smrg	  fi
235409885543Smrg	  continue
235509885543Smrg	fi # $pass = conv
235609885543Smrg
235709885543Smrg
235809885543Smrg	# Get the name of the library we link against.
235909885543Smrg	linklib=
236009885543Smrg	for l in $old_library $library_names; do
236109885543Smrg	  linklib="$l"
236209885543Smrg	done
236309885543Smrg	if test -z "$linklib"; then
236409885543Smrg	  $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
236509885543Smrg	  exit $EXIT_FAILURE
236609885543Smrg	fi
236709885543Smrg
236809885543Smrg	# This library was specified with -dlopen.
236909885543Smrg	if test "$pass" = dlopen; then
237009885543Smrg	  if test -z "$libdir"; then
237109885543Smrg	    $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2
237209885543Smrg	    exit $EXIT_FAILURE
237309885543Smrg	  fi
237409885543Smrg	  if test -z "$dlname" ||
237509885543Smrg	     test "$dlopen_support" != yes ||
237609885543Smrg	     test "$build_libtool_libs" = no; then
237709885543Smrg	    # If there is no dlname, no dlopen support or we're linking
237809885543Smrg	    # statically, we need to preload.  We also need to preload any
237909885543Smrg	    # dependent libraries so libltdl's deplib preloader doesn't
238009885543Smrg	    # bomb out in the load deplibs phase.
238109885543Smrg	    dlprefiles="$dlprefiles $lib $dependency_libs"
238209885543Smrg	  else
238309885543Smrg	    newdlfiles="$newdlfiles $lib"
238409885543Smrg	  fi
238509885543Smrg	  continue
238609885543Smrg	fi # $pass = dlopen
238709885543Smrg
238809885543Smrg	# We need an absolute path.
238909885543Smrg	case $ladir in
239009885543Smrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
239109885543Smrg	*)
239209885543Smrg	  abs_ladir=`cd "$ladir" && pwd`
239309885543Smrg	  if test -z "$abs_ladir"; then
239409885543Smrg	    $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2
239509885543Smrg	    $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
239609885543Smrg	    abs_ladir="$ladir"
239709885543Smrg	  fi
239809885543Smrg	  ;;
239909885543Smrg	esac
240009885543Smrg	laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
240109885543Smrg
240209885543Smrg	# Find the relevant object directory and library name.
240309885543Smrg	if test "X$installed" = Xyes; then
240409885543Smrg	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
240509885543Smrg	    $echo "$modename: warning: library \`$lib' was moved." 1>&2
240609885543Smrg	    dir="$ladir"
240709885543Smrg	    absdir="$abs_ladir"
240809885543Smrg	    libdir="$abs_ladir"
240909885543Smrg	  else
241009885543Smrg	    dir="$libdir"
241109885543Smrg	    absdir="$libdir"
241209885543Smrg	  fi
241309885543Smrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
241409885543Smrg	else
241509885543Smrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
241609885543Smrg	    dir="$ladir"
241709885543Smrg	    absdir="$abs_ladir"
241809885543Smrg	    # Remove this search path later
241909885543Smrg	    notinst_path="$notinst_path $abs_ladir"
242009885543Smrg	  else
242109885543Smrg	    dir="$ladir/$objdir"
242209885543Smrg	    absdir="$abs_ladir/$objdir"
242309885543Smrg	    # Remove this search path later
242409885543Smrg	    notinst_path="$notinst_path $abs_ladir"
242509885543Smrg	  fi
242609885543Smrg	fi # $installed = yes
242709885543Smrg	name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
242809885543Smrg
242909885543Smrg	# This library was specified with -dlpreopen.
243009885543Smrg	if test "$pass" = dlpreopen; then
243109885543Smrg	  if test -z "$libdir"; then
243209885543Smrg	    $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2
243309885543Smrg	    exit $EXIT_FAILURE
243409885543Smrg	  fi
243509885543Smrg	  # Prefer using a static library (so that no silly _DYNAMIC symbols
243609885543Smrg	  # are required to link).
243709885543Smrg	  if test -n "$old_library"; then
243809885543Smrg	    newdlprefiles="$newdlprefiles $dir/$old_library"
243909885543Smrg	  # Otherwise, use the dlname, so that lt_dlopen finds it.
244009885543Smrg	  elif test -n "$dlname"; then
244109885543Smrg	    newdlprefiles="$newdlprefiles $dir/$dlname"
244209885543Smrg	  else
244309885543Smrg	    newdlprefiles="$newdlprefiles $dir/$linklib"
244409885543Smrg	  fi
244509885543Smrg	fi # $pass = dlpreopen
244609885543Smrg
244709885543Smrg	if test -z "$libdir"; then
244809885543Smrg	  # Link the convenience library
244909885543Smrg	  if test "$linkmode" = lib; then
245009885543Smrg	    deplibs="$dir/$old_library $deplibs"
245109885543Smrg	  elif test "$linkmode,$pass" = "prog,link"; then
245209885543Smrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
245309885543Smrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
245409885543Smrg	  else
245509885543Smrg	    deplibs="$lib $deplibs" # used for prog,scan pass
245609885543Smrg	  fi
245709885543Smrg	  continue
245809885543Smrg	fi
245909885543Smrg
246009885543Smrg
246109885543Smrg	if test "$linkmode" = prog && test "$pass" != link; then
246209885543Smrg	  newlib_search_path="$newlib_search_path $ladir"
246309885543Smrg	  deplibs="$lib $deplibs"
246409885543Smrg
246509885543Smrg	  linkalldeplibs=no
246609885543Smrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
246709885543Smrg	     test "$build_libtool_libs" = no; then
246809885543Smrg	    linkalldeplibs=yes
246909885543Smrg	  fi
247009885543Smrg
247109885543Smrg	  tmp_libs=
247209885543Smrg	  for deplib in $dependency_libs; do
247309885543Smrg	    case $deplib in
247409885543Smrg	    -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test
247509885543Smrg	    esac
247609885543Smrg	    # Need to link against all dependency_libs?
247709885543Smrg	    if test "$linkalldeplibs" = yes; then
247809885543Smrg	      deplibs="$deplib $deplibs"
247909885543Smrg	    else
248009885543Smrg	      # Need to hardcode shared library paths
248109885543Smrg	      # or/and link against static libraries
248209885543Smrg	      newdependency_libs="$deplib $newdependency_libs"
248309885543Smrg	    fi
248409885543Smrg	    if test "X$duplicate_deps" = "Xyes" ; then
248509885543Smrg	      case "$tmp_libs " in
248609885543Smrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
248709885543Smrg	      esac
248809885543Smrg	    fi
248909885543Smrg	    tmp_libs="$tmp_libs $deplib"
249009885543Smrg	  done # for deplib
249109885543Smrg	  continue
249209885543Smrg	fi # $linkmode = prog...
249309885543Smrg
249409885543Smrg	if test "$linkmode,$pass" = "prog,link"; then
249509885543Smrg	  if test -n "$library_names" &&
249609885543Smrg	     { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
249709885543Smrg	    # We need to hardcode the library path
249809885543Smrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
249909885543Smrg	      # Make sure the rpath contains only unique directories.
250009885543Smrg	      case "$temp_rpath " in
250109885543Smrg	      *" $dir "*) ;;
250209885543Smrg	      *" $absdir "*) ;;
250309885543Smrg	      *) temp_rpath="$temp_rpath $absdir" ;;
250409885543Smrg	      esac
250509885543Smrg	    fi
250609885543Smrg
250709885543Smrg	    # Hardcode the library path.
250809885543Smrg	    # Skip directories that are in the system default run-time
250909885543Smrg	    # search path.
251009885543Smrg	    case " $sys_lib_dlsearch_path " in
251109885543Smrg	    *" $absdir "*) ;;
251209885543Smrg	    *)
251309885543Smrg	      case "$compile_rpath " in
251409885543Smrg	      *" $absdir "*) ;;
251509885543Smrg	      *) compile_rpath="$compile_rpath $absdir"
251609885543Smrg	      esac
251709885543Smrg	      ;;
251809885543Smrg	    esac
251909885543Smrg	    case " $sys_lib_dlsearch_path " in
252009885543Smrg	    *" $libdir "*) ;;
252109885543Smrg	    *)
252209885543Smrg	      case "$finalize_rpath " in
252309885543Smrg	      *" $libdir "*) ;;
252409885543Smrg	      *) finalize_rpath="$finalize_rpath $libdir"
252509885543Smrg	      esac
252609885543Smrg	      ;;
252709885543Smrg	    esac
252809885543Smrg	  fi # $linkmode,$pass = prog,link...
252909885543Smrg
253009885543Smrg	  if test "$alldeplibs" = yes &&
253109885543Smrg	     { test "$deplibs_check_method" = pass_all ||
253209885543Smrg	       { test "$build_libtool_libs" = yes &&
253309885543Smrg		 test -n "$library_names"; }; }; then
253409885543Smrg	    # We only need to search for static libraries
253509885543Smrg	    continue
253609885543Smrg	  fi
253709885543Smrg	fi
253809885543Smrg
253909885543Smrg	link_static=no # Whether the deplib will be linked statically
254009885543Smrg	use_static_libs=$prefer_static_libs
254109885543Smrg	if test "$use_static_libs" = built && test "$installed" = yes ; then
254209885543Smrg	  use_static_libs=no
254309885543Smrg	fi
254409885543Smrg	if test -n "$library_names" &&
254509885543Smrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
254609885543Smrg	  if test "$installed" = no; then
254709885543Smrg	    notinst_deplibs="$notinst_deplibs $lib"
254809885543Smrg	    need_relink=yes
254909885543Smrg	  fi
255009885543Smrg	  # This is a shared library
255109885543Smrg
255209885543Smrg	  # Warn about portability, can't link against -module's on
255309885543Smrg	  # some systems (darwin)
255409885543Smrg	  if test "$shouldnotlink" = yes && test "$pass" = link ; then
255509885543Smrg	    $echo
255609885543Smrg	    if test "$linkmode" = prog; then
255709885543Smrg	      $echo "*** Warning: Linking the executable $output against the loadable module"
255809885543Smrg	    else
255909885543Smrg	      $echo "*** Warning: Linking the shared library $output against the loadable module"
256009885543Smrg	    fi
256109885543Smrg	    $echo "*** $linklib is not portable!"
256209885543Smrg	  fi
256309885543Smrg	  if test "$linkmode" = lib &&
256409885543Smrg	     test "$hardcode_into_libs" = yes; then
256509885543Smrg	    # Hardcode the library path.
256609885543Smrg	    # Skip directories that are in the system default run-time
256709885543Smrg	    # search path.
256809885543Smrg	    case " $sys_lib_dlsearch_path " in
256909885543Smrg	    *" $absdir "*) ;;
257009885543Smrg	    *)
257109885543Smrg	      case "$compile_rpath " in
257209885543Smrg	      *" $absdir "*) ;;
257309885543Smrg	      *) compile_rpath="$compile_rpath $absdir"
257409885543Smrg	      esac
257509885543Smrg	      ;;
257609885543Smrg	    esac
257709885543Smrg	    case " $sys_lib_dlsearch_path " in
257809885543Smrg	    *" $libdir "*) ;;
257909885543Smrg	    *)
258009885543Smrg	      case "$finalize_rpath " in
258109885543Smrg	      *" $libdir "*) ;;
258209885543Smrg	      *) finalize_rpath="$finalize_rpath $libdir"
258309885543Smrg	      esac
258409885543Smrg	      ;;
258509885543Smrg	    esac
258609885543Smrg	  fi
258709885543Smrg
258809885543Smrg	  if test -n "$old_archive_from_expsyms_cmds"; then
258909885543Smrg	    # figure out the soname
259009885543Smrg	    set dummy $library_names
259109885543Smrg	    realname="$2"
259209885543Smrg	    shift; shift
259309885543Smrg	    libname=`eval \\$echo \"$libname_spec\"`
259409885543Smrg	    # use dlname if we got it. it's perfectly good, no?
259509885543Smrg	    if test -n "$dlname"; then
259609885543Smrg	      soname="$dlname"
259709885543Smrg	    elif test -n "$soname_spec"; then
259809885543Smrg	      # bleh windows
259909885543Smrg	      case $host in
260009885543Smrg	      *cygwin* | mingw*)
260109885543Smrg		major=`expr $current - $age`
260209885543Smrg		versuffix="-$major"
260309885543Smrg		;;
260409885543Smrg	      esac
260509885543Smrg	      eval soname=\"$soname_spec\"
260609885543Smrg	    else
260709885543Smrg	      soname="$realname"
260809885543Smrg	    fi
260909885543Smrg
261009885543Smrg	    # Make a new name for the extract_expsyms_cmds to use
261109885543Smrg	    soroot="$soname"
261209885543Smrg	    soname=`$echo $soroot | ${SED} -e 's/^.*\///'`
261309885543Smrg	    newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a"
261409885543Smrg
261509885543Smrg	    # If the library has no export list, then create one now
261609885543Smrg	    if test -f "$output_objdir/$soname-def"; then :
261709885543Smrg	    else
261809885543Smrg	      $show "extracting exported symbol list from \`$soname'"
261909885543Smrg	      save_ifs="$IFS"; IFS='~'
262009885543Smrg	      cmds=$extract_expsyms_cmds
262109885543Smrg	      for cmd in $cmds; do
262209885543Smrg		IFS="$save_ifs"
262309885543Smrg		eval cmd=\"$cmd\"
262409885543Smrg		$show "$cmd"
262509885543Smrg		$run eval "$cmd" || exit $?
262609885543Smrg	      done
262709885543Smrg	      IFS="$save_ifs"
262809885543Smrg	    fi
262909885543Smrg
263009885543Smrg	    # Create $newlib
263109885543Smrg	    if test -f "$output_objdir/$newlib"; then :; else
263209885543Smrg	      $show "generating import library for \`$soname'"
263309885543Smrg	      save_ifs="$IFS"; IFS='~'
263409885543Smrg	      cmds=$old_archive_from_expsyms_cmds
263509885543Smrg	      for cmd in $cmds; do
263609885543Smrg		IFS="$save_ifs"
263709885543Smrg		eval cmd=\"$cmd\"
263809885543Smrg		$show "$cmd"
263909885543Smrg		$run eval "$cmd" || exit $?
264009885543Smrg	      done
264109885543Smrg	      IFS="$save_ifs"
264209885543Smrg	    fi
264309885543Smrg	    # make sure the library variables are pointing to the new library
264409885543Smrg	    dir=$output_objdir
264509885543Smrg	    linklib=$newlib
264609885543Smrg	  fi # test -n "$old_archive_from_expsyms_cmds"
264709885543Smrg
264809885543Smrg	  if test "$linkmode" = prog || test "$mode" != relink; then
264909885543Smrg	    add_shlibpath=
265009885543Smrg	    add_dir=
265109885543Smrg	    add=
265209885543Smrg	    lib_linked=yes
265309885543Smrg	    case $hardcode_action in
265409885543Smrg	    immediate | unsupported)
265509885543Smrg	      if test "$hardcode_direct" = no; then
265609885543Smrg		add="$dir/$linklib"
265709885543Smrg		case $host in
265809885543Smrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
265909885543Smrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
266009885543Smrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
266109885543Smrg		    *-*-unixware7*) add_dir="-L$dir" ;;
266209885543Smrg		  *-*-darwin* )
266309885543Smrg		    # if the lib is a module then we can not link against
266409885543Smrg		    # it, someone is ignoring the new warnings I added
266509885543Smrg		    if /usr/bin/file -L $add 2> /dev/null |
266609885543Smrg                      $EGREP ": [^:]* bundle" >/dev/null ; then
266709885543Smrg		      $echo "** Warning, lib $linklib is a module, not a shared library"
266809885543Smrg		      if test -z "$old_library" ; then
266909885543Smrg		        $echo
267009885543Smrg		        $echo "** And there doesn't seem to be a static archive available"
267109885543Smrg		        $echo "** The link will probably fail, sorry"
267209885543Smrg		      else
267309885543Smrg		        add="$dir/$old_library"
267409885543Smrg		      fi
267509885543Smrg		    fi
267609885543Smrg		esac
267709885543Smrg	      elif test "$hardcode_minus_L" = no; then
267809885543Smrg		case $host in
267909885543Smrg		*-*-sunos*) add_shlibpath="$dir" ;;
268009885543Smrg		esac
268109885543Smrg		add_dir="-L$dir"
268209885543Smrg		add="-l$name"
268309885543Smrg	      elif test "$hardcode_shlibpath_var" = no; then
268409885543Smrg		add_shlibpath="$dir"
268509885543Smrg		add="-l$name"
268609885543Smrg	      else
268709885543Smrg		lib_linked=no
268809885543Smrg	      fi
268909885543Smrg	      ;;
269009885543Smrg	    relink)
269109885543Smrg	      if test "$hardcode_direct" = yes; then
269209885543Smrg		add="$dir/$linklib"
269309885543Smrg	      elif test "$hardcode_minus_L" = yes; then
269409885543Smrg		add_dir="-L$dir"
269509885543Smrg		# Try looking first in the location we're being installed to.
269609885543Smrg		if test -n "$inst_prefix_dir"; then
269709885543Smrg		  case $libdir in
269809885543Smrg		    [\\/]*)
269909885543Smrg		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
270009885543Smrg		      ;;
270109885543Smrg		  esac
270209885543Smrg		fi
270309885543Smrg		add="-l$name"
270409885543Smrg	      elif test "$hardcode_shlibpath_var" = yes; then
270509885543Smrg		add_shlibpath="$dir"
270609885543Smrg		add="-l$name"
270709885543Smrg	      else
270809885543Smrg		lib_linked=no
270909885543Smrg	      fi
271009885543Smrg	      ;;
271109885543Smrg	    *) lib_linked=no ;;
271209885543Smrg	    esac
271309885543Smrg
271409885543Smrg	    if test "$lib_linked" != yes; then
271509885543Smrg	      $echo "$modename: configuration error: unsupported hardcode properties"
271609885543Smrg	      exit $EXIT_FAILURE
271709885543Smrg	    fi
271809885543Smrg
271909885543Smrg	    if test -n "$add_shlibpath"; then
272009885543Smrg	      case :$compile_shlibpath: in
272109885543Smrg	      *":$add_shlibpath:"*) ;;
272209885543Smrg	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
272309885543Smrg	      esac
272409885543Smrg	    fi
272509885543Smrg	    if test "$linkmode" = prog; then
272609885543Smrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
272709885543Smrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
272809885543Smrg	    else
272909885543Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
273009885543Smrg	      test -n "$add" && deplibs="$add $deplibs"
273109885543Smrg	      if test "$hardcode_direct" != yes && \
273209885543Smrg		 test "$hardcode_minus_L" != yes && \
273309885543Smrg		 test "$hardcode_shlibpath_var" = yes; then
273409885543Smrg		case :$finalize_shlibpath: in
273509885543Smrg		*":$libdir:"*) ;;
273609885543Smrg		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
273709885543Smrg		esac
273809885543Smrg	      fi
273909885543Smrg	    fi
274009885543Smrg	  fi
274109885543Smrg
274209885543Smrg	  if test "$linkmode" = prog || test "$mode" = relink; then
274309885543Smrg	    add_shlibpath=
274409885543Smrg	    add_dir=
274509885543Smrg	    add=
274609885543Smrg	    # Finalize command for both is simple: just hardcode it.
274709885543Smrg	    if test "$hardcode_direct" = yes; then
274809885543Smrg	      add="$libdir/$linklib"
274909885543Smrg	    elif test "$hardcode_minus_L" = yes; then
275009885543Smrg	      add_dir="-L$libdir"
275109885543Smrg	      add="-l$name"
275209885543Smrg	    elif test "$hardcode_shlibpath_var" = yes; then
275309885543Smrg	      case :$finalize_shlibpath: in
275409885543Smrg	      *":$libdir:"*) ;;
275509885543Smrg	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
275609885543Smrg	      esac
275709885543Smrg	      add="-l$name"
275809885543Smrg	    elif test "$hardcode_automatic" = yes; then
275909885543Smrg	      if test -n "$inst_prefix_dir" &&
276009885543Smrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
276109885543Smrg	        add="$inst_prefix_dir$libdir/$linklib"
276209885543Smrg	      else
276309885543Smrg	        add="$libdir/$linklib"
276409885543Smrg	      fi
276509885543Smrg	    else
276609885543Smrg	      # We cannot seem to hardcode it, guess we'll fake it.
276709885543Smrg	      add_dir="-L$libdir"
276809885543Smrg	      # Try looking first in the location we're being installed to.
276909885543Smrg	      if test -n "$inst_prefix_dir"; then
277009885543Smrg		case $libdir in
277109885543Smrg		  [\\/]*)
277209885543Smrg		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
277309885543Smrg		    ;;
277409885543Smrg		esac
277509885543Smrg	      fi
277609885543Smrg	      add="-l$name"
277709885543Smrg	    fi
277809885543Smrg
277909885543Smrg	    if test "$linkmode" = prog; then
278009885543Smrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
278109885543Smrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
278209885543Smrg	    else
278309885543Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
278409885543Smrg	      test -n "$add" && deplibs="$add $deplibs"
278509885543Smrg	    fi
278609885543Smrg	  fi
278709885543Smrg	elif test "$linkmode" = prog; then
278809885543Smrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
278909885543Smrg	  # is not unsupported.  This is valid on all known static and
279009885543Smrg	  # shared platforms.
279109885543Smrg	  if test "$hardcode_direct" != unsupported; then
279209885543Smrg	    test -n "$old_library" && linklib="$old_library"
279309885543Smrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
279409885543Smrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
279509885543Smrg	  else
279609885543Smrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
279709885543Smrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
279809885543Smrg	  fi
279909885543Smrg	elif test "$build_libtool_libs" = yes; then
280009885543Smrg	  # Not a shared library
280109885543Smrg	  if test "$deplibs_check_method" != pass_all; then
280209885543Smrg	    # We're trying link a shared library against a static one
280309885543Smrg	    # but the system doesn't support it.
280409885543Smrg
280509885543Smrg	    # Just print a warning and add the library to dependency_libs so
280609885543Smrg	    # that the program can be linked against the static library.
280709885543Smrg	    $echo
280809885543Smrg	    $echo "*** Warning: This system can not link to static lib archive $lib."
280909885543Smrg	    $echo "*** I have the capability to make that library automatically link in when"
281009885543Smrg	    $echo "*** you link to this library.  But I can only do this if you have a"
281109885543Smrg	    $echo "*** shared version of the library, which you do not appear to have."
281209885543Smrg	    if test "$module" = yes; then
281309885543Smrg	      $echo "*** But as you try to build a module library, libtool will still create "
281409885543Smrg	      $echo "*** a static module, that should work as long as the dlopening application"
281509885543Smrg	      $echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
281609885543Smrg	      if test -z "$global_symbol_pipe"; then
281709885543Smrg		$echo
281809885543Smrg		$echo "*** However, this would only work if libtool was able to extract symbol"
281909885543Smrg		$echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
282009885543Smrg		$echo "*** not find such a program.  So, this module is probably useless."
282109885543Smrg		$echo "*** \`nm' from GNU binutils and a full rebuild may help."
282209885543Smrg	      fi
282309885543Smrg	      if test "$build_old_libs" = no; then
282409885543Smrg		build_libtool_libs=module
282509885543Smrg		build_old_libs=yes
282609885543Smrg	      else
282709885543Smrg		build_libtool_libs=no
282809885543Smrg	      fi
282909885543Smrg	    fi
283009885543Smrg	  else
283109885543Smrg	    deplibs="$dir/$old_library $deplibs"
283209885543Smrg	    link_static=yes
283309885543Smrg	  fi
283409885543Smrg	fi # link shared/static library?
283509885543Smrg
283609885543Smrg	if test "$linkmode" = lib; then
283709885543Smrg	  if test -n "$dependency_libs" &&
283809885543Smrg	     { test "$hardcode_into_libs" != yes ||
283909885543Smrg	       test "$build_old_libs" = yes ||
284009885543Smrg	       test "$link_static" = yes; }; then
284109885543Smrg	    # Extract -R from dependency_libs
284209885543Smrg	    temp_deplibs=
284309885543Smrg	    for libdir in $dependency_libs; do
284409885543Smrg	      case $libdir in
284509885543Smrg	      -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'`
284609885543Smrg		   case " $xrpath " in
284709885543Smrg		   *" $temp_xrpath "*) ;;
284809885543Smrg		   *) xrpath="$xrpath $temp_xrpath";;
284909885543Smrg		   esac;;
285009885543Smrg	      *) temp_deplibs="$temp_deplibs $libdir";;
285109885543Smrg	      esac
285209885543Smrg	    done
285309885543Smrg	    dependency_libs="$temp_deplibs"
285409885543Smrg	  fi
285509885543Smrg
285609885543Smrg	  newlib_search_path="$newlib_search_path $absdir"
285709885543Smrg	  # Link against this library
285809885543Smrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
285909885543Smrg	  # ... and its dependency_libs
286009885543Smrg	  tmp_libs=
286109885543Smrg	  for deplib in $dependency_libs; do
286209885543Smrg	    newdependency_libs="$deplib $newdependency_libs"
286309885543Smrg	    if test "X$duplicate_deps" = "Xyes" ; then
286409885543Smrg	      case "$tmp_libs " in
286509885543Smrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
286609885543Smrg	      esac
286709885543Smrg	    fi
286809885543Smrg	    tmp_libs="$tmp_libs $deplib"
286909885543Smrg	  done
287009885543Smrg
287109885543Smrg	  if test "$link_all_deplibs" != no; then
287209885543Smrg	    # Add the search paths of all dependency libraries
287309885543Smrg	    for deplib in $dependency_libs; do
287409885543Smrg	      case $deplib in
287509885543Smrg	      -L*) path="$deplib" ;;
287609885543Smrg	      *.la)
287709885543Smrg		dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'`
287809885543Smrg		test "X$dir" = "X$deplib" && dir="."
287909885543Smrg		# We need an absolute path.
288009885543Smrg		case $dir in
288109885543Smrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
288209885543Smrg		*)
288309885543Smrg		  absdir=`cd "$dir" && pwd`
288409885543Smrg		  if test -z "$absdir"; then
288509885543Smrg		    $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
288609885543Smrg		    absdir="$dir"
288709885543Smrg		  fi
288809885543Smrg		  ;;
288909885543Smrg		esac
289009885543Smrg		if grep "^installed=no" $deplib > /dev/null; then
289109885543Smrg		  path="$absdir/$objdir"
289209885543Smrg		else
289309885543Smrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
289409885543Smrg		  if test -z "$libdir"; then
289509885543Smrg		    $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
289609885543Smrg		    exit $EXIT_FAILURE
289709885543Smrg		  fi
289809885543Smrg		  if test "$absdir" != "$libdir"; then
289909885543Smrg		    $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2
290009885543Smrg		  fi
290109885543Smrg		  path="$absdir"
290209885543Smrg		fi
290309885543Smrg		depdepl=
290409885543Smrg		case $host in
290509885543Smrg		*-*-darwin*)
290609885543Smrg		  # we do not want to link against static libs,
290709885543Smrg		  # but need to link against shared
290809885543Smrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
290909885543Smrg		  if test -n "$deplibrary_names" ; then
291009885543Smrg		    for tmp in $deplibrary_names ; do
291109885543Smrg		      depdepl=$tmp
291209885543Smrg		    done
291309885543Smrg		    if test -f "$path/$depdepl" ; then
291409885543Smrg		      depdepl="$path/$depdepl"
291509885543Smrg		    fi
291609885543Smrg		    # do not add paths which are already there
291709885543Smrg		    case " $newlib_search_path " in
291809885543Smrg		    *" $path "*) ;;
291909885543Smrg		    *) newlib_search_path="$newlib_search_path $path";;
292009885543Smrg		    esac
292109885543Smrg		  fi
292209885543Smrg		  path=""
292309885543Smrg		  ;;
292409885543Smrg		*)
292509885543Smrg		  path="-L$path"
292609885543Smrg		  ;;
292709885543Smrg		esac
292809885543Smrg		;;
292909885543Smrg	      -l*)
293009885543Smrg		case $host in
293109885543Smrg		*-*-darwin*)
293209885543Smrg		  # Again, we only want to link against shared libraries
293309885543Smrg		  eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"`
293409885543Smrg		  for tmp in $newlib_search_path ; do
293509885543Smrg		    if test -f "$tmp/lib$tmp_libs.dylib" ; then
293609885543Smrg		      eval depdepl="$tmp/lib$tmp_libs.dylib"
293709885543Smrg		      break
293809885543Smrg		    fi
293909885543Smrg		  done
294009885543Smrg		  path=""
294109885543Smrg		  ;;
294209885543Smrg		*) continue ;;
294309885543Smrg		esac
294409885543Smrg		;;
294509885543Smrg	      *) continue ;;
294609885543Smrg	      esac
294709885543Smrg	      case " $deplibs " in
294809885543Smrg	      *" $path "*) ;;
294909885543Smrg	      *) deplibs="$path $deplibs" ;;
295009885543Smrg	      esac
295109885543Smrg	      case " $deplibs " in
295209885543Smrg	      *" $depdepl "*) ;;
295309885543Smrg	      *) deplibs="$depdepl $deplibs" ;;
295409885543Smrg	      esac
295509885543Smrg	    done
295609885543Smrg	  fi # link_all_deplibs != no
295709885543Smrg	fi # linkmode = lib
295809885543Smrg      done # for deplib in $libs
295909885543Smrg      dependency_libs="$newdependency_libs"
296009885543Smrg      if test "$pass" = dlpreopen; then
296109885543Smrg	# Link the dlpreopened libraries before other libraries
296209885543Smrg	for deplib in $save_deplibs; do
296309885543Smrg	  deplibs="$deplib $deplibs"
296409885543Smrg	done
296509885543Smrg      fi
296609885543Smrg      if test "$pass" != dlopen; then
296709885543Smrg	if test "$pass" != conv; then
296809885543Smrg	  # Make sure lib_search_path contains only unique directories.
296909885543Smrg	  lib_search_path=
297009885543Smrg	  for dir in $newlib_search_path; do
297109885543Smrg	    case "$lib_search_path " in
297209885543Smrg	    *" $dir "*) ;;
297309885543Smrg	    *) lib_search_path="$lib_search_path $dir" ;;
297409885543Smrg	    esac
297509885543Smrg	  done
297609885543Smrg	  newlib_search_path=
297709885543Smrg	fi
297809885543Smrg
297909885543Smrg	if test "$linkmode,$pass" != "prog,link"; then
298009885543Smrg	  vars="deplibs"
298109885543Smrg	else
298209885543Smrg	  vars="compile_deplibs finalize_deplibs"
298309885543Smrg	fi
298409885543Smrg	for var in $vars dependency_libs; do
298509885543Smrg	  # Add libraries to $var in reverse order
298609885543Smrg	  eval tmp_libs=\"\$$var\"
298709885543Smrg	  new_libs=
298809885543Smrg	  for deplib in $tmp_libs; do
298909885543Smrg	    # FIXME: Pedantically, this is the right thing to do, so
299009885543Smrg	    #        that some nasty dependency loop isn't accidentally
299109885543Smrg	    #        broken:
299209885543Smrg	    #new_libs="$deplib $new_libs"
299309885543Smrg	    # Pragmatically, this seems to cause very few problems in
299409885543Smrg	    # practice:
299509885543Smrg	    case $deplib in
299609885543Smrg	    -L*) new_libs="$deplib $new_libs" ;;
299709885543Smrg	    -R*) ;;
299809885543Smrg	    *)
299909885543Smrg	      # And here is the reason: when a library appears more
300009885543Smrg	      # than once as an explicit dependence of a library, or
300109885543Smrg	      # is implicitly linked in more than once by the
300209885543Smrg	      # compiler, it is considered special, and multiple
300309885543Smrg	      # occurrences thereof are not removed.  Compare this
300409885543Smrg	      # with having the same library being listed as a
300509885543Smrg	      # dependency of multiple other libraries: in this case,
300609885543Smrg	      # we know (pedantically, we assume) the library does not
300709885543Smrg	      # need to be listed more than once, so we keep only the
300809885543Smrg	      # last copy.  This is not always right, but it is rare
300909885543Smrg	      # enough that we require users that really mean to play
301009885543Smrg	      # such unportable linking tricks to link the library
301109885543Smrg	      # using -Wl,-lname, so that libtool does not consider it
301209885543Smrg	      # for duplicate removal.
301309885543Smrg	      case " $specialdeplibs " in
301409885543Smrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
301509885543Smrg	      *)
301609885543Smrg		case " $new_libs " in
301709885543Smrg		*" $deplib "*) ;;
301809885543Smrg		*) new_libs="$deplib $new_libs" ;;
301909885543Smrg		esac
302009885543Smrg		;;
302109885543Smrg	      esac
302209885543Smrg	      ;;
302309885543Smrg	    esac
302409885543Smrg	  done
302509885543Smrg	  tmp_libs=
302609885543Smrg	  for deplib in $new_libs; do
302709885543Smrg	    case $deplib in
302809885543Smrg	    -L*)
302909885543Smrg	      case " $tmp_libs " in
303009885543Smrg	      *" $deplib "*) ;;
303109885543Smrg	      *) tmp_libs="$tmp_libs $deplib" ;;
303209885543Smrg	      esac
303309885543Smrg	      ;;
303409885543Smrg	    *) tmp_libs="$tmp_libs $deplib" ;;
303509885543Smrg	    esac
303609885543Smrg	  done
303709885543Smrg	  eval $var=\"$tmp_libs\"
303809885543Smrg	done # for var
303909885543Smrg      fi
304009885543Smrg      # Last step: remove runtime libs from dependency_libs
304109885543Smrg      # (they stay in deplibs)
304209885543Smrg      tmp_libs=
304309885543Smrg      for i in $dependency_libs ; do
304409885543Smrg	case " $predeps $postdeps $compiler_lib_search_path " in
304509885543Smrg	*" $i "*)
304609885543Smrg	  i=""
304709885543Smrg	  ;;
304809885543Smrg	esac
304909885543Smrg	if test -n "$i" ; then
305009885543Smrg	  tmp_libs="$tmp_libs $i"
305109885543Smrg	fi
305209885543Smrg      done
305309885543Smrg      dependency_libs=$tmp_libs
305409885543Smrg    done # for pass
305509885543Smrg    if test "$linkmode" = prog; then
305609885543Smrg      dlfiles="$newdlfiles"
305709885543Smrg      dlprefiles="$newdlprefiles"
305809885543Smrg    fi
305909885543Smrg
306009885543Smrg    case $linkmode in
306109885543Smrg    oldlib)
306209885543Smrg      if test -n "$deplibs"; then
306309885543Smrg	$echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2
306409885543Smrg      fi
306509885543Smrg
306609885543Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
306709885543Smrg	$echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
306809885543Smrg      fi
306909885543Smrg
307009885543Smrg      if test -n "$rpath"; then
307109885543Smrg	$echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2
307209885543Smrg      fi
307309885543Smrg
307409885543Smrg      if test -n "$xrpath"; then
307509885543Smrg	$echo "$modename: warning: \`-R' is ignored for archives" 1>&2
307609885543Smrg      fi
307709885543Smrg
307809885543Smrg      if test -n "$vinfo"; then
307909885543Smrg	$echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2
308009885543Smrg      fi
308109885543Smrg
308209885543Smrg      if test -n "$release"; then
308309885543Smrg	$echo "$modename: warning: \`-release' is ignored for archives" 1>&2
308409885543Smrg      fi
308509885543Smrg
308609885543Smrg      if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
308709885543Smrg	$echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2
308809885543Smrg      fi
308909885543Smrg
309009885543Smrg      # Now set the variables for building old libraries.
309109885543Smrg      build_libtool_libs=no
309209885543Smrg      oldlibs="$output"
309309885543Smrg      objs="$objs$old_deplibs"
309409885543Smrg      ;;
309509885543Smrg
309609885543Smrg    lib)
309709885543Smrg      # Make sure we only generate libraries of the form `libNAME.la'.
309809885543Smrg      case $outputname in
309909885543Smrg      lib*)
310009885543Smrg	name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
310109885543Smrg	eval shared_ext=\"$shrext_cmds\"
310209885543Smrg	eval libname=\"$libname_spec\"
310309885543Smrg	;;
310409885543Smrg      *)
310509885543Smrg	if test "$module" = no; then
310609885543Smrg	  $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
310709885543Smrg	  $echo "$help" 1>&2
310809885543Smrg	  exit $EXIT_FAILURE
310909885543Smrg	fi
311009885543Smrg	if test "$need_lib_prefix" != no; then
311109885543Smrg	  # Add the "lib" prefix for modules if required
311209885543Smrg	  name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
311309885543Smrg	  eval shared_ext=\"$shrext_cmds\"
311409885543Smrg	  eval libname=\"$libname_spec\"
311509885543Smrg	else
311609885543Smrg	  libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
311709885543Smrg	fi
311809885543Smrg	;;
311909885543Smrg      esac
312009885543Smrg
312109885543Smrg      if test -n "$objs"; then
312209885543Smrg	if test "$deplibs_check_method" != pass_all; then
312309885543Smrg	  $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1
312409885543Smrg	  exit $EXIT_FAILURE
312509885543Smrg	else
312609885543Smrg	  $echo
312709885543Smrg	  $echo "*** Warning: Linking the shared library $output against the non-libtool"
312809885543Smrg	  $echo "*** objects $objs is not portable!"
312909885543Smrg	  libobjs="$libobjs $objs"
313009885543Smrg	fi
313109885543Smrg      fi
313209885543Smrg
313309885543Smrg      if test "$dlself" != no; then
313409885543Smrg	$echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2
313509885543Smrg      fi
313609885543Smrg
313709885543Smrg      set dummy $rpath
313809885543Smrg      if test "$#" -gt 2; then
313909885543Smrg	$echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
314009885543Smrg      fi
314109885543Smrg      install_libdir="$2"
314209885543Smrg
314309885543Smrg      oldlibs=
314409885543Smrg      if test -z "$rpath"; then
314509885543Smrg	if test "$build_libtool_libs" = yes; then
314609885543Smrg	  # Building a libtool convenience library.
314709885543Smrg	  # Some compilers have problems with a `.al' extension so
314809885543Smrg	  # convenience libraries should have the same extension an
314909885543Smrg	  # archive normally would.
315009885543Smrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
315109885543Smrg	  build_libtool_libs=convenience
315209885543Smrg	  build_old_libs=yes
315309885543Smrg	fi
315409885543Smrg
315509885543Smrg	if test -n "$vinfo"; then
315609885543Smrg	  $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2
315709885543Smrg	fi
315809885543Smrg
315909885543Smrg	if test -n "$release"; then
316009885543Smrg	  $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2
316109885543Smrg	fi
316209885543Smrg      else
316309885543Smrg
316409885543Smrg	# Parse the version information argument.
316509885543Smrg	save_ifs="$IFS"; IFS=':'
316609885543Smrg	set dummy $vinfo 0 0 0
316709885543Smrg	IFS="$save_ifs"
316809885543Smrg
316909885543Smrg	if test -n "$8"; then
317009885543Smrg	  $echo "$modename: too many parameters to \`-version-info'" 1>&2
317109885543Smrg	  $echo "$help" 1>&2
317209885543Smrg	  exit $EXIT_FAILURE
317309885543Smrg	fi
317409885543Smrg
317509885543Smrg	# convert absolute version numbers to libtool ages
317609885543Smrg	# this retains compatibility with .la files and attempts
317709885543Smrg	# to make the code below a bit more comprehensible
317809885543Smrg
317909885543Smrg	case $vinfo_number in
318009885543Smrg	yes)
318109885543Smrg	  number_major="$2"
318209885543Smrg	  number_minor="$3"
318309885543Smrg	  number_revision="$4"
318409885543Smrg	  #
318509885543Smrg	  # There are really only two kinds -- those that
318609885543Smrg	  # use the current revision as the major version
318709885543Smrg	  # and those that subtract age and use age as
318809885543Smrg	  # a minor version.  But, then there is irix
318909885543Smrg	  # which has an extra 1 added just for fun
319009885543Smrg	  #
319109885543Smrg	  case $version_type in
319209885543Smrg	  darwin|linux|osf|windows)
319309885543Smrg	    current=`expr $number_major + $number_minor`
319409885543Smrg	    age="$number_minor"
319509885543Smrg	    revision="$number_revision"
319609885543Smrg	    ;;
319709885543Smrg	  freebsd-aout|freebsd-elf|sunos)
319809885543Smrg	    current="$number_major"
319909885543Smrg	    revision="$number_minor"
320009885543Smrg	    age="0"
320109885543Smrg	    ;;
320209885543Smrg	  irix|nonstopux)
320309885543Smrg	    current=`expr $number_major + $number_minor - 1`
320409885543Smrg	    age="$number_minor"
320509885543Smrg	    revision="$number_minor"
320609885543Smrg	    ;;
320709885543Smrg	  *)
320809885543Smrg	    $echo "$modename: unknown library version type \`$version_type'" 1>&2
320909885543Smrg	    $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
321009885543Smrg	    exit $EXIT_FAILURE
321109885543Smrg	    ;;
321209885543Smrg	  esac
321309885543Smrg	  ;;
321409885543Smrg	no)
321509885543Smrg	  current="$2"
321609885543Smrg	  revision="$3"
321709885543Smrg	  age="$4"
321809885543Smrg	  ;;
321909885543Smrg	esac
322009885543Smrg
322109885543Smrg	# Check that each of the things are valid numbers.
322209885543Smrg	case $current in
322309885543Smrg	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]) ;;
322409885543Smrg	*)
322509885543Smrg	  $echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2
322609885543Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
322709885543Smrg	  exit $EXIT_FAILURE
322809885543Smrg	  ;;
322909885543Smrg	esac
323009885543Smrg
323109885543Smrg	case $revision in
323209885543Smrg	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]) ;;
323309885543Smrg	*)
323409885543Smrg	  $echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2
323509885543Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
323609885543Smrg	  exit $EXIT_FAILURE
323709885543Smrg	  ;;
323809885543Smrg	esac
323909885543Smrg
324009885543Smrg	case $age in
324109885543Smrg	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]) ;;
324209885543Smrg	*)
324309885543Smrg	  $echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2
324409885543Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
324509885543Smrg	  exit $EXIT_FAILURE
324609885543Smrg	  ;;
324709885543Smrg	esac
324809885543Smrg
324909885543Smrg	if test "$age" -gt "$current"; then
325009885543Smrg	  $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
325109885543Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
325209885543Smrg	  exit $EXIT_FAILURE
325309885543Smrg	fi
325409885543Smrg
325509885543Smrg	# Calculate the version variables.
325609885543Smrg	major=
325709885543Smrg	versuffix=
325809885543Smrg	verstring=
325909885543Smrg	case $version_type in
326009885543Smrg	none) ;;
326109885543Smrg
326209885543Smrg	darwin)
326309885543Smrg	  # Like Linux, but with the current version available in
326409885543Smrg	  # verstring for coding it into the library header
326509885543Smrg	  major=.`expr $current - $age`
326609885543Smrg	  versuffix="$major.$age.$revision"
326709885543Smrg	  # Darwin ld doesn't like 0 for these options...
326809885543Smrg	  minor_current=`expr $current + 1`
326909885543Smrg	  verstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
327009885543Smrg	  ;;
327109885543Smrg
327209885543Smrg	freebsd-aout)
327309885543Smrg	  major=".$current"
327409885543Smrg	  versuffix=".$current.$revision";
327509885543Smrg	  ;;
327609885543Smrg
327709885543Smrg	freebsd-elf)
327809885543Smrg	  major=".$current"
327909885543Smrg	  versuffix=".$current";
328009885543Smrg	  ;;
328109885543Smrg
328209885543Smrg	irix | nonstopux)
328309885543Smrg	  major=`expr $current - $age + 1`
328409885543Smrg
328509885543Smrg	  case $version_type in
328609885543Smrg	    nonstopux) verstring_prefix=nonstopux ;;
328709885543Smrg	    *)         verstring_prefix=sgi ;;
328809885543Smrg	  esac
328909885543Smrg	  verstring="$verstring_prefix$major.$revision"
329009885543Smrg
329109885543Smrg	  # Add in all the interfaces that we are compatible with.
329209885543Smrg	  loop=$revision
329309885543Smrg	  while test "$loop" -ne 0; do
329409885543Smrg	    iface=`expr $revision - $loop`
329509885543Smrg	    loop=`expr $loop - 1`
329609885543Smrg	    verstring="$verstring_prefix$major.$iface:$verstring"
329709885543Smrg	  done
329809885543Smrg
329909885543Smrg	  # Before this point, $major must not contain `.'.
330009885543Smrg	  major=.$major
330109885543Smrg	  versuffix="$major.$revision"
330209885543Smrg	  ;;
330309885543Smrg
330409885543Smrg	linux)
330509885543Smrg	  major=.`expr $current - $age`
330609885543Smrg	  versuffix="$major.$age.$revision"
330709885543Smrg	  ;;
330809885543Smrg
330909885543Smrg	osf)
331009885543Smrg	  major=.`expr $current - $age`
331109885543Smrg	  versuffix=".$current.$age.$revision"
331209885543Smrg	  verstring="$current.$age.$revision"
331309885543Smrg
331409885543Smrg	  # Add in all the interfaces that we are compatible with.
331509885543Smrg	  loop=$age
331609885543Smrg	  while test "$loop" -ne 0; do
331709885543Smrg	    iface=`expr $current - $loop`
331809885543Smrg	    loop=`expr $loop - 1`
331909885543Smrg	    verstring="$verstring:${iface}.0"
332009885543Smrg	  done
332109885543Smrg
332209885543Smrg	  # Make executables depend on our current version.
332309885543Smrg	  verstring="$verstring:${current}.0"
332409885543Smrg	  ;;
332509885543Smrg
332609885543Smrg	sunos)
332709885543Smrg	  major=".$current"
332809885543Smrg	  versuffix=".$current.$revision"
332909885543Smrg	  ;;
333009885543Smrg
333109885543Smrg	windows)
333209885543Smrg	  # Use '-' rather than '.', since we only want one
333309885543Smrg	  # extension on DOS 8.3 filesystems.
333409885543Smrg	  major=`expr $current - $age`
333509885543Smrg	  versuffix="-$major"
333609885543Smrg	  ;;
333709885543Smrg
333809885543Smrg	*)
333909885543Smrg	  $echo "$modename: unknown library version type \`$version_type'" 1>&2
334009885543Smrg	  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
334109885543Smrg	  exit $EXIT_FAILURE
334209885543Smrg	  ;;
334309885543Smrg	esac
334409885543Smrg
334509885543Smrg	# Clear the version info if we defaulted, and they specified a release.
334609885543Smrg	if test -z "$vinfo" && test -n "$release"; then
334709885543Smrg	  major=
334809885543Smrg	  case $version_type in
334909885543Smrg	  darwin)
335009885543Smrg	    # we can't check for "0.0" in archive_cmds due to quoting
335109885543Smrg	    # problems, so we reset it completely
335209885543Smrg	    verstring=
335309885543Smrg	    ;;
335409885543Smrg	  *)
335509885543Smrg	    verstring="0.0"
335609885543Smrg	    ;;
335709885543Smrg	  esac
335809885543Smrg	  if test "$need_version" = no; then
335909885543Smrg	    versuffix=
336009885543Smrg	  else
336109885543Smrg	    versuffix=".0.0"
336209885543Smrg	  fi
336309885543Smrg	fi
336409885543Smrg
336509885543Smrg	# Remove version info from name if versioning should be avoided
336609885543Smrg	if test "$avoid_version" = yes && test "$need_version" = no; then
336709885543Smrg	  major=
336809885543Smrg	  versuffix=
336909885543Smrg	  verstring=""
337009885543Smrg	fi
337109885543Smrg
337209885543Smrg	# Check to see if the archive will have undefined symbols.
337309885543Smrg	if test "$allow_undefined" = yes; then
337409885543Smrg	  if test "$allow_undefined_flag" = unsupported; then
337509885543Smrg	    $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2
337609885543Smrg	    build_libtool_libs=no
337709885543Smrg	    build_old_libs=yes
337809885543Smrg	  fi
337909885543Smrg	else
338009885543Smrg	  # Don't allow undefined symbols.
338109885543Smrg	  allow_undefined_flag="$no_undefined_flag"
338209885543Smrg	fi
338309885543Smrg      fi
338409885543Smrg
338509885543Smrg      if test "$mode" != relink; then
338609885543Smrg	# Remove our outputs, but don't remove object files since they
338709885543Smrg	# may have been created when compiling PIC objects.
338809885543Smrg	removelist=
338909885543Smrg	tempremovelist=`$echo "$output_objdir/*"`
339009885543Smrg	for p in $tempremovelist; do
339109885543Smrg	  case $p in
339209885543Smrg	    *.$objext)
339309885543Smrg	       ;;
339409885543Smrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
339509885543Smrg	       if test "X$precious_files_regex" != "X"; then
339609885543Smrg	         if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
339709885543Smrg	         then
339809885543Smrg		   continue
339909885543Smrg		 fi
340009885543Smrg	       fi
340109885543Smrg	       removelist="$removelist $p"
340209885543Smrg	       ;;
340309885543Smrg	    *) ;;
340409885543Smrg	  esac
340509885543Smrg	done
340609885543Smrg	if test -n "$removelist"; then
340709885543Smrg	  $show "${rm}r $removelist"
340809885543Smrg	  $run ${rm}r $removelist
340909885543Smrg	fi
341009885543Smrg      fi
341109885543Smrg
341209885543Smrg      # Now set the variables for building old libraries.
341309885543Smrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
341409885543Smrg	oldlibs="$oldlibs $output_objdir/$libname.$libext"
341509885543Smrg
341609885543Smrg	# Transform .lo files to .o files.
341709885543Smrg	oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
341809885543Smrg      fi
341909885543Smrg
342009885543Smrg      # Eliminate all temporary directories.
342109885543Smrg      for path in $notinst_path; do
342209885543Smrg	lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"`
342309885543Smrg	deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"`
342409885543Smrg	dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"`
342509885543Smrg      done
342609885543Smrg
342709885543Smrg      if test -n "$xrpath"; then
342809885543Smrg	# If the user specified any rpath flags, then add them.
342909885543Smrg	temp_xrpath=
343009885543Smrg	for libdir in $xrpath; do
343109885543Smrg	  temp_xrpath="$temp_xrpath -R$libdir"
343209885543Smrg	  case "$finalize_rpath " in
343309885543Smrg	  *" $libdir "*) ;;
343409885543Smrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
343509885543Smrg	  esac
343609885543Smrg	done
343709885543Smrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
343809885543Smrg	  dependency_libs="$temp_xrpath $dependency_libs"
343909885543Smrg	fi
344009885543Smrg      fi
344109885543Smrg
344209885543Smrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
344309885543Smrg      old_dlfiles="$dlfiles"
344409885543Smrg      dlfiles=
344509885543Smrg      for lib in $old_dlfiles; do
344609885543Smrg	case " $dlprefiles $dlfiles " in
344709885543Smrg	*" $lib "*) ;;
344809885543Smrg	*) dlfiles="$dlfiles $lib" ;;
344909885543Smrg	esac
345009885543Smrg      done
345109885543Smrg
345209885543Smrg      # Make sure dlprefiles contains only unique files
345309885543Smrg      old_dlprefiles="$dlprefiles"
345409885543Smrg      dlprefiles=
345509885543Smrg      for lib in $old_dlprefiles; do
345609885543Smrg	case "$dlprefiles " in
345709885543Smrg	*" $lib "*) ;;
345809885543Smrg	*) dlprefiles="$dlprefiles $lib" ;;
345909885543Smrg	esac
346009885543Smrg      done
346109885543Smrg
346209885543Smrg      if test "$build_libtool_libs" = yes; then
346309885543Smrg	if test -n "$rpath"; then
346409885543Smrg	  case $host in
346509885543Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*)
346609885543Smrg	    # these systems don't actually have a c library (as such)!
346709885543Smrg	    ;;
346809885543Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
346909885543Smrg	    # Rhapsody C library is in the System framework
347009885543Smrg	    deplibs="$deplibs -framework System"
347109885543Smrg	    ;;
347209885543Smrg	  *-*-netbsd*)
347309885543Smrg	    # Don't link with libc until the a.out ld.so is fixed.
347409885543Smrg	    ;;
347509885543Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
347609885543Smrg	    # Do not include libc due to us having libc/libc_r.
347709885543Smrg	    ;;
347809885543Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
347909885543Smrg	    # Causes problems with __ctype
348009885543Smrg	    ;;
348109885543Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
348209885543Smrg	    # Compiler inserts libc in the correct place for threads to work
348309885543Smrg	    ;;
348409885543Smrg 	  *)
348509885543Smrg	    # Add libc to deplibs on all other systems if necessary.
348609885543Smrg	    if test "$build_libtool_need_lc" = "yes"; then
348709885543Smrg	      deplibs="$deplibs -lc"
348809885543Smrg	    fi
348909885543Smrg	    ;;
349009885543Smrg	  esac
349109885543Smrg	fi
349209885543Smrg
349309885543Smrg	# Transform deplibs into only deplibs that can be linked in shared.
349409885543Smrg	name_save=$name
349509885543Smrg	libname_save=$libname
349609885543Smrg	release_save=$release
349709885543Smrg	versuffix_save=$versuffix
349809885543Smrg	major_save=$major
349909885543Smrg	# I'm not sure if I'm treating the release correctly.  I think
350009885543Smrg	# release should show up in the -l (ie -lgmp5) so we don't want to
350109885543Smrg	# add it in twice.  Is that correct?
350209885543Smrg	release=""
350309885543Smrg	versuffix=""
350409885543Smrg	major=""
350509885543Smrg	newdeplibs=
350609885543Smrg	droppeddeps=no
350709885543Smrg	case $deplibs_check_method in
350809885543Smrg	pass_all)
350909885543Smrg	  # Don't check for shared/static.  Everything works.
351009885543Smrg	  # This might be a little naive.  We might want to check
351109885543Smrg	  # whether the library exists or not.  But this is on
351209885543Smrg	  # osf3 & osf4 and I'm not really sure... Just
351309885543Smrg	  # implementing what was already the behavior.
351409885543Smrg	  newdeplibs=$deplibs
351509885543Smrg	  ;;
351609885543Smrg	test_compile)
351709885543Smrg	  # This code stresses the "libraries are programs" paradigm to its
351809885543Smrg	  # limits. Maybe even breaks it.  We compile a program, linking it
351909885543Smrg	  # against the deplibs as a proxy for the library.  Then we can check
352009885543Smrg	  # whether they linked in statically or dynamically with ldd.
352109885543Smrg	  $rm conftest.c
352209885543Smrg	  cat > conftest.c <<EOF
352309885543Smrg	  int main() { return 0; }
352409885543SmrgEOF
352509885543Smrg	  $rm conftest
352609885543Smrg	  $LTCC $LTCFLAGS -o conftest conftest.c $deplibs
352709885543Smrg	  if test "$?" -eq 0 ; then
352809885543Smrg	    ldd_output=`ldd conftest`
352909885543Smrg	    for i in $deplibs; do
353009885543Smrg	      name=`expr $i : '-l\(.*\)'`
353109885543Smrg	      # If $name is empty we are operating on a -L argument.
353209885543Smrg              if test "$name" != "" && test "$name" -ne "0"; then
353309885543Smrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
353409885543Smrg		  case " $predeps $postdeps " in
353509885543Smrg		  *" $i "*)
353609885543Smrg		    newdeplibs="$newdeplibs $i"
353709885543Smrg		    i=""
353809885543Smrg		    ;;
353909885543Smrg		  esac
354009885543Smrg	        fi
354109885543Smrg		if test -n "$i" ; then
354209885543Smrg		  libname=`eval \\$echo \"$libname_spec\"`
354309885543Smrg		  deplib_matches=`eval \\$echo \"$library_names_spec\"`
354409885543Smrg		  set dummy $deplib_matches
354509885543Smrg		  deplib_match=$2
354609885543Smrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
354709885543Smrg		    newdeplibs="$newdeplibs $i"
354809885543Smrg		  else
354909885543Smrg		    droppeddeps=yes
355009885543Smrg		    $echo
355109885543Smrg		    $echo "*** Warning: dynamic linker does not accept needed library $i."
355209885543Smrg		    $echo "*** I have the capability to make that library automatically link in when"
355309885543Smrg		    $echo "*** you link to this library.  But I can only do this if you have a"
355409885543Smrg		    $echo "*** shared version of the library, which I believe you do not have"
355509885543Smrg		    $echo "*** because a test_compile did reveal that the linker did not use it for"
355609885543Smrg		    $echo "*** its dynamic dependency list that programs get resolved with at runtime."
355709885543Smrg		  fi
355809885543Smrg		fi
355909885543Smrg	      else
356009885543Smrg		newdeplibs="$newdeplibs $i"
356109885543Smrg	      fi
356209885543Smrg	    done
356309885543Smrg	  else
356409885543Smrg	    # Error occurred in the first compile.  Let's try to salvage
356509885543Smrg	    # the situation: Compile a separate program for each library.
356609885543Smrg	    for i in $deplibs; do
356709885543Smrg	      name=`expr $i : '-l\(.*\)'`
356809885543Smrg	      # If $name is empty we are operating on a -L argument.
356909885543Smrg              if test "$name" != "" && test "$name" != "0"; then
357009885543Smrg		$rm conftest
357109885543Smrg		$LTCC $LTCFLAGS -o conftest conftest.c $i
357209885543Smrg		# Did it work?
357309885543Smrg		if test "$?" -eq 0 ; then
357409885543Smrg		  ldd_output=`ldd conftest`
357509885543Smrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
357609885543Smrg		    case " $predeps $postdeps " in
357709885543Smrg		    *" $i "*)
357809885543Smrg		      newdeplibs="$newdeplibs $i"
357909885543Smrg		      i=""
358009885543Smrg		      ;;
358109885543Smrg		    esac
358209885543Smrg		  fi
358309885543Smrg		  if test -n "$i" ; then
358409885543Smrg		    libname=`eval \\$echo \"$libname_spec\"`
358509885543Smrg		    deplib_matches=`eval \\$echo \"$library_names_spec\"`
358609885543Smrg		    set dummy $deplib_matches
358709885543Smrg		    deplib_match=$2
358809885543Smrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
358909885543Smrg		      newdeplibs="$newdeplibs $i"
359009885543Smrg		    else
359109885543Smrg		      droppeddeps=yes
359209885543Smrg		      $echo
359309885543Smrg		      $echo "*** Warning: dynamic linker does not accept needed library $i."
359409885543Smrg		      $echo "*** I have the capability to make that library automatically link in when"
359509885543Smrg		      $echo "*** you link to this library.  But I can only do this if you have a"
359609885543Smrg		      $echo "*** shared version of the library, which you do not appear to have"
359709885543Smrg		      $echo "*** because a test_compile did reveal that the linker did not use this one"
359809885543Smrg		      $echo "*** as a dynamic dependency that programs can get resolved with at runtime."
359909885543Smrg		    fi
360009885543Smrg		  fi
360109885543Smrg		else
360209885543Smrg		  droppeddeps=yes
360309885543Smrg		  $echo
360409885543Smrg		  $echo "*** Warning!  Library $i is needed by this library but I was not able to"
360509885543Smrg		  $echo "***  make it link in!  You will probably need to install it or some"
360609885543Smrg		  $echo "*** library that it depends on before this library will be fully"
360709885543Smrg		  $echo "*** functional.  Installing it before continuing would be even better."
360809885543Smrg		fi
360909885543Smrg	      else
361009885543Smrg		newdeplibs="$newdeplibs $i"
361109885543Smrg	      fi
361209885543Smrg	    done
361309885543Smrg	  fi
361409885543Smrg	  ;;
361509885543Smrg	file_magic*)
361609885543Smrg	  set dummy $deplibs_check_method
361709885543Smrg	  file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
361809885543Smrg	  for a_deplib in $deplibs; do
361909885543Smrg	    name=`expr $a_deplib : '-l\(.*\)'`
362009885543Smrg	    # If $name is empty we are operating on a -L argument.
362109885543Smrg            if test "$name" != "" && test  "$name" != "0"; then
362209885543Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
362309885543Smrg		case " $predeps $postdeps " in
362409885543Smrg		*" $a_deplib "*)
362509885543Smrg		  newdeplibs="$newdeplibs $a_deplib"
362609885543Smrg		  a_deplib=""
362709885543Smrg		  ;;
362809885543Smrg		esac
362909885543Smrg	      fi
363009885543Smrg	      if test -n "$a_deplib" ; then
363109885543Smrg		libname=`eval \\$echo \"$libname_spec\"`
363209885543Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
363309885543Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
363409885543Smrg		  for potent_lib in $potential_libs; do
363509885543Smrg		      # Follow soft links.
363609885543Smrg		      if ls -lLd "$potent_lib" 2>/dev/null \
363709885543Smrg			 | grep " -> " >/dev/null; then
363809885543Smrg			continue
363909885543Smrg		      fi
364009885543Smrg		      # The statement above tries to avoid entering an
364109885543Smrg		      # endless loop below, in case of cyclic links.
364209885543Smrg		      # We might still enter an endless loop, since a link
364309885543Smrg		      # loop can be closed while we follow links,
364409885543Smrg		      # but so what?
364509885543Smrg		      potlib="$potent_lib"
364609885543Smrg		      while test -h "$potlib" 2>/dev/null; do
364709885543Smrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
364809885543Smrg			case $potliblink in
364909885543Smrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
365009885543Smrg			*) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
365109885543Smrg			esac
365209885543Smrg		      done
365309885543Smrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
365409885543Smrg			 | ${SED} 10q \
365509885543Smrg			 | $EGREP "$file_magic_regex" > /dev/null; then
365609885543Smrg			newdeplibs="$newdeplibs $a_deplib"
365709885543Smrg			a_deplib=""
365809885543Smrg			break 2
365909885543Smrg		      fi
366009885543Smrg		  done
366109885543Smrg		done
366209885543Smrg	      fi
366309885543Smrg	      if test -n "$a_deplib" ; then
366409885543Smrg		droppeddeps=yes
366509885543Smrg		$echo
366609885543Smrg		$echo "*** Warning: linker path does not have real file for library $a_deplib."
366709885543Smrg		$echo "*** I have the capability to make that library automatically link in when"
366809885543Smrg		$echo "*** you link to this library.  But I can only do this if you have a"
366909885543Smrg		$echo "*** shared version of the library, which you do not appear to have"
367009885543Smrg		$echo "*** because I did check the linker path looking for a file starting"
367109885543Smrg		if test -z "$potlib" ; then
367209885543Smrg		  $echo "*** with $libname but no candidates were found. (...for file magic test)"
367309885543Smrg		else
367409885543Smrg		  $echo "*** with $libname and none of the candidates passed a file format test"
367509885543Smrg		  $echo "*** using a file magic. Last file checked: $potlib"
367609885543Smrg		fi
367709885543Smrg	      fi
367809885543Smrg	    else
367909885543Smrg	      # Add a -L argument.
368009885543Smrg	      newdeplibs="$newdeplibs $a_deplib"
368109885543Smrg	    fi
368209885543Smrg	  done # Gone through all deplibs.
368309885543Smrg	  ;;
368409885543Smrg	match_pattern*)
368509885543Smrg	  set dummy $deplibs_check_method
368609885543Smrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
368709885543Smrg	  for a_deplib in $deplibs; do
368809885543Smrg	    name=`expr $a_deplib : '-l\(.*\)'`
368909885543Smrg	    # If $name is empty we are operating on a -L argument.
369009885543Smrg	    if test -n "$name" && test "$name" != "0"; then
369109885543Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
369209885543Smrg		case " $predeps $postdeps " in
369309885543Smrg		*" $a_deplib "*)
369409885543Smrg		  newdeplibs="$newdeplibs $a_deplib"
369509885543Smrg		  a_deplib=""
369609885543Smrg		  ;;
369709885543Smrg		esac
369809885543Smrg	      fi
369909885543Smrg	      if test -n "$a_deplib" ; then
370009885543Smrg		libname=`eval \\$echo \"$libname_spec\"`
370109885543Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
370209885543Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
370309885543Smrg		  for potent_lib in $potential_libs; do
370409885543Smrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
370509885543Smrg		    if eval $echo \"$potent_lib\" 2>/dev/null \
370609885543Smrg		        | ${SED} 10q \
370709885543Smrg		        | $EGREP "$match_pattern_regex" > /dev/null; then
370809885543Smrg		      newdeplibs="$newdeplibs $a_deplib"
370909885543Smrg		      a_deplib=""
371009885543Smrg		      break 2
371109885543Smrg		    fi
371209885543Smrg		  done
371309885543Smrg		done
371409885543Smrg	      fi
371509885543Smrg	      if test -n "$a_deplib" ; then
371609885543Smrg		droppeddeps=yes
371709885543Smrg		$echo
371809885543Smrg		$echo "*** Warning: linker path does not have real file for library $a_deplib."
371909885543Smrg		$echo "*** I have the capability to make that library automatically link in when"
372009885543Smrg		$echo "*** you link to this library.  But I can only do this if you have a"
372109885543Smrg		$echo "*** shared version of the library, which you do not appear to have"
372209885543Smrg		$echo "*** because I did check the linker path looking for a file starting"
372309885543Smrg		if test -z "$potlib" ; then
372409885543Smrg		  $echo "*** with $libname but no candidates were found. (...for regex pattern test)"
372509885543Smrg		else
372609885543Smrg		  $echo "*** with $libname and none of the candidates passed a file format test"
372709885543Smrg		  $echo "*** using a regex pattern. Last file checked: $potlib"
372809885543Smrg		fi
372909885543Smrg	      fi
373009885543Smrg	    else
373109885543Smrg	      # Add a -L argument.
373209885543Smrg	      newdeplibs="$newdeplibs $a_deplib"
373309885543Smrg	    fi
373409885543Smrg	  done # Gone through all deplibs.
373509885543Smrg	  ;;
373609885543Smrg	none | unknown | *)
373709885543Smrg	  newdeplibs=""
373809885543Smrg	  tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
373909885543Smrg	    -e 's/ -[LR][^ ]*//g'`
374009885543Smrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
374109885543Smrg	    for i in $predeps $postdeps ; do
374209885543Smrg	      # can't use Xsed below, because $i might contain '/'
374309885543Smrg	      tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"`
374409885543Smrg	    done
374509885543Smrg	  fi
374609885543Smrg	  if $echo "X $tmp_deplibs" | $Xsed -e 's/[ 	]//g' \
374709885543Smrg	    | grep . >/dev/null; then
374809885543Smrg	    $echo
374909885543Smrg	    if test "X$deplibs_check_method" = "Xnone"; then
375009885543Smrg	      $echo "*** Warning: inter-library dependencies are not supported in this platform."
375109885543Smrg	    else
375209885543Smrg	      $echo "*** Warning: inter-library dependencies are not known to be supported."
375309885543Smrg	    fi
375409885543Smrg	    $echo "*** All declared inter-library dependencies are being dropped."
375509885543Smrg	    droppeddeps=yes
375609885543Smrg	  fi
375709885543Smrg	  ;;
375809885543Smrg	esac
375909885543Smrg	versuffix=$versuffix_save
376009885543Smrg	major=$major_save
376109885543Smrg	release=$release_save
376209885543Smrg	libname=$libname_save
376309885543Smrg	name=$name_save
376409885543Smrg
376509885543Smrg	case $host in
376609885543Smrg	*-*-rhapsody* | *-*-darwin1.[012])
376709885543Smrg	  # On Rhapsody replace the C library is the System framework
376809885543Smrg	  newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'`
376909885543Smrg	  ;;
377009885543Smrg	esac
377109885543Smrg
377209885543Smrg	if test "$droppeddeps" = yes; then
377309885543Smrg	  if test "$module" = yes; then
377409885543Smrg	    $echo
377509885543Smrg	    $echo "*** Warning: libtool could not satisfy all declared inter-library"
377609885543Smrg	    $echo "*** dependencies of module $libname.  Therefore, libtool will create"
377709885543Smrg	    $echo "*** a static module, that should work as long as the dlopening"
377809885543Smrg	    $echo "*** application is linked with the -dlopen flag."
377909885543Smrg	    if test -z "$global_symbol_pipe"; then
378009885543Smrg	      $echo
378109885543Smrg	      $echo "*** However, this would only work if libtool was able to extract symbol"
378209885543Smrg	      $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
378309885543Smrg	      $echo "*** not find such a program.  So, this module is probably useless."
378409885543Smrg	      $echo "*** \`nm' from GNU binutils and a full rebuild may help."
378509885543Smrg	    fi
378609885543Smrg	    if test "$build_old_libs" = no; then
378709885543Smrg	      oldlibs="$output_objdir/$libname.$libext"
378809885543Smrg	      build_libtool_libs=module
378909885543Smrg	      build_old_libs=yes
379009885543Smrg	    else
379109885543Smrg	      build_libtool_libs=no
379209885543Smrg	    fi
379309885543Smrg	  else
379409885543Smrg	    $echo "*** The inter-library dependencies that have been dropped here will be"
379509885543Smrg	    $echo "*** automatically added whenever a program is linked with this library"
379609885543Smrg	    $echo "*** or is declared to -dlopen it."
379709885543Smrg
379809885543Smrg	    if test "$allow_undefined" = no; then
379909885543Smrg	      $echo
380009885543Smrg	      $echo "*** Since this library must not contain undefined symbols,"
380109885543Smrg	      $echo "*** because either the platform does not support them or"
380209885543Smrg	      $echo "*** it was explicitly requested with -no-undefined,"
380309885543Smrg	      $echo "*** libtool will only create a static version of it."
380409885543Smrg	      if test "$build_old_libs" = no; then
380509885543Smrg		oldlibs="$output_objdir/$libname.$libext"
380609885543Smrg		build_libtool_libs=module
380709885543Smrg		build_old_libs=yes
380809885543Smrg	      else
380909885543Smrg		build_libtool_libs=no
381009885543Smrg	      fi
381109885543Smrg	    fi
381209885543Smrg	  fi
381309885543Smrg	fi
381409885543Smrg	# Done checking deplibs!
381509885543Smrg	deplibs=$newdeplibs
381609885543Smrg      fi
381709885543Smrg
381809885543Smrg
381909885543Smrg      # move library search paths that coincide with paths to not yet
382009885543Smrg      # installed libraries to the beginning of the library search list
382109885543Smrg      new_libs=
382209885543Smrg      for path in $notinst_path; do
382309885543Smrg	case " $new_libs " in
382409885543Smrg	*" -L$path/$objdir "*) ;;
382509885543Smrg	*)
382609885543Smrg	  case " $deplibs " in
382709885543Smrg	  *" -L$path/$objdir "*)
382809885543Smrg	    new_libs="$new_libs -L$path/$objdir" ;;
382909885543Smrg	  esac
383009885543Smrg	  ;;
383109885543Smrg	esac
383209885543Smrg      done
383309885543Smrg      for deplib in $deplibs; do
383409885543Smrg	case $deplib in
383509885543Smrg	-L*)
383609885543Smrg	  case " $new_libs " in
383709885543Smrg	  *" $deplib "*) ;;
383809885543Smrg	  *) new_libs="$new_libs $deplib" ;;
383909885543Smrg	  esac
384009885543Smrg	  ;;
384109885543Smrg	*) new_libs="$new_libs $deplib" ;;
384209885543Smrg	esac
384309885543Smrg      done
384409885543Smrg      deplibs="$new_libs"
384509885543Smrg
384609885543Smrg
384709885543Smrg      # All the library-specific variables (install_libdir is set above).
384809885543Smrg      library_names=
384909885543Smrg      old_library=
385009885543Smrg      dlname=
385109885543Smrg
385209885543Smrg      # Test again, we may have decided not to build it any more
385309885543Smrg      if test "$build_libtool_libs" = yes; then
385409885543Smrg	if test "$hardcode_into_libs" = yes; then
385509885543Smrg	  # Hardcode the library paths
385609885543Smrg	  hardcode_libdirs=
385709885543Smrg	  dep_rpath=
385809885543Smrg	  rpath="$finalize_rpath"
385909885543Smrg	  test "$mode" != relink && rpath="$compile_rpath$rpath"
386009885543Smrg	  for libdir in $rpath; do
386109885543Smrg	    if test -n "$hardcode_libdir_flag_spec"; then
386209885543Smrg	      if test -n "$hardcode_libdir_separator"; then
386309885543Smrg		if test -z "$hardcode_libdirs"; then
386409885543Smrg		  hardcode_libdirs="$libdir"
386509885543Smrg		else
386609885543Smrg		  # Just accumulate the unique libdirs.
386709885543Smrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
386809885543Smrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
386909885543Smrg		    ;;
387009885543Smrg		  *)
387109885543Smrg		    hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
387209885543Smrg		    ;;
387309885543Smrg		  esac
387409885543Smrg		fi
387509885543Smrg	      else
387609885543Smrg		eval flag=\"$hardcode_libdir_flag_spec\"
387709885543Smrg		dep_rpath="$dep_rpath $flag"
387809885543Smrg	      fi
387909885543Smrg	    elif test -n "$runpath_var"; then
388009885543Smrg	      case "$perm_rpath " in
388109885543Smrg	      *" $libdir "*) ;;
388209885543Smrg	      *) perm_rpath="$perm_rpath $libdir" ;;
388309885543Smrg	      esac
388409885543Smrg	    fi
388509885543Smrg	  done
388609885543Smrg	  # Substitute the hardcoded libdirs into the rpath.
388709885543Smrg	  if test -n "$hardcode_libdir_separator" &&
388809885543Smrg	     test -n "$hardcode_libdirs"; then
388909885543Smrg	    libdir="$hardcode_libdirs"
389009885543Smrg	    if test -n "$hardcode_libdir_flag_spec_ld"; then
389109885543Smrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
389209885543Smrg	    else
389309885543Smrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
389409885543Smrg	    fi
389509885543Smrg	  fi
389609885543Smrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
389709885543Smrg	    # We should set the runpath_var.
389809885543Smrg	    rpath=
389909885543Smrg	    for dir in $perm_rpath; do
390009885543Smrg	      rpath="$rpath$dir:"
390109885543Smrg	    done
390209885543Smrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
390309885543Smrg	  fi
390409885543Smrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
390509885543Smrg	fi
390609885543Smrg
390709885543Smrg	shlibpath="$finalize_shlibpath"
390809885543Smrg	test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
390909885543Smrg	if test -n "$shlibpath"; then
391009885543Smrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
391109885543Smrg	fi
391209885543Smrg
391309885543Smrg	# Get the real and link names of the library.
391409885543Smrg	eval shared_ext=\"$shrext_cmds\"
391509885543Smrg	eval library_names=\"$library_names_spec\"
391609885543Smrg	set dummy $library_names
391709885543Smrg	realname="$2"
391809885543Smrg	shift; shift
391909885543Smrg
392009885543Smrg	if test -n "$soname_spec"; then
392109885543Smrg	  eval soname=\"$soname_spec\"
392209885543Smrg	else
392309885543Smrg	  soname="$realname"
392409885543Smrg	fi
392509885543Smrg	if test -z "$dlname"; then
392609885543Smrg	  dlname=$soname
392709885543Smrg	fi
392809885543Smrg
392909885543Smrg	lib="$output_objdir/$realname"
393009885543Smrg	linknames=
393109885543Smrg	for link
393209885543Smrg	do
393309885543Smrg	  linknames="$linknames $link"
393409885543Smrg	done
393509885543Smrg
393609885543Smrg	# Use standard objects if they are pic
393709885543Smrg	test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
393809885543Smrg
393909885543Smrg	# Prepare the list of exported symbols
394009885543Smrg	if test -z "$export_symbols"; then
394109885543Smrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
394209885543Smrg	    $show "generating symbol list for \`$libname.la'"
394309885543Smrg	    export_symbols="$output_objdir/$libname.exp"
394409885543Smrg	    $run $rm $export_symbols
394509885543Smrg	    cmds=$export_symbols_cmds
394609885543Smrg	    save_ifs="$IFS"; IFS='~'
394709885543Smrg	    for cmd in $cmds; do
394809885543Smrg	      IFS="$save_ifs"
394909885543Smrg	      eval cmd=\"$cmd\"
395009885543Smrg	      if len=`expr "X$cmd" : ".*"` &&
395109885543Smrg	       test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
395209885543Smrg	        $show "$cmd"
395309885543Smrg	        $run eval "$cmd" || exit $?
395409885543Smrg	        skipped_export=false
395509885543Smrg	      else
395609885543Smrg	        # The command line is too long to execute in one step.
395709885543Smrg	        $show "using reloadable object file for export list..."
395809885543Smrg	        skipped_export=:
395909885543Smrg		# Break out early, otherwise skipped_export may be
396009885543Smrg		# set to false by a later but shorter cmd.
396109885543Smrg		break
396209885543Smrg	      fi
396309885543Smrg	    done
396409885543Smrg	    IFS="$save_ifs"
396509885543Smrg	    if test -n "$export_symbols_regex"; then
396609885543Smrg	      $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""
396709885543Smrg	      $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
396809885543Smrg	      $show "$mv \"${export_symbols}T\" \"$export_symbols\""
396909885543Smrg	      $run eval '$mv "${export_symbols}T" "$export_symbols"'
397009885543Smrg	    fi
397109885543Smrg	  fi
397209885543Smrg	fi
397309885543Smrg
397409885543Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
397509885543Smrg	  $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"'
397609885543Smrg	fi
397709885543Smrg
397809885543Smrg	tmp_deplibs=
397909885543Smrg	for test_deplib in $deplibs; do
398009885543Smrg		case " $convenience " in
398109885543Smrg		*" $test_deplib "*) ;;
398209885543Smrg		*)
398309885543Smrg			tmp_deplibs="$tmp_deplibs $test_deplib"
398409885543Smrg			;;
398509885543Smrg		esac
398609885543Smrg	done
398709885543Smrg	deplibs="$tmp_deplibs"
398809885543Smrg
398909885543Smrg	if test -n "$convenience"; then
399009885543Smrg	  if test -n "$whole_archive_flag_spec"; then
399109885543Smrg	    save_libobjs=$libobjs
399209885543Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
399309885543Smrg	  else
399409885543Smrg	    gentop="$output_objdir/${outputname}x"
399509885543Smrg	    generated="$generated $gentop"
399609885543Smrg
399709885543Smrg	    func_extract_archives $gentop $convenience
399809885543Smrg	    libobjs="$libobjs $func_extract_archives_result"
399909885543Smrg	  fi
400009885543Smrg	fi
400109885543Smrg	
400209885543Smrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
400309885543Smrg	  eval flag=\"$thread_safe_flag_spec\"
400409885543Smrg	  linker_flags="$linker_flags $flag"
400509885543Smrg	fi
400609885543Smrg
400709885543Smrg	# Make a backup of the uninstalled library when relinking
400809885543Smrg	if test "$mode" = relink; then
400909885543Smrg	  $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $?
401009885543Smrg	fi
401109885543Smrg
401209885543Smrg	# Do each of the archive commands.
401309885543Smrg	if test "$module" = yes && test -n "$module_cmds" ; then
401409885543Smrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
401509885543Smrg	    eval test_cmds=\"$module_expsym_cmds\"
401609885543Smrg	    cmds=$module_expsym_cmds
401709885543Smrg	  else
401809885543Smrg	    eval test_cmds=\"$module_cmds\"
401909885543Smrg	    cmds=$module_cmds
402009885543Smrg	  fi
402109885543Smrg	else
402209885543Smrg	if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
402309885543Smrg	  eval test_cmds=\"$archive_expsym_cmds\"
402409885543Smrg	  cmds=$archive_expsym_cmds
402509885543Smrg	else
402609885543Smrg	  eval test_cmds=\"$archive_cmds\"
402709885543Smrg	  cmds=$archive_cmds
402809885543Smrg	  fi
402909885543Smrg	fi
403009885543Smrg
403109885543Smrg	if test "X$skipped_export" != "X:" &&
403209885543Smrg	   len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
403309885543Smrg	   test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
403409885543Smrg	  :
403509885543Smrg	else
403609885543Smrg	  # The command line is too long to link in one step, link piecewise.
403709885543Smrg	  $echo "creating reloadable object files..."
403809885543Smrg
403909885543Smrg	  # Save the value of $output and $libobjs because we want to
404009885543Smrg	  # use them later.  If we have whole_archive_flag_spec, we
404109885543Smrg	  # want to use save_libobjs as it was before
404209885543Smrg	  # whole_archive_flag_spec was expanded, because we can't
404309885543Smrg	  # assume the linker understands whole_archive_flag_spec.
404409885543Smrg	  # This may have to be revisited, in case too many
404509885543Smrg	  # convenience libraries get linked in and end up exceeding
404609885543Smrg	  # the spec.
404709885543Smrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
404809885543Smrg	    save_libobjs=$libobjs
404909885543Smrg	  fi
405009885543Smrg	  save_output=$output
405109885543Smrg	  output_la=`$echo "X$output" | $Xsed -e "$basename"`
405209885543Smrg
405309885543Smrg	  # Clear the reloadable object creation command queue and
405409885543Smrg	  # initialize k to one.
405509885543Smrg	  test_cmds=
405609885543Smrg	  concat_cmds=
405709885543Smrg	  objlist=
405809885543Smrg	  delfiles=
405909885543Smrg	  last_robj=
406009885543Smrg	  k=1
406109885543Smrg	  output=$output_objdir/$output_la-${k}.$objext
406209885543Smrg	  # Loop over the list of objects to be linked.
406309885543Smrg	  for obj in $save_libobjs
406409885543Smrg	  do
406509885543Smrg	    eval test_cmds=\"$reload_cmds $objlist $last_robj\"
406609885543Smrg	    if test "X$objlist" = X ||
406709885543Smrg	       { len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
406809885543Smrg		 test "$len" -le "$max_cmd_len"; }; then
406909885543Smrg	      objlist="$objlist $obj"
407009885543Smrg	    else
407109885543Smrg	      # The command $test_cmds is almost too long, add a
407209885543Smrg	      # command to the queue.
407309885543Smrg	      if test "$k" -eq 1 ; then
407409885543Smrg		# The first file doesn't have a previous command to add.
407509885543Smrg		eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
407609885543Smrg	      else
407709885543Smrg		# All subsequent reloadable object files will link in
407809885543Smrg		# the last one created.
407909885543Smrg		eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\"
408009885543Smrg	      fi
408109885543Smrg	      last_robj=$output_objdir/$output_la-${k}.$objext
408209885543Smrg	      k=`expr $k + 1`
408309885543Smrg	      output=$output_objdir/$output_la-${k}.$objext
408409885543Smrg	      objlist=$obj
408509885543Smrg	      len=1
408609885543Smrg	    fi
408709885543Smrg	  done
408809885543Smrg	  # Handle the remaining objects by creating one last
408909885543Smrg	  # reloadable object file.  All subsequent reloadable object
409009885543Smrg	  # files will link in the last one created.
409109885543Smrg	  test -z "$concat_cmds" || concat_cmds=$concat_cmds~
409209885543Smrg	  eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
409309885543Smrg
409409885543Smrg	  if ${skipped_export-false}; then
409509885543Smrg	    $show "generating symbol list for \`$libname.la'"
409609885543Smrg	    export_symbols="$output_objdir/$libname.exp"
409709885543Smrg	    $run $rm $export_symbols
409809885543Smrg	    libobjs=$output
409909885543Smrg	    # Append the command to create the export file.
410009885543Smrg	    eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\"
410109885543Smrg          fi
410209885543Smrg
410309885543Smrg	  # Set up a command to remove the reloadable object files
410409885543Smrg	  # after they are used.
410509885543Smrg	  i=0
410609885543Smrg	  while test "$i" -lt "$k"
410709885543Smrg	  do
410809885543Smrg	    i=`expr $i + 1`
410909885543Smrg	    delfiles="$delfiles $output_objdir/$output_la-${i}.$objext"
411009885543Smrg	  done
411109885543Smrg
411209885543Smrg	  $echo "creating a temporary reloadable object file: $output"
411309885543Smrg
411409885543Smrg	  # Loop through the commands generated above and execute them.
411509885543Smrg	  save_ifs="$IFS"; IFS='~'
411609885543Smrg	  for cmd in $concat_cmds; do
411709885543Smrg	    IFS="$save_ifs"
411809885543Smrg	    $show "$cmd"
411909885543Smrg	    $run eval "$cmd" || exit $?
412009885543Smrg	  done
412109885543Smrg	  IFS="$save_ifs"
412209885543Smrg
412309885543Smrg	  libobjs=$output
412409885543Smrg	  # Restore the value of output.
412509885543Smrg	  output=$save_output
412609885543Smrg
412709885543Smrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
412809885543Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
412909885543Smrg	  fi
413009885543Smrg	  # Expand the library linking commands again to reset the
413109885543Smrg	  # value of $libobjs for piecewise linking.
413209885543Smrg
413309885543Smrg	  # Do each of the archive commands.
413409885543Smrg	  if test "$module" = yes && test -n "$module_cmds" ; then
413509885543Smrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
413609885543Smrg	      cmds=$module_expsym_cmds
413709885543Smrg	    else
413809885543Smrg	      cmds=$module_cmds
413909885543Smrg	    fi
414009885543Smrg	  else
414109885543Smrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
414209885543Smrg	    cmds=$archive_expsym_cmds
414309885543Smrg	  else
414409885543Smrg	    cmds=$archive_cmds
414509885543Smrg	    fi
414609885543Smrg	  fi
414709885543Smrg
414809885543Smrg	  # Append the command to remove the reloadable object files
414909885543Smrg	  # to the just-reset $cmds.
415009885543Smrg	  eval cmds=\"\$cmds~\$rm $delfiles\"
415109885543Smrg	fi
415209885543Smrg	save_ifs="$IFS"; IFS='~'
415309885543Smrg	for cmd in $cmds; do
415409885543Smrg	  IFS="$save_ifs"
415509885543Smrg	  eval cmd=\"$cmd\"
415609885543Smrg	  $show "$cmd"
415709885543Smrg	  $run eval "$cmd" || {
415809885543Smrg	    lt_exit=$?
415909885543Smrg
416009885543Smrg	    # Restore the uninstalled library and exit
416109885543Smrg	    if test "$mode" = relink; then
416209885543Smrg	      $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
416309885543Smrg	    fi
416409885543Smrg
416509885543Smrg	    exit $lt_exit
416609885543Smrg	  }
416709885543Smrg	done
416809885543Smrg	IFS="$save_ifs"
416909885543Smrg
417009885543Smrg	# Restore the uninstalled library and exit
417109885543Smrg	if test "$mode" = relink; then
417209885543Smrg	  $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $?
417309885543Smrg
417409885543Smrg	  if test -n "$convenience"; then
417509885543Smrg	    if test -z "$whole_archive_flag_spec"; then
417609885543Smrg	      $show "${rm}r $gentop"
417709885543Smrg	      $run ${rm}r "$gentop"
417809885543Smrg	    fi
417909885543Smrg	  fi
418009885543Smrg
418109885543Smrg	  exit $EXIT_SUCCESS
418209885543Smrg	fi
418309885543Smrg
418409885543Smrg	# Create links to the real library.
418509885543Smrg	for linkname in $linknames; do
418609885543Smrg	  if test "$realname" != "$linkname"; then
418709885543Smrg	    $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)"
418809885543Smrg	    $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $?
418909885543Smrg	  fi
419009885543Smrg	done
419109885543Smrg
419209885543Smrg	# If -module or -export-dynamic was specified, set the dlname.
419309885543Smrg	if test "$module" = yes || test "$export_dynamic" = yes; then
419409885543Smrg	  # On all known operating systems, these are identical.
419509885543Smrg	  dlname="$soname"
419609885543Smrg	fi
419709885543Smrg      fi
419809885543Smrg      ;;
419909885543Smrg
420009885543Smrg    obj)
420109885543Smrg      if test -n "$deplibs"; then
420209885543Smrg	$echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2
420309885543Smrg      fi
420409885543Smrg
420509885543Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
420609885543Smrg	$echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
420709885543Smrg      fi
420809885543Smrg
420909885543Smrg      if test -n "$rpath"; then
421009885543Smrg	$echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2
421109885543Smrg      fi
421209885543Smrg
421309885543Smrg      if test -n "$xrpath"; then
421409885543Smrg	$echo "$modename: warning: \`-R' is ignored for objects" 1>&2
421509885543Smrg      fi
421609885543Smrg
421709885543Smrg      if test -n "$vinfo"; then
421809885543Smrg	$echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2
421909885543Smrg      fi
422009885543Smrg
422109885543Smrg      if test -n "$release"; then
422209885543Smrg	$echo "$modename: warning: \`-release' is ignored for objects" 1>&2
422309885543Smrg      fi
422409885543Smrg
422509885543Smrg      case $output in
422609885543Smrg      *.lo)
422709885543Smrg	if test -n "$objs$old_deplibs"; then
422809885543Smrg	  $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
422909885543Smrg	  exit $EXIT_FAILURE
423009885543Smrg	fi
423109885543Smrg	libobj="$output"
423209885543Smrg	obj=`$echo "X$output" | $Xsed -e "$lo2o"`
423309885543Smrg	;;
423409885543Smrg      *)
423509885543Smrg	libobj=
423609885543Smrg	obj="$output"
423709885543Smrg	;;
423809885543Smrg      esac
423909885543Smrg
424009885543Smrg      # Delete the old objects.
424109885543Smrg      $run $rm $obj $libobj
424209885543Smrg
424309885543Smrg      # Objects from convenience libraries.  This assumes
424409885543Smrg      # single-version convenience libraries.  Whenever we create
424509885543Smrg      # different ones for PIC/non-PIC, this we'll have to duplicate
424609885543Smrg      # the extraction.
424709885543Smrg      reload_conv_objs=
424809885543Smrg      gentop=
424909885543Smrg      # reload_cmds runs $LD directly, so let us get rid of
425009885543Smrg      # -Wl from whole_archive_flag_spec
425109885543Smrg      wl=
425209885543Smrg
425309885543Smrg      if test -n "$convenience"; then
425409885543Smrg	if test -n "$whole_archive_flag_spec"; then
425509885543Smrg	  eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
425609885543Smrg	else
425709885543Smrg	  gentop="$output_objdir/${obj}x"
425809885543Smrg	  generated="$generated $gentop"
425909885543Smrg
426009885543Smrg	  func_extract_archives $gentop $convenience
426109885543Smrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
426209885543Smrg	fi
426309885543Smrg      fi
426409885543Smrg
426509885543Smrg      # Create the old-style object.
426609885543Smrg      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
426709885543Smrg
426809885543Smrg      output="$obj"
426909885543Smrg      cmds=$reload_cmds
427009885543Smrg      save_ifs="$IFS"; IFS='~'
427109885543Smrg      for cmd in $cmds; do
427209885543Smrg	IFS="$save_ifs"
427309885543Smrg	eval cmd=\"$cmd\"
427409885543Smrg	$show "$cmd"
427509885543Smrg	$run eval "$cmd" || exit $?
427609885543Smrg      done
427709885543Smrg      IFS="$save_ifs"
427809885543Smrg
427909885543Smrg      # Exit if we aren't doing a library object file.
428009885543Smrg      if test -z "$libobj"; then
428109885543Smrg	if test -n "$gentop"; then
428209885543Smrg	  $show "${rm}r $gentop"
428309885543Smrg	  $run ${rm}r $gentop
428409885543Smrg	fi
428509885543Smrg
428609885543Smrg	exit $EXIT_SUCCESS
428709885543Smrg      fi
428809885543Smrg
428909885543Smrg      if test "$build_libtool_libs" != yes; then
429009885543Smrg	if test -n "$gentop"; then
429109885543Smrg	  $show "${rm}r $gentop"
429209885543Smrg	  $run ${rm}r $gentop
429309885543Smrg	fi
429409885543Smrg
429509885543Smrg	# Create an invalid libtool object if no PIC, so that we don't
429609885543Smrg	# accidentally link it into a program.
429709885543Smrg	# $show "echo timestamp > $libobj"
429809885543Smrg	# $run eval "echo timestamp > $libobj" || exit $?
429909885543Smrg	exit $EXIT_SUCCESS
430009885543Smrg      fi
430109885543Smrg
430209885543Smrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
430309885543Smrg	# Only do commands if we really have different PIC objects.
430409885543Smrg	reload_objs="$libobjs $reload_conv_objs"
430509885543Smrg	output="$libobj"
430609885543Smrg	cmds=$reload_cmds
430709885543Smrg	save_ifs="$IFS"; IFS='~'
430809885543Smrg	for cmd in $cmds; do
430909885543Smrg	  IFS="$save_ifs"
431009885543Smrg	  eval cmd=\"$cmd\"
431109885543Smrg	  $show "$cmd"
431209885543Smrg	  $run eval "$cmd" || exit $?
431309885543Smrg	done
431409885543Smrg	IFS="$save_ifs"
431509885543Smrg      fi
431609885543Smrg
431709885543Smrg      if test -n "$gentop"; then
431809885543Smrg	$show "${rm}r $gentop"
431909885543Smrg	$run ${rm}r $gentop
432009885543Smrg      fi
432109885543Smrg
432209885543Smrg      exit $EXIT_SUCCESS
432309885543Smrg      ;;
432409885543Smrg
432509885543Smrg    prog)
432609885543Smrg      case $host in
432709885543Smrg	*cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;
432809885543Smrg      esac
432909885543Smrg      if test -n "$vinfo"; then
433009885543Smrg	$echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
433109885543Smrg      fi
433209885543Smrg
433309885543Smrg      if test -n "$release"; then
433409885543Smrg	$echo "$modename: warning: \`-release' is ignored for programs" 1>&2
433509885543Smrg      fi
433609885543Smrg
433709885543Smrg      if test "$preload" = yes; then
433809885543Smrg	if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown &&
433909885543Smrg	   test "$dlopen_self_static" = unknown; then
434009885543Smrg	  $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support."
434109885543Smrg	fi
434209885543Smrg      fi
434309885543Smrg
434409885543Smrg      case $host in
434509885543Smrg      *-*-rhapsody* | *-*-darwin1.[012])
434609885543Smrg	# On Rhapsody replace the C library is the System framework
434709885543Smrg	compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
434809885543Smrg	finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
434909885543Smrg	;;
435009885543Smrg      esac
435109885543Smrg
435209885543Smrg      case $host in
435309885543Smrg      *darwin*)
435409885543Smrg        # Don't allow lazy linking, it breaks C++ global constructors
435509885543Smrg        if test "$tagname" = CXX ; then
435609885543Smrg        compile_command="$compile_command ${wl}-bind_at_load"
435709885543Smrg        finalize_command="$finalize_command ${wl}-bind_at_load"
435809885543Smrg        fi
435909885543Smrg        ;;
436009885543Smrg      esac
436109885543Smrg
436209885543Smrg
436309885543Smrg      # move library search paths that coincide with paths to not yet
436409885543Smrg      # installed libraries to the beginning of the library search list
436509885543Smrg      new_libs=
436609885543Smrg      for path in $notinst_path; do
436709885543Smrg	case " $new_libs " in
436809885543Smrg	*" -L$path/$objdir "*) ;;
436909885543Smrg	*)
437009885543Smrg	  case " $compile_deplibs " in
437109885543Smrg	  *" -L$path/$objdir "*)
437209885543Smrg	    new_libs="$new_libs -L$path/$objdir" ;;
437309885543Smrg	  esac
437409885543Smrg	  ;;
437509885543Smrg	esac
437609885543Smrg      done
437709885543Smrg      for deplib in $compile_deplibs; do
437809885543Smrg	case $deplib in
437909885543Smrg	-L*)
438009885543Smrg	  case " $new_libs " in
438109885543Smrg	  *" $deplib "*) ;;
438209885543Smrg	  *) new_libs="$new_libs $deplib" ;;
438309885543Smrg	  esac
438409885543Smrg	  ;;
438509885543Smrg	*) new_libs="$new_libs $deplib" ;;
438609885543Smrg	esac
438709885543Smrg      done
438809885543Smrg      compile_deplibs="$new_libs"
438909885543Smrg
439009885543Smrg
439109885543Smrg      compile_command="$compile_command $compile_deplibs"
439209885543Smrg      finalize_command="$finalize_command $finalize_deplibs"
439309885543Smrg
439409885543Smrg      if test -n "$rpath$xrpath"; then
439509885543Smrg	# If the user specified any rpath flags, then add them.
439609885543Smrg	for libdir in $rpath $xrpath; do
439709885543Smrg	  # This is the magic to use -rpath.
439809885543Smrg	  case "$finalize_rpath " in
439909885543Smrg	  *" $libdir "*) ;;
440009885543Smrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
440109885543Smrg	  esac
440209885543Smrg	done
440309885543Smrg      fi
440409885543Smrg
440509885543Smrg      # Now hardcode the library paths
440609885543Smrg      rpath=
440709885543Smrg      hardcode_libdirs=
440809885543Smrg      for libdir in $compile_rpath $finalize_rpath; do
440909885543Smrg	if test -n "$hardcode_libdir_flag_spec"; then
441009885543Smrg	  if test -n "$hardcode_libdir_separator"; then
441109885543Smrg	    if test -z "$hardcode_libdirs"; then
441209885543Smrg	      hardcode_libdirs="$libdir"
441309885543Smrg	    else
441409885543Smrg	      # Just accumulate the unique libdirs.
441509885543Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
441609885543Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
441709885543Smrg		;;
441809885543Smrg	      *)
441909885543Smrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
442009885543Smrg		;;
442109885543Smrg	      esac
442209885543Smrg	    fi
442309885543Smrg	  else
442409885543Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
442509885543Smrg	    rpath="$rpath $flag"
442609885543Smrg	  fi
442709885543Smrg	elif test -n "$runpath_var"; then
442809885543Smrg	  case "$perm_rpath " in
442909885543Smrg	  *" $libdir "*) ;;
443009885543Smrg	  *) perm_rpath="$perm_rpath $libdir" ;;
443109885543Smrg	  esac
443209885543Smrg	fi
443309885543Smrg	case $host in
443409885543Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
443509885543Smrg	  testbindir=`$echo "X$libdir" | $Xsed -e 's*/lib$*/bin*'`
443609885543Smrg	  case :$dllsearchpath: in
443709885543Smrg	  *":$libdir:"*) ;;
443809885543Smrg	  *) dllsearchpath="$dllsearchpath:$libdir";;
443909885543Smrg	  esac
444009885543Smrg	  case :$dllsearchpath: in
444109885543Smrg	  *":$testbindir:"*) ;;
444209885543Smrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
444309885543Smrg	  esac
444409885543Smrg	  ;;
444509885543Smrg	esac
444609885543Smrg      done
444709885543Smrg      # Substitute the hardcoded libdirs into the rpath.
444809885543Smrg      if test -n "$hardcode_libdir_separator" &&
444909885543Smrg	 test -n "$hardcode_libdirs"; then
445009885543Smrg	libdir="$hardcode_libdirs"
445109885543Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
445209885543Smrg      fi
445309885543Smrg      compile_rpath="$rpath"
445409885543Smrg
445509885543Smrg      rpath=
445609885543Smrg      hardcode_libdirs=
445709885543Smrg      for libdir in $finalize_rpath; do
445809885543Smrg	if test -n "$hardcode_libdir_flag_spec"; then
445909885543Smrg	  if test -n "$hardcode_libdir_separator"; then
446009885543Smrg	    if test -z "$hardcode_libdirs"; then
446109885543Smrg	      hardcode_libdirs="$libdir"
446209885543Smrg	    else
446309885543Smrg	      # Just accumulate the unique libdirs.
446409885543Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
446509885543Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
446609885543Smrg		;;
446709885543Smrg	      *)
446809885543Smrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
446909885543Smrg		;;
447009885543Smrg	      esac
447109885543Smrg	    fi
447209885543Smrg	  else
447309885543Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
447409885543Smrg	    rpath="$rpath $flag"
447509885543Smrg	  fi
447609885543Smrg	elif test -n "$runpath_var"; then
447709885543Smrg	  case "$finalize_perm_rpath " in
447809885543Smrg	  *" $libdir "*) ;;
447909885543Smrg	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
448009885543Smrg	  esac
448109885543Smrg	fi
448209885543Smrg      done
448309885543Smrg      # Substitute the hardcoded libdirs into the rpath.
448409885543Smrg      if test -n "$hardcode_libdir_separator" &&
448509885543Smrg	 test -n "$hardcode_libdirs"; then
448609885543Smrg	libdir="$hardcode_libdirs"
448709885543Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
448809885543Smrg      fi
448909885543Smrg      finalize_rpath="$rpath"
449009885543Smrg
449109885543Smrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
449209885543Smrg	# Transform all the library objects into standard objects.
449309885543Smrg	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
449409885543Smrg	finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
449509885543Smrg      fi
449609885543Smrg
449709885543Smrg      dlsyms=
449809885543Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
449909885543Smrg	if test -n "$NM" && test -n "$global_symbol_pipe"; then
450009885543Smrg	  dlsyms="${outputname}S.c"
450109885543Smrg	else
450209885543Smrg	  $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2
450309885543Smrg	fi
450409885543Smrg      fi
450509885543Smrg
450609885543Smrg      if test -n "$dlsyms"; then
450709885543Smrg	case $dlsyms in
450809885543Smrg	"") ;;
450909885543Smrg	*.c)
451009885543Smrg	  # Discover the nlist of each of the dlfiles.
451109885543Smrg	  nlist="$output_objdir/${outputname}.nm"
451209885543Smrg
451309885543Smrg	  $show "$rm $nlist ${nlist}S ${nlist}T"
451409885543Smrg	  $run $rm "$nlist" "${nlist}S" "${nlist}T"
451509885543Smrg
451609885543Smrg	  # Parse the name list into a source file.
451709885543Smrg	  $show "creating $output_objdir/$dlsyms"
451809885543Smrg
451909885543Smrg	  test -z "$run" && $echo > "$output_objdir/$dlsyms" "\
452009885543Smrg/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */
452109885543Smrg/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */
452209885543Smrg
452309885543Smrg#ifdef __cplusplus
452409885543Smrgextern \"C\" {
452509885543Smrg#endif
452609885543Smrg
452709885543Smrg/* Prevent the only kind of declaration conflicts we can make. */
452809885543Smrg#define lt_preloaded_symbols some_other_symbol
452909885543Smrg
453009885543Smrg/* External symbol declarations for the compiler. */\
453109885543Smrg"
453209885543Smrg
453309885543Smrg	  if test "$dlself" = yes; then
453409885543Smrg	    $show "generating symbol list for \`$output'"
453509885543Smrg
453609885543Smrg	    test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist"
453709885543Smrg
453809885543Smrg	    # Add our own program objects to the symbol list.
453909885543Smrg	    progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
454009885543Smrg	    for arg in $progfiles; do
454109885543Smrg	      $show "extracting global C symbols from \`$arg'"
454209885543Smrg	      $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
454309885543Smrg	    done
454409885543Smrg
454509885543Smrg	    if test -n "$exclude_expsyms"; then
454609885543Smrg	      $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
454709885543Smrg	      $run eval '$mv "$nlist"T "$nlist"'
454809885543Smrg	    fi
454909885543Smrg
455009885543Smrg	    if test -n "$export_symbols_regex"; then
455109885543Smrg	      $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
455209885543Smrg	      $run eval '$mv "$nlist"T "$nlist"'
455309885543Smrg	    fi
455409885543Smrg
455509885543Smrg	    # Prepare the list of exported symbols
455609885543Smrg	    if test -z "$export_symbols"; then
455709885543Smrg	      export_symbols="$output_objdir/$outputname.exp"
455809885543Smrg	      $run $rm $export_symbols
455909885543Smrg	      $run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
456009885543Smrg              case $host in
456109885543Smrg              *cygwin* | *mingw* )
456209885543Smrg	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
456309885543Smrg		$run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
456409885543Smrg                ;;
456509885543Smrg              esac
456609885543Smrg	    else
456709885543Smrg	      $run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
456809885543Smrg	      $run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
456909885543Smrg	      $run eval 'mv "$nlist"T "$nlist"'
457009885543Smrg              case $host in
457109885543Smrg              *cygwin* | *mingw* )
457209885543Smrg	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
457309885543Smrg		$run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
457409885543Smrg                ;;
457509885543Smrg              esac
457609885543Smrg	    fi
457709885543Smrg	  fi
457809885543Smrg
457909885543Smrg	  for arg in $dlprefiles; do
458009885543Smrg	    $show "extracting global C symbols from \`$arg'"
458109885543Smrg	    name=`$echo "$arg" | ${SED} -e 's%^.*/%%'`
458209885543Smrg	    $run eval '$echo ": $name " >> "$nlist"'
458309885543Smrg	    $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
458409885543Smrg	  done
458509885543Smrg
458609885543Smrg	  if test -z "$run"; then
458709885543Smrg	    # Make sure we have at least an empty file.
458809885543Smrg	    test -f "$nlist" || : > "$nlist"
458909885543Smrg
459009885543Smrg	    if test -n "$exclude_expsyms"; then
459109885543Smrg	      $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
459209885543Smrg	      $mv "$nlist"T "$nlist"
459309885543Smrg	    fi
459409885543Smrg
459509885543Smrg	    # Try sorting and uniquifying the output.
459609885543Smrg	    if grep -v "^: " < "$nlist" |
459709885543Smrg		if sort -k 3 </dev/null >/dev/null 2>&1; then
459809885543Smrg		  sort -k 3
459909885543Smrg		else
460009885543Smrg		  sort +2
460109885543Smrg		fi |
460209885543Smrg		uniq > "$nlist"S; then
460309885543Smrg	      :
460409885543Smrg	    else
460509885543Smrg	      grep -v "^: " < "$nlist" > "$nlist"S
460609885543Smrg	    fi
460709885543Smrg
460809885543Smrg	    if test -f "$nlist"S; then
460909885543Smrg	      eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"'
461009885543Smrg	    else
461109885543Smrg	      $echo '/* NONE */' >> "$output_objdir/$dlsyms"
461209885543Smrg	    fi
461309885543Smrg
461409885543Smrg	    $echo >> "$output_objdir/$dlsyms" "\
461509885543Smrg
461609885543Smrg#undef lt_preloaded_symbols
461709885543Smrg
461809885543Smrg#if defined (__STDC__) && __STDC__
461909885543Smrg# define lt_ptr void *
462009885543Smrg#else
462109885543Smrg# define lt_ptr char *
462209885543Smrg# define const
462309885543Smrg#endif
462409885543Smrg
462509885543Smrg/* The mapping between symbol names and symbols. */
462609885543Smrg"
462709885543Smrg
462809885543Smrg	    case $host in
462909885543Smrg	    *cygwin* | *mingw* )
463009885543Smrg	  $echo >> "$output_objdir/$dlsyms" "\
463109885543Smrg/* DATA imports from DLLs on WIN32 can't be const, because
463209885543Smrg   runtime relocations are performed -- see ld's documentation
463309885543Smrg   on pseudo-relocs */
463409885543Smrgstruct {
463509885543Smrg"
463609885543Smrg	      ;;
463709885543Smrg	    * )
463809885543Smrg	  $echo >> "$output_objdir/$dlsyms" "\
463909885543Smrgconst struct {
464009885543Smrg"
464109885543Smrg	      ;;
464209885543Smrg	    esac
464309885543Smrg
464409885543Smrg
464509885543Smrg	  $echo >> "$output_objdir/$dlsyms" "\
464609885543Smrg  const char *name;
464709885543Smrg  lt_ptr address;
464809885543Smrg}
464909885543Smrglt_preloaded_symbols[] =
465009885543Smrg{\
465109885543Smrg"
465209885543Smrg
465309885543Smrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms"
465409885543Smrg
465509885543Smrg	    $echo >> "$output_objdir/$dlsyms" "\
465609885543Smrg  {0, (lt_ptr) 0}
465709885543Smrg};
465809885543Smrg
465909885543Smrg/* This works around a problem in FreeBSD linker */
466009885543Smrg#ifdef FREEBSD_WORKAROUND
466109885543Smrgstatic const void *lt_preloaded_setup() {
466209885543Smrg  return lt_preloaded_symbols;
466309885543Smrg}
466409885543Smrg#endif
466509885543Smrg
466609885543Smrg#ifdef __cplusplus
466709885543Smrg}
466809885543Smrg#endif\
466909885543Smrg"
467009885543Smrg	  fi
467109885543Smrg
467209885543Smrg	  pic_flag_for_symtable=
467309885543Smrg	  case $host in
467409885543Smrg	  # compiling the symbol table file with pic_flag works around
467509885543Smrg	  # a FreeBSD bug that causes programs to crash when -lm is
467609885543Smrg	  # linked before any other PIC object.  But we must not use
467709885543Smrg	  # pic_flag when linking with -static.  The problem exists in
467809885543Smrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
467909885543Smrg	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
468009885543Smrg	    case "$compile_command " in
468109885543Smrg	    *" -static "*) ;;
468209885543Smrg	    *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";;
468309885543Smrg	    esac;;
468409885543Smrg	  *-*-hpux*)
468509885543Smrg	    case "$compile_command " in
468609885543Smrg	    *" -static "*) ;;
468709885543Smrg	    *) pic_flag_for_symtable=" $pic_flag";;
468809885543Smrg	    esac
468909885543Smrg	  esac
469009885543Smrg
469109885543Smrg	  # Now compile the dynamic symbol file.
469209885543Smrg	  $show "(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
469309885543Smrg	  $run eval '(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
469409885543Smrg
469509885543Smrg	  # Clean up the generated files.
469609885543Smrg	  $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
469709885543Smrg	  $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
469809885543Smrg
469909885543Smrg	  # Transform the symbol file into the correct name.
470009885543Smrg          case $host in
470109885543Smrg          *cygwin* | *mingw* )
470209885543Smrg            if test -f "$output_objdir/${outputname}.def" ; then
470309885543Smrg              compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
470409885543Smrg              finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
470509885543Smrg            else
470609885543Smrg              compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
470709885543Smrg              finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
470809885543Smrg             fi
470909885543Smrg            ;;
471009885543Smrg          * )
471109885543Smrg            compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
471209885543Smrg            finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
471309885543Smrg            ;;
471409885543Smrg          esac
471509885543Smrg	  ;;
471609885543Smrg	*)
471709885543Smrg	  $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
471809885543Smrg	  exit $EXIT_FAILURE
471909885543Smrg	  ;;
472009885543Smrg	esac
472109885543Smrg      else
472209885543Smrg	# We keep going just in case the user didn't refer to
472309885543Smrg	# lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
472409885543Smrg	# really was required.
472509885543Smrg
472609885543Smrg	# Nullify the symbol file.
472709885543Smrg	compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
472809885543Smrg	finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
472909885543Smrg      fi
473009885543Smrg
473109885543Smrg      if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
473209885543Smrg	# Replace the output file specification.
473309885543Smrg	compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
473409885543Smrg	link_command="$compile_command$compile_rpath"
473509885543Smrg
473609885543Smrg	# We have no uninstalled library dependencies, so finalize right now.
473709885543Smrg	$show "$link_command"
473809885543Smrg	$run eval "$link_command"
473909885543Smrg	exit_status=$?
474009885543Smrg
474109885543Smrg	# Delete the generated files.
474209885543Smrg	if test -n "$dlsyms"; then
474309885543Smrg	  $show "$rm $output_objdir/${outputname}S.${objext}"
474409885543Smrg	  $run $rm "$output_objdir/${outputname}S.${objext}"
474509885543Smrg	fi
474609885543Smrg
474709885543Smrg	exit $exit_status
474809885543Smrg      fi
474909885543Smrg
475009885543Smrg      if test -n "$shlibpath_var"; then
475109885543Smrg	# We should set the shlibpath_var
475209885543Smrg	rpath=
475309885543Smrg	for dir in $temp_rpath; do
475409885543Smrg	  case $dir in
475509885543Smrg	  [\\/]* | [A-Za-z]:[\\/]*)
475609885543Smrg	    # Absolute path.
475709885543Smrg	    rpath="$rpath$dir:"
475809885543Smrg	    ;;
475909885543Smrg	  *)
476009885543Smrg	    # Relative path: add a thisdir entry.
476109885543Smrg	    rpath="$rpath\$thisdir/$dir:"
476209885543Smrg	    ;;
476309885543Smrg	  esac
476409885543Smrg	done
476509885543Smrg	temp_rpath="$rpath"
476609885543Smrg      fi
476709885543Smrg
476809885543Smrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
476909885543Smrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
477009885543Smrg      fi
477109885543Smrg      if test -n "$finalize_shlibpath"; then
477209885543Smrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
477309885543Smrg      fi
477409885543Smrg
477509885543Smrg      compile_var=
477609885543Smrg      finalize_var=
477709885543Smrg      if test -n "$runpath_var"; then
477809885543Smrg	if test -n "$perm_rpath"; then
477909885543Smrg	  # We should set the runpath_var.
478009885543Smrg	  rpath=
478109885543Smrg	  for dir in $perm_rpath; do
478209885543Smrg	    rpath="$rpath$dir:"
478309885543Smrg	  done
478409885543Smrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
478509885543Smrg	fi
478609885543Smrg	if test -n "$finalize_perm_rpath"; then
478709885543Smrg	  # We should set the runpath_var.
478809885543Smrg	  rpath=
478909885543Smrg	  for dir in $finalize_perm_rpath; do
479009885543Smrg	    rpath="$rpath$dir:"
479109885543Smrg	  done
479209885543Smrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
479309885543Smrg	fi
479409885543Smrg      fi
479509885543Smrg
479609885543Smrg      if test "$no_install" = yes; then
479709885543Smrg	# We don't need to create a wrapper script.
479809885543Smrg	link_command="$compile_var$compile_command$compile_rpath"
479909885543Smrg	# Replace the output file specification.
480009885543Smrg	link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
480109885543Smrg	# Delete the old output file.
480209885543Smrg	$run $rm $output
480309885543Smrg	# Link the executable and exit
480409885543Smrg	$show "$link_command"
480509885543Smrg	$run eval "$link_command" || exit $?
480609885543Smrg	exit $EXIT_SUCCESS
480709885543Smrg      fi
480809885543Smrg
480909885543Smrg      if test "$hardcode_action" = relink; then
481009885543Smrg	# Fast installation is not supported
481109885543Smrg	link_command="$compile_var$compile_command$compile_rpath"
481209885543Smrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
481309885543Smrg
481409885543Smrg	$echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2
481509885543Smrg	$echo "$modename: \`$output' will be relinked during installation" 1>&2
481609885543Smrg      else
481709885543Smrg	if test "$fast_install" != no; then
481809885543Smrg	  link_command="$finalize_var$compile_command$finalize_rpath"
481909885543Smrg	  if test "$fast_install" = yes; then
482009885543Smrg	    relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
482109885543Smrg	  else
482209885543Smrg	    # fast_install is set to needless
482309885543Smrg	    relink_command=
482409885543Smrg	  fi
482509885543Smrg	else
482609885543Smrg	  link_command="$compile_var$compile_command$compile_rpath"
482709885543Smrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
482809885543Smrg	fi
482909885543Smrg      fi
483009885543Smrg
483109885543Smrg      # Replace the output file specification.
483209885543Smrg      link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
483309885543Smrg
483409885543Smrg      # Delete the old output files.
483509885543Smrg      $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname
483609885543Smrg
483709885543Smrg      $show "$link_command"
483809885543Smrg      $run eval "$link_command" || exit $?
483909885543Smrg
484009885543Smrg      # Now create the wrapper script.
484109885543Smrg      $show "creating $output"
484209885543Smrg
484309885543Smrg      # Quote the relink command for shipping.
484409885543Smrg      if test -n "$relink_command"; then
484509885543Smrg	# Preserve any variables that may affect compiler behavior
484609885543Smrg	for var in $variables_saved_for_relink; do
484709885543Smrg	  if eval test -z \"\${$var+set}\"; then
484809885543Smrg	    relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
484909885543Smrg	  elif eval var_value=\$$var; test -z "$var_value"; then
485009885543Smrg	    relink_command="$var=; export $var; $relink_command"
485109885543Smrg	  else
485209885543Smrg	    var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
485309885543Smrg	    relink_command="$var=\"$var_value\"; export $var; $relink_command"
485409885543Smrg	  fi
485509885543Smrg	done
485609885543Smrg	relink_command="(cd `pwd`; $relink_command)"
485709885543Smrg	relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
485809885543Smrg      fi
485909885543Smrg
486009885543Smrg      # Quote $echo for shipping.
486109885543Smrg      if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then
486209885543Smrg	case $progpath in
486309885543Smrg	[\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
486409885543Smrg	*) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
486509885543Smrg	esac
486609885543Smrg	qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"`
486709885543Smrg      else
486809885543Smrg	qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"`
486909885543Smrg      fi
487009885543Smrg
487109885543Smrg      # Only actually do things if our run command is non-null.
487209885543Smrg      if test -z "$run"; then
487309885543Smrg	# win32 will think the script is a binary if it has
487409885543Smrg	# a .exe suffix, so we strip it off here.
487509885543Smrg	case $output in
487609885543Smrg	  *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;;
487709885543Smrg	esac
487809885543Smrg	# test for cygwin because mv fails w/o .exe extensions
487909885543Smrg	case $host in
488009885543Smrg	  *cygwin*)
488109885543Smrg	    exeext=.exe
488209885543Smrg	    outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;;
488309885543Smrg	  *) exeext= ;;
488409885543Smrg	esac
488509885543Smrg	case $host in
488609885543Smrg	  *cygwin* | *mingw* )
488709885543Smrg            output_name=`basename $output`
488809885543Smrg            output_path=`dirname $output`
488909885543Smrg            cwrappersource="$output_path/$objdir/lt-$output_name.c"
489009885543Smrg            cwrapper="$output_path/$output_name.exe"
489109885543Smrg            $rm $cwrappersource $cwrapper
489209885543Smrg            trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
489309885543Smrg
489409885543Smrg	    cat > $cwrappersource <<EOF
489509885543Smrg
489609885543Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
489709885543Smrg   Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
489809885543Smrg
489909885543Smrg   The $output program cannot be directly executed until all the libtool
490009885543Smrg   libraries that it depends on are installed.
490109885543Smrg
490209885543Smrg   This wrapper executable should never be moved out of the build directory.
490309885543Smrg   If it is, it will not operate correctly.
490409885543Smrg
490509885543Smrg   Currently, it simply execs the wrapper *script* "/bin/sh $output",
490609885543Smrg   but could eventually absorb all of the scripts functionality and
490709885543Smrg   exec $objdir/$outputname directly.
490809885543Smrg*/
490909885543SmrgEOF
491009885543Smrg	    cat >> $cwrappersource<<"EOF"
491109885543Smrg#include <stdio.h>
491209885543Smrg#include <stdlib.h>
491309885543Smrg#include <unistd.h>
491409885543Smrg#include <malloc.h>
491509885543Smrg#include <stdarg.h>
491609885543Smrg#include <assert.h>
491709885543Smrg#include <string.h>
491809885543Smrg#include <ctype.h>
491909885543Smrg#include <sys/stat.h>
492009885543Smrg
492109885543Smrg#if defined(PATH_MAX)
492209885543Smrg# define LT_PATHMAX PATH_MAX
492309885543Smrg#elif defined(MAXPATHLEN)
492409885543Smrg# define LT_PATHMAX MAXPATHLEN
492509885543Smrg#else
492609885543Smrg# define LT_PATHMAX 1024
492709885543Smrg#endif
492809885543Smrg
492909885543Smrg#ifndef DIR_SEPARATOR
493009885543Smrg# define DIR_SEPARATOR '/'
493109885543Smrg# define PATH_SEPARATOR ':'
493209885543Smrg#endif
493309885543Smrg
493409885543Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
493509885543Smrg  defined (__OS2__)
493609885543Smrg# define HAVE_DOS_BASED_FILE_SYSTEM
493709885543Smrg# ifndef DIR_SEPARATOR_2
493809885543Smrg#  define DIR_SEPARATOR_2 '\\'
493909885543Smrg# endif
494009885543Smrg# ifndef PATH_SEPARATOR_2
494109885543Smrg#  define PATH_SEPARATOR_2 ';'
494209885543Smrg# endif
494309885543Smrg#endif
494409885543Smrg
494509885543Smrg#ifndef DIR_SEPARATOR_2
494609885543Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
494709885543Smrg#else /* DIR_SEPARATOR_2 */
494809885543Smrg# define IS_DIR_SEPARATOR(ch) \
494909885543Smrg        (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
495009885543Smrg#endif /* DIR_SEPARATOR_2 */
495109885543Smrg
495209885543Smrg#ifndef PATH_SEPARATOR_2
495309885543Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
495409885543Smrg#else /* PATH_SEPARATOR_2 */
495509885543Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
495609885543Smrg#endif /* PATH_SEPARATOR_2 */
495709885543Smrg
495809885543Smrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
495909885543Smrg#define XFREE(stale) do { \
496009885543Smrg  if (stale) { free ((void *) stale); stale = 0; } \
496109885543Smrg} while (0)
496209885543Smrg
496309885543Smrg/* -DDEBUG is fairly common in CFLAGS.  */
496409885543Smrg#undef DEBUG
496509885543Smrg#if defined DEBUGWRAPPER
496609885543Smrg# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
496709885543Smrg#else
496809885543Smrg# define DEBUG(format, ...)
496909885543Smrg#endif
497009885543Smrg
497109885543Smrgconst char *program_name = NULL;
497209885543Smrg
497309885543Smrgvoid * xmalloc (size_t num);
497409885543Smrgchar * xstrdup (const char *string);
497509885543Smrgconst char * base_name (const char *name);
497609885543Smrgchar * find_executable(const char *wrapper);
497709885543Smrgint    check_executable(const char *path);
497809885543Smrgchar * strendzap(char *str, const char *pat);
497909885543Smrgvoid lt_fatal (const char *message, ...);
498009885543Smrg
498109885543Smrgint
498209885543Smrgmain (int argc, char *argv[])
498309885543Smrg{
498409885543Smrg  char **newargz;
498509885543Smrg  int i;
498609885543Smrg
498709885543Smrg  program_name = (char *) xstrdup (base_name (argv[0]));
498809885543Smrg  DEBUG("(main) argv[0]      : %s\n",argv[0]);
498909885543Smrg  DEBUG("(main) program_name : %s\n",program_name);
499009885543Smrg  newargz = XMALLOC(char *, argc+2);
499109885543SmrgEOF
499209885543Smrg
499309885543Smrg            cat >> $cwrappersource <<EOF
499409885543Smrg  newargz[0] = (char *) xstrdup("$SHELL");
499509885543SmrgEOF
499609885543Smrg
499709885543Smrg            cat >> $cwrappersource <<"EOF"
499809885543Smrg  newargz[1] = find_executable(argv[0]);
499909885543Smrg  if (newargz[1] == NULL)
500009885543Smrg    lt_fatal("Couldn't find %s", argv[0]);
500109885543Smrg  DEBUG("(main) found exe at : %s\n",newargz[1]);
500209885543Smrg  /* we know the script has the same name, without the .exe */
500309885543Smrg  /* so make sure newargz[1] doesn't end in .exe */
500409885543Smrg  strendzap(newargz[1],".exe");
500509885543Smrg  for (i = 1; i < argc; i++)
500609885543Smrg    newargz[i+1] = xstrdup(argv[i]);
500709885543Smrg  newargz[argc+1] = NULL;
500809885543Smrg
500909885543Smrg  for (i=0; i<argc+1; i++)
501009885543Smrg  {
501109885543Smrg    DEBUG("(main) newargz[%d]   : %s\n",i,newargz[i]);
501209885543Smrg    ;
501309885543Smrg  }
501409885543Smrg
501509885543SmrgEOF
501609885543Smrg
501709885543Smrg            case $host_os in
501809885543Smrg              mingw*)
501909885543Smrg                cat >> $cwrappersource <<EOF
502009885543Smrg  execv("$SHELL",(char const **)newargz);
502109885543SmrgEOF
502209885543Smrg              ;;
502309885543Smrg              *)
502409885543Smrg                cat >> $cwrappersource <<EOF
502509885543Smrg  execv("$SHELL",newargz);
502609885543SmrgEOF
502709885543Smrg              ;;
502809885543Smrg            esac
502909885543Smrg
503009885543Smrg            cat >> $cwrappersource <<"EOF"
503109885543Smrg  return 127;
503209885543Smrg}
503309885543Smrg
503409885543Smrgvoid *
503509885543Smrgxmalloc (size_t num)
503609885543Smrg{
503709885543Smrg  void * p = (void *) malloc (num);
503809885543Smrg  if (!p)
503909885543Smrg    lt_fatal ("Memory exhausted");
504009885543Smrg
504109885543Smrg  return p;
504209885543Smrg}
504309885543Smrg
504409885543Smrgchar *
504509885543Smrgxstrdup (const char *string)
504609885543Smrg{
504709885543Smrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL
504809885543Smrg;
504909885543Smrg}
505009885543Smrg
505109885543Smrgconst char *
505209885543Smrgbase_name (const char *name)
505309885543Smrg{
505409885543Smrg  const char *base;
505509885543Smrg
505609885543Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
505709885543Smrg  /* Skip over the disk name in MSDOS pathnames. */
505809885543Smrg  if (isalpha ((unsigned char)name[0]) && name[1] == ':')
505909885543Smrg    name += 2;
506009885543Smrg#endif
506109885543Smrg
506209885543Smrg  for (base = name; *name; name++)
506309885543Smrg    if (IS_DIR_SEPARATOR (*name))
506409885543Smrg      base = name + 1;
506509885543Smrg  return base;
506609885543Smrg}
506709885543Smrg
506809885543Smrgint
506909885543Smrgcheck_executable(const char * path)
507009885543Smrg{
507109885543Smrg  struct stat st;
507209885543Smrg
507309885543Smrg  DEBUG("(check_executable)  : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!");
507409885543Smrg  if ((!path) || (!*path))
507509885543Smrg    return 0;
507609885543Smrg
507709885543Smrg  if ((stat (path, &st) >= 0) &&
507809885543Smrg      (
507909885543Smrg        /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */
508009885543Smrg#if defined (S_IXOTH)
508109885543Smrg       ((st.st_mode & S_IXOTH) == S_IXOTH) ||
508209885543Smrg#endif
508309885543Smrg#if defined (S_IXGRP)
508409885543Smrg       ((st.st_mode & S_IXGRP) == S_IXGRP) ||
508509885543Smrg#endif
508609885543Smrg       ((st.st_mode & S_IXUSR) == S_IXUSR))
508709885543Smrg      )
508809885543Smrg    return 1;
508909885543Smrg  else
509009885543Smrg    return 0;
509109885543Smrg}
509209885543Smrg
509309885543Smrg/* Searches for the full path of the wrapper.  Returns
509409885543Smrg   newly allocated full path name if found, NULL otherwise */
509509885543Smrgchar *
509609885543Smrgfind_executable (const char* wrapper)
509709885543Smrg{
509809885543Smrg  int has_slash = 0;
509909885543Smrg  const char* p;
510009885543Smrg  const char* p_next;
510109885543Smrg  /* static buffer for getcwd */
510209885543Smrg  char tmp[LT_PATHMAX + 1];
510309885543Smrg  int tmp_len;
510409885543Smrg  char* concat_name;
510509885543Smrg
510609885543Smrg  DEBUG("(find_executable)  : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!");
510709885543Smrg
510809885543Smrg  if ((wrapper == NULL) || (*wrapper == '\0'))
510909885543Smrg    return NULL;
511009885543Smrg
511109885543Smrg  /* Absolute path? */
511209885543Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
511309885543Smrg  if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':')
511409885543Smrg  {
511509885543Smrg    concat_name = xstrdup (wrapper);
511609885543Smrg    if (check_executable(concat_name))
511709885543Smrg      return concat_name;
511809885543Smrg    XFREE(concat_name);
511909885543Smrg  }
512009885543Smrg  else
512109885543Smrg  {
512209885543Smrg#endif
512309885543Smrg    if (IS_DIR_SEPARATOR (wrapper[0]))
512409885543Smrg    {
512509885543Smrg      concat_name = xstrdup (wrapper);
512609885543Smrg      if (check_executable(concat_name))
512709885543Smrg        return concat_name;
512809885543Smrg      XFREE(concat_name);
512909885543Smrg    }
513009885543Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
513109885543Smrg  }
513209885543Smrg#endif
513309885543Smrg
513409885543Smrg  for (p = wrapper; *p; p++)
513509885543Smrg    if (*p == '/')
513609885543Smrg    {
513709885543Smrg      has_slash = 1;
513809885543Smrg      break;
513909885543Smrg    }
514009885543Smrg  if (!has_slash)
514109885543Smrg  {
514209885543Smrg    /* no slashes; search PATH */
514309885543Smrg    const char* path = getenv ("PATH");
514409885543Smrg    if (path != NULL)
514509885543Smrg    {
514609885543Smrg      for (p = path; *p; p = p_next)
514709885543Smrg      {
514809885543Smrg        const char* q;
514909885543Smrg        size_t p_len;
515009885543Smrg        for (q = p; *q; q++)
515109885543Smrg          if (IS_PATH_SEPARATOR(*q))
515209885543Smrg            break;
515309885543Smrg        p_len = q - p;
515409885543Smrg        p_next = (*q == '\0' ? q : q + 1);
515509885543Smrg        if (p_len == 0)
515609885543Smrg        {
515709885543Smrg          /* empty path: current directory */
515809885543Smrg          if (getcwd (tmp, LT_PATHMAX) == NULL)
515909885543Smrg            lt_fatal ("getcwd failed");
516009885543Smrg          tmp_len = strlen(tmp);
516109885543Smrg          concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
516209885543Smrg          memcpy (concat_name, tmp, tmp_len);
516309885543Smrg          concat_name[tmp_len] = '/';
516409885543Smrg          strcpy (concat_name + tmp_len + 1, wrapper);
516509885543Smrg        }
516609885543Smrg        else
516709885543Smrg        {
516809885543Smrg          concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1);
516909885543Smrg          memcpy (concat_name, p, p_len);
517009885543Smrg          concat_name[p_len] = '/';
517109885543Smrg          strcpy (concat_name + p_len + 1, wrapper);
517209885543Smrg        }
517309885543Smrg        if (check_executable(concat_name))
517409885543Smrg          return concat_name;
517509885543Smrg        XFREE(concat_name);
517609885543Smrg      }
517709885543Smrg    }
517809885543Smrg    /* not found in PATH; assume curdir */
517909885543Smrg  }
518009885543Smrg  /* Relative path | not found in path: prepend cwd */
518109885543Smrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
518209885543Smrg    lt_fatal ("getcwd failed");
518309885543Smrg  tmp_len = strlen(tmp);
518409885543Smrg  concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
518509885543Smrg  memcpy (concat_name, tmp, tmp_len);
518609885543Smrg  concat_name[tmp_len] = '/';
518709885543Smrg  strcpy (concat_name + tmp_len + 1, wrapper);
518809885543Smrg
518909885543Smrg  if (check_executable(concat_name))
519009885543Smrg    return concat_name;
519109885543Smrg  XFREE(concat_name);
519209885543Smrg  return NULL;
519309885543Smrg}
519409885543Smrg
519509885543Smrgchar *
519609885543Smrgstrendzap(char *str, const char *pat)
519709885543Smrg{
519809885543Smrg  size_t len, patlen;
519909885543Smrg
520009885543Smrg  assert(str != NULL);
520109885543Smrg  assert(pat != NULL);
520209885543Smrg
520309885543Smrg  len = strlen(str);
520409885543Smrg  patlen = strlen(pat);
520509885543Smrg
520609885543Smrg  if (patlen <= len)
520709885543Smrg  {
520809885543Smrg    str += len - patlen;
520909885543Smrg    if (strcmp(str, pat) == 0)
521009885543Smrg      *str = '\0';
521109885543Smrg  }
521209885543Smrg  return str;
521309885543Smrg}
521409885543Smrg
521509885543Smrgstatic void
521609885543Smrglt_error_core (int exit_status, const char * mode,
521709885543Smrg          const char * message, va_list ap)
521809885543Smrg{
521909885543Smrg  fprintf (stderr, "%s: %s: ", program_name, mode);
522009885543Smrg  vfprintf (stderr, message, ap);
522109885543Smrg  fprintf (stderr, ".\n");
522209885543Smrg
522309885543Smrg  if (exit_status >= 0)
522409885543Smrg    exit (exit_status);
522509885543Smrg}
522609885543Smrg
522709885543Smrgvoid
522809885543Smrglt_fatal (const char *message, ...)
522909885543Smrg{
523009885543Smrg  va_list ap;
523109885543Smrg  va_start (ap, message);
523209885543Smrg  lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
523309885543Smrg  va_end (ap);
523409885543Smrg}
523509885543SmrgEOF
523609885543Smrg          # we should really use a build-platform specific compiler
523709885543Smrg          # here, but OTOH, the wrappers (shell script and this C one)
523809885543Smrg          # are only useful if you want to execute the "real" binary.
523909885543Smrg          # Since the "real" binary is built for $host, then this
524009885543Smrg          # wrapper might as well be built for $host, too.
524109885543Smrg          $run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource
524209885543Smrg          ;;
524309885543Smrg        esac
524409885543Smrg        $rm $output
524509885543Smrg        trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
524609885543Smrg
524709885543Smrg	$echo > $output "\
524809885543Smrg#! $SHELL
524909885543Smrg
525009885543Smrg# $output - temporary wrapper script for $objdir/$outputname
525109885543Smrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
525209885543Smrg#
525309885543Smrg# The $output program cannot be directly executed until all the libtool
525409885543Smrg# libraries that it depends on are installed.
525509885543Smrg#
525609885543Smrg# This wrapper script should never be moved out of the build directory.
525709885543Smrg# If it is, it will not operate correctly.
525809885543Smrg
525909885543Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
526009885543Smrg# metacharacters that are still active within double-quoted strings.
526109885543SmrgXsed='${SED} -e 1s/^X//'
526209885543Smrgsed_quote_subst='$sed_quote_subst'
526309885543Smrg
526409885543Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout
526509885543Smrg# if CDPATH is set.
526609885543Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
526709885543Smrg
526809885543Smrgrelink_command=\"$relink_command\"
526909885543Smrg
527009885543Smrg# This environment variable determines our operation mode.
527109885543Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then
527209885543Smrg  # install mode needs the following variable:
527309885543Smrg  notinst_deplibs='$notinst_deplibs'
527409885543Smrgelse
527509885543Smrg  # When we are sourced in execute mode, \$file and \$echo are already set.
527609885543Smrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
527709885543Smrg    echo=\"$qecho\"
527809885543Smrg    file=\"\$0\"
527909885543Smrg    # Make sure echo works.
528009885543Smrg    if test \"X\$1\" = X--no-reexec; then
528109885543Smrg      # Discard the --no-reexec flag, and continue.
528209885543Smrg      shift
528309885543Smrg    elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then
528409885543Smrg      # Yippee, \$echo works!
528509885543Smrg      :
528609885543Smrg    else
528709885543Smrg      # Restart under the correct shell, and then maybe \$echo will work.
528809885543Smrg      exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
528909885543Smrg    fi
529009885543Smrg  fi\
529109885543Smrg"
529209885543Smrg	$echo >> $output "\
529309885543Smrg
529409885543Smrg  # Find the directory that this script lives in.
529509885543Smrg  thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
529609885543Smrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
529709885543Smrg
529809885543Smrg  # Follow symbolic links until we get to the real thisdir.
529909885543Smrg  file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
530009885543Smrg  while test -n \"\$file\"; do
530109885543Smrg    destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
530209885543Smrg
530309885543Smrg    # If there was a directory component, then change thisdir.
530409885543Smrg    if test \"x\$destdir\" != \"x\$file\"; then
530509885543Smrg      case \"\$destdir\" in
530609885543Smrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
530709885543Smrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
530809885543Smrg      esac
530909885543Smrg    fi
531009885543Smrg
531109885543Smrg    file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
531209885543Smrg    file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
531309885543Smrg  done
531409885543Smrg
531509885543Smrg  # Try to get the absolute directory name.
531609885543Smrg  absdir=\`cd \"\$thisdir\" && pwd\`
531709885543Smrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
531809885543Smrg"
531909885543Smrg
532009885543Smrg	if test "$fast_install" = yes; then
532109885543Smrg	  $echo >> $output "\
532209885543Smrg  program=lt-'$outputname'$exeext
532309885543Smrg  progdir=\"\$thisdir/$objdir\"
532409885543Smrg
532509885543Smrg  if test ! -f \"\$progdir/\$program\" || \\
532609885543Smrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
532709885543Smrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
532809885543Smrg
532909885543Smrg    file=\"\$\$-\$program\"
533009885543Smrg
533109885543Smrg    if test ! -d \"\$progdir\"; then
533209885543Smrg      $mkdir \"\$progdir\"
533309885543Smrg    else
533409885543Smrg      $rm \"\$progdir/\$file\"
533509885543Smrg    fi"
533609885543Smrg
533709885543Smrg	  $echo >> $output "\
533809885543Smrg
533909885543Smrg    # relink executable if necessary
534009885543Smrg    if test -n \"\$relink_command\"; then
534109885543Smrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
534209885543Smrg      else
534309885543Smrg	$echo \"\$relink_command_output\" >&2
534409885543Smrg	$rm \"\$progdir/\$file\"
534509885543Smrg	exit $EXIT_FAILURE
534609885543Smrg      fi
534709885543Smrg    fi
534809885543Smrg
534909885543Smrg    $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
535009885543Smrg    { $rm \"\$progdir/\$program\";
535109885543Smrg      $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
535209885543Smrg    $rm \"\$progdir/\$file\"
535309885543Smrg  fi"
535409885543Smrg	else
535509885543Smrg	  $echo >> $output "\
535609885543Smrg  program='$outputname'
535709885543Smrg  progdir=\"\$thisdir/$objdir\"
535809885543Smrg"
535909885543Smrg	fi
536009885543Smrg
536109885543Smrg	$echo >> $output "\
536209885543Smrg
536309885543Smrg  if test -f \"\$progdir/\$program\"; then"
536409885543Smrg
536509885543Smrg	# Export our shlibpath_var if we have one.
536609885543Smrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
536709885543Smrg	  $echo >> $output "\
536809885543Smrg    # Add our own library path to $shlibpath_var
536909885543Smrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
537009885543Smrg
537109885543Smrg    # Some systems cannot cope with colon-terminated $shlibpath_var
537209885543Smrg    # The second colon is a workaround for a bug in BeOS R4 sed
537309885543Smrg    $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
537409885543Smrg
537509885543Smrg    export $shlibpath_var
537609885543Smrg"
537709885543Smrg	fi
537809885543Smrg
537909885543Smrg	# fixup the dll searchpath if we need to.
538009885543Smrg	if test -n "$dllsearchpath"; then
538109885543Smrg	  $echo >> $output "\
538209885543Smrg    # Add the dll search path components to the executable PATH
538309885543Smrg    PATH=$dllsearchpath:\$PATH
538409885543Smrg"
538509885543Smrg	fi
538609885543Smrg
538709885543Smrg	$echo >> $output "\
538809885543Smrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
538909885543Smrg      # Run the actual program with our arguments.
539009885543Smrg"
539109885543Smrg	case $host in
539209885543Smrg	# Backslashes separate directories on plain windows
539309885543Smrg	*-*-mingw | *-*-os2*)
539409885543Smrg	  $echo >> $output "\
539509885543Smrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
539609885543Smrg"
539709885543Smrg	  ;;
539809885543Smrg
539909885543Smrg	*)
540009885543Smrg	  $echo >> $output "\
540109885543Smrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
540209885543Smrg"
540309885543Smrg	  ;;
540409885543Smrg	esac
540509885543Smrg	$echo >> $output "\
540609885543Smrg      \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\"
540709885543Smrg      exit $EXIT_FAILURE
540809885543Smrg    fi
540909885543Smrg  else
541009885543Smrg    # The program doesn't exist.
541109885543Smrg    \$echo \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
541209885543Smrg    \$echo \"This script is just a wrapper for \$program.\" 1>&2
541309885543Smrg    $echo \"See the $PACKAGE documentation for more information.\" 1>&2
541409885543Smrg    exit $EXIT_FAILURE
541509885543Smrg  fi
541609885543Smrgfi\
541709885543Smrg"
541809885543Smrg	chmod +x $output
541909885543Smrg      fi
542009885543Smrg      exit $EXIT_SUCCESS
542109885543Smrg      ;;
542209885543Smrg    esac
542309885543Smrg
542409885543Smrg    # See if we need to build an old-fashioned archive.
542509885543Smrg    for oldlib in $oldlibs; do
542609885543Smrg
542709885543Smrg      if test "$build_libtool_libs" = convenience; then
542809885543Smrg	oldobjs="$libobjs_save"
542909885543Smrg	addlibs="$convenience"
543009885543Smrg	build_libtool_libs=no
543109885543Smrg      else
543209885543Smrg	if test "$build_libtool_libs" = module; then
543309885543Smrg	  oldobjs="$libobjs_save"
543409885543Smrg	  build_libtool_libs=no
543509885543Smrg	else
543609885543Smrg	  oldobjs="$old_deplibs $non_pic_objects"
543709885543Smrg	fi
543809885543Smrg	addlibs="$old_convenience"
543909885543Smrg      fi
544009885543Smrg
544109885543Smrg      if test -n "$addlibs"; then
544209885543Smrg	gentop="$output_objdir/${outputname}x"
544309885543Smrg	generated="$generated $gentop"
544409885543Smrg
544509885543Smrg	func_extract_archives $gentop $addlibs
544609885543Smrg	oldobjs="$oldobjs $func_extract_archives_result"
544709885543Smrg      fi
544809885543Smrg
544909885543Smrg      # Do each command in the archive commands.
545009885543Smrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
545109885543Smrg       cmds=$old_archive_from_new_cmds
545209885543Smrg      else
545309885543Smrg	# POSIX demands no paths to be encoded in archives.  We have
545409885543Smrg	# to avoid creating archives with duplicate basenames if we
545509885543Smrg	# might have to extract them afterwards, e.g., when creating a
545609885543Smrg	# static archive out of a convenience library, or when linking
545709885543Smrg	# the entirety of a libtool archive into another (currently
545809885543Smrg	# not supported by libtool).
545909885543Smrg	if (for obj in $oldobjs
546009885543Smrg	    do
546109885543Smrg	      $echo "X$obj" | $Xsed -e 's%^.*/%%'
546209885543Smrg	    done | sort | sort -uc >/dev/null 2>&1); then
546309885543Smrg	  :
546409885543Smrg	else
546509885543Smrg	  $echo "copying selected object files to avoid basename conflicts..."
546609885543Smrg
546709885543Smrg	  if test -z "$gentop"; then
546809885543Smrg	    gentop="$output_objdir/${outputname}x"
546909885543Smrg	    generated="$generated $gentop"
547009885543Smrg
547109885543Smrg	    $show "${rm}r $gentop"
547209885543Smrg	    $run ${rm}r "$gentop"
547309885543Smrg	    $show "$mkdir $gentop"
547409885543Smrg	    $run $mkdir "$gentop"
547509885543Smrg	    exit_status=$?
547609885543Smrg	    if test "$exit_status" -ne 0 && test ! -d "$gentop"; then
547709885543Smrg	      exit $exit_status
547809885543Smrg	    fi
547909885543Smrg	  fi
548009885543Smrg
548109885543Smrg	  save_oldobjs=$oldobjs
548209885543Smrg	  oldobjs=
548309885543Smrg	  counter=1
548409885543Smrg	  for obj in $save_oldobjs
548509885543Smrg	  do
548609885543Smrg	    objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
548709885543Smrg	    case " $oldobjs " in
548809885543Smrg	    " ") oldobjs=$obj ;;
548909885543Smrg	    *[\ /]"$objbase "*)
549009885543Smrg	      while :; do
549109885543Smrg		# Make sure we don't pick an alternate name that also
549209885543Smrg		# overlaps.
549309885543Smrg		newobj=lt$counter-$objbase
549409885543Smrg		counter=`expr $counter + 1`
549509885543Smrg		case " $oldobjs " in
549609885543Smrg		*[\ /]"$newobj "*) ;;
549709885543Smrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
549809885543Smrg		esac
549909885543Smrg	      done
550009885543Smrg	      $show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
550109885543Smrg	      $run ln "$obj" "$gentop/$newobj" ||
550209885543Smrg	      $run cp "$obj" "$gentop/$newobj"
550309885543Smrg	      oldobjs="$oldobjs $gentop/$newobj"
550409885543Smrg	      ;;
550509885543Smrg	    *) oldobjs="$oldobjs $obj" ;;
550609885543Smrg	    esac
550709885543Smrg	  done
550809885543Smrg	fi
550909885543Smrg
551009885543Smrg	eval cmds=\"$old_archive_cmds\"
551109885543Smrg
551209885543Smrg	if len=`expr "X$cmds" : ".*"` &&
551309885543Smrg	     test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
551409885543Smrg	  cmds=$old_archive_cmds
551509885543Smrg	else
551609885543Smrg	  # the command line is too long to link in one step, link in parts
551709885543Smrg	  $echo "using piecewise archive linking..."
551809885543Smrg	  save_RANLIB=$RANLIB
551909885543Smrg	  RANLIB=:
552009885543Smrg	  objlist=
552109885543Smrg	  concat_cmds=
552209885543Smrg	  save_oldobjs=$oldobjs
552309885543Smrg
552409885543Smrg	  # Is there a better way of finding the last object in the list?
552509885543Smrg	  for obj in $save_oldobjs
552609885543Smrg	  do
552709885543Smrg	    last_oldobj=$obj
552809885543Smrg	  done
552909885543Smrg	  for obj in $save_oldobjs
553009885543Smrg	  do
553109885543Smrg	    oldobjs="$objlist $obj"
553209885543Smrg	    objlist="$objlist $obj"
553309885543Smrg	    eval test_cmds=\"$old_archive_cmds\"
553409885543Smrg	    if len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
553509885543Smrg	       test "$len" -le "$max_cmd_len"; then
553609885543Smrg	      :
553709885543Smrg	    else
553809885543Smrg	      # the above command should be used before it gets too long
553909885543Smrg	      oldobjs=$objlist
554009885543Smrg	      if test "$obj" = "$last_oldobj" ; then
554109885543Smrg	        RANLIB=$save_RANLIB
554209885543Smrg	      fi
554309885543Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
554409885543Smrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
554509885543Smrg	      objlist=
554609885543Smrg	    fi
554709885543Smrg	  done
554809885543Smrg	  RANLIB=$save_RANLIB
554909885543Smrg	  oldobjs=$objlist
555009885543Smrg	  if test "X$oldobjs" = "X" ; then
555109885543Smrg	    eval cmds=\"\$concat_cmds\"
555209885543Smrg	  else
555309885543Smrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
555409885543Smrg	  fi
555509885543Smrg	fi
555609885543Smrg      fi
555709885543Smrg      save_ifs="$IFS"; IFS='~'
555809885543Smrg      for cmd in $cmds; do
555909885543Smrg        eval cmd=\"$cmd\"
556009885543Smrg	IFS="$save_ifs"
556109885543Smrg	$show "$cmd"
556209885543Smrg	$run eval "$cmd" || exit $?
556309885543Smrg      done
556409885543Smrg      IFS="$save_ifs"
556509885543Smrg    done
556609885543Smrg
556709885543Smrg    if test -n "$generated"; then
556809885543Smrg      $show "${rm}r$generated"
556909885543Smrg      $run ${rm}r$generated
557009885543Smrg    fi
557109885543Smrg
557209885543Smrg    # Now create the libtool archive.
557309885543Smrg    case $output in
557409885543Smrg    *.la)
557509885543Smrg      old_library=
557609885543Smrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
557709885543Smrg      $show "creating $output"
557809885543Smrg
557909885543Smrg      # Preserve any variables that may affect compiler behavior
558009885543Smrg      for var in $variables_saved_for_relink; do
558109885543Smrg	if eval test -z \"\${$var+set}\"; then
558209885543Smrg	  relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
558309885543Smrg	elif eval var_value=\$$var; test -z "$var_value"; then
558409885543Smrg	  relink_command="$var=; export $var; $relink_command"
558509885543Smrg	else
558609885543Smrg	  var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
558709885543Smrg	  relink_command="$var=\"$var_value\"; export $var; $relink_command"
558809885543Smrg	fi
558909885543Smrg      done
559009885543Smrg      # Quote the link command for shipping.
559109885543Smrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
559209885543Smrg      relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
559309885543Smrg      if test "$hardcode_automatic" = yes ; then
559409885543Smrg	relink_command=
559509885543Smrg      fi
559609885543Smrg
559709885543Smrg
559809885543Smrg      # Only create the output if not a dry run.
559909885543Smrg      if test -z "$run"; then
560009885543Smrg	for installed in no yes; do
560109885543Smrg	  if test "$installed" = yes; then
560209885543Smrg	    if test -z "$install_libdir"; then
560309885543Smrg	      break
560409885543Smrg	    fi
560509885543Smrg	    output="$output_objdir/$outputname"i
560609885543Smrg	    # Replace all uninstalled libtool libraries with the installed ones
560709885543Smrg	    newdependency_libs=
560809885543Smrg	    for deplib in $dependency_libs; do
560909885543Smrg	      case $deplib in
561009885543Smrg	      *.la)
561109885543Smrg		name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'`
561209885543Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
561309885543Smrg		if test -z "$libdir"; then
561409885543Smrg		  $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
561509885543Smrg		  exit $EXIT_FAILURE
561609885543Smrg		fi
561709885543Smrg		newdependency_libs="$newdependency_libs $libdir/$name"
561809885543Smrg		;;
561909885543Smrg	      *) newdependency_libs="$newdependency_libs $deplib" ;;
562009885543Smrg	      esac
562109885543Smrg	    done
562209885543Smrg	    dependency_libs="$newdependency_libs"
562309885543Smrg	    newdlfiles=
562409885543Smrg	    for lib in $dlfiles; do
562509885543Smrg	      name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
562609885543Smrg	      eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
562709885543Smrg	      if test -z "$libdir"; then
562809885543Smrg		$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
562909885543Smrg		exit $EXIT_FAILURE
563009885543Smrg	      fi
563109885543Smrg	      newdlfiles="$newdlfiles $libdir/$name"
563209885543Smrg	    done
563309885543Smrg	    dlfiles="$newdlfiles"
563409885543Smrg	    newdlprefiles=
563509885543Smrg	    for lib in $dlprefiles; do
563609885543Smrg	      name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
563709885543Smrg	      eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
563809885543Smrg	      if test -z "$libdir"; then
563909885543Smrg		$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
564009885543Smrg		exit $EXIT_FAILURE
564109885543Smrg	      fi
564209885543Smrg	      newdlprefiles="$newdlprefiles $libdir/$name"
564309885543Smrg	    done
564409885543Smrg	    dlprefiles="$newdlprefiles"
564509885543Smrg	  else
564609885543Smrg	    newdlfiles=
564709885543Smrg	    for lib in $dlfiles; do
564809885543Smrg	      case $lib in
564909885543Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
565009885543Smrg		*) abs=`pwd`"/$lib" ;;
565109885543Smrg	      esac
565209885543Smrg	      newdlfiles="$newdlfiles $abs"
565309885543Smrg	    done
565409885543Smrg	    dlfiles="$newdlfiles"
565509885543Smrg	    newdlprefiles=
565609885543Smrg	    for lib in $dlprefiles; do
565709885543Smrg	      case $lib in
565809885543Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
565909885543Smrg		*) abs=`pwd`"/$lib" ;;
566009885543Smrg	      esac
566109885543Smrg	      newdlprefiles="$newdlprefiles $abs"
566209885543Smrg	    done
566309885543Smrg	    dlprefiles="$newdlprefiles"
566409885543Smrg	  fi
566509885543Smrg	  $rm $output
566609885543Smrg	  # place dlname in correct position for cygwin
566709885543Smrg	  tdlname=$dlname
566809885543Smrg	  case $host,$output,$installed,$module,$dlname in
566909885543Smrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
567009885543Smrg	  esac
567109885543Smrg	  $echo > $output "\
567209885543Smrg# $outputname - a libtool library file
567309885543Smrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
567409885543Smrg#
567509885543Smrg# Please DO NOT delete this file!
567609885543Smrg# It is necessary for linking the library.
567709885543Smrg
567809885543Smrg# The name that we can dlopen(3).
567909885543Smrgdlname='$tdlname'
568009885543Smrg
568109885543Smrg# Names of this library.
568209885543Smrglibrary_names='$library_names'
568309885543Smrg
568409885543Smrg# The name of the static archive.
568509885543Smrgold_library='$old_library'
568609885543Smrg
568709885543Smrg# Libraries that this one depends upon.
568809885543Smrgdependency_libs='$dependency_libs'
568909885543Smrg
569009885543Smrg# Version information for $libname.
569109885543Smrgcurrent=$current
569209885543Smrgage=$age
569309885543Smrgrevision=$revision
569409885543Smrg
569509885543Smrg# Is this an already installed library?
569609885543Smrginstalled=$installed
569709885543Smrg
569809885543Smrg# Should we warn about portability when linking against -modules?
569909885543Smrgshouldnotlink=$module
570009885543Smrg
570109885543Smrg# Files to dlopen/dlpreopen
570209885543Smrgdlopen='$dlfiles'
570309885543Smrgdlpreopen='$dlprefiles'
570409885543Smrg
570509885543Smrg# Directory that this library needs to be installed in:
570609885543Smrglibdir='$install_libdir'"
570709885543Smrg	  if test "$installed" = no && test "$need_relink" = yes; then
570809885543Smrg	    $echo >> $output "\
570909885543Smrgrelink_command=\"$relink_command\""
571009885543Smrg	  fi
571109885543Smrg	done
571209885543Smrg      fi
571309885543Smrg
571409885543Smrg      # Do a symbolic link so that the libtool archive can be found in
571509885543Smrg      # LD_LIBRARY_PATH before the program is installed.
571609885543Smrg      $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)"
571709885543Smrg      $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $?
571809885543Smrg      ;;
571909885543Smrg    esac
572009885543Smrg    exit $EXIT_SUCCESS
572109885543Smrg    ;;
572209885543Smrg
572309885543Smrg  # libtool install mode
572409885543Smrg  install)
572509885543Smrg    modename="$modename: install"
572609885543Smrg
572709885543Smrg    # There may be an optional sh(1) argument at the beginning of
572809885543Smrg    # install_prog (especially on Windows NT).
572909885543Smrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
573009885543Smrg       # Allow the use of GNU shtool's install command.
573109885543Smrg       $echo "X$nonopt" | grep shtool > /dev/null; then
573209885543Smrg      # Aesthetically quote it.
573309885543Smrg      arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"`
573409885543Smrg      case $arg in
573509885543Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
573609885543Smrg	arg="\"$arg\""
573709885543Smrg	;;
573809885543Smrg      esac
573909885543Smrg      install_prog="$arg "
574009885543Smrg      arg="$1"
574109885543Smrg      shift
574209885543Smrg    else
574309885543Smrg      install_prog=
574409885543Smrg      arg=$nonopt
574509885543Smrg    fi
574609885543Smrg
574709885543Smrg    # The real first argument should be the name of the installation program.
574809885543Smrg    # Aesthetically quote it.
574909885543Smrg    arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
575009885543Smrg    case $arg in
575109885543Smrg    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
575209885543Smrg      arg="\"$arg\""
575309885543Smrg      ;;
575409885543Smrg    esac
575509885543Smrg    install_prog="$install_prog$arg"
575609885543Smrg
575709885543Smrg    # We need to accept at least all the BSD install flags.
575809885543Smrg    dest=
575909885543Smrg    files=
576009885543Smrg    opts=
576109885543Smrg    prev=
576209885543Smrg    install_type=
576309885543Smrg    isdir=no
576409885543Smrg    stripme=
576509885543Smrg    for arg
576609885543Smrg    do
576709885543Smrg      if test -n "$dest"; then
576809885543Smrg	files="$files $dest"
576909885543Smrg	dest=$arg
577009885543Smrg	continue
577109885543Smrg      fi
577209885543Smrg
577309885543Smrg      case $arg in
577409885543Smrg      -d) isdir=yes ;;
577509885543Smrg      -f) 
577609885543Smrg      	case " $install_prog " in
577709885543Smrg	*[\\\ /]cp\ *) ;;
577809885543Smrg	*) prev=$arg ;;
577909885543Smrg	esac
578009885543Smrg	;;
578109885543Smrg      -g | -m | -o) prev=$arg ;;
578209885543Smrg      -s)
578309885543Smrg	stripme=" -s"
578409885543Smrg	continue
578509885543Smrg	;;
578609885543Smrg      -*)
578709885543Smrg	;;
578809885543Smrg      *)
578909885543Smrg	# If the previous option needed an argument, then skip it.
579009885543Smrg	if test -n "$prev"; then
579109885543Smrg	  prev=
579209885543Smrg	else
579309885543Smrg	  dest=$arg
579409885543Smrg	  continue
579509885543Smrg	fi
579609885543Smrg	;;
579709885543Smrg      esac
579809885543Smrg
579909885543Smrg      # Aesthetically quote the argument.
580009885543Smrg      arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
580109885543Smrg      case $arg in
580209885543Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
580309885543Smrg	arg="\"$arg\""
580409885543Smrg	;;
580509885543Smrg      esac
580609885543Smrg      install_prog="$install_prog $arg"
580709885543Smrg    done
580809885543Smrg
580909885543Smrg    if test -z "$install_prog"; then
581009885543Smrg      $echo "$modename: you must specify an install program" 1>&2
581109885543Smrg      $echo "$help" 1>&2
581209885543Smrg      exit $EXIT_FAILURE
581309885543Smrg    fi
581409885543Smrg
581509885543Smrg    if test -n "$prev"; then
581609885543Smrg      $echo "$modename: the \`$prev' option requires an argument" 1>&2
581709885543Smrg      $echo "$help" 1>&2
581809885543Smrg      exit $EXIT_FAILURE
581909885543Smrg    fi
582009885543Smrg
582109885543Smrg    if test -z "$files"; then
582209885543Smrg      if test -z "$dest"; then
582309885543Smrg	$echo "$modename: no file or destination specified" 1>&2
582409885543Smrg      else
582509885543Smrg	$echo "$modename: you must specify a destination" 1>&2
582609885543Smrg      fi
582709885543Smrg      $echo "$help" 1>&2
582809885543Smrg      exit $EXIT_FAILURE
582909885543Smrg    fi
583009885543Smrg
583109885543Smrg    # Strip any trailing slash from the destination.
583209885543Smrg    dest=`$echo "X$dest" | $Xsed -e 's%/$%%'`
583309885543Smrg
583409885543Smrg    # Check to see that the destination is a directory.
583509885543Smrg    test -d "$dest" && isdir=yes
583609885543Smrg    if test "$isdir" = yes; then
583709885543Smrg      destdir="$dest"
583809885543Smrg      destname=
583909885543Smrg    else
584009885543Smrg      destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'`
584109885543Smrg      test "X$destdir" = "X$dest" && destdir=.
584209885543Smrg      destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'`
584309885543Smrg
584409885543Smrg      # Not a directory, so check to see that there is only one file specified.
584509885543Smrg      set dummy $files
584609885543Smrg      if test "$#" -gt 2; then
584709885543Smrg	$echo "$modename: \`$dest' is not a directory" 1>&2
584809885543Smrg	$echo "$help" 1>&2
584909885543Smrg	exit $EXIT_FAILURE
585009885543Smrg      fi
585109885543Smrg    fi
585209885543Smrg    case $destdir in
585309885543Smrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
585409885543Smrg    *)
585509885543Smrg      for file in $files; do
585609885543Smrg	case $file in
585709885543Smrg	*.lo) ;;
585809885543Smrg	*)
585909885543Smrg	  $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2
586009885543Smrg	  $echo "$help" 1>&2
586109885543Smrg	  exit $EXIT_FAILURE
586209885543Smrg	  ;;
586309885543Smrg	esac
586409885543Smrg      done
586509885543Smrg      ;;
586609885543Smrg    esac
586709885543Smrg
586809885543Smrg    # This variable tells wrapper scripts just to set variables rather
586909885543Smrg    # than running their programs.
587009885543Smrg    libtool_install_magic="$magic"
587109885543Smrg
587209885543Smrg    staticlibs=
587309885543Smrg    future_libdirs=
587409885543Smrg    current_libdirs=
587509885543Smrg    for file in $files; do
587609885543Smrg
587709885543Smrg      # Do each installation.
587809885543Smrg      case $file in
587909885543Smrg      *.$libext)
588009885543Smrg	# Do the static libraries later.
588109885543Smrg	staticlibs="$staticlibs $file"
588209885543Smrg	;;
588309885543Smrg
588409885543Smrg      *.la)
588509885543Smrg	# Check to see that this really is a libtool archive.
588609885543Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
588709885543Smrg	else
588809885543Smrg	  $echo "$modename: \`$file' is not a valid libtool archive" 1>&2
588909885543Smrg	  $echo "$help" 1>&2
589009885543Smrg	  exit $EXIT_FAILURE
589109885543Smrg	fi
589209885543Smrg
589309885543Smrg	library_names=
589409885543Smrg	old_library=
589509885543Smrg	relink_command=
589609885543Smrg	# If there is no directory component, then add one.
589709885543Smrg	case $file in
589809885543Smrg	*/* | *\\*) . $file ;;
589909885543Smrg	*) . ./$file ;;
590009885543Smrg	esac
590109885543Smrg
590209885543Smrg	# Add the libdir to current_libdirs if it is the destination.
590309885543Smrg	if test "X$destdir" = "X$libdir"; then
590409885543Smrg	  case "$current_libdirs " in
590509885543Smrg	  *" $libdir "*) ;;
590609885543Smrg	  *) current_libdirs="$current_libdirs $libdir" ;;
590709885543Smrg	  esac
590809885543Smrg	else
590909885543Smrg	  # Note the libdir as a future libdir.
591009885543Smrg	  case "$future_libdirs " in
591109885543Smrg	  *" $libdir "*) ;;
591209885543Smrg	  *) future_libdirs="$future_libdirs $libdir" ;;
591309885543Smrg	  esac
591409885543Smrg	fi
591509885543Smrg
591609885543Smrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/
591709885543Smrg	test "X$dir" = "X$file/" && dir=
591809885543Smrg	dir="$dir$objdir"
591909885543Smrg
592009885543Smrg	if test -n "$relink_command"; then
592109885543Smrg	  # Determine the prefix the user has applied to our future dir.
592209885543Smrg	  inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"`
592309885543Smrg
592409885543Smrg	  # Don't allow the user to place us outside of our expected
592509885543Smrg	  # location b/c this prevents finding dependent libraries that
592609885543Smrg	  # are installed to the same prefix.
592709885543Smrg	  # At present, this check doesn't affect windows .dll's that
592809885543Smrg	  # are installed into $libdir/../bin (currently, that works fine)
592909885543Smrg	  # but it's something to keep an eye on.
593009885543Smrg	  if test "$inst_prefix_dir" = "$destdir"; then
593109885543Smrg	    $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2
593209885543Smrg	    exit $EXIT_FAILURE
593309885543Smrg	  fi
593409885543Smrg
593509885543Smrg	  if test -n "$inst_prefix_dir"; then
593609885543Smrg	    # Stick the inst_prefix_dir data into the link command.
593709885543Smrg	    relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
593809885543Smrg	  else
593909885543Smrg	    relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
594009885543Smrg	  fi
594109885543Smrg
594209885543Smrg	  $echo "$modename: warning: relinking \`$file'" 1>&2
594309885543Smrg	  $show "$relink_command"
594409885543Smrg	  if $run eval "$relink_command"; then :
594509885543Smrg	  else
594609885543Smrg	    $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
594709885543Smrg	    exit $EXIT_FAILURE
594809885543Smrg	  fi
594909885543Smrg	fi
595009885543Smrg
595109885543Smrg	# See the names of the shared library.
595209885543Smrg	set dummy $library_names
595309885543Smrg	if test -n "$2"; then
595409885543Smrg	  realname="$2"
595509885543Smrg	  shift
595609885543Smrg	  shift
595709885543Smrg
595809885543Smrg	  srcname="$realname"
595909885543Smrg	  test -n "$relink_command" && srcname="$realname"T
596009885543Smrg
596109885543Smrg	  # Install the shared library and build the symlinks.
596209885543Smrg	  $show "$install_prog $dir/$srcname $destdir/$realname"
596309885543Smrg	  $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $?
596409885543Smrg	  if test -n "$stripme" && test -n "$striplib"; then
596509885543Smrg	    $show "$striplib $destdir/$realname"
596609885543Smrg	    $run eval "$striplib $destdir/$realname" || exit $?
596709885543Smrg	  fi
596809885543Smrg
596909885543Smrg	  if test "$#" -gt 0; then
597009885543Smrg	    # Delete the old symlinks, and create new ones.
597109885543Smrg	    # Try `ln -sf' first, because the `ln' binary might depend on
597209885543Smrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
597309885543Smrg	    # so we also need to try rm && ln -s.
597409885543Smrg	    for linkname
597509885543Smrg	    do
597609885543Smrg	      if test "$linkname" != "$realname"; then
597709885543Smrg                $show "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
597809885543Smrg                $run eval "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
597909885543Smrg	      fi
598009885543Smrg	    done
598109885543Smrg	  fi
598209885543Smrg
598309885543Smrg	  # Do each command in the postinstall commands.
598409885543Smrg	  lib="$destdir/$realname"
598509885543Smrg	  cmds=$postinstall_cmds
598609885543Smrg	  save_ifs="$IFS"; IFS='~'
598709885543Smrg	  for cmd in $cmds; do
598809885543Smrg	    IFS="$save_ifs"
598909885543Smrg	    eval cmd=\"$cmd\"
599009885543Smrg	    $show "$cmd"
599109885543Smrg	    $run eval "$cmd" || {
599209885543Smrg	      lt_exit=$?
599309885543Smrg
599409885543Smrg	      # Restore the uninstalled library and exit
599509885543Smrg	      if test "$mode" = relink; then
599609885543Smrg		$run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
599709885543Smrg	      fi
599809885543Smrg
599909885543Smrg	      exit $lt_exit
600009885543Smrg	    }
600109885543Smrg	  done
600209885543Smrg	  IFS="$save_ifs"
600309885543Smrg	fi
600409885543Smrg
600509885543Smrg	# Install the pseudo-library for information purposes.
600609885543Smrg	name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
600709885543Smrg	instname="$dir/$name"i
600809885543Smrg	$show "$install_prog $instname $destdir/$name"
600909885543Smrg	$run eval "$install_prog $instname $destdir/$name" || exit $?
601009885543Smrg
601109885543Smrg	# Maybe install the static library, too.
601209885543Smrg	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
601309885543Smrg	;;
601409885543Smrg
601509885543Smrg      *.lo)
601609885543Smrg	# Install (i.e. copy) a libtool object.
601709885543Smrg
601809885543Smrg	# Figure out destination file name, if it wasn't already specified.
601909885543Smrg	if test -n "$destname"; then
602009885543Smrg	  destfile="$destdir/$destname"
602109885543Smrg	else
602209885543Smrg	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
602309885543Smrg	  destfile="$destdir/$destfile"
602409885543Smrg	fi
602509885543Smrg
602609885543Smrg	# Deduce the name of the destination old-style object file.
602709885543Smrg	case $destfile in
602809885543Smrg	*.lo)
602909885543Smrg	  staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"`
603009885543Smrg	  ;;
603109885543Smrg	*.$objext)
603209885543Smrg	  staticdest="$destfile"
603309885543Smrg	  destfile=
603409885543Smrg	  ;;
603509885543Smrg	*)
603609885543Smrg	  $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2
603709885543Smrg	  $echo "$help" 1>&2
603809885543Smrg	  exit $EXIT_FAILURE
603909885543Smrg	  ;;
604009885543Smrg	esac
604109885543Smrg
604209885543Smrg	# Install the libtool object if requested.
604309885543Smrg	if test -n "$destfile"; then
604409885543Smrg	  $show "$install_prog $file $destfile"
604509885543Smrg	  $run eval "$install_prog $file $destfile" || exit $?
604609885543Smrg	fi
604709885543Smrg
604809885543Smrg	# Install the old object if enabled.
604909885543Smrg	if test "$build_old_libs" = yes; then
605009885543Smrg	  # Deduce the name of the old-style object file.
605109885543Smrg	  staticobj=`$echo "X$file" | $Xsed -e "$lo2o"`
605209885543Smrg
605309885543Smrg	  $show "$install_prog $staticobj $staticdest"
605409885543Smrg	  $run eval "$install_prog \$staticobj \$staticdest" || exit $?
605509885543Smrg	fi
605609885543Smrg	exit $EXIT_SUCCESS
605709885543Smrg	;;
605809885543Smrg
605909885543Smrg      *)
606009885543Smrg	# Figure out destination file name, if it wasn't already specified.
606109885543Smrg	if test -n "$destname"; then
606209885543Smrg	  destfile="$destdir/$destname"
606309885543Smrg	else
606409885543Smrg	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
606509885543Smrg	  destfile="$destdir/$destfile"
606609885543Smrg	fi
606709885543Smrg
606809885543Smrg	# If the file is missing, and there is a .exe on the end, strip it
606909885543Smrg	# because it is most likely a libtool script we actually want to
607009885543Smrg	# install
607109885543Smrg	stripped_ext=""
607209885543Smrg	case $file in
607309885543Smrg	  *.exe)
607409885543Smrg	    if test ! -f "$file"; then
607509885543Smrg	      file=`$echo $file|${SED} 's,.exe$,,'`
607609885543Smrg	      stripped_ext=".exe"
607709885543Smrg	    fi
607809885543Smrg	    ;;
607909885543Smrg	esac
608009885543Smrg
608109885543Smrg	# Do a test to see if this is really a libtool program.
608209885543Smrg	case $host in
608309885543Smrg	*cygwin*|*mingw*)
608409885543Smrg	    wrapper=`$echo $file | ${SED} -e 's,.exe$,,'`
608509885543Smrg	    ;;
608609885543Smrg	*)
608709885543Smrg	    wrapper=$file
608809885543Smrg	    ;;
608909885543Smrg	esac
609009885543Smrg	if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then
609109885543Smrg	  notinst_deplibs=
609209885543Smrg	  relink_command=
609309885543Smrg
609409885543Smrg	  # Note that it is not necessary on cygwin/mingw to append a dot to
609509885543Smrg	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
609609885543Smrg	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
609709885543Smrg	  # `FILE.' does not work on cygwin managed mounts.
609809885543Smrg	  #
609909885543Smrg	  # If there is no directory component, then add one.
610009885543Smrg	  case $wrapper in
610109885543Smrg	  */* | *\\*) . ${wrapper} ;;
610209885543Smrg	  *) . ./${wrapper} ;;
610309885543Smrg	  esac
610409885543Smrg
610509885543Smrg	  # Check the variables that should have been set.
610609885543Smrg	  if test -z "$notinst_deplibs"; then
610709885543Smrg	    $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2
610809885543Smrg	    exit $EXIT_FAILURE
610909885543Smrg	  fi
611009885543Smrg
611109885543Smrg	  finalize=yes
611209885543Smrg	  for lib in $notinst_deplibs; do
611309885543Smrg	    # Check to see that each library is installed.
611409885543Smrg	    libdir=
611509885543Smrg	    if test -f "$lib"; then
611609885543Smrg	      # If there is no directory component, then add one.
611709885543Smrg	      case $lib in
611809885543Smrg	      */* | *\\*) . $lib ;;
611909885543Smrg	      *) . ./$lib ;;
612009885543Smrg	      esac
612109885543Smrg	    fi
612209885543Smrg	    libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
612309885543Smrg	    if test -n "$libdir" && test ! -f "$libfile"; then
612409885543Smrg	      $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2
612509885543Smrg	      finalize=no
612609885543Smrg	    fi
612709885543Smrg	  done
612809885543Smrg
612909885543Smrg	  relink_command=
613009885543Smrg	  # Note that it is not necessary on cygwin/mingw to append a dot to
613109885543Smrg	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
613209885543Smrg	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
613309885543Smrg	  # `FILE.' does not work on cygwin managed mounts.
613409885543Smrg	  #
613509885543Smrg	  # If there is no directory component, then add one.
613609885543Smrg	  case $wrapper in
613709885543Smrg	  */* | *\\*) . ${wrapper} ;;
613809885543Smrg	  *) . ./${wrapper} ;;
613909885543Smrg	  esac
614009885543Smrg
614109885543Smrg	  outputname=
614209885543Smrg	  if test "$fast_install" = no && test -n "$relink_command"; then
614309885543Smrg	    if test "$finalize" = yes && test -z "$run"; then
614409885543Smrg	      tmpdir=`func_mktempdir`
614509885543Smrg	      file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
614609885543Smrg	      outputname="$tmpdir/$file"
614709885543Smrg	      # Replace the output file specification.
614809885543Smrg	      relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
614909885543Smrg
615009885543Smrg	      $show "$relink_command"
615109885543Smrg	      if $run eval "$relink_command"; then :
615209885543Smrg	      else
615309885543Smrg		$echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
615409885543Smrg		${rm}r "$tmpdir"
615509885543Smrg		continue
615609885543Smrg	      fi
615709885543Smrg	      file="$outputname"
615809885543Smrg	    else
615909885543Smrg	      $echo "$modename: warning: cannot relink \`$file'" 1>&2
616009885543Smrg	    fi
616109885543Smrg	  else
616209885543Smrg	    # Install the binary that we compiled earlier.
616309885543Smrg	    file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
616409885543Smrg	  fi
616509885543Smrg	fi
616609885543Smrg
616709885543Smrg	# remove .exe since cygwin /usr/bin/install will append another
616809885543Smrg	# one anyway 
616909885543Smrg	case $install_prog,$host in
617009885543Smrg	*/usr/bin/install*,*cygwin*)
617109885543Smrg	  case $file:$destfile in
617209885543Smrg	  *.exe:*.exe)
617309885543Smrg	    # this is ok
617409885543Smrg	    ;;
617509885543Smrg	  *.exe:*)
617609885543Smrg	    destfile=$destfile.exe
617709885543Smrg	    ;;
617809885543Smrg	  *:*.exe)
617909885543Smrg	    destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'`
618009885543Smrg	    ;;
618109885543Smrg	  esac
618209885543Smrg	  ;;
618309885543Smrg	esac
618409885543Smrg	$show "$install_prog$stripme $file $destfile"
618509885543Smrg	$run eval "$install_prog\$stripme \$file \$destfile" || exit $?
618609885543Smrg	test -n "$outputname" && ${rm}r "$tmpdir"
618709885543Smrg	;;
618809885543Smrg      esac
618909885543Smrg    done
619009885543Smrg
619109885543Smrg    for file in $staticlibs; do
619209885543Smrg      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
619309885543Smrg
619409885543Smrg      # Set up the ranlib parameters.
619509885543Smrg      oldlib="$destdir/$name"
619609885543Smrg
619709885543Smrg      $show "$install_prog $file $oldlib"
619809885543Smrg      $run eval "$install_prog \$file \$oldlib" || exit $?
619909885543Smrg
620009885543Smrg      if test -n "$stripme" && test -n "$old_striplib"; then
620109885543Smrg	$show "$old_striplib $oldlib"
620209885543Smrg	$run eval "$old_striplib $oldlib" || exit $?
620309885543Smrg      fi
620409885543Smrg
620509885543Smrg      # Do each command in the postinstall commands.
620609885543Smrg      cmds=$old_postinstall_cmds
620709885543Smrg      save_ifs="$IFS"; IFS='~'
620809885543Smrg      for cmd in $cmds; do
620909885543Smrg	IFS="$save_ifs"
621009885543Smrg	eval cmd=\"$cmd\"
621109885543Smrg	$show "$cmd"
621209885543Smrg	$run eval "$cmd" || exit $?
621309885543Smrg      done
621409885543Smrg      IFS="$save_ifs"
621509885543Smrg    done
621609885543Smrg
621709885543Smrg    if test -n "$future_libdirs"; then
621809885543Smrg      $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2
621909885543Smrg    fi
622009885543Smrg
622109885543Smrg    if test -n "$current_libdirs"; then
622209885543Smrg      # Maybe just do a dry run.
622309885543Smrg      test -n "$run" && current_libdirs=" -n$current_libdirs"
622409885543Smrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
622509885543Smrg    else
622609885543Smrg      exit $EXIT_SUCCESS
622709885543Smrg    fi
622809885543Smrg    ;;
622909885543Smrg
623009885543Smrg  # libtool finish mode
623109885543Smrg  finish)
623209885543Smrg    modename="$modename: finish"
623309885543Smrg    libdirs="$nonopt"
623409885543Smrg    admincmds=
623509885543Smrg
623609885543Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
623709885543Smrg      for dir
623809885543Smrg      do
623909885543Smrg	libdirs="$libdirs $dir"
624009885543Smrg      done
624109885543Smrg
624209885543Smrg      for libdir in $libdirs; do
624309885543Smrg	if test -n "$finish_cmds"; then
624409885543Smrg	  # Do each command in the finish commands.
624509885543Smrg	  cmds=$finish_cmds
624609885543Smrg	  save_ifs="$IFS"; IFS='~'
624709885543Smrg	  for cmd in $cmds; do
624809885543Smrg	    IFS="$save_ifs"
624909885543Smrg	    eval cmd=\"$cmd\"
625009885543Smrg	    $show "$cmd"
625109885543Smrg	    $run eval "$cmd" || admincmds="$admincmds
625209885543Smrg       $cmd"
625309885543Smrg	  done
625409885543Smrg	  IFS="$save_ifs"
625509885543Smrg	fi
625609885543Smrg	if test -n "$finish_eval"; then
625709885543Smrg	  # Do the single finish_eval.
625809885543Smrg	  eval cmds=\"$finish_eval\"
625909885543Smrg	  $run eval "$cmds" || admincmds="$admincmds
626009885543Smrg       $cmds"
626109885543Smrg	fi
626209885543Smrg      done
626309885543Smrg    fi
626409885543Smrg
626509885543Smrg    # Exit here if they wanted silent mode.
626609885543Smrg    test "$show" = : && exit $EXIT_SUCCESS
626709885543Smrg
626809885543Smrg    $echo "X----------------------------------------------------------------------" | $Xsed
626909885543Smrg    $echo "Libraries have been installed in:"
627009885543Smrg    for libdir in $libdirs; do
627109885543Smrg      $echo "   $libdir"
627209885543Smrg    done
627309885543Smrg    $echo
627409885543Smrg    $echo "If you ever happen to want to link against installed libraries"
627509885543Smrg    $echo "in a given directory, LIBDIR, you must either use libtool, and"
627609885543Smrg    $echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
627709885543Smrg    $echo "flag during linking and do at least one of the following:"
627809885543Smrg    if test -n "$shlibpath_var"; then
627909885543Smrg      $echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
628009885543Smrg      $echo "     during execution"
628109885543Smrg    fi
628209885543Smrg    if test -n "$runpath_var"; then
628309885543Smrg      $echo "   - add LIBDIR to the \`$runpath_var' environment variable"
628409885543Smrg      $echo "     during linking"
628509885543Smrg    fi
628609885543Smrg    if test -n "$hardcode_libdir_flag_spec"; then
628709885543Smrg      libdir=LIBDIR
628809885543Smrg      eval flag=\"$hardcode_libdir_flag_spec\"
628909885543Smrg
629009885543Smrg      $echo "   - use the \`$flag' linker flag"
629109885543Smrg    fi
629209885543Smrg    if test -n "$admincmds"; then
629309885543Smrg      $echo "   - have your system administrator run these commands:$admincmds"
629409885543Smrg    fi
629509885543Smrg    if test -f /etc/ld.so.conf; then
629609885543Smrg      $echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
629709885543Smrg    fi
629809885543Smrg    $echo
629909885543Smrg    $echo "See any operating system documentation about shared libraries for"
630009885543Smrg    $echo "more information, such as the ld(1) and ld.so(8) manual pages."
630109885543Smrg    $echo "X----------------------------------------------------------------------" | $Xsed
630209885543Smrg    exit $EXIT_SUCCESS
630309885543Smrg    ;;
630409885543Smrg
630509885543Smrg  # libtool execute mode
630609885543Smrg  execute)
630709885543Smrg    modename="$modename: execute"
630809885543Smrg
630909885543Smrg    # The first argument is the command name.
631009885543Smrg    cmd="$nonopt"
631109885543Smrg    if test -z "$cmd"; then
631209885543Smrg      $echo "$modename: you must specify a COMMAND" 1>&2
631309885543Smrg      $echo "$help"
631409885543Smrg      exit $EXIT_FAILURE
631509885543Smrg    fi
631609885543Smrg
631709885543Smrg    # Handle -dlopen flags immediately.
631809885543Smrg    for file in $execute_dlfiles; do
631909885543Smrg      if test ! -f "$file"; then
632009885543Smrg	$echo "$modename: \`$file' is not a file" 1>&2
632109885543Smrg	$echo "$help" 1>&2
632209885543Smrg	exit $EXIT_FAILURE
632309885543Smrg      fi
632409885543Smrg
632509885543Smrg      dir=
632609885543Smrg      case $file in
632709885543Smrg      *.la)
632809885543Smrg	# Check to see that this really is a libtool archive.
632909885543Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
633009885543Smrg	else
633109885543Smrg	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
633209885543Smrg	  $echo "$help" 1>&2
633309885543Smrg	  exit $EXIT_FAILURE
633409885543Smrg	fi
633509885543Smrg
633609885543Smrg	# Read the libtool library.
633709885543Smrg	dlname=
633809885543Smrg	library_names=
633909885543Smrg
634009885543Smrg	# If there is no directory component, then add one.
634109885543Smrg	case $file in
634209885543Smrg	*/* | *\\*) . $file ;;
634309885543Smrg	*) . ./$file ;;
634409885543Smrg	esac
634509885543Smrg
634609885543Smrg	# Skip this library if it cannot be dlopened.
634709885543Smrg	if test -z "$dlname"; then
634809885543Smrg	  # Warn if it was a shared library.
634909885543Smrg	  test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'"
635009885543Smrg	  continue
635109885543Smrg	fi
635209885543Smrg
635309885543Smrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
635409885543Smrg	test "X$dir" = "X$file" && dir=.
635509885543Smrg
635609885543Smrg	if test -f "$dir/$objdir/$dlname"; then
635709885543Smrg	  dir="$dir/$objdir"
635809885543Smrg	else
635909885543Smrg	  $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
636009885543Smrg	  exit $EXIT_FAILURE
636109885543Smrg	fi
636209885543Smrg	;;
636309885543Smrg
636409885543Smrg      *.lo)
636509885543Smrg	# Just add the directory containing the .lo file.
636609885543Smrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
636709885543Smrg	test "X$dir" = "X$file" && dir=.
636809885543Smrg	;;
636909885543Smrg
637009885543Smrg      *)
637109885543Smrg	$echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2
637209885543Smrg	continue
637309885543Smrg	;;
637409885543Smrg      esac
637509885543Smrg
637609885543Smrg      # Get the absolute pathname.
637709885543Smrg      absdir=`cd "$dir" && pwd`
637809885543Smrg      test -n "$absdir" && dir="$absdir"
637909885543Smrg
638009885543Smrg      # Now add the directory to shlibpath_var.
638109885543Smrg      if eval "test -z \"\$$shlibpath_var\""; then
638209885543Smrg	eval "$shlibpath_var=\"\$dir\""
638309885543Smrg      else
638409885543Smrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
638509885543Smrg      fi
638609885543Smrg    done
638709885543Smrg
638809885543Smrg    # This variable tells wrapper scripts just to set shlibpath_var
638909885543Smrg    # rather than running their programs.
639009885543Smrg    libtool_execute_magic="$magic"
639109885543Smrg
639209885543Smrg    # Check if any of the arguments is a wrapper script.
639309885543Smrg    args=
639409885543Smrg    for file
639509885543Smrg    do
639609885543Smrg      case $file in
639709885543Smrg      -*) ;;
639809885543Smrg      *)
639909885543Smrg	# Do a test to see if this is really a libtool program.
640009885543Smrg	if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
640109885543Smrg	  # If there is no directory component, then add one.
640209885543Smrg	  case $file in
640309885543Smrg	  */* | *\\*) . $file ;;
640409885543Smrg	  *) . ./$file ;;
640509885543Smrg	  esac
640609885543Smrg
640709885543Smrg	  # Transform arg to wrapped name.
640809885543Smrg	  file="$progdir/$program"
640909885543Smrg	fi
641009885543Smrg	;;
641109885543Smrg      esac
641209885543Smrg      # Quote arguments (to preserve shell metacharacters).
641309885543Smrg      file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"`
641409885543Smrg      args="$args \"$file\""
641509885543Smrg    done
641609885543Smrg
641709885543Smrg    if test -z "$run"; then
641809885543Smrg      if test -n "$shlibpath_var"; then
641909885543Smrg	# Export the shlibpath_var.
642009885543Smrg	eval "export $shlibpath_var"
642109885543Smrg      fi
642209885543Smrg
642309885543Smrg      # Restore saved environment variables
642409885543Smrg      if test "${save_LC_ALL+set}" = set; then
642509885543Smrg	LC_ALL="$save_LC_ALL"; export LC_ALL
642609885543Smrg      fi
642709885543Smrg      if test "${save_LANG+set}" = set; then
642809885543Smrg	LANG="$save_LANG"; export LANG
642909885543Smrg      fi
643009885543Smrg
643109885543Smrg      # Now prepare to actually exec the command.
643209885543Smrg      exec_cmd="\$cmd$args"
643309885543Smrg    else
643409885543Smrg      # Display what would be done.
643509885543Smrg      if test -n "$shlibpath_var"; then
643609885543Smrg	eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\""
643709885543Smrg	$echo "export $shlibpath_var"
643809885543Smrg      fi
643909885543Smrg      $echo "$cmd$args"
644009885543Smrg      exit $EXIT_SUCCESS
644109885543Smrg    fi
644209885543Smrg    ;;
644309885543Smrg
644409885543Smrg  # libtool clean and uninstall mode
644509885543Smrg  clean | uninstall)
644609885543Smrg    modename="$modename: $mode"
644709885543Smrg    rm="$nonopt"
644809885543Smrg    files=
644909885543Smrg    rmforce=
645009885543Smrg    exit_status=0
645109885543Smrg
645209885543Smrg    # This variable tells wrapper scripts just to set variables rather
645309885543Smrg    # than running their programs.
645409885543Smrg    libtool_install_magic="$magic"
645509885543Smrg
645609885543Smrg    for arg
645709885543Smrg    do
645809885543Smrg      case $arg in
645909885543Smrg      -f) rm="$rm $arg"; rmforce=yes ;;
646009885543Smrg      -*) rm="$rm $arg" ;;
646109885543Smrg      *) files="$files $arg" ;;
646209885543Smrg      esac
646309885543Smrg    done
646409885543Smrg
646509885543Smrg    if test -z "$rm"; then
646609885543Smrg      $echo "$modename: you must specify an RM program" 1>&2
646709885543Smrg      $echo "$help" 1>&2
646809885543Smrg      exit $EXIT_FAILURE
646909885543Smrg    fi
647009885543Smrg
647109885543Smrg    rmdirs=
647209885543Smrg
647309885543Smrg    origobjdir="$objdir"
647409885543Smrg    for file in $files; do
647509885543Smrg      dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
647609885543Smrg      if test "X$dir" = "X$file"; then
647709885543Smrg	dir=.
647809885543Smrg	objdir="$origobjdir"
647909885543Smrg      else
648009885543Smrg	objdir="$dir/$origobjdir"
648109885543Smrg      fi
648209885543Smrg      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
648309885543Smrg      test "$mode" = uninstall && objdir="$dir"
648409885543Smrg
648509885543Smrg      # Remember objdir for removal later, being careful to avoid duplicates
648609885543Smrg      if test "$mode" = clean; then
648709885543Smrg	case " $rmdirs " in
648809885543Smrg	  *" $objdir "*) ;;
648909885543Smrg	  *) rmdirs="$rmdirs $objdir" ;;
649009885543Smrg	esac
649109885543Smrg      fi
649209885543Smrg
649309885543Smrg      # Don't error if the file doesn't exist and rm -f was used.
649409885543Smrg      if (test -L "$file") >/dev/null 2>&1 \
649509885543Smrg	|| (test -h "$file") >/dev/null 2>&1 \
649609885543Smrg	|| test -f "$file"; then
649709885543Smrg	:
649809885543Smrg      elif test -d "$file"; then
649909885543Smrg	exit_status=1
650009885543Smrg	continue
650109885543Smrg      elif test "$rmforce" = yes; then
650209885543Smrg	continue
650309885543Smrg      fi
650409885543Smrg
650509885543Smrg      rmfiles="$file"
650609885543Smrg
650709885543Smrg      case $name in
650809885543Smrg      *.la)
650909885543Smrg	# Possibly a libtool archive, so verify it.
651009885543Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
651109885543Smrg	  . $dir/$name
651209885543Smrg
651309885543Smrg	  # Delete the libtool libraries and symlinks.
651409885543Smrg	  for n in $library_names; do
651509885543Smrg	    rmfiles="$rmfiles $objdir/$n"
651609885543Smrg	  done
651709885543Smrg	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
651809885543Smrg
651909885543Smrg	  case "$mode" in
652009885543Smrg	  clean)
652109885543Smrg	    case "  $library_names " in
652209885543Smrg	    # "  " in the beginning catches empty $dlname
652309885543Smrg	    *" $dlname "*) ;;
652409885543Smrg	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
652509885543Smrg	    esac
652609885543Smrg	     test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
652709885543Smrg	    ;;
652809885543Smrg	  uninstall)
652909885543Smrg	    if test -n "$library_names"; then
653009885543Smrg	      # Do each command in the postuninstall commands.
653109885543Smrg	      cmds=$postuninstall_cmds
653209885543Smrg	      save_ifs="$IFS"; IFS='~'
653309885543Smrg	      for cmd in $cmds; do
653409885543Smrg		IFS="$save_ifs"
653509885543Smrg		eval cmd=\"$cmd\"
653609885543Smrg		$show "$cmd"
653709885543Smrg		$run eval "$cmd"
653809885543Smrg		if test "$?" -ne 0 && test "$rmforce" != yes; then
653909885543Smrg		  exit_status=1
654009885543Smrg		fi
654109885543Smrg	      done
654209885543Smrg	      IFS="$save_ifs"
654309885543Smrg	    fi
654409885543Smrg
654509885543Smrg	    if test -n "$old_library"; then
654609885543Smrg	      # Do each command in the old_postuninstall commands.
654709885543Smrg	      cmds=$old_postuninstall_cmds
654809885543Smrg	      save_ifs="$IFS"; IFS='~'
654909885543Smrg	      for cmd in $cmds; do
655009885543Smrg		IFS="$save_ifs"
655109885543Smrg		eval cmd=\"$cmd\"
655209885543Smrg		$show "$cmd"
655309885543Smrg		$run eval "$cmd"
655409885543Smrg		if test "$?" -ne 0 && test "$rmforce" != yes; then
655509885543Smrg		  exit_status=1
655609885543Smrg		fi
655709885543Smrg	      done
655809885543Smrg	      IFS="$save_ifs"
655909885543Smrg	    fi
656009885543Smrg	    # FIXME: should reinstall the best remaining shared library.
656109885543Smrg	    ;;
656209885543Smrg	  esac
656309885543Smrg	fi
656409885543Smrg	;;
656509885543Smrg
656609885543Smrg      *.lo)
656709885543Smrg	# Possibly a libtool object, so verify it.
656809885543Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
656909885543Smrg
657009885543Smrg	  # Read the .lo file
657109885543Smrg	  . $dir/$name
657209885543Smrg
657309885543Smrg	  # Add PIC object to the list of files to remove.
657409885543Smrg	  if test -n "$pic_object" \
657509885543Smrg	     && test "$pic_object" != none; then
657609885543Smrg	    rmfiles="$rmfiles $dir/$pic_object"
657709885543Smrg	  fi
657809885543Smrg
657909885543Smrg	  # Add non-PIC object to the list of files to remove.
658009885543Smrg	  if test -n "$non_pic_object" \
658109885543Smrg	     && test "$non_pic_object" != none; then
658209885543Smrg	    rmfiles="$rmfiles $dir/$non_pic_object"
658309885543Smrg	  fi
658409885543Smrg	fi
658509885543Smrg	;;
658609885543Smrg
658709885543Smrg      *)
658809885543Smrg	if test "$mode" = clean ; then
658909885543Smrg	  noexename=$name
659009885543Smrg	  case $file in
659109885543Smrg	  *.exe)
659209885543Smrg	    file=`$echo $file|${SED} 's,.exe$,,'`
659309885543Smrg	    noexename=`$echo $name|${SED} 's,.exe$,,'`
659409885543Smrg	    # $file with .exe has already been added to rmfiles,
659509885543Smrg	    # add $file without .exe
659609885543Smrg	    rmfiles="$rmfiles $file"
659709885543Smrg	    ;;
659809885543Smrg	  esac
659909885543Smrg	  # Do a test to see if this is a libtool program.
660009885543Smrg	  if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
660109885543Smrg	    relink_command=
660209885543Smrg	    . $dir/$noexename
660309885543Smrg
660409885543Smrg	    # note $name still contains .exe if it was in $file originally
660509885543Smrg	    # as does the version of $file that was added into $rmfiles
660609885543Smrg	    rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
660709885543Smrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
660809885543Smrg	      rmfiles="$rmfiles $objdir/lt-$name"
660909885543Smrg	    fi
661009885543Smrg	    if test "X$noexename" != "X$name" ; then
661109885543Smrg	      rmfiles="$rmfiles $objdir/lt-${noexename}.c"
661209885543Smrg	    fi
661309885543Smrg	  fi
661409885543Smrg	fi
661509885543Smrg	;;
661609885543Smrg      esac
661709885543Smrg      $show "$rm $rmfiles"
661809885543Smrg      $run $rm $rmfiles || exit_status=1
661909885543Smrg    done
662009885543Smrg    objdir="$origobjdir"
662109885543Smrg
662209885543Smrg    # Try to remove the ${objdir}s in the directories where we deleted files
662309885543Smrg    for dir in $rmdirs; do
662409885543Smrg      if test -d "$dir"; then
662509885543Smrg	$show "rmdir $dir"
662609885543Smrg	$run rmdir $dir >/dev/null 2>&1
662709885543Smrg      fi
662809885543Smrg    done
662909885543Smrg
663009885543Smrg    exit $exit_status
663109885543Smrg    ;;
663209885543Smrg
663309885543Smrg  "")
663409885543Smrg    $echo "$modename: you must specify a MODE" 1>&2
663509885543Smrg    $echo "$generic_help" 1>&2
663609885543Smrg    exit $EXIT_FAILURE
663709885543Smrg    ;;
663809885543Smrg  esac
663909885543Smrg
664009885543Smrg  if test -z "$exec_cmd"; then
664109885543Smrg    $echo "$modename: invalid operation mode \`$mode'" 1>&2
664209885543Smrg    $echo "$generic_help" 1>&2
664309885543Smrg    exit $EXIT_FAILURE
664409885543Smrg  fi
664509885543Smrgfi # test -z "$show_help"
664609885543Smrg
664709885543Smrgif test -n "$exec_cmd"; then
664809885543Smrg  eval exec $exec_cmd
664909885543Smrg  exit $EXIT_FAILURE
665009885543Smrgfi
665109885543Smrg
665209885543Smrg# We need to display help for each of the modes.
665309885543Smrgcase $mode in
665409885543Smrg"") $echo \
665509885543Smrg"Usage: $modename [OPTION]... [MODE-ARG]...
665609885543Smrg
665709885543SmrgProvide generalized library-building support services.
665809885543Smrg
665909885543Smrg    --config          show all configuration variables
666009885543Smrg    --debug           enable verbose shell tracing
666109885543Smrg-n, --dry-run         display commands without modifying any files
666209885543Smrg    --features        display basic configuration information and exit
666309885543Smrg    --finish          same as \`--mode=finish'
666409885543Smrg    --help            display this help message and exit
666509885543Smrg    --mode=MODE       use operation mode MODE [default=inferred from MODE-ARGS]
666609885543Smrg    --quiet           same as \`--silent'
666709885543Smrg    --silent          don't print informational messages
666809885543Smrg    --tag=TAG         use configuration variables from tag TAG
666909885543Smrg    --version         print version information
667009885543Smrg
667109885543SmrgMODE must be one of the following:
667209885543Smrg
667309885543Smrg      clean           remove files from the build directory
667409885543Smrg      compile         compile a source file into a libtool object
667509885543Smrg      execute         automatically set library path, then run a program
667609885543Smrg      finish          complete the installation of libtool libraries
667709885543Smrg      install         install libraries or executables
667809885543Smrg      link            create a library or an executable
667909885543Smrg      uninstall       remove libraries from an installed directory
668009885543Smrg
668109885543SmrgMODE-ARGS vary depending on the MODE.  Try \`$modename --help --mode=MODE' for
668209885543Smrga more detailed description of MODE.
668309885543Smrg
668409885543SmrgReport bugs to <bug-libtool@gnu.org>."
668509885543Smrg  exit $EXIT_SUCCESS
668609885543Smrg  ;;
668709885543Smrg
668809885543Smrgclean)
668909885543Smrg  $echo \
669009885543Smrg"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
669109885543Smrg
669209885543SmrgRemove files from the build directory.
669309885543Smrg
669409885543SmrgRM is the name of the program to use to delete files associated with each FILE
669509885543Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
669609885543Smrgto RM.
669709885543Smrg
669809885543SmrgIf FILE is a libtool library, object or program, all the files associated
669909885543Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
670009885543Smrg  ;;
670109885543Smrg
670209885543Smrgcompile)
670309885543Smrg  $echo \
670409885543Smrg"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
670509885543Smrg
670609885543SmrgCompile a source file into a libtool library object.
670709885543Smrg
670809885543SmrgThis mode accepts the following additional options:
670909885543Smrg
671009885543Smrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
671109885543Smrg  -prefer-pic       try to building PIC objects only
671209885543Smrg  -prefer-non-pic   try to building non-PIC objects only
671309885543Smrg  -static           always build a \`.o' file suitable for static linking
671409885543Smrg
671509885543SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
671609885543Smrgfrom the given SOURCEFILE.
671709885543Smrg
671809885543SmrgThe output file name is determined by removing the directory component from
671909885543SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
672009885543Smrglibrary object suffix, \`.lo'."
672109885543Smrg  ;;
672209885543Smrg
672309885543Smrgexecute)
672409885543Smrg  $echo \
672509885543Smrg"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]...
672609885543Smrg
672709885543SmrgAutomatically set library path, then run a program.
672809885543Smrg
672909885543SmrgThis mode accepts the following additional options:
673009885543Smrg
673109885543Smrg  -dlopen FILE      add the directory containing FILE to the library path
673209885543Smrg
673309885543SmrgThis mode sets the library path environment variable according to \`-dlopen'
673409885543Smrgflags.
673509885543Smrg
673609885543SmrgIf any of the ARGS are libtool executable wrappers, then they are translated
673709885543Smrginto their corresponding uninstalled binary, and any of their required library
673809885543Smrgdirectories are added to the library path.
673909885543Smrg
674009885543SmrgThen, COMMAND is executed, with ARGS as arguments."
674109885543Smrg  ;;
674209885543Smrg
674309885543Smrgfinish)
674409885543Smrg  $echo \
674509885543Smrg"Usage: $modename [OPTION]... --mode=finish [LIBDIR]...
674609885543Smrg
674709885543SmrgComplete the installation of libtool libraries.
674809885543Smrg
674909885543SmrgEach LIBDIR is a directory that contains libtool libraries.
675009885543Smrg
675109885543SmrgThe commands that this mode executes may require superuser privileges.  Use
675209885543Smrgthe \`--dry-run' option if you just want to see what would be executed."
675309885543Smrg  ;;
675409885543Smrg
675509885543Smrginstall)
675609885543Smrg  $echo \
675709885543Smrg"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND...
675809885543Smrg
675909885543SmrgInstall executables or libraries.
676009885543Smrg
676109885543SmrgINSTALL-COMMAND is the installation command.  The first component should be
676209885543Smrgeither the \`install' or \`cp' program.
676309885543Smrg
676409885543SmrgThe rest of the components are interpreted as arguments to that command (only
676509885543SmrgBSD-compatible install options are recognized)."
676609885543Smrg  ;;
676709885543Smrg
676809885543Smrglink)
676909885543Smrg  $echo \
677009885543Smrg"Usage: $modename [OPTION]... --mode=link LINK-COMMAND...
677109885543Smrg
677209885543SmrgLink object files or libraries together to form another library, or to
677309885543Smrgcreate an executable program.
677409885543Smrg
677509885543SmrgLINK-COMMAND is a command using the C compiler that you would use to create
677609885543Smrga program from several object files.
677709885543Smrg
677809885543SmrgThe following components of LINK-COMMAND are treated specially:
677909885543Smrg
678009885543Smrg  -all-static       do not do any dynamic linking at all
678109885543Smrg  -avoid-version    do not add a version suffix if possible
678209885543Smrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
678309885543Smrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
678409885543Smrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
678509885543Smrg  -export-symbols SYMFILE
678609885543Smrg		    try to export only the symbols listed in SYMFILE
678709885543Smrg  -export-symbols-regex REGEX
678809885543Smrg		    try to export only the symbols matching REGEX
678909885543Smrg  -LLIBDIR          search LIBDIR for required installed libraries
679009885543Smrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
679109885543Smrg  -module           build a library that can dlopened
679209885543Smrg  -no-fast-install  disable the fast-install mode
679309885543Smrg  -no-install       link a not-installable executable
679409885543Smrg  -no-undefined     declare that a library does not refer to external symbols
679509885543Smrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
679609885543Smrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
679709885543Smrg  -precious-files-regex REGEX
679809885543Smrg                    don't remove output files matching REGEX
679909885543Smrg  -release RELEASE  specify package release information
680009885543Smrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
680109885543Smrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
680209885543Smrg  -static           do not do any dynamic linking of libtool libraries
680309885543Smrg  -version-info CURRENT[:REVISION[:AGE]]
680409885543Smrg		    specify library version info [each variable defaults to 0]
680509885543Smrg
680609885543SmrgAll other options (arguments beginning with \`-') are ignored.
680709885543Smrg
680809885543SmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
680909885543Smrgtreated as uninstalled libtool libraries, other files are standard or library
681009885543Smrgobject files.
681109885543Smrg
681209885543SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
681309885543Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
681409885543Smrgrequired, except when creating a convenience library.
681509885543Smrg
681609885543SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
681709885543Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
681809885543Smrg
681909885543SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
682009885543Smrgis created, otherwise an executable program is created."
682109885543Smrg  ;;
682209885543Smrg
682309885543Smrguninstall)
682409885543Smrg  $echo \
682509885543Smrg"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
682609885543Smrg
682709885543SmrgRemove libraries from an installation directory.
682809885543Smrg
682909885543SmrgRM is the name of the program to use to delete files associated with each FILE
683009885543Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
683109885543Smrgto RM.
683209885543Smrg
683309885543SmrgIf FILE is a libtool library, all the files associated with it are deleted.
683409885543SmrgOtherwise, only FILE itself is deleted using RM."
683509885543Smrg  ;;
683609885543Smrg
683709885543Smrg*)
683809885543Smrg  $echo "$modename: invalid operation mode \`$mode'" 1>&2
683909885543Smrg  $echo "$help" 1>&2
684009885543Smrg  exit $EXIT_FAILURE
684109885543Smrg  ;;
684209885543Smrgesac
684309885543Smrg
684409885543Smrg$echo
684509885543Smrg$echo "Try \`$modename --help' for more information about other modes."
684609885543Smrg
684709885543Smrgexit $?
684809885543Smrg
684909885543Smrg# The TAGs below are defined such that we never get into a situation
685009885543Smrg# in which we disable both kinds of libraries.  Given conflicting
685109885543Smrg# choices, we go for a static library, that is the most portable,
685209885543Smrg# since we can't tell whether shared libraries were disabled because
685309885543Smrg# the user asked for that or because the platform doesn't support
685409885543Smrg# them.  This is particularly important on AIX, because we don't
685509885543Smrg# support having both static and shared libraries enabled at the same
685609885543Smrg# time on that platform, so we default to a shared-only configuration.
685709885543Smrg# If a disable-shared tag is given, we'll fallback to a static-only
685809885543Smrg# configuration.  But we'll never go from static-only to shared-only.
685909885543Smrg
686009885543Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
686109885543Smrgdisable_libs=shared
686209885543Smrg# ### END LIBTOOL TAG CONFIG: disable-shared
686309885543Smrg
686409885543Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
686509885543Smrgdisable_libs=static
686609885543Smrg# ### END LIBTOOL TAG CONFIG: disable-static
686709885543Smrg
686809885543Smrg# Local Variables:
686909885543Smrg# mode:shell-script
687009885543Smrg# sh-indentation:2
687109885543Smrg# End:
6872