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