ltmain.sh revision 34977a2f
134977a2fSmrg# Generated from ltmain.m4sh.
234977a2fSmrg
334977a2fSmrg# ltmain.sh (GNU libtool) 2.2.6
434977a2fSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
534977a2fSmrg
634977a2fSmrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 Free Software Foundation, Inc.
734977a2fSmrg# This is free software; see the source for copying conditions.  There is NO
834977a2fSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
934977a2fSmrg
1034977a2fSmrg# GNU Libtool is free software; you can redistribute it and/or modify
11ee3138f1Smrg# it under the terms of the GNU General Public License as published by
12ee3138f1Smrg# the Free Software Foundation; either version 2 of the License, or
13ee3138f1Smrg# (at your option) any later version.
14ee3138f1Smrg#
1534977a2fSmrg# As a special exception to the GNU General Public License,
1634977a2fSmrg# if you distribute this file as part of a program or library that
1734977a2fSmrg# is built using GNU Libtool, you may include this file under the
1834977a2fSmrg# same distribution terms that you use for the rest of that program.
1934977a2fSmrg#
2034977a2fSmrg# GNU Libtool is distributed in the hope that it will be useful, but
21ee3138f1Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
22ee3138f1Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23ee3138f1Smrg# General Public License for more details.
24ee3138f1Smrg#
25ee3138f1Smrg# You should have received a copy of the GNU General Public License
2634977a2fSmrg# along with GNU Libtool; see the file COPYING.  If not, a copy
2734977a2fSmrg# can be downloaded from http://www.gnu.org/licenses/gpl.html,
2834977a2fSmrg# or obtained by writing to the Free Software Foundation, Inc.,
2934977a2fSmrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
3079a8a9c6Smrg
3134977a2fSmrg# Usage: $progname [OPTION]... [MODE-ARG]...
3234977a2fSmrg#
3334977a2fSmrg# Provide generalized library-building support services.
3434977a2fSmrg#
3534977a2fSmrg#     --config             show all configuration variables
3634977a2fSmrg#     --debug              enable verbose shell tracing
3734977a2fSmrg# -n, --dry-run            display commands without modifying any files
3834977a2fSmrg#     --features           display basic configuration information and exit
3934977a2fSmrg#     --mode=MODE          use operation mode MODE
4034977a2fSmrg#     --preserve-dup-deps  don't remove duplicate dependency libraries
4134977a2fSmrg#     --quiet, --silent    don't print informational messages
4234977a2fSmrg#     --tag=TAG            use configuration variables from tag TAG
4334977a2fSmrg# -v, --verbose            print informational messages (default)
4434977a2fSmrg#     --version            print version information
4534977a2fSmrg# -h, --help               print short or long help message
4634977a2fSmrg#
4734977a2fSmrg# MODE must be one of the following:
4834977a2fSmrg#
4934977a2fSmrg#       clean              remove files from the build directory
5034977a2fSmrg#       compile            compile a source file into a libtool object
5134977a2fSmrg#       execute            automatically set library path, then run a program
5234977a2fSmrg#       finish             complete the installation of libtool libraries
5334977a2fSmrg#       install            install libraries or executables
5434977a2fSmrg#       link               create a library or an executable
5534977a2fSmrg#       uninstall          remove libraries from an installed directory
5634977a2fSmrg#
5734977a2fSmrg# MODE-ARGS vary depending on the MODE.
5834977a2fSmrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
5934977a2fSmrg#
6034977a2fSmrg# When reporting a bug, please describe a test case to reproduce it and
6134977a2fSmrg# include the following information:
6234977a2fSmrg#
6334977a2fSmrg#       host-triplet:	$host
6434977a2fSmrg#       shell:		$SHELL
6534977a2fSmrg#       compiler:		$LTCC
6634977a2fSmrg#       compiler flags:		$LTCFLAGS
6734977a2fSmrg#       linker:		$LD (gnu? $with_gnu_ld)
6834977a2fSmrg#       $progname:		(GNU libtool) 2.2.6
6934977a2fSmrg#       automake:		$automake_version
7034977a2fSmrg#       autoconf:		$autoconf_version
7134977a2fSmrg#
7234977a2fSmrg# Report bugs to <bug-libtool@gnu.org>.
73ee3138f1Smrg
74ee3138f1SmrgPROGRAM=ltmain.sh
75ee3138f1SmrgPACKAGE=libtool
7634977a2fSmrgVERSION=2.2.6
7734977a2fSmrgTIMESTAMP=""
7834977a2fSmrgpackage_revision=1.3012
79ee3138f1Smrg
8034977a2fSmrg# Be Bourne compatible
81ee3138f1Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
82ee3138f1Smrg  emulate sh
83ee3138f1Smrg  NULLCMD=:
84ee3138f1Smrg  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
85ee3138f1Smrg  # is contrary to our usage.  Disable this feature.
86ee3138f1Smrg  alias -g '${1+"$@"}'='"$@"'
87ee3138f1Smrg  setopt NO_GLOB_SUBST
88ee3138f1Smrgelse
89ee3138f1Smrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
90ee3138f1Smrgfi
91ee3138f1SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
92ee3138f1SmrgDUALCASE=1; export DUALCASE # for MKS sh
93ee3138f1Smrg
9434977a2fSmrg# NLS nuisances: We save the old values to restore during execute mode.
95ee3138f1Smrg# Only set LANG and LC_ALL to C if already set.
96ee3138f1Smrg# These must not be set unconditionally because not all systems understand
97ee3138f1Smrg# e.g. LANG=C (notably SCO).
9834977a2fSmrglt_user_locale=
9934977a2fSmrglt_safe_locale=
10079a8a9c6Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
101ee3138f1Smrgdo
102ee3138f1Smrg  eval "if test \"\${$lt_var+set}\" = set; then
10334977a2fSmrg          save_$lt_var=\$$lt_var
10434977a2fSmrg          $lt_var=C
105ee3138f1Smrg	  export $lt_var
10634977a2fSmrg	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
10734977a2fSmrg	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
108ee3138f1Smrg	fi"
109ee3138f1Smrgdone
110ee3138f1Smrg
11134977a2fSmrg$lt_unset CDPATH
11234977a2fSmrg
11334977a2fSmrg
11434977a2fSmrg
11534977a2fSmrg
11634977a2fSmrg
11734977a2fSmrg: ${CP="cp -f"}
11834977a2fSmrg: ${ECHO="echo"}
11934977a2fSmrg: ${EGREP="/bin/grep -E"}
12034977a2fSmrg: ${FGREP="/bin/grep -F"}
12134977a2fSmrg: ${GREP="/bin/grep"}
12234977a2fSmrg: ${LN_S="ln -s"}
12334977a2fSmrg: ${MAKE="make"}
12434977a2fSmrg: ${MKDIR="mkdir"}
12534977a2fSmrg: ${MV="mv -f"}
12634977a2fSmrg: ${RM="rm -f"}
12734977a2fSmrg: ${SED="/bin/sed"}
12834977a2fSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
12934977a2fSmrg: ${Xsed="$SED -e 1s/^X//"}
13034977a2fSmrg
13134977a2fSmrg# Global variables:
13234977a2fSmrgEXIT_SUCCESS=0
13334977a2fSmrgEXIT_FAILURE=1
13434977a2fSmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
13534977a2fSmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
13634977a2fSmrg
13734977a2fSmrgexit_status=$EXIT_SUCCESS
13879a8a9c6Smrg
139ee3138f1Smrg# Make sure IFS has a sensible default
140ee3138f1Smrglt_nl='
141ee3138f1Smrg'
142ee3138f1SmrgIFS=" 	$lt_nl"
143ee3138f1Smrg
14434977a2fSmrgdirname="s,/[^/]*$,,"
14534977a2fSmrgbasename="s,^.*/,,"
14634977a2fSmrg
14734977a2fSmrg# func_dirname_and_basename file append nondir_replacement
14834977a2fSmrg# perform func_basename and func_dirname in a single function
14934977a2fSmrg# call:
15034977a2fSmrg#   dirname:  Compute the dirname of FILE.  If nonempty,
15134977a2fSmrg#             add APPEND to the result, otherwise set result
15234977a2fSmrg#             to NONDIR_REPLACEMENT.
15334977a2fSmrg#             value returned in "$func_dirname_result"
15434977a2fSmrg#   basename: Compute filename of FILE.
15534977a2fSmrg#             value retuned in "$func_basename_result"
15634977a2fSmrg# Implementation must be kept synchronized with func_dirname
15734977a2fSmrg# and func_basename. For efficiency, we do not delegate to
15834977a2fSmrg# those functions but instead duplicate the functionality here.
15934977a2fSmrgfunc_dirname_and_basename ()
16034977a2fSmrg{
16134977a2fSmrg  # Extract subdirectory from the argument.
16234977a2fSmrg  func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
16334977a2fSmrg  if test "X$func_dirname_result" = "X${1}"; then
16434977a2fSmrg    func_dirname_result="${3}"
16534977a2fSmrg  else
16634977a2fSmrg    func_dirname_result="$func_dirname_result${2}"
16734977a2fSmrg  fi
16834977a2fSmrg  func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
16934977a2fSmrg}
170ee3138f1Smrg
17134977a2fSmrg# Generated shell functions inserted here.
17234977a2fSmrg
17334977a2fSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
17434977a2fSmrg# is ksh but when the shell is invoked as "sh" and the current value of
17534977a2fSmrg# the _XPG environment variable is not equal to 1 (one), the special
17634977a2fSmrg# positional parameter $0, within a function call, is the name of the
17734977a2fSmrg# function.
17834977a2fSmrgprogpath="$0"
17934977a2fSmrg
18034977a2fSmrg# The name of this program:
18134977a2fSmrg# In the unlikely event $progname began with a '-', it would play havoc with
18234977a2fSmrg# func_echo (imagine progname=-n), so we prepend ./ in that case:
18334977a2fSmrgfunc_dirname_and_basename "$progpath"
18434977a2fSmrgprogname=$func_basename_result
18534977a2fSmrgcase $progname in
18634977a2fSmrg  -*) progname=./$progname ;;
18734977a2fSmrgesac
18834977a2fSmrg
18934977a2fSmrg# Make sure we have an absolute path for reexecution:
19034977a2fSmrgcase $progpath in
19134977a2fSmrg  [\\/]*|[A-Za-z]:\\*) ;;
19234977a2fSmrg  *[\\/]*)
19334977a2fSmrg     progdir=$func_dirname_result
19434977a2fSmrg     progdir=`cd "$progdir" && pwd`
19534977a2fSmrg     progpath="$progdir/$progname"
19634977a2fSmrg     ;;
19734977a2fSmrg  *)
19834977a2fSmrg     save_IFS="$IFS"
19934977a2fSmrg     IFS=:
20034977a2fSmrg     for progdir in $PATH; do
20134977a2fSmrg       IFS="$save_IFS"
20234977a2fSmrg       test -x "$progdir/$progname" && break
20334977a2fSmrg     done
20434977a2fSmrg     IFS="$save_IFS"
20534977a2fSmrg     test -n "$progdir" || progdir=`pwd`
20634977a2fSmrg     progpath="$progdir/$progname"
20734977a2fSmrg     ;;
20834977a2fSmrgesac
20934977a2fSmrg
21034977a2fSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
21134977a2fSmrg# metacharacters that are still active within double-quoted strings.
21234977a2fSmrgXsed="${SED}"' -e 1s/^X//'
21334977a2fSmrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g'
21434977a2fSmrg
21534977a2fSmrg# Same as above, but do not quote variable references.
21634977a2fSmrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g'
21734977a2fSmrg
21834977a2fSmrg# Re-`\' parameter expansions in output of double_quote_subst that were
21934977a2fSmrg# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
22034977a2fSmrg# in input to double_quote_subst, that '$' was protected from expansion.
22134977a2fSmrg# Since each input `\' is now two `\'s, look for any number of runs of
22234977a2fSmrg# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
22334977a2fSmrgbs='\\'
22434977a2fSmrgbs2='\\\\'
22534977a2fSmrgbs4='\\\\\\\\'
22634977a2fSmrgdollar='\$'
22734977a2fSmrgsed_double_backslash="\
22834977a2fSmrg  s/$bs4/&\\
22934977a2fSmrg/g
23034977a2fSmrg  s/^$bs2$dollar/$bs&/
23134977a2fSmrg  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
23234977a2fSmrg  s/\n//g"
23334977a2fSmrg
23434977a2fSmrg# Standard options:
23534977a2fSmrgopt_dry_run=false
23634977a2fSmrgopt_help=false
23734977a2fSmrgopt_quiet=false
23834977a2fSmrgopt_verbose=false
23934977a2fSmrgopt_warning=:
24034977a2fSmrg
24134977a2fSmrg# func_echo arg...
24234977a2fSmrg# Echo program name prefixed message, along with the current mode
24334977a2fSmrg# name if it has been set yet.
24434977a2fSmrgfunc_echo ()
24534977a2fSmrg{
24634977a2fSmrg    $ECHO "$progname${mode+: }$mode: $*"
24734977a2fSmrg}
24834977a2fSmrg
24934977a2fSmrg# func_verbose arg...
25034977a2fSmrg# Echo program name prefixed message in verbose mode only.
25134977a2fSmrgfunc_verbose ()
25234977a2fSmrg{
25334977a2fSmrg    $opt_verbose && func_echo ${1+"$@"}
25434977a2fSmrg
25534977a2fSmrg    # A bug in bash halts the script if the last line of a function
25634977a2fSmrg    # fails when set -e is in force, so we need another command to
25734977a2fSmrg    # work around that:
25834977a2fSmrg    :
25934977a2fSmrg}
26034977a2fSmrg
26134977a2fSmrg# func_error arg...
26234977a2fSmrg# Echo program name prefixed message to standard error.
26334977a2fSmrgfunc_error ()
26434977a2fSmrg{
26534977a2fSmrg    $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2
26634977a2fSmrg}
26734977a2fSmrg
26834977a2fSmrg# func_warning arg...
26934977a2fSmrg# Echo program name prefixed warning message to standard error.
27034977a2fSmrgfunc_warning ()
27134977a2fSmrg{
27234977a2fSmrg    $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2
27334977a2fSmrg
27434977a2fSmrg    # bash bug again:
27534977a2fSmrg    :
27634977a2fSmrg}
27734977a2fSmrg
27834977a2fSmrg# func_fatal_error arg...
27934977a2fSmrg# Echo program name prefixed message to standard error, and exit.
28034977a2fSmrgfunc_fatal_error ()
28134977a2fSmrg{
28234977a2fSmrg    func_error ${1+"$@"}
28334977a2fSmrg    exit $EXIT_FAILURE
28434977a2fSmrg}
28534977a2fSmrg
28634977a2fSmrg# func_fatal_help arg...
28734977a2fSmrg# Echo program name prefixed message to standard error, followed by
28834977a2fSmrg# a help hint, and exit.
28934977a2fSmrgfunc_fatal_help ()
29034977a2fSmrg{
29134977a2fSmrg    func_error ${1+"$@"}
29234977a2fSmrg    func_fatal_error "$help"
29334977a2fSmrg}
29434977a2fSmrghelp="Try \`$progname --help' for more information."  ## default
29534977a2fSmrg
29634977a2fSmrg
29734977a2fSmrg# func_grep expression filename
29834977a2fSmrg# Check whether EXPRESSION matches any line of FILENAME, without output.
29934977a2fSmrgfunc_grep ()
30034977a2fSmrg{
30134977a2fSmrg    $GREP "$1" "$2" >/dev/null 2>&1
30234977a2fSmrg}
30334977a2fSmrg
30434977a2fSmrg
30534977a2fSmrg# func_mkdir_p directory-path
30634977a2fSmrg# Make sure the entire path to DIRECTORY-PATH is available.
30734977a2fSmrgfunc_mkdir_p ()
30834977a2fSmrg{
30934977a2fSmrg    my_directory_path="$1"
31034977a2fSmrg    my_dir_list=
31134977a2fSmrg
31234977a2fSmrg    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
31334977a2fSmrg
31434977a2fSmrg      # Protect directory names starting with `-'
31534977a2fSmrg      case $my_directory_path in
31634977a2fSmrg        -*) my_directory_path="./$my_directory_path" ;;
31734977a2fSmrg      esac
31834977a2fSmrg
31934977a2fSmrg      # While some portion of DIR does not yet exist...
32034977a2fSmrg      while test ! -d "$my_directory_path"; do
32134977a2fSmrg        # ...make a list in topmost first order.  Use a colon delimited
32234977a2fSmrg	# list incase some portion of path contains whitespace.
32334977a2fSmrg        my_dir_list="$my_directory_path:$my_dir_list"
32434977a2fSmrg
32534977a2fSmrg        # If the last portion added has no slash in it, the list is done
32634977a2fSmrg        case $my_directory_path in */*) ;; *) break ;; esac
32734977a2fSmrg
32834977a2fSmrg        # ...otherwise throw away the child directory and loop
32934977a2fSmrg        my_directory_path=`$ECHO "X$my_directory_path" | $Xsed -e "$dirname"`
33034977a2fSmrg      done
33134977a2fSmrg      my_dir_list=`$ECHO "X$my_dir_list" | $Xsed -e 's,:*$,,'`
33234977a2fSmrg
33334977a2fSmrg      save_mkdir_p_IFS="$IFS"; IFS=':'
33434977a2fSmrg      for my_dir in $my_dir_list; do
33534977a2fSmrg	IFS="$save_mkdir_p_IFS"
33634977a2fSmrg        # mkdir can fail with a `File exist' error if two processes
33734977a2fSmrg        # try to create one of the directories concurrently.  Don't
33834977a2fSmrg        # stop in that case!
33934977a2fSmrg        $MKDIR "$my_dir" 2>/dev/null || :
34034977a2fSmrg      done
34134977a2fSmrg      IFS="$save_mkdir_p_IFS"
34234977a2fSmrg
34334977a2fSmrg      # Bail out if we (or some other process) failed to create a directory.
34434977a2fSmrg      test -d "$my_directory_path" || \
34534977a2fSmrg        func_fatal_error "Failed to create \`$1'"
34634977a2fSmrg    fi
34734977a2fSmrg}
348ee3138f1Smrg
349ee3138f1Smrg
350ee3138f1Smrg# func_mktempdir [string]
351ee3138f1Smrg# Make a temporary directory that won't clash with other running
352ee3138f1Smrg# libtool processes, and avoids race conditions if possible.  If
353ee3138f1Smrg# given, STRING is the basename for that directory.
354ee3138f1Smrgfunc_mktempdir ()
355ee3138f1Smrg{
356ee3138f1Smrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
357ee3138f1Smrg
35834977a2fSmrg    if test "$opt_dry_run" = ":"; then
359ee3138f1Smrg      # Return a directory name, but don't create it in dry-run mode
360ee3138f1Smrg      my_tmpdir="${my_template}-$$"
361ee3138f1Smrg    else
362ee3138f1Smrg
363ee3138f1Smrg      # If mktemp works, use that first and foremost
364ee3138f1Smrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
365ee3138f1Smrg
366ee3138f1Smrg      if test ! -d "$my_tmpdir"; then
36734977a2fSmrg        # Failing that, at least try and use $RANDOM to avoid a race
36834977a2fSmrg        my_tmpdir="${my_template}-${RANDOM-0}$$"
369ee3138f1Smrg
37034977a2fSmrg        save_mktempdir_umask=`umask`
37134977a2fSmrg        umask 0077
37234977a2fSmrg        $MKDIR "$my_tmpdir"
37334977a2fSmrg        umask $save_mktempdir_umask
374ee3138f1Smrg      fi
375ee3138f1Smrg
376ee3138f1Smrg      # If we're not in dry-run mode, bomb out on failure
37734977a2fSmrg      test -d "$my_tmpdir" || \
37834977a2fSmrg        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
379ee3138f1Smrg    fi
380ee3138f1Smrg
38134977a2fSmrg    $ECHO "X$my_tmpdir" | $Xsed
382ee3138f1Smrg}
383ee3138f1Smrg
384ee3138f1Smrg
38534977a2fSmrg# func_quote_for_eval arg
38634977a2fSmrg# Aesthetically quote ARG to be evaled later.
38734977a2fSmrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
38834977a2fSmrg# is double-quoted, suitable for a subsequent eval, whereas
38934977a2fSmrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
39034977a2fSmrg# which are still active within double quotes backslashified.
39134977a2fSmrgfunc_quote_for_eval ()
392ee3138f1Smrg{
39334977a2fSmrg    case $1 in
39434977a2fSmrg      *[\\\`\"\$]*)
39534977a2fSmrg	func_quote_for_eval_unquoted_result=`$ECHO "X$1" | $Xsed -e "$sed_quote_subst"` ;;
39634977a2fSmrg      *)
39734977a2fSmrg        func_quote_for_eval_unquoted_result="$1" ;;
39834977a2fSmrg    esac
39934977a2fSmrg
40034977a2fSmrg    case $func_quote_for_eval_unquoted_result in
40134977a2fSmrg      # Double-quote args containing shell metacharacters to delay
40234977a2fSmrg      # word splitting, command substitution and and variable
40334977a2fSmrg      # expansion for a subsequent eval.
40434977a2fSmrg      # Many Bourne shells cannot handle close brackets correctly
40534977a2fSmrg      # in scan sets, so we specify it separately.
40634977a2fSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
40734977a2fSmrg        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
40834977a2fSmrg        ;;
40934977a2fSmrg      *)
41034977a2fSmrg        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
411ee3138f1Smrg    esac
412ee3138f1Smrg}
413ee3138f1Smrg
414ee3138f1Smrg
41534977a2fSmrg# func_quote_for_expand arg
41634977a2fSmrg# Aesthetically quote ARG to be evaled later; same as above,
41734977a2fSmrg# but do not quote variable references.
41834977a2fSmrgfunc_quote_for_expand ()
419ee3138f1Smrg{
42034977a2fSmrg    case $1 in
42134977a2fSmrg      *[\\\`\"]*)
42234977a2fSmrg	my_arg=`$ECHO "X$1" | $Xsed \
42334977a2fSmrg	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
424ee3138f1Smrg      *)
42534977a2fSmrg        my_arg="$1" ;;
42634977a2fSmrg    esac
42734977a2fSmrg
42834977a2fSmrg    case $my_arg in
42934977a2fSmrg      # Double-quote args containing shell metacharacters to delay
43034977a2fSmrg      # word splitting and command substitution for a subsequent eval.
43134977a2fSmrg      # Many Bourne shells cannot handle close brackets correctly
43234977a2fSmrg      # in scan sets, so we specify it separately.
43334977a2fSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
43434977a2fSmrg        my_arg="\"$my_arg\""
43534977a2fSmrg        ;;
43634977a2fSmrg    esac
43734977a2fSmrg
43834977a2fSmrg    func_quote_for_expand_result="$my_arg"
439ee3138f1Smrg}
440ee3138f1Smrg
441ee3138f1Smrg
44234977a2fSmrg# func_show_eval cmd [fail_exp]
44334977a2fSmrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
44434977a2fSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
44534977a2fSmrg# is given, then evaluate it.
44634977a2fSmrgfunc_show_eval ()
447ee3138f1Smrg{
44834977a2fSmrg    my_cmd="$1"
44934977a2fSmrg    my_fail_exp="${2-:}"
450ee3138f1Smrg
45134977a2fSmrg    ${opt_silent-false} || {
45234977a2fSmrg      func_quote_for_expand "$my_cmd"
45334977a2fSmrg      eval "func_echo $func_quote_for_expand_result"
45434977a2fSmrg    }
45534977a2fSmrg
45634977a2fSmrg    if ${opt_dry_run-false}; then :; else
45734977a2fSmrg      eval "$my_cmd"
45834977a2fSmrg      my_status=$?
45934977a2fSmrg      if test "$my_status" -eq 0; then :; else
46034977a2fSmrg	eval "(exit $my_status); $my_fail_exp"
46134977a2fSmrg      fi
462ee3138f1Smrg    fi
463ee3138f1Smrg}
464ee3138f1Smrg
46534977a2fSmrg
46634977a2fSmrg# func_show_eval_locale cmd [fail_exp]
46734977a2fSmrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
46834977a2fSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
46934977a2fSmrg# is given, then evaluate it.  Use the saved locale for evaluation.
47034977a2fSmrgfunc_show_eval_locale ()
471ee3138f1Smrg{
47234977a2fSmrg    my_cmd="$1"
47334977a2fSmrg    my_fail_exp="${2-:}"
47434977a2fSmrg
47534977a2fSmrg    ${opt_silent-false} || {
47634977a2fSmrg      func_quote_for_expand "$my_cmd"
47734977a2fSmrg      eval "func_echo $func_quote_for_expand_result"
47834977a2fSmrg    }
47934977a2fSmrg
48034977a2fSmrg    if ${opt_dry_run-false}; then :; else
48134977a2fSmrg      eval "$lt_user_locale
48234977a2fSmrg	    $my_cmd"
48334977a2fSmrg      my_status=$?
48434977a2fSmrg      eval "$lt_safe_locale"
48534977a2fSmrg      if test "$my_status" -eq 0; then :; else
48634977a2fSmrg	eval "(exit $my_status); $my_fail_exp"
48734977a2fSmrg      fi
488ee3138f1Smrg    fi
48934977a2fSmrg}
490ee3138f1Smrg
491ee3138f1Smrg
49234977a2fSmrg
49334977a2fSmrg
49434977a2fSmrg
49534977a2fSmrg# func_version
49634977a2fSmrg# Echo version message to standard output and exit.
49734977a2fSmrgfunc_version ()
49834977a2fSmrg{
49934977a2fSmrg    $SED -n '/^# '$PROGRAM' (GNU /,/# warranty; / {
50034977a2fSmrg        s/^# //
50134977a2fSmrg	s/^# *$//
50234977a2fSmrg        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
50334977a2fSmrg        p
50434977a2fSmrg     }' < "$progpath"
50534977a2fSmrg     exit $?
506ee3138f1Smrg}
507ee3138f1Smrg
50834977a2fSmrg# func_usage
50934977a2fSmrg# Echo short help message to standard output and exit.
51034977a2fSmrgfunc_usage ()
51134977a2fSmrg{
51234977a2fSmrg    $SED -n '/^# Usage:/,/# -h/ {
51334977a2fSmrg        s/^# //
51434977a2fSmrg	s/^# *$//
51534977a2fSmrg	s/\$progname/'$progname'/
51634977a2fSmrg	p
51734977a2fSmrg    }' < "$progpath"
51834977a2fSmrg    $ECHO
51934977a2fSmrg    $ECHO "run \`$progname --help | more' for full usage"
52034977a2fSmrg    exit $?
52134977a2fSmrg}
522ee3138f1Smrg
52334977a2fSmrg# func_help
52434977a2fSmrg# Echo long help message to standard output and exit.
52534977a2fSmrgfunc_help ()
52634977a2fSmrg{
52734977a2fSmrg    $SED -n '/^# Usage:/,/# Report bugs to/ {
52834977a2fSmrg        s/^# //
52934977a2fSmrg	s/^# *$//
53034977a2fSmrg	s*\$progname*'$progname'*
53134977a2fSmrg	s*\$host*'"$host"'*
53234977a2fSmrg	s*\$SHELL*'"$SHELL"'*
53334977a2fSmrg	s*\$LTCC*'"$LTCC"'*
53434977a2fSmrg	s*\$LTCFLAGS*'"$LTCFLAGS"'*
53534977a2fSmrg	s*\$LD*'"$LD"'*
53634977a2fSmrg	s/\$with_gnu_ld/'"$with_gnu_ld"'/
53734977a2fSmrg	s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
53834977a2fSmrg	s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
53934977a2fSmrg	p
54034977a2fSmrg     }' < "$progpath"
54134977a2fSmrg    exit $?
54234977a2fSmrg}
543ee3138f1Smrg
54434977a2fSmrg# func_missing_arg argname
54534977a2fSmrg# Echo program name prefixed message to standard error and set global
54634977a2fSmrg# exit_cmd.
54734977a2fSmrgfunc_missing_arg ()
54834977a2fSmrg{
54934977a2fSmrg    func_error "missing argument for $1"
55034977a2fSmrg    exit_cmd=exit
55134977a2fSmrg}
55234977a2fSmrg
55334977a2fSmrgexit_cmd=:
55434977a2fSmrg
55534977a2fSmrg
55634977a2fSmrg
55734977a2fSmrg
55834977a2fSmrg
55934977a2fSmrg# Check that we have a working $ECHO.
56034977a2fSmrgif test "X$1" = X--no-reexec; then
56134977a2fSmrg  # Discard the --no-reexec flag, and continue.
562ee3138f1Smrg  shift
56334977a2fSmrgelif test "X$1" = X--fallback-echo; then
56434977a2fSmrg  # Avoid inline document here, it may be left over
56534977a2fSmrg  :
56634977a2fSmrgelif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then
56734977a2fSmrg  # Yippee, $ECHO works!
56834977a2fSmrg  :
56934977a2fSmrgelse
57034977a2fSmrg  # Restart under the correct shell, and then maybe $ECHO will work.
57134977a2fSmrg  exec $SHELL "$progpath" --no-reexec ${1+"$@"}
57234977a2fSmrgfi
573ee3138f1Smrg
57434977a2fSmrgif test "X$1" = X--fallback-echo; then
57534977a2fSmrg  # used as fallback echo
57634977a2fSmrg  shift
57734977a2fSmrg  cat <<EOF
57834977a2fSmrg$*
57934977a2fSmrgEOF
58034977a2fSmrg  exit $EXIT_SUCCESS
58134977a2fSmrgfi
582ee3138f1Smrg
58334977a2fSmrgmagic="%%%MAGIC variable%%%"
58434977a2fSmrgmagic_exe="%%%MAGIC EXE variable%%%"
585ee3138f1Smrg
58634977a2fSmrg# Global variables.
58734977a2fSmrg# $mode is unset
58834977a2fSmrgnonopt=
58934977a2fSmrgexecute_dlfiles=
59034977a2fSmrgpreserve_args=
59134977a2fSmrglo2o="s/\\.lo\$/.${objext}/"
59234977a2fSmrgo2lo="s/\\.${objext}\$/.lo/"
59334977a2fSmrgextracted_archives=
59434977a2fSmrgextracted_serial=0
595ee3138f1Smrg
59634977a2fSmrgopt_dry_run=false
59734977a2fSmrgopt_duplicate_deps=false
59834977a2fSmrgopt_silent=false
59934977a2fSmrgopt_debug=:
600ee3138f1Smrg
60134977a2fSmrg# If this variable is set in any of the actions, the command in it
60234977a2fSmrg# will be execed at the end.  This prevents here-documents from being
60334977a2fSmrg# left over by shells.
60434977a2fSmrgexec_cmd=
60534977a2fSmrg
60634977a2fSmrg# func_fatal_configuration arg...
60734977a2fSmrg# Echo program name prefixed message to standard error, followed by
60834977a2fSmrg# a configuration failure hint, and exit.
60934977a2fSmrgfunc_fatal_configuration ()
61034977a2fSmrg{
61134977a2fSmrg    func_error ${1+"$@"}
61234977a2fSmrg    func_error "See the $PACKAGE documentation for more information."
61334977a2fSmrg    func_fatal_error "Fatal configuration error."
61434977a2fSmrg}
615ee3138f1Smrg
616ee3138f1Smrg
61734977a2fSmrg# func_config
61834977a2fSmrg# Display the configuration for all the tags in this script.
61934977a2fSmrgfunc_config ()
62034977a2fSmrg{
62134977a2fSmrg    re_begincf='^# ### BEGIN LIBTOOL'
62234977a2fSmrg    re_endcf='^# ### END LIBTOOL'
62334977a2fSmrg
62434977a2fSmrg    # Default configuration.
62534977a2fSmrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
626ee3138f1Smrg
627ee3138f1Smrg    # Now print the configurations for the tags.
628ee3138f1Smrg    for tagname in $taglist; do
62934977a2fSmrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
630ee3138f1Smrg    done
631ee3138f1Smrg
63234977a2fSmrg    exit $?
63334977a2fSmrg}
634ee3138f1Smrg
63534977a2fSmrg# func_features
63634977a2fSmrg# Display the features supported by this script.
63734977a2fSmrgfunc_features ()
63834977a2fSmrg{
63934977a2fSmrg    $ECHO "host: $host"
640ee3138f1Smrg    if test "$build_libtool_libs" = yes; then
64134977a2fSmrg      $ECHO "enable shared libraries"
642ee3138f1Smrg    else
64334977a2fSmrg      $ECHO "disable shared libraries"
644ee3138f1Smrg    fi
645ee3138f1Smrg    if test "$build_old_libs" = yes; then
64634977a2fSmrg      $ECHO "enable static libraries"
647ee3138f1Smrg    else
64834977a2fSmrg      $ECHO "disable static libraries"
649ee3138f1Smrg    fi
65034977a2fSmrg
651ee3138f1Smrg    exit $?
65234977a2fSmrg}
653ee3138f1Smrg
65434977a2fSmrg# func_enable_tag tagname
65534977a2fSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or
65634977a2fSmrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
65734977a2fSmrg# variable here.
65834977a2fSmrgfunc_enable_tag ()
65934977a2fSmrg{
66034977a2fSmrg  # Global variable:
66134977a2fSmrg  tagname="$1"
662ee3138f1Smrg
66334977a2fSmrg  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
66434977a2fSmrg  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
66534977a2fSmrg  sed_extractcf="/$re_begincf/,/$re_endcf/p"
666ee3138f1Smrg
66734977a2fSmrg  # Validate tagname.
66834977a2fSmrg  case $tagname in
66934977a2fSmrg    *[!-_A-Za-z0-9,/]*)
67034977a2fSmrg      func_fatal_error "invalid tag name: $tagname"
67134977a2fSmrg      ;;
67234977a2fSmrg  esac
673ee3138f1Smrg
67434977a2fSmrg  # Don't test for the "default" C tag, as we know it's
67534977a2fSmrg  # there but not specially marked.
67634977a2fSmrg  case $tagname in
67734977a2fSmrg    CC) ;;
67834977a2fSmrg    *)
67934977a2fSmrg      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
68034977a2fSmrg	taglist="$taglist $tagname"
68134977a2fSmrg
68234977a2fSmrg	# Evaluate the configuration.  Be careful to quote the path
68334977a2fSmrg	# and the sed script, to avoid splitting on whitespace, but
68434977a2fSmrg	# also don't use non-portable quotes within backquotes within
68534977a2fSmrg	# quotes we have to do it in 2 steps:
68634977a2fSmrg	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
68734977a2fSmrg	eval "$extractedcf"
68834977a2fSmrg      else
68934977a2fSmrg	func_error "ignoring unknown tag $tagname"
69034977a2fSmrg      fi
69134977a2fSmrg      ;;
69234977a2fSmrg  esac
69334977a2fSmrg}
69434977a2fSmrg
69534977a2fSmrg# Parse options once, thoroughly.  This comes as soon as possible in
69634977a2fSmrg# the script to make things like `libtool --version' happen quickly.
69734977a2fSmrg{
698ee3138f1Smrg
69934977a2fSmrg  # Shorthand for --mode=foo, only valid as the first argument
70034977a2fSmrg  case $1 in
70134977a2fSmrg  clean|clea|cle|cl)
70234977a2fSmrg    shift; set dummy --mode clean ${1+"$@"}; shift
703ee3138f1Smrg    ;;
70434977a2fSmrg  compile|compil|compi|comp|com|co|c)
70534977a2fSmrg    shift; set dummy --mode compile ${1+"$@"}; shift
706ee3138f1Smrg    ;;
70734977a2fSmrg  execute|execut|execu|exec|exe|ex|e)
70834977a2fSmrg    shift; set dummy --mode execute ${1+"$@"}; shift
709ee3138f1Smrg    ;;
71034977a2fSmrg  finish|finis|fini|fin|fi|f)
71134977a2fSmrg    shift; set dummy --mode finish ${1+"$@"}; shift
712ee3138f1Smrg    ;;
71334977a2fSmrg  install|instal|insta|inst|ins|in|i)
71434977a2fSmrg    shift; set dummy --mode install ${1+"$@"}; shift
71534977a2fSmrg    ;;
71634977a2fSmrg  link|lin|li|l)
71734977a2fSmrg    shift; set dummy --mode link ${1+"$@"}; shift
71834977a2fSmrg    ;;
71934977a2fSmrg  uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
72034977a2fSmrg    shift; set dummy --mode uninstall ${1+"$@"}; shift
721ee3138f1Smrg    ;;
722ee3138f1Smrg  esac
723ee3138f1Smrg
72434977a2fSmrg  # Parse non-mode specific arguments:
72534977a2fSmrg  while test "$#" -gt 0; do
72634977a2fSmrg    opt="$1"
72734977a2fSmrg    shift
728ee3138f1Smrg
72934977a2fSmrg    case $opt in
73034977a2fSmrg      --config)		func_config					;;
731ee3138f1Smrg
73234977a2fSmrg      --debug)		preserve_args="$preserve_args $opt"
73334977a2fSmrg			func_echo "enabling shell trace mode"
73434977a2fSmrg			opt_debug='set -x'
73534977a2fSmrg			$opt_debug
73634977a2fSmrg			;;
73734977a2fSmrg
73834977a2fSmrg      -dlopen)		test "$#" -eq 0 && func_missing_arg "$opt" && break
73934977a2fSmrg			execute_dlfiles="$execute_dlfiles $1"
74034977a2fSmrg			shift
74134977a2fSmrg			;;
742ee3138f1Smrg
74334977a2fSmrg      --dry-run | -n)	opt_dry_run=:					;;
74434977a2fSmrg      --features)       func_features					;;
74534977a2fSmrg      --finish)		mode="finish"					;;
74634977a2fSmrg
74734977a2fSmrg      --mode)		test "$#" -eq 0 && func_missing_arg "$opt" && break
74834977a2fSmrg			case $1 in
74934977a2fSmrg			  # Valid mode arguments:
75034977a2fSmrg			  clean)	;;
75134977a2fSmrg			  compile)	;;
75234977a2fSmrg			  execute)	;;
75334977a2fSmrg			  finish)	;;
75434977a2fSmrg			  install)	;;
75534977a2fSmrg			  link)		;;
75634977a2fSmrg			  relink)	;;
75734977a2fSmrg			  uninstall)	;;
75834977a2fSmrg
75934977a2fSmrg			  # Catch anything else as an error
76034977a2fSmrg			  *) func_error "invalid argument for $opt"
76134977a2fSmrg			     exit_cmd=exit
76234977a2fSmrg			     break
76334977a2fSmrg			     ;;
76434977a2fSmrg		        esac
76534977a2fSmrg
76634977a2fSmrg			mode="$1"
76734977a2fSmrg			shift
76834977a2fSmrg			;;
769ee3138f1Smrg
77034977a2fSmrg      --preserve-dup-deps)
77134977a2fSmrg			opt_duplicate_deps=:				;;
77234977a2fSmrg
77334977a2fSmrg      --quiet|--silent)	preserve_args="$preserve_args $opt"
77434977a2fSmrg			opt_silent=:
77534977a2fSmrg			;;
77634977a2fSmrg
77734977a2fSmrg      --verbose| -v)	preserve_args="$preserve_args $opt"
77834977a2fSmrg			opt_silent=false
77934977a2fSmrg			;;
78034977a2fSmrg
78134977a2fSmrg      --tag)		test "$#" -eq 0 && func_missing_arg "$opt" && break
78234977a2fSmrg			preserve_args="$preserve_args $opt $1"
78334977a2fSmrg			func_enable_tag "$1"	# tagname is set here
78434977a2fSmrg			shift
78534977a2fSmrg			;;
78634977a2fSmrg
78734977a2fSmrg      # Separate optargs to long options:
78834977a2fSmrg      -dlopen=*|--mode=*|--tag=*)
78934977a2fSmrg			func_opt_split "$opt"
79034977a2fSmrg			set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"}
79134977a2fSmrg			shift
79234977a2fSmrg			;;
79334977a2fSmrg
79434977a2fSmrg      -\?|-h)		func_usage					;;
79534977a2fSmrg      --help)		opt_help=:					;;
79634977a2fSmrg      --version)	func_version					;;
79734977a2fSmrg
79834977a2fSmrg      -*)		func_fatal_help "unrecognized option \`$opt'"	;;
79934977a2fSmrg
80034977a2fSmrg      *)		nonopt="$opt"
80134977a2fSmrg			break
80234977a2fSmrg			;;
80334977a2fSmrg    esac
80434977a2fSmrg  done
80534977a2fSmrg
80634977a2fSmrg
80734977a2fSmrg  case $host in
80834977a2fSmrg    *cygwin* | *mingw* | *pw32* | *cegcc*)
80934977a2fSmrg      # don't eliminate duplications in $postdeps and $predeps
81034977a2fSmrg      opt_duplicate_compiler_generated_deps=:
811ee3138f1Smrg      ;;
812ee3138f1Smrg    *)
81334977a2fSmrg      opt_duplicate_compiler_generated_deps=$opt_duplicate_deps
81434977a2fSmrg      ;;
81534977a2fSmrg  esac
816ee3138f1Smrg
81734977a2fSmrg  # Having warned about all mis-specified options, bail out if
81834977a2fSmrg  # anything was wrong.
81934977a2fSmrg  $exit_cmd $EXIT_FAILURE
82034977a2fSmrg}
82134977a2fSmrg
82234977a2fSmrg# func_check_version_match
82334977a2fSmrg# Ensure that we are using m4 macros, and libtool script from the same
82434977a2fSmrg# release of libtool.
82534977a2fSmrgfunc_check_version_match ()
82634977a2fSmrg{
82734977a2fSmrg  if test "$package_revision" != "$macro_revision"; then
82834977a2fSmrg    if test "$VERSION" != "$macro_version"; then
82934977a2fSmrg      if test -z "$macro_version"; then
83034977a2fSmrg        cat >&2 <<_LT_EOF
83134977a2fSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
83234977a2fSmrg$progname: definition of this LT_INIT comes from an older release.
83334977a2fSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
83434977a2fSmrg$progname: and run autoconf again.
83534977a2fSmrg_LT_EOF
83634977a2fSmrg      else
83734977a2fSmrg        cat >&2 <<_LT_EOF
83834977a2fSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
83934977a2fSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
84034977a2fSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
84134977a2fSmrg$progname: and run autoconf again.
84234977a2fSmrg_LT_EOF
843ee3138f1Smrg      fi
84434977a2fSmrg    else
84534977a2fSmrg      cat >&2 <<_LT_EOF
84634977a2fSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
84734977a2fSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
84834977a2fSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
84934977a2fSmrg$progname: of $PACKAGE $VERSION and run autoconf again.
85034977a2fSmrg_LT_EOF
85134977a2fSmrg    fi
85234977a2fSmrg
85334977a2fSmrg    exit $EXIT_MISMATCH
854ee3138f1Smrg  fi
85534977a2fSmrg}
85634977a2fSmrg
85734977a2fSmrg
85834977a2fSmrg## ----------- ##
85934977a2fSmrg##    Main.    ##
86034977a2fSmrg## ----------- ##
86134977a2fSmrg
86234977a2fSmrg$opt_help || {
86334977a2fSmrg  # Sanity checks first:
86434977a2fSmrg  func_check_version_match
86534977a2fSmrg
86634977a2fSmrg  if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
86734977a2fSmrg    func_fatal_configuration "not configured to build any kind of library"
86834977a2fSmrg  fi
86934977a2fSmrg
87034977a2fSmrg  test -z "$mode" && func_fatal_error "error: you must specify a MODE."
87134977a2fSmrg
87234977a2fSmrg
87334977a2fSmrg  # Darwin sucks
87434977a2fSmrg  eval std_shrext=\"$shrext_cmds\"
87534977a2fSmrg
876ee3138f1Smrg
877ee3138f1Smrg  # Only execute mode is allowed to have -dlopen flags.
878ee3138f1Smrg  if test -n "$execute_dlfiles" && test "$mode" != execute; then
87934977a2fSmrg    func_error "unrecognized option \`-dlopen'"
88034977a2fSmrg    $ECHO "$help" 1>&2
881ee3138f1Smrg    exit $EXIT_FAILURE
882ee3138f1Smrg  fi
883ee3138f1Smrg
884ee3138f1Smrg  # Change the help message to a mode-specific one.
885ee3138f1Smrg  generic_help="$help"
88634977a2fSmrg  help="Try \`$progname --help --mode=$mode' for more information."
88734977a2fSmrg}
888ee3138f1Smrg
889ee3138f1Smrg
89034977a2fSmrg# func_lalib_p file
89134977a2fSmrg# True iff FILE is a libtool `.la' library or `.lo' object file.
89234977a2fSmrg# This function is only a basic sanity check; it will hardly flush out
89334977a2fSmrg# determined imposters.
89434977a2fSmrgfunc_lalib_p ()
89534977a2fSmrg{
89634977a2fSmrg    test -f "$1" &&
89734977a2fSmrg      $SED -e 4q "$1" 2>/dev/null \
89834977a2fSmrg        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
89934977a2fSmrg}
900ee3138f1Smrg
90134977a2fSmrg# func_lalib_unsafe_p file
90234977a2fSmrg# True iff FILE is a libtool `.la' library or `.lo' object file.
90334977a2fSmrg# This function implements the same check as func_lalib_p without
90434977a2fSmrg# resorting to external programs.  To this end, it redirects stdin and
90534977a2fSmrg# closes it afterwards, without saving the original file descriptor.
90634977a2fSmrg# As a safety measure, use it only where a negative result would be
90734977a2fSmrg# fatal anyway.  Works if `file' does not exist.
90834977a2fSmrgfunc_lalib_unsafe_p ()
90934977a2fSmrg{
91034977a2fSmrg    lalib_p=no
91134977a2fSmrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
91234977a2fSmrg	for lalib_p_l in 1 2 3 4
91334977a2fSmrg	do
91434977a2fSmrg	    read lalib_p_line
91534977a2fSmrg	    case "$lalib_p_line" in
91634977a2fSmrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
91734977a2fSmrg	    esac
91834977a2fSmrg	done
91934977a2fSmrg	exec 0<&5 5<&-
92034977a2fSmrg    fi
92134977a2fSmrg    test "$lalib_p" = yes
92234977a2fSmrg}
923ee3138f1Smrg
92434977a2fSmrg# func_ltwrapper_script_p file
92534977a2fSmrg# True iff FILE is a libtool wrapper script
92634977a2fSmrg# This function is only a basic sanity check; it will hardly flush out
92734977a2fSmrg# determined imposters.
92834977a2fSmrgfunc_ltwrapper_script_p ()
92934977a2fSmrg{
93034977a2fSmrg    func_lalib_p "$1"
93134977a2fSmrg}
932ee3138f1Smrg
93334977a2fSmrg# func_ltwrapper_executable_p file
93434977a2fSmrg# True iff FILE is a libtool wrapper executable
93534977a2fSmrg# This function is only a basic sanity check; it will hardly flush out
93634977a2fSmrg# determined imposters.
93734977a2fSmrgfunc_ltwrapper_executable_p ()
93834977a2fSmrg{
93934977a2fSmrg    func_ltwrapper_exec_suffix=
94034977a2fSmrg    case $1 in
94134977a2fSmrg    *.exe) ;;
94234977a2fSmrg    *) func_ltwrapper_exec_suffix=.exe ;;
94334977a2fSmrg    esac
94434977a2fSmrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
94534977a2fSmrg}
94634977a2fSmrg
94734977a2fSmrg# func_ltwrapper_scriptname file
94834977a2fSmrg# Assumes file is an ltwrapper_executable
94934977a2fSmrg# uses $file to determine the appropriate filename for a
95034977a2fSmrg# temporary ltwrapper_script.
95134977a2fSmrgfunc_ltwrapper_scriptname ()
95234977a2fSmrg{
95334977a2fSmrg    func_ltwrapper_scriptname_result=""
95434977a2fSmrg    if func_ltwrapper_executable_p "$1"; then
95534977a2fSmrg	func_dirname_and_basename "$1" "" "."
95634977a2fSmrg	func_stripname '' '.exe' "$func_basename_result"
95734977a2fSmrg	func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
95834977a2fSmrg    fi
95934977a2fSmrg}
96034977a2fSmrg
96134977a2fSmrg# func_ltwrapper_p file
96234977a2fSmrg# True iff FILE is a libtool wrapper script or wrapper executable
96334977a2fSmrg# This function is only a basic sanity check; it will hardly flush out
96434977a2fSmrg# determined imposters.
96534977a2fSmrgfunc_ltwrapper_p ()
96634977a2fSmrg{
96734977a2fSmrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
96834977a2fSmrg}
96934977a2fSmrg
97034977a2fSmrg
97134977a2fSmrg# func_execute_cmds commands fail_cmd
97234977a2fSmrg# Execute tilde-delimited COMMANDS.
97334977a2fSmrg# If FAIL_CMD is given, eval that upon failure.
97434977a2fSmrg# FAIL_CMD may read-access the current command in variable CMD!
97534977a2fSmrgfunc_execute_cmds ()
97634977a2fSmrg{
97734977a2fSmrg    $opt_debug
97834977a2fSmrg    save_ifs=$IFS; IFS='~'
97934977a2fSmrg    for cmd in $1; do
98034977a2fSmrg      IFS=$save_ifs
98134977a2fSmrg      eval cmd=\"$cmd\"
98234977a2fSmrg      func_show_eval "$cmd" "${2-:}"
98334977a2fSmrg    done
98434977a2fSmrg    IFS=$save_ifs
98534977a2fSmrg}
98634977a2fSmrg
98734977a2fSmrg
98834977a2fSmrg# func_source file
98934977a2fSmrg# Source FILE, adding directory component if necessary.
99034977a2fSmrg# Note that it is not necessary on cygwin/mingw to append a dot to
99134977a2fSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
99234977a2fSmrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
99334977a2fSmrg# `FILE.' does not work on cygwin managed mounts.
99434977a2fSmrgfunc_source ()
99534977a2fSmrg{
99634977a2fSmrg    $opt_debug
99734977a2fSmrg    case $1 in
99834977a2fSmrg    */* | *\\*)	. "$1" ;;
99934977a2fSmrg    *)		. "./$1" ;;
100034977a2fSmrg    esac
100134977a2fSmrg}
100234977a2fSmrg
100334977a2fSmrg
100434977a2fSmrg# func_infer_tag arg
100534977a2fSmrg# Infer tagged configuration to use if any are available and
100634977a2fSmrg# if one wasn't chosen via the "--tag" command line option.
100734977a2fSmrg# Only attempt this if the compiler in the base compile
100834977a2fSmrg# command doesn't match the default compiler.
100934977a2fSmrg# arg is usually of the form 'gcc ...'
101034977a2fSmrgfunc_infer_tag ()
101134977a2fSmrg{
101234977a2fSmrg    $opt_debug
101334977a2fSmrg    if test -n "$available_tags" && test -z "$tagname"; then
101434977a2fSmrg      CC_quoted=
101534977a2fSmrg      for arg in $CC; do
101634977a2fSmrg        func_quote_for_eval "$arg"
101734977a2fSmrg	CC_quoted="$CC_quoted $func_quote_for_eval_result"
101834977a2fSmrg      done
101934977a2fSmrg      case $@ in
102034977a2fSmrg      # Blanks in the command may have been stripped by the calling shell,
102134977a2fSmrg      # but not from the CC environment variable when configure was run.
102234977a2fSmrg      " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) ;;
102334977a2fSmrg      # Blanks at the start of $base_compile will cause this to fail
102434977a2fSmrg      # if we don't check for them as well.
102534977a2fSmrg      *)
102634977a2fSmrg	for z in $available_tags; do
102734977a2fSmrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
102834977a2fSmrg	    # Evaluate the configuration.
102934977a2fSmrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
103034977a2fSmrg	    CC_quoted=
103134977a2fSmrg	    for arg in $CC; do
103234977a2fSmrg	      # Double-quote args containing other shell metacharacters.
103334977a2fSmrg	      func_quote_for_eval "$arg"
103434977a2fSmrg	      CC_quoted="$CC_quoted $func_quote_for_eval_result"
103534977a2fSmrg	    done
103634977a2fSmrg	    case "$@ " in
103734977a2fSmrg	      " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*)
103834977a2fSmrg	      # The compiler in the base compile command matches
103934977a2fSmrg	      # the one in the tagged configuration.
104034977a2fSmrg	      # Assume this is the tagged configuration we want.
104134977a2fSmrg	      tagname=$z
104234977a2fSmrg	      break
104334977a2fSmrg	      ;;
104434977a2fSmrg	    esac
104534977a2fSmrg	  fi
104634977a2fSmrg	done
104734977a2fSmrg	# If $tagname still isn't set, then no tagged configuration
104834977a2fSmrg	# was found and let the user know that the "--tag" command
104934977a2fSmrg	# line option must be used.
105034977a2fSmrg	if test -z "$tagname"; then
105134977a2fSmrg	  func_echo "unable to infer tagged configuration"
105234977a2fSmrg	  func_fatal_error "specify a tag with \`--tag'"
105334977a2fSmrg#	else
105434977a2fSmrg#	  func_verbose "using $tagname tagged configuration"
105534977a2fSmrg	fi
105634977a2fSmrg	;;
105734977a2fSmrg      esac
105834977a2fSmrg    fi
105934977a2fSmrg}
106034977a2fSmrg
106134977a2fSmrg
106234977a2fSmrg
106334977a2fSmrg# func_write_libtool_object output_name pic_name nonpic_name
106434977a2fSmrg# Create a libtool object file (analogous to a ".la" file),
106534977a2fSmrg# but don't create it if we're doing a dry run.
106634977a2fSmrgfunc_write_libtool_object ()
106734977a2fSmrg{
106834977a2fSmrg    write_libobj=${1}
106934977a2fSmrg    if test "$build_libtool_libs" = yes; then
107034977a2fSmrg      write_lobj=\'${2}\'
107134977a2fSmrg    else
107234977a2fSmrg      write_lobj=none
107334977a2fSmrg    fi
107434977a2fSmrg
107534977a2fSmrg    if test "$build_old_libs" = yes; then
107634977a2fSmrg      write_oldobj=\'${3}\'
107734977a2fSmrg    else
107834977a2fSmrg      write_oldobj=none
107934977a2fSmrg    fi
108034977a2fSmrg
108134977a2fSmrg    $opt_dry_run || {
108234977a2fSmrg      cat >${write_libobj}T <<EOF
108334977a2fSmrg# $write_libobj - a libtool object file
108434977a2fSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
108534977a2fSmrg#
108634977a2fSmrg# Please DO NOT delete this file!
108734977a2fSmrg# It is necessary for linking the library.
108834977a2fSmrg
108934977a2fSmrg# Name of the PIC object.
109034977a2fSmrgpic_object=$write_lobj
109134977a2fSmrg
109234977a2fSmrg# Name of the non-PIC object
109334977a2fSmrgnon_pic_object=$write_oldobj
109434977a2fSmrg
109534977a2fSmrgEOF
109634977a2fSmrg      $MV "${write_libobj}T" "${write_libobj}"
109734977a2fSmrg    }
109834977a2fSmrg}
109934977a2fSmrg
110034977a2fSmrg# func_mode_compile arg...
110134977a2fSmrgfunc_mode_compile ()
110234977a2fSmrg{
110334977a2fSmrg    $opt_debug
110434977a2fSmrg    # Get the compilation command and the source file.
110534977a2fSmrg    base_compile=
110634977a2fSmrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
110734977a2fSmrg    suppress_opt=yes
110834977a2fSmrg    suppress_output=
110934977a2fSmrg    arg_mode=normal
111034977a2fSmrg    libobj=
111134977a2fSmrg    later=
111234977a2fSmrg    pie_flag=
111334977a2fSmrg
111434977a2fSmrg    for arg
111534977a2fSmrg    do
111634977a2fSmrg      case $arg_mode in
111734977a2fSmrg      arg  )
111834977a2fSmrg	# do not "continue".  Instead, add this to base_compile
111934977a2fSmrg	lastarg="$arg"
112034977a2fSmrg	arg_mode=normal
112134977a2fSmrg	;;
112234977a2fSmrg
112334977a2fSmrg      target )
112434977a2fSmrg	libobj="$arg"
112534977a2fSmrg	arg_mode=normal
112634977a2fSmrg	continue
112734977a2fSmrg	;;
112834977a2fSmrg
112934977a2fSmrg      normal )
113034977a2fSmrg	# Accept any command-line options.
113134977a2fSmrg	case $arg in
113234977a2fSmrg	-o)
113334977a2fSmrg	  test -n "$libobj" && \
113434977a2fSmrg	    func_fatal_error "you cannot specify \`-o' more than once"
113534977a2fSmrg	  arg_mode=target
113634977a2fSmrg	  continue
113734977a2fSmrg	  ;;
113834977a2fSmrg
113934977a2fSmrg	-pie | -fpie | -fPIE)
114034977a2fSmrg          pie_flag="$pie_flag $arg"
114134977a2fSmrg	  continue
114234977a2fSmrg	  ;;
114334977a2fSmrg
114434977a2fSmrg	-shared | -static | -prefer-pic | -prefer-non-pic)
114534977a2fSmrg	  later="$later $arg"
114634977a2fSmrg	  continue
114734977a2fSmrg	  ;;
1148ee3138f1Smrg
1149ee3138f1Smrg	-no-suppress)
1150ee3138f1Smrg	  suppress_opt=no
1151ee3138f1Smrg	  continue
1152ee3138f1Smrg	  ;;
1153ee3138f1Smrg
1154ee3138f1Smrg	-Xcompiler)
1155ee3138f1Smrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
1156ee3138f1Smrg	  continue      #  The current "srcfile" will either be retained or
1157ee3138f1Smrg	  ;;            #  replaced later.  I would guess that would be a bug.
1158ee3138f1Smrg
1159ee3138f1Smrg	-Wc,*)
116034977a2fSmrg	  func_stripname '-Wc,' '' "$arg"
116134977a2fSmrg	  args=$func_stripname_result
1162ee3138f1Smrg	  lastarg=
1163ee3138f1Smrg	  save_ifs="$IFS"; IFS=','
116434977a2fSmrg	  for arg in $args; do
1165ee3138f1Smrg	    IFS="$save_ifs"
116634977a2fSmrg	    func_quote_for_eval "$arg"
116734977a2fSmrg	    lastarg="$lastarg $func_quote_for_eval_result"
1168ee3138f1Smrg	  done
1169ee3138f1Smrg	  IFS="$save_ifs"
117034977a2fSmrg	  func_stripname ' ' '' "$lastarg"
117134977a2fSmrg	  lastarg=$func_stripname_result
1172ee3138f1Smrg
1173ee3138f1Smrg	  # Add the arguments to base_compile.
1174ee3138f1Smrg	  base_compile="$base_compile $lastarg"
1175ee3138f1Smrg	  continue
1176ee3138f1Smrg	  ;;
1177ee3138f1Smrg
117834977a2fSmrg	*)
1179ee3138f1Smrg	  # Accept the current argument as the source file.
1180ee3138f1Smrg	  # The previous "srcfile" becomes the current argument.
1181ee3138f1Smrg	  #
1182ee3138f1Smrg	  lastarg="$srcfile"
1183ee3138f1Smrg	  srcfile="$arg"
1184ee3138f1Smrg	  ;;
1185ee3138f1Smrg	esac  #  case $arg
1186ee3138f1Smrg	;;
1187ee3138f1Smrg      esac    #  case $arg_mode
1188ee3138f1Smrg
1189ee3138f1Smrg      # Aesthetically quote the previous argument.
119034977a2fSmrg      func_quote_for_eval "$lastarg"
119134977a2fSmrg      base_compile="$base_compile $func_quote_for_eval_result"
1192ee3138f1Smrg    done # for arg
1193ee3138f1Smrg
1194ee3138f1Smrg    case $arg_mode in
1195ee3138f1Smrg    arg)
119634977a2fSmrg      func_fatal_error "you must specify an argument for -Xcompile"
1197ee3138f1Smrg      ;;
1198ee3138f1Smrg    target)
119934977a2fSmrg      func_fatal_error "you must specify a target with \`-o'"
1200ee3138f1Smrg      ;;
1201ee3138f1Smrg    *)
1202ee3138f1Smrg      # Get the name of the library object.
120334977a2fSmrg      test -z "$libobj" && {
120434977a2fSmrg	func_basename "$srcfile"
120534977a2fSmrg	libobj="$func_basename_result"
120634977a2fSmrg      }
1207ee3138f1Smrg      ;;
1208ee3138f1Smrg    esac
1209ee3138f1Smrg
1210ee3138f1Smrg    # Recognize several different file suffixes.
1211ee3138f1Smrg    # If the user specifies -o file.o, it is replaced with file.lo
1212ee3138f1Smrg    case $libobj in
121334977a2fSmrg    *.[cCFSifmso] | \
121434977a2fSmrg    *.ada | *.adb | *.ads | *.asm | \
121534977a2fSmrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
121634977a2fSmrg    *.[fF][09]? | *.for | *.java | *.obj | *.sx)
121734977a2fSmrg      func_xform "$libobj"
121834977a2fSmrg      libobj=$func_xform_result
121934977a2fSmrg      ;;
1220ee3138f1Smrg    esac
1221ee3138f1Smrg
1222ee3138f1Smrg    case $libobj in
122334977a2fSmrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
1224ee3138f1Smrg    *)
122534977a2fSmrg      func_fatal_error "cannot determine name of library object from \`$libobj'"
1226ee3138f1Smrg      ;;
1227ee3138f1Smrg    esac
1228ee3138f1Smrg
1229ee3138f1Smrg    func_infer_tag $base_compile
1230ee3138f1Smrg
1231ee3138f1Smrg    for arg in $later; do
1232ee3138f1Smrg      case $arg in
123334977a2fSmrg      -shared)
123434977a2fSmrg	test "$build_libtool_libs" != yes && \
123534977a2fSmrg	  func_fatal_configuration "can not build a shared library"
123634977a2fSmrg	build_old_libs=no
123734977a2fSmrg	continue
123834977a2fSmrg	;;
123934977a2fSmrg
1240ee3138f1Smrg      -static)
124134977a2fSmrg	build_libtool_libs=no
1242ee3138f1Smrg	build_old_libs=yes
1243ee3138f1Smrg	continue
1244ee3138f1Smrg	;;
1245ee3138f1Smrg
1246ee3138f1Smrg      -prefer-pic)
1247ee3138f1Smrg	pic_mode=yes
1248ee3138f1Smrg	continue
1249ee3138f1Smrg	;;
1250ee3138f1Smrg
1251ee3138f1Smrg      -prefer-non-pic)
1252ee3138f1Smrg	pic_mode=no
1253ee3138f1Smrg	continue
1254ee3138f1Smrg	;;
1255ee3138f1Smrg      esac
1256ee3138f1Smrg    done
1257ee3138f1Smrg
125834977a2fSmrg    func_quote_for_eval "$libobj"
125934977a2fSmrg    test "X$libobj" != "X$func_quote_for_eval_result" \
126034977a2fSmrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
126134977a2fSmrg      && func_warning "libobj name \`$libobj' may not contain shell special characters."
126234977a2fSmrg    func_dirname_and_basename "$obj" "/" ""
126334977a2fSmrg    objname="$func_basename_result"
126434977a2fSmrg    xdir="$func_dirname_result"
1265ee3138f1Smrg    lobj=${xdir}$objdir/$objname
1266ee3138f1Smrg
126734977a2fSmrg    test -z "$base_compile" && \
126834977a2fSmrg      func_fatal_help "you must specify a compilation command"
1269ee3138f1Smrg
1270ee3138f1Smrg    # Delete any leftover library objects.
1271ee3138f1Smrg    if test "$build_old_libs" = yes; then
1272ee3138f1Smrg      removelist="$obj $lobj $libobj ${libobj}T"
1273ee3138f1Smrg    else
1274ee3138f1Smrg      removelist="$lobj $libobj ${libobj}T"
1275ee3138f1Smrg    fi
1276ee3138f1Smrg
1277ee3138f1Smrg    # On Cygwin there's no "real" PIC flag so we must build both object types
1278ee3138f1Smrg    case $host_os in
127934977a2fSmrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
1280ee3138f1Smrg      pic_mode=default
1281ee3138f1Smrg      ;;
1282ee3138f1Smrg    esac
1283ee3138f1Smrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
1284ee3138f1Smrg      # non-PIC code in shared libraries is not supported
1285ee3138f1Smrg      pic_mode=default
1286ee3138f1Smrg    fi
1287ee3138f1Smrg
1288ee3138f1Smrg    # Calculate the filename of the output object if compiler does
1289ee3138f1Smrg    # not support -o with -c
1290ee3138f1Smrg    if test "$compiler_c_o" = no; then
129134977a2fSmrg      output_obj=`$ECHO "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
1292ee3138f1Smrg      lockfile="$output_obj.lock"
1293ee3138f1Smrg    else
1294ee3138f1Smrg      output_obj=
1295ee3138f1Smrg      need_locks=no
1296ee3138f1Smrg      lockfile=
1297ee3138f1Smrg    fi
1298ee3138f1Smrg
1299ee3138f1Smrg    # Lock this critical section if it is needed
1300ee3138f1Smrg    # We use this script file to make the link, it avoids creating a new file
1301ee3138f1Smrg    if test "$need_locks" = yes; then
130234977a2fSmrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
130334977a2fSmrg	func_echo "Waiting for $lockfile to be removed"
1304ee3138f1Smrg	sleep 2
1305ee3138f1Smrg      done
1306ee3138f1Smrg    elif test "$need_locks" = warn; then
1307ee3138f1Smrg      if test -f "$lockfile"; then
130834977a2fSmrg	$ECHO "\
1309ee3138f1Smrg*** ERROR, $lockfile exists and contains:
1310ee3138f1Smrg`cat $lockfile 2>/dev/null`
1311ee3138f1Smrg
1312ee3138f1SmrgThis indicates that another process is trying to use the same
1313ee3138f1Smrgtemporary object file, and libtool could not work around it because
1314ee3138f1Smrgyour compiler does not support \`-c' and \`-o' together.  If you
1315ee3138f1Smrgrepeat this compilation, it may succeed, by chance, but you had better
1316ee3138f1Smrgavoid parallel builds (make -j) in this platform, or get a better
1317ee3138f1Smrgcompiler."
1318ee3138f1Smrg
131934977a2fSmrg	$opt_dry_run || $RM $removelist
1320ee3138f1Smrg	exit $EXIT_FAILURE
1321ee3138f1Smrg      fi
132234977a2fSmrg      removelist="$removelist $output_obj"
132334977a2fSmrg      $ECHO "$srcfile" > "$lockfile"
1324ee3138f1Smrg    fi
1325ee3138f1Smrg
132634977a2fSmrg    $opt_dry_run || $RM $removelist
132734977a2fSmrg    removelist="$removelist $lockfile"
132834977a2fSmrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
132934977a2fSmrg
1330ee3138f1Smrg    if test -n "$fix_srcfile_path"; then
1331ee3138f1Smrg      eval srcfile=\"$fix_srcfile_path\"
1332ee3138f1Smrg    fi
133334977a2fSmrg    func_quote_for_eval "$srcfile"
133434977a2fSmrg    qsrcfile=$func_quote_for_eval_result
1335ee3138f1Smrg
1336ee3138f1Smrg    # Only build a PIC object if we are building libtool libraries.
1337ee3138f1Smrg    if test "$build_libtool_libs" = yes; then
1338ee3138f1Smrg      # Without this assignment, base_compile gets emptied.
1339ee3138f1Smrg      fbsd_hideous_sh_bug=$base_compile
1340ee3138f1Smrg
1341ee3138f1Smrg      if test "$pic_mode" != no; then
1342ee3138f1Smrg	command="$base_compile $qsrcfile $pic_flag"
1343ee3138f1Smrg      else
1344ee3138f1Smrg	# Don't build PIC code
1345ee3138f1Smrg	command="$base_compile $qsrcfile"
1346ee3138f1Smrg      fi
1347ee3138f1Smrg
134834977a2fSmrg      func_mkdir_p "$xdir$objdir"
1349ee3138f1Smrg
1350ee3138f1Smrg      if test -z "$output_obj"; then
1351ee3138f1Smrg	# Place PIC objects in $objdir
1352ee3138f1Smrg	command="$command -o $lobj"
1353ee3138f1Smrg      fi
1354ee3138f1Smrg
135534977a2fSmrg      func_show_eval_locale "$command"	\
135634977a2fSmrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
1357ee3138f1Smrg
1358ee3138f1Smrg      if test "$need_locks" = warn &&
1359ee3138f1Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
136034977a2fSmrg	$ECHO "\
1361ee3138f1Smrg*** ERROR, $lockfile contains:
1362ee3138f1Smrg`cat $lockfile 2>/dev/null`
1363ee3138f1Smrg
1364ee3138f1Smrgbut it should contain:
1365ee3138f1Smrg$srcfile
1366ee3138f1Smrg
1367ee3138f1SmrgThis indicates that another process is trying to use the same
1368ee3138f1Smrgtemporary object file, and libtool could not work around it because
1369ee3138f1Smrgyour compiler does not support \`-c' and \`-o' together.  If you
1370ee3138f1Smrgrepeat this compilation, it may succeed, by chance, but you had better
1371ee3138f1Smrgavoid parallel builds (make -j) in this platform, or get a better
1372ee3138f1Smrgcompiler."
1373ee3138f1Smrg
137434977a2fSmrg	$opt_dry_run || $RM $removelist
1375ee3138f1Smrg	exit $EXIT_FAILURE
1376ee3138f1Smrg      fi
1377ee3138f1Smrg
1378ee3138f1Smrg      # Just move the object if needed, then go on to compile the next one
1379ee3138f1Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
138034977a2fSmrg	func_show_eval '$MV "$output_obj" "$lobj"' \
138134977a2fSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
1382ee3138f1Smrg      fi
1383ee3138f1Smrg
1384ee3138f1Smrg      # Allow error messages only from the first compilation.
1385ee3138f1Smrg      if test "$suppress_opt" = yes; then
138634977a2fSmrg	suppress_output=' >/dev/null 2>&1'
1387ee3138f1Smrg      fi
1388ee3138f1Smrg    fi
1389ee3138f1Smrg
1390ee3138f1Smrg    # Only build a position-dependent object if we build old libraries.
1391ee3138f1Smrg    if test "$build_old_libs" = yes; then
1392ee3138f1Smrg      if test "$pic_mode" != yes; then
1393ee3138f1Smrg	# Don't build PIC code
139434977a2fSmrg	command="$base_compile $qsrcfile$pie_flag"
1395ee3138f1Smrg      else
1396ee3138f1Smrg	command="$base_compile $qsrcfile $pic_flag"
1397ee3138f1Smrg      fi
1398ee3138f1Smrg      if test "$compiler_c_o" = yes; then
1399ee3138f1Smrg	command="$command -o $obj"
1400ee3138f1Smrg      fi
1401ee3138f1Smrg
1402ee3138f1Smrg      # Suppress compiler output if we already did a PIC compilation.
1403ee3138f1Smrg      command="$command$suppress_output"
140434977a2fSmrg      func_show_eval_locale "$command" \
140534977a2fSmrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
1406ee3138f1Smrg
1407ee3138f1Smrg      if test "$need_locks" = warn &&
1408ee3138f1Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
140934977a2fSmrg	$ECHO "\
1410ee3138f1Smrg*** ERROR, $lockfile contains:
1411ee3138f1Smrg`cat $lockfile 2>/dev/null`
1412ee3138f1Smrg
1413ee3138f1Smrgbut it should contain:
1414ee3138f1Smrg$srcfile
1415ee3138f1Smrg
1416ee3138f1SmrgThis indicates that another process is trying to use the same
1417ee3138f1Smrgtemporary object file, and libtool could not work around it because
1418ee3138f1Smrgyour compiler does not support \`-c' and \`-o' together.  If you
1419ee3138f1Smrgrepeat this compilation, it may succeed, by chance, but you had better
1420ee3138f1Smrgavoid parallel builds (make -j) in this platform, or get a better
1421ee3138f1Smrgcompiler."
1422ee3138f1Smrg
142334977a2fSmrg	$opt_dry_run || $RM $removelist
1424ee3138f1Smrg	exit $EXIT_FAILURE
1425ee3138f1Smrg      fi
1426ee3138f1Smrg
1427ee3138f1Smrg      # Just move the object if needed
1428ee3138f1Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
142934977a2fSmrg	func_show_eval '$MV "$output_obj" "$obj"' \
143034977a2fSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
1431ee3138f1Smrg      fi
1432ee3138f1Smrg    fi
1433ee3138f1Smrg
143434977a2fSmrg    $opt_dry_run || {
143534977a2fSmrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
1436ee3138f1Smrg
143734977a2fSmrg      # Unlock the critical section if it was locked
143834977a2fSmrg      if test "$need_locks" != no; then
143934977a2fSmrg	removelist=$lockfile
144034977a2fSmrg        $RM "$lockfile"
144134977a2fSmrg      fi
144234977a2fSmrg    }
1443ee3138f1Smrg
1444ee3138f1Smrg    exit $EXIT_SUCCESS
144534977a2fSmrg}
1446ee3138f1Smrg
144734977a2fSmrg$opt_help || {
144834977a2fSmrgtest "$mode" = compile && func_mode_compile ${1+"$@"}
144934977a2fSmrg}
1450ee3138f1Smrg
145134977a2fSmrgfunc_mode_help ()
145234977a2fSmrg{
145334977a2fSmrg    # We need to display help for each of the modes.
145434977a2fSmrg    case $mode in
145534977a2fSmrg      "")
145634977a2fSmrg        # Generic help is extracted from the usage comments
145734977a2fSmrg        # at the start of this file.
145834977a2fSmrg        func_help
145934977a2fSmrg        ;;
1460ee3138f1Smrg
146134977a2fSmrg      clean)
146234977a2fSmrg        $ECHO \
146334977a2fSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
1464ee3138f1Smrg
146534977a2fSmrgRemove files from the build directory.
1466ee3138f1Smrg
146734977a2fSmrgRM is the name of the program to use to delete files associated with each FILE
146834977a2fSmrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
146934977a2fSmrgto RM.
1470ee3138f1Smrg
147134977a2fSmrgIf FILE is a libtool library, object or program, all the files associated
147234977a2fSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
147334977a2fSmrg        ;;
1474ee3138f1Smrg
147534977a2fSmrg      compile)
147634977a2fSmrg      $ECHO \
147734977a2fSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
1478ee3138f1Smrg
147934977a2fSmrgCompile a source file into a libtool library object.
1480ee3138f1Smrg
148134977a2fSmrgThis mode accepts the following additional options:
1482ee3138f1Smrg
148334977a2fSmrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
148434977a2fSmrg  -no-suppress      do not suppress compiler output for multiple passes
148534977a2fSmrg  -prefer-pic       try to building PIC objects only
148634977a2fSmrg  -prefer-non-pic   try to building non-PIC objects only
148734977a2fSmrg  -shared           do not build a \`.o' file suitable for static linking
148834977a2fSmrg  -static           only build a \`.o' file suitable for static linking
1489ee3138f1Smrg
149034977a2fSmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
149134977a2fSmrgfrom the given SOURCEFILE.
1492ee3138f1Smrg
149334977a2fSmrgThe output file name is determined by removing the directory component from
149434977a2fSmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
149534977a2fSmrglibrary object suffix, \`.lo'."
149634977a2fSmrg        ;;
1497ee3138f1Smrg
149834977a2fSmrg      execute)
149934977a2fSmrg        $ECHO \
150034977a2fSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
1501ee3138f1Smrg
150234977a2fSmrgAutomatically set library path, then run a program.
1503ee3138f1Smrg
150434977a2fSmrgThis mode accepts the following additional options:
1505ee3138f1Smrg
150634977a2fSmrg  -dlopen FILE      add the directory containing FILE to the library path
1507ee3138f1Smrg
150834977a2fSmrgThis mode sets the library path environment variable according to \`-dlopen'
150934977a2fSmrgflags.
1510ee3138f1Smrg
151134977a2fSmrgIf any of the ARGS are libtool executable wrappers, then they are translated
151234977a2fSmrginto their corresponding uninstalled binary, and any of their required library
151334977a2fSmrgdirectories are added to the library path.
1514ee3138f1Smrg
151534977a2fSmrgThen, COMMAND is executed, with ARGS as arguments."
151634977a2fSmrg        ;;
1517ee3138f1Smrg
151834977a2fSmrg      finish)
151934977a2fSmrg        $ECHO \
152034977a2fSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
1521ee3138f1Smrg
152234977a2fSmrgComplete the installation of libtool libraries.
1523ee3138f1Smrg
152434977a2fSmrgEach LIBDIR is a directory that contains libtool libraries.
1525ee3138f1Smrg
152634977a2fSmrgThe commands that this mode executes may require superuser privileges.  Use
152734977a2fSmrgthe \`--dry-run' option if you just want to see what would be executed."
152834977a2fSmrg        ;;
1529ee3138f1Smrg
153034977a2fSmrg      install)
153134977a2fSmrg        $ECHO \
153234977a2fSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
1533ee3138f1Smrg
153434977a2fSmrgInstall executables or libraries.
1535ee3138f1Smrg
153634977a2fSmrgINSTALL-COMMAND is the installation command.  The first component should be
153734977a2fSmrgeither the \`install' or \`cp' program.
1538ee3138f1Smrg
153934977a2fSmrgThe following components of INSTALL-COMMAND are treated specially:
1540ee3138f1Smrg
154134977a2fSmrg  -inst-prefix PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
1542ee3138f1Smrg
154334977a2fSmrgThe rest of the components are interpreted as arguments to that command (only
154434977a2fSmrgBSD-compatible install options are recognized)."
154534977a2fSmrg        ;;
1546ee3138f1Smrg
154734977a2fSmrg      link)
154834977a2fSmrg        $ECHO \
154934977a2fSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
1550ee3138f1Smrg
155134977a2fSmrgLink object files or libraries together to form another library, or to
155234977a2fSmrgcreate an executable program.
1553ee3138f1Smrg
155434977a2fSmrgLINK-COMMAND is a command using the C compiler that you would use to create
155534977a2fSmrga program from several object files.
1556ee3138f1Smrg
155734977a2fSmrgThe following components of LINK-COMMAND are treated specially:
1558ee3138f1Smrg
155934977a2fSmrg  -all-static       do not do any dynamic linking at all
156034977a2fSmrg  -avoid-version    do not add a version suffix if possible
156134977a2fSmrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
156234977a2fSmrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
156334977a2fSmrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
156434977a2fSmrg  -export-symbols SYMFILE
156534977a2fSmrg                    try to export only the symbols listed in SYMFILE
156634977a2fSmrg  -export-symbols-regex REGEX
156734977a2fSmrg                    try to export only the symbols matching REGEX
156834977a2fSmrg  -LLIBDIR          search LIBDIR for required installed libraries
156934977a2fSmrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
157034977a2fSmrg  -module           build a library that can dlopened
157134977a2fSmrg  -no-fast-install  disable the fast-install mode
157234977a2fSmrg  -no-install       link a not-installable executable
157334977a2fSmrg  -no-undefined     declare that a library does not refer to external symbols
157434977a2fSmrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
157534977a2fSmrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
157634977a2fSmrg  -precious-files-regex REGEX
157734977a2fSmrg                    don't remove output files matching REGEX
157834977a2fSmrg  -release RELEASE  specify package release information
157934977a2fSmrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
158034977a2fSmrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
158134977a2fSmrg  -shared           only do dynamic linking of libtool libraries
158234977a2fSmrg  -shrext SUFFIX    override the standard shared library file extension
158334977a2fSmrg  -static           do not do any dynamic linking of uninstalled libtool libraries
158434977a2fSmrg  -static-libtool-libs
158534977a2fSmrg                    do not do any dynamic linking of libtool libraries
158634977a2fSmrg  -version-info CURRENT[:REVISION[:AGE]]
158734977a2fSmrg                    specify library version info [each variable defaults to 0]
158834977a2fSmrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
1589ee3138f1Smrg
159034977a2fSmrgAll other options (arguments beginning with \`-') are ignored.
1591ee3138f1Smrg
159234977a2fSmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
159334977a2fSmrgtreated as uninstalled libtool libraries, other files are standard or library
159434977a2fSmrgobject files.
159579a8a9c6Smrg
159634977a2fSmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
159734977a2fSmrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
159834977a2fSmrgrequired, except when creating a convenience library.
1599ee3138f1Smrg
160034977a2fSmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
160134977a2fSmrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
1602ee3138f1Smrg
160334977a2fSmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
160434977a2fSmrgis created, otherwise an executable program is created."
1605ee3138f1Smrg        ;;
1606ee3138f1Smrg
160734977a2fSmrg      uninstall)
160834977a2fSmrg        $ECHO \
160934977a2fSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
1610ee3138f1Smrg
161134977a2fSmrgRemove libraries from an installation directory.
1612ee3138f1Smrg
161334977a2fSmrgRM is the name of the program to use to delete files associated with each FILE
161434977a2fSmrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
161534977a2fSmrgto RM.
1616ee3138f1Smrg
161734977a2fSmrgIf FILE is a libtool library, all the files associated with it are deleted.
161834977a2fSmrgOtherwise, only FILE itself is deleted using RM."
161934977a2fSmrg        ;;
1620ee3138f1Smrg
162134977a2fSmrg      *)
162234977a2fSmrg        func_fatal_help "invalid operation mode \`$mode'"
162334977a2fSmrg        ;;
162434977a2fSmrg    esac
1625ee3138f1Smrg
162634977a2fSmrg    $ECHO
162734977a2fSmrg    $ECHO "Try \`$progname --help' for more information about other modes."
1628ee3138f1Smrg
162934977a2fSmrg    exit $?
163034977a2fSmrg}
1631ee3138f1Smrg
163234977a2fSmrg  # Now that we've collected a possible --mode arg, show help if necessary
163334977a2fSmrg  $opt_help && func_mode_help
1634ee3138f1Smrg
1635ee3138f1Smrg
163634977a2fSmrg# func_mode_execute arg...
163734977a2fSmrgfunc_mode_execute ()
163834977a2fSmrg{
163934977a2fSmrg    $opt_debug
164034977a2fSmrg    # The first argument is the command name.
164134977a2fSmrg    cmd="$nonopt"
164234977a2fSmrg    test -z "$cmd" && \
164334977a2fSmrg      func_fatal_help "you must specify a COMMAND"
1644ee3138f1Smrg
164534977a2fSmrg    # Handle -dlopen flags immediately.
164634977a2fSmrg    for file in $execute_dlfiles; do
164734977a2fSmrg      test -f "$file" \
164834977a2fSmrg	|| func_fatal_help "\`$file' is not a file"
1649ee3138f1Smrg
165034977a2fSmrg      dir=
165134977a2fSmrg      case $file in
165234977a2fSmrg      *.la)
165334977a2fSmrg	# Check to see that this really is a libtool archive.
165434977a2fSmrg	func_lalib_unsafe_p "$file" \
165534977a2fSmrg	  || func_fatal_help "\`$lib' is not a valid libtool archive"
1656ee3138f1Smrg
165734977a2fSmrg	# Read the libtool library.
165834977a2fSmrg	dlname=
165934977a2fSmrg	library_names=
166034977a2fSmrg	func_source "$file"
1661ee3138f1Smrg
166234977a2fSmrg	# Skip this library if it cannot be dlopened.
166334977a2fSmrg	if test -z "$dlname"; then
166434977a2fSmrg	  # Warn if it was a shared library.
166534977a2fSmrg	  test -n "$library_names" && \
166634977a2fSmrg	    func_warning "\`$file' was not linked with \`-export-dynamic'"
166734977a2fSmrg	  continue
166834977a2fSmrg	fi
1669ee3138f1Smrg
167034977a2fSmrg	func_dirname "$file" "" "."
167134977a2fSmrg	dir="$func_dirname_result"
1672ee3138f1Smrg
167334977a2fSmrg	if test -f "$dir/$objdir/$dlname"; then
167434977a2fSmrg	  dir="$dir/$objdir"
167534977a2fSmrg	else
167634977a2fSmrg	  if test ! -f "$dir/$dlname"; then
167734977a2fSmrg	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
167834977a2fSmrg	  fi
167934977a2fSmrg	fi
1680ee3138f1Smrg	;;
1681ee3138f1Smrg
168234977a2fSmrg      *.lo)
168334977a2fSmrg	# Just add the directory containing the .lo file.
168434977a2fSmrg	func_dirname "$file" "" "."
168534977a2fSmrg	dir="$func_dirname_result"
1686ee3138f1Smrg	;;
1687ee3138f1Smrg
168834977a2fSmrg      *)
168934977a2fSmrg	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
1690ee3138f1Smrg	continue
1691ee3138f1Smrg	;;
169234977a2fSmrg      esac
1693ee3138f1Smrg
169434977a2fSmrg      # Get the absolute pathname.
169534977a2fSmrg      absdir=`cd "$dir" && pwd`
169634977a2fSmrg      test -n "$absdir" && dir="$absdir"
1697ee3138f1Smrg
169834977a2fSmrg      # Now add the directory to shlibpath_var.
169934977a2fSmrg      if eval "test -z \"\$$shlibpath_var\""; then
170034977a2fSmrg	eval "$shlibpath_var=\"\$dir\""
170134977a2fSmrg      else
170234977a2fSmrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
170334977a2fSmrg      fi
170434977a2fSmrg    done
1705ee3138f1Smrg
170634977a2fSmrg    # This variable tells wrapper scripts just to set shlibpath_var
170734977a2fSmrg    # rather than running their programs.
170834977a2fSmrg    libtool_execute_magic="$magic"
1709ee3138f1Smrg
171034977a2fSmrg    # Check if any of the arguments is a wrapper script.
171134977a2fSmrg    args=
171234977a2fSmrg    for file
171334977a2fSmrg    do
171434977a2fSmrg      case $file in
171534977a2fSmrg      -*) ;;
171634977a2fSmrg      *)
171734977a2fSmrg	# Do a test to see if this is really a libtool program.
171834977a2fSmrg	if func_ltwrapper_script_p "$file"; then
171934977a2fSmrg	  func_source "$file"
172034977a2fSmrg	  # Transform arg to wrapped name.
172134977a2fSmrg	  file="$progdir/$program"
172234977a2fSmrg	elif func_ltwrapper_executable_p "$file"; then
172334977a2fSmrg	  func_ltwrapper_scriptname "$file"
172434977a2fSmrg	  func_source "$func_ltwrapper_scriptname_result"
172534977a2fSmrg	  # Transform arg to wrapped name.
172634977a2fSmrg	  file="$progdir/$program"
172734977a2fSmrg	fi
172834977a2fSmrg	;;
172934977a2fSmrg      esac
173034977a2fSmrg      # Quote arguments (to preserve shell metacharacters).
173134977a2fSmrg      func_quote_for_eval "$file"
173234977a2fSmrg      args="$args $func_quote_for_eval_result"
173334977a2fSmrg    done
1734ee3138f1Smrg
173534977a2fSmrg    if test "X$opt_dry_run" = Xfalse; then
173634977a2fSmrg      if test -n "$shlibpath_var"; then
173734977a2fSmrg	# Export the shlibpath_var.
173834977a2fSmrg	eval "export $shlibpath_var"
173934977a2fSmrg      fi
1740ee3138f1Smrg
174134977a2fSmrg      # Restore saved environment variables
174234977a2fSmrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
174334977a2fSmrg      do
174434977a2fSmrg	eval "if test \"\${save_$lt_var+set}\" = set; then
174534977a2fSmrg                $lt_var=\$save_$lt_var; export $lt_var
1746ee3138f1Smrg	      else
174734977a2fSmrg		$lt_unset $lt_var
174834977a2fSmrg	      fi"
174934977a2fSmrg      done
1750ee3138f1Smrg
175134977a2fSmrg      # Now prepare to actually exec the command.
175234977a2fSmrg      exec_cmd="\$cmd$args"
175334977a2fSmrg    else
175434977a2fSmrg      # Display what would be done.
175534977a2fSmrg      if test -n "$shlibpath_var"; then
175634977a2fSmrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
175734977a2fSmrg	$ECHO "export $shlibpath_var"
175834977a2fSmrg      fi
175934977a2fSmrg      $ECHO "$cmd$args"
176034977a2fSmrg      exit $EXIT_SUCCESS
176134977a2fSmrg    fi
176234977a2fSmrg}
1763ee3138f1Smrg
176434977a2fSmrgtest "$mode" = execute && func_mode_execute ${1+"$@"}
1765ee3138f1Smrg
1766ee3138f1Smrg
176734977a2fSmrg# func_mode_finish arg...
176834977a2fSmrgfunc_mode_finish ()
176934977a2fSmrg{
177034977a2fSmrg    $opt_debug
177134977a2fSmrg    libdirs="$nonopt"
177234977a2fSmrg    admincmds=
1773ee3138f1Smrg
177434977a2fSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
177534977a2fSmrg      for dir
177634977a2fSmrg      do
177734977a2fSmrg	libdirs="$libdirs $dir"
177834977a2fSmrg      done
1779ee3138f1Smrg
178034977a2fSmrg      for libdir in $libdirs; do
178134977a2fSmrg	if test -n "$finish_cmds"; then
178234977a2fSmrg	  # Do each command in the finish commands.
178334977a2fSmrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
178434977a2fSmrg'"$cmd"'"'
1785ee3138f1Smrg	fi
178634977a2fSmrg	if test -n "$finish_eval"; then
178734977a2fSmrg	  # Do the single finish_eval.
178834977a2fSmrg	  eval cmds=\"$finish_eval\"
178934977a2fSmrg	  $opt_dry_run || eval "$cmds" || admincmds="$admincmds
179034977a2fSmrg       $cmds"
179134977a2fSmrg	fi
179234977a2fSmrg      done
179334977a2fSmrg    fi
1794ee3138f1Smrg
179534977a2fSmrg    # Exit here if they wanted silent mode.
179634977a2fSmrg    $opt_silent && exit $EXIT_SUCCESS
1797ee3138f1Smrg
179834977a2fSmrg    $ECHO "X----------------------------------------------------------------------" | $Xsed
179934977a2fSmrg    $ECHO "Libraries have been installed in:"
180034977a2fSmrg    for libdir in $libdirs; do
180134977a2fSmrg      $ECHO "   $libdir"
180234977a2fSmrg    done
180334977a2fSmrg    $ECHO
180434977a2fSmrg    $ECHO "If you ever happen to want to link against installed libraries"
180534977a2fSmrg    $ECHO "in a given directory, LIBDIR, you must either use libtool, and"
180634977a2fSmrg    $ECHO "specify the full pathname of the library, or use the \`-LLIBDIR'"
180734977a2fSmrg    $ECHO "flag during linking and do at least one of the following:"
180834977a2fSmrg    if test -n "$shlibpath_var"; then
180934977a2fSmrg      $ECHO "   - add LIBDIR to the \`$shlibpath_var' environment variable"
181034977a2fSmrg      $ECHO "     during execution"
181134977a2fSmrg    fi
181234977a2fSmrg    if test -n "$runpath_var"; then
181334977a2fSmrg      $ECHO "   - add LIBDIR to the \`$runpath_var' environment variable"
181434977a2fSmrg      $ECHO "     during linking"
181534977a2fSmrg    fi
181634977a2fSmrg    if test -n "$hardcode_libdir_flag_spec"; then
181734977a2fSmrg      libdir=LIBDIR
181834977a2fSmrg      eval flag=\"$hardcode_libdir_flag_spec\"
1819ee3138f1Smrg
182034977a2fSmrg      $ECHO "   - use the \`$flag' linker flag"
182134977a2fSmrg    fi
182234977a2fSmrg    if test -n "$admincmds"; then
182334977a2fSmrg      $ECHO "   - have your system administrator run these commands:$admincmds"
182434977a2fSmrg    fi
182534977a2fSmrg    if test -f /etc/ld.so.conf; then
182634977a2fSmrg      $ECHO "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
182734977a2fSmrg    fi
182834977a2fSmrg    $ECHO
182934977a2fSmrg
183034977a2fSmrg    $ECHO "See any operating system documentation about shared libraries for"
183134977a2fSmrg    case $host in
183234977a2fSmrg      solaris2.[6789]|solaris2.1[0-9])
183334977a2fSmrg        $ECHO "more information, such as the ld(1), crle(1) and ld.so(8) manual"
183434977a2fSmrg	$ECHO "pages."
1835ee3138f1Smrg	;;
183634977a2fSmrg      *)
183734977a2fSmrg        $ECHO "more information, such as the ld(1) and ld.so(8) manual pages."
183834977a2fSmrg        ;;
183934977a2fSmrg    esac
184034977a2fSmrg    $ECHO "X----------------------------------------------------------------------" | $Xsed
184134977a2fSmrg    exit $EXIT_SUCCESS
184234977a2fSmrg}
1843ee3138f1Smrg
184434977a2fSmrgtest "$mode" = finish && func_mode_finish ${1+"$@"}
1845ee3138f1Smrg
184679a8a9c6Smrg
184734977a2fSmrg# func_mode_install arg...
184834977a2fSmrgfunc_mode_install ()
184934977a2fSmrg{
185034977a2fSmrg    $opt_debug
185134977a2fSmrg    # There may be an optional sh(1) argument at the beginning of
185234977a2fSmrg    # install_prog (especially on Windows NT).
185334977a2fSmrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
185434977a2fSmrg       # Allow the use of GNU shtool's install command.
185534977a2fSmrg       $ECHO "X$nonopt" | $GREP shtool >/dev/null; then
185634977a2fSmrg      # Aesthetically quote it.
185734977a2fSmrg      func_quote_for_eval "$nonopt"
185834977a2fSmrg      install_prog="$func_quote_for_eval_result "
185934977a2fSmrg      arg=$1
186034977a2fSmrg      shift
186134977a2fSmrg    else
186234977a2fSmrg      install_prog=
186334977a2fSmrg      arg=$nonopt
1864ee3138f1Smrg    fi
1865ee3138f1Smrg
186634977a2fSmrg    # The real first argument should be the name of the installation program.
186734977a2fSmrg    # Aesthetically quote it.
186834977a2fSmrg    func_quote_for_eval "$arg"
186934977a2fSmrg    install_prog="$install_prog$func_quote_for_eval_result"
1870ee3138f1Smrg
187134977a2fSmrg    # We need to accept at least all the BSD install flags.
187234977a2fSmrg    dest=
187334977a2fSmrg    files=
187434977a2fSmrg    opts=
187534977a2fSmrg    prev=
187634977a2fSmrg    install_type=
187734977a2fSmrg    isdir=no
187834977a2fSmrg    stripme=
187934977a2fSmrg    for arg
188034977a2fSmrg    do
188134977a2fSmrg      if test -n "$dest"; then
188234977a2fSmrg	files="$files $dest"
188334977a2fSmrg	dest=$arg
188434977a2fSmrg	continue
188534977a2fSmrg      fi
1886ee3138f1Smrg
188734977a2fSmrg      case $arg in
188834977a2fSmrg      -d) isdir=yes ;;
188934977a2fSmrg      -f)
189034977a2fSmrg	case " $install_prog " in
189134977a2fSmrg	*[\\\ /]cp\ *) ;;
189234977a2fSmrg	*) prev=$arg ;;
189334977a2fSmrg	esac
189434977a2fSmrg	;;
189534977a2fSmrg      -g | -m | -o)
189634977a2fSmrg	prev=$arg
189734977a2fSmrg	;;
189834977a2fSmrg      -s)
189934977a2fSmrg	stripme=" -s"
190034977a2fSmrg	continue
190134977a2fSmrg	;;
190234977a2fSmrg      -*)
190334977a2fSmrg	;;
190434977a2fSmrg      *)
190534977a2fSmrg	# If the previous option needed an argument, then skip it.
190634977a2fSmrg	if test -n "$prev"; then
190734977a2fSmrg	  prev=
190834977a2fSmrg	else
190934977a2fSmrg	  dest=$arg
191034977a2fSmrg	  continue
191134977a2fSmrg	fi
191234977a2fSmrg	;;
191334977a2fSmrg      esac
1914ee3138f1Smrg
191534977a2fSmrg      # Aesthetically quote the argument.
191634977a2fSmrg      func_quote_for_eval "$arg"
191734977a2fSmrg      install_prog="$install_prog $func_quote_for_eval_result"
191834977a2fSmrg    done
191934977a2fSmrg
192034977a2fSmrg    test -z "$install_prog" && \
192134977a2fSmrg      func_fatal_help "you must specify an install program"
192234977a2fSmrg
192334977a2fSmrg    test -n "$prev" && \
192434977a2fSmrg      func_fatal_help "the \`$prev' option requires an argument"
192534977a2fSmrg
192634977a2fSmrg    if test -z "$files"; then
192734977a2fSmrg      if test -z "$dest"; then
192834977a2fSmrg	func_fatal_help "no file or destination specified"
192934977a2fSmrg      else
193034977a2fSmrg	func_fatal_help "you must specify a destination"
1931ee3138f1Smrg      fi
1932ee3138f1Smrg    fi
1933ee3138f1Smrg
193434977a2fSmrg    # Strip any trailing slash from the destination.
193534977a2fSmrg    func_stripname '' '/' "$dest"
193634977a2fSmrg    dest=$func_stripname_result
1937ee3138f1Smrg
193834977a2fSmrg    # Check to see that the destination is a directory.
193934977a2fSmrg    test -d "$dest" && isdir=yes
194034977a2fSmrg    if test "$isdir" = yes; then
194134977a2fSmrg      destdir="$dest"
194234977a2fSmrg      destname=
194334977a2fSmrg    else
194434977a2fSmrg      func_dirname_and_basename "$dest" "" "."
194534977a2fSmrg      destdir="$func_dirname_result"
194634977a2fSmrg      destname="$func_basename_result"
194734977a2fSmrg
194834977a2fSmrg      # Not a directory, so check to see that there is only one file specified.
194934977a2fSmrg      set dummy $files; shift
195034977a2fSmrg      test "$#" -gt 1 && \
195134977a2fSmrg	func_fatal_help "\`$dest' is not a directory"
195234977a2fSmrg    fi
195334977a2fSmrg    case $destdir in
195434977a2fSmrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
1955ee3138f1Smrg    *)
195634977a2fSmrg      for file in $files; do
195734977a2fSmrg	case $file in
195834977a2fSmrg	*.lo) ;;
195934977a2fSmrg	*)
196034977a2fSmrg	  func_fatal_help "\`$destdir' must be an absolute directory name"
196134977a2fSmrg	  ;;
196234977a2fSmrg	esac
196334977a2fSmrg      done
1964ee3138f1Smrg      ;;
1965ee3138f1Smrg    esac
1966ee3138f1Smrg
196734977a2fSmrg    # This variable tells wrapper scripts just to set variables rather
196834977a2fSmrg    # than running their programs.
196934977a2fSmrg    libtool_install_magic="$magic"
1970ee3138f1Smrg
197134977a2fSmrg    staticlibs=
197234977a2fSmrg    future_libdirs=
197334977a2fSmrg    current_libdirs=
197434977a2fSmrg    for file in $files; do
1975ee3138f1Smrg
197634977a2fSmrg      # Do each installation.
197734977a2fSmrg      case $file in
197834977a2fSmrg      *.$libext)
197934977a2fSmrg	# Do the static libraries later.
198034977a2fSmrg	staticlibs="$staticlibs $file"
198134977a2fSmrg	;;
198234977a2fSmrg
198334977a2fSmrg      *.la)
198434977a2fSmrg	# Check to see that this really is a libtool archive.
198534977a2fSmrg	func_lalib_unsafe_p "$file" \
198634977a2fSmrg	  || func_fatal_help "\`$file' is not a valid libtool archive"
198734977a2fSmrg
198834977a2fSmrg	library_names=
198934977a2fSmrg	old_library=
199034977a2fSmrg	relink_command=
199134977a2fSmrg	func_source "$file"
199234977a2fSmrg
199334977a2fSmrg	# Add the libdir to current_libdirs if it is the destination.
199434977a2fSmrg	if test "X$destdir" = "X$libdir"; then
199534977a2fSmrg	  case "$current_libdirs " in
199634977a2fSmrg	  *" $libdir "*) ;;
199734977a2fSmrg	  *) current_libdirs="$current_libdirs $libdir" ;;
1998ee3138f1Smrg	  esac
199934977a2fSmrg	else
200034977a2fSmrg	  # Note the libdir as a future libdir.
200134977a2fSmrg	  case "$future_libdirs " in
200234977a2fSmrg	  *" $libdir "*) ;;
200334977a2fSmrg	  *) future_libdirs="$future_libdirs $libdir" ;;
200434977a2fSmrg	  esac
200534977a2fSmrg	fi
2006ee3138f1Smrg
200734977a2fSmrg	func_dirname "$file" "/" ""
200834977a2fSmrg	dir="$func_dirname_result"
200934977a2fSmrg	dir="$dir$objdir"
201034977a2fSmrg
201134977a2fSmrg	if test -n "$relink_command"; then
201234977a2fSmrg	  # Determine the prefix the user has applied to our future dir.
201334977a2fSmrg	  inst_prefix_dir=`$ECHO "X$destdir" | $Xsed -e "s%$libdir\$%%"`
201434977a2fSmrg
201534977a2fSmrg	  # Don't allow the user to place us outside of our expected
201634977a2fSmrg	  # location b/c this prevents finding dependent libraries that
201734977a2fSmrg	  # are installed to the same prefix.
201834977a2fSmrg	  # At present, this check doesn't affect windows .dll's that
201934977a2fSmrg	  # are installed into $libdir/../bin (currently, that works fine)
202034977a2fSmrg	  # but it's something to keep an eye on.
202134977a2fSmrg	  test "$inst_prefix_dir" = "$destdir" && \
202234977a2fSmrg	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
202334977a2fSmrg
202434977a2fSmrg	  if test -n "$inst_prefix_dir"; then
202534977a2fSmrg	    # Stick the inst_prefix_dir data into the link command.
202634977a2fSmrg	    relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
202734977a2fSmrg	  else
202834977a2fSmrg	    relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%%"`
202934977a2fSmrg	  fi
203034977a2fSmrg
203134977a2fSmrg	  func_warning "relinking \`$file'"
203234977a2fSmrg	  func_show_eval "$relink_command" \
203334977a2fSmrg	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
203434977a2fSmrg	fi
203534977a2fSmrg
203634977a2fSmrg	# See the names of the shared library.
203734977a2fSmrg	set dummy $library_names; shift
203834977a2fSmrg	if test -n "$1"; then
203934977a2fSmrg	  realname="$1"
204034977a2fSmrg	  shift
204134977a2fSmrg
204234977a2fSmrg	  srcname="$realname"
204334977a2fSmrg	  test -n "$relink_command" && srcname="$realname"T
204434977a2fSmrg
204534977a2fSmrg	  # Install the shared library and build the symlinks.
204634977a2fSmrg	  func_show_eval "$install_prog $dir/$srcname $destdir/$realname" \
204734977a2fSmrg	      'exit $?'
204834977a2fSmrg	  tstripme="$stripme"
204934977a2fSmrg	  case $host_os in
205034977a2fSmrg	  cygwin* | mingw* | pw32* | cegcc*)
205134977a2fSmrg	    case $realname in
205234977a2fSmrg	    *.dll.a)
205334977a2fSmrg	      tstripme=""
205434977a2fSmrg	      ;;
205534977a2fSmrg	    esac
2056ee3138f1Smrg	    ;;
2057ee3138f1Smrg	  esac
205834977a2fSmrg	  if test -n "$tstripme" && test -n "$striplib"; then
205934977a2fSmrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
206079a8a9c6Smrg	  fi
206134977a2fSmrg
206234977a2fSmrg	  if test "$#" -gt 0; then
206334977a2fSmrg	    # Delete the old symlinks, and create new ones.
206434977a2fSmrg	    # Try `ln -sf' first, because the `ln' binary might depend on
206534977a2fSmrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
206634977a2fSmrg	    # so we also need to try rm && ln -s.
206734977a2fSmrg	    for linkname
206834977a2fSmrg	    do
206934977a2fSmrg	      test "$linkname" != "$realname" \
207034977a2fSmrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
2071ee3138f1Smrg	    done
2072ee3138f1Smrg	  fi
2073ee3138f1Smrg
207434977a2fSmrg	  # Do each command in the postinstall commands.
207534977a2fSmrg	  lib="$destdir/$realname"
207634977a2fSmrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
2077ee3138f1Smrg	fi
2078ee3138f1Smrg
207934977a2fSmrg	# Install the pseudo-library for information purposes.
208034977a2fSmrg	func_basename "$file"
208134977a2fSmrg	name="$func_basename_result"
208234977a2fSmrg	instname="$dir/$name"i
208334977a2fSmrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
2084ee3138f1Smrg
208534977a2fSmrg	# Maybe install the static library, too.
208634977a2fSmrg	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
208734977a2fSmrg	;;
2088ee3138f1Smrg
208934977a2fSmrg      *.lo)
209034977a2fSmrg	# Install (i.e. copy) a libtool object.
2091ee3138f1Smrg
209234977a2fSmrg	# Figure out destination file name, if it wasn't already specified.
209334977a2fSmrg	if test -n "$destname"; then
209434977a2fSmrg	  destfile="$destdir/$destname"
209534977a2fSmrg	else
209634977a2fSmrg	  func_basename "$file"
209734977a2fSmrg	  destfile="$func_basename_result"
209834977a2fSmrg	  destfile="$destdir/$destfile"
209934977a2fSmrg	fi
210034977a2fSmrg
210134977a2fSmrg	# Deduce the name of the destination old-style object file.
210234977a2fSmrg	case $destfile in
210334977a2fSmrg	*.lo)
210434977a2fSmrg	  func_lo2o "$destfile"
210534977a2fSmrg	  staticdest=$func_lo2o_result
210634977a2fSmrg	  ;;
210734977a2fSmrg	*.$objext)
210834977a2fSmrg	  staticdest="$destfile"
210934977a2fSmrg	  destfile=
211034977a2fSmrg	  ;;
211134977a2fSmrg	*)
211234977a2fSmrg	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
211334977a2fSmrg	  ;;
2114ee3138f1Smrg	esac
2115ee3138f1Smrg
211634977a2fSmrg	# Install the libtool object if requested.
211734977a2fSmrg	test -n "$destfile" && \
211834977a2fSmrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
211934977a2fSmrg
212034977a2fSmrg	# Install the old object if enabled.
212134977a2fSmrg	if test "$build_old_libs" = yes; then
212234977a2fSmrg	  # Deduce the name of the old-style object file.
212334977a2fSmrg	  func_lo2o "$file"
212434977a2fSmrg	  staticobj=$func_lo2o_result
212534977a2fSmrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
2126ee3138f1Smrg	fi
212734977a2fSmrg	exit $EXIT_SUCCESS
212834977a2fSmrg	;;
2129ee3138f1Smrg
213034977a2fSmrg      *)
213134977a2fSmrg	# Figure out destination file name, if it wasn't already specified.
213234977a2fSmrg	if test -n "$destname"; then
213334977a2fSmrg	  destfile="$destdir/$destname"
213434977a2fSmrg	else
213534977a2fSmrg	  func_basename "$file"
213634977a2fSmrg	  destfile="$func_basename_result"
213734977a2fSmrg	  destfile="$destdir/$destfile"
213834977a2fSmrg	fi
2139ee3138f1Smrg
214034977a2fSmrg	# If the file is missing, and there is a .exe on the end, strip it
214134977a2fSmrg	# because it is most likely a libtool script we actually want to
214234977a2fSmrg	# install
214334977a2fSmrg	stripped_ext=""
214434977a2fSmrg	case $file in
214534977a2fSmrg	  *.exe)
214634977a2fSmrg	    if test ! -f "$file"; then
214734977a2fSmrg	      func_stripname '' '.exe' "$file"
214834977a2fSmrg	      file=$func_stripname_result
214934977a2fSmrg	      stripped_ext=".exe"
215034977a2fSmrg	    fi
215134977a2fSmrg	    ;;
215234977a2fSmrg	esac
2153ee3138f1Smrg
215434977a2fSmrg	# Do a test to see if this is really a libtool program.
215534977a2fSmrg	case $host in
215634977a2fSmrg	*cygwin* | *mingw*)
215734977a2fSmrg	    if func_ltwrapper_executable_p "$file"; then
215834977a2fSmrg	      func_ltwrapper_scriptname "$file"
215934977a2fSmrg	      wrapper=$func_ltwrapper_scriptname_result
216034977a2fSmrg	    else
216134977a2fSmrg	      func_stripname '' '.exe' "$file"
216234977a2fSmrg	      wrapper=$func_stripname_result
216334977a2fSmrg	    fi
216434977a2fSmrg	    ;;
216534977a2fSmrg	*)
216634977a2fSmrg	    wrapper=$file
216734977a2fSmrg	    ;;
216834977a2fSmrg	esac
216934977a2fSmrg	if func_ltwrapper_script_p "$wrapper"; then
217034977a2fSmrg	  notinst_deplibs=
217134977a2fSmrg	  relink_command=
2172ee3138f1Smrg
217334977a2fSmrg	  func_source "$wrapper"
217434977a2fSmrg
217534977a2fSmrg	  # Check the variables that should have been set.
217634977a2fSmrg	  test -z "$generated_by_libtool_version" && \
217734977a2fSmrg	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
217834977a2fSmrg
217934977a2fSmrg	  finalize=yes
218034977a2fSmrg	  for lib in $notinst_deplibs; do
218134977a2fSmrg	    # Check to see that each library is installed.
218234977a2fSmrg	    libdir=
218334977a2fSmrg	    if test -f "$lib"; then
218434977a2fSmrg	      func_source "$lib"
218534977a2fSmrg	    fi
218634977a2fSmrg	    libfile="$libdir/"`$ECHO "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
218734977a2fSmrg	    if test -n "$libdir" && test ! -f "$libfile"; then
218834977a2fSmrg	      func_warning "\`$lib' has not been installed in \`$libdir'"
218934977a2fSmrg	      finalize=no
219034977a2fSmrg	    fi
219134977a2fSmrg	  done
219234977a2fSmrg
219334977a2fSmrg	  relink_command=
219434977a2fSmrg	  func_source "$wrapper"
219534977a2fSmrg
219634977a2fSmrg	  outputname=
219734977a2fSmrg	  if test "$fast_install" = no && test -n "$relink_command"; then
219834977a2fSmrg	    $opt_dry_run || {
219934977a2fSmrg	      if test "$finalize" = yes; then
220034977a2fSmrg	        tmpdir=`func_mktempdir`
220134977a2fSmrg		func_basename "$file$stripped_ext"
220234977a2fSmrg		file="$func_basename_result"
220334977a2fSmrg	        outputname="$tmpdir/$file"
220434977a2fSmrg	        # Replace the output file specification.
220534977a2fSmrg	        relink_command=`$ECHO "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
220634977a2fSmrg
220734977a2fSmrg	        $opt_silent || {
220834977a2fSmrg	          func_quote_for_expand "$relink_command"
220934977a2fSmrg		  eval "func_echo $func_quote_for_expand_result"
221034977a2fSmrg	        }
221134977a2fSmrg	        if eval "$relink_command"; then :
221234977a2fSmrg	          else
221334977a2fSmrg		  func_error "error: relink \`$file' with the above command before installing it"
221434977a2fSmrg		  $opt_dry_run || ${RM}r "$tmpdir"
221534977a2fSmrg		  continue
221634977a2fSmrg	        fi
221734977a2fSmrg	        file="$outputname"
221834977a2fSmrg	      else
221934977a2fSmrg	        func_warning "cannot relink \`$file'"
222034977a2fSmrg	      fi
222134977a2fSmrg	    }
2222ee3138f1Smrg	  else
222334977a2fSmrg	    # Install the binary that we compiled earlier.
222434977a2fSmrg	    file=`$ECHO "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
2225ee3138f1Smrg	  fi
222634977a2fSmrg	fi
2227ee3138f1Smrg
222834977a2fSmrg	# remove .exe since cygwin /usr/bin/install will append another
222934977a2fSmrg	# one anyway
223034977a2fSmrg	case $install_prog,$host in
223134977a2fSmrg	*/usr/bin/install*,*cygwin*)
223234977a2fSmrg	  case $file:$destfile in
223334977a2fSmrg	  *.exe:*.exe)
223434977a2fSmrg	    # this is ok
223534977a2fSmrg	    ;;
223634977a2fSmrg	  *.exe:*)
223734977a2fSmrg	    destfile=$destfile.exe
223834977a2fSmrg	    ;;
223934977a2fSmrg	  *:*.exe)
224034977a2fSmrg	    func_stripname '' '.exe' "$destfile"
224134977a2fSmrg	    destfile=$func_stripname_result
224234977a2fSmrg	    ;;
224334977a2fSmrg	  esac
2244ee3138f1Smrg	  ;;
2245ee3138f1Smrg	esac
224634977a2fSmrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
224734977a2fSmrg	$opt_dry_run || if test -n "$outputname"; then
224834977a2fSmrg	  ${RM}r "$tmpdir"
224934977a2fSmrg	fi
225034977a2fSmrg	;;
225134977a2fSmrg      esac
225234977a2fSmrg    done
2253ee3138f1Smrg
225434977a2fSmrg    for file in $staticlibs; do
225534977a2fSmrg      func_basename "$file"
225634977a2fSmrg      name="$func_basename_result"
225734977a2fSmrg
225834977a2fSmrg      # Set up the ranlib parameters.
225934977a2fSmrg      oldlib="$destdir/$name"
226034977a2fSmrg
226134977a2fSmrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
226234977a2fSmrg
226334977a2fSmrg      if test -n "$stripme" && test -n "$old_striplib"; then
226434977a2fSmrg	func_show_eval "$old_striplib $oldlib" 'exit $?'
226534977a2fSmrg      fi
226634977a2fSmrg
226734977a2fSmrg      # Do each command in the postinstall commands.
226834977a2fSmrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
226934977a2fSmrg    done
227034977a2fSmrg
227134977a2fSmrg    test -n "$future_libdirs" && \
227234977a2fSmrg      func_warning "remember to run \`$progname --finish$future_libdirs'"
227334977a2fSmrg
227434977a2fSmrg    if test -n "$current_libdirs"; then
227534977a2fSmrg      # Maybe just do a dry run.
227634977a2fSmrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
227734977a2fSmrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
227834977a2fSmrg    else
227934977a2fSmrg      exit $EXIT_SUCCESS
228034977a2fSmrg    fi
228134977a2fSmrg}
228234977a2fSmrg
228334977a2fSmrgtest "$mode" = install && func_mode_install ${1+"$@"}
228434977a2fSmrg
228534977a2fSmrg
228634977a2fSmrg# func_generate_dlsyms outputname originator pic_p
228734977a2fSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with
228834977a2fSmrg# a dlpreopen symbol table.
228934977a2fSmrgfunc_generate_dlsyms ()
229034977a2fSmrg{
229134977a2fSmrg    $opt_debug
229234977a2fSmrg    my_outputname="$1"
229334977a2fSmrg    my_originator="$2"
229434977a2fSmrg    my_pic_p="${3-no}"
229534977a2fSmrg    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
229634977a2fSmrg    my_dlsyms=
229734977a2fSmrg
229834977a2fSmrg    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
229934977a2fSmrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
230034977a2fSmrg	my_dlsyms="${my_outputname}S.c"
230134977a2fSmrg      else
230234977a2fSmrg	func_error "not configured to extract global symbols from dlpreopened files"
230334977a2fSmrg      fi
230434977a2fSmrg    fi
230534977a2fSmrg
230634977a2fSmrg    if test -n "$my_dlsyms"; then
230734977a2fSmrg      case $my_dlsyms in
230834977a2fSmrg      "") ;;
230934977a2fSmrg      *.c)
231034977a2fSmrg	# Discover the nlist of each of the dlfiles.
231134977a2fSmrg	nlist="$output_objdir/${my_outputname}.nm"
231234977a2fSmrg
231334977a2fSmrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
231434977a2fSmrg
231534977a2fSmrg	# Parse the name list into a source file.
231634977a2fSmrg	func_verbose "creating $output_objdir/$my_dlsyms"
231734977a2fSmrg
231834977a2fSmrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
231934977a2fSmrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
232034977a2fSmrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
232134977a2fSmrg
232234977a2fSmrg#ifdef __cplusplus
232334977a2fSmrgextern \"C\" {
232434977a2fSmrg#endif
232534977a2fSmrg
232634977a2fSmrg/* External symbol declarations for the compiler. */\
232734977a2fSmrg"
232834977a2fSmrg
232934977a2fSmrg	if test "$dlself" = yes; then
233034977a2fSmrg	  func_verbose "generating symbol list for \`$output'"
233134977a2fSmrg
233234977a2fSmrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
233334977a2fSmrg
233434977a2fSmrg	  # Add our own program objects to the symbol list.
233534977a2fSmrg	  progfiles=`$ECHO "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
233634977a2fSmrg	  for progfile in $progfiles; do
233734977a2fSmrg	    func_verbose "extracting global C symbols from \`$progfile'"
233834977a2fSmrg	    $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'"
233934977a2fSmrg	  done
234034977a2fSmrg
234134977a2fSmrg	  if test -n "$exclude_expsyms"; then
234234977a2fSmrg	    $opt_dry_run || {
234334977a2fSmrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
234434977a2fSmrg	      eval '$MV "$nlist"T "$nlist"'
234534977a2fSmrg	    }
2346ee3138f1Smrg	  fi
234734977a2fSmrg
234834977a2fSmrg	  if test -n "$export_symbols_regex"; then
234934977a2fSmrg	    $opt_dry_run || {
235034977a2fSmrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
235134977a2fSmrg	      eval '$MV "$nlist"T "$nlist"'
235234977a2fSmrg	    }
235334977a2fSmrg	  fi
235434977a2fSmrg
235534977a2fSmrg	  # Prepare the list of exported symbols
235634977a2fSmrg	  if test -z "$export_symbols"; then
235734977a2fSmrg	    export_symbols="$output_objdir/$outputname.exp"
235834977a2fSmrg	    $opt_dry_run || {
235934977a2fSmrg	      $RM $export_symbols
236034977a2fSmrg	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
236134977a2fSmrg	      case $host in
236234977a2fSmrg	      *cygwin* | *mingw* | *cegcc* )
236334977a2fSmrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
236434977a2fSmrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
236534977a2fSmrg	        ;;
236634977a2fSmrg	      esac
236734977a2fSmrg	    }
2368ee3138f1Smrg	  else
236934977a2fSmrg	    $opt_dry_run || {
237034977a2fSmrg	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
237134977a2fSmrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
237234977a2fSmrg	      eval '$MV "$nlist"T "$nlist"'
237334977a2fSmrg	      case $host in
237434977a2fSmrg	        *cygwin | *mingw* | *cegcc* )
237534977a2fSmrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
237634977a2fSmrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
237734977a2fSmrg	          ;;
237834977a2fSmrg	      esac
237934977a2fSmrg	    }
2380ee3138f1Smrg	  fi
238134977a2fSmrg	fi
2382ee3138f1Smrg
238334977a2fSmrg	for dlprefile in $dlprefiles; do
238434977a2fSmrg	  func_verbose "extracting global C symbols from \`$dlprefile'"
238534977a2fSmrg	  func_basename "$dlprefile"
238634977a2fSmrg	  name="$func_basename_result"
238734977a2fSmrg	  $opt_dry_run || {
238834977a2fSmrg	    eval '$ECHO ": $name " >> "$nlist"'
238934977a2fSmrg	    eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'"
239034977a2fSmrg	  }
239134977a2fSmrg	done
239234977a2fSmrg
239334977a2fSmrg	$opt_dry_run || {
239434977a2fSmrg	  # Make sure we have at least an empty file.
239534977a2fSmrg	  test -f "$nlist" || : > "$nlist"
239634977a2fSmrg
239734977a2fSmrg	  if test -n "$exclude_expsyms"; then
239834977a2fSmrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
239934977a2fSmrg	    $MV "$nlist"T "$nlist"
2400ee3138f1Smrg	  fi
240134977a2fSmrg
240234977a2fSmrg	  # Try sorting and uniquifying the output.
240334977a2fSmrg	  if $GREP -v "^: " < "$nlist" |
240434977a2fSmrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
240534977a2fSmrg		sort -k 3
240634977a2fSmrg	      else
240734977a2fSmrg		sort +2
240834977a2fSmrg	      fi |
240934977a2fSmrg	      uniq > "$nlist"S; then
241034977a2fSmrg	    :
2411ee3138f1Smrg	  else
241234977a2fSmrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
2413ee3138f1Smrg	  fi
2414ee3138f1Smrg
241534977a2fSmrg	  if test -f "$nlist"S; then
241634977a2fSmrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
2417ee3138f1Smrg	  else
241834977a2fSmrg	    $ECHO '/* NONE */' >> "$output_objdir/$my_dlsyms"
2419ee3138f1Smrg	  fi
2420ee3138f1Smrg
242134977a2fSmrg	  $ECHO >> "$output_objdir/$my_dlsyms" "\
2422ee3138f1Smrg
242334977a2fSmrg/* The mapping between symbol names and symbols.  */
242434977a2fSmrgtypedef struct {
242534977a2fSmrg  const char *name;
242634977a2fSmrg  void *address;
242734977a2fSmrg} lt_dlsymlist;
242834977a2fSmrg"
242934977a2fSmrg	  case $host in
243034977a2fSmrg	  *cygwin* | *mingw* | *cegcc* )
243134977a2fSmrg	    $ECHO >> "$output_objdir/$my_dlsyms" "\
243234977a2fSmrg/* DATA imports from DLLs on WIN32 con't be const, because
243334977a2fSmrg   runtime relocations are performed -- see ld's documentation
243434977a2fSmrg   on pseudo-relocs.  */"
243534977a2fSmrg	    lt_dlsym_const= ;;
243634977a2fSmrg	  *osf5*)
243734977a2fSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
243834977a2fSmrg/* This system does not cope well with relocations in const data */"
243934977a2fSmrg	    lt_dlsym_const= ;;
244034977a2fSmrg	  *)
244134977a2fSmrg	    lt_dlsym_const=const ;;
244234977a2fSmrg	  esac
2443ee3138f1Smrg
244434977a2fSmrg	  $ECHO >> "$output_objdir/$my_dlsyms" "\
244534977a2fSmrgextern $lt_dlsym_const lt_dlsymlist
244634977a2fSmrglt_${my_prefix}_LTX_preloaded_symbols[];
244734977a2fSmrg$lt_dlsym_const lt_dlsymlist
244834977a2fSmrglt_${my_prefix}_LTX_preloaded_symbols[] =
244934977a2fSmrg{\
245034977a2fSmrg  { \"$my_originator\", (void *) 0 },"
2451ee3138f1Smrg
245234977a2fSmrg	  case $need_lib_prefix in
245334977a2fSmrg	  no)
245434977a2fSmrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
245534977a2fSmrg	    ;;
245634977a2fSmrg	  *)
245734977a2fSmrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
245834977a2fSmrg	    ;;
245934977a2fSmrg	  esac
246034977a2fSmrg	  $ECHO >> "$output_objdir/$my_dlsyms" "\
246134977a2fSmrg  {0, (void *) 0}
246234977a2fSmrg};
2463ee3138f1Smrg
246434977a2fSmrg/* This works around a problem in FreeBSD linker */
246534977a2fSmrg#ifdef FREEBSD_WORKAROUND
246634977a2fSmrgstatic const void *lt_preloaded_setup() {
246734977a2fSmrg  return lt_${my_prefix}_LTX_preloaded_symbols;
246834977a2fSmrg}
246934977a2fSmrg#endif
247034977a2fSmrg
247134977a2fSmrg#ifdef __cplusplus
247234977a2fSmrg}
247334977a2fSmrg#endif\
247434977a2fSmrg"
247534977a2fSmrg	} # !$opt_dry_run
247634977a2fSmrg
247734977a2fSmrg	pic_flag_for_symtable=
247834977a2fSmrg	case "$compile_command " in
247934977a2fSmrg	*" -static "*) ;;
248034977a2fSmrg	*)
248134977a2fSmrg	  case $host in
248234977a2fSmrg	  # compiling the symbol table file with pic_flag works around
248334977a2fSmrg	  # a FreeBSD bug that causes programs to crash when -lm is
248434977a2fSmrg	  # linked before any other PIC object.  But we must not use
248534977a2fSmrg	  # pic_flag when linking with -static.  The problem exists in
248634977a2fSmrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
248734977a2fSmrg	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
248834977a2fSmrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
248934977a2fSmrg	  *-*-hpux*)
249034977a2fSmrg	    pic_flag_for_symtable=" $pic_flag"  ;;
249134977a2fSmrg	  *)
249234977a2fSmrg	    if test "X$my_pic_p" != Xno; then
249334977a2fSmrg	      pic_flag_for_symtable=" $pic_flag"
2494ee3138f1Smrg	    fi
249534977a2fSmrg	    ;;
249634977a2fSmrg	  esac
249734977a2fSmrg	  ;;
249834977a2fSmrg	esac
249934977a2fSmrg	symtab_cflags=
250034977a2fSmrg	for arg in $LTCFLAGS; do
250134977a2fSmrg	  case $arg in
250234977a2fSmrg	  -pie | -fpie | -fPIE) ;;
250334977a2fSmrg	  *) symtab_cflags="$symtab_cflags $arg" ;;
250434977a2fSmrg	  esac
250534977a2fSmrg	done
2506ee3138f1Smrg
250734977a2fSmrg	# Now compile the dynamic symbol file.
250834977a2fSmrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
2509ee3138f1Smrg
251034977a2fSmrg	# Clean up the generated files.
251134977a2fSmrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
2512ee3138f1Smrg
251334977a2fSmrg	# Transform the symbol file into the correct name.
251434977a2fSmrg	symfileobj="$output_objdir/${my_outputname}S.$objext"
251534977a2fSmrg	case $host in
251634977a2fSmrg	*cygwin* | *mingw* | *cegcc* )
251734977a2fSmrg	  if test -f "$output_objdir/$my_outputname.def"; then
251834977a2fSmrg	    compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
251934977a2fSmrg	    finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
252034977a2fSmrg	  else
252134977a2fSmrg	    compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
252234977a2fSmrg	    finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2523ee3138f1Smrg	  fi
252434977a2fSmrg	  ;;
252534977a2fSmrg	*)
252634977a2fSmrg	  compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
252734977a2fSmrg	  finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
252834977a2fSmrg	  ;;
252934977a2fSmrg	esac
253034977a2fSmrg	;;
253134977a2fSmrg      *)
253234977a2fSmrg	func_fatal_error "unknown suffix for \`$my_dlsyms'"
253334977a2fSmrg	;;
253434977a2fSmrg      esac
253534977a2fSmrg    else
253634977a2fSmrg      # We keep going just in case the user didn't refer to
253734977a2fSmrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
253834977a2fSmrg      # really was required.
2539ee3138f1Smrg
254034977a2fSmrg      # Nullify the symbol file.
254134977a2fSmrg      compile_command=`$ECHO "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
254234977a2fSmrg      finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
254334977a2fSmrg    fi
254434977a2fSmrg}
2545ee3138f1Smrg
254634977a2fSmrg# func_win32_libid arg
254734977a2fSmrg# return the library type of file 'arg'
254834977a2fSmrg#
254934977a2fSmrg# Need a lot of goo to handle *both* DLLs and import libs
255034977a2fSmrg# Has to be a shell function in order to 'eat' the argument
255134977a2fSmrg# that is supplied when $file_magic_command is called.
255234977a2fSmrgfunc_win32_libid ()
255334977a2fSmrg{
255434977a2fSmrg  $opt_debug
255534977a2fSmrg  win32_libid_type="unknown"
255634977a2fSmrg  win32_fileres=`file -L $1 2>/dev/null`
255734977a2fSmrg  case $win32_fileres in
255834977a2fSmrg  *ar\ archive\ import\ library*) # definitely import
255934977a2fSmrg    win32_libid_type="x86 archive import"
256034977a2fSmrg    ;;
256134977a2fSmrg  *ar\ archive*) # could be an import, or static
256234977a2fSmrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
256334977a2fSmrg       $EGREP 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
256434977a2fSmrg      win32_nmres=`eval $NM -f posix -A $1 |
256534977a2fSmrg	$SED -n -e '
256634977a2fSmrg	    1,100{
256734977a2fSmrg		/ I /{
256834977a2fSmrg		    s,.*,import,
256934977a2fSmrg		    p
257034977a2fSmrg		    q
257134977a2fSmrg		}
257234977a2fSmrg	    }'`
257334977a2fSmrg      case $win32_nmres in
257434977a2fSmrg      import*)  win32_libid_type="x86 archive import";;
257534977a2fSmrg      *)        win32_libid_type="x86 archive static";;
257634977a2fSmrg      esac
257734977a2fSmrg    fi
257834977a2fSmrg    ;;
257934977a2fSmrg  *DLL*)
258034977a2fSmrg    win32_libid_type="x86 DLL"
258134977a2fSmrg    ;;
258234977a2fSmrg  *executable*) # but shell scripts are "executable" too...
258334977a2fSmrg    case $win32_fileres in
258434977a2fSmrg    *MS\ Windows\ PE\ Intel*)
258534977a2fSmrg      win32_libid_type="x86 DLL"
258634977a2fSmrg      ;;
258734977a2fSmrg    esac
258834977a2fSmrg    ;;
258934977a2fSmrg  esac
259034977a2fSmrg  $ECHO "$win32_libid_type"
259134977a2fSmrg}
2592ee3138f1Smrg
2593ee3138f1Smrg
2594ee3138f1Smrg
259534977a2fSmrg# func_extract_an_archive dir oldlib
259634977a2fSmrgfunc_extract_an_archive ()
259734977a2fSmrg{
259834977a2fSmrg    $opt_debug
259934977a2fSmrg    f_ex_an_ar_dir="$1"; shift
260034977a2fSmrg    f_ex_an_ar_oldlib="$1"
260134977a2fSmrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" 'exit $?'
260234977a2fSmrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
260334977a2fSmrg     :
260434977a2fSmrg    else
260534977a2fSmrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
260634977a2fSmrg    fi
260734977a2fSmrg}
2608ee3138f1Smrg
2609ee3138f1Smrg
261034977a2fSmrg# func_extract_archives gentop oldlib ...
261134977a2fSmrgfunc_extract_archives ()
261234977a2fSmrg{
261334977a2fSmrg    $opt_debug
261434977a2fSmrg    my_gentop="$1"; shift
261534977a2fSmrg    my_oldlibs=${1+"$@"}
261634977a2fSmrg    my_oldobjs=""
261734977a2fSmrg    my_xlib=""
261834977a2fSmrg    my_xabs=""
261934977a2fSmrg    my_xdir=""
2620ee3138f1Smrg
262134977a2fSmrg    for my_xlib in $my_oldlibs; do
262234977a2fSmrg      # Extract the objects.
262334977a2fSmrg      case $my_xlib in
262434977a2fSmrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
262534977a2fSmrg	*) my_xabs=`pwd`"/$my_xlib" ;;
262634977a2fSmrg      esac
262734977a2fSmrg      func_basename "$my_xlib"
262834977a2fSmrg      my_xlib="$func_basename_result"
262934977a2fSmrg      my_xlib_u=$my_xlib
263034977a2fSmrg      while :; do
263134977a2fSmrg        case " $extracted_archives " in
263234977a2fSmrg	*" $my_xlib_u "*)
263334977a2fSmrg	  func_arith $extracted_serial + 1
263434977a2fSmrg	  extracted_serial=$func_arith_result
263534977a2fSmrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
263634977a2fSmrg	*) break ;;
263734977a2fSmrg	esac
263834977a2fSmrg      done
263934977a2fSmrg      extracted_archives="$extracted_archives $my_xlib_u"
264034977a2fSmrg      my_xdir="$my_gentop/$my_xlib_u"
2641ee3138f1Smrg
264234977a2fSmrg      func_mkdir_p "$my_xdir"
2643ee3138f1Smrg
264434977a2fSmrg      case $host in
264534977a2fSmrg      *-darwin*)
264634977a2fSmrg	func_verbose "Extracting $my_xabs"
264734977a2fSmrg	# Do not bother doing anything if just a dry run
264834977a2fSmrg	$opt_dry_run || {
264934977a2fSmrg	  darwin_orig_dir=`pwd`
265034977a2fSmrg	  cd $my_xdir || exit $?
265134977a2fSmrg	  darwin_archive=$my_xabs
265234977a2fSmrg	  darwin_curdir=`pwd`
265334977a2fSmrg	  darwin_base_archive=`basename "$darwin_archive"`
265434977a2fSmrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
265534977a2fSmrg	  if test -n "$darwin_arches"; then
265634977a2fSmrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
265734977a2fSmrg	    darwin_arch=
265834977a2fSmrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
265934977a2fSmrg	    for darwin_arch in  $darwin_arches ; do
266034977a2fSmrg	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
266134977a2fSmrg	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
266234977a2fSmrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
266334977a2fSmrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
266434977a2fSmrg	      cd "$darwin_curdir"
266534977a2fSmrg	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
266634977a2fSmrg	    done # $darwin_arches
266734977a2fSmrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
266834977a2fSmrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
266934977a2fSmrg	    darwin_file=
267034977a2fSmrg	    darwin_files=
267134977a2fSmrg	    for darwin_file in $darwin_filelist; do
267234977a2fSmrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
267334977a2fSmrg	      $LIPO -create -output "$darwin_file" $darwin_files
267434977a2fSmrg	    done # $darwin_filelist
267534977a2fSmrg	    $RM -rf unfat-$$
267634977a2fSmrg	    cd "$darwin_orig_dir"
2677ee3138f1Smrg	  else
267834977a2fSmrg	    cd $darwin_orig_dir
267934977a2fSmrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
268034977a2fSmrg	  fi # $darwin_arches
268134977a2fSmrg	} # !$opt_dry_run
268234977a2fSmrg	;;
268334977a2fSmrg      *)
268434977a2fSmrg        func_extract_an_archive "$my_xdir" "$my_xabs"
268534977a2fSmrg	;;
268634977a2fSmrg      esac
268734977a2fSmrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
268834977a2fSmrg    done
2689ee3138f1Smrg
269034977a2fSmrg    func_extract_archives_result="$my_oldobjs"
269134977a2fSmrg}
2692ee3138f1Smrg
2693ee3138f1Smrg
2694ee3138f1Smrg
269534977a2fSmrg# func_emit_wrapper_part1 [arg=no]
269634977a2fSmrg#
269734977a2fSmrg# Emit the first part of a libtool wrapper script on stdout.
269834977a2fSmrg# For more information, see the description associated with
269934977a2fSmrg# func_emit_wrapper(), below.
270034977a2fSmrgfunc_emit_wrapper_part1 ()
270134977a2fSmrg{
270234977a2fSmrg	func_emit_wrapper_part1_arg1=no
270334977a2fSmrg	if test -n "$1" ; then
270434977a2fSmrg	  func_emit_wrapper_part1_arg1=$1
2705ee3138f1Smrg	fi
2706ee3138f1Smrg
270734977a2fSmrg	$ECHO "\
270834977a2fSmrg#! $SHELL
2709ee3138f1Smrg
271034977a2fSmrg# $output - temporary wrapper script for $objdir/$outputname
271134977a2fSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
271234977a2fSmrg#
271334977a2fSmrg# The $output program cannot be directly executed until all the libtool
271434977a2fSmrg# libraries that it depends on are installed.
271534977a2fSmrg#
271634977a2fSmrg# This wrapper script should never be moved out of the build directory.
271734977a2fSmrg# If it is, it will not operate correctly.
2718ee3138f1Smrg
271934977a2fSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
272034977a2fSmrg# metacharacters that are still active within double-quoted strings.
272134977a2fSmrgXsed='${SED} -e 1s/^X//'
272234977a2fSmrgsed_quote_subst='$sed_quote_subst'
2723ee3138f1Smrg
272434977a2fSmrg# Be Bourne compatible
272534977a2fSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
272634977a2fSmrg  emulate sh
272734977a2fSmrg  NULLCMD=:
272834977a2fSmrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
272934977a2fSmrg  # is contrary to our usage.  Disable this feature.
273034977a2fSmrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
273134977a2fSmrg  setopt NO_GLOB_SUBST
273234977a2fSmrgelse
273334977a2fSmrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
273434977a2fSmrgfi
273534977a2fSmrgBIN_SH=xpg4; export BIN_SH # for Tru64
273634977a2fSmrgDUALCASE=1; export DUALCASE # for MKS sh
2737ee3138f1Smrg
273834977a2fSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout
273934977a2fSmrg# if CDPATH is set.
274034977a2fSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
2741ee3138f1Smrg
274234977a2fSmrgrelink_command=\"$relink_command\"
2743ee3138f1Smrg
274434977a2fSmrg# This environment variable determines our operation mode.
274534977a2fSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then
274634977a2fSmrg  # install mode needs the following variables:
274734977a2fSmrg  generated_by_libtool_version='$macro_version'
274834977a2fSmrg  notinst_deplibs='$notinst_deplibs'
274934977a2fSmrgelse
275034977a2fSmrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
275134977a2fSmrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
275234977a2fSmrg    ECHO=\"$qecho\"
275334977a2fSmrg    file=\"\$0\"
275434977a2fSmrg    # Make sure echo works.
275534977a2fSmrg    if test \"X\$1\" = X--no-reexec; then
275634977a2fSmrg      # Discard the --no-reexec flag, and continue.
275734977a2fSmrg      shift
275834977a2fSmrg    elif test \"X\`{ \$ECHO '\t'; } 2>/dev/null\`\" = 'X\t'; then
275934977a2fSmrg      # Yippee, \$ECHO works!
276034977a2fSmrg      :
276134977a2fSmrg    else
276234977a2fSmrg      # Restart under the correct shell, and then maybe \$ECHO will work.
276334977a2fSmrg      exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
276434977a2fSmrg    fi
276534977a2fSmrg  fi\
276634977a2fSmrg"
276734977a2fSmrg	$ECHO "\
2768ee3138f1Smrg
276934977a2fSmrg  # Find the directory that this script lives in.
277034977a2fSmrg  thisdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
277134977a2fSmrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
2772ee3138f1Smrg
277334977a2fSmrg  # Follow symbolic links until we get to the real thisdir.
277434977a2fSmrg  file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
277534977a2fSmrg  while test -n \"\$file\"; do
277634977a2fSmrg    destdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
2777ee3138f1Smrg
277834977a2fSmrg    # If there was a directory component, then change thisdir.
277934977a2fSmrg    if test \"x\$destdir\" != \"x\$file\"; then
278034977a2fSmrg      case \"\$destdir\" in
278134977a2fSmrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
278234977a2fSmrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
2783ee3138f1Smrg      esac
278434977a2fSmrg    fi
2785ee3138f1Smrg
278634977a2fSmrg    file=\`\$ECHO \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
278734977a2fSmrg    file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
278834977a2fSmrg  done
278934977a2fSmrg"
279034977a2fSmrg}
279134977a2fSmrg# end: func_emit_wrapper_part1
279234977a2fSmrg
279334977a2fSmrg# func_emit_wrapper_part2 [arg=no]
279434977a2fSmrg#
279534977a2fSmrg# Emit the second part of a libtool wrapper script on stdout.
279634977a2fSmrg# For more information, see the description associated with
279734977a2fSmrg# func_emit_wrapper(), below.
279834977a2fSmrgfunc_emit_wrapper_part2 ()
279934977a2fSmrg{
280034977a2fSmrg	func_emit_wrapper_part2_arg1=no
280134977a2fSmrg	if test -n "$1" ; then
280234977a2fSmrg	  func_emit_wrapper_part2_arg1=$1
2803ee3138f1Smrg	fi
2804ee3138f1Smrg
280534977a2fSmrg	$ECHO "\
2806ee3138f1Smrg
280734977a2fSmrg  # Usually 'no', except on cygwin/mingw when embedded into
280834977a2fSmrg  # the cwrapper.
280934977a2fSmrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_part2_arg1
281034977a2fSmrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
281134977a2fSmrg    # special case for '.'
281234977a2fSmrg    if test \"\$thisdir\" = \".\"; then
281334977a2fSmrg      thisdir=\`pwd\`
281434977a2fSmrg    fi
281534977a2fSmrg    # remove .libs from thisdir
281634977a2fSmrg    case \"\$thisdir\" in
281734977a2fSmrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"X\$thisdir\" | \$Xsed -e 's%[\\\\/][^\\\\/]*$%%'\` ;;
281834977a2fSmrg    $objdir )   thisdir=. ;;
281934977a2fSmrg    esac
282034977a2fSmrg  fi
282134977a2fSmrg
282234977a2fSmrg  # Try to get the absolute directory name.
282334977a2fSmrg  absdir=\`cd \"\$thisdir\" && pwd\`
282434977a2fSmrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
282534977a2fSmrg"
282634977a2fSmrg
282734977a2fSmrg	if test "$fast_install" = yes; then
282834977a2fSmrg	  $ECHO "\
282934977a2fSmrg  program=lt-'$outputname'$exeext
283034977a2fSmrg  progdir=\"\$thisdir/$objdir\"
283134977a2fSmrg
283234977a2fSmrg  if test ! -f \"\$progdir/\$program\" ||
283334977a2fSmrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
283434977a2fSmrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
283534977a2fSmrg
283634977a2fSmrg    file=\"\$\$-\$program\"
283734977a2fSmrg
283834977a2fSmrg    if test ! -d \"\$progdir\"; then
283934977a2fSmrg      $MKDIR \"\$progdir\"
284034977a2fSmrg    else
284134977a2fSmrg      $RM \"\$progdir/\$file\"
284234977a2fSmrg    fi"
284334977a2fSmrg
284434977a2fSmrg	  $ECHO "\
284534977a2fSmrg
284634977a2fSmrg    # relink executable if necessary
284734977a2fSmrg    if test -n \"\$relink_command\"; then
284834977a2fSmrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
284934977a2fSmrg      else
285034977a2fSmrg	$ECHO \"\$relink_command_output\" >&2
285134977a2fSmrg	$RM \"\$progdir/\$file\"
285234977a2fSmrg	exit 1
2853ee3138f1Smrg      fi
285434977a2fSmrg    fi
2855ee3138f1Smrg
285634977a2fSmrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
285734977a2fSmrg    { $RM \"\$progdir/\$program\";
285834977a2fSmrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
285934977a2fSmrg    $RM \"\$progdir/\$file\"
286034977a2fSmrg  fi"
286134977a2fSmrg	else
286234977a2fSmrg	  $ECHO "\
286334977a2fSmrg  program='$outputname'
286434977a2fSmrg  progdir=\"\$thisdir/$objdir\"
286534977a2fSmrg"
2866ee3138f1Smrg	fi
2867ee3138f1Smrg
286834977a2fSmrg	$ECHO "\
2869ee3138f1Smrg
287034977a2fSmrg  if test -f \"\$progdir/\$program\"; then"
2871ee3138f1Smrg
287234977a2fSmrg	# Export our shlibpath_var if we have one.
287334977a2fSmrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
287434977a2fSmrg	  $ECHO "\
287534977a2fSmrg    # Add our own library path to $shlibpath_var
287634977a2fSmrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
2877ee3138f1Smrg
287834977a2fSmrg    # Some systems cannot cope with colon-terminated $shlibpath_var
287934977a2fSmrg    # The second colon is a workaround for a bug in BeOS R4 sed
288034977a2fSmrg    $shlibpath_var=\`\$ECHO \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
288134977a2fSmrg
288234977a2fSmrg    export $shlibpath_var
288334977a2fSmrg"
2884ee3138f1Smrg	fi
2885ee3138f1Smrg
288634977a2fSmrg	# fixup the dll searchpath if we need to.
288734977a2fSmrg	if test -n "$dllsearchpath"; then
288834977a2fSmrg	  $ECHO "\
288934977a2fSmrg    # Add the dll search path components to the executable PATH
289034977a2fSmrg    PATH=$dllsearchpath:\$PATH
289134977a2fSmrg"
289234977a2fSmrg	fi
2893ee3138f1Smrg
289434977a2fSmrg	$ECHO "\
289534977a2fSmrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
289634977a2fSmrg      # Run the actual program with our arguments.
289734977a2fSmrg"
289834977a2fSmrg	case $host in
289934977a2fSmrg	# Backslashes separate directories on plain windows
290034977a2fSmrg	*-*-mingw | *-*-os2* | *-cegcc*)
290134977a2fSmrg	  $ECHO "\
290234977a2fSmrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
290334977a2fSmrg"
2904ee3138f1Smrg	  ;;
2905ee3138f1Smrg
2906ee3138f1Smrg	*)
290734977a2fSmrg	  $ECHO "\
290834977a2fSmrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
290934977a2fSmrg"
2910ee3138f1Smrg	  ;;
2911ee3138f1Smrg	esac
291234977a2fSmrg	$ECHO "\
291334977a2fSmrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
291434977a2fSmrg      exit 1
291534977a2fSmrg    fi
291634977a2fSmrg  else
291734977a2fSmrg    # The program doesn't exist.
291834977a2fSmrg    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
291934977a2fSmrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
292034977a2fSmrg    $ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
292134977a2fSmrg    exit 1
292234977a2fSmrg  fi
292334977a2fSmrgfi\
292434977a2fSmrg"
292534977a2fSmrg}
292634977a2fSmrg# end: func_emit_wrapper_part2
2927ee3138f1Smrg
2928ee3138f1Smrg
292934977a2fSmrg# func_emit_wrapper [arg=no]
293034977a2fSmrg#
293134977a2fSmrg# Emit a libtool wrapper script on stdout.
293234977a2fSmrg# Don't directly open a file because we may want to
293334977a2fSmrg# incorporate the script contents within a cygwin/mingw
293434977a2fSmrg# wrapper executable.  Must ONLY be called from within
293534977a2fSmrg# func_mode_link because it depends on a number of variables
293634977a2fSmrg# set therein.
293734977a2fSmrg#
293834977a2fSmrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
293934977a2fSmrg# variable will take.  If 'yes', then the emitted script
294034977a2fSmrg# will assume that the directory in which it is stored is
294134977a2fSmrg# the $objdir directory.  This is a cygwin/mingw-specific
294234977a2fSmrg# behavior.
294334977a2fSmrgfunc_emit_wrapper ()
294434977a2fSmrg{
294534977a2fSmrg	func_emit_wrapper_arg1=no
294634977a2fSmrg	if test -n "$1" ; then
294734977a2fSmrg	  func_emit_wrapper_arg1=$1
2948ee3138f1Smrg	fi
2949ee3138f1Smrg
295034977a2fSmrg	# split this up so that func_emit_cwrapperexe_src
295134977a2fSmrg	# can call each part independently.
295234977a2fSmrg	func_emit_wrapper_part1 "${func_emit_wrapper_arg1}"
295334977a2fSmrg	func_emit_wrapper_part2 "${func_emit_wrapper_arg1}"
295434977a2fSmrg}
2955ee3138f1Smrg
2956ee3138f1Smrg
295734977a2fSmrg# func_to_host_path arg
295834977a2fSmrg#
295934977a2fSmrg# Convert paths to host format when used with build tools.
296034977a2fSmrg# Intended for use with "native" mingw (where libtool itself
296134977a2fSmrg# is running under the msys shell), or in the following cross-
296234977a2fSmrg# build environments:
296334977a2fSmrg#    $build          $host
296434977a2fSmrg#    mingw (msys)    mingw  [e.g. native]
296534977a2fSmrg#    cygwin          mingw
296634977a2fSmrg#    *nix + wine     mingw
296734977a2fSmrg# where wine is equipped with the `winepath' executable.
296834977a2fSmrg# In the native mingw case, the (msys) shell automatically
296934977a2fSmrg# converts paths for any non-msys applications it launches,
297034977a2fSmrg# but that facility isn't available from inside the cwrapper.
297134977a2fSmrg# Similar accommodations are necessary for $host mingw and
297234977a2fSmrg# $build cygwin.  Calling this function does no harm for other
297334977a2fSmrg# $host/$build combinations not listed above.
297434977a2fSmrg#
297534977a2fSmrg# ARG is the path (on $build) that should be converted to
297634977a2fSmrg# the proper representation for $host. The result is stored
297734977a2fSmrg# in $func_to_host_path_result.
297834977a2fSmrgfunc_to_host_path ()
297934977a2fSmrg{
298034977a2fSmrg  func_to_host_path_result="$1"
298134977a2fSmrg  if test -n "$1" ; then
298234977a2fSmrg    case $host in
298334977a2fSmrg      *mingw* )
298434977a2fSmrg        lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
298534977a2fSmrg        case $build in
298634977a2fSmrg          *mingw* ) # actually, msys
298734977a2fSmrg            # awkward: cmd appends spaces to result
298834977a2fSmrg            lt_sed_strip_trailing_spaces="s/[ ]*\$//"
298934977a2fSmrg            func_to_host_path_tmp1=`( cmd //c echo "$1" |\
299034977a2fSmrg              $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""`
299134977a2fSmrg            func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
299234977a2fSmrg              $SED -e "$lt_sed_naive_backslashify"`
299334977a2fSmrg            ;;
299434977a2fSmrg          *cygwin* )
299534977a2fSmrg            func_to_host_path_tmp1=`cygpath -w "$1"`
299634977a2fSmrg            func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
299734977a2fSmrg              $SED -e "$lt_sed_naive_backslashify"`
299834977a2fSmrg            ;;
299934977a2fSmrg          * )
300034977a2fSmrg            # Unfortunately, winepath does not exit with a non-zero
300134977a2fSmrg            # error code, so we are forced to check the contents of
300234977a2fSmrg            # stdout. On the other hand, if the command is not
300334977a2fSmrg            # found, the shell will set an exit code of 127 and print
300434977a2fSmrg            # *an error message* to stdout. So we must check for both
300534977a2fSmrg            # error code of zero AND non-empty stdout, which explains
300634977a2fSmrg            # the odd construction:
300734977a2fSmrg            func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null`
300834977a2fSmrg            if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then
300934977a2fSmrg              func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
301034977a2fSmrg                $SED -e "$lt_sed_naive_backslashify"`
301134977a2fSmrg            else
301234977a2fSmrg              # Allow warning below.
301334977a2fSmrg              func_to_host_path_result=""
301434977a2fSmrg            fi
301534977a2fSmrg            ;;
301634977a2fSmrg        esac
301734977a2fSmrg        if test -z "$func_to_host_path_result" ; then
301834977a2fSmrg          func_error "Could not determine host path corresponding to"
301934977a2fSmrg          func_error "  '$1'"
302034977a2fSmrg          func_error "Continuing, but uninstalled executables may not work."
302134977a2fSmrg          # Fallback:
302234977a2fSmrg          func_to_host_path_result="$1"
302334977a2fSmrg        fi
302434977a2fSmrg        ;;
302534977a2fSmrg    esac
302634977a2fSmrg  fi
302734977a2fSmrg}
302834977a2fSmrg# end: func_to_host_path
3029ee3138f1Smrg
303034977a2fSmrg# func_to_host_pathlist arg
303134977a2fSmrg#
303234977a2fSmrg# Convert pathlists to host format when used with build tools.
303334977a2fSmrg# See func_to_host_path(), above. This function supports the
303434977a2fSmrg# following $build/$host combinations (but does no harm for
303534977a2fSmrg# combinations not listed here):
303634977a2fSmrg#    $build          $host
303734977a2fSmrg#    mingw (msys)    mingw  [e.g. native]
303834977a2fSmrg#    cygwin          mingw
303934977a2fSmrg#    *nix + wine     mingw
304034977a2fSmrg#
304134977a2fSmrg# Path separators are also converted from $build format to
304234977a2fSmrg# $host format. If ARG begins or ends with a path separator
304334977a2fSmrg# character, it is preserved (but converted to $host format)
304434977a2fSmrg# on output.
304534977a2fSmrg#
304634977a2fSmrg# ARG is a pathlist (on $build) that should be converted to
304734977a2fSmrg# the proper representation on $host. The result is stored
304834977a2fSmrg# in $func_to_host_pathlist_result.
304934977a2fSmrgfunc_to_host_pathlist ()
305034977a2fSmrg{
305134977a2fSmrg  func_to_host_pathlist_result="$1"
305234977a2fSmrg  if test -n "$1" ; then
305334977a2fSmrg    case $host in
305434977a2fSmrg      *mingw* )
305534977a2fSmrg        lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
305634977a2fSmrg        # Remove leading and trailing path separator characters from
305734977a2fSmrg        # ARG. msys behavior is inconsistent here, cygpath turns them
305834977a2fSmrg        # into '.;' and ';.', and winepath ignores them completely.
305934977a2fSmrg        func_to_host_pathlist_tmp2="$1"
306034977a2fSmrg        # Once set for this call, this variable should not be
306134977a2fSmrg        # reassigned. It is used in tha fallback case.
306234977a2fSmrg        func_to_host_pathlist_tmp1=`echo "$func_to_host_pathlist_tmp2" |\
306334977a2fSmrg          $SED -e 's|^:*||' -e 's|:*$||'`
306434977a2fSmrg        case $build in
306534977a2fSmrg          *mingw* ) # Actually, msys.
306634977a2fSmrg            # Awkward: cmd appends spaces to result.
306734977a2fSmrg            lt_sed_strip_trailing_spaces="s/[ ]*\$//"
306834977a2fSmrg            func_to_host_pathlist_tmp2=`( cmd //c echo "$func_to_host_pathlist_tmp1" |\
306934977a2fSmrg              $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""`
307034977a2fSmrg            func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
307134977a2fSmrg              $SED -e "$lt_sed_naive_backslashify"`
307234977a2fSmrg            ;;
307334977a2fSmrg          *cygwin* )
307434977a2fSmrg            func_to_host_pathlist_tmp2=`cygpath -w -p "$func_to_host_pathlist_tmp1"`
307534977a2fSmrg            func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
307634977a2fSmrg              $SED -e "$lt_sed_naive_backslashify"`
307734977a2fSmrg            ;;
307834977a2fSmrg          * )
307934977a2fSmrg            # unfortunately, winepath doesn't convert pathlists
308034977a2fSmrg            func_to_host_pathlist_result=""
308134977a2fSmrg            func_to_host_pathlist_oldIFS=$IFS
308234977a2fSmrg            IFS=:
308334977a2fSmrg            for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do
308434977a2fSmrg              IFS=$func_to_host_pathlist_oldIFS
308534977a2fSmrg              if test -n "$func_to_host_pathlist_f" ; then
308634977a2fSmrg                func_to_host_path "$func_to_host_pathlist_f"
308734977a2fSmrg                if test -n "$func_to_host_path_result" ; then
308834977a2fSmrg                  if test -z "$func_to_host_pathlist_result" ; then
308934977a2fSmrg                    func_to_host_pathlist_result="$func_to_host_path_result"
309034977a2fSmrg                  else
309134977a2fSmrg                    func_to_host_pathlist_result="$func_to_host_pathlist_result;$func_to_host_path_result"
309234977a2fSmrg                  fi
309334977a2fSmrg                fi
309434977a2fSmrg              fi
309534977a2fSmrg              IFS=:
309634977a2fSmrg            done
309734977a2fSmrg            IFS=$func_to_host_pathlist_oldIFS
309834977a2fSmrg            ;;
309934977a2fSmrg        esac
310034977a2fSmrg        if test -z "$func_to_host_pathlist_result" ; then
310134977a2fSmrg          func_error "Could not determine the host path(s) corresponding to"
310234977a2fSmrg          func_error "  '$1'"
310334977a2fSmrg          func_error "Continuing, but uninstalled executables may not work."
310434977a2fSmrg          # Fallback. This may break if $1 contains DOS-style drive
310534977a2fSmrg          # specifications. The fix is not to complicate the expression
310634977a2fSmrg          # below, but for the user to provide a working wine installation
310734977a2fSmrg          # with winepath so that path translation in the cross-to-mingw
310834977a2fSmrg          # case works properly.
310934977a2fSmrg          lt_replace_pathsep_nix_to_dos="s|:|;|g"
311034977a2fSmrg          func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\
311134977a2fSmrg            $SED -e "$lt_replace_pathsep_nix_to_dos"`
311234977a2fSmrg        fi
311334977a2fSmrg        # Now, add the leading and trailing path separators back
311434977a2fSmrg        case "$1" in
311534977a2fSmrg          :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result"
311634977a2fSmrg            ;;
311734977a2fSmrg        esac
311834977a2fSmrg        case "$1" in
311934977a2fSmrg          *: ) func_to_host_pathlist_result="$func_to_host_pathlist_result;"
312034977a2fSmrg            ;;
312134977a2fSmrg        esac
312234977a2fSmrg        ;;
312334977a2fSmrg    esac
312434977a2fSmrg  fi
312534977a2fSmrg}
312634977a2fSmrg# end: func_to_host_pathlist
3127ee3138f1Smrg
312834977a2fSmrg# func_emit_cwrapperexe_src
312934977a2fSmrg# emit the source code for a wrapper executable on stdout
313034977a2fSmrg# Must ONLY be called from within func_mode_link because
313134977a2fSmrg# it depends on a number of variable set therein.
313234977a2fSmrgfunc_emit_cwrapperexe_src ()
313334977a2fSmrg{
313434977a2fSmrg	cat <<EOF
3135ee3138f1Smrg
313634977a2fSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
313734977a2fSmrg   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
3138ee3138f1Smrg
313934977a2fSmrg   The $output program cannot be directly executed until all the libtool
314034977a2fSmrg   libraries that it depends on are installed.
3141ee3138f1Smrg
314234977a2fSmrg   This wrapper executable should never be moved out of the build directory.
314334977a2fSmrg   If it is, it will not operate correctly.
3144ee3138f1Smrg
314534977a2fSmrg   Currently, it simply execs the wrapper *script* "$SHELL $output",
314634977a2fSmrg   but could eventually absorb all of the scripts functionality and
314734977a2fSmrg   exec $objdir/$outputname directly.
314834977a2fSmrg*/
314934977a2fSmrgEOF
315034977a2fSmrg	    cat <<"EOF"
315134977a2fSmrg#include <stdio.h>
315234977a2fSmrg#include <stdlib.h>
315334977a2fSmrg#ifdef _MSC_VER
315434977a2fSmrg# include <direct.h>
315534977a2fSmrg# include <process.h>
315634977a2fSmrg# include <io.h>
315734977a2fSmrg# define setmode _setmode
315834977a2fSmrg#else
315934977a2fSmrg# include <unistd.h>
316034977a2fSmrg# include <stdint.h>
316134977a2fSmrg# ifdef __CYGWIN__
316234977a2fSmrg#  include <io.h>
316334977a2fSmrg#  define HAVE_SETENV
316434977a2fSmrg#  ifdef __STRICT_ANSI__
316534977a2fSmrgchar *realpath (const char *, char *);
316634977a2fSmrgint putenv (char *);
316734977a2fSmrgint setenv (const char *, const char *, int);
316834977a2fSmrg#  endif
316934977a2fSmrg# endif
317034977a2fSmrg#endif
317134977a2fSmrg#include <malloc.h>
317234977a2fSmrg#include <stdarg.h>
317334977a2fSmrg#include <assert.h>
317434977a2fSmrg#include <string.h>
317534977a2fSmrg#include <ctype.h>
317634977a2fSmrg#include <errno.h>
317734977a2fSmrg#include <fcntl.h>
317834977a2fSmrg#include <sys/stat.h>
3179ee3138f1Smrg
318034977a2fSmrg#if defined(PATH_MAX)
318134977a2fSmrg# define LT_PATHMAX PATH_MAX
318234977a2fSmrg#elif defined(MAXPATHLEN)
318334977a2fSmrg# define LT_PATHMAX MAXPATHLEN
318434977a2fSmrg#else
318534977a2fSmrg# define LT_PATHMAX 1024
318634977a2fSmrg#endif
3187ee3138f1Smrg
318834977a2fSmrg#ifndef S_IXOTH
318934977a2fSmrg# define S_IXOTH 0
319034977a2fSmrg#endif
319134977a2fSmrg#ifndef S_IXGRP
319234977a2fSmrg# define S_IXGRP 0
319334977a2fSmrg#endif
3194ee3138f1Smrg
319534977a2fSmrg#ifdef _MSC_VER
319634977a2fSmrg# define S_IXUSR _S_IEXEC
319734977a2fSmrg# define stat _stat
319834977a2fSmrg# ifndef _INTPTR_T_DEFINED
319934977a2fSmrg#  define intptr_t int
320034977a2fSmrg# endif
320134977a2fSmrg#endif
3202ee3138f1Smrg
320334977a2fSmrg#ifndef DIR_SEPARATOR
320434977a2fSmrg# define DIR_SEPARATOR '/'
320534977a2fSmrg# define PATH_SEPARATOR ':'
320634977a2fSmrg#endif
3207ee3138f1Smrg
320834977a2fSmrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
320934977a2fSmrg  defined (__OS2__)
321034977a2fSmrg# define HAVE_DOS_BASED_FILE_SYSTEM
321134977a2fSmrg# define FOPEN_WB "wb"
321234977a2fSmrg# ifndef DIR_SEPARATOR_2
321334977a2fSmrg#  define DIR_SEPARATOR_2 '\\'
321434977a2fSmrg# endif
321534977a2fSmrg# ifndef PATH_SEPARATOR_2
321634977a2fSmrg#  define PATH_SEPARATOR_2 ';'
321734977a2fSmrg# endif
321834977a2fSmrg#endif
3219ee3138f1Smrg
322034977a2fSmrg#ifndef DIR_SEPARATOR_2
322134977a2fSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
322234977a2fSmrg#else /* DIR_SEPARATOR_2 */
322334977a2fSmrg# define IS_DIR_SEPARATOR(ch) \
322434977a2fSmrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
322534977a2fSmrg#endif /* DIR_SEPARATOR_2 */
3226ee3138f1Smrg
322734977a2fSmrg#ifndef PATH_SEPARATOR_2
322834977a2fSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
322934977a2fSmrg#else /* PATH_SEPARATOR_2 */
323034977a2fSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
323134977a2fSmrg#endif /* PATH_SEPARATOR_2 */
3232ee3138f1Smrg
323334977a2fSmrg#ifdef __CYGWIN__
323434977a2fSmrg# define FOPEN_WB "wb"
323534977a2fSmrg#endif
3236ee3138f1Smrg
323734977a2fSmrg#ifndef FOPEN_WB
323834977a2fSmrg# define FOPEN_WB "w"
323934977a2fSmrg#endif
324034977a2fSmrg#ifndef _O_BINARY
324134977a2fSmrg# define _O_BINARY 0
324234977a2fSmrg#endif
3243ee3138f1Smrg
324434977a2fSmrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
324534977a2fSmrg#define XFREE(stale) do { \
324634977a2fSmrg  if (stale) { free ((void *) stale); stale = 0; } \
324734977a2fSmrg} while (0)
3248ee3138f1Smrg
324934977a2fSmrg#undef LTWRAPPER_DEBUGPRINTF
325034977a2fSmrg#if defined DEBUGWRAPPER
325134977a2fSmrg# define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args
325234977a2fSmrgstatic void
325334977a2fSmrgltwrapper_debugprintf (const char *fmt, ...)
325434977a2fSmrg{
325534977a2fSmrg    va_list args;
325634977a2fSmrg    va_start (args, fmt);
325734977a2fSmrg    (void) vfprintf (stderr, fmt, args);
325834977a2fSmrg    va_end (args);
325934977a2fSmrg}
326034977a2fSmrg#else
326134977a2fSmrg# define LTWRAPPER_DEBUGPRINTF(args)
326234977a2fSmrg#endif
3263ee3138f1Smrg
326434977a2fSmrgconst char *program_name = NULL;
3265ee3138f1Smrg
326634977a2fSmrgvoid *xmalloc (size_t num);
326734977a2fSmrgchar *xstrdup (const char *string);
326834977a2fSmrgconst char *base_name (const char *name);
326934977a2fSmrgchar *find_executable (const char *wrapper);
327034977a2fSmrgchar *chase_symlinks (const char *pathspec);
327134977a2fSmrgint make_executable (const char *path);
327234977a2fSmrgint check_executable (const char *path);
327334977a2fSmrgchar *strendzap (char *str, const char *pat);
327434977a2fSmrgvoid lt_fatal (const char *message, ...);
327534977a2fSmrgvoid lt_setenv (const char *name, const char *value);
327634977a2fSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
327734977a2fSmrgvoid lt_opt_process_env_set (const char *arg);
327834977a2fSmrgvoid lt_opt_process_env_prepend (const char *arg);
327934977a2fSmrgvoid lt_opt_process_env_append (const char *arg);
328034977a2fSmrgint lt_split_name_value (const char *arg, char** name, char** value);
328134977a2fSmrgvoid lt_update_exe_path (const char *name, const char *value);
328234977a2fSmrgvoid lt_update_lib_path (const char *name, const char *value);
328334977a2fSmrg
328434977a2fSmrgstatic const char *script_text_part1 =
328534977a2fSmrgEOF
3286ee3138f1Smrg
328734977a2fSmrg	    func_emit_wrapper_part1 yes |
328834977a2fSmrg	        $SED -e 's/\([\\"]\)/\\\1/g' \
328934977a2fSmrg	             -e 's/^/  "/' -e 's/$/\\n"/'
329034977a2fSmrg	    echo ";"
329134977a2fSmrg	    cat <<EOF
3292ee3138f1Smrg
329334977a2fSmrgstatic const char *script_text_part2 =
329434977a2fSmrgEOF
329534977a2fSmrg	    func_emit_wrapper_part2 yes |
329634977a2fSmrg	        $SED -e 's/\([\\"]\)/\\\1/g' \
329734977a2fSmrg	             -e 's/^/  "/' -e 's/$/\\n"/'
329834977a2fSmrg	    echo ";"
329934977a2fSmrg
330034977a2fSmrg	    cat <<EOF
330134977a2fSmrgconst char * MAGIC_EXE = "$magic_exe";
330234977a2fSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
330334977a2fSmrgEOF
3304ee3138f1Smrg
330534977a2fSmrg	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
330634977a2fSmrg              func_to_host_pathlist "$temp_rpath"
330734977a2fSmrg	      cat <<EOF
330834977a2fSmrgconst char * LIB_PATH_VALUE   = "$func_to_host_pathlist_result";
330934977a2fSmrgEOF
331034977a2fSmrg	    else
331134977a2fSmrg	      cat <<"EOF"
331234977a2fSmrgconst char * LIB_PATH_VALUE   = "";
331334977a2fSmrgEOF
3314ee3138f1Smrg	    fi
3315ee3138f1Smrg
331634977a2fSmrg	    if test -n "$dllsearchpath"; then
331734977a2fSmrg              func_to_host_pathlist "$dllsearchpath:"
331834977a2fSmrg	      cat <<EOF
331934977a2fSmrgconst char * EXE_PATH_VARNAME = "PATH";
332034977a2fSmrgconst char * EXE_PATH_VALUE   = "$func_to_host_pathlist_result";
3321ee3138f1SmrgEOF
3322ee3138f1Smrg	    else
332334977a2fSmrg	      cat <<"EOF"
332434977a2fSmrgconst char * EXE_PATH_VARNAME = "";
332534977a2fSmrgconst char * EXE_PATH_VALUE   = "";
332634977a2fSmrgEOF
3327ee3138f1Smrg	    fi
332834977a2fSmrg
332934977a2fSmrg	    if test "$fast_install" = yes; then
333034977a2fSmrg	      cat <<EOF
333134977a2fSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
333234977a2fSmrgEOF
3333ee3138f1Smrg	    else
333434977a2fSmrg	      cat <<EOF
333534977a2fSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
333634977a2fSmrgEOF
3337ee3138f1Smrg	    fi
3338ee3138f1Smrg
3339ee3138f1Smrg
334034977a2fSmrg	    cat <<"EOF"
3341ee3138f1Smrg
334234977a2fSmrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
334334977a2fSmrg#define LTWRAPPER_OPTION_PREFIX_LENGTH  5
3344ee3138f1Smrg
334534977a2fSmrgstatic const size_t opt_prefix_len         = LTWRAPPER_OPTION_PREFIX_LENGTH;
334634977a2fSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
3347ee3138f1Smrg
334834977a2fSmrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
3349ee3138f1Smrg
335034977a2fSmrgstatic const size_t env_set_opt_len     = LTWRAPPER_OPTION_PREFIX_LENGTH + 7;
335134977a2fSmrgstatic const char *env_set_opt          = LTWRAPPER_OPTION_PREFIX "env-set";
335234977a2fSmrg  /* argument is putenv-style "foo=bar", value of foo is set to bar */
3353ee3138f1Smrg
335434977a2fSmrgstatic const size_t env_prepend_opt_len = LTWRAPPER_OPTION_PREFIX_LENGTH + 11;
335534977a2fSmrgstatic const char *env_prepend_opt      = LTWRAPPER_OPTION_PREFIX "env-prepend";
335634977a2fSmrg  /* argument is putenv-style "foo=bar", new value of foo is bar${foo} */
3357ee3138f1Smrg
335834977a2fSmrgstatic const size_t env_append_opt_len  = LTWRAPPER_OPTION_PREFIX_LENGTH + 10;
335934977a2fSmrgstatic const char *env_append_opt       = LTWRAPPER_OPTION_PREFIX "env-append";
336034977a2fSmrg  /* argument is putenv-style "foo=bar", new value of foo is ${foo}bar */
3361ee3138f1Smrg
336234977a2fSmrgint
336334977a2fSmrgmain (int argc, char *argv[])
336434977a2fSmrg{
336534977a2fSmrg  char **newargz;
336634977a2fSmrg  int  newargc;
336734977a2fSmrg  char *tmp_pathspec;
336834977a2fSmrg  char *actual_cwrapper_path;
336934977a2fSmrg  char *actual_cwrapper_name;
337034977a2fSmrg  char *target_name;
337134977a2fSmrg  char *lt_argv_zero;
337234977a2fSmrg  intptr_t rval = 127;
3373ee3138f1Smrg
337434977a2fSmrg  int i;
3375ee3138f1Smrg
337634977a2fSmrg  program_name = (char *) xstrdup (base_name (argv[0]));
337734977a2fSmrg  LTWRAPPER_DEBUGPRINTF (("(main) argv[0]      : %s\n", argv[0]));
337834977a2fSmrg  LTWRAPPER_DEBUGPRINTF (("(main) program_name : %s\n", program_name));
3379ee3138f1Smrg
338034977a2fSmrg  /* very simple arg parsing; don't want to rely on getopt */
338134977a2fSmrg  for (i = 1; i < argc; i++)
338234977a2fSmrg    {
338334977a2fSmrg      if (strcmp (argv[i], dumpscript_opt) == 0)
338434977a2fSmrg	{
338534977a2fSmrgEOF
338634977a2fSmrg	    case "$host" in
338734977a2fSmrg	      *mingw* | *cygwin* )
338834977a2fSmrg		# make stdout use "unix" line endings
338934977a2fSmrg		echo "          setmode(1,_O_BINARY);"
339034977a2fSmrg		;;
339134977a2fSmrg	      esac
3392ee3138f1Smrg
339334977a2fSmrg	    cat <<"EOF"
339434977a2fSmrg	  printf ("%s", script_text_part1);
339534977a2fSmrg	  printf ("%s", script_text_part2);
339634977a2fSmrg	  return 0;
339734977a2fSmrg	}
339834977a2fSmrg    }
3399ee3138f1Smrg
340034977a2fSmrg  newargz = XMALLOC (char *, argc + 1);
340134977a2fSmrg  tmp_pathspec = find_executable (argv[0]);
340234977a2fSmrg  if (tmp_pathspec == NULL)
340334977a2fSmrg    lt_fatal ("Couldn't find %s", argv[0]);
340434977a2fSmrg  LTWRAPPER_DEBUGPRINTF (("(main) found exe (before symlink chase) at : %s\n",
340534977a2fSmrg			  tmp_pathspec));
340634977a2fSmrg
340734977a2fSmrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
340834977a2fSmrg  LTWRAPPER_DEBUGPRINTF (("(main) found exe (after symlink chase) at : %s\n",
340934977a2fSmrg			  actual_cwrapper_path));
341034977a2fSmrg  XFREE (tmp_pathspec);
341134977a2fSmrg
341234977a2fSmrg  actual_cwrapper_name = xstrdup( base_name (actual_cwrapper_path));
341334977a2fSmrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
341434977a2fSmrg
341534977a2fSmrg  /* wrapper name transforms */
341634977a2fSmrg  strendzap (actual_cwrapper_name, ".exe");
341734977a2fSmrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
341834977a2fSmrg  XFREE (actual_cwrapper_name);
341934977a2fSmrg  actual_cwrapper_name = tmp_pathspec;
342034977a2fSmrg  tmp_pathspec = 0;
342134977a2fSmrg
342234977a2fSmrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
342334977a2fSmrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
342434977a2fSmrg  strendzap (target_name, ".exe");
342534977a2fSmrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
342634977a2fSmrg  XFREE (target_name);
342734977a2fSmrg  target_name = tmp_pathspec;
342834977a2fSmrg  tmp_pathspec = 0;
342934977a2fSmrg
343034977a2fSmrg  LTWRAPPER_DEBUGPRINTF (("(main) libtool target name: %s\n",
343134977a2fSmrg			  target_name));
343234977a2fSmrgEOF
3433ee3138f1Smrg
343434977a2fSmrg	    cat <<EOF
343534977a2fSmrg  newargz[0] =
343634977a2fSmrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
343734977a2fSmrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
343834977a2fSmrg  strcpy (newargz[0], actual_cwrapper_path);
343934977a2fSmrg  strcat (newargz[0], "$objdir");
344034977a2fSmrg  strcat (newargz[0], "/");
344134977a2fSmrgEOF
3442ee3138f1Smrg
344334977a2fSmrg	    cat <<"EOF"
344434977a2fSmrg  /* stop here, and copy so we don't have to do this twice */
344534977a2fSmrg  tmp_pathspec = xstrdup (newargz[0]);
3446ee3138f1Smrg
344734977a2fSmrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
344834977a2fSmrg  strcat (newargz[0], actual_cwrapper_name);
3449ee3138f1Smrg
345034977a2fSmrg  /* DO want the lt- prefix here if it exists, so use target_name */
345134977a2fSmrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
345234977a2fSmrg  XFREE (tmp_pathspec);
345334977a2fSmrg  tmp_pathspec = NULL;
345434977a2fSmrgEOF
3455ee3138f1Smrg
345634977a2fSmrg	    case $host_os in
345734977a2fSmrg	      mingw*)
345834977a2fSmrg	    cat <<"EOF"
345934977a2fSmrg  {
346034977a2fSmrg    char* p;
346134977a2fSmrg    while ((p = strchr (newargz[0], '\\')) != NULL)
346234977a2fSmrg      {
346334977a2fSmrg	*p = '/';
346434977a2fSmrg      }
346534977a2fSmrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
346634977a2fSmrg      {
346734977a2fSmrg	*p = '/';
346834977a2fSmrg      }
346934977a2fSmrg  }
347034977a2fSmrgEOF
347134977a2fSmrg	    ;;
347234977a2fSmrg	    esac
3473ee3138f1Smrg
347434977a2fSmrg	    cat <<"EOF"
347534977a2fSmrg  XFREE (target_name);
347634977a2fSmrg  XFREE (actual_cwrapper_path);
347734977a2fSmrg  XFREE (actual_cwrapper_name);
3478ee3138f1Smrg
347934977a2fSmrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
348034977a2fSmrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
348134977a2fSmrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
348234977a2fSmrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
3483ee3138f1Smrg
348434977a2fSmrg  newargc=0;
348534977a2fSmrg  for (i = 1; i < argc; i++)
348634977a2fSmrg    {
348734977a2fSmrg      if (strncmp (argv[i], env_set_opt, env_set_opt_len) == 0)
348834977a2fSmrg        {
348934977a2fSmrg          if (argv[i][env_set_opt_len] == '=')
349034977a2fSmrg            {
349134977a2fSmrg              const char *p = argv[i] + env_set_opt_len + 1;
349234977a2fSmrg              lt_opt_process_env_set (p);
349334977a2fSmrg            }
349434977a2fSmrg          else if (argv[i][env_set_opt_len] == '\0' && i + 1 < argc)
349534977a2fSmrg            {
349634977a2fSmrg              lt_opt_process_env_set (argv[++i]); /* don't copy */
349734977a2fSmrg            }
349834977a2fSmrg          else
349934977a2fSmrg            lt_fatal ("%s missing required argument", env_set_opt);
350034977a2fSmrg          continue;
350134977a2fSmrg        }
350234977a2fSmrg      if (strncmp (argv[i], env_prepend_opt, env_prepend_opt_len) == 0)
350334977a2fSmrg        {
350434977a2fSmrg          if (argv[i][env_prepend_opt_len] == '=')
350534977a2fSmrg            {
350634977a2fSmrg              const char *p = argv[i] + env_prepend_opt_len + 1;
350734977a2fSmrg              lt_opt_process_env_prepend (p);
350834977a2fSmrg            }
350934977a2fSmrg          else if (argv[i][env_prepend_opt_len] == '\0' && i + 1 < argc)
351034977a2fSmrg            {
351134977a2fSmrg              lt_opt_process_env_prepend (argv[++i]); /* don't copy */
351234977a2fSmrg            }
351334977a2fSmrg          else
351434977a2fSmrg            lt_fatal ("%s missing required argument", env_prepend_opt);
351534977a2fSmrg          continue;
351634977a2fSmrg        }
351734977a2fSmrg      if (strncmp (argv[i], env_append_opt, env_append_opt_len) == 0)
351834977a2fSmrg        {
351934977a2fSmrg          if (argv[i][env_append_opt_len] == '=')
352034977a2fSmrg            {
352134977a2fSmrg              const char *p = argv[i] + env_append_opt_len + 1;
352234977a2fSmrg              lt_opt_process_env_append (p);
352334977a2fSmrg            }
352434977a2fSmrg          else if (argv[i][env_append_opt_len] == '\0' && i + 1 < argc)
352534977a2fSmrg            {
352634977a2fSmrg              lt_opt_process_env_append (argv[++i]); /* don't copy */
352734977a2fSmrg            }
352834977a2fSmrg          else
352934977a2fSmrg            lt_fatal ("%s missing required argument", env_append_opt);
353034977a2fSmrg          continue;
353134977a2fSmrg        }
353234977a2fSmrg      if (strncmp (argv[i], ltwrapper_option_prefix, opt_prefix_len) == 0)
353334977a2fSmrg        {
353434977a2fSmrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
353534977a2fSmrg             namespace, but it is not one of the ones we know about and
353634977a2fSmrg             have already dealt with, above (inluding dump-script), then
353734977a2fSmrg             report an error. Otherwise, targets might begin to believe
353834977a2fSmrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
353934977a2fSmrg             namespace. The first time any user complains about this, we'll
354034977a2fSmrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
354134977a2fSmrg             or a configure.ac-settable value.
354234977a2fSmrg           */
354334977a2fSmrg          lt_fatal ("Unrecognized option in %s namespace: '%s'",
354434977a2fSmrg                    ltwrapper_option_prefix, argv[i]);
354534977a2fSmrg        }
354634977a2fSmrg      /* otherwise ... */
354734977a2fSmrg      newargz[++newargc] = xstrdup (argv[i]);
354834977a2fSmrg    }
354934977a2fSmrg  newargz[++newargc] = NULL;
3550ee3138f1Smrg
355134977a2fSmrg  LTWRAPPER_DEBUGPRINTF     (("(main) lt_argv_zero : %s\n", (lt_argv_zero ? lt_argv_zero : "<NULL>")));
355234977a2fSmrg  for (i = 0; i < newargc; i++)
355334977a2fSmrg    {
355434977a2fSmrg      LTWRAPPER_DEBUGPRINTF (("(main) newargz[%d]   : %s\n", i, (newargz[i] ? newargz[i] : "<NULL>")));
355534977a2fSmrg    }
3556ee3138f1Smrg
355734977a2fSmrgEOF
3558ee3138f1Smrg
355934977a2fSmrg	    case $host_os in
356034977a2fSmrg	      mingw*)
356134977a2fSmrg		cat <<"EOF"
356234977a2fSmrg  /* execv doesn't actually work on mingw as expected on unix */
356334977a2fSmrg  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
356434977a2fSmrg  if (rval == -1)
356534977a2fSmrg    {
356634977a2fSmrg      /* failed to start process */
356734977a2fSmrg      LTWRAPPER_DEBUGPRINTF (("(main) failed to launch target \"%s\": errno = %d\n", lt_argv_zero, errno));
356834977a2fSmrg      return 127;
356934977a2fSmrg    }
357034977a2fSmrg  return rval;
357134977a2fSmrgEOF
357234977a2fSmrg		;;
357334977a2fSmrg	      *)
357434977a2fSmrg		cat <<"EOF"
357534977a2fSmrg  execv (lt_argv_zero, newargz);
357634977a2fSmrg  return rval; /* =127, but avoids unused variable warning */
357734977a2fSmrgEOF
357834977a2fSmrg		;;
357934977a2fSmrg	    esac
3580ee3138f1Smrg
358134977a2fSmrg	    cat <<"EOF"
358234977a2fSmrg}
3583ee3138f1Smrg
358434977a2fSmrgvoid *
358534977a2fSmrgxmalloc (size_t num)
358634977a2fSmrg{
358734977a2fSmrg  void *p = (void *) malloc (num);
358834977a2fSmrg  if (!p)
358934977a2fSmrg    lt_fatal ("Memory exhausted");
3590ee3138f1Smrg
359134977a2fSmrg  return p;
359234977a2fSmrg}
3593ee3138f1Smrg
359434977a2fSmrgchar *
359534977a2fSmrgxstrdup (const char *string)
359634977a2fSmrg{
359734977a2fSmrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
359834977a2fSmrg			  string) : NULL;
359934977a2fSmrg}
3600ee3138f1Smrg
360134977a2fSmrgconst char *
360234977a2fSmrgbase_name (const char *name)
360334977a2fSmrg{
360434977a2fSmrg  const char *base;
3605ee3138f1Smrg
360634977a2fSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
360734977a2fSmrg  /* Skip over the disk name in MSDOS pathnames. */
360834977a2fSmrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
360934977a2fSmrg    name += 2;
361034977a2fSmrg#endif
3611ee3138f1Smrg
361234977a2fSmrg  for (base = name; *name; name++)
361334977a2fSmrg    if (IS_DIR_SEPARATOR (*name))
361434977a2fSmrg      base = name + 1;
361534977a2fSmrg  return base;
361634977a2fSmrg}
3617ee3138f1Smrg
361834977a2fSmrgint
361934977a2fSmrgcheck_executable (const char *path)
362034977a2fSmrg{
362134977a2fSmrg  struct stat st;
3622ee3138f1Smrg
362334977a2fSmrg  LTWRAPPER_DEBUGPRINTF (("(check_executable)  : %s\n",
362434977a2fSmrg			  path ? (*path ? path : "EMPTY!") : "NULL!"));
362534977a2fSmrg  if ((!path) || (!*path))
362634977a2fSmrg    return 0;
3627ee3138f1Smrg
362834977a2fSmrg  if ((stat (path, &st) >= 0)
362934977a2fSmrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
363034977a2fSmrg    return 1;
363134977a2fSmrg  else
363234977a2fSmrg    return 0;
363334977a2fSmrg}
3634ee3138f1Smrg
363534977a2fSmrgint
363634977a2fSmrgmake_executable (const char *path)
363734977a2fSmrg{
363834977a2fSmrg  int rval = 0;
363934977a2fSmrg  struct stat st;
3640ee3138f1Smrg
364134977a2fSmrg  LTWRAPPER_DEBUGPRINTF (("(make_executable)   : %s\n",
364234977a2fSmrg			  path ? (*path ? path : "EMPTY!") : "NULL!"));
364334977a2fSmrg  if ((!path) || (!*path))
364434977a2fSmrg    return 0;
3645ee3138f1Smrg
364634977a2fSmrg  if (stat (path, &st) >= 0)
364734977a2fSmrg    {
364834977a2fSmrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
364934977a2fSmrg    }
365034977a2fSmrg  return rval;
365134977a2fSmrg}
3652ee3138f1Smrg
365334977a2fSmrg/* Searches for the full path of the wrapper.  Returns
365434977a2fSmrg   newly allocated full path name if found, NULL otherwise
365534977a2fSmrg   Does not chase symlinks, even on platforms that support them.
365634977a2fSmrg*/
365734977a2fSmrgchar *
365834977a2fSmrgfind_executable (const char *wrapper)
365934977a2fSmrg{
366034977a2fSmrg  int has_slash = 0;
366134977a2fSmrg  const char *p;
366234977a2fSmrg  const char *p_next;
366334977a2fSmrg  /* static buffer for getcwd */
366434977a2fSmrg  char tmp[LT_PATHMAX + 1];
366534977a2fSmrg  int tmp_len;
366634977a2fSmrg  char *concat_name;
3667ee3138f1Smrg
366834977a2fSmrg  LTWRAPPER_DEBUGPRINTF (("(find_executable)   : %s\n",
366934977a2fSmrg			  wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!"));
3670ee3138f1Smrg
367134977a2fSmrg  if ((wrapper == NULL) || (*wrapper == '\0'))
367234977a2fSmrg    return NULL;
3673ee3138f1Smrg
367434977a2fSmrg  /* Absolute path? */
367534977a2fSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
367634977a2fSmrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
367734977a2fSmrg    {
367834977a2fSmrg      concat_name = xstrdup (wrapper);
367934977a2fSmrg      if (check_executable (concat_name))
368034977a2fSmrg	return concat_name;
368134977a2fSmrg      XFREE (concat_name);
368234977a2fSmrg    }
368334977a2fSmrg  else
368434977a2fSmrg    {
368534977a2fSmrg#endif
368634977a2fSmrg      if (IS_DIR_SEPARATOR (wrapper[0]))
368734977a2fSmrg	{
368834977a2fSmrg	  concat_name = xstrdup (wrapper);
368934977a2fSmrg	  if (check_executable (concat_name))
369034977a2fSmrg	    return concat_name;
369134977a2fSmrg	  XFREE (concat_name);
369234977a2fSmrg	}
369334977a2fSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
369434977a2fSmrg    }
369534977a2fSmrg#endif
3696ee3138f1Smrg
369734977a2fSmrg  for (p = wrapper; *p; p++)
369834977a2fSmrg    if (*p == '/')
369934977a2fSmrg      {
370034977a2fSmrg	has_slash = 1;
370134977a2fSmrg	break;
370234977a2fSmrg      }
370334977a2fSmrg  if (!has_slash)
370434977a2fSmrg    {
370534977a2fSmrg      /* no slashes; search PATH */
370634977a2fSmrg      const char *path = getenv ("PATH");
370734977a2fSmrg      if (path != NULL)
370834977a2fSmrg	{
370934977a2fSmrg	  for (p = path; *p; p = p_next)
371034977a2fSmrg	    {
371134977a2fSmrg	      const char *q;
371234977a2fSmrg	      size_t p_len;
371334977a2fSmrg	      for (q = p; *q; q++)
371434977a2fSmrg		if (IS_PATH_SEPARATOR (*q))
371534977a2fSmrg		  break;
371634977a2fSmrg	      p_len = q - p;
371734977a2fSmrg	      p_next = (*q == '\0' ? q : q + 1);
371834977a2fSmrg	      if (p_len == 0)
371934977a2fSmrg		{
372034977a2fSmrg		  /* empty path: current directory */
372134977a2fSmrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
372234977a2fSmrg		    lt_fatal ("getcwd failed");
372334977a2fSmrg		  tmp_len = strlen (tmp);
372434977a2fSmrg		  concat_name =
372534977a2fSmrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
372634977a2fSmrg		  memcpy (concat_name, tmp, tmp_len);
372734977a2fSmrg		  concat_name[tmp_len] = '/';
372834977a2fSmrg		  strcpy (concat_name + tmp_len + 1, wrapper);
372934977a2fSmrg		}
373034977a2fSmrg	      else
373134977a2fSmrg		{
373234977a2fSmrg		  concat_name =
373334977a2fSmrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
373434977a2fSmrg		  memcpy (concat_name, p, p_len);
373534977a2fSmrg		  concat_name[p_len] = '/';
373634977a2fSmrg		  strcpy (concat_name + p_len + 1, wrapper);
373734977a2fSmrg		}
373834977a2fSmrg	      if (check_executable (concat_name))
373934977a2fSmrg		return concat_name;
374034977a2fSmrg	      XFREE (concat_name);
374134977a2fSmrg	    }
374234977a2fSmrg	}
374334977a2fSmrg      /* not found in PATH; assume curdir */
374434977a2fSmrg    }
374534977a2fSmrg  /* Relative path | not found in path: prepend cwd */
374634977a2fSmrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
374734977a2fSmrg    lt_fatal ("getcwd failed");
374834977a2fSmrg  tmp_len = strlen (tmp);
374934977a2fSmrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
375034977a2fSmrg  memcpy (concat_name, tmp, tmp_len);
375134977a2fSmrg  concat_name[tmp_len] = '/';
375234977a2fSmrg  strcpy (concat_name + tmp_len + 1, wrapper);
3753ee3138f1Smrg
375434977a2fSmrg  if (check_executable (concat_name))
375534977a2fSmrg    return concat_name;
375634977a2fSmrg  XFREE (concat_name);
375734977a2fSmrg  return NULL;
375834977a2fSmrg}
3759ee3138f1Smrg
376034977a2fSmrgchar *
376134977a2fSmrgchase_symlinks (const char *pathspec)
376234977a2fSmrg{
376334977a2fSmrg#ifndef S_ISLNK
376434977a2fSmrg  return xstrdup (pathspec);
376534977a2fSmrg#else
376634977a2fSmrg  char buf[LT_PATHMAX];
376734977a2fSmrg  struct stat s;
376834977a2fSmrg  char *tmp_pathspec = xstrdup (pathspec);
376934977a2fSmrg  char *p;
377034977a2fSmrg  int has_symlinks = 0;
377134977a2fSmrg  while (strlen (tmp_pathspec) && !has_symlinks)
377234977a2fSmrg    {
377334977a2fSmrg      LTWRAPPER_DEBUGPRINTF (("checking path component for symlinks: %s\n",
377434977a2fSmrg			      tmp_pathspec));
377534977a2fSmrg      if (lstat (tmp_pathspec, &s) == 0)
377634977a2fSmrg	{
377734977a2fSmrg	  if (S_ISLNK (s.st_mode) != 0)
377834977a2fSmrg	    {
377934977a2fSmrg	      has_symlinks = 1;
378034977a2fSmrg	      break;
378134977a2fSmrg	    }
3782ee3138f1Smrg
378334977a2fSmrg	  /* search backwards for last DIR_SEPARATOR */
378434977a2fSmrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
378534977a2fSmrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
378634977a2fSmrg	    p--;
378734977a2fSmrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
378834977a2fSmrg	    {
378934977a2fSmrg	      /* no more DIR_SEPARATORS left */
379034977a2fSmrg	      break;
379134977a2fSmrg	    }
379234977a2fSmrg	  *p = '\0';
379334977a2fSmrg	}
379434977a2fSmrg      else
379534977a2fSmrg	{
379634977a2fSmrg	  char *errstr = strerror (errno);
379734977a2fSmrg	  lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr);
379834977a2fSmrg	}
379934977a2fSmrg    }
380034977a2fSmrg  XFREE (tmp_pathspec);
3801ee3138f1Smrg
380234977a2fSmrg  if (!has_symlinks)
380334977a2fSmrg    {
380434977a2fSmrg      return xstrdup (pathspec);
380534977a2fSmrg    }
3806ee3138f1Smrg
380734977a2fSmrg  tmp_pathspec = realpath (pathspec, buf);
380834977a2fSmrg  if (tmp_pathspec == 0)
380934977a2fSmrg    {
381034977a2fSmrg      lt_fatal ("Could not follow symlinks for %s", pathspec);
381134977a2fSmrg    }
381234977a2fSmrg  return xstrdup (tmp_pathspec);
381334977a2fSmrg#endif
381434977a2fSmrg}
3815ee3138f1Smrg
381634977a2fSmrgchar *
381734977a2fSmrgstrendzap (char *str, const char *pat)
381834977a2fSmrg{
381934977a2fSmrg  size_t len, patlen;
3820ee3138f1Smrg
382134977a2fSmrg  assert (str != NULL);
382234977a2fSmrg  assert (pat != NULL);
3823ee3138f1Smrg
382434977a2fSmrg  len = strlen (str);
382534977a2fSmrg  patlen = strlen (pat);
3826ee3138f1Smrg
382734977a2fSmrg  if (patlen <= len)
382834977a2fSmrg    {
382934977a2fSmrg      str += len - patlen;
383034977a2fSmrg      if (strcmp (str, pat) == 0)
383134977a2fSmrg	*str = '\0';
383234977a2fSmrg    }
383334977a2fSmrg  return str;
383434977a2fSmrg}
3835ee3138f1Smrg
383634977a2fSmrgstatic void
383734977a2fSmrglt_error_core (int exit_status, const char *mode,
383834977a2fSmrg	       const char *message, va_list ap)
383934977a2fSmrg{
384034977a2fSmrg  fprintf (stderr, "%s: %s: ", program_name, mode);
384134977a2fSmrg  vfprintf (stderr, message, ap);
384234977a2fSmrg  fprintf (stderr, ".\n");
3843ee3138f1Smrg
384434977a2fSmrg  if (exit_status >= 0)
384534977a2fSmrg    exit (exit_status);
384634977a2fSmrg}
3847ee3138f1Smrg
384834977a2fSmrgvoid
384934977a2fSmrglt_fatal (const char *message, ...)
385034977a2fSmrg{
385134977a2fSmrg  va_list ap;
385234977a2fSmrg  va_start (ap, message);
385334977a2fSmrg  lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
385434977a2fSmrg  va_end (ap);
385534977a2fSmrg}
3856ee3138f1Smrg
385734977a2fSmrgvoid
385834977a2fSmrglt_setenv (const char *name, const char *value)
385934977a2fSmrg{
386034977a2fSmrg  LTWRAPPER_DEBUGPRINTF (("(lt_setenv) setting '%s' to '%s'\n",
386134977a2fSmrg                          (name ? name : "<NULL>"),
386234977a2fSmrg                          (value ? value : "<NULL>")));
386334977a2fSmrg  {
386434977a2fSmrg#ifdef HAVE_SETENV
386534977a2fSmrg    /* always make a copy, for consistency with !HAVE_SETENV */
386634977a2fSmrg    char *str = xstrdup (value);
386734977a2fSmrg    setenv (name, str, 1);
386834977a2fSmrg#else
386934977a2fSmrg    int len = strlen (name) + 1 + strlen (value) + 1;
387034977a2fSmrg    char *str = XMALLOC (char, len);
387134977a2fSmrg    sprintf (str, "%s=%s", name, value);
387234977a2fSmrg    if (putenv (str) != EXIT_SUCCESS)
387334977a2fSmrg      {
387434977a2fSmrg        XFREE (str);
387534977a2fSmrg      }
387634977a2fSmrg#endif
387734977a2fSmrg  }
387834977a2fSmrg}
3879ee3138f1Smrg
388034977a2fSmrgchar *
388134977a2fSmrglt_extend_str (const char *orig_value, const char *add, int to_end)
388234977a2fSmrg{
388334977a2fSmrg  char *new_value;
388434977a2fSmrg  if (orig_value && *orig_value)
388534977a2fSmrg    {
388634977a2fSmrg      int orig_value_len = strlen (orig_value);
388734977a2fSmrg      int add_len = strlen (add);
388834977a2fSmrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
388934977a2fSmrg      if (to_end)
389034977a2fSmrg        {
389134977a2fSmrg          strcpy (new_value, orig_value);
389234977a2fSmrg          strcpy (new_value + orig_value_len, add);
389334977a2fSmrg        }
389434977a2fSmrg      else
389534977a2fSmrg        {
389634977a2fSmrg          strcpy (new_value, add);
389734977a2fSmrg          strcpy (new_value + add_len, orig_value);
389834977a2fSmrg        }
389934977a2fSmrg    }
390034977a2fSmrg  else
390134977a2fSmrg    {
390234977a2fSmrg      new_value = xstrdup (add);
390334977a2fSmrg    }
390434977a2fSmrg  return new_value;
390534977a2fSmrg}
3906ee3138f1Smrg
390734977a2fSmrgint
390834977a2fSmrglt_split_name_value (const char *arg, char** name, char** value)
390934977a2fSmrg{
391034977a2fSmrg  const char *p;
391134977a2fSmrg  int len;
391234977a2fSmrg  if (!arg || !*arg)
391334977a2fSmrg    return 1;
3914ee3138f1Smrg
391534977a2fSmrg  p = strchr (arg, (int)'=');
3916ee3138f1Smrg
391734977a2fSmrg  if (!p)
391834977a2fSmrg    return 1;
3919ee3138f1Smrg
392034977a2fSmrg  *value = xstrdup (++p);
3921ee3138f1Smrg
392234977a2fSmrg  len = strlen (arg) - strlen (*value);
392334977a2fSmrg  *name = XMALLOC (char, len);
392434977a2fSmrg  strncpy (*name, arg, len-1);
392534977a2fSmrg  (*name)[len - 1] = '\0';
3926ee3138f1Smrg
392734977a2fSmrg  return 0;
392834977a2fSmrg}
3929ee3138f1Smrg
393034977a2fSmrgvoid
393134977a2fSmrglt_opt_process_env_set (const char *arg)
393234977a2fSmrg{
393334977a2fSmrg  char *name = NULL;
393434977a2fSmrg  char *value = NULL;
3935ee3138f1Smrg
393634977a2fSmrg  if (lt_split_name_value (arg, &name, &value) != 0)
393734977a2fSmrg    {
393834977a2fSmrg      XFREE (name);
393934977a2fSmrg      XFREE (value);
394034977a2fSmrg      lt_fatal ("bad argument for %s: '%s'", env_set_opt, arg);
394134977a2fSmrg    }
3942ee3138f1Smrg
394334977a2fSmrg  lt_setenv (name, value);
394434977a2fSmrg  XFREE (name);
394534977a2fSmrg  XFREE (value);
394634977a2fSmrg}
3947ee3138f1Smrg
394834977a2fSmrgvoid
394934977a2fSmrglt_opt_process_env_prepend (const char *arg)
395034977a2fSmrg{
395134977a2fSmrg  char *name = NULL;
395234977a2fSmrg  char *value = NULL;
395334977a2fSmrg  char *new_value = NULL;
3954ee3138f1Smrg
395534977a2fSmrg  if (lt_split_name_value (arg, &name, &value) != 0)
395634977a2fSmrg    {
395734977a2fSmrg      XFREE (name);
395834977a2fSmrg      XFREE (value);
395934977a2fSmrg      lt_fatal ("bad argument for %s: '%s'", env_prepend_opt, arg);
396034977a2fSmrg    }
3961ee3138f1Smrg
396234977a2fSmrg  new_value = lt_extend_str (getenv (name), value, 0);
396334977a2fSmrg  lt_setenv (name, new_value);
396434977a2fSmrg  XFREE (new_value);
396534977a2fSmrg  XFREE (name);
396634977a2fSmrg  XFREE (value);
396734977a2fSmrg}
3968ee3138f1Smrg
396934977a2fSmrgvoid
397034977a2fSmrglt_opt_process_env_append (const char *arg)
397134977a2fSmrg{
397234977a2fSmrg  char *name = NULL;
397334977a2fSmrg  char *value = NULL;
397434977a2fSmrg  char *new_value = NULL;
3975ee3138f1Smrg
397634977a2fSmrg  if (lt_split_name_value (arg, &name, &value) != 0)
397734977a2fSmrg    {
397834977a2fSmrg      XFREE (name);
397934977a2fSmrg      XFREE (value);
398034977a2fSmrg      lt_fatal ("bad argument for %s: '%s'", env_append_opt, arg);
398134977a2fSmrg    }
3982ee3138f1Smrg
398334977a2fSmrg  new_value = lt_extend_str (getenv (name), value, 1);
398434977a2fSmrg  lt_setenv (name, new_value);
398534977a2fSmrg  XFREE (new_value);
398634977a2fSmrg  XFREE (name);
398734977a2fSmrg  XFREE (value);
398834977a2fSmrg}
3989ee3138f1Smrg
399034977a2fSmrgvoid
399134977a2fSmrglt_update_exe_path (const char *name, const char *value)
399234977a2fSmrg{
399334977a2fSmrg  LTWRAPPER_DEBUGPRINTF (("(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
399434977a2fSmrg                          (name ? name : "<NULL>"),
399534977a2fSmrg                          (value ? value : "<NULL>")));
3996ee3138f1Smrg
399734977a2fSmrg  if (name && *name && value && *value)
399834977a2fSmrg    {
399934977a2fSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
400034977a2fSmrg      /* some systems can't cope with a ':'-terminated path #' */
400134977a2fSmrg      int len = strlen (new_value);
400234977a2fSmrg      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
400334977a2fSmrg        {
400434977a2fSmrg          new_value[len-1] = '\0';
400534977a2fSmrg        }
400634977a2fSmrg      lt_setenv (name, new_value);
400734977a2fSmrg      XFREE (new_value);
400834977a2fSmrg    }
400934977a2fSmrg}
4010ee3138f1Smrg
401134977a2fSmrgvoid
401234977a2fSmrglt_update_lib_path (const char *name, const char *value)
401334977a2fSmrg{
401434977a2fSmrg  LTWRAPPER_DEBUGPRINTF (("(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
401534977a2fSmrg                          (name ? name : "<NULL>"),
401634977a2fSmrg                          (value ? value : "<NULL>")));
4017ee3138f1Smrg
401834977a2fSmrg  if (name && *name && value && *value)
401934977a2fSmrg    {
402034977a2fSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
402134977a2fSmrg      lt_setenv (name, new_value);
402234977a2fSmrg      XFREE (new_value);
402334977a2fSmrg    }
402434977a2fSmrg}
4025ee3138f1Smrg
4026ee3138f1Smrg
402734977a2fSmrgEOF
402834977a2fSmrg}
402934977a2fSmrg# end: func_emit_cwrapperexe_src
4030ee3138f1Smrg
403134977a2fSmrg# func_mode_link arg...
403234977a2fSmrgfunc_mode_link ()
403334977a2fSmrg{
403434977a2fSmrg    $opt_debug
403534977a2fSmrg    case $host in
403634977a2fSmrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
403734977a2fSmrg      # It is impossible to link a dll without this setting, and
403834977a2fSmrg      # we shouldn't force the makefile maintainer to figure out
403934977a2fSmrg      # which system we are compiling for in order to pass an extra
404034977a2fSmrg      # flag for every libtool invocation.
404134977a2fSmrg      # allow_undefined=no
4042ee3138f1Smrg
404334977a2fSmrg      # FIXME: Unfortunately, there are problems with the above when trying
404434977a2fSmrg      # to make a dll which has undefined symbols, in which case not
404534977a2fSmrg      # even a static library is built.  For now, we need to specify
404634977a2fSmrg      # -no-undefined on the libtool link line when we can be certain
404734977a2fSmrg      # that all symbols are satisfied, otherwise we get a static library.
404834977a2fSmrg      allow_undefined=yes
404934977a2fSmrg      ;;
405034977a2fSmrg    *)
405134977a2fSmrg      allow_undefined=yes
405234977a2fSmrg      ;;
405334977a2fSmrg    esac
405434977a2fSmrg    libtool_args=$nonopt
405534977a2fSmrg    base_compile="$nonopt $@"
405634977a2fSmrg    compile_command=$nonopt
405734977a2fSmrg    finalize_command=$nonopt
4058ee3138f1Smrg
405934977a2fSmrg    compile_rpath=
406034977a2fSmrg    finalize_rpath=
406134977a2fSmrg    compile_shlibpath=
406234977a2fSmrg    finalize_shlibpath=
406334977a2fSmrg    convenience=
406434977a2fSmrg    old_convenience=
406534977a2fSmrg    deplibs=
406634977a2fSmrg    old_deplibs=
406734977a2fSmrg    compiler_flags=
406834977a2fSmrg    linker_flags=
406934977a2fSmrg    dllsearchpath=
407034977a2fSmrg    lib_search_path=`pwd`
407134977a2fSmrg    inst_prefix_dir=
407234977a2fSmrg    new_inherited_linker_flags=
4073ee3138f1Smrg
407434977a2fSmrg    avoid_version=no
407534977a2fSmrg    dlfiles=
407634977a2fSmrg    dlprefiles=
407734977a2fSmrg    dlself=no
407834977a2fSmrg    export_dynamic=no
407934977a2fSmrg    export_symbols=
408034977a2fSmrg    export_symbols_regex=
408134977a2fSmrg    generated=
408234977a2fSmrg    libobjs=
408334977a2fSmrg    ltlibs=
408434977a2fSmrg    module=no
408534977a2fSmrg    no_install=no
408634977a2fSmrg    objs=
408734977a2fSmrg    non_pic_objects=
408834977a2fSmrg    precious_files_regex=
408934977a2fSmrg    prefer_static_libs=no
409034977a2fSmrg    preload=no
409134977a2fSmrg    prev=
409234977a2fSmrg    prevarg=
409334977a2fSmrg    release=
409434977a2fSmrg    rpath=
409534977a2fSmrg    xrpath=
409634977a2fSmrg    perm_rpath=
409734977a2fSmrg    temp_rpath=
409834977a2fSmrg    thread_safe=no
409934977a2fSmrg    vinfo=
410034977a2fSmrg    vinfo_number=no
410134977a2fSmrg    weak_libs=
410234977a2fSmrg    single_module="${wl}-single_module"
410334977a2fSmrg    func_infer_tag $base_compile
4104ee3138f1Smrg
410534977a2fSmrg    # We need to know -static, to get the right output filenames.
410634977a2fSmrg    for arg
410734977a2fSmrg    do
410834977a2fSmrg      case $arg in
410934977a2fSmrg      -shared)
411034977a2fSmrg	test "$build_libtool_libs" != yes && \
411134977a2fSmrg	  func_fatal_configuration "can not build a shared library"
411234977a2fSmrg	build_old_libs=no
411334977a2fSmrg	break
411434977a2fSmrg	;;
411534977a2fSmrg      -all-static | -static | -static-libtool-libs)
411634977a2fSmrg	case $arg in
411734977a2fSmrg	-all-static)
411834977a2fSmrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
411934977a2fSmrg	    func_warning "complete static linking is impossible in this configuration"
412034977a2fSmrg	  fi
412134977a2fSmrg	  if test -n "$link_static_flag"; then
412234977a2fSmrg	    dlopen_self=$dlopen_self_static
412334977a2fSmrg	  fi
412434977a2fSmrg	  prefer_static_libs=yes
412534977a2fSmrg	  ;;
412634977a2fSmrg	-static)
412734977a2fSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
412834977a2fSmrg	    dlopen_self=$dlopen_self_static
412934977a2fSmrg	  fi
413034977a2fSmrg	  prefer_static_libs=built
413134977a2fSmrg	  ;;
413234977a2fSmrg	-static-libtool-libs)
413334977a2fSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
413434977a2fSmrg	    dlopen_self=$dlopen_self_static
413534977a2fSmrg	  fi
413634977a2fSmrg	  prefer_static_libs=yes
413734977a2fSmrg	  ;;
413834977a2fSmrg	esac
413934977a2fSmrg	build_libtool_libs=no
414034977a2fSmrg	build_old_libs=yes
414134977a2fSmrg	break
414234977a2fSmrg	;;
414334977a2fSmrg      esac
414434977a2fSmrg    done
4145ee3138f1Smrg
414634977a2fSmrg    # See if our shared archives depend on static archives.
414734977a2fSmrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
4148ee3138f1Smrg
414934977a2fSmrg    # Go through the arguments, transforming them on the way.
415034977a2fSmrg    while test "$#" -gt 0; do
415134977a2fSmrg      arg="$1"
415234977a2fSmrg      shift
415334977a2fSmrg      func_quote_for_eval "$arg"
415434977a2fSmrg      qarg=$func_quote_for_eval_unquoted_result
415534977a2fSmrg      func_append libtool_args " $func_quote_for_eval_result"
4156ee3138f1Smrg
415734977a2fSmrg      # If the previous option needs an argument, assign it.
415834977a2fSmrg      if test -n "$prev"; then
415934977a2fSmrg	case $prev in
416034977a2fSmrg	output)
416134977a2fSmrg	  func_append compile_command " @OUTPUT@"
416234977a2fSmrg	  func_append finalize_command " @OUTPUT@"
416334977a2fSmrg	  ;;
416434977a2fSmrg	esac
4165ee3138f1Smrg
416634977a2fSmrg	case $prev in
416734977a2fSmrg	dlfiles|dlprefiles)
416834977a2fSmrg	  if test "$preload" = no; then
416934977a2fSmrg	    # Add the symbol object into the linking commands.
417034977a2fSmrg	    func_append compile_command " @SYMFILE@"
417134977a2fSmrg	    func_append finalize_command " @SYMFILE@"
417234977a2fSmrg	    preload=yes
4173ee3138f1Smrg	  fi
417434977a2fSmrg	  case $arg in
417534977a2fSmrg	  *.la | *.lo) ;;  # We handle these cases below.
417634977a2fSmrg	  force)
417734977a2fSmrg	    if test "$dlself" = no; then
417834977a2fSmrg	      dlself=needless
417934977a2fSmrg	      export_dynamic=yes
418034977a2fSmrg	    fi
418134977a2fSmrg	    prev=
418234977a2fSmrg	    continue
418334977a2fSmrg	    ;;
418434977a2fSmrg	  self)
418534977a2fSmrg	    if test "$prev" = dlprefiles; then
418634977a2fSmrg	      dlself=yes
418734977a2fSmrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
418834977a2fSmrg	      dlself=yes
418934977a2fSmrg	    else
419034977a2fSmrg	      dlself=needless
419134977a2fSmrg	      export_dynamic=yes
419234977a2fSmrg	    fi
419334977a2fSmrg	    prev=
419434977a2fSmrg	    continue
419534977a2fSmrg	    ;;
419634977a2fSmrg	  *)
419734977a2fSmrg	    if test "$prev" = dlfiles; then
419834977a2fSmrg	      dlfiles="$dlfiles $arg"
419934977a2fSmrg	    else
420034977a2fSmrg	      dlprefiles="$dlprefiles $arg"
420134977a2fSmrg	    fi
420234977a2fSmrg	    prev=
420334977a2fSmrg	    continue
420434977a2fSmrg	    ;;
420534977a2fSmrg	  esac
420634977a2fSmrg	  ;;
420734977a2fSmrg	expsyms)
420834977a2fSmrg	  export_symbols="$arg"
420934977a2fSmrg	  test -f "$arg" \
421034977a2fSmrg	    || func_fatal_error "symbol file \`$arg' does not exist"
421134977a2fSmrg	  prev=
421234977a2fSmrg	  continue
421334977a2fSmrg	  ;;
421434977a2fSmrg	expsyms_regex)
421534977a2fSmrg	  export_symbols_regex="$arg"
421634977a2fSmrg	  prev=
421734977a2fSmrg	  continue
421834977a2fSmrg	  ;;
421934977a2fSmrg	framework)
4220ee3138f1Smrg	  case $host in
422134977a2fSmrg	    *-*-darwin*)
422234977a2fSmrg	      case "$deplibs " in
422334977a2fSmrg		*" $qarg.ltframework "*) ;;
422434977a2fSmrg		*) deplibs="$deplibs $qarg.ltframework" # this is fixed later
422534977a2fSmrg		   ;;
422634977a2fSmrg	      esac
422734977a2fSmrg	      ;;
4228ee3138f1Smrg	  esac
422934977a2fSmrg	  prev=
423034977a2fSmrg	  continue
4231ee3138f1Smrg	  ;;
423234977a2fSmrg	inst_prefix)
423334977a2fSmrg	  inst_prefix_dir="$arg"
423434977a2fSmrg	  prev=
423534977a2fSmrg	  continue
4236ee3138f1Smrg	  ;;
423734977a2fSmrg	objectlist)
423834977a2fSmrg	  if test -f "$arg"; then
423934977a2fSmrg	    save_arg=$arg
424034977a2fSmrg	    moreargs=
424134977a2fSmrg	    for fil in `cat "$save_arg"`
424234977a2fSmrg	    do
424334977a2fSmrg#	      moreargs="$moreargs $fil"
424434977a2fSmrg	      arg=$fil
424534977a2fSmrg	      # A libtool-controlled object.
4246ee3138f1Smrg
424734977a2fSmrg	      # Check to see that this really is a libtool object.
424834977a2fSmrg	      if func_lalib_unsafe_p "$arg"; then
424934977a2fSmrg		pic_object=
425034977a2fSmrg		non_pic_object=
4251ee3138f1Smrg
425234977a2fSmrg		# Read the .lo file
425334977a2fSmrg		func_source "$arg"
4254ee3138f1Smrg
425534977a2fSmrg		if test -z "$pic_object" ||
425634977a2fSmrg		   test -z "$non_pic_object" ||
425734977a2fSmrg		   test "$pic_object" = none &&
425834977a2fSmrg		   test "$non_pic_object" = none; then
425934977a2fSmrg		  func_fatal_error "cannot find name of object for \`$arg'"
426034977a2fSmrg		fi
4261ee3138f1Smrg
426234977a2fSmrg		# Extract subdirectory from the argument.
426334977a2fSmrg		func_dirname "$arg" "/" ""
426434977a2fSmrg		xdir="$func_dirname_result"
4265ee3138f1Smrg
426634977a2fSmrg		if test "$pic_object" != none; then
426734977a2fSmrg		  # Prepend the subdirectory the object is found in.
426834977a2fSmrg		  pic_object="$xdir$pic_object"
4269ee3138f1Smrg
427034977a2fSmrg		  if test "$prev" = dlfiles; then
427134977a2fSmrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
427234977a2fSmrg		      dlfiles="$dlfiles $pic_object"
427334977a2fSmrg		      prev=
427434977a2fSmrg		      continue
427534977a2fSmrg		    else
427634977a2fSmrg		      # If libtool objects are unsupported, then we need to preload.
427734977a2fSmrg		      prev=dlprefiles
427834977a2fSmrg		    fi
427934977a2fSmrg		  fi
4280ee3138f1Smrg
428134977a2fSmrg		  # CHECK ME:  I think I busted this.  -Ossama
428234977a2fSmrg		  if test "$prev" = dlprefiles; then
428334977a2fSmrg		    # Preload the old-style object.
428434977a2fSmrg		    dlprefiles="$dlprefiles $pic_object"
428534977a2fSmrg		    prev=
428634977a2fSmrg		  fi
4287ee3138f1Smrg
428834977a2fSmrg		  # A PIC object.
428934977a2fSmrg		  func_append libobjs " $pic_object"
429034977a2fSmrg		  arg="$pic_object"
429134977a2fSmrg		fi
4292ee3138f1Smrg
429334977a2fSmrg		# Non-PIC object.
429434977a2fSmrg		if test "$non_pic_object" != none; then
429534977a2fSmrg		  # Prepend the subdirectory the object is found in.
429634977a2fSmrg		  non_pic_object="$xdir$non_pic_object"
429734977a2fSmrg
429834977a2fSmrg		  # A standard non-PIC object
429934977a2fSmrg		  func_append non_pic_objects " $non_pic_object"
430034977a2fSmrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
430134977a2fSmrg		    arg="$non_pic_object"
430234977a2fSmrg		  fi
430334977a2fSmrg		else
430434977a2fSmrg		  # If the PIC object exists, use it instead.
430534977a2fSmrg		  # $xdir was prepended to $pic_object above.
430634977a2fSmrg		  non_pic_object="$pic_object"
430734977a2fSmrg		  func_append non_pic_objects " $non_pic_object"
430834977a2fSmrg		fi
430934977a2fSmrg	      else
431034977a2fSmrg		# Only an error if not doing a dry-run.
431134977a2fSmrg		if $opt_dry_run; then
431234977a2fSmrg		  # Extract subdirectory from the argument.
431334977a2fSmrg		  func_dirname "$arg" "/" ""
431434977a2fSmrg		  xdir="$func_dirname_result"
431534977a2fSmrg
431634977a2fSmrg		  func_lo2o "$arg"
431734977a2fSmrg		  pic_object=$xdir$objdir/$func_lo2o_result
431834977a2fSmrg		  non_pic_object=$xdir$func_lo2o_result
431934977a2fSmrg		  func_append libobjs " $pic_object"
432034977a2fSmrg		  func_append non_pic_objects " $non_pic_object"
432134977a2fSmrg	        else
432234977a2fSmrg		  func_fatal_error "\`$arg' is not a valid libtool object"
432334977a2fSmrg		fi
432434977a2fSmrg	      fi
432534977a2fSmrg	    done
4326ee3138f1Smrg	  else
432734977a2fSmrg	    func_fatal_error "link input file \`$arg' does not exist"
4328ee3138f1Smrg	  fi
432934977a2fSmrg	  arg=$save_arg
433034977a2fSmrg	  prev=
433134977a2fSmrg	  continue
433234977a2fSmrg	  ;;
433334977a2fSmrg	precious_regex)
433434977a2fSmrg	  precious_files_regex="$arg"
433534977a2fSmrg	  prev=
433634977a2fSmrg	  continue
433734977a2fSmrg	  ;;
433834977a2fSmrg	release)
433934977a2fSmrg	  release="-$arg"
434034977a2fSmrg	  prev=
434134977a2fSmrg	  continue
434234977a2fSmrg	  ;;
434334977a2fSmrg	rpath | xrpath)
434434977a2fSmrg	  # We need an absolute path.
434534977a2fSmrg	  case $arg in
434634977a2fSmrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
434734977a2fSmrg	  *)
434834977a2fSmrg	    func_fatal_error "only absolute run-paths are allowed"
434934977a2fSmrg	    ;;
435034977a2fSmrg	  esac
435134977a2fSmrg	  if test "$prev" = rpath; then
435234977a2fSmrg	    case "$rpath " in
435334977a2fSmrg	    *" $arg "*) ;;
435434977a2fSmrg	    *) rpath="$rpath $arg" ;;
435534977a2fSmrg	    esac
4356ee3138f1Smrg	  else
435734977a2fSmrg	    case "$xrpath " in
435834977a2fSmrg	    *" $arg "*) ;;
435934977a2fSmrg	    *) xrpath="$xrpath $arg" ;;
436034977a2fSmrg	    esac
4361ee3138f1Smrg	  fi
436234977a2fSmrg	  prev=
436334977a2fSmrg	  continue
436434977a2fSmrg	  ;;
436534977a2fSmrg	shrext)
436634977a2fSmrg	  shrext_cmds="$arg"
436734977a2fSmrg	  prev=
436834977a2fSmrg	  continue
436934977a2fSmrg	  ;;
437034977a2fSmrg	weak)
437134977a2fSmrg	  weak_libs="$weak_libs $arg"
437234977a2fSmrg	  prev=
437334977a2fSmrg	  continue
437434977a2fSmrg	  ;;
437534977a2fSmrg	xcclinker)
437634977a2fSmrg	  linker_flags="$linker_flags $qarg"
437734977a2fSmrg	  compiler_flags="$compiler_flags $qarg"
437834977a2fSmrg	  prev=
437934977a2fSmrg	  func_append compile_command " $qarg"
438034977a2fSmrg	  func_append finalize_command " $qarg"
438134977a2fSmrg	  continue
438234977a2fSmrg	  ;;
438334977a2fSmrg	xcompiler)
438434977a2fSmrg	  compiler_flags="$compiler_flags $qarg"
438534977a2fSmrg	  prev=
438634977a2fSmrg	  func_append compile_command " $qarg"
438734977a2fSmrg	  func_append finalize_command " $qarg"
438834977a2fSmrg	  continue
438934977a2fSmrg	  ;;
439034977a2fSmrg	xlinker)
439134977a2fSmrg	  linker_flags="$linker_flags $qarg"
439234977a2fSmrg	  compiler_flags="$compiler_flags $wl$qarg"
439334977a2fSmrg	  prev=
439434977a2fSmrg	  func_append compile_command " $wl$qarg"
439534977a2fSmrg	  func_append finalize_command " $wl$qarg"
439634977a2fSmrg	  continue
439734977a2fSmrg	  ;;
439834977a2fSmrg	*)
439934977a2fSmrg	  eval "$prev=\"\$arg\""
440034977a2fSmrg	  prev=
440134977a2fSmrg	  continue
440234977a2fSmrg	  ;;
4403ee3138f1Smrg	esac
440434977a2fSmrg      fi # test -n "$prev"
4405ee3138f1Smrg
440634977a2fSmrg      prevarg="$arg"
4407ee3138f1Smrg
440834977a2fSmrg      case $arg in
440934977a2fSmrg      -all-static)
441034977a2fSmrg	if test -n "$link_static_flag"; then
441134977a2fSmrg	  # See comment for -static flag below, for more details.
441234977a2fSmrg	  func_append compile_command " $link_static_flag"
441334977a2fSmrg	  func_append finalize_command " $link_static_flag"
441434977a2fSmrg	fi
441534977a2fSmrg	continue
441634977a2fSmrg	;;
4417ee3138f1Smrg
441834977a2fSmrg      -allow-undefined)
441934977a2fSmrg	# FIXME: remove this flag sometime in the future.
442034977a2fSmrg	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
442134977a2fSmrg	;;
4422ee3138f1Smrg
442334977a2fSmrg      -avoid-version)
442434977a2fSmrg	avoid_version=yes
442534977a2fSmrg	continue
442634977a2fSmrg	;;
4427ee3138f1Smrg
442834977a2fSmrg      -dlopen)
442934977a2fSmrg	prev=dlfiles
443034977a2fSmrg	continue
443134977a2fSmrg	;;
4432ee3138f1Smrg
443334977a2fSmrg      -dlpreopen)
443434977a2fSmrg	prev=dlprefiles
443534977a2fSmrg	continue
443634977a2fSmrg	;;
4437ee3138f1Smrg
443834977a2fSmrg      -export-dynamic)
443934977a2fSmrg	export_dynamic=yes
444034977a2fSmrg	continue
444134977a2fSmrg	;;
4442ee3138f1Smrg
444334977a2fSmrg      -export-symbols | -export-symbols-regex)
444434977a2fSmrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
444534977a2fSmrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
444634977a2fSmrg	fi
444734977a2fSmrg	if test "X$arg" = "X-export-symbols"; then
444834977a2fSmrg	  prev=expsyms
444934977a2fSmrg	else
445034977a2fSmrg	  prev=expsyms_regex
445134977a2fSmrg	fi
445234977a2fSmrg	continue
445334977a2fSmrg	;;
4454ee3138f1Smrg
445534977a2fSmrg      -framework)
445634977a2fSmrg	prev=framework
445734977a2fSmrg	continue
445834977a2fSmrg	;;
4459ee3138f1Smrg
446034977a2fSmrg      -inst-prefix-dir)
446134977a2fSmrg	prev=inst_prefix
446234977a2fSmrg	continue
446334977a2fSmrg	;;
4464ee3138f1Smrg
446534977a2fSmrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
446634977a2fSmrg      # so, if we see these flags be careful not to treat them like -L
446734977a2fSmrg      -L[A-Z][A-Z]*:*)
446834977a2fSmrg	case $with_gcc/$host in
446934977a2fSmrg	no/*-*-irix* | /*-*-irix*)
447034977a2fSmrg	  func_append compile_command " $arg"
447134977a2fSmrg	  func_append finalize_command " $arg"
447234977a2fSmrg	  ;;
447334977a2fSmrg	esac
447434977a2fSmrg	continue
447534977a2fSmrg	;;
4476ee3138f1Smrg
447734977a2fSmrg      -L*)
447834977a2fSmrg	func_stripname '-L' '' "$arg"
447934977a2fSmrg	dir=$func_stripname_result
448034977a2fSmrg	if test -z "$dir"; then
448134977a2fSmrg	  if test "$#" -gt 0; then
448234977a2fSmrg	    func_fatal_error "require no space between \`-L' and \`$1'"
448334977a2fSmrg	  else
448434977a2fSmrg	    func_fatal_error "need path for \`-L' option"
448534977a2fSmrg	  fi
448634977a2fSmrg	fi
448734977a2fSmrg	# We need an absolute path.
448834977a2fSmrg	case $dir in
448934977a2fSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
449034977a2fSmrg	*)
449134977a2fSmrg	  absdir=`cd "$dir" && pwd`
449234977a2fSmrg	  test -z "$absdir" && \
449334977a2fSmrg	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
449434977a2fSmrg	  dir="$absdir"
449534977a2fSmrg	  ;;
449634977a2fSmrg	esac
449734977a2fSmrg	case "$deplibs " in
449834977a2fSmrg	*" -L$dir "*) ;;
449934977a2fSmrg	*)
450034977a2fSmrg	  deplibs="$deplibs -L$dir"
450134977a2fSmrg	  lib_search_path="$lib_search_path $dir"
450234977a2fSmrg	  ;;
450334977a2fSmrg	esac
450434977a2fSmrg	case $host in
450534977a2fSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
450634977a2fSmrg	  testbindir=`$ECHO "X$dir" | $Xsed -e 's*/lib$*/bin*'`
450734977a2fSmrg	  case :$dllsearchpath: in
450834977a2fSmrg	  *":$dir:"*) ;;
450934977a2fSmrg	  ::) dllsearchpath=$dir;;
451034977a2fSmrg	  *) dllsearchpath="$dllsearchpath:$dir";;
451134977a2fSmrg	  esac
451234977a2fSmrg	  case :$dllsearchpath: in
451334977a2fSmrg	  *":$testbindir:"*) ;;
451434977a2fSmrg	  ::) dllsearchpath=$testbindir;;
451534977a2fSmrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
451634977a2fSmrg	  esac
451734977a2fSmrg	  ;;
451834977a2fSmrg	esac
451934977a2fSmrg	continue
452034977a2fSmrg	;;
4521ee3138f1Smrg
452234977a2fSmrg      -l*)
452334977a2fSmrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
452434977a2fSmrg	  case $host in
452534977a2fSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc*)
452634977a2fSmrg	    # These systems don't actually have a C or math library (as such)
452734977a2fSmrg	    continue
452834977a2fSmrg	    ;;
452934977a2fSmrg	  *-*-os2*)
453034977a2fSmrg	    # These systems don't actually have a C library (as such)
453134977a2fSmrg	    test "X$arg" = "X-lc" && continue
453234977a2fSmrg	    ;;
453334977a2fSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
453434977a2fSmrg	    # Do not include libc due to us having libc/libc_r.
453534977a2fSmrg	    test "X$arg" = "X-lc" && continue
453634977a2fSmrg	    ;;
453734977a2fSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
453834977a2fSmrg	    # Rhapsody C and math libraries are in the System framework
453934977a2fSmrg	    deplibs="$deplibs System.ltframework"
454034977a2fSmrg	    continue
454134977a2fSmrg	    ;;
454234977a2fSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
454334977a2fSmrg	    # Causes problems with __ctype
454434977a2fSmrg	    test "X$arg" = "X-lc" && continue
454534977a2fSmrg	    ;;
454634977a2fSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
454734977a2fSmrg	    # Compiler inserts libc in the correct place for threads to work
454834977a2fSmrg	    test "X$arg" = "X-lc" && continue
454934977a2fSmrg	    ;;
455034977a2fSmrg	  esac
455134977a2fSmrg	elif test "X$arg" = "X-lc_r"; then
455234977a2fSmrg	 case $host in
455334977a2fSmrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
455434977a2fSmrg	   # Do not include libc_r directly, use -pthread flag.
455534977a2fSmrg	   continue
455634977a2fSmrg	   ;;
455734977a2fSmrg	 esac
455834977a2fSmrg	fi
455934977a2fSmrg	deplibs="$deplibs $arg"
456034977a2fSmrg	continue
456134977a2fSmrg	;;
4562ee3138f1Smrg
456334977a2fSmrg      -module)
456434977a2fSmrg	module=yes
456534977a2fSmrg	continue
456634977a2fSmrg	;;
4567ee3138f1Smrg
456834977a2fSmrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
456934977a2fSmrg      # classes, name mangling, and exception handling.
457034977a2fSmrg      # Darwin uses the -arch flag to determine output architecture.
457134977a2fSmrg      -model|-arch|-isysroot)
457234977a2fSmrg	compiler_flags="$compiler_flags $arg"
457334977a2fSmrg	func_append compile_command " $arg"
457434977a2fSmrg	func_append finalize_command " $arg"
457534977a2fSmrg	prev=xcompiler
457634977a2fSmrg	continue
457734977a2fSmrg	;;
4578ee3138f1Smrg
457934977a2fSmrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
458034977a2fSmrg	compiler_flags="$compiler_flags $arg"
458134977a2fSmrg	func_append compile_command " $arg"
458234977a2fSmrg	func_append finalize_command " $arg"
458334977a2fSmrg	case "$new_inherited_linker_flags " in
458434977a2fSmrg	    *" $arg "*) ;;
458534977a2fSmrg	    * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;;
458634977a2fSmrg	esac
458734977a2fSmrg	continue
458834977a2fSmrg	;;
4589ee3138f1Smrg
459034977a2fSmrg      -multi_module)
459134977a2fSmrg	single_module="${wl}-multi_module"
459234977a2fSmrg	continue
459334977a2fSmrg	;;
4594ee3138f1Smrg
459534977a2fSmrg      -no-fast-install)
459634977a2fSmrg	fast_install=no
459734977a2fSmrg	continue
459834977a2fSmrg	;;
4599ee3138f1Smrg
460034977a2fSmrg      -no-install)
460134977a2fSmrg	case $host in
460234977a2fSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
460334977a2fSmrg	  # The PATH hackery in wrapper scripts is required on Windows
460434977a2fSmrg	  # and Darwin in order for the loader to find any dlls it needs.
460534977a2fSmrg	  func_warning "\`-no-install' is ignored for $host"
460634977a2fSmrg	  func_warning "assuming \`-no-fast-install' instead"
460734977a2fSmrg	  fast_install=no
460834977a2fSmrg	  ;;
460934977a2fSmrg	*) no_install=yes ;;
461034977a2fSmrg	esac
461134977a2fSmrg	continue
461234977a2fSmrg	;;
4613ee3138f1Smrg
461434977a2fSmrg      -no-undefined)
461534977a2fSmrg	allow_undefined=no
461634977a2fSmrg	continue
461734977a2fSmrg	;;
4618ee3138f1Smrg
461934977a2fSmrg      -objectlist)
462034977a2fSmrg	prev=objectlist
462134977a2fSmrg	continue
462234977a2fSmrg	;;
4623ee3138f1Smrg
462434977a2fSmrg      -o) prev=output ;;
4625ee3138f1Smrg
462634977a2fSmrg      -precious-files-regex)
462734977a2fSmrg	prev=precious_regex
462834977a2fSmrg	continue
462934977a2fSmrg	;;
4630ee3138f1Smrg
463134977a2fSmrg      -release)
463234977a2fSmrg	prev=release
463334977a2fSmrg	continue
463434977a2fSmrg	;;
4635ee3138f1Smrg
463634977a2fSmrg      -rpath)
463734977a2fSmrg	prev=rpath
463834977a2fSmrg	continue
463934977a2fSmrg	;;
4640ee3138f1Smrg
464134977a2fSmrg      -R)
464234977a2fSmrg	prev=xrpath
464334977a2fSmrg	continue
464434977a2fSmrg	;;
4645ee3138f1Smrg
464634977a2fSmrg      -R*)
464734977a2fSmrg	func_stripname '-R' '' "$arg"
464834977a2fSmrg	dir=$func_stripname_result
464934977a2fSmrg	# We need an absolute path.
465034977a2fSmrg	case $dir in
465134977a2fSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
465234977a2fSmrg	*)
465334977a2fSmrg	  func_fatal_error "only absolute run-paths are allowed"
465434977a2fSmrg	  ;;
465534977a2fSmrg	esac
465634977a2fSmrg	case "$xrpath " in
465734977a2fSmrg	*" $dir "*) ;;
465834977a2fSmrg	*) xrpath="$xrpath $dir" ;;
465934977a2fSmrg	esac
466034977a2fSmrg	continue
466134977a2fSmrg	;;
4662ee3138f1Smrg
466334977a2fSmrg      -shared)
466434977a2fSmrg	# The effects of -shared are defined in a previous loop.
466534977a2fSmrg	continue
466634977a2fSmrg	;;
4667ee3138f1Smrg
466834977a2fSmrg      -shrext)
466934977a2fSmrg	prev=shrext
467034977a2fSmrg	continue
467134977a2fSmrg	;;
4672ee3138f1Smrg
467334977a2fSmrg      -static | -static-libtool-libs)
467434977a2fSmrg	# The effects of -static are defined in a previous loop.
467534977a2fSmrg	# We used to do the same as -all-static on platforms that
467634977a2fSmrg	# didn't have a PIC flag, but the assumption that the effects
467734977a2fSmrg	# would be equivalent was wrong.  It would break on at least
467834977a2fSmrg	# Digital Unix and AIX.
467934977a2fSmrg	continue
468034977a2fSmrg	;;
4681ee3138f1Smrg
468234977a2fSmrg      -thread-safe)
468334977a2fSmrg	thread_safe=yes
468434977a2fSmrg	continue
468534977a2fSmrg	;;
4686ee3138f1Smrg
468734977a2fSmrg      -version-info)
468834977a2fSmrg	prev=vinfo
468934977a2fSmrg	continue
469034977a2fSmrg	;;
4691ee3138f1Smrg
469234977a2fSmrg      -version-number)
469334977a2fSmrg	prev=vinfo
469434977a2fSmrg	vinfo_number=yes
469534977a2fSmrg	continue
469634977a2fSmrg	;;
4697ee3138f1Smrg
469834977a2fSmrg      -weak)
469934977a2fSmrg        prev=weak
470034977a2fSmrg	continue
470134977a2fSmrg	;;
4702ee3138f1Smrg
470334977a2fSmrg      -Wc,*)
470434977a2fSmrg	func_stripname '-Wc,' '' "$arg"
470534977a2fSmrg	args=$func_stripname_result
470634977a2fSmrg	arg=
470734977a2fSmrg	save_ifs="$IFS"; IFS=','
470834977a2fSmrg	for flag in $args; do
470934977a2fSmrg	  IFS="$save_ifs"
471034977a2fSmrg          func_quote_for_eval "$flag"
471134977a2fSmrg	  arg="$arg $wl$func_quote_for_eval_result"
471234977a2fSmrg	  compiler_flags="$compiler_flags $func_quote_for_eval_result"
471334977a2fSmrg	done
471434977a2fSmrg	IFS="$save_ifs"
471534977a2fSmrg	func_stripname ' ' '' "$arg"
471634977a2fSmrg	arg=$func_stripname_result
471734977a2fSmrg	;;
4718ee3138f1Smrg
471934977a2fSmrg      -Wl,*)
472034977a2fSmrg	func_stripname '-Wl,' '' "$arg"
472134977a2fSmrg	args=$func_stripname_result
472234977a2fSmrg	arg=
472334977a2fSmrg	save_ifs="$IFS"; IFS=','
472434977a2fSmrg	for flag in $args; do
472534977a2fSmrg	  IFS="$save_ifs"
472634977a2fSmrg          func_quote_for_eval "$flag"
472734977a2fSmrg	  arg="$arg $wl$func_quote_for_eval_result"
472834977a2fSmrg	  compiler_flags="$compiler_flags $wl$func_quote_for_eval_result"
472934977a2fSmrg	  linker_flags="$linker_flags $func_quote_for_eval_result"
473034977a2fSmrg	done
473134977a2fSmrg	IFS="$save_ifs"
473234977a2fSmrg	func_stripname ' ' '' "$arg"
473334977a2fSmrg	arg=$func_stripname_result
473434977a2fSmrg	;;
4735ee3138f1Smrg
473634977a2fSmrg      -Xcompiler)
473734977a2fSmrg	prev=xcompiler
473834977a2fSmrg	continue
473934977a2fSmrg	;;
4740ee3138f1Smrg
474134977a2fSmrg      -Xlinker)
474234977a2fSmrg	prev=xlinker
474334977a2fSmrg	continue
474434977a2fSmrg	;;
4745ee3138f1Smrg
474634977a2fSmrg      -XCClinker)
474734977a2fSmrg	prev=xcclinker
474834977a2fSmrg	continue
474934977a2fSmrg	;;
4750ee3138f1Smrg
475134977a2fSmrg      # -msg_* for osf cc
475234977a2fSmrg      -msg_*)
475334977a2fSmrg	func_quote_for_eval "$arg"
475434977a2fSmrg	arg="$func_quote_for_eval_result"
475534977a2fSmrg	;;
4756ee3138f1Smrg
475734977a2fSmrg      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
475834977a2fSmrg      # -r[0-9][0-9]* specifies the processor on the SGI compiler
475934977a2fSmrg      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
476034977a2fSmrg      # +DA*, +DD* enable 64-bit mode on the HP compiler
476134977a2fSmrg      # -q* pass through compiler args for the IBM compiler
476234977a2fSmrg      # -m*, -t[45]*, -txscale* pass through architecture-specific
476334977a2fSmrg      # compiler args for GCC
476434977a2fSmrg      # -F/path gives path to uninstalled frameworks, gcc on darwin
476534977a2fSmrg      # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
476634977a2fSmrg      # @file GCC response files
476734977a2fSmrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
476834977a2fSmrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*)
476934977a2fSmrg        func_quote_for_eval "$arg"
477034977a2fSmrg	arg="$func_quote_for_eval_result"
477134977a2fSmrg        func_append compile_command " $arg"
477234977a2fSmrg        func_append finalize_command " $arg"
477334977a2fSmrg        compiler_flags="$compiler_flags $arg"
477434977a2fSmrg        continue
477534977a2fSmrg        ;;
4776ee3138f1Smrg
477734977a2fSmrg      # Some other compiler flag.
477834977a2fSmrg      -* | +*)
477934977a2fSmrg        func_quote_for_eval "$arg"
478034977a2fSmrg	arg="$func_quote_for_eval_result"
478134977a2fSmrg	;;
4782ee3138f1Smrg
478334977a2fSmrg      *.$objext)
478434977a2fSmrg	# A standard object.
478534977a2fSmrg	objs="$objs $arg"
478634977a2fSmrg	;;
4787ee3138f1Smrg
478834977a2fSmrg      *.lo)
478934977a2fSmrg	# A libtool-controlled object.
4790ee3138f1Smrg
479134977a2fSmrg	# Check to see that this really is a libtool object.
479234977a2fSmrg	if func_lalib_unsafe_p "$arg"; then
479334977a2fSmrg	  pic_object=
479434977a2fSmrg	  non_pic_object=
4795ee3138f1Smrg
479634977a2fSmrg	  # Read the .lo file
479734977a2fSmrg	  func_source "$arg"
4798ee3138f1Smrg
479934977a2fSmrg	  if test -z "$pic_object" ||
480034977a2fSmrg	     test -z "$non_pic_object" ||
480134977a2fSmrg	     test "$pic_object" = none &&
480234977a2fSmrg	     test "$non_pic_object" = none; then
480334977a2fSmrg	    func_fatal_error "cannot find name of object for \`$arg'"
480434977a2fSmrg	  fi
4805ee3138f1Smrg
480634977a2fSmrg	  # Extract subdirectory from the argument.
480734977a2fSmrg	  func_dirname "$arg" "/" ""
480834977a2fSmrg	  xdir="$func_dirname_result"
4809ee3138f1Smrg
481034977a2fSmrg	  if test "$pic_object" != none; then
481134977a2fSmrg	    # Prepend the subdirectory the object is found in.
481234977a2fSmrg	    pic_object="$xdir$pic_object"
4813ee3138f1Smrg
481434977a2fSmrg	    if test "$prev" = dlfiles; then
481534977a2fSmrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
481634977a2fSmrg		dlfiles="$dlfiles $pic_object"
481734977a2fSmrg		prev=
481834977a2fSmrg		continue
481934977a2fSmrg	      else
482034977a2fSmrg		# If libtool objects are unsupported, then we need to preload.
482134977a2fSmrg		prev=dlprefiles
482234977a2fSmrg	      fi
482334977a2fSmrg	    fi
4824ee3138f1Smrg
482534977a2fSmrg	    # CHECK ME:  I think I busted this.  -Ossama
482634977a2fSmrg	    if test "$prev" = dlprefiles; then
482734977a2fSmrg	      # Preload the old-style object.
482834977a2fSmrg	      dlprefiles="$dlprefiles $pic_object"
482934977a2fSmrg	      prev=
483034977a2fSmrg	    fi
4831ee3138f1Smrg
483234977a2fSmrg	    # A PIC object.
483334977a2fSmrg	    func_append libobjs " $pic_object"
483434977a2fSmrg	    arg="$pic_object"
483534977a2fSmrg	  fi
4836ee3138f1Smrg
483734977a2fSmrg	  # Non-PIC object.
483834977a2fSmrg	  if test "$non_pic_object" != none; then
483934977a2fSmrg	    # Prepend the subdirectory the object is found in.
484034977a2fSmrg	    non_pic_object="$xdir$non_pic_object"
4841ee3138f1Smrg
484234977a2fSmrg	    # A standard non-PIC object
484334977a2fSmrg	    func_append non_pic_objects " $non_pic_object"
484434977a2fSmrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
484534977a2fSmrg	      arg="$non_pic_object"
484634977a2fSmrg	    fi
484734977a2fSmrg	  else
484834977a2fSmrg	    # If the PIC object exists, use it instead.
484934977a2fSmrg	    # $xdir was prepended to $pic_object above.
485034977a2fSmrg	    non_pic_object="$pic_object"
485134977a2fSmrg	    func_append non_pic_objects " $non_pic_object"
485234977a2fSmrg	  fi
485334977a2fSmrg	else
485434977a2fSmrg	  # Only an error if not doing a dry-run.
485534977a2fSmrg	  if $opt_dry_run; then
485634977a2fSmrg	    # Extract subdirectory from the argument.
485734977a2fSmrg	    func_dirname "$arg" "/" ""
485834977a2fSmrg	    xdir="$func_dirname_result"
485934977a2fSmrg
486034977a2fSmrg	    func_lo2o "$arg"
486134977a2fSmrg	    pic_object=$xdir$objdir/$func_lo2o_result
486234977a2fSmrg	    non_pic_object=$xdir$func_lo2o_result
486334977a2fSmrg	    func_append libobjs " $pic_object"
486434977a2fSmrg	    func_append non_pic_objects " $non_pic_object"
486534977a2fSmrg	  else
486634977a2fSmrg	    func_fatal_error "\`$arg' is not a valid libtool object"
486734977a2fSmrg	  fi
486834977a2fSmrg	fi
486934977a2fSmrg	;;
487034977a2fSmrg
487134977a2fSmrg      *.$libext)
487234977a2fSmrg	# An archive.
487334977a2fSmrg	deplibs="$deplibs $arg"
487434977a2fSmrg	old_deplibs="$old_deplibs $arg"
487534977a2fSmrg	continue
487634977a2fSmrg	;;
487734977a2fSmrg
487834977a2fSmrg      *.la)
487934977a2fSmrg	# A libtool-controlled library.
488034977a2fSmrg
488134977a2fSmrg	if test "$prev" = dlfiles; then
488234977a2fSmrg	  # This library was specified with -dlopen.
488334977a2fSmrg	  dlfiles="$dlfiles $arg"
488434977a2fSmrg	  prev=
488534977a2fSmrg	elif test "$prev" = dlprefiles; then
488634977a2fSmrg	  # The library was specified with -dlpreopen.
488734977a2fSmrg	  dlprefiles="$dlprefiles $arg"
488834977a2fSmrg	  prev=
488934977a2fSmrg	else
489034977a2fSmrg	  deplibs="$deplibs $arg"
489134977a2fSmrg	fi
489234977a2fSmrg	continue
489334977a2fSmrg	;;
489434977a2fSmrg
489534977a2fSmrg      # Some other compiler argument.
489634977a2fSmrg      *)
489734977a2fSmrg	# Unknown arguments in both finalize_command and compile_command need
489834977a2fSmrg	# to be aesthetically quoted because they are evaled later.
489934977a2fSmrg	func_quote_for_eval "$arg"
490034977a2fSmrg	arg="$func_quote_for_eval_result"
490134977a2fSmrg	;;
490234977a2fSmrg      esac # arg
490334977a2fSmrg
490434977a2fSmrg      # Now actually substitute the argument into the commands.
490534977a2fSmrg      if test -n "$arg"; then
490634977a2fSmrg	func_append compile_command " $arg"
490734977a2fSmrg	func_append finalize_command " $arg"
490834977a2fSmrg      fi
490934977a2fSmrg    done # argument parsing loop
491034977a2fSmrg
491134977a2fSmrg    test -n "$prev" && \
491234977a2fSmrg      func_fatal_help "the \`$prevarg' option requires an argument"
491334977a2fSmrg
491434977a2fSmrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
491534977a2fSmrg      eval arg=\"$export_dynamic_flag_spec\"
491634977a2fSmrg      func_append compile_command " $arg"
491734977a2fSmrg      func_append finalize_command " $arg"
491834977a2fSmrg    fi
491934977a2fSmrg
492034977a2fSmrg    oldlibs=
492134977a2fSmrg    # calculate the name of the file, without its directory
492234977a2fSmrg    func_basename "$output"
492334977a2fSmrg    outputname="$func_basename_result"
492434977a2fSmrg    libobjs_save="$libobjs"
492534977a2fSmrg
492634977a2fSmrg    if test -n "$shlibpath_var"; then
492734977a2fSmrg      # get the directories listed in $shlibpath_var
492834977a2fSmrg      eval shlib_search_path=\`\$ECHO \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
492934977a2fSmrg    else
493034977a2fSmrg      shlib_search_path=
493134977a2fSmrg    fi
493234977a2fSmrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
493334977a2fSmrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
493434977a2fSmrg
493534977a2fSmrg    func_dirname "$output" "/" ""
493634977a2fSmrg    output_objdir="$func_dirname_result$objdir"
493734977a2fSmrg    # Create the object directory.
493834977a2fSmrg    func_mkdir_p "$output_objdir"
493934977a2fSmrg
494034977a2fSmrg    # Determine the type of output
494134977a2fSmrg    case $output in
494234977a2fSmrg    "")
494334977a2fSmrg      func_fatal_help "you must specify an output file"
494434977a2fSmrg      ;;
494534977a2fSmrg    *.$libext) linkmode=oldlib ;;
494634977a2fSmrg    *.lo | *.$objext) linkmode=obj ;;
494734977a2fSmrg    *.la) linkmode=lib ;;
494834977a2fSmrg    *) linkmode=prog ;; # Anything else should be a program.
494934977a2fSmrg    esac
495034977a2fSmrg
495134977a2fSmrg    specialdeplibs=
495234977a2fSmrg
495334977a2fSmrg    libs=
495434977a2fSmrg    # Find all interdependent deplibs by searching for libraries
495534977a2fSmrg    # that are linked more than once (e.g. -la -lb -la)
495634977a2fSmrg    for deplib in $deplibs; do
495734977a2fSmrg      if $opt_duplicate_deps ; then
495834977a2fSmrg	case "$libs " in
495934977a2fSmrg	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
496034977a2fSmrg	esac
496134977a2fSmrg      fi
496234977a2fSmrg      libs="$libs $deplib"
496334977a2fSmrg    done
496434977a2fSmrg
496534977a2fSmrg    if test "$linkmode" = lib; then
496634977a2fSmrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
496734977a2fSmrg
496834977a2fSmrg      # Compute libraries that are listed more than once in $predeps
496934977a2fSmrg      # $postdeps and mark them as special (i.e., whose duplicates are
497034977a2fSmrg      # not to be eliminated).
497134977a2fSmrg      pre_post_deps=
497234977a2fSmrg      if $opt_duplicate_compiler_generated_deps; then
497334977a2fSmrg	for pre_post_dep in $predeps $postdeps; do
497434977a2fSmrg	  case "$pre_post_deps " in
497534977a2fSmrg	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
497634977a2fSmrg	  esac
497734977a2fSmrg	  pre_post_deps="$pre_post_deps $pre_post_dep"
497834977a2fSmrg	done
497934977a2fSmrg      fi
498034977a2fSmrg      pre_post_deps=
498134977a2fSmrg    fi
498234977a2fSmrg
498334977a2fSmrg    deplibs=
498434977a2fSmrg    newdependency_libs=
498534977a2fSmrg    newlib_search_path=
498634977a2fSmrg    need_relink=no # whether we're linking any uninstalled libtool libraries
498734977a2fSmrg    notinst_deplibs= # not-installed libtool libraries
498834977a2fSmrg    notinst_path= # paths that contain not-installed libtool libraries
498934977a2fSmrg
499034977a2fSmrg    case $linkmode in
499134977a2fSmrg    lib)
499234977a2fSmrg	passes="conv dlpreopen link"
499334977a2fSmrg	for file in $dlfiles $dlprefiles; do
499434977a2fSmrg	  case $file in
499534977a2fSmrg	  *.la) ;;
499634977a2fSmrg	  *)
499734977a2fSmrg	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
499834977a2fSmrg	    ;;
499934977a2fSmrg	  esac
500034977a2fSmrg	done
500134977a2fSmrg	;;
500234977a2fSmrg    prog)
500334977a2fSmrg	compile_deplibs=
500434977a2fSmrg	finalize_deplibs=
500534977a2fSmrg	alldeplibs=no
500634977a2fSmrg	newdlfiles=
500734977a2fSmrg	newdlprefiles=
500834977a2fSmrg	passes="conv scan dlopen dlpreopen link"
500934977a2fSmrg	;;
501034977a2fSmrg    *)  passes="conv"
501134977a2fSmrg	;;
501234977a2fSmrg    esac
501334977a2fSmrg
501434977a2fSmrg    for pass in $passes; do
501534977a2fSmrg      # The preopen pass in lib mode reverses $deplibs; put it back here
501634977a2fSmrg      # so that -L comes before libs that need it for instance...
501734977a2fSmrg      if test "$linkmode,$pass" = "lib,link"; then
501834977a2fSmrg	## FIXME: Find the place where the list is rebuilt in the wrong
501934977a2fSmrg	##        order, and fix it there properly
502034977a2fSmrg        tmp_deplibs=
502134977a2fSmrg	for deplib in $deplibs; do
502234977a2fSmrg	  tmp_deplibs="$deplib $tmp_deplibs"
502334977a2fSmrg	done
502434977a2fSmrg	deplibs="$tmp_deplibs"
502534977a2fSmrg      fi
502634977a2fSmrg
502734977a2fSmrg      if test "$linkmode,$pass" = "lib,link" ||
502834977a2fSmrg	 test "$linkmode,$pass" = "prog,scan"; then
502934977a2fSmrg	libs="$deplibs"
503034977a2fSmrg	deplibs=
503134977a2fSmrg      fi
503234977a2fSmrg      if test "$linkmode" = prog; then
503334977a2fSmrg	case $pass in
503434977a2fSmrg	dlopen) libs="$dlfiles" ;;
503534977a2fSmrg	dlpreopen) libs="$dlprefiles" ;;
503634977a2fSmrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
503734977a2fSmrg	esac
503834977a2fSmrg      fi
503934977a2fSmrg      if test "$linkmode,$pass" = "lib,dlpreopen"; then
504034977a2fSmrg	# Collect and forward deplibs of preopened libtool libs
504134977a2fSmrg	for lib in $dlprefiles; do
504234977a2fSmrg	  # Ignore non-libtool-libs
504334977a2fSmrg	  dependency_libs=
504434977a2fSmrg	  case $lib in
504534977a2fSmrg	  *.la)	func_source "$lib" ;;
504634977a2fSmrg	  esac
504734977a2fSmrg
504834977a2fSmrg	  # Collect preopened libtool deplibs, except any this library
504934977a2fSmrg	  # has declared as weak libs
505034977a2fSmrg	  for deplib in $dependency_libs; do
505134977a2fSmrg            deplib_base=`$ECHO "X$deplib" | $Xsed -e "$basename"`
505234977a2fSmrg	    case " $weak_libs " in
505334977a2fSmrg	    *" $deplib_base "*) ;;
505434977a2fSmrg	    *) deplibs="$deplibs $deplib" ;;
505534977a2fSmrg	    esac
505634977a2fSmrg	  done
505734977a2fSmrg	done
505834977a2fSmrg	libs="$dlprefiles"
505934977a2fSmrg      fi
506034977a2fSmrg      if test "$pass" = dlopen; then
506134977a2fSmrg	# Collect dlpreopened libraries
506234977a2fSmrg	save_deplibs="$deplibs"
506334977a2fSmrg	deplibs=
506434977a2fSmrg      fi
506534977a2fSmrg
506634977a2fSmrg      for deplib in $libs; do
506734977a2fSmrg	lib=
506834977a2fSmrg	found=no
506934977a2fSmrg	case $deplib in
507034977a2fSmrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
507134977a2fSmrg	  if test "$linkmode,$pass" = "prog,link"; then
507234977a2fSmrg	    compile_deplibs="$deplib $compile_deplibs"
507334977a2fSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
507434977a2fSmrg	  else
507534977a2fSmrg	    compiler_flags="$compiler_flags $deplib"
507634977a2fSmrg	    if test "$linkmode" = lib ; then
507734977a2fSmrg		case "$new_inherited_linker_flags " in
507834977a2fSmrg		    *" $deplib "*) ;;
507934977a2fSmrg		    * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
508034977a2fSmrg		esac
508134977a2fSmrg	    fi
508234977a2fSmrg	  fi
508334977a2fSmrg	  continue
508434977a2fSmrg	  ;;
508534977a2fSmrg	-l*)
508634977a2fSmrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
508734977a2fSmrg	    func_warning "\`-l' is ignored for archives/objects"
508834977a2fSmrg	    continue
508934977a2fSmrg	  fi
509034977a2fSmrg	  func_stripname '-l' '' "$deplib"
509134977a2fSmrg	  name=$func_stripname_result
509234977a2fSmrg	  if test "$linkmode" = lib; then
509334977a2fSmrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
509434977a2fSmrg	  else
509534977a2fSmrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
509634977a2fSmrg	  fi
509734977a2fSmrg	  for searchdir in $searchdirs; do
509834977a2fSmrg	    for search_ext in .la $std_shrext .so .a; do
509934977a2fSmrg	      # Search the libtool library
510034977a2fSmrg	      lib="$searchdir/lib${name}${search_ext}"
510134977a2fSmrg	      if test -f "$lib"; then
510234977a2fSmrg		if test "$search_ext" = ".la"; then
510334977a2fSmrg		  found=yes
510434977a2fSmrg		else
510534977a2fSmrg		  found=no
510634977a2fSmrg		fi
510734977a2fSmrg		break 2
510834977a2fSmrg	      fi
510934977a2fSmrg	    done
511034977a2fSmrg	  done
511134977a2fSmrg	  if test "$found" != yes; then
511234977a2fSmrg	    # deplib doesn't seem to be a libtool library
511334977a2fSmrg	    if test "$linkmode,$pass" = "prog,link"; then
511434977a2fSmrg	      compile_deplibs="$deplib $compile_deplibs"
511534977a2fSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
511634977a2fSmrg	    else
511734977a2fSmrg	      deplibs="$deplib $deplibs"
511834977a2fSmrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
511934977a2fSmrg	    fi
512034977a2fSmrg	    continue
512134977a2fSmrg	  else # deplib is a libtool library
512234977a2fSmrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
512334977a2fSmrg	    # We need to do some special things here, and not later.
512434977a2fSmrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
512534977a2fSmrg	      case " $predeps $postdeps " in
512634977a2fSmrg	      *" $deplib "*)
512734977a2fSmrg		if func_lalib_p "$lib"; then
512834977a2fSmrg		  library_names=
512934977a2fSmrg		  old_library=
513034977a2fSmrg		  func_source "$lib"
513134977a2fSmrg		  for l in $old_library $library_names; do
513234977a2fSmrg		    ll="$l"
513334977a2fSmrg		  done
513434977a2fSmrg		  if test "X$ll" = "X$old_library" ; then # only static version available
513534977a2fSmrg		    found=no
513634977a2fSmrg		    func_dirname "$lib" "" "."
513734977a2fSmrg		    ladir="$func_dirname_result"
513834977a2fSmrg		    lib=$ladir/$old_library
513934977a2fSmrg		    if test "$linkmode,$pass" = "prog,link"; then
514034977a2fSmrg		      compile_deplibs="$deplib $compile_deplibs"
514134977a2fSmrg		      finalize_deplibs="$deplib $finalize_deplibs"
514234977a2fSmrg		    else
514334977a2fSmrg		      deplibs="$deplib $deplibs"
514434977a2fSmrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
514534977a2fSmrg		    fi
514634977a2fSmrg		    continue
514734977a2fSmrg		  fi
514834977a2fSmrg		fi
514934977a2fSmrg		;;
515034977a2fSmrg	      *) ;;
515134977a2fSmrg	      esac
515234977a2fSmrg	    fi
515334977a2fSmrg	  fi
515434977a2fSmrg	  ;; # -l
515534977a2fSmrg	*.ltframework)
515634977a2fSmrg	  if test "$linkmode,$pass" = "prog,link"; then
515734977a2fSmrg	    compile_deplibs="$deplib $compile_deplibs"
515834977a2fSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
515934977a2fSmrg	  else
516034977a2fSmrg	    deplibs="$deplib $deplibs"
516134977a2fSmrg	    if test "$linkmode" = lib ; then
516234977a2fSmrg		case "$new_inherited_linker_flags " in
516334977a2fSmrg		    *" $deplib "*) ;;
516434977a2fSmrg		    * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
516534977a2fSmrg		esac
516634977a2fSmrg	    fi
516734977a2fSmrg	  fi
516834977a2fSmrg	  continue
516934977a2fSmrg	  ;;
517034977a2fSmrg	-L*)
517134977a2fSmrg	  case $linkmode in
517234977a2fSmrg	  lib)
517334977a2fSmrg	    deplibs="$deplib $deplibs"
517434977a2fSmrg	    test "$pass" = conv && continue
517534977a2fSmrg	    newdependency_libs="$deplib $newdependency_libs"
517634977a2fSmrg	    func_stripname '-L' '' "$deplib"
517734977a2fSmrg	    newlib_search_path="$newlib_search_path $func_stripname_result"
517834977a2fSmrg	    ;;
517934977a2fSmrg	  prog)
518034977a2fSmrg	    if test "$pass" = conv; then
518134977a2fSmrg	      deplibs="$deplib $deplibs"
518234977a2fSmrg	      continue
518334977a2fSmrg	    fi
518434977a2fSmrg	    if test "$pass" = scan; then
518534977a2fSmrg	      deplibs="$deplib $deplibs"
518634977a2fSmrg	    else
518734977a2fSmrg	      compile_deplibs="$deplib $compile_deplibs"
518834977a2fSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
518934977a2fSmrg	    fi
519034977a2fSmrg	    func_stripname '-L' '' "$deplib"
519134977a2fSmrg	    newlib_search_path="$newlib_search_path $func_stripname_result"
519234977a2fSmrg	    ;;
519334977a2fSmrg	  *)
519434977a2fSmrg	    func_warning "\`-L' is ignored for archives/objects"
519534977a2fSmrg	    ;;
519634977a2fSmrg	  esac # linkmode
519734977a2fSmrg	  continue
519834977a2fSmrg	  ;; # -L
519934977a2fSmrg	-R*)
520034977a2fSmrg	  if test "$pass" = link; then
520134977a2fSmrg	    func_stripname '-R' '' "$deplib"
520234977a2fSmrg	    dir=$func_stripname_result
520334977a2fSmrg	    # Make sure the xrpath contains only unique directories.
520434977a2fSmrg	    case "$xrpath " in
520534977a2fSmrg	    *" $dir "*) ;;
520634977a2fSmrg	    *) xrpath="$xrpath $dir" ;;
520734977a2fSmrg	    esac
520834977a2fSmrg	  fi
520934977a2fSmrg	  deplibs="$deplib $deplibs"
521034977a2fSmrg	  continue
521134977a2fSmrg	  ;;
521234977a2fSmrg	*.la) lib="$deplib" ;;
521334977a2fSmrg	*.$libext)
521434977a2fSmrg	  if test "$pass" = conv; then
521534977a2fSmrg	    deplibs="$deplib $deplibs"
521634977a2fSmrg	    continue
521734977a2fSmrg	  fi
521834977a2fSmrg	  case $linkmode in
521934977a2fSmrg	  lib)
522034977a2fSmrg	    # Linking convenience modules into shared libraries is allowed,
522134977a2fSmrg	    # but linking other static libraries is non-portable.
522234977a2fSmrg	    case " $dlpreconveniencelibs " in
522334977a2fSmrg	    *" $deplib "*) ;;
522434977a2fSmrg	    *)
522534977a2fSmrg	      valid_a_lib=no
522634977a2fSmrg	      case $deplibs_check_method in
522734977a2fSmrg		match_pattern*)
522834977a2fSmrg		  set dummy $deplibs_check_method; shift
522934977a2fSmrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
523034977a2fSmrg		  if eval "\$ECHO \"X$deplib\"" 2>/dev/null | $Xsed -e 10q \
523134977a2fSmrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
523234977a2fSmrg		    valid_a_lib=yes
523334977a2fSmrg		  fi
523434977a2fSmrg		;;
523534977a2fSmrg		pass_all)
523634977a2fSmrg		  valid_a_lib=yes
523734977a2fSmrg		;;
523834977a2fSmrg	      esac
523934977a2fSmrg	      if test "$valid_a_lib" != yes; then
524034977a2fSmrg		$ECHO
524134977a2fSmrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
524234977a2fSmrg		$ECHO "*** I have the capability to make that library automatically link in when"
524334977a2fSmrg		$ECHO "*** you link to this library.  But I can only do this if you have a"
524434977a2fSmrg		$ECHO "*** shared version of the library, which you do not appear to have"
524534977a2fSmrg		$ECHO "*** because the file extensions .$libext of this argument makes me believe"
524634977a2fSmrg		$ECHO "*** that it is just a static archive that I should not use here."
524734977a2fSmrg	      else
524834977a2fSmrg		$ECHO
524934977a2fSmrg		$ECHO "*** Warning: Linking the shared library $output against the"
525034977a2fSmrg		$ECHO "*** static library $deplib is not portable!"
525134977a2fSmrg		deplibs="$deplib $deplibs"
525234977a2fSmrg	      fi
525334977a2fSmrg	      ;;
525434977a2fSmrg	    esac
525534977a2fSmrg	    continue
525634977a2fSmrg	    ;;
525734977a2fSmrg	  prog)
525834977a2fSmrg	    if test "$pass" != link; then
525934977a2fSmrg	      deplibs="$deplib $deplibs"
526034977a2fSmrg	    else
526134977a2fSmrg	      compile_deplibs="$deplib $compile_deplibs"
526234977a2fSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
526334977a2fSmrg	    fi
526434977a2fSmrg	    continue
526534977a2fSmrg	    ;;
526634977a2fSmrg	  esac # linkmode
526734977a2fSmrg	  ;; # *.$libext
526834977a2fSmrg	*.lo | *.$objext)
526934977a2fSmrg	  if test "$pass" = conv; then
527034977a2fSmrg	    deplibs="$deplib $deplibs"
527134977a2fSmrg	  elif test "$linkmode" = prog; then
527234977a2fSmrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
527334977a2fSmrg	      # If there is no dlopen support or we're linking statically,
527434977a2fSmrg	      # we need to preload.
527534977a2fSmrg	      newdlprefiles="$newdlprefiles $deplib"
527634977a2fSmrg	      compile_deplibs="$deplib $compile_deplibs"
527734977a2fSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
527834977a2fSmrg	    else
527934977a2fSmrg	      newdlfiles="$newdlfiles $deplib"
528034977a2fSmrg	    fi
528134977a2fSmrg	  fi
528234977a2fSmrg	  continue
528334977a2fSmrg	  ;;
528434977a2fSmrg	%DEPLIBS%)
528534977a2fSmrg	  alldeplibs=yes
528634977a2fSmrg	  continue
528734977a2fSmrg	  ;;
528834977a2fSmrg	esac # case $deplib
528934977a2fSmrg
529034977a2fSmrg	if test "$found" = yes || test -f "$lib"; then :
529134977a2fSmrg	else
529234977a2fSmrg	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
529334977a2fSmrg	fi
529434977a2fSmrg
529534977a2fSmrg	# Check to see that this really is a libtool archive.
529634977a2fSmrg	func_lalib_unsafe_p "$lib" \
529734977a2fSmrg	  || func_fatal_error "\`$lib' is not a valid libtool archive"
529834977a2fSmrg
529934977a2fSmrg	func_dirname "$lib" "" "."
530034977a2fSmrg	ladir="$func_dirname_result"
530134977a2fSmrg
530234977a2fSmrg	dlname=
530334977a2fSmrg	dlopen=
530434977a2fSmrg	dlpreopen=
530534977a2fSmrg	libdir=
530634977a2fSmrg	library_names=
530734977a2fSmrg	old_library=
530834977a2fSmrg	inherited_linker_flags=
530934977a2fSmrg	# If the library was installed with an old release of libtool,
531034977a2fSmrg	# it will not redefine variables installed, or shouldnotlink
531134977a2fSmrg	installed=yes
531234977a2fSmrg	shouldnotlink=no
531334977a2fSmrg	avoidtemprpath=
531434977a2fSmrg
531534977a2fSmrg
531634977a2fSmrg	# Read the .la file
531734977a2fSmrg	func_source "$lib"
531834977a2fSmrg
531934977a2fSmrg	# Convert "-framework foo" to "foo.ltframework"
532034977a2fSmrg	if test -n "$inherited_linker_flags"; then
532134977a2fSmrg	  tmp_inherited_linker_flags=`$ECHO "X$inherited_linker_flags" | $Xsed -e 's/-framework \([^ $]*\)/\1.ltframework/g'`
532234977a2fSmrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
532334977a2fSmrg	    case " $new_inherited_linker_flags " in
532434977a2fSmrg	      *" $tmp_inherited_linker_flag "*) ;;
532534977a2fSmrg	      *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";;
532634977a2fSmrg	    esac
532734977a2fSmrg	  done
532834977a2fSmrg	fi
532934977a2fSmrg	dependency_libs=`$ECHO "X $dependency_libs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
533034977a2fSmrg	if test "$linkmode,$pass" = "lib,link" ||
533134977a2fSmrg	   test "$linkmode,$pass" = "prog,scan" ||
533234977a2fSmrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
533334977a2fSmrg	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
533434977a2fSmrg	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
533534977a2fSmrg	fi
533634977a2fSmrg
533734977a2fSmrg	if test "$pass" = conv; then
533834977a2fSmrg	  # Only check for convenience libraries
533934977a2fSmrg	  deplibs="$lib $deplibs"
534034977a2fSmrg	  if test -z "$libdir"; then
534134977a2fSmrg	    if test -z "$old_library"; then
534234977a2fSmrg	      func_fatal_error "cannot find name of link library for \`$lib'"
534334977a2fSmrg	    fi
534434977a2fSmrg	    # It is a libtool convenience library, so add in its objects.
534534977a2fSmrg	    convenience="$convenience $ladir/$objdir/$old_library"
534634977a2fSmrg	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
534734977a2fSmrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
534834977a2fSmrg	    func_fatal_error "\`$lib' is not a convenience library"
534934977a2fSmrg	  fi
535034977a2fSmrg	  tmp_libs=
535134977a2fSmrg	  for deplib in $dependency_libs; do
535234977a2fSmrg	    deplibs="$deplib $deplibs"
535334977a2fSmrg	    if $opt_duplicate_deps ; then
535434977a2fSmrg	      case "$tmp_libs " in
535534977a2fSmrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
535634977a2fSmrg	      esac
535734977a2fSmrg	    fi
535834977a2fSmrg	    tmp_libs="$tmp_libs $deplib"
535934977a2fSmrg	  done
536034977a2fSmrg	  continue
536134977a2fSmrg	fi # $pass = conv
536234977a2fSmrg
536334977a2fSmrg
536434977a2fSmrg	# Get the name of the library we link against.
536534977a2fSmrg	linklib=
536634977a2fSmrg	for l in $old_library $library_names; do
536734977a2fSmrg	  linklib="$l"
536834977a2fSmrg	done
536934977a2fSmrg	if test -z "$linklib"; then
537034977a2fSmrg	  func_fatal_error "cannot find name of link library for \`$lib'"
537134977a2fSmrg	fi
537234977a2fSmrg
537334977a2fSmrg	# This library was specified with -dlopen.
537434977a2fSmrg	if test "$pass" = dlopen; then
537534977a2fSmrg	  if test -z "$libdir"; then
537634977a2fSmrg	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
537734977a2fSmrg	  fi
537834977a2fSmrg	  if test -z "$dlname" ||
537934977a2fSmrg	     test "$dlopen_support" != yes ||
538034977a2fSmrg	     test "$build_libtool_libs" = no; then
538134977a2fSmrg	    # If there is no dlname, no dlopen support or we're linking
538234977a2fSmrg	    # statically, we need to preload.  We also need to preload any
538334977a2fSmrg	    # dependent libraries so libltdl's deplib preloader doesn't
538434977a2fSmrg	    # bomb out in the load deplibs phase.
538534977a2fSmrg	    dlprefiles="$dlprefiles $lib $dependency_libs"
538634977a2fSmrg	  else
538734977a2fSmrg	    newdlfiles="$newdlfiles $lib"
538834977a2fSmrg	  fi
538934977a2fSmrg	  continue
539034977a2fSmrg	fi # $pass = dlopen
539134977a2fSmrg
539234977a2fSmrg	# We need an absolute path.
539334977a2fSmrg	case $ladir in
539434977a2fSmrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
539534977a2fSmrg	*)
539634977a2fSmrg	  abs_ladir=`cd "$ladir" && pwd`
539734977a2fSmrg	  if test -z "$abs_ladir"; then
539834977a2fSmrg	    func_warning "cannot determine absolute directory name of \`$ladir'"
539934977a2fSmrg	    func_warning "passing it literally to the linker, although it might fail"
540034977a2fSmrg	    abs_ladir="$ladir"
540134977a2fSmrg	  fi
540234977a2fSmrg	  ;;
540334977a2fSmrg	esac
540434977a2fSmrg	func_basename "$lib"
540534977a2fSmrg	laname="$func_basename_result"
540634977a2fSmrg
540734977a2fSmrg	# Find the relevant object directory and library name.
540834977a2fSmrg	if test "X$installed" = Xyes; then
540934977a2fSmrg	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
541034977a2fSmrg	    func_warning "library \`$lib' was moved."
541134977a2fSmrg	    dir="$ladir"
541234977a2fSmrg	    absdir="$abs_ladir"
541334977a2fSmrg	    libdir="$abs_ladir"
541434977a2fSmrg	  else
541534977a2fSmrg	    dir="$libdir"
541634977a2fSmrg	    absdir="$libdir"
541734977a2fSmrg	  fi
541834977a2fSmrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
541934977a2fSmrg	else
542034977a2fSmrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
542134977a2fSmrg	    dir="$ladir"
542234977a2fSmrg	    absdir="$abs_ladir"
542334977a2fSmrg	    # Remove this search path later
542434977a2fSmrg	    notinst_path="$notinst_path $abs_ladir"
542534977a2fSmrg	  else
542634977a2fSmrg	    dir="$ladir/$objdir"
542734977a2fSmrg	    absdir="$abs_ladir/$objdir"
542834977a2fSmrg	    # Remove this search path later
542934977a2fSmrg	    notinst_path="$notinst_path $abs_ladir"
543034977a2fSmrg	  fi
543134977a2fSmrg	fi # $installed = yes
543234977a2fSmrg	func_stripname 'lib' '.la' "$laname"
543334977a2fSmrg	name=$func_stripname_result
543434977a2fSmrg
543534977a2fSmrg	# This library was specified with -dlpreopen.
543634977a2fSmrg	if test "$pass" = dlpreopen; then
543734977a2fSmrg	  if test -z "$libdir" && test "$linkmode" = prog; then
543834977a2fSmrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
543934977a2fSmrg	  fi
544034977a2fSmrg	  # Prefer using a static library (so that no silly _DYNAMIC symbols
544134977a2fSmrg	  # are required to link).
544234977a2fSmrg	  if test -n "$old_library"; then
544334977a2fSmrg	    newdlprefiles="$newdlprefiles $dir/$old_library"
544434977a2fSmrg	    # Keep a list of preopened convenience libraries to check
544534977a2fSmrg	    # that they are being used correctly in the link pass.
544634977a2fSmrg	    test -z "$libdir" && \
544734977a2fSmrg		dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library"
544834977a2fSmrg	  # Otherwise, use the dlname, so that lt_dlopen finds it.
544934977a2fSmrg	  elif test -n "$dlname"; then
545034977a2fSmrg	    newdlprefiles="$newdlprefiles $dir/$dlname"
545134977a2fSmrg	  else
545234977a2fSmrg	    newdlprefiles="$newdlprefiles $dir/$linklib"
545334977a2fSmrg	  fi
545434977a2fSmrg	fi # $pass = dlpreopen
545534977a2fSmrg
545634977a2fSmrg	if test -z "$libdir"; then
545734977a2fSmrg	  # Link the convenience library
545834977a2fSmrg	  if test "$linkmode" = lib; then
545934977a2fSmrg	    deplibs="$dir/$old_library $deplibs"
546034977a2fSmrg	  elif test "$linkmode,$pass" = "prog,link"; then
546134977a2fSmrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
546234977a2fSmrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
546334977a2fSmrg	  else
546434977a2fSmrg	    deplibs="$lib $deplibs" # used for prog,scan pass
546534977a2fSmrg	  fi
546634977a2fSmrg	  continue
546734977a2fSmrg	fi
546834977a2fSmrg
546934977a2fSmrg
547034977a2fSmrg	if test "$linkmode" = prog && test "$pass" != link; then
547134977a2fSmrg	  newlib_search_path="$newlib_search_path $ladir"
547234977a2fSmrg	  deplibs="$lib $deplibs"
547334977a2fSmrg
547434977a2fSmrg	  linkalldeplibs=no
547534977a2fSmrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
547634977a2fSmrg	     test "$build_libtool_libs" = no; then
547734977a2fSmrg	    linkalldeplibs=yes
547834977a2fSmrg	  fi
547934977a2fSmrg
548034977a2fSmrg	  tmp_libs=
548134977a2fSmrg	  for deplib in $dependency_libs; do
548234977a2fSmrg	    case $deplib in
548334977a2fSmrg	    -L*) func_stripname '-L' '' "$deplib"
548434977a2fSmrg	         newlib_search_path="$newlib_search_path $func_stripname_result"
548534977a2fSmrg		 ;;
548634977a2fSmrg	    esac
548734977a2fSmrg	    # Need to link against all dependency_libs?
548834977a2fSmrg	    if test "$linkalldeplibs" = yes; then
548934977a2fSmrg	      deplibs="$deplib $deplibs"
549034977a2fSmrg	    else
549134977a2fSmrg	      # Need to hardcode shared library paths
549234977a2fSmrg	      # or/and link against static libraries
549334977a2fSmrg	      newdependency_libs="$deplib $newdependency_libs"
549434977a2fSmrg	    fi
549534977a2fSmrg	    if $opt_duplicate_deps ; then
549634977a2fSmrg	      case "$tmp_libs " in
549734977a2fSmrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
549834977a2fSmrg	      esac
549934977a2fSmrg	    fi
550034977a2fSmrg	    tmp_libs="$tmp_libs $deplib"
550134977a2fSmrg	  done # for deplib
550234977a2fSmrg	  continue
550334977a2fSmrg	fi # $linkmode = prog...
550434977a2fSmrg
550534977a2fSmrg	if test "$linkmode,$pass" = "prog,link"; then
550634977a2fSmrg	  if test -n "$library_names" &&
550734977a2fSmrg	     { { test "$prefer_static_libs" = no ||
550834977a2fSmrg	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
550934977a2fSmrg	       test -z "$old_library"; }; then
551034977a2fSmrg	    # We need to hardcode the library path
551134977a2fSmrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
551234977a2fSmrg	      # Make sure the rpath contains only unique directories.
551334977a2fSmrg	      case "$temp_rpath:" in
551434977a2fSmrg	      *"$absdir:"*) ;;
551534977a2fSmrg	      *) temp_rpath="$temp_rpath$absdir:" ;;
551634977a2fSmrg	      esac
551734977a2fSmrg	    fi
551834977a2fSmrg
551934977a2fSmrg	    # Hardcode the library path.
552034977a2fSmrg	    # Skip directories that are in the system default run-time
552134977a2fSmrg	    # search path.
552234977a2fSmrg	    case " $sys_lib_dlsearch_path " in
552334977a2fSmrg	    *" $absdir "*) ;;
552434977a2fSmrg	    *)
552534977a2fSmrg	      case "$compile_rpath " in
552634977a2fSmrg	      *" $absdir "*) ;;
552734977a2fSmrg	      *) compile_rpath="$compile_rpath $absdir"
552834977a2fSmrg	      esac
552934977a2fSmrg	      ;;
553034977a2fSmrg	    esac
553134977a2fSmrg	    case " $sys_lib_dlsearch_path " in
553234977a2fSmrg	    *" $libdir "*) ;;
553334977a2fSmrg	    *)
553434977a2fSmrg	      case "$finalize_rpath " in
553534977a2fSmrg	      *" $libdir "*) ;;
553634977a2fSmrg	      *) finalize_rpath="$finalize_rpath $libdir"
553734977a2fSmrg	      esac
553834977a2fSmrg	      ;;
553934977a2fSmrg	    esac
554034977a2fSmrg	  fi # $linkmode,$pass = prog,link...
554134977a2fSmrg
554234977a2fSmrg	  if test "$alldeplibs" = yes &&
554334977a2fSmrg	     { test "$deplibs_check_method" = pass_all ||
554434977a2fSmrg	       { test "$build_libtool_libs" = yes &&
554534977a2fSmrg		 test -n "$library_names"; }; }; then
554634977a2fSmrg	    # We only need to search for static libraries
554734977a2fSmrg	    continue
554834977a2fSmrg	  fi
554934977a2fSmrg	fi
555034977a2fSmrg
555134977a2fSmrg	link_static=no # Whether the deplib will be linked statically
555234977a2fSmrg	use_static_libs=$prefer_static_libs
555334977a2fSmrg	if test "$use_static_libs" = built && test "$installed" = yes; then
555434977a2fSmrg	  use_static_libs=no
555534977a2fSmrg	fi
555634977a2fSmrg	if test -n "$library_names" &&
555734977a2fSmrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
555834977a2fSmrg	  case $host in
555934977a2fSmrg	  *cygwin* | *mingw* | *cegcc*)
556034977a2fSmrg	      # No point in relinking DLLs because paths are not encoded
556134977a2fSmrg	      notinst_deplibs="$notinst_deplibs $lib"
556234977a2fSmrg	      need_relink=no
556334977a2fSmrg	    ;;
556434977a2fSmrg	  *)
556534977a2fSmrg	    if test "$installed" = no; then
556634977a2fSmrg	      notinst_deplibs="$notinst_deplibs $lib"
556734977a2fSmrg	      need_relink=yes
556834977a2fSmrg	    fi
556934977a2fSmrg	    ;;
557034977a2fSmrg	  esac
557134977a2fSmrg	  # This is a shared library
557234977a2fSmrg
557334977a2fSmrg	  # Warn about portability, can't link against -module's on some
557434977a2fSmrg	  # systems (darwin).  Don't bleat about dlopened modules though!
557534977a2fSmrg	  dlopenmodule=""
557634977a2fSmrg	  for dlpremoduletest in $dlprefiles; do
557734977a2fSmrg	    if test "X$dlpremoduletest" = "X$lib"; then
557834977a2fSmrg	      dlopenmodule="$dlpremoduletest"
557934977a2fSmrg	      break
558034977a2fSmrg	    fi
558134977a2fSmrg	  done
558234977a2fSmrg	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
558334977a2fSmrg	    $ECHO
558434977a2fSmrg	    if test "$linkmode" = prog; then
558534977a2fSmrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
558634977a2fSmrg	    else
558734977a2fSmrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
558834977a2fSmrg	    fi
558934977a2fSmrg	    $ECHO "*** $linklib is not portable!"
559034977a2fSmrg	  fi
559134977a2fSmrg	  if test "$linkmode" = lib &&
559234977a2fSmrg	     test "$hardcode_into_libs" = yes; then
559334977a2fSmrg	    # Hardcode the library path.
559434977a2fSmrg	    # Skip directories that are in the system default run-time
559534977a2fSmrg	    # search path.
559634977a2fSmrg	    case " $sys_lib_dlsearch_path " in
559734977a2fSmrg	    *" $absdir "*) ;;
559834977a2fSmrg	    *)
559934977a2fSmrg	      case "$compile_rpath " in
560034977a2fSmrg	      *" $absdir "*) ;;
560134977a2fSmrg	      *) compile_rpath="$compile_rpath $absdir"
560234977a2fSmrg	      esac
560334977a2fSmrg	      ;;
560434977a2fSmrg	    esac
560534977a2fSmrg	    case " $sys_lib_dlsearch_path " in
560634977a2fSmrg	    *" $libdir "*) ;;
560734977a2fSmrg	    *)
560834977a2fSmrg	      case "$finalize_rpath " in
560934977a2fSmrg	      *" $libdir "*) ;;
561034977a2fSmrg	      *) finalize_rpath="$finalize_rpath $libdir"
561134977a2fSmrg	      esac
561234977a2fSmrg	      ;;
561334977a2fSmrg	    esac
561434977a2fSmrg	  fi
561534977a2fSmrg
561634977a2fSmrg	  if test -n "$old_archive_from_expsyms_cmds"; then
561734977a2fSmrg	    # figure out the soname
561834977a2fSmrg	    set dummy $library_names
561934977a2fSmrg	    shift
562034977a2fSmrg	    realname="$1"
562134977a2fSmrg	    shift
562234977a2fSmrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
562334977a2fSmrg	    # use dlname if we got it. it's perfectly good, no?
562434977a2fSmrg	    if test -n "$dlname"; then
562534977a2fSmrg	      soname="$dlname"
562634977a2fSmrg	    elif test -n "$soname_spec"; then
562734977a2fSmrg	      # bleh windows
562834977a2fSmrg	      case $host in
562934977a2fSmrg	      *cygwin* | mingw* | *cegcc*)
563034977a2fSmrg	        func_arith $current - $age
563134977a2fSmrg		major=$func_arith_result
563234977a2fSmrg		versuffix="-$major"
563334977a2fSmrg		;;
563434977a2fSmrg	      esac
563534977a2fSmrg	      eval soname=\"$soname_spec\"
563634977a2fSmrg	    else
563734977a2fSmrg	      soname="$realname"
563834977a2fSmrg	    fi
563934977a2fSmrg
564034977a2fSmrg	    # Make a new name for the extract_expsyms_cmds to use
564134977a2fSmrg	    soroot="$soname"
564234977a2fSmrg	    func_basename "$soroot"
564334977a2fSmrg	    soname="$func_basename_result"
564434977a2fSmrg	    func_stripname 'lib' '.dll' "$soname"
564534977a2fSmrg	    newlib=libimp-$func_stripname_result.a
564634977a2fSmrg
564734977a2fSmrg	    # If the library has no export list, then create one now
564834977a2fSmrg	    if test -f "$output_objdir/$soname-def"; then :
564934977a2fSmrg	    else
565034977a2fSmrg	      func_verbose "extracting exported symbol list from \`$soname'"
565134977a2fSmrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
565234977a2fSmrg	    fi
565334977a2fSmrg
565434977a2fSmrg	    # Create $newlib
565534977a2fSmrg	    if test -f "$output_objdir/$newlib"; then :; else
565634977a2fSmrg	      func_verbose "generating import library for \`$soname'"
565734977a2fSmrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
565834977a2fSmrg	    fi
565934977a2fSmrg	    # make sure the library variables are pointing to the new library
566034977a2fSmrg	    dir=$output_objdir
566134977a2fSmrg	    linklib=$newlib
566234977a2fSmrg	  fi # test -n "$old_archive_from_expsyms_cmds"
566334977a2fSmrg
566434977a2fSmrg	  if test "$linkmode" = prog || test "$mode" != relink; then
566534977a2fSmrg	    add_shlibpath=
566634977a2fSmrg	    add_dir=
566734977a2fSmrg	    add=
566834977a2fSmrg	    lib_linked=yes
566934977a2fSmrg	    case $hardcode_action in
567034977a2fSmrg	    immediate | unsupported)
567134977a2fSmrg	      if test "$hardcode_direct" = no; then
567234977a2fSmrg		add="$dir/$linklib"
567334977a2fSmrg		case $host in
567434977a2fSmrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
567534977a2fSmrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
567634977a2fSmrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
567734977a2fSmrg		    *-*-unixware7*) add_dir="-L$dir" ;;
567834977a2fSmrg		  *-*-darwin* )
567934977a2fSmrg		    # if the lib is a (non-dlopened) module then we can not
568034977a2fSmrg		    # link against it, someone is ignoring the earlier warnings
568134977a2fSmrg		    if /usr/bin/file -L $add 2> /dev/null |
568234977a2fSmrg			 $GREP ": [^:]* bundle" >/dev/null ; then
568334977a2fSmrg		      if test "X$dlopenmodule" != "X$lib"; then
568434977a2fSmrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
568534977a2fSmrg			if test -z "$old_library" ; then
568634977a2fSmrg			  $ECHO
568734977a2fSmrg			  $ECHO "*** And there doesn't seem to be a static archive available"
568834977a2fSmrg			  $ECHO "*** The link will probably fail, sorry"
568934977a2fSmrg			else
569034977a2fSmrg			  add="$dir/$old_library"
569134977a2fSmrg			fi
569234977a2fSmrg		      elif test -n "$old_library"; then
569334977a2fSmrg			add="$dir/$old_library"
569434977a2fSmrg		      fi
569534977a2fSmrg		    fi
569634977a2fSmrg		esac
569734977a2fSmrg	      elif test "$hardcode_minus_L" = no; then
569834977a2fSmrg		case $host in
569934977a2fSmrg		*-*-sunos*) add_shlibpath="$dir" ;;
570034977a2fSmrg		esac
570134977a2fSmrg		add_dir="-L$dir"
570234977a2fSmrg		add="-l$name"
570334977a2fSmrg	      elif test "$hardcode_shlibpath_var" = no; then
570434977a2fSmrg		add_shlibpath="$dir"
570534977a2fSmrg		add="-l$name"
570634977a2fSmrg	      else
570734977a2fSmrg		lib_linked=no
570834977a2fSmrg	      fi
570934977a2fSmrg	      ;;
571034977a2fSmrg	    relink)
571134977a2fSmrg	      if test "$hardcode_direct" = yes &&
571234977a2fSmrg	         test "$hardcode_direct_absolute" = no; then
571334977a2fSmrg		add="$dir/$linklib"
571434977a2fSmrg	      elif test "$hardcode_minus_L" = yes; then
571534977a2fSmrg		add_dir="-L$dir"
571634977a2fSmrg		# Try looking first in the location we're being installed to.
571734977a2fSmrg		if test -n "$inst_prefix_dir"; then
571834977a2fSmrg		  case $libdir in
571934977a2fSmrg		    [\\/]*)
572034977a2fSmrg		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
572134977a2fSmrg		      ;;
572234977a2fSmrg		  esac
572334977a2fSmrg		fi
572434977a2fSmrg		add="-l$name"
572534977a2fSmrg	      elif test "$hardcode_shlibpath_var" = yes; then
572634977a2fSmrg		add_shlibpath="$dir"
572734977a2fSmrg		add="-l$name"
572834977a2fSmrg	      else
572934977a2fSmrg		lib_linked=no
573034977a2fSmrg	      fi
573134977a2fSmrg	      ;;
573234977a2fSmrg	    *) lib_linked=no ;;
573334977a2fSmrg	    esac
573434977a2fSmrg
573534977a2fSmrg	    if test "$lib_linked" != yes; then
573634977a2fSmrg	      func_fatal_configuration "unsupported hardcode properties"
573734977a2fSmrg	    fi
573834977a2fSmrg
573934977a2fSmrg	    if test -n "$add_shlibpath"; then
574034977a2fSmrg	      case :$compile_shlibpath: in
574134977a2fSmrg	      *":$add_shlibpath:"*) ;;
574234977a2fSmrg	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
574334977a2fSmrg	      esac
574434977a2fSmrg	    fi
574534977a2fSmrg	    if test "$linkmode" = prog; then
574634977a2fSmrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
574734977a2fSmrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
574834977a2fSmrg	    else
574934977a2fSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
575034977a2fSmrg	      test -n "$add" && deplibs="$add $deplibs"
575134977a2fSmrg	      if test "$hardcode_direct" != yes &&
575234977a2fSmrg		 test "$hardcode_minus_L" != yes &&
575334977a2fSmrg		 test "$hardcode_shlibpath_var" = yes; then
575434977a2fSmrg		case :$finalize_shlibpath: in
575534977a2fSmrg		*":$libdir:"*) ;;
575634977a2fSmrg		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
575734977a2fSmrg		esac
575834977a2fSmrg	      fi
575934977a2fSmrg	    fi
576034977a2fSmrg	  fi
576134977a2fSmrg
576234977a2fSmrg	  if test "$linkmode" = prog || test "$mode" = relink; then
576334977a2fSmrg	    add_shlibpath=
576434977a2fSmrg	    add_dir=
576534977a2fSmrg	    add=
576634977a2fSmrg	    # Finalize command for both is simple: just hardcode it.
576734977a2fSmrg	    if test "$hardcode_direct" = yes &&
576834977a2fSmrg	       test "$hardcode_direct_absolute" = no; then
576934977a2fSmrg	      add="$libdir/$linklib"
577034977a2fSmrg	    elif test "$hardcode_minus_L" = yes; then
577134977a2fSmrg	      add_dir="-L$libdir"
577234977a2fSmrg	      add="-l$name"
577334977a2fSmrg	    elif test "$hardcode_shlibpath_var" = yes; then
577434977a2fSmrg	      case :$finalize_shlibpath: in
577534977a2fSmrg	      *":$libdir:"*) ;;
577634977a2fSmrg	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
577734977a2fSmrg	      esac
577834977a2fSmrg	      add="-l$name"
577934977a2fSmrg	    elif test "$hardcode_automatic" = yes; then
578034977a2fSmrg	      if test -n "$inst_prefix_dir" &&
578134977a2fSmrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
578234977a2fSmrg		add="$inst_prefix_dir$libdir/$linklib"
578334977a2fSmrg	      else
578434977a2fSmrg		add="$libdir/$linklib"
578534977a2fSmrg	      fi
578634977a2fSmrg	    else
578734977a2fSmrg	      # We cannot seem to hardcode it, guess we'll fake it.
578834977a2fSmrg	      add_dir="-L$libdir"
578934977a2fSmrg	      # Try looking first in the location we're being installed to.
579034977a2fSmrg	      if test -n "$inst_prefix_dir"; then
579134977a2fSmrg		case $libdir in
579234977a2fSmrg		  [\\/]*)
579334977a2fSmrg		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
579434977a2fSmrg		    ;;
579534977a2fSmrg		esac
579634977a2fSmrg	      fi
579734977a2fSmrg	      add="-l$name"
579834977a2fSmrg	    fi
579934977a2fSmrg
580034977a2fSmrg	    if test "$linkmode" = prog; then
580134977a2fSmrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
580234977a2fSmrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
580334977a2fSmrg	    else
580434977a2fSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
580534977a2fSmrg	      test -n "$add" && deplibs="$add $deplibs"
580634977a2fSmrg	    fi
580734977a2fSmrg	  fi
580834977a2fSmrg	elif test "$linkmode" = prog; then
580934977a2fSmrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
581034977a2fSmrg	  # is not unsupported.  This is valid on all known static and
581134977a2fSmrg	  # shared platforms.
581234977a2fSmrg	  if test "$hardcode_direct" != unsupported; then
581334977a2fSmrg	    test -n "$old_library" && linklib="$old_library"
581434977a2fSmrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
581534977a2fSmrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
581634977a2fSmrg	  else
581734977a2fSmrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
581834977a2fSmrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
581934977a2fSmrg	  fi
582034977a2fSmrg	elif test "$build_libtool_libs" = yes; then
582134977a2fSmrg	  # Not a shared library
582234977a2fSmrg	  if test "$deplibs_check_method" != pass_all; then
582334977a2fSmrg	    # We're trying link a shared library against a static one
582434977a2fSmrg	    # but the system doesn't support it.
582534977a2fSmrg
582634977a2fSmrg	    # Just print a warning and add the library to dependency_libs so
582734977a2fSmrg	    # that the program can be linked against the static library.
582834977a2fSmrg	    $ECHO
582934977a2fSmrg	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
583034977a2fSmrg	    $ECHO "*** I have the capability to make that library automatically link in when"
583134977a2fSmrg	    $ECHO "*** you link to this library.  But I can only do this if you have a"
583234977a2fSmrg	    $ECHO "*** shared version of the library, which you do not appear to have."
583334977a2fSmrg	    if test "$module" = yes; then
583434977a2fSmrg	      $ECHO "*** But as you try to build a module library, libtool will still create "
583534977a2fSmrg	      $ECHO "*** a static module, that should work as long as the dlopening application"
583634977a2fSmrg	      $ECHO "*** is linked with the -dlopen flag to resolve symbols at runtime."
583734977a2fSmrg	      if test -z "$global_symbol_pipe"; then
583834977a2fSmrg		$ECHO
583934977a2fSmrg		$ECHO "*** However, this would only work if libtool was able to extract symbol"
584034977a2fSmrg		$ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
584134977a2fSmrg		$ECHO "*** not find such a program.  So, this module is probably useless."
584234977a2fSmrg		$ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
584334977a2fSmrg	      fi
584434977a2fSmrg	      if test "$build_old_libs" = no; then
584534977a2fSmrg		build_libtool_libs=module
584634977a2fSmrg		build_old_libs=yes
584734977a2fSmrg	      else
584834977a2fSmrg		build_libtool_libs=no
584934977a2fSmrg	      fi
585034977a2fSmrg	    fi
585134977a2fSmrg	  else
585234977a2fSmrg	    deplibs="$dir/$old_library $deplibs"
585334977a2fSmrg	    link_static=yes
585434977a2fSmrg	  fi
585534977a2fSmrg	fi # link shared/static library?
585634977a2fSmrg
585734977a2fSmrg	if test "$linkmode" = lib; then
585834977a2fSmrg	  if test -n "$dependency_libs" &&
585934977a2fSmrg	     { test "$hardcode_into_libs" != yes ||
586034977a2fSmrg	       test "$build_old_libs" = yes ||
586134977a2fSmrg	       test "$link_static" = yes; }; then
586234977a2fSmrg	    # Extract -R from dependency_libs
586334977a2fSmrg	    temp_deplibs=
586434977a2fSmrg	    for libdir in $dependency_libs; do
586534977a2fSmrg	      case $libdir in
586634977a2fSmrg	      -R*) func_stripname '-R' '' "$libdir"
586734977a2fSmrg	           temp_xrpath=$func_stripname_result
586834977a2fSmrg		   case " $xrpath " in
586934977a2fSmrg		   *" $temp_xrpath "*) ;;
587034977a2fSmrg		   *) xrpath="$xrpath $temp_xrpath";;
587134977a2fSmrg		   esac;;
587234977a2fSmrg	      *) temp_deplibs="$temp_deplibs $libdir";;
587334977a2fSmrg	      esac
587434977a2fSmrg	    done
587534977a2fSmrg	    dependency_libs="$temp_deplibs"
587634977a2fSmrg	  fi
587734977a2fSmrg
587834977a2fSmrg	  newlib_search_path="$newlib_search_path $absdir"
587934977a2fSmrg	  # Link against this library
588034977a2fSmrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
588134977a2fSmrg	  # ... and its dependency_libs
588234977a2fSmrg	  tmp_libs=
588334977a2fSmrg	  for deplib in $dependency_libs; do
588434977a2fSmrg	    newdependency_libs="$deplib $newdependency_libs"
588534977a2fSmrg	    if $opt_duplicate_deps ; then
588634977a2fSmrg	      case "$tmp_libs " in
588734977a2fSmrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
588834977a2fSmrg	      esac
588934977a2fSmrg	    fi
589034977a2fSmrg	    tmp_libs="$tmp_libs $deplib"
589134977a2fSmrg	  done
589234977a2fSmrg
589334977a2fSmrg	  if test "$link_all_deplibs" != no; then
589434977a2fSmrg	    # Add the search paths of all dependency libraries
589534977a2fSmrg	    for deplib in $dependency_libs; do
589634977a2fSmrg	      case $deplib in
589734977a2fSmrg	      -L*) path="$deplib" ;;
589834977a2fSmrg	      *.la)
589934977a2fSmrg	        func_dirname "$deplib" "" "."
590034977a2fSmrg		dir="$func_dirname_result"
590134977a2fSmrg		# We need an absolute path.
590234977a2fSmrg		case $dir in
590334977a2fSmrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
590434977a2fSmrg		*)
590534977a2fSmrg		  absdir=`cd "$dir" && pwd`
590634977a2fSmrg		  if test -z "$absdir"; then
590734977a2fSmrg		    func_warning "cannot determine absolute directory name of \`$dir'"
590834977a2fSmrg		    absdir="$dir"
590934977a2fSmrg		  fi
591034977a2fSmrg		  ;;
591134977a2fSmrg		esac
591234977a2fSmrg		if $GREP "^installed=no" $deplib > /dev/null; then
591334977a2fSmrg		case $host in
591434977a2fSmrg		*-*-darwin*)
591534977a2fSmrg		  depdepl=
591634977a2fSmrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
591734977a2fSmrg		  if test -n "$deplibrary_names" ; then
591834977a2fSmrg		    for tmp in $deplibrary_names ; do
591934977a2fSmrg		      depdepl=$tmp
592034977a2fSmrg		    done
592134977a2fSmrg		    if test -f "$absdir/$objdir/$depdepl" ; then
592234977a2fSmrg		      depdepl="$absdir/$objdir/$depdepl"
592334977a2fSmrg		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
592434977a2fSmrg                      if test -z "$darwin_install_name"; then
592534977a2fSmrg                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
592634977a2fSmrg                      fi
592734977a2fSmrg		      compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
592834977a2fSmrg		      linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}"
592934977a2fSmrg		      path=
593034977a2fSmrg		    fi
593134977a2fSmrg		  fi
593234977a2fSmrg		  ;;
593334977a2fSmrg		*)
593434977a2fSmrg		  path="-L$absdir/$objdir"
593534977a2fSmrg		  ;;
593634977a2fSmrg		esac
593734977a2fSmrg		else
593834977a2fSmrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
593934977a2fSmrg		  test -z "$libdir" && \
594034977a2fSmrg		    func_fatal_error "\`$deplib' is not a valid libtool archive"
594134977a2fSmrg		  test "$absdir" != "$libdir" && \
594234977a2fSmrg		    func_warning "\`$deplib' seems to be moved"
594334977a2fSmrg
594434977a2fSmrg		  path="-L$absdir"
594534977a2fSmrg		fi
594634977a2fSmrg		;;
594734977a2fSmrg	      esac
594834977a2fSmrg	      case " $deplibs " in
594934977a2fSmrg	      *" $path "*) ;;
595034977a2fSmrg	      *) deplibs="$path $deplibs" ;;
595134977a2fSmrg	      esac
595234977a2fSmrg	    done
595334977a2fSmrg	  fi # link_all_deplibs != no
595434977a2fSmrg	fi # linkmode = lib
595534977a2fSmrg      done # for deplib in $libs
595634977a2fSmrg      if test "$pass" = link; then
595734977a2fSmrg	if test "$linkmode" = "prog"; then
595834977a2fSmrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
595934977a2fSmrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
596034977a2fSmrg	else
596134977a2fSmrg	  compiler_flags="$compiler_flags "`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
596234977a2fSmrg	fi
596334977a2fSmrg      fi
596434977a2fSmrg      dependency_libs="$newdependency_libs"
596534977a2fSmrg      if test "$pass" = dlpreopen; then
596634977a2fSmrg	# Link the dlpreopened libraries before other libraries
596734977a2fSmrg	for deplib in $save_deplibs; do
596834977a2fSmrg	  deplibs="$deplib $deplibs"
596934977a2fSmrg	done
597034977a2fSmrg      fi
597134977a2fSmrg      if test "$pass" != dlopen; then
597234977a2fSmrg	if test "$pass" != conv; then
597334977a2fSmrg	  # Make sure lib_search_path contains only unique directories.
597434977a2fSmrg	  lib_search_path=
597534977a2fSmrg	  for dir in $newlib_search_path; do
597634977a2fSmrg	    case "$lib_search_path " in
597734977a2fSmrg	    *" $dir "*) ;;
597834977a2fSmrg	    *) lib_search_path="$lib_search_path $dir" ;;
597934977a2fSmrg	    esac
598034977a2fSmrg	  done
598134977a2fSmrg	  newlib_search_path=
598234977a2fSmrg	fi
598334977a2fSmrg
598434977a2fSmrg	if test "$linkmode,$pass" != "prog,link"; then
598534977a2fSmrg	  vars="deplibs"
598634977a2fSmrg	else
598734977a2fSmrg	  vars="compile_deplibs finalize_deplibs"
598834977a2fSmrg	fi
598934977a2fSmrg	for var in $vars dependency_libs; do
599034977a2fSmrg	  # Add libraries to $var in reverse order
599134977a2fSmrg	  eval tmp_libs=\"\$$var\"
599234977a2fSmrg	  new_libs=
599334977a2fSmrg	  for deplib in $tmp_libs; do
599434977a2fSmrg	    # FIXME: Pedantically, this is the right thing to do, so
599534977a2fSmrg	    #        that some nasty dependency loop isn't accidentally
599634977a2fSmrg	    #        broken:
599734977a2fSmrg	    #new_libs="$deplib $new_libs"
599834977a2fSmrg	    # Pragmatically, this seems to cause very few problems in
599934977a2fSmrg	    # practice:
600034977a2fSmrg	    case $deplib in
600134977a2fSmrg	    -L*) new_libs="$deplib $new_libs" ;;
600234977a2fSmrg	    -R*) ;;
600334977a2fSmrg	    *)
600434977a2fSmrg	      # And here is the reason: when a library appears more
600534977a2fSmrg	      # than once as an explicit dependence of a library, or
600634977a2fSmrg	      # is implicitly linked in more than once by the
600734977a2fSmrg	      # compiler, it is considered special, and multiple
600834977a2fSmrg	      # occurrences thereof are not removed.  Compare this
600934977a2fSmrg	      # with having the same library being listed as a
601034977a2fSmrg	      # dependency of multiple other libraries: in this case,
601134977a2fSmrg	      # we know (pedantically, we assume) the library does not
601234977a2fSmrg	      # need to be listed more than once, so we keep only the
601334977a2fSmrg	      # last copy.  This is not always right, but it is rare
601434977a2fSmrg	      # enough that we require users that really mean to play
601534977a2fSmrg	      # such unportable linking tricks to link the library
601634977a2fSmrg	      # using -Wl,-lname, so that libtool does not consider it
601734977a2fSmrg	      # for duplicate removal.
601834977a2fSmrg	      case " $specialdeplibs " in
601934977a2fSmrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
602034977a2fSmrg	      *)
602134977a2fSmrg		case " $new_libs " in
602234977a2fSmrg		*" $deplib "*) ;;
602334977a2fSmrg		*) new_libs="$deplib $new_libs" ;;
602434977a2fSmrg		esac
602534977a2fSmrg		;;
602634977a2fSmrg	      esac
602734977a2fSmrg	      ;;
602834977a2fSmrg	    esac
602934977a2fSmrg	  done
603034977a2fSmrg	  tmp_libs=
603134977a2fSmrg	  for deplib in $new_libs; do
603234977a2fSmrg	    case $deplib in
603334977a2fSmrg	    -L*)
603434977a2fSmrg	      case " $tmp_libs " in
603534977a2fSmrg	      *" $deplib "*) ;;
603634977a2fSmrg	      *) tmp_libs="$tmp_libs $deplib" ;;
603734977a2fSmrg	      esac
603834977a2fSmrg	      ;;
603934977a2fSmrg	    *) tmp_libs="$tmp_libs $deplib" ;;
604034977a2fSmrg	    esac
604134977a2fSmrg	  done
604234977a2fSmrg	  eval $var=\"$tmp_libs\"
604334977a2fSmrg	done # for var
604434977a2fSmrg      fi
604534977a2fSmrg      # Last step: remove runtime libs from dependency_libs
604634977a2fSmrg      # (they stay in deplibs)
604734977a2fSmrg      tmp_libs=
604834977a2fSmrg      for i in $dependency_libs ; do
604934977a2fSmrg	case " $predeps $postdeps $compiler_lib_search_path " in
605034977a2fSmrg	*" $i "*)
605134977a2fSmrg	  i=""
605234977a2fSmrg	  ;;
605334977a2fSmrg	esac
605434977a2fSmrg	if test -n "$i" ; then
605534977a2fSmrg	  tmp_libs="$tmp_libs $i"
605634977a2fSmrg	fi
605734977a2fSmrg      done
605834977a2fSmrg      dependency_libs=$tmp_libs
605934977a2fSmrg    done # for pass
606034977a2fSmrg    if test "$linkmode" = prog; then
606134977a2fSmrg      dlfiles="$newdlfiles"
606234977a2fSmrg    fi
606334977a2fSmrg    if test "$linkmode" = prog || test "$linkmode" = lib; then
606434977a2fSmrg      dlprefiles="$newdlprefiles"
606534977a2fSmrg    fi
606634977a2fSmrg
606734977a2fSmrg    case $linkmode in
606834977a2fSmrg    oldlib)
606934977a2fSmrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
607034977a2fSmrg	func_warning "\`-dlopen' is ignored for archives"
607134977a2fSmrg      fi
607234977a2fSmrg
607334977a2fSmrg      case " $deplibs" in
607434977a2fSmrg      *\ -l* | *\ -L*)
607534977a2fSmrg	func_warning "\`-l' and \`-L' are ignored for archives" ;;
607634977a2fSmrg      esac
607734977a2fSmrg
607834977a2fSmrg      test -n "$rpath" && \
607934977a2fSmrg	func_warning "\`-rpath' is ignored for archives"
608034977a2fSmrg
608134977a2fSmrg      test -n "$xrpath" && \
608234977a2fSmrg	func_warning "\`-R' is ignored for archives"
608334977a2fSmrg
608434977a2fSmrg      test -n "$vinfo" && \
608534977a2fSmrg	func_warning "\`-version-info/-version-number' is ignored for archives"
608634977a2fSmrg
608734977a2fSmrg      test -n "$release" && \
608834977a2fSmrg	func_warning "\`-release' is ignored for archives"
608934977a2fSmrg
609034977a2fSmrg      test -n "$export_symbols$export_symbols_regex" && \
609134977a2fSmrg	func_warning "\`-export-symbols' is ignored for archives"
609234977a2fSmrg
609334977a2fSmrg      # Now set the variables for building old libraries.
609434977a2fSmrg      build_libtool_libs=no
609534977a2fSmrg      oldlibs="$output"
609634977a2fSmrg      objs="$objs$old_deplibs"
609734977a2fSmrg      ;;
609834977a2fSmrg
609934977a2fSmrg    lib)
610034977a2fSmrg      # Make sure we only generate libraries of the form `libNAME.la'.
610134977a2fSmrg      case $outputname in
610234977a2fSmrg      lib*)
610334977a2fSmrg	func_stripname 'lib' '.la' "$outputname"
610434977a2fSmrg	name=$func_stripname_result
610534977a2fSmrg	eval shared_ext=\"$shrext_cmds\"
610634977a2fSmrg	eval libname=\"$libname_spec\"
610734977a2fSmrg	;;
610834977a2fSmrg      *)
610934977a2fSmrg	test "$module" = no && \
611034977a2fSmrg	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
611134977a2fSmrg
611234977a2fSmrg	if test "$need_lib_prefix" != no; then
611334977a2fSmrg	  # Add the "lib" prefix for modules if required
611434977a2fSmrg	  func_stripname '' '.la' "$outputname"
611534977a2fSmrg	  name=$func_stripname_result
611634977a2fSmrg	  eval shared_ext=\"$shrext_cmds\"
611734977a2fSmrg	  eval libname=\"$libname_spec\"
611834977a2fSmrg	else
611934977a2fSmrg	  func_stripname '' '.la' "$outputname"
612034977a2fSmrg	  libname=$func_stripname_result
612134977a2fSmrg	fi
612234977a2fSmrg	;;
612334977a2fSmrg      esac
612434977a2fSmrg
612534977a2fSmrg      if test -n "$objs"; then
612634977a2fSmrg	if test "$deplibs_check_method" != pass_all; then
612734977a2fSmrg	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
612834977a2fSmrg	else
612934977a2fSmrg	  $ECHO
613034977a2fSmrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
613134977a2fSmrg	  $ECHO "*** objects $objs is not portable!"
613234977a2fSmrg	  libobjs="$libobjs $objs"
613334977a2fSmrg	fi
613434977a2fSmrg      fi
613534977a2fSmrg
613634977a2fSmrg      test "$dlself" != no && \
613734977a2fSmrg	func_warning "\`-dlopen self' is ignored for libtool libraries"
613834977a2fSmrg
613934977a2fSmrg      set dummy $rpath
614034977a2fSmrg      shift
614134977a2fSmrg      test "$#" -gt 1 && \
614234977a2fSmrg	func_warning "ignoring multiple \`-rpath's for a libtool library"
614334977a2fSmrg
614434977a2fSmrg      install_libdir="$1"
614534977a2fSmrg
614634977a2fSmrg      oldlibs=
614734977a2fSmrg      if test -z "$rpath"; then
614834977a2fSmrg	if test "$build_libtool_libs" = yes; then
614934977a2fSmrg	  # Building a libtool convenience library.
615034977a2fSmrg	  # Some compilers have problems with a `.al' extension so
615134977a2fSmrg	  # convenience libraries should have the same extension an
615234977a2fSmrg	  # archive normally would.
615334977a2fSmrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
615434977a2fSmrg	  build_libtool_libs=convenience
615534977a2fSmrg	  build_old_libs=yes
615634977a2fSmrg	fi
615734977a2fSmrg
615834977a2fSmrg	test -n "$vinfo" && \
615934977a2fSmrg	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
616034977a2fSmrg
616134977a2fSmrg	test -n "$release" && \
616234977a2fSmrg	  func_warning "\`-release' is ignored for convenience libraries"
616334977a2fSmrg      else
616434977a2fSmrg
616534977a2fSmrg	# Parse the version information argument.
616634977a2fSmrg	save_ifs="$IFS"; IFS=':'
616734977a2fSmrg	set dummy $vinfo 0 0 0
616834977a2fSmrg	shift
616934977a2fSmrg	IFS="$save_ifs"
617034977a2fSmrg
617134977a2fSmrg	test -n "$7" && \
617234977a2fSmrg	  func_fatal_help "too many parameters to \`-version-info'"
617334977a2fSmrg
617434977a2fSmrg	# convert absolute version numbers to libtool ages
617534977a2fSmrg	# this retains compatibility with .la files and attempts
617634977a2fSmrg	# to make the code below a bit more comprehensible
617734977a2fSmrg
617834977a2fSmrg	case $vinfo_number in
617934977a2fSmrg	yes)
618034977a2fSmrg	  number_major="$1"
618134977a2fSmrg	  number_minor="$2"
618234977a2fSmrg	  number_revision="$3"
618334977a2fSmrg	  #
618434977a2fSmrg	  # There are really only two kinds -- those that
618534977a2fSmrg	  # use the current revision as the major version
618634977a2fSmrg	  # and those that subtract age and use age as
618734977a2fSmrg	  # a minor version.  But, then there is irix
618834977a2fSmrg	  # which has an extra 1 added just for fun
618934977a2fSmrg	  #
619034977a2fSmrg	  case $version_type in
619134977a2fSmrg	  darwin|linux|osf|windows|none)
619234977a2fSmrg	    func_arith $number_major + $number_minor
619334977a2fSmrg	    current=$func_arith_result
619434977a2fSmrg	    age="$number_minor"
619534977a2fSmrg	    revision="$number_revision"
619634977a2fSmrg	    ;;
619734977a2fSmrg	  freebsd-aout|freebsd-elf|sunos)
619834977a2fSmrg	    current="$number_major"
619934977a2fSmrg	    revision="$number_minor"
620034977a2fSmrg	    age="0"
620134977a2fSmrg	    ;;
620234977a2fSmrg	  irix|nonstopux)
620334977a2fSmrg	    func_arith $number_major + $number_minor
620434977a2fSmrg	    current=$func_arith_result
620534977a2fSmrg	    age="$number_minor"
620634977a2fSmrg	    revision="$number_minor"
620734977a2fSmrg	    lt_irix_increment=no
620834977a2fSmrg	    ;;
620934977a2fSmrg	  esac
621034977a2fSmrg	  ;;
621134977a2fSmrg	no)
621234977a2fSmrg	  current="$1"
621334977a2fSmrg	  revision="$2"
621434977a2fSmrg	  age="$3"
621534977a2fSmrg	  ;;
621634977a2fSmrg	esac
621734977a2fSmrg
621834977a2fSmrg	# Check that each of the things are valid numbers.
621934977a2fSmrg	case $current in
622034977a2fSmrg	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]) ;;
622134977a2fSmrg	*)
622234977a2fSmrg	  func_error "CURRENT \`$current' must be a nonnegative integer"
622334977a2fSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
622434977a2fSmrg	  ;;
622534977a2fSmrg	esac
622634977a2fSmrg
622734977a2fSmrg	case $revision in
622834977a2fSmrg	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]) ;;
622934977a2fSmrg	*)
623034977a2fSmrg	  func_error "REVISION \`$revision' must be a nonnegative integer"
623134977a2fSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
623234977a2fSmrg	  ;;
623334977a2fSmrg	esac
623434977a2fSmrg
623534977a2fSmrg	case $age in
623634977a2fSmrg	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]) ;;
623734977a2fSmrg	*)
623834977a2fSmrg	  func_error "AGE \`$age' must be a nonnegative integer"
623934977a2fSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
624034977a2fSmrg	  ;;
624134977a2fSmrg	esac
624234977a2fSmrg
624334977a2fSmrg	if test "$age" -gt "$current"; then
624434977a2fSmrg	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
624534977a2fSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
624634977a2fSmrg	fi
624734977a2fSmrg
624834977a2fSmrg	# Calculate the version variables.
624934977a2fSmrg	major=
625034977a2fSmrg	versuffix=
625134977a2fSmrg	verstring=
625234977a2fSmrg	case $version_type in
625334977a2fSmrg	none) ;;
625434977a2fSmrg
625534977a2fSmrg	darwin)
625634977a2fSmrg	  # Like Linux, but with the current version available in
625734977a2fSmrg	  # verstring for coding it into the library header
625834977a2fSmrg	  func_arith $current - $age
625934977a2fSmrg	  major=.$func_arith_result
626034977a2fSmrg	  versuffix="$major.$age.$revision"
626134977a2fSmrg	  # Darwin ld doesn't like 0 for these options...
626234977a2fSmrg	  func_arith $current + 1
626334977a2fSmrg	  minor_current=$func_arith_result
626434977a2fSmrg	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
626534977a2fSmrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
626634977a2fSmrg	  ;;
626734977a2fSmrg
626834977a2fSmrg	freebsd-aout)
626934977a2fSmrg	  major=".$current"
627034977a2fSmrg	  versuffix=".$current.$revision";
627134977a2fSmrg	  ;;
627234977a2fSmrg
627334977a2fSmrg	freebsd-elf)
627434977a2fSmrg	  major=".$current"
627534977a2fSmrg	  versuffix=".$current"
627634977a2fSmrg	  ;;
627734977a2fSmrg
627834977a2fSmrg	irix | nonstopux)
627934977a2fSmrg	  if test "X$lt_irix_increment" = "Xno"; then
628034977a2fSmrg	    func_arith $current - $age
628134977a2fSmrg	  else
628234977a2fSmrg	    func_arith $current - $age + 1
628334977a2fSmrg	  fi
628434977a2fSmrg	  major=$func_arith_result
628534977a2fSmrg
628634977a2fSmrg	  case $version_type in
628734977a2fSmrg	    nonstopux) verstring_prefix=nonstopux ;;
628834977a2fSmrg	    *)         verstring_prefix=sgi ;;
628934977a2fSmrg	  esac
629034977a2fSmrg	  verstring="$verstring_prefix$major.$revision"
629134977a2fSmrg
629234977a2fSmrg	  # Add in all the interfaces that we are compatible with.
629334977a2fSmrg	  loop=$revision
629434977a2fSmrg	  while test "$loop" -ne 0; do
629534977a2fSmrg	    func_arith $revision - $loop
629634977a2fSmrg	    iface=$func_arith_result
629734977a2fSmrg	    func_arith $loop - 1
629834977a2fSmrg	    loop=$func_arith_result
629934977a2fSmrg	    verstring="$verstring_prefix$major.$iface:$verstring"
630034977a2fSmrg	  done
630134977a2fSmrg
630234977a2fSmrg	  # Before this point, $major must not contain `.'.
630334977a2fSmrg	  major=.$major
630434977a2fSmrg	  versuffix="$major.$revision"
630534977a2fSmrg	  ;;
630634977a2fSmrg
630734977a2fSmrg	linux)
630834977a2fSmrg	  func_arith $current - $age
630934977a2fSmrg	  major=.$func_arith_result
631034977a2fSmrg	  versuffix="$major.$age.$revision"
631134977a2fSmrg	  ;;
631234977a2fSmrg
631334977a2fSmrg	osf)
631434977a2fSmrg	  func_arith $current - $age
631534977a2fSmrg	  major=.$func_arith_result
631634977a2fSmrg	  versuffix=".$current.$age.$revision"
631734977a2fSmrg	  verstring="$current.$age.$revision"
631834977a2fSmrg
631934977a2fSmrg	  # Add in all the interfaces that we are compatible with.
632034977a2fSmrg	  loop=$age
632134977a2fSmrg	  while test "$loop" -ne 0; do
632234977a2fSmrg	    func_arith $current - $loop
632334977a2fSmrg	    iface=$func_arith_result
632434977a2fSmrg	    func_arith $loop - 1
632534977a2fSmrg	    loop=$func_arith_result
632634977a2fSmrg	    verstring="$verstring:${iface}.0"
632734977a2fSmrg	  done
632834977a2fSmrg
632934977a2fSmrg	  # Make executables depend on our current version.
633034977a2fSmrg	  verstring="$verstring:${current}.0"
633134977a2fSmrg	  ;;
633234977a2fSmrg
633334977a2fSmrg	qnx)
633434977a2fSmrg	  major=".$current"
633534977a2fSmrg	  versuffix=".$current"
633634977a2fSmrg	  ;;
633734977a2fSmrg
633834977a2fSmrg	sunos)
633934977a2fSmrg	  major=".$current"
634034977a2fSmrg	  versuffix=".$current.$revision"
634134977a2fSmrg	  ;;
634234977a2fSmrg
634334977a2fSmrg	windows)
634434977a2fSmrg	  # Use '-' rather than '.', since we only want one
634534977a2fSmrg	  # extension on DOS 8.3 filesystems.
634634977a2fSmrg	  func_arith $current - $age
634734977a2fSmrg	  major=$func_arith_result
634834977a2fSmrg	  versuffix="-$major"
634934977a2fSmrg	  ;;
635034977a2fSmrg
635134977a2fSmrg	*)
635234977a2fSmrg	  func_fatal_configuration "unknown library version type \`$version_type'"
635334977a2fSmrg	  ;;
635434977a2fSmrg	esac
635534977a2fSmrg
635634977a2fSmrg	# Clear the version info if we defaulted, and they specified a release.
635734977a2fSmrg	if test -z "$vinfo" && test -n "$release"; then
635834977a2fSmrg	  major=
635934977a2fSmrg	  case $version_type in
636034977a2fSmrg	  darwin)
636134977a2fSmrg	    # we can't check for "0.0" in archive_cmds due to quoting
636234977a2fSmrg	    # problems, so we reset it completely
636334977a2fSmrg	    verstring=
636434977a2fSmrg	    ;;
636534977a2fSmrg	  *)
636634977a2fSmrg	    verstring="0.0"
636734977a2fSmrg	    ;;
636834977a2fSmrg	  esac
636934977a2fSmrg	  if test "$need_version" = no; then
637034977a2fSmrg	    versuffix=
637134977a2fSmrg	  else
637234977a2fSmrg	    versuffix=".0.0"
637334977a2fSmrg	  fi
637434977a2fSmrg	fi
637534977a2fSmrg
637634977a2fSmrg	# Remove version info from name if versioning should be avoided
637734977a2fSmrg	if test "$avoid_version" = yes && test "$need_version" = no; then
637834977a2fSmrg	  major=
637934977a2fSmrg	  versuffix=
638034977a2fSmrg	  verstring=""
638134977a2fSmrg	fi
638234977a2fSmrg
638334977a2fSmrg	# Check to see if the archive will have undefined symbols.
638434977a2fSmrg	if test "$allow_undefined" = yes; then
638534977a2fSmrg	  if test "$allow_undefined_flag" = unsupported; then
638634977a2fSmrg	    func_warning "undefined symbols not allowed in $host shared libraries"
638734977a2fSmrg	    build_libtool_libs=no
638834977a2fSmrg	    build_old_libs=yes
638934977a2fSmrg	  fi
639034977a2fSmrg	else
639134977a2fSmrg	  # Don't allow undefined symbols.
639234977a2fSmrg	  allow_undefined_flag="$no_undefined_flag"
639334977a2fSmrg	fi
639434977a2fSmrg
639534977a2fSmrg      fi
639634977a2fSmrg
639734977a2fSmrg      func_generate_dlsyms "$libname" "$libname" "yes"
639834977a2fSmrg      libobjs="$libobjs $symfileobj"
639934977a2fSmrg      test "X$libobjs" = "X " && libobjs=
640034977a2fSmrg
640134977a2fSmrg      if test "$mode" != relink; then
640234977a2fSmrg	# Remove our outputs, but don't remove object files since they
640334977a2fSmrg	# may have been created when compiling PIC objects.
640434977a2fSmrg	removelist=
640534977a2fSmrg	tempremovelist=`$ECHO "$output_objdir/*"`
640634977a2fSmrg	for p in $tempremovelist; do
640734977a2fSmrg	  case $p in
640834977a2fSmrg	    *.$objext | *.gcno)
640934977a2fSmrg	       ;;
641034977a2fSmrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
641134977a2fSmrg	       if test "X$precious_files_regex" != "X"; then
641234977a2fSmrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
641334977a2fSmrg		 then
641434977a2fSmrg		   continue
641534977a2fSmrg		 fi
641634977a2fSmrg	       fi
641734977a2fSmrg	       removelist="$removelist $p"
641834977a2fSmrg	       ;;
641934977a2fSmrg	    *) ;;
642034977a2fSmrg	  esac
642134977a2fSmrg	done
642234977a2fSmrg	test -n "$removelist" && \
642334977a2fSmrg	  func_show_eval "${RM}r \$removelist"
642434977a2fSmrg      fi
642534977a2fSmrg
642634977a2fSmrg      # Now set the variables for building old libraries.
642734977a2fSmrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
642834977a2fSmrg	oldlibs="$oldlibs $output_objdir/$libname.$libext"
642934977a2fSmrg
643034977a2fSmrg	# Transform .lo files to .o files.
643134977a2fSmrg	oldobjs="$objs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
643234977a2fSmrg      fi
643334977a2fSmrg
643434977a2fSmrg      # Eliminate all temporary directories.
643534977a2fSmrg      #for path in $notinst_path; do
643634977a2fSmrg      #	lib_search_path=`$ECHO "X$lib_search_path " | $Xsed -e "s% $path % %g"`
643734977a2fSmrg      #	deplibs=`$ECHO "X$deplibs " | $Xsed -e "s% -L$path % %g"`
643834977a2fSmrg      #	dependency_libs=`$ECHO "X$dependency_libs " | $Xsed -e "s% -L$path % %g"`
643934977a2fSmrg      #done
644034977a2fSmrg
644134977a2fSmrg      if test -n "$xrpath"; then
644234977a2fSmrg	# If the user specified any rpath flags, then add them.
644334977a2fSmrg	temp_xrpath=
644434977a2fSmrg	for libdir in $xrpath; do
644534977a2fSmrg	  temp_xrpath="$temp_xrpath -R$libdir"
644634977a2fSmrg	  case "$finalize_rpath " in
644734977a2fSmrg	  *" $libdir "*) ;;
644834977a2fSmrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
644934977a2fSmrg	  esac
645034977a2fSmrg	done
645134977a2fSmrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
645234977a2fSmrg	  dependency_libs="$temp_xrpath $dependency_libs"
645334977a2fSmrg	fi
645434977a2fSmrg      fi
645534977a2fSmrg
645634977a2fSmrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
645734977a2fSmrg      old_dlfiles="$dlfiles"
645834977a2fSmrg      dlfiles=
645934977a2fSmrg      for lib in $old_dlfiles; do
646034977a2fSmrg	case " $dlprefiles $dlfiles " in
646134977a2fSmrg	*" $lib "*) ;;
646234977a2fSmrg	*) dlfiles="$dlfiles $lib" ;;
646334977a2fSmrg	esac
646434977a2fSmrg      done
646534977a2fSmrg
646634977a2fSmrg      # Make sure dlprefiles contains only unique files
646734977a2fSmrg      old_dlprefiles="$dlprefiles"
646834977a2fSmrg      dlprefiles=
646934977a2fSmrg      for lib in $old_dlprefiles; do
647034977a2fSmrg	case "$dlprefiles " in
647134977a2fSmrg	*" $lib "*) ;;
647234977a2fSmrg	*) dlprefiles="$dlprefiles $lib" ;;
647334977a2fSmrg	esac
647434977a2fSmrg      done
647534977a2fSmrg
647634977a2fSmrg      if test "$build_libtool_libs" = yes; then
647734977a2fSmrg	if test -n "$rpath"; then
647834977a2fSmrg	  case $host in
647934977a2fSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc*)
648034977a2fSmrg	    # these systems don't actually have a c library (as such)!
648134977a2fSmrg	    ;;
648234977a2fSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
648334977a2fSmrg	    # Rhapsody C library is in the System framework
648434977a2fSmrg	    deplibs="$deplibs System.ltframework"
648534977a2fSmrg	    ;;
648634977a2fSmrg	  *-*-netbsd*)
648734977a2fSmrg	    # Don't link with libc until the a.out ld.so is fixed.
648834977a2fSmrg	    ;;
648934977a2fSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
649034977a2fSmrg	    # Do not include libc due to us having libc/libc_r.
649134977a2fSmrg	    ;;
649234977a2fSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
649334977a2fSmrg	    # Causes problems with __ctype
649434977a2fSmrg	    ;;
649534977a2fSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
649634977a2fSmrg	    # Compiler inserts libc in the correct place for threads to work
649734977a2fSmrg	    ;;
649834977a2fSmrg	  *)
649934977a2fSmrg	    # Add libc to deplibs on all other systems if necessary.
650034977a2fSmrg	    if test "$build_libtool_need_lc" = "yes"; then
650134977a2fSmrg	      deplibs="$deplibs -lc"
650234977a2fSmrg	    fi
650334977a2fSmrg	    ;;
650434977a2fSmrg	  esac
650534977a2fSmrg	fi
650634977a2fSmrg
650734977a2fSmrg	# Transform deplibs into only deplibs that can be linked in shared.
650834977a2fSmrg	name_save=$name
650934977a2fSmrg	libname_save=$libname
651034977a2fSmrg	release_save=$release
651134977a2fSmrg	versuffix_save=$versuffix
651234977a2fSmrg	major_save=$major
651334977a2fSmrg	# I'm not sure if I'm treating the release correctly.  I think
651434977a2fSmrg	# release should show up in the -l (ie -lgmp5) so we don't want to
651534977a2fSmrg	# add it in twice.  Is that correct?
651634977a2fSmrg	release=""
651734977a2fSmrg	versuffix=""
651834977a2fSmrg	major=""
651934977a2fSmrg	newdeplibs=
652034977a2fSmrg	droppeddeps=no
652134977a2fSmrg	case $deplibs_check_method in
652234977a2fSmrg	pass_all)
652334977a2fSmrg	  # Don't check for shared/static.  Everything works.
652434977a2fSmrg	  # This might be a little naive.  We might want to check
652534977a2fSmrg	  # whether the library exists or not.  But this is on
652634977a2fSmrg	  # osf3 & osf4 and I'm not really sure... Just
652734977a2fSmrg	  # implementing what was already the behavior.
652834977a2fSmrg	  newdeplibs=$deplibs
652934977a2fSmrg	  ;;
653034977a2fSmrg	test_compile)
653134977a2fSmrg	  # This code stresses the "libraries are programs" paradigm to its
653234977a2fSmrg	  # limits. Maybe even breaks it.  We compile a program, linking it
653334977a2fSmrg	  # against the deplibs as a proxy for the library.  Then we can check
653434977a2fSmrg	  # whether they linked in statically or dynamically with ldd.
653534977a2fSmrg	  $opt_dry_run || $RM conftest.c
653634977a2fSmrg	  cat > conftest.c <<EOF
653734977a2fSmrg	  int main() { return 0; }
653834977a2fSmrgEOF
653934977a2fSmrg	  $opt_dry_run || $RM conftest
654034977a2fSmrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
654134977a2fSmrg	    ldd_output=`ldd conftest`
654234977a2fSmrg	    for i in $deplibs; do
654334977a2fSmrg	      case $i in
654434977a2fSmrg	      -l*)
654534977a2fSmrg		func_stripname -l '' "$i"
654634977a2fSmrg		name=$func_stripname_result
654734977a2fSmrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
654834977a2fSmrg		  case " $predeps $postdeps " in
654934977a2fSmrg		  *" $i "*)
655034977a2fSmrg		    newdeplibs="$newdeplibs $i"
655134977a2fSmrg		    i=""
655234977a2fSmrg		    ;;
655334977a2fSmrg		  esac
655434977a2fSmrg		fi
655534977a2fSmrg		if test -n "$i" ; then
655634977a2fSmrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
655734977a2fSmrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
655834977a2fSmrg		  set dummy $deplib_matches; shift
655934977a2fSmrg		  deplib_match=$1
656034977a2fSmrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
656134977a2fSmrg		    newdeplibs="$newdeplibs $i"
656234977a2fSmrg		  else
656334977a2fSmrg		    droppeddeps=yes
656434977a2fSmrg		    $ECHO
656534977a2fSmrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
656634977a2fSmrg		    $ECHO "*** I have the capability to make that library automatically link in when"
656734977a2fSmrg		    $ECHO "*** you link to this library.  But I can only do this if you have a"
656834977a2fSmrg		    $ECHO "*** shared version of the library, which I believe you do not have"
656934977a2fSmrg		    $ECHO "*** because a test_compile did reveal that the linker did not use it for"
657034977a2fSmrg		    $ECHO "*** its dynamic dependency list that programs get resolved with at runtime."
657134977a2fSmrg		  fi
657234977a2fSmrg		fi
657334977a2fSmrg		;;
657434977a2fSmrg	      *)
657534977a2fSmrg		newdeplibs="$newdeplibs $i"
657634977a2fSmrg		;;
657734977a2fSmrg	      esac
657834977a2fSmrg	    done
657934977a2fSmrg	  else
658034977a2fSmrg	    # Error occurred in the first compile.  Let's try to salvage
658134977a2fSmrg	    # the situation: Compile a separate program for each library.
658234977a2fSmrg	    for i in $deplibs; do
658334977a2fSmrg	      case $i in
658434977a2fSmrg	      -l*)
658534977a2fSmrg		func_stripname -l '' "$i"
658634977a2fSmrg		name=$func_stripname_result
658734977a2fSmrg		$opt_dry_run || $RM conftest
658834977a2fSmrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
658934977a2fSmrg		  ldd_output=`ldd conftest`
659034977a2fSmrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
659134977a2fSmrg		    case " $predeps $postdeps " in
659234977a2fSmrg		    *" $i "*)
659334977a2fSmrg		      newdeplibs="$newdeplibs $i"
659434977a2fSmrg		      i=""
659534977a2fSmrg		      ;;
659634977a2fSmrg		    esac
659734977a2fSmrg		  fi
659834977a2fSmrg		  if test -n "$i" ; then
659934977a2fSmrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
660034977a2fSmrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
660134977a2fSmrg		    set dummy $deplib_matches; shift
660234977a2fSmrg		    deplib_match=$1
660334977a2fSmrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
660434977a2fSmrg		      newdeplibs="$newdeplibs $i"
660534977a2fSmrg		    else
660634977a2fSmrg		      droppeddeps=yes
660734977a2fSmrg		      $ECHO
660834977a2fSmrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
660934977a2fSmrg		      $ECHO "*** I have the capability to make that library automatically link in when"
661034977a2fSmrg		      $ECHO "*** you link to this library.  But I can only do this if you have a"
661134977a2fSmrg		      $ECHO "*** shared version of the library, which you do not appear to have"
661234977a2fSmrg		      $ECHO "*** because a test_compile did reveal that the linker did not use this one"
661334977a2fSmrg		      $ECHO "*** as a dynamic dependency that programs can get resolved with at runtime."
661434977a2fSmrg		    fi
661534977a2fSmrg		  fi
661634977a2fSmrg		else
661734977a2fSmrg		  droppeddeps=yes
661834977a2fSmrg		  $ECHO
661934977a2fSmrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
662034977a2fSmrg		  $ECHO "*** make it link in!  You will probably need to install it or some"
662134977a2fSmrg		  $ECHO "*** library that it depends on before this library will be fully"
662234977a2fSmrg		  $ECHO "*** functional.  Installing it before continuing would be even better."
662334977a2fSmrg		fi
662434977a2fSmrg		;;
662534977a2fSmrg	      *)
662634977a2fSmrg		newdeplibs="$newdeplibs $i"
662734977a2fSmrg		;;
662834977a2fSmrg	      esac
662934977a2fSmrg	    done
663034977a2fSmrg	  fi
663134977a2fSmrg	  ;;
663234977a2fSmrg	file_magic*)
663334977a2fSmrg	  set dummy $deplibs_check_method; shift
663434977a2fSmrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
663534977a2fSmrg	  for a_deplib in $deplibs; do
663634977a2fSmrg	    case $a_deplib in
663734977a2fSmrg	    -l*)
663834977a2fSmrg	      func_stripname -l '' "$a_deplib"
663934977a2fSmrg	      name=$func_stripname_result
664034977a2fSmrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
664134977a2fSmrg		case " $predeps $postdeps " in
664234977a2fSmrg		*" $a_deplib "*)
664334977a2fSmrg		  newdeplibs="$newdeplibs $a_deplib"
664434977a2fSmrg		  a_deplib=""
664534977a2fSmrg		  ;;
664634977a2fSmrg		esac
664734977a2fSmrg	      fi
664834977a2fSmrg	      if test -n "$a_deplib" ; then
664934977a2fSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
665034977a2fSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
665134977a2fSmrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
665234977a2fSmrg		  for potent_lib in $potential_libs; do
665334977a2fSmrg		      # Follow soft links.
665434977a2fSmrg		      if ls -lLd "$potent_lib" 2>/dev/null |
665534977a2fSmrg			 $GREP " -> " >/dev/null; then
665634977a2fSmrg			continue
665734977a2fSmrg		      fi
665834977a2fSmrg		      # The statement above tries to avoid entering an
665934977a2fSmrg		      # endless loop below, in case of cyclic links.
666034977a2fSmrg		      # We might still enter an endless loop, since a link
666134977a2fSmrg		      # loop can be closed while we follow links,
666234977a2fSmrg		      # but so what?
666334977a2fSmrg		      potlib="$potent_lib"
666434977a2fSmrg		      while test -h "$potlib" 2>/dev/null; do
666534977a2fSmrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
666634977a2fSmrg			case $potliblink in
666734977a2fSmrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
666834977a2fSmrg			*) potlib=`$ECHO "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
666934977a2fSmrg			esac
667034977a2fSmrg		      done
667134977a2fSmrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
667234977a2fSmrg			 $SED -e 10q |
667334977a2fSmrg			 $EGREP "$file_magic_regex" > /dev/null; then
667434977a2fSmrg			newdeplibs="$newdeplibs $a_deplib"
667534977a2fSmrg			a_deplib=""
667634977a2fSmrg			break 2
667734977a2fSmrg		      fi
667834977a2fSmrg		  done
667934977a2fSmrg		done
668034977a2fSmrg	      fi
668134977a2fSmrg	      if test -n "$a_deplib" ; then
668234977a2fSmrg		droppeddeps=yes
668334977a2fSmrg		$ECHO
668434977a2fSmrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
668534977a2fSmrg		$ECHO "*** I have the capability to make that library automatically link in when"
668634977a2fSmrg		$ECHO "*** you link to this library.  But I can only do this if you have a"
668734977a2fSmrg		$ECHO "*** shared version of the library, which you do not appear to have"
668834977a2fSmrg		$ECHO "*** because I did check the linker path looking for a file starting"
668934977a2fSmrg		if test -z "$potlib" ; then
669034977a2fSmrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
669134977a2fSmrg		else
669234977a2fSmrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
669334977a2fSmrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
669434977a2fSmrg		fi
669534977a2fSmrg	      fi
669634977a2fSmrg	      ;;
669734977a2fSmrg	    *)
669834977a2fSmrg	      # Add a -L argument.
669934977a2fSmrg	      newdeplibs="$newdeplibs $a_deplib"
670034977a2fSmrg	      ;;
670134977a2fSmrg	    esac
670234977a2fSmrg	  done # Gone through all deplibs.
670334977a2fSmrg	  ;;
670434977a2fSmrg	match_pattern*)
670534977a2fSmrg	  set dummy $deplibs_check_method; shift
670634977a2fSmrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
670734977a2fSmrg	  for a_deplib in $deplibs; do
670834977a2fSmrg	    case $a_deplib in
670934977a2fSmrg	    -l*)
671034977a2fSmrg	      func_stripname -l '' "$a_deplib"
671134977a2fSmrg	      name=$func_stripname_result
671234977a2fSmrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
671334977a2fSmrg		case " $predeps $postdeps " in
671434977a2fSmrg		*" $a_deplib "*)
671534977a2fSmrg		  newdeplibs="$newdeplibs $a_deplib"
671634977a2fSmrg		  a_deplib=""
671734977a2fSmrg		  ;;
671834977a2fSmrg		esac
671934977a2fSmrg	      fi
672034977a2fSmrg	      if test -n "$a_deplib" ; then
672134977a2fSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
672234977a2fSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
672334977a2fSmrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
672434977a2fSmrg		  for potent_lib in $potential_libs; do
672534977a2fSmrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
672634977a2fSmrg		    if eval "\$ECHO \"X$potent_lib\"" 2>/dev/null | $Xsed -e 10q | \
672734977a2fSmrg		       $EGREP "$match_pattern_regex" > /dev/null; then
672834977a2fSmrg		      newdeplibs="$newdeplibs $a_deplib"
672934977a2fSmrg		      a_deplib=""
673034977a2fSmrg		      break 2
673134977a2fSmrg		    fi
673234977a2fSmrg		  done
673334977a2fSmrg		done
673434977a2fSmrg	      fi
673534977a2fSmrg	      if test -n "$a_deplib" ; then
673634977a2fSmrg		droppeddeps=yes
673734977a2fSmrg		$ECHO
673834977a2fSmrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
673934977a2fSmrg		$ECHO "*** I have the capability to make that library automatically link in when"
674034977a2fSmrg		$ECHO "*** you link to this library.  But I can only do this if you have a"
674134977a2fSmrg		$ECHO "*** shared version of the library, which you do not appear to have"
674234977a2fSmrg		$ECHO "*** because I did check the linker path looking for a file starting"
674334977a2fSmrg		if test -z "$potlib" ; then
674434977a2fSmrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
674534977a2fSmrg		else
674634977a2fSmrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
674734977a2fSmrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
674834977a2fSmrg		fi
674934977a2fSmrg	      fi
675034977a2fSmrg	      ;;
675134977a2fSmrg	    *)
675234977a2fSmrg	      # Add a -L argument.
675334977a2fSmrg	      newdeplibs="$newdeplibs $a_deplib"
675434977a2fSmrg	      ;;
675534977a2fSmrg	    esac
675634977a2fSmrg	  done # Gone through all deplibs.
675734977a2fSmrg	  ;;
675834977a2fSmrg	none | unknown | *)
675934977a2fSmrg	  newdeplibs=""
676034977a2fSmrg	  tmp_deplibs=`$ECHO "X $deplibs" | $Xsed \
676134977a2fSmrg	      -e 's/ -lc$//' -e 's/ -[LR][^ ]*//g'`
676234977a2fSmrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
676334977a2fSmrg	    for i in $predeps $postdeps ; do
676434977a2fSmrg	      # can't use Xsed below, because $i might contain '/'
676534977a2fSmrg	      tmp_deplibs=`$ECHO "X $tmp_deplibs" | $Xsed -e "s,$i,,"`
676634977a2fSmrg	    done
676734977a2fSmrg	  fi
676834977a2fSmrg	  if $ECHO "X $tmp_deplibs" | $Xsed -e 's/[	 ]//g' |
676934977a2fSmrg	     $GREP . >/dev/null; then
677034977a2fSmrg	    $ECHO
677134977a2fSmrg	    if test "X$deplibs_check_method" = "Xnone"; then
677234977a2fSmrg	      $ECHO "*** Warning: inter-library dependencies are not supported in this platform."
677334977a2fSmrg	    else
677434977a2fSmrg	      $ECHO "*** Warning: inter-library dependencies are not known to be supported."
677534977a2fSmrg	    fi
677634977a2fSmrg	    $ECHO "*** All declared inter-library dependencies are being dropped."
677734977a2fSmrg	    droppeddeps=yes
677834977a2fSmrg	  fi
677934977a2fSmrg	  ;;
678034977a2fSmrg	esac
678134977a2fSmrg	versuffix=$versuffix_save
678234977a2fSmrg	major=$major_save
678334977a2fSmrg	release=$release_save
678434977a2fSmrg	libname=$libname_save
678534977a2fSmrg	name=$name_save
678634977a2fSmrg
678734977a2fSmrg	case $host in
678834977a2fSmrg	*-*-rhapsody* | *-*-darwin1.[012])
678934977a2fSmrg	  # On Rhapsody replace the C library with the System framework
679034977a2fSmrg	  newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
679134977a2fSmrg	  ;;
679234977a2fSmrg	esac
679334977a2fSmrg
679434977a2fSmrg	if test "$droppeddeps" = yes; then
679534977a2fSmrg	  if test "$module" = yes; then
679634977a2fSmrg	    $ECHO
679734977a2fSmrg	    $ECHO "*** Warning: libtool could not satisfy all declared inter-library"
679834977a2fSmrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
679934977a2fSmrg	    $ECHO "*** a static module, that should work as long as the dlopening"
680034977a2fSmrg	    $ECHO "*** application is linked with the -dlopen flag."
680134977a2fSmrg	    if test -z "$global_symbol_pipe"; then
680234977a2fSmrg	      $ECHO
680334977a2fSmrg	      $ECHO "*** However, this would only work if libtool was able to extract symbol"
680434977a2fSmrg	      $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
680534977a2fSmrg	      $ECHO "*** not find such a program.  So, this module is probably useless."
680634977a2fSmrg	      $ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
680734977a2fSmrg	    fi
680834977a2fSmrg	    if test "$build_old_libs" = no; then
680934977a2fSmrg	      oldlibs="$output_objdir/$libname.$libext"
681034977a2fSmrg	      build_libtool_libs=module
681134977a2fSmrg	      build_old_libs=yes
681234977a2fSmrg	    else
681334977a2fSmrg	      build_libtool_libs=no
681434977a2fSmrg	    fi
681534977a2fSmrg	  else
681634977a2fSmrg	    $ECHO "*** The inter-library dependencies that have been dropped here will be"
681734977a2fSmrg	    $ECHO "*** automatically added whenever a program is linked with this library"
681834977a2fSmrg	    $ECHO "*** or is declared to -dlopen it."
681934977a2fSmrg
682034977a2fSmrg	    if test "$allow_undefined" = no; then
682134977a2fSmrg	      $ECHO
682234977a2fSmrg	      $ECHO "*** Since this library must not contain undefined symbols,"
682334977a2fSmrg	      $ECHO "*** because either the platform does not support them or"
682434977a2fSmrg	      $ECHO "*** it was explicitly requested with -no-undefined,"
682534977a2fSmrg	      $ECHO "*** libtool will only create a static version of it."
682634977a2fSmrg	      if test "$build_old_libs" = no; then
682734977a2fSmrg		oldlibs="$output_objdir/$libname.$libext"
682834977a2fSmrg		build_libtool_libs=module
682934977a2fSmrg		build_old_libs=yes
683034977a2fSmrg	      else
683134977a2fSmrg		build_libtool_libs=no
683234977a2fSmrg	      fi
683334977a2fSmrg	    fi
683434977a2fSmrg	  fi
683534977a2fSmrg	fi
683634977a2fSmrg	# Done checking deplibs!
683734977a2fSmrg	deplibs=$newdeplibs
683834977a2fSmrg      fi
683934977a2fSmrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
684034977a2fSmrg      case $host in
684134977a2fSmrg	*-*-darwin*)
684234977a2fSmrg	  newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
684334977a2fSmrg	  new_inherited_linker_flags=`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
684434977a2fSmrg	  deplibs=`$ECHO "X $deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
684534977a2fSmrg	  ;;
684634977a2fSmrg      esac
684734977a2fSmrg
684834977a2fSmrg      # move library search paths that coincide with paths to not yet
684934977a2fSmrg      # installed libraries to the beginning of the library search list
685034977a2fSmrg      new_libs=
685134977a2fSmrg      for path in $notinst_path; do
685234977a2fSmrg	case " $new_libs " in
685334977a2fSmrg	*" -L$path/$objdir "*) ;;
685434977a2fSmrg	*)
685534977a2fSmrg	  case " $deplibs " in
685634977a2fSmrg	  *" -L$path/$objdir "*)
685734977a2fSmrg	    new_libs="$new_libs -L$path/$objdir" ;;
685834977a2fSmrg	  esac
685934977a2fSmrg	  ;;
686034977a2fSmrg	esac
686134977a2fSmrg      done
686234977a2fSmrg      for deplib in $deplibs; do
686334977a2fSmrg	case $deplib in
686434977a2fSmrg	-L*)
686534977a2fSmrg	  case " $new_libs " in
686634977a2fSmrg	  *" $deplib "*) ;;
686734977a2fSmrg	  *) new_libs="$new_libs $deplib" ;;
686834977a2fSmrg	  esac
686934977a2fSmrg	  ;;
687034977a2fSmrg	*) new_libs="$new_libs $deplib" ;;
687134977a2fSmrg	esac
687234977a2fSmrg      done
687334977a2fSmrg      deplibs="$new_libs"
687434977a2fSmrg
687534977a2fSmrg      # All the library-specific variables (install_libdir is set above).
687634977a2fSmrg      library_names=
687734977a2fSmrg      old_library=
687834977a2fSmrg      dlname=
687934977a2fSmrg
688034977a2fSmrg      # Test again, we may have decided not to build it any more
688134977a2fSmrg      if test "$build_libtool_libs" = yes; then
688234977a2fSmrg	if test "$hardcode_into_libs" = yes; then
688334977a2fSmrg	  # Hardcode the library paths
688434977a2fSmrg	  hardcode_libdirs=
688534977a2fSmrg	  dep_rpath=
688634977a2fSmrg	  rpath="$finalize_rpath"
688734977a2fSmrg	  test "$mode" != relink && rpath="$compile_rpath$rpath"
688834977a2fSmrg	  for libdir in $rpath; do
688934977a2fSmrg	    if test -n "$hardcode_libdir_flag_spec"; then
689034977a2fSmrg	      if test -n "$hardcode_libdir_separator"; then
689134977a2fSmrg		if test -z "$hardcode_libdirs"; then
689234977a2fSmrg		  hardcode_libdirs="$libdir"
689334977a2fSmrg		else
689434977a2fSmrg		  # Just accumulate the unique libdirs.
689534977a2fSmrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
689634977a2fSmrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
689734977a2fSmrg		    ;;
689834977a2fSmrg		  *)
689934977a2fSmrg		    hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
690034977a2fSmrg		    ;;
690134977a2fSmrg		  esac
690234977a2fSmrg		fi
690334977a2fSmrg	      else
690434977a2fSmrg		eval flag=\"$hardcode_libdir_flag_spec\"
690534977a2fSmrg		dep_rpath="$dep_rpath $flag"
690634977a2fSmrg	      fi
690734977a2fSmrg	    elif test -n "$runpath_var"; then
690834977a2fSmrg	      case "$perm_rpath " in
690934977a2fSmrg	      *" $libdir "*) ;;
691034977a2fSmrg	      *) perm_rpath="$perm_rpath $libdir" ;;
691134977a2fSmrg	      esac
691234977a2fSmrg	    fi
691334977a2fSmrg	  done
691434977a2fSmrg	  # Substitute the hardcoded libdirs into the rpath.
691534977a2fSmrg	  if test -n "$hardcode_libdir_separator" &&
691634977a2fSmrg	     test -n "$hardcode_libdirs"; then
691734977a2fSmrg	    libdir="$hardcode_libdirs"
691834977a2fSmrg	    if test -n "$hardcode_libdir_flag_spec_ld"; then
691934977a2fSmrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
692034977a2fSmrg	    else
692134977a2fSmrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
692234977a2fSmrg	    fi
692334977a2fSmrg	  fi
692434977a2fSmrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
692534977a2fSmrg	    # We should set the runpath_var.
692634977a2fSmrg	    rpath=
692734977a2fSmrg	    for dir in $perm_rpath; do
692834977a2fSmrg	      rpath="$rpath$dir:"
692934977a2fSmrg	    done
693034977a2fSmrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
693134977a2fSmrg	  fi
693234977a2fSmrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
693334977a2fSmrg	fi
6934ee3138f1Smrg
693534977a2fSmrg	shlibpath="$finalize_shlibpath"
693634977a2fSmrg	test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
693734977a2fSmrg	if test -n "$shlibpath"; then
693834977a2fSmrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
693934977a2fSmrg	fi
6940ee3138f1Smrg
694134977a2fSmrg	# Get the real and link names of the library.
694234977a2fSmrg	eval shared_ext=\"$shrext_cmds\"
694334977a2fSmrg	eval library_names=\"$library_names_spec\"
694434977a2fSmrg	set dummy $library_names
694534977a2fSmrg	shift
694634977a2fSmrg	realname="$1"
694734977a2fSmrg	shift
6948ee3138f1Smrg
694934977a2fSmrg	if test -n "$soname_spec"; then
695034977a2fSmrg	  eval soname=\"$soname_spec\"
695134977a2fSmrg	else
695234977a2fSmrg	  soname="$realname"
695334977a2fSmrg	fi
695434977a2fSmrg	if test -z "$dlname"; then
695534977a2fSmrg	  dlname=$soname
695634977a2fSmrg	fi
6957ee3138f1Smrg
695834977a2fSmrg	lib="$output_objdir/$realname"
695934977a2fSmrg	linknames=
696034977a2fSmrg	for link
696134977a2fSmrg	do
696234977a2fSmrg	  linknames="$linknames $link"
696334977a2fSmrg	done
6964ee3138f1Smrg
696534977a2fSmrg	# Use standard objects if they are pic
696634977a2fSmrg	test -z "$pic_flag" && libobjs=`$ECHO "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
696734977a2fSmrg	test "X$libobjs" = "X " && libobjs=
6968ee3138f1Smrg
696934977a2fSmrg	delfiles=
697034977a2fSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
697134977a2fSmrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
697234977a2fSmrg	  export_symbols="$output_objdir/$libname.uexp"
697334977a2fSmrg	  delfiles="$delfiles $export_symbols"
697434977a2fSmrg	fi
6975ee3138f1Smrg
697634977a2fSmrg	orig_export_symbols=
697734977a2fSmrg	case $host_os in
697834977a2fSmrg	cygwin* | mingw* | cegcc*)
697934977a2fSmrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
698034977a2fSmrg	    # exporting using user supplied symfile
698134977a2fSmrg	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
698234977a2fSmrg	      # and it's NOT already a .def file. Must figure out
698334977a2fSmrg	      # which of the given symbols are data symbols and tag
698434977a2fSmrg	      # them as such. So, trigger use of export_symbols_cmds.
698534977a2fSmrg	      # export_symbols gets reassigned inside the "prepare
698634977a2fSmrg	      # the list of exported symbols" if statement, so the
698734977a2fSmrg	      # include_expsyms logic still works.
698834977a2fSmrg	      orig_export_symbols="$export_symbols"
698934977a2fSmrg	      export_symbols=
699034977a2fSmrg	      always_export_symbols=yes
699134977a2fSmrg	    fi
699234977a2fSmrg	  fi
699334977a2fSmrg	  ;;
699434977a2fSmrg	esac
6995ee3138f1Smrg
699634977a2fSmrg	# Prepare the list of exported symbols
699734977a2fSmrg	if test -z "$export_symbols"; then
699834977a2fSmrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
699934977a2fSmrg	    func_verbose "generating symbol list for \`$libname.la'"
700034977a2fSmrg	    export_symbols="$output_objdir/$libname.exp"
700134977a2fSmrg	    $opt_dry_run || $RM $export_symbols
700234977a2fSmrg	    cmds=$export_symbols_cmds
700334977a2fSmrg	    save_ifs="$IFS"; IFS='~'
700434977a2fSmrg	    for cmd in $cmds; do
700534977a2fSmrg	      IFS="$save_ifs"
700634977a2fSmrg	      eval cmd=\"$cmd\"
700734977a2fSmrg	      func_len " $cmd"
700834977a2fSmrg	      len=$func_len_result
700934977a2fSmrg	      if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
701034977a2fSmrg		func_show_eval "$cmd" 'exit $?'
701134977a2fSmrg		skipped_export=false
701234977a2fSmrg	      else
701334977a2fSmrg		# The command line is too long to execute in one step.
701434977a2fSmrg		func_verbose "using reloadable object file for export list..."
701534977a2fSmrg		skipped_export=:
701634977a2fSmrg		# Break out early, otherwise skipped_export may be
701734977a2fSmrg		# set to false by a later but shorter cmd.
701834977a2fSmrg		break
701934977a2fSmrg	      fi
702034977a2fSmrg	    done
702134977a2fSmrg	    IFS="$save_ifs"
702234977a2fSmrg	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
702334977a2fSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
702434977a2fSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
702534977a2fSmrg	    fi
702634977a2fSmrg	  fi
7027ee3138f1Smrg	fi
7028ee3138f1Smrg
702934977a2fSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
703034977a2fSmrg	  tmp_export_symbols="$export_symbols"
703134977a2fSmrg	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
703234977a2fSmrg	  $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
703334977a2fSmrg	fi
7034ee3138f1Smrg
703534977a2fSmrg	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
703634977a2fSmrg	  # The given exports_symbols file has to be filtered, so filter it.
703734977a2fSmrg	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
703834977a2fSmrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
703934977a2fSmrg	  # 's' commands which not all seds can handle. GNU sed should be fine
704034977a2fSmrg	  # though. Also, the filter scales superlinearly with the number of
704134977a2fSmrg	  # global variables. join(1) would be nice here, but unfortunately
704234977a2fSmrg	  # isn't a blessed tool.
704334977a2fSmrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
704434977a2fSmrg	  delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
704534977a2fSmrg	  export_symbols=$output_objdir/$libname.def
704634977a2fSmrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
704734977a2fSmrg	fi
7048ee3138f1Smrg
704934977a2fSmrg	tmp_deplibs=
705034977a2fSmrg	for test_deplib in $deplibs; do
705134977a2fSmrg	  case " $convenience " in
705234977a2fSmrg	  *" $test_deplib "*) ;;
705334977a2fSmrg	  *)
705434977a2fSmrg	    tmp_deplibs="$tmp_deplibs $test_deplib"
705534977a2fSmrg	    ;;
705634977a2fSmrg	  esac
705734977a2fSmrg	done
705834977a2fSmrg	deplibs="$tmp_deplibs"
7059ee3138f1Smrg
706034977a2fSmrg	if test -n "$convenience"; then
706134977a2fSmrg	  if test -n "$whole_archive_flag_spec" &&
706234977a2fSmrg	    test "$compiler_needs_object" = yes &&
706334977a2fSmrg	    test -z "$libobjs"; then
706434977a2fSmrg	    # extract the archives, so we have objects to list.
706534977a2fSmrg	    # TODO: could optimize this to just extract one archive.
706634977a2fSmrg	    whole_archive_flag_spec=
706734977a2fSmrg	  fi
706834977a2fSmrg	  if test -n "$whole_archive_flag_spec"; then
706934977a2fSmrg	    save_libobjs=$libobjs
707034977a2fSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
707134977a2fSmrg	    test "X$libobjs" = "X " && libobjs=
707234977a2fSmrg	  else
707334977a2fSmrg	    gentop="$output_objdir/${outputname}x"
707434977a2fSmrg	    generated="$generated $gentop"
7075ee3138f1Smrg
707634977a2fSmrg	    func_extract_archives $gentop $convenience
707734977a2fSmrg	    libobjs="$libobjs $func_extract_archives_result"
707834977a2fSmrg	    test "X$libobjs" = "X " && libobjs=
707934977a2fSmrg	  fi
7080ee3138f1Smrg	fi
7081ee3138f1Smrg
708234977a2fSmrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
708334977a2fSmrg	  eval flag=\"$thread_safe_flag_spec\"
708434977a2fSmrg	  linker_flags="$linker_flags $flag"
7085ee3138f1Smrg	fi
7086ee3138f1Smrg
708734977a2fSmrg	# Make a backup of the uninstalled library when relinking
708834977a2fSmrg	if test "$mode" = relink; then
708934977a2fSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
709034977a2fSmrg	fi
7091ee3138f1Smrg
709234977a2fSmrg	# Do each of the archive commands.
709334977a2fSmrg	if test "$module" = yes && test -n "$module_cmds" ; then
709434977a2fSmrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
709534977a2fSmrg	    eval test_cmds=\"$module_expsym_cmds\"
709634977a2fSmrg	    cmds=$module_expsym_cmds
709734977a2fSmrg	  else
709834977a2fSmrg	    eval test_cmds=\"$module_cmds\"
709934977a2fSmrg	    cmds=$module_cmds
710034977a2fSmrg	  fi
7101ee3138f1Smrg	else
710234977a2fSmrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
710334977a2fSmrg	    eval test_cmds=\"$archive_expsym_cmds\"
710434977a2fSmrg	    cmds=$archive_expsym_cmds
710534977a2fSmrg	  else
710634977a2fSmrg	    eval test_cmds=\"$archive_cmds\"
710734977a2fSmrg	    cmds=$archive_cmds
710834977a2fSmrg	  fi
7109ee3138f1Smrg	fi
7110ee3138f1Smrg
711134977a2fSmrg	if test "X$skipped_export" != "X:" &&
711234977a2fSmrg	   func_len " $test_cmds" &&
711334977a2fSmrg	   len=$func_len_result &&
711434977a2fSmrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
711534977a2fSmrg	  :
711634977a2fSmrg	else
711734977a2fSmrg	  # The command line is too long to link in one step, link piecewise
711834977a2fSmrg	  # or, if using GNU ld and skipped_export is not :, use a linker
711934977a2fSmrg	  # script.
7120ee3138f1Smrg
712134977a2fSmrg	  # Save the value of $output and $libobjs because we want to
712234977a2fSmrg	  # use them later.  If we have whole_archive_flag_spec, we
712334977a2fSmrg	  # want to use save_libobjs as it was before
712434977a2fSmrg	  # whole_archive_flag_spec was expanded, because we can't
712534977a2fSmrg	  # assume the linker understands whole_archive_flag_spec.
712634977a2fSmrg	  # This may have to be revisited, in case too many
712734977a2fSmrg	  # convenience libraries get linked in and end up exceeding
712834977a2fSmrg	  # the spec.
712934977a2fSmrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
713034977a2fSmrg	    save_libobjs=$libobjs
713134977a2fSmrg	  fi
713234977a2fSmrg	  save_output=$output
713334977a2fSmrg	  output_la=`$ECHO "X$output" | $Xsed -e "$basename"`
7134ee3138f1Smrg
713534977a2fSmrg	  # Clear the reloadable object creation command queue and
713634977a2fSmrg	  # initialize k to one.
713734977a2fSmrg	  test_cmds=
713834977a2fSmrg	  concat_cmds=
713934977a2fSmrg	  objlist=
714034977a2fSmrg	  last_robj=
714134977a2fSmrg	  k=1
714234977a2fSmrg
714334977a2fSmrg	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
714434977a2fSmrg	    output=${output_objdir}/${output_la}.lnkscript
714534977a2fSmrg	    func_verbose "creating GNU ld script: $output"
714634977a2fSmrg	    $ECHO 'INPUT (' > $output
714734977a2fSmrg	    for obj in $save_libobjs
7148ee3138f1Smrg	    do
714934977a2fSmrg	      $ECHO "$obj" >> $output
715034977a2fSmrg	    done
715134977a2fSmrg	    $ECHO ')' >> $output
715234977a2fSmrg	    delfiles="$delfiles $output"
715334977a2fSmrg	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
715434977a2fSmrg	    output=${output_objdir}/${output_la}.lnk
715534977a2fSmrg	    func_verbose "creating linker input file list: $output"
715634977a2fSmrg	    : > $output
715734977a2fSmrg	    set x $save_libobjs
715834977a2fSmrg	    shift
715934977a2fSmrg	    firstobj=
716034977a2fSmrg	    if test "$compiler_needs_object" = yes; then
716134977a2fSmrg	      firstobj="$1 "
716234977a2fSmrg	      shift
716334977a2fSmrg	    fi
716434977a2fSmrg	    for obj
716534977a2fSmrg	    do
716634977a2fSmrg	      $ECHO "$obj" >> $output
716734977a2fSmrg	    done
716834977a2fSmrg	    delfiles="$delfiles $output"
716934977a2fSmrg	    output=$firstobj\"$file_list_spec$output\"
717034977a2fSmrg	  else
717134977a2fSmrg	    if test -n "$save_libobjs"; then
717234977a2fSmrg	      func_verbose "creating reloadable object files..."
717334977a2fSmrg	      output=$output_objdir/$output_la-${k}.$objext
717434977a2fSmrg	      eval test_cmds=\"$reload_cmds\"
717534977a2fSmrg	      func_len " $test_cmds"
717634977a2fSmrg	      len0=$func_len_result
717734977a2fSmrg	      len=$len0
717834977a2fSmrg
717934977a2fSmrg	      # Loop over the list of objects to be linked.
718034977a2fSmrg	      for obj in $save_libobjs
718134977a2fSmrg	      do
718234977a2fSmrg		func_len " $obj"
718334977a2fSmrg		func_arith $len + $func_len_result
718434977a2fSmrg		len=$func_arith_result
718534977a2fSmrg		if test "X$objlist" = X ||
718634977a2fSmrg		   test "$len" -lt "$max_cmd_len"; then
718734977a2fSmrg		  func_append objlist " $obj"
718834977a2fSmrg		else
718934977a2fSmrg		  # The command $test_cmds is almost too long, add a
719034977a2fSmrg		  # command to the queue.
719134977a2fSmrg		  if test "$k" -eq 1 ; then
719234977a2fSmrg		    # The first file doesn't have a previous command to add.
719334977a2fSmrg		    eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
719434977a2fSmrg		  else
719534977a2fSmrg		    # All subsequent reloadable object files will link in
719634977a2fSmrg		    # the last one created.
719734977a2fSmrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj~\$RM $last_robj\"
719834977a2fSmrg		  fi
719934977a2fSmrg		  last_robj=$output_objdir/$output_la-${k}.$objext
720034977a2fSmrg		  func_arith $k + 1
720134977a2fSmrg		  k=$func_arith_result
720234977a2fSmrg		  output=$output_objdir/$output_la-${k}.$objext
720334977a2fSmrg		  objlist=$obj
720434977a2fSmrg		  func_len " $last_robj"
720534977a2fSmrg		  func_arith $len0 + $func_len_result
720634977a2fSmrg		  len=$func_arith_result
720734977a2fSmrg		fi
720834977a2fSmrg	      done
720934977a2fSmrg	      # Handle the remaining objects by creating one last
721034977a2fSmrg	      # reloadable object file.  All subsequent reloadable object
721134977a2fSmrg	      # files will link in the last one created.
721234977a2fSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
721334977a2fSmrg	      eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
721434977a2fSmrg	      if test -n "$last_robj"; then
721534977a2fSmrg	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
721634977a2fSmrg	      fi
721734977a2fSmrg	      delfiles="$delfiles $output"
7218ee3138f1Smrg
721934977a2fSmrg	    else
722034977a2fSmrg	      output=
722134977a2fSmrg	    fi
7222ee3138f1Smrg
722334977a2fSmrg	    if ${skipped_export-false}; then
722434977a2fSmrg	      func_verbose "generating symbol list for \`$libname.la'"
722534977a2fSmrg	      export_symbols="$output_objdir/$libname.exp"
722634977a2fSmrg	      $opt_dry_run || $RM $export_symbols
722734977a2fSmrg	      libobjs=$output
722834977a2fSmrg	      # Append the command to create the export file.
722934977a2fSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
723034977a2fSmrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
723134977a2fSmrg	      if test -n "$last_robj"; then
723234977a2fSmrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
723334977a2fSmrg	      fi
7234ee3138f1Smrg	    fi
7235ee3138f1Smrg
723634977a2fSmrg	    test -n "$save_libobjs" &&
723734977a2fSmrg	      func_verbose "creating a temporary reloadable object file: $output"
7238ee3138f1Smrg
723934977a2fSmrg	    # Loop through the commands generated above and execute them.
724034977a2fSmrg	    save_ifs="$IFS"; IFS='~'
724134977a2fSmrg	    for cmd in $concat_cmds; do
724234977a2fSmrg	      IFS="$save_ifs"
724334977a2fSmrg	      $opt_silent || {
724434977a2fSmrg		  func_quote_for_expand "$cmd"
724534977a2fSmrg		  eval "func_echo $func_quote_for_expand_result"
724634977a2fSmrg	      }
724734977a2fSmrg	      $opt_dry_run || eval "$cmd" || {
724834977a2fSmrg		lt_exit=$?
724934977a2fSmrg
725034977a2fSmrg		# Restore the uninstalled library and exit
725134977a2fSmrg		if test "$mode" = relink; then
725234977a2fSmrg		  ( cd "$output_objdir" && \
725334977a2fSmrg		    $RM "${realname}T" && \
725434977a2fSmrg		    $MV "${realname}U" "$realname" )
725534977a2fSmrg		fi
7256ee3138f1Smrg
725734977a2fSmrg		exit $lt_exit
725834977a2fSmrg	      }
725934977a2fSmrg	    done
726034977a2fSmrg	    IFS="$save_ifs"
7261ee3138f1Smrg
726234977a2fSmrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
726334977a2fSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
726434977a2fSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
7265ee3138f1Smrg	    fi
7266ee3138f1Smrg	  fi
7267ee3138f1Smrg
726834977a2fSmrg          if ${skipped_export-false}; then
726934977a2fSmrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
727034977a2fSmrg	      tmp_export_symbols="$export_symbols"
727134977a2fSmrg	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
727234977a2fSmrg	      $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
727334977a2fSmrg	    fi
7274ee3138f1Smrg
727534977a2fSmrg	    if test -n "$orig_export_symbols"; then
727634977a2fSmrg	      # The given exports_symbols file has to be filtered, so filter it.
727734977a2fSmrg	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
727834977a2fSmrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
727934977a2fSmrg	      # 's' commands which not all seds can handle. GNU sed should be fine
728034977a2fSmrg	      # though. Also, the filter scales superlinearly with the number of
728134977a2fSmrg	      # global variables. join(1) would be nice here, but unfortunately
728234977a2fSmrg	      # isn't a blessed tool.
728334977a2fSmrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
728434977a2fSmrg	      delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
728534977a2fSmrg	      export_symbols=$output_objdir/$libname.def
728634977a2fSmrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
728734977a2fSmrg	    fi
728834977a2fSmrg	  fi
7289ee3138f1Smrg
729034977a2fSmrg	  libobjs=$output
729134977a2fSmrg	  # Restore the value of output.
729234977a2fSmrg	  output=$save_output
7293ee3138f1Smrg
729434977a2fSmrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
729534977a2fSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
729634977a2fSmrg	    test "X$libobjs" = "X " && libobjs=
729734977a2fSmrg	  fi
729834977a2fSmrg	  # Expand the library linking commands again to reset the
729934977a2fSmrg	  # value of $libobjs for piecewise linking.
7300ee3138f1Smrg
730134977a2fSmrg	  # Do each of the archive commands.
730234977a2fSmrg	  if test "$module" = yes && test -n "$module_cmds" ; then
730334977a2fSmrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
730434977a2fSmrg	      cmds=$module_expsym_cmds
730534977a2fSmrg	    else
730634977a2fSmrg	      cmds=$module_cmds
7307ee3138f1Smrg	    fi
7308ee3138f1Smrg	  else
730934977a2fSmrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
731034977a2fSmrg	      cmds=$archive_expsym_cmds
731134977a2fSmrg	    else
731234977a2fSmrg	      cmds=$archive_cmds
731334977a2fSmrg	    fi
7314ee3138f1Smrg	  fi
731534977a2fSmrg	fi
7316ee3138f1Smrg
731734977a2fSmrg	if test -n "$delfiles"; then
731834977a2fSmrg	  # Append the command to remove temporary files to $cmds.
731934977a2fSmrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
732034977a2fSmrg	fi
7321ee3138f1Smrg
732234977a2fSmrg	# Add any objects from preloaded convenience libraries
732334977a2fSmrg	if test -n "$dlprefiles"; then
732434977a2fSmrg	  gentop="$output_objdir/${outputname}x"
732534977a2fSmrg	  generated="$generated $gentop"
7326ee3138f1Smrg
732734977a2fSmrg	  func_extract_archives $gentop $dlprefiles
732834977a2fSmrg	  libobjs="$libobjs $func_extract_archives_result"
732934977a2fSmrg	  test "X$libobjs" = "X " && libobjs=
733034977a2fSmrg	fi
7331ee3138f1Smrg
733234977a2fSmrg	save_ifs="$IFS"; IFS='~'
733334977a2fSmrg	for cmd in $cmds; do
733434977a2fSmrg	  IFS="$save_ifs"
733534977a2fSmrg	  eval cmd=\"$cmd\"
733634977a2fSmrg	  $opt_silent || {
733734977a2fSmrg	    func_quote_for_expand "$cmd"
733834977a2fSmrg	    eval "func_echo $func_quote_for_expand_result"
733934977a2fSmrg	  }
734034977a2fSmrg	  $opt_dry_run || eval "$cmd" || {
734134977a2fSmrg	    lt_exit=$?
7342ee3138f1Smrg
734334977a2fSmrg	    # Restore the uninstalled library and exit
734434977a2fSmrg	    if test "$mode" = relink; then
734534977a2fSmrg	      ( cd "$output_objdir" && \
734634977a2fSmrg	        $RM "${realname}T" && \
734734977a2fSmrg		$MV "${realname}U" "$realname" )
734834977a2fSmrg	    fi
7349ee3138f1Smrg
735034977a2fSmrg	    exit $lt_exit
735134977a2fSmrg	  }
735234977a2fSmrg	done
735334977a2fSmrg	IFS="$save_ifs"
7354ee3138f1Smrg
735534977a2fSmrg	# Restore the uninstalled library and exit
735634977a2fSmrg	if test "$mode" = relink; then
735734977a2fSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
7358ee3138f1Smrg
735934977a2fSmrg	  if test -n "$convenience"; then
736034977a2fSmrg	    if test -z "$whole_archive_flag_spec"; then
736134977a2fSmrg	      func_show_eval '${RM}r "$gentop"'
736234977a2fSmrg	    fi
736334977a2fSmrg	  fi
7364ee3138f1Smrg
736534977a2fSmrg	  exit $EXIT_SUCCESS
736634977a2fSmrg	fi
736734977a2fSmrg
736834977a2fSmrg	# Create links to the real library.
736934977a2fSmrg	for linkname in $linknames; do
737034977a2fSmrg	  if test "$realname" != "$linkname"; then
737134977a2fSmrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
7372ee3138f1Smrg	  fi
7373ee3138f1Smrg	done
7374ee3138f1Smrg
737534977a2fSmrg	# If -module or -export-dynamic was specified, set the dlname.
737634977a2fSmrg	if test "$module" = yes || test "$export_dynamic" = yes; then
737734977a2fSmrg	  # On all known operating systems, these are identical.
737834977a2fSmrg	  dlname="$soname"
737934977a2fSmrg	fi
738034977a2fSmrg      fi
7381ee3138f1Smrg      ;;
7382ee3138f1Smrg
738334977a2fSmrg    obj)
738434977a2fSmrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
738534977a2fSmrg	func_warning "\`-dlopen' is ignored for objects"
738634977a2fSmrg      fi
7387ee3138f1Smrg
738834977a2fSmrg      case " $deplibs" in
738934977a2fSmrg      *\ -l* | *\ -L*)
739034977a2fSmrg	func_warning "\`-l' and \`-L' are ignored for objects" ;;
7391ee3138f1Smrg      esac
7392ee3138f1Smrg
739334977a2fSmrg      test -n "$rpath" && \
739434977a2fSmrg	func_warning "\`-rpath' is ignored for objects"
739534977a2fSmrg
739634977a2fSmrg      test -n "$xrpath" && \
739734977a2fSmrg	func_warning "\`-R' is ignored for objects"
7398ee3138f1Smrg
739934977a2fSmrg      test -n "$vinfo" && \
740034977a2fSmrg	func_warning "\`-version-info' is ignored for objects"
7401ee3138f1Smrg
740234977a2fSmrg      test -n "$release" && \
740334977a2fSmrg	func_warning "\`-release' is ignored for objects"
740434977a2fSmrg
740534977a2fSmrg      case $output in
740634977a2fSmrg      *.lo)
740734977a2fSmrg	test -n "$objs$old_deplibs" && \
740834977a2fSmrg	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
740934977a2fSmrg
741034977a2fSmrg	libobj=$output
741134977a2fSmrg	func_lo2o "$libobj"
741234977a2fSmrg	obj=$func_lo2o_result
7413ee3138f1Smrg	;;
7414ee3138f1Smrg      *)
741534977a2fSmrg	libobj=
741634977a2fSmrg	obj="$output"
7417ee3138f1Smrg	;;
7418ee3138f1Smrg      esac
7419ee3138f1Smrg
742034977a2fSmrg      # Delete the old objects.
742134977a2fSmrg      $opt_dry_run || $RM $obj $libobj
7422ee3138f1Smrg
742334977a2fSmrg      # Objects from convenience libraries.  This assumes
742434977a2fSmrg      # single-version convenience libraries.  Whenever we create
742534977a2fSmrg      # different ones for PIC/non-PIC, this we'll have to duplicate
742634977a2fSmrg      # the extraction.
742734977a2fSmrg      reload_conv_objs=
742834977a2fSmrg      gentop=
742934977a2fSmrg      # reload_cmds runs $LD directly, so let us get rid of
743034977a2fSmrg      # -Wl from whole_archive_flag_spec and hope we can get by with
743134977a2fSmrg      # turning comma into space..
743234977a2fSmrg      wl=
7433ee3138f1Smrg
743434977a2fSmrg      if test -n "$convenience"; then
743534977a2fSmrg	if test -n "$whole_archive_flag_spec"; then
743634977a2fSmrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
743734977a2fSmrg	  reload_conv_objs=$reload_objs\ `$ECHO "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'`
743834977a2fSmrg	else
743934977a2fSmrg	  gentop="$output_objdir/${obj}x"
744034977a2fSmrg	  generated="$generated $gentop"
7441ee3138f1Smrg
744234977a2fSmrg	  func_extract_archives $gentop $convenience
744334977a2fSmrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
744434977a2fSmrg	fi
7445ee3138f1Smrg      fi
7446ee3138f1Smrg
744734977a2fSmrg      # Create the old-style object.
744834977a2fSmrg      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
7449ee3138f1Smrg
745034977a2fSmrg      output="$obj"
745134977a2fSmrg      func_execute_cmds "$reload_cmds" 'exit $?'
7452ee3138f1Smrg
745334977a2fSmrg      # Exit if we aren't doing a library object file.
745434977a2fSmrg      if test -z "$libobj"; then
745534977a2fSmrg	if test -n "$gentop"; then
745634977a2fSmrg	  func_show_eval '${RM}r "$gentop"'
745734977a2fSmrg	fi
745834977a2fSmrg
745934977a2fSmrg	exit $EXIT_SUCCESS
7460ee3138f1Smrg      fi
746134977a2fSmrg
746234977a2fSmrg      if test "$build_libtool_libs" != yes; then
746334977a2fSmrg	if test -n "$gentop"; then
746434977a2fSmrg	  func_show_eval '${RM}r "$gentop"'
746534977a2fSmrg	fi
746634977a2fSmrg
746734977a2fSmrg	# Create an invalid libtool object if no PIC, so that we don't
746834977a2fSmrg	# accidentally link it into a program.
746934977a2fSmrg	# $show "echo timestamp > $libobj"
747034977a2fSmrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
747134977a2fSmrg	exit $EXIT_SUCCESS
747234977a2fSmrg      fi
747334977a2fSmrg
747434977a2fSmrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
747534977a2fSmrg	# Only do commands if we really have different PIC objects.
747634977a2fSmrg	reload_objs="$libobjs $reload_conv_objs"
747734977a2fSmrg	output="$libobj"
747834977a2fSmrg	func_execute_cmds "$reload_cmds" 'exit $?'
747934977a2fSmrg      fi
748034977a2fSmrg
748134977a2fSmrg      if test -n "$gentop"; then
748234977a2fSmrg	func_show_eval '${RM}r "$gentop"'
748334977a2fSmrg      fi
748434977a2fSmrg
748534977a2fSmrg      exit $EXIT_SUCCESS
7486ee3138f1Smrg      ;;
7487ee3138f1Smrg
748834977a2fSmrg    prog)
748934977a2fSmrg      case $host in
749034977a2fSmrg	*cygwin*) func_stripname '' '.exe' "$output"
749134977a2fSmrg	          output=$func_stripname_result.exe;;
749234977a2fSmrg      esac
749334977a2fSmrg      test -n "$vinfo" && \
749434977a2fSmrg	func_warning "\`-version-info' is ignored for programs"
7495ee3138f1Smrg
749634977a2fSmrg      test -n "$release" && \
749734977a2fSmrg	func_warning "\`-release' is ignored for programs"
7498ee3138f1Smrg
749934977a2fSmrg      test "$preload" = yes \
750034977a2fSmrg        && test "$dlopen_support" = unknown \
750134977a2fSmrg	&& test "$dlopen_self" = unknown \
750234977a2fSmrg	&& test "$dlopen_self_static" = unknown && \
750334977a2fSmrg	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
750434977a2fSmrg
750534977a2fSmrg      case $host in
750634977a2fSmrg      *-*-rhapsody* | *-*-darwin1.[012])
750734977a2fSmrg	# On Rhapsody replace the C library is the System framework
750834977a2fSmrg	compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
750934977a2fSmrg	finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
7510ee3138f1Smrg	;;
751134977a2fSmrg      esac
7512ee3138f1Smrg
751334977a2fSmrg      case $host in
751434977a2fSmrg      *-*-darwin*)
751534977a2fSmrg	# Don't allow lazy linking, it breaks C++ global constructors
751634977a2fSmrg	# But is supposedly fixed on 10.4 or later (yay!).
751734977a2fSmrg	if test "$tagname" = CXX ; then
751834977a2fSmrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
751934977a2fSmrg	    10.[0123])
752034977a2fSmrg	      compile_command="$compile_command ${wl}-bind_at_load"
752134977a2fSmrg	      finalize_command="$finalize_command ${wl}-bind_at_load"
752234977a2fSmrg	    ;;
752334977a2fSmrg	  esac
7524ee3138f1Smrg	fi
752534977a2fSmrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
752634977a2fSmrg	compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
752734977a2fSmrg	finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
752834977a2fSmrg	;;
752934977a2fSmrg      esac
7530ee3138f1Smrg
7531ee3138f1Smrg
753234977a2fSmrg      # move library search paths that coincide with paths to not yet
753334977a2fSmrg      # installed libraries to the beginning of the library search list
753434977a2fSmrg      new_libs=
753534977a2fSmrg      for path in $notinst_path; do
753634977a2fSmrg	case " $new_libs " in
753734977a2fSmrg	*" -L$path/$objdir "*) ;;
753834977a2fSmrg	*)
753934977a2fSmrg	  case " $compile_deplibs " in
754034977a2fSmrg	  *" -L$path/$objdir "*)
754134977a2fSmrg	    new_libs="$new_libs -L$path/$objdir" ;;
7542ee3138f1Smrg	  esac
754334977a2fSmrg	  ;;
754434977a2fSmrg	esac
754534977a2fSmrg      done
754634977a2fSmrg      for deplib in $compile_deplibs; do
754734977a2fSmrg	case $deplib in
754834977a2fSmrg	-L*)
754934977a2fSmrg	  case " $new_libs " in
755034977a2fSmrg	  *" $deplib "*) ;;
755134977a2fSmrg	  *) new_libs="$new_libs $deplib" ;;
7552ee3138f1Smrg	  esac
755334977a2fSmrg	  ;;
755434977a2fSmrg	*) new_libs="$new_libs $deplib" ;;
755534977a2fSmrg	esac
755634977a2fSmrg      done
755734977a2fSmrg      compile_deplibs="$new_libs"
7558ee3138f1Smrg
7559ee3138f1Smrg
756034977a2fSmrg      compile_command="$compile_command $compile_deplibs"
756134977a2fSmrg      finalize_command="$finalize_command $finalize_deplibs"
7562ee3138f1Smrg
756334977a2fSmrg      if test -n "$rpath$xrpath"; then
756434977a2fSmrg	# If the user specified any rpath flags, then add them.
756534977a2fSmrg	for libdir in $rpath $xrpath; do
756634977a2fSmrg	  # This is the magic to use -rpath.
756734977a2fSmrg	  case "$finalize_rpath " in
756834977a2fSmrg	  *" $libdir "*) ;;
756934977a2fSmrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
757034977a2fSmrg	  esac
757134977a2fSmrg	done
757234977a2fSmrg      fi
7573ee3138f1Smrg
757434977a2fSmrg      # Now hardcode the library paths
757534977a2fSmrg      rpath=
757634977a2fSmrg      hardcode_libdirs=
757734977a2fSmrg      for libdir in $compile_rpath $finalize_rpath; do
757834977a2fSmrg	if test -n "$hardcode_libdir_flag_spec"; then
757934977a2fSmrg	  if test -n "$hardcode_libdir_separator"; then
758034977a2fSmrg	    if test -z "$hardcode_libdirs"; then
758134977a2fSmrg	      hardcode_libdirs="$libdir"
758234977a2fSmrg	    else
758334977a2fSmrg	      # Just accumulate the unique libdirs.
758434977a2fSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
758534977a2fSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
758634977a2fSmrg		;;
758734977a2fSmrg	      *)
758834977a2fSmrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
758934977a2fSmrg		;;
759034977a2fSmrg	      esac
759134977a2fSmrg	    fi
7592ee3138f1Smrg	  else
759334977a2fSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
759434977a2fSmrg	    rpath="$rpath $flag"
7595ee3138f1Smrg	  fi
759634977a2fSmrg	elif test -n "$runpath_var"; then
759734977a2fSmrg	  case "$perm_rpath " in
759834977a2fSmrg	  *" $libdir "*) ;;
759934977a2fSmrg	  *) perm_rpath="$perm_rpath $libdir" ;;
760034977a2fSmrg	  esac
760134977a2fSmrg	fi
760234977a2fSmrg	case $host in
760334977a2fSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
760434977a2fSmrg	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
760534977a2fSmrg	  case :$dllsearchpath: in
760634977a2fSmrg	  *":$libdir:"*) ;;
760734977a2fSmrg	  ::) dllsearchpath=$libdir;;
760834977a2fSmrg	  *) dllsearchpath="$dllsearchpath:$libdir";;
760934977a2fSmrg	  esac
761034977a2fSmrg	  case :$dllsearchpath: in
761134977a2fSmrg	  *":$testbindir:"*) ;;
761234977a2fSmrg	  ::) dllsearchpath=$testbindir;;
761334977a2fSmrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
761434977a2fSmrg	  esac
761534977a2fSmrg	  ;;
761634977a2fSmrg	esac
761734977a2fSmrg      done
761834977a2fSmrg      # Substitute the hardcoded libdirs into the rpath.
761934977a2fSmrg      if test -n "$hardcode_libdir_separator" &&
762034977a2fSmrg	 test -n "$hardcode_libdirs"; then
762134977a2fSmrg	libdir="$hardcode_libdirs"
762234977a2fSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
762334977a2fSmrg      fi
762434977a2fSmrg      compile_rpath="$rpath"
7625ee3138f1Smrg
762634977a2fSmrg      rpath=
762734977a2fSmrg      hardcode_libdirs=
762834977a2fSmrg      for libdir in $finalize_rpath; do
762934977a2fSmrg	if test -n "$hardcode_libdir_flag_spec"; then
763034977a2fSmrg	  if test -n "$hardcode_libdir_separator"; then
763134977a2fSmrg	    if test -z "$hardcode_libdirs"; then
763234977a2fSmrg	      hardcode_libdirs="$libdir"
763334977a2fSmrg	    else
763434977a2fSmrg	      # Just accumulate the unique libdirs.
763534977a2fSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
763634977a2fSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
763734977a2fSmrg		;;
763834977a2fSmrg	      *)
763934977a2fSmrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
764034977a2fSmrg		;;
764134977a2fSmrg	      esac
764234977a2fSmrg	    fi
7643ee3138f1Smrg	  else
764434977a2fSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
764534977a2fSmrg	    rpath="$rpath $flag"
7646ee3138f1Smrg	  fi
764734977a2fSmrg	elif test -n "$runpath_var"; then
764834977a2fSmrg	  case "$finalize_perm_rpath " in
764934977a2fSmrg	  *" $libdir "*) ;;
765034977a2fSmrg	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
765134977a2fSmrg	  esac
7652ee3138f1Smrg	fi
765334977a2fSmrg      done
765434977a2fSmrg      # Substitute the hardcoded libdirs into the rpath.
765534977a2fSmrg      if test -n "$hardcode_libdir_separator" &&
765634977a2fSmrg	 test -n "$hardcode_libdirs"; then
765734977a2fSmrg	libdir="$hardcode_libdirs"
765834977a2fSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
765934977a2fSmrg      fi
766034977a2fSmrg      finalize_rpath="$rpath"
7661ee3138f1Smrg
766234977a2fSmrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
766334977a2fSmrg	# Transform all the library objects into standard objects.
766434977a2fSmrg	compile_command=`$ECHO "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
766534977a2fSmrg	finalize_command=`$ECHO "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
766634977a2fSmrg      fi
7667ee3138f1Smrg
766834977a2fSmrg      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
7669ee3138f1Smrg
767034977a2fSmrg      # template prelinking step
767134977a2fSmrg      if test -n "$prelink_cmds"; then
767234977a2fSmrg	func_execute_cmds "$prelink_cmds" 'exit $?'
767334977a2fSmrg      fi
7674ee3138f1Smrg
767534977a2fSmrg      wrappers_required=yes
767634977a2fSmrg      case $host in
767734977a2fSmrg      *cygwin* | *mingw* )
767834977a2fSmrg        if test "$build_libtool_libs" != yes; then
767934977a2fSmrg          wrappers_required=no
768034977a2fSmrg        fi
768134977a2fSmrg        ;;
768234977a2fSmrg      *cegcc)
768334977a2fSmrg        # Disable wrappers for cegcc, we are cross compiling anyway.
768434977a2fSmrg        wrappers_required=no
768534977a2fSmrg        ;;
768634977a2fSmrg      *)
768734977a2fSmrg        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
768834977a2fSmrg          wrappers_required=no
768934977a2fSmrg        fi
769034977a2fSmrg        ;;
769134977a2fSmrg      esac
769234977a2fSmrg      if test "$wrappers_required" = no; then
769334977a2fSmrg	# Replace the output file specification.
769434977a2fSmrg	compile_command=`$ECHO "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
769534977a2fSmrg	link_command="$compile_command$compile_rpath"
7696ee3138f1Smrg
769734977a2fSmrg	# We have no uninstalled library dependencies, so finalize right now.
769834977a2fSmrg	exit_status=0
769934977a2fSmrg	func_show_eval "$link_command" 'exit_status=$?'
7700ee3138f1Smrg
770134977a2fSmrg	# Delete the generated files.
770234977a2fSmrg	if test -f "$output_objdir/${outputname}S.${objext}"; then
770334977a2fSmrg	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
7704ee3138f1Smrg	fi
7705ee3138f1Smrg
770634977a2fSmrg	exit $exit_status
770734977a2fSmrg      fi
7708ee3138f1Smrg
770934977a2fSmrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
771034977a2fSmrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
771134977a2fSmrg      fi
771234977a2fSmrg      if test -n "$finalize_shlibpath"; then
771334977a2fSmrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
771434977a2fSmrg      fi
7715ee3138f1Smrg
771634977a2fSmrg      compile_var=
771734977a2fSmrg      finalize_var=
771834977a2fSmrg      if test -n "$runpath_var"; then
771934977a2fSmrg	if test -n "$perm_rpath"; then
772034977a2fSmrg	  # We should set the runpath_var.
772134977a2fSmrg	  rpath=
772234977a2fSmrg	  for dir in $perm_rpath; do
772334977a2fSmrg	    rpath="$rpath$dir:"
772434977a2fSmrg	  done
772534977a2fSmrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
7726ee3138f1Smrg	fi
772734977a2fSmrg	if test -n "$finalize_perm_rpath"; then
772834977a2fSmrg	  # We should set the runpath_var.
772934977a2fSmrg	  rpath=
773034977a2fSmrg	  for dir in $finalize_perm_rpath; do
773134977a2fSmrg	    rpath="$rpath$dir:"
773234977a2fSmrg	  done
773334977a2fSmrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
7734ee3138f1Smrg	fi
773534977a2fSmrg      fi
7736ee3138f1Smrg
773734977a2fSmrg      if test "$no_install" = yes; then
773834977a2fSmrg	# We don't need to create a wrapper script.
773934977a2fSmrg	link_command="$compile_var$compile_command$compile_rpath"
774034977a2fSmrg	# Replace the output file specification.
774134977a2fSmrg	link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
774234977a2fSmrg	# Delete the old output file.
774334977a2fSmrg	$opt_dry_run || $RM $output
774434977a2fSmrg	# Link the executable and exit
774534977a2fSmrg	func_show_eval "$link_command" 'exit $?'
7746ee3138f1Smrg	exit $EXIT_SUCCESS
774734977a2fSmrg      fi
7748ee3138f1Smrg
774934977a2fSmrg      if test "$hardcode_action" = relink; then
775034977a2fSmrg	# Fast installation is not supported
775134977a2fSmrg	link_command="$compile_var$compile_command$compile_rpath"
775234977a2fSmrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
775334977a2fSmrg
775434977a2fSmrg	func_warning "this platform does not like uninstalled shared libraries"
775534977a2fSmrg	func_warning "\`$output' will be relinked during installation"
775634977a2fSmrg      else
775734977a2fSmrg	if test "$fast_install" != no; then
775834977a2fSmrg	  link_command="$finalize_var$compile_command$finalize_rpath"
775934977a2fSmrg	  if test "$fast_install" = yes; then
776034977a2fSmrg	    relink_command=`$ECHO "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
776134977a2fSmrg	  else
776234977a2fSmrg	    # fast_install is set to needless
776334977a2fSmrg	    relink_command=
776434977a2fSmrg	  fi
7765ee3138f1Smrg	else
776634977a2fSmrg	  link_command="$compile_var$compile_command$compile_rpath"
776734977a2fSmrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
7768ee3138f1Smrg	fi
776934977a2fSmrg      fi
7770ee3138f1Smrg
777134977a2fSmrg      # Replace the output file specification.
777234977a2fSmrg      link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
7773ee3138f1Smrg
777434977a2fSmrg      # Delete the old output files.
777534977a2fSmrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
7776ee3138f1Smrg
777734977a2fSmrg      func_show_eval "$link_command" 'exit $?'
7778ee3138f1Smrg
777934977a2fSmrg      # Now create the wrapper script.
778034977a2fSmrg      func_verbose "creating $output"
7781ee3138f1Smrg
778234977a2fSmrg      # Quote the relink command for shipping.
778334977a2fSmrg      if test -n "$relink_command"; then
778434977a2fSmrg	# Preserve any variables that may affect compiler behavior
778534977a2fSmrg	for var in $variables_saved_for_relink; do
778634977a2fSmrg	  if eval test -z \"\${$var+set}\"; then
778734977a2fSmrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
778834977a2fSmrg	  elif eval var_value=\$$var; test -z "$var_value"; then
778934977a2fSmrg	    relink_command="$var=; export $var; $relink_command"
7790ee3138f1Smrg	  else
779134977a2fSmrg	    func_quote_for_eval "$var_value"
779234977a2fSmrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
7793ee3138f1Smrg	  fi
779434977a2fSmrg	done
779534977a2fSmrg	relink_command="(cd `pwd`; $relink_command)"
779634977a2fSmrg	relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
779734977a2fSmrg      fi
7798ee3138f1Smrg
779934977a2fSmrg      # Quote $ECHO for shipping.
780034977a2fSmrg      if test "X$ECHO" = "X$SHELL $progpath --fallback-echo"; then
780134977a2fSmrg	case $progpath in
780234977a2fSmrg	[\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
780334977a2fSmrg	*) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
780434977a2fSmrg	esac
780534977a2fSmrg	qecho=`$ECHO "X$qecho" | $Xsed -e "$sed_quote_subst"`
780634977a2fSmrg      else
780734977a2fSmrg	qecho=`$ECHO "X$ECHO" | $Xsed -e "$sed_quote_subst"`
780834977a2fSmrg      fi
780934977a2fSmrg
781034977a2fSmrg      # Only actually do things if not in dry run mode.
781134977a2fSmrg      $opt_dry_run || {
781234977a2fSmrg	# win32 will think the script is a binary if it has
781334977a2fSmrg	# a .exe suffix, so we strip it off here.
781434977a2fSmrg	case $output in
781534977a2fSmrg	  *.exe) func_stripname '' '.exe' "$output"
781634977a2fSmrg	         output=$func_stripname_result ;;
781734977a2fSmrg	esac
781834977a2fSmrg	# test for cygwin because mv fails w/o .exe extensions
781934977a2fSmrg	case $host in
782034977a2fSmrg	  *cygwin*)
782134977a2fSmrg	    exeext=.exe
782234977a2fSmrg	    func_stripname '' '.exe' "$outputname"
782334977a2fSmrg	    outputname=$func_stripname_result ;;
782434977a2fSmrg	  *) exeext= ;;
7825ee3138f1Smrg	esac
782634977a2fSmrg	case $host in
782734977a2fSmrg	  *cygwin* | *mingw* )
782834977a2fSmrg	    func_dirname_and_basename "$output" "" "."
782934977a2fSmrg	    output_name=$func_basename_result
783034977a2fSmrg	    output_path=$func_dirname_result
783134977a2fSmrg	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
783234977a2fSmrg	    cwrapper="$output_path/$output_name.exe"
783334977a2fSmrg	    $RM $cwrappersource $cwrapper
783434977a2fSmrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
783534977a2fSmrg
783634977a2fSmrg	    func_emit_cwrapperexe_src > $cwrappersource
783734977a2fSmrg
783834977a2fSmrg	    # The wrapper executable is built using the $host compiler,
783934977a2fSmrg	    # because it contains $host paths and files. If cross-
784034977a2fSmrg	    # compiling, it, like the target executable, must be
784134977a2fSmrg	    # executed on the $host or under an emulation environment.
784234977a2fSmrg	    $opt_dry_run || {
784334977a2fSmrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
784434977a2fSmrg	      $STRIP $cwrapper
784534977a2fSmrg	    }
7846ee3138f1Smrg
784734977a2fSmrg	    # Now, create the wrapper script for func_source use:
784834977a2fSmrg	    func_ltwrapper_scriptname $cwrapper
784934977a2fSmrg	    $RM $func_ltwrapper_scriptname_result
785034977a2fSmrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
785134977a2fSmrg	    $opt_dry_run || {
785234977a2fSmrg	      # note: this script will not be executed, so do not chmod.
785334977a2fSmrg	      if test "x$build" = "x$host" ; then
785434977a2fSmrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
785534977a2fSmrg	      else
785634977a2fSmrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
785734977a2fSmrg	      fi
785834977a2fSmrg	    }
785934977a2fSmrg	  ;;
786034977a2fSmrg	  * )
786134977a2fSmrg	    $RM $output
786234977a2fSmrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
7863ee3138f1Smrg
786434977a2fSmrg	    func_emit_wrapper no > $output
786534977a2fSmrg	    chmod +x $output
786634977a2fSmrg	  ;;
786734977a2fSmrg	esac
786834977a2fSmrg      }
786934977a2fSmrg      exit $EXIT_SUCCESS
787034977a2fSmrg      ;;
787134977a2fSmrg    esac
7872ee3138f1Smrg
787334977a2fSmrg    # See if we need to build an old-fashioned archive.
787434977a2fSmrg    for oldlib in $oldlibs; do
7875ee3138f1Smrg
787634977a2fSmrg      if test "$build_libtool_libs" = convenience; then
787734977a2fSmrg	oldobjs="$libobjs_save $symfileobj"
787834977a2fSmrg	addlibs="$convenience"
787934977a2fSmrg	build_libtool_libs=no
788034977a2fSmrg      else
788134977a2fSmrg	if test "$build_libtool_libs" = module; then
788234977a2fSmrg	  oldobjs="$libobjs_save"
788334977a2fSmrg	  build_libtool_libs=no
788434977a2fSmrg	else
788534977a2fSmrg	  oldobjs="$old_deplibs $non_pic_objects"
788634977a2fSmrg	  if test "$preload" = yes && test -f "$symfileobj"; then
788734977a2fSmrg	    oldobjs="$oldobjs $symfileobj"
788834977a2fSmrg	  fi
788934977a2fSmrg	fi
789034977a2fSmrg	addlibs="$old_convenience"
7891ee3138f1Smrg      fi
7892ee3138f1Smrg
789334977a2fSmrg      if test -n "$addlibs"; then
789434977a2fSmrg	gentop="$output_objdir/${outputname}x"
789534977a2fSmrg	generated="$generated $gentop"
7896ee3138f1Smrg
789734977a2fSmrg	func_extract_archives $gentop $addlibs
789834977a2fSmrg	oldobjs="$oldobjs $func_extract_archives_result"
789934977a2fSmrg      fi
7900ee3138f1Smrg
790134977a2fSmrg      # Do each command in the archive commands.
790234977a2fSmrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
790334977a2fSmrg	cmds=$old_archive_from_new_cmds
790434977a2fSmrg      else
7905ee3138f1Smrg
790634977a2fSmrg	# Add any objects from preloaded convenience libraries
790734977a2fSmrg	if test -n "$dlprefiles"; then
790834977a2fSmrg	  gentop="$output_objdir/${outputname}x"
790934977a2fSmrg	  generated="$generated $gentop"
7910ee3138f1Smrg
791134977a2fSmrg	  func_extract_archives $gentop $dlprefiles
791234977a2fSmrg	  oldobjs="$oldobjs $func_extract_archives_result"
791334977a2fSmrg	fi
7914ee3138f1Smrg
791534977a2fSmrg	# POSIX demands no paths to be encoded in archives.  We have
791634977a2fSmrg	# to avoid creating archives with duplicate basenames if we
791734977a2fSmrg	# might have to extract them afterwards, e.g., when creating a
791834977a2fSmrg	# static archive out of a convenience library, or when linking
791934977a2fSmrg	# the entirety of a libtool archive into another (currently
792034977a2fSmrg	# not supported by libtool).
792134977a2fSmrg	if (for obj in $oldobjs
792234977a2fSmrg	    do
792334977a2fSmrg	      func_basename "$obj"
792434977a2fSmrg	      $ECHO "$func_basename_result"
792534977a2fSmrg	    done | sort | sort -uc >/dev/null 2>&1); then
792634977a2fSmrg	  :
792734977a2fSmrg	else
792834977a2fSmrg	  $ECHO "copying selected object files to avoid basename conflicts..."
792934977a2fSmrg	  gentop="$output_objdir/${outputname}x"
793034977a2fSmrg	  generated="$generated $gentop"
793134977a2fSmrg	  func_mkdir_p "$gentop"
793234977a2fSmrg	  save_oldobjs=$oldobjs
793334977a2fSmrg	  oldobjs=
793434977a2fSmrg	  counter=1
793534977a2fSmrg	  for obj in $save_oldobjs
793634977a2fSmrg	  do
793734977a2fSmrg	    func_basename "$obj"
793834977a2fSmrg	    objbase="$func_basename_result"
793934977a2fSmrg	    case " $oldobjs " in
794034977a2fSmrg	    " ") oldobjs=$obj ;;
794134977a2fSmrg	    *[\ /]"$objbase "*)
794234977a2fSmrg	      while :; do
794334977a2fSmrg		# Make sure we don't pick an alternate name that also
794434977a2fSmrg		# overlaps.
794534977a2fSmrg		newobj=lt$counter-$objbase
794634977a2fSmrg		func_arith $counter + 1
794734977a2fSmrg		counter=$func_arith_result
794834977a2fSmrg		case " $oldobjs " in
794934977a2fSmrg		*[\ /]"$newobj "*) ;;
795034977a2fSmrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
795134977a2fSmrg		esac
795234977a2fSmrg	      done
795334977a2fSmrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
795434977a2fSmrg	      oldobjs="$oldobjs $gentop/$newobj"
795534977a2fSmrg	      ;;
795634977a2fSmrg	    *) oldobjs="$oldobjs $obj" ;;
795734977a2fSmrg	    esac
7958ee3138f1Smrg	  done
7959ee3138f1Smrg	fi
796034977a2fSmrg	eval cmds=\"$old_archive_cmds\"
7961ee3138f1Smrg
796234977a2fSmrg	func_len " $cmds"
796334977a2fSmrg	len=$func_len_result
796434977a2fSmrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
796534977a2fSmrg	  cmds=$old_archive_cmds
796634977a2fSmrg	else
796734977a2fSmrg	  # the command line is too long to link in one step, link in parts
796834977a2fSmrg	  func_verbose "using piecewise archive linking..."
796934977a2fSmrg	  save_RANLIB=$RANLIB
797034977a2fSmrg	  RANLIB=:
797134977a2fSmrg	  objlist=
797234977a2fSmrg	  concat_cmds=
797334977a2fSmrg	  save_oldobjs=$oldobjs
797434977a2fSmrg	  oldobjs=
797534977a2fSmrg	  # Is there a better way of finding the last object in the list?
797634977a2fSmrg	  for obj in $save_oldobjs
797734977a2fSmrg	  do
797834977a2fSmrg	    last_oldobj=$obj
797934977a2fSmrg	  done
798034977a2fSmrg	  eval test_cmds=\"$old_archive_cmds\"
798134977a2fSmrg	  func_len " $test_cmds"
798234977a2fSmrg	  len0=$func_len_result
798334977a2fSmrg	  len=$len0
798434977a2fSmrg	  for obj in $save_oldobjs
798534977a2fSmrg	  do
798634977a2fSmrg	    func_len " $obj"
798734977a2fSmrg	    func_arith $len + $func_len_result
798834977a2fSmrg	    len=$func_arith_result
798934977a2fSmrg	    func_append objlist " $obj"
799034977a2fSmrg	    if test "$len" -lt "$max_cmd_len"; then
799134977a2fSmrg	      :
799234977a2fSmrg	    else
799334977a2fSmrg	      # the above command should be used before it gets too long
799434977a2fSmrg	      oldobjs=$objlist
799534977a2fSmrg	      if test "$obj" = "$last_oldobj" ; then
799634977a2fSmrg		RANLIB=$save_RANLIB
799734977a2fSmrg	      fi
799834977a2fSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
799934977a2fSmrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
800034977a2fSmrg	      objlist=
800134977a2fSmrg	      len=$len0
800234977a2fSmrg	    fi
800334977a2fSmrg	  done
800434977a2fSmrg	  RANLIB=$save_RANLIB
800534977a2fSmrg	  oldobjs=$objlist
800634977a2fSmrg	  if test "X$oldobjs" = "X" ; then
800734977a2fSmrg	    eval cmds=\"\$concat_cmds\"
800834977a2fSmrg	  else
800934977a2fSmrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
801034977a2fSmrg	  fi
801134977a2fSmrg	fi
801234977a2fSmrg      fi
801334977a2fSmrg      func_execute_cmds "$cmds" 'exit $?'
8014ee3138f1Smrg    done
8015ee3138f1Smrg
801634977a2fSmrg    test -n "$generated" && \
801734977a2fSmrg      func_show_eval "${RM}r$generated"
8018ee3138f1Smrg
801934977a2fSmrg    # Now create the libtool archive.
802034977a2fSmrg    case $output in
802134977a2fSmrg    *.la)
802234977a2fSmrg      old_library=
802334977a2fSmrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
802434977a2fSmrg      func_verbose "creating $output"
8025ee3138f1Smrg
802634977a2fSmrg      # Preserve any variables that may affect compiler behavior
802734977a2fSmrg      for var in $variables_saved_for_relink; do
802834977a2fSmrg	if eval test -z \"\${$var+set}\"; then
802934977a2fSmrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
803034977a2fSmrg	elif eval var_value=\$$var; test -z "$var_value"; then
803134977a2fSmrg	  relink_command="$var=; export $var; $relink_command"
8032ee3138f1Smrg	else
803334977a2fSmrg	  func_quote_for_eval "$var_value"
803434977a2fSmrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
8035ee3138f1Smrg	fi
803634977a2fSmrg      done
803734977a2fSmrg      # Quote the link command for shipping.
803834977a2fSmrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
803934977a2fSmrg      relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
804034977a2fSmrg      if test "$hardcode_automatic" = yes ; then
804134977a2fSmrg	relink_command=
804234977a2fSmrg      fi
8043ee3138f1Smrg
804434977a2fSmrg      # Only create the output if not a dry run.
804534977a2fSmrg      $opt_dry_run || {
804634977a2fSmrg	for installed in no yes; do
804734977a2fSmrg	  if test "$installed" = yes; then
804834977a2fSmrg	    if test -z "$install_libdir"; then
804934977a2fSmrg	      break
805034977a2fSmrg	    fi
805134977a2fSmrg	    output="$output_objdir/$outputname"i
805234977a2fSmrg	    # Replace all uninstalled libtool libraries with the installed ones
805334977a2fSmrg	    newdependency_libs=
805434977a2fSmrg	    for deplib in $dependency_libs; do
805534977a2fSmrg	      case $deplib in
805634977a2fSmrg	      *.la)
805734977a2fSmrg		func_basename "$deplib"
805834977a2fSmrg		name="$func_basename_result"
805934977a2fSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
806034977a2fSmrg		test -z "$libdir" && \
806134977a2fSmrg		  func_fatal_error "\`$deplib' is not a valid libtool archive"
806234977a2fSmrg		newdependency_libs="$newdependency_libs $libdir/$name"
806334977a2fSmrg		;;
806434977a2fSmrg	      *) newdependency_libs="$newdependency_libs $deplib" ;;
806534977a2fSmrg	      esac
806634977a2fSmrg	    done
806734977a2fSmrg	    dependency_libs="$newdependency_libs"
806834977a2fSmrg	    newdlfiles=
806934977a2fSmrg
807034977a2fSmrg	    for lib in $dlfiles; do
807134977a2fSmrg	      case $lib in
807234977a2fSmrg	      *.la)
807334977a2fSmrg	        func_basename "$lib"
807434977a2fSmrg		name="$func_basename_result"
807534977a2fSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
807634977a2fSmrg		test -z "$libdir" && \
807734977a2fSmrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
807834977a2fSmrg		newdlfiles="$newdlfiles $libdir/$name"
807934977a2fSmrg		;;
808034977a2fSmrg	      *) newdlfiles="$newdlfiles $lib" ;;
808134977a2fSmrg	      esac
808234977a2fSmrg	    done
808334977a2fSmrg	    dlfiles="$newdlfiles"
808434977a2fSmrg	    newdlprefiles=
808534977a2fSmrg	    for lib in $dlprefiles; do
808634977a2fSmrg	      case $lib in
808734977a2fSmrg	      *.la)
808834977a2fSmrg		# Only pass preopened files to the pseudo-archive (for
808934977a2fSmrg		# eventual linking with the app. that links it) if we
809034977a2fSmrg		# didn't already link the preopened objects directly into
809134977a2fSmrg		# the library:
809234977a2fSmrg		func_basename "$lib"
809334977a2fSmrg		name="$func_basename_result"
809434977a2fSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
809534977a2fSmrg		test -z "$libdir" && \
809634977a2fSmrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
809734977a2fSmrg		newdlprefiles="$newdlprefiles $libdir/$name"
809834977a2fSmrg		;;
809934977a2fSmrg	      esac
810034977a2fSmrg	    done
810134977a2fSmrg	    dlprefiles="$newdlprefiles"
810234977a2fSmrg	  else
810334977a2fSmrg	    newdlfiles=
810434977a2fSmrg	    for lib in $dlfiles; do
810534977a2fSmrg	      case $lib in
810634977a2fSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
810734977a2fSmrg		*) abs=`pwd`"/$lib" ;;
810834977a2fSmrg	      esac
810934977a2fSmrg	      newdlfiles="$newdlfiles $abs"
811034977a2fSmrg	    done
811134977a2fSmrg	    dlfiles="$newdlfiles"
811234977a2fSmrg	    newdlprefiles=
811334977a2fSmrg	    for lib in $dlprefiles; do
811434977a2fSmrg	      case $lib in
811534977a2fSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
811634977a2fSmrg		*) abs=`pwd`"/$lib" ;;
811734977a2fSmrg	      esac
811834977a2fSmrg	      newdlprefiles="$newdlprefiles $abs"
811934977a2fSmrg	    done
812034977a2fSmrg	    dlprefiles="$newdlprefiles"
812134977a2fSmrg	  fi
812234977a2fSmrg	  $RM $output
812334977a2fSmrg	  # place dlname in correct position for cygwin
812434977a2fSmrg	  tdlname=$dlname
812534977a2fSmrg	  case $host,$output,$installed,$module,$dlname in
812634977a2fSmrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
812734977a2fSmrg	  esac
812834977a2fSmrg	  $ECHO > $output "\
812934977a2fSmrg# $outputname - a libtool library file
813034977a2fSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
813134977a2fSmrg#
813234977a2fSmrg# Please DO NOT delete this file!
813334977a2fSmrg# It is necessary for linking the library.
8134ee3138f1Smrg
813534977a2fSmrg# The name that we can dlopen(3).
813634977a2fSmrgdlname='$tdlname'
8137ee3138f1Smrg
813834977a2fSmrg# Names of this library.
813934977a2fSmrglibrary_names='$library_names'
8140ee3138f1Smrg
814134977a2fSmrg# The name of the static archive.
814234977a2fSmrgold_library='$old_library'
8143ee3138f1Smrg
814434977a2fSmrg# Linker flags that can not go in dependency_libs.
814534977a2fSmrginherited_linker_flags='$new_inherited_linker_flags'
8146ee3138f1Smrg
814734977a2fSmrg# Libraries that this one depends upon.
814834977a2fSmrgdependency_libs='$dependency_libs'
8149ee3138f1Smrg
815034977a2fSmrg# Names of additional weak libraries provided by this library
815134977a2fSmrgweak_library_names='$weak_libs'
8152ee3138f1Smrg
815334977a2fSmrg# Version information for $libname.
815434977a2fSmrgcurrent=$current
815534977a2fSmrgage=$age
815634977a2fSmrgrevision=$revision
8157ee3138f1Smrg
815834977a2fSmrg# Is this an already installed library?
815934977a2fSmrginstalled=$installed
8160ee3138f1Smrg
816134977a2fSmrg# Should we warn about portability when linking against -modules?
816234977a2fSmrgshouldnotlink=$module
8163ee3138f1Smrg
816434977a2fSmrg# Files to dlopen/dlpreopen
816534977a2fSmrgdlopen='$dlfiles'
816634977a2fSmrgdlpreopen='$dlprefiles'
8167ee3138f1Smrg
816834977a2fSmrg# Directory that this library needs to be installed in:
816934977a2fSmrglibdir='$install_libdir'"
817034977a2fSmrg	  if test "$installed" = no && test "$need_relink" = yes; then
817134977a2fSmrg	    $ECHO >> $output "\
817234977a2fSmrgrelink_command=\"$relink_command\""
817334977a2fSmrg	  fi
817434977a2fSmrg	done
817534977a2fSmrg      }
8176ee3138f1Smrg
817734977a2fSmrg      # Do a symbolic link so that the libtool archive can be found in
817834977a2fSmrg      # LD_LIBRARY_PATH before the program is installed.
817934977a2fSmrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
818034977a2fSmrg      ;;
818134977a2fSmrg    esac
818234977a2fSmrg    exit $EXIT_SUCCESS
818334977a2fSmrg}
8184ee3138f1Smrg
818534977a2fSmrg{ test "$mode" = link || test "$mode" = relink; } &&
818634977a2fSmrg    func_mode_link ${1+"$@"}
8187ee3138f1Smrg
8188ee3138f1Smrg
818934977a2fSmrg# func_mode_uninstall arg...
819034977a2fSmrgfunc_mode_uninstall ()
819134977a2fSmrg{
819234977a2fSmrg    $opt_debug
819334977a2fSmrg    RM="$nonopt"
8194ee3138f1Smrg    files=
8195ee3138f1Smrg    rmforce=
8196ee3138f1Smrg    exit_status=0
8197ee3138f1Smrg
8198ee3138f1Smrg    # This variable tells wrapper scripts just to set variables rather
8199ee3138f1Smrg    # than running their programs.
8200ee3138f1Smrg    libtool_install_magic="$magic"
8201ee3138f1Smrg
8202ee3138f1Smrg    for arg
8203ee3138f1Smrg    do
8204ee3138f1Smrg      case $arg in
820534977a2fSmrg      -f) RM="$RM $arg"; rmforce=yes ;;
820634977a2fSmrg      -*) RM="$RM $arg" ;;
8207ee3138f1Smrg      *) files="$files $arg" ;;
8208ee3138f1Smrg      esac
8209ee3138f1Smrg    done
8210ee3138f1Smrg
821134977a2fSmrg    test -z "$RM" && \
821234977a2fSmrg      func_fatal_help "you must specify an RM program"
8213ee3138f1Smrg
8214ee3138f1Smrg    rmdirs=
8215ee3138f1Smrg
8216ee3138f1Smrg    origobjdir="$objdir"
8217ee3138f1Smrg    for file in $files; do
821834977a2fSmrg      func_dirname "$file" "" "."
821934977a2fSmrg      dir="$func_dirname_result"
822034977a2fSmrg      if test "X$dir" = X.; then
8221ee3138f1Smrg	objdir="$origobjdir"
8222ee3138f1Smrg      else
8223ee3138f1Smrg	objdir="$dir/$origobjdir"
8224ee3138f1Smrg      fi
822534977a2fSmrg      func_basename "$file"
822634977a2fSmrg      name="$func_basename_result"
8227ee3138f1Smrg      test "$mode" = uninstall && objdir="$dir"
8228ee3138f1Smrg
8229ee3138f1Smrg      # Remember objdir for removal later, being careful to avoid duplicates
8230ee3138f1Smrg      if test "$mode" = clean; then
8231ee3138f1Smrg	case " $rmdirs " in
8232ee3138f1Smrg	  *" $objdir "*) ;;
8233ee3138f1Smrg	  *) rmdirs="$rmdirs $objdir" ;;
8234ee3138f1Smrg	esac
8235ee3138f1Smrg      fi
8236ee3138f1Smrg
8237ee3138f1Smrg      # Don't error if the file doesn't exist and rm -f was used.
823834977a2fSmrg      if { test -L "$file"; } >/dev/null 2>&1 ||
823934977a2fSmrg	 { test -h "$file"; } >/dev/null 2>&1 ||
824034977a2fSmrg	 test -f "$file"; then
8241ee3138f1Smrg	:
8242ee3138f1Smrg      elif test -d "$file"; then
8243ee3138f1Smrg	exit_status=1
8244ee3138f1Smrg	continue
8245ee3138f1Smrg      elif test "$rmforce" = yes; then
8246ee3138f1Smrg	continue
8247ee3138f1Smrg      fi
8248ee3138f1Smrg
8249ee3138f1Smrg      rmfiles="$file"
8250ee3138f1Smrg
8251ee3138f1Smrg      case $name in
8252ee3138f1Smrg      *.la)
8253ee3138f1Smrg	# Possibly a libtool archive, so verify it.
825434977a2fSmrg	if func_lalib_p "$file"; then
825534977a2fSmrg	  func_source $dir/$name
8256ee3138f1Smrg
8257ee3138f1Smrg	  # Delete the libtool libraries and symlinks.
8258ee3138f1Smrg	  for n in $library_names; do
8259ee3138f1Smrg	    rmfiles="$rmfiles $objdir/$n"
8260ee3138f1Smrg	  done
8261ee3138f1Smrg	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
8262ee3138f1Smrg
8263ee3138f1Smrg	  case "$mode" in
8264ee3138f1Smrg	  clean)
8265ee3138f1Smrg	    case "  $library_names " in
8266ee3138f1Smrg	    # "  " in the beginning catches empty $dlname
8267ee3138f1Smrg	    *" $dlname "*) ;;
8268ee3138f1Smrg	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
8269ee3138f1Smrg	    esac
827034977a2fSmrg	    test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
8271ee3138f1Smrg	    ;;
8272ee3138f1Smrg	  uninstall)
8273ee3138f1Smrg	    if test -n "$library_names"; then
8274ee3138f1Smrg	      # Do each command in the postuninstall commands.
827534977a2fSmrg	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
8276ee3138f1Smrg	    fi
8277ee3138f1Smrg
8278ee3138f1Smrg	    if test -n "$old_library"; then
8279ee3138f1Smrg	      # Do each command in the old_postuninstall commands.
828034977a2fSmrg	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
8281ee3138f1Smrg	    fi
8282ee3138f1Smrg	    # FIXME: should reinstall the best remaining shared library.
8283ee3138f1Smrg	    ;;
8284ee3138f1Smrg	  esac
8285ee3138f1Smrg	fi
8286ee3138f1Smrg	;;
8287ee3138f1Smrg
8288ee3138f1Smrg      *.lo)
8289ee3138f1Smrg	# Possibly a libtool object, so verify it.
829034977a2fSmrg	if func_lalib_p "$file"; then
8291ee3138f1Smrg
8292ee3138f1Smrg	  # Read the .lo file
829334977a2fSmrg	  func_source $dir/$name
8294ee3138f1Smrg
8295ee3138f1Smrg	  # Add PIC object to the list of files to remove.
829634977a2fSmrg	  if test -n "$pic_object" &&
829734977a2fSmrg	     test "$pic_object" != none; then
8298ee3138f1Smrg	    rmfiles="$rmfiles $dir/$pic_object"
8299ee3138f1Smrg	  fi
8300ee3138f1Smrg
8301ee3138f1Smrg	  # Add non-PIC object to the list of files to remove.
830234977a2fSmrg	  if test -n "$non_pic_object" &&
830334977a2fSmrg	     test "$non_pic_object" != none; then
8304ee3138f1Smrg	    rmfiles="$rmfiles $dir/$non_pic_object"
8305ee3138f1Smrg	  fi
8306ee3138f1Smrg	fi
8307ee3138f1Smrg	;;
8308ee3138f1Smrg
8309ee3138f1Smrg      *)
8310ee3138f1Smrg	if test "$mode" = clean ; then
8311ee3138f1Smrg	  noexename=$name
8312ee3138f1Smrg	  case $file in
8313ee3138f1Smrg	  *.exe)
831434977a2fSmrg	    func_stripname '' '.exe' "$file"
831534977a2fSmrg	    file=$func_stripname_result
831634977a2fSmrg	    func_stripname '' '.exe' "$name"
831734977a2fSmrg	    noexename=$func_stripname_result
8318ee3138f1Smrg	    # $file with .exe has already been added to rmfiles,
8319ee3138f1Smrg	    # add $file without .exe
8320ee3138f1Smrg	    rmfiles="$rmfiles $file"
8321ee3138f1Smrg	    ;;
8322ee3138f1Smrg	  esac
8323ee3138f1Smrg	  # Do a test to see if this is a libtool program.
832434977a2fSmrg	  if func_ltwrapper_p "$file"; then
832534977a2fSmrg	    if func_ltwrapper_executable_p "$file"; then
832634977a2fSmrg	      func_ltwrapper_scriptname "$file"
832734977a2fSmrg	      relink_command=
832834977a2fSmrg	      func_source $func_ltwrapper_scriptname_result
832934977a2fSmrg	      rmfiles="$rmfiles $func_ltwrapper_scriptname_result"
833034977a2fSmrg	    else
833134977a2fSmrg	      relink_command=
833234977a2fSmrg	      func_source $dir/$noexename
833334977a2fSmrg	    fi
8334ee3138f1Smrg
8335ee3138f1Smrg	    # note $name still contains .exe if it was in $file originally
8336ee3138f1Smrg	    # as does the version of $file that was added into $rmfiles
8337ee3138f1Smrg	    rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
8338ee3138f1Smrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
8339ee3138f1Smrg	      rmfiles="$rmfiles $objdir/lt-$name"
8340ee3138f1Smrg	    fi
8341ee3138f1Smrg	    if test "X$noexename" != "X$name" ; then
8342ee3138f1Smrg	      rmfiles="$rmfiles $objdir/lt-${noexename}.c"
8343ee3138f1Smrg	    fi
8344ee3138f1Smrg	  fi
8345ee3138f1Smrg	fi
8346ee3138f1Smrg	;;
8347ee3138f1Smrg      esac
834834977a2fSmrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
8349ee3138f1Smrg    done
8350ee3138f1Smrg    objdir="$origobjdir"
8351ee3138f1Smrg
8352ee3138f1Smrg    # Try to remove the ${objdir}s in the directories where we deleted files
8353ee3138f1Smrg    for dir in $rmdirs; do
8354ee3138f1Smrg      if test -d "$dir"; then
835534977a2fSmrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
8356ee3138f1Smrg      fi
8357ee3138f1Smrg    done
8358ee3138f1Smrg
8359ee3138f1Smrg    exit $exit_status
836034977a2fSmrg}
8361ee3138f1Smrg
836234977a2fSmrg{ test "$mode" = uninstall || test "$mode" = clean; } &&
836334977a2fSmrg    func_mode_uninstall ${1+"$@"}
8364ee3138f1Smrg
836534977a2fSmrgtest -z "$mode" && {
836634977a2fSmrg  help="$generic_help"
836734977a2fSmrg  func_fatal_help "you must specify a MODE"
836834977a2fSmrg}
836934977a2fSmrg
837034977a2fSmrgtest -z "$exec_cmd" && \
837134977a2fSmrg  func_fatal_help "invalid operation mode \`$mode'"
8372ee3138f1Smrg
8373ee3138f1Smrgif test -n "$exec_cmd"; then
837434977a2fSmrg  eval exec "$exec_cmd"
8375ee3138f1Smrg  exit $EXIT_FAILURE
8376ee3138f1Smrgfi
8377ee3138f1Smrg
837834977a2fSmrgexit $exit_status
8379ee3138f1Smrg
8380ee3138f1Smrg
8381ee3138f1Smrg# The TAGs below are defined such that we never get into a situation
8382ee3138f1Smrg# in which we disable both kinds of libraries.  Given conflicting
8383ee3138f1Smrg# choices, we go for a static library, that is the most portable,
8384ee3138f1Smrg# since we can't tell whether shared libraries were disabled because
8385ee3138f1Smrg# the user asked for that or because the platform doesn't support
8386ee3138f1Smrg# them.  This is particularly important on AIX, because we don't
8387ee3138f1Smrg# support having both static and shared libraries enabled at the same
8388ee3138f1Smrg# time on that platform, so we default to a shared-only configuration.
8389ee3138f1Smrg# If a disable-shared tag is given, we'll fallback to a static-only
8390ee3138f1Smrg# configuration.  But we'll never go from static-only to shared-only.
8391ee3138f1Smrg
8392ee3138f1Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
839334977a2fSmrgbuild_libtool_libs=no
839434977a2fSmrgbuild_old_libs=yes
8395ee3138f1Smrg# ### END LIBTOOL TAG CONFIG: disable-shared
8396ee3138f1Smrg
8397ee3138f1Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
839834977a2fSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
8399ee3138f1Smrg# ### END LIBTOOL TAG CONFIG: disable-static
8400ee3138f1Smrg
8401ee3138f1Smrg# Local Variables:
8402ee3138f1Smrg# mode:shell-script
8403ee3138f1Smrg# sh-indentation:2
8404ee3138f1Smrg# End:
840534977a2fSmrg# vi:sw=2
840634977a2fSmrg
8407