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