ltmain.sh revision 72b676d7
172b676d7Smrg# ltmain.sh - Provide generalized library-building support services.
272b676d7Smrg# NOTE: Changing this file will not affect anything until you rerun configure.
372b676d7Smrg#
472b676d7Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005
572b676d7Smrg# Free Software Foundation, Inc.
672b676d7Smrg# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
772b676d7Smrg#
872b676d7Smrg# This program is free software; you can redistribute it and/or modify
972b676d7Smrg# it under the terms of the GNU General Public License as published by
1072b676d7Smrg# the Free Software Foundation; either version 2 of the License, or
1172b676d7Smrg# (at your option) any later version.
1272b676d7Smrg#
1372b676d7Smrg# This program is distributed in the hope that it will be useful, but
1472b676d7Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
1572b676d7Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1672b676d7Smrg# General Public License for more details.
1772b676d7Smrg#
1872b676d7Smrg# You should have received a copy of the GNU General Public License
1972b676d7Smrg# along with this program; if not, write to the Free Software
2072b676d7Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2172b676d7Smrg#
2272b676d7Smrg# As a special exception to the GNU General Public License, if you
2372b676d7Smrg# distribute this file as part of a program that contains a
2472b676d7Smrg# configuration script generated by Autoconf, you may include it under
2572b676d7Smrg# the same distribution terms that you use for the rest of that program.
2672b676d7Smrg
2772b676d7Smrgbasename="s,^.*/,,g"
2872b676d7Smrg
2972b676d7Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
3072b676d7Smrg# is ksh but when the shell is invoked as "sh" and the current value of
3172b676d7Smrg# the _XPG environment variable is not equal to 1 (one), the special
3272b676d7Smrg# positional parameter $0, within a function call, is the name of the
3372b676d7Smrg# function.
3472b676d7Smrgprogpath="$0"
3572b676d7Smrg
3672b676d7Smrg# The name of this program:
3772b676d7Smrgprogname=`echo "$progpath" | $SED $basename`
3872b676d7Smrgmodename="$progname"
3972b676d7Smrg
4072b676d7Smrg# Global variables:
4172b676d7SmrgEXIT_SUCCESS=0
4272b676d7SmrgEXIT_FAILURE=1
4372b676d7Smrg
4472b676d7SmrgPROGRAM=ltmain.sh
4572b676d7SmrgPACKAGE=libtool
4672b676d7SmrgVERSION="1.5.22 Debian 1.5.22-4"
4772b676d7SmrgTIMESTAMP=" (1.1220.2.365 2005/12/18 22:14:06)"
4872b676d7Smrg
4972b676d7Smrg# See if we are running on zsh, and set the options which allow our
5072b676d7Smrg# commands through without removal of \ escapes.
5172b676d7Smrgif test -n "${ZSH_VERSION+set}" ; then
5272b676d7Smrg  setopt NO_GLOB_SUBST
5372b676d7Smrgfi
5472b676d7Smrg
5572b676d7Smrg# Check that we have a working $echo.
5672b676d7Smrgif test "X$1" = X--no-reexec; then
5772b676d7Smrg  # Discard the --no-reexec flag, and continue.
5872b676d7Smrg  shift
5972b676d7Smrgelif test "X$1" = X--fallback-echo; then
6072b676d7Smrg  # Avoid inline document here, it may be left over
6172b676d7Smrg  :
6272b676d7Smrgelif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
6372b676d7Smrg  # Yippee, $echo works!
6472b676d7Smrg  :
6572b676d7Smrgelse
6672b676d7Smrg  # Restart under the correct shell, and then maybe $echo will work.
6772b676d7Smrg  exec $SHELL "$progpath" --no-reexec ${1+"$@"}
6872b676d7Smrgfi
6972b676d7Smrg
7072b676d7Smrgif test "X$1" = X--fallback-echo; then
7172b676d7Smrg  # used as fallback echo
7272b676d7Smrg  shift
7372b676d7Smrg  cat <<EOF
7472b676d7Smrg$*
7572b676d7SmrgEOF
7672b676d7Smrg  exit $EXIT_SUCCESS
7772b676d7Smrgfi
7872b676d7Smrg
7972b676d7Smrgdefault_mode=
8072b676d7Smrghelp="Try \`$progname --help' for more information."
8172b676d7Smrgmagic="%%%MAGIC variable%%%"
8272b676d7Smrgmkdir="mkdir"
8372b676d7Smrgmv="mv -f"
8472b676d7Smrgrm="rm -f"
8572b676d7Smrg
8672b676d7Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
8772b676d7Smrg# metacharacters that are still active within double-quoted strings.
8872b676d7SmrgXsed="${SED}"' -e 1s/^X//'
8972b676d7Smrgsed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
9072b676d7Smrg# test EBCDIC or ASCII
9172b676d7Smrgcase `echo X|tr X '\101'` in
9272b676d7Smrg A) # ASCII based system
9372b676d7Smrg    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
9472b676d7Smrg  SP2NL='tr \040 \012'
9572b676d7Smrg  NL2SP='tr \015\012 \040\040'
9672b676d7Smrg  ;;
9772b676d7Smrg *) # EBCDIC based system
9872b676d7Smrg  SP2NL='tr \100 \n'
9972b676d7Smrg  NL2SP='tr \r\n \100\100'
10072b676d7Smrg  ;;
10172b676d7Smrgesac
10272b676d7Smrg
10372b676d7Smrg# NLS nuisances.
10472b676d7Smrg# Only set LANG and LC_ALL to C if already set.
10572b676d7Smrg# These must not be set unconditionally because not all systems understand
10672b676d7Smrg# e.g. LANG=C (notably SCO).
10772b676d7Smrg# We save the old values to restore during execute mode.
10872b676d7Smrgif test "${LC_ALL+set}" = set; then
10972b676d7Smrg  save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
11072b676d7Smrgfi
11172b676d7Smrgif test "${LANG+set}" = set; then
11272b676d7Smrg  save_LANG="$LANG"; LANG=C; export LANG
11372b676d7Smrgfi
11472b676d7Smrg
11572b676d7Smrg# Make sure IFS has a sensible default
11672b676d7Smrglt_nl='
11772b676d7Smrg'
11872b676d7SmrgIFS=" 	$lt_nl"
11972b676d7Smrg
12072b676d7Smrgif test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
12172b676d7Smrg  $echo "$modename: not configured to build any kind of library" 1>&2
12272b676d7Smrg  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
12372b676d7Smrg  exit $EXIT_FAILURE
12472b676d7Smrgfi
12572b676d7Smrg
12672b676d7Smrg# Global variables.
12772b676d7Smrgmode=$default_mode
12872b676d7Smrgnonopt=
12972b676d7Smrgprev=
13072b676d7Smrgprevopt=
13172b676d7Smrgrun=
13272b676d7Smrgshow="$echo"
13372b676d7Smrgshow_help=
13472b676d7Smrgexecute_dlfiles=
13572b676d7Smrgduplicate_deps=no
13672b676d7Smrgpreserve_args=
13772b676d7Smrglo2o="s/\\.lo\$/.${objext}/"
13872b676d7Smrgo2lo="s/\\.${objext}\$/.lo/"
13972b676d7Smrg
14072b676d7Smrg#####################################
14172b676d7Smrg# Shell function definitions:
14272b676d7Smrg# This seems to be the best place for them
14372b676d7Smrg
14472b676d7Smrg# func_mktempdir [string]
14572b676d7Smrg# Make a temporary directory that won't clash with other running
14672b676d7Smrg# libtool processes, and avoids race conditions if possible.  If
14772b676d7Smrg# given, STRING is the basename for that directory.
14872b676d7Smrgfunc_mktempdir ()
14972b676d7Smrg{
15072b676d7Smrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
15172b676d7Smrg
15272b676d7Smrg    if test "$run" = ":"; then
15372b676d7Smrg      # Return a directory name, but don't create it in dry-run mode
15472b676d7Smrg      my_tmpdir="${my_template}-$$"
15572b676d7Smrg    else
15672b676d7Smrg
15772b676d7Smrg      # If mktemp works, use that first and foremost
15872b676d7Smrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
15972b676d7Smrg
16072b676d7Smrg      if test ! -d "$my_tmpdir"; then
16172b676d7Smrg	# Failing that, at least try and use $RANDOM to avoid a race
16272b676d7Smrg	my_tmpdir="${my_template}-${RANDOM-0}$$"
16372b676d7Smrg
16472b676d7Smrg	save_mktempdir_umask=`umask`
16572b676d7Smrg	umask 0077
16672b676d7Smrg	$mkdir "$my_tmpdir"
16772b676d7Smrg	umask $save_mktempdir_umask
16872b676d7Smrg      fi
16972b676d7Smrg
17072b676d7Smrg      # If we're not in dry-run mode, bomb out on failure
17172b676d7Smrg      test -d "$my_tmpdir" || {
17272b676d7Smrg        $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
17372b676d7Smrg	exit $EXIT_FAILURE
17472b676d7Smrg      }
17572b676d7Smrg    fi
17672b676d7Smrg
17772b676d7Smrg    $echo "X$my_tmpdir" | $Xsed
17872b676d7Smrg}
17972b676d7Smrg
18072b676d7Smrg
18172b676d7Smrg# func_win32_libid arg
18272b676d7Smrg# return the library type of file 'arg'
18372b676d7Smrg#
18472b676d7Smrg# Need a lot of goo to handle *both* DLLs and import libs
18572b676d7Smrg# Has to be a shell function in order to 'eat' the argument
18672b676d7Smrg# that is supplied when $file_magic_command is called.
18772b676d7Smrgfunc_win32_libid ()
18872b676d7Smrg{
18972b676d7Smrg  win32_libid_type="unknown"
19072b676d7Smrg  win32_fileres=`file -L $1 2>/dev/null`
19172b676d7Smrg  case $win32_fileres in
19272b676d7Smrg  *ar\ archive\ import\ library*) # definitely import
19372b676d7Smrg    win32_libid_type="x86 archive import"
19472b676d7Smrg    ;;
19572b676d7Smrg  *ar\ archive*) # could be an import, or static
19672b676d7Smrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
19772b676d7Smrg      $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
19872b676d7Smrg      win32_nmres=`eval $NM -f posix -A $1 | \
19972b676d7Smrg	$SED -n -e '1,100{/ I /{s,.*,import,;p;q;};}'`
20072b676d7Smrg      case $win32_nmres in
20172b676d7Smrg      import*)  win32_libid_type="x86 archive import";;
20272b676d7Smrg      *)        win32_libid_type="x86 archive static";;
20372b676d7Smrg      esac
20472b676d7Smrg    fi
20572b676d7Smrg    ;;
20672b676d7Smrg  *DLL*)
20772b676d7Smrg    win32_libid_type="x86 DLL"
20872b676d7Smrg    ;;
20972b676d7Smrg  *executable*) # but shell scripts are "executable" too...
21072b676d7Smrg    case $win32_fileres in
21172b676d7Smrg    *MS\ Windows\ PE\ Intel*)
21272b676d7Smrg      win32_libid_type="x86 DLL"
21372b676d7Smrg      ;;
21472b676d7Smrg    esac
21572b676d7Smrg    ;;
21672b676d7Smrg  esac
21772b676d7Smrg  $echo $win32_libid_type
21872b676d7Smrg}
21972b676d7Smrg
22072b676d7Smrg
22172b676d7Smrg# func_infer_tag arg
22272b676d7Smrg# Infer tagged configuration to use if any are available and
22372b676d7Smrg# if one wasn't chosen via the "--tag" command line option.
22472b676d7Smrg# Only attempt this if the compiler in the base compile
22572b676d7Smrg# command doesn't match the default compiler.
22672b676d7Smrg# arg is usually of the form 'gcc ...'
22772b676d7Smrgfunc_infer_tag ()
22872b676d7Smrg{
22972b676d7Smrg    if test -n "$available_tags" && test -z "$tagname"; then
23072b676d7Smrg      CC_quoted=
23172b676d7Smrg      for arg in $CC; do
23272b676d7Smrg	case $arg in
23372b676d7Smrg	  *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
23472b676d7Smrg	  arg="\"$arg\""
23572b676d7Smrg	  ;;
23672b676d7Smrg	esac
23772b676d7Smrg	CC_quoted="$CC_quoted $arg"
23872b676d7Smrg      done
23972b676d7Smrg      case $@ in
24072b676d7Smrg      # Blanks in the command may have been stripped by the calling shell,
24172b676d7Smrg      # but not from the CC environment variable when configure was run.
24272b676d7Smrg      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
24372b676d7Smrg      # Blanks at the start of $base_compile will cause this to fail
24472b676d7Smrg      # if we don't check for them as well.
24572b676d7Smrg      *)
24672b676d7Smrg	for z in $available_tags; do
24772b676d7Smrg	  if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
24872b676d7Smrg	    # Evaluate the configuration.
24972b676d7Smrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
25072b676d7Smrg	    CC_quoted=
25172b676d7Smrg	    for arg in $CC; do
25272b676d7Smrg	    # Double-quote args containing other shell metacharacters.
25372b676d7Smrg	    case $arg in
25472b676d7Smrg	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
25572b676d7Smrg	      arg="\"$arg\""
25672b676d7Smrg	      ;;
25772b676d7Smrg	    esac
25872b676d7Smrg	    CC_quoted="$CC_quoted $arg"
25972b676d7Smrg	  done
26072b676d7Smrg	    case "$@ " in
26172b676d7Smrg	      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
26272b676d7Smrg	      # The compiler in the base compile command matches
26372b676d7Smrg	      # the one in the tagged configuration.
26472b676d7Smrg	      # Assume this is the tagged configuration we want.
26572b676d7Smrg	      tagname=$z
26672b676d7Smrg	      break
26772b676d7Smrg	      ;;
26872b676d7Smrg	    esac
26972b676d7Smrg	  fi
27072b676d7Smrg	done
27172b676d7Smrg	# If $tagname still isn't set, then no tagged configuration
27272b676d7Smrg	# was found and let the user know that the "--tag" command
27372b676d7Smrg	# line option must be used.
27472b676d7Smrg	if test -z "$tagname"; then
27572b676d7Smrg	  $echo "$modename: unable to infer tagged configuration"
27672b676d7Smrg	  $echo "$modename: specify a tag with \`--tag'" 1>&2
27772b676d7Smrg	  exit $EXIT_FAILURE
27872b676d7Smrg#        else
27972b676d7Smrg#          $echo "$modename: using $tagname tagged configuration"
28072b676d7Smrg	fi
28172b676d7Smrg	;;
28272b676d7Smrg      esac
28372b676d7Smrg    fi
28472b676d7Smrg}
28572b676d7Smrg
28672b676d7Smrg
28772b676d7Smrg# func_extract_an_archive dir oldlib
28872b676d7Smrgfunc_extract_an_archive ()
28972b676d7Smrg{
29072b676d7Smrg    f_ex_an_ar_dir="$1"; shift
29172b676d7Smrg    f_ex_an_ar_oldlib="$1"
29272b676d7Smrg
29372b676d7Smrg    $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
29472b676d7Smrg    $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
29572b676d7Smrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
29672b676d7Smrg     :
29772b676d7Smrg    else
29872b676d7Smrg      $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2
29972b676d7Smrg      exit $EXIT_FAILURE
30072b676d7Smrg    fi
30172b676d7Smrg}
30272b676d7Smrg
30372b676d7Smrg# func_extract_archives gentop oldlib ...
30472b676d7Smrgfunc_extract_archives ()
30572b676d7Smrg{
30672b676d7Smrg    my_gentop="$1"; shift
30772b676d7Smrg    my_oldlibs=${1+"$@"}
30872b676d7Smrg    my_oldobjs=""
30972b676d7Smrg    my_xlib=""
31072b676d7Smrg    my_xabs=""
31172b676d7Smrg    my_xdir=""
31272b676d7Smrg    my_status=""
31372b676d7Smrg
31472b676d7Smrg    $show "${rm}r $my_gentop"
31572b676d7Smrg    $run ${rm}r "$my_gentop"
31672b676d7Smrg    $show "$mkdir $my_gentop"
31772b676d7Smrg    $run $mkdir "$my_gentop"
31872b676d7Smrg    my_status=$?
31972b676d7Smrg    if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
32072b676d7Smrg      exit $my_status
32172b676d7Smrg    fi
32272b676d7Smrg
32372b676d7Smrg    for my_xlib in $my_oldlibs; do
32472b676d7Smrg      # Extract the objects.
32572b676d7Smrg      case $my_xlib in
32672b676d7Smrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
32772b676d7Smrg	*) my_xabs=`pwd`"/$my_xlib" ;;
32872b676d7Smrg      esac
32972b676d7Smrg      my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
33072b676d7Smrg      my_xdir="$my_gentop/$my_xlib"
33172b676d7Smrg
33272b676d7Smrg      $show "${rm}r $my_xdir"
33372b676d7Smrg      $run ${rm}r "$my_xdir"
33472b676d7Smrg      $show "$mkdir $my_xdir"
33572b676d7Smrg      $run $mkdir "$my_xdir"
33672b676d7Smrg      exit_status=$?
33772b676d7Smrg      if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then
33872b676d7Smrg	exit $exit_status
33972b676d7Smrg      fi
34072b676d7Smrg      case $host in
34172b676d7Smrg      *-darwin*)
34272b676d7Smrg	$show "Extracting $my_xabs"
34372b676d7Smrg	# Do not bother doing anything if just a dry run
34472b676d7Smrg	if test -z "$run"; then
34572b676d7Smrg	  darwin_orig_dir=`pwd`
34672b676d7Smrg	  cd $my_xdir || exit $?
34772b676d7Smrg	  darwin_archive=$my_xabs
34872b676d7Smrg	  darwin_curdir=`pwd`
34972b676d7Smrg	  darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'`
35072b676d7Smrg	  darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
35172b676d7Smrg	  if test -n "$darwin_arches"; then 
35272b676d7Smrg	    darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
35372b676d7Smrg	    darwin_arch=
35472b676d7Smrg	    $show "$darwin_base_archive has multiple architectures $darwin_arches"
35572b676d7Smrg	    for darwin_arch in  $darwin_arches ; do
35672b676d7Smrg	      mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
35772b676d7Smrg	      lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
35872b676d7Smrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
35972b676d7Smrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
36072b676d7Smrg	      cd "$darwin_curdir"
36172b676d7Smrg	      $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
36272b676d7Smrg	    done # $darwin_arches
36372b676d7Smrg      ## Okay now we have a bunch of thin objects, gotta fatten them up :)
36472b676d7Smrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP`
36572b676d7Smrg	    darwin_file=
36672b676d7Smrg	    darwin_files=
36772b676d7Smrg	    for darwin_file in $darwin_filelist; do
36872b676d7Smrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
36972b676d7Smrg	      lipo -create -output "$darwin_file" $darwin_files
37072b676d7Smrg	    done # $darwin_filelist
37172b676d7Smrg	    ${rm}r unfat-$$
37272b676d7Smrg	    cd "$darwin_orig_dir"
37372b676d7Smrg	  else
37472b676d7Smrg	    cd "$darwin_orig_dir"
37572b676d7Smrg 	    func_extract_an_archive "$my_xdir" "$my_xabs"
37672b676d7Smrg	  fi # $darwin_arches
37772b676d7Smrg	fi # $run
37872b676d7Smrg	;;
37972b676d7Smrg      *)
38072b676d7Smrg        func_extract_an_archive "$my_xdir" "$my_xabs"
38172b676d7Smrg        ;;
38272b676d7Smrg      esac
38372b676d7Smrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
38472b676d7Smrg    done
38572b676d7Smrg    func_extract_archives_result="$my_oldobjs"
38672b676d7Smrg}
38772b676d7Smrg# End of Shell function definitions
38872b676d7Smrg#####################################
38972b676d7Smrg
39072b676d7Smrg# Darwin sucks
39172b676d7Smrgeval std_shrext=\"$shrext_cmds\"
39272b676d7Smrg
39372b676d7Smrgdisable_libs=no
39472b676d7Smrg
39572b676d7Smrg# Parse our command line options once, thoroughly.
39672b676d7Smrgwhile test "$#" -gt 0
39772b676d7Smrgdo
39872b676d7Smrg  arg="$1"
39972b676d7Smrg  shift
40072b676d7Smrg
40172b676d7Smrg  case $arg in
40272b676d7Smrg  -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
40372b676d7Smrg  *) optarg= ;;
40472b676d7Smrg  esac
40572b676d7Smrg
40672b676d7Smrg  # If the previous option needs an argument, assign it.
40772b676d7Smrg  if test -n "$prev"; then
40872b676d7Smrg    case $prev in
40972b676d7Smrg    execute_dlfiles)
41072b676d7Smrg      execute_dlfiles="$execute_dlfiles $arg"
41172b676d7Smrg      ;;
41272b676d7Smrg    tag)
41372b676d7Smrg      tagname="$arg"
41472b676d7Smrg      preserve_args="${preserve_args}=$arg"
41572b676d7Smrg
41672b676d7Smrg      # Check whether tagname contains only valid characters
41772b676d7Smrg      case $tagname in
41872b676d7Smrg      *[!-_A-Za-z0-9,/]*)
41972b676d7Smrg	$echo "$progname: invalid tag name: $tagname" 1>&2
42072b676d7Smrg	exit $EXIT_FAILURE
42172b676d7Smrg	;;
42272b676d7Smrg      esac
42372b676d7Smrg
42472b676d7Smrg      case $tagname in
42572b676d7Smrg      CC)
42672b676d7Smrg	# Don't test for the "default" C tag, as we know, it's there, but
42772b676d7Smrg	# not specially marked.
42872b676d7Smrg	;;
42972b676d7Smrg      *)
43072b676d7Smrg	if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then
43172b676d7Smrg	  taglist="$taglist $tagname"
43272b676d7Smrg	  # Evaluate the configuration.
43372b676d7Smrg	  eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`"
43472b676d7Smrg	else
43572b676d7Smrg	  $echo "$progname: ignoring unknown tag $tagname" 1>&2
43672b676d7Smrg	fi
43772b676d7Smrg	;;
43872b676d7Smrg      esac
43972b676d7Smrg      ;;
44072b676d7Smrg    *)
44172b676d7Smrg      eval "$prev=\$arg"
44272b676d7Smrg      ;;
44372b676d7Smrg    esac
44472b676d7Smrg
44572b676d7Smrg    prev=
44672b676d7Smrg    prevopt=
44772b676d7Smrg    continue
44872b676d7Smrg  fi
44972b676d7Smrg
45072b676d7Smrg  # Have we seen a non-optional argument yet?
45172b676d7Smrg  case $arg in
45272b676d7Smrg  --help)
45372b676d7Smrg    show_help=yes
45472b676d7Smrg    ;;
45572b676d7Smrg
45672b676d7Smrg  --version)
45772b676d7Smrg    $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
45872b676d7Smrg    $echo
45972b676d7Smrg    $echo "Copyright (C) 2005  Free Software Foundation, Inc."
46072b676d7Smrg    $echo "This is free software; see the source for copying conditions.  There is NO"
46172b676d7Smrg    $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
46272b676d7Smrg    exit $?
46372b676d7Smrg    ;;
46472b676d7Smrg
46572b676d7Smrg  --config)
46672b676d7Smrg    ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath
46772b676d7Smrg    # Now print the configurations for the tags.
46872b676d7Smrg    for tagname in $taglist; do
46972b676d7Smrg      ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
47072b676d7Smrg    done
47172b676d7Smrg    exit $?
47272b676d7Smrg    ;;
47372b676d7Smrg
47472b676d7Smrg  --debug)
47572b676d7Smrg    $echo "$progname: enabling shell trace mode"
47672b676d7Smrg    set -x
47772b676d7Smrg    preserve_args="$preserve_args $arg"
47872b676d7Smrg    ;;
47972b676d7Smrg
48072b676d7Smrg  --dry-run | -n)
48172b676d7Smrg    run=:
48272b676d7Smrg    ;;
48372b676d7Smrg
48472b676d7Smrg  --features)
48572b676d7Smrg    $echo "host: $host"
48672b676d7Smrg    if test "$build_libtool_libs" = yes; then
48772b676d7Smrg      $echo "enable shared libraries"
48872b676d7Smrg    else
48972b676d7Smrg      $echo "disable shared libraries"
49072b676d7Smrg    fi
49172b676d7Smrg    if test "$build_old_libs" = yes; then
49272b676d7Smrg      $echo "enable static libraries"
49372b676d7Smrg    else
49472b676d7Smrg      $echo "disable static libraries"
49572b676d7Smrg    fi
49672b676d7Smrg    exit $?
49772b676d7Smrg    ;;
49872b676d7Smrg
49972b676d7Smrg  --finish) mode="finish" ;;
50072b676d7Smrg
50172b676d7Smrg  --mode) prevopt="--mode" prev=mode ;;
50272b676d7Smrg  --mode=*) mode="$optarg" ;;
50372b676d7Smrg
50472b676d7Smrg  --preserve-dup-deps) duplicate_deps="yes" ;;
50572b676d7Smrg
50672b676d7Smrg  --quiet | --silent)
50772b676d7Smrg    show=:
50872b676d7Smrg    preserve_args="$preserve_args $arg"
50972b676d7Smrg    ;;
51072b676d7Smrg
51172b676d7Smrg  --tag)
51272b676d7Smrg    prevopt="--tag"
51372b676d7Smrg    prev=tag
51472b676d7Smrg    preserve_args="$preserve_args --tag"
51572b676d7Smrg    ;;
51672b676d7Smrg  --tag=*)
51772b676d7Smrg    set tag "$optarg" ${1+"$@"}
51872b676d7Smrg    shift
51972b676d7Smrg    prev=tag
52072b676d7Smrg    preserve_args="$preserve_args --tag"
52172b676d7Smrg    ;;
52272b676d7Smrg
52372b676d7Smrg  -dlopen)
52472b676d7Smrg    prevopt="-dlopen"
52572b676d7Smrg    prev=execute_dlfiles
52672b676d7Smrg    ;;
52772b676d7Smrg
52872b676d7Smrg  -*)
52972b676d7Smrg    $echo "$modename: unrecognized option \`$arg'" 1>&2
53072b676d7Smrg    $echo "$help" 1>&2
53172b676d7Smrg    exit $EXIT_FAILURE
53272b676d7Smrg    ;;
53372b676d7Smrg
53472b676d7Smrg  *)
53572b676d7Smrg    nonopt="$arg"
53672b676d7Smrg    break
53772b676d7Smrg    ;;
53872b676d7Smrg  esac
53972b676d7Smrgdone
54072b676d7Smrg
54172b676d7Smrgif test -n "$prevopt"; then
54272b676d7Smrg  $echo "$modename: option \`$prevopt' requires an argument" 1>&2
54372b676d7Smrg  $echo "$help" 1>&2
54472b676d7Smrg  exit $EXIT_FAILURE
54572b676d7Smrgfi
54672b676d7Smrg
54772b676d7Smrgcase $disable_libs in
54872b676d7Smrgno) 
54972b676d7Smrg  ;;
55072b676d7Smrgshared)
55172b676d7Smrg  build_libtool_libs=no
55272b676d7Smrg  build_old_libs=yes
55372b676d7Smrg  ;;
55472b676d7Smrgstatic)
55572b676d7Smrg  build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
55672b676d7Smrg  ;;
55772b676d7Smrgesac
55872b676d7Smrg
55972b676d7Smrg# If this variable is set in any of the actions, the command in it
56072b676d7Smrg# will be execed at the end.  This prevents here-documents from being
56172b676d7Smrg# left over by shells.
56272b676d7Smrgexec_cmd=
56372b676d7Smrg
56472b676d7Smrgif test -z "$show_help"; then
56572b676d7Smrg
56672b676d7Smrg  # Infer the operation mode.
56772b676d7Smrg  if test -z "$mode"; then
56872b676d7Smrg    $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
56972b676d7Smrg    $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2
57072b676d7Smrg    case $nonopt in
57172b676d7Smrg    *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
57272b676d7Smrg      mode=link
57372b676d7Smrg      for arg
57472b676d7Smrg      do
57572b676d7Smrg	case $arg in
57672b676d7Smrg	-c)
57772b676d7Smrg	   mode=compile
57872b676d7Smrg	   break
57972b676d7Smrg	   ;;
58072b676d7Smrg	esac
58172b676d7Smrg      done
58272b676d7Smrg      ;;
58372b676d7Smrg    *db | *dbx | *strace | *truss)
58472b676d7Smrg      mode=execute
58572b676d7Smrg      ;;
58672b676d7Smrg    *install*|cp|mv)
58772b676d7Smrg      mode=install
58872b676d7Smrg      ;;
58972b676d7Smrg    *rm)
59072b676d7Smrg      mode=uninstall
59172b676d7Smrg      ;;
59272b676d7Smrg    *)
59372b676d7Smrg      # If we have no mode, but dlfiles were specified, then do execute mode.
59472b676d7Smrg      test -n "$execute_dlfiles" && mode=execute
59572b676d7Smrg
59672b676d7Smrg      # Just use the default operation mode.
59772b676d7Smrg      if test -z "$mode"; then
59872b676d7Smrg	if test -n "$nonopt"; then
59972b676d7Smrg	  $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
60072b676d7Smrg	else
60172b676d7Smrg	  $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
60272b676d7Smrg	fi
60372b676d7Smrg      fi
60472b676d7Smrg      ;;
60572b676d7Smrg    esac
60672b676d7Smrg  fi
60772b676d7Smrg
60872b676d7Smrg  # Only execute mode is allowed to have -dlopen flags.
60972b676d7Smrg  if test -n "$execute_dlfiles" && test "$mode" != execute; then
61072b676d7Smrg    $echo "$modename: unrecognized option \`-dlopen'" 1>&2
61172b676d7Smrg    $echo "$help" 1>&2
61272b676d7Smrg    exit $EXIT_FAILURE
61372b676d7Smrg  fi
61472b676d7Smrg
61572b676d7Smrg  # Change the help message to a mode-specific one.
61672b676d7Smrg  generic_help="$help"
61772b676d7Smrg  help="Try \`$modename --help --mode=$mode' for more information."
61872b676d7Smrg
61972b676d7Smrg  # These modes are in order of execution frequency so that they run quickly.
62072b676d7Smrg  case $mode in
62172b676d7Smrg  # libtool compile mode
62272b676d7Smrg  compile)
62372b676d7Smrg    modename="$modename: compile"
62472b676d7Smrg    # Get the compilation command and the source file.
62572b676d7Smrg    base_compile=
62672b676d7Smrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
62772b676d7Smrg    suppress_opt=yes
62872b676d7Smrg    suppress_output=
62972b676d7Smrg    arg_mode=normal
63072b676d7Smrg    libobj=
63172b676d7Smrg    later=
63272b676d7Smrg
63372b676d7Smrg    for arg
63472b676d7Smrg    do
63572b676d7Smrg      case $arg_mode in
63672b676d7Smrg      arg  )
63772b676d7Smrg	# do not "continue".  Instead, add this to base_compile
63872b676d7Smrg	lastarg="$arg"
63972b676d7Smrg	arg_mode=normal
64072b676d7Smrg	;;
64172b676d7Smrg
64272b676d7Smrg      target )
64372b676d7Smrg	libobj="$arg"
64472b676d7Smrg	arg_mode=normal
64572b676d7Smrg	continue
64672b676d7Smrg	;;
64772b676d7Smrg
64872b676d7Smrg      normal )
64972b676d7Smrg	# Accept any command-line options.
65072b676d7Smrg	case $arg in
65172b676d7Smrg	-o)
65272b676d7Smrg	  if test -n "$libobj" ; then
65372b676d7Smrg	    $echo "$modename: you cannot specify \`-o' more than once" 1>&2
65472b676d7Smrg	    exit $EXIT_FAILURE
65572b676d7Smrg	  fi
65672b676d7Smrg	  arg_mode=target
65772b676d7Smrg	  continue
65872b676d7Smrg	  ;;
65972b676d7Smrg
66072b676d7Smrg	-static | -prefer-pic | -prefer-non-pic)
66172b676d7Smrg	  later="$later $arg"
66272b676d7Smrg	  continue
66372b676d7Smrg	  ;;
66472b676d7Smrg
66572b676d7Smrg	-no-suppress)
66672b676d7Smrg	  suppress_opt=no
66772b676d7Smrg	  continue
66872b676d7Smrg	  ;;
66972b676d7Smrg
67072b676d7Smrg	-Xcompiler)
67172b676d7Smrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
67272b676d7Smrg	  continue      #  The current "srcfile" will either be retained or
67372b676d7Smrg	  ;;            #  replaced later.  I would guess that would be a bug.
67472b676d7Smrg
67572b676d7Smrg	-Wc,*)
67672b676d7Smrg	  args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
67772b676d7Smrg	  lastarg=
67872b676d7Smrg	  save_ifs="$IFS"; IFS=','
67972b676d7Smrg 	  for arg in $args; do
68072b676d7Smrg	    IFS="$save_ifs"
68172b676d7Smrg
68272b676d7Smrg	    # Double-quote args containing other shell metacharacters.
68372b676d7Smrg	    # Many Bourne shells cannot handle close brackets correctly
68472b676d7Smrg	    # in scan sets, so we specify it separately.
68572b676d7Smrg	    case $arg in
68672b676d7Smrg	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
68772b676d7Smrg	      arg="\"$arg\""
68872b676d7Smrg	      ;;
68972b676d7Smrg	    esac
69072b676d7Smrg	    lastarg="$lastarg $arg"
69172b676d7Smrg	  done
69272b676d7Smrg	  IFS="$save_ifs"
69372b676d7Smrg	  lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
69472b676d7Smrg
69572b676d7Smrg	  # Add the arguments to base_compile.
69672b676d7Smrg	  base_compile="$base_compile $lastarg"
69772b676d7Smrg	  continue
69872b676d7Smrg	  ;;
69972b676d7Smrg
70072b676d7Smrg	* )
70172b676d7Smrg	  # Accept the current argument as the source file.
70272b676d7Smrg	  # The previous "srcfile" becomes the current argument.
70372b676d7Smrg	  #
70472b676d7Smrg	  lastarg="$srcfile"
70572b676d7Smrg	  srcfile="$arg"
70672b676d7Smrg	  ;;
70772b676d7Smrg	esac  #  case $arg
70872b676d7Smrg	;;
70972b676d7Smrg      esac    #  case $arg_mode
71072b676d7Smrg
71172b676d7Smrg      # Aesthetically quote the previous argument.
71272b676d7Smrg      lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
71372b676d7Smrg
71472b676d7Smrg      case $lastarg in
71572b676d7Smrg      # Double-quote args containing other shell metacharacters.
71672b676d7Smrg      # Many Bourne shells cannot handle close brackets correctly
71772b676d7Smrg      # in scan sets, and some SunOS ksh mistreat backslash-escaping
71872b676d7Smrg      # in scan sets (worked around with variable expansion),
71972b676d7Smrg      # and furthermore cannot handle '|' '&' '(' ')' in scan sets 
72072b676d7Smrg      # at all, so we specify them separately.
72172b676d7Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
72272b676d7Smrg	lastarg="\"$lastarg\""
72372b676d7Smrg	;;
72472b676d7Smrg      esac
72572b676d7Smrg
72672b676d7Smrg      base_compile="$base_compile $lastarg"
72772b676d7Smrg    done # for arg
72872b676d7Smrg
72972b676d7Smrg    case $arg_mode in
73072b676d7Smrg    arg)
73172b676d7Smrg      $echo "$modename: you must specify an argument for -Xcompile"
73272b676d7Smrg      exit $EXIT_FAILURE
73372b676d7Smrg      ;;
73472b676d7Smrg    target)
73572b676d7Smrg      $echo "$modename: you must specify a target with \`-o'" 1>&2
73672b676d7Smrg      exit $EXIT_FAILURE
73772b676d7Smrg      ;;
73872b676d7Smrg    *)
73972b676d7Smrg      # Get the name of the library object.
74072b676d7Smrg      [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
74172b676d7Smrg      ;;
74272b676d7Smrg    esac
74372b676d7Smrg
74472b676d7Smrg    # Recognize several different file suffixes.
74572b676d7Smrg    # If the user specifies -o file.o, it is replaced with file.lo
74672b676d7Smrg    xform='[cCFSifmso]'
74772b676d7Smrg    case $libobj in
74872b676d7Smrg    *.ada) xform=ada ;;
74972b676d7Smrg    *.adb) xform=adb ;;
75072b676d7Smrg    *.ads) xform=ads ;;
75172b676d7Smrg    *.asm) xform=asm ;;
75272b676d7Smrg    *.c++) xform=c++ ;;
75372b676d7Smrg    *.cc) xform=cc ;;
75472b676d7Smrg    *.ii) xform=ii ;;
75572b676d7Smrg    *.class) xform=class ;;
75672b676d7Smrg    *.cpp) xform=cpp ;;
75772b676d7Smrg    *.cxx) xform=cxx ;;
75872b676d7Smrg    *.f90) xform=f90 ;;
75972b676d7Smrg    *.for) xform=for ;;
76072b676d7Smrg    *.java) xform=java ;;
76172b676d7Smrg    esac
76272b676d7Smrg
76372b676d7Smrg    libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
76472b676d7Smrg
76572b676d7Smrg    case $libobj in
76672b676d7Smrg    *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
76772b676d7Smrg    *)
76872b676d7Smrg      $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
76972b676d7Smrg      exit $EXIT_FAILURE
77072b676d7Smrg      ;;
77172b676d7Smrg    esac
77272b676d7Smrg
77372b676d7Smrg    func_infer_tag $base_compile
77472b676d7Smrg
77572b676d7Smrg    for arg in $later; do
77672b676d7Smrg      case $arg in
77772b676d7Smrg      -static)
77872b676d7Smrg	build_old_libs=yes
77972b676d7Smrg	continue
78072b676d7Smrg	;;
78172b676d7Smrg
78272b676d7Smrg      -prefer-pic)
78372b676d7Smrg	pic_mode=yes
78472b676d7Smrg	continue
78572b676d7Smrg	;;
78672b676d7Smrg
78772b676d7Smrg      -prefer-non-pic)
78872b676d7Smrg	pic_mode=no
78972b676d7Smrg	continue
79072b676d7Smrg	;;
79172b676d7Smrg      esac
79272b676d7Smrg    done
79372b676d7Smrg
79472b676d7Smrg    qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"`
79572b676d7Smrg    case $qlibobj in
79672b676d7Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
79772b676d7Smrg	qlibobj="\"$qlibobj\"" ;;
79872b676d7Smrg    esac
79972b676d7Smrg    test "X$libobj" != "X$qlibobj" \
80072b676d7Smrg	&& $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"' 	&()|`$[]' \
80172b676d7Smrg	&& $echo "$modename: libobj name \`$libobj' may not contain shell special characters."
80272b676d7Smrg    objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
80372b676d7Smrg    xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
80472b676d7Smrg    if test "X$xdir" = "X$obj"; then
80572b676d7Smrg      xdir=
80672b676d7Smrg    else
80772b676d7Smrg      xdir=$xdir/
80872b676d7Smrg    fi
80972b676d7Smrg    lobj=${xdir}$objdir/$objname
81072b676d7Smrg
81172b676d7Smrg    if test -z "$base_compile"; then
81272b676d7Smrg      $echo "$modename: you must specify a compilation command" 1>&2
81372b676d7Smrg      $echo "$help" 1>&2
81472b676d7Smrg      exit $EXIT_FAILURE
81572b676d7Smrg    fi
81672b676d7Smrg
81772b676d7Smrg    # Delete any leftover library objects.
81872b676d7Smrg    if test "$build_old_libs" = yes; then
81972b676d7Smrg      removelist="$obj $lobj $libobj ${libobj}T"
82072b676d7Smrg    else
82172b676d7Smrg      removelist="$lobj $libobj ${libobj}T"
82272b676d7Smrg    fi
82372b676d7Smrg
82472b676d7Smrg    $run $rm $removelist
82572b676d7Smrg    trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
82672b676d7Smrg
82772b676d7Smrg    # On Cygwin there's no "real" PIC flag so we must build both object types
82872b676d7Smrg    case $host_os in
82972b676d7Smrg    cygwin* | mingw* | pw32* | os2*)
83072b676d7Smrg      pic_mode=default
83172b676d7Smrg      ;;
83272b676d7Smrg    esac
83372b676d7Smrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
83472b676d7Smrg      # non-PIC code in shared libraries is not supported
83572b676d7Smrg      pic_mode=default
83672b676d7Smrg    fi
83772b676d7Smrg
83872b676d7Smrg    # Calculate the filename of the output object if compiler does
83972b676d7Smrg    # not support -o with -c
84072b676d7Smrg    if test "$compiler_c_o" = no; then
84172b676d7Smrg      output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
84272b676d7Smrg      lockfile="$output_obj.lock"
84372b676d7Smrg      removelist="$removelist $output_obj $lockfile"
84472b676d7Smrg      trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
84572b676d7Smrg    else
84672b676d7Smrg      output_obj=
84772b676d7Smrg      need_locks=no
84872b676d7Smrg      lockfile=
84972b676d7Smrg    fi
85072b676d7Smrg
85172b676d7Smrg    # Lock this critical section if it is needed
85272b676d7Smrg    # We use this script file to make the link, it avoids creating a new file
85372b676d7Smrg    if test "$need_locks" = yes; then
85472b676d7Smrg      until $run ln "$progpath" "$lockfile" 2>/dev/null; do
85572b676d7Smrg	$show "Waiting for $lockfile to be removed"
85672b676d7Smrg	sleep 2
85772b676d7Smrg      done
85872b676d7Smrg    elif test "$need_locks" = warn; then
85972b676d7Smrg      if test -f "$lockfile"; then
86072b676d7Smrg	$echo "\
86172b676d7Smrg*** ERROR, $lockfile exists and contains:
86272b676d7Smrg`cat $lockfile 2>/dev/null`
86372b676d7Smrg
86472b676d7SmrgThis indicates that another process is trying to use the same
86572b676d7Smrgtemporary object file, and libtool could not work around it because
86672b676d7Smrgyour compiler does not support \`-c' and \`-o' together.  If you
86772b676d7Smrgrepeat this compilation, it may succeed, by chance, but you had better
86872b676d7Smrgavoid parallel builds (make -j) in this platform, or get a better
86972b676d7Smrgcompiler."
87072b676d7Smrg
87172b676d7Smrg	$run $rm $removelist
87272b676d7Smrg	exit $EXIT_FAILURE
87372b676d7Smrg      fi
87472b676d7Smrg      $echo "$srcfile" > "$lockfile"
87572b676d7Smrg    fi
87672b676d7Smrg
87772b676d7Smrg    if test -n "$fix_srcfile_path"; then
87872b676d7Smrg      eval srcfile=\"$fix_srcfile_path\"
87972b676d7Smrg    fi
88072b676d7Smrg    qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"`
88172b676d7Smrg    case $qsrcfile in
88272b676d7Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
88372b676d7Smrg      qsrcfile="\"$qsrcfile\"" ;;
88472b676d7Smrg    esac
88572b676d7Smrg
88672b676d7Smrg    $run $rm "$libobj" "${libobj}T"
88772b676d7Smrg
88872b676d7Smrg    # Create a libtool object file (analogous to a ".la" file),
88972b676d7Smrg    # but don't create it if we're doing a dry run.
89072b676d7Smrg    test -z "$run" && cat > ${libobj}T <<EOF
89172b676d7Smrg# $libobj - a libtool object file
89272b676d7Smrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
89372b676d7Smrg#
89472b676d7Smrg# Please DO NOT delete this file!
89572b676d7Smrg# It is necessary for linking the library.
89672b676d7Smrg
89772b676d7Smrg# Name of the PIC object.
89872b676d7SmrgEOF
89972b676d7Smrg
90072b676d7Smrg    # Only build a PIC object if we are building libtool libraries.
90172b676d7Smrg    if test "$build_libtool_libs" = yes; then
90272b676d7Smrg      # Without this assignment, base_compile gets emptied.
90372b676d7Smrg      fbsd_hideous_sh_bug=$base_compile
90472b676d7Smrg
90572b676d7Smrg      if test "$pic_mode" != no; then
90672b676d7Smrg	command="$base_compile $qsrcfile $pic_flag"
90772b676d7Smrg      else
90872b676d7Smrg	# Don't build PIC code
90972b676d7Smrg	command="$base_compile $qsrcfile"
91072b676d7Smrg      fi
91172b676d7Smrg
91272b676d7Smrg      if test ! -d "${xdir}$objdir"; then
91372b676d7Smrg	$show "$mkdir ${xdir}$objdir"
91472b676d7Smrg	$run $mkdir ${xdir}$objdir
91572b676d7Smrg	exit_status=$?
91672b676d7Smrg	if test "$exit_status" -ne 0 && test ! -d "${xdir}$objdir"; then
91772b676d7Smrg	  exit $exit_status
91872b676d7Smrg	fi
91972b676d7Smrg      fi
92072b676d7Smrg
92172b676d7Smrg      if test -z "$output_obj"; then
92272b676d7Smrg	# Place PIC objects in $objdir
92372b676d7Smrg	command="$command -o $lobj"
92472b676d7Smrg      fi
92572b676d7Smrg
92672b676d7Smrg      $run $rm "$lobj" "$output_obj"
92772b676d7Smrg
92872b676d7Smrg      $show "$command"
92972b676d7Smrg      if $run eval "$command"; then :
93072b676d7Smrg      else
93172b676d7Smrg	test -n "$output_obj" && $run $rm $removelist
93272b676d7Smrg	exit $EXIT_FAILURE
93372b676d7Smrg      fi
93472b676d7Smrg
93572b676d7Smrg      if test "$need_locks" = warn &&
93672b676d7Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
93772b676d7Smrg	$echo "\
93872b676d7Smrg*** ERROR, $lockfile contains:
93972b676d7Smrg`cat $lockfile 2>/dev/null`
94072b676d7Smrg
94172b676d7Smrgbut it should contain:
94272b676d7Smrg$srcfile
94372b676d7Smrg
94472b676d7SmrgThis indicates that another process is trying to use the same
94572b676d7Smrgtemporary object file, and libtool could not work around it because
94672b676d7Smrgyour compiler does not support \`-c' and \`-o' together.  If you
94772b676d7Smrgrepeat this compilation, it may succeed, by chance, but you had better
94872b676d7Smrgavoid parallel builds (make -j) in this platform, or get a better
94972b676d7Smrgcompiler."
95072b676d7Smrg
95172b676d7Smrg	$run $rm $removelist
95272b676d7Smrg	exit $EXIT_FAILURE
95372b676d7Smrg      fi
95472b676d7Smrg
95572b676d7Smrg      # Just move the object if needed, then go on to compile the next one
95672b676d7Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
95772b676d7Smrg	$show "$mv $output_obj $lobj"
95872b676d7Smrg	if $run $mv $output_obj $lobj; then :
95972b676d7Smrg	else
96072b676d7Smrg	  error=$?
96172b676d7Smrg	  $run $rm $removelist
96272b676d7Smrg	  exit $error
96372b676d7Smrg	fi
96472b676d7Smrg      fi
96572b676d7Smrg
96672b676d7Smrg      # Append the name of the PIC object to the libtool object file.
96772b676d7Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
96872b676d7Smrgpic_object='$objdir/$objname'
96972b676d7Smrg
97072b676d7SmrgEOF
97172b676d7Smrg
97272b676d7Smrg      # Allow error messages only from the first compilation.
97372b676d7Smrg      if test "$suppress_opt" = yes; then
97472b676d7Smrg        suppress_output=' >/dev/null 2>&1'
97572b676d7Smrg      fi
97672b676d7Smrg    else
97772b676d7Smrg      # No PIC object so indicate it doesn't exist in the libtool
97872b676d7Smrg      # object file.
97972b676d7Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
98072b676d7Smrgpic_object=none
98172b676d7Smrg
98272b676d7SmrgEOF
98372b676d7Smrg    fi
98472b676d7Smrg
98572b676d7Smrg    # Only build a position-dependent object if we build old libraries.
98672b676d7Smrg    if test "$build_old_libs" = yes; then
98772b676d7Smrg      if test "$pic_mode" != yes; then
98872b676d7Smrg	# Don't build PIC code
98972b676d7Smrg	command="$base_compile $qsrcfile"
99072b676d7Smrg      else
99172b676d7Smrg	command="$base_compile $qsrcfile $pic_flag"
99272b676d7Smrg      fi
99372b676d7Smrg      if test "$compiler_c_o" = yes; then
99472b676d7Smrg	command="$command -o $obj"
99572b676d7Smrg      fi
99672b676d7Smrg
99772b676d7Smrg      # Suppress compiler output if we already did a PIC compilation.
99872b676d7Smrg      command="$command$suppress_output"
99972b676d7Smrg      $run $rm "$obj" "$output_obj"
100072b676d7Smrg      $show "$command"
100172b676d7Smrg      if $run eval "$command"; then :
100272b676d7Smrg      else
100372b676d7Smrg	$run $rm $removelist
100472b676d7Smrg	exit $EXIT_FAILURE
100572b676d7Smrg      fi
100672b676d7Smrg
100772b676d7Smrg      if test "$need_locks" = warn &&
100872b676d7Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
100972b676d7Smrg	$echo "\
101072b676d7Smrg*** ERROR, $lockfile contains:
101172b676d7Smrg`cat $lockfile 2>/dev/null`
101272b676d7Smrg
101372b676d7Smrgbut it should contain:
101472b676d7Smrg$srcfile
101572b676d7Smrg
101672b676d7SmrgThis indicates that another process is trying to use the same
101772b676d7Smrgtemporary object file, and libtool could not work around it because
101872b676d7Smrgyour compiler does not support \`-c' and \`-o' together.  If you
101972b676d7Smrgrepeat this compilation, it may succeed, by chance, but you had better
102072b676d7Smrgavoid parallel builds (make -j) in this platform, or get a better
102172b676d7Smrgcompiler."
102272b676d7Smrg
102372b676d7Smrg	$run $rm $removelist
102472b676d7Smrg	exit $EXIT_FAILURE
102572b676d7Smrg      fi
102672b676d7Smrg
102772b676d7Smrg      # Just move the object if needed
102872b676d7Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
102972b676d7Smrg	$show "$mv $output_obj $obj"
103072b676d7Smrg	if $run $mv $output_obj $obj; then :
103172b676d7Smrg	else
103272b676d7Smrg	  error=$?
103372b676d7Smrg	  $run $rm $removelist
103472b676d7Smrg	  exit $error
103572b676d7Smrg	fi
103672b676d7Smrg      fi
103772b676d7Smrg
103872b676d7Smrg      # Append the name of the non-PIC object the libtool object file.
103972b676d7Smrg      # Only append if the libtool object file exists.
104072b676d7Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
104172b676d7Smrg# Name of the non-PIC object.
104272b676d7Smrgnon_pic_object='$objname'
104372b676d7Smrg
104472b676d7SmrgEOF
104572b676d7Smrg    else
104672b676d7Smrg      # Append the name of the non-PIC object the libtool object file.
104772b676d7Smrg      # Only append if the libtool object file exists.
104872b676d7Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
104972b676d7Smrg# Name of the non-PIC object.
105072b676d7Smrgnon_pic_object=none
105172b676d7Smrg
105272b676d7SmrgEOF
105372b676d7Smrg    fi
105472b676d7Smrg
105572b676d7Smrg    $run $mv "${libobj}T" "${libobj}"
105672b676d7Smrg
105772b676d7Smrg    # Unlock the critical section if it was locked
105872b676d7Smrg    if test "$need_locks" != no; then
105972b676d7Smrg      $run $rm "$lockfile"
106072b676d7Smrg    fi
106172b676d7Smrg
106272b676d7Smrg    exit $EXIT_SUCCESS
106372b676d7Smrg    ;;
106472b676d7Smrg
106572b676d7Smrg  # libtool link mode
106672b676d7Smrg  link | relink)
106772b676d7Smrg    modename="$modename: link"
106872b676d7Smrg    case $host in
106972b676d7Smrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
107072b676d7Smrg      # It is impossible to link a dll without this setting, and
107172b676d7Smrg      # we shouldn't force the makefile maintainer to figure out
107272b676d7Smrg      # which system we are compiling for in order to pass an extra
107372b676d7Smrg      # flag for every libtool invocation.
107472b676d7Smrg      # allow_undefined=no
107572b676d7Smrg
107672b676d7Smrg      # FIXME: Unfortunately, there are problems with the above when trying
107772b676d7Smrg      # to make a dll which has undefined symbols, in which case not
107872b676d7Smrg      # even a static library is built.  For now, we need to specify
107972b676d7Smrg      # -no-undefined on the libtool link line when we can be certain
108072b676d7Smrg      # that all symbols are satisfied, otherwise we get a static library.
108172b676d7Smrg      allow_undefined=yes
108272b676d7Smrg      ;;
108372b676d7Smrg    *)
108472b676d7Smrg      allow_undefined=yes
108572b676d7Smrg      ;;
108672b676d7Smrg    esac
108772b676d7Smrg    libtool_args="$nonopt"
108872b676d7Smrg    base_compile="$nonopt $@"
108972b676d7Smrg    compile_command="$nonopt"
109072b676d7Smrg    finalize_command="$nonopt"
109172b676d7Smrg
109272b676d7Smrg    compile_rpath=
109372b676d7Smrg    finalize_rpath=
109472b676d7Smrg    compile_shlibpath=
109572b676d7Smrg    finalize_shlibpath=
109672b676d7Smrg    convenience=
109772b676d7Smrg    old_convenience=
109872b676d7Smrg    deplibs=
109972b676d7Smrg    old_deplibs=
110072b676d7Smrg    compiler_flags=
110172b676d7Smrg    linker_flags=
110272b676d7Smrg    dllsearchpath=
110372b676d7Smrg    lib_search_path=`pwd`
110472b676d7Smrg    inst_prefix_dir=
110572b676d7Smrg
110672b676d7Smrg    avoid_version=no
110772b676d7Smrg    dlfiles=
110872b676d7Smrg    dlprefiles=
110972b676d7Smrg    dlself=no
111072b676d7Smrg    export_dynamic=no
111172b676d7Smrg    export_symbols=
111272b676d7Smrg    export_symbols_regex=
111372b676d7Smrg    generated=
111472b676d7Smrg    libobjs=
111572b676d7Smrg    ltlibs=
111672b676d7Smrg    module=no
111772b676d7Smrg    no_install=no
111872b676d7Smrg    objs=
111972b676d7Smrg    non_pic_objects=
112072b676d7Smrg    notinst_path= # paths that contain not-installed libtool libraries
112172b676d7Smrg    precious_files_regex=
112272b676d7Smrg    prefer_static_libs=no
112372b676d7Smrg    preload=no
112472b676d7Smrg    prev=
112572b676d7Smrg    prevarg=
112672b676d7Smrg    release=
112772b676d7Smrg    rpath=
112872b676d7Smrg    xrpath=
112972b676d7Smrg    perm_rpath=
113072b676d7Smrg    temp_rpath=
113172b676d7Smrg    thread_safe=no
113272b676d7Smrg    vinfo=
113372b676d7Smrg    vinfo_number=no
113472b676d7Smrg
113572b676d7Smrg    func_infer_tag $base_compile
113672b676d7Smrg
113772b676d7Smrg    # We need to know -static, to get the right output filenames.
113872b676d7Smrg    for arg
113972b676d7Smrg    do
114072b676d7Smrg      case $arg in
114172b676d7Smrg      -all-static | -static)
114272b676d7Smrg	if test "X$arg" = "X-all-static"; then
114372b676d7Smrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
114472b676d7Smrg	    $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
114572b676d7Smrg	  fi
114672b676d7Smrg	  if test -n "$link_static_flag"; then
114772b676d7Smrg	    dlopen_self=$dlopen_self_static
114872b676d7Smrg	  fi
114972b676d7Smrg	  prefer_static_libs=yes
115072b676d7Smrg	else
115172b676d7Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
115272b676d7Smrg	    dlopen_self=$dlopen_self_static
115372b676d7Smrg	  fi
115472b676d7Smrg	  prefer_static_libs=built
115572b676d7Smrg	fi
115672b676d7Smrg	build_libtool_libs=no
115772b676d7Smrg	build_old_libs=yes
115872b676d7Smrg	break
115972b676d7Smrg	;;
116072b676d7Smrg      esac
116172b676d7Smrg    done
116272b676d7Smrg
116372b676d7Smrg    # See if our shared archives depend on static archives.
116472b676d7Smrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
116572b676d7Smrg
116672b676d7Smrg    # Go through the arguments, transforming them on the way.
116772b676d7Smrg    while test "$#" -gt 0; do
116872b676d7Smrg      arg="$1"
116972b676d7Smrg      shift
117072b676d7Smrg      case $arg in
117172b676d7Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
117272b676d7Smrg	qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test
117372b676d7Smrg	;;
117472b676d7Smrg      *) qarg=$arg ;;
117572b676d7Smrg      esac
117672b676d7Smrg      libtool_args="$libtool_args $qarg"
117772b676d7Smrg
117872b676d7Smrg      # If the previous option needs an argument, assign it.
117972b676d7Smrg      if test -n "$prev"; then
118072b676d7Smrg	case $prev in
118172b676d7Smrg	output)
118272b676d7Smrg	  compile_command="$compile_command @OUTPUT@"
118372b676d7Smrg	  finalize_command="$finalize_command @OUTPUT@"
118472b676d7Smrg	  ;;
118572b676d7Smrg	esac
118672b676d7Smrg
118772b676d7Smrg	case $prev in
118872b676d7Smrg	dlfiles|dlprefiles)
118972b676d7Smrg	  if test "$preload" = no; then
119072b676d7Smrg	    # Add the symbol object into the linking commands.
119172b676d7Smrg	    compile_command="$compile_command @SYMFILE@"
119272b676d7Smrg	    finalize_command="$finalize_command @SYMFILE@"
119372b676d7Smrg	    preload=yes
119472b676d7Smrg	  fi
119572b676d7Smrg	  case $arg in
119672b676d7Smrg	  *.la | *.lo) ;;  # We handle these cases below.
119772b676d7Smrg	  force)
119872b676d7Smrg	    if test "$dlself" = no; then
119972b676d7Smrg	      dlself=needless
120072b676d7Smrg	      export_dynamic=yes
120172b676d7Smrg	    fi
120272b676d7Smrg	    prev=
120372b676d7Smrg	    continue
120472b676d7Smrg	    ;;
120572b676d7Smrg	  self)
120672b676d7Smrg	    if test "$prev" = dlprefiles; then
120772b676d7Smrg	      dlself=yes
120872b676d7Smrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
120972b676d7Smrg	      dlself=yes
121072b676d7Smrg	    else
121172b676d7Smrg	      dlself=needless
121272b676d7Smrg	      export_dynamic=yes
121372b676d7Smrg	    fi
121472b676d7Smrg	    prev=
121572b676d7Smrg	    continue
121672b676d7Smrg	    ;;
121772b676d7Smrg	  *)
121872b676d7Smrg	    if test "$prev" = dlfiles; then
121972b676d7Smrg	      dlfiles="$dlfiles $arg"
122072b676d7Smrg	    else
122172b676d7Smrg	      dlprefiles="$dlprefiles $arg"
122272b676d7Smrg	    fi
122372b676d7Smrg	    prev=
122472b676d7Smrg	    continue
122572b676d7Smrg	    ;;
122672b676d7Smrg	  esac
122772b676d7Smrg	  ;;
122872b676d7Smrg	expsyms)
122972b676d7Smrg	  export_symbols="$arg"
123072b676d7Smrg	  if test ! -f "$arg"; then
123172b676d7Smrg	    $echo "$modename: symbol file \`$arg' does not exist"
123272b676d7Smrg	    exit $EXIT_FAILURE
123372b676d7Smrg	  fi
123472b676d7Smrg	  prev=
123572b676d7Smrg	  continue
123672b676d7Smrg	  ;;
123772b676d7Smrg	expsyms_regex)
123872b676d7Smrg	  export_symbols_regex="$arg"
123972b676d7Smrg	  prev=
124072b676d7Smrg	  continue
124172b676d7Smrg	  ;;
124272b676d7Smrg	inst_prefix)
124372b676d7Smrg	  inst_prefix_dir="$arg"
124472b676d7Smrg	  prev=
124572b676d7Smrg	  continue
124672b676d7Smrg	  ;;
124772b676d7Smrg	precious_regex)
124872b676d7Smrg	  precious_files_regex="$arg"
124972b676d7Smrg	  prev=
125072b676d7Smrg	  continue
125172b676d7Smrg	  ;;
125272b676d7Smrg	release)
125372b676d7Smrg	  release="-$arg"
125472b676d7Smrg	  prev=
125572b676d7Smrg	  continue
125672b676d7Smrg	  ;;
125772b676d7Smrg	objectlist)
125872b676d7Smrg	  if test -f "$arg"; then
125972b676d7Smrg	    save_arg=$arg
126072b676d7Smrg	    moreargs=
126172b676d7Smrg	    for fil in `cat $save_arg`
126272b676d7Smrg	    do
126372b676d7Smrg#	      moreargs="$moreargs $fil"
126472b676d7Smrg	      arg=$fil
126572b676d7Smrg	      # A libtool-controlled object.
126672b676d7Smrg
126772b676d7Smrg	      # Check to see that this really is a libtool object.
126872b676d7Smrg	      if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
126972b676d7Smrg		pic_object=
127072b676d7Smrg		non_pic_object=
127172b676d7Smrg
127272b676d7Smrg		# Read the .lo file
127372b676d7Smrg		# If there is no directory component, then add one.
127472b676d7Smrg		case $arg in
127572b676d7Smrg		*/* | *\\*) . $arg ;;
127672b676d7Smrg		*) . ./$arg ;;
127772b676d7Smrg		esac
127872b676d7Smrg
127972b676d7Smrg		if test -z "$pic_object" || \
128072b676d7Smrg		   test -z "$non_pic_object" ||
128172b676d7Smrg		   test "$pic_object" = none && \
128272b676d7Smrg		   test "$non_pic_object" = none; then
128372b676d7Smrg		  $echo "$modename: cannot find name of object for \`$arg'" 1>&2
128472b676d7Smrg		  exit $EXIT_FAILURE
128572b676d7Smrg		fi
128672b676d7Smrg
128772b676d7Smrg		# Extract subdirectory from the argument.
128872b676d7Smrg		xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
128972b676d7Smrg		if test "X$xdir" = "X$arg"; then
129072b676d7Smrg		  xdir=
129172b676d7Smrg		else
129272b676d7Smrg		  xdir="$xdir/"
129372b676d7Smrg		fi
129472b676d7Smrg
129572b676d7Smrg		if test "$pic_object" != none; then
129672b676d7Smrg		  # Prepend the subdirectory the object is found in.
129772b676d7Smrg		  pic_object="$xdir$pic_object"
129872b676d7Smrg
129972b676d7Smrg		  if test "$prev" = dlfiles; then
130072b676d7Smrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
130172b676d7Smrg		      dlfiles="$dlfiles $pic_object"
130272b676d7Smrg		      prev=
130372b676d7Smrg		      continue
130472b676d7Smrg		    else
130572b676d7Smrg		      # If libtool objects are unsupported, then we need to preload.
130672b676d7Smrg		      prev=dlprefiles
130772b676d7Smrg		    fi
130872b676d7Smrg		  fi
130972b676d7Smrg
131072b676d7Smrg		  # CHECK ME:  I think I busted this.  -Ossama
131172b676d7Smrg		  if test "$prev" = dlprefiles; then
131272b676d7Smrg		    # Preload the old-style object.
131372b676d7Smrg		    dlprefiles="$dlprefiles $pic_object"
131472b676d7Smrg		    prev=
131572b676d7Smrg		  fi
131672b676d7Smrg
131772b676d7Smrg		  # A PIC object.
131872b676d7Smrg		  libobjs="$libobjs $pic_object"
131972b676d7Smrg		  arg="$pic_object"
132072b676d7Smrg		fi
132172b676d7Smrg
132272b676d7Smrg		# Non-PIC object.
132372b676d7Smrg		if test "$non_pic_object" != none; then
132472b676d7Smrg		  # Prepend the subdirectory the object is found in.
132572b676d7Smrg		  non_pic_object="$xdir$non_pic_object"
132672b676d7Smrg
132772b676d7Smrg		  # A standard non-PIC object
132872b676d7Smrg		  non_pic_objects="$non_pic_objects $non_pic_object"
132972b676d7Smrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
133072b676d7Smrg		    arg="$non_pic_object"
133172b676d7Smrg		  fi
133272b676d7Smrg		else
133372b676d7Smrg		  # If the PIC object exists, use it instead.
133472b676d7Smrg		  # $xdir was prepended to $pic_object above.
133572b676d7Smrg		  non_pic_object="$pic_object"
133672b676d7Smrg		  non_pic_objects="$non_pic_objects $non_pic_object"
133772b676d7Smrg		fi
133872b676d7Smrg	      else
133972b676d7Smrg		# Only an error if not doing a dry-run.
134072b676d7Smrg		if test -z "$run"; then
134172b676d7Smrg		  $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
134272b676d7Smrg		  exit $EXIT_FAILURE
134372b676d7Smrg		else
134472b676d7Smrg		  # Dry-run case.
134572b676d7Smrg
134672b676d7Smrg		  # Extract subdirectory from the argument.
134772b676d7Smrg		  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
134872b676d7Smrg		  if test "X$xdir" = "X$arg"; then
134972b676d7Smrg		    xdir=
135072b676d7Smrg		  else
135172b676d7Smrg		    xdir="$xdir/"
135272b676d7Smrg		  fi
135372b676d7Smrg
135472b676d7Smrg		  pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
135572b676d7Smrg		  non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
135672b676d7Smrg		  libobjs="$libobjs $pic_object"
135772b676d7Smrg		  non_pic_objects="$non_pic_objects $non_pic_object"
135872b676d7Smrg		fi
135972b676d7Smrg	      fi
136072b676d7Smrg	    done
136172b676d7Smrg	  else
136272b676d7Smrg	    $echo "$modename: link input file \`$save_arg' does not exist"
136372b676d7Smrg	    exit $EXIT_FAILURE
136472b676d7Smrg	  fi
136572b676d7Smrg	  arg=$save_arg
136672b676d7Smrg	  prev=
136772b676d7Smrg	  continue
136872b676d7Smrg	  ;;
136972b676d7Smrg	rpath | xrpath)
137072b676d7Smrg	  # We need an absolute path.
137172b676d7Smrg	  case $arg in
137272b676d7Smrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
137372b676d7Smrg	  *)
137472b676d7Smrg	    $echo "$modename: only absolute run-paths are allowed" 1>&2
137572b676d7Smrg	    exit $EXIT_FAILURE
137672b676d7Smrg	    ;;
137772b676d7Smrg	  esac
137872b676d7Smrg	  if test "$prev" = rpath; then
137972b676d7Smrg	    case "$rpath " in
138072b676d7Smrg	    *" $arg "*) ;;
138172b676d7Smrg	    *) rpath="$rpath $arg" ;;
138272b676d7Smrg	    esac
138372b676d7Smrg	  else
138472b676d7Smrg	    case "$xrpath " in
138572b676d7Smrg	    *" $arg "*) ;;
138672b676d7Smrg	    *) xrpath="$xrpath $arg" ;;
138772b676d7Smrg	    esac
138872b676d7Smrg	  fi
138972b676d7Smrg	  prev=
139072b676d7Smrg	  continue
139172b676d7Smrg	  ;;
139272b676d7Smrg	xcompiler)
139372b676d7Smrg	  compiler_flags="$compiler_flags $qarg"
139472b676d7Smrg	  prev=
139572b676d7Smrg	  compile_command="$compile_command $qarg"
139672b676d7Smrg	  finalize_command="$finalize_command $qarg"
139772b676d7Smrg	  continue
139872b676d7Smrg	  ;;
139972b676d7Smrg	xlinker)
140072b676d7Smrg	  linker_flags="$linker_flags $qarg"
140172b676d7Smrg	  compiler_flags="$compiler_flags $wl$qarg"
140272b676d7Smrg	  prev=
140372b676d7Smrg	  compile_command="$compile_command $wl$qarg"
140472b676d7Smrg	  finalize_command="$finalize_command $wl$qarg"
140572b676d7Smrg	  continue
140672b676d7Smrg	  ;;
140772b676d7Smrg	xcclinker)
140872b676d7Smrg	  linker_flags="$linker_flags $qarg"
140972b676d7Smrg	  compiler_flags="$compiler_flags $qarg"
141072b676d7Smrg	  prev=
141172b676d7Smrg	  compile_command="$compile_command $qarg"
141272b676d7Smrg	  finalize_command="$finalize_command $qarg"
141372b676d7Smrg	  continue
141472b676d7Smrg	  ;;
141572b676d7Smrg	shrext)
141672b676d7Smrg  	  shrext_cmds="$arg"
141772b676d7Smrg	  prev=
141872b676d7Smrg	  continue
141972b676d7Smrg	  ;;
142072b676d7Smrg	darwin_framework|darwin_framework_skip)
142172b676d7Smrg	  test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg"
142272b676d7Smrg	  compile_command="$compile_command $arg"
142372b676d7Smrg	  finalize_command="$finalize_command $arg"
142472b676d7Smrg	  prev=
142572b676d7Smrg	  continue
142672b676d7Smrg	  ;;
142772b676d7Smrg	*)
142872b676d7Smrg	  eval "$prev=\"\$arg\""
142972b676d7Smrg	  prev=
143072b676d7Smrg	  continue
143172b676d7Smrg	  ;;
143272b676d7Smrg	esac
143372b676d7Smrg      fi # test -n "$prev"
143472b676d7Smrg
143572b676d7Smrg      prevarg="$arg"
143672b676d7Smrg
143772b676d7Smrg      case $arg in
143872b676d7Smrg      -all-static)
143972b676d7Smrg	if test -n "$link_static_flag"; then
144072b676d7Smrg	  compile_command="$compile_command $link_static_flag"
144172b676d7Smrg	  finalize_command="$finalize_command $link_static_flag"
144272b676d7Smrg	fi
144372b676d7Smrg	continue
144472b676d7Smrg	;;
144572b676d7Smrg
144672b676d7Smrg      -allow-undefined)
144772b676d7Smrg	# FIXME: remove this flag sometime in the future.
144872b676d7Smrg	$echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
144972b676d7Smrg	continue
145072b676d7Smrg	;;
145172b676d7Smrg
145272b676d7Smrg      -avoid-version)
145372b676d7Smrg	avoid_version=yes
145472b676d7Smrg	continue
145572b676d7Smrg	;;
145672b676d7Smrg
145772b676d7Smrg      -dlopen)
145872b676d7Smrg	prev=dlfiles
145972b676d7Smrg	continue
146072b676d7Smrg	;;
146172b676d7Smrg
146272b676d7Smrg      -dlpreopen)
146372b676d7Smrg	prev=dlprefiles
146472b676d7Smrg	continue
146572b676d7Smrg	;;
146672b676d7Smrg
146772b676d7Smrg      -export-dynamic)
146872b676d7Smrg	export_dynamic=yes
146972b676d7Smrg	continue
147072b676d7Smrg	;;
147172b676d7Smrg
147272b676d7Smrg      -export-symbols | -export-symbols-regex)
147372b676d7Smrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
147472b676d7Smrg	  $echo "$modename: more than one -exported-symbols argument is not allowed"
147572b676d7Smrg	  exit $EXIT_FAILURE
147672b676d7Smrg	fi
147772b676d7Smrg	if test "X$arg" = "X-export-symbols"; then
147872b676d7Smrg	  prev=expsyms
147972b676d7Smrg	else
148072b676d7Smrg	  prev=expsyms_regex
148172b676d7Smrg	fi
148272b676d7Smrg	continue
148372b676d7Smrg	;;
148472b676d7Smrg
148572b676d7Smrg      -framework|-arch|-isysroot)
148672b676d7Smrg	case " $CC " in
148772b676d7Smrg	  *" ${arg} ${1} "* | *" ${arg}	${1} "*) 
148872b676d7Smrg		prev=darwin_framework_skip ;;
148972b676d7Smrg	  *) compiler_flags="$compiler_flags $arg"
149072b676d7Smrg	     prev=darwin_framework ;;
149172b676d7Smrg	esac
149272b676d7Smrg	compile_command="$compile_command $arg"
149372b676d7Smrg	finalize_command="$finalize_command $arg"
149472b676d7Smrg	continue
149572b676d7Smrg	;;
149672b676d7Smrg
149772b676d7Smrg      -inst-prefix-dir)
149872b676d7Smrg	prev=inst_prefix
149972b676d7Smrg	continue
150072b676d7Smrg	;;
150172b676d7Smrg
150272b676d7Smrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
150372b676d7Smrg      # so, if we see these flags be careful not to treat them like -L
150472b676d7Smrg      -L[A-Z][A-Z]*:*)
150572b676d7Smrg	case $with_gcc/$host in
150672b676d7Smrg	no/*-*-irix* | /*-*-irix*)
150772b676d7Smrg	  compile_command="$compile_command $arg"
150872b676d7Smrg	  finalize_command="$finalize_command $arg"
150972b676d7Smrg	  ;;
151072b676d7Smrg	esac
151172b676d7Smrg	continue
151272b676d7Smrg	;;
151372b676d7Smrg
151472b676d7Smrg      -L*)
151572b676d7Smrg	dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
151672b676d7Smrg	# We need an absolute path.
151772b676d7Smrg	case $dir in
151872b676d7Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
151972b676d7Smrg	*)
152072b676d7Smrg	  absdir=`cd "$dir" && pwd`
152172b676d7Smrg	  if test -z "$absdir"; then
152272b676d7Smrg	    $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
152372b676d7Smrg	    absdir="$dir"
152472b676d7Smrg	    notinst_path="$notinst_path $dir"
152572b676d7Smrg	  fi
152672b676d7Smrg	  dir="$absdir"
152772b676d7Smrg	  ;;
152872b676d7Smrg	esac
152972b676d7Smrg	case "$deplibs " in
153072b676d7Smrg	*" -L$dir "*) ;;
153172b676d7Smrg	*)
153272b676d7Smrg	  deplibs="$deplibs -L$dir"
153372b676d7Smrg	  lib_search_path="$lib_search_path $dir"
153472b676d7Smrg	  ;;
153572b676d7Smrg	esac
153672b676d7Smrg	case $host in
153772b676d7Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
153872b676d7Smrg	  testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'`
153972b676d7Smrg	  case :$dllsearchpath: in
154072b676d7Smrg	  *":$dir:"*) ;;
154172b676d7Smrg	  *) dllsearchpath="$dllsearchpath:$dir";;
154272b676d7Smrg	  esac
154372b676d7Smrg	  case :$dllsearchpath: in
154472b676d7Smrg	  *":$testbindir:"*) ;;
154572b676d7Smrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
154672b676d7Smrg	  esac
154772b676d7Smrg	  ;;
154872b676d7Smrg	esac
154972b676d7Smrg	continue
155072b676d7Smrg	;;
155172b676d7Smrg
155272b676d7Smrg      -l*)
155372b676d7Smrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
155472b676d7Smrg	  case $host in
155572b676d7Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*)
155672b676d7Smrg	    # These systems don't actually have a C or math library (as such)
155772b676d7Smrg	    continue
155872b676d7Smrg	    ;;
155972b676d7Smrg	  *-*-os2*)
156072b676d7Smrg	    # These systems don't actually have a C library (as such)
156172b676d7Smrg	    test "X$arg" = "X-lc" && continue
156272b676d7Smrg	    ;;
156372b676d7Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
156472b676d7Smrg	    # Do not include libc due to us having libc/libc_r.
156572b676d7Smrg	    test "X$arg" = "X-lc" && continue
156672b676d7Smrg	    ;;
156772b676d7Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
156872b676d7Smrg	    # Rhapsody C and math libraries are in the System framework
156972b676d7Smrg	    deplibs="$deplibs -framework System"
157072b676d7Smrg	    continue
157172b676d7Smrg	    ;;
157272b676d7Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
157372b676d7Smrg	    # Causes problems with __ctype
157472b676d7Smrg	    test "X$arg" = "X-lc" && continue
157572b676d7Smrg	    ;;
157672b676d7Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
157772b676d7Smrg	    # Compiler inserts libc in the correct place for threads to work
157872b676d7Smrg	    test "X$arg" = "X-lc" && continue
157972b676d7Smrg	    ;;
158072b676d7Smrg	  esac
158172b676d7Smrg	elif test "X$arg" = "X-lc_r"; then
158272b676d7Smrg	 case $host in
158372b676d7Smrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
158472b676d7Smrg	   # Do not include libc_r directly, use -pthread flag.
158572b676d7Smrg	   continue
158672b676d7Smrg	   ;;
158772b676d7Smrg	 esac
158872b676d7Smrg	fi
158972b676d7Smrg	deplibs="$deplibs $arg"
159072b676d7Smrg	continue
159172b676d7Smrg	;;
159272b676d7Smrg
159372b676d7Smrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
159472b676d7Smrg      # classes, name mangling, and exception handling.
159572b676d7Smrg      -model)
159672b676d7Smrg	compile_command="$compile_command $arg"
159772b676d7Smrg	compiler_flags="$compiler_flags $arg"
159872b676d7Smrg	finalize_command="$finalize_command $arg"
159972b676d7Smrg	prev=xcompiler
160072b676d7Smrg	continue
160172b676d7Smrg	;;
160272b676d7Smrg
160372b676d7Smrg     -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
160472b676d7Smrg	compiler_flags="$compiler_flags $arg"
160572b676d7Smrg	compile_command="$compile_command $arg"
160672b676d7Smrg	finalize_command="$finalize_command $arg"
160772b676d7Smrg	continue
160872b676d7Smrg	;;
160972b676d7Smrg
161072b676d7Smrg      -module)
161172b676d7Smrg	module=yes
161272b676d7Smrg	continue
161372b676d7Smrg	;;
161472b676d7Smrg
161572b676d7Smrg      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
161672b676d7Smrg      # -r[0-9][0-9]* specifies the processor on the SGI compiler
161772b676d7Smrg      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
161872b676d7Smrg      # +DA*, +DD* enable 64-bit mode on the HP compiler
161972b676d7Smrg      # -q* pass through compiler args for the IBM compiler
162072b676d7Smrg      # -m* pass through architecture-specific compiler args for GCC
162172b676d7Smrg      # -m*, -t[45]*, -txscale* pass through architecture-specific
162272b676d7Smrg      # compiler args for GCC
162372b676d7Smrg      # -pg pass through profiling flag for GCC
162472b676d7Smrg      # @file GCC response files
162572b676d7Smrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*|-pg| \
162672b676d7Smrg      -t[45]*|-txscale*|@*)
162772b676d7Smrg
162872b676d7Smrg	# Unknown arguments in both finalize_command and compile_command need
162972b676d7Smrg	# to be aesthetically quoted because they are evaled later.
163072b676d7Smrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
163172b676d7Smrg	case $arg in
163272b676d7Smrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
163372b676d7Smrg	  arg="\"$arg\""
163472b676d7Smrg	  ;;
163572b676d7Smrg	esac
163672b676d7Smrg        compile_command="$compile_command $arg"
163772b676d7Smrg        finalize_command="$finalize_command $arg"
163872b676d7Smrg        compiler_flags="$compiler_flags $arg"
163972b676d7Smrg        continue
164072b676d7Smrg        ;;
164172b676d7Smrg
164272b676d7Smrg      -shrext)
164372b676d7Smrg	prev=shrext
164472b676d7Smrg	continue
164572b676d7Smrg	;;
164672b676d7Smrg
164772b676d7Smrg      -no-fast-install)
164872b676d7Smrg	fast_install=no
164972b676d7Smrg	continue
165072b676d7Smrg	;;
165172b676d7Smrg
165272b676d7Smrg      -no-install)
165372b676d7Smrg	case $host in
165472b676d7Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
165572b676d7Smrg	  # The PATH hackery in wrapper scripts is required on Windows
165672b676d7Smrg	  # in order for the loader to find any dlls it needs.
165772b676d7Smrg	  $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2
165872b676d7Smrg	  $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2
165972b676d7Smrg	  fast_install=no
166072b676d7Smrg	  ;;
166172b676d7Smrg	*) no_install=yes ;;
166272b676d7Smrg	esac
166372b676d7Smrg	continue
166472b676d7Smrg	;;
166572b676d7Smrg
166672b676d7Smrg      -no-undefined)
166772b676d7Smrg	allow_undefined=no
166872b676d7Smrg	continue
166972b676d7Smrg	;;
167072b676d7Smrg
167172b676d7Smrg      -objectlist)
167272b676d7Smrg	prev=objectlist
167372b676d7Smrg	continue
167472b676d7Smrg	;;
167572b676d7Smrg
167672b676d7Smrg      -o) prev=output ;;
167772b676d7Smrg
167872b676d7Smrg      -precious-files-regex)
167972b676d7Smrg	prev=precious_regex
168072b676d7Smrg	continue
168172b676d7Smrg	;;
168272b676d7Smrg
168372b676d7Smrg      -release)
168472b676d7Smrg	prev=release
168572b676d7Smrg	continue
168672b676d7Smrg	;;
168772b676d7Smrg
168872b676d7Smrg      -rpath)
168972b676d7Smrg	prev=rpath
169072b676d7Smrg	continue
169172b676d7Smrg	;;
169272b676d7Smrg
169372b676d7Smrg      -R)
169472b676d7Smrg	prev=xrpath
169572b676d7Smrg	continue
169672b676d7Smrg	;;
169772b676d7Smrg
169872b676d7Smrg      -R*)
169972b676d7Smrg	dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
170072b676d7Smrg	# We need an absolute path.
170172b676d7Smrg	case $dir in
170272b676d7Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
170372b676d7Smrg	*)
170472b676d7Smrg	  $echo "$modename: only absolute run-paths are allowed" 1>&2
170572b676d7Smrg	  exit $EXIT_FAILURE
170672b676d7Smrg	  ;;
170772b676d7Smrg	esac
170872b676d7Smrg	case "$xrpath " in
170972b676d7Smrg	*" $dir "*) ;;
171072b676d7Smrg	*) xrpath="$xrpath $dir" ;;
171172b676d7Smrg	esac
171272b676d7Smrg	continue
171372b676d7Smrg	;;
171472b676d7Smrg
171572b676d7Smrg      -static)
171672b676d7Smrg	# The effects of -static are defined in a previous loop.
171772b676d7Smrg	# We used to do the same as -all-static on platforms that
171872b676d7Smrg	# didn't have a PIC flag, but the assumption that the effects
171972b676d7Smrg	# would be equivalent was wrong.  It would break on at least
172072b676d7Smrg	# Digital Unix and AIX.
172172b676d7Smrg	continue
172272b676d7Smrg	;;
172372b676d7Smrg
172472b676d7Smrg      -thread-safe)
172572b676d7Smrg	thread_safe=yes
172672b676d7Smrg	continue
172772b676d7Smrg	;;
172872b676d7Smrg
172972b676d7Smrg      -version-info)
173072b676d7Smrg	prev=vinfo
173172b676d7Smrg	continue
173272b676d7Smrg	;;
173372b676d7Smrg      -version-number)
173472b676d7Smrg	prev=vinfo
173572b676d7Smrg	vinfo_number=yes
173672b676d7Smrg	continue
173772b676d7Smrg	;;
173872b676d7Smrg
173972b676d7Smrg      -Wc,*)
174072b676d7Smrg	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'`
174172b676d7Smrg	arg=
174272b676d7Smrg	save_ifs="$IFS"; IFS=','
174372b676d7Smrg	for flag in $args; do
174472b676d7Smrg	  IFS="$save_ifs"
174572b676d7Smrg	  case $flag in
174672b676d7Smrg	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
174772b676d7Smrg	    flag="\"$flag\""
174872b676d7Smrg	    ;;
174972b676d7Smrg	  esac
175072b676d7Smrg	  arg="$arg $wl$flag"
175172b676d7Smrg	  compiler_flags="$compiler_flags $flag"
175272b676d7Smrg	done
175372b676d7Smrg	IFS="$save_ifs"
175472b676d7Smrg	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
175572b676d7Smrg	;;
175672b676d7Smrg
175772b676d7Smrg      -Wl,*)
175872b676d7Smrg	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'`
175972b676d7Smrg	arg=
176072b676d7Smrg	save_ifs="$IFS"; IFS=','
176172b676d7Smrg	for flag in $args; do
176272b676d7Smrg	  IFS="$save_ifs"
176372b676d7Smrg	  case $flag in
176472b676d7Smrg	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
176572b676d7Smrg	    flag="\"$flag\""
176672b676d7Smrg	    ;;
176772b676d7Smrg	  esac
176872b676d7Smrg	  arg="$arg $wl$flag"
176972b676d7Smrg	  compiler_flags="$compiler_flags $wl$flag"
177072b676d7Smrg	  linker_flags="$linker_flags $flag"
177172b676d7Smrg	done
177272b676d7Smrg	IFS="$save_ifs"
177372b676d7Smrg	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
177472b676d7Smrg	;;
177572b676d7Smrg
177672b676d7Smrg      -Xcompiler)
177772b676d7Smrg	prev=xcompiler
177872b676d7Smrg	continue
177972b676d7Smrg	;;
178072b676d7Smrg
178172b676d7Smrg      -Xlinker)
178272b676d7Smrg	prev=xlinker
178372b676d7Smrg	continue
178472b676d7Smrg	;;
178572b676d7Smrg
178672b676d7Smrg      -XCClinker)
178772b676d7Smrg	prev=xcclinker
178872b676d7Smrg	continue
178972b676d7Smrg	;;
179072b676d7Smrg
179172b676d7Smrg      # Some other compiler flag.
179272b676d7Smrg      -* | +*)
179372b676d7Smrg	# Unknown arguments in both finalize_command and compile_command need
179472b676d7Smrg	# to be aesthetically quoted because they are evaled later.
179572b676d7Smrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
179672b676d7Smrg	case $arg in
179772b676d7Smrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
179872b676d7Smrg	  arg="\"$arg\""
179972b676d7Smrg	  ;;
180072b676d7Smrg	esac
180172b676d7Smrg	;;
180272b676d7Smrg
180372b676d7Smrg      *.$objext)
180472b676d7Smrg	# A standard object.
180572b676d7Smrg	objs="$objs $arg"
180672b676d7Smrg	;;
180772b676d7Smrg
180872b676d7Smrg      *.lo)
180972b676d7Smrg	# A libtool-controlled object.
181072b676d7Smrg
181172b676d7Smrg	# Check to see that this really is a libtool object.
181272b676d7Smrg	if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
181372b676d7Smrg	  pic_object=
181472b676d7Smrg	  non_pic_object=
181572b676d7Smrg
181672b676d7Smrg	  # Read the .lo file
181772b676d7Smrg	  # If there is no directory component, then add one.
181872b676d7Smrg	  case $arg in
181972b676d7Smrg	  */* | *\\*) . $arg ;;
182072b676d7Smrg	  *) . ./$arg ;;
182172b676d7Smrg	  esac
182272b676d7Smrg
182372b676d7Smrg	  if test -z "$pic_object" || \
182472b676d7Smrg	     test -z "$non_pic_object" ||
182572b676d7Smrg	     test "$pic_object" = none && \
182672b676d7Smrg	     test "$non_pic_object" = none; then
182772b676d7Smrg	    $echo "$modename: cannot find name of object for \`$arg'" 1>&2
182872b676d7Smrg	    exit $EXIT_FAILURE
182972b676d7Smrg	  fi
183072b676d7Smrg
183172b676d7Smrg	  # Extract subdirectory from the argument.
183272b676d7Smrg	  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
183372b676d7Smrg	  if test "X$xdir" = "X$arg"; then
183472b676d7Smrg	    xdir=
183572b676d7Smrg 	  else
183672b676d7Smrg	    xdir="$xdir/"
183772b676d7Smrg	  fi
183872b676d7Smrg
183972b676d7Smrg	  if test "$pic_object" != none; then
184072b676d7Smrg	    # Prepend the subdirectory the object is found in.
184172b676d7Smrg	    pic_object="$xdir$pic_object"
184272b676d7Smrg
184372b676d7Smrg	    if test "$prev" = dlfiles; then
184472b676d7Smrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
184572b676d7Smrg		dlfiles="$dlfiles $pic_object"
184672b676d7Smrg		prev=
184772b676d7Smrg		continue
184872b676d7Smrg	      else
184972b676d7Smrg		# If libtool objects are unsupported, then we need to preload.
185072b676d7Smrg		prev=dlprefiles
185172b676d7Smrg	      fi
185272b676d7Smrg	    fi
185372b676d7Smrg
185472b676d7Smrg	    # CHECK ME:  I think I busted this.  -Ossama
185572b676d7Smrg	    if test "$prev" = dlprefiles; then
185672b676d7Smrg	      # Preload the old-style object.
185772b676d7Smrg	      dlprefiles="$dlprefiles $pic_object"
185872b676d7Smrg	      prev=
185972b676d7Smrg	    fi
186072b676d7Smrg
186172b676d7Smrg	    # A PIC object.
186272b676d7Smrg	    libobjs="$libobjs $pic_object"
186372b676d7Smrg	    arg="$pic_object"
186472b676d7Smrg	  fi
186572b676d7Smrg
186672b676d7Smrg	  # Non-PIC object.
186772b676d7Smrg	  if test "$non_pic_object" != none; then
186872b676d7Smrg	    # Prepend the subdirectory the object is found in.
186972b676d7Smrg	    non_pic_object="$xdir$non_pic_object"
187072b676d7Smrg
187172b676d7Smrg	    # A standard non-PIC object
187272b676d7Smrg	    non_pic_objects="$non_pic_objects $non_pic_object"
187372b676d7Smrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
187472b676d7Smrg	      arg="$non_pic_object"
187572b676d7Smrg	    fi
187672b676d7Smrg	  else
187772b676d7Smrg	    # If the PIC object exists, use it instead.
187872b676d7Smrg	    # $xdir was prepended to $pic_object above.
187972b676d7Smrg	    non_pic_object="$pic_object"
188072b676d7Smrg	    non_pic_objects="$non_pic_objects $non_pic_object"
188172b676d7Smrg	  fi
188272b676d7Smrg	else
188372b676d7Smrg	  # Only an error if not doing a dry-run.
188472b676d7Smrg	  if test -z "$run"; then
188572b676d7Smrg	    $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
188672b676d7Smrg	    exit $EXIT_FAILURE
188772b676d7Smrg	  else
188872b676d7Smrg	    # Dry-run case.
188972b676d7Smrg
189072b676d7Smrg	    # Extract subdirectory from the argument.
189172b676d7Smrg	    xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
189272b676d7Smrg	    if test "X$xdir" = "X$arg"; then
189372b676d7Smrg	      xdir=
189472b676d7Smrg	    else
189572b676d7Smrg	      xdir="$xdir/"
189672b676d7Smrg	    fi
189772b676d7Smrg
189872b676d7Smrg	    pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
189972b676d7Smrg	    non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
190072b676d7Smrg	    libobjs="$libobjs $pic_object"
190172b676d7Smrg	    non_pic_objects="$non_pic_objects $non_pic_object"
190272b676d7Smrg	  fi
190372b676d7Smrg	fi
190472b676d7Smrg	;;
190572b676d7Smrg
190672b676d7Smrg      *.$libext)
190772b676d7Smrg	# An archive.
190872b676d7Smrg	deplibs="$deplibs $arg"
190972b676d7Smrg	old_deplibs="$old_deplibs $arg"
191072b676d7Smrg	continue
191172b676d7Smrg	;;
191272b676d7Smrg
191372b676d7Smrg      *.la)
191472b676d7Smrg	# A libtool-controlled library.
191572b676d7Smrg
191672b676d7Smrg	if test "$prev" = dlfiles; then
191772b676d7Smrg	  # This library was specified with -dlopen.
191872b676d7Smrg	  dlfiles="$dlfiles $arg"
191972b676d7Smrg	  prev=
192072b676d7Smrg	elif test "$prev" = dlprefiles; then
192172b676d7Smrg	  # The library was specified with -dlpreopen.
192272b676d7Smrg	  dlprefiles="$dlprefiles $arg"
192372b676d7Smrg	  prev=
192472b676d7Smrg	else
192572b676d7Smrg	  deplibs="$deplibs $arg"
192672b676d7Smrg	fi
192772b676d7Smrg	continue
192872b676d7Smrg	;;
192972b676d7Smrg
193072b676d7Smrg      # Some other compiler argument.
193172b676d7Smrg      *)
193272b676d7Smrg	# Unknown arguments in both finalize_command and compile_command need
193372b676d7Smrg	# to be aesthetically quoted because they are evaled later.
193472b676d7Smrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
193572b676d7Smrg	case $arg in
193672b676d7Smrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
193772b676d7Smrg	  arg="\"$arg\""
193872b676d7Smrg	  ;;
193972b676d7Smrg	esac
194072b676d7Smrg	;;
194172b676d7Smrg      esac # arg
194272b676d7Smrg
194372b676d7Smrg      # Now actually substitute the argument into the commands.
194472b676d7Smrg      if test -n "$arg"; then
194572b676d7Smrg	compile_command="$compile_command $arg"
194672b676d7Smrg	finalize_command="$finalize_command $arg"
194772b676d7Smrg      fi
194872b676d7Smrg    done # argument parsing loop
194972b676d7Smrg
195072b676d7Smrg    if test -n "$prev"; then
195172b676d7Smrg      $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
195272b676d7Smrg      $echo "$help" 1>&2
195372b676d7Smrg      exit $EXIT_FAILURE
195472b676d7Smrg    fi
195572b676d7Smrg
195672b676d7Smrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
195772b676d7Smrg      eval arg=\"$export_dynamic_flag_spec\"
195872b676d7Smrg      compile_command="$compile_command $arg"
195972b676d7Smrg      finalize_command="$finalize_command $arg"
196072b676d7Smrg    fi
196172b676d7Smrg
196272b676d7Smrg    oldlibs=
196372b676d7Smrg    # calculate the name of the file, without its directory
196472b676d7Smrg    outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
196572b676d7Smrg    libobjs_save="$libobjs"
196672b676d7Smrg
196772b676d7Smrg    if test -n "$shlibpath_var"; then
196872b676d7Smrg      # get the directories listed in $shlibpath_var
196972b676d7Smrg      eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
197072b676d7Smrg    else
197172b676d7Smrg      shlib_search_path=
197272b676d7Smrg    fi
197372b676d7Smrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
197472b676d7Smrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
197572b676d7Smrg
197672b676d7Smrg    output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
197772b676d7Smrg    if test "X$output_objdir" = "X$output"; then
197872b676d7Smrg      output_objdir="$objdir"
197972b676d7Smrg    else
198072b676d7Smrg      output_objdir="$output_objdir/$objdir"
198172b676d7Smrg    fi
198272b676d7Smrg    # Create the object directory.
198372b676d7Smrg    if test ! -d "$output_objdir"; then
198472b676d7Smrg      $show "$mkdir $output_objdir"
198572b676d7Smrg      $run $mkdir $output_objdir
198672b676d7Smrg      exit_status=$?
198772b676d7Smrg      if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then
198872b676d7Smrg	exit $exit_status
198972b676d7Smrg      fi
199072b676d7Smrg    fi
199172b676d7Smrg
199272b676d7Smrg    # Determine the type of output
199372b676d7Smrg    case $output in
199472b676d7Smrg    "")
199572b676d7Smrg      $echo "$modename: you must specify an output file" 1>&2
199672b676d7Smrg      $echo "$help" 1>&2
199772b676d7Smrg      exit $EXIT_FAILURE
199872b676d7Smrg      ;;
199972b676d7Smrg    *.$libext) linkmode=oldlib ;;
200072b676d7Smrg    *.lo | *.$objext) linkmode=obj ;;
200172b676d7Smrg    *.la) linkmode=lib ;;
200272b676d7Smrg    *) linkmode=prog ;; # Anything else should be a program.
200372b676d7Smrg    esac
200472b676d7Smrg
200572b676d7Smrg    case $host in
200672b676d7Smrg    *cygwin* | *mingw* | *pw32*)
200772b676d7Smrg      # don't eliminate duplications in $postdeps and $predeps
200872b676d7Smrg      duplicate_compiler_generated_deps=yes
200972b676d7Smrg      ;;
201072b676d7Smrg    *)
201172b676d7Smrg      duplicate_compiler_generated_deps=$duplicate_deps
201272b676d7Smrg      ;;
201372b676d7Smrg    esac
201472b676d7Smrg    specialdeplibs=
201572b676d7Smrg
201672b676d7Smrg    libs=
201772b676d7Smrg    # Find all interdependent deplibs by searching for libraries
201872b676d7Smrg    # that are linked more than once (e.g. -la -lb -la)
201972b676d7Smrg    for deplib in $deplibs; do
202072b676d7Smrg      if test "X$duplicate_deps" = "Xyes" ; then
202172b676d7Smrg	case "$libs " in
202272b676d7Smrg	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
202372b676d7Smrg	esac
202472b676d7Smrg      fi
202572b676d7Smrg      libs="$libs $deplib"
202672b676d7Smrg    done
202772b676d7Smrg
202872b676d7Smrg    if test "$linkmode" = lib; then
202972b676d7Smrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
203072b676d7Smrg
203172b676d7Smrg      # Compute libraries that are listed more than once in $predeps
203272b676d7Smrg      # $postdeps and mark them as special (i.e., whose duplicates are
203372b676d7Smrg      # not to be eliminated).
203472b676d7Smrg      pre_post_deps=
203572b676d7Smrg      if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then
203672b676d7Smrg	for pre_post_dep in $predeps $postdeps; do
203772b676d7Smrg	  case "$pre_post_deps " in
203872b676d7Smrg	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
203972b676d7Smrg	  esac
204072b676d7Smrg	  pre_post_deps="$pre_post_deps $pre_post_dep"
204172b676d7Smrg	done
204272b676d7Smrg      fi
204372b676d7Smrg      pre_post_deps=
204472b676d7Smrg    fi
204572b676d7Smrg
204672b676d7Smrg    deplibs=
204772b676d7Smrg    newdependency_libs=
204872b676d7Smrg    newlib_search_path=
204972b676d7Smrg    need_relink=no # whether we're linking any uninstalled libtool libraries
205072b676d7Smrg    notinst_deplibs= # not-installed libtool libraries
205172b676d7Smrg    case $linkmode in
205272b676d7Smrg    lib)
205372b676d7Smrg	passes="conv link"
205472b676d7Smrg	for file in $dlfiles $dlprefiles; do
205572b676d7Smrg	  case $file in
205672b676d7Smrg	  *.la) ;;
205772b676d7Smrg	  *)
205872b676d7Smrg	    $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2
205972b676d7Smrg	    exit $EXIT_FAILURE
206072b676d7Smrg	    ;;
206172b676d7Smrg	  esac
206272b676d7Smrg	done
206372b676d7Smrg	;;
206472b676d7Smrg    prog)
206572b676d7Smrg	compile_deplibs=
206672b676d7Smrg	finalize_deplibs=
206772b676d7Smrg	alldeplibs=no
206872b676d7Smrg	newdlfiles=
206972b676d7Smrg	newdlprefiles=
207072b676d7Smrg	passes="conv scan dlopen dlpreopen link"
207172b676d7Smrg	;;
207272b676d7Smrg    *)  passes="conv"
207372b676d7Smrg	;;
207472b676d7Smrg    esac
207572b676d7Smrg    for pass in $passes; do
207672b676d7Smrg      if test "$linkmode,$pass" = "lib,link" ||
207772b676d7Smrg	 test "$linkmode,$pass" = "prog,scan"; then
207872b676d7Smrg	libs="$deplibs"
207972b676d7Smrg	deplibs=
208072b676d7Smrg      fi
208172b676d7Smrg      if test "$linkmode" = prog; then
208272b676d7Smrg	case $pass in
208372b676d7Smrg	dlopen) libs="$dlfiles" ;;
208472b676d7Smrg	dlpreopen) libs="$dlprefiles" ;;
208572b676d7Smrg	link)
208672b676d7Smrg	  libs="$deplibs %DEPLIBS%"
208772b676d7Smrg	  test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
208872b676d7Smrg	  ;;
208972b676d7Smrg	esac
209072b676d7Smrg      fi
209172b676d7Smrg      if test "$pass" = dlopen; then
209272b676d7Smrg	# Collect dlpreopened libraries
209372b676d7Smrg	save_deplibs="$deplibs"
209472b676d7Smrg	deplibs=
209572b676d7Smrg      fi
209672b676d7Smrg      for deplib in $libs; do
209772b676d7Smrg	lib=
209872b676d7Smrg	found=no
209972b676d7Smrg	case $deplib in
210072b676d7Smrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
210172b676d7Smrg	  if test "$linkmode,$pass" = "prog,link"; then
210272b676d7Smrg	    compile_deplibs="$deplib $compile_deplibs"
210372b676d7Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
210472b676d7Smrg	  else
210572b676d7Smrg	    compiler_flags="$compiler_flags $deplib"
210672b676d7Smrg	  fi
210772b676d7Smrg	  continue
210872b676d7Smrg	  ;;
210972b676d7Smrg	-l*)
211072b676d7Smrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
211172b676d7Smrg	    $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2
211272b676d7Smrg	    continue
211372b676d7Smrg	  fi
211472b676d7Smrg	  name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
211572b676d7Smrg	  for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do
211672b676d7Smrg	    for search_ext in .la $std_shrext .so .a; do
211772b676d7Smrg	      # Search the libtool library
211872b676d7Smrg	      lib="$searchdir/lib${name}${search_ext}"
211972b676d7Smrg	      if test -f "$lib"; then
212072b676d7Smrg		if test "$search_ext" = ".la"; then
212172b676d7Smrg		  found=yes
212272b676d7Smrg		else
212372b676d7Smrg		  found=no
212472b676d7Smrg		fi
212572b676d7Smrg		break 2
212672b676d7Smrg	      fi
212772b676d7Smrg	    done
212872b676d7Smrg	  done
212972b676d7Smrg	  if test "$found" != yes; then
213072b676d7Smrg	    # deplib doesn't seem to be a libtool library
213172b676d7Smrg	    if test "$linkmode,$pass" = "prog,link"; then
213272b676d7Smrg	      compile_deplibs="$deplib $compile_deplibs"
213372b676d7Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
213472b676d7Smrg	    else
213572b676d7Smrg	      deplibs="$deplib $deplibs"
213672b676d7Smrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
213772b676d7Smrg	    fi
213872b676d7Smrg	    continue
213972b676d7Smrg	  else # deplib is a libtool library
214072b676d7Smrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
214172b676d7Smrg	    # We need to do some special things here, and not later.
214272b676d7Smrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
214372b676d7Smrg	      case " $predeps $postdeps " in
214472b676d7Smrg	      *" $deplib "*)
214572b676d7Smrg		if (${SED} -e '2q' $lib |
214672b676d7Smrg                    grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
214772b676d7Smrg		  library_names=
214872b676d7Smrg		  old_library=
214972b676d7Smrg		  case $lib in
215072b676d7Smrg		  */* | *\\*) . $lib ;;
215172b676d7Smrg		  *) . ./$lib ;;
215272b676d7Smrg		  esac
215372b676d7Smrg		  for l in $old_library $library_names; do
215472b676d7Smrg		    ll="$l"
215572b676d7Smrg		  done
215672b676d7Smrg		  if test "X$ll" = "X$old_library" ; then # only static version available
215772b676d7Smrg		    found=no
215872b676d7Smrg		    ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
215972b676d7Smrg		    test "X$ladir" = "X$lib" && ladir="."
216072b676d7Smrg		    lib=$ladir/$old_library
216172b676d7Smrg		    if test "$linkmode,$pass" = "prog,link"; then
216272b676d7Smrg		      compile_deplibs="$deplib $compile_deplibs"
216372b676d7Smrg		      finalize_deplibs="$deplib $finalize_deplibs"
216472b676d7Smrg		    else
216572b676d7Smrg		      deplibs="$deplib $deplibs"
216672b676d7Smrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
216772b676d7Smrg		    fi
216872b676d7Smrg		    continue
216972b676d7Smrg		  fi
217072b676d7Smrg		fi
217172b676d7Smrg	        ;;
217272b676d7Smrg	      *) ;;
217372b676d7Smrg	      esac
217472b676d7Smrg	    fi
217572b676d7Smrg	  fi
217672b676d7Smrg	  ;; # -l
217772b676d7Smrg	-L*)
217872b676d7Smrg	  case $linkmode in
217972b676d7Smrg	  lib)
218072b676d7Smrg	    deplibs="$deplib $deplibs"
218172b676d7Smrg	    test "$pass" = conv && continue
218272b676d7Smrg	    newdependency_libs="$deplib $newdependency_libs"
218372b676d7Smrg	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
218472b676d7Smrg	    ;;
218572b676d7Smrg	  prog)
218672b676d7Smrg	    if test "$pass" = conv; then
218772b676d7Smrg	      deplibs="$deplib $deplibs"
218872b676d7Smrg	      continue
218972b676d7Smrg	    fi
219072b676d7Smrg	    if test "$pass" = scan; then
219172b676d7Smrg	      deplibs="$deplib $deplibs"
219272b676d7Smrg	    else
219372b676d7Smrg	      compile_deplibs="$deplib $compile_deplibs"
219472b676d7Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
219572b676d7Smrg	    fi
219672b676d7Smrg	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
219772b676d7Smrg	    ;;
219872b676d7Smrg	  *)
219972b676d7Smrg	    $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2
220072b676d7Smrg	    ;;
220172b676d7Smrg	  esac # linkmode
220272b676d7Smrg	  continue
220372b676d7Smrg	  ;; # -L
220472b676d7Smrg	-R*)
220572b676d7Smrg	  if test "$pass" = link; then
220672b676d7Smrg	    dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
220772b676d7Smrg	    # Make sure the xrpath contains only unique directories.
220872b676d7Smrg	    case "$xrpath " in
220972b676d7Smrg	    *" $dir "*) ;;
221072b676d7Smrg	    *) xrpath="$xrpath $dir" ;;
221172b676d7Smrg	    esac
221272b676d7Smrg	  fi
221372b676d7Smrg	  deplibs="$deplib $deplibs"
221472b676d7Smrg	  continue
221572b676d7Smrg	  ;;
221672b676d7Smrg	*.la) lib="$deplib" ;;
221772b676d7Smrg	*.$libext)
221872b676d7Smrg	  if test "$pass" = conv; then
221972b676d7Smrg	    deplibs="$deplib $deplibs"
222072b676d7Smrg	    continue
222172b676d7Smrg	  fi
222272b676d7Smrg	  case $linkmode in
222372b676d7Smrg	  lib)
222472b676d7Smrg	    valid_a_lib=no
222572b676d7Smrg	    case $deplibs_check_method in
222672b676d7Smrg	      match_pattern*)
222772b676d7Smrg		set dummy $deplibs_check_method
222872b676d7Smrg	        match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
222972b676d7Smrg		if eval $echo \"$deplib\" 2>/dev/null \
223072b676d7Smrg		    | $SED 10q \
223172b676d7Smrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
223272b676d7Smrg		  valid_a_lib=yes
223372b676d7Smrg		fi
223472b676d7Smrg		;;
223572b676d7Smrg	      pass_all)
223672b676d7Smrg		valid_a_lib=yes
223772b676d7Smrg		;;
223872b676d7Smrg            esac
223972b676d7Smrg	    if test "$valid_a_lib" != yes; then
224072b676d7Smrg	      $echo
224172b676d7Smrg	      $echo "*** Warning: Trying to link with static lib archive $deplib."
224272b676d7Smrg	      $echo "*** I have the capability to make that library automatically link in when"
224372b676d7Smrg	      $echo "*** you link to this library.  But I can only do this if you have a"
224472b676d7Smrg	      $echo "*** shared version of the library, which you do not appear to have"
224572b676d7Smrg	      $echo "*** because the file extensions .$libext of this argument makes me believe"
224672b676d7Smrg	      $echo "*** that it is just a static archive that I should not used here."
224772b676d7Smrg	    else
224872b676d7Smrg	      $echo
224972b676d7Smrg	      $echo "*** Warning: Linking the shared library $output against the"
225072b676d7Smrg	      $echo "*** static library $deplib is not portable!"
225172b676d7Smrg	      deplibs="$deplib $deplibs"
225272b676d7Smrg	    fi
225372b676d7Smrg	    continue
225472b676d7Smrg	    ;;
225572b676d7Smrg	  prog)
225672b676d7Smrg	    if test "$pass" != link; then
225772b676d7Smrg	      deplibs="$deplib $deplibs"
225872b676d7Smrg	    else
225972b676d7Smrg	      compile_deplibs="$deplib $compile_deplibs"
226072b676d7Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
226172b676d7Smrg	    fi
226272b676d7Smrg	    continue
226372b676d7Smrg	    ;;
226472b676d7Smrg	  esac # linkmode
226572b676d7Smrg	  ;; # *.$libext
226672b676d7Smrg	*.lo | *.$objext)
226772b676d7Smrg	  if test "$pass" = conv; then
226872b676d7Smrg	    deplibs="$deplib $deplibs"
226972b676d7Smrg	  elif test "$linkmode" = prog; then
227072b676d7Smrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
227172b676d7Smrg	      # If there is no dlopen support or we're linking statically,
227272b676d7Smrg	      # we need to preload.
227372b676d7Smrg	      newdlprefiles="$newdlprefiles $deplib"
227472b676d7Smrg	      compile_deplibs="$deplib $compile_deplibs"
227572b676d7Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
227672b676d7Smrg	    else
227772b676d7Smrg	      newdlfiles="$newdlfiles $deplib"
227872b676d7Smrg	    fi
227972b676d7Smrg	  fi
228072b676d7Smrg	  continue
228172b676d7Smrg	  ;;
228272b676d7Smrg	%DEPLIBS%)
228372b676d7Smrg	  alldeplibs=yes
228472b676d7Smrg	  continue
228572b676d7Smrg	  ;;
228672b676d7Smrg	esac # case $deplib
228772b676d7Smrg	if test "$found" = yes || test -f "$lib"; then :
228872b676d7Smrg	else
228972b676d7Smrg	  $echo "$modename: cannot find the library \`$lib' or unhandled argument \`$deplib'" 1>&2
229072b676d7Smrg	  exit $EXIT_FAILURE
229172b676d7Smrg	fi
229272b676d7Smrg
229372b676d7Smrg	# Check to see that this really is a libtool archive.
229472b676d7Smrg	if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
229572b676d7Smrg	else
229672b676d7Smrg	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
229772b676d7Smrg	  exit $EXIT_FAILURE
229872b676d7Smrg	fi
229972b676d7Smrg
230072b676d7Smrg	ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
230172b676d7Smrg	test "X$ladir" = "X$lib" && ladir="."
230272b676d7Smrg
230372b676d7Smrg	dlname=
230472b676d7Smrg	dlopen=
230572b676d7Smrg	dlpreopen=
230672b676d7Smrg	libdir=
230772b676d7Smrg	library_names=
230872b676d7Smrg	old_library=
230972b676d7Smrg	# If the library was installed with an old release of libtool,
231072b676d7Smrg	# it will not redefine variables installed, or shouldnotlink
231172b676d7Smrg	installed=yes
231272b676d7Smrg	shouldnotlink=no
231372b676d7Smrg	avoidtemprpath=
231472b676d7Smrg
231572b676d7Smrg
231672b676d7Smrg	# Read the .la file
231772b676d7Smrg	case $lib in
231872b676d7Smrg	*/* | *\\*) . $lib ;;
231972b676d7Smrg	*) . ./$lib ;;
232072b676d7Smrg	esac
232172b676d7Smrg
232272b676d7Smrg	if test "$linkmode,$pass" = "lib,link" ||
232372b676d7Smrg	   test "$linkmode,$pass" = "prog,scan" ||
232472b676d7Smrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
232572b676d7Smrg	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
232672b676d7Smrg	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
232772b676d7Smrg	fi
232872b676d7Smrg
232972b676d7Smrg	if test "$pass" = conv; then
233072b676d7Smrg	  # Only check for convenience libraries
233172b676d7Smrg	  deplibs="$lib $deplibs"
233272b676d7Smrg	  if test -z "$libdir"; then
233372b676d7Smrg	    if test -z "$old_library"; then
233472b676d7Smrg	      $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
233572b676d7Smrg	      exit $EXIT_FAILURE
233672b676d7Smrg	    fi
233772b676d7Smrg	    # It is a libtool convenience library, so add in its objects.
233872b676d7Smrg	    convenience="$convenience $ladir/$objdir/$old_library"
233972b676d7Smrg	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
234072b676d7Smrg	    tmp_libs=
234172b676d7Smrg	    for deplib in $dependency_libs; do
234272b676d7Smrg	      deplibs="$deplib $deplibs"
234372b676d7Smrg              if test "X$duplicate_deps" = "Xyes" ; then
234472b676d7Smrg	        case "$tmp_libs " in
234572b676d7Smrg	        *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
234672b676d7Smrg	        esac
234772b676d7Smrg              fi
234872b676d7Smrg	      tmp_libs="$tmp_libs $deplib"
234972b676d7Smrg	    done
235072b676d7Smrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
235172b676d7Smrg	    $echo "$modename: \`$lib' is not a convenience library" 1>&2
235272b676d7Smrg	    exit $EXIT_FAILURE
235372b676d7Smrg	  fi
235472b676d7Smrg	  continue
235572b676d7Smrg	fi # $pass = conv
235672b676d7Smrg
235772b676d7Smrg
235872b676d7Smrg	# Get the name of the library we link against.
235972b676d7Smrg	linklib=
236072b676d7Smrg	for l in $old_library $library_names; do
236172b676d7Smrg	  linklib="$l"
236272b676d7Smrg	done
236372b676d7Smrg	if test -z "$linklib"; then
236472b676d7Smrg	  $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
236572b676d7Smrg	  exit $EXIT_FAILURE
236672b676d7Smrg	fi
236772b676d7Smrg
236872b676d7Smrg	# This library was specified with -dlopen.
236972b676d7Smrg	if test "$pass" = dlopen; then
237072b676d7Smrg	  if test -z "$libdir"; then
237172b676d7Smrg	    $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2
237272b676d7Smrg	    exit $EXIT_FAILURE
237372b676d7Smrg	  fi
237472b676d7Smrg	  if test -z "$dlname" ||
237572b676d7Smrg	     test "$dlopen_support" != yes ||
237672b676d7Smrg	     test "$build_libtool_libs" = no; then
237772b676d7Smrg	    # If there is no dlname, no dlopen support or we're linking
237872b676d7Smrg	    # statically, we need to preload.  We also need to preload any
237972b676d7Smrg	    # dependent libraries so libltdl's deplib preloader doesn't
238072b676d7Smrg	    # bomb out in the load deplibs phase.
238172b676d7Smrg	    dlprefiles="$dlprefiles $lib $dependency_libs"
238272b676d7Smrg	  else
238372b676d7Smrg	    newdlfiles="$newdlfiles $lib"
238472b676d7Smrg	  fi
238572b676d7Smrg	  continue
238672b676d7Smrg	fi # $pass = dlopen
238772b676d7Smrg
238872b676d7Smrg	# We need an absolute path.
238972b676d7Smrg	case $ladir in
239072b676d7Smrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
239172b676d7Smrg	*)
239272b676d7Smrg	  abs_ladir=`cd "$ladir" && pwd`
239372b676d7Smrg	  if test -z "$abs_ladir"; then
239472b676d7Smrg	    $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2
239572b676d7Smrg	    $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
239672b676d7Smrg	    abs_ladir="$ladir"
239772b676d7Smrg	  fi
239872b676d7Smrg	  ;;
239972b676d7Smrg	esac
240072b676d7Smrg	laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
240172b676d7Smrg
240272b676d7Smrg	# Find the relevant object directory and library name.
240372b676d7Smrg	if test "X$installed" = Xyes; then
240472b676d7Smrg	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
240572b676d7Smrg	    $echo "$modename: warning: library \`$lib' was moved." 1>&2
240672b676d7Smrg	    dir="$ladir"
240772b676d7Smrg	    absdir="$abs_ladir"
240872b676d7Smrg	    libdir="$abs_ladir"
240972b676d7Smrg	  else
241072b676d7Smrg	    dir="$libdir"
241172b676d7Smrg	    absdir="$libdir"
241272b676d7Smrg	  fi
241372b676d7Smrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
241472b676d7Smrg	else
241572b676d7Smrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
241672b676d7Smrg	    dir="$ladir"
241772b676d7Smrg	    absdir="$abs_ladir"
241872b676d7Smrg	    # Remove this search path later
241972b676d7Smrg	    notinst_path="$notinst_path $abs_ladir"
242072b676d7Smrg	  else
242172b676d7Smrg	    dir="$ladir/$objdir"
242272b676d7Smrg	    absdir="$abs_ladir/$objdir"
242372b676d7Smrg	    # Remove this search path later
242472b676d7Smrg	    notinst_path="$notinst_path $abs_ladir"
242572b676d7Smrg	  fi
242672b676d7Smrg	fi # $installed = yes
242772b676d7Smrg	name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
242872b676d7Smrg
242972b676d7Smrg	# This library was specified with -dlpreopen.
243072b676d7Smrg	if test "$pass" = dlpreopen; then
243172b676d7Smrg	  if test -z "$libdir"; then
243272b676d7Smrg	    $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2
243372b676d7Smrg	    exit $EXIT_FAILURE
243472b676d7Smrg	  fi
243572b676d7Smrg	  # Prefer using a static library (so that no silly _DYNAMIC symbols
243672b676d7Smrg	  # are required to link).
243772b676d7Smrg	  if test -n "$old_library"; then
243872b676d7Smrg	    newdlprefiles="$newdlprefiles $dir/$old_library"
243972b676d7Smrg	  # Otherwise, use the dlname, so that lt_dlopen finds it.
244072b676d7Smrg	  elif test -n "$dlname"; then
244172b676d7Smrg	    newdlprefiles="$newdlprefiles $dir/$dlname"
244272b676d7Smrg	  else
244372b676d7Smrg	    newdlprefiles="$newdlprefiles $dir/$linklib"
244472b676d7Smrg	  fi
244572b676d7Smrg	fi # $pass = dlpreopen
244672b676d7Smrg
244772b676d7Smrg	if test -z "$libdir"; then
244872b676d7Smrg	  # Link the convenience library
244972b676d7Smrg	  if test "$linkmode" = lib; then
245072b676d7Smrg	    deplibs="$dir/$old_library $deplibs"
245172b676d7Smrg	  elif test "$linkmode,$pass" = "prog,link"; then
245272b676d7Smrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
245372b676d7Smrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
245472b676d7Smrg	  else
245572b676d7Smrg	    deplibs="$lib $deplibs" # used for prog,scan pass
245672b676d7Smrg	  fi
245772b676d7Smrg	  continue
245872b676d7Smrg	fi
245972b676d7Smrg
246072b676d7Smrg
246172b676d7Smrg	if test "$linkmode" = prog && test "$pass" != link; then
246272b676d7Smrg	  newlib_search_path="$newlib_search_path $ladir"
246372b676d7Smrg	  deplibs="$lib $deplibs"
246472b676d7Smrg
246572b676d7Smrg	  linkalldeplibs=no
246672b676d7Smrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
246772b676d7Smrg	     test "$build_libtool_libs" = no; then
246872b676d7Smrg	    linkalldeplibs=yes
246972b676d7Smrg	  fi
247072b676d7Smrg
247172b676d7Smrg	  tmp_libs=
247272b676d7Smrg	  for deplib in $dependency_libs; do
247372b676d7Smrg	    case $deplib in
247472b676d7Smrg	    -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test
247572b676d7Smrg	    esac
247672b676d7Smrg	    # Need to link against all dependency_libs?
247772b676d7Smrg	    if test "$linkalldeplibs" = yes; then
247872b676d7Smrg	      deplibs="$deplib $deplibs"
247972b676d7Smrg	    else
248072b676d7Smrg	      # Need to hardcode shared library paths
248172b676d7Smrg	      # or/and link against static libraries
248272b676d7Smrg	      newdependency_libs="$deplib $newdependency_libs"
248372b676d7Smrg	    fi
248472b676d7Smrg	    if test "X$duplicate_deps" = "Xyes" ; then
248572b676d7Smrg	      case "$tmp_libs " in
248672b676d7Smrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
248772b676d7Smrg	      esac
248872b676d7Smrg	    fi
248972b676d7Smrg	    tmp_libs="$tmp_libs $deplib"
249072b676d7Smrg	  done # for deplib
249172b676d7Smrg	  continue
249272b676d7Smrg	fi # $linkmode = prog...
249372b676d7Smrg
249472b676d7Smrg	if test "$linkmode,$pass" = "prog,link"; then
249572b676d7Smrg	  if test -n "$library_names" &&
249672b676d7Smrg	     { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
249772b676d7Smrg	    # We need to hardcode the library path
249872b676d7Smrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
249972b676d7Smrg	      # Make sure the rpath contains only unique directories.
250072b676d7Smrg	      case "$temp_rpath " in
250172b676d7Smrg	      *" $dir "*) ;;
250272b676d7Smrg	      *" $absdir "*) ;;
250372b676d7Smrg	      *) temp_rpath="$temp_rpath $absdir" ;;
250472b676d7Smrg	      esac
250572b676d7Smrg	    fi
250672b676d7Smrg
250772b676d7Smrg	    # Hardcode the library path.
250872b676d7Smrg	    # Skip directories that are in the system default run-time
250972b676d7Smrg	    # search path.
251072b676d7Smrg	    case " $sys_lib_dlsearch_path " in
251172b676d7Smrg	    *" $absdir "*) ;;
251272b676d7Smrg	    *)
251372b676d7Smrg	      case "$compile_rpath " in
251472b676d7Smrg	      *" $absdir "*) ;;
251572b676d7Smrg	      *) compile_rpath="$compile_rpath $absdir"
251672b676d7Smrg	      esac
251772b676d7Smrg	      ;;
251872b676d7Smrg	    esac
251972b676d7Smrg	    case " $sys_lib_dlsearch_path " in
252072b676d7Smrg	    *" $libdir "*) ;;
252172b676d7Smrg	    *)
252272b676d7Smrg	      case "$finalize_rpath " in
252372b676d7Smrg	      *" $libdir "*) ;;
252472b676d7Smrg	      *) finalize_rpath="$finalize_rpath $libdir"
252572b676d7Smrg	      esac
252672b676d7Smrg	      ;;
252772b676d7Smrg	    esac
252872b676d7Smrg	  fi # $linkmode,$pass = prog,link...
252972b676d7Smrg
253072b676d7Smrg	  if test "$alldeplibs" = yes &&
253172b676d7Smrg	     { test "$deplibs_check_method" = pass_all ||
253272b676d7Smrg	       { test "$build_libtool_libs" = yes &&
253372b676d7Smrg		 test -n "$library_names"; }; }; then
253472b676d7Smrg	    # We only need to search for static libraries
253572b676d7Smrg	    continue
253672b676d7Smrg	  fi
253772b676d7Smrg	fi
253872b676d7Smrg
253972b676d7Smrg	link_static=no # Whether the deplib will be linked statically
254072b676d7Smrg	use_static_libs=$prefer_static_libs
254172b676d7Smrg	if test "$use_static_libs" = built && test "$installed" = yes ; then
254272b676d7Smrg	  use_static_libs=no
254372b676d7Smrg	fi
254472b676d7Smrg	if test -n "$library_names" &&
254572b676d7Smrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
254672b676d7Smrg	  if test "$installed" = no; then
254772b676d7Smrg	    notinst_deplibs="$notinst_deplibs $lib"
254872b676d7Smrg	    need_relink=yes
254972b676d7Smrg	  fi
255072b676d7Smrg	  # This is a shared library
255172b676d7Smrg
255272b676d7Smrg	  # Warn about portability, can't link against -module's on
255372b676d7Smrg	  # some systems (darwin)
255472b676d7Smrg	  if test "$shouldnotlink" = yes && test "$pass" = link ; then
255572b676d7Smrg	    $echo
255672b676d7Smrg	    if test "$linkmode" = prog; then
255772b676d7Smrg	      $echo "*** Warning: Linking the executable $output against the loadable module"
255872b676d7Smrg	    else
255972b676d7Smrg	      $echo "*** Warning: Linking the shared library $output against the loadable module"
256072b676d7Smrg	    fi
256172b676d7Smrg	    $echo "*** $linklib is not portable!"
256272b676d7Smrg	  fi
256372b676d7Smrg	  if test "$linkmode" = lib &&
256472b676d7Smrg	     test "$hardcode_into_libs" = yes; then
256572b676d7Smrg	    # Hardcode the library path.
256672b676d7Smrg	    # Skip directories that are in the system default run-time
256772b676d7Smrg	    # search path.
256872b676d7Smrg	    case " $sys_lib_dlsearch_path " in
256972b676d7Smrg	    *" $absdir "*) ;;
257072b676d7Smrg	    *)
257172b676d7Smrg	      case "$compile_rpath " in
257272b676d7Smrg	      *" $absdir "*) ;;
257372b676d7Smrg	      *) compile_rpath="$compile_rpath $absdir"
257472b676d7Smrg	      esac
257572b676d7Smrg	      ;;
257672b676d7Smrg	    esac
257772b676d7Smrg	    case " $sys_lib_dlsearch_path " in
257872b676d7Smrg	    *" $libdir "*) ;;
257972b676d7Smrg	    *)
258072b676d7Smrg	      case "$finalize_rpath " in
258172b676d7Smrg	      *" $libdir "*) ;;
258272b676d7Smrg	      *) finalize_rpath="$finalize_rpath $libdir"
258372b676d7Smrg	      esac
258472b676d7Smrg	      ;;
258572b676d7Smrg	    esac
258672b676d7Smrg	  fi
258772b676d7Smrg
258872b676d7Smrg	  if test -n "$old_archive_from_expsyms_cmds"; then
258972b676d7Smrg	    # figure out the soname
259072b676d7Smrg	    set dummy $library_names
259172b676d7Smrg	    realname="$2"
259272b676d7Smrg	    shift; shift
259372b676d7Smrg	    libname=`eval \\$echo \"$libname_spec\"`
259472b676d7Smrg	    # use dlname if we got it. it's perfectly good, no?
259572b676d7Smrg	    if test -n "$dlname"; then
259672b676d7Smrg	      soname="$dlname"
259772b676d7Smrg	    elif test -n "$soname_spec"; then
259872b676d7Smrg	      # bleh windows
259972b676d7Smrg	      case $host in
260072b676d7Smrg	      *cygwin* | mingw*)
260172b676d7Smrg		major=`expr $current - $age`
260272b676d7Smrg		versuffix="-$major"
260372b676d7Smrg		;;
260472b676d7Smrg	      esac
260572b676d7Smrg	      eval soname=\"$soname_spec\"
260672b676d7Smrg	    else
260772b676d7Smrg	      soname="$realname"
260872b676d7Smrg	    fi
260972b676d7Smrg
261072b676d7Smrg	    # Make a new name for the extract_expsyms_cmds to use
261172b676d7Smrg	    soroot="$soname"
261272b676d7Smrg	    soname=`$echo $soroot | ${SED} -e 's/^.*\///'`
261372b676d7Smrg	    newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a"
261472b676d7Smrg
261572b676d7Smrg	    # If the library has no export list, then create one now
261672b676d7Smrg	    if test -f "$output_objdir/$soname-def"; then :
261772b676d7Smrg	    else
261872b676d7Smrg	      $show "extracting exported symbol list from \`$soname'"
261972b676d7Smrg	      save_ifs="$IFS"; IFS='~'
262072b676d7Smrg	      cmds=$extract_expsyms_cmds
262172b676d7Smrg	      for cmd in $cmds; do
262272b676d7Smrg		IFS="$save_ifs"
262372b676d7Smrg		eval cmd=\"$cmd\"
262472b676d7Smrg		$show "$cmd"
262572b676d7Smrg		$run eval "$cmd" || exit $?
262672b676d7Smrg	      done
262772b676d7Smrg	      IFS="$save_ifs"
262872b676d7Smrg	    fi
262972b676d7Smrg
263072b676d7Smrg	    # Create $newlib
263172b676d7Smrg	    if test -f "$output_objdir/$newlib"; then :; else
263272b676d7Smrg	      $show "generating import library for \`$soname'"
263372b676d7Smrg	      save_ifs="$IFS"; IFS='~'
263472b676d7Smrg	      cmds=$old_archive_from_expsyms_cmds
263572b676d7Smrg	      for cmd in $cmds; do
263672b676d7Smrg		IFS="$save_ifs"
263772b676d7Smrg		eval cmd=\"$cmd\"
263872b676d7Smrg		$show "$cmd"
263972b676d7Smrg		$run eval "$cmd" || exit $?
264072b676d7Smrg	      done
264172b676d7Smrg	      IFS="$save_ifs"
264272b676d7Smrg	    fi
264372b676d7Smrg	    # make sure the library variables are pointing to the new library
264472b676d7Smrg	    dir=$output_objdir
264572b676d7Smrg	    linklib=$newlib
264672b676d7Smrg	  fi # test -n "$old_archive_from_expsyms_cmds"
264772b676d7Smrg
264872b676d7Smrg	  if test "$linkmode" = prog || test "$mode" != relink; then
264972b676d7Smrg	    add_shlibpath=
265072b676d7Smrg	    add_dir=
265172b676d7Smrg	    add=
265272b676d7Smrg	    lib_linked=yes
265372b676d7Smrg	    case $hardcode_action in
265472b676d7Smrg	    immediate | unsupported)
265572b676d7Smrg	      if test "$hardcode_direct" = no; then
265672b676d7Smrg		add="$dir/$linklib"
265772b676d7Smrg		case $host in
265872b676d7Smrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
265972b676d7Smrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
266072b676d7Smrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
266172b676d7Smrg		    *-*-unixware7*) add_dir="-L$dir" ;;
266272b676d7Smrg		  *-*-darwin* )
266372b676d7Smrg		    # if the lib is a module then we can not link against
266472b676d7Smrg		    # it, someone is ignoring the new warnings I added
266572b676d7Smrg		    if /usr/bin/file -L $add 2> /dev/null |
266672b676d7Smrg                      $EGREP ": [^:]* bundle" >/dev/null ; then
266772b676d7Smrg		      $echo "** Warning, lib $linklib is a module, not a shared library"
266872b676d7Smrg		      if test -z "$old_library" ; then
266972b676d7Smrg		        $echo
267072b676d7Smrg		        $echo "** And there doesn't seem to be a static archive available"
267172b676d7Smrg		        $echo "** The link will probably fail, sorry"
267272b676d7Smrg		      else
267372b676d7Smrg		        add="$dir/$old_library"
267472b676d7Smrg		      fi
267572b676d7Smrg		    fi
267672b676d7Smrg		esac
267772b676d7Smrg	      elif test "$hardcode_minus_L" = no; then
267872b676d7Smrg		case $host in
267972b676d7Smrg		*-*-sunos*) add_shlibpath="$dir" ;;
268072b676d7Smrg		esac
268172b676d7Smrg		add_dir="-L$dir"
268272b676d7Smrg		add="-l$name"
268372b676d7Smrg	      elif test "$hardcode_shlibpath_var" = no; then
268472b676d7Smrg		add_shlibpath="$dir"
268572b676d7Smrg		add="-l$name"
268672b676d7Smrg	      else
268772b676d7Smrg		lib_linked=no
268872b676d7Smrg	      fi
268972b676d7Smrg	      ;;
269072b676d7Smrg	    relink)
269172b676d7Smrg	      if test "$hardcode_direct" = yes; then
269272b676d7Smrg		add="$dir/$linklib"
269372b676d7Smrg	      elif test "$hardcode_minus_L" = yes; then
269472b676d7Smrg		add_dir="-L$dir"
269572b676d7Smrg		# Try looking first in the location we're being installed to.
269672b676d7Smrg		if test -n "$inst_prefix_dir"; then
269772b676d7Smrg		  case $libdir in
269872b676d7Smrg		    [\\/]*)
269972b676d7Smrg		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
270072b676d7Smrg		      ;;
270172b676d7Smrg		  esac
270272b676d7Smrg		fi
270372b676d7Smrg		add="-l$name"
270472b676d7Smrg	      elif test "$hardcode_shlibpath_var" = yes; then
270572b676d7Smrg		add_shlibpath="$dir"
270672b676d7Smrg		add="-l$name"
270772b676d7Smrg	      else
270872b676d7Smrg		lib_linked=no
270972b676d7Smrg	      fi
271072b676d7Smrg	      ;;
271172b676d7Smrg	    *) lib_linked=no ;;
271272b676d7Smrg	    esac
271372b676d7Smrg
271472b676d7Smrg	    if test "$lib_linked" != yes; then
271572b676d7Smrg	      $echo "$modename: configuration error: unsupported hardcode properties"
271672b676d7Smrg	      exit $EXIT_FAILURE
271772b676d7Smrg	    fi
271872b676d7Smrg
271972b676d7Smrg	    if test -n "$add_shlibpath"; then
272072b676d7Smrg	      case :$compile_shlibpath: in
272172b676d7Smrg	      *":$add_shlibpath:"*) ;;
272272b676d7Smrg	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
272372b676d7Smrg	      esac
272472b676d7Smrg	    fi
272572b676d7Smrg	    if test "$linkmode" = prog; then
272672b676d7Smrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
272772b676d7Smrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
272872b676d7Smrg	    else
272972b676d7Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
273072b676d7Smrg	      test -n "$add" && deplibs="$add $deplibs"
273172b676d7Smrg	      if test "$hardcode_direct" != yes && \
273272b676d7Smrg		 test "$hardcode_minus_L" != yes && \
273372b676d7Smrg		 test "$hardcode_shlibpath_var" = yes; then
273472b676d7Smrg		case :$finalize_shlibpath: in
273572b676d7Smrg		*":$libdir:"*) ;;
273672b676d7Smrg		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
273772b676d7Smrg		esac
273872b676d7Smrg	      fi
273972b676d7Smrg	    fi
274072b676d7Smrg	  fi
274172b676d7Smrg
274272b676d7Smrg	  if test "$linkmode" = prog || test "$mode" = relink; then
274372b676d7Smrg	    add_shlibpath=
274472b676d7Smrg	    add_dir=
274572b676d7Smrg	    add=
274672b676d7Smrg	    # Finalize command for both is simple: just hardcode it.
274772b676d7Smrg	    if test "$hardcode_direct" = yes; then
274872b676d7Smrg	      add="$libdir/$linklib"
274972b676d7Smrg	    elif test "$hardcode_minus_L" = yes; then
275072b676d7Smrg	      add_dir="-L$libdir"
275172b676d7Smrg	      add="-l$name"
275272b676d7Smrg	    elif test "$hardcode_shlibpath_var" = yes; then
275372b676d7Smrg	      case :$finalize_shlibpath: in
275472b676d7Smrg	      *":$libdir:"*) ;;
275572b676d7Smrg	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
275672b676d7Smrg	      esac
275772b676d7Smrg	      add="-l$name"
275872b676d7Smrg	    elif test "$hardcode_automatic" = yes; then
275972b676d7Smrg	      if test -n "$inst_prefix_dir" &&
276072b676d7Smrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
276172b676d7Smrg	        add="$inst_prefix_dir$libdir/$linklib"
276272b676d7Smrg	      else
276372b676d7Smrg	        add="$libdir/$linklib"
276472b676d7Smrg	      fi
276572b676d7Smrg	    else
276672b676d7Smrg	      # We cannot seem to hardcode it, guess we'll fake it.
276772b676d7Smrg	      add_dir="-L$libdir"
276872b676d7Smrg	      # Try looking first in the location we're being installed to.
276972b676d7Smrg	      if test -n "$inst_prefix_dir"; then
277072b676d7Smrg		case $libdir in
277172b676d7Smrg		  [\\/]*)
277272b676d7Smrg		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
277372b676d7Smrg		    ;;
277472b676d7Smrg		esac
277572b676d7Smrg	      fi
277672b676d7Smrg	      add="-l$name"
277772b676d7Smrg	    fi
277872b676d7Smrg
277972b676d7Smrg	    if test "$linkmode" = prog; then
278072b676d7Smrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
278172b676d7Smrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
278272b676d7Smrg	    else
278372b676d7Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
278472b676d7Smrg	      test -n "$add" && deplibs="$add $deplibs"
278572b676d7Smrg	    fi
278672b676d7Smrg	  fi
278772b676d7Smrg	elif test "$linkmode" = prog; then
278872b676d7Smrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
278972b676d7Smrg	  # is not unsupported.  This is valid on all known static and
279072b676d7Smrg	  # shared platforms.
279172b676d7Smrg	  if test "$hardcode_direct" != unsupported; then
279272b676d7Smrg	    test -n "$old_library" && linklib="$old_library"
279372b676d7Smrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
279472b676d7Smrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
279572b676d7Smrg	  else
279672b676d7Smrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
279772b676d7Smrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
279872b676d7Smrg	  fi
279972b676d7Smrg	elif test "$build_libtool_libs" = yes; then
280072b676d7Smrg	  # Not a shared library
280172b676d7Smrg	  if test "$deplibs_check_method" != pass_all; then
280272b676d7Smrg	    # We're trying link a shared library against a static one
280372b676d7Smrg	    # but the system doesn't support it.
280472b676d7Smrg
280572b676d7Smrg	    # Just print a warning and add the library to dependency_libs so
280672b676d7Smrg	    # that the program can be linked against the static library.
280772b676d7Smrg	    $echo
280872b676d7Smrg	    $echo "*** Warning: This system can not link to static lib archive $lib."
280972b676d7Smrg	    $echo "*** I have the capability to make that library automatically link in when"
281072b676d7Smrg	    $echo "*** you link to this library.  But I can only do this if you have a"
281172b676d7Smrg	    $echo "*** shared version of the library, which you do not appear to have."
281272b676d7Smrg	    if test "$module" = yes; then
281372b676d7Smrg	      $echo "*** But as you try to build a module library, libtool will still create "
281472b676d7Smrg	      $echo "*** a static module, that should work as long as the dlopening application"
281572b676d7Smrg	      $echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
281672b676d7Smrg	      if test -z "$global_symbol_pipe"; then
281772b676d7Smrg		$echo
281872b676d7Smrg		$echo "*** However, this would only work if libtool was able to extract symbol"
281972b676d7Smrg		$echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
282072b676d7Smrg		$echo "*** not find such a program.  So, this module is probably useless."
282172b676d7Smrg		$echo "*** \`nm' from GNU binutils and a full rebuild may help."
282272b676d7Smrg	      fi
282372b676d7Smrg	      if test "$build_old_libs" = no; then
282472b676d7Smrg		build_libtool_libs=module
282572b676d7Smrg		build_old_libs=yes
282672b676d7Smrg	      else
282772b676d7Smrg		build_libtool_libs=no
282872b676d7Smrg	      fi
282972b676d7Smrg	    fi
283072b676d7Smrg	  else
283172b676d7Smrg	    deplibs="$dir/$old_library $deplibs"
283272b676d7Smrg	    link_static=yes
283372b676d7Smrg	  fi
283472b676d7Smrg	fi # link shared/static library?
283572b676d7Smrg
283672b676d7Smrg	if test "$linkmode" = lib; then
283772b676d7Smrg	  if test -n "$dependency_libs" &&
283872b676d7Smrg	     { test "$hardcode_into_libs" != yes ||
283972b676d7Smrg	       test "$build_old_libs" = yes ||
284072b676d7Smrg	       test "$link_static" = yes; }; then
284172b676d7Smrg	    # Extract -R from dependency_libs
284272b676d7Smrg	    temp_deplibs=
284372b676d7Smrg	    for libdir in $dependency_libs; do
284472b676d7Smrg	      case $libdir in
284572b676d7Smrg	      -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'`
284672b676d7Smrg		   case " $xrpath " in
284772b676d7Smrg		   *" $temp_xrpath "*) ;;
284872b676d7Smrg		   *) xrpath="$xrpath $temp_xrpath";;
284972b676d7Smrg		   esac;;
285072b676d7Smrg	      *) temp_deplibs="$temp_deplibs $libdir";;
285172b676d7Smrg	      esac
285272b676d7Smrg	    done
285372b676d7Smrg	    dependency_libs="$temp_deplibs"
285472b676d7Smrg	  fi
285572b676d7Smrg
285672b676d7Smrg	  newlib_search_path="$newlib_search_path $absdir"
285772b676d7Smrg	  # Link against this library
285872b676d7Smrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
285972b676d7Smrg	  # ... and its dependency_libs
286072b676d7Smrg	  tmp_libs=
286172b676d7Smrg	  for deplib in $dependency_libs; do
286272b676d7Smrg	    newdependency_libs="$deplib $newdependency_libs"
286372b676d7Smrg	    if test "X$duplicate_deps" = "Xyes" ; then
286472b676d7Smrg	      case "$tmp_libs " in
286572b676d7Smrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
286672b676d7Smrg	      esac
286772b676d7Smrg	    fi
286872b676d7Smrg	    tmp_libs="$tmp_libs $deplib"
286972b676d7Smrg	  done
287072b676d7Smrg
287172b676d7Smrg	  if test "$link_all_deplibs" != no; then
287272b676d7Smrg	    # Add the search paths of all dependency libraries
287372b676d7Smrg	    for deplib in $dependency_libs; do
287472b676d7Smrg	      case $deplib in
287572b676d7Smrg	      -L*) path="$deplib" ;;
287672b676d7Smrg	      *.la)
287772b676d7Smrg		dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'`
287872b676d7Smrg		test "X$dir" = "X$deplib" && dir="."
287972b676d7Smrg		# We need an absolute path.
288072b676d7Smrg		case $dir in
288172b676d7Smrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
288272b676d7Smrg		*)
288372b676d7Smrg		  absdir=`cd "$dir" && pwd`
288472b676d7Smrg		  if test -z "$absdir"; then
288572b676d7Smrg		    $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
288672b676d7Smrg		    absdir="$dir"
288772b676d7Smrg		  fi
288872b676d7Smrg		  ;;
288972b676d7Smrg		esac
289072b676d7Smrg		if grep "^installed=no" $deplib > /dev/null; then
289172b676d7Smrg		  path="$absdir/$objdir"
289272b676d7Smrg		else
289372b676d7Smrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
289472b676d7Smrg		  if test -z "$libdir"; then
289572b676d7Smrg		    $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
289672b676d7Smrg		    exit $EXIT_FAILURE
289772b676d7Smrg		  fi
289872b676d7Smrg		  if test "$absdir" != "$libdir"; then
289972b676d7Smrg		    $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2
290072b676d7Smrg		  fi
290172b676d7Smrg		  path="$absdir"
290272b676d7Smrg		fi
290372b676d7Smrg		depdepl=
290472b676d7Smrg		case $host in
290572b676d7Smrg		*-*-darwin*)
290672b676d7Smrg		  # we do not want to link against static libs,
290772b676d7Smrg		  # but need to link against shared
290872b676d7Smrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
290972b676d7Smrg		  if test -n "$deplibrary_names" ; then
291072b676d7Smrg		    for tmp in $deplibrary_names ; do
291172b676d7Smrg		      depdepl=$tmp
291272b676d7Smrg		    done
291372b676d7Smrg		    if test -f "$path/$depdepl" ; then
291472b676d7Smrg		      depdepl="$path/$depdepl"
291572b676d7Smrg		    fi
291672b676d7Smrg		    # do not add paths which are already there
291772b676d7Smrg		    case " $newlib_search_path " in
291872b676d7Smrg		    *" $path "*) ;;
291972b676d7Smrg		    *) newlib_search_path="$newlib_search_path $path";;
292072b676d7Smrg		    esac
292172b676d7Smrg		  fi
292272b676d7Smrg		  path=""
292372b676d7Smrg		  ;;
292472b676d7Smrg		*)
292572b676d7Smrg		  path="-L$path"
292672b676d7Smrg		  ;;
292772b676d7Smrg		esac
292872b676d7Smrg		;;
292972b676d7Smrg	      -l*)
293072b676d7Smrg		case $host in
293172b676d7Smrg		*-*-darwin*)
293272b676d7Smrg		  # Again, we only want to link against shared libraries
293372b676d7Smrg		  eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"`
293472b676d7Smrg		  for tmp in $newlib_search_path ; do
293572b676d7Smrg		    if test -f "$tmp/lib$tmp_libs.dylib" ; then
293672b676d7Smrg		      eval depdepl="$tmp/lib$tmp_libs.dylib"
293772b676d7Smrg		      break
293872b676d7Smrg		    fi
293972b676d7Smrg		  done
294072b676d7Smrg		  path=""
294172b676d7Smrg		  ;;
294272b676d7Smrg		*) continue ;;
294372b676d7Smrg		esac
294472b676d7Smrg		;;
294572b676d7Smrg	      *) continue ;;
294672b676d7Smrg	      esac
294772b676d7Smrg	      case " $deplibs " in
294872b676d7Smrg	      *" $path "*) ;;
294972b676d7Smrg	      *) deplibs="$path $deplibs" ;;
295072b676d7Smrg	      esac
295172b676d7Smrg	      case " $deplibs " in
295272b676d7Smrg	      *" $depdepl "*) ;;
295372b676d7Smrg	      *) deplibs="$depdepl $deplibs" ;;
295472b676d7Smrg	      esac
295572b676d7Smrg	    done
295672b676d7Smrg	  fi # link_all_deplibs != no
295772b676d7Smrg	fi # linkmode = lib
295872b676d7Smrg      done # for deplib in $libs
295972b676d7Smrg      dependency_libs="$newdependency_libs"
296072b676d7Smrg      if test "$pass" = dlpreopen; then
296172b676d7Smrg	# Link the dlpreopened libraries before other libraries
296272b676d7Smrg	for deplib in $save_deplibs; do
296372b676d7Smrg	  deplibs="$deplib $deplibs"
296472b676d7Smrg	done
296572b676d7Smrg      fi
296672b676d7Smrg      if test "$pass" != dlopen; then
296772b676d7Smrg	if test "$pass" != conv; then
296872b676d7Smrg	  # Make sure lib_search_path contains only unique directories.
296972b676d7Smrg	  lib_search_path=
297072b676d7Smrg	  for dir in $newlib_search_path; do
297172b676d7Smrg	    case "$lib_search_path " in
297272b676d7Smrg	    *" $dir "*) ;;
297372b676d7Smrg	    *) lib_search_path="$lib_search_path $dir" ;;
297472b676d7Smrg	    esac
297572b676d7Smrg	  done
297672b676d7Smrg	  newlib_search_path=
297772b676d7Smrg	fi
297872b676d7Smrg
297972b676d7Smrg	if test "$linkmode,$pass" != "prog,link"; then
298072b676d7Smrg	  vars="deplibs"
298172b676d7Smrg	else
298272b676d7Smrg	  vars="compile_deplibs finalize_deplibs"
298372b676d7Smrg	fi
298472b676d7Smrg	for var in $vars dependency_libs; do
298572b676d7Smrg	  # Add libraries to $var in reverse order
298672b676d7Smrg	  eval tmp_libs=\"\$$var\"
298772b676d7Smrg	  new_libs=
298872b676d7Smrg	  for deplib in $tmp_libs; do
298972b676d7Smrg	    # FIXME: Pedantically, this is the right thing to do, so
299072b676d7Smrg	    #        that some nasty dependency loop isn't accidentally
299172b676d7Smrg	    #        broken:
299272b676d7Smrg	    #new_libs="$deplib $new_libs"
299372b676d7Smrg	    # Pragmatically, this seems to cause very few problems in
299472b676d7Smrg	    # practice:
299572b676d7Smrg	    case $deplib in
299672b676d7Smrg	    -L*) new_libs="$deplib $new_libs" ;;
299772b676d7Smrg	    -R*) ;;
299872b676d7Smrg	    *)
299972b676d7Smrg	      # And here is the reason: when a library appears more
300072b676d7Smrg	      # than once as an explicit dependence of a library, or
300172b676d7Smrg	      # is implicitly linked in more than once by the
300272b676d7Smrg	      # compiler, it is considered special, and multiple
300372b676d7Smrg	      # occurrences thereof are not removed.  Compare this
300472b676d7Smrg	      # with having the same library being listed as a
300572b676d7Smrg	      # dependency of multiple other libraries: in this case,
300672b676d7Smrg	      # we know (pedantically, we assume) the library does not
300772b676d7Smrg	      # need to be listed more than once, so we keep only the
300872b676d7Smrg	      # last copy.  This is not always right, but it is rare
300972b676d7Smrg	      # enough that we require users that really mean to play
301072b676d7Smrg	      # such unportable linking tricks to link the library
301172b676d7Smrg	      # using -Wl,-lname, so that libtool does not consider it
301272b676d7Smrg	      # for duplicate removal.
301372b676d7Smrg	      case " $specialdeplibs " in
301472b676d7Smrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
301572b676d7Smrg	      *)
301672b676d7Smrg		case " $new_libs " in
301772b676d7Smrg		*" $deplib "*) ;;
301872b676d7Smrg		*) new_libs="$deplib $new_libs" ;;
301972b676d7Smrg		esac
302072b676d7Smrg		;;
302172b676d7Smrg	      esac
302272b676d7Smrg	      ;;
302372b676d7Smrg	    esac
302472b676d7Smrg	  done
302572b676d7Smrg	  tmp_libs=
302672b676d7Smrg	  for deplib in $new_libs; do
302772b676d7Smrg	    case $deplib in
302872b676d7Smrg	    -L*)
302972b676d7Smrg	      case " $tmp_libs " in
303072b676d7Smrg	      *" $deplib "*) ;;
303172b676d7Smrg	      *) tmp_libs="$tmp_libs $deplib" ;;
303272b676d7Smrg	      esac
303372b676d7Smrg	      ;;
303472b676d7Smrg	    *) tmp_libs="$tmp_libs $deplib" ;;
303572b676d7Smrg	    esac
303672b676d7Smrg	  done
303772b676d7Smrg	  eval $var=\"$tmp_libs\"
303872b676d7Smrg	done # for var
303972b676d7Smrg      fi
304072b676d7Smrg      # Last step: remove runtime libs from dependency_libs
304172b676d7Smrg      # (they stay in deplibs)
304272b676d7Smrg      tmp_libs=
304372b676d7Smrg      for i in $dependency_libs ; do
304472b676d7Smrg	case " $predeps $postdeps $compiler_lib_search_path " in
304572b676d7Smrg	*" $i "*)
304672b676d7Smrg	  i=""
304772b676d7Smrg	  ;;
304872b676d7Smrg	esac
304972b676d7Smrg	if test -n "$i" ; then
305072b676d7Smrg	  tmp_libs="$tmp_libs $i"
305172b676d7Smrg	fi
305272b676d7Smrg      done
305372b676d7Smrg      dependency_libs=$tmp_libs
305472b676d7Smrg    done # for pass
305572b676d7Smrg    if test "$linkmode" = prog; then
305672b676d7Smrg      dlfiles="$newdlfiles"
305772b676d7Smrg      dlprefiles="$newdlprefiles"
305872b676d7Smrg    fi
305972b676d7Smrg
306072b676d7Smrg    case $linkmode in
306172b676d7Smrg    oldlib)
306272b676d7Smrg      if test -n "$deplibs"; then
306372b676d7Smrg	$echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2
306472b676d7Smrg      fi
306572b676d7Smrg
306672b676d7Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
306772b676d7Smrg	$echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
306872b676d7Smrg      fi
306972b676d7Smrg
307072b676d7Smrg      if test -n "$rpath"; then
307172b676d7Smrg	$echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2
307272b676d7Smrg      fi
307372b676d7Smrg
307472b676d7Smrg      if test -n "$xrpath"; then
307572b676d7Smrg	$echo "$modename: warning: \`-R' is ignored for archives" 1>&2
307672b676d7Smrg      fi
307772b676d7Smrg
307872b676d7Smrg      if test -n "$vinfo"; then
307972b676d7Smrg	$echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2
308072b676d7Smrg      fi
308172b676d7Smrg
308272b676d7Smrg      if test -n "$release"; then
308372b676d7Smrg	$echo "$modename: warning: \`-release' is ignored for archives" 1>&2
308472b676d7Smrg      fi
308572b676d7Smrg
308672b676d7Smrg      if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
308772b676d7Smrg	$echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2
308872b676d7Smrg      fi
308972b676d7Smrg
309072b676d7Smrg      # Now set the variables for building old libraries.
309172b676d7Smrg      build_libtool_libs=no
309272b676d7Smrg      oldlibs="$output"
309372b676d7Smrg      objs="$objs$old_deplibs"
309472b676d7Smrg      ;;
309572b676d7Smrg
309672b676d7Smrg    lib)
309772b676d7Smrg      # Make sure we only generate libraries of the form `libNAME.la'.
309872b676d7Smrg      case $outputname in
309972b676d7Smrg      lib*)
310072b676d7Smrg	name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
310172b676d7Smrg	eval shared_ext=\"$shrext_cmds\"
310272b676d7Smrg	eval libname=\"$libname_spec\"
310372b676d7Smrg	;;
310472b676d7Smrg      *)
310572b676d7Smrg	if test "$module" = no; then
310672b676d7Smrg	  $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
310772b676d7Smrg	  $echo "$help" 1>&2
310872b676d7Smrg	  exit $EXIT_FAILURE
310972b676d7Smrg	fi
311072b676d7Smrg	if test "$need_lib_prefix" != no; then
311172b676d7Smrg	  # Add the "lib" prefix for modules if required
311272b676d7Smrg	  name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
311372b676d7Smrg	  eval shared_ext=\"$shrext_cmds\"
311472b676d7Smrg	  eval libname=\"$libname_spec\"
311572b676d7Smrg	else
311672b676d7Smrg	  libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
311772b676d7Smrg	fi
311872b676d7Smrg	;;
311972b676d7Smrg      esac
312072b676d7Smrg
312172b676d7Smrg      if test -n "$objs"; then
312272b676d7Smrg	if test "$deplibs_check_method" != pass_all; then
312372b676d7Smrg	  $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1
312472b676d7Smrg	  exit $EXIT_FAILURE
312572b676d7Smrg	else
312672b676d7Smrg	  $echo
312772b676d7Smrg	  $echo "*** Warning: Linking the shared library $output against the non-libtool"
312872b676d7Smrg	  $echo "*** objects $objs is not portable!"
312972b676d7Smrg	  libobjs="$libobjs $objs"
313072b676d7Smrg	fi
313172b676d7Smrg      fi
313272b676d7Smrg
313372b676d7Smrg      if test "$dlself" != no; then
313472b676d7Smrg	$echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2
313572b676d7Smrg      fi
313672b676d7Smrg
313772b676d7Smrg      set dummy $rpath
313872b676d7Smrg      if test "$#" -gt 2; then
313972b676d7Smrg	$echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
314072b676d7Smrg      fi
314172b676d7Smrg      install_libdir="$2"
314272b676d7Smrg
314372b676d7Smrg      oldlibs=
314472b676d7Smrg      if test -z "$rpath"; then
314572b676d7Smrg	if test "$build_libtool_libs" = yes; then
314672b676d7Smrg	  # Building a libtool convenience library.
314772b676d7Smrg	  # Some compilers have problems with a `.al' extension so
314872b676d7Smrg	  # convenience libraries should have the same extension an
314972b676d7Smrg	  # archive normally would.
315072b676d7Smrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
315172b676d7Smrg	  build_libtool_libs=convenience
315272b676d7Smrg	  build_old_libs=yes
315372b676d7Smrg	fi
315472b676d7Smrg
315572b676d7Smrg	if test -n "$vinfo"; then
315672b676d7Smrg	  $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2
315772b676d7Smrg	fi
315872b676d7Smrg
315972b676d7Smrg	if test -n "$release"; then
316072b676d7Smrg	  $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2
316172b676d7Smrg	fi
316272b676d7Smrg      else
316372b676d7Smrg
316472b676d7Smrg	# Parse the version information argument.
316572b676d7Smrg	save_ifs="$IFS"; IFS=':'
316672b676d7Smrg	set dummy $vinfo 0 0 0
316772b676d7Smrg	IFS="$save_ifs"
316872b676d7Smrg
316972b676d7Smrg	if test -n "$8"; then
317072b676d7Smrg	  $echo "$modename: too many parameters to \`-version-info'" 1>&2
317172b676d7Smrg	  $echo "$help" 1>&2
317272b676d7Smrg	  exit $EXIT_FAILURE
317372b676d7Smrg	fi
317472b676d7Smrg
317572b676d7Smrg	# convert absolute version numbers to libtool ages
317672b676d7Smrg	# this retains compatibility with .la files and attempts
317772b676d7Smrg	# to make the code below a bit more comprehensible
317872b676d7Smrg
317972b676d7Smrg	case $vinfo_number in
318072b676d7Smrg	yes)
318172b676d7Smrg	  number_major="$2"
318272b676d7Smrg	  number_minor="$3"
318372b676d7Smrg	  number_revision="$4"
318472b676d7Smrg	  #
318572b676d7Smrg	  # There are really only two kinds -- those that
318672b676d7Smrg	  # use the current revision as the major version
318772b676d7Smrg	  # and those that subtract age and use age as
318872b676d7Smrg	  # a minor version.  But, then there is irix
318972b676d7Smrg	  # which has an extra 1 added just for fun
319072b676d7Smrg	  #
319172b676d7Smrg	  case $version_type in
319272b676d7Smrg	  darwin|linux|osf|windows)
319372b676d7Smrg	    current=`expr $number_major + $number_minor`
319472b676d7Smrg	    age="$number_minor"
319572b676d7Smrg	    revision="$number_revision"
319672b676d7Smrg	    ;;
319772b676d7Smrg	  freebsd-aout|freebsd-elf|sunos)
319872b676d7Smrg	    current="$number_major"
319972b676d7Smrg	    revision="$number_minor"
320072b676d7Smrg	    age="0"
320172b676d7Smrg	    ;;
320272b676d7Smrg	  irix|nonstopux)
320372b676d7Smrg	    current=`expr $number_major + $number_minor - 1`
320472b676d7Smrg	    age="$number_minor"
320572b676d7Smrg	    revision="$number_minor"
320672b676d7Smrg	    ;;
320772b676d7Smrg	  *)
320872b676d7Smrg	    $echo "$modename: unknown library version type \`$version_type'" 1>&2
320972b676d7Smrg	    $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
321072b676d7Smrg	    exit $EXIT_FAILURE
321172b676d7Smrg	    ;;
321272b676d7Smrg	  esac
321372b676d7Smrg	  ;;
321472b676d7Smrg	no)
321572b676d7Smrg	  current="$2"
321672b676d7Smrg	  revision="$3"
321772b676d7Smrg	  age="$4"
321872b676d7Smrg	  ;;
321972b676d7Smrg	esac
322072b676d7Smrg
322172b676d7Smrg	# Check that each of the things are valid numbers.
322272b676d7Smrg	case $current in
322372b676d7Smrg	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]) ;;
322472b676d7Smrg	*)
322572b676d7Smrg	  $echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2
322672b676d7Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
322772b676d7Smrg	  exit $EXIT_FAILURE
322872b676d7Smrg	  ;;
322972b676d7Smrg	esac
323072b676d7Smrg
323172b676d7Smrg	case $revision in
323272b676d7Smrg	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]) ;;
323372b676d7Smrg	*)
323472b676d7Smrg	  $echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2
323572b676d7Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
323672b676d7Smrg	  exit $EXIT_FAILURE
323772b676d7Smrg	  ;;
323872b676d7Smrg	esac
323972b676d7Smrg
324072b676d7Smrg	case $age in
324172b676d7Smrg	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]) ;;
324272b676d7Smrg	*)
324372b676d7Smrg	  $echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2
324472b676d7Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
324572b676d7Smrg	  exit $EXIT_FAILURE
324672b676d7Smrg	  ;;
324772b676d7Smrg	esac
324872b676d7Smrg
324972b676d7Smrg	if test "$age" -gt "$current"; then
325072b676d7Smrg	  $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
325172b676d7Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
325272b676d7Smrg	  exit $EXIT_FAILURE
325372b676d7Smrg	fi
325472b676d7Smrg
325572b676d7Smrg	# Calculate the version variables.
325672b676d7Smrg	major=
325772b676d7Smrg	versuffix=
325872b676d7Smrg	verstring=
325972b676d7Smrg	case $version_type in
326072b676d7Smrg	none) ;;
326172b676d7Smrg
326272b676d7Smrg	darwin)
326372b676d7Smrg	  # Like Linux, but with the current version available in
326472b676d7Smrg	  # verstring for coding it into the library header
326572b676d7Smrg	  major=.`expr $current - $age`
326672b676d7Smrg	  versuffix="$major.$age.$revision"
326772b676d7Smrg	  # Darwin ld doesn't like 0 for these options...
326872b676d7Smrg	  minor_current=`expr $current + 1`
326972b676d7Smrg	  verstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
327072b676d7Smrg	  ;;
327172b676d7Smrg
327272b676d7Smrg	freebsd-aout)
327372b676d7Smrg	  major=".$current"
327472b676d7Smrg	  versuffix=".$current.$revision";
327572b676d7Smrg	  ;;
327672b676d7Smrg
327772b676d7Smrg	freebsd-elf)
327872b676d7Smrg	  major=".$current"
327972b676d7Smrg	  versuffix=".$current";
328072b676d7Smrg	  ;;
328172b676d7Smrg
328272b676d7Smrg	irix | nonstopux)
328372b676d7Smrg	  major=`expr $current - $age + 1`
328472b676d7Smrg
328572b676d7Smrg	  case $version_type in
328672b676d7Smrg	    nonstopux) verstring_prefix=nonstopux ;;
328772b676d7Smrg	    *)         verstring_prefix=sgi ;;
328872b676d7Smrg	  esac
328972b676d7Smrg	  verstring="$verstring_prefix$major.$revision"
329072b676d7Smrg
329172b676d7Smrg	  # Add in all the interfaces that we are compatible with.
329272b676d7Smrg	  loop=$revision
329372b676d7Smrg	  while test "$loop" -ne 0; do
329472b676d7Smrg	    iface=`expr $revision - $loop`
329572b676d7Smrg	    loop=`expr $loop - 1`
329672b676d7Smrg	    verstring="$verstring_prefix$major.$iface:$verstring"
329772b676d7Smrg	  done
329872b676d7Smrg
329972b676d7Smrg	  # Before this point, $major must not contain `.'.
330072b676d7Smrg	  major=.$major
330172b676d7Smrg	  versuffix="$major.$revision"
330272b676d7Smrg	  ;;
330372b676d7Smrg
330472b676d7Smrg	linux)
330572b676d7Smrg	  major=.`expr $current - $age`
330672b676d7Smrg	  versuffix="$major.$age.$revision"
330772b676d7Smrg	  ;;
330872b676d7Smrg
330972b676d7Smrg	osf)
331072b676d7Smrg	  major=.`expr $current - $age`
331172b676d7Smrg	  versuffix=".$current.$age.$revision"
331272b676d7Smrg	  verstring="$current.$age.$revision"
331372b676d7Smrg
331472b676d7Smrg	  # Add in all the interfaces that we are compatible with.
331572b676d7Smrg	  loop=$age
331672b676d7Smrg	  while test "$loop" -ne 0; do
331772b676d7Smrg	    iface=`expr $current - $loop`
331872b676d7Smrg	    loop=`expr $loop - 1`
331972b676d7Smrg	    verstring="$verstring:${iface}.0"
332072b676d7Smrg	  done
332172b676d7Smrg
332272b676d7Smrg	  # Make executables depend on our current version.
332372b676d7Smrg	  verstring="$verstring:${current}.0"
332472b676d7Smrg	  ;;
332572b676d7Smrg
332672b676d7Smrg	sunos)
332772b676d7Smrg	  major=".$current"
332872b676d7Smrg	  versuffix=".$current.$revision"
332972b676d7Smrg	  ;;
333072b676d7Smrg
333172b676d7Smrg	windows)
333272b676d7Smrg	  # Use '-' rather than '.', since we only want one
333372b676d7Smrg	  # extension on DOS 8.3 filesystems.
333472b676d7Smrg	  major=`expr $current - $age`
333572b676d7Smrg	  versuffix="-$major"
333672b676d7Smrg	  ;;
333772b676d7Smrg
333872b676d7Smrg	*)
333972b676d7Smrg	  $echo "$modename: unknown library version type \`$version_type'" 1>&2
334072b676d7Smrg	  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
334172b676d7Smrg	  exit $EXIT_FAILURE
334272b676d7Smrg	  ;;
334372b676d7Smrg	esac
334472b676d7Smrg
334572b676d7Smrg	# Clear the version info if we defaulted, and they specified a release.
334672b676d7Smrg	if test -z "$vinfo" && test -n "$release"; then
334772b676d7Smrg	  major=
334872b676d7Smrg	  case $version_type in
334972b676d7Smrg	  darwin)
335072b676d7Smrg	    # we can't check for "0.0" in archive_cmds due to quoting
335172b676d7Smrg	    # problems, so we reset it completely
335272b676d7Smrg	    verstring=
335372b676d7Smrg	    ;;
335472b676d7Smrg	  *)
335572b676d7Smrg	    verstring="0.0"
335672b676d7Smrg	    ;;
335772b676d7Smrg	  esac
335872b676d7Smrg	  if test "$need_version" = no; then
335972b676d7Smrg	    versuffix=
336072b676d7Smrg	  else
336172b676d7Smrg	    versuffix=".0.0"
336272b676d7Smrg	  fi
336372b676d7Smrg	fi
336472b676d7Smrg
336572b676d7Smrg	# Remove version info from name if versioning should be avoided
336672b676d7Smrg	if test "$avoid_version" = yes && test "$need_version" = no; then
336772b676d7Smrg	  major=
336872b676d7Smrg	  versuffix=
336972b676d7Smrg	  verstring=""
337072b676d7Smrg	fi
337172b676d7Smrg
337272b676d7Smrg	# Check to see if the archive will have undefined symbols.
337372b676d7Smrg	if test "$allow_undefined" = yes; then
337472b676d7Smrg	  if test "$allow_undefined_flag" = unsupported; then
337572b676d7Smrg	    $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2
337672b676d7Smrg	    build_libtool_libs=no
337772b676d7Smrg	    build_old_libs=yes
337872b676d7Smrg	  fi
337972b676d7Smrg	else
338072b676d7Smrg	  # Don't allow undefined symbols.
338172b676d7Smrg	  allow_undefined_flag="$no_undefined_flag"
338272b676d7Smrg	fi
338372b676d7Smrg      fi
338472b676d7Smrg
338572b676d7Smrg      if test "$mode" != relink; then
338672b676d7Smrg	# Remove our outputs, but don't remove object files since they
338772b676d7Smrg	# may have been created when compiling PIC objects.
338872b676d7Smrg	removelist=
338972b676d7Smrg	tempremovelist=`$echo "$output_objdir/*"`
339072b676d7Smrg	for p in $tempremovelist; do
339172b676d7Smrg	  case $p in
339272b676d7Smrg	    *.$objext)
339372b676d7Smrg	       ;;
339472b676d7Smrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
339572b676d7Smrg	       if test "X$precious_files_regex" != "X"; then
339672b676d7Smrg	         if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
339772b676d7Smrg	         then
339872b676d7Smrg		   continue
339972b676d7Smrg		 fi
340072b676d7Smrg	       fi
340172b676d7Smrg	       removelist="$removelist $p"
340272b676d7Smrg	       ;;
340372b676d7Smrg	    *) ;;
340472b676d7Smrg	  esac
340572b676d7Smrg	done
340672b676d7Smrg	if test -n "$removelist"; then
340772b676d7Smrg	  $show "${rm}r $removelist"
340872b676d7Smrg	  $run ${rm}r $removelist
340972b676d7Smrg	fi
341072b676d7Smrg      fi
341172b676d7Smrg
341272b676d7Smrg      # Now set the variables for building old libraries.
341372b676d7Smrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
341472b676d7Smrg	oldlibs="$oldlibs $output_objdir/$libname.$libext"
341572b676d7Smrg
341672b676d7Smrg	# Transform .lo files to .o files.
341772b676d7Smrg	oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
341872b676d7Smrg      fi
341972b676d7Smrg
342072b676d7Smrg      # Eliminate all temporary directories.
342172b676d7Smrg      for path in $notinst_path; do
342272b676d7Smrg	lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"`
342372b676d7Smrg	deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"`
342472b676d7Smrg	dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"`
342572b676d7Smrg      done
342672b676d7Smrg
342772b676d7Smrg      if test -n "$xrpath"; then
342872b676d7Smrg	# If the user specified any rpath flags, then add them.
342972b676d7Smrg	temp_xrpath=
343072b676d7Smrg	for libdir in $xrpath; do
343172b676d7Smrg	  temp_xrpath="$temp_xrpath -R$libdir"
343272b676d7Smrg	  case "$finalize_rpath " in
343372b676d7Smrg	  *" $libdir "*) ;;
343472b676d7Smrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
343572b676d7Smrg	  esac
343672b676d7Smrg	done
343772b676d7Smrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
343872b676d7Smrg	  dependency_libs="$temp_xrpath $dependency_libs"
343972b676d7Smrg	fi
344072b676d7Smrg      fi
344172b676d7Smrg
344272b676d7Smrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
344372b676d7Smrg      old_dlfiles="$dlfiles"
344472b676d7Smrg      dlfiles=
344572b676d7Smrg      for lib in $old_dlfiles; do
344672b676d7Smrg	case " $dlprefiles $dlfiles " in
344772b676d7Smrg	*" $lib "*) ;;
344872b676d7Smrg	*) dlfiles="$dlfiles $lib" ;;
344972b676d7Smrg	esac
345072b676d7Smrg      done
345172b676d7Smrg
345272b676d7Smrg      # Make sure dlprefiles contains only unique files
345372b676d7Smrg      old_dlprefiles="$dlprefiles"
345472b676d7Smrg      dlprefiles=
345572b676d7Smrg      for lib in $old_dlprefiles; do
345672b676d7Smrg	case "$dlprefiles " in
345772b676d7Smrg	*" $lib "*) ;;
345872b676d7Smrg	*) dlprefiles="$dlprefiles $lib" ;;
345972b676d7Smrg	esac
346072b676d7Smrg      done
346172b676d7Smrg
346272b676d7Smrg      if test "$build_libtool_libs" = yes; then
346372b676d7Smrg	if test -n "$rpath"; then
346472b676d7Smrg	  case $host in
346572b676d7Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*)
346672b676d7Smrg	    # these systems don't actually have a c library (as such)!
346772b676d7Smrg	    ;;
346872b676d7Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
346972b676d7Smrg	    # Rhapsody C library is in the System framework
347072b676d7Smrg	    deplibs="$deplibs -framework System"
347172b676d7Smrg	    ;;
347272b676d7Smrg	  *-*-netbsd*)
347372b676d7Smrg	    # Don't link with libc until the a.out ld.so is fixed.
347472b676d7Smrg	    ;;
347572b676d7Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
347672b676d7Smrg	    # Do not include libc due to us having libc/libc_r.
347772b676d7Smrg	    ;;
347872b676d7Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
347972b676d7Smrg	    # Causes problems with __ctype
348072b676d7Smrg	    ;;
348172b676d7Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
348272b676d7Smrg	    # Compiler inserts libc in the correct place for threads to work
348372b676d7Smrg	    ;;
348472b676d7Smrg 	  *)
348572b676d7Smrg	    # Add libc to deplibs on all other systems if necessary.
348672b676d7Smrg	    if test "$build_libtool_need_lc" = "yes"; then
348772b676d7Smrg	      deplibs="$deplibs -lc"
348872b676d7Smrg	    fi
348972b676d7Smrg	    ;;
349072b676d7Smrg	  esac
349172b676d7Smrg	fi
349272b676d7Smrg
349372b676d7Smrg	# Transform deplibs into only deplibs that can be linked in shared.
349472b676d7Smrg	name_save=$name
349572b676d7Smrg	libname_save=$libname
349672b676d7Smrg	release_save=$release
349772b676d7Smrg	versuffix_save=$versuffix
349872b676d7Smrg	major_save=$major
349972b676d7Smrg	# I'm not sure if I'm treating the release correctly.  I think
350072b676d7Smrg	# release should show up in the -l (ie -lgmp5) so we don't want to
350172b676d7Smrg	# add it in twice.  Is that correct?
350272b676d7Smrg	release=""
350372b676d7Smrg	versuffix=""
350472b676d7Smrg	major=""
350572b676d7Smrg	newdeplibs=
350672b676d7Smrg	droppeddeps=no
350772b676d7Smrg	case $deplibs_check_method in
350872b676d7Smrg	pass_all)
350972b676d7Smrg	  # Don't check for shared/static.  Everything works.
351072b676d7Smrg	  # This might be a little naive.  We might want to check
351172b676d7Smrg	  # whether the library exists or not.  But this is on
351272b676d7Smrg	  # osf3 & osf4 and I'm not really sure... Just
351372b676d7Smrg	  # implementing what was already the behavior.
351472b676d7Smrg	  newdeplibs=$deplibs
351572b676d7Smrg	  ;;
351672b676d7Smrg	test_compile)
351772b676d7Smrg	  # This code stresses the "libraries are programs" paradigm to its
351872b676d7Smrg	  # limits. Maybe even breaks it.  We compile a program, linking it
351972b676d7Smrg	  # against the deplibs as a proxy for the library.  Then we can check
352072b676d7Smrg	  # whether they linked in statically or dynamically with ldd.
352172b676d7Smrg	  $rm conftest.c
352272b676d7Smrg	  cat > conftest.c <<EOF
352372b676d7Smrg	  int main() { return 0; }
352472b676d7SmrgEOF
352572b676d7Smrg	  $rm conftest
352672b676d7Smrg	  $LTCC $LTCFLAGS -o conftest conftest.c $deplibs
352772b676d7Smrg	  if test "$?" -eq 0 ; then
352872b676d7Smrg	    ldd_output=`ldd conftest`
352972b676d7Smrg	    for i in $deplibs; do
353072b676d7Smrg	      name=`expr $i : '-l\(.*\)'`
353172b676d7Smrg	      # If $name is empty we are operating on a -L argument.
353272b676d7Smrg              if test "$name" != "" && test "$name" -ne "0"; then
353372b676d7Smrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
353472b676d7Smrg		  case " $predeps $postdeps " in
353572b676d7Smrg		  *" $i "*)
353672b676d7Smrg		    newdeplibs="$newdeplibs $i"
353772b676d7Smrg		    i=""
353872b676d7Smrg		    ;;
353972b676d7Smrg		  esac
354072b676d7Smrg	        fi
354172b676d7Smrg		if test -n "$i" ; then
354272b676d7Smrg		  libname=`eval \\$echo \"$libname_spec\"`
354372b676d7Smrg		  deplib_matches=`eval \\$echo \"$library_names_spec\"`
354472b676d7Smrg		  set dummy $deplib_matches
354572b676d7Smrg		  deplib_match=$2
354672b676d7Smrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
354772b676d7Smrg		    newdeplibs="$newdeplibs $i"
354872b676d7Smrg		  else
354972b676d7Smrg		    droppeddeps=yes
355072b676d7Smrg		    $echo
355172b676d7Smrg		    $echo "*** Warning: dynamic linker does not accept needed library $i."
355272b676d7Smrg		    $echo "*** I have the capability to make that library automatically link in when"
355372b676d7Smrg		    $echo "*** you link to this library.  But I can only do this if you have a"
355472b676d7Smrg		    $echo "*** shared version of the library, which I believe you do not have"
355572b676d7Smrg		    $echo "*** because a test_compile did reveal that the linker did not use it for"
355672b676d7Smrg		    $echo "*** its dynamic dependency list that programs get resolved with at runtime."
355772b676d7Smrg		  fi
355872b676d7Smrg		fi
355972b676d7Smrg	      else
356072b676d7Smrg		newdeplibs="$newdeplibs $i"
356172b676d7Smrg	      fi
356272b676d7Smrg	    done
356372b676d7Smrg	  else
356472b676d7Smrg	    # Error occurred in the first compile.  Let's try to salvage
356572b676d7Smrg	    # the situation: Compile a separate program for each library.
356672b676d7Smrg	    for i in $deplibs; do
356772b676d7Smrg	      name=`expr $i : '-l\(.*\)'`
356872b676d7Smrg	      # If $name is empty we are operating on a -L argument.
356972b676d7Smrg              if test "$name" != "" && test "$name" != "0"; then
357072b676d7Smrg		$rm conftest
357172b676d7Smrg		$LTCC $LTCFLAGS -o conftest conftest.c $i
357272b676d7Smrg		# Did it work?
357372b676d7Smrg		if test "$?" -eq 0 ; then
357472b676d7Smrg		  ldd_output=`ldd conftest`
357572b676d7Smrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
357672b676d7Smrg		    case " $predeps $postdeps " in
357772b676d7Smrg		    *" $i "*)
357872b676d7Smrg		      newdeplibs="$newdeplibs $i"
357972b676d7Smrg		      i=""
358072b676d7Smrg		      ;;
358172b676d7Smrg		    esac
358272b676d7Smrg		  fi
358372b676d7Smrg		  if test -n "$i" ; then
358472b676d7Smrg		    libname=`eval \\$echo \"$libname_spec\"`
358572b676d7Smrg		    deplib_matches=`eval \\$echo \"$library_names_spec\"`
358672b676d7Smrg		    set dummy $deplib_matches
358772b676d7Smrg		    deplib_match=$2
358872b676d7Smrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
358972b676d7Smrg		      newdeplibs="$newdeplibs $i"
359072b676d7Smrg		    else
359172b676d7Smrg		      droppeddeps=yes
359272b676d7Smrg		      $echo
359372b676d7Smrg		      $echo "*** Warning: dynamic linker does not accept needed library $i."
359472b676d7Smrg		      $echo "*** I have the capability to make that library automatically link in when"
359572b676d7Smrg		      $echo "*** you link to this library.  But I can only do this if you have a"
359672b676d7Smrg		      $echo "*** shared version of the library, which you do not appear to have"
359772b676d7Smrg		      $echo "*** because a test_compile did reveal that the linker did not use this one"
359872b676d7Smrg		      $echo "*** as a dynamic dependency that programs can get resolved with at runtime."
359972b676d7Smrg		    fi
360072b676d7Smrg		  fi
360172b676d7Smrg		else
360272b676d7Smrg		  droppeddeps=yes
360372b676d7Smrg		  $echo
360472b676d7Smrg		  $echo "*** Warning!  Library $i is needed by this library but I was not able to"
360572b676d7Smrg		  $echo "***  make it link in!  You will probably need to install it or some"
360672b676d7Smrg		  $echo "*** library that it depends on before this library will be fully"
360772b676d7Smrg		  $echo "*** functional.  Installing it before continuing would be even better."
360872b676d7Smrg		fi
360972b676d7Smrg	      else
361072b676d7Smrg		newdeplibs="$newdeplibs $i"
361172b676d7Smrg	      fi
361272b676d7Smrg	    done
361372b676d7Smrg	  fi
361472b676d7Smrg	  ;;
361572b676d7Smrg	file_magic*)
361672b676d7Smrg	  set dummy $deplibs_check_method
361772b676d7Smrg	  file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
361872b676d7Smrg	  for a_deplib in $deplibs; do
361972b676d7Smrg	    name=`expr $a_deplib : '-l\(.*\)'`
362072b676d7Smrg	    # If $name is empty we are operating on a -L argument.
362172b676d7Smrg            if test "$name" != "" && test  "$name" != "0"; then
362272b676d7Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
362372b676d7Smrg		case " $predeps $postdeps " in
362472b676d7Smrg		*" $a_deplib "*)
362572b676d7Smrg		  newdeplibs="$newdeplibs $a_deplib"
362672b676d7Smrg		  a_deplib=""
362772b676d7Smrg		  ;;
362872b676d7Smrg		esac
362972b676d7Smrg	      fi
363072b676d7Smrg	      if test -n "$a_deplib" ; then
363172b676d7Smrg		libname=`eval \\$echo \"$libname_spec\"`
363272b676d7Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
363372b676d7Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
363472b676d7Smrg		  for potent_lib in $potential_libs; do
363572b676d7Smrg		      # Follow soft links.
363672b676d7Smrg		      if ls -lLd "$potent_lib" 2>/dev/null \
363772b676d7Smrg			 | grep " -> " >/dev/null; then
363872b676d7Smrg			continue
363972b676d7Smrg		      fi
364072b676d7Smrg		      # The statement above tries to avoid entering an
364172b676d7Smrg		      # endless loop below, in case of cyclic links.
364272b676d7Smrg		      # We might still enter an endless loop, since a link
364372b676d7Smrg		      # loop can be closed while we follow links,
364472b676d7Smrg		      # but so what?
364572b676d7Smrg		      potlib="$potent_lib"
364672b676d7Smrg		      while test -h "$potlib" 2>/dev/null; do
364772b676d7Smrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
364872b676d7Smrg			case $potliblink in
364972b676d7Smrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
365072b676d7Smrg			*) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
365172b676d7Smrg			esac
365272b676d7Smrg		      done
365372b676d7Smrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
365472b676d7Smrg			 | ${SED} 10q \
365572b676d7Smrg			 | $EGREP "$file_magic_regex" > /dev/null; then
365672b676d7Smrg			newdeplibs="$newdeplibs $a_deplib"
365772b676d7Smrg			a_deplib=""
365872b676d7Smrg			break 2
365972b676d7Smrg		      fi
366072b676d7Smrg		  done
366172b676d7Smrg		done
366272b676d7Smrg	      fi
366372b676d7Smrg	      if test -n "$a_deplib" ; then
366472b676d7Smrg		droppeddeps=yes
366572b676d7Smrg		$echo
366672b676d7Smrg		$echo "*** Warning: linker path does not have real file for library $a_deplib."
366772b676d7Smrg		$echo "*** I have the capability to make that library automatically link in when"
366872b676d7Smrg		$echo "*** you link to this library.  But I can only do this if you have a"
366972b676d7Smrg		$echo "*** shared version of the library, which you do not appear to have"
367072b676d7Smrg		$echo "*** because I did check the linker path looking for a file starting"
367172b676d7Smrg		if test -z "$potlib" ; then
367272b676d7Smrg		  $echo "*** with $libname but no candidates were found. (...for file magic test)"
367372b676d7Smrg		else
367472b676d7Smrg		  $echo "*** with $libname and none of the candidates passed a file format test"
367572b676d7Smrg		  $echo "*** using a file magic. Last file checked: $potlib"
367672b676d7Smrg		fi
367772b676d7Smrg	      fi
367872b676d7Smrg	    else
367972b676d7Smrg	      # Add a -L argument.
368072b676d7Smrg	      newdeplibs="$newdeplibs $a_deplib"
368172b676d7Smrg	    fi
368272b676d7Smrg	  done # Gone through all deplibs.
368372b676d7Smrg	  ;;
368472b676d7Smrg	match_pattern*)
368572b676d7Smrg	  set dummy $deplibs_check_method
368672b676d7Smrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
368772b676d7Smrg	  for a_deplib in $deplibs; do
368872b676d7Smrg	    name=`expr $a_deplib : '-l\(.*\)'`
368972b676d7Smrg	    # If $name is empty we are operating on a -L argument.
369072b676d7Smrg	    if test -n "$name" && test "$name" != "0"; then
369172b676d7Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
369272b676d7Smrg		case " $predeps $postdeps " in
369372b676d7Smrg		*" $a_deplib "*)
369472b676d7Smrg		  newdeplibs="$newdeplibs $a_deplib"
369572b676d7Smrg		  a_deplib=""
369672b676d7Smrg		  ;;
369772b676d7Smrg		esac
369872b676d7Smrg	      fi
369972b676d7Smrg	      if test -n "$a_deplib" ; then
370072b676d7Smrg		libname=`eval \\$echo \"$libname_spec\"`
370172b676d7Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
370272b676d7Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
370372b676d7Smrg		  for potent_lib in $potential_libs; do
370472b676d7Smrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
370572b676d7Smrg		    if eval $echo \"$potent_lib\" 2>/dev/null \
370672b676d7Smrg		        | ${SED} 10q \
370772b676d7Smrg		        | $EGREP "$match_pattern_regex" > /dev/null; then
370872b676d7Smrg		      newdeplibs="$newdeplibs $a_deplib"
370972b676d7Smrg		      a_deplib=""
371072b676d7Smrg		      break 2
371172b676d7Smrg		    fi
371272b676d7Smrg		  done
371372b676d7Smrg		done
371472b676d7Smrg	      fi
371572b676d7Smrg	      if test -n "$a_deplib" ; then
371672b676d7Smrg		droppeddeps=yes
371772b676d7Smrg		$echo
371872b676d7Smrg		$echo "*** Warning: linker path does not have real file for library $a_deplib."
371972b676d7Smrg		$echo "*** I have the capability to make that library automatically link in when"
372072b676d7Smrg		$echo "*** you link to this library.  But I can only do this if you have a"
372172b676d7Smrg		$echo "*** shared version of the library, which you do not appear to have"
372272b676d7Smrg		$echo "*** because I did check the linker path looking for a file starting"
372372b676d7Smrg		if test -z "$potlib" ; then
372472b676d7Smrg		  $echo "*** with $libname but no candidates were found. (...for regex pattern test)"
372572b676d7Smrg		else
372672b676d7Smrg		  $echo "*** with $libname and none of the candidates passed a file format test"
372772b676d7Smrg		  $echo "*** using a regex pattern. Last file checked: $potlib"
372872b676d7Smrg		fi
372972b676d7Smrg	      fi
373072b676d7Smrg	    else
373172b676d7Smrg	      # Add a -L argument.
373272b676d7Smrg	      newdeplibs="$newdeplibs $a_deplib"
373372b676d7Smrg	    fi
373472b676d7Smrg	  done # Gone through all deplibs.
373572b676d7Smrg	  ;;
373672b676d7Smrg	none | unknown | *)
373772b676d7Smrg	  newdeplibs=""
373872b676d7Smrg	  tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
373972b676d7Smrg	    -e 's/ -[LR][^ ]*//g'`
374072b676d7Smrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
374172b676d7Smrg	    for i in $predeps $postdeps ; do
374272b676d7Smrg	      # can't use Xsed below, because $i might contain '/'
374372b676d7Smrg	      tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"`
374472b676d7Smrg	    done
374572b676d7Smrg	  fi
374672b676d7Smrg	  if $echo "X $tmp_deplibs" | $Xsed -e 's/[ 	]//g' \
374772b676d7Smrg	    | grep . >/dev/null; then
374872b676d7Smrg	    $echo
374972b676d7Smrg	    if test "X$deplibs_check_method" = "Xnone"; then
375072b676d7Smrg	      $echo "*** Warning: inter-library dependencies are not supported in this platform."
375172b676d7Smrg	    else
375272b676d7Smrg	      $echo "*** Warning: inter-library dependencies are not known to be supported."
375372b676d7Smrg	    fi
375472b676d7Smrg	    $echo "*** All declared inter-library dependencies are being dropped."
375572b676d7Smrg	    droppeddeps=yes
375672b676d7Smrg	  fi
375772b676d7Smrg	  ;;
375872b676d7Smrg	esac
375972b676d7Smrg	versuffix=$versuffix_save
376072b676d7Smrg	major=$major_save
376172b676d7Smrg	release=$release_save
376272b676d7Smrg	libname=$libname_save
376372b676d7Smrg	name=$name_save
376472b676d7Smrg
376572b676d7Smrg	case $host in
376672b676d7Smrg	*-*-rhapsody* | *-*-darwin1.[012])
376772b676d7Smrg	  # On Rhapsody replace the C library is the System framework
376872b676d7Smrg	  newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'`
376972b676d7Smrg	  ;;
377072b676d7Smrg	esac
377172b676d7Smrg
377272b676d7Smrg	if test "$droppeddeps" = yes; then
377372b676d7Smrg	  if test "$module" = yes; then
377472b676d7Smrg	    $echo
377572b676d7Smrg	    $echo "*** Warning: libtool could not satisfy all declared inter-library"
377672b676d7Smrg	    $echo "*** dependencies of module $libname.  Therefore, libtool will create"
377772b676d7Smrg	    $echo "*** a static module, that should work as long as the dlopening"
377872b676d7Smrg	    $echo "*** application is linked with the -dlopen flag."
377972b676d7Smrg	    if test -z "$global_symbol_pipe"; then
378072b676d7Smrg	      $echo
378172b676d7Smrg	      $echo "*** However, this would only work if libtool was able to extract symbol"
378272b676d7Smrg	      $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
378372b676d7Smrg	      $echo "*** not find such a program.  So, this module is probably useless."
378472b676d7Smrg	      $echo "*** \`nm' from GNU binutils and a full rebuild may help."
378572b676d7Smrg	    fi
378672b676d7Smrg	    if test "$build_old_libs" = no; then
378772b676d7Smrg	      oldlibs="$output_objdir/$libname.$libext"
378872b676d7Smrg	      build_libtool_libs=module
378972b676d7Smrg	      build_old_libs=yes
379072b676d7Smrg	    else
379172b676d7Smrg	      build_libtool_libs=no
379272b676d7Smrg	    fi
379372b676d7Smrg	  else
379472b676d7Smrg	    $echo "*** The inter-library dependencies that have been dropped here will be"
379572b676d7Smrg	    $echo "*** automatically added whenever a program is linked with this library"
379672b676d7Smrg	    $echo "*** or is declared to -dlopen it."
379772b676d7Smrg
379872b676d7Smrg	    if test "$allow_undefined" = no; then
379972b676d7Smrg	      $echo
380072b676d7Smrg	      $echo "*** Since this library must not contain undefined symbols,"
380172b676d7Smrg	      $echo "*** because either the platform does not support them or"
380272b676d7Smrg	      $echo "*** it was explicitly requested with -no-undefined,"
380372b676d7Smrg	      $echo "*** libtool will only create a static version of it."
380472b676d7Smrg	      if test "$build_old_libs" = no; then
380572b676d7Smrg		oldlibs="$output_objdir/$libname.$libext"
380672b676d7Smrg		build_libtool_libs=module
380772b676d7Smrg		build_old_libs=yes
380872b676d7Smrg	      else
380972b676d7Smrg		build_libtool_libs=no
381072b676d7Smrg	      fi
381172b676d7Smrg	    fi
381272b676d7Smrg	  fi
381372b676d7Smrg	fi
381472b676d7Smrg	# Done checking deplibs!
381572b676d7Smrg	deplibs=$newdeplibs
381672b676d7Smrg      fi
381772b676d7Smrg
381872b676d7Smrg
381972b676d7Smrg      # move library search paths that coincide with paths to not yet
382072b676d7Smrg      # installed libraries to the beginning of the library search list
382172b676d7Smrg      new_libs=
382272b676d7Smrg      for path in $notinst_path; do
382372b676d7Smrg	case " $new_libs " in
382472b676d7Smrg	*" -L$path/$objdir "*) ;;
382572b676d7Smrg	*)
382672b676d7Smrg	  case " $deplibs " in
382772b676d7Smrg	  *" -L$path/$objdir "*)
382872b676d7Smrg	    new_libs="$new_libs -L$path/$objdir" ;;
382972b676d7Smrg	  esac
383072b676d7Smrg	  ;;
383172b676d7Smrg	esac
383272b676d7Smrg      done
383372b676d7Smrg      for deplib in $deplibs; do
383472b676d7Smrg	case $deplib in
383572b676d7Smrg	-L*)
383672b676d7Smrg	  case " $new_libs " in
383772b676d7Smrg	  *" $deplib "*) ;;
383872b676d7Smrg	  *) new_libs="$new_libs $deplib" ;;
383972b676d7Smrg	  esac
384072b676d7Smrg	  ;;
384172b676d7Smrg	*) new_libs="$new_libs $deplib" ;;
384272b676d7Smrg	esac
384372b676d7Smrg      done
384472b676d7Smrg      deplibs="$new_libs"
384572b676d7Smrg
384672b676d7Smrg
384772b676d7Smrg      # All the library-specific variables (install_libdir is set above).
384872b676d7Smrg      library_names=
384972b676d7Smrg      old_library=
385072b676d7Smrg      dlname=
385172b676d7Smrg
385272b676d7Smrg      # Test again, we may have decided not to build it any more
385372b676d7Smrg      if test "$build_libtool_libs" = yes; then
385472b676d7Smrg	if test "$hardcode_into_libs" = yes; then
385572b676d7Smrg	  # Hardcode the library paths
385672b676d7Smrg	  hardcode_libdirs=
385772b676d7Smrg	  dep_rpath=
385872b676d7Smrg	  rpath="$finalize_rpath"
385972b676d7Smrg	  test "$mode" != relink && rpath="$compile_rpath$rpath"
386072b676d7Smrg	  for libdir in $rpath; do
386172b676d7Smrg	    if test -n "$hardcode_libdir_flag_spec"; then
386272b676d7Smrg	      if test -n "$hardcode_libdir_separator"; then
386372b676d7Smrg		if test -z "$hardcode_libdirs"; then
386472b676d7Smrg		  hardcode_libdirs="$libdir"
386572b676d7Smrg		else
386672b676d7Smrg		  # Just accumulate the unique libdirs.
386772b676d7Smrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
386872b676d7Smrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
386972b676d7Smrg		    ;;
387072b676d7Smrg		  *)
387172b676d7Smrg		    hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
387272b676d7Smrg		    ;;
387372b676d7Smrg		  esac
387472b676d7Smrg		fi
387572b676d7Smrg	      else
387672b676d7Smrg		eval flag=\"$hardcode_libdir_flag_spec\"
387772b676d7Smrg		dep_rpath="$dep_rpath $flag"
387872b676d7Smrg	      fi
387972b676d7Smrg	    elif test -n "$runpath_var"; then
388072b676d7Smrg	      case "$perm_rpath " in
388172b676d7Smrg	      *" $libdir "*) ;;
388272b676d7Smrg	      *) perm_rpath="$perm_rpath $libdir" ;;
388372b676d7Smrg	      esac
388472b676d7Smrg	    fi
388572b676d7Smrg	  done
388672b676d7Smrg	  # Substitute the hardcoded libdirs into the rpath.
388772b676d7Smrg	  if test -n "$hardcode_libdir_separator" &&
388872b676d7Smrg	     test -n "$hardcode_libdirs"; then
388972b676d7Smrg	    libdir="$hardcode_libdirs"
389072b676d7Smrg	    if test -n "$hardcode_libdir_flag_spec_ld"; then
389172b676d7Smrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
389272b676d7Smrg	    else
389372b676d7Smrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
389472b676d7Smrg	    fi
389572b676d7Smrg	  fi
389672b676d7Smrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
389772b676d7Smrg	    # We should set the runpath_var.
389872b676d7Smrg	    rpath=
389972b676d7Smrg	    for dir in $perm_rpath; do
390072b676d7Smrg	      rpath="$rpath$dir:"
390172b676d7Smrg	    done
390272b676d7Smrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
390372b676d7Smrg	  fi
390472b676d7Smrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
390572b676d7Smrg	fi
390672b676d7Smrg
390772b676d7Smrg	shlibpath="$finalize_shlibpath"
390872b676d7Smrg	test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
390972b676d7Smrg	if test -n "$shlibpath"; then
391072b676d7Smrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
391172b676d7Smrg	fi
391272b676d7Smrg
391372b676d7Smrg	# Get the real and link names of the library.
391472b676d7Smrg	eval shared_ext=\"$shrext_cmds\"
391572b676d7Smrg	eval library_names=\"$library_names_spec\"
391672b676d7Smrg	set dummy $library_names
391772b676d7Smrg	realname="$2"
391872b676d7Smrg	shift; shift
391972b676d7Smrg
392072b676d7Smrg	if test -n "$soname_spec"; then
392172b676d7Smrg	  eval soname=\"$soname_spec\"
392272b676d7Smrg	else
392372b676d7Smrg	  soname="$realname"
392472b676d7Smrg	fi
392572b676d7Smrg	if test -z "$dlname"; then
392672b676d7Smrg	  dlname=$soname
392772b676d7Smrg	fi
392872b676d7Smrg
392972b676d7Smrg	lib="$output_objdir/$realname"
393072b676d7Smrg	linknames=
393172b676d7Smrg	for link
393272b676d7Smrg	do
393372b676d7Smrg	  linknames="$linknames $link"
393472b676d7Smrg	done
393572b676d7Smrg
393672b676d7Smrg	# Use standard objects if they are pic
393772b676d7Smrg	test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
393872b676d7Smrg
393972b676d7Smrg	# Prepare the list of exported symbols
394072b676d7Smrg	if test -z "$export_symbols"; then
394172b676d7Smrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
394272b676d7Smrg	    $show "generating symbol list for \`$libname.la'"
394372b676d7Smrg	    export_symbols="$output_objdir/$libname.exp"
394472b676d7Smrg	    $run $rm $export_symbols
394572b676d7Smrg	    cmds=$export_symbols_cmds
394672b676d7Smrg	    save_ifs="$IFS"; IFS='~'
394772b676d7Smrg	    for cmd in $cmds; do
394872b676d7Smrg	      IFS="$save_ifs"
394972b676d7Smrg	      eval cmd=\"$cmd\"
395072b676d7Smrg	      if len=`expr "X$cmd" : ".*"` &&
395172b676d7Smrg	       test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
395272b676d7Smrg	        $show "$cmd"
395372b676d7Smrg	        $run eval "$cmd" || exit $?
395472b676d7Smrg	        skipped_export=false
395572b676d7Smrg	      else
395672b676d7Smrg	        # The command line is too long to execute in one step.
395772b676d7Smrg	        $show "using reloadable object file for export list..."
395872b676d7Smrg	        skipped_export=:
395972b676d7Smrg		# Break out early, otherwise skipped_export may be
396072b676d7Smrg		# set to false by a later but shorter cmd.
396172b676d7Smrg		break
396272b676d7Smrg	      fi
396372b676d7Smrg	    done
396472b676d7Smrg	    IFS="$save_ifs"
396572b676d7Smrg	    if test -n "$export_symbols_regex"; then
396672b676d7Smrg	      $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""
396772b676d7Smrg	      $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
396872b676d7Smrg	      $show "$mv \"${export_symbols}T\" \"$export_symbols\""
396972b676d7Smrg	      $run eval '$mv "${export_symbols}T" "$export_symbols"'
397072b676d7Smrg	    fi
397172b676d7Smrg	  fi
397272b676d7Smrg	fi
397372b676d7Smrg
397472b676d7Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
397572b676d7Smrg	  $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"'
397672b676d7Smrg	fi
397772b676d7Smrg
397872b676d7Smrg	tmp_deplibs=
397972b676d7Smrg	for test_deplib in $deplibs; do
398072b676d7Smrg		case " $convenience " in
398172b676d7Smrg		*" $test_deplib "*) ;;
398272b676d7Smrg		*)
398372b676d7Smrg			tmp_deplibs="$tmp_deplibs $test_deplib"
398472b676d7Smrg			;;
398572b676d7Smrg		esac
398672b676d7Smrg	done
398772b676d7Smrg	deplibs="$tmp_deplibs"
398872b676d7Smrg
398972b676d7Smrg	if test -n "$convenience"; then
399072b676d7Smrg	  if test -n "$whole_archive_flag_spec"; then
399172b676d7Smrg	    save_libobjs=$libobjs
399272b676d7Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
399372b676d7Smrg	  else
399472b676d7Smrg	    gentop="$output_objdir/${outputname}x"
399572b676d7Smrg	    generated="$generated $gentop"
399672b676d7Smrg
399772b676d7Smrg	    func_extract_archives $gentop $convenience
399872b676d7Smrg	    libobjs="$libobjs $func_extract_archives_result"
399972b676d7Smrg	  fi
400072b676d7Smrg	fi
400172b676d7Smrg	
400272b676d7Smrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
400372b676d7Smrg	  eval flag=\"$thread_safe_flag_spec\"
400472b676d7Smrg	  linker_flags="$linker_flags $flag"
400572b676d7Smrg	fi
400672b676d7Smrg
400772b676d7Smrg	# Make a backup of the uninstalled library when relinking
400872b676d7Smrg	if test "$mode" = relink; then
400972b676d7Smrg	  $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $?
401072b676d7Smrg	fi
401172b676d7Smrg
401272b676d7Smrg	# Do each of the archive commands.
401372b676d7Smrg	if test "$module" = yes && test -n "$module_cmds" ; then
401472b676d7Smrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
401572b676d7Smrg	    eval test_cmds=\"$module_expsym_cmds\"
401672b676d7Smrg	    cmds=$module_expsym_cmds
401772b676d7Smrg	  else
401872b676d7Smrg	    eval test_cmds=\"$module_cmds\"
401972b676d7Smrg	    cmds=$module_cmds
402072b676d7Smrg	  fi
402172b676d7Smrg	else
402272b676d7Smrg	if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
402372b676d7Smrg	  eval test_cmds=\"$archive_expsym_cmds\"
402472b676d7Smrg	  cmds=$archive_expsym_cmds
402572b676d7Smrg	else
402672b676d7Smrg	  eval test_cmds=\"$archive_cmds\"
402772b676d7Smrg	  cmds=$archive_cmds
402872b676d7Smrg	  fi
402972b676d7Smrg	fi
403072b676d7Smrg
403172b676d7Smrg	if test "X$skipped_export" != "X:" &&
403272b676d7Smrg	   len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
403372b676d7Smrg	   test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
403472b676d7Smrg	  :
403572b676d7Smrg	else
403672b676d7Smrg	  # The command line is too long to link in one step, link piecewise.
403772b676d7Smrg	  $echo "creating reloadable object files..."
403872b676d7Smrg
403972b676d7Smrg	  # Save the value of $output and $libobjs because we want to
404072b676d7Smrg	  # use them later.  If we have whole_archive_flag_spec, we
404172b676d7Smrg	  # want to use save_libobjs as it was before
404272b676d7Smrg	  # whole_archive_flag_spec was expanded, because we can't
404372b676d7Smrg	  # assume the linker understands whole_archive_flag_spec.
404472b676d7Smrg	  # This may have to be revisited, in case too many
404572b676d7Smrg	  # convenience libraries get linked in and end up exceeding
404672b676d7Smrg	  # the spec.
404772b676d7Smrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
404872b676d7Smrg	    save_libobjs=$libobjs
404972b676d7Smrg	  fi
405072b676d7Smrg	  save_output=$output
405172b676d7Smrg	  output_la=`$echo "X$output" | $Xsed -e "$basename"`
405272b676d7Smrg
405372b676d7Smrg	  # Clear the reloadable object creation command queue and
405472b676d7Smrg	  # initialize k to one.
405572b676d7Smrg	  test_cmds=
405672b676d7Smrg	  concat_cmds=
405772b676d7Smrg	  objlist=
405872b676d7Smrg	  delfiles=
405972b676d7Smrg	  last_robj=
406072b676d7Smrg	  k=1
406172b676d7Smrg	  output=$output_objdir/$output_la-${k}.$objext
406272b676d7Smrg	  # Loop over the list of objects to be linked.
406372b676d7Smrg	  for obj in $save_libobjs
406472b676d7Smrg	  do
406572b676d7Smrg	    eval test_cmds=\"$reload_cmds $objlist $last_robj\"
406672b676d7Smrg	    if test "X$objlist" = X ||
406772b676d7Smrg	       { len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
406872b676d7Smrg		 test "$len" -le "$max_cmd_len"; }; then
406972b676d7Smrg	      objlist="$objlist $obj"
407072b676d7Smrg	    else
407172b676d7Smrg	      # The command $test_cmds is almost too long, add a
407272b676d7Smrg	      # command to the queue.
407372b676d7Smrg	      if test "$k" -eq 1 ; then
407472b676d7Smrg		# The first file doesn't have a previous command to add.
407572b676d7Smrg		eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
407672b676d7Smrg	      else
407772b676d7Smrg		# All subsequent reloadable object files will link in
407872b676d7Smrg		# the last one created.
407972b676d7Smrg		eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\"
408072b676d7Smrg	      fi
408172b676d7Smrg	      last_robj=$output_objdir/$output_la-${k}.$objext
408272b676d7Smrg	      k=`expr $k + 1`
408372b676d7Smrg	      output=$output_objdir/$output_la-${k}.$objext
408472b676d7Smrg	      objlist=$obj
408572b676d7Smrg	      len=1
408672b676d7Smrg	    fi
408772b676d7Smrg	  done
408872b676d7Smrg	  # Handle the remaining objects by creating one last
408972b676d7Smrg	  # reloadable object file.  All subsequent reloadable object
409072b676d7Smrg	  # files will link in the last one created.
409172b676d7Smrg	  test -z "$concat_cmds" || concat_cmds=$concat_cmds~
409272b676d7Smrg	  eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
409372b676d7Smrg
409472b676d7Smrg	  if ${skipped_export-false}; then
409572b676d7Smrg	    $show "generating symbol list for \`$libname.la'"
409672b676d7Smrg	    export_symbols="$output_objdir/$libname.exp"
409772b676d7Smrg	    $run $rm $export_symbols
409872b676d7Smrg	    libobjs=$output
409972b676d7Smrg	    # Append the command to create the export file.
410072b676d7Smrg	    eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\"
410172b676d7Smrg          fi
410272b676d7Smrg
410372b676d7Smrg	  # Set up a command to remove the reloadable object files
410472b676d7Smrg	  # after they are used.
410572b676d7Smrg	  i=0
410672b676d7Smrg	  while test "$i" -lt "$k"
410772b676d7Smrg	  do
410872b676d7Smrg	    i=`expr $i + 1`
410972b676d7Smrg	    delfiles="$delfiles $output_objdir/$output_la-${i}.$objext"
411072b676d7Smrg	  done
411172b676d7Smrg
411272b676d7Smrg	  $echo "creating a temporary reloadable object file: $output"
411372b676d7Smrg
411472b676d7Smrg	  # Loop through the commands generated above and execute them.
411572b676d7Smrg	  save_ifs="$IFS"; IFS='~'
411672b676d7Smrg	  for cmd in $concat_cmds; do
411772b676d7Smrg	    IFS="$save_ifs"
411872b676d7Smrg	    $show "$cmd"
411972b676d7Smrg	    $run eval "$cmd" || exit $?
412072b676d7Smrg	  done
412172b676d7Smrg	  IFS="$save_ifs"
412272b676d7Smrg
412372b676d7Smrg	  libobjs=$output
412472b676d7Smrg	  # Restore the value of output.
412572b676d7Smrg	  output=$save_output
412672b676d7Smrg
412772b676d7Smrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
412872b676d7Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
412972b676d7Smrg	  fi
413072b676d7Smrg	  # Expand the library linking commands again to reset the
413172b676d7Smrg	  # value of $libobjs for piecewise linking.
413272b676d7Smrg
413372b676d7Smrg	  # Do each of the archive commands.
413472b676d7Smrg	  if test "$module" = yes && test -n "$module_cmds" ; then
413572b676d7Smrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
413672b676d7Smrg	      cmds=$module_expsym_cmds
413772b676d7Smrg	    else
413872b676d7Smrg	      cmds=$module_cmds
413972b676d7Smrg	    fi
414072b676d7Smrg	  else
414172b676d7Smrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
414272b676d7Smrg	    cmds=$archive_expsym_cmds
414372b676d7Smrg	  else
414472b676d7Smrg	    cmds=$archive_cmds
414572b676d7Smrg	    fi
414672b676d7Smrg	  fi
414772b676d7Smrg
414872b676d7Smrg	  # Append the command to remove the reloadable object files
414972b676d7Smrg	  # to the just-reset $cmds.
415072b676d7Smrg	  eval cmds=\"\$cmds~\$rm $delfiles\"
415172b676d7Smrg	fi
415272b676d7Smrg	save_ifs="$IFS"; IFS='~'
415372b676d7Smrg	for cmd in $cmds; do
415472b676d7Smrg	  IFS="$save_ifs"
415572b676d7Smrg	  eval cmd=\"$cmd\"
415672b676d7Smrg	  $show "$cmd"
415772b676d7Smrg	  $run eval "$cmd" || {
415872b676d7Smrg	    lt_exit=$?
415972b676d7Smrg
416072b676d7Smrg	    # Restore the uninstalled library and exit
416172b676d7Smrg	    if test "$mode" = relink; then
416272b676d7Smrg	      $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
416372b676d7Smrg	    fi
416472b676d7Smrg
416572b676d7Smrg	    exit $lt_exit
416672b676d7Smrg	  }
416772b676d7Smrg	done
416872b676d7Smrg	IFS="$save_ifs"
416972b676d7Smrg
417072b676d7Smrg	# Restore the uninstalled library and exit
417172b676d7Smrg	if test "$mode" = relink; then
417272b676d7Smrg	  $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $?
417372b676d7Smrg
417472b676d7Smrg	  if test -n "$convenience"; then
417572b676d7Smrg	    if test -z "$whole_archive_flag_spec"; then
417672b676d7Smrg	      $show "${rm}r $gentop"
417772b676d7Smrg	      $run ${rm}r "$gentop"
417872b676d7Smrg	    fi
417972b676d7Smrg	  fi
418072b676d7Smrg
418172b676d7Smrg	  exit $EXIT_SUCCESS
418272b676d7Smrg	fi
418372b676d7Smrg
418472b676d7Smrg	# Create links to the real library.
418572b676d7Smrg	for linkname in $linknames; do
418672b676d7Smrg	  if test "$realname" != "$linkname"; then
418772b676d7Smrg	    $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)"
418872b676d7Smrg	    $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $?
418972b676d7Smrg	  fi
419072b676d7Smrg	done
419172b676d7Smrg
419272b676d7Smrg	# If -module or -export-dynamic was specified, set the dlname.
419372b676d7Smrg	if test "$module" = yes || test "$export_dynamic" = yes; then
419472b676d7Smrg	  # On all known operating systems, these are identical.
419572b676d7Smrg	  dlname="$soname"
419672b676d7Smrg	fi
419772b676d7Smrg      fi
419872b676d7Smrg      ;;
419972b676d7Smrg
420072b676d7Smrg    obj)
420172b676d7Smrg      if test -n "$deplibs"; then
420272b676d7Smrg	$echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2
420372b676d7Smrg      fi
420472b676d7Smrg
420572b676d7Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
420672b676d7Smrg	$echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
420772b676d7Smrg      fi
420872b676d7Smrg
420972b676d7Smrg      if test -n "$rpath"; then
421072b676d7Smrg	$echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2
421172b676d7Smrg      fi
421272b676d7Smrg
421372b676d7Smrg      if test -n "$xrpath"; then
421472b676d7Smrg	$echo "$modename: warning: \`-R' is ignored for objects" 1>&2
421572b676d7Smrg      fi
421672b676d7Smrg
421772b676d7Smrg      if test -n "$vinfo"; then
421872b676d7Smrg	$echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2
421972b676d7Smrg      fi
422072b676d7Smrg
422172b676d7Smrg      if test -n "$release"; then
422272b676d7Smrg	$echo "$modename: warning: \`-release' is ignored for objects" 1>&2
422372b676d7Smrg      fi
422472b676d7Smrg
422572b676d7Smrg      case $output in
422672b676d7Smrg      *.lo)
422772b676d7Smrg	if test -n "$objs$old_deplibs"; then
422872b676d7Smrg	  $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
422972b676d7Smrg	  exit $EXIT_FAILURE
423072b676d7Smrg	fi
423172b676d7Smrg	libobj="$output"
423272b676d7Smrg	obj=`$echo "X$output" | $Xsed -e "$lo2o"`
423372b676d7Smrg	;;
423472b676d7Smrg      *)
423572b676d7Smrg	libobj=
423672b676d7Smrg	obj="$output"
423772b676d7Smrg	;;
423872b676d7Smrg      esac
423972b676d7Smrg
424072b676d7Smrg      # Delete the old objects.
424172b676d7Smrg      $run $rm $obj $libobj
424272b676d7Smrg
424372b676d7Smrg      # Objects from convenience libraries.  This assumes
424472b676d7Smrg      # single-version convenience libraries.  Whenever we create
424572b676d7Smrg      # different ones for PIC/non-PIC, this we'll have to duplicate
424672b676d7Smrg      # the extraction.
424772b676d7Smrg      reload_conv_objs=
424872b676d7Smrg      gentop=
424972b676d7Smrg      # reload_cmds runs $LD directly, so let us get rid of
425072b676d7Smrg      # -Wl from whole_archive_flag_spec
425172b676d7Smrg      wl=
425272b676d7Smrg
425372b676d7Smrg      if test -n "$convenience"; then
425472b676d7Smrg	if test -n "$whole_archive_flag_spec"; then
425572b676d7Smrg	  eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
425672b676d7Smrg	else
425772b676d7Smrg	  gentop="$output_objdir/${obj}x"
425872b676d7Smrg	  generated="$generated $gentop"
425972b676d7Smrg
426072b676d7Smrg	  func_extract_archives $gentop $convenience
426172b676d7Smrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
426272b676d7Smrg	fi
426372b676d7Smrg      fi
426472b676d7Smrg
426572b676d7Smrg      # Create the old-style object.
426672b676d7Smrg      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
426772b676d7Smrg
426872b676d7Smrg      output="$obj"
426972b676d7Smrg      cmds=$reload_cmds
427072b676d7Smrg      save_ifs="$IFS"; IFS='~'
427172b676d7Smrg      for cmd in $cmds; do
427272b676d7Smrg	IFS="$save_ifs"
427372b676d7Smrg	eval cmd=\"$cmd\"
427472b676d7Smrg	$show "$cmd"
427572b676d7Smrg	$run eval "$cmd" || exit $?
427672b676d7Smrg      done
427772b676d7Smrg      IFS="$save_ifs"
427872b676d7Smrg
427972b676d7Smrg      # Exit if we aren't doing a library object file.
428072b676d7Smrg      if test -z "$libobj"; then
428172b676d7Smrg	if test -n "$gentop"; then
428272b676d7Smrg	  $show "${rm}r $gentop"
428372b676d7Smrg	  $run ${rm}r $gentop
428472b676d7Smrg	fi
428572b676d7Smrg
428672b676d7Smrg	exit $EXIT_SUCCESS
428772b676d7Smrg      fi
428872b676d7Smrg
428972b676d7Smrg      if test "$build_libtool_libs" != yes; then
429072b676d7Smrg	if test -n "$gentop"; then
429172b676d7Smrg	  $show "${rm}r $gentop"
429272b676d7Smrg	  $run ${rm}r $gentop
429372b676d7Smrg	fi
429472b676d7Smrg
429572b676d7Smrg	# Create an invalid libtool object if no PIC, so that we don't
429672b676d7Smrg	# accidentally link it into a program.
429772b676d7Smrg	# $show "echo timestamp > $libobj"
429872b676d7Smrg	# $run eval "echo timestamp > $libobj" || exit $?
429972b676d7Smrg	exit $EXIT_SUCCESS
430072b676d7Smrg      fi
430172b676d7Smrg
430272b676d7Smrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
430372b676d7Smrg	# Only do commands if we really have different PIC objects.
430472b676d7Smrg	reload_objs="$libobjs $reload_conv_objs"
430572b676d7Smrg	output="$libobj"
430672b676d7Smrg	cmds=$reload_cmds
430772b676d7Smrg	save_ifs="$IFS"; IFS='~'
430872b676d7Smrg	for cmd in $cmds; do
430972b676d7Smrg	  IFS="$save_ifs"
431072b676d7Smrg	  eval cmd=\"$cmd\"
431172b676d7Smrg	  $show "$cmd"
431272b676d7Smrg	  $run eval "$cmd" || exit $?
431372b676d7Smrg	done
431472b676d7Smrg	IFS="$save_ifs"
431572b676d7Smrg      fi
431672b676d7Smrg
431772b676d7Smrg      if test -n "$gentop"; then
431872b676d7Smrg	$show "${rm}r $gentop"
431972b676d7Smrg	$run ${rm}r $gentop
432072b676d7Smrg      fi
432172b676d7Smrg
432272b676d7Smrg      exit $EXIT_SUCCESS
432372b676d7Smrg      ;;
432472b676d7Smrg
432572b676d7Smrg    prog)
432672b676d7Smrg      case $host in
432772b676d7Smrg	*cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;
432872b676d7Smrg      esac
432972b676d7Smrg      if test -n "$vinfo"; then
433072b676d7Smrg	$echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
433172b676d7Smrg      fi
433272b676d7Smrg
433372b676d7Smrg      if test -n "$release"; then
433472b676d7Smrg	$echo "$modename: warning: \`-release' is ignored for programs" 1>&2
433572b676d7Smrg      fi
433672b676d7Smrg
433772b676d7Smrg      if test "$preload" = yes; then
433872b676d7Smrg	if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown &&
433972b676d7Smrg	   test "$dlopen_self_static" = unknown; then
434072b676d7Smrg	  $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support."
434172b676d7Smrg	fi
434272b676d7Smrg      fi
434372b676d7Smrg
434472b676d7Smrg      case $host in
434572b676d7Smrg      *-*-rhapsody* | *-*-darwin1.[012])
434672b676d7Smrg	# On Rhapsody replace the C library is the System framework
434772b676d7Smrg	compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
434872b676d7Smrg	finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
434972b676d7Smrg	;;
435072b676d7Smrg      esac
435172b676d7Smrg
435272b676d7Smrg      case $host in
435372b676d7Smrg      *darwin*)
435472b676d7Smrg        # Don't allow lazy linking, it breaks C++ global constructors
435572b676d7Smrg        if test "$tagname" = CXX ; then
435672b676d7Smrg        compile_command="$compile_command ${wl}-bind_at_load"
435772b676d7Smrg        finalize_command="$finalize_command ${wl}-bind_at_load"
435872b676d7Smrg        fi
435972b676d7Smrg        ;;
436072b676d7Smrg      esac
436172b676d7Smrg
436272b676d7Smrg
436372b676d7Smrg      # move library search paths that coincide with paths to not yet
436472b676d7Smrg      # installed libraries to the beginning of the library search list
436572b676d7Smrg      new_libs=
436672b676d7Smrg      for path in $notinst_path; do
436772b676d7Smrg	case " $new_libs " in
436872b676d7Smrg	*" -L$path/$objdir "*) ;;
436972b676d7Smrg	*)
437072b676d7Smrg	  case " $compile_deplibs " in
437172b676d7Smrg	  *" -L$path/$objdir "*)
437272b676d7Smrg	    new_libs="$new_libs -L$path/$objdir" ;;
437372b676d7Smrg	  esac
437472b676d7Smrg	  ;;
437572b676d7Smrg	esac
437672b676d7Smrg      done
437772b676d7Smrg      for deplib in $compile_deplibs; do
437872b676d7Smrg	case $deplib in
437972b676d7Smrg	-L*)
438072b676d7Smrg	  case " $new_libs " in
438172b676d7Smrg	  *" $deplib "*) ;;
438272b676d7Smrg	  *) new_libs="$new_libs $deplib" ;;
438372b676d7Smrg	  esac
438472b676d7Smrg	  ;;
438572b676d7Smrg	*) new_libs="$new_libs $deplib" ;;
438672b676d7Smrg	esac
438772b676d7Smrg      done
438872b676d7Smrg      compile_deplibs="$new_libs"
438972b676d7Smrg
439072b676d7Smrg
439172b676d7Smrg      compile_command="$compile_command $compile_deplibs"
439272b676d7Smrg      finalize_command="$finalize_command $finalize_deplibs"
439372b676d7Smrg
439472b676d7Smrg      if test -n "$rpath$xrpath"; then
439572b676d7Smrg	# If the user specified any rpath flags, then add them.
439672b676d7Smrg	for libdir in $rpath $xrpath; do
439772b676d7Smrg	  # This is the magic to use -rpath.
439872b676d7Smrg	  case "$finalize_rpath " in
439972b676d7Smrg	  *" $libdir "*) ;;
440072b676d7Smrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
440172b676d7Smrg	  esac
440272b676d7Smrg	done
440372b676d7Smrg      fi
440472b676d7Smrg
440572b676d7Smrg      # Now hardcode the library paths
440672b676d7Smrg      rpath=
440772b676d7Smrg      hardcode_libdirs=
440872b676d7Smrg      for libdir in $compile_rpath $finalize_rpath; do
440972b676d7Smrg	if test -n "$hardcode_libdir_flag_spec"; then
441072b676d7Smrg	  if test -n "$hardcode_libdir_separator"; then
441172b676d7Smrg	    if test -z "$hardcode_libdirs"; then
441272b676d7Smrg	      hardcode_libdirs="$libdir"
441372b676d7Smrg	    else
441472b676d7Smrg	      # Just accumulate the unique libdirs.
441572b676d7Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
441672b676d7Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
441772b676d7Smrg		;;
441872b676d7Smrg	      *)
441972b676d7Smrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
442072b676d7Smrg		;;
442172b676d7Smrg	      esac
442272b676d7Smrg	    fi
442372b676d7Smrg	  else
442472b676d7Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
442572b676d7Smrg	    rpath="$rpath $flag"
442672b676d7Smrg	  fi
442772b676d7Smrg	elif test -n "$runpath_var"; then
442872b676d7Smrg	  case "$perm_rpath " in
442972b676d7Smrg	  *" $libdir "*) ;;
443072b676d7Smrg	  *) perm_rpath="$perm_rpath $libdir" ;;
443172b676d7Smrg	  esac
443272b676d7Smrg	fi
443372b676d7Smrg	case $host in
443472b676d7Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
443572b676d7Smrg	  testbindir=`$echo "X$libdir" | $Xsed -e 's*/lib$*/bin*'`
443672b676d7Smrg	  case :$dllsearchpath: in
443772b676d7Smrg	  *":$libdir:"*) ;;
443872b676d7Smrg	  *) dllsearchpath="$dllsearchpath:$libdir";;
443972b676d7Smrg	  esac
444072b676d7Smrg	  case :$dllsearchpath: in
444172b676d7Smrg	  *":$testbindir:"*) ;;
444272b676d7Smrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
444372b676d7Smrg	  esac
444472b676d7Smrg	  ;;
444572b676d7Smrg	esac
444672b676d7Smrg      done
444772b676d7Smrg      # Substitute the hardcoded libdirs into the rpath.
444872b676d7Smrg      if test -n "$hardcode_libdir_separator" &&
444972b676d7Smrg	 test -n "$hardcode_libdirs"; then
445072b676d7Smrg	libdir="$hardcode_libdirs"
445172b676d7Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
445272b676d7Smrg      fi
445372b676d7Smrg      compile_rpath="$rpath"
445472b676d7Smrg
445572b676d7Smrg      rpath=
445672b676d7Smrg      hardcode_libdirs=
445772b676d7Smrg      for libdir in $finalize_rpath; do
445872b676d7Smrg	if test -n "$hardcode_libdir_flag_spec"; then
445972b676d7Smrg	  if test -n "$hardcode_libdir_separator"; then
446072b676d7Smrg	    if test -z "$hardcode_libdirs"; then
446172b676d7Smrg	      hardcode_libdirs="$libdir"
446272b676d7Smrg	    else
446372b676d7Smrg	      # Just accumulate the unique libdirs.
446472b676d7Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
446572b676d7Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
446672b676d7Smrg		;;
446772b676d7Smrg	      *)
446872b676d7Smrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
446972b676d7Smrg		;;
447072b676d7Smrg	      esac
447172b676d7Smrg	    fi
447272b676d7Smrg	  else
447372b676d7Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
447472b676d7Smrg	    rpath="$rpath $flag"
447572b676d7Smrg	  fi
447672b676d7Smrg	elif test -n "$runpath_var"; then
447772b676d7Smrg	  case "$finalize_perm_rpath " in
447872b676d7Smrg	  *" $libdir "*) ;;
447972b676d7Smrg	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
448072b676d7Smrg	  esac
448172b676d7Smrg	fi
448272b676d7Smrg      done
448372b676d7Smrg      # Substitute the hardcoded libdirs into the rpath.
448472b676d7Smrg      if test -n "$hardcode_libdir_separator" &&
448572b676d7Smrg	 test -n "$hardcode_libdirs"; then
448672b676d7Smrg	libdir="$hardcode_libdirs"
448772b676d7Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
448872b676d7Smrg      fi
448972b676d7Smrg      finalize_rpath="$rpath"
449072b676d7Smrg
449172b676d7Smrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
449272b676d7Smrg	# Transform all the library objects into standard objects.
449372b676d7Smrg	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
449472b676d7Smrg	finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
449572b676d7Smrg      fi
449672b676d7Smrg
449772b676d7Smrg      dlsyms=
449872b676d7Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
449972b676d7Smrg	if test -n "$NM" && test -n "$global_symbol_pipe"; then
450072b676d7Smrg	  dlsyms="${outputname}S.c"
450172b676d7Smrg	else
450272b676d7Smrg	  $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2
450372b676d7Smrg	fi
450472b676d7Smrg      fi
450572b676d7Smrg
450672b676d7Smrg      if test -n "$dlsyms"; then
450772b676d7Smrg	case $dlsyms in
450872b676d7Smrg	"") ;;
450972b676d7Smrg	*.c)
451072b676d7Smrg	  # Discover the nlist of each of the dlfiles.
451172b676d7Smrg	  nlist="$output_objdir/${outputname}.nm"
451272b676d7Smrg
451372b676d7Smrg	  $show "$rm $nlist ${nlist}S ${nlist}T"
451472b676d7Smrg	  $run $rm "$nlist" "${nlist}S" "${nlist}T"
451572b676d7Smrg
451672b676d7Smrg	  # Parse the name list into a source file.
451772b676d7Smrg	  $show "creating $output_objdir/$dlsyms"
451872b676d7Smrg
451972b676d7Smrg	  test -z "$run" && $echo > "$output_objdir/$dlsyms" "\
452072b676d7Smrg/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */
452172b676d7Smrg/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */
452272b676d7Smrg
452372b676d7Smrg#ifdef __cplusplus
452472b676d7Smrgextern \"C\" {
452572b676d7Smrg#endif
452672b676d7Smrg
452772b676d7Smrg/* Prevent the only kind of declaration conflicts we can make. */
452872b676d7Smrg#define lt_preloaded_symbols some_other_symbol
452972b676d7Smrg
453072b676d7Smrg/* External symbol declarations for the compiler. */\
453172b676d7Smrg"
453272b676d7Smrg
453372b676d7Smrg	  if test "$dlself" = yes; then
453472b676d7Smrg	    $show "generating symbol list for \`$output'"
453572b676d7Smrg
453672b676d7Smrg	    test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist"
453772b676d7Smrg
453872b676d7Smrg	    # Add our own program objects to the symbol list.
453972b676d7Smrg	    progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
454072b676d7Smrg	    for arg in $progfiles; do
454172b676d7Smrg	      $show "extracting global C symbols from \`$arg'"
454272b676d7Smrg	      $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
454372b676d7Smrg	    done
454472b676d7Smrg
454572b676d7Smrg	    if test -n "$exclude_expsyms"; then
454672b676d7Smrg	      $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
454772b676d7Smrg	      $run eval '$mv "$nlist"T "$nlist"'
454872b676d7Smrg	    fi
454972b676d7Smrg
455072b676d7Smrg	    if test -n "$export_symbols_regex"; then
455172b676d7Smrg	      $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
455272b676d7Smrg	      $run eval '$mv "$nlist"T "$nlist"'
455372b676d7Smrg	    fi
455472b676d7Smrg
455572b676d7Smrg	    # Prepare the list of exported symbols
455672b676d7Smrg	    if test -z "$export_symbols"; then
455772b676d7Smrg	      export_symbols="$output_objdir/$outputname.exp"
455872b676d7Smrg	      $run $rm $export_symbols
455972b676d7Smrg	      $run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
456072b676d7Smrg              case $host in
456172b676d7Smrg              *cygwin* | *mingw* )
456272b676d7Smrg	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
456372b676d7Smrg		$run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
456472b676d7Smrg                ;;
456572b676d7Smrg              esac
456672b676d7Smrg	    else
456772b676d7Smrg	      $run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
456872b676d7Smrg	      $run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
456972b676d7Smrg	      $run eval 'mv "$nlist"T "$nlist"'
457072b676d7Smrg              case $host in
457172b676d7Smrg              *cygwin* | *mingw* )
457272b676d7Smrg	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
457372b676d7Smrg		$run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
457472b676d7Smrg                ;;
457572b676d7Smrg              esac
457672b676d7Smrg	    fi
457772b676d7Smrg	  fi
457872b676d7Smrg
457972b676d7Smrg	  for arg in $dlprefiles; do
458072b676d7Smrg	    $show "extracting global C symbols from \`$arg'"
458172b676d7Smrg	    name=`$echo "$arg" | ${SED} -e 's%^.*/%%'`
458272b676d7Smrg	    $run eval '$echo ": $name " >> "$nlist"'
458372b676d7Smrg	    $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
458472b676d7Smrg	  done
458572b676d7Smrg
458672b676d7Smrg	  if test -z "$run"; then
458772b676d7Smrg	    # Make sure we have at least an empty file.
458872b676d7Smrg	    test -f "$nlist" || : > "$nlist"
458972b676d7Smrg
459072b676d7Smrg	    if test -n "$exclude_expsyms"; then
459172b676d7Smrg	      $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
459272b676d7Smrg	      $mv "$nlist"T "$nlist"
459372b676d7Smrg	    fi
459472b676d7Smrg
459572b676d7Smrg	    # Try sorting and uniquifying the output.
459672b676d7Smrg	    if grep -v "^: " < "$nlist" |
459772b676d7Smrg		if sort -k 3 </dev/null >/dev/null 2>&1; then
459872b676d7Smrg		  sort -k 3
459972b676d7Smrg		else
460072b676d7Smrg		  sort +2
460172b676d7Smrg		fi |
460272b676d7Smrg		uniq > "$nlist"S; then
460372b676d7Smrg	      :
460472b676d7Smrg	    else
460572b676d7Smrg	      grep -v "^: " < "$nlist" > "$nlist"S
460672b676d7Smrg	    fi
460772b676d7Smrg
460872b676d7Smrg	    if test -f "$nlist"S; then
460972b676d7Smrg	      eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"'
461072b676d7Smrg	    else
461172b676d7Smrg	      $echo '/* NONE */' >> "$output_objdir/$dlsyms"
461272b676d7Smrg	    fi
461372b676d7Smrg
461472b676d7Smrg	    $echo >> "$output_objdir/$dlsyms" "\
461572b676d7Smrg
461672b676d7Smrg#undef lt_preloaded_symbols
461772b676d7Smrg
461872b676d7Smrg#if defined (__STDC__) && __STDC__
461972b676d7Smrg# define lt_ptr void *
462072b676d7Smrg#else
462172b676d7Smrg# define lt_ptr char *
462272b676d7Smrg# define const
462372b676d7Smrg#endif
462472b676d7Smrg
462572b676d7Smrg/* The mapping between symbol names and symbols. */
462672b676d7Smrg"
462772b676d7Smrg
462872b676d7Smrg	    case $host in
462972b676d7Smrg	    *cygwin* | *mingw* )
463072b676d7Smrg	  $echo >> "$output_objdir/$dlsyms" "\
463172b676d7Smrg/* DATA imports from DLLs on WIN32 can't be const, because
463272b676d7Smrg   runtime relocations are performed -- see ld's documentation
463372b676d7Smrg   on pseudo-relocs */
463472b676d7Smrgstruct {
463572b676d7Smrg"
463672b676d7Smrg	      ;;
463772b676d7Smrg	    * )
463872b676d7Smrg	  $echo >> "$output_objdir/$dlsyms" "\
463972b676d7Smrgconst struct {
464072b676d7Smrg"
464172b676d7Smrg	      ;;
464272b676d7Smrg	    esac
464372b676d7Smrg
464472b676d7Smrg
464572b676d7Smrg	  $echo >> "$output_objdir/$dlsyms" "\
464672b676d7Smrg  const char *name;
464772b676d7Smrg  lt_ptr address;
464872b676d7Smrg}
464972b676d7Smrglt_preloaded_symbols[] =
465072b676d7Smrg{\
465172b676d7Smrg"
465272b676d7Smrg
465372b676d7Smrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms"
465472b676d7Smrg
465572b676d7Smrg	    $echo >> "$output_objdir/$dlsyms" "\
465672b676d7Smrg  {0, (lt_ptr) 0}
465772b676d7Smrg};
465872b676d7Smrg
465972b676d7Smrg/* This works around a problem in FreeBSD linker */
466072b676d7Smrg#ifdef FREEBSD_WORKAROUND
466172b676d7Smrgstatic const void *lt_preloaded_setup() {
466272b676d7Smrg  return lt_preloaded_symbols;
466372b676d7Smrg}
466472b676d7Smrg#endif
466572b676d7Smrg
466672b676d7Smrg#ifdef __cplusplus
466772b676d7Smrg}
466872b676d7Smrg#endif\
466972b676d7Smrg"
467072b676d7Smrg	  fi
467172b676d7Smrg
467272b676d7Smrg	  pic_flag_for_symtable=
467372b676d7Smrg	  case $host in
467472b676d7Smrg	  # compiling the symbol table file with pic_flag works around
467572b676d7Smrg	  # a FreeBSD bug that causes programs to crash when -lm is
467672b676d7Smrg	  # linked before any other PIC object.  But we must not use
467772b676d7Smrg	  # pic_flag when linking with -static.  The problem exists in
467872b676d7Smrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
467972b676d7Smrg	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
468072b676d7Smrg	    case "$compile_command " in
468172b676d7Smrg	    *" -static "*) ;;
468272b676d7Smrg	    *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";;
468372b676d7Smrg	    esac;;
468472b676d7Smrg	  *-*-hpux*)
468572b676d7Smrg	    case "$compile_command " in
468672b676d7Smrg	    *" -static "*) ;;
468772b676d7Smrg	    *) pic_flag_for_symtable=" $pic_flag";;
468872b676d7Smrg	    esac
468972b676d7Smrg	  esac
469072b676d7Smrg
469172b676d7Smrg	  # Now compile the dynamic symbol file.
469272b676d7Smrg	  $show "(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
469372b676d7Smrg	  $run eval '(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
469472b676d7Smrg
469572b676d7Smrg	  # Clean up the generated files.
469672b676d7Smrg	  $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
469772b676d7Smrg	  $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
469872b676d7Smrg
469972b676d7Smrg	  # Transform the symbol file into the correct name.
470072b676d7Smrg          case $host in
470172b676d7Smrg          *cygwin* | *mingw* )
470272b676d7Smrg            if test -f "$output_objdir/${outputname}.def" ; then
470372b676d7Smrg              compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
470472b676d7Smrg              finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
470572b676d7Smrg            else
470672b676d7Smrg              compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
470772b676d7Smrg              finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
470872b676d7Smrg             fi
470972b676d7Smrg            ;;
471072b676d7Smrg          * )
471172b676d7Smrg            compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
471272b676d7Smrg            finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
471372b676d7Smrg            ;;
471472b676d7Smrg          esac
471572b676d7Smrg	  ;;
471672b676d7Smrg	*)
471772b676d7Smrg	  $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
471872b676d7Smrg	  exit $EXIT_FAILURE
471972b676d7Smrg	  ;;
472072b676d7Smrg	esac
472172b676d7Smrg      else
472272b676d7Smrg	# We keep going just in case the user didn't refer to
472372b676d7Smrg	# lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
472472b676d7Smrg	# really was required.
472572b676d7Smrg
472672b676d7Smrg	# Nullify the symbol file.
472772b676d7Smrg	compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
472872b676d7Smrg	finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
472972b676d7Smrg      fi
473072b676d7Smrg
473172b676d7Smrg      if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
473272b676d7Smrg	# Replace the output file specification.
473372b676d7Smrg	compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
473472b676d7Smrg	link_command="$compile_command$compile_rpath"
473572b676d7Smrg
473672b676d7Smrg	# We have no uninstalled library dependencies, so finalize right now.
473772b676d7Smrg	$show "$link_command"
473872b676d7Smrg	$run eval "$link_command"
473972b676d7Smrg	exit_status=$?
474072b676d7Smrg
474172b676d7Smrg	# Delete the generated files.
474272b676d7Smrg	if test -n "$dlsyms"; then
474372b676d7Smrg	  $show "$rm $output_objdir/${outputname}S.${objext}"
474472b676d7Smrg	  $run $rm "$output_objdir/${outputname}S.${objext}"
474572b676d7Smrg	fi
474672b676d7Smrg
474772b676d7Smrg	exit $exit_status
474872b676d7Smrg      fi
474972b676d7Smrg
475072b676d7Smrg      if test -n "$shlibpath_var"; then
475172b676d7Smrg	# We should set the shlibpath_var
475272b676d7Smrg	rpath=
475372b676d7Smrg	for dir in $temp_rpath; do
475472b676d7Smrg	  case $dir in
475572b676d7Smrg	  [\\/]* | [A-Za-z]:[\\/]*)
475672b676d7Smrg	    # Absolute path.
475772b676d7Smrg	    rpath="$rpath$dir:"
475872b676d7Smrg	    ;;
475972b676d7Smrg	  *)
476072b676d7Smrg	    # Relative path: add a thisdir entry.
476172b676d7Smrg	    rpath="$rpath\$thisdir/$dir:"
476272b676d7Smrg	    ;;
476372b676d7Smrg	  esac
476472b676d7Smrg	done
476572b676d7Smrg	temp_rpath="$rpath"
476672b676d7Smrg      fi
476772b676d7Smrg
476872b676d7Smrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
476972b676d7Smrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
477072b676d7Smrg      fi
477172b676d7Smrg      if test -n "$finalize_shlibpath"; then
477272b676d7Smrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
477372b676d7Smrg      fi
477472b676d7Smrg
477572b676d7Smrg      compile_var=
477672b676d7Smrg      finalize_var=
477772b676d7Smrg      if test -n "$runpath_var"; then
477872b676d7Smrg	if test -n "$perm_rpath"; then
477972b676d7Smrg	  # We should set the runpath_var.
478072b676d7Smrg	  rpath=
478172b676d7Smrg	  for dir in $perm_rpath; do
478272b676d7Smrg	    rpath="$rpath$dir:"
478372b676d7Smrg	  done
478472b676d7Smrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
478572b676d7Smrg	fi
478672b676d7Smrg	if test -n "$finalize_perm_rpath"; then
478772b676d7Smrg	  # We should set the runpath_var.
478872b676d7Smrg	  rpath=
478972b676d7Smrg	  for dir in $finalize_perm_rpath; do
479072b676d7Smrg	    rpath="$rpath$dir:"
479172b676d7Smrg	  done
479272b676d7Smrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
479372b676d7Smrg	fi
479472b676d7Smrg      fi
479572b676d7Smrg
479672b676d7Smrg      if test "$no_install" = yes; then
479772b676d7Smrg	# We don't need to create a wrapper script.
479872b676d7Smrg	link_command="$compile_var$compile_command$compile_rpath"
479972b676d7Smrg	# Replace the output file specification.
480072b676d7Smrg	link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
480172b676d7Smrg	# Delete the old output file.
480272b676d7Smrg	$run $rm $output
480372b676d7Smrg	# Link the executable and exit
480472b676d7Smrg	$show "$link_command"
480572b676d7Smrg	$run eval "$link_command" || exit $?
480672b676d7Smrg	exit $EXIT_SUCCESS
480772b676d7Smrg      fi
480872b676d7Smrg
480972b676d7Smrg      if test "$hardcode_action" = relink; then
481072b676d7Smrg	# Fast installation is not supported
481172b676d7Smrg	link_command="$compile_var$compile_command$compile_rpath"
481272b676d7Smrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
481372b676d7Smrg
481472b676d7Smrg	$echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2
481572b676d7Smrg	$echo "$modename: \`$output' will be relinked during installation" 1>&2
481672b676d7Smrg      else
481772b676d7Smrg	if test "$fast_install" != no; then
481872b676d7Smrg	  link_command="$finalize_var$compile_command$finalize_rpath"
481972b676d7Smrg	  if test "$fast_install" = yes; then
482072b676d7Smrg	    relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
482172b676d7Smrg	  else
482272b676d7Smrg	    # fast_install is set to needless
482372b676d7Smrg	    relink_command=
482472b676d7Smrg	  fi
482572b676d7Smrg	else
482672b676d7Smrg	  link_command="$compile_var$compile_command$compile_rpath"
482772b676d7Smrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
482872b676d7Smrg	fi
482972b676d7Smrg      fi
483072b676d7Smrg
483172b676d7Smrg      # Replace the output file specification.
483272b676d7Smrg      link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
483372b676d7Smrg
483472b676d7Smrg      # Delete the old output files.
483572b676d7Smrg      $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname
483672b676d7Smrg
483772b676d7Smrg      $show "$link_command"
483872b676d7Smrg      $run eval "$link_command" || exit $?
483972b676d7Smrg
484072b676d7Smrg      # Now create the wrapper script.
484172b676d7Smrg      $show "creating $output"
484272b676d7Smrg
484372b676d7Smrg      # Quote the relink command for shipping.
484472b676d7Smrg      if test -n "$relink_command"; then
484572b676d7Smrg	# Preserve any variables that may affect compiler behavior
484672b676d7Smrg	for var in $variables_saved_for_relink; do
484772b676d7Smrg	  if eval test -z \"\${$var+set}\"; then
484872b676d7Smrg	    relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
484972b676d7Smrg	  elif eval var_value=\$$var; test -z "$var_value"; then
485072b676d7Smrg	    relink_command="$var=; export $var; $relink_command"
485172b676d7Smrg	  else
485272b676d7Smrg	    var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
485372b676d7Smrg	    relink_command="$var=\"$var_value\"; export $var; $relink_command"
485472b676d7Smrg	  fi
485572b676d7Smrg	done
485672b676d7Smrg	relink_command="(cd `pwd`; $relink_command)"
485772b676d7Smrg	relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
485872b676d7Smrg      fi
485972b676d7Smrg
486072b676d7Smrg      # Quote $echo for shipping.
486172b676d7Smrg      if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then
486272b676d7Smrg	case $progpath in
486372b676d7Smrg	[\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
486472b676d7Smrg	*) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
486572b676d7Smrg	esac
486672b676d7Smrg	qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"`
486772b676d7Smrg      else
486872b676d7Smrg	qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"`
486972b676d7Smrg      fi
487072b676d7Smrg
487172b676d7Smrg      # Only actually do things if our run command is non-null.
487272b676d7Smrg      if test -z "$run"; then
487372b676d7Smrg	# win32 will think the script is a binary if it has
487472b676d7Smrg	# a .exe suffix, so we strip it off here.
487572b676d7Smrg	case $output in
487672b676d7Smrg	  *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;;
487772b676d7Smrg	esac
487872b676d7Smrg	# test for cygwin because mv fails w/o .exe extensions
487972b676d7Smrg	case $host in
488072b676d7Smrg	  *cygwin*)
488172b676d7Smrg	    exeext=.exe
488272b676d7Smrg	    outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;;
488372b676d7Smrg	  *) exeext= ;;
488472b676d7Smrg	esac
488572b676d7Smrg	case $host in
488672b676d7Smrg	  *cygwin* | *mingw* )
488772b676d7Smrg            output_name=`basename $output`
488872b676d7Smrg            output_path=`dirname $output`
488972b676d7Smrg            cwrappersource="$output_path/$objdir/lt-$output_name.c"
489072b676d7Smrg            cwrapper="$output_path/$output_name.exe"
489172b676d7Smrg            $rm $cwrappersource $cwrapper
489272b676d7Smrg            trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
489372b676d7Smrg
489472b676d7Smrg	    cat > $cwrappersource <<EOF
489572b676d7Smrg
489672b676d7Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
489772b676d7Smrg   Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
489872b676d7Smrg
489972b676d7Smrg   The $output program cannot be directly executed until all the libtool
490072b676d7Smrg   libraries that it depends on are installed.
490172b676d7Smrg
490272b676d7Smrg   This wrapper executable should never be moved out of the build directory.
490372b676d7Smrg   If it is, it will not operate correctly.
490472b676d7Smrg
490572b676d7Smrg   Currently, it simply execs the wrapper *script* "/bin/sh $output",
490672b676d7Smrg   but could eventually absorb all of the scripts functionality and
490772b676d7Smrg   exec $objdir/$outputname directly.
490872b676d7Smrg*/
490972b676d7SmrgEOF
491072b676d7Smrg	    cat >> $cwrappersource<<"EOF"
491172b676d7Smrg#include <stdio.h>
491272b676d7Smrg#include <stdlib.h>
491372b676d7Smrg#include <unistd.h>
491472b676d7Smrg#include <malloc.h>
491572b676d7Smrg#include <stdarg.h>
491672b676d7Smrg#include <assert.h>
491772b676d7Smrg#include <string.h>
491872b676d7Smrg#include <ctype.h>
491972b676d7Smrg#include <sys/stat.h>
492072b676d7Smrg
492172b676d7Smrg#if defined(PATH_MAX)
492272b676d7Smrg# define LT_PATHMAX PATH_MAX
492372b676d7Smrg#elif defined(MAXPATHLEN)
492472b676d7Smrg# define LT_PATHMAX MAXPATHLEN
492572b676d7Smrg#else
492672b676d7Smrg# define LT_PATHMAX 1024
492772b676d7Smrg#endif
492872b676d7Smrg
492972b676d7Smrg#ifndef DIR_SEPARATOR
493072b676d7Smrg# define DIR_SEPARATOR '/'
493172b676d7Smrg# define PATH_SEPARATOR ':'
493272b676d7Smrg#endif
493372b676d7Smrg
493472b676d7Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
493572b676d7Smrg  defined (__OS2__)
493672b676d7Smrg# define HAVE_DOS_BASED_FILE_SYSTEM
493772b676d7Smrg# ifndef DIR_SEPARATOR_2
493872b676d7Smrg#  define DIR_SEPARATOR_2 '\\'
493972b676d7Smrg# endif
494072b676d7Smrg# ifndef PATH_SEPARATOR_2
494172b676d7Smrg#  define PATH_SEPARATOR_2 ';'
494272b676d7Smrg# endif
494372b676d7Smrg#endif
494472b676d7Smrg
494572b676d7Smrg#ifndef DIR_SEPARATOR_2
494672b676d7Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
494772b676d7Smrg#else /* DIR_SEPARATOR_2 */
494872b676d7Smrg# define IS_DIR_SEPARATOR(ch) \
494972b676d7Smrg        (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
495072b676d7Smrg#endif /* DIR_SEPARATOR_2 */
495172b676d7Smrg
495272b676d7Smrg#ifndef PATH_SEPARATOR_2
495372b676d7Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
495472b676d7Smrg#else /* PATH_SEPARATOR_2 */
495572b676d7Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
495672b676d7Smrg#endif /* PATH_SEPARATOR_2 */
495772b676d7Smrg
495872b676d7Smrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
495972b676d7Smrg#define XFREE(stale) do { \
496072b676d7Smrg  if (stale) { free ((void *) stale); stale = 0; } \
496172b676d7Smrg} while (0)
496272b676d7Smrg
496372b676d7Smrg/* -DDEBUG is fairly common in CFLAGS.  */
496472b676d7Smrg#undef DEBUG
496572b676d7Smrg#if defined DEBUGWRAPPER
496672b676d7Smrg# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
496772b676d7Smrg#else
496872b676d7Smrg# define DEBUG(format, ...)
496972b676d7Smrg#endif
497072b676d7Smrg
497172b676d7Smrgconst char *program_name = NULL;
497272b676d7Smrg
497372b676d7Smrgvoid * xmalloc (size_t num);
497472b676d7Smrgchar * xstrdup (const char *string);
497572b676d7Smrgconst char * base_name (const char *name);
497672b676d7Smrgchar * find_executable(const char *wrapper);
497772b676d7Smrgint    check_executable(const char *path);
497872b676d7Smrgchar * strendzap(char *str, const char *pat);
497972b676d7Smrgvoid lt_fatal (const char *message, ...);
498072b676d7Smrg
498172b676d7Smrgint
498272b676d7Smrgmain (int argc, char *argv[])
498372b676d7Smrg{
498472b676d7Smrg  char **newargz;
498572b676d7Smrg  int i;
498672b676d7Smrg
498772b676d7Smrg  program_name = (char *) xstrdup (base_name (argv[0]));
498872b676d7Smrg  DEBUG("(main) argv[0]      : %s\n",argv[0]);
498972b676d7Smrg  DEBUG("(main) program_name : %s\n",program_name);
499072b676d7Smrg  newargz = XMALLOC(char *, argc+2);
499172b676d7SmrgEOF
499272b676d7Smrg
499372b676d7Smrg            cat >> $cwrappersource <<EOF
499472b676d7Smrg  newargz[0] = (char *) xstrdup("$SHELL");
499572b676d7SmrgEOF
499672b676d7Smrg
499772b676d7Smrg            cat >> $cwrappersource <<"EOF"
499872b676d7Smrg  newargz[1] = find_executable(argv[0]);
499972b676d7Smrg  if (newargz[1] == NULL)
500072b676d7Smrg    lt_fatal("Couldn't find %s", argv[0]);
500172b676d7Smrg  DEBUG("(main) found exe at : %s\n",newargz[1]);
500272b676d7Smrg  /* we know the script has the same name, without the .exe */
500372b676d7Smrg  /* so make sure newargz[1] doesn't end in .exe */
500472b676d7Smrg  strendzap(newargz[1],".exe");
500572b676d7Smrg  for (i = 1; i < argc; i++)
500672b676d7Smrg    newargz[i+1] = xstrdup(argv[i]);
500772b676d7Smrg  newargz[argc+1] = NULL;
500872b676d7Smrg
500972b676d7Smrg  for (i=0; i<argc+1; i++)
501072b676d7Smrg  {
501172b676d7Smrg    DEBUG("(main) newargz[%d]   : %s\n",i,newargz[i]);
501272b676d7Smrg    ;
501372b676d7Smrg  }
501472b676d7Smrg
501572b676d7SmrgEOF
501672b676d7Smrg
501772b676d7Smrg            case $host_os in
501872b676d7Smrg              mingw*)
501972b676d7Smrg                cat >> $cwrappersource <<EOF
502072b676d7Smrg  execv("$SHELL",(char const **)newargz);
502172b676d7SmrgEOF
502272b676d7Smrg              ;;
502372b676d7Smrg              *)
502472b676d7Smrg                cat >> $cwrappersource <<EOF
502572b676d7Smrg  execv("$SHELL",newargz);
502672b676d7SmrgEOF
502772b676d7Smrg              ;;
502872b676d7Smrg            esac
502972b676d7Smrg
503072b676d7Smrg            cat >> $cwrappersource <<"EOF"
503172b676d7Smrg  return 127;
503272b676d7Smrg}
503372b676d7Smrg
503472b676d7Smrgvoid *
503572b676d7Smrgxmalloc (size_t num)
503672b676d7Smrg{
503772b676d7Smrg  void * p = (void *) malloc (num);
503872b676d7Smrg  if (!p)
503972b676d7Smrg    lt_fatal ("Memory exhausted");
504072b676d7Smrg
504172b676d7Smrg  return p;
504272b676d7Smrg}
504372b676d7Smrg
504472b676d7Smrgchar *
504572b676d7Smrgxstrdup (const char *string)
504672b676d7Smrg{
504772b676d7Smrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL
504872b676d7Smrg;
504972b676d7Smrg}
505072b676d7Smrg
505172b676d7Smrgconst char *
505272b676d7Smrgbase_name (const char *name)
505372b676d7Smrg{
505472b676d7Smrg  const char *base;
505572b676d7Smrg
505672b676d7Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
505772b676d7Smrg  /* Skip over the disk name in MSDOS pathnames. */
505872b676d7Smrg  if (isalpha ((unsigned char)name[0]) && name[1] == ':')
505972b676d7Smrg    name += 2;
506072b676d7Smrg#endif
506172b676d7Smrg
506272b676d7Smrg  for (base = name; *name; name++)
506372b676d7Smrg    if (IS_DIR_SEPARATOR (*name))
506472b676d7Smrg      base = name + 1;
506572b676d7Smrg  return base;
506672b676d7Smrg}
506772b676d7Smrg
506872b676d7Smrgint
506972b676d7Smrgcheck_executable(const char * path)
507072b676d7Smrg{
507172b676d7Smrg  struct stat st;
507272b676d7Smrg
507372b676d7Smrg  DEBUG("(check_executable)  : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!");
507472b676d7Smrg  if ((!path) || (!*path))
507572b676d7Smrg    return 0;
507672b676d7Smrg
507772b676d7Smrg  if ((stat (path, &st) >= 0) &&
507872b676d7Smrg      (
507972b676d7Smrg        /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */
508072b676d7Smrg#if defined (S_IXOTH)
508172b676d7Smrg       ((st.st_mode & S_IXOTH) == S_IXOTH) ||
508272b676d7Smrg#endif
508372b676d7Smrg#if defined (S_IXGRP)
508472b676d7Smrg       ((st.st_mode & S_IXGRP) == S_IXGRP) ||
508572b676d7Smrg#endif
508672b676d7Smrg       ((st.st_mode & S_IXUSR) == S_IXUSR))
508772b676d7Smrg      )
508872b676d7Smrg    return 1;
508972b676d7Smrg  else
509072b676d7Smrg    return 0;
509172b676d7Smrg}
509272b676d7Smrg
509372b676d7Smrg/* Searches for the full path of the wrapper.  Returns
509472b676d7Smrg   newly allocated full path name if found, NULL otherwise */
509572b676d7Smrgchar *
509672b676d7Smrgfind_executable (const char* wrapper)
509772b676d7Smrg{
509872b676d7Smrg  int has_slash = 0;
509972b676d7Smrg  const char* p;
510072b676d7Smrg  const char* p_next;
510172b676d7Smrg  /* static buffer for getcwd */
510272b676d7Smrg  char tmp[LT_PATHMAX + 1];
510372b676d7Smrg  int tmp_len;
510472b676d7Smrg  char* concat_name;
510572b676d7Smrg
510672b676d7Smrg  DEBUG("(find_executable)  : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!");
510772b676d7Smrg
510872b676d7Smrg  if ((wrapper == NULL) || (*wrapper == '\0'))
510972b676d7Smrg    return NULL;
511072b676d7Smrg
511172b676d7Smrg  /* Absolute path? */
511272b676d7Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
511372b676d7Smrg  if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':')
511472b676d7Smrg  {
511572b676d7Smrg    concat_name = xstrdup (wrapper);
511672b676d7Smrg    if (check_executable(concat_name))
511772b676d7Smrg      return concat_name;
511872b676d7Smrg    XFREE(concat_name);
511972b676d7Smrg  }
512072b676d7Smrg  else
512172b676d7Smrg  {
512272b676d7Smrg#endif
512372b676d7Smrg    if (IS_DIR_SEPARATOR (wrapper[0]))
512472b676d7Smrg    {
512572b676d7Smrg      concat_name = xstrdup (wrapper);
512672b676d7Smrg      if (check_executable(concat_name))
512772b676d7Smrg        return concat_name;
512872b676d7Smrg      XFREE(concat_name);
512972b676d7Smrg    }
513072b676d7Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
513172b676d7Smrg  }
513272b676d7Smrg#endif
513372b676d7Smrg
513472b676d7Smrg  for (p = wrapper; *p; p++)
513572b676d7Smrg    if (*p == '/')
513672b676d7Smrg    {
513772b676d7Smrg      has_slash = 1;
513872b676d7Smrg      break;
513972b676d7Smrg    }
514072b676d7Smrg  if (!has_slash)
514172b676d7Smrg  {
514272b676d7Smrg    /* no slashes; search PATH */
514372b676d7Smrg    const char* path = getenv ("PATH");
514472b676d7Smrg    if (path != NULL)
514572b676d7Smrg    {
514672b676d7Smrg      for (p = path; *p; p = p_next)
514772b676d7Smrg      {
514872b676d7Smrg        const char* q;
514972b676d7Smrg        size_t p_len;
515072b676d7Smrg        for (q = p; *q; q++)
515172b676d7Smrg          if (IS_PATH_SEPARATOR(*q))
515272b676d7Smrg            break;
515372b676d7Smrg        p_len = q - p;
515472b676d7Smrg        p_next = (*q == '\0' ? q : q + 1);
515572b676d7Smrg        if (p_len == 0)
515672b676d7Smrg        {
515772b676d7Smrg          /* empty path: current directory */
515872b676d7Smrg          if (getcwd (tmp, LT_PATHMAX) == NULL)
515972b676d7Smrg            lt_fatal ("getcwd failed");
516072b676d7Smrg          tmp_len = strlen(tmp);
516172b676d7Smrg          concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
516272b676d7Smrg          memcpy (concat_name, tmp, tmp_len);
516372b676d7Smrg          concat_name[tmp_len] = '/';
516472b676d7Smrg          strcpy (concat_name + tmp_len + 1, wrapper);
516572b676d7Smrg        }
516672b676d7Smrg        else
516772b676d7Smrg        {
516872b676d7Smrg          concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1);
516972b676d7Smrg          memcpy (concat_name, p, p_len);
517072b676d7Smrg          concat_name[p_len] = '/';
517172b676d7Smrg          strcpy (concat_name + p_len + 1, wrapper);
517272b676d7Smrg        }
517372b676d7Smrg        if (check_executable(concat_name))
517472b676d7Smrg          return concat_name;
517572b676d7Smrg        XFREE(concat_name);
517672b676d7Smrg      }
517772b676d7Smrg    }
517872b676d7Smrg    /* not found in PATH; assume curdir */
517972b676d7Smrg  }
518072b676d7Smrg  /* Relative path | not found in path: prepend cwd */
518172b676d7Smrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
518272b676d7Smrg    lt_fatal ("getcwd failed");
518372b676d7Smrg  tmp_len = strlen(tmp);
518472b676d7Smrg  concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
518572b676d7Smrg  memcpy (concat_name, tmp, tmp_len);
518672b676d7Smrg  concat_name[tmp_len] = '/';
518772b676d7Smrg  strcpy (concat_name + tmp_len + 1, wrapper);
518872b676d7Smrg
518972b676d7Smrg  if (check_executable(concat_name))
519072b676d7Smrg    return concat_name;
519172b676d7Smrg  XFREE(concat_name);
519272b676d7Smrg  return NULL;
519372b676d7Smrg}
519472b676d7Smrg
519572b676d7Smrgchar *
519672b676d7Smrgstrendzap(char *str, const char *pat)
519772b676d7Smrg{
519872b676d7Smrg  size_t len, patlen;
519972b676d7Smrg
520072b676d7Smrg  assert(str != NULL);
520172b676d7Smrg  assert(pat != NULL);
520272b676d7Smrg
520372b676d7Smrg  len = strlen(str);
520472b676d7Smrg  patlen = strlen(pat);
520572b676d7Smrg
520672b676d7Smrg  if (patlen <= len)
520772b676d7Smrg  {
520872b676d7Smrg    str += len - patlen;
520972b676d7Smrg    if (strcmp(str, pat) == 0)
521072b676d7Smrg      *str = '\0';
521172b676d7Smrg  }
521272b676d7Smrg  return str;
521372b676d7Smrg}
521472b676d7Smrg
521572b676d7Smrgstatic void
521672b676d7Smrglt_error_core (int exit_status, const char * mode,
521772b676d7Smrg          const char * message, va_list ap)
521872b676d7Smrg{
521972b676d7Smrg  fprintf (stderr, "%s: %s: ", program_name, mode);
522072b676d7Smrg  vfprintf (stderr, message, ap);
522172b676d7Smrg  fprintf (stderr, ".\n");
522272b676d7Smrg
522372b676d7Smrg  if (exit_status >= 0)
522472b676d7Smrg    exit (exit_status);
522572b676d7Smrg}
522672b676d7Smrg
522772b676d7Smrgvoid
522872b676d7Smrglt_fatal (const char *message, ...)
522972b676d7Smrg{
523072b676d7Smrg  va_list ap;
523172b676d7Smrg  va_start (ap, message);
523272b676d7Smrg  lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
523372b676d7Smrg  va_end (ap);
523472b676d7Smrg}
523572b676d7SmrgEOF
523672b676d7Smrg          # we should really use a build-platform specific compiler
523772b676d7Smrg          # here, but OTOH, the wrappers (shell script and this C one)
523872b676d7Smrg          # are only useful if you want to execute the "real" binary.
523972b676d7Smrg          # Since the "real" binary is built for $host, then this
524072b676d7Smrg          # wrapper might as well be built for $host, too.
524172b676d7Smrg          $run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource
524272b676d7Smrg          ;;
524372b676d7Smrg        esac
524472b676d7Smrg        $rm $output
524572b676d7Smrg        trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
524672b676d7Smrg
524772b676d7Smrg	$echo > $output "\
524872b676d7Smrg#! $SHELL
524972b676d7Smrg
525072b676d7Smrg# $output - temporary wrapper script for $objdir/$outputname
525172b676d7Smrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
525272b676d7Smrg#
525372b676d7Smrg# The $output program cannot be directly executed until all the libtool
525472b676d7Smrg# libraries that it depends on are installed.
525572b676d7Smrg#
525672b676d7Smrg# This wrapper script should never be moved out of the build directory.
525772b676d7Smrg# If it is, it will not operate correctly.
525872b676d7Smrg
525972b676d7Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
526072b676d7Smrg# metacharacters that are still active within double-quoted strings.
526172b676d7SmrgXsed='${SED} -e 1s/^X//'
526272b676d7Smrgsed_quote_subst='$sed_quote_subst'
526372b676d7Smrg
526472b676d7Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout
526572b676d7Smrg# if CDPATH is set.
526672b676d7Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
526772b676d7Smrg
526872b676d7Smrgrelink_command=\"$relink_command\"
526972b676d7Smrg
527072b676d7Smrg# This environment variable determines our operation mode.
527172b676d7Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then
527272b676d7Smrg  # install mode needs the following variable:
527372b676d7Smrg  notinst_deplibs='$notinst_deplibs'
527472b676d7Smrgelse
527572b676d7Smrg  # When we are sourced in execute mode, \$file and \$echo are already set.
527672b676d7Smrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
527772b676d7Smrg    echo=\"$qecho\"
527872b676d7Smrg    file=\"\$0\"
527972b676d7Smrg    # Make sure echo works.
528072b676d7Smrg    if test \"X\$1\" = X--no-reexec; then
528172b676d7Smrg      # Discard the --no-reexec flag, and continue.
528272b676d7Smrg      shift
528372b676d7Smrg    elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then
528472b676d7Smrg      # Yippee, \$echo works!
528572b676d7Smrg      :
528672b676d7Smrg    else
528772b676d7Smrg      # Restart under the correct shell, and then maybe \$echo will work.
528872b676d7Smrg      exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
528972b676d7Smrg    fi
529072b676d7Smrg  fi\
529172b676d7Smrg"
529272b676d7Smrg	$echo >> $output "\
529372b676d7Smrg
529472b676d7Smrg  # Find the directory that this script lives in.
529572b676d7Smrg  thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
529672b676d7Smrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
529772b676d7Smrg
529872b676d7Smrg  # Follow symbolic links until we get to the real thisdir.
529972b676d7Smrg  file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
530072b676d7Smrg  while test -n \"\$file\"; do
530172b676d7Smrg    destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
530272b676d7Smrg
530372b676d7Smrg    # If there was a directory component, then change thisdir.
530472b676d7Smrg    if test \"x\$destdir\" != \"x\$file\"; then
530572b676d7Smrg      case \"\$destdir\" in
530672b676d7Smrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
530772b676d7Smrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
530872b676d7Smrg      esac
530972b676d7Smrg    fi
531072b676d7Smrg
531172b676d7Smrg    file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
531272b676d7Smrg    file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
531372b676d7Smrg  done
531472b676d7Smrg
531572b676d7Smrg  # Try to get the absolute directory name.
531672b676d7Smrg  absdir=\`cd \"\$thisdir\" && pwd\`
531772b676d7Smrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
531872b676d7Smrg"
531972b676d7Smrg
532072b676d7Smrg	if test "$fast_install" = yes; then
532172b676d7Smrg	  $echo >> $output "\
532272b676d7Smrg  program=lt-'$outputname'$exeext
532372b676d7Smrg  progdir=\"\$thisdir/$objdir\"
532472b676d7Smrg
532572b676d7Smrg  if test ! -f \"\$progdir/\$program\" || \\
532672b676d7Smrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
532772b676d7Smrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
532872b676d7Smrg
532972b676d7Smrg    file=\"\$\$-\$program\"
533072b676d7Smrg
533172b676d7Smrg    if test ! -d \"\$progdir\"; then
533272b676d7Smrg      $mkdir \"\$progdir\"
533372b676d7Smrg    else
533472b676d7Smrg      $rm \"\$progdir/\$file\"
533572b676d7Smrg    fi"
533672b676d7Smrg
533772b676d7Smrg	  $echo >> $output "\
533872b676d7Smrg
533972b676d7Smrg    # relink executable if necessary
534072b676d7Smrg    if test -n \"\$relink_command\"; then
534172b676d7Smrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
534272b676d7Smrg      else
534372b676d7Smrg	$echo \"\$relink_command_output\" >&2
534472b676d7Smrg	$rm \"\$progdir/\$file\"
534572b676d7Smrg	exit $EXIT_FAILURE
534672b676d7Smrg      fi
534772b676d7Smrg    fi
534872b676d7Smrg
534972b676d7Smrg    $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
535072b676d7Smrg    { $rm \"\$progdir/\$program\";
535172b676d7Smrg      $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
535272b676d7Smrg    $rm \"\$progdir/\$file\"
535372b676d7Smrg  fi"
535472b676d7Smrg	else
535572b676d7Smrg	  $echo >> $output "\
535672b676d7Smrg  program='$outputname'
535772b676d7Smrg  progdir=\"\$thisdir/$objdir\"
535872b676d7Smrg"
535972b676d7Smrg	fi
536072b676d7Smrg
536172b676d7Smrg	$echo >> $output "\
536272b676d7Smrg
536372b676d7Smrg  if test -f \"\$progdir/\$program\"; then"
536472b676d7Smrg
536572b676d7Smrg	# Export our shlibpath_var if we have one.
536672b676d7Smrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
536772b676d7Smrg	  $echo >> $output "\
536872b676d7Smrg    # Add our own library path to $shlibpath_var
536972b676d7Smrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
537072b676d7Smrg
537172b676d7Smrg    # Some systems cannot cope with colon-terminated $shlibpath_var
537272b676d7Smrg    # The second colon is a workaround for a bug in BeOS R4 sed
537372b676d7Smrg    $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
537472b676d7Smrg
537572b676d7Smrg    export $shlibpath_var
537672b676d7Smrg"
537772b676d7Smrg	fi
537872b676d7Smrg
537972b676d7Smrg	# fixup the dll searchpath if we need to.
538072b676d7Smrg	if test -n "$dllsearchpath"; then
538172b676d7Smrg	  $echo >> $output "\
538272b676d7Smrg    # Add the dll search path components to the executable PATH
538372b676d7Smrg    PATH=$dllsearchpath:\$PATH
538472b676d7Smrg"
538572b676d7Smrg	fi
538672b676d7Smrg
538772b676d7Smrg	$echo >> $output "\
538872b676d7Smrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
538972b676d7Smrg      # Run the actual program with our arguments.
539072b676d7Smrg"
539172b676d7Smrg	case $host in
539272b676d7Smrg	# Backslashes separate directories on plain windows
539372b676d7Smrg	*-*-mingw | *-*-os2*)
539472b676d7Smrg	  $echo >> $output "\
539572b676d7Smrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
539672b676d7Smrg"
539772b676d7Smrg	  ;;
539872b676d7Smrg
539972b676d7Smrg	*)
540072b676d7Smrg	  $echo >> $output "\
540172b676d7Smrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
540272b676d7Smrg"
540372b676d7Smrg	  ;;
540472b676d7Smrg	esac
540572b676d7Smrg	$echo >> $output "\
540672b676d7Smrg      \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\"
540772b676d7Smrg      exit $EXIT_FAILURE
540872b676d7Smrg    fi
540972b676d7Smrg  else
541072b676d7Smrg    # The program doesn't exist.
541172b676d7Smrg    \$echo \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
541272b676d7Smrg    \$echo \"This script is just a wrapper for \$program.\" 1>&2
541372b676d7Smrg    $echo \"See the $PACKAGE documentation for more information.\" 1>&2
541472b676d7Smrg    exit $EXIT_FAILURE
541572b676d7Smrg  fi
541672b676d7Smrgfi\
541772b676d7Smrg"
541872b676d7Smrg	chmod +x $output
541972b676d7Smrg      fi
542072b676d7Smrg      exit $EXIT_SUCCESS
542172b676d7Smrg      ;;
542272b676d7Smrg    esac
542372b676d7Smrg
542472b676d7Smrg    # See if we need to build an old-fashioned archive.
542572b676d7Smrg    for oldlib in $oldlibs; do
542672b676d7Smrg
542772b676d7Smrg      if test "$build_libtool_libs" = convenience; then
542872b676d7Smrg	oldobjs="$libobjs_save"
542972b676d7Smrg	addlibs="$convenience"
543072b676d7Smrg	build_libtool_libs=no
543172b676d7Smrg      else
543272b676d7Smrg	if test "$build_libtool_libs" = module; then
543372b676d7Smrg	  oldobjs="$libobjs_save"
543472b676d7Smrg	  build_libtool_libs=no
543572b676d7Smrg	else
543672b676d7Smrg	  oldobjs="$old_deplibs $non_pic_objects"
543772b676d7Smrg	fi
543872b676d7Smrg	addlibs="$old_convenience"
543972b676d7Smrg      fi
544072b676d7Smrg
544172b676d7Smrg      if test -n "$addlibs"; then
544272b676d7Smrg	gentop="$output_objdir/${outputname}x"
544372b676d7Smrg	generated="$generated $gentop"
544472b676d7Smrg
544572b676d7Smrg	func_extract_archives $gentop $addlibs
544672b676d7Smrg	oldobjs="$oldobjs $func_extract_archives_result"
544772b676d7Smrg      fi
544872b676d7Smrg
544972b676d7Smrg      # Do each command in the archive commands.
545072b676d7Smrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
545172b676d7Smrg       cmds=$old_archive_from_new_cmds
545272b676d7Smrg      else
545372b676d7Smrg	# POSIX demands no paths to be encoded in archives.  We have
545472b676d7Smrg	# to avoid creating archives with duplicate basenames if we
545572b676d7Smrg	# might have to extract them afterwards, e.g., when creating a
545672b676d7Smrg	# static archive out of a convenience library, or when linking
545772b676d7Smrg	# the entirety of a libtool archive into another (currently
545872b676d7Smrg	# not supported by libtool).
545972b676d7Smrg	if (for obj in $oldobjs
546072b676d7Smrg	    do
546172b676d7Smrg	      $echo "X$obj" | $Xsed -e 's%^.*/%%'
546272b676d7Smrg	    done | sort | sort -uc >/dev/null 2>&1); then
546372b676d7Smrg	  :
546472b676d7Smrg	else
546572b676d7Smrg	  $echo "copying selected object files to avoid basename conflicts..."
546672b676d7Smrg
546772b676d7Smrg	  if test -z "$gentop"; then
546872b676d7Smrg	    gentop="$output_objdir/${outputname}x"
546972b676d7Smrg	    generated="$generated $gentop"
547072b676d7Smrg
547172b676d7Smrg	    $show "${rm}r $gentop"
547272b676d7Smrg	    $run ${rm}r "$gentop"
547372b676d7Smrg	    $show "$mkdir $gentop"
547472b676d7Smrg	    $run $mkdir "$gentop"
547572b676d7Smrg	    exit_status=$?
547672b676d7Smrg	    if test "$exit_status" -ne 0 && test ! -d "$gentop"; then
547772b676d7Smrg	      exit $exit_status
547872b676d7Smrg	    fi
547972b676d7Smrg	  fi
548072b676d7Smrg
548172b676d7Smrg	  save_oldobjs=$oldobjs
548272b676d7Smrg	  oldobjs=
548372b676d7Smrg	  counter=1
548472b676d7Smrg	  for obj in $save_oldobjs
548572b676d7Smrg	  do
548672b676d7Smrg	    objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
548772b676d7Smrg	    case " $oldobjs " in
548872b676d7Smrg	    " ") oldobjs=$obj ;;
548972b676d7Smrg	    *[\ /]"$objbase "*)
549072b676d7Smrg	      while :; do
549172b676d7Smrg		# Make sure we don't pick an alternate name that also
549272b676d7Smrg		# overlaps.
549372b676d7Smrg		newobj=lt$counter-$objbase
549472b676d7Smrg		counter=`expr $counter + 1`
549572b676d7Smrg		case " $oldobjs " in
549672b676d7Smrg		*[\ /]"$newobj "*) ;;
549772b676d7Smrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
549872b676d7Smrg		esac
549972b676d7Smrg	      done
550072b676d7Smrg	      $show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
550172b676d7Smrg	      $run ln "$obj" "$gentop/$newobj" ||
550272b676d7Smrg	      $run cp "$obj" "$gentop/$newobj"
550372b676d7Smrg	      oldobjs="$oldobjs $gentop/$newobj"
550472b676d7Smrg	      ;;
550572b676d7Smrg	    *) oldobjs="$oldobjs $obj" ;;
550672b676d7Smrg	    esac
550772b676d7Smrg	  done
550872b676d7Smrg	fi
550972b676d7Smrg
551072b676d7Smrg	eval cmds=\"$old_archive_cmds\"
551172b676d7Smrg
551272b676d7Smrg	if len=`expr "X$cmds" : ".*"` &&
551372b676d7Smrg	     test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
551472b676d7Smrg	  cmds=$old_archive_cmds
551572b676d7Smrg	else
551672b676d7Smrg	  # the command line is too long to link in one step, link in parts
551772b676d7Smrg	  $echo "using piecewise archive linking..."
551872b676d7Smrg	  save_RANLIB=$RANLIB
551972b676d7Smrg	  RANLIB=:
552072b676d7Smrg	  objlist=
552172b676d7Smrg	  concat_cmds=
552272b676d7Smrg	  save_oldobjs=$oldobjs
552372b676d7Smrg
552472b676d7Smrg	  # Is there a better way of finding the last object in the list?
552572b676d7Smrg	  for obj in $save_oldobjs
552672b676d7Smrg	  do
552772b676d7Smrg	    last_oldobj=$obj
552872b676d7Smrg	  done
552972b676d7Smrg	  for obj in $save_oldobjs
553072b676d7Smrg	  do
553172b676d7Smrg	    oldobjs="$objlist $obj"
553272b676d7Smrg	    objlist="$objlist $obj"
553372b676d7Smrg	    eval test_cmds=\"$old_archive_cmds\"
553472b676d7Smrg	    if len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
553572b676d7Smrg	       test "$len" -le "$max_cmd_len"; then
553672b676d7Smrg	      :
553772b676d7Smrg	    else
553872b676d7Smrg	      # the above command should be used before it gets too long
553972b676d7Smrg	      oldobjs=$objlist
554072b676d7Smrg	      if test "$obj" = "$last_oldobj" ; then
554172b676d7Smrg	        RANLIB=$save_RANLIB
554272b676d7Smrg	      fi
554372b676d7Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
554472b676d7Smrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
554572b676d7Smrg	      objlist=
554672b676d7Smrg	    fi
554772b676d7Smrg	  done
554872b676d7Smrg	  RANLIB=$save_RANLIB
554972b676d7Smrg	  oldobjs=$objlist
555072b676d7Smrg	  if test "X$oldobjs" = "X" ; then
555172b676d7Smrg	    eval cmds=\"\$concat_cmds\"
555272b676d7Smrg	  else
555372b676d7Smrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
555472b676d7Smrg	  fi
555572b676d7Smrg	fi
555672b676d7Smrg      fi
555772b676d7Smrg      save_ifs="$IFS"; IFS='~'
555872b676d7Smrg      for cmd in $cmds; do
555972b676d7Smrg        eval cmd=\"$cmd\"
556072b676d7Smrg	IFS="$save_ifs"
556172b676d7Smrg	$show "$cmd"
556272b676d7Smrg	$run eval "$cmd" || exit $?
556372b676d7Smrg      done
556472b676d7Smrg      IFS="$save_ifs"
556572b676d7Smrg    done
556672b676d7Smrg
556772b676d7Smrg    if test -n "$generated"; then
556872b676d7Smrg      $show "${rm}r$generated"
556972b676d7Smrg      $run ${rm}r$generated
557072b676d7Smrg    fi
557172b676d7Smrg
557272b676d7Smrg    # Now create the libtool archive.
557372b676d7Smrg    case $output in
557472b676d7Smrg    *.la)
557572b676d7Smrg      old_library=
557672b676d7Smrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
557772b676d7Smrg      $show "creating $output"
557872b676d7Smrg
557972b676d7Smrg      # Preserve any variables that may affect compiler behavior
558072b676d7Smrg      for var in $variables_saved_for_relink; do
558172b676d7Smrg	if eval test -z \"\${$var+set}\"; then
558272b676d7Smrg	  relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
558372b676d7Smrg	elif eval var_value=\$$var; test -z "$var_value"; then
558472b676d7Smrg	  relink_command="$var=; export $var; $relink_command"
558572b676d7Smrg	else
558672b676d7Smrg	  var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
558772b676d7Smrg	  relink_command="$var=\"$var_value\"; export $var; $relink_command"
558872b676d7Smrg	fi
558972b676d7Smrg      done
559072b676d7Smrg      # Quote the link command for shipping.
559172b676d7Smrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
559272b676d7Smrg      relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
559372b676d7Smrg      if test "$hardcode_automatic" = yes ; then
559472b676d7Smrg	relink_command=
559572b676d7Smrg      fi
559672b676d7Smrg
559772b676d7Smrg
559872b676d7Smrg      # Only create the output if not a dry run.
559972b676d7Smrg      if test -z "$run"; then
560072b676d7Smrg	for installed in no yes; do
560172b676d7Smrg	  if test "$installed" = yes; then
560272b676d7Smrg	    if test -z "$install_libdir"; then
560372b676d7Smrg	      break
560472b676d7Smrg	    fi
560572b676d7Smrg	    output="$output_objdir/$outputname"i
560672b676d7Smrg	    # Replace all uninstalled libtool libraries with the installed ones
560772b676d7Smrg	    newdependency_libs=
560872b676d7Smrg	    for deplib in $dependency_libs; do
560972b676d7Smrg	      case $deplib in
561072b676d7Smrg	      *.la)
561172b676d7Smrg		name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'`
561272b676d7Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
561372b676d7Smrg		if test -z "$libdir"; then
561472b676d7Smrg		  $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
561572b676d7Smrg		  exit $EXIT_FAILURE
561672b676d7Smrg		fi
561772b676d7Smrg		newdependency_libs="$newdependency_libs $libdir/$name"
561872b676d7Smrg		;;
561972b676d7Smrg	      *) newdependency_libs="$newdependency_libs $deplib" ;;
562072b676d7Smrg	      esac
562172b676d7Smrg	    done
562272b676d7Smrg	    dependency_libs="$newdependency_libs"
562372b676d7Smrg	    newdlfiles=
562472b676d7Smrg	    for lib in $dlfiles; do
562572b676d7Smrg	      name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
562672b676d7Smrg	      eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
562772b676d7Smrg	      if test -z "$libdir"; then
562872b676d7Smrg		$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
562972b676d7Smrg		exit $EXIT_FAILURE
563072b676d7Smrg	      fi
563172b676d7Smrg	      newdlfiles="$newdlfiles $libdir/$name"
563272b676d7Smrg	    done
563372b676d7Smrg	    dlfiles="$newdlfiles"
563472b676d7Smrg	    newdlprefiles=
563572b676d7Smrg	    for lib in $dlprefiles; do
563672b676d7Smrg	      name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
563772b676d7Smrg	      eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
563872b676d7Smrg	      if test -z "$libdir"; then
563972b676d7Smrg		$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
564072b676d7Smrg		exit $EXIT_FAILURE
564172b676d7Smrg	      fi
564272b676d7Smrg	      newdlprefiles="$newdlprefiles $libdir/$name"
564372b676d7Smrg	    done
564472b676d7Smrg	    dlprefiles="$newdlprefiles"
564572b676d7Smrg	  else
564672b676d7Smrg	    newdlfiles=
564772b676d7Smrg	    for lib in $dlfiles; do
564872b676d7Smrg	      case $lib in
564972b676d7Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
565072b676d7Smrg		*) abs=`pwd`"/$lib" ;;
565172b676d7Smrg	      esac
565272b676d7Smrg	      newdlfiles="$newdlfiles $abs"
565372b676d7Smrg	    done
565472b676d7Smrg	    dlfiles="$newdlfiles"
565572b676d7Smrg	    newdlprefiles=
565672b676d7Smrg	    for lib in $dlprefiles; do
565772b676d7Smrg	      case $lib in
565872b676d7Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
565972b676d7Smrg		*) abs=`pwd`"/$lib" ;;
566072b676d7Smrg	      esac
566172b676d7Smrg	      newdlprefiles="$newdlprefiles $abs"
566272b676d7Smrg	    done
566372b676d7Smrg	    dlprefiles="$newdlprefiles"
566472b676d7Smrg	  fi
566572b676d7Smrg	  $rm $output
566672b676d7Smrg	  # place dlname in correct position for cygwin
566772b676d7Smrg	  tdlname=$dlname
566872b676d7Smrg	  case $host,$output,$installed,$module,$dlname in
566972b676d7Smrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
567072b676d7Smrg	  esac
567172b676d7Smrg	  $echo > $output "\
567272b676d7Smrg# $outputname - a libtool library file
567372b676d7Smrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
567472b676d7Smrg#
567572b676d7Smrg# Please DO NOT delete this file!
567672b676d7Smrg# It is necessary for linking the library.
567772b676d7Smrg
567872b676d7Smrg# The name that we can dlopen(3).
567972b676d7Smrgdlname='$tdlname'
568072b676d7Smrg
568172b676d7Smrg# Names of this library.
568272b676d7Smrglibrary_names='$library_names'
568372b676d7Smrg
568472b676d7Smrg# The name of the static archive.
568572b676d7Smrgold_library='$old_library'
568672b676d7Smrg
568772b676d7Smrg# Libraries that this one depends upon.
568872b676d7Smrgdependency_libs='$dependency_libs'
568972b676d7Smrg
569072b676d7Smrg# Version information for $libname.
569172b676d7Smrgcurrent=$current
569272b676d7Smrgage=$age
569372b676d7Smrgrevision=$revision
569472b676d7Smrg
569572b676d7Smrg# Is this an already installed library?
569672b676d7Smrginstalled=$installed
569772b676d7Smrg
569872b676d7Smrg# Should we warn about portability when linking against -modules?
569972b676d7Smrgshouldnotlink=$module
570072b676d7Smrg
570172b676d7Smrg# Files to dlopen/dlpreopen
570272b676d7Smrgdlopen='$dlfiles'
570372b676d7Smrgdlpreopen='$dlprefiles'
570472b676d7Smrg
570572b676d7Smrg# Directory that this library needs to be installed in:
570672b676d7Smrglibdir='$install_libdir'"
570772b676d7Smrg	  if test "$installed" = no && test "$need_relink" = yes; then
570872b676d7Smrg	    $echo >> $output "\
570972b676d7Smrgrelink_command=\"$relink_command\""
571072b676d7Smrg	  fi
571172b676d7Smrg	done
571272b676d7Smrg      fi
571372b676d7Smrg
571472b676d7Smrg      # Do a symbolic link so that the libtool archive can be found in
571572b676d7Smrg      # LD_LIBRARY_PATH before the program is installed.
571672b676d7Smrg      $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)"
571772b676d7Smrg      $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $?
571872b676d7Smrg      ;;
571972b676d7Smrg    esac
572072b676d7Smrg    exit $EXIT_SUCCESS
572172b676d7Smrg    ;;
572272b676d7Smrg
572372b676d7Smrg  # libtool install mode
572472b676d7Smrg  install)
572572b676d7Smrg    modename="$modename: install"
572672b676d7Smrg
572772b676d7Smrg    # There may be an optional sh(1) argument at the beginning of
572872b676d7Smrg    # install_prog (especially on Windows NT).
572972b676d7Smrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
573072b676d7Smrg       # Allow the use of GNU shtool's install command.
573172b676d7Smrg       $echo "X$nonopt" | grep shtool > /dev/null; then
573272b676d7Smrg      # Aesthetically quote it.
573372b676d7Smrg      arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"`
573472b676d7Smrg      case $arg in
573572b676d7Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
573672b676d7Smrg	arg="\"$arg\""
573772b676d7Smrg	;;
573872b676d7Smrg      esac
573972b676d7Smrg      install_prog="$arg "
574072b676d7Smrg      arg="$1"
574172b676d7Smrg      shift
574272b676d7Smrg    else
574372b676d7Smrg      install_prog=
574472b676d7Smrg      arg=$nonopt
574572b676d7Smrg    fi
574672b676d7Smrg
574772b676d7Smrg    # The real first argument should be the name of the installation program.
574872b676d7Smrg    # Aesthetically quote it.
574972b676d7Smrg    arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
575072b676d7Smrg    case $arg in
575172b676d7Smrg    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
575272b676d7Smrg      arg="\"$arg\""
575372b676d7Smrg      ;;
575472b676d7Smrg    esac
575572b676d7Smrg    install_prog="$install_prog$arg"
575672b676d7Smrg
575772b676d7Smrg    # We need to accept at least all the BSD install flags.
575872b676d7Smrg    dest=
575972b676d7Smrg    files=
576072b676d7Smrg    opts=
576172b676d7Smrg    prev=
576272b676d7Smrg    install_type=
576372b676d7Smrg    isdir=no
576472b676d7Smrg    stripme=
576572b676d7Smrg    for arg
576672b676d7Smrg    do
576772b676d7Smrg      if test -n "$dest"; then
576872b676d7Smrg	files="$files $dest"
576972b676d7Smrg	dest=$arg
577072b676d7Smrg	continue
577172b676d7Smrg      fi
577272b676d7Smrg
577372b676d7Smrg      case $arg in
577472b676d7Smrg      -d) isdir=yes ;;
577572b676d7Smrg      -f) 
577672b676d7Smrg      	case " $install_prog " in
577772b676d7Smrg	*[\\\ /]cp\ *) ;;
577872b676d7Smrg	*) prev=$arg ;;
577972b676d7Smrg	esac
578072b676d7Smrg	;;
578172b676d7Smrg      -g | -m | -o) prev=$arg ;;
578272b676d7Smrg      -s)
578372b676d7Smrg	stripme=" -s"
578472b676d7Smrg	continue
578572b676d7Smrg	;;
578672b676d7Smrg      -*)
578772b676d7Smrg	;;
578872b676d7Smrg      *)
578972b676d7Smrg	# If the previous option needed an argument, then skip it.
579072b676d7Smrg	if test -n "$prev"; then
579172b676d7Smrg	  prev=
579272b676d7Smrg	else
579372b676d7Smrg	  dest=$arg
579472b676d7Smrg	  continue
579572b676d7Smrg	fi
579672b676d7Smrg	;;
579772b676d7Smrg      esac
579872b676d7Smrg
579972b676d7Smrg      # Aesthetically quote the argument.
580072b676d7Smrg      arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
580172b676d7Smrg      case $arg in
580272b676d7Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
580372b676d7Smrg	arg="\"$arg\""
580472b676d7Smrg	;;
580572b676d7Smrg      esac
580672b676d7Smrg      install_prog="$install_prog $arg"
580772b676d7Smrg    done
580872b676d7Smrg
580972b676d7Smrg    if test -z "$install_prog"; then
581072b676d7Smrg      $echo "$modename: you must specify an install program" 1>&2
581172b676d7Smrg      $echo "$help" 1>&2
581272b676d7Smrg      exit $EXIT_FAILURE
581372b676d7Smrg    fi
581472b676d7Smrg
581572b676d7Smrg    if test -n "$prev"; then
581672b676d7Smrg      $echo "$modename: the \`$prev' option requires an argument" 1>&2
581772b676d7Smrg      $echo "$help" 1>&2
581872b676d7Smrg      exit $EXIT_FAILURE
581972b676d7Smrg    fi
582072b676d7Smrg
582172b676d7Smrg    if test -z "$files"; then
582272b676d7Smrg      if test -z "$dest"; then
582372b676d7Smrg	$echo "$modename: no file or destination specified" 1>&2
582472b676d7Smrg      else
582572b676d7Smrg	$echo "$modename: you must specify a destination" 1>&2
582672b676d7Smrg      fi
582772b676d7Smrg      $echo "$help" 1>&2
582872b676d7Smrg      exit $EXIT_FAILURE
582972b676d7Smrg    fi
583072b676d7Smrg
583172b676d7Smrg    # Strip any trailing slash from the destination.
583272b676d7Smrg    dest=`$echo "X$dest" | $Xsed -e 's%/$%%'`
583372b676d7Smrg
583472b676d7Smrg    # Check to see that the destination is a directory.
583572b676d7Smrg    test -d "$dest" && isdir=yes
583672b676d7Smrg    if test "$isdir" = yes; then
583772b676d7Smrg      destdir="$dest"
583872b676d7Smrg      destname=
583972b676d7Smrg    else
584072b676d7Smrg      destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'`
584172b676d7Smrg      test "X$destdir" = "X$dest" && destdir=.
584272b676d7Smrg      destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'`
584372b676d7Smrg
584472b676d7Smrg      # Not a directory, so check to see that there is only one file specified.
584572b676d7Smrg      set dummy $files
584672b676d7Smrg      if test "$#" -gt 2; then
584772b676d7Smrg	$echo "$modename: \`$dest' is not a directory" 1>&2
584872b676d7Smrg	$echo "$help" 1>&2
584972b676d7Smrg	exit $EXIT_FAILURE
585072b676d7Smrg      fi
585172b676d7Smrg    fi
585272b676d7Smrg    case $destdir in
585372b676d7Smrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
585472b676d7Smrg    *)
585572b676d7Smrg      for file in $files; do
585672b676d7Smrg	case $file in
585772b676d7Smrg	*.lo) ;;
585872b676d7Smrg	*)
585972b676d7Smrg	  $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2
586072b676d7Smrg	  $echo "$help" 1>&2
586172b676d7Smrg	  exit $EXIT_FAILURE
586272b676d7Smrg	  ;;
586372b676d7Smrg	esac
586472b676d7Smrg      done
586572b676d7Smrg      ;;
586672b676d7Smrg    esac
586772b676d7Smrg
586872b676d7Smrg    # This variable tells wrapper scripts just to set variables rather
586972b676d7Smrg    # than running their programs.
587072b676d7Smrg    libtool_install_magic="$magic"
587172b676d7Smrg
587272b676d7Smrg    staticlibs=
587372b676d7Smrg    future_libdirs=
587472b676d7Smrg    current_libdirs=
587572b676d7Smrg    for file in $files; do
587672b676d7Smrg
587772b676d7Smrg      # Do each installation.
587872b676d7Smrg      case $file in
587972b676d7Smrg      *.$libext)
588072b676d7Smrg	# Do the static libraries later.
588172b676d7Smrg	staticlibs="$staticlibs $file"
588272b676d7Smrg	;;
588372b676d7Smrg
588472b676d7Smrg      *.la)
588572b676d7Smrg	# Check to see that this really is a libtool archive.
588672b676d7Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
588772b676d7Smrg	else
588872b676d7Smrg	  $echo "$modename: \`$file' is not a valid libtool archive" 1>&2
588972b676d7Smrg	  $echo "$help" 1>&2
589072b676d7Smrg	  exit $EXIT_FAILURE
589172b676d7Smrg	fi
589272b676d7Smrg
589372b676d7Smrg	library_names=
589472b676d7Smrg	old_library=
589572b676d7Smrg	relink_command=
589672b676d7Smrg	# If there is no directory component, then add one.
589772b676d7Smrg	case $file in
589872b676d7Smrg	*/* | *\\*) . $file ;;
589972b676d7Smrg	*) . ./$file ;;
590072b676d7Smrg	esac
590172b676d7Smrg
590272b676d7Smrg	# Add the libdir to current_libdirs if it is the destination.
590372b676d7Smrg	if test "X$destdir" = "X$libdir"; then
590472b676d7Smrg	  case "$current_libdirs " in
590572b676d7Smrg	  *" $libdir "*) ;;
590672b676d7Smrg	  *) current_libdirs="$current_libdirs $libdir" ;;
590772b676d7Smrg	  esac
590872b676d7Smrg	else
590972b676d7Smrg	  # Note the libdir as a future libdir.
591072b676d7Smrg	  case "$future_libdirs " in
591172b676d7Smrg	  *" $libdir "*) ;;
591272b676d7Smrg	  *) future_libdirs="$future_libdirs $libdir" ;;
591372b676d7Smrg	  esac
591472b676d7Smrg	fi
591572b676d7Smrg
591672b676d7Smrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/
591772b676d7Smrg	test "X$dir" = "X$file/" && dir=
591872b676d7Smrg	dir="$dir$objdir"
591972b676d7Smrg
592072b676d7Smrg	if test -n "$relink_command"; then
592172b676d7Smrg	  # Determine the prefix the user has applied to our future dir.
592272b676d7Smrg	  inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"`
592372b676d7Smrg
592472b676d7Smrg	  # Don't allow the user to place us outside of our expected
592572b676d7Smrg	  # location b/c this prevents finding dependent libraries that
592672b676d7Smrg	  # are installed to the same prefix.
592772b676d7Smrg	  # At present, this check doesn't affect windows .dll's that
592872b676d7Smrg	  # are installed into $libdir/../bin (currently, that works fine)
592972b676d7Smrg	  # but it's something to keep an eye on.
593072b676d7Smrg	  if test "$inst_prefix_dir" = "$destdir"; then
593172b676d7Smrg	    $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2
593272b676d7Smrg	    exit $EXIT_FAILURE
593372b676d7Smrg	  fi
593472b676d7Smrg
593572b676d7Smrg	  if test -n "$inst_prefix_dir"; then
593672b676d7Smrg	    # Stick the inst_prefix_dir data into the link command.
593772b676d7Smrg	    relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
593872b676d7Smrg	  else
593972b676d7Smrg	    relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
594072b676d7Smrg	  fi
594172b676d7Smrg
594272b676d7Smrg	  $echo "$modename: warning: relinking \`$file'" 1>&2
594372b676d7Smrg	  $show "$relink_command"
594472b676d7Smrg	  if $run eval "$relink_command"; then :
594572b676d7Smrg	  else
594672b676d7Smrg	    $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
594772b676d7Smrg	    exit $EXIT_FAILURE
594872b676d7Smrg	  fi
594972b676d7Smrg	fi
595072b676d7Smrg
595172b676d7Smrg	# See the names of the shared library.
595272b676d7Smrg	set dummy $library_names
595372b676d7Smrg	if test -n "$2"; then
595472b676d7Smrg	  realname="$2"
595572b676d7Smrg	  shift
595672b676d7Smrg	  shift
595772b676d7Smrg
595872b676d7Smrg	  srcname="$realname"
595972b676d7Smrg	  test -n "$relink_command" && srcname="$realname"T
596072b676d7Smrg
596172b676d7Smrg	  # Install the shared library and build the symlinks.
596272b676d7Smrg	  $show "$install_prog $dir/$srcname $destdir/$realname"
596372b676d7Smrg	  $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $?
596472b676d7Smrg	  if test -n "$stripme" && test -n "$striplib"; then
596572b676d7Smrg	    $show "$striplib $destdir/$realname"
596672b676d7Smrg	    $run eval "$striplib $destdir/$realname" || exit $?
596772b676d7Smrg	  fi
596872b676d7Smrg
596972b676d7Smrg	  if test "$#" -gt 0; then
597072b676d7Smrg	    # Delete the old symlinks, and create new ones.
597172b676d7Smrg	    # Try `ln -sf' first, because the `ln' binary might depend on
597272b676d7Smrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
597372b676d7Smrg	    # so we also need to try rm && ln -s.
597472b676d7Smrg	    for linkname
597572b676d7Smrg	    do
597672b676d7Smrg	      if test "$linkname" != "$realname"; then
597772b676d7Smrg                $show "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
597872b676d7Smrg                $run eval "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
597972b676d7Smrg	      fi
598072b676d7Smrg	    done
598172b676d7Smrg	  fi
598272b676d7Smrg
598372b676d7Smrg	  # Do each command in the postinstall commands.
598472b676d7Smrg	  lib="$destdir/$realname"
598572b676d7Smrg	  cmds=$postinstall_cmds
598672b676d7Smrg	  save_ifs="$IFS"; IFS='~'
598772b676d7Smrg	  for cmd in $cmds; do
598872b676d7Smrg	    IFS="$save_ifs"
598972b676d7Smrg	    eval cmd=\"$cmd\"
599072b676d7Smrg	    $show "$cmd"
599172b676d7Smrg	    $run eval "$cmd" || {
599272b676d7Smrg	      lt_exit=$?
599372b676d7Smrg
599472b676d7Smrg	      # Restore the uninstalled library and exit
599572b676d7Smrg	      if test "$mode" = relink; then
599672b676d7Smrg		$run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
599772b676d7Smrg	      fi
599872b676d7Smrg
599972b676d7Smrg	      exit $lt_exit
600072b676d7Smrg	    }
600172b676d7Smrg	  done
600272b676d7Smrg	  IFS="$save_ifs"
600372b676d7Smrg	fi
600472b676d7Smrg
600572b676d7Smrg	# Install the pseudo-library for information purposes.
600672b676d7Smrg	name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
600772b676d7Smrg	instname="$dir/$name"i
600872b676d7Smrg	$show "$install_prog $instname $destdir/$name"
600972b676d7Smrg	$run eval "$install_prog $instname $destdir/$name" || exit $?
601072b676d7Smrg
601172b676d7Smrg	# Maybe install the static library, too.
601272b676d7Smrg	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
601372b676d7Smrg	;;
601472b676d7Smrg
601572b676d7Smrg      *.lo)
601672b676d7Smrg	# Install (i.e. copy) a libtool object.
601772b676d7Smrg
601872b676d7Smrg	# Figure out destination file name, if it wasn't already specified.
601972b676d7Smrg	if test -n "$destname"; then
602072b676d7Smrg	  destfile="$destdir/$destname"
602172b676d7Smrg	else
602272b676d7Smrg	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
602372b676d7Smrg	  destfile="$destdir/$destfile"
602472b676d7Smrg	fi
602572b676d7Smrg
602672b676d7Smrg	# Deduce the name of the destination old-style object file.
602772b676d7Smrg	case $destfile in
602872b676d7Smrg	*.lo)
602972b676d7Smrg	  staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"`
603072b676d7Smrg	  ;;
603172b676d7Smrg	*.$objext)
603272b676d7Smrg	  staticdest="$destfile"
603372b676d7Smrg	  destfile=
603472b676d7Smrg	  ;;
603572b676d7Smrg	*)
603672b676d7Smrg	  $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2
603772b676d7Smrg	  $echo "$help" 1>&2
603872b676d7Smrg	  exit $EXIT_FAILURE
603972b676d7Smrg	  ;;
604072b676d7Smrg	esac
604172b676d7Smrg
604272b676d7Smrg	# Install the libtool object if requested.
604372b676d7Smrg	if test -n "$destfile"; then
604472b676d7Smrg	  $show "$install_prog $file $destfile"
604572b676d7Smrg	  $run eval "$install_prog $file $destfile" || exit $?
604672b676d7Smrg	fi
604772b676d7Smrg
604872b676d7Smrg	# Install the old object if enabled.
604972b676d7Smrg	if test "$build_old_libs" = yes; then
605072b676d7Smrg	  # Deduce the name of the old-style object file.
605172b676d7Smrg	  staticobj=`$echo "X$file" | $Xsed -e "$lo2o"`
605272b676d7Smrg
605372b676d7Smrg	  $show "$install_prog $staticobj $staticdest"
605472b676d7Smrg	  $run eval "$install_prog \$staticobj \$staticdest" || exit $?
605572b676d7Smrg	fi
605672b676d7Smrg	exit $EXIT_SUCCESS
605772b676d7Smrg	;;
605872b676d7Smrg
605972b676d7Smrg      *)
606072b676d7Smrg	# Figure out destination file name, if it wasn't already specified.
606172b676d7Smrg	if test -n "$destname"; then
606272b676d7Smrg	  destfile="$destdir/$destname"
606372b676d7Smrg	else
606472b676d7Smrg	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
606572b676d7Smrg	  destfile="$destdir/$destfile"
606672b676d7Smrg	fi
606772b676d7Smrg
606872b676d7Smrg	# If the file is missing, and there is a .exe on the end, strip it
606972b676d7Smrg	# because it is most likely a libtool script we actually want to
607072b676d7Smrg	# install
607172b676d7Smrg	stripped_ext=""
607272b676d7Smrg	case $file in
607372b676d7Smrg	  *.exe)
607472b676d7Smrg	    if test ! -f "$file"; then
607572b676d7Smrg	      file=`$echo $file|${SED} 's,.exe$,,'`
607672b676d7Smrg	      stripped_ext=".exe"
607772b676d7Smrg	    fi
607872b676d7Smrg	    ;;
607972b676d7Smrg	esac
608072b676d7Smrg
608172b676d7Smrg	# Do a test to see if this is really a libtool program.
608272b676d7Smrg	case $host in
608372b676d7Smrg	*cygwin*|*mingw*)
608472b676d7Smrg	    wrapper=`$echo $file | ${SED} -e 's,.exe$,,'`
608572b676d7Smrg	    ;;
608672b676d7Smrg	*)
608772b676d7Smrg	    wrapper=$file
608872b676d7Smrg	    ;;
608972b676d7Smrg	esac
609072b676d7Smrg	if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then
609172b676d7Smrg	  notinst_deplibs=
609272b676d7Smrg	  relink_command=
609372b676d7Smrg
609472b676d7Smrg	  # Note that it is not necessary on cygwin/mingw to append a dot to
609572b676d7Smrg	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
609672b676d7Smrg	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
609772b676d7Smrg	  # `FILE.' does not work on cygwin managed mounts.
609872b676d7Smrg	  #
609972b676d7Smrg	  # If there is no directory component, then add one.
610072b676d7Smrg	  case $wrapper in
610172b676d7Smrg	  */* | *\\*) . ${wrapper} ;;
610272b676d7Smrg	  *) . ./${wrapper} ;;
610372b676d7Smrg	  esac
610472b676d7Smrg
610572b676d7Smrg	  # Check the variables that should have been set.
610672b676d7Smrg	  if test -z "$notinst_deplibs"; then
610772b676d7Smrg	    $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2
610872b676d7Smrg	    exit $EXIT_FAILURE
610972b676d7Smrg	  fi
611072b676d7Smrg
611172b676d7Smrg	  finalize=yes
611272b676d7Smrg	  for lib in $notinst_deplibs; do
611372b676d7Smrg	    # Check to see that each library is installed.
611472b676d7Smrg	    libdir=
611572b676d7Smrg	    if test -f "$lib"; then
611672b676d7Smrg	      # If there is no directory component, then add one.
611772b676d7Smrg	      case $lib in
611872b676d7Smrg	      */* | *\\*) . $lib ;;
611972b676d7Smrg	      *) . ./$lib ;;
612072b676d7Smrg	      esac
612172b676d7Smrg	    fi
612272b676d7Smrg	    libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
612372b676d7Smrg	    if test -n "$libdir" && test ! -f "$libfile"; then
612472b676d7Smrg	      $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2
612572b676d7Smrg	      finalize=no
612672b676d7Smrg	    fi
612772b676d7Smrg	  done
612872b676d7Smrg
612972b676d7Smrg	  relink_command=
613072b676d7Smrg	  # Note that it is not necessary on cygwin/mingw to append a dot to
613172b676d7Smrg	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
613272b676d7Smrg	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
613372b676d7Smrg	  # `FILE.' does not work on cygwin managed mounts.
613472b676d7Smrg	  #
613572b676d7Smrg	  # If there is no directory component, then add one.
613672b676d7Smrg	  case $wrapper in
613772b676d7Smrg	  */* | *\\*) . ${wrapper} ;;
613872b676d7Smrg	  *) . ./${wrapper} ;;
613972b676d7Smrg	  esac
614072b676d7Smrg
614172b676d7Smrg	  outputname=
614272b676d7Smrg	  if test "$fast_install" = no && test -n "$relink_command"; then
614372b676d7Smrg	    if test "$finalize" = yes && test -z "$run"; then
614472b676d7Smrg	      tmpdir=`func_mktempdir`
614572b676d7Smrg	      file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
614672b676d7Smrg	      outputname="$tmpdir/$file"
614772b676d7Smrg	      # Replace the output file specification.
614872b676d7Smrg	      relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
614972b676d7Smrg
615072b676d7Smrg	      $show "$relink_command"
615172b676d7Smrg	      if $run eval "$relink_command"; then :
615272b676d7Smrg	      else
615372b676d7Smrg		$echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
615472b676d7Smrg		${rm}r "$tmpdir"
615572b676d7Smrg		continue
615672b676d7Smrg	      fi
615772b676d7Smrg	      file="$outputname"
615872b676d7Smrg	    else
615972b676d7Smrg	      $echo "$modename: warning: cannot relink \`$file'" 1>&2
616072b676d7Smrg	    fi
616172b676d7Smrg	  else
616272b676d7Smrg	    # Install the binary that we compiled earlier.
616372b676d7Smrg	    file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
616472b676d7Smrg	  fi
616572b676d7Smrg	fi
616672b676d7Smrg
616772b676d7Smrg	# remove .exe since cygwin /usr/bin/install will append another
616872b676d7Smrg	# one anyway 
616972b676d7Smrg	case $install_prog,$host in
617072b676d7Smrg	*/usr/bin/install*,*cygwin*)
617172b676d7Smrg	  case $file:$destfile in
617272b676d7Smrg	  *.exe:*.exe)
617372b676d7Smrg	    # this is ok
617472b676d7Smrg	    ;;
617572b676d7Smrg	  *.exe:*)
617672b676d7Smrg	    destfile=$destfile.exe
617772b676d7Smrg	    ;;
617872b676d7Smrg	  *:*.exe)
617972b676d7Smrg	    destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'`
618072b676d7Smrg	    ;;
618172b676d7Smrg	  esac
618272b676d7Smrg	  ;;
618372b676d7Smrg	esac
618472b676d7Smrg	$show "$install_prog$stripme $file $destfile"
618572b676d7Smrg	$run eval "$install_prog\$stripme \$file \$destfile" || exit $?
618672b676d7Smrg	test -n "$outputname" && ${rm}r "$tmpdir"
618772b676d7Smrg	;;
618872b676d7Smrg      esac
618972b676d7Smrg    done
619072b676d7Smrg
619172b676d7Smrg    for file in $staticlibs; do
619272b676d7Smrg      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
619372b676d7Smrg
619472b676d7Smrg      # Set up the ranlib parameters.
619572b676d7Smrg      oldlib="$destdir/$name"
619672b676d7Smrg
619772b676d7Smrg      $show "$install_prog $file $oldlib"
619872b676d7Smrg      $run eval "$install_prog \$file \$oldlib" || exit $?
619972b676d7Smrg
620072b676d7Smrg      if test -n "$stripme" && test -n "$old_striplib"; then
620172b676d7Smrg	$show "$old_striplib $oldlib"
620272b676d7Smrg	$run eval "$old_striplib $oldlib" || exit $?
620372b676d7Smrg      fi
620472b676d7Smrg
620572b676d7Smrg      # Do each command in the postinstall commands.
620672b676d7Smrg      cmds=$old_postinstall_cmds
620772b676d7Smrg      save_ifs="$IFS"; IFS='~'
620872b676d7Smrg      for cmd in $cmds; do
620972b676d7Smrg	IFS="$save_ifs"
621072b676d7Smrg	eval cmd=\"$cmd\"
621172b676d7Smrg	$show "$cmd"
621272b676d7Smrg	$run eval "$cmd" || exit $?
621372b676d7Smrg      done
621472b676d7Smrg      IFS="$save_ifs"
621572b676d7Smrg    done
621672b676d7Smrg
621772b676d7Smrg    if test -n "$future_libdirs"; then
621872b676d7Smrg      $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2
621972b676d7Smrg    fi
622072b676d7Smrg
622172b676d7Smrg    if test -n "$current_libdirs"; then
622272b676d7Smrg      # Maybe just do a dry run.
622372b676d7Smrg      test -n "$run" && current_libdirs=" -n$current_libdirs"
622472b676d7Smrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
622572b676d7Smrg    else
622672b676d7Smrg      exit $EXIT_SUCCESS
622772b676d7Smrg    fi
622872b676d7Smrg    ;;
622972b676d7Smrg
623072b676d7Smrg  # libtool finish mode
623172b676d7Smrg  finish)
623272b676d7Smrg    modename="$modename: finish"
623372b676d7Smrg    libdirs="$nonopt"
623472b676d7Smrg    admincmds=
623572b676d7Smrg
623672b676d7Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
623772b676d7Smrg      for dir
623872b676d7Smrg      do
623972b676d7Smrg	libdirs="$libdirs $dir"
624072b676d7Smrg      done
624172b676d7Smrg
624272b676d7Smrg      for libdir in $libdirs; do
624372b676d7Smrg	if test -n "$finish_cmds"; then
624472b676d7Smrg	  # Do each command in the finish commands.
624572b676d7Smrg	  cmds=$finish_cmds
624672b676d7Smrg	  save_ifs="$IFS"; IFS='~'
624772b676d7Smrg	  for cmd in $cmds; do
624872b676d7Smrg	    IFS="$save_ifs"
624972b676d7Smrg	    eval cmd=\"$cmd\"
625072b676d7Smrg	    $show "$cmd"
625172b676d7Smrg	    $run eval "$cmd" || admincmds="$admincmds
625272b676d7Smrg       $cmd"
625372b676d7Smrg	  done
625472b676d7Smrg	  IFS="$save_ifs"
625572b676d7Smrg	fi
625672b676d7Smrg	if test -n "$finish_eval"; then
625772b676d7Smrg	  # Do the single finish_eval.
625872b676d7Smrg	  eval cmds=\"$finish_eval\"
625972b676d7Smrg	  $run eval "$cmds" || admincmds="$admincmds
626072b676d7Smrg       $cmds"
626172b676d7Smrg	fi
626272b676d7Smrg      done
626372b676d7Smrg    fi
626472b676d7Smrg
626572b676d7Smrg    # Exit here if they wanted silent mode.
626672b676d7Smrg    test "$show" = : && exit $EXIT_SUCCESS
626772b676d7Smrg
626872b676d7Smrg    $echo "X----------------------------------------------------------------------" | $Xsed
626972b676d7Smrg    $echo "Libraries have been installed in:"
627072b676d7Smrg    for libdir in $libdirs; do
627172b676d7Smrg      $echo "   $libdir"
627272b676d7Smrg    done
627372b676d7Smrg    $echo
627472b676d7Smrg    $echo "If you ever happen to want to link against installed libraries"
627572b676d7Smrg    $echo "in a given directory, LIBDIR, you must either use libtool, and"
627672b676d7Smrg    $echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
627772b676d7Smrg    $echo "flag during linking and do at least one of the following:"
627872b676d7Smrg    if test -n "$shlibpath_var"; then
627972b676d7Smrg      $echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
628072b676d7Smrg      $echo "     during execution"
628172b676d7Smrg    fi
628272b676d7Smrg    if test -n "$runpath_var"; then
628372b676d7Smrg      $echo "   - add LIBDIR to the \`$runpath_var' environment variable"
628472b676d7Smrg      $echo "     during linking"
628572b676d7Smrg    fi
628672b676d7Smrg    if test -n "$hardcode_libdir_flag_spec"; then
628772b676d7Smrg      libdir=LIBDIR
628872b676d7Smrg      eval flag=\"$hardcode_libdir_flag_spec\"
628972b676d7Smrg
629072b676d7Smrg      $echo "   - use the \`$flag' linker flag"
629172b676d7Smrg    fi
629272b676d7Smrg    if test -n "$admincmds"; then
629372b676d7Smrg      $echo "   - have your system administrator run these commands:$admincmds"
629472b676d7Smrg    fi
629572b676d7Smrg    if test -f /etc/ld.so.conf; then
629672b676d7Smrg      $echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
629772b676d7Smrg    fi
629872b676d7Smrg    $echo
629972b676d7Smrg    $echo "See any operating system documentation about shared libraries for"
630072b676d7Smrg    $echo "more information, such as the ld(1) and ld.so(8) manual pages."
630172b676d7Smrg    $echo "X----------------------------------------------------------------------" | $Xsed
630272b676d7Smrg    exit $EXIT_SUCCESS
630372b676d7Smrg    ;;
630472b676d7Smrg
630572b676d7Smrg  # libtool execute mode
630672b676d7Smrg  execute)
630772b676d7Smrg    modename="$modename: execute"
630872b676d7Smrg
630972b676d7Smrg    # The first argument is the command name.
631072b676d7Smrg    cmd="$nonopt"
631172b676d7Smrg    if test -z "$cmd"; then
631272b676d7Smrg      $echo "$modename: you must specify a COMMAND" 1>&2
631372b676d7Smrg      $echo "$help"
631472b676d7Smrg      exit $EXIT_FAILURE
631572b676d7Smrg    fi
631672b676d7Smrg
631772b676d7Smrg    # Handle -dlopen flags immediately.
631872b676d7Smrg    for file in $execute_dlfiles; do
631972b676d7Smrg      if test ! -f "$file"; then
632072b676d7Smrg	$echo "$modename: \`$file' is not a file" 1>&2
632172b676d7Smrg	$echo "$help" 1>&2
632272b676d7Smrg	exit $EXIT_FAILURE
632372b676d7Smrg      fi
632472b676d7Smrg
632572b676d7Smrg      dir=
632672b676d7Smrg      case $file in
632772b676d7Smrg      *.la)
632872b676d7Smrg	# Check to see that this really is a libtool archive.
632972b676d7Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
633072b676d7Smrg	else
633172b676d7Smrg	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
633272b676d7Smrg	  $echo "$help" 1>&2
633372b676d7Smrg	  exit $EXIT_FAILURE
633472b676d7Smrg	fi
633572b676d7Smrg
633672b676d7Smrg	# Read the libtool library.
633772b676d7Smrg	dlname=
633872b676d7Smrg	library_names=
633972b676d7Smrg
634072b676d7Smrg	# If there is no directory component, then add one.
634172b676d7Smrg	case $file in
634272b676d7Smrg	*/* | *\\*) . $file ;;
634372b676d7Smrg	*) . ./$file ;;
634472b676d7Smrg	esac
634572b676d7Smrg
634672b676d7Smrg	# Skip this library if it cannot be dlopened.
634772b676d7Smrg	if test -z "$dlname"; then
634872b676d7Smrg	  # Warn if it was a shared library.
634972b676d7Smrg	  test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'"
635072b676d7Smrg	  continue
635172b676d7Smrg	fi
635272b676d7Smrg
635372b676d7Smrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
635472b676d7Smrg	test "X$dir" = "X$file" && dir=.
635572b676d7Smrg
635672b676d7Smrg	if test -f "$dir/$objdir/$dlname"; then
635772b676d7Smrg	  dir="$dir/$objdir"
635872b676d7Smrg	else
635972b676d7Smrg	  $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
636072b676d7Smrg	  exit $EXIT_FAILURE
636172b676d7Smrg	fi
636272b676d7Smrg	;;
636372b676d7Smrg
636472b676d7Smrg      *.lo)
636572b676d7Smrg	# Just add the directory containing the .lo file.
636672b676d7Smrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
636772b676d7Smrg	test "X$dir" = "X$file" && dir=.
636872b676d7Smrg	;;
636972b676d7Smrg
637072b676d7Smrg      *)
637172b676d7Smrg	$echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2
637272b676d7Smrg	continue
637372b676d7Smrg	;;
637472b676d7Smrg      esac
637572b676d7Smrg
637672b676d7Smrg      # Get the absolute pathname.
637772b676d7Smrg      absdir=`cd "$dir" && pwd`
637872b676d7Smrg      test -n "$absdir" && dir="$absdir"
637972b676d7Smrg
638072b676d7Smrg      # Now add the directory to shlibpath_var.
638172b676d7Smrg      if eval "test -z \"\$$shlibpath_var\""; then
638272b676d7Smrg	eval "$shlibpath_var=\"\$dir\""
638372b676d7Smrg      else
638472b676d7Smrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
638572b676d7Smrg      fi
638672b676d7Smrg    done
638772b676d7Smrg
638872b676d7Smrg    # This variable tells wrapper scripts just to set shlibpath_var
638972b676d7Smrg    # rather than running their programs.
639072b676d7Smrg    libtool_execute_magic="$magic"
639172b676d7Smrg
639272b676d7Smrg    # Check if any of the arguments is a wrapper script.
639372b676d7Smrg    args=
639472b676d7Smrg    for file
639572b676d7Smrg    do
639672b676d7Smrg      case $file in
639772b676d7Smrg      -*) ;;
639872b676d7Smrg      *)
639972b676d7Smrg	# Do a test to see if this is really a libtool program.
640072b676d7Smrg	if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
640172b676d7Smrg	  # If there is no directory component, then add one.
640272b676d7Smrg	  case $file in
640372b676d7Smrg	  */* | *\\*) . $file ;;
640472b676d7Smrg	  *) . ./$file ;;
640572b676d7Smrg	  esac
640672b676d7Smrg
640772b676d7Smrg	  # Transform arg to wrapped name.
640872b676d7Smrg	  file="$progdir/$program"
640972b676d7Smrg	fi
641072b676d7Smrg	;;
641172b676d7Smrg      esac
641272b676d7Smrg      # Quote arguments (to preserve shell metacharacters).
641372b676d7Smrg      file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"`
641472b676d7Smrg      args="$args \"$file\""
641572b676d7Smrg    done
641672b676d7Smrg
641772b676d7Smrg    if test -z "$run"; then
641872b676d7Smrg      if test -n "$shlibpath_var"; then
641972b676d7Smrg	# Export the shlibpath_var.
642072b676d7Smrg	eval "export $shlibpath_var"
642172b676d7Smrg      fi
642272b676d7Smrg
642372b676d7Smrg      # Restore saved environment variables
642472b676d7Smrg      if test "${save_LC_ALL+set}" = set; then
642572b676d7Smrg	LC_ALL="$save_LC_ALL"; export LC_ALL
642672b676d7Smrg      fi
642772b676d7Smrg      if test "${save_LANG+set}" = set; then
642872b676d7Smrg	LANG="$save_LANG"; export LANG
642972b676d7Smrg      fi
643072b676d7Smrg
643172b676d7Smrg      # Now prepare to actually exec the command.
643272b676d7Smrg      exec_cmd="\$cmd$args"
643372b676d7Smrg    else
643472b676d7Smrg      # Display what would be done.
643572b676d7Smrg      if test -n "$shlibpath_var"; then
643672b676d7Smrg	eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\""
643772b676d7Smrg	$echo "export $shlibpath_var"
643872b676d7Smrg      fi
643972b676d7Smrg      $echo "$cmd$args"
644072b676d7Smrg      exit $EXIT_SUCCESS
644172b676d7Smrg    fi
644272b676d7Smrg    ;;
644372b676d7Smrg
644472b676d7Smrg  # libtool clean and uninstall mode
644572b676d7Smrg  clean | uninstall)
644672b676d7Smrg    modename="$modename: $mode"
644772b676d7Smrg    rm="$nonopt"
644872b676d7Smrg    files=
644972b676d7Smrg    rmforce=
645072b676d7Smrg    exit_status=0
645172b676d7Smrg
645272b676d7Smrg    # This variable tells wrapper scripts just to set variables rather
645372b676d7Smrg    # than running their programs.
645472b676d7Smrg    libtool_install_magic="$magic"
645572b676d7Smrg
645672b676d7Smrg    for arg
645772b676d7Smrg    do
645872b676d7Smrg      case $arg in
645972b676d7Smrg      -f) rm="$rm $arg"; rmforce=yes ;;
646072b676d7Smrg      -*) rm="$rm $arg" ;;
646172b676d7Smrg      *) files="$files $arg" ;;
646272b676d7Smrg      esac
646372b676d7Smrg    done
646472b676d7Smrg
646572b676d7Smrg    if test -z "$rm"; then
646672b676d7Smrg      $echo "$modename: you must specify an RM program" 1>&2
646772b676d7Smrg      $echo "$help" 1>&2
646872b676d7Smrg      exit $EXIT_FAILURE
646972b676d7Smrg    fi
647072b676d7Smrg
647172b676d7Smrg    rmdirs=
647272b676d7Smrg
647372b676d7Smrg    origobjdir="$objdir"
647472b676d7Smrg    for file in $files; do
647572b676d7Smrg      dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
647672b676d7Smrg      if test "X$dir" = "X$file"; then
647772b676d7Smrg	dir=.
647872b676d7Smrg	objdir="$origobjdir"
647972b676d7Smrg      else
648072b676d7Smrg	objdir="$dir/$origobjdir"
648172b676d7Smrg      fi
648272b676d7Smrg      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
648372b676d7Smrg      test "$mode" = uninstall && objdir="$dir"
648472b676d7Smrg
648572b676d7Smrg      # Remember objdir for removal later, being careful to avoid duplicates
648672b676d7Smrg      if test "$mode" = clean; then
648772b676d7Smrg	case " $rmdirs " in
648872b676d7Smrg	  *" $objdir "*) ;;
648972b676d7Smrg	  *) rmdirs="$rmdirs $objdir" ;;
649072b676d7Smrg	esac
649172b676d7Smrg      fi
649272b676d7Smrg
649372b676d7Smrg      # Don't error if the file doesn't exist and rm -f was used.
649472b676d7Smrg      if (test -L "$file") >/dev/null 2>&1 \
649572b676d7Smrg	|| (test -h "$file") >/dev/null 2>&1 \
649672b676d7Smrg	|| test -f "$file"; then
649772b676d7Smrg	:
649872b676d7Smrg      elif test -d "$file"; then
649972b676d7Smrg	exit_status=1
650072b676d7Smrg	continue
650172b676d7Smrg      elif test "$rmforce" = yes; then
650272b676d7Smrg	continue
650372b676d7Smrg      fi
650472b676d7Smrg
650572b676d7Smrg      rmfiles="$file"
650672b676d7Smrg
650772b676d7Smrg      case $name in
650872b676d7Smrg      *.la)
650972b676d7Smrg	# Possibly a libtool archive, so verify it.
651072b676d7Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
651172b676d7Smrg	  . $dir/$name
651272b676d7Smrg
651372b676d7Smrg	  # Delete the libtool libraries and symlinks.
651472b676d7Smrg	  for n in $library_names; do
651572b676d7Smrg	    rmfiles="$rmfiles $objdir/$n"
651672b676d7Smrg	  done
651772b676d7Smrg	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
651872b676d7Smrg
651972b676d7Smrg	  case "$mode" in
652072b676d7Smrg	  clean)
652172b676d7Smrg	    case "  $library_names " in
652272b676d7Smrg	    # "  " in the beginning catches empty $dlname
652372b676d7Smrg	    *" $dlname "*) ;;
652472b676d7Smrg	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
652572b676d7Smrg	    esac
652672b676d7Smrg	     test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
652772b676d7Smrg	    ;;
652872b676d7Smrg	  uninstall)
652972b676d7Smrg	    if test -n "$library_names"; then
653072b676d7Smrg	      # Do each command in the postuninstall commands.
653172b676d7Smrg	      cmds=$postuninstall_cmds
653272b676d7Smrg	      save_ifs="$IFS"; IFS='~'
653372b676d7Smrg	      for cmd in $cmds; do
653472b676d7Smrg		IFS="$save_ifs"
653572b676d7Smrg		eval cmd=\"$cmd\"
653672b676d7Smrg		$show "$cmd"
653772b676d7Smrg		$run eval "$cmd"
653872b676d7Smrg		if test "$?" -ne 0 && test "$rmforce" != yes; then
653972b676d7Smrg		  exit_status=1
654072b676d7Smrg		fi
654172b676d7Smrg	      done
654272b676d7Smrg	      IFS="$save_ifs"
654372b676d7Smrg	    fi
654472b676d7Smrg
654572b676d7Smrg	    if test -n "$old_library"; then
654672b676d7Smrg	      # Do each command in the old_postuninstall commands.
654772b676d7Smrg	      cmds=$old_postuninstall_cmds
654872b676d7Smrg	      save_ifs="$IFS"; IFS='~'
654972b676d7Smrg	      for cmd in $cmds; do
655072b676d7Smrg		IFS="$save_ifs"
655172b676d7Smrg		eval cmd=\"$cmd\"
655272b676d7Smrg		$show "$cmd"
655372b676d7Smrg		$run eval "$cmd"
655472b676d7Smrg		if test "$?" -ne 0 && test "$rmforce" != yes; then
655572b676d7Smrg		  exit_status=1
655672b676d7Smrg		fi
655772b676d7Smrg	      done
655872b676d7Smrg	      IFS="$save_ifs"
655972b676d7Smrg	    fi
656072b676d7Smrg	    # FIXME: should reinstall the best remaining shared library.
656172b676d7Smrg	    ;;
656272b676d7Smrg	  esac
656372b676d7Smrg	fi
656472b676d7Smrg	;;
656572b676d7Smrg
656672b676d7Smrg      *.lo)
656772b676d7Smrg	# Possibly a libtool object, so verify it.
656872b676d7Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
656972b676d7Smrg
657072b676d7Smrg	  # Read the .lo file
657172b676d7Smrg	  . $dir/$name
657272b676d7Smrg
657372b676d7Smrg	  # Add PIC object to the list of files to remove.
657472b676d7Smrg	  if test -n "$pic_object" \
657572b676d7Smrg	     && test "$pic_object" != none; then
657672b676d7Smrg	    rmfiles="$rmfiles $dir/$pic_object"
657772b676d7Smrg	  fi
657872b676d7Smrg
657972b676d7Smrg	  # Add non-PIC object to the list of files to remove.
658072b676d7Smrg	  if test -n "$non_pic_object" \
658172b676d7Smrg	     && test "$non_pic_object" != none; then
658272b676d7Smrg	    rmfiles="$rmfiles $dir/$non_pic_object"
658372b676d7Smrg	  fi
658472b676d7Smrg	fi
658572b676d7Smrg	;;
658672b676d7Smrg
658772b676d7Smrg      *)
658872b676d7Smrg	if test "$mode" = clean ; then
658972b676d7Smrg	  noexename=$name
659072b676d7Smrg	  case $file in
659172b676d7Smrg	  *.exe)
659272b676d7Smrg	    file=`$echo $file|${SED} 's,.exe$,,'`
659372b676d7Smrg	    noexename=`$echo $name|${SED} 's,.exe$,,'`
659472b676d7Smrg	    # $file with .exe has already been added to rmfiles,
659572b676d7Smrg	    # add $file without .exe
659672b676d7Smrg	    rmfiles="$rmfiles $file"
659772b676d7Smrg	    ;;
659872b676d7Smrg	  esac
659972b676d7Smrg	  # Do a test to see if this is a libtool program.
660072b676d7Smrg	  if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
660172b676d7Smrg	    relink_command=
660272b676d7Smrg	    . $dir/$noexename
660372b676d7Smrg
660472b676d7Smrg	    # note $name still contains .exe if it was in $file originally
660572b676d7Smrg	    # as does the version of $file that was added into $rmfiles
660672b676d7Smrg	    rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
660772b676d7Smrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
660872b676d7Smrg	      rmfiles="$rmfiles $objdir/lt-$name"
660972b676d7Smrg	    fi
661072b676d7Smrg	    if test "X$noexename" != "X$name" ; then
661172b676d7Smrg	      rmfiles="$rmfiles $objdir/lt-${noexename}.c"
661272b676d7Smrg	    fi
661372b676d7Smrg	  fi
661472b676d7Smrg	fi
661572b676d7Smrg	;;
661672b676d7Smrg      esac
661772b676d7Smrg      $show "$rm $rmfiles"
661872b676d7Smrg      $run $rm $rmfiles || exit_status=1
661972b676d7Smrg    done
662072b676d7Smrg    objdir="$origobjdir"
662172b676d7Smrg
662272b676d7Smrg    # Try to remove the ${objdir}s in the directories where we deleted files
662372b676d7Smrg    for dir in $rmdirs; do
662472b676d7Smrg      if test -d "$dir"; then
662572b676d7Smrg	$show "rmdir $dir"
662672b676d7Smrg	$run rmdir $dir >/dev/null 2>&1
662772b676d7Smrg      fi
662872b676d7Smrg    done
662972b676d7Smrg
663072b676d7Smrg    exit $exit_status
663172b676d7Smrg    ;;
663272b676d7Smrg
663372b676d7Smrg  "")
663472b676d7Smrg    $echo "$modename: you must specify a MODE" 1>&2
663572b676d7Smrg    $echo "$generic_help" 1>&2
663672b676d7Smrg    exit $EXIT_FAILURE
663772b676d7Smrg    ;;
663872b676d7Smrg  esac
663972b676d7Smrg
664072b676d7Smrg  if test -z "$exec_cmd"; then
664172b676d7Smrg    $echo "$modename: invalid operation mode \`$mode'" 1>&2
664272b676d7Smrg    $echo "$generic_help" 1>&2
664372b676d7Smrg    exit $EXIT_FAILURE
664472b676d7Smrg  fi
664572b676d7Smrgfi # test -z "$show_help"
664672b676d7Smrg
664772b676d7Smrgif test -n "$exec_cmd"; then
664872b676d7Smrg  eval exec $exec_cmd
664972b676d7Smrg  exit $EXIT_FAILURE
665072b676d7Smrgfi
665172b676d7Smrg
665272b676d7Smrg# We need to display help for each of the modes.
665372b676d7Smrgcase $mode in
665472b676d7Smrg"") $echo \
665572b676d7Smrg"Usage: $modename [OPTION]... [MODE-ARG]...
665672b676d7Smrg
665772b676d7SmrgProvide generalized library-building support services.
665872b676d7Smrg
665972b676d7Smrg    --config          show all configuration variables
666072b676d7Smrg    --debug           enable verbose shell tracing
666172b676d7Smrg-n, --dry-run         display commands without modifying any files
666272b676d7Smrg    --features        display basic configuration information and exit
666372b676d7Smrg    --finish          same as \`--mode=finish'
666472b676d7Smrg    --help            display this help message and exit
666572b676d7Smrg    --mode=MODE       use operation mode MODE [default=inferred from MODE-ARGS]
666672b676d7Smrg    --quiet           same as \`--silent'
666772b676d7Smrg    --silent          don't print informational messages
666872b676d7Smrg    --tag=TAG         use configuration variables from tag TAG
666972b676d7Smrg    --version         print version information
667072b676d7Smrg
667172b676d7SmrgMODE must be one of the following:
667272b676d7Smrg
667372b676d7Smrg      clean           remove files from the build directory
667472b676d7Smrg      compile         compile a source file into a libtool object
667572b676d7Smrg      execute         automatically set library path, then run a program
667672b676d7Smrg      finish          complete the installation of libtool libraries
667772b676d7Smrg      install         install libraries or executables
667872b676d7Smrg      link            create a library or an executable
667972b676d7Smrg      uninstall       remove libraries from an installed directory
668072b676d7Smrg
668172b676d7SmrgMODE-ARGS vary depending on the MODE.  Try \`$modename --help --mode=MODE' for
668272b676d7Smrga more detailed description of MODE.
668372b676d7Smrg
668472b676d7SmrgReport bugs to <bug-libtool@gnu.org>."
668572b676d7Smrg  exit $EXIT_SUCCESS
668672b676d7Smrg  ;;
668772b676d7Smrg
668872b676d7Smrgclean)
668972b676d7Smrg  $echo \
669072b676d7Smrg"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
669172b676d7Smrg
669272b676d7SmrgRemove files from the build directory.
669372b676d7Smrg
669472b676d7SmrgRM is the name of the program to use to delete files associated with each FILE
669572b676d7Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
669672b676d7Smrgto RM.
669772b676d7Smrg
669872b676d7SmrgIf FILE is a libtool library, object or program, all the files associated
669972b676d7Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
670072b676d7Smrg  ;;
670172b676d7Smrg
670272b676d7Smrgcompile)
670372b676d7Smrg  $echo \
670472b676d7Smrg"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
670572b676d7Smrg
670672b676d7SmrgCompile a source file into a libtool library object.
670772b676d7Smrg
670872b676d7SmrgThis mode accepts the following additional options:
670972b676d7Smrg
671072b676d7Smrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
671172b676d7Smrg  -prefer-pic       try to building PIC objects only
671272b676d7Smrg  -prefer-non-pic   try to building non-PIC objects only
671372b676d7Smrg  -static           always build a \`.o' file suitable for static linking
671472b676d7Smrg
671572b676d7SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
671672b676d7Smrgfrom the given SOURCEFILE.
671772b676d7Smrg
671872b676d7SmrgThe output file name is determined by removing the directory component from
671972b676d7SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
672072b676d7Smrglibrary object suffix, \`.lo'."
672172b676d7Smrg  ;;
672272b676d7Smrg
672372b676d7Smrgexecute)
672472b676d7Smrg  $echo \
672572b676d7Smrg"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]...
672672b676d7Smrg
672772b676d7SmrgAutomatically set library path, then run a program.
672872b676d7Smrg
672972b676d7SmrgThis mode accepts the following additional options:
673072b676d7Smrg
673172b676d7Smrg  -dlopen FILE      add the directory containing FILE to the library path
673272b676d7Smrg
673372b676d7SmrgThis mode sets the library path environment variable according to \`-dlopen'
673472b676d7Smrgflags.
673572b676d7Smrg
673672b676d7SmrgIf any of the ARGS are libtool executable wrappers, then they are translated
673772b676d7Smrginto their corresponding uninstalled binary, and any of their required library
673872b676d7Smrgdirectories are added to the library path.
673972b676d7Smrg
674072b676d7SmrgThen, COMMAND is executed, with ARGS as arguments."
674172b676d7Smrg  ;;
674272b676d7Smrg
674372b676d7Smrgfinish)
674472b676d7Smrg  $echo \
674572b676d7Smrg"Usage: $modename [OPTION]... --mode=finish [LIBDIR]...
674672b676d7Smrg
674772b676d7SmrgComplete the installation of libtool libraries.
674872b676d7Smrg
674972b676d7SmrgEach LIBDIR is a directory that contains libtool libraries.
675072b676d7Smrg
675172b676d7SmrgThe commands that this mode executes may require superuser privileges.  Use
675272b676d7Smrgthe \`--dry-run' option if you just want to see what would be executed."
675372b676d7Smrg  ;;
675472b676d7Smrg
675572b676d7Smrginstall)
675672b676d7Smrg  $echo \
675772b676d7Smrg"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND...
675872b676d7Smrg
675972b676d7SmrgInstall executables or libraries.
676072b676d7Smrg
676172b676d7SmrgINSTALL-COMMAND is the installation command.  The first component should be
676272b676d7Smrgeither the \`install' or \`cp' program.
676372b676d7Smrg
676472b676d7SmrgThe rest of the components are interpreted as arguments to that command (only
676572b676d7SmrgBSD-compatible install options are recognized)."
676672b676d7Smrg  ;;
676772b676d7Smrg
676872b676d7Smrglink)
676972b676d7Smrg  $echo \
677072b676d7Smrg"Usage: $modename [OPTION]... --mode=link LINK-COMMAND...
677172b676d7Smrg
677272b676d7SmrgLink object files or libraries together to form another library, or to
677372b676d7Smrgcreate an executable program.
677472b676d7Smrg
677572b676d7SmrgLINK-COMMAND is a command using the C compiler that you would use to create
677672b676d7Smrga program from several object files.
677772b676d7Smrg
677872b676d7SmrgThe following components of LINK-COMMAND are treated specially:
677972b676d7Smrg
678072b676d7Smrg  -all-static       do not do any dynamic linking at all
678172b676d7Smrg  -avoid-version    do not add a version suffix if possible
678272b676d7Smrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
678372b676d7Smrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
678472b676d7Smrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
678572b676d7Smrg  -export-symbols SYMFILE
678672b676d7Smrg		    try to export only the symbols listed in SYMFILE
678772b676d7Smrg  -export-symbols-regex REGEX
678872b676d7Smrg		    try to export only the symbols matching REGEX
678972b676d7Smrg  -LLIBDIR          search LIBDIR for required installed libraries
679072b676d7Smrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
679172b676d7Smrg  -module           build a library that can dlopened
679272b676d7Smrg  -no-fast-install  disable the fast-install mode
679372b676d7Smrg  -no-install       link a not-installable executable
679472b676d7Smrg  -no-undefined     declare that a library does not refer to external symbols
679572b676d7Smrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
679672b676d7Smrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
679772b676d7Smrg  -precious-files-regex REGEX
679872b676d7Smrg                    don't remove output files matching REGEX
679972b676d7Smrg  -release RELEASE  specify package release information
680072b676d7Smrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
680172b676d7Smrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
680272b676d7Smrg  -static           do not do any dynamic linking of libtool libraries
680372b676d7Smrg  -version-info CURRENT[:REVISION[:AGE]]
680472b676d7Smrg		    specify library version info [each variable defaults to 0]
680572b676d7Smrg
680672b676d7SmrgAll other options (arguments beginning with \`-') are ignored.
680772b676d7Smrg
680872b676d7SmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
680972b676d7Smrgtreated as uninstalled libtool libraries, other files are standard or library
681072b676d7Smrgobject files.
681172b676d7Smrg
681272b676d7SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
681372b676d7Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
681472b676d7Smrgrequired, except when creating a convenience library.
681572b676d7Smrg
681672b676d7SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
681772b676d7Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
681872b676d7Smrg
681972b676d7SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
682072b676d7Smrgis created, otherwise an executable program is created."
682172b676d7Smrg  ;;
682272b676d7Smrg
682372b676d7Smrguninstall)
682472b676d7Smrg  $echo \
682572b676d7Smrg"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
682672b676d7Smrg
682772b676d7SmrgRemove libraries from an installation directory.
682872b676d7Smrg
682972b676d7SmrgRM is the name of the program to use to delete files associated with each FILE
683072b676d7Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
683172b676d7Smrgto RM.
683272b676d7Smrg
683372b676d7SmrgIf FILE is a libtool library, all the files associated with it are deleted.
683472b676d7SmrgOtherwise, only FILE itself is deleted using RM."
683572b676d7Smrg  ;;
683672b676d7Smrg
683772b676d7Smrg*)
683872b676d7Smrg  $echo "$modename: invalid operation mode \`$mode'" 1>&2
683972b676d7Smrg  $echo "$help" 1>&2
684072b676d7Smrg  exit $EXIT_FAILURE
684172b676d7Smrg  ;;
684272b676d7Smrgesac
684372b676d7Smrg
684472b676d7Smrg$echo
684572b676d7Smrg$echo "Try \`$modename --help' for more information about other modes."
684672b676d7Smrg
684772b676d7Smrgexit $?
684872b676d7Smrg
684972b676d7Smrg# The TAGs below are defined such that we never get into a situation
685072b676d7Smrg# in which we disable both kinds of libraries.  Given conflicting
685172b676d7Smrg# choices, we go for a static library, that is the most portable,
685272b676d7Smrg# since we can't tell whether shared libraries were disabled because
685372b676d7Smrg# the user asked for that or because the platform doesn't support
685472b676d7Smrg# them.  This is particularly important on AIX, because we don't
685572b676d7Smrg# support having both static and shared libraries enabled at the same
685672b676d7Smrg# time on that platform, so we default to a shared-only configuration.
685772b676d7Smrg# If a disable-shared tag is given, we'll fallback to a static-only
685872b676d7Smrg# configuration.  But we'll never go from static-only to shared-only.
685972b676d7Smrg
686072b676d7Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
686172b676d7Smrgdisable_libs=shared
686272b676d7Smrg# ### END LIBTOOL TAG CONFIG: disable-shared
686372b676d7Smrg
686472b676d7Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
686572b676d7Smrgdisable_libs=static
686672b676d7Smrg# ### END LIBTOOL TAG CONFIG: disable-static
686772b676d7Smrg
686872b676d7Smrg# Local Variables:
686972b676d7Smrg# mode:shell-script
687072b676d7Smrg# sh-indentation:2
687172b676d7Smrg# End:
6872