ltmain.sh revision ea133fd7
1ea133fd7Smrg# Generated from ltmain.m4sh.
2ea133fd7Smrg
3ea133fd7Smrg# ltmain.sh (GNU libtool) 2.2.6
4ea133fd7Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
5ea133fd7Smrg
6ea133fd7Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 Free Software Foundation, Inc.
7ea133fd7Smrg# This is free software; see the source for copying conditions.  There is NO
8ea133fd7Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9ea133fd7Smrg
10ea133fd7Smrg# GNU Libtool is free software; you can redistribute it and/or modify
11a253d6aeSmrg# it under the terms of the GNU General Public License as published by
12a253d6aeSmrg# the Free Software Foundation; either version 2 of the License, or
13a253d6aeSmrg# (at your option) any later version.
14a253d6aeSmrg#
15ea133fd7Smrg# As a special exception to the GNU General Public License,
16ea133fd7Smrg# if you distribute this file as part of a program or library that
17ea133fd7Smrg# is built using GNU Libtool, you may include this file under the
18ea133fd7Smrg# same distribution terms that you use for the rest of that program.
19ea133fd7Smrg#
20ea133fd7Smrg# GNU Libtool is distributed in the hope that it will be useful, but
21a253d6aeSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
22a253d6aeSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23a253d6aeSmrg# General Public License for more details.
24a253d6aeSmrg#
25a253d6aeSmrg# You should have received a copy of the GNU General Public License
26ea133fd7Smrg# along with GNU Libtool; see the file COPYING.  If not, a copy
27ea133fd7Smrg# can be downloaded from http://www.gnu.org/licenses/gpl.html,
28ea133fd7Smrg# or obtained by writing to the Free Software Foundation, Inc.,
29ea133fd7Smrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30ea133fd7Smrg
31ea133fd7Smrg# Usage: $progname [OPTION]... [MODE-ARG]...
32ea133fd7Smrg#
33ea133fd7Smrg# Provide generalized library-building support services.
34a253d6aeSmrg#
35ea133fd7Smrg#     --config             show all configuration variables
36ea133fd7Smrg#     --debug              enable verbose shell tracing
37ea133fd7Smrg# -n, --dry-run            display commands without modifying any files
38ea133fd7Smrg#     --features           display basic configuration information and exit
39ea133fd7Smrg#     --mode=MODE          use operation mode MODE
40ea133fd7Smrg#     --preserve-dup-deps  don't remove duplicate dependency libraries
41ea133fd7Smrg#     --quiet, --silent    don't print informational messages
42ea133fd7Smrg#     --tag=TAG            use configuration variables from tag TAG
43ea133fd7Smrg# -v, --verbose            print informational messages (default)
44ea133fd7Smrg#     --version            print version information
45ea133fd7Smrg# -h, --help               print short or long help message
46ea133fd7Smrg#
47ea133fd7Smrg# MODE must be one of the following:
48ea133fd7Smrg#
49ea133fd7Smrg#       clean              remove files from the build directory
50ea133fd7Smrg#       compile            compile a source file into a libtool object
51ea133fd7Smrg#       execute            automatically set library path, then run a program
52ea133fd7Smrg#       finish             complete the installation of libtool libraries
53ea133fd7Smrg#       install            install libraries or executables
54ea133fd7Smrg#       link               create a library or an executable
55ea133fd7Smrg#       uninstall          remove libraries from an installed directory
56ea133fd7Smrg#
57ea133fd7Smrg# MODE-ARGS vary depending on the MODE.
58ea133fd7Smrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
59ea133fd7Smrg#
60ea133fd7Smrg# When reporting a bug, please describe a test case to reproduce it and
61ea133fd7Smrg# include the following information:
62ea133fd7Smrg#
63ea133fd7Smrg#       host-triplet:	$host
64ea133fd7Smrg#       shell:		$SHELL
65ea133fd7Smrg#       compiler:		$LTCC
66ea133fd7Smrg#       compiler flags:		$LTCFLAGS
67ea133fd7Smrg#       linker:		$LD (gnu? $with_gnu_ld)
68ea133fd7Smrg#       $progname:		(GNU libtool) 2.2.6
69ea133fd7Smrg#       automake:		$automake_version
70ea133fd7Smrg#       autoconf:		$autoconf_version
71ea133fd7Smrg#
72ea133fd7Smrg# Report bugs to <bug-libtool@gnu.org>.
73ea133fd7Smrg
74ea133fd7SmrgPROGRAM=ltmain.sh
75ea133fd7SmrgPACKAGE=libtool
76ea133fd7SmrgVERSION=2.2.6
77ea133fd7SmrgTIMESTAMP=""
78ea133fd7Smrgpackage_revision=1.3012
79ea133fd7Smrg
80ea133fd7Smrg# Be Bourne compatible
81ea133fd7Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
82ea133fd7Smrg  emulate sh
83ea133fd7Smrg  NULLCMD=:
84ea133fd7Smrg  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
85ea133fd7Smrg  # is contrary to our usage.  Disable this feature.
86ea133fd7Smrg  alias -g '${1+"$@"}'='"$@"'
87ea133fd7Smrg  setopt NO_GLOB_SUBST
88ea133fd7Smrgelse
89ea133fd7Smrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
90ea133fd7Smrgfi
91ea133fd7SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
92ea133fd7SmrgDUALCASE=1; export DUALCASE # for MKS sh
93ea133fd7Smrg
94ea133fd7Smrg# NLS nuisances: We save the old values to restore during execute mode.
95ea133fd7Smrg# Only set LANG and LC_ALL to C if already set.
96ea133fd7Smrg# These must not be set unconditionally because not all systems understand
97ea133fd7Smrg# e.g. LANG=C (notably SCO).
98ea133fd7Smrglt_user_locale=
99ea133fd7Smrglt_safe_locale=
100ea133fd7Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
101ea133fd7Smrgdo
102ea133fd7Smrg  eval "if test \"\${$lt_var+set}\" = set; then
103ea133fd7Smrg          save_$lt_var=\$$lt_var
104ea133fd7Smrg          $lt_var=C
105ea133fd7Smrg	  export $lt_var
106ea133fd7Smrg	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
107ea133fd7Smrg	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
108ea133fd7Smrg	fi"
109ea133fd7Smrgdone
110ea133fd7Smrg
111ea133fd7Smrg$lt_unset CDPATH
112ea133fd7Smrg
113ea133fd7Smrg
114ea133fd7Smrg
115ea133fd7Smrg
116ea133fd7Smrg
117ea133fd7Smrg: ${CP="cp -f"}
118ea133fd7Smrg: ${ECHO="echo"}
119ea133fd7Smrg: ${EGREP="/bin/grep -E"}
120ea133fd7Smrg: ${FGREP="/bin/grep -F"}
121ea133fd7Smrg: ${GREP="/bin/grep"}
122ea133fd7Smrg: ${LN_S="ln -s"}
123ea133fd7Smrg: ${MAKE="make"}
124ea133fd7Smrg: ${MKDIR="mkdir"}
125ea133fd7Smrg: ${MV="mv -f"}
126ea133fd7Smrg: ${RM="rm -f"}
127ea133fd7Smrg: ${SED="/bin/sed"}
128ea133fd7Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
129ea133fd7Smrg: ${Xsed="$SED -e 1s/^X//"}
130a253d6aeSmrg
131ea133fd7Smrg# Global variables:
132ea133fd7SmrgEXIT_SUCCESS=0
133ea133fd7SmrgEXIT_FAILURE=1
134ea133fd7SmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
135ea133fd7SmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
136ea133fd7Smrg
137ea133fd7Smrgexit_status=$EXIT_SUCCESS
138ea133fd7Smrg
139ea133fd7Smrg# Make sure IFS has a sensible default
140ea133fd7Smrglt_nl='
141ea133fd7Smrg'
142ea133fd7SmrgIFS=" 	$lt_nl"
143ea133fd7Smrg
144ea133fd7Smrgdirname="s,/[^/]*$,,"
145ea133fd7Smrgbasename="s,^.*/,,"
146ea133fd7Smrg
147ea133fd7Smrg# func_dirname_and_basename file append nondir_replacement
148ea133fd7Smrg# perform func_basename and func_dirname in a single function
149ea133fd7Smrg# call:
150ea133fd7Smrg#   dirname:  Compute the dirname of FILE.  If nonempty,
151ea133fd7Smrg#             add APPEND to the result, otherwise set result
152ea133fd7Smrg#             to NONDIR_REPLACEMENT.
153ea133fd7Smrg#             value returned in "$func_dirname_result"
154ea133fd7Smrg#   basename: Compute filename of FILE.
155ea133fd7Smrg#             value retuned in "$func_basename_result"
156ea133fd7Smrg# Implementation must be kept synchronized with func_dirname
157ea133fd7Smrg# and func_basename. For efficiency, we do not delegate to
158ea133fd7Smrg# those functions but instead duplicate the functionality here.
159ea133fd7Smrgfunc_dirname_and_basename ()
160ea133fd7Smrg{
161ea133fd7Smrg  # Extract subdirectory from the argument.
162ea133fd7Smrg  func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
163ea133fd7Smrg  if test "X$func_dirname_result" = "X${1}"; then
164ea133fd7Smrg    func_dirname_result="${3}"
165ea133fd7Smrg  else
166ea133fd7Smrg    func_dirname_result="$func_dirname_result${2}"
167ea133fd7Smrg  fi
168ea133fd7Smrg  func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
169ea133fd7Smrg}
170ea133fd7Smrg
171ea133fd7Smrg# Generated shell functions inserted here.
172a253d6aeSmrg
173a253d6aeSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
174a253d6aeSmrg# is ksh but when the shell is invoked as "sh" and the current value of
175a253d6aeSmrg# the _XPG environment variable is not equal to 1 (one), the special
176a253d6aeSmrg# positional parameter $0, within a function call, is the name of the
177a253d6aeSmrg# function.
178a253d6aeSmrgprogpath="$0"
179a253d6aeSmrg
180a253d6aeSmrg# The name of this program:
181ea133fd7Smrg# In the unlikely event $progname began with a '-', it would play havoc with
182ea133fd7Smrg# func_echo (imagine progname=-n), so we prepend ./ in that case:
183ea133fd7Smrgfunc_dirname_and_basename "$progpath"
184ea133fd7Smrgprogname=$func_basename_result
185ea133fd7Smrgcase $progname in
186ea133fd7Smrg  -*) progname=./$progname ;;
187ea133fd7Smrgesac
188a253d6aeSmrg
189ea133fd7Smrg# Make sure we have an absolute path for reexecution:
190ea133fd7Smrgcase $progpath in
191ea133fd7Smrg  [\\/]*|[A-Za-z]:\\*) ;;
192ea133fd7Smrg  *[\\/]*)
193ea133fd7Smrg     progdir=$func_dirname_result
194ea133fd7Smrg     progdir=`cd "$progdir" && pwd`
195ea133fd7Smrg     progpath="$progdir/$progname"
196ea133fd7Smrg     ;;
197ea133fd7Smrg  *)
198ea133fd7Smrg     save_IFS="$IFS"
199ea133fd7Smrg     IFS=:
200ea133fd7Smrg     for progdir in $PATH; do
201ea133fd7Smrg       IFS="$save_IFS"
202ea133fd7Smrg       test -x "$progdir/$progname" && break
203ea133fd7Smrg     done
204ea133fd7Smrg     IFS="$save_IFS"
205ea133fd7Smrg     test -n "$progdir" || progdir=`pwd`
206ea133fd7Smrg     progpath="$progdir/$progname"
207ea133fd7Smrg     ;;
208ea133fd7Smrgesac
209a253d6aeSmrg
210ea133fd7Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
211ea133fd7Smrg# metacharacters that are still active within double-quoted strings.
212ea133fd7SmrgXsed="${SED}"' -e 1s/^X//'
213ea133fd7Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g'
214ea133fd7Smrg
215ea133fd7Smrg# Same as above, but do not quote variable references.
216ea133fd7Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g'
217ea133fd7Smrg
218ea133fd7Smrg# Re-`\' parameter expansions in output of double_quote_subst that were
219ea133fd7Smrg# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
220ea133fd7Smrg# in input to double_quote_subst, that '$' was protected from expansion.
221ea133fd7Smrg# Since each input `\' is now two `\'s, look for any number of runs of
222ea133fd7Smrg# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
223ea133fd7Smrgbs='\\'
224ea133fd7Smrgbs2='\\\\'
225ea133fd7Smrgbs4='\\\\\\\\'
226ea133fd7Smrgdollar='\$'
227ea133fd7Smrgsed_double_backslash="\
228ea133fd7Smrg  s/$bs4/&\\
229ea133fd7Smrg/g
230ea133fd7Smrg  s/^$bs2$dollar/$bs&/
231ea133fd7Smrg  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
232ea133fd7Smrg  s/\n//g"
233ea133fd7Smrg
234ea133fd7Smrg# Standard options:
235ea133fd7Smrgopt_dry_run=false
236ea133fd7Smrgopt_help=false
237ea133fd7Smrgopt_quiet=false
238ea133fd7Smrgopt_verbose=false
239ea133fd7Smrgopt_warning=:
240ea133fd7Smrg
241ea133fd7Smrg# func_echo arg...
242ea133fd7Smrg# Echo program name prefixed message, along with the current mode
243ea133fd7Smrg# name if it has been set yet.
244ea133fd7Smrgfunc_echo ()
245ea133fd7Smrg{
246ea133fd7Smrg    $ECHO "$progname${mode+: }$mode: $*"
247ea133fd7Smrg}
248a253d6aeSmrg
249ea133fd7Smrg# func_verbose arg...
250ea133fd7Smrg# Echo program name prefixed message in verbose mode only.
251ea133fd7Smrgfunc_verbose ()
252ea133fd7Smrg{
253ea133fd7Smrg    $opt_verbose && func_echo ${1+"$@"}
254a253d6aeSmrg
255ea133fd7Smrg    # A bug in bash halts the script if the last line of a function
256ea133fd7Smrg    # fails when set -e is in force, so we need another command to
257ea133fd7Smrg    # work around that:
258ea133fd7Smrg    :
259ea133fd7Smrg}
260a253d6aeSmrg
261ea133fd7Smrg# func_error arg...
262ea133fd7Smrg# Echo program name prefixed message to standard error.
263ea133fd7Smrgfunc_error ()
264ea133fd7Smrg{
265ea133fd7Smrg    $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2
266ea133fd7Smrg}
267a253d6aeSmrg
268ea133fd7Smrg# func_warning arg...
269ea133fd7Smrg# Echo program name prefixed warning message to standard error.
270ea133fd7Smrgfunc_warning ()
271ea133fd7Smrg{
272ea133fd7Smrg    $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2
273a253d6aeSmrg
274ea133fd7Smrg    # bash bug again:
275ea133fd7Smrg    :
276ea133fd7Smrg}
277a253d6aeSmrg
278ea133fd7Smrg# func_fatal_error arg...
279ea133fd7Smrg# Echo program name prefixed message to standard error, and exit.
280ea133fd7Smrgfunc_fatal_error ()
281ea133fd7Smrg{
282ea133fd7Smrg    func_error ${1+"$@"}
283ea133fd7Smrg    exit $EXIT_FAILURE
284ea133fd7Smrg}
285a253d6aeSmrg
286ea133fd7Smrg# func_fatal_help arg...
287ea133fd7Smrg# Echo program name prefixed message to standard error, followed by
288ea133fd7Smrg# a help hint, and exit.
289ea133fd7Smrgfunc_fatal_help ()
290ea133fd7Smrg{
291ea133fd7Smrg    func_error ${1+"$@"}
292ea133fd7Smrg    func_fatal_error "$help"
293ea133fd7Smrg}
294ea133fd7Smrghelp="Try \`$progname --help' for more information."  ## default
295a253d6aeSmrg
296a253d6aeSmrg
297ea133fd7Smrg# func_grep expression filename
298ea133fd7Smrg# Check whether EXPRESSION matches any line of FILENAME, without output.
299ea133fd7Smrgfunc_grep ()
300ea133fd7Smrg{
301ea133fd7Smrg    $GREP "$1" "$2" >/dev/null 2>&1
302ea133fd7Smrg}
303ea133fd7Smrg
304ea133fd7Smrg
305ea133fd7Smrg# func_mkdir_p directory-path
306ea133fd7Smrg# Make sure the entire path to DIRECTORY-PATH is available.
307ea133fd7Smrgfunc_mkdir_p ()
308ea133fd7Smrg{
309ea133fd7Smrg    my_directory_path="$1"
310ea133fd7Smrg    my_dir_list=
311ea133fd7Smrg
312ea133fd7Smrg    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
313ea133fd7Smrg
314ea133fd7Smrg      # Protect directory names starting with `-'
315ea133fd7Smrg      case $my_directory_path in
316ea133fd7Smrg        -*) my_directory_path="./$my_directory_path" ;;
317ea133fd7Smrg      esac
318ea133fd7Smrg
319ea133fd7Smrg      # While some portion of DIR does not yet exist...
320ea133fd7Smrg      while test ! -d "$my_directory_path"; do
321ea133fd7Smrg        # ...make a list in topmost first order.  Use a colon delimited
322ea133fd7Smrg	# list incase some portion of path contains whitespace.
323ea133fd7Smrg        my_dir_list="$my_directory_path:$my_dir_list"
324ea133fd7Smrg
325ea133fd7Smrg        # If the last portion added has no slash in it, the list is done
326ea133fd7Smrg        case $my_directory_path in */*) ;; *) break ;; esac
327ea133fd7Smrg
328ea133fd7Smrg        # ...otherwise throw away the child directory and loop
329ea133fd7Smrg        my_directory_path=`$ECHO "X$my_directory_path" | $Xsed -e "$dirname"`
330ea133fd7Smrg      done
331ea133fd7Smrg      my_dir_list=`$ECHO "X$my_dir_list" | $Xsed -e 's,:*$,,'`
332ea133fd7Smrg
333ea133fd7Smrg      save_mkdir_p_IFS="$IFS"; IFS=':'
334ea133fd7Smrg      for my_dir in $my_dir_list; do
335ea133fd7Smrg	IFS="$save_mkdir_p_IFS"
336ea133fd7Smrg        # mkdir can fail with a `File exist' error if two processes
337ea133fd7Smrg        # try to create one of the directories concurrently.  Don't
338ea133fd7Smrg        # stop in that case!
339ea133fd7Smrg        $MKDIR "$my_dir" 2>/dev/null || :
340ea133fd7Smrg      done
341ea133fd7Smrg      IFS="$save_mkdir_p_IFS"
342ea133fd7Smrg
343ea133fd7Smrg      # Bail out if we (or some other process) failed to create a directory.
344ea133fd7Smrg      test -d "$my_directory_path" || \
345ea133fd7Smrg        func_fatal_error "Failed to create \`$1'"
346ea133fd7Smrg    fi
347ea133fd7Smrg}
348a253d6aeSmrg
349a253d6aeSmrg
350a253d6aeSmrg# func_mktempdir [string]
351a253d6aeSmrg# Make a temporary directory that won't clash with other running
352a253d6aeSmrg# libtool processes, and avoids race conditions if possible.  If
353a253d6aeSmrg# given, STRING is the basename for that directory.
354a253d6aeSmrgfunc_mktempdir ()
355a253d6aeSmrg{
356a253d6aeSmrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
357a253d6aeSmrg
358ea133fd7Smrg    if test "$opt_dry_run" = ":"; then
359a253d6aeSmrg      # Return a directory name, but don't create it in dry-run mode
360a253d6aeSmrg      my_tmpdir="${my_template}-$$"
361a253d6aeSmrg    else
362a253d6aeSmrg
363a253d6aeSmrg      # If mktemp works, use that first and foremost
364a253d6aeSmrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
365a253d6aeSmrg
366a253d6aeSmrg      if test ! -d "$my_tmpdir"; then
367ea133fd7Smrg        # Failing that, at least try and use $RANDOM to avoid a race
368ea133fd7Smrg        my_tmpdir="${my_template}-${RANDOM-0}$$"
369a253d6aeSmrg
370ea133fd7Smrg        save_mktempdir_umask=`umask`
371ea133fd7Smrg        umask 0077
372ea133fd7Smrg        $MKDIR "$my_tmpdir"
373ea133fd7Smrg        umask $save_mktempdir_umask
374a253d6aeSmrg      fi
375a253d6aeSmrg
376a253d6aeSmrg      # If we're not in dry-run mode, bomb out on failure
377ea133fd7Smrg      test -d "$my_tmpdir" || \
378ea133fd7Smrg        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
379a253d6aeSmrg    fi
380a253d6aeSmrg
381ea133fd7Smrg    $ECHO "X$my_tmpdir" | $Xsed
382a253d6aeSmrg}
383a253d6aeSmrg
384a253d6aeSmrg
385ea133fd7Smrg# func_quote_for_eval arg
386ea133fd7Smrg# Aesthetically quote ARG to be evaled later.
387ea133fd7Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
388ea133fd7Smrg# is double-quoted, suitable for a subsequent eval, whereas
389ea133fd7Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
390ea133fd7Smrg# which are still active within double quotes backslashified.
391ea133fd7Smrgfunc_quote_for_eval ()
392a253d6aeSmrg{
393ea133fd7Smrg    case $1 in
394ea133fd7Smrg      *[\\\`\"\$]*)
395ea133fd7Smrg	func_quote_for_eval_unquoted_result=`$ECHO "X$1" | $Xsed -e "$sed_quote_subst"` ;;
396ea133fd7Smrg      *)
397ea133fd7Smrg        func_quote_for_eval_unquoted_result="$1" ;;
398ea133fd7Smrg    esac
399ea133fd7Smrg
400ea133fd7Smrg    case $func_quote_for_eval_unquoted_result in
401ea133fd7Smrg      # Double-quote args containing shell metacharacters to delay
402ea133fd7Smrg      # word splitting, command substitution and and variable
403ea133fd7Smrg      # expansion for a subsequent eval.
404ea133fd7Smrg      # Many Bourne shells cannot handle close brackets correctly
405ea133fd7Smrg      # in scan sets, so we specify it separately.
406ea133fd7Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
407ea133fd7Smrg        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
408ea133fd7Smrg        ;;
409ea133fd7Smrg      *)
410ea133fd7Smrg        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
411a253d6aeSmrg    esac
412a253d6aeSmrg}
413a253d6aeSmrg
414a253d6aeSmrg
415ea133fd7Smrg# func_quote_for_expand arg
416ea133fd7Smrg# Aesthetically quote ARG to be evaled later; same as above,
417ea133fd7Smrg# but do not quote variable references.
418ea133fd7Smrgfunc_quote_for_expand ()
419a253d6aeSmrg{
420ea133fd7Smrg    case $1 in
421ea133fd7Smrg      *[\\\`\"]*)
422ea133fd7Smrg	my_arg=`$ECHO "X$1" | $Xsed \
423ea133fd7Smrg	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
424a253d6aeSmrg      *)
425ea133fd7Smrg        my_arg="$1" ;;
426ea133fd7Smrg    esac
427ea133fd7Smrg
428ea133fd7Smrg    case $my_arg in
429ea133fd7Smrg      # Double-quote args containing shell metacharacters to delay
430ea133fd7Smrg      # word splitting and command substitution for a subsequent eval.
431ea133fd7Smrg      # Many Bourne shells cannot handle close brackets correctly
432ea133fd7Smrg      # in scan sets, so we specify it separately.
433ea133fd7Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
434ea133fd7Smrg        my_arg="\"$my_arg\""
435ea133fd7Smrg        ;;
436ea133fd7Smrg    esac
437ea133fd7Smrg
438ea133fd7Smrg    func_quote_for_expand_result="$my_arg"
439a253d6aeSmrg}
440a253d6aeSmrg
441a253d6aeSmrg
442ea133fd7Smrg# func_show_eval cmd [fail_exp]
443ea133fd7Smrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
444ea133fd7Smrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
445ea133fd7Smrg# is given, then evaluate it.
446ea133fd7Smrgfunc_show_eval ()
447a253d6aeSmrg{
448ea133fd7Smrg    my_cmd="$1"
449ea133fd7Smrg    my_fail_exp="${2-:}"
450a253d6aeSmrg
451ea133fd7Smrg    ${opt_silent-false} || {
452ea133fd7Smrg      func_quote_for_expand "$my_cmd"
453ea133fd7Smrg      eval "func_echo $func_quote_for_expand_result"
454ea133fd7Smrg    }
455ea133fd7Smrg
456ea133fd7Smrg    if ${opt_dry_run-false}; then :; else
457ea133fd7Smrg      eval "$my_cmd"
458ea133fd7Smrg      my_status=$?
459ea133fd7Smrg      if test "$my_status" -eq 0; then :; else
460ea133fd7Smrg	eval "(exit $my_status); $my_fail_exp"
461ea133fd7Smrg      fi
462a253d6aeSmrg    fi
463a253d6aeSmrg}
464a253d6aeSmrg
465ea133fd7Smrg
466ea133fd7Smrg# func_show_eval_locale cmd [fail_exp]
467ea133fd7Smrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
468ea133fd7Smrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
469ea133fd7Smrg# is given, then evaluate it.  Use the saved locale for evaluation.
470ea133fd7Smrgfunc_show_eval_locale ()
471a253d6aeSmrg{
472ea133fd7Smrg    my_cmd="$1"
473ea133fd7Smrg    my_fail_exp="${2-:}"
474a253d6aeSmrg
475ea133fd7Smrg    ${opt_silent-false} || {
476ea133fd7Smrg      func_quote_for_expand "$my_cmd"
477ea133fd7Smrg      eval "func_echo $func_quote_for_expand_result"
478ea133fd7Smrg    }
479ea133fd7Smrg
480ea133fd7Smrg    if ${opt_dry_run-false}; then :; else
481ea133fd7Smrg      eval "$lt_user_locale
482ea133fd7Smrg	    $my_cmd"
483ea133fd7Smrg      my_status=$?
484ea133fd7Smrg      eval "$lt_safe_locale"
485ea133fd7Smrg      if test "$my_status" -eq 0; then :; else
486ea133fd7Smrg	eval "(exit $my_status); $my_fail_exp"
487a253d6aeSmrg      fi
488ea133fd7Smrg    fi
489a253d6aeSmrg}
490a253d6aeSmrg
491a253d6aeSmrg
492a253d6aeSmrg
493ea133fd7Smrg
494ea133fd7Smrg
495ea133fd7Smrg# func_version
496ea133fd7Smrg# Echo version message to standard output and exit.
497ea133fd7Smrgfunc_version ()
498ea133fd7Smrg{
499ea133fd7Smrg    $SED -n '/^# '$PROGRAM' (GNU /,/# warranty; / {
500ea133fd7Smrg        s/^# //
501ea133fd7Smrg	s/^# *$//
502ea133fd7Smrg        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
503ea133fd7Smrg        p
504ea133fd7Smrg     }' < "$progpath"
505ea133fd7Smrg     exit $?
506ea133fd7Smrg}
507ea133fd7Smrg
508ea133fd7Smrg# func_usage
509ea133fd7Smrg# Echo short help message to standard output and exit.
510ea133fd7Smrgfunc_usage ()
511ea133fd7Smrg{
512ea133fd7Smrg    $SED -n '/^# Usage:/,/# -h/ {
513ea133fd7Smrg        s/^# //
514ea133fd7Smrg	s/^# *$//
515ea133fd7Smrg	s/\$progname/'$progname'/
516ea133fd7Smrg	p
517ea133fd7Smrg    }' < "$progpath"
518ea133fd7Smrg    $ECHO
519ea133fd7Smrg    $ECHO "run \`$progname --help | more' for full usage"
520ea133fd7Smrg    exit $?
521ea133fd7Smrg}
522ea133fd7Smrg
523ea133fd7Smrg# func_help
524ea133fd7Smrg# Echo long help message to standard output and exit.
525ea133fd7Smrgfunc_help ()
526ea133fd7Smrg{
527ea133fd7Smrg    $SED -n '/^# Usage:/,/# Report bugs to/ {
528ea133fd7Smrg        s/^# //
529ea133fd7Smrg	s/^# *$//
530ea133fd7Smrg	s*\$progname*'$progname'*
531ea133fd7Smrg	s*\$host*'"$host"'*
532ea133fd7Smrg	s*\$SHELL*'"$SHELL"'*
533ea133fd7Smrg	s*\$LTCC*'"$LTCC"'*
534ea133fd7Smrg	s*\$LTCFLAGS*'"$LTCFLAGS"'*
535ea133fd7Smrg	s*\$LD*'"$LD"'*
536ea133fd7Smrg	s/\$with_gnu_ld/'"$with_gnu_ld"'/
537ea133fd7Smrg	s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
538ea133fd7Smrg	s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
539ea133fd7Smrg	p
540ea133fd7Smrg     }' < "$progpath"
541ea133fd7Smrg    exit $?
542ea133fd7Smrg}
543ea133fd7Smrg
544ea133fd7Smrg# func_missing_arg argname
545ea133fd7Smrg# Echo program name prefixed message to standard error and set global
546ea133fd7Smrg# exit_cmd.
547ea133fd7Smrgfunc_missing_arg ()
548ea133fd7Smrg{
549ea133fd7Smrg    func_error "missing argument for $1"
550ea133fd7Smrg    exit_cmd=exit
551ea133fd7Smrg}
552ea133fd7Smrg
553ea133fd7Smrgexit_cmd=:
554ea133fd7Smrg
555ea133fd7Smrg
556ea133fd7Smrg
557ea133fd7Smrg
558ea133fd7Smrg
559ea133fd7Smrg# Check that we have a working $ECHO.
560ea133fd7Smrgif test "X$1" = X--no-reexec; then
561ea133fd7Smrg  # Discard the --no-reexec flag, and continue.
562a253d6aeSmrg  shift
563ea133fd7Smrgelif test "X$1" = X--fallback-echo; then
564ea133fd7Smrg  # Avoid inline document here, it may be left over
565ea133fd7Smrg  :
566ea133fd7Smrgelif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then
567ea133fd7Smrg  # Yippee, $ECHO works!
568ea133fd7Smrg  :
569ea133fd7Smrgelse
570ea133fd7Smrg  # Restart under the correct shell, and then maybe $ECHO will work.
571ea133fd7Smrg  exec $SHELL "$progpath" --no-reexec ${1+"$@"}
572ea133fd7Smrgfi
573a253d6aeSmrg
574ea133fd7Smrgif test "X$1" = X--fallback-echo; then
575ea133fd7Smrg  # used as fallback echo
576ea133fd7Smrg  shift
577ea133fd7Smrg  cat <<EOF
578ea133fd7Smrg$*
579ea133fd7SmrgEOF
580ea133fd7Smrg  exit $EXIT_SUCCESS
581ea133fd7Smrgfi
582a253d6aeSmrg
583ea133fd7Smrgmagic="%%%MAGIC variable%%%"
584ea133fd7Smrgmagic_exe="%%%MAGIC EXE variable%%%"
585a253d6aeSmrg
586ea133fd7Smrg# Global variables.
587ea133fd7Smrg# $mode is unset
588ea133fd7Smrgnonopt=
589ea133fd7Smrgexecute_dlfiles=
590ea133fd7Smrgpreserve_args=
591ea133fd7Smrglo2o="s/\\.lo\$/.${objext}/"
592ea133fd7Smrgo2lo="s/\\.${objext}\$/.lo/"
593ea133fd7Smrgextracted_archives=
594ea133fd7Smrgextracted_serial=0
595a253d6aeSmrg
596ea133fd7Smrgopt_dry_run=false
597ea133fd7Smrgopt_duplicate_deps=false
598ea133fd7Smrgopt_silent=false
599ea133fd7Smrgopt_debug=:
600a253d6aeSmrg
601ea133fd7Smrg# If this variable is set in any of the actions, the command in it
602ea133fd7Smrg# will be execed at the end.  This prevents here-documents from being
603ea133fd7Smrg# left over by shells.
604ea133fd7Smrgexec_cmd=
605a253d6aeSmrg
606ea133fd7Smrg# func_fatal_configuration arg...
607ea133fd7Smrg# Echo program name prefixed message to standard error, followed by
608ea133fd7Smrg# a configuration failure hint, and exit.
609ea133fd7Smrgfunc_fatal_configuration ()
610ea133fd7Smrg{
611ea133fd7Smrg    func_error ${1+"$@"}
612ea133fd7Smrg    func_error "See the $PACKAGE documentation for more information."
613ea133fd7Smrg    func_fatal_error "Fatal configuration error."
614ea133fd7Smrg}
615ea133fd7Smrg
616ea133fd7Smrg
617ea133fd7Smrg# func_config
618ea133fd7Smrg# Display the configuration for all the tags in this script.
619ea133fd7Smrgfunc_config ()
620ea133fd7Smrg{
621ea133fd7Smrg    re_begincf='^# ### BEGIN LIBTOOL'
622ea133fd7Smrg    re_endcf='^# ### END LIBTOOL'
623ea133fd7Smrg
624ea133fd7Smrg    # Default configuration.
625ea133fd7Smrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
626a253d6aeSmrg
627a253d6aeSmrg    # Now print the configurations for the tags.
628a253d6aeSmrg    for tagname in $taglist; do
629ea133fd7Smrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
630a253d6aeSmrg    done
631a253d6aeSmrg
632ea133fd7Smrg    exit $?
633ea133fd7Smrg}
634a253d6aeSmrg
635ea133fd7Smrg# func_features
636ea133fd7Smrg# Display the features supported by this script.
637ea133fd7Smrgfunc_features ()
638ea133fd7Smrg{
639ea133fd7Smrg    $ECHO "host: $host"
640a253d6aeSmrg    if test "$build_libtool_libs" = yes; then
641ea133fd7Smrg      $ECHO "enable shared libraries"
642a253d6aeSmrg    else
643ea133fd7Smrg      $ECHO "disable shared libraries"
644a253d6aeSmrg    fi
645a253d6aeSmrg    if test "$build_old_libs" = yes; then
646ea133fd7Smrg      $ECHO "enable static libraries"
647a253d6aeSmrg    else
648ea133fd7Smrg      $ECHO "disable static libraries"
649a253d6aeSmrg    fi
650ea133fd7Smrg
651a253d6aeSmrg    exit $?
652ea133fd7Smrg}
653ea133fd7Smrg
654ea133fd7Smrg# func_enable_tag tagname
655ea133fd7Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or
656ea133fd7Smrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
657ea133fd7Smrg# variable here.
658ea133fd7Smrgfunc_enable_tag ()
659ea133fd7Smrg{
660ea133fd7Smrg  # Global variable:
661ea133fd7Smrg  tagname="$1"
662a253d6aeSmrg
663ea133fd7Smrg  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
664ea133fd7Smrg  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
665ea133fd7Smrg  sed_extractcf="/$re_begincf/,/$re_endcf/p"
666a253d6aeSmrg
667ea133fd7Smrg  # Validate tagname.
668ea133fd7Smrg  case $tagname in
669ea133fd7Smrg    *[!-_A-Za-z0-9,/]*)
670ea133fd7Smrg      func_fatal_error "invalid tag name: $tagname"
671ea133fd7Smrg      ;;
672ea133fd7Smrg  esac
673a253d6aeSmrg
674ea133fd7Smrg  # Don't test for the "default" C tag, as we know it's
675ea133fd7Smrg  # there but not specially marked.
676ea133fd7Smrg  case $tagname in
677ea133fd7Smrg    CC) ;;
678ea133fd7Smrg    *)
679ea133fd7Smrg      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
680ea133fd7Smrg	taglist="$taglist $tagname"
681ea133fd7Smrg
682ea133fd7Smrg	# Evaluate the configuration.  Be careful to quote the path
683ea133fd7Smrg	# and the sed script, to avoid splitting on whitespace, but
684ea133fd7Smrg	# also don't use non-portable quotes within backquotes within
685ea133fd7Smrg	# quotes we have to do it in 2 steps:
686ea133fd7Smrg	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
687ea133fd7Smrg	eval "$extractedcf"
688ea133fd7Smrg      else
689ea133fd7Smrg	func_error "ignoring unknown tag $tagname"
690ea133fd7Smrg      fi
691ea133fd7Smrg      ;;
692ea133fd7Smrg  esac
693ea133fd7Smrg}
694a253d6aeSmrg
695ea133fd7Smrg# Parse options once, thoroughly.  This comes as soon as possible in
696ea133fd7Smrg# the script to make things like `libtool --version' happen quickly.
697ea133fd7Smrg{
698a253d6aeSmrg
699ea133fd7Smrg  # Shorthand for --mode=foo, only valid as the first argument
700ea133fd7Smrg  case $1 in
701ea133fd7Smrg  clean|clea|cle|cl)
702ea133fd7Smrg    shift; set dummy --mode clean ${1+"$@"}; shift
703a253d6aeSmrg    ;;
704ea133fd7Smrg  compile|compil|compi|comp|com|co|c)
705ea133fd7Smrg    shift; set dummy --mode compile ${1+"$@"}; shift
706a253d6aeSmrg    ;;
707ea133fd7Smrg  execute|execut|execu|exec|exe|ex|e)
708ea133fd7Smrg    shift; set dummy --mode execute ${1+"$@"}; shift
709a253d6aeSmrg    ;;
710ea133fd7Smrg  finish|finis|fini|fin|fi|f)
711ea133fd7Smrg    shift; set dummy --mode finish ${1+"$@"}; shift
712a253d6aeSmrg    ;;
713ea133fd7Smrg  install|instal|insta|inst|ins|in|i)
714ea133fd7Smrg    shift; set dummy --mode install ${1+"$@"}; shift
715ea133fd7Smrg    ;;
716ea133fd7Smrg  link|lin|li|l)
717ea133fd7Smrg    shift; set dummy --mode link ${1+"$@"}; shift
718ea133fd7Smrg    ;;
719ea133fd7Smrg  uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
720ea133fd7Smrg    shift; set dummy --mode uninstall ${1+"$@"}; shift
721a253d6aeSmrg    ;;
722a253d6aeSmrg  esac
723a253d6aeSmrg
724ea133fd7Smrg  # Parse non-mode specific arguments:
725ea133fd7Smrg  while test "$#" -gt 0; do
726ea133fd7Smrg    opt="$1"
727ea133fd7Smrg    shift
728a253d6aeSmrg
729ea133fd7Smrg    case $opt in
730ea133fd7Smrg      --config)		func_config					;;
731a253d6aeSmrg
732ea133fd7Smrg      --debug)		preserve_args="$preserve_args $opt"
733ea133fd7Smrg			func_echo "enabling shell trace mode"
734ea133fd7Smrg			opt_debug='set -x'
735ea133fd7Smrg			$opt_debug
736ea133fd7Smrg			;;
737a253d6aeSmrg
738ea133fd7Smrg      -dlopen)		test "$#" -eq 0 && func_missing_arg "$opt" && break
739ea133fd7Smrg			execute_dlfiles="$execute_dlfiles $1"
740ea133fd7Smrg			shift
741ea133fd7Smrg			;;
742a253d6aeSmrg
743ea133fd7Smrg      --dry-run | -n)	opt_dry_run=:					;;
744ea133fd7Smrg      --features)       func_features					;;
745ea133fd7Smrg      --finish)		mode="finish"					;;
746ea133fd7Smrg
747ea133fd7Smrg      --mode)		test "$#" -eq 0 && func_missing_arg "$opt" && break
748ea133fd7Smrg			case $1 in
749ea133fd7Smrg			  # Valid mode arguments:
750ea133fd7Smrg			  clean)	;;
751ea133fd7Smrg			  compile)	;;
752ea133fd7Smrg			  execute)	;;
753ea133fd7Smrg			  finish)	;;
754ea133fd7Smrg			  install)	;;
755ea133fd7Smrg			  link)		;;
756ea133fd7Smrg			  relink)	;;
757ea133fd7Smrg			  uninstall)	;;
758ea133fd7Smrg
759ea133fd7Smrg			  # Catch anything else as an error
760ea133fd7Smrg			  *) func_error "invalid argument for $opt"
761ea133fd7Smrg			     exit_cmd=exit
762ea133fd7Smrg			     break
763ea133fd7Smrg			     ;;
764ea133fd7Smrg		        esac
765ea133fd7Smrg
766ea133fd7Smrg			mode="$1"
767ea133fd7Smrg			shift
768ea133fd7Smrg			;;
769ea133fd7Smrg
770ea133fd7Smrg      --preserve-dup-deps)
771ea133fd7Smrg			opt_duplicate_deps=:				;;
772ea133fd7Smrg
773ea133fd7Smrg      --quiet|--silent)	preserve_args="$preserve_args $opt"
774ea133fd7Smrg			opt_silent=:
775ea133fd7Smrg			;;
776ea133fd7Smrg
777ea133fd7Smrg      --verbose| -v)	preserve_args="$preserve_args $opt"
778ea133fd7Smrg			opt_silent=false
779ea133fd7Smrg			;;
780ea133fd7Smrg
781ea133fd7Smrg      --tag)		test "$#" -eq 0 && func_missing_arg "$opt" && break
782ea133fd7Smrg			preserve_args="$preserve_args $opt $1"
783ea133fd7Smrg			func_enable_tag "$1"	# tagname is set here
784ea133fd7Smrg			shift
785ea133fd7Smrg			;;
786ea133fd7Smrg
787ea133fd7Smrg      # Separate optargs to long options:
788ea133fd7Smrg      -dlopen=*|--mode=*|--tag=*)
789ea133fd7Smrg			func_opt_split "$opt"
790ea133fd7Smrg			set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"}
791ea133fd7Smrg			shift
792ea133fd7Smrg			;;
793ea133fd7Smrg
794ea133fd7Smrg      -\?|-h)		func_usage					;;
795ea133fd7Smrg      --help)		opt_help=:					;;
796ea133fd7Smrg      --version)	func_version					;;
797ea133fd7Smrg
798ea133fd7Smrg      -*)		func_fatal_help "unrecognized option \`$opt'"	;;
799ea133fd7Smrg
800ea133fd7Smrg      *)		nonopt="$opt"
801ea133fd7Smrg			break
802ea133fd7Smrg			;;
803ea133fd7Smrg    esac
804ea133fd7Smrg  done
805ea133fd7Smrg
806ea133fd7Smrg
807ea133fd7Smrg  case $host in
808ea133fd7Smrg    *cygwin* | *mingw* | *pw32* | *cegcc*)
809ea133fd7Smrg      # don't eliminate duplications in $postdeps and $predeps
810ea133fd7Smrg      opt_duplicate_compiler_generated_deps=:
811a253d6aeSmrg      ;;
812a253d6aeSmrg    *)
813ea133fd7Smrg      opt_duplicate_compiler_generated_deps=$opt_duplicate_deps
814ea133fd7Smrg      ;;
815ea133fd7Smrg  esac
816a253d6aeSmrg
817ea133fd7Smrg  # Having warned about all mis-specified options, bail out if
818ea133fd7Smrg  # anything was wrong.
819ea133fd7Smrg  $exit_cmd $EXIT_FAILURE
820ea133fd7Smrg}
821ea133fd7Smrg
822ea133fd7Smrg# func_check_version_match
823ea133fd7Smrg# Ensure that we are using m4 macros, and libtool script from the same
824ea133fd7Smrg# release of libtool.
825ea133fd7Smrgfunc_check_version_match ()
826ea133fd7Smrg{
827ea133fd7Smrg  if test "$package_revision" != "$macro_revision"; then
828ea133fd7Smrg    if test "$VERSION" != "$macro_version"; then
829ea133fd7Smrg      if test -z "$macro_version"; then
830ea133fd7Smrg        cat >&2 <<_LT_EOF
831ea133fd7Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
832ea133fd7Smrg$progname: definition of this LT_INIT comes from an older release.
833ea133fd7Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
834ea133fd7Smrg$progname: and run autoconf again.
835ea133fd7Smrg_LT_EOF
836ea133fd7Smrg      else
837ea133fd7Smrg        cat >&2 <<_LT_EOF
838ea133fd7Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
839ea133fd7Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
840ea133fd7Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
841ea133fd7Smrg$progname: and run autoconf again.
842ea133fd7Smrg_LT_EOF
843a253d6aeSmrg      fi
844ea133fd7Smrg    else
845ea133fd7Smrg      cat >&2 <<_LT_EOF
846ea133fd7Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
847ea133fd7Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
848ea133fd7Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
849ea133fd7Smrg$progname: of $PACKAGE $VERSION and run autoconf again.
850ea133fd7Smrg_LT_EOF
851ea133fd7Smrg    fi
852ea133fd7Smrg
853ea133fd7Smrg    exit $EXIT_MISMATCH
854ea133fd7Smrg  fi
855ea133fd7Smrg}
856ea133fd7Smrg
857ea133fd7Smrg
858ea133fd7Smrg## ----------- ##
859ea133fd7Smrg##    Main.    ##
860ea133fd7Smrg## ----------- ##
861ea133fd7Smrg
862ea133fd7Smrg$opt_help || {
863ea133fd7Smrg  # Sanity checks first:
864ea133fd7Smrg  func_check_version_match
865ea133fd7Smrg
866ea133fd7Smrg  if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
867ea133fd7Smrg    func_fatal_configuration "not configured to build any kind of library"
868a253d6aeSmrg  fi
869a253d6aeSmrg
870ea133fd7Smrg  test -z "$mode" && func_fatal_error "error: you must specify a MODE."
871ea133fd7Smrg
872ea133fd7Smrg
873ea133fd7Smrg  # Darwin sucks
874ea133fd7Smrg  eval std_shrext=\"$shrext_cmds\"
875ea133fd7Smrg
876ea133fd7Smrg
877a253d6aeSmrg  # Only execute mode is allowed to have -dlopen flags.
878a253d6aeSmrg  if test -n "$execute_dlfiles" && test "$mode" != execute; then
879ea133fd7Smrg    func_error "unrecognized option \`-dlopen'"
880ea133fd7Smrg    $ECHO "$help" 1>&2
881a253d6aeSmrg    exit $EXIT_FAILURE
882a253d6aeSmrg  fi
883a253d6aeSmrg
884a253d6aeSmrg  # Change the help message to a mode-specific one.
885a253d6aeSmrg  generic_help="$help"
886ea133fd7Smrg  help="Try \`$progname --help --mode=$mode' for more information."
887ea133fd7Smrg}
888a253d6aeSmrg
889a253d6aeSmrg
890ea133fd7Smrg# func_lalib_p file
891ea133fd7Smrg# True iff FILE is a libtool `.la' library or `.lo' object file.
892ea133fd7Smrg# This function is only a basic sanity check; it will hardly flush out
893ea133fd7Smrg# determined imposters.
894ea133fd7Smrgfunc_lalib_p ()
895ea133fd7Smrg{
896ea133fd7Smrg    test -f "$1" &&
897ea133fd7Smrg      $SED -e 4q "$1" 2>/dev/null \
898ea133fd7Smrg        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
899ea133fd7Smrg}
900a253d6aeSmrg
901ea133fd7Smrg# func_lalib_unsafe_p file
902ea133fd7Smrg# True iff FILE is a libtool `.la' library or `.lo' object file.
903ea133fd7Smrg# This function implements the same check as func_lalib_p without
904ea133fd7Smrg# resorting to external programs.  To this end, it redirects stdin and
905ea133fd7Smrg# closes it afterwards, without saving the original file descriptor.
906ea133fd7Smrg# As a safety measure, use it only where a negative result would be
907ea133fd7Smrg# fatal anyway.  Works if `file' does not exist.
908ea133fd7Smrgfunc_lalib_unsafe_p ()
909ea133fd7Smrg{
910ea133fd7Smrg    lalib_p=no
911ea133fd7Smrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
912ea133fd7Smrg	for lalib_p_l in 1 2 3 4
913ea133fd7Smrg	do
914ea133fd7Smrg	    read lalib_p_line
915ea133fd7Smrg	    case "$lalib_p_line" in
916ea133fd7Smrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
917ea133fd7Smrg	    esac
918ea133fd7Smrg	done
919ea133fd7Smrg	exec 0<&5 5<&-
920ea133fd7Smrg    fi
921ea133fd7Smrg    test "$lalib_p" = yes
922ea133fd7Smrg}
923a253d6aeSmrg
924ea133fd7Smrg# func_ltwrapper_script_p file
925ea133fd7Smrg# True iff FILE is a libtool wrapper script
926ea133fd7Smrg# This function is only a basic sanity check; it will hardly flush out
927ea133fd7Smrg# determined imposters.
928ea133fd7Smrgfunc_ltwrapper_script_p ()
929ea133fd7Smrg{
930ea133fd7Smrg    func_lalib_p "$1"
931ea133fd7Smrg}
932a253d6aeSmrg
933ea133fd7Smrg# func_ltwrapper_executable_p file
934ea133fd7Smrg# True iff FILE is a libtool wrapper executable
935ea133fd7Smrg# This function is only a basic sanity check; it will hardly flush out
936ea133fd7Smrg# determined imposters.
937ea133fd7Smrgfunc_ltwrapper_executable_p ()
938ea133fd7Smrg{
939ea133fd7Smrg    func_ltwrapper_exec_suffix=
940ea133fd7Smrg    case $1 in
941ea133fd7Smrg    *.exe) ;;
942ea133fd7Smrg    *) func_ltwrapper_exec_suffix=.exe ;;
943ea133fd7Smrg    esac
944ea133fd7Smrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
945ea133fd7Smrg}
946a253d6aeSmrg
947ea133fd7Smrg# func_ltwrapper_scriptname file
948ea133fd7Smrg# Assumes file is an ltwrapper_executable
949ea133fd7Smrg# uses $file to determine the appropriate filename for a
950ea133fd7Smrg# temporary ltwrapper_script.
951ea133fd7Smrgfunc_ltwrapper_scriptname ()
952ea133fd7Smrg{
953ea133fd7Smrg    func_ltwrapper_scriptname_result=""
954ea133fd7Smrg    if func_ltwrapper_executable_p "$1"; then
955ea133fd7Smrg	func_dirname_and_basename "$1" "" "."
956ea133fd7Smrg	func_stripname '' '.exe' "$func_basename_result"
957ea133fd7Smrg	func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
958ea133fd7Smrg    fi
959ea133fd7Smrg}
960a253d6aeSmrg
961ea133fd7Smrg# func_ltwrapper_p file
962ea133fd7Smrg# True iff FILE is a libtool wrapper script or wrapper executable
963ea133fd7Smrg# This function is only a basic sanity check; it will hardly flush out
964ea133fd7Smrg# determined imposters.
965ea133fd7Smrgfunc_ltwrapper_p ()
966ea133fd7Smrg{
967ea133fd7Smrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
968ea133fd7Smrg}
969a253d6aeSmrg
970a253d6aeSmrg
971ea133fd7Smrg# func_execute_cmds commands fail_cmd
972ea133fd7Smrg# Execute tilde-delimited COMMANDS.
973ea133fd7Smrg# If FAIL_CMD is given, eval that upon failure.
974ea133fd7Smrg# FAIL_CMD may read-access the current command in variable CMD!
975ea133fd7Smrgfunc_execute_cmds ()
976ea133fd7Smrg{
977ea133fd7Smrg    $opt_debug
978ea133fd7Smrg    save_ifs=$IFS; IFS='~'
979ea133fd7Smrg    for cmd in $1; do
980ea133fd7Smrg      IFS=$save_ifs
981ea133fd7Smrg      eval cmd=\"$cmd\"
982ea133fd7Smrg      func_show_eval "$cmd" "${2-:}"
983ea133fd7Smrg    done
984ea133fd7Smrg    IFS=$save_ifs
985ea133fd7Smrg}
986ea133fd7Smrg
987ea133fd7Smrg
988ea133fd7Smrg# func_source file
989ea133fd7Smrg# Source FILE, adding directory component if necessary.
990ea133fd7Smrg# Note that it is not necessary on cygwin/mingw to append a dot to
991ea133fd7Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
992ea133fd7Smrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
993ea133fd7Smrg# `FILE.' does not work on cygwin managed mounts.
994ea133fd7Smrgfunc_source ()
995ea133fd7Smrg{
996ea133fd7Smrg    $opt_debug
997ea133fd7Smrg    case $1 in
998ea133fd7Smrg    */* | *\\*)	. "$1" ;;
999ea133fd7Smrg    *)		. "./$1" ;;
1000ea133fd7Smrg    esac
1001ea133fd7Smrg}
1002ea133fd7Smrg
1003ea133fd7Smrg
1004ea133fd7Smrg# func_infer_tag arg
1005ea133fd7Smrg# Infer tagged configuration to use if any are available and
1006ea133fd7Smrg# if one wasn't chosen via the "--tag" command line option.
1007ea133fd7Smrg# Only attempt this if the compiler in the base compile
1008ea133fd7Smrg# command doesn't match the default compiler.
1009ea133fd7Smrg# arg is usually of the form 'gcc ...'
1010ea133fd7Smrgfunc_infer_tag ()
1011ea133fd7Smrg{
1012ea133fd7Smrg    $opt_debug
1013ea133fd7Smrg    if test -n "$available_tags" && test -z "$tagname"; then
1014ea133fd7Smrg      CC_quoted=
1015ea133fd7Smrg      for arg in $CC; do
1016ea133fd7Smrg        func_quote_for_eval "$arg"
1017ea133fd7Smrg	CC_quoted="$CC_quoted $func_quote_for_eval_result"
1018ea133fd7Smrg      done
1019ea133fd7Smrg      case $@ in
1020ea133fd7Smrg      # Blanks in the command may have been stripped by the calling shell,
1021ea133fd7Smrg      # but not from the CC environment variable when configure was run.
1022ea133fd7Smrg      " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) ;;
1023ea133fd7Smrg      # Blanks at the start of $base_compile will cause this to fail
1024ea133fd7Smrg      # if we don't check for them as well.
1025ea133fd7Smrg      *)
1026ea133fd7Smrg	for z in $available_tags; do
1027ea133fd7Smrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
1028ea133fd7Smrg	    # Evaluate the configuration.
1029ea133fd7Smrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
1030ea133fd7Smrg	    CC_quoted=
1031ea133fd7Smrg	    for arg in $CC; do
1032ea133fd7Smrg	      # Double-quote args containing other shell metacharacters.
1033ea133fd7Smrg	      func_quote_for_eval "$arg"
1034ea133fd7Smrg	      CC_quoted="$CC_quoted $func_quote_for_eval_result"
1035ea133fd7Smrg	    done
1036ea133fd7Smrg	    case "$@ " in
1037ea133fd7Smrg	      " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*)
1038ea133fd7Smrg	      # The compiler in the base compile command matches
1039ea133fd7Smrg	      # the one in the tagged configuration.
1040ea133fd7Smrg	      # Assume this is the tagged configuration we want.
1041ea133fd7Smrg	      tagname=$z
1042ea133fd7Smrg	      break
1043ea133fd7Smrg	      ;;
1044a253d6aeSmrg	    esac
1045ea133fd7Smrg	  fi
1046ea133fd7Smrg	done
1047ea133fd7Smrg	# If $tagname still isn't set, then no tagged configuration
1048ea133fd7Smrg	# was found and let the user know that the "--tag" command
1049ea133fd7Smrg	# line option must be used.
1050ea133fd7Smrg	if test -z "$tagname"; then
1051ea133fd7Smrg	  func_echo "unable to infer tagged configuration"
1052ea133fd7Smrg	  func_fatal_error "specify a tag with \`--tag'"
1053ea133fd7Smrg#	else
1054ea133fd7Smrg#	  func_verbose "using $tagname tagged configuration"
1055ea133fd7Smrg	fi
1056ea133fd7Smrg	;;
1057ea133fd7Smrg      esac
1058ea133fd7Smrg    fi
1059ea133fd7Smrg}
1060ea133fd7Smrg
1061ea133fd7Smrg
1062ea133fd7Smrg
1063ea133fd7Smrg# func_write_libtool_object output_name pic_name nonpic_name
1064ea133fd7Smrg# Create a libtool object file (analogous to a ".la" file),
1065ea133fd7Smrg# but don't create it if we're doing a dry run.
1066ea133fd7Smrgfunc_write_libtool_object ()
1067ea133fd7Smrg{
1068ea133fd7Smrg    write_libobj=${1}
1069ea133fd7Smrg    if test "$build_libtool_libs" = yes; then
1070ea133fd7Smrg      write_lobj=\'${2}\'
1071ea133fd7Smrg    else
1072ea133fd7Smrg      write_lobj=none
1073ea133fd7Smrg    fi
1074ea133fd7Smrg
1075ea133fd7Smrg    if test "$build_old_libs" = yes; then
1076ea133fd7Smrg      write_oldobj=\'${3}\'
1077ea133fd7Smrg    else
1078ea133fd7Smrg      write_oldobj=none
1079ea133fd7Smrg    fi
1080ea133fd7Smrg
1081ea133fd7Smrg    $opt_dry_run || {
1082ea133fd7Smrg      cat >${write_libobj}T <<EOF
1083ea133fd7Smrg# $write_libobj - a libtool object file
1084ea133fd7Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1085ea133fd7Smrg#
1086ea133fd7Smrg# Please DO NOT delete this file!
1087ea133fd7Smrg# It is necessary for linking the library.
1088ea133fd7Smrg
1089ea133fd7Smrg# Name of the PIC object.
1090ea133fd7Smrgpic_object=$write_lobj
1091ea133fd7Smrg
1092ea133fd7Smrg# Name of the non-PIC object
1093ea133fd7Smrgnon_pic_object=$write_oldobj
1094ea133fd7Smrg
1095ea133fd7SmrgEOF
1096ea133fd7Smrg      $MV "${write_libobj}T" "${write_libobj}"
1097ea133fd7Smrg    }
1098ea133fd7Smrg}
1099ea133fd7Smrg
1100ea133fd7Smrg# func_mode_compile arg...
1101ea133fd7Smrgfunc_mode_compile ()
1102ea133fd7Smrg{
1103ea133fd7Smrg    $opt_debug
1104ea133fd7Smrg    # Get the compilation command and the source file.
1105ea133fd7Smrg    base_compile=
1106ea133fd7Smrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
1107ea133fd7Smrg    suppress_opt=yes
1108ea133fd7Smrg    suppress_output=
1109ea133fd7Smrg    arg_mode=normal
1110ea133fd7Smrg    libobj=
1111ea133fd7Smrg    later=
1112ea133fd7Smrg    pie_flag=
1113ea133fd7Smrg
1114ea133fd7Smrg    for arg
1115ea133fd7Smrg    do
1116ea133fd7Smrg      case $arg_mode in
1117ea133fd7Smrg      arg  )
1118ea133fd7Smrg	# do not "continue".  Instead, add this to base_compile
1119ea133fd7Smrg	lastarg="$arg"
1120ea133fd7Smrg	arg_mode=normal
1121ea133fd7Smrg	;;
1122ea133fd7Smrg
1123ea133fd7Smrg      target )
1124ea133fd7Smrg	libobj="$arg"
1125ea133fd7Smrg	arg_mode=normal
1126ea133fd7Smrg	continue
1127ea133fd7Smrg	;;
1128ea133fd7Smrg
1129ea133fd7Smrg      normal )
1130ea133fd7Smrg	# Accept any command-line options.
1131ea133fd7Smrg	case $arg in
1132ea133fd7Smrg	-o)
1133ea133fd7Smrg	  test -n "$libobj" && \
1134ea133fd7Smrg	    func_fatal_error "you cannot specify \`-o' more than once"
1135ea133fd7Smrg	  arg_mode=target
1136ea133fd7Smrg	  continue
1137ea133fd7Smrg	  ;;
1138ea133fd7Smrg
1139ea133fd7Smrg	-pie | -fpie | -fPIE)
1140ea133fd7Smrg          pie_flag="$pie_flag $arg"
1141ea133fd7Smrg	  continue
1142ea133fd7Smrg	  ;;
1143ea133fd7Smrg
1144ea133fd7Smrg	-shared | -static | -prefer-pic | -prefer-non-pic)
1145ea133fd7Smrg	  later="$later $arg"
1146ea133fd7Smrg	  continue
1147ea133fd7Smrg	  ;;
1148ea133fd7Smrg
1149ea133fd7Smrg	-no-suppress)
1150ea133fd7Smrg	  suppress_opt=no
1151ea133fd7Smrg	  continue
1152ea133fd7Smrg	  ;;
1153ea133fd7Smrg
1154ea133fd7Smrg	-Xcompiler)
1155ea133fd7Smrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
1156ea133fd7Smrg	  continue      #  The current "srcfile" will either be retained or
1157ea133fd7Smrg	  ;;            #  replaced later.  I would guess that would be a bug.
1158ea133fd7Smrg
1159ea133fd7Smrg	-Wc,*)
1160ea133fd7Smrg	  func_stripname '-Wc,' '' "$arg"
1161ea133fd7Smrg	  args=$func_stripname_result
1162ea133fd7Smrg	  lastarg=
1163ea133fd7Smrg	  save_ifs="$IFS"; IFS=','
1164ea133fd7Smrg	  for arg in $args; do
1165ea133fd7Smrg	    IFS="$save_ifs"
1166ea133fd7Smrg	    func_quote_for_eval "$arg"
1167ea133fd7Smrg	    lastarg="$lastarg $func_quote_for_eval_result"
1168a253d6aeSmrg	  done
1169a253d6aeSmrg	  IFS="$save_ifs"
1170ea133fd7Smrg	  func_stripname ' ' '' "$lastarg"
1171ea133fd7Smrg	  lastarg=$func_stripname_result
1172a253d6aeSmrg
1173a253d6aeSmrg	  # Add the arguments to base_compile.
1174a253d6aeSmrg	  base_compile="$base_compile $lastarg"
1175a253d6aeSmrg	  continue
1176a253d6aeSmrg	  ;;
1177a253d6aeSmrg
1178ea133fd7Smrg	*)
1179a253d6aeSmrg	  # Accept the current argument as the source file.
1180a253d6aeSmrg	  # The previous "srcfile" becomes the current argument.
1181a253d6aeSmrg	  #
1182a253d6aeSmrg	  lastarg="$srcfile"
1183a253d6aeSmrg	  srcfile="$arg"
1184a253d6aeSmrg	  ;;
1185a253d6aeSmrg	esac  #  case $arg
1186a253d6aeSmrg	;;
1187a253d6aeSmrg      esac    #  case $arg_mode
1188a253d6aeSmrg
1189a253d6aeSmrg      # Aesthetically quote the previous argument.
1190ea133fd7Smrg      func_quote_for_eval "$lastarg"
1191ea133fd7Smrg      base_compile="$base_compile $func_quote_for_eval_result"
1192a253d6aeSmrg    done # for arg
1193a253d6aeSmrg
1194a253d6aeSmrg    case $arg_mode in
1195a253d6aeSmrg    arg)
1196ea133fd7Smrg      func_fatal_error "you must specify an argument for -Xcompile"
1197a253d6aeSmrg      ;;
1198a253d6aeSmrg    target)
1199ea133fd7Smrg      func_fatal_error "you must specify a target with \`-o'"
1200a253d6aeSmrg      ;;
1201a253d6aeSmrg    *)
1202a253d6aeSmrg      # Get the name of the library object.
1203ea133fd7Smrg      test -z "$libobj" && {
1204ea133fd7Smrg	func_basename "$srcfile"
1205ea133fd7Smrg	libobj="$func_basename_result"
1206ea133fd7Smrg      }
1207a253d6aeSmrg      ;;
1208a253d6aeSmrg    esac
1209a253d6aeSmrg
1210a253d6aeSmrg    # Recognize several different file suffixes.
1211a253d6aeSmrg    # If the user specifies -o file.o, it is replaced with file.lo
1212a253d6aeSmrg    case $libobj in
1213ea133fd7Smrg    *.[cCFSifmso] | \
1214ea133fd7Smrg    *.ada | *.adb | *.ads | *.asm | \
1215ea133fd7Smrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
1216ea133fd7Smrg    *.[fF][09]? | *.for | *.java | *.obj | *.sx)
1217ea133fd7Smrg      func_xform "$libobj"
1218ea133fd7Smrg      libobj=$func_xform_result
1219ea133fd7Smrg      ;;
1220a253d6aeSmrg    esac
1221a253d6aeSmrg
1222a253d6aeSmrg    case $libobj in
1223ea133fd7Smrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
1224a253d6aeSmrg    *)
1225ea133fd7Smrg      func_fatal_error "cannot determine name of library object from \`$libobj'"
1226a253d6aeSmrg      ;;
1227a253d6aeSmrg    esac
1228a253d6aeSmrg
1229a253d6aeSmrg    func_infer_tag $base_compile
1230a253d6aeSmrg
1231a253d6aeSmrg    for arg in $later; do
1232a253d6aeSmrg      case $arg in
1233ea133fd7Smrg      -shared)
1234ea133fd7Smrg	test "$build_libtool_libs" != yes && \
1235ea133fd7Smrg	  func_fatal_configuration "can not build a shared library"
1236ea133fd7Smrg	build_old_libs=no
1237ea133fd7Smrg	continue
1238ea133fd7Smrg	;;
1239ea133fd7Smrg
1240a253d6aeSmrg      -static)
1241ea133fd7Smrg	build_libtool_libs=no
1242a253d6aeSmrg	build_old_libs=yes
1243a253d6aeSmrg	continue
1244a253d6aeSmrg	;;
1245a253d6aeSmrg
1246a253d6aeSmrg      -prefer-pic)
1247a253d6aeSmrg	pic_mode=yes
1248a253d6aeSmrg	continue
1249a253d6aeSmrg	;;
1250a253d6aeSmrg
1251a253d6aeSmrg      -prefer-non-pic)
1252a253d6aeSmrg	pic_mode=no
1253a253d6aeSmrg	continue
1254a253d6aeSmrg	;;
1255a253d6aeSmrg      esac
1256a253d6aeSmrg    done
1257a253d6aeSmrg
1258ea133fd7Smrg    func_quote_for_eval "$libobj"
1259ea133fd7Smrg    test "X$libobj" != "X$func_quote_for_eval_result" \
1260ea133fd7Smrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
1261ea133fd7Smrg      && func_warning "libobj name \`$libobj' may not contain shell special characters."
1262ea133fd7Smrg    func_dirname_and_basename "$obj" "/" ""
1263ea133fd7Smrg    objname="$func_basename_result"
1264ea133fd7Smrg    xdir="$func_dirname_result"
1265a253d6aeSmrg    lobj=${xdir}$objdir/$objname
1266a253d6aeSmrg
1267ea133fd7Smrg    test -z "$base_compile" && \
1268ea133fd7Smrg      func_fatal_help "you must specify a compilation command"
1269a253d6aeSmrg
1270a253d6aeSmrg    # Delete any leftover library objects.
1271a253d6aeSmrg    if test "$build_old_libs" = yes; then
1272a253d6aeSmrg      removelist="$obj $lobj $libobj ${libobj}T"
1273a253d6aeSmrg    else
1274a253d6aeSmrg      removelist="$lobj $libobj ${libobj}T"
1275a253d6aeSmrg    fi
1276a253d6aeSmrg
1277a253d6aeSmrg    # On Cygwin there's no "real" PIC flag so we must build both object types
1278a253d6aeSmrg    case $host_os in
1279ea133fd7Smrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
1280a253d6aeSmrg      pic_mode=default
1281a253d6aeSmrg      ;;
1282a253d6aeSmrg    esac
1283a253d6aeSmrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
1284a253d6aeSmrg      # non-PIC code in shared libraries is not supported
1285a253d6aeSmrg      pic_mode=default
1286a253d6aeSmrg    fi
1287a253d6aeSmrg
1288a253d6aeSmrg    # Calculate the filename of the output object if compiler does
1289a253d6aeSmrg    # not support -o with -c
1290a253d6aeSmrg    if test "$compiler_c_o" = no; then
1291ea133fd7Smrg      output_obj=`$ECHO "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
1292a253d6aeSmrg      lockfile="$output_obj.lock"
1293a253d6aeSmrg    else
1294a253d6aeSmrg      output_obj=
1295a253d6aeSmrg      need_locks=no
1296a253d6aeSmrg      lockfile=
1297a253d6aeSmrg    fi
1298a253d6aeSmrg
1299a253d6aeSmrg    # Lock this critical section if it is needed
1300a253d6aeSmrg    # We use this script file to make the link, it avoids creating a new file
1301a253d6aeSmrg    if test "$need_locks" = yes; then
1302ea133fd7Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
1303ea133fd7Smrg	func_echo "Waiting for $lockfile to be removed"
1304a253d6aeSmrg	sleep 2
1305a253d6aeSmrg      done
1306a253d6aeSmrg    elif test "$need_locks" = warn; then
1307a253d6aeSmrg      if test -f "$lockfile"; then
1308ea133fd7Smrg	$ECHO "\
1309a253d6aeSmrg*** ERROR, $lockfile exists and contains:
1310a253d6aeSmrg`cat $lockfile 2>/dev/null`
1311a253d6aeSmrg
1312a253d6aeSmrgThis indicates that another process is trying to use the same
1313a253d6aeSmrgtemporary object file, and libtool could not work around it because
1314a253d6aeSmrgyour compiler does not support \`-c' and \`-o' together.  If you
1315a253d6aeSmrgrepeat this compilation, it may succeed, by chance, but you had better
1316a253d6aeSmrgavoid parallel builds (make -j) in this platform, or get a better
1317a253d6aeSmrgcompiler."
1318a253d6aeSmrg
1319ea133fd7Smrg	$opt_dry_run || $RM $removelist
1320a253d6aeSmrg	exit $EXIT_FAILURE
1321a253d6aeSmrg      fi
1322ea133fd7Smrg      removelist="$removelist $output_obj"
1323ea133fd7Smrg      $ECHO "$srcfile" > "$lockfile"
1324a253d6aeSmrg    fi
1325a253d6aeSmrg
1326ea133fd7Smrg    $opt_dry_run || $RM $removelist
1327ea133fd7Smrg    removelist="$removelist $lockfile"
1328ea133fd7Smrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
1329ea133fd7Smrg
1330a253d6aeSmrg    if test -n "$fix_srcfile_path"; then
1331a253d6aeSmrg      eval srcfile=\"$fix_srcfile_path\"
1332a253d6aeSmrg    fi
1333ea133fd7Smrg    func_quote_for_eval "$srcfile"
1334ea133fd7Smrg    qsrcfile=$func_quote_for_eval_result
1335a253d6aeSmrg
1336a253d6aeSmrg    # Only build a PIC object if we are building libtool libraries.
1337a253d6aeSmrg    if test "$build_libtool_libs" = yes; then
1338a253d6aeSmrg      # Without this assignment, base_compile gets emptied.
1339a253d6aeSmrg      fbsd_hideous_sh_bug=$base_compile
1340a253d6aeSmrg
1341a253d6aeSmrg      if test "$pic_mode" != no; then
1342a253d6aeSmrg	command="$base_compile $qsrcfile $pic_flag"
1343a253d6aeSmrg      else
1344a253d6aeSmrg	# Don't build PIC code
1345a253d6aeSmrg	command="$base_compile $qsrcfile"
1346a253d6aeSmrg      fi
1347a253d6aeSmrg
1348ea133fd7Smrg      func_mkdir_p "$xdir$objdir"
1349a253d6aeSmrg
1350a253d6aeSmrg      if test -z "$output_obj"; then
1351a253d6aeSmrg	# Place PIC objects in $objdir
1352a253d6aeSmrg	command="$command -o $lobj"
1353a253d6aeSmrg      fi
1354a253d6aeSmrg
1355ea133fd7Smrg      func_show_eval_locale "$command"	\
1356ea133fd7Smrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
1357a253d6aeSmrg
1358a253d6aeSmrg      if test "$need_locks" = warn &&
1359a253d6aeSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
1360ea133fd7Smrg	$ECHO "\
1361a253d6aeSmrg*** ERROR, $lockfile contains:
1362a253d6aeSmrg`cat $lockfile 2>/dev/null`
1363a253d6aeSmrg
1364a253d6aeSmrgbut it should contain:
1365a253d6aeSmrg$srcfile
1366a253d6aeSmrg
1367a253d6aeSmrgThis indicates that another process is trying to use the same
1368a253d6aeSmrgtemporary object file, and libtool could not work around it because
1369a253d6aeSmrgyour compiler does not support \`-c' and \`-o' together.  If you
1370a253d6aeSmrgrepeat this compilation, it may succeed, by chance, but you had better
1371a253d6aeSmrgavoid parallel builds (make -j) in this platform, or get a better
1372a253d6aeSmrgcompiler."
1373a253d6aeSmrg
1374ea133fd7Smrg	$opt_dry_run || $RM $removelist
1375a253d6aeSmrg	exit $EXIT_FAILURE
1376a253d6aeSmrg      fi
1377a253d6aeSmrg
1378a253d6aeSmrg      # Just move the object if needed, then go on to compile the next one
1379a253d6aeSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
1380ea133fd7Smrg	func_show_eval '$MV "$output_obj" "$lobj"' \
1381ea133fd7Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
1382a253d6aeSmrg      fi
1383a253d6aeSmrg
1384a253d6aeSmrg      # Allow error messages only from the first compilation.
1385a253d6aeSmrg      if test "$suppress_opt" = yes; then
1386ea133fd7Smrg	suppress_output=' >/dev/null 2>&1'
1387a253d6aeSmrg      fi
1388a253d6aeSmrg    fi
1389a253d6aeSmrg
1390a253d6aeSmrg    # Only build a position-dependent object if we build old libraries.
1391a253d6aeSmrg    if test "$build_old_libs" = yes; then
1392a253d6aeSmrg      if test "$pic_mode" != yes; then
1393a253d6aeSmrg	# Don't build PIC code
1394ea133fd7Smrg	command="$base_compile $qsrcfile$pie_flag"
1395a253d6aeSmrg      else
1396a253d6aeSmrg	command="$base_compile $qsrcfile $pic_flag"
1397a253d6aeSmrg      fi
1398a253d6aeSmrg      if test "$compiler_c_o" = yes; then
1399a253d6aeSmrg	command="$command -o $obj"
1400a253d6aeSmrg      fi
1401a253d6aeSmrg
1402a253d6aeSmrg      # Suppress compiler output if we already did a PIC compilation.
1403a253d6aeSmrg      command="$command$suppress_output"
1404ea133fd7Smrg      func_show_eval_locale "$command" \
1405ea133fd7Smrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
1406a253d6aeSmrg
1407a253d6aeSmrg      if test "$need_locks" = warn &&
1408a253d6aeSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
1409ea133fd7Smrg	$ECHO "\
1410a253d6aeSmrg*** ERROR, $lockfile contains:
1411a253d6aeSmrg`cat $lockfile 2>/dev/null`
1412a253d6aeSmrg
1413a253d6aeSmrgbut it should contain:
1414a253d6aeSmrg$srcfile
1415a253d6aeSmrg
1416a253d6aeSmrgThis indicates that another process is trying to use the same
1417a253d6aeSmrgtemporary object file, and libtool could not work around it because
1418a253d6aeSmrgyour compiler does not support \`-c' and \`-o' together.  If you
1419a253d6aeSmrgrepeat this compilation, it may succeed, by chance, but you had better
1420a253d6aeSmrgavoid parallel builds (make -j) in this platform, or get a better
1421a253d6aeSmrgcompiler."
1422a253d6aeSmrg
1423ea133fd7Smrg	$opt_dry_run || $RM $removelist
1424a253d6aeSmrg	exit $EXIT_FAILURE
1425a253d6aeSmrg      fi
1426a253d6aeSmrg
1427a253d6aeSmrg      # Just move the object if needed
1428a253d6aeSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
1429ea133fd7Smrg	func_show_eval '$MV "$output_obj" "$obj"' \
1430ea133fd7Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
1431a253d6aeSmrg      fi
1432a253d6aeSmrg    fi
1433a253d6aeSmrg
1434ea133fd7Smrg    $opt_dry_run || {
1435ea133fd7Smrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
1436a253d6aeSmrg
1437ea133fd7Smrg      # Unlock the critical section if it was locked
1438ea133fd7Smrg      if test "$need_locks" != no; then
1439ea133fd7Smrg	removelist=$lockfile
1440ea133fd7Smrg        $RM "$lockfile"
1441ea133fd7Smrg      fi
1442ea133fd7Smrg    }
1443a253d6aeSmrg
1444a253d6aeSmrg    exit $EXIT_SUCCESS
1445ea133fd7Smrg}
1446a253d6aeSmrg
1447ea133fd7Smrg$opt_help || {
1448ea133fd7Smrgtest "$mode" = compile && func_mode_compile ${1+"$@"}
1449ea133fd7Smrg}
1450a253d6aeSmrg
1451ea133fd7Smrgfunc_mode_help ()
1452ea133fd7Smrg{
1453ea133fd7Smrg    # We need to display help for each of the modes.
1454ea133fd7Smrg    case $mode in
1455ea133fd7Smrg      "")
1456ea133fd7Smrg        # Generic help is extracted from the usage comments
1457ea133fd7Smrg        # at the start of this file.
1458ea133fd7Smrg        func_help
1459ea133fd7Smrg        ;;
1460a253d6aeSmrg
1461ea133fd7Smrg      clean)
1462ea133fd7Smrg        $ECHO \
1463ea133fd7Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
1464a253d6aeSmrg
1465ea133fd7SmrgRemove files from the build directory.
1466a253d6aeSmrg
1467ea133fd7SmrgRM is the name of the program to use to delete files associated with each FILE
1468ea133fd7Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
1469ea133fd7Smrgto RM.
1470a253d6aeSmrg
1471ea133fd7SmrgIf FILE is a libtool library, object or program, all the files associated
1472ea133fd7Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
1473ea133fd7Smrg        ;;
1474a253d6aeSmrg
1475ea133fd7Smrg      compile)
1476ea133fd7Smrg      $ECHO \
1477ea133fd7Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
1478a253d6aeSmrg
1479ea133fd7SmrgCompile a source file into a libtool library object.
1480a253d6aeSmrg
1481ea133fd7SmrgThis mode accepts the following additional options:
1482a253d6aeSmrg
1483ea133fd7Smrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
1484ea133fd7Smrg  -no-suppress      do not suppress compiler output for multiple passes
1485ea133fd7Smrg  -prefer-pic       try to building PIC objects only
1486ea133fd7Smrg  -prefer-non-pic   try to building non-PIC objects only
1487ea133fd7Smrg  -shared           do not build a \`.o' file suitable for static linking
1488ea133fd7Smrg  -static           only build a \`.o' file suitable for static linking
1489a253d6aeSmrg
1490ea133fd7SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
1491ea133fd7Smrgfrom the given SOURCEFILE.
1492a253d6aeSmrg
1493ea133fd7SmrgThe output file name is determined by removing the directory component from
1494ea133fd7SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
1495ea133fd7Smrglibrary object suffix, \`.lo'."
1496ea133fd7Smrg        ;;
1497a253d6aeSmrg
1498ea133fd7Smrg      execute)
1499ea133fd7Smrg        $ECHO \
1500ea133fd7Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
1501a253d6aeSmrg
1502ea133fd7SmrgAutomatically set library path, then run a program.
1503a253d6aeSmrg
1504ea133fd7SmrgThis mode accepts the following additional options:
1505a253d6aeSmrg
1506ea133fd7Smrg  -dlopen FILE      add the directory containing FILE to the library path
1507a253d6aeSmrg
1508ea133fd7SmrgThis mode sets the library path environment variable according to \`-dlopen'
1509ea133fd7Smrgflags.
1510a253d6aeSmrg
1511ea133fd7SmrgIf any of the ARGS are libtool executable wrappers, then they are translated
1512ea133fd7Smrginto their corresponding uninstalled binary, and any of their required library
1513ea133fd7Smrgdirectories are added to the library path.
1514a253d6aeSmrg
1515ea133fd7SmrgThen, COMMAND is executed, with ARGS as arguments."
1516ea133fd7Smrg        ;;
1517a253d6aeSmrg
1518ea133fd7Smrg      finish)
1519ea133fd7Smrg        $ECHO \
1520ea133fd7Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
1521a253d6aeSmrg
1522ea133fd7SmrgComplete the installation of libtool libraries.
1523a253d6aeSmrg
1524ea133fd7SmrgEach LIBDIR is a directory that contains libtool libraries.
1525a253d6aeSmrg
1526ea133fd7SmrgThe commands that this mode executes may require superuser privileges.  Use
1527ea133fd7Smrgthe \`--dry-run' option if you just want to see what would be executed."
1528ea133fd7Smrg        ;;
1529a253d6aeSmrg
1530ea133fd7Smrg      install)
1531ea133fd7Smrg        $ECHO \
1532ea133fd7Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
1533a253d6aeSmrg
1534ea133fd7SmrgInstall executables or libraries.
1535a253d6aeSmrg
1536ea133fd7SmrgINSTALL-COMMAND is the installation command.  The first component should be
1537ea133fd7Smrgeither the \`install' or \`cp' program.
1538a253d6aeSmrg
1539ea133fd7SmrgThe following components of INSTALL-COMMAND are treated specially:
1540a253d6aeSmrg
1541ea133fd7Smrg  -inst-prefix PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
1542a253d6aeSmrg
1543ea133fd7SmrgThe rest of the components are interpreted as arguments to that command (only
1544ea133fd7SmrgBSD-compatible install options are recognized)."
1545ea133fd7Smrg        ;;
1546a253d6aeSmrg
1547ea133fd7Smrg      link)
1548ea133fd7Smrg        $ECHO \
1549ea133fd7Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
1550a253d6aeSmrg
1551ea133fd7SmrgLink object files or libraries together to form another library, or to
1552ea133fd7Smrgcreate an executable program.
1553a253d6aeSmrg
1554ea133fd7SmrgLINK-COMMAND is a command using the C compiler that you would use to create
1555ea133fd7Smrga program from several object files.
1556a253d6aeSmrg
1557ea133fd7SmrgThe following components of LINK-COMMAND are treated specially:
1558a253d6aeSmrg
1559ea133fd7Smrg  -all-static       do not do any dynamic linking at all
1560ea133fd7Smrg  -avoid-version    do not add a version suffix if possible
1561ea133fd7Smrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
1562ea133fd7Smrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
1563ea133fd7Smrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
1564ea133fd7Smrg  -export-symbols SYMFILE
1565ea133fd7Smrg                    try to export only the symbols listed in SYMFILE
1566ea133fd7Smrg  -export-symbols-regex REGEX
1567ea133fd7Smrg                    try to export only the symbols matching REGEX
1568ea133fd7Smrg  -LLIBDIR          search LIBDIR for required installed libraries
1569ea133fd7Smrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
1570ea133fd7Smrg  -module           build a library that can dlopened
1571ea133fd7Smrg  -no-fast-install  disable the fast-install mode
1572ea133fd7Smrg  -no-install       link a not-installable executable
1573ea133fd7Smrg  -no-undefined     declare that a library does not refer to external symbols
1574ea133fd7Smrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
1575ea133fd7Smrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
1576ea133fd7Smrg  -precious-files-regex REGEX
1577ea133fd7Smrg                    don't remove output files matching REGEX
1578ea133fd7Smrg  -release RELEASE  specify package release information
1579ea133fd7Smrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
1580ea133fd7Smrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
1581ea133fd7Smrg  -shared           only do dynamic linking of libtool libraries
1582ea133fd7Smrg  -shrext SUFFIX    override the standard shared library file extension
1583ea133fd7Smrg  -static           do not do any dynamic linking of uninstalled libtool libraries
1584ea133fd7Smrg  -static-libtool-libs
1585ea133fd7Smrg                    do not do any dynamic linking of libtool libraries
1586ea133fd7Smrg  -version-info CURRENT[:REVISION[:AGE]]
1587ea133fd7Smrg                    specify library version info [each variable defaults to 0]
1588ea133fd7Smrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
1589a253d6aeSmrg
1590ea133fd7SmrgAll other options (arguments beginning with \`-') are ignored.
1591a253d6aeSmrg
1592ea133fd7SmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
1593ea133fd7Smrgtreated as uninstalled libtool libraries, other files are standard or library
1594ea133fd7Smrgobject files.
1595a253d6aeSmrg
1596ea133fd7SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
1597ea133fd7Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
1598ea133fd7Smrgrequired, except when creating a convenience library.
1599a253d6aeSmrg
1600ea133fd7SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
1601ea133fd7Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
1602a253d6aeSmrg
1603ea133fd7SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
1604ea133fd7Smrgis created, otherwise an executable program is created."
1605a253d6aeSmrg        ;;
1606a253d6aeSmrg
1607ea133fd7Smrg      uninstall)
1608ea133fd7Smrg        $ECHO \
1609ea133fd7Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
1610a253d6aeSmrg
1611ea133fd7SmrgRemove libraries from an installation directory.
1612a253d6aeSmrg
1613ea133fd7SmrgRM is the name of the program to use to delete files associated with each FILE
1614ea133fd7Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
1615ea133fd7Smrgto RM.
1616a253d6aeSmrg
1617ea133fd7SmrgIf FILE is a libtool library, all the files associated with it are deleted.
1618ea133fd7SmrgOtherwise, only FILE itself is deleted using RM."
1619ea133fd7Smrg        ;;
1620a253d6aeSmrg
1621ea133fd7Smrg      *)
1622ea133fd7Smrg        func_fatal_help "invalid operation mode \`$mode'"
1623ea133fd7Smrg        ;;
1624ea133fd7Smrg    esac
1625a253d6aeSmrg
1626ea133fd7Smrg    $ECHO
1627ea133fd7Smrg    $ECHO "Try \`$progname --help' for more information about other modes."
1628a253d6aeSmrg
1629ea133fd7Smrg    exit $?
1630ea133fd7Smrg}
1631a253d6aeSmrg
1632ea133fd7Smrg  # Now that we've collected a possible --mode arg, show help if necessary
1633ea133fd7Smrg  $opt_help && func_mode_help
1634a253d6aeSmrg
1635a253d6aeSmrg
1636ea133fd7Smrg# func_mode_execute arg...
1637ea133fd7Smrgfunc_mode_execute ()
1638ea133fd7Smrg{
1639ea133fd7Smrg    $opt_debug
1640ea133fd7Smrg    # The first argument is the command name.
1641ea133fd7Smrg    cmd="$nonopt"
1642ea133fd7Smrg    test -z "$cmd" && \
1643ea133fd7Smrg      func_fatal_help "you must specify a COMMAND"
1644a253d6aeSmrg
1645ea133fd7Smrg    # Handle -dlopen flags immediately.
1646ea133fd7Smrg    for file in $execute_dlfiles; do
1647ea133fd7Smrg      test -f "$file" \
1648ea133fd7Smrg	|| func_fatal_help "\`$file' is not a file"
1649a253d6aeSmrg
1650ea133fd7Smrg      dir=
1651ea133fd7Smrg      case $file in
1652ea133fd7Smrg      *.la)
1653ea133fd7Smrg	# Check to see that this really is a libtool archive.
1654ea133fd7Smrg	func_lalib_unsafe_p "$file" \
1655ea133fd7Smrg	  || func_fatal_help "\`$lib' is not a valid libtool archive"
1656a253d6aeSmrg
1657ea133fd7Smrg	# Read the libtool library.
1658ea133fd7Smrg	dlname=
1659ea133fd7Smrg	library_names=
1660ea133fd7Smrg	func_source "$file"
1661a253d6aeSmrg
1662ea133fd7Smrg	# Skip this library if it cannot be dlopened.
1663ea133fd7Smrg	if test -z "$dlname"; then
1664ea133fd7Smrg	  # Warn if it was a shared library.
1665ea133fd7Smrg	  test -n "$library_names" && \
1666ea133fd7Smrg	    func_warning "\`$file' was not linked with \`-export-dynamic'"
1667ea133fd7Smrg	  continue
1668ea133fd7Smrg	fi
1669a253d6aeSmrg
1670ea133fd7Smrg	func_dirname "$file" "" "."
1671ea133fd7Smrg	dir="$func_dirname_result"
1672a253d6aeSmrg
1673ea133fd7Smrg	if test -f "$dir/$objdir/$dlname"; then
1674ea133fd7Smrg	  dir="$dir/$objdir"
1675ea133fd7Smrg	else
1676ea133fd7Smrg	  if test ! -f "$dir/$dlname"; then
1677ea133fd7Smrg	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
1678ea133fd7Smrg	  fi
1679ea133fd7Smrg	fi
1680a253d6aeSmrg	;;
1681a253d6aeSmrg
1682ea133fd7Smrg      *.lo)
1683ea133fd7Smrg	# Just add the directory containing the .lo file.
1684ea133fd7Smrg	func_dirname "$file" "" "."
1685ea133fd7Smrg	dir="$func_dirname_result"
1686a253d6aeSmrg	;;
1687a253d6aeSmrg
1688ea133fd7Smrg      *)
1689ea133fd7Smrg	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
1690a253d6aeSmrg	continue
1691a253d6aeSmrg	;;
1692ea133fd7Smrg      esac
1693a253d6aeSmrg
1694ea133fd7Smrg      # Get the absolute pathname.
1695ea133fd7Smrg      absdir=`cd "$dir" && pwd`
1696ea133fd7Smrg      test -n "$absdir" && dir="$absdir"
1697a253d6aeSmrg
1698ea133fd7Smrg      # Now add the directory to shlibpath_var.
1699ea133fd7Smrg      if eval "test -z \"\$$shlibpath_var\""; then
1700ea133fd7Smrg	eval "$shlibpath_var=\"\$dir\""
1701ea133fd7Smrg      else
1702ea133fd7Smrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
1703ea133fd7Smrg      fi
1704ea133fd7Smrg    done
1705a253d6aeSmrg
1706ea133fd7Smrg    # This variable tells wrapper scripts just to set shlibpath_var
1707ea133fd7Smrg    # rather than running their programs.
1708ea133fd7Smrg    libtool_execute_magic="$magic"
1709a253d6aeSmrg
1710ea133fd7Smrg    # Check if any of the arguments is a wrapper script.
1711ea133fd7Smrg    args=
1712ea133fd7Smrg    for file
1713ea133fd7Smrg    do
1714ea133fd7Smrg      case $file in
1715ea133fd7Smrg      -*) ;;
1716ea133fd7Smrg      *)
1717ea133fd7Smrg	# Do a test to see if this is really a libtool program.
1718ea133fd7Smrg	if func_ltwrapper_script_p "$file"; then
1719ea133fd7Smrg	  func_source "$file"
1720ea133fd7Smrg	  # Transform arg to wrapped name.
1721ea133fd7Smrg	  file="$progdir/$program"
1722ea133fd7Smrg	elif func_ltwrapper_executable_p "$file"; then
1723ea133fd7Smrg	  func_ltwrapper_scriptname "$file"
1724ea133fd7Smrg	  func_source "$func_ltwrapper_scriptname_result"
1725ea133fd7Smrg	  # Transform arg to wrapped name.
1726ea133fd7Smrg	  file="$progdir/$program"
1727ea133fd7Smrg	fi
1728ea133fd7Smrg	;;
1729ea133fd7Smrg      esac
1730ea133fd7Smrg      # Quote arguments (to preserve shell metacharacters).
1731ea133fd7Smrg      func_quote_for_eval "$file"
1732ea133fd7Smrg      args="$args $func_quote_for_eval_result"
1733ea133fd7Smrg    done
1734a253d6aeSmrg
1735ea133fd7Smrg    if test "X$opt_dry_run" = Xfalse; then
1736ea133fd7Smrg      if test -n "$shlibpath_var"; then
1737ea133fd7Smrg	# Export the shlibpath_var.
1738ea133fd7Smrg	eval "export $shlibpath_var"
1739ea133fd7Smrg      fi
1740a253d6aeSmrg
1741ea133fd7Smrg      # Restore saved environment variables
1742ea133fd7Smrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
1743ea133fd7Smrg      do
1744ea133fd7Smrg	eval "if test \"\${save_$lt_var+set}\" = set; then
1745ea133fd7Smrg                $lt_var=\$save_$lt_var; export $lt_var
1746ea133fd7Smrg	      else
1747ea133fd7Smrg		$lt_unset $lt_var
1748ea133fd7Smrg	      fi"
1749ea133fd7Smrg      done
1750a253d6aeSmrg
1751ea133fd7Smrg      # Now prepare to actually exec the command.
1752ea133fd7Smrg      exec_cmd="\$cmd$args"
1753ea133fd7Smrg    else
1754ea133fd7Smrg      # Display what would be done.
1755ea133fd7Smrg      if test -n "$shlibpath_var"; then
1756ea133fd7Smrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
1757ea133fd7Smrg	$ECHO "export $shlibpath_var"
1758ea133fd7Smrg      fi
1759ea133fd7Smrg      $ECHO "$cmd$args"
1760ea133fd7Smrg      exit $EXIT_SUCCESS
1761ea133fd7Smrg    fi
1762ea133fd7Smrg}
1763a253d6aeSmrg
1764ea133fd7Smrgtest "$mode" = execute && func_mode_execute ${1+"$@"}
1765a253d6aeSmrg
1766a253d6aeSmrg
1767ea133fd7Smrg# func_mode_finish arg...
1768ea133fd7Smrgfunc_mode_finish ()
1769ea133fd7Smrg{
1770ea133fd7Smrg    $opt_debug
1771ea133fd7Smrg    libdirs="$nonopt"
1772ea133fd7Smrg    admincmds=
1773a253d6aeSmrg
1774ea133fd7Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
1775ea133fd7Smrg      for dir
1776ea133fd7Smrg      do
1777ea133fd7Smrg	libdirs="$libdirs $dir"
1778ea133fd7Smrg      done
1779a253d6aeSmrg
1780ea133fd7Smrg      for libdir in $libdirs; do
1781ea133fd7Smrg	if test -n "$finish_cmds"; then
1782ea133fd7Smrg	  # Do each command in the finish commands.
1783ea133fd7Smrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
1784ea133fd7Smrg'"$cmd"'"'
1785ea133fd7Smrg	fi
1786ea133fd7Smrg	if test -n "$finish_eval"; then
1787ea133fd7Smrg	  # Do the single finish_eval.
1788ea133fd7Smrg	  eval cmds=\"$finish_eval\"
1789ea133fd7Smrg	  $opt_dry_run || eval "$cmds" || admincmds="$admincmds
1790ea133fd7Smrg       $cmds"
1791ea133fd7Smrg	fi
1792ea133fd7Smrg      done
1793ea133fd7Smrg    fi
1794a253d6aeSmrg
1795ea133fd7Smrg    # Exit here if they wanted silent mode.
1796ea133fd7Smrg    $opt_silent && exit $EXIT_SUCCESS
1797a253d6aeSmrg
1798ea133fd7Smrg    $ECHO "X----------------------------------------------------------------------" | $Xsed
1799ea133fd7Smrg    $ECHO "Libraries have been installed in:"
1800ea133fd7Smrg    for libdir in $libdirs; do
1801ea133fd7Smrg      $ECHO "   $libdir"
1802ea133fd7Smrg    done
1803ea133fd7Smrg    $ECHO
1804ea133fd7Smrg    $ECHO "If you ever happen to want to link against installed libraries"
1805ea133fd7Smrg    $ECHO "in a given directory, LIBDIR, you must either use libtool, and"
1806ea133fd7Smrg    $ECHO "specify the full pathname of the library, or use the \`-LLIBDIR'"
1807ea133fd7Smrg    $ECHO "flag during linking and do at least one of the following:"
1808ea133fd7Smrg    if test -n "$shlibpath_var"; then
1809ea133fd7Smrg      $ECHO "   - add LIBDIR to the \`$shlibpath_var' environment variable"
1810ea133fd7Smrg      $ECHO "     during execution"
1811ea133fd7Smrg    fi
1812ea133fd7Smrg    if test -n "$runpath_var"; then
1813ea133fd7Smrg      $ECHO "   - add LIBDIR to the \`$runpath_var' environment variable"
1814ea133fd7Smrg      $ECHO "     during linking"
1815ea133fd7Smrg    fi
1816ea133fd7Smrg    if test -n "$hardcode_libdir_flag_spec"; then
1817ea133fd7Smrg      libdir=LIBDIR
1818ea133fd7Smrg      eval flag=\"$hardcode_libdir_flag_spec\"
1819a253d6aeSmrg
1820ea133fd7Smrg      $ECHO "   - use the \`$flag' linker flag"
1821ea133fd7Smrg    fi
1822ea133fd7Smrg    if test -n "$admincmds"; then
1823ea133fd7Smrg      $ECHO "   - have your system administrator run these commands:$admincmds"
1824ea133fd7Smrg    fi
1825ea133fd7Smrg    if test -f /etc/ld.so.conf; then
1826ea133fd7Smrg      $ECHO "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
1827ea133fd7Smrg    fi
1828ea133fd7Smrg    $ECHO
1829a253d6aeSmrg
1830ea133fd7Smrg    $ECHO "See any operating system documentation about shared libraries for"
1831ea133fd7Smrg    case $host in
1832ea133fd7Smrg      solaris2.[6789]|solaris2.1[0-9])
1833ea133fd7Smrg        $ECHO "more information, such as the ld(1), crle(1) and ld.so(8) manual"
1834ea133fd7Smrg	$ECHO "pages."
1835a253d6aeSmrg	;;
1836ea133fd7Smrg      *)
1837ea133fd7Smrg        $ECHO "more information, such as the ld(1) and ld.so(8) manual pages."
1838ea133fd7Smrg        ;;
1839ea133fd7Smrg    esac
1840ea133fd7Smrg    $ECHO "X----------------------------------------------------------------------" | $Xsed
1841ea133fd7Smrg    exit $EXIT_SUCCESS
1842ea133fd7Smrg}
1843a253d6aeSmrg
1844ea133fd7Smrgtest "$mode" = finish && func_mode_finish ${1+"$@"}
1845a253d6aeSmrg
1846a253d6aeSmrg
1847ea133fd7Smrg# func_mode_install arg...
1848ea133fd7Smrgfunc_mode_install ()
1849ea133fd7Smrg{
1850ea133fd7Smrg    $opt_debug
1851ea133fd7Smrg    # There may be an optional sh(1) argument at the beginning of
1852ea133fd7Smrg    # install_prog (especially on Windows NT).
1853ea133fd7Smrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
1854ea133fd7Smrg       # Allow the use of GNU shtool's install command.
1855ea133fd7Smrg       $ECHO "X$nonopt" | $GREP shtool >/dev/null; then
1856ea133fd7Smrg      # Aesthetically quote it.
1857ea133fd7Smrg      func_quote_for_eval "$nonopt"
1858ea133fd7Smrg      install_prog="$func_quote_for_eval_result "
1859ea133fd7Smrg      arg=$1
1860ea133fd7Smrg      shift
1861ea133fd7Smrg    else
1862ea133fd7Smrg      install_prog=
1863ea133fd7Smrg      arg=$nonopt
1864ea133fd7Smrg    fi
1865a253d6aeSmrg
1866ea133fd7Smrg    # The real first argument should be the name of the installation program.
1867ea133fd7Smrg    # Aesthetically quote it.
1868ea133fd7Smrg    func_quote_for_eval "$arg"
1869ea133fd7Smrg    install_prog="$install_prog$func_quote_for_eval_result"
1870ea133fd7Smrg
1871ea133fd7Smrg    # We need to accept at least all the BSD install flags.
1872ea133fd7Smrg    dest=
1873ea133fd7Smrg    files=
1874ea133fd7Smrg    opts=
1875ea133fd7Smrg    prev=
1876ea133fd7Smrg    install_type=
1877ea133fd7Smrg    isdir=no
1878ea133fd7Smrg    stripme=
1879ea133fd7Smrg    for arg
1880ea133fd7Smrg    do
1881ea133fd7Smrg      if test -n "$dest"; then
1882ea133fd7Smrg	files="$files $dest"
1883ea133fd7Smrg	dest=$arg
1884ea133fd7Smrg	continue
1885a253d6aeSmrg      fi
1886a253d6aeSmrg
1887ea133fd7Smrg      case $arg in
1888ea133fd7Smrg      -d) isdir=yes ;;
1889ea133fd7Smrg      -f)
1890ea133fd7Smrg	case " $install_prog " in
1891ea133fd7Smrg	*[\\\ /]cp\ *) ;;
1892ea133fd7Smrg	*) prev=$arg ;;
1893ea133fd7Smrg	esac
1894ea133fd7Smrg	;;
1895ea133fd7Smrg      -g | -m | -o)
1896ea133fd7Smrg	prev=$arg
1897ea133fd7Smrg	;;
1898ea133fd7Smrg      -s)
1899ea133fd7Smrg	stripme=" -s"
1900ea133fd7Smrg	continue
1901ea133fd7Smrg	;;
1902ea133fd7Smrg      -*)
1903ea133fd7Smrg	;;
1904ea133fd7Smrg      *)
1905ea133fd7Smrg	# If the previous option needed an argument, then skip it.
1906ea133fd7Smrg	if test -n "$prev"; then
1907ea133fd7Smrg	  prev=
1908ea133fd7Smrg	else
1909ea133fd7Smrg	  dest=$arg
1910ea133fd7Smrg	  continue
1911ea133fd7Smrg	fi
1912ea133fd7Smrg	;;
1913ea133fd7Smrg      esac
1914a253d6aeSmrg
1915ea133fd7Smrg      # Aesthetically quote the argument.
1916ea133fd7Smrg      func_quote_for_eval "$arg"
1917ea133fd7Smrg      install_prog="$install_prog $func_quote_for_eval_result"
1918ea133fd7Smrg    done
1919a253d6aeSmrg
1920ea133fd7Smrg    test -z "$install_prog" && \
1921ea133fd7Smrg      func_fatal_help "you must specify an install program"
1922a253d6aeSmrg
1923ea133fd7Smrg    test -n "$prev" && \
1924ea133fd7Smrg      func_fatal_help "the \`$prev' option requires an argument"
1925a253d6aeSmrg
1926ea133fd7Smrg    if test -z "$files"; then
1927ea133fd7Smrg      if test -z "$dest"; then
1928ea133fd7Smrg	func_fatal_help "no file or destination specified"
1929ea133fd7Smrg      else
1930ea133fd7Smrg	func_fatal_help "you must specify a destination"
1931a253d6aeSmrg      fi
1932a253d6aeSmrg    fi
1933a253d6aeSmrg
1934ea133fd7Smrg    # Strip any trailing slash from the destination.
1935ea133fd7Smrg    func_stripname '' '/' "$dest"
1936ea133fd7Smrg    dest=$func_stripname_result
1937a253d6aeSmrg
1938ea133fd7Smrg    # Check to see that the destination is a directory.
1939ea133fd7Smrg    test -d "$dest" && isdir=yes
1940ea133fd7Smrg    if test "$isdir" = yes; then
1941ea133fd7Smrg      destdir="$dest"
1942ea133fd7Smrg      destname=
1943ea133fd7Smrg    else
1944ea133fd7Smrg      func_dirname_and_basename "$dest" "" "."
1945ea133fd7Smrg      destdir="$func_dirname_result"
1946ea133fd7Smrg      destname="$func_basename_result"
1947ea133fd7Smrg
1948ea133fd7Smrg      # Not a directory, so check to see that there is only one file specified.
1949ea133fd7Smrg      set dummy $files; shift
1950ea133fd7Smrg      test "$#" -gt 1 && \
1951ea133fd7Smrg	func_fatal_help "\`$dest' is not a directory"
1952ea133fd7Smrg    fi
1953ea133fd7Smrg    case $destdir in
1954ea133fd7Smrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
1955a253d6aeSmrg    *)
1956ea133fd7Smrg      for file in $files; do
1957ea133fd7Smrg	case $file in
1958ea133fd7Smrg	*.lo) ;;
1959ea133fd7Smrg	*)
1960ea133fd7Smrg	  func_fatal_help "\`$destdir' must be an absolute directory name"
1961ea133fd7Smrg	  ;;
1962ea133fd7Smrg	esac
1963ea133fd7Smrg      done
1964a253d6aeSmrg      ;;
1965a253d6aeSmrg    esac
1966a253d6aeSmrg
1967ea133fd7Smrg    # This variable tells wrapper scripts just to set variables rather
1968ea133fd7Smrg    # than running their programs.
1969ea133fd7Smrg    libtool_install_magic="$magic"
1970a253d6aeSmrg
1971ea133fd7Smrg    staticlibs=
1972ea133fd7Smrg    future_libdirs=
1973ea133fd7Smrg    current_libdirs=
1974ea133fd7Smrg    for file in $files; do
1975a253d6aeSmrg
1976ea133fd7Smrg      # Do each installation.
1977ea133fd7Smrg      case $file in
1978ea133fd7Smrg      *.$libext)
1979ea133fd7Smrg	# Do the static libraries later.
1980ea133fd7Smrg	staticlibs="$staticlibs $file"
1981ea133fd7Smrg	;;
1982ea133fd7Smrg
1983ea133fd7Smrg      *.la)
1984ea133fd7Smrg	# Check to see that this really is a libtool archive.
1985ea133fd7Smrg	func_lalib_unsafe_p "$file" \
1986ea133fd7Smrg	  || func_fatal_help "\`$file' is not a valid libtool archive"
1987ea133fd7Smrg
1988ea133fd7Smrg	library_names=
1989ea133fd7Smrg	old_library=
1990ea133fd7Smrg	relink_command=
1991ea133fd7Smrg	func_source "$file"
1992ea133fd7Smrg
1993ea133fd7Smrg	# Add the libdir to current_libdirs if it is the destination.
1994ea133fd7Smrg	if test "X$destdir" = "X$libdir"; then
1995ea133fd7Smrg	  case "$current_libdirs " in
1996ea133fd7Smrg	  *" $libdir "*) ;;
1997ea133fd7Smrg	  *) current_libdirs="$current_libdirs $libdir" ;;
1998a253d6aeSmrg	  esac
1999ea133fd7Smrg	else
2000ea133fd7Smrg	  # Note the libdir as a future libdir.
2001ea133fd7Smrg	  case "$future_libdirs " in
2002ea133fd7Smrg	  *" $libdir "*) ;;
2003ea133fd7Smrg	  *) future_libdirs="$future_libdirs $libdir" ;;
2004ea133fd7Smrg	  esac
2005ea133fd7Smrg	fi
2006a253d6aeSmrg
2007ea133fd7Smrg	func_dirname "$file" "/" ""
2008ea133fd7Smrg	dir="$func_dirname_result"
2009ea133fd7Smrg	dir="$dir$objdir"
2010ea133fd7Smrg
2011ea133fd7Smrg	if test -n "$relink_command"; then
2012ea133fd7Smrg	  # Determine the prefix the user has applied to our future dir.
2013ea133fd7Smrg	  inst_prefix_dir=`$ECHO "X$destdir" | $Xsed -e "s%$libdir\$%%"`
2014ea133fd7Smrg
2015ea133fd7Smrg	  # Don't allow the user to place us outside of our expected
2016ea133fd7Smrg	  # location b/c this prevents finding dependent libraries that
2017ea133fd7Smrg	  # are installed to the same prefix.
2018ea133fd7Smrg	  # At present, this check doesn't affect windows .dll's that
2019ea133fd7Smrg	  # are installed into $libdir/../bin (currently, that works fine)
2020ea133fd7Smrg	  # but it's something to keep an eye on.
2021ea133fd7Smrg	  test "$inst_prefix_dir" = "$destdir" && \
2022ea133fd7Smrg	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
2023ea133fd7Smrg
2024ea133fd7Smrg	  if test -n "$inst_prefix_dir"; then
2025ea133fd7Smrg	    # Stick the inst_prefix_dir data into the link command.
2026ea133fd7Smrg	    relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
2027ea133fd7Smrg	  else
2028ea133fd7Smrg	    relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%%"`
2029ea133fd7Smrg	  fi
2030ea133fd7Smrg
2031ea133fd7Smrg	  func_warning "relinking \`$file'"
2032ea133fd7Smrg	  func_show_eval "$relink_command" \
2033ea133fd7Smrg	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
2034ea133fd7Smrg	fi
2035ea133fd7Smrg
2036ea133fd7Smrg	# See the names of the shared library.
2037ea133fd7Smrg	set dummy $library_names; shift
2038ea133fd7Smrg	if test -n "$1"; then
2039ea133fd7Smrg	  realname="$1"
2040ea133fd7Smrg	  shift
2041ea133fd7Smrg
2042ea133fd7Smrg	  srcname="$realname"
2043ea133fd7Smrg	  test -n "$relink_command" && srcname="$realname"T
2044ea133fd7Smrg
2045ea133fd7Smrg	  # Install the shared library and build the symlinks.
2046ea133fd7Smrg	  func_show_eval "$install_prog $dir/$srcname $destdir/$realname" \
2047ea133fd7Smrg	      'exit $?'
2048ea133fd7Smrg	  tstripme="$stripme"
2049ea133fd7Smrg	  case $host_os in
2050ea133fd7Smrg	  cygwin* | mingw* | pw32* | cegcc*)
2051ea133fd7Smrg	    case $realname in
2052ea133fd7Smrg	    *.dll.a)
2053ea133fd7Smrg	      tstripme=""
2054ea133fd7Smrg	      ;;
2055ea133fd7Smrg	    esac
2056a253d6aeSmrg	    ;;
2057a253d6aeSmrg	  esac
2058ea133fd7Smrg	  if test -n "$tstripme" && test -n "$striplib"; then
2059ea133fd7Smrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
2060a253d6aeSmrg	  fi
2061ea133fd7Smrg
2062ea133fd7Smrg	  if test "$#" -gt 0; then
2063ea133fd7Smrg	    # Delete the old symlinks, and create new ones.
2064ea133fd7Smrg	    # Try `ln -sf' first, because the `ln' binary might depend on
2065ea133fd7Smrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
2066ea133fd7Smrg	    # so we also need to try rm && ln -s.
2067ea133fd7Smrg	    for linkname
2068ea133fd7Smrg	    do
2069ea133fd7Smrg	      test "$linkname" != "$realname" \
2070ea133fd7Smrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
2071a253d6aeSmrg	    done
2072a253d6aeSmrg	  fi
2073a253d6aeSmrg
2074ea133fd7Smrg	  # Do each command in the postinstall commands.
2075ea133fd7Smrg	  lib="$destdir/$realname"
2076ea133fd7Smrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
2077a253d6aeSmrg	fi
2078a253d6aeSmrg
2079ea133fd7Smrg	# Install the pseudo-library for information purposes.
2080ea133fd7Smrg	func_basename "$file"
2081ea133fd7Smrg	name="$func_basename_result"
2082ea133fd7Smrg	instname="$dir/$name"i
2083ea133fd7Smrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
2084a253d6aeSmrg
2085ea133fd7Smrg	# Maybe install the static library, too.
2086ea133fd7Smrg	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
2087ea133fd7Smrg	;;
2088a253d6aeSmrg
2089ea133fd7Smrg      *.lo)
2090ea133fd7Smrg	# Install (i.e. copy) a libtool object.
2091a253d6aeSmrg
2092ea133fd7Smrg	# Figure out destination file name, if it wasn't already specified.
2093ea133fd7Smrg	if test -n "$destname"; then
2094ea133fd7Smrg	  destfile="$destdir/$destname"
2095ea133fd7Smrg	else
2096ea133fd7Smrg	  func_basename "$file"
2097ea133fd7Smrg	  destfile="$func_basename_result"
2098ea133fd7Smrg	  destfile="$destdir/$destfile"
2099ea133fd7Smrg	fi
2100ea133fd7Smrg
2101ea133fd7Smrg	# Deduce the name of the destination old-style object file.
2102ea133fd7Smrg	case $destfile in
2103ea133fd7Smrg	*.lo)
2104ea133fd7Smrg	  func_lo2o "$destfile"
2105ea133fd7Smrg	  staticdest=$func_lo2o_result
2106ea133fd7Smrg	  ;;
2107ea133fd7Smrg	*.$objext)
2108ea133fd7Smrg	  staticdest="$destfile"
2109ea133fd7Smrg	  destfile=
2110ea133fd7Smrg	  ;;
2111ea133fd7Smrg	*)
2112ea133fd7Smrg	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
2113ea133fd7Smrg	  ;;
2114a253d6aeSmrg	esac
2115a253d6aeSmrg
2116ea133fd7Smrg	# Install the libtool object if requested.
2117ea133fd7Smrg	test -n "$destfile" && \
2118ea133fd7Smrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
2119ea133fd7Smrg
2120ea133fd7Smrg	# Install the old object if enabled.
2121ea133fd7Smrg	if test "$build_old_libs" = yes; then
2122ea133fd7Smrg	  # Deduce the name of the old-style object file.
2123ea133fd7Smrg	  func_lo2o "$file"
2124ea133fd7Smrg	  staticobj=$func_lo2o_result
2125ea133fd7Smrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
2126a253d6aeSmrg	fi
2127ea133fd7Smrg	exit $EXIT_SUCCESS
2128ea133fd7Smrg	;;
2129a253d6aeSmrg
2130ea133fd7Smrg      *)
2131ea133fd7Smrg	# Figure out destination file name, if it wasn't already specified.
2132ea133fd7Smrg	if test -n "$destname"; then
2133ea133fd7Smrg	  destfile="$destdir/$destname"
2134ea133fd7Smrg	else
2135ea133fd7Smrg	  func_basename "$file"
2136ea133fd7Smrg	  destfile="$func_basename_result"
2137ea133fd7Smrg	  destfile="$destdir/$destfile"
2138ea133fd7Smrg	fi
2139ea133fd7Smrg
2140ea133fd7Smrg	# If the file is missing, and there is a .exe on the end, strip it
2141ea133fd7Smrg	# because it is most likely a libtool script we actually want to
2142ea133fd7Smrg	# install
2143ea133fd7Smrg	stripped_ext=""
2144ea133fd7Smrg	case $file in
2145ea133fd7Smrg	  *.exe)
2146ea133fd7Smrg	    if test ! -f "$file"; then
2147ea133fd7Smrg	      func_stripname '' '.exe' "$file"
2148ea133fd7Smrg	      file=$func_stripname_result
2149ea133fd7Smrg	      stripped_ext=".exe"
2150a253d6aeSmrg	    fi
2151ea133fd7Smrg	    ;;
2152ea133fd7Smrg	esac
2153a253d6aeSmrg
2154ea133fd7Smrg	# Do a test to see if this is really a libtool program.
2155ea133fd7Smrg	case $host in
2156ea133fd7Smrg	*cygwin* | *mingw*)
2157ea133fd7Smrg	    if func_ltwrapper_executable_p "$file"; then
2158ea133fd7Smrg	      func_ltwrapper_scriptname "$file"
2159ea133fd7Smrg	      wrapper=$func_ltwrapper_scriptname_result
2160ea133fd7Smrg	    else
2161ea133fd7Smrg	      func_stripname '' '.exe' "$file"
2162ea133fd7Smrg	      wrapper=$func_stripname_result
2163ea133fd7Smrg	    fi
2164ea133fd7Smrg	    ;;
2165ea133fd7Smrg	*)
2166ea133fd7Smrg	    wrapper=$file
2167ea133fd7Smrg	    ;;
2168ea133fd7Smrg	esac
2169ea133fd7Smrg	if func_ltwrapper_script_p "$wrapper"; then
2170ea133fd7Smrg	  notinst_deplibs=
2171ea133fd7Smrg	  relink_command=
2172a253d6aeSmrg
2173ea133fd7Smrg	  func_source "$wrapper"
2174a253d6aeSmrg
2175ea133fd7Smrg	  # Check the variables that should have been set.
2176ea133fd7Smrg	  test -z "$generated_by_libtool_version" && \
2177ea133fd7Smrg	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
2178ea133fd7Smrg
2179ea133fd7Smrg	  finalize=yes
2180ea133fd7Smrg	  for lib in $notinst_deplibs; do
2181ea133fd7Smrg	    # Check to see that each library is installed.
2182ea133fd7Smrg	    libdir=
2183ea133fd7Smrg	    if test -f "$lib"; then
2184ea133fd7Smrg	      func_source "$lib"
2185ea133fd7Smrg	    fi
2186ea133fd7Smrg	    libfile="$libdir/"`$ECHO "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
2187ea133fd7Smrg	    if test -n "$libdir" && test ! -f "$libfile"; then
2188ea133fd7Smrg	      func_warning "\`$lib' has not been installed in \`$libdir'"
2189ea133fd7Smrg	      finalize=no
2190ea133fd7Smrg	    fi
2191ea133fd7Smrg	  done
2192ea133fd7Smrg
2193ea133fd7Smrg	  relink_command=
2194ea133fd7Smrg	  func_source "$wrapper"
2195ea133fd7Smrg
2196ea133fd7Smrg	  outputname=
2197ea133fd7Smrg	  if test "$fast_install" = no && test -n "$relink_command"; then
2198ea133fd7Smrg	    $opt_dry_run || {
2199ea133fd7Smrg	      if test "$finalize" = yes; then
2200ea133fd7Smrg	        tmpdir=`func_mktempdir`
2201ea133fd7Smrg		func_basename "$file$stripped_ext"
2202ea133fd7Smrg		file="$func_basename_result"
2203ea133fd7Smrg	        outputname="$tmpdir/$file"
2204ea133fd7Smrg	        # Replace the output file specification.
2205ea133fd7Smrg	        relink_command=`$ECHO "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
2206ea133fd7Smrg
2207ea133fd7Smrg	        $opt_silent || {
2208ea133fd7Smrg	          func_quote_for_expand "$relink_command"
2209ea133fd7Smrg		  eval "func_echo $func_quote_for_expand_result"
2210ea133fd7Smrg	        }
2211ea133fd7Smrg	        if eval "$relink_command"; then :
2212ea133fd7Smrg	          else
2213ea133fd7Smrg		  func_error "error: relink \`$file' with the above command before installing it"
2214ea133fd7Smrg		  $opt_dry_run || ${RM}r "$tmpdir"
2215ea133fd7Smrg		  continue
2216ea133fd7Smrg	        fi
2217ea133fd7Smrg	        file="$outputname"
2218ea133fd7Smrg	      else
2219ea133fd7Smrg	        func_warning "cannot relink \`$file'"
2220ea133fd7Smrg	      fi
2221ea133fd7Smrg	    }
2222a253d6aeSmrg	  else
2223ea133fd7Smrg	    # Install the binary that we compiled earlier.
2224ea133fd7Smrg	    file=`$ECHO "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
2225a253d6aeSmrg	  fi
2226ea133fd7Smrg	fi
2227a253d6aeSmrg
2228ea133fd7Smrg	# remove .exe since cygwin /usr/bin/install will append another
2229ea133fd7Smrg	# one anyway
2230ea133fd7Smrg	case $install_prog,$host in
2231ea133fd7Smrg	*/usr/bin/install*,*cygwin*)
2232ea133fd7Smrg	  case $file:$destfile in
2233ea133fd7Smrg	  *.exe:*.exe)
2234ea133fd7Smrg	    # this is ok
2235ea133fd7Smrg	    ;;
2236ea133fd7Smrg	  *.exe:*)
2237ea133fd7Smrg	    destfile=$destfile.exe
2238ea133fd7Smrg	    ;;
2239ea133fd7Smrg	  *:*.exe)
2240ea133fd7Smrg	    func_stripname '' '.exe' "$destfile"
2241ea133fd7Smrg	    destfile=$func_stripname_result
2242ea133fd7Smrg	    ;;
2243ea133fd7Smrg	  esac
2244a253d6aeSmrg	  ;;
2245a253d6aeSmrg	esac
2246ea133fd7Smrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
2247ea133fd7Smrg	$opt_dry_run || if test -n "$outputname"; then
2248ea133fd7Smrg	  ${RM}r "$tmpdir"
2249ea133fd7Smrg	fi
2250ea133fd7Smrg	;;
2251ea133fd7Smrg      esac
2252ea133fd7Smrg    done
2253a253d6aeSmrg
2254ea133fd7Smrg    for file in $staticlibs; do
2255ea133fd7Smrg      func_basename "$file"
2256ea133fd7Smrg      name="$func_basename_result"
2257a253d6aeSmrg
2258ea133fd7Smrg      # Set up the ranlib parameters.
2259ea133fd7Smrg      oldlib="$destdir/$name"
2260a253d6aeSmrg
2261ea133fd7Smrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
2262a253d6aeSmrg
2263ea133fd7Smrg      if test -n "$stripme" && test -n "$old_striplib"; then
2264ea133fd7Smrg	func_show_eval "$old_striplib $oldlib" 'exit $?'
2265ea133fd7Smrg      fi
2266a253d6aeSmrg
2267ea133fd7Smrg      # Do each command in the postinstall commands.
2268ea133fd7Smrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
2269ea133fd7Smrg    done
2270a253d6aeSmrg
2271ea133fd7Smrg    test -n "$future_libdirs" && \
2272ea133fd7Smrg      func_warning "remember to run \`$progname --finish$future_libdirs'"
2273a253d6aeSmrg
2274ea133fd7Smrg    if test -n "$current_libdirs"; then
2275ea133fd7Smrg      # Maybe just do a dry run.
2276ea133fd7Smrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
2277ea133fd7Smrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
2278ea133fd7Smrg    else
2279ea133fd7Smrg      exit $EXIT_SUCCESS
2280ea133fd7Smrg    fi
2281ea133fd7Smrg}
2282a253d6aeSmrg
2283ea133fd7Smrgtest "$mode" = install && func_mode_install ${1+"$@"}
2284a253d6aeSmrg
2285a253d6aeSmrg
2286ea133fd7Smrg# func_generate_dlsyms outputname originator pic_p
2287ea133fd7Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with
2288ea133fd7Smrg# a dlpreopen symbol table.
2289ea133fd7Smrgfunc_generate_dlsyms ()
2290ea133fd7Smrg{
2291ea133fd7Smrg    $opt_debug
2292ea133fd7Smrg    my_outputname="$1"
2293ea133fd7Smrg    my_originator="$2"
2294ea133fd7Smrg    my_pic_p="${3-no}"
2295ea133fd7Smrg    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
2296ea133fd7Smrg    my_dlsyms=
2297ea133fd7Smrg
2298ea133fd7Smrg    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
2299ea133fd7Smrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
2300ea133fd7Smrg	my_dlsyms="${my_outputname}S.c"
2301ea133fd7Smrg      else
2302ea133fd7Smrg	func_error "not configured to extract global symbols from dlpreopened files"
2303ea133fd7Smrg      fi
2304ea133fd7Smrg    fi
2305a253d6aeSmrg
2306ea133fd7Smrg    if test -n "$my_dlsyms"; then
2307ea133fd7Smrg      case $my_dlsyms in
2308ea133fd7Smrg      "") ;;
2309ea133fd7Smrg      *.c)
2310ea133fd7Smrg	# Discover the nlist of each of the dlfiles.
2311ea133fd7Smrg	nlist="$output_objdir/${my_outputname}.nm"
2312ea133fd7Smrg
2313ea133fd7Smrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
2314ea133fd7Smrg
2315ea133fd7Smrg	# Parse the name list into a source file.
2316ea133fd7Smrg	func_verbose "creating $output_objdir/$my_dlsyms"
2317ea133fd7Smrg
2318ea133fd7Smrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
2319ea133fd7Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
2320ea133fd7Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
2321ea133fd7Smrg
2322ea133fd7Smrg#ifdef __cplusplus
2323ea133fd7Smrgextern \"C\" {
2324ea133fd7Smrg#endif
2325ea133fd7Smrg
2326ea133fd7Smrg/* External symbol declarations for the compiler. */\
2327ea133fd7Smrg"
2328ea133fd7Smrg
2329ea133fd7Smrg	if test "$dlself" = yes; then
2330ea133fd7Smrg	  func_verbose "generating symbol list for \`$output'"
2331ea133fd7Smrg
2332ea133fd7Smrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
2333ea133fd7Smrg
2334ea133fd7Smrg	  # Add our own program objects to the symbol list.
2335ea133fd7Smrg	  progfiles=`$ECHO "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
2336ea133fd7Smrg	  for progfile in $progfiles; do
2337ea133fd7Smrg	    func_verbose "extracting global C symbols from \`$progfile'"
2338ea133fd7Smrg	    $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'"
2339ea133fd7Smrg	  done
2340ea133fd7Smrg
2341ea133fd7Smrg	  if test -n "$exclude_expsyms"; then
2342ea133fd7Smrg	    $opt_dry_run || {
2343ea133fd7Smrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
2344ea133fd7Smrg	      eval '$MV "$nlist"T "$nlist"'
2345ea133fd7Smrg	    }
2346a253d6aeSmrg	  fi
2347a253d6aeSmrg
2348ea133fd7Smrg	  if test -n "$export_symbols_regex"; then
2349ea133fd7Smrg	    $opt_dry_run || {
2350ea133fd7Smrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
2351ea133fd7Smrg	      eval '$MV "$nlist"T "$nlist"'
2352ea133fd7Smrg	    }
2353a253d6aeSmrg	  fi
2354ea133fd7Smrg
2355ea133fd7Smrg	  # Prepare the list of exported symbols
2356ea133fd7Smrg	  if test -z "$export_symbols"; then
2357ea133fd7Smrg	    export_symbols="$output_objdir/$outputname.exp"
2358ea133fd7Smrg	    $opt_dry_run || {
2359ea133fd7Smrg	      $RM $export_symbols
2360ea133fd7Smrg	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
2361ea133fd7Smrg	      case $host in
2362ea133fd7Smrg	      *cygwin* | *mingw* | *cegcc* )
2363ea133fd7Smrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
2364ea133fd7Smrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
2365ea133fd7Smrg	        ;;
2366a253d6aeSmrg	      esac
2367ea133fd7Smrg	    }
2368ea133fd7Smrg	  else
2369ea133fd7Smrg	    $opt_dry_run || {
2370ea133fd7Smrg	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
2371ea133fd7Smrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
2372ea133fd7Smrg	      eval '$MV "$nlist"T "$nlist"'
2373ea133fd7Smrg	      case $host in
2374ea133fd7Smrg	        *cygwin | *mingw* | *cegcc* )
2375ea133fd7Smrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
2376ea133fd7Smrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
2377ea133fd7Smrg	          ;;
2378a253d6aeSmrg	      esac
2379ea133fd7Smrg	    }
2380a253d6aeSmrg	  fi
2381ea133fd7Smrg	fi
2382a253d6aeSmrg
2383ea133fd7Smrg	for dlprefile in $dlprefiles; do
2384ea133fd7Smrg	  func_verbose "extracting global C symbols from \`$dlprefile'"
2385ea133fd7Smrg	  func_basename "$dlprefile"
2386ea133fd7Smrg	  name="$func_basename_result"
2387ea133fd7Smrg	  $opt_dry_run || {
2388ea133fd7Smrg	    eval '$ECHO ": $name " >> "$nlist"'
2389ea133fd7Smrg	    eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'"
2390ea133fd7Smrg	  }
2391ea133fd7Smrg	done
2392a253d6aeSmrg
2393ea133fd7Smrg	$opt_dry_run || {
2394ea133fd7Smrg	  # Make sure we have at least an empty file.
2395ea133fd7Smrg	  test -f "$nlist" || : > "$nlist"
2396a253d6aeSmrg
2397ea133fd7Smrg	  if test -n "$exclude_expsyms"; then
2398ea133fd7Smrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
2399ea133fd7Smrg	    $MV "$nlist"T "$nlist"
2400a253d6aeSmrg	  fi
2401a253d6aeSmrg
2402ea133fd7Smrg	  # Try sorting and uniquifying the output.
2403ea133fd7Smrg	  if $GREP -v "^: " < "$nlist" |
2404ea133fd7Smrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
2405ea133fd7Smrg		sort -k 3
2406a253d6aeSmrg	      else
2407ea133fd7Smrg		sort +2
2408ea133fd7Smrg	      fi |
2409ea133fd7Smrg	      uniq > "$nlist"S; then
2410ea133fd7Smrg	    :
2411a253d6aeSmrg	  else
2412ea133fd7Smrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
2413a253d6aeSmrg	  fi
2414a253d6aeSmrg
2415ea133fd7Smrg	  if test -f "$nlist"S; then
2416ea133fd7Smrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
2417a253d6aeSmrg	  else
2418ea133fd7Smrg	    $ECHO '/* NONE */' >> "$output_objdir/$my_dlsyms"
2419a253d6aeSmrg	  fi
2420a253d6aeSmrg
2421ea133fd7Smrg	  $ECHO >> "$output_objdir/$my_dlsyms" "\
2422a253d6aeSmrg
2423ea133fd7Smrg/* The mapping between symbol names and symbols.  */
2424ea133fd7Smrgtypedef struct {
2425ea133fd7Smrg  const char *name;
2426ea133fd7Smrg  void *address;
2427ea133fd7Smrg} lt_dlsymlist;
2428ea133fd7Smrg"
2429ea133fd7Smrg	  case $host in
2430ea133fd7Smrg	  *cygwin* | *mingw* | *cegcc* )
2431ea133fd7Smrg	    $ECHO >> "$output_objdir/$my_dlsyms" "\
2432ea133fd7Smrg/* DATA imports from DLLs on WIN32 con't be const, because
2433ea133fd7Smrg   runtime relocations are performed -- see ld's documentation
2434ea133fd7Smrg   on pseudo-relocs.  */"
2435ea133fd7Smrg	    lt_dlsym_const= ;;
2436ea133fd7Smrg	  *osf5*)
2437ea133fd7Smrg	    echo >> "$output_objdir/$my_dlsyms" "\
2438ea133fd7Smrg/* This system does not cope well with relocations in const data */"
2439ea133fd7Smrg	    lt_dlsym_const= ;;
2440ea133fd7Smrg	  *)
2441ea133fd7Smrg	    lt_dlsym_const=const ;;
2442ea133fd7Smrg	  esac
2443ea133fd7Smrg
2444ea133fd7Smrg	  $ECHO >> "$output_objdir/$my_dlsyms" "\
2445ea133fd7Smrgextern $lt_dlsym_const lt_dlsymlist
2446ea133fd7Smrglt_${my_prefix}_LTX_preloaded_symbols[];
2447ea133fd7Smrg$lt_dlsym_const lt_dlsymlist
2448ea133fd7Smrglt_${my_prefix}_LTX_preloaded_symbols[] =
2449ea133fd7Smrg{\
2450ea133fd7Smrg  { \"$my_originator\", (void *) 0 },"
2451ea133fd7Smrg
2452ea133fd7Smrg	  case $need_lib_prefix in
2453ea133fd7Smrg	  no)
2454ea133fd7Smrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
2455ea133fd7Smrg	    ;;
2456ea133fd7Smrg	  *)
2457ea133fd7Smrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
2458ea133fd7Smrg	    ;;
2459ea133fd7Smrg	  esac
2460ea133fd7Smrg	  $ECHO >> "$output_objdir/$my_dlsyms" "\
2461ea133fd7Smrg  {0, (void *) 0}
2462ea133fd7Smrg};
2463ea133fd7Smrg
2464ea133fd7Smrg/* This works around a problem in FreeBSD linker */
2465ea133fd7Smrg#ifdef FREEBSD_WORKAROUND
2466ea133fd7Smrgstatic const void *lt_preloaded_setup() {
2467ea133fd7Smrg  return lt_${my_prefix}_LTX_preloaded_symbols;
2468ea133fd7Smrg}
2469ea133fd7Smrg#endif
2470ea133fd7Smrg
2471ea133fd7Smrg#ifdef __cplusplus
2472ea133fd7Smrg}
2473ea133fd7Smrg#endif\
2474ea133fd7Smrg"
2475ea133fd7Smrg	} # !$opt_dry_run
2476ea133fd7Smrg
2477ea133fd7Smrg	pic_flag_for_symtable=
2478ea133fd7Smrg	case "$compile_command " in
2479ea133fd7Smrg	*" -static "*) ;;
2480ea133fd7Smrg	*)
2481ea133fd7Smrg	  case $host in
2482ea133fd7Smrg	  # compiling the symbol table file with pic_flag works around
2483ea133fd7Smrg	  # a FreeBSD bug that causes programs to crash when -lm is
2484ea133fd7Smrg	  # linked before any other PIC object.  But we must not use
2485ea133fd7Smrg	  # pic_flag when linking with -static.  The problem exists in
2486ea133fd7Smrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
2487ea133fd7Smrg	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
2488ea133fd7Smrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
2489ea133fd7Smrg	  *-*-hpux*)
2490ea133fd7Smrg	    pic_flag_for_symtable=" $pic_flag"  ;;
2491ea133fd7Smrg	  *)
2492ea133fd7Smrg	    if test "X$my_pic_p" != Xno; then
2493ea133fd7Smrg	      pic_flag_for_symtable=" $pic_flag"
2494a253d6aeSmrg	    fi
2495ea133fd7Smrg	    ;;
2496ea133fd7Smrg	  esac
2497ea133fd7Smrg	  ;;
2498ea133fd7Smrg	esac
2499ea133fd7Smrg	symtab_cflags=
2500ea133fd7Smrg	for arg in $LTCFLAGS; do
2501ea133fd7Smrg	  case $arg in
2502ea133fd7Smrg	  -pie | -fpie | -fPIE) ;;
2503ea133fd7Smrg	  *) symtab_cflags="$symtab_cflags $arg" ;;
2504ea133fd7Smrg	  esac
2505ea133fd7Smrg	done
2506a253d6aeSmrg
2507ea133fd7Smrg	# Now compile the dynamic symbol file.
2508ea133fd7Smrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
2509a253d6aeSmrg
2510ea133fd7Smrg	# Clean up the generated files.
2511ea133fd7Smrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
2512ea133fd7Smrg
2513ea133fd7Smrg	# Transform the symbol file into the correct name.
2514ea133fd7Smrg	symfileobj="$output_objdir/${my_outputname}S.$objext"
2515ea133fd7Smrg	case $host in
2516ea133fd7Smrg	*cygwin* | *mingw* | *cegcc* )
2517ea133fd7Smrg	  if test -f "$output_objdir/$my_outputname.def"; then
2518ea133fd7Smrg	    compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
2519ea133fd7Smrg	    finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
2520ea133fd7Smrg	  else
2521ea133fd7Smrg	    compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2522ea133fd7Smrg	    finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2523ea133fd7Smrg	  fi
2524ea133fd7Smrg	  ;;
2525ea133fd7Smrg	*)
2526ea133fd7Smrg	  compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2527ea133fd7Smrg	  finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2528a253d6aeSmrg	  ;;
2529a253d6aeSmrg	esac
2530ea133fd7Smrg	;;
2531ea133fd7Smrg      *)
2532ea133fd7Smrg	func_fatal_error "unknown suffix for \`$my_dlsyms'"
2533ea133fd7Smrg	;;
2534ea133fd7Smrg      esac
2535ea133fd7Smrg    else
2536ea133fd7Smrg      # We keep going just in case the user didn't refer to
2537ea133fd7Smrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
2538ea133fd7Smrg      # really was required.
2539ea133fd7Smrg
2540ea133fd7Smrg      # Nullify the symbol file.
2541ea133fd7Smrg      compile_command=`$ECHO "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
2542ea133fd7Smrg      finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
2543a253d6aeSmrg    fi
2544ea133fd7Smrg}
2545a253d6aeSmrg
2546ea133fd7Smrg# func_win32_libid arg
2547ea133fd7Smrg# return the library type of file 'arg'
2548ea133fd7Smrg#
2549ea133fd7Smrg# Need a lot of goo to handle *both* DLLs and import libs
2550ea133fd7Smrg# Has to be a shell function in order to 'eat' the argument
2551ea133fd7Smrg# that is supplied when $file_magic_command is called.
2552ea133fd7Smrgfunc_win32_libid ()
2553ea133fd7Smrg{
2554ea133fd7Smrg  $opt_debug
2555ea133fd7Smrg  win32_libid_type="unknown"
2556ea133fd7Smrg  win32_fileres=`file -L $1 2>/dev/null`
2557ea133fd7Smrg  case $win32_fileres in
2558ea133fd7Smrg  *ar\ archive\ import\ library*) # definitely import
2559ea133fd7Smrg    win32_libid_type="x86 archive import"
2560ea133fd7Smrg    ;;
2561ea133fd7Smrg  *ar\ archive*) # could be an import, or static
2562ea133fd7Smrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
2563ea133fd7Smrg       $EGREP 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
2564ea133fd7Smrg      win32_nmres=`eval $NM -f posix -A $1 |
2565ea133fd7Smrg	$SED -n -e '
2566ea133fd7Smrg	    1,100{
2567ea133fd7Smrg		/ I /{
2568ea133fd7Smrg		    s,.*,import,
2569ea133fd7Smrg		    p
2570ea133fd7Smrg		    q
2571ea133fd7Smrg		}
2572ea133fd7Smrg	    }'`
2573ea133fd7Smrg      case $win32_nmres in
2574ea133fd7Smrg      import*)  win32_libid_type="x86 archive import";;
2575ea133fd7Smrg      *)        win32_libid_type="x86 archive static";;
2576ea133fd7Smrg      esac
2577ea133fd7Smrg    fi
2578ea133fd7Smrg    ;;
2579ea133fd7Smrg  *DLL*)
2580ea133fd7Smrg    win32_libid_type="x86 DLL"
2581ea133fd7Smrg    ;;
2582ea133fd7Smrg  *executable*) # but shell scripts are "executable" too...
2583ea133fd7Smrg    case $win32_fileres in
2584ea133fd7Smrg    *MS\ Windows\ PE\ Intel*)
2585ea133fd7Smrg      win32_libid_type="x86 DLL"
2586ea133fd7Smrg      ;;
2587ea133fd7Smrg    esac
2588ea133fd7Smrg    ;;
2589ea133fd7Smrg  esac
2590ea133fd7Smrg  $ECHO "$win32_libid_type"
2591ea133fd7Smrg}
2592a253d6aeSmrg
2593a253d6aeSmrg
2594a253d6aeSmrg
2595ea133fd7Smrg# func_extract_an_archive dir oldlib
2596ea133fd7Smrgfunc_extract_an_archive ()
2597ea133fd7Smrg{
2598ea133fd7Smrg    $opt_debug
2599ea133fd7Smrg    f_ex_an_ar_dir="$1"; shift
2600ea133fd7Smrg    f_ex_an_ar_oldlib="$1"
2601ea133fd7Smrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" 'exit $?'
2602ea133fd7Smrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
2603ea133fd7Smrg     :
2604ea133fd7Smrg    else
2605ea133fd7Smrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
2606ea133fd7Smrg    fi
2607ea133fd7Smrg}
2608a253d6aeSmrg
2609a253d6aeSmrg
2610ea133fd7Smrg# func_extract_archives gentop oldlib ...
2611ea133fd7Smrgfunc_extract_archives ()
2612ea133fd7Smrg{
2613ea133fd7Smrg    $opt_debug
2614ea133fd7Smrg    my_gentop="$1"; shift
2615ea133fd7Smrg    my_oldlibs=${1+"$@"}
2616ea133fd7Smrg    my_oldobjs=""
2617ea133fd7Smrg    my_xlib=""
2618ea133fd7Smrg    my_xabs=""
2619ea133fd7Smrg    my_xdir=""
2620a253d6aeSmrg
2621ea133fd7Smrg    for my_xlib in $my_oldlibs; do
2622ea133fd7Smrg      # Extract the objects.
2623ea133fd7Smrg      case $my_xlib in
2624ea133fd7Smrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
2625ea133fd7Smrg	*) my_xabs=`pwd`"/$my_xlib" ;;
2626ea133fd7Smrg      esac
2627ea133fd7Smrg      func_basename "$my_xlib"
2628ea133fd7Smrg      my_xlib="$func_basename_result"
2629ea133fd7Smrg      my_xlib_u=$my_xlib
2630ea133fd7Smrg      while :; do
2631ea133fd7Smrg        case " $extracted_archives " in
2632ea133fd7Smrg	*" $my_xlib_u "*)
2633ea133fd7Smrg	  func_arith $extracted_serial + 1
2634ea133fd7Smrg	  extracted_serial=$func_arith_result
2635ea133fd7Smrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
2636ea133fd7Smrg	*) break ;;
2637ea133fd7Smrg	esac
2638ea133fd7Smrg      done
2639ea133fd7Smrg      extracted_archives="$extracted_archives $my_xlib_u"
2640ea133fd7Smrg      my_xdir="$my_gentop/$my_xlib_u"
2641a253d6aeSmrg
2642ea133fd7Smrg      func_mkdir_p "$my_xdir"
2643a253d6aeSmrg
2644ea133fd7Smrg      case $host in
2645ea133fd7Smrg      *-darwin*)
2646ea133fd7Smrg	func_verbose "Extracting $my_xabs"
2647ea133fd7Smrg	# Do not bother doing anything if just a dry run
2648ea133fd7Smrg	$opt_dry_run || {
2649ea133fd7Smrg	  darwin_orig_dir=`pwd`
2650ea133fd7Smrg	  cd $my_xdir || exit $?
2651ea133fd7Smrg	  darwin_archive=$my_xabs
2652ea133fd7Smrg	  darwin_curdir=`pwd`
2653ea133fd7Smrg	  darwin_base_archive=`basename "$darwin_archive"`
2654ea133fd7Smrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
2655ea133fd7Smrg	  if test -n "$darwin_arches"; then
2656ea133fd7Smrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
2657ea133fd7Smrg	    darwin_arch=
2658ea133fd7Smrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
2659ea133fd7Smrg	    for darwin_arch in  $darwin_arches ; do
2660ea133fd7Smrg	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
2661ea133fd7Smrg	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
2662ea133fd7Smrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
2663ea133fd7Smrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
2664ea133fd7Smrg	      cd "$darwin_curdir"
2665ea133fd7Smrg	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
2666ea133fd7Smrg	    done # $darwin_arches
2667ea133fd7Smrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
2668ea133fd7Smrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
2669ea133fd7Smrg	    darwin_file=
2670ea133fd7Smrg	    darwin_files=
2671ea133fd7Smrg	    for darwin_file in $darwin_filelist; do
2672ea133fd7Smrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
2673ea133fd7Smrg	      $LIPO -create -output "$darwin_file" $darwin_files
2674ea133fd7Smrg	    done # $darwin_filelist
2675ea133fd7Smrg	    $RM -rf unfat-$$
2676ea133fd7Smrg	    cd "$darwin_orig_dir"
2677ea133fd7Smrg	  else
2678ea133fd7Smrg	    cd $darwin_orig_dir
2679ea133fd7Smrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
2680ea133fd7Smrg	  fi # $darwin_arches
2681ea133fd7Smrg	} # !$opt_dry_run
2682ea133fd7Smrg	;;
2683ea133fd7Smrg      *)
2684ea133fd7Smrg        func_extract_an_archive "$my_xdir" "$my_xabs"
2685ea133fd7Smrg	;;
2686a253d6aeSmrg      esac
2687ea133fd7Smrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
2688ea133fd7Smrg    done
2689a253d6aeSmrg
2690ea133fd7Smrg    func_extract_archives_result="$my_oldobjs"
2691ea133fd7Smrg}
2692a253d6aeSmrg
2693a253d6aeSmrg
2694a253d6aeSmrg
2695ea133fd7Smrg# func_emit_wrapper_part1 [arg=no]
2696ea133fd7Smrg#
2697ea133fd7Smrg# Emit the first part of a libtool wrapper script on stdout.
2698ea133fd7Smrg# For more information, see the description associated with
2699ea133fd7Smrg# func_emit_wrapper(), below.
2700ea133fd7Smrgfunc_emit_wrapper_part1 ()
2701ea133fd7Smrg{
2702ea133fd7Smrg	func_emit_wrapper_part1_arg1=no
2703ea133fd7Smrg	if test -n "$1" ; then
2704ea133fd7Smrg	  func_emit_wrapper_part1_arg1=$1
2705a253d6aeSmrg	fi
2706a253d6aeSmrg
2707ea133fd7Smrg	$ECHO "\
2708ea133fd7Smrg#! $SHELL
2709a253d6aeSmrg
2710ea133fd7Smrg# $output - temporary wrapper script for $objdir/$outputname
2711ea133fd7Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
2712ea133fd7Smrg#
2713ea133fd7Smrg# The $output program cannot be directly executed until all the libtool
2714ea133fd7Smrg# libraries that it depends on are installed.
2715ea133fd7Smrg#
2716ea133fd7Smrg# This wrapper script should never be moved out of the build directory.
2717ea133fd7Smrg# If it is, it will not operate correctly.
2718a253d6aeSmrg
2719ea133fd7Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
2720ea133fd7Smrg# metacharacters that are still active within double-quoted strings.
2721ea133fd7SmrgXsed='${SED} -e 1s/^X//'
2722ea133fd7Smrgsed_quote_subst='$sed_quote_subst'
2723a253d6aeSmrg
2724ea133fd7Smrg# Be Bourne compatible
2725ea133fd7Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
2726ea133fd7Smrg  emulate sh
2727ea133fd7Smrg  NULLCMD=:
2728ea133fd7Smrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
2729ea133fd7Smrg  # is contrary to our usage.  Disable this feature.
2730ea133fd7Smrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
2731ea133fd7Smrg  setopt NO_GLOB_SUBST
2732ea133fd7Smrgelse
2733ea133fd7Smrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
2734ea133fd7Smrgfi
2735ea133fd7SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
2736ea133fd7SmrgDUALCASE=1; export DUALCASE # for MKS sh
2737a253d6aeSmrg
2738ea133fd7Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout
2739ea133fd7Smrg# if CDPATH is set.
2740ea133fd7Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
2741a253d6aeSmrg
2742ea133fd7Smrgrelink_command=\"$relink_command\"
2743a253d6aeSmrg
2744ea133fd7Smrg# This environment variable determines our operation mode.
2745ea133fd7Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then
2746ea133fd7Smrg  # install mode needs the following variables:
2747ea133fd7Smrg  generated_by_libtool_version='$macro_version'
2748ea133fd7Smrg  notinst_deplibs='$notinst_deplibs'
2749ea133fd7Smrgelse
2750ea133fd7Smrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
2751ea133fd7Smrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
2752ea133fd7Smrg    ECHO=\"$qecho\"
2753ea133fd7Smrg    file=\"\$0\"
2754ea133fd7Smrg    # Make sure echo works.
2755ea133fd7Smrg    if test \"X\$1\" = X--no-reexec; then
2756ea133fd7Smrg      # Discard the --no-reexec flag, and continue.
2757ea133fd7Smrg      shift
2758ea133fd7Smrg    elif test \"X\`{ \$ECHO '\t'; } 2>/dev/null\`\" = 'X\t'; then
2759ea133fd7Smrg      # Yippee, \$ECHO works!
2760ea133fd7Smrg      :
2761ea133fd7Smrg    else
2762ea133fd7Smrg      # Restart under the correct shell, and then maybe \$ECHO will work.
2763ea133fd7Smrg      exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
2764ea133fd7Smrg    fi
2765ea133fd7Smrg  fi\
2766ea133fd7Smrg"
2767ea133fd7Smrg	$ECHO "\
2768a253d6aeSmrg
2769ea133fd7Smrg  # Find the directory that this script lives in.
2770ea133fd7Smrg  thisdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
2771ea133fd7Smrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
2772a253d6aeSmrg
2773ea133fd7Smrg  # Follow symbolic links until we get to the real thisdir.
2774ea133fd7Smrg  file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
2775ea133fd7Smrg  while test -n \"\$file\"; do
2776ea133fd7Smrg    destdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
2777a253d6aeSmrg
2778ea133fd7Smrg    # If there was a directory component, then change thisdir.
2779ea133fd7Smrg    if test \"x\$destdir\" != \"x\$file\"; then
2780ea133fd7Smrg      case \"\$destdir\" in
2781ea133fd7Smrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
2782ea133fd7Smrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
2783ea133fd7Smrg      esac
2784ea133fd7Smrg    fi
2785a253d6aeSmrg
2786ea133fd7Smrg    file=\`\$ECHO \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
2787ea133fd7Smrg    file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
2788ea133fd7Smrg  done
2789ea133fd7Smrg"
2790ea133fd7Smrg}
2791ea133fd7Smrg# end: func_emit_wrapper_part1
2792a253d6aeSmrg
2793ea133fd7Smrg# func_emit_wrapper_part2 [arg=no]
2794ea133fd7Smrg#
2795ea133fd7Smrg# Emit the second part of a libtool wrapper script on stdout.
2796ea133fd7Smrg# For more information, see the description associated with
2797ea133fd7Smrg# func_emit_wrapper(), below.
2798ea133fd7Smrgfunc_emit_wrapper_part2 ()
2799ea133fd7Smrg{
2800ea133fd7Smrg	func_emit_wrapper_part2_arg1=no
2801ea133fd7Smrg	if test -n "$1" ; then
2802ea133fd7Smrg	  func_emit_wrapper_part2_arg1=$1
2803ea133fd7Smrg	fi
2804a253d6aeSmrg
2805ea133fd7Smrg	$ECHO "\
2806a253d6aeSmrg
2807ea133fd7Smrg  # Usually 'no', except on cygwin/mingw when embedded into
2808ea133fd7Smrg  # the cwrapper.
2809ea133fd7Smrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_part2_arg1
2810ea133fd7Smrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
2811ea133fd7Smrg    # special case for '.'
2812ea133fd7Smrg    if test \"\$thisdir\" = \".\"; then
2813ea133fd7Smrg      thisdir=\`pwd\`
2814ea133fd7Smrg    fi
2815ea133fd7Smrg    # remove .libs from thisdir
2816ea133fd7Smrg    case \"\$thisdir\" in
2817ea133fd7Smrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"X\$thisdir\" | \$Xsed -e 's%[\\\\/][^\\\\/]*$%%'\` ;;
2818ea133fd7Smrg    $objdir )   thisdir=. ;;
2819ea133fd7Smrg    esac
2820ea133fd7Smrg  fi
2821a253d6aeSmrg
2822ea133fd7Smrg  # Try to get the absolute directory name.
2823ea133fd7Smrg  absdir=\`cd \"\$thisdir\" && pwd\`
2824ea133fd7Smrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
2825ea133fd7Smrg"
2826a253d6aeSmrg
2827ea133fd7Smrg	if test "$fast_install" = yes; then
2828ea133fd7Smrg	  $ECHO "\
2829ea133fd7Smrg  program=lt-'$outputname'$exeext
2830ea133fd7Smrg  progdir=\"\$thisdir/$objdir\"
2831a253d6aeSmrg
2832ea133fd7Smrg  if test ! -f \"\$progdir/\$program\" ||
2833ea133fd7Smrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
2834ea133fd7Smrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
2835a253d6aeSmrg
2836ea133fd7Smrg    file=\"\$\$-\$program\"
2837a253d6aeSmrg
2838ea133fd7Smrg    if test ! -d \"\$progdir\"; then
2839ea133fd7Smrg      $MKDIR \"\$progdir\"
2840ea133fd7Smrg    else
2841ea133fd7Smrg      $RM \"\$progdir/\$file\"
2842ea133fd7Smrg    fi"
2843a253d6aeSmrg
2844ea133fd7Smrg	  $ECHO "\
2845a253d6aeSmrg
2846ea133fd7Smrg    # relink executable if necessary
2847ea133fd7Smrg    if test -n \"\$relink_command\"; then
2848ea133fd7Smrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
2849ea133fd7Smrg      else
2850ea133fd7Smrg	$ECHO \"\$relink_command_output\" >&2
2851ea133fd7Smrg	$RM \"\$progdir/\$file\"
2852ea133fd7Smrg	exit 1
2853ea133fd7Smrg      fi
2854ea133fd7Smrg    fi
2855a253d6aeSmrg
2856ea133fd7Smrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
2857ea133fd7Smrg    { $RM \"\$progdir/\$program\";
2858ea133fd7Smrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
2859ea133fd7Smrg    $RM \"\$progdir/\$file\"
2860ea133fd7Smrg  fi"
2861ea133fd7Smrg	else
2862ea133fd7Smrg	  $ECHO "\
2863ea133fd7Smrg  program='$outputname'
2864ea133fd7Smrg  progdir=\"\$thisdir/$objdir\"
2865ea133fd7Smrg"
2866ea133fd7Smrg	fi
2867a253d6aeSmrg
2868ea133fd7Smrg	$ECHO "\
2869a253d6aeSmrg
2870ea133fd7Smrg  if test -f \"\$progdir/\$program\"; then"
2871a253d6aeSmrg
2872ea133fd7Smrg	# Export our shlibpath_var if we have one.
2873ea133fd7Smrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
2874ea133fd7Smrg	  $ECHO "\
2875ea133fd7Smrg    # Add our own library path to $shlibpath_var
2876ea133fd7Smrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
2877a253d6aeSmrg
2878ea133fd7Smrg    # Some systems cannot cope with colon-terminated $shlibpath_var
2879ea133fd7Smrg    # The second colon is a workaround for a bug in BeOS R4 sed
2880ea133fd7Smrg    $shlibpath_var=\`\$ECHO \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
2881a253d6aeSmrg
2882ea133fd7Smrg    export $shlibpath_var
2883ea133fd7Smrg"
2884a253d6aeSmrg	fi
2885a253d6aeSmrg
2886ea133fd7Smrg	# fixup the dll searchpath if we need to.
2887ea133fd7Smrg	if test -n "$dllsearchpath"; then
2888ea133fd7Smrg	  $ECHO "\
2889ea133fd7Smrg    # Add the dll search path components to the executable PATH
2890ea133fd7Smrg    PATH=$dllsearchpath:\$PATH
2891ea133fd7Smrg"
2892a253d6aeSmrg	fi
2893a253d6aeSmrg
2894ea133fd7Smrg	$ECHO "\
2895ea133fd7Smrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
2896ea133fd7Smrg      # Run the actual program with our arguments.
2897ea133fd7Smrg"
2898ea133fd7Smrg	case $host in
2899ea133fd7Smrg	# Backslashes separate directories on plain windows
2900ea133fd7Smrg	*-*-mingw | *-*-os2* | *-cegcc*)
2901ea133fd7Smrg	  $ECHO "\
2902ea133fd7Smrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
2903ea133fd7Smrg"
2904ea133fd7Smrg	  ;;
2905ea133fd7Smrg
2906ea133fd7Smrg	*)
2907ea133fd7Smrg	  $ECHO "\
2908ea133fd7Smrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
2909ea133fd7Smrg"
2910ea133fd7Smrg	  ;;
2911ea133fd7Smrg	esac
2912ea133fd7Smrg	$ECHO "\
2913ea133fd7Smrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
2914ea133fd7Smrg      exit 1
2915ea133fd7Smrg    fi
2916ea133fd7Smrg  else
2917ea133fd7Smrg    # The program doesn't exist.
2918ea133fd7Smrg    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
2919ea133fd7Smrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
2920ea133fd7Smrg    $ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
2921ea133fd7Smrg    exit 1
2922ea133fd7Smrg  fi
2923ea133fd7Smrgfi\
2924ea133fd7Smrg"
2925ea133fd7Smrg}
2926ea133fd7Smrg# end: func_emit_wrapper_part2
2927ea133fd7Smrg
2928ea133fd7Smrg
2929ea133fd7Smrg# func_emit_wrapper [arg=no]
2930ea133fd7Smrg#
2931ea133fd7Smrg# Emit a libtool wrapper script on stdout.
2932ea133fd7Smrg# Don't directly open a file because we may want to
2933ea133fd7Smrg# incorporate the script contents within a cygwin/mingw
2934ea133fd7Smrg# wrapper executable.  Must ONLY be called from within
2935ea133fd7Smrg# func_mode_link because it depends on a number of variables
2936ea133fd7Smrg# set therein.
2937ea133fd7Smrg#
2938ea133fd7Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
2939ea133fd7Smrg# variable will take.  If 'yes', then the emitted script
2940ea133fd7Smrg# will assume that the directory in which it is stored is
2941ea133fd7Smrg# the $objdir directory.  This is a cygwin/mingw-specific
2942ea133fd7Smrg# behavior.
2943ea133fd7Smrgfunc_emit_wrapper ()
2944ea133fd7Smrg{
2945ea133fd7Smrg	func_emit_wrapper_arg1=no
2946ea133fd7Smrg	if test -n "$1" ; then
2947ea133fd7Smrg	  func_emit_wrapper_arg1=$1
2948a253d6aeSmrg	fi
2949a253d6aeSmrg
2950ea133fd7Smrg	# split this up so that func_emit_cwrapperexe_src
2951ea133fd7Smrg	# can call each part independently.
2952ea133fd7Smrg	func_emit_wrapper_part1 "${func_emit_wrapper_arg1}"
2953ea133fd7Smrg	func_emit_wrapper_part2 "${func_emit_wrapper_arg1}"
2954ea133fd7Smrg}
2955a253d6aeSmrg
2956a253d6aeSmrg
2957ea133fd7Smrg# func_to_host_path arg
2958ea133fd7Smrg#
2959ea133fd7Smrg# Convert paths to host format when used with build tools.
2960ea133fd7Smrg# Intended for use with "native" mingw (where libtool itself
2961ea133fd7Smrg# is running under the msys shell), or in the following cross-
2962ea133fd7Smrg# build environments:
2963ea133fd7Smrg#    $build          $host
2964ea133fd7Smrg#    mingw (msys)    mingw  [e.g. native]
2965ea133fd7Smrg#    cygwin          mingw
2966ea133fd7Smrg#    *nix + wine     mingw
2967ea133fd7Smrg# where wine is equipped with the `winepath' executable.
2968ea133fd7Smrg# In the native mingw case, the (msys) shell automatically
2969ea133fd7Smrg# converts paths for any non-msys applications it launches,
2970ea133fd7Smrg# but that facility isn't available from inside the cwrapper.
2971ea133fd7Smrg# Similar accommodations are necessary for $host mingw and
2972ea133fd7Smrg# $build cygwin.  Calling this function does no harm for other
2973ea133fd7Smrg# $host/$build combinations not listed above.
2974ea133fd7Smrg#
2975ea133fd7Smrg# ARG is the path (on $build) that should be converted to
2976ea133fd7Smrg# the proper representation for $host. The result is stored
2977ea133fd7Smrg# in $func_to_host_path_result.
2978ea133fd7Smrgfunc_to_host_path ()
2979ea133fd7Smrg{
2980ea133fd7Smrg  func_to_host_path_result="$1"
2981ea133fd7Smrg  if test -n "$1" ; then
2982ea133fd7Smrg    case $host in
2983ea133fd7Smrg      *mingw* )
2984ea133fd7Smrg        lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
2985ea133fd7Smrg        case $build in
2986ea133fd7Smrg          *mingw* ) # actually, msys
2987ea133fd7Smrg            # awkward: cmd appends spaces to result
2988ea133fd7Smrg            lt_sed_strip_trailing_spaces="s/[ ]*\$//"
2989ea133fd7Smrg            func_to_host_path_tmp1=`( cmd //c echo "$1" |\
2990ea133fd7Smrg              $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""`
2991ea133fd7Smrg            func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
2992ea133fd7Smrg              $SED -e "$lt_sed_naive_backslashify"`
2993ea133fd7Smrg            ;;
2994ea133fd7Smrg          *cygwin* )
2995ea133fd7Smrg            func_to_host_path_tmp1=`cygpath -w "$1"`
2996ea133fd7Smrg            func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
2997ea133fd7Smrg              $SED -e "$lt_sed_naive_backslashify"`
2998ea133fd7Smrg            ;;
2999ea133fd7Smrg          * )
3000ea133fd7Smrg            # Unfortunately, winepath does not exit with a non-zero
3001ea133fd7Smrg            # error code, so we are forced to check the contents of
3002ea133fd7Smrg            # stdout. On the other hand, if the command is not
3003ea133fd7Smrg            # found, the shell will set an exit code of 127 and print
3004ea133fd7Smrg            # *an error message* to stdout. So we must check for both
3005ea133fd7Smrg            # error code of zero AND non-empty stdout, which explains
3006ea133fd7Smrg            # the odd construction:
3007ea133fd7Smrg            func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null`
3008ea133fd7Smrg            if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then
3009ea133fd7Smrg              func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
3010ea133fd7Smrg                $SED -e "$lt_sed_naive_backslashify"`
3011ea133fd7Smrg            else
3012ea133fd7Smrg              # Allow warning below.
3013ea133fd7Smrg              func_to_host_path_result=""
3014ea133fd7Smrg            fi
3015ea133fd7Smrg            ;;
3016ea133fd7Smrg        esac
3017ea133fd7Smrg        if test -z "$func_to_host_path_result" ; then
3018ea133fd7Smrg          func_error "Could not determine host path corresponding to"
3019ea133fd7Smrg          func_error "  '$1'"
3020ea133fd7Smrg          func_error "Continuing, but uninstalled executables may not work."
3021ea133fd7Smrg          # Fallback:
3022ea133fd7Smrg          func_to_host_path_result="$1"
3023ea133fd7Smrg        fi
3024ea133fd7Smrg        ;;
3025ea133fd7Smrg    esac
3026ea133fd7Smrg  fi
3027ea133fd7Smrg}
3028ea133fd7Smrg# end: func_to_host_path
3029a253d6aeSmrg
3030ea133fd7Smrg# func_to_host_pathlist arg
3031ea133fd7Smrg#
3032ea133fd7Smrg# Convert pathlists to host format when used with build tools.
3033ea133fd7Smrg# See func_to_host_path(), above. This function supports the
3034ea133fd7Smrg# following $build/$host combinations (but does no harm for
3035ea133fd7Smrg# combinations not listed here):
3036ea133fd7Smrg#    $build          $host
3037ea133fd7Smrg#    mingw (msys)    mingw  [e.g. native]
3038ea133fd7Smrg#    cygwin          mingw
3039ea133fd7Smrg#    *nix + wine     mingw
3040ea133fd7Smrg#
3041ea133fd7Smrg# Path separators are also converted from $build format to
3042ea133fd7Smrg# $host format. If ARG begins or ends with a path separator
3043ea133fd7Smrg# character, it is preserved (but converted to $host format)
3044ea133fd7Smrg# on output.
3045ea133fd7Smrg#
3046ea133fd7Smrg# ARG is a pathlist (on $build) that should be converted to
3047ea133fd7Smrg# the proper representation on $host. The result is stored
3048ea133fd7Smrg# in $func_to_host_pathlist_result.
3049ea133fd7Smrgfunc_to_host_pathlist ()
3050ea133fd7Smrg{
3051ea133fd7Smrg  func_to_host_pathlist_result="$1"
3052ea133fd7Smrg  if test -n "$1" ; then
3053ea133fd7Smrg    case $host in
3054ea133fd7Smrg      *mingw* )
3055ea133fd7Smrg        lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
3056ea133fd7Smrg        # Remove leading and trailing path separator characters from
3057ea133fd7Smrg        # ARG. msys behavior is inconsistent here, cygpath turns them
3058ea133fd7Smrg        # into '.;' and ';.', and winepath ignores them completely.
3059ea133fd7Smrg        func_to_host_pathlist_tmp2="$1"
3060ea133fd7Smrg        # Once set for this call, this variable should not be
3061ea133fd7Smrg        # reassigned. It is used in tha fallback case.
3062ea133fd7Smrg        func_to_host_pathlist_tmp1=`echo "$func_to_host_pathlist_tmp2" |\
3063ea133fd7Smrg          $SED -e 's|^:*||' -e 's|:*$||'`
3064ea133fd7Smrg        case $build in
3065ea133fd7Smrg          *mingw* ) # Actually, msys.
3066ea133fd7Smrg            # Awkward: cmd appends spaces to result.
3067ea133fd7Smrg            lt_sed_strip_trailing_spaces="s/[ ]*\$//"
3068ea133fd7Smrg            func_to_host_pathlist_tmp2=`( cmd //c echo "$func_to_host_pathlist_tmp1" |\
3069ea133fd7Smrg              $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""`
3070ea133fd7Smrg            func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
3071ea133fd7Smrg              $SED -e "$lt_sed_naive_backslashify"`
3072ea133fd7Smrg            ;;
3073ea133fd7Smrg          *cygwin* )
3074ea133fd7Smrg            func_to_host_pathlist_tmp2=`cygpath -w -p "$func_to_host_pathlist_tmp1"`
3075ea133fd7Smrg            func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
3076ea133fd7Smrg              $SED -e "$lt_sed_naive_backslashify"`
3077ea133fd7Smrg            ;;
3078ea133fd7Smrg          * )
3079ea133fd7Smrg            # unfortunately, winepath doesn't convert pathlists
3080ea133fd7Smrg            func_to_host_pathlist_result=""
3081ea133fd7Smrg            func_to_host_pathlist_oldIFS=$IFS
3082ea133fd7Smrg            IFS=:
3083ea133fd7Smrg            for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do
3084ea133fd7Smrg              IFS=$func_to_host_pathlist_oldIFS
3085ea133fd7Smrg              if test -n "$func_to_host_pathlist_f" ; then
3086ea133fd7Smrg                func_to_host_path "$func_to_host_pathlist_f"
3087ea133fd7Smrg                if test -n "$func_to_host_path_result" ; then
3088ea133fd7Smrg                  if test -z "$func_to_host_pathlist_result" ; then
3089ea133fd7Smrg                    func_to_host_pathlist_result="$func_to_host_path_result"
3090ea133fd7Smrg                  else
3091ea133fd7Smrg                    func_to_host_pathlist_result="$func_to_host_pathlist_result;$func_to_host_path_result"
3092ea133fd7Smrg                  fi
3093ea133fd7Smrg                fi
3094ea133fd7Smrg              fi
3095ea133fd7Smrg              IFS=:
3096ea133fd7Smrg            done
3097ea133fd7Smrg            IFS=$func_to_host_pathlist_oldIFS
3098ea133fd7Smrg            ;;
3099ea133fd7Smrg        esac
3100ea133fd7Smrg        if test -z "$func_to_host_pathlist_result" ; then
3101ea133fd7Smrg          func_error "Could not determine the host path(s) corresponding to"
3102ea133fd7Smrg          func_error "  '$1'"
3103ea133fd7Smrg          func_error "Continuing, but uninstalled executables may not work."
3104ea133fd7Smrg          # Fallback. This may break if $1 contains DOS-style drive
3105ea133fd7Smrg          # specifications. The fix is not to complicate the expression
3106ea133fd7Smrg          # below, but for the user to provide a working wine installation
3107ea133fd7Smrg          # with winepath so that path translation in the cross-to-mingw
3108ea133fd7Smrg          # case works properly.
3109ea133fd7Smrg          lt_replace_pathsep_nix_to_dos="s|:|;|g"
3110ea133fd7Smrg          func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\
3111ea133fd7Smrg            $SED -e "$lt_replace_pathsep_nix_to_dos"`
3112ea133fd7Smrg        fi
3113ea133fd7Smrg        # Now, add the leading and trailing path separators back
3114ea133fd7Smrg        case "$1" in
3115ea133fd7Smrg          :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result"
3116ea133fd7Smrg            ;;
3117ea133fd7Smrg        esac
3118ea133fd7Smrg        case "$1" in
3119ea133fd7Smrg          *: ) func_to_host_pathlist_result="$func_to_host_pathlist_result;"
3120ea133fd7Smrg            ;;
3121ea133fd7Smrg        esac
3122ea133fd7Smrg        ;;
3123ea133fd7Smrg    esac
3124ea133fd7Smrg  fi
3125ea133fd7Smrg}
3126ea133fd7Smrg# end: func_to_host_pathlist
3127a253d6aeSmrg
3128ea133fd7Smrg# func_emit_cwrapperexe_src
3129ea133fd7Smrg# emit the source code for a wrapper executable on stdout
3130ea133fd7Smrg# Must ONLY be called from within func_mode_link because
3131ea133fd7Smrg# it depends on a number of variable set therein.
3132ea133fd7Smrgfunc_emit_cwrapperexe_src ()
3133ea133fd7Smrg{
3134ea133fd7Smrg	cat <<EOF
3135a253d6aeSmrg
3136ea133fd7Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
3137ea133fd7Smrg   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
3138a253d6aeSmrg
3139ea133fd7Smrg   The $output program cannot be directly executed until all the libtool
3140ea133fd7Smrg   libraries that it depends on are installed.
3141a253d6aeSmrg
3142ea133fd7Smrg   This wrapper executable should never be moved out of the build directory.
3143ea133fd7Smrg   If it is, it will not operate correctly.
3144ea133fd7Smrg
3145ea133fd7Smrg   Currently, it simply execs the wrapper *script* "$SHELL $output",
3146ea133fd7Smrg   but could eventually absorb all of the scripts functionality and
3147ea133fd7Smrg   exec $objdir/$outputname directly.
3148ea133fd7Smrg*/
3149ea133fd7SmrgEOF
3150ea133fd7Smrg	    cat <<"EOF"
3151ea133fd7Smrg#include <stdio.h>
3152ea133fd7Smrg#include <stdlib.h>
3153ea133fd7Smrg#ifdef _MSC_VER
3154ea133fd7Smrg# include <direct.h>
3155ea133fd7Smrg# include <process.h>
3156ea133fd7Smrg# include <io.h>
3157ea133fd7Smrg# define setmode _setmode
3158ea133fd7Smrg#else
3159ea133fd7Smrg# include <unistd.h>
3160ea133fd7Smrg# include <stdint.h>
3161ea133fd7Smrg# ifdef __CYGWIN__
3162ea133fd7Smrg#  include <io.h>
3163ea133fd7Smrg#  define HAVE_SETENV
3164ea133fd7Smrg#  ifdef __STRICT_ANSI__
3165ea133fd7Smrgchar *realpath (const char *, char *);
3166ea133fd7Smrgint putenv (char *);
3167ea133fd7Smrgint setenv (const char *, const char *, int);
3168ea133fd7Smrg#  endif
3169ea133fd7Smrg# endif
3170ea133fd7Smrg#endif
3171ea133fd7Smrg#include <malloc.h>
3172ea133fd7Smrg#include <stdarg.h>
3173ea133fd7Smrg#include <assert.h>
3174ea133fd7Smrg#include <string.h>
3175ea133fd7Smrg#include <ctype.h>
3176ea133fd7Smrg#include <errno.h>
3177ea133fd7Smrg#include <fcntl.h>
3178ea133fd7Smrg#include <sys/stat.h>
3179ea133fd7Smrg
3180ea133fd7Smrg#if defined(PATH_MAX)
3181ea133fd7Smrg# define LT_PATHMAX PATH_MAX
3182ea133fd7Smrg#elif defined(MAXPATHLEN)
3183ea133fd7Smrg# define LT_PATHMAX MAXPATHLEN
3184ea133fd7Smrg#else
3185ea133fd7Smrg# define LT_PATHMAX 1024
3186ea133fd7Smrg#endif
3187ea133fd7Smrg
3188ea133fd7Smrg#ifndef S_IXOTH
3189ea133fd7Smrg# define S_IXOTH 0
3190ea133fd7Smrg#endif
3191ea133fd7Smrg#ifndef S_IXGRP
3192ea133fd7Smrg# define S_IXGRP 0
3193ea133fd7Smrg#endif
3194ea133fd7Smrg
3195ea133fd7Smrg#ifdef _MSC_VER
3196ea133fd7Smrg# define S_IXUSR _S_IEXEC
3197ea133fd7Smrg# define stat _stat
3198ea133fd7Smrg# ifndef _INTPTR_T_DEFINED
3199ea133fd7Smrg#  define intptr_t int
3200ea133fd7Smrg# endif
3201ea133fd7Smrg#endif
3202ea133fd7Smrg
3203ea133fd7Smrg#ifndef DIR_SEPARATOR
3204ea133fd7Smrg# define DIR_SEPARATOR '/'
3205ea133fd7Smrg# define PATH_SEPARATOR ':'
3206ea133fd7Smrg#endif
3207ea133fd7Smrg
3208ea133fd7Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
3209ea133fd7Smrg  defined (__OS2__)
3210ea133fd7Smrg# define HAVE_DOS_BASED_FILE_SYSTEM
3211ea133fd7Smrg# define FOPEN_WB "wb"
3212ea133fd7Smrg# ifndef DIR_SEPARATOR_2
3213ea133fd7Smrg#  define DIR_SEPARATOR_2 '\\'
3214ea133fd7Smrg# endif
3215ea133fd7Smrg# ifndef PATH_SEPARATOR_2
3216ea133fd7Smrg#  define PATH_SEPARATOR_2 ';'
3217ea133fd7Smrg# endif
3218ea133fd7Smrg#endif
3219ea133fd7Smrg
3220ea133fd7Smrg#ifndef DIR_SEPARATOR_2
3221ea133fd7Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
3222ea133fd7Smrg#else /* DIR_SEPARATOR_2 */
3223ea133fd7Smrg# define IS_DIR_SEPARATOR(ch) \
3224ea133fd7Smrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
3225ea133fd7Smrg#endif /* DIR_SEPARATOR_2 */
3226ea133fd7Smrg
3227ea133fd7Smrg#ifndef PATH_SEPARATOR_2
3228ea133fd7Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
3229ea133fd7Smrg#else /* PATH_SEPARATOR_2 */
3230ea133fd7Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
3231ea133fd7Smrg#endif /* PATH_SEPARATOR_2 */
3232ea133fd7Smrg
3233ea133fd7Smrg#ifdef __CYGWIN__
3234ea133fd7Smrg# define FOPEN_WB "wb"
3235ea133fd7Smrg#endif
3236ea133fd7Smrg
3237ea133fd7Smrg#ifndef FOPEN_WB
3238ea133fd7Smrg# define FOPEN_WB "w"
3239ea133fd7Smrg#endif
3240ea133fd7Smrg#ifndef _O_BINARY
3241ea133fd7Smrg# define _O_BINARY 0
3242ea133fd7Smrg#endif
3243ea133fd7Smrg
3244ea133fd7Smrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
3245ea133fd7Smrg#define XFREE(stale) do { \
3246ea133fd7Smrg  if (stale) { free ((void *) stale); stale = 0; } \
3247ea133fd7Smrg} while (0)
3248ea133fd7Smrg
3249ea133fd7Smrg#undef LTWRAPPER_DEBUGPRINTF
3250ea133fd7Smrg#if defined DEBUGWRAPPER
3251ea133fd7Smrg# define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args
3252ea133fd7Smrgstatic void
3253ea133fd7Smrgltwrapper_debugprintf (const char *fmt, ...)
3254ea133fd7Smrg{
3255ea133fd7Smrg    va_list args;
3256ea133fd7Smrg    va_start (args, fmt);
3257ea133fd7Smrg    (void) vfprintf (stderr, fmt, args);
3258ea133fd7Smrg    va_end (args);
3259ea133fd7Smrg}
3260ea133fd7Smrg#else
3261ea133fd7Smrg# define LTWRAPPER_DEBUGPRINTF(args)
3262ea133fd7Smrg#endif
3263ea133fd7Smrg
3264ea133fd7Smrgconst char *program_name = NULL;
3265ea133fd7Smrg
3266ea133fd7Smrgvoid *xmalloc (size_t num);
3267ea133fd7Smrgchar *xstrdup (const char *string);
3268ea133fd7Smrgconst char *base_name (const char *name);
3269ea133fd7Smrgchar *find_executable (const char *wrapper);
3270ea133fd7Smrgchar *chase_symlinks (const char *pathspec);
3271ea133fd7Smrgint make_executable (const char *path);
3272ea133fd7Smrgint check_executable (const char *path);
3273ea133fd7Smrgchar *strendzap (char *str, const char *pat);
3274ea133fd7Smrgvoid lt_fatal (const char *message, ...);
3275ea133fd7Smrgvoid lt_setenv (const char *name, const char *value);
3276ea133fd7Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
3277ea133fd7Smrgvoid lt_opt_process_env_set (const char *arg);
3278ea133fd7Smrgvoid lt_opt_process_env_prepend (const char *arg);
3279ea133fd7Smrgvoid lt_opt_process_env_append (const char *arg);
3280ea133fd7Smrgint lt_split_name_value (const char *arg, char** name, char** value);
3281ea133fd7Smrgvoid lt_update_exe_path (const char *name, const char *value);
3282ea133fd7Smrgvoid lt_update_lib_path (const char *name, const char *value);
3283ea133fd7Smrg
3284ea133fd7Smrgstatic const char *script_text_part1 =
3285ea133fd7SmrgEOF
3286ea133fd7Smrg
3287ea133fd7Smrg	    func_emit_wrapper_part1 yes |
3288ea133fd7Smrg	        $SED -e 's/\([\\"]\)/\\\1/g' \
3289ea133fd7Smrg	             -e 's/^/  "/' -e 's/$/\\n"/'
3290ea133fd7Smrg	    echo ";"
3291ea133fd7Smrg	    cat <<EOF
3292ea133fd7Smrg
3293ea133fd7Smrgstatic const char *script_text_part2 =
3294ea133fd7SmrgEOF
3295ea133fd7Smrg	    func_emit_wrapper_part2 yes |
3296ea133fd7Smrg	        $SED -e 's/\([\\"]\)/\\\1/g' \
3297ea133fd7Smrg	             -e 's/^/  "/' -e 's/$/\\n"/'
3298ea133fd7Smrg	    echo ";"
3299ea133fd7Smrg
3300ea133fd7Smrg	    cat <<EOF
3301ea133fd7Smrgconst char * MAGIC_EXE = "$magic_exe";
3302ea133fd7Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
3303ea133fd7SmrgEOF
3304ea133fd7Smrg
3305ea133fd7Smrg	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
3306ea133fd7Smrg              func_to_host_pathlist "$temp_rpath"
3307ea133fd7Smrg	      cat <<EOF
3308ea133fd7Smrgconst char * LIB_PATH_VALUE   = "$func_to_host_pathlist_result";
3309a253d6aeSmrgEOF
3310a253d6aeSmrg	    else
3311ea133fd7Smrg	      cat <<"EOF"
3312ea133fd7Smrgconst char * LIB_PATH_VALUE   = "";
3313ea133fd7SmrgEOF
3314a253d6aeSmrg	    fi
3315ea133fd7Smrg
3316ea133fd7Smrg	    if test -n "$dllsearchpath"; then
3317ea133fd7Smrg              func_to_host_pathlist "$dllsearchpath:"
3318ea133fd7Smrg	      cat <<EOF
3319ea133fd7Smrgconst char * EXE_PATH_VARNAME = "PATH";
3320ea133fd7Smrgconst char * EXE_PATH_VALUE   = "$func_to_host_pathlist_result";
3321ea133fd7SmrgEOF
3322a253d6aeSmrg	    else
3323ea133fd7Smrg	      cat <<"EOF"
3324ea133fd7Smrgconst char * EXE_PATH_VARNAME = "";
3325ea133fd7Smrgconst char * EXE_PATH_VALUE   = "";
3326ea133fd7SmrgEOF
3327a253d6aeSmrg	    fi
3328ea133fd7Smrg
3329ea133fd7Smrg	    if test "$fast_install" = yes; then
3330ea133fd7Smrg	      cat <<EOF
3331ea133fd7Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
3332ea133fd7SmrgEOF
3333a253d6aeSmrg	    else
3334ea133fd7Smrg	      cat <<EOF
3335ea133fd7Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
3336ea133fd7SmrgEOF
3337a253d6aeSmrg	    fi
3338a253d6aeSmrg
3339a253d6aeSmrg
3340ea133fd7Smrg	    cat <<"EOF"
3341a253d6aeSmrg
3342ea133fd7Smrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
3343ea133fd7Smrg#define LTWRAPPER_OPTION_PREFIX_LENGTH  5
3344a253d6aeSmrg
3345ea133fd7Smrgstatic const size_t opt_prefix_len         = LTWRAPPER_OPTION_PREFIX_LENGTH;
3346ea133fd7Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
3347a253d6aeSmrg
3348ea133fd7Smrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
3349a253d6aeSmrg
3350ea133fd7Smrgstatic const size_t env_set_opt_len     = LTWRAPPER_OPTION_PREFIX_LENGTH + 7;
3351ea133fd7Smrgstatic const char *env_set_opt          = LTWRAPPER_OPTION_PREFIX "env-set";
3352ea133fd7Smrg  /* argument is putenv-style "foo=bar", value of foo is set to bar */
3353a253d6aeSmrg
3354ea133fd7Smrgstatic const size_t env_prepend_opt_len = LTWRAPPER_OPTION_PREFIX_LENGTH + 11;
3355ea133fd7Smrgstatic const char *env_prepend_opt      = LTWRAPPER_OPTION_PREFIX "env-prepend";
3356ea133fd7Smrg  /* argument is putenv-style "foo=bar", new value of foo is bar${foo} */
3357a253d6aeSmrg
3358ea133fd7Smrgstatic const size_t env_append_opt_len  = LTWRAPPER_OPTION_PREFIX_LENGTH + 10;
3359ea133fd7Smrgstatic const char *env_append_opt       = LTWRAPPER_OPTION_PREFIX "env-append";
3360ea133fd7Smrg  /* argument is putenv-style "foo=bar", new value of foo is ${foo}bar */
3361a253d6aeSmrg
3362ea133fd7Smrgint
3363ea133fd7Smrgmain (int argc, char *argv[])
3364ea133fd7Smrg{
3365ea133fd7Smrg  char **newargz;
3366ea133fd7Smrg  int  newargc;
3367ea133fd7Smrg  char *tmp_pathspec;
3368ea133fd7Smrg  char *actual_cwrapper_path;
3369ea133fd7Smrg  char *actual_cwrapper_name;
3370ea133fd7Smrg  char *target_name;
3371ea133fd7Smrg  char *lt_argv_zero;
3372ea133fd7Smrg  intptr_t rval = 127;
3373a253d6aeSmrg
3374ea133fd7Smrg  int i;
3375a253d6aeSmrg
3376ea133fd7Smrg  program_name = (char *) xstrdup (base_name (argv[0]));
3377ea133fd7Smrg  LTWRAPPER_DEBUGPRINTF (("(main) argv[0]      : %s\n", argv[0]));
3378ea133fd7Smrg  LTWRAPPER_DEBUGPRINTF (("(main) program_name : %s\n", program_name));
3379a253d6aeSmrg
3380ea133fd7Smrg  /* very simple arg parsing; don't want to rely on getopt */
3381ea133fd7Smrg  for (i = 1; i < argc; i++)
3382ea133fd7Smrg    {
3383ea133fd7Smrg      if (strcmp (argv[i], dumpscript_opt) == 0)
3384ea133fd7Smrg	{
3385ea133fd7SmrgEOF
3386ea133fd7Smrg	    case "$host" in
3387ea133fd7Smrg	      *mingw* | *cygwin* )
3388ea133fd7Smrg		# make stdout use "unix" line endings
3389ea133fd7Smrg		echo "          setmode(1,_O_BINARY);"
3390ea133fd7Smrg		;;
3391ea133fd7Smrg	      esac
3392a253d6aeSmrg
3393ea133fd7Smrg	    cat <<"EOF"
3394ea133fd7Smrg	  printf ("%s", script_text_part1);
3395ea133fd7Smrg	  printf ("%s", script_text_part2);
3396ea133fd7Smrg	  return 0;
3397ea133fd7Smrg	}
3398ea133fd7Smrg    }
3399a253d6aeSmrg
3400ea133fd7Smrg  newargz = XMALLOC (char *, argc + 1);
3401ea133fd7Smrg  tmp_pathspec = find_executable (argv[0]);
3402ea133fd7Smrg  if (tmp_pathspec == NULL)
3403ea133fd7Smrg    lt_fatal ("Couldn't find %s", argv[0]);
3404ea133fd7Smrg  LTWRAPPER_DEBUGPRINTF (("(main) found exe (before symlink chase) at : %s\n",
3405ea133fd7Smrg			  tmp_pathspec));
3406ea133fd7Smrg
3407ea133fd7Smrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
3408ea133fd7Smrg  LTWRAPPER_DEBUGPRINTF (("(main) found exe (after symlink chase) at : %s\n",
3409ea133fd7Smrg			  actual_cwrapper_path));
3410ea133fd7Smrg  XFREE (tmp_pathspec);
3411ea133fd7Smrg
3412ea133fd7Smrg  actual_cwrapper_name = xstrdup( base_name (actual_cwrapper_path));
3413ea133fd7Smrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
3414ea133fd7Smrg
3415ea133fd7Smrg  /* wrapper name transforms */
3416ea133fd7Smrg  strendzap (actual_cwrapper_name, ".exe");
3417ea133fd7Smrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
3418ea133fd7Smrg  XFREE (actual_cwrapper_name);
3419ea133fd7Smrg  actual_cwrapper_name = tmp_pathspec;
3420ea133fd7Smrg  tmp_pathspec = 0;
3421ea133fd7Smrg
3422ea133fd7Smrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
3423ea133fd7Smrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
3424ea133fd7Smrg  strendzap (target_name, ".exe");
3425ea133fd7Smrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
3426ea133fd7Smrg  XFREE (target_name);
3427ea133fd7Smrg  target_name = tmp_pathspec;
3428ea133fd7Smrg  tmp_pathspec = 0;
3429ea133fd7Smrg
3430ea133fd7Smrg  LTWRAPPER_DEBUGPRINTF (("(main) libtool target name: %s\n",
3431ea133fd7Smrg			  target_name));
3432ea133fd7SmrgEOF
3433a253d6aeSmrg
3434ea133fd7Smrg	    cat <<EOF
3435ea133fd7Smrg  newargz[0] =
3436ea133fd7Smrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
3437ea133fd7Smrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
3438ea133fd7Smrg  strcpy (newargz[0], actual_cwrapper_path);
3439ea133fd7Smrg  strcat (newargz[0], "$objdir");
3440ea133fd7Smrg  strcat (newargz[0], "/");
3441ea133fd7SmrgEOF
3442a253d6aeSmrg
3443ea133fd7Smrg	    cat <<"EOF"
3444ea133fd7Smrg  /* stop here, and copy so we don't have to do this twice */
3445ea133fd7Smrg  tmp_pathspec = xstrdup (newargz[0]);
3446a253d6aeSmrg
3447ea133fd7Smrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
3448ea133fd7Smrg  strcat (newargz[0], actual_cwrapper_name);
3449a253d6aeSmrg
3450ea133fd7Smrg  /* DO want the lt- prefix here if it exists, so use target_name */
3451ea133fd7Smrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
3452ea133fd7Smrg  XFREE (tmp_pathspec);
3453ea133fd7Smrg  tmp_pathspec = NULL;
3454ea133fd7SmrgEOF
3455a253d6aeSmrg
3456ea133fd7Smrg	    case $host_os in
3457ea133fd7Smrg	      mingw*)
3458ea133fd7Smrg	    cat <<"EOF"
3459ea133fd7Smrg  {
3460ea133fd7Smrg    char* p;
3461ea133fd7Smrg    while ((p = strchr (newargz[0], '\\')) != NULL)
3462ea133fd7Smrg      {
3463ea133fd7Smrg	*p = '/';
3464ea133fd7Smrg      }
3465ea133fd7Smrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
3466ea133fd7Smrg      {
3467ea133fd7Smrg	*p = '/';
3468ea133fd7Smrg      }
3469ea133fd7Smrg  }
3470ea133fd7SmrgEOF
3471ea133fd7Smrg	    ;;
3472ea133fd7Smrg	    esac
3473a253d6aeSmrg
3474ea133fd7Smrg	    cat <<"EOF"
3475ea133fd7Smrg  XFREE (target_name);
3476ea133fd7Smrg  XFREE (actual_cwrapper_path);
3477ea133fd7Smrg  XFREE (actual_cwrapper_name);
3478a253d6aeSmrg
3479ea133fd7Smrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
3480ea133fd7Smrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
3481ea133fd7Smrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
3482ea133fd7Smrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
3483a253d6aeSmrg
3484ea133fd7Smrg  newargc=0;
3485ea133fd7Smrg  for (i = 1; i < argc; i++)
3486ea133fd7Smrg    {
3487ea133fd7Smrg      if (strncmp (argv[i], env_set_opt, env_set_opt_len) == 0)
3488ea133fd7Smrg        {
3489ea133fd7Smrg          if (argv[i][env_set_opt_len] == '=')
3490ea133fd7Smrg            {
3491ea133fd7Smrg              const char *p = argv[i] + env_set_opt_len + 1;
3492ea133fd7Smrg              lt_opt_process_env_set (p);
3493ea133fd7Smrg            }
3494ea133fd7Smrg          else if (argv[i][env_set_opt_len] == '\0' && i + 1 < argc)
3495ea133fd7Smrg            {
3496ea133fd7Smrg              lt_opt_process_env_set (argv[++i]); /* don't copy */
3497ea133fd7Smrg            }
3498ea133fd7Smrg          else
3499ea133fd7Smrg            lt_fatal ("%s missing required argument", env_set_opt);
3500ea133fd7Smrg          continue;
3501ea133fd7Smrg        }
3502ea133fd7Smrg      if (strncmp (argv[i], env_prepend_opt, env_prepend_opt_len) == 0)
3503ea133fd7Smrg        {
3504ea133fd7Smrg          if (argv[i][env_prepend_opt_len] == '=')
3505ea133fd7Smrg            {
3506ea133fd7Smrg              const char *p = argv[i] + env_prepend_opt_len + 1;
3507ea133fd7Smrg              lt_opt_process_env_prepend (p);
3508ea133fd7Smrg            }
3509ea133fd7Smrg          else if (argv[i][env_prepend_opt_len] == '\0' && i + 1 < argc)
3510ea133fd7Smrg            {
3511ea133fd7Smrg              lt_opt_process_env_prepend (argv[++i]); /* don't copy */
3512ea133fd7Smrg            }
3513ea133fd7Smrg          else
3514ea133fd7Smrg            lt_fatal ("%s missing required argument", env_prepend_opt);
3515ea133fd7Smrg          continue;
3516ea133fd7Smrg        }
3517ea133fd7Smrg      if (strncmp (argv[i], env_append_opt, env_append_opt_len) == 0)
3518ea133fd7Smrg        {
3519ea133fd7Smrg          if (argv[i][env_append_opt_len] == '=')
3520ea133fd7Smrg            {
3521ea133fd7Smrg              const char *p = argv[i] + env_append_opt_len + 1;
3522ea133fd7Smrg              lt_opt_process_env_append (p);
3523ea133fd7Smrg            }
3524ea133fd7Smrg          else if (argv[i][env_append_opt_len] == '\0' && i + 1 < argc)
3525ea133fd7Smrg            {
3526ea133fd7Smrg              lt_opt_process_env_append (argv[++i]); /* don't copy */
3527ea133fd7Smrg            }
3528ea133fd7Smrg          else
3529ea133fd7Smrg            lt_fatal ("%s missing required argument", env_append_opt);
3530ea133fd7Smrg          continue;
3531ea133fd7Smrg        }
3532ea133fd7Smrg      if (strncmp (argv[i], ltwrapper_option_prefix, opt_prefix_len) == 0)
3533ea133fd7Smrg        {
3534ea133fd7Smrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
3535ea133fd7Smrg             namespace, but it is not one of the ones we know about and
3536ea133fd7Smrg             have already dealt with, above (inluding dump-script), then
3537ea133fd7Smrg             report an error. Otherwise, targets might begin to believe
3538ea133fd7Smrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
3539ea133fd7Smrg             namespace. The first time any user complains about this, we'll
3540ea133fd7Smrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
3541ea133fd7Smrg             or a configure.ac-settable value.
3542ea133fd7Smrg           */
3543ea133fd7Smrg          lt_fatal ("Unrecognized option in %s namespace: '%s'",
3544ea133fd7Smrg                    ltwrapper_option_prefix, argv[i]);
3545ea133fd7Smrg        }
3546ea133fd7Smrg      /* otherwise ... */
3547ea133fd7Smrg      newargz[++newargc] = xstrdup (argv[i]);
3548ea133fd7Smrg    }
3549ea133fd7Smrg  newargz[++newargc] = NULL;
3550a253d6aeSmrg
3551ea133fd7Smrg  LTWRAPPER_DEBUGPRINTF     (("(main) lt_argv_zero : %s\n", (lt_argv_zero ? lt_argv_zero : "<NULL>")));
3552ea133fd7Smrg  for (i = 0; i < newargc; i++)
3553ea133fd7Smrg    {
3554ea133fd7Smrg      LTWRAPPER_DEBUGPRINTF (("(main) newargz[%d]   : %s\n", i, (newargz[i] ? newargz[i] : "<NULL>")));
3555ea133fd7Smrg    }
3556a253d6aeSmrg
3557ea133fd7SmrgEOF
3558a253d6aeSmrg
3559ea133fd7Smrg	    case $host_os in
3560ea133fd7Smrg	      mingw*)
3561ea133fd7Smrg		cat <<"EOF"
3562ea133fd7Smrg  /* execv doesn't actually work on mingw as expected on unix */
3563ea133fd7Smrg  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
3564ea133fd7Smrg  if (rval == -1)
3565ea133fd7Smrg    {
3566ea133fd7Smrg      /* failed to start process */
3567ea133fd7Smrg      LTWRAPPER_DEBUGPRINTF (("(main) failed to launch target \"%s\": errno = %d\n", lt_argv_zero, errno));
3568ea133fd7Smrg      return 127;
3569ea133fd7Smrg    }
3570ea133fd7Smrg  return rval;
3571ea133fd7SmrgEOF
3572ea133fd7Smrg		;;
3573ea133fd7Smrg	      *)
3574ea133fd7Smrg		cat <<"EOF"
3575ea133fd7Smrg  execv (lt_argv_zero, newargz);
3576ea133fd7Smrg  return rval; /* =127, but avoids unused variable warning */
3577ea133fd7SmrgEOF
3578ea133fd7Smrg		;;
3579ea133fd7Smrg	    esac
3580a253d6aeSmrg
3581ea133fd7Smrg	    cat <<"EOF"
3582ea133fd7Smrg}
3583a253d6aeSmrg
3584ea133fd7Smrgvoid *
3585ea133fd7Smrgxmalloc (size_t num)
3586ea133fd7Smrg{
3587ea133fd7Smrg  void *p = (void *) malloc (num);
3588ea133fd7Smrg  if (!p)
3589ea133fd7Smrg    lt_fatal ("Memory exhausted");
3590a253d6aeSmrg
3591ea133fd7Smrg  return p;
3592ea133fd7Smrg}
3593a253d6aeSmrg
3594ea133fd7Smrgchar *
3595ea133fd7Smrgxstrdup (const char *string)
3596ea133fd7Smrg{
3597ea133fd7Smrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
3598ea133fd7Smrg			  string) : NULL;
3599ea133fd7Smrg}
3600a253d6aeSmrg
3601ea133fd7Smrgconst char *
3602ea133fd7Smrgbase_name (const char *name)
3603ea133fd7Smrg{
3604ea133fd7Smrg  const char *base;
3605a253d6aeSmrg
3606ea133fd7Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3607ea133fd7Smrg  /* Skip over the disk name in MSDOS pathnames. */
3608ea133fd7Smrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
3609ea133fd7Smrg    name += 2;
3610ea133fd7Smrg#endif
3611a253d6aeSmrg
3612ea133fd7Smrg  for (base = name; *name; name++)
3613ea133fd7Smrg    if (IS_DIR_SEPARATOR (*name))
3614ea133fd7Smrg      base = name + 1;
3615ea133fd7Smrg  return base;
3616ea133fd7Smrg}
3617a253d6aeSmrg
3618ea133fd7Smrgint
3619ea133fd7Smrgcheck_executable (const char *path)
3620ea133fd7Smrg{
3621ea133fd7Smrg  struct stat st;
3622a253d6aeSmrg
3623ea133fd7Smrg  LTWRAPPER_DEBUGPRINTF (("(check_executable)  : %s\n",
3624ea133fd7Smrg			  path ? (*path ? path : "EMPTY!") : "NULL!"));
3625ea133fd7Smrg  if ((!path) || (!*path))
3626ea133fd7Smrg    return 0;
3627a253d6aeSmrg
3628ea133fd7Smrg  if ((stat (path, &st) >= 0)
3629ea133fd7Smrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
3630ea133fd7Smrg    return 1;
3631ea133fd7Smrg  else
3632ea133fd7Smrg    return 0;
3633ea133fd7Smrg}
3634a253d6aeSmrg
3635ea133fd7Smrgint
3636ea133fd7Smrgmake_executable (const char *path)
3637ea133fd7Smrg{
3638ea133fd7Smrg  int rval = 0;
3639ea133fd7Smrg  struct stat st;
3640a253d6aeSmrg
3641ea133fd7Smrg  LTWRAPPER_DEBUGPRINTF (("(make_executable)   : %s\n",
3642ea133fd7Smrg			  path ? (*path ? path : "EMPTY!") : "NULL!"));
3643ea133fd7Smrg  if ((!path) || (!*path))
3644ea133fd7Smrg    return 0;
3645a253d6aeSmrg
3646ea133fd7Smrg  if (stat (path, &st) >= 0)
3647ea133fd7Smrg    {
3648ea133fd7Smrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
3649ea133fd7Smrg    }
3650ea133fd7Smrg  return rval;
3651ea133fd7Smrg}
3652a253d6aeSmrg
3653ea133fd7Smrg/* Searches for the full path of the wrapper.  Returns
3654ea133fd7Smrg   newly allocated full path name if found, NULL otherwise
3655ea133fd7Smrg   Does not chase symlinks, even on platforms that support them.
3656ea133fd7Smrg*/
3657ea133fd7Smrgchar *
3658ea133fd7Smrgfind_executable (const char *wrapper)
3659ea133fd7Smrg{
3660ea133fd7Smrg  int has_slash = 0;
3661ea133fd7Smrg  const char *p;
3662ea133fd7Smrg  const char *p_next;
3663ea133fd7Smrg  /* static buffer for getcwd */
3664ea133fd7Smrg  char tmp[LT_PATHMAX + 1];
3665ea133fd7Smrg  int tmp_len;
3666ea133fd7Smrg  char *concat_name;
3667a253d6aeSmrg
3668ea133fd7Smrg  LTWRAPPER_DEBUGPRINTF (("(find_executable)   : %s\n",
3669ea133fd7Smrg			  wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!"));
3670a253d6aeSmrg
3671ea133fd7Smrg  if ((wrapper == NULL) || (*wrapper == '\0'))
3672ea133fd7Smrg    return NULL;
3673a253d6aeSmrg
3674ea133fd7Smrg  /* Absolute path? */
3675ea133fd7Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3676ea133fd7Smrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
3677ea133fd7Smrg    {
3678ea133fd7Smrg      concat_name = xstrdup (wrapper);
3679ea133fd7Smrg      if (check_executable (concat_name))
3680ea133fd7Smrg	return concat_name;
3681ea133fd7Smrg      XFREE (concat_name);
3682ea133fd7Smrg    }
3683ea133fd7Smrg  else
3684ea133fd7Smrg    {
3685ea133fd7Smrg#endif
3686ea133fd7Smrg      if (IS_DIR_SEPARATOR (wrapper[0]))
3687ea133fd7Smrg	{
3688ea133fd7Smrg	  concat_name = xstrdup (wrapper);
3689ea133fd7Smrg	  if (check_executable (concat_name))
3690ea133fd7Smrg	    return concat_name;
3691ea133fd7Smrg	  XFREE (concat_name);
3692ea133fd7Smrg	}
3693ea133fd7Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3694ea133fd7Smrg    }
3695ea133fd7Smrg#endif
3696a253d6aeSmrg
3697ea133fd7Smrg  for (p = wrapper; *p; p++)
3698ea133fd7Smrg    if (*p == '/')
3699ea133fd7Smrg      {
3700ea133fd7Smrg	has_slash = 1;
3701ea133fd7Smrg	break;
3702ea133fd7Smrg      }
3703ea133fd7Smrg  if (!has_slash)
3704ea133fd7Smrg    {
3705ea133fd7Smrg      /* no slashes; search PATH */
3706ea133fd7Smrg      const char *path = getenv ("PATH");
3707ea133fd7Smrg      if (path != NULL)
3708ea133fd7Smrg	{
3709ea133fd7Smrg	  for (p = path; *p; p = p_next)
3710ea133fd7Smrg	    {
3711ea133fd7Smrg	      const char *q;
3712ea133fd7Smrg	      size_t p_len;
3713ea133fd7Smrg	      for (q = p; *q; q++)
3714ea133fd7Smrg		if (IS_PATH_SEPARATOR (*q))
3715ea133fd7Smrg		  break;
3716ea133fd7Smrg	      p_len = q - p;
3717ea133fd7Smrg	      p_next = (*q == '\0' ? q : q + 1);
3718ea133fd7Smrg	      if (p_len == 0)
3719ea133fd7Smrg		{
3720ea133fd7Smrg		  /* empty path: current directory */
3721ea133fd7Smrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
3722ea133fd7Smrg		    lt_fatal ("getcwd failed");
3723ea133fd7Smrg		  tmp_len = strlen (tmp);
3724ea133fd7Smrg		  concat_name =
3725ea133fd7Smrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
3726ea133fd7Smrg		  memcpy (concat_name, tmp, tmp_len);
3727ea133fd7Smrg		  concat_name[tmp_len] = '/';
3728ea133fd7Smrg		  strcpy (concat_name + tmp_len + 1, wrapper);
3729ea133fd7Smrg		}
3730ea133fd7Smrg	      else
3731ea133fd7Smrg		{
3732ea133fd7Smrg		  concat_name =
3733ea133fd7Smrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
3734ea133fd7Smrg		  memcpy (concat_name, p, p_len);
3735ea133fd7Smrg		  concat_name[p_len] = '/';
3736ea133fd7Smrg		  strcpy (concat_name + p_len + 1, wrapper);
3737ea133fd7Smrg		}
3738ea133fd7Smrg	      if (check_executable (concat_name))
3739ea133fd7Smrg		return concat_name;
3740ea133fd7Smrg	      XFREE (concat_name);
3741ea133fd7Smrg	    }
3742ea133fd7Smrg	}
3743ea133fd7Smrg      /* not found in PATH; assume curdir */
3744ea133fd7Smrg    }
3745ea133fd7Smrg  /* Relative path | not found in path: prepend cwd */
3746ea133fd7Smrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
3747ea133fd7Smrg    lt_fatal ("getcwd failed");
3748ea133fd7Smrg  tmp_len = strlen (tmp);
3749ea133fd7Smrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
3750ea133fd7Smrg  memcpy (concat_name, tmp, tmp_len);
3751ea133fd7Smrg  concat_name[tmp_len] = '/';
3752ea133fd7Smrg  strcpy (concat_name + tmp_len + 1, wrapper);
3753a253d6aeSmrg
3754ea133fd7Smrg  if (check_executable (concat_name))
3755ea133fd7Smrg    return concat_name;
3756ea133fd7Smrg  XFREE (concat_name);
3757ea133fd7Smrg  return NULL;
3758ea133fd7Smrg}
3759a253d6aeSmrg
3760ea133fd7Smrgchar *
3761ea133fd7Smrgchase_symlinks (const char *pathspec)
3762ea133fd7Smrg{
3763ea133fd7Smrg#ifndef S_ISLNK
3764ea133fd7Smrg  return xstrdup (pathspec);
3765ea133fd7Smrg#else
3766ea133fd7Smrg  char buf[LT_PATHMAX];
3767ea133fd7Smrg  struct stat s;
3768ea133fd7Smrg  char *tmp_pathspec = xstrdup (pathspec);
3769ea133fd7Smrg  char *p;
3770ea133fd7Smrg  int has_symlinks = 0;
3771ea133fd7Smrg  while (strlen (tmp_pathspec) && !has_symlinks)
3772ea133fd7Smrg    {
3773ea133fd7Smrg      LTWRAPPER_DEBUGPRINTF (("checking path component for symlinks: %s\n",
3774ea133fd7Smrg			      tmp_pathspec));
3775ea133fd7Smrg      if (lstat (tmp_pathspec, &s) == 0)
3776ea133fd7Smrg	{
3777ea133fd7Smrg	  if (S_ISLNK (s.st_mode) != 0)
3778ea133fd7Smrg	    {
3779ea133fd7Smrg	      has_symlinks = 1;
3780ea133fd7Smrg	      break;
3781ea133fd7Smrg	    }
3782a253d6aeSmrg
3783ea133fd7Smrg	  /* search backwards for last DIR_SEPARATOR */
3784ea133fd7Smrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
3785ea133fd7Smrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
3786ea133fd7Smrg	    p--;
3787ea133fd7Smrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
3788ea133fd7Smrg	    {
3789ea133fd7Smrg	      /* no more DIR_SEPARATORS left */
3790ea133fd7Smrg	      break;
3791ea133fd7Smrg	    }
3792ea133fd7Smrg	  *p = '\0';
3793ea133fd7Smrg	}
3794ea133fd7Smrg      else
3795ea133fd7Smrg	{
3796ea133fd7Smrg	  char *errstr = strerror (errno);
3797ea133fd7Smrg	  lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr);
3798ea133fd7Smrg	}
3799ea133fd7Smrg    }
3800ea133fd7Smrg  XFREE (tmp_pathspec);
3801a253d6aeSmrg
3802ea133fd7Smrg  if (!has_symlinks)
3803ea133fd7Smrg    {
3804ea133fd7Smrg      return xstrdup (pathspec);
3805ea133fd7Smrg    }
3806a253d6aeSmrg
3807ea133fd7Smrg  tmp_pathspec = realpath (pathspec, buf);
3808ea133fd7Smrg  if (tmp_pathspec == 0)
3809ea133fd7Smrg    {
3810ea133fd7Smrg      lt_fatal ("Could not follow symlinks for %s", pathspec);
3811ea133fd7Smrg    }
3812ea133fd7Smrg  return xstrdup (tmp_pathspec);
3813ea133fd7Smrg#endif
3814ea133fd7Smrg}
3815a253d6aeSmrg
3816ea133fd7Smrgchar *
3817ea133fd7Smrgstrendzap (char *str, const char *pat)
3818ea133fd7Smrg{
3819ea133fd7Smrg  size_t len, patlen;
3820a253d6aeSmrg
3821ea133fd7Smrg  assert (str != NULL);
3822ea133fd7Smrg  assert (pat != NULL);
3823a253d6aeSmrg
3824ea133fd7Smrg  len = strlen (str);
3825ea133fd7Smrg  patlen = strlen (pat);
3826a253d6aeSmrg
3827ea133fd7Smrg  if (patlen <= len)
3828ea133fd7Smrg    {
3829ea133fd7Smrg      str += len - patlen;
3830ea133fd7Smrg      if (strcmp (str, pat) == 0)
3831ea133fd7Smrg	*str = '\0';
3832ea133fd7Smrg    }
3833ea133fd7Smrg  return str;
3834ea133fd7Smrg}
3835a253d6aeSmrg
3836ea133fd7Smrgstatic void
3837ea133fd7Smrglt_error_core (int exit_status, const char *mode,
3838ea133fd7Smrg	       const char *message, va_list ap)
3839ea133fd7Smrg{
3840ea133fd7Smrg  fprintf (stderr, "%s: %s: ", program_name, mode);
3841ea133fd7Smrg  vfprintf (stderr, message, ap);
3842ea133fd7Smrg  fprintf (stderr, ".\n");
3843a253d6aeSmrg
3844ea133fd7Smrg  if (exit_status >= 0)
3845ea133fd7Smrg    exit (exit_status);
3846ea133fd7Smrg}
3847a253d6aeSmrg
3848ea133fd7Smrgvoid
3849ea133fd7Smrglt_fatal (const char *message, ...)
3850ea133fd7Smrg{
3851ea133fd7Smrg  va_list ap;
3852ea133fd7Smrg  va_start (ap, message);
3853ea133fd7Smrg  lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
3854ea133fd7Smrg  va_end (ap);
3855ea133fd7Smrg}
3856a253d6aeSmrg
3857ea133fd7Smrgvoid
3858ea133fd7Smrglt_setenv (const char *name, const char *value)
3859ea133fd7Smrg{
3860ea133fd7Smrg  LTWRAPPER_DEBUGPRINTF (("(lt_setenv) setting '%s' to '%s'\n",
3861ea133fd7Smrg                          (name ? name : "<NULL>"),
3862ea133fd7Smrg                          (value ? value : "<NULL>")));
3863ea133fd7Smrg  {
3864ea133fd7Smrg#ifdef HAVE_SETENV
3865ea133fd7Smrg    /* always make a copy, for consistency with !HAVE_SETENV */
3866ea133fd7Smrg    char *str = xstrdup (value);
3867ea133fd7Smrg    setenv (name, str, 1);
3868ea133fd7Smrg#else
3869ea133fd7Smrg    int len = strlen (name) + 1 + strlen (value) + 1;
3870ea133fd7Smrg    char *str = XMALLOC (char, len);
3871ea133fd7Smrg    sprintf (str, "%s=%s", name, value);
3872ea133fd7Smrg    if (putenv (str) != EXIT_SUCCESS)
3873ea133fd7Smrg      {
3874ea133fd7Smrg        XFREE (str);
3875ea133fd7Smrg      }
3876ea133fd7Smrg#endif
3877ea133fd7Smrg  }
3878ea133fd7Smrg}
3879a253d6aeSmrg
3880ea133fd7Smrgchar *
3881ea133fd7Smrglt_extend_str (const char *orig_value, const char *add, int to_end)
3882ea133fd7Smrg{
3883ea133fd7Smrg  char *new_value;
3884ea133fd7Smrg  if (orig_value && *orig_value)
3885ea133fd7Smrg    {
3886ea133fd7Smrg      int orig_value_len = strlen (orig_value);
3887ea133fd7Smrg      int add_len = strlen (add);
3888ea133fd7Smrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
3889ea133fd7Smrg      if (to_end)
3890ea133fd7Smrg        {
3891ea133fd7Smrg          strcpy (new_value, orig_value);
3892ea133fd7Smrg          strcpy (new_value + orig_value_len, add);
3893ea133fd7Smrg        }
3894ea133fd7Smrg      else
3895ea133fd7Smrg        {
3896ea133fd7Smrg          strcpy (new_value, add);
3897ea133fd7Smrg          strcpy (new_value + add_len, orig_value);
3898ea133fd7Smrg        }
3899ea133fd7Smrg    }
3900ea133fd7Smrg  else
3901ea133fd7Smrg    {
3902ea133fd7Smrg      new_value = xstrdup (add);
3903ea133fd7Smrg    }
3904ea133fd7Smrg  return new_value;
3905ea133fd7Smrg}
3906a253d6aeSmrg
3907ea133fd7Smrgint
3908ea133fd7Smrglt_split_name_value (const char *arg, char** name, char** value)
3909ea133fd7Smrg{
3910ea133fd7Smrg  const char *p;
3911ea133fd7Smrg  int len;
3912ea133fd7Smrg  if (!arg || !*arg)
3913ea133fd7Smrg    return 1;
3914a253d6aeSmrg
3915ea133fd7Smrg  p = strchr (arg, (int)'=');
3916a253d6aeSmrg
3917ea133fd7Smrg  if (!p)
3918ea133fd7Smrg    return 1;
3919a253d6aeSmrg
3920ea133fd7Smrg  *value = xstrdup (++p);
3921a253d6aeSmrg
3922ea133fd7Smrg  len = strlen (arg) - strlen (*value);
3923ea133fd7Smrg  *name = XMALLOC (char, len);
3924ea133fd7Smrg  strncpy (*name, arg, len-1);
3925ea133fd7Smrg  (*name)[len - 1] = '\0';
3926a253d6aeSmrg
3927ea133fd7Smrg  return 0;
3928ea133fd7Smrg}
3929a253d6aeSmrg
3930ea133fd7Smrgvoid
3931ea133fd7Smrglt_opt_process_env_set (const char *arg)
3932ea133fd7Smrg{
3933ea133fd7Smrg  char *name = NULL;
3934ea133fd7Smrg  char *value = NULL;
3935a253d6aeSmrg
3936ea133fd7Smrg  if (lt_split_name_value (arg, &name, &value) != 0)
3937ea133fd7Smrg    {
3938ea133fd7Smrg      XFREE (name);
3939ea133fd7Smrg      XFREE (value);
3940ea133fd7Smrg      lt_fatal ("bad argument for %s: '%s'", env_set_opt, arg);
3941ea133fd7Smrg    }
3942a253d6aeSmrg
3943ea133fd7Smrg  lt_setenv (name, value);
3944ea133fd7Smrg  XFREE (name);
3945ea133fd7Smrg  XFREE (value);
3946ea133fd7Smrg}
3947a253d6aeSmrg
3948ea133fd7Smrgvoid
3949ea133fd7Smrglt_opt_process_env_prepend (const char *arg)
3950ea133fd7Smrg{
3951ea133fd7Smrg  char *name = NULL;
3952ea133fd7Smrg  char *value = NULL;
3953ea133fd7Smrg  char *new_value = NULL;
3954a253d6aeSmrg
3955ea133fd7Smrg  if (lt_split_name_value (arg, &name, &value) != 0)
3956ea133fd7Smrg    {
3957ea133fd7Smrg      XFREE (name);
3958ea133fd7Smrg      XFREE (value);
3959ea133fd7Smrg      lt_fatal ("bad argument for %s: '%s'", env_prepend_opt, arg);
3960ea133fd7Smrg    }
3961a253d6aeSmrg
3962ea133fd7Smrg  new_value = lt_extend_str (getenv (name), value, 0);
3963ea133fd7Smrg  lt_setenv (name, new_value);
3964ea133fd7Smrg  XFREE (new_value);
3965ea133fd7Smrg  XFREE (name);
3966ea133fd7Smrg  XFREE (value);
3967ea133fd7Smrg}
3968a253d6aeSmrg
3969ea133fd7Smrgvoid
3970ea133fd7Smrglt_opt_process_env_append (const char *arg)
3971ea133fd7Smrg{
3972ea133fd7Smrg  char *name = NULL;
3973ea133fd7Smrg  char *value = NULL;
3974ea133fd7Smrg  char *new_value = NULL;
3975a253d6aeSmrg
3976ea133fd7Smrg  if (lt_split_name_value (arg, &name, &value) != 0)
3977ea133fd7Smrg    {
3978ea133fd7Smrg      XFREE (name);
3979ea133fd7Smrg      XFREE (value);
3980ea133fd7Smrg      lt_fatal ("bad argument for %s: '%s'", env_append_opt, arg);
3981ea133fd7Smrg    }
3982a253d6aeSmrg
3983ea133fd7Smrg  new_value = lt_extend_str (getenv (name), value, 1);
3984ea133fd7Smrg  lt_setenv (name, new_value);
3985ea133fd7Smrg  XFREE (new_value);
3986ea133fd7Smrg  XFREE (name);
3987ea133fd7Smrg  XFREE (value);
3988ea133fd7Smrg}
3989a253d6aeSmrg
3990ea133fd7Smrgvoid
3991ea133fd7Smrglt_update_exe_path (const char *name, const char *value)
3992ea133fd7Smrg{
3993ea133fd7Smrg  LTWRAPPER_DEBUGPRINTF (("(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
3994ea133fd7Smrg                          (name ? name : "<NULL>"),
3995ea133fd7Smrg                          (value ? value : "<NULL>")));
3996a253d6aeSmrg
3997ea133fd7Smrg  if (name && *name && value && *value)
3998ea133fd7Smrg    {
3999ea133fd7Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
4000ea133fd7Smrg      /* some systems can't cope with a ':'-terminated path #' */
4001ea133fd7Smrg      int len = strlen (new_value);
4002ea133fd7Smrg      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
4003ea133fd7Smrg        {
4004ea133fd7Smrg          new_value[len-1] = '\0';
4005ea133fd7Smrg        }
4006ea133fd7Smrg      lt_setenv (name, new_value);
4007ea133fd7Smrg      XFREE (new_value);
4008ea133fd7Smrg    }
4009ea133fd7Smrg}
4010a253d6aeSmrg
4011ea133fd7Smrgvoid
4012ea133fd7Smrglt_update_lib_path (const char *name, const char *value)
4013ea133fd7Smrg{
4014ea133fd7Smrg  LTWRAPPER_DEBUGPRINTF (("(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
4015ea133fd7Smrg                          (name ? name : "<NULL>"),
4016ea133fd7Smrg                          (value ? value : "<NULL>")));
4017a253d6aeSmrg
4018ea133fd7Smrg  if (name && *name && value && *value)
4019ea133fd7Smrg    {
4020ea133fd7Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
4021ea133fd7Smrg      lt_setenv (name, new_value);
4022ea133fd7Smrg      XFREE (new_value);
4023ea133fd7Smrg    }
4024ea133fd7Smrg}
4025a253d6aeSmrg
4026a253d6aeSmrg
4027ea133fd7SmrgEOF
4028ea133fd7Smrg}
4029ea133fd7Smrg# end: func_emit_cwrapperexe_src
4030a253d6aeSmrg
4031ea133fd7Smrg# func_mode_link arg...
4032ea133fd7Smrgfunc_mode_link ()
4033ea133fd7Smrg{
4034ea133fd7Smrg    $opt_debug
4035ea133fd7Smrg    case $host in
4036ea133fd7Smrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
4037ea133fd7Smrg      # It is impossible to link a dll without this setting, and
4038ea133fd7Smrg      # we shouldn't force the makefile maintainer to figure out
4039ea133fd7Smrg      # which system we are compiling for in order to pass an extra
4040ea133fd7Smrg      # flag for every libtool invocation.
4041ea133fd7Smrg      # allow_undefined=no
4042a253d6aeSmrg
4043ea133fd7Smrg      # FIXME: Unfortunately, there are problems with the above when trying
4044ea133fd7Smrg      # to make a dll which has undefined symbols, in which case not
4045ea133fd7Smrg      # even a static library is built.  For now, we need to specify
4046ea133fd7Smrg      # -no-undefined on the libtool link line when we can be certain
4047ea133fd7Smrg      # that all symbols are satisfied, otherwise we get a static library.
4048ea133fd7Smrg      allow_undefined=yes
4049ea133fd7Smrg      ;;
4050ea133fd7Smrg    *)
4051ea133fd7Smrg      allow_undefined=yes
4052ea133fd7Smrg      ;;
4053ea133fd7Smrg    esac
4054ea133fd7Smrg    libtool_args=$nonopt
4055ea133fd7Smrg    base_compile="$nonopt $@"
4056ea133fd7Smrg    compile_command=$nonopt
4057ea133fd7Smrg    finalize_command=$nonopt
4058a253d6aeSmrg
4059ea133fd7Smrg    compile_rpath=
4060ea133fd7Smrg    finalize_rpath=
4061ea133fd7Smrg    compile_shlibpath=
4062ea133fd7Smrg    finalize_shlibpath=
4063ea133fd7Smrg    convenience=
4064ea133fd7Smrg    old_convenience=
4065ea133fd7Smrg    deplibs=
4066ea133fd7Smrg    old_deplibs=
4067ea133fd7Smrg    compiler_flags=
4068ea133fd7Smrg    linker_flags=
4069ea133fd7Smrg    dllsearchpath=
4070ea133fd7Smrg    lib_search_path=`pwd`
4071ea133fd7Smrg    inst_prefix_dir=
4072ea133fd7Smrg    new_inherited_linker_flags=
4073a253d6aeSmrg
4074ea133fd7Smrg    avoid_version=no
4075ea133fd7Smrg    dlfiles=
4076ea133fd7Smrg    dlprefiles=
4077ea133fd7Smrg    dlself=no
4078ea133fd7Smrg    export_dynamic=no
4079ea133fd7Smrg    export_symbols=
4080ea133fd7Smrg    export_symbols_regex=
4081ea133fd7Smrg    generated=
4082ea133fd7Smrg    libobjs=
4083ea133fd7Smrg    ltlibs=
4084ea133fd7Smrg    module=no
4085ea133fd7Smrg    no_install=no
4086ea133fd7Smrg    objs=
4087ea133fd7Smrg    non_pic_objects=
4088ea133fd7Smrg    precious_files_regex=
4089ea133fd7Smrg    prefer_static_libs=no
4090ea133fd7Smrg    preload=no
4091ea133fd7Smrg    prev=
4092ea133fd7Smrg    prevarg=
4093ea133fd7Smrg    release=
4094ea133fd7Smrg    rpath=
4095ea133fd7Smrg    xrpath=
4096ea133fd7Smrg    perm_rpath=
4097ea133fd7Smrg    temp_rpath=
4098ea133fd7Smrg    thread_safe=no
4099ea133fd7Smrg    vinfo=
4100ea133fd7Smrg    vinfo_number=no
4101ea133fd7Smrg    weak_libs=
4102ea133fd7Smrg    single_module="${wl}-single_module"
4103ea133fd7Smrg    func_infer_tag $base_compile
4104a253d6aeSmrg
4105ea133fd7Smrg    # We need to know -static, to get the right output filenames.
4106ea133fd7Smrg    for arg
4107ea133fd7Smrg    do
4108ea133fd7Smrg      case $arg in
4109ea133fd7Smrg      -shared)
4110ea133fd7Smrg	test "$build_libtool_libs" != yes && \
4111ea133fd7Smrg	  func_fatal_configuration "can not build a shared library"
4112ea133fd7Smrg	build_old_libs=no
4113ea133fd7Smrg	break
4114ea133fd7Smrg	;;
4115ea133fd7Smrg      -all-static | -static | -static-libtool-libs)
4116ea133fd7Smrg	case $arg in
4117ea133fd7Smrg	-all-static)
4118ea133fd7Smrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
4119ea133fd7Smrg	    func_warning "complete static linking is impossible in this configuration"
4120a253d6aeSmrg	  fi
4121ea133fd7Smrg	  if test -n "$link_static_flag"; then
4122ea133fd7Smrg	    dlopen_self=$dlopen_self_static
4123a253d6aeSmrg	  fi
4124ea133fd7Smrg	  prefer_static_libs=yes
4125a253d6aeSmrg	  ;;
4126ea133fd7Smrg	-static)
4127ea133fd7Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
4128ea133fd7Smrg	    dlopen_self=$dlopen_self_static
4129ea133fd7Smrg	  fi
4130ea133fd7Smrg	  prefer_static_libs=built
4131ea133fd7Smrg	  ;;
4132ea133fd7Smrg	-static-libtool-libs)
4133ea133fd7Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
4134ea133fd7Smrg	    dlopen_self=$dlopen_self_static
4135ea133fd7Smrg	  fi
4136ea133fd7Smrg	  prefer_static_libs=yes
4137a253d6aeSmrg	  ;;
4138a253d6aeSmrg	esac
4139ea133fd7Smrg	build_libtool_libs=no
4140ea133fd7Smrg	build_old_libs=yes
4141ea133fd7Smrg	break
4142ea133fd7Smrg	;;
4143ea133fd7Smrg      esac
4144ea133fd7Smrg    done
4145a253d6aeSmrg
4146ea133fd7Smrg    # See if our shared archives depend on static archives.
4147ea133fd7Smrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
4148a253d6aeSmrg
4149ea133fd7Smrg    # Go through the arguments, transforming them on the way.
4150ea133fd7Smrg    while test "$#" -gt 0; do
4151ea133fd7Smrg      arg="$1"
4152ea133fd7Smrg      shift
4153ea133fd7Smrg      func_quote_for_eval "$arg"
4154ea133fd7Smrg      qarg=$func_quote_for_eval_unquoted_result
4155ea133fd7Smrg      func_append libtool_args " $func_quote_for_eval_result"
4156a253d6aeSmrg
4157ea133fd7Smrg      # If the previous option needs an argument, assign it.
4158ea133fd7Smrg      if test -n "$prev"; then
4159ea133fd7Smrg	case $prev in
4160ea133fd7Smrg	output)
4161ea133fd7Smrg	  func_append compile_command " @OUTPUT@"
4162ea133fd7Smrg	  func_append finalize_command " @OUTPUT@"
4163ea133fd7Smrg	  ;;
4164ea133fd7Smrg	esac
4165a253d6aeSmrg
4166ea133fd7Smrg	case $prev in
4167ea133fd7Smrg	dlfiles|dlprefiles)
4168ea133fd7Smrg	  if test "$preload" = no; then
4169ea133fd7Smrg	    # Add the symbol object into the linking commands.
4170ea133fd7Smrg	    func_append compile_command " @SYMFILE@"
4171ea133fd7Smrg	    func_append finalize_command " @SYMFILE@"
4172ea133fd7Smrg	    preload=yes
4173ea133fd7Smrg	  fi
4174ea133fd7Smrg	  case $arg in
4175ea133fd7Smrg	  *.la | *.lo) ;;  # We handle these cases below.
4176ea133fd7Smrg	  force)
4177ea133fd7Smrg	    if test "$dlself" = no; then
4178ea133fd7Smrg	      dlself=needless
4179ea133fd7Smrg	      export_dynamic=yes
4180ea133fd7Smrg	    fi
4181ea133fd7Smrg	    prev=
4182ea133fd7Smrg	    continue
4183ea133fd7Smrg	    ;;
4184ea133fd7Smrg	  self)
4185ea133fd7Smrg	    if test "$prev" = dlprefiles; then
4186ea133fd7Smrg	      dlself=yes
4187ea133fd7Smrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
4188ea133fd7Smrg	      dlself=yes
4189ea133fd7Smrg	    else
4190ea133fd7Smrg	      dlself=needless
4191ea133fd7Smrg	      export_dynamic=yes
4192ea133fd7Smrg	    fi
4193ea133fd7Smrg	    prev=
4194ea133fd7Smrg	    continue
4195a253d6aeSmrg	    ;;
4196a253d6aeSmrg	  *)
4197ea133fd7Smrg	    if test "$prev" = dlfiles; then
4198ea133fd7Smrg	      dlfiles="$dlfiles $arg"
4199ea133fd7Smrg	    else
4200ea133fd7Smrg	      dlprefiles="$dlprefiles $arg"
4201ea133fd7Smrg	    fi
4202ea133fd7Smrg	    prev=
4203ea133fd7Smrg	    continue
4204a253d6aeSmrg	    ;;
4205a253d6aeSmrg	  esac
4206ea133fd7Smrg	  ;;
4207ea133fd7Smrg	expsyms)
4208ea133fd7Smrg	  export_symbols="$arg"
4209ea133fd7Smrg	  test -f "$arg" \
4210ea133fd7Smrg	    || func_fatal_error "symbol file \`$arg' does not exist"
4211ea133fd7Smrg	  prev=
4212ea133fd7Smrg	  continue
4213ea133fd7Smrg	  ;;
4214ea133fd7Smrg	expsyms_regex)
4215ea133fd7Smrg	  export_symbols_regex="$arg"
4216ea133fd7Smrg	  prev=
4217ea133fd7Smrg	  continue
4218ea133fd7Smrg	  ;;
4219ea133fd7Smrg	framework)
4220ea133fd7Smrg	  case $host in
4221ea133fd7Smrg	    *-*-darwin*)
4222ea133fd7Smrg	      case "$deplibs " in
4223ea133fd7Smrg		*" $qarg.ltframework "*) ;;
4224ea133fd7Smrg		*) deplibs="$deplibs $qarg.ltframework" # this is fixed later
4225ea133fd7Smrg		   ;;
4226ea133fd7Smrg	      esac
4227ea133fd7Smrg	      ;;
4228ea133fd7Smrg	  esac
4229ea133fd7Smrg	  prev=
4230ea133fd7Smrg	  continue
4231ea133fd7Smrg	  ;;
4232ea133fd7Smrg	inst_prefix)
4233ea133fd7Smrg	  inst_prefix_dir="$arg"
4234ea133fd7Smrg	  prev=
4235ea133fd7Smrg	  continue
4236ea133fd7Smrg	  ;;
4237ea133fd7Smrg	objectlist)
4238ea133fd7Smrg	  if test -f "$arg"; then
4239ea133fd7Smrg	    save_arg=$arg
4240ea133fd7Smrg	    moreargs=
4241ea133fd7Smrg	    for fil in `cat "$save_arg"`
4242ea133fd7Smrg	    do
4243ea133fd7Smrg#	      moreargs="$moreargs $fil"
4244ea133fd7Smrg	      arg=$fil
4245ea133fd7Smrg	      # A libtool-controlled object.
4246a253d6aeSmrg
4247ea133fd7Smrg	      # Check to see that this really is a libtool object.
4248ea133fd7Smrg	      if func_lalib_unsafe_p "$arg"; then
4249ea133fd7Smrg		pic_object=
4250ea133fd7Smrg		non_pic_object=
4251a253d6aeSmrg
4252ea133fd7Smrg		# Read the .lo file
4253ea133fd7Smrg		func_source "$arg"
4254a253d6aeSmrg
4255ea133fd7Smrg		if test -z "$pic_object" ||
4256ea133fd7Smrg		   test -z "$non_pic_object" ||
4257ea133fd7Smrg		   test "$pic_object" = none &&
4258ea133fd7Smrg		   test "$non_pic_object" = none; then
4259ea133fd7Smrg		  func_fatal_error "cannot find name of object for \`$arg'"
4260ea133fd7Smrg		fi
4261a253d6aeSmrg
4262ea133fd7Smrg		# Extract subdirectory from the argument.
4263ea133fd7Smrg		func_dirname "$arg" "/" ""
4264ea133fd7Smrg		xdir="$func_dirname_result"
4265a253d6aeSmrg
4266ea133fd7Smrg		if test "$pic_object" != none; then
4267ea133fd7Smrg		  # Prepend the subdirectory the object is found in.
4268ea133fd7Smrg		  pic_object="$xdir$pic_object"
4269a253d6aeSmrg
4270ea133fd7Smrg		  if test "$prev" = dlfiles; then
4271ea133fd7Smrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
4272ea133fd7Smrg		      dlfiles="$dlfiles $pic_object"
4273ea133fd7Smrg		      prev=
4274ea133fd7Smrg		      continue
4275ea133fd7Smrg		    else
4276ea133fd7Smrg		      # If libtool objects are unsupported, then we need to preload.
4277ea133fd7Smrg		      prev=dlprefiles
4278ea133fd7Smrg		    fi
4279ea133fd7Smrg		  fi
4280a253d6aeSmrg
4281ea133fd7Smrg		  # CHECK ME:  I think I busted this.  -Ossama
4282ea133fd7Smrg		  if test "$prev" = dlprefiles; then
4283ea133fd7Smrg		    # Preload the old-style object.
4284ea133fd7Smrg		    dlprefiles="$dlprefiles $pic_object"
4285ea133fd7Smrg		    prev=
4286ea133fd7Smrg		  fi
4287a253d6aeSmrg
4288ea133fd7Smrg		  # A PIC object.
4289ea133fd7Smrg		  func_append libobjs " $pic_object"
4290ea133fd7Smrg		  arg="$pic_object"
4291ea133fd7Smrg		fi
4292a253d6aeSmrg
4293ea133fd7Smrg		# Non-PIC object.
4294ea133fd7Smrg		if test "$non_pic_object" != none; then
4295ea133fd7Smrg		  # Prepend the subdirectory the object is found in.
4296ea133fd7Smrg		  non_pic_object="$xdir$non_pic_object"
4297a253d6aeSmrg
4298ea133fd7Smrg		  # A standard non-PIC object
4299ea133fd7Smrg		  func_append non_pic_objects " $non_pic_object"
4300ea133fd7Smrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
4301ea133fd7Smrg		    arg="$non_pic_object"
4302ea133fd7Smrg		  fi
4303ea133fd7Smrg		else
4304ea133fd7Smrg		  # If the PIC object exists, use it instead.
4305ea133fd7Smrg		  # $xdir was prepended to $pic_object above.
4306ea133fd7Smrg		  non_pic_object="$pic_object"
4307ea133fd7Smrg		  func_append non_pic_objects " $non_pic_object"
4308ea133fd7Smrg		fi
4309ea133fd7Smrg	      else
4310ea133fd7Smrg		# Only an error if not doing a dry-run.
4311ea133fd7Smrg		if $opt_dry_run; then
4312ea133fd7Smrg		  # Extract subdirectory from the argument.
4313ea133fd7Smrg		  func_dirname "$arg" "/" ""
4314ea133fd7Smrg		  xdir="$func_dirname_result"
4315ea133fd7Smrg
4316ea133fd7Smrg		  func_lo2o "$arg"
4317ea133fd7Smrg		  pic_object=$xdir$objdir/$func_lo2o_result
4318ea133fd7Smrg		  non_pic_object=$xdir$func_lo2o_result
4319ea133fd7Smrg		  func_append libobjs " $pic_object"
4320ea133fd7Smrg		  func_append non_pic_objects " $non_pic_object"
4321ea133fd7Smrg	        else
4322ea133fd7Smrg		  func_fatal_error "\`$arg' is not a valid libtool object"
4323ea133fd7Smrg		fi
4324ea133fd7Smrg	      fi
4325ea133fd7Smrg	    done
4326ea133fd7Smrg	  else
4327ea133fd7Smrg	    func_fatal_error "link input file \`$arg' does not exist"
4328ea133fd7Smrg	  fi
4329ea133fd7Smrg	  arg=$save_arg
4330ea133fd7Smrg	  prev=
4331ea133fd7Smrg	  continue
4332ea133fd7Smrg	  ;;
4333ea133fd7Smrg	precious_regex)
4334ea133fd7Smrg	  precious_files_regex="$arg"
4335ea133fd7Smrg	  prev=
4336ea133fd7Smrg	  continue
4337ea133fd7Smrg	  ;;
4338ea133fd7Smrg	release)
4339ea133fd7Smrg	  release="-$arg"
4340ea133fd7Smrg	  prev=
4341ea133fd7Smrg	  continue
4342ea133fd7Smrg	  ;;
4343ea133fd7Smrg	rpath | xrpath)
4344ea133fd7Smrg	  # We need an absolute path.
4345ea133fd7Smrg	  case $arg in
4346ea133fd7Smrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
4347ea133fd7Smrg	  *)
4348ea133fd7Smrg	    func_fatal_error "only absolute run-paths are allowed"
4349ea133fd7Smrg	    ;;
4350ea133fd7Smrg	  esac
4351ea133fd7Smrg	  if test "$prev" = rpath; then
4352ea133fd7Smrg	    case "$rpath " in
4353ea133fd7Smrg	    *" $arg "*) ;;
4354ea133fd7Smrg	    *) rpath="$rpath $arg" ;;
4355ea133fd7Smrg	    esac
4356ea133fd7Smrg	  else
4357ea133fd7Smrg	    case "$xrpath " in
4358ea133fd7Smrg	    *" $arg "*) ;;
4359ea133fd7Smrg	    *) xrpath="$xrpath $arg" ;;
4360ea133fd7Smrg	    esac
4361ea133fd7Smrg	  fi
4362ea133fd7Smrg	  prev=
4363ea133fd7Smrg	  continue
4364ea133fd7Smrg	  ;;
4365ea133fd7Smrg	shrext)
4366ea133fd7Smrg	  shrext_cmds="$arg"
4367ea133fd7Smrg	  prev=
4368ea133fd7Smrg	  continue
4369ea133fd7Smrg	  ;;
4370ea133fd7Smrg	weak)
4371ea133fd7Smrg	  weak_libs="$weak_libs $arg"
4372ea133fd7Smrg	  prev=
4373ea133fd7Smrg	  continue
4374ea133fd7Smrg	  ;;
4375ea133fd7Smrg	xcclinker)
4376ea133fd7Smrg	  linker_flags="$linker_flags $qarg"
4377ea133fd7Smrg	  compiler_flags="$compiler_flags $qarg"
4378ea133fd7Smrg	  prev=
4379ea133fd7Smrg	  func_append compile_command " $qarg"
4380ea133fd7Smrg	  func_append finalize_command " $qarg"
4381ea133fd7Smrg	  continue
4382ea133fd7Smrg	  ;;
4383ea133fd7Smrg	xcompiler)
4384ea133fd7Smrg	  compiler_flags="$compiler_flags $qarg"
4385ea133fd7Smrg	  prev=
4386ea133fd7Smrg	  func_append compile_command " $qarg"
4387ea133fd7Smrg	  func_append finalize_command " $qarg"
4388ea133fd7Smrg	  continue
4389ea133fd7Smrg	  ;;
4390ea133fd7Smrg	xlinker)
4391ea133fd7Smrg	  linker_flags="$linker_flags $qarg"
4392ea133fd7Smrg	  compiler_flags="$compiler_flags $wl$qarg"
4393ea133fd7Smrg	  prev=
4394ea133fd7Smrg	  func_append compile_command " $wl$qarg"
4395ea133fd7Smrg	  func_append finalize_command " $wl$qarg"
4396ea133fd7Smrg	  continue
4397ea133fd7Smrg	  ;;
4398ea133fd7Smrg	*)
4399ea133fd7Smrg	  eval "$prev=\"\$arg\""
4400ea133fd7Smrg	  prev=
4401ea133fd7Smrg	  continue
4402ea133fd7Smrg	  ;;
4403a253d6aeSmrg	esac
4404ea133fd7Smrg      fi # test -n "$prev"
4405a253d6aeSmrg
4406ea133fd7Smrg      prevarg="$arg"
4407a253d6aeSmrg
4408ea133fd7Smrg      case $arg in
4409ea133fd7Smrg      -all-static)
4410ea133fd7Smrg	if test -n "$link_static_flag"; then
4411ea133fd7Smrg	  # See comment for -static flag below, for more details.
4412ea133fd7Smrg	  func_append compile_command " $link_static_flag"
4413ea133fd7Smrg	  func_append finalize_command " $link_static_flag"
4414ea133fd7Smrg	fi
4415ea133fd7Smrg	continue
4416ea133fd7Smrg	;;
4417a253d6aeSmrg
4418ea133fd7Smrg      -allow-undefined)
4419ea133fd7Smrg	# FIXME: remove this flag sometime in the future.
4420ea133fd7Smrg	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
4421ea133fd7Smrg	;;
4422a253d6aeSmrg
4423ea133fd7Smrg      -avoid-version)
4424ea133fd7Smrg	avoid_version=yes
4425ea133fd7Smrg	continue
4426ea133fd7Smrg	;;
4427a253d6aeSmrg
4428ea133fd7Smrg      -dlopen)
4429ea133fd7Smrg	prev=dlfiles
4430ea133fd7Smrg	continue
4431ea133fd7Smrg	;;
4432a253d6aeSmrg
4433ea133fd7Smrg      -dlpreopen)
4434ea133fd7Smrg	prev=dlprefiles
4435ea133fd7Smrg	continue
4436ea133fd7Smrg	;;
4437a253d6aeSmrg
4438ea133fd7Smrg      -export-dynamic)
4439ea133fd7Smrg	export_dynamic=yes
4440ea133fd7Smrg	continue
4441ea133fd7Smrg	;;
4442a253d6aeSmrg
4443ea133fd7Smrg      -export-symbols | -export-symbols-regex)
4444ea133fd7Smrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
4445ea133fd7Smrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
4446ea133fd7Smrg	fi
4447ea133fd7Smrg	if test "X$arg" = "X-export-symbols"; then
4448ea133fd7Smrg	  prev=expsyms
4449ea133fd7Smrg	else
4450ea133fd7Smrg	  prev=expsyms_regex
4451ea133fd7Smrg	fi
4452ea133fd7Smrg	continue
4453ea133fd7Smrg	;;
4454a253d6aeSmrg
4455ea133fd7Smrg      -framework)
4456ea133fd7Smrg	prev=framework
4457ea133fd7Smrg	continue
4458ea133fd7Smrg	;;
4459a253d6aeSmrg
4460ea133fd7Smrg      -inst-prefix-dir)
4461ea133fd7Smrg	prev=inst_prefix
4462ea133fd7Smrg	continue
4463ea133fd7Smrg	;;
4464a253d6aeSmrg
4465ea133fd7Smrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
4466ea133fd7Smrg      # so, if we see these flags be careful not to treat them like -L
4467ea133fd7Smrg      -L[A-Z][A-Z]*:*)
4468ea133fd7Smrg	case $with_gcc/$host in
4469ea133fd7Smrg	no/*-*-irix* | /*-*-irix*)
4470ea133fd7Smrg	  func_append compile_command " $arg"
4471ea133fd7Smrg	  func_append finalize_command " $arg"
4472ea133fd7Smrg	  ;;
4473ea133fd7Smrg	esac
4474ea133fd7Smrg	continue
4475ea133fd7Smrg	;;
4476a253d6aeSmrg
4477ea133fd7Smrg      -L*)
4478ea133fd7Smrg	func_stripname '-L' '' "$arg"
4479ea133fd7Smrg	dir=$func_stripname_result
4480ea133fd7Smrg	if test -z "$dir"; then
4481ea133fd7Smrg	  if test "$#" -gt 0; then
4482ea133fd7Smrg	    func_fatal_error "require no space between \`-L' and \`$1'"
4483ea133fd7Smrg	  else
4484ea133fd7Smrg	    func_fatal_error "need path for \`-L' option"
4485ea133fd7Smrg	  fi
4486ea133fd7Smrg	fi
4487ea133fd7Smrg	# We need an absolute path.
4488ea133fd7Smrg	case $dir in
4489ea133fd7Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
4490ea133fd7Smrg	*)
4491ea133fd7Smrg	  absdir=`cd "$dir" && pwd`
4492ea133fd7Smrg	  test -z "$absdir" && \
4493ea133fd7Smrg	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
4494ea133fd7Smrg	  dir="$absdir"
4495ea133fd7Smrg	  ;;
4496ea133fd7Smrg	esac
4497ea133fd7Smrg	case "$deplibs " in
4498ea133fd7Smrg	*" -L$dir "*) ;;
4499ea133fd7Smrg	*)
4500ea133fd7Smrg	  deplibs="$deplibs -L$dir"
4501ea133fd7Smrg	  lib_search_path="$lib_search_path $dir"
4502ea133fd7Smrg	  ;;
4503ea133fd7Smrg	esac
4504ea133fd7Smrg	case $host in
4505ea133fd7Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
4506ea133fd7Smrg	  testbindir=`$ECHO "X$dir" | $Xsed -e 's*/lib$*/bin*'`
4507ea133fd7Smrg	  case :$dllsearchpath: in
4508ea133fd7Smrg	  *":$dir:"*) ;;
4509ea133fd7Smrg	  ::) dllsearchpath=$dir;;
4510ea133fd7Smrg	  *) dllsearchpath="$dllsearchpath:$dir";;
4511ea133fd7Smrg	  esac
4512ea133fd7Smrg	  case :$dllsearchpath: in
4513ea133fd7Smrg	  *":$testbindir:"*) ;;
4514ea133fd7Smrg	  ::) dllsearchpath=$testbindir;;
4515ea133fd7Smrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
4516ea133fd7Smrg	  esac
4517ea133fd7Smrg	  ;;
4518ea133fd7Smrg	esac
4519ea133fd7Smrg	continue
4520ea133fd7Smrg	;;
4521a253d6aeSmrg
4522ea133fd7Smrg      -l*)
4523ea133fd7Smrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
4524ea133fd7Smrg	  case $host in
4525ea133fd7Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc*)
4526ea133fd7Smrg	    # These systems don't actually have a C or math library (as such)
4527ea133fd7Smrg	    continue
4528ea133fd7Smrg	    ;;
4529ea133fd7Smrg	  *-*-os2*)
4530ea133fd7Smrg	    # These systems don't actually have a C library (as such)
4531ea133fd7Smrg	    test "X$arg" = "X-lc" && continue
4532ea133fd7Smrg	    ;;
4533ea133fd7Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
4534ea133fd7Smrg	    # Do not include libc due to us having libc/libc_r.
4535ea133fd7Smrg	    test "X$arg" = "X-lc" && continue
4536ea133fd7Smrg	    ;;
4537ea133fd7Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
4538ea133fd7Smrg	    # Rhapsody C and math libraries are in the System framework
4539ea133fd7Smrg	    deplibs="$deplibs System.ltframework"
4540ea133fd7Smrg	    continue
4541ea133fd7Smrg	    ;;
4542ea133fd7Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
4543ea133fd7Smrg	    # Causes problems with __ctype
4544ea133fd7Smrg	    test "X$arg" = "X-lc" && continue
4545ea133fd7Smrg	    ;;
4546ea133fd7Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
4547ea133fd7Smrg	    # Compiler inserts libc in the correct place for threads to work
4548ea133fd7Smrg	    test "X$arg" = "X-lc" && continue
4549ea133fd7Smrg	    ;;
4550ea133fd7Smrg	  esac
4551ea133fd7Smrg	elif test "X$arg" = "X-lc_r"; then
4552ea133fd7Smrg	 case $host in
4553ea133fd7Smrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
4554ea133fd7Smrg	   # Do not include libc_r directly, use -pthread flag.
4555ea133fd7Smrg	   continue
4556ea133fd7Smrg	   ;;
4557ea133fd7Smrg	 esac
4558ea133fd7Smrg	fi
4559ea133fd7Smrg	deplibs="$deplibs $arg"
4560ea133fd7Smrg	continue
4561ea133fd7Smrg	;;
4562a253d6aeSmrg
4563ea133fd7Smrg      -module)
4564ea133fd7Smrg	module=yes
4565ea133fd7Smrg	continue
4566ea133fd7Smrg	;;
4567a253d6aeSmrg
4568ea133fd7Smrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
4569ea133fd7Smrg      # classes, name mangling, and exception handling.
4570ea133fd7Smrg      # Darwin uses the -arch flag to determine output architecture.
4571ea133fd7Smrg      -model|-arch|-isysroot)
4572ea133fd7Smrg	compiler_flags="$compiler_flags $arg"
4573ea133fd7Smrg	func_append compile_command " $arg"
4574ea133fd7Smrg	func_append finalize_command " $arg"
4575ea133fd7Smrg	prev=xcompiler
4576ea133fd7Smrg	continue
4577ea133fd7Smrg	;;
4578a253d6aeSmrg
4579ea133fd7Smrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
4580ea133fd7Smrg	compiler_flags="$compiler_flags $arg"
4581ea133fd7Smrg	func_append compile_command " $arg"
4582ea133fd7Smrg	func_append finalize_command " $arg"
4583ea133fd7Smrg	case "$new_inherited_linker_flags " in
4584ea133fd7Smrg	    *" $arg "*) ;;
4585ea133fd7Smrg	    * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;;
4586ea133fd7Smrg	esac
4587ea133fd7Smrg	continue
4588ea133fd7Smrg	;;
4589a253d6aeSmrg
4590ea133fd7Smrg      -multi_module)
4591ea133fd7Smrg	single_module="${wl}-multi_module"
4592ea133fd7Smrg	continue
4593ea133fd7Smrg	;;
4594a253d6aeSmrg
4595ea133fd7Smrg      -no-fast-install)
4596ea133fd7Smrg	fast_install=no
4597ea133fd7Smrg	continue
4598ea133fd7Smrg	;;
4599a253d6aeSmrg
4600ea133fd7Smrg      -no-install)
4601ea133fd7Smrg	case $host in
4602ea133fd7Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
4603ea133fd7Smrg	  # The PATH hackery in wrapper scripts is required on Windows
4604ea133fd7Smrg	  # and Darwin in order for the loader to find any dlls it needs.
4605ea133fd7Smrg	  func_warning "\`-no-install' is ignored for $host"
4606ea133fd7Smrg	  func_warning "assuming \`-no-fast-install' instead"
4607ea133fd7Smrg	  fast_install=no
4608ea133fd7Smrg	  ;;
4609ea133fd7Smrg	*) no_install=yes ;;
4610ea133fd7Smrg	esac
4611ea133fd7Smrg	continue
4612ea133fd7Smrg	;;
4613a253d6aeSmrg
4614ea133fd7Smrg      -no-undefined)
4615ea133fd7Smrg	allow_undefined=no
4616ea133fd7Smrg	continue
4617ea133fd7Smrg	;;
4618a253d6aeSmrg
4619ea133fd7Smrg      -objectlist)
4620ea133fd7Smrg	prev=objectlist
4621ea133fd7Smrg	continue
4622ea133fd7Smrg	;;
4623a253d6aeSmrg
4624ea133fd7Smrg      -o) prev=output ;;
4625a253d6aeSmrg
4626ea133fd7Smrg      -precious-files-regex)
4627ea133fd7Smrg	prev=precious_regex
4628ea133fd7Smrg	continue
4629ea133fd7Smrg	;;
4630a253d6aeSmrg
4631ea133fd7Smrg      -release)
4632ea133fd7Smrg	prev=release
4633ea133fd7Smrg	continue
4634ea133fd7Smrg	;;
4635a253d6aeSmrg
4636ea133fd7Smrg      -rpath)
4637ea133fd7Smrg	prev=rpath
4638ea133fd7Smrg	continue
4639ea133fd7Smrg	;;
4640a253d6aeSmrg
4641ea133fd7Smrg      -R)
4642ea133fd7Smrg	prev=xrpath
4643ea133fd7Smrg	continue
4644ea133fd7Smrg	;;
4645a253d6aeSmrg
4646ea133fd7Smrg      -R*)
4647ea133fd7Smrg	func_stripname '-R' '' "$arg"
4648ea133fd7Smrg	dir=$func_stripname_result
4649ea133fd7Smrg	# We need an absolute path.
4650ea133fd7Smrg	case $dir in
4651ea133fd7Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
4652ea133fd7Smrg	*)
4653ea133fd7Smrg	  func_fatal_error "only absolute run-paths are allowed"
4654ea133fd7Smrg	  ;;
4655ea133fd7Smrg	esac
4656ea133fd7Smrg	case "$xrpath " in
4657ea133fd7Smrg	*" $dir "*) ;;
4658ea133fd7Smrg	*) xrpath="$xrpath $dir" ;;
4659ea133fd7Smrg	esac
4660ea133fd7Smrg	continue
4661ea133fd7Smrg	;;
4662a253d6aeSmrg
4663ea133fd7Smrg      -shared)
4664ea133fd7Smrg	# The effects of -shared are defined in a previous loop.
4665ea133fd7Smrg	continue
4666ea133fd7Smrg	;;
4667a253d6aeSmrg
4668ea133fd7Smrg      -shrext)
4669ea133fd7Smrg	prev=shrext
4670ea133fd7Smrg	continue
4671ea133fd7Smrg	;;
4672a253d6aeSmrg
4673ea133fd7Smrg      -static | -static-libtool-libs)
4674ea133fd7Smrg	# The effects of -static are defined in a previous loop.
4675ea133fd7Smrg	# We used to do the same as -all-static on platforms that
4676ea133fd7Smrg	# didn't have a PIC flag, but the assumption that the effects
4677ea133fd7Smrg	# would be equivalent was wrong.  It would break on at least
4678ea133fd7Smrg	# Digital Unix and AIX.
4679ea133fd7Smrg	continue
4680ea133fd7Smrg	;;
4681a253d6aeSmrg
4682ea133fd7Smrg      -thread-safe)
4683ea133fd7Smrg	thread_safe=yes
4684ea133fd7Smrg	continue
4685ea133fd7Smrg	;;
4686a253d6aeSmrg
4687ea133fd7Smrg      -version-info)
4688ea133fd7Smrg	prev=vinfo
4689ea133fd7Smrg	continue
4690ea133fd7Smrg	;;
4691a253d6aeSmrg
4692ea133fd7Smrg      -version-number)
4693ea133fd7Smrg	prev=vinfo
4694ea133fd7Smrg	vinfo_number=yes
4695ea133fd7Smrg	continue
4696ea133fd7Smrg	;;
4697a253d6aeSmrg
4698ea133fd7Smrg      -weak)
4699ea133fd7Smrg        prev=weak
4700ea133fd7Smrg	continue
4701ea133fd7Smrg	;;
4702a253d6aeSmrg
4703ea133fd7Smrg      -Wc,*)
4704ea133fd7Smrg	func_stripname '-Wc,' '' "$arg"
4705ea133fd7Smrg	args=$func_stripname_result
4706ea133fd7Smrg	arg=
4707ea133fd7Smrg	save_ifs="$IFS"; IFS=','
4708ea133fd7Smrg	for flag in $args; do
4709ea133fd7Smrg	  IFS="$save_ifs"
4710ea133fd7Smrg          func_quote_for_eval "$flag"
4711ea133fd7Smrg	  arg="$arg $wl$func_quote_for_eval_result"
4712ea133fd7Smrg	  compiler_flags="$compiler_flags $func_quote_for_eval_result"
4713ea133fd7Smrg	done
4714ea133fd7Smrg	IFS="$save_ifs"
4715ea133fd7Smrg	func_stripname ' ' '' "$arg"
4716ea133fd7Smrg	arg=$func_stripname_result
4717ea133fd7Smrg	;;
4718a253d6aeSmrg
4719ea133fd7Smrg      -Wl,*)
4720ea133fd7Smrg	func_stripname '-Wl,' '' "$arg"
4721ea133fd7Smrg	args=$func_stripname_result
4722ea133fd7Smrg	arg=
4723ea133fd7Smrg	save_ifs="$IFS"; IFS=','
4724ea133fd7Smrg	for flag in $args; do
4725ea133fd7Smrg	  IFS="$save_ifs"
4726ea133fd7Smrg          func_quote_for_eval "$flag"
4727ea133fd7Smrg	  arg="$arg $wl$func_quote_for_eval_result"
4728ea133fd7Smrg	  compiler_flags="$compiler_flags $wl$func_quote_for_eval_result"
4729ea133fd7Smrg	  linker_flags="$linker_flags $func_quote_for_eval_result"
4730ea133fd7Smrg	done
4731ea133fd7Smrg	IFS="$save_ifs"
4732ea133fd7Smrg	func_stripname ' ' '' "$arg"
4733ea133fd7Smrg	arg=$func_stripname_result
4734ea133fd7Smrg	;;
4735a253d6aeSmrg
4736ea133fd7Smrg      -Xcompiler)
4737ea133fd7Smrg	prev=xcompiler
4738ea133fd7Smrg	continue
4739ea133fd7Smrg	;;
4740a253d6aeSmrg
4741ea133fd7Smrg      -Xlinker)
4742ea133fd7Smrg	prev=xlinker
4743ea133fd7Smrg	continue
4744ea133fd7Smrg	;;
4745a253d6aeSmrg
4746ea133fd7Smrg      -XCClinker)
4747ea133fd7Smrg	prev=xcclinker
4748ea133fd7Smrg	continue
4749ea133fd7Smrg	;;
4750a253d6aeSmrg
4751ea133fd7Smrg      # -msg_* for osf cc
4752ea133fd7Smrg      -msg_*)
4753ea133fd7Smrg	func_quote_for_eval "$arg"
4754ea133fd7Smrg	arg="$func_quote_for_eval_result"
4755ea133fd7Smrg	;;
4756a253d6aeSmrg
4757ea133fd7Smrg      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
4758ea133fd7Smrg      # -r[0-9][0-9]* specifies the processor on the SGI compiler
4759ea133fd7Smrg      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
4760ea133fd7Smrg      # +DA*, +DD* enable 64-bit mode on the HP compiler
4761ea133fd7Smrg      # -q* pass through compiler args for the IBM compiler
4762ea133fd7Smrg      # -m*, -t[45]*, -txscale* pass through architecture-specific
4763ea133fd7Smrg      # compiler args for GCC
4764ea133fd7Smrg      # -F/path gives path to uninstalled frameworks, gcc on darwin
4765ea133fd7Smrg      # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
4766ea133fd7Smrg      # @file GCC response files
4767ea133fd7Smrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
4768ea133fd7Smrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*)
4769ea133fd7Smrg        func_quote_for_eval "$arg"
4770ea133fd7Smrg	arg="$func_quote_for_eval_result"
4771ea133fd7Smrg        func_append compile_command " $arg"
4772ea133fd7Smrg        func_append finalize_command " $arg"
4773ea133fd7Smrg        compiler_flags="$compiler_flags $arg"
4774ea133fd7Smrg        continue
4775ea133fd7Smrg        ;;
4776a253d6aeSmrg
4777ea133fd7Smrg      # Some other compiler flag.
4778ea133fd7Smrg      -* | +*)
4779ea133fd7Smrg        func_quote_for_eval "$arg"
4780ea133fd7Smrg	arg="$func_quote_for_eval_result"
4781ea133fd7Smrg	;;
4782a253d6aeSmrg
4783ea133fd7Smrg      *.$objext)
4784ea133fd7Smrg	# A standard object.
4785ea133fd7Smrg	objs="$objs $arg"
4786ea133fd7Smrg	;;
4787ea133fd7Smrg
4788ea133fd7Smrg      *.lo)
4789ea133fd7Smrg	# A libtool-controlled object.
4790ea133fd7Smrg
4791ea133fd7Smrg	# Check to see that this really is a libtool object.
4792ea133fd7Smrg	if func_lalib_unsafe_p "$arg"; then
4793ea133fd7Smrg	  pic_object=
4794ea133fd7Smrg	  non_pic_object=
4795ea133fd7Smrg
4796ea133fd7Smrg	  # Read the .lo file
4797ea133fd7Smrg	  func_source "$arg"
4798ea133fd7Smrg
4799ea133fd7Smrg	  if test -z "$pic_object" ||
4800ea133fd7Smrg	     test -z "$non_pic_object" ||
4801ea133fd7Smrg	     test "$pic_object" = none &&
4802ea133fd7Smrg	     test "$non_pic_object" = none; then
4803ea133fd7Smrg	    func_fatal_error "cannot find name of object for \`$arg'"
4804ea133fd7Smrg	  fi
4805ea133fd7Smrg
4806ea133fd7Smrg	  # Extract subdirectory from the argument.
4807ea133fd7Smrg	  func_dirname "$arg" "/" ""
4808ea133fd7Smrg	  xdir="$func_dirname_result"
4809ea133fd7Smrg
4810ea133fd7Smrg	  if test "$pic_object" != none; then
4811ea133fd7Smrg	    # Prepend the subdirectory the object is found in.
4812ea133fd7Smrg	    pic_object="$xdir$pic_object"
4813ea133fd7Smrg
4814ea133fd7Smrg	    if test "$prev" = dlfiles; then
4815ea133fd7Smrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
4816ea133fd7Smrg		dlfiles="$dlfiles $pic_object"
4817ea133fd7Smrg		prev=
4818ea133fd7Smrg		continue
4819ea133fd7Smrg	      else
4820ea133fd7Smrg		# If libtool objects are unsupported, then we need to preload.
4821ea133fd7Smrg		prev=dlprefiles
4822ea133fd7Smrg	      fi
4823ea133fd7Smrg	    fi
4824ea133fd7Smrg
4825ea133fd7Smrg	    # CHECK ME:  I think I busted this.  -Ossama
4826ea133fd7Smrg	    if test "$prev" = dlprefiles; then
4827ea133fd7Smrg	      # Preload the old-style object.
4828ea133fd7Smrg	      dlprefiles="$dlprefiles $pic_object"
4829ea133fd7Smrg	      prev=
4830ea133fd7Smrg	    fi
4831ea133fd7Smrg
4832ea133fd7Smrg	    # A PIC object.
4833ea133fd7Smrg	    func_append libobjs " $pic_object"
4834ea133fd7Smrg	    arg="$pic_object"
4835ea133fd7Smrg	  fi
4836ea133fd7Smrg
4837ea133fd7Smrg	  # Non-PIC object.
4838ea133fd7Smrg	  if test "$non_pic_object" != none; then
4839ea133fd7Smrg	    # Prepend the subdirectory the object is found in.
4840ea133fd7Smrg	    non_pic_object="$xdir$non_pic_object"
4841ea133fd7Smrg
4842ea133fd7Smrg	    # A standard non-PIC object
4843ea133fd7Smrg	    func_append non_pic_objects " $non_pic_object"
4844ea133fd7Smrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
4845ea133fd7Smrg	      arg="$non_pic_object"
4846ea133fd7Smrg	    fi
4847ea133fd7Smrg	  else
4848ea133fd7Smrg	    # If the PIC object exists, use it instead.
4849ea133fd7Smrg	    # $xdir was prepended to $pic_object above.
4850ea133fd7Smrg	    non_pic_object="$pic_object"
4851ea133fd7Smrg	    func_append non_pic_objects " $non_pic_object"
4852ea133fd7Smrg	  fi
4853ea133fd7Smrg	else
4854ea133fd7Smrg	  # Only an error if not doing a dry-run.
4855ea133fd7Smrg	  if $opt_dry_run; then
4856ea133fd7Smrg	    # Extract subdirectory from the argument.
4857ea133fd7Smrg	    func_dirname "$arg" "/" ""
4858ea133fd7Smrg	    xdir="$func_dirname_result"
4859ea133fd7Smrg
4860ea133fd7Smrg	    func_lo2o "$arg"
4861ea133fd7Smrg	    pic_object=$xdir$objdir/$func_lo2o_result
4862ea133fd7Smrg	    non_pic_object=$xdir$func_lo2o_result
4863ea133fd7Smrg	    func_append libobjs " $pic_object"
4864ea133fd7Smrg	    func_append non_pic_objects " $non_pic_object"
4865ea133fd7Smrg	  else
4866ea133fd7Smrg	    func_fatal_error "\`$arg' is not a valid libtool object"
4867ea133fd7Smrg	  fi
4868ea133fd7Smrg	fi
4869ea133fd7Smrg	;;
4870ea133fd7Smrg
4871ea133fd7Smrg      *.$libext)
4872ea133fd7Smrg	# An archive.
4873ea133fd7Smrg	deplibs="$deplibs $arg"
4874ea133fd7Smrg	old_deplibs="$old_deplibs $arg"
4875ea133fd7Smrg	continue
4876ea133fd7Smrg	;;
4877ea133fd7Smrg
4878ea133fd7Smrg      *.la)
4879ea133fd7Smrg	# A libtool-controlled library.
4880ea133fd7Smrg
4881ea133fd7Smrg	if test "$prev" = dlfiles; then
4882ea133fd7Smrg	  # This library was specified with -dlopen.
4883ea133fd7Smrg	  dlfiles="$dlfiles $arg"
4884ea133fd7Smrg	  prev=
4885ea133fd7Smrg	elif test "$prev" = dlprefiles; then
4886ea133fd7Smrg	  # The library was specified with -dlpreopen.
4887ea133fd7Smrg	  dlprefiles="$dlprefiles $arg"
4888ea133fd7Smrg	  prev=
4889ea133fd7Smrg	else
4890ea133fd7Smrg	  deplibs="$deplibs $arg"
4891ea133fd7Smrg	fi
4892ea133fd7Smrg	continue
4893ea133fd7Smrg	;;
4894ea133fd7Smrg
4895ea133fd7Smrg      # Some other compiler argument.
4896ea133fd7Smrg      *)
4897ea133fd7Smrg	# Unknown arguments in both finalize_command and compile_command need
4898ea133fd7Smrg	# to be aesthetically quoted because they are evaled later.
4899ea133fd7Smrg	func_quote_for_eval "$arg"
4900ea133fd7Smrg	arg="$func_quote_for_eval_result"
4901ea133fd7Smrg	;;
4902ea133fd7Smrg      esac # arg
4903ea133fd7Smrg
4904ea133fd7Smrg      # Now actually substitute the argument into the commands.
4905ea133fd7Smrg      if test -n "$arg"; then
4906ea133fd7Smrg	func_append compile_command " $arg"
4907ea133fd7Smrg	func_append finalize_command " $arg"
4908ea133fd7Smrg      fi
4909ea133fd7Smrg    done # argument parsing loop
4910ea133fd7Smrg
4911ea133fd7Smrg    test -n "$prev" && \
4912ea133fd7Smrg      func_fatal_help "the \`$prevarg' option requires an argument"
4913ea133fd7Smrg
4914ea133fd7Smrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
4915ea133fd7Smrg      eval arg=\"$export_dynamic_flag_spec\"
4916ea133fd7Smrg      func_append compile_command " $arg"
4917ea133fd7Smrg      func_append finalize_command " $arg"
4918ea133fd7Smrg    fi
4919ea133fd7Smrg
4920ea133fd7Smrg    oldlibs=
4921ea133fd7Smrg    # calculate the name of the file, without its directory
4922ea133fd7Smrg    func_basename "$output"
4923ea133fd7Smrg    outputname="$func_basename_result"
4924ea133fd7Smrg    libobjs_save="$libobjs"
4925ea133fd7Smrg
4926ea133fd7Smrg    if test -n "$shlibpath_var"; then
4927ea133fd7Smrg      # get the directories listed in $shlibpath_var
4928ea133fd7Smrg      eval shlib_search_path=\`\$ECHO \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
4929a253d6aeSmrg    else
4930ea133fd7Smrg      shlib_search_path=
4931a253d6aeSmrg    fi
4932ea133fd7Smrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
4933ea133fd7Smrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
4934a253d6aeSmrg
4935ea133fd7Smrg    func_dirname "$output" "/" ""
4936ea133fd7Smrg    output_objdir="$func_dirname_result$objdir"
4937ea133fd7Smrg    # Create the object directory.
4938ea133fd7Smrg    func_mkdir_p "$output_objdir"
4939a253d6aeSmrg
4940ea133fd7Smrg    # Determine the type of output
4941ea133fd7Smrg    case $output in
4942ea133fd7Smrg    "")
4943ea133fd7Smrg      func_fatal_help "you must specify an output file"
4944ea133fd7Smrg      ;;
4945ea133fd7Smrg    *.$libext) linkmode=oldlib ;;
4946ea133fd7Smrg    *.lo | *.$objext) linkmode=obj ;;
4947ea133fd7Smrg    *.la) linkmode=lib ;;
4948ea133fd7Smrg    *) linkmode=prog ;; # Anything else should be a program.
4949ea133fd7Smrg    esac
4950ea133fd7Smrg
4951ea133fd7Smrg    specialdeplibs=
4952ea133fd7Smrg
4953ea133fd7Smrg    libs=
4954ea133fd7Smrg    # Find all interdependent deplibs by searching for libraries
4955ea133fd7Smrg    # that are linked more than once (e.g. -la -lb -la)
4956ea133fd7Smrg    for deplib in $deplibs; do
4957ea133fd7Smrg      if $opt_duplicate_deps ; then
4958ea133fd7Smrg	case "$libs " in
4959ea133fd7Smrg	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
4960ea133fd7Smrg	esac
4961ea133fd7Smrg      fi
4962ea133fd7Smrg      libs="$libs $deplib"
4963ea133fd7Smrg    done
4964ea133fd7Smrg
4965ea133fd7Smrg    if test "$linkmode" = lib; then
4966ea133fd7Smrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
4967ea133fd7Smrg
4968ea133fd7Smrg      # Compute libraries that are listed more than once in $predeps
4969ea133fd7Smrg      # $postdeps and mark them as special (i.e., whose duplicates are
4970ea133fd7Smrg      # not to be eliminated).
4971ea133fd7Smrg      pre_post_deps=
4972ea133fd7Smrg      if $opt_duplicate_compiler_generated_deps; then
4973ea133fd7Smrg	for pre_post_dep in $predeps $postdeps; do
4974ea133fd7Smrg	  case "$pre_post_deps " in
4975ea133fd7Smrg	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
4976ea133fd7Smrg	  esac
4977ea133fd7Smrg	  pre_post_deps="$pre_post_deps $pre_post_dep"
4978ea133fd7Smrg	done
4979ea133fd7Smrg      fi
4980ea133fd7Smrg      pre_post_deps=
4981ea133fd7Smrg    fi
4982ea133fd7Smrg
4983ea133fd7Smrg    deplibs=
4984ea133fd7Smrg    newdependency_libs=
4985ea133fd7Smrg    newlib_search_path=
4986ea133fd7Smrg    need_relink=no # whether we're linking any uninstalled libtool libraries
4987ea133fd7Smrg    notinst_deplibs= # not-installed libtool libraries
4988ea133fd7Smrg    notinst_path= # paths that contain not-installed libtool libraries
4989ea133fd7Smrg
4990ea133fd7Smrg    case $linkmode in
4991ea133fd7Smrg    lib)
4992ea133fd7Smrg	passes="conv dlpreopen link"
4993ea133fd7Smrg	for file in $dlfiles $dlprefiles; do
4994ea133fd7Smrg	  case $file in
4995ea133fd7Smrg	  *.la) ;;
4996ea133fd7Smrg	  *)
4997ea133fd7Smrg	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
4998ea133fd7Smrg	    ;;
4999ea133fd7Smrg	  esac
5000ea133fd7Smrg	done
5001ea133fd7Smrg	;;
5002ea133fd7Smrg    prog)
5003ea133fd7Smrg	compile_deplibs=
5004ea133fd7Smrg	finalize_deplibs=
5005ea133fd7Smrg	alldeplibs=no
5006ea133fd7Smrg	newdlfiles=
5007ea133fd7Smrg	newdlprefiles=
5008ea133fd7Smrg	passes="conv scan dlopen dlpreopen link"
5009ea133fd7Smrg	;;
5010ea133fd7Smrg    *)  passes="conv"
5011ea133fd7Smrg	;;
5012ea133fd7Smrg    esac
5013ea133fd7Smrg
5014ea133fd7Smrg    for pass in $passes; do
5015ea133fd7Smrg      # The preopen pass in lib mode reverses $deplibs; put it back here
5016ea133fd7Smrg      # so that -L comes before libs that need it for instance...
5017ea133fd7Smrg      if test "$linkmode,$pass" = "lib,link"; then
5018ea133fd7Smrg	## FIXME: Find the place where the list is rebuilt in the wrong
5019ea133fd7Smrg	##        order, and fix it there properly
5020ea133fd7Smrg        tmp_deplibs=
5021ea133fd7Smrg	for deplib in $deplibs; do
5022ea133fd7Smrg	  tmp_deplibs="$deplib $tmp_deplibs"
5023ea133fd7Smrg	done
5024ea133fd7Smrg	deplibs="$tmp_deplibs"
5025ea133fd7Smrg      fi
5026ea133fd7Smrg
5027ea133fd7Smrg      if test "$linkmode,$pass" = "lib,link" ||
5028ea133fd7Smrg	 test "$linkmode,$pass" = "prog,scan"; then
5029ea133fd7Smrg	libs="$deplibs"
5030ea133fd7Smrg	deplibs=
5031ea133fd7Smrg      fi
5032ea133fd7Smrg      if test "$linkmode" = prog; then
5033ea133fd7Smrg	case $pass in
5034ea133fd7Smrg	dlopen) libs="$dlfiles" ;;
5035ea133fd7Smrg	dlpreopen) libs="$dlprefiles" ;;
5036ea133fd7Smrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
5037ea133fd7Smrg	esac
5038ea133fd7Smrg      fi
5039ea133fd7Smrg      if test "$linkmode,$pass" = "lib,dlpreopen"; then
5040ea133fd7Smrg	# Collect and forward deplibs of preopened libtool libs
5041ea133fd7Smrg	for lib in $dlprefiles; do
5042ea133fd7Smrg	  # Ignore non-libtool-libs
5043ea133fd7Smrg	  dependency_libs=
5044ea133fd7Smrg	  case $lib in
5045ea133fd7Smrg	  *.la)	func_source "$lib" ;;
5046ea133fd7Smrg	  esac
5047ea133fd7Smrg
5048ea133fd7Smrg	  # Collect preopened libtool deplibs, except any this library
5049ea133fd7Smrg	  # has declared as weak libs
5050ea133fd7Smrg	  for deplib in $dependency_libs; do
5051ea133fd7Smrg            deplib_base=`$ECHO "X$deplib" | $Xsed -e "$basename"`
5052ea133fd7Smrg	    case " $weak_libs " in
5053ea133fd7Smrg	    *" $deplib_base "*) ;;
5054ea133fd7Smrg	    *) deplibs="$deplibs $deplib" ;;
5055ea133fd7Smrg	    esac
5056ea133fd7Smrg	  done
5057ea133fd7Smrg	done
5058ea133fd7Smrg	libs="$dlprefiles"
5059ea133fd7Smrg      fi
5060ea133fd7Smrg      if test "$pass" = dlopen; then
5061ea133fd7Smrg	# Collect dlpreopened libraries
5062ea133fd7Smrg	save_deplibs="$deplibs"
5063ea133fd7Smrg	deplibs=
5064ea133fd7Smrg      fi
5065ea133fd7Smrg
5066ea133fd7Smrg      for deplib in $libs; do
5067ea133fd7Smrg	lib=
5068ea133fd7Smrg	found=no
5069ea133fd7Smrg	case $deplib in
5070ea133fd7Smrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
5071ea133fd7Smrg	  if test "$linkmode,$pass" = "prog,link"; then
5072ea133fd7Smrg	    compile_deplibs="$deplib $compile_deplibs"
5073ea133fd7Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
5074ea133fd7Smrg	  else
5075ea133fd7Smrg	    compiler_flags="$compiler_flags $deplib"
5076ea133fd7Smrg	    if test "$linkmode" = lib ; then
5077ea133fd7Smrg		case "$new_inherited_linker_flags " in
5078ea133fd7Smrg		    *" $deplib "*) ;;
5079ea133fd7Smrg		    * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
5080ea133fd7Smrg		esac
5081ea133fd7Smrg	    fi
5082ea133fd7Smrg	  fi
5083ea133fd7Smrg	  continue
5084ea133fd7Smrg	  ;;
5085ea133fd7Smrg	-l*)
5086ea133fd7Smrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
5087ea133fd7Smrg	    func_warning "\`-l' is ignored for archives/objects"
5088ea133fd7Smrg	    continue
5089ea133fd7Smrg	  fi
5090ea133fd7Smrg	  func_stripname '-l' '' "$deplib"
5091ea133fd7Smrg	  name=$func_stripname_result
5092ea133fd7Smrg	  if test "$linkmode" = lib; then
5093ea133fd7Smrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
5094ea133fd7Smrg	  else
5095ea133fd7Smrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
5096ea133fd7Smrg	  fi
5097ea133fd7Smrg	  for searchdir in $searchdirs; do
5098ea133fd7Smrg	    for search_ext in .la $std_shrext .so .a; do
5099ea133fd7Smrg	      # Search the libtool library
5100ea133fd7Smrg	      lib="$searchdir/lib${name}${search_ext}"
5101ea133fd7Smrg	      if test -f "$lib"; then
5102ea133fd7Smrg		if test "$search_ext" = ".la"; then
5103ea133fd7Smrg		  found=yes
5104ea133fd7Smrg		else
5105ea133fd7Smrg		  found=no
5106ea133fd7Smrg		fi
5107ea133fd7Smrg		break 2
5108ea133fd7Smrg	      fi
5109ea133fd7Smrg	    done
5110ea133fd7Smrg	  done
5111ea133fd7Smrg	  if test "$found" != yes; then
5112ea133fd7Smrg	    # deplib doesn't seem to be a libtool library
5113ea133fd7Smrg	    if test "$linkmode,$pass" = "prog,link"; then
5114ea133fd7Smrg	      compile_deplibs="$deplib $compile_deplibs"
5115ea133fd7Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
5116ea133fd7Smrg	    else
5117ea133fd7Smrg	      deplibs="$deplib $deplibs"
5118ea133fd7Smrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
5119ea133fd7Smrg	    fi
5120ea133fd7Smrg	    continue
5121ea133fd7Smrg	  else # deplib is a libtool library
5122ea133fd7Smrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
5123ea133fd7Smrg	    # We need to do some special things here, and not later.
5124ea133fd7Smrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
5125ea133fd7Smrg	      case " $predeps $postdeps " in
5126ea133fd7Smrg	      *" $deplib "*)
5127ea133fd7Smrg		if func_lalib_p "$lib"; then
5128ea133fd7Smrg		  library_names=
5129ea133fd7Smrg		  old_library=
5130ea133fd7Smrg		  func_source "$lib"
5131ea133fd7Smrg		  for l in $old_library $library_names; do
5132ea133fd7Smrg		    ll="$l"
5133ea133fd7Smrg		  done
5134ea133fd7Smrg		  if test "X$ll" = "X$old_library" ; then # only static version available
5135ea133fd7Smrg		    found=no
5136ea133fd7Smrg		    func_dirname "$lib" "" "."
5137ea133fd7Smrg		    ladir="$func_dirname_result"
5138ea133fd7Smrg		    lib=$ladir/$old_library
5139ea133fd7Smrg		    if test "$linkmode,$pass" = "prog,link"; then
5140ea133fd7Smrg		      compile_deplibs="$deplib $compile_deplibs"
5141ea133fd7Smrg		      finalize_deplibs="$deplib $finalize_deplibs"
5142ea133fd7Smrg		    else
5143ea133fd7Smrg		      deplibs="$deplib $deplibs"
5144ea133fd7Smrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
5145ea133fd7Smrg		    fi
5146ea133fd7Smrg		    continue
5147ea133fd7Smrg		  fi
5148ea133fd7Smrg		fi
5149ea133fd7Smrg		;;
5150ea133fd7Smrg	      *) ;;
5151ea133fd7Smrg	      esac
5152ea133fd7Smrg	    fi
5153ea133fd7Smrg	  fi
5154ea133fd7Smrg	  ;; # -l
5155ea133fd7Smrg	*.ltframework)
5156ea133fd7Smrg	  if test "$linkmode,$pass" = "prog,link"; then
5157ea133fd7Smrg	    compile_deplibs="$deplib $compile_deplibs"
5158ea133fd7Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
5159ea133fd7Smrg	  else
5160ea133fd7Smrg	    deplibs="$deplib $deplibs"
5161ea133fd7Smrg	    if test "$linkmode" = lib ; then
5162ea133fd7Smrg		case "$new_inherited_linker_flags " in
5163ea133fd7Smrg		    *" $deplib "*) ;;
5164ea133fd7Smrg		    * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
5165ea133fd7Smrg		esac
5166ea133fd7Smrg	    fi
5167ea133fd7Smrg	  fi
5168ea133fd7Smrg	  continue
5169ea133fd7Smrg	  ;;
5170ea133fd7Smrg	-L*)
5171ea133fd7Smrg	  case $linkmode in
5172ea133fd7Smrg	  lib)
5173ea133fd7Smrg	    deplibs="$deplib $deplibs"
5174ea133fd7Smrg	    test "$pass" = conv && continue
5175ea133fd7Smrg	    newdependency_libs="$deplib $newdependency_libs"
5176ea133fd7Smrg	    func_stripname '-L' '' "$deplib"
5177ea133fd7Smrg	    newlib_search_path="$newlib_search_path $func_stripname_result"
5178ea133fd7Smrg	    ;;
5179ea133fd7Smrg	  prog)
5180ea133fd7Smrg	    if test "$pass" = conv; then
5181ea133fd7Smrg	      deplibs="$deplib $deplibs"
5182ea133fd7Smrg	      continue
5183ea133fd7Smrg	    fi
5184ea133fd7Smrg	    if test "$pass" = scan; then
5185ea133fd7Smrg	      deplibs="$deplib $deplibs"
5186ea133fd7Smrg	    else
5187ea133fd7Smrg	      compile_deplibs="$deplib $compile_deplibs"
5188ea133fd7Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
5189ea133fd7Smrg	    fi
5190ea133fd7Smrg	    func_stripname '-L' '' "$deplib"
5191ea133fd7Smrg	    newlib_search_path="$newlib_search_path $func_stripname_result"
5192ea133fd7Smrg	    ;;
5193ea133fd7Smrg	  *)
5194ea133fd7Smrg	    func_warning "\`-L' is ignored for archives/objects"
5195ea133fd7Smrg	    ;;
5196ea133fd7Smrg	  esac # linkmode
5197ea133fd7Smrg	  continue
5198ea133fd7Smrg	  ;; # -L
5199ea133fd7Smrg	-R*)
5200ea133fd7Smrg	  if test "$pass" = link; then
5201ea133fd7Smrg	    func_stripname '-R' '' "$deplib"
5202ea133fd7Smrg	    dir=$func_stripname_result
5203ea133fd7Smrg	    # Make sure the xrpath contains only unique directories.
5204ea133fd7Smrg	    case "$xrpath " in
5205ea133fd7Smrg	    *" $dir "*) ;;
5206ea133fd7Smrg	    *) xrpath="$xrpath $dir" ;;
5207ea133fd7Smrg	    esac
5208ea133fd7Smrg	  fi
5209ea133fd7Smrg	  deplibs="$deplib $deplibs"
5210ea133fd7Smrg	  continue
5211ea133fd7Smrg	  ;;
5212ea133fd7Smrg	*.la) lib="$deplib" ;;
5213ea133fd7Smrg	*.$libext)
5214ea133fd7Smrg	  if test "$pass" = conv; then
5215ea133fd7Smrg	    deplibs="$deplib $deplibs"
5216ea133fd7Smrg	    continue
5217ea133fd7Smrg	  fi
5218ea133fd7Smrg	  case $linkmode in
5219ea133fd7Smrg	  lib)
5220ea133fd7Smrg	    # Linking convenience modules into shared libraries is allowed,
5221ea133fd7Smrg	    # but linking other static libraries is non-portable.
5222ea133fd7Smrg	    case " $dlpreconveniencelibs " in
5223ea133fd7Smrg	    *" $deplib "*) ;;
5224ea133fd7Smrg	    *)
5225ea133fd7Smrg	      valid_a_lib=no
5226ea133fd7Smrg	      case $deplibs_check_method in
5227ea133fd7Smrg		match_pattern*)
5228ea133fd7Smrg		  set dummy $deplibs_check_method; shift
5229ea133fd7Smrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
5230ea133fd7Smrg		  if eval "\$ECHO \"X$deplib\"" 2>/dev/null | $Xsed -e 10q \
5231ea133fd7Smrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
5232ea133fd7Smrg		    valid_a_lib=yes
5233ea133fd7Smrg		  fi
5234ea133fd7Smrg		;;
5235ea133fd7Smrg		pass_all)
5236ea133fd7Smrg		  valid_a_lib=yes
5237ea133fd7Smrg		;;
5238ea133fd7Smrg	      esac
5239ea133fd7Smrg	      if test "$valid_a_lib" != yes; then
5240ea133fd7Smrg		$ECHO
5241ea133fd7Smrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
5242ea133fd7Smrg		$ECHO "*** I have the capability to make that library automatically link in when"
5243ea133fd7Smrg		$ECHO "*** you link to this library.  But I can only do this if you have a"
5244ea133fd7Smrg		$ECHO "*** shared version of the library, which you do not appear to have"
5245ea133fd7Smrg		$ECHO "*** because the file extensions .$libext of this argument makes me believe"
5246ea133fd7Smrg		$ECHO "*** that it is just a static archive that I should not use here."
5247ea133fd7Smrg	      else
5248ea133fd7Smrg		$ECHO
5249ea133fd7Smrg		$ECHO "*** Warning: Linking the shared library $output against the"
5250ea133fd7Smrg		$ECHO "*** static library $deplib is not portable!"
5251ea133fd7Smrg		deplibs="$deplib $deplibs"
5252ea133fd7Smrg	      fi
5253ea133fd7Smrg	      ;;
5254ea133fd7Smrg	    esac
5255ea133fd7Smrg	    continue
5256ea133fd7Smrg	    ;;
5257ea133fd7Smrg	  prog)
5258ea133fd7Smrg	    if test "$pass" != link; then
5259ea133fd7Smrg	      deplibs="$deplib $deplibs"
5260ea133fd7Smrg	    else
5261ea133fd7Smrg	      compile_deplibs="$deplib $compile_deplibs"
5262ea133fd7Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
5263ea133fd7Smrg	    fi
5264ea133fd7Smrg	    continue
5265ea133fd7Smrg	    ;;
5266ea133fd7Smrg	  esac # linkmode
5267ea133fd7Smrg	  ;; # *.$libext
5268ea133fd7Smrg	*.lo | *.$objext)
5269ea133fd7Smrg	  if test "$pass" = conv; then
5270ea133fd7Smrg	    deplibs="$deplib $deplibs"
5271ea133fd7Smrg	  elif test "$linkmode" = prog; then
5272ea133fd7Smrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
5273ea133fd7Smrg	      # If there is no dlopen support or we're linking statically,
5274ea133fd7Smrg	      # we need to preload.
5275ea133fd7Smrg	      newdlprefiles="$newdlprefiles $deplib"
5276ea133fd7Smrg	      compile_deplibs="$deplib $compile_deplibs"
5277ea133fd7Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
5278ea133fd7Smrg	    else
5279ea133fd7Smrg	      newdlfiles="$newdlfiles $deplib"
5280ea133fd7Smrg	    fi
5281ea133fd7Smrg	  fi
5282ea133fd7Smrg	  continue
5283ea133fd7Smrg	  ;;
5284ea133fd7Smrg	%DEPLIBS%)
5285ea133fd7Smrg	  alldeplibs=yes
5286ea133fd7Smrg	  continue
5287ea133fd7Smrg	  ;;
5288ea133fd7Smrg	esac # case $deplib
5289ea133fd7Smrg
5290ea133fd7Smrg	if test "$found" = yes || test -f "$lib"; then :
5291ea133fd7Smrg	else
5292ea133fd7Smrg	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
5293ea133fd7Smrg	fi
5294ea133fd7Smrg
5295ea133fd7Smrg	# Check to see that this really is a libtool archive.
5296ea133fd7Smrg	func_lalib_unsafe_p "$lib" \
5297ea133fd7Smrg	  || func_fatal_error "\`$lib' is not a valid libtool archive"
5298ea133fd7Smrg
5299ea133fd7Smrg	func_dirname "$lib" "" "."
5300ea133fd7Smrg	ladir="$func_dirname_result"
5301ea133fd7Smrg
5302ea133fd7Smrg	dlname=
5303ea133fd7Smrg	dlopen=
5304ea133fd7Smrg	dlpreopen=
5305ea133fd7Smrg	libdir=
5306ea133fd7Smrg	library_names=
5307ea133fd7Smrg	old_library=
5308ea133fd7Smrg	inherited_linker_flags=
5309ea133fd7Smrg	# If the library was installed with an old release of libtool,
5310ea133fd7Smrg	# it will not redefine variables installed, or shouldnotlink
5311ea133fd7Smrg	installed=yes
5312ea133fd7Smrg	shouldnotlink=no
5313ea133fd7Smrg	avoidtemprpath=
5314ea133fd7Smrg
5315ea133fd7Smrg
5316ea133fd7Smrg	# Read the .la file
5317ea133fd7Smrg	func_source "$lib"
5318ea133fd7Smrg
5319ea133fd7Smrg	# Convert "-framework foo" to "foo.ltframework"
5320ea133fd7Smrg	if test -n "$inherited_linker_flags"; then
5321ea133fd7Smrg	  tmp_inherited_linker_flags=`$ECHO "X$inherited_linker_flags" | $Xsed -e 's/-framework \([^ $]*\)/\1.ltframework/g'`
5322ea133fd7Smrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
5323ea133fd7Smrg	    case " $new_inherited_linker_flags " in
5324ea133fd7Smrg	      *" $tmp_inherited_linker_flag "*) ;;
5325ea133fd7Smrg	      *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";;
5326ea133fd7Smrg	    esac
5327ea133fd7Smrg	  done
5328ea133fd7Smrg	fi
5329ea133fd7Smrg	dependency_libs=`$ECHO "X $dependency_libs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
5330ea133fd7Smrg	if test "$linkmode,$pass" = "lib,link" ||
5331ea133fd7Smrg	   test "$linkmode,$pass" = "prog,scan" ||
5332ea133fd7Smrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
5333ea133fd7Smrg	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
5334ea133fd7Smrg	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
5335ea133fd7Smrg	fi
5336ea133fd7Smrg
5337ea133fd7Smrg	if test "$pass" = conv; then
5338ea133fd7Smrg	  # Only check for convenience libraries
5339ea133fd7Smrg	  deplibs="$lib $deplibs"
5340ea133fd7Smrg	  if test -z "$libdir"; then
5341ea133fd7Smrg	    if test -z "$old_library"; then
5342ea133fd7Smrg	      func_fatal_error "cannot find name of link library for \`$lib'"
5343ea133fd7Smrg	    fi
5344ea133fd7Smrg	    # It is a libtool convenience library, so add in its objects.
5345ea133fd7Smrg	    convenience="$convenience $ladir/$objdir/$old_library"
5346ea133fd7Smrg	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
5347ea133fd7Smrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
5348ea133fd7Smrg	    func_fatal_error "\`$lib' is not a convenience library"
5349ea133fd7Smrg	  fi
5350ea133fd7Smrg	  tmp_libs=
5351ea133fd7Smrg	  for deplib in $dependency_libs; do
5352ea133fd7Smrg	    deplibs="$deplib $deplibs"
5353ea133fd7Smrg	    if $opt_duplicate_deps ; then
5354ea133fd7Smrg	      case "$tmp_libs " in
5355ea133fd7Smrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
5356ea133fd7Smrg	      esac
5357ea133fd7Smrg	    fi
5358ea133fd7Smrg	    tmp_libs="$tmp_libs $deplib"
5359ea133fd7Smrg	  done
5360ea133fd7Smrg	  continue
5361ea133fd7Smrg	fi # $pass = conv
5362ea133fd7Smrg
5363ea133fd7Smrg
5364ea133fd7Smrg	# Get the name of the library we link against.
5365ea133fd7Smrg	linklib=
5366ea133fd7Smrg	for l in $old_library $library_names; do
5367ea133fd7Smrg	  linklib="$l"
5368ea133fd7Smrg	done
5369ea133fd7Smrg	if test -z "$linklib"; then
5370ea133fd7Smrg	  func_fatal_error "cannot find name of link library for \`$lib'"
5371ea133fd7Smrg	fi
5372ea133fd7Smrg
5373ea133fd7Smrg	# This library was specified with -dlopen.
5374ea133fd7Smrg	if test "$pass" = dlopen; then
5375ea133fd7Smrg	  if test -z "$libdir"; then
5376ea133fd7Smrg	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
5377ea133fd7Smrg	  fi
5378ea133fd7Smrg	  if test -z "$dlname" ||
5379ea133fd7Smrg	     test "$dlopen_support" != yes ||
5380ea133fd7Smrg	     test "$build_libtool_libs" = no; then
5381ea133fd7Smrg	    # If there is no dlname, no dlopen support or we're linking
5382ea133fd7Smrg	    # statically, we need to preload.  We also need to preload any
5383ea133fd7Smrg	    # dependent libraries so libltdl's deplib preloader doesn't
5384ea133fd7Smrg	    # bomb out in the load deplibs phase.
5385ea133fd7Smrg	    dlprefiles="$dlprefiles $lib $dependency_libs"
5386ea133fd7Smrg	  else
5387ea133fd7Smrg	    newdlfiles="$newdlfiles $lib"
5388ea133fd7Smrg	  fi
5389ea133fd7Smrg	  continue
5390ea133fd7Smrg	fi # $pass = dlopen
5391ea133fd7Smrg
5392ea133fd7Smrg	# We need an absolute path.
5393ea133fd7Smrg	case $ladir in
5394ea133fd7Smrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
5395ea133fd7Smrg	*)
5396ea133fd7Smrg	  abs_ladir=`cd "$ladir" && pwd`
5397ea133fd7Smrg	  if test -z "$abs_ladir"; then
5398ea133fd7Smrg	    func_warning "cannot determine absolute directory name of \`$ladir'"
5399ea133fd7Smrg	    func_warning "passing it literally to the linker, although it might fail"
5400ea133fd7Smrg	    abs_ladir="$ladir"
5401ea133fd7Smrg	  fi
5402ea133fd7Smrg	  ;;
5403ea133fd7Smrg	esac
5404ea133fd7Smrg	func_basename "$lib"
5405ea133fd7Smrg	laname="$func_basename_result"
5406ea133fd7Smrg
5407ea133fd7Smrg	# Find the relevant object directory and library name.
5408ea133fd7Smrg	if test "X$installed" = Xyes; then
5409ea133fd7Smrg	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
5410ea133fd7Smrg	    func_warning "library \`$lib' was moved."
5411ea133fd7Smrg	    dir="$ladir"
5412ea133fd7Smrg	    absdir="$abs_ladir"
5413ea133fd7Smrg	    libdir="$abs_ladir"
5414ea133fd7Smrg	  else
5415ea133fd7Smrg	    dir="$libdir"
5416ea133fd7Smrg	    absdir="$libdir"
5417ea133fd7Smrg	  fi
5418ea133fd7Smrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
5419ea133fd7Smrg	else
5420ea133fd7Smrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
5421ea133fd7Smrg	    dir="$ladir"
5422ea133fd7Smrg	    absdir="$abs_ladir"
5423ea133fd7Smrg	    # Remove this search path later
5424ea133fd7Smrg	    notinst_path="$notinst_path $abs_ladir"
5425ea133fd7Smrg	  else
5426ea133fd7Smrg	    dir="$ladir/$objdir"
5427ea133fd7Smrg	    absdir="$abs_ladir/$objdir"
5428ea133fd7Smrg	    # Remove this search path later
5429ea133fd7Smrg	    notinst_path="$notinst_path $abs_ladir"
5430ea133fd7Smrg	  fi
5431ea133fd7Smrg	fi # $installed = yes
5432ea133fd7Smrg	func_stripname 'lib' '.la' "$laname"
5433ea133fd7Smrg	name=$func_stripname_result
5434ea133fd7Smrg
5435ea133fd7Smrg	# This library was specified with -dlpreopen.
5436ea133fd7Smrg	if test "$pass" = dlpreopen; then
5437ea133fd7Smrg	  if test -z "$libdir" && test "$linkmode" = prog; then
5438ea133fd7Smrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
5439ea133fd7Smrg	  fi
5440ea133fd7Smrg	  # Prefer using a static library (so that no silly _DYNAMIC symbols
5441ea133fd7Smrg	  # are required to link).
5442ea133fd7Smrg	  if test -n "$old_library"; then
5443ea133fd7Smrg	    newdlprefiles="$newdlprefiles $dir/$old_library"
5444ea133fd7Smrg	    # Keep a list of preopened convenience libraries to check
5445ea133fd7Smrg	    # that they are being used correctly in the link pass.
5446ea133fd7Smrg	    test -z "$libdir" && \
5447ea133fd7Smrg		dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library"
5448ea133fd7Smrg	  # Otherwise, use the dlname, so that lt_dlopen finds it.
5449ea133fd7Smrg	  elif test -n "$dlname"; then
5450ea133fd7Smrg	    newdlprefiles="$newdlprefiles $dir/$dlname"
5451ea133fd7Smrg	  else
5452ea133fd7Smrg	    newdlprefiles="$newdlprefiles $dir/$linklib"
5453ea133fd7Smrg	  fi
5454ea133fd7Smrg	fi # $pass = dlpreopen
5455ea133fd7Smrg
5456ea133fd7Smrg	if test -z "$libdir"; then
5457ea133fd7Smrg	  # Link the convenience library
5458ea133fd7Smrg	  if test "$linkmode" = lib; then
5459ea133fd7Smrg	    deplibs="$dir/$old_library $deplibs"
5460ea133fd7Smrg	  elif test "$linkmode,$pass" = "prog,link"; then
5461ea133fd7Smrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
5462ea133fd7Smrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
5463ea133fd7Smrg	  else
5464ea133fd7Smrg	    deplibs="$lib $deplibs" # used for prog,scan pass
5465ea133fd7Smrg	  fi
5466ea133fd7Smrg	  continue
5467ea133fd7Smrg	fi
5468ea133fd7Smrg
5469ea133fd7Smrg
5470ea133fd7Smrg	if test "$linkmode" = prog && test "$pass" != link; then
5471ea133fd7Smrg	  newlib_search_path="$newlib_search_path $ladir"
5472ea133fd7Smrg	  deplibs="$lib $deplibs"
5473ea133fd7Smrg
5474ea133fd7Smrg	  linkalldeplibs=no
5475ea133fd7Smrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
5476ea133fd7Smrg	     test "$build_libtool_libs" = no; then
5477ea133fd7Smrg	    linkalldeplibs=yes
5478ea133fd7Smrg	  fi
5479ea133fd7Smrg
5480ea133fd7Smrg	  tmp_libs=
5481ea133fd7Smrg	  for deplib in $dependency_libs; do
5482ea133fd7Smrg	    case $deplib in
5483ea133fd7Smrg	    -L*) func_stripname '-L' '' "$deplib"
5484ea133fd7Smrg	         newlib_search_path="$newlib_search_path $func_stripname_result"
5485ea133fd7Smrg		 ;;
5486ea133fd7Smrg	    esac
5487ea133fd7Smrg	    # Need to link against all dependency_libs?
5488ea133fd7Smrg	    if test "$linkalldeplibs" = yes; then
5489ea133fd7Smrg	      deplibs="$deplib $deplibs"
5490ea133fd7Smrg	    else
5491ea133fd7Smrg	      # Need to hardcode shared library paths
5492ea133fd7Smrg	      # or/and link against static libraries
5493ea133fd7Smrg	      newdependency_libs="$deplib $newdependency_libs"
5494ea133fd7Smrg	    fi
5495ea133fd7Smrg	    if $opt_duplicate_deps ; then
5496ea133fd7Smrg	      case "$tmp_libs " in
5497ea133fd7Smrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
5498ea133fd7Smrg	      esac
5499ea133fd7Smrg	    fi
5500ea133fd7Smrg	    tmp_libs="$tmp_libs $deplib"
5501ea133fd7Smrg	  done # for deplib
5502ea133fd7Smrg	  continue
5503ea133fd7Smrg	fi # $linkmode = prog...
5504ea133fd7Smrg
5505ea133fd7Smrg	if test "$linkmode,$pass" = "prog,link"; then
5506ea133fd7Smrg	  if test -n "$library_names" &&
5507ea133fd7Smrg	     { { test "$prefer_static_libs" = no ||
5508ea133fd7Smrg	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
5509ea133fd7Smrg	       test -z "$old_library"; }; then
5510ea133fd7Smrg	    # We need to hardcode the library path
5511ea133fd7Smrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
5512ea133fd7Smrg	      # Make sure the rpath contains only unique directories.
5513ea133fd7Smrg	      case "$temp_rpath:" in
5514ea133fd7Smrg	      *"$absdir:"*) ;;
5515ea133fd7Smrg	      *) temp_rpath="$temp_rpath$absdir:" ;;
5516ea133fd7Smrg	      esac
5517ea133fd7Smrg	    fi
5518ea133fd7Smrg
5519ea133fd7Smrg	    # Hardcode the library path.
5520ea133fd7Smrg	    # Skip directories that are in the system default run-time
5521ea133fd7Smrg	    # search path.
5522ea133fd7Smrg	    case " $sys_lib_dlsearch_path " in
5523ea133fd7Smrg	    *" $absdir "*) ;;
5524ea133fd7Smrg	    *)
5525ea133fd7Smrg	      case "$compile_rpath " in
5526ea133fd7Smrg	      *" $absdir "*) ;;
5527ea133fd7Smrg	      *) compile_rpath="$compile_rpath $absdir"
5528ea133fd7Smrg	      esac
5529ea133fd7Smrg	      ;;
5530ea133fd7Smrg	    esac
5531ea133fd7Smrg	    case " $sys_lib_dlsearch_path " in
5532ea133fd7Smrg	    *" $libdir "*) ;;
5533ea133fd7Smrg	    *)
5534ea133fd7Smrg	      case "$finalize_rpath " in
5535ea133fd7Smrg	      *" $libdir "*) ;;
5536ea133fd7Smrg	      *) finalize_rpath="$finalize_rpath $libdir"
5537ea133fd7Smrg	      esac
5538ea133fd7Smrg	      ;;
5539ea133fd7Smrg	    esac
5540ea133fd7Smrg	  fi # $linkmode,$pass = prog,link...
5541ea133fd7Smrg
5542ea133fd7Smrg	  if test "$alldeplibs" = yes &&
5543ea133fd7Smrg	     { test "$deplibs_check_method" = pass_all ||
5544ea133fd7Smrg	       { test "$build_libtool_libs" = yes &&
5545ea133fd7Smrg		 test -n "$library_names"; }; }; then
5546ea133fd7Smrg	    # We only need to search for static libraries
5547ea133fd7Smrg	    continue
5548ea133fd7Smrg	  fi
5549ea133fd7Smrg	fi
5550ea133fd7Smrg
5551ea133fd7Smrg	link_static=no # Whether the deplib will be linked statically
5552ea133fd7Smrg	use_static_libs=$prefer_static_libs
5553ea133fd7Smrg	if test "$use_static_libs" = built && test "$installed" = yes; then
5554ea133fd7Smrg	  use_static_libs=no
5555ea133fd7Smrg	fi
5556ea133fd7Smrg	if test -n "$library_names" &&
5557ea133fd7Smrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
5558ea133fd7Smrg	  case $host in
5559ea133fd7Smrg	  *cygwin* | *mingw* | *cegcc*)
5560ea133fd7Smrg	      # No point in relinking DLLs because paths are not encoded
5561ea133fd7Smrg	      notinst_deplibs="$notinst_deplibs $lib"
5562ea133fd7Smrg	      need_relink=no
5563ea133fd7Smrg	    ;;
5564ea133fd7Smrg	  *)
5565ea133fd7Smrg	    if test "$installed" = no; then
5566ea133fd7Smrg	      notinst_deplibs="$notinst_deplibs $lib"
5567ea133fd7Smrg	      need_relink=yes
5568ea133fd7Smrg	    fi
5569ea133fd7Smrg	    ;;
5570ea133fd7Smrg	  esac
5571ea133fd7Smrg	  # This is a shared library
5572ea133fd7Smrg
5573ea133fd7Smrg	  # Warn about portability, can't link against -module's on some
5574ea133fd7Smrg	  # systems (darwin).  Don't bleat about dlopened modules though!
5575ea133fd7Smrg	  dlopenmodule=""
5576ea133fd7Smrg	  for dlpremoduletest in $dlprefiles; do
5577ea133fd7Smrg	    if test "X$dlpremoduletest" = "X$lib"; then
5578ea133fd7Smrg	      dlopenmodule="$dlpremoduletest"
5579ea133fd7Smrg	      break
5580ea133fd7Smrg	    fi
5581ea133fd7Smrg	  done
5582ea133fd7Smrg	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
5583ea133fd7Smrg	    $ECHO
5584ea133fd7Smrg	    if test "$linkmode" = prog; then
5585ea133fd7Smrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
5586ea133fd7Smrg	    else
5587ea133fd7Smrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
5588ea133fd7Smrg	    fi
5589ea133fd7Smrg	    $ECHO "*** $linklib is not portable!"
5590ea133fd7Smrg	  fi
5591ea133fd7Smrg	  if test "$linkmode" = lib &&
5592ea133fd7Smrg	     test "$hardcode_into_libs" = yes; then
5593ea133fd7Smrg	    # Hardcode the library path.
5594ea133fd7Smrg	    # Skip directories that are in the system default run-time
5595ea133fd7Smrg	    # search path.
5596ea133fd7Smrg	    case " $sys_lib_dlsearch_path " in
5597ea133fd7Smrg	    *" $absdir "*) ;;
5598ea133fd7Smrg	    *)
5599ea133fd7Smrg	      case "$compile_rpath " in
5600ea133fd7Smrg	      *" $absdir "*) ;;
5601ea133fd7Smrg	      *) compile_rpath="$compile_rpath $absdir"
5602ea133fd7Smrg	      esac
5603ea133fd7Smrg	      ;;
5604ea133fd7Smrg	    esac
5605ea133fd7Smrg	    case " $sys_lib_dlsearch_path " in
5606ea133fd7Smrg	    *" $libdir "*) ;;
5607ea133fd7Smrg	    *)
5608ea133fd7Smrg	      case "$finalize_rpath " in
5609ea133fd7Smrg	      *" $libdir "*) ;;
5610ea133fd7Smrg	      *) finalize_rpath="$finalize_rpath $libdir"
5611ea133fd7Smrg	      esac
5612ea133fd7Smrg	      ;;
5613ea133fd7Smrg	    esac
5614ea133fd7Smrg	  fi
5615ea133fd7Smrg
5616ea133fd7Smrg	  if test -n "$old_archive_from_expsyms_cmds"; then
5617ea133fd7Smrg	    # figure out the soname
5618ea133fd7Smrg	    set dummy $library_names
5619ea133fd7Smrg	    shift
5620ea133fd7Smrg	    realname="$1"
5621ea133fd7Smrg	    shift
5622ea133fd7Smrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
5623ea133fd7Smrg	    # use dlname if we got it. it's perfectly good, no?
5624ea133fd7Smrg	    if test -n "$dlname"; then
5625ea133fd7Smrg	      soname="$dlname"
5626ea133fd7Smrg	    elif test -n "$soname_spec"; then
5627ea133fd7Smrg	      # bleh windows
5628ea133fd7Smrg	      case $host in
5629ea133fd7Smrg	      *cygwin* | mingw* | *cegcc*)
5630ea133fd7Smrg	        func_arith $current - $age
5631ea133fd7Smrg		major=$func_arith_result
5632ea133fd7Smrg		versuffix="-$major"
5633ea133fd7Smrg		;;
5634ea133fd7Smrg	      esac
5635ea133fd7Smrg	      eval soname=\"$soname_spec\"
5636ea133fd7Smrg	    else
5637ea133fd7Smrg	      soname="$realname"
5638ea133fd7Smrg	    fi
5639ea133fd7Smrg
5640ea133fd7Smrg	    # Make a new name for the extract_expsyms_cmds to use
5641ea133fd7Smrg	    soroot="$soname"
5642ea133fd7Smrg	    func_basename "$soroot"
5643ea133fd7Smrg	    soname="$func_basename_result"
5644ea133fd7Smrg	    func_stripname 'lib' '.dll' "$soname"
5645ea133fd7Smrg	    newlib=libimp-$func_stripname_result.a
5646ea133fd7Smrg
5647ea133fd7Smrg	    # If the library has no export list, then create one now
5648ea133fd7Smrg	    if test -f "$output_objdir/$soname-def"; then :
5649ea133fd7Smrg	    else
5650ea133fd7Smrg	      func_verbose "extracting exported symbol list from \`$soname'"
5651ea133fd7Smrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
5652ea133fd7Smrg	    fi
5653ea133fd7Smrg
5654ea133fd7Smrg	    # Create $newlib
5655ea133fd7Smrg	    if test -f "$output_objdir/$newlib"; then :; else
5656ea133fd7Smrg	      func_verbose "generating import library for \`$soname'"
5657ea133fd7Smrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
5658ea133fd7Smrg	    fi
5659ea133fd7Smrg	    # make sure the library variables are pointing to the new library
5660ea133fd7Smrg	    dir=$output_objdir
5661ea133fd7Smrg	    linklib=$newlib
5662ea133fd7Smrg	  fi # test -n "$old_archive_from_expsyms_cmds"
5663ea133fd7Smrg
5664ea133fd7Smrg	  if test "$linkmode" = prog || test "$mode" != relink; then
5665ea133fd7Smrg	    add_shlibpath=
5666ea133fd7Smrg	    add_dir=
5667ea133fd7Smrg	    add=
5668ea133fd7Smrg	    lib_linked=yes
5669ea133fd7Smrg	    case $hardcode_action in
5670ea133fd7Smrg	    immediate | unsupported)
5671ea133fd7Smrg	      if test "$hardcode_direct" = no; then
5672ea133fd7Smrg		add="$dir/$linklib"
5673ea133fd7Smrg		case $host in
5674ea133fd7Smrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
5675ea133fd7Smrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
5676ea133fd7Smrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
5677ea133fd7Smrg		    *-*-unixware7*) add_dir="-L$dir" ;;
5678ea133fd7Smrg		  *-*-darwin* )
5679ea133fd7Smrg		    # if the lib is a (non-dlopened) module then we can not
5680ea133fd7Smrg		    # link against it, someone is ignoring the earlier warnings
5681ea133fd7Smrg		    if /usr/bin/file -L $add 2> /dev/null |
5682ea133fd7Smrg			 $GREP ": [^:]* bundle" >/dev/null ; then
5683ea133fd7Smrg		      if test "X$dlopenmodule" != "X$lib"; then
5684ea133fd7Smrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
5685ea133fd7Smrg			if test -z "$old_library" ; then
5686ea133fd7Smrg			  $ECHO
5687ea133fd7Smrg			  $ECHO "*** And there doesn't seem to be a static archive available"
5688ea133fd7Smrg			  $ECHO "*** The link will probably fail, sorry"
5689ea133fd7Smrg			else
5690ea133fd7Smrg			  add="$dir/$old_library"
5691ea133fd7Smrg			fi
5692ea133fd7Smrg		      elif test -n "$old_library"; then
5693ea133fd7Smrg			add="$dir/$old_library"
5694ea133fd7Smrg		      fi
5695ea133fd7Smrg		    fi
5696ea133fd7Smrg		esac
5697ea133fd7Smrg	      elif test "$hardcode_minus_L" = no; then
5698ea133fd7Smrg		case $host in
5699ea133fd7Smrg		*-*-sunos*) add_shlibpath="$dir" ;;
5700ea133fd7Smrg		esac
5701ea133fd7Smrg		add_dir="-L$dir"
5702ea133fd7Smrg		add="-l$name"
5703ea133fd7Smrg	      elif test "$hardcode_shlibpath_var" = no; then
5704ea133fd7Smrg		add_shlibpath="$dir"
5705ea133fd7Smrg		add="-l$name"
5706ea133fd7Smrg	      else
5707ea133fd7Smrg		lib_linked=no
5708ea133fd7Smrg	      fi
5709ea133fd7Smrg	      ;;
5710ea133fd7Smrg	    relink)
5711ea133fd7Smrg	      if test "$hardcode_direct" = yes &&
5712ea133fd7Smrg	         test "$hardcode_direct_absolute" = no; then
5713ea133fd7Smrg		add="$dir/$linklib"
5714ea133fd7Smrg	      elif test "$hardcode_minus_L" = yes; then
5715ea133fd7Smrg		add_dir="-L$dir"
5716ea133fd7Smrg		# Try looking first in the location we're being installed to.
5717ea133fd7Smrg		if test -n "$inst_prefix_dir"; then
5718ea133fd7Smrg		  case $libdir in
5719ea133fd7Smrg		    [\\/]*)
5720ea133fd7Smrg		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
5721ea133fd7Smrg		      ;;
5722ea133fd7Smrg		  esac
5723ea133fd7Smrg		fi
5724ea133fd7Smrg		add="-l$name"
5725ea133fd7Smrg	      elif test "$hardcode_shlibpath_var" = yes; then
5726ea133fd7Smrg		add_shlibpath="$dir"
5727ea133fd7Smrg		add="-l$name"
5728ea133fd7Smrg	      else
5729ea133fd7Smrg		lib_linked=no
5730ea133fd7Smrg	      fi
5731ea133fd7Smrg	      ;;
5732ea133fd7Smrg	    *) lib_linked=no ;;
5733ea133fd7Smrg	    esac
5734ea133fd7Smrg
5735ea133fd7Smrg	    if test "$lib_linked" != yes; then
5736ea133fd7Smrg	      func_fatal_configuration "unsupported hardcode properties"
5737ea133fd7Smrg	    fi
5738ea133fd7Smrg
5739ea133fd7Smrg	    if test -n "$add_shlibpath"; then
5740ea133fd7Smrg	      case :$compile_shlibpath: in
5741ea133fd7Smrg	      *":$add_shlibpath:"*) ;;
5742ea133fd7Smrg	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
5743ea133fd7Smrg	      esac
5744ea133fd7Smrg	    fi
5745ea133fd7Smrg	    if test "$linkmode" = prog; then
5746ea133fd7Smrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
5747ea133fd7Smrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
5748ea133fd7Smrg	    else
5749ea133fd7Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
5750ea133fd7Smrg	      test -n "$add" && deplibs="$add $deplibs"
5751ea133fd7Smrg	      if test "$hardcode_direct" != yes &&
5752ea133fd7Smrg		 test "$hardcode_minus_L" != yes &&
5753ea133fd7Smrg		 test "$hardcode_shlibpath_var" = yes; then
5754ea133fd7Smrg		case :$finalize_shlibpath: in
5755ea133fd7Smrg		*":$libdir:"*) ;;
5756ea133fd7Smrg		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
5757ea133fd7Smrg		esac
5758ea133fd7Smrg	      fi
5759ea133fd7Smrg	    fi
5760ea133fd7Smrg	  fi
5761ea133fd7Smrg
5762ea133fd7Smrg	  if test "$linkmode" = prog || test "$mode" = relink; then
5763ea133fd7Smrg	    add_shlibpath=
5764ea133fd7Smrg	    add_dir=
5765ea133fd7Smrg	    add=
5766ea133fd7Smrg	    # Finalize command for both is simple: just hardcode it.
5767ea133fd7Smrg	    if test "$hardcode_direct" = yes &&
5768ea133fd7Smrg	       test "$hardcode_direct_absolute" = no; then
5769ea133fd7Smrg	      add="$libdir/$linklib"
5770ea133fd7Smrg	    elif test "$hardcode_minus_L" = yes; then
5771ea133fd7Smrg	      add_dir="-L$libdir"
5772ea133fd7Smrg	      add="-l$name"
5773ea133fd7Smrg	    elif test "$hardcode_shlibpath_var" = yes; then
5774ea133fd7Smrg	      case :$finalize_shlibpath: in
5775ea133fd7Smrg	      *":$libdir:"*) ;;
5776ea133fd7Smrg	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
5777ea133fd7Smrg	      esac
5778ea133fd7Smrg	      add="-l$name"
5779ea133fd7Smrg	    elif test "$hardcode_automatic" = yes; then
5780ea133fd7Smrg	      if test -n "$inst_prefix_dir" &&
5781ea133fd7Smrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
5782ea133fd7Smrg		add="$inst_prefix_dir$libdir/$linklib"
5783ea133fd7Smrg	      else
5784ea133fd7Smrg		add="$libdir/$linklib"
5785ea133fd7Smrg	      fi
5786ea133fd7Smrg	    else
5787ea133fd7Smrg	      # We cannot seem to hardcode it, guess we'll fake it.
5788ea133fd7Smrg	      add_dir="-L$libdir"
5789ea133fd7Smrg	      # Try looking first in the location we're being installed to.
5790ea133fd7Smrg	      if test -n "$inst_prefix_dir"; then
5791ea133fd7Smrg		case $libdir in
5792ea133fd7Smrg		  [\\/]*)
5793ea133fd7Smrg		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
5794ea133fd7Smrg		    ;;
5795ea133fd7Smrg		esac
5796ea133fd7Smrg	      fi
5797ea133fd7Smrg	      add="-l$name"
5798ea133fd7Smrg	    fi
5799ea133fd7Smrg
5800ea133fd7Smrg	    if test "$linkmode" = prog; then
5801ea133fd7Smrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
5802ea133fd7Smrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
5803ea133fd7Smrg	    else
5804ea133fd7Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
5805ea133fd7Smrg	      test -n "$add" && deplibs="$add $deplibs"
5806ea133fd7Smrg	    fi
5807ea133fd7Smrg	  fi
5808ea133fd7Smrg	elif test "$linkmode" = prog; then
5809ea133fd7Smrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
5810ea133fd7Smrg	  # is not unsupported.  This is valid on all known static and
5811ea133fd7Smrg	  # shared platforms.
5812ea133fd7Smrg	  if test "$hardcode_direct" != unsupported; then
5813ea133fd7Smrg	    test -n "$old_library" && linklib="$old_library"
5814ea133fd7Smrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
5815ea133fd7Smrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
5816ea133fd7Smrg	  else
5817ea133fd7Smrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
5818ea133fd7Smrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
5819ea133fd7Smrg	  fi
5820ea133fd7Smrg	elif test "$build_libtool_libs" = yes; then
5821ea133fd7Smrg	  # Not a shared library
5822ea133fd7Smrg	  if test "$deplibs_check_method" != pass_all; then
5823ea133fd7Smrg	    # We're trying link a shared library against a static one
5824ea133fd7Smrg	    # but the system doesn't support it.
5825ea133fd7Smrg
5826ea133fd7Smrg	    # Just print a warning and add the library to dependency_libs so
5827ea133fd7Smrg	    # that the program can be linked against the static library.
5828ea133fd7Smrg	    $ECHO
5829ea133fd7Smrg	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
5830ea133fd7Smrg	    $ECHO "*** I have the capability to make that library automatically link in when"
5831ea133fd7Smrg	    $ECHO "*** you link to this library.  But I can only do this if you have a"
5832ea133fd7Smrg	    $ECHO "*** shared version of the library, which you do not appear to have."
5833ea133fd7Smrg	    if test "$module" = yes; then
5834ea133fd7Smrg	      $ECHO "*** But as you try to build a module library, libtool will still create "
5835ea133fd7Smrg	      $ECHO "*** a static module, that should work as long as the dlopening application"
5836ea133fd7Smrg	      $ECHO "*** is linked with the -dlopen flag to resolve symbols at runtime."
5837ea133fd7Smrg	      if test -z "$global_symbol_pipe"; then
5838ea133fd7Smrg		$ECHO
5839ea133fd7Smrg		$ECHO "*** However, this would only work if libtool was able to extract symbol"
5840ea133fd7Smrg		$ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
5841ea133fd7Smrg		$ECHO "*** not find such a program.  So, this module is probably useless."
5842ea133fd7Smrg		$ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
5843ea133fd7Smrg	      fi
5844ea133fd7Smrg	      if test "$build_old_libs" = no; then
5845ea133fd7Smrg		build_libtool_libs=module
5846ea133fd7Smrg		build_old_libs=yes
5847ea133fd7Smrg	      else
5848ea133fd7Smrg		build_libtool_libs=no
5849ea133fd7Smrg	      fi
5850ea133fd7Smrg	    fi
5851ea133fd7Smrg	  else
5852ea133fd7Smrg	    deplibs="$dir/$old_library $deplibs"
5853ea133fd7Smrg	    link_static=yes
5854ea133fd7Smrg	  fi
5855ea133fd7Smrg	fi # link shared/static library?
5856ea133fd7Smrg
5857ea133fd7Smrg	if test "$linkmode" = lib; then
5858ea133fd7Smrg	  if test -n "$dependency_libs" &&
5859ea133fd7Smrg	     { test "$hardcode_into_libs" != yes ||
5860ea133fd7Smrg	       test "$build_old_libs" = yes ||
5861ea133fd7Smrg	       test "$link_static" = yes; }; then
5862ea133fd7Smrg	    # Extract -R from dependency_libs
5863ea133fd7Smrg	    temp_deplibs=
5864ea133fd7Smrg	    for libdir in $dependency_libs; do
5865ea133fd7Smrg	      case $libdir in
5866ea133fd7Smrg	      -R*) func_stripname '-R' '' "$libdir"
5867ea133fd7Smrg	           temp_xrpath=$func_stripname_result
5868ea133fd7Smrg		   case " $xrpath " in
5869ea133fd7Smrg		   *" $temp_xrpath "*) ;;
5870ea133fd7Smrg		   *) xrpath="$xrpath $temp_xrpath";;
5871ea133fd7Smrg		   esac;;
5872ea133fd7Smrg	      *) temp_deplibs="$temp_deplibs $libdir";;
5873ea133fd7Smrg	      esac
5874ea133fd7Smrg	    done
5875ea133fd7Smrg	    dependency_libs="$temp_deplibs"
5876ea133fd7Smrg	  fi
5877ea133fd7Smrg
5878ea133fd7Smrg	  newlib_search_path="$newlib_search_path $absdir"
5879ea133fd7Smrg	  # Link against this library
5880ea133fd7Smrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
5881ea133fd7Smrg	  # ... and its dependency_libs
5882ea133fd7Smrg	  tmp_libs=
5883ea133fd7Smrg	  for deplib in $dependency_libs; do
5884ea133fd7Smrg	    newdependency_libs="$deplib $newdependency_libs"
5885ea133fd7Smrg	    if $opt_duplicate_deps ; then
5886ea133fd7Smrg	      case "$tmp_libs " in
5887ea133fd7Smrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
5888ea133fd7Smrg	      esac
5889ea133fd7Smrg	    fi
5890ea133fd7Smrg	    tmp_libs="$tmp_libs $deplib"
5891ea133fd7Smrg	  done
5892ea133fd7Smrg
5893ea133fd7Smrg	  if test "$link_all_deplibs" != no; then
5894ea133fd7Smrg	    # Add the search paths of all dependency libraries
5895ea133fd7Smrg	    for deplib in $dependency_libs; do
5896ea133fd7Smrg	      case $deplib in
5897ea133fd7Smrg	      -L*) path="$deplib" ;;
5898ea133fd7Smrg	      *.la)
5899ea133fd7Smrg	        func_dirname "$deplib" "" "."
5900ea133fd7Smrg		dir="$func_dirname_result"
5901ea133fd7Smrg		# We need an absolute path.
5902ea133fd7Smrg		case $dir in
5903ea133fd7Smrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
5904ea133fd7Smrg		*)
5905ea133fd7Smrg		  absdir=`cd "$dir" && pwd`
5906ea133fd7Smrg		  if test -z "$absdir"; then
5907ea133fd7Smrg		    func_warning "cannot determine absolute directory name of \`$dir'"
5908ea133fd7Smrg		    absdir="$dir"
5909ea133fd7Smrg		  fi
5910ea133fd7Smrg		  ;;
5911ea133fd7Smrg		esac
5912ea133fd7Smrg		if $GREP "^installed=no" $deplib > /dev/null; then
5913ea133fd7Smrg		case $host in
5914ea133fd7Smrg		*-*-darwin*)
5915ea133fd7Smrg		  depdepl=
5916ea133fd7Smrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
5917ea133fd7Smrg		  if test -n "$deplibrary_names" ; then
5918ea133fd7Smrg		    for tmp in $deplibrary_names ; do
5919ea133fd7Smrg		      depdepl=$tmp
5920ea133fd7Smrg		    done
5921ea133fd7Smrg		    if test -f "$absdir/$objdir/$depdepl" ; then
5922ea133fd7Smrg		      depdepl="$absdir/$objdir/$depdepl"
5923ea133fd7Smrg		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
5924ea133fd7Smrg                      if test -z "$darwin_install_name"; then
5925ea133fd7Smrg                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
5926ea133fd7Smrg                      fi
5927ea133fd7Smrg		      compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
5928ea133fd7Smrg		      linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}"
5929ea133fd7Smrg		      path=
5930ea133fd7Smrg		    fi
5931ea133fd7Smrg		  fi
5932ea133fd7Smrg		  ;;
5933ea133fd7Smrg		*)
5934ea133fd7Smrg		  path="-L$absdir/$objdir"
5935ea133fd7Smrg		  ;;
5936ea133fd7Smrg		esac
5937ea133fd7Smrg		else
5938ea133fd7Smrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
5939ea133fd7Smrg		  test -z "$libdir" && \
5940ea133fd7Smrg		    func_fatal_error "\`$deplib' is not a valid libtool archive"
5941ea133fd7Smrg		  test "$absdir" != "$libdir" && \
5942ea133fd7Smrg		    func_warning "\`$deplib' seems to be moved"
5943ea133fd7Smrg
5944ea133fd7Smrg		  path="-L$absdir"
5945ea133fd7Smrg		fi
5946ea133fd7Smrg		;;
5947ea133fd7Smrg	      esac
5948ea133fd7Smrg	      case " $deplibs " in
5949ea133fd7Smrg	      *" $path "*) ;;
5950ea133fd7Smrg	      *) deplibs="$path $deplibs" ;;
5951ea133fd7Smrg	      esac
5952ea133fd7Smrg	    done
5953ea133fd7Smrg	  fi # link_all_deplibs != no
5954ea133fd7Smrg	fi # linkmode = lib
5955ea133fd7Smrg      done # for deplib in $libs
5956ea133fd7Smrg      if test "$pass" = link; then
5957ea133fd7Smrg	if test "$linkmode" = "prog"; then
5958ea133fd7Smrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
5959ea133fd7Smrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
5960ea133fd7Smrg	else
5961ea133fd7Smrg	  compiler_flags="$compiler_flags "`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
5962ea133fd7Smrg	fi
5963ea133fd7Smrg      fi
5964ea133fd7Smrg      dependency_libs="$newdependency_libs"
5965ea133fd7Smrg      if test "$pass" = dlpreopen; then
5966ea133fd7Smrg	# Link the dlpreopened libraries before other libraries
5967ea133fd7Smrg	for deplib in $save_deplibs; do
5968ea133fd7Smrg	  deplibs="$deplib $deplibs"
5969ea133fd7Smrg	done
5970ea133fd7Smrg      fi
5971ea133fd7Smrg      if test "$pass" != dlopen; then
5972ea133fd7Smrg	if test "$pass" != conv; then
5973ea133fd7Smrg	  # Make sure lib_search_path contains only unique directories.
5974ea133fd7Smrg	  lib_search_path=
5975ea133fd7Smrg	  for dir in $newlib_search_path; do
5976ea133fd7Smrg	    case "$lib_search_path " in
5977ea133fd7Smrg	    *" $dir "*) ;;
5978ea133fd7Smrg	    *) lib_search_path="$lib_search_path $dir" ;;
5979ea133fd7Smrg	    esac
5980ea133fd7Smrg	  done
5981ea133fd7Smrg	  newlib_search_path=
5982ea133fd7Smrg	fi
5983ea133fd7Smrg
5984ea133fd7Smrg	if test "$linkmode,$pass" != "prog,link"; then
5985ea133fd7Smrg	  vars="deplibs"
5986ea133fd7Smrg	else
5987ea133fd7Smrg	  vars="compile_deplibs finalize_deplibs"
5988ea133fd7Smrg	fi
5989ea133fd7Smrg	for var in $vars dependency_libs; do
5990ea133fd7Smrg	  # Add libraries to $var in reverse order
5991ea133fd7Smrg	  eval tmp_libs=\"\$$var\"
5992ea133fd7Smrg	  new_libs=
5993ea133fd7Smrg	  for deplib in $tmp_libs; do
5994ea133fd7Smrg	    # FIXME: Pedantically, this is the right thing to do, so
5995ea133fd7Smrg	    #        that some nasty dependency loop isn't accidentally
5996ea133fd7Smrg	    #        broken:
5997ea133fd7Smrg	    #new_libs="$deplib $new_libs"
5998ea133fd7Smrg	    # Pragmatically, this seems to cause very few problems in
5999ea133fd7Smrg	    # practice:
6000ea133fd7Smrg	    case $deplib in
6001ea133fd7Smrg	    -L*) new_libs="$deplib $new_libs" ;;
6002ea133fd7Smrg	    -R*) ;;
6003ea133fd7Smrg	    *)
6004ea133fd7Smrg	      # And here is the reason: when a library appears more
6005ea133fd7Smrg	      # than once as an explicit dependence of a library, or
6006ea133fd7Smrg	      # is implicitly linked in more than once by the
6007ea133fd7Smrg	      # compiler, it is considered special, and multiple
6008ea133fd7Smrg	      # occurrences thereof are not removed.  Compare this
6009ea133fd7Smrg	      # with having the same library being listed as a
6010ea133fd7Smrg	      # dependency of multiple other libraries: in this case,
6011ea133fd7Smrg	      # we know (pedantically, we assume) the library does not
6012ea133fd7Smrg	      # need to be listed more than once, so we keep only the
6013ea133fd7Smrg	      # last copy.  This is not always right, but it is rare
6014ea133fd7Smrg	      # enough that we require users that really mean to play
6015ea133fd7Smrg	      # such unportable linking tricks to link the library
6016ea133fd7Smrg	      # using -Wl,-lname, so that libtool does not consider it
6017ea133fd7Smrg	      # for duplicate removal.
6018ea133fd7Smrg	      case " $specialdeplibs " in
6019ea133fd7Smrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
6020ea133fd7Smrg	      *)
6021ea133fd7Smrg		case " $new_libs " in
6022ea133fd7Smrg		*" $deplib "*) ;;
6023ea133fd7Smrg		*) new_libs="$deplib $new_libs" ;;
6024ea133fd7Smrg		esac
6025ea133fd7Smrg		;;
6026ea133fd7Smrg	      esac
6027ea133fd7Smrg	      ;;
6028ea133fd7Smrg	    esac
6029ea133fd7Smrg	  done
6030ea133fd7Smrg	  tmp_libs=
6031ea133fd7Smrg	  for deplib in $new_libs; do
6032ea133fd7Smrg	    case $deplib in
6033ea133fd7Smrg	    -L*)
6034ea133fd7Smrg	      case " $tmp_libs " in
6035ea133fd7Smrg	      *" $deplib "*) ;;
6036ea133fd7Smrg	      *) tmp_libs="$tmp_libs $deplib" ;;
6037ea133fd7Smrg	      esac
6038ea133fd7Smrg	      ;;
6039ea133fd7Smrg	    *) tmp_libs="$tmp_libs $deplib" ;;
6040ea133fd7Smrg	    esac
6041ea133fd7Smrg	  done
6042ea133fd7Smrg	  eval $var=\"$tmp_libs\"
6043ea133fd7Smrg	done # for var
6044ea133fd7Smrg      fi
6045ea133fd7Smrg      # Last step: remove runtime libs from dependency_libs
6046ea133fd7Smrg      # (they stay in deplibs)
6047ea133fd7Smrg      tmp_libs=
6048ea133fd7Smrg      for i in $dependency_libs ; do
6049ea133fd7Smrg	case " $predeps $postdeps $compiler_lib_search_path " in
6050ea133fd7Smrg	*" $i "*)
6051ea133fd7Smrg	  i=""
6052ea133fd7Smrg	  ;;
6053ea133fd7Smrg	esac
6054ea133fd7Smrg	if test -n "$i" ; then
6055ea133fd7Smrg	  tmp_libs="$tmp_libs $i"
6056ea133fd7Smrg	fi
6057ea133fd7Smrg      done
6058ea133fd7Smrg      dependency_libs=$tmp_libs
6059ea133fd7Smrg    done # for pass
6060ea133fd7Smrg    if test "$linkmode" = prog; then
6061ea133fd7Smrg      dlfiles="$newdlfiles"
6062ea133fd7Smrg    fi
6063ea133fd7Smrg    if test "$linkmode" = prog || test "$linkmode" = lib; then
6064ea133fd7Smrg      dlprefiles="$newdlprefiles"
6065ea133fd7Smrg    fi
6066ea133fd7Smrg
6067ea133fd7Smrg    case $linkmode in
6068ea133fd7Smrg    oldlib)
6069ea133fd7Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
6070ea133fd7Smrg	func_warning "\`-dlopen' is ignored for archives"
6071ea133fd7Smrg      fi
6072ea133fd7Smrg
6073ea133fd7Smrg      case " $deplibs" in
6074ea133fd7Smrg      *\ -l* | *\ -L*)
6075ea133fd7Smrg	func_warning "\`-l' and \`-L' are ignored for archives" ;;
6076ea133fd7Smrg      esac
6077ea133fd7Smrg
6078ea133fd7Smrg      test -n "$rpath" && \
6079ea133fd7Smrg	func_warning "\`-rpath' is ignored for archives"
6080ea133fd7Smrg
6081ea133fd7Smrg      test -n "$xrpath" && \
6082ea133fd7Smrg	func_warning "\`-R' is ignored for archives"
6083ea133fd7Smrg
6084ea133fd7Smrg      test -n "$vinfo" && \
6085ea133fd7Smrg	func_warning "\`-version-info/-version-number' is ignored for archives"
6086ea133fd7Smrg
6087ea133fd7Smrg      test -n "$release" && \
6088ea133fd7Smrg	func_warning "\`-release' is ignored for archives"
6089ea133fd7Smrg
6090ea133fd7Smrg      test -n "$export_symbols$export_symbols_regex" && \
6091ea133fd7Smrg	func_warning "\`-export-symbols' is ignored for archives"
6092ea133fd7Smrg
6093ea133fd7Smrg      # Now set the variables for building old libraries.
6094ea133fd7Smrg      build_libtool_libs=no
6095ea133fd7Smrg      oldlibs="$output"
6096ea133fd7Smrg      objs="$objs$old_deplibs"
6097ea133fd7Smrg      ;;
6098ea133fd7Smrg
6099ea133fd7Smrg    lib)
6100ea133fd7Smrg      # Make sure we only generate libraries of the form `libNAME.la'.
6101ea133fd7Smrg      case $outputname in
6102ea133fd7Smrg      lib*)
6103ea133fd7Smrg	func_stripname 'lib' '.la' "$outputname"
6104ea133fd7Smrg	name=$func_stripname_result
6105ea133fd7Smrg	eval shared_ext=\"$shrext_cmds\"
6106ea133fd7Smrg	eval libname=\"$libname_spec\"
6107ea133fd7Smrg	;;
6108ea133fd7Smrg      *)
6109ea133fd7Smrg	test "$module" = no && \
6110ea133fd7Smrg	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
6111ea133fd7Smrg
6112ea133fd7Smrg	if test "$need_lib_prefix" != no; then
6113ea133fd7Smrg	  # Add the "lib" prefix for modules if required
6114ea133fd7Smrg	  func_stripname '' '.la' "$outputname"
6115ea133fd7Smrg	  name=$func_stripname_result
6116ea133fd7Smrg	  eval shared_ext=\"$shrext_cmds\"
6117ea133fd7Smrg	  eval libname=\"$libname_spec\"
6118ea133fd7Smrg	else
6119ea133fd7Smrg	  func_stripname '' '.la' "$outputname"
6120ea133fd7Smrg	  libname=$func_stripname_result
6121ea133fd7Smrg	fi
6122ea133fd7Smrg	;;
6123ea133fd7Smrg      esac
6124ea133fd7Smrg
6125ea133fd7Smrg      if test -n "$objs"; then
6126ea133fd7Smrg	if test "$deplibs_check_method" != pass_all; then
6127ea133fd7Smrg	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
6128ea133fd7Smrg	else
6129ea133fd7Smrg	  $ECHO
6130ea133fd7Smrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
6131ea133fd7Smrg	  $ECHO "*** objects $objs is not portable!"
6132ea133fd7Smrg	  libobjs="$libobjs $objs"
6133ea133fd7Smrg	fi
6134ea133fd7Smrg      fi
6135ea133fd7Smrg
6136ea133fd7Smrg      test "$dlself" != no && \
6137ea133fd7Smrg	func_warning "\`-dlopen self' is ignored for libtool libraries"
6138ea133fd7Smrg
6139ea133fd7Smrg      set dummy $rpath
6140ea133fd7Smrg      shift
6141ea133fd7Smrg      test "$#" -gt 1 && \
6142ea133fd7Smrg	func_warning "ignoring multiple \`-rpath's for a libtool library"
6143ea133fd7Smrg
6144ea133fd7Smrg      install_libdir="$1"
6145ea133fd7Smrg
6146ea133fd7Smrg      oldlibs=
6147ea133fd7Smrg      if test -z "$rpath"; then
6148ea133fd7Smrg	if test "$build_libtool_libs" = yes; then
6149ea133fd7Smrg	  # Building a libtool convenience library.
6150ea133fd7Smrg	  # Some compilers have problems with a `.al' extension so
6151ea133fd7Smrg	  # convenience libraries should have the same extension an
6152ea133fd7Smrg	  # archive normally would.
6153ea133fd7Smrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
6154ea133fd7Smrg	  build_libtool_libs=convenience
6155ea133fd7Smrg	  build_old_libs=yes
6156ea133fd7Smrg	fi
6157ea133fd7Smrg
6158ea133fd7Smrg	test -n "$vinfo" && \
6159ea133fd7Smrg	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
6160ea133fd7Smrg
6161ea133fd7Smrg	test -n "$release" && \
6162ea133fd7Smrg	  func_warning "\`-release' is ignored for convenience libraries"
6163ea133fd7Smrg      else
6164ea133fd7Smrg
6165ea133fd7Smrg	# Parse the version information argument.
6166ea133fd7Smrg	save_ifs="$IFS"; IFS=':'
6167ea133fd7Smrg	set dummy $vinfo 0 0 0
6168ea133fd7Smrg	shift
6169ea133fd7Smrg	IFS="$save_ifs"
6170ea133fd7Smrg
6171ea133fd7Smrg	test -n "$7" && \
6172ea133fd7Smrg	  func_fatal_help "too many parameters to \`-version-info'"
6173ea133fd7Smrg
6174ea133fd7Smrg	# convert absolute version numbers to libtool ages
6175ea133fd7Smrg	# this retains compatibility with .la files and attempts
6176ea133fd7Smrg	# to make the code below a bit more comprehensible
6177ea133fd7Smrg
6178ea133fd7Smrg	case $vinfo_number in
6179ea133fd7Smrg	yes)
6180ea133fd7Smrg	  number_major="$1"
6181ea133fd7Smrg	  number_minor="$2"
6182ea133fd7Smrg	  number_revision="$3"
6183ea133fd7Smrg	  #
6184ea133fd7Smrg	  # There are really only two kinds -- those that
6185ea133fd7Smrg	  # use the current revision as the major version
6186ea133fd7Smrg	  # and those that subtract age and use age as
6187ea133fd7Smrg	  # a minor version.  But, then there is irix
6188ea133fd7Smrg	  # which has an extra 1 added just for fun
6189ea133fd7Smrg	  #
6190ea133fd7Smrg	  case $version_type in
6191ea133fd7Smrg	  darwin|linux|osf|windows|none)
6192ea133fd7Smrg	    func_arith $number_major + $number_minor
6193ea133fd7Smrg	    current=$func_arith_result
6194ea133fd7Smrg	    age="$number_minor"
6195ea133fd7Smrg	    revision="$number_revision"
6196ea133fd7Smrg	    ;;
6197ea133fd7Smrg	  freebsd-aout|freebsd-elf|sunos)
6198ea133fd7Smrg	    current="$number_major"
6199ea133fd7Smrg	    revision="$number_minor"
6200ea133fd7Smrg	    age="0"
6201ea133fd7Smrg	    ;;
6202ea133fd7Smrg	  irix|nonstopux)
6203ea133fd7Smrg	    func_arith $number_major + $number_minor
6204ea133fd7Smrg	    current=$func_arith_result
6205ea133fd7Smrg	    age="$number_minor"
6206ea133fd7Smrg	    revision="$number_minor"
6207ea133fd7Smrg	    lt_irix_increment=no
6208ea133fd7Smrg	    ;;
6209ea133fd7Smrg	  esac
6210ea133fd7Smrg	  ;;
6211ea133fd7Smrg	no)
6212ea133fd7Smrg	  current="$1"
6213ea133fd7Smrg	  revision="$2"
6214ea133fd7Smrg	  age="$3"
6215ea133fd7Smrg	  ;;
6216ea133fd7Smrg	esac
6217ea133fd7Smrg
6218ea133fd7Smrg	# Check that each of the things are valid numbers.
6219ea133fd7Smrg	case $current in
6220ea133fd7Smrg	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]) ;;
6221ea133fd7Smrg	*)
6222ea133fd7Smrg	  func_error "CURRENT \`$current' must be a nonnegative integer"
6223ea133fd7Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
6224ea133fd7Smrg	  ;;
6225ea133fd7Smrg	esac
6226ea133fd7Smrg
6227ea133fd7Smrg	case $revision in
6228ea133fd7Smrg	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]) ;;
6229ea133fd7Smrg	*)
6230ea133fd7Smrg	  func_error "REVISION \`$revision' must be a nonnegative integer"
6231ea133fd7Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
6232ea133fd7Smrg	  ;;
6233ea133fd7Smrg	esac
6234ea133fd7Smrg
6235ea133fd7Smrg	case $age in
6236ea133fd7Smrg	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]) ;;
6237ea133fd7Smrg	*)
6238ea133fd7Smrg	  func_error "AGE \`$age' must be a nonnegative integer"
6239ea133fd7Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
6240ea133fd7Smrg	  ;;
6241ea133fd7Smrg	esac
6242ea133fd7Smrg
6243ea133fd7Smrg	if test "$age" -gt "$current"; then
6244ea133fd7Smrg	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
6245ea133fd7Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
6246ea133fd7Smrg	fi
6247ea133fd7Smrg
6248ea133fd7Smrg	# Calculate the version variables.
6249ea133fd7Smrg	major=
6250ea133fd7Smrg	versuffix=
6251ea133fd7Smrg	verstring=
6252ea133fd7Smrg	case $version_type in
6253ea133fd7Smrg	none) ;;
6254ea133fd7Smrg
6255ea133fd7Smrg	darwin)
6256ea133fd7Smrg	  # Like Linux, but with the current version available in
6257ea133fd7Smrg	  # verstring for coding it into the library header
6258ea133fd7Smrg	  func_arith $current - $age
6259ea133fd7Smrg	  major=.$func_arith_result
6260ea133fd7Smrg	  versuffix="$major.$age.$revision"
6261ea133fd7Smrg	  # Darwin ld doesn't like 0 for these options...
6262ea133fd7Smrg	  func_arith $current + 1
6263ea133fd7Smrg	  minor_current=$func_arith_result
6264ea133fd7Smrg	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
6265ea133fd7Smrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
6266ea133fd7Smrg	  ;;
6267ea133fd7Smrg
6268ea133fd7Smrg	freebsd-aout)
6269ea133fd7Smrg	  major=".$current"
6270ea133fd7Smrg	  versuffix=".$current.$revision";
6271ea133fd7Smrg	  ;;
6272ea133fd7Smrg
6273ea133fd7Smrg	freebsd-elf)
6274ea133fd7Smrg	  major=".$current"
6275ea133fd7Smrg	  versuffix=".$current"
6276ea133fd7Smrg	  ;;
6277ea133fd7Smrg
6278ea133fd7Smrg	irix | nonstopux)
6279ea133fd7Smrg	  if test "X$lt_irix_increment" = "Xno"; then
6280ea133fd7Smrg	    func_arith $current - $age
6281ea133fd7Smrg	  else
6282ea133fd7Smrg	    func_arith $current - $age + 1
6283ea133fd7Smrg	  fi
6284ea133fd7Smrg	  major=$func_arith_result
6285ea133fd7Smrg
6286ea133fd7Smrg	  case $version_type in
6287ea133fd7Smrg	    nonstopux) verstring_prefix=nonstopux ;;
6288ea133fd7Smrg	    *)         verstring_prefix=sgi ;;
6289ea133fd7Smrg	  esac
6290ea133fd7Smrg	  verstring="$verstring_prefix$major.$revision"
6291ea133fd7Smrg
6292ea133fd7Smrg	  # Add in all the interfaces that we are compatible with.
6293ea133fd7Smrg	  loop=$revision
6294ea133fd7Smrg	  while test "$loop" -ne 0; do
6295ea133fd7Smrg	    func_arith $revision - $loop
6296ea133fd7Smrg	    iface=$func_arith_result
6297ea133fd7Smrg	    func_arith $loop - 1
6298ea133fd7Smrg	    loop=$func_arith_result
6299ea133fd7Smrg	    verstring="$verstring_prefix$major.$iface:$verstring"
6300ea133fd7Smrg	  done
6301ea133fd7Smrg
6302ea133fd7Smrg	  # Before this point, $major must not contain `.'.
6303ea133fd7Smrg	  major=.$major
6304ea133fd7Smrg	  versuffix="$major.$revision"
6305ea133fd7Smrg	  ;;
6306ea133fd7Smrg
6307ea133fd7Smrg	linux)
6308ea133fd7Smrg	  func_arith $current - $age
6309ea133fd7Smrg	  major=.$func_arith_result
6310ea133fd7Smrg	  versuffix="$major.$age.$revision"
6311ea133fd7Smrg	  ;;
6312ea133fd7Smrg
6313ea133fd7Smrg	osf)
6314ea133fd7Smrg	  func_arith $current - $age
6315ea133fd7Smrg	  major=.$func_arith_result
6316ea133fd7Smrg	  versuffix=".$current.$age.$revision"
6317ea133fd7Smrg	  verstring="$current.$age.$revision"
6318ea133fd7Smrg
6319ea133fd7Smrg	  # Add in all the interfaces that we are compatible with.
6320ea133fd7Smrg	  loop=$age
6321ea133fd7Smrg	  while test "$loop" -ne 0; do
6322ea133fd7Smrg	    func_arith $current - $loop
6323ea133fd7Smrg	    iface=$func_arith_result
6324ea133fd7Smrg	    func_arith $loop - 1
6325ea133fd7Smrg	    loop=$func_arith_result
6326ea133fd7Smrg	    verstring="$verstring:${iface}.0"
6327ea133fd7Smrg	  done
6328ea133fd7Smrg
6329ea133fd7Smrg	  # Make executables depend on our current version.
6330ea133fd7Smrg	  verstring="$verstring:${current}.0"
6331ea133fd7Smrg	  ;;
6332ea133fd7Smrg
6333ea133fd7Smrg	qnx)
6334ea133fd7Smrg	  major=".$current"
6335ea133fd7Smrg	  versuffix=".$current"
6336ea133fd7Smrg	  ;;
6337ea133fd7Smrg
6338ea133fd7Smrg	sunos)
6339ea133fd7Smrg	  major=".$current"
6340ea133fd7Smrg	  versuffix=".$current.$revision"
6341ea133fd7Smrg	  ;;
6342ea133fd7Smrg
6343ea133fd7Smrg	windows)
6344ea133fd7Smrg	  # Use '-' rather than '.', since we only want one
6345ea133fd7Smrg	  # extension on DOS 8.3 filesystems.
6346ea133fd7Smrg	  func_arith $current - $age
6347ea133fd7Smrg	  major=$func_arith_result
6348ea133fd7Smrg	  versuffix="-$major"
6349ea133fd7Smrg	  ;;
6350ea133fd7Smrg
6351ea133fd7Smrg	*)
6352ea133fd7Smrg	  func_fatal_configuration "unknown library version type \`$version_type'"
6353ea133fd7Smrg	  ;;
6354ea133fd7Smrg	esac
6355ea133fd7Smrg
6356ea133fd7Smrg	# Clear the version info if we defaulted, and they specified a release.
6357ea133fd7Smrg	if test -z "$vinfo" && test -n "$release"; then
6358ea133fd7Smrg	  major=
6359ea133fd7Smrg	  case $version_type in
6360ea133fd7Smrg	  darwin)
6361ea133fd7Smrg	    # we can't check for "0.0" in archive_cmds due to quoting
6362ea133fd7Smrg	    # problems, so we reset it completely
6363ea133fd7Smrg	    verstring=
6364ea133fd7Smrg	    ;;
6365ea133fd7Smrg	  *)
6366ea133fd7Smrg	    verstring="0.0"
6367ea133fd7Smrg	    ;;
6368ea133fd7Smrg	  esac
6369ea133fd7Smrg	  if test "$need_version" = no; then
6370ea133fd7Smrg	    versuffix=
6371ea133fd7Smrg	  else
6372ea133fd7Smrg	    versuffix=".0.0"
6373ea133fd7Smrg	  fi
6374ea133fd7Smrg	fi
6375ea133fd7Smrg
6376ea133fd7Smrg	# Remove version info from name if versioning should be avoided
6377ea133fd7Smrg	if test "$avoid_version" = yes && test "$need_version" = no; then
6378ea133fd7Smrg	  major=
6379ea133fd7Smrg	  versuffix=
6380ea133fd7Smrg	  verstring=""
6381ea133fd7Smrg	fi
6382ea133fd7Smrg
6383ea133fd7Smrg	# Check to see if the archive will have undefined symbols.
6384ea133fd7Smrg	if test "$allow_undefined" = yes; then
6385ea133fd7Smrg	  if test "$allow_undefined_flag" = unsupported; then
6386ea133fd7Smrg	    func_warning "undefined symbols not allowed in $host shared libraries"
6387ea133fd7Smrg	    build_libtool_libs=no
6388ea133fd7Smrg	    build_old_libs=yes
6389ea133fd7Smrg	  fi
6390ea133fd7Smrg	else
6391ea133fd7Smrg	  # Don't allow undefined symbols.
6392ea133fd7Smrg	  allow_undefined_flag="$no_undefined_flag"
6393ea133fd7Smrg	fi
6394ea133fd7Smrg
6395ea133fd7Smrg      fi
6396ea133fd7Smrg
6397ea133fd7Smrg      func_generate_dlsyms "$libname" "$libname" "yes"
6398ea133fd7Smrg      libobjs="$libobjs $symfileobj"
6399ea133fd7Smrg      test "X$libobjs" = "X " && libobjs=
6400ea133fd7Smrg
6401ea133fd7Smrg      if test "$mode" != relink; then
6402ea133fd7Smrg	# Remove our outputs, but don't remove object files since they
6403ea133fd7Smrg	# may have been created when compiling PIC objects.
6404ea133fd7Smrg	removelist=
6405ea133fd7Smrg	tempremovelist=`$ECHO "$output_objdir/*"`
6406ea133fd7Smrg	for p in $tempremovelist; do
6407ea133fd7Smrg	  case $p in
6408ea133fd7Smrg	    *.$objext | *.gcno)
6409ea133fd7Smrg	       ;;
6410ea133fd7Smrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
6411ea133fd7Smrg	       if test "X$precious_files_regex" != "X"; then
6412ea133fd7Smrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
6413ea133fd7Smrg		 then
6414ea133fd7Smrg		   continue
6415ea133fd7Smrg		 fi
6416ea133fd7Smrg	       fi
6417ea133fd7Smrg	       removelist="$removelist $p"
6418ea133fd7Smrg	       ;;
6419ea133fd7Smrg	    *) ;;
6420ea133fd7Smrg	  esac
6421ea133fd7Smrg	done
6422ea133fd7Smrg	test -n "$removelist" && \
6423ea133fd7Smrg	  func_show_eval "${RM}r \$removelist"
6424ea133fd7Smrg      fi
6425ea133fd7Smrg
6426ea133fd7Smrg      # Now set the variables for building old libraries.
6427ea133fd7Smrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
6428ea133fd7Smrg	oldlibs="$oldlibs $output_objdir/$libname.$libext"
6429ea133fd7Smrg
6430ea133fd7Smrg	# Transform .lo files to .o files.
6431ea133fd7Smrg	oldobjs="$objs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
6432ea133fd7Smrg      fi
6433ea133fd7Smrg
6434ea133fd7Smrg      # Eliminate all temporary directories.
6435ea133fd7Smrg      #for path in $notinst_path; do
6436ea133fd7Smrg      #	lib_search_path=`$ECHO "X$lib_search_path " | $Xsed -e "s% $path % %g"`
6437ea133fd7Smrg      #	deplibs=`$ECHO "X$deplibs " | $Xsed -e "s% -L$path % %g"`
6438ea133fd7Smrg      #	dependency_libs=`$ECHO "X$dependency_libs " | $Xsed -e "s% -L$path % %g"`
6439ea133fd7Smrg      #done
6440ea133fd7Smrg
6441ea133fd7Smrg      if test -n "$xrpath"; then
6442ea133fd7Smrg	# If the user specified any rpath flags, then add them.
6443ea133fd7Smrg	temp_xrpath=
6444ea133fd7Smrg	for libdir in $xrpath; do
6445ea133fd7Smrg	  temp_xrpath="$temp_xrpath -R$libdir"
6446ea133fd7Smrg	  case "$finalize_rpath " in
6447ea133fd7Smrg	  *" $libdir "*) ;;
6448ea133fd7Smrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
6449ea133fd7Smrg	  esac
6450ea133fd7Smrg	done
6451ea133fd7Smrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
6452ea133fd7Smrg	  dependency_libs="$temp_xrpath $dependency_libs"
6453ea133fd7Smrg	fi
6454ea133fd7Smrg      fi
6455ea133fd7Smrg
6456ea133fd7Smrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
6457ea133fd7Smrg      old_dlfiles="$dlfiles"
6458ea133fd7Smrg      dlfiles=
6459ea133fd7Smrg      for lib in $old_dlfiles; do
6460ea133fd7Smrg	case " $dlprefiles $dlfiles " in
6461ea133fd7Smrg	*" $lib "*) ;;
6462ea133fd7Smrg	*) dlfiles="$dlfiles $lib" ;;
6463ea133fd7Smrg	esac
6464ea133fd7Smrg      done
6465ea133fd7Smrg
6466ea133fd7Smrg      # Make sure dlprefiles contains only unique files
6467ea133fd7Smrg      old_dlprefiles="$dlprefiles"
6468ea133fd7Smrg      dlprefiles=
6469ea133fd7Smrg      for lib in $old_dlprefiles; do
6470ea133fd7Smrg	case "$dlprefiles " in
6471ea133fd7Smrg	*" $lib "*) ;;
6472ea133fd7Smrg	*) dlprefiles="$dlprefiles $lib" ;;
6473ea133fd7Smrg	esac
6474ea133fd7Smrg      done
6475ea133fd7Smrg
6476ea133fd7Smrg      if test "$build_libtool_libs" = yes; then
6477ea133fd7Smrg	if test -n "$rpath"; then
6478ea133fd7Smrg	  case $host in
6479ea133fd7Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc*)
6480ea133fd7Smrg	    # these systems don't actually have a c library (as such)!
6481ea133fd7Smrg	    ;;
6482ea133fd7Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
6483ea133fd7Smrg	    # Rhapsody C library is in the System framework
6484ea133fd7Smrg	    deplibs="$deplibs System.ltframework"
6485ea133fd7Smrg	    ;;
6486ea133fd7Smrg	  *-*-netbsd*)
6487ea133fd7Smrg	    # Don't link with libc until the a.out ld.so is fixed.
6488ea133fd7Smrg	    ;;
6489ea133fd7Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
6490ea133fd7Smrg	    # Do not include libc due to us having libc/libc_r.
6491ea133fd7Smrg	    ;;
6492ea133fd7Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
6493ea133fd7Smrg	    # Causes problems with __ctype
6494ea133fd7Smrg	    ;;
6495ea133fd7Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
6496ea133fd7Smrg	    # Compiler inserts libc in the correct place for threads to work
6497ea133fd7Smrg	    ;;
6498ea133fd7Smrg	  *)
6499ea133fd7Smrg	    # Add libc to deplibs on all other systems if necessary.
6500ea133fd7Smrg	    if test "$build_libtool_need_lc" = "yes"; then
6501ea133fd7Smrg	      deplibs="$deplibs -lc"
6502ea133fd7Smrg	    fi
6503ea133fd7Smrg	    ;;
6504ea133fd7Smrg	  esac
6505ea133fd7Smrg	fi
6506ea133fd7Smrg
6507ea133fd7Smrg	# Transform deplibs into only deplibs that can be linked in shared.
6508ea133fd7Smrg	name_save=$name
6509ea133fd7Smrg	libname_save=$libname
6510ea133fd7Smrg	release_save=$release
6511ea133fd7Smrg	versuffix_save=$versuffix
6512ea133fd7Smrg	major_save=$major
6513ea133fd7Smrg	# I'm not sure if I'm treating the release correctly.  I think
6514ea133fd7Smrg	# release should show up in the -l (ie -lgmp5) so we don't want to
6515ea133fd7Smrg	# add it in twice.  Is that correct?
6516ea133fd7Smrg	release=""
6517ea133fd7Smrg	versuffix=""
6518ea133fd7Smrg	major=""
6519ea133fd7Smrg	newdeplibs=
6520ea133fd7Smrg	droppeddeps=no
6521ea133fd7Smrg	case $deplibs_check_method in
6522ea133fd7Smrg	pass_all)
6523ea133fd7Smrg	  # Don't check for shared/static.  Everything works.
6524ea133fd7Smrg	  # This might be a little naive.  We might want to check
6525ea133fd7Smrg	  # whether the library exists or not.  But this is on
6526ea133fd7Smrg	  # osf3 & osf4 and I'm not really sure... Just
6527ea133fd7Smrg	  # implementing what was already the behavior.
6528ea133fd7Smrg	  newdeplibs=$deplibs
6529ea133fd7Smrg	  ;;
6530ea133fd7Smrg	test_compile)
6531ea133fd7Smrg	  # This code stresses the "libraries are programs" paradigm to its
6532ea133fd7Smrg	  # limits. Maybe even breaks it.  We compile a program, linking it
6533ea133fd7Smrg	  # against the deplibs as a proxy for the library.  Then we can check
6534ea133fd7Smrg	  # whether they linked in statically or dynamically with ldd.
6535ea133fd7Smrg	  $opt_dry_run || $RM conftest.c
6536ea133fd7Smrg	  cat > conftest.c <<EOF
6537ea133fd7Smrg	  int main() { return 0; }
6538ea133fd7SmrgEOF
6539ea133fd7Smrg	  $opt_dry_run || $RM conftest
6540ea133fd7Smrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
6541ea133fd7Smrg	    ldd_output=`ldd conftest`
6542ea133fd7Smrg	    for i in $deplibs; do
6543ea133fd7Smrg	      case $i in
6544ea133fd7Smrg	      -l*)
6545ea133fd7Smrg		func_stripname -l '' "$i"
6546ea133fd7Smrg		name=$func_stripname_result
6547ea133fd7Smrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6548ea133fd7Smrg		  case " $predeps $postdeps " in
6549ea133fd7Smrg		  *" $i "*)
6550ea133fd7Smrg		    newdeplibs="$newdeplibs $i"
6551ea133fd7Smrg		    i=""
6552ea133fd7Smrg		    ;;
6553ea133fd7Smrg		  esac
6554ea133fd7Smrg		fi
6555ea133fd7Smrg		if test -n "$i" ; then
6556ea133fd7Smrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
6557ea133fd7Smrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
6558ea133fd7Smrg		  set dummy $deplib_matches; shift
6559ea133fd7Smrg		  deplib_match=$1
6560ea133fd7Smrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
6561ea133fd7Smrg		    newdeplibs="$newdeplibs $i"
6562ea133fd7Smrg		  else
6563ea133fd7Smrg		    droppeddeps=yes
6564ea133fd7Smrg		    $ECHO
6565ea133fd7Smrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
6566ea133fd7Smrg		    $ECHO "*** I have the capability to make that library automatically link in when"
6567ea133fd7Smrg		    $ECHO "*** you link to this library.  But I can only do this if you have a"
6568ea133fd7Smrg		    $ECHO "*** shared version of the library, which I believe you do not have"
6569ea133fd7Smrg		    $ECHO "*** because a test_compile did reveal that the linker did not use it for"
6570ea133fd7Smrg		    $ECHO "*** its dynamic dependency list that programs get resolved with at runtime."
6571ea133fd7Smrg		  fi
6572ea133fd7Smrg		fi
6573ea133fd7Smrg		;;
6574ea133fd7Smrg	      *)
6575ea133fd7Smrg		newdeplibs="$newdeplibs $i"
6576ea133fd7Smrg		;;
6577ea133fd7Smrg	      esac
6578ea133fd7Smrg	    done
6579ea133fd7Smrg	  else
6580ea133fd7Smrg	    # Error occurred in the first compile.  Let's try to salvage
6581ea133fd7Smrg	    # the situation: Compile a separate program for each library.
6582ea133fd7Smrg	    for i in $deplibs; do
6583ea133fd7Smrg	      case $i in
6584ea133fd7Smrg	      -l*)
6585ea133fd7Smrg		func_stripname -l '' "$i"
6586ea133fd7Smrg		name=$func_stripname_result
6587ea133fd7Smrg		$opt_dry_run || $RM conftest
6588ea133fd7Smrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
6589ea133fd7Smrg		  ldd_output=`ldd conftest`
6590ea133fd7Smrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6591ea133fd7Smrg		    case " $predeps $postdeps " in
6592ea133fd7Smrg		    *" $i "*)
6593ea133fd7Smrg		      newdeplibs="$newdeplibs $i"
6594ea133fd7Smrg		      i=""
6595ea133fd7Smrg		      ;;
6596ea133fd7Smrg		    esac
6597ea133fd7Smrg		  fi
6598ea133fd7Smrg		  if test -n "$i" ; then
6599ea133fd7Smrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
6600ea133fd7Smrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
6601ea133fd7Smrg		    set dummy $deplib_matches; shift
6602ea133fd7Smrg		    deplib_match=$1
6603ea133fd7Smrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
6604ea133fd7Smrg		      newdeplibs="$newdeplibs $i"
6605ea133fd7Smrg		    else
6606ea133fd7Smrg		      droppeddeps=yes
6607ea133fd7Smrg		      $ECHO
6608ea133fd7Smrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
6609ea133fd7Smrg		      $ECHO "*** I have the capability to make that library automatically link in when"
6610ea133fd7Smrg		      $ECHO "*** you link to this library.  But I can only do this if you have a"
6611ea133fd7Smrg		      $ECHO "*** shared version of the library, which you do not appear to have"
6612ea133fd7Smrg		      $ECHO "*** because a test_compile did reveal that the linker did not use this one"
6613ea133fd7Smrg		      $ECHO "*** as a dynamic dependency that programs can get resolved with at runtime."
6614ea133fd7Smrg		    fi
6615ea133fd7Smrg		  fi
6616ea133fd7Smrg		else
6617ea133fd7Smrg		  droppeddeps=yes
6618ea133fd7Smrg		  $ECHO
6619ea133fd7Smrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
6620ea133fd7Smrg		  $ECHO "*** make it link in!  You will probably need to install it or some"
6621ea133fd7Smrg		  $ECHO "*** library that it depends on before this library will be fully"
6622ea133fd7Smrg		  $ECHO "*** functional.  Installing it before continuing would be even better."
6623ea133fd7Smrg		fi
6624ea133fd7Smrg		;;
6625ea133fd7Smrg	      *)
6626ea133fd7Smrg		newdeplibs="$newdeplibs $i"
6627ea133fd7Smrg		;;
6628ea133fd7Smrg	      esac
6629ea133fd7Smrg	    done
6630ea133fd7Smrg	  fi
6631ea133fd7Smrg	  ;;
6632ea133fd7Smrg	file_magic*)
6633ea133fd7Smrg	  set dummy $deplibs_check_method; shift
6634ea133fd7Smrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6635ea133fd7Smrg	  for a_deplib in $deplibs; do
6636ea133fd7Smrg	    case $a_deplib in
6637ea133fd7Smrg	    -l*)
6638ea133fd7Smrg	      func_stripname -l '' "$a_deplib"
6639ea133fd7Smrg	      name=$func_stripname_result
6640ea133fd7Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6641ea133fd7Smrg		case " $predeps $postdeps " in
6642ea133fd7Smrg		*" $a_deplib "*)
6643ea133fd7Smrg		  newdeplibs="$newdeplibs $a_deplib"
6644ea133fd7Smrg		  a_deplib=""
6645ea133fd7Smrg		  ;;
6646ea133fd7Smrg		esac
6647ea133fd7Smrg	      fi
6648ea133fd7Smrg	      if test -n "$a_deplib" ; then
6649ea133fd7Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
6650ea133fd7Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
6651ea133fd7Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
6652ea133fd7Smrg		  for potent_lib in $potential_libs; do
6653ea133fd7Smrg		      # Follow soft links.
6654ea133fd7Smrg		      if ls -lLd "$potent_lib" 2>/dev/null |
6655ea133fd7Smrg			 $GREP " -> " >/dev/null; then
6656ea133fd7Smrg			continue
6657ea133fd7Smrg		      fi
6658ea133fd7Smrg		      # The statement above tries to avoid entering an
6659ea133fd7Smrg		      # endless loop below, in case of cyclic links.
6660ea133fd7Smrg		      # We might still enter an endless loop, since a link
6661ea133fd7Smrg		      # loop can be closed while we follow links,
6662ea133fd7Smrg		      # but so what?
6663ea133fd7Smrg		      potlib="$potent_lib"
6664ea133fd7Smrg		      while test -h "$potlib" 2>/dev/null; do
6665ea133fd7Smrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
6666ea133fd7Smrg			case $potliblink in
6667ea133fd7Smrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
6668ea133fd7Smrg			*) potlib=`$ECHO "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
6669ea133fd7Smrg			esac
6670ea133fd7Smrg		      done
6671ea133fd7Smrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
6672ea133fd7Smrg			 $SED -e 10q |
6673ea133fd7Smrg			 $EGREP "$file_magic_regex" > /dev/null; then
6674ea133fd7Smrg			newdeplibs="$newdeplibs $a_deplib"
6675ea133fd7Smrg			a_deplib=""
6676ea133fd7Smrg			break 2
6677ea133fd7Smrg		      fi
6678ea133fd7Smrg		  done
6679ea133fd7Smrg		done
6680ea133fd7Smrg	      fi
6681ea133fd7Smrg	      if test -n "$a_deplib" ; then
6682ea133fd7Smrg		droppeddeps=yes
6683ea133fd7Smrg		$ECHO
6684ea133fd7Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
6685ea133fd7Smrg		$ECHO "*** I have the capability to make that library automatically link in when"
6686ea133fd7Smrg		$ECHO "*** you link to this library.  But I can only do this if you have a"
6687ea133fd7Smrg		$ECHO "*** shared version of the library, which you do not appear to have"
6688ea133fd7Smrg		$ECHO "*** because I did check the linker path looking for a file starting"
6689ea133fd7Smrg		if test -z "$potlib" ; then
6690ea133fd7Smrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
6691ea133fd7Smrg		else
6692ea133fd7Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
6693ea133fd7Smrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
6694ea133fd7Smrg		fi
6695ea133fd7Smrg	      fi
6696ea133fd7Smrg	      ;;
6697ea133fd7Smrg	    *)
6698ea133fd7Smrg	      # Add a -L argument.
6699ea133fd7Smrg	      newdeplibs="$newdeplibs $a_deplib"
6700ea133fd7Smrg	      ;;
6701ea133fd7Smrg	    esac
6702ea133fd7Smrg	  done # Gone through all deplibs.
6703ea133fd7Smrg	  ;;
6704ea133fd7Smrg	match_pattern*)
6705ea133fd7Smrg	  set dummy $deplibs_check_method; shift
6706ea133fd7Smrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6707ea133fd7Smrg	  for a_deplib in $deplibs; do
6708ea133fd7Smrg	    case $a_deplib in
6709ea133fd7Smrg	    -l*)
6710ea133fd7Smrg	      func_stripname -l '' "$a_deplib"
6711ea133fd7Smrg	      name=$func_stripname_result
6712ea133fd7Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6713ea133fd7Smrg		case " $predeps $postdeps " in
6714ea133fd7Smrg		*" $a_deplib "*)
6715ea133fd7Smrg		  newdeplibs="$newdeplibs $a_deplib"
6716ea133fd7Smrg		  a_deplib=""
6717ea133fd7Smrg		  ;;
6718ea133fd7Smrg		esac
6719ea133fd7Smrg	      fi
6720ea133fd7Smrg	      if test -n "$a_deplib" ; then
6721ea133fd7Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
6722ea133fd7Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
6723ea133fd7Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
6724ea133fd7Smrg		  for potent_lib in $potential_libs; do
6725ea133fd7Smrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
6726ea133fd7Smrg		    if eval "\$ECHO \"X$potent_lib\"" 2>/dev/null | $Xsed -e 10q | \
6727ea133fd7Smrg		       $EGREP "$match_pattern_regex" > /dev/null; then
6728ea133fd7Smrg		      newdeplibs="$newdeplibs $a_deplib"
6729ea133fd7Smrg		      a_deplib=""
6730ea133fd7Smrg		      break 2
6731ea133fd7Smrg		    fi
6732ea133fd7Smrg		  done
6733ea133fd7Smrg		done
6734ea133fd7Smrg	      fi
6735ea133fd7Smrg	      if test -n "$a_deplib" ; then
6736ea133fd7Smrg		droppeddeps=yes
6737ea133fd7Smrg		$ECHO
6738ea133fd7Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
6739ea133fd7Smrg		$ECHO "*** I have the capability to make that library automatically link in when"
6740ea133fd7Smrg		$ECHO "*** you link to this library.  But I can only do this if you have a"
6741ea133fd7Smrg		$ECHO "*** shared version of the library, which you do not appear to have"
6742ea133fd7Smrg		$ECHO "*** because I did check the linker path looking for a file starting"
6743ea133fd7Smrg		if test -z "$potlib" ; then
6744ea133fd7Smrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
6745ea133fd7Smrg		else
6746ea133fd7Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
6747ea133fd7Smrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
6748ea133fd7Smrg		fi
6749ea133fd7Smrg	      fi
6750ea133fd7Smrg	      ;;
6751ea133fd7Smrg	    *)
6752ea133fd7Smrg	      # Add a -L argument.
6753ea133fd7Smrg	      newdeplibs="$newdeplibs $a_deplib"
6754ea133fd7Smrg	      ;;
6755ea133fd7Smrg	    esac
6756ea133fd7Smrg	  done # Gone through all deplibs.
6757ea133fd7Smrg	  ;;
6758ea133fd7Smrg	none | unknown | *)
6759ea133fd7Smrg	  newdeplibs=""
6760ea133fd7Smrg	  tmp_deplibs=`$ECHO "X $deplibs" | $Xsed \
6761ea133fd7Smrg	      -e 's/ -lc$//' -e 's/ -[LR][^ ]*//g'`
6762ea133fd7Smrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6763ea133fd7Smrg	    for i in $predeps $postdeps ; do
6764ea133fd7Smrg	      # can't use Xsed below, because $i might contain '/'
6765ea133fd7Smrg	      tmp_deplibs=`$ECHO "X $tmp_deplibs" | $Xsed -e "s,$i,,"`
6766ea133fd7Smrg	    done
6767ea133fd7Smrg	  fi
6768ea133fd7Smrg	  if $ECHO "X $tmp_deplibs" | $Xsed -e 's/[	 ]//g' |
6769ea133fd7Smrg	     $GREP . >/dev/null; then
6770ea133fd7Smrg	    $ECHO
6771ea133fd7Smrg	    if test "X$deplibs_check_method" = "Xnone"; then
6772ea133fd7Smrg	      $ECHO "*** Warning: inter-library dependencies are not supported in this platform."
6773ea133fd7Smrg	    else
6774ea133fd7Smrg	      $ECHO "*** Warning: inter-library dependencies are not known to be supported."
6775ea133fd7Smrg	    fi
6776ea133fd7Smrg	    $ECHO "*** All declared inter-library dependencies are being dropped."
6777ea133fd7Smrg	    droppeddeps=yes
6778ea133fd7Smrg	  fi
6779ea133fd7Smrg	  ;;
6780ea133fd7Smrg	esac
6781ea133fd7Smrg	versuffix=$versuffix_save
6782ea133fd7Smrg	major=$major_save
6783ea133fd7Smrg	release=$release_save
6784ea133fd7Smrg	libname=$libname_save
6785ea133fd7Smrg	name=$name_save
6786ea133fd7Smrg
6787ea133fd7Smrg	case $host in
6788ea133fd7Smrg	*-*-rhapsody* | *-*-darwin1.[012])
6789ea133fd7Smrg	  # On Rhapsody replace the C library with the System framework
6790ea133fd7Smrg	  newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
6791ea133fd7Smrg	  ;;
6792ea133fd7Smrg	esac
6793ea133fd7Smrg
6794ea133fd7Smrg	if test "$droppeddeps" = yes; then
6795ea133fd7Smrg	  if test "$module" = yes; then
6796ea133fd7Smrg	    $ECHO
6797ea133fd7Smrg	    $ECHO "*** Warning: libtool could not satisfy all declared inter-library"
6798ea133fd7Smrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
6799ea133fd7Smrg	    $ECHO "*** a static module, that should work as long as the dlopening"
6800ea133fd7Smrg	    $ECHO "*** application is linked with the -dlopen flag."
6801ea133fd7Smrg	    if test -z "$global_symbol_pipe"; then
6802ea133fd7Smrg	      $ECHO
6803ea133fd7Smrg	      $ECHO "*** However, this would only work if libtool was able to extract symbol"
6804ea133fd7Smrg	      $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
6805ea133fd7Smrg	      $ECHO "*** not find such a program.  So, this module is probably useless."
6806ea133fd7Smrg	      $ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
6807ea133fd7Smrg	    fi
6808ea133fd7Smrg	    if test "$build_old_libs" = no; then
6809ea133fd7Smrg	      oldlibs="$output_objdir/$libname.$libext"
6810ea133fd7Smrg	      build_libtool_libs=module
6811ea133fd7Smrg	      build_old_libs=yes
6812ea133fd7Smrg	    else
6813ea133fd7Smrg	      build_libtool_libs=no
6814ea133fd7Smrg	    fi
6815ea133fd7Smrg	  else
6816ea133fd7Smrg	    $ECHO "*** The inter-library dependencies that have been dropped here will be"
6817ea133fd7Smrg	    $ECHO "*** automatically added whenever a program is linked with this library"
6818ea133fd7Smrg	    $ECHO "*** or is declared to -dlopen it."
6819ea133fd7Smrg
6820ea133fd7Smrg	    if test "$allow_undefined" = no; then
6821ea133fd7Smrg	      $ECHO
6822ea133fd7Smrg	      $ECHO "*** Since this library must not contain undefined symbols,"
6823ea133fd7Smrg	      $ECHO "*** because either the platform does not support them or"
6824ea133fd7Smrg	      $ECHO "*** it was explicitly requested with -no-undefined,"
6825ea133fd7Smrg	      $ECHO "*** libtool will only create a static version of it."
6826ea133fd7Smrg	      if test "$build_old_libs" = no; then
6827ea133fd7Smrg		oldlibs="$output_objdir/$libname.$libext"
6828ea133fd7Smrg		build_libtool_libs=module
6829ea133fd7Smrg		build_old_libs=yes
6830ea133fd7Smrg	      else
6831ea133fd7Smrg		build_libtool_libs=no
6832ea133fd7Smrg	      fi
6833ea133fd7Smrg	    fi
6834ea133fd7Smrg	  fi
6835ea133fd7Smrg	fi
6836ea133fd7Smrg	# Done checking deplibs!
6837ea133fd7Smrg	deplibs=$newdeplibs
6838ea133fd7Smrg      fi
6839ea133fd7Smrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
6840ea133fd7Smrg      case $host in
6841ea133fd7Smrg	*-*-darwin*)
6842ea133fd7Smrg	  newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
6843ea133fd7Smrg	  new_inherited_linker_flags=`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
6844ea133fd7Smrg	  deplibs=`$ECHO "X $deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
6845ea133fd7Smrg	  ;;
6846ea133fd7Smrg      esac
6847ea133fd7Smrg
6848ea133fd7Smrg      # move library search paths that coincide with paths to not yet
6849ea133fd7Smrg      # installed libraries to the beginning of the library search list
6850ea133fd7Smrg      new_libs=
6851ea133fd7Smrg      for path in $notinst_path; do
6852ea133fd7Smrg	case " $new_libs " in
6853ea133fd7Smrg	*" -L$path/$objdir "*) ;;
6854ea133fd7Smrg	*)
6855ea133fd7Smrg	  case " $deplibs " in
6856ea133fd7Smrg	  *" -L$path/$objdir "*)
6857ea133fd7Smrg	    new_libs="$new_libs -L$path/$objdir" ;;
6858ea133fd7Smrg	  esac
6859ea133fd7Smrg	  ;;
6860ea133fd7Smrg	esac
6861ea133fd7Smrg      done
6862ea133fd7Smrg      for deplib in $deplibs; do
6863ea133fd7Smrg	case $deplib in
6864ea133fd7Smrg	-L*)
6865ea133fd7Smrg	  case " $new_libs " in
6866ea133fd7Smrg	  *" $deplib "*) ;;
6867ea133fd7Smrg	  *) new_libs="$new_libs $deplib" ;;
6868ea133fd7Smrg	  esac
6869ea133fd7Smrg	  ;;
6870ea133fd7Smrg	*) new_libs="$new_libs $deplib" ;;
6871ea133fd7Smrg	esac
6872ea133fd7Smrg      done
6873ea133fd7Smrg      deplibs="$new_libs"
6874ea133fd7Smrg
6875ea133fd7Smrg      # All the library-specific variables (install_libdir is set above).
6876ea133fd7Smrg      library_names=
6877ea133fd7Smrg      old_library=
6878ea133fd7Smrg      dlname=
6879ea133fd7Smrg
6880ea133fd7Smrg      # Test again, we may have decided not to build it any more
6881ea133fd7Smrg      if test "$build_libtool_libs" = yes; then
6882ea133fd7Smrg	if test "$hardcode_into_libs" = yes; then
6883ea133fd7Smrg	  # Hardcode the library paths
6884ea133fd7Smrg	  hardcode_libdirs=
6885ea133fd7Smrg	  dep_rpath=
6886ea133fd7Smrg	  rpath="$finalize_rpath"
6887ea133fd7Smrg	  test "$mode" != relink && rpath="$compile_rpath$rpath"
6888ea133fd7Smrg	  for libdir in $rpath; do
6889ea133fd7Smrg	    if test -n "$hardcode_libdir_flag_spec"; then
6890ea133fd7Smrg	      if test -n "$hardcode_libdir_separator"; then
6891ea133fd7Smrg		if test -z "$hardcode_libdirs"; then
6892ea133fd7Smrg		  hardcode_libdirs="$libdir"
6893ea133fd7Smrg		else
6894ea133fd7Smrg		  # Just accumulate the unique libdirs.
6895ea133fd7Smrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
6896ea133fd7Smrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
6897ea133fd7Smrg		    ;;
6898ea133fd7Smrg		  *)
6899ea133fd7Smrg		    hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
6900ea133fd7Smrg		    ;;
6901ea133fd7Smrg		  esac
6902ea133fd7Smrg		fi
6903ea133fd7Smrg	      else
6904ea133fd7Smrg		eval flag=\"$hardcode_libdir_flag_spec\"
6905ea133fd7Smrg		dep_rpath="$dep_rpath $flag"
6906ea133fd7Smrg	      fi
6907ea133fd7Smrg	    elif test -n "$runpath_var"; then
6908ea133fd7Smrg	      case "$perm_rpath " in
6909ea133fd7Smrg	      *" $libdir "*) ;;
6910ea133fd7Smrg	      *) perm_rpath="$perm_rpath $libdir" ;;
6911ea133fd7Smrg	      esac
6912ea133fd7Smrg	    fi
6913ea133fd7Smrg	  done
6914ea133fd7Smrg	  # Substitute the hardcoded libdirs into the rpath.
6915ea133fd7Smrg	  if test -n "$hardcode_libdir_separator" &&
6916ea133fd7Smrg	     test -n "$hardcode_libdirs"; then
6917ea133fd7Smrg	    libdir="$hardcode_libdirs"
6918ea133fd7Smrg	    if test -n "$hardcode_libdir_flag_spec_ld"; then
6919ea133fd7Smrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
6920ea133fd7Smrg	    else
6921ea133fd7Smrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
6922ea133fd7Smrg	    fi
6923ea133fd7Smrg	  fi
6924ea133fd7Smrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
6925ea133fd7Smrg	    # We should set the runpath_var.
6926ea133fd7Smrg	    rpath=
6927ea133fd7Smrg	    for dir in $perm_rpath; do
6928ea133fd7Smrg	      rpath="$rpath$dir:"
6929ea133fd7Smrg	    done
6930ea133fd7Smrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
6931ea133fd7Smrg	  fi
6932ea133fd7Smrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
6933ea133fd7Smrg	fi
6934a253d6aeSmrg
6935ea133fd7Smrg	shlibpath="$finalize_shlibpath"
6936ea133fd7Smrg	test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
6937ea133fd7Smrg	if test -n "$shlibpath"; then
6938ea133fd7Smrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
6939ea133fd7Smrg	fi
6940a253d6aeSmrg
6941ea133fd7Smrg	# Get the real and link names of the library.
6942ea133fd7Smrg	eval shared_ext=\"$shrext_cmds\"
6943ea133fd7Smrg	eval library_names=\"$library_names_spec\"
6944ea133fd7Smrg	set dummy $library_names
6945ea133fd7Smrg	shift
6946ea133fd7Smrg	realname="$1"
6947ea133fd7Smrg	shift
6948a253d6aeSmrg
6949ea133fd7Smrg	if test -n "$soname_spec"; then
6950ea133fd7Smrg	  eval soname=\"$soname_spec\"
6951ea133fd7Smrg	else
6952ea133fd7Smrg	  soname="$realname"
6953ea133fd7Smrg	fi
6954ea133fd7Smrg	if test -z "$dlname"; then
6955ea133fd7Smrg	  dlname=$soname
6956ea133fd7Smrg	fi
6957a253d6aeSmrg
6958ea133fd7Smrg	lib="$output_objdir/$realname"
6959ea133fd7Smrg	linknames=
6960ea133fd7Smrg	for link
6961ea133fd7Smrg	do
6962ea133fd7Smrg	  linknames="$linknames $link"
6963ea133fd7Smrg	done
6964a253d6aeSmrg
6965ea133fd7Smrg	# Use standard objects if they are pic
6966ea133fd7Smrg	test -z "$pic_flag" && libobjs=`$ECHO "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
6967ea133fd7Smrg	test "X$libobjs" = "X " && libobjs=
6968a253d6aeSmrg
6969ea133fd7Smrg	delfiles=
6970ea133fd7Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
6971ea133fd7Smrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
6972ea133fd7Smrg	  export_symbols="$output_objdir/$libname.uexp"
6973ea133fd7Smrg	  delfiles="$delfiles $export_symbols"
6974ea133fd7Smrg	fi
6975a253d6aeSmrg
6976ea133fd7Smrg	orig_export_symbols=
6977ea133fd7Smrg	case $host_os in
6978ea133fd7Smrg	cygwin* | mingw* | cegcc*)
6979ea133fd7Smrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
6980ea133fd7Smrg	    # exporting using user supplied symfile
6981ea133fd7Smrg	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
6982ea133fd7Smrg	      # and it's NOT already a .def file. Must figure out
6983ea133fd7Smrg	      # which of the given symbols are data symbols and tag
6984ea133fd7Smrg	      # them as such. So, trigger use of export_symbols_cmds.
6985ea133fd7Smrg	      # export_symbols gets reassigned inside the "prepare
6986ea133fd7Smrg	      # the list of exported symbols" if statement, so the
6987ea133fd7Smrg	      # include_expsyms logic still works.
6988ea133fd7Smrg	      orig_export_symbols="$export_symbols"
6989ea133fd7Smrg	      export_symbols=
6990ea133fd7Smrg	      always_export_symbols=yes
6991ea133fd7Smrg	    fi
6992ea133fd7Smrg	  fi
6993ea133fd7Smrg	  ;;
6994ea133fd7Smrg	esac
6995a253d6aeSmrg
6996ea133fd7Smrg	# Prepare the list of exported symbols
6997ea133fd7Smrg	if test -z "$export_symbols"; then
6998ea133fd7Smrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
6999ea133fd7Smrg	    func_verbose "generating symbol list for \`$libname.la'"
7000ea133fd7Smrg	    export_symbols="$output_objdir/$libname.exp"
7001ea133fd7Smrg	    $opt_dry_run || $RM $export_symbols
7002ea133fd7Smrg	    cmds=$export_symbols_cmds
7003ea133fd7Smrg	    save_ifs="$IFS"; IFS='~'
7004ea133fd7Smrg	    for cmd in $cmds; do
7005ea133fd7Smrg	      IFS="$save_ifs"
7006ea133fd7Smrg	      eval cmd=\"$cmd\"
7007ea133fd7Smrg	      func_len " $cmd"
7008ea133fd7Smrg	      len=$func_len_result
7009ea133fd7Smrg	      if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
7010ea133fd7Smrg		func_show_eval "$cmd" 'exit $?'
7011ea133fd7Smrg		skipped_export=false
7012ea133fd7Smrg	      else
7013ea133fd7Smrg		# The command line is too long to execute in one step.
7014ea133fd7Smrg		func_verbose "using reloadable object file for export list..."
7015ea133fd7Smrg		skipped_export=:
7016ea133fd7Smrg		# Break out early, otherwise skipped_export may be
7017ea133fd7Smrg		# set to false by a later but shorter cmd.
7018ea133fd7Smrg		break
7019ea133fd7Smrg	      fi
7020ea133fd7Smrg	    done
7021ea133fd7Smrg	    IFS="$save_ifs"
7022ea133fd7Smrg	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
7023ea133fd7Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
7024ea133fd7Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
7025ea133fd7Smrg	    fi
7026ea133fd7Smrg	  fi
7027ea133fd7Smrg	fi
7028a253d6aeSmrg
7029ea133fd7Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
7030ea133fd7Smrg	  tmp_export_symbols="$export_symbols"
7031ea133fd7Smrg	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
7032ea133fd7Smrg	  $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
7033ea133fd7Smrg	fi
7034a253d6aeSmrg
7035ea133fd7Smrg	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
7036ea133fd7Smrg	  # The given exports_symbols file has to be filtered, so filter it.
7037ea133fd7Smrg	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
7038ea133fd7Smrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
7039ea133fd7Smrg	  # 's' commands which not all seds can handle. GNU sed should be fine
7040ea133fd7Smrg	  # though. Also, the filter scales superlinearly with the number of
7041ea133fd7Smrg	  # global variables. join(1) would be nice here, but unfortunately
7042ea133fd7Smrg	  # isn't a blessed tool.
7043ea133fd7Smrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
7044ea133fd7Smrg	  delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
7045ea133fd7Smrg	  export_symbols=$output_objdir/$libname.def
7046ea133fd7Smrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
7047a253d6aeSmrg	fi
7048a253d6aeSmrg
7049ea133fd7Smrg	tmp_deplibs=
7050ea133fd7Smrg	for test_deplib in $deplibs; do
7051ea133fd7Smrg	  case " $convenience " in
7052ea133fd7Smrg	  *" $test_deplib "*) ;;
7053ea133fd7Smrg	  *)
7054ea133fd7Smrg	    tmp_deplibs="$tmp_deplibs $test_deplib"
7055ea133fd7Smrg	    ;;
7056ea133fd7Smrg	  esac
7057ea133fd7Smrg	done
7058ea133fd7Smrg	deplibs="$tmp_deplibs"
7059a253d6aeSmrg
7060ea133fd7Smrg	if test -n "$convenience"; then
7061ea133fd7Smrg	  if test -n "$whole_archive_flag_spec" &&
7062ea133fd7Smrg	    test "$compiler_needs_object" = yes &&
7063ea133fd7Smrg	    test -z "$libobjs"; then
7064ea133fd7Smrg	    # extract the archives, so we have objects to list.
7065ea133fd7Smrg	    # TODO: could optimize this to just extract one archive.
7066ea133fd7Smrg	    whole_archive_flag_spec=
7067ea133fd7Smrg	  fi
7068ea133fd7Smrg	  if test -n "$whole_archive_flag_spec"; then
7069ea133fd7Smrg	    save_libobjs=$libobjs
7070ea133fd7Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
7071ea133fd7Smrg	    test "X$libobjs" = "X " && libobjs=
7072ea133fd7Smrg	  else
7073ea133fd7Smrg	    gentop="$output_objdir/${outputname}x"
7074ea133fd7Smrg	    generated="$generated $gentop"
7075a253d6aeSmrg
7076ea133fd7Smrg	    func_extract_archives $gentop $convenience
7077ea133fd7Smrg	    libobjs="$libobjs $func_extract_archives_result"
7078ea133fd7Smrg	    test "X$libobjs" = "X " && libobjs=
7079ea133fd7Smrg	  fi
7080ea133fd7Smrg	fi
7081a253d6aeSmrg
7082ea133fd7Smrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
7083ea133fd7Smrg	  eval flag=\"$thread_safe_flag_spec\"
7084ea133fd7Smrg	  linker_flags="$linker_flags $flag"
7085ea133fd7Smrg	fi
7086a253d6aeSmrg
7087ea133fd7Smrg	# Make a backup of the uninstalled library when relinking
7088ea133fd7Smrg	if test "$mode" = relink; then
7089ea133fd7Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
7090a253d6aeSmrg	fi
7091a253d6aeSmrg
7092ea133fd7Smrg	# Do each of the archive commands.
7093ea133fd7Smrg	if test "$module" = yes && test -n "$module_cmds" ; then
7094ea133fd7Smrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
7095ea133fd7Smrg	    eval test_cmds=\"$module_expsym_cmds\"
7096ea133fd7Smrg	    cmds=$module_expsym_cmds
7097ea133fd7Smrg	  else
7098ea133fd7Smrg	    eval test_cmds=\"$module_cmds\"
7099ea133fd7Smrg	    cmds=$module_cmds
7100ea133fd7Smrg	  fi
7101ea133fd7Smrg	else
7102ea133fd7Smrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
7103ea133fd7Smrg	    eval test_cmds=\"$archive_expsym_cmds\"
7104ea133fd7Smrg	    cmds=$archive_expsym_cmds
7105ea133fd7Smrg	  else
7106ea133fd7Smrg	    eval test_cmds=\"$archive_cmds\"
7107ea133fd7Smrg	    cmds=$archive_cmds
7108ea133fd7Smrg	  fi
7109a253d6aeSmrg	fi
7110a253d6aeSmrg
7111ea133fd7Smrg	if test "X$skipped_export" != "X:" &&
7112ea133fd7Smrg	   func_len " $test_cmds" &&
7113ea133fd7Smrg	   len=$func_len_result &&
7114ea133fd7Smrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
7115ea133fd7Smrg	  :
7116ea133fd7Smrg	else
7117ea133fd7Smrg	  # The command line is too long to link in one step, link piecewise
7118ea133fd7Smrg	  # or, if using GNU ld and skipped_export is not :, use a linker
7119ea133fd7Smrg	  # script.
7120a253d6aeSmrg
7121ea133fd7Smrg	  # Save the value of $output and $libobjs because we want to
7122ea133fd7Smrg	  # use them later.  If we have whole_archive_flag_spec, we
7123ea133fd7Smrg	  # want to use save_libobjs as it was before
7124ea133fd7Smrg	  # whole_archive_flag_spec was expanded, because we can't
7125ea133fd7Smrg	  # assume the linker understands whole_archive_flag_spec.
7126ea133fd7Smrg	  # This may have to be revisited, in case too many
7127ea133fd7Smrg	  # convenience libraries get linked in and end up exceeding
7128ea133fd7Smrg	  # the spec.
7129ea133fd7Smrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
7130ea133fd7Smrg	    save_libobjs=$libobjs
7131ea133fd7Smrg	  fi
7132ea133fd7Smrg	  save_output=$output
7133ea133fd7Smrg	  output_la=`$ECHO "X$output" | $Xsed -e "$basename"`
7134a253d6aeSmrg
7135ea133fd7Smrg	  # Clear the reloadable object creation command queue and
7136ea133fd7Smrg	  # initialize k to one.
7137ea133fd7Smrg	  test_cmds=
7138ea133fd7Smrg	  concat_cmds=
7139ea133fd7Smrg	  objlist=
7140ea133fd7Smrg	  last_robj=
7141ea133fd7Smrg	  k=1
7142a253d6aeSmrg
7143ea133fd7Smrg	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
7144ea133fd7Smrg	    output=${output_objdir}/${output_la}.lnkscript
7145ea133fd7Smrg	    func_verbose "creating GNU ld script: $output"
7146ea133fd7Smrg	    $ECHO 'INPUT (' > $output
7147ea133fd7Smrg	    for obj in $save_libobjs
7148ea133fd7Smrg	    do
7149ea133fd7Smrg	      $ECHO "$obj" >> $output
7150ea133fd7Smrg	    done
7151ea133fd7Smrg	    $ECHO ')' >> $output
7152ea133fd7Smrg	    delfiles="$delfiles $output"
7153ea133fd7Smrg	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
7154ea133fd7Smrg	    output=${output_objdir}/${output_la}.lnk
7155ea133fd7Smrg	    func_verbose "creating linker input file list: $output"
7156ea133fd7Smrg	    : > $output
7157ea133fd7Smrg	    set x $save_libobjs
7158ea133fd7Smrg	    shift
7159ea133fd7Smrg	    firstobj=
7160ea133fd7Smrg	    if test "$compiler_needs_object" = yes; then
7161ea133fd7Smrg	      firstobj="$1 "
7162ea133fd7Smrg	      shift
7163ea133fd7Smrg	    fi
7164ea133fd7Smrg	    for obj
7165ea133fd7Smrg	    do
7166ea133fd7Smrg	      $ECHO "$obj" >> $output
7167ea133fd7Smrg	    done
7168ea133fd7Smrg	    delfiles="$delfiles $output"
7169ea133fd7Smrg	    output=$firstobj\"$file_list_spec$output\"
7170ea133fd7Smrg	  else
7171ea133fd7Smrg	    if test -n "$save_libobjs"; then
7172ea133fd7Smrg	      func_verbose "creating reloadable object files..."
7173ea133fd7Smrg	      output=$output_objdir/$output_la-${k}.$objext
7174ea133fd7Smrg	      eval test_cmds=\"$reload_cmds\"
7175ea133fd7Smrg	      func_len " $test_cmds"
7176ea133fd7Smrg	      len0=$func_len_result
7177ea133fd7Smrg	      len=$len0
7178ea133fd7Smrg
7179ea133fd7Smrg	      # Loop over the list of objects to be linked.
7180ea133fd7Smrg	      for obj in $save_libobjs
7181ea133fd7Smrg	      do
7182ea133fd7Smrg		func_len " $obj"
7183ea133fd7Smrg		func_arith $len + $func_len_result
7184ea133fd7Smrg		len=$func_arith_result
7185ea133fd7Smrg		if test "X$objlist" = X ||
7186ea133fd7Smrg		   test "$len" -lt "$max_cmd_len"; then
7187ea133fd7Smrg		  func_append objlist " $obj"
7188ea133fd7Smrg		else
7189ea133fd7Smrg		  # The command $test_cmds is almost too long, add a
7190ea133fd7Smrg		  # command to the queue.
7191ea133fd7Smrg		  if test "$k" -eq 1 ; then
7192ea133fd7Smrg		    # The first file doesn't have a previous command to add.
7193ea133fd7Smrg		    eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
7194ea133fd7Smrg		  else
7195ea133fd7Smrg		    # All subsequent reloadable object files will link in
7196ea133fd7Smrg		    # the last one created.
7197ea133fd7Smrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj~\$RM $last_robj\"
7198ea133fd7Smrg		  fi
7199ea133fd7Smrg		  last_robj=$output_objdir/$output_la-${k}.$objext
7200ea133fd7Smrg		  func_arith $k + 1
7201ea133fd7Smrg		  k=$func_arith_result
7202ea133fd7Smrg		  output=$output_objdir/$output_la-${k}.$objext
7203ea133fd7Smrg		  objlist=$obj
7204ea133fd7Smrg		  func_len " $last_robj"
7205ea133fd7Smrg		  func_arith $len0 + $func_len_result
7206ea133fd7Smrg		  len=$func_arith_result
7207ea133fd7Smrg		fi
7208ea133fd7Smrg	      done
7209ea133fd7Smrg	      # Handle the remaining objects by creating one last
7210ea133fd7Smrg	      # reloadable object file.  All subsequent reloadable object
7211ea133fd7Smrg	      # files will link in the last one created.
7212ea133fd7Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
7213ea133fd7Smrg	      eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
7214ea133fd7Smrg	      if test -n "$last_robj"; then
7215ea133fd7Smrg	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
7216ea133fd7Smrg	      fi
7217ea133fd7Smrg	      delfiles="$delfiles $output"
7218a253d6aeSmrg
7219ea133fd7Smrg	    else
7220ea133fd7Smrg	      output=
7221ea133fd7Smrg	    fi
7222a253d6aeSmrg
7223ea133fd7Smrg	    if ${skipped_export-false}; then
7224ea133fd7Smrg	      func_verbose "generating symbol list for \`$libname.la'"
7225ea133fd7Smrg	      export_symbols="$output_objdir/$libname.exp"
7226ea133fd7Smrg	      $opt_dry_run || $RM $export_symbols
7227ea133fd7Smrg	      libobjs=$output
7228ea133fd7Smrg	      # Append the command to create the export file.
7229ea133fd7Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
7230ea133fd7Smrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
7231ea133fd7Smrg	      if test -n "$last_robj"; then
7232ea133fd7Smrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
7233ea133fd7Smrg	      fi
7234ea133fd7Smrg	    fi
7235a253d6aeSmrg
7236ea133fd7Smrg	    test -n "$save_libobjs" &&
7237ea133fd7Smrg	      func_verbose "creating a temporary reloadable object file: $output"
7238a253d6aeSmrg
7239ea133fd7Smrg	    # Loop through the commands generated above and execute them.
7240ea133fd7Smrg	    save_ifs="$IFS"; IFS='~'
7241ea133fd7Smrg	    for cmd in $concat_cmds; do
7242ea133fd7Smrg	      IFS="$save_ifs"
7243ea133fd7Smrg	      $opt_silent || {
7244ea133fd7Smrg		  func_quote_for_expand "$cmd"
7245ea133fd7Smrg		  eval "func_echo $func_quote_for_expand_result"
7246ea133fd7Smrg	      }
7247ea133fd7Smrg	      $opt_dry_run || eval "$cmd" || {
7248ea133fd7Smrg		lt_exit=$?
7249ea133fd7Smrg
7250ea133fd7Smrg		# Restore the uninstalled library and exit
7251ea133fd7Smrg		if test "$mode" = relink; then
7252ea133fd7Smrg		  ( cd "$output_objdir" && \
7253ea133fd7Smrg		    $RM "${realname}T" && \
7254ea133fd7Smrg		    $MV "${realname}U" "$realname" )
7255ea133fd7Smrg		fi
7256a253d6aeSmrg
7257ea133fd7Smrg		exit $lt_exit
7258ea133fd7Smrg	      }
7259ea133fd7Smrg	    done
7260ea133fd7Smrg	    IFS="$save_ifs"
7261ea133fd7Smrg
7262ea133fd7Smrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
7263ea133fd7Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
7264ea133fd7Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
7265a253d6aeSmrg	    fi
7266a253d6aeSmrg	  fi
7267a253d6aeSmrg
7268ea133fd7Smrg          if ${skipped_export-false}; then
7269ea133fd7Smrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
7270ea133fd7Smrg	      tmp_export_symbols="$export_symbols"
7271ea133fd7Smrg	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
7272ea133fd7Smrg	      $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
7273ea133fd7Smrg	    fi
7274a253d6aeSmrg
7275ea133fd7Smrg	    if test -n "$orig_export_symbols"; then
7276ea133fd7Smrg	      # The given exports_symbols file has to be filtered, so filter it.
7277ea133fd7Smrg	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
7278ea133fd7Smrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
7279ea133fd7Smrg	      # 's' commands which not all seds can handle. GNU sed should be fine
7280ea133fd7Smrg	      # though. Also, the filter scales superlinearly with the number of
7281ea133fd7Smrg	      # global variables. join(1) would be nice here, but unfortunately
7282ea133fd7Smrg	      # isn't a blessed tool.
7283ea133fd7Smrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
7284ea133fd7Smrg	      delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
7285ea133fd7Smrg	      export_symbols=$output_objdir/$libname.def
7286ea133fd7Smrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
7287ea133fd7Smrg	    fi
7288ea133fd7Smrg	  fi
7289a253d6aeSmrg
7290ea133fd7Smrg	  libobjs=$output
7291ea133fd7Smrg	  # Restore the value of output.
7292ea133fd7Smrg	  output=$save_output
7293a253d6aeSmrg
7294ea133fd7Smrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
7295ea133fd7Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
7296ea133fd7Smrg	    test "X$libobjs" = "X " && libobjs=
7297ea133fd7Smrg	  fi
7298ea133fd7Smrg	  # Expand the library linking commands again to reset the
7299ea133fd7Smrg	  # value of $libobjs for piecewise linking.
7300ea133fd7Smrg
7301ea133fd7Smrg	  # Do each of the archive commands.
7302ea133fd7Smrg	  if test "$module" = yes && test -n "$module_cmds" ; then
7303ea133fd7Smrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
7304ea133fd7Smrg	      cmds=$module_expsym_cmds
7305a253d6aeSmrg	    else
7306ea133fd7Smrg	      cmds=$module_cmds
7307a253d6aeSmrg	    fi
7308a253d6aeSmrg	  else
7309ea133fd7Smrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
7310ea133fd7Smrg	      cmds=$archive_expsym_cmds
7311ea133fd7Smrg	    else
7312ea133fd7Smrg	      cmds=$archive_cmds
7313ea133fd7Smrg	    fi
7314a253d6aeSmrg	  fi
7315a253d6aeSmrg	fi
7316a253d6aeSmrg
7317ea133fd7Smrg	if test -n "$delfiles"; then
7318ea133fd7Smrg	  # Append the command to remove temporary files to $cmds.
7319ea133fd7Smrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
7320ea133fd7Smrg	fi
7321a253d6aeSmrg
7322ea133fd7Smrg	# Add any objects from preloaded convenience libraries
7323ea133fd7Smrg	if test -n "$dlprefiles"; then
7324ea133fd7Smrg	  gentop="$output_objdir/${outputname}x"
7325ea133fd7Smrg	  generated="$generated $gentop"
7326a253d6aeSmrg
7327ea133fd7Smrg	  func_extract_archives $gentop $dlprefiles
7328ea133fd7Smrg	  libobjs="$libobjs $func_extract_archives_result"
7329ea133fd7Smrg	  test "X$libobjs" = "X " && libobjs=
7330a253d6aeSmrg	fi
7331a253d6aeSmrg
7332ea133fd7Smrg	save_ifs="$IFS"; IFS='~'
7333ea133fd7Smrg	for cmd in $cmds; do
7334ea133fd7Smrg	  IFS="$save_ifs"
7335ea133fd7Smrg	  eval cmd=\"$cmd\"
7336ea133fd7Smrg	  $opt_silent || {
7337ea133fd7Smrg	    func_quote_for_expand "$cmd"
7338ea133fd7Smrg	    eval "func_echo $func_quote_for_expand_result"
7339ea133fd7Smrg	  }
7340ea133fd7Smrg	  $opt_dry_run || eval "$cmd" || {
7341ea133fd7Smrg	    lt_exit=$?
7342a253d6aeSmrg
7343ea133fd7Smrg	    # Restore the uninstalled library and exit
7344ea133fd7Smrg	    if test "$mode" = relink; then
7345ea133fd7Smrg	      ( cd "$output_objdir" && \
7346ea133fd7Smrg	        $RM "${realname}T" && \
7347ea133fd7Smrg		$MV "${realname}U" "$realname" )
7348ea133fd7Smrg	    fi
7349ea133fd7Smrg
7350ea133fd7Smrg	    exit $lt_exit
7351ea133fd7Smrg	  }
7352ea133fd7Smrg	done
7353ea133fd7Smrg	IFS="$save_ifs"
7354ea133fd7Smrg
7355ea133fd7Smrg	# Restore the uninstalled library and exit
7356ea133fd7Smrg	if test "$mode" = relink; then
7357ea133fd7Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
7358ea133fd7Smrg
7359ea133fd7Smrg	  if test -n "$convenience"; then
7360ea133fd7Smrg	    if test -z "$whole_archive_flag_spec"; then
7361ea133fd7Smrg	      func_show_eval '${RM}r "$gentop"'
7362a253d6aeSmrg	    fi
7363a253d6aeSmrg	  fi
7364a253d6aeSmrg
7365ea133fd7Smrg	  exit $EXIT_SUCCESS
7366ea133fd7Smrg	fi
7367a253d6aeSmrg
7368ea133fd7Smrg	# Create links to the real library.
7369ea133fd7Smrg	for linkname in $linknames; do
7370ea133fd7Smrg	  if test "$realname" != "$linkname"; then
7371ea133fd7Smrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
7372ea133fd7Smrg	  fi
7373ea133fd7Smrg	done
7374ea133fd7Smrg
7375ea133fd7Smrg	# If -module or -export-dynamic was specified, set the dlname.
7376ea133fd7Smrg	if test "$module" = yes || test "$export_dynamic" = yes; then
7377ea133fd7Smrg	  # On all known operating systems, these are identical.
7378ea133fd7Smrg	  dlname="$soname"
7379ea133fd7Smrg	fi
7380ea133fd7Smrg      fi
7381ea133fd7Smrg      ;;
7382ea133fd7Smrg
7383ea133fd7Smrg    obj)
7384ea133fd7Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
7385ea133fd7Smrg	func_warning "\`-dlopen' is ignored for objects"
7386ea133fd7Smrg      fi
7387ea133fd7Smrg
7388ea133fd7Smrg      case " $deplibs" in
7389ea133fd7Smrg      *\ -l* | *\ -L*)
7390ea133fd7Smrg	func_warning "\`-l' and \`-L' are ignored for objects" ;;
7391ea133fd7Smrg      esac
7392ea133fd7Smrg
7393ea133fd7Smrg      test -n "$rpath" && \
7394ea133fd7Smrg	func_warning "\`-rpath' is ignored for objects"
7395ea133fd7Smrg
7396ea133fd7Smrg      test -n "$xrpath" && \
7397ea133fd7Smrg	func_warning "\`-R' is ignored for objects"
7398ea133fd7Smrg
7399ea133fd7Smrg      test -n "$vinfo" && \
7400ea133fd7Smrg	func_warning "\`-version-info' is ignored for objects"
7401ea133fd7Smrg
7402ea133fd7Smrg      test -n "$release" && \
7403ea133fd7Smrg	func_warning "\`-release' is ignored for objects"
7404ea133fd7Smrg
7405ea133fd7Smrg      case $output in
7406ea133fd7Smrg      *.lo)
7407ea133fd7Smrg	test -n "$objs$old_deplibs" && \
7408ea133fd7Smrg	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
7409ea133fd7Smrg
7410ea133fd7Smrg	libobj=$output
7411ea133fd7Smrg	func_lo2o "$libobj"
7412ea133fd7Smrg	obj=$func_lo2o_result
7413ea133fd7Smrg	;;
7414ea133fd7Smrg      *)
7415ea133fd7Smrg	libobj=
7416ea133fd7Smrg	obj="$output"
7417ea133fd7Smrg	;;
7418ea133fd7Smrg      esac
7419ea133fd7Smrg
7420ea133fd7Smrg      # Delete the old objects.
7421ea133fd7Smrg      $opt_dry_run || $RM $obj $libobj
7422ea133fd7Smrg
7423ea133fd7Smrg      # Objects from convenience libraries.  This assumes
7424ea133fd7Smrg      # single-version convenience libraries.  Whenever we create
7425ea133fd7Smrg      # different ones for PIC/non-PIC, this we'll have to duplicate
7426ea133fd7Smrg      # the extraction.
7427ea133fd7Smrg      reload_conv_objs=
7428ea133fd7Smrg      gentop=
7429ea133fd7Smrg      # reload_cmds runs $LD directly, so let us get rid of
7430ea133fd7Smrg      # -Wl from whole_archive_flag_spec and hope we can get by with
7431ea133fd7Smrg      # turning comma into space..
7432ea133fd7Smrg      wl=
7433ea133fd7Smrg
7434ea133fd7Smrg      if test -n "$convenience"; then
7435ea133fd7Smrg	if test -n "$whole_archive_flag_spec"; then
7436ea133fd7Smrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
7437ea133fd7Smrg	  reload_conv_objs=$reload_objs\ `$ECHO "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'`
7438ea133fd7Smrg	else
7439ea133fd7Smrg	  gentop="$output_objdir/${obj}x"
7440ea133fd7Smrg	  generated="$generated $gentop"
7441ea133fd7Smrg
7442ea133fd7Smrg	  func_extract_archives $gentop $convenience
7443ea133fd7Smrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
7444ea133fd7Smrg	fi
7445ea133fd7Smrg      fi
7446a253d6aeSmrg
7447ea133fd7Smrg      # Create the old-style object.
7448ea133fd7Smrg      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
7449a253d6aeSmrg
7450ea133fd7Smrg      output="$obj"
7451ea133fd7Smrg      func_execute_cmds "$reload_cmds" 'exit $?'
7452a253d6aeSmrg
7453ea133fd7Smrg      # Exit if we aren't doing a library object file.
7454ea133fd7Smrg      if test -z "$libobj"; then
7455ea133fd7Smrg	if test -n "$gentop"; then
7456ea133fd7Smrg	  func_show_eval '${RM}r "$gentop"'
7457ea133fd7Smrg	fi
7458a253d6aeSmrg
7459ea133fd7Smrg	exit $EXIT_SUCCESS
7460ea133fd7Smrg      fi
7461a253d6aeSmrg
7462ea133fd7Smrg      if test "$build_libtool_libs" != yes; then
7463ea133fd7Smrg	if test -n "$gentop"; then
7464ea133fd7Smrg	  func_show_eval '${RM}r "$gentop"'
7465ea133fd7Smrg	fi
7466a253d6aeSmrg
7467ea133fd7Smrg	# Create an invalid libtool object if no PIC, so that we don't
7468ea133fd7Smrg	# accidentally link it into a program.
7469ea133fd7Smrg	# $show "echo timestamp > $libobj"
7470ea133fd7Smrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
7471ea133fd7Smrg	exit $EXIT_SUCCESS
7472ea133fd7Smrg      fi
7473a253d6aeSmrg
7474ea133fd7Smrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
7475ea133fd7Smrg	# Only do commands if we really have different PIC objects.
7476ea133fd7Smrg	reload_objs="$libobjs $reload_conv_objs"
7477ea133fd7Smrg	output="$libobj"
7478ea133fd7Smrg	func_execute_cmds "$reload_cmds" 'exit $?'
7479a253d6aeSmrg      fi
7480a253d6aeSmrg
7481ea133fd7Smrg      if test -n "$gentop"; then
7482ea133fd7Smrg	func_show_eval '${RM}r "$gentop"'
7483ea133fd7Smrg      fi
7484a253d6aeSmrg
7485ea133fd7Smrg      exit $EXIT_SUCCESS
7486ea133fd7Smrg      ;;
7487a253d6aeSmrg
7488ea133fd7Smrg    prog)
7489ea133fd7Smrg      case $host in
7490ea133fd7Smrg	*cygwin*) func_stripname '' '.exe' "$output"
7491ea133fd7Smrg	          output=$func_stripname_result.exe;;
7492a253d6aeSmrg      esac
7493ea133fd7Smrg      test -n "$vinfo" && \
7494ea133fd7Smrg	func_warning "\`-version-info' is ignored for programs"
7495a253d6aeSmrg
7496ea133fd7Smrg      test -n "$release" && \
7497ea133fd7Smrg	func_warning "\`-release' is ignored for programs"
7498a253d6aeSmrg
7499ea133fd7Smrg      test "$preload" = yes \
7500ea133fd7Smrg        && test "$dlopen_support" = unknown \
7501ea133fd7Smrg	&& test "$dlopen_self" = unknown \
7502ea133fd7Smrg	&& test "$dlopen_self_static" = unknown && \
7503ea133fd7Smrg	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
7504a253d6aeSmrg
7505ea133fd7Smrg      case $host in
7506ea133fd7Smrg      *-*-rhapsody* | *-*-darwin1.[012])
7507ea133fd7Smrg	# On Rhapsody replace the C library is the System framework
7508ea133fd7Smrg	compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
7509ea133fd7Smrg	finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
7510a253d6aeSmrg	;;
7511a253d6aeSmrg      esac
7512a253d6aeSmrg
7513ea133fd7Smrg      case $host in
7514ea133fd7Smrg      *-*-darwin*)
7515ea133fd7Smrg	# Don't allow lazy linking, it breaks C++ global constructors
7516ea133fd7Smrg	# But is supposedly fixed on 10.4 or later (yay!).
7517ea133fd7Smrg	if test "$tagname" = CXX ; then
7518ea133fd7Smrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
7519ea133fd7Smrg	    10.[0123])
7520ea133fd7Smrg	      compile_command="$compile_command ${wl}-bind_at_load"
7521ea133fd7Smrg	      finalize_command="$finalize_command ${wl}-bind_at_load"
7522ea133fd7Smrg	    ;;
7523ea133fd7Smrg	  esac
7524ea133fd7Smrg	fi
7525ea133fd7Smrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
7526ea133fd7Smrg	compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
7527ea133fd7Smrg	finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
7528a253d6aeSmrg	;;
7529a253d6aeSmrg      esac
7530a253d6aeSmrg
7531a253d6aeSmrg
7532ea133fd7Smrg      # move library search paths that coincide with paths to not yet
7533ea133fd7Smrg      # installed libraries to the beginning of the library search list
7534ea133fd7Smrg      new_libs=
7535ea133fd7Smrg      for path in $notinst_path; do
7536ea133fd7Smrg	case " $new_libs " in
7537ea133fd7Smrg	*" -L$path/$objdir "*) ;;
7538a253d6aeSmrg	*)
7539ea133fd7Smrg	  case " $compile_deplibs " in
7540ea133fd7Smrg	  *" -L$path/$objdir "*)
7541ea133fd7Smrg	    new_libs="$new_libs -L$path/$objdir" ;;
7542ea133fd7Smrg	  esac
7543a253d6aeSmrg	  ;;
7544a253d6aeSmrg	esac
7545a253d6aeSmrg      done
7546ea133fd7Smrg      for deplib in $compile_deplibs; do
7547ea133fd7Smrg	case $deplib in
7548ea133fd7Smrg	-L*)
7549ea133fd7Smrg	  case " $new_libs " in
7550ea133fd7Smrg	  *" $deplib "*) ;;
7551ea133fd7Smrg	  *) new_libs="$new_libs $deplib" ;;
7552ea133fd7Smrg	  esac
7553ea133fd7Smrg	  ;;
7554ea133fd7Smrg	*) new_libs="$new_libs $deplib" ;;
7555ea133fd7Smrg	esac
7556ea133fd7Smrg      done
7557ea133fd7Smrg      compile_deplibs="$new_libs"
7558a253d6aeSmrg
7559a253d6aeSmrg
7560ea133fd7Smrg      compile_command="$compile_command $compile_deplibs"
7561ea133fd7Smrg      finalize_command="$finalize_command $finalize_deplibs"
7562a253d6aeSmrg
7563ea133fd7Smrg      if test -n "$rpath$xrpath"; then
7564ea133fd7Smrg	# If the user specified any rpath flags, then add them.
7565ea133fd7Smrg	for libdir in $rpath $xrpath; do
7566ea133fd7Smrg	  # This is the magic to use -rpath.
7567ea133fd7Smrg	  case "$finalize_rpath " in
7568ea133fd7Smrg	  *" $libdir "*) ;;
7569ea133fd7Smrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
7570ea133fd7Smrg	  esac
7571ea133fd7Smrg	done
7572ea133fd7Smrg      fi
7573a253d6aeSmrg
7574ea133fd7Smrg      # Now hardcode the library paths
7575ea133fd7Smrg      rpath=
7576ea133fd7Smrg      hardcode_libdirs=
7577ea133fd7Smrg      for libdir in $compile_rpath $finalize_rpath; do
7578ea133fd7Smrg	if test -n "$hardcode_libdir_flag_spec"; then
7579ea133fd7Smrg	  if test -n "$hardcode_libdir_separator"; then
7580ea133fd7Smrg	    if test -z "$hardcode_libdirs"; then
7581ea133fd7Smrg	      hardcode_libdirs="$libdir"
7582ea133fd7Smrg	    else
7583ea133fd7Smrg	      # Just accumulate the unique libdirs.
7584ea133fd7Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
7585ea133fd7Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
7586ea133fd7Smrg		;;
7587ea133fd7Smrg	      *)
7588ea133fd7Smrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
7589ea133fd7Smrg		;;
7590ea133fd7Smrg	      esac
7591ea133fd7Smrg	    fi
7592ea133fd7Smrg	  else
7593ea133fd7Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
7594ea133fd7Smrg	    rpath="$rpath $flag"
7595ea133fd7Smrg	  fi
7596ea133fd7Smrg	elif test -n "$runpath_var"; then
7597ea133fd7Smrg	  case "$perm_rpath " in
7598a253d6aeSmrg	  *" $libdir "*) ;;
7599ea133fd7Smrg	  *) perm_rpath="$perm_rpath $libdir" ;;
7600a253d6aeSmrg	  esac
7601ea133fd7Smrg	fi
7602ea133fd7Smrg	case $host in
7603ea133fd7Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
7604ea133fd7Smrg	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
7605ea133fd7Smrg	  case :$dllsearchpath: in
7606ea133fd7Smrg	  *":$libdir:"*) ;;
7607ea133fd7Smrg	  ::) dllsearchpath=$libdir;;
7608ea133fd7Smrg	  *) dllsearchpath="$dllsearchpath:$libdir";;
7609ea133fd7Smrg	  esac
7610ea133fd7Smrg	  case :$dllsearchpath: in
7611ea133fd7Smrg	  *":$testbindir:"*) ;;
7612ea133fd7Smrg	  ::) dllsearchpath=$testbindir;;
7613ea133fd7Smrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
7614ea133fd7Smrg	  esac
7615ea133fd7Smrg	  ;;
7616ea133fd7Smrg	esac
7617ea133fd7Smrg      done
7618ea133fd7Smrg      # Substitute the hardcoded libdirs into the rpath.
7619ea133fd7Smrg      if test -n "$hardcode_libdir_separator" &&
7620ea133fd7Smrg	 test -n "$hardcode_libdirs"; then
7621ea133fd7Smrg	libdir="$hardcode_libdirs"
7622ea133fd7Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
7623ea133fd7Smrg      fi
7624ea133fd7Smrg      compile_rpath="$rpath"
7625ea133fd7Smrg
7626ea133fd7Smrg      rpath=
7627ea133fd7Smrg      hardcode_libdirs=
7628ea133fd7Smrg      for libdir in $finalize_rpath; do
7629ea133fd7Smrg	if test -n "$hardcode_libdir_flag_spec"; then
7630ea133fd7Smrg	  if test -n "$hardcode_libdir_separator"; then
7631ea133fd7Smrg	    if test -z "$hardcode_libdirs"; then
7632ea133fd7Smrg	      hardcode_libdirs="$libdir"
7633ea133fd7Smrg	    else
7634ea133fd7Smrg	      # Just accumulate the unique libdirs.
7635ea133fd7Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
7636ea133fd7Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
7637ea133fd7Smrg		;;
7638ea133fd7Smrg	      *)
7639ea133fd7Smrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
7640ea133fd7Smrg		;;
7641ea133fd7Smrg	      esac
7642ea133fd7Smrg	    fi
7643ea133fd7Smrg	  else
7644ea133fd7Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
7645ea133fd7Smrg	    rpath="$rpath $flag"
7646ea133fd7Smrg	  fi
7647ea133fd7Smrg	elif test -n "$runpath_var"; then
7648ea133fd7Smrg	  case "$finalize_perm_rpath " in
7649a253d6aeSmrg	  *" $libdir "*) ;;
7650ea133fd7Smrg	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
7651a253d6aeSmrg	  esac
7652a253d6aeSmrg	fi
7653ea133fd7Smrg      done
7654ea133fd7Smrg      # Substitute the hardcoded libdirs into the rpath.
7655ea133fd7Smrg      if test -n "$hardcode_libdir_separator" &&
7656ea133fd7Smrg	 test -n "$hardcode_libdirs"; then
7657ea133fd7Smrg	libdir="$hardcode_libdirs"
7658ea133fd7Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
7659ea133fd7Smrg      fi
7660ea133fd7Smrg      finalize_rpath="$rpath"
7661a253d6aeSmrg
7662ea133fd7Smrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
7663ea133fd7Smrg	# Transform all the library objects into standard objects.
7664ea133fd7Smrg	compile_command=`$ECHO "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
7665ea133fd7Smrg	finalize_command=`$ECHO "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
7666ea133fd7Smrg      fi
7667a253d6aeSmrg
7668ea133fd7Smrg      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
7669a253d6aeSmrg
7670ea133fd7Smrg      # template prelinking step
7671ea133fd7Smrg      if test -n "$prelink_cmds"; then
7672ea133fd7Smrg	func_execute_cmds "$prelink_cmds" 'exit $?'
7673ea133fd7Smrg      fi
7674a253d6aeSmrg
7675ea133fd7Smrg      wrappers_required=yes
7676ea133fd7Smrg      case $host in
7677ea133fd7Smrg      *cygwin* | *mingw* )
7678ea133fd7Smrg        if test "$build_libtool_libs" != yes; then
7679ea133fd7Smrg          wrappers_required=no
7680ea133fd7Smrg        fi
7681ea133fd7Smrg        ;;
7682ea133fd7Smrg      *cegcc)
7683ea133fd7Smrg        # Disable wrappers for cegcc, we are cross compiling anyway.
7684ea133fd7Smrg        wrappers_required=no
7685ea133fd7Smrg        ;;
7686ea133fd7Smrg      *)
7687ea133fd7Smrg        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
7688ea133fd7Smrg          wrappers_required=no
7689ea133fd7Smrg        fi
7690ea133fd7Smrg        ;;
7691ea133fd7Smrg      esac
7692ea133fd7Smrg      if test "$wrappers_required" = no; then
7693ea133fd7Smrg	# Replace the output file specification.
7694ea133fd7Smrg	compile_command=`$ECHO "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
7695ea133fd7Smrg	link_command="$compile_command$compile_rpath"
7696a253d6aeSmrg
7697ea133fd7Smrg	# We have no uninstalled library dependencies, so finalize right now.
7698ea133fd7Smrg	exit_status=0
7699ea133fd7Smrg	func_show_eval "$link_command" 'exit_status=$?'
7700a253d6aeSmrg
7701ea133fd7Smrg	# Delete the generated files.
7702ea133fd7Smrg	if test -f "$output_objdir/${outputname}S.${objext}"; then
7703ea133fd7Smrg	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
7704ea133fd7Smrg	fi
7705a253d6aeSmrg
7706ea133fd7Smrg	exit $exit_status
7707ea133fd7Smrg      fi
7708a253d6aeSmrg
7709ea133fd7Smrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
7710ea133fd7Smrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
7711ea133fd7Smrg      fi
7712ea133fd7Smrg      if test -n "$finalize_shlibpath"; then
7713ea133fd7Smrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
7714ea133fd7Smrg      fi
7715a253d6aeSmrg
7716ea133fd7Smrg      compile_var=
7717ea133fd7Smrg      finalize_var=
7718ea133fd7Smrg      if test -n "$runpath_var"; then
7719ea133fd7Smrg	if test -n "$perm_rpath"; then
7720ea133fd7Smrg	  # We should set the runpath_var.
7721ea133fd7Smrg	  rpath=
7722ea133fd7Smrg	  for dir in $perm_rpath; do
7723ea133fd7Smrg	    rpath="$rpath$dir:"
7724a253d6aeSmrg	  done
7725ea133fd7Smrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
7726a253d6aeSmrg	fi
7727ea133fd7Smrg	if test -n "$finalize_perm_rpath"; then
7728ea133fd7Smrg	  # We should set the runpath_var.
7729ea133fd7Smrg	  rpath=
7730ea133fd7Smrg	  for dir in $finalize_perm_rpath; do
7731ea133fd7Smrg	    rpath="$rpath$dir:"
7732ea133fd7Smrg	  done
7733ea133fd7Smrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
7734ea133fd7Smrg	fi
7735ea133fd7Smrg      fi
7736a253d6aeSmrg
7737ea133fd7Smrg      if test "$no_install" = yes; then
7738ea133fd7Smrg	# We don't need to create a wrapper script.
7739ea133fd7Smrg	link_command="$compile_var$compile_command$compile_rpath"
7740ea133fd7Smrg	# Replace the output file specification.
7741ea133fd7Smrg	link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
7742ea133fd7Smrg	# Delete the old output file.
7743ea133fd7Smrg	$opt_dry_run || $RM $output
7744ea133fd7Smrg	# Link the executable and exit
7745ea133fd7Smrg	func_show_eval "$link_command" 'exit $?'
7746ea133fd7Smrg	exit $EXIT_SUCCESS
7747ea133fd7Smrg      fi
7748a253d6aeSmrg
7749ea133fd7Smrg      if test "$hardcode_action" = relink; then
7750ea133fd7Smrg	# Fast installation is not supported
7751ea133fd7Smrg	link_command="$compile_var$compile_command$compile_rpath"
7752ea133fd7Smrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
7753a253d6aeSmrg
7754ea133fd7Smrg	func_warning "this platform does not like uninstalled shared libraries"
7755ea133fd7Smrg	func_warning "\`$output' will be relinked during installation"
7756ea133fd7Smrg      else
7757ea133fd7Smrg	if test "$fast_install" != no; then
7758ea133fd7Smrg	  link_command="$finalize_var$compile_command$finalize_rpath"
7759ea133fd7Smrg	  if test "$fast_install" = yes; then
7760ea133fd7Smrg	    relink_command=`$ECHO "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
7761ea133fd7Smrg	  else
7762ea133fd7Smrg	    # fast_install is set to needless
7763ea133fd7Smrg	    relink_command=
7764ea133fd7Smrg	  fi
7765a253d6aeSmrg	else
7766ea133fd7Smrg	  link_command="$compile_var$compile_command$compile_rpath"
7767ea133fd7Smrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
7768a253d6aeSmrg	fi
7769ea133fd7Smrg      fi
7770a253d6aeSmrg
7771ea133fd7Smrg      # Replace the output file specification.
7772ea133fd7Smrg      link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
7773a253d6aeSmrg
7774ea133fd7Smrg      # Delete the old output files.
7775ea133fd7Smrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
7776a253d6aeSmrg
7777ea133fd7Smrg      func_show_eval "$link_command" 'exit $?'
7778a253d6aeSmrg
7779ea133fd7Smrg      # Now create the wrapper script.
7780ea133fd7Smrg      func_verbose "creating $output"
7781a253d6aeSmrg
7782ea133fd7Smrg      # Quote the relink command for shipping.
7783ea133fd7Smrg      if test -n "$relink_command"; then
7784ea133fd7Smrg	# Preserve any variables that may affect compiler behavior
7785ea133fd7Smrg	for var in $variables_saved_for_relink; do
7786ea133fd7Smrg	  if eval test -z \"\${$var+set}\"; then
7787ea133fd7Smrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
7788ea133fd7Smrg	  elif eval var_value=\$$var; test -z "$var_value"; then
7789ea133fd7Smrg	    relink_command="$var=; export $var; $relink_command"
7790ea133fd7Smrg	  else
7791ea133fd7Smrg	    func_quote_for_eval "$var_value"
7792ea133fd7Smrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
7793ea133fd7Smrg	  fi
7794ea133fd7Smrg	done
7795ea133fd7Smrg	relink_command="(cd `pwd`; $relink_command)"
7796ea133fd7Smrg	relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
7797ea133fd7Smrg      fi
7798a253d6aeSmrg
7799ea133fd7Smrg      # Quote $ECHO for shipping.
7800ea133fd7Smrg      if test "X$ECHO" = "X$SHELL $progpath --fallback-echo"; then
7801ea133fd7Smrg	case $progpath in
7802ea133fd7Smrg	[\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
7803ea133fd7Smrg	*) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
7804a253d6aeSmrg	esac
7805ea133fd7Smrg	qecho=`$ECHO "X$qecho" | $Xsed -e "$sed_quote_subst"`
7806ea133fd7Smrg      else
7807ea133fd7Smrg	qecho=`$ECHO "X$ECHO" | $Xsed -e "$sed_quote_subst"`
7808ea133fd7Smrg      fi
7809a253d6aeSmrg
7810ea133fd7Smrg      # Only actually do things if not in dry run mode.
7811ea133fd7Smrg      $opt_dry_run || {
7812ea133fd7Smrg	# win32 will think the script is a binary if it has
7813ea133fd7Smrg	# a .exe suffix, so we strip it off here.
7814ea133fd7Smrg	case $output in
7815ea133fd7Smrg	  *.exe) func_stripname '' '.exe' "$output"
7816ea133fd7Smrg	         output=$func_stripname_result ;;
7817ea133fd7Smrg	esac
7818ea133fd7Smrg	# test for cygwin because mv fails w/o .exe extensions
7819a253d6aeSmrg	case $host in
7820ea133fd7Smrg	  *cygwin*)
7821ea133fd7Smrg	    exeext=.exe
7822ea133fd7Smrg	    func_stripname '' '.exe' "$outputname"
7823ea133fd7Smrg	    outputname=$func_stripname_result ;;
7824ea133fd7Smrg	  *) exeext= ;;
7825a253d6aeSmrg	esac
7826ea133fd7Smrg	case $host in
7827ea133fd7Smrg	  *cygwin* | *mingw* )
7828ea133fd7Smrg	    func_dirname_and_basename "$output" "" "."
7829ea133fd7Smrg	    output_name=$func_basename_result
7830ea133fd7Smrg	    output_path=$func_dirname_result
7831ea133fd7Smrg	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
7832ea133fd7Smrg	    cwrapper="$output_path/$output_name.exe"
7833ea133fd7Smrg	    $RM $cwrappersource $cwrapper
7834ea133fd7Smrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
7835ea133fd7Smrg
7836ea133fd7Smrg	    func_emit_cwrapperexe_src > $cwrappersource
7837ea133fd7Smrg
7838ea133fd7Smrg	    # The wrapper executable is built using the $host compiler,
7839ea133fd7Smrg	    # because it contains $host paths and files. If cross-
7840ea133fd7Smrg	    # compiling, it, like the target executable, must be
7841ea133fd7Smrg	    # executed on the $host or under an emulation environment.
7842ea133fd7Smrg	    $opt_dry_run || {
7843ea133fd7Smrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
7844ea133fd7Smrg	      $STRIP $cwrapper
7845ea133fd7Smrg	    }
7846a253d6aeSmrg
7847ea133fd7Smrg	    # Now, create the wrapper script for func_source use:
7848ea133fd7Smrg	    func_ltwrapper_scriptname $cwrapper
7849ea133fd7Smrg	    $RM $func_ltwrapper_scriptname_result
7850ea133fd7Smrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
7851ea133fd7Smrg	    $opt_dry_run || {
7852ea133fd7Smrg	      # note: this script will not be executed, so do not chmod.
7853ea133fd7Smrg	      if test "x$build" = "x$host" ; then
7854ea133fd7Smrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
7855a253d6aeSmrg	      else
7856ea133fd7Smrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
7857a253d6aeSmrg	      fi
7858ea133fd7Smrg	    }
7859ea133fd7Smrg	  ;;
7860ea133fd7Smrg	  * )
7861ea133fd7Smrg	    $RM $output
7862ea133fd7Smrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
7863a253d6aeSmrg
7864ea133fd7Smrg	    func_emit_wrapper no > $output
7865ea133fd7Smrg	    chmod +x $output
7866a253d6aeSmrg	  ;;
7867a253d6aeSmrg	esac
7868ea133fd7Smrg      }
7869ea133fd7Smrg      exit $EXIT_SUCCESS
7870ea133fd7Smrg      ;;
7871ea133fd7Smrg    esac
7872a253d6aeSmrg
7873ea133fd7Smrg    # See if we need to build an old-fashioned archive.
7874ea133fd7Smrg    for oldlib in $oldlibs; do
7875a253d6aeSmrg
7876ea133fd7Smrg      if test "$build_libtool_libs" = convenience; then
7877ea133fd7Smrg	oldobjs="$libobjs_save $symfileobj"
7878ea133fd7Smrg	addlibs="$convenience"
7879ea133fd7Smrg	build_libtool_libs=no
7880ea133fd7Smrg      else
7881ea133fd7Smrg	if test "$build_libtool_libs" = module; then
7882ea133fd7Smrg	  oldobjs="$libobjs_save"
7883ea133fd7Smrg	  build_libtool_libs=no
7884ea133fd7Smrg	else
7885ea133fd7Smrg	  oldobjs="$old_deplibs $non_pic_objects"
7886ea133fd7Smrg	  if test "$preload" = yes && test -f "$symfileobj"; then
7887ea133fd7Smrg	    oldobjs="$oldobjs $symfileobj"
7888ea133fd7Smrg	  fi
7889ea133fd7Smrg	fi
7890ea133fd7Smrg	addlibs="$old_convenience"
7891a253d6aeSmrg      fi
7892a253d6aeSmrg
7893ea133fd7Smrg      if test -n "$addlibs"; then
7894ea133fd7Smrg	gentop="$output_objdir/${outputname}x"
7895ea133fd7Smrg	generated="$generated $gentop"
7896a253d6aeSmrg
7897ea133fd7Smrg	func_extract_archives $gentop $addlibs
7898ea133fd7Smrg	oldobjs="$oldobjs $func_extract_archives_result"
7899ea133fd7Smrg      fi
7900a253d6aeSmrg
7901ea133fd7Smrg      # Do each command in the archive commands.
7902ea133fd7Smrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
7903ea133fd7Smrg	cmds=$old_archive_from_new_cmds
7904ea133fd7Smrg      else
7905a253d6aeSmrg
7906ea133fd7Smrg	# Add any objects from preloaded convenience libraries
7907ea133fd7Smrg	if test -n "$dlprefiles"; then
7908ea133fd7Smrg	  gentop="$output_objdir/${outputname}x"
7909ea133fd7Smrg	  generated="$generated $gentop"
7910a253d6aeSmrg
7911ea133fd7Smrg	  func_extract_archives $gentop $dlprefiles
7912ea133fd7Smrg	  oldobjs="$oldobjs $func_extract_archives_result"
7913ea133fd7Smrg	fi
7914a253d6aeSmrg
7915ea133fd7Smrg	# POSIX demands no paths to be encoded in archives.  We have
7916ea133fd7Smrg	# to avoid creating archives with duplicate basenames if we
7917ea133fd7Smrg	# might have to extract them afterwards, e.g., when creating a
7918ea133fd7Smrg	# static archive out of a convenience library, or when linking
7919ea133fd7Smrg	# the entirety of a libtool archive into another (currently
7920ea133fd7Smrg	# not supported by libtool).
7921ea133fd7Smrg	if (for obj in $oldobjs
7922ea133fd7Smrg	    do
7923ea133fd7Smrg	      func_basename "$obj"
7924ea133fd7Smrg	      $ECHO "$func_basename_result"
7925ea133fd7Smrg	    done | sort | sort -uc >/dev/null 2>&1); then
7926ea133fd7Smrg	  :
7927ea133fd7Smrg	else
7928ea133fd7Smrg	  $ECHO "copying selected object files to avoid basename conflicts..."
7929ea133fd7Smrg	  gentop="$output_objdir/${outputname}x"
7930ea133fd7Smrg	  generated="$generated $gentop"
7931ea133fd7Smrg	  func_mkdir_p "$gentop"
7932ea133fd7Smrg	  save_oldobjs=$oldobjs
7933ea133fd7Smrg	  oldobjs=
7934ea133fd7Smrg	  counter=1
7935ea133fd7Smrg	  for obj in $save_oldobjs
7936ea133fd7Smrg	  do
7937ea133fd7Smrg	    func_basename "$obj"
7938ea133fd7Smrg	    objbase="$func_basename_result"
7939ea133fd7Smrg	    case " $oldobjs " in
7940ea133fd7Smrg	    " ") oldobjs=$obj ;;
7941ea133fd7Smrg	    *[\ /]"$objbase "*)
7942ea133fd7Smrg	      while :; do
7943ea133fd7Smrg		# Make sure we don't pick an alternate name that also
7944ea133fd7Smrg		# overlaps.
7945ea133fd7Smrg		newobj=lt$counter-$objbase
7946ea133fd7Smrg		func_arith $counter + 1
7947ea133fd7Smrg		counter=$func_arith_result
7948ea133fd7Smrg		case " $oldobjs " in
7949ea133fd7Smrg		*[\ /]"$newobj "*) ;;
7950ea133fd7Smrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
7951ea133fd7Smrg		esac
7952ea133fd7Smrg	      done
7953ea133fd7Smrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
7954ea133fd7Smrg	      oldobjs="$oldobjs $gentop/$newobj"
7955ea133fd7Smrg	      ;;
7956ea133fd7Smrg	    *) oldobjs="$oldobjs $obj" ;;
7957ea133fd7Smrg	    esac
7958a253d6aeSmrg	  done
7959a253d6aeSmrg	fi
7960ea133fd7Smrg	eval cmds=\"$old_archive_cmds\"
7961a253d6aeSmrg
7962ea133fd7Smrg	func_len " $cmds"
7963ea133fd7Smrg	len=$func_len_result
7964ea133fd7Smrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
7965ea133fd7Smrg	  cmds=$old_archive_cmds
7966ea133fd7Smrg	else
7967ea133fd7Smrg	  # the command line is too long to link in one step, link in parts
7968ea133fd7Smrg	  func_verbose "using piecewise archive linking..."
7969ea133fd7Smrg	  save_RANLIB=$RANLIB
7970ea133fd7Smrg	  RANLIB=:
7971ea133fd7Smrg	  objlist=
7972ea133fd7Smrg	  concat_cmds=
7973ea133fd7Smrg	  save_oldobjs=$oldobjs
7974ea133fd7Smrg	  oldobjs=
7975ea133fd7Smrg	  # Is there a better way of finding the last object in the list?
7976ea133fd7Smrg	  for obj in $save_oldobjs
7977ea133fd7Smrg	  do
7978ea133fd7Smrg	    last_oldobj=$obj
7979ea133fd7Smrg	  done
7980ea133fd7Smrg	  eval test_cmds=\"$old_archive_cmds\"
7981ea133fd7Smrg	  func_len " $test_cmds"
7982ea133fd7Smrg	  len0=$func_len_result
7983ea133fd7Smrg	  len=$len0
7984ea133fd7Smrg	  for obj in $save_oldobjs
7985ea133fd7Smrg	  do
7986ea133fd7Smrg	    func_len " $obj"
7987ea133fd7Smrg	    func_arith $len + $func_len_result
7988ea133fd7Smrg	    len=$func_arith_result
7989ea133fd7Smrg	    func_append objlist " $obj"
7990ea133fd7Smrg	    if test "$len" -lt "$max_cmd_len"; then
7991ea133fd7Smrg	      :
7992ea133fd7Smrg	    else
7993ea133fd7Smrg	      # the above command should be used before it gets too long
7994ea133fd7Smrg	      oldobjs=$objlist
7995ea133fd7Smrg	      if test "$obj" = "$last_oldobj" ; then
7996ea133fd7Smrg		RANLIB=$save_RANLIB
7997ea133fd7Smrg	      fi
7998ea133fd7Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
7999ea133fd7Smrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
8000ea133fd7Smrg	      objlist=
8001ea133fd7Smrg	      len=$len0
8002ea133fd7Smrg	    fi
8003ea133fd7Smrg	  done
8004ea133fd7Smrg	  RANLIB=$save_RANLIB
8005ea133fd7Smrg	  oldobjs=$objlist
8006ea133fd7Smrg	  if test "X$oldobjs" = "X" ; then
8007ea133fd7Smrg	    eval cmds=\"\$concat_cmds\"
8008ea133fd7Smrg	  else
8009ea133fd7Smrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
8010ea133fd7Smrg	  fi
8011ea133fd7Smrg	fi
8012ea133fd7Smrg      fi
8013ea133fd7Smrg      func_execute_cmds "$cmds" 'exit $?'
8014a253d6aeSmrg    done
8015a253d6aeSmrg
8016ea133fd7Smrg    test -n "$generated" && \
8017ea133fd7Smrg      func_show_eval "${RM}r$generated"
8018a253d6aeSmrg
8019ea133fd7Smrg    # Now create the libtool archive.
8020ea133fd7Smrg    case $output in
8021ea133fd7Smrg    *.la)
8022ea133fd7Smrg      old_library=
8023ea133fd7Smrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
8024ea133fd7Smrg      func_verbose "creating $output"
8025a253d6aeSmrg
8026ea133fd7Smrg      # Preserve any variables that may affect compiler behavior
8027ea133fd7Smrg      for var in $variables_saved_for_relink; do
8028ea133fd7Smrg	if eval test -z \"\${$var+set}\"; then
8029ea133fd7Smrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
8030ea133fd7Smrg	elif eval var_value=\$$var; test -z "$var_value"; then
8031ea133fd7Smrg	  relink_command="$var=; export $var; $relink_command"
8032a253d6aeSmrg	else
8033ea133fd7Smrg	  func_quote_for_eval "$var_value"
8034ea133fd7Smrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
8035a253d6aeSmrg	fi
8036ea133fd7Smrg      done
8037ea133fd7Smrg      # Quote the link command for shipping.
8038ea133fd7Smrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
8039ea133fd7Smrg      relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
8040ea133fd7Smrg      if test "$hardcode_automatic" = yes ; then
8041ea133fd7Smrg	relink_command=
8042ea133fd7Smrg      fi
8043a253d6aeSmrg
8044ea133fd7Smrg      # Only create the output if not a dry run.
8045ea133fd7Smrg      $opt_dry_run || {
8046ea133fd7Smrg	for installed in no yes; do
8047ea133fd7Smrg	  if test "$installed" = yes; then
8048ea133fd7Smrg	    if test -z "$install_libdir"; then
8049ea133fd7Smrg	      break
8050ea133fd7Smrg	    fi
8051ea133fd7Smrg	    output="$output_objdir/$outputname"i
8052ea133fd7Smrg	    # Replace all uninstalled libtool libraries with the installed ones
8053ea133fd7Smrg	    newdependency_libs=
8054ea133fd7Smrg	    for deplib in $dependency_libs; do
8055ea133fd7Smrg	      case $deplib in
8056ea133fd7Smrg	      *.la)
8057ea133fd7Smrg		func_basename "$deplib"
8058ea133fd7Smrg		name="$func_basename_result"
8059ea133fd7Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
8060ea133fd7Smrg		test -z "$libdir" && \
8061ea133fd7Smrg		  func_fatal_error "\`$deplib' is not a valid libtool archive"
8062ea133fd7Smrg		newdependency_libs="$newdependency_libs $libdir/$name"
8063ea133fd7Smrg		;;
8064ea133fd7Smrg	      *) newdependency_libs="$newdependency_libs $deplib" ;;
8065ea133fd7Smrg	      esac
8066ea133fd7Smrg	    done
8067ea133fd7Smrg	    dependency_libs="$newdependency_libs"
8068ea133fd7Smrg	    newdlfiles=
8069ea133fd7Smrg
8070ea133fd7Smrg	    for lib in $dlfiles; do
8071ea133fd7Smrg	      case $lib in
8072ea133fd7Smrg	      *.la)
8073ea133fd7Smrg	        func_basename "$lib"
8074ea133fd7Smrg		name="$func_basename_result"
8075ea133fd7Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
8076ea133fd7Smrg		test -z "$libdir" && \
8077ea133fd7Smrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
8078ea133fd7Smrg		newdlfiles="$newdlfiles $libdir/$name"
8079ea133fd7Smrg		;;
8080ea133fd7Smrg	      *) newdlfiles="$newdlfiles $lib" ;;
8081ea133fd7Smrg	      esac
8082ea133fd7Smrg	    done
8083ea133fd7Smrg	    dlfiles="$newdlfiles"
8084ea133fd7Smrg	    newdlprefiles=
8085ea133fd7Smrg	    for lib in $dlprefiles; do
8086ea133fd7Smrg	      case $lib in
8087ea133fd7Smrg	      *.la)
8088ea133fd7Smrg		# Only pass preopened files to the pseudo-archive (for
8089ea133fd7Smrg		# eventual linking with the app. that links it) if we
8090ea133fd7Smrg		# didn't already link the preopened objects directly into
8091ea133fd7Smrg		# the library:
8092ea133fd7Smrg		func_basename "$lib"
8093ea133fd7Smrg		name="$func_basename_result"
8094ea133fd7Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
8095ea133fd7Smrg		test -z "$libdir" && \
8096ea133fd7Smrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
8097ea133fd7Smrg		newdlprefiles="$newdlprefiles $libdir/$name"
8098ea133fd7Smrg		;;
8099ea133fd7Smrg	      esac
8100ea133fd7Smrg	    done
8101ea133fd7Smrg	    dlprefiles="$newdlprefiles"
8102ea133fd7Smrg	  else
8103ea133fd7Smrg	    newdlfiles=
8104ea133fd7Smrg	    for lib in $dlfiles; do
8105ea133fd7Smrg	      case $lib in
8106ea133fd7Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
8107ea133fd7Smrg		*) abs=`pwd`"/$lib" ;;
8108ea133fd7Smrg	      esac
8109ea133fd7Smrg	      newdlfiles="$newdlfiles $abs"
8110ea133fd7Smrg	    done
8111ea133fd7Smrg	    dlfiles="$newdlfiles"
8112ea133fd7Smrg	    newdlprefiles=
8113ea133fd7Smrg	    for lib in $dlprefiles; do
8114ea133fd7Smrg	      case $lib in
8115ea133fd7Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
8116ea133fd7Smrg		*) abs=`pwd`"/$lib" ;;
8117ea133fd7Smrg	      esac
8118ea133fd7Smrg	      newdlprefiles="$newdlprefiles $abs"
8119ea133fd7Smrg	    done
8120ea133fd7Smrg	    dlprefiles="$newdlprefiles"
8121ea133fd7Smrg	  fi
8122ea133fd7Smrg	  $RM $output
8123ea133fd7Smrg	  # place dlname in correct position for cygwin
8124ea133fd7Smrg	  tdlname=$dlname
8125ea133fd7Smrg	  case $host,$output,$installed,$module,$dlname in
8126ea133fd7Smrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
8127ea133fd7Smrg	  esac
8128ea133fd7Smrg	  $ECHO > $output "\
8129ea133fd7Smrg# $outputname - a libtool library file
8130ea133fd7Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
8131ea133fd7Smrg#
8132ea133fd7Smrg# Please DO NOT delete this file!
8133ea133fd7Smrg# It is necessary for linking the library.
8134a253d6aeSmrg
8135ea133fd7Smrg# The name that we can dlopen(3).
8136ea133fd7Smrgdlname='$tdlname'
8137a253d6aeSmrg
8138ea133fd7Smrg# Names of this library.
8139ea133fd7Smrglibrary_names='$library_names'
8140a253d6aeSmrg
8141ea133fd7Smrg# The name of the static archive.
8142ea133fd7Smrgold_library='$old_library'
8143a253d6aeSmrg
8144ea133fd7Smrg# Linker flags that can not go in dependency_libs.
8145ea133fd7Smrginherited_linker_flags='$new_inherited_linker_flags'
8146a253d6aeSmrg
8147ea133fd7Smrg# Libraries that this one depends upon.
8148ea133fd7Smrgdependency_libs='$dependency_libs'
8149a253d6aeSmrg
8150ea133fd7Smrg# Names of additional weak libraries provided by this library
8151ea133fd7Smrgweak_library_names='$weak_libs'
8152a253d6aeSmrg
8153ea133fd7Smrg# Version information for $libname.
8154ea133fd7Smrgcurrent=$current
8155ea133fd7Smrgage=$age
8156ea133fd7Smrgrevision=$revision
8157a253d6aeSmrg
8158ea133fd7Smrg# Is this an already installed library?
8159ea133fd7Smrginstalled=$installed
8160a253d6aeSmrg
8161ea133fd7Smrg# Should we warn about portability when linking against -modules?
8162ea133fd7Smrgshouldnotlink=$module
8163a253d6aeSmrg
8164ea133fd7Smrg# Files to dlopen/dlpreopen
8165ea133fd7Smrgdlopen='$dlfiles'
8166ea133fd7Smrgdlpreopen='$dlprefiles'
8167a253d6aeSmrg
8168ea133fd7Smrg# Directory that this library needs to be installed in:
8169ea133fd7Smrglibdir='$install_libdir'"
8170ea133fd7Smrg	  if test "$installed" = no && test "$need_relink" = yes; then
8171ea133fd7Smrg	    $ECHO >> $output "\
8172ea133fd7Smrgrelink_command=\"$relink_command\""
8173ea133fd7Smrg	  fi
8174ea133fd7Smrg	done
8175ea133fd7Smrg      }
8176a253d6aeSmrg
8177ea133fd7Smrg      # Do a symbolic link so that the libtool archive can be found in
8178ea133fd7Smrg      # LD_LIBRARY_PATH before the program is installed.
8179ea133fd7Smrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
8180ea133fd7Smrg      ;;
8181ea133fd7Smrg    esac
8182ea133fd7Smrg    exit $EXIT_SUCCESS
8183ea133fd7Smrg}
8184a253d6aeSmrg
8185ea133fd7Smrg{ test "$mode" = link || test "$mode" = relink; } &&
8186ea133fd7Smrg    func_mode_link ${1+"$@"}
8187a253d6aeSmrg
8188a253d6aeSmrg
8189ea133fd7Smrg# func_mode_uninstall arg...
8190ea133fd7Smrgfunc_mode_uninstall ()
8191ea133fd7Smrg{
8192ea133fd7Smrg    $opt_debug
8193ea133fd7Smrg    RM="$nonopt"
8194a253d6aeSmrg    files=
8195a253d6aeSmrg    rmforce=
8196a253d6aeSmrg    exit_status=0
8197a253d6aeSmrg
8198a253d6aeSmrg    # This variable tells wrapper scripts just to set variables rather
8199a253d6aeSmrg    # than running their programs.
8200a253d6aeSmrg    libtool_install_magic="$magic"
8201a253d6aeSmrg
8202a253d6aeSmrg    for arg
8203a253d6aeSmrg    do
8204a253d6aeSmrg      case $arg in
8205ea133fd7Smrg      -f) RM="$RM $arg"; rmforce=yes ;;
8206ea133fd7Smrg      -*) RM="$RM $arg" ;;
8207a253d6aeSmrg      *) files="$files $arg" ;;
8208a253d6aeSmrg      esac
8209a253d6aeSmrg    done
8210a253d6aeSmrg
8211ea133fd7Smrg    test -z "$RM" && \
8212ea133fd7Smrg      func_fatal_help "you must specify an RM program"
8213a253d6aeSmrg
8214a253d6aeSmrg    rmdirs=
8215a253d6aeSmrg
8216a253d6aeSmrg    origobjdir="$objdir"
8217a253d6aeSmrg    for file in $files; do
8218ea133fd7Smrg      func_dirname "$file" "" "."
8219ea133fd7Smrg      dir="$func_dirname_result"
8220ea133fd7Smrg      if test "X$dir" = X.; then
8221a253d6aeSmrg	objdir="$origobjdir"
8222a253d6aeSmrg      else
8223a253d6aeSmrg	objdir="$dir/$origobjdir"
8224a253d6aeSmrg      fi
8225ea133fd7Smrg      func_basename "$file"
8226ea133fd7Smrg      name="$func_basename_result"
8227a253d6aeSmrg      test "$mode" = uninstall && objdir="$dir"
8228a253d6aeSmrg
8229a253d6aeSmrg      # Remember objdir for removal later, being careful to avoid duplicates
8230a253d6aeSmrg      if test "$mode" = clean; then
8231a253d6aeSmrg	case " $rmdirs " in
8232a253d6aeSmrg	  *" $objdir "*) ;;
8233a253d6aeSmrg	  *) rmdirs="$rmdirs $objdir" ;;
8234a253d6aeSmrg	esac
8235a253d6aeSmrg      fi
8236a253d6aeSmrg
8237a253d6aeSmrg      # Don't error if the file doesn't exist and rm -f was used.
8238ea133fd7Smrg      if { test -L "$file"; } >/dev/null 2>&1 ||
8239ea133fd7Smrg	 { test -h "$file"; } >/dev/null 2>&1 ||
8240ea133fd7Smrg	 test -f "$file"; then
8241a253d6aeSmrg	:
8242a253d6aeSmrg      elif test -d "$file"; then
8243a253d6aeSmrg	exit_status=1
8244a253d6aeSmrg	continue
8245a253d6aeSmrg      elif test "$rmforce" = yes; then
8246a253d6aeSmrg	continue
8247a253d6aeSmrg      fi
8248a253d6aeSmrg
8249a253d6aeSmrg      rmfiles="$file"
8250a253d6aeSmrg
8251a253d6aeSmrg      case $name in
8252a253d6aeSmrg      *.la)
8253a253d6aeSmrg	# Possibly a libtool archive, so verify it.
8254ea133fd7Smrg	if func_lalib_p "$file"; then
8255ea133fd7Smrg	  func_source $dir/$name
8256a253d6aeSmrg
8257a253d6aeSmrg	  # Delete the libtool libraries and symlinks.
8258a253d6aeSmrg	  for n in $library_names; do
8259a253d6aeSmrg	    rmfiles="$rmfiles $objdir/$n"
8260a253d6aeSmrg	  done
8261a253d6aeSmrg	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
8262a253d6aeSmrg
8263a253d6aeSmrg	  case "$mode" in
8264a253d6aeSmrg	  clean)
8265a253d6aeSmrg	    case "  $library_names " in
8266a253d6aeSmrg	    # "  " in the beginning catches empty $dlname
8267a253d6aeSmrg	    *" $dlname "*) ;;
8268a253d6aeSmrg	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
8269a253d6aeSmrg	    esac
8270ea133fd7Smrg	    test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
8271a253d6aeSmrg	    ;;
8272a253d6aeSmrg	  uninstall)
8273a253d6aeSmrg	    if test -n "$library_names"; then
8274a253d6aeSmrg	      # Do each command in the postuninstall commands.
8275ea133fd7Smrg	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
8276a253d6aeSmrg	    fi
8277a253d6aeSmrg
8278a253d6aeSmrg	    if test -n "$old_library"; then
8279a253d6aeSmrg	      # Do each command in the old_postuninstall commands.
8280ea133fd7Smrg	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
8281a253d6aeSmrg	    fi
8282a253d6aeSmrg	    # FIXME: should reinstall the best remaining shared library.
8283a253d6aeSmrg	    ;;
8284a253d6aeSmrg	  esac
8285a253d6aeSmrg	fi
8286a253d6aeSmrg	;;
8287a253d6aeSmrg
8288a253d6aeSmrg      *.lo)
8289a253d6aeSmrg	# Possibly a libtool object, so verify it.
8290ea133fd7Smrg	if func_lalib_p "$file"; then
8291a253d6aeSmrg
8292a253d6aeSmrg	  # Read the .lo file
8293ea133fd7Smrg	  func_source $dir/$name
8294a253d6aeSmrg
8295a253d6aeSmrg	  # Add PIC object to the list of files to remove.
8296ea133fd7Smrg	  if test -n "$pic_object" &&
8297ea133fd7Smrg	     test "$pic_object" != none; then
8298a253d6aeSmrg	    rmfiles="$rmfiles $dir/$pic_object"
8299a253d6aeSmrg	  fi
8300a253d6aeSmrg
8301a253d6aeSmrg	  # Add non-PIC object to the list of files to remove.
8302ea133fd7Smrg	  if test -n "$non_pic_object" &&
8303ea133fd7Smrg	     test "$non_pic_object" != none; then
8304a253d6aeSmrg	    rmfiles="$rmfiles $dir/$non_pic_object"
8305a253d6aeSmrg	  fi
8306a253d6aeSmrg	fi
8307a253d6aeSmrg	;;
8308a253d6aeSmrg
8309a253d6aeSmrg      *)
8310a253d6aeSmrg	if test "$mode" = clean ; then
8311a253d6aeSmrg	  noexename=$name
8312a253d6aeSmrg	  case $file in
8313a253d6aeSmrg	  *.exe)
8314ea133fd7Smrg	    func_stripname '' '.exe' "$file"
8315ea133fd7Smrg	    file=$func_stripname_result
8316ea133fd7Smrg	    func_stripname '' '.exe' "$name"
8317ea133fd7Smrg	    noexename=$func_stripname_result
8318a253d6aeSmrg	    # $file with .exe has already been added to rmfiles,
8319a253d6aeSmrg	    # add $file without .exe
8320a253d6aeSmrg	    rmfiles="$rmfiles $file"
8321a253d6aeSmrg	    ;;
8322a253d6aeSmrg	  esac
8323a253d6aeSmrg	  # Do a test to see if this is a libtool program.
8324ea133fd7Smrg	  if func_ltwrapper_p "$file"; then
8325ea133fd7Smrg	    if func_ltwrapper_executable_p "$file"; then
8326ea133fd7Smrg	      func_ltwrapper_scriptname "$file"
8327ea133fd7Smrg	      relink_command=
8328ea133fd7Smrg	      func_source $func_ltwrapper_scriptname_result
8329ea133fd7Smrg	      rmfiles="$rmfiles $func_ltwrapper_scriptname_result"
8330ea133fd7Smrg	    else
8331ea133fd7Smrg	      relink_command=
8332ea133fd7Smrg	      func_source $dir/$noexename
8333ea133fd7Smrg	    fi
8334a253d6aeSmrg
8335a253d6aeSmrg	    # note $name still contains .exe if it was in $file originally
8336a253d6aeSmrg	    # as does the version of $file that was added into $rmfiles
8337a253d6aeSmrg	    rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
8338a253d6aeSmrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
8339a253d6aeSmrg	      rmfiles="$rmfiles $objdir/lt-$name"
8340a253d6aeSmrg	    fi
8341a253d6aeSmrg	    if test "X$noexename" != "X$name" ; then
8342a253d6aeSmrg	      rmfiles="$rmfiles $objdir/lt-${noexename}.c"
8343a253d6aeSmrg	    fi
8344a253d6aeSmrg	  fi
8345a253d6aeSmrg	fi
8346a253d6aeSmrg	;;
8347a253d6aeSmrg      esac
8348ea133fd7Smrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
8349a253d6aeSmrg    done
8350a253d6aeSmrg    objdir="$origobjdir"
8351a253d6aeSmrg
8352a253d6aeSmrg    # Try to remove the ${objdir}s in the directories where we deleted files
8353a253d6aeSmrg    for dir in $rmdirs; do
8354a253d6aeSmrg      if test -d "$dir"; then
8355ea133fd7Smrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
8356a253d6aeSmrg      fi
8357a253d6aeSmrg    done
8358a253d6aeSmrg
8359a253d6aeSmrg    exit $exit_status
8360ea133fd7Smrg}
8361a253d6aeSmrg
8362ea133fd7Smrg{ test "$mode" = uninstall || test "$mode" = clean; } &&
8363ea133fd7Smrg    func_mode_uninstall ${1+"$@"}
8364a253d6aeSmrg
8365ea133fd7Smrgtest -z "$mode" && {
8366ea133fd7Smrg  help="$generic_help"
8367ea133fd7Smrg  func_fatal_help "you must specify a MODE"
8368ea133fd7Smrg}
8369ea133fd7Smrg
8370ea133fd7Smrgtest -z "$exec_cmd" && \
8371ea133fd7Smrg  func_fatal_help "invalid operation mode \`$mode'"
8372a253d6aeSmrg
8373a253d6aeSmrgif test -n "$exec_cmd"; then
8374ea133fd7Smrg  eval exec "$exec_cmd"
8375a253d6aeSmrg  exit $EXIT_FAILURE
8376a253d6aeSmrgfi
8377a253d6aeSmrg
8378ea133fd7Smrgexit $exit_status
8379a253d6aeSmrg
8380a253d6aeSmrg
8381a253d6aeSmrg# The TAGs below are defined such that we never get into a situation
8382a253d6aeSmrg# in which we disable both kinds of libraries.  Given conflicting
8383a253d6aeSmrg# choices, we go for a static library, that is the most portable,
8384a253d6aeSmrg# since we can't tell whether shared libraries were disabled because
8385a253d6aeSmrg# the user asked for that or because the platform doesn't support
8386a253d6aeSmrg# them.  This is particularly important on AIX, because we don't
8387a253d6aeSmrg# support having both static and shared libraries enabled at the same
8388a253d6aeSmrg# time on that platform, so we default to a shared-only configuration.
8389a253d6aeSmrg# If a disable-shared tag is given, we'll fallback to a static-only
8390a253d6aeSmrg# configuration.  But we'll never go from static-only to shared-only.
8391a253d6aeSmrg
8392a253d6aeSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
8393ea133fd7Smrgbuild_libtool_libs=no
8394ea133fd7Smrgbuild_old_libs=yes
8395a253d6aeSmrg# ### END LIBTOOL TAG CONFIG: disable-shared
8396a253d6aeSmrg
8397a253d6aeSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
8398ea133fd7Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
8399a253d6aeSmrg# ### END LIBTOOL TAG CONFIG: disable-static
8400a253d6aeSmrg
8401a253d6aeSmrg# Local Variables:
8402a253d6aeSmrg# mode:shell-script
8403a253d6aeSmrg# sh-indentation:2
8404a253d6aeSmrg# End:
8405ea133fd7Smrg# vi:sw=2
8406ea133fd7Smrg
8407