ltmain.sh revision 786a6f21
1786a6f21Smrg# Generated from ltmain.m4sh.
2786a6f21Smrg
3786a6f21Smrg# ltmain.sh (GNU libtool) 2.2.6
4786a6f21Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
5786a6f21Smrg
6786a6f21Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 Free Software Foundation, Inc.
7786a6f21Smrg# This is free software; see the source for copying conditions.  There is NO
8786a6f21Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9786a6f21Smrg
10786a6f21Smrg# GNU Libtool is free software; you can redistribute it and/or modify
111d54945dSmrg# it under the terms of the GNU General Public License as published by
121d54945dSmrg# the Free Software Foundation; either version 2 of the License, or
131d54945dSmrg# (at your option) any later version.
141d54945dSmrg#
15786a6f21Smrg# As a special exception to the GNU General Public License,
16786a6f21Smrg# if you distribute this file as part of a program or library that
17786a6f21Smrg# is built using GNU Libtool, you may include this file under the
18786a6f21Smrg# same distribution terms that you use for the rest of that program.
19786a6f21Smrg#
20786a6f21Smrg# GNU Libtool is distributed in the hope that it will be useful, but
211d54945dSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
221d54945dSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
231d54945dSmrg# General Public License for more details.
241d54945dSmrg#
251d54945dSmrg# You should have received a copy of the GNU General Public License
26786a6f21Smrg# along with GNU Libtool; see the file COPYING.  If not, a copy
27786a6f21Smrg# can be downloaded from http://www.gnu.org/licenses/gpl.html,
28786a6f21Smrg# or obtained by writing to the Free Software Foundation, Inc.,
29786a6f21Smrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
301d54945dSmrg
31786a6f21Smrg# Usage: $progname [OPTION]... [MODE-ARG]...
32786a6f21Smrg#
33786a6f21Smrg# Provide generalized library-building support services.
34786a6f21Smrg#
35786a6f21Smrg#     --config             show all configuration variables
36786a6f21Smrg#     --debug              enable verbose shell tracing
37786a6f21Smrg# -n, --dry-run            display commands without modifying any files
38786a6f21Smrg#     --features           display basic configuration information and exit
39786a6f21Smrg#     --mode=MODE          use operation mode MODE
40786a6f21Smrg#     --preserve-dup-deps  don't remove duplicate dependency libraries
41786a6f21Smrg#     --quiet, --silent    don't print informational messages
42786a6f21Smrg#     --tag=TAG            use configuration variables from tag TAG
43786a6f21Smrg# -v, --verbose            print informational messages (default)
44786a6f21Smrg#     --version            print version information
45786a6f21Smrg# -h, --help               print short or long help message
46786a6f21Smrg#
47786a6f21Smrg# MODE must be one of the following:
48786a6f21Smrg#
49786a6f21Smrg#       clean              remove files from the build directory
50786a6f21Smrg#       compile            compile a source file into a libtool object
51786a6f21Smrg#       execute            automatically set library path, then run a program
52786a6f21Smrg#       finish             complete the installation of libtool libraries
53786a6f21Smrg#       install            install libraries or executables
54786a6f21Smrg#       link               create a library or an executable
55786a6f21Smrg#       uninstall          remove libraries from an installed directory
56786a6f21Smrg#
57786a6f21Smrg# MODE-ARGS vary depending on the MODE.
58786a6f21Smrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
59786a6f21Smrg#
60786a6f21Smrg# When reporting a bug, please describe a test case to reproduce it and
61786a6f21Smrg# include the following information:
62786a6f21Smrg#
63786a6f21Smrg#       host-triplet:	$host
64786a6f21Smrg#       shell:		$SHELL
65786a6f21Smrg#       compiler:		$LTCC
66786a6f21Smrg#       compiler flags:		$LTCFLAGS
67786a6f21Smrg#       linker:		$LD (gnu? $with_gnu_ld)
68786a6f21Smrg#       $progname:		(GNU libtool) 2.2.6
69786a6f21Smrg#       automake:		$automake_version
70786a6f21Smrg#       autoconf:		$autoconf_version
71786a6f21Smrg#
72786a6f21Smrg# Report bugs to <bug-libtool@gnu.org>.
731d54945dSmrg
741d54945dSmrgPROGRAM=ltmain.sh
751d54945dSmrgPACKAGE=libtool
76786a6f21SmrgVERSION=2.2.6
77786a6f21SmrgTIMESTAMP=""
78786a6f21Smrgpackage_revision=1.3012
791d54945dSmrg
80786a6f21Smrg# Be Bourne compatible
81ba85709eSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
82ba85709eSmrg  emulate sh
83ba85709eSmrg  NULLCMD=:
84ba85709eSmrg  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
85ba85709eSmrg  # is contrary to our usage.  Disable this feature.
86ba85709eSmrg  alias -g '${1+"$@"}'='"$@"'
871d54945dSmrg  setopt NO_GLOB_SUBST
88ba85709eSmrgelse
89ba85709eSmrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
901d54945dSmrgfi
91786a6f21SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
92786a6f21SmrgDUALCASE=1; export DUALCASE # for MKS sh
931d54945dSmrg
94786a6f21Smrg# NLS nuisances: We save the old values to restore during execute mode.
951d54945dSmrg# Only set LANG and LC_ALL to C if already set.
961d54945dSmrg# These must not be set unconditionally because not all systems understand
971d54945dSmrg# e.g. LANG=C (notably SCO).
98786a6f21Smrglt_user_locale=
99786a6f21Smrglt_safe_locale=
100786a6f21Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
101ba85709eSmrgdo
102ba85709eSmrg  eval "if test \"\${$lt_var+set}\" = set; then
103786a6f21Smrg          save_$lt_var=\$$lt_var
104786a6f21Smrg          $lt_var=C
105786a6f21Smrg	  export $lt_var
106786a6f21Smrg	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
107786a6f21Smrg	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
108786a6f21Smrg	fi"
109ba85709eSmrgdone
1101d54945dSmrg
111786a6f21Smrg$lt_unset CDPATH
112786a6f21Smrg
113786a6f21Smrg
114786a6f21Smrg
115786a6f21Smrg
116786a6f21Smrg
117786a6f21Smrg: ${CP="cp -f"}
118786a6f21Smrg: ${ECHO="echo"}
119786a6f21Smrg: ${EGREP="/bin/grep -E"}
120786a6f21Smrg: ${FGREP="/bin/grep -F"}
121786a6f21Smrg: ${GREP="/bin/grep"}
122786a6f21Smrg: ${LN_S="ln -s"}
123786a6f21Smrg: ${MAKE="make"}
124786a6f21Smrg: ${MKDIR="mkdir"}
125786a6f21Smrg: ${MV="mv -f"}
126786a6f21Smrg: ${RM="rm -f"}
127786a6f21Smrg: ${SED="/bin/sed"}
128786a6f21Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
129786a6f21Smrg: ${Xsed="$SED -e 1s/^X//"}
130786a6f21Smrg
131786a6f21Smrg# Global variables:
132786a6f21SmrgEXIT_SUCCESS=0
133786a6f21SmrgEXIT_FAILURE=1
134786a6f21SmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
135786a6f21SmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
136786a6f21Smrg
137786a6f21Smrgexit_status=$EXIT_SUCCESS
138786a6f21Smrg
1391d54945dSmrg# Make sure IFS has a sensible default
1401d54945dSmrglt_nl='
1411d54945dSmrg'
1421d54945dSmrgIFS=" 	$lt_nl"
1431d54945dSmrg
144786a6f21Smrgdirname="s,/[^/]*$,,"
145786a6f21Smrgbasename="s,^.*/,,"
146786a6f21Smrg
147786a6f21Smrg# func_dirname_and_basename file append nondir_replacement
148786a6f21Smrg# perform func_basename and func_dirname in a single function
149786a6f21Smrg# call:
150786a6f21Smrg#   dirname:  Compute the dirname of FILE.  If nonempty,
151786a6f21Smrg#             add APPEND to the result, otherwise set result
152786a6f21Smrg#             to NONDIR_REPLACEMENT.
153786a6f21Smrg#             value returned in "$func_dirname_result"
154786a6f21Smrg#   basename: Compute filename of FILE.
155786a6f21Smrg#             value retuned in "$func_basename_result"
156786a6f21Smrg# Implementation must be kept synchronized with func_dirname
157786a6f21Smrg# and func_basename. For efficiency, we do not delegate to
158786a6f21Smrg# those functions but instead duplicate the functionality here.
159786a6f21Smrgfunc_dirname_and_basename ()
160786a6f21Smrg{
161786a6f21Smrg  # Extract subdirectory from the argument.
162786a6f21Smrg  func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
163786a6f21Smrg  if test "X$func_dirname_result" = "X${1}"; then
164786a6f21Smrg    func_dirname_result="${3}"
165786a6f21Smrg  else
166786a6f21Smrg    func_dirname_result="$func_dirname_result${2}"
167786a6f21Smrg  fi
168786a6f21Smrg  func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
169786a6f21Smrg}
1701d54945dSmrg
171786a6f21Smrg# Generated shell functions inserted here.
172786a6f21Smrg
173786a6f21Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
174786a6f21Smrg# is ksh but when the shell is invoked as "sh" and the current value of
175786a6f21Smrg# the _XPG environment variable is not equal to 1 (one), the special
176786a6f21Smrg# positional parameter $0, within a function call, is the name of the
177786a6f21Smrg# function.
178786a6f21Smrgprogpath="$0"
179786a6f21Smrg
180786a6f21Smrg# The name of this program:
181786a6f21Smrg# In the unlikely event $progname began with a '-', it would play havoc with
182786a6f21Smrg# func_echo (imagine progname=-n), so we prepend ./ in that case:
183786a6f21Smrgfunc_dirname_and_basename "$progpath"
184786a6f21Smrgprogname=$func_basename_result
185786a6f21Smrgcase $progname in
186786a6f21Smrg  -*) progname=./$progname ;;
187786a6f21Smrgesac
188786a6f21Smrg
189786a6f21Smrg# Make sure we have an absolute path for reexecution:
190786a6f21Smrgcase $progpath in
191786a6f21Smrg  [\\/]*|[A-Za-z]:\\*) ;;
192786a6f21Smrg  *[\\/]*)
193786a6f21Smrg     progdir=$func_dirname_result
194786a6f21Smrg     progdir=`cd "$progdir" && pwd`
195786a6f21Smrg     progpath="$progdir/$progname"
196786a6f21Smrg     ;;
197786a6f21Smrg  *)
198786a6f21Smrg     save_IFS="$IFS"
199786a6f21Smrg     IFS=:
200786a6f21Smrg     for progdir in $PATH; do
201786a6f21Smrg       IFS="$save_IFS"
202786a6f21Smrg       test -x "$progdir/$progname" && break
203786a6f21Smrg     done
204786a6f21Smrg     IFS="$save_IFS"
205786a6f21Smrg     test -n "$progdir" || progdir=`pwd`
206786a6f21Smrg     progpath="$progdir/$progname"
207786a6f21Smrg     ;;
208786a6f21Smrgesac
209786a6f21Smrg
210786a6f21Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
211786a6f21Smrg# metacharacters that are still active within double-quoted strings.
212786a6f21SmrgXsed="${SED}"' -e 1s/^X//'
213786a6f21Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g'
214786a6f21Smrg
215786a6f21Smrg# Same as above, but do not quote variable references.
216786a6f21Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g'
217786a6f21Smrg
218786a6f21Smrg# Re-`\' parameter expansions in output of double_quote_subst that were
219786a6f21Smrg# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
220786a6f21Smrg# in input to double_quote_subst, that '$' was protected from expansion.
221786a6f21Smrg# Since each input `\' is now two `\'s, look for any number of runs of
222786a6f21Smrg# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
223786a6f21Smrgbs='\\'
224786a6f21Smrgbs2='\\\\'
225786a6f21Smrgbs4='\\\\\\\\'
226786a6f21Smrgdollar='\$'
227786a6f21Smrgsed_double_backslash="\
228786a6f21Smrg  s/$bs4/&\\
229786a6f21Smrg/g
230786a6f21Smrg  s/^$bs2$dollar/$bs&/
231786a6f21Smrg  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
232786a6f21Smrg  s/\n//g"
233786a6f21Smrg
234786a6f21Smrg# Standard options:
235786a6f21Smrgopt_dry_run=false
236786a6f21Smrgopt_help=false
237786a6f21Smrgopt_quiet=false
238786a6f21Smrgopt_verbose=false
239786a6f21Smrgopt_warning=:
240786a6f21Smrg
241786a6f21Smrg# func_echo arg...
242786a6f21Smrg# Echo program name prefixed message, along with the current mode
243786a6f21Smrg# name if it has been set yet.
244786a6f21Smrgfunc_echo ()
245786a6f21Smrg{
246786a6f21Smrg    $ECHO "$progname${mode+: }$mode: $*"
247786a6f21Smrg}
248786a6f21Smrg
249786a6f21Smrg# func_verbose arg...
250786a6f21Smrg# Echo program name prefixed message in verbose mode only.
251786a6f21Smrgfunc_verbose ()
252786a6f21Smrg{
253786a6f21Smrg    $opt_verbose && func_echo ${1+"$@"}
254786a6f21Smrg
255786a6f21Smrg    # A bug in bash halts the script if the last line of a function
256786a6f21Smrg    # fails when set -e is in force, so we need another command to
257786a6f21Smrg    # work around that:
258786a6f21Smrg    :
259786a6f21Smrg}
260786a6f21Smrg
261786a6f21Smrg# func_error arg...
262786a6f21Smrg# Echo program name prefixed message to standard error.
263786a6f21Smrgfunc_error ()
264786a6f21Smrg{
265786a6f21Smrg    $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2
266786a6f21Smrg}
267786a6f21Smrg
268786a6f21Smrg# func_warning arg...
269786a6f21Smrg# Echo program name prefixed warning message to standard error.
270786a6f21Smrgfunc_warning ()
271786a6f21Smrg{
272786a6f21Smrg    $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2
273786a6f21Smrg
274786a6f21Smrg    # bash bug again:
275786a6f21Smrg    :
276786a6f21Smrg}
277786a6f21Smrg
278786a6f21Smrg# func_fatal_error arg...
279786a6f21Smrg# Echo program name prefixed message to standard error, and exit.
280786a6f21Smrgfunc_fatal_error ()
281786a6f21Smrg{
282786a6f21Smrg    func_error ${1+"$@"}
283786a6f21Smrg    exit $EXIT_FAILURE
284786a6f21Smrg}
285786a6f21Smrg
286786a6f21Smrg# func_fatal_help arg...
287786a6f21Smrg# Echo program name prefixed message to standard error, followed by
288786a6f21Smrg# a help hint, and exit.
289786a6f21Smrgfunc_fatal_help ()
290786a6f21Smrg{
291786a6f21Smrg    func_error ${1+"$@"}
292786a6f21Smrg    func_fatal_error "$help"
293786a6f21Smrg}
294786a6f21Smrghelp="Try \`$progname --help' for more information."  ## default
295786a6f21Smrg
296786a6f21Smrg
297786a6f21Smrg# func_grep expression filename
298786a6f21Smrg# Check whether EXPRESSION matches any line of FILENAME, without output.
299786a6f21Smrgfunc_grep ()
300786a6f21Smrg{
301786a6f21Smrg    $GREP "$1" "$2" >/dev/null 2>&1
302786a6f21Smrg}
303786a6f21Smrg
304786a6f21Smrg
305786a6f21Smrg# func_mkdir_p directory-path
306786a6f21Smrg# Make sure the entire path to DIRECTORY-PATH is available.
307786a6f21Smrgfunc_mkdir_p ()
308786a6f21Smrg{
309786a6f21Smrg    my_directory_path="$1"
310786a6f21Smrg    my_dir_list=
311786a6f21Smrg
312786a6f21Smrg    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
313786a6f21Smrg
314786a6f21Smrg      # Protect directory names starting with `-'
315786a6f21Smrg      case $my_directory_path in
316786a6f21Smrg        -*) my_directory_path="./$my_directory_path" ;;
317786a6f21Smrg      esac
318786a6f21Smrg
319786a6f21Smrg      # While some portion of DIR does not yet exist...
320786a6f21Smrg      while test ! -d "$my_directory_path"; do
321786a6f21Smrg        # ...make a list in topmost first order.  Use a colon delimited
322786a6f21Smrg	# list incase some portion of path contains whitespace.
323786a6f21Smrg        my_dir_list="$my_directory_path:$my_dir_list"
324786a6f21Smrg
325786a6f21Smrg        # If the last portion added has no slash in it, the list is done
326786a6f21Smrg        case $my_directory_path in */*) ;; *) break ;; esac
327786a6f21Smrg
328786a6f21Smrg        # ...otherwise throw away the child directory and loop
329786a6f21Smrg        my_directory_path=`$ECHO "X$my_directory_path" | $Xsed -e "$dirname"`
330786a6f21Smrg      done
331786a6f21Smrg      my_dir_list=`$ECHO "X$my_dir_list" | $Xsed -e 's,:*$,,'`
332786a6f21Smrg
333786a6f21Smrg      save_mkdir_p_IFS="$IFS"; IFS=':'
334786a6f21Smrg      for my_dir in $my_dir_list; do
335786a6f21Smrg	IFS="$save_mkdir_p_IFS"
336786a6f21Smrg        # mkdir can fail with a `File exist' error if two processes
337786a6f21Smrg        # try to create one of the directories concurrently.  Don't
338786a6f21Smrg        # stop in that case!
339786a6f21Smrg        $MKDIR "$my_dir" 2>/dev/null || :
340786a6f21Smrg      done
341786a6f21Smrg      IFS="$save_mkdir_p_IFS"
342786a6f21Smrg
343786a6f21Smrg      # Bail out if we (or some other process) failed to create a directory.
344786a6f21Smrg      test -d "$my_directory_path" || \
345786a6f21Smrg        func_fatal_error "Failed to create \`$1'"
346786a6f21Smrg    fi
347786a6f21Smrg}
3481d54945dSmrg
3491d54945dSmrg
3501d54945dSmrg# func_mktempdir [string]
3511d54945dSmrg# Make a temporary directory that won't clash with other running
3521d54945dSmrg# libtool processes, and avoids race conditions if possible.  If
3531d54945dSmrg# given, STRING is the basename for that directory.
3541d54945dSmrgfunc_mktempdir ()
3551d54945dSmrg{
3561d54945dSmrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
3571d54945dSmrg
358786a6f21Smrg    if test "$opt_dry_run" = ":"; then
3591d54945dSmrg      # Return a directory name, but don't create it in dry-run mode
3601d54945dSmrg      my_tmpdir="${my_template}-$$"
3611d54945dSmrg    else
3621d54945dSmrg
3631d54945dSmrg      # If mktemp works, use that first and foremost
3641d54945dSmrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
3651d54945dSmrg
3661d54945dSmrg      if test ! -d "$my_tmpdir"; then
367786a6f21Smrg        # Failing that, at least try and use $RANDOM to avoid a race
368786a6f21Smrg        my_tmpdir="${my_template}-${RANDOM-0}$$"
3691d54945dSmrg
370786a6f21Smrg        save_mktempdir_umask=`umask`
371786a6f21Smrg        umask 0077
372786a6f21Smrg        $MKDIR "$my_tmpdir"
373786a6f21Smrg        umask $save_mktempdir_umask
3741d54945dSmrg      fi
3751d54945dSmrg
3761d54945dSmrg      # If we're not in dry-run mode, bomb out on failure
377786a6f21Smrg      test -d "$my_tmpdir" || \
378786a6f21Smrg        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
3791d54945dSmrg    fi
3801d54945dSmrg
381786a6f21Smrg    $ECHO "X$my_tmpdir" | $Xsed
3821d54945dSmrg}
3831d54945dSmrg
3841d54945dSmrg
385786a6f21Smrg# func_quote_for_eval arg
386786a6f21Smrg# Aesthetically quote ARG to be evaled later.
387786a6f21Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
388786a6f21Smrg# is double-quoted, suitable for a subsequent eval, whereas
389786a6f21Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
390786a6f21Smrg# which are still active within double quotes backslashified.
391786a6f21Smrgfunc_quote_for_eval ()
3921d54945dSmrg{
393786a6f21Smrg    case $1 in
394786a6f21Smrg      *[\\\`\"\$]*)
395786a6f21Smrg	func_quote_for_eval_unquoted_result=`$ECHO "X$1" | $Xsed -e "$sed_quote_subst"` ;;
396786a6f21Smrg      *)
397786a6f21Smrg        func_quote_for_eval_unquoted_result="$1" ;;
398786a6f21Smrg    esac
399786a6f21Smrg
400786a6f21Smrg    case $func_quote_for_eval_unquoted_result in
401786a6f21Smrg      # Double-quote args containing shell metacharacters to delay
402786a6f21Smrg      # word splitting, command substitution and and variable
403786a6f21Smrg      # expansion for a subsequent eval.
404786a6f21Smrg      # Many Bourne shells cannot handle close brackets correctly
405786a6f21Smrg      # in scan sets, so we specify it separately.
406786a6f21Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
407786a6f21Smrg        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
408786a6f21Smrg        ;;
409786a6f21Smrg      *)
410786a6f21Smrg        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
4111d54945dSmrg    esac
4121d54945dSmrg}
4131d54945dSmrg
4141d54945dSmrg
415786a6f21Smrg# func_quote_for_expand arg
416786a6f21Smrg# Aesthetically quote ARG to be evaled later; same as above,
417786a6f21Smrg# but do not quote variable references.
418786a6f21Smrgfunc_quote_for_expand ()
4191d54945dSmrg{
420786a6f21Smrg    case $1 in
421786a6f21Smrg      *[\\\`\"]*)
422786a6f21Smrg	my_arg=`$ECHO "X$1" | $Xsed \
423786a6f21Smrg	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
4241d54945dSmrg      *)
425786a6f21Smrg        my_arg="$1" ;;
426786a6f21Smrg    esac
427786a6f21Smrg
428786a6f21Smrg    case $my_arg in
429786a6f21Smrg      # Double-quote args containing shell metacharacters to delay
430786a6f21Smrg      # word splitting and command substitution for a subsequent eval.
431786a6f21Smrg      # Many Bourne shells cannot handle close brackets correctly
432786a6f21Smrg      # in scan sets, so we specify it separately.
433786a6f21Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
434786a6f21Smrg        my_arg="\"$my_arg\""
435786a6f21Smrg        ;;
436786a6f21Smrg    esac
437786a6f21Smrg
438786a6f21Smrg    func_quote_for_expand_result="$my_arg"
4391d54945dSmrg}
4401d54945dSmrg
4411d54945dSmrg
442786a6f21Smrg# func_show_eval cmd [fail_exp]
443786a6f21Smrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
444786a6f21Smrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
445786a6f21Smrg# is given, then evaluate it.
446786a6f21Smrgfunc_show_eval ()
4471d54945dSmrg{
448786a6f21Smrg    my_cmd="$1"
449786a6f21Smrg    my_fail_exp="${2-:}"
4501d54945dSmrg
451786a6f21Smrg    ${opt_silent-false} || {
452786a6f21Smrg      func_quote_for_expand "$my_cmd"
453786a6f21Smrg      eval "func_echo $func_quote_for_expand_result"
454786a6f21Smrg    }
455786a6f21Smrg
456786a6f21Smrg    if ${opt_dry_run-false}; then :; else
457786a6f21Smrg      eval "$my_cmd"
458786a6f21Smrg      my_status=$?
459786a6f21Smrg      if test "$my_status" -eq 0; then :; else
460786a6f21Smrg	eval "(exit $my_status); $my_fail_exp"
461786a6f21Smrg      fi
4621d54945dSmrg    fi
4631d54945dSmrg}
4641d54945dSmrg
465786a6f21Smrg
466786a6f21Smrg# func_show_eval_locale cmd [fail_exp]
467786a6f21Smrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
468786a6f21Smrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
469786a6f21Smrg# is given, then evaluate it.  Use the saved locale for evaluation.
470786a6f21Smrgfunc_show_eval_locale ()
4711d54945dSmrg{
472786a6f21Smrg    my_cmd="$1"
473786a6f21Smrg    my_fail_exp="${2-:}"
474786a6f21Smrg
475786a6f21Smrg    ${opt_silent-false} || {
476786a6f21Smrg      func_quote_for_expand "$my_cmd"
477786a6f21Smrg      eval "func_echo $func_quote_for_expand_result"
478786a6f21Smrg    }
479786a6f21Smrg
480786a6f21Smrg    if ${opt_dry_run-false}; then :; else
481786a6f21Smrg      eval "$lt_user_locale
482786a6f21Smrg	    $my_cmd"
483786a6f21Smrg      my_status=$?
484786a6f21Smrg      eval "$lt_safe_locale"
485786a6f21Smrg      if test "$my_status" -eq 0; then :; else
486786a6f21Smrg	eval "(exit $my_status); $my_fail_exp"
487786a6f21Smrg      fi
4881d54945dSmrg    fi
489786a6f21Smrg}
4901d54945dSmrg
4911d54945dSmrg
492786a6f21Smrg
493786a6f21Smrg
494786a6f21Smrg
495786a6f21Smrg# func_version
496786a6f21Smrg# Echo version message to standard output and exit.
497786a6f21Smrgfunc_version ()
498786a6f21Smrg{
499786a6f21Smrg    $SED -n '/^# '$PROGRAM' (GNU /,/# warranty; / {
500786a6f21Smrg        s/^# //
501786a6f21Smrg	s/^# *$//
502786a6f21Smrg        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
503786a6f21Smrg        p
504786a6f21Smrg     }' < "$progpath"
505786a6f21Smrg     exit $?
506786a6f21Smrg}
507786a6f21Smrg
508786a6f21Smrg# func_usage
509786a6f21Smrg# Echo short help message to standard output and exit.
510786a6f21Smrgfunc_usage ()
511786a6f21Smrg{
512786a6f21Smrg    $SED -n '/^# Usage:/,/# -h/ {
513786a6f21Smrg        s/^# //
514786a6f21Smrg	s/^# *$//
515786a6f21Smrg	s/\$progname/'$progname'/
516786a6f21Smrg	p
517786a6f21Smrg    }' < "$progpath"
518786a6f21Smrg    $ECHO
519786a6f21Smrg    $ECHO "run \`$progname --help | more' for full usage"
520786a6f21Smrg    exit $?
521786a6f21Smrg}
522786a6f21Smrg
523786a6f21Smrg# func_help
524786a6f21Smrg# Echo long help message to standard output and exit.
525786a6f21Smrgfunc_help ()
526786a6f21Smrg{
527786a6f21Smrg    $SED -n '/^# Usage:/,/# Report bugs to/ {
528786a6f21Smrg        s/^# //
529786a6f21Smrg	s/^# *$//
530786a6f21Smrg	s*\$progname*'$progname'*
531786a6f21Smrg	s*\$host*'"$host"'*
532786a6f21Smrg	s*\$SHELL*'"$SHELL"'*
533786a6f21Smrg	s*\$LTCC*'"$LTCC"'*
534786a6f21Smrg	s*\$LTCFLAGS*'"$LTCFLAGS"'*
535786a6f21Smrg	s*\$LD*'"$LD"'*
536786a6f21Smrg	s/\$with_gnu_ld/'"$with_gnu_ld"'/
537786a6f21Smrg	s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
538786a6f21Smrg	s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
539786a6f21Smrg	p
540786a6f21Smrg     }' < "$progpath"
541786a6f21Smrg    exit $?
542786a6f21Smrg}
543786a6f21Smrg
544786a6f21Smrg# func_missing_arg argname
545786a6f21Smrg# Echo program name prefixed message to standard error and set global
546786a6f21Smrg# exit_cmd.
547786a6f21Smrgfunc_missing_arg ()
548786a6f21Smrg{
549786a6f21Smrg    func_error "missing argument for $1"
550786a6f21Smrg    exit_cmd=exit
5511d54945dSmrg}
5521d54945dSmrg
553786a6f21Smrgexit_cmd=:
5541d54945dSmrg
5551d54945dSmrg
556786a6f21Smrg
557786a6f21Smrg
558786a6f21Smrg
559786a6f21Smrg# Check that we have a working $ECHO.
560786a6f21Smrgif test "X$1" = X--no-reexec; then
561786a6f21Smrg  # Discard the --no-reexec flag, and continue.
562786a6f21Smrg  shift
563786a6f21Smrgelif test "X$1" = X--fallback-echo; then
564786a6f21Smrg  # Avoid inline document here, it may be left over
565786a6f21Smrg  :
566786a6f21Smrgelif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then
567786a6f21Smrg  # Yippee, $ECHO works!
568786a6f21Smrg  :
569786a6f21Smrgelse
570786a6f21Smrg  # Restart under the correct shell, and then maybe $ECHO will work.
571786a6f21Smrg  exec $SHELL "$progpath" --no-reexec ${1+"$@"}
572786a6f21Smrgfi
573786a6f21Smrg
574786a6f21Smrgif test "X$1" = X--fallback-echo; then
575786a6f21Smrg  # used as fallback echo
5761d54945dSmrg  shift
577786a6f21Smrg  cat <<EOF
578786a6f21Smrg$*
579786a6f21SmrgEOF
580786a6f21Smrg  exit $EXIT_SUCCESS
581786a6f21Smrgfi
5821d54945dSmrg
583786a6f21Smrgmagic="%%%MAGIC variable%%%"
584786a6f21Smrgmagic_exe="%%%MAGIC EXE variable%%%"
5851d54945dSmrg
586786a6f21Smrg# Global variables.
587786a6f21Smrg# $mode is unset
588786a6f21Smrgnonopt=
589786a6f21Smrgexecute_dlfiles=
590786a6f21Smrgpreserve_args=
591786a6f21Smrglo2o="s/\\.lo\$/.${objext}/"
592786a6f21Smrgo2lo="s/\\.${objext}\$/.lo/"
593786a6f21Smrgextracted_archives=
594786a6f21Smrgextracted_serial=0
5951d54945dSmrg
596786a6f21Smrgopt_dry_run=false
597786a6f21Smrgopt_duplicate_deps=false
598786a6f21Smrgopt_silent=false
599786a6f21Smrgopt_debug=:
6001d54945dSmrg
601786a6f21Smrg# If this variable is set in any of the actions, the command in it
602786a6f21Smrg# will be execed at the end.  This prevents here-documents from being
603786a6f21Smrg# left over by shells.
604786a6f21Smrgexec_cmd=
6051d54945dSmrg
606786a6f21Smrg# func_fatal_configuration arg...
607786a6f21Smrg# Echo program name prefixed message to standard error, followed by
608786a6f21Smrg# a configuration failure hint, and exit.
609786a6f21Smrgfunc_fatal_configuration ()
610786a6f21Smrg{
611786a6f21Smrg    func_error ${1+"$@"}
612786a6f21Smrg    func_error "See the $PACKAGE documentation for more information."
613786a6f21Smrg    func_fatal_error "Fatal configuration error."
614786a6f21Smrg}
6151d54945dSmrg
6161d54945dSmrg
617786a6f21Smrg# func_config
618786a6f21Smrg# Display the configuration for all the tags in this script.
619786a6f21Smrgfunc_config ()
620786a6f21Smrg{
621786a6f21Smrg    re_begincf='^# ### BEGIN LIBTOOL'
622786a6f21Smrg    re_endcf='^# ### END LIBTOOL'
623786a6f21Smrg
624786a6f21Smrg    # Default configuration.
625786a6f21Smrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
626786a6f21Smrg
6271d54945dSmrg    # Now print the configurations for the tags.
6281d54945dSmrg    for tagname in $taglist; do
629786a6f21Smrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
6301d54945dSmrg    done
6311d54945dSmrg
632786a6f21Smrg    exit $?
633786a6f21Smrg}
6341d54945dSmrg
635786a6f21Smrg# func_features
636786a6f21Smrg# Display the features supported by this script.
637786a6f21Smrgfunc_features ()
638786a6f21Smrg{
639786a6f21Smrg    $ECHO "host: $host"
6401d54945dSmrg    if test "$build_libtool_libs" = yes; then
641786a6f21Smrg      $ECHO "enable shared libraries"
6421d54945dSmrg    else
643786a6f21Smrg      $ECHO "disable shared libraries"
6441d54945dSmrg    fi
6451d54945dSmrg    if test "$build_old_libs" = yes; then
646786a6f21Smrg      $ECHO "enable static libraries"
6471d54945dSmrg    else
648786a6f21Smrg      $ECHO "disable static libraries"
6491d54945dSmrg    fi
650786a6f21Smrg
6511d54945dSmrg    exit $?
652786a6f21Smrg}
6531d54945dSmrg
654786a6f21Smrg# func_enable_tag tagname
655786a6f21Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or
656786a6f21Smrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
657786a6f21Smrg# variable here.
658786a6f21Smrgfunc_enable_tag ()
659786a6f21Smrg{
660786a6f21Smrg  # Global variable:
661786a6f21Smrg  tagname="$1"
6621d54945dSmrg
663786a6f21Smrg  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
664786a6f21Smrg  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
665786a6f21Smrg  sed_extractcf="/$re_begincf/,/$re_endcf/p"
6661d54945dSmrg
667786a6f21Smrg  # Validate tagname.
668786a6f21Smrg  case $tagname in
669786a6f21Smrg    *[!-_A-Za-z0-9,/]*)
670786a6f21Smrg      func_fatal_error "invalid tag name: $tagname"
671786a6f21Smrg      ;;
672786a6f21Smrg  esac
6731d54945dSmrg
674786a6f21Smrg  # Don't test for the "default" C tag, as we know it's
675786a6f21Smrg  # there but not specially marked.
676786a6f21Smrg  case $tagname in
677786a6f21Smrg    CC) ;;
678786a6f21Smrg    *)
679786a6f21Smrg      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
680786a6f21Smrg	taglist="$taglist $tagname"
681786a6f21Smrg
682786a6f21Smrg	# Evaluate the configuration.  Be careful to quote the path
683786a6f21Smrg	# and the sed script, to avoid splitting on whitespace, but
684786a6f21Smrg	# also don't use non-portable quotes within backquotes within
685786a6f21Smrg	# quotes we have to do it in 2 steps:
686786a6f21Smrg	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
687786a6f21Smrg	eval "$extractedcf"
688786a6f21Smrg      else
689786a6f21Smrg	func_error "ignoring unknown tag $tagname"
690786a6f21Smrg      fi
691786a6f21Smrg      ;;
692786a6f21Smrg  esac
693786a6f21Smrg}
694786a6f21Smrg
695786a6f21Smrg# Parse options once, thoroughly.  This comes as soon as possible in
696786a6f21Smrg# the script to make things like `libtool --version' happen quickly.
697786a6f21Smrg{
6981d54945dSmrg
699786a6f21Smrg  # Shorthand for --mode=foo, only valid as the first argument
700786a6f21Smrg  case $1 in
701786a6f21Smrg  clean|clea|cle|cl)
702786a6f21Smrg    shift; set dummy --mode clean ${1+"$@"}; shift
7031d54945dSmrg    ;;
704786a6f21Smrg  compile|compil|compi|comp|com|co|c)
705786a6f21Smrg    shift; set dummy --mode compile ${1+"$@"}; shift
7061d54945dSmrg    ;;
707786a6f21Smrg  execute|execut|execu|exec|exe|ex|e)
708786a6f21Smrg    shift; set dummy --mode execute ${1+"$@"}; shift
7091d54945dSmrg    ;;
710786a6f21Smrg  finish|finis|fini|fin|fi|f)
711786a6f21Smrg    shift; set dummy --mode finish ${1+"$@"}; shift
7121d54945dSmrg    ;;
713786a6f21Smrg  install|instal|insta|inst|ins|in|i)
714786a6f21Smrg    shift; set dummy --mode install ${1+"$@"}; shift
715786a6f21Smrg    ;;
716786a6f21Smrg  link|lin|li|l)
717786a6f21Smrg    shift; set dummy --mode link ${1+"$@"}; shift
718786a6f21Smrg    ;;
719786a6f21Smrg  uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
720786a6f21Smrg    shift; set dummy --mode uninstall ${1+"$@"}; shift
7211d54945dSmrg    ;;
7221d54945dSmrg  esac
7231d54945dSmrg
724786a6f21Smrg  # Parse non-mode specific arguments:
725786a6f21Smrg  while test "$#" -gt 0; do
726786a6f21Smrg    opt="$1"
727786a6f21Smrg    shift
7281d54945dSmrg
729786a6f21Smrg    case $opt in
730786a6f21Smrg      --config)		func_config					;;
7311d54945dSmrg
732786a6f21Smrg      --debug)		preserve_args="$preserve_args $opt"
733786a6f21Smrg			func_echo "enabling shell trace mode"
734786a6f21Smrg			opt_debug='set -x'
735786a6f21Smrg			$opt_debug
736786a6f21Smrg			;;
7371d54945dSmrg
738786a6f21Smrg      -dlopen)		test "$#" -eq 0 && func_missing_arg "$opt" && break
739786a6f21Smrg			execute_dlfiles="$execute_dlfiles $1"
740786a6f21Smrg			shift
741786a6f21Smrg			;;
7421d54945dSmrg
743786a6f21Smrg      --dry-run | -n)	opt_dry_run=:					;;
744786a6f21Smrg      --features)       func_features					;;
745786a6f21Smrg      --finish)		mode="finish"					;;
746786a6f21Smrg
747786a6f21Smrg      --mode)		test "$#" -eq 0 && func_missing_arg "$opt" && break
748786a6f21Smrg			case $1 in
749786a6f21Smrg			  # Valid mode arguments:
750786a6f21Smrg			  clean)	;;
751786a6f21Smrg			  compile)	;;
752786a6f21Smrg			  execute)	;;
753786a6f21Smrg			  finish)	;;
754786a6f21Smrg			  install)	;;
755786a6f21Smrg			  link)		;;
756786a6f21Smrg			  relink)	;;
757786a6f21Smrg			  uninstall)	;;
758786a6f21Smrg
759786a6f21Smrg			  # Catch anything else as an error
760786a6f21Smrg			  *) func_error "invalid argument for $opt"
761786a6f21Smrg			     exit_cmd=exit
762786a6f21Smrg			     break
763786a6f21Smrg			     ;;
764786a6f21Smrg		        esac
765786a6f21Smrg
766786a6f21Smrg			mode="$1"
767786a6f21Smrg			shift
768786a6f21Smrg			;;
769786a6f21Smrg
770786a6f21Smrg      --preserve-dup-deps)
771786a6f21Smrg			opt_duplicate_deps=:				;;
772786a6f21Smrg
773786a6f21Smrg      --quiet|--silent)	preserve_args="$preserve_args $opt"
774786a6f21Smrg			opt_silent=:
775786a6f21Smrg			;;
776786a6f21Smrg
777786a6f21Smrg      --verbose| -v)	preserve_args="$preserve_args $opt"
778786a6f21Smrg			opt_silent=false
779786a6f21Smrg			;;
780786a6f21Smrg
781786a6f21Smrg      --tag)		test "$#" -eq 0 && func_missing_arg "$opt" && break
782786a6f21Smrg			preserve_args="$preserve_args $opt $1"
783786a6f21Smrg			func_enable_tag "$1"	# tagname is set here
784786a6f21Smrg			shift
785786a6f21Smrg			;;
786786a6f21Smrg
787786a6f21Smrg      # Separate optargs to long options:
788786a6f21Smrg      -dlopen=*|--mode=*|--tag=*)
789786a6f21Smrg			func_opt_split "$opt"
790786a6f21Smrg			set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"}
791786a6f21Smrg			shift
792786a6f21Smrg			;;
793786a6f21Smrg
794786a6f21Smrg      -\?|-h)		func_usage					;;
795786a6f21Smrg      --help)		opt_help=:					;;
796786a6f21Smrg      --version)	func_version					;;
797786a6f21Smrg
798786a6f21Smrg      -*)		func_fatal_help "unrecognized option \`$opt'"	;;
799786a6f21Smrg
800786a6f21Smrg      *)		nonopt="$opt"
801786a6f21Smrg			break
802786a6f21Smrg			;;
803786a6f21Smrg    esac
804786a6f21Smrg  done
805786a6f21Smrg
806786a6f21Smrg
807786a6f21Smrg  case $host in
808786a6f21Smrg    *cygwin* | *mingw* | *pw32* | *cegcc*)
809786a6f21Smrg      # don't eliminate duplications in $postdeps and $predeps
810786a6f21Smrg      opt_duplicate_compiler_generated_deps=:
8111d54945dSmrg      ;;
8121d54945dSmrg    *)
813786a6f21Smrg      opt_duplicate_compiler_generated_deps=$opt_duplicate_deps
814786a6f21Smrg      ;;
815786a6f21Smrg  esac
8161d54945dSmrg
817786a6f21Smrg  # Having warned about all mis-specified options, bail out if
818786a6f21Smrg  # anything was wrong.
819786a6f21Smrg  $exit_cmd $EXIT_FAILURE
820786a6f21Smrg}
821786a6f21Smrg
822786a6f21Smrg# func_check_version_match
823786a6f21Smrg# Ensure that we are using m4 macros, and libtool script from the same
824786a6f21Smrg# release of libtool.
825786a6f21Smrgfunc_check_version_match ()
826786a6f21Smrg{
827786a6f21Smrg  if test "$package_revision" != "$macro_revision"; then
828786a6f21Smrg    if test "$VERSION" != "$macro_version"; then
829786a6f21Smrg      if test -z "$macro_version"; then
830786a6f21Smrg        cat >&2 <<_LT_EOF
831786a6f21Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
832786a6f21Smrg$progname: definition of this LT_INIT comes from an older release.
833786a6f21Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
834786a6f21Smrg$progname: and run autoconf again.
835786a6f21Smrg_LT_EOF
836786a6f21Smrg      else
837786a6f21Smrg        cat >&2 <<_LT_EOF
838786a6f21Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
839786a6f21Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
840786a6f21Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
841786a6f21Smrg$progname: and run autoconf again.
842786a6f21Smrg_LT_EOF
8431d54945dSmrg      fi
844786a6f21Smrg    else
845786a6f21Smrg      cat >&2 <<_LT_EOF
846786a6f21Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
847786a6f21Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
848786a6f21Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
849786a6f21Smrg$progname: of $PACKAGE $VERSION and run autoconf again.
850786a6f21Smrg_LT_EOF
851786a6f21Smrg    fi
852786a6f21Smrg
853786a6f21Smrg    exit $EXIT_MISMATCH
854786a6f21Smrg  fi
855786a6f21Smrg}
856786a6f21Smrg
857786a6f21Smrg
858786a6f21Smrg## ----------- ##
859786a6f21Smrg##    Main.    ##
860786a6f21Smrg## ----------- ##
861786a6f21Smrg
862786a6f21Smrg$opt_help || {
863786a6f21Smrg  # Sanity checks first:
864786a6f21Smrg  func_check_version_match
865786a6f21Smrg
866786a6f21Smrg  if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
867786a6f21Smrg    func_fatal_configuration "not configured to build any kind of library"
8681d54945dSmrg  fi
8691d54945dSmrg
870786a6f21Smrg  test -z "$mode" && func_fatal_error "error: you must specify a MODE."
871786a6f21Smrg
872786a6f21Smrg
873786a6f21Smrg  # Darwin sucks
874786a6f21Smrg  eval std_shrext=\"$shrext_cmds\"
875786a6f21Smrg
876786a6f21Smrg
8771d54945dSmrg  # Only execute mode is allowed to have -dlopen flags.
8781d54945dSmrg  if test -n "$execute_dlfiles" && test "$mode" != execute; then
879786a6f21Smrg    func_error "unrecognized option \`-dlopen'"
880786a6f21Smrg    $ECHO "$help" 1>&2
8811d54945dSmrg    exit $EXIT_FAILURE
8821d54945dSmrg  fi
8831d54945dSmrg
8841d54945dSmrg  # Change the help message to a mode-specific one.
8851d54945dSmrg  generic_help="$help"
886786a6f21Smrg  help="Try \`$progname --help --mode=$mode' for more information."
887786a6f21Smrg}
8881d54945dSmrg
8891d54945dSmrg
890786a6f21Smrg# func_lalib_p file
891786a6f21Smrg# True iff FILE is a libtool `.la' library or `.lo' object file.
892786a6f21Smrg# This function is only a basic sanity check; it will hardly flush out
893786a6f21Smrg# determined imposters.
894786a6f21Smrgfunc_lalib_p ()
895786a6f21Smrg{
896786a6f21Smrg    test -f "$1" &&
897786a6f21Smrg      $SED -e 4q "$1" 2>/dev/null \
898786a6f21Smrg        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
899786a6f21Smrg}
9001d54945dSmrg
901786a6f21Smrg# func_lalib_unsafe_p file
902786a6f21Smrg# True iff FILE is a libtool `.la' library or `.lo' object file.
903786a6f21Smrg# This function implements the same check as func_lalib_p without
904786a6f21Smrg# resorting to external programs.  To this end, it redirects stdin and
905786a6f21Smrg# closes it afterwards, without saving the original file descriptor.
906786a6f21Smrg# As a safety measure, use it only where a negative result would be
907786a6f21Smrg# fatal anyway.  Works if `file' does not exist.
908786a6f21Smrgfunc_lalib_unsafe_p ()
909786a6f21Smrg{
910786a6f21Smrg    lalib_p=no
911786a6f21Smrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
912786a6f21Smrg	for lalib_p_l in 1 2 3 4
913786a6f21Smrg	do
914786a6f21Smrg	    read lalib_p_line
915786a6f21Smrg	    case "$lalib_p_line" in
916786a6f21Smrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
917786a6f21Smrg	    esac
918786a6f21Smrg	done
919786a6f21Smrg	exec 0<&5 5<&-
920786a6f21Smrg    fi
921786a6f21Smrg    test "$lalib_p" = yes
922786a6f21Smrg}
9231d54945dSmrg
924786a6f21Smrg# func_ltwrapper_script_p file
925786a6f21Smrg# True iff FILE is a libtool wrapper script
926786a6f21Smrg# This function is only a basic sanity check; it will hardly flush out
927786a6f21Smrg# determined imposters.
928786a6f21Smrgfunc_ltwrapper_script_p ()
929786a6f21Smrg{
930786a6f21Smrg    func_lalib_p "$1"
931786a6f21Smrg}
9321d54945dSmrg
933786a6f21Smrg# func_ltwrapper_executable_p file
934786a6f21Smrg# True iff FILE is a libtool wrapper executable
935786a6f21Smrg# This function is only a basic sanity check; it will hardly flush out
936786a6f21Smrg# determined imposters.
937786a6f21Smrgfunc_ltwrapper_executable_p ()
938786a6f21Smrg{
939786a6f21Smrg    func_ltwrapper_exec_suffix=
940786a6f21Smrg    case $1 in
941786a6f21Smrg    *.exe) ;;
942786a6f21Smrg    *) func_ltwrapper_exec_suffix=.exe ;;
943786a6f21Smrg    esac
944786a6f21Smrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
945786a6f21Smrg}
946786a6f21Smrg
947786a6f21Smrg# func_ltwrapper_scriptname file
948786a6f21Smrg# Assumes file is an ltwrapper_executable
949786a6f21Smrg# uses $file to determine the appropriate filename for a
950786a6f21Smrg# temporary ltwrapper_script.
951786a6f21Smrgfunc_ltwrapper_scriptname ()
952786a6f21Smrg{
953786a6f21Smrg    func_ltwrapper_scriptname_result=""
954786a6f21Smrg    if func_ltwrapper_executable_p "$1"; then
955786a6f21Smrg	func_dirname_and_basename "$1" "" "."
956786a6f21Smrg	func_stripname '' '.exe' "$func_basename_result"
957786a6f21Smrg	func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
958786a6f21Smrg    fi
959786a6f21Smrg}
960786a6f21Smrg
961786a6f21Smrg# func_ltwrapper_p file
962786a6f21Smrg# True iff FILE is a libtool wrapper script or wrapper executable
963786a6f21Smrg# This function is only a basic sanity check; it will hardly flush out
964786a6f21Smrg# determined imposters.
965786a6f21Smrgfunc_ltwrapper_p ()
966786a6f21Smrg{
967786a6f21Smrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
968786a6f21Smrg}
969786a6f21Smrg
970786a6f21Smrg
971786a6f21Smrg# func_execute_cmds commands fail_cmd
972786a6f21Smrg# Execute tilde-delimited COMMANDS.
973786a6f21Smrg# If FAIL_CMD is given, eval that upon failure.
974786a6f21Smrg# FAIL_CMD may read-access the current command in variable CMD!
975786a6f21Smrgfunc_execute_cmds ()
976786a6f21Smrg{
977786a6f21Smrg    $opt_debug
978786a6f21Smrg    save_ifs=$IFS; IFS='~'
979786a6f21Smrg    for cmd in $1; do
980786a6f21Smrg      IFS=$save_ifs
981786a6f21Smrg      eval cmd=\"$cmd\"
982786a6f21Smrg      func_show_eval "$cmd" "${2-:}"
983786a6f21Smrg    done
984786a6f21Smrg    IFS=$save_ifs
985786a6f21Smrg}
986786a6f21Smrg
987786a6f21Smrg
988786a6f21Smrg# func_source file
989786a6f21Smrg# Source FILE, adding directory component if necessary.
990786a6f21Smrg# Note that it is not necessary on cygwin/mingw to append a dot to
991786a6f21Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
992786a6f21Smrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
993786a6f21Smrg# `FILE.' does not work on cygwin managed mounts.
994786a6f21Smrgfunc_source ()
995786a6f21Smrg{
996786a6f21Smrg    $opt_debug
997786a6f21Smrg    case $1 in
998786a6f21Smrg    */* | *\\*)	. "$1" ;;
999786a6f21Smrg    *)		. "./$1" ;;
1000786a6f21Smrg    esac
1001786a6f21Smrg}
1002786a6f21Smrg
1003786a6f21Smrg
1004786a6f21Smrg# func_infer_tag arg
1005786a6f21Smrg# Infer tagged configuration to use if any are available and
1006786a6f21Smrg# if one wasn't chosen via the "--tag" command line option.
1007786a6f21Smrg# Only attempt this if the compiler in the base compile
1008786a6f21Smrg# command doesn't match the default compiler.
1009786a6f21Smrg# arg is usually of the form 'gcc ...'
1010786a6f21Smrgfunc_infer_tag ()
1011786a6f21Smrg{
1012786a6f21Smrg    $opt_debug
1013786a6f21Smrg    if test -n "$available_tags" && test -z "$tagname"; then
1014786a6f21Smrg      CC_quoted=
1015786a6f21Smrg      for arg in $CC; do
1016786a6f21Smrg        func_quote_for_eval "$arg"
1017786a6f21Smrg	CC_quoted="$CC_quoted $func_quote_for_eval_result"
1018786a6f21Smrg      done
1019786a6f21Smrg      case $@ in
1020786a6f21Smrg      # Blanks in the command may have been stripped by the calling shell,
1021786a6f21Smrg      # but not from the CC environment variable when configure was run.
1022786a6f21Smrg      " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) ;;
1023786a6f21Smrg      # Blanks at the start of $base_compile will cause this to fail
1024786a6f21Smrg      # if we don't check for them as well.
1025786a6f21Smrg      *)
1026786a6f21Smrg	for z in $available_tags; do
1027786a6f21Smrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
1028786a6f21Smrg	    # Evaluate the configuration.
1029786a6f21Smrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
1030786a6f21Smrg	    CC_quoted=
1031786a6f21Smrg	    for arg in $CC; do
1032786a6f21Smrg	      # Double-quote args containing other shell metacharacters.
1033786a6f21Smrg	      func_quote_for_eval "$arg"
1034786a6f21Smrg	      CC_quoted="$CC_quoted $func_quote_for_eval_result"
1035786a6f21Smrg	    done
1036786a6f21Smrg	    case "$@ " in
1037786a6f21Smrg	      " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*)
1038786a6f21Smrg	      # The compiler in the base compile command matches
1039786a6f21Smrg	      # the one in the tagged configuration.
1040786a6f21Smrg	      # Assume this is the tagged configuration we want.
1041786a6f21Smrg	      tagname=$z
1042786a6f21Smrg	      break
1043786a6f21Smrg	      ;;
1044786a6f21Smrg	    esac
1045786a6f21Smrg	  fi
1046786a6f21Smrg	done
1047786a6f21Smrg	# If $tagname still isn't set, then no tagged configuration
1048786a6f21Smrg	# was found and let the user know that the "--tag" command
1049786a6f21Smrg	# line option must be used.
1050786a6f21Smrg	if test -z "$tagname"; then
1051786a6f21Smrg	  func_echo "unable to infer tagged configuration"
1052786a6f21Smrg	  func_fatal_error "specify a tag with \`--tag'"
1053786a6f21Smrg#	else
1054786a6f21Smrg#	  func_verbose "using $tagname tagged configuration"
1055786a6f21Smrg	fi
1056786a6f21Smrg	;;
1057786a6f21Smrg      esac
1058786a6f21Smrg    fi
1059786a6f21Smrg}
1060786a6f21Smrg
1061786a6f21Smrg
1062786a6f21Smrg
1063786a6f21Smrg# func_write_libtool_object output_name pic_name nonpic_name
1064786a6f21Smrg# Create a libtool object file (analogous to a ".la" file),
1065786a6f21Smrg# but don't create it if we're doing a dry run.
1066786a6f21Smrgfunc_write_libtool_object ()
1067786a6f21Smrg{
1068786a6f21Smrg    write_libobj=${1}
1069786a6f21Smrg    if test "$build_libtool_libs" = yes; then
1070786a6f21Smrg      write_lobj=\'${2}\'
1071786a6f21Smrg    else
1072786a6f21Smrg      write_lobj=none
1073786a6f21Smrg    fi
1074786a6f21Smrg
1075786a6f21Smrg    if test "$build_old_libs" = yes; then
1076786a6f21Smrg      write_oldobj=\'${3}\'
1077786a6f21Smrg    else
1078786a6f21Smrg      write_oldobj=none
1079786a6f21Smrg    fi
1080786a6f21Smrg
1081786a6f21Smrg    $opt_dry_run || {
1082786a6f21Smrg      cat >${write_libobj}T <<EOF
1083786a6f21Smrg# $write_libobj - a libtool object file
1084786a6f21Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1085786a6f21Smrg#
1086786a6f21Smrg# Please DO NOT delete this file!
1087786a6f21Smrg# It is necessary for linking the library.
1088786a6f21Smrg
1089786a6f21Smrg# Name of the PIC object.
1090786a6f21Smrgpic_object=$write_lobj
1091786a6f21Smrg
1092786a6f21Smrg# Name of the non-PIC object
1093786a6f21Smrgnon_pic_object=$write_oldobj
1094786a6f21Smrg
1095786a6f21SmrgEOF
1096786a6f21Smrg      $MV "${write_libobj}T" "${write_libobj}"
1097786a6f21Smrg    }
1098786a6f21Smrg}
1099786a6f21Smrg
1100786a6f21Smrg# func_mode_compile arg...
1101786a6f21Smrgfunc_mode_compile ()
1102786a6f21Smrg{
1103786a6f21Smrg    $opt_debug
1104786a6f21Smrg    # Get the compilation command and the source file.
1105786a6f21Smrg    base_compile=
1106786a6f21Smrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
1107786a6f21Smrg    suppress_opt=yes
1108786a6f21Smrg    suppress_output=
1109786a6f21Smrg    arg_mode=normal
1110786a6f21Smrg    libobj=
1111786a6f21Smrg    later=
1112786a6f21Smrg    pie_flag=
1113786a6f21Smrg
1114786a6f21Smrg    for arg
1115786a6f21Smrg    do
1116786a6f21Smrg      case $arg_mode in
1117786a6f21Smrg      arg  )
1118786a6f21Smrg	# do not "continue".  Instead, add this to base_compile
1119786a6f21Smrg	lastarg="$arg"
1120786a6f21Smrg	arg_mode=normal
1121786a6f21Smrg	;;
1122786a6f21Smrg
1123786a6f21Smrg      target )
1124786a6f21Smrg	libobj="$arg"
1125786a6f21Smrg	arg_mode=normal
1126786a6f21Smrg	continue
1127786a6f21Smrg	;;
1128786a6f21Smrg
1129786a6f21Smrg      normal )
1130786a6f21Smrg	# Accept any command-line options.
1131786a6f21Smrg	case $arg in
1132786a6f21Smrg	-o)
1133786a6f21Smrg	  test -n "$libobj" && \
1134786a6f21Smrg	    func_fatal_error "you cannot specify \`-o' more than once"
1135786a6f21Smrg	  arg_mode=target
1136786a6f21Smrg	  continue
1137786a6f21Smrg	  ;;
1138786a6f21Smrg
1139786a6f21Smrg	-pie | -fpie | -fPIE)
1140786a6f21Smrg          pie_flag="$pie_flag $arg"
1141786a6f21Smrg	  continue
1142786a6f21Smrg	  ;;
1143786a6f21Smrg
1144786a6f21Smrg	-shared | -static | -prefer-pic | -prefer-non-pic)
1145786a6f21Smrg	  later="$later $arg"
1146786a6f21Smrg	  continue
1147786a6f21Smrg	  ;;
1148786a6f21Smrg
1149786a6f21Smrg	-no-suppress)
1150786a6f21Smrg	  suppress_opt=no
1151786a6f21Smrg	  continue
1152786a6f21Smrg	  ;;
11531d54945dSmrg
11541d54945dSmrg	-Xcompiler)
11551d54945dSmrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
11561d54945dSmrg	  continue      #  The current "srcfile" will either be retained or
11571d54945dSmrg	  ;;            #  replaced later.  I would guess that would be a bug.
11581d54945dSmrg
11591d54945dSmrg	-Wc,*)
1160786a6f21Smrg	  func_stripname '-Wc,' '' "$arg"
1161786a6f21Smrg	  args=$func_stripname_result
11621d54945dSmrg	  lastarg=
11631d54945dSmrg	  save_ifs="$IFS"; IFS=','
1164786a6f21Smrg	  for arg in $args; do
11651d54945dSmrg	    IFS="$save_ifs"
1166786a6f21Smrg	    func_quote_for_eval "$arg"
1167786a6f21Smrg	    lastarg="$lastarg $func_quote_for_eval_result"
11681d54945dSmrg	  done
11691d54945dSmrg	  IFS="$save_ifs"
1170786a6f21Smrg	  func_stripname ' ' '' "$lastarg"
1171786a6f21Smrg	  lastarg=$func_stripname_result
11721d54945dSmrg
11731d54945dSmrg	  # Add the arguments to base_compile.
11741d54945dSmrg	  base_compile="$base_compile $lastarg"
11751d54945dSmrg	  continue
11761d54945dSmrg	  ;;
11771d54945dSmrg
1178786a6f21Smrg	*)
11791d54945dSmrg	  # Accept the current argument as the source file.
11801d54945dSmrg	  # The previous "srcfile" becomes the current argument.
11811d54945dSmrg	  #
11821d54945dSmrg	  lastarg="$srcfile"
11831d54945dSmrg	  srcfile="$arg"
11841d54945dSmrg	  ;;
11851d54945dSmrg	esac  #  case $arg
11861d54945dSmrg	;;
11871d54945dSmrg      esac    #  case $arg_mode
11881d54945dSmrg
11891d54945dSmrg      # Aesthetically quote the previous argument.
1190786a6f21Smrg      func_quote_for_eval "$lastarg"
1191786a6f21Smrg      base_compile="$base_compile $func_quote_for_eval_result"
11921d54945dSmrg    done # for arg
11931d54945dSmrg
11941d54945dSmrg    case $arg_mode in
11951d54945dSmrg    arg)
1196786a6f21Smrg      func_fatal_error "you must specify an argument for -Xcompile"
11971d54945dSmrg      ;;
11981d54945dSmrg    target)
1199786a6f21Smrg      func_fatal_error "you must specify a target with \`-o'"
12001d54945dSmrg      ;;
12011d54945dSmrg    *)
12021d54945dSmrg      # Get the name of the library object.
1203786a6f21Smrg      test -z "$libobj" && {
1204786a6f21Smrg	func_basename "$srcfile"
1205786a6f21Smrg	libobj="$func_basename_result"
1206786a6f21Smrg      }
12071d54945dSmrg      ;;
12081d54945dSmrg    esac
12091d54945dSmrg
12101d54945dSmrg    # Recognize several different file suffixes.
12111d54945dSmrg    # If the user specifies -o file.o, it is replaced with file.lo
12121d54945dSmrg    case $libobj in
1213786a6f21Smrg    *.[cCFSifmso] | \
1214786a6f21Smrg    *.ada | *.adb | *.ads | *.asm | \
1215786a6f21Smrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
1216786a6f21Smrg    *.[fF][09]? | *.for | *.java | *.obj | *.sx)
1217786a6f21Smrg      func_xform "$libobj"
1218786a6f21Smrg      libobj=$func_xform_result
1219786a6f21Smrg      ;;
12201d54945dSmrg    esac
12211d54945dSmrg
12221d54945dSmrg    case $libobj in
1223786a6f21Smrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
12241d54945dSmrg    *)
1225786a6f21Smrg      func_fatal_error "cannot determine name of library object from \`$libobj'"
12261d54945dSmrg      ;;
12271d54945dSmrg    esac
12281d54945dSmrg
12291d54945dSmrg    func_infer_tag $base_compile
12301d54945dSmrg
12311d54945dSmrg    for arg in $later; do
12321d54945dSmrg      case $arg in
1233786a6f21Smrg      -shared)
1234786a6f21Smrg	test "$build_libtool_libs" != yes && \
1235786a6f21Smrg	  func_fatal_configuration "can not build a shared library"
1236786a6f21Smrg	build_old_libs=no
1237786a6f21Smrg	continue
1238786a6f21Smrg	;;
1239786a6f21Smrg
12401d54945dSmrg      -static)
1241786a6f21Smrg	build_libtool_libs=no
12421d54945dSmrg	build_old_libs=yes
12431d54945dSmrg	continue
12441d54945dSmrg	;;
12451d54945dSmrg
12461d54945dSmrg      -prefer-pic)
12471d54945dSmrg	pic_mode=yes
12481d54945dSmrg	continue
12491d54945dSmrg	;;
12501d54945dSmrg
12511d54945dSmrg      -prefer-non-pic)
12521d54945dSmrg	pic_mode=no
12531d54945dSmrg	continue
12541d54945dSmrg	;;
12551d54945dSmrg      esac
12561d54945dSmrg    done
12571d54945dSmrg
1258786a6f21Smrg    func_quote_for_eval "$libobj"
1259786a6f21Smrg    test "X$libobj" != "X$func_quote_for_eval_result" \
1260786a6f21Smrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
1261786a6f21Smrg      && func_warning "libobj name \`$libobj' may not contain shell special characters."
1262786a6f21Smrg    func_dirname_and_basename "$obj" "/" ""
1263786a6f21Smrg    objname="$func_basename_result"
1264786a6f21Smrg    xdir="$func_dirname_result"
12651d54945dSmrg    lobj=${xdir}$objdir/$objname
12661d54945dSmrg
1267786a6f21Smrg    test -z "$base_compile" && \
1268786a6f21Smrg      func_fatal_help "you must specify a compilation command"
12691d54945dSmrg
12701d54945dSmrg    # Delete any leftover library objects.
12711d54945dSmrg    if test "$build_old_libs" = yes; then
12721d54945dSmrg      removelist="$obj $lobj $libobj ${libobj}T"
12731d54945dSmrg    else
12741d54945dSmrg      removelist="$lobj $libobj ${libobj}T"
12751d54945dSmrg    fi
12761d54945dSmrg
12771d54945dSmrg    # On Cygwin there's no "real" PIC flag so we must build both object types
12781d54945dSmrg    case $host_os in
1279786a6f21Smrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
12801d54945dSmrg      pic_mode=default
12811d54945dSmrg      ;;
12821d54945dSmrg    esac
12831d54945dSmrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
12841d54945dSmrg      # non-PIC code in shared libraries is not supported
12851d54945dSmrg      pic_mode=default
12861d54945dSmrg    fi
12871d54945dSmrg
12881d54945dSmrg    # Calculate the filename of the output object if compiler does
12891d54945dSmrg    # not support -o with -c
12901d54945dSmrg    if test "$compiler_c_o" = no; then
1291786a6f21Smrg      output_obj=`$ECHO "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
12921d54945dSmrg      lockfile="$output_obj.lock"
12931d54945dSmrg    else
12941d54945dSmrg      output_obj=
12951d54945dSmrg      need_locks=no
12961d54945dSmrg      lockfile=
12971d54945dSmrg    fi
12981d54945dSmrg
12991d54945dSmrg    # Lock this critical section if it is needed
13001d54945dSmrg    # We use this script file to make the link, it avoids creating a new file
13011d54945dSmrg    if test "$need_locks" = yes; then
1302786a6f21Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
1303786a6f21Smrg	func_echo "Waiting for $lockfile to be removed"
13041d54945dSmrg	sleep 2
13051d54945dSmrg      done
13061d54945dSmrg    elif test "$need_locks" = warn; then
13071d54945dSmrg      if test -f "$lockfile"; then
1308786a6f21Smrg	$ECHO "\
13091d54945dSmrg*** ERROR, $lockfile exists and contains:
13101d54945dSmrg`cat $lockfile 2>/dev/null`
13111d54945dSmrg
13121d54945dSmrgThis indicates that another process is trying to use the same
13131d54945dSmrgtemporary object file, and libtool could not work around it because
13141d54945dSmrgyour compiler does not support \`-c' and \`-o' together.  If you
13151d54945dSmrgrepeat this compilation, it may succeed, by chance, but you had better
13161d54945dSmrgavoid parallel builds (make -j) in this platform, or get a better
13171d54945dSmrgcompiler."
13181d54945dSmrg
1319786a6f21Smrg	$opt_dry_run || $RM $removelist
13201d54945dSmrg	exit $EXIT_FAILURE
13211d54945dSmrg      fi
1322786a6f21Smrg      removelist="$removelist $output_obj"
1323786a6f21Smrg      $ECHO "$srcfile" > "$lockfile"
13241d54945dSmrg    fi
13251d54945dSmrg
1326786a6f21Smrg    $opt_dry_run || $RM $removelist
1327786a6f21Smrg    removelist="$removelist $lockfile"
1328786a6f21Smrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
1329786a6f21Smrg
13301d54945dSmrg    if test -n "$fix_srcfile_path"; then
13311d54945dSmrg      eval srcfile=\"$fix_srcfile_path\"
13321d54945dSmrg    fi
1333786a6f21Smrg    func_quote_for_eval "$srcfile"
1334786a6f21Smrg    qsrcfile=$func_quote_for_eval_result
13351d54945dSmrg
13361d54945dSmrg    # Only build a PIC object if we are building libtool libraries.
13371d54945dSmrg    if test "$build_libtool_libs" = yes; then
13381d54945dSmrg      # Without this assignment, base_compile gets emptied.
13391d54945dSmrg      fbsd_hideous_sh_bug=$base_compile
13401d54945dSmrg
13411d54945dSmrg      if test "$pic_mode" != no; then
13421d54945dSmrg	command="$base_compile $qsrcfile $pic_flag"
13431d54945dSmrg      else
13441d54945dSmrg	# Don't build PIC code
13451d54945dSmrg	command="$base_compile $qsrcfile"
13461d54945dSmrg      fi
13471d54945dSmrg
1348786a6f21Smrg      func_mkdir_p "$xdir$objdir"
13491d54945dSmrg
13501d54945dSmrg      if test -z "$output_obj"; then
13511d54945dSmrg	# Place PIC objects in $objdir
13521d54945dSmrg	command="$command -o $lobj"
13531d54945dSmrg      fi
13541d54945dSmrg
1355786a6f21Smrg      func_show_eval_locale "$command"	\
1356786a6f21Smrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
13571d54945dSmrg
13581d54945dSmrg      if test "$need_locks" = warn &&
13591d54945dSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
1360786a6f21Smrg	$ECHO "\
13611d54945dSmrg*** ERROR, $lockfile contains:
13621d54945dSmrg`cat $lockfile 2>/dev/null`
13631d54945dSmrg
13641d54945dSmrgbut it should contain:
13651d54945dSmrg$srcfile
13661d54945dSmrg
13671d54945dSmrgThis indicates that another process is trying to use the same
13681d54945dSmrgtemporary object file, and libtool could not work around it because
13691d54945dSmrgyour compiler does not support \`-c' and \`-o' together.  If you
13701d54945dSmrgrepeat this compilation, it may succeed, by chance, but you had better
13711d54945dSmrgavoid parallel builds (make -j) in this platform, or get a better
13721d54945dSmrgcompiler."
13731d54945dSmrg
1374786a6f21Smrg	$opt_dry_run || $RM $removelist
13751d54945dSmrg	exit $EXIT_FAILURE
13761d54945dSmrg      fi
13771d54945dSmrg
13781d54945dSmrg      # Just move the object if needed, then go on to compile the next one
13791d54945dSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
1380786a6f21Smrg	func_show_eval '$MV "$output_obj" "$lobj"' \
1381786a6f21Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
13821d54945dSmrg      fi
13831d54945dSmrg
13841d54945dSmrg      # Allow error messages only from the first compilation.
13851d54945dSmrg      if test "$suppress_opt" = yes; then
1386786a6f21Smrg	suppress_output=' >/dev/null 2>&1'
13871d54945dSmrg      fi
13881d54945dSmrg    fi
13891d54945dSmrg
13901d54945dSmrg    # Only build a position-dependent object if we build old libraries.
13911d54945dSmrg    if test "$build_old_libs" = yes; then
13921d54945dSmrg      if test "$pic_mode" != yes; then
13931d54945dSmrg	# Don't build PIC code
1394786a6f21Smrg	command="$base_compile $qsrcfile$pie_flag"
13951d54945dSmrg      else
13961d54945dSmrg	command="$base_compile $qsrcfile $pic_flag"
13971d54945dSmrg      fi
13981d54945dSmrg      if test "$compiler_c_o" = yes; then
13991d54945dSmrg	command="$command -o $obj"
14001d54945dSmrg      fi
14011d54945dSmrg
14021d54945dSmrg      # Suppress compiler output if we already did a PIC compilation.
14031d54945dSmrg      command="$command$suppress_output"
1404786a6f21Smrg      func_show_eval_locale "$command" \
1405786a6f21Smrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
14061d54945dSmrg
14071d54945dSmrg      if test "$need_locks" = warn &&
14081d54945dSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
1409786a6f21Smrg	$ECHO "\
14101d54945dSmrg*** ERROR, $lockfile contains:
14111d54945dSmrg`cat $lockfile 2>/dev/null`
14121d54945dSmrg
14131d54945dSmrgbut it should contain:
14141d54945dSmrg$srcfile
14151d54945dSmrg
14161d54945dSmrgThis indicates that another process is trying to use the same
14171d54945dSmrgtemporary object file, and libtool could not work around it because
14181d54945dSmrgyour compiler does not support \`-c' and \`-o' together.  If you
14191d54945dSmrgrepeat this compilation, it may succeed, by chance, but you had better
14201d54945dSmrgavoid parallel builds (make -j) in this platform, or get a better
14211d54945dSmrgcompiler."
14221d54945dSmrg
1423786a6f21Smrg	$opt_dry_run || $RM $removelist
14241d54945dSmrg	exit $EXIT_FAILURE
14251d54945dSmrg      fi
14261d54945dSmrg
14271d54945dSmrg      # Just move the object if needed
14281d54945dSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
1429786a6f21Smrg	func_show_eval '$MV "$output_obj" "$obj"' \
1430786a6f21Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
14311d54945dSmrg      fi
1432786a6f21Smrg    fi
14331d54945dSmrg
1434786a6f21Smrg    $opt_dry_run || {
1435786a6f21Smrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
14361d54945dSmrg
1437786a6f21Smrg      # Unlock the critical section if it was locked
1438786a6f21Smrg      if test "$need_locks" != no; then
1439786a6f21Smrg	removelist=$lockfile
1440786a6f21Smrg        $RM "$lockfile"
1441786a6f21Smrg      fi
1442786a6f21Smrg    }
14431d54945dSmrg
1444786a6f21Smrg    exit $EXIT_SUCCESS
1445786a6f21Smrg}
14461d54945dSmrg
1447786a6f21Smrg$opt_help || {
1448786a6f21Smrgtest "$mode" = compile && func_mode_compile ${1+"$@"}
1449786a6f21Smrg}
14501d54945dSmrg
1451786a6f21Smrgfunc_mode_help ()
1452786a6f21Smrg{
1453786a6f21Smrg    # We need to display help for each of the modes.
1454786a6f21Smrg    case $mode in
1455786a6f21Smrg      "")
1456786a6f21Smrg        # Generic help is extracted from the usage comments
1457786a6f21Smrg        # at the start of this file.
1458786a6f21Smrg        func_help
1459786a6f21Smrg        ;;
14601d54945dSmrg
1461786a6f21Smrg      clean)
1462786a6f21Smrg        $ECHO \
1463786a6f21Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
14641d54945dSmrg
1465786a6f21SmrgRemove files from the build directory.
14661d54945dSmrg
1467786a6f21SmrgRM is the name of the program to use to delete files associated with each FILE
1468786a6f21Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
1469786a6f21Smrgto RM.
14701d54945dSmrg
1471786a6f21SmrgIf FILE is a libtool library, object or program, all the files associated
1472786a6f21Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
1473786a6f21Smrg        ;;
14741d54945dSmrg
1475786a6f21Smrg      compile)
1476786a6f21Smrg      $ECHO \
1477786a6f21Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
14781d54945dSmrg
1479786a6f21SmrgCompile a source file into a libtool library object.
14801d54945dSmrg
1481786a6f21SmrgThis mode accepts the following additional options:
14821d54945dSmrg
1483786a6f21Smrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
1484786a6f21Smrg  -no-suppress      do not suppress compiler output for multiple passes
1485786a6f21Smrg  -prefer-pic       try to building PIC objects only
1486786a6f21Smrg  -prefer-non-pic   try to building non-PIC objects only
1487786a6f21Smrg  -shared           do not build a \`.o' file suitable for static linking
1488786a6f21Smrg  -static           only build a \`.o' file suitable for static linking
14891d54945dSmrg
1490786a6f21SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
1491786a6f21Smrgfrom the given SOURCEFILE.
14921d54945dSmrg
1493786a6f21SmrgThe output file name is determined by removing the directory component from
1494786a6f21SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
1495786a6f21Smrglibrary object suffix, \`.lo'."
1496786a6f21Smrg        ;;
14971d54945dSmrg
1498786a6f21Smrg      execute)
1499786a6f21Smrg        $ECHO \
1500786a6f21Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
15011d54945dSmrg
1502786a6f21SmrgAutomatically set library path, then run a program.
15031d54945dSmrg
1504786a6f21SmrgThis mode accepts the following additional options:
15051d54945dSmrg
1506786a6f21Smrg  -dlopen FILE      add the directory containing FILE to the library path
15071d54945dSmrg
1508786a6f21SmrgThis mode sets the library path environment variable according to \`-dlopen'
1509786a6f21Smrgflags.
15101d54945dSmrg
1511786a6f21SmrgIf any of the ARGS are libtool executable wrappers, then they are translated
1512786a6f21Smrginto their corresponding uninstalled binary, and any of their required library
1513786a6f21Smrgdirectories are added to the library path.
15141d54945dSmrg
1515786a6f21SmrgThen, COMMAND is executed, with ARGS as arguments."
1516786a6f21Smrg        ;;
15171d54945dSmrg
1518786a6f21Smrg      finish)
1519786a6f21Smrg        $ECHO \
1520786a6f21Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
15211d54945dSmrg
1522786a6f21SmrgComplete the installation of libtool libraries.
15231d54945dSmrg
1524786a6f21SmrgEach LIBDIR is a directory that contains libtool libraries.
15251d54945dSmrg
1526786a6f21SmrgThe commands that this mode executes may require superuser privileges.  Use
1527786a6f21Smrgthe \`--dry-run' option if you just want to see what would be executed."
1528786a6f21Smrg        ;;
15291d54945dSmrg
1530786a6f21Smrg      install)
1531786a6f21Smrg        $ECHO \
1532786a6f21Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
15331d54945dSmrg
1534786a6f21SmrgInstall executables or libraries.
15351d54945dSmrg
1536786a6f21SmrgINSTALL-COMMAND is the installation command.  The first component should be
1537786a6f21Smrgeither the \`install' or \`cp' program.
15381d54945dSmrg
1539786a6f21SmrgThe following components of INSTALL-COMMAND are treated specially:
15401d54945dSmrg
1541786a6f21Smrg  -inst-prefix PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
15421d54945dSmrg
1543786a6f21SmrgThe rest of the components are interpreted as arguments to that command (only
1544786a6f21SmrgBSD-compatible install options are recognized)."
1545786a6f21Smrg        ;;
15461d54945dSmrg
1547786a6f21Smrg      link)
1548786a6f21Smrg        $ECHO \
1549786a6f21Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
15501d54945dSmrg
1551786a6f21SmrgLink object files or libraries together to form another library, or to
1552786a6f21Smrgcreate an executable program.
15531d54945dSmrg
1554786a6f21SmrgLINK-COMMAND is a command using the C compiler that you would use to create
1555786a6f21Smrga program from several object files.
15561d54945dSmrg
1557786a6f21SmrgThe following components of LINK-COMMAND are treated specially:
15581d54945dSmrg
1559786a6f21Smrg  -all-static       do not do any dynamic linking at all
1560786a6f21Smrg  -avoid-version    do not add a version suffix if possible
1561786a6f21Smrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
1562786a6f21Smrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
1563786a6f21Smrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
1564786a6f21Smrg  -export-symbols SYMFILE
1565786a6f21Smrg                    try to export only the symbols listed in SYMFILE
1566786a6f21Smrg  -export-symbols-regex REGEX
1567786a6f21Smrg                    try to export only the symbols matching REGEX
1568786a6f21Smrg  -LLIBDIR          search LIBDIR for required installed libraries
1569786a6f21Smrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
1570786a6f21Smrg  -module           build a library that can dlopened
1571786a6f21Smrg  -no-fast-install  disable the fast-install mode
1572786a6f21Smrg  -no-install       link a not-installable executable
1573786a6f21Smrg  -no-undefined     declare that a library does not refer to external symbols
1574786a6f21Smrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
1575786a6f21Smrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
1576786a6f21Smrg  -precious-files-regex REGEX
1577786a6f21Smrg                    don't remove output files matching REGEX
1578786a6f21Smrg  -release RELEASE  specify package release information
1579786a6f21Smrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
1580786a6f21Smrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
1581786a6f21Smrg  -shared           only do dynamic linking of libtool libraries
1582786a6f21Smrg  -shrext SUFFIX    override the standard shared library file extension
1583786a6f21Smrg  -static           do not do any dynamic linking of uninstalled libtool libraries
1584786a6f21Smrg  -static-libtool-libs
1585786a6f21Smrg                    do not do any dynamic linking of libtool libraries
1586786a6f21Smrg  -version-info CURRENT[:REVISION[:AGE]]
1587786a6f21Smrg                    specify library version info [each variable defaults to 0]
1588786a6f21Smrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
15891d54945dSmrg
1590786a6f21SmrgAll other options (arguments beginning with \`-') are ignored.
15911d54945dSmrg
1592786a6f21SmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
1593786a6f21Smrgtreated as uninstalled libtool libraries, other files are standard or library
1594786a6f21Smrgobject files.
15951d54945dSmrg
1596786a6f21SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
1597786a6f21Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
1598786a6f21Smrgrequired, except when creating a convenience library.
15991d54945dSmrg
1600786a6f21SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
1601786a6f21Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
16021d54945dSmrg
1603786a6f21SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
1604786a6f21Smrgis created, otherwise an executable program is created."
1605786a6f21Smrg        ;;
16061d54945dSmrg
1607786a6f21Smrg      uninstall)
1608786a6f21Smrg        $ECHO \
1609786a6f21Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
16101d54945dSmrg
1611786a6f21SmrgRemove libraries from an installation directory.
16121d54945dSmrg
1613786a6f21SmrgRM is the name of the program to use to delete files associated with each FILE
1614786a6f21Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
1615786a6f21Smrgto RM.
16161d54945dSmrg
1617786a6f21SmrgIf FILE is a libtool library, all the files associated with it are deleted.
1618786a6f21SmrgOtherwise, only FILE itself is deleted using RM."
16191d54945dSmrg        ;;
16201d54945dSmrg
1621786a6f21Smrg      *)
1622786a6f21Smrg        func_fatal_help "invalid operation mode \`$mode'"
1623786a6f21Smrg        ;;
1624786a6f21Smrg    esac
16251d54945dSmrg
1626786a6f21Smrg    $ECHO
1627786a6f21Smrg    $ECHO "Try \`$progname --help' for more information about other modes."
16281d54945dSmrg
1629786a6f21Smrg    exit $?
1630786a6f21Smrg}
16311d54945dSmrg
1632786a6f21Smrg  # Now that we've collected a possible --mode arg, show help if necessary
1633786a6f21Smrg  $opt_help && func_mode_help
16341d54945dSmrg
16351d54945dSmrg
1636786a6f21Smrg# func_mode_execute arg...
1637786a6f21Smrgfunc_mode_execute ()
1638786a6f21Smrg{
1639786a6f21Smrg    $opt_debug
1640786a6f21Smrg    # The first argument is the command name.
1641786a6f21Smrg    cmd="$nonopt"
1642786a6f21Smrg    test -z "$cmd" && \
1643786a6f21Smrg      func_fatal_help "you must specify a COMMAND"
16441d54945dSmrg
1645786a6f21Smrg    # Handle -dlopen flags immediately.
1646786a6f21Smrg    for file in $execute_dlfiles; do
1647786a6f21Smrg      test -f "$file" \
1648786a6f21Smrg	|| func_fatal_help "\`$file' is not a file"
16491d54945dSmrg
1650786a6f21Smrg      dir=
1651786a6f21Smrg      case $file in
1652786a6f21Smrg      *.la)
1653786a6f21Smrg	# Check to see that this really is a libtool archive.
1654786a6f21Smrg	func_lalib_unsafe_p "$file" \
1655786a6f21Smrg	  || func_fatal_help "\`$lib' is not a valid libtool archive"
16561d54945dSmrg
1657786a6f21Smrg	# Read the libtool library.
1658786a6f21Smrg	dlname=
1659786a6f21Smrg	library_names=
1660786a6f21Smrg	func_source "$file"
16611d54945dSmrg
1662786a6f21Smrg	# Skip this library if it cannot be dlopened.
1663786a6f21Smrg	if test -z "$dlname"; then
1664786a6f21Smrg	  # Warn if it was a shared library.
1665786a6f21Smrg	  test -n "$library_names" && \
1666786a6f21Smrg	    func_warning "\`$file' was not linked with \`-export-dynamic'"
1667786a6f21Smrg	  continue
1668786a6f21Smrg	fi
16691d54945dSmrg
1670786a6f21Smrg	func_dirname "$file" "" "."
1671786a6f21Smrg	dir="$func_dirname_result"
16721d54945dSmrg
1673786a6f21Smrg	if test -f "$dir/$objdir/$dlname"; then
1674786a6f21Smrg	  dir="$dir/$objdir"
1675786a6f21Smrg	else
1676786a6f21Smrg	  if test ! -f "$dir/$dlname"; then
1677786a6f21Smrg	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
1678786a6f21Smrg	  fi
1679786a6f21Smrg	fi
16801d54945dSmrg	;;
16811d54945dSmrg
1682786a6f21Smrg      *.lo)
1683786a6f21Smrg	# Just add the directory containing the .lo file.
1684786a6f21Smrg	func_dirname "$file" "" "."
1685786a6f21Smrg	dir="$func_dirname_result"
16861d54945dSmrg	;;
16871d54945dSmrg
1688786a6f21Smrg      *)
1689786a6f21Smrg	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
16901d54945dSmrg	continue
16911d54945dSmrg	;;
1692786a6f21Smrg      esac
16931d54945dSmrg
1694786a6f21Smrg      # Get the absolute pathname.
1695786a6f21Smrg      absdir=`cd "$dir" && pwd`
1696786a6f21Smrg      test -n "$absdir" && dir="$absdir"
16971d54945dSmrg
1698786a6f21Smrg      # Now add the directory to shlibpath_var.
1699786a6f21Smrg      if eval "test -z \"\$$shlibpath_var\""; then
1700786a6f21Smrg	eval "$shlibpath_var=\"\$dir\""
1701786a6f21Smrg      else
1702786a6f21Smrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
1703786a6f21Smrg      fi
1704786a6f21Smrg    done
17051d54945dSmrg
1706786a6f21Smrg    # This variable tells wrapper scripts just to set shlibpath_var
1707786a6f21Smrg    # rather than running their programs.
1708786a6f21Smrg    libtool_execute_magic="$magic"
17091d54945dSmrg
1710786a6f21Smrg    # Check if any of the arguments is a wrapper script.
1711786a6f21Smrg    args=
1712786a6f21Smrg    for file
1713786a6f21Smrg    do
1714786a6f21Smrg      case $file in
1715786a6f21Smrg      -*) ;;
1716786a6f21Smrg      *)
1717786a6f21Smrg	# Do a test to see if this is really a libtool program.
1718786a6f21Smrg	if func_ltwrapper_script_p "$file"; then
1719786a6f21Smrg	  func_source "$file"
1720786a6f21Smrg	  # Transform arg to wrapped name.
1721786a6f21Smrg	  file="$progdir/$program"
1722786a6f21Smrg	elif func_ltwrapper_executable_p "$file"; then
1723786a6f21Smrg	  func_ltwrapper_scriptname "$file"
1724786a6f21Smrg	  func_source "$func_ltwrapper_scriptname_result"
1725786a6f21Smrg	  # Transform arg to wrapped name.
1726786a6f21Smrg	  file="$progdir/$program"
1727786a6f21Smrg	fi
17281d54945dSmrg	;;
1729786a6f21Smrg      esac
1730786a6f21Smrg      # Quote arguments (to preserve shell metacharacters).
1731786a6f21Smrg      func_quote_for_eval "$file"
1732786a6f21Smrg      args="$args $func_quote_for_eval_result"
1733786a6f21Smrg    done
17341d54945dSmrg
1735786a6f21Smrg    if test "X$opt_dry_run" = Xfalse; then
1736786a6f21Smrg      if test -n "$shlibpath_var"; then
1737786a6f21Smrg	# Export the shlibpath_var.
1738786a6f21Smrg	eval "export $shlibpath_var"
1739786a6f21Smrg      fi
17401d54945dSmrg
1741786a6f21Smrg      # Restore saved environment variables
1742786a6f21Smrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
1743786a6f21Smrg      do
1744786a6f21Smrg	eval "if test \"\${save_$lt_var+set}\" = set; then
1745786a6f21Smrg                $lt_var=\$save_$lt_var; export $lt_var
1746786a6f21Smrg	      else
1747786a6f21Smrg		$lt_unset $lt_var
1748786a6f21Smrg	      fi"
1749786a6f21Smrg      done
17501d54945dSmrg
1751786a6f21Smrg      # Now prepare to actually exec the command.
1752786a6f21Smrg      exec_cmd="\$cmd$args"
1753786a6f21Smrg    else
1754786a6f21Smrg      # Display what would be done.
1755786a6f21Smrg      if test -n "$shlibpath_var"; then
1756786a6f21Smrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
1757786a6f21Smrg	$ECHO "export $shlibpath_var"
1758786a6f21Smrg      fi
1759786a6f21Smrg      $ECHO "$cmd$args"
1760786a6f21Smrg      exit $EXIT_SUCCESS
1761786a6f21Smrg    fi
1762786a6f21Smrg}
17631d54945dSmrg
1764786a6f21Smrgtest "$mode" = execute && func_mode_execute ${1+"$@"}
17651d54945dSmrg
17661d54945dSmrg
1767786a6f21Smrg# func_mode_finish arg...
1768786a6f21Smrgfunc_mode_finish ()
1769786a6f21Smrg{
1770786a6f21Smrg    $opt_debug
1771786a6f21Smrg    libdirs="$nonopt"
1772786a6f21Smrg    admincmds=
17731d54945dSmrg
1774786a6f21Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
1775786a6f21Smrg      for dir
1776786a6f21Smrg      do
1777786a6f21Smrg	libdirs="$libdirs $dir"
1778786a6f21Smrg      done
17791d54945dSmrg
1780786a6f21Smrg      for libdir in $libdirs; do
1781786a6f21Smrg	if test -n "$finish_cmds"; then
1782786a6f21Smrg	  # Do each command in the finish commands.
1783786a6f21Smrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
1784786a6f21Smrg'"$cmd"'"'
1785786a6f21Smrg	fi
1786786a6f21Smrg	if test -n "$finish_eval"; then
1787786a6f21Smrg	  # Do the single finish_eval.
1788786a6f21Smrg	  eval cmds=\"$finish_eval\"
1789786a6f21Smrg	  $opt_dry_run || eval "$cmds" || admincmds="$admincmds
1790786a6f21Smrg       $cmds"
1791786a6f21Smrg	fi
1792786a6f21Smrg      done
1793786a6f21Smrg    fi
17941d54945dSmrg
1795786a6f21Smrg    # Exit here if they wanted silent mode.
1796786a6f21Smrg    $opt_silent && exit $EXIT_SUCCESS
17971d54945dSmrg
1798786a6f21Smrg    $ECHO "X----------------------------------------------------------------------" | $Xsed
1799786a6f21Smrg    $ECHO "Libraries have been installed in:"
1800786a6f21Smrg    for libdir in $libdirs; do
1801786a6f21Smrg      $ECHO "   $libdir"
1802786a6f21Smrg    done
1803786a6f21Smrg    $ECHO
1804786a6f21Smrg    $ECHO "If you ever happen to want to link against installed libraries"
1805786a6f21Smrg    $ECHO "in a given directory, LIBDIR, you must either use libtool, and"
1806786a6f21Smrg    $ECHO "specify the full pathname of the library, or use the \`-LLIBDIR'"
1807786a6f21Smrg    $ECHO "flag during linking and do at least one of the following:"
1808786a6f21Smrg    if test -n "$shlibpath_var"; then
1809786a6f21Smrg      $ECHO "   - add LIBDIR to the \`$shlibpath_var' environment variable"
1810786a6f21Smrg      $ECHO "     during execution"
1811786a6f21Smrg    fi
1812786a6f21Smrg    if test -n "$runpath_var"; then
1813786a6f21Smrg      $ECHO "   - add LIBDIR to the \`$runpath_var' environment variable"
1814786a6f21Smrg      $ECHO "     during linking"
1815786a6f21Smrg    fi
1816786a6f21Smrg    if test -n "$hardcode_libdir_flag_spec"; then
1817786a6f21Smrg      libdir=LIBDIR
1818786a6f21Smrg      eval flag=\"$hardcode_libdir_flag_spec\"
18191d54945dSmrg
1820786a6f21Smrg      $ECHO "   - use the \`$flag' linker flag"
1821786a6f21Smrg    fi
1822786a6f21Smrg    if test -n "$admincmds"; then
1823786a6f21Smrg      $ECHO "   - have your system administrator run these commands:$admincmds"
1824786a6f21Smrg    fi
1825786a6f21Smrg    if test -f /etc/ld.so.conf; then
1826786a6f21Smrg      $ECHO "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
1827786a6f21Smrg    fi
1828786a6f21Smrg    $ECHO
18291d54945dSmrg
1830786a6f21Smrg    $ECHO "See any operating system documentation about shared libraries for"
1831786a6f21Smrg    case $host in
1832786a6f21Smrg      solaris2.[6789]|solaris2.1[0-9])
1833786a6f21Smrg        $ECHO "more information, such as the ld(1), crle(1) and ld.so(8) manual"
1834786a6f21Smrg	$ECHO "pages."
1835786a6f21Smrg	;;
1836786a6f21Smrg      *)
1837786a6f21Smrg        $ECHO "more information, such as the ld(1) and ld.so(8) manual pages."
1838786a6f21Smrg        ;;
1839786a6f21Smrg    esac
1840786a6f21Smrg    $ECHO "X----------------------------------------------------------------------" | $Xsed
1841786a6f21Smrg    exit $EXIT_SUCCESS
1842786a6f21Smrg}
18431d54945dSmrg
1844786a6f21Smrgtest "$mode" = finish && func_mode_finish ${1+"$@"}
18451d54945dSmrg
18461d54945dSmrg
1847786a6f21Smrg# func_mode_install arg...
1848786a6f21Smrgfunc_mode_install ()
1849786a6f21Smrg{
1850786a6f21Smrg    $opt_debug
1851786a6f21Smrg    # There may be an optional sh(1) argument at the beginning of
1852786a6f21Smrg    # install_prog (especially on Windows NT).
1853786a6f21Smrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
1854786a6f21Smrg       # Allow the use of GNU shtool's install command.
1855786a6f21Smrg       $ECHO "X$nonopt" | $GREP shtool >/dev/null; then
1856786a6f21Smrg      # Aesthetically quote it.
1857786a6f21Smrg      func_quote_for_eval "$nonopt"
1858786a6f21Smrg      install_prog="$func_quote_for_eval_result "
1859786a6f21Smrg      arg=$1
1860786a6f21Smrg      shift
1861786a6f21Smrg    else
1862786a6f21Smrg      install_prog=
1863786a6f21Smrg      arg=$nonopt
1864786a6f21Smrg    fi
18651d54945dSmrg
1866786a6f21Smrg    # The real first argument should be the name of the installation program.
1867786a6f21Smrg    # Aesthetically quote it.
1868786a6f21Smrg    func_quote_for_eval "$arg"
1869786a6f21Smrg    install_prog="$install_prog$func_quote_for_eval_result"
18701d54945dSmrg
1871786a6f21Smrg    # We need to accept at least all the BSD install flags.
1872786a6f21Smrg    dest=
1873786a6f21Smrg    files=
1874786a6f21Smrg    opts=
1875786a6f21Smrg    prev=
1876786a6f21Smrg    install_type=
1877786a6f21Smrg    isdir=no
1878786a6f21Smrg    stripme=
1879786a6f21Smrg    for arg
1880786a6f21Smrg    do
1881786a6f21Smrg      if test -n "$dest"; then
1882786a6f21Smrg	files="$files $dest"
1883786a6f21Smrg	dest=$arg
18841d54945dSmrg	continue
1885786a6f21Smrg      fi
18861d54945dSmrg
1887786a6f21Smrg      case $arg in
1888786a6f21Smrg      -d) isdir=yes ;;
1889786a6f21Smrg      -f)
1890786a6f21Smrg	case " $install_prog " in
1891786a6f21Smrg	*[\\\ /]cp\ *) ;;
1892786a6f21Smrg	*) prev=$arg ;;
1893786a6f21Smrg	esac
1894786a6f21Smrg	;;
1895786a6f21Smrg      -g | -m | -o)
1896786a6f21Smrg	prev=$arg
1897786a6f21Smrg	;;
1898786a6f21Smrg      -s)
1899786a6f21Smrg	stripme=" -s"
1900786a6f21Smrg	continue
1901786a6f21Smrg	;;
1902786a6f21Smrg      -*)
1903786a6f21Smrg	;;
1904786a6f21Smrg      *)
1905786a6f21Smrg	# If the previous option needed an argument, then skip it.
1906786a6f21Smrg	if test -n "$prev"; then
19071d54945dSmrg	  prev=
19081d54945dSmrg	else
1909786a6f21Smrg	  dest=$arg
1910786a6f21Smrg	  continue
19111d54945dSmrg	fi
19121d54945dSmrg	;;
1913786a6f21Smrg      esac
19141d54945dSmrg
1915786a6f21Smrg      # Aesthetically quote the argument.
1916786a6f21Smrg      func_quote_for_eval "$arg"
1917786a6f21Smrg      install_prog="$install_prog $func_quote_for_eval_result"
1918786a6f21Smrg    done
19191d54945dSmrg
1920786a6f21Smrg    test -z "$install_prog" && \
1921786a6f21Smrg      func_fatal_help "you must specify an install program"
19221d54945dSmrg
1923786a6f21Smrg    test -n "$prev" && \
1924786a6f21Smrg      func_fatal_help "the \`$prev' option requires an argument"
19251d54945dSmrg
1926786a6f21Smrg    if test -z "$files"; then
1927786a6f21Smrg      if test -z "$dest"; then
1928786a6f21Smrg	func_fatal_help "no file or destination specified"
1929786a6f21Smrg      else
1930786a6f21Smrg	func_fatal_help "you must specify a destination"
1931786a6f21Smrg      fi
19321d54945dSmrg    fi
19331d54945dSmrg
1934786a6f21Smrg    # Strip any trailing slash from the destination.
1935786a6f21Smrg    func_stripname '' '/' "$dest"
1936786a6f21Smrg    dest=$func_stripname_result
19371d54945dSmrg
1938786a6f21Smrg    # Check to see that the destination is a directory.
1939786a6f21Smrg    test -d "$dest" && isdir=yes
1940786a6f21Smrg    if test "$isdir" = yes; then
1941786a6f21Smrg      destdir="$dest"
1942786a6f21Smrg      destname=
19431d54945dSmrg    else
1944786a6f21Smrg      func_dirname_and_basename "$dest" "" "."
1945786a6f21Smrg      destdir="$func_dirname_result"
1946786a6f21Smrg      destname="$func_basename_result"
19471d54945dSmrg
1948786a6f21Smrg      # Not a directory, so check to see that there is only one file specified.
1949786a6f21Smrg      set dummy $files; shift
1950786a6f21Smrg      test "$#" -gt 1 && \
1951786a6f21Smrg	func_fatal_help "\`$dest' is not a directory"
19521d54945dSmrg    fi
1953786a6f21Smrg    case $destdir in
1954786a6f21Smrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
19551d54945dSmrg    *)
1956786a6f21Smrg      for file in $files; do
1957786a6f21Smrg	case $file in
1958786a6f21Smrg	*.lo) ;;
1959786a6f21Smrg	*)
1960786a6f21Smrg	  func_fatal_help "\`$destdir' must be an absolute directory name"
1961786a6f21Smrg	  ;;
1962786a6f21Smrg	esac
1963786a6f21Smrg      done
19641d54945dSmrg      ;;
19651d54945dSmrg    esac
19661d54945dSmrg
1967786a6f21Smrg    # This variable tells wrapper scripts just to set variables rather
1968786a6f21Smrg    # than running their programs.
1969786a6f21Smrg    libtool_install_magic="$magic"
19701d54945dSmrg
1971786a6f21Smrg    staticlibs=
1972786a6f21Smrg    future_libdirs=
1973786a6f21Smrg    current_libdirs=
1974786a6f21Smrg    for file in $files; do
19751d54945dSmrg
1976786a6f21Smrg      # Do each installation.
1977786a6f21Smrg      case $file in
1978786a6f21Smrg      *.$libext)
1979786a6f21Smrg	# Do the static libraries later.
1980786a6f21Smrg	staticlibs="$staticlibs $file"
1981786a6f21Smrg	;;
1982786a6f21Smrg
1983786a6f21Smrg      *.la)
1984786a6f21Smrg	# Check to see that this really is a libtool archive.
1985786a6f21Smrg	func_lalib_unsafe_p "$file" \
1986786a6f21Smrg	  || func_fatal_help "\`$file' is not a valid libtool archive"
1987786a6f21Smrg
1988786a6f21Smrg	library_names=
1989786a6f21Smrg	old_library=
1990786a6f21Smrg	relink_command=
1991786a6f21Smrg	func_source "$file"
1992786a6f21Smrg
1993786a6f21Smrg	# Add the libdir to current_libdirs if it is the destination.
1994786a6f21Smrg	if test "X$destdir" = "X$libdir"; then
1995786a6f21Smrg	  case "$current_libdirs " in
1996786a6f21Smrg	  *" $libdir "*) ;;
1997786a6f21Smrg	  *) current_libdirs="$current_libdirs $libdir" ;;
19981d54945dSmrg	  esac
1999786a6f21Smrg	else
2000786a6f21Smrg	  # Note the libdir as a future libdir.
2001786a6f21Smrg	  case "$future_libdirs " in
2002786a6f21Smrg	  *" $libdir "*) ;;
2003786a6f21Smrg	  *) future_libdirs="$future_libdirs $libdir" ;;
2004786a6f21Smrg	  esac
2005786a6f21Smrg	fi
20061d54945dSmrg
2007786a6f21Smrg	func_dirname "$file" "/" ""
2008786a6f21Smrg	dir="$func_dirname_result"
2009786a6f21Smrg	dir="$dir$objdir"
2010786a6f21Smrg
2011786a6f21Smrg	if test -n "$relink_command"; then
2012786a6f21Smrg	  # Determine the prefix the user has applied to our future dir.
2013786a6f21Smrg	  inst_prefix_dir=`$ECHO "X$destdir" | $Xsed -e "s%$libdir\$%%"`
2014786a6f21Smrg
2015786a6f21Smrg	  # Don't allow the user to place us outside of our expected
2016786a6f21Smrg	  # location b/c this prevents finding dependent libraries that
2017786a6f21Smrg	  # are installed to the same prefix.
2018786a6f21Smrg	  # At present, this check doesn't affect windows .dll's that
2019786a6f21Smrg	  # are installed into $libdir/../bin (currently, that works fine)
2020786a6f21Smrg	  # but it's something to keep an eye on.
2021786a6f21Smrg	  test "$inst_prefix_dir" = "$destdir" && \
2022786a6f21Smrg	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
2023786a6f21Smrg
2024786a6f21Smrg	  if test -n "$inst_prefix_dir"; then
2025786a6f21Smrg	    # Stick the inst_prefix_dir data into the link command.
2026786a6f21Smrg	    relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
2027786a6f21Smrg	  else
2028786a6f21Smrg	    relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%%"`
2029786a6f21Smrg	  fi
2030786a6f21Smrg
2031786a6f21Smrg	  func_warning "relinking \`$file'"
2032786a6f21Smrg	  func_show_eval "$relink_command" \
2033786a6f21Smrg	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
2034786a6f21Smrg	fi
2035786a6f21Smrg
2036786a6f21Smrg	# See the names of the shared library.
2037786a6f21Smrg	set dummy $library_names; shift
2038786a6f21Smrg	if test -n "$1"; then
2039786a6f21Smrg	  realname="$1"
2040786a6f21Smrg	  shift
2041786a6f21Smrg
2042786a6f21Smrg	  srcname="$realname"
2043786a6f21Smrg	  test -n "$relink_command" && srcname="$realname"T
2044786a6f21Smrg
2045786a6f21Smrg	  # Install the shared library and build the symlinks.
2046786a6f21Smrg	  func_show_eval "$install_prog $dir/$srcname $destdir/$realname" \
2047786a6f21Smrg	      'exit $?'
2048786a6f21Smrg	  tstripme="$stripme"
2049786a6f21Smrg	  case $host_os in
2050786a6f21Smrg	  cygwin* | mingw* | pw32* | cegcc*)
2051786a6f21Smrg	    case $realname in
2052786a6f21Smrg	    *.dll.a)
2053786a6f21Smrg	      tstripme=""
2054786a6f21Smrg	      ;;
2055786a6f21Smrg	    esac
20561d54945dSmrg	    ;;
20571d54945dSmrg	  esac
2058786a6f21Smrg	  if test -n "$tstripme" && test -n "$striplib"; then
2059786a6f21Smrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
2060786a6f21Smrg	  fi
2061786a6f21Smrg
2062786a6f21Smrg	  if test "$#" -gt 0; then
2063786a6f21Smrg	    # Delete the old symlinks, and create new ones.
2064786a6f21Smrg	    # Try `ln -sf' first, because the `ln' binary might depend on
2065786a6f21Smrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
2066786a6f21Smrg	    # so we also need to try rm && ln -s.
2067786a6f21Smrg	    for linkname
2068786a6f21Smrg	    do
2069786a6f21Smrg	      test "$linkname" != "$realname" \
2070786a6f21Smrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
2071786a6f21Smrg	    done
2072786a6f21Smrg	  fi
2073786a6f21Smrg
2074786a6f21Smrg	  # Do each command in the postinstall commands.
2075786a6f21Smrg	  lib="$destdir/$realname"
2076786a6f21Smrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
2077786a6f21Smrg	fi
2078786a6f21Smrg
2079786a6f21Smrg	# Install the pseudo-library for information purposes.
2080786a6f21Smrg	func_basename "$file"
2081786a6f21Smrg	name="$func_basename_result"
2082786a6f21Smrg	instname="$dir/$name"i
2083786a6f21Smrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
2084786a6f21Smrg
2085786a6f21Smrg	# Maybe install the static library, too.
2086786a6f21Smrg	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
20871d54945dSmrg	;;
2088786a6f21Smrg
2089786a6f21Smrg      *.lo)
2090786a6f21Smrg	# Install (i.e. copy) a libtool object.
2091786a6f21Smrg
2092786a6f21Smrg	# Figure out destination file name, if it wasn't already specified.
2093786a6f21Smrg	if test -n "$destname"; then
2094786a6f21Smrg	  destfile="$destdir/$destname"
2095786a6f21Smrg	else
2096786a6f21Smrg	  func_basename "$file"
2097786a6f21Smrg	  destfile="$func_basename_result"
2098786a6f21Smrg	  destfile="$destdir/$destfile"
2099786a6f21Smrg	fi
2100786a6f21Smrg
2101786a6f21Smrg	# Deduce the name of the destination old-style object file.
2102786a6f21Smrg	case $destfile in
2103786a6f21Smrg	*.lo)
2104786a6f21Smrg	  func_lo2o "$destfile"
2105786a6f21Smrg	  staticdest=$func_lo2o_result
21061d54945dSmrg	  ;;
2107786a6f21Smrg	*.$objext)
2108786a6f21Smrg	  staticdest="$destfile"
2109786a6f21Smrg	  destfile=
21101d54945dSmrg	  ;;
2111786a6f21Smrg	*)
2112786a6f21Smrg	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
21131d54945dSmrg	  ;;
2114786a6f21Smrg	esac
2115786a6f21Smrg
2116786a6f21Smrg	# Install the libtool object if requested.
2117786a6f21Smrg	test -n "$destfile" && \
2118786a6f21Smrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
2119786a6f21Smrg
2120786a6f21Smrg	# Install the old object if enabled.
2121786a6f21Smrg	if test "$build_old_libs" = yes; then
2122786a6f21Smrg	  # Deduce the name of the old-style object file.
2123786a6f21Smrg	  func_lo2o "$file"
2124786a6f21Smrg	  staticobj=$func_lo2o_result
2125786a6f21Smrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
21261d54945dSmrg	fi
2127786a6f21Smrg	exit $EXIT_SUCCESS
2128786a6f21Smrg	;;
21291d54945dSmrg
2130786a6f21Smrg      *)
2131786a6f21Smrg	# Figure out destination file name, if it wasn't already specified.
2132786a6f21Smrg	if test -n "$destname"; then
2133786a6f21Smrg	  destfile="$destdir/$destname"
21341d54945dSmrg	else
2135786a6f21Smrg	  func_basename "$file"
2136786a6f21Smrg	  destfile="$func_basename_result"
2137786a6f21Smrg	  destfile="$destdir/$destfile"
21381d54945dSmrg	fi
21391d54945dSmrg
2140786a6f21Smrg	# If the file is missing, and there is a .exe on the end, strip it
2141786a6f21Smrg	# because it is most likely a libtool script we actually want to
2142786a6f21Smrg	# install
2143786a6f21Smrg	stripped_ext=""
2144786a6f21Smrg	case $file in
2145786a6f21Smrg	  *.exe)
2146786a6f21Smrg	    if test ! -f "$file"; then
2147786a6f21Smrg	      func_stripname '' '.exe' "$file"
2148786a6f21Smrg	      file=$func_stripname_result
2149786a6f21Smrg	      stripped_ext=".exe"
2150786a6f21Smrg	    fi
2151786a6f21Smrg	    ;;
2152786a6f21Smrg	esac
21531d54945dSmrg
2154786a6f21Smrg	# Do a test to see if this is really a libtool program.
2155786a6f21Smrg	case $host in
2156786a6f21Smrg	*cygwin* | *mingw*)
2157786a6f21Smrg	    if func_ltwrapper_executable_p "$file"; then
2158786a6f21Smrg	      func_ltwrapper_scriptname "$file"
2159786a6f21Smrg	      wrapper=$func_ltwrapper_scriptname_result
2160786a6f21Smrg	    else
2161786a6f21Smrg	      func_stripname '' '.exe' "$file"
2162786a6f21Smrg	      wrapper=$func_stripname_result
2163786a6f21Smrg	    fi
2164786a6f21Smrg	    ;;
2165786a6f21Smrg	*)
2166786a6f21Smrg	    wrapper=$file
2167786a6f21Smrg	    ;;
21681d54945dSmrg	esac
2169786a6f21Smrg	if func_ltwrapper_script_p "$wrapper"; then
2170786a6f21Smrg	  notinst_deplibs=
2171786a6f21Smrg	  relink_command=
21721d54945dSmrg
2173786a6f21Smrg	  func_source "$wrapper"
21741d54945dSmrg
2175786a6f21Smrg	  # Check the variables that should have been set.
2176786a6f21Smrg	  test -z "$generated_by_libtool_version" && \
2177786a6f21Smrg	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
2178786a6f21Smrg
2179786a6f21Smrg	  finalize=yes
2180786a6f21Smrg	  for lib in $notinst_deplibs; do
2181786a6f21Smrg	    # Check to see that each library is installed.
2182786a6f21Smrg	    libdir=
2183786a6f21Smrg	    if test -f "$lib"; then
2184786a6f21Smrg	      func_source "$lib"
21851d54945dSmrg	    fi
2186786a6f21Smrg	    libfile="$libdir/"`$ECHO "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
2187786a6f21Smrg	    if test -n "$libdir" && test ! -f "$libfile"; then
2188786a6f21Smrg	      func_warning "\`$lib' has not been installed in \`$libdir'"
2189786a6f21Smrg	      finalize=no
2190786a6f21Smrg	    fi
2191786a6f21Smrg	  done
21921d54945dSmrg
2193786a6f21Smrg	  relink_command=
2194786a6f21Smrg	  func_source "$wrapper"
21951d54945dSmrg
2196786a6f21Smrg	  outputname=
2197786a6f21Smrg	  if test "$fast_install" = no && test -n "$relink_command"; then
2198786a6f21Smrg	    $opt_dry_run || {
2199786a6f21Smrg	      if test "$finalize" = yes; then
2200786a6f21Smrg	        tmpdir=`func_mktempdir`
2201786a6f21Smrg		func_basename "$file$stripped_ext"
2202786a6f21Smrg		file="$func_basename_result"
2203786a6f21Smrg	        outputname="$tmpdir/$file"
2204786a6f21Smrg	        # Replace the output file specification.
2205786a6f21Smrg	        relink_command=`$ECHO "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
2206786a6f21Smrg
2207786a6f21Smrg	        $opt_silent || {
2208786a6f21Smrg	          func_quote_for_expand "$relink_command"
2209786a6f21Smrg		  eval "func_echo $func_quote_for_expand_result"
2210786a6f21Smrg	        }
2211786a6f21Smrg	        if eval "$relink_command"; then :
2212786a6f21Smrg	          else
2213786a6f21Smrg		  func_error "error: relink \`$file' with the above command before installing it"
2214786a6f21Smrg		  $opt_dry_run || ${RM}r "$tmpdir"
2215786a6f21Smrg		  continue
2216786a6f21Smrg	        fi
2217786a6f21Smrg	        file="$outputname"
2218786a6f21Smrg	      else
2219786a6f21Smrg	        func_warning "cannot relink \`$file'"
2220786a6f21Smrg	      fi
2221786a6f21Smrg	    }
22221d54945dSmrg	  else
2223786a6f21Smrg	    # Install the binary that we compiled earlier.
2224786a6f21Smrg	    file=`$ECHO "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
22251d54945dSmrg	  fi
2226786a6f21Smrg	fi
22271d54945dSmrg
2228786a6f21Smrg	# remove .exe since cygwin /usr/bin/install will append another
2229786a6f21Smrg	# one anyway
2230786a6f21Smrg	case $install_prog,$host in
2231786a6f21Smrg	*/usr/bin/install*,*cygwin*)
2232786a6f21Smrg	  case $file:$destfile in
2233786a6f21Smrg	  *.exe:*.exe)
2234786a6f21Smrg	    # this is ok
2235786a6f21Smrg	    ;;
2236786a6f21Smrg	  *.exe:*)
2237786a6f21Smrg	    destfile=$destfile.exe
2238786a6f21Smrg	    ;;
2239786a6f21Smrg	  *:*.exe)
2240786a6f21Smrg	    func_stripname '' '.exe' "$destfile"
2241786a6f21Smrg	    destfile=$func_stripname_result
2242786a6f21Smrg	    ;;
2243786a6f21Smrg	  esac
22441d54945dSmrg	  ;;
22451d54945dSmrg	esac
2246786a6f21Smrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
2247786a6f21Smrg	$opt_dry_run || if test -n "$outputname"; then
2248786a6f21Smrg	  ${RM}r "$tmpdir"
2249786a6f21Smrg	fi
2250786a6f21Smrg	;;
2251786a6f21Smrg      esac
2252786a6f21Smrg    done
22531d54945dSmrg
2254786a6f21Smrg    for file in $staticlibs; do
2255786a6f21Smrg      func_basename "$file"
2256786a6f21Smrg      name="$func_basename_result"
22571d54945dSmrg
2258786a6f21Smrg      # Set up the ranlib parameters.
2259786a6f21Smrg      oldlib="$destdir/$name"
2260786a6f21Smrg
2261786a6f21Smrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
2262786a6f21Smrg
2263786a6f21Smrg      if test -n "$stripme" && test -n "$old_striplib"; then
2264786a6f21Smrg	func_show_eval "$old_striplib $oldlib" 'exit $?'
2265786a6f21Smrg      fi
2266786a6f21Smrg
2267786a6f21Smrg      # Do each command in the postinstall commands.
2268786a6f21Smrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
2269786a6f21Smrg    done
2270786a6f21Smrg
2271786a6f21Smrg    test -n "$future_libdirs" && \
2272786a6f21Smrg      func_warning "remember to run \`$progname --finish$future_libdirs'"
2273786a6f21Smrg
2274786a6f21Smrg    if test -n "$current_libdirs"; then
2275786a6f21Smrg      # Maybe just do a dry run.
2276786a6f21Smrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
2277786a6f21Smrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
2278786a6f21Smrg    else
2279786a6f21Smrg      exit $EXIT_SUCCESS
2280786a6f21Smrg    fi
2281786a6f21Smrg}
2282786a6f21Smrg
2283786a6f21Smrgtest "$mode" = install && func_mode_install ${1+"$@"}
2284786a6f21Smrg
2285786a6f21Smrg
2286786a6f21Smrg# func_generate_dlsyms outputname originator pic_p
2287786a6f21Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with
2288786a6f21Smrg# a dlpreopen symbol table.
2289786a6f21Smrgfunc_generate_dlsyms ()
2290786a6f21Smrg{
2291786a6f21Smrg    $opt_debug
2292786a6f21Smrg    my_outputname="$1"
2293786a6f21Smrg    my_originator="$2"
2294786a6f21Smrg    my_pic_p="${3-no}"
2295786a6f21Smrg    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
2296786a6f21Smrg    my_dlsyms=
2297786a6f21Smrg
2298786a6f21Smrg    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
2299786a6f21Smrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
2300786a6f21Smrg	my_dlsyms="${my_outputname}S.c"
2301786a6f21Smrg      else
2302786a6f21Smrg	func_error "not configured to extract global symbols from dlpreopened files"
2303786a6f21Smrg      fi
2304786a6f21Smrg    fi
2305786a6f21Smrg
2306786a6f21Smrg    if test -n "$my_dlsyms"; then
2307786a6f21Smrg      case $my_dlsyms in
2308786a6f21Smrg      "") ;;
2309786a6f21Smrg      *.c)
2310786a6f21Smrg	# Discover the nlist of each of the dlfiles.
2311786a6f21Smrg	nlist="$output_objdir/${my_outputname}.nm"
2312786a6f21Smrg
2313786a6f21Smrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
2314786a6f21Smrg
2315786a6f21Smrg	# Parse the name list into a source file.
2316786a6f21Smrg	func_verbose "creating $output_objdir/$my_dlsyms"
2317786a6f21Smrg
2318786a6f21Smrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
2319786a6f21Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
2320786a6f21Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
2321786a6f21Smrg
2322786a6f21Smrg#ifdef __cplusplus
2323786a6f21Smrgextern \"C\" {
2324786a6f21Smrg#endif
2325786a6f21Smrg
2326786a6f21Smrg/* External symbol declarations for the compiler. */\
2327786a6f21Smrg"
2328786a6f21Smrg
2329786a6f21Smrg	if test "$dlself" = yes; then
2330786a6f21Smrg	  func_verbose "generating symbol list for \`$output'"
2331786a6f21Smrg
2332786a6f21Smrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
2333786a6f21Smrg
2334786a6f21Smrg	  # Add our own program objects to the symbol list.
2335786a6f21Smrg	  progfiles=`$ECHO "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
2336786a6f21Smrg	  for progfile in $progfiles; do
2337786a6f21Smrg	    func_verbose "extracting global C symbols from \`$progfile'"
2338786a6f21Smrg	    $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'"
2339786a6f21Smrg	  done
2340786a6f21Smrg
2341786a6f21Smrg	  if test -n "$exclude_expsyms"; then
2342786a6f21Smrg	    $opt_dry_run || {
2343786a6f21Smrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
2344786a6f21Smrg	      eval '$MV "$nlist"T "$nlist"'
2345786a6f21Smrg	    }
23461d54945dSmrg	  fi
2347786a6f21Smrg
2348786a6f21Smrg	  if test -n "$export_symbols_regex"; then
2349786a6f21Smrg	    $opt_dry_run || {
2350786a6f21Smrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
2351786a6f21Smrg	      eval '$MV "$nlist"T "$nlist"'
2352786a6f21Smrg	    }
23531d54945dSmrg	  fi
23541d54945dSmrg
2355786a6f21Smrg	  # Prepare the list of exported symbols
2356786a6f21Smrg	  if test -z "$export_symbols"; then
2357786a6f21Smrg	    export_symbols="$output_objdir/$outputname.exp"
2358786a6f21Smrg	    $opt_dry_run || {
2359786a6f21Smrg	      $RM $export_symbols
2360786a6f21Smrg	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
2361786a6f21Smrg	      case $host in
2362786a6f21Smrg	      *cygwin* | *mingw* | *cegcc* )
2363786a6f21Smrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
2364786a6f21Smrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
2365786a6f21Smrg	        ;;
2366786a6f21Smrg	      esac
2367786a6f21Smrg	    }
23681d54945dSmrg	  else
2369786a6f21Smrg	    $opt_dry_run || {
2370786a6f21Smrg	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
2371786a6f21Smrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
2372786a6f21Smrg	      eval '$MV "$nlist"T "$nlist"'
2373786a6f21Smrg	      case $host in
2374786a6f21Smrg	        *cygwin | *mingw* | *cegcc* )
2375786a6f21Smrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
2376786a6f21Smrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
2377786a6f21Smrg	          ;;
2378786a6f21Smrg	      esac
2379786a6f21Smrg	    }
23801d54945dSmrg	  fi
23811d54945dSmrg	fi
23821d54945dSmrg
2383786a6f21Smrg	for dlprefile in $dlprefiles; do
2384786a6f21Smrg	  func_verbose "extracting global C symbols from \`$dlprefile'"
2385786a6f21Smrg	  func_basename "$dlprefile"
2386786a6f21Smrg	  name="$func_basename_result"
2387786a6f21Smrg	  $opt_dry_run || {
2388786a6f21Smrg	    eval '$ECHO ": $name " >> "$nlist"'
2389786a6f21Smrg	    eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'"
2390786a6f21Smrg	  }
2391786a6f21Smrg	done
23921d54945dSmrg
2393786a6f21Smrg	$opt_dry_run || {
2394786a6f21Smrg	  # Make sure we have at least an empty file.
2395786a6f21Smrg	  test -f "$nlist" || : > "$nlist"
23961d54945dSmrg
2397786a6f21Smrg	  if test -n "$exclude_expsyms"; then
2398786a6f21Smrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
2399786a6f21Smrg	    $MV "$nlist"T "$nlist"
24001d54945dSmrg	  fi
24011d54945dSmrg
2402786a6f21Smrg	  # Try sorting and uniquifying the output.
2403786a6f21Smrg	  if $GREP -v "^: " < "$nlist" |
2404786a6f21Smrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
2405786a6f21Smrg		sort -k 3
2406786a6f21Smrg	      else
2407786a6f21Smrg		sort +2
2408786a6f21Smrg	      fi |
2409786a6f21Smrg	      uniq > "$nlist"S; then
2410786a6f21Smrg	    :
2411786a6f21Smrg	  else
2412786a6f21Smrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
2413786a6f21Smrg	  fi
24141d54945dSmrg
2415786a6f21Smrg	  if test -f "$nlist"S; then
2416786a6f21Smrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
2417786a6f21Smrg	  else
2418786a6f21Smrg	    $ECHO '/* NONE */' >> "$output_objdir/$my_dlsyms"
2419786a6f21Smrg	  fi
24201d54945dSmrg
2421786a6f21Smrg	  $ECHO >> "$output_objdir/$my_dlsyms" "\
24221d54945dSmrg
2423786a6f21Smrg/* The mapping between symbol names and symbols.  */
2424786a6f21Smrgtypedef struct {
2425786a6f21Smrg  const char *name;
2426786a6f21Smrg  void *address;
2427786a6f21Smrg} lt_dlsymlist;
2428786a6f21Smrg"
2429786a6f21Smrg	  case $host in
2430786a6f21Smrg	  *cygwin* | *mingw* | *cegcc* )
2431786a6f21Smrg	    $ECHO >> "$output_objdir/$my_dlsyms" "\
2432786a6f21Smrg/* DATA imports from DLLs on WIN32 con't be const, because
2433786a6f21Smrg   runtime relocations are performed -- see ld's documentation
2434786a6f21Smrg   on pseudo-relocs.  */"
2435786a6f21Smrg	    lt_dlsym_const= ;;
2436786a6f21Smrg	  *osf5*)
2437786a6f21Smrg	    echo >> "$output_objdir/$my_dlsyms" "\
2438786a6f21Smrg/* This system does not cope well with relocations in const data */"
2439786a6f21Smrg	    lt_dlsym_const= ;;
2440786a6f21Smrg	  *)
2441786a6f21Smrg	    lt_dlsym_const=const ;;
2442786a6f21Smrg	  esac
24431d54945dSmrg
2444786a6f21Smrg	  $ECHO >> "$output_objdir/$my_dlsyms" "\
2445786a6f21Smrgextern $lt_dlsym_const lt_dlsymlist
2446786a6f21Smrglt_${my_prefix}_LTX_preloaded_symbols[];
2447786a6f21Smrg$lt_dlsym_const lt_dlsymlist
2448786a6f21Smrglt_${my_prefix}_LTX_preloaded_symbols[] =
2449786a6f21Smrg{\
2450786a6f21Smrg  { \"$my_originator\", (void *) 0 },"
24511d54945dSmrg
2452786a6f21Smrg	  case $need_lib_prefix in
2453786a6f21Smrg	  no)
2454786a6f21Smrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
2455786a6f21Smrg	    ;;
2456786a6f21Smrg	  *)
2457786a6f21Smrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
2458786a6f21Smrg	    ;;
2459786a6f21Smrg	  esac
2460786a6f21Smrg	  $ECHO >> "$output_objdir/$my_dlsyms" "\
2461786a6f21Smrg  {0, (void *) 0}
2462786a6f21Smrg};
24631d54945dSmrg
2464786a6f21Smrg/* This works around a problem in FreeBSD linker */
2465786a6f21Smrg#ifdef FREEBSD_WORKAROUND
2466786a6f21Smrgstatic const void *lt_preloaded_setup() {
2467786a6f21Smrg  return lt_${my_prefix}_LTX_preloaded_symbols;
2468786a6f21Smrg}
2469786a6f21Smrg#endif
24701d54945dSmrg
2471786a6f21Smrg#ifdef __cplusplus
2472786a6f21Smrg}
2473786a6f21Smrg#endif\
2474786a6f21Smrg"
2475786a6f21Smrg	} # !$opt_dry_run
24761d54945dSmrg
2477786a6f21Smrg	pic_flag_for_symtable=
2478786a6f21Smrg	case "$compile_command " in
2479786a6f21Smrg	*" -static "*) ;;
2480786a6f21Smrg	*)
2481786a6f21Smrg	  case $host in
2482786a6f21Smrg	  # compiling the symbol table file with pic_flag works around
2483786a6f21Smrg	  # a FreeBSD bug that causes programs to crash when -lm is
2484786a6f21Smrg	  # linked before any other PIC object.  But we must not use
2485786a6f21Smrg	  # pic_flag when linking with -static.  The problem exists in
2486786a6f21Smrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
2487786a6f21Smrg	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
2488786a6f21Smrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
2489786a6f21Smrg	  *-*-hpux*)
2490786a6f21Smrg	    pic_flag_for_symtable=" $pic_flag"  ;;
2491786a6f21Smrg	  *)
2492786a6f21Smrg	    if test "X$my_pic_p" != Xno; then
2493786a6f21Smrg	      pic_flag_for_symtable=" $pic_flag"
24941d54945dSmrg	    fi
2495786a6f21Smrg	    ;;
2496786a6f21Smrg	  esac
2497786a6f21Smrg	  ;;
2498786a6f21Smrg	esac
2499786a6f21Smrg	symtab_cflags=
2500786a6f21Smrg	for arg in $LTCFLAGS; do
2501786a6f21Smrg	  case $arg in
2502786a6f21Smrg	  -pie | -fpie | -fPIE) ;;
2503786a6f21Smrg	  *) symtab_cflags="$symtab_cflags $arg" ;;
2504786a6f21Smrg	  esac
2505786a6f21Smrg	done
25061d54945dSmrg
2507786a6f21Smrg	# Now compile the dynamic symbol file.
2508786a6f21Smrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
25091d54945dSmrg
2510786a6f21Smrg	# Clean up the generated files.
2511786a6f21Smrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
25121d54945dSmrg
2513786a6f21Smrg	# Transform the symbol file into the correct name.
2514786a6f21Smrg	symfileobj="$output_objdir/${my_outputname}S.$objext"
2515786a6f21Smrg	case $host in
2516786a6f21Smrg	*cygwin* | *mingw* | *cegcc* )
2517786a6f21Smrg	  if test -f "$output_objdir/$my_outputname.def"; then
2518786a6f21Smrg	    compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
2519786a6f21Smrg	    finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
25201d54945dSmrg	  else
2521786a6f21Smrg	    compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2522786a6f21Smrg	    finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
25231d54945dSmrg	  fi
2524786a6f21Smrg	  ;;
2525786a6f21Smrg	*)
2526786a6f21Smrg	  compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2527786a6f21Smrg	  finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2528786a6f21Smrg	  ;;
2529786a6f21Smrg	esac
2530786a6f21Smrg	;;
2531786a6f21Smrg      *)
2532786a6f21Smrg	func_fatal_error "unknown suffix for \`$my_dlsyms'"
2533786a6f21Smrg	;;
2534786a6f21Smrg      esac
2535786a6f21Smrg    else
2536786a6f21Smrg      # We keep going just in case the user didn't refer to
2537786a6f21Smrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
2538786a6f21Smrg      # really was required.
25391d54945dSmrg
2540786a6f21Smrg      # Nullify the symbol file.
2541786a6f21Smrg      compile_command=`$ECHO "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
2542786a6f21Smrg      finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
2543786a6f21Smrg    fi
2544786a6f21Smrg}
25451d54945dSmrg
2546786a6f21Smrg# func_win32_libid arg
2547786a6f21Smrg# return the library type of file 'arg'
2548786a6f21Smrg#
2549786a6f21Smrg# Need a lot of goo to handle *both* DLLs and import libs
2550786a6f21Smrg# Has to be a shell function in order to 'eat' the argument
2551786a6f21Smrg# that is supplied when $file_magic_command is called.
2552786a6f21Smrgfunc_win32_libid ()
2553786a6f21Smrg{
2554786a6f21Smrg  $opt_debug
2555786a6f21Smrg  win32_libid_type="unknown"
2556786a6f21Smrg  win32_fileres=`file -L $1 2>/dev/null`
2557786a6f21Smrg  case $win32_fileres in
2558786a6f21Smrg  *ar\ archive\ import\ library*) # definitely import
2559786a6f21Smrg    win32_libid_type="x86 archive import"
2560786a6f21Smrg    ;;
2561786a6f21Smrg  *ar\ archive*) # could be an import, or static
2562786a6f21Smrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
2563786a6f21Smrg       $EGREP 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
2564786a6f21Smrg      win32_nmres=`eval $NM -f posix -A $1 |
2565786a6f21Smrg	$SED -n -e '
2566786a6f21Smrg	    1,100{
2567786a6f21Smrg		/ I /{
2568786a6f21Smrg		    s,.*,import,
2569786a6f21Smrg		    p
2570786a6f21Smrg		    q
2571786a6f21Smrg		}
2572786a6f21Smrg	    }'`
2573786a6f21Smrg      case $win32_nmres in
2574786a6f21Smrg      import*)  win32_libid_type="x86 archive import";;
2575786a6f21Smrg      *)        win32_libid_type="x86 archive static";;
2576786a6f21Smrg      esac
2577786a6f21Smrg    fi
2578786a6f21Smrg    ;;
2579786a6f21Smrg  *DLL*)
2580786a6f21Smrg    win32_libid_type="x86 DLL"
2581786a6f21Smrg    ;;
2582786a6f21Smrg  *executable*) # but shell scripts are "executable" too...
2583786a6f21Smrg    case $win32_fileres in
2584786a6f21Smrg    *MS\ Windows\ PE\ Intel*)
2585786a6f21Smrg      win32_libid_type="x86 DLL"
2586786a6f21Smrg      ;;
2587786a6f21Smrg    esac
2588786a6f21Smrg    ;;
2589786a6f21Smrg  esac
2590786a6f21Smrg  $ECHO "$win32_libid_type"
2591786a6f21Smrg}
25921d54945dSmrg
25931d54945dSmrg
25941d54945dSmrg
2595786a6f21Smrg# func_extract_an_archive dir oldlib
2596786a6f21Smrgfunc_extract_an_archive ()
2597786a6f21Smrg{
2598786a6f21Smrg    $opt_debug
2599786a6f21Smrg    f_ex_an_ar_dir="$1"; shift
2600786a6f21Smrg    f_ex_an_ar_oldlib="$1"
2601786a6f21Smrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" 'exit $?'
2602786a6f21Smrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
2603786a6f21Smrg     :
2604786a6f21Smrg    else
2605786a6f21Smrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
26061d54945dSmrg    fi
2607786a6f21Smrg}
26081d54945dSmrg
26091d54945dSmrg
2610786a6f21Smrg# func_extract_archives gentop oldlib ...
2611786a6f21Smrgfunc_extract_archives ()
2612786a6f21Smrg{
2613786a6f21Smrg    $opt_debug
2614786a6f21Smrg    my_gentop="$1"; shift
2615786a6f21Smrg    my_oldlibs=${1+"$@"}
2616786a6f21Smrg    my_oldobjs=""
2617786a6f21Smrg    my_xlib=""
2618786a6f21Smrg    my_xabs=""
2619786a6f21Smrg    my_xdir=""
26201d54945dSmrg
2621786a6f21Smrg    for my_xlib in $my_oldlibs; do
2622786a6f21Smrg      # Extract the objects.
2623786a6f21Smrg      case $my_xlib in
2624786a6f21Smrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
2625786a6f21Smrg	*) my_xabs=`pwd`"/$my_xlib" ;;
2626786a6f21Smrg      esac
2627786a6f21Smrg      func_basename "$my_xlib"
2628786a6f21Smrg      my_xlib="$func_basename_result"
2629786a6f21Smrg      my_xlib_u=$my_xlib
2630786a6f21Smrg      while :; do
2631786a6f21Smrg        case " $extracted_archives " in
2632786a6f21Smrg	*" $my_xlib_u "*)
2633786a6f21Smrg	  func_arith $extracted_serial + 1
2634786a6f21Smrg	  extracted_serial=$func_arith_result
2635786a6f21Smrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
2636786a6f21Smrg	*) break ;;
2637786a6f21Smrg	esac
2638786a6f21Smrg      done
2639786a6f21Smrg      extracted_archives="$extracted_archives $my_xlib_u"
2640786a6f21Smrg      my_xdir="$my_gentop/$my_xlib_u"
26411d54945dSmrg
2642786a6f21Smrg      func_mkdir_p "$my_xdir"
26431d54945dSmrg
2644786a6f21Smrg      case $host in
2645786a6f21Smrg      *-darwin*)
2646786a6f21Smrg	func_verbose "Extracting $my_xabs"
2647786a6f21Smrg	# Do not bother doing anything if just a dry run
2648786a6f21Smrg	$opt_dry_run || {
2649786a6f21Smrg	  darwin_orig_dir=`pwd`
2650786a6f21Smrg	  cd $my_xdir || exit $?
2651786a6f21Smrg	  darwin_archive=$my_xabs
2652786a6f21Smrg	  darwin_curdir=`pwd`
2653786a6f21Smrg	  darwin_base_archive=`basename "$darwin_archive"`
2654786a6f21Smrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
2655786a6f21Smrg	  if test -n "$darwin_arches"; then
2656786a6f21Smrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
2657786a6f21Smrg	    darwin_arch=
2658786a6f21Smrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
2659786a6f21Smrg	    for darwin_arch in  $darwin_arches ; do
2660786a6f21Smrg	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
2661786a6f21Smrg	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
2662786a6f21Smrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
2663786a6f21Smrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
2664786a6f21Smrg	      cd "$darwin_curdir"
2665786a6f21Smrg	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
2666786a6f21Smrg	    done # $darwin_arches
2667786a6f21Smrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
2668786a6f21Smrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
2669786a6f21Smrg	    darwin_file=
2670786a6f21Smrg	    darwin_files=
2671786a6f21Smrg	    for darwin_file in $darwin_filelist; do
2672786a6f21Smrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
2673786a6f21Smrg	      $LIPO -create -output "$darwin_file" $darwin_files
2674786a6f21Smrg	    done # $darwin_filelist
2675786a6f21Smrg	    $RM -rf unfat-$$
2676786a6f21Smrg	    cd "$darwin_orig_dir"
2677786a6f21Smrg	  else
2678786a6f21Smrg	    cd $darwin_orig_dir
2679786a6f21Smrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
2680786a6f21Smrg	  fi # $darwin_arches
2681786a6f21Smrg	} # !$opt_dry_run
26821d54945dSmrg	;;
26831d54945dSmrg      *)
2684786a6f21Smrg        func_extract_an_archive "$my_xdir" "$my_xabs"
26851d54945dSmrg	;;
26861d54945dSmrg      esac
2687786a6f21Smrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
2688786a6f21Smrg    done
26891d54945dSmrg
2690786a6f21Smrg    func_extract_archives_result="$my_oldobjs"
2691786a6f21Smrg}
26921d54945dSmrg
26931d54945dSmrg
26941d54945dSmrg
2695786a6f21Smrg# func_emit_wrapper_part1 [arg=no]
2696786a6f21Smrg#
2697786a6f21Smrg# Emit the first part of a libtool wrapper script on stdout.
2698786a6f21Smrg# For more information, see the description associated with
2699786a6f21Smrg# func_emit_wrapper(), below.
2700786a6f21Smrgfunc_emit_wrapper_part1 ()
2701786a6f21Smrg{
2702786a6f21Smrg	func_emit_wrapper_part1_arg1=no
2703786a6f21Smrg	if test -n "$1" ; then
2704786a6f21Smrg	  func_emit_wrapper_part1_arg1=$1
27051d54945dSmrg	fi
27061d54945dSmrg
2707786a6f21Smrg	$ECHO "\
2708786a6f21Smrg#! $SHELL
27091d54945dSmrg
2710786a6f21Smrg# $output - temporary wrapper script for $objdir/$outputname
2711786a6f21Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
2712786a6f21Smrg#
2713786a6f21Smrg# The $output program cannot be directly executed until all the libtool
2714786a6f21Smrg# libraries that it depends on are installed.
2715786a6f21Smrg#
2716786a6f21Smrg# This wrapper script should never be moved out of the build directory.
2717786a6f21Smrg# If it is, it will not operate correctly.
27181d54945dSmrg
2719786a6f21Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
2720786a6f21Smrg# metacharacters that are still active within double-quoted strings.
2721786a6f21SmrgXsed='${SED} -e 1s/^X//'
2722786a6f21Smrgsed_quote_subst='$sed_quote_subst'
27231d54945dSmrg
2724786a6f21Smrg# Be Bourne compatible
2725786a6f21Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
2726786a6f21Smrg  emulate sh
2727786a6f21Smrg  NULLCMD=:
2728786a6f21Smrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
2729786a6f21Smrg  # is contrary to our usage.  Disable this feature.
2730786a6f21Smrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
2731786a6f21Smrg  setopt NO_GLOB_SUBST
2732786a6f21Smrgelse
2733786a6f21Smrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
2734786a6f21Smrgfi
2735786a6f21SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
2736786a6f21SmrgDUALCASE=1; export DUALCASE # for MKS sh
27371d54945dSmrg
2738786a6f21Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout
2739786a6f21Smrg# if CDPATH is set.
2740786a6f21Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
27411d54945dSmrg
2742786a6f21Smrgrelink_command=\"$relink_command\"
27431d54945dSmrg
2744786a6f21Smrg# This environment variable determines our operation mode.
2745786a6f21Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then
2746786a6f21Smrg  # install mode needs the following variables:
2747786a6f21Smrg  generated_by_libtool_version='$macro_version'
2748786a6f21Smrg  notinst_deplibs='$notinst_deplibs'
2749786a6f21Smrgelse
2750786a6f21Smrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
2751786a6f21Smrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
2752786a6f21Smrg    ECHO=\"$qecho\"
2753786a6f21Smrg    file=\"\$0\"
2754786a6f21Smrg    # Make sure echo works.
2755786a6f21Smrg    if test \"X\$1\" = X--no-reexec; then
2756786a6f21Smrg      # Discard the --no-reexec flag, and continue.
2757786a6f21Smrg      shift
2758786a6f21Smrg    elif test \"X\`{ \$ECHO '\t'; } 2>/dev/null\`\" = 'X\t'; then
2759786a6f21Smrg      # Yippee, \$ECHO works!
2760786a6f21Smrg      :
2761786a6f21Smrg    else
2762786a6f21Smrg      # Restart under the correct shell, and then maybe \$ECHO will work.
2763786a6f21Smrg      exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
2764786a6f21Smrg    fi
2765786a6f21Smrg  fi\
2766786a6f21Smrg"
2767786a6f21Smrg	$ECHO "\
27681d54945dSmrg
2769786a6f21Smrg  # Find the directory that this script lives in.
2770786a6f21Smrg  thisdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
2771786a6f21Smrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
27721d54945dSmrg
2773786a6f21Smrg  # Follow symbolic links until we get to the real thisdir.
2774786a6f21Smrg  file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
2775786a6f21Smrg  while test -n \"\$file\"; do
2776786a6f21Smrg    destdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
27771d54945dSmrg
2778786a6f21Smrg    # If there was a directory component, then change thisdir.
2779786a6f21Smrg    if test \"x\$destdir\" != \"x\$file\"; then
2780786a6f21Smrg      case \"\$destdir\" in
2781786a6f21Smrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
2782786a6f21Smrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
2783786a6f21Smrg      esac
2784786a6f21Smrg    fi
27851d54945dSmrg
2786786a6f21Smrg    file=\`\$ECHO \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
2787786a6f21Smrg    file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
2788786a6f21Smrg  done
2789786a6f21Smrg"
2790786a6f21Smrg}
2791786a6f21Smrg# end: func_emit_wrapper_part1
27921d54945dSmrg
2793786a6f21Smrg# func_emit_wrapper_part2 [arg=no]
2794786a6f21Smrg#
2795786a6f21Smrg# Emit the second part of a libtool wrapper script on stdout.
2796786a6f21Smrg# For more information, see the description associated with
2797786a6f21Smrg# func_emit_wrapper(), below.
2798786a6f21Smrgfunc_emit_wrapper_part2 ()
2799786a6f21Smrg{
2800786a6f21Smrg	func_emit_wrapper_part2_arg1=no
2801786a6f21Smrg	if test -n "$1" ; then
2802786a6f21Smrg	  func_emit_wrapper_part2_arg1=$1
2803786a6f21Smrg	fi
28041d54945dSmrg
2805786a6f21Smrg	$ECHO "\
28061d54945dSmrg
2807786a6f21Smrg  # Usually 'no', except on cygwin/mingw when embedded into
2808786a6f21Smrg  # the cwrapper.
2809786a6f21Smrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_part2_arg1
2810786a6f21Smrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
2811786a6f21Smrg    # special case for '.'
2812786a6f21Smrg    if test \"\$thisdir\" = \".\"; then
2813786a6f21Smrg      thisdir=\`pwd\`
2814786a6f21Smrg    fi
2815786a6f21Smrg    # remove .libs from thisdir
2816786a6f21Smrg    case \"\$thisdir\" in
2817786a6f21Smrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"X\$thisdir\" | \$Xsed -e 's%[\\\\/][^\\\\/]*$%%'\` ;;
2818786a6f21Smrg    $objdir )   thisdir=. ;;
2819786a6f21Smrg    esac
2820786a6f21Smrg  fi
28211d54945dSmrg
2822786a6f21Smrg  # Try to get the absolute directory name.
2823786a6f21Smrg  absdir=\`cd \"\$thisdir\" && pwd\`
2824786a6f21Smrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
2825786a6f21Smrg"
28261d54945dSmrg
2827786a6f21Smrg	if test "$fast_install" = yes; then
2828786a6f21Smrg	  $ECHO "\
2829786a6f21Smrg  program=lt-'$outputname'$exeext
2830786a6f21Smrg  progdir=\"\$thisdir/$objdir\"
28311d54945dSmrg
2832786a6f21Smrg  if test ! -f \"\$progdir/\$program\" ||
2833786a6f21Smrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
2834786a6f21Smrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
28351d54945dSmrg
2836786a6f21Smrg    file=\"\$\$-\$program\"
28371d54945dSmrg
2838786a6f21Smrg    if test ! -d \"\$progdir\"; then
2839786a6f21Smrg      $MKDIR \"\$progdir\"
2840786a6f21Smrg    else
2841786a6f21Smrg      $RM \"\$progdir/\$file\"
2842786a6f21Smrg    fi"
28431d54945dSmrg
2844786a6f21Smrg	  $ECHO "\
28451d54945dSmrg
2846786a6f21Smrg    # relink executable if necessary
2847786a6f21Smrg    if test -n \"\$relink_command\"; then
2848786a6f21Smrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
2849786a6f21Smrg      else
2850786a6f21Smrg	$ECHO \"\$relink_command_output\" >&2
2851786a6f21Smrg	$RM \"\$progdir/\$file\"
2852786a6f21Smrg	exit 1
2853786a6f21Smrg      fi
2854786a6f21Smrg    fi
28551d54945dSmrg
2856786a6f21Smrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
2857786a6f21Smrg    { $RM \"\$progdir/\$program\";
2858786a6f21Smrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
2859786a6f21Smrg    $RM \"\$progdir/\$file\"
2860786a6f21Smrg  fi"
2861786a6f21Smrg	else
2862786a6f21Smrg	  $ECHO "\
2863786a6f21Smrg  program='$outputname'
2864786a6f21Smrg  progdir=\"\$thisdir/$objdir\"
2865786a6f21Smrg"
2866786a6f21Smrg	fi
28671d54945dSmrg
2868786a6f21Smrg	$ECHO "\
28691d54945dSmrg
2870786a6f21Smrg  if test -f \"\$progdir/\$program\"; then"
2871786a6f21Smrg
2872786a6f21Smrg	# Export our shlibpath_var if we have one.
2873786a6f21Smrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
2874786a6f21Smrg	  $ECHO "\
2875786a6f21Smrg    # Add our own library path to $shlibpath_var
2876786a6f21Smrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
2877786a6f21Smrg
2878786a6f21Smrg    # Some systems cannot cope with colon-terminated $shlibpath_var
2879786a6f21Smrg    # The second colon is a workaround for a bug in BeOS R4 sed
2880786a6f21Smrg    $shlibpath_var=\`\$ECHO \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
2881786a6f21Smrg
2882786a6f21Smrg    export $shlibpath_var
2883786a6f21Smrg"
2884786a6f21Smrg	fi
2885786a6f21Smrg
2886786a6f21Smrg	# fixup the dll searchpath if we need to.
2887786a6f21Smrg	if test -n "$dllsearchpath"; then
2888786a6f21Smrg	  $ECHO "\
2889786a6f21Smrg    # Add the dll search path components to the executable PATH
2890786a6f21Smrg    PATH=$dllsearchpath:\$PATH
2891786a6f21Smrg"
2892786a6f21Smrg	fi
2893786a6f21Smrg
2894786a6f21Smrg	$ECHO "\
2895786a6f21Smrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
2896786a6f21Smrg      # Run the actual program with our arguments.
2897786a6f21Smrg"
2898786a6f21Smrg	case $host in
2899786a6f21Smrg	# Backslashes separate directories on plain windows
2900786a6f21Smrg	*-*-mingw | *-*-os2* | *-cegcc*)
2901786a6f21Smrg	  $ECHO "\
2902786a6f21Smrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
2903786a6f21Smrg"
29041d54945dSmrg	  ;;
29051d54945dSmrg
29061d54945dSmrg	*)
2907786a6f21Smrg	  $ECHO "\
2908786a6f21Smrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
2909786a6f21Smrg"
29101d54945dSmrg	  ;;
29111d54945dSmrg	esac
2912786a6f21Smrg	$ECHO "\
2913786a6f21Smrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
2914786a6f21Smrg      exit 1
2915786a6f21Smrg    fi
2916786a6f21Smrg  else
2917786a6f21Smrg    # The program doesn't exist.
2918786a6f21Smrg    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
2919786a6f21Smrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
2920786a6f21Smrg    $ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
2921786a6f21Smrg    exit 1
2922786a6f21Smrg  fi
2923786a6f21Smrgfi\
2924786a6f21Smrg"
2925786a6f21Smrg}
2926786a6f21Smrg# end: func_emit_wrapper_part2
29271d54945dSmrg
29281d54945dSmrg
2929786a6f21Smrg# func_emit_wrapper [arg=no]
2930786a6f21Smrg#
2931786a6f21Smrg# Emit a libtool wrapper script on stdout.
2932786a6f21Smrg# Don't directly open a file because we may want to
2933786a6f21Smrg# incorporate the script contents within a cygwin/mingw
2934786a6f21Smrg# wrapper executable.  Must ONLY be called from within
2935786a6f21Smrg# func_mode_link because it depends on a number of variables
2936786a6f21Smrg# set therein.
2937786a6f21Smrg#
2938786a6f21Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
2939786a6f21Smrg# variable will take.  If 'yes', then the emitted script
2940786a6f21Smrg# will assume that the directory in which it is stored is
2941786a6f21Smrg# the $objdir directory.  This is a cygwin/mingw-specific
2942786a6f21Smrg# behavior.
2943786a6f21Smrgfunc_emit_wrapper ()
2944786a6f21Smrg{
2945786a6f21Smrg	func_emit_wrapper_arg1=no
2946786a6f21Smrg	if test -n "$1" ; then
2947786a6f21Smrg	  func_emit_wrapper_arg1=$1
29481d54945dSmrg	fi
29491d54945dSmrg
2950786a6f21Smrg	# split this up so that func_emit_cwrapperexe_src
2951786a6f21Smrg	# can call each part independently.
2952786a6f21Smrg	func_emit_wrapper_part1 "${func_emit_wrapper_arg1}"
2953786a6f21Smrg	func_emit_wrapper_part2 "${func_emit_wrapper_arg1}"
2954786a6f21Smrg}
29551d54945dSmrg
29561d54945dSmrg
2957786a6f21Smrg# func_to_host_path arg
2958786a6f21Smrg#
2959786a6f21Smrg# Convert paths to host format when used with build tools.
2960786a6f21Smrg# Intended for use with "native" mingw (where libtool itself
2961786a6f21Smrg# is running under the msys shell), or in the following cross-
2962786a6f21Smrg# build environments:
2963786a6f21Smrg#    $build          $host
2964786a6f21Smrg#    mingw (msys)    mingw  [e.g. native]
2965786a6f21Smrg#    cygwin          mingw
2966786a6f21Smrg#    *nix + wine     mingw
2967786a6f21Smrg# where wine is equipped with the `winepath' executable.
2968786a6f21Smrg# In the native mingw case, the (msys) shell automatically
2969786a6f21Smrg# converts paths for any non-msys applications it launches,
2970786a6f21Smrg# but that facility isn't available from inside the cwrapper.
2971786a6f21Smrg# Similar accommodations are necessary for $host mingw and
2972786a6f21Smrg# $build cygwin.  Calling this function does no harm for other
2973786a6f21Smrg# $host/$build combinations not listed above.
2974786a6f21Smrg#
2975786a6f21Smrg# ARG is the path (on $build) that should be converted to
2976786a6f21Smrg# the proper representation for $host. The result is stored
2977786a6f21Smrg# in $func_to_host_path_result.
2978786a6f21Smrgfunc_to_host_path ()
2979786a6f21Smrg{
2980786a6f21Smrg  func_to_host_path_result="$1"
2981786a6f21Smrg  if test -n "$1" ; then
2982786a6f21Smrg    case $host in
2983786a6f21Smrg      *mingw* )
2984786a6f21Smrg        lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
2985786a6f21Smrg        case $build in
2986786a6f21Smrg          *mingw* ) # actually, msys
2987786a6f21Smrg            # awkward: cmd appends spaces to result
2988786a6f21Smrg            lt_sed_strip_trailing_spaces="s/[ ]*\$//"
2989786a6f21Smrg            func_to_host_path_tmp1=`( cmd //c echo "$1" |\
2990786a6f21Smrg              $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""`
2991786a6f21Smrg            func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
2992786a6f21Smrg              $SED -e "$lt_sed_naive_backslashify"`
2993786a6f21Smrg            ;;
2994786a6f21Smrg          *cygwin* )
2995786a6f21Smrg            func_to_host_path_tmp1=`cygpath -w "$1"`
2996786a6f21Smrg            func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
2997786a6f21Smrg              $SED -e "$lt_sed_naive_backslashify"`
2998786a6f21Smrg            ;;
2999786a6f21Smrg          * )
3000786a6f21Smrg            # Unfortunately, winepath does not exit with a non-zero
3001786a6f21Smrg            # error code, so we are forced to check the contents of
3002786a6f21Smrg            # stdout. On the other hand, if the command is not
3003786a6f21Smrg            # found, the shell will set an exit code of 127 and print
3004786a6f21Smrg            # *an error message* to stdout. So we must check for both
3005786a6f21Smrg            # error code of zero AND non-empty stdout, which explains
3006786a6f21Smrg            # the odd construction:
3007786a6f21Smrg            func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null`
3008786a6f21Smrg            if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then
3009786a6f21Smrg              func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
3010786a6f21Smrg                $SED -e "$lt_sed_naive_backslashify"`
3011786a6f21Smrg            else
3012786a6f21Smrg              # Allow warning below.
3013786a6f21Smrg              func_to_host_path_result=""
3014786a6f21Smrg            fi
3015786a6f21Smrg            ;;
3016786a6f21Smrg        esac
3017786a6f21Smrg        if test -z "$func_to_host_path_result" ; then
3018786a6f21Smrg          func_error "Could not determine host path corresponding to"
3019786a6f21Smrg          func_error "  '$1'"
3020786a6f21Smrg          func_error "Continuing, but uninstalled executables may not work."
3021786a6f21Smrg          # Fallback:
3022786a6f21Smrg          func_to_host_path_result="$1"
3023786a6f21Smrg        fi
3024786a6f21Smrg        ;;
3025786a6f21Smrg    esac
3026786a6f21Smrg  fi
3027786a6f21Smrg}
3028786a6f21Smrg# end: func_to_host_path
30291d54945dSmrg
3030786a6f21Smrg# func_to_host_pathlist arg
3031786a6f21Smrg#
3032786a6f21Smrg# Convert pathlists to host format when used with build tools.
3033786a6f21Smrg# See func_to_host_path(), above. This function supports the
3034786a6f21Smrg# following $build/$host combinations (but does no harm for
3035786a6f21Smrg# combinations not listed here):
3036786a6f21Smrg#    $build          $host
3037786a6f21Smrg#    mingw (msys)    mingw  [e.g. native]
3038786a6f21Smrg#    cygwin          mingw
3039786a6f21Smrg#    *nix + wine     mingw
3040786a6f21Smrg#
3041786a6f21Smrg# Path separators are also converted from $build format to
3042786a6f21Smrg# $host format. If ARG begins or ends with a path separator
3043786a6f21Smrg# character, it is preserved (but converted to $host format)
3044786a6f21Smrg# on output.
3045786a6f21Smrg#
3046786a6f21Smrg# ARG is a pathlist (on $build) that should be converted to
3047786a6f21Smrg# the proper representation on $host. The result is stored
3048786a6f21Smrg# in $func_to_host_pathlist_result.
3049786a6f21Smrgfunc_to_host_pathlist ()
3050786a6f21Smrg{
3051786a6f21Smrg  func_to_host_pathlist_result="$1"
3052786a6f21Smrg  if test -n "$1" ; then
3053786a6f21Smrg    case $host in
3054786a6f21Smrg      *mingw* )
3055786a6f21Smrg        lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
3056786a6f21Smrg        # Remove leading and trailing path separator characters from
3057786a6f21Smrg        # ARG. msys behavior is inconsistent here, cygpath turns them
3058786a6f21Smrg        # into '.;' and ';.', and winepath ignores them completely.
3059786a6f21Smrg        func_to_host_pathlist_tmp2="$1"
3060786a6f21Smrg        # Once set for this call, this variable should not be
3061786a6f21Smrg        # reassigned. It is used in tha fallback case.
3062786a6f21Smrg        func_to_host_pathlist_tmp1=`echo "$func_to_host_pathlist_tmp2" |\
3063786a6f21Smrg          $SED -e 's|^:*||' -e 's|:*$||'`
3064786a6f21Smrg        case $build in
3065786a6f21Smrg          *mingw* ) # Actually, msys.
3066786a6f21Smrg            # Awkward: cmd appends spaces to result.
3067786a6f21Smrg            lt_sed_strip_trailing_spaces="s/[ ]*\$//"
3068786a6f21Smrg            func_to_host_pathlist_tmp2=`( cmd //c echo "$func_to_host_pathlist_tmp1" |\
3069786a6f21Smrg              $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""`
3070786a6f21Smrg            func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
3071786a6f21Smrg              $SED -e "$lt_sed_naive_backslashify"`
3072786a6f21Smrg            ;;
3073786a6f21Smrg          *cygwin* )
3074786a6f21Smrg            func_to_host_pathlist_tmp2=`cygpath -w -p "$func_to_host_pathlist_tmp1"`
3075786a6f21Smrg            func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
3076786a6f21Smrg              $SED -e "$lt_sed_naive_backslashify"`
3077786a6f21Smrg            ;;
3078786a6f21Smrg          * )
3079786a6f21Smrg            # unfortunately, winepath doesn't convert pathlists
3080786a6f21Smrg            func_to_host_pathlist_result=""
3081786a6f21Smrg            func_to_host_pathlist_oldIFS=$IFS
3082786a6f21Smrg            IFS=:
3083786a6f21Smrg            for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do
3084786a6f21Smrg              IFS=$func_to_host_pathlist_oldIFS
3085786a6f21Smrg              if test -n "$func_to_host_pathlist_f" ; then
3086786a6f21Smrg                func_to_host_path "$func_to_host_pathlist_f"
3087786a6f21Smrg                if test -n "$func_to_host_path_result" ; then
3088786a6f21Smrg                  if test -z "$func_to_host_pathlist_result" ; then
3089786a6f21Smrg                    func_to_host_pathlist_result="$func_to_host_path_result"
3090786a6f21Smrg                  else
3091786a6f21Smrg                    func_to_host_pathlist_result="$func_to_host_pathlist_result;$func_to_host_path_result"
3092786a6f21Smrg                  fi
3093786a6f21Smrg                fi
3094786a6f21Smrg              fi
3095786a6f21Smrg              IFS=:
3096786a6f21Smrg            done
3097786a6f21Smrg            IFS=$func_to_host_pathlist_oldIFS
3098786a6f21Smrg            ;;
3099786a6f21Smrg        esac
3100786a6f21Smrg        if test -z "$func_to_host_pathlist_result" ; then
3101786a6f21Smrg          func_error "Could not determine the host path(s) corresponding to"
3102786a6f21Smrg          func_error "  '$1'"
3103786a6f21Smrg          func_error "Continuing, but uninstalled executables may not work."
3104786a6f21Smrg          # Fallback. This may break if $1 contains DOS-style drive
3105786a6f21Smrg          # specifications. The fix is not to complicate the expression
3106786a6f21Smrg          # below, but for the user to provide a working wine installation
3107786a6f21Smrg          # with winepath so that path translation in the cross-to-mingw
3108786a6f21Smrg          # case works properly.
3109786a6f21Smrg          lt_replace_pathsep_nix_to_dos="s|:|;|g"
3110786a6f21Smrg          func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\
3111786a6f21Smrg            $SED -e "$lt_replace_pathsep_nix_to_dos"`
3112786a6f21Smrg        fi
3113786a6f21Smrg        # Now, add the leading and trailing path separators back
3114786a6f21Smrg        case "$1" in
3115786a6f21Smrg          :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result"
3116786a6f21Smrg            ;;
3117786a6f21Smrg        esac
3118786a6f21Smrg        case "$1" in
3119786a6f21Smrg          *: ) func_to_host_pathlist_result="$func_to_host_pathlist_result;"
3120786a6f21Smrg            ;;
3121786a6f21Smrg        esac
3122786a6f21Smrg        ;;
3123786a6f21Smrg    esac
3124786a6f21Smrg  fi
3125786a6f21Smrg}
3126786a6f21Smrg# end: func_to_host_pathlist
31271d54945dSmrg
3128786a6f21Smrg# func_emit_cwrapperexe_src
3129786a6f21Smrg# emit the source code for a wrapper executable on stdout
3130786a6f21Smrg# Must ONLY be called from within func_mode_link because
3131786a6f21Smrg# it depends on a number of variable set therein.
3132786a6f21Smrgfunc_emit_cwrapperexe_src ()
3133786a6f21Smrg{
3134786a6f21Smrg	cat <<EOF
31351d54945dSmrg
3136786a6f21Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
3137786a6f21Smrg   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
31381d54945dSmrg
3139786a6f21Smrg   The $output program cannot be directly executed until all the libtool
3140786a6f21Smrg   libraries that it depends on are installed.
31411d54945dSmrg
3142786a6f21Smrg   This wrapper executable should never be moved out of the build directory.
3143786a6f21Smrg   If it is, it will not operate correctly.
31441d54945dSmrg
3145786a6f21Smrg   Currently, it simply execs the wrapper *script* "$SHELL $output",
3146786a6f21Smrg   but could eventually absorb all of the scripts functionality and
3147786a6f21Smrg   exec $objdir/$outputname directly.
3148786a6f21Smrg*/
3149786a6f21SmrgEOF
3150786a6f21Smrg	    cat <<"EOF"
3151786a6f21Smrg#include <stdio.h>
3152786a6f21Smrg#include <stdlib.h>
3153786a6f21Smrg#ifdef _MSC_VER
3154786a6f21Smrg# include <direct.h>
3155786a6f21Smrg# include <process.h>
3156786a6f21Smrg# include <io.h>
3157786a6f21Smrg# define setmode _setmode
3158786a6f21Smrg#else
3159786a6f21Smrg# include <unistd.h>
3160786a6f21Smrg# include <stdint.h>
3161786a6f21Smrg# ifdef __CYGWIN__
3162786a6f21Smrg#  include <io.h>
3163786a6f21Smrg#  define HAVE_SETENV
3164786a6f21Smrg#  ifdef __STRICT_ANSI__
3165786a6f21Smrgchar *realpath (const char *, char *);
3166786a6f21Smrgint putenv (char *);
3167786a6f21Smrgint setenv (const char *, const char *, int);
3168786a6f21Smrg#  endif
3169786a6f21Smrg# endif
3170786a6f21Smrg#endif
3171786a6f21Smrg#include <malloc.h>
3172786a6f21Smrg#include <stdarg.h>
3173786a6f21Smrg#include <assert.h>
3174786a6f21Smrg#include <string.h>
3175786a6f21Smrg#include <ctype.h>
3176786a6f21Smrg#include <errno.h>
3177786a6f21Smrg#include <fcntl.h>
3178786a6f21Smrg#include <sys/stat.h>
3179786a6f21Smrg
3180786a6f21Smrg#if defined(PATH_MAX)
3181786a6f21Smrg# define LT_PATHMAX PATH_MAX
3182786a6f21Smrg#elif defined(MAXPATHLEN)
3183786a6f21Smrg# define LT_PATHMAX MAXPATHLEN
3184786a6f21Smrg#else
3185786a6f21Smrg# define LT_PATHMAX 1024
3186786a6f21Smrg#endif
3187786a6f21Smrg
3188786a6f21Smrg#ifndef S_IXOTH
3189786a6f21Smrg# define S_IXOTH 0
3190786a6f21Smrg#endif
3191786a6f21Smrg#ifndef S_IXGRP
3192786a6f21Smrg# define S_IXGRP 0
3193786a6f21Smrg#endif
3194786a6f21Smrg
3195786a6f21Smrg#ifdef _MSC_VER
3196786a6f21Smrg# define S_IXUSR _S_IEXEC
3197786a6f21Smrg# define stat _stat
3198786a6f21Smrg# ifndef _INTPTR_T_DEFINED
3199786a6f21Smrg#  define intptr_t int
3200786a6f21Smrg# endif
3201786a6f21Smrg#endif
3202786a6f21Smrg
3203786a6f21Smrg#ifndef DIR_SEPARATOR
3204786a6f21Smrg# define DIR_SEPARATOR '/'
3205786a6f21Smrg# define PATH_SEPARATOR ':'
3206786a6f21Smrg#endif
3207786a6f21Smrg
3208786a6f21Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
3209786a6f21Smrg  defined (__OS2__)
3210786a6f21Smrg# define HAVE_DOS_BASED_FILE_SYSTEM
3211786a6f21Smrg# define FOPEN_WB "wb"
3212786a6f21Smrg# ifndef DIR_SEPARATOR_2
3213786a6f21Smrg#  define DIR_SEPARATOR_2 '\\'
3214786a6f21Smrg# endif
3215786a6f21Smrg# ifndef PATH_SEPARATOR_2
3216786a6f21Smrg#  define PATH_SEPARATOR_2 ';'
3217786a6f21Smrg# endif
3218786a6f21Smrg#endif
3219786a6f21Smrg
3220786a6f21Smrg#ifndef DIR_SEPARATOR_2
3221786a6f21Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
3222786a6f21Smrg#else /* DIR_SEPARATOR_2 */
3223786a6f21Smrg# define IS_DIR_SEPARATOR(ch) \
3224786a6f21Smrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
3225786a6f21Smrg#endif /* DIR_SEPARATOR_2 */
3226786a6f21Smrg
3227786a6f21Smrg#ifndef PATH_SEPARATOR_2
3228786a6f21Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
3229786a6f21Smrg#else /* PATH_SEPARATOR_2 */
3230786a6f21Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
3231786a6f21Smrg#endif /* PATH_SEPARATOR_2 */
3232786a6f21Smrg
3233786a6f21Smrg#ifdef __CYGWIN__
3234786a6f21Smrg# define FOPEN_WB "wb"
3235786a6f21Smrg#endif
3236786a6f21Smrg
3237786a6f21Smrg#ifndef FOPEN_WB
3238786a6f21Smrg# define FOPEN_WB "w"
3239786a6f21Smrg#endif
3240786a6f21Smrg#ifndef _O_BINARY
3241786a6f21Smrg# define _O_BINARY 0
3242786a6f21Smrg#endif
3243786a6f21Smrg
3244786a6f21Smrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
3245786a6f21Smrg#define XFREE(stale) do { \
3246786a6f21Smrg  if (stale) { free ((void *) stale); stale = 0; } \
3247786a6f21Smrg} while (0)
3248786a6f21Smrg
3249786a6f21Smrg#undef LTWRAPPER_DEBUGPRINTF
3250786a6f21Smrg#if defined DEBUGWRAPPER
3251786a6f21Smrg# define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args
3252786a6f21Smrgstatic void
3253786a6f21Smrgltwrapper_debugprintf (const char *fmt, ...)
3254786a6f21Smrg{
3255786a6f21Smrg    va_list args;
3256786a6f21Smrg    va_start (args, fmt);
3257786a6f21Smrg    (void) vfprintf (stderr, fmt, args);
3258786a6f21Smrg    va_end (args);
3259786a6f21Smrg}
3260786a6f21Smrg#else
3261786a6f21Smrg# define LTWRAPPER_DEBUGPRINTF(args)
3262786a6f21Smrg#endif
3263786a6f21Smrg
3264786a6f21Smrgconst char *program_name = NULL;
3265786a6f21Smrg
3266786a6f21Smrgvoid *xmalloc (size_t num);
3267786a6f21Smrgchar *xstrdup (const char *string);
3268786a6f21Smrgconst char *base_name (const char *name);
3269786a6f21Smrgchar *find_executable (const char *wrapper);
3270786a6f21Smrgchar *chase_symlinks (const char *pathspec);
3271786a6f21Smrgint make_executable (const char *path);
3272786a6f21Smrgint check_executable (const char *path);
3273786a6f21Smrgchar *strendzap (char *str, const char *pat);
3274786a6f21Smrgvoid lt_fatal (const char *message, ...);
3275786a6f21Smrgvoid lt_setenv (const char *name, const char *value);
3276786a6f21Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
3277786a6f21Smrgvoid lt_opt_process_env_set (const char *arg);
3278786a6f21Smrgvoid lt_opt_process_env_prepend (const char *arg);
3279786a6f21Smrgvoid lt_opt_process_env_append (const char *arg);
3280786a6f21Smrgint lt_split_name_value (const char *arg, char** name, char** value);
3281786a6f21Smrgvoid lt_update_exe_path (const char *name, const char *value);
3282786a6f21Smrgvoid lt_update_lib_path (const char *name, const char *value);
3283786a6f21Smrg
3284786a6f21Smrgstatic const char *script_text_part1 =
3285786a6f21SmrgEOF
3286786a6f21Smrg
3287786a6f21Smrg	    func_emit_wrapper_part1 yes |
3288786a6f21Smrg	        $SED -e 's/\([\\"]\)/\\\1/g' \
3289786a6f21Smrg	             -e 's/^/  "/' -e 's/$/\\n"/'
3290786a6f21Smrg	    echo ";"
3291786a6f21Smrg	    cat <<EOF
3292786a6f21Smrg
3293786a6f21Smrgstatic const char *script_text_part2 =
3294786a6f21SmrgEOF
3295786a6f21Smrg	    func_emit_wrapper_part2 yes |
3296786a6f21Smrg	        $SED -e 's/\([\\"]\)/\\\1/g' \
3297786a6f21Smrg	             -e 's/^/  "/' -e 's/$/\\n"/'
3298786a6f21Smrg	    echo ";"
3299786a6f21Smrg
3300786a6f21Smrg	    cat <<EOF
3301786a6f21Smrgconst char * MAGIC_EXE = "$magic_exe";
3302786a6f21Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
3303786a6f21SmrgEOF
3304786a6f21Smrg
3305786a6f21Smrg	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
3306786a6f21Smrg              func_to_host_pathlist "$temp_rpath"
3307786a6f21Smrg	      cat <<EOF
3308786a6f21Smrgconst char * LIB_PATH_VALUE   = "$func_to_host_pathlist_result";
33091d54945dSmrgEOF
33101d54945dSmrg	    else
3311786a6f21Smrg	      cat <<"EOF"
3312786a6f21Smrgconst char * LIB_PATH_VALUE   = "";
3313786a6f21SmrgEOF
33141d54945dSmrg	    fi
3315786a6f21Smrg
3316786a6f21Smrg	    if test -n "$dllsearchpath"; then
3317786a6f21Smrg              func_to_host_pathlist "$dllsearchpath:"
3318786a6f21Smrg	      cat <<EOF
3319786a6f21Smrgconst char * EXE_PATH_VARNAME = "PATH";
3320786a6f21Smrgconst char * EXE_PATH_VALUE   = "$func_to_host_pathlist_result";
3321786a6f21SmrgEOF
33221d54945dSmrg	    else
3323786a6f21Smrg	      cat <<"EOF"
3324786a6f21Smrgconst char * EXE_PATH_VARNAME = "";
3325786a6f21Smrgconst char * EXE_PATH_VALUE   = "";
3326786a6f21SmrgEOF
33271d54945dSmrg	    fi
3328786a6f21Smrg
3329786a6f21Smrg	    if test "$fast_install" = yes; then
3330786a6f21Smrg	      cat <<EOF
3331786a6f21Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
3332786a6f21SmrgEOF
33331d54945dSmrg	    else
3334786a6f21Smrg	      cat <<EOF
3335786a6f21Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
3336786a6f21SmrgEOF
33371d54945dSmrg	    fi
33381d54945dSmrg
33391d54945dSmrg
3340786a6f21Smrg	    cat <<"EOF"
33411d54945dSmrg
3342786a6f21Smrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
3343786a6f21Smrg#define LTWRAPPER_OPTION_PREFIX_LENGTH  5
33441d54945dSmrg
3345786a6f21Smrgstatic const size_t opt_prefix_len         = LTWRAPPER_OPTION_PREFIX_LENGTH;
3346786a6f21Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
33471d54945dSmrg
3348786a6f21Smrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
33491d54945dSmrg
3350786a6f21Smrgstatic const size_t env_set_opt_len     = LTWRAPPER_OPTION_PREFIX_LENGTH + 7;
3351786a6f21Smrgstatic const char *env_set_opt          = LTWRAPPER_OPTION_PREFIX "env-set";
3352786a6f21Smrg  /* argument is putenv-style "foo=bar", value of foo is set to bar */
33531d54945dSmrg
3354786a6f21Smrgstatic const size_t env_prepend_opt_len = LTWRAPPER_OPTION_PREFIX_LENGTH + 11;
3355786a6f21Smrgstatic const char *env_prepend_opt      = LTWRAPPER_OPTION_PREFIX "env-prepend";
3356786a6f21Smrg  /* argument is putenv-style "foo=bar", new value of foo is bar${foo} */
33571d54945dSmrg
3358786a6f21Smrgstatic const size_t env_append_opt_len  = LTWRAPPER_OPTION_PREFIX_LENGTH + 10;
3359786a6f21Smrgstatic const char *env_append_opt       = LTWRAPPER_OPTION_PREFIX "env-append";
3360786a6f21Smrg  /* argument is putenv-style "foo=bar", new value of foo is ${foo}bar */
33611d54945dSmrg
3362786a6f21Smrgint
3363786a6f21Smrgmain (int argc, char *argv[])
3364786a6f21Smrg{
3365786a6f21Smrg  char **newargz;
3366786a6f21Smrg  int  newargc;
3367786a6f21Smrg  char *tmp_pathspec;
3368786a6f21Smrg  char *actual_cwrapper_path;
3369786a6f21Smrg  char *actual_cwrapper_name;
3370786a6f21Smrg  char *target_name;
3371786a6f21Smrg  char *lt_argv_zero;
3372786a6f21Smrg  intptr_t rval = 127;
33731d54945dSmrg
3374786a6f21Smrg  int i;
33751d54945dSmrg
3376786a6f21Smrg  program_name = (char *) xstrdup (base_name (argv[0]));
3377786a6f21Smrg  LTWRAPPER_DEBUGPRINTF (("(main) argv[0]      : %s\n", argv[0]));
3378786a6f21Smrg  LTWRAPPER_DEBUGPRINTF (("(main) program_name : %s\n", program_name));
33791d54945dSmrg
3380786a6f21Smrg  /* very simple arg parsing; don't want to rely on getopt */
3381786a6f21Smrg  for (i = 1; i < argc; i++)
3382786a6f21Smrg    {
3383786a6f21Smrg      if (strcmp (argv[i], dumpscript_opt) == 0)
3384786a6f21Smrg	{
3385786a6f21SmrgEOF
3386786a6f21Smrg	    case "$host" in
3387786a6f21Smrg	      *mingw* | *cygwin* )
3388786a6f21Smrg		# make stdout use "unix" line endings
3389786a6f21Smrg		echo "          setmode(1,_O_BINARY);"
3390786a6f21Smrg		;;
3391786a6f21Smrg	      esac
33921d54945dSmrg
3393786a6f21Smrg	    cat <<"EOF"
3394786a6f21Smrg	  printf ("%s", script_text_part1);
3395786a6f21Smrg	  printf ("%s", script_text_part2);
3396786a6f21Smrg	  return 0;
3397786a6f21Smrg	}
3398786a6f21Smrg    }
33991d54945dSmrg
3400786a6f21Smrg  newargz = XMALLOC (char *, argc + 1);
3401786a6f21Smrg  tmp_pathspec = find_executable (argv[0]);
3402786a6f21Smrg  if (tmp_pathspec == NULL)
3403786a6f21Smrg    lt_fatal ("Couldn't find %s", argv[0]);
3404786a6f21Smrg  LTWRAPPER_DEBUGPRINTF (("(main) found exe (before symlink chase) at : %s\n",
3405786a6f21Smrg			  tmp_pathspec));
3406786a6f21Smrg
3407786a6f21Smrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
3408786a6f21Smrg  LTWRAPPER_DEBUGPRINTF (("(main) found exe (after symlink chase) at : %s\n",
3409786a6f21Smrg			  actual_cwrapper_path));
3410786a6f21Smrg  XFREE (tmp_pathspec);
3411786a6f21Smrg
3412786a6f21Smrg  actual_cwrapper_name = xstrdup( base_name (actual_cwrapper_path));
3413786a6f21Smrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
3414786a6f21Smrg
3415786a6f21Smrg  /* wrapper name transforms */
3416786a6f21Smrg  strendzap (actual_cwrapper_name, ".exe");
3417786a6f21Smrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
3418786a6f21Smrg  XFREE (actual_cwrapper_name);
3419786a6f21Smrg  actual_cwrapper_name = tmp_pathspec;
3420786a6f21Smrg  tmp_pathspec = 0;
3421786a6f21Smrg
3422786a6f21Smrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
3423786a6f21Smrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
3424786a6f21Smrg  strendzap (target_name, ".exe");
3425786a6f21Smrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
3426786a6f21Smrg  XFREE (target_name);
3427786a6f21Smrg  target_name = tmp_pathspec;
3428786a6f21Smrg  tmp_pathspec = 0;
3429786a6f21Smrg
3430786a6f21Smrg  LTWRAPPER_DEBUGPRINTF (("(main) libtool target name: %s\n",
3431786a6f21Smrg			  target_name));
3432786a6f21SmrgEOF
34331d54945dSmrg
3434786a6f21Smrg	    cat <<EOF
3435786a6f21Smrg  newargz[0] =
3436786a6f21Smrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
3437786a6f21Smrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
3438786a6f21Smrg  strcpy (newargz[0], actual_cwrapper_path);
3439786a6f21Smrg  strcat (newargz[0], "$objdir");
3440786a6f21Smrg  strcat (newargz[0], "/");
3441786a6f21SmrgEOF
34421d54945dSmrg
3443786a6f21Smrg	    cat <<"EOF"
3444786a6f21Smrg  /* stop here, and copy so we don't have to do this twice */
3445786a6f21Smrg  tmp_pathspec = xstrdup (newargz[0]);
34461d54945dSmrg
3447786a6f21Smrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
3448786a6f21Smrg  strcat (newargz[0], actual_cwrapper_name);
34491d54945dSmrg
3450786a6f21Smrg  /* DO want the lt- prefix here if it exists, so use target_name */
3451786a6f21Smrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
3452786a6f21Smrg  XFREE (tmp_pathspec);
3453786a6f21Smrg  tmp_pathspec = NULL;
3454786a6f21SmrgEOF
34551d54945dSmrg
3456786a6f21Smrg	    case $host_os in
3457786a6f21Smrg	      mingw*)
3458786a6f21Smrg	    cat <<"EOF"
3459786a6f21Smrg  {
3460786a6f21Smrg    char* p;
3461786a6f21Smrg    while ((p = strchr (newargz[0], '\\')) != NULL)
3462786a6f21Smrg      {
3463786a6f21Smrg	*p = '/';
3464786a6f21Smrg      }
3465786a6f21Smrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
3466786a6f21Smrg      {
3467786a6f21Smrg	*p = '/';
3468786a6f21Smrg      }
3469786a6f21Smrg  }
3470786a6f21SmrgEOF
3471786a6f21Smrg	    ;;
3472786a6f21Smrg	    esac
34731d54945dSmrg
3474786a6f21Smrg	    cat <<"EOF"
3475786a6f21Smrg  XFREE (target_name);
3476786a6f21Smrg  XFREE (actual_cwrapper_path);
3477786a6f21Smrg  XFREE (actual_cwrapper_name);
34781d54945dSmrg
3479786a6f21Smrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
3480786a6f21Smrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
3481786a6f21Smrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
3482786a6f21Smrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
34831d54945dSmrg
3484786a6f21Smrg  newargc=0;
3485786a6f21Smrg  for (i = 1; i < argc; i++)
3486786a6f21Smrg    {
3487786a6f21Smrg      if (strncmp (argv[i], env_set_opt, env_set_opt_len) == 0)
3488786a6f21Smrg        {
3489786a6f21Smrg          if (argv[i][env_set_opt_len] == '=')
3490786a6f21Smrg            {
3491786a6f21Smrg              const char *p = argv[i] + env_set_opt_len + 1;
3492786a6f21Smrg              lt_opt_process_env_set (p);
3493786a6f21Smrg            }
3494786a6f21Smrg          else if (argv[i][env_set_opt_len] == '\0' && i + 1 < argc)
3495786a6f21Smrg            {
3496786a6f21Smrg              lt_opt_process_env_set (argv[++i]); /* don't copy */
3497786a6f21Smrg            }
3498786a6f21Smrg          else
3499786a6f21Smrg            lt_fatal ("%s missing required argument", env_set_opt);
3500786a6f21Smrg          continue;
3501786a6f21Smrg        }
3502786a6f21Smrg      if (strncmp (argv[i], env_prepend_opt, env_prepend_opt_len) == 0)
3503786a6f21Smrg        {
3504786a6f21Smrg          if (argv[i][env_prepend_opt_len] == '=')
3505786a6f21Smrg            {
3506786a6f21Smrg              const char *p = argv[i] + env_prepend_opt_len + 1;
3507786a6f21Smrg              lt_opt_process_env_prepend (p);
3508786a6f21Smrg            }
3509786a6f21Smrg          else if (argv[i][env_prepend_opt_len] == '\0' && i + 1 < argc)
3510786a6f21Smrg            {
3511786a6f21Smrg              lt_opt_process_env_prepend (argv[++i]); /* don't copy */
3512786a6f21Smrg            }
3513786a6f21Smrg          else
3514786a6f21Smrg            lt_fatal ("%s missing required argument", env_prepend_opt);
3515786a6f21Smrg          continue;
3516786a6f21Smrg        }
3517786a6f21Smrg      if (strncmp (argv[i], env_append_opt, env_append_opt_len) == 0)
3518786a6f21Smrg        {
3519786a6f21Smrg          if (argv[i][env_append_opt_len] == '=')
3520786a6f21Smrg            {
3521786a6f21Smrg              const char *p = argv[i] + env_append_opt_len + 1;
3522786a6f21Smrg              lt_opt_process_env_append (p);
3523786a6f21Smrg            }
3524786a6f21Smrg          else if (argv[i][env_append_opt_len] == '\0' && i + 1 < argc)
3525786a6f21Smrg            {
3526786a6f21Smrg              lt_opt_process_env_append (argv[++i]); /* don't copy */
3527786a6f21Smrg            }
3528786a6f21Smrg          else
3529786a6f21Smrg            lt_fatal ("%s missing required argument", env_append_opt);
3530786a6f21Smrg          continue;
3531786a6f21Smrg        }
3532786a6f21Smrg      if (strncmp (argv[i], ltwrapper_option_prefix, opt_prefix_len) == 0)
3533786a6f21Smrg        {
3534786a6f21Smrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
3535786a6f21Smrg             namespace, but it is not one of the ones we know about and
3536786a6f21Smrg             have already dealt with, above (inluding dump-script), then
3537786a6f21Smrg             report an error. Otherwise, targets might begin to believe
3538786a6f21Smrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
3539786a6f21Smrg             namespace. The first time any user complains about this, we'll
3540786a6f21Smrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
3541786a6f21Smrg             or a configure.ac-settable value.
3542786a6f21Smrg           */
3543786a6f21Smrg          lt_fatal ("Unrecognized option in %s namespace: '%s'",
3544786a6f21Smrg                    ltwrapper_option_prefix, argv[i]);
3545786a6f21Smrg        }
3546786a6f21Smrg      /* otherwise ... */
3547786a6f21Smrg      newargz[++newargc] = xstrdup (argv[i]);
3548786a6f21Smrg    }
3549786a6f21Smrg  newargz[++newargc] = NULL;
35501d54945dSmrg
3551786a6f21Smrg  LTWRAPPER_DEBUGPRINTF     (("(main) lt_argv_zero : %s\n", (lt_argv_zero ? lt_argv_zero : "<NULL>")));
3552786a6f21Smrg  for (i = 0; i < newargc; i++)
3553786a6f21Smrg    {
3554786a6f21Smrg      LTWRAPPER_DEBUGPRINTF (("(main) newargz[%d]   : %s\n", i, (newargz[i] ? newargz[i] : "<NULL>")));
3555786a6f21Smrg    }
35561d54945dSmrg
3557786a6f21SmrgEOF
35581d54945dSmrg
3559786a6f21Smrg	    case $host_os in
3560786a6f21Smrg	      mingw*)
3561786a6f21Smrg		cat <<"EOF"
3562786a6f21Smrg  /* execv doesn't actually work on mingw as expected on unix */
3563786a6f21Smrg  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
3564786a6f21Smrg  if (rval == -1)
3565786a6f21Smrg    {
3566786a6f21Smrg      /* failed to start process */
3567786a6f21Smrg      LTWRAPPER_DEBUGPRINTF (("(main) failed to launch target \"%s\": errno = %d\n", lt_argv_zero, errno));
3568786a6f21Smrg      return 127;
3569786a6f21Smrg    }
3570786a6f21Smrg  return rval;
3571786a6f21SmrgEOF
3572786a6f21Smrg		;;
3573786a6f21Smrg	      *)
3574786a6f21Smrg		cat <<"EOF"
3575786a6f21Smrg  execv (lt_argv_zero, newargz);
3576786a6f21Smrg  return rval; /* =127, but avoids unused variable warning */
3577786a6f21SmrgEOF
3578786a6f21Smrg		;;
3579786a6f21Smrg	    esac
35801d54945dSmrg
3581786a6f21Smrg	    cat <<"EOF"
3582786a6f21Smrg}
35831d54945dSmrg
3584786a6f21Smrgvoid *
3585786a6f21Smrgxmalloc (size_t num)
3586786a6f21Smrg{
3587786a6f21Smrg  void *p = (void *) malloc (num);
3588786a6f21Smrg  if (!p)
3589786a6f21Smrg    lt_fatal ("Memory exhausted");
35901d54945dSmrg
3591786a6f21Smrg  return p;
3592786a6f21Smrg}
35931d54945dSmrg
3594786a6f21Smrgchar *
3595786a6f21Smrgxstrdup (const char *string)
3596786a6f21Smrg{
3597786a6f21Smrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
3598786a6f21Smrg			  string) : NULL;
3599786a6f21Smrg}
36001d54945dSmrg
3601786a6f21Smrgconst char *
3602786a6f21Smrgbase_name (const char *name)
3603786a6f21Smrg{
3604786a6f21Smrg  const char *base;
36051d54945dSmrg
3606786a6f21Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3607786a6f21Smrg  /* Skip over the disk name in MSDOS pathnames. */
3608786a6f21Smrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
3609786a6f21Smrg    name += 2;
3610786a6f21Smrg#endif
36111d54945dSmrg
3612786a6f21Smrg  for (base = name; *name; name++)
3613786a6f21Smrg    if (IS_DIR_SEPARATOR (*name))
3614786a6f21Smrg      base = name + 1;
3615786a6f21Smrg  return base;
3616786a6f21Smrg}
36171d54945dSmrg
3618786a6f21Smrgint
3619786a6f21Smrgcheck_executable (const char *path)
3620786a6f21Smrg{
3621786a6f21Smrg  struct stat st;
36221d54945dSmrg
3623786a6f21Smrg  LTWRAPPER_DEBUGPRINTF (("(check_executable)  : %s\n",
3624786a6f21Smrg			  path ? (*path ? path : "EMPTY!") : "NULL!"));
3625786a6f21Smrg  if ((!path) || (!*path))
3626786a6f21Smrg    return 0;
36271d54945dSmrg
3628786a6f21Smrg  if ((stat (path, &st) >= 0)
3629786a6f21Smrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
3630786a6f21Smrg    return 1;
3631786a6f21Smrg  else
3632786a6f21Smrg    return 0;
3633786a6f21Smrg}
36341d54945dSmrg
3635786a6f21Smrgint
3636786a6f21Smrgmake_executable (const char *path)
3637786a6f21Smrg{
3638786a6f21Smrg  int rval = 0;
3639786a6f21Smrg  struct stat st;
36401d54945dSmrg
3641786a6f21Smrg  LTWRAPPER_DEBUGPRINTF (("(make_executable)   : %s\n",
3642786a6f21Smrg			  path ? (*path ? path : "EMPTY!") : "NULL!"));
3643786a6f21Smrg  if ((!path) || (!*path))
3644786a6f21Smrg    return 0;
36451d54945dSmrg
3646786a6f21Smrg  if (stat (path, &st) >= 0)
3647786a6f21Smrg    {
3648786a6f21Smrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
3649786a6f21Smrg    }
3650786a6f21Smrg  return rval;
3651786a6f21Smrg}
36521d54945dSmrg
3653786a6f21Smrg/* Searches for the full path of the wrapper.  Returns
3654786a6f21Smrg   newly allocated full path name if found, NULL otherwise
3655786a6f21Smrg   Does not chase symlinks, even on platforms that support them.
3656786a6f21Smrg*/
3657786a6f21Smrgchar *
3658786a6f21Smrgfind_executable (const char *wrapper)
3659786a6f21Smrg{
3660786a6f21Smrg  int has_slash = 0;
3661786a6f21Smrg  const char *p;
3662786a6f21Smrg  const char *p_next;
3663786a6f21Smrg  /* static buffer for getcwd */
3664786a6f21Smrg  char tmp[LT_PATHMAX + 1];
3665786a6f21Smrg  int tmp_len;
3666786a6f21Smrg  char *concat_name;
36671d54945dSmrg
3668786a6f21Smrg  LTWRAPPER_DEBUGPRINTF (("(find_executable)   : %s\n",
3669786a6f21Smrg			  wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!"));
36701d54945dSmrg
3671786a6f21Smrg  if ((wrapper == NULL) || (*wrapper == '\0'))
3672786a6f21Smrg    return NULL;
36731d54945dSmrg
3674786a6f21Smrg  /* Absolute path? */
3675786a6f21Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3676786a6f21Smrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
3677786a6f21Smrg    {
3678786a6f21Smrg      concat_name = xstrdup (wrapper);
3679786a6f21Smrg      if (check_executable (concat_name))
3680786a6f21Smrg	return concat_name;
3681786a6f21Smrg      XFREE (concat_name);
3682786a6f21Smrg    }
3683786a6f21Smrg  else
3684786a6f21Smrg    {
3685786a6f21Smrg#endif
3686786a6f21Smrg      if (IS_DIR_SEPARATOR (wrapper[0]))
3687786a6f21Smrg	{
3688786a6f21Smrg	  concat_name = xstrdup (wrapper);
3689786a6f21Smrg	  if (check_executable (concat_name))
3690786a6f21Smrg	    return concat_name;
3691786a6f21Smrg	  XFREE (concat_name);
3692786a6f21Smrg	}
3693786a6f21Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3694786a6f21Smrg    }
3695786a6f21Smrg#endif
36961d54945dSmrg
3697786a6f21Smrg  for (p = wrapper; *p; p++)
3698786a6f21Smrg    if (*p == '/')
3699786a6f21Smrg      {
3700786a6f21Smrg	has_slash = 1;
3701786a6f21Smrg	break;
3702786a6f21Smrg      }
3703786a6f21Smrg  if (!has_slash)
3704786a6f21Smrg    {
3705786a6f21Smrg      /* no slashes; search PATH */
3706786a6f21Smrg      const char *path = getenv ("PATH");
3707786a6f21Smrg      if (path != NULL)
3708786a6f21Smrg	{
3709786a6f21Smrg	  for (p = path; *p; p = p_next)
3710786a6f21Smrg	    {
3711786a6f21Smrg	      const char *q;
3712786a6f21Smrg	      size_t p_len;
3713786a6f21Smrg	      for (q = p; *q; q++)
3714786a6f21Smrg		if (IS_PATH_SEPARATOR (*q))
3715786a6f21Smrg		  break;
3716786a6f21Smrg	      p_len = q - p;
3717786a6f21Smrg	      p_next = (*q == '\0' ? q : q + 1);
3718786a6f21Smrg	      if (p_len == 0)
3719786a6f21Smrg		{
3720786a6f21Smrg		  /* empty path: current directory */
3721786a6f21Smrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
3722786a6f21Smrg		    lt_fatal ("getcwd failed");
3723786a6f21Smrg		  tmp_len = strlen (tmp);
3724786a6f21Smrg		  concat_name =
3725786a6f21Smrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
3726786a6f21Smrg		  memcpy (concat_name, tmp, tmp_len);
3727786a6f21Smrg		  concat_name[tmp_len] = '/';
3728786a6f21Smrg		  strcpy (concat_name + tmp_len + 1, wrapper);
3729786a6f21Smrg		}
3730786a6f21Smrg	      else
3731786a6f21Smrg		{
3732786a6f21Smrg		  concat_name =
3733786a6f21Smrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
3734786a6f21Smrg		  memcpy (concat_name, p, p_len);
3735786a6f21Smrg		  concat_name[p_len] = '/';
3736786a6f21Smrg		  strcpy (concat_name + p_len + 1, wrapper);
3737786a6f21Smrg		}
3738786a6f21Smrg	      if (check_executable (concat_name))
3739786a6f21Smrg		return concat_name;
3740786a6f21Smrg	      XFREE (concat_name);
3741786a6f21Smrg	    }
3742786a6f21Smrg	}
3743786a6f21Smrg      /* not found in PATH; assume curdir */
3744786a6f21Smrg    }
3745786a6f21Smrg  /* Relative path | not found in path: prepend cwd */
3746786a6f21Smrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
3747786a6f21Smrg    lt_fatal ("getcwd failed");
3748786a6f21Smrg  tmp_len = strlen (tmp);
3749786a6f21Smrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
3750786a6f21Smrg  memcpy (concat_name, tmp, tmp_len);
3751786a6f21Smrg  concat_name[tmp_len] = '/';
3752786a6f21Smrg  strcpy (concat_name + tmp_len + 1, wrapper);
37531d54945dSmrg
3754786a6f21Smrg  if (check_executable (concat_name))
3755786a6f21Smrg    return concat_name;
3756786a6f21Smrg  XFREE (concat_name);
3757786a6f21Smrg  return NULL;
3758786a6f21Smrg}
37591d54945dSmrg
3760786a6f21Smrgchar *
3761786a6f21Smrgchase_symlinks (const char *pathspec)
3762786a6f21Smrg{
3763786a6f21Smrg#ifndef S_ISLNK
3764786a6f21Smrg  return xstrdup (pathspec);
3765786a6f21Smrg#else
3766786a6f21Smrg  char buf[LT_PATHMAX];
3767786a6f21Smrg  struct stat s;
3768786a6f21Smrg  char *tmp_pathspec = xstrdup (pathspec);
3769786a6f21Smrg  char *p;
3770786a6f21Smrg  int has_symlinks = 0;
3771786a6f21Smrg  while (strlen (tmp_pathspec) && !has_symlinks)
3772786a6f21Smrg    {
3773786a6f21Smrg      LTWRAPPER_DEBUGPRINTF (("checking path component for symlinks: %s\n",
3774786a6f21Smrg			      tmp_pathspec));
3775786a6f21Smrg      if (lstat (tmp_pathspec, &s) == 0)
3776786a6f21Smrg	{
3777786a6f21Smrg	  if (S_ISLNK (s.st_mode) != 0)
3778786a6f21Smrg	    {
3779786a6f21Smrg	      has_symlinks = 1;
3780786a6f21Smrg	      break;
3781786a6f21Smrg	    }
37821d54945dSmrg
3783786a6f21Smrg	  /* search backwards for last DIR_SEPARATOR */
3784786a6f21Smrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
3785786a6f21Smrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
3786786a6f21Smrg	    p--;
3787786a6f21Smrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
3788786a6f21Smrg	    {
3789786a6f21Smrg	      /* no more DIR_SEPARATORS left */
3790786a6f21Smrg	      break;
3791786a6f21Smrg	    }
3792786a6f21Smrg	  *p = '\0';
3793786a6f21Smrg	}
3794786a6f21Smrg      else
3795786a6f21Smrg	{
3796786a6f21Smrg	  char *errstr = strerror (errno);
3797786a6f21Smrg	  lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr);
3798786a6f21Smrg	}
3799786a6f21Smrg    }
3800786a6f21Smrg  XFREE (tmp_pathspec);
38011d54945dSmrg
3802786a6f21Smrg  if (!has_symlinks)
3803786a6f21Smrg    {
3804786a6f21Smrg      return xstrdup (pathspec);
3805786a6f21Smrg    }
38061d54945dSmrg
3807786a6f21Smrg  tmp_pathspec = realpath (pathspec, buf);
3808786a6f21Smrg  if (tmp_pathspec == 0)
3809786a6f21Smrg    {
3810786a6f21Smrg      lt_fatal ("Could not follow symlinks for %s", pathspec);
3811786a6f21Smrg    }
3812786a6f21Smrg  return xstrdup (tmp_pathspec);
3813786a6f21Smrg#endif
3814786a6f21Smrg}
38151d54945dSmrg
3816786a6f21Smrgchar *
3817786a6f21Smrgstrendzap (char *str, const char *pat)
3818786a6f21Smrg{
3819786a6f21Smrg  size_t len, patlen;
38201d54945dSmrg
3821786a6f21Smrg  assert (str != NULL);
3822786a6f21Smrg  assert (pat != NULL);
38231d54945dSmrg
3824786a6f21Smrg  len = strlen (str);
3825786a6f21Smrg  patlen = strlen (pat);
38261d54945dSmrg
3827786a6f21Smrg  if (patlen <= len)
3828786a6f21Smrg    {
3829786a6f21Smrg      str += len - patlen;
3830786a6f21Smrg      if (strcmp (str, pat) == 0)
3831786a6f21Smrg	*str = '\0';
3832786a6f21Smrg    }
3833786a6f21Smrg  return str;
3834786a6f21Smrg}
38351d54945dSmrg
3836786a6f21Smrgstatic void
3837786a6f21Smrglt_error_core (int exit_status, const char *mode,
3838786a6f21Smrg	       const char *message, va_list ap)
3839786a6f21Smrg{
3840786a6f21Smrg  fprintf (stderr, "%s: %s: ", program_name, mode);
3841786a6f21Smrg  vfprintf (stderr, message, ap);
3842786a6f21Smrg  fprintf (stderr, ".\n");
38431d54945dSmrg
3844786a6f21Smrg  if (exit_status >= 0)
3845786a6f21Smrg    exit (exit_status);
3846786a6f21Smrg}
38471d54945dSmrg
3848786a6f21Smrgvoid
3849786a6f21Smrglt_fatal (const char *message, ...)
3850786a6f21Smrg{
3851786a6f21Smrg  va_list ap;
3852786a6f21Smrg  va_start (ap, message);
3853786a6f21Smrg  lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
3854786a6f21Smrg  va_end (ap);
3855786a6f21Smrg}
38561d54945dSmrg
3857786a6f21Smrgvoid
3858786a6f21Smrglt_setenv (const char *name, const char *value)
3859786a6f21Smrg{
3860786a6f21Smrg  LTWRAPPER_DEBUGPRINTF (("(lt_setenv) setting '%s' to '%s'\n",
3861786a6f21Smrg                          (name ? name : "<NULL>"),
3862786a6f21Smrg                          (value ? value : "<NULL>")));
3863786a6f21Smrg  {
3864786a6f21Smrg#ifdef HAVE_SETENV
3865786a6f21Smrg    /* always make a copy, for consistency with !HAVE_SETENV */
3866786a6f21Smrg    char *str = xstrdup (value);
3867786a6f21Smrg    setenv (name, str, 1);
3868786a6f21Smrg#else
3869786a6f21Smrg    int len = strlen (name) + 1 + strlen (value) + 1;
3870786a6f21Smrg    char *str = XMALLOC (char, len);
3871786a6f21Smrg    sprintf (str, "%s=%s", name, value);
3872786a6f21Smrg    if (putenv (str) != EXIT_SUCCESS)
3873786a6f21Smrg      {
3874786a6f21Smrg        XFREE (str);
3875786a6f21Smrg      }
3876786a6f21Smrg#endif
3877786a6f21Smrg  }
3878786a6f21Smrg}
38791d54945dSmrg
3880786a6f21Smrgchar *
3881786a6f21Smrglt_extend_str (const char *orig_value, const char *add, int to_end)
3882786a6f21Smrg{
3883786a6f21Smrg  char *new_value;
3884786a6f21Smrg  if (orig_value && *orig_value)
3885786a6f21Smrg    {
3886786a6f21Smrg      int orig_value_len = strlen (orig_value);
3887786a6f21Smrg      int add_len = strlen (add);
3888786a6f21Smrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
3889786a6f21Smrg      if (to_end)
3890786a6f21Smrg        {
3891786a6f21Smrg          strcpy (new_value, orig_value);
3892786a6f21Smrg          strcpy (new_value + orig_value_len, add);
3893786a6f21Smrg        }
3894786a6f21Smrg      else
3895786a6f21Smrg        {
3896786a6f21Smrg          strcpy (new_value, add);
3897786a6f21Smrg          strcpy (new_value + add_len, orig_value);
3898786a6f21Smrg        }
3899786a6f21Smrg    }
3900786a6f21Smrg  else
3901786a6f21Smrg    {
3902786a6f21Smrg      new_value = xstrdup (add);
3903786a6f21Smrg    }
3904786a6f21Smrg  return new_value;
3905786a6f21Smrg}
39061d54945dSmrg
3907786a6f21Smrgint
3908786a6f21Smrglt_split_name_value (const char *arg, char** name, char** value)
3909786a6f21Smrg{
3910786a6f21Smrg  const char *p;
3911786a6f21Smrg  int len;
3912786a6f21Smrg  if (!arg || !*arg)
3913786a6f21Smrg    return 1;
39141d54945dSmrg
3915786a6f21Smrg  p = strchr (arg, (int)'=');
39161d54945dSmrg
3917786a6f21Smrg  if (!p)
3918786a6f21Smrg    return 1;
39191d54945dSmrg
3920786a6f21Smrg  *value = xstrdup (++p);
39211d54945dSmrg
3922786a6f21Smrg  len = strlen (arg) - strlen (*value);
3923786a6f21Smrg  *name = XMALLOC (char, len);
3924786a6f21Smrg  strncpy (*name, arg, len-1);
3925786a6f21Smrg  (*name)[len - 1] = '\0';
39261d54945dSmrg
3927786a6f21Smrg  return 0;
3928786a6f21Smrg}
39291d54945dSmrg
3930786a6f21Smrgvoid
3931786a6f21Smrglt_opt_process_env_set (const char *arg)
3932786a6f21Smrg{
3933786a6f21Smrg  char *name = NULL;
3934786a6f21Smrg  char *value = NULL;
39351d54945dSmrg
3936786a6f21Smrg  if (lt_split_name_value (arg, &name, &value) != 0)
3937786a6f21Smrg    {
3938786a6f21Smrg      XFREE (name);
3939786a6f21Smrg      XFREE (value);
3940786a6f21Smrg      lt_fatal ("bad argument for %s: '%s'", env_set_opt, arg);
3941786a6f21Smrg    }
39421d54945dSmrg
3943786a6f21Smrg  lt_setenv (name, value);
3944786a6f21Smrg  XFREE (name);
3945786a6f21Smrg  XFREE (value);
3946786a6f21Smrg}
39471d54945dSmrg
3948786a6f21Smrgvoid
3949786a6f21Smrglt_opt_process_env_prepend (const char *arg)
3950786a6f21Smrg{
3951786a6f21Smrg  char *name = NULL;
3952786a6f21Smrg  char *value = NULL;
3953786a6f21Smrg  char *new_value = NULL;
39541d54945dSmrg
3955786a6f21Smrg  if (lt_split_name_value (arg, &name, &value) != 0)
3956786a6f21Smrg    {
3957786a6f21Smrg      XFREE (name);
3958786a6f21Smrg      XFREE (value);
3959786a6f21Smrg      lt_fatal ("bad argument for %s: '%s'", env_prepend_opt, arg);
3960786a6f21Smrg    }
39611d54945dSmrg
3962786a6f21Smrg  new_value = lt_extend_str (getenv (name), value, 0);
3963786a6f21Smrg  lt_setenv (name, new_value);
3964786a6f21Smrg  XFREE (new_value);
3965786a6f21Smrg  XFREE (name);
3966786a6f21Smrg  XFREE (value);
3967786a6f21Smrg}
39681d54945dSmrg
3969786a6f21Smrgvoid
3970786a6f21Smrglt_opt_process_env_append (const char *arg)
3971786a6f21Smrg{
3972786a6f21Smrg  char *name = NULL;
3973786a6f21Smrg  char *value = NULL;
3974786a6f21Smrg  char *new_value = NULL;
39751d54945dSmrg
3976786a6f21Smrg  if (lt_split_name_value (arg, &name, &value) != 0)
3977786a6f21Smrg    {
3978786a6f21Smrg      XFREE (name);
3979786a6f21Smrg      XFREE (value);
3980786a6f21Smrg      lt_fatal ("bad argument for %s: '%s'", env_append_opt, arg);
3981786a6f21Smrg    }
39821d54945dSmrg
3983786a6f21Smrg  new_value = lt_extend_str (getenv (name), value, 1);
3984786a6f21Smrg  lt_setenv (name, new_value);
3985786a6f21Smrg  XFREE (new_value);
3986786a6f21Smrg  XFREE (name);
3987786a6f21Smrg  XFREE (value);
3988786a6f21Smrg}
39891d54945dSmrg
3990786a6f21Smrgvoid
3991786a6f21Smrglt_update_exe_path (const char *name, const char *value)
3992786a6f21Smrg{
3993786a6f21Smrg  LTWRAPPER_DEBUGPRINTF (("(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
3994786a6f21Smrg                          (name ? name : "<NULL>"),
3995786a6f21Smrg                          (value ? value : "<NULL>")));
39961d54945dSmrg
3997786a6f21Smrg  if (name && *name && value && *value)
3998786a6f21Smrg    {
3999786a6f21Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
4000786a6f21Smrg      /* some systems can't cope with a ':'-terminated path #' */
4001786a6f21Smrg      int len = strlen (new_value);
4002786a6f21Smrg      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
4003786a6f21Smrg        {
4004786a6f21Smrg          new_value[len-1] = '\0';
4005786a6f21Smrg        }
4006786a6f21Smrg      lt_setenv (name, new_value);
4007786a6f21Smrg      XFREE (new_value);
4008786a6f21Smrg    }
4009786a6f21Smrg}
40101d54945dSmrg
4011786a6f21Smrgvoid
4012786a6f21Smrglt_update_lib_path (const char *name, const char *value)
4013786a6f21Smrg{
4014786a6f21Smrg  LTWRAPPER_DEBUGPRINTF (("(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
4015786a6f21Smrg                          (name ? name : "<NULL>"),
4016786a6f21Smrg                          (value ? value : "<NULL>")));
40171d54945dSmrg
4018786a6f21Smrg  if (name && *name && value && *value)
4019786a6f21Smrg    {
4020786a6f21Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
4021786a6f21Smrg      lt_setenv (name, new_value);
4022786a6f21Smrg      XFREE (new_value);
4023786a6f21Smrg    }
40241d54945dSmrg}
40251d54945dSmrg
40261d54945dSmrg
4027786a6f21SmrgEOF
40281d54945dSmrg}
4029786a6f21Smrg# end: func_emit_cwrapperexe_src
40301d54945dSmrg
4031786a6f21Smrg# func_mode_link arg...
4032786a6f21Smrgfunc_mode_link ()
4033786a6f21Smrg{
4034786a6f21Smrg    $opt_debug
4035786a6f21Smrg    case $host in
4036786a6f21Smrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
4037786a6f21Smrg      # It is impossible to link a dll without this setting, and
4038786a6f21Smrg      # we shouldn't force the makefile maintainer to figure out
4039786a6f21Smrg      # which system we are compiling for in order to pass an extra
4040786a6f21Smrg      # flag for every libtool invocation.
4041786a6f21Smrg      # allow_undefined=no
40421d54945dSmrg
4043786a6f21Smrg      # FIXME: Unfortunately, there are problems with the above when trying
4044786a6f21Smrg      # to make a dll which has undefined symbols, in which case not
4045786a6f21Smrg      # even a static library is built.  For now, we need to specify
4046786a6f21Smrg      # -no-undefined on the libtool link line when we can be certain
4047786a6f21Smrg      # that all symbols are satisfied, otherwise we get a static library.
4048786a6f21Smrg      allow_undefined=yes
4049786a6f21Smrg      ;;
4050786a6f21Smrg    *)
4051786a6f21Smrg      allow_undefined=yes
4052786a6f21Smrg      ;;
4053786a6f21Smrg    esac
4054786a6f21Smrg    libtool_args=$nonopt
4055786a6f21Smrg    base_compile="$nonopt $@"
4056786a6f21Smrg    compile_command=$nonopt
4057786a6f21Smrg    finalize_command=$nonopt
40581d54945dSmrg
4059786a6f21Smrg    compile_rpath=
4060786a6f21Smrg    finalize_rpath=
4061786a6f21Smrg    compile_shlibpath=
4062786a6f21Smrg    finalize_shlibpath=
4063786a6f21Smrg    convenience=
4064786a6f21Smrg    old_convenience=
4065786a6f21Smrg    deplibs=
4066786a6f21Smrg    old_deplibs=
4067786a6f21Smrg    compiler_flags=
4068786a6f21Smrg    linker_flags=
4069786a6f21Smrg    dllsearchpath=
4070786a6f21Smrg    lib_search_path=`pwd`
4071786a6f21Smrg    inst_prefix_dir=
4072786a6f21Smrg    new_inherited_linker_flags=
40731d54945dSmrg
4074786a6f21Smrg    avoid_version=no
4075786a6f21Smrg    dlfiles=
4076786a6f21Smrg    dlprefiles=
4077786a6f21Smrg    dlself=no
4078786a6f21Smrg    export_dynamic=no
4079786a6f21Smrg    export_symbols=
4080786a6f21Smrg    export_symbols_regex=
4081786a6f21Smrg    generated=
4082786a6f21Smrg    libobjs=
4083786a6f21Smrg    ltlibs=
4084786a6f21Smrg    module=no
4085786a6f21Smrg    no_install=no
4086786a6f21Smrg    objs=
4087786a6f21Smrg    non_pic_objects=
4088786a6f21Smrg    precious_files_regex=
4089786a6f21Smrg    prefer_static_libs=no
4090786a6f21Smrg    preload=no
4091786a6f21Smrg    prev=
4092786a6f21Smrg    prevarg=
4093786a6f21Smrg    release=
4094786a6f21Smrg    rpath=
4095786a6f21Smrg    xrpath=
4096786a6f21Smrg    perm_rpath=
4097786a6f21Smrg    temp_rpath=
4098786a6f21Smrg    thread_safe=no
4099786a6f21Smrg    vinfo=
4100786a6f21Smrg    vinfo_number=no
4101786a6f21Smrg    weak_libs=
4102786a6f21Smrg    single_module="${wl}-single_module"
4103786a6f21Smrg    func_infer_tag $base_compile
41041d54945dSmrg
4105786a6f21Smrg    # We need to know -static, to get the right output filenames.
4106786a6f21Smrg    for arg
4107786a6f21Smrg    do
4108786a6f21Smrg      case $arg in
4109786a6f21Smrg      -shared)
4110786a6f21Smrg	test "$build_libtool_libs" != yes && \
4111786a6f21Smrg	  func_fatal_configuration "can not build a shared library"
4112786a6f21Smrg	build_old_libs=no
4113786a6f21Smrg	break
4114786a6f21Smrg	;;
4115786a6f21Smrg      -all-static | -static | -static-libtool-libs)
4116786a6f21Smrg	case $arg in
4117786a6f21Smrg	-all-static)
4118786a6f21Smrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
4119786a6f21Smrg	    func_warning "complete static linking is impossible in this configuration"
4120786a6f21Smrg	  fi
4121786a6f21Smrg	  if test -n "$link_static_flag"; then
4122786a6f21Smrg	    dlopen_self=$dlopen_self_static
4123786a6f21Smrg	  fi
4124786a6f21Smrg	  prefer_static_libs=yes
41251d54945dSmrg	  ;;
4126786a6f21Smrg	-static)
4127786a6f21Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
4128786a6f21Smrg	    dlopen_self=$dlopen_self_static
4129786a6f21Smrg	  fi
4130786a6f21Smrg	  prefer_static_libs=built
4131786a6f21Smrg	  ;;
4132786a6f21Smrg	-static-libtool-libs)
4133786a6f21Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
4134786a6f21Smrg	    dlopen_self=$dlopen_self_static
4135786a6f21Smrg	  fi
4136786a6f21Smrg	  prefer_static_libs=yes
41371d54945dSmrg	  ;;
41381d54945dSmrg	esac
4139786a6f21Smrg	build_libtool_libs=no
4140786a6f21Smrg	build_old_libs=yes
4141786a6f21Smrg	break
4142786a6f21Smrg	;;
4143786a6f21Smrg      esac
4144786a6f21Smrg    done
41451d54945dSmrg
4146786a6f21Smrg    # See if our shared archives depend on static archives.
4147786a6f21Smrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
41481d54945dSmrg
4149786a6f21Smrg    # Go through the arguments, transforming them on the way.
4150786a6f21Smrg    while test "$#" -gt 0; do
4151786a6f21Smrg      arg="$1"
4152786a6f21Smrg      shift
4153786a6f21Smrg      func_quote_for_eval "$arg"
4154786a6f21Smrg      qarg=$func_quote_for_eval_unquoted_result
4155786a6f21Smrg      func_append libtool_args " $func_quote_for_eval_result"
41561d54945dSmrg
4157786a6f21Smrg      # If the previous option needs an argument, assign it.
4158786a6f21Smrg      if test -n "$prev"; then
4159786a6f21Smrg	case $prev in
4160786a6f21Smrg	output)
4161786a6f21Smrg	  func_append compile_command " @OUTPUT@"
4162786a6f21Smrg	  func_append finalize_command " @OUTPUT@"
4163786a6f21Smrg	  ;;
4164786a6f21Smrg	esac
41651d54945dSmrg
4166786a6f21Smrg	case $prev in
4167786a6f21Smrg	dlfiles|dlprefiles)
4168786a6f21Smrg	  if test "$preload" = no; then
4169786a6f21Smrg	    # Add the symbol object into the linking commands.
4170786a6f21Smrg	    func_append compile_command " @SYMFILE@"
4171786a6f21Smrg	    func_append finalize_command " @SYMFILE@"
4172786a6f21Smrg	    preload=yes
4173786a6f21Smrg	  fi
4174786a6f21Smrg	  case $arg in
4175786a6f21Smrg	  *.la | *.lo) ;;  # We handle these cases below.
4176786a6f21Smrg	  force)
4177786a6f21Smrg	    if test "$dlself" = no; then
4178786a6f21Smrg	      dlself=needless
4179786a6f21Smrg	      export_dynamic=yes
4180786a6f21Smrg	    fi
4181786a6f21Smrg	    prev=
4182786a6f21Smrg	    continue
4183786a6f21Smrg	    ;;
4184786a6f21Smrg	  self)
4185786a6f21Smrg	    if test "$prev" = dlprefiles; then
4186786a6f21Smrg	      dlself=yes
4187786a6f21Smrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
4188786a6f21Smrg	      dlself=yes
4189786a6f21Smrg	    else
4190786a6f21Smrg	      dlself=needless
4191786a6f21Smrg	      export_dynamic=yes
4192786a6f21Smrg	    fi
4193786a6f21Smrg	    prev=
4194786a6f21Smrg	    continue
41951d54945dSmrg	    ;;
41961d54945dSmrg	  *)
4197786a6f21Smrg	    if test "$prev" = dlfiles; then
4198786a6f21Smrg	      dlfiles="$dlfiles $arg"
4199786a6f21Smrg	    else
4200786a6f21Smrg	      dlprefiles="$dlprefiles $arg"
4201786a6f21Smrg	    fi
4202786a6f21Smrg	    prev=
4203786a6f21Smrg	    continue
42041d54945dSmrg	    ;;
42051d54945dSmrg	  esac
4206786a6f21Smrg	  ;;
4207786a6f21Smrg	expsyms)
4208786a6f21Smrg	  export_symbols="$arg"
4209786a6f21Smrg	  test -f "$arg" \
4210786a6f21Smrg	    || func_fatal_error "symbol file \`$arg' does not exist"
4211786a6f21Smrg	  prev=
4212786a6f21Smrg	  continue
4213786a6f21Smrg	  ;;
4214786a6f21Smrg	expsyms_regex)
4215786a6f21Smrg	  export_symbols_regex="$arg"
4216786a6f21Smrg	  prev=
4217786a6f21Smrg	  continue
4218786a6f21Smrg	  ;;
4219786a6f21Smrg	framework)
4220786a6f21Smrg	  case $host in
4221786a6f21Smrg	    *-*-darwin*)
4222786a6f21Smrg	      case "$deplibs " in
4223786a6f21Smrg		*" $qarg.ltframework "*) ;;
4224786a6f21Smrg		*) deplibs="$deplibs $qarg.ltframework" # this is fixed later
4225786a6f21Smrg		   ;;
4226786a6f21Smrg	      esac
4227786a6f21Smrg	      ;;
4228786a6f21Smrg	  esac
4229786a6f21Smrg	  prev=
4230786a6f21Smrg	  continue
4231786a6f21Smrg	  ;;
4232786a6f21Smrg	inst_prefix)
4233786a6f21Smrg	  inst_prefix_dir="$arg"
4234786a6f21Smrg	  prev=
4235786a6f21Smrg	  continue
4236786a6f21Smrg	  ;;
4237786a6f21Smrg	objectlist)
4238786a6f21Smrg	  if test -f "$arg"; then
4239786a6f21Smrg	    save_arg=$arg
4240786a6f21Smrg	    moreargs=
4241786a6f21Smrg	    for fil in `cat "$save_arg"`
4242786a6f21Smrg	    do
4243786a6f21Smrg#	      moreargs="$moreargs $fil"
4244786a6f21Smrg	      arg=$fil
4245786a6f21Smrg	      # A libtool-controlled object.
42461d54945dSmrg
4247786a6f21Smrg	      # Check to see that this really is a libtool object.
4248786a6f21Smrg	      if func_lalib_unsafe_p "$arg"; then
4249786a6f21Smrg		pic_object=
4250786a6f21Smrg		non_pic_object=
42511d54945dSmrg
4252786a6f21Smrg		# Read the .lo file
4253786a6f21Smrg		func_source "$arg"
42541d54945dSmrg
4255786a6f21Smrg		if test -z "$pic_object" ||
4256786a6f21Smrg		   test -z "$non_pic_object" ||
4257786a6f21Smrg		   test "$pic_object" = none &&
4258786a6f21Smrg		   test "$non_pic_object" = none; then
4259786a6f21Smrg		  func_fatal_error "cannot find name of object for \`$arg'"
4260786a6f21Smrg		fi
42611d54945dSmrg
4262786a6f21Smrg		# Extract subdirectory from the argument.
4263786a6f21Smrg		func_dirname "$arg" "/" ""
4264786a6f21Smrg		xdir="$func_dirname_result"
42651d54945dSmrg
4266786a6f21Smrg		if test "$pic_object" != none; then
4267786a6f21Smrg		  # Prepend the subdirectory the object is found in.
4268786a6f21Smrg		  pic_object="$xdir$pic_object"
42691d54945dSmrg
4270786a6f21Smrg		  if test "$prev" = dlfiles; then
4271786a6f21Smrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
4272786a6f21Smrg		      dlfiles="$dlfiles $pic_object"
4273786a6f21Smrg		      prev=
4274786a6f21Smrg		      continue
4275786a6f21Smrg		    else
4276786a6f21Smrg		      # If libtool objects are unsupported, then we need to preload.
4277786a6f21Smrg		      prev=dlprefiles
4278786a6f21Smrg		    fi
4279786a6f21Smrg		  fi
42801d54945dSmrg
4281786a6f21Smrg		  # CHECK ME:  I think I busted this.  -Ossama
4282786a6f21Smrg		  if test "$prev" = dlprefiles; then
4283786a6f21Smrg		    # Preload the old-style object.
4284786a6f21Smrg		    dlprefiles="$dlprefiles $pic_object"
4285786a6f21Smrg		    prev=
4286786a6f21Smrg		  fi
42871d54945dSmrg
4288786a6f21Smrg		  # A PIC object.
4289786a6f21Smrg		  func_append libobjs " $pic_object"
4290786a6f21Smrg		  arg="$pic_object"
4291786a6f21Smrg		fi
42921d54945dSmrg
4293786a6f21Smrg		# Non-PIC object.
4294786a6f21Smrg		if test "$non_pic_object" != none; then
4295786a6f21Smrg		  # Prepend the subdirectory the object is found in.
4296786a6f21Smrg		  non_pic_object="$xdir$non_pic_object"
42971d54945dSmrg
4298786a6f21Smrg		  # A standard non-PIC object
4299786a6f21Smrg		  func_append non_pic_objects " $non_pic_object"
4300786a6f21Smrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
4301786a6f21Smrg		    arg="$non_pic_object"
4302786a6f21Smrg		  fi
4303786a6f21Smrg		else
4304786a6f21Smrg		  # If the PIC object exists, use it instead.
4305786a6f21Smrg		  # $xdir was prepended to $pic_object above.
4306786a6f21Smrg		  non_pic_object="$pic_object"
4307786a6f21Smrg		  func_append non_pic_objects " $non_pic_object"
4308786a6f21Smrg		fi
4309786a6f21Smrg	      else
4310786a6f21Smrg		# Only an error if not doing a dry-run.
4311786a6f21Smrg		if $opt_dry_run; then
4312786a6f21Smrg		  # Extract subdirectory from the argument.
4313786a6f21Smrg		  func_dirname "$arg" "/" ""
4314786a6f21Smrg		  xdir="$func_dirname_result"
4315786a6f21Smrg
4316786a6f21Smrg		  func_lo2o "$arg"
4317786a6f21Smrg		  pic_object=$xdir$objdir/$func_lo2o_result
4318786a6f21Smrg		  non_pic_object=$xdir$func_lo2o_result
4319786a6f21Smrg		  func_append libobjs " $pic_object"
4320786a6f21Smrg		  func_append non_pic_objects " $non_pic_object"
4321786a6f21Smrg	        else
4322786a6f21Smrg		  func_fatal_error "\`$arg' is not a valid libtool object"
4323786a6f21Smrg		fi
4324786a6f21Smrg	      fi
4325786a6f21Smrg	    done
43261d54945dSmrg	  else
4327786a6f21Smrg	    func_fatal_error "link input file \`$arg' does not exist"
43281d54945dSmrg	  fi
4329786a6f21Smrg	  arg=$save_arg
4330786a6f21Smrg	  prev=
4331786a6f21Smrg	  continue
4332786a6f21Smrg	  ;;
4333786a6f21Smrg	precious_regex)
4334786a6f21Smrg	  precious_files_regex="$arg"
4335786a6f21Smrg	  prev=
4336786a6f21Smrg	  continue
4337786a6f21Smrg	  ;;
4338786a6f21Smrg	release)
4339786a6f21Smrg	  release="-$arg"
4340786a6f21Smrg	  prev=
4341786a6f21Smrg	  continue
4342786a6f21Smrg	  ;;
4343786a6f21Smrg	rpath | xrpath)
4344786a6f21Smrg	  # We need an absolute path.
4345786a6f21Smrg	  case $arg in
4346786a6f21Smrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
4347786a6f21Smrg	  *)
4348786a6f21Smrg	    func_fatal_error "only absolute run-paths are allowed"
4349786a6f21Smrg	    ;;
4350786a6f21Smrg	  esac
4351786a6f21Smrg	  if test "$prev" = rpath; then
4352786a6f21Smrg	    case "$rpath " in
4353786a6f21Smrg	    *" $arg "*) ;;
4354786a6f21Smrg	    *) rpath="$rpath $arg" ;;
4355786a6f21Smrg	    esac
4356786a6f21Smrg	  else
4357786a6f21Smrg	    case "$xrpath " in
4358786a6f21Smrg	    *" $arg "*) ;;
4359786a6f21Smrg	    *) xrpath="$xrpath $arg" ;;
4360786a6f21Smrg	    esac
4361786a6f21Smrg	  fi
4362786a6f21Smrg	  prev=
4363786a6f21Smrg	  continue
4364786a6f21Smrg	  ;;
4365786a6f21Smrg	shrext)
4366786a6f21Smrg	  shrext_cmds="$arg"
4367786a6f21Smrg	  prev=
4368786a6f21Smrg	  continue
4369786a6f21Smrg	  ;;
4370786a6f21Smrg	weak)
4371786a6f21Smrg	  weak_libs="$weak_libs $arg"
4372786a6f21Smrg	  prev=
4373786a6f21Smrg	  continue
4374786a6f21Smrg	  ;;
4375786a6f21Smrg	xcclinker)
4376786a6f21Smrg	  linker_flags="$linker_flags $qarg"
4377786a6f21Smrg	  compiler_flags="$compiler_flags $qarg"
4378786a6f21Smrg	  prev=
4379786a6f21Smrg	  func_append compile_command " $qarg"
4380786a6f21Smrg	  func_append finalize_command " $qarg"
4381786a6f21Smrg	  continue
4382786a6f21Smrg	  ;;
4383786a6f21Smrg	xcompiler)
4384786a6f21Smrg	  compiler_flags="$compiler_flags $qarg"
4385786a6f21Smrg	  prev=
4386786a6f21Smrg	  func_append compile_command " $qarg"
4387786a6f21Smrg	  func_append finalize_command " $qarg"
4388786a6f21Smrg	  continue
4389786a6f21Smrg	  ;;
4390786a6f21Smrg	xlinker)
4391786a6f21Smrg	  linker_flags="$linker_flags $qarg"
4392786a6f21Smrg	  compiler_flags="$compiler_flags $wl$qarg"
4393786a6f21Smrg	  prev=
4394786a6f21Smrg	  func_append compile_command " $wl$qarg"
4395786a6f21Smrg	  func_append finalize_command " $wl$qarg"
4396786a6f21Smrg	  continue
4397786a6f21Smrg	  ;;
4398786a6f21Smrg	*)
4399786a6f21Smrg	  eval "$prev=\"\$arg\""
4400786a6f21Smrg	  prev=
4401786a6f21Smrg	  continue
4402786a6f21Smrg	  ;;
44031d54945dSmrg	esac
4404786a6f21Smrg      fi # test -n "$prev"
44051d54945dSmrg
4406786a6f21Smrg      prevarg="$arg"
44071d54945dSmrg
4408786a6f21Smrg      case $arg in
4409786a6f21Smrg      -all-static)
4410786a6f21Smrg	if test -n "$link_static_flag"; then
4411786a6f21Smrg	  # See comment for -static flag below, for more details.
4412786a6f21Smrg	  func_append compile_command " $link_static_flag"
4413786a6f21Smrg	  func_append finalize_command " $link_static_flag"
4414786a6f21Smrg	fi
4415786a6f21Smrg	continue
4416786a6f21Smrg	;;
44171d54945dSmrg
4418786a6f21Smrg      -allow-undefined)
4419786a6f21Smrg	# FIXME: remove this flag sometime in the future.
4420786a6f21Smrg	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
4421786a6f21Smrg	;;
44221d54945dSmrg
4423786a6f21Smrg      -avoid-version)
4424786a6f21Smrg	avoid_version=yes
4425786a6f21Smrg	continue
4426786a6f21Smrg	;;
44271d54945dSmrg
4428786a6f21Smrg      -dlopen)
4429786a6f21Smrg	prev=dlfiles
4430786a6f21Smrg	continue
4431786a6f21Smrg	;;
44321d54945dSmrg
4433786a6f21Smrg      -dlpreopen)
4434786a6f21Smrg	prev=dlprefiles
4435786a6f21Smrg	continue
4436786a6f21Smrg	;;
44371d54945dSmrg
4438786a6f21Smrg      -export-dynamic)
4439786a6f21Smrg	export_dynamic=yes
4440786a6f21Smrg	continue
4441786a6f21Smrg	;;
44421d54945dSmrg
4443786a6f21Smrg      -export-symbols | -export-symbols-regex)
4444786a6f21Smrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
4445786a6f21Smrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
4446786a6f21Smrg	fi
4447786a6f21Smrg	if test "X$arg" = "X-export-symbols"; then
4448786a6f21Smrg	  prev=expsyms
4449786a6f21Smrg	else
4450786a6f21Smrg	  prev=expsyms_regex
4451786a6f21Smrg	fi
4452786a6f21Smrg	continue
4453786a6f21Smrg	;;
44541d54945dSmrg
4455786a6f21Smrg      -framework)
4456786a6f21Smrg	prev=framework
4457786a6f21Smrg	continue
4458786a6f21Smrg	;;
44591d54945dSmrg
4460786a6f21Smrg      -inst-prefix-dir)
4461786a6f21Smrg	prev=inst_prefix
4462786a6f21Smrg	continue
4463786a6f21Smrg	;;
44641d54945dSmrg
4465786a6f21Smrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
4466786a6f21Smrg      # so, if we see these flags be careful not to treat them like -L
4467786a6f21Smrg      -L[A-Z][A-Z]*:*)
4468786a6f21Smrg	case $with_gcc/$host in
4469786a6f21Smrg	no/*-*-irix* | /*-*-irix*)
4470786a6f21Smrg	  func_append compile_command " $arg"
4471786a6f21Smrg	  func_append finalize_command " $arg"
4472786a6f21Smrg	  ;;
4473786a6f21Smrg	esac
4474786a6f21Smrg	continue
4475786a6f21Smrg	;;
44761d54945dSmrg
4477786a6f21Smrg      -L*)
4478786a6f21Smrg	func_stripname '-L' '' "$arg"
4479786a6f21Smrg	dir=$func_stripname_result
4480786a6f21Smrg	if test -z "$dir"; then
4481786a6f21Smrg	  if test "$#" -gt 0; then
4482786a6f21Smrg	    func_fatal_error "require no space between \`-L' and \`$1'"
4483786a6f21Smrg	  else
4484786a6f21Smrg	    func_fatal_error "need path for \`-L' option"
4485786a6f21Smrg	  fi
4486786a6f21Smrg	fi
4487786a6f21Smrg	# We need an absolute path.
4488786a6f21Smrg	case $dir in
4489786a6f21Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
4490786a6f21Smrg	*)
4491786a6f21Smrg	  absdir=`cd "$dir" && pwd`
4492786a6f21Smrg	  test -z "$absdir" && \
4493786a6f21Smrg	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
4494786a6f21Smrg	  dir="$absdir"
4495786a6f21Smrg	  ;;
4496786a6f21Smrg	esac
4497786a6f21Smrg	case "$deplibs " in
4498786a6f21Smrg	*" -L$dir "*) ;;
4499786a6f21Smrg	*)
4500786a6f21Smrg	  deplibs="$deplibs -L$dir"
4501786a6f21Smrg	  lib_search_path="$lib_search_path $dir"
4502786a6f21Smrg	  ;;
4503786a6f21Smrg	esac
4504786a6f21Smrg	case $host in
4505786a6f21Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
4506786a6f21Smrg	  testbindir=`$ECHO "X$dir" | $Xsed -e 's*/lib$*/bin*'`
4507786a6f21Smrg	  case :$dllsearchpath: in
4508786a6f21Smrg	  *":$dir:"*) ;;
4509786a6f21Smrg	  ::) dllsearchpath=$dir;;
4510786a6f21Smrg	  *) dllsearchpath="$dllsearchpath:$dir";;
4511786a6f21Smrg	  esac
4512786a6f21Smrg	  case :$dllsearchpath: in
4513786a6f21Smrg	  *":$testbindir:"*) ;;
4514786a6f21Smrg	  ::) dllsearchpath=$testbindir;;
4515786a6f21Smrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
4516786a6f21Smrg	  esac
4517786a6f21Smrg	  ;;
4518786a6f21Smrg	esac
4519786a6f21Smrg	continue
4520786a6f21Smrg	;;
45211d54945dSmrg
4522786a6f21Smrg      -l*)
4523786a6f21Smrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
4524786a6f21Smrg	  case $host in
4525786a6f21Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc*)
4526786a6f21Smrg	    # These systems don't actually have a C or math library (as such)
4527786a6f21Smrg	    continue
4528786a6f21Smrg	    ;;
4529786a6f21Smrg	  *-*-os2*)
4530786a6f21Smrg	    # These systems don't actually have a C library (as such)
4531786a6f21Smrg	    test "X$arg" = "X-lc" && continue
4532786a6f21Smrg	    ;;
4533786a6f21Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
4534786a6f21Smrg	    # Do not include libc due to us having libc/libc_r.
4535786a6f21Smrg	    test "X$arg" = "X-lc" && continue
4536786a6f21Smrg	    ;;
4537786a6f21Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
4538786a6f21Smrg	    # Rhapsody C and math libraries are in the System framework
4539786a6f21Smrg	    deplibs="$deplibs System.ltframework"
4540786a6f21Smrg	    continue
4541786a6f21Smrg	    ;;
4542786a6f21Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
4543786a6f21Smrg	    # Causes problems with __ctype
4544786a6f21Smrg	    test "X$arg" = "X-lc" && continue
4545786a6f21Smrg	    ;;
4546786a6f21Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
4547786a6f21Smrg	    # Compiler inserts libc in the correct place for threads to work
4548786a6f21Smrg	    test "X$arg" = "X-lc" && continue
4549786a6f21Smrg	    ;;
4550786a6f21Smrg	  esac
4551786a6f21Smrg	elif test "X$arg" = "X-lc_r"; then
4552786a6f21Smrg	 case $host in
4553786a6f21Smrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
4554786a6f21Smrg	   # Do not include libc_r directly, use -pthread flag.
4555786a6f21Smrg	   continue
4556786a6f21Smrg	   ;;
4557786a6f21Smrg	 esac
4558786a6f21Smrg	fi
4559786a6f21Smrg	deplibs="$deplibs $arg"
4560786a6f21Smrg	continue
4561786a6f21Smrg	;;
45621d54945dSmrg
4563786a6f21Smrg      -module)
4564786a6f21Smrg	module=yes
4565786a6f21Smrg	continue
4566786a6f21Smrg	;;
45671d54945dSmrg
4568786a6f21Smrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
4569786a6f21Smrg      # classes, name mangling, and exception handling.
4570786a6f21Smrg      # Darwin uses the -arch flag to determine output architecture.
4571786a6f21Smrg      -model|-arch|-isysroot)
4572786a6f21Smrg	compiler_flags="$compiler_flags $arg"
4573786a6f21Smrg	func_append compile_command " $arg"
4574786a6f21Smrg	func_append finalize_command " $arg"
4575786a6f21Smrg	prev=xcompiler
4576786a6f21Smrg	continue
4577786a6f21Smrg	;;
45781d54945dSmrg
4579786a6f21Smrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
4580786a6f21Smrg	compiler_flags="$compiler_flags $arg"
4581786a6f21Smrg	func_append compile_command " $arg"
4582786a6f21Smrg	func_append finalize_command " $arg"
4583786a6f21Smrg	case "$new_inherited_linker_flags " in
4584786a6f21Smrg	    *" $arg "*) ;;
4585786a6f21Smrg	    * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;;
4586786a6f21Smrg	esac
4587786a6f21Smrg	continue
4588786a6f21Smrg	;;
45891d54945dSmrg
4590786a6f21Smrg      -multi_module)
4591786a6f21Smrg	single_module="${wl}-multi_module"
4592786a6f21Smrg	continue
4593786a6f21Smrg	;;
45941d54945dSmrg
4595786a6f21Smrg      -no-fast-install)
4596786a6f21Smrg	fast_install=no
4597786a6f21Smrg	continue
4598786a6f21Smrg	;;
45991d54945dSmrg
4600786a6f21Smrg      -no-install)
4601786a6f21Smrg	case $host in
4602786a6f21Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
4603786a6f21Smrg	  # The PATH hackery in wrapper scripts is required on Windows
4604786a6f21Smrg	  # and Darwin in order for the loader to find any dlls it needs.
4605786a6f21Smrg	  func_warning "\`-no-install' is ignored for $host"
4606786a6f21Smrg	  func_warning "assuming \`-no-fast-install' instead"
4607786a6f21Smrg	  fast_install=no
4608786a6f21Smrg	  ;;
4609786a6f21Smrg	*) no_install=yes ;;
4610786a6f21Smrg	esac
4611786a6f21Smrg	continue
4612786a6f21Smrg	;;
46131d54945dSmrg
4614786a6f21Smrg      -no-undefined)
4615786a6f21Smrg	allow_undefined=no
4616786a6f21Smrg	continue
4617786a6f21Smrg	;;
46181d54945dSmrg
4619786a6f21Smrg      -objectlist)
4620786a6f21Smrg	prev=objectlist
4621786a6f21Smrg	continue
4622786a6f21Smrg	;;
46231d54945dSmrg
4624786a6f21Smrg      -o) prev=output ;;
46251d54945dSmrg
4626786a6f21Smrg      -precious-files-regex)
4627786a6f21Smrg	prev=precious_regex
4628786a6f21Smrg	continue
4629786a6f21Smrg	;;
46301d54945dSmrg
4631786a6f21Smrg      -release)
4632786a6f21Smrg	prev=release
4633786a6f21Smrg	continue
4634786a6f21Smrg	;;
46351d54945dSmrg
4636786a6f21Smrg      -rpath)
4637786a6f21Smrg	prev=rpath
4638786a6f21Smrg	continue
4639786a6f21Smrg	;;
46401d54945dSmrg
4641786a6f21Smrg      -R)
4642786a6f21Smrg	prev=xrpath
4643786a6f21Smrg	continue
4644786a6f21Smrg	;;
46451d54945dSmrg
4646786a6f21Smrg      -R*)
4647786a6f21Smrg	func_stripname '-R' '' "$arg"
4648786a6f21Smrg	dir=$func_stripname_result
4649786a6f21Smrg	# We need an absolute path.
4650786a6f21Smrg	case $dir in
4651786a6f21Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
4652786a6f21Smrg	*)
4653786a6f21Smrg	  func_fatal_error "only absolute run-paths are allowed"
4654786a6f21Smrg	  ;;
4655786a6f21Smrg	esac
4656786a6f21Smrg	case "$xrpath " in
4657786a6f21Smrg	*" $dir "*) ;;
4658786a6f21Smrg	*) xrpath="$xrpath $dir" ;;
4659786a6f21Smrg	esac
4660786a6f21Smrg	continue
4661786a6f21Smrg	;;
46621d54945dSmrg
4663786a6f21Smrg      -shared)
4664786a6f21Smrg	# The effects of -shared are defined in a previous loop.
4665786a6f21Smrg	continue
4666786a6f21Smrg	;;
46671d54945dSmrg
4668786a6f21Smrg      -shrext)
4669786a6f21Smrg	prev=shrext
4670786a6f21Smrg	continue
4671786a6f21Smrg	;;
46721d54945dSmrg
4673786a6f21Smrg      -static | -static-libtool-libs)
4674786a6f21Smrg	# The effects of -static are defined in a previous loop.
4675786a6f21Smrg	# We used to do the same as -all-static on platforms that
4676786a6f21Smrg	# didn't have a PIC flag, but the assumption that the effects
4677786a6f21Smrg	# would be equivalent was wrong.  It would break on at least
4678786a6f21Smrg	# Digital Unix and AIX.
4679786a6f21Smrg	continue
4680786a6f21Smrg	;;
46811d54945dSmrg
4682786a6f21Smrg      -thread-safe)
4683786a6f21Smrg	thread_safe=yes
4684786a6f21Smrg	continue
4685786a6f21Smrg	;;
46861d54945dSmrg
4687786a6f21Smrg      -version-info)
4688786a6f21Smrg	prev=vinfo
4689786a6f21Smrg	continue
4690786a6f21Smrg	;;
46911d54945dSmrg
4692786a6f21Smrg      -version-number)
4693786a6f21Smrg	prev=vinfo
4694786a6f21Smrg	vinfo_number=yes
4695786a6f21Smrg	continue
4696786a6f21Smrg	;;
46971d54945dSmrg
4698786a6f21Smrg      -weak)
4699786a6f21Smrg        prev=weak
4700786a6f21Smrg	continue
4701786a6f21Smrg	;;
47021d54945dSmrg
4703786a6f21Smrg      -Wc,*)
4704786a6f21Smrg	func_stripname '-Wc,' '' "$arg"
4705786a6f21Smrg	args=$func_stripname_result
4706786a6f21Smrg	arg=
4707786a6f21Smrg	save_ifs="$IFS"; IFS=','
4708786a6f21Smrg	for flag in $args; do
4709786a6f21Smrg	  IFS="$save_ifs"
4710786a6f21Smrg          func_quote_for_eval "$flag"
4711786a6f21Smrg	  arg="$arg $wl$func_quote_for_eval_result"
4712786a6f21Smrg	  compiler_flags="$compiler_flags $func_quote_for_eval_result"
4713786a6f21Smrg	done
4714786a6f21Smrg	IFS="$save_ifs"
4715786a6f21Smrg	func_stripname ' ' '' "$arg"
4716786a6f21Smrg	arg=$func_stripname_result
4717786a6f21Smrg	;;
47181d54945dSmrg
4719786a6f21Smrg      -Wl,*)
4720786a6f21Smrg	func_stripname '-Wl,' '' "$arg"
4721786a6f21Smrg	args=$func_stripname_result
4722786a6f21Smrg	arg=
4723786a6f21Smrg	save_ifs="$IFS"; IFS=','
4724786a6f21Smrg	for flag in $args; do
4725786a6f21Smrg	  IFS="$save_ifs"
4726786a6f21Smrg          func_quote_for_eval "$flag"
4727786a6f21Smrg	  arg="$arg $wl$func_quote_for_eval_result"
4728786a6f21Smrg	  compiler_flags="$compiler_flags $wl$func_quote_for_eval_result"
4729786a6f21Smrg	  linker_flags="$linker_flags $func_quote_for_eval_result"
4730786a6f21Smrg	done
4731786a6f21Smrg	IFS="$save_ifs"
4732786a6f21Smrg	func_stripname ' ' '' "$arg"
4733786a6f21Smrg	arg=$func_stripname_result
4734786a6f21Smrg	;;
47351d54945dSmrg
4736786a6f21Smrg      -Xcompiler)
4737786a6f21Smrg	prev=xcompiler
4738786a6f21Smrg	continue
4739786a6f21Smrg	;;
47401d54945dSmrg
4741786a6f21Smrg      -Xlinker)
4742786a6f21Smrg	prev=xlinker
4743786a6f21Smrg	continue
4744786a6f21Smrg	;;
4745ba85709eSmrg
4746786a6f21Smrg      -XCClinker)
4747786a6f21Smrg	prev=xcclinker
4748786a6f21Smrg	continue
4749786a6f21Smrg	;;
47501d54945dSmrg
4751786a6f21Smrg      # -msg_* for osf cc
4752786a6f21Smrg      -msg_*)
4753786a6f21Smrg	func_quote_for_eval "$arg"
4754786a6f21Smrg	arg="$func_quote_for_eval_result"
4755786a6f21Smrg	;;
47561d54945dSmrg
4757786a6f21Smrg      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
4758786a6f21Smrg      # -r[0-9][0-9]* specifies the processor on the SGI compiler
4759786a6f21Smrg      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
4760786a6f21Smrg      # +DA*, +DD* enable 64-bit mode on the HP compiler
4761786a6f21Smrg      # -q* pass through compiler args for the IBM compiler
4762786a6f21Smrg      # -m*, -t[45]*, -txscale* pass through architecture-specific
4763786a6f21Smrg      # compiler args for GCC
4764786a6f21Smrg      # -F/path gives path to uninstalled frameworks, gcc on darwin
4765786a6f21Smrg      # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
4766786a6f21Smrg      # @file GCC response files
4767786a6f21Smrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
4768786a6f21Smrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*)
4769786a6f21Smrg        func_quote_for_eval "$arg"
4770786a6f21Smrg	arg="$func_quote_for_eval_result"
4771786a6f21Smrg        func_append compile_command " $arg"
4772786a6f21Smrg        func_append finalize_command " $arg"
4773786a6f21Smrg        compiler_flags="$compiler_flags $arg"
4774786a6f21Smrg        continue
4775786a6f21Smrg        ;;
47761d54945dSmrg
4777786a6f21Smrg      # Some other compiler flag.
4778786a6f21Smrg      -* | +*)
4779786a6f21Smrg        func_quote_for_eval "$arg"
4780786a6f21Smrg	arg="$func_quote_for_eval_result"
4781786a6f21Smrg	;;
47821d54945dSmrg
4783786a6f21Smrg      *.$objext)
4784786a6f21Smrg	# A standard object.
4785786a6f21Smrg	objs="$objs $arg"
4786786a6f21Smrg	;;
47871d54945dSmrg
4788786a6f21Smrg      *.lo)
4789786a6f21Smrg	# A libtool-controlled object.
47901d54945dSmrg
4791786a6f21Smrg	# Check to see that this really is a libtool object.
4792786a6f21Smrg	if func_lalib_unsafe_p "$arg"; then
4793786a6f21Smrg	  pic_object=
4794786a6f21Smrg	  non_pic_object=
47951d54945dSmrg
4796786a6f21Smrg	  # Read the .lo file
4797786a6f21Smrg	  func_source "$arg"
47981d54945dSmrg
4799786a6f21Smrg	  if test -z "$pic_object" ||
4800786a6f21Smrg	     test -z "$non_pic_object" ||
4801786a6f21Smrg	     test "$pic_object" = none &&
4802786a6f21Smrg	     test "$non_pic_object" = none; then
4803786a6f21Smrg	    func_fatal_error "cannot find name of object for \`$arg'"
4804786a6f21Smrg	  fi
48051d54945dSmrg
4806786a6f21Smrg	  # Extract subdirectory from the argument.
4807786a6f21Smrg	  func_dirname "$arg" "/" ""
4808786a6f21Smrg	  xdir="$func_dirname_result"
48091d54945dSmrg
4810786a6f21Smrg	  if test "$pic_object" != none; then
4811786a6f21Smrg	    # Prepend the subdirectory the object is found in.
4812786a6f21Smrg	    pic_object="$xdir$pic_object"
48131d54945dSmrg
4814786a6f21Smrg	    if test "$prev" = dlfiles; then
4815786a6f21Smrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
4816786a6f21Smrg		dlfiles="$dlfiles $pic_object"
4817786a6f21Smrg		prev=
4818786a6f21Smrg		continue
4819786a6f21Smrg	      else
4820786a6f21Smrg		# If libtool objects are unsupported, then we need to preload.
4821786a6f21Smrg		prev=dlprefiles
4822786a6f21Smrg	      fi
4823786a6f21Smrg	    fi
4824786a6f21Smrg
4825786a6f21Smrg	    # CHECK ME:  I think I busted this.  -Ossama
4826786a6f21Smrg	    if test "$prev" = dlprefiles; then
4827786a6f21Smrg	      # Preload the old-style object.
4828786a6f21Smrg	      dlprefiles="$dlprefiles $pic_object"
4829786a6f21Smrg	      prev=
4830786a6f21Smrg	    fi
48311d54945dSmrg
4832786a6f21Smrg	    # A PIC object.
4833786a6f21Smrg	    func_append libobjs " $pic_object"
4834786a6f21Smrg	    arg="$pic_object"
4835786a6f21Smrg	  fi
48361d54945dSmrg
4837786a6f21Smrg	  # Non-PIC object.
4838786a6f21Smrg	  if test "$non_pic_object" != none; then
4839786a6f21Smrg	    # Prepend the subdirectory the object is found in.
4840786a6f21Smrg	    non_pic_object="$xdir$non_pic_object"
48411d54945dSmrg
4842786a6f21Smrg	    # A standard non-PIC object
4843786a6f21Smrg	    func_append non_pic_objects " $non_pic_object"
4844786a6f21Smrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
4845786a6f21Smrg	      arg="$non_pic_object"
4846786a6f21Smrg	    fi
4847786a6f21Smrg	  else
4848786a6f21Smrg	    # If the PIC object exists, use it instead.
4849786a6f21Smrg	    # $xdir was prepended to $pic_object above.
4850786a6f21Smrg	    non_pic_object="$pic_object"
4851786a6f21Smrg	    func_append non_pic_objects " $non_pic_object"
4852786a6f21Smrg	  fi
48531d54945dSmrg	else
4854786a6f21Smrg	  # Only an error if not doing a dry-run.
4855786a6f21Smrg	  if $opt_dry_run; then
4856786a6f21Smrg	    # Extract subdirectory from the argument.
4857786a6f21Smrg	    func_dirname "$arg" "/" ""
4858786a6f21Smrg	    xdir="$func_dirname_result"
4859786a6f21Smrg
4860786a6f21Smrg	    func_lo2o "$arg"
4861786a6f21Smrg	    pic_object=$xdir$objdir/$func_lo2o_result
4862786a6f21Smrg	    non_pic_object=$xdir$func_lo2o_result
4863786a6f21Smrg	    func_append libobjs " $pic_object"
4864786a6f21Smrg	    func_append non_pic_objects " $non_pic_object"
4865786a6f21Smrg	  else
4866786a6f21Smrg	    func_fatal_error "\`$arg' is not a valid libtool object"
4867786a6f21Smrg	  fi
48681d54945dSmrg	fi
4869786a6f21Smrg	;;
48701d54945dSmrg
4871786a6f21Smrg      *.$libext)
4872786a6f21Smrg	# An archive.
4873786a6f21Smrg	deplibs="$deplibs $arg"
4874786a6f21Smrg	old_deplibs="$old_deplibs $arg"
4875786a6f21Smrg	continue
4876786a6f21Smrg	;;
48771d54945dSmrg
4878786a6f21Smrg      *.la)
4879786a6f21Smrg	# A libtool-controlled library.
48801d54945dSmrg
4881786a6f21Smrg	if test "$prev" = dlfiles; then
4882786a6f21Smrg	  # This library was specified with -dlopen.
4883786a6f21Smrg	  dlfiles="$dlfiles $arg"
4884786a6f21Smrg	  prev=
4885786a6f21Smrg	elif test "$prev" = dlprefiles; then
4886786a6f21Smrg	  # The library was specified with -dlpreopen.
4887786a6f21Smrg	  dlprefiles="$dlprefiles $arg"
4888786a6f21Smrg	  prev=
4889786a6f21Smrg	else
4890786a6f21Smrg	  deplibs="$deplibs $arg"
4891786a6f21Smrg	fi
4892786a6f21Smrg	continue
4893786a6f21Smrg	;;
48941d54945dSmrg
4895786a6f21Smrg      # Some other compiler argument.
4896786a6f21Smrg      *)
4897786a6f21Smrg	# Unknown arguments in both finalize_command and compile_command need
4898786a6f21Smrg	# to be aesthetically quoted because they are evaled later.
4899786a6f21Smrg	func_quote_for_eval "$arg"
4900786a6f21Smrg	arg="$func_quote_for_eval_result"
4901786a6f21Smrg	;;
4902786a6f21Smrg      esac # arg
49031d54945dSmrg
4904786a6f21Smrg      # Now actually substitute the argument into the commands.
4905786a6f21Smrg      if test -n "$arg"; then
4906786a6f21Smrg	func_append compile_command " $arg"
4907786a6f21Smrg	func_append finalize_command " $arg"
4908786a6f21Smrg      fi
4909786a6f21Smrg    done # argument parsing loop
49101d54945dSmrg
4911786a6f21Smrg    test -n "$prev" && \
4912786a6f21Smrg      func_fatal_help "the \`$prevarg' option requires an argument"
4913786a6f21Smrg
4914786a6f21Smrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
4915786a6f21Smrg      eval arg=\"$export_dynamic_flag_spec\"
4916786a6f21Smrg      func_append compile_command " $arg"
4917786a6f21Smrg      func_append finalize_command " $arg"
4918786a6f21Smrg    fi
4919786a6f21Smrg
4920786a6f21Smrg    oldlibs=
4921786a6f21Smrg    # calculate the name of the file, without its directory
4922786a6f21Smrg    func_basename "$output"
4923786a6f21Smrg    outputname="$func_basename_result"
4924786a6f21Smrg    libobjs_save="$libobjs"
4925786a6f21Smrg
4926786a6f21Smrg    if test -n "$shlibpath_var"; then
4927786a6f21Smrg      # get the directories listed in $shlibpath_var
4928786a6f21Smrg      eval shlib_search_path=\`\$ECHO \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
4929786a6f21Smrg    else
4930786a6f21Smrg      shlib_search_path=
4931786a6f21Smrg    fi
4932786a6f21Smrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
4933786a6f21Smrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
4934786a6f21Smrg
4935786a6f21Smrg    func_dirname "$output" "/" ""
4936786a6f21Smrg    output_objdir="$func_dirname_result$objdir"
4937786a6f21Smrg    # Create the object directory.
4938786a6f21Smrg    func_mkdir_p "$output_objdir"
4939786a6f21Smrg
4940786a6f21Smrg    # Determine the type of output
4941786a6f21Smrg    case $output in
4942786a6f21Smrg    "")
4943786a6f21Smrg      func_fatal_help "you must specify an output file"
4944786a6f21Smrg      ;;
4945786a6f21Smrg    *.$libext) linkmode=oldlib ;;
4946786a6f21Smrg    *.lo | *.$objext) linkmode=obj ;;
4947786a6f21Smrg    *.la) linkmode=lib ;;
4948786a6f21Smrg    *) linkmode=prog ;; # Anything else should be a program.
4949786a6f21Smrg    esac
4950786a6f21Smrg
4951786a6f21Smrg    specialdeplibs=
4952786a6f21Smrg
4953786a6f21Smrg    libs=
4954786a6f21Smrg    # Find all interdependent deplibs by searching for libraries
4955786a6f21Smrg    # that are linked more than once (e.g. -la -lb -la)
4956786a6f21Smrg    for deplib in $deplibs; do
4957786a6f21Smrg      if $opt_duplicate_deps ; then
4958786a6f21Smrg	case "$libs " in
4959786a6f21Smrg	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
4960786a6f21Smrg	esac
4961786a6f21Smrg      fi
4962786a6f21Smrg      libs="$libs $deplib"
4963786a6f21Smrg    done
4964786a6f21Smrg
4965786a6f21Smrg    if test "$linkmode" = lib; then
4966786a6f21Smrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
4967786a6f21Smrg
4968786a6f21Smrg      # Compute libraries that are listed more than once in $predeps
4969786a6f21Smrg      # $postdeps and mark them as special (i.e., whose duplicates are
4970786a6f21Smrg      # not to be eliminated).
4971786a6f21Smrg      pre_post_deps=
4972786a6f21Smrg      if $opt_duplicate_compiler_generated_deps; then
4973786a6f21Smrg	for pre_post_dep in $predeps $postdeps; do
4974786a6f21Smrg	  case "$pre_post_deps " in
4975786a6f21Smrg	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
4976786a6f21Smrg	  esac
4977786a6f21Smrg	  pre_post_deps="$pre_post_deps $pre_post_dep"
4978786a6f21Smrg	done
4979786a6f21Smrg      fi
4980786a6f21Smrg      pre_post_deps=
4981786a6f21Smrg    fi
4982786a6f21Smrg
4983786a6f21Smrg    deplibs=
4984786a6f21Smrg    newdependency_libs=
4985786a6f21Smrg    newlib_search_path=
4986786a6f21Smrg    need_relink=no # whether we're linking any uninstalled libtool libraries
4987786a6f21Smrg    notinst_deplibs= # not-installed libtool libraries
4988786a6f21Smrg    notinst_path= # paths that contain not-installed libtool libraries
4989786a6f21Smrg
4990786a6f21Smrg    case $linkmode in
4991786a6f21Smrg    lib)
4992786a6f21Smrg	passes="conv dlpreopen link"
4993786a6f21Smrg	for file in $dlfiles $dlprefiles; do
4994786a6f21Smrg	  case $file in
4995786a6f21Smrg	  *.la) ;;
4996786a6f21Smrg	  *)
4997786a6f21Smrg	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
4998786a6f21Smrg	    ;;
4999786a6f21Smrg	  esac
5000786a6f21Smrg	done
5001786a6f21Smrg	;;
5002786a6f21Smrg    prog)
5003786a6f21Smrg	compile_deplibs=
5004786a6f21Smrg	finalize_deplibs=
5005786a6f21Smrg	alldeplibs=no
5006786a6f21Smrg	newdlfiles=
5007786a6f21Smrg	newdlprefiles=
5008786a6f21Smrg	passes="conv scan dlopen dlpreopen link"
5009786a6f21Smrg	;;
5010786a6f21Smrg    *)  passes="conv"
5011786a6f21Smrg	;;
5012786a6f21Smrg    esac
5013786a6f21Smrg
5014786a6f21Smrg    for pass in $passes; do
5015786a6f21Smrg      # The preopen pass in lib mode reverses $deplibs; put it back here
5016786a6f21Smrg      # so that -L comes before libs that need it for instance...
5017786a6f21Smrg      if test "$linkmode,$pass" = "lib,link"; then
5018786a6f21Smrg	## FIXME: Find the place where the list is rebuilt in the wrong
5019786a6f21Smrg	##        order, and fix it there properly
5020786a6f21Smrg        tmp_deplibs=
5021786a6f21Smrg	for deplib in $deplibs; do
5022786a6f21Smrg	  tmp_deplibs="$deplib $tmp_deplibs"
5023786a6f21Smrg	done
5024786a6f21Smrg	deplibs="$tmp_deplibs"
5025786a6f21Smrg      fi
5026786a6f21Smrg
5027786a6f21Smrg      if test "$linkmode,$pass" = "lib,link" ||
5028786a6f21Smrg	 test "$linkmode,$pass" = "prog,scan"; then
5029786a6f21Smrg	libs="$deplibs"
5030786a6f21Smrg	deplibs=
5031786a6f21Smrg      fi
5032786a6f21Smrg      if test "$linkmode" = prog; then
5033786a6f21Smrg	case $pass in
5034786a6f21Smrg	dlopen) libs="$dlfiles" ;;
5035786a6f21Smrg	dlpreopen) libs="$dlprefiles" ;;
5036786a6f21Smrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
5037786a6f21Smrg	esac
5038786a6f21Smrg      fi
5039786a6f21Smrg      if test "$linkmode,$pass" = "lib,dlpreopen"; then
5040786a6f21Smrg	# Collect and forward deplibs of preopened libtool libs
5041786a6f21Smrg	for lib in $dlprefiles; do
5042786a6f21Smrg	  # Ignore non-libtool-libs
5043786a6f21Smrg	  dependency_libs=
5044786a6f21Smrg	  case $lib in
5045786a6f21Smrg	  *.la)	func_source "$lib" ;;
5046786a6f21Smrg	  esac
5047786a6f21Smrg
5048786a6f21Smrg	  # Collect preopened libtool deplibs, except any this library
5049786a6f21Smrg	  # has declared as weak libs
5050786a6f21Smrg	  for deplib in $dependency_libs; do
5051786a6f21Smrg            deplib_base=`$ECHO "X$deplib" | $Xsed -e "$basename"`
5052786a6f21Smrg	    case " $weak_libs " in
5053786a6f21Smrg	    *" $deplib_base "*) ;;
5054786a6f21Smrg	    *) deplibs="$deplibs $deplib" ;;
5055786a6f21Smrg	    esac
5056786a6f21Smrg	  done
5057786a6f21Smrg	done
5058786a6f21Smrg	libs="$dlprefiles"
5059786a6f21Smrg      fi
5060786a6f21Smrg      if test "$pass" = dlopen; then
5061786a6f21Smrg	# Collect dlpreopened libraries
5062786a6f21Smrg	save_deplibs="$deplibs"
5063786a6f21Smrg	deplibs=
5064786a6f21Smrg      fi
5065786a6f21Smrg
5066786a6f21Smrg      for deplib in $libs; do
5067786a6f21Smrg	lib=
5068786a6f21Smrg	found=no
5069786a6f21Smrg	case $deplib in
5070786a6f21Smrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
5071786a6f21Smrg	  if test "$linkmode,$pass" = "prog,link"; then
5072786a6f21Smrg	    compile_deplibs="$deplib $compile_deplibs"
5073786a6f21Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
5074786a6f21Smrg	  else
5075786a6f21Smrg	    compiler_flags="$compiler_flags $deplib"
5076786a6f21Smrg	    if test "$linkmode" = lib ; then
5077786a6f21Smrg		case "$new_inherited_linker_flags " in
5078786a6f21Smrg		    *" $deplib "*) ;;
5079786a6f21Smrg		    * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
5080786a6f21Smrg		esac
5081786a6f21Smrg	    fi
5082786a6f21Smrg	  fi
5083786a6f21Smrg	  continue
5084786a6f21Smrg	  ;;
5085786a6f21Smrg	-l*)
5086786a6f21Smrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
5087786a6f21Smrg	    func_warning "\`-l' is ignored for archives/objects"
5088786a6f21Smrg	    continue
5089786a6f21Smrg	  fi
5090786a6f21Smrg	  func_stripname '-l' '' "$deplib"
5091786a6f21Smrg	  name=$func_stripname_result
5092786a6f21Smrg	  if test "$linkmode" = lib; then
5093786a6f21Smrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
5094786a6f21Smrg	  else
5095786a6f21Smrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
5096786a6f21Smrg	  fi
5097786a6f21Smrg	  for searchdir in $searchdirs; do
5098786a6f21Smrg	    for search_ext in .la $std_shrext .so .a; do
5099786a6f21Smrg	      # Search the libtool library
5100786a6f21Smrg	      lib="$searchdir/lib${name}${search_ext}"
5101786a6f21Smrg	      if test -f "$lib"; then
5102786a6f21Smrg		if test "$search_ext" = ".la"; then
5103786a6f21Smrg		  found=yes
5104786a6f21Smrg		else
5105786a6f21Smrg		  found=no
5106786a6f21Smrg		fi
5107786a6f21Smrg		break 2
5108786a6f21Smrg	      fi
5109786a6f21Smrg	    done
5110786a6f21Smrg	  done
5111786a6f21Smrg	  if test "$found" != yes; then
5112786a6f21Smrg	    # deplib doesn't seem to be a libtool library
5113786a6f21Smrg	    if test "$linkmode,$pass" = "prog,link"; then
5114786a6f21Smrg	      compile_deplibs="$deplib $compile_deplibs"
5115786a6f21Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
5116786a6f21Smrg	    else
5117786a6f21Smrg	      deplibs="$deplib $deplibs"
5118786a6f21Smrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
5119786a6f21Smrg	    fi
5120786a6f21Smrg	    continue
5121786a6f21Smrg	  else # deplib is a libtool library
5122786a6f21Smrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
5123786a6f21Smrg	    # We need to do some special things here, and not later.
5124786a6f21Smrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
5125786a6f21Smrg	      case " $predeps $postdeps " in
5126786a6f21Smrg	      *" $deplib "*)
5127786a6f21Smrg		if func_lalib_p "$lib"; then
5128786a6f21Smrg		  library_names=
5129786a6f21Smrg		  old_library=
5130786a6f21Smrg		  func_source "$lib"
5131786a6f21Smrg		  for l in $old_library $library_names; do
5132786a6f21Smrg		    ll="$l"
5133786a6f21Smrg		  done
5134786a6f21Smrg		  if test "X$ll" = "X$old_library" ; then # only static version available
5135786a6f21Smrg		    found=no
5136786a6f21Smrg		    func_dirname "$lib" "" "."
5137786a6f21Smrg		    ladir="$func_dirname_result"
5138786a6f21Smrg		    lib=$ladir/$old_library
5139786a6f21Smrg		    if test "$linkmode,$pass" = "prog,link"; then
5140786a6f21Smrg		      compile_deplibs="$deplib $compile_deplibs"
5141786a6f21Smrg		      finalize_deplibs="$deplib $finalize_deplibs"
5142786a6f21Smrg		    else
5143786a6f21Smrg		      deplibs="$deplib $deplibs"
5144786a6f21Smrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
5145786a6f21Smrg		    fi
5146786a6f21Smrg		    continue
5147786a6f21Smrg		  fi
5148786a6f21Smrg		fi
5149786a6f21Smrg		;;
5150786a6f21Smrg	      *) ;;
5151786a6f21Smrg	      esac
5152786a6f21Smrg	    fi
5153786a6f21Smrg	  fi
5154786a6f21Smrg	  ;; # -l
5155786a6f21Smrg	*.ltframework)
5156786a6f21Smrg	  if test "$linkmode,$pass" = "prog,link"; then
5157786a6f21Smrg	    compile_deplibs="$deplib $compile_deplibs"
5158786a6f21Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
5159786a6f21Smrg	  else
5160786a6f21Smrg	    deplibs="$deplib $deplibs"
5161786a6f21Smrg	    if test "$linkmode" = lib ; then
5162786a6f21Smrg		case "$new_inherited_linker_flags " in
5163786a6f21Smrg		    *" $deplib "*) ;;
5164786a6f21Smrg		    * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
5165786a6f21Smrg		esac
5166786a6f21Smrg	    fi
5167786a6f21Smrg	  fi
5168786a6f21Smrg	  continue
5169786a6f21Smrg	  ;;
5170786a6f21Smrg	-L*)
5171786a6f21Smrg	  case $linkmode in
5172786a6f21Smrg	  lib)
5173786a6f21Smrg	    deplibs="$deplib $deplibs"
5174786a6f21Smrg	    test "$pass" = conv && continue
5175786a6f21Smrg	    newdependency_libs="$deplib $newdependency_libs"
5176786a6f21Smrg	    func_stripname '-L' '' "$deplib"
5177786a6f21Smrg	    newlib_search_path="$newlib_search_path $func_stripname_result"
5178786a6f21Smrg	    ;;
5179786a6f21Smrg	  prog)
5180786a6f21Smrg	    if test "$pass" = conv; then
5181786a6f21Smrg	      deplibs="$deplib $deplibs"
5182786a6f21Smrg	      continue
5183786a6f21Smrg	    fi
5184786a6f21Smrg	    if test "$pass" = scan; then
5185786a6f21Smrg	      deplibs="$deplib $deplibs"
5186786a6f21Smrg	    else
5187786a6f21Smrg	      compile_deplibs="$deplib $compile_deplibs"
5188786a6f21Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
5189786a6f21Smrg	    fi
5190786a6f21Smrg	    func_stripname '-L' '' "$deplib"
5191786a6f21Smrg	    newlib_search_path="$newlib_search_path $func_stripname_result"
5192786a6f21Smrg	    ;;
5193786a6f21Smrg	  *)
5194786a6f21Smrg	    func_warning "\`-L' is ignored for archives/objects"
5195786a6f21Smrg	    ;;
5196786a6f21Smrg	  esac # linkmode
5197786a6f21Smrg	  continue
5198786a6f21Smrg	  ;; # -L
5199786a6f21Smrg	-R*)
5200786a6f21Smrg	  if test "$pass" = link; then
5201786a6f21Smrg	    func_stripname '-R' '' "$deplib"
5202786a6f21Smrg	    dir=$func_stripname_result
5203786a6f21Smrg	    # Make sure the xrpath contains only unique directories.
5204786a6f21Smrg	    case "$xrpath " in
5205786a6f21Smrg	    *" $dir "*) ;;
5206786a6f21Smrg	    *) xrpath="$xrpath $dir" ;;
5207786a6f21Smrg	    esac
5208786a6f21Smrg	  fi
5209786a6f21Smrg	  deplibs="$deplib $deplibs"
5210786a6f21Smrg	  continue
5211786a6f21Smrg	  ;;
5212786a6f21Smrg	*.la) lib="$deplib" ;;
5213786a6f21Smrg	*.$libext)
5214786a6f21Smrg	  if test "$pass" = conv; then
5215786a6f21Smrg	    deplibs="$deplib $deplibs"
5216786a6f21Smrg	    continue
5217786a6f21Smrg	  fi
5218786a6f21Smrg	  case $linkmode in
5219786a6f21Smrg	  lib)
5220786a6f21Smrg	    # Linking convenience modules into shared libraries is allowed,
5221786a6f21Smrg	    # but linking other static libraries is non-portable.
5222786a6f21Smrg	    case " $dlpreconveniencelibs " in
5223786a6f21Smrg	    *" $deplib "*) ;;
5224786a6f21Smrg	    *)
5225786a6f21Smrg	      valid_a_lib=no
5226786a6f21Smrg	      case $deplibs_check_method in
5227786a6f21Smrg		match_pattern*)
5228786a6f21Smrg		  set dummy $deplibs_check_method; shift
5229786a6f21Smrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
5230786a6f21Smrg		  if eval "\$ECHO \"X$deplib\"" 2>/dev/null | $Xsed -e 10q \
5231786a6f21Smrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
5232786a6f21Smrg		    valid_a_lib=yes
5233786a6f21Smrg		  fi
5234786a6f21Smrg		;;
5235786a6f21Smrg		pass_all)
5236786a6f21Smrg		  valid_a_lib=yes
5237786a6f21Smrg		;;
5238786a6f21Smrg	      esac
5239786a6f21Smrg	      if test "$valid_a_lib" != yes; then
5240786a6f21Smrg		$ECHO
5241786a6f21Smrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
5242786a6f21Smrg		$ECHO "*** I have the capability to make that library automatically link in when"
5243786a6f21Smrg		$ECHO "*** you link to this library.  But I can only do this if you have a"
5244786a6f21Smrg		$ECHO "*** shared version of the library, which you do not appear to have"
5245786a6f21Smrg		$ECHO "*** because the file extensions .$libext of this argument makes me believe"
5246786a6f21Smrg		$ECHO "*** that it is just a static archive that I should not use here."
5247786a6f21Smrg	      else
5248786a6f21Smrg		$ECHO
5249786a6f21Smrg		$ECHO "*** Warning: Linking the shared library $output against the"
5250786a6f21Smrg		$ECHO "*** static library $deplib is not portable!"
5251786a6f21Smrg		deplibs="$deplib $deplibs"
5252786a6f21Smrg	      fi
5253786a6f21Smrg	      ;;
5254786a6f21Smrg	    esac
5255786a6f21Smrg	    continue
5256786a6f21Smrg	    ;;
5257786a6f21Smrg	  prog)
5258786a6f21Smrg	    if test "$pass" != link; then
5259786a6f21Smrg	      deplibs="$deplib $deplibs"
5260786a6f21Smrg	    else
5261786a6f21Smrg	      compile_deplibs="$deplib $compile_deplibs"
5262786a6f21Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
5263786a6f21Smrg	    fi
5264786a6f21Smrg	    continue
5265786a6f21Smrg	    ;;
5266786a6f21Smrg	  esac # linkmode
5267786a6f21Smrg	  ;; # *.$libext
5268786a6f21Smrg	*.lo | *.$objext)
5269786a6f21Smrg	  if test "$pass" = conv; then
5270786a6f21Smrg	    deplibs="$deplib $deplibs"
5271786a6f21Smrg	  elif test "$linkmode" = prog; then
5272786a6f21Smrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
5273786a6f21Smrg	      # If there is no dlopen support or we're linking statically,
5274786a6f21Smrg	      # we need to preload.
5275786a6f21Smrg	      newdlprefiles="$newdlprefiles $deplib"
5276786a6f21Smrg	      compile_deplibs="$deplib $compile_deplibs"
5277786a6f21Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
5278786a6f21Smrg	    else
5279786a6f21Smrg	      newdlfiles="$newdlfiles $deplib"
5280786a6f21Smrg	    fi
5281786a6f21Smrg	  fi
5282786a6f21Smrg	  continue
5283786a6f21Smrg	  ;;
5284786a6f21Smrg	%DEPLIBS%)
5285786a6f21Smrg	  alldeplibs=yes
5286786a6f21Smrg	  continue
5287786a6f21Smrg	  ;;
5288786a6f21Smrg	esac # case $deplib
5289786a6f21Smrg
5290786a6f21Smrg	if test "$found" = yes || test -f "$lib"; then :
5291786a6f21Smrg	else
5292786a6f21Smrg	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
5293786a6f21Smrg	fi
5294786a6f21Smrg
5295786a6f21Smrg	# Check to see that this really is a libtool archive.
5296786a6f21Smrg	func_lalib_unsafe_p "$lib" \
5297786a6f21Smrg	  || func_fatal_error "\`$lib' is not a valid libtool archive"
5298786a6f21Smrg
5299786a6f21Smrg	func_dirname "$lib" "" "."
5300786a6f21Smrg	ladir="$func_dirname_result"
5301786a6f21Smrg
5302786a6f21Smrg	dlname=
5303786a6f21Smrg	dlopen=
5304786a6f21Smrg	dlpreopen=
5305786a6f21Smrg	libdir=
5306786a6f21Smrg	library_names=
5307786a6f21Smrg	old_library=
5308786a6f21Smrg	inherited_linker_flags=
5309786a6f21Smrg	# If the library was installed with an old release of libtool,
5310786a6f21Smrg	# it will not redefine variables installed, or shouldnotlink
5311786a6f21Smrg	installed=yes
5312786a6f21Smrg	shouldnotlink=no
5313786a6f21Smrg	avoidtemprpath=
5314786a6f21Smrg
5315786a6f21Smrg
5316786a6f21Smrg	# Read the .la file
5317786a6f21Smrg	func_source "$lib"
5318786a6f21Smrg
5319786a6f21Smrg	# Convert "-framework foo" to "foo.ltframework"
5320786a6f21Smrg	if test -n "$inherited_linker_flags"; then
5321786a6f21Smrg	  tmp_inherited_linker_flags=`$ECHO "X$inherited_linker_flags" | $Xsed -e 's/-framework \([^ $]*\)/\1.ltframework/g'`
5322786a6f21Smrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
5323786a6f21Smrg	    case " $new_inherited_linker_flags " in
5324786a6f21Smrg	      *" $tmp_inherited_linker_flag "*) ;;
5325786a6f21Smrg	      *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";;
5326786a6f21Smrg	    esac
5327786a6f21Smrg	  done
5328786a6f21Smrg	fi
5329786a6f21Smrg	dependency_libs=`$ECHO "X $dependency_libs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
5330786a6f21Smrg	if test "$linkmode,$pass" = "lib,link" ||
5331786a6f21Smrg	   test "$linkmode,$pass" = "prog,scan" ||
5332786a6f21Smrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
5333786a6f21Smrg	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
5334786a6f21Smrg	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
5335786a6f21Smrg	fi
5336786a6f21Smrg
5337786a6f21Smrg	if test "$pass" = conv; then
5338786a6f21Smrg	  # Only check for convenience libraries
5339786a6f21Smrg	  deplibs="$lib $deplibs"
5340786a6f21Smrg	  if test -z "$libdir"; then
5341786a6f21Smrg	    if test -z "$old_library"; then
5342786a6f21Smrg	      func_fatal_error "cannot find name of link library for \`$lib'"
5343786a6f21Smrg	    fi
5344786a6f21Smrg	    # It is a libtool convenience library, so add in its objects.
5345786a6f21Smrg	    convenience="$convenience $ladir/$objdir/$old_library"
5346786a6f21Smrg	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
5347786a6f21Smrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
5348786a6f21Smrg	    func_fatal_error "\`$lib' is not a convenience library"
5349786a6f21Smrg	  fi
5350786a6f21Smrg	  tmp_libs=
5351786a6f21Smrg	  for deplib in $dependency_libs; do
5352786a6f21Smrg	    deplibs="$deplib $deplibs"
5353786a6f21Smrg	    if $opt_duplicate_deps ; then
5354786a6f21Smrg	      case "$tmp_libs " in
5355786a6f21Smrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
5356786a6f21Smrg	      esac
5357786a6f21Smrg	    fi
5358786a6f21Smrg	    tmp_libs="$tmp_libs $deplib"
5359786a6f21Smrg	  done
5360786a6f21Smrg	  continue
5361786a6f21Smrg	fi # $pass = conv
5362786a6f21Smrg
5363786a6f21Smrg
5364786a6f21Smrg	# Get the name of the library we link against.
5365786a6f21Smrg	linklib=
5366786a6f21Smrg	for l in $old_library $library_names; do
5367786a6f21Smrg	  linklib="$l"
5368786a6f21Smrg	done
5369786a6f21Smrg	if test -z "$linklib"; then
5370786a6f21Smrg	  func_fatal_error "cannot find name of link library for \`$lib'"
5371786a6f21Smrg	fi
5372786a6f21Smrg
5373786a6f21Smrg	# This library was specified with -dlopen.
5374786a6f21Smrg	if test "$pass" = dlopen; then
5375786a6f21Smrg	  if test -z "$libdir"; then
5376786a6f21Smrg	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
5377786a6f21Smrg	  fi
5378786a6f21Smrg	  if test -z "$dlname" ||
5379786a6f21Smrg	     test "$dlopen_support" != yes ||
5380786a6f21Smrg	     test "$build_libtool_libs" = no; then
5381786a6f21Smrg	    # If there is no dlname, no dlopen support or we're linking
5382786a6f21Smrg	    # statically, we need to preload.  We also need to preload any
5383786a6f21Smrg	    # dependent libraries so libltdl's deplib preloader doesn't
5384786a6f21Smrg	    # bomb out in the load deplibs phase.
5385786a6f21Smrg	    dlprefiles="$dlprefiles $lib $dependency_libs"
5386786a6f21Smrg	  else
5387786a6f21Smrg	    newdlfiles="$newdlfiles $lib"
5388786a6f21Smrg	  fi
5389786a6f21Smrg	  continue
5390786a6f21Smrg	fi # $pass = dlopen
5391786a6f21Smrg
5392786a6f21Smrg	# We need an absolute path.
5393786a6f21Smrg	case $ladir in
5394786a6f21Smrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
5395786a6f21Smrg	*)
5396786a6f21Smrg	  abs_ladir=`cd "$ladir" && pwd`
5397786a6f21Smrg	  if test -z "$abs_ladir"; then
5398786a6f21Smrg	    func_warning "cannot determine absolute directory name of \`$ladir'"
5399786a6f21Smrg	    func_warning "passing it literally to the linker, although it might fail"
5400786a6f21Smrg	    abs_ladir="$ladir"
5401786a6f21Smrg	  fi
5402786a6f21Smrg	  ;;
5403786a6f21Smrg	esac
5404786a6f21Smrg	func_basename "$lib"
5405786a6f21Smrg	laname="$func_basename_result"
5406786a6f21Smrg
5407786a6f21Smrg	# Find the relevant object directory and library name.
5408786a6f21Smrg	if test "X$installed" = Xyes; then
5409786a6f21Smrg	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
5410786a6f21Smrg	    func_warning "library \`$lib' was moved."
5411786a6f21Smrg	    dir="$ladir"
5412786a6f21Smrg	    absdir="$abs_ladir"
5413786a6f21Smrg	    libdir="$abs_ladir"
5414786a6f21Smrg	  else
5415786a6f21Smrg	    dir="$libdir"
5416786a6f21Smrg	    absdir="$libdir"
5417786a6f21Smrg	  fi
5418786a6f21Smrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
5419786a6f21Smrg	else
5420786a6f21Smrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
5421786a6f21Smrg	    dir="$ladir"
5422786a6f21Smrg	    absdir="$abs_ladir"
5423786a6f21Smrg	    # Remove this search path later
5424786a6f21Smrg	    notinst_path="$notinst_path $abs_ladir"
5425786a6f21Smrg	  else
5426786a6f21Smrg	    dir="$ladir/$objdir"
5427786a6f21Smrg	    absdir="$abs_ladir/$objdir"
5428786a6f21Smrg	    # Remove this search path later
5429786a6f21Smrg	    notinst_path="$notinst_path $abs_ladir"
5430786a6f21Smrg	  fi
5431786a6f21Smrg	fi # $installed = yes
5432786a6f21Smrg	func_stripname 'lib' '.la' "$laname"
5433786a6f21Smrg	name=$func_stripname_result
5434786a6f21Smrg
5435786a6f21Smrg	# This library was specified with -dlpreopen.
5436786a6f21Smrg	if test "$pass" = dlpreopen; then
5437786a6f21Smrg	  if test -z "$libdir" && test "$linkmode" = prog; then
5438786a6f21Smrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
5439786a6f21Smrg	  fi
5440786a6f21Smrg	  # Prefer using a static library (so that no silly _DYNAMIC symbols
5441786a6f21Smrg	  # are required to link).
5442786a6f21Smrg	  if test -n "$old_library"; then
5443786a6f21Smrg	    newdlprefiles="$newdlprefiles $dir/$old_library"
5444786a6f21Smrg	    # Keep a list of preopened convenience libraries to check
5445786a6f21Smrg	    # that they are being used correctly in the link pass.
5446786a6f21Smrg	    test -z "$libdir" && \
5447786a6f21Smrg		dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library"
5448786a6f21Smrg	  # Otherwise, use the dlname, so that lt_dlopen finds it.
5449786a6f21Smrg	  elif test -n "$dlname"; then
5450786a6f21Smrg	    newdlprefiles="$newdlprefiles $dir/$dlname"
5451786a6f21Smrg	  else
5452786a6f21Smrg	    newdlprefiles="$newdlprefiles $dir/$linklib"
5453786a6f21Smrg	  fi
5454786a6f21Smrg	fi # $pass = dlpreopen
5455786a6f21Smrg
5456786a6f21Smrg	if test -z "$libdir"; then
5457786a6f21Smrg	  # Link the convenience library
5458786a6f21Smrg	  if test "$linkmode" = lib; then
5459786a6f21Smrg	    deplibs="$dir/$old_library $deplibs"
5460786a6f21Smrg	  elif test "$linkmode,$pass" = "prog,link"; then
5461786a6f21Smrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
5462786a6f21Smrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
5463786a6f21Smrg	  else
5464786a6f21Smrg	    deplibs="$lib $deplibs" # used for prog,scan pass
5465786a6f21Smrg	  fi
5466786a6f21Smrg	  continue
5467786a6f21Smrg	fi
5468786a6f21Smrg
5469786a6f21Smrg
5470786a6f21Smrg	if test "$linkmode" = prog && test "$pass" != link; then
5471786a6f21Smrg	  newlib_search_path="$newlib_search_path $ladir"
5472786a6f21Smrg	  deplibs="$lib $deplibs"
5473786a6f21Smrg
5474786a6f21Smrg	  linkalldeplibs=no
5475786a6f21Smrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
5476786a6f21Smrg	     test "$build_libtool_libs" = no; then
5477786a6f21Smrg	    linkalldeplibs=yes
5478786a6f21Smrg	  fi
5479786a6f21Smrg
5480786a6f21Smrg	  tmp_libs=
5481786a6f21Smrg	  for deplib in $dependency_libs; do
5482786a6f21Smrg	    case $deplib in
5483786a6f21Smrg	    -L*) func_stripname '-L' '' "$deplib"
5484786a6f21Smrg	         newlib_search_path="$newlib_search_path $func_stripname_result"
5485786a6f21Smrg		 ;;
5486786a6f21Smrg	    esac
5487786a6f21Smrg	    # Need to link against all dependency_libs?
5488786a6f21Smrg	    if test "$linkalldeplibs" = yes; then
5489786a6f21Smrg	      deplibs="$deplib $deplibs"
5490786a6f21Smrg	    else
5491786a6f21Smrg	      # Need to hardcode shared library paths
5492786a6f21Smrg	      # or/and link against static libraries
5493786a6f21Smrg	      newdependency_libs="$deplib $newdependency_libs"
5494786a6f21Smrg	    fi
5495786a6f21Smrg	    if $opt_duplicate_deps ; then
5496786a6f21Smrg	      case "$tmp_libs " in
5497786a6f21Smrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
5498786a6f21Smrg	      esac
5499786a6f21Smrg	    fi
5500786a6f21Smrg	    tmp_libs="$tmp_libs $deplib"
5501786a6f21Smrg	  done # for deplib
5502786a6f21Smrg	  continue
5503786a6f21Smrg	fi # $linkmode = prog...
5504786a6f21Smrg
5505786a6f21Smrg	if test "$linkmode,$pass" = "prog,link"; then
5506786a6f21Smrg	  if test -n "$library_names" &&
5507786a6f21Smrg	     { { test "$prefer_static_libs" = no ||
5508786a6f21Smrg	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
5509786a6f21Smrg	       test -z "$old_library"; }; then
5510786a6f21Smrg	    # We need to hardcode the library path
5511786a6f21Smrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
5512786a6f21Smrg	      # Make sure the rpath contains only unique directories.
5513786a6f21Smrg	      case "$temp_rpath:" in
5514786a6f21Smrg	      *"$absdir:"*) ;;
5515786a6f21Smrg	      *) temp_rpath="$temp_rpath$absdir:" ;;
5516786a6f21Smrg	      esac
5517786a6f21Smrg	    fi
5518786a6f21Smrg
5519786a6f21Smrg	    # Hardcode the library path.
5520786a6f21Smrg	    # Skip directories that are in the system default run-time
5521786a6f21Smrg	    # search path.
5522786a6f21Smrg	    case " $sys_lib_dlsearch_path " in
5523786a6f21Smrg	    *" $absdir "*) ;;
5524786a6f21Smrg	    *)
5525786a6f21Smrg	      case "$compile_rpath " in
5526786a6f21Smrg	      *" $absdir "*) ;;
5527786a6f21Smrg	      *) compile_rpath="$compile_rpath $absdir"
5528786a6f21Smrg	      esac
5529786a6f21Smrg	      ;;
5530786a6f21Smrg	    esac
5531786a6f21Smrg	    case " $sys_lib_dlsearch_path " in
5532786a6f21Smrg	    *" $libdir "*) ;;
5533786a6f21Smrg	    *)
5534786a6f21Smrg	      case "$finalize_rpath " in
5535786a6f21Smrg	      *" $libdir "*) ;;
5536786a6f21Smrg	      *) finalize_rpath="$finalize_rpath $libdir"
5537786a6f21Smrg	      esac
5538786a6f21Smrg	      ;;
5539786a6f21Smrg	    esac
5540786a6f21Smrg	  fi # $linkmode,$pass = prog,link...
5541786a6f21Smrg
5542786a6f21Smrg	  if test "$alldeplibs" = yes &&
5543786a6f21Smrg	     { test "$deplibs_check_method" = pass_all ||
5544786a6f21Smrg	       { test "$build_libtool_libs" = yes &&
5545786a6f21Smrg		 test -n "$library_names"; }; }; then
5546786a6f21Smrg	    # We only need to search for static libraries
5547786a6f21Smrg	    continue
5548786a6f21Smrg	  fi
5549786a6f21Smrg	fi
5550786a6f21Smrg
5551786a6f21Smrg	link_static=no # Whether the deplib will be linked statically
5552786a6f21Smrg	use_static_libs=$prefer_static_libs
5553786a6f21Smrg	if test "$use_static_libs" = built && test "$installed" = yes; then
5554786a6f21Smrg	  use_static_libs=no
5555786a6f21Smrg	fi
5556786a6f21Smrg	if test -n "$library_names" &&
5557786a6f21Smrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
5558786a6f21Smrg	  case $host in
5559786a6f21Smrg	  *cygwin* | *mingw* | *cegcc*)
5560786a6f21Smrg	      # No point in relinking DLLs because paths are not encoded
5561786a6f21Smrg	      notinst_deplibs="$notinst_deplibs $lib"
5562786a6f21Smrg	      need_relink=no
5563786a6f21Smrg	    ;;
5564786a6f21Smrg	  *)
5565786a6f21Smrg	    if test "$installed" = no; then
5566786a6f21Smrg	      notinst_deplibs="$notinst_deplibs $lib"
5567786a6f21Smrg	      need_relink=yes
5568786a6f21Smrg	    fi
5569786a6f21Smrg	    ;;
5570786a6f21Smrg	  esac
5571786a6f21Smrg	  # This is a shared library
5572786a6f21Smrg
5573786a6f21Smrg	  # Warn about portability, can't link against -module's on some
5574786a6f21Smrg	  # systems (darwin).  Don't bleat about dlopened modules though!
5575786a6f21Smrg	  dlopenmodule=""
5576786a6f21Smrg	  for dlpremoduletest in $dlprefiles; do
5577786a6f21Smrg	    if test "X$dlpremoduletest" = "X$lib"; then
5578786a6f21Smrg	      dlopenmodule="$dlpremoduletest"
5579786a6f21Smrg	      break
5580786a6f21Smrg	    fi
5581786a6f21Smrg	  done
5582786a6f21Smrg	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
5583786a6f21Smrg	    $ECHO
5584786a6f21Smrg	    if test "$linkmode" = prog; then
5585786a6f21Smrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
5586786a6f21Smrg	    else
5587786a6f21Smrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
5588786a6f21Smrg	    fi
5589786a6f21Smrg	    $ECHO "*** $linklib is not portable!"
5590786a6f21Smrg	  fi
5591786a6f21Smrg	  if test "$linkmode" = lib &&
5592786a6f21Smrg	     test "$hardcode_into_libs" = yes; then
5593786a6f21Smrg	    # Hardcode the library path.
5594786a6f21Smrg	    # Skip directories that are in the system default run-time
5595786a6f21Smrg	    # search path.
5596786a6f21Smrg	    case " $sys_lib_dlsearch_path " in
5597786a6f21Smrg	    *" $absdir "*) ;;
5598786a6f21Smrg	    *)
5599786a6f21Smrg	      case "$compile_rpath " in
5600786a6f21Smrg	      *" $absdir "*) ;;
5601786a6f21Smrg	      *) compile_rpath="$compile_rpath $absdir"
5602786a6f21Smrg	      esac
5603786a6f21Smrg	      ;;
5604786a6f21Smrg	    esac
5605786a6f21Smrg	    case " $sys_lib_dlsearch_path " in
5606786a6f21Smrg	    *" $libdir "*) ;;
5607786a6f21Smrg	    *)
5608786a6f21Smrg	      case "$finalize_rpath " in
5609786a6f21Smrg	      *" $libdir "*) ;;
5610786a6f21Smrg	      *) finalize_rpath="$finalize_rpath $libdir"
5611786a6f21Smrg	      esac
5612786a6f21Smrg	      ;;
5613786a6f21Smrg	    esac
5614786a6f21Smrg	  fi
5615786a6f21Smrg
5616786a6f21Smrg	  if test -n "$old_archive_from_expsyms_cmds"; then
5617786a6f21Smrg	    # figure out the soname
5618786a6f21Smrg	    set dummy $library_names
5619786a6f21Smrg	    shift
5620786a6f21Smrg	    realname="$1"
5621786a6f21Smrg	    shift
5622786a6f21Smrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
5623786a6f21Smrg	    # use dlname if we got it. it's perfectly good, no?
5624786a6f21Smrg	    if test -n "$dlname"; then
5625786a6f21Smrg	      soname="$dlname"
5626786a6f21Smrg	    elif test -n "$soname_spec"; then
5627786a6f21Smrg	      # bleh windows
5628786a6f21Smrg	      case $host in
5629786a6f21Smrg	      *cygwin* | mingw* | *cegcc*)
5630786a6f21Smrg	        func_arith $current - $age
5631786a6f21Smrg		major=$func_arith_result
5632786a6f21Smrg		versuffix="-$major"
5633786a6f21Smrg		;;
5634786a6f21Smrg	      esac
5635786a6f21Smrg	      eval soname=\"$soname_spec\"
5636786a6f21Smrg	    else
5637786a6f21Smrg	      soname="$realname"
5638786a6f21Smrg	    fi
5639786a6f21Smrg
5640786a6f21Smrg	    # Make a new name for the extract_expsyms_cmds to use
5641786a6f21Smrg	    soroot="$soname"
5642786a6f21Smrg	    func_basename "$soroot"
5643786a6f21Smrg	    soname="$func_basename_result"
5644786a6f21Smrg	    func_stripname 'lib' '.dll' "$soname"
5645786a6f21Smrg	    newlib=libimp-$func_stripname_result.a
5646786a6f21Smrg
5647786a6f21Smrg	    # If the library has no export list, then create one now
5648786a6f21Smrg	    if test -f "$output_objdir/$soname-def"; then :
5649786a6f21Smrg	    else
5650786a6f21Smrg	      func_verbose "extracting exported symbol list from \`$soname'"
5651786a6f21Smrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
5652786a6f21Smrg	    fi
5653786a6f21Smrg
5654786a6f21Smrg	    # Create $newlib
5655786a6f21Smrg	    if test -f "$output_objdir/$newlib"; then :; else
5656786a6f21Smrg	      func_verbose "generating import library for \`$soname'"
5657786a6f21Smrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
5658786a6f21Smrg	    fi
5659786a6f21Smrg	    # make sure the library variables are pointing to the new library
5660786a6f21Smrg	    dir=$output_objdir
5661786a6f21Smrg	    linklib=$newlib
5662786a6f21Smrg	  fi # test -n "$old_archive_from_expsyms_cmds"
5663786a6f21Smrg
5664786a6f21Smrg	  if test "$linkmode" = prog || test "$mode" != relink; then
5665786a6f21Smrg	    add_shlibpath=
5666786a6f21Smrg	    add_dir=
5667786a6f21Smrg	    add=
5668786a6f21Smrg	    lib_linked=yes
5669786a6f21Smrg	    case $hardcode_action in
5670786a6f21Smrg	    immediate | unsupported)
5671786a6f21Smrg	      if test "$hardcode_direct" = no; then
5672786a6f21Smrg		add="$dir/$linklib"
5673786a6f21Smrg		case $host in
5674786a6f21Smrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
5675786a6f21Smrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
5676786a6f21Smrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
5677786a6f21Smrg		    *-*-unixware7*) add_dir="-L$dir" ;;
5678786a6f21Smrg		  *-*-darwin* )
5679786a6f21Smrg		    # if the lib is a (non-dlopened) module then we can not
5680786a6f21Smrg		    # link against it, someone is ignoring the earlier warnings
5681786a6f21Smrg		    if /usr/bin/file -L $add 2> /dev/null |
5682786a6f21Smrg			 $GREP ": [^:]* bundle" >/dev/null ; then
5683786a6f21Smrg		      if test "X$dlopenmodule" != "X$lib"; then
5684786a6f21Smrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
5685786a6f21Smrg			if test -z "$old_library" ; then
5686786a6f21Smrg			  $ECHO
5687786a6f21Smrg			  $ECHO "*** And there doesn't seem to be a static archive available"
5688786a6f21Smrg			  $ECHO "*** The link will probably fail, sorry"
5689786a6f21Smrg			else
5690786a6f21Smrg			  add="$dir/$old_library"
5691786a6f21Smrg			fi
5692786a6f21Smrg		      elif test -n "$old_library"; then
5693786a6f21Smrg			add="$dir/$old_library"
5694786a6f21Smrg		      fi
5695786a6f21Smrg		    fi
5696786a6f21Smrg		esac
5697786a6f21Smrg	      elif test "$hardcode_minus_L" = no; then
5698786a6f21Smrg		case $host in
5699786a6f21Smrg		*-*-sunos*) add_shlibpath="$dir" ;;
5700786a6f21Smrg		esac
5701786a6f21Smrg		add_dir="-L$dir"
5702786a6f21Smrg		add="-l$name"
5703786a6f21Smrg	      elif test "$hardcode_shlibpath_var" = no; then
5704786a6f21Smrg		add_shlibpath="$dir"
5705786a6f21Smrg		add="-l$name"
5706786a6f21Smrg	      else
5707786a6f21Smrg		lib_linked=no
5708786a6f21Smrg	      fi
5709786a6f21Smrg	      ;;
5710786a6f21Smrg	    relink)
5711786a6f21Smrg	      if test "$hardcode_direct" = yes &&
5712786a6f21Smrg	         test "$hardcode_direct_absolute" = no; then
5713786a6f21Smrg		add="$dir/$linklib"
5714786a6f21Smrg	      elif test "$hardcode_minus_L" = yes; then
5715786a6f21Smrg		add_dir="-L$dir"
5716786a6f21Smrg		# Try looking first in the location we're being installed to.
5717786a6f21Smrg		if test -n "$inst_prefix_dir"; then
5718786a6f21Smrg		  case $libdir in
5719786a6f21Smrg		    [\\/]*)
5720786a6f21Smrg		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
5721786a6f21Smrg		      ;;
5722786a6f21Smrg		  esac
5723786a6f21Smrg		fi
5724786a6f21Smrg		add="-l$name"
5725786a6f21Smrg	      elif test "$hardcode_shlibpath_var" = yes; then
5726786a6f21Smrg		add_shlibpath="$dir"
5727786a6f21Smrg		add="-l$name"
5728786a6f21Smrg	      else
5729786a6f21Smrg		lib_linked=no
5730786a6f21Smrg	      fi
5731786a6f21Smrg	      ;;
5732786a6f21Smrg	    *) lib_linked=no ;;
5733786a6f21Smrg	    esac
5734786a6f21Smrg
5735786a6f21Smrg	    if test "$lib_linked" != yes; then
5736786a6f21Smrg	      func_fatal_configuration "unsupported hardcode properties"
5737786a6f21Smrg	    fi
5738786a6f21Smrg
5739786a6f21Smrg	    if test -n "$add_shlibpath"; then
5740786a6f21Smrg	      case :$compile_shlibpath: in
5741786a6f21Smrg	      *":$add_shlibpath:"*) ;;
5742786a6f21Smrg	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
5743786a6f21Smrg	      esac
5744786a6f21Smrg	    fi
5745786a6f21Smrg	    if test "$linkmode" = prog; then
5746786a6f21Smrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
5747786a6f21Smrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
5748786a6f21Smrg	    else
5749786a6f21Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
5750786a6f21Smrg	      test -n "$add" && deplibs="$add $deplibs"
5751786a6f21Smrg	      if test "$hardcode_direct" != yes &&
5752786a6f21Smrg		 test "$hardcode_minus_L" != yes &&
5753786a6f21Smrg		 test "$hardcode_shlibpath_var" = yes; then
5754786a6f21Smrg		case :$finalize_shlibpath: in
5755786a6f21Smrg		*":$libdir:"*) ;;
5756786a6f21Smrg		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
5757786a6f21Smrg		esac
5758786a6f21Smrg	      fi
5759786a6f21Smrg	    fi
5760786a6f21Smrg	  fi
5761786a6f21Smrg
5762786a6f21Smrg	  if test "$linkmode" = prog || test "$mode" = relink; then
5763786a6f21Smrg	    add_shlibpath=
5764786a6f21Smrg	    add_dir=
5765786a6f21Smrg	    add=
5766786a6f21Smrg	    # Finalize command for both is simple: just hardcode it.
5767786a6f21Smrg	    if test "$hardcode_direct" = yes &&
5768786a6f21Smrg	       test "$hardcode_direct_absolute" = no; then
5769786a6f21Smrg	      add="$libdir/$linklib"
5770786a6f21Smrg	    elif test "$hardcode_minus_L" = yes; then
5771786a6f21Smrg	      add_dir="-L$libdir"
5772786a6f21Smrg	      add="-l$name"
5773786a6f21Smrg	    elif test "$hardcode_shlibpath_var" = yes; then
5774786a6f21Smrg	      case :$finalize_shlibpath: in
5775786a6f21Smrg	      *":$libdir:"*) ;;
5776786a6f21Smrg	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
5777786a6f21Smrg	      esac
5778786a6f21Smrg	      add="-l$name"
5779786a6f21Smrg	    elif test "$hardcode_automatic" = yes; then
5780786a6f21Smrg	      if test -n "$inst_prefix_dir" &&
5781786a6f21Smrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
5782786a6f21Smrg		add="$inst_prefix_dir$libdir/$linklib"
5783786a6f21Smrg	      else
5784786a6f21Smrg		add="$libdir/$linklib"
5785786a6f21Smrg	      fi
5786786a6f21Smrg	    else
5787786a6f21Smrg	      # We cannot seem to hardcode it, guess we'll fake it.
5788786a6f21Smrg	      add_dir="-L$libdir"
5789786a6f21Smrg	      # Try looking first in the location we're being installed to.
5790786a6f21Smrg	      if test -n "$inst_prefix_dir"; then
5791786a6f21Smrg		case $libdir in
5792786a6f21Smrg		  [\\/]*)
5793786a6f21Smrg		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
5794786a6f21Smrg		    ;;
5795786a6f21Smrg		esac
5796786a6f21Smrg	      fi
5797786a6f21Smrg	      add="-l$name"
5798786a6f21Smrg	    fi
5799786a6f21Smrg
5800786a6f21Smrg	    if test "$linkmode" = prog; then
5801786a6f21Smrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
5802786a6f21Smrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
5803786a6f21Smrg	    else
5804786a6f21Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
5805786a6f21Smrg	      test -n "$add" && deplibs="$add $deplibs"
5806786a6f21Smrg	    fi
5807786a6f21Smrg	  fi
5808786a6f21Smrg	elif test "$linkmode" = prog; then
5809786a6f21Smrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
5810786a6f21Smrg	  # is not unsupported.  This is valid on all known static and
5811786a6f21Smrg	  # shared platforms.
5812786a6f21Smrg	  if test "$hardcode_direct" != unsupported; then
5813786a6f21Smrg	    test -n "$old_library" && linklib="$old_library"
5814786a6f21Smrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
5815786a6f21Smrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
5816786a6f21Smrg	  else
5817786a6f21Smrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
5818786a6f21Smrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
5819786a6f21Smrg	  fi
5820786a6f21Smrg	elif test "$build_libtool_libs" = yes; then
5821786a6f21Smrg	  # Not a shared library
5822786a6f21Smrg	  if test "$deplibs_check_method" != pass_all; then
5823786a6f21Smrg	    # We're trying link a shared library against a static one
5824786a6f21Smrg	    # but the system doesn't support it.
5825786a6f21Smrg
5826786a6f21Smrg	    # Just print a warning and add the library to dependency_libs so
5827786a6f21Smrg	    # that the program can be linked against the static library.
5828786a6f21Smrg	    $ECHO
5829786a6f21Smrg	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
5830786a6f21Smrg	    $ECHO "*** I have the capability to make that library automatically link in when"
5831786a6f21Smrg	    $ECHO "*** you link to this library.  But I can only do this if you have a"
5832786a6f21Smrg	    $ECHO "*** shared version of the library, which you do not appear to have."
5833786a6f21Smrg	    if test "$module" = yes; then
5834786a6f21Smrg	      $ECHO "*** But as you try to build a module library, libtool will still create "
5835786a6f21Smrg	      $ECHO "*** a static module, that should work as long as the dlopening application"
5836786a6f21Smrg	      $ECHO "*** is linked with the -dlopen flag to resolve symbols at runtime."
5837786a6f21Smrg	      if test -z "$global_symbol_pipe"; then
5838786a6f21Smrg		$ECHO
5839786a6f21Smrg		$ECHO "*** However, this would only work if libtool was able to extract symbol"
5840786a6f21Smrg		$ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
5841786a6f21Smrg		$ECHO "*** not find such a program.  So, this module is probably useless."
5842786a6f21Smrg		$ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
5843786a6f21Smrg	      fi
5844786a6f21Smrg	      if test "$build_old_libs" = no; then
5845786a6f21Smrg		build_libtool_libs=module
5846786a6f21Smrg		build_old_libs=yes
5847786a6f21Smrg	      else
5848786a6f21Smrg		build_libtool_libs=no
5849786a6f21Smrg	      fi
5850786a6f21Smrg	    fi
5851786a6f21Smrg	  else
5852786a6f21Smrg	    deplibs="$dir/$old_library $deplibs"
5853786a6f21Smrg	    link_static=yes
5854786a6f21Smrg	  fi
5855786a6f21Smrg	fi # link shared/static library?
5856786a6f21Smrg
5857786a6f21Smrg	if test "$linkmode" = lib; then
5858786a6f21Smrg	  if test -n "$dependency_libs" &&
5859786a6f21Smrg	     { test "$hardcode_into_libs" != yes ||
5860786a6f21Smrg	       test "$build_old_libs" = yes ||
5861786a6f21Smrg	       test "$link_static" = yes; }; then
5862786a6f21Smrg	    # Extract -R from dependency_libs
5863786a6f21Smrg	    temp_deplibs=
5864786a6f21Smrg	    for libdir in $dependency_libs; do
5865786a6f21Smrg	      case $libdir in
5866786a6f21Smrg	      -R*) func_stripname '-R' '' "$libdir"
5867786a6f21Smrg	           temp_xrpath=$func_stripname_result
5868786a6f21Smrg		   case " $xrpath " in
5869786a6f21Smrg		   *" $temp_xrpath "*) ;;
5870786a6f21Smrg		   *) xrpath="$xrpath $temp_xrpath";;
5871786a6f21Smrg		   esac;;
5872786a6f21Smrg	      *) temp_deplibs="$temp_deplibs $libdir";;
5873786a6f21Smrg	      esac
5874786a6f21Smrg	    done
5875786a6f21Smrg	    dependency_libs="$temp_deplibs"
5876786a6f21Smrg	  fi
5877786a6f21Smrg
5878786a6f21Smrg	  newlib_search_path="$newlib_search_path $absdir"
5879786a6f21Smrg	  # Link against this library
5880786a6f21Smrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
5881786a6f21Smrg	  # ... and its dependency_libs
5882786a6f21Smrg	  tmp_libs=
5883786a6f21Smrg	  for deplib in $dependency_libs; do
5884786a6f21Smrg	    newdependency_libs="$deplib $newdependency_libs"
5885786a6f21Smrg	    if $opt_duplicate_deps ; then
5886786a6f21Smrg	      case "$tmp_libs " in
5887786a6f21Smrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
5888786a6f21Smrg	      esac
5889786a6f21Smrg	    fi
5890786a6f21Smrg	    tmp_libs="$tmp_libs $deplib"
5891786a6f21Smrg	  done
5892786a6f21Smrg
5893786a6f21Smrg	  if test "$link_all_deplibs" != no; then
5894786a6f21Smrg	    # Add the search paths of all dependency libraries
5895786a6f21Smrg	    for deplib in $dependency_libs; do
5896786a6f21Smrg	      case $deplib in
5897786a6f21Smrg	      -L*) path="$deplib" ;;
5898786a6f21Smrg	      *.la)
5899786a6f21Smrg	        func_dirname "$deplib" "" "."
5900786a6f21Smrg		dir="$func_dirname_result"
5901786a6f21Smrg		# We need an absolute path.
5902786a6f21Smrg		case $dir in
5903786a6f21Smrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
5904786a6f21Smrg		*)
5905786a6f21Smrg		  absdir=`cd "$dir" && pwd`
5906786a6f21Smrg		  if test -z "$absdir"; then
5907786a6f21Smrg		    func_warning "cannot determine absolute directory name of \`$dir'"
5908786a6f21Smrg		    absdir="$dir"
5909786a6f21Smrg		  fi
5910786a6f21Smrg		  ;;
5911786a6f21Smrg		esac
5912786a6f21Smrg		if $GREP "^installed=no" $deplib > /dev/null; then
5913786a6f21Smrg		case $host in
5914786a6f21Smrg		*-*-darwin*)
5915786a6f21Smrg		  depdepl=
5916786a6f21Smrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
5917786a6f21Smrg		  if test -n "$deplibrary_names" ; then
5918786a6f21Smrg		    for tmp in $deplibrary_names ; do
5919786a6f21Smrg		      depdepl=$tmp
5920786a6f21Smrg		    done
5921786a6f21Smrg		    if test -f "$absdir/$objdir/$depdepl" ; then
5922786a6f21Smrg		      depdepl="$absdir/$objdir/$depdepl"
5923786a6f21Smrg		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
5924786a6f21Smrg                      if test -z "$darwin_install_name"; then
5925786a6f21Smrg                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
5926786a6f21Smrg                      fi
5927786a6f21Smrg		      compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
5928786a6f21Smrg		      linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}"
5929786a6f21Smrg		      path=
5930786a6f21Smrg		    fi
5931786a6f21Smrg		  fi
5932786a6f21Smrg		  ;;
5933786a6f21Smrg		*)
5934786a6f21Smrg		  path="-L$absdir/$objdir"
5935786a6f21Smrg		  ;;
5936786a6f21Smrg		esac
5937786a6f21Smrg		else
5938786a6f21Smrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
5939786a6f21Smrg		  test -z "$libdir" && \
5940786a6f21Smrg		    func_fatal_error "\`$deplib' is not a valid libtool archive"
5941786a6f21Smrg		  test "$absdir" != "$libdir" && \
5942786a6f21Smrg		    func_warning "\`$deplib' seems to be moved"
5943786a6f21Smrg
5944786a6f21Smrg		  path="-L$absdir"
5945786a6f21Smrg		fi
5946786a6f21Smrg		;;
5947786a6f21Smrg	      esac
5948786a6f21Smrg	      case " $deplibs " in
5949786a6f21Smrg	      *" $path "*) ;;
5950786a6f21Smrg	      *) deplibs="$path $deplibs" ;;
5951786a6f21Smrg	      esac
5952786a6f21Smrg	    done
5953786a6f21Smrg	  fi # link_all_deplibs != no
5954786a6f21Smrg	fi # linkmode = lib
5955786a6f21Smrg      done # for deplib in $libs
5956786a6f21Smrg      if test "$pass" = link; then
5957786a6f21Smrg	if test "$linkmode" = "prog"; then
5958786a6f21Smrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
5959786a6f21Smrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
5960786a6f21Smrg	else
5961786a6f21Smrg	  compiler_flags="$compiler_flags "`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
5962786a6f21Smrg	fi
5963786a6f21Smrg      fi
5964786a6f21Smrg      dependency_libs="$newdependency_libs"
5965786a6f21Smrg      if test "$pass" = dlpreopen; then
5966786a6f21Smrg	# Link the dlpreopened libraries before other libraries
5967786a6f21Smrg	for deplib in $save_deplibs; do
5968786a6f21Smrg	  deplibs="$deplib $deplibs"
5969786a6f21Smrg	done
5970786a6f21Smrg      fi
5971786a6f21Smrg      if test "$pass" != dlopen; then
5972786a6f21Smrg	if test "$pass" != conv; then
5973786a6f21Smrg	  # Make sure lib_search_path contains only unique directories.
5974786a6f21Smrg	  lib_search_path=
5975786a6f21Smrg	  for dir in $newlib_search_path; do
5976786a6f21Smrg	    case "$lib_search_path " in
5977786a6f21Smrg	    *" $dir "*) ;;
5978786a6f21Smrg	    *) lib_search_path="$lib_search_path $dir" ;;
5979786a6f21Smrg	    esac
5980786a6f21Smrg	  done
5981786a6f21Smrg	  newlib_search_path=
5982786a6f21Smrg	fi
5983786a6f21Smrg
5984786a6f21Smrg	if test "$linkmode,$pass" != "prog,link"; then
5985786a6f21Smrg	  vars="deplibs"
5986786a6f21Smrg	else
5987786a6f21Smrg	  vars="compile_deplibs finalize_deplibs"
5988786a6f21Smrg	fi
5989786a6f21Smrg	for var in $vars dependency_libs; do
5990786a6f21Smrg	  # Add libraries to $var in reverse order
5991786a6f21Smrg	  eval tmp_libs=\"\$$var\"
5992786a6f21Smrg	  new_libs=
5993786a6f21Smrg	  for deplib in $tmp_libs; do
5994786a6f21Smrg	    # FIXME: Pedantically, this is the right thing to do, so
5995786a6f21Smrg	    #        that some nasty dependency loop isn't accidentally
5996786a6f21Smrg	    #        broken:
5997786a6f21Smrg	    #new_libs="$deplib $new_libs"
5998786a6f21Smrg	    # Pragmatically, this seems to cause very few problems in
5999786a6f21Smrg	    # practice:
6000786a6f21Smrg	    case $deplib in
6001786a6f21Smrg	    -L*) new_libs="$deplib $new_libs" ;;
6002786a6f21Smrg	    -R*) ;;
6003786a6f21Smrg	    *)
6004786a6f21Smrg	      # And here is the reason: when a library appears more
6005786a6f21Smrg	      # than once as an explicit dependence of a library, or
6006786a6f21Smrg	      # is implicitly linked in more than once by the
6007786a6f21Smrg	      # compiler, it is considered special, and multiple
6008786a6f21Smrg	      # occurrences thereof are not removed.  Compare this
6009786a6f21Smrg	      # with having the same library being listed as a
6010786a6f21Smrg	      # dependency of multiple other libraries: in this case,
6011786a6f21Smrg	      # we know (pedantically, we assume) the library does not
6012786a6f21Smrg	      # need to be listed more than once, so we keep only the
6013786a6f21Smrg	      # last copy.  This is not always right, but it is rare
6014786a6f21Smrg	      # enough that we require users that really mean to play
6015786a6f21Smrg	      # such unportable linking tricks to link the library
6016786a6f21Smrg	      # using -Wl,-lname, so that libtool does not consider it
6017786a6f21Smrg	      # for duplicate removal.
6018786a6f21Smrg	      case " $specialdeplibs " in
6019786a6f21Smrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
6020786a6f21Smrg	      *)
6021786a6f21Smrg		case " $new_libs " in
6022786a6f21Smrg		*" $deplib "*) ;;
6023786a6f21Smrg		*) new_libs="$deplib $new_libs" ;;
6024786a6f21Smrg		esac
6025786a6f21Smrg		;;
6026786a6f21Smrg	      esac
6027786a6f21Smrg	      ;;
6028786a6f21Smrg	    esac
6029786a6f21Smrg	  done
6030786a6f21Smrg	  tmp_libs=
6031786a6f21Smrg	  for deplib in $new_libs; do
6032786a6f21Smrg	    case $deplib in
6033786a6f21Smrg	    -L*)
6034786a6f21Smrg	      case " $tmp_libs " in
6035786a6f21Smrg	      *" $deplib "*) ;;
6036786a6f21Smrg	      *) tmp_libs="$tmp_libs $deplib" ;;
6037786a6f21Smrg	      esac
6038786a6f21Smrg	      ;;
6039786a6f21Smrg	    *) tmp_libs="$tmp_libs $deplib" ;;
6040786a6f21Smrg	    esac
6041786a6f21Smrg	  done
6042786a6f21Smrg	  eval $var=\"$tmp_libs\"
6043786a6f21Smrg	done # for var
6044786a6f21Smrg      fi
6045786a6f21Smrg      # Last step: remove runtime libs from dependency_libs
6046786a6f21Smrg      # (they stay in deplibs)
6047786a6f21Smrg      tmp_libs=
6048786a6f21Smrg      for i in $dependency_libs ; do
6049786a6f21Smrg	case " $predeps $postdeps $compiler_lib_search_path " in
6050786a6f21Smrg	*" $i "*)
6051786a6f21Smrg	  i=""
6052786a6f21Smrg	  ;;
6053786a6f21Smrg	esac
6054786a6f21Smrg	if test -n "$i" ; then
6055786a6f21Smrg	  tmp_libs="$tmp_libs $i"
6056786a6f21Smrg	fi
6057786a6f21Smrg      done
6058786a6f21Smrg      dependency_libs=$tmp_libs
6059786a6f21Smrg    done # for pass
6060786a6f21Smrg    if test "$linkmode" = prog; then
6061786a6f21Smrg      dlfiles="$newdlfiles"
6062786a6f21Smrg    fi
6063786a6f21Smrg    if test "$linkmode" = prog || test "$linkmode" = lib; then
6064786a6f21Smrg      dlprefiles="$newdlprefiles"
6065786a6f21Smrg    fi
6066786a6f21Smrg
6067786a6f21Smrg    case $linkmode in
6068786a6f21Smrg    oldlib)
6069786a6f21Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
6070786a6f21Smrg	func_warning "\`-dlopen' is ignored for archives"
6071786a6f21Smrg      fi
6072786a6f21Smrg
6073786a6f21Smrg      case " $deplibs" in
6074786a6f21Smrg      *\ -l* | *\ -L*)
6075786a6f21Smrg	func_warning "\`-l' and \`-L' are ignored for archives" ;;
6076786a6f21Smrg      esac
6077786a6f21Smrg
6078786a6f21Smrg      test -n "$rpath" && \
6079786a6f21Smrg	func_warning "\`-rpath' is ignored for archives"
6080786a6f21Smrg
6081786a6f21Smrg      test -n "$xrpath" && \
6082786a6f21Smrg	func_warning "\`-R' is ignored for archives"
6083786a6f21Smrg
6084786a6f21Smrg      test -n "$vinfo" && \
6085786a6f21Smrg	func_warning "\`-version-info/-version-number' is ignored for archives"
6086786a6f21Smrg
6087786a6f21Smrg      test -n "$release" && \
6088786a6f21Smrg	func_warning "\`-release' is ignored for archives"
6089786a6f21Smrg
6090786a6f21Smrg      test -n "$export_symbols$export_symbols_regex" && \
6091786a6f21Smrg	func_warning "\`-export-symbols' is ignored for archives"
6092786a6f21Smrg
6093786a6f21Smrg      # Now set the variables for building old libraries.
6094786a6f21Smrg      build_libtool_libs=no
6095786a6f21Smrg      oldlibs="$output"
6096786a6f21Smrg      objs="$objs$old_deplibs"
6097786a6f21Smrg      ;;
6098786a6f21Smrg
6099786a6f21Smrg    lib)
6100786a6f21Smrg      # Make sure we only generate libraries of the form `libNAME.la'.
6101786a6f21Smrg      case $outputname in
6102786a6f21Smrg      lib*)
6103786a6f21Smrg	func_stripname 'lib' '.la' "$outputname"
6104786a6f21Smrg	name=$func_stripname_result
6105786a6f21Smrg	eval shared_ext=\"$shrext_cmds\"
6106786a6f21Smrg	eval libname=\"$libname_spec\"
6107786a6f21Smrg	;;
6108786a6f21Smrg      *)
6109786a6f21Smrg	test "$module" = no && \
6110786a6f21Smrg	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
6111786a6f21Smrg
6112786a6f21Smrg	if test "$need_lib_prefix" != no; then
6113786a6f21Smrg	  # Add the "lib" prefix for modules if required
6114786a6f21Smrg	  func_stripname '' '.la' "$outputname"
6115786a6f21Smrg	  name=$func_stripname_result
6116786a6f21Smrg	  eval shared_ext=\"$shrext_cmds\"
6117786a6f21Smrg	  eval libname=\"$libname_spec\"
6118786a6f21Smrg	else
6119786a6f21Smrg	  func_stripname '' '.la' "$outputname"
6120786a6f21Smrg	  libname=$func_stripname_result
6121786a6f21Smrg	fi
6122786a6f21Smrg	;;
6123786a6f21Smrg      esac
6124786a6f21Smrg
6125786a6f21Smrg      if test -n "$objs"; then
6126786a6f21Smrg	if test "$deplibs_check_method" != pass_all; then
6127786a6f21Smrg	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
6128786a6f21Smrg	else
6129786a6f21Smrg	  $ECHO
6130786a6f21Smrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
6131786a6f21Smrg	  $ECHO "*** objects $objs is not portable!"
6132786a6f21Smrg	  libobjs="$libobjs $objs"
6133786a6f21Smrg	fi
6134786a6f21Smrg      fi
6135786a6f21Smrg
6136786a6f21Smrg      test "$dlself" != no && \
6137786a6f21Smrg	func_warning "\`-dlopen self' is ignored for libtool libraries"
6138786a6f21Smrg
6139786a6f21Smrg      set dummy $rpath
6140786a6f21Smrg      shift
6141786a6f21Smrg      test "$#" -gt 1 && \
6142786a6f21Smrg	func_warning "ignoring multiple \`-rpath's for a libtool library"
6143786a6f21Smrg
6144786a6f21Smrg      install_libdir="$1"
6145786a6f21Smrg
6146786a6f21Smrg      oldlibs=
6147786a6f21Smrg      if test -z "$rpath"; then
6148786a6f21Smrg	if test "$build_libtool_libs" = yes; then
6149786a6f21Smrg	  # Building a libtool convenience library.
6150786a6f21Smrg	  # Some compilers have problems with a `.al' extension so
6151786a6f21Smrg	  # convenience libraries should have the same extension an
6152786a6f21Smrg	  # archive normally would.
6153786a6f21Smrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
6154786a6f21Smrg	  build_libtool_libs=convenience
6155786a6f21Smrg	  build_old_libs=yes
6156786a6f21Smrg	fi
6157786a6f21Smrg
6158786a6f21Smrg	test -n "$vinfo" && \
6159786a6f21Smrg	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
6160786a6f21Smrg
6161786a6f21Smrg	test -n "$release" && \
6162786a6f21Smrg	  func_warning "\`-release' is ignored for convenience libraries"
6163786a6f21Smrg      else
6164786a6f21Smrg
6165786a6f21Smrg	# Parse the version information argument.
6166786a6f21Smrg	save_ifs="$IFS"; IFS=':'
6167786a6f21Smrg	set dummy $vinfo 0 0 0
6168786a6f21Smrg	shift
6169786a6f21Smrg	IFS="$save_ifs"
6170786a6f21Smrg
6171786a6f21Smrg	test -n "$7" && \
6172786a6f21Smrg	  func_fatal_help "too many parameters to \`-version-info'"
6173786a6f21Smrg
6174786a6f21Smrg	# convert absolute version numbers to libtool ages
6175786a6f21Smrg	# this retains compatibility with .la files and attempts
6176786a6f21Smrg	# to make the code below a bit more comprehensible
6177786a6f21Smrg
6178786a6f21Smrg	case $vinfo_number in
6179786a6f21Smrg	yes)
6180786a6f21Smrg	  number_major="$1"
6181786a6f21Smrg	  number_minor="$2"
6182786a6f21Smrg	  number_revision="$3"
6183786a6f21Smrg	  #
6184786a6f21Smrg	  # There are really only two kinds -- those that
6185786a6f21Smrg	  # use the current revision as the major version
6186786a6f21Smrg	  # and those that subtract age and use age as
6187786a6f21Smrg	  # a minor version.  But, then there is irix
6188786a6f21Smrg	  # which has an extra 1 added just for fun
6189786a6f21Smrg	  #
6190786a6f21Smrg	  case $version_type in
6191786a6f21Smrg	  darwin|linux|osf|windows|none)
6192786a6f21Smrg	    func_arith $number_major + $number_minor
6193786a6f21Smrg	    current=$func_arith_result
6194786a6f21Smrg	    age="$number_minor"
6195786a6f21Smrg	    revision="$number_revision"
6196786a6f21Smrg	    ;;
6197786a6f21Smrg	  freebsd-aout|freebsd-elf|sunos)
6198786a6f21Smrg	    current="$number_major"
6199786a6f21Smrg	    revision="$number_minor"
6200786a6f21Smrg	    age="0"
6201786a6f21Smrg	    ;;
6202786a6f21Smrg	  irix|nonstopux)
6203786a6f21Smrg	    func_arith $number_major + $number_minor
6204786a6f21Smrg	    current=$func_arith_result
6205786a6f21Smrg	    age="$number_minor"
6206786a6f21Smrg	    revision="$number_minor"
6207786a6f21Smrg	    lt_irix_increment=no
6208786a6f21Smrg	    ;;
6209786a6f21Smrg	  esac
6210786a6f21Smrg	  ;;
6211786a6f21Smrg	no)
6212786a6f21Smrg	  current="$1"
6213786a6f21Smrg	  revision="$2"
6214786a6f21Smrg	  age="$3"
6215786a6f21Smrg	  ;;
6216786a6f21Smrg	esac
6217786a6f21Smrg
6218786a6f21Smrg	# Check that each of the things are valid numbers.
6219786a6f21Smrg	case $current in
6220786a6f21Smrg	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]) ;;
6221786a6f21Smrg	*)
6222786a6f21Smrg	  func_error "CURRENT \`$current' must be a nonnegative integer"
6223786a6f21Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
6224786a6f21Smrg	  ;;
6225786a6f21Smrg	esac
6226786a6f21Smrg
6227786a6f21Smrg	case $revision in
6228786a6f21Smrg	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]) ;;
6229786a6f21Smrg	*)
6230786a6f21Smrg	  func_error "REVISION \`$revision' must be a nonnegative integer"
6231786a6f21Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
6232786a6f21Smrg	  ;;
6233786a6f21Smrg	esac
6234786a6f21Smrg
6235786a6f21Smrg	case $age in
6236786a6f21Smrg	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]) ;;
6237786a6f21Smrg	*)
6238786a6f21Smrg	  func_error "AGE \`$age' must be a nonnegative integer"
6239786a6f21Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
6240786a6f21Smrg	  ;;
6241786a6f21Smrg	esac
6242786a6f21Smrg
6243786a6f21Smrg	if test "$age" -gt "$current"; then
6244786a6f21Smrg	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
6245786a6f21Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
6246786a6f21Smrg	fi
6247786a6f21Smrg
6248786a6f21Smrg	# Calculate the version variables.
6249786a6f21Smrg	major=
6250786a6f21Smrg	versuffix=
6251786a6f21Smrg	verstring=
6252786a6f21Smrg	case $version_type in
6253786a6f21Smrg	none) ;;
6254786a6f21Smrg
6255786a6f21Smrg	darwin)
6256786a6f21Smrg	  # Like Linux, but with the current version available in
6257786a6f21Smrg	  # verstring for coding it into the library header
6258786a6f21Smrg	  func_arith $current - $age
6259786a6f21Smrg	  major=.$func_arith_result
6260786a6f21Smrg	  versuffix="$major.$age.$revision"
6261786a6f21Smrg	  # Darwin ld doesn't like 0 for these options...
6262786a6f21Smrg	  func_arith $current + 1
6263786a6f21Smrg	  minor_current=$func_arith_result
6264786a6f21Smrg	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
6265786a6f21Smrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
6266786a6f21Smrg	  ;;
6267786a6f21Smrg
6268786a6f21Smrg	freebsd-aout)
6269786a6f21Smrg	  major=".$current"
6270786a6f21Smrg	  versuffix=".$current.$revision";
6271786a6f21Smrg	  ;;
6272786a6f21Smrg
6273786a6f21Smrg	freebsd-elf)
6274786a6f21Smrg	  major=".$current"
6275786a6f21Smrg	  versuffix=".$current"
6276786a6f21Smrg	  ;;
6277786a6f21Smrg
6278786a6f21Smrg	irix | nonstopux)
6279786a6f21Smrg	  if test "X$lt_irix_increment" = "Xno"; then
6280786a6f21Smrg	    func_arith $current - $age
6281786a6f21Smrg	  else
6282786a6f21Smrg	    func_arith $current - $age + 1
6283786a6f21Smrg	  fi
6284786a6f21Smrg	  major=$func_arith_result
6285786a6f21Smrg
6286786a6f21Smrg	  case $version_type in
6287786a6f21Smrg	    nonstopux) verstring_prefix=nonstopux ;;
6288786a6f21Smrg	    *)         verstring_prefix=sgi ;;
6289786a6f21Smrg	  esac
6290786a6f21Smrg	  verstring="$verstring_prefix$major.$revision"
6291786a6f21Smrg
6292786a6f21Smrg	  # Add in all the interfaces that we are compatible with.
6293786a6f21Smrg	  loop=$revision
6294786a6f21Smrg	  while test "$loop" -ne 0; do
6295786a6f21Smrg	    func_arith $revision - $loop
6296786a6f21Smrg	    iface=$func_arith_result
6297786a6f21Smrg	    func_arith $loop - 1
6298786a6f21Smrg	    loop=$func_arith_result
6299786a6f21Smrg	    verstring="$verstring_prefix$major.$iface:$verstring"
6300786a6f21Smrg	  done
6301786a6f21Smrg
6302786a6f21Smrg	  # Before this point, $major must not contain `.'.
6303786a6f21Smrg	  major=.$major
6304786a6f21Smrg	  versuffix="$major.$revision"
6305786a6f21Smrg	  ;;
6306786a6f21Smrg
6307786a6f21Smrg	linux)
6308786a6f21Smrg	  func_arith $current - $age
6309786a6f21Smrg	  major=.$func_arith_result
6310786a6f21Smrg	  versuffix="$major.$age.$revision"
6311786a6f21Smrg	  ;;
6312786a6f21Smrg
6313786a6f21Smrg	osf)
6314786a6f21Smrg	  func_arith $current - $age
6315786a6f21Smrg	  major=.$func_arith_result
6316786a6f21Smrg	  versuffix=".$current.$age.$revision"
6317786a6f21Smrg	  verstring="$current.$age.$revision"
6318786a6f21Smrg
6319786a6f21Smrg	  # Add in all the interfaces that we are compatible with.
6320786a6f21Smrg	  loop=$age
6321786a6f21Smrg	  while test "$loop" -ne 0; do
6322786a6f21Smrg	    func_arith $current - $loop
6323786a6f21Smrg	    iface=$func_arith_result
6324786a6f21Smrg	    func_arith $loop - 1
6325786a6f21Smrg	    loop=$func_arith_result
6326786a6f21Smrg	    verstring="$verstring:${iface}.0"
6327786a6f21Smrg	  done
6328786a6f21Smrg
6329786a6f21Smrg	  # Make executables depend on our current version.
6330786a6f21Smrg	  verstring="$verstring:${current}.0"
6331786a6f21Smrg	  ;;
6332786a6f21Smrg
6333786a6f21Smrg	qnx)
6334786a6f21Smrg	  major=".$current"
6335786a6f21Smrg	  versuffix=".$current"
6336786a6f21Smrg	  ;;
6337786a6f21Smrg
6338786a6f21Smrg	sunos)
6339786a6f21Smrg	  major=".$current"
6340786a6f21Smrg	  versuffix=".$current.$revision"
6341786a6f21Smrg	  ;;
6342786a6f21Smrg
6343786a6f21Smrg	windows)
6344786a6f21Smrg	  # Use '-' rather than '.', since we only want one
6345786a6f21Smrg	  # extension on DOS 8.3 filesystems.
6346786a6f21Smrg	  func_arith $current - $age
6347786a6f21Smrg	  major=$func_arith_result
6348786a6f21Smrg	  versuffix="-$major"
6349786a6f21Smrg	  ;;
6350786a6f21Smrg
6351786a6f21Smrg	*)
6352786a6f21Smrg	  func_fatal_configuration "unknown library version type \`$version_type'"
6353786a6f21Smrg	  ;;
6354786a6f21Smrg	esac
6355786a6f21Smrg
6356786a6f21Smrg	# Clear the version info if we defaulted, and they specified a release.
6357786a6f21Smrg	if test -z "$vinfo" && test -n "$release"; then
6358786a6f21Smrg	  major=
6359786a6f21Smrg	  case $version_type in
6360786a6f21Smrg	  darwin)
6361786a6f21Smrg	    # we can't check for "0.0" in archive_cmds due to quoting
6362786a6f21Smrg	    # problems, so we reset it completely
6363786a6f21Smrg	    verstring=
6364786a6f21Smrg	    ;;
6365786a6f21Smrg	  *)
6366786a6f21Smrg	    verstring="0.0"
6367786a6f21Smrg	    ;;
6368786a6f21Smrg	  esac
6369786a6f21Smrg	  if test "$need_version" = no; then
6370786a6f21Smrg	    versuffix=
6371786a6f21Smrg	  else
6372786a6f21Smrg	    versuffix=".0.0"
6373786a6f21Smrg	  fi
6374786a6f21Smrg	fi
6375786a6f21Smrg
6376786a6f21Smrg	# Remove version info from name if versioning should be avoided
6377786a6f21Smrg	if test "$avoid_version" = yes && test "$need_version" = no; then
6378786a6f21Smrg	  major=
6379786a6f21Smrg	  versuffix=
6380786a6f21Smrg	  verstring=""
6381786a6f21Smrg	fi
6382786a6f21Smrg
6383786a6f21Smrg	# Check to see if the archive will have undefined symbols.
6384786a6f21Smrg	if test "$allow_undefined" = yes; then
6385786a6f21Smrg	  if test "$allow_undefined_flag" = unsupported; then
6386786a6f21Smrg	    func_warning "undefined symbols not allowed in $host shared libraries"
6387786a6f21Smrg	    build_libtool_libs=no
6388786a6f21Smrg	    build_old_libs=yes
6389786a6f21Smrg	  fi
6390786a6f21Smrg	else
6391786a6f21Smrg	  # Don't allow undefined symbols.
6392786a6f21Smrg	  allow_undefined_flag="$no_undefined_flag"
6393786a6f21Smrg	fi
6394786a6f21Smrg
6395786a6f21Smrg      fi
6396786a6f21Smrg
6397786a6f21Smrg      func_generate_dlsyms "$libname" "$libname" "yes"
6398786a6f21Smrg      libobjs="$libobjs $symfileobj"
6399786a6f21Smrg      test "X$libobjs" = "X " && libobjs=
6400786a6f21Smrg
6401786a6f21Smrg      if test "$mode" != relink; then
6402786a6f21Smrg	# Remove our outputs, but don't remove object files since they
6403786a6f21Smrg	# may have been created when compiling PIC objects.
6404786a6f21Smrg	removelist=
6405786a6f21Smrg	tempremovelist=`$ECHO "$output_objdir/*"`
6406786a6f21Smrg	for p in $tempremovelist; do
6407786a6f21Smrg	  case $p in
6408786a6f21Smrg	    *.$objext | *.gcno)
6409786a6f21Smrg	       ;;
6410786a6f21Smrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
6411786a6f21Smrg	       if test "X$precious_files_regex" != "X"; then
6412786a6f21Smrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
6413786a6f21Smrg		 then
6414786a6f21Smrg		   continue
6415786a6f21Smrg		 fi
6416786a6f21Smrg	       fi
6417786a6f21Smrg	       removelist="$removelist $p"
6418786a6f21Smrg	       ;;
6419786a6f21Smrg	    *) ;;
6420786a6f21Smrg	  esac
6421786a6f21Smrg	done
6422786a6f21Smrg	test -n "$removelist" && \
6423786a6f21Smrg	  func_show_eval "${RM}r \$removelist"
6424786a6f21Smrg      fi
6425786a6f21Smrg
6426786a6f21Smrg      # Now set the variables for building old libraries.
6427786a6f21Smrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
6428786a6f21Smrg	oldlibs="$oldlibs $output_objdir/$libname.$libext"
6429786a6f21Smrg
6430786a6f21Smrg	# Transform .lo files to .o files.
6431786a6f21Smrg	oldobjs="$objs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
6432786a6f21Smrg      fi
6433786a6f21Smrg
6434786a6f21Smrg      # Eliminate all temporary directories.
6435786a6f21Smrg      #for path in $notinst_path; do
6436786a6f21Smrg      #	lib_search_path=`$ECHO "X$lib_search_path " | $Xsed -e "s% $path % %g"`
6437786a6f21Smrg      #	deplibs=`$ECHO "X$deplibs " | $Xsed -e "s% -L$path % %g"`
6438786a6f21Smrg      #	dependency_libs=`$ECHO "X$dependency_libs " | $Xsed -e "s% -L$path % %g"`
6439786a6f21Smrg      #done
6440786a6f21Smrg
6441786a6f21Smrg      if test -n "$xrpath"; then
6442786a6f21Smrg	# If the user specified any rpath flags, then add them.
6443786a6f21Smrg	temp_xrpath=
6444786a6f21Smrg	for libdir in $xrpath; do
6445786a6f21Smrg	  temp_xrpath="$temp_xrpath -R$libdir"
6446786a6f21Smrg	  case "$finalize_rpath " in
6447786a6f21Smrg	  *" $libdir "*) ;;
6448786a6f21Smrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
6449786a6f21Smrg	  esac
6450786a6f21Smrg	done
6451786a6f21Smrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
6452786a6f21Smrg	  dependency_libs="$temp_xrpath $dependency_libs"
6453786a6f21Smrg	fi
6454786a6f21Smrg      fi
6455786a6f21Smrg
6456786a6f21Smrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
6457786a6f21Smrg      old_dlfiles="$dlfiles"
6458786a6f21Smrg      dlfiles=
6459786a6f21Smrg      for lib in $old_dlfiles; do
6460786a6f21Smrg	case " $dlprefiles $dlfiles " in
6461786a6f21Smrg	*" $lib "*) ;;
6462786a6f21Smrg	*) dlfiles="$dlfiles $lib" ;;
6463786a6f21Smrg	esac
6464786a6f21Smrg      done
6465786a6f21Smrg
6466786a6f21Smrg      # Make sure dlprefiles contains only unique files
6467786a6f21Smrg      old_dlprefiles="$dlprefiles"
6468786a6f21Smrg      dlprefiles=
6469786a6f21Smrg      for lib in $old_dlprefiles; do
6470786a6f21Smrg	case "$dlprefiles " in
6471786a6f21Smrg	*" $lib "*) ;;
6472786a6f21Smrg	*) dlprefiles="$dlprefiles $lib" ;;
6473786a6f21Smrg	esac
6474786a6f21Smrg      done
6475786a6f21Smrg
6476786a6f21Smrg      if test "$build_libtool_libs" = yes; then
6477786a6f21Smrg	if test -n "$rpath"; then
6478786a6f21Smrg	  case $host in
6479786a6f21Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc*)
6480786a6f21Smrg	    # these systems don't actually have a c library (as such)!
6481786a6f21Smrg	    ;;
6482786a6f21Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
6483786a6f21Smrg	    # Rhapsody C library is in the System framework
6484786a6f21Smrg	    deplibs="$deplibs System.ltframework"
6485786a6f21Smrg	    ;;
6486786a6f21Smrg	  *-*-netbsd*)
6487786a6f21Smrg	    # Don't link with libc until the a.out ld.so is fixed.
6488786a6f21Smrg	    ;;
6489786a6f21Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
6490786a6f21Smrg	    # Do not include libc due to us having libc/libc_r.
6491786a6f21Smrg	    ;;
6492786a6f21Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
6493786a6f21Smrg	    # Causes problems with __ctype
6494786a6f21Smrg	    ;;
6495786a6f21Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
6496786a6f21Smrg	    # Compiler inserts libc in the correct place for threads to work
6497786a6f21Smrg	    ;;
6498786a6f21Smrg	  *)
6499786a6f21Smrg	    # Add libc to deplibs on all other systems if necessary.
6500786a6f21Smrg	    if test "$build_libtool_need_lc" = "yes"; then
6501786a6f21Smrg	      deplibs="$deplibs -lc"
6502786a6f21Smrg	    fi
6503786a6f21Smrg	    ;;
6504786a6f21Smrg	  esac
6505786a6f21Smrg	fi
6506786a6f21Smrg
6507786a6f21Smrg	# Transform deplibs into only deplibs that can be linked in shared.
6508786a6f21Smrg	name_save=$name
6509786a6f21Smrg	libname_save=$libname
6510786a6f21Smrg	release_save=$release
6511786a6f21Smrg	versuffix_save=$versuffix
6512786a6f21Smrg	major_save=$major
6513786a6f21Smrg	# I'm not sure if I'm treating the release correctly.  I think
6514786a6f21Smrg	# release should show up in the -l (ie -lgmp5) so we don't want to
6515786a6f21Smrg	# add it in twice.  Is that correct?
6516786a6f21Smrg	release=""
6517786a6f21Smrg	versuffix=""
6518786a6f21Smrg	major=""
6519786a6f21Smrg	newdeplibs=
6520786a6f21Smrg	droppeddeps=no
6521786a6f21Smrg	case $deplibs_check_method in
6522786a6f21Smrg	pass_all)
6523786a6f21Smrg	  # Don't check for shared/static.  Everything works.
6524786a6f21Smrg	  # This might be a little naive.  We might want to check
6525786a6f21Smrg	  # whether the library exists or not.  But this is on
6526786a6f21Smrg	  # osf3 & osf4 and I'm not really sure... Just
6527786a6f21Smrg	  # implementing what was already the behavior.
6528786a6f21Smrg	  newdeplibs=$deplibs
6529786a6f21Smrg	  ;;
6530786a6f21Smrg	test_compile)
6531786a6f21Smrg	  # This code stresses the "libraries are programs" paradigm to its
6532786a6f21Smrg	  # limits. Maybe even breaks it.  We compile a program, linking it
6533786a6f21Smrg	  # against the deplibs as a proxy for the library.  Then we can check
6534786a6f21Smrg	  # whether they linked in statically or dynamically with ldd.
6535786a6f21Smrg	  $opt_dry_run || $RM conftest.c
6536786a6f21Smrg	  cat > conftest.c <<EOF
6537786a6f21Smrg	  int main() { return 0; }
6538786a6f21SmrgEOF
6539786a6f21Smrg	  $opt_dry_run || $RM conftest
6540786a6f21Smrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
6541786a6f21Smrg	    ldd_output=`ldd conftest`
6542786a6f21Smrg	    for i in $deplibs; do
6543786a6f21Smrg	      case $i in
6544786a6f21Smrg	      -l*)
6545786a6f21Smrg		func_stripname -l '' "$i"
6546786a6f21Smrg		name=$func_stripname_result
6547786a6f21Smrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6548786a6f21Smrg		  case " $predeps $postdeps " in
6549786a6f21Smrg		  *" $i "*)
6550786a6f21Smrg		    newdeplibs="$newdeplibs $i"
6551786a6f21Smrg		    i=""
6552786a6f21Smrg		    ;;
6553786a6f21Smrg		  esac
6554786a6f21Smrg		fi
6555786a6f21Smrg		if test -n "$i" ; then
6556786a6f21Smrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
6557786a6f21Smrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
6558786a6f21Smrg		  set dummy $deplib_matches; shift
6559786a6f21Smrg		  deplib_match=$1
6560786a6f21Smrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
6561786a6f21Smrg		    newdeplibs="$newdeplibs $i"
6562786a6f21Smrg		  else
6563786a6f21Smrg		    droppeddeps=yes
6564786a6f21Smrg		    $ECHO
6565786a6f21Smrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
6566786a6f21Smrg		    $ECHO "*** I have the capability to make that library automatically link in when"
6567786a6f21Smrg		    $ECHO "*** you link to this library.  But I can only do this if you have a"
6568786a6f21Smrg		    $ECHO "*** shared version of the library, which I believe you do not have"
6569786a6f21Smrg		    $ECHO "*** because a test_compile did reveal that the linker did not use it for"
6570786a6f21Smrg		    $ECHO "*** its dynamic dependency list that programs get resolved with at runtime."
6571786a6f21Smrg		  fi
6572786a6f21Smrg		fi
6573786a6f21Smrg		;;
6574786a6f21Smrg	      *)
6575786a6f21Smrg		newdeplibs="$newdeplibs $i"
6576786a6f21Smrg		;;
6577786a6f21Smrg	      esac
6578786a6f21Smrg	    done
6579786a6f21Smrg	  else
6580786a6f21Smrg	    # Error occurred in the first compile.  Let's try to salvage
6581786a6f21Smrg	    # the situation: Compile a separate program for each library.
6582786a6f21Smrg	    for i in $deplibs; do
6583786a6f21Smrg	      case $i in
6584786a6f21Smrg	      -l*)
6585786a6f21Smrg		func_stripname -l '' "$i"
6586786a6f21Smrg		name=$func_stripname_result
6587786a6f21Smrg		$opt_dry_run || $RM conftest
6588786a6f21Smrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
6589786a6f21Smrg		  ldd_output=`ldd conftest`
6590786a6f21Smrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6591786a6f21Smrg		    case " $predeps $postdeps " in
6592786a6f21Smrg		    *" $i "*)
6593786a6f21Smrg		      newdeplibs="$newdeplibs $i"
6594786a6f21Smrg		      i=""
6595786a6f21Smrg		      ;;
6596786a6f21Smrg		    esac
6597786a6f21Smrg		  fi
6598786a6f21Smrg		  if test -n "$i" ; then
6599786a6f21Smrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
6600786a6f21Smrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
6601786a6f21Smrg		    set dummy $deplib_matches; shift
6602786a6f21Smrg		    deplib_match=$1
6603786a6f21Smrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
6604786a6f21Smrg		      newdeplibs="$newdeplibs $i"
6605786a6f21Smrg		    else
6606786a6f21Smrg		      droppeddeps=yes
6607786a6f21Smrg		      $ECHO
6608786a6f21Smrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
6609786a6f21Smrg		      $ECHO "*** I have the capability to make that library automatically link in when"
6610786a6f21Smrg		      $ECHO "*** you link to this library.  But I can only do this if you have a"
6611786a6f21Smrg		      $ECHO "*** shared version of the library, which you do not appear to have"
6612786a6f21Smrg		      $ECHO "*** because a test_compile did reveal that the linker did not use this one"
6613786a6f21Smrg		      $ECHO "*** as a dynamic dependency that programs can get resolved with at runtime."
6614786a6f21Smrg		    fi
6615786a6f21Smrg		  fi
6616786a6f21Smrg		else
6617786a6f21Smrg		  droppeddeps=yes
6618786a6f21Smrg		  $ECHO
6619786a6f21Smrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
6620786a6f21Smrg		  $ECHO "*** make it link in!  You will probably need to install it or some"
6621786a6f21Smrg		  $ECHO "*** library that it depends on before this library will be fully"
6622786a6f21Smrg		  $ECHO "*** functional.  Installing it before continuing would be even better."
6623786a6f21Smrg		fi
6624786a6f21Smrg		;;
6625786a6f21Smrg	      *)
6626786a6f21Smrg		newdeplibs="$newdeplibs $i"
6627786a6f21Smrg		;;
6628786a6f21Smrg	      esac
6629786a6f21Smrg	    done
6630786a6f21Smrg	  fi
6631786a6f21Smrg	  ;;
6632786a6f21Smrg	file_magic*)
6633786a6f21Smrg	  set dummy $deplibs_check_method; shift
6634786a6f21Smrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6635786a6f21Smrg	  for a_deplib in $deplibs; do
6636786a6f21Smrg	    case $a_deplib in
6637786a6f21Smrg	    -l*)
6638786a6f21Smrg	      func_stripname -l '' "$a_deplib"
6639786a6f21Smrg	      name=$func_stripname_result
6640786a6f21Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6641786a6f21Smrg		case " $predeps $postdeps " in
6642786a6f21Smrg		*" $a_deplib "*)
6643786a6f21Smrg		  newdeplibs="$newdeplibs $a_deplib"
6644786a6f21Smrg		  a_deplib=""
6645786a6f21Smrg		  ;;
6646786a6f21Smrg		esac
6647786a6f21Smrg	      fi
6648786a6f21Smrg	      if test -n "$a_deplib" ; then
6649786a6f21Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
6650786a6f21Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
6651786a6f21Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
6652786a6f21Smrg		  for potent_lib in $potential_libs; do
6653786a6f21Smrg		      # Follow soft links.
6654786a6f21Smrg		      if ls -lLd "$potent_lib" 2>/dev/null |
6655786a6f21Smrg			 $GREP " -> " >/dev/null; then
6656786a6f21Smrg			continue
6657786a6f21Smrg		      fi
6658786a6f21Smrg		      # The statement above tries to avoid entering an
6659786a6f21Smrg		      # endless loop below, in case of cyclic links.
6660786a6f21Smrg		      # We might still enter an endless loop, since a link
6661786a6f21Smrg		      # loop can be closed while we follow links,
6662786a6f21Smrg		      # but so what?
6663786a6f21Smrg		      potlib="$potent_lib"
6664786a6f21Smrg		      while test -h "$potlib" 2>/dev/null; do
6665786a6f21Smrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
6666786a6f21Smrg			case $potliblink in
6667786a6f21Smrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
6668786a6f21Smrg			*) potlib=`$ECHO "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
6669786a6f21Smrg			esac
6670786a6f21Smrg		      done
6671786a6f21Smrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
6672786a6f21Smrg			 $SED -e 10q |
6673786a6f21Smrg			 $EGREP "$file_magic_regex" > /dev/null; then
6674786a6f21Smrg			newdeplibs="$newdeplibs $a_deplib"
6675786a6f21Smrg			a_deplib=""
6676786a6f21Smrg			break 2
6677786a6f21Smrg		      fi
6678786a6f21Smrg		  done
6679786a6f21Smrg		done
6680786a6f21Smrg	      fi
6681786a6f21Smrg	      if test -n "$a_deplib" ; then
6682786a6f21Smrg		droppeddeps=yes
6683786a6f21Smrg		$ECHO
6684786a6f21Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
6685786a6f21Smrg		$ECHO "*** I have the capability to make that library automatically link in when"
6686786a6f21Smrg		$ECHO "*** you link to this library.  But I can only do this if you have a"
6687786a6f21Smrg		$ECHO "*** shared version of the library, which you do not appear to have"
6688786a6f21Smrg		$ECHO "*** because I did check the linker path looking for a file starting"
6689786a6f21Smrg		if test -z "$potlib" ; then
6690786a6f21Smrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
6691786a6f21Smrg		else
6692786a6f21Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
6693786a6f21Smrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
6694786a6f21Smrg		fi
6695786a6f21Smrg	      fi
6696786a6f21Smrg	      ;;
6697786a6f21Smrg	    *)
6698786a6f21Smrg	      # Add a -L argument.
6699786a6f21Smrg	      newdeplibs="$newdeplibs $a_deplib"
6700786a6f21Smrg	      ;;
6701786a6f21Smrg	    esac
6702786a6f21Smrg	  done # Gone through all deplibs.
6703786a6f21Smrg	  ;;
6704786a6f21Smrg	match_pattern*)
6705786a6f21Smrg	  set dummy $deplibs_check_method; shift
6706786a6f21Smrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6707786a6f21Smrg	  for a_deplib in $deplibs; do
6708786a6f21Smrg	    case $a_deplib in
6709786a6f21Smrg	    -l*)
6710786a6f21Smrg	      func_stripname -l '' "$a_deplib"
6711786a6f21Smrg	      name=$func_stripname_result
6712786a6f21Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6713786a6f21Smrg		case " $predeps $postdeps " in
6714786a6f21Smrg		*" $a_deplib "*)
6715786a6f21Smrg		  newdeplibs="$newdeplibs $a_deplib"
6716786a6f21Smrg		  a_deplib=""
6717786a6f21Smrg		  ;;
6718786a6f21Smrg		esac
6719786a6f21Smrg	      fi
6720786a6f21Smrg	      if test -n "$a_deplib" ; then
6721786a6f21Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
6722786a6f21Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
6723786a6f21Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
6724786a6f21Smrg		  for potent_lib in $potential_libs; do
6725786a6f21Smrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
6726786a6f21Smrg		    if eval "\$ECHO \"X$potent_lib\"" 2>/dev/null | $Xsed -e 10q | \
6727786a6f21Smrg		       $EGREP "$match_pattern_regex" > /dev/null; then
6728786a6f21Smrg		      newdeplibs="$newdeplibs $a_deplib"
6729786a6f21Smrg		      a_deplib=""
6730786a6f21Smrg		      break 2
6731786a6f21Smrg		    fi
6732786a6f21Smrg		  done
6733786a6f21Smrg		done
6734786a6f21Smrg	      fi
6735786a6f21Smrg	      if test -n "$a_deplib" ; then
6736786a6f21Smrg		droppeddeps=yes
6737786a6f21Smrg		$ECHO
6738786a6f21Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
6739786a6f21Smrg		$ECHO "*** I have the capability to make that library automatically link in when"
6740786a6f21Smrg		$ECHO "*** you link to this library.  But I can only do this if you have a"
6741786a6f21Smrg		$ECHO "*** shared version of the library, which you do not appear to have"
6742786a6f21Smrg		$ECHO "*** because I did check the linker path looking for a file starting"
6743786a6f21Smrg		if test -z "$potlib" ; then
6744786a6f21Smrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
6745786a6f21Smrg		else
6746786a6f21Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
6747786a6f21Smrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
6748786a6f21Smrg		fi
6749786a6f21Smrg	      fi
6750786a6f21Smrg	      ;;
6751786a6f21Smrg	    *)
6752786a6f21Smrg	      # Add a -L argument.
6753786a6f21Smrg	      newdeplibs="$newdeplibs $a_deplib"
6754786a6f21Smrg	      ;;
6755786a6f21Smrg	    esac
6756786a6f21Smrg	  done # Gone through all deplibs.
6757786a6f21Smrg	  ;;
6758786a6f21Smrg	none | unknown | *)
6759786a6f21Smrg	  newdeplibs=""
6760786a6f21Smrg	  tmp_deplibs=`$ECHO "X $deplibs" | $Xsed \
6761786a6f21Smrg	      -e 's/ -lc$//' -e 's/ -[LR][^ ]*//g'`
6762786a6f21Smrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6763786a6f21Smrg	    for i in $predeps $postdeps ; do
6764786a6f21Smrg	      # can't use Xsed below, because $i might contain '/'
6765786a6f21Smrg	      tmp_deplibs=`$ECHO "X $tmp_deplibs" | $Xsed -e "s,$i,,"`
6766786a6f21Smrg	    done
6767786a6f21Smrg	  fi
6768786a6f21Smrg	  if $ECHO "X $tmp_deplibs" | $Xsed -e 's/[	 ]//g' |
6769786a6f21Smrg	     $GREP . >/dev/null; then
6770786a6f21Smrg	    $ECHO
6771786a6f21Smrg	    if test "X$deplibs_check_method" = "Xnone"; then
6772786a6f21Smrg	      $ECHO "*** Warning: inter-library dependencies are not supported in this platform."
6773786a6f21Smrg	    else
6774786a6f21Smrg	      $ECHO "*** Warning: inter-library dependencies are not known to be supported."
6775786a6f21Smrg	    fi
6776786a6f21Smrg	    $ECHO "*** All declared inter-library dependencies are being dropped."
6777786a6f21Smrg	    droppeddeps=yes
6778786a6f21Smrg	  fi
6779786a6f21Smrg	  ;;
6780786a6f21Smrg	esac
6781786a6f21Smrg	versuffix=$versuffix_save
6782786a6f21Smrg	major=$major_save
6783786a6f21Smrg	release=$release_save
6784786a6f21Smrg	libname=$libname_save
6785786a6f21Smrg	name=$name_save
6786786a6f21Smrg
6787786a6f21Smrg	case $host in
6788786a6f21Smrg	*-*-rhapsody* | *-*-darwin1.[012])
6789786a6f21Smrg	  # On Rhapsody replace the C library with the System framework
6790786a6f21Smrg	  newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
6791786a6f21Smrg	  ;;
6792786a6f21Smrg	esac
6793786a6f21Smrg
6794786a6f21Smrg	if test "$droppeddeps" = yes; then
6795786a6f21Smrg	  if test "$module" = yes; then
6796786a6f21Smrg	    $ECHO
6797786a6f21Smrg	    $ECHO "*** Warning: libtool could not satisfy all declared inter-library"
6798786a6f21Smrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
6799786a6f21Smrg	    $ECHO "*** a static module, that should work as long as the dlopening"
6800786a6f21Smrg	    $ECHO "*** application is linked with the -dlopen flag."
6801786a6f21Smrg	    if test -z "$global_symbol_pipe"; then
6802786a6f21Smrg	      $ECHO
6803786a6f21Smrg	      $ECHO "*** However, this would only work if libtool was able to extract symbol"
6804786a6f21Smrg	      $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
6805786a6f21Smrg	      $ECHO "*** not find such a program.  So, this module is probably useless."
6806786a6f21Smrg	      $ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
6807786a6f21Smrg	    fi
6808786a6f21Smrg	    if test "$build_old_libs" = no; then
6809786a6f21Smrg	      oldlibs="$output_objdir/$libname.$libext"
6810786a6f21Smrg	      build_libtool_libs=module
6811786a6f21Smrg	      build_old_libs=yes
6812786a6f21Smrg	    else
6813786a6f21Smrg	      build_libtool_libs=no
6814786a6f21Smrg	    fi
6815786a6f21Smrg	  else
6816786a6f21Smrg	    $ECHO "*** The inter-library dependencies that have been dropped here will be"
6817786a6f21Smrg	    $ECHO "*** automatically added whenever a program is linked with this library"
6818786a6f21Smrg	    $ECHO "*** or is declared to -dlopen it."
6819786a6f21Smrg
6820786a6f21Smrg	    if test "$allow_undefined" = no; then
6821786a6f21Smrg	      $ECHO
6822786a6f21Smrg	      $ECHO "*** Since this library must not contain undefined symbols,"
6823786a6f21Smrg	      $ECHO "*** because either the platform does not support them or"
6824786a6f21Smrg	      $ECHO "*** it was explicitly requested with -no-undefined,"
6825786a6f21Smrg	      $ECHO "*** libtool will only create a static version of it."
6826786a6f21Smrg	      if test "$build_old_libs" = no; then
6827786a6f21Smrg		oldlibs="$output_objdir/$libname.$libext"
6828786a6f21Smrg		build_libtool_libs=module
6829786a6f21Smrg		build_old_libs=yes
6830786a6f21Smrg	      else
6831786a6f21Smrg		build_libtool_libs=no
6832786a6f21Smrg	      fi
6833786a6f21Smrg	    fi
6834786a6f21Smrg	  fi
68351d54945dSmrg	fi
6836786a6f21Smrg	# Done checking deplibs!
6837786a6f21Smrg	deplibs=$newdeplibs
6838786a6f21Smrg      fi
6839786a6f21Smrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
6840786a6f21Smrg      case $host in
6841786a6f21Smrg	*-*-darwin*)
6842786a6f21Smrg	  newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
6843786a6f21Smrg	  new_inherited_linker_flags=`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
6844786a6f21Smrg	  deplibs=`$ECHO "X $deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
68451d54945dSmrg	  ;;
6846786a6f21Smrg      esac
68471d54945dSmrg
6848786a6f21Smrg      # move library search paths that coincide with paths to not yet
6849786a6f21Smrg      # installed libraries to the beginning of the library search list
6850786a6f21Smrg      new_libs=
6851786a6f21Smrg      for path in $notinst_path; do
6852786a6f21Smrg	case " $new_libs " in
6853786a6f21Smrg	*" -L$path/$objdir "*) ;;
68541d54945dSmrg	*)
6855786a6f21Smrg	  case " $deplibs " in
6856786a6f21Smrg	  *" -L$path/$objdir "*)
6857786a6f21Smrg	    new_libs="$new_libs -L$path/$objdir" ;;
6858786a6f21Smrg	  esac
68591d54945dSmrg	  ;;
68601d54945dSmrg	esac
6861786a6f21Smrg      done
6862786a6f21Smrg      for deplib in $deplibs; do
6863786a6f21Smrg	case $deplib in
6864786a6f21Smrg	-L*)
6865786a6f21Smrg	  case " $new_libs " in
6866786a6f21Smrg	  *" $deplib "*) ;;
6867786a6f21Smrg	  *) new_libs="$new_libs $deplib" ;;
6868786a6f21Smrg	  esac
6869786a6f21Smrg	  ;;
6870786a6f21Smrg	*) new_libs="$new_libs $deplib" ;;
6871786a6f21Smrg	esac
6872786a6f21Smrg      done
6873786a6f21Smrg      deplibs="$new_libs"
68741d54945dSmrg
6875786a6f21Smrg      # All the library-specific variables (install_libdir is set above).
6876786a6f21Smrg      library_names=
6877786a6f21Smrg      old_library=
6878786a6f21Smrg      dlname=
68791d54945dSmrg
6880786a6f21Smrg      # Test again, we may have decided not to build it any more
6881786a6f21Smrg      if test "$build_libtool_libs" = yes; then
6882786a6f21Smrg	if test "$hardcode_into_libs" = yes; then
6883786a6f21Smrg	  # Hardcode the library paths
6884786a6f21Smrg	  hardcode_libdirs=
6885786a6f21Smrg	  dep_rpath=
6886786a6f21Smrg	  rpath="$finalize_rpath"
6887786a6f21Smrg	  test "$mode" != relink && rpath="$compile_rpath$rpath"
6888786a6f21Smrg	  for libdir in $rpath; do
6889786a6f21Smrg	    if test -n "$hardcode_libdir_flag_spec"; then
6890786a6f21Smrg	      if test -n "$hardcode_libdir_separator"; then
6891786a6f21Smrg		if test -z "$hardcode_libdirs"; then
6892786a6f21Smrg		  hardcode_libdirs="$libdir"
6893786a6f21Smrg		else
6894786a6f21Smrg		  # Just accumulate the unique libdirs.
6895786a6f21Smrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
6896786a6f21Smrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
6897786a6f21Smrg		    ;;
6898786a6f21Smrg		  *)
6899786a6f21Smrg		    hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
6900786a6f21Smrg		    ;;
6901786a6f21Smrg		  esac
6902786a6f21Smrg		fi
6903786a6f21Smrg	      else
6904786a6f21Smrg		eval flag=\"$hardcode_libdir_flag_spec\"
6905786a6f21Smrg		dep_rpath="$dep_rpath $flag"
6906786a6f21Smrg	      fi
6907786a6f21Smrg	    elif test -n "$runpath_var"; then
6908786a6f21Smrg	      case "$perm_rpath " in
6909786a6f21Smrg	      *" $libdir "*) ;;
6910786a6f21Smrg	      *) perm_rpath="$perm_rpath $libdir" ;;
6911786a6f21Smrg	      esac
6912786a6f21Smrg	    fi
6913786a6f21Smrg	  done
6914786a6f21Smrg	  # Substitute the hardcoded libdirs into the rpath.
6915786a6f21Smrg	  if test -n "$hardcode_libdir_separator" &&
6916786a6f21Smrg	     test -n "$hardcode_libdirs"; then
6917786a6f21Smrg	    libdir="$hardcode_libdirs"
6918786a6f21Smrg	    if test -n "$hardcode_libdir_flag_spec_ld"; then
6919786a6f21Smrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
6920786a6f21Smrg	    else
6921786a6f21Smrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
6922786a6f21Smrg	    fi
6923786a6f21Smrg	  fi
6924786a6f21Smrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
6925786a6f21Smrg	    # We should set the runpath_var.
6926786a6f21Smrg	    rpath=
6927786a6f21Smrg	    for dir in $perm_rpath; do
6928786a6f21Smrg	      rpath="$rpath$dir:"
6929786a6f21Smrg	    done
6930786a6f21Smrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
6931786a6f21Smrg	  fi
6932786a6f21Smrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
69331d54945dSmrg	fi
69341d54945dSmrg
6935786a6f21Smrg	shlibpath="$finalize_shlibpath"
6936786a6f21Smrg	test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
6937786a6f21Smrg	if test -n "$shlibpath"; then
6938786a6f21Smrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
6939786a6f21Smrg	fi
69401d54945dSmrg
6941786a6f21Smrg	# Get the real and link names of the library.
6942786a6f21Smrg	eval shared_ext=\"$shrext_cmds\"
6943786a6f21Smrg	eval library_names=\"$library_names_spec\"
6944786a6f21Smrg	set dummy $library_names
6945786a6f21Smrg	shift
6946786a6f21Smrg	realname="$1"
6947786a6f21Smrg	shift
69481d54945dSmrg
6949786a6f21Smrg	if test -n "$soname_spec"; then
6950786a6f21Smrg	  eval soname=\"$soname_spec\"
69511d54945dSmrg	else
6952786a6f21Smrg	  soname="$realname"
6953786a6f21Smrg	fi
6954786a6f21Smrg	if test -z "$dlname"; then
6955786a6f21Smrg	  dlname=$soname
6956786a6f21Smrg	fi
69571d54945dSmrg
6958786a6f21Smrg	lib="$output_objdir/$realname"
6959786a6f21Smrg	linknames=
6960786a6f21Smrg	for link
6961786a6f21Smrg	do
6962786a6f21Smrg	  linknames="$linknames $link"
6963786a6f21Smrg	done
6964786a6f21Smrg
6965786a6f21Smrg	# Use standard objects if they are pic
6966786a6f21Smrg	test -z "$pic_flag" && libobjs=`$ECHO "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
6967786a6f21Smrg	test "X$libobjs" = "X " && libobjs=
6968786a6f21Smrg
6969786a6f21Smrg	delfiles=
6970786a6f21Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
6971786a6f21Smrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
6972786a6f21Smrg	  export_symbols="$output_objdir/$libname.uexp"
6973786a6f21Smrg	  delfiles="$delfiles $export_symbols"
6974786a6f21Smrg	fi
69751d54945dSmrg
6976786a6f21Smrg	orig_export_symbols=
6977786a6f21Smrg	case $host_os in
6978786a6f21Smrg	cygwin* | mingw* | cegcc*)
6979786a6f21Smrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
6980786a6f21Smrg	    # exporting using user supplied symfile
6981786a6f21Smrg	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
6982786a6f21Smrg	      # and it's NOT already a .def file. Must figure out
6983786a6f21Smrg	      # which of the given symbols are data symbols and tag
6984786a6f21Smrg	      # them as such. So, trigger use of export_symbols_cmds.
6985786a6f21Smrg	      # export_symbols gets reassigned inside the "prepare
6986786a6f21Smrg	      # the list of exported symbols" if statement, so the
6987786a6f21Smrg	      # include_expsyms logic still works.
6988786a6f21Smrg	      orig_export_symbols="$export_symbols"
6989786a6f21Smrg	      export_symbols=
6990786a6f21Smrg	      always_export_symbols=yes
69911d54945dSmrg	    fi
69921d54945dSmrg	  fi
6993786a6f21Smrg	  ;;
6994786a6f21Smrg	esac
69951d54945dSmrg
6996786a6f21Smrg	# Prepare the list of exported symbols
6997786a6f21Smrg	if test -z "$export_symbols"; then
6998786a6f21Smrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
6999786a6f21Smrg	    func_verbose "generating symbol list for \`$libname.la'"
7000786a6f21Smrg	    export_symbols="$output_objdir/$libname.exp"
7001786a6f21Smrg	    $opt_dry_run || $RM $export_symbols
7002786a6f21Smrg	    cmds=$export_symbols_cmds
7003786a6f21Smrg	    save_ifs="$IFS"; IFS='~'
7004786a6f21Smrg	    for cmd in $cmds; do
7005786a6f21Smrg	      IFS="$save_ifs"
7006786a6f21Smrg	      eval cmd=\"$cmd\"
7007786a6f21Smrg	      func_len " $cmd"
7008786a6f21Smrg	      len=$func_len_result
7009786a6f21Smrg	      if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
7010786a6f21Smrg		func_show_eval "$cmd" 'exit $?'
7011786a6f21Smrg		skipped_export=false
7012786a6f21Smrg	      else
7013786a6f21Smrg		# The command line is too long to execute in one step.
7014786a6f21Smrg		func_verbose "using reloadable object file for export list..."
7015786a6f21Smrg		skipped_export=:
7016786a6f21Smrg		# Break out early, otherwise skipped_export may be
7017786a6f21Smrg		# set to false by a later but shorter cmd.
7018786a6f21Smrg		break
7019786a6f21Smrg	      fi
7020786a6f21Smrg	    done
7021786a6f21Smrg	    IFS="$save_ifs"
7022786a6f21Smrg	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
7023786a6f21Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
7024786a6f21Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
7025786a6f21Smrg	    fi
7026786a6f21Smrg	  fi
70271d54945dSmrg	fi
70281d54945dSmrg
7029786a6f21Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
7030786a6f21Smrg	  tmp_export_symbols="$export_symbols"
7031786a6f21Smrg	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
7032786a6f21Smrg	  $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
7033786a6f21Smrg	fi
70341d54945dSmrg
7035786a6f21Smrg	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
7036786a6f21Smrg	  # The given exports_symbols file has to be filtered, so filter it.
7037786a6f21Smrg	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
7038786a6f21Smrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
7039786a6f21Smrg	  # 's' commands which not all seds can handle. GNU sed should be fine
7040786a6f21Smrg	  # though. Also, the filter scales superlinearly with the number of
7041786a6f21Smrg	  # global variables. join(1) would be nice here, but unfortunately
7042786a6f21Smrg	  # isn't a blessed tool.
7043786a6f21Smrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
7044786a6f21Smrg	  delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
7045786a6f21Smrg	  export_symbols=$output_objdir/$libname.def
7046786a6f21Smrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
7047786a6f21Smrg	fi
70481d54945dSmrg
7049786a6f21Smrg	tmp_deplibs=
7050786a6f21Smrg	for test_deplib in $deplibs; do
7051786a6f21Smrg	  case " $convenience " in
7052786a6f21Smrg	  *" $test_deplib "*) ;;
7053786a6f21Smrg	  *)
7054786a6f21Smrg	    tmp_deplibs="$tmp_deplibs $test_deplib"
7055786a6f21Smrg	    ;;
7056786a6f21Smrg	  esac
7057786a6f21Smrg	done
7058786a6f21Smrg	deplibs="$tmp_deplibs"
7059786a6f21Smrg
7060786a6f21Smrg	if test -n "$convenience"; then
7061786a6f21Smrg	  if test -n "$whole_archive_flag_spec" &&
7062786a6f21Smrg	    test "$compiler_needs_object" = yes &&
7063786a6f21Smrg	    test -z "$libobjs"; then
7064786a6f21Smrg	    # extract the archives, so we have objects to list.
7065786a6f21Smrg	    # TODO: could optimize this to just extract one archive.
7066786a6f21Smrg	    whole_archive_flag_spec=
7067786a6f21Smrg	  fi
7068786a6f21Smrg	  if test -n "$whole_archive_flag_spec"; then
7069786a6f21Smrg	    save_libobjs=$libobjs
7070786a6f21Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
7071786a6f21Smrg	    test "X$libobjs" = "X " && libobjs=
70721d54945dSmrg	  else
7073786a6f21Smrg	    gentop="$output_objdir/${outputname}x"
7074786a6f21Smrg	    generated="$generated $gentop"
7075786a6f21Smrg
7076786a6f21Smrg	    func_extract_archives $gentop $convenience
7077786a6f21Smrg	    libobjs="$libobjs $func_extract_archives_result"
7078786a6f21Smrg	    test "X$libobjs" = "X " && libobjs=
70791d54945dSmrg	  fi
70801d54945dSmrg	fi
70811d54945dSmrg
7082786a6f21Smrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
7083786a6f21Smrg	  eval flag=\"$thread_safe_flag_spec\"
7084786a6f21Smrg	  linker_flags="$linker_flags $flag"
7085786a6f21Smrg	fi
70861d54945dSmrg
7087786a6f21Smrg	# Make a backup of the uninstalled library when relinking
7088786a6f21Smrg	if test "$mode" = relink; then
7089786a6f21Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
7090786a6f21Smrg	fi
70911d54945dSmrg
7092786a6f21Smrg	# Do each of the archive commands.
7093786a6f21Smrg	if test "$module" = yes && test -n "$module_cmds" ; then
7094786a6f21Smrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
7095786a6f21Smrg	    eval test_cmds=\"$module_expsym_cmds\"
7096786a6f21Smrg	    cmds=$module_expsym_cmds
7097786a6f21Smrg	  else
7098786a6f21Smrg	    eval test_cmds=\"$module_cmds\"
7099786a6f21Smrg	    cmds=$module_cmds
7100786a6f21Smrg	  fi
71011d54945dSmrg	else
7102786a6f21Smrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
7103786a6f21Smrg	    eval test_cmds=\"$archive_expsym_cmds\"
7104786a6f21Smrg	    cmds=$archive_expsym_cmds
7105786a6f21Smrg	  else
7106786a6f21Smrg	    eval test_cmds=\"$archive_cmds\"
7107786a6f21Smrg	    cmds=$archive_cmds
7108786a6f21Smrg	  fi
71091d54945dSmrg	fi
71101d54945dSmrg
7111786a6f21Smrg	if test "X$skipped_export" != "X:" &&
7112786a6f21Smrg	   func_len " $test_cmds" &&
7113786a6f21Smrg	   len=$func_len_result &&
7114786a6f21Smrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
7115786a6f21Smrg	  :
7116786a6f21Smrg	else
7117786a6f21Smrg	  # The command line is too long to link in one step, link piecewise
7118786a6f21Smrg	  # or, if using GNU ld and skipped_export is not :, use a linker
7119786a6f21Smrg	  # script.
71201d54945dSmrg
7121786a6f21Smrg	  # Save the value of $output and $libobjs because we want to
7122786a6f21Smrg	  # use them later.  If we have whole_archive_flag_spec, we
7123786a6f21Smrg	  # want to use save_libobjs as it was before
7124786a6f21Smrg	  # whole_archive_flag_spec was expanded, because we can't
7125786a6f21Smrg	  # assume the linker understands whole_archive_flag_spec.
7126786a6f21Smrg	  # This may have to be revisited, in case too many
7127786a6f21Smrg	  # convenience libraries get linked in and end up exceeding
7128786a6f21Smrg	  # the spec.
7129786a6f21Smrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
7130786a6f21Smrg	    save_libobjs=$libobjs
7131786a6f21Smrg	  fi
7132786a6f21Smrg	  save_output=$output
7133786a6f21Smrg	  output_la=`$ECHO "X$output" | $Xsed -e "$basename"`
7134786a6f21Smrg
7135786a6f21Smrg	  # Clear the reloadable object creation command queue and
7136786a6f21Smrg	  # initialize k to one.
7137786a6f21Smrg	  test_cmds=
7138786a6f21Smrg	  concat_cmds=
7139786a6f21Smrg	  objlist=
7140786a6f21Smrg	  last_robj=
7141786a6f21Smrg	  k=1
7142786a6f21Smrg
7143786a6f21Smrg	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
7144786a6f21Smrg	    output=${output_objdir}/${output_la}.lnkscript
7145786a6f21Smrg	    func_verbose "creating GNU ld script: $output"
7146786a6f21Smrg	    $ECHO 'INPUT (' > $output
7147786a6f21Smrg	    for obj in $save_libobjs
7148786a6f21Smrg	    do
7149786a6f21Smrg	      $ECHO "$obj" >> $output
7150786a6f21Smrg	    done
7151786a6f21Smrg	    $ECHO ')' >> $output
7152786a6f21Smrg	    delfiles="$delfiles $output"
7153786a6f21Smrg	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
7154786a6f21Smrg	    output=${output_objdir}/${output_la}.lnk
7155786a6f21Smrg	    func_verbose "creating linker input file list: $output"
7156786a6f21Smrg	    : > $output
7157786a6f21Smrg	    set x $save_libobjs
7158786a6f21Smrg	    shift
7159786a6f21Smrg	    firstobj=
7160786a6f21Smrg	    if test "$compiler_needs_object" = yes; then
7161786a6f21Smrg	      firstobj="$1 "
7162786a6f21Smrg	      shift
71631d54945dSmrg	    fi
7164786a6f21Smrg	    for obj
7165786a6f21Smrg	    do
7166786a6f21Smrg	      $ECHO "$obj" >> $output
71671d54945dSmrg	    done
7168786a6f21Smrg	    delfiles="$delfiles $output"
7169786a6f21Smrg	    output=$firstobj\"$file_list_spec$output\"
7170786a6f21Smrg	  else
7171786a6f21Smrg	    if test -n "$save_libobjs"; then
7172786a6f21Smrg	      func_verbose "creating reloadable object files..."
7173786a6f21Smrg	      output=$output_objdir/$output_la-${k}.$objext
7174786a6f21Smrg	      eval test_cmds=\"$reload_cmds\"
7175786a6f21Smrg	      func_len " $test_cmds"
7176786a6f21Smrg	      len0=$func_len_result
7177786a6f21Smrg	      len=$len0
7178786a6f21Smrg
7179786a6f21Smrg	      # Loop over the list of objects to be linked.
7180786a6f21Smrg	      for obj in $save_libobjs
7181786a6f21Smrg	      do
7182786a6f21Smrg		func_len " $obj"
7183786a6f21Smrg		func_arith $len + $func_len_result
7184786a6f21Smrg		len=$func_arith_result
7185786a6f21Smrg		if test "X$objlist" = X ||
7186786a6f21Smrg		   test "$len" -lt "$max_cmd_len"; then
7187786a6f21Smrg		  func_append objlist " $obj"
7188786a6f21Smrg		else
7189786a6f21Smrg		  # The command $test_cmds is almost too long, add a
7190786a6f21Smrg		  # command to the queue.
7191786a6f21Smrg		  if test "$k" -eq 1 ; then
7192786a6f21Smrg		    # The first file doesn't have a previous command to add.
7193786a6f21Smrg		    eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
7194786a6f21Smrg		  else
7195786a6f21Smrg		    # All subsequent reloadable object files will link in
7196786a6f21Smrg		    # the last one created.
7197786a6f21Smrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj~\$RM $last_robj\"
7198786a6f21Smrg		  fi
7199786a6f21Smrg		  last_robj=$output_objdir/$output_la-${k}.$objext
7200786a6f21Smrg		  func_arith $k + 1
7201786a6f21Smrg		  k=$func_arith_result
7202786a6f21Smrg		  output=$output_objdir/$output_la-${k}.$objext
7203786a6f21Smrg		  objlist=$obj
7204786a6f21Smrg		  func_len " $last_robj"
7205786a6f21Smrg		  func_arith $len0 + $func_len_result
7206786a6f21Smrg		  len=$func_arith_result
7207786a6f21Smrg		fi
7208786a6f21Smrg	      done
7209786a6f21Smrg	      # Handle the remaining objects by creating one last
7210786a6f21Smrg	      # reloadable object file.  All subsequent reloadable object
7211786a6f21Smrg	      # files will link in the last one created.
7212786a6f21Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
7213786a6f21Smrg	      eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
7214786a6f21Smrg	      if test -n "$last_robj"; then
7215786a6f21Smrg	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
72161d54945dSmrg	      fi
7217786a6f21Smrg	      delfiles="$delfiles $output"
7218786a6f21Smrg
7219786a6f21Smrg	    else
7220786a6f21Smrg	      output=
7221786a6f21Smrg	    fi
7222786a6f21Smrg
7223786a6f21Smrg	    if ${skipped_export-false}; then
7224786a6f21Smrg	      func_verbose "generating symbol list for \`$libname.la'"
7225786a6f21Smrg	      export_symbols="$output_objdir/$libname.exp"
7226786a6f21Smrg	      $opt_dry_run || $RM $export_symbols
7227786a6f21Smrg	      libobjs=$output
7228786a6f21Smrg	      # Append the command to create the export file.
7229786a6f21Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
7230786a6f21Smrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
7231786a6f21Smrg	      if test -n "$last_robj"; then
7232786a6f21Smrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
72331d54945dSmrg	      fi
7234786a6f21Smrg	    fi
7235786a6f21Smrg
7236786a6f21Smrg	    test -n "$save_libobjs" &&
7237786a6f21Smrg	      func_verbose "creating a temporary reloadable object file: $output"
7238786a6f21Smrg
7239786a6f21Smrg	    # Loop through the commands generated above and execute them.
7240786a6f21Smrg	    save_ifs="$IFS"; IFS='~'
7241786a6f21Smrg	    for cmd in $concat_cmds; do
7242786a6f21Smrg	      IFS="$save_ifs"
7243786a6f21Smrg	      $opt_silent || {
7244786a6f21Smrg		  func_quote_for_expand "$cmd"
7245786a6f21Smrg		  eval "func_echo $func_quote_for_expand_result"
7246786a6f21Smrg	      }
7247786a6f21Smrg	      $opt_dry_run || eval "$cmd" || {
7248786a6f21Smrg		lt_exit=$?
7249786a6f21Smrg
7250786a6f21Smrg		# Restore the uninstalled library and exit
7251786a6f21Smrg		if test "$mode" = relink; then
7252786a6f21Smrg		  ( cd "$output_objdir" && \
7253786a6f21Smrg		    $RM "${realname}T" && \
7254786a6f21Smrg		    $MV "${realname}U" "$realname" )
7255786a6f21Smrg		fi
7256786a6f21Smrg
7257786a6f21Smrg		exit $lt_exit
7258786a6f21Smrg	      }
72591d54945dSmrg	    done
7260786a6f21Smrg	    IFS="$save_ifs"
7261786a6f21Smrg
7262786a6f21Smrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
7263786a6f21Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
7264786a6f21Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
7265786a6f21Smrg	    fi
72661d54945dSmrg	  fi
72671d54945dSmrg
7268786a6f21Smrg          if ${skipped_export-false}; then
7269786a6f21Smrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
7270786a6f21Smrg	      tmp_export_symbols="$export_symbols"
7271786a6f21Smrg	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
7272786a6f21Smrg	      $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
7273786a6f21Smrg	    fi
72741d54945dSmrg
7275786a6f21Smrg	    if test -n "$orig_export_symbols"; then
7276786a6f21Smrg	      # The given exports_symbols file has to be filtered, so filter it.
7277786a6f21Smrg	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
7278786a6f21Smrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
7279786a6f21Smrg	      # 's' commands which not all seds can handle. GNU sed should be fine
7280786a6f21Smrg	      # though. Also, the filter scales superlinearly with the number of
7281786a6f21Smrg	      # global variables. join(1) would be nice here, but unfortunately
7282786a6f21Smrg	      # isn't a blessed tool.
7283786a6f21Smrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
7284786a6f21Smrg	      delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
7285786a6f21Smrg	      export_symbols=$output_objdir/$libname.def
7286786a6f21Smrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
7287786a6f21Smrg	    fi
7288786a6f21Smrg	  fi
72891d54945dSmrg
7290786a6f21Smrg	  libobjs=$output
7291786a6f21Smrg	  # Restore the value of output.
7292786a6f21Smrg	  output=$save_output
72931d54945dSmrg
7294786a6f21Smrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
7295786a6f21Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
7296786a6f21Smrg	    test "X$libobjs" = "X " && libobjs=
7297786a6f21Smrg	  fi
7298786a6f21Smrg	  # Expand the library linking commands again to reset the
7299786a6f21Smrg	  # value of $libobjs for piecewise linking.
73001d54945dSmrg
7301786a6f21Smrg	  # Do each of the archive commands.
7302786a6f21Smrg	  if test "$module" = yes && test -n "$module_cmds" ; then
7303786a6f21Smrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
7304786a6f21Smrg	      cmds=$module_expsym_cmds
7305786a6f21Smrg	    else
7306786a6f21Smrg	      cmds=$module_cmds
7307786a6f21Smrg	    fi
7308786a6f21Smrg	  else
7309786a6f21Smrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
7310786a6f21Smrg	      cmds=$archive_expsym_cmds
7311786a6f21Smrg	    else
7312786a6f21Smrg	      cmds=$archive_cmds
7313786a6f21Smrg	    fi
7314786a6f21Smrg	  fi
7315786a6f21Smrg	fi
73161d54945dSmrg
7317786a6f21Smrg	if test -n "$delfiles"; then
7318786a6f21Smrg	  # Append the command to remove temporary files to $cmds.
7319786a6f21Smrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
7320786a6f21Smrg	fi
73211d54945dSmrg
7322786a6f21Smrg	# Add any objects from preloaded convenience libraries
7323786a6f21Smrg	if test -n "$dlprefiles"; then
7324786a6f21Smrg	  gentop="$output_objdir/${outputname}x"
7325786a6f21Smrg	  generated="$generated $gentop"
73261d54945dSmrg
7327786a6f21Smrg	  func_extract_archives $gentop $dlprefiles
7328786a6f21Smrg	  libobjs="$libobjs $func_extract_archives_result"
7329786a6f21Smrg	  test "X$libobjs" = "X " && libobjs=
7330786a6f21Smrg	fi
73311d54945dSmrg
7332786a6f21Smrg	save_ifs="$IFS"; IFS='~'
7333786a6f21Smrg	for cmd in $cmds; do
7334786a6f21Smrg	  IFS="$save_ifs"
7335786a6f21Smrg	  eval cmd=\"$cmd\"
7336786a6f21Smrg	  $opt_silent || {
7337786a6f21Smrg	    func_quote_for_expand "$cmd"
7338786a6f21Smrg	    eval "func_echo $func_quote_for_expand_result"
7339786a6f21Smrg	  }
7340786a6f21Smrg	  $opt_dry_run || eval "$cmd" || {
7341786a6f21Smrg	    lt_exit=$?
7342786a6f21Smrg
7343786a6f21Smrg	    # Restore the uninstalled library and exit
7344786a6f21Smrg	    if test "$mode" = relink; then
7345786a6f21Smrg	      ( cd "$output_objdir" && \
7346786a6f21Smrg	        $RM "${realname}T" && \
7347786a6f21Smrg		$MV "${realname}U" "$realname" )
7348786a6f21Smrg	    fi
7349786a6f21Smrg
7350786a6f21Smrg	    exit $lt_exit
7351786a6f21Smrg	  }
73521d54945dSmrg	done
7353786a6f21Smrg	IFS="$save_ifs"
73541d54945dSmrg
7355786a6f21Smrg	# Restore the uninstalled library and exit
7356786a6f21Smrg	if test "$mode" = relink; then
7357786a6f21Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
73581d54945dSmrg
7359786a6f21Smrg	  if test -n "$convenience"; then
7360786a6f21Smrg	    if test -z "$whole_archive_flag_spec"; then
7361786a6f21Smrg	      func_show_eval '${RM}r "$gentop"'
7362786a6f21Smrg	    fi
7363786a6f21Smrg	  fi
73641d54945dSmrg
7365786a6f21Smrg	  exit $EXIT_SUCCESS
7366786a6f21Smrg	fi
73671d54945dSmrg
7368786a6f21Smrg	# Create links to the real library.
7369786a6f21Smrg	for linkname in $linknames; do
7370786a6f21Smrg	  if test "$realname" != "$linkname"; then
7371786a6f21Smrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
7372786a6f21Smrg	  fi
7373786a6f21Smrg	done
7374786a6f21Smrg
7375786a6f21Smrg	# If -module or -export-dynamic was specified, set the dlname.
7376786a6f21Smrg	if test "$module" = yes || test "$export_dynamic" = yes; then
7377786a6f21Smrg	  # On all known operating systems, these are identical.
7378786a6f21Smrg	  dlname="$soname"
7379786a6f21Smrg	fi
7380786a6f21Smrg      fi
73811d54945dSmrg      ;;
73821d54945dSmrg
7383786a6f21Smrg    obj)
7384786a6f21Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
7385786a6f21Smrg	func_warning "\`-dlopen' is ignored for objects"
73861d54945dSmrg      fi
73871d54945dSmrg
7388786a6f21Smrg      case " $deplibs" in
7389786a6f21Smrg      *\ -l* | *\ -L*)
7390786a6f21Smrg	func_warning "\`-l' and \`-L' are ignored for objects" ;;
7391786a6f21Smrg      esac
7392786a6f21Smrg
7393786a6f21Smrg      test -n "$rpath" && \
7394786a6f21Smrg	func_warning "\`-rpath' is ignored for objects"
7395786a6f21Smrg
7396786a6f21Smrg      test -n "$xrpath" && \
7397786a6f21Smrg	func_warning "\`-R' is ignored for objects"
7398786a6f21Smrg
7399786a6f21Smrg      test -n "$vinfo" && \
7400786a6f21Smrg	func_warning "\`-version-info' is ignored for objects"
7401786a6f21Smrg
7402786a6f21Smrg      test -n "$release" && \
7403786a6f21Smrg	func_warning "\`-release' is ignored for objects"
7404786a6f21Smrg
7405786a6f21Smrg      case $output in
7406786a6f21Smrg      *.lo)
7407786a6f21Smrg	test -n "$objs$old_deplibs" && \
7408786a6f21Smrg	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
7409786a6f21Smrg
7410786a6f21Smrg	libobj=$output
7411786a6f21Smrg	func_lo2o "$libobj"
7412786a6f21Smrg	obj=$func_lo2o_result
74131d54945dSmrg	;;
74141d54945dSmrg      *)
7415786a6f21Smrg	libobj=
7416786a6f21Smrg	obj="$output"
74171d54945dSmrg	;;
74181d54945dSmrg      esac
74191d54945dSmrg
7420786a6f21Smrg      # Delete the old objects.
7421786a6f21Smrg      $opt_dry_run || $RM $obj $libobj
74221d54945dSmrg
7423786a6f21Smrg      # Objects from convenience libraries.  This assumes
7424786a6f21Smrg      # single-version convenience libraries.  Whenever we create
7425786a6f21Smrg      # different ones for PIC/non-PIC, this we'll have to duplicate
7426786a6f21Smrg      # the extraction.
7427786a6f21Smrg      reload_conv_objs=
7428786a6f21Smrg      gentop=
7429786a6f21Smrg      # reload_cmds runs $LD directly, so let us get rid of
7430786a6f21Smrg      # -Wl from whole_archive_flag_spec and hope we can get by with
7431786a6f21Smrg      # turning comma into space..
7432786a6f21Smrg      wl=
74331d54945dSmrg
7434786a6f21Smrg      if test -n "$convenience"; then
7435786a6f21Smrg	if test -n "$whole_archive_flag_spec"; then
7436786a6f21Smrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
7437786a6f21Smrg	  reload_conv_objs=$reload_objs\ `$ECHO "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'`
7438786a6f21Smrg	else
7439786a6f21Smrg	  gentop="$output_objdir/${obj}x"
7440786a6f21Smrg	  generated="$generated $gentop"
74411d54945dSmrg
7442786a6f21Smrg	  func_extract_archives $gentop $convenience
7443786a6f21Smrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
7444786a6f21Smrg	fi
74451d54945dSmrg      fi
74461d54945dSmrg
7447786a6f21Smrg      # Create the old-style object.
7448786a6f21Smrg      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
74491d54945dSmrg
7450786a6f21Smrg      output="$obj"
7451786a6f21Smrg      func_execute_cmds "$reload_cmds" 'exit $?'
74521d54945dSmrg
7453786a6f21Smrg      # Exit if we aren't doing a library object file.
7454786a6f21Smrg      if test -z "$libobj"; then
7455786a6f21Smrg	if test -n "$gentop"; then
7456786a6f21Smrg	  func_show_eval '${RM}r "$gentop"'
7457786a6f21Smrg	fi
7458786a6f21Smrg
7459786a6f21Smrg	exit $EXIT_SUCCESS
74601d54945dSmrg      fi
7461786a6f21Smrg
7462786a6f21Smrg      if test "$build_libtool_libs" != yes; then
7463786a6f21Smrg	if test -n "$gentop"; then
7464786a6f21Smrg	  func_show_eval '${RM}r "$gentop"'
7465786a6f21Smrg	fi
7466786a6f21Smrg
7467786a6f21Smrg	# Create an invalid libtool object if no PIC, so that we don't
7468786a6f21Smrg	# accidentally link it into a program.
7469786a6f21Smrg	# $show "echo timestamp > $libobj"
7470786a6f21Smrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
7471786a6f21Smrg	exit $EXIT_SUCCESS
7472786a6f21Smrg      fi
7473786a6f21Smrg
7474786a6f21Smrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
7475786a6f21Smrg	# Only do commands if we really have different PIC objects.
7476786a6f21Smrg	reload_objs="$libobjs $reload_conv_objs"
7477786a6f21Smrg	output="$libobj"
7478786a6f21Smrg	func_execute_cmds "$reload_cmds" 'exit $?'
7479786a6f21Smrg      fi
7480786a6f21Smrg
7481786a6f21Smrg      if test -n "$gentop"; then
7482786a6f21Smrg	func_show_eval '${RM}r "$gentop"'
7483786a6f21Smrg      fi
7484786a6f21Smrg
7485786a6f21Smrg      exit $EXIT_SUCCESS
74861d54945dSmrg      ;;
74871d54945dSmrg
7488786a6f21Smrg    prog)
7489786a6f21Smrg      case $host in
7490786a6f21Smrg	*cygwin*) func_stripname '' '.exe' "$output"
7491786a6f21Smrg	          output=$func_stripname_result.exe;;
7492786a6f21Smrg      esac
7493786a6f21Smrg      test -n "$vinfo" && \
7494786a6f21Smrg	func_warning "\`-version-info' is ignored for programs"
74951d54945dSmrg
7496786a6f21Smrg      test -n "$release" && \
7497786a6f21Smrg	func_warning "\`-release' is ignored for programs"
74981d54945dSmrg
7499786a6f21Smrg      test "$preload" = yes \
7500786a6f21Smrg        && test "$dlopen_support" = unknown \
7501786a6f21Smrg	&& test "$dlopen_self" = unknown \
7502786a6f21Smrg	&& test "$dlopen_self_static" = unknown && \
7503786a6f21Smrg	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
7504786a6f21Smrg
7505786a6f21Smrg      case $host in
7506786a6f21Smrg      *-*-rhapsody* | *-*-darwin1.[012])
7507786a6f21Smrg	# On Rhapsody replace the C library is the System framework
7508786a6f21Smrg	compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
7509786a6f21Smrg	finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
75101d54945dSmrg	;;
7511786a6f21Smrg      esac
75121d54945dSmrg
7513786a6f21Smrg      case $host in
7514786a6f21Smrg      *-*-darwin*)
7515786a6f21Smrg	# Don't allow lazy linking, it breaks C++ global constructors
7516786a6f21Smrg	# But is supposedly fixed on 10.4 or later (yay!).
7517786a6f21Smrg	if test "$tagname" = CXX ; then
7518786a6f21Smrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
7519786a6f21Smrg	    10.[0123])
7520786a6f21Smrg	      compile_command="$compile_command ${wl}-bind_at_load"
7521786a6f21Smrg	      finalize_command="$finalize_command ${wl}-bind_at_load"
7522786a6f21Smrg	    ;;
7523786a6f21Smrg	  esac
75241d54945dSmrg	fi
7525786a6f21Smrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
7526786a6f21Smrg	compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
7527786a6f21Smrg	finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
7528786a6f21Smrg	;;
7529786a6f21Smrg      esac
75301d54945dSmrg
75311d54945dSmrg
7532786a6f21Smrg      # move library search paths that coincide with paths to not yet
7533786a6f21Smrg      # installed libraries to the beginning of the library search list
7534786a6f21Smrg      new_libs=
7535786a6f21Smrg      for path in $notinst_path; do
7536786a6f21Smrg	case " $new_libs " in
7537786a6f21Smrg	*" -L$path/$objdir "*) ;;
7538786a6f21Smrg	*)
7539786a6f21Smrg	  case " $compile_deplibs " in
7540786a6f21Smrg	  *" -L$path/$objdir "*)
7541786a6f21Smrg	    new_libs="$new_libs -L$path/$objdir" ;;
75421d54945dSmrg	  esac
7543786a6f21Smrg	  ;;
7544786a6f21Smrg	esac
7545786a6f21Smrg      done
7546786a6f21Smrg      for deplib in $compile_deplibs; do
7547786a6f21Smrg	case $deplib in
7548786a6f21Smrg	-L*)
7549786a6f21Smrg	  case " $new_libs " in
7550786a6f21Smrg	  *" $deplib "*) ;;
7551786a6f21Smrg	  *) new_libs="$new_libs $deplib" ;;
75521d54945dSmrg	  esac
7553786a6f21Smrg	  ;;
7554786a6f21Smrg	*) new_libs="$new_libs $deplib" ;;
7555786a6f21Smrg	esac
7556786a6f21Smrg      done
7557786a6f21Smrg      compile_deplibs="$new_libs"
75581d54945dSmrg
75591d54945dSmrg
7560786a6f21Smrg      compile_command="$compile_command $compile_deplibs"
7561786a6f21Smrg      finalize_command="$finalize_command $finalize_deplibs"
75621d54945dSmrg
7563786a6f21Smrg      if test -n "$rpath$xrpath"; then
7564786a6f21Smrg	# If the user specified any rpath flags, then add them.
7565786a6f21Smrg	for libdir in $rpath $xrpath; do
7566786a6f21Smrg	  # This is the magic to use -rpath.
7567786a6f21Smrg	  case "$finalize_rpath " in
7568786a6f21Smrg	  *" $libdir "*) ;;
7569786a6f21Smrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
7570786a6f21Smrg	  esac
7571786a6f21Smrg	done
7572786a6f21Smrg      fi
75731d54945dSmrg
7574786a6f21Smrg      # Now hardcode the library paths
7575786a6f21Smrg      rpath=
7576786a6f21Smrg      hardcode_libdirs=
7577786a6f21Smrg      for libdir in $compile_rpath $finalize_rpath; do
7578786a6f21Smrg	if test -n "$hardcode_libdir_flag_spec"; then
7579786a6f21Smrg	  if test -n "$hardcode_libdir_separator"; then
7580786a6f21Smrg	    if test -z "$hardcode_libdirs"; then
7581786a6f21Smrg	      hardcode_libdirs="$libdir"
7582786a6f21Smrg	    else
7583786a6f21Smrg	      # Just accumulate the unique libdirs.
7584786a6f21Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
7585786a6f21Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
7586786a6f21Smrg		;;
7587786a6f21Smrg	      *)
7588786a6f21Smrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
7589786a6f21Smrg		;;
7590786a6f21Smrg	      esac
7591786a6f21Smrg	    fi
75921d54945dSmrg	  else
7593786a6f21Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
7594786a6f21Smrg	    rpath="$rpath $flag"
75951d54945dSmrg	  fi
7596786a6f21Smrg	elif test -n "$runpath_var"; then
7597786a6f21Smrg	  case "$perm_rpath " in
7598786a6f21Smrg	  *" $libdir "*) ;;
7599786a6f21Smrg	  *) perm_rpath="$perm_rpath $libdir" ;;
7600786a6f21Smrg	  esac
7601786a6f21Smrg	fi
7602786a6f21Smrg	case $host in
7603786a6f21Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
7604786a6f21Smrg	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
7605786a6f21Smrg	  case :$dllsearchpath: in
7606786a6f21Smrg	  *":$libdir:"*) ;;
7607786a6f21Smrg	  ::) dllsearchpath=$libdir;;
7608786a6f21Smrg	  *) dllsearchpath="$dllsearchpath:$libdir";;
7609786a6f21Smrg	  esac
7610786a6f21Smrg	  case :$dllsearchpath: in
7611786a6f21Smrg	  *":$testbindir:"*) ;;
7612786a6f21Smrg	  ::) dllsearchpath=$testbindir;;
7613786a6f21Smrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
7614786a6f21Smrg	  esac
7615786a6f21Smrg	  ;;
7616786a6f21Smrg	esac
7617786a6f21Smrg      done
7618786a6f21Smrg      # Substitute the hardcoded libdirs into the rpath.
7619786a6f21Smrg      if test -n "$hardcode_libdir_separator" &&
7620786a6f21Smrg	 test -n "$hardcode_libdirs"; then
7621786a6f21Smrg	libdir="$hardcode_libdirs"
7622786a6f21Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
7623786a6f21Smrg      fi
7624786a6f21Smrg      compile_rpath="$rpath"
76251d54945dSmrg
7626786a6f21Smrg      rpath=
7627786a6f21Smrg      hardcode_libdirs=
7628786a6f21Smrg      for libdir in $finalize_rpath; do
7629786a6f21Smrg	if test -n "$hardcode_libdir_flag_spec"; then
7630786a6f21Smrg	  if test -n "$hardcode_libdir_separator"; then
7631786a6f21Smrg	    if test -z "$hardcode_libdirs"; then
7632786a6f21Smrg	      hardcode_libdirs="$libdir"
7633786a6f21Smrg	    else
7634786a6f21Smrg	      # Just accumulate the unique libdirs.
7635786a6f21Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
7636786a6f21Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
7637786a6f21Smrg		;;
7638786a6f21Smrg	      *)
7639786a6f21Smrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
7640786a6f21Smrg		;;
7641786a6f21Smrg	      esac
7642786a6f21Smrg	    fi
76431d54945dSmrg	  else
7644786a6f21Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
7645786a6f21Smrg	    rpath="$rpath $flag"
76461d54945dSmrg	  fi
7647786a6f21Smrg	elif test -n "$runpath_var"; then
7648786a6f21Smrg	  case "$finalize_perm_rpath " in
7649786a6f21Smrg	  *" $libdir "*) ;;
7650786a6f21Smrg	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
7651786a6f21Smrg	  esac
76521d54945dSmrg	fi
7653786a6f21Smrg      done
7654786a6f21Smrg      # Substitute the hardcoded libdirs into the rpath.
7655786a6f21Smrg      if test -n "$hardcode_libdir_separator" &&
7656786a6f21Smrg	 test -n "$hardcode_libdirs"; then
7657786a6f21Smrg	libdir="$hardcode_libdirs"
7658786a6f21Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
7659786a6f21Smrg      fi
7660786a6f21Smrg      finalize_rpath="$rpath"
76611d54945dSmrg
7662786a6f21Smrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
7663786a6f21Smrg	# Transform all the library objects into standard objects.
7664786a6f21Smrg	compile_command=`$ECHO "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
7665786a6f21Smrg	finalize_command=`$ECHO "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
7666786a6f21Smrg      fi
76671d54945dSmrg
7668786a6f21Smrg      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
76691d54945dSmrg
7670786a6f21Smrg      # template prelinking step
7671786a6f21Smrg      if test -n "$prelink_cmds"; then
7672786a6f21Smrg	func_execute_cmds "$prelink_cmds" 'exit $?'
7673786a6f21Smrg      fi
76741d54945dSmrg
7675786a6f21Smrg      wrappers_required=yes
7676786a6f21Smrg      case $host in
7677786a6f21Smrg      *cygwin* | *mingw* )
7678786a6f21Smrg        if test "$build_libtool_libs" != yes; then
7679786a6f21Smrg          wrappers_required=no
7680786a6f21Smrg        fi
7681786a6f21Smrg        ;;
7682786a6f21Smrg      *cegcc)
7683786a6f21Smrg        # Disable wrappers for cegcc, we are cross compiling anyway.
7684786a6f21Smrg        wrappers_required=no
7685786a6f21Smrg        ;;
7686786a6f21Smrg      *)
7687786a6f21Smrg        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
7688786a6f21Smrg          wrappers_required=no
7689786a6f21Smrg        fi
7690786a6f21Smrg        ;;
7691786a6f21Smrg      esac
7692786a6f21Smrg      if test "$wrappers_required" = no; then
7693786a6f21Smrg	# Replace the output file specification.
7694786a6f21Smrg	compile_command=`$ECHO "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
7695786a6f21Smrg	link_command="$compile_command$compile_rpath"
76961d54945dSmrg
7697786a6f21Smrg	# We have no uninstalled library dependencies, so finalize right now.
7698786a6f21Smrg	exit_status=0
7699786a6f21Smrg	func_show_eval "$link_command" 'exit_status=$?'
77001d54945dSmrg
7701786a6f21Smrg	# Delete the generated files.
7702786a6f21Smrg	if test -f "$output_objdir/${outputname}S.${objext}"; then
7703786a6f21Smrg	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
77041d54945dSmrg	fi
77051d54945dSmrg
7706786a6f21Smrg	exit $exit_status
7707786a6f21Smrg      fi
77081d54945dSmrg
7709786a6f21Smrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
7710786a6f21Smrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
7711786a6f21Smrg      fi
7712786a6f21Smrg      if test -n "$finalize_shlibpath"; then
7713786a6f21Smrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
7714786a6f21Smrg      fi
77151d54945dSmrg
7716786a6f21Smrg      compile_var=
7717786a6f21Smrg      finalize_var=
7718786a6f21Smrg      if test -n "$runpath_var"; then
7719786a6f21Smrg	if test -n "$perm_rpath"; then
7720786a6f21Smrg	  # We should set the runpath_var.
7721786a6f21Smrg	  rpath=
7722786a6f21Smrg	  for dir in $perm_rpath; do
7723786a6f21Smrg	    rpath="$rpath$dir:"
7724786a6f21Smrg	  done
7725786a6f21Smrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
77261d54945dSmrg	fi
7727786a6f21Smrg	if test -n "$finalize_perm_rpath"; then
7728786a6f21Smrg	  # We should set the runpath_var.
7729786a6f21Smrg	  rpath=
7730786a6f21Smrg	  for dir in $finalize_perm_rpath; do
7731786a6f21Smrg	    rpath="$rpath$dir:"
7732786a6f21Smrg	  done
7733786a6f21Smrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
77341d54945dSmrg	fi
7735786a6f21Smrg      fi
77361d54945dSmrg
7737786a6f21Smrg      if test "$no_install" = yes; then
7738786a6f21Smrg	# We don't need to create a wrapper script.
7739786a6f21Smrg	link_command="$compile_var$compile_command$compile_rpath"
7740786a6f21Smrg	# Replace the output file specification.
7741786a6f21Smrg	link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
7742786a6f21Smrg	# Delete the old output file.
7743786a6f21Smrg	$opt_dry_run || $RM $output
7744786a6f21Smrg	# Link the executable and exit
7745786a6f21Smrg	func_show_eval "$link_command" 'exit $?'
77461d54945dSmrg	exit $EXIT_SUCCESS
7747786a6f21Smrg      fi
77481d54945dSmrg
7749786a6f21Smrg      if test "$hardcode_action" = relink; then
7750786a6f21Smrg	# Fast installation is not supported
7751786a6f21Smrg	link_command="$compile_var$compile_command$compile_rpath"
7752786a6f21Smrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
7753786a6f21Smrg
7754786a6f21Smrg	func_warning "this platform does not like uninstalled shared libraries"
7755786a6f21Smrg	func_warning "\`$output' will be relinked during installation"
7756786a6f21Smrg      else
7757786a6f21Smrg	if test "$fast_install" != no; then
7758786a6f21Smrg	  link_command="$finalize_var$compile_command$finalize_rpath"
7759786a6f21Smrg	  if test "$fast_install" = yes; then
7760786a6f21Smrg	    relink_command=`$ECHO "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
7761786a6f21Smrg	  else
7762786a6f21Smrg	    # fast_install is set to needless
7763786a6f21Smrg	    relink_command=
7764786a6f21Smrg	  fi
77651d54945dSmrg	else
7766786a6f21Smrg	  link_command="$compile_var$compile_command$compile_rpath"
7767786a6f21Smrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
77681d54945dSmrg	fi
7769786a6f21Smrg      fi
77701d54945dSmrg
7771786a6f21Smrg      # Replace the output file specification.
7772786a6f21Smrg      link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
77731d54945dSmrg
7774786a6f21Smrg      # Delete the old output files.
7775786a6f21Smrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
77761d54945dSmrg
7777786a6f21Smrg      func_show_eval "$link_command" 'exit $?'
77781d54945dSmrg
7779786a6f21Smrg      # Now create the wrapper script.
7780786a6f21Smrg      func_verbose "creating $output"
77811d54945dSmrg
7782786a6f21Smrg      # Quote the relink command for shipping.
7783786a6f21Smrg      if test -n "$relink_command"; then
7784786a6f21Smrg	# Preserve any variables that may affect compiler behavior
7785786a6f21Smrg	for var in $variables_saved_for_relink; do
7786786a6f21Smrg	  if eval test -z \"\${$var+set}\"; then
7787786a6f21Smrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
7788786a6f21Smrg	  elif eval var_value=\$$var; test -z "$var_value"; then
7789786a6f21Smrg	    relink_command="$var=; export $var; $relink_command"
77901d54945dSmrg	  else
7791786a6f21Smrg	    func_quote_for_eval "$var_value"
7792786a6f21Smrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
77931d54945dSmrg	  fi
7794786a6f21Smrg	done
7795786a6f21Smrg	relink_command="(cd `pwd`; $relink_command)"
7796786a6f21Smrg	relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
7797786a6f21Smrg      fi
77981d54945dSmrg
7799786a6f21Smrg      # Quote $ECHO for shipping.
7800786a6f21Smrg      if test "X$ECHO" = "X$SHELL $progpath --fallback-echo"; then
7801786a6f21Smrg	case $progpath in
7802786a6f21Smrg	[\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
7803786a6f21Smrg	*) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
7804786a6f21Smrg	esac
7805786a6f21Smrg	qecho=`$ECHO "X$qecho" | $Xsed -e "$sed_quote_subst"`
7806786a6f21Smrg      else
7807786a6f21Smrg	qecho=`$ECHO "X$ECHO" | $Xsed -e "$sed_quote_subst"`
7808786a6f21Smrg      fi
7809786a6f21Smrg
7810786a6f21Smrg      # Only actually do things if not in dry run mode.
7811786a6f21Smrg      $opt_dry_run || {
7812786a6f21Smrg	# win32 will think the script is a binary if it has
7813786a6f21Smrg	# a .exe suffix, so we strip it off here.
7814786a6f21Smrg	case $output in
7815786a6f21Smrg	  *.exe) func_stripname '' '.exe' "$output"
7816786a6f21Smrg	         output=$func_stripname_result ;;
78171d54945dSmrg	esac
7818786a6f21Smrg	# test for cygwin because mv fails w/o .exe extensions
7819786a6f21Smrg	case $host in
7820786a6f21Smrg	  *cygwin*)
7821786a6f21Smrg	    exeext=.exe
7822786a6f21Smrg	    func_stripname '' '.exe' "$outputname"
7823786a6f21Smrg	    outputname=$func_stripname_result ;;
7824786a6f21Smrg	  *) exeext= ;;
7825786a6f21Smrg	esac
7826786a6f21Smrg	case $host in
7827786a6f21Smrg	  *cygwin* | *mingw* )
7828786a6f21Smrg	    func_dirname_and_basename "$output" "" "."
7829786a6f21Smrg	    output_name=$func_basename_result
7830786a6f21Smrg	    output_path=$func_dirname_result
7831786a6f21Smrg	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
7832786a6f21Smrg	    cwrapper="$output_path/$output_name.exe"
7833786a6f21Smrg	    $RM $cwrappersource $cwrapper
7834786a6f21Smrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
7835786a6f21Smrg
7836786a6f21Smrg	    func_emit_cwrapperexe_src > $cwrappersource
7837786a6f21Smrg
7838786a6f21Smrg	    # The wrapper executable is built using the $host compiler,
7839786a6f21Smrg	    # because it contains $host paths and files. If cross-
7840786a6f21Smrg	    # compiling, it, like the target executable, must be
7841786a6f21Smrg	    # executed on the $host or under an emulation environment.
7842786a6f21Smrg	    $opt_dry_run || {
7843786a6f21Smrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
7844786a6f21Smrg	      $STRIP $cwrapper
7845786a6f21Smrg	    }
78461d54945dSmrg
7847786a6f21Smrg	    # Now, create the wrapper script for func_source use:
7848786a6f21Smrg	    func_ltwrapper_scriptname $cwrapper
7849786a6f21Smrg	    $RM $func_ltwrapper_scriptname_result
7850786a6f21Smrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
7851786a6f21Smrg	    $opt_dry_run || {
7852786a6f21Smrg	      # note: this script will not be executed, so do not chmod.
7853786a6f21Smrg	      if test "x$build" = "x$host" ; then
7854786a6f21Smrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
7855786a6f21Smrg	      else
7856786a6f21Smrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
7857786a6f21Smrg	      fi
7858786a6f21Smrg	    }
7859786a6f21Smrg	  ;;
7860786a6f21Smrg	  * )
7861786a6f21Smrg	    $RM $output
7862786a6f21Smrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
78631d54945dSmrg
7864786a6f21Smrg	    func_emit_wrapper no > $output
7865786a6f21Smrg	    chmod +x $output
7866786a6f21Smrg	  ;;
7867786a6f21Smrg	esac
7868786a6f21Smrg      }
7869786a6f21Smrg      exit $EXIT_SUCCESS
7870786a6f21Smrg      ;;
7871786a6f21Smrg    esac
78721d54945dSmrg
7873786a6f21Smrg    # See if we need to build an old-fashioned archive.
7874786a6f21Smrg    for oldlib in $oldlibs; do
78751d54945dSmrg
7876786a6f21Smrg      if test "$build_libtool_libs" = convenience; then
7877786a6f21Smrg	oldobjs="$libobjs_save $symfileobj"
7878786a6f21Smrg	addlibs="$convenience"
7879786a6f21Smrg	build_libtool_libs=no
7880786a6f21Smrg      else
7881786a6f21Smrg	if test "$build_libtool_libs" = module; then
7882786a6f21Smrg	  oldobjs="$libobjs_save"
7883786a6f21Smrg	  build_libtool_libs=no
7884786a6f21Smrg	else
7885786a6f21Smrg	  oldobjs="$old_deplibs $non_pic_objects"
7886786a6f21Smrg	  if test "$preload" = yes && test -f "$symfileobj"; then
7887786a6f21Smrg	    oldobjs="$oldobjs $symfileobj"
7888786a6f21Smrg	  fi
7889786a6f21Smrg	fi
7890786a6f21Smrg	addlibs="$old_convenience"
78911d54945dSmrg      fi
78921d54945dSmrg
7893786a6f21Smrg      if test -n "$addlibs"; then
7894786a6f21Smrg	gentop="$output_objdir/${outputname}x"
7895786a6f21Smrg	generated="$generated $gentop"
78961d54945dSmrg
7897786a6f21Smrg	func_extract_archives $gentop $addlibs
7898786a6f21Smrg	oldobjs="$oldobjs $func_extract_archives_result"
7899786a6f21Smrg      fi
79001d54945dSmrg
7901786a6f21Smrg      # Do each command in the archive commands.
7902786a6f21Smrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
7903786a6f21Smrg	cmds=$old_archive_from_new_cmds
7904786a6f21Smrg      else
79051d54945dSmrg
7906786a6f21Smrg	# Add any objects from preloaded convenience libraries
7907786a6f21Smrg	if test -n "$dlprefiles"; then
7908786a6f21Smrg	  gentop="$output_objdir/${outputname}x"
7909786a6f21Smrg	  generated="$generated $gentop"
79101d54945dSmrg
7911786a6f21Smrg	  func_extract_archives $gentop $dlprefiles
7912786a6f21Smrg	  oldobjs="$oldobjs $func_extract_archives_result"
7913786a6f21Smrg	fi
79141d54945dSmrg
7915786a6f21Smrg	# POSIX demands no paths to be encoded in archives.  We have
7916786a6f21Smrg	# to avoid creating archives with duplicate basenames if we
7917786a6f21Smrg	# might have to extract them afterwards, e.g., when creating a
7918786a6f21Smrg	# static archive out of a convenience library, or when linking
7919786a6f21Smrg	# the entirety of a libtool archive into another (currently
7920786a6f21Smrg	# not supported by libtool).
7921786a6f21Smrg	if (for obj in $oldobjs
7922786a6f21Smrg	    do
7923786a6f21Smrg	      func_basename "$obj"
7924786a6f21Smrg	      $ECHO "$func_basename_result"
7925786a6f21Smrg	    done | sort | sort -uc >/dev/null 2>&1); then
7926786a6f21Smrg	  :
7927786a6f21Smrg	else
7928786a6f21Smrg	  $ECHO "copying selected object files to avoid basename conflicts..."
7929786a6f21Smrg	  gentop="$output_objdir/${outputname}x"
7930786a6f21Smrg	  generated="$generated $gentop"
7931786a6f21Smrg	  func_mkdir_p "$gentop"
7932786a6f21Smrg	  save_oldobjs=$oldobjs
7933786a6f21Smrg	  oldobjs=
7934786a6f21Smrg	  counter=1
7935786a6f21Smrg	  for obj in $save_oldobjs
7936786a6f21Smrg	  do
7937786a6f21Smrg	    func_basename "$obj"
7938786a6f21Smrg	    objbase="$func_basename_result"
7939786a6f21Smrg	    case " $oldobjs " in
7940786a6f21Smrg	    " ") oldobjs=$obj ;;
7941786a6f21Smrg	    *[\ /]"$objbase "*)
7942786a6f21Smrg	      while :; do
7943786a6f21Smrg		# Make sure we don't pick an alternate name that also
7944786a6f21Smrg		# overlaps.
7945786a6f21Smrg		newobj=lt$counter-$objbase
7946786a6f21Smrg		func_arith $counter + 1
7947786a6f21Smrg		counter=$func_arith_result
7948786a6f21Smrg		case " $oldobjs " in
7949786a6f21Smrg		*[\ /]"$newobj "*) ;;
7950786a6f21Smrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
7951786a6f21Smrg		esac
7952786a6f21Smrg	      done
7953786a6f21Smrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
7954786a6f21Smrg	      oldobjs="$oldobjs $gentop/$newobj"
7955786a6f21Smrg	      ;;
7956786a6f21Smrg	    *) oldobjs="$oldobjs $obj" ;;
7957786a6f21Smrg	    esac
79581d54945dSmrg	  done
79591d54945dSmrg	fi
7960786a6f21Smrg	eval cmds=\"$old_archive_cmds\"
79611d54945dSmrg
7962786a6f21Smrg	func_len " $cmds"
7963786a6f21Smrg	len=$func_len_result
7964786a6f21Smrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
7965786a6f21Smrg	  cmds=$old_archive_cmds
7966786a6f21Smrg	else
7967786a6f21Smrg	  # the command line is too long to link in one step, link in parts
7968786a6f21Smrg	  func_verbose "using piecewise archive linking..."
7969786a6f21Smrg	  save_RANLIB=$RANLIB
7970786a6f21Smrg	  RANLIB=:
7971786a6f21Smrg	  objlist=
7972786a6f21Smrg	  concat_cmds=
7973786a6f21Smrg	  save_oldobjs=$oldobjs
7974786a6f21Smrg	  oldobjs=
7975786a6f21Smrg	  # Is there a better way of finding the last object in the list?
7976786a6f21Smrg	  for obj in $save_oldobjs
7977786a6f21Smrg	  do
7978786a6f21Smrg	    last_oldobj=$obj
7979786a6f21Smrg	  done
7980786a6f21Smrg	  eval test_cmds=\"$old_archive_cmds\"
7981786a6f21Smrg	  func_len " $test_cmds"
7982786a6f21Smrg	  len0=$func_len_result
7983786a6f21Smrg	  len=$len0
7984786a6f21Smrg	  for obj in $save_oldobjs
7985786a6f21Smrg	  do
7986786a6f21Smrg	    func_len " $obj"
7987786a6f21Smrg	    func_arith $len + $func_len_result
7988786a6f21Smrg	    len=$func_arith_result
7989786a6f21Smrg	    func_append objlist " $obj"
7990786a6f21Smrg	    if test "$len" -lt "$max_cmd_len"; then
7991786a6f21Smrg	      :
7992786a6f21Smrg	    else
7993786a6f21Smrg	      # the above command should be used before it gets too long
7994786a6f21Smrg	      oldobjs=$objlist
7995786a6f21Smrg	      if test "$obj" = "$last_oldobj" ; then
7996786a6f21Smrg		RANLIB=$save_RANLIB
7997786a6f21Smrg	      fi
7998786a6f21Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
7999786a6f21Smrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
8000786a6f21Smrg	      objlist=
8001786a6f21Smrg	      len=$len0
8002786a6f21Smrg	    fi
8003786a6f21Smrg	  done
8004786a6f21Smrg	  RANLIB=$save_RANLIB
8005786a6f21Smrg	  oldobjs=$objlist
8006786a6f21Smrg	  if test "X$oldobjs" = "X" ; then
8007786a6f21Smrg	    eval cmds=\"\$concat_cmds\"
8008786a6f21Smrg	  else
8009786a6f21Smrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
8010786a6f21Smrg	  fi
8011786a6f21Smrg	fi
8012786a6f21Smrg      fi
8013786a6f21Smrg      func_execute_cmds "$cmds" 'exit $?'
80141d54945dSmrg    done
80151d54945dSmrg
8016786a6f21Smrg    test -n "$generated" && \
8017786a6f21Smrg      func_show_eval "${RM}r$generated"
80181d54945dSmrg
8019786a6f21Smrg    # Now create the libtool archive.
8020786a6f21Smrg    case $output in
8021786a6f21Smrg    *.la)
8022786a6f21Smrg      old_library=
8023786a6f21Smrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
8024786a6f21Smrg      func_verbose "creating $output"
80251d54945dSmrg
8026786a6f21Smrg      # Preserve any variables that may affect compiler behavior
8027786a6f21Smrg      for var in $variables_saved_for_relink; do
8028786a6f21Smrg	if eval test -z \"\${$var+set}\"; then
8029786a6f21Smrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
8030786a6f21Smrg	elif eval var_value=\$$var; test -z "$var_value"; then
8031786a6f21Smrg	  relink_command="$var=; export $var; $relink_command"
80321d54945dSmrg	else
8033786a6f21Smrg	  func_quote_for_eval "$var_value"
8034786a6f21Smrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
80351d54945dSmrg	fi
8036786a6f21Smrg      done
8037786a6f21Smrg      # Quote the link command for shipping.
8038786a6f21Smrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
8039786a6f21Smrg      relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
8040786a6f21Smrg      if test "$hardcode_automatic" = yes ; then
8041786a6f21Smrg	relink_command=
8042786a6f21Smrg      fi
80431d54945dSmrg
8044786a6f21Smrg      # Only create the output if not a dry run.
8045786a6f21Smrg      $opt_dry_run || {
8046786a6f21Smrg	for installed in no yes; do
8047786a6f21Smrg	  if test "$installed" = yes; then
8048786a6f21Smrg	    if test -z "$install_libdir"; then
8049786a6f21Smrg	      break
8050786a6f21Smrg	    fi
8051786a6f21Smrg	    output="$output_objdir/$outputname"i
8052786a6f21Smrg	    # Replace all uninstalled libtool libraries with the installed ones
8053786a6f21Smrg	    newdependency_libs=
8054786a6f21Smrg	    for deplib in $dependency_libs; do
8055786a6f21Smrg	      case $deplib in
8056786a6f21Smrg	      *.la)
8057786a6f21Smrg		func_basename "$deplib"
8058786a6f21Smrg		name="$func_basename_result"
8059786a6f21Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
8060786a6f21Smrg		test -z "$libdir" && \
8061786a6f21Smrg		  func_fatal_error "\`$deplib' is not a valid libtool archive"
8062786a6f21Smrg		newdependency_libs="$newdependency_libs $libdir/$name"
8063786a6f21Smrg		;;
8064786a6f21Smrg	      *) newdependency_libs="$newdependency_libs $deplib" ;;
8065786a6f21Smrg	      esac
8066786a6f21Smrg	    done
8067786a6f21Smrg	    dependency_libs="$newdependency_libs"
8068786a6f21Smrg	    newdlfiles=
80691d54945dSmrg
8070786a6f21Smrg	    for lib in $dlfiles; do
8071786a6f21Smrg	      case $lib in
8072786a6f21Smrg	      *.la)
8073786a6f21Smrg	        func_basename "$lib"
8074786a6f21Smrg		name="$func_basename_result"
8075786a6f21Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
8076786a6f21Smrg		test -z "$libdir" && \
8077786a6f21Smrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
8078786a6f21Smrg		newdlfiles="$newdlfiles $libdir/$name"
8079786a6f21Smrg		;;
8080786a6f21Smrg	      *) newdlfiles="$newdlfiles $lib" ;;
8081786a6f21Smrg	      esac
8082786a6f21Smrg	    done
8083786a6f21Smrg	    dlfiles="$newdlfiles"
8084786a6f21Smrg	    newdlprefiles=
8085786a6f21Smrg	    for lib in $dlprefiles; do
8086786a6f21Smrg	      case $lib in
8087786a6f21Smrg	      *.la)
8088786a6f21Smrg		# Only pass preopened files to the pseudo-archive (for
8089786a6f21Smrg		# eventual linking with the app. that links it) if we
8090786a6f21Smrg		# didn't already link the preopened objects directly into
8091786a6f21Smrg		# the library:
8092786a6f21Smrg		func_basename "$lib"
8093786a6f21Smrg		name="$func_basename_result"
8094786a6f21Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
8095786a6f21Smrg		test -z "$libdir" && \
8096786a6f21Smrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
8097786a6f21Smrg		newdlprefiles="$newdlprefiles $libdir/$name"
8098786a6f21Smrg		;;
8099786a6f21Smrg	      esac
8100786a6f21Smrg	    done
8101786a6f21Smrg	    dlprefiles="$newdlprefiles"
8102786a6f21Smrg	  else
8103786a6f21Smrg	    newdlfiles=
8104786a6f21Smrg	    for lib in $dlfiles; do
8105786a6f21Smrg	      case $lib in
8106786a6f21Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
8107786a6f21Smrg		*) abs=`pwd`"/$lib" ;;
8108786a6f21Smrg	      esac
8109786a6f21Smrg	      newdlfiles="$newdlfiles $abs"
8110786a6f21Smrg	    done
8111786a6f21Smrg	    dlfiles="$newdlfiles"
8112786a6f21Smrg	    newdlprefiles=
8113786a6f21Smrg	    for lib in $dlprefiles; do
8114786a6f21Smrg	      case $lib in
8115786a6f21Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
8116786a6f21Smrg		*) abs=`pwd`"/$lib" ;;
8117786a6f21Smrg	      esac
8118786a6f21Smrg	      newdlprefiles="$newdlprefiles $abs"
8119786a6f21Smrg	    done
8120786a6f21Smrg	    dlprefiles="$newdlprefiles"
8121786a6f21Smrg	  fi
8122786a6f21Smrg	  $RM $output
8123786a6f21Smrg	  # place dlname in correct position for cygwin
8124786a6f21Smrg	  tdlname=$dlname
8125786a6f21Smrg	  case $host,$output,$installed,$module,$dlname in
8126786a6f21Smrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
8127786a6f21Smrg	  esac
8128786a6f21Smrg	  $ECHO > $output "\
8129786a6f21Smrg# $outputname - a libtool library file
8130786a6f21Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
8131786a6f21Smrg#
8132786a6f21Smrg# Please DO NOT delete this file!
8133786a6f21Smrg# It is necessary for linking the library.
81341d54945dSmrg
8135786a6f21Smrg# The name that we can dlopen(3).
8136786a6f21Smrgdlname='$tdlname'
81371d54945dSmrg
8138786a6f21Smrg# Names of this library.
8139786a6f21Smrglibrary_names='$library_names'
81401d54945dSmrg
8141786a6f21Smrg# The name of the static archive.
8142786a6f21Smrgold_library='$old_library'
81431d54945dSmrg
8144786a6f21Smrg# Linker flags that can not go in dependency_libs.
8145786a6f21Smrginherited_linker_flags='$new_inherited_linker_flags'
81461d54945dSmrg
8147786a6f21Smrg# Libraries that this one depends upon.
8148786a6f21Smrgdependency_libs='$dependency_libs'
81491d54945dSmrg
8150786a6f21Smrg# Names of additional weak libraries provided by this library
8151786a6f21Smrgweak_library_names='$weak_libs'
81521d54945dSmrg
8153786a6f21Smrg# Version information for $libname.
8154786a6f21Smrgcurrent=$current
8155786a6f21Smrgage=$age
8156786a6f21Smrgrevision=$revision
81571d54945dSmrg
8158786a6f21Smrg# Is this an already installed library?
8159786a6f21Smrginstalled=$installed
81601d54945dSmrg
8161786a6f21Smrg# Should we warn about portability when linking against -modules?
8162786a6f21Smrgshouldnotlink=$module
81631d54945dSmrg
8164786a6f21Smrg# Files to dlopen/dlpreopen
8165786a6f21Smrgdlopen='$dlfiles'
8166786a6f21Smrgdlpreopen='$dlprefiles'
81671d54945dSmrg
8168786a6f21Smrg# Directory that this library needs to be installed in:
8169786a6f21Smrglibdir='$install_libdir'"
8170786a6f21Smrg	  if test "$installed" = no && test "$need_relink" = yes; then
8171786a6f21Smrg	    $ECHO >> $output "\
8172786a6f21Smrgrelink_command=\"$relink_command\""
8173786a6f21Smrg	  fi
8174786a6f21Smrg	done
8175786a6f21Smrg      }
81761d54945dSmrg
8177786a6f21Smrg      # Do a symbolic link so that the libtool archive can be found in
8178786a6f21Smrg      # LD_LIBRARY_PATH before the program is installed.
8179786a6f21Smrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
8180786a6f21Smrg      ;;
8181786a6f21Smrg    esac
8182786a6f21Smrg    exit $EXIT_SUCCESS
8183786a6f21Smrg}
8184ba85709eSmrg
8185786a6f21Smrg{ test "$mode" = link || test "$mode" = relink; } &&
8186786a6f21Smrg    func_mode_link ${1+"$@"}
81871d54945dSmrg
81881d54945dSmrg
8189786a6f21Smrg# func_mode_uninstall arg...
8190786a6f21Smrgfunc_mode_uninstall ()
8191786a6f21Smrg{
8192786a6f21Smrg    $opt_debug
8193786a6f21Smrg    RM="$nonopt"
81941d54945dSmrg    files=
81951d54945dSmrg    rmforce=
81961d54945dSmrg    exit_status=0
81971d54945dSmrg
81981d54945dSmrg    # This variable tells wrapper scripts just to set variables rather
81991d54945dSmrg    # than running their programs.
82001d54945dSmrg    libtool_install_magic="$magic"
82011d54945dSmrg
82021d54945dSmrg    for arg
82031d54945dSmrg    do
82041d54945dSmrg      case $arg in
8205786a6f21Smrg      -f) RM="$RM $arg"; rmforce=yes ;;
8206786a6f21Smrg      -*) RM="$RM $arg" ;;
82071d54945dSmrg      *) files="$files $arg" ;;
82081d54945dSmrg      esac
82091d54945dSmrg    done
82101d54945dSmrg
8211786a6f21Smrg    test -z "$RM" && \
8212786a6f21Smrg      func_fatal_help "you must specify an RM program"
82131d54945dSmrg
82141d54945dSmrg    rmdirs=
82151d54945dSmrg
82161d54945dSmrg    origobjdir="$objdir"
82171d54945dSmrg    for file in $files; do
8218786a6f21Smrg      func_dirname "$file" "" "."
8219786a6f21Smrg      dir="$func_dirname_result"
8220786a6f21Smrg      if test "X$dir" = X.; then
82211d54945dSmrg	objdir="$origobjdir"
82221d54945dSmrg      else
82231d54945dSmrg	objdir="$dir/$origobjdir"
82241d54945dSmrg      fi
8225786a6f21Smrg      func_basename "$file"
8226786a6f21Smrg      name="$func_basename_result"
82271d54945dSmrg      test "$mode" = uninstall && objdir="$dir"
82281d54945dSmrg
82291d54945dSmrg      # Remember objdir for removal later, being careful to avoid duplicates
82301d54945dSmrg      if test "$mode" = clean; then
82311d54945dSmrg	case " $rmdirs " in
82321d54945dSmrg	  *" $objdir "*) ;;
82331d54945dSmrg	  *) rmdirs="$rmdirs $objdir" ;;
82341d54945dSmrg	esac
82351d54945dSmrg      fi
82361d54945dSmrg
82371d54945dSmrg      # Don't error if the file doesn't exist and rm -f was used.
8238786a6f21Smrg      if { test -L "$file"; } >/dev/null 2>&1 ||
8239786a6f21Smrg	 { test -h "$file"; } >/dev/null 2>&1 ||
8240786a6f21Smrg	 test -f "$file"; then
82411d54945dSmrg	:
82421d54945dSmrg      elif test -d "$file"; then
82431d54945dSmrg	exit_status=1
82441d54945dSmrg	continue
82451d54945dSmrg      elif test "$rmforce" = yes; then
82461d54945dSmrg	continue
82471d54945dSmrg      fi
82481d54945dSmrg
82491d54945dSmrg      rmfiles="$file"
82501d54945dSmrg
82511d54945dSmrg      case $name in
82521d54945dSmrg      *.la)
82531d54945dSmrg	# Possibly a libtool archive, so verify it.
8254786a6f21Smrg	if func_lalib_p "$file"; then
8255786a6f21Smrg	  func_source $dir/$name
82561d54945dSmrg
82571d54945dSmrg	  # Delete the libtool libraries and symlinks.
82581d54945dSmrg	  for n in $library_names; do
82591d54945dSmrg	    rmfiles="$rmfiles $objdir/$n"
82601d54945dSmrg	  done
82611d54945dSmrg	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
82621d54945dSmrg
82631d54945dSmrg	  case "$mode" in
82641d54945dSmrg	  clean)
82651d54945dSmrg	    case "  $library_names " in
82661d54945dSmrg	    # "  " in the beginning catches empty $dlname
82671d54945dSmrg	    *" $dlname "*) ;;
82681d54945dSmrg	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
82691d54945dSmrg	    esac
8270786a6f21Smrg	    test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
82711d54945dSmrg	    ;;
82721d54945dSmrg	  uninstall)
82731d54945dSmrg	    if test -n "$library_names"; then
82741d54945dSmrg	      # Do each command in the postuninstall commands.
8275786a6f21Smrg	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
82761d54945dSmrg	    fi
82771d54945dSmrg
82781d54945dSmrg	    if test -n "$old_library"; then
82791d54945dSmrg	      # Do each command in the old_postuninstall commands.
8280786a6f21Smrg	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
82811d54945dSmrg	    fi
82821d54945dSmrg	    # FIXME: should reinstall the best remaining shared library.
82831d54945dSmrg	    ;;
82841d54945dSmrg	  esac
82851d54945dSmrg	fi
82861d54945dSmrg	;;
82871d54945dSmrg
82881d54945dSmrg      *.lo)
82891d54945dSmrg	# Possibly a libtool object, so verify it.
8290786a6f21Smrg	if func_lalib_p "$file"; then
82911d54945dSmrg
82921d54945dSmrg	  # Read the .lo file
8293786a6f21Smrg	  func_source $dir/$name
82941d54945dSmrg
82951d54945dSmrg	  # Add PIC object to the list of files to remove.
8296786a6f21Smrg	  if test -n "$pic_object" &&
8297786a6f21Smrg	     test "$pic_object" != none; then
82981d54945dSmrg	    rmfiles="$rmfiles $dir/$pic_object"
82991d54945dSmrg	  fi
83001d54945dSmrg
83011d54945dSmrg	  # Add non-PIC object to the list of files to remove.
8302786a6f21Smrg	  if test -n "$non_pic_object" &&
8303786a6f21Smrg	     test "$non_pic_object" != none; then
83041d54945dSmrg	    rmfiles="$rmfiles $dir/$non_pic_object"
83051d54945dSmrg	  fi
83061d54945dSmrg	fi
83071d54945dSmrg	;;
83081d54945dSmrg
83091d54945dSmrg      *)
83101d54945dSmrg	if test "$mode" = clean ; then
83111d54945dSmrg	  noexename=$name
83121d54945dSmrg	  case $file in
83131d54945dSmrg	  *.exe)
8314786a6f21Smrg	    func_stripname '' '.exe' "$file"
8315786a6f21Smrg	    file=$func_stripname_result
8316786a6f21Smrg	    func_stripname '' '.exe' "$name"
8317786a6f21Smrg	    noexename=$func_stripname_result
83181d54945dSmrg	    # $file with .exe has already been added to rmfiles,
83191d54945dSmrg	    # add $file without .exe
83201d54945dSmrg	    rmfiles="$rmfiles $file"
83211d54945dSmrg	    ;;
83221d54945dSmrg	  esac
83231d54945dSmrg	  # Do a test to see if this is a libtool program.
8324786a6f21Smrg	  if func_ltwrapper_p "$file"; then
8325786a6f21Smrg	    if func_ltwrapper_executable_p "$file"; then
8326786a6f21Smrg	      func_ltwrapper_scriptname "$file"
8327786a6f21Smrg	      relink_command=
8328786a6f21Smrg	      func_source $func_ltwrapper_scriptname_result
8329786a6f21Smrg	      rmfiles="$rmfiles $func_ltwrapper_scriptname_result"
8330786a6f21Smrg	    else
8331786a6f21Smrg	      relink_command=
8332786a6f21Smrg	      func_source $dir/$noexename
8333786a6f21Smrg	    fi
83341d54945dSmrg
83351d54945dSmrg	    # note $name still contains .exe if it was in $file originally
83361d54945dSmrg	    # as does the version of $file that was added into $rmfiles
83371d54945dSmrg	    rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
83381d54945dSmrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
83391d54945dSmrg	      rmfiles="$rmfiles $objdir/lt-$name"
83401d54945dSmrg	    fi
83411d54945dSmrg	    if test "X$noexename" != "X$name" ; then
83421d54945dSmrg	      rmfiles="$rmfiles $objdir/lt-${noexename}.c"
83431d54945dSmrg	    fi
83441d54945dSmrg	  fi
83451d54945dSmrg	fi
83461d54945dSmrg	;;
83471d54945dSmrg      esac
8348786a6f21Smrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
83491d54945dSmrg    done
83501d54945dSmrg    objdir="$origobjdir"
83511d54945dSmrg
83521d54945dSmrg    # Try to remove the ${objdir}s in the directories where we deleted files
83531d54945dSmrg    for dir in $rmdirs; do
83541d54945dSmrg      if test -d "$dir"; then
8355786a6f21Smrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
83561d54945dSmrg      fi
83571d54945dSmrg    done
83581d54945dSmrg
83591d54945dSmrg    exit $exit_status
8360786a6f21Smrg}
83611d54945dSmrg
8362786a6f21Smrg{ test "$mode" = uninstall || test "$mode" = clean; } &&
8363786a6f21Smrg    func_mode_uninstall ${1+"$@"}
83641d54945dSmrg
8365786a6f21Smrgtest -z "$mode" && {
8366786a6f21Smrg  help="$generic_help"
8367786a6f21Smrg  func_fatal_help "you must specify a MODE"
8368786a6f21Smrg}
8369786a6f21Smrg
8370786a6f21Smrgtest -z "$exec_cmd" && \
8371786a6f21Smrg  func_fatal_help "invalid operation mode \`$mode'"
83721d54945dSmrg
83731d54945dSmrgif test -n "$exec_cmd"; then
8374786a6f21Smrg  eval exec "$exec_cmd"
83751d54945dSmrg  exit $EXIT_FAILURE
83761d54945dSmrgfi
83771d54945dSmrg
8378786a6f21Smrgexit $exit_status
83791d54945dSmrg
83801d54945dSmrg
83811d54945dSmrg# The TAGs below are defined such that we never get into a situation
83821d54945dSmrg# in which we disable both kinds of libraries.  Given conflicting
83831d54945dSmrg# choices, we go for a static library, that is the most portable,
83841d54945dSmrg# since we can't tell whether shared libraries were disabled because
83851d54945dSmrg# the user asked for that or because the platform doesn't support
83861d54945dSmrg# them.  This is particularly important on AIX, because we don't
83871d54945dSmrg# support having both static and shared libraries enabled at the same
83881d54945dSmrg# time on that platform, so we default to a shared-only configuration.
83891d54945dSmrg# If a disable-shared tag is given, we'll fallback to a static-only
83901d54945dSmrg# configuration.  But we'll never go from static-only to shared-only.
83911d54945dSmrg
83921d54945dSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
8393786a6f21Smrgbuild_libtool_libs=no
8394786a6f21Smrgbuild_old_libs=yes
83951d54945dSmrg# ### END LIBTOOL TAG CONFIG: disable-shared
83961d54945dSmrg
83971d54945dSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
8398786a6f21Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
83991d54945dSmrg# ### END LIBTOOL TAG CONFIG: disable-static
84001d54945dSmrg
84011d54945dSmrg# Local Variables:
84021d54945dSmrg# mode:shell-script
84031d54945dSmrg# sh-indentation:2
84041d54945dSmrg# End:
8405786a6f21Smrg# vi:sw=2
8406786a6f21Smrg
8407