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