ltmain.sh revision a241306c
1b68e1f86Smrg# Generated from ltmain.m4sh.
2b68e1f86Smrg
3a241306cSmrg# 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)
68a241306cSmrg#       $progname:		(GNU libtool) 2.2.6
69b68e1f86Smrg#       automake:		$automake_version
70b68e1f86Smrg#       autoconf:		$autoconf_version
71b68e1f86Smrg#
72b68e1f86Smrg# Report bugs to <bug-libtool@gnu.org>.
736df26cacSmrg
746df26cacSmrgPROGRAM=ltmain.sh
756df26cacSmrgPACKAGE=libtool
76a241306cSmrgVERSION=2.2.6
77b68e1f86SmrgTIMESTAMP=""
78a241306cSmrgpackage_revision=1.3012
79a241306cSmrg
80a241306cSmrg# define SED for historic ltconfig's generated by Libtool 1.3
81a241306cSmrgtest -z "$SED" && SED=sed
8216fd1166Smrg
83b68e1f86Smrg# Be Bourne compatible
8416fd1166Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
8516fd1166Smrg  emulate sh
8616fd1166Smrg  NULLCMD=:
8716fd1166Smrg  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
8816fd1166Smrg  # is contrary to our usage.  Disable this feature.
8916fd1166Smrg  alias -g '${1+"$@"}'='"$@"'
906df26cacSmrg  setopt NO_GLOB_SUBST
9116fd1166Smrgelse
9216fd1166Smrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
936df26cacSmrgfi
9416fd1166SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
9516fd1166SmrgDUALCASE=1; export DUALCASE # for MKS sh
966df26cacSmrg
97b68e1f86Smrg# NLS nuisances: We save the old values to restore during execute mode.
986df26cacSmrg# Only set LANG and LC_ALL to C if already set.
996df26cacSmrg# These must not be set unconditionally because not all systems understand
1006df26cacSmrg# e.g. LANG=C (notably SCO).
101b68e1f86Smrglt_user_locale=
102b68e1f86Smrglt_safe_locale=
103b68e1f86Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
10416fd1166Smrgdo
10516fd1166Smrg  eval "if test \"\${$lt_var+set}\" = set; then
106b68e1f86Smrg          save_$lt_var=\$$lt_var
107b68e1f86Smrg          $lt_var=C
10816fd1166Smrg	  export $lt_var
109b68e1f86Smrg	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
110b68e1f86Smrg	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
11116fd1166Smrg	fi"
11216fd1166Smrgdone
1136df26cacSmrg
114b68e1f86Smrg$lt_unset CDPATH
115b68e1f86Smrg
116b68e1f86Smrg
117b68e1f86Smrg
118b68e1f86Smrg
119b68e1f86Smrg
120b68e1f86Smrg: ${CP="cp -f"}
121b68e1f86Smrg: ${ECHO="echo"}
122b68e1f86Smrg: ${EGREP="/bin/grep -E"}
123b68e1f86Smrg: ${FGREP="/bin/grep -F"}
124b68e1f86Smrg: ${GREP="/bin/grep"}
125b68e1f86Smrg: ${LN_S="ln -s"}
126b68e1f86Smrg: ${MAKE="make"}
127b68e1f86Smrg: ${MKDIR="mkdir"}
128b68e1f86Smrg: ${MV="mv -f"}
129b68e1f86Smrg: ${RM="rm -f"}
130b68e1f86Smrg: ${SED="/bin/sed"}
131b68e1f86Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
132b68e1f86Smrg: ${Xsed="$SED -e 1s/^X//"}
133b68e1f86Smrg
134b68e1f86Smrg# Global variables:
135b68e1f86SmrgEXIT_SUCCESS=0
136b68e1f86SmrgEXIT_FAILURE=1
137b68e1f86SmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
138b68e1f86SmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
139b68e1f86Smrg
140b68e1f86Smrgexit_status=$EXIT_SUCCESS
141b68e1f86Smrg
1426df26cacSmrg# Make sure IFS has a sensible default
1436df26cacSmrglt_nl='
1446df26cacSmrg'
1456df26cacSmrgIFS=" 	$lt_nl"
1466df26cacSmrg
147b68e1f86Smrgdirname="s,/[^/]*$,,"
148b68e1f86Smrgbasename="s,^.*/,,"
149b68e1f86Smrg
150b68e1f86Smrg# func_dirname_and_basename file append nondir_replacement
151b68e1f86Smrg# perform func_basename and func_dirname in a single function
152b68e1f86Smrg# call:
153b68e1f86Smrg#   dirname:  Compute the dirname of FILE.  If nonempty,
154b68e1f86Smrg#             add APPEND to the result, otherwise set result
155b68e1f86Smrg#             to NONDIR_REPLACEMENT.
156b68e1f86Smrg#             value returned in "$func_dirname_result"
157b68e1f86Smrg#   basename: Compute filename of FILE.
158b68e1f86Smrg#             value retuned in "$func_basename_result"
159b68e1f86Smrg# Implementation must be kept synchronized with func_dirname
160b68e1f86Smrg# and func_basename. For efficiency, we do not delegate to
161b68e1f86Smrg# those functions but instead duplicate the functionality here.
162b68e1f86Smrgfunc_dirname_and_basename ()
163b68e1f86Smrg{
164b68e1f86Smrg  # Extract subdirectory from the argument.
165b68e1f86Smrg  func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
166b68e1f86Smrg  if test "X$func_dirname_result" = "X${1}"; then
167b68e1f86Smrg    func_dirname_result="${3}"
168b68e1f86Smrg  else
169b68e1f86Smrg    func_dirname_result="$func_dirname_result${2}"
170b68e1f86Smrg  fi
171b68e1f86Smrg  func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
172b68e1f86Smrg}
1736df26cacSmrg
174b68e1f86Smrg# Generated shell functions inserted here.
175b68e1f86Smrg
176b68e1f86Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
177b68e1f86Smrg# is ksh but when the shell is invoked as "sh" and the current value of
178b68e1f86Smrg# the _XPG environment variable is not equal to 1 (one), the special
179b68e1f86Smrg# positional parameter $0, within a function call, is the name of the
180b68e1f86Smrg# function.
181b68e1f86Smrgprogpath="$0"
182b68e1f86Smrg
183b68e1f86Smrg# The name of this program:
184b68e1f86Smrg# In the unlikely event $progname began with a '-', it would play havoc with
185b68e1f86Smrg# func_echo (imagine progname=-n), so we prepend ./ in that case:
186b68e1f86Smrgfunc_dirname_and_basename "$progpath"
187b68e1f86Smrgprogname=$func_basename_result
188b68e1f86Smrgcase $progname in
189b68e1f86Smrg  -*) progname=./$progname ;;
190b68e1f86Smrgesac
191b68e1f86Smrg
192b68e1f86Smrg# Make sure we have an absolute path for reexecution:
193b68e1f86Smrgcase $progpath in
194b68e1f86Smrg  [\\/]*|[A-Za-z]:\\*) ;;
195b68e1f86Smrg  *[\\/]*)
196b68e1f86Smrg     progdir=$func_dirname_result
197b68e1f86Smrg     progdir=`cd "$progdir" && pwd`
198b68e1f86Smrg     progpath="$progdir/$progname"
199b68e1f86Smrg     ;;
200b68e1f86Smrg  *)
201b68e1f86Smrg     save_IFS="$IFS"
202b68e1f86Smrg     IFS=:
203b68e1f86Smrg     for progdir in $PATH; do
204b68e1f86Smrg       IFS="$save_IFS"
205b68e1f86Smrg       test -x "$progdir/$progname" && break
206b68e1f86Smrg     done
207b68e1f86Smrg     IFS="$save_IFS"
208b68e1f86Smrg     test -n "$progdir" || progdir=`pwd`
209b68e1f86Smrg     progpath="$progdir/$progname"
210b68e1f86Smrg     ;;
211b68e1f86Smrgesac
212b68e1f86Smrg
213b68e1f86Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
214b68e1f86Smrg# metacharacters that are still active within double-quoted strings.
215b68e1f86SmrgXsed="${SED}"' -e 1s/^X//'
216b68e1f86Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g'
217b68e1f86Smrg
218b68e1f86Smrg# Same as above, but do not quote variable references.
219b68e1f86Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g'
220b68e1f86Smrg
221b68e1f86Smrg# Re-`\' parameter expansions in output of double_quote_subst that were
222b68e1f86Smrg# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
223b68e1f86Smrg# in input to double_quote_subst, that '$' was protected from expansion.
224b68e1f86Smrg# Since each input `\' is now two `\'s, look for any number of runs of
225b68e1f86Smrg# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
226b68e1f86Smrgbs='\\'
227b68e1f86Smrgbs2='\\\\'
228b68e1f86Smrgbs4='\\\\\\\\'
229b68e1f86Smrgdollar='\$'
230b68e1f86Smrgsed_double_backslash="\
231b68e1f86Smrg  s/$bs4/&\\
232b68e1f86Smrg/g
233b68e1f86Smrg  s/^$bs2$dollar/$bs&/
234b68e1f86Smrg  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
235b68e1f86Smrg  s/\n//g"
236b68e1f86Smrg
237b68e1f86Smrg# Standard options:
238b68e1f86Smrgopt_dry_run=false
239b68e1f86Smrgopt_help=false
240b68e1f86Smrgopt_quiet=false
241b68e1f86Smrgopt_verbose=false
242b68e1f86Smrgopt_warning=:
243b68e1f86Smrg
244b68e1f86Smrg# func_echo arg...
245b68e1f86Smrg# Echo program name prefixed message, along with the current mode
246b68e1f86Smrg# name if it has been set yet.
247b68e1f86Smrgfunc_echo ()
248b68e1f86Smrg{
249b68e1f86Smrg    $ECHO "$progname${mode+: }$mode: $*"
250b68e1f86Smrg}
251b68e1f86Smrg
252b68e1f86Smrg# func_verbose arg...
253b68e1f86Smrg# Echo program name prefixed message in verbose mode only.
254b68e1f86Smrgfunc_verbose ()
255b68e1f86Smrg{
256b68e1f86Smrg    $opt_verbose && func_echo ${1+"$@"}
257b68e1f86Smrg
258b68e1f86Smrg    # A bug in bash halts the script if the last line of a function
259b68e1f86Smrg    # fails when set -e is in force, so we need another command to
260b68e1f86Smrg    # work around that:
261b68e1f86Smrg    :
262b68e1f86Smrg}
263b68e1f86Smrg
264b68e1f86Smrg# func_error arg...
265b68e1f86Smrg# Echo program name prefixed message to standard error.
266b68e1f86Smrgfunc_error ()
267b68e1f86Smrg{
268b68e1f86Smrg    $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2
269b68e1f86Smrg}
270b68e1f86Smrg
271b68e1f86Smrg# func_warning arg...
272b68e1f86Smrg# Echo program name prefixed warning message to standard error.
273b68e1f86Smrgfunc_warning ()
274b68e1f86Smrg{
275b68e1f86Smrg    $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2
276b68e1f86Smrg
277b68e1f86Smrg    # bash bug again:
278b68e1f86Smrg    :
279b68e1f86Smrg}
280b68e1f86Smrg
281b68e1f86Smrg# func_fatal_error arg...
282b68e1f86Smrg# Echo program name prefixed message to standard error, and exit.
283b68e1f86Smrgfunc_fatal_error ()
284b68e1f86Smrg{
285b68e1f86Smrg    func_error ${1+"$@"}
286b68e1f86Smrg    exit $EXIT_FAILURE
287b68e1f86Smrg}
288b68e1f86Smrg
289b68e1f86Smrg# func_fatal_help arg...
290b68e1f86Smrg# Echo program name prefixed message to standard error, followed by
291b68e1f86Smrg# a help hint, and exit.
292b68e1f86Smrgfunc_fatal_help ()
293b68e1f86Smrg{
294b68e1f86Smrg    func_error ${1+"$@"}
295b68e1f86Smrg    func_fatal_error "$help"
296b68e1f86Smrg}
297b68e1f86Smrghelp="Try \`$progname --help' for more information."  ## default
298b68e1f86Smrg
299b68e1f86Smrg
300b68e1f86Smrg# func_grep expression filename
301b68e1f86Smrg# Check whether EXPRESSION matches any line of FILENAME, without output.
302b68e1f86Smrgfunc_grep ()
303b68e1f86Smrg{
304b68e1f86Smrg    $GREP "$1" "$2" >/dev/null 2>&1
305b68e1f86Smrg}
306b68e1f86Smrg
307b68e1f86Smrg
308b68e1f86Smrg# func_mkdir_p directory-path
309b68e1f86Smrg# Make sure the entire path to DIRECTORY-PATH is available.
310b68e1f86Smrgfunc_mkdir_p ()
311b68e1f86Smrg{
312b68e1f86Smrg    my_directory_path="$1"
313b68e1f86Smrg    my_dir_list=
314b68e1f86Smrg
315b68e1f86Smrg    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
316b68e1f86Smrg
317b68e1f86Smrg      # Protect directory names starting with `-'
318b68e1f86Smrg      case $my_directory_path in
319b68e1f86Smrg        -*) my_directory_path="./$my_directory_path" ;;
320b68e1f86Smrg      esac
321b68e1f86Smrg
322b68e1f86Smrg      # While some portion of DIR does not yet exist...
323b68e1f86Smrg      while test ! -d "$my_directory_path"; do
324b68e1f86Smrg        # ...make a list in topmost first order.  Use a colon delimited
325b68e1f86Smrg	# list incase some portion of path contains whitespace.
326b68e1f86Smrg        my_dir_list="$my_directory_path:$my_dir_list"
327b68e1f86Smrg
328b68e1f86Smrg        # If the last portion added has no slash in it, the list is done
329b68e1f86Smrg        case $my_directory_path in */*) ;; *) break ;; esac
330b68e1f86Smrg
331b68e1f86Smrg        # ...otherwise throw away the child directory and loop
332b68e1f86Smrg        my_directory_path=`$ECHO "X$my_directory_path" | $Xsed -e "$dirname"`
333b68e1f86Smrg      done
334b68e1f86Smrg      my_dir_list=`$ECHO "X$my_dir_list" | $Xsed -e 's,:*$,,'`
335b68e1f86Smrg
336b68e1f86Smrg      save_mkdir_p_IFS="$IFS"; IFS=':'
337b68e1f86Smrg      for my_dir in $my_dir_list; do
338b68e1f86Smrg	IFS="$save_mkdir_p_IFS"
339b68e1f86Smrg        # mkdir can fail with a `File exist' error if two processes
340b68e1f86Smrg        # try to create one of the directories concurrently.  Don't
341b68e1f86Smrg        # stop in that case!
342b68e1f86Smrg        $MKDIR "$my_dir" 2>/dev/null || :
343b68e1f86Smrg      done
344b68e1f86Smrg      IFS="$save_mkdir_p_IFS"
345b68e1f86Smrg
346b68e1f86Smrg      # Bail out if we (or some other process) failed to create a directory.
347b68e1f86Smrg      test -d "$my_directory_path" || \
348b68e1f86Smrg        func_fatal_error "Failed to create \`$1'"
349b68e1f86Smrg    fi
350b68e1f86Smrg}
3516df26cacSmrg
3526df26cacSmrg
3536df26cacSmrg# func_mktempdir [string]
3546df26cacSmrg# Make a temporary directory that won't clash with other running
3556df26cacSmrg# libtool processes, and avoids race conditions if possible.  If
3566df26cacSmrg# given, STRING is the basename for that directory.
3576df26cacSmrgfunc_mktempdir ()
3586df26cacSmrg{
3596df26cacSmrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
3606df26cacSmrg
361b68e1f86Smrg    if test "$opt_dry_run" = ":"; then
3626df26cacSmrg      # Return a directory name, but don't create it in dry-run mode
3636df26cacSmrg      my_tmpdir="${my_template}-$$"
3646df26cacSmrg    else
3656df26cacSmrg
3666df26cacSmrg      # If mktemp works, use that first and foremost
3676df26cacSmrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
3686df26cacSmrg
3696df26cacSmrg      if test ! -d "$my_tmpdir"; then
370b68e1f86Smrg        # Failing that, at least try and use $RANDOM to avoid a race
371b68e1f86Smrg        my_tmpdir="${my_template}-${RANDOM-0}$$"
3726df26cacSmrg
373b68e1f86Smrg        save_mktempdir_umask=`umask`
374b68e1f86Smrg        umask 0077
375b68e1f86Smrg        $MKDIR "$my_tmpdir"
376b68e1f86Smrg        umask $save_mktempdir_umask
3776df26cacSmrg      fi
3786df26cacSmrg
3796df26cacSmrg      # If we're not in dry-run mode, bomb out on failure
380b68e1f86Smrg      test -d "$my_tmpdir" || \
381b68e1f86Smrg        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
3826df26cacSmrg    fi
3836df26cacSmrg
384b68e1f86Smrg    $ECHO "X$my_tmpdir" | $Xsed
3856df26cacSmrg}
3866df26cacSmrg
3876df26cacSmrg
388b68e1f86Smrg# func_quote_for_eval arg
389b68e1f86Smrg# Aesthetically quote ARG to be evaled later.
390b68e1f86Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
391b68e1f86Smrg# is double-quoted, suitable for a subsequent eval, whereas
392b68e1f86Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
393b68e1f86Smrg# which are still active within double quotes backslashified.
394b68e1f86Smrgfunc_quote_for_eval ()
3956df26cacSmrg{
396b68e1f86Smrg    case $1 in
397b68e1f86Smrg      *[\\\`\"\$]*)
398b68e1f86Smrg	func_quote_for_eval_unquoted_result=`$ECHO "X$1" | $Xsed -e "$sed_quote_subst"` ;;
399b68e1f86Smrg      *)
400b68e1f86Smrg        func_quote_for_eval_unquoted_result="$1" ;;
401b68e1f86Smrg    esac
402b68e1f86Smrg
403b68e1f86Smrg    case $func_quote_for_eval_unquoted_result in
404b68e1f86Smrg      # Double-quote args containing shell metacharacters to delay
405b68e1f86Smrg      # word splitting, command substitution and and variable
406b68e1f86Smrg      # expansion for a subsequent eval.
407b68e1f86Smrg      # Many Bourne shells cannot handle close brackets correctly
408b68e1f86Smrg      # in scan sets, so we specify it separately.
409b68e1f86Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
410b68e1f86Smrg        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
411b68e1f86Smrg        ;;
412b68e1f86Smrg      *)
413b68e1f86Smrg        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
4146df26cacSmrg    esac
4156df26cacSmrg}
4166df26cacSmrg
4176df26cacSmrg
418b68e1f86Smrg# func_quote_for_expand arg
419b68e1f86Smrg# Aesthetically quote ARG to be evaled later; same as above,
420b68e1f86Smrg# but do not quote variable references.
421b68e1f86Smrgfunc_quote_for_expand ()
4226df26cacSmrg{
423b68e1f86Smrg    case $1 in
424b68e1f86Smrg      *[\\\`\"]*)
425b68e1f86Smrg	my_arg=`$ECHO "X$1" | $Xsed \
426b68e1f86Smrg	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
4276df26cacSmrg      *)
428b68e1f86Smrg        my_arg="$1" ;;
429b68e1f86Smrg    esac
430b68e1f86Smrg
431b68e1f86Smrg    case $my_arg in
432b68e1f86Smrg      # Double-quote args containing shell metacharacters to delay
433b68e1f86Smrg      # word splitting and command substitution for a subsequent eval.
434b68e1f86Smrg      # Many Bourne shells cannot handle close brackets correctly
435b68e1f86Smrg      # in scan sets, so we specify it separately.
436b68e1f86Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
437b68e1f86Smrg        my_arg="\"$my_arg\""
438b68e1f86Smrg        ;;
439b68e1f86Smrg    esac
440b68e1f86Smrg
441b68e1f86Smrg    func_quote_for_expand_result="$my_arg"
4426df26cacSmrg}
4436df26cacSmrg
4446df26cacSmrg
445b68e1f86Smrg# func_show_eval cmd [fail_exp]
446b68e1f86Smrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
447b68e1f86Smrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
448b68e1f86Smrg# is given, then evaluate it.
449b68e1f86Smrgfunc_show_eval ()
4506df26cacSmrg{
451b68e1f86Smrg    my_cmd="$1"
452b68e1f86Smrg    my_fail_exp="${2-:}"
4536df26cacSmrg
454b68e1f86Smrg    ${opt_silent-false} || {
455b68e1f86Smrg      func_quote_for_expand "$my_cmd"
456b68e1f86Smrg      eval "func_echo $func_quote_for_expand_result"
457b68e1f86Smrg    }
458b68e1f86Smrg
459b68e1f86Smrg    if ${opt_dry_run-false}; then :; else
460b68e1f86Smrg      eval "$my_cmd"
461b68e1f86Smrg      my_status=$?
462b68e1f86Smrg      if test "$my_status" -eq 0; then :; else
463b68e1f86Smrg	eval "(exit $my_status); $my_fail_exp"
464b68e1f86Smrg      fi
4656df26cacSmrg    fi
4666df26cacSmrg}
4676df26cacSmrg
468b68e1f86Smrg
469b68e1f86Smrg# func_show_eval_locale cmd [fail_exp]
470b68e1f86Smrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
471b68e1f86Smrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
472b68e1f86Smrg# is given, then evaluate it.  Use the saved locale for evaluation.
473b68e1f86Smrgfunc_show_eval_locale ()
4746df26cacSmrg{
475b68e1f86Smrg    my_cmd="$1"
476b68e1f86Smrg    my_fail_exp="${2-:}"
477b68e1f86Smrg
478b68e1f86Smrg    ${opt_silent-false} || {
479b68e1f86Smrg      func_quote_for_expand "$my_cmd"
480b68e1f86Smrg      eval "func_echo $func_quote_for_expand_result"
481b68e1f86Smrg    }
482b68e1f86Smrg
483b68e1f86Smrg    if ${opt_dry_run-false}; then :; else
484b68e1f86Smrg      eval "$lt_user_locale
485b68e1f86Smrg	    $my_cmd"
486b68e1f86Smrg      my_status=$?
487b68e1f86Smrg      eval "$lt_safe_locale"
488b68e1f86Smrg      if test "$my_status" -eq 0; then :; else
489b68e1f86Smrg	eval "(exit $my_status); $my_fail_exp"
490b68e1f86Smrg      fi
4916df26cacSmrg    fi
492b68e1f86Smrg}
4936df26cacSmrg
4946df26cacSmrg
495b68e1f86Smrg
496b68e1f86Smrg
497b68e1f86Smrg
498b68e1f86Smrg# func_version
499b68e1f86Smrg# Echo version message to standard output and exit.
500b68e1f86Smrgfunc_version ()
501b68e1f86Smrg{
502b68e1f86Smrg    $SED -n '/^# '$PROGRAM' (GNU /,/# warranty; / {
503b68e1f86Smrg        s/^# //
504b68e1f86Smrg	s/^# *$//
505b68e1f86Smrg        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
506b68e1f86Smrg        p
507b68e1f86Smrg     }' < "$progpath"
508b68e1f86Smrg     exit $?
509b68e1f86Smrg}
510b68e1f86Smrg
511b68e1f86Smrg# func_usage
512b68e1f86Smrg# Echo short help message to standard output and exit.
513b68e1f86Smrgfunc_usage ()
514b68e1f86Smrg{
515b68e1f86Smrg    $SED -n '/^# Usage:/,/# -h/ {
516b68e1f86Smrg        s/^# //
517b68e1f86Smrg	s/^# *$//
518b68e1f86Smrg	s/\$progname/'$progname'/
519b68e1f86Smrg	p
520b68e1f86Smrg    }' < "$progpath"
521b68e1f86Smrg    $ECHO
522b68e1f86Smrg    $ECHO "run \`$progname --help | more' for full usage"
523b68e1f86Smrg    exit $?
524b68e1f86Smrg}
525b68e1f86Smrg
526b68e1f86Smrg# func_help
527b68e1f86Smrg# Echo long help message to standard output and exit.
528b68e1f86Smrgfunc_help ()
529b68e1f86Smrg{
530b68e1f86Smrg    $SED -n '/^# Usage:/,/# Report bugs to/ {
531b68e1f86Smrg        s/^# //
532b68e1f86Smrg	s/^# *$//
533b68e1f86Smrg	s*\$progname*'$progname'*
534b68e1f86Smrg	s*\$host*'"$host"'*
535b68e1f86Smrg	s*\$SHELL*'"$SHELL"'*
536b68e1f86Smrg	s*\$LTCC*'"$LTCC"'*
537b68e1f86Smrg	s*\$LTCFLAGS*'"$LTCFLAGS"'*
538b68e1f86Smrg	s*\$LD*'"$LD"'*
539b68e1f86Smrg	s/\$with_gnu_ld/'"$with_gnu_ld"'/
540b68e1f86Smrg	s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
541b68e1f86Smrg	s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
542b68e1f86Smrg	p
543b68e1f86Smrg     }' < "$progpath"
544b68e1f86Smrg    exit $?
545b68e1f86Smrg}
546b68e1f86Smrg
547b68e1f86Smrg# func_missing_arg argname
548b68e1f86Smrg# Echo program name prefixed message to standard error and set global
549b68e1f86Smrg# exit_cmd.
550b68e1f86Smrgfunc_missing_arg ()
551b68e1f86Smrg{
552b68e1f86Smrg    func_error "missing argument for $1"
553b68e1f86Smrg    exit_cmd=exit
5546df26cacSmrg}
5556df26cacSmrg
556b68e1f86Smrgexit_cmd=:
5576df26cacSmrg
5586df26cacSmrg
559b68e1f86Smrg
560b68e1f86Smrg
561b68e1f86Smrg
562b68e1f86Smrg# Check that we have a working $ECHO.
563b68e1f86Smrgif test "X$1" = X--no-reexec; then
564b68e1f86Smrg  # Discard the --no-reexec flag, and continue.
5656df26cacSmrg  shift
566b68e1f86Smrgelif test "X$1" = X--fallback-echo; then
567b68e1f86Smrg  # Avoid inline document here, it may be left over
568b68e1f86Smrg  :
569b68e1f86Smrgelif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then
570b68e1f86Smrg  # Yippee, $ECHO works!
571b68e1f86Smrg  :
572b68e1f86Smrgelse
573b68e1f86Smrg  # Restart under the correct shell, and then maybe $ECHO will work.
574b68e1f86Smrg  exec $SHELL "$progpath" --no-reexec ${1+"$@"}
575b68e1f86Smrgfi
5766df26cacSmrg
577b68e1f86Smrgif test "X$1" = X--fallback-echo; then
578b68e1f86Smrg  # used as fallback echo
579b68e1f86Smrg  shift
580b68e1f86Smrg  cat <<EOF
581b68e1f86Smrg$*
582b68e1f86SmrgEOF
583b68e1f86Smrg  exit $EXIT_SUCCESS
584b68e1f86Smrgfi
5856df26cacSmrg
586b68e1f86Smrgmagic="%%%MAGIC variable%%%"
587b68e1f86Smrgmagic_exe="%%%MAGIC EXE variable%%%"
5886df26cacSmrg
589b68e1f86Smrg# Global variables.
590b68e1f86Smrg# $mode is unset
591b68e1f86Smrgnonopt=
592b68e1f86Smrgexecute_dlfiles=
593b68e1f86Smrgpreserve_args=
594b68e1f86Smrglo2o="s/\\.lo\$/.${objext}/"
595b68e1f86Smrgo2lo="s/\\.${objext}\$/.lo/"
596b68e1f86Smrgextracted_archives=
597b68e1f86Smrgextracted_serial=0
5986df26cacSmrg
599b68e1f86Smrgopt_dry_run=false
600b68e1f86Smrgopt_duplicate_deps=false
601b68e1f86Smrgopt_silent=false
602b68e1f86Smrgopt_debug=:
6036df26cacSmrg
604b68e1f86Smrg# If this variable is set in any of the actions, the command in it
605b68e1f86Smrg# will be execed at the end.  This prevents here-documents from being
606b68e1f86Smrg# left over by shells.
607b68e1f86Smrgexec_cmd=
608b68e1f86Smrg
609b68e1f86Smrg# func_fatal_configuration arg...
610b68e1f86Smrg# Echo program name prefixed message to standard error, followed by
611b68e1f86Smrg# a configuration failure hint, and exit.
612b68e1f86Smrgfunc_fatal_configuration ()
613b68e1f86Smrg{
614b68e1f86Smrg    func_error ${1+"$@"}
615b68e1f86Smrg    func_error "See the $PACKAGE documentation for more information."
616b68e1f86Smrg    func_fatal_error "Fatal configuration error."
617b68e1f86Smrg}
6186df26cacSmrg
61916fd1166Smrg
620b68e1f86Smrg# func_config
621b68e1f86Smrg# Display the configuration for all the tags in this script.
622b68e1f86Smrgfunc_config ()
623b68e1f86Smrg{
624b68e1f86Smrg    re_begincf='^# ### BEGIN LIBTOOL'
625b68e1f86Smrg    re_endcf='^# ### END LIBTOOL'
626b68e1f86Smrg
627b68e1f86Smrg    # Default configuration.
628b68e1f86Smrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
6296df26cacSmrg
6306df26cacSmrg    # Now print the configurations for the tags.
6316df26cacSmrg    for tagname in $taglist; do
632b68e1f86Smrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
6336df26cacSmrg    done
6346df26cacSmrg
635b68e1f86Smrg    exit $?
636b68e1f86Smrg}
6376df26cacSmrg
638b68e1f86Smrg# func_features
639b68e1f86Smrg# Display the features supported by this script.
640b68e1f86Smrgfunc_features ()
641b68e1f86Smrg{
642b68e1f86Smrg    $ECHO "host: $host"
6436df26cacSmrg    if test "$build_libtool_libs" = yes; then
644b68e1f86Smrg      $ECHO "enable shared libraries"
6456df26cacSmrg    else
646b68e1f86Smrg      $ECHO "disable shared libraries"
6476df26cacSmrg    fi
6486df26cacSmrg    if test "$build_old_libs" = yes; then
649b68e1f86Smrg      $ECHO "enable static libraries"
6506df26cacSmrg    else
651b68e1f86Smrg      $ECHO "disable static libraries"
6526df26cacSmrg    fi
653b68e1f86Smrg
6546df26cacSmrg    exit $?
655b68e1f86Smrg}
6566df26cacSmrg
657b68e1f86Smrg# func_enable_tag tagname
658b68e1f86Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or
659b68e1f86Smrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
660b68e1f86Smrg# variable here.
661b68e1f86Smrgfunc_enable_tag ()
662b68e1f86Smrg{
663b68e1f86Smrg  # Global variable:
664b68e1f86Smrg  tagname="$1"
6656df26cacSmrg
666b68e1f86Smrg  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
667b68e1f86Smrg  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
668b68e1f86Smrg  sed_extractcf="/$re_begincf/,/$re_endcf/p"
6696df26cacSmrg
670b68e1f86Smrg  # Validate tagname.
671b68e1f86Smrg  case $tagname in
672b68e1f86Smrg    *[!-_A-Za-z0-9,/]*)
673b68e1f86Smrg      func_fatal_error "invalid tag name: $tagname"
674b68e1f86Smrg      ;;
675b68e1f86Smrg  esac
6766df26cacSmrg
677b68e1f86Smrg  # Don't test for the "default" C tag, as we know it's
678b68e1f86Smrg  # there but not specially marked.
679b68e1f86Smrg  case $tagname in
680b68e1f86Smrg    CC) ;;
681b68e1f86Smrg    *)
682b68e1f86Smrg      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
683b68e1f86Smrg	taglist="$taglist $tagname"
684b68e1f86Smrg
685b68e1f86Smrg	# Evaluate the configuration.  Be careful to quote the path
686b68e1f86Smrg	# and the sed script, to avoid splitting on whitespace, but
687b68e1f86Smrg	# also don't use non-portable quotes within backquotes within
688b68e1f86Smrg	# quotes we have to do it in 2 steps:
689b68e1f86Smrg	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
690b68e1f86Smrg	eval "$extractedcf"
691b68e1f86Smrg      else
692b68e1f86Smrg	func_error "ignoring unknown tag $tagname"
693b68e1f86Smrg      fi
694b68e1f86Smrg      ;;
695b68e1f86Smrg  esac
696b68e1f86Smrg}
697b68e1f86Smrg
698b68e1f86Smrg# Parse options once, thoroughly.  This comes as soon as possible in
699b68e1f86Smrg# the script to make things like `libtool --version' happen quickly.
700b68e1f86Smrg{
7016df26cacSmrg
702b68e1f86Smrg  # Shorthand for --mode=foo, only valid as the first argument
703b68e1f86Smrg  case $1 in
704b68e1f86Smrg  clean|clea|cle|cl)
705b68e1f86Smrg    shift; set dummy --mode clean ${1+"$@"}; shift
7066df26cacSmrg    ;;
707b68e1f86Smrg  compile|compil|compi|comp|com|co|c)
708b68e1f86Smrg    shift; set dummy --mode compile ${1+"$@"}; shift
7096df26cacSmrg    ;;
710b68e1f86Smrg  execute|execut|execu|exec|exe|ex|e)
711b68e1f86Smrg    shift; set dummy --mode execute ${1+"$@"}; shift
7126df26cacSmrg    ;;
713b68e1f86Smrg  finish|finis|fini|fin|fi|f)
714b68e1f86Smrg    shift; set dummy --mode finish ${1+"$@"}; shift
7156df26cacSmrg    ;;
716b68e1f86Smrg  install|instal|insta|inst|ins|in|i)
717b68e1f86Smrg    shift; set dummy --mode install ${1+"$@"}; shift
718b68e1f86Smrg    ;;
719b68e1f86Smrg  link|lin|li|l)
720b68e1f86Smrg    shift; set dummy --mode link ${1+"$@"}; shift
721b68e1f86Smrg    ;;
722b68e1f86Smrg  uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
723b68e1f86Smrg    shift; set dummy --mode uninstall ${1+"$@"}; shift
7246df26cacSmrg    ;;
7256df26cacSmrg  esac
7266df26cacSmrg
727b68e1f86Smrg  # Parse non-mode specific arguments:
728b68e1f86Smrg  while test "$#" -gt 0; do
729b68e1f86Smrg    opt="$1"
730b68e1f86Smrg    shift
7316df26cacSmrg
732b68e1f86Smrg    case $opt in
733b68e1f86Smrg      --config)		func_config					;;
7346df26cacSmrg
735b68e1f86Smrg      --debug)		preserve_args="$preserve_args $opt"
736b68e1f86Smrg			func_echo "enabling shell trace mode"
737b68e1f86Smrg			opt_debug='set -x'
738b68e1f86Smrg			$opt_debug
739b68e1f86Smrg			;;
7406df26cacSmrg
741b68e1f86Smrg      -dlopen)		test "$#" -eq 0 && func_missing_arg "$opt" && break
742b68e1f86Smrg			execute_dlfiles="$execute_dlfiles $1"
743b68e1f86Smrg			shift
744b68e1f86Smrg			;;
7456df26cacSmrg
746b68e1f86Smrg      --dry-run | -n)	opt_dry_run=:					;;
747b68e1f86Smrg      --features)       func_features					;;
748b68e1f86Smrg      --finish)		mode="finish"					;;
749b68e1f86Smrg
750b68e1f86Smrg      --mode)		test "$#" -eq 0 && func_missing_arg "$opt" && break
751b68e1f86Smrg			case $1 in
752b68e1f86Smrg			  # Valid mode arguments:
753b68e1f86Smrg			  clean)	;;
754b68e1f86Smrg			  compile)	;;
755b68e1f86Smrg			  execute)	;;
756b68e1f86Smrg			  finish)	;;
757b68e1f86Smrg			  install)	;;
758b68e1f86Smrg			  link)		;;
759b68e1f86Smrg			  relink)	;;
760b68e1f86Smrg			  uninstall)	;;
761b68e1f86Smrg
762b68e1f86Smrg			  # Catch anything else as an error
763b68e1f86Smrg			  *) func_error "invalid argument for $opt"
764b68e1f86Smrg			     exit_cmd=exit
765b68e1f86Smrg			     break
766b68e1f86Smrg			     ;;
767b68e1f86Smrg		        esac
768b68e1f86Smrg
769b68e1f86Smrg			mode="$1"
770b68e1f86Smrg			shift
771b68e1f86Smrg			;;
772b68e1f86Smrg
773b68e1f86Smrg      --preserve-dup-deps)
774b68e1f86Smrg			opt_duplicate_deps=:				;;
775b68e1f86Smrg
776b68e1f86Smrg      --quiet|--silent)	preserve_args="$preserve_args $opt"
777b68e1f86Smrg			opt_silent=:
778b68e1f86Smrg			;;
779b68e1f86Smrg
780b68e1f86Smrg      --verbose| -v)	preserve_args="$preserve_args $opt"
781b68e1f86Smrg			opt_silent=false
782b68e1f86Smrg			;;
783b68e1f86Smrg
784b68e1f86Smrg      --tag)		test "$#" -eq 0 && func_missing_arg "$opt" && break
785b68e1f86Smrg			preserve_args="$preserve_args $opt $1"
786b68e1f86Smrg			func_enable_tag "$1"	# tagname is set here
787b68e1f86Smrg			shift
788b68e1f86Smrg			;;
789b68e1f86Smrg
790b68e1f86Smrg      # Separate optargs to long options:
791b68e1f86Smrg      -dlopen=*|--mode=*|--tag=*)
792b68e1f86Smrg			func_opt_split "$opt"
793b68e1f86Smrg			set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"}
794b68e1f86Smrg			shift
795b68e1f86Smrg			;;
796b68e1f86Smrg
797b68e1f86Smrg      -\?|-h)		func_usage					;;
798b68e1f86Smrg      --help)		opt_help=:					;;
799b68e1f86Smrg      --version)	func_version					;;
800b68e1f86Smrg
801b68e1f86Smrg      -*)		func_fatal_help "unrecognized option \`$opt'"	;;
802b68e1f86Smrg
803b68e1f86Smrg      *)		nonopt="$opt"
804b68e1f86Smrg			break
805b68e1f86Smrg			;;
806b68e1f86Smrg    esac
807b68e1f86Smrg  done
808b68e1f86Smrg
809b68e1f86Smrg
810b68e1f86Smrg  case $host in
811b68e1f86Smrg    *cygwin* | *mingw* | *pw32* | *cegcc*)
812b68e1f86Smrg      # don't eliminate duplications in $postdeps and $predeps
813b68e1f86Smrg      opt_duplicate_compiler_generated_deps=:
8146df26cacSmrg      ;;
8156df26cacSmrg    *)
816b68e1f86Smrg      opt_duplicate_compiler_generated_deps=$opt_duplicate_deps
817b68e1f86Smrg      ;;
818b68e1f86Smrg  esac
8196df26cacSmrg
820b68e1f86Smrg  # Having warned about all mis-specified options, bail out if
821b68e1f86Smrg  # anything was wrong.
822b68e1f86Smrg  $exit_cmd $EXIT_FAILURE
823b68e1f86Smrg}
824b68e1f86Smrg
825b68e1f86Smrg# func_check_version_match
826b68e1f86Smrg# Ensure that we are using m4 macros, and libtool script from the same
827b68e1f86Smrg# release of libtool.
828b68e1f86Smrgfunc_check_version_match ()
829b68e1f86Smrg{
830b68e1f86Smrg  if test "$package_revision" != "$macro_revision"; then
831b68e1f86Smrg    if test "$VERSION" != "$macro_version"; then
832b68e1f86Smrg      if test -z "$macro_version"; then
833b68e1f86Smrg        cat >&2 <<_LT_EOF
834b68e1f86Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
835b68e1f86Smrg$progname: definition of this LT_INIT comes from an older release.
836b68e1f86Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
837b68e1f86Smrg$progname: and run autoconf again.
838b68e1f86Smrg_LT_EOF
839b68e1f86Smrg      else
840b68e1f86Smrg        cat >&2 <<_LT_EOF
841b68e1f86Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
842b68e1f86Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
843b68e1f86Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
844b68e1f86Smrg$progname: and run autoconf again.
845b68e1f86Smrg_LT_EOF
8466df26cacSmrg      fi
847b68e1f86Smrg    else
848b68e1f86Smrg      cat >&2 <<_LT_EOF
849b68e1f86Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
850b68e1f86Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
851b68e1f86Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
852b68e1f86Smrg$progname: of $PACKAGE $VERSION and run autoconf again.
853b68e1f86Smrg_LT_EOF
854b68e1f86Smrg    fi
855b68e1f86Smrg
856b68e1f86Smrg    exit $EXIT_MISMATCH
857b68e1f86Smrg  fi
858b68e1f86Smrg}
859b68e1f86Smrg
860b68e1f86Smrg
861b68e1f86Smrg## ----------- ##
862b68e1f86Smrg##    Main.    ##
863b68e1f86Smrg## ----------- ##
864b68e1f86Smrg
865b68e1f86Smrg$opt_help || {
866b68e1f86Smrg  # Sanity checks first:
867b68e1f86Smrg  func_check_version_match
868b68e1f86Smrg
869b68e1f86Smrg  if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
870b68e1f86Smrg    func_fatal_configuration "not configured to build any kind of library"
8716df26cacSmrg  fi
8726df26cacSmrg
873b68e1f86Smrg  test -z "$mode" && func_fatal_error "error: you must specify a MODE."
874b68e1f86Smrg
875b68e1f86Smrg
876b68e1f86Smrg  # Darwin sucks
877b68e1f86Smrg  eval std_shrext=\"$shrext_cmds\"
878b68e1f86Smrg
879b68e1f86Smrg
8806df26cacSmrg  # Only execute mode is allowed to have -dlopen flags.
8816df26cacSmrg  if test -n "$execute_dlfiles" && test "$mode" != execute; then
882b68e1f86Smrg    func_error "unrecognized option \`-dlopen'"
883b68e1f86Smrg    $ECHO "$help" 1>&2
8846df26cacSmrg    exit $EXIT_FAILURE
8856df26cacSmrg  fi
8866df26cacSmrg
8876df26cacSmrg  # Change the help message to a mode-specific one.
8886df26cacSmrg  generic_help="$help"
889b68e1f86Smrg  help="Try \`$progname --help --mode=$mode' for more information."
890b68e1f86Smrg}
8916df26cacSmrg
8926df26cacSmrg
893b68e1f86Smrg# func_lalib_p file
894b68e1f86Smrg# True iff FILE is a libtool `.la' library or `.lo' object file.
895b68e1f86Smrg# This function is only a basic sanity check; it will hardly flush out
896b68e1f86Smrg# determined imposters.
897b68e1f86Smrgfunc_lalib_p ()
898b68e1f86Smrg{
899b68e1f86Smrg    test -f "$1" &&
900b68e1f86Smrg      $SED -e 4q "$1" 2>/dev/null \
901b68e1f86Smrg        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
902b68e1f86Smrg}
9036df26cacSmrg
904b68e1f86Smrg# func_lalib_unsafe_p file
905b68e1f86Smrg# True iff FILE is a libtool `.la' library or `.lo' object file.
906b68e1f86Smrg# This function implements the same check as func_lalib_p without
907b68e1f86Smrg# resorting to external programs.  To this end, it redirects stdin and
908b68e1f86Smrg# closes it afterwards, without saving the original file descriptor.
909b68e1f86Smrg# As a safety measure, use it only where a negative result would be
910b68e1f86Smrg# fatal anyway.  Works if `file' does not exist.
911b68e1f86Smrgfunc_lalib_unsafe_p ()
912b68e1f86Smrg{
913b68e1f86Smrg    lalib_p=no
914b68e1f86Smrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
915b68e1f86Smrg	for lalib_p_l in 1 2 3 4
916b68e1f86Smrg	do
917b68e1f86Smrg	    read lalib_p_line
918b68e1f86Smrg	    case "$lalib_p_line" in
919b68e1f86Smrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
920b68e1f86Smrg	    esac
921b68e1f86Smrg	done
922b68e1f86Smrg	exec 0<&5 5<&-
923b68e1f86Smrg    fi
924b68e1f86Smrg    test "$lalib_p" = yes
925b68e1f86Smrg}
9266df26cacSmrg
927b68e1f86Smrg# func_ltwrapper_script_p file
928b68e1f86Smrg# True iff FILE is a libtool wrapper script
929b68e1f86Smrg# This function is only a basic sanity check; it will hardly flush out
930b68e1f86Smrg# determined imposters.
931b68e1f86Smrgfunc_ltwrapper_script_p ()
932b68e1f86Smrg{
933b68e1f86Smrg    func_lalib_p "$1"
934b68e1f86Smrg}
9356df26cacSmrg
936b68e1f86Smrg# func_ltwrapper_executable_p file
937b68e1f86Smrg# True iff FILE is a libtool wrapper executable
938b68e1f86Smrg# This function is only a basic sanity check; it will hardly flush out
939b68e1f86Smrg# determined imposters.
940b68e1f86Smrgfunc_ltwrapper_executable_p ()
941b68e1f86Smrg{
942b68e1f86Smrg    func_ltwrapper_exec_suffix=
943b68e1f86Smrg    case $1 in
944b68e1f86Smrg    *.exe) ;;
945b68e1f86Smrg    *) func_ltwrapper_exec_suffix=.exe ;;
946b68e1f86Smrg    esac
947b68e1f86Smrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
948b68e1f86Smrg}
9496df26cacSmrg
950b68e1f86Smrg# func_ltwrapper_scriptname file
951b68e1f86Smrg# Assumes file is an ltwrapper_executable
952b68e1f86Smrg# uses $file to determine the appropriate filename for a
953b68e1f86Smrg# temporary ltwrapper_script.
954b68e1f86Smrgfunc_ltwrapper_scriptname ()
955b68e1f86Smrg{
956b68e1f86Smrg    func_ltwrapper_scriptname_result=""
957b68e1f86Smrg    if func_ltwrapper_executable_p "$1"; then
958b68e1f86Smrg	func_dirname_and_basename "$1" "" "."
959b68e1f86Smrg	func_stripname '' '.exe' "$func_basename_result"
960b68e1f86Smrg	func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
961b68e1f86Smrg    fi
962b68e1f86Smrg}
963b68e1f86Smrg
964b68e1f86Smrg# func_ltwrapper_p file
965b68e1f86Smrg# True iff FILE is a libtool wrapper script or wrapper executable
966b68e1f86Smrg# This function is only a basic sanity check; it will hardly flush out
967b68e1f86Smrg# determined imposters.
968b68e1f86Smrgfunc_ltwrapper_p ()
969b68e1f86Smrg{
970b68e1f86Smrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
971b68e1f86Smrg}
972b68e1f86Smrg
973b68e1f86Smrg
974b68e1f86Smrg# func_execute_cmds commands fail_cmd
975b68e1f86Smrg# Execute tilde-delimited COMMANDS.
976b68e1f86Smrg# If FAIL_CMD is given, eval that upon failure.
977b68e1f86Smrg# FAIL_CMD may read-access the current command in variable CMD!
978b68e1f86Smrgfunc_execute_cmds ()
979b68e1f86Smrg{
980b68e1f86Smrg    $opt_debug
981b68e1f86Smrg    save_ifs=$IFS; IFS='~'
982b68e1f86Smrg    for cmd in $1; do
983b68e1f86Smrg      IFS=$save_ifs
984b68e1f86Smrg      eval cmd=\"$cmd\"
985b68e1f86Smrg      func_show_eval "$cmd" "${2-:}"
986b68e1f86Smrg    done
987b68e1f86Smrg    IFS=$save_ifs
988b68e1f86Smrg}
989b68e1f86Smrg
990b68e1f86Smrg
991b68e1f86Smrg# func_source file
992b68e1f86Smrg# Source FILE, adding directory component if necessary.
993b68e1f86Smrg# Note that it is not necessary on cygwin/mingw to append a dot to
994b68e1f86Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
995b68e1f86Smrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
996b68e1f86Smrg# `FILE.' does not work on cygwin managed mounts.
997b68e1f86Smrgfunc_source ()
998b68e1f86Smrg{
999b68e1f86Smrg    $opt_debug
1000b68e1f86Smrg    case $1 in
1001b68e1f86Smrg    */* | *\\*)	. "$1" ;;
1002b68e1f86Smrg    *)		. "./$1" ;;
1003b68e1f86Smrg    esac
1004b68e1f86Smrg}
1005b68e1f86Smrg
1006b68e1f86Smrg
1007b68e1f86Smrg# func_infer_tag arg
1008b68e1f86Smrg# Infer tagged configuration to use if any are available and
1009b68e1f86Smrg# if one wasn't chosen via the "--tag" command line option.
1010b68e1f86Smrg# Only attempt this if the compiler in the base compile
1011b68e1f86Smrg# command doesn't match the default compiler.
1012b68e1f86Smrg# arg is usually of the form 'gcc ...'
1013b68e1f86Smrgfunc_infer_tag ()
1014b68e1f86Smrg{
1015b68e1f86Smrg    $opt_debug
1016b68e1f86Smrg    if test -n "$available_tags" && test -z "$tagname"; then
1017b68e1f86Smrg      CC_quoted=
1018b68e1f86Smrg      for arg in $CC; do
1019b68e1f86Smrg        func_quote_for_eval "$arg"
1020b68e1f86Smrg	CC_quoted="$CC_quoted $func_quote_for_eval_result"
1021b68e1f86Smrg      done
1022b68e1f86Smrg      case $@ in
1023b68e1f86Smrg      # Blanks in the command may have been stripped by the calling shell,
1024b68e1f86Smrg      # but not from the CC environment variable when configure was run.
1025b68e1f86Smrg      " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) ;;
1026b68e1f86Smrg      # Blanks at the start of $base_compile will cause this to fail
1027b68e1f86Smrg      # if we don't check for them as well.
1028b68e1f86Smrg      *)
1029b68e1f86Smrg	for z in $available_tags; do
1030b68e1f86Smrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
1031b68e1f86Smrg	    # Evaluate the configuration.
1032b68e1f86Smrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
1033b68e1f86Smrg	    CC_quoted=
1034b68e1f86Smrg	    for arg in $CC; do
1035b68e1f86Smrg	      # Double-quote args containing other shell metacharacters.
1036b68e1f86Smrg	      func_quote_for_eval "$arg"
1037b68e1f86Smrg	      CC_quoted="$CC_quoted $func_quote_for_eval_result"
1038b68e1f86Smrg	    done
1039b68e1f86Smrg	    case "$@ " in
1040b68e1f86Smrg	      " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*)
1041b68e1f86Smrg	      # The compiler in the base compile command matches
1042b68e1f86Smrg	      # the one in the tagged configuration.
1043b68e1f86Smrg	      # Assume this is the tagged configuration we want.
1044b68e1f86Smrg	      tagname=$z
1045b68e1f86Smrg	      break
1046b68e1f86Smrg	      ;;
1047b68e1f86Smrg	    esac
1048b68e1f86Smrg	  fi
1049b68e1f86Smrg	done
1050b68e1f86Smrg	# If $tagname still isn't set, then no tagged configuration
1051b68e1f86Smrg	# was found and let the user know that the "--tag" command
1052b68e1f86Smrg	# line option must be used.
1053b68e1f86Smrg	if test -z "$tagname"; then
1054b68e1f86Smrg	  func_echo "unable to infer tagged configuration"
1055b68e1f86Smrg	  func_fatal_error "specify a tag with \`--tag'"
1056b68e1f86Smrg#	else
1057b68e1f86Smrg#	  func_verbose "using $tagname tagged configuration"
1058b68e1f86Smrg	fi
1059b68e1f86Smrg	;;
1060b68e1f86Smrg      esac
1061b68e1f86Smrg    fi
1062b68e1f86Smrg}
1063b68e1f86Smrg
1064b68e1f86Smrg
1065b68e1f86Smrg
1066b68e1f86Smrg# func_write_libtool_object output_name pic_name nonpic_name
1067b68e1f86Smrg# Create a libtool object file (analogous to a ".la" file),
1068b68e1f86Smrg# but don't create it if we're doing a dry run.
1069b68e1f86Smrgfunc_write_libtool_object ()
1070b68e1f86Smrg{
1071b68e1f86Smrg    write_libobj=${1}
1072b68e1f86Smrg    if test "$build_libtool_libs" = yes; then
1073b68e1f86Smrg      write_lobj=\'${2}\'
1074b68e1f86Smrg    else
1075b68e1f86Smrg      write_lobj=none
1076b68e1f86Smrg    fi
1077b68e1f86Smrg
1078b68e1f86Smrg    if test "$build_old_libs" = yes; then
1079b68e1f86Smrg      write_oldobj=\'${3}\'
1080b68e1f86Smrg    else
1081b68e1f86Smrg      write_oldobj=none
1082b68e1f86Smrg    fi
1083b68e1f86Smrg
1084b68e1f86Smrg    $opt_dry_run || {
1085b68e1f86Smrg      cat >${write_libobj}T <<EOF
1086b68e1f86Smrg# $write_libobj - a libtool object file
1087b68e1f86Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1088b68e1f86Smrg#
1089b68e1f86Smrg# Please DO NOT delete this file!
1090b68e1f86Smrg# It is necessary for linking the library.
1091b68e1f86Smrg
1092b68e1f86Smrg# Name of the PIC object.
1093b68e1f86Smrgpic_object=$write_lobj
1094b68e1f86Smrg
1095b68e1f86Smrg# Name of the non-PIC object
1096b68e1f86Smrgnon_pic_object=$write_oldobj
1097b68e1f86Smrg
1098b68e1f86SmrgEOF
1099b68e1f86Smrg      $MV "${write_libobj}T" "${write_libobj}"
1100b68e1f86Smrg    }
1101b68e1f86Smrg}
1102b68e1f86Smrg
1103b68e1f86Smrg# func_mode_compile arg...
1104b68e1f86Smrgfunc_mode_compile ()
1105b68e1f86Smrg{
1106b68e1f86Smrg    $opt_debug
1107b68e1f86Smrg    # Get the compilation command and the source file.
1108b68e1f86Smrg    base_compile=
1109b68e1f86Smrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
1110b68e1f86Smrg    suppress_opt=yes
1111b68e1f86Smrg    suppress_output=
1112b68e1f86Smrg    arg_mode=normal
1113b68e1f86Smrg    libobj=
1114b68e1f86Smrg    later=
1115b68e1f86Smrg    pie_flag=
1116b68e1f86Smrg
1117b68e1f86Smrg    for arg
1118b68e1f86Smrg    do
1119b68e1f86Smrg      case $arg_mode in
1120b68e1f86Smrg      arg  )
1121b68e1f86Smrg	# do not "continue".  Instead, add this to base_compile
1122b68e1f86Smrg	lastarg="$arg"
1123b68e1f86Smrg	arg_mode=normal
1124b68e1f86Smrg	;;
1125b68e1f86Smrg
1126b68e1f86Smrg      target )
1127b68e1f86Smrg	libobj="$arg"
1128b68e1f86Smrg	arg_mode=normal
1129b68e1f86Smrg	continue
1130b68e1f86Smrg	;;
1131b68e1f86Smrg
1132b68e1f86Smrg      normal )
1133b68e1f86Smrg	# Accept any command-line options.
1134b68e1f86Smrg	case $arg in
1135b68e1f86Smrg	-o)
1136b68e1f86Smrg	  test -n "$libobj" && \
1137b68e1f86Smrg	    func_fatal_error "you cannot specify \`-o' more than once"
1138b68e1f86Smrg	  arg_mode=target
1139b68e1f86Smrg	  continue
1140b68e1f86Smrg	  ;;
1141b68e1f86Smrg
1142b68e1f86Smrg	-pie | -fpie | -fPIE)
1143b68e1f86Smrg          pie_flag="$pie_flag $arg"
1144b68e1f86Smrg	  continue
1145b68e1f86Smrg	  ;;
1146b68e1f86Smrg
1147b68e1f86Smrg	-shared | -static | -prefer-pic | -prefer-non-pic)
1148b68e1f86Smrg	  later="$later $arg"
1149b68e1f86Smrg	  continue
1150b68e1f86Smrg	  ;;
1151b68e1f86Smrg
1152b68e1f86Smrg	-no-suppress)
11536df26cacSmrg	  suppress_opt=no
11546df26cacSmrg	  continue
11556df26cacSmrg	  ;;
11566df26cacSmrg
11576df26cacSmrg	-Xcompiler)
11586df26cacSmrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
11596df26cacSmrg	  continue      #  The current "srcfile" will either be retained or
11606df26cacSmrg	  ;;            #  replaced later.  I would guess that would be a bug.
11616df26cacSmrg
11626df26cacSmrg	-Wc,*)
1163b68e1f86Smrg	  func_stripname '-Wc,' '' "$arg"
1164b68e1f86Smrg	  args=$func_stripname_result
11656df26cacSmrg	  lastarg=
11666df26cacSmrg	  save_ifs="$IFS"; IFS=','
1167b68e1f86Smrg	  for arg in $args; do
11686df26cacSmrg	    IFS="$save_ifs"
1169b68e1f86Smrg	    func_quote_for_eval "$arg"
1170b68e1f86Smrg	    lastarg="$lastarg $func_quote_for_eval_result"
11716df26cacSmrg	  done
11726df26cacSmrg	  IFS="$save_ifs"
1173b68e1f86Smrg	  func_stripname ' ' '' "$lastarg"
1174b68e1f86Smrg	  lastarg=$func_stripname_result
11756df26cacSmrg
11766df26cacSmrg	  # Add the arguments to base_compile.
11776df26cacSmrg	  base_compile="$base_compile $lastarg"
11786df26cacSmrg	  continue
11796df26cacSmrg	  ;;
11806df26cacSmrg
1181b68e1f86Smrg	*)
11826df26cacSmrg	  # Accept the current argument as the source file.
11836df26cacSmrg	  # The previous "srcfile" becomes the current argument.
11846df26cacSmrg	  #
11856df26cacSmrg	  lastarg="$srcfile"
11866df26cacSmrg	  srcfile="$arg"
11876df26cacSmrg	  ;;
11886df26cacSmrg	esac  #  case $arg
11896df26cacSmrg	;;
11906df26cacSmrg      esac    #  case $arg_mode
11916df26cacSmrg
11926df26cacSmrg      # Aesthetically quote the previous argument.
1193b68e1f86Smrg      func_quote_for_eval "$lastarg"
1194b68e1f86Smrg      base_compile="$base_compile $func_quote_for_eval_result"
11956df26cacSmrg    done # for arg
11966df26cacSmrg
11976df26cacSmrg    case $arg_mode in
11986df26cacSmrg    arg)
1199b68e1f86Smrg      func_fatal_error "you must specify an argument for -Xcompile"
12006df26cacSmrg      ;;
12016df26cacSmrg    target)
1202b68e1f86Smrg      func_fatal_error "you must specify a target with \`-o'"
12036df26cacSmrg      ;;
12046df26cacSmrg    *)
12056df26cacSmrg      # Get the name of the library object.
1206b68e1f86Smrg      test -z "$libobj" && {
1207b68e1f86Smrg	func_basename "$srcfile"
1208b68e1f86Smrg	libobj="$func_basename_result"
1209b68e1f86Smrg      }
12106df26cacSmrg      ;;
12116df26cacSmrg    esac
12126df26cacSmrg
12136df26cacSmrg    # Recognize several different file suffixes.
12146df26cacSmrg    # If the user specifies -o file.o, it is replaced with file.lo
12156df26cacSmrg    case $libobj in
1216b68e1f86Smrg    *.[cCFSifmso] | \
1217b68e1f86Smrg    *.ada | *.adb | *.ads | *.asm | \
1218b68e1f86Smrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
1219b68e1f86Smrg    *.[fF][09]? | *.for | *.java | *.obj | *.sx)
1220b68e1f86Smrg      func_xform "$libobj"
1221b68e1f86Smrg      libobj=$func_xform_result
1222b68e1f86Smrg      ;;
12236df26cacSmrg    esac
12246df26cacSmrg
12256df26cacSmrg    case $libobj in
1226b68e1f86Smrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
12276df26cacSmrg    *)
1228b68e1f86Smrg      func_fatal_error "cannot determine name of library object from \`$libobj'"
12296df26cacSmrg      ;;
12306df26cacSmrg    esac
12316df26cacSmrg
12326df26cacSmrg    func_infer_tag $base_compile
12336df26cacSmrg
12346df26cacSmrg    for arg in $later; do
12356df26cacSmrg      case $arg in
1236b68e1f86Smrg      -shared)
1237b68e1f86Smrg	test "$build_libtool_libs" != yes && \
1238b68e1f86Smrg	  func_fatal_configuration "can not build a shared library"
1239b68e1f86Smrg	build_old_libs=no
1240b68e1f86Smrg	continue
1241b68e1f86Smrg	;;
1242b68e1f86Smrg
12436df26cacSmrg      -static)
1244b68e1f86Smrg	build_libtool_libs=no
12456df26cacSmrg	build_old_libs=yes
12466df26cacSmrg	continue
12476df26cacSmrg	;;
12486df26cacSmrg
12496df26cacSmrg      -prefer-pic)
12506df26cacSmrg	pic_mode=yes
12516df26cacSmrg	continue
12526df26cacSmrg	;;
12536df26cacSmrg
12546df26cacSmrg      -prefer-non-pic)
12556df26cacSmrg	pic_mode=no
12566df26cacSmrg	continue
12576df26cacSmrg	;;
12586df26cacSmrg      esac
12596df26cacSmrg    done
12606df26cacSmrg
1261b68e1f86Smrg    func_quote_for_eval "$libobj"
1262b68e1f86Smrg    test "X$libobj" != "X$func_quote_for_eval_result" \
1263b68e1f86Smrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
1264b68e1f86Smrg      && func_warning "libobj name \`$libobj' may not contain shell special characters."
1265b68e1f86Smrg    func_dirname_and_basename "$obj" "/" ""
1266b68e1f86Smrg    objname="$func_basename_result"
1267b68e1f86Smrg    xdir="$func_dirname_result"
12686df26cacSmrg    lobj=${xdir}$objdir/$objname
12696df26cacSmrg
1270b68e1f86Smrg    test -z "$base_compile" && \
1271b68e1f86Smrg      func_fatal_help "you must specify a compilation command"
12726df26cacSmrg
12736df26cacSmrg    # Delete any leftover library objects.
12746df26cacSmrg    if test "$build_old_libs" = yes; then
12756df26cacSmrg      removelist="$obj $lobj $libobj ${libobj}T"
12766df26cacSmrg    else
12776df26cacSmrg      removelist="$lobj $libobj ${libobj}T"
12786df26cacSmrg    fi
12796df26cacSmrg
12806df26cacSmrg    # On Cygwin there's no "real" PIC flag so we must build both object types
12816df26cacSmrg    case $host_os in
1282b68e1f86Smrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
12836df26cacSmrg      pic_mode=default
12846df26cacSmrg      ;;
12856df26cacSmrg    esac
12866df26cacSmrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
12876df26cacSmrg      # non-PIC code in shared libraries is not supported
12886df26cacSmrg      pic_mode=default
12896df26cacSmrg    fi
12906df26cacSmrg
12916df26cacSmrg    # Calculate the filename of the output object if compiler does
12926df26cacSmrg    # not support -o with -c
12936df26cacSmrg    if test "$compiler_c_o" = no; then
1294b68e1f86Smrg      output_obj=`$ECHO "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
12956df26cacSmrg      lockfile="$output_obj.lock"
12966df26cacSmrg    else
12976df26cacSmrg      output_obj=
12986df26cacSmrg      need_locks=no
12996df26cacSmrg      lockfile=
13006df26cacSmrg    fi
13016df26cacSmrg
13026df26cacSmrg    # Lock this critical section if it is needed
13036df26cacSmrg    # We use this script file to make the link, it avoids creating a new file
13046df26cacSmrg    if test "$need_locks" = yes; then
1305b68e1f86Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
1306b68e1f86Smrg	func_echo "Waiting for $lockfile to be removed"
13076df26cacSmrg	sleep 2
13086df26cacSmrg      done
13096df26cacSmrg    elif test "$need_locks" = warn; then
13106df26cacSmrg      if test -f "$lockfile"; then
1311b68e1f86Smrg	$ECHO "\
13126df26cacSmrg*** ERROR, $lockfile exists and contains:
13136df26cacSmrg`cat $lockfile 2>/dev/null`
13146df26cacSmrg
13156df26cacSmrgThis indicates that another process is trying to use the same
13166df26cacSmrgtemporary object file, and libtool could not work around it because
13176df26cacSmrgyour compiler does not support \`-c' and \`-o' together.  If you
13186df26cacSmrgrepeat this compilation, it may succeed, by chance, but you had better
13196df26cacSmrgavoid parallel builds (make -j) in this platform, or get a better
13206df26cacSmrgcompiler."
13216df26cacSmrg
1322b68e1f86Smrg	$opt_dry_run || $RM $removelist
13236df26cacSmrg	exit $EXIT_FAILURE
13246df26cacSmrg      fi
1325b68e1f86Smrg      removelist="$removelist $output_obj"
1326b68e1f86Smrg      $ECHO "$srcfile" > "$lockfile"
13276df26cacSmrg    fi
13286df26cacSmrg
1329b68e1f86Smrg    $opt_dry_run || $RM $removelist
1330b68e1f86Smrg    removelist="$removelist $lockfile"
1331b68e1f86Smrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
1332b68e1f86Smrg
13336df26cacSmrg    if test -n "$fix_srcfile_path"; then
13346df26cacSmrg      eval srcfile=\"$fix_srcfile_path\"
13356df26cacSmrg    fi
1336b68e1f86Smrg    func_quote_for_eval "$srcfile"
1337b68e1f86Smrg    qsrcfile=$func_quote_for_eval_result
13386df26cacSmrg
13396df26cacSmrg    # Only build a PIC object if we are building libtool libraries.
13406df26cacSmrg    if test "$build_libtool_libs" = yes; then
13416df26cacSmrg      # Without this assignment, base_compile gets emptied.
13426df26cacSmrg      fbsd_hideous_sh_bug=$base_compile
13436df26cacSmrg
13446df26cacSmrg      if test "$pic_mode" != no; then
13456df26cacSmrg	command="$base_compile $qsrcfile $pic_flag"
13466df26cacSmrg      else
13476df26cacSmrg	# Don't build PIC code
13486df26cacSmrg	command="$base_compile $qsrcfile"
13496df26cacSmrg      fi
13506df26cacSmrg
1351b68e1f86Smrg      func_mkdir_p "$xdir$objdir"
13526df26cacSmrg
13536df26cacSmrg      if test -z "$output_obj"; then
13546df26cacSmrg	# Place PIC objects in $objdir
13556df26cacSmrg	command="$command -o $lobj"
13566df26cacSmrg      fi
13576df26cacSmrg
1358b68e1f86Smrg      func_show_eval_locale "$command"	\
1359b68e1f86Smrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
13606df26cacSmrg
13616df26cacSmrg      if test "$need_locks" = warn &&
13626df26cacSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
1363b68e1f86Smrg	$ECHO "\
13646df26cacSmrg*** ERROR, $lockfile contains:
13656df26cacSmrg`cat $lockfile 2>/dev/null`
13666df26cacSmrg
13676df26cacSmrgbut it should contain:
13686df26cacSmrg$srcfile
13696df26cacSmrg
13706df26cacSmrgThis indicates that another process is trying to use the same
13716df26cacSmrgtemporary object file, and libtool could not work around it because
13726df26cacSmrgyour compiler does not support \`-c' and \`-o' together.  If you
13736df26cacSmrgrepeat this compilation, it may succeed, by chance, but you had better
13746df26cacSmrgavoid parallel builds (make -j) in this platform, or get a better
13756df26cacSmrgcompiler."
13766df26cacSmrg
1377b68e1f86Smrg	$opt_dry_run || $RM $removelist
13786df26cacSmrg	exit $EXIT_FAILURE
13796df26cacSmrg      fi
13806df26cacSmrg
13816df26cacSmrg      # Just move the object if needed, then go on to compile the next one
13826df26cacSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
1383b68e1f86Smrg	func_show_eval '$MV "$output_obj" "$lobj"' \
1384b68e1f86Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
13856df26cacSmrg      fi
13866df26cacSmrg
13876df26cacSmrg      # Allow error messages only from the first compilation.
13886df26cacSmrg      if test "$suppress_opt" = yes; then
1389b68e1f86Smrg	suppress_output=' >/dev/null 2>&1'
13906df26cacSmrg      fi
13916df26cacSmrg    fi
13926df26cacSmrg
13936df26cacSmrg    # Only build a position-dependent object if we build old libraries.
13946df26cacSmrg    if test "$build_old_libs" = yes; then
13956df26cacSmrg      if test "$pic_mode" != yes; then
13966df26cacSmrg	# Don't build PIC code
1397b68e1f86Smrg	command="$base_compile $qsrcfile$pie_flag"
13986df26cacSmrg      else
13996df26cacSmrg	command="$base_compile $qsrcfile $pic_flag"
14006df26cacSmrg      fi
14016df26cacSmrg      if test "$compiler_c_o" = yes; then
14026df26cacSmrg	command="$command -o $obj"
14036df26cacSmrg      fi
14046df26cacSmrg
14056df26cacSmrg      # Suppress compiler output if we already did a PIC compilation.
14066df26cacSmrg      command="$command$suppress_output"
1407b68e1f86Smrg      func_show_eval_locale "$command" \
1408b68e1f86Smrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
14096df26cacSmrg
14106df26cacSmrg      if test "$need_locks" = warn &&
14116df26cacSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
1412b68e1f86Smrg	$ECHO "\
14136df26cacSmrg*** ERROR, $lockfile contains:
14146df26cacSmrg`cat $lockfile 2>/dev/null`
14156df26cacSmrg
14166df26cacSmrgbut it should contain:
14176df26cacSmrg$srcfile
14186df26cacSmrg
14196df26cacSmrgThis indicates that another process is trying to use the same
14206df26cacSmrgtemporary object file, and libtool could not work around it because
14216df26cacSmrgyour compiler does not support \`-c' and \`-o' together.  If you
14226df26cacSmrgrepeat this compilation, it may succeed, by chance, but you had better
14236df26cacSmrgavoid parallel builds (make -j) in this platform, or get a better
14246df26cacSmrgcompiler."
14256df26cacSmrg
1426b68e1f86Smrg	$opt_dry_run || $RM $removelist
14276df26cacSmrg	exit $EXIT_FAILURE
14286df26cacSmrg      fi
14296df26cacSmrg
14306df26cacSmrg      # Just move the object if needed
14316df26cacSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
1432b68e1f86Smrg	func_show_eval '$MV "$output_obj" "$obj"' \
1433b68e1f86Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
14346df26cacSmrg      fi
14356df26cacSmrg    fi
14366df26cacSmrg
1437b68e1f86Smrg    $opt_dry_run || {
1438b68e1f86Smrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
14396df26cacSmrg
1440b68e1f86Smrg      # Unlock the critical section if it was locked
1441b68e1f86Smrg      if test "$need_locks" != no; then
1442b68e1f86Smrg	removelist=$lockfile
1443b68e1f86Smrg        $RM "$lockfile"
1444b68e1f86Smrg      fi
1445b68e1f86Smrg    }
14466df26cacSmrg
14476df26cacSmrg    exit $EXIT_SUCCESS
1448b68e1f86Smrg}
14496df26cacSmrg
1450b68e1f86Smrg$opt_help || {
1451b68e1f86Smrgtest "$mode" = compile && func_mode_compile ${1+"$@"}
1452b68e1f86Smrg}
14536df26cacSmrg
1454b68e1f86Smrgfunc_mode_help ()
1455b68e1f86Smrg{
1456b68e1f86Smrg    # We need to display help for each of the modes.
1457b68e1f86Smrg    case $mode in
1458b68e1f86Smrg      "")
1459b68e1f86Smrg        # Generic help is extracted from the usage comments
1460b68e1f86Smrg        # at the start of this file.
1461b68e1f86Smrg        func_help
1462b68e1f86Smrg        ;;
14636df26cacSmrg
1464b68e1f86Smrg      clean)
1465b68e1f86Smrg        $ECHO \
1466b68e1f86Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
14676df26cacSmrg
1468b68e1f86SmrgRemove files from the build directory.
14696df26cacSmrg
1470b68e1f86SmrgRM is the name of the program to use to delete files associated with each FILE
1471b68e1f86Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
1472b68e1f86Smrgto RM.
14736df26cacSmrg
1474b68e1f86SmrgIf FILE is a libtool library, object or program, all the files associated
1475b68e1f86Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
1476b68e1f86Smrg        ;;
14776df26cacSmrg
1478b68e1f86Smrg      compile)
1479b68e1f86Smrg      $ECHO \
1480b68e1f86Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
14816df26cacSmrg
1482b68e1f86SmrgCompile a source file into a libtool library object.
14836df26cacSmrg
1484b68e1f86SmrgThis mode accepts the following additional options:
14856df26cacSmrg
1486b68e1f86Smrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
1487b68e1f86Smrg  -no-suppress      do not suppress compiler output for multiple passes
1488b68e1f86Smrg  -prefer-pic       try to building PIC objects only
1489b68e1f86Smrg  -prefer-non-pic   try to building non-PIC objects only
1490b68e1f86Smrg  -shared           do not build a \`.o' file suitable for static linking
1491b68e1f86Smrg  -static           only build a \`.o' file suitable for static linking
14926df26cacSmrg
1493b68e1f86SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
1494b68e1f86Smrgfrom the given SOURCEFILE.
14956df26cacSmrg
1496b68e1f86SmrgThe output file name is determined by removing the directory component from
1497b68e1f86SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
1498b68e1f86Smrglibrary object suffix, \`.lo'."
1499b68e1f86Smrg        ;;
15006df26cacSmrg
1501b68e1f86Smrg      execute)
1502b68e1f86Smrg        $ECHO \
1503b68e1f86Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
15046df26cacSmrg
1505b68e1f86SmrgAutomatically set library path, then run a program.
15066df26cacSmrg
1507b68e1f86SmrgThis mode accepts the following additional options:
15086df26cacSmrg
1509b68e1f86Smrg  -dlopen FILE      add the directory containing FILE to the library path
15106df26cacSmrg
1511b68e1f86SmrgThis mode sets the library path environment variable according to \`-dlopen'
1512b68e1f86Smrgflags.
15136df26cacSmrg
1514b68e1f86SmrgIf any of the ARGS are libtool executable wrappers, then they are translated
1515b68e1f86Smrginto their corresponding uninstalled binary, and any of their required library
1516b68e1f86Smrgdirectories are added to the library path.
15176df26cacSmrg
1518b68e1f86SmrgThen, COMMAND is executed, with ARGS as arguments."
1519b68e1f86Smrg        ;;
15206df26cacSmrg
1521b68e1f86Smrg      finish)
1522b68e1f86Smrg        $ECHO \
1523b68e1f86Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
15246df26cacSmrg
1525b68e1f86SmrgComplete the installation of libtool libraries.
15266df26cacSmrg
1527b68e1f86SmrgEach LIBDIR is a directory that contains libtool libraries.
15286df26cacSmrg
1529b68e1f86SmrgThe commands that this mode executes may require superuser privileges.  Use
1530b68e1f86Smrgthe \`--dry-run' option if you just want to see what would be executed."
1531b68e1f86Smrg        ;;
15326df26cacSmrg
1533b68e1f86Smrg      install)
1534b68e1f86Smrg        $ECHO \
1535b68e1f86Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
15366df26cacSmrg
1537b68e1f86SmrgInstall executables or libraries.
15386df26cacSmrg
1539b68e1f86SmrgINSTALL-COMMAND is the installation command.  The first component should be
1540b68e1f86Smrgeither the \`install' or \`cp' program.
15416df26cacSmrg
1542b68e1f86SmrgThe following components of INSTALL-COMMAND are treated specially:
15436df26cacSmrg
1544b68e1f86Smrg  -inst-prefix PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
15456df26cacSmrg
1546b68e1f86SmrgThe rest of the components are interpreted as arguments to that command (only
1547b68e1f86SmrgBSD-compatible install options are recognized)."
1548b68e1f86Smrg        ;;
15496df26cacSmrg
1550b68e1f86Smrg      link)
1551b68e1f86Smrg        $ECHO \
1552b68e1f86Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
15536df26cacSmrg
1554b68e1f86SmrgLink object files or libraries together to form another library, or to
1555b68e1f86Smrgcreate an executable program.
15566df26cacSmrg
1557b68e1f86SmrgLINK-COMMAND is a command using the C compiler that you would use to create
1558b68e1f86Smrga program from several object files.
15596df26cacSmrg
1560b68e1f86SmrgThe following components of LINK-COMMAND are treated specially:
15616df26cacSmrg
1562b68e1f86Smrg  -all-static       do not do any dynamic linking at all
1563b68e1f86Smrg  -avoid-version    do not add a version suffix if possible
1564b68e1f86Smrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
1565b68e1f86Smrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
1566b68e1f86Smrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
1567b68e1f86Smrg  -export-symbols SYMFILE
1568b68e1f86Smrg                    try to export only the symbols listed in SYMFILE
1569b68e1f86Smrg  -export-symbols-regex REGEX
1570b68e1f86Smrg                    try to export only the symbols matching REGEX
1571b68e1f86Smrg  -LLIBDIR          search LIBDIR for required installed libraries
1572b68e1f86Smrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
1573b68e1f86Smrg  -module           build a library that can dlopened
1574b68e1f86Smrg  -no-fast-install  disable the fast-install mode
1575b68e1f86Smrg  -no-install       link a not-installable executable
1576b68e1f86Smrg  -no-undefined     declare that a library does not refer to external symbols
1577b68e1f86Smrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
1578b68e1f86Smrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
1579b68e1f86Smrg  -precious-files-regex REGEX
1580b68e1f86Smrg                    don't remove output files matching REGEX
1581b68e1f86Smrg  -release RELEASE  specify package release information
1582b68e1f86Smrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
1583b68e1f86Smrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
1584b68e1f86Smrg  -shared           only do dynamic linking of libtool libraries
1585b68e1f86Smrg  -shrext SUFFIX    override the standard shared library file extension
1586b68e1f86Smrg  -static           do not do any dynamic linking of uninstalled libtool libraries
1587b68e1f86Smrg  -static-libtool-libs
1588b68e1f86Smrg                    do not do any dynamic linking of libtool libraries
1589b68e1f86Smrg  -version-info CURRENT[:REVISION[:AGE]]
1590b68e1f86Smrg                    specify library version info [each variable defaults to 0]
1591b68e1f86Smrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
15926df26cacSmrg
1593b68e1f86SmrgAll other options (arguments beginning with \`-') are ignored.
15946df26cacSmrg
1595b68e1f86SmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
1596b68e1f86Smrgtreated as uninstalled libtool libraries, other files are standard or library
1597b68e1f86Smrgobject files.
15986df26cacSmrg
1599b68e1f86SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
1600b68e1f86Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
1601b68e1f86Smrgrequired, except when creating a convenience library.
16026df26cacSmrg
1603b68e1f86SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
1604b68e1f86Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
16056df26cacSmrg
1606b68e1f86SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
1607b68e1f86Smrgis created, otherwise an executable program is created."
16086df26cacSmrg        ;;
16096df26cacSmrg
1610b68e1f86Smrg      uninstall)
1611b68e1f86Smrg        $ECHO \
1612b68e1f86Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
16136df26cacSmrg
1614b68e1f86SmrgRemove libraries from an installation directory.
16156df26cacSmrg
1616b68e1f86SmrgRM is the name of the program to use to delete files associated with each FILE
1617b68e1f86Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
1618b68e1f86Smrgto RM.
16196df26cacSmrg
1620b68e1f86SmrgIf FILE is a libtool library, all the files associated with it are deleted.
1621b68e1f86SmrgOtherwise, only FILE itself is deleted using RM."
1622b68e1f86Smrg        ;;
16236df26cacSmrg
1624b68e1f86Smrg      *)
1625b68e1f86Smrg        func_fatal_help "invalid operation mode \`$mode'"
1626b68e1f86Smrg        ;;
1627b68e1f86Smrg    esac
16286df26cacSmrg
1629b68e1f86Smrg    $ECHO
1630b68e1f86Smrg    $ECHO "Try \`$progname --help' for more information about other modes."
16316df26cacSmrg
1632b68e1f86Smrg    exit $?
1633b68e1f86Smrg}
16346df26cacSmrg
1635b68e1f86Smrg  # Now that we've collected a possible --mode arg, show help if necessary
1636b68e1f86Smrg  $opt_help && func_mode_help
16376df26cacSmrg
16386df26cacSmrg
1639b68e1f86Smrg# func_mode_execute arg...
1640b68e1f86Smrgfunc_mode_execute ()
1641b68e1f86Smrg{
1642b68e1f86Smrg    $opt_debug
1643b68e1f86Smrg    # The first argument is the command name.
1644b68e1f86Smrg    cmd="$nonopt"
1645b68e1f86Smrg    test -z "$cmd" && \
1646b68e1f86Smrg      func_fatal_help "you must specify a COMMAND"
16476df26cacSmrg
1648b68e1f86Smrg    # Handle -dlopen flags immediately.
1649b68e1f86Smrg    for file in $execute_dlfiles; do
1650b68e1f86Smrg      test -f "$file" \
1651b68e1f86Smrg	|| func_fatal_help "\`$file' is not a file"
16526df26cacSmrg
1653b68e1f86Smrg      dir=
1654b68e1f86Smrg      case $file in
1655b68e1f86Smrg      *.la)
1656b68e1f86Smrg	# Check to see that this really is a libtool archive.
1657b68e1f86Smrg	func_lalib_unsafe_p "$file" \
1658b68e1f86Smrg	  || func_fatal_help "\`$lib' is not a valid libtool archive"
16596df26cacSmrg
1660b68e1f86Smrg	# Read the libtool library.
1661b68e1f86Smrg	dlname=
1662b68e1f86Smrg	library_names=
1663b68e1f86Smrg	func_source "$file"
16646df26cacSmrg
1665b68e1f86Smrg	# Skip this library if it cannot be dlopened.
1666b68e1f86Smrg	if test -z "$dlname"; then
1667b68e1f86Smrg	  # Warn if it was a shared library.
1668b68e1f86Smrg	  test -n "$library_names" && \
1669b68e1f86Smrg	    func_warning "\`$file' was not linked with \`-export-dynamic'"
1670b68e1f86Smrg	  continue
1671b68e1f86Smrg	fi
16726df26cacSmrg
1673b68e1f86Smrg	func_dirname "$file" "" "."
1674b68e1f86Smrg	dir="$func_dirname_result"
16756df26cacSmrg
1676b68e1f86Smrg	if test -f "$dir/$objdir/$dlname"; then
1677b68e1f86Smrg	  dir="$dir/$objdir"
1678b68e1f86Smrg	else
1679b68e1f86Smrg	  if test ! -f "$dir/$dlname"; then
1680b68e1f86Smrg	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
1681b68e1f86Smrg	  fi
1682b68e1f86Smrg	fi
16836df26cacSmrg	;;
16846df26cacSmrg
1685b68e1f86Smrg      *.lo)
1686b68e1f86Smrg	# Just add the directory containing the .lo file.
1687b68e1f86Smrg	func_dirname "$file" "" "."
1688b68e1f86Smrg	dir="$func_dirname_result"
16896df26cacSmrg	;;
16906df26cacSmrg
1691b68e1f86Smrg      *)
1692b68e1f86Smrg	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
16936df26cacSmrg	continue
16946df26cacSmrg	;;
1695b68e1f86Smrg      esac
16966df26cacSmrg
1697b68e1f86Smrg      # Get the absolute pathname.
1698b68e1f86Smrg      absdir=`cd "$dir" && pwd`
1699b68e1f86Smrg      test -n "$absdir" && dir="$absdir"
17006df26cacSmrg
1701b68e1f86Smrg      # Now add the directory to shlibpath_var.
1702b68e1f86Smrg      if eval "test -z \"\$$shlibpath_var\""; then
1703b68e1f86Smrg	eval "$shlibpath_var=\"\$dir\""
1704b68e1f86Smrg      else
1705b68e1f86Smrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
1706b68e1f86Smrg      fi
1707b68e1f86Smrg    done
17086df26cacSmrg
1709b68e1f86Smrg    # This variable tells wrapper scripts just to set shlibpath_var
1710b68e1f86Smrg    # rather than running their programs.
1711b68e1f86Smrg    libtool_execute_magic="$magic"
17126df26cacSmrg
1713b68e1f86Smrg    # Check if any of the arguments is a wrapper script.
1714b68e1f86Smrg    args=
1715b68e1f86Smrg    for file
1716b68e1f86Smrg    do
1717b68e1f86Smrg      case $file in
1718b68e1f86Smrg      -*) ;;
1719b68e1f86Smrg      *)
1720b68e1f86Smrg	# Do a test to see if this is really a libtool program.
1721b68e1f86Smrg	if func_ltwrapper_script_p "$file"; then
1722b68e1f86Smrg	  func_source "$file"
1723b68e1f86Smrg	  # Transform arg to wrapped name.
1724b68e1f86Smrg	  file="$progdir/$program"
1725b68e1f86Smrg	elif func_ltwrapper_executable_p "$file"; then
1726b68e1f86Smrg	  func_ltwrapper_scriptname "$file"
1727b68e1f86Smrg	  func_source "$func_ltwrapper_scriptname_result"
1728b68e1f86Smrg	  # Transform arg to wrapped name.
1729b68e1f86Smrg	  file="$progdir/$program"
1730b68e1f86Smrg	fi
1731b68e1f86Smrg	;;
1732b68e1f86Smrg      esac
1733b68e1f86Smrg      # Quote arguments (to preserve shell metacharacters).
1734b68e1f86Smrg      func_quote_for_eval "$file"
1735b68e1f86Smrg      args="$args $func_quote_for_eval_result"
1736b68e1f86Smrg    done
17376df26cacSmrg
1738b68e1f86Smrg    if test "X$opt_dry_run" = Xfalse; then
1739b68e1f86Smrg      if test -n "$shlibpath_var"; then
1740b68e1f86Smrg	# Export the shlibpath_var.
1741b68e1f86Smrg	eval "export $shlibpath_var"
1742b68e1f86Smrg      fi
17436df26cacSmrg
1744b68e1f86Smrg      # Restore saved environment variables
1745b68e1f86Smrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
1746b68e1f86Smrg      do
1747b68e1f86Smrg	eval "if test \"\${save_$lt_var+set}\" = set; then
1748b68e1f86Smrg                $lt_var=\$save_$lt_var; export $lt_var
17496df26cacSmrg	      else
1750b68e1f86Smrg		$lt_unset $lt_var
1751b68e1f86Smrg	      fi"
1752b68e1f86Smrg      done
17536df26cacSmrg
1754b68e1f86Smrg      # Now prepare to actually exec the command.
1755b68e1f86Smrg      exec_cmd="\$cmd$args"
1756b68e1f86Smrg    else
1757b68e1f86Smrg      # Display what would be done.
1758b68e1f86Smrg      if test -n "$shlibpath_var"; then
1759b68e1f86Smrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
1760b68e1f86Smrg	$ECHO "export $shlibpath_var"
1761b68e1f86Smrg      fi
1762b68e1f86Smrg      $ECHO "$cmd$args"
1763b68e1f86Smrg      exit $EXIT_SUCCESS
1764b68e1f86Smrg    fi
1765b68e1f86Smrg}
17666df26cacSmrg
1767b68e1f86Smrgtest "$mode" = execute && func_mode_execute ${1+"$@"}
17686df26cacSmrg
17696df26cacSmrg
1770b68e1f86Smrg# func_mode_finish arg...
1771b68e1f86Smrgfunc_mode_finish ()
1772b68e1f86Smrg{
1773b68e1f86Smrg    $opt_debug
1774b68e1f86Smrg    libdirs="$nonopt"
1775b68e1f86Smrg    admincmds=
17766df26cacSmrg
1777b68e1f86Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
1778b68e1f86Smrg      for dir
1779b68e1f86Smrg      do
1780b68e1f86Smrg	libdirs="$libdirs $dir"
1781b68e1f86Smrg      done
17826df26cacSmrg
1783b68e1f86Smrg      for libdir in $libdirs; do
1784b68e1f86Smrg	if test -n "$finish_cmds"; then
1785b68e1f86Smrg	  # Do each command in the finish commands.
1786b68e1f86Smrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
1787b68e1f86Smrg'"$cmd"'"'
17886df26cacSmrg	fi
1789b68e1f86Smrg	if test -n "$finish_eval"; then
1790b68e1f86Smrg	  # Do the single finish_eval.
1791b68e1f86Smrg	  eval cmds=\"$finish_eval\"
1792b68e1f86Smrg	  $opt_dry_run || eval "$cmds" || admincmds="$admincmds
1793b68e1f86Smrg       $cmds"
1794b68e1f86Smrg	fi
1795b68e1f86Smrg      done
1796b68e1f86Smrg    fi
17976df26cacSmrg
1798b68e1f86Smrg    # Exit here if they wanted silent mode.
1799b68e1f86Smrg    $opt_silent && exit $EXIT_SUCCESS
18006df26cacSmrg
1801b68e1f86Smrg    $ECHO "X----------------------------------------------------------------------" | $Xsed
1802b68e1f86Smrg    $ECHO "Libraries have been installed in:"
1803b68e1f86Smrg    for libdir in $libdirs; do
1804b68e1f86Smrg      $ECHO "   $libdir"
1805b68e1f86Smrg    done
1806b68e1f86Smrg    $ECHO
1807b68e1f86Smrg    $ECHO "If you ever happen to want to link against installed libraries"
1808b68e1f86Smrg    $ECHO "in a given directory, LIBDIR, you must either use libtool, and"
1809b68e1f86Smrg    $ECHO "specify the full pathname of the library, or use the \`-LLIBDIR'"
1810b68e1f86Smrg    $ECHO "flag during linking and do at least one of the following:"
1811b68e1f86Smrg    if test -n "$shlibpath_var"; then
1812b68e1f86Smrg      $ECHO "   - add LIBDIR to the \`$shlibpath_var' environment variable"
1813b68e1f86Smrg      $ECHO "     during execution"
1814b68e1f86Smrg    fi
1815b68e1f86Smrg    if test -n "$runpath_var"; then
1816b68e1f86Smrg      $ECHO "   - add LIBDIR to the \`$runpath_var' environment variable"
1817b68e1f86Smrg      $ECHO "     during linking"
1818b68e1f86Smrg    fi
1819b68e1f86Smrg    if test -n "$hardcode_libdir_flag_spec"; then
1820b68e1f86Smrg      libdir=LIBDIR
1821b68e1f86Smrg      eval flag=\"$hardcode_libdir_flag_spec\"
18226df26cacSmrg
1823b68e1f86Smrg      $ECHO "   - use the \`$flag' linker flag"
1824b68e1f86Smrg    fi
1825b68e1f86Smrg    if test -n "$admincmds"; then
1826b68e1f86Smrg      $ECHO "   - have your system administrator run these commands:$admincmds"
1827b68e1f86Smrg    fi
1828b68e1f86Smrg    if test -f /etc/ld.so.conf; then
1829b68e1f86Smrg      $ECHO "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
1830b68e1f86Smrg    fi
1831b68e1f86Smrg    $ECHO
1832b68e1f86Smrg
1833b68e1f86Smrg    $ECHO "See any operating system documentation about shared libraries for"
1834b68e1f86Smrg    case $host in
1835b68e1f86Smrg      solaris2.[6789]|solaris2.1[0-9])
1836b68e1f86Smrg        $ECHO "more information, such as the ld(1), crle(1) and ld.so(8) manual"
1837b68e1f86Smrg	$ECHO "pages."
1838b68e1f86Smrg	;;
1839b68e1f86Smrg      *)
1840b68e1f86Smrg        $ECHO "more information, such as the ld(1) and ld.so(8) manual pages."
1841b68e1f86Smrg        ;;
1842b68e1f86Smrg    esac
1843b68e1f86Smrg    $ECHO "X----------------------------------------------------------------------" | $Xsed
1844b68e1f86Smrg    exit $EXIT_SUCCESS
1845b68e1f86Smrg}
1846b68e1f86Smrg
1847b68e1f86Smrgtest "$mode" = finish && func_mode_finish ${1+"$@"}
1848b68e1f86Smrg
1849b68e1f86Smrg
1850b68e1f86Smrg# func_mode_install arg...
1851b68e1f86Smrgfunc_mode_install ()
1852b68e1f86Smrg{
1853b68e1f86Smrg    $opt_debug
1854b68e1f86Smrg    # There may be an optional sh(1) argument at the beginning of
1855b68e1f86Smrg    # install_prog (especially on Windows NT).
1856b68e1f86Smrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
1857b68e1f86Smrg       # Allow the use of GNU shtool's install command.
1858b68e1f86Smrg       $ECHO "X$nonopt" | $GREP shtool >/dev/null; then
1859b68e1f86Smrg      # Aesthetically quote it.
1860b68e1f86Smrg      func_quote_for_eval "$nonopt"
1861b68e1f86Smrg      install_prog="$func_quote_for_eval_result "
1862b68e1f86Smrg      arg=$1
1863b68e1f86Smrg      shift
1864b68e1f86Smrg    else
1865b68e1f86Smrg      install_prog=
1866b68e1f86Smrg      arg=$nonopt
1867b68e1f86Smrg    fi
1868b68e1f86Smrg
1869b68e1f86Smrg    # The real first argument should be the name of the installation program.
1870b68e1f86Smrg    # Aesthetically quote it.
1871b68e1f86Smrg    func_quote_for_eval "$arg"
1872b68e1f86Smrg    install_prog="$install_prog$func_quote_for_eval_result"
1873b68e1f86Smrg
1874b68e1f86Smrg    # We need to accept at least all the BSD install flags.
1875b68e1f86Smrg    dest=
1876b68e1f86Smrg    files=
1877b68e1f86Smrg    opts=
1878b68e1f86Smrg    prev=
1879b68e1f86Smrg    install_type=
1880b68e1f86Smrg    isdir=no
1881b68e1f86Smrg    stripme=
1882b68e1f86Smrg    for arg
1883b68e1f86Smrg    do
1884b68e1f86Smrg      if test -n "$dest"; then
1885b68e1f86Smrg	files="$files $dest"
1886b68e1f86Smrg	dest=$arg
1887b68e1f86Smrg	continue
1888b68e1f86Smrg      fi
1889b68e1f86Smrg
1890b68e1f86Smrg      case $arg in
1891b68e1f86Smrg      -d) isdir=yes ;;
1892b68e1f86Smrg      -f)
1893b68e1f86Smrg	case " $install_prog " in
1894b68e1f86Smrg	*[\\\ /]cp\ *) ;;
1895b68e1f86Smrg	*) prev=$arg ;;
1896b68e1f86Smrg	esac
1897b68e1f86Smrg	;;
1898b68e1f86Smrg      -g | -m | -o)
1899b68e1f86Smrg	prev=$arg
1900b68e1f86Smrg	;;
1901b68e1f86Smrg      -s)
1902b68e1f86Smrg	stripme=" -s"
1903b68e1f86Smrg	continue
1904b68e1f86Smrg	;;
1905b68e1f86Smrg      -*)
1906b68e1f86Smrg	;;
1907b68e1f86Smrg      *)
1908b68e1f86Smrg	# If the previous option needed an argument, then skip it.
1909b68e1f86Smrg	if test -n "$prev"; then
19106df26cacSmrg	  prev=
19116df26cacSmrg	else
1912b68e1f86Smrg	  dest=$arg
1913b68e1f86Smrg	  continue
19146df26cacSmrg	fi
19156df26cacSmrg	;;
1916b68e1f86Smrg      esac
19176df26cacSmrg
1918b68e1f86Smrg      # Aesthetically quote the argument.
1919b68e1f86Smrg      func_quote_for_eval "$arg"
1920b68e1f86Smrg      install_prog="$install_prog $func_quote_for_eval_result"
1921b68e1f86Smrg    done
19226df26cacSmrg
1923b68e1f86Smrg    test -z "$install_prog" && \
1924b68e1f86Smrg      func_fatal_help "you must specify an install program"
19256df26cacSmrg
1926b68e1f86Smrg    test -n "$prev" && \
1927b68e1f86Smrg      func_fatal_help "the \`$prev' option requires an argument"
19286df26cacSmrg
1929b68e1f86Smrg    if test -z "$files"; then
1930b68e1f86Smrg      if test -z "$dest"; then
1931b68e1f86Smrg	func_fatal_help "no file or destination specified"
1932b68e1f86Smrg      else
1933b68e1f86Smrg	func_fatal_help "you must specify a destination"
1934b68e1f86Smrg      fi
19356df26cacSmrg    fi
19366df26cacSmrg
1937b68e1f86Smrg    # Strip any trailing slash from the destination.
1938b68e1f86Smrg    func_stripname '' '/' "$dest"
1939b68e1f86Smrg    dest=$func_stripname_result
19406df26cacSmrg
1941b68e1f86Smrg    # Check to see that the destination is a directory.
1942b68e1f86Smrg    test -d "$dest" && isdir=yes
1943b68e1f86Smrg    if test "$isdir" = yes; then
1944b68e1f86Smrg      destdir="$dest"
1945b68e1f86Smrg      destname=
19466df26cacSmrg    else
1947b68e1f86Smrg      func_dirname_and_basename "$dest" "" "."
1948b68e1f86Smrg      destdir="$func_dirname_result"
1949b68e1f86Smrg      destname="$func_basename_result"
19506df26cacSmrg
1951b68e1f86Smrg      # Not a directory, so check to see that there is only one file specified.
1952b68e1f86Smrg      set dummy $files; shift
1953b68e1f86Smrg      test "$#" -gt 1 && \
1954b68e1f86Smrg	func_fatal_help "\`$dest' is not a directory"
19556df26cacSmrg    fi
1956b68e1f86Smrg    case $destdir in
1957b68e1f86Smrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
19586df26cacSmrg    *)
1959b68e1f86Smrg      for file in $files; do
1960b68e1f86Smrg	case $file in
1961b68e1f86Smrg	*.lo) ;;
1962b68e1f86Smrg	*)
1963b68e1f86Smrg	  func_fatal_help "\`$destdir' must be an absolute directory name"
1964b68e1f86Smrg	  ;;
1965b68e1f86Smrg	esac
1966b68e1f86Smrg      done
19676df26cacSmrg      ;;
19686df26cacSmrg    esac
19696df26cacSmrg
1970b68e1f86Smrg    # This variable tells wrapper scripts just to set variables rather
1971b68e1f86Smrg    # than running their programs.
1972b68e1f86Smrg    libtool_install_magic="$magic"
19736df26cacSmrg
1974b68e1f86Smrg    staticlibs=
1975b68e1f86Smrg    future_libdirs=
1976b68e1f86Smrg    current_libdirs=
1977b68e1f86Smrg    for file in $files; do
19786df26cacSmrg
1979b68e1f86Smrg      # Do each installation.
1980b68e1f86Smrg      case $file in
1981b68e1f86Smrg      *.$libext)
1982b68e1f86Smrg	# Do the static libraries later.
1983b68e1f86Smrg	staticlibs="$staticlibs $file"
1984b68e1f86Smrg	;;
1985b68e1f86Smrg
1986b68e1f86Smrg      *.la)
1987b68e1f86Smrg	# Check to see that this really is a libtool archive.
1988b68e1f86Smrg	func_lalib_unsafe_p "$file" \
1989b68e1f86Smrg	  || func_fatal_help "\`$file' is not a valid libtool archive"
1990b68e1f86Smrg
1991b68e1f86Smrg	library_names=
1992b68e1f86Smrg	old_library=
1993b68e1f86Smrg	relink_command=
1994b68e1f86Smrg	func_source "$file"
1995b68e1f86Smrg
1996b68e1f86Smrg	# Add the libdir to current_libdirs if it is the destination.
1997b68e1f86Smrg	if test "X$destdir" = "X$libdir"; then
1998b68e1f86Smrg	  case "$current_libdirs " in
1999b68e1f86Smrg	  *" $libdir "*) ;;
2000b68e1f86Smrg	  *) current_libdirs="$current_libdirs $libdir" ;;
20016df26cacSmrg	  esac
2002b68e1f86Smrg	else
2003b68e1f86Smrg	  # Note the libdir as a future libdir.
2004b68e1f86Smrg	  case "$future_libdirs " in
2005b68e1f86Smrg	  *" $libdir "*) ;;
2006b68e1f86Smrg	  *) future_libdirs="$future_libdirs $libdir" ;;
2007b68e1f86Smrg	  esac
2008b68e1f86Smrg	fi
20096df26cacSmrg
2010b68e1f86Smrg	func_dirname "$file" "/" ""
2011b68e1f86Smrg	dir="$func_dirname_result"
2012b68e1f86Smrg	dir="$dir$objdir"
2013b68e1f86Smrg
2014b68e1f86Smrg	if test -n "$relink_command"; then
2015b68e1f86Smrg	  # Determine the prefix the user has applied to our future dir.
2016b68e1f86Smrg	  inst_prefix_dir=`$ECHO "X$destdir" | $Xsed -e "s%$libdir\$%%"`
2017b68e1f86Smrg
2018b68e1f86Smrg	  # Don't allow the user to place us outside of our expected
2019b68e1f86Smrg	  # location b/c this prevents finding dependent libraries that
2020b68e1f86Smrg	  # are installed to the same prefix.
2021b68e1f86Smrg	  # At present, this check doesn't affect windows .dll's that
2022b68e1f86Smrg	  # are installed into $libdir/../bin (currently, that works fine)
2023b68e1f86Smrg	  # but it's something to keep an eye on.
2024b68e1f86Smrg	  test "$inst_prefix_dir" = "$destdir" && \
2025b68e1f86Smrg	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
2026b68e1f86Smrg
2027b68e1f86Smrg	  if test -n "$inst_prefix_dir"; then
2028b68e1f86Smrg	    # Stick the inst_prefix_dir data into the link command.
2029b68e1f86Smrg	    relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
2030b68e1f86Smrg	  else
2031b68e1f86Smrg	    relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%%"`
2032b68e1f86Smrg	  fi
2033b68e1f86Smrg
2034b68e1f86Smrg	  func_warning "relinking \`$file'"
2035b68e1f86Smrg	  func_show_eval "$relink_command" \
2036b68e1f86Smrg	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
2037b68e1f86Smrg	fi
2038b68e1f86Smrg
2039b68e1f86Smrg	# See the names of the shared library.
2040b68e1f86Smrg	set dummy $library_names; shift
2041b68e1f86Smrg	if test -n "$1"; then
2042b68e1f86Smrg	  realname="$1"
2043b68e1f86Smrg	  shift
2044b68e1f86Smrg
2045b68e1f86Smrg	  srcname="$realname"
2046b68e1f86Smrg	  test -n "$relink_command" && srcname="$realname"T
2047b68e1f86Smrg
2048b68e1f86Smrg	  # Install the shared library and build the symlinks.
2049b68e1f86Smrg	  func_show_eval "$install_prog $dir/$srcname $destdir/$realname" \
2050b68e1f86Smrg	      'exit $?'
2051b68e1f86Smrg	  tstripme="$stripme"
2052b68e1f86Smrg	  case $host_os in
2053b68e1f86Smrg	  cygwin* | mingw* | pw32* | cegcc*)
2054b68e1f86Smrg	    case $realname in
2055b68e1f86Smrg	    *.dll.a)
2056b68e1f86Smrg	      tstripme=""
2057b68e1f86Smrg	      ;;
2058b68e1f86Smrg	    esac
20596df26cacSmrg	    ;;
20606df26cacSmrg	  esac
2061b68e1f86Smrg	  if test -n "$tstripme" && test -n "$striplib"; then
2062b68e1f86Smrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
20636df26cacSmrg	  fi
2064b68e1f86Smrg
2065b68e1f86Smrg	  if test "$#" -gt 0; then
2066b68e1f86Smrg	    # Delete the old symlinks, and create new ones.
2067b68e1f86Smrg	    # Try `ln -sf' first, because the `ln' binary might depend on
2068b68e1f86Smrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
2069b68e1f86Smrg	    # so we also need to try rm && ln -s.
2070b68e1f86Smrg	    for linkname
2071b68e1f86Smrg	    do
2072b68e1f86Smrg	      test "$linkname" != "$realname" \
2073b68e1f86Smrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
20746df26cacSmrg	    done
20756df26cacSmrg	  fi
20766df26cacSmrg
2077b68e1f86Smrg	  # Do each command in the postinstall commands.
2078b68e1f86Smrg	  lib="$destdir/$realname"
2079b68e1f86Smrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
20806df26cacSmrg	fi
20816df26cacSmrg
2082b68e1f86Smrg	# Install the pseudo-library for information purposes.
2083b68e1f86Smrg	func_basename "$file"
2084b68e1f86Smrg	name="$func_basename_result"
2085b68e1f86Smrg	instname="$dir/$name"i
2086b68e1f86Smrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
20876df26cacSmrg
2088b68e1f86Smrg	# Maybe install the static library, too.
2089b68e1f86Smrg	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
2090b68e1f86Smrg	;;
20916df26cacSmrg
2092b68e1f86Smrg      *.lo)
2093b68e1f86Smrg	# Install (i.e. copy) a libtool object.
20946df26cacSmrg
2095b68e1f86Smrg	# Figure out destination file name, if it wasn't already specified.
2096b68e1f86Smrg	if test -n "$destname"; then
2097b68e1f86Smrg	  destfile="$destdir/$destname"
2098b68e1f86Smrg	else
2099b68e1f86Smrg	  func_basename "$file"
2100b68e1f86Smrg	  destfile="$func_basename_result"
2101b68e1f86Smrg	  destfile="$destdir/$destfile"
21026df26cacSmrg	fi
21036df26cacSmrg
2104b68e1f86Smrg	# Deduce the name of the destination old-style object file.
2105b68e1f86Smrg	case $destfile in
2106b68e1f86Smrg	*.lo)
2107b68e1f86Smrg	  func_lo2o "$destfile"
2108b68e1f86Smrg	  staticdest=$func_lo2o_result
2109b68e1f86Smrg	  ;;
2110b68e1f86Smrg	*.$objext)
2111b68e1f86Smrg	  staticdest="$destfile"
2112b68e1f86Smrg	  destfile=
2113b68e1f86Smrg	  ;;
2114b68e1f86Smrg	*)
2115b68e1f86Smrg	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
2116b68e1f86Smrg	  ;;
2117b68e1f86Smrg	esac
21186df26cacSmrg
2119b68e1f86Smrg	# Install the libtool object if requested.
2120b68e1f86Smrg	test -n "$destfile" && \
2121b68e1f86Smrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
21226df26cacSmrg
2123b68e1f86Smrg	# Install the old object if enabled.
2124b68e1f86Smrg	if test "$build_old_libs" = yes; then
2125b68e1f86Smrg	  # Deduce the name of the old-style object file.
2126b68e1f86Smrg	  func_lo2o "$file"
2127b68e1f86Smrg	  staticobj=$func_lo2o_result
2128b68e1f86Smrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
21296df26cacSmrg	fi
2130b68e1f86Smrg	exit $EXIT_SUCCESS
2131b68e1f86Smrg	;;
21326df26cacSmrg
2133b68e1f86Smrg      *)
2134b68e1f86Smrg	# Figure out destination file name, if it wasn't already specified.
2135b68e1f86Smrg	if test -n "$destname"; then
2136b68e1f86Smrg	  destfile="$destdir/$destname"
2137b68e1f86Smrg	else
2138b68e1f86Smrg	  func_basename "$file"
2139b68e1f86Smrg	  destfile="$func_basename_result"
2140b68e1f86Smrg	  destfile="$destdir/$destfile"
2141b68e1f86Smrg	fi
21426df26cacSmrg
2143b68e1f86Smrg	# If the file is missing, and there is a .exe on the end, strip it
2144b68e1f86Smrg	# because it is most likely a libtool script we actually want to
2145b68e1f86Smrg	# install
2146b68e1f86Smrg	stripped_ext=""
2147b68e1f86Smrg	case $file in
2148b68e1f86Smrg	  *.exe)
2149b68e1f86Smrg	    if test ! -f "$file"; then
2150b68e1f86Smrg	      func_stripname '' '.exe' "$file"
2151b68e1f86Smrg	      file=$func_stripname_result
2152b68e1f86Smrg	      stripped_ext=".exe"
2153b68e1f86Smrg	    fi
2154b68e1f86Smrg	    ;;
2155b68e1f86Smrg	esac
2156b68e1f86Smrg
2157b68e1f86Smrg	# Do a test to see if this is really a libtool program.
2158b68e1f86Smrg	case $host in
2159b68e1f86Smrg	*cygwin* | *mingw*)
2160b68e1f86Smrg	    if func_ltwrapper_executable_p "$file"; then
2161b68e1f86Smrg	      func_ltwrapper_scriptname "$file"
2162b68e1f86Smrg	      wrapper=$func_ltwrapper_scriptname_result
2163b68e1f86Smrg	    else
2164b68e1f86Smrg	      func_stripname '' '.exe' "$file"
2165b68e1f86Smrg	      wrapper=$func_stripname_result
2166b68e1f86Smrg	    fi
2167b68e1f86Smrg	    ;;
21686df26cacSmrg	*)
2169b68e1f86Smrg	    wrapper=$file
2170b68e1f86Smrg	    ;;
2171b68e1f86Smrg	esac
2172b68e1f86Smrg	if func_ltwrapper_script_p "$wrapper"; then
2173b68e1f86Smrg	  notinst_deplibs=
2174b68e1f86Smrg	  relink_command=
2175b68e1f86Smrg
2176b68e1f86Smrg	  func_source "$wrapper"
2177b68e1f86Smrg
2178b68e1f86Smrg	  # Check the variables that should have been set.
2179b68e1f86Smrg	  test -z "$generated_by_libtool_version" && \
2180b68e1f86Smrg	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
2181b68e1f86Smrg
2182b68e1f86Smrg	  finalize=yes
2183b68e1f86Smrg	  for lib in $notinst_deplibs; do
2184b68e1f86Smrg	    # Check to see that each library is installed.
2185b68e1f86Smrg	    libdir=
2186b68e1f86Smrg	    if test -f "$lib"; then
2187b68e1f86Smrg	      func_source "$lib"
2188b68e1f86Smrg	    fi
2189b68e1f86Smrg	    libfile="$libdir/"`$ECHO "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
2190b68e1f86Smrg	    if test -n "$libdir" && test ! -f "$libfile"; then
2191b68e1f86Smrg	      func_warning "\`$lib' has not been installed in \`$libdir'"
2192b68e1f86Smrg	      finalize=no
2193b68e1f86Smrg	    fi
2194b68e1f86Smrg	  done
2195b68e1f86Smrg
2196b68e1f86Smrg	  relink_command=
2197b68e1f86Smrg	  func_source "$wrapper"
2198b68e1f86Smrg
2199b68e1f86Smrg	  outputname=
2200b68e1f86Smrg	  if test "$fast_install" = no && test -n "$relink_command"; then
2201b68e1f86Smrg	    $opt_dry_run || {
2202b68e1f86Smrg	      if test "$finalize" = yes; then
2203b68e1f86Smrg	        tmpdir=`func_mktempdir`
2204b68e1f86Smrg		func_basename "$file$stripped_ext"
2205b68e1f86Smrg		file="$func_basename_result"
2206b68e1f86Smrg	        outputname="$tmpdir/$file"
2207b68e1f86Smrg	        # Replace the output file specification.
2208b68e1f86Smrg	        relink_command=`$ECHO "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
2209b68e1f86Smrg
2210b68e1f86Smrg	        $opt_silent || {
2211b68e1f86Smrg	          func_quote_for_expand "$relink_command"
2212b68e1f86Smrg		  eval "func_echo $func_quote_for_expand_result"
2213b68e1f86Smrg	        }
2214b68e1f86Smrg	        if eval "$relink_command"; then :
2215b68e1f86Smrg	          else
2216b68e1f86Smrg		  func_error "error: relink \`$file' with the above command before installing it"
2217b68e1f86Smrg		  $opt_dry_run || ${RM}r "$tmpdir"
2218b68e1f86Smrg		  continue
2219b68e1f86Smrg	        fi
2220b68e1f86Smrg	        file="$outputname"
2221b68e1f86Smrg	      else
2222b68e1f86Smrg	        func_warning "cannot relink \`$file'"
2223b68e1f86Smrg	      fi
2224b68e1f86Smrg	    }
2225b68e1f86Smrg	  else
2226b68e1f86Smrg	    # Install the binary that we compiled earlier.
2227b68e1f86Smrg	    file=`$ECHO "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
22286df26cacSmrg	  fi
2229b68e1f86Smrg	fi
2230b68e1f86Smrg
2231b68e1f86Smrg	# remove .exe since cygwin /usr/bin/install will append another
2232b68e1f86Smrg	# one anyway
2233b68e1f86Smrg	case $install_prog,$host in
2234b68e1f86Smrg	*/usr/bin/install*,*cygwin*)
2235b68e1f86Smrg	  case $file:$destfile in
2236b68e1f86Smrg	  *.exe:*.exe)
2237b68e1f86Smrg	    # this is ok
2238b68e1f86Smrg	    ;;
2239b68e1f86Smrg	  *.exe:*)
2240b68e1f86Smrg	    destfile=$destfile.exe
2241b68e1f86Smrg	    ;;
2242b68e1f86Smrg	  *:*.exe)
2243b68e1f86Smrg	    func_stripname '' '.exe' "$destfile"
2244b68e1f86Smrg	    destfile=$func_stripname_result
2245b68e1f86Smrg	    ;;
2246b68e1f86Smrg	  esac
22476df26cacSmrg	  ;;
22486df26cacSmrg	esac
2249b68e1f86Smrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
2250b68e1f86Smrg	$opt_dry_run || if test -n "$outputname"; then
2251b68e1f86Smrg	  ${RM}r "$tmpdir"
2252b68e1f86Smrg	fi
2253b68e1f86Smrg	;;
2254b68e1f86Smrg      esac
2255b68e1f86Smrg    done
22566df26cacSmrg
2257b68e1f86Smrg    for file in $staticlibs; do
2258b68e1f86Smrg      func_basename "$file"
2259b68e1f86Smrg      name="$func_basename_result"
2260b68e1f86Smrg
2261b68e1f86Smrg      # Set up the ranlib parameters.
2262b68e1f86Smrg      oldlib="$destdir/$name"
2263b68e1f86Smrg
2264b68e1f86Smrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
2265b68e1f86Smrg
2266b68e1f86Smrg      if test -n "$stripme" && test -n "$old_striplib"; then
2267b68e1f86Smrg	func_show_eval "$old_striplib $oldlib" 'exit $?'
2268b68e1f86Smrg      fi
2269b68e1f86Smrg
2270b68e1f86Smrg      # Do each command in the postinstall commands.
2271b68e1f86Smrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
2272b68e1f86Smrg    done
2273b68e1f86Smrg
2274b68e1f86Smrg    test -n "$future_libdirs" && \
2275b68e1f86Smrg      func_warning "remember to run \`$progname --finish$future_libdirs'"
2276b68e1f86Smrg
2277b68e1f86Smrg    if test -n "$current_libdirs"; then
2278b68e1f86Smrg      # Maybe just do a dry run.
2279b68e1f86Smrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
2280b68e1f86Smrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
2281b68e1f86Smrg    else
2282b68e1f86Smrg      exit $EXIT_SUCCESS
2283b68e1f86Smrg    fi
2284b68e1f86Smrg}
2285b68e1f86Smrg
2286b68e1f86Smrgtest "$mode" = install && func_mode_install ${1+"$@"}
2287b68e1f86Smrg
2288b68e1f86Smrg
2289b68e1f86Smrg# func_generate_dlsyms outputname originator pic_p
2290b68e1f86Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with
2291b68e1f86Smrg# a dlpreopen symbol table.
2292b68e1f86Smrgfunc_generate_dlsyms ()
2293b68e1f86Smrg{
2294b68e1f86Smrg    $opt_debug
2295b68e1f86Smrg    my_outputname="$1"
2296b68e1f86Smrg    my_originator="$2"
2297b68e1f86Smrg    my_pic_p="${3-no}"
2298b68e1f86Smrg    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
2299b68e1f86Smrg    my_dlsyms=
2300b68e1f86Smrg
2301b68e1f86Smrg    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
2302b68e1f86Smrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
2303b68e1f86Smrg	my_dlsyms="${my_outputname}S.c"
2304b68e1f86Smrg      else
2305b68e1f86Smrg	func_error "not configured to extract global symbols from dlpreopened files"
2306b68e1f86Smrg      fi
2307b68e1f86Smrg    fi
2308b68e1f86Smrg
2309b68e1f86Smrg    if test -n "$my_dlsyms"; then
2310b68e1f86Smrg      case $my_dlsyms in
2311b68e1f86Smrg      "") ;;
2312b68e1f86Smrg      *.c)
2313b68e1f86Smrg	# Discover the nlist of each of the dlfiles.
2314b68e1f86Smrg	nlist="$output_objdir/${my_outputname}.nm"
2315b68e1f86Smrg
2316b68e1f86Smrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
2317b68e1f86Smrg
2318b68e1f86Smrg	# Parse the name list into a source file.
2319b68e1f86Smrg	func_verbose "creating $output_objdir/$my_dlsyms"
2320b68e1f86Smrg
2321b68e1f86Smrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
2322b68e1f86Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
2323b68e1f86Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
2324b68e1f86Smrg
2325b68e1f86Smrg#ifdef __cplusplus
2326b68e1f86Smrgextern \"C\" {
2327b68e1f86Smrg#endif
2328b68e1f86Smrg
2329b68e1f86Smrg/* External symbol declarations for the compiler. */\
2330b68e1f86Smrg"
2331b68e1f86Smrg
2332b68e1f86Smrg	if test "$dlself" = yes; then
2333b68e1f86Smrg	  func_verbose "generating symbol list for \`$output'"
2334b68e1f86Smrg
2335b68e1f86Smrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
2336b68e1f86Smrg
2337b68e1f86Smrg	  # Add our own program objects to the symbol list.
2338b68e1f86Smrg	  progfiles=`$ECHO "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
2339b68e1f86Smrg	  for progfile in $progfiles; do
2340b68e1f86Smrg	    func_verbose "extracting global C symbols from \`$progfile'"
2341b68e1f86Smrg	    $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'"
2342b68e1f86Smrg	  done
2343b68e1f86Smrg
2344b68e1f86Smrg	  if test -n "$exclude_expsyms"; then
2345b68e1f86Smrg	    $opt_dry_run || {
2346b68e1f86Smrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
2347b68e1f86Smrg	      eval '$MV "$nlist"T "$nlist"'
2348b68e1f86Smrg	    }
23496df26cacSmrg	  fi
2350b68e1f86Smrg
2351b68e1f86Smrg	  if test -n "$export_symbols_regex"; then
2352b68e1f86Smrg	    $opt_dry_run || {
2353b68e1f86Smrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
2354b68e1f86Smrg	      eval '$MV "$nlist"T "$nlist"'
2355b68e1f86Smrg	    }
2356b68e1f86Smrg	  fi
2357b68e1f86Smrg
2358b68e1f86Smrg	  # Prepare the list of exported symbols
2359b68e1f86Smrg	  if test -z "$export_symbols"; then
2360b68e1f86Smrg	    export_symbols="$output_objdir/$outputname.exp"
2361b68e1f86Smrg	    $opt_dry_run || {
2362b68e1f86Smrg	      $RM $export_symbols
2363b68e1f86Smrg	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
2364b68e1f86Smrg	      case $host in
2365b68e1f86Smrg	      *cygwin* | *mingw* | *cegcc* )
2366b68e1f86Smrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
2367b68e1f86Smrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
2368b68e1f86Smrg	        ;;
2369b68e1f86Smrg	      esac
2370b68e1f86Smrg	    }
23716df26cacSmrg	  else
2372b68e1f86Smrg	    $opt_dry_run || {
2373b68e1f86Smrg	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
2374b68e1f86Smrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
2375b68e1f86Smrg	      eval '$MV "$nlist"T "$nlist"'
2376b68e1f86Smrg	      case $host in
2377b68e1f86Smrg	        *cygwin | *mingw* | *cegcc* )
2378b68e1f86Smrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
2379b68e1f86Smrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
2380b68e1f86Smrg	          ;;
2381b68e1f86Smrg	      esac
2382b68e1f86Smrg	    }
23836df26cacSmrg	  fi
2384b68e1f86Smrg	fi
23856df26cacSmrg
2386b68e1f86Smrg	for dlprefile in $dlprefiles; do
2387b68e1f86Smrg	  func_verbose "extracting global C symbols from \`$dlprefile'"
2388b68e1f86Smrg	  func_basename "$dlprefile"
2389b68e1f86Smrg	  name="$func_basename_result"
2390b68e1f86Smrg	  $opt_dry_run || {
2391b68e1f86Smrg	    eval '$ECHO ": $name " >> "$nlist"'
2392b68e1f86Smrg	    eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'"
2393b68e1f86Smrg	  }
2394b68e1f86Smrg	done
2395b68e1f86Smrg
2396b68e1f86Smrg	$opt_dry_run || {
2397b68e1f86Smrg	  # Make sure we have at least an empty file.
2398b68e1f86Smrg	  test -f "$nlist" || : > "$nlist"
2399b68e1f86Smrg
2400b68e1f86Smrg	  if test -n "$exclude_expsyms"; then
2401b68e1f86Smrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
2402b68e1f86Smrg	    $MV "$nlist"T "$nlist"
24036df26cacSmrg	  fi
2404b68e1f86Smrg
2405b68e1f86Smrg	  # Try sorting and uniquifying the output.
2406b68e1f86Smrg	  if $GREP -v "^: " < "$nlist" |
2407b68e1f86Smrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
2408b68e1f86Smrg		sort -k 3
2409b68e1f86Smrg	      else
2410b68e1f86Smrg		sort +2
2411b68e1f86Smrg	      fi |
2412b68e1f86Smrg	      uniq > "$nlist"S; then
2413b68e1f86Smrg	    :
24146df26cacSmrg	  else
2415b68e1f86Smrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
24166df26cacSmrg	  fi
24176df26cacSmrg
2418b68e1f86Smrg	  if test -f "$nlist"S; then
2419b68e1f86Smrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
24206df26cacSmrg	  else
2421b68e1f86Smrg	    $ECHO '/* NONE */' >> "$output_objdir/$my_dlsyms"
24226df26cacSmrg	  fi
24236df26cacSmrg
2424b68e1f86Smrg	  $ECHO >> "$output_objdir/$my_dlsyms" "\
24256df26cacSmrg
2426b68e1f86Smrg/* The mapping between symbol names and symbols.  */
2427b68e1f86Smrgtypedef struct {
2428b68e1f86Smrg  const char *name;
2429b68e1f86Smrg  void *address;
2430b68e1f86Smrg} lt_dlsymlist;
2431b68e1f86Smrg"
2432b68e1f86Smrg	  case $host in
2433b68e1f86Smrg	  *cygwin* | *mingw* | *cegcc* )
2434b68e1f86Smrg	    $ECHO >> "$output_objdir/$my_dlsyms" "\
2435b68e1f86Smrg/* DATA imports from DLLs on WIN32 con't be const, because
2436b68e1f86Smrg   runtime relocations are performed -- see ld's documentation
2437b68e1f86Smrg   on pseudo-relocs.  */"
2438b68e1f86Smrg	    lt_dlsym_const= ;;
2439b68e1f86Smrg	  *osf5*)
2440b68e1f86Smrg	    echo >> "$output_objdir/$my_dlsyms" "\
2441b68e1f86Smrg/* This system does not cope well with relocations in const data */"
2442b68e1f86Smrg	    lt_dlsym_const= ;;
2443b68e1f86Smrg	  *)
2444b68e1f86Smrg	    lt_dlsym_const=const ;;
2445b68e1f86Smrg	  esac
24466df26cacSmrg
2447b68e1f86Smrg	  $ECHO >> "$output_objdir/$my_dlsyms" "\
2448b68e1f86Smrgextern $lt_dlsym_const lt_dlsymlist
2449b68e1f86Smrglt_${my_prefix}_LTX_preloaded_symbols[];
2450b68e1f86Smrg$lt_dlsym_const lt_dlsymlist
2451b68e1f86Smrglt_${my_prefix}_LTX_preloaded_symbols[] =
2452b68e1f86Smrg{\
2453b68e1f86Smrg  { \"$my_originator\", (void *) 0 },"
24546df26cacSmrg
2455b68e1f86Smrg	  case $need_lib_prefix in
2456b68e1f86Smrg	  no)
2457b68e1f86Smrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
2458b68e1f86Smrg	    ;;
2459b68e1f86Smrg	  *)
2460b68e1f86Smrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
2461b68e1f86Smrg	    ;;
2462b68e1f86Smrg	  esac
2463b68e1f86Smrg	  $ECHO >> "$output_objdir/$my_dlsyms" "\
2464b68e1f86Smrg  {0, (void *) 0}
2465b68e1f86Smrg};
24666df26cacSmrg
2467b68e1f86Smrg/* This works around a problem in FreeBSD linker */
2468b68e1f86Smrg#ifdef FREEBSD_WORKAROUND
2469b68e1f86Smrgstatic const void *lt_preloaded_setup() {
2470b68e1f86Smrg  return lt_${my_prefix}_LTX_preloaded_symbols;
2471b68e1f86Smrg}
2472b68e1f86Smrg#endif
24736df26cacSmrg
2474b68e1f86Smrg#ifdef __cplusplus
2475b68e1f86Smrg}
2476b68e1f86Smrg#endif\
2477b68e1f86Smrg"
2478b68e1f86Smrg	} # !$opt_dry_run
24796df26cacSmrg
2480b68e1f86Smrg	pic_flag_for_symtable=
2481b68e1f86Smrg	case "$compile_command " in
2482b68e1f86Smrg	*" -static "*) ;;
2483b68e1f86Smrg	*)
2484b68e1f86Smrg	  case $host in
2485b68e1f86Smrg	  # compiling the symbol table file with pic_flag works around
2486b68e1f86Smrg	  # a FreeBSD bug that causes programs to crash when -lm is
2487b68e1f86Smrg	  # linked before any other PIC object.  But we must not use
2488b68e1f86Smrg	  # pic_flag when linking with -static.  The problem exists in
2489b68e1f86Smrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
2490b68e1f86Smrg	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
2491b68e1f86Smrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
2492b68e1f86Smrg	  *-*-hpux*)
2493b68e1f86Smrg	    pic_flag_for_symtable=" $pic_flag"  ;;
2494b68e1f86Smrg	  *)
2495b68e1f86Smrg	    if test "X$my_pic_p" != Xno; then
2496b68e1f86Smrg	      pic_flag_for_symtable=" $pic_flag"
2497b68e1f86Smrg	    fi
2498b68e1f86Smrg	    ;;
2499b68e1f86Smrg	  esac
2500b68e1f86Smrg	  ;;
2501b68e1f86Smrg	esac
2502b68e1f86Smrg	symtab_cflags=
2503b68e1f86Smrg	for arg in $LTCFLAGS; do
2504b68e1f86Smrg	  case $arg in
2505b68e1f86Smrg	  -pie | -fpie | -fPIE) ;;
2506b68e1f86Smrg	  *) symtab_cflags="$symtab_cflags $arg" ;;
2507b68e1f86Smrg	  esac
2508b68e1f86Smrg	done
25096df26cacSmrg
2510b68e1f86Smrg	# Now compile the dynamic symbol file.
2511b68e1f86Smrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
25126df26cacSmrg
2513b68e1f86Smrg	# Clean up the generated files.
2514b68e1f86Smrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
25156df26cacSmrg
2516b68e1f86Smrg	# Transform the symbol file into the correct name.
2517b68e1f86Smrg	symfileobj="$output_objdir/${my_outputname}S.$objext"
2518b68e1f86Smrg	case $host in
2519b68e1f86Smrg	*cygwin* | *mingw* | *cegcc* )
2520b68e1f86Smrg	  if test -f "$output_objdir/$my_outputname.def"; then
2521b68e1f86Smrg	    compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
2522b68e1f86Smrg	    finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
2523b68e1f86Smrg	  else
2524b68e1f86Smrg	    compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2525b68e1f86Smrg	    finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2526b68e1f86Smrg	  fi
2527b68e1f86Smrg	  ;;
2528b68e1f86Smrg	*)
2529b68e1f86Smrg	  compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2530b68e1f86Smrg	  finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2531b68e1f86Smrg	  ;;
2532b68e1f86Smrg	esac
2533b68e1f86Smrg	;;
2534b68e1f86Smrg      *)
2535b68e1f86Smrg	func_fatal_error "unknown suffix for \`$my_dlsyms'"
2536b68e1f86Smrg	;;
2537b68e1f86Smrg      esac
2538b68e1f86Smrg    else
2539b68e1f86Smrg      # We keep going just in case the user didn't refer to
2540b68e1f86Smrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
2541b68e1f86Smrg      # really was required.
25426df26cacSmrg
2543b68e1f86Smrg      # Nullify the symbol file.
2544b68e1f86Smrg      compile_command=`$ECHO "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
2545b68e1f86Smrg      finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
2546b68e1f86Smrg    fi
2547b68e1f86Smrg}
25486df26cacSmrg
2549b68e1f86Smrg# func_win32_libid arg
2550b68e1f86Smrg# return the library type of file 'arg'
2551b68e1f86Smrg#
2552b68e1f86Smrg# Need a lot of goo to handle *both* DLLs and import libs
2553b68e1f86Smrg# Has to be a shell function in order to 'eat' the argument
2554b68e1f86Smrg# that is supplied when $file_magic_command is called.
2555b68e1f86Smrgfunc_win32_libid ()
2556b68e1f86Smrg{
2557b68e1f86Smrg  $opt_debug
2558b68e1f86Smrg  win32_libid_type="unknown"
2559b68e1f86Smrg  win32_fileres=`file -L $1 2>/dev/null`
2560b68e1f86Smrg  case $win32_fileres in
2561b68e1f86Smrg  *ar\ archive\ import\ library*) # definitely import
2562b68e1f86Smrg    win32_libid_type="x86 archive import"
2563b68e1f86Smrg    ;;
2564b68e1f86Smrg  *ar\ archive*) # could be an import, or static
2565b68e1f86Smrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
2566b68e1f86Smrg       $EGREP 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
2567b68e1f86Smrg      win32_nmres=`eval $NM -f posix -A $1 |
2568b68e1f86Smrg	$SED -n -e '
2569b68e1f86Smrg	    1,100{
2570b68e1f86Smrg		/ I /{
2571b68e1f86Smrg		    s,.*,import,
2572b68e1f86Smrg		    p
2573b68e1f86Smrg		    q
2574b68e1f86Smrg		}
2575b68e1f86Smrg	    }'`
2576b68e1f86Smrg      case $win32_nmres in
2577b68e1f86Smrg      import*)  win32_libid_type="x86 archive import";;
2578b68e1f86Smrg      *)        win32_libid_type="x86 archive static";;
2579b68e1f86Smrg      esac
2580b68e1f86Smrg    fi
2581b68e1f86Smrg    ;;
2582b68e1f86Smrg  *DLL*)
2583b68e1f86Smrg    win32_libid_type="x86 DLL"
2584b68e1f86Smrg    ;;
2585b68e1f86Smrg  *executable*) # but shell scripts are "executable" too...
2586b68e1f86Smrg    case $win32_fileres in
2587b68e1f86Smrg    *MS\ Windows\ PE\ Intel*)
2588b68e1f86Smrg      win32_libid_type="x86 DLL"
2589b68e1f86Smrg      ;;
2590b68e1f86Smrg    esac
2591b68e1f86Smrg    ;;
2592b68e1f86Smrg  esac
2593b68e1f86Smrg  $ECHO "$win32_libid_type"
2594b68e1f86Smrg}
25956df26cacSmrg
25966df26cacSmrg
25976df26cacSmrg
2598b68e1f86Smrg# func_extract_an_archive dir oldlib
2599b68e1f86Smrgfunc_extract_an_archive ()
2600b68e1f86Smrg{
2601b68e1f86Smrg    $opt_debug
2602b68e1f86Smrg    f_ex_an_ar_dir="$1"; shift
2603b68e1f86Smrg    f_ex_an_ar_oldlib="$1"
2604b68e1f86Smrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" 'exit $?'
2605b68e1f86Smrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
2606b68e1f86Smrg     :
2607b68e1f86Smrg    else
2608b68e1f86Smrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
2609b68e1f86Smrg    fi
2610b68e1f86Smrg}
26116df26cacSmrg
26126df26cacSmrg
2613b68e1f86Smrg# func_extract_archives gentop oldlib ...
2614b68e1f86Smrgfunc_extract_archives ()
2615b68e1f86Smrg{
2616b68e1f86Smrg    $opt_debug
2617b68e1f86Smrg    my_gentop="$1"; shift
2618b68e1f86Smrg    my_oldlibs=${1+"$@"}
2619b68e1f86Smrg    my_oldobjs=""
2620b68e1f86Smrg    my_xlib=""
2621b68e1f86Smrg    my_xabs=""
2622b68e1f86Smrg    my_xdir=""
26236df26cacSmrg
2624b68e1f86Smrg    for my_xlib in $my_oldlibs; do
2625b68e1f86Smrg      # Extract the objects.
2626b68e1f86Smrg      case $my_xlib in
2627b68e1f86Smrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
2628b68e1f86Smrg	*) my_xabs=`pwd`"/$my_xlib" ;;
2629b68e1f86Smrg      esac
2630b68e1f86Smrg      func_basename "$my_xlib"
2631b68e1f86Smrg      my_xlib="$func_basename_result"
2632b68e1f86Smrg      my_xlib_u=$my_xlib
2633b68e1f86Smrg      while :; do
2634b68e1f86Smrg        case " $extracted_archives " in
2635b68e1f86Smrg	*" $my_xlib_u "*)
2636b68e1f86Smrg	  func_arith $extracted_serial + 1
2637b68e1f86Smrg	  extracted_serial=$func_arith_result
2638b68e1f86Smrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
2639b68e1f86Smrg	*) break ;;
2640b68e1f86Smrg	esac
2641b68e1f86Smrg      done
2642b68e1f86Smrg      extracted_archives="$extracted_archives $my_xlib_u"
2643b68e1f86Smrg      my_xdir="$my_gentop/$my_xlib_u"
26446df26cacSmrg
2645b68e1f86Smrg      func_mkdir_p "$my_xdir"
2646b68e1f86Smrg
2647b68e1f86Smrg      case $host in
2648b68e1f86Smrg      *-darwin*)
2649b68e1f86Smrg	func_verbose "Extracting $my_xabs"
2650b68e1f86Smrg	# Do not bother doing anything if just a dry run
2651b68e1f86Smrg	$opt_dry_run || {
2652b68e1f86Smrg	  darwin_orig_dir=`pwd`
2653b68e1f86Smrg	  cd $my_xdir || exit $?
2654b68e1f86Smrg	  darwin_archive=$my_xabs
2655b68e1f86Smrg	  darwin_curdir=`pwd`
2656b68e1f86Smrg	  darwin_base_archive=`basename "$darwin_archive"`
2657b68e1f86Smrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
2658b68e1f86Smrg	  if test -n "$darwin_arches"; then
2659b68e1f86Smrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
2660b68e1f86Smrg	    darwin_arch=
2661b68e1f86Smrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
2662b68e1f86Smrg	    for darwin_arch in  $darwin_arches ; do
2663b68e1f86Smrg	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
2664b68e1f86Smrg	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
2665b68e1f86Smrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
2666b68e1f86Smrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
2667b68e1f86Smrg	      cd "$darwin_curdir"
2668b68e1f86Smrg	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
2669b68e1f86Smrg	    done # $darwin_arches
2670b68e1f86Smrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
2671b68e1f86Smrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
2672b68e1f86Smrg	    darwin_file=
2673b68e1f86Smrg	    darwin_files=
2674b68e1f86Smrg	    for darwin_file in $darwin_filelist; do
2675b68e1f86Smrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
2676b68e1f86Smrg	      $LIPO -create -output "$darwin_file" $darwin_files
2677b68e1f86Smrg	    done # $darwin_filelist
2678b68e1f86Smrg	    $RM -rf unfat-$$
2679b68e1f86Smrg	    cd "$darwin_orig_dir"
26806df26cacSmrg	  else
2681b68e1f86Smrg	    cd $darwin_orig_dir
2682b68e1f86Smrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
2683b68e1f86Smrg	  fi # $darwin_arches
2684b68e1f86Smrg	} # !$opt_dry_run
2685b68e1f86Smrg	;;
2686b68e1f86Smrg      *)
2687b68e1f86Smrg        func_extract_an_archive "$my_xdir" "$my_xabs"
2688b68e1f86Smrg	;;
2689b68e1f86Smrg      esac
2690b68e1f86Smrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
2691b68e1f86Smrg    done
26926df26cacSmrg
2693b68e1f86Smrg    func_extract_archives_result="$my_oldobjs"
2694b68e1f86Smrg}
26956df26cacSmrg
26966df26cacSmrg
26976df26cacSmrg
2698b68e1f86Smrg# func_emit_wrapper_part1 [arg=no]
2699b68e1f86Smrg#
2700b68e1f86Smrg# Emit the first part of a libtool wrapper script on stdout.
2701b68e1f86Smrg# For more information, see the description associated with
2702b68e1f86Smrg# func_emit_wrapper(), below.
2703b68e1f86Smrgfunc_emit_wrapper_part1 ()
2704b68e1f86Smrg{
2705b68e1f86Smrg	func_emit_wrapper_part1_arg1=no
2706b68e1f86Smrg	if test -n "$1" ; then
2707b68e1f86Smrg	  func_emit_wrapper_part1_arg1=$1
27086df26cacSmrg	fi
27096df26cacSmrg
2710b68e1f86Smrg	$ECHO "\
2711b68e1f86Smrg#! $SHELL
27126df26cacSmrg
2713b68e1f86Smrg# $output - temporary wrapper script for $objdir/$outputname
2714b68e1f86Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
2715b68e1f86Smrg#
2716b68e1f86Smrg# The $output program cannot be directly executed until all the libtool
2717b68e1f86Smrg# libraries that it depends on are installed.
2718b68e1f86Smrg#
2719b68e1f86Smrg# This wrapper script should never be moved out of the build directory.
2720b68e1f86Smrg# If it is, it will not operate correctly.
27216df26cacSmrg
2722b68e1f86Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
2723b68e1f86Smrg# metacharacters that are still active within double-quoted strings.
2724b68e1f86SmrgXsed='${SED} -e 1s/^X//'
2725b68e1f86Smrgsed_quote_subst='$sed_quote_subst'
27266df26cacSmrg
2727b68e1f86Smrg# Be Bourne compatible
2728b68e1f86Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
2729b68e1f86Smrg  emulate sh
2730b68e1f86Smrg  NULLCMD=:
2731b68e1f86Smrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
2732b68e1f86Smrg  # is contrary to our usage.  Disable this feature.
2733b68e1f86Smrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
2734b68e1f86Smrg  setopt NO_GLOB_SUBST
2735b68e1f86Smrgelse
2736b68e1f86Smrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
2737b68e1f86Smrgfi
2738b68e1f86SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
2739b68e1f86SmrgDUALCASE=1; export DUALCASE # for MKS sh
27406df26cacSmrg
2741b68e1f86Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout
2742b68e1f86Smrg# if CDPATH is set.
2743b68e1f86Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
27446df26cacSmrg
2745b68e1f86Smrgrelink_command=\"$relink_command\"
27466df26cacSmrg
2747b68e1f86Smrg# This environment variable determines our operation mode.
2748b68e1f86Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then
2749b68e1f86Smrg  # install mode needs the following variables:
2750b68e1f86Smrg  generated_by_libtool_version='$macro_version'
2751b68e1f86Smrg  notinst_deplibs='$notinst_deplibs'
2752b68e1f86Smrgelse
2753b68e1f86Smrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
2754b68e1f86Smrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
2755b68e1f86Smrg    ECHO=\"$qecho\"
2756b68e1f86Smrg    file=\"\$0\"
2757b68e1f86Smrg    # Make sure echo works.
2758b68e1f86Smrg    if test \"X\$1\" = X--no-reexec; then
2759b68e1f86Smrg      # Discard the --no-reexec flag, and continue.
2760b68e1f86Smrg      shift
2761b68e1f86Smrg    elif test \"X\`{ \$ECHO '\t'; } 2>/dev/null\`\" = 'X\t'; then
2762b68e1f86Smrg      # Yippee, \$ECHO works!
2763b68e1f86Smrg      :
2764b68e1f86Smrg    else
2765b68e1f86Smrg      # Restart under the correct shell, and then maybe \$ECHO will work.
2766b68e1f86Smrg      exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
2767b68e1f86Smrg    fi
2768b68e1f86Smrg  fi\
2769b68e1f86Smrg"
2770b68e1f86Smrg	$ECHO "\
27716df26cacSmrg
2772b68e1f86Smrg  # Find the directory that this script lives in.
2773b68e1f86Smrg  thisdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
2774b68e1f86Smrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
27756df26cacSmrg
2776b68e1f86Smrg  # Follow symbolic links until we get to the real thisdir.
2777b68e1f86Smrg  file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
2778b68e1f86Smrg  while test -n \"\$file\"; do
2779b68e1f86Smrg    destdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
2780b68e1f86Smrg
2781b68e1f86Smrg    # If there was a directory component, then change thisdir.
2782b68e1f86Smrg    if test \"x\$destdir\" != \"x\$file\"; then
2783b68e1f86Smrg      case \"\$destdir\" in
2784b68e1f86Smrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
2785b68e1f86Smrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
27866df26cacSmrg      esac
2787b68e1f86Smrg    fi
27886df26cacSmrg
2789b68e1f86Smrg    file=\`\$ECHO \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
2790b68e1f86Smrg    file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
2791b68e1f86Smrg  done
2792b68e1f86Smrg"
2793b68e1f86Smrg}
2794b68e1f86Smrg# end: func_emit_wrapper_part1
2795b68e1f86Smrg
2796b68e1f86Smrg# func_emit_wrapper_part2 [arg=no]
2797b68e1f86Smrg#
2798b68e1f86Smrg# Emit the second part of a libtool wrapper script on stdout.
2799b68e1f86Smrg# For more information, see the description associated with
2800b68e1f86Smrg# func_emit_wrapper(), below.
2801b68e1f86Smrgfunc_emit_wrapper_part2 ()
2802b68e1f86Smrg{
2803b68e1f86Smrg	func_emit_wrapper_part2_arg1=no
2804b68e1f86Smrg	if test -n "$1" ; then
2805b68e1f86Smrg	  func_emit_wrapper_part2_arg1=$1
28066df26cacSmrg	fi
28076df26cacSmrg
2808b68e1f86Smrg	$ECHO "\
28096df26cacSmrg
2810b68e1f86Smrg  # Usually 'no', except on cygwin/mingw when embedded into
2811b68e1f86Smrg  # the cwrapper.
2812b68e1f86Smrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_part2_arg1
2813b68e1f86Smrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
2814b68e1f86Smrg    # special case for '.'
2815b68e1f86Smrg    if test \"\$thisdir\" = \".\"; then
2816b68e1f86Smrg      thisdir=\`pwd\`
2817b68e1f86Smrg    fi
2818b68e1f86Smrg    # remove .libs from thisdir
2819b68e1f86Smrg    case \"\$thisdir\" in
2820b68e1f86Smrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"X\$thisdir\" | \$Xsed -e 's%[\\\\/][^\\\\/]*$%%'\` ;;
2821b68e1f86Smrg    $objdir )   thisdir=. ;;
2822b68e1f86Smrg    esac
2823b68e1f86Smrg  fi
2824b68e1f86Smrg
2825b68e1f86Smrg  # Try to get the absolute directory name.
2826b68e1f86Smrg  absdir=\`cd \"\$thisdir\" && pwd\`
2827b68e1f86Smrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
2828b68e1f86Smrg"
2829b68e1f86Smrg
2830b68e1f86Smrg	if test "$fast_install" = yes; then
2831b68e1f86Smrg	  $ECHO "\
2832b68e1f86Smrg  program=lt-'$outputname'$exeext
2833b68e1f86Smrg  progdir=\"\$thisdir/$objdir\"
2834b68e1f86Smrg
2835b68e1f86Smrg  if test ! -f \"\$progdir/\$program\" ||
2836b68e1f86Smrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
2837b68e1f86Smrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
2838b68e1f86Smrg
2839b68e1f86Smrg    file=\"\$\$-\$program\"
2840b68e1f86Smrg
2841b68e1f86Smrg    if test ! -d \"\$progdir\"; then
2842b68e1f86Smrg      $MKDIR \"\$progdir\"
2843b68e1f86Smrg    else
2844b68e1f86Smrg      $RM \"\$progdir/\$file\"
2845b68e1f86Smrg    fi"
2846b68e1f86Smrg
2847b68e1f86Smrg	  $ECHO "\
2848b68e1f86Smrg
2849b68e1f86Smrg    # relink executable if necessary
2850b68e1f86Smrg    if test -n \"\$relink_command\"; then
2851b68e1f86Smrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
2852b68e1f86Smrg      else
2853b68e1f86Smrg	$ECHO \"\$relink_command_output\" >&2
2854b68e1f86Smrg	$RM \"\$progdir/\$file\"
2855b68e1f86Smrg	exit 1
28566df26cacSmrg      fi
2857b68e1f86Smrg    fi
28586df26cacSmrg
2859b68e1f86Smrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
2860b68e1f86Smrg    { $RM \"\$progdir/\$program\";
2861b68e1f86Smrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
2862b68e1f86Smrg    $RM \"\$progdir/\$file\"
2863b68e1f86Smrg  fi"
2864b68e1f86Smrg	else
2865b68e1f86Smrg	  $ECHO "\
2866b68e1f86Smrg  program='$outputname'
2867b68e1f86Smrg  progdir=\"\$thisdir/$objdir\"
2868b68e1f86Smrg"
28696df26cacSmrg	fi
28706df26cacSmrg
2871b68e1f86Smrg	$ECHO "\
2872b68e1f86Smrg
2873b68e1f86Smrg  if test -f \"\$progdir/\$program\"; then"
2874b68e1f86Smrg
2875b68e1f86Smrg	# Export our shlibpath_var if we have one.
2876b68e1f86Smrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
2877b68e1f86Smrg	  $ECHO "\
2878b68e1f86Smrg    # Add our own library path to $shlibpath_var
2879b68e1f86Smrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
2880b68e1f86Smrg
2881b68e1f86Smrg    # Some systems cannot cope with colon-terminated $shlibpath_var
2882b68e1f86Smrg    # The second colon is a workaround for a bug in BeOS R4 sed
2883b68e1f86Smrg    $shlibpath_var=\`\$ECHO \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
2884b68e1f86Smrg
2885b68e1f86Smrg    export $shlibpath_var
2886b68e1f86Smrg"
28876df26cacSmrg	fi
28886df26cacSmrg
2889b68e1f86Smrg	# fixup the dll searchpath if we need to.
2890b68e1f86Smrg	if test -n "$dllsearchpath"; then
2891b68e1f86Smrg	  $ECHO "\
2892b68e1f86Smrg    # Add the dll search path components to the executable PATH
2893b68e1f86Smrg    PATH=$dllsearchpath:\$PATH
2894b68e1f86Smrg"
28956df26cacSmrg	fi
28966df26cacSmrg
2897b68e1f86Smrg	$ECHO "\
2898b68e1f86Smrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
2899b68e1f86Smrg      # Run the actual program with our arguments.
2900b68e1f86Smrg"
2901b68e1f86Smrg	case $host in
2902b68e1f86Smrg	# Backslashes separate directories on plain windows
2903b68e1f86Smrg	*-*-mingw | *-*-os2* | *-cegcc*)
2904b68e1f86Smrg	  $ECHO "\
2905b68e1f86Smrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
2906b68e1f86Smrg"
2907b68e1f86Smrg	  ;;
2908b68e1f86Smrg
2909b68e1f86Smrg	*)
2910b68e1f86Smrg	  $ECHO "\
2911b68e1f86Smrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
2912b68e1f86Smrg"
2913b68e1f86Smrg	  ;;
2914b68e1f86Smrg	esac
2915b68e1f86Smrg	$ECHO "\
2916b68e1f86Smrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
2917b68e1f86Smrg      exit 1
2918b68e1f86Smrg    fi
2919b68e1f86Smrg  else
2920b68e1f86Smrg    # The program doesn't exist.
2921b68e1f86Smrg    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
2922b68e1f86Smrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
2923b68e1f86Smrg    $ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
2924b68e1f86Smrg    exit 1
2925b68e1f86Smrg  fi
2926b68e1f86Smrgfi\
2927b68e1f86Smrg"
2928b68e1f86Smrg}
2929b68e1f86Smrg# end: func_emit_wrapper_part2
2930b68e1f86Smrg
29316df26cacSmrg
2932b68e1f86Smrg# func_emit_wrapper [arg=no]
2933b68e1f86Smrg#
2934b68e1f86Smrg# Emit a libtool wrapper script on stdout.
2935b68e1f86Smrg# Don't directly open a file because we may want to
2936b68e1f86Smrg# incorporate the script contents within a cygwin/mingw
2937b68e1f86Smrg# wrapper executable.  Must ONLY be called from within
2938b68e1f86Smrg# func_mode_link because it depends on a number of variables
2939b68e1f86Smrg# set therein.
2940b68e1f86Smrg#
2941b68e1f86Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
2942b68e1f86Smrg# variable will take.  If 'yes', then the emitted script
2943b68e1f86Smrg# will assume that the directory in which it is stored is
2944b68e1f86Smrg# the $objdir directory.  This is a cygwin/mingw-specific
2945b68e1f86Smrg# behavior.
2946b68e1f86Smrgfunc_emit_wrapper ()
2947b68e1f86Smrg{
2948b68e1f86Smrg	func_emit_wrapper_arg1=no
2949b68e1f86Smrg	if test -n "$1" ; then
2950b68e1f86Smrg	  func_emit_wrapper_arg1=$1
29516df26cacSmrg	fi
29526df26cacSmrg
2953b68e1f86Smrg	# split this up so that func_emit_cwrapperexe_src
2954b68e1f86Smrg	# can call each part independently.
2955b68e1f86Smrg	func_emit_wrapper_part1 "${func_emit_wrapper_arg1}"
2956b68e1f86Smrg	func_emit_wrapper_part2 "${func_emit_wrapper_arg1}"
2957b68e1f86Smrg}
29586df26cacSmrg
29596df26cacSmrg
2960b68e1f86Smrg# func_to_host_path arg
2961b68e1f86Smrg#
2962b68e1f86Smrg# Convert paths to host format when used with build tools.
2963b68e1f86Smrg# Intended for use with "native" mingw (where libtool itself
2964b68e1f86Smrg# is running under the msys shell), or in the following cross-
2965b68e1f86Smrg# build environments:
2966b68e1f86Smrg#    $build          $host
2967b68e1f86Smrg#    mingw (msys)    mingw  [e.g. native]
2968b68e1f86Smrg#    cygwin          mingw
2969b68e1f86Smrg#    *nix + wine     mingw
2970b68e1f86Smrg# where wine is equipped with the `winepath' executable.
2971b68e1f86Smrg# In the native mingw case, the (msys) shell automatically
2972b68e1f86Smrg# converts paths for any non-msys applications it launches,
2973b68e1f86Smrg# but that facility isn't available from inside the cwrapper.
2974b68e1f86Smrg# Similar accommodations are necessary for $host mingw and
2975b68e1f86Smrg# $build cygwin.  Calling this function does no harm for other
2976b68e1f86Smrg# $host/$build combinations not listed above.
2977b68e1f86Smrg#
2978b68e1f86Smrg# ARG is the path (on $build) that should be converted to
2979b68e1f86Smrg# the proper representation for $host. The result is stored
2980b68e1f86Smrg# in $func_to_host_path_result.
2981b68e1f86Smrgfunc_to_host_path ()
2982b68e1f86Smrg{
2983b68e1f86Smrg  func_to_host_path_result="$1"
2984b68e1f86Smrg  if test -n "$1" ; then
2985b68e1f86Smrg    case $host in
2986b68e1f86Smrg      *mingw* )
2987b68e1f86Smrg        lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
2988b68e1f86Smrg        case $build in
2989b68e1f86Smrg          *mingw* ) # actually, msys
2990b68e1f86Smrg            # awkward: cmd appends spaces to result
2991b68e1f86Smrg            lt_sed_strip_trailing_spaces="s/[ ]*\$//"
2992b68e1f86Smrg            func_to_host_path_tmp1=`( cmd //c echo "$1" |\
2993b68e1f86Smrg              $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""`
2994b68e1f86Smrg            func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
2995b68e1f86Smrg              $SED -e "$lt_sed_naive_backslashify"`
2996b68e1f86Smrg            ;;
2997b68e1f86Smrg          *cygwin* )
2998b68e1f86Smrg            func_to_host_path_tmp1=`cygpath -w "$1"`
2999b68e1f86Smrg            func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
3000b68e1f86Smrg              $SED -e "$lt_sed_naive_backslashify"`
3001b68e1f86Smrg            ;;
3002b68e1f86Smrg          * )
3003b68e1f86Smrg            # Unfortunately, winepath does not exit with a non-zero
3004b68e1f86Smrg            # error code, so we are forced to check the contents of
3005b68e1f86Smrg            # stdout. On the other hand, if the command is not
3006b68e1f86Smrg            # found, the shell will set an exit code of 127 and print
3007b68e1f86Smrg            # *an error message* to stdout. So we must check for both
3008b68e1f86Smrg            # error code of zero AND non-empty stdout, which explains
3009b68e1f86Smrg            # the odd construction:
3010b68e1f86Smrg            func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null`
3011b68e1f86Smrg            if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then
3012b68e1f86Smrg              func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
3013b68e1f86Smrg                $SED -e "$lt_sed_naive_backslashify"`
3014b68e1f86Smrg            else
3015b68e1f86Smrg              # Allow warning below.
3016b68e1f86Smrg              func_to_host_path_result=""
3017b68e1f86Smrg            fi
3018b68e1f86Smrg            ;;
3019b68e1f86Smrg        esac
3020b68e1f86Smrg        if test -z "$func_to_host_path_result" ; then
3021b68e1f86Smrg          func_error "Could not determine host path corresponding to"
3022b68e1f86Smrg          func_error "  '$1'"
3023b68e1f86Smrg          func_error "Continuing, but uninstalled executables may not work."
3024b68e1f86Smrg          # Fallback:
3025b68e1f86Smrg          func_to_host_path_result="$1"
3026b68e1f86Smrg        fi
3027b68e1f86Smrg        ;;
3028b68e1f86Smrg    esac
3029b68e1f86Smrg  fi
3030b68e1f86Smrg}
3031b68e1f86Smrg# end: func_to_host_path
30326df26cacSmrg
3033b68e1f86Smrg# func_to_host_pathlist arg
3034b68e1f86Smrg#
3035b68e1f86Smrg# Convert pathlists to host format when used with build tools.
3036b68e1f86Smrg# See func_to_host_path(), above. This function supports the
3037b68e1f86Smrg# following $build/$host combinations (but does no harm for
3038b68e1f86Smrg# combinations not listed here):
3039b68e1f86Smrg#    $build          $host
3040b68e1f86Smrg#    mingw (msys)    mingw  [e.g. native]
3041b68e1f86Smrg#    cygwin          mingw
3042b68e1f86Smrg#    *nix + wine     mingw
3043b68e1f86Smrg#
3044b68e1f86Smrg# Path separators are also converted from $build format to
3045b68e1f86Smrg# $host format. If ARG begins or ends with a path separator
3046b68e1f86Smrg# character, it is preserved (but converted to $host format)
3047b68e1f86Smrg# on output.
3048b68e1f86Smrg#
3049b68e1f86Smrg# ARG is a pathlist (on $build) that should be converted to
3050b68e1f86Smrg# the proper representation on $host. The result is stored
3051b68e1f86Smrg# in $func_to_host_pathlist_result.
3052b68e1f86Smrgfunc_to_host_pathlist ()
3053b68e1f86Smrg{
3054b68e1f86Smrg  func_to_host_pathlist_result="$1"
3055b68e1f86Smrg  if test -n "$1" ; then
3056b68e1f86Smrg    case $host in
3057b68e1f86Smrg      *mingw* )
3058b68e1f86Smrg        lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
3059b68e1f86Smrg        # Remove leading and trailing path separator characters from
3060b68e1f86Smrg        # ARG. msys behavior is inconsistent here, cygpath turns them
3061b68e1f86Smrg        # into '.;' and ';.', and winepath ignores them completely.
3062b68e1f86Smrg        func_to_host_pathlist_tmp2="$1"
3063b68e1f86Smrg        # Once set for this call, this variable should not be
3064b68e1f86Smrg        # reassigned. It is used in tha fallback case.
3065b68e1f86Smrg        func_to_host_pathlist_tmp1=`echo "$func_to_host_pathlist_tmp2" |\
3066b68e1f86Smrg          $SED -e 's|^:*||' -e 's|:*$||'`
3067b68e1f86Smrg        case $build in
3068b68e1f86Smrg          *mingw* ) # Actually, msys.
3069b68e1f86Smrg            # Awkward: cmd appends spaces to result.
3070b68e1f86Smrg            lt_sed_strip_trailing_spaces="s/[ ]*\$//"
3071b68e1f86Smrg            func_to_host_pathlist_tmp2=`( cmd //c echo "$func_to_host_pathlist_tmp1" |\
3072b68e1f86Smrg              $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""`
3073b68e1f86Smrg            func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
3074b68e1f86Smrg              $SED -e "$lt_sed_naive_backslashify"`
3075b68e1f86Smrg            ;;
3076b68e1f86Smrg          *cygwin* )
3077b68e1f86Smrg            func_to_host_pathlist_tmp2=`cygpath -w -p "$func_to_host_pathlist_tmp1"`
3078b68e1f86Smrg            func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
3079b68e1f86Smrg              $SED -e "$lt_sed_naive_backslashify"`
3080b68e1f86Smrg            ;;
3081b68e1f86Smrg          * )
3082b68e1f86Smrg            # unfortunately, winepath doesn't convert pathlists
3083b68e1f86Smrg            func_to_host_pathlist_result=""
3084b68e1f86Smrg            func_to_host_pathlist_oldIFS=$IFS
3085b68e1f86Smrg            IFS=:
3086b68e1f86Smrg            for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do
3087b68e1f86Smrg              IFS=$func_to_host_pathlist_oldIFS
3088b68e1f86Smrg              if test -n "$func_to_host_pathlist_f" ; then
3089b68e1f86Smrg                func_to_host_path "$func_to_host_pathlist_f"
3090b68e1f86Smrg                if test -n "$func_to_host_path_result" ; then
3091b68e1f86Smrg                  if test -z "$func_to_host_pathlist_result" ; then
3092b68e1f86Smrg                    func_to_host_pathlist_result="$func_to_host_path_result"
3093b68e1f86Smrg                  else
3094b68e1f86Smrg                    func_to_host_pathlist_result="$func_to_host_pathlist_result;$func_to_host_path_result"
3095b68e1f86Smrg                  fi
3096b68e1f86Smrg                fi
3097b68e1f86Smrg              fi
3098b68e1f86Smrg              IFS=:
3099b68e1f86Smrg            done
3100b68e1f86Smrg            IFS=$func_to_host_pathlist_oldIFS
3101b68e1f86Smrg            ;;
3102b68e1f86Smrg        esac
3103b68e1f86Smrg        if test -z "$func_to_host_pathlist_result" ; then
3104b68e1f86Smrg          func_error "Could not determine the host path(s) corresponding to"
3105b68e1f86Smrg          func_error "  '$1'"
3106b68e1f86Smrg          func_error "Continuing, but uninstalled executables may not work."
3107b68e1f86Smrg          # Fallback. This may break if $1 contains DOS-style drive
3108b68e1f86Smrg          # specifications. The fix is not to complicate the expression
3109b68e1f86Smrg          # below, but for the user to provide a working wine installation
3110b68e1f86Smrg          # with winepath so that path translation in the cross-to-mingw
3111b68e1f86Smrg          # case works properly.
3112b68e1f86Smrg          lt_replace_pathsep_nix_to_dos="s|:|;|g"
3113b68e1f86Smrg          func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\
3114b68e1f86Smrg            $SED -e "$lt_replace_pathsep_nix_to_dos"`
3115b68e1f86Smrg        fi
3116b68e1f86Smrg        # Now, add the leading and trailing path separators back
3117b68e1f86Smrg        case "$1" in
3118b68e1f86Smrg          :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result"
3119b68e1f86Smrg            ;;
3120b68e1f86Smrg        esac
3121b68e1f86Smrg        case "$1" in
3122b68e1f86Smrg          *: ) func_to_host_pathlist_result="$func_to_host_pathlist_result;"
3123b68e1f86Smrg            ;;
3124b68e1f86Smrg        esac
3125b68e1f86Smrg        ;;
3126b68e1f86Smrg    esac
3127b68e1f86Smrg  fi
3128b68e1f86Smrg}
3129b68e1f86Smrg# end: func_to_host_pathlist
31306df26cacSmrg
3131b68e1f86Smrg# func_emit_cwrapperexe_src
3132b68e1f86Smrg# emit the source code for a wrapper executable on stdout
3133b68e1f86Smrg# Must ONLY be called from within func_mode_link because
3134b68e1f86Smrg# it depends on a number of variable set therein.
3135b68e1f86Smrgfunc_emit_cwrapperexe_src ()
3136b68e1f86Smrg{
3137b68e1f86Smrg	cat <<EOF
31386df26cacSmrg
3139b68e1f86Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
3140b68e1f86Smrg   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
31416df26cacSmrg
3142b68e1f86Smrg   The $output program cannot be directly executed until all the libtool
3143b68e1f86Smrg   libraries that it depends on are installed.
31446df26cacSmrg
3145b68e1f86Smrg   This wrapper executable should never be moved out of the build directory.
3146b68e1f86Smrg   If it is, it will not operate correctly.
31476df26cacSmrg
3148b68e1f86Smrg   Currently, it simply execs the wrapper *script* "$SHELL $output",
3149b68e1f86Smrg   but could eventually absorb all of the scripts functionality and
3150b68e1f86Smrg   exec $objdir/$outputname directly.
3151b68e1f86Smrg*/
3152b68e1f86SmrgEOF
3153b68e1f86Smrg	    cat <<"EOF"
3154b68e1f86Smrg#include <stdio.h>
3155b68e1f86Smrg#include <stdlib.h>
3156b68e1f86Smrg#ifdef _MSC_VER
3157b68e1f86Smrg# include <direct.h>
3158b68e1f86Smrg# include <process.h>
3159b68e1f86Smrg# include <io.h>
3160b68e1f86Smrg# define setmode _setmode
3161b68e1f86Smrg#else
3162b68e1f86Smrg# include <unistd.h>
3163b68e1f86Smrg# include <stdint.h>
3164b68e1f86Smrg# ifdef __CYGWIN__
3165b68e1f86Smrg#  include <io.h>
3166b68e1f86Smrg#  define HAVE_SETENV
3167b68e1f86Smrg#  ifdef __STRICT_ANSI__
3168b68e1f86Smrgchar *realpath (const char *, char *);
3169b68e1f86Smrgint putenv (char *);
3170b68e1f86Smrgint setenv (const char *, const char *, int);
3171b68e1f86Smrg#  endif
3172b68e1f86Smrg# endif
3173b68e1f86Smrg#endif
3174b68e1f86Smrg#include <malloc.h>
3175b68e1f86Smrg#include <stdarg.h>
3176b68e1f86Smrg#include <assert.h>
3177b68e1f86Smrg#include <string.h>
3178b68e1f86Smrg#include <ctype.h>
3179b68e1f86Smrg#include <errno.h>
3180b68e1f86Smrg#include <fcntl.h>
3181b68e1f86Smrg#include <sys/stat.h>
31826df26cacSmrg
3183b68e1f86Smrg#if defined(PATH_MAX)
3184b68e1f86Smrg# define LT_PATHMAX PATH_MAX
3185b68e1f86Smrg#elif defined(MAXPATHLEN)
3186b68e1f86Smrg# define LT_PATHMAX MAXPATHLEN
3187b68e1f86Smrg#else
3188b68e1f86Smrg# define LT_PATHMAX 1024
3189b68e1f86Smrg#endif
31906df26cacSmrg
3191b68e1f86Smrg#ifndef S_IXOTH
3192b68e1f86Smrg# define S_IXOTH 0
3193b68e1f86Smrg#endif
3194b68e1f86Smrg#ifndef S_IXGRP
3195b68e1f86Smrg# define S_IXGRP 0
3196b68e1f86Smrg#endif
31976df26cacSmrg
3198b68e1f86Smrg#ifdef _MSC_VER
3199b68e1f86Smrg# define S_IXUSR _S_IEXEC
3200b68e1f86Smrg# define stat _stat
3201b68e1f86Smrg# ifndef _INTPTR_T_DEFINED
3202b68e1f86Smrg#  define intptr_t int
3203b68e1f86Smrg# endif
3204b68e1f86Smrg#endif
32056df26cacSmrg
3206b68e1f86Smrg#ifndef DIR_SEPARATOR
3207b68e1f86Smrg# define DIR_SEPARATOR '/'
3208b68e1f86Smrg# define PATH_SEPARATOR ':'
3209b68e1f86Smrg#endif
32106df26cacSmrg
3211b68e1f86Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
3212b68e1f86Smrg  defined (__OS2__)
3213b68e1f86Smrg# define HAVE_DOS_BASED_FILE_SYSTEM
3214b68e1f86Smrg# define FOPEN_WB "wb"
3215b68e1f86Smrg# ifndef DIR_SEPARATOR_2
3216b68e1f86Smrg#  define DIR_SEPARATOR_2 '\\'
3217b68e1f86Smrg# endif
3218b68e1f86Smrg# ifndef PATH_SEPARATOR_2
3219b68e1f86Smrg#  define PATH_SEPARATOR_2 ';'
3220b68e1f86Smrg# endif
3221b68e1f86Smrg#endif
32226df26cacSmrg
3223b68e1f86Smrg#ifndef DIR_SEPARATOR_2
3224b68e1f86Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
3225b68e1f86Smrg#else /* DIR_SEPARATOR_2 */
3226b68e1f86Smrg# define IS_DIR_SEPARATOR(ch) \
3227b68e1f86Smrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
3228b68e1f86Smrg#endif /* DIR_SEPARATOR_2 */
32296df26cacSmrg
3230b68e1f86Smrg#ifndef PATH_SEPARATOR_2
3231b68e1f86Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
3232b68e1f86Smrg#else /* PATH_SEPARATOR_2 */
3233b68e1f86Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
3234b68e1f86Smrg#endif /* PATH_SEPARATOR_2 */
32356df26cacSmrg
3236b68e1f86Smrg#ifdef __CYGWIN__
3237b68e1f86Smrg# define FOPEN_WB "wb"
3238b68e1f86Smrg#endif
32396df26cacSmrg
3240b68e1f86Smrg#ifndef FOPEN_WB
3241b68e1f86Smrg# define FOPEN_WB "w"
3242b68e1f86Smrg#endif
3243b68e1f86Smrg#ifndef _O_BINARY
3244b68e1f86Smrg# define _O_BINARY 0
3245b68e1f86Smrg#endif
32466df26cacSmrg
3247b68e1f86Smrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
3248b68e1f86Smrg#define XFREE(stale) do { \
3249b68e1f86Smrg  if (stale) { free ((void *) stale); stale = 0; } \
3250b68e1f86Smrg} while (0)
32516df26cacSmrg
3252b68e1f86Smrg#undef LTWRAPPER_DEBUGPRINTF
3253b68e1f86Smrg#if defined DEBUGWRAPPER
3254b68e1f86Smrg# define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args
3255b68e1f86Smrgstatic void
3256b68e1f86Smrgltwrapper_debugprintf (const char *fmt, ...)
3257b68e1f86Smrg{
3258b68e1f86Smrg    va_list args;
3259b68e1f86Smrg    va_start (args, fmt);
3260b68e1f86Smrg    (void) vfprintf (stderr, fmt, args);
3261b68e1f86Smrg    va_end (args);
3262b68e1f86Smrg}
3263b68e1f86Smrg#else
3264b68e1f86Smrg# define LTWRAPPER_DEBUGPRINTF(args)
3265b68e1f86Smrg#endif
32666df26cacSmrg
3267b68e1f86Smrgconst char *program_name = NULL;
32686df26cacSmrg
3269b68e1f86Smrgvoid *xmalloc (size_t num);
3270b68e1f86Smrgchar *xstrdup (const char *string);
3271b68e1f86Smrgconst char *base_name (const char *name);
3272b68e1f86Smrgchar *find_executable (const char *wrapper);
3273b68e1f86Smrgchar *chase_symlinks (const char *pathspec);
3274b68e1f86Smrgint make_executable (const char *path);
3275b68e1f86Smrgint check_executable (const char *path);
3276b68e1f86Smrgchar *strendzap (char *str, const char *pat);
3277b68e1f86Smrgvoid lt_fatal (const char *message, ...);
3278b68e1f86Smrgvoid lt_setenv (const char *name, const char *value);
3279b68e1f86Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
3280b68e1f86Smrgvoid lt_opt_process_env_set (const char *arg);
3281b68e1f86Smrgvoid lt_opt_process_env_prepend (const char *arg);
3282b68e1f86Smrgvoid lt_opt_process_env_append (const char *arg);
3283b68e1f86Smrgint lt_split_name_value (const char *arg, char** name, char** value);
3284b68e1f86Smrgvoid lt_update_exe_path (const char *name, const char *value);
3285b68e1f86Smrgvoid lt_update_lib_path (const char *name, const char *value);
3286b68e1f86Smrg
3287b68e1f86Smrgstatic const char *script_text_part1 =
3288b68e1f86SmrgEOF
32896df26cacSmrg
3290b68e1f86Smrg	    func_emit_wrapper_part1 yes |
3291b68e1f86Smrg	        $SED -e 's/\([\\"]\)/\\\1/g' \
3292b68e1f86Smrg	             -e 's/^/  "/' -e 's/$/\\n"/'
3293b68e1f86Smrg	    echo ";"
3294b68e1f86Smrg	    cat <<EOF
32956df26cacSmrg
3296b68e1f86Smrgstatic const char *script_text_part2 =
3297b68e1f86SmrgEOF
3298b68e1f86Smrg	    func_emit_wrapper_part2 yes |
3299b68e1f86Smrg	        $SED -e 's/\([\\"]\)/\\\1/g' \
3300b68e1f86Smrg	             -e 's/^/  "/' -e 's/$/\\n"/'
3301b68e1f86Smrg	    echo ";"
3302b68e1f86Smrg
3303b68e1f86Smrg	    cat <<EOF
3304b68e1f86Smrgconst char * MAGIC_EXE = "$magic_exe";
3305b68e1f86Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
3306b68e1f86SmrgEOF
33076df26cacSmrg
3308b68e1f86Smrg	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
3309b68e1f86Smrg              func_to_host_pathlist "$temp_rpath"
3310b68e1f86Smrg	      cat <<EOF
3311b68e1f86Smrgconst char * LIB_PATH_VALUE   = "$func_to_host_pathlist_result";
3312b68e1f86SmrgEOF
3313b68e1f86Smrg	    else
3314b68e1f86Smrg	      cat <<"EOF"
3315b68e1f86Smrgconst char * LIB_PATH_VALUE   = "";
3316b68e1f86SmrgEOF
3317b68e1f86Smrg	    fi
33186df26cacSmrg
3319b68e1f86Smrg	    if test -n "$dllsearchpath"; then
3320b68e1f86Smrg              func_to_host_pathlist "$dllsearchpath:"
3321b68e1f86Smrg	      cat <<EOF
3322b68e1f86Smrgconst char * EXE_PATH_VARNAME = "PATH";
3323b68e1f86Smrgconst char * EXE_PATH_VALUE   = "$func_to_host_pathlist_result";
3324b68e1f86SmrgEOF
3325b68e1f86Smrg	    else
3326b68e1f86Smrg	      cat <<"EOF"
3327b68e1f86Smrgconst char * EXE_PATH_VARNAME = "";
3328b68e1f86Smrgconst char * EXE_PATH_VALUE   = "";
3329b68e1f86SmrgEOF
3330b68e1f86Smrg	    fi
33316df26cacSmrg
3332b68e1f86Smrg	    if test "$fast_install" = yes; then
3333b68e1f86Smrg	      cat <<EOF
3334b68e1f86Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
3335b68e1f86SmrgEOF
3336b68e1f86Smrg	    else
3337b68e1f86Smrg	      cat <<EOF
3338b68e1f86Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
3339b68e1f86SmrgEOF
3340b68e1f86Smrg	    fi
33416df26cacSmrg
33426df26cacSmrg
3343b68e1f86Smrg	    cat <<"EOF"
33446df26cacSmrg
3345b68e1f86Smrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
3346b68e1f86Smrg#define LTWRAPPER_OPTION_PREFIX_LENGTH  5
33476df26cacSmrg
3348b68e1f86Smrgstatic const size_t opt_prefix_len         = LTWRAPPER_OPTION_PREFIX_LENGTH;
3349b68e1f86Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
3350b68e1f86Smrg
3351b68e1f86Smrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
3352b68e1f86Smrg
3353b68e1f86Smrgstatic const size_t env_set_opt_len     = LTWRAPPER_OPTION_PREFIX_LENGTH + 7;
3354b68e1f86Smrgstatic const char *env_set_opt          = LTWRAPPER_OPTION_PREFIX "env-set";
3355b68e1f86Smrg  /* argument is putenv-style "foo=bar", value of foo is set to bar */
3356b68e1f86Smrg
3357b68e1f86Smrgstatic const size_t env_prepend_opt_len = LTWRAPPER_OPTION_PREFIX_LENGTH + 11;
3358b68e1f86Smrgstatic const char *env_prepend_opt      = LTWRAPPER_OPTION_PREFIX "env-prepend";
3359b68e1f86Smrg  /* argument is putenv-style "foo=bar", new value of foo is bar${foo} */
3360b68e1f86Smrg
3361b68e1f86Smrgstatic const size_t env_append_opt_len  = LTWRAPPER_OPTION_PREFIX_LENGTH + 10;
3362b68e1f86Smrgstatic const char *env_append_opt       = LTWRAPPER_OPTION_PREFIX "env-append";
3363b68e1f86Smrg  /* argument is putenv-style "foo=bar", new value of foo is ${foo}bar */
3364b68e1f86Smrg
3365b68e1f86Smrgint
3366b68e1f86Smrgmain (int argc, char *argv[])
3367b68e1f86Smrg{
3368b68e1f86Smrg  char **newargz;
3369b68e1f86Smrg  int  newargc;
3370b68e1f86Smrg  char *tmp_pathspec;
3371b68e1f86Smrg  char *actual_cwrapper_path;
3372b68e1f86Smrg  char *actual_cwrapper_name;
3373b68e1f86Smrg  char *target_name;
3374b68e1f86Smrg  char *lt_argv_zero;
3375b68e1f86Smrg  intptr_t rval = 127;
3376b68e1f86Smrg
3377b68e1f86Smrg  int i;
3378b68e1f86Smrg
3379b68e1f86Smrg  program_name = (char *) xstrdup (base_name (argv[0]));
3380b68e1f86Smrg  LTWRAPPER_DEBUGPRINTF (("(main) argv[0]      : %s\n", argv[0]));
3381b68e1f86Smrg  LTWRAPPER_DEBUGPRINTF (("(main) program_name : %s\n", program_name));
3382b68e1f86Smrg
3383b68e1f86Smrg  /* very simple arg parsing; don't want to rely on getopt */
3384b68e1f86Smrg  for (i = 1; i < argc; i++)
3385b68e1f86Smrg    {
3386b68e1f86Smrg      if (strcmp (argv[i], dumpscript_opt) == 0)
3387b68e1f86Smrg	{
3388b68e1f86SmrgEOF
3389b68e1f86Smrg	    case "$host" in
3390b68e1f86Smrg	      *mingw* | *cygwin* )
3391b68e1f86Smrg		# make stdout use "unix" line endings
3392b68e1f86Smrg		echo "          setmode(1,_O_BINARY);"
3393b68e1f86Smrg		;;
3394b68e1f86Smrg	      esac
3395b68e1f86Smrg
3396b68e1f86Smrg	    cat <<"EOF"
3397b68e1f86Smrg	  printf ("%s", script_text_part1);
3398b68e1f86Smrg	  printf ("%s", script_text_part2);
3399b68e1f86Smrg	  return 0;
3400b68e1f86Smrg	}
3401b68e1f86Smrg    }
3402b68e1f86Smrg
3403b68e1f86Smrg  newargz = XMALLOC (char *, argc + 1);
3404b68e1f86Smrg  tmp_pathspec = find_executable (argv[0]);
3405b68e1f86Smrg  if (tmp_pathspec == NULL)
3406b68e1f86Smrg    lt_fatal ("Couldn't find %s", argv[0]);
3407b68e1f86Smrg  LTWRAPPER_DEBUGPRINTF (("(main) found exe (before symlink chase) at : %s\n",
3408b68e1f86Smrg			  tmp_pathspec));
3409b68e1f86Smrg
3410b68e1f86Smrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
3411b68e1f86Smrg  LTWRAPPER_DEBUGPRINTF (("(main) found exe (after symlink chase) at : %s\n",
3412b68e1f86Smrg			  actual_cwrapper_path));
3413b68e1f86Smrg  XFREE (tmp_pathspec);
3414b68e1f86Smrg
3415b68e1f86Smrg  actual_cwrapper_name = xstrdup( base_name (actual_cwrapper_path));
3416b68e1f86Smrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
3417b68e1f86Smrg
3418b68e1f86Smrg  /* wrapper name transforms */
3419b68e1f86Smrg  strendzap (actual_cwrapper_name, ".exe");
3420b68e1f86Smrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
3421b68e1f86Smrg  XFREE (actual_cwrapper_name);
3422b68e1f86Smrg  actual_cwrapper_name = tmp_pathspec;
3423b68e1f86Smrg  tmp_pathspec = 0;
3424b68e1f86Smrg
3425b68e1f86Smrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
3426b68e1f86Smrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
3427b68e1f86Smrg  strendzap (target_name, ".exe");
3428b68e1f86Smrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
3429b68e1f86Smrg  XFREE (target_name);
3430b68e1f86Smrg  target_name = tmp_pathspec;
3431b68e1f86Smrg  tmp_pathspec = 0;
3432b68e1f86Smrg
3433b68e1f86Smrg  LTWRAPPER_DEBUGPRINTF (("(main) libtool target name: %s\n",
3434b68e1f86Smrg			  target_name));
3435b68e1f86SmrgEOF
3436b68e1f86Smrg
3437b68e1f86Smrg	    cat <<EOF
3438b68e1f86Smrg  newargz[0] =
3439b68e1f86Smrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
3440b68e1f86Smrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
3441b68e1f86Smrg  strcpy (newargz[0], actual_cwrapper_path);
3442b68e1f86Smrg  strcat (newargz[0], "$objdir");
3443b68e1f86Smrg  strcat (newargz[0], "/");
3444b68e1f86SmrgEOF
3445b68e1f86Smrg
3446b68e1f86Smrg	    cat <<"EOF"
3447b68e1f86Smrg  /* stop here, and copy so we don't have to do this twice */
3448b68e1f86Smrg  tmp_pathspec = xstrdup (newargz[0]);
3449b68e1f86Smrg
3450b68e1f86Smrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
3451b68e1f86Smrg  strcat (newargz[0], actual_cwrapper_name);
3452b68e1f86Smrg
3453b68e1f86Smrg  /* DO want the lt- prefix here if it exists, so use target_name */
3454b68e1f86Smrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
3455b68e1f86Smrg  XFREE (tmp_pathspec);
3456b68e1f86Smrg  tmp_pathspec = NULL;
3457b68e1f86SmrgEOF
3458b68e1f86Smrg
3459b68e1f86Smrg	    case $host_os in
3460b68e1f86Smrg	      mingw*)
3461b68e1f86Smrg	    cat <<"EOF"
3462b68e1f86Smrg  {
3463b68e1f86Smrg    char* p;
3464b68e1f86Smrg    while ((p = strchr (newargz[0], '\\')) != NULL)
3465b68e1f86Smrg      {
3466b68e1f86Smrg	*p = '/';
3467b68e1f86Smrg      }
3468b68e1f86Smrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
3469b68e1f86Smrg      {
3470b68e1f86Smrg	*p = '/';
3471b68e1f86Smrg      }
3472b68e1f86Smrg  }
3473b68e1f86SmrgEOF
34746df26cacSmrg	    ;;
3475b68e1f86Smrg	    esac
3476b68e1f86Smrg
3477b68e1f86Smrg	    cat <<"EOF"
3478b68e1f86Smrg  XFREE (target_name);
3479b68e1f86Smrg  XFREE (actual_cwrapper_path);
3480b68e1f86Smrg  XFREE (actual_cwrapper_name);
3481b68e1f86Smrg
3482b68e1f86Smrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
3483b68e1f86Smrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
3484b68e1f86Smrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
3485b68e1f86Smrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
3486b68e1f86Smrg
3487b68e1f86Smrg  newargc=0;
3488b68e1f86Smrg  for (i = 1; i < argc; i++)
3489b68e1f86Smrg    {
3490b68e1f86Smrg      if (strncmp (argv[i], env_set_opt, env_set_opt_len) == 0)
3491b68e1f86Smrg        {
3492b68e1f86Smrg          if (argv[i][env_set_opt_len] == '=')
3493b68e1f86Smrg            {
3494b68e1f86Smrg              const char *p = argv[i] + env_set_opt_len + 1;
3495b68e1f86Smrg              lt_opt_process_env_set (p);
3496b68e1f86Smrg            }
3497b68e1f86Smrg          else if (argv[i][env_set_opt_len] == '\0' && i + 1 < argc)
3498b68e1f86Smrg            {
3499b68e1f86Smrg              lt_opt_process_env_set (argv[++i]); /* don't copy */
3500b68e1f86Smrg            }
3501b68e1f86Smrg          else
3502b68e1f86Smrg            lt_fatal ("%s missing required argument", env_set_opt);
3503b68e1f86Smrg          continue;
3504b68e1f86Smrg        }
3505b68e1f86Smrg      if (strncmp (argv[i], env_prepend_opt, env_prepend_opt_len) == 0)
3506b68e1f86Smrg        {
3507b68e1f86Smrg          if (argv[i][env_prepend_opt_len] == '=')
3508b68e1f86Smrg            {
3509b68e1f86Smrg              const char *p = argv[i] + env_prepend_opt_len + 1;
3510b68e1f86Smrg              lt_opt_process_env_prepend (p);
3511b68e1f86Smrg            }
3512b68e1f86Smrg          else if (argv[i][env_prepend_opt_len] == '\0' && i + 1 < argc)
3513b68e1f86Smrg            {
3514b68e1f86Smrg              lt_opt_process_env_prepend (argv[++i]); /* don't copy */
3515b68e1f86Smrg            }
3516b68e1f86Smrg          else
3517b68e1f86Smrg            lt_fatal ("%s missing required argument", env_prepend_opt);
3518b68e1f86Smrg          continue;
3519b68e1f86Smrg        }
3520b68e1f86Smrg      if (strncmp (argv[i], env_append_opt, env_append_opt_len) == 0)
3521b68e1f86Smrg        {
3522b68e1f86Smrg          if (argv[i][env_append_opt_len] == '=')
3523b68e1f86Smrg            {
3524b68e1f86Smrg              const char *p = argv[i] + env_append_opt_len + 1;
3525b68e1f86Smrg              lt_opt_process_env_append (p);
3526b68e1f86Smrg            }
3527b68e1f86Smrg          else if (argv[i][env_append_opt_len] == '\0' && i + 1 < argc)
3528b68e1f86Smrg            {
3529b68e1f86Smrg              lt_opt_process_env_append (argv[++i]); /* don't copy */
3530b68e1f86Smrg            }
3531b68e1f86Smrg          else
3532b68e1f86Smrg            lt_fatal ("%s missing required argument", env_append_opt);
3533b68e1f86Smrg          continue;
3534b68e1f86Smrg        }
3535b68e1f86Smrg      if (strncmp (argv[i], ltwrapper_option_prefix, opt_prefix_len) == 0)
3536b68e1f86Smrg        {
3537b68e1f86Smrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
3538b68e1f86Smrg             namespace, but it is not one of the ones we know about and
3539b68e1f86Smrg             have already dealt with, above (inluding dump-script), then
3540b68e1f86Smrg             report an error. Otherwise, targets might begin to believe
3541b68e1f86Smrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
3542b68e1f86Smrg             namespace. The first time any user complains about this, we'll
3543b68e1f86Smrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
3544b68e1f86Smrg             or a configure.ac-settable value.
3545b68e1f86Smrg           */
3546b68e1f86Smrg          lt_fatal ("Unrecognized option in %s namespace: '%s'",
3547b68e1f86Smrg                    ltwrapper_option_prefix, argv[i]);
3548b68e1f86Smrg        }
3549b68e1f86Smrg      /* otherwise ... */
3550b68e1f86Smrg      newargz[++newargc] = xstrdup (argv[i]);
3551b68e1f86Smrg    }
3552b68e1f86Smrg  newargz[++newargc] = NULL;
3553b68e1f86Smrg
3554b68e1f86Smrg  LTWRAPPER_DEBUGPRINTF     (("(main) lt_argv_zero : %s\n", (lt_argv_zero ? lt_argv_zero : "<NULL>")));
3555b68e1f86Smrg  for (i = 0; i < newargc; i++)
3556b68e1f86Smrg    {
3557b68e1f86Smrg      LTWRAPPER_DEBUGPRINTF (("(main) newargz[%d]   : %s\n", i, (newargz[i] ? newargz[i] : "<NULL>")));
3558b68e1f86Smrg    }
35596df26cacSmrg
35606df26cacSmrgEOF
35616df26cacSmrg
3562b68e1f86Smrg	    case $host_os in
3563b68e1f86Smrg	      mingw*)
3564b68e1f86Smrg		cat <<"EOF"
3565b68e1f86Smrg  /* execv doesn't actually work on mingw as expected on unix */
3566b68e1f86Smrg  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
3567b68e1f86Smrg  if (rval == -1)
3568b68e1f86Smrg    {
3569b68e1f86Smrg      /* failed to start process */
3570b68e1f86Smrg      LTWRAPPER_DEBUGPRINTF (("(main) failed to launch target \"%s\": errno = %d\n", lt_argv_zero, errno));
3571b68e1f86Smrg      return 127;
3572b68e1f86Smrg    }
3573b68e1f86Smrg  return rval;
3574b68e1f86SmrgEOF
3575b68e1f86Smrg		;;
3576b68e1f86Smrg	      *)
3577b68e1f86Smrg		cat <<"EOF"
3578b68e1f86Smrg  execv (lt_argv_zero, newargz);
3579b68e1f86Smrg  return rval; /* =127, but avoids unused variable warning */
3580b68e1f86SmrgEOF
3581b68e1f86Smrg		;;
3582b68e1f86Smrg	    esac
35836df26cacSmrg
3584b68e1f86Smrg	    cat <<"EOF"
3585b68e1f86Smrg}
35866df26cacSmrg
3587b68e1f86Smrgvoid *
3588b68e1f86Smrgxmalloc (size_t num)
3589b68e1f86Smrg{
3590b68e1f86Smrg  void *p = (void *) malloc (num);
3591b68e1f86Smrg  if (!p)
3592b68e1f86Smrg    lt_fatal ("Memory exhausted");
35936df26cacSmrg
3594b68e1f86Smrg  return p;
3595b68e1f86Smrg}
35966df26cacSmrg
3597b68e1f86Smrgchar *
3598b68e1f86Smrgxstrdup (const char *string)
3599b68e1f86Smrg{
3600b68e1f86Smrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
3601b68e1f86Smrg			  string) : NULL;
3602b68e1f86Smrg}
36036df26cacSmrg
3604b68e1f86Smrgconst char *
3605b68e1f86Smrgbase_name (const char *name)
3606b68e1f86Smrg{
3607b68e1f86Smrg  const char *base;
36086df26cacSmrg
3609b68e1f86Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3610b68e1f86Smrg  /* Skip over the disk name in MSDOS pathnames. */
3611b68e1f86Smrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
3612b68e1f86Smrg    name += 2;
3613b68e1f86Smrg#endif
36146df26cacSmrg
3615b68e1f86Smrg  for (base = name; *name; name++)
3616b68e1f86Smrg    if (IS_DIR_SEPARATOR (*name))
3617b68e1f86Smrg      base = name + 1;
3618b68e1f86Smrg  return base;
3619b68e1f86Smrg}
36206df26cacSmrg
3621b68e1f86Smrgint
3622b68e1f86Smrgcheck_executable (const char *path)
3623b68e1f86Smrg{
3624b68e1f86Smrg  struct stat st;
36256df26cacSmrg
3626b68e1f86Smrg  LTWRAPPER_DEBUGPRINTF (("(check_executable)  : %s\n",
3627b68e1f86Smrg			  path ? (*path ? path : "EMPTY!") : "NULL!"));
3628b68e1f86Smrg  if ((!path) || (!*path))
3629b68e1f86Smrg    return 0;
36306df26cacSmrg
3631b68e1f86Smrg  if ((stat (path, &st) >= 0)
3632b68e1f86Smrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
3633b68e1f86Smrg    return 1;
3634b68e1f86Smrg  else
3635b68e1f86Smrg    return 0;
3636b68e1f86Smrg}
36376df26cacSmrg
3638b68e1f86Smrgint
3639b68e1f86Smrgmake_executable (const char *path)
3640b68e1f86Smrg{
3641b68e1f86Smrg  int rval = 0;
3642b68e1f86Smrg  struct stat st;
36436df26cacSmrg
3644b68e1f86Smrg  LTWRAPPER_DEBUGPRINTF (("(make_executable)   : %s\n",
3645b68e1f86Smrg			  path ? (*path ? path : "EMPTY!") : "NULL!"));
3646b68e1f86Smrg  if ((!path) || (!*path))
3647b68e1f86Smrg    return 0;
36486df26cacSmrg
3649b68e1f86Smrg  if (stat (path, &st) >= 0)
3650b68e1f86Smrg    {
3651b68e1f86Smrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
3652b68e1f86Smrg    }
3653b68e1f86Smrg  return rval;
3654b68e1f86Smrg}
36556df26cacSmrg
3656b68e1f86Smrg/* Searches for the full path of the wrapper.  Returns
3657b68e1f86Smrg   newly allocated full path name if found, NULL otherwise
3658b68e1f86Smrg   Does not chase symlinks, even on platforms that support them.
3659b68e1f86Smrg*/
3660b68e1f86Smrgchar *
3661b68e1f86Smrgfind_executable (const char *wrapper)
3662b68e1f86Smrg{
3663b68e1f86Smrg  int has_slash = 0;
3664b68e1f86Smrg  const char *p;
3665b68e1f86Smrg  const char *p_next;
3666b68e1f86Smrg  /* static buffer for getcwd */
3667b68e1f86Smrg  char tmp[LT_PATHMAX + 1];
3668b68e1f86Smrg  int tmp_len;
3669b68e1f86Smrg  char *concat_name;
36706df26cacSmrg
3671b68e1f86Smrg  LTWRAPPER_DEBUGPRINTF (("(find_executable)   : %s\n",
3672b68e1f86Smrg			  wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!"));
36736df26cacSmrg
3674b68e1f86Smrg  if ((wrapper == NULL) || (*wrapper == '\0'))
3675b68e1f86Smrg    return NULL;
36766df26cacSmrg
3677b68e1f86Smrg  /* Absolute path? */
3678b68e1f86Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3679b68e1f86Smrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
3680b68e1f86Smrg    {
3681b68e1f86Smrg      concat_name = xstrdup (wrapper);
3682b68e1f86Smrg      if (check_executable (concat_name))
3683b68e1f86Smrg	return concat_name;
3684b68e1f86Smrg      XFREE (concat_name);
3685b68e1f86Smrg    }
3686b68e1f86Smrg  else
3687b68e1f86Smrg    {
3688b68e1f86Smrg#endif
3689b68e1f86Smrg      if (IS_DIR_SEPARATOR (wrapper[0]))
3690b68e1f86Smrg	{
3691b68e1f86Smrg	  concat_name = xstrdup (wrapper);
3692b68e1f86Smrg	  if (check_executable (concat_name))
3693b68e1f86Smrg	    return concat_name;
3694b68e1f86Smrg	  XFREE (concat_name);
3695b68e1f86Smrg	}
3696b68e1f86Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3697b68e1f86Smrg    }
3698b68e1f86Smrg#endif
36996df26cacSmrg
3700b68e1f86Smrg  for (p = wrapper; *p; p++)
3701b68e1f86Smrg    if (*p == '/')
3702b68e1f86Smrg      {
3703b68e1f86Smrg	has_slash = 1;
3704b68e1f86Smrg	break;
3705b68e1f86Smrg      }
3706b68e1f86Smrg  if (!has_slash)
3707b68e1f86Smrg    {
3708b68e1f86Smrg      /* no slashes; search PATH */
3709b68e1f86Smrg      const char *path = getenv ("PATH");
3710b68e1f86Smrg      if (path != NULL)
3711b68e1f86Smrg	{
3712b68e1f86Smrg	  for (p = path; *p; p = p_next)
3713b68e1f86Smrg	    {
3714b68e1f86Smrg	      const char *q;
3715b68e1f86Smrg	      size_t p_len;
3716b68e1f86Smrg	      for (q = p; *q; q++)
3717b68e1f86Smrg		if (IS_PATH_SEPARATOR (*q))
3718b68e1f86Smrg		  break;
3719b68e1f86Smrg	      p_len = q - p;
3720b68e1f86Smrg	      p_next = (*q == '\0' ? q : q + 1);
3721b68e1f86Smrg	      if (p_len == 0)
3722b68e1f86Smrg		{
3723b68e1f86Smrg		  /* empty path: current directory */
3724b68e1f86Smrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
3725b68e1f86Smrg		    lt_fatal ("getcwd failed");
3726b68e1f86Smrg		  tmp_len = strlen (tmp);
3727b68e1f86Smrg		  concat_name =
3728b68e1f86Smrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
3729b68e1f86Smrg		  memcpy (concat_name, tmp, tmp_len);
3730b68e1f86Smrg		  concat_name[tmp_len] = '/';
3731b68e1f86Smrg		  strcpy (concat_name + tmp_len + 1, wrapper);
3732b68e1f86Smrg		}
3733b68e1f86Smrg	      else
3734b68e1f86Smrg		{
3735b68e1f86Smrg		  concat_name =
3736b68e1f86Smrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
3737b68e1f86Smrg		  memcpy (concat_name, p, p_len);
3738b68e1f86Smrg		  concat_name[p_len] = '/';
3739b68e1f86Smrg		  strcpy (concat_name + p_len + 1, wrapper);
3740b68e1f86Smrg		}
3741b68e1f86Smrg	      if (check_executable (concat_name))
3742b68e1f86Smrg		return concat_name;
3743b68e1f86Smrg	      XFREE (concat_name);
3744b68e1f86Smrg	    }
3745b68e1f86Smrg	}
3746b68e1f86Smrg      /* not found in PATH; assume curdir */
3747b68e1f86Smrg    }
3748b68e1f86Smrg  /* Relative path | not found in path: prepend cwd */
3749b68e1f86Smrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
3750b68e1f86Smrg    lt_fatal ("getcwd failed");
3751b68e1f86Smrg  tmp_len = strlen (tmp);
3752b68e1f86Smrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
3753b68e1f86Smrg  memcpy (concat_name, tmp, tmp_len);
3754b68e1f86Smrg  concat_name[tmp_len] = '/';
3755b68e1f86Smrg  strcpy (concat_name + tmp_len + 1, wrapper);
37566df26cacSmrg
3757b68e1f86Smrg  if (check_executable (concat_name))
3758b68e1f86Smrg    return concat_name;
3759b68e1f86Smrg  XFREE (concat_name);
3760b68e1f86Smrg  return NULL;
3761b68e1f86Smrg}
37626df26cacSmrg
3763b68e1f86Smrgchar *
3764b68e1f86Smrgchase_symlinks (const char *pathspec)
3765b68e1f86Smrg{
3766b68e1f86Smrg#ifndef S_ISLNK
3767b68e1f86Smrg  return xstrdup (pathspec);
3768b68e1f86Smrg#else
3769b68e1f86Smrg  char buf[LT_PATHMAX];
3770b68e1f86Smrg  struct stat s;
3771b68e1f86Smrg  char *tmp_pathspec = xstrdup (pathspec);
3772b68e1f86Smrg  char *p;
3773b68e1f86Smrg  int has_symlinks = 0;
3774b68e1f86Smrg  while (strlen (tmp_pathspec) && !has_symlinks)
3775b68e1f86Smrg    {
3776b68e1f86Smrg      LTWRAPPER_DEBUGPRINTF (("checking path component for symlinks: %s\n",
3777b68e1f86Smrg			      tmp_pathspec));
3778b68e1f86Smrg      if (lstat (tmp_pathspec, &s) == 0)
3779b68e1f86Smrg	{
3780b68e1f86Smrg	  if (S_ISLNK (s.st_mode) != 0)
3781b68e1f86Smrg	    {
3782b68e1f86Smrg	      has_symlinks = 1;
3783b68e1f86Smrg	      break;
3784b68e1f86Smrg	    }
37856df26cacSmrg
3786b68e1f86Smrg	  /* search backwards for last DIR_SEPARATOR */
3787b68e1f86Smrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
3788b68e1f86Smrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
3789b68e1f86Smrg	    p--;
3790b68e1f86Smrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
3791b68e1f86Smrg	    {
3792b68e1f86Smrg	      /* no more DIR_SEPARATORS left */
3793b68e1f86Smrg	      break;
3794b68e1f86Smrg	    }
3795b68e1f86Smrg	  *p = '\0';
3796b68e1f86Smrg	}
3797b68e1f86Smrg      else
3798b68e1f86Smrg	{
3799b68e1f86Smrg	  char *errstr = strerror (errno);
3800b68e1f86Smrg	  lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr);
3801b68e1f86Smrg	}
3802b68e1f86Smrg    }
3803b68e1f86Smrg  XFREE (tmp_pathspec);
38046df26cacSmrg
3805b68e1f86Smrg  if (!has_symlinks)
3806b68e1f86Smrg    {
3807b68e1f86Smrg      return xstrdup (pathspec);
3808b68e1f86Smrg    }
38096df26cacSmrg
3810b68e1f86Smrg  tmp_pathspec = realpath (pathspec, buf);
3811b68e1f86Smrg  if (tmp_pathspec == 0)
3812b68e1f86Smrg    {
3813b68e1f86Smrg      lt_fatal ("Could not follow symlinks for %s", pathspec);
3814b68e1f86Smrg    }
3815b68e1f86Smrg  return xstrdup (tmp_pathspec);
3816b68e1f86Smrg#endif
3817b68e1f86Smrg}
38186df26cacSmrg
3819b68e1f86Smrgchar *
3820b68e1f86Smrgstrendzap (char *str, const char *pat)
3821b68e1f86Smrg{
3822b68e1f86Smrg  size_t len, patlen;
38236df26cacSmrg
3824b68e1f86Smrg  assert (str != NULL);
3825b68e1f86Smrg  assert (pat != NULL);
38266df26cacSmrg
3827b68e1f86Smrg  len = strlen (str);
3828b68e1f86Smrg  patlen = strlen (pat);
38296df26cacSmrg
3830b68e1f86Smrg  if (patlen <= len)
3831b68e1f86Smrg    {
3832b68e1f86Smrg      str += len - patlen;
3833b68e1f86Smrg      if (strcmp (str, pat) == 0)
3834b68e1f86Smrg	*str = '\0';
3835b68e1f86Smrg    }
3836b68e1f86Smrg  return str;
3837b68e1f86Smrg}
38386df26cacSmrg
3839b68e1f86Smrgstatic void
3840b68e1f86Smrglt_error_core (int exit_status, const char *mode,
3841b68e1f86Smrg	       const char *message, va_list ap)
3842b68e1f86Smrg{
3843b68e1f86Smrg  fprintf (stderr, "%s: %s: ", program_name, mode);
3844b68e1f86Smrg  vfprintf (stderr, message, ap);
3845b68e1f86Smrg  fprintf (stderr, ".\n");
38466df26cacSmrg
3847b68e1f86Smrg  if (exit_status >= 0)
3848b68e1f86Smrg    exit (exit_status);
3849b68e1f86Smrg}
38506df26cacSmrg
3851b68e1f86Smrgvoid
3852b68e1f86Smrglt_fatal (const char *message, ...)
3853b68e1f86Smrg{
3854b68e1f86Smrg  va_list ap;
3855b68e1f86Smrg  va_start (ap, message);
3856b68e1f86Smrg  lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
3857b68e1f86Smrg  va_end (ap);
3858b68e1f86Smrg}
38596df26cacSmrg
3860b68e1f86Smrgvoid
3861b68e1f86Smrglt_setenv (const char *name, const char *value)
3862b68e1f86Smrg{
3863b68e1f86Smrg  LTWRAPPER_DEBUGPRINTF (("(lt_setenv) setting '%s' to '%s'\n",
3864b68e1f86Smrg                          (name ? name : "<NULL>"),
3865b68e1f86Smrg                          (value ? value : "<NULL>")));
3866b68e1f86Smrg  {
3867b68e1f86Smrg#ifdef HAVE_SETENV
3868b68e1f86Smrg    /* always make a copy, for consistency with !HAVE_SETENV */
3869b68e1f86Smrg    char *str = xstrdup (value);
3870b68e1f86Smrg    setenv (name, str, 1);
3871b68e1f86Smrg#else
3872b68e1f86Smrg    int len = strlen (name) + 1 + strlen (value) + 1;
3873b68e1f86Smrg    char *str = XMALLOC (char, len);
3874b68e1f86Smrg    sprintf (str, "%s=%s", name, value);
3875b68e1f86Smrg    if (putenv (str) != EXIT_SUCCESS)
3876b68e1f86Smrg      {
3877b68e1f86Smrg        XFREE (str);
3878b68e1f86Smrg      }
3879b68e1f86Smrg#endif
3880b68e1f86Smrg  }
3881b68e1f86Smrg}
38826df26cacSmrg
3883b68e1f86Smrgchar *
3884b68e1f86Smrglt_extend_str (const char *orig_value, const char *add, int to_end)
3885b68e1f86Smrg{
3886b68e1f86Smrg  char *new_value;
3887b68e1f86Smrg  if (orig_value && *orig_value)
3888b68e1f86Smrg    {
3889b68e1f86Smrg      int orig_value_len = strlen (orig_value);
3890b68e1f86Smrg      int add_len = strlen (add);
3891b68e1f86Smrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
3892b68e1f86Smrg      if (to_end)
3893b68e1f86Smrg        {
3894b68e1f86Smrg          strcpy (new_value, orig_value);
3895b68e1f86Smrg          strcpy (new_value + orig_value_len, add);
3896b68e1f86Smrg        }
3897b68e1f86Smrg      else
3898b68e1f86Smrg        {
3899b68e1f86Smrg          strcpy (new_value, add);
3900b68e1f86Smrg          strcpy (new_value + add_len, orig_value);
3901b68e1f86Smrg        }
3902b68e1f86Smrg    }
3903b68e1f86Smrg  else
3904b68e1f86Smrg    {
3905b68e1f86Smrg      new_value = xstrdup (add);
3906b68e1f86Smrg    }
3907b68e1f86Smrg  return new_value;
3908b68e1f86Smrg}
39096df26cacSmrg
3910b68e1f86Smrgint
3911b68e1f86Smrglt_split_name_value (const char *arg, char** name, char** value)
3912b68e1f86Smrg{
3913b68e1f86Smrg  const char *p;
3914b68e1f86Smrg  int len;
3915b68e1f86Smrg  if (!arg || !*arg)
3916b68e1f86Smrg    return 1;
39176df26cacSmrg
3918b68e1f86Smrg  p = strchr (arg, (int)'=');
39196df26cacSmrg
3920b68e1f86Smrg  if (!p)
3921b68e1f86Smrg    return 1;
39226df26cacSmrg
3923b68e1f86Smrg  *value = xstrdup (++p);
39246df26cacSmrg
3925b68e1f86Smrg  len = strlen (arg) - strlen (*value);
3926b68e1f86Smrg  *name = XMALLOC (char, len);
3927b68e1f86Smrg  strncpy (*name, arg, len-1);
3928b68e1f86Smrg  (*name)[len - 1] = '\0';
39296df26cacSmrg
3930b68e1f86Smrg  return 0;
3931b68e1f86Smrg}
39326df26cacSmrg
3933b68e1f86Smrgvoid
3934b68e1f86Smrglt_opt_process_env_set (const char *arg)
3935b68e1f86Smrg{
3936b68e1f86Smrg  char *name = NULL;
3937b68e1f86Smrg  char *value = NULL;
39386df26cacSmrg
3939b68e1f86Smrg  if (lt_split_name_value (arg, &name, &value) != 0)
3940b68e1f86Smrg    {
3941b68e1f86Smrg      XFREE (name);
3942b68e1f86Smrg      XFREE (value);
3943b68e1f86Smrg      lt_fatal ("bad argument for %s: '%s'", env_set_opt, arg);
3944b68e1f86Smrg    }
39456df26cacSmrg
3946b68e1f86Smrg  lt_setenv (name, value);
3947b68e1f86Smrg  XFREE (name);
3948b68e1f86Smrg  XFREE (value);
3949b68e1f86Smrg}
39506df26cacSmrg
3951b68e1f86Smrgvoid
3952b68e1f86Smrglt_opt_process_env_prepend (const char *arg)
3953b68e1f86Smrg{
3954b68e1f86Smrg  char *name = NULL;
3955b68e1f86Smrg  char *value = NULL;
3956b68e1f86Smrg  char *new_value = NULL;
39576df26cacSmrg
3958b68e1f86Smrg  if (lt_split_name_value (arg, &name, &value) != 0)
3959b68e1f86Smrg    {
3960b68e1f86Smrg      XFREE (name);
3961b68e1f86Smrg      XFREE (value);
3962b68e1f86Smrg      lt_fatal ("bad argument for %s: '%s'", env_prepend_opt, arg);
3963b68e1f86Smrg    }
39646df26cacSmrg
3965b68e1f86Smrg  new_value = lt_extend_str (getenv (name), value, 0);
3966b68e1f86Smrg  lt_setenv (name, new_value);
3967b68e1f86Smrg  XFREE (new_value);
3968b68e1f86Smrg  XFREE (name);
3969b68e1f86Smrg  XFREE (value);
3970b68e1f86Smrg}
39716df26cacSmrg
3972b68e1f86Smrgvoid
3973b68e1f86Smrglt_opt_process_env_append (const char *arg)
3974b68e1f86Smrg{
3975b68e1f86Smrg  char *name = NULL;
3976b68e1f86Smrg  char *value = NULL;
3977b68e1f86Smrg  char *new_value = NULL;
39786df26cacSmrg
3979b68e1f86Smrg  if (lt_split_name_value (arg, &name, &value) != 0)
3980b68e1f86Smrg    {
3981b68e1f86Smrg      XFREE (name);
3982b68e1f86Smrg      XFREE (value);
3983b68e1f86Smrg      lt_fatal ("bad argument for %s: '%s'", env_append_opt, arg);
3984b68e1f86Smrg    }
39856df26cacSmrg
3986b68e1f86Smrg  new_value = lt_extend_str (getenv (name), value, 1);
3987b68e1f86Smrg  lt_setenv (name, new_value);
3988b68e1f86Smrg  XFREE (new_value);
3989b68e1f86Smrg  XFREE (name);
3990b68e1f86Smrg  XFREE (value);
3991b68e1f86Smrg}
39926df26cacSmrg
3993b68e1f86Smrgvoid
3994b68e1f86Smrglt_update_exe_path (const char *name, const char *value)
3995b68e1f86Smrg{
3996b68e1f86Smrg  LTWRAPPER_DEBUGPRINTF (("(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
3997b68e1f86Smrg                          (name ? name : "<NULL>"),
3998b68e1f86Smrg                          (value ? value : "<NULL>")));
39996df26cacSmrg
4000b68e1f86Smrg  if (name && *name && value && *value)
4001b68e1f86Smrg    {
4002b68e1f86Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
4003b68e1f86Smrg      /* some systems can't cope with a ':'-terminated path #' */
4004b68e1f86Smrg      int len = strlen (new_value);
4005b68e1f86Smrg      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
4006b68e1f86Smrg        {
4007b68e1f86Smrg          new_value[len-1] = '\0';
4008b68e1f86Smrg        }
4009b68e1f86Smrg      lt_setenv (name, new_value);
4010b68e1f86Smrg      XFREE (new_value);
4011b68e1f86Smrg    }
4012b68e1f86Smrg}
40136df26cacSmrg
4014b68e1f86Smrgvoid
4015b68e1f86Smrglt_update_lib_path (const char *name, const char *value)
4016b68e1f86Smrg{
4017b68e1f86Smrg  LTWRAPPER_DEBUGPRINTF (("(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
4018b68e1f86Smrg                          (name ? name : "<NULL>"),
4019b68e1f86Smrg                          (value ? value : "<NULL>")));
40206df26cacSmrg
4021b68e1f86Smrg  if (name && *name && value && *value)
4022b68e1f86Smrg    {
4023b68e1f86Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
4024b68e1f86Smrg      lt_setenv (name, new_value);
4025b68e1f86Smrg      XFREE (new_value);
4026b68e1f86Smrg    }
4027b68e1f86Smrg}
40286df26cacSmrg
40296df26cacSmrg
4030b68e1f86SmrgEOF
4031b68e1f86Smrg}
4032b68e1f86Smrg# end: func_emit_cwrapperexe_src
40336df26cacSmrg
4034b68e1f86Smrg# func_mode_link arg...
4035b68e1f86Smrgfunc_mode_link ()
4036b68e1f86Smrg{
4037b68e1f86Smrg    $opt_debug
4038b68e1f86Smrg    case $host in
4039b68e1f86Smrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
4040b68e1f86Smrg      # It is impossible to link a dll without this setting, and
4041b68e1f86Smrg      # we shouldn't force the makefile maintainer to figure out
4042b68e1f86Smrg      # which system we are compiling for in order to pass an extra
4043b68e1f86Smrg      # flag for every libtool invocation.
4044b68e1f86Smrg      # allow_undefined=no
40456df26cacSmrg
4046b68e1f86Smrg      # FIXME: Unfortunately, there are problems with the above when trying
4047b68e1f86Smrg      # to make a dll which has undefined symbols, in which case not
4048b68e1f86Smrg      # even a static library is built.  For now, we need to specify
4049b68e1f86Smrg      # -no-undefined on the libtool link line when we can be certain
4050b68e1f86Smrg      # that all symbols are satisfied, otherwise we get a static library.
4051b68e1f86Smrg      allow_undefined=yes
40526df26cacSmrg      ;;
4053b68e1f86Smrg    *)
4054b68e1f86Smrg      allow_undefined=yes
4055b68e1f86Smrg      ;;
4056b68e1f86Smrg    esac
4057b68e1f86Smrg    libtool_args=$nonopt
4058b68e1f86Smrg    base_compile="$nonopt $@"
4059b68e1f86Smrg    compile_command=$nonopt
4060b68e1f86Smrg    finalize_command=$nonopt
40616df26cacSmrg
4062b68e1f86Smrg    compile_rpath=
4063b68e1f86Smrg    finalize_rpath=
4064b68e1f86Smrg    compile_shlibpath=
4065b68e1f86Smrg    finalize_shlibpath=
4066b68e1f86Smrg    convenience=
4067b68e1f86Smrg    old_convenience=
4068b68e1f86Smrg    deplibs=
4069b68e1f86Smrg    old_deplibs=
4070b68e1f86Smrg    compiler_flags=
4071b68e1f86Smrg    linker_flags=
4072b68e1f86Smrg    dllsearchpath=
4073b68e1f86Smrg    lib_search_path=`pwd`
4074b68e1f86Smrg    inst_prefix_dir=
4075b68e1f86Smrg    new_inherited_linker_flags=
40766df26cacSmrg
4077b68e1f86Smrg    avoid_version=no
4078b68e1f86Smrg    dlfiles=
4079b68e1f86Smrg    dlprefiles=
4080b68e1f86Smrg    dlself=no
4081b68e1f86Smrg    export_dynamic=no
4082b68e1f86Smrg    export_symbols=
4083b68e1f86Smrg    export_symbols_regex=
4084b68e1f86Smrg    generated=
4085b68e1f86Smrg    libobjs=
4086b68e1f86Smrg    ltlibs=
4087b68e1f86Smrg    module=no
4088b68e1f86Smrg    no_install=no
4089b68e1f86Smrg    objs=
4090b68e1f86Smrg    non_pic_objects=
4091b68e1f86Smrg    precious_files_regex=
4092b68e1f86Smrg    prefer_static_libs=no
4093b68e1f86Smrg    preload=no
4094b68e1f86Smrg    prev=
4095b68e1f86Smrg    prevarg=
4096b68e1f86Smrg    release=
4097b68e1f86Smrg    rpath=
4098b68e1f86Smrg    xrpath=
4099b68e1f86Smrg    perm_rpath=
4100b68e1f86Smrg    temp_rpath=
4101b68e1f86Smrg    thread_safe=no
4102b68e1f86Smrg    vinfo=
4103b68e1f86Smrg    vinfo_number=no
4104b68e1f86Smrg    weak_libs=
4105b68e1f86Smrg    single_module="${wl}-single_module"
4106b68e1f86Smrg    func_infer_tag $base_compile
41076df26cacSmrg
4108b68e1f86Smrg    # We need to know -static, to get the right output filenames.
4109b68e1f86Smrg    for arg
4110b68e1f86Smrg    do
4111b68e1f86Smrg      case $arg in
4112b68e1f86Smrg      -shared)
4113b68e1f86Smrg	test "$build_libtool_libs" != yes && \
4114b68e1f86Smrg	  func_fatal_configuration "can not build a shared library"
4115b68e1f86Smrg	build_old_libs=no
4116b68e1f86Smrg	break
4117b68e1f86Smrg	;;
4118b68e1f86Smrg      -all-static | -static | -static-libtool-libs)
4119b68e1f86Smrg	case $arg in
4120b68e1f86Smrg	-all-static)
4121b68e1f86Smrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
4122b68e1f86Smrg	    func_warning "complete static linking is impossible in this configuration"
4123b68e1f86Smrg	  fi
4124b68e1f86Smrg	  if test -n "$link_static_flag"; then
4125b68e1f86Smrg	    dlopen_self=$dlopen_self_static
4126b68e1f86Smrg	  fi
4127b68e1f86Smrg	  prefer_static_libs=yes
4128b68e1f86Smrg	  ;;
4129b68e1f86Smrg	-static)
4130b68e1f86Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
4131b68e1f86Smrg	    dlopen_self=$dlopen_self_static
4132b68e1f86Smrg	  fi
4133b68e1f86Smrg	  prefer_static_libs=built
4134b68e1f86Smrg	  ;;
4135b68e1f86Smrg	-static-libtool-libs)
4136b68e1f86Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
4137b68e1f86Smrg	    dlopen_self=$dlopen_self_static
4138b68e1f86Smrg	  fi
4139b68e1f86Smrg	  prefer_static_libs=yes
4140b68e1f86Smrg	  ;;
4141b68e1f86Smrg	esac
4142b68e1f86Smrg	build_libtool_libs=no
4143b68e1f86Smrg	build_old_libs=yes
4144b68e1f86Smrg	break
41456df26cacSmrg	;;
41466df26cacSmrg      esac
4147b68e1f86Smrg    done
41486df26cacSmrg
4149b68e1f86Smrg    # See if our shared archives depend on static archives.
4150b68e1f86Smrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
41516df26cacSmrg
4152b68e1f86Smrg    # Go through the arguments, transforming them on the way.
4153b68e1f86Smrg    while test "$#" -gt 0; do
4154b68e1f86Smrg      arg="$1"
4155b68e1f86Smrg      shift
4156b68e1f86Smrg      func_quote_for_eval "$arg"
4157b68e1f86Smrg      qarg=$func_quote_for_eval_unquoted_result
4158b68e1f86Smrg      func_append libtool_args " $func_quote_for_eval_result"
41596df26cacSmrg
4160b68e1f86Smrg      # If the previous option needs an argument, assign it.
4161b68e1f86Smrg      if test -n "$prev"; then
4162b68e1f86Smrg	case $prev in
4163b68e1f86Smrg	output)
4164b68e1f86Smrg	  func_append compile_command " @OUTPUT@"
4165b68e1f86Smrg	  func_append finalize_command " @OUTPUT@"
41666df26cacSmrg	  ;;
41676df26cacSmrg	esac
41686df26cacSmrg
4169b68e1f86Smrg	case $prev in
4170b68e1f86Smrg	dlfiles|dlprefiles)
4171b68e1f86Smrg	  if test "$preload" = no; then
4172b68e1f86Smrg	    # Add the symbol object into the linking commands.
4173b68e1f86Smrg	    func_append compile_command " @SYMFILE@"
4174b68e1f86Smrg	    func_append finalize_command " @SYMFILE@"
4175b68e1f86Smrg	    preload=yes
4176b68e1f86Smrg	  fi
4177b68e1f86Smrg	  case $arg in
4178b68e1f86Smrg	  *.la | *.lo) ;;  # We handle these cases below.
4179b68e1f86Smrg	  force)
4180b68e1f86Smrg	    if test "$dlself" = no; then
4181b68e1f86Smrg	      dlself=needless
4182b68e1f86Smrg	      export_dynamic=yes
4183b68e1f86Smrg	    fi
4184b68e1f86Smrg	    prev=
4185b68e1f86Smrg	    continue
4186b68e1f86Smrg	    ;;
4187b68e1f86Smrg	  self)
4188b68e1f86Smrg	    if test "$prev" = dlprefiles; then
4189b68e1f86Smrg	      dlself=yes
4190b68e1f86Smrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
4191b68e1f86Smrg	      dlself=yes
41926df26cacSmrg	    else
4193b68e1f86Smrg	      dlself=needless
4194b68e1f86Smrg	      export_dynamic=yes
41956df26cacSmrg	    fi
4196b68e1f86Smrg	    prev=
4197b68e1f86Smrg	    continue
4198b68e1f86Smrg	    ;;
4199b68e1f86Smrg	  *)
4200b68e1f86Smrg	    if test "$prev" = dlfiles; then
4201b68e1f86Smrg	      dlfiles="$dlfiles $arg"
4202b68e1f86Smrg	    else
4203b68e1f86Smrg	      dlprefiles="$dlprefiles $arg"
4204b68e1f86Smrg	    fi
4205b68e1f86Smrg	    prev=
4206b68e1f86Smrg	    continue
4207b68e1f86Smrg	    ;;
42086df26cacSmrg	  esac
42096df26cacSmrg	  ;;
4210b68e1f86Smrg	expsyms)
4211b68e1f86Smrg	  export_symbols="$arg"
4212b68e1f86Smrg	  test -f "$arg" \
4213b68e1f86Smrg	    || func_fatal_error "symbol file \`$arg' does not exist"
4214b68e1f86Smrg	  prev=
4215b68e1f86Smrg	  continue
4216b68e1f86Smrg	  ;;
4217b68e1f86Smrg	expsyms_regex)
4218b68e1f86Smrg	  export_symbols_regex="$arg"
4219b68e1f86Smrg	  prev=
4220b68e1f86Smrg	  continue
4221b68e1f86Smrg	  ;;
4222b68e1f86Smrg	framework)
4223b68e1f86Smrg	  case $host in
4224b68e1f86Smrg	    *-*-darwin*)
4225b68e1f86Smrg	      case "$deplibs " in
4226b68e1f86Smrg		*" $qarg.ltframework "*) ;;
4227b68e1f86Smrg		*) deplibs="$deplibs $qarg.ltframework" # this is fixed later
4228b68e1f86Smrg		   ;;
42296df26cacSmrg	      esac
4230b68e1f86Smrg	      ;;
42316df26cacSmrg	  esac
4232b68e1f86Smrg	  prev=
4233b68e1f86Smrg	  continue
4234b68e1f86Smrg	  ;;
4235b68e1f86Smrg	inst_prefix)
4236b68e1f86Smrg	  inst_prefix_dir="$arg"
4237b68e1f86Smrg	  prev=
4238b68e1f86Smrg	  continue
4239b68e1f86Smrg	  ;;
4240b68e1f86Smrg	objectlist)
4241b68e1f86Smrg	  if test -f "$arg"; then
4242b68e1f86Smrg	    save_arg=$arg
4243b68e1f86Smrg	    moreargs=
4244b68e1f86Smrg	    for fil in `cat "$save_arg"`
4245b68e1f86Smrg	    do
4246b68e1f86Smrg#	      moreargs="$moreargs $fil"
4247b68e1f86Smrg	      arg=$fil
4248b68e1f86Smrg	      # A libtool-controlled object.
42496df26cacSmrg
4250b68e1f86Smrg	      # Check to see that this really is a libtool object.
4251b68e1f86Smrg	      if func_lalib_unsafe_p "$arg"; then
4252b68e1f86Smrg		pic_object=
4253b68e1f86Smrg		non_pic_object=
42546df26cacSmrg
4255b68e1f86Smrg		# Read the .lo file
4256b68e1f86Smrg		func_source "$arg"
42576df26cacSmrg
4258b68e1f86Smrg		if test -z "$pic_object" ||
4259b68e1f86Smrg		   test -z "$non_pic_object" ||
4260b68e1f86Smrg		   test "$pic_object" = none &&
4261b68e1f86Smrg		   test "$non_pic_object" = none; then
4262b68e1f86Smrg		  func_fatal_error "cannot find name of object for \`$arg'"
4263b68e1f86Smrg		fi
42646df26cacSmrg
4265b68e1f86Smrg		# Extract subdirectory from the argument.
4266b68e1f86Smrg		func_dirname "$arg" "/" ""
4267b68e1f86Smrg		xdir="$func_dirname_result"
42686df26cacSmrg
4269b68e1f86Smrg		if test "$pic_object" != none; then
4270b68e1f86Smrg		  # Prepend the subdirectory the object is found in.
4271b68e1f86Smrg		  pic_object="$xdir$pic_object"
42726df26cacSmrg
4273b68e1f86Smrg		  if test "$prev" = dlfiles; then
4274b68e1f86Smrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
4275b68e1f86Smrg		      dlfiles="$dlfiles $pic_object"
4276b68e1f86Smrg		      prev=
4277b68e1f86Smrg		      continue
4278b68e1f86Smrg		    else
4279b68e1f86Smrg		      # If libtool objects are unsupported, then we need to preload.
4280b68e1f86Smrg		      prev=dlprefiles
4281b68e1f86Smrg		    fi
4282b68e1f86Smrg		  fi
42836df26cacSmrg
4284b68e1f86Smrg		  # CHECK ME:  I think I busted this.  -Ossama
4285b68e1f86Smrg		  if test "$prev" = dlprefiles; then
4286b68e1f86Smrg		    # Preload the old-style object.
4287b68e1f86Smrg		    dlprefiles="$dlprefiles $pic_object"
4288b68e1f86Smrg		    prev=
4289b68e1f86Smrg		  fi
42906df26cacSmrg
4291b68e1f86Smrg		  # A PIC object.
4292b68e1f86Smrg		  func_append libobjs " $pic_object"
4293b68e1f86Smrg		  arg="$pic_object"
4294b68e1f86Smrg		fi
42956df26cacSmrg
4296b68e1f86Smrg		# Non-PIC object.
4297b68e1f86Smrg		if test "$non_pic_object" != none; then
4298b68e1f86Smrg		  # Prepend the subdirectory the object is found in.
4299b68e1f86Smrg		  non_pic_object="$xdir$non_pic_object"
43006df26cacSmrg
4301b68e1f86Smrg		  # A standard non-PIC object
4302b68e1f86Smrg		  func_append non_pic_objects " $non_pic_object"
4303b68e1f86Smrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
4304b68e1f86Smrg		    arg="$non_pic_object"
4305b68e1f86Smrg		  fi
4306b68e1f86Smrg		else
4307b68e1f86Smrg		  # If the PIC object exists, use it instead.
4308b68e1f86Smrg		  # $xdir was prepended to $pic_object above.
4309b68e1f86Smrg		  non_pic_object="$pic_object"
4310b68e1f86Smrg		  func_append non_pic_objects " $non_pic_object"
4311b68e1f86Smrg		fi
4312b68e1f86Smrg	      else
4313b68e1f86Smrg		# Only an error if not doing a dry-run.
4314b68e1f86Smrg		if $opt_dry_run; then
4315b68e1f86Smrg		  # Extract subdirectory from the argument.
4316b68e1f86Smrg		  func_dirname "$arg" "/" ""
4317b68e1f86Smrg		  xdir="$func_dirname_result"
4318b68e1f86Smrg
4319b68e1f86Smrg		  func_lo2o "$arg"
4320b68e1f86Smrg		  pic_object=$xdir$objdir/$func_lo2o_result
4321b68e1f86Smrg		  non_pic_object=$xdir$func_lo2o_result
4322b68e1f86Smrg		  func_append libobjs " $pic_object"
4323b68e1f86Smrg		  func_append non_pic_objects " $non_pic_object"
4324b68e1f86Smrg	        else
4325b68e1f86Smrg		  func_fatal_error "\`$arg' is not a valid libtool object"
4326b68e1f86Smrg		fi
4327b68e1f86Smrg	      fi
43286df26cacSmrg	    done
4329b68e1f86Smrg	  else
4330b68e1f86Smrg	    func_fatal_error "link input file \`$arg' does not exist"
43316df26cacSmrg	  fi
4332b68e1f86Smrg	  arg=$save_arg
4333b68e1f86Smrg	  prev=
4334b68e1f86Smrg	  continue
4335b68e1f86Smrg	  ;;
4336b68e1f86Smrg	precious_regex)
4337b68e1f86Smrg	  precious_files_regex="$arg"
4338b68e1f86Smrg	  prev=
4339b68e1f86Smrg	  continue
4340b68e1f86Smrg	  ;;
4341b68e1f86Smrg	release)
4342b68e1f86Smrg	  release="-$arg"
4343b68e1f86Smrg	  prev=
4344b68e1f86Smrg	  continue
4345b68e1f86Smrg	  ;;
4346b68e1f86Smrg	rpath | xrpath)
4347b68e1f86Smrg	  # We need an absolute path.
4348b68e1f86Smrg	  case $arg in
4349b68e1f86Smrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
4350b68e1f86Smrg	  *)
4351b68e1f86Smrg	    func_fatal_error "only absolute run-paths are allowed"
4352b68e1f86Smrg	    ;;
43536df26cacSmrg	  esac
4354b68e1f86Smrg	  if test "$prev" = rpath; then
4355b68e1f86Smrg	    case "$rpath " in
4356b68e1f86Smrg	    *" $arg "*) ;;
4357b68e1f86Smrg	    *) rpath="$rpath $arg" ;;
4358b68e1f86Smrg	    esac
4359b68e1f86Smrg	  else
4360b68e1f86Smrg	    case "$xrpath " in
4361b68e1f86Smrg	    *" $arg "*) ;;
4362b68e1f86Smrg	    *) xrpath="$xrpath $arg" ;;
4363b68e1f86Smrg	    esac
4364b68e1f86Smrg	  fi
4365b68e1f86Smrg	  prev=
4366b68e1f86Smrg	  continue
4367b68e1f86Smrg	  ;;
4368b68e1f86Smrg	shrext)
4369b68e1f86Smrg	  shrext_cmds="$arg"
4370b68e1f86Smrg	  prev=
4371b68e1f86Smrg	  continue
4372b68e1f86Smrg	  ;;
4373b68e1f86Smrg	weak)
4374b68e1f86Smrg	  weak_libs="$weak_libs $arg"
4375b68e1f86Smrg	  prev=
4376b68e1f86Smrg	  continue
4377b68e1f86Smrg	  ;;
4378b68e1f86Smrg	xcclinker)
4379b68e1f86Smrg	  linker_flags="$linker_flags $qarg"
4380b68e1f86Smrg	  compiler_flags="$compiler_flags $qarg"
4381b68e1f86Smrg	  prev=
4382b68e1f86Smrg	  func_append compile_command " $qarg"
4383b68e1f86Smrg	  func_append finalize_command " $qarg"
4384b68e1f86Smrg	  continue
4385b68e1f86Smrg	  ;;
4386b68e1f86Smrg	xcompiler)
4387b68e1f86Smrg	  compiler_flags="$compiler_flags $qarg"
4388b68e1f86Smrg	  prev=
4389b68e1f86Smrg	  func_append compile_command " $qarg"
4390b68e1f86Smrg	  func_append finalize_command " $qarg"
4391b68e1f86Smrg	  continue
4392b68e1f86Smrg	  ;;
4393b68e1f86Smrg	xlinker)
4394b68e1f86Smrg	  linker_flags="$linker_flags $qarg"
4395b68e1f86Smrg	  compiler_flags="$compiler_flags $wl$qarg"
4396b68e1f86Smrg	  prev=
4397b68e1f86Smrg	  func_append compile_command " $wl$qarg"
4398b68e1f86Smrg	  func_append finalize_command " $wl$qarg"
4399b68e1f86Smrg	  continue
44006df26cacSmrg	  ;;
44016df26cacSmrg	*)
4402b68e1f86Smrg	  eval "$prev=\"\$arg\""
4403b68e1f86Smrg	  prev=
4404b68e1f86Smrg	  continue
44056df26cacSmrg	  ;;
44066df26cacSmrg	esac
4407b68e1f86Smrg      fi # test -n "$prev"
44086df26cacSmrg
4409b68e1f86Smrg      prevarg="$arg"
44106df26cacSmrg
4411b68e1f86Smrg      case $arg in
4412b68e1f86Smrg      -all-static)
4413b68e1f86Smrg	if test -n "$link_static_flag"; then
4414b68e1f86Smrg	  # See comment for -static flag below, for more details.
4415b68e1f86Smrg	  func_append compile_command " $link_static_flag"
4416b68e1f86Smrg	  func_append finalize_command " $link_static_flag"
44176df26cacSmrg	fi
4418b68e1f86Smrg	continue
4419b68e1f86Smrg	;;
44206df26cacSmrg
4421b68e1f86Smrg      -allow-undefined)
4422b68e1f86Smrg	# FIXME: remove this flag sometime in the future.
4423b68e1f86Smrg	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
4424b68e1f86Smrg	;;
44256df26cacSmrg
4426b68e1f86Smrg      -avoid-version)
4427b68e1f86Smrg	avoid_version=yes
4428b68e1f86Smrg	continue
4429b68e1f86Smrg	;;
44306df26cacSmrg
4431b68e1f86Smrg      -dlopen)
4432b68e1f86Smrg	prev=dlfiles
4433b68e1f86Smrg	continue
4434b68e1f86Smrg	;;
44356df26cacSmrg
4436b68e1f86Smrg      -dlpreopen)
4437b68e1f86Smrg	prev=dlprefiles
4438b68e1f86Smrg	continue
4439b68e1f86Smrg	;;
44406df26cacSmrg
4441b68e1f86Smrg      -export-dynamic)
4442b68e1f86Smrg	export_dynamic=yes
4443b68e1f86Smrg	continue
4444b68e1f86Smrg	;;
44456df26cacSmrg
4446b68e1f86Smrg      -export-symbols | -export-symbols-regex)
4447b68e1f86Smrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
4448b68e1f86Smrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
4449b68e1f86Smrg	fi
4450b68e1f86Smrg	if test "X$arg" = "X-export-symbols"; then
4451b68e1f86Smrg	  prev=expsyms
44526df26cacSmrg	else
4453b68e1f86Smrg	  prev=expsyms_regex
44546df26cacSmrg	fi
4455b68e1f86Smrg	continue
4456b68e1f86Smrg	;;
44576df26cacSmrg
4458b68e1f86Smrg      -framework)
4459b68e1f86Smrg	prev=framework
4460b68e1f86Smrg	continue
4461b68e1f86Smrg	;;
44626df26cacSmrg
4463b68e1f86Smrg      -inst-prefix-dir)
4464b68e1f86Smrg	prev=inst_prefix
4465b68e1f86Smrg	continue
4466b68e1f86Smrg	;;
44676df26cacSmrg
4468b68e1f86Smrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
4469b68e1f86Smrg      # so, if we see these flags be careful not to treat them like -L
4470b68e1f86Smrg      -L[A-Z][A-Z]*:*)
4471b68e1f86Smrg	case $with_gcc/$host in
4472b68e1f86Smrg	no/*-*-irix* | /*-*-irix*)
4473b68e1f86Smrg	  func_append compile_command " $arg"
4474b68e1f86Smrg	  func_append finalize_command " $arg"
4475b68e1f86Smrg	  ;;
4476b68e1f86Smrg	esac
4477b68e1f86Smrg	continue
4478b68e1f86Smrg	;;
44796df26cacSmrg
4480b68e1f86Smrg      -L*)
4481b68e1f86Smrg	func_stripname '-L' '' "$arg"
4482b68e1f86Smrg	dir=$func_stripname_result
4483b68e1f86Smrg	if test -z "$dir"; then
4484b68e1f86Smrg	  if test "$#" -gt 0; then
4485b68e1f86Smrg	    func_fatal_error "require no space between \`-L' and \`$1'"
44866df26cacSmrg	  else
4487b68e1f86Smrg	    func_fatal_error "need path for \`-L' option"
44886df26cacSmrg	  fi
4489b68e1f86Smrg	fi
4490b68e1f86Smrg	# We need an absolute path.
4491b68e1f86Smrg	case $dir in
4492b68e1f86Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
4493b68e1f86Smrg	*)
4494b68e1f86Smrg	  absdir=`cd "$dir" && pwd`
4495b68e1f86Smrg	  test -z "$absdir" && \
4496b68e1f86Smrg	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
4497b68e1f86Smrg	  dir="$absdir"
4498b68e1f86Smrg	  ;;
44996df26cacSmrg	esac
4500b68e1f86Smrg	case "$deplibs " in
4501b68e1f86Smrg	*" -L$dir "*) ;;
4502b68e1f86Smrg	*)
4503b68e1f86Smrg	  deplibs="$deplibs -L$dir"
4504b68e1f86Smrg	  lib_search_path="$lib_search_path $dir"
4505b68e1f86Smrg	  ;;
45066df26cacSmrg	esac
45076df26cacSmrg	case $host in
4508b68e1f86Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
4509b68e1f86Smrg	  testbindir=`$ECHO "X$dir" | $Xsed -e 's*/lib$*/bin*'`
4510b68e1f86Smrg	  case :$dllsearchpath: in
4511b68e1f86Smrg	  *":$dir:"*) ;;
4512b68e1f86Smrg	  ::) dllsearchpath=$dir;;
4513b68e1f86Smrg	  *) dllsearchpath="$dllsearchpath:$dir";;
4514b68e1f86Smrg	  esac
4515b68e1f86Smrg	  case :$dllsearchpath: in
4516b68e1f86Smrg	  *":$testbindir:"*) ;;
4517b68e1f86Smrg	  ::) dllsearchpath=$testbindir;;
4518b68e1f86Smrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
4519b68e1f86Smrg	  esac
4520b68e1f86Smrg	  ;;
45216df26cacSmrg	esac
4522b68e1f86Smrg	continue
4523b68e1f86Smrg	;;
45246df26cacSmrg
4525b68e1f86Smrg      -l*)
4526b68e1f86Smrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
4527b68e1f86Smrg	  case $host in
4528b68e1f86Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc*)
4529b68e1f86Smrg	    # These systems don't actually have a C or math library (as such)
4530b68e1f86Smrg	    continue
4531b68e1f86Smrg	    ;;
4532b68e1f86Smrg	  *-*-os2*)
4533b68e1f86Smrg	    # These systems don't actually have a C library (as such)
4534b68e1f86Smrg	    test "X$arg" = "X-lc" && continue
4535b68e1f86Smrg	    ;;
4536b68e1f86Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
4537b68e1f86Smrg	    # Do not include libc due to us having libc/libc_r.
4538b68e1f86Smrg	    test "X$arg" = "X-lc" && continue
4539b68e1f86Smrg	    ;;
4540b68e1f86Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
4541b68e1f86Smrg	    # Rhapsody C and math libraries are in the System framework
4542b68e1f86Smrg	    deplibs="$deplibs System.ltframework"
4543b68e1f86Smrg	    continue
4544b68e1f86Smrg	    ;;
4545b68e1f86Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
4546b68e1f86Smrg	    # Causes problems with __ctype
4547b68e1f86Smrg	    test "X$arg" = "X-lc" && continue
4548b68e1f86Smrg	    ;;
4549b68e1f86Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
4550b68e1f86Smrg	    # Compiler inserts libc in the correct place for threads to work
4551b68e1f86Smrg	    test "X$arg" = "X-lc" && continue
4552b68e1f86Smrg	    ;;
4553b68e1f86Smrg	  esac
4554b68e1f86Smrg	elif test "X$arg" = "X-lc_r"; then
4555b68e1f86Smrg	 case $host in
4556b68e1f86Smrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
4557b68e1f86Smrg	   # Do not include libc_r directly, use -pthread flag.
4558b68e1f86Smrg	   continue
4559b68e1f86Smrg	   ;;
4560b68e1f86Smrg	 esac
4561b68e1f86Smrg	fi
4562b68e1f86Smrg	deplibs="$deplibs $arg"
4563b68e1f86Smrg	continue
4564b68e1f86Smrg	;;
45656df26cacSmrg
4566b68e1f86Smrg      -module)
4567b68e1f86Smrg	module=yes
4568b68e1f86Smrg	continue
4569b68e1f86Smrg	;;
45706df26cacSmrg
4571b68e1f86Smrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
4572b68e1f86Smrg      # classes, name mangling, and exception handling.
4573b68e1f86Smrg      # Darwin uses the -arch flag to determine output architecture.
4574b68e1f86Smrg      -model|-arch|-isysroot)
4575b68e1f86Smrg	compiler_flags="$compiler_flags $arg"
4576b68e1f86Smrg	func_append compile_command " $arg"
4577b68e1f86Smrg	func_append finalize_command " $arg"
4578b68e1f86Smrg	prev=xcompiler
4579b68e1f86Smrg	continue
4580b68e1f86Smrg	;;
45816df26cacSmrg
4582b68e1f86Smrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
4583b68e1f86Smrg	compiler_flags="$compiler_flags $arg"
4584b68e1f86Smrg	func_append compile_command " $arg"
4585b68e1f86Smrg	func_append finalize_command " $arg"
4586b68e1f86Smrg	case "$new_inherited_linker_flags " in
4587b68e1f86Smrg	    *" $arg "*) ;;
4588b68e1f86Smrg	    * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;;
4589b68e1f86Smrg	esac
4590b68e1f86Smrg	continue
4591b68e1f86Smrg	;;
45926df26cacSmrg
4593b68e1f86Smrg      -multi_module)
4594b68e1f86Smrg	single_module="${wl}-multi_module"
4595b68e1f86Smrg	continue
4596b68e1f86Smrg	;;
45976df26cacSmrg
4598b68e1f86Smrg      -no-fast-install)
4599b68e1f86Smrg	fast_install=no
4600b68e1f86Smrg	continue
4601b68e1f86Smrg	;;
46026df26cacSmrg
4603b68e1f86Smrg      -no-install)
4604b68e1f86Smrg	case $host in
4605b68e1f86Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
4606b68e1f86Smrg	  # The PATH hackery in wrapper scripts is required on Windows
4607b68e1f86Smrg	  # and Darwin in order for the loader to find any dlls it needs.
4608b68e1f86Smrg	  func_warning "\`-no-install' is ignored for $host"
4609b68e1f86Smrg	  func_warning "assuming \`-no-fast-install' instead"
4610b68e1f86Smrg	  fast_install=no
4611b68e1f86Smrg	  ;;
4612b68e1f86Smrg	*) no_install=yes ;;
4613b68e1f86Smrg	esac
4614b68e1f86Smrg	continue
4615b68e1f86Smrg	;;
46166df26cacSmrg
4617b68e1f86Smrg      -no-undefined)
4618b68e1f86Smrg	allow_undefined=no
4619b68e1f86Smrg	continue
4620b68e1f86Smrg	;;
46216df26cacSmrg
4622b68e1f86Smrg      -objectlist)
4623b68e1f86Smrg	prev=objectlist
4624b68e1f86Smrg	continue
4625b68e1f86Smrg	;;
46266df26cacSmrg
4627b68e1f86Smrg      -o) prev=output ;;
46286df26cacSmrg
4629b68e1f86Smrg      -precious-files-regex)
4630b68e1f86Smrg	prev=precious_regex
4631b68e1f86Smrg	continue
4632b68e1f86Smrg	;;
46336df26cacSmrg
4634b68e1f86Smrg      -release)
4635b68e1f86Smrg	prev=release
4636b68e1f86Smrg	continue
4637b68e1f86Smrg	;;
46386df26cacSmrg
4639b68e1f86Smrg      -rpath)
4640b68e1f86Smrg	prev=rpath
4641b68e1f86Smrg	continue
4642b68e1f86Smrg	;;
46436df26cacSmrg
4644b68e1f86Smrg      -R)
4645b68e1f86Smrg	prev=xrpath
4646b68e1f86Smrg	continue
4647b68e1f86Smrg	;;
46486df26cacSmrg
4649b68e1f86Smrg      -R*)
4650b68e1f86Smrg	func_stripname '-R' '' "$arg"
4651b68e1f86Smrg	dir=$func_stripname_result
4652b68e1f86Smrg	# We need an absolute path.
4653b68e1f86Smrg	case $dir in
4654b68e1f86Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
4655b68e1f86Smrg	*)
4656b68e1f86Smrg	  func_fatal_error "only absolute run-paths are allowed"
4657b68e1f86Smrg	  ;;
4658b68e1f86Smrg	esac
4659b68e1f86Smrg	case "$xrpath " in
4660b68e1f86Smrg	*" $dir "*) ;;
4661b68e1f86Smrg	*) xrpath="$xrpath $dir" ;;
4662b68e1f86Smrg	esac
4663b68e1f86Smrg	continue
4664b68e1f86Smrg	;;
46656df26cacSmrg
4666b68e1f86Smrg      -shared)
4667b68e1f86Smrg	# The effects of -shared are defined in a previous loop.
4668b68e1f86Smrg	continue
4669b68e1f86Smrg	;;
46706df26cacSmrg
4671b68e1f86Smrg      -shrext)
4672b68e1f86Smrg	prev=shrext
4673b68e1f86Smrg	continue
4674b68e1f86Smrg	;;
46756df26cacSmrg
4676b68e1f86Smrg      -static | -static-libtool-libs)
4677b68e1f86Smrg	# The effects of -static are defined in a previous loop.
4678b68e1f86Smrg	# We used to do the same as -all-static on platforms that
4679b68e1f86Smrg	# didn't have a PIC flag, but the assumption that the effects
4680b68e1f86Smrg	# would be equivalent was wrong.  It would break on at least
4681b68e1f86Smrg	# Digital Unix and AIX.
4682b68e1f86Smrg	continue
4683b68e1f86Smrg	;;
46846df26cacSmrg
4685b68e1f86Smrg      -thread-safe)
4686b68e1f86Smrg	thread_safe=yes
4687b68e1f86Smrg	continue
4688b68e1f86Smrg	;;
46896df26cacSmrg
4690b68e1f86Smrg      -version-info)
4691b68e1f86Smrg	prev=vinfo
4692b68e1f86Smrg	continue
4693b68e1f86Smrg	;;
46946df26cacSmrg
4695b68e1f86Smrg      -version-number)
4696b68e1f86Smrg	prev=vinfo
4697b68e1f86Smrg	vinfo_number=yes
4698b68e1f86Smrg	continue
4699b68e1f86Smrg	;;
47006df26cacSmrg
4701b68e1f86Smrg      -weak)
4702b68e1f86Smrg        prev=weak
4703b68e1f86Smrg	continue
4704b68e1f86Smrg	;;
47056df26cacSmrg
4706b68e1f86Smrg      -Wc,*)
4707b68e1f86Smrg	func_stripname '-Wc,' '' "$arg"
4708b68e1f86Smrg	args=$func_stripname_result
4709b68e1f86Smrg	arg=
4710b68e1f86Smrg	save_ifs="$IFS"; IFS=','
4711b68e1f86Smrg	for flag in $args; do
4712b68e1f86Smrg	  IFS="$save_ifs"
4713b68e1f86Smrg          func_quote_for_eval "$flag"
4714b68e1f86Smrg	  arg="$arg $wl$func_quote_for_eval_result"
4715b68e1f86Smrg	  compiler_flags="$compiler_flags $func_quote_for_eval_result"
4716b68e1f86Smrg	done
4717b68e1f86Smrg	IFS="$save_ifs"
4718b68e1f86Smrg	func_stripname ' ' '' "$arg"
4719b68e1f86Smrg	arg=$func_stripname_result
4720b68e1f86Smrg	;;
47216df26cacSmrg
4722b68e1f86Smrg      -Wl,*)
4723b68e1f86Smrg	func_stripname '-Wl,' '' "$arg"
4724b68e1f86Smrg	args=$func_stripname_result
4725b68e1f86Smrg	arg=
4726b68e1f86Smrg	save_ifs="$IFS"; IFS=','
4727b68e1f86Smrg	for flag in $args; do
4728b68e1f86Smrg	  IFS="$save_ifs"
4729b68e1f86Smrg          func_quote_for_eval "$flag"
4730b68e1f86Smrg	  arg="$arg $wl$func_quote_for_eval_result"
4731b68e1f86Smrg	  compiler_flags="$compiler_flags $wl$func_quote_for_eval_result"
4732b68e1f86Smrg	  linker_flags="$linker_flags $func_quote_for_eval_result"
4733b68e1f86Smrg	done
4734b68e1f86Smrg	IFS="$save_ifs"
4735b68e1f86Smrg	func_stripname ' ' '' "$arg"
4736b68e1f86Smrg	arg=$func_stripname_result
4737b68e1f86Smrg	;;
47386df26cacSmrg
4739b68e1f86Smrg      -Xcompiler)
4740b68e1f86Smrg	prev=xcompiler
4741b68e1f86Smrg	continue
4742b68e1f86Smrg	;;
47436df26cacSmrg
4744b68e1f86Smrg      -Xlinker)
4745b68e1f86Smrg	prev=xlinker
4746b68e1f86Smrg	continue
4747b68e1f86Smrg	;;
47486df26cacSmrg
4749b68e1f86Smrg      -XCClinker)
4750b68e1f86Smrg	prev=xcclinker
4751b68e1f86Smrg	continue
4752b68e1f86Smrg	;;
47536df26cacSmrg
4754b68e1f86Smrg      # -msg_* for osf cc
4755b68e1f86Smrg      -msg_*)
4756b68e1f86Smrg	func_quote_for_eval "$arg"
4757b68e1f86Smrg	arg="$func_quote_for_eval_result"
4758b68e1f86Smrg	;;
47596df26cacSmrg
4760b68e1f86Smrg      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
4761b68e1f86Smrg      # -r[0-9][0-9]* specifies the processor on the SGI compiler
4762b68e1f86Smrg      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
4763b68e1f86Smrg      # +DA*, +DD* enable 64-bit mode on the HP compiler
4764b68e1f86Smrg      # -q* pass through compiler args for the IBM compiler
4765b68e1f86Smrg      # -m*, -t[45]*, -txscale* pass through architecture-specific
4766b68e1f86Smrg      # compiler args for GCC
4767b68e1f86Smrg      # -F/path gives path to uninstalled frameworks, gcc on darwin
4768b68e1f86Smrg      # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
4769b68e1f86Smrg      # @file GCC response files
4770b68e1f86Smrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
4771b68e1f86Smrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*)
4772b68e1f86Smrg        func_quote_for_eval "$arg"
4773b68e1f86Smrg	arg="$func_quote_for_eval_result"
4774b68e1f86Smrg        func_append compile_command " $arg"
4775b68e1f86Smrg        func_append finalize_command " $arg"
4776b68e1f86Smrg        compiler_flags="$compiler_flags $arg"
4777b68e1f86Smrg        continue
4778b68e1f86Smrg        ;;
47796df26cacSmrg
4780b68e1f86Smrg      # Some other compiler flag.
4781b68e1f86Smrg      -* | +*)
4782b68e1f86Smrg        func_quote_for_eval "$arg"
4783b68e1f86Smrg	arg="$func_quote_for_eval_result"
4784b68e1f86Smrg	;;
47856df26cacSmrg
4786b68e1f86Smrg      *.$objext)
4787b68e1f86Smrg	# A standard object.
4788b68e1f86Smrg	objs="$objs $arg"
4789b68e1f86Smrg	;;
47906df26cacSmrg
4791b68e1f86Smrg      *.lo)
4792b68e1f86Smrg	# A libtool-controlled object.
47936df26cacSmrg
4794b68e1f86Smrg	# Check to see that this really is a libtool object.
4795b68e1f86Smrg	if func_lalib_unsafe_p "$arg"; then
4796b68e1f86Smrg	  pic_object=
4797b68e1f86Smrg	  non_pic_object=
47986df26cacSmrg
4799b68e1f86Smrg	  # Read the .lo file
4800b68e1f86Smrg	  func_source "$arg"
48016df26cacSmrg
4802b68e1f86Smrg	  if test -z "$pic_object" ||
4803b68e1f86Smrg	     test -z "$non_pic_object" ||
4804b68e1f86Smrg	     test "$pic_object" = none &&
4805b68e1f86Smrg	     test "$non_pic_object" = none; then
4806b68e1f86Smrg	    func_fatal_error "cannot find name of object for \`$arg'"
4807b68e1f86Smrg	  fi
48086df26cacSmrg
4809b68e1f86Smrg	  # Extract subdirectory from the argument.
4810b68e1f86Smrg	  func_dirname "$arg" "/" ""
4811b68e1f86Smrg	  xdir="$func_dirname_result"
48126df26cacSmrg
4813b68e1f86Smrg	  if test "$pic_object" != none; then
4814b68e1f86Smrg	    # Prepend the subdirectory the object is found in.
4815b68e1f86Smrg	    pic_object="$xdir$pic_object"
48166df26cacSmrg
4817b68e1f86Smrg	    if test "$prev" = dlfiles; then
4818b68e1f86Smrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
4819b68e1f86Smrg		dlfiles="$dlfiles $pic_object"
4820b68e1f86Smrg		prev=
4821b68e1f86Smrg		continue
4822b68e1f86Smrg	      else
4823b68e1f86Smrg		# If libtool objects are unsupported, then we need to preload.
4824b68e1f86Smrg		prev=dlprefiles
4825b68e1f86Smrg	      fi
4826b68e1f86Smrg	    fi
48276df26cacSmrg
4828b68e1f86Smrg	    # CHECK ME:  I think I busted this.  -Ossama
4829b68e1f86Smrg	    if test "$prev" = dlprefiles; then
4830b68e1f86Smrg	      # Preload the old-style object.
4831b68e1f86Smrg	      dlprefiles="$dlprefiles $pic_object"
4832b68e1f86Smrg	      prev=
4833b68e1f86Smrg	    fi
48346df26cacSmrg
4835b68e1f86Smrg	    # A PIC object.
4836b68e1f86Smrg	    func_append libobjs " $pic_object"
4837b68e1f86Smrg	    arg="$pic_object"
4838b68e1f86Smrg	  fi
48396df26cacSmrg
4840b68e1f86Smrg	  # Non-PIC object.
4841b68e1f86Smrg	  if test "$non_pic_object" != none; then
4842b68e1f86Smrg	    # Prepend the subdirectory the object is found in.
4843b68e1f86Smrg	    non_pic_object="$xdir$non_pic_object"
48446df26cacSmrg
4845b68e1f86Smrg	    # A standard non-PIC object
4846b68e1f86Smrg	    func_append non_pic_objects " $non_pic_object"
4847b68e1f86Smrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
4848b68e1f86Smrg	      arg="$non_pic_object"
4849b68e1f86Smrg	    fi
4850b68e1f86Smrg	  else
4851b68e1f86Smrg	    # If the PIC object exists, use it instead.
4852b68e1f86Smrg	    # $xdir was prepended to $pic_object above.
4853b68e1f86Smrg	    non_pic_object="$pic_object"
4854b68e1f86Smrg	    func_append non_pic_objects " $non_pic_object"
4855b68e1f86Smrg	  fi
4856b68e1f86Smrg	else
4857b68e1f86Smrg	  # Only an error if not doing a dry-run.
4858b68e1f86Smrg	  if $opt_dry_run; then
4859b68e1f86Smrg	    # Extract subdirectory from the argument.
4860b68e1f86Smrg	    func_dirname "$arg" "/" ""
4861b68e1f86Smrg	    xdir="$func_dirname_result"
4862b68e1f86Smrg
4863b68e1f86Smrg	    func_lo2o "$arg"
4864b68e1f86Smrg	    pic_object=$xdir$objdir/$func_lo2o_result
4865b68e1f86Smrg	    non_pic_object=$xdir$func_lo2o_result
4866b68e1f86Smrg	    func_append libobjs " $pic_object"
4867b68e1f86Smrg	    func_append non_pic_objects " $non_pic_object"
4868b68e1f86Smrg	  else
4869b68e1f86Smrg	    func_fatal_error "\`$arg' is not a valid libtool object"
4870b68e1f86Smrg	  fi
4871b68e1f86Smrg	fi
4872b68e1f86Smrg	;;
48736df26cacSmrg
4874b68e1f86Smrg      *.$libext)
4875b68e1f86Smrg	# An archive.
4876b68e1f86Smrg	deplibs="$deplibs $arg"
4877b68e1f86Smrg	old_deplibs="$old_deplibs $arg"
4878b68e1f86Smrg	continue
4879b68e1f86Smrg	;;
48806df26cacSmrg
4881b68e1f86Smrg      *.la)
4882b68e1f86Smrg	# A libtool-controlled library.
48836df26cacSmrg
4884b68e1f86Smrg	if test "$prev" = dlfiles; then
4885b68e1f86Smrg	  # This library was specified with -dlopen.
4886b68e1f86Smrg	  dlfiles="$dlfiles $arg"
4887b68e1f86Smrg	  prev=
4888b68e1f86Smrg	elif test "$prev" = dlprefiles; then
4889b68e1f86Smrg	  # The library was specified with -dlpreopen.
4890b68e1f86Smrg	  dlprefiles="$dlprefiles $arg"
4891b68e1f86Smrg	  prev=
4892b68e1f86Smrg	else
4893b68e1f86Smrg	  deplibs="$deplibs $arg"
4894b68e1f86Smrg	fi
4895b68e1f86Smrg	continue
4896b68e1f86Smrg	;;
48976df26cacSmrg
4898b68e1f86Smrg      # Some other compiler argument.
4899b68e1f86Smrg      *)
4900b68e1f86Smrg	# Unknown arguments in both finalize_command and compile_command need
4901b68e1f86Smrg	# to be aesthetically quoted because they are evaled later.
4902b68e1f86Smrg	func_quote_for_eval "$arg"
4903b68e1f86Smrg	arg="$func_quote_for_eval_result"
4904b68e1f86Smrg	;;
4905b68e1f86Smrg      esac # arg
49066df26cacSmrg
4907b68e1f86Smrg      # Now actually substitute the argument into the commands.
4908b68e1f86Smrg      if test -n "$arg"; then
4909b68e1f86Smrg	func_append compile_command " $arg"
4910b68e1f86Smrg	func_append finalize_command " $arg"
4911b68e1f86Smrg      fi
4912b68e1f86Smrg    done # argument parsing loop
49136df26cacSmrg
4914a241306cSmrg    if test "$module" = yes ; then
4915a241306cSmrg      # [Mandriva] dropping ld option "--no-undefined" which is wrong for plugins
4916a241306cSmrg      linker_flags=`$ECHO "X $linker_flags" | $Xsed -e 's/ --no-undefined//'`
4917a241306cSmrg      compiler_flags=`$ECHO "X $compiler_flags" | $Xsed -e 's/ -Wl,--no-undefined//'`
4918a241306cSmrg    fi
4919a241306cSmrg
4920b68e1f86Smrg    test -n "$prev" && \
4921b68e1f86Smrg      func_fatal_help "the \`$prevarg' option requires an argument"
492216fd1166Smrg
4923b68e1f86Smrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
4924b68e1f86Smrg      eval arg=\"$export_dynamic_flag_spec\"
4925b68e1f86Smrg      func_append compile_command " $arg"
4926b68e1f86Smrg      func_append finalize_command " $arg"
4927b68e1f86Smrg    fi
49286df26cacSmrg
4929b68e1f86Smrg    oldlibs=
4930b68e1f86Smrg    # calculate the name of the file, without its directory
4931b68e1f86Smrg    func_basename "$output"
4932b68e1f86Smrg    outputname="$func_basename_result"
4933b68e1f86Smrg    libobjs_save="$libobjs"
49346df26cacSmrg
4935b68e1f86Smrg    if test -n "$shlibpath_var"; then
4936b68e1f86Smrg      # get the directories listed in $shlibpath_var
4937b68e1f86Smrg      eval shlib_search_path=\`\$ECHO \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
49386df26cacSmrg    else
4939b68e1f86Smrg      shlib_search_path=
49406df26cacSmrg    fi
4941b68e1f86Smrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
4942b68e1f86Smrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
49436df26cacSmrg
4944b68e1f86Smrg    func_dirname "$output" "/" ""
4945b68e1f86Smrg    output_objdir="$func_dirname_result$objdir"
4946b68e1f86Smrg    # Create the object directory.
4947b68e1f86Smrg    func_mkdir_p "$output_objdir"
49486df26cacSmrg
4949b68e1f86Smrg    # Determine the type of output
4950b68e1f86Smrg    case $output in
4951b68e1f86Smrg    "")
4952b68e1f86Smrg      func_fatal_help "you must specify an output file"
4953b68e1f86Smrg      ;;
4954b68e1f86Smrg    *.$libext) linkmode=oldlib ;;
4955b68e1f86Smrg    *.lo | *.$objext) linkmode=obj ;;
4956b68e1f86Smrg    *.la) linkmode=lib ;;
4957b68e1f86Smrg    *) linkmode=prog ;; # Anything else should be a program.
4958b68e1f86Smrg    esac
4959b68e1f86Smrg
4960b68e1f86Smrg    specialdeplibs=
4961b68e1f86Smrg
4962b68e1f86Smrg    libs=
4963b68e1f86Smrg    # Find all interdependent deplibs by searching for libraries
4964b68e1f86Smrg    # that are linked more than once (e.g. -la -lb -la)
4965b68e1f86Smrg    for deplib in $deplibs; do
4966b68e1f86Smrg      if $opt_duplicate_deps ; then
4967b68e1f86Smrg	case "$libs " in
4968b68e1f86Smrg	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
4969b68e1f86Smrg	esac
4970b68e1f86Smrg      fi
4971b68e1f86Smrg      libs="$libs $deplib"
4972b68e1f86Smrg    done
4973b68e1f86Smrg
4974b68e1f86Smrg    if test "$linkmode" = lib; then
4975b68e1f86Smrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
4976b68e1f86Smrg
4977b68e1f86Smrg      # Compute libraries that are listed more than once in $predeps
4978b68e1f86Smrg      # $postdeps and mark them as special (i.e., whose duplicates are
4979b68e1f86Smrg      # not to be eliminated).
4980b68e1f86Smrg      pre_post_deps=
4981b68e1f86Smrg      if $opt_duplicate_compiler_generated_deps; then
4982b68e1f86Smrg	for pre_post_dep in $predeps $postdeps; do
4983b68e1f86Smrg	  case "$pre_post_deps " in
4984b68e1f86Smrg	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
4985b68e1f86Smrg	  esac
4986b68e1f86Smrg	  pre_post_deps="$pre_post_deps $pre_post_dep"
4987b68e1f86Smrg	done
4988b68e1f86Smrg      fi
4989b68e1f86Smrg      pre_post_deps=
4990b68e1f86Smrg    fi
4991b68e1f86Smrg
4992b68e1f86Smrg    deplibs=
4993b68e1f86Smrg    newdependency_libs=
4994b68e1f86Smrg    newlib_search_path=
4995b68e1f86Smrg    need_relink=no # whether we're linking any uninstalled libtool libraries
4996b68e1f86Smrg    notinst_deplibs= # not-installed libtool libraries
4997b68e1f86Smrg    notinst_path= # paths that contain not-installed libtool libraries
4998b68e1f86Smrg
4999b68e1f86Smrg    case $linkmode in
5000b68e1f86Smrg    lib)
5001b68e1f86Smrg	passes="conv dlpreopen link"
5002b68e1f86Smrg	for file in $dlfiles $dlprefiles; do
5003b68e1f86Smrg	  case $file in
5004b68e1f86Smrg	  *.la) ;;
5005b68e1f86Smrg	  *)
5006b68e1f86Smrg	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
5007b68e1f86Smrg	    ;;
5008b68e1f86Smrg	  esac
5009b68e1f86Smrg	done
5010b68e1f86Smrg	;;
5011b68e1f86Smrg    prog)
5012b68e1f86Smrg	compile_deplibs=
5013b68e1f86Smrg	finalize_deplibs=
5014b68e1f86Smrg	alldeplibs=no
5015b68e1f86Smrg	newdlfiles=
5016b68e1f86Smrg	newdlprefiles=
5017b68e1f86Smrg	passes="conv scan dlopen dlpreopen link"
5018b68e1f86Smrg	;;
5019b68e1f86Smrg    *)  passes="conv"
5020b68e1f86Smrg	;;
5021b68e1f86Smrg    esac
5022b68e1f86Smrg
5023b68e1f86Smrg    for pass in $passes; do
5024b68e1f86Smrg      # The preopen pass in lib mode reverses $deplibs; put it back here
5025b68e1f86Smrg      # so that -L comes before libs that need it for instance...
5026b68e1f86Smrg      if test "$linkmode,$pass" = "lib,link"; then
5027b68e1f86Smrg	## FIXME: Find the place where the list is rebuilt in the wrong
5028b68e1f86Smrg	##        order, and fix it there properly
5029b68e1f86Smrg        tmp_deplibs=
5030b68e1f86Smrg	for deplib in $deplibs; do
5031b68e1f86Smrg	  tmp_deplibs="$deplib $tmp_deplibs"
5032b68e1f86Smrg	done
5033b68e1f86Smrg	deplibs="$tmp_deplibs"
5034b68e1f86Smrg      fi
5035b68e1f86Smrg
5036b68e1f86Smrg      if test "$linkmode,$pass" = "lib,link" ||
5037b68e1f86Smrg	 test "$linkmode,$pass" = "prog,scan"; then
5038b68e1f86Smrg	libs="$deplibs"
5039b68e1f86Smrg	deplibs=
5040b68e1f86Smrg      fi
5041b68e1f86Smrg      if test "$linkmode" = prog; then
5042b68e1f86Smrg	case $pass in
5043b68e1f86Smrg	dlopen) libs="$dlfiles" ;;
5044b68e1f86Smrg	dlpreopen) libs="$dlprefiles" ;;
5045a241306cSmrg	link)
5046a241306cSmrg	  libs="$deplibs %DEPLIBS%"
5047a241306cSmrg	  test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
5048a241306cSmrg	  ;;
5049b68e1f86Smrg	esac
5050b68e1f86Smrg      fi
5051b68e1f86Smrg      if test "$linkmode,$pass" = "lib,dlpreopen"; then
5052b68e1f86Smrg	# Collect and forward deplibs of preopened libtool libs
5053b68e1f86Smrg	for lib in $dlprefiles; do
5054b68e1f86Smrg	  # Ignore non-libtool-libs
5055b68e1f86Smrg	  dependency_libs=
5056b68e1f86Smrg	  case $lib in
5057b68e1f86Smrg	  *.la)	func_source "$lib" ;;
5058b68e1f86Smrg	  esac
5059b68e1f86Smrg
5060b68e1f86Smrg	  # Collect preopened libtool deplibs, except any this library
5061b68e1f86Smrg	  # has declared as weak libs
5062b68e1f86Smrg	  for deplib in $dependency_libs; do
5063b68e1f86Smrg            deplib_base=`$ECHO "X$deplib" | $Xsed -e "$basename"`
5064b68e1f86Smrg	    case " $weak_libs " in
5065b68e1f86Smrg	    *" $deplib_base "*) ;;
5066b68e1f86Smrg	    *) deplibs="$deplibs $deplib" ;;
5067b68e1f86Smrg	    esac
5068b68e1f86Smrg	  done
5069b68e1f86Smrg	done
5070b68e1f86Smrg	libs="$dlprefiles"
5071b68e1f86Smrg      fi
5072b68e1f86Smrg      if test "$pass" = dlopen; then
5073b68e1f86Smrg	# Collect dlpreopened libraries
5074b68e1f86Smrg	save_deplibs="$deplibs"
5075b68e1f86Smrg	deplibs=
5076b68e1f86Smrg      fi
5077b68e1f86Smrg
5078b68e1f86Smrg      for deplib in $libs; do
5079b68e1f86Smrg	lib=
5080b68e1f86Smrg	found=no
5081b68e1f86Smrg	case $deplib in
5082b68e1f86Smrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
5083b68e1f86Smrg	  if test "$linkmode,$pass" = "prog,link"; then
5084b68e1f86Smrg	    compile_deplibs="$deplib $compile_deplibs"
5085b68e1f86Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
5086b68e1f86Smrg	  else
5087b68e1f86Smrg	    compiler_flags="$compiler_flags $deplib"
5088b68e1f86Smrg	    if test "$linkmode" = lib ; then
5089b68e1f86Smrg		case "$new_inherited_linker_flags " in
5090b68e1f86Smrg		    *" $deplib "*) ;;
5091b68e1f86Smrg		    * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
5092b68e1f86Smrg		esac
5093b68e1f86Smrg	    fi
5094b68e1f86Smrg	  fi
5095b68e1f86Smrg	  continue
5096b68e1f86Smrg	  ;;
5097b68e1f86Smrg	-l*)
5098b68e1f86Smrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
5099b68e1f86Smrg	    func_warning "\`-l' is ignored for archives/objects"
5100b68e1f86Smrg	    continue
5101b68e1f86Smrg	  fi
5102b68e1f86Smrg	  func_stripname '-l' '' "$deplib"
5103b68e1f86Smrg	  name=$func_stripname_result
5104b68e1f86Smrg	  if test "$linkmode" = lib; then
5105b68e1f86Smrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
5106b68e1f86Smrg	  else
5107b68e1f86Smrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
5108b68e1f86Smrg	  fi
5109b68e1f86Smrg	  for searchdir in $searchdirs; do
5110b68e1f86Smrg	    for search_ext in .la $std_shrext .so .a; do
5111b68e1f86Smrg	      # Search the libtool library
5112b68e1f86Smrg	      lib="$searchdir/lib${name}${search_ext}"
5113b68e1f86Smrg	      if test -f "$lib"; then
5114b68e1f86Smrg		if test "$search_ext" = ".la"; then
5115b68e1f86Smrg		  found=yes
5116b68e1f86Smrg		else
5117b68e1f86Smrg		  found=no
5118b68e1f86Smrg		fi
5119b68e1f86Smrg		break 2
5120b68e1f86Smrg	      fi
5121b68e1f86Smrg	    done
5122b68e1f86Smrg	  done
5123b68e1f86Smrg	  if test "$found" != yes; then
5124b68e1f86Smrg	    # deplib doesn't seem to be a libtool library
5125b68e1f86Smrg	    if test "$linkmode,$pass" = "prog,link"; then
5126b68e1f86Smrg	      compile_deplibs="$deplib $compile_deplibs"
5127b68e1f86Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
5128b68e1f86Smrg	    else
5129b68e1f86Smrg	      deplibs="$deplib $deplibs"
5130b68e1f86Smrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
5131b68e1f86Smrg	    fi
5132b68e1f86Smrg	    continue
5133b68e1f86Smrg	  else # deplib is a libtool library
5134b68e1f86Smrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
5135b68e1f86Smrg	    # We need to do some special things here, and not later.
5136b68e1f86Smrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
5137b68e1f86Smrg	      case " $predeps $postdeps " in
5138b68e1f86Smrg	      *" $deplib "*)
5139b68e1f86Smrg		if func_lalib_p "$lib"; then
5140b68e1f86Smrg		  library_names=
5141b68e1f86Smrg		  old_library=
5142b68e1f86Smrg		  func_source "$lib"
5143b68e1f86Smrg		  for l in $old_library $library_names; do
5144b68e1f86Smrg		    ll="$l"
5145b68e1f86Smrg		  done
5146b68e1f86Smrg		  if test "X$ll" = "X$old_library" ; then # only static version available
5147b68e1f86Smrg		    found=no
5148b68e1f86Smrg		    func_dirname "$lib" "" "."
5149b68e1f86Smrg		    ladir="$func_dirname_result"
5150b68e1f86Smrg		    lib=$ladir/$old_library
5151b68e1f86Smrg		    if test "$linkmode,$pass" = "prog,link"; then
5152b68e1f86Smrg		      compile_deplibs="$deplib $compile_deplibs"
5153b68e1f86Smrg		      finalize_deplibs="$deplib $finalize_deplibs"
5154b68e1f86Smrg		    else
5155b68e1f86Smrg		      deplibs="$deplib $deplibs"
5156b68e1f86Smrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
5157b68e1f86Smrg		    fi
5158b68e1f86Smrg		    continue
5159b68e1f86Smrg		  fi
5160b68e1f86Smrg		fi
5161b68e1f86Smrg		;;
5162b68e1f86Smrg	      *) ;;
5163b68e1f86Smrg	      esac
5164b68e1f86Smrg	    fi
5165b68e1f86Smrg	  fi
5166b68e1f86Smrg	  ;; # -l
5167b68e1f86Smrg	*.ltframework)
5168b68e1f86Smrg	  if test "$linkmode,$pass" = "prog,link"; then
5169b68e1f86Smrg	    compile_deplibs="$deplib $compile_deplibs"
5170b68e1f86Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
5171b68e1f86Smrg	  else
5172b68e1f86Smrg	    deplibs="$deplib $deplibs"
5173b68e1f86Smrg	    if test "$linkmode" = lib ; then
5174b68e1f86Smrg		case "$new_inherited_linker_flags " in
5175b68e1f86Smrg		    *" $deplib "*) ;;
5176b68e1f86Smrg		    * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
5177b68e1f86Smrg		esac
5178b68e1f86Smrg	    fi
5179b68e1f86Smrg	  fi
5180b68e1f86Smrg	  continue
5181b68e1f86Smrg	  ;;
5182b68e1f86Smrg	-L*)
5183b68e1f86Smrg	  case $linkmode in
5184b68e1f86Smrg	  lib)
5185b68e1f86Smrg	    deplibs="$deplib $deplibs"
5186b68e1f86Smrg	    test "$pass" = conv && continue
5187b68e1f86Smrg	    newdependency_libs="$deplib $newdependency_libs"
5188b68e1f86Smrg	    func_stripname '-L' '' "$deplib"
5189b68e1f86Smrg	    newlib_search_path="$newlib_search_path $func_stripname_result"
5190b68e1f86Smrg	    ;;
5191b68e1f86Smrg	  prog)
5192b68e1f86Smrg	    if test "$pass" = conv; then
5193b68e1f86Smrg	      deplibs="$deplib $deplibs"
5194b68e1f86Smrg	      continue
5195b68e1f86Smrg	    fi
5196b68e1f86Smrg	    if test "$pass" = scan; then
5197b68e1f86Smrg	      deplibs="$deplib $deplibs"
5198b68e1f86Smrg	    else
5199b68e1f86Smrg	      compile_deplibs="$deplib $compile_deplibs"
5200b68e1f86Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
5201b68e1f86Smrg	    fi
5202b68e1f86Smrg	    func_stripname '-L' '' "$deplib"
5203b68e1f86Smrg	    newlib_search_path="$newlib_search_path $func_stripname_result"
5204b68e1f86Smrg	    ;;
5205b68e1f86Smrg	  *)
5206b68e1f86Smrg	    func_warning "\`-L' is ignored for archives/objects"
5207b68e1f86Smrg	    ;;
5208b68e1f86Smrg	  esac # linkmode
5209b68e1f86Smrg	  continue
5210b68e1f86Smrg	  ;; # -L
5211b68e1f86Smrg	-R*)
5212b68e1f86Smrg	  if test "$pass" = link; then
5213b68e1f86Smrg	    func_stripname '-R' '' "$deplib"
5214b68e1f86Smrg	    dir=$func_stripname_result
5215b68e1f86Smrg	    # Make sure the xrpath contains only unique directories.
5216b68e1f86Smrg	    case "$xrpath " in
5217b68e1f86Smrg	    *" $dir "*) ;;
5218b68e1f86Smrg	    *) xrpath="$xrpath $dir" ;;
5219b68e1f86Smrg	    esac
5220b68e1f86Smrg	  fi
5221b68e1f86Smrg	  deplibs="$deplib $deplibs"
5222b68e1f86Smrg	  continue
5223b68e1f86Smrg	  ;;
5224b68e1f86Smrg	*.la) lib="$deplib" ;;
5225b68e1f86Smrg	*.$libext)
5226b68e1f86Smrg	  if test "$pass" = conv; then
5227b68e1f86Smrg	    deplibs="$deplib $deplibs"
5228b68e1f86Smrg	    continue
5229b68e1f86Smrg	  fi
5230b68e1f86Smrg	  case $linkmode in
5231b68e1f86Smrg	  lib)
5232b68e1f86Smrg	    # Linking convenience modules into shared libraries is allowed,
5233b68e1f86Smrg	    # but linking other static libraries is non-portable.
5234b68e1f86Smrg	    case " $dlpreconveniencelibs " in
5235b68e1f86Smrg	    *" $deplib "*) ;;
5236b68e1f86Smrg	    *)
5237b68e1f86Smrg	      valid_a_lib=no
5238b68e1f86Smrg	      case $deplibs_check_method in
5239b68e1f86Smrg		match_pattern*)
5240b68e1f86Smrg		  set dummy $deplibs_check_method; shift
5241b68e1f86Smrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
5242b68e1f86Smrg		  if eval "\$ECHO \"X$deplib\"" 2>/dev/null | $Xsed -e 10q \
5243b68e1f86Smrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
5244b68e1f86Smrg		    valid_a_lib=yes
5245b68e1f86Smrg		  fi
5246b68e1f86Smrg		;;
5247b68e1f86Smrg		pass_all)
5248b68e1f86Smrg		  valid_a_lib=yes
5249b68e1f86Smrg		;;
5250b68e1f86Smrg	      esac
5251b68e1f86Smrg	      if test "$valid_a_lib" != yes; then
5252b68e1f86Smrg		$ECHO
5253b68e1f86Smrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
5254b68e1f86Smrg		$ECHO "*** I have the capability to make that library automatically link in when"
5255b68e1f86Smrg		$ECHO "*** you link to this library.  But I can only do this if you have a"
5256b68e1f86Smrg		$ECHO "*** shared version of the library, which you do not appear to have"
5257b68e1f86Smrg		$ECHO "*** because the file extensions .$libext of this argument makes me believe"
5258b68e1f86Smrg		$ECHO "*** that it is just a static archive that I should not use here."
5259b68e1f86Smrg	      else
5260b68e1f86Smrg		$ECHO
5261b68e1f86Smrg		$ECHO "*** Warning: Linking the shared library $output against the"
5262b68e1f86Smrg		$ECHO "*** static library $deplib is not portable!"
5263b68e1f86Smrg		deplibs="$deplib $deplibs"
5264b68e1f86Smrg	      fi
5265b68e1f86Smrg	      ;;
5266b68e1f86Smrg	    esac
5267b68e1f86Smrg	    continue
5268b68e1f86Smrg	    ;;
5269b68e1f86Smrg	  prog)
5270b68e1f86Smrg	    if test "$pass" != link; then
5271b68e1f86Smrg	      deplibs="$deplib $deplibs"
5272b68e1f86Smrg	    else
5273b68e1f86Smrg	      compile_deplibs="$deplib $compile_deplibs"
5274b68e1f86Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
5275b68e1f86Smrg	    fi
5276b68e1f86Smrg	    continue
5277b68e1f86Smrg	    ;;
5278b68e1f86Smrg	  esac # linkmode
5279b68e1f86Smrg	  ;; # *.$libext
5280b68e1f86Smrg	*.lo | *.$objext)
5281b68e1f86Smrg	  if test "$pass" = conv; then
5282b68e1f86Smrg	    deplibs="$deplib $deplibs"
5283b68e1f86Smrg	  elif test "$linkmode" = prog; then
5284b68e1f86Smrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
5285b68e1f86Smrg	      # If there is no dlopen support or we're linking statically,
5286b68e1f86Smrg	      # we need to preload.
5287b68e1f86Smrg	      newdlprefiles="$newdlprefiles $deplib"
5288b68e1f86Smrg	      compile_deplibs="$deplib $compile_deplibs"
5289b68e1f86Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
5290b68e1f86Smrg	    else
5291b68e1f86Smrg	      newdlfiles="$newdlfiles $deplib"
5292b68e1f86Smrg	    fi
5293b68e1f86Smrg	  fi
5294b68e1f86Smrg	  continue
5295b68e1f86Smrg	  ;;
5296b68e1f86Smrg	%DEPLIBS%)
5297b68e1f86Smrg	  alldeplibs=yes
5298b68e1f86Smrg	  continue
5299b68e1f86Smrg	  ;;
5300b68e1f86Smrg	esac # case $deplib
5301b68e1f86Smrg
5302b68e1f86Smrg	if test "$found" = yes || test -f "$lib"; then :
5303b68e1f86Smrg	else
5304b68e1f86Smrg	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
5305b68e1f86Smrg	fi
5306b68e1f86Smrg
5307b68e1f86Smrg	# Check to see that this really is a libtool archive.
5308b68e1f86Smrg	func_lalib_unsafe_p "$lib" \
5309b68e1f86Smrg	  || func_fatal_error "\`$lib' is not a valid libtool archive"
5310b68e1f86Smrg
5311b68e1f86Smrg	func_dirname "$lib" "" "."
5312b68e1f86Smrg	ladir="$func_dirname_result"
5313b68e1f86Smrg
5314b68e1f86Smrg	dlname=
5315b68e1f86Smrg	dlopen=
5316b68e1f86Smrg	dlpreopen=
5317b68e1f86Smrg	libdir=
5318b68e1f86Smrg	library_names=
5319b68e1f86Smrg	old_library=
5320b68e1f86Smrg	inherited_linker_flags=
5321b68e1f86Smrg	# If the library was installed with an old release of libtool,
5322b68e1f86Smrg	# it will not redefine variables installed, or shouldnotlink
5323b68e1f86Smrg	installed=yes
5324b68e1f86Smrg	shouldnotlink=no
5325b68e1f86Smrg	avoidtemprpath=
5326b68e1f86Smrg
5327b68e1f86Smrg
5328b68e1f86Smrg	# Read the .la file
5329b68e1f86Smrg	func_source "$lib"
5330b68e1f86Smrg
5331b68e1f86Smrg	# Convert "-framework foo" to "foo.ltframework"
5332b68e1f86Smrg	if test -n "$inherited_linker_flags"; then
5333b68e1f86Smrg	  tmp_inherited_linker_flags=`$ECHO "X$inherited_linker_flags" | $Xsed -e 's/-framework \([^ $]*\)/\1.ltframework/g'`
5334b68e1f86Smrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
5335b68e1f86Smrg	    case " $new_inherited_linker_flags " in
5336b68e1f86Smrg	      *" $tmp_inherited_linker_flag "*) ;;
5337b68e1f86Smrg	      *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";;
5338b68e1f86Smrg	    esac
5339b68e1f86Smrg	  done
5340b68e1f86Smrg	fi
5341b68e1f86Smrg	dependency_libs=`$ECHO "X $dependency_libs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
5342b68e1f86Smrg	if test "$linkmode,$pass" = "lib,link" ||
5343b68e1f86Smrg	   test "$linkmode,$pass" = "prog,scan" ||
5344b68e1f86Smrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
5345b68e1f86Smrg	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
5346b68e1f86Smrg	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
5347b68e1f86Smrg	fi
5348b68e1f86Smrg
5349b68e1f86Smrg	if test "$pass" = conv; then
5350b68e1f86Smrg	  # Only check for convenience libraries
5351b68e1f86Smrg	  deplibs="$lib $deplibs"
5352b68e1f86Smrg	  if test -z "$libdir"; then
5353b68e1f86Smrg	    if test -z "$old_library"; then
5354b68e1f86Smrg	      func_fatal_error "cannot find name of link library for \`$lib'"
5355b68e1f86Smrg	    fi
5356b68e1f86Smrg	    # It is a libtool convenience library, so add in its objects.
5357b68e1f86Smrg	    convenience="$convenience $ladir/$objdir/$old_library"
5358b68e1f86Smrg	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
5359b68e1f86Smrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
5360b68e1f86Smrg	    func_fatal_error "\`$lib' is not a convenience library"
5361b68e1f86Smrg	  fi
5362b68e1f86Smrg	  tmp_libs=
5363b68e1f86Smrg	  for deplib in $dependency_libs; do
5364b68e1f86Smrg	    deplibs="$deplib $deplibs"
5365b68e1f86Smrg	    if $opt_duplicate_deps ; then
5366b68e1f86Smrg	      case "$tmp_libs " in
5367b68e1f86Smrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
5368b68e1f86Smrg	      esac
5369b68e1f86Smrg	    fi
5370b68e1f86Smrg	    tmp_libs="$tmp_libs $deplib"
5371b68e1f86Smrg	  done
5372b68e1f86Smrg	  continue
5373b68e1f86Smrg	fi # $pass = conv
5374b68e1f86Smrg
5375b68e1f86Smrg
5376b68e1f86Smrg	# Get the name of the library we link against.
5377b68e1f86Smrg	linklib=
5378b68e1f86Smrg	for l in $old_library $library_names; do
5379b68e1f86Smrg	  linklib="$l"
5380b68e1f86Smrg	done
5381b68e1f86Smrg	if test -z "$linklib"; then
5382b68e1f86Smrg	  func_fatal_error "cannot find name of link library for \`$lib'"
5383b68e1f86Smrg	fi
5384b68e1f86Smrg
5385b68e1f86Smrg	# This library was specified with -dlopen.
5386b68e1f86Smrg	if test "$pass" = dlopen; then
5387b68e1f86Smrg	  if test -z "$libdir"; then
5388b68e1f86Smrg	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
5389b68e1f86Smrg	  fi
5390b68e1f86Smrg	  if test -z "$dlname" ||
5391b68e1f86Smrg	     test "$dlopen_support" != yes ||
5392b68e1f86Smrg	     test "$build_libtool_libs" = no; then
5393b68e1f86Smrg	    # If there is no dlname, no dlopen support or we're linking
5394b68e1f86Smrg	    # statically, we need to preload.  We also need to preload any
5395b68e1f86Smrg	    # dependent libraries so libltdl's deplib preloader doesn't
5396b68e1f86Smrg	    # bomb out in the load deplibs phase.
5397b68e1f86Smrg	    dlprefiles="$dlprefiles $lib $dependency_libs"
5398b68e1f86Smrg	  else
5399b68e1f86Smrg	    newdlfiles="$newdlfiles $lib"
5400b68e1f86Smrg	  fi
5401b68e1f86Smrg	  continue
5402b68e1f86Smrg	fi # $pass = dlopen
5403b68e1f86Smrg
5404b68e1f86Smrg	# We need an absolute path.
5405b68e1f86Smrg	case $ladir in
5406b68e1f86Smrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
5407b68e1f86Smrg	*)
5408b68e1f86Smrg	  abs_ladir=`cd "$ladir" && pwd`
5409b68e1f86Smrg	  if test -z "$abs_ladir"; then
5410b68e1f86Smrg	    func_warning "cannot determine absolute directory name of \`$ladir'"
5411b68e1f86Smrg	    func_warning "passing it literally to the linker, although it might fail"
5412b68e1f86Smrg	    abs_ladir="$ladir"
5413b68e1f86Smrg	  fi
5414b68e1f86Smrg	  ;;
5415b68e1f86Smrg	esac
5416b68e1f86Smrg	func_basename "$lib"
5417b68e1f86Smrg	laname="$func_basename_result"
5418b68e1f86Smrg
5419b68e1f86Smrg	# Find the relevant object directory and library name.
5420b68e1f86Smrg	if test "X$installed" = Xyes; then
5421b68e1f86Smrg	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
5422b68e1f86Smrg	    func_warning "library \`$lib' was moved."
5423b68e1f86Smrg	    dir="$ladir"
5424b68e1f86Smrg	    absdir="$abs_ladir"
5425b68e1f86Smrg	    libdir="$abs_ladir"
5426b68e1f86Smrg	  else
5427b68e1f86Smrg	    dir="$libdir"
5428b68e1f86Smrg	    absdir="$libdir"
5429b68e1f86Smrg	  fi
5430b68e1f86Smrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
5431b68e1f86Smrg	else
5432b68e1f86Smrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
5433b68e1f86Smrg	    dir="$ladir"
5434b68e1f86Smrg	    absdir="$abs_ladir"
5435b68e1f86Smrg	    # Remove this search path later
5436b68e1f86Smrg	    notinst_path="$notinst_path $abs_ladir"
5437b68e1f86Smrg	  else
5438b68e1f86Smrg	    dir="$ladir/$objdir"
5439b68e1f86Smrg	    absdir="$abs_ladir/$objdir"
5440b68e1f86Smrg	    # Remove this search path later
5441b68e1f86Smrg	    notinst_path="$notinst_path $abs_ladir"
5442b68e1f86Smrg	  fi
5443b68e1f86Smrg	fi # $installed = yes
5444b68e1f86Smrg	func_stripname 'lib' '.la' "$laname"
5445b68e1f86Smrg	name=$func_stripname_result
5446b68e1f86Smrg
5447b68e1f86Smrg	# This library was specified with -dlpreopen.
5448b68e1f86Smrg	if test "$pass" = dlpreopen; then
5449b68e1f86Smrg	  if test -z "$libdir" && test "$linkmode" = prog; then
5450b68e1f86Smrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
5451b68e1f86Smrg	  fi
5452b68e1f86Smrg	  # Prefer using a static library (so that no silly _DYNAMIC symbols
5453b68e1f86Smrg	  # are required to link).
5454b68e1f86Smrg	  if test -n "$old_library"; then
5455b68e1f86Smrg	    newdlprefiles="$newdlprefiles $dir/$old_library"
5456b68e1f86Smrg	    # Keep a list of preopened convenience libraries to check
5457b68e1f86Smrg	    # that they are being used correctly in the link pass.
5458b68e1f86Smrg	    test -z "$libdir" && \
5459b68e1f86Smrg		dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library"
5460b68e1f86Smrg	  # Otherwise, use the dlname, so that lt_dlopen finds it.
5461b68e1f86Smrg	  elif test -n "$dlname"; then
5462b68e1f86Smrg	    newdlprefiles="$newdlprefiles $dir/$dlname"
5463b68e1f86Smrg	  else
5464b68e1f86Smrg	    newdlprefiles="$newdlprefiles $dir/$linklib"
5465b68e1f86Smrg	  fi
5466b68e1f86Smrg	fi # $pass = dlpreopen
5467b68e1f86Smrg
5468b68e1f86Smrg	if test -z "$libdir"; then
5469b68e1f86Smrg	  # Link the convenience library
5470b68e1f86Smrg	  if test "$linkmode" = lib; then
5471b68e1f86Smrg	    deplibs="$dir/$old_library $deplibs"
5472b68e1f86Smrg	  elif test "$linkmode,$pass" = "prog,link"; then
5473b68e1f86Smrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
5474b68e1f86Smrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
5475b68e1f86Smrg	  else
5476b68e1f86Smrg	    deplibs="$lib $deplibs" # used for prog,scan pass
5477b68e1f86Smrg	  fi
5478b68e1f86Smrg	  continue
5479b68e1f86Smrg	fi
5480b68e1f86Smrg
5481b68e1f86Smrg
5482b68e1f86Smrg	if test "$linkmode" = prog && test "$pass" != link; then
5483b68e1f86Smrg	  newlib_search_path="$newlib_search_path $ladir"
5484b68e1f86Smrg	  deplibs="$lib $deplibs"
5485b68e1f86Smrg
5486b68e1f86Smrg	  linkalldeplibs=no
5487b68e1f86Smrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
5488b68e1f86Smrg	     test "$build_libtool_libs" = no; then
5489b68e1f86Smrg	    linkalldeplibs=yes
5490b68e1f86Smrg	  fi
5491b68e1f86Smrg
5492b68e1f86Smrg	  tmp_libs=
5493b68e1f86Smrg	  for deplib in $dependency_libs; do
5494b68e1f86Smrg	    case $deplib in
5495b68e1f86Smrg	    -L*) func_stripname '-L' '' "$deplib"
5496b68e1f86Smrg	         newlib_search_path="$newlib_search_path $func_stripname_result"
5497b68e1f86Smrg		 ;;
5498b68e1f86Smrg	    esac
5499b68e1f86Smrg	    # Need to link against all dependency_libs?
5500b68e1f86Smrg	    if test "$linkalldeplibs" = yes; then
5501b68e1f86Smrg	      deplibs="$deplib $deplibs"
5502b68e1f86Smrg	    else
5503b68e1f86Smrg	      # Need to hardcode shared library paths
5504b68e1f86Smrg	      # or/and link against static libraries
5505b68e1f86Smrg	      newdependency_libs="$deplib $newdependency_libs"
5506b68e1f86Smrg	    fi
5507b68e1f86Smrg	    if $opt_duplicate_deps ; then
5508b68e1f86Smrg	      case "$tmp_libs " in
5509b68e1f86Smrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
5510b68e1f86Smrg	      esac
5511b68e1f86Smrg	    fi
5512b68e1f86Smrg	    tmp_libs="$tmp_libs $deplib"
5513b68e1f86Smrg	  done # for deplib
5514b68e1f86Smrg	  continue
5515b68e1f86Smrg	fi # $linkmode = prog...
5516b68e1f86Smrg
5517b68e1f86Smrg	if test "$linkmode,$pass" = "prog,link"; then
5518b68e1f86Smrg	  if test -n "$library_names" &&
5519b68e1f86Smrg	     { { test "$prefer_static_libs" = no ||
5520b68e1f86Smrg	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
5521b68e1f86Smrg	       test -z "$old_library"; }; then
5522b68e1f86Smrg	    # We need to hardcode the library path
5523b68e1f86Smrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
5524b68e1f86Smrg	      # Make sure the rpath contains only unique directories.
5525b68e1f86Smrg	      case "$temp_rpath:" in
5526b68e1f86Smrg	      *"$absdir:"*) ;;
5527b68e1f86Smrg	      *) temp_rpath="$temp_rpath$absdir:" ;;
5528b68e1f86Smrg	      esac
5529b68e1f86Smrg	    fi
5530b68e1f86Smrg
5531b68e1f86Smrg	    # Hardcode the library path.
5532b68e1f86Smrg	    # Skip directories that are in the system default run-time
5533b68e1f86Smrg	    # search path.
5534b68e1f86Smrg	    case " $sys_lib_dlsearch_path " in
5535b68e1f86Smrg	    *" $absdir "*) ;;
5536b68e1f86Smrg	    *)
5537b68e1f86Smrg	      case "$compile_rpath " in
5538b68e1f86Smrg	      *" $absdir "*) ;;
5539b68e1f86Smrg	      *) compile_rpath="$compile_rpath $absdir"
5540b68e1f86Smrg	      esac
5541b68e1f86Smrg	      ;;
5542b68e1f86Smrg	    esac
5543b68e1f86Smrg	    case " $sys_lib_dlsearch_path " in
5544b68e1f86Smrg	    *" $libdir "*) ;;
5545b68e1f86Smrg	    *)
5546b68e1f86Smrg	      case "$finalize_rpath " in
5547b68e1f86Smrg	      *" $libdir "*) ;;
5548b68e1f86Smrg	      *) finalize_rpath="$finalize_rpath $libdir"
5549b68e1f86Smrg	      esac
5550b68e1f86Smrg	      ;;
5551b68e1f86Smrg	    esac
5552b68e1f86Smrg	  fi # $linkmode,$pass = prog,link...
5553b68e1f86Smrg
5554b68e1f86Smrg	  if test "$alldeplibs" = yes &&
5555b68e1f86Smrg	     { test "$deplibs_check_method" = pass_all ||
5556b68e1f86Smrg	       { test "$build_libtool_libs" = yes &&
5557b68e1f86Smrg		 test -n "$library_names"; }; }; then
5558b68e1f86Smrg	    # We only need to search for static libraries
5559b68e1f86Smrg	    continue
5560b68e1f86Smrg	  fi
5561b68e1f86Smrg	fi
5562b68e1f86Smrg
5563b68e1f86Smrg	link_static=no # Whether the deplib will be linked statically
5564b68e1f86Smrg	use_static_libs=$prefer_static_libs
5565b68e1f86Smrg	if test "$use_static_libs" = built && test "$installed" = yes; then
5566b68e1f86Smrg	  use_static_libs=no
5567b68e1f86Smrg	fi
5568b68e1f86Smrg	if test -n "$library_names" &&
5569b68e1f86Smrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
5570b68e1f86Smrg	  case $host in
5571b68e1f86Smrg	  *cygwin* | *mingw* | *cegcc*)
5572b68e1f86Smrg	      # No point in relinking DLLs because paths are not encoded
5573b68e1f86Smrg	      notinst_deplibs="$notinst_deplibs $lib"
5574b68e1f86Smrg	      need_relink=no
5575b68e1f86Smrg	    ;;
5576b68e1f86Smrg	  *)
5577b68e1f86Smrg	    if test "$installed" = no; then
5578b68e1f86Smrg	      notinst_deplibs="$notinst_deplibs $lib"
5579b68e1f86Smrg	      need_relink=yes
5580b68e1f86Smrg	    fi
5581b68e1f86Smrg	    ;;
5582b68e1f86Smrg	  esac
5583b68e1f86Smrg	  # This is a shared library
5584b68e1f86Smrg
5585b68e1f86Smrg	  # Warn about portability, can't link against -module's on some
5586b68e1f86Smrg	  # systems (darwin).  Don't bleat about dlopened modules though!
5587b68e1f86Smrg	  dlopenmodule=""
5588b68e1f86Smrg	  for dlpremoduletest in $dlprefiles; do
5589b68e1f86Smrg	    if test "X$dlpremoduletest" = "X$lib"; then
5590b68e1f86Smrg	      dlopenmodule="$dlpremoduletest"
5591b68e1f86Smrg	      break
5592b68e1f86Smrg	    fi
5593b68e1f86Smrg	  done
5594b68e1f86Smrg	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
5595b68e1f86Smrg	    $ECHO
5596b68e1f86Smrg	    if test "$linkmode" = prog; then
5597b68e1f86Smrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
5598b68e1f86Smrg	    else
5599b68e1f86Smrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
5600b68e1f86Smrg	    fi
5601b68e1f86Smrg	    $ECHO "*** $linklib is not portable!"
5602b68e1f86Smrg	  fi
5603b68e1f86Smrg	  if test "$linkmode" = lib &&
5604b68e1f86Smrg	     test "$hardcode_into_libs" = yes; then
5605b68e1f86Smrg	    # Hardcode the library path.
5606b68e1f86Smrg	    # Skip directories that are in the system default run-time
5607b68e1f86Smrg	    # search path.
5608b68e1f86Smrg	    case " $sys_lib_dlsearch_path " in
5609b68e1f86Smrg	    *" $absdir "*) ;;
5610b68e1f86Smrg	    *)
5611b68e1f86Smrg	      case "$compile_rpath " in
5612b68e1f86Smrg	      *" $absdir "*) ;;
5613b68e1f86Smrg	      *) compile_rpath="$compile_rpath $absdir"
5614b68e1f86Smrg	      esac
5615b68e1f86Smrg	      ;;
5616b68e1f86Smrg	    esac
5617b68e1f86Smrg	    case " $sys_lib_dlsearch_path " in
5618b68e1f86Smrg	    *" $libdir "*) ;;
5619b68e1f86Smrg	    *)
5620b68e1f86Smrg	      case "$finalize_rpath " in
5621b68e1f86Smrg	      *" $libdir "*) ;;
5622b68e1f86Smrg	      *) finalize_rpath="$finalize_rpath $libdir"
5623b68e1f86Smrg	      esac
5624b68e1f86Smrg	      ;;
5625b68e1f86Smrg	    esac
5626b68e1f86Smrg	  fi
5627b68e1f86Smrg
5628b68e1f86Smrg	  if test -n "$old_archive_from_expsyms_cmds"; then
5629b68e1f86Smrg	    # figure out the soname
5630b68e1f86Smrg	    set dummy $library_names
5631b68e1f86Smrg	    shift
5632b68e1f86Smrg	    realname="$1"
5633b68e1f86Smrg	    shift
5634b68e1f86Smrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
5635b68e1f86Smrg	    # use dlname if we got it. it's perfectly good, no?
5636b68e1f86Smrg	    if test -n "$dlname"; then
5637b68e1f86Smrg	      soname="$dlname"
5638b68e1f86Smrg	    elif test -n "$soname_spec"; then
5639b68e1f86Smrg	      # bleh windows
5640b68e1f86Smrg	      case $host in
5641b68e1f86Smrg	      *cygwin* | mingw* | *cegcc*)
5642b68e1f86Smrg	        func_arith $current - $age
5643b68e1f86Smrg		major=$func_arith_result
5644b68e1f86Smrg		versuffix="-$major"
5645b68e1f86Smrg		;;
5646b68e1f86Smrg	      esac
5647b68e1f86Smrg	      eval soname=\"$soname_spec\"
5648b68e1f86Smrg	    else
5649b68e1f86Smrg	      soname="$realname"
5650b68e1f86Smrg	    fi
5651b68e1f86Smrg
5652b68e1f86Smrg	    # Make a new name for the extract_expsyms_cmds to use
5653b68e1f86Smrg	    soroot="$soname"
5654b68e1f86Smrg	    func_basename "$soroot"
5655b68e1f86Smrg	    soname="$func_basename_result"
5656b68e1f86Smrg	    func_stripname 'lib' '.dll' "$soname"
5657b68e1f86Smrg	    newlib=libimp-$func_stripname_result.a
5658b68e1f86Smrg
5659b68e1f86Smrg	    # If the library has no export list, then create one now
5660b68e1f86Smrg	    if test -f "$output_objdir/$soname-def"; then :
5661b68e1f86Smrg	    else
5662b68e1f86Smrg	      func_verbose "extracting exported symbol list from \`$soname'"
5663b68e1f86Smrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
5664b68e1f86Smrg	    fi
5665b68e1f86Smrg
5666b68e1f86Smrg	    # Create $newlib
5667b68e1f86Smrg	    if test -f "$output_objdir/$newlib"; then :; else
5668b68e1f86Smrg	      func_verbose "generating import library for \`$soname'"
5669b68e1f86Smrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
5670b68e1f86Smrg	    fi
5671b68e1f86Smrg	    # make sure the library variables are pointing to the new library
5672b68e1f86Smrg	    dir=$output_objdir
5673b68e1f86Smrg	    linklib=$newlib
5674b68e1f86Smrg	  fi # test -n "$old_archive_from_expsyms_cmds"
5675b68e1f86Smrg
5676b68e1f86Smrg	  if test "$linkmode" = prog || test "$mode" != relink; then
5677b68e1f86Smrg	    add_shlibpath=
5678b68e1f86Smrg	    add_dir=
5679b68e1f86Smrg	    add=
5680b68e1f86Smrg	    lib_linked=yes
5681b68e1f86Smrg	    case $hardcode_action in
5682b68e1f86Smrg	    immediate | unsupported)
5683b68e1f86Smrg	      if test "$hardcode_direct" = no; then
5684b68e1f86Smrg		add="$dir/$linklib"
5685b68e1f86Smrg		case $host in
5686b68e1f86Smrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
5687b68e1f86Smrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
5688b68e1f86Smrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
5689b68e1f86Smrg		    *-*-unixware7*) add_dir="-L$dir" ;;
5690b68e1f86Smrg		  *-*-darwin* )
5691b68e1f86Smrg		    # if the lib is a (non-dlopened) module then we can not
5692b68e1f86Smrg		    # link against it, someone is ignoring the earlier warnings
5693b68e1f86Smrg		    if /usr/bin/file -L $add 2> /dev/null |
5694b68e1f86Smrg			 $GREP ": [^:]* bundle" >/dev/null ; then
5695b68e1f86Smrg		      if test "X$dlopenmodule" != "X$lib"; then
5696b68e1f86Smrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
5697b68e1f86Smrg			if test -z "$old_library" ; then
5698b68e1f86Smrg			  $ECHO
5699b68e1f86Smrg			  $ECHO "*** And there doesn't seem to be a static archive available"
5700b68e1f86Smrg			  $ECHO "*** The link will probably fail, sorry"
5701b68e1f86Smrg			else
5702b68e1f86Smrg			  add="$dir/$old_library"
5703b68e1f86Smrg			fi
5704b68e1f86Smrg		      elif test -n "$old_library"; then
5705b68e1f86Smrg			add="$dir/$old_library"
5706b68e1f86Smrg		      fi
5707b68e1f86Smrg		    fi
5708b68e1f86Smrg		esac
5709b68e1f86Smrg	      elif test "$hardcode_minus_L" = no; then
5710b68e1f86Smrg		case $host in
5711b68e1f86Smrg		*-*-sunos*) add_shlibpath="$dir" ;;
5712b68e1f86Smrg		esac
5713b68e1f86Smrg		add_dir="-L$dir"
5714b68e1f86Smrg		add="-l$name"
5715b68e1f86Smrg	      elif test "$hardcode_shlibpath_var" = no; then
5716b68e1f86Smrg		add_shlibpath="$dir"
5717b68e1f86Smrg		add="-l$name"
5718b68e1f86Smrg	      else
5719b68e1f86Smrg		lib_linked=no
5720b68e1f86Smrg	      fi
5721b68e1f86Smrg	      ;;
5722b68e1f86Smrg	    relink)
5723b68e1f86Smrg	      if test "$hardcode_direct" = yes &&
5724b68e1f86Smrg	         test "$hardcode_direct_absolute" = no; then
5725b68e1f86Smrg		add="$dir/$linklib"
5726b68e1f86Smrg	      elif test "$hardcode_minus_L" = yes; then
5727b68e1f86Smrg		add_dir="-L$dir"
5728b68e1f86Smrg		# Try looking first in the location we're being installed to.
5729b68e1f86Smrg		if test -n "$inst_prefix_dir"; then
5730b68e1f86Smrg		  case $libdir in
5731b68e1f86Smrg		    [\\/]*)
5732b68e1f86Smrg		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
5733b68e1f86Smrg		      ;;
5734b68e1f86Smrg		  esac
5735b68e1f86Smrg		fi
5736b68e1f86Smrg		add="-l$name"
5737b68e1f86Smrg	      elif test "$hardcode_shlibpath_var" = yes; then
5738b68e1f86Smrg		add_shlibpath="$dir"
5739b68e1f86Smrg		add="-l$name"
5740b68e1f86Smrg	      else
5741b68e1f86Smrg		lib_linked=no
5742b68e1f86Smrg	      fi
5743b68e1f86Smrg	      ;;
5744b68e1f86Smrg	    *) lib_linked=no ;;
5745b68e1f86Smrg	    esac
5746b68e1f86Smrg
5747b68e1f86Smrg	    if test "$lib_linked" != yes; then
5748b68e1f86Smrg	      func_fatal_configuration "unsupported hardcode properties"
5749b68e1f86Smrg	    fi
5750b68e1f86Smrg
5751b68e1f86Smrg	    if test -n "$add_shlibpath"; then
5752b68e1f86Smrg	      case :$compile_shlibpath: in
5753b68e1f86Smrg	      *":$add_shlibpath:"*) ;;
5754b68e1f86Smrg	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
5755b68e1f86Smrg	      esac
5756b68e1f86Smrg	    fi
5757b68e1f86Smrg	    if test "$linkmode" = prog; then
5758b68e1f86Smrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
5759b68e1f86Smrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
5760b68e1f86Smrg	    else
5761b68e1f86Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
5762b68e1f86Smrg	      test -n "$add" && deplibs="$add $deplibs"
5763b68e1f86Smrg	      if test "$hardcode_direct" != yes &&
5764b68e1f86Smrg		 test "$hardcode_minus_L" != yes &&
5765b68e1f86Smrg		 test "$hardcode_shlibpath_var" = yes; then
5766b68e1f86Smrg		case :$finalize_shlibpath: in
5767b68e1f86Smrg		*":$libdir:"*) ;;
5768b68e1f86Smrg		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
5769b68e1f86Smrg		esac
5770b68e1f86Smrg	      fi
5771b68e1f86Smrg	    fi
5772b68e1f86Smrg	  fi
5773b68e1f86Smrg
5774b68e1f86Smrg	  if test "$linkmode" = prog || test "$mode" = relink; then
5775b68e1f86Smrg	    add_shlibpath=
5776b68e1f86Smrg	    add_dir=
5777b68e1f86Smrg	    add=
5778b68e1f86Smrg	    # Finalize command for both is simple: just hardcode it.
5779b68e1f86Smrg	    if test "$hardcode_direct" = yes &&
5780b68e1f86Smrg	       test "$hardcode_direct_absolute" = no; then
5781b68e1f86Smrg	      add="$libdir/$linklib"
5782b68e1f86Smrg	    elif test "$hardcode_minus_L" = yes; then
5783b68e1f86Smrg	      add_dir="-L$libdir"
5784b68e1f86Smrg	      add="-l$name"
5785b68e1f86Smrg	    elif test "$hardcode_shlibpath_var" = yes; then
5786b68e1f86Smrg	      case :$finalize_shlibpath: in
5787b68e1f86Smrg	      *":$libdir:"*) ;;
5788b68e1f86Smrg	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
5789b68e1f86Smrg	      esac
5790b68e1f86Smrg	      add="-l$name"
5791b68e1f86Smrg	    elif test "$hardcode_automatic" = yes; then
5792b68e1f86Smrg	      if test -n "$inst_prefix_dir" &&
5793b68e1f86Smrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
5794b68e1f86Smrg		add="$inst_prefix_dir$libdir/$linklib"
5795b68e1f86Smrg	      else
5796b68e1f86Smrg		add="$libdir/$linklib"
5797b68e1f86Smrg	      fi
5798b68e1f86Smrg	    else
5799b68e1f86Smrg	      # We cannot seem to hardcode it, guess we'll fake it.
5800b68e1f86Smrg	      add_dir="-L$libdir"
5801b68e1f86Smrg	      # Try looking first in the location we're being installed to.
5802b68e1f86Smrg	      if test -n "$inst_prefix_dir"; then
5803b68e1f86Smrg		case $libdir in
5804b68e1f86Smrg		  [\\/]*)
5805b68e1f86Smrg		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
5806b68e1f86Smrg		    ;;
5807b68e1f86Smrg		esac
5808b68e1f86Smrg	      fi
5809b68e1f86Smrg	      add="-l$name"
5810b68e1f86Smrg	    fi
5811b68e1f86Smrg
5812b68e1f86Smrg	    if test "$linkmode" = prog; then
5813b68e1f86Smrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
5814b68e1f86Smrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
5815b68e1f86Smrg	    else
5816b68e1f86Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
5817b68e1f86Smrg	      test -n "$add" && deplibs="$add $deplibs"
5818b68e1f86Smrg	    fi
5819b68e1f86Smrg	  fi
5820b68e1f86Smrg	elif test "$linkmode" = prog; then
5821b68e1f86Smrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
5822b68e1f86Smrg	  # is not unsupported.  This is valid on all known static and
5823b68e1f86Smrg	  # shared platforms.
5824b68e1f86Smrg	  if test "$hardcode_direct" != unsupported; then
5825b68e1f86Smrg	    test -n "$old_library" && linklib="$old_library"
5826b68e1f86Smrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
5827b68e1f86Smrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
5828b68e1f86Smrg	  else
5829b68e1f86Smrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
5830b68e1f86Smrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
5831b68e1f86Smrg	  fi
5832b68e1f86Smrg	elif test "$build_libtool_libs" = yes; then
5833b68e1f86Smrg	  # Not a shared library
5834b68e1f86Smrg	  if test "$deplibs_check_method" != pass_all; then
5835b68e1f86Smrg	    # We're trying link a shared library against a static one
5836b68e1f86Smrg	    # but the system doesn't support it.
5837b68e1f86Smrg
5838b68e1f86Smrg	    # Just print a warning and add the library to dependency_libs so
5839b68e1f86Smrg	    # that the program can be linked against the static library.
5840b68e1f86Smrg	    $ECHO
5841b68e1f86Smrg	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
5842b68e1f86Smrg	    $ECHO "*** I have the capability to make that library automatically link in when"
5843b68e1f86Smrg	    $ECHO "*** you link to this library.  But I can only do this if you have a"
5844b68e1f86Smrg	    $ECHO "*** shared version of the library, which you do not appear to have."
5845b68e1f86Smrg	    if test "$module" = yes; then
5846b68e1f86Smrg	      $ECHO "*** But as you try to build a module library, libtool will still create "
5847b68e1f86Smrg	      $ECHO "*** a static module, that should work as long as the dlopening application"
5848b68e1f86Smrg	      $ECHO "*** is linked with the -dlopen flag to resolve symbols at runtime."
5849b68e1f86Smrg	      if test -z "$global_symbol_pipe"; then
5850b68e1f86Smrg		$ECHO
5851b68e1f86Smrg		$ECHO "*** However, this would only work if libtool was able to extract symbol"
5852b68e1f86Smrg		$ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
5853b68e1f86Smrg		$ECHO "*** not find such a program.  So, this module is probably useless."
5854b68e1f86Smrg		$ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
5855b68e1f86Smrg	      fi
5856b68e1f86Smrg	      if test "$build_old_libs" = no; then
5857b68e1f86Smrg		build_libtool_libs=module
5858b68e1f86Smrg		build_old_libs=yes
5859b68e1f86Smrg	      else
5860b68e1f86Smrg		build_libtool_libs=no
5861b68e1f86Smrg	      fi
5862b68e1f86Smrg	    fi
5863b68e1f86Smrg	  else
5864b68e1f86Smrg	    deplibs="$dir/$old_library $deplibs"
5865b68e1f86Smrg	    link_static=yes
5866b68e1f86Smrg	  fi
5867b68e1f86Smrg	fi # link shared/static library?
5868b68e1f86Smrg
5869b68e1f86Smrg	if test "$linkmode" = lib; then
5870b68e1f86Smrg	  if test -n "$dependency_libs" &&
5871b68e1f86Smrg	     { test "$hardcode_into_libs" != yes ||
5872b68e1f86Smrg	       test "$build_old_libs" = yes ||
5873b68e1f86Smrg	       test "$link_static" = yes; }; then
5874b68e1f86Smrg	    # Extract -R from dependency_libs
5875b68e1f86Smrg	    temp_deplibs=
5876b68e1f86Smrg	    for libdir in $dependency_libs; do
5877b68e1f86Smrg	      case $libdir in
5878b68e1f86Smrg	      -R*) func_stripname '-R' '' "$libdir"
5879b68e1f86Smrg	           temp_xrpath=$func_stripname_result
5880b68e1f86Smrg		   case " $xrpath " in
5881b68e1f86Smrg		   *" $temp_xrpath "*) ;;
5882b68e1f86Smrg		   *) xrpath="$xrpath $temp_xrpath";;
5883b68e1f86Smrg		   esac;;
5884b68e1f86Smrg	      *) temp_deplibs="$temp_deplibs $libdir";;
5885b68e1f86Smrg	      esac
5886b68e1f86Smrg	    done
5887b68e1f86Smrg	    dependency_libs="$temp_deplibs"
5888b68e1f86Smrg	  fi
5889b68e1f86Smrg
5890b68e1f86Smrg	  newlib_search_path="$newlib_search_path $absdir"
5891b68e1f86Smrg	  # Link against this library
5892b68e1f86Smrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
5893b68e1f86Smrg	  # ... and its dependency_libs
5894b68e1f86Smrg	  tmp_libs=
5895b68e1f86Smrg	  for deplib in $dependency_libs; do
5896b68e1f86Smrg	    newdependency_libs="$deplib $newdependency_libs"
5897b68e1f86Smrg	    if $opt_duplicate_deps ; then
5898b68e1f86Smrg	      case "$tmp_libs " in
5899b68e1f86Smrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
5900b68e1f86Smrg	      esac
5901b68e1f86Smrg	    fi
5902b68e1f86Smrg	    tmp_libs="$tmp_libs $deplib"
5903b68e1f86Smrg	  done
5904b68e1f86Smrg
5905b68e1f86Smrg	  if test "$link_all_deplibs" != no; then
5906b68e1f86Smrg	    # Add the search paths of all dependency libraries
5907b68e1f86Smrg	    for deplib in $dependency_libs; do
5908b68e1f86Smrg	      case $deplib in
5909b68e1f86Smrg	      -L*) path="$deplib" ;;
5910b68e1f86Smrg	      *.la)
5911b68e1f86Smrg	        func_dirname "$deplib" "" "."
5912b68e1f86Smrg		dir="$func_dirname_result"
5913b68e1f86Smrg		# We need an absolute path.
5914b68e1f86Smrg		case $dir in
5915b68e1f86Smrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
5916b68e1f86Smrg		*)
5917b68e1f86Smrg		  absdir=`cd "$dir" && pwd`
5918b68e1f86Smrg		  if test -z "$absdir"; then
5919b68e1f86Smrg		    func_warning "cannot determine absolute directory name of \`$dir'"
5920b68e1f86Smrg		    absdir="$dir"
5921b68e1f86Smrg		  fi
5922b68e1f86Smrg		  ;;
5923b68e1f86Smrg		esac
5924b68e1f86Smrg		if $GREP "^installed=no" $deplib > /dev/null; then
5925b68e1f86Smrg		case $host in
5926b68e1f86Smrg		*-*-darwin*)
5927b68e1f86Smrg		  depdepl=
5928b68e1f86Smrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
5929b68e1f86Smrg		  if test -n "$deplibrary_names" ; then
5930b68e1f86Smrg		    for tmp in $deplibrary_names ; do
5931b68e1f86Smrg		      depdepl=$tmp
5932b68e1f86Smrg		    done
5933b68e1f86Smrg		    if test -f "$absdir/$objdir/$depdepl" ; then
5934b68e1f86Smrg		      depdepl="$absdir/$objdir/$depdepl"
5935b68e1f86Smrg		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
5936b68e1f86Smrg                      if test -z "$darwin_install_name"; then
5937b68e1f86Smrg                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
5938b68e1f86Smrg                      fi
5939b68e1f86Smrg		      compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
5940b68e1f86Smrg		      linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}"
5941b68e1f86Smrg		      path=
5942b68e1f86Smrg		    fi
5943b68e1f86Smrg		  fi
5944b68e1f86Smrg		  ;;
5945b68e1f86Smrg		*)
5946b68e1f86Smrg		  path="-L$absdir/$objdir"
5947b68e1f86Smrg		  ;;
5948b68e1f86Smrg		esac
5949b68e1f86Smrg		else
5950b68e1f86Smrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
5951b68e1f86Smrg		  test -z "$libdir" && \
5952b68e1f86Smrg		    func_fatal_error "\`$deplib' is not a valid libtool archive"
5953b68e1f86Smrg		  test "$absdir" != "$libdir" && \
5954b68e1f86Smrg		    func_warning "\`$deplib' seems to be moved"
5955b68e1f86Smrg
5956b68e1f86Smrg		  path="-L$absdir"
5957b68e1f86Smrg		fi
5958b68e1f86Smrg		;;
5959b68e1f86Smrg	      esac
5960b68e1f86Smrg	      case " $deplibs " in
5961b68e1f86Smrg	      *" $path "*) ;;
5962b68e1f86Smrg	      *) deplibs="$path $deplibs" ;;
5963b68e1f86Smrg	      esac
5964b68e1f86Smrg	    done
5965b68e1f86Smrg	  fi # link_all_deplibs != no
5966b68e1f86Smrg	fi # linkmode = lib
5967b68e1f86Smrg      done # for deplib in $libs
5968b68e1f86Smrg      if test "$pass" = link; then
5969b68e1f86Smrg	if test "$linkmode" = "prog"; then
5970b68e1f86Smrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
5971b68e1f86Smrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
5972b68e1f86Smrg	else
5973b68e1f86Smrg	  compiler_flags="$compiler_flags "`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
5974b68e1f86Smrg	fi
5975b68e1f86Smrg      fi
5976b68e1f86Smrg      dependency_libs="$newdependency_libs"
5977b68e1f86Smrg      if test "$pass" = dlpreopen; then
5978b68e1f86Smrg	# Link the dlpreopened libraries before other libraries
5979b68e1f86Smrg	for deplib in $save_deplibs; do
5980b68e1f86Smrg	  deplibs="$deplib $deplibs"
5981b68e1f86Smrg	done
5982b68e1f86Smrg      fi
5983b68e1f86Smrg      if test "$pass" != dlopen; then
5984b68e1f86Smrg	if test "$pass" != conv; then
5985b68e1f86Smrg	  # Make sure lib_search_path contains only unique directories.
5986b68e1f86Smrg	  lib_search_path=
5987b68e1f86Smrg	  for dir in $newlib_search_path; do
5988b68e1f86Smrg	    case "$lib_search_path " in
5989b68e1f86Smrg	    *" $dir "*) ;;
5990b68e1f86Smrg	    *) lib_search_path="$lib_search_path $dir" ;;
5991b68e1f86Smrg	    esac
5992b68e1f86Smrg	  done
5993b68e1f86Smrg	  newlib_search_path=
5994b68e1f86Smrg	fi
5995b68e1f86Smrg
5996b68e1f86Smrg	if test "$linkmode,$pass" != "prog,link"; then
5997b68e1f86Smrg	  vars="deplibs"
5998b68e1f86Smrg	else
5999b68e1f86Smrg	  vars="compile_deplibs finalize_deplibs"
6000b68e1f86Smrg	fi
6001b68e1f86Smrg	for var in $vars dependency_libs; do
6002b68e1f86Smrg	  # Add libraries to $var in reverse order
6003b68e1f86Smrg	  eval tmp_libs=\"\$$var\"
6004b68e1f86Smrg	  new_libs=
6005b68e1f86Smrg	  for deplib in $tmp_libs; do
6006b68e1f86Smrg	    # FIXME: Pedantically, this is the right thing to do, so
6007b68e1f86Smrg	    #        that some nasty dependency loop isn't accidentally
6008b68e1f86Smrg	    #        broken:
6009b68e1f86Smrg	    #new_libs="$deplib $new_libs"
6010b68e1f86Smrg	    # Pragmatically, this seems to cause very few problems in
6011b68e1f86Smrg	    # practice:
6012b68e1f86Smrg	    case $deplib in
6013b68e1f86Smrg	    -L*) new_libs="$deplib $new_libs" ;;
6014b68e1f86Smrg	    -R*) ;;
6015b68e1f86Smrg	    *)
6016b68e1f86Smrg	      # And here is the reason: when a library appears more
6017b68e1f86Smrg	      # than once as an explicit dependence of a library, or
6018b68e1f86Smrg	      # is implicitly linked in more than once by the
6019b68e1f86Smrg	      # compiler, it is considered special, and multiple
6020b68e1f86Smrg	      # occurrences thereof are not removed.  Compare this
6021b68e1f86Smrg	      # with having the same library being listed as a
6022b68e1f86Smrg	      # dependency of multiple other libraries: in this case,
6023b68e1f86Smrg	      # we know (pedantically, we assume) the library does not
6024b68e1f86Smrg	      # need to be listed more than once, so we keep only the
6025b68e1f86Smrg	      # last copy.  This is not always right, but it is rare
6026b68e1f86Smrg	      # enough that we require users that really mean to play
6027b68e1f86Smrg	      # such unportable linking tricks to link the library
6028b68e1f86Smrg	      # using -Wl,-lname, so that libtool does not consider it
6029b68e1f86Smrg	      # for duplicate removal.
6030b68e1f86Smrg	      case " $specialdeplibs " in
6031b68e1f86Smrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
6032b68e1f86Smrg	      *)
6033b68e1f86Smrg		case " $new_libs " in
6034b68e1f86Smrg		*" $deplib "*) ;;
6035b68e1f86Smrg		*) new_libs="$deplib $new_libs" ;;
6036b68e1f86Smrg		esac
6037b68e1f86Smrg		;;
6038b68e1f86Smrg	      esac
6039b68e1f86Smrg	      ;;
6040b68e1f86Smrg	    esac
6041b68e1f86Smrg	  done
6042b68e1f86Smrg	  tmp_libs=
6043b68e1f86Smrg	  for deplib in $new_libs; do
6044b68e1f86Smrg	    case $deplib in
6045b68e1f86Smrg	    -L*)
6046b68e1f86Smrg	      case " $tmp_libs " in
6047b68e1f86Smrg	      *" $deplib "*) ;;
6048b68e1f86Smrg	      *) tmp_libs="$tmp_libs $deplib" ;;
6049b68e1f86Smrg	      esac
6050b68e1f86Smrg	      ;;
6051b68e1f86Smrg	    *) tmp_libs="$tmp_libs $deplib" ;;
6052b68e1f86Smrg	    esac
6053b68e1f86Smrg	  done
6054b68e1f86Smrg	  eval $var=\"$tmp_libs\"
6055b68e1f86Smrg	done # for var
6056b68e1f86Smrg      fi
6057b68e1f86Smrg      # Last step: remove runtime libs from dependency_libs
6058b68e1f86Smrg      # (they stay in deplibs)
6059b68e1f86Smrg      tmp_libs=
6060b68e1f86Smrg      for i in $dependency_libs ; do
6061b68e1f86Smrg	case " $predeps $postdeps $compiler_lib_search_path " in
6062b68e1f86Smrg	*" $i "*)
6063b68e1f86Smrg	  i=""
6064b68e1f86Smrg	  ;;
6065b68e1f86Smrg	esac
6066b68e1f86Smrg	if test -n "$i" ; then
6067b68e1f86Smrg	  tmp_libs="$tmp_libs $i"
6068b68e1f86Smrg	fi
6069b68e1f86Smrg      done
6070b68e1f86Smrg      dependency_libs=$tmp_libs
6071b68e1f86Smrg    done # for pass
6072b68e1f86Smrg    if test "$linkmode" = prog; then
6073b68e1f86Smrg      dlfiles="$newdlfiles"
6074b68e1f86Smrg    fi
6075b68e1f86Smrg    if test "$linkmode" = prog || test "$linkmode" = lib; then
6076b68e1f86Smrg      dlprefiles="$newdlprefiles"
6077b68e1f86Smrg    fi
6078b68e1f86Smrg
6079b68e1f86Smrg    case $linkmode in
6080b68e1f86Smrg    oldlib)
6081b68e1f86Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
6082b68e1f86Smrg	func_warning "\`-dlopen' is ignored for archives"
6083b68e1f86Smrg      fi
6084b68e1f86Smrg
6085b68e1f86Smrg      case " $deplibs" in
6086b68e1f86Smrg      *\ -l* | *\ -L*)
6087b68e1f86Smrg	func_warning "\`-l' and \`-L' are ignored for archives" ;;
6088b68e1f86Smrg      esac
6089b68e1f86Smrg
6090b68e1f86Smrg      test -n "$rpath" && \
6091b68e1f86Smrg	func_warning "\`-rpath' is ignored for archives"
6092b68e1f86Smrg
6093b68e1f86Smrg      test -n "$xrpath" && \
6094b68e1f86Smrg	func_warning "\`-R' is ignored for archives"
6095b68e1f86Smrg
6096b68e1f86Smrg      test -n "$vinfo" && \
6097b68e1f86Smrg	func_warning "\`-version-info/-version-number' is ignored for archives"
6098b68e1f86Smrg
6099b68e1f86Smrg      test -n "$release" && \
6100b68e1f86Smrg	func_warning "\`-release' is ignored for archives"
6101b68e1f86Smrg
6102b68e1f86Smrg      test -n "$export_symbols$export_symbols_regex" && \
6103b68e1f86Smrg	func_warning "\`-export-symbols' is ignored for archives"
6104b68e1f86Smrg
6105b68e1f86Smrg      # Now set the variables for building old libraries.
6106b68e1f86Smrg      build_libtool_libs=no
6107b68e1f86Smrg      oldlibs="$output"
6108b68e1f86Smrg      objs="$objs$old_deplibs"
6109b68e1f86Smrg      ;;
6110b68e1f86Smrg
6111b68e1f86Smrg    lib)
6112b68e1f86Smrg      # Make sure we only generate libraries of the form `libNAME.la'.
6113b68e1f86Smrg      case $outputname in
6114b68e1f86Smrg      lib*)
6115b68e1f86Smrg	func_stripname 'lib' '.la' "$outputname"
6116b68e1f86Smrg	name=$func_stripname_result
6117b68e1f86Smrg	eval shared_ext=\"$shrext_cmds\"
6118b68e1f86Smrg	eval libname=\"$libname_spec\"
6119b68e1f86Smrg	;;
6120b68e1f86Smrg      *)
6121b68e1f86Smrg	test "$module" = no && \
6122b68e1f86Smrg	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
6123b68e1f86Smrg
6124b68e1f86Smrg	if test "$need_lib_prefix" != no; then
6125b68e1f86Smrg	  # Add the "lib" prefix for modules if required
6126b68e1f86Smrg	  func_stripname '' '.la' "$outputname"
6127b68e1f86Smrg	  name=$func_stripname_result
6128b68e1f86Smrg	  eval shared_ext=\"$shrext_cmds\"
6129b68e1f86Smrg	  eval libname=\"$libname_spec\"
6130b68e1f86Smrg	else
6131b68e1f86Smrg	  func_stripname '' '.la' "$outputname"
6132b68e1f86Smrg	  libname=$func_stripname_result
6133b68e1f86Smrg	fi
6134b68e1f86Smrg	;;
6135b68e1f86Smrg      esac
6136b68e1f86Smrg
6137b68e1f86Smrg      if test -n "$objs"; then
6138b68e1f86Smrg	if test "$deplibs_check_method" != pass_all; then
6139b68e1f86Smrg	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
6140b68e1f86Smrg	else
6141b68e1f86Smrg	  $ECHO
6142b68e1f86Smrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
6143b68e1f86Smrg	  $ECHO "*** objects $objs is not portable!"
6144b68e1f86Smrg	  libobjs="$libobjs $objs"
6145b68e1f86Smrg	fi
6146b68e1f86Smrg      fi
6147b68e1f86Smrg
6148b68e1f86Smrg      test "$dlself" != no && \
6149b68e1f86Smrg	func_warning "\`-dlopen self' is ignored for libtool libraries"
6150b68e1f86Smrg
6151b68e1f86Smrg      set dummy $rpath
6152b68e1f86Smrg      shift
6153b68e1f86Smrg      test "$#" -gt 1 && \
6154b68e1f86Smrg	func_warning "ignoring multiple \`-rpath's for a libtool library"
6155b68e1f86Smrg
6156b68e1f86Smrg      install_libdir="$1"
6157b68e1f86Smrg
6158b68e1f86Smrg      oldlibs=
6159b68e1f86Smrg      if test -z "$rpath"; then
6160b68e1f86Smrg	if test "$build_libtool_libs" = yes; then
6161b68e1f86Smrg	  # Building a libtool convenience library.
6162b68e1f86Smrg	  # Some compilers have problems with a `.al' extension so
6163b68e1f86Smrg	  # convenience libraries should have the same extension an
6164b68e1f86Smrg	  # archive normally would.
6165b68e1f86Smrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
6166b68e1f86Smrg	  build_libtool_libs=convenience
6167b68e1f86Smrg	  build_old_libs=yes
6168b68e1f86Smrg	fi
6169b68e1f86Smrg
6170b68e1f86Smrg	test -n "$vinfo" && \
6171b68e1f86Smrg	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
6172b68e1f86Smrg
6173b68e1f86Smrg	test -n "$release" && \
6174b68e1f86Smrg	  func_warning "\`-release' is ignored for convenience libraries"
6175b68e1f86Smrg      else
6176b68e1f86Smrg
6177b68e1f86Smrg	# Parse the version information argument.
6178b68e1f86Smrg	save_ifs="$IFS"; IFS=':'
6179b68e1f86Smrg	set dummy $vinfo 0 0 0
6180b68e1f86Smrg	shift
6181b68e1f86Smrg	IFS="$save_ifs"
6182b68e1f86Smrg
6183b68e1f86Smrg	test -n "$7" && \
6184b68e1f86Smrg	  func_fatal_help "too many parameters to \`-version-info'"
6185b68e1f86Smrg
6186b68e1f86Smrg	# convert absolute version numbers to libtool ages
6187b68e1f86Smrg	# this retains compatibility with .la files and attempts
6188b68e1f86Smrg	# to make the code below a bit more comprehensible
6189b68e1f86Smrg
6190b68e1f86Smrg	case $vinfo_number in
6191b68e1f86Smrg	yes)
6192b68e1f86Smrg	  number_major="$1"
6193b68e1f86Smrg	  number_minor="$2"
6194b68e1f86Smrg	  number_revision="$3"
6195b68e1f86Smrg	  #
6196b68e1f86Smrg	  # There are really only two kinds -- those that
6197b68e1f86Smrg	  # use the current revision as the major version
6198b68e1f86Smrg	  # and those that subtract age and use age as
6199b68e1f86Smrg	  # a minor version.  But, then there is irix
6200b68e1f86Smrg	  # which has an extra 1 added just for fun
6201b68e1f86Smrg	  #
6202b68e1f86Smrg	  case $version_type in
6203b68e1f86Smrg	  darwin|linux|osf|windows|none)
6204b68e1f86Smrg	    func_arith $number_major + $number_minor
6205b68e1f86Smrg	    current=$func_arith_result
6206b68e1f86Smrg	    age="$number_minor"
6207b68e1f86Smrg	    revision="$number_revision"
6208b68e1f86Smrg	    ;;
6209b68e1f86Smrg	  freebsd-aout|freebsd-elf|sunos)
6210b68e1f86Smrg	    current="$number_major"
6211b68e1f86Smrg	    revision="$number_minor"
6212b68e1f86Smrg	    age="0"
6213b68e1f86Smrg	    ;;
6214b68e1f86Smrg	  irix|nonstopux)
6215b68e1f86Smrg	    func_arith $number_major + $number_minor
6216b68e1f86Smrg	    current=$func_arith_result
6217b68e1f86Smrg	    age="$number_minor"
6218b68e1f86Smrg	    revision="$number_minor"
6219b68e1f86Smrg	    lt_irix_increment=no
6220b68e1f86Smrg	    ;;
6221b68e1f86Smrg	  esac
6222b68e1f86Smrg	  ;;
6223b68e1f86Smrg	no)
6224b68e1f86Smrg	  current="$1"
6225b68e1f86Smrg	  revision="$2"
6226b68e1f86Smrg	  age="$3"
6227b68e1f86Smrg	  ;;
6228b68e1f86Smrg	esac
6229b68e1f86Smrg
6230b68e1f86Smrg	# Check that each of the things are valid numbers.
6231b68e1f86Smrg	case $current in
6232b68e1f86Smrg	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]) ;;
6233b68e1f86Smrg	*)
6234b68e1f86Smrg	  func_error "CURRENT \`$current' must be a nonnegative integer"
6235b68e1f86Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
6236b68e1f86Smrg	  ;;
6237b68e1f86Smrg	esac
6238b68e1f86Smrg
6239b68e1f86Smrg	case $revision in
6240b68e1f86Smrg	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]) ;;
6241b68e1f86Smrg	*)
6242b68e1f86Smrg	  func_error "REVISION \`$revision' must be a nonnegative integer"
6243b68e1f86Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
6244b68e1f86Smrg	  ;;
6245b68e1f86Smrg	esac
6246b68e1f86Smrg
6247b68e1f86Smrg	case $age in
6248b68e1f86Smrg	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]) ;;
6249b68e1f86Smrg	*)
6250b68e1f86Smrg	  func_error "AGE \`$age' must be a nonnegative integer"
6251b68e1f86Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
6252b68e1f86Smrg	  ;;
6253b68e1f86Smrg	esac
6254b68e1f86Smrg
6255b68e1f86Smrg	if test "$age" -gt "$current"; then
6256b68e1f86Smrg	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
6257b68e1f86Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
6258b68e1f86Smrg	fi
6259b68e1f86Smrg
6260b68e1f86Smrg	# Calculate the version variables.
6261b68e1f86Smrg	major=
6262b68e1f86Smrg	versuffix=
6263b68e1f86Smrg	verstring=
6264b68e1f86Smrg	case $version_type in
6265b68e1f86Smrg	none) ;;
6266b68e1f86Smrg
6267b68e1f86Smrg	darwin)
6268b68e1f86Smrg	  # Like Linux, but with the current version available in
6269b68e1f86Smrg	  # verstring for coding it into the library header
6270b68e1f86Smrg	  func_arith $current - $age
6271b68e1f86Smrg	  major=.$func_arith_result
6272b68e1f86Smrg	  versuffix="$major.$age.$revision"
6273b68e1f86Smrg	  # Darwin ld doesn't like 0 for these options...
6274b68e1f86Smrg	  func_arith $current + 1
6275b68e1f86Smrg	  minor_current=$func_arith_result
6276b68e1f86Smrg	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
6277b68e1f86Smrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
6278b68e1f86Smrg	  ;;
6279b68e1f86Smrg
6280b68e1f86Smrg	freebsd-aout)
6281b68e1f86Smrg	  major=".$current"
6282b68e1f86Smrg	  versuffix=".$current.$revision";
6283b68e1f86Smrg	  ;;
6284b68e1f86Smrg
6285b68e1f86Smrg	freebsd-elf)
6286b68e1f86Smrg	  major=".$current"
6287b68e1f86Smrg	  versuffix=".$current"
6288b68e1f86Smrg	  ;;
6289b68e1f86Smrg
6290b68e1f86Smrg	irix | nonstopux)
6291b68e1f86Smrg	  if test "X$lt_irix_increment" = "Xno"; then
6292b68e1f86Smrg	    func_arith $current - $age
6293b68e1f86Smrg	  else
6294b68e1f86Smrg	    func_arith $current - $age + 1
6295b68e1f86Smrg	  fi
6296b68e1f86Smrg	  major=$func_arith_result
6297b68e1f86Smrg
6298b68e1f86Smrg	  case $version_type in
6299b68e1f86Smrg	    nonstopux) verstring_prefix=nonstopux ;;
6300b68e1f86Smrg	    *)         verstring_prefix=sgi ;;
6301b68e1f86Smrg	  esac
6302b68e1f86Smrg	  verstring="$verstring_prefix$major.$revision"
6303b68e1f86Smrg
6304b68e1f86Smrg	  # Add in all the interfaces that we are compatible with.
6305b68e1f86Smrg	  loop=$revision
6306b68e1f86Smrg	  while test "$loop" -ne 0; do
6307b68e1f86Smrg	    func_arith $revision - $loop
6308b68e1f86Smrg	    iface=$func_arith_result
6309b68e1f86Smrg	    func_arith $loop - 1
6310b68e1f86Smrg	    loop=$func_arith_result
6311b68e1f86Smrg	    verstring="$verstring_prefix$major.$iface:$verstring"
6312b68e1f86Smrg	  done
6313b68e1f86Smrg
6314b68e1f86Smrg	  # Before this point, $major must not contain `.'.
6315b68e1f86Smrg	  major=.$major
6316b68e1f86Smrg	  versuffix="$major.$revision"
6317b68e1f86Smrg	  ;;
6318b68e1f86Smrg
6319b68e1f86Smrg	linux)
6320b68e1f86Smrg	  func_arith $current - $age
6321b68e1f86Smrg	  major=.$func_arith_result
6322b68e1f86Smrg	  versuffix="$major.$age.$revision"
6323b68e1f86Smrg	  ;;
6324b68e1f86Smrg
6325b68e1f86Smrg	osf)
6326b68e1f86Smrg	  func_arith $current - $age
6327b68e1f86Smrg	  major=.$func_arith_result
6328b68e1f86Smrg	  versuffix=".$current.$age.$revision"
6329b68e1f86Smrg	  verstring="$current.$age.$revision"
6330b68e1f86Smrg
6331b68e1f86Smrg	  # Add in all the interfaces that we are compatible with.
6332b68e1f86Smrg	  loop=$age
6333b68e1f86Smrg	  while test "$loop" -ne 0; do
6334b68e1f86Smrg	    func_arith $current - $loop
6335b68e1f86Smrg	    iface=$func_arith_result
6336b68e1f86Smrg	    func_arith $loop - 1
6337b68e1f86Smrg	    loop=$func_arith_result
6338b68e1f86Smrg	    verstring="$verstring:${iface}.0"
6339b68e1f86Smrg	  done
6340b68e1f86Smrg
6341b68e1f86Smrg	  # Make executables depend on our current version.
6342b68e1f86Smrg	  verstring="$verstring:${current}.0"
6343b68e1f86Smrg	  ;;
6344b68e1f86Smrg
6345b68e1f86Smrg	qnx)
6346b68e1f86Smrg	  major=".$current"
6347b68e1f86Smrg	  versuffix=".$current"
6348b68e1f86Smrg	  ;;
6349b68e1f86Smrg
6350b68e1f86Smrg	sunos)
6351b68e1f86Smrg	  major=".$current"
6352b68e1f86Smrg	  versuffix=".$current.$revision"
6353b68e1f86Smrg	  ;;
6354b68e1f86Smrg
6355b68e1f86Smrg	windows)
6356b68e1f86Smrg	  # Use '-' rather than '.', since we only want one
6357b68e1f86Smrg	  # extension on DOS 8.3 filesystems.
6358b68e1f86Smrg	  func_arith $current - $age
6359b68e1f86Smrg	  major=$func_arith_result
6360b68e1f86Smrg	  versuffix="-$major"
6361b68e1f86Smrg	  ;;
6362b68e1f86Smrg
6363b68e1f86Smrg	*)
6364b68e1f86Smrg	  func_fatal_configuration "unknown library version type \`$version_type'"
6365b68e1f86Smrg	  ;;
6366b68e1f86Smrg	esac
6367b68e1f86Smrg
6368b68e1f86Smrg	# Clear the version info if we defaulted, and they specified a release.
6369b68e1f86Smrg	if test -z "$vinfo" && test -n "$release"; then
6370b68e1f86Smrg	  major=
6371b68e1f86Smrg	  case $version_type in
6372b68e1f86Smrg	  darwin)
6373b68e1f86Smrg	    # we can't check for "0.0" in archive_cmds due to quoting
6374b68e1f86Smrg	    # problems, so we reset it completely
6375b68e1f86Smrg	    verstring=
6376b68e1f86Smrg	    ;;
6377b68e1f86Smrg	  *)
6378b68e1f86Smrg	    verstring="0.0"
6379b68e1f86Smrg	    ;;
6380b68e1f86Smrg	  esac
6381b68e1f86Smrg	  if test "$need_version" = no; then
6382b68e1f86Smrg	    versuffix=
6383b68e1f86Smrg	  else
6384b68e1f86Smrg	    versuffix=".0.0"
6385b68e1f86Smrg	  fi
6386b68e1f86Smrg	fi
6387b68e1f86Smrg
6388b68e1f86Smrg	# Remove version info from name if versioning should be avoided
6389b68e1f86Smrg	if test "$avoid_version" = yes && test "$need_version" = no; then
6390b68e1f86Smrg	  major=
6391b68e1f86Smrg	  versuffix=
6392b68e1f86Smrg	  verstring=""
6393b68e1f86Smrg	fi
6394b68e1f86Smrg
6395b68e1f86Smrg	# Check to see if the archive will have undefined symbols.
6396b68e1f86Smrg	if test "$allow_undefined" = yes; then
6397b68e1f86Smrg	  if test "$allow_undefined_flag" = unsupported; then
6398b68e1f86Smrg	    func_warning "undefined symbols not allowed in $host shared libraries"
6399b68e1f86Smrg	    build_libtool_libs=no
6400b68e1f86Smrg	    build_old_libs=yes
6401b68e1f86Smrg	  fi
6402b68e1f86Smrg	else
6403b68e1f86Smrg	  # Don't allow undefined symbols.
6404b68e1f86Smrg	  allow_undefined_flag="$no_undefined_flag"
6405b68e1f86Smrg	fi
6406b68e1f86Smrg
6407b68e1f86Smrg      fi
6408b68e1f86Smrg
6409b68e1f86Smrg      func_generate_dlsyms "$libname" "$libname" "yes"
6410b68e1f86Smrg      libobjs="$libobjs $symfileobj"
6411b68e1f86Smrg      test "X$libobjs" = "X " && libobjs=
6412b68e1f86Smrg
6413b68e1f86Smrg      if test "$mode" != relink; then
6414b68e1f86Smrg	# Remove our outputs, but don't remove object files since they
6415b68e1f86Smrg	# may have been created when compiling PIC objects.
6416b68e1f86Smrg	removelist=
6417b68e1f86Smrg	tempremovelist=`$ECHO "$output_objdir/*"`
6418b68e1f86Smrg	for p in $tempremovelist; do
6419b68e1f86Smrg	  case $p in
6420b68e1f86Smrg	    *.$objext | *.gcno)
6421b68e1f86Smrg	       ;;
6422b68e1f86Smrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
6423b68e1f86Smrg	       if test "X$precious_files_regex" != "X"; then
6424b68e1f86Smrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
6425b68e1f86Smrg		 then
6426b68e1f86Smrg		   continue
6427b68e1f86Smrg		 fi
6428b68e1f86Smrg	       fi
6429b68e1f86Smrg	       removelist="$removelist $p"
6430b68e1f86Smrg	       ;;
6431b68e1f86Smrg	    *) ;;
6432b68e1f86Smrg	  esac
6433b68e1f86Smrg	done
6434b68e1f86Smrg	test -n "$removelist" && \
6435b68e1f86Smrg	  func_show_eval "${RM}r \$removelist"
6436b68e1f86Smrg      fi
6437b68e1f86Smrg
6438b68e1f86Smrg      # Now set the variables for building old libraries.
6439b68e1f86Smrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
6440b68e1f86Smrg	oldlibs="$oldlibs $output_objdir/$libname.$libext"
6441b68e1f86Smrg
6442b68e1f86Smrg	# Transform .lo files to .o files.
6443b68e1f86Smrg	oldobjs="$objs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
6444b68e1f86Smrg      fi
6445b68e1f86Smrg
6446b68e1f86Smrg      # Eliminate all temporary directories.
6447b68e1f86Smrg      #for path in $notinst_path; do
6448b68e1f86Smrg      #	lib_search_path=`$ECHO "X$lib_search_path " | $Xsed -e "s% $path % %g"`
6449b68e1f86Smrg      #	deplibs=`$ECHO "X$deplibs " | $Xsed -e "s% -L$path % %g"`
6450b68e1f86Smrg      #	dependency_libs=`$ECHO "X$dependency_libs " | $Xsed -e "s% -L$path % %g"`
6451b68e1f86Smrg      #done
6452b68e1f86Smrg
6453b68e1f86Smrg      if test -n "$xrpath"; then
6454b68e1f86Smrg	# If the user specified any rpath flags, then add them.
6455b68e1f86Smrg	temp_xrpath=
6456b68e1f86Smrg	for libdir in $xrpath; do
6457b68e1f86Smrg	  temp_xrpath="$temp_xrpath -R$libdir"
6458b68e1f86Smrg	  case "$finalize_rpath " in
6459b68e1f86Smrg	  *" $libdir "*) ;;
6460b68e1f86Smrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
6461b68e1f86Smrg	  esac
6462b68e1f86Smrg	done
6463b68e1f86Smrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
6464b68e1f86Smrg	  dependency_libs="$temp_xrpath $dependency_libs"
6465b68e1f86Smrg	fi
6466b68e1f86Smrg      fi
6467b68e1f86Smrg
6468b68e1f86Smrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
6469b68e1f86Smrg      old_dlfiles="$dlfiles"
6470b68e1f86Smrg      dlfiles=
6471b68e1f86Smrg      for lib in $old_dlfiles; do
6472b68e1f86Smrg	case " $dlprefiles $dlfiles " in
6473b68e1f86Smrg	*" $lib "*) ;;
6474b68e1f86Smrg	*) dlfiles="$dlfiles $lib" ;;
6475b68e1f86Smrg	esac
6476b68e1f86Smrg      done
6477b68e1f86Smrg
6478b68e1f86Smrg      # Make sure dlprefiles contains only unique files
6479b68e1f86Smrg      old_dlprefiles="$dlprefiles"
6480b68e1f86Smrg      dlprefiles=
6481b68e1f86Smrg      for lib in $old_dlprefiles; do
6482b68e1f86Smrg	case "$dlprefiles " in
6483b68e1f86Smrg	*" $lib "*) ;;
6484b68e1f86Smrg	*) dlprefiles="$dlprefiles $lib" ;;
6485b68e1f86Smrg	esac
6486b68e1f86Smrg      done
6487b68e1f86Smrg
6488b68e1f86Smrg      if test "$build_libtool_libs" = yes; then
6489b68e1f86Smrg	if test -n "$rpath"; then
6490b68e1f86Smrg	  case $host in
6491b68e1f86Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc*)
6492b68e1f86Smrg	    # these systems don't actually have a c library (as such)!
6493b68e1f86Smrg	    ;;
6494b68e1f86Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
6495b68e1f86Smrg	    # Rhapsody C library is in the System framework
6496b68e1f86Smrg	    deplibs="$deplibs System.ltframework"
6497b68e1f86Smrg	    ;;
6498b68e1f86Smrg	  *-*-netbsd*)
6499b68e1f86Smrg	    # Don't link with libc until the a.out ld.so is fixed.
6500b68e1f86Smrg	    ;;
6501b68e1f86Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
6502b68e1f86Smrg	    # Do not include libc due to us having libc/libc_r.
6503b68e1f86Smrg	    ;;
6504b68e1f86Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
6505b68e1f86Smrg	    # Causes problems with __ctype
6506b68e1f86Smrg	    ;;
6507b68e1f86Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
6508b68e1f86Smrg	    # Compiler inserts libc in the correct place for threads to work
6509b68e1f86Smrg	    ;;
6510b68e1f86Smrg	  *)
6511b68e1f86Smrg	    # Add libc to deplibs on all other systems if necessary.
6512b68e1f86Smrg	    if test "$build_libtool_need_lc" = "yes"; then
6513b68e1f86Smrg	      deplibs="$deplibs -lc"
6514b68e1f86Smrg	    fi
6515b68e1f86Smrg	    ;;
6516b68e1f86Smrg	  esac
6517b68e1f86Smrg	fi
6518b68e1f86Smrg
6519b68e1f86Smrg	# Transform deplibs into only deplibs that can be linked in shared.
6520b68e1f86Smrg	name_save=$name
6521b68e1f86Smrg	libname_save=$libname
6522b68e1f86Smrg	release_save=$release
6523b68e1f86Smrg	versuffix_save=$versuffix
6524b68e1f86Smrg	major_save=$major
6525b68e1f86Smrg	# I'm not sure if I'm treating the release correctly.  I think
6526b68e1f86Smrg	# release should show up in the -l (ie -lgmp5) so we don't want to
6527b68e1f86Smrg	# add it in twice.  Is that correct?
6528b68e1f86Smrg	release=""
6529b68e1f86Smrg	versuffix=""
6530b68e1f86Smrg	major=""
6531b68e1f86Smrg	newdeplibs=
6532b68e1f86Smrg	droppeddeps=no
6533b68e1f86Smrg	case $deplibs_check_method in
6534b68e1f86Smrg	pass_all)
6535b68e1f86Smrg	  # Don't check for shared/static.  Everything works.
6536b68e1f86Smrg	  # This might be a little naive.  We might want to check
6537b68e1f86Smrg	  # whether the library exists or not.  But this is on
6538b68e1f86Smrg	  # osf3 & osf4 and I'm not really sure... Just
6539b68e1f86Smrg	  # implementing what was already the behavior.
6540b68e1f86Smrg	  newdeplibs=$deplibs
6541b68e1f86Smrg	  ;;
6542b68e1f86Smrg	test_compile)
6543b68e1f86Smrg	  # This code stresses the "libraries are programs" paradigm to its
6544b68e1f86Smrg	  # limits. Maybe even breaks it.  We compile a program, linking it
6545b68e1f86Smrg	  # against the deplibs as a proxy for the library.  Then we can check
6546b68e1f86Smrg	  # whether they linked in statically or dynamically with ldd.
6547b68e1f86Smrg	  $opt_dry_run || $RM conftest.c
6548b68e1f86Smrg	  cat > conftest.c <<EOF
6549b68e1f86Smrg	  int main() { return 0; }
6550b68e1f86SmrgEOF
6551b68e1f86Smrg	  $opt_dry_run || $RM conftest
6552b68e1f86Smrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
6553b68e1f86Smrg	    ldd_output=`ldd conftest`
6554b68e1f86Smrg	    for i in $deplibs; do
6555b68e1f86Smrg	      case $i in
6556b68e1f86Smrg	      -l*)
6557b68e1f86Smrg		func_stripname -l '' "$i"
6558b68e1f86Smrg		name=$func_stripname_result
6559b68e1f86Smrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6560b68e1f86Smrg		  case " $predeps $postdeps " in
6561b68e1f86Smrg		  *" $i "*)
6562b68e1f86Smrg		    newdeplibs="$newdeplibs $i"
6563b68e1f86Smrg		    i=""
6564b68e1f86Smrg		    ;;
6565b68e1f86Smrg		  esac
6566b68e1f86Smrg		fi
6567b68e1f86Smrg		if test -n "$i" ; then
6568b68e1f86Smrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
6569b68e1f86Smrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
6570b68e1f86Smrg		  set dummy $deplib_matches; shift
6571b68e1f86Smrg		  deplib_match=$1
6572b68e1f86Smrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
6573b68e1f86Smrg		    newdeplibs="$newdeplibs $i"
6574b68e1f86Smrg		  else
6575b68e1f86Smrg		    droppeddeps=yes
6576b68e1f86Smrg		    $ECHO
6577b68e1f86Smrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
6578b68e1f86Smrg		    $ECHO "*** I have the capability to make that library automatically link in when"
6579b68e1f86Smrg		    $ECHO "*** you link to this library.  But I can only do this if you have a"
6580b68e1f86Smrg		    $ECHO "*** shared version of the library, which I believe you do not have"
6581b68e1f86Smrg		    $ECHO "*** because a test_compile did reveal that the linker did not use it for"
6582b68e1f86Smrg		    $ECHO "*** its dynamic dependency list that programs get resolved with at runtime."
6583b68e1f86Smrg		  fi
6584b68e1f86Smrg		fi
6585b68e1f86Smrg		;;
6586b68e1f86Smrg	      *)
6587b68e1f86Smrg		newdeplibs="$newdeplibs $i"
6588b68e1f86Smrg		;;
6589b68e1f86Smrg	      esac
6590b68e1f86Smrg	    done
6591b68e1f86Smrg	  else
6592b68e1f86Smrg	    # Error occurred in the first compile.  Let's try to salvage
6593b68e1f86Smrg	    # the situation: Compile a separate program for each library.
6594b68e1f86Smrg	    for i in $deplibs; do
6595b68e1f86Smrg	      case $i in
6596b68e1f86Smrg	      -l*)
6597b68e1f86Smrg		func_stripname -l '' "$i"
6598b68e1f86Smrg		name=$func_stripname_result
6599b68e1f86Smrg		$opt_dry_run || $RM conftest
6600b68e1f86Smrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
6601b68e1f86Smrg		  ldd_output=`ldd conftest`
6602b68e1f86Smrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6603b68e1f86Smrg		    case " $predeps $postdeps " in
6604b68e1f86Smrg		    *" $i "*)
6605b68e1f86Smrg		      newdeplibs="$newdeplibs $i"
6606b68e1f86Smrg		      i=""
6607b68e1f86Smrg		      ;;
6608b68e1f86Smrg		    esac
6609b68e1f86Smrg		  fi
6610b68e1f86Smrg		  if test -n "$i" ; then
6611b68e1f86Smrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
6612b68e1f86Smrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
6613b68e1f86Smrg		    set dummy $deplib_matches; shift
6614b68e1f86Smrg		    deplib_match=$1
6615b68e1f86Smrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
6616b68e1f86Smrg		      newdeplibs="$newdeplibs $i"
6617b68e1f86Smrg		    else
6618b68e1f86Smrg		      droppeddeps=yes
6619b68e1f86Smrg		      $ECHO
6620b68e1f86Smrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
6621b68e1f86Smrg		      $ECHO "*** I have the capability to make that library automatically link in when"
6622b68e1f86Smrg		      $ECHO "*** you link to this library.  But I can only do this if you have a"
6623b68e1f86Smrg		      $ECHO "*** shared version of the library, which you do not appear to have"
6624b68e1f86Smrg		      $ECHO "*** because a test_compile did reveal that the linker did not use this one"
6625b68e1f86Smrg		      $ECHO "*** as a dynamic dependency that programs can get resolved with at runtime."
6626b68e1f86Smrg		    fi
6627b68e1f86Smrg		  fi
6628b68e1f86Smrg		else
6629b68e1f86Smrg		  droppeddeps=yes
6630b68e1f86Smrg		  $ECHO
6631b68e1f86Smrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
6632b68e1f86Smrg		  $ECHO "*** make it link in!  You will probably need to install it or some"
6633b68e1f86Smrg		  $ECHO "*** library that it depends on before this library will be fully"
6634b68e1f86Smrg		  $ECHO "*** functional.  Installing it before continuing would be even better."
6635b68e1f86Smrg		fi
6636b68e1f86Smrg		;;
6637b68e1f86Smrg	      *)
6638b68e1f86Smrg		newdeplibs="$newdeplibs $i"
6639b68e1f86Smrg		;;
6640b68e1f86Smrg	      esac
6641b68e1f86Smrg	    done
6642b68e1f86Smrg	  fi
6643b68e1f86Smrg	  ;;
6644b68e1f86Smrg	file_magic*)
6645b68e1f86Smrg	  set dummy $deplibs_check_method; shift
6646b68e1f86Smrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6647b68e1f86Smrg	  for a_deplib in $deplibs; do
6648b68e1f86Smrg	    case $a_deplib in
6649b68e1f86Smrg	    -l*)
6650b68e1f86Smrg	      func_stripname -l '' "$a_deplib"
6651b68e1f86Smrg	      name=$func_stripname_result
6652b68e1f86Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6653b68e1f86Smrg		case " $predeps $postdeps " in
6654b68e1f86Smrg		*" $a_deplib "*)
6655b68e1f86Smrg		  newdeplibs="$newdeplibs $a_deplib"
6656b68e1f86Smrg		  a_deplib=""
6657b68e1f86Smrg		  ;;
6658b68e1f86Smrg		esac
6659b68e1f86Smrg	      fi
6660b68e1f86Smrg	      if test -n "$a_deplib" ; then
6661b68e1f86Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
6662b68e1f86Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
6663b68e1f86Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
6664b68e1f86Smrg		  for potent_lib in $potential_libs; do
6665b68e1f86Smrg		      # Follow soft links.
6666b68e1f86Smrg		      if ls -lLd "$potent_lib" 2>/dev/null |
6667b68e1f86Smrg			 $GREP " -> " >/dev/null; then
6668b68e1f86Smrg			continue
6669b68e1f86Smrg		      fi
6670b68e1f86Smrg		      # The statement above tries to avoid entering an
6671b68e1f86Smrg		      # endless loop below, in case of cyclic links.
6672b68e1f86Smrg		      # We might still enter an endless loop, since a link
6673b68e1f86Smrg		      # loop can be closed while we follow links,
6674b68e1f86Smrg		      # but so what?
6675b68e1f86Smrg		      potlib="$potent_lib"
6676b68e1f86Smrg		      while test -h "$potlib" 2>/dev/null; do
6677b68e1f86Smrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
6678b68e1f86Smrg			case $potliblink in
6679b68e1f86Smrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
6680b68e1f86Smrg			*) potlib=`$ECHO "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
6681b68e1f86Smrg			esac
6682b68e1f86Smrg		      done
6683b68e1f86Smrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
6684b68e1f86Smrg			 $SED -e 10q |
6685b68e1f86Smrg			 $EGREP "$file_magic_regex" > /dev/null; then
6686b68e1f86Smrg			newdeplibs="$newdeplibs $a_deplib"
6687b68e1f86Smrg			a_deplib=""
6688b68e1f86Smrg			break 2
6689b68e1f86Smrg		      fi
6690b68e1f86Smrg		  done
6691b68e1f86Smrg		done
6692b68e1f86Smrg	      fi
6693b68e1f86Smrg	      if test -n "$a_deplib" ; then
6694b68e1f86Smrg		droppeddeps=yes
6695b68e1f86Smrg		$ECHO
6696b68e1f86Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
6697b68e1f86Smrg		$ECHO "*** I have the capability to make that library automatically link in when"
6698b68e1f86Smrg		$ECHO "*** you link to this library.  But I can only do this if you have a"
6699b68e1f86Smrg		$ECHO "*** shared version of the library, which you do not appear to have"
6700b68e1f86Smrg		$ECHO "*** because I did check the linker path looking for a file starting"
6701b68e1f86Smrg		if test -z "$potlib" ; then
6702b68e1f86Smrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
6703b68e1f86Smrg		else
6704b68e1f86Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
6705b68e1f86Smrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
6706b68e1f86Smrg		fi
6707b68e1f86Smrg	      fi
6708b68e1f86Smrg	      ;;
6709b68e1f86Smrg	    *)
6710b68e1f86Smrg	      # Add a -L argument.
6711b68e1f86Smrg	      newdeplibs="$newdeplibs $a_deplib"
6712b68e1f86Smrg	      ;;
6713b68e1f86Smrg	    esac
6714b68e1f86Smrg	  done # Gone through all deplibs.
6715b68e1f86Smrg	  ;;
6716b68e1f86Smrg	match_pattern*)
6717b68e1f86Smrg	  set dummy $deplibs_check_method; shift
6718b68e1f86Smrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6719b68e1f86Smrg	  for a_deplib in $deplibs; do
6720b68e1f86Smrg	    case $a_deplib in
6721b68e1f86Smrg	    -l*)
6722b68e1f86Smrg	      func_stripname -l '' "$a_deplib"
6723b68e1f86Smrg	      name=$func_stripname_result
6724b68e1f86Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6725b68e1f86Smrg		case " $predeps $postdeps " in
6726b68e1f86Smrg		*" $a_deplib "*)
6727b68e1f86Smrg		  newdeplibs="$newdeplibs $a_deplib"
6728b68e1f86Smrg		  a_deplib=""
6729b68e1f86Smrg		  ;;
6730b68e1f86Smrg		esac
6731b68e1f86Smrg	      fi
6732b68e1f86Smrg	      if test -n "$a_deplib" ; then
6733b68e1f86Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
6734b68e1f86Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
6735b68e1f86Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
6736b68e1f86Smrg		  for potent_lib in $potential_libs; do
6737b68e1f86Smrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
6738b68e1f86Smrg		    if eval "\$ECHO \"X$potent_lib\"" 2>/dev/null | $Xsed -e 10q | \
6739b68e1f86Smrg		       $EGREP "$match_pattern_regex" > /dev/null; then
6740b68e1f86Smrg		      newdeplibs="$newdeplibs $a_deplib"
6741b68e1f86Smrg		      a_deplib=""
6742b68e1f86Smrg		      break 2
6743b68e1f86Smrg		    fi
6744b68e1f86Smrg		  done
6745b68e1f86Smrg		done
6746b68e1f86Smrg	      fi
6747b68e1f86Smrg	      if test -n "$a_deplib" ; then
6748b68e1f86Smrg		droppeddeps=yes
6749b68e1f86Smrg		$ECHO
6750b68e1f86Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
6751b68e1f86Smrg		$ECHO "*** I have the capability to make that library automatically link in when"
6752b68e1f86Smrg		$ECHO "*** you link to this library.  But I can only do this if you have a"
6753b68e1f86Smrg		$ECHO "*** shared version of the library, which you do not appear to have"
6754b68e1f86Smrg		$ECHO "*** because I did check the linker path looking for a file starting"
6755b68e1f86Smrg		if test -z "$potlib" ; then
6756b68e1f86Smrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
6757b68e1f86Smrg		else
6758b68e1f86Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
6759b68e1f86Smrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
6760b68e1f86Smrg		fi
6761b68e1f86Smrg	      fi
6762b68e1f86Smrg	      ;;
6763b68e1f86Smrg	    *)
6764b68e1f86Smrg	      # Add a -L argument.
6765b68e1f86Smrg	      newdeplibs="$newdeplibs $a_deplib"
6766b68e1f86Smrg	      ;;
6767b68e1f86Smrg	    esac
6768b68e1f86Smrg	  done # Gone through all deplibs.
6769b68e1f86Smrg	  ;;
6770b68e1f86Smrg	none | unknown | *)
6771b68e1f86Smrg	  newdeplibs=""
6772b68e1f86Smrg	  tmp_deplibs=`$ECHO "X $deplibs" | $Xsed \
6773b68e1f86Smrg	      -e 's/ -lc$//' -e 's/ -[LR][^ ]*//g'`
6774b68e1f86Smrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6775b68e1f86Smrg	    for i in $predeps $postdeps ; do
6776b68e1f86Smrg	      # can't use Xsed below, because $i might contain '/'
6777b68e1f86Smrg	      tmp_deplibs=`$ECHO "X $tmp_deplibs" | $Xsed -e "s,$i,,"`
6778b68e1f86Smrg	    done
6779b68e1f86Smrg	  fi
6780b68e1f86Smrg	  if $ECHO "X $tmp_deplibs" | $Xsed -e 's/[	 ]//g' |
6781b68e1f86Smrg	     $GREP . >/dev/null; then
6782b68e1f86Smrg	    $ECHO
6783b68e1f86Smrg	    if test "X$deplibs_check_method" = "Xnone"; then
6784b68e1f86Smrg	      $ECHO "*** Warning: inter-library dependencies are not supported in this platform."
6785b68e1f86Smrg	    else
6786b68e1f86Smrg	      $ECHO "*** Warning: inter-library dependencies are not known to be supported."
6787b68e1f86Smrg	    fi
6788b68e1f86Smrg	    $ECHO "*** All declared inter-library dependencies are being dropped."
6789b68e1f86Smrg	    droppeddeps=yes
6790b68e1f86Smrg	  fi
6791b68e1f86Smrg	  ;;
6792b68e1f86Smrg	esac
6793b68e1f86Smrg	versuffix=$versuffix_save
6794b68e1f86Smrg	major=$major_save
6795b68e1f86Smrg	release=$release_save
6796b68e1f86Smrg	libname=$libname_save
6797b68e1f86Smrg	name=$name_save
6798b68e1f86Smrg
6799b68e1f86Smrg	case $host in
6800b68e1f86Smrg	*-*-rhapsody* | *-*-darwin1.[012])
6801b68e1f86Smrg	  # On Rhapsody replace the C library with the System framework
6802b68e1f86Smrg	  newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
6803b68e1f86Smrg	  ;;
6804b68e1f86Smrg	esac
6805b68e1f86Smrg
6806b68e1f86Smrg	if test "$droppeddeps" = yes; then
6807b68e1f86Smrg	  if test "$module" = yes; then
6808b68e1f86Smrg	    $ECHO
6809b68e1f86Smrg	    $ECHO "*** Warning: libtool could not satisfy all declared inter-library"
6810b68e1f86Smrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
6811b68e1f86Smrg	    $ECHO "*** a static module, that should work as long as the dlopening"
6812b68e1f86Smrg	    $ECHO "*** application is linked with the -dlopen flag."
6813b68e1f86Smrg	    if test -z "$global_symbol_pipe"; then
6814b68e1f86Smrg	      $ECHO
6815b68e1f86Smrg	      $ECHO "*** However, this would only work if libtool was able to extract symbol"
6816b68e1f86Smrg	      $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
6817b68e1f86Smrg	      $ECHO "*** not find such a program.  So, this module is probably useless."
6818b68e1f86Smrg	      $ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
6819b68e1f86Smrg	    fi
6820b68e1f86Smrg	    if test "$build_old_libs" = no; then
6821b68e1f86Smrg	      oldlibs="$output_objdir/$libname.$libext"
6822b68e1f86Smrg	      build_libtool_libs=module
6823b68e1f86Smrg	      build_old_libs=yes
6824b68e1f86Smrg	    else
6825b68e1f86Smrg	      build_libtool_libs=no
6826b68e1f86Smrg	    fi
6827b68e1f86Smrg	  else
6828b68e1f86Smrg	    $ECHO "*** The inter-library dependencies that have been dropped here will be"
6829b68e1f86Smrg	    $ECHO "*** automatically added whenever a program is linked with this library"
6830b68e1f86Smrg	    $ECHO "*** or is declared to -dlopen it."
6831b68e1f86Smrg
6832b68e1f86Smrg	    if test "$allow_undefined" = no; then
6833b68e1f86Smrg	      $ECHO
6834b68e1f86Smrg	      $ECHO "*** Since this library must not contain undefined symbols,"
6835b68e1f86Smrg	      $ECHO "*** because either the platform does not support them or"
6836b68e1f86Smrg	      $ECHO "*** it was explicitly requested with -no-undefined,"
6837b68e1f86Smrg	      $ECHO "*** libtool will only create a static version of it."
6838b68e1f86Smrg	      if test "$build_old_libs" = no; then
6839b68e1f86Smrg		oldlibs="$output_objdir/$libname.$libext"
6840b68e1f86Smrg		build_libtool_libs=module
6841b68e1f86Smrg		build_old_libs=yes
6842b68e1f86Smrg	      else
6843b68e1f86Smrg		build_libtool_libs=no
6844b68e1f86Smrg	      fi
6845b68e1f86Smrg	    fi
6846b68e1f86Smrg	  fi
6847b68e1f86Smrg	fi
6848b68e1f86Smrg	# Done checking deplibs!
6849b68e1f86Smrg	deplibs=$newdeplibs
6850b68e1f86Smrg      fi
6851b68e1f86Smrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
6852b68e1f86Smrg      case $host in
6853b68e1f86Smrg	*-*-darwin*)
6854b68e1f86Smrg	  newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
6855b68e1f86Smrg	  new_inherited_linker_flags=`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
6856b68e1f86Smrg	  deplibs=`$ECHO "X $deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
6857b68e1f86Smrg	  ;;
6858b68e1f86Smrg      esac
6859b68e1f86Smrg
6860b68e1f86Smrg      # move library search paths that coincide with paths to not yet
6861b68e1f86Smrg      # installed libraries to the beginning of the library search list
6862b68e1f86Smrg      new_libs=
6863b68e1f86Smrg      for path in $notinst_path; do
6864b68e1f86Smrg	case " $new_libs " in
6865b68e1f86Smrg	*" -L$path/$objdir "*) ;;
6866b68e1f86Smrg	*)
6867b68e1f86Smrg	  case " $deplibs " in
6868b68e1f86Smrg	  *" -L$path/$objdir "*)
6869b68e1f86Smrg	    new_libs="$new_libs -L$path/$objdir" ;;
6870b68e1f86Smrg	  esac
6871b68e1f86Smrg	  ;;
6872b68e1f86Smrg	esac
6873b68e1f86Smrg      done
6874b68e1f86Smrg      for deplib in $deplibs; do
6875b68e1f86Smrg	case $deplib in
6876b68e1f86Smrg	-L*)
6877b68e1f86Smrg	  case " $new_libs " in
6878b68e1f86Smrg	  *" $deplib "*) ;;
6879b68e1f86Smrg	  *) new_libs="$new_libs $deplib" ;;
6880b68e1f86Smrg	  esac
6881b68e1f86Smrg	  ;;
6882b68e1f86Smrg	*) new_libs="$new_libs $deplib" ;;
6883b68e1f86Smrg	esac
6884b68e1f86Smrg      done
6885b68e1f86Smrg      deplibs="$new_libs"
6886b68e1f86Smrg
6887b68e1f86Smrg      # All the library-specific variables (install_libdir is set above).
6888b68e1f86Smrg      library_names=
6889b68e1f86Smrg      old_library=
6890b68e1f86Smrg      dlname=
6891b68e1f86Smrg
6892b68e1f86Smrg      # Test again, we may have decided not to build it any more
6893b68e1f86Smrg      if test "$build_libtool_libs" = yes; then
6894b68e1f86Smrg	if test "$hardcode_into_libs" = yes; then
6895b68e1f86Smrg	  # Hardcode the library paths
6896b68e1f86Smrg	  hardcode_libdirs=
6897b68e1f86Smrg	  dep_rpath=
6898b68e1f86Smrg	  rpath="$finalize_rpath"
6899b68e1f86Smrg	  test "$mode" != relink && rpath="$compile_rpath$rpath"
6900b68e1f86Smrg	  for libdir in $rpath; do
6901b68e1f86Smrg	    if test -n "$hardcode_libdir_flag_spec"; then
6902b68e1f86Smrg	      if test -n "$hardcode_libdir_separator"; then
6903b68e1f86Smrg		if test -z "$hardcode_libdirs"; then
6904b68e1f86Smrg		  hardcode_libdirs="$libdir"
6905b68e1f86Smrg		else
6906b68e1f86Smrg		  # Just accumulate the unique libdirs.
6907b68e1f86Smrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
6908b68e1f86Smrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
6909b68e1f86Smrg		    ;;
6910b68e1f86Smrg		  *)
6911b68e1f86Smrg		    hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
6912b68e1f86Smrg		    ;;
6913b68e1f86Smrg		  esac
6914b68e1f86Smrg		fi
6915b68e1f86Smrg	      else
6916b68e1f86Smrg		eval flag=\"$hardcode_libdir_flag_spec\"
6917b68e1f86Smrg		dep_rpath="$dep_rpath $flag"
6918b68e1f86Smrg	      fi
6919b68e1f86Smrg	    elif test -n "$runpath_var"; then
6920b68e1f86Smrg	      case "$perm_rpath " in
6921b68e1f86Smrg	      *" $libdir "*) ;;
6922b68e1f86Smrg	      *) perm_rpath="$perm_rpath $libdir" ;;
6923b68e1f86Smrg	      esac
6924b68e1f86Smrg	    fi
6925b68e1f86Smrg	  done
6926b68e1f86Smrg	  # Substitute the hardcoded libdirs into the rpath.
6927b68e1f86Smrg	  if test -n "$hardcode_libdir_separator" &&
6928b68e1f86Smrg	     test -n "$hardcode_libdirs"; then
6929b68e1f86Smrg	    libdir="$hardcode_libdirs"
6930b68e1f86Smrg	    if test -n "$hardcode_libdir_flag_spec_ld"; then
6931b68e1f86Smrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
6932b68e1f86Smrg	    else
6933b68e1f86Smrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
6934b68e1f86Smrg	    fi
6935b68e1f86Smrg	  fi
6936b68e1f86Smrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
6937b68e1f86Smrg	    # We should set the runpath_var.
6938b68e1f86Smrg	    rpath=
6939b68e1f86Smrg	    for dir in $perm_rpath; do
6940b68e1f86Smrg	      rpath="$rpath$dir:"
6941b68e1f86Smrg	    done
6942b68e1f86Smrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
6943b68e1f86Smrg	  fi
6944b68e1f86Smrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
6945b68e1f86Smrg	fi
69466df26cacSmrg
6947b68e1f86Smrg	shlibpath="$finalize_shlibpath"
6948b68e1f86Smrg	test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
6949b68e1f86Smrg	if test -n "$shlibpath"; then
6950b68e1f86Smrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
6951b68e1f86Smrg	fi
69526df26cacSmrg
6953b68e1f86Smrg	# Get the real and link names of the library.
6954b68e1f86Smrg	eval shared_ext=\"$shrext_cmds\"
6955b68e1f86Smrg	eval library_names=\"$library_names_spec\"
6956b68e1f86Smrg	set dummy $library_names
6957b68e1f86Smrg	shift
6958b68e1f86Smrg	realname="$1"
6959b68e1f86Smrg	shift
69606df26cacSmrg
6961b68e1f86Smrg	if test -n "$soname_spec"; then
6962b68e1f86Smrg	  eval soname=\"$soname_spec\"
6963b68e1f86Smrg	else
6964b68e1f86Smrg	  soname="$realname"
6965b68e1f86Smrg	fi
6966b68e1f86Smrg	if test -z "$dlname"; then
6967b68e1f86Smrg	  dlname=$soname
6968b68e1f86Smrg	fi
69696df26cacSmrg
6970b68e1f86Smrg	lib="$output_objdir/$realname"
6971b68e1f86Smrg	linknames=
6972b68e1f86Smrg	for link
6973b68e1f86Smrg	do
6974b68e1f86Smrg	  linknames="$linknames $link"
6975b68e1f86Smrg	done
69766df26cacSmrg
6977b68e1f86Smrg	# Use standard objects if they are pic
6978b68e1f86Smrg	test -z "$pic_flag" && libobjs=`$ECHO "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
6979b68e1f86Smrg	test "X$libobjs" = "X " && libobjs=
69806df26cacSmrg
6981b68e1f86Smrg	delfiles=
6982b68e1f86Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
6983b68e1f86Smrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
6984b68e1f86Smrg	  export_symbols="$output_objdir/$libname.uexp"
6985b68e1f86Smrg	  delfiles="$delfiles $export_symbols"
6986b68e1f86Smrg	fi
69876df26cacSmrg
6988b68e1f86Smrg	orig_export_symbols=
6989b68e1f86Smrg	case $host_os in
6990b68e1f86Smrg	cygwin* | mingw* | cegcc*)
6991b68e1f86Smrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
6992b68e1f86Smrg	    # exporting using user supplied symfile
6993b68e1f86Smrg	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
6994b68e1f86Smrg	      # and it's NOT already a .def file. Must figure out
6995b68e1f86Smrg	      # which of the given symbols are data symbols and tag
6996b68e1f86Smrg	      # them as such. So, trigger use of export_symbols_cmds.
6997b68e1f86Smrg	      # export_symbols gets reassigned inside the "prepare
6998b68e1f86Smrg	      # the list of exported symbols" if statement, so the
6999b68e1f86Smrg	      # include_expsyms logic still works.
7000b68e1f86Smrg	      orig_export_symbols="$export_symbols"
7001b68e1f86Smrg	      export_symbols=
7002b68e1f86Smrg	      always_export_symbols=yes
7003b68e1f86Smrg	    fi
7004b68e1f86Smrg	  fi
7005b68e1f86Smrg	  ;;
7006b68e1f86Smrg	esac
70076df26cacSmrg
7008b68e1f86Smrg	# Prepare the list of exported symbols
7009b68e1f86Smrg	if test -z "$export_symbols"; then
7010b68e1f86Smrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
7011b68e1f86Smrg	    func_verbose "generating symbol list for \`$libname.la'"
7012b68e1f86Smrg	    export_symbols="$output_objdir/$libname.exp"
7013b68e1f86Smrg	    $opt_dry_run || $RM $export_symbols
7014b68e1f86Smrg	    cmds=$export_symbols_cmds
7015b68e1f86Smrg	    save_ifs="$IFS"; IFS='~'
7016b68e1f86Smrg	    for cmd in $cmds; do
7017b68e1f86Smrg	      IFS="$save_ifs"
7018b68e1f86Smrg	      eval cmd=\"$cmd\"
7019b68e1f86Smrg	      func_len " $cmd"
7020b68e1f86Smrg	      len=$func_len_result
7021b68e1f86Smrg	      if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
7022b68e1f86Smrg		func_show_eval "$cmd" 'exit $?'
7023b68e1f86Smrg		skipped_export=false
7024b68e1f86Smrg	      else
7025b68e1f86Smrg		# The command line is too long to execute in one step.
7026b68e1f86Smrg		func_verbose "using reloadable object file for export list..."
7027b68e1f86Smrg		skipped_export=:
7028b68e1f86Smrg		# Break out early, otherwise skipped_export may be
7029b68e1f86Smrg		# set to false by a later but shorter cmd.
7030b68e1f86Smrg		break
7031b68e1f86Smrg	      fi
7032b68e1f86Smrg	    done
7033b68e1f86Smrg	    IFS="$save_ifs"
7034b68e1f86Smrg	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
7035b68e1f86Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
7036b68e1f86Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
7037b68e1f86Smrg	    fi
7038b68e1f86Smrg	  fi
7039b68e1f86Smrg	fi
70406df26cacSmrg
7041b68e1f86Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
7042b68e1f86Smrg	  tmp_export_symbols="$export_symbols"
7043b68e1f86Smrg	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
7044b68e1f86Smrg	  $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
7045b68e1f86Smrg	fi
70466df26cacSmrg
7047b68e1f86Smrg	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
7048b68e1f86Smrg	  # The given exports_symbols file has to be filtered, so filter it.
7049b68e1f86Smrg	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
7050b68e1f86Smrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
7051b68e1f86Smrg	  # 's' commands which not all seds can handle. GNU sed should be fine
7052b68e1f86Smrg	  # though. Also, the filter scales superlinearly with the number of
7053b68e1f86Smrg	  # global variables. join(1) would be nice here, but unfortunately
7054b68e1f86Smrg	  # isn't a blessed tool.
7055b68e1f86Smrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
7056b68e1f86Smrg	  delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
7057b68e1f86Smrg	  export_symbols=$output_objdir/$libname.def
7058b68e1f86Smrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
70596df26cacSmrg	fi
70606df26cacSmrg
7061b68e1f86Smrg	tmp_deplibs=
7062a241306cSmrg	inst_prefix_arg=
7063b68e1f86Smrg	for test_deplib in $deplibs; do
7064b68e1f86Smrg	  case " $convenience " in
7065b68e1f86Smrg	  *" $test_deplib "*) ;;
7066b68e1f86Smrg	  *)
7067a241306cSmrg		if test -n "$inst_prefix_dir" && (echo "$test_deplib" | grep -- "$inst_prefix_dir" >/dev/null); then
7068a241306cSmrg			inst_prefix_arg="$inst_prefix_arg $test_deplib"
7069a241306cSmrg		else
7070a241306cSmrg			tmp_deplibs="$tmp_deplibs $test_deplib"
7071a241306cSmrg		fi
7072b68e1f86Smrg	    ;;
7073b68e1f86Smrg	  esac
7074b68e1f86Smrg	done
7075b68e1f86Smrg	deplibs="$tmp_deplibs"
7076a241306cSmrg	if test -n "$inst_prefix_arg"; then
7077a241306cSmrg		deplibs="$inst_prefix_arg $deplibs"
7078a241306cSmrg	fi
70796df26cacSmrg
7080b68e1f86Smrg	if test -n "$convenience"; then
7081b68e1f86Smrg	  if test -n "$whole_archive_flag_spec" &&
7082b68e1f86Smrg	    test "$compiler_needs_object" = yes &&
7083b68e1f86Smrg	    test -z "$libobjs"; then
7084b68e1f86Smrg	    # extract the archives, so we have objects to list.
7085b68e1f86Smrg	    # TODO: could optimize this to just extract one archive.
7086b68e1f86Smrg	    whole_archive_flag_spec=
7087b68e1f86Smrg	  fi
7088b68e1f86Smrg	  if test -n "$whole_archive_flag_spec"; then
7089b68e1f86Smrg	    save_libobjs=$libobjs
7090b68e1f86Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
7091b68e1f86Smrg	    test "X$libobjs" = "X " && libobjs=
7092b68e1f86Smrg	  else
7093b68e1f86Smrg	    gentop="$output_objdir/${outputname}x"
7094b68e1f86Smrg	    generated="$generated $gentop"
70956df26cacSmrg
7096b68e1f86Smrg	    func_extract_archives $gentop $convenience
7097b68e1f86Smrg	    libobjs="$libobjs $func_extract_archives_result"
7098b68e1f86Smrg	    test "X$libobjs" = "X " && libobjs=
7099b68e1f86Smrg	  fi
7100b68e1f86Smrg	fi
71016df26cacSmrg
7102b68e1f86Smrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
7103b68e1f86Smrg	  eval flag=\"$thread_safe_flag_spec\"
7104b68e1f86Smrg	  linker_flags="$linker_flags $flag"
7105b68e1f86Smrg	fi
71066df26cacSmrg
7107b68e1f86Smrg	# Make a backup of the uninstalled library when relinking
7108b68e1f86Smrg	if test "$mode" = relink; then
7109b68e1f86Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
71106df26cacSmrg	fi
71116df26cacSmrg
7112b68e1f86Smrg	# Do each of the archive commands.
7113b68e1f86Smrg	if test "$module" = yes && test -n "$module_cmds" ; then
7114b68e1f86Smrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
7115b68e1f86Smrg	    eval test_cmds=\"$module_expsym_cmds\"
7116b68e1f86Smrg	    cmds=$module_expsym_cmds
7117b68e1f86Smrg	  else
7118b68e1f86Smrg	    eval test_cmds=\"$module_cmds\"
7119b68e1f86Smrg	    cmds=$module_cmds
7120b68e1f86Smrg	  fi
7121b68e1f86Smrg	else
7122b68e1f86Smrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
7123b68e1f86Smrg	    eval test_cmds=\"$archive_expsym_cmds\"
7124b68e1f86Smrg	    cmds=$archive_expsym_cmds
7125b68e1f86Smrg	  else
7126b68e1f86Smrg	    eval test_cmds=\"$archive_cmds\"
7127b68e1f86Smrg	    cmds=$archive_cmds
7128b68e1f86Smrg	  fi
71296df26cacSmrg	fi
71306df26cacSmrg
7131b68e1f86Smrg	if test "X$skipped_export" != "X:" &&
7132b68e1f86Smrg	   func_len " $test_cmds" &&
7133b68e1f86Smrg	   len=$func_len_result &&
7134b68e1f86Smrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
7135b68e1f86Smrg	  :
7136b68e1f86Smrg	else
7137b68e1f86Smrg	  # The command line is too long to link in one step, link piecewise
7138b68e1f86Smrg	  # or, if using GNU ld and skipped_export is not :, use a linker
7139b68e1f86Smrg	  # script.
71406df26cacSmrg
7141b68e1f86Smrg	  # Save the value of $output and $libobjs because we want to
7142b68e1f86Smrg	  # use them later.  If we have whole_archive_flag_spec, we
7143b68e1f86Smrg	  # want to use save_libobjs as it was before
7144b68e1f86Smrg	  # whole_archive_flag_spec was expanded, because we can't
7145b68e1f86Smrg	  # assume the linker understands whole_archive_flag_spec.
7146b68e1f86Smrg	  # This may have to be revisited, in case too many
7147b68e1f86Smrg	  # convenience libraries get linked in and end up exceeding
7148b68e1f86Smrg	  # the spec.
7149b68e1f86Smrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
7150b68e1f86Smrg	    save_libobjs=$libobjs
7151b68e1f86Smrg	  fi
7152b68e1f86Smrg	  save_output=$output
7153b68e1f86Smrg	  output_la=`$ECHO "X$output" | $Xsed -e "$basename"`
71546df26cacSmrg
7155b68e1f86Smrg	  # Clear the reloadable object creation command queue and
7156b68e1f86Smrg	  # initialize k to one.
7157b68e1f86Smrg	  test_cmds=
7158b68e1f86Smrg	  concat_cmds=
7159b68e1f86Smrg	  objlist=
7160b68e1f86Smrg	  last_robj=
7161b68e1f86Smrg	  k=1
71626df26cacSmrg
7163b68e1f86Smrg	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
7164b68e1f86Smrg	    output=${output_objdir}/${output_la}.lnkscript
7165b68e1f86Smrg	    func_verbose "creating GNU ld script: $output"
7166b68e1f86Smrg	    $ECHO 'INPUT (' > $output
7167b68e1f86Smrg	    for obj in $save_libobjs
7168b68e1f86Smrg	    do
7169b68e1f86Smrg	      $ECHO "$obj" >> $output
7170b68e1f86Smrg	    done
7171b68e1f86Smrg	    $ECHO ')' >> $output
7172b68e1f86Smrg	    delfiles="$delfiles $output"
7173b68e1f86Smrg	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
7174b68e1f86Smrg	    output=${output_objdir}/${output_la}.lnk
7175b68e1f86Smrg	    func_verbose "creating linker input file list: $output"
7176b68e1f86Smrg	    : > $output
7177b68e1f86Smrg	    set x $save_libobjs
7178b68e1f86Smrg	    shift
7179b68e1f86Smrg	    firstobj=
7180b68e1f86Smrg	    if test "$compiler_needs_object" = yes; then
7181b68e1f86Smrg	      firstobj="$1 "
7182b68e1f86Smrg	      shift
7183b68e1f86Smrg	    fi
7184b68e1f86Smrg	    for obj
7185b68e1f86Smrg	    do
7186b68e1f86Smrg	      $ECHO "$obj" >> $output
7187b68e1f86Smrg	    done
7188b68e1f86Smrg	    delfiles="$delfiles $output"
7189b68e1f86Smrg	    output=$firstobj\"$file_list_spec$output\"
7190b68e1f86Smrg	  else
7191b68e1f86Smrg	    if test -n "$save_libobjs"; then
7192b68e1f86Smrg	      func_verbose "creating reloadable object files..."
7193b68e1f86Smrg	      output=$output_objdir/$output_la-${k}.$objext
7194b68e1f86Smrg	      eval test_cmds=\"$reload_cmds\"
7195b68e1f86Smrg	      func_len " $test_cmds"
7196b68e1f86Smrg	      len0=$func_len_result
7197b68e1f86Smrg	      len=$len0
7198b68e1f86Smrg
7199b68e1f86Smrg	      # Loop over the list of objects to be linked.
7200b68e1f86Smrg	      for obj in $save_libobjs
7201b68e1f86Smrg	      do
7202b68e1f86Smrg		func_len " $obj"
7203b68e1f86Smrg		func_arith $len + $func_len_result
7204b68e1f86Smrg		len=$func_arith_result
7205b68e1f86Smrg		if test "X$objlist" = X ||
7206b68e1f86Smrg		   test "$len" -lt "$max_cmd_len"; then
7207b68e1f86Smrg		  func_append objlist " $obj"
7208b68e1f86Smrg		else
7209b68e1f86Smrg		  # The command $test_cmds is almost too long, add a
7210b68e1f86Smrg		  # command to the queue.
7211b68e1f86Smrg		  if test "$k" -eq 1 ; then
7212b68e1f86Smrg		    # The first file doesn't have a previous command to add.
7213b68e1f86Smrg		    eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
7214b68e1f86Smrg		  else
7215b68e1f86Smrg		    # All subsequent reloadable object files will link in
7216b68e1f86Smrg		    # the last one created.
7217b68e1f86Smrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj~\$RM $last_robj\"
7218b68e1f86Smrg		  fi
7219b68e1f86Smrg		  last_robj=$output_objdir/$output_la-${k}.$objext
7220b68e1f86Smrg		  func_arith $k + 1
7221b68e1f86Smrg		  k=$func_arith_result
7222b68e1f86Smrg		  output=$output_objdir/$output_la-${k}.$objext
7223b68e1f86Smrg		  objlist=$obj
7224b68e1f86Smrg		  func_len " $last_robj"
7225b68e1f86Smrg		  func_arith $len0 + $func_len_result
7226b68e1f86Smrg		  len=$func_arith_result
7227b68e1f86Smrg		fi
7228b68e1f86Smrg	      done
7229b68e1f86Smrg	      # Handle the remaining objects by creating one last
7230b68e1f86Smrg	      # reloadable object file.  All subsequent reloadable object
7231b68e1f86Smrg	      # files will link in the last one created.
7232b68e1f86Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
7233b68e1f86Smrg	      eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
7234b68e1f86Smrg	      if test -n "$last_robj"; then
7235b68e1f86Smrg	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
7236b68e1f86Smrg	      fi
7237b68e1f86Smrg	      delfiles="$delfiles $output"
72386df26cacSmrg
7239b68e1f86Smrg	    else
7240b68e1f86Smrg	      output=
7241b68e1f86Smrg	    fi
7242b68e1f86Smrg
7243b68e1f86Smrg	    if ${skipped_export-false}; then
7244b68e1f86Smrg	      func_verbose "generating symbol list for \`$libname.la'"
7245b68e1f86Smrg	      export_symbols="$output_objdir/$libname.exp"
7246b68e1f86Smrg	      $opt_dry_run || $RM $export_symbols
7247b68e1f86Smrg	      libobjs=$output
7248b68e1f86Smrg	      # Append the command to create the export file.
7249b68e1f86Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
7250b68e1f86Smrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
7251b68e1f86Smrg	      if test -n "$last_robj"; then
7252b68e1f86Smrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
7253b68e1f86Smrg	      fi
7254b68e1f86Smrg	    fi
72556df26cacSmrg
7256b68e1f86Smrg	    test -n "$save_libobjs" &&
7257b68e1f86Smrg	      func_verbose "creating a temporary reloadable object file: $output"
72586df26cacSmrg
7259b68e1f86Smrg	    # Loop through the commands generated above and execute them.
7260b68e1f86Smrg	    save_ifs="$IFS"; IFS='~'
7261b68e1f86Smrg	    for cmd in $concat_cmds; do
7262b68e1f86Smrg	      IFS="$save_ifs"
7263b68e1f86Smrg	      $opt_silent || {
7264b68e1f86Smrg		  func_quote_for_expand "$cmd"
7265b68e1f86Smrg		  eval "func_echo $func_quote_for_expand_result"
7266b68e1f86Smrg	      }
7267b68e1f86Smrg	      $opt_dry_run || eval "$cmd" || {
7268b68e1f86Smrg		lt_exit=$?
7269b68e1f86Smrg
7270b68e1f86Smrg		# Restore the uninstalled library and exit
7271b68e1f86Smrg		if test "$mode" = relink; then
7272b68e1f86Smrg		  ( cd "$output_objdir" && \
7273b68e1f86Smrg		    $RM "${realname}T" && \
7274b68e1f86Smrg		    $MV "${realname}U" "$realname" )
7275b68e1f86Smrg		fi
72766df26cacSmrg
7277b68e1f86Smrg		exit $lt_exit
7278b68e1f86Smrg	      }
7279b68e1f86Smrg	    done
7280b68e1f86Smrg	    IFS="$save_ifs"
72816df26cacSmrg
7282b68e1f86Smrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
7283b68e1f86Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
7284b68e1f86Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
72856df26cacSmrg	    fi
72866df26cacSmrg	  fi
72876df26cacSmrg
7288b68e1f86Smrg          if ${skipped_export-false}; then
7289b68e1f86Smrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
7290b68e1f86Smrg	      tmp_export_symbols="$export_symbols"
7291b68e1f86Smrg	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
7292b68e1f86Smrg	      $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
7293b68e1f86Smrg	    fi
72946df26cacSmrg
7295b68e1f86Smrg	    if test -n "$orig_export_symbols"; then
7296b68e1f86Smrg	      # The given exports_symbols file has to be filtered, so filter it.
7297b68e1f86Smrg	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
7298b68e1f86Smrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
7299b68e1f86Smrg	      # 's' commands which not all seds can handle. GNU sed should be fine
7300b68e1f86Smrg	      # though. Also, the filter scales superlinearly with the number of
7301b68e1f86Smrg	      # global variables. join(1) would be nice here, but unfortunately
7302b68e1f86Smrg	      # isn't a blessed tool.
7303b68e1f86Smrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
7304b68e1f86Smrg	      delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
7305b68e1f86Smrg	      export_symbols=$output_objdir/$libname.def
7306b68e1f86Smrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
7307b68e1f86Smrg	    fi
7308b68e1f86Smrg	  fi
73096df26cacSmrg
7310b68e1f86Smrg	  libobjs=$output
7311b68e1f86Smrg	  # Restore the value of output.
7312b68e1f86Smrg	  output=$save_output
73136df26cacSmrg
7314b68e1f86Smrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
7315b68e1f86Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
7316b68e1f86Smrg	    test "X$libobjs" = "X " && libobjs=
7317b68e1f86Smrg	  fi
7318b68e1f86Smrg	  # Expand the library linking commands again to reset the
7319b68e1f86Smrg	  # value of $libobjs for piecewise linking.
7320b68e1f86Smrg
7321b68e1f86Smrg	  # Do each of the archive commands.
7322b68e1f86Smrg	  if test "$module" = yes && test -n "$module_cmds" ; then
7323b68e1f86Smrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
7324b68e1f86Smrg	      cmds=$module_expsym_cmds
73256df26cacSmrg	    else
7326b68e1f86Smrg	      cmds=$module_cmds
73276df26cacSmrg	    fi
73286df26cacSmrg	  else
7329b68e1f86Smrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
7330b68e1f86Smrg	      cmds=$archive_expsym_cmds
7331b68e1f86Smrg	    else
7332b68e1f86Smrg	      cmds=$archive_cmds
7333b68e1f86Smrg	    fi
73346df26cacSmrg	  fi
73356df26cacSmrg	fi
73366df26cacSmrg
7337b68e1f86Smrg	if test -n "$delfiles"; then
7338b68e1f86Smrg	  # Append the command to remove temporary files to $cmds.
7339b68e1f86Smrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
7340b68e1f86Smrg	fi
73416df26cacSmrg
7342b68e1f86Smrg	# Add any objects from preloaded convenience libraries
7343b68e1f86Smrg	if test -n "$dlprefiles"; then
7344b68e1f86Smrg	  gentop="$output_objdir/${outputname}x"
7345b68e1f86Smrg	  generated="$generated $gentop"
73466df26cacSmrg
7347b68e1f86Smrg	  func_extract_archives $gentop $dlprefiles
7348b68e1f86Smrg	  libobjs="$libobjs $func_extract_archives_result"
7349b68e1f86Smrg	  test "X$libobjs" = "X " && libobjs=
73506df26cacSmrg	fi
73516df26cacSmrg
7352b68e1f86Smrg	save_ifs="$IFS"; IFS='~'
7353b68e1f86Smrg	for cmd in $cmds; do
7354b68e1f86Smrg	  IFS="$save_ifs"
7355b68e1f86Smrg	  eval cmd=\"$cmd\"
7356b68e1f86Smrg	  $opt_silent || {
7357b68e1f86Smrg	    func_quote_for_expand "$cmd"
7358b68e1f86Smrg	    eval "func_echo $func_quote_for_expand_result"
7359b68e1f86Smrg	  }
7360b68e1f86Smrg	  $opt_dry_run || eval "$cmd" || {
7361b68e1f86Smrg	    lt_exit=$?
73626df26cacSmrg
7363b68e1f86Smrg	    # Restore the uninstalled library and exit
7364b68e1f86Smrg	    if test "$mode" = relink; then
7365b68e1f86Smrg	      ( cd "$output_objdir" && \
7366b68e1f86Smrg	        $RM "${realname}T" && \
7367b68e1f86Smrg		$MV "${realname}U" "$realname" )
73686df26cacSmrg	    fi
73696df26cacSmrg
7370b68e1f86Smrg	    exit $lt_exit
7371b68e1f86Smrg	  }
7372b68e1f86Smrg	done
7373b68e1f86Smrg	IFS="$save_ifs"
73746df26cacSmrg
7375b68e1f86Smrg	# Restore the uninstalled library and exit
7376b68e1f86Smrg	if test "$mode" = relink; then
7377b68e1f86Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
73786df26cacSmrg
7379b68e1f86Smrg	  if test -n "$convenience"; then
7380b68e1f86Smrg	    if test -z "$whole_archive_flag_spec"; then
7381b68e1f86Smrg	      func_show_eval '${RM}r "$gentop"'
7382b68e1f86Smrg	    fi
7383b68e1f86Smrg	  fi
73846df26cacSmrg
7385b68e1f86Smrg	  exit $EXIT_SUCCESS
7386b68e1f86Smrg	fi
73876df26cacSmrg
7388b68e1f86Smrg	# Create links to the real library.
7389b68e1f86Smrg	for linkname in $linknames; do
7390b68e1f86Smrg	  if test "$realname" != "$linkname"; then
7391b68e1f86Smrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
73926df26cacSmrg	  fi
73936df26cacSmrg	done
73946df26cacSmrg
7395b68e1f86Smrg	# If -module or -export-dynamic was specified, set the dlname.
7396b68e1f86Smrg	if test "$module" = yes || test "$export_dynamic" = yes; then
7397b68e1f86Smrg	  # On all known operating systems, these are identical.
7398b68e1f86Smrg	  dlname="$soname"
7399b68e1f86Smrg	fi
7400b68e1f86Smrg      fi
74016df26cacSmrg      ;;
74026df26cacSmrg
7403b68e1f86Smrg    obj)
7404b68e1f86Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
7405b68e1f86Smrg	func_warning "\`-dlopen' is ignored for objects"
7406b68e1f86Smrg      fi
74076df26cacSmrg
7408b68e1f86Smrg      case " $deplibs" in
7409b68e1f86Smrg      *\ -l* | *\ -L*)
7410b68e1f86Smrg	func_warning "\`-l' and \`-L' are ignored for objects" ;;
74116df26cacSmrg      esac
74126df26cacSmrg
7413b68e1f86Smrg      test -n "$rpath" && \
7414b68e1f86Smrg	func_warning "\`-rpath' is ignored for objects"
74156df26cacSmrg
7416b68e1f86Smrg      test -n "$xrpath" && \
7417b68e1f86Smrg	func_warning "\`-R' is ignored for objects"
74186df26cacSmrg
7419b68e1f86Smrg      test -n "$vinfo" && \
7420b68e1f86Smrg	func_warning "\`-version-info' is ignored for objects"
7421b68e1f86Smrg
7422b68e1f86Smrg      test -n "$release" && \
7423b68e1f86Smrg	func_warning "\`-release' is ignored for objects"
7424b68e1f86Smrg
7425b68e1f86Smrg      case $output in
7426b68e1f86Smrg      *.lo)
7427b68e1f86Smrg	test -n "$objs$old_deplibs" && \
7428b68e1f86Smrg	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
7429b68e1f86Smrg
7430b68e1f86Smrg	libobj=$output
7431b68e1f86Smrg	func_lo2o "$libobj"
7432b68e1f86Smrg	obj=$func_lo2o_result
74336df26cacSmrg	;;
74346df26cacSmrg      *)
7435b68e1f86Smrg	libobj=
7436b68e1f86Smrg	obj="$output"
74376df26cacSmrg	;;
74386df26cacSmrg      esac
74396df26cacSmrg
7440b68e1f86Smrg      # Delete the old objects.
7441b68e1f86Smrg      $opt_dry_run || $RM $obj $libobj
74426df26cacSmrg
7443b68e1f86Smrg      # Objects from convenience libraries.  This assumes
7444b68e1f86Smrg      # single-version convenience libraries.  Whenever we create
7445b68e1f86Smrg      # different ones for PIC/non-PIC, this we'll have to duplicate
7446b68e1f86Smrg      # the extraction.
7447b68e1f86Smrg      reload_conv_objs=
7448b68e1f86Smrg      gentop=
7449b68e1f86Smrg      # reload_cmds runs $LD directly, so let us get rid of
7450b68e1f86Smrg      # -Wl from whole_archive_flag_spec and hope we can get by with
7451b68e1f86Smrg      # turning comma into space..
7452b68e1f86Smrg      wl=
74536df26cacSmrg
7454b68e1f86Smrg      if test -n "$convenience"; then
7455b68e1f86Smrg	if test -n "$whole_archive_flag_spec"; then
7456b68e1f86Smrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
7457b68e1f86Smrg	  reload_conv_objs=$reload_objs\ `$ECHO "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'`
7458b68e1f86Smrg	else
7459b68e1f86Smrg	  gentop="$output_objdir/${obj}x"
7460b68e1f86Smrg	  generated="$generated $gentop"
74616df26cacSmrg
7462b68e1f86Smrg	  func_extract_archives $gentop $convenience
7463b68e1f86Smrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
7464b68e1f86Smrg	fi
74656df26cacSmrg      fi
74666df26cacSmrg
7467b68e1f86Smrg      # Create the old-style object.
7468b68e1f86Smrg      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
74696df26cacSmrg
7470b68e1f86Smrg      output="$obj"
7471b68e1f86Smrg      func_execute_cmds "$reload_cmds" 'exit $?'
74726df26cacSmrg
7473b68e1f86Smrg      # Exit if we aren't doing a library object file.
7474b68e1f86Smrg      if test -z "$libobj"; then
7475b68e1f86Smrg	if test -n "$gentop"; then
7476b68e1f86Smrg	  func_show_eval '${RM}r "$gentop"'
7477b68e1f86Smrg	fi
7478b68e1f86Smrg
7479b68e1f86Smrg	exit $EXIT_SUCCESS
74806df26cacSmrg      fi
7481b68e1f86Smrg
7482b68e1f86Smrg      if test "$build_libtool_libs" != yes; then
7483b68e1f86Smrg	if test -n "$gentop"; then
7484b68e1f86Smrg	  func_show_eval '${RM}r "$gentop"'
7485b68e1f86Smrg	fi
7486b68e1f86Smrg
7487b68e1f86Smrg	# Create an invalid libtool object if no PIC, so that we don't
7488b68e1f86Smrg	# accidentally link it into a program.
7489b68e1f86Smrg	# $show "echo timestamp > $libobj"
7490b68e1f86Smrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
7491b68e1f86Smrg	exit $EXIT_SUCCESS
7492b68e1f86Smrg      fi
7493b68e1f86Smrg
7494b68e1f86Smrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
7495b68e1f86Smrg	# Only do commands if we really have different PIC objects.
7496b68e1f86Smrg	reload_objs="$libobjs $reload_conv_objs"
7497b68e1f86Smrg	output="$libobj"
7498b68e1f86Smrg	func_execute_cmds "$reload_cmds" 'exit $?'
7499b68e1f86Smrg      fi
7500b68e1f86Smrg
7501b68e1f86Smrg      if test -n "$gentop"; then
7502b68e1f86Smrg	func_show_eval '${RM}r "$gentop"'
7503b68e1f86Smrg      fi
7504b68e1f86Smrg
7505b68e1f86Smrg      exit $EXIT_SUCCESS
75066df26cacSmrg      ;;
75076df26cacSmrg
7508b68e1f86Smrg    prog)
7509b68e1f86Smrg      case $host in
7510b68e1f86Smrg	*cygwin*) func_stripname '' '.exe' "$output"
7511b68e1f86Smrg	          output=$func_stripname_result.exe;;
7512b68e1f86Smrg      esac
7513b68e1f86Smrg      test -n "$vinfo" && \
7514b68e1f86Smrg	func_warning "\`-version-info' is ignored for programs"
75156df26cacSmrg
7516b68e1f86Smrg      test -n "$release" && \
7517b68e1f86Smrg	func_warning "\`-release' is ignored for programs"
75186df26cacSmrg
7519b68e1f86Smrg      test "$preload" = yes \
7520b68e1f86Smrg        && test "$dlopen_support" = unknown \
7521b68e1f86Smrg	&& test "$dlopen_self" = unknown \
7522b68e1f86Smrg	&& test "$dlopen_self_static" = unknown && \
7523b68e1f86Smrg	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
7524b68e1f86Smrg
7525b68e1f86Smrg      case $host in
7526b68e1f86Smrg      *-*-rhapsody* | *-*-darwin1.[012])
7527b68e1f86Smrg	# On Rhapsody replace the C library is the System framework
7528b68e1f86Smrg	compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
7529b68e1f86Smrg	finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
75306df26cacSmrg	;;
7531b68e1f86Smrg      esac
75326df26cacSmrg
7533b68e1f86Smrg      case $host in
7534b68e1f86Smrg      *-*-darwin*)
7535b68e1f86Smrg	# Don't allow lazy linking, it breaks C++ global constructors
7536b68e1f86Smrg	# But is supposedly fixed on 10.4 or later (yay!).
7537b68e1f86Smrg	if test "$tagname" = CXX ; then
7538b68e1f86Smrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
7539b68e1f86Smrg	    10.[0123])
7540b68e1f86Smrg	      compile_command="$compile_command ${wl}-bind_at_load"
7541b68e1f86Smrg	      finalize_command="$finalize_command ${wl}-bind_at_load"
7542b68e1f86Smrg	    ;;
7543b68e1f86Smrg	  esac
75446df26cacSmrg	fi
7545b68e1f86Smrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
7546b68e1f86Smrg	compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
7547b68e1f86Smrg	finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
7548b68e1f86Smrg	;;
7549b68e1f86Smrg      esac
75506df26cacSmrg
75516df26cacSmrg
7552b68e1f86Smrg      # move library search paths that coincide with paths to not yet
7553b68e1f86Smrg      # installed libraries to the beginning of the library search list
7554b68e1f86Smrg      new_libs=
7555b68e1f86Smrg      for path in $notinst_path; do
7556b68e1f86Smrg	case " $new_libs " in
7557b68e1f86Smrg	*" -L$path/$objdir "*) ;;
7558b68e1f86Smrg	*)
7559b68e1f86Smrg	  case " $compile_deplibs " in
7560b68e1f86Smrg	  *" -L$path/$objdir "*)
7561b68e1f86Smrg	    new_libs="$new_libs -L$path/$objdir" ;;
75626df26cacSmrg	  esac
7563b68e1f86Smrg	  ;;
7564b68e1f86Smrg	esac
7565b68e1f86Smrg      done
7566b68e1f86Smrg      for deplib in $compile_deplibs; do
7567b68e1f86Smrg	case $deplib in
7568b68e1f86Smrg	-L*)
7569b68e1f86Smrg	  case " $new_libs " in
7570b68e1f86Smrg	  *" $deplib "*) ;;
7571b68e1f86Smrg	  *) new_libs="$new_libs $deplib" ;;
75726df26cacSmrg	  esac
7573b68e1f86Smrg	  ;;
7574b68e1f86Smrg	*) new_libs="$new_libs $deplib" ;;
7575b68e1f86Smrg	esac
7576b68e1f86Smrg      done
7577b68e1f86Smrg      compile_deplibs="$new_libs"
75786df26cacSmrg
75796df26cacSmrg
7580b68e1f86Smrg      compile_command="$compile_command $compile_deplibs"
7581b68e1f86Smrg      finalize_command="$finalize_command $finalize_deplibs"
75826df26cacSmrg
7583b68e1f86Smrg      if test -n "$rpath$xrpath"; then
7584b68e1f86Smrg	# If the user specified any rpath flags, then add them.
7585b68e1f86Smrg	for libdir in $rpath $xrpath; do
7586b68e1f86Smrg	  # This is the magic to use -rpath.
7587b68e1f86Smrg	  case "$finalize_rpath " in
7588b68e1f86Smrg	  *" $libdir "*) ;;
7589b68e1f86Smrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
7590b68e1f86Smrg	  esac
7591b68e1f86Smrg	done
7592b68e1f86Smrg      fi
75936df26cacSmrg
7594b68e1f86Smrg      # Now hardcode the library paths
7595b68e1f86Smrg      rpath=
7596b68e1f86Smrg      hardcode_libdirs=
7597b68e1f86Smrg      for libdir in $compile_rpath $finalize_rpath; do
7598b68e1f86Smrg	if test -n "$hardcode_libdir_flag_spec"; then
7599b68e1f86Smrg	  if test -n "$hardcode_libdir_separator"; then
7600b68e1f86Smrg	    if test -z "$hardcode_libdirs"; then
7601b68e1f86Smrg	      hardcode_libdirs="$libdir"
7602b68e1f86Smrg	    else
7603b68e1f86Smrg	      # Just accumulate the unique libdirs.
7604b68e1f86Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
7605b68e1f86Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
7606b68e1f86Smrg		;;
7607b68e1f86Smrg	      *)
7608b68e1f86Smrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
7609b68e1f86Smrg		;;
7610b68e1f86Smrg	      esac
7611b68e1f86Smrg	    fi
76126df26cacSmrg	  else
7613b68e1f86Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
7614b68e1f86Smrg	    rpath="$rpath $flag"
76156df26cacSmrg	  fi
7616b68e1f86Smrg	elif test -n "$runpath_var"; then
7617b68e1f86Smrg	  case "$perm_rpath " in
7618b68e1f86Smrg	  *" $libdir "*) ;;
7619b68e1f86Smrg	  *) perm_rpath="$perm_rpath $libdir" ;;
7620b68e1f86Smrg	  esac
7621b68e1f86Smrg	fi
7622b68e1f86Smrg	case $host in
7623b68e1f86Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
7624b68e1f86Smrg	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
7625b68e1f86Smrg	  case :$dllsearchpath: in
7626b68e1f86Smrg	  *":$libdir:"*) ;;
7627b68e1f86Smrg	  ::) dllsearchpath=$libdir;;
7628b68e1f86Smrg	  *) dllsearchpath="$dllsearchpath:$libdir";;
7629b68e1f86Smrg	  esac
7630b68e1f86Smrg	  case :$dllsearchpath: in
7631b68e1f86Smrg	  *":$testbindir:"*) ;;
7632b68e1f86Smrg	  ::) dllsearchpath=$testbindir;;
7633b68e1f86Smrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
7634b68e1f86Smrg	  esac
7635b68e1f86Smrg	  ;;
7636b68e1f86Smrg	esac
7637b68e1f86Smrg      done
7638b68e1f86Smrg      # Substitute the hardcoded libdirs into the rpath.
7639b68e1f86Smrg      if test -n "$hardcode_libdir_separator" &&
7640b68e1f86Smrg	 test -n "$hardcode_libdirs"; then
7641b68e1f86Smrg	libdir="$hardcode_libdirs"
7642b68e1f86Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
7643b68e1f86Smrg      fi
7644b68e1f86Smrg      compile_rpath="$rpath"
76456df26cacSmrg
7646b68e1f86Smrg      rpath=
7647b68e1f86Smrg      hardcode_libdirs=
7648b68e1f86Smrg      for libdir in $finalize_rpath; do
7649b68e1f86Smrg	if test -n "$hardcode_libdir_flag_spec"; then
7650b68e1f86Smrg	  if test -n "$hardcode_libdir_separator"; then
7651b68e1f86Smrg	    if test -z "$hardcode_libdirs"; then
7652b68e1f86Smrg	      hardcode_libdirs="$libdir"
7653b68e1f86Smrg	    else
7654b68e1f86Smrg	      # Just accumulate the unique libdirs.
7655b68e1f86Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
7656b68e1f86Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
7657b68e1f86Smrg		;;
7658b68e1f86Smrg	      *)
7659b68e1f86Smrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
7660b68e1f86Smrg		;;
7661b68e1f86Smrg	      esac
7662b68e1f86Smrg	    fi
76636df26cacSmrg	  else
7664b68e1f86Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
7665b68e1f86Smrg	    rpath="$rpath $flag"
76666df26cacSmrg	  fi
7667b68e1f86Smrg	elif test -n "$runpath_var"; then
7668b68e1f86Smrg	  case "$finalize_perm_rpath " in
7669b68e1f86Smrg	  *" $libdir "*) ;;
7670b68e1f86Smrg	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
7671b68e1f86Smrg	  esac
76726df26cacSmrg	fi
7673b68e1f86Smrg      done
7674b68e1f86Smrg      # Substitute the hardcoded libdirs into the rpath.
7675b68e1f86Smrg      if test -n "$hardcode_libdir_separator" &&
7676b68e1f86Smrg	 test -n "$hardcode_libdirs"; then
7677b68e1f86Smrg	libdir="$hardcode_libdirs"
7678b68e1f86Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
7679b68e1f86Smrg      fi
7680b68e1f86Smrg      finalize_rpath="$rpath"
76816df26cacSmrg
7682b68e1f86Smrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
7683b68e1f86Smrg	# Transform all the library objects into standard objects.
7684b68e1f86Smrg	compile_command=`$ECHO "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
7685b68e1f86Smrg	finalize_command=`$ECHO "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
7686b68e1f86Smrg      fi
76876df26cacSmrg
7688b68e1f86Smrg      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
76896df26cacSmrg
7690b68e1f86Smrg      # template prelinking step
7691b68e1f86Smrg      if test -n "$prelink_cmds"; then
7692b68e1f86Smrg	func_execute_cmds "$prelink_cmds" 'exit $?'
7693b68e1f86Smrg      fi
76946df26cacSmrg
7695b68e1f86Smrg      wrappers_required=yes
7696b68e1f86Smrg      case $host in
7697b68e1f86Smrg      *cygwin* | *mingw* )
7698b68e1f86Smrg        if test "$build_libtool_libs" != yes; then
7699b68e1f86Smrg          wrappers_required=no
7700b68e1f86Smrg        fi
7701b68e1f86Smrg        ;;
7702b68e1f86Smrg      *cegcc)
7703b68e1f86Smrg        # Disable wrappers for cegcc, we are cross compiling anyway.
7704b68e1f86Smrg        wrappers_required=no
7705b68e1f86Smrg        ;;
7706b68e1f86Smrg      *)
7707b68e1f86Smrg        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
7708b68e1f86Smrg          wrappers_required=no
7709b68e1f86Smrg        fi
7710b68e1f86Smrg        ;;
7711b68e1f86Smrg      esac
7712b68e1f86Smrg      if test "$wrappers_required" = no; then
7713b68e1f86Smrg	# Replace the output file specification.
7714b68e1f86Smrg	compile_command=`$ECHO "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
7715b68e1f86Smrg	link_command="$compile_command$compile_rpath"
77166df26cacSmrg
7717b68e1f86Smrg	# We have no uninstalled library dependencies, so finalize right now.
7718b68e1f86Smrg	exit_status=0
7719b68e1f86Smrg	func_show_eval "$link_command" 'exit_status=$?'
77206df26cacSmrg
7721b68e1f86Smrg	# Delete the generated files.
7722b68e1f86Smrg	if test -f "$output_objdir/${outputname}S.${objext}"; then
7723b68e1f86Smrg	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
77246df26cacSmrg	fi
77256df26cacSmrg
7726b68e1f86Smrg	exit $exit_status
7727b68e1f86Smrg      fi
77286df26cacSmrg
7729b68e1f86Smrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
7730b68e1f86Smrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
7731b68e1f86Smrg      fi
7732b68e1f86Smrg      if test -n "$finalize_shlibpath"; then
7733b68e1f86Smrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
7734b68e1f86Smrg      fi
77356df26cacSmrg
7736b68e1f86Smrg      compile_var=
7737b68e1f86Smrg      finalize_var=
7738b68e1f86Smrg      if test -n "$runpath_var"; then
7739b68e1f86Smrg	if test -n "$perm_rpath"; then
7740b68e1f86Smrg	  # We should set the runpath_var.
7741b68e1f86Smrg	  rpath=
7742b68e1f86Smrg	  for dir in $perm_rpath; do
7743b68e1f86Smrg	    rpath="$rpath$dir:"
7744b68e1f86Smrg	  done
7745b68e1f86Smrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
77466df26cacSmrg	fi
7747b68e1f86Smrg	if test -n "$finalize_perm_rpath"; then
7748b68e1f86Smrg	  # We should set the runpath_var.
7749b68e1f86Smrg	  rpath=
7750b68e1f86Smrg	  for dir in $finalize_perm_rpath; do
7751b68e1f86Smrg	    rpath="$rpath$dir:"
7752b68e1f86Smrg	  done
7753b68e1f86Smrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
77546df26cacSmrg	fi
7755b68e1f86Smrg      fi
77566df26cacSmrg
7757b68e1f86Smrg      if test "$no_install" = yes; then
7758b68e1f86Smrg	# We don't need to create a wrapper script.
7759b68e1f86Smrg	link_command="$compile_var$compile_command$compile_rpath"
7760b68e1f86Smrg	# Replace the output file specification.
7761b68e1f86Smrg	link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
7762b68e1f86Smrg	# Delete the old output file.
7763b68e1f86Smrg	$opt_dry_run || $RM $output
7764b68e1f86Smrg	# Link the executable and exit
7765b68e1f86Smrg	func_show_eval "$link_command" 'exit $?'
77666df26cacSmrg	exit $EXIT_SUCCESS
7767b68e1f86Smrg      fi
77686df26cacSmrg
7769b68e1f86Smrg      if test "$hardcode_action" = relink; then
7770b68e1f86Smrg	# Fast installation is not supported
7771b68e1f86Smrg	link_command="$compile_var$compile_command$compile_rpath"
7772b68e1f86Smrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
7773b68e1f86Smrg
7774b68e1f86Smrg	func_warning "this platform does not like uninstalled shared libraries"
7775b68e1f86Smrg	func_warning "\`$output' will be relinked during installation"
7776b68e1f86Smrg      else
7777b68e1f86Smrg	if test "$fast_install" != no; then
7778b68e1f86Smrg	  link_command="$finalize_var$compile_command$finalize_rpath"
7779b68e1f86Smrg	  if test "$fast_install" = yes; then
7780b68e1f86Smrg	    relink_command=`$ECHO "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
7781b68e1f86Smrg	  else
7782b68e1f86Smrg	    # fast_install is set to needless
7783b68e1f86Smrg	    relink_command=
7784b68e1f86Smrg	  fi
77856df26cacSmrg	else
7786b68e1f86Smrg	  link_command="$compile_var$compile_command$compile_rpath"
7787b68e1f86Smrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
77886df26cacSmrg	fi
7789b68e1f86Smrg      fi
77906df26cacSmrg
7791b68e1f86Smrg      # Replace the output file specification.
7792b68e1f86Smrg      link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
77936df26cacSmrg
7794b68e1f86Smrg      # Delete the old output files.
7795b68e1f86Smrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
77966df26cacSmrg
7797b68e1f86Smrg      func_show_eval "$link_command" 'exit $?'
77986df26cacSmrg
7799b68e1f86Smrg      # Now create the wrapper script.
7800b68e1f86Smrg      func_verbose "creating $output"
78016df26cacSmrg
7802b68e1f86Smrg      # Quote the relink command for shipping.
7803b68e1f86Smrg      if test -n "$relink_command"; then
7804b68e1f86Smrg	# Preserve any variables that may affect compiler behavior
7805b68e1f86Smrg	for var in $variables_saved_for_relink; do
7806b68e1f86Smrg	  if eval test -z \"\${$var+set}\"; then
7807b68e1f86Smrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
7808b68e1f86Smrg	  elif eval var_value=\$$var; test -z "$var_value"; then
7809b68e1f86Smrg	    relink_command="$var=; export $var; $relink_command"
78106df26cacSmrg	  else
7811b68e1f86Smrg	    func_quote_for_eval "$var_value"
7812b68e1f86Smrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
78136df26cacSmrg	  fi
7814b68e1f86Smrg	done
7815b68e1f86Smrg	relink_command="(cd `pwd`; $relink_command)"
7816b68e1f86Smrg	relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
7817b68e1f86Smrg      fi
78186df26cacSmrg
7819b68e1f86Smrg      # Quote $ECHO for shipping.
7820b68e1f86Smrg      if test "X$ECHO" = "X$SHELL $progpath --fallback-echo"; then
7821b68e1f86Smrg	case $progpath in
7822b68e1f86Smrg	[\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
7823b68e1f86Smrg	*) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
7824b68e1f86Smrg	esac
7825b68e1f86Smrg	qecho=`$ECHO "X$qecho" | $Xsed -e "$sed_quote_subst"`
7826b68e1f86Smrg      else
7827b68e1f86Smrg	qecho=`$ECHO "X$ECHO" | $Xsed -e "$sed_quote_subst"`
7828b68e1f86Smrg      fi
7829b68e1f86Smrg
7830b68e1f86Smrg      # Only actually do things if not in dry run mode.
7831b68e1f86Smrg      $opt_dry_run || {
7832b68e1f86Smrg	# win32 will think the script is a binary if it has
7833b68e1f86Smrg	# a .exe suffix, so we strip it off here.
7834b68e1f86Smrg	case $output in
7835b68e1f86Smrg	  *.exe) func_stripname '' '.exe' "$output"
7836b68e1f86Smrg	         output=$func_stripname_result ;;
7837b68e1f86Smrg	esac
7838b68e1f86Smrg	# test for cygwin because mv fails w/o .exe extensions
7839b68e1f86Smrg	case $host in
7840b68e1f86Smrg	  *cygwin*)
7841b68e1f86Smrg	    exeext=.exe
7842b68e1f86Smrg	    func_stripname '' '.exe' "$outputname"
7843b68e1f86Smrg	    outputname=$func_stripname_result ;;
7844b68e1f86Smrg	  *) exeext= ;;
78456df26cacSmrg	esac
7846b68e1f86Smrg	case $host in
7847b68e1f86Smrg	  *cygwin* | *mingw* )
7848b68e1f86Smrg	    func_dirname_and_basename "$output" "" "."
7849b68e1f86Smrg	    output_name=$func_basename_result
7850b68e1f86Smrg	    output_path=$func_dirname_result
7851b68e1f86Smrg	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
7852b68e1f86Smrg	    cwrapper="$output_path/$output_name.exe"
7853b68e1f86Smrg	    $RM $cwrappersource $cwrapper
7854b68e1f86Smrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
7855b68e1f86Smrg
7856b68e1f86Smrg	    func_emit_cwrapperexe_src > $cwrappersource
7857b68e1f86Smrg
7858b68e1f86Smrg	    # The wrapper executable is built using the $host compiler,
7859b68e1f86Smrg	    # because it contains $host paths and files. If cross-
7860b68e1f86Smrg	    # compiling, it, like the target executable, must be
7861b68e1f86Smrg	    # executed on the $host or under an emulation environment.
7862b68e1f86Smrg	    $opt_dry_run || {
7863b68e1f86Smrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
7864b68e1f86Smrg	      $STRIP $cwrapper
7865b68e1f86Smrg	    }
78666df26cacSmrg
7867b68e1f86Smrg	    # Now, create the wrapper script for func_source use:
7868b68e1f86Smrg	    func_ltwrapper_scriptname $cwrapper
7869b68e1f86Smrg	    $RM $func_ltwrapper_scriptname_result
7870b68e1f86Smrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
7871b68e1f86Smrg	    $opt_dry_run || {
7872b68e1f86Smrg	      # note: this script will not be executed, so do not chmod.
7873b68e1f86Smrg	      if test "x$build" = "x$host" ; then
7874b68e1f86Smrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
7875b68e1f86Smrg	      else
7876b68e1f86Smrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
7877b68e1f86Smrg	      fi
7878b68e1f86Smrg	    }
7879b68e1f86Smrg	  ;;
7880b68e1f86Smrg	  * )
7881b68e1f86Smrg	    $RM $output
7882b68e1f86Smrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
78836df26cacSmrg
7884b68e1f86Smrg	    func_emit_wrapper no > $output
7885b68e1f86Smrg	    chmod +x $output
7886b68e1f86Smrg	  ;;
7887b68e1f86Smrg	esac
7888b68e1f86Smrg      }
7889b68e1f86Smrg      exit $EXIT_SUCCESS
7890b68e1f86Smrg      ;;
7891b68e1f86Smrg    esac
78926df26cacSmrg
7893b68e1f86Smrg    # See if we need to build an old-fashioned archive.
7894b68e1f86Smrg    for oldlib in $oldlibs; do
78956df26cacSmrg
7896b68e1f86Smrg      if test "$build_libtool_libs" = convenience; then
7897b68e1f86Smrg	oldobjs="$libobjs_save $symfileobj"
7898b68e1f86Smrg	addlibs="$convenience"
7899b68e1f86Smrg	build_libtool_libs=no
7900b68e1f86Smrg      else
7901b68e1f86Smrg	if test "$build_libtool_libs" = module; then
7902b68e1f86Smrg	  oldobjs="$libobjs_save"
7903b68e1f86Smrg	  build_libtool_libs=no
7904b68e1f86Smrg	else
7905b68e1f86Smrg	  oldobjs="$old_deplibs $non_pic_objects"
7906b68e1f86Smrg	  if test "$preload" = yes && test -f "$symfileobj"; then
7907b68e1f86Smrg	    oldobjs="$oldobjs $symfileobj"
7908b68e1f86Smrg	  fi
7909b68e1f86Smrg	fi
7910b68e1f86Smrg	addlibs="$old_convenience"
79116df26cacSmrg      fi
79126df26cacSmrg
7913b68e1f86Smrg      if test -n "$addlibs"; then
7914b68e1f86Smrg	gentop="$output_objdir/${outputname}x"
7915b68e1f86Smrg	generated="$generated $gentop"
79166df26cacSmrg
7917b68e1f86Smrg	func_extract_archives $gentop $addlibs
7918b68e1f86Smrg	oldobjs="$oldobjs $func_extract_archives_result"
7919b68e1f86Smrg      fi
79206df26cacSmrg
7921b68e1f86Smrg      # Do each command in the archive commands.
7922b68e1f86Smrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
7923b68e1f86Smrg	cmds=$old_archive_from_new_cmds
7924b68e1f86Smrg      else
79256df26cacSmrg
7926b68e1f86Smrg	# Add any objects from preloaded convenience libraries
7927b68e1f86Smrg	if test -n "$dlprefiles"; then
7928b68e1f86Smrg	  gentop="$output_objdir/${outputname}x"
7929b68e1f86Smrg	  generated="$generated $gentop"
79306df26cacSmrg
7931b68e1f86Smrg	  func_extract_archives $gentop $dlprefiles
7932b68e1f86Smrg	  oldobjs="$oldobjs $func_extract_archives_result"
7933b68e1f86Smrg	fi
79346df26cacSmrg
7935b68e1f86Smrg	# POSIX demands no paths to be encoded in archives.  We have
7936b68e1f86Smrg	# to avoid creating archives with duplicate basenames if we
7937b68e1f86Smrg	# might have to extract them afterwards, e.g., when creating a
7938b68e1f86Smrg	# static archive out of a convenience library, or when linking
7939b68e1f86Smrg	# the entirety of a libtool archive into another (currently
7940b68e1f86Smrg	# not supported by libtool).
7941b68e1f86Smrg	if (for obj in $oldobjs
7942b68e1f86Smrg	    do
7943b68e1f86Smrg	      func_basename "$obj"
7944b68e1f86Smrg	      $ECHO "$func_basename_result"
7945b68e1f86Smrg	    done | sort | sort -uc >/dev/null 2>&1); then
7946b68e1f86Smrg	  :
7947b68e1f86Smrg	else
7948b68e1f86Smrg	  $ECHO "copying selected object files to avoid basename conflicts..."
7949b68e1f86Smrg	  gentop="$output_objdir/${outputname}x"
7950b68e1f86Smrg	  generated="$generated $gentop"
7951b68e1f86Smrg	  func_mkdir_p "$gentop"
7952b68e1f86Smrg	  save_oldobjs=$oldobjs
7953b68e1f86Smrg	  oldobjs=
7954b68e1f86Smrg	  counter=1
7955b68e1f86Smrg	  for obj in $save_oldobjs
7956b68e1f86Smrg	  do
7957b68e1f86Smrg	    func_basename "$obj"
7958b68e1f86Smrg	    objbase="$func_basename_result"
7959b68e1f86Smrg	    case " $oldobjs " in
7960b68e1f86Smrg	    " ") oldobjs=$obj ;;
7961b68e1f86Smrg	    *[\ /]"$objbase "*)
7962b68e1f86Smrg	      while :; do
7963b68e1f86Smrg		# Make sure we don't pick an alternate name that also
7964b68e1f86Smrg		# overlaps.
7965b68e1f86Smrg		newobj=lt$counter-$objbase
7966b68e1f86Smrg		func_arith $counter + 1
7967b68e1f86Smrg		counter=$func_arith_result
7968b68e1f86Smrg		case " $oldobjs " in
7969b68e1f86Smrg		*[\ /]"$newobj "*) ;;
7970b68e1f86Smrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
7971b68e1f86Smrg		esac
7972b68e1f86Smrg	      done
7973b68e1f86Smrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
7974b68e1f86Smrg	      oldobjs="$oldobjs $gentop/$newobj"
7975b68e1f86Smrg	      ;;
7976b68e1f86Smrg	    *) oldobjs="$oldobjs $obj" ;;
7977b68e1f86Smrg	    esac
79786df26cacSmrg	  done
79796df26cacSmrg	fi
7980b68e1f86Smrg	eval cmds=\"$old_archive_cmds\"
79816df26cacSmrg
7982b68e1f86Smrg	func_len " $cmds"
7983b68e1f86Smrg	len=$func_len_result
7984b68e1f86Smrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
7985b68e1f86Smrg	  cmds=$old_archive_cmds
7986b68e1f86Smrg	else
7987b68e1f86Smrg	  # the command line is too long to link in one step, link in parts
7988b68e1f86Smrg	  func_verbose "using piecewise archive linking..."
7989b68e1f86Smrg	  save_RANLIB=$RANLIB
7990b68e1f86Smrg	  RANLIB=:
7991b68e1f86Smrg	  objlist=
7992b68e1f86Smrg	  concat_cmds=
7993b68e1f86Smrg	  save_oldobjs=$oldobjs
7994b68e1f86Smrg	  oldobjs=
7995b68e1f86Smrg	  # Is there a better way of finding the last object in the list?
7996b68e1f86Smrg	  for obj in $save_oldobjs
7997b68e1f86Smrg	  do
7998b68e1f86Smrg	    last_oldobj=$obj
7999b68e1f86Smrg	  done
8000b68e1f86Smrg	  eval test_cmds=\"$old_archive_cmds\"
8001b68e1f86Smrg	  func_len " $test_cmds"
8002b68e1f86Smrg	  len0=$func_len_result
8003b68e1f86Smrg	  len=$len0
8004b68e1f86Smrg	  for obj in $save_oldobjs
8005b68e1f86Smrg	  do
8006b68e1f86Smrg	    func_len " $obj"
8007b68e1f86Smrg	    func_arith $len + $func_len_result
8008b68e1f86Smrg	    len=$func_arith_result
8009b68e1f86Smrg	    func_append objlist " $obj"
8010b68e1f86Smrg	    if test "$len" -lt "$max_cmd_len"; then
8011b68e1f86Smrg	      :
8012b68e1f86Smrg	    else
8013b68e1f86Smrg	      # the above command should be used before it gets too long
8014b68e1f86Smrg	      oldobjs=$objlist
8015b68e1f86Smrg	      if test "$obj" = "$last_oldobj" ; then
8016b68e1f86Smrg		RANLIB=$save_RANLIB
8017b68e1f86Smrg	      fi
8018b68e1f86Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8019b68e1f86Smrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
8020b68e1f86Smrg	      objlist=
8021b68e1f86Smrg	      len=$len0
8022b68e1f86Smrg	    fi
8023b68e1f86Smrg	  done
8024b68e1f86Smrg	  RANLIB=$save_RANLIB
8025b68e1f86Smrg	  oldobjs=$objlist
8026b68e1f86Smrg	  if test "X$oldobjs" = "X" ; then
8027b68e1f86Smrg	    eval cmds=\"\$concat_cmds\"
8028b68e1f86Smrg	  else
8029b68e1f86Smrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
8030b68e1f86Smrg	  fi
8031b68e1f86Smrg	fi
8032b68e1f86Smrg      fi
8033b68e1f86Smrg      func_execute_cmds "$cmds" 'exit $?'
80346df26cacSmrg    done
80356df26cacSmrg
8036b68e1f86Smrg    test -n "$generated" && \
8037b68e1f86Smrg      func_show_eval "${RM}r$generated"
80386df26cacSmrg
8039b68e1f86Smrg    # Now create the libtool archive.
8040b68e1f86Smrg    case $output in
8041b68e1f86Smrg    *.la)
8042b68e1f86Smrg      old_library=
8043b68e1f86Smrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
8044b68e1f86Smrg      func_verbose "creating $output"
80456df26cacSmrg
8046b68e1f86Smrg      # Preserve any variables that may affect compiler behavior
8047b68e1f86Smrg      for var in $variables_saved_for_relink; do
8048b68e1f86Smrg	if eval test -z \"\${$var+set}\"; then
8049b68e1f86Smrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
8050b68e1f86Smrg	elif eval var_value=\$$var; test -z "$var_value"; then
8051b68e1f86Smrg	  relink_command="$var=; export $var; $relink_command"
80526df26cacSmrg	else
8053b68e1f86Smrg	  func_quote_for_eval "$var_value"
8054b68e1f86Smrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
80556df26cacSmrg	fi
8056b68e1f86Smrg      done
8057b68e1f86Smrg      # Quote the link command for shipping.
8058b68e1f86Smrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
8059b68e1f86Smrg      relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
8060b68e1f86Smrg      if test "$hardcode_automatic" = yes ; then
8061b68e1f86Smrg	relink_command=
8062b68e1f86Smrg      fi
80636df26cacSmrg
8064b68e1f86Smrg      # Only create the output if not a dry run.
8065b68e1f86Smrg      $opt_dry_run || {
8066b68e1f86Smrg	for installed in no yes; do
8067b68e1f86Smrg	  if test "$installed" = yes; then
8068b68e1f86Smrg	    if test -z "$install_libdir"; then
8069b68e1f86Smrg	      break
8070b68e1f86Smrg	    fi
8071b68e1f86Smrg	    output="$output_objdir/$outputname"i
8072b68e1f86Smrg	    # Replace all uninstalled libtool libraries with the installed ones
8073b68e1f86Smrg	    newdependency_libs=
8074b68e1f86Smrg	    for deplib in $dependency_libs; do
8075b68e1f86Smrg	      case $deplib in
8076b68e1f86Smrg	      *.la)
8077b68e1f86Smrg		func_basename "$deplib"
8078b68e1f86Smrg		name="$func_basename_result"
8079b68e1f86Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
8080b68e1f86Smrg		test -z "$libdir" && \
8081b68e1f86Smrg		  func_fatal_error "\`$deplib' is not a valid libtool archive"
8082b68e1f86Smrg		newdependency_libs="$newdependency_libs $libdir/$name"
8083b68e1f86Smrg		;;
8084b68e1f86Smrg	      *) newdependency_libs="$newdependency_libs $deplib" ;;
8085b68e1f86Smrg	      esac
8086b68e1f86Smrg	    done
8087b68e1f86Smrg	    dependency_libs="$newdependency_libs"
8088b68e1f86Smrg	    newdlfiles=
8089b68e1f86Smrg
8090b68e1f86Smrg	    for lib in $dlfiles; do
8091b68e1f86Smrg	      case $lib in
8092b68e1f86Smrg	      *.la)
8093b68e1f86Smrg	        func_basename "$lib"
8094b68e1f86Smrg		name="$func_basename_result"
8095b68e1f86Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
8096b68e1f86Smrg		test -z "$libdir" && \
8097b68e1f86Smrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
8098b68e1f86Smrg		newdlfiles="$newdlfiles $libdir/$name"
8099b68e1f86Smrg		;;
8100b68e1f86Smrg	      *) newdlfiles="$newdlfiles $lib" ;;
8101b68e1f86Smrg	      esac
8102b68e1f86Smrg	    done
8103b68e1f86Smrg	    dlfiles="$newdlfiles"
8104b68e1f86Smrg	    newdlprefiles=
8105b68e1f86Smrg	    for lib in $dlprefiles; do
8106b68e1f86Smrg	      case $lib in
8107b68e1f86Smrg	      *.la)
8108b68e1f86Smrg		# Only pass preopened files to the pseudo-archive (for
8109b68e1f86Smrg		# eventual linking with the app. that links it) if we
8110b68e1f86Smrg		# didn't already link the preopened objects directly into
8111b68e1f86Smrg		# the library:
8112b68e1f86Smrg		func_basename "$lib"
8113b68e1f86Smrg		name="$func_basename_result"
8114b68e1f86Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
8115b68e1f86Smrg		test -z "$libdir" && \
8116b68e1f86Smrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
8117b68e1f86Smrg		newdlprefiles="$newdlprefiles $libdir/$name"
8118b68e1f86Smrg		;;
8119b68e1f86Smrg	      esac
8120b68e1f86Smrg	    done
8121b68e1f86Smrg	    dlprefiles="$newdlprefiles"
8122b68e1f86Smrg	  else
8123b68e1f86Smrg	    newdlfiles=
8124b68e1f86Smrg	    for lib in $dlfiles; do
8125b68e1f86Smrg	      case $lib in
8126b68e1f86Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
8127b68e1f86Smrg		*) abs=`pwd`"/$lib" ;;
8128b68e1f86Smrg	      esac
8129b68e1f86Smrg	      newdlfiles="$newdlfiles $abs"
8130b68e1f86Smrg	    done
8131b68e1f86Smrg	    dlfiles="$newdlfiles"
8132b68e1f86Smrg	    newdlprefiles=
8133b68e1f86Smrg	    for lib in $dlprefiles; do
8134b68e1f86Smrg	      case $lib in
8135b68e1f86Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
8136b68e1f86Smrg		*) abs=`pwd`"/$lib" ;;
8137b68e1f86Smrg	      esac
8138b68e1f86Smrg	      newdlprefiles="$newdlprefiles $abs"
8139b68e1f86Smrg	    done
8140b68e1f86Smrg	    dlprefiles="$newdlprefiles"
8141b68e1f86Smrg	  fi
8142b68e1f86Smrg	  $RM $output
8143b68e1f86Smrg	  # place dlname in correct position for cygwin
8144b68e1f86Smrg	  tdlname=$dlname
8145b68e1f86Smrg	  case $host,$output,$installed,$module,$dlname in
8146b68e1f86Smrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
8147b68e1f86Smrg	  esac
8148b68e1f86Smrg	  $ECHO > $output "\
8149b68e1f86Smrg# $outputname - a libtool library file
8150b68e1f86Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
8151b68e1f86Smrg#
8152b68e1f86Smrg# Please DO NOT delete this file!
8153b68e1f86Smrg# It is necessary for linking the library.
81546df26cacSmrg
8155b68e1f86Smrg# The name that we can dlopen(3).
8156b68e1f86Smrgdlname='$tdlname'
81576df26cacSmrg
8158b68e1f86Smrg# Names of this library.
8159b68e1f86Smrglibrary_names='$library_names'
81606df26cacSmrg
8161b68e1f86Smrg# The name of the static archive.
8162b68e1f86Smrgold_library='$old_library'
81636df26cacSmrg
8164b68e1f86Smrg# Linker flags that can not go in dependency_libs.
8165b68e1f86Smrginherited_linker_flags='$new_inherited_linker_flags'
81666df26cacSmrg
8167b68e1f86Smrg# Libraries that this one depends upon.
8168b68e1f86Smrgdependency_libs='$dependency_libs'
81696df26cacSmrg
8170b68e1f86Smrg# Names of additional weak libraries provided by this library
8171b68e1f86Smrgweak_library_names='$weak_libs'
81726df26cacSmrg
8173b68e1f86Smrg# Version information for $libname.
8174b68e1f86Smrgcurrent=$current
8175b68e1f86Smrgage=$age
8176b68e1f86Smrgrevision=$revision
81776df26cacSmrg
8178b68e1f86Smrg# Is this an already installed library?
8179b68e1f86Smrginstalled=$installed
81806df26cacSmrg
8181b68e1f86Smrg# Should we warn about portability when linking against -modules?
8182b68e1f86Smrgshouldnotlink=$module
81836df26cacSmrg
8184b68e1f86Smrg# Files to dlopen/dlpreopen
8185b68e1f86Smrgdlopen='$dlfiles'
8186b68e1f86Smrgdlpreopen='$dlprefiles'
81876df26cacSmrg
8188b68e1f86Smrg# Directory that this library needs to be installed in:
8189b68e1f86Smrglibdir='$install_libdir'"
8190b68e1f86Smrg	  if test "$installed" = no && test "$need_relink" = yes; then
8191b68e1f86Smrg	    $ECHO >> $output "\
8192b68e1f86Smrgrelink_command=\"$relink_command\""
8193b68e1f86Smrg	  fi
8194b68e1f86Smrg	done
8195b68e1f86Smrg      }
81966df26cacSmrg
8197b68e1f86Smrg      # Do a symbolic link so that the libtool archive can be found in
8198b68e1f86Smrg      # LD_LIBRARY_PATH before the program is installed.
8199b68e1f86Smrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
8200b68e1f86Smrg      ;;
8201b68e1f86Smrg    esac
8202b68e1f86Smrg    exit $EXIT_SUCCESS
8203b68e1f86Smrg}
82046df26cacSmrg
8205b68e1f86Smrg{ test "$mode" = link || test "$mode" = relink; } &&
8206b68e1f86Smrg    func_mode_link ${1+"$@"}
82076df26cacSmrg
82086df26cacSmrg
8209b68e1f86Smrg# func_mode_uninstall arg...
8210b68e1f86Smrgfunc_mode_uninstall ()
8211b68e1f86Smrg{
8212b68e1f86Smrg    $opt_debug
8213b68e1f86Smrg    RM="$nonopt"
82146df26cacSmrg    files=
82156df26cacSmrg    rmforce=
82166df26cacSmrg    exit_status=0
82176df26cacSmrg
82186df26cacSmrg    # This variable tells wrapper scripts just to set variables rather
82196df26cacSmrg    # than running their programs.
82206df26cacSmrg    libtool_install_magic="$magic"
82216df26cacSmrg
82226df26cacSmrg    for arg
82236df26cacSmrg    do
82246df26cacSmrg      case $arg in
8225b68e1f86Smrg      -f) RM="$RM $arg"; rmforce=yes ;;
8226b68e1f86Smrg      -*) RM="$RM $arg" ;;
82276df26cacSmrg      *) files="$files $arg" ;;
82286df26cacSmrg      esac
82296df26cacSmrg    done
82306df26cacSmrg
8231b68e1f86Smrg    test -z "$RM" && \
8232b68e1f86Smrg      func_fatal_help "you must specify an RM program"
82336df26cacSmrg
82346df26cacSmrg    rmdirs=
82356df26cacSmrg
82366df26cacSmrg    origobjdir="$objdir"
82376df26cacSmrg    for file in $files; do
8238b68e1f86Smrg      func_dirname "$file" "" "."
8239b68e1f86Smrg      dir="$func_dirname_result"
8240b68e1f86Smrg      if test "X$dir" = X.; then
82416df26cacSmrg	objdir="$origobjdir"
82426df26cacSmrg      else
82436df26cacSmrg	objdir="$dir/$origobjdir"
82446df26cacSmrg      fi
8245b68e1f86Smrg      func_basename "$file"
8246b68e1f86Smrg      name="$func_basename_result"
82476df26cacSmrg      test "$mode" = uninstall && objdir="$dir"
82486df26cacSmrg
82496df26cacSmrg      # Remember objdir for removal later, being careful to avoid duplicates
82506df26cacSmrg      if test "$mode" = clean; then
82516df26cacSmrg	case " $rmdirs " in
82526df26cacSmrg	  *" $objdir "*) ;;
82536df26cacSmrg	  *) rmdirs="$rmdirs $objdir" ;;
82546df26cacSmrg	esac
82556df26cacSmrg      fi
82566df26cacSmrg
82576df26cacSmrg      # Don't error if the file doesn't exist and rm -f was used.
8258b68e1f86Smrg      if { test -L "$file"; } >/dev/null 2>&1 ||
8259b68e1f86Smrg	 { test -h "$file"; } >/dev/null 2>&1 ||
8260b68e1f86Smrg	 test -f "$file"; then
82616df26cacSmrg	:
82626df26cacSmrg      elif test -d "$file"; then
82636df26cacSmrg	exit_status=1
82646df26cacSmrg	continue
82656df26cacSmrg      elif test "$rmforce" = yes; then
82666df26cacSmrg	continue
82676df26cacSmrg      fi
82686df26cacSmrg
82696df26cacSmrg      rmfiles="$file"
82706df26cacSmrg
82716df26cacSmrg      case $name in
82726df26cacSmrg      *.la)
82736df26cacSmrg	# Possibly a libtool archive, so verify it.
8274b68e1f86Smrg	if func_lalib_p "$file"; then
8275b68e1f86Smrg	  func_source $dir/$name
82766df26cacSmrg
82776df26cacSmrg	  # Delete the libtool libraries and symlinks.
82786df26cacSmrg	  for n in $library_names; do
82796df26cacSmrg	    rmfiles="$rmfiles $objdir/$n"
82806df26cacSmrg	  done
82816df26cacSmrg	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
82826df26cacSmrg
82836df26cacSmrg	  case "$mode" in
82846df26cacSmrg	  clean)
82856df26cacSmrg	    case "  $library_names " in
82866df26cacSmrg	    # "  " in the beginning catches empty $dlname
82876df26cacSmrg	    *" $dlname "*) ;;
82886df26cacSmrg	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
82896df26cacSmrg	    esac
8290b68e1f86Smrg	    test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
82916df26cacSmrg	    ;;
82926df26cacSmrg	  uninstall)
82936df26cacSmrg	    if test -n "$library_names"; then
82946df26cacSmrg	      # Do each command in the postuninstall commands.
8295b68e1f86Smrg	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
82966df26cacSmrg	    fi
82976df26cacSmrg
82986df26cacSmrg	    if test -n "$old_library"; then
82996df26cacSmrg	      # Do each command in the old_postuninstall commands.
8300b68e1f86Smrg	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
83016df26cacSmrg	    fi
83026df26cacSmrg	    # FIXME: should reinstall the best remaining shared library.
83036df26cacSmrg	    ;;
83046df26cacSmrg	  esac
83056df26cacSmrg	fi
83066df26cacSmrg	;;
83076df26cacSmrg
83086df26cacSmrg      *.lo)
83096df26cacSmrg	# Possibly a libtool object, so verify it.
8310b68e1f86Smrg	if func_lalib_p "$file"; then
83116df26cacSmrg
83126df26cacSmrg	  # Read the .lo file
8313b68e1f86Smrg	  func_source $dir/$name
83146df26cacSmrg
83156df26cacSmrg	  # Add PIC object to the list of files to remove.
8316b68e1f86Smrg	  if test -n "$pic_object" &&
8317b68e1f86Smrg	     test "$pic_object" != none; then
83186df26cacSmrg	    rmfiles="$rmfiles $dir/$pic_object"
83196df26cacSmrg	  fi
83206df26cacSmrg
83216df26cacSmrg	  # Add non-PIC object to the list of files to remove.
8322b68e1f86Smrg	  if test -n "$non_pic_object" &&
8323b68e1f86Smrg	     test "$non_pic_object" != none; then
83246df26cacSmrg	    rmfiles="$rmfiles $dir/$non_pic_object"
83256df26cacSmrg	  fi
83266df26cacSmrg	fi
83276df26cacSmrg	;;
83286df26cacSmrg
83296df26cacSmrg      *)
83306df26cacSmrg	if test "$mode" = clean ; then
83316df26cacSmrg	  noexename=$name
83326df26cacSmrg	  case $file in
83336df26cacSmrg	  *.exe)
8334b68e1f86Smrg	    func_stripname '' '.exe' "$file"
8335b68e1f86Smrg	    file=$func_stripname_result
8336b68e1f86Smrg	    func_stripname '' '.exe' "$name"
8337b68e1f86Smrg	    noexename=$func_stripname_result
83386df26cacSmrg	    # $file with .exe has already been added to rmfiles,
83396df26cacSmrg	    # add $file without .exe
83406df26cacSmrg	    rmfiles="$rmfiles $file"
83416df26cacSmrg	    ;;
83426df26cacSmrg	  esac
83436df26cacSmrg	  # Do a test to see if this is a libtool program.
8344b68e1f86Smrg	  if func_ltwrapper_p "$file"; then
8345b68e1f86Smrg	    if func_ltwrapper_executable_p "$file"; then
8346b68e1f86Smrg	      func_ltwrapper_scriptname "$file"
8347b68e1f86Smrg	      relink_command=
8348b68e1f86Smrg	      func_source $func_ltwrapper_scriptname_result
8349b68e1f86Smrg	      rmfiles="$rmfiles $func_ltwrapper_scriptname_result"
8350b68e1f86Smrg	    else
8351b68e1f86Smrg	      relink_command=
8352b68e1f86Smrg	      func_source $dir/$noexename
8353b68e1f86Smrg	    fi
83546df26cacSmrg
83556df26cacSmrg	    # note $name still contains .exe if it was in $file originally
83566df26cacSmrg	    # as does the version of $file that was added into $rmfiles
83576df26cacSmrg	    rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
83586df26cacSmrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
83596df26cacSmrg	      rmfiles="$rmfiles $objdir/lt-$name"
83606df26cacSmrg	    fi
83616df26cacSmrg	    if test "X$noexename" != "X$name" ; then
83626df26cacSmrg	      rmfiles="$rmfiles $objdir/lt-${noexename}.c"
83636df26cacSmrg	    fi
83646df26cacSmrg	  fi
83656df26cacSmrg	fi
83666df26cacSmrg	;;
83676df26cacSmrg      esac
8368b68e1f86Smrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
83696df26cacSmrg    done
83706df26cacSmrg    objdir="$origobjdir"
83716df26cacSmrg
83726df26cacSmrg    # Try to remove the ${objdir}s in the directories where we deleted files
83736df26cacSmrg    for dir in $rmdirs; do
83746df26cacSmrg      if test -d "$dir"; then
8375b68e1f86Smrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
83766df26cacSmrg      fi
83776df26cacSmrg    done
83786df26cacSmrg
83796df26cacSmrg    exit $exit_status
8380b68e1f86Smrg}
83816df26cacSmrg
8382b68e1f86Smrg{ test "$mode" = uninstall || test "$mode" = clean; } &&
8383b68e1f86Smrg    func_mode_uninstall ${1+"$@"}
83846df26cacSmrg
8385b68e1f86Smrgtest -z "$mode" && {
8386b68e1f86Smrg  help="$generic_help"
8387b68e1f86Smrg  func_fatal_help "you must specify a MODE"
8388b68e1f86Smrg}
8389b68e1f86Smrg
8390b68e1f86Smrgtest -z "$exec_cmd" && \
8391b68e1f86Smrg  func_fatal_help "invalid operation mode \`$mode'"
83926df26cacSmrg
83936df26cacSmrgif test -n "$exec_cmd"; then
8394b68e1f86Smrg  eval exec "$exec_cmd"
83956df26cacSmrg  exit $EXIT_FAILURE
83966df26cacSmrgfi
83976df26cacSmrg
8398b68e1f86Smrgexit $exit_status
83996df26cacSmrg
84006df26cacSmrg
84016df26cacSmrg# The TAGs below are defined such that we never get into a situation
84026df26cacSmrg# in which we disable both kinds of libraries.  Given conflicting
84036df26cacSmrg# choices, we go for a static library, that is the most portable,
84046df26cacSmrg# since we can't tell whether shared libraries were disabled because
84056df26cacSmrg# the user asked for that or because the platform doesn't support
84066df26cacSmrg# them.  This is particularly important on AIX, because we don't
84076df26cacSmrg# support having both static and shared libraries enabled at the same
84086df26cacSmrg# time on that platform, so we default to a shared-only configuration.
84096df26cacSmrg# If a disable-shared tag is given, we'll fallback to a static-only
84106df26cacSmrg# configuration.  But we'll never go from static-only to shared-only.
84116df26cacSmrg
84126df26cacSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
8413b68e1f86Smrgbuild_libtool_libs=no
8414b68e1f86Smrgbuild_old_libs=yes
84156df26cacSmrg# ### END LIBTOOL TAG CONFIG: disable-shared
84166df26cacSmrg
84176df26cacSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
8418b68e1f86Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
84196df26cacSmrg# ### END LIBTOOL TAG CONFIG: disable-static
84206df26cacSmrg
84216df26cacSmrg# Local Variables:
84226df26cacSmrg# mode:shell-script
84236df26cacSmrg# sh-indentation:2
84246df26cacSmrg# End:
8425b68e1f86Smrg# vi:sw=2
8426b68e1f86Smrg
8427