xref: /aosp_15_r20/external/libnfnetlink/build-aux/ltmain.sh (revision a376eb3279f225b393114c4820c780cbda860a6c)
1*a376eb32SXin Li
2*a376eb32SXin Li# libtool (GNU libtool) 2.4.2
3*a376eb32SXin Li# Written by Gordon Matzigkeit <[email protected]>, 1996
4*a376eb32SXin Li
5*a376eb32SXin Li# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
6*a376eb32SXin Li# 2007, 2008, 2009, 2010, 2011 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#       --no-quiet, --no-silent
43*a376eb32SXin Li#                            print informational messages (default)
44*a376eb32SXin Li#       --no-warn            don't display warning messages
45*a376eb32SXin Li#       --tag=TAG            use configuration variables from tag TAG
46*a376eb32SXin Li#   -v, --verbose            print more informational messages than default
47*a376eb32SXin Li#       --no-verbose         don't print the extra informational messages
48*a376eb32SXin Li#       --version            print version information
49*a376eb32SXin Li#   -h, --help, --help-all   print short, long, or detailed help message
50*a376eb32SXin Li#
51*a376eb32SXin Li# MODE must be one of the following:
52*a376eb32SXin Li#
53*a376eb32SXin Li#         clean              remove files from the build directory
54*a376eb32SXin Li#         compile            compile a source file into a libtool object
55*a376eb32SXin Li#         execute            automatically set library path, then run a program
56*a376eb32SXin Li#         finish             complete the installation of libtool libraries
57*a376eb32SXin Li#         install            install libraries or executables
58*a376eb32SXin Li#         link               create a library or an executable
59*a376eb32SXin Li#         uninstall          remove libraries from an installed directory
60*a376eb32SXin Li#
61*a376eb32SXin Li# MODE-ARGS vary depending on the MODE.  When passed as first option,
62*a376eb32SXin Li# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
63*a376eb32SXin Li# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
64*a376eb32SXin Li#
65*a376eb32SXin Li# When reporting a bug, please describe a test case to reproduce it and
66*a376eb32SXin Li# include the following information:
67*a376eb32SXin Li#
68*a376eb32SXin Li#         host-triplet:	$host
69*a376eb32SXin Li#         shell:		$SHELL
70*a376eb32SXin Li#         compiler:		$LTCC
71*a376eb32SXin Li#         compiler flags:		$LTCFLAGS
72*a376eb32SXin Li#         linker:		$LD (gnu? $with_gnu_ld)
73*a376eb32SXin Li#         $progname:	(GNU libtool) 2.4.2 Debian-2.4.2-1.1
74*a376eb32SXin Li#         automake:	$automake_version
75*a376eb32SXin Li#         autoconf:	$autoconf_version
76*a376eb32SXin Li#
77*a376eb32SXin Li# Report bugs to <[email protected]>.
78*a376eb32SXin Li# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
79*a376eb32SXin Li# General help using GNU software: <http://www.gnu.org/gethelp/>.
80*a376eb32SXin Li
81*a376eb32SXin LiPROGRAM=libtool
82*a376eb32SXin LiPACKAGE=libtool
83*a376eb32SXin LiVERSION="2.4.2 Debian-2.4.2-1.1"
84*a376eb32SXin LiTIMESTAMP=""
85*a376eb32SXin Lipackage_revision=1.3337
86*a376eb32SXin Li
87*a376eb32SXin Li# Be Bourne compatible
88*a376eb32SXin Liif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
89*a376eb32SXin Li  emulate sh
90*a376eb32SXin Li  NULLCMD=:
91*a376eb32SXin Li  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
92*a376eb32SXin Li  # is contrary to our usage.  Disable this feature.
93*a376eb32SXin Li  alias -g '${1+"$@"}'='"$@"'
94*a376eb32SXin Li  setopt NO_GLOB_SUBST
95*a376eb32SXin Lielse
96*a376eb32SXin Li  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
97*a376eb32SXin Lifi
98*a376eb32SXin LiBIN_SH=xpg4; export BIN_SH # for Tru64
99*a376eb32SXin LiDUALCASE=1; export DUALCASE # for MKS sh
100*a376eb32SXin Li
101*a376eb32SXin Li# A function that is used when there is no print builtin or printf.
102*a376eb32SXin Lifunc_fallback_echo ()
103*a376eb32SXin Li{
104*a376eb32SXin Li  eval 'cat <<_LTECHO_EOF
105*a376eb32SXin Li$1
106*a376eb32SXin Li_LTECHO_EOF'
107*a376eb32SXin Li}
108*a376eb32SXin Li
109*a376eb32SXin Li# NLS nuisances: We save the old values to restore during execute mode.
110*a376eb32SXin Lilt_user_locale=
111*a376eb32SXin Lilt_safe_locale=
112*a376eb32SXin Lifor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
113*a376eb32SXin Lido
114*a376eb32SXin Li  eval "if test \"\${$lt_var+set}\" = set; then
115*a376eb32SXin Li          save_$lt_var=\$$lt_var
116*a376eb32SXin Li          $lt_var=C
117*a376eb32SXin Li	  export $lt_var
118*a376eb32SXin Li	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
119*a376eb32SXin Li	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
120*a376eb32SXin Li	fi"
121*a376eb32SXin Lidone
122*a376eb32SXin LiLC_ALL=C
123*a376eb32SXin LiLANGUAGE=C
124*a376eb32SXin Liexport LANGUAGE LC_ALL
125*a376eb32SXin Li
126*a376eb32SXin Li$lt_unset CDPATH
127*a376eb32SXin Li
128*a376eb32SXin Li
129*a376eb32SXin Li# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
130*a376eb32SXin Li# is ksh but when the shell is invoked as "sh" and the current value of
131*a376eb32SXin Li# the _XPG environment variable is not equal to 1 (one), the special
132*a376eb32SXin Li# positional parameter $0, within a function call, is the name of the
133*a376eb32SXin Li# function.
134*a376eb32SXin Liprogpath="$0"
135*a376eb32SXin Li
136*a376eb32SXin Li
137*a376eb32SXin Li
138*a376eb32SXin Li: ${CP="cp -f"}
139*a376eb32SXin Litest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
140*a376eb32SXin Li: ${MAKE="make"}
141*a376eb32SXin Li: ${MKDIR="mkdir"}
142*a376eb32SXin Li: ${MV="mv -f"}
143*a376eb32SXin Li: ${RM="rm -f"}
144*a376eb32SXin Li: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
145*a376eb32SXin Li: ${Xsed="$SED -e 1s/^X//"}
146*a376eb32SXin Li
147*a376eb32SXin Li# Global variables:
148*a376eb32SXin LiEXIT_SUCCESS=0
149*a376eb32SXin LiEXIT_FAILURE=1
150*a376eb32SXin LiEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
151*a376eb32SXin LiEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
152*a376eb32SXin Li
153*a376eb32SXin Liexit_status=$EXIT_SUCCESS
154*a376eb32SXin Li
155*a376eb32SXin Li# Make sure IFS has a sensible default
156*a376eb32SXin Lilt_nl='
157*a376eb32SXin Li'
158*a376eb32SXin LiIFS=" 	$lt_nl"
159*a376eb32SXin Li
160*a376eb32SXin Lidirname="s,/[^/]*$,,"
161*a376eb32SXin Libasename="s,^.*/,,"
162*a376eb32SXin Li
163*a376eb32SXin Li# func_dirname file append nondir_replacement
164*a376eb32SXin Li# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
165*a376eb32SXin Li# otherwise set result to NONDIR_REPLACEMENT.
166*a376eb32SXin Lifunc_dirname ()
167*a376eb32SXin Li{
168*a376eb32SXin Li    func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
169*a376eb32SXin Li    if test "X$func_dirname_result" = "X${1}"; then
170*a376eb32SXin Li      func_dirname_result="${3}"
171*a376eb32SXin Li    else
172*a376eb32SXin Li      func_dirname_result="$func_dirname_result${2}"
173*a376eb32SXin Li    fi
174*a376eb32SXin Li} # func_dirname may be replaced by extended shell implementation
175*a376eb32SXin Li
176*a376eb32SXin Li
177*a376eb32SXin Li# func_basename file
178*a376eb32SXin Lifunc_basename ()
179*a376eb32SXin Li{
180*a376eb32SXin Li    func_basename_result=`$ECHO "${1}" | $SED "$basename"`
181*a376eb32SXin Li} # func_basename may be replaced by extended shell implementation
182*a376eb32SXin Li
183*a376eb32SXin Li
184*a376eb32SXin Li# func_dirname_and_basename file append nondir_replacement
185*a376eb32SXin Li# perform func_basename and func_dirname in a single function
186*a376eb32SXin Li# call:
187*a376eb32SXin Li#   dirname:  Compute the dirname of FILE.  If nonempty,
188*a376eb32SXin Li#             add APPEND to the result, otherwise set result
189*a376eb32SXin Li#             to NONDIR_REPLACEMENT.
190*a376eb32SXin Li#             value returned in "$func_dirname_result"
191*a376eb32SXin Li#   basename: Compute filename of FILE.
192*a376eb32SXin Li#             value retuned in "$func_basename_result"
193*a376eb32SXin Li# Implementation must be kept synchronized with func_dirname
194*a376eb32SXin Li# and func_basename. For efficiency, we do not delegate to
195*a376eb32SXin Li# those functions but instead duplicate the functionality here.
196*a376eb32SXin Lifunc_dirname_and_basename ()
197*a376eb32SXin Li{
198*a376eb32SXin Li    # Extract subdirectory from the argument.
199*a376eb32SXin Li    func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
200*a376eb32SXin Li    if test "X$func_dirname_result" = "X${1}"; then
201*a376eb32SXin Li      func_dirname_result="${3}"
202*a376eb32SXin Li    else
203*a376eb32SXin Li      func_dirname_result="$func_dirname_result${2}"
204*a376eb32SXin Li    fi
205*a376eb32SXin Li    func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
206*a376eb32SXin Li} # func_dirname_and_basename may be replaced by extended shell implementation
207*a376eb32SXin Li
208*a376eb32SXin Li
209*a376eb32SXin Li# func_stripname prefix suffix name
210*a376eb32SXin Li# strip PREFIX and SUFFIX off of NAME.
211*a376eb32SXin Li# PREFIX and SUFFIX must not contain globbing or regex special
212*a376eb32SXin Li# characters, hashes, percent signs, but SUFFIX may contain a leading
213*a376eb32SXin Li# dot (in which case that matches only a dot).
214*a376eb32SXin Li# func_strip_suffix prefix name
215*a376eb32SXin Lifunc_stripname ()
216*a376eb32SXin Li{
217*a376eb32SXin Li    case ${2} in
218*a376eb32SXin Li      .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
219*a376eb32SXin Li      *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
220*a376eb32SXin Li    esac
221*a376eb32SXin Li} # func_stripname may be replaced by extended shell implementation
222*a376eb32SXin Li
223*a376eb32SXin Li
224*a376eb32SXin Li# These SED scripts presuppose an absolute path with a trailing slash.
225*a376eb32SXin Lipathcar='s,^/\([^/]*\).*$,\1,'
226*a376eb32SXin Lipathcdr='s,^/[^/]*,,'
227*a376eb32SXin Liremovedotparts=':dotsl
228*a376eb32SXin Li		s@/\./@/@g
229*a376eb32SXin Li		t dotsl
230*a376eb32SXin Li		s,/\.$,/,'
231*a376eb32SXin Licollapseslashes='s@/\{1,\}@/@g'
232*a376eb32SXin Lifinalslash='s,/*$,/,'
233*a376eb32SXin Li
234*a376eb32SXin Li# func_normal_abspath PATH
235*a376eb32SXin Li# Remove doubled-up and trailing slashes, "." path components,
236*a376eb32SXin Li# and cancel out any ".." path components in PATH after making
237*a376eb32SXin Li# it an absolute path.
238*a376eb32SXin Li#             value returned in "$func_normal_abspath_result"
239*a376eb32SXin Lifunc_normal_abspath ()
240*a376eb32SXin Li{
241*a376eb32SXin Li  # Start from root dir and reassemble the path.
242*a376eb32SXin Li  func_normal_abspath_result=
243*a376eb32SXin Li  func_normal_abspath_tpath=$1
244*a376eb32SXin Li  func_normal_abspath_altnamespace=
245*a376eb32SXin Li  case $func_normal_abspath_tpath in
246*a376eb32SXin Li    "")
247*a376eb32SXin Li      # Empty path, that just means $cwd.
248*a376eb32SXin Li      func_stripname '' '/' "`pwd`"
249*a376eb32SXin Li      func_normal_abspath_result=$func_stripname_result
250*a376eb32SXin Li      return
251*a376eb32SXin Li    ;;
252*a376eb32SXin Li    # The next three entries are used to spot a run of precisely
253*a376eb32SXin Li    # two leading slashes without using negated character classes;
254*a376eb32SXin Li    # we take advantage of case's first-match behaviour.
255*a376eb32SXin Li    ///*)
256*a376eb32SXin Li      # Unusual form of absolute path, do nothing.
257*a376eb32SXin Li    ;;
258*a376eb32SXin Li    //*)
259*a376eb32SXin Li      # Not necessarily an ordinary path; POSIX reserves leading '//'
260*a376eb32SXin Li      # and for example Cygwin uses it to access remote file shares
261*a376eb32SXin Li      # over CIFS/SMB, so we conserve a leading double slash if found.
262*a376eb32SXin Li      func_normal_abspath_altnamespace=/
263*a376eb32SXin Li    ;;
264*a376eb32SXin Li    /*)
265*a376eb32SXin Li      # Absolute path, do nothing.
266*a376eb32SXin Li    ;;
267*a376eb32SXin Li    *)
268*a376eb32SXin Li      # Relative path, prepend $cwd.
269*a376eb32SXin Li      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
270*a376eb32SXin Li    ;;
271*a376eb32SXin Li  esac
272*a376eb32SXin Li  # Cancel out all the simple stuff to save iterations.  We also want
273*a376eb32SXin Li  # the path to end with a slash for ease of parsing, so make sure
274*a376eb32SXin Li  # there is one (and only one) here.
275*a376eb32SXin Li  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
276*a376eb32SXin Li        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
277*a376eb32SXin Li  while :; do
278*a376eb32SXin Li    # Processed it all yet?
279*a376eb32SXin Li    if test "$func_normal_abspath_tpath" = / ; then
280*a376eb32SXin Li      # If we ascended to the root using ".." the result may be empty now.
281*a376eb32SXin Li      if test -z "$func_normal_abspath_result" ; then
282*a376eb32SXin Li        func_normal_abspath_result=/
283*a376eb32SXin Li      fi
284*a376eb32SXin Li      break
285*a376eb32SXin Li    fi
286*a376eb32SXin Li    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
287*a376eb32SXin Li        -e "$pathcar"`
288*a376eb32SXin Li    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
289*a376eb32SXin Li        -e "$pathcdr"`
290*a376eb32SXin Li    # Figure out what to do with it
291*a376eb32SXin Li    case $func_normal_abspath_tcomponent in
292*a376eb32SXin Li      "")
293*a376eb32SXin Li        # Trailing empty path component, ignore it.
294*a376eb32SXin Li      ;;
295*a376eb32SXin Li      ..)
296*a376eb32SXin Li        # Parent dir; strip last assembled component from result.
297*a376eb32SXin Li        func_dirname "$func_normal_abspath_result"
298*a376eb32SXin Li        func_normal_abspath_result=$func_dirname_result
299*a376eb32SXin Li      ;;
300*a376eb32SXin Li      *)
301*a376eb32SXin Li        # Actual path component, append it.
302*a376eb32SXin Li        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
303*a376eb32SXin Li      ;;
304*a376eb32SXin Li    esac
305*a376eb32SXin Li  done
306*a376eb32SXin Li  # Restore leading double-slash if one was found on entry.
307*a376eb32SXin Li  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
308*a376eb32SXin Li}
309*a376eb32SXin Li
310*a376eb32SXin Li# func_relative_path SRCDIR DSTDIR
311*a376eb32SXin Li# generates a relative path from SRCDIR to DSTDIR, with a trailing
312*a376eb32SXin Li# slash if non-empty, suitable for immediately appending a filename
313*a376eb32SXin Li# without needing to append a separator.
314*a376eb32SXin Li#             value returned in "$func_relative_path_result"
315*a376eb32SXin Lifunc_relative_path ()
316*a376eb32SXin Li{
317*a376eb32SXin Li  func_relative_path_result=
318*a376eb32SXin Li  func_normal_abspath "$1"
319*a376eb32SXin Li  func_relative_path_tlibdir=$func_normal_abspath_result
320*a376eb32SXin Li  func_normal_abspath "$2"
321*a376eb32SXin Li  func_relative_path_tbindir=$func_normal_abspath_result
322*a376eb32SXin Li
323*a376eb32SXin Li  # Ascend the tree starting from libdir
324*a376eb32SXin Li  while :; do
325*a376eb32SXin Li    # check if we have found a prefix of bindir
326*a376eb32SXin Li    case $func_relative_path_tbindir in
327*a376eb32SXin Li      $func_relative_path_tlibdir)
328*a376eb32SXin Li        # found an exact match
329*a376eb32SXin Li        func_relative_path_tcancelled=
330*a376eb32SXin Li        break
331*a376eb32SXin Li        ;;
332*a376eb32SXin Li      $func_relative_path_tlibdir*)
333*a376eb32SXin Li        # found a matching prefix
334*a376eb32SXin Li        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
335*a376eb32SXin Li        func_relative_path_tcancelled=$func_stripname_result
336*a376eb32SXin Li        if test -z "$func_relative_path_result"; then
337*a376eb32SXin Li          func_relative_path_result=.
338*a376eb32SXin Li        fi
339*a376eb32SXin Li        break
340*a376eb32SXin Li        ;;
341*a376eb32SXin Li      *)
342*a376eb32SXin Li        func_dirname $func_relative_path_tlibdir
343*a376eb32SXin Li        func_relative_path_tlibdir=${func_dirname_result}
344*a376eb32SXin Li        if test "x$func_relative_path_tlibdir" = x ; then
345*a376eb32SXin Li          # Have to descend all the way to the root!
346*a376eb32SXin Li          func_relative_path_result=../$func_relative_path_result
347*a376eb32SXin Li          func_relative_path_tcancelled=$func_relative_path_tbindir
348*a376eb32SXin Li          break
349*a376eb32SXin Li        fi
350*a376eb32SXin Li        func_relative_path_result=../$func_relative_path_result
351*a376eb32SXin Li        ;;
352*a376eb32SXin Li    esac
353*a376eb32SXin Li  done
354*a376eb32SXin Li
355*a376eb32SXin Li  # Now calculate path; take care to avoid doubling-up slashes.
356*a376eb32SXin Li  func_stripname '' '/' "$func_relative_path_result"
357*a376eb32SXin Li  func_relative_path_result=$func_stripname_result
358*a376eb32SXin Li  func_stripname '/' '/' "$func_relative_path_tcancelled"
359*a376eb32SXin Li  if test "x$func_stripname_result" != x ; then
360*a376eb32SXin Li    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
361*a376eb32SXin Li  fi
362*a376eb32SXin Li
363*a376eb32SXin Li  # Normalisation. If bindir is libdir, return empty string,
364*a376eb32SXin Li  # else relative path ending with a slash; either way, target
365*a376eb32SXin Li  # file name can be directly appended.
366*a376eb32SXin Li  if test ! -z "$func_relative_path_result"; then
367*a376eb32SXin Li    func_stripname './' '' "$func_relative_path_result/"
368*a376eb32SXin Li    func_relative_path_result=$func_stripname_result
369*a376eb32SXin Li  fi
370*a376eb32SXin Li}
371*a376eb32SXin Li
372*a376eb32SXin Li# The name of this program:
373*a376eb32SXin Lifunc_dirname_and_basename "$progpath"
374*a376eb32SXin Liprogname=$func_basename_result
375*a376eb32SXin Li
376*a376eb32SXin Li# Make sure we have an absolute path for reexecution:
377*a376eb32SXin Licase $progpath in
378*a376eb32SXin Li  [\\/]*|[A-Za-z]:\\*) ;;
379*a376eb32SXin Li  *[\\/]*)
380*a376eb32SXin Li     progdir=$func_dirname_result
381*a376eb32SXin Li     progdir=`cd "$progdir" && pwd`
382*a376eb32SXin Li     progpath="$progdir/$progname"
383*a376eb32SXin Li     ;;
384*a376eb32SXin Li  *)
385*a376eb32SXin Li     save_IFS="$IFS"
386*a376eb32SXin Li     IFS=${PATH_SEPARATOR-:}
387*a376eb32SXin Li     for progdir in $PATH; do
388*a376eb32SXin Li       IFS="$save_IFS"
389*a376eb32SXin Li       test -x "$progdir/$progname" && break
390*a376eb32SXin Li     done
391*a376eb32SXin Li     IFS="$save_IFS"
392*a376eb32SXin Li     test -n "$progdir" || progdir=`pwd`
393*a376eb32SXin Li     progpath="$progdir/$progname"
394*a376eb32SXin Li     ;;
395*a376eb32SXin Liesac
396*a376eb32SXin Li
397*a376eb32SXin Li# Sed substitution that helps us do robust quoting.  It backslashifies
398*a376eb32SXin Li# metacharacters that are still active within double-quoted strings.
399*a376eb32SXin LiXsed="${SED}"' -e 1s/^X//'
400*a376eb32SXin Lised_quote_subst='s/\([`"$\\]\)/\\\1/g'
401*a376eb32SXin Li
402*a376eb32SXin Li# Same as above, but do not quote variable references.
403*a376eb32SXin Lidouble_quote_subst='s/\(["`\\]\)/\\\1/g'
404*a376eb32SXin Li
405*a376eb32SXin Li# Sed substitution that turns a string into a regex matching for the
406*a376eb32SXin Li# string literally.
407*a376eb32SXin Lised_make_literal_regex='s,[].[^$\\*\/],\\&,g'
408*a376eb32SXin Li
409*a376eb32SXin Li# Sed substitution that converts a w32 file name or path
410*a376eb32SXin Li# which contains forward slashes, into one that contains
411*a376eb32SXin Li# (escaped) backslashes.  A very naive implementation.
412*a376eb32SXin Lilt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
413*a376eb32SXin Li
414*a376eb32SXin Li# Re-`\' parameter expansions in output of double_quote_subst that were
415*a376eb32SXin Li# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
416*a376eb32SXin Li# in input to double_quote_subst, that '$' was protected from expansion.
417*a376eb32SXin Li# Since each input `\' is now two `\'s, look for any number of runs of
418*a376eb32SXin Li# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
419*a376eb32SXin Libs='\\'
420*a376eb32SXin Libs2='\\\\'
421*a376eb32SXin Libs4='\\\\\\\\'
422*a376eb32SXin Lidollar='\$'
423*a376eb32SXin Lised_double_backslash="\
424*a376eb32SXin Li  s/$bs4/&\\
425*a376eb32SXin Li/g
426*a376eb32SXin Li  s/^$bs2$dollar/$bs&/
427*a376eb32SXin Li  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
428*a376eb32SXin Li  s/\n//g"
429*a376eb32SXin Li
430*a376eb32SXin Li# Standard options:
431*a376eb32SXin Liopt_dry_run=false
432*a376eb32SXin Liopt_help=false
433*a376eb32SXin Liopt_quiet=false
434*a376eb32SXin Liopt_verbose=false
435*a376eb32SXin Liopt_warning=:
436*a376eb32SXin Li
437*a376eb32SXin Li# func_echo arg...
438*a376eb32SXin Li# Echo program name prefixed message, along with the current mode
439*a376eb32SXin Li# name if it has been set yet.
440*a376eb32SXin Lifunc_echo ()
441*a376eb32SXin Li{
442*a376eb32SXin Li    $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
443*a376eb32SXin Li}
444*a376eb32SXin Li
445*a376eb32SXin Li# func_verbose arg...
446*a376eb32SXin Li# Echo program name prefixed message in verbose mode only.
447*a376eb32SXin Lifunc_verbose ()
448*a376eb32SXin Li{
449*a376eb32SXin Li    $opt_verbose && func_echo ${1+"$@"}
450*a376eb32SXin Li
451*a376eb32SXin Li    # A bug in bash halts the script if the last line of a function
452*a376eb32SXin Li    # fails when set -e is in force, so we need another command to
453*a376eb32SXin Li    # work around that:
454*a376eb32SXin Li    :
455*a376eb32SXin Li}
456*a376eb32SXin Li
457*a376eb32SXin Li# func_echo_all arg...
458*a376eb32SXin Li# Invoke $ECHO with all args, space-separated.
459*a376eb32SXin Lifunc_echo_all ()
460*a376eb32SXin Li{
461*a376eb32SXin Li    $ECHO "$*"
462*a376eb32SXin Li}
463*a376eb32SXin Li
464*a376eb32SXin Li# func_error arg...
465*a376eb32SXin Li# Echo program name prefixed message to standard error.
466*a376eb32SXin Lifunc_error ()
467*a376eb32SXin Li{
468*a376eb32SXin Li    $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
469*a376eb32SXin Li}
470*a376eb32SXin Li
471*a376eb32SXin Li# func_warning arg...
472*a376eb32SXin Li# Echo program name prefixed warning message to standard error.
473*a376eb32SXin Lifunc_warning ()
474*a376eb32SXin Li{
475*a376eb32SXin Li    $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
476*a376eb32SXin Li
477*a376eb32SXin Li    # bash bug again:
478*a376eb32SXin Li    :
479*a376eb32SXin Li}
480*a376eb32SXin Li
481*a376eb32SXin Li# func_fatal_error arg...
482*a376eb32SXin Li# Echo program name prefixed message to standard error, and exit.
483*a376eb32SXin Lifunc_fatal_error ()
484*a376eb32SXin Li{
485*a376eb32SXin Li    func_error ${1+"$@"}
486*a376eb32SXin Li    exit $EXIT_FAILURE
487*a376eb32SXin Li}
488*a376eb32SXin Li
489*a376eb32SXin Li# func_fatal_help arg...
490*a376eb32SXin Li# Echo program name prefixed message to standard error, followed by
491*a376eb32SXin Li# a help hint, and exit.
492*a376eb32SXin Lifunc_fatal_help ()
493*a376eb32SXin Li{
494*a376eb32SXin Li    func_error ${1+"$@"}
495*a376eb32SXin Li    func_fatal_error "$help"
496*a376eb32SXin Li}
497*a376eb32SXin Lihelp="Try \`$progname --help' for more information."  ## default
498*a376eb32SXin Li
499*a376eb32SXin Li
500*a376eb32SXin Li# func_grep expression filename
501*a376eb32SXin Li# Check whether EXPRESSION matches any line of FILENAME, without output.
502*a376eb32SXin Lifunc_grep ()
503*a376eb32SXin Li{
504*a376eb32SXin Li    $GREP "$1" "$2" >/dev/null 2>&1
505*a376eb32SXin Li}
506*a376eb32SXin Li
507*a376eb32SXin Li
508*a376eb32SXin Li# func_mkdir_p directory-path
509*a376eb32SXin Li# Make sure the entire path to DIRECTORY-PATH is available.
510*a376eb32SXin Lifunc_mkdir_p ()
511*a376eb32SXin Li{
512*a376eb32SXin Li    my_directory_path="$1"
513*a376eb32SXin Li    my_dir_list=
514*a376eb32SXin Li
515*a376eb32SXin Li    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
516*a376eb32SXin Li
517*a376eb32SXin Li      # Protect directory names starting with `-'
518*a376eb32SXin Li      case $my_directory_path in
519*a376eb32SXin Li        -*) my_directory_path="./$my_directory_path" ;;
520*a376eb32SXin Li      esac
521*a376eb32SXin Li
522*a376eb32SXin Li      # While some portion of DIR does not yet exist...
523*a376eb32SXin Li      while test ! -d "$my_directory_path"; do
524*a376eb32SXin Li        # ...make a list in topmost first order.  Use a colon delimited
525*a376eb32SXin Li	# list incase some portion of path contains whitespace.
526*a376eb32SXin Li        my_dir_list="$my_directory_path:$my_dir_list"
527*a376eb32SXin Li
528*a376eb32SXin Li        # If the last portion added has no slash in it, the list is done
529*a376eb32SXin Li        case $my_directory_path in */*) ;; *) break ;; esac
530*a376eb32SXin Li
531*a376eb32SXin Li        # ...otherwise throw away the child directory and loop
532*a376eb32SXin Li        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
533*a376eb32SXin Li      done
534*a376eb32SXin Li      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
535*a376eb32SXin Li
536*a376eb32SXin Li      save_mkdir_p_IFS="$IFS"; IFS=':'
537*a376eb32SXin Li      for my_dir in $my_dir_list; do
538*a376eb32SXin Li	IFS="$save_mkdir_p_IFS"
539*a376eb32SXin Li        # mkdir can fail with a `File exist' error if two processes
540*a376eb32SXin Li        # try to create one of the directories concurrently.  Don't
541*a376eb32SXin Li        # stop in that case!
542*a376eb32SXin Li        $MKDIR "$my_dir" 2>/dev/null || :
543*a376eb32SXin Li      done
544*a376eb32SXin Li      IFS="$save_mkdir_p_IFS"
545*a376eb32SXin Li
546*a376eb32SXin Li      # Bail out if we (or some other process) failed to create a directory.
547*a376eb32SXin Li      test -d "$my_directory_path" || \
548*a376eb32SXin Li        func_fatal_error "Failed to create \`$1'"
549*a376eb32SXin Li    fi
550*a376eb32SXin Li}
551*a376eb32SXin Li
552*a376eb32SXin Li
553*a376eb32SXin Li# func_mktempdir [string]
554*a376eb32SXin Li# Make a temporary directory that won't clash with other running
555*a376eb32SXin Li# libtool processes, and avoids race conditions if possible.  If
556*a376eb32SXin Li# given, STRING is the basename for that directory.
557*a376eb32SXin Lifunc_mktempdir ()
558*a376eb32SXin Li{
559*a376eb32SXin Li    my_template="${TMPDIR-/tmp}/${1-$progname}"
560*a376eb32SXin Li
561*a376eb32SXin Li    if test "$opt_dry_run" = ":"; then
562*a376eb32SXin Li      # Return a directory name, but don't create it in dry-run mode
563*a376eb32SXin Li      my_tmpdir="${my_template}-$$"
564*a376eb32SXin Li    else
565*a376eb32SXin Li
566*a376eb32SXin Li      # If mktemp works, use that first and foremost
567*a376eb32SXin Li      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
568*a376eb32SXin Li
569*a376eb32SXin Li      if test ! -d "$my_tmpdir"; then
570*a376eb32SXin Li        # Failing that, at least try and use $RANDOM to avoid a race
571*a376eb32SXin Li        my_tmpdir="${my_template}-${RANDOM-0}$$"
572*a376eb32SXin Li
573*a376eb32SXin Li        save_mktempdir_umask=`umask`
574*a376eb32SXin Li        umask 0077
575*a376eb32SXin Li        $MKDIR "$my_tmpdir"
576*a376eb32SXin Li        umask $save_mktempdir_umask
577*a376eb32SXin Li      fi
578*a376eb32SXin Li
579*a376eb32SXin Li      # If we're not in dry-run mode, bomb out on failure
580*a376eb32SXin Li      test -d "$my_tmpdir" || \
581*a376eb32SXin Li        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
582*a376eb32SXin Li    fi
583*a376eb32SXin Li
584*a376eb32SXin Li    $ECHO "$my_tmpdir"
585*a376eb32SXin Li}
586*a376eb32SXin Li
587*a376eb32SXin Li
588*a376eb32SXin Li# func_quote_for_eval arg
589*a376eb32SXin Li# Aesthetically quote ARG to be evaled later.
590*a376eb32SXin Li# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
591*a376eb32SXin Li# is double-quoted, suitable for a subsequent eval, whereas
592*a376eb32SXin Li# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
593*a376eb32SXin Li# which are still active within double quotes backslashified.
594*a376eb32SXin Lifunc_quote_for_eval ()
595*a376eb32SXin Li{
596*a376eb32SXin Li    case $1 in
597*a376eb32SXin Li      *[\\\`\"\$]*)
598*a376eb32SXin Li	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
599*a376eb32SXin Li      *)
600*a376eb32SXin Li        func_quote_for_eval_unquoted_result="$1" ;;
601*a376eb32SXin Li    esac
602*a376eb32SXin Li
603*a376eb32SXin Li    case $func_quote_for_eval_unquoted_result in
604*a376eb32SXin Li      # Double-quote args containing shell metacharacters to delay
605*a376eb32SXin Li      # word splitting, command substitution and and variable
606*a376eb32SXin Li      # expansion for a subsequent eval.
607*a376eb32SXin Li      # Many Bourne shells cannot handle close brackets correctly
608*a376eb32SXin Li      # in scan sets, so we specify it separately.
609*a376eb32SXin Li      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
610*a376eb32SXin Li        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
611*a376eb32SXin Li        ;;
612*a376eb32SXin Li      *)
613*a376eb32SXin Li        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
614*a376eb32SXin Li    esac
615*a376eb32SXin Li}
616*a376eb32SXin Li
617*a376eb32SXin Li
618*a376eb32SXin Li# func_quote_for_expand arg
619*a376eb32SXin Li# Aesthetically quote ARG to be evaled later; same as above,
620*a376eb32SXin Li# but do not quote variable references.
621*a376eb32SXin Lifunc_quote_for_expand ()
622*a376eb32SXin Li{
623*a376eb32SXin Li    case $1 in
624*a376eb32SXin Li      *[\\\`\"]*)
625*a376eb32SXin Li	my_arg=`$ECHO "$1" | $SED \
626*a376eb32SXin Li	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
627*a376eb32SXin Li      *)
628*a376eb32SXin Li        my_arg="$1" ;;
629*a376eb32SXin Li    esac
630*a376eb32SXin Li
631*a376eb32SXin Li    case $my_arg in
632*a376eb32SXin Li      # Double-quote args containing shell metacharacters to delay
633*a376eb32SXin Li      # word splitting and command substitution for a subsequent eval.
634*a376eb32SXin Li      # Many Bourne shells cannot handle close brackets correctly
635*a376eb32SXin Li      # in scan sets, so we specify it separately.
636*a376eb32SXin Li      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
637*a376eb32SXin Li        my_arg="\"$my_arg\""
638*a376eb32SXin Li        ;;
639*a376eb32SXin Li    esac
640*a376eb32SXin Li
641*a376eb32SXin Li    func_quote_for_expand_result="$my_arg"
642*a376eb32SXin Li}
643*a376eb32SXin Li
644*a376eb32SXin Li
645*a376eb32SXin Li# func_show_eval cmd [fail_exp]
646*a376eb32SXin Li# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
647*a376eb32SXin Li# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
648*a376eb32SXin Li# is given, then evaluate it.
649*a376eb32SXin Lifunc_show_eval ()
650*a376eb32SXin Li{
651*a376eb32SXin Li    my_cmd="$1"
652*a376eb32SXin Li    my_fail_exp="${2-:}"
653*a376eb32SXin Li
654*a376eb32SXin Li    ${opt_silent-false} || {
655*a376eb32SXin Li      func_quote_for_expand "$my_cmd"
656*a376eb32SXin Li      eval "func_echo $func_quote_for_expand_result"
657*a376eb32SXin Li    }
658*a376eb32SXin Li
659*a376eb32SXin Li    if ${opt_dry_run-false}; then :; else
660*a376eb32SXin Li      eval "$my_cmd"
661*a376eb32SXin Li      my_status=$?
662*a376eb32SXin Li      if test "$my_status" -eq 0; then :; else
663*a376eb32SXin Li	eval "(exit $my_status); $my_fail_exp"
664*a376eb32SXin Li      fi
665*a376eb32SXin Li    fi
666*a376eb32SXin Li}
667*a376eb32SXin Li
668*a376eb32SXin Li
669*a376eb32SXin Li# func_show_eval_locale cmd [fail_exp]
670*a376eb32SXin Li# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
671*a376eb32SXin Li# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
672*a376eb32SXin Li# is given, then evaluate it.  Use the saved locale for evaluation.
673*a376eb32SXin Lifunc_show_eval_locale ()
674*a376eb32SXin Li{
675*a376eb32SXin Li    my_cmd="$1"
676*a376eb32SXin Li    my_fail_exp="${2-:}"
677*a376eb32SXin Li
678*a376eb32SXin Li    ${opt_silent-false} || {
679*a376eb32SXin Li      func_quote_for_expand "$my_cmd"
680*a376eb32SXin Li      eval "func_echo $func_quote_for_expand_result"
681*a376eb32SXin Li    }
682*a376eb32SXin Li
683*a376eb32SXin Li    if ${opt_dry_run-false}; then :; else
684*a376eb32SXin Li      eval "$lt_user_locale
685*a376eb32SXin Li	    $my_cmd"
686*a376eb32SXin Li      my_status=$?
687*a376eb32SXin Li      eval "$lt_safe_locale"
688*a376eb32SXin Li      if test "$my_status" -eq 0; then :; else
689*a376eb32SXin Li	eval "(exit $my_status); $my_fail_exp"
690*a376eb32SXin Li      fi
691*a376eb32SXin Li    fi
692*a376eb32SXin Li}
693*a376eb32SXin Li
694*a376eb32SXin Li# func_tr_sh
695*a376eb32SXin Li# Turn $1 into a string suitable for a shell variable name.
696*a376eb32SXin Li# Result is stored in $func_tr_sh_result.  All characters
697*a376eb32SXin Li# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
698*a376eb32SXin Li# if $1 begins with a digit, a '_' is prepended as well.
699*a376eb32SXin Lifunc_tr_sh ()
700*a376eb32SXin Li{
701*a376eb32SXin Li  case $1 in
702*a376eb32SXin Li  [0-9]* | *[!a-zA-Z0-9_]*)
703*a376eb32SXin Li    func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
704*a376eb32SXin Li    ;;
705*a376eb32SXin Li  * )
706*a376eb32SXin Li    func_tr_sh_result=$1
707*a376eb32SXin Li    ;;
708*a376eb32SXin Li  esac
709*a376eb32SXin Li}
710*a376eb32SXin Li
711*a376eb32SXin Li
712*a376eb32SXin Li# func_version
713*a376eb32SXin Li# Echo version message to standard output and exit.
714*a376eb32SXin Lifunc_version ()
715*a376eb32SXin Li{
716*a376eb32SXin Li    $opt_debug
717*a376eb32SXin Li
718*a376eb32SXin Li    $SED -n '/(C)/!b go
719*a376eb32SXin Li	:more
720*a376eb32SXin Li	/\./!{
721*a376eb32SXin Li	  N
722*a376eb32SXin Li	  s/\n# / /
723*a376eb32SXin Li	  b more
724*a376eb32SXin Li	}
725*a376eb32SXin Li	:go
726*a376eb32SXin Li	/^# '$PROGRAM' (GNU /,/# warranty; / {
727*a376eb32SXin Li        s/^# //
728*a376eb32SXin Li	s/^# *$//
729*a376eb32SXin Li        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
730*a376eb32SXin Li        p
731*a376eb32SXin Li     }' < "$progpath"
732*a376eb32SXin Li     exit $?
733*a376eb32SXin Li}
734*a376eb32SXin Li
735*a376eb32SXin Li# func_usage
736*a376eb32SXin Li# Echo short help message to standard output and exit.
737*a376eb32SXin Lifunc_usage ()
738*a376eb32SXin Li{
739*a376eb32SXin Li    $opt_debug
740*a376eb32SXin Li
741*a376eb32SXin Li    $SED -n '/^# Usage:/,/^#  *.*--help/ {
742*a376eb32SXin Li        s/^# //
743*a376eb32SXin Li	s/^# *$//
744*a376eb32SXin Li	s/\$progname/'$progname'/
745*a376eb32SXin Li	p
746*a376eb32SXin Li    }' < "$progpath"
747*a376eb32SXin Li    echo
748*a376eb32SXin Li    $ECHO "run \`$progname --help | more' for full usage"
749*a376eb32SXin Li    exit $?
750*a376eb32SXin Li}
751*a376eb32SXin Li
752*a376eb32SXin Li# func_help [NOEXIT]
753*a376eb32SXin Li# Echo long help message to standard output and exit,
754*a376eb32SXin Li# unless 'noexit' is passed as argument.
755*a376eb32SXin Lifunc_help ()
756*a376eb32SXin Li{
757*a376eb32SXin Li    $opt_debug
758*a376eb32SXin Li
759*a376eb32SXin Li    $SED -n '/^# Usage:/,/# Report bugs to/ {
760*a376eb32SXin Li	:print
761*a376eb32SXin Li        s/^# //
762*a376eb32SXin Li	s/^# *$//
763*a376eb32SXin Li	s*\$progname*'$progname'*
764*a376eb32SXin Li	s*\$host*'"$host"'*
765*a376eb32SXin Li	s*\$SHELL*'"$SHELL"'*
766*a376eb32SXin Li	s*\$LTCC*'"$LTCC"'*
767*a376eb32SXin Li	s*\$LTCFLAGS*'"$LTCFLAGS"'*
768*a376eb32SXin Li	s*\$LD*'"$LD"'*
769*a376eb32SXin Li	s/\$with_gnu_ld/'"$with_gnu_ld"'/
770*a376eb32SXin Li	s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/
771*a376eb32SXin Li	s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/
772*a376eb32SXin Li	p
773*a376eb32SXin Li	d
774*a376eb32SXin Li     }
775*a376eb32SXin Li     /^# .* home page:/b print
776*a376eb32SXin Li     /^# General help using/b print
777*a376eb32SXin Li     ' < "$progpath"
778*a376eb32SXin Li    ret=$?
779*a376eb32SXin Li    if test -z "$1"; then
780*a376eb32SXin Li      exit $ret
781*a376eb32SXin Li    fi
782*a376eb32SXin Li}
783*a376eb32SXin Li
784*a376eb32SXin Li# func_missing_arg argname
785*a376eb32SXin Li# Echo program name prefixed message to standard error and set global
786*a376eb32SXin Li# exit_cmd.
787*a376eb32SXin Lifunc_missing_arg ()
788*a376eb32SXin Li{
789*a376eb32SXin Li    $opt_debug
790*a376eb32SXin Li
791*a376eb32SXin Li    func_error "missing argument for $1."
792*a376eb32SXin Li    exit_cmd=exit
793*a376eb32SXin Li}
794*a376eb32SXin Li
795*a376eb32SXin Li
796*a376eb32SXin Li# func_split_short_opt shortopt
797*a376eb32SXin Li# Set func_split_short_opt_name and func_split_short_opt_arg shell
798*a376eb32SXin Li# variables after splitting SHORTOPT after the 2nd character.
799*a376eb32SXin Lifunc_split_short_opt ()
800*a376eb32SXin Li{
801*a376eb32SXin Li    my_sed_short_opt='1s/^\(..\).*$/\1/;q'
802*a376eb32SXin Li    my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
803*a376eb32SXin Li
804*a376eb32SXin Li    func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
805*a376eb32SXin Li    func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
806*a376eb32SXin Li} # func_split_short_opt may be replaced by extended shell implementation
807*a376eb32SXin Li
808*a376eb32SXin Li
809*a376eb32SXin Li# func_split_long_opt longopt
810*a376eb32SXin Li# Set func_split_long_opt_name and func_split_long_opt_arg shell
811*a376eb32SXin Li# variables after splitting LONGOPT at the `=' sign.
812*a376eb32SXin Lifunc_split_long_opt ()
813*a376eb32SXin Li{
814*a376eb32SXin Li    my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
815*a376eb32SXin Li    my_sed_long_arg='1s/^--[^=]*=//'
816*a376eb32SXin Li
817*a376eb32SXin Li    func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
818*a376eb32SXin Li    func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
819*a376eb32SXin Li} # func_split_long_opt may be replaced by extended shell implementation
820*a376eb32SXin Li
821*a376eb32SXin Liexit_cmd=:
822*a376eb32SXin Li
823*a376eb32SXin Li
824*a376eb32SXin Li
825*a376eb32SXin Li
826*a376eb32SXin Li
827*a376eb32SXin Limagic="%%%MAGIC variable%%%"
828*a376eb32SXin Limagic_exe="%%%MAGIC EXE variable%%%"
829*a376eb32SXin Li
830*a376eb32SXin Li# Global variables.
831*a376eb32SXin Linonopt=
832*a376eb32SXin Lipreserve_args=
833*a376eb32SXin Lilo2o="s/\\.lo\$/.${objext}/"
834*a376eb32SXin Lio2lo="s/\\.${objext}\$/.lo/"
835*a376eb32SXin Liextracted_archives=
836*a376eb32SXin Liextracted_serial=0
837*a376eb32SXin Li
838*a376eb32SXin Li# If this variable is set in any of the actions, the command in it
839*a376eb32SXin Li# will be execed at the end.  This prevents here-documents from being
840*a376eb32SXin Li# left over by shells.
841*a376eb32SXin Liexec_cmd=
842*a376eb32SXin Li
843*a376eb32SXin Li# func_append var value
844*a376eb32SXin Li# Append VALUE to the end of shell variable VAR.
845*a376eb32SXin Lifunc_append ()
846*a376eb32SXin Li{
847*a376eb32SXin Li    eval "${1}=\$${1}\${2}"
848*a376eb32SXin Li} # func_append may be replaced by extended shell implementation
849*a376eb32SXin Li
850*a376eb32SXin Li# func_append_quoted var value
851*a376eb32SXin Li# Quote VALUE and append to the end of shell variable VAR, separated
852*a376eb32SXin Li# by a space.
853*a376eb32SXin Lifunc_append_quoted ()
854*a376eb32SXin Li{
855*a376eb32SXin Li    func_quote_for_eval "${2}"
856*a376eb32SXin Li    eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
857*a376eb32SXin Li} # func_append_quoted may be replaced by extended shell implementation
858*a376eb32SXin Li
859*a376eb32SXin Li
860*a376eb32SXin Li# func_arith arithmetic-term...
861*a376eb32SXin Lifunc_arith ()
862*a376eb32SXin Li{
863*a376eb32SXin Li    func_arith_result=`expr "${@}"`
864*a376eb32SXin Li} # func_arith may be replaced by extended shell implementation
865*a376eb32SXin Li
866*a376eb32SXin Li
867*a376eb32SXin Li# func_len string
868*a376eb32SXin Li# STRING may not start with a hyphen.
869*a376eb32SXin Lifunc_len ()
870*a376eb32SXin Li{
871*a376eb32SXin Li    func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
872*a376eb32SXin Li} # func_len may be replaced by extended shell implementation
873*a376eb32SXin Li
874*a376eb32SXin Li
875*a376eb32SXin Li# func_lo2o object
876*a376eb32SXin Lifunc_lo2o ()
877*a376eb32SXin Li{
878*a376eb32SXin Li    func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
879*a376eb32SXin Li} # func_lo2o may be replaced by extended shell implementation
880*a376eb32SXin Li
881*a376eb32SXin Li
882*a376eb32SXin Li# func_xform libobj-or-source
883*a376eb32SXin Lifunc_xform ()
884*a376eb32SXin Li{
885*a376eb32SXin Li    func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
886*a376eb32SXin Li} # func_xform may be replaced by extended shell implementation
887*a376eb32SXin Li
888*a376eb32SXin Li
889*a376eb32SXin Li# func_fatal_configuration arg...
890*a376eb32SXin Li# Echo program name prefixed message to standard error, followed by
891*a376eb32SXin Li# a configuration failure hint, and exit.
892*a376eb32SXin Lifunc_fatal_configuration ()
893*a376eb32SXin Li{
894*a376eb32SXin Li    func_error ${1+"$@"}
895*a376eb32SXin Li    func_error "See the $PACKAGE documentation for more information."
896*a376eb32SXin Li    func_fatal_error "Fatal configuration error."
897*a376eb32SXin Li}
898*a376eb32SXin Li
899*a376eb32SXin Li
900*a376eb32SXin Li# func_config
901*a376eb32SXin Li# Display the configuration for all the tags in this script.
902*a376eb32SXin Lifunc_config ()
903*a376eb32SXin Li{
904*a376eb32SXin Li    re_begincf='^# ### BEGIN LIBTOOL'
905*a376eb32SXin Li    re_endcf='^# ### END LIBTOOL'
906*a376eb32SXin Li
907*a376eb32SXin Li    # Default configuration.
908*a376eb32SXin Li    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
909*a376eb32SXin Li
910*a376eb32SXin Li    # Now print the configurations for the tags.
911*a376eb32SXin Li    for tagname in $taglist; do
912*a376eb32SXin Li      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
913*a376eb32SXin Li    done
914*a376eb32SXin Li
915*a376eb32SXin Li    exit $?
916*a376eb32SXin Li}
917*a376eb32SXin Li
918*a376eb32SXin Li# func_features
919*a376eb32SXin Li# Display the features supported by this script.
920*a376eb32SXin Lifunc_features ()
921*a376eb32SXin Li{
922*a376eb32SXin Li    echo "host: $host"
923*a376eb32SXin Li    if test "$build_libtool_libs" = yes; then
924*a376eb32SXin Li      echo "enable shared libraries"
925*a376eb32SXin Li    else
926*a376eb32SXin Li      echo "disable shared libraries"
927*a376eb32SXin Li    fi
928*a376eb32SXin Li    if test "$build_old_libs" = yes; then
929*a376eb32SXin Li      echo "enable static libraries"
930*a376eb32SXin Li    else
931*a376eb32SXin Li      echo "disable static libraries"
932*a376eb32SXin Li    fi
933*a376eb32SXin Li
934*a376eb32SXin Li    exit $?
935*a376eb32SXin Li}
936*a376eb32SXin Li
937*a376eb32SXin Li# func_enable_tag tagname
938*a376eb32SXin Li# Verify that TAGNAME is valid, and either flag an error and exit, or
939*a376eb32SXin Li# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
940*a376eb32SXin Li# variable here.
941*a376eb32SXin Lifunc_enable_tag ()
942*a376eb32SXin Li{
943*a376eb32SXin Li  # Global variable:
944*a376eb32SXin Li  tagname="$1"
945*a376eb32SXin Li
946*a376eb32SXin Li  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
947*a376eb32SXin Li  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
948*a376eb32SXin Li  sed_extractcf="/$re_begincf/,/$re_endcf/p"
949*a376eb32SXin Li
950*a376eb32SXin Li  # Validate tagname.
951*a376eb32SXin Li  case $tagname in
952*a376eb32SXin Li    *[!-_A-Za-z0-9,/]*)
953*a376eb32SXin Li      func_fatal_error "invalid tag name: $tagname"
954*a376eb32SXin Li      ;;
955*a376eb32SXin Li  esac
956*a376eb32SXin Li
957*a376eb32SXin Li  # Don't test for the "default" C tag, as we know it's
958*a376eb32SXin Li  # there but not specially marked.
959*a376eb32SXin Li  case $tagname in
960*a376eb32SXin Li    CC) ;;
961*a376eb32SXin Li    *)
962*a376eb32SXin Li      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
963*a376eb32SXin Li	taglist="$taglist $tagname"
964*a376eb32SXin Li
965*a376eb32SXin Li	# Evaluate the configuration.  Be careful to quote the path
966*a376eb32SXin Li	# and the sed script, to avoid splitting on whitespace, but
967*a376eb32SXin Li	# also don't use non-portable quotes within backquotes within
968*a376eb32SXin Li	# quotes we have to do it in 2 steps:
969*a376eb32SXin Li	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
970*a376eb32SXin Li	eval "$extractedcf"
971*a376eb32SXin Li      else
972*a376eb32SXin Li	func_error "ignoring unknown tag $tagname"
973*a376eb32SXin Li      fi
974*a376eb32SXin Li      ;;
975*a376eb32SXin Li  esac
976*a376eb32SXin Li}
977*a376eb32SXin Li
978*a376eb32SXin Li# func_check_version_match
979*a376eb32SXin Li# Ensure that we are using m4 macros, and libtool script from the same
980*a376eb32SXin Li# release of libtool.
981*a376eb32SXin Lifunc_check_version_match ()
982*a376eb32SXin Li{
983*a376eb32SXin Li  if test "$package_revision" != "$macro_revision"; then
984*a376eb32SXin Li    if test "$VERSION" != "$macro_version"; then
985*a376eb32SXin Li      if test -z "$macro_version"; then
986*a376eb32SXin Li        cat >&2 <<_LT_EOF
987*a376eb32SXin Li$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
988*a376eb32SXin Li$progname: definition of this LT_INIT comes from an older release.
989*a376eb32SXin Li$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
990*a376eb32SXin Li$progname: and run autoconf again.
991*a376eb32SXin Li_LT_EOF
992*a376eb32SXin Li      else
993*a376eb32SXin Li        cat >&2 <<_LT_EOF
994*a376eb32SXin Li$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
995*a376eb32SXin Li$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
996*a376eb32SXin Li$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
997*a376eb32SXin Li$progname: and run autoconf again.
998*a376eb32SXin Li_LT_EOF
999*a376eb32SXin Li      fi
1000*a376eb32SXin Li    else
1001*a376eb32SXin Li      cat >&2 <<_LT_EOF
1002*a376eb32SXin Li$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
1003*a376eb32SXin Li$progname: but the definition of this LT_INIT comes from revision $macro_revision.
1004*a376eb32SXin Li$progname: You should recreate aclocal.m4 with macros from revision $package_revision
1005*a376eb32SXin Li$progname: of $PACKAGE $VERSION and run autoconf again.
1006*a376eb32SXin Li_LT_EOF
1007*a376eb32SXin Li    fi
1008*a376eb32SXin Li
1009*a376eb32SXin Li    exit $EXIT_MISMATCH
1010*a376eb32SXin Li  fi
1011*a376eb32SXin Li}
1012*a376eb32SXin Li
1013*a376eb32SXin Li
1014*a376eb32SXin Li# Shorthand for --mode=foo, only valid as the first argument
1015*a376eb32SXin Licase $1 in
1016*a376eb32SXin Liclean|clea|cle|cl)
1017*a376eb32SXin Li  shift; set dummy --mode clean ${1+"$@"}; shift
1018*a376eb32SXin Li  ;;
1019*a376eb32SXin Licompile|compil|compi|comp|com|co|c)
1020*a376eb32SXin Li  shift; set dummy --mode compile ${1+"$@"}; shift
1021*a376eb32SXin Li  ;;
1022*a376eb32SXin Liexecute|execut|execu|exec|exe|ex|e)
1023*a376eb32SXin Li  shift; set dummy --mode execute ${1+"$@"}; shift
1024*a376eb32SXin Li  ;;
1025*a376eb32SXin Lifinish|finis|fini|fin|fi|f)
1026*a376eb32SXin Li  shift; set dummy --mode finish ${1+"$@"}; shift
1027*a376eb32SXin Li  ;;
1028*a376eb32SXin Liinstall|instal|insta|inst|ins|in|i)
1029*a376eb32SXin Li  shift; set dummy --mode install ${1+"$@"}; shift
1030*a376eb32SXin Li  ;;
1031*a376eb32SXin Lilink|lin|li|l)
1032*a376eb32SXin Li  shift; set dummy --mode link ${1+"$@"}; shift
1033*a376eb32SXin Li  ;;
1034*a376eb32SXin Liuninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
1035*a376eb32SXin Li  shift; set dummy --mode uninstall ${1+"$@"}; shift
1036*a376eb32SXin Li  ;;
1037*a376eb32SXin Liesac
1038*a376eb32SXin Li
1039*a376eb32SXin Li
1040*a376eb32SXin Li
1041*a376eb32SXin Li# Option defaults:
1042*a376eb32SXin Liopt_debug=:
1043*a376eb32SXin Liopt_dry_run=false
1044*a376eb32SXin Liopt_config=false
1045*a376eb32SXin Liopt_preserve_dup_deps=false
1046*a376eb32SXin Liopt_features=false
1047*a376eb32SXin Liopt_finish=false
1048*a376eb32SXin Liopt_help=false
1049*a376eb32SXin Liopt_help_all=false
1050*a376eb32SXin Liopt_silent=:
1051*a376eb32SXin Liopt_warning=:
1052*a376eb32SXin Liopt_verbose=:
1053*a376eb32SXin Liopt_silent=false
1054*a376eb32SXin Liopt_verbose=false
1055*a376eb32SXin Li
1056*a376eb32SXin Li
1057*a376eb32SXin Li# Parse options once, thoroughly.  This comes as soon as possible in the
1058*a376eb32SXin Li# script to make things like `--version' happen as quickly as we can.
1059*a376eb32SXin Li{
1060*a376eb32SXin Li  # this just eases exit handling
1061*a376eb32SXin Li  while test $# -gt 0; do
1062*a376eb32SXin Li    opt="$1"
1063*a376eb32SXin Li    shift
1064*a376eb32SXin Li    case $opt in
1065*a376eb32SXin Li      --debug|-x)	opt_debug='set -x'
1066*a376eb32SXin Li			func_echo "enabling shell trace mode"
1067*a376eb32SXin Li			$opt_debug
1068*a376eb32SXin Li			;;
1069*a376eb32SXin Li      --dry-run|--dryrun|-n)
1070*a376eb32SXin Li			opt_dry_run=:
1071*a376eb32SXin Li			;;
1072*a376eb32SXin Li      --config)
1073*a376eb32SXin Li			opt_config=:
1074*a376eb32SXin Lifunc_config
1075*a376eb32SXin Li			;;
1076*a376eb32SXin Li      --dlopen|-dlopen)
1077*a376eb32SXin Li			optarg="$1"
1078*a376eb32SXin Li			opt_dlopen="${opt_dlopen+$opt_dlopen
1079*a376eb32SXin Li}$optarg"
1080*a376eb32SXin Li			shift
1081*a376eb32SXin Li			;;
1082*a376eb32SXin Li      --preserve-dup-deps)
1083*a376eb32SXin Li			opt_preserve_dup_deps=:
1084*a376eb32SXin Li			;;
1085*a376eb32SXin Li      --features)
1086*a376eb32SXin Li			opt_features=:
1087*a376eb32SXin Lifunc_features
1088*a376eb32SXin Li			;;
1089*a376eb32SXin Li      --finish)
1090*a376eb32SXin Li			opt_finish=:
1091*a376eb32SXin Liset dummy --mode finish ${1+"$@"}; shift
1092*a376eb32SXin Li			;;
1093*a376eb32SXin Li      --help)
1094*a376eb32SXin Li			opt_help=:
1095*a376eb32SXin Li			;;
1096*a376eb32SXin Li      --help-all)
1097*a376eb32SXin Li			opt_help_all=:
1098*a376eb32SXin Liopt_help=': help-all'
1099*a376eb32SXin Li			;;
1100*a376eb32SXin Li      --mode)
1101*a376eb32SXin Li			test $# = 0 && func_missing_arg $opt && break
1102*a376eb32SXin Li			optarg="$1"
1103*a376eb32SXin Li			opt_mode="$optarg"
1104*a376eb32SXin Licase $optarg in
1105*a376eb32SXin Li  # Valid mode arguments:
1106*a376eb32SXin Li  clean|compile|execute|finish|install|link|relink|uninstall) ;;
1107*a376eb32SXin Li
1108*a376eb32SXin Li  # Catch anything else as an error
1109*a376eb32SXin Li  *) func_error "invalid argument for $opt"
1110*a376eb32SXin Li     exit_cmd=exit
1111*a376eb32SXin Li     break
1112*a376eb32SXin Li     ;;
1113*a376eb32SXin Liesac
1114*a376eb32SXin Li			shift
1115*a376eb32SXin Li			;;
1116*a376eb32SXin Li      --no-silent|--no-quiet)
1117*a376eb32SXin Li			opt_silent=false
1118*a376eb32SXin Lifunc_append preserve_args " $opt"
1119*a376eb32SXin Li			;;
1120*a376eb32SXin Li      --no-warning|--no-warn)
1121*a376eb32SXin Li			opt_warning=false
1122*a376eb32SXin Lifunc_append preserve_args " $opt"
1123*a376eb32SXin Li			;;
1124*a376eb32SXin Li      --no-verbose)
1125*a376eb32SXin Li			opt_verbose=false
1126*a376eb32SXin Lifunc_append preserve_args " $opt"
1127*a376eb32SXin Li			;;
1128*a376eb32SXin Li      --silent|--quiet)
1129*a376eb32SXin Li			opt_silent=:
1130*a376eb32SXin Lifunc_append preserve_args " $opt"
1131*a376eb32SXin Li        opt_verbose=false
1132*a376eb32SXin Li			;;
1133*a376eb32SXin Li      --verbose|-v)
1134*a376eb32SXin Li			opt_verbose=:
1135*a376eb32SXin Lifunc_append preserve_args " $opt"
1136*a376eb32SXin Liopt_silent=false
1137*a376eb32SXin Li			;;
1138*a376eb32SXin Li      --tag)
1139*a376eb32SXin Li			test $# = 0 && func_missing_arg $opt && break
1140*a376eb32SXin Li			optarg="$1"
1141*a376eb32SXin Li			opt_tag="$optarg"
1142*a376eb32SXin Lifunc_append preserve_args " $opt $optarg"
1143*a376eb32SXin Lifunc_enable_tag "$optarg"
1144*a376eb32SXin Li			shift
1145*a376eb32SXin Li			;;
1146*a376eb32SXin Li
1147*a376eb32SXin Li      -\?|-h)		func_usage				;;
1148*a376eb32SXin Li      --help)		func_help				;;
1149*a376eb32SXin Li      --version)	func_version				;;
1150*a376eb32SXin Li
1151*a376eb32SXin Li      # Separate optargs to long options:
1152*a376eb32SXin Li      --*=*)
1153*a376eb32SXin Li			func_split_long_opt "$opt"
1154*a376eb32SXin Li			set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
1155*a376eb32SXin Li			shift
1156*a376eb32SXin Li			;;
1157*a376eb32SXin Li
1158*a376eb32SXin Li      # Separate non-argument short options:
1159*a376eb32SXin Li      -\?*|-h*|-n*|-v*)
1160*a376eb32SXin Li			func_split_short_opt "$opt"
1161*a376eb32SXin Li			set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
1162*a376eb32SXin Li			shift
1163*a376eb32SXin Li			;;
1164*a376eb32SXin Li
1165*a376eb32SXin Li      --)		break					;;
1166*a376eb32SXin Li      -*)		func_fatal_help "unrecognized option \`$opt'" ;;
1167*a376eb32SXin Li      *)		set dummy "$opt" ${1+"$@"};	shift; break  ;;
1168*a376eb32SXin Li    esac
1169*a376eb32SXin Li  done
1170*a376eb32SXin Li
1171*a376eb32SXin Li  # Validate options:
1172*a376eb32SXin Li
1173*a376eb32SXin Li  # save first non-option argument
1174*a376eb32SXin Li  if test "$#" -gt 0; then
1175*a376eb32SXin Li    nonopt="$opt"
1176*a376eb32SXin Li    shift
1177*a376eb32SXin Li  fi
1178*a376eb32SXin Li
1179*a376eb32SXin Li  # preserve --debug
1180*a376eb32SXin Li  test "$opt_debug" = : || func_append preserve_args " --debug"
1181*a376eb32SXin Li
1182*a376eb32SXin Li  case $host in
1183*a376eb32SXin Li    *cygwin* | *mingw* | *pw32* | *cegcc*)
1184*a376eb32SXin Li      # don't eliminate duplications in $postdeps and $predeps
1185*a376eb32SXin Li      opt_duplicate_compiler_generated_deps=:
1186*a376eb32SXin Li      ;;
1187*a376eb32SXin Li    *)
1188*a376eb32SXin Li      opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
1189*a376eb32SXin Li      ;;
1190*a376eb32SXin Li  esac
1191*a376eb32SXin Li
1192*a376eb32SXin Li  $opt_help || {
1193*a376eb32SXin Li    # Sanity checks first:
1194*a376eb32SXin Li    func_check_version_match
1195*a376eb32SXin Li
1196*a376eb32SXin Li    if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
1197*a376eb32SXin Li      func_fatal_configuration "not configured to build any kind of library"
1198*a376eb32SXin Li    fi
1199*a376eb32SXin Li
1200*a376eb32SXin Li    # Darwin sucks
1201*a376eb32SXin Li    eval std_shrext=\"$shrext_cmds\"
1202*a376eb32SXin Li
1203*a376eb32SXin Li    # Only execute mode is allowed to have -dlopen flags.
1204*a376eb32SXin Li    if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
1205*a376eb32SXin Li      func_error "unrecognized option \`-dlopen'"
1206*a376eb32SXin Li      $ECHO "$help" 1>&2
1207*a376eb32SXin Li      exit $EXIT_FAILURE
1208*a376eb32SXin Li    fi
1209*a376eb32SXin Li
1210*a376eb32SXin Li    # Change the help message to a mode-specific one.
1211*a376eb32SXin Li    generic_help="$help"
1212*a376eb32SXin Li    help="Try \`$progname --help --mode=$opt_mode' for more information."
1213*a376eb32SXin Li  }
1214*a376eb32SXin Li
1215*a376eb32SXin Li
1216*a376eb32SXin Li  # Bail if the options were screwed
1217*a376eb32SXin Li  $exit_cmd $EXIT_FAILURE
1218*a376eb32SXin Li}
1219*a376eb32SXin Li
1220*a376eb32SXin Li
1221*a376eb32SXin Li
1222*a376eb32SXin Li
1223*a376eb32SXin Li## ----------- ##
1224*a376eb32SXin Li##    Main.    ##
1225*a376eb32SXin Li## ----------- ##
1226*a376eb32SXin Li
1227*a376eb32SXin Li# func_lalib_p file
1228*a376eb32SXin Li# True iff FILE is a libtool `.la' library or `.lo' object file.
1229*a376eb32SXin Li# This function is only a basic sanity check; it will hardly flush out
1230*a376eb32SXin Li# determined imposters.
1231*a376eb32SXin Lifunc_lalib_p ()
1232*a376eb32SXin Li{
1233*a376eb32SXin Li    test -f "$1" &&
1234*a376eb32SXin Li      $SED -e 4q "$1" 2>/dev/null \
1235*a376eb32SXin Li        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
1236*a376eb32SXin Li}
1237*a376eb32SXin Li
1238*a376eb32SXin Li# func_lalib_unsafe_p file
1239*a376eb32SXin Li# True iff FILE is a libtool `.la' library or `.lo' object file.
1240*a376eb32SXin Li# This function implements the same check as func_lalib_p without
1241*a376eb32SXin Li# resorting to external programs.  To this end, it redirects stdin and
1242*a376eb32SXin Li# closes it afterwards, without saving the original file descriptor.
1243*a376eb32SXin Li# As a safety measure, use it only where a negative result would be
1244*a376eb32SXin Li# fatal anyway.  Works if `file' does not exist.
1245*a376eb32SXin Lifunc_lalib_unsafe_p ()
1246*a376eb32SXin Li{
1247*a376eb32SXin Li    lalib_p=no
1248*a376eb32SXin Li    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
1249*a376eb32SXin Li	for lalib_p_l in 1 2 3 4
1250*a376eb32SXin Li	do
1251*a376eb32SXin Li	    read lalib_p_line
1252*a376eb32SXin Li	    case "$lalib_p_line" in
1253*a376eb32SXin Li		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
1254*a376eb32SXin Li	    esac
1255*a376eb32SXin Li	done
1256*a376eb32SXin Li	exec 0<&5 5<&-
1257*a376eb32SXin Li    fi
1258*a376eb32SXin Li    test "$lalib_p" = yes
1259*a376eb32SXin Li}
1260*a376eb32SXin Li
1261*a376eb32SXin Li# func_ltwrapper_script_p file
1262*a376eb32SXin Li# True iff FILE is a libtool wrapper script
1263*a376eb32SXin Li# This function is only a basic sanity check; it will hardly flush out
1264*a376eb32SXin Li# determined imposters.
1265*a376eb32SXin Lifunc_ltwrapper_script_p ()
1266*a376eb32SXin Li{
1267*a376eb32SXin Li    func_lalib_p "$1"
1268*a376eb32SXin Li}
1269*a376eb32SXin Li
1270*a376eb32SXin Li# func_ltwrapper_executable_p file
1271*a376eb32SXin Li# True iff FILE is a libtool wrapper executable
1272*a376eb32SXin Li# This function is only a basic sanity check; it will hardly flush out
1273*a376eb32SXin Li# determined imposters.
1274*a376eb32SXin Lifunc_ltwrapper_executable_p ()
1275*a376eb32SXin Li{
1276*a376eb32SXin Li    func_ltwrapper_exec_suffix=
1277*a376eb32SXin Li    case $1 in
1278*a376eb32SXin Li    *.exe) ;;
1279*a376eb32SXin Li    *) func_ltwrapper_exec_suffix=.exe ;;
1280*a376eb32SXin Li    esac
1281*a376eb32SXin Li    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
1282*a376eb32SXin Li}
1283*a376eb32SXin Li
1284*a376eb32SXin Li# func_ltwrapper_scriptname file
1285*a376eb32SXin Li# Assumes file is an ltwrapper_executable
1286*a376eb32SXin Li# uses $file to determine the appropriate filename for a
1287*a376eb32SXin Li# temporary ltwrapper_script.
1288*a376eb32SXin Lifunc_ltwrapper_scriptname ()
1289*a376eb32SXin Li{
1290*a376eb32SXin Li    func_dirname_and_basename "$1" "" "."
1291*a376eb32SXin Li    func_stripname '' '.exe' "$func_basename_result"
1292*a376eb32SXin Li    func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
1293*a376eb32SXin Li}
1294*a376eb32SXin Li
1295*a376eb32SXin Li# func_ltwrapper_p file
1296*a376eb32SXin Li# True iff FILE is a libtool wrapper script or wrapper executable
1297*a376eb32SXin Li# This function is only a basic sanity check; it will hardly flush out
1298*a376eb32SXin Li# determined imposters.
1299*a376eb32SXin Lifunc_ltwrapper_p ()
1300*a376eb32SXin Li{
1301*a376eb32SXin Li    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
1302*a376eb32SXin Li}
1303*a376eb32SXin Li
1304*a376eb32SXin Li
1305*a376eb32SXin Li# func_execute_cmds commands fail_cmd
1306*a376eb32SXin Li# Execute tilde-delimited COMMANDS.
1307*a376eb32SXin Li# If FAIL_CMD is given, eval that upon failure.
1308*a376eb32SXin Li# FAIL_CMD may read-access the current command in variable CMD!
1309*a376eb32SXin Lifunc_execute_cmds ()
1310*a376eb32SXin Li{
1311*a376eb32SXin Li    $opt_debug
1312*a376eb32SXin Li    save_ifs=$IFS; IFS='~'
1313*a376eb32SXin Li    for cmd in $1; do
1314*a376eb32SXin Li      IFS=$save_ifs
1315*a376eb32SXin Li      eval cmd=\"$cmd\"
1316*a376eb32SXin Li      func_show_eval "$cmd" "${2-:}"
1317*a376eb32SXin Li    done
1318*a376eb32SXin Li    IFS=$save_ifs
1319*a376eb32SXin Li}
1320*a376eb32SXin Li
1321*a376eb32SXin Li
1322*a376eb32SXin Li# func_source file
1323*a376eb32SXin Li# Source FILE, adding directory component if necessary.
1324*a376eb32SXin Li# Note that it is not necessary on cygwin/mingw to append a dot to
1325*a376eb32SXin Li# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
1326*a376eb32SXin Li# behavior happens only for exec(3), not for open(2)!  Also, sourcing
1327*a376eb32SXin Li# `FILE.' does not work on cygwin managed mounts.
1328*a376eb32SXin Lifunc_source ()
1329*a376eb32SXin Li{
1330*a376eb32SXin Li    $opt_debug
1331*a376eb32SXin Li    case $1 in
1332*a376eb32SXin Li    */* | *\\*)	. "$1" ;;
1333*a376eb32SXin Li    *)		. "./$1" ;;
1334*a376eb32SXin Li    esac
1335*a376eb32SXin Li}
1336*a376eb32SXin Li
1337*a376eb32SXin Li
1338*a376eb32SXin Li# func_resolve_sysroot PATH
1339*a376eb32SXin Li# Replace a leading = in PATH with a sysroot.  Store the result into
1340*a376eb32SXin Li# func_resolve_sysroot_result
1341*a376eb32SXin Lifunc_resolve_sysroot ()
1342*a376eb32SXin Li{
1343*a376eb32SXin Li  func_resolve_sysroot_result=$1
1344*a376eb32SXin Li  case $func_resolve_sysroot_result in
1345*a376eb32SXin Li  =*)
1346*a376eb32SXin Li    func_stripname '=' '' "$func_resolve_sysroot_result"
1347*a376eb32SXin Li    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
1348*a376eb32SXin Li    ;;
1349*a376eb32SXin Li  esac
1350*a376eb32SXin Li}
1351*a376eb32SXin Li
1352*a376eb32SXin Li# func_replace_sysroot PATH
1353*a376eb32SXin Li# If PATH begins with the sysroot, replace it with = and
1354*a376eb32SXin Li# store the result into func_replace_sysroot_result.
1355*a376eb32SXin Lifunc_replace_sysroot ()
1356*a376eb32SXin Li{
1357*a376eb32SXin Li  case "$lt_sysroot:$1" in
1358*a376eb32SXin Li  ?*:"$lt_sysroot"*)
1359*a376eb32SXin Li    func_stripname "$lt_sysroot" '' "$1"
1360*a376eb32SXin Li    func_replace_sysroot_result="=$func_stripname_result"
1361*a376eb32SXin Li    ;;
1362*a376eb32SXin Li  *)
1363*a376eb32SXin Li    # Including no sysroot.
1364*a376eb32SXin Li    func_replace_sysroot_result=$1
1365*a376eb32SXin Li    ;;
1366*a376eb32SXin Li  esac
1367*a376eb32SXin Li}
1368*a376eb32SXin Li
1369*a376eb32SXin Li# func_infer_tag arg
1370*a376eb32SXin Li# Infer tagged configuration to use if any are available and
1371*a376eb32SXin Li# if one wasn't chosen via the "--tag" command line option.
1372*a376eb32SXin Li# Only attempt this if the compiler in the base compile
1373*a376eb32SXin Li# command doesn't match the default compiler.
1374*a376eb32SXin Li# arg is usually of the form 'gcc ...'
1375*a376eb32SXin Lifunc_infer_tag ()
1376*a376eb32SXin Li{
1377*a376eb32SXin Li    $opt_debug
1378*a376eb32SXin Li    if test -n "$available_tags" && test -z "$tagname"; then
1379*a376eb32SXin Li      CC_quoted=
1380*a376eb32SXin Li      for arg in $CC; do
1381*a376eb32SXin Li	func_append_quoted CC_quoted "$arg"
1382*a376eb32SXin Li      done
1383*a376eb32SXin Li      CC_expanded=`func_echo_all $CC`
1384*a376eb32SXin Li      CC_quoted_expanded=`func_echo_all $CC_quoted`
1385*a376eb32SXin Li      case $@ in
1386*a376eb32SXin Li      # Blanks in the command may have been stripped by the calling shell,
1387*a376eb32SXin Li      # but not from the CC environment variable when configure was run.
1388*a376eb32SXin Li      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1389*a376eb32SXin Li      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
1390*a376eb32SXin Li      # Blanks at the start of $base_compile will cause this to fail
1391*a376eb32SXin Li      # if we don't check for them as well.
1392*a376eb32SXin Li      *)
1393*a376eb32SXin Li	for z in $available_tags; do
1394*a376eb32SXin Li	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
1395*a376eb32SXin Li	    # Evaluate the configuration.
1396*a376eb32SXin Li	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
1397*a376eb32SXin Li	    CC_quoted=
1398*a376eb32SXin Li	    for arg in $CC; do
1399*a376eb32SXin Li	      # Double-quote args containing other shell metacharacters.
1400*a376eb32SXin Li	      func_append_quoted CC_quoted "$arg"
1401*a376eb32SXin Li	    done
1402*a376eb32SXin Li	    CC_expanded=`func_echo_all $CC`
1403*a376eb32SXin Li	    CC_quoted_expanded=`func_echo_all $CC_quoted`
1404*a376eb32SXin Li	    case "$@ " in
1405*a376eb32SXin Li	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1406*a376eb32SXin Li	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
1407*a376eb32SXin Li	      # The compiler in the base compile command matches
1408*a376eb32SXin Li	      # the one in the tagged configuration.
1409*a376eb32SXin Li	      # Assume this is the tagged configuration we want.
1410*a376eb32SXin Li	      tagname=$z
1411*a376eb32SXin Li	      break
1412*a376eb32SXin Li	      ;;
1413*a376eb32SXin Li	    esac
1414*a376eb32SXin Li	  fi
1415*a376eb32SXin Li	done
1416*a376eb32SXin Li	# If $tagname still isn't set, then no tagged configuration
1417*a376eb32SXin Li	# was found and let the user know that the "--tag" command
1418*a376eb32SXin Li	# line option must be used.
1419*a376eb32SXin Li	if test -z "$tagname"; then
1420*a376eb32SXin Li	  func_echo "unable to infer tagged configuration"
1421*a376eb32SXin Li	  func_fatal_error "specify a tag with \`--tag'"
1422*a376eb32SXin Li#	else
1423*a376eb32SXin Li#	  func_verbose "using $tagname tagged configuration"
1424*a376eb32SXin Li	fi
1425*a376eb32SXin Li	;;
1426*a376eb32SXin Li      esac
1427*a376eb32SXin Li    fi
1428*a376eb32SXin Li}
1429*a376eb32SXin Li
1430*a376eb32SXin Li
1431*a376eb32SXin Li
1432*a376eb32SXin Li# func_write_libtool_object output_name pic_name nonpic_name
1433*a376eb32SXin Li# Create a libtool object file (analogous to a ".la" file),
1434*a376eb32SXin Li# but don't create it if we're doing a dry run.
1435*a376eb32SXin Lifunc_write_libtool_object ()
1436*a376eb32SXin Li{
1437*a376eb32SXin Li    write_libobj=${1}
1438*a376eb32SXin Li    if test "$build_libtool_libs" = yes; then
1439*a376eb32SXin Li      write_lobj=\'${2}\'
1440*a376eb32SXin Li    else
1441*a376eb32SXin Li      write_lobj=none
1442*a376eb32SXin Li    fi
1443*a376eb32SXin Li
1444*a376eb32SXin Li    if test "$build_old_libs" = yes; then
1445*a376eb32SXin Li      write_oldobj=\'${3}\'
1446*a376eb32SXin Li    else
1447*a376eb32SXin Li      write_oldobj=none
1448*a376eb32SXin Li    fi
1449*a376eb32SXin Li
1450*a376eb32SXin Li    $opt_dry_run || {
1451*a376eb32SXin Li      cat >${write_libobj}T <<EOF
1452*a376eb32SXin Li# $write_libobj - a libtool object file
1453*a376eb32SXin Li# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1454*a376eb32SXin Li#
1455*a376eb32SXin Li# Please DO NOT delete this file!
1456*a376eb32SXin Li# It is necessary for linking the library.
1457*a376eb32SXin Li
1458*a376eb32SXin Li# Name of the PIC object.
1459*a376eb32SXin Lipic_object=$write_lobj
1460*a376eb32SXin Li
1461*a376eb32SXin Li# Name of the non-PIC object
1462*a376eb32SXin Linon_pic_object=$write_oldobj
1463*a376eb32SXin Li
1464*a376eb32SXin LiEOF
1465*a376eb32SXin Li      $MV "${write_libobj}T" "${write_libobj}"
1466*a376eb32SXin Li    }
1467*a376eb32SXin Li}
1468*a376eb32SXin Li
1469*a376eb32SXin Li
1470*a376eb32SXin Li##################################################
1471*a376eb32SXin Li# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
1472*a376eb32SXin Li##################################################
1473*a376eb32SXin Li
1474*a376eb32SXin Li# func_convert_core_file_wine_to_w32 ARG
1475*a376eb32SXin Li# Helper function used by file name conversion functions when $build is *nix,
1476*a376eb32SXin Li# and $host is mingw, cygwin, or some other w32 environment. Relies on a
1477*a376eb32SXin Li# correctly configured wine environment available, with the winepath program
1478*a376eb32SXin Li# in $build's $PATH.
1479*a376eb32SXin Li#
1480*a376eb32SXin Li# ARG is the $build file name to be converted to w32 format.
1481*a376eb32SXin Li# Result is available in $func_convert_core_file_wine_to_w32_result, and will
1482*a376eb32SXin Li# be empty on error (or when ARG is empty)
1483*a376eb32SXin Lifunc_convert_core_file_wine_to_w32 ()
1484*a376eb32SXin Li{
1485*a376eb32SXin Li  $opt_debug
1486*a376eb32SXin Li  func_convert_core_file_wine_to_w32_result="$1"
1487*a376eb32SXin Li  if test -n "$1"; then
1488*a376eb32SXin Li    # Unfortunately, winepath does not exit with a non-zero error code, so we
1489*a376eb32SXin Li    # are forced to check the contents of stdout. On the other hand, if the
1490*a376eb32SXin Li    # command is not found, the shell will set an exit code of 127 and print
1491*a376eb32SXin Li    # *an error message* to stdout. So we must check for both error code of
1492*a376eb32SXin Li    # zero AND non-empty stdout, which explains the odd construction:
1493*a376eb32SXin Li    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
1494*a376eb32SXin Li    if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
1495*a376eb32SXin Li      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
1496*a376eb32SXin Li        $SED -e "$lt_sed_naive_backslashify"`
1497*a376eb32SXin Li    else
1498*a376eb32SXin Li      func_convert_core_file_wine_to_w32_result=
1499*a376eb32SXin Li    fi
1500*a376eb32SXin Li  fi
1501*a376eb32SXin Li}
1502*a376eb32SXin Li# end: func_convert_core_file_wine_to_w32
1503*a376eb32SXin Li
1504*a376eb32SXin Li
1505*a376eb32SXin Li# func_convert_core_path_wine_to_w32 ARG
1506*a376eb32SXin Li# Helper function used by path conversion functions when $build is *nix, and
1507*a376eb32SXin Li# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
1508*a376eb32SXin Li# configured wine environment available, with the winepath program in $build's
1509*a376eb32SXin Li# $PATH. Assumes ARG has no leading or trailing path separator characters.
1510*a376eb32SXin Li#
1511*a376eb32SXin Li# ARG is path to be converted from $build format to win32.
1512*a376eb32SXin Li# Result is available in $func_convert_core_path_wine_to_w32_result.
1513*a376eb32SXin Li# Unconvertible file (directory) names in ARG are skipped; if no directory names
1514*a376eb32SXin Li# are convertible, then the result may be empty.
1515*a376eb32SXin Lifunc_convert_core_path_wine_to_w32 ()
1516*a376eb32SXin Li{
1517*a376eb32SXin Li  $opt_debug
1518*a376eb32SXin Li  # unfortunately, winepath doesn't convert paths, only file names
1519*a376eb32SXin Li  func_convert_core_path_wine_to_w32_result=""
1520*a376eb32SXin Li  if test -n "$1"; then
1521*a376eb32SXin Li    oldIFS=$IFS
1522*a376eb32SXin Li    IFS=:
1523*a376eb32SXin Li    for func_convert_core_path_wine_to_w32_f in $1; do
1524*a376eb32SXin Li      IFS=$oldIFS
1525*a376eb32SXin Li      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
1526*a376eb32SXin Li      if test -n "$func_convert_core_file_wine_to_w32_result" ; then
1527*a376eb32SXin Li        if test -z "$func_convert_core_path_wine_to_w32_result"; then
1528*a376eb32SXin Li          func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
1529*a376eb32SXin Li        else
1530*a376eb32SXin Li          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
1531*a376eb32SXin Li        fi
1532*a376eb32SXin Li      fi
1533*a376eb32SXin Li    done
1534*a376eb32SXin Li    IFS=$oldIFS
1535*a376eb32SXin Li  fi
1536*a376eb32SXin Li}
1537*a376eb32SXin Li# end: func_convert_core_path_wine_to_w32
1538*a376eb32SXin Li
1539*a376eb32SXin Li
1540*a376eb32SXin Li# func_cygpath ARGS...
1541*a376eb32SXin Li# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
1542*a376eb32SXin Li# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
1543*a376eb32SXin Li# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
1544*a376eb32SXin Li# (2), returns the Cygwin file name or path in func_cygpath_result (input
1545*a376eb32SXin Li# file name or path is assumed to be in w32 format, as previously converted
1546*a376eb32SXin Li# from $build's *nix or MSYS format). In case (3), returns the w32 file name
1547*a376eb32SXin Li# or path in func_cygpath_result (input file name or path is assumed to be in
1548*a376eb32SXin Li# Cygwin format). Returns an empty string on error.
1549*a376eb32SXin Li#
1550*a376eb32SXin Li# ARGS are passed to cygpath, with the last one being the file name or path to
1551*a376eb32SXin Li# be converted.
1552*a376eb32SXin Li#
1553*a376eb32SXin Li# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
1554*a376eb32SXin Li# environment variable; do not put it in $PATH.
1555*a376eb32SXin Lifunc_cygpath ()
1556*a376eb32SXin Li{
1557*a376eb32SXin Li  $opt_debug
1558*a376eb32SXin Li  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
1559*a376eb32SXin Li    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
1560*a376eb32SXin Li    if test "$?" -ne 0; then
1561*a376eb32SXin Li      # on failure, ensure result is empty
1562*a376eb32SXin Li      func_cygpath_result=
1563*a376eb32SXin Li    fi
1564*a376eb32SXin Li  else
1565*a376eb32SXin Li    func_cygpath_result=
1566*a376eb32SXin Li    func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
1567*a376eb32SXin Li  fi
1568*a376eb32SXin Li}
1569*a376eb32SXin Li#end: func_cygpath
1570*a376eb32SXin Li
1571*a376eb32SXin Li
1572*a376eb32SXin Li# func_convert_core_msys_to_w32 ARG
1573*a376eb32SXin Li# Convert file name or path ARG from MSYS format to w32 format.  Return
1574*a376eb32SXin Li# result in func_convert_core_msys_to_w32_result.
1575*a376eb32SXin Lifunc_convert_core_msys_to_w32 ()
1576*a376eb32SXin Li{
1577*a376eb32SXin Li  $opt_debug
1578*a376eb32SXin Li  # awkward: cmd appends spaces to result
1579*a376eb32SXin Li  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
1580*a376eb32SXin Li    $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
1581*a376eb32SXin Li}
1582*a376eb32SXin Li#end: func_convert_core_msys_to_w32
1583*a376eb32SXin Li
1584*a376eb32SXin Li
1585*a376eb32SXin Li# func_convert_file_check ARG1 ARG2
1586*a376eb32SXin Li# Verify that ARG1 (a file name in $build format) was converted to $host
1587*a376eb32SXin Li# format in ARG2. Otherwise, emit an error message, but continue (resetting
1588*a376eb32SXin Li# func_to_host_file_result to ARG1).
1589*a376eb32SXin Lifunc_convert_file_check ()
1590*a376eb32SXin Li{
1591*a376eb32SXin Li  $opt_debug
1592*a376eb32SXin Li  if test -z "$2" && test -n "$1" ; then
1593*a376eb32SXin Li    func_error "Could not determine host file name corresponding to"
1594*a376eb32SXin Li    func_error "  \`$1'"
1595*a376eb32SXin Li    func_error "Continuing, but uninstalled executables may not work."
1596*a376eb32SXin Li    # Fallback:
1597*a376eb32SXin Li    func_to_host_file_result="$1"
1598*a376eb32SXin Li  fi
1599*a376eb32SXin Li}
1600*a376eb32SXin Li# end func_convert_file_check
1601*a376eb32SXin Li
1602*a376eb32SXin Li
1603*a376eb32SXin Li# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
1604*a376eb32SXin Li# Verify that FROM_PATH (a path in $build format) was converted to $host
1605*a376eb32SXin Li# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
1606*a376eb32SXin Li# func_to_host_file_result to a simplistic fallback value (see below).
1607*a376eb32SXin Lifunc_convert_path_check ()
1608*a376eb32SXin Li{
1609*a376eb32SXin Li  $opt_debug
1610*a376eb32SXin Li  if test -z "$4" && test -n "$3"; then
1611*a376eb32SXin Li    func_error "Could not determine the host path corresponding to"
1612*a376eb32SXin Li    func_error "  \`$3'"
1613*a376eb32SXin Li    func_error "Continuing, but uninstalled executables may not work."
1614*a376eb32SXin Li    # Fallback.  This is a deliberately simplistic "conversion" and
1615*a376eb32SXin Li    # should not be "improved".  See libtool.info.
1616*a376eb32SXin Li    if test "x$1" != "x$2"; then
1617*a376eb32SXin Li      lt_replace_pathsep_chars="s|$1|$2|g"
1618*a376eb32SXin Li      func_to_host_path_result=`echo "$3" |
1619*a376eb32SXin Li        $SED -e "$lt_replace_pathsep_chars"`
1620*a376eb32SXin Li    else
1621*a376eb32SXin Li      func_to_host_path_result="$3"
1622*a376eb32SXin Li    fi
1623*a376eb32SXin Li  fi
1624*a376eb32SXin Li}
1625*a376eb32SXin Li# end func_convert_path_check
1626*a376eb32SXin Li
1627*a376eb32SXin Li
1628*a376eb32SXin Li# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
1629*a376eb32SXin Li# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
1630*a376eb32SXin Li# and appending REPL if ORIG matches BACKPAT.
1631*a376eb32SXin Lifunc_convert_path_front_back_pathsep ()
1632*a376eb32SXin Li{
1633*a376eb32SXin Li  $opt_debug
1634*a376eb32SXin Li  case $4 in
1635*a376eb32SXin Li  $1 ) func_to_host_path_result="$3$func_to_host_path_result"
1636*a376eb32SXin Li    ;;
1637*a376eb32SXin Li  esac
1638*a376eb32SXin Li  case $4 in
1639*a376eb32SXin Li  $2 ) func_append func_to_host_path_result "$3"
1640*a376eb32SXin Li    ;;
1641*a376eb32SXin Li  esac
1642*a376eb32SXin Li}
1643*a376eb32SXin Li# end func_convert_path_front_back_pathsep
1644*a376eb32SXin Li
1645*a376eb32SXin Li
1646*a376eb32SXin Li##################################################
1647*a376eb32SXin Li# $build to $host FILE NAME CONVERSION FUNCTIONS #
1648*a376eb32SXin Li##################################################
1649*a376eb32SXin Li# invoked via `$to_host_file_cmd ARG'
1650*a376eb32SXin Li#
1651*a376eb32SXin Li# In each case, ARG is the path to be converted from $build to $host format.
1652*a376eb32SXin Li# Result will be available in $func_to_host_file_result.
1653*a376eb32SXin Li
1654*a376eb32SXin Li
1655*a376eb32SXin Li# func_to_host_file ARG
1656*a376eb32SXin Li# Converts the file name ARG from $build format to $host format. Return result
1657*a376eb32SXin Li# in func_to_host_file_result.
1658*a376eb32SXin Lifunc_to_host_file ()
1659*a376eb32SXin Li{
1660*a376eb32SXin Li  $opt_debug
1661*a376eb32SXin Li  $to_host_file_cmd "$1"
1662*a376eb32SXin Li}
1663*a376eb32SXin Li# end func_to_host_file
1664*a376eb32SXin Li
1665*a376eb32SXin Li
1666*a376eb32SXin Li# func_to_tool_file ARG LAZY
1667*a376eb32SXin Li# converts the file name ARG from $build format to toolchain format. Return
1668*a376eb32SXin Li# result in func_to_tool_file_result.  If the conversion in use is listed
1669*a376eb32SXin Li# in (the comma separated) LAZY, no conversion takes place.
1670*a376eb32SXin Lifunc_to_tool_file ()
1671*a376eb32SXin Li{
1672*a376eb32SXin Li  $opt_debug
1673*a376eb32SXin Li  case ,$2, in
1674*a376eb32SXin Li    *,"$to_tool_file_cmd",*)
1675*a376eb32SXin Li      func_to_tool_file_result=$1
1676*a376eb32SXin Li      ;;
1677*a376eb32SXin Li    *)
1678*a376eb32SXin Li      $to_tool_file_cmd "$1"
1679*a376eb32SXin Li      func_to_tool_file_result=$func_to_host_file_result
1680*a376eb32SXin Li      ;;
1681*a376eb32SXin Li  esac
1682*a376eb32SXin Li}
1683*a376eb32SXin Li# end func_to_tool_file
1684*a376eb32SXin Li
1685*a376eb32SXin Li
1686*a376eb32SXin Li# func_convert_file_noop ARG
1687*a376eb32SXin Li# Copy ARG to func_to_host_file_result.
1688*a376eb32SXin Lifunc_convert_file_noop ()
1689*a376eb32SXin Li{
1690*a376eb32SXin Li  func_to_host_file_result="$1"
1691*a376eb32SXin Li}
1692*a376eb32SXin Li# end func_convert_file_noop
1693*a376eb32SXin Li
1694*a376eb32SXin Li
1695*a376eb32SXin Li# func_convert_file_msys_to_w32 ARG
1696*a376eb32SXin Li# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
1697*a376eb32SXin Li# conversion to w32 is not available inside the cwrapper.  Returns result in
1698*a376eb32SXin Li# func_to_host_file_result.
1699*a376eb32SXin Lifunc_convert_file_msys_to_w32 ()
1700*a376eb32SXin Li{
1701*a376eb32SXin Li  $opt_debug
1702*a376eb32SXin Li  func_to_host_file_result="$1"
1703*a376eb32SXin Li  if test -n "$1"; then
1704*a376eb32SXin Li    func_convert_core_msys_to_w32 "$1"
1705*a376eb32SXin Li    func_to_host_file_result="$func_convert_core_msys_to_w32_result"
1706*a376eb32SXin Li  fi
1707*a376eb32SXin Li  func_convert_file_check "$1" "$func_to_host_file_result"
1708*a376eb32SXin Li}
1709*a376eb32SXin Li# end func_convert_file_msys_to_w32
1710*a376eb32SXin Li
1711*a376eb32SXin Li
1712*a376eb32SXin Li# func_convert_file_cygwin_to_w32 ARG
1713*a376eb32SXin Li# Convert file name ARG from Cygwin to w32 format.  Returns result in
1714*a376eb32SXin Li# func_to_host_file_result.
1715*a376eb32SXin Lifunc_convert_file_cygwin_to_w32 ()
1716*a376eb32SXin Li{
1717*a376eb32SXin Li  $opt_debug
1718*a376eb32SXin Li  func_to_host_file_result="$1"
1719*a376eb32SXin Li  if test -n "$1"; then
1720*a376eb32SXin Li    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
1721*a376eb32SXin Li    # LT_CYGPATH in this case.
1722*a376eb32SXin Li    func_to_host_file_result=`cygpath -m "$1"`
1723*a376eb32SXin Li  fi
1724*a376eb32SXin Li  func_convert_file_check "$1" "$func_to_host_file_result"
1725*a376eb32SXin Li}
1726*a376eb32SXin Li# end func_convert_file_cygwin_to_w32
1727*a376eb32SXin Li
1728*a376eb32SXin Li
1729*a376eb32SXin Li# func_convert_file_nix_to_w32 ARG
1730*a376eb32SXin Li# Convert file name ARG from *nix to w32 format.  Requires a wine environment
1731*a376eb32SXin Li# and a working winepath. Returns result in func_to_host_file_result.
1732*a376eb32SXin Lifunc_convert_file_nix_to_w32 ()
1733*a376eb32SXin Li{
1734*a376eb32SXin Li  $opt_debug
1735*a376eb32SXin Li  func_to_host_file_result="$1"
1736*a376eb32SXin Li  if test -n "$1"; then
1737*a376eb32SXin Li    func_convert_core_file_wine_to_w32 "$1"
1738*a376eb32SXin Li    func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
1739*a376eb32SXin Li  fi
1740*a376eb32SXin Li  func_convert_file_check "$1" "$func_to_host_file_result"
1741*a376eb32SXin Li}
1742*a376eb32SXin Li# end func_convert_file_nix_to_w32
1743*a376eb32SXin Li
1744*a376eb32SXin Li
1745*a376eb32SXin Li# func_convert_file_msys_to_cygwin ARG
1746*a376eb32SXin Li# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
1747*a376eb32SXin Li# Returns result in func_to_host_file_result.
1748*a376eb32SXin Lifunc_convert_file_msys_to_cygwin ()
1749*a376eb32SXin Li{
1750*a376eb32SXin Li  $opt_debug
1751*a376eb32SXin Li  func_to_host_file_result="$1"
1752*a376eb32SXin Li  if test -n "$1"; then
1753*a376eb32SXin Li    func_convert_core_msys_to_w32 "$1"
1754*a376eb32SXin Li    func_cygpath -u "$func_convert_core_msys_to_w32_result"
1755*a376eb32SXin Li    func_to_host_file_result="$func_cygpath_result"
1756*a376eb32SXin Li  fi
1757*a376eb32SXin Li  func_convert_file_check "$1" "$func_to_host_file_result"
1758*a376eb32SXin Li}
1759*a376eb32SXin Li# end func_convert_file_msys_to_cygwin
1760*a376eb32SXin Li
1761*a376eb32SXin Li
1762*a376eb32SXin Li# func_convert_file_nix_to_cygwin ARG
1763*a376eb32SXin Li# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
1764*a376eb32SXin Li# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
1765*a376eb32SXin Li# in func_to_host_file_result.
1766*a376eb32SXin Lifunc_convert_file_nix_to_cygwin ()
1767*a376eb32SXin Li{
1768*a376eb32SXin Li  $opt_debug
1769*a376eb32SXin Li  func_to_host_file_result="$1"
1770*a376eb32SXin Li  if test -n "$1"; then
1771*a376eb32SXin Li    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
1772*a376eb32SXin Li    func_convert_core_file_wine_to_w32 "$1"
1773*a376eb32SXin Li    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
1774*a376eb32SXin Li    func_to_host_file_result="$func_cygpath_result"
1775*a376eb32SXin Li  fi
1776*a376eb32SXin Li  func_convert_file_check "$1" "$func_to_host_file_result"
1777*a376eb32SXin Li}
1778*a376eb32SXin Li# end func_convert_file_nix_to_cygwin
1779*a376eb32SXin Li
1780*a376eb32SXin Li
1781*a376eb32SXin Li#############################################
1782*a376eb32SXin Li# $build to $host PATH CONVERSION FUNCTIONS #
1783*a376eb32SXin Li#############################################
1784*a376eb32SXin Li# invoked via `$to_host_path_cmd ARG'
1785*a376eb32SXin Li#
1786*a376eb32SXin Li# In each case, ARG is the path to be converted from $build to $host format.
1787*a376eb32SXin Li# The result will be available in $func_to_host_path_result.
1788*a376eb32SXin Li#
1789*a376eb32SXin Li# Path separators are also converted from $build format to $host format.  If
1790*a376eb32SXin Li# ARG begins or ends with a path separator character, it is preserved (but
1791*a376eb32SXin Li# converted to $host format) on output.
1792*a376eb32SXin Li#
1793*a376eb32SXin Li# All path conversion functions are named using the following convention:
1794*a376eb32SXin Li#   file name conversion function    : func_convert_file_X_to_Y ()
1795*a376eb32SXin Li#   path conversion function         : func_convert_path_X_to_Y ()
1796*a376eb32SXin Li# where, for any given $build/$host combination the 'X_to_Y' value is the
1797*a376eb32SXin Li# same.  If conversion functions are added for new $build/$host combinations,
1798*a376eb32SXin Li# the two new functions must follow this pattern, or func_init_to_host_path_cmd
1799*a376eb32SXin Li# will break.
1800*a376eb32SXin Li
1801*a376eb32SXin Li
1802*a376eb32SXin Li# func_init_to_host_path_cmd
1803*a376eb32SXin Li# Ensures that function "pointer" variable $to_host_path_cmd is set to the
1804*a376eb32SXin Li# appropriate value, based on the value of $to_host_file_cmd.
1805*a376eb32SXin Lito_host_path_cmd=
1806*a376eb32SXin Lifunc_init_to_host_path_cmd ()
1807*a376eb32SXin Li{
1808*a376eb32SXin Li  $opt_debug
1809*a376eb32SXin Li  if test -z "$to_host_path_cmd"; then
1810*a376eb32SXin Li    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
1811*a376eb32SXin Li    to_host_path_cmd="func_convert_path_${func_stripname_result}"
1812*a376eb32SXin Li  fi
1813*a376eb32SXin Li}
1814*a376eb32SXin Li
1815*a376eb32SXin Li
1816*a376eb32SXin Li# func_to_host_path ARG
1817*a376eb32SXin Li# Converts the path ARG from $build format to $host format. Return result
1818*a376eb32SXin Li# in func_to_host_path_result.
1819*a376eb32SXin Lifunc_to_host_path ()
1820*a376eb32SXin Li{
1821*a376eb32SXin Li  $opt_debug
1822*a376eb32SXin Li  func_init_to_host_path_cmd
1823*a376eb32SXin Li  $to_host_path_cmd "$1"
1824*a376eb32SXin Li}
1825*a376eb32SXin Li# end func_to_host_path
1826*a376eb32SXin Li
1827*a376eb32SXin Li
1828*a376eb32SXin Li# func_convert_path_noop ARG
1829*a376eb32SXin Li# Copy ARG to func_to_host_path_result.
1830*a376eb32SXin Lifunc_convert_path_noop ()
1831*a376eb32SXin Li{
1832*a376eb32SXin Li  func_to_host_path_result="$1"
1833*a376eb32SXin Li}
1834*a376eb32SXin Li# end func_convert_path_noop
1835*a376eb32SXin Li
1836*a376eb32SXin Li
1837*a376eb32SXin Li# func_convert_path_msys_to_w32 ARG
1838*a376eb32SXin Li# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
1839*a376eb32SXin Li# conversion to w32 is not available inside the cwrapper.  Returns result in
1840*a376eb32SXin Li# func_to_host_path_result.
1841*a376eb32SXin Lifunc_convert_path_msys_to_w32 ()
1842*a376eb32SXin Li{
1843*a376eb32SXin Li  $opt_debug
1844*a376eb32SXin Li  func_to_host_path_result="$1"
1845*a376eb32SXin Li  if test -n "$1"; then
1846*a376eb32SXin Li    # Remove leading and trailing path separator characters from ARG.  MSYS
1847*a376eb32SXin Li    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
1848*a376eb32SXin Li    # and winepath ignores them completely.
1849*a376eb32SXin Li    func_stripname : : "$1"
1850*a376eb32SXin Li    func_to_host_path_tmp1=$func_stripname_result
1851*a376eb32SXin Li    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1852*a376eb32SXin Li    func_to_host_path_result="$func_convert_core_msys_to_w32_result"
1853*a376eb32SXin Li    func_convert_path_check : ";" \
1854*a376eb32SXin Li      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1855*a376eb32SXin Li    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1856*a376eb32SXin Li  fi
1857*a376eb32SXin Li}
1858*a376eb32SXin Li# end func_convert_path_msys_to_w32
1859*a376eb32SXin Li
1860*a376eb32SXin Li
1861*a376eb32SXin Li# func_convert_path_cygwin_to_w32 ARG
1862*a376eb32SXin Li# Convert path ARG from Cygwin to w32 format.  Returns result in
1863*a376eb32SXin Li# func_to_host_file_result.
1864*a376eb32SXin Lifunc_convert_path_cygwin_to_w32 ()
1865*a376eb32SXin Li{
1866*a376eb32SXin Li  $opt_debug
1867*a376eb32SXin Li  func_to_host_path_result="$1"
1868*a376eb32SXin Li  if test -n "$1"; then
1869*a376eb32SXin Li    # See func_convert_path_msys_to_w32:
1870*a376eb32SXin Li    func_stripname : : "$1"
1871*a376eb32SXin Li    func_to_host_path_tmp1=$func_stripname_result
1872*a376eb32SXin Li    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
1873*a376eb32SXin Li    func_convert_path_check : ";" \
1874*a376eb32SXin Li      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1875*a376eb32SXin Li    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1876*a376eb32SXin Li  fi
1877*a376eb32SXin Li}
1878*a376eb32SXin Li# end func_convert_path_cygwin_to_w32
1879*a376eb32SXin Li
1880*a376eb32SXin Li
1881*a376eb32SXin Li# func_convert_path_nix_to_w32 ARG
1882*a376eb32SXin Li# Convert path ARG from *nix to w32 format.  Requires a wine environment and
1883*a376eb32SXin Li# a working winepath.  Returns result in func_to_host_file_result.
1884*a376eb32SXin Lifunc_convert_path_nix_to_w32 ()
1885*a376eb32SXin Li{
1886*a376eb32SXin Li  $opt_debug
1887*a376eb32SXin Li  func_to_host_path_result="$1"
1888*a376eb32SXin Li  if test -n "$1"; then
1889*a376eb32SXin Li    # See func_convert_path_msys_to_w32:
1890*a376eb32SXin Li    func_stripname : : "$1"
1891*a376eb32SXin Li    func_to_host_path_tmp1=$func_stripname_result
1892*a376eb32SXin Li    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1893*a376eb32SXin Li    func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
1894*a376eb32SXin Li    func_convert_path_check : ";" \
1895*a376eb32SXin Li      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1896*a376eb32SXin Li    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1897*a376eb32SXin Li  fi
1898*a376eb32SXin Li}
1899*a376eb32SXin Li# end func_convert_path_nix_to_w32
1900*a376eb32SXin Li
1901*a376eb32SXin Li
1902*a376eb32SXin Li# func_convert_path_msys_to_cygwin ARG
1903*a376eb32SXin Li# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
1904*a376eb32SXin Li# Returns result in func_to_host_file_result.
1905*a376eb32SXin Lifunc_convert_path_msys_to_cygwin ()
1906*a376eb32SXin Li{
1907*a376eb32SXin Li  $opt_debug
1908*a376eb32SXin Li  func_to_host_path_result="$1"
1909*a376eb32SXin Li  if test -n "$1"; then
1910*a376eb32SXin Li    # See func_convert_path_msys_to_w32:
1911*a376eb32SXin Li    func_stripname : : "$1"
1912*a376eb32SXin Li    func_to_host_path_tmp1=$func_stripname_result
1913*a376eb32SXin Li    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1914*a376eb32SXin Li    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
1915*a376eb32SXin Li    func_to_host_path_result="$func_cygpath_result"
1916*a376eb32SXin Li    func_convert_path_check : : \
1917*a376eb32SXin Li      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1918*a376eb32SXin Li    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1919*a376eb32SXin Li  fi
1920*a376eb32SXin Li}
1921*a376eb32SXin Li# end func_convert_path_msys_to_cygwin
1922*a376eb32SXin Li
1923*a376eb32SXin Li
1924*a376eb32SXin Li# func_convert_path_nix_to_cygwin ARG
1925*a376eb32SXin Li# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
1926*a376eb32SXin Li# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
1927*a376eb32SXin Li# func_to_host_file_result.
1928*a376eb32SXin Lifunc_convert_path_nix_to_cygwin ()
1929*a376eb32SXin Li{
1930*a376eb32SXin Li  $opt_debug
1931*a376eb32SXin Li  func_to_host_path_result="$1"
1932*a376eb32SXin Li  if test -n "$1"; then
1933*a376eb32SXin Li    # Remove leading and trailing path separator characters from
1934*a376eb32SXin Li    # ARG. msys behavior is inconsistent here, cygpath turns them
1935*a376eb32SXin Li    # into '.;' and ';.', and winepath ignores them completely.
1936*a376eb32SXin Li    func_stripname : : "$1"
1937*a376eb32SXin Li    func_to_host_path_tmp1=$func_stripname_result
1938*a376eb32SXin Li    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1939*a376eb32SXin Li    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
1940*a376eb32SXin Li    func_to_host_path_result="$func_cygpath_result"
1941*a376eb32SXin Li    func_convert_path_check : : \
1942*a376eb32SXin Li      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1943*a376eb32SXin Li    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1944*a376eb32SXin Li  fi
1945*a376eb32SXin Li}
1946*a376eb32SXin Li# end func_convert_path_nix_to_cygwin
1947*a376eb32SXin Li
1948*a376eb32SXin Li
1949*a376eb32SXin Li# func_mode_compile arg...
1950*a376eb32SXin Lifunc_mode_compile ()
1951*a376eb32SXin Li{
1952*a376eb32SXin Li    $opt_debug
1953*a376eb32SXin Li    # Get the compilation command and the source file.
1954*a376eb32SXin Li    base_compile=
1955*a376eb32SXin Li    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
1956*a376eb32SXin Li    suppress_opt=yes
1957*a376eb32SXin Li    suppress_output=
1958*a376eb32SXin Li    arg_mode=normal
1959*a376eb32SXin Li    libobj=
1960*a376eb32SXin Li    later=
1961*a376eb32SXin Li    pie_flag=
1962*a376eb32SXin Li
1963*a376eb32SXin Li    for arg
1964*a376eb32SXin Li    do
1965*a376eb32SXin Li      case $arg_mode in
1966*a376eb32SXin Li      arg  )
1967*a376eb32SXin Li	# do not "continue".  Instead, add this to base_compile
1968*a376eb32SXin Li	lastarg="$arg"
1969*a376eb32SXin Li	arg_mode=normal
1970*a376eb32SXin Li	;;
1971*a376eb32SXin Li
1972*a376eb32SXin Li      target )
1973*a376eb32SXin Li	libobj="$arg"
1974*a376eb32SXin Li	arg_mode=normal
1975*a376eb32SXin Li	continue
1976*a376eb32SXin Li	;;
1977*a376eb32SXin Li
1978*a376eb32SXin Li      normal )
1979*a376eb32SXin Li	# Accept any command-line options.
1980*a376eb32SXin Li	case $arg in
1981*a376eb32SXin Li	-o)
1982*a376eb32SXin Li	  test -n "$libobj" && \
1983*a376eb32SXin Li	    func_fatal_error "you cannot specify \`-o' more than once"
1984*a376eb32SXin Li	  arg_mode=target
1985*a376eb32SXin Li	  continue
1986*a376eb32SXin Li	  ;;
1987*a376eb32SXin Li
1988*a376eb32SXin Li	-pie | -fpie | -fPIE)
1989*a376eb32SXin Li          func_append pie_flag " $arg"
1990*a376eb32SXin Li	  continue
1991*a376eb32SXin Li	  ;;
1992*a376eb32SXin Li
1993*a376eb32SXin Li	-shared | -static | -prefer-pic | -prefer-non-pic)
1994*a376eb32SXin Li	  func_append later " $arg"
1995*a376eb32SXin Li	  continue
1996*a376eb32SXin Li	  ;;
1997*a376eb32SXin Li
1998*a376eb32SXin Li	-no-suppress)
1999*a376eb32SXin Li	  suppress_opt=no
2000*a376eb32SXin Li	  continue
2001*a376eb32SXin Li	  ;;
2002*a376eb32SXin Li
2003*a376eb32SXin Li	-Xcompiler)
2004*a376eb32SXin Li	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
2005*a376eb32SXin Li	  continue      #  The current "srcfile" will either be retained or
2006*a376eb32SXin Li	  ;;            #  replaced later.  I would guess that would be a bug.
2007*a376eb32SXin Li
2008*a376eb32SXin Li	-Wc,*)
2009*a376eb32SXin Li	  func_stripname '-Wc,' '' "$arg"
2010*a376eb32SXin Li	  args=$func_stripname_result
2011*a376eb32SXin Li	  lastarg=
2012*a376eb32SXin Li	  save_ifs="$IFS"; IFS=','
2013*a376eb32SXin Li	  for arg in $args; do
2014*a376eb32SXin Li	    IFS="$save_ifs"
2015*a376eb32SXin Li	    func_append_quoted lastarg "$arg"
2016*a376eb32SXin Li	  done
2017*a376eb32SXin Li	  IFS="$save_ifs"
2018*a376eb32SXin Li	  func_stripname ' ' '' "$lastarg"
2019*a376eb32SXin Li	  lastarg=$func_stripname_result
2020*a376eb32SXin Li
2021*a376eb32SXin Li	  # Add the arguments to base_compile.
2022*a376eb32SXin Li	  func_append base_compile " $lastarg"
2023*a376eb32SXin Li	  continue
2024*a376eb32SXin Li	  ;;
2025*a376eb32SXin Li
2026*a376eb32SXin Li	*)
2027*a376eb32SXin Li	  # Accept the current argument as the source file.
2028*a376eb32SXin Li	  # The previous "srcfile" becomes the current argument.
2029*a376eb32SXin Li	  #
2030*a376eb32SXin Li	  lastarg="$srcfile"
2031*a376eb32SXin Li	  srcfile="$arg"
2032*a376eb32SXin Li	  ;;
2033*a376eb32SXin Li	esac  #  case $arg
2034*a376eb32SXin Li	;;
2035*a376eb32SXin Li      esac    #  case $arg_mode
2036*a376eb32SXin Li
2037*a376eb32SXin Li      # Aesthetically quote the previous argument.
2038*a376eb32SXin Li      func_append_quoted base_compile "$lastarg"
2039*a376eb32SXin Li    done # for arg
2040*a376eb32SXin Li
2041*a376eb32SXin Li    case $arg_mode in
2042*a376eb32SXin Li    arg)
2043*a376eb32SXin Li      func_fatal_error "you must specify an argument for -Xcompile"
2044*a376eb32SXin Li      ;;
2045*a376eb32SXin Li    target)
2046*a376eb32SXin Li      func_fatal_error "you must specify a target with \`-o'"
2047*a376eb32SXin Li      ;;
2048*a376eb32SXin Li    *)
2049*a376eb32SXin Li      # Get the name of the library object.
2050*a376eb32SXin Li      test -z "$libobj" && {
2051*a376eb32SXin Li	func_basename "$srcfile"
2052*a376eb32SXin Li	libobj="$func_basename_result"
2053*a376eb32SXin Li      }
2054*a376eb32SXin Li      ;;
2055*a376eb32SXin Li    esac
2056*a376eb32SXin Li
2057*a376eb32SXin Li    # Recognize several different file suffixes.
2058*a376eb32SXin Li    # If the user specifies -o file.o, it is replaced with file.lo
2059*a376eb32SXin Li    case $libobj in
2060*a376eb32SXin Li    *.[cCFSifmso] | \
2061*a376eb32SXin Li    *.ada | *.adb | *.ads | *.asm | \
2062*a376eb32SXin Li    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
2063*a376eb32SXin Li    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
2064*a376eb32SXin Li      func_xform "$libobj"
2065*a376eb32SXin Li      libobj=$func_xform_result
2066*a376eb32SXin Li      ;;
2067*a376eb32SXin Li    esac
2068*a376eb32SXin Li
2069*a376eb32SXin Li    case $libobj in
2070*a376eb32SXin Li    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
2071*a376eb32SXin Li    *)
2072*a376eb32SXin Li      func_fatal_error "cannot determine name of library object from \`$libobj'"
2073*a376eb32SXin Li      ;;
2074*a376eb32SXin Li    esac
2075*a376eb32SXin Li
2076*a376eb32SXin Li    func_infer_tag $base_compile
2077*a376eb32SXin Li
2078*a376eb32SXin Li    for arg in $later; do
2079*a376eb32SXin Li      case $arg in
2080*a376eb32SXin Li      -shared)
2081*a376eb32SXin Li	test "$build_libtool_libs" != yes && \
2082*a376eb32SXin Li	  func_fatal_configuration "can not build a shared library"
2083*a376eb32SXin Li	build_old_libs=no
2084*a376eb32SXin Li	continue
2085*a376eb32SXin Li	;;
2086*a376eb32SXin Li
2087*a376eb32SXin Li      -static)
2088*a376eb32SXin Li	build_libtool_libs=no
2089*a376eb32SXin Li	build_old_libs=yes
2090*a376eb32SXin Li	continue
2091*a376eb32SXin Li	;;
2092*a376eb32SXin Li
2093*a376eb32SXin Li      -prefer-pic)
2094*a376eb32SXin Li	pic_mode=yes
2095*a376eb32SXin Li	continue
2096*a376eb32SXin Li	;;
2097*a376eb32SXin Li
2098*a376eb32SXin Li      -prefer-non-pic)
2099*a376eb32SXin Li	pic_mode=no
2100*a376eb32SXin Li	continue
2101*a376eb32SXin Li	;;
2102*a376eb32SXin Li      esac
2103*a376eb32SXin Li    done
2104*a376eb32SXin Li
2105*a376eb32SXin Li    func_quote_for_eval "$libobj"
2106*a376eb32SXin Li    test "X$libobj" != "X$func_quote_for_eval_result" \
2107*a376eb32SXin Li      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
2108*a376eb32SXin Li      && func_warning "libobj name \`$libobj' may not contain shell special characters."
2109*a376eb32SXin Li    func_dirname_and_basename "$obj" "/" ""
2110*a376eb32SXin Li    objname="$func_basename_result"
2111*a376eb32SXin Li    xdir="$func_dirname_result"
2112*a376eb32SXin Li    lobj=${xdir}$objdir/$objname
2113*a376eb32SXin Li
2114*a376eb32SXin Li    test -z "$base_compile" && \
2115*a376eb32SXin Li      func_fatal_help "you must specify a compilation command"
2116*a376eb32SXin Li
2117*a376eb32SXin Li    # Delete any leftover library objects.
2118*a376eb32SXin Li    if test "$build_old_libs" = yes; then
2119*a376eb32SXin Li      removelist="$obj $lobj $libobj ${libobj}T"
2120*a376eb32SXin Li    else
2121*a376eb32SXin Li      removelist="$lobj $libobj ${libobj}T"
2122*a376eb32SXin Li    fi
2123*a376eb32SXin Li
2124*a376eb32SXin Li    # On Cygwin there's no "real" PIC flag so we must build both object types
2125*a376eb32SXin Li    case $host_os in
2126*a376eb32SXin Li    cygwin* | mingw* | pw32* | os2* | cegcc*)
2127*a376eb32SXin Li      pic_mode=default
2128*a376eb32SXin Li      ;;
2129*a376eb32SXin Li    esac
2130*a376eb32SXin Li    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
2131*a376eb32SXin Li      # non-PIC code in shared libraries is not supported
2132*a376eb32SXin Li      pic_mode=default
2133*a376eb32SXin Li    fi
2134*a376eb32SXin Li
2135*a376eb32SXin Li    # Calculate the filename of the output object if compiler does
2136*a376eb32SXin Li    # not support -o with -c
2137*a376eb32SXin Li    if test "$compiler_c_o" = no; then
2138*a376eb32SXin Li      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
2139*a376eb32SXin Li      lockfile="$output_obj.lock"
2140*a376eb32SXin Li    else
2141*a376eb32SXin Li      output_obj=
2142*a376eb32SXin Li      need_locks=no
2143*a376eb32SXin Li      lockfile=
2144*a376eb32SXin Li    fi
2145*a376eb32SXin Li
2146*a376eb32SXin Li    # Lock this critical section if it is needed
2147*a376eb32SXin Li    # We use this script file to make the link, it avoids creating a new file
2148*a376eb32SXin Li    if test "$need_locks" = yes; then
2149*a376eb32SXin Li      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
2150*a376eb32SXin Li	func_echo "Waiting for $lockfile to be removed"
2151*a376eb32SXin Li	sleep 2
2152*a376eb32SXin Li      done
2153*a376eb32SXin Li    elif test "$need_locks" = warn; then
2154*a376eb32SXin Li      if test -f "$lockfile"; then
2155*a376eb32SXin Li	$ECHO "\
2156*a376eb32SXin Li*** ERROR, $lockfile exists and contains:
2157*a376eb32SXin Li`cat $lockfile 2>/dev/null`
2158*a376eb32SXin Li
2159*a376eb32SXin LiThis indicates that another process is trying to use the same
2160*a376eb32SXin Litemporary object file, and libtool could not work around it because
2161*a376eb32SXin Liyour compiler does not support \`-c' and \`-o' together.  If you
2162*a376eb32SXin Lirepeat this compilation, it may succeed, by chance, but you had better
2163*a376eb32SXin Liavoid parallel builds (make -j) in this platform, or get a better
2164*a376eb32SXin Licompiler."
2165*a376eb32SXin Li
2166*a376eb32SXin Li	$opt_dry_run || $RM $removelist
2167*a376eb32SXin Li	exit $EXIT_FAILURE
2168*a376eb32SXin Li      fi
2169*a376eb32SXin Li      func_append removelist " $output_obj"
2170*a376eb32SXin Li      $ECHO "$srcfile" > "$lockfile"
2171*a376eb32SXin Li    fi
2172*a376eb32SXin Li
2173*a376eb32SXin Li    $opt_dry_run || $RM $removelist
2174*a376eb32SXin Li    func_append removelist " $lockfile"
2175*a376eb32SXin Li    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
2176*a376eb32SXin Li
2177*a376eb32SXin Li    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
2178*a376eb32SXin Li    srcfile=$func_to_tool_file_result
2179*a376eb32SXin Li    func_quote_for_eval "$srcfile"
2180*a376eb32SXin Li    qsrcfile=$func_quote_for_eval_result
2181*a376eb32SXin Li
2182*a376eb32SXin Li    # Only build a PIC object if we are building libtool libraries.
2183*a376eb32SXin Li    if test "$build_libtool_libs" = yes; then
2184*a376eb32SXin Li      # Without this assignment, base_compile gets emptied.
2185*a376eb32SXin Li      fbsd_hideous_sh_bug=$base_compile
2186*a376eb32SXin Li
2187*a376eb32SXin Li      if test "$pic_mode" != no; then
2188*a376eb32SXin Li	command="$base_compile $qsrcfile $pic_flag"
2189*a376eb32SXin Li      else
2190*a376eb32SXin Li	# Don't build PIC code
2191*a376eb32SXin Li	command="$base_compile $qsrcfile"
2192*a376eb32SXin Li      fi
2193*a376eb32SXin Li
2194*a376eb32SXin Li      func_mkdir_p "$xdir$objdir"
2195*a376eb32SXin Li
2196*a376eb32SXin Li      if test -z "$output_obj"; then
2197*a376eb32SXin Li	# Place PIC objects in $objdir
2198*a376eb32SXin Li	func_append command " -o $lobj"
2199*a376eb32SXin Li      fi
2200*a376eb32SXin Li
2201*a376eb32SXin Li      func_show_eval_locale "$command"	\
2202*a376eb32SXin Li          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
2203*a376eb32SXin Li
2204*a376eb32SXin Li      if test "$need_locks" = warn &&
2205*a376eb32SXin Li	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2206*a376eb32SXin Li	$ECHO "\
2207*a376eb32SXin Li*** ERROR, $lockfile contains:
2208*a376eb32SXin Li`cat $lockfile 2>/dev/null`
2209*a376eb32SXin Li
2210*a376eb32SXin Libut it should contain:
2211*a376eb32SXin Li$srcfile
2212*a376eb32SXin Li
2213*a376eb32SXin LiThis indicates that another process is trying to use the same
2214*a376eb32SXin Litemporary object file, and libtool could not work around it because
2215*a376eb32SXin Liyour compiler does not support \`-c' and \`-o' together.  If you
2216*a376eb32SXin Lirepeat this compilation, it may succeed, by chance, but you had better
2217*a376eb32SXin Liavoid parallel builds (make -j) in this platform, or get a better
2218*a376eb32SXin Licompiler."
2219*a376eb32SXin Li
2220*a376eb32SXin Li	$opt_dry_run || $RM $removelist
2221*a376eb32SXin Li	exit $EXIT_FAILURE
2222*a376eb32SXin Li      fi
2223*a376eb32SXin Li
2224*a376eb32SXin Li      # Just move the object if needed, then go on to compile the next one
2225*a376eb32SXin Li      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
2226*a376eb32SXin Li	func_show_eval '$MV "$output_obj" "$lobj"' \
2227*a376eb32SXin Li	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
2228*a376eb32SXin Li      fi
2229*a376eb32SXin Li
2230*a376eb32SXin Li      # Allow error messages only from the first compilation.
2231*a376eb32SXin Li      if test "$suppress_opt" = yes; then
2232*a376eb32SXin Li	suppress_output=' >/dev/null 2>&1'
2233*a376eb32SXin Li      fi
2234*a376eb32SXin Li    fi
2235*a376eb32SXin Li
2236*a376eb32SXin Li    # Only build a position-dependent object if we build old libraries.
2237*a376eb32SXin Li    if test "$build_old_libs" = yes; then
2238*a376eb32SXin Li      if test "$pic_mode" != yes; then
2239*a376eb32SXin Li	# Don't build PIC code
2240*a376eb32SXin Li	command="$base_compile $qsrcfile$pie_flag"
2241*a376eb32SXin Li      else
2242*a376eb32SXin Li	command="$base_compile $qsrcfile $pic_flag"
2243*a376eb32SXin Li      fi
2244*a376eb32SXin Li      if test "$compiler_c_o" = yes; then
2245*a376eb32SXin Li	func_append command " -o $obj"
2246*a376eb32SXin Li      fi
2247*a376eb32SXin Li
2248*a376eb32SXin Li      # Suppress compiler output if we already did a PIC compilation.
2249*a376eb32SXin Li      func_append command "$suppress_output"
2250*a376eb32SXin Li      func_show_eval_locale "$command" \
2251*a376eb32SXin Li        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
2252*a376eb32SXin Li
2253*a376eb32SXin Li      if test "$need_locks" = warn &&
2254*a376eb32SXin Li	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2255*a376eb32SXin Li	$ECHO "\
2256*a376eb32SXin Li*** ERROR, $lockfile contains:
2257*a376eb32SXin Li`cat $lockfile 2>/dev/null`
2258*a376eb32SXin Li
2259*a376eb32SXin Libut it should contain:
2260*a376eb32SXin Li$srcfile
2261*a376eb32SXin Li
2262*a376eb32SXin LiThis indicates that another process is trying to use the same
2263*a376eb32SXin Litemporary object file, and libtool could not work around it because
2264*a376eb32SXin Liyour compiler does not support \`-c' and \`-o' together.  If you
2265*a376eb32SXin Lirepeat this compilation, it may succeed, by chance, but you had better
2266*a376eb32SXin Liavoid parallel builds (make -j) in this platform, or get a better
2267*a376eb32SXin Licompiler."
2268*a376eb32SXin Li
2269*a376eb32SXin Li	$opt_dry_run || $RM $removelist
2270*a376eb32SXin Li	exit $EXIT_FAILURE
2271*a376eb32SXin Li      fi
2272*a376eb32SXin Li
2273*a376eb32SXin Li      # Just move the object if needed
2274*a376eb32SXin Li      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
2275*a376eb32SXin Li	func_show_eval '$MV "$output_obj" "$obj"' \
2276*a376eb32SXin Li	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
2277*a376eb32SXin Li      fi
2278*a376eb32SXin Li    fi
2279*a376eb32SXin Li
2280*a376eb32SXin Li    $opt_dry_run || {
2281*a376eb32SXin Li      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
2282*a376eb32SXin Li
2283*a376eb32SXin Li      # Unlock the critical section if it was locked
2284*a376eb32SXin Li      if test "$need_locks" != no; then
2285*a376eb32SXin Li	removelist=$lockfile
2286*a376eb32SXin Li        $RM "$lockfile"
2287*a376eb32SXin Li      fi
2288*a376eb32SXin Li    }
2289*a376eb32SXin Li
2290*a376eb32SXin Li    exit $EXIT_SUCCESS
2291*a376eb32SXin Li}
2292*a376eb32SXin Li
2293*a376eb32SXin Li$opt_help || {
2294*a376eb32SXin Li  test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
2295*a376eb32SXin Li}
2296*a376eb32SXin Li
2297*a376eb32SXin Lifunc_mode_help ()
2298*a376eb32SXin Li{
2299*a376eb32SXin Li    # We need to display help for each of the modes.
2300*a376eb32SXin Li    case $opt_mode in
2301*a376eb32SXin Li      "")
2302*a376eb32SXin Li        # Generic help is extracted from the usage comments
2303*a376eb32SXin Li        # at the start of this file.
2304*a376eb32SXin Li        func_help
2305*a376eb32SXin Li        ;;
2306*a376eb32SXin Li
2307*a376eb32SXin Li      clean)
2308*a376eb32SXin Li        $ECHO \
2309*a376eb32SXin Li"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
2310*a376eb32SXin Li
2311*a376eb32SXin LiRemove files from the build directory.
2312*a376eb32SXin Li
2313*a376eb32SXin LiRM is the name of the program to use to delete files associated with each FILE
2314*a376eb32SXin Li(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
2315*a376eb32SXin Lito RM.
2316*a376eb32SXin Li
2317*a376eb32SXin LiIf FILE is a libtool library, object or program, all the files associated
2318*a376eb32SXin Liwith it are deleted. Otherwise, only FILE itself is deleted using RM."
2319*a376eb32SXin Li        ;;
2320*a376eb32SXin Li
2321*a376eb32SXin Li      compile)
2322*a376eb32SXin Li      $ECHO \
2323*a376eb32SXin Li"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
2324*a376eb32SXin Li
2325*a376eb32SXin LiCompile a source file into a libtool library object.
2326*a376eb32SXin Li
2327*a376eb32SXin LiThis mode accepts the following additional options:
2328*a376eb32SXin Li
2329*a376eb32SXin Li  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
2330*a376eb32SXin Li  -no-suppress      do not suppress compiler output for multiple passes
2331*a376eb32SXin Li  -prefer-pic       try to build PIC objects only
2332*a376eb32SXin Li  -prefer-non-pic   try to build non-PIC objects only
2333*a376eb32SXin Li  -shared           do not build a \`.o' file suitable for static linking
2334*a376eb32SXin Li  -static           only build a \`.o' file suitable for static linking
2335*a376eb32SXin Li  -Wc,FLAG          pass FLAG directly to the compiler
2336*a376eb32SXin Li
2337*a376eb32SXin LiCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
2338*a376eb32SXin Lifrom the given SOURCEFILE.
2339*a376eb32SXin Li
2340*a376eb32SXin LiThe output file name is determined by removing the directory component from
2341*a376eb32SXin LiSOURCEFILE, then substituting the C source code suffix \`.c' with the
2342*a376eb32SXin Lilibrary object suffix, \`.lo'."
2343*a376eb32SXin Li        ;;
2344*a376eb32SXin Li
2345*a376eb32SXin Li      execute)
2346*a376eb32SXin Li        $ECHO \
2347*a376eb32SXin Li"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
2348*a376eb32SXin Li
2349*a376eb32SXin LiAutomatically set library path, then run a program.
2350*a376eb32SXin Li
2351*a376eb32SXin LiThis mode accepts the following additional options:
2352*a376eb32SXin Li
2353*a376eb32SXin Li  -dlopen FILE      add the directory containing FILE to the library path
2354*a376eb32SXin Li
2355*a376eb32SXin LiThis mode sets the library path environment variable according to \`-dlopen'
2356*a376eb32SXin Liflags.
2357*a376eb32SXin Li
2358*a376eb32SXin LiIf any of the ARGS are libtool executable wrappers, then they are translated
2359*a376eb32SXin Liinto their corresponding uninstalled binary, and any of their required library
2360*a376eb32SXin Lidirectories are added to the library path.
2361*a376eb32SXin Li
2362*a376eb32SXin LiThen, COMMAND is executed, with ARGS as arguments."
2363*a376eb32SXin Li        ;;
2364*a376eb32SXin Li
2365*a376eb32SXin Li      finish)
2366*a376eb32SXin Li        $ECHO \
2367*a376eb32SXin Li"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
2368*a376eb32SXin Li
2369*a376eb32SXin LiComplete the installation of libtool libraries.
2370*a376eb32SXin Li
2371*a376eb32SXin LiEach LIBDIR is a directory that contains libtool libraries.
2372*a376eb32SXin Li
2373*a376eb32SXin LiThe commands that this mode executes may require superuser privileges.  Use
2374*a376eb32SXin Lithe \`--dry-run' option if you just want to see what would be executed."
2375*a376eb32SXin Li        ;;
2376*a376eb32SXin Li
2377*a376eb32SXin Li      install)
2378*a376eb32SXin Li        $ECHO \
2379*a376eb32SXin Li"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
2380*a376eb32SXin Li
2381*a376eb32SXin LiInstall executables or libraries.
2382*a376eb32SXin Li
2383*a376eb32SXin LiINSTALL-COMMAND is the installation command.  The first component should be
2384*a376eb32SXin Lieither the \`install' or \`cp' program.
2385*a376eb32SXin Li
2386*a376eb32SXin LiThe following components of INSTALL-COMMAND are treated specially:
2387*a376eb32SXin Li
2388*a376eb32SXin Li  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
2389*a376eb32SXin Li
2390*a376eb32SXin LiThe rest of the components are interpreted as arguments to that command (only
2391*a376eb32SXin LiBSD-compatible install options are recognized)."
2392*a376eb32SXin Li        ;;
2393*a376eb32SXin Li
2394*a376eb32SXin Li      link)
2395*a376eb32SXin Li        $ECHO \
2396*a376eb32SXin Li"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
2397*a376eb32SXin Li
2398*a376eb32SXin LiLink object files or libraries together to form another library, or to
2399*a376eb32SXin Licreate an executable program.
2400*a376eb32SXin Li
2401*a376eb32SXin LiLINK-COMMAND is a command using the C compiler that you would use to create
2402*a376eb32SXin Lia program from several object files.
2403*a376eb32SXin Li
2404*a376eb32SXin LiThe following components of LINK-COMMAND are treated specially:
2405*a376eb32SXin Li
2406*a376eb32SXin Li  -all-static       do not do any dynamic linking at all
2407*a376eb32SXin Li  -avoid-version    do not add a version suffix if possible
2408*a376eb32SXin Li  -bindir BINDIR    specify path to binaries directory (for systems where
2409*a376eb32SXin Li                    libraries must be found in the PATH setting at runtime)
2410*a376eb32SXin Li  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
2411*a376eb32SXin Li  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
2412*a376eb32SXin Li  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
2413*a376eb32SXin Li  -export-symbols SYMFILE
2414*a376eb32SXin Li                    try to export only the symbols listed in SYMFILE
2415*a376eb32SXin Li  -export-symbols-regex REGEX
2416*a376eb32SXin Li                    try to export only the symbols matching REGEX
2417*a376eb32SXin Li  -LLIBDIR          search LIBDIR for required installed libraries
2418*a376eb32SXin Li  -lNAME            OUTPUT-FILE requires the installed library libNAME
2419*a376eb32SXin Li  -module           build a library that can dlopened
2420*a376eb32SXin Li  -no-fast-install  disable the fast-install mode
2421*a376eb32SXin Li  -no-install       link a not-installable executable
2422*a376eb32SXin Li  -no-undefined     declare that a library does not refer to external symbols
2423*a376eb32SXin Li  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
2424*a376eb32SXin Li  -objectlist FILE  Use a list of object files found in FILE to specify objects
2425*a376eb32SXin Li  -precious-files-regex REGEX
2426*a376eb32SXin Li                    don't remove output files matching REGEX
2427*a376eb32SXin Li  -release RELEASE  specify package release information
2428*a376eb32SXin Li  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
2429*a376eb32SXin Li  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
2430*a376eb32SXin Li  -shared           only do dynamic linking of libtool libraries
2431*a376eb32SXin Li  -shrext SUFFIX    override the standard shared library file extension
2432*a376eb32SXin Li  -static           do not do any dynamic linking of uninstalled libtool libraries
2433*a376eb32SXin Li  -static-libtool-libs
2434*a376eb32SXin Li                    do not do any dynamic linking of libtool libraries
2435*a376eb32SXin Li  -version-info CURRENT[:REVISION[:AGE]]
2436*a376eb32SXin Li                    specify library version info [each variable defaults to 0]
2437*a376eb32SXin Li  -weak LIBNAME     declare that the target provides the LIBNAME interface
2438*a376eb32SXin Li  -Wc,FLAG
2439*a376eb32SXin Li  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
2440*a376eb32SXin Li  -Wl,FLAG
2441*a376eb32SXin Li  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
2442*a376eb32SXin Li  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
2443*a376eb32SXin Li
2444*a376eb32SXin LiAll other options (arguments beginning with \`-') are ignored.
2445*a376eb32SXin Li
2446*a376eb32SXin LiEvery other argument is treated as a filename.  Files ending in \`.la' are
2447*a376eb32SXin Litreated as uninstalled libtool libraries, other files are standard or library
2448*a376eb32SXin Liobject files.
2449*a376eb32SXin Li
2450*a376eb32SXin LiIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
2451*a376eb32SXin Lionly library objects (\`.lo' files) may be specified, and \`-rpath' is
2452*a376eb32SXin Lirequired, except when creating a convenience library.
2453*a376eb32SXin Li
2454*a376eb32SXin LiIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
2455*a376eb32SXin Liusing \`ar' and \`ranlib', or on Windows using \`lib'.
2456*a376eb32SXin Li
2457*a376eb32SXin LiIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
2458*a376eb32SXin Liis created, otherwise an executable program is created."
2459*a376eb32SXin Li        ;;
2460*a376eb32SXin Li
2461*a376eb32SXin Li      uninstall)
2462*a376eb32SXin Li        $ECHO \
2463*a376eb32SXin Li"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
2464*a376eb32SXin Li
2465*a376eb32SXin LiRemove libraries from an installation directory.
2466*a376eb32SXin Li
2467*a376eb32SXin LiRM is the name of the program to use to delete files associated with each FILE
2468*a376eb32SXin Li(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
2469*a376eb32SXin Lito RM.
2470*a376eb32SXin Li
2471*a376eb32SXin LiIf FILE is a libtool library, all the files associated with it are deleted.
2472*a376eb32SXin LiOtherwise, only FILE itself is deleted using RM."
2473*a376eb32SXin Li        ;;
2474*a376eb32SXin Li
2475*a376eb32SXin Li      *)
2476*a376eb32SXin Li        func_fatal_help "invalid operation mode \`$opt_mode'"
2477*a376eb32SXin Li        ;;
2478*a376eb32SXin Li    esac
2479*a376eb32SXin Li
2480*a376eb32SXin Li    echo
2481*a376eb32SXin Li    $ECHO "Try \`$progname --help' for more information about other modes."
2482*a376eb32SXin Li}
2483*a376eb32SXin Li
2484*a376eb32SXin Li# Now that we've collected a possible --mode arg, show help if necessary
2485*a376eb32SXin Liif $opt_help; then
2486*a376eb32SXin Li  if test "$opt_help" = :; then
2487*a376eb32SXin Li    func_mode_help
2488*a376eb32SXin Li  else
2489*a376eb32SXin Li    {
2490*a376eb32SXin Li      func_help noexit
2491*a376eb32SXin Li      for opt_mode in compile link execute install finish uninstall clean; do
2492*a376eb32SXin Li	func_mode_help
2493*a376eb32SXin Li      done
2494*a376eb32SXin Li    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
2495*a376eb32SXin Li    {
2496*a376eb32SXin Li      func_help noexit
2497*a376eb32SXin Li      for opt_mode in compile link execute install finish uninstall clean; do
2498*a376eb32SXin Li	echo
2499*a376eb32SXin Li	func_mode_help
2500*a376eb32SXin Li      done
2501*a376eb32SXin Li    } |
2502*a376eb32SXin Li    sed '1d
2503*a376eb32SXin Li      /^When reporting/,/^Report/{
2504*a376eb32SXin Li	H
2505*a376eb32SXin Li	d
2506*a376eb32SXin Li      }
2507*a376eb32SXin Li      $x
2508*a376eb32SXin Li      /information about other modes/d
2509*a376eb32SXin Li      /more detailed .*MODE/d
2510*a376eb32SXin Li      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
2511*a376eb32SXin Li  fi
2512*a376eb32SXin Li  exit $?
2513*a376eb32SXin Lifi
2514*a376eb32SXin Li
2515*a376eb32SXin Li
2516*a376eb32SXin Li# func_mode_execute arg...
2517*a376eb32SXin Lifunc_mode_execute ()
2518*a376eb32SXin Li{
2519*a376eb32SXin Li    $opt_debug
2520*a376eb32SXin Li    # The first argument is the command name.
2521*a376eb32SXin Li    cmd="$nonopt"
2522*a376eb32SXin Li    test -z "$cmd" && \
2523*a376eb32SXin Li      func_fatal_help "you must specify a COMMAND"
2524*a376eb32SXin Li
2525*a376eb32SXin Li    # Handle -dlopen flags immediately.
2526*a376eb32SXin Li    for file in $opt_dlopen; do
2527*a376eb32SXin Li      test -f "$file" \
2528*a376eb32SXin Li	|| func_fatal_help "\`$file' is not a file"
2529*a376eb32SXin Li
2530*a376eb32SXin Li      dir=
2531*a376eb32SXin Li      case $file in
2532*a376eb32SXin Li      *.la)
2533*a376eb32SXin Li	func_resolve_sysroot "$file"
2534*a376eb32SXin Li	file=$func_resolve_sysroot_result
2535*a376eb32SXin Li
2536*a376eb32SXin Li	# Check to see that this really is a libtool archive.
2537*a376eb32SXin Li	func_lalib_unsafe_p "$file" \
2538*a376eb32SXin Li	  || func_fatal_help "\`$lib' is not a valid libtool archive"
2539*a376eb32SXin Li
2540*a376eb32SXin Li	# Read the libtool library.
2541*a376eb32SXin Li	dlname=
2542*a376eb32SXin Li	library_names=
2543*a376eb32SXin Li	func_source "$file"
2544*a376eb32SXin Li
2545*a376eb32SXin Li	# Skip this library if it cannot be dlopened.
2546*a376eb32SXin Li	if test -z "$dlname"; then
2547*a376eb32SXin Li	  # Warn if it was a shared library.
2548*a376eb32SXin Li	  test -n "$library_names" && \
2549*a376eb32SXin Li	    func_warning "\`$file' was not linked with \`-export-dynamic'"
2550*a376eb32SXin Li	  continue
2551*a376eb32SXin Li	fi
2552*a376eb32SXin Li
2553*a376eb32SXin Li	func_dirname "$file" "" "."
2554*a376eb32SXin Li	dir="$func_dirname_result"
2555*a376eb32SXin Li
2556*a376eb32SXin Li	if test -f "$dir/$objdir/$dlname"; then
2557*a376eb32SXin Li	  func_append dir "/$objdir"
2558*a376eb32SXin Li	else
2559*a376eb32SXin Li	  if test ! -f "$dir/$dlname"; then
2560*a376eb32SXin Li	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
2561*a376eb32SXin Li	  fi
2562*a376eb32SXin Li	fi
2563*a376eb32SXin Li	;;
2564*a376eb32SXin Li
2565*a376eb32SXin Li      *.lo)
2566*a376eb32SXin Li	# Just add the directory containing the .lo file.
2567*a376eb32SXin Li	func_dirname "$file" "" "."
2568*a376eb32SXin Li	dir="$func_dirname_result"
2569*a376eb32SXin Li	;;
2570*a376eb32SXin Li
2571*a376eb32SXin Li      *)
2572*a376eb32SXin Li	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
2573*a376eb32SXin Li	continue
2574*a376eb32SXin Li	;;
2575*a376eb32SXin Li      esac
2576*a376eb32SXin Li
2577*a376eb32SXin Li      # Get the absolute pathname.
2578*a376eb32SXin Li      absdir=`cd "$dir" && pwd`
2579*a376eb32SXin Li      test -n "$absdir" && dir="$absdir"
2580*a376eb32SXin Li
2581*a376eb32SXin Li      # Now add the directory to shlibpath_var.
2582*a376eb32SXin Li      if eval "test -z \"\$$shlibpath_var\""; then
2583*a376eb32SXin Li	eval "$shlibpath_var=\"\$dir\""
2584*a376eb32SXin Li      else
2585*a376eb32SXin Li	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
2586*a376eb32SXin Li      fi
2587*a376eb32SXin Li    done
2588*a376eb32SXin Li
2589*a376eb32SXin Li    # This variable tells wrapper scripts just to set shlibpath_var
2590*a376eb32SXin Li    # rather than running their programs.
2591*a376eb32SXin Li    libtool_execute_magic="$magic"
2592*a376eb32SXin Li
2593*a376eb32SXin Li    # Check if any of the arguments is a wrapper script.
2594*a376eb32SXin Li    args=
2595*a376eb32SXin Li    for file
2596*a376eb32SXin Li    do
2597*a376eb32SXin Li      case $file in
2598*a376eb32SXin Li      -* | *.la | *.lo ) ;;
2599*a376eb32SXin Li      *)
2600*a376eb32SXin Li	# Do a test to see if this is really a libtool program.
2601*a376eb32SXin Li	if func_ltwrapper_script_p "$file"; then
2602*a376eb32SXin Li	  func_source "$file"
2603*a376eb32SXin Li	  # Transform arg to wrapped name.
2604*a376eb32SXin Li	  file="$progdir/$program"
2605*a376eb32SXin Li	elif func_ltwrapper_executable_p "$file"; then
2606*a376eb32SXin Li	  func_ltwrapper_scriptname "$file"
2607*a376eb32SXin Li	  func_source "$func_ltwrapper_scriptname_result"
2608*a376eb32SXin Li	  # Transform arg to wrapped name.
2609*a376eb32SXin Li	  file="$progdir/$program"
2610*a376eb32SXin Li	fi
2611*a376eb32SXin Li	;;
2612*a376eb32SXin Li      esac
2613*a376eb32SXin Li      # Quote arguments (to preserve shell metacharacters).
2614*a376eb32SXin Li      func_append_quoted args "$file"
2615*a376eb32SXin Li    done
2616*a376eb32SXin Li
2617*a376eb32SXin Li    if test "X$opt_dry_run" = Xfalse; then
2618*a376eb32SXin Li      if test -n "$shlibpath_var"; then
2619*a376eb32SXin Li	# Export the shlibpath_var.
2620*a376eb32SXin Li	eval "export $shlibpath_var"
2621*a376eb32SXin Li      fi
2622*a376eb32SXin Li
2623*a376eb32SXin Li      # Restore saved environment variables
2624*a376eb32SXin Li      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
2625*a376eb32SXin Li      do
2626*a376eb32SXin Li	eval "if test \"\${save_$lt_var+set}\" = set; then
2627*a376eb32SXin Li                $lt_var=\$save_$lt_var; export $lt_var
2628*a376eb32SXin Li	      else
2629*a376eb32SXin Li		$lt_unset $lt_var
2630*a376eb32SXin Li	      fi"
2631*a376eb32SXin Li      done
2632*a376eb32SXin Li
2633*a376eb32SXin Li      # Now prepare to actually exec the command.
2634*a376eb32SXin Li      exec_cmd="\$cmd$args"
2635*a376eb32SXin Li    else
2636*a376eb32SXin Li      # Display what would be done.
2637*a376eb32SXin Li      if test -n "$shlibpath_var"; then
2638*a376eb32SXin Li	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
2639*a376eb32SXin Li	echo "export $shlibpath_var"
2640*a376eb32SXin Li      fi
2641*a376eb32SXin Li      $ECHO "$cmd$args"
2642*a376eb32SXin Li      exit $EXIT_SUCCESS
2643*a376eb32SXin Li    fi
2644*a376eb32SXin Li}
2645*a376eb32SXin Li
2646*a376eb32SXin Litest "$opt_mode" = execute && func_mode_execute ${1+"$@"}
2647*a376eb32SXin Li
2648*a376eb32SXin Li
2649*a376eb32SXin Li# func_mode_finish arg...
2650*a376eb32SXin Lifunc_mode_finish ()
2651*a376eb32SXin Li{
2652*a376eb32SXin Li    $opt_debug
2653*a376eb32SXin Li    libs=
2654*a376eb32SXin Li    libdirs=
2655*a376eb32SXin Li    admincmds=
2656*a376eb32SXin Li
2657*a376eb32SXin Li    for opt in "$nonopt" ${1+"$@"}
2658*a376eb32SXin Li    do
2659*a376eb32SXin Li      if test -d "$opt"; then
2660*a376eb32SXin Li	func_append libdirs " $opt"
2661*a376eb32SXin Li
2662*a376eb32SXin Li      elif test -f "$opt"; then
2663*a376eb32SXin Li	if func_lalib_unsafe_p "$opt"; then
2664*a376eb32SXin Li	  func_append libs " $opt"
2665*a376eb32SXin Li	else
2666*a376eb32SXin Li	  func_warning "\`$opt' is not a valid libtool archive"
2667*a376eb32SXin Li	fi
2668*a376eb32SXin Li
2669*a376eb32SXin Li      else
2670*a376eb32SXin Li	func_fatal_error "invalid argument \`$opt'"
2671*a376eb32SXin Li      fi
2672*a376eb32SXin Li    done
2673*a376eb32SXin Li
2674*a376eb32SXin Li    if test -n "$libs"; then
2675*a376eb32SXin Li      if test -n "$lt_sysroot"; then
2676*a376eb32SXin Li        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
2677*a376eb32SXin Li        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
2678*a376eb32SXin Li      else
2679*a376eb32SXin Li        sysroot_cmd=
2680*a376eb32SXin Li      fi
2681*a376eb32SXin Li
2682*a376eb32SXin Li      # Remove sysroot references
2683*a376eb32SXin Li      if $opt_dry_run; then
2684*a376eb32SXin Li        for lib in $libs; do
2685*a376eb32SXin Li          echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
2686*a376eb32SXin Li        done
2687*a376eb32SXin Li      else
2688*a376eb32SXin Li        tmpdir=`func_mktempdir`
2689*a376eb32SXin Li        for lib in $libs; do
2690*a376eb32SXin Li	  sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
2691*a376eb32SXin Li	    > $tmpdir/tmp-la
2692*a376eb32SXin Li	  mv -f $tmpdir/tmp-la $lib
2693*a376eb32SXin Li	done
2694*a376eb32SXin Li        ${RM}r "$tmpdir"
2695*a376eb32SXin Li      fi
2696*a376eb32SXin Li    fi
2697*a376eb32SXin Li
2698*a376eb32SXin Li    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2699*a376eb32SXin Li      for libdir in $libdirs; do
2700*a376eb32SXin Li	if test -n "$finish_cmds"; then
2701*a376eb32SXin Li	  # Do each command in the finish commands.
2702*a376eb32SXin Li	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
2703*a376eb32SXin Li'"$cmd"'"'
2704*a376eb32SXin Li	fi
2705*a376eb32SXin Li	if test -n "$finish_eval"; then
2706*a376eb32SXin Li	  # Do the single finish_eval.
2707*a376eb32SXin Li	  eval cmds=\"$finish_eval\"
2708*a376eb32SXin Li	  $opt_dry_run || eval "$cmds" || func_append admincmds "
2709*a376eb32SXin Li       $cmds"
2710*a376eb32SXin Li	fi
2711*a376eb32SXin Li      done
2712*a376eb32SXin Li    fi
2713*a376eb32SXin Li
2714*a376eb32SXin Li    # Exit here if they wanted silent mode.
2715*a376eb32SXin Li    $opt_silent && exit $EXIT_SUCCESS
2716*a376eb32SXin Li
2717*a376eb32SXin Li    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2718*a376eb32SXin Li      echo "----------------------------------------------------------------------"
2719*a376eb32SXin Li      echo "Libraries have been installed in:"
2720*a376eb32SXin Li      for libdir in $libdirs; do
2721*a376eb32SXin Li	$ECHO "   $libdir"
2722*a376eb32SXin Li      done
2723*a376eb32SXin Li      echo
2724*a376eb32SXin Li      echo "If you ever happen to want to link against installed libraries"
2725*a376eb32SXin Li      echo "in a given directory, LIBDIR, you must either use libtool, and"
2726*a376eb32SXin Li      echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
2727*a376eb32SXin Li      echo "flag during linking and do at least one of the following:"
2728*a376eb32SXin Li      if test -n "$shlibpath_var"; then
2729*a376eb32SXin Li	echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
2730*a376eb32SXin Li	echo "     during execution"
2731*a376eb32SXin Li      fi
2732*a376eb32SXin Li      if test -n "$runpath_var"; then
2733*a376eb32SXin Li	echo "   - add LIBDIR to the \`$runpath_var' environment variable"
2734*a376eb32SXin Li	echo "     during linking"
2735*a376eb32SXin Li      fi
2736*a376eb32SXin Li      if test -n "$hardcode_libdir_flag_spec"; then
2737*a376eb32SXin Li	libdir=LIBDIR
2738*a376eb32SXin Li	eval flag=\"$hardcode_libdir_flag_spec\"
2739*a376eb32SXin Li
2740*a376eb32SXin Li	$ECHO "   - use the \`$flag' linker flag"
2741*a376eb32SXin Li      fi
2742*a376eb32SXin Li      if test -n "$admincmds"; then
2743*a376eb32SXin Li	$ECHO "   - have your system administrator run these commands:$admincmds"
2744*a376eb32SXin Li      fi
2745*a376eb32SXin Li      if test -f /etc/ld.so.conf; then
2746*a376eb32SXin Li	echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
2747*a376eb32SXin Li      fi
2748*a376eb32SXin Li      echo
2749*a376eb32SXin Li
2750*a376eb32SXin Li      echo "See any operating system documentation about shared libraries for"
2751*a376eb32SXin Li      case $host in
2752*a376eb32SXin Li	solaris2.[6789]|solaris2.1[0-9])
2753*a376eb32SXin Li	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
2754*a376eb32SXin Li	  echo "pages."
2755*a376eb32SXin Li	  ;;
2756*a376eb32SXin Li	*)
2757*a376eb32SXin Li	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
2758*a376eb32SXin Li	  ;;
2759*a376eb32SXin Li      esac
2760*a376eb32SXin Li      echo "----------------------------------------------------------------------"
2761*a376eb32SXin Li    fi
2762*a376eb32SXin Li    exit $EXIT_SUCCESS
2763*a376eb32SXin Li}
2764*a376eb32SXin Li
2765*a376eb32SXin Litest "$opt_mode" = finish && func_mode_finish ${1+"$@"}
2766*a376eb32SXin Li
2767*a376eb32SXin Li
2768*a376eb32SXin Li# func_mode_install arg...
2769*a376eb32SXin Lifunc_mode_install ()
2770*a376eb32SXin Li{
2771*a376eb32SXin Li    $opt_debug
2772*a376eb32SXin Li    # There may be an optional sh(1) argument at the beginning of
2773*a376eb32SXin Li    # install_prog (especially on Windows NT).
2774*a376eb32SXin Li    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
2775*a376eb32SXin Li       # Allow the use of GNU shtool's install command.
2776*a376eb32SXin Li       case $nonopt in *shtool*) :;; *) false;; esac; then
2777*a376eb32SXin Li      # Aesthetically quote it.
2778*a376eb32SXin Li      func_quote_for_eval "$nonopt"
2779*a376eb32SXin Li      install_prog="$func_quote_for_eval_result "
2780*a376eb32SXin Li      arg=$1
2781*a376eb32SXin Li      shift
2782*a376eb32SXin Li    else
2783*a376eb32SXin Li      install_prog=
2784*a376eb32SXin Li      arg=$nonopt
2785*a376eb32SXin Li    fi
2786*a376eb32SXin Li
2787*a376eb32SXin Li    # The real first argument should be the name of the installation program.
2788*a376eb32SXin Li    # Aesthetically quote it.
2789*a376eb32SXin Li    func_quote_for_eval "$arg"
2790*a376eb32SXin Li    func_append install_prog "$func_quote_for_eval_result"
2791*a376eb32SXin Li    install_shared_prog=$install_prog
2792*a376eb32SXin Li    case " $install_prog " in
2793*a376eb32SXin Li      *[\\\ /]cp\ *) install_cp=: ;;
2794*a376eb32SXin Li      *) install_cp=false ;;
2795*a376eb32SXin Li    esac
2796*a376eb32SXin Li
2797*a376eb32SXin Li    # We need to accept at least all the BSD install flags.
2798*a376eb32SXin Li    dest=
2799*a376eb32SXin Li    files=
2800*a376eb32SXin Li    opts=
2801*a376eb32SXin Li    prev=
2802*a376eb32SXin Li    install_type=
2803*a376eb32SXin Li    isdir=no
2804*a376eb32SXin Li    stripme=
2805*a376eb32SXin Li    no_mode=:
2806*a376eb32SXin Li    for arg
2807*a376eb32SXin Li    do
2808*a376eb32SXin Li      arg2=
2809*a376eb32SXin Li      if test -n "$dest"; then
2810*a376eb32SXin Li	func_append files " $dest"
2811*a376eb32SXin Li	dest=$arg
2812*a376eb32SXin Li	continue
2813*a376eb32SXin Li      fi
2814*a376eb32SXin Li
2815*a376eb32SXin Li      case $arg in
2816*a376eb32SXin Li      -d) isdir=yes ;;
2817*a376eb32SXin Li      -f)
2818*a376eb32SXin Li	if $install_cp; then :; else
2819*a376eb32SXin Li	  prev=$arg
2820*a376eb32SXin Li	fi
2821*a376eb32SXin Li	;;
2822*a376eb32SXin Li      -g | -m | -o)
2823*a376eb32SXin Li	prev=$arg
2824*a376eb32SXin Li	;;
2825*a376eb32SXin Li      -s)
2826*a376eb32SXin Li	stripme=" -s"
2827*a376eb32SXin Li	continue
2828*a376eb32SXin Li	;;
2829*a376eb32SXin Li      -*)
2830*a376eb32SXin Li	;;
2831*a376eb32SXin Li      *)
2832*a376eb32SXin Li	# If the previous option needed an argument, then skip it.
2833*a376eb32SXin Li	if test -n "$prev"; then
2834*a376eb32SXin Li	  if test "x$prev" = x-m && test -n "$install_override_mode"; then
2835*a376eb32SXin Li	    arg2=$install_override_mode
2836*a376eb32SXin Li	    no_mode=false
2837*a376eb32SXin Li	  fi
2838*a376eb32SXin Li	  prev=
2839*a376eb32SXin Li	else
2840*a376eb32SXin Li	  dest=$arg
2841*a376eb32SXin Li	  continue
2842*a376eb32SXin Li	fi
2843*a376eb32SXin Li	;;
2844*a376eb32SXin Li      esac
2845*a376eb32SXin Li
2846*a376eb32SXin Li      # Aesthetically quote the argument.
2847*a376eb32SXin Li      func_quote_for_eval "$arg"
2848*a376eb32SXin Li      func_append install_prog " $func_quote_for_eval_result"
2849*a376eb32SXin Li      if test -n "$arg2"; then
2850*a376eb32SXin Li	func_quote_for_eval "$arg2"
2851*a376eb32SXin Li      fi
2852*a376eb32SXin Li      func_append install_shared_prog " $func_quote_for_eval_result"
2853*a376eb32SXin Li    done
2854*a376eb32SXin Li
2855*a376eb32SXin Li    test -z "$install_prog" && \
2856*a376eb32SXin Li      func_fatal_help "you must specify an install program"
2857*a376eb32SXin Li
2858*a376eb32SXin Li    test -n "$prev" && \
2859*a376eb32SXin Li      func_fatal_help "the \`$prev' option requires an argument"
2860*a376eb32SXin Li
2861*a376eb32SXin Li    if test -n "$install_override_mode" && $no_mode; then
2862*a376eb32SXin Li      if $install_cp; then :; else
2863*a376eb32SXin Li	func_quote_for_eval "$install_override_mode"
2864*a376eb32SXin Li	func_append install_shared_prog " -m $func_quote_for_eval_result"
2865*a376eb32SXin Li      fi
2866*a376eb32SXin Li    fi
2867*a376eb32SXin Li
2868*a376eb32SXin Li    if test -z "$files"; then
2869*a376eb32SXin Li      if test -z "$dest"; then
2870*a376eb32SXin Li	func_fatal_help "no file or destination specified"
2871*a376eb32SXin Li      else
2872*a376eb32SXin Li	func_fatal_help "you must specify a destination"
2873*a376eb32SXin Li      fi
2874*a376eb32SXin Li    fi
2875*a376eb32SXin Li
2876*a376eb32SXin Li    # Strip any trailing slash from the destination.
2877*a376eb32SXin Li    func_stripname '' '/' "$dest"
2878*a376eb32SXin Li    dest=$func_stripname_result
2879*a376eb32SXin Li
2880*a376eb32SXin Li    # Check to see that the destination is a directory.
2881*a376eb32SXin Li    test -d "$dest" && isdir=yes
2882*a376eb32SXin Li    if test "$isdir" = yes; then
2883*a376eb32SXin Li      destdir="$dest"
2884*a376eb32SXin Li      destname=
2885*a376eb32SXin Li    else
2886*a376eb32SXin Li      func_dirname_and_basename "$dest" "" "."
2887*a376eb32SXin Li      destdir="$func_dirname_result"
2888*a376eb32SXin Li      destname="$func_basename_result"
2889*a376eb32SXin Li
2890*a376eb32SXin Li      # Not a directory, so check to see that there is only one file specified.
2891*a376eb32SXin Li      set dummy $files; shift
2892*a376eb32SXin Li      test "$#" -gt 1 && \
2893*a376eb32SXin Li	func_fatal_help "\`$dest' is not a directory"
2894*a376eb32SXin Li    fi
2895*a376eb32SXin Li    case $destdir in
2896*a376eb32SXin Li    [\\/]* | [A-Za-z]:[\\/]*) ;;
2897*a376eb32SXin Li    *)
2898*a376eb32SXin Li      for file in $files; do
2899*a376eb32SXin Li	case $file in
2900*a376eb32SXin Li	*.lo) ;;
2901*a376eb32SXin Li	*)
2902*a376eb32SXin Li	  func_fatal_help "\`$destdir' must be an absolute directory name"
2903*a376eb32SXin Li	  ;;
2904*a376eb32SXin Li	esac
2905*a376eb32SXin Li      done
2906*a376eb32SXin Li      ;;
2907*a376eb32SXin Li    esac
2908*a376eb32SXin Li
2909*a376eb32SXin Li    # This variable tells wrapper scripts just to set variables rather
2910*a376eb32SXin Li    # than running their programs.
2911*a376eb32SXin Li    libtool_install_magic="$magic"
2912*a376eb32SXin Li
2913*a376eb32SXin Li    staticlibs=
2914*a376eb32SXin Li    future_libdirs=
2915*a376eb32SXin Li    current_libdirs=
2916*a376eb32SXin Li    for file in $files; do
2917*a376eb32SXin Li
2918*a376eb32SXin Li      # Do each installation.
2919*a376eb32SXin Li      case $file in
2920*a376eb32SXin Li      *.$libext)
2921*a376eb32SXin Li	# Do the static libraries later.
2922*a376eb32SXin Li	func_append staticlibs " $file"
2923*a376eb32SXin Li	;;
2924*a376eb32SXin Li
2925*a376eb32SXin Li      *.la)
2926*a376eb32SXin Li	func_resolve_sysroot "$file"
2927*a376eb32SXin Li	file=$func_resolve_sysroot_result
2928*a376eb32SXin Li
2929*a376eb32SXin Li	# Check to see that this really is a libtool archive.
2930*a376eb32SXin Li	func_lalib_unsafe_p "$file" \
2931*a376eb32SXin Li	  || func_fatal_help "\`$file' is not a valid libtool archive"
2932*a376eb32SXin Li
2933*a376eb32SXin Li	library_names=
2934*a376eb32SXin Li	old_library=
2935*a376eb32SXin Li	relink_command=
2936*a376eb32SXin Li	func_source "$file"
2937*a376eb32SXin Li
2938*a376eb32SXin Li	# Add the libdir to current_libdirs if it is the destination.
2939*a376eb32SXin Li	if test "X$destdir" = "X$libdir"; then
2940*a376eb32SXin Li	  case "$current_libdirs " in
2941*a376eb32SXin Li	  *" $libdir "*) ;;
2942*a376eb32SXin Li	  *) func_append current_libdirs " $libdir" ;;
2943*a376eb32SXin Li	  esac
2944*a376eb32SXin Li	else
2945*a376eb32SXin Li	  # Note the libdir as a future libdir.
2946*a376eb32SXin Li	  case "$future_libdirs " in
2947*a376eb32SXin Li	  *" $libdir "*) ;;
2948*a376eb32SXin Li	  *) func_append future_libdirs " $libdir" ;;
2949*a376eb32SXin Li	  esac
2950*a376eb32SXin Li	fi
2951*a376eb32SXin Li
2952*a376eb32SXin Li	func_dirname "$file" "/" ""
2953*a376eb32SXin Li	dir="$func_dirname_result"
2954*a376eb32SXin Li	func_append dir "$objdir"
2955*a376eb32SXin Li
2956*a376eb32SXin Li	if test -n "$relink_command"; then
2957*a376eb32SXin Li	  # Determine the prefix the user has applied to our future dir.
2958*a376eb32SXin Li	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
2959*a376eb32SXin Li
2960*a376eb32SXin Li	  # Don't allow the user to place us outside of our expected
2961*a376eb32SXin Li	  # location b/c this prevents finding dependent libraries that
2962*a376eb32SXin Li	  # are installed to the same prefix.
2963*a376eb32SXin Li	  # At present, this check doesn't affect windows .dll's that
2964*a376eb32SXin Li	  # are installed into $libdir/../bin (currently, that works fine)
2965*a376eb32SXin Li	  # but it's something to keep an eye on.
2966*a376eb32SXin Li	  test "$inst_prefix_dir" = "$destdir" && \
2967*a376eb32SXin Li	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
2968*a376eb32SXin Li
2969*a376eb32SXin Li	  if test -n "$inst_prefix_dir"; then
2970*a376eb32SXin Li	    # Stick the inst_prefix_dir data into the link command.
2971*a376eb32SXin Li	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
2972*a376eb32SXin Li	  else
2973*a376eb32SXin Li	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
2974*a376eb32SXin Li	  fi
2975*a376eb32SXin Li
2976*a376eb32SXin Li	  func_warning "relinking \`$file'"
2977*a376eb32SXin Li	  func_show_eval "$relink_command" \
2978*a376eb32SXin Li	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
2979*a376eb32SXin Li	fi
2980*a376eb32SXin Li
2981*a376eb32SXin Li	# See the names of the shared library.
2982*a376eb32SXin Li	set dummy $library_names; shift
2983*a376eb32SXin Li	if test -n "$1"; then
2984*a376eb32SXin Li	  realname="$1"
2985*a376eb32SXin Li	  shift
2986*a376eb32SXin Li
2987*a376eb32SXin Li	  srcname="$realname"
2988*a376eb32SXin Li	  test -n "$relink_command" && srcname="$realname"T
2989*a376eb32SXin Li
2990*a376eb32SXin Li	  # Install the shared library and build the symlinks.
2991*a376eb32SXin Li	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
2992*a376eb32SXin Li	      'exit $?'
2993*a376eb32SXin Li	  tstripme="$stripme"
2994*a376eb32SXin Li	  case $host_os in
2995*a376eb32SXin Li	  cygwin* | mingw* | pw32* | cegcc*)
2996*a376eb32SXin Li	    case $realname in
2997*a376eb32SXin Li	    *.dll.a)
2998*a376eb32SXin Li	      tstripme=""
2999*a376eb32SXin Li	      ;;
3000*a376eb32SXin Li	    esac
3001*a376eb32SXin Li	    ;;
3002*a376eb32SXin Li	  esac
3003*a376eb32SXin Li	  if test -n "$tstripme" && test -n "$striplib"; then
3004*a376eb32SXin Li	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
3005*a376eb32SXin Li	  fi
3006*a376eb32SXin Li
3007*a376eb32SXin Li	  if test "$#" -gt 0; then
3008*a376eb32SXin Li	    # Delete the old symlinks, and create new ones.
3009*a376eb32SXin Li	    # Try `ln -sf' first, because the `ln' binary might depend on
3010*a376eb32SXin Li	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
3011*a376eb32SXin Li	    # so we also need to try rm && ln -s.
3012*a376eb32SXin Li	    for linkname
3013*a376eb32SXin Li	    do
3014*a376eb32SXin Li	      test "$linkname" != "$realname" \
3015*a376eb32SXin Li		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
3016*a376eb32SXin Li	    done
3017*a376eb32SXin Li	  fi
3018*a376eb32SXin Li
3019*a376eb32SXin Li	  # Do each command in the postinstall commands.
3020*a376eb32SXin Li	  lib="$destdir/$realname"
3021*a376eb32SXin Li	  func_execute_cmds "$postinstall_cmds" 'exit $?'
3022*a376eb32SXin Li	fi
3023*a376eb32SXin Li
3024*a376eb32SXin Li	# Install the pseudo-library for information purposes.
3025*a376eb32SXin Li	func_basename "$file"
3026*a376eb32SXin Li	name="$func_basename_result"
3027*a376eb32SXin Li	instname="$dir/$name"i
3028*a376eb32SXin Li	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
3029*a376eb32SXin Li
3030*a376eb32SXin Li	# Maybe install the static library, too.
3031*a376eb32SXin Li	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
3032*a376eb32SXin Li	;;
3033*a376eb32SXin Li
3034*a376eb32SXin Li      *.lo)
3035*a376eb32SXin Li	# Install (i.e. copy) a libtool object.
3036*a376eb32SXin Li
3037*a376eb32SXin Li	# Figure out destination file name, if it wasn't already specified.
3038*a376eb32SXin Li	if test -n "$destname"; then
3039*a376eb32SXin Li	  destfile="$destdir/$destname"
3040*a376eb32SXin Li	else
3041*a376eb32SXin Li	  func_basename "$file"
3042*a376eb32SXin Li	  destfile="$func_basename_result"
3043*a376eb32SXin Li	  destfile="$destdir/$destfile"
3044*a376eb32SXin Li	fi
3045*a376eb32SXin Li
3046*a376eb32SXin Li	# Deduce the name of the destination old-style object file.
3047*a376eb32SXin Li	case $destfile in
3048*a376eb32SXin Li	*.lo)
3049*a376eb32SXin Li	  func_lo2o "$destfile"
3050*a376eb32SXin Li	  staticdest=$func_lo2o_result
3051*a376eb32SXin Li	  ;;
3052*a376eb32SXin Li	*.$objext)
3053*a376eb32SXin Li	  staticdest="$destfile"
3054*a376eb32SXin Li	  destfile=
3055*a376eb32SXin Li	  ;;
3056*a376eb32SXin Li	*)
3057*a376eb32SXin Li	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
3058*a376eb32SXin Li	  ;;
3059*a376eb32SXin Li	esac
3060*a376eb32SXin Li
3061*a376eb32SXin Li	# Install the libtool object if requested.
3062*a376eb32SXin Li	test -n "$destfile" && \
3063*a376eb32SXin Li	  func_show_eval "$install_prog $file $destfile" 'exit $?'
3064*a376eb32SXin Li
3065*a376eb32SXin Li	# Install the old object if enabled.
3066*a376eb32SXin Li	if test "$build_old_libs" = yes; then
3067*a376eb32SXin Li	  # Deduce the name of the old-style object file.
3068*a376eb32SXin Li	  func_lo2o "$file"
3069*a376eb32SXin Li	  staticobj=$func_lo2o_result
3070*a376eb32SXin Li	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
3071*a376eb32SXin Li	fi
3072*a376eb32SXin Li	exit $EXIT_SUCCESS
3073*a376eb32SXin Li	;;
3074*a376eb32SXin Li
3075*a376eb32SXin Li      *)
3076*a376eb32SXin Li	# Figure out destination file name, if it wasn't already specified.
3077*a376eb32SXin Li	if test -n "$destname"; then
3078*a376eb32SXin Li	  destfile="$destdir/$destname"
3079*a376eb32SXin Li	else
3080*a376eb32SXin Li	  func_basename "$file"
3081*a376eb32SXin Li	  destfile="$func_basename_result"
3082*a376eb32SXin Li	  destfile="$destdir/$destfile"
3083*a376eb32SXin Li	fi
3084*a376eb32SXin Li
3085*a376eb32SXin Li	# If the file is missing, and there is a .exe on the end, strip it
3086*a376eb32SXin Li	# because it is most likely a libtool script we actually want to
3087*a376eb32SXin Li	# install
3088*a376eb32SXin Li	stripped_ext=""
3089*a376eb32SXin Li	case $file in
3090*a376eb32SXin Li	  *.exe)
3091*a376eb32SXin Li	    if test ! -f "$file"; then
3092*a376eb32SXin Li	      func_stripname '' '.exe' "$file"
3093*a376eb32SXin Li	      file=$func_stripname_result
3094*a376eb32SXin Li	      stripped_ext=".exe"
3095*a376eb32SXin Li	    fi
3096*a376eb32SXin Li	    ;;
3097*a376eb32SXin Li	esac
3098*a376eb32SXin Li
3099*a376eb32SXin Li	# Do a test to see if this is really a libtool program.
3100*a376eb32SXin Li	case $host in
3101*a376eb32SXin Li	*cygwin* | *mingw*)
3102*a376eb32SXin Li	    if func_ltwrapper_executable_p "$file"; then
3103*a376eb32SXin Li	      func_ltwrapper_scriptname "$file"
3104*a376eb32SXin Li	      wrapper=$func_ltwrapper_scriptname_result
3105*a376eb32SXin Li	    else
3106*a376eb32SXin Li	      func_stripname '' '.exe' "$file"
3107*a376eb32SXin Li	      wrapper=$func_stripname_result
3108*a376eb32SXin Li	    fi
3109*a376eb32SXin Li	    ;;
3110*a376eb32SXin Li	*)
3111*a376eb32SXin Li	    wrapper=$file
3112*a376eb32SXin Li	    ;;
3113*a376eb32SXin Li	esac
3114*a376eb32SXin Li	if func_ltwrapper_script_p "$wrapper"; then
3115*a376eb32SXin Li	  notinst_deplibs=
3116*a376eb32SXin Li	  relink_command=
3117*a376eb32SXin Li
3118*a376eb32SXin Li	  func_source "$wrapper"
3119*a376eb32SXin Li
3120*a376eb32SXin Li	  # Check the variables that should have been set.
3121*a376eb32SXin Li	  test -z "$generated_by_libtool_version" && \
3122*a376eb32SXin Li	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
3123*a376eb32SXin Li
3124*a376eb32SXin Li	  finalize=yes
3125*a376eb32SXin Li	  for lib in $notinst_deplibs; do
3126*a376eb32SXin Li	    # Check to see that each library is installed.
3127*a376eb32SXin Li	    libdir=
3128*a376eb32SXin Li	    if test -f "$lib"; then
3129*a376eb32SXin Li	      func_source "$lib"
3130*a376eb32SXin Li	    fi
3131*a376eb32SXin Li	    libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
3132*a376eb32SXin Li	    if test -n "$libdir" && test ! -f "$libfile"; then
3133*a376eb32SXin Li	      func_warning "\`$lib' has not been installed in \`$libdir'"
3134*a376eb32SXin Li	      finalize=no
3135*a376eb32SXin Li	    fi
3136*a376eb32SXin Li	  done
3137*a376eb32SXin Li
3138*a376eb32SXin Li	  relink_command=
3139*a376eb32SXin Li	  func_source "$wrapper"
3140*a376eb32SXin Li
3141*a376eb32SXin Li	  outputname=
3142*a376eb32SXin Li	  if test "$fast_install" = no && test -n "$relink_command"; then
3143*a376eb32SXin Li	    $opt_dry_run || {
3144*a376eb32SXin Li	      if test "$finalize" = yes; then
3145*a376eb32SXin Li	        tmpdir=`func_mktempdir`
3146*a376eb32SXin Li		func_basename "$file$stripped_ext"
3147*a376eb32SXin Li		file="$func_basename_result"
3148*a376eb32SXin Li	        outputname="$tmpdir/$file"
3149*a376eb32SXin Li	        # Replace the output file specification.
3150*a376eb32SXin Li	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
3151*a376eb32SXin Li
3152*a376eb32SXin Li	        $opt_silent || {
3153*a376eb32SXin Li	          func_quote_for_expand "$relink_command"
3154*a376eb32SXin Li		  eval "func_echo $func_quote_for_expand_result"
3155*a376eb32SXin Li	        }
3156*a376eb32SXin Li	        if eval "$relink_command"; then :
3157*a376eb32SXin Li	          else
3158*a376eb32SXin Li		  func_error "error: relink \`$file' with the above command before installing it"
3159*a376eb32SXin Li		  $opt_dry_run || ${RM}r "$tmpdir"
3160*a376eb32SXin Li		  continue
3161*a376eb32SXin Li	        fi
3162*a376eb32SXin Li	        file="$outputname"
3163*a376eb32SXin Li	      else
3164*a376eb32SXin Li	        func_warning "cannot relink \`$file'"
3165*a376eb32SXin Li	      fi
3166*a376eb32SXin Li	    }
3167*a376eb32SXin Li	  else
3168*a376eb32SXin Li	    # Install the binary that we compiled earlier.
3169*a376eb32SXin Li	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
3170*a376eb32SXin Li	  fi
3171*a376eb32SXin Li	fi
3172*a376eb32SXin Li
3173*a376eb32SXin Li	# remove .exe since cygwin /usr/bin/install will append another
3174*a376eb32SXin Li	# one anyway
3175*a376eb32SXin Li	case $install_prog,$host in
3176*a376eb32SXin Li	*/usr/bin/install*,*cygwin*)
3177*a376eb32SXin Li	  case $file:$destfile in
3178*a376eb32SXin Li	  *.exe:*.exe)
3179*a376eb32SXin Li	    # this is ok
3180*a376eb32SXin Li	    ;;
3181*a376eb32SXin Li	  *.exe:*)
3182*a376eb32SXin Li	    destfile=$destfile.exe
3183*a376eb32SXin Li	    ;;
3184*a376eb32SXin Li	  *:*.exe)
3185*a376eb32SXin Li	    func_stripname '' '.exe' "$destfile"
3186*a376eb32SXin Li	    destfile=$func_stripname_result
3187*a376eb32SXin Li	    ;;
3188*a376eb32SXin Li	  esac
3189*a376eb32SXin Li	  ;;
3190*a376eb32SXin Li	esac
3191*a376eb32SXin Li	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
3192*a376eb32SXin Li	$opt_dry_run || if test -n "$outputname"; then
3193*a376eb32SXin Li	  ${RM}r "$tmpdir"
3194*a376eb32SXin Li	fi
3195*a376eb32SXin Li	;;
3196*a376eb32SXin Li      esac
3197*a376eb32SXin Li    done
3198*a376eb32SXin Li
3199*a376eb32SXin Li    for file in $staticlibs; do
3200*a376eb32SXin Li      func_basename "$file"
3201*a376eb32SXin Li      name="$func_basename_result"
3202*a376eb32SXin Li
3203*a376eb32SXin Li      # Set up the ranlib parameters.
3204*a376eb32SXin Li      oldlib="$destdir/$name"
3205*a376eb32SXin Li      func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
3206*a376eb32SXin Li      tool_oldlib=$func_to_tool_file_result
3207*a376eb32SXin Li
3208*a376eb32SXin Li      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
3209*a376eb32SXin Li
3210*a376eb32SXin Li      if test -n "$stripme" && test -n "$old_striplib"; then
3211*a376eb32SXin Li	func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
3212*a376eb32SXin Li      fi
3213*a376eb32SXin Li
3214*a376eb32SXin Li      # Do each command in the postinstall commands.
3215*a376eb32SXin Li      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
3216*a376eb32SXin Li    done
3217*a376eb32SXin Li
3218*a376eb32SXin Li    test -n "$future_libdirs" && \
3219*a376eb32SXin Li      func_warning "remember to run \`$progname --finish$future_libdirs'"
3220*a376eb32SXin Li
3221*a376eb32SXin Li    if test -n "$current_libdirs"; then
3222*a376eb32SXin Li      # Maybe just do a dry run.
3223*a376eb32SXin Li      $opt_dry_run && current_libdirs=" -n$current_libdirs"
3224*a376eb32SXin Li      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
3225*a376eb32SXin Li    else
3226*a376eb32SXin Li      exit $EXIT_SUCCESS
3227*a376eb32SXin Li    fi
3228*a376eb32SXin Li}
3229*a376eb32SXin Li
3230*a376eb32SXin Litest "$opt_mode" = install && func_mode_install ${1+"$@"}
3231*a376eb32SXin Li
3232*a376eb32SXin Li
3233*a376eb32SXin Li# func_generate_dlsyms outputname originator pic_p
3234*a376eb32SXin Li# Extract symbols from dlprefiles and create ${outputname}S.o with
3235*a376eb32SXin Li# a dlpreopen symbol table.
3236*a376eb32SXin Lifunc_generate_dlsyms ()
3237*a376eb32SXin Li{
3238*a376eb32SXin Li    $opt_debug
3239*a376eb32SXin Li    my_outputname="$1"
3240*a376eb32SXin Li    my_originator="$2"
3241*a376eb32SXin Li    my_pic_p="${3-no}"
3242*a376eb32SXin Li    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
3243*a376eb32SXin Li    my_dlsyms=
3244*a376eb32SXin Li
3245*a376eb32SXin Li    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
3246*a376eb32SXin Li      if test -n "$NM" && test -n "$global_symbol_pipe"; then
3247*a376eb32SXin Li	my_dlsyms="${my_outputname}S.c"
3248*a376eb32SXin Li      else
3249*a376eb32SXin Li	func_error "not configured to extract global symbols from dlpreopened files"
3250*a376eb32SXin Li      fi
3251*a376eb32SXin Li    fi
3252*a376eb32SXin Li
3253*a376eb32SXin Li    if test -n "$my_dlsyms"; then
3254*a376eb32SXin Li      case $my_dlsyms in
3255*a376eb32SXin Li      "") ;;
3256*a376eb32SXin Li      *.c)
3257*a376eb32SXin Li	# Discover the nlist of each of the dlfiles.
3258*a376eb32SXin Li	nlist="$output_objdir/${my_outputname}.nm"
3259*a376eb32SXin Li
3260*a376eb32SXin Li	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
3261*a376eb32SXin Li
3262*a376eb32SXin Li	# Parse the name list into a source file.
3263*a376eb32SXin Li	func_verbose "creating $output_objdir/$my_dlsyms"
3264*a376eb32SXin Li
3265*a376eb32SXin Li	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
3266*a376eb32SXin Li/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
3267*a376eb32SXin Li/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
3268*a376eb32SXin Li
3269*a376eb32SXin Li#ifdef __cplusplus
3270*a376eb32SXin Liextern \"C\" {
3271*a376eb32SXin Li#endif
3272*a376eb32SXin Li
3273*a376eb32SXin Li#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
3274*a376eb32SXin Li#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
3275*a376eb32SXin Li#endif
3276*a376eb32SXin Li
3277*a376eb32SXin Li/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
3278*a376eb32SXin Li#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
3279*a376eb32SXin Li/* DATA imports from DLLs on WIN32 con't be const, because runtime
3280*a376eb32SXin Li   relocations are performed -- see ld's documentation on pseudo-relocs.  */
3281*a376eb32SXin Li# define LT_DLSYM_CONST
3282*a376eb32SXin Li#elif defined(__osf__)
3283*a376eb32SXin Li/* This system does not cope well with relocations in const data.  */
3284*a376eb32SXin Li# define LT_DLSYM_CONST
3285*a376eb32SXin Li#else
3286*a376eb32SXin Li# define LT_DLSYM_CONST const
3287*a376eb32SXin Li#endif
3288*a376eb32SXin Li
3289*a376eb32SXin Li/* External symbol declarations for the compiler. */\
3290*a376eb32SXin Li"
3291*a376eb32SXin Li
3292*a376eb32SXin Li	if test "$dlself" = yes; then
3293*a376eb32SXin Li	  func_verbose "generating symbol list for \`$output'"
3294*a376eb32SXin Li
3295*a376eb32SXin Li	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
3296*a376eb32SXin Li
3297*a376eb32SXin Li	  # Add our own program objects to the symbol list.
3298*a376eb32SXin Li	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
3299*a376eb32SXin Li	  for progfile in $progfiles; do
3300*a376eb32SXin Li	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
3301*a376eb32SXin Li	    func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
3302*a376eb32SXin Li	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
3303*a376eb32SXin Li	  done
3304*a376eb32SXin Li
3305*a376eb32SXin Li	  if test -n "$exclude_expsyms"; then
3306*a376eb32SXin Li	    $opt_dry_run || {
3307*a376eb32SXin Li	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
3308*a376eb32SXin Li	      eval '$MV "$nlist"T "$nlist"'
3309*a376eb32SXin Li	    }
3310*a376eb32SXin Li	  fi
3311*a376eb32SXin Li
3312*a376eb32SXin Li	  if test -n "$export_symbols_regex"; then
3313*a376eb32SXin Li	    $opt_dry_run || {
3314*a376eb32SXin Li	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
3315*a376eb32SXin Li	      eval '$MV "$nlist"T "$nlist"'
3316*a376eb32SXin Li	    }
3317*a376eb32SXin Li	  fi
3318*a376eb32SXin Li
3319*a376eb32SXin Li	  # Prepare the list of exported symbols
3320*a376eb32SXin Li	  if test -z "$export_symbols"; then
3321*a376eb32SXin Li	    export_symbols="$output_objdir/$outputname.exp"
3322*a376eb32SXin Li	    $opt_dry_run || {
3323*a376eb32SXin Li	      $RM $export_symbols
3324*a376eb32SXin Li	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
3325*a376eb32SXin Li	      case $host in
3326*a376eb32SXin Li	      *cygwin* | *mingw* | *cegcc* )
3327*a376eb32SXin Li                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3328*a376eb32SXin Li                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
3329*a376eb32SXin Li	        ;;
3330*a376eb32SXin Li	      esac
3331*a376eb32SXin Li	    }
3332*a376eb32SXin Li	  else
3333*a376eb32SXin Li	    $opt_dry_run || {
3334*a376eb32SXin Li	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
3335*a376eb32SXin Li	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
3336*a376eb32SXin Li	      eval '$MV "$nlist"T "$nlist"'
3337*a376eb32SXin Li	      case $host in
3338*a376eb32SXin Li	        *cygwin* | *mingw* | *cegcc* )
3339*a376eb32SXin Li	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3340*a376eb32SXin Li	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
3341*a376eb32SXin Li	          ;;
3342*a376eb32SXin Li	      esac
3343*a376eb32SXin Li	    }
3344*a376eb32SXin Li	  fi
3345*a376eb32SXin Li	fi
3346*a376eb32SXin Li
3347*a376eb32SXin Li	for dlprefile in $dlprefiles; do
3348*a376eb32SXin Li	  func_verbose "extracting global C symbols from \`$dlprefile'"
3349*a376eb32SXin Li	  func_basename "$dlprefile"
3350*a376eb32SXin Li	  name="$func_basename_result"
3351*a376eb32SXin Li          case $host in
3352*a376eb32SXin Li	    *cygwin* | *mingw* | *cegcc* )
3353*a376eb32SXin Li	      # if an import library, we need to obtain dlname
3354*a376eb32SXin Li	      if func_win32_import_lib_p "$dlprefile"; then
3355*a376eb32SXin Li	        func_tr_sh "$dlprefile"
3356*a376eb32SXin Li	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
3357*a376eb32SXin Li	        dlprefile_dlbasename=""
3358*a376eb32SXin Li	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
3359*a376eb32SXin Li	          # Use subshell, to avoid clobbering current variable values
3360*a376eb32SXin Li	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
3361*a376eb32SXin Li	          if test -n "$dlprefile_dlname" ; then
3362*a376eb32SXin Li	            func_basename "$dlprefile_dlname"
3363*a376eb32SXin Li	            dlprefile_dlbasename="$func_basename_result"
3364*a376eb32SXin Li	          else
3365*a376eb32SXin Li	            # no lafile. user explicitly requested -dlpreopen <import library>.
3366*a376eb32SXin Li	            $sharedlib_from_linklib_cmd "$dlprefile"
3367*a376eb32SXin Li	            dlprefile_dlbasename=$sharedlib_from_linklib_result
3368*a376eb32SXin Li	          fi
3369*a376eb32SXin Li	        fi
3370*a376eb32SXin Li	        $opt_dry_run || {
3371*a376eb32SXin Li	          if test -n "$dlprefile_dlbasename" ; then
3372*a376eb32SXin Li	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
3373*a376eb32SXin Li	          else
3374*a376eb32SXin Li	            func_warning "Could not compute DLL name from $name"
3375*a376eb32SXin Li	            eval '$ECHO ": $name " >> "$nlist"'
3376*a376eb32SXin Li	          fi
3377*a376eb32SXin Li	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3378*a376eb32SXin Li	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
3379*a376eb32SXin Li	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
3380*a376eb32SXin Li	        }
3381*a376eb32SXin Li	      else # not an import lib
3382*a376eb32SXin Li	        $opt_dry_run || {
3383*a376eb32SXin Li	          eval '$ECHO ": $name " >> "$nlist"'
3384*a376eb32SXin Li	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3385*a376eb32SXin Li	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3386*a376eb32SXin Li	        }
3387*a376eb32SXin Li	      fi
3388*a376eb32SXin Li	    ;;
3389*a376eb32SXin Li	    *)
3390*a376eb32SXin Li	      $opt_dry_run || {
3391*a376eb32SXin Li	        eval '$ECHO ": $name " >> "$nlist"'
3392*a376eb32SXin Li	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3393*a376eb32SXin Li	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3394*a376eb32SXin Li	      }
3395*a376eb32SXin Li	    ;;
3396*a376eb32SXin Li          esac
3397*a376eb32SXin Li	done
3398*a376eb32SXin Li
3399*a376eb32SXin Li	$opt_dry_run || {
3400*a376eb32SXin Li	  # Make sure we have at least an empty file.
3401*a376eb32SXin Li	  test -f "$nlist" || : > "$nlist"
3402*a376eb32SXin Li
3403*a376eb32SXin Li	  if test -n "$exclude_expsyms"; then
3404*a376eb32SXin Li	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
3405*a376eb32SXin Li	    $MV "$nlist"T "$nlist"
3406*a376eb32SXin Li	  fi
3407*a376eb32SXin Li
3408*a376eb32SXin Li	  # Try sorting and uniquifying the output.
3409*a376eb32SXin Li	  if $GREP -v "^: " < "$nlist" |
3410*a376eb32SXin Li	      if sort -k 3 </dev/null >/dev/null 2>&1; then
3411*a376eb32SXin Li		sort -k 3
3412*a376eb32SXin Li	      else
3413*a376eb32SXin Li		sort +2
3414*a376eb32SXin Li	      fi |
3415*a376eb32SXin Li	      uniq > "$nlist"S; then
3416*a376eb32SXin Li	    :
3417*a376eb32SXin Li	  else
3418*a376eb32SXin Li	    $GREP -v "^: " < "$nlist" > "$nlist"S
3419*a376eb32SXin Li	  fi
3420*a376eb32SXin Li
3421*a376eb32SXin Li	  if test -f "$nlist"S; then
3422*a376eb32SXin Li	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
3423*a376eb32SXin Li	  else
3424*a376eb32SXin Li	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
3425*a376eb32SXin Li	  fi
3426*a376eb32SXin Li
3427*a376eb32SXin Li	  echo >> "$output_objdir/$my_dlsyms" "\
3428*a376eb32SXin Li
3429*a376eb32SXin Li/* The mapping between symbol names and symbols.  */
3430*a376eb32SXin Litypedef struct {
3431*a376eb32SXin Li  const char *name;
3432*a376eb32SXin Li  void *address;
3433*a376eb32SXin Li} lt_dlsymlist;
3434*a376eb32SXin Liextern LT_DLSYM_CONST lt_dlsymlist
3435*a376eb32SXin Lilt_${my_prefix}_LTX_preloaded_symbols[];
3436*a376eb32SXin LiLT_DLSYM_CONST lt_dlsymlist
3437*a376eb32SXin Lilt_${my_prefix}_LTX_preloaded_symbols[] =
3438*a376eb32SXin Li{\
3439*a376eb32SXin Li  { \"$my_originator\", (void *) 0 },"
3440*a376eb32SXin Li
3441*a376eb32SXin Li	  case $need_lib_prefix in
3442*a376eb32SXin Li	  no)
3443*a376eb32SXin Li	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
3444*a376eb32SXin Li	    ;;
3445*a376eb32SXin Li	  *)
3446*a376eb32SXin Li	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
3447*a376eb32SXin Li	    ;;
3448*a376eb32SXin Li	  esac
3449*a376eb32SXin Li	  echo >> "$output_objdir/$my_dlsyms" "\
3450*a376eb32SXin Li  {0, (void *) 0}
3451*a376eb32SXin Li};
3452*a376eb32SXin Li
3453*a376eb32SXin Li/* This works around a problem in FreeBSD linker */
3454*a376eb32SXin Li#ifdef FREEBSD_WORKAROUND
3455*a376eb32SXin Listatic const void *lt_preloaded_setup() {
3456*a376eb32SXin Li  return lt_${my_prefix}_LTX_preloaded_symbols;
3457*a376eb32SXin Li}
3458*a376eb32SXin Li#endif
3459*a376eb32SXin Li
3460*a376eb32SXin Li#ifdef __cplusplus
3461*a376eb32SXin Li}
3462*a376eb32SXin Li#endif\
3463*a376eb32SXin Li"
3464*a376eb32SXin Li	} # !$opt_dry_run
3465*a376eb32SXin Li
3466*a376eb32SXin Li	pic_flag_for_symtable=
3467*a376eb32SXin Li	case "$compile_command " in
3468*a376eb32SXin Li	*" -static "*) ;;
3469*a376eb32SXin Li	*)
3470*a376eb32SXin Li	  case $host in
3471*a376eb32SXin Li	  # compiling the symbol table file with pic_flag works around
3472*a376eb32SXin Li	  # a FreeBSD bug that causes programs to crash when -lm is
3473*a376eb32SXin Li	  # linked before any other PIC object.  But we must not use
3474*a376eb32SXin Li	  # pic_flag when linking with -static.  The problem exists in
3475*a376eb32SXin Li	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
3476*a376eb32SXin Li	  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
3477*a376eb32SXin Li	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
3478*a376eb32SXin Li	  *-*-hpux*)
3479*a376eb32SXin Li	    pic_flag_for_symtable=" $pic_flag"  ;;
3480*a376eb32SXin Li	  *)
3481*a376eb32SXin Li	    if test "X$my_pic_p" != Xno; then
3482*a376eb32SXin Li	      pic_flag_for_symtable=" $pic_flag"
3483*a376eb32SXin Li	    fi
3484*a376eb32SXin Li	    ;;
3485*a376eb32SXin Li	  esac
3486*a376eb32SXin Li	  ;;
3487*a376eb32SXin Li	esac
3488*a376eb32SXin Li	symtab_cflags=
3489*a376eb32SXin Li	for arg in $LTCFLAGS; do
3490*a376eb32SXin Li	  case $arg in
3491*a376eb32SXin Li	  -pie | -fpie | -fPIE) ;;
3492*a376eb32SXin Li	  *) func_append symtab_cflags " $arg" ;;
3493*a376eb32SXin Li	  esac
3494*a376eb32SXin Li	done
3495*a376eb32SXin Li
3496*a376eb32SXin Li	# Now compile the dynamic symbol file.
3497*a376eb32SXin Li	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
3498*a376eb32SXin Li
3499*a376eb32SXin Li	# Clean up the generated files.
3500*a376eb32SXin Li	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
3501*a376eb32SXin Li
3502*a376eb32SXin Li	# Transform the symbol file into the correct name.
3503*a376eb32SXin Li	symfileobj="$output_objdir/${my_outputname}S.$objext"
3504*a376eb32SXin Li	case $host in
3505*a376eb32SXin Li	*cygwin* | *mingw* | *cegcc* )
3506*a376eb32SXin Li	  if test -f "$output_objdir/$my_outputname.def"; then
3507*a376eb32SXin Li	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3508*a376eb32SXin Li	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3509*a376eb32SXin Li	  else
3510*a376eb32SXin Li	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3511*a376eb32SXin Li	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3512*a376eb32SXin Li	  fi
3513*a376eb32SXin Li	  ;;
3514*a376eb32SXin Li	*)
3515*a376eb32SXin Li	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3516*a376eb32SXin Li	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3517*a376eb32SXin Li	  ;;
3518*a376eb32SXin Li	esac
3519*a376eb32SXin Li	;;
3520*a376eb32SXin Li      *)
3521*a376eb32SXin Li	func_fatal_error "unknown suffix for \`$my_dlsyms'"
3522*a376eb32SXin Li	;;
3523*a376eb32SXin Li      esac
3524*a376eb32SXin Li    else
3525*a376eb32SXin Li      # We keep going just in case the user didn't refer to
3526*a376eb32SXin Li      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
3527*a376eb32SXin Li      # really was required.
3528*a376eb32SXin Li
3529*a376eb32SXin Li      # Nullify the symbol file.
3530*a376eb32SXin Li      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
3531*a376eb32SXin Li      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
3532*a376eb32SXin Li    fi
3533*a376eb32SXin Li}
3534*a376eb32SXin Li
3535*a376eb32SXin Li# func_win32_libid arg
3536*a376eb32SXin Li# return the library type of file 'arg'
3537*a376eb32SXin Li#
3538*a376eb32SXin Li# Need a lot of goo to handle *both* DLLs and import libs
3539*a376eb32SXin Li# Has to be a shell function in order to 'eat' the argument
3540*a376eb32SXin Li# that is supplied when $file_magic_command is called.
3541*a376eb32SXin Li# Despite the name, also deal with 64 bit binaries.
3542*a376eb32SXin Lifunc_win32_libid ()
3543*a376eb32SXin Li{
3544*a376eb32SXin Li  $opt_debug
3545*a376eb32SXin Li  win32_libid_type="unknown"
3546*a376eb32SXin Li  win32_fileres=`file -L $1 2>/dev/null`
3547*a376eb32SXin Li  case $win32_fileres in
3548*a376eb32SXin Li  *ar\ archive\ import\ library*) # definitely import
3549*a376eb32SXin Li    win32_libid_type="x86 archive import"
3550*a376eb32SXin Li    ;;
3551*a376eb32SXin Li  *ar\ archive*) # could be an import, or static
3552*a376eb32SXin Li    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
3553*a376eb32SXin Li    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
3554*a376eb32SXin Li       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
3555*a376eb32SXin Li      func_to_tool_file "$1" func_convert_file_msys_to_w32
3556*a376eb32SXin Li      win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
3557*a376eb32SXin Li	$SED -n -e '
3558*a376eb32SXin Li	    1,100{
3559*a376eb32SXin Li		/ I /{
3560*a376eb32SXin Li		    s,.*,import,
3561*a376eb32SXin Li		    p
3562*a376eb32SXin Li		    q
3563*a376eb32SXin Li		}
3564*a376eb32SXin Li	    }'`
3565*a376eb32SXin Li      case $win32_nmres in
3566*a376eb32SXin Li      import*)  win32_libid_type="x86 archive import";;
3567*a376eb32SXin Li      *)        win32_libid_type="x86 archive static";;
3568*a376eb32SXin Li      esac
3569*a376eb32SXin Li    fi
3570*a376eb32SXin Li    ;;
3571*a376eb32SXin Li  *DLL*)
3572*a376eb32SXin Li    win32_libid_type="x86 DLL"
3573*a376eb32SXin Li    ;;
3574*a376eb32SXin Li  *executable*) # but shell scripts are "executable" too...
3575*a376eb32SXin Li    case $win32_fileres in
3576*a376eb32SXin Li    *MS\ Windows\ PE\ Intel*)
3577*a376eb32SXin Li      win32_libid_type="x86 DLL"
3578*a376eb32SXin Li      ;;
3579*a376eb32SXin Li    esac
3580*a376eb32SXin Li    ;;
3581*a376eb32SXin Li  esac
3582*a376eb32SXin Li  $ECHO "$win32_libid_type"
3583*a376eb32SXin Li}
3584*a376eb32SXin Li
3585*a376eb32SXin Li# func_cygming_dll_for_implib ARG
3586*a376eb32SXin Li#
3587*a376eb32SXin Li# Platform-specific function to extract the
3588*a376eb32SXin Li# name of the DLL associated with the specified
3589*a376eb32SXin Li# import library ARG.
3590*a376eb32SXin Li# Invoked by eval'ing the libtool variable
3591*a376eb32SXin Li#    $sharedlib_from_linklib_cmd
3592*a376eb32SXin Li# Result is available in the variable
3593*a376eb32SXin Li#    $sharedlib_from_linklib_result
3594*a376eb32SXin Lifunc_cygming_dll_for_implib ()
3595*a376eb32SXin Li{
3596*a376eb32SXin Li  $opt_debug
3597*a376eb32SXin Li  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
3598*a376eb32SXin Li}
3599*a376eb32SXin Li
3600*a376eb32SXin Li# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
3601*a376eb32SXin Li#
3602*a376eb32SXin Li# The is the core of a fallback implementation of a
3603*a376eb32SXin Li# platform-specific function to extract the name of the
3604*a376eb32SXin Li# DLL associated with the specified import library LIBNAME.
3605*a376eb32SXin Li#
3606*a376eb32SXin Li# SECTION_NAME is either .idata$6 or .idata$7, depending
3607*a376eb32SXin Li# on the platform and compiler that created the implib.
3608*a376eb32SXin Li#
3609*a376eb32SXin Li# Echos the name of the DLL associated with the
3610*a376eb32SXin Li# specified import library.
3611*a376eb32SXin Lifunc_cygming_dll_for_implib_fallback_core ()
3612*a376eb32SXin Li{
3613*a376eb32SXin Li  $opt_debug
3614*a376eb32SXin Li  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
3615*a376eb32SXin Li  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
3616*a376eb32SXin Li    $SED '/^Contents of section '"$match_literal"':/{
3617*a376eb32SXin Li      # Place marker at beginning of archive member dllname section
3618*a376eb32SXin Li      s/.*/====MARK====/
3619*a376eb32SXin Li      p
3620*a376eb32SXin Li      d
3621*a376eb32SXin Li    }
3622*a376eb32SXin Li    # These lines can sometimes be longer than 43 characters, but
3623*a376eb32SXin Li    # are always uninteresting
3624*a376eb32SXin Li    /:[	 ]*file format pe[i]\{,1\}-/d
3625*a376eb32SXin Li    /^In archive [^:]*:/d
3626*a376eb32SXin Li    # Ensure marker is printed
3627*a376eb32SXin Li    /^====MARK====/p
3628*a376eb32SXin Li    # Remove all lines with less than 43 characters
3629*a376eb32SXin Li    /^.\{43\}/!d
3630*a376eb32SXin Li    # From remaining lines, remove first 43 characters
3631*a376eb32SXin Li    s/^.\{43\}//' |
3632*a376eb32SXin Li    $SED -n '
3633*a376eb32SXin Li      # Join marker and all lines until next marker into a single line
3634*a376eb32SXin Li      /^====MARK====/ b para
3635*a376eb32SXin Li      H
3636*a376eb32SXin Li      $ b para
3637*a376eb32SXin Li      b
3638*a376eb32SXin Li      :para
3639*a376eb32SXin Li      x
3640*a376eb32SXin Li      s/\n//g
3641*a376eb32SXin Li      # Remove the marker
3642*a376eb32SXin Li      s/^====MARK====//
3643*a376eb32SXin Li      # Remove trailing dots and whitespace
3644*a376eb32SXin Li      s/[\. \t]*$//
3645*a376eb32SXin Li      # Print
3646*a376eb32SXin Li      /./p' |
3647*a376eb32SXin Li    # we now have a list, one entry per line, of the stringified
3648*a376eb32SXin Li    # contents of the appropriate section of all members of the
3649*a376eb32SXin Li    # archive which possess that section. Heuristic: eliminate
3650*a376eb32SXin Li    # all those which have a first or second character that is
3651*a376eb32SXin Li    # a '.' (that is, objdump's representation of an unprintable
3652*a376eb32SXin Li    # character.) This should work for all archives with less than
3653*a376eb32SXin Li    # 0x302f exports -- but will fail for DLLs whose name actually
3654*a376eb32SXin Li    # begins with a literal '.' or a single character followed by
3655*a376eb32SXin Li    # a '.'.
3656*a376eb32SXin Li    #
3657*a376eb32SXin Li    # Of those that remain, print the first one.
3658*a376eb32SXin Li    $SED -e '/^\./d;/^.\./d;q'
3659*a376eb32SXin Li}
3660*a376eb32SXin Li
3661*a376eb32SXin Li# func_cygming_gnu_implib_p ARG
3662*a376eb32SXin Li# This predicate returns with zero status (TRUE) if
3663*a376eb32SXin Li# ARG is a GNU/binutils-style import library. Returns
3664*a376eb32SXin Li# with nonzero status (FALSE) otherwise.
3665*a376eb32SXin Lifunc_cygming_gnu_implib_p ()
3666*a376eb32SXin Li{
3667*a376eb32SXin Li  $opt_debug
3668*a376eb32SXin Li  func_to_tool_file "$1" func_convert_file_msys_to_w32
3669*a376eb32SXin Li  func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'`
3670*a376eb32SXin Li  test -n "$func_cygming_gnu_implib_tmp"
3671*a376eb32SXin Li}
3672*a376eb32SXin Li
3673*a376eb32SXin Li# func_cygming_ms_implib_p ARG
3674*a376eb32SXin Li# This predicate returns with zero status (TRUE) if
3675*a376eb32SXin Li# ARG is an MS-style import library. Returns
3676*a376eb32SXin Li# with nonzero status (FALSE) otherwise.
3677*a376eb32SXin Lifunc_cygming_ms_implib_p ()
3678*a376eb32SXin Li{
3679*a376eb32SXin Li  $opt_debug
3680*a376eb32SXin Li  func_to_tool_file "$1" func_convert_file_msys_to_w32
3681*a376eb32SXin Li  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
3682*a376eb32SXin Li  test -n "$func_cygming_ms_implib_tmp"
3683*a376eb32SXin Li}
3684*a376eb32SXin Li
3685*a376eb32SXin Li# func_cygming_dll_for_implib_fallback ARG
3686*a376eb32SXin Li# Platform-specific function to extract the
3687*a376eb32SXin Li# name of the DLL associated with the specified
3688*a376eb32SXin Li# import library ARG.
3689*a376eb32SXin Li#
3690*a376eb32SXin Li# This fallback implementation is for use when $DLLTOOL
3691*a376eb32SXin Li# does not support the --identify-strict option.
3692*a376eb32SXin Li# Invoked by eval'ing the libtool variable
3693*a376eb32SXin Li#    $sharedlib_from_linklib_cmd
3694*a376eb32SXin Li# Result is available in the variable
3695*a376eb32SXin Li#    $sharedlib_from_linklib_result
3696*a376eb32SXin Lifunc_cygming_dll_for_implib_fallback ()
3697*a376eb32SXin Li{
3698*a376eb32SXin Li  $opt_debug
3699*a376eb32SXin Li  if func_cygming_gnu_implib_p "$1" ; then
3700*a376eb32SXin Li    # binutils import library
3701*a376eb32SXin Li    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
3702*a376eb32SXin Li  elif func_cygming_ms_implib_p "$1" ; then
3703*a376eb32SXin Li    # ms-generated import library
3704*a376eb32SXin Li    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
3705*a376eb32SXin Li  else
3706*a376eb32SXin Li    # unknown
3707*a376eb32SXin Li    sharedlib_from_linklib_result=""
3708*a376eb32SXin Li  fi
3709*a376eb32SXin Li}
3710*a376eb32SXin Li
3711*a376eb32SXin Li
3712*a376eb32SXin Li# func_extract_an_archive dir oldlib
3713*a376eb32SXin Lifunc_extract_an_archive ()
3714*a376eb32SXin Li{
3715*a376eb32SXin Li    $opt_debug
3716*a376eb32SXin Li    f_ex_an_ar_dir="$1"; shift
3717*a376eb32SXin Li    f_ex_an_ar_oldlib="$1"
3718*a376eb32SXin Li    if test "$lock_old_archive_extraction" = yes; then
3719*a376eb32SXin Li      lockfile=$f_ex_an_ar_oldlib.lock
3720*a376eb32SXin Li      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
3721*a376eb32SXin Li	func_echo "Waiting for $lockfile to be removed"
3722*a376eb32SXin Li	sleep 2
3723*a376eb32SXin Li      done
3724*a376eb32SXin Li    fi
3725*a376eb32SXin Li    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
3726*a376eb32SXin Li		   'stat=$?; rm -f "$lockfile"; exit $stat'
3727*a376eb32SXin Li    if test "$lock_old_archive_extraction" = yes; then
3728*a376eb32SXin Li      $opt_dry_run || rm -f "$lockfile"
3729*a376eb32SXin Li    fi
3730*a376eb32SXin Li    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
3731*a376eb32SXin Li     :
3732*a376eb32SXin Li    else
3733*a376eb32SXin Li      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
3734*a376eb32SXin Li    fi
3735*a376eb32SXin Li}
3736*a376eb32SXin Li
3737*a376eb32SXin Li
3738*a376eb32SXin Li# func_extract_archives gentop oldlib ...
3739*a376eb32SXin Lifunc_extract_archives ()
3740*a376eb32SXin Li{
3741*a376eb32SXin Li    $opt_debug
3742*a376eb32SXin Li    my_gentop="$1"; shift
3743*a376eb32SXin Li    my_oldlibs=${1+"$@"}
3744*a376eb32SXin Li    my_oldobjs=""
3745*a376eb32SXin Li    my_xlib=""
3746*a376eb32SXin Li    my_xabs=""
3747*a376eb32SXin Li    my_xdir=""
3748*a376eb32SXin Li
3749*a376eb32SXin Li    for my_xlib in $my_oldlibs; do
3750*a376eb32SXin Li      # Extract the objects.
3751*a376eb32SXin Li      case $my_xlib in
3752*a376eb32SXin Li	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
3753*a376eb32SXin Li	*) my_xabs=`pwd`"/$my_xlib" ;;
3754*a376eb32SXin Li      esac
3755*a376eb32SXin Li      func_basename "$my_xlib"
3756*a376eb32SXin Li      my_xlib="$func_basename_result"
3757*a376eb32SXin Li      my_xlib_u=$my_xlib
3758*a376eb32SXin Li      while :; do
3759*a376eb32SXin Li        case " $extracted_archives " in
3760*a376eb32SXin Li	*" $my_xlib_u "*)
3761*a376eb32SXin Li	  func_arith $extracted_serial + 1
3762*a376eb32SXin Li	  extracted_serial=$func_arith_result
3763*a376eb32SXin Li	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
3764*a376eb32SXin Li	*) break ;;
3765*a376eb32SXin Li	esac
3766*a376eb32SXin Li      done
3767*a376eb32SXin Li      extracted_archives="$extracted_archives $my_xlib_u"
3768*a376eb32SXin Li      my_xdir="$my_gentop/$my_xlib_u"
3769*a376eb32SXin Li
3770*a376eb32SXin Li      func_mkdir_p "$my_xdir"
3771*a376eb32SXin Li
3772*a376eb32SXin Li      case $host in
3773*a376eb32SXin Li      *-darwin*)
3774*a376eb32SXin Li	func_verbose "Extracting $my_xabs"
3775*a376eb32SXin Li	# Do not bother doing anything if just a dry run
3776*a376eb32SXin Li	$opt_dry_run || {
3777*a376eb32SXin Li	  darwin_orig_dir=`pwd`
3778*a376eb32SXin Li	  cd $my_xdir || exit $?
3779*a376eb32SXin Li	  darwin_archive=$my_xabs
3780*a376eb32SXin Li	  darwin_curdir=`pwd`
3781*a376eb32SXin Li	  darwin_base_archive=`basename "$darwin_archive"`
3782*a376eb32SXin Li	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
3783*a376eb32SXin Li	  if test -n "$darwin_arches"; then
3784*a376eb32SXin Li	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
3785*a376eb32SXin Li	    darwin_arch=
3786*a376eb32SXin Li	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
3787*a376eb32SXin Li	    for darwin_arch in  $darwin_arches ; do
3788*a376eb32SXin Li	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3789*a376eb32SXin Li	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
3790*a376eb32SXin Li	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3791*a376eb32SXin Li	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
3792*a376eb32SXin Li	      cd "$darwin_curdir"
3793*a376eb32SXin Li	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
3794*a376eb32SXin Li	    done # $darwin_arches
3795*a376eb32SXin Li            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
3796*a376eb32SXin Li	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
3797*a376eb32SXin Li	    darwin_file=
3798*a376eb32SXin Li	    darwin_files=
3799*a376eb32SXin Li	    for darwin_file in $darwin_filelist; do
3800*a376eb32SXin Li	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
3801*a376eb32SXin Li	      $LIPO -create -output "$darwin_file" $darwin_files
3802*a376eb32SXin Li	    done # $darwin_filelist
3803*a376eb32SXin Li	    $RM -rf unfat-$$
3804*a376eb32SXin Li	    cd "$darwin_orig_dir"
3805*a376eb32SXin Li	  else
3806*a376eb32SXin Li	    cd $darwin_orig_dir
3807*a376eb32SXin Li	    func_extract_an_archive "$my_xdir" "$my_xabs"
3808*a376eb32SXin Li	  fi # $darwin_arches
3809*a376eb32SXin Li	} # !$opt_dry_run
3810*a376eb32SXin Li	;;
3811*a376eb32SXin Li      *)
3812*a376eb32SXin Li        func_extract_an_archive "$my_xdir" "$my_xabs"
3813*a376eb32SXin Li	;;
3814*a376eb32SXin Li      esac
3815*a376eb32SXin Li      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
3816*a376eb32SXin Li    done
3817*a376eb32SXin Li
3818*a376eb32SXin Li    func_extract_archives_result="$my_oldobjs"
3819*a376eb32SXin Li}
3820*a376eb32SXin Li
3821*a376eb32SXin Li
3822*a376eb32SXin Li# func_emit_wrapper [arg=no]
3823*a376eb32SXin Li#
3824*a376eb32SXin Li# Emit a libtool wrapper script on stdout.
3825*a376eb32SXin Li# Don't directly open a file because we may want to
3826*a376eb32SXin Li# incorporate the script contents within a cygwin/mingw
3827*a376eb32SXin Li# wrapper executable.  Must ONLY be called from within
3828*a376eb32SXin Li# func_mode_link because it depends on a number of variables
3829*a376eb32SXin Li# set therein.
3830*a376eb32SXin Li#
3831*a376eb32SXin Li# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
3832*a376eb32SXin Li# variable will take.  If 'yes', then the emitted script
3833*a376eb32SXin Li# will assume that the directory in which it is stored is
3834*a376eb32SXin Li# the $objdir directory.  This is a cygwin/mingw-specific
3835*a376eb32SXin Li# behavior.
3836*a376eb32SXin Lifunc_emit_wrapper ()
3837*a376eb32SXin Li{
3838*a376eb32SXin Li	func_emit_wrapper_arg1=${1-no}
3839*a376eb32SXin Li
3840*a376eb32SXin Li	$ECHO "\
3841*a376eb32SXin Li#! $SHELL
3842*a376eb32SXin Li
3843*a376eb32SXin Li# $output - temporary wrapper script for $objdir/$outputname
3844*a376eb32SXin Li# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
3845*a376eb32SXin Li#
3846*a376eb32SXin Li# The $output program cannot be directly executed until all the libtool
3847*a376eb32SXin Li# libraries that it depends on are installed.
3848*a376eb32SXin Li#
3849*a376eb32SXin Li# This wrapper script should never be moved out of the build directory.
3850*a376eb32SXin Li# If it is, it will not operate correctly.
3851*a376eb32SXin Li
3852*a376eb32SXin Li# Sed substitution that helps us do robust quoting.  It backslashifies
3853*a376eb32SXin Li# metacharacters that are still active within double-quoted strings.
3854*a376eb32SXin Lised_quote_subst='$sed_quote_subst'
3855*a376eb32SXin Li
3856*a376eb32SXin Li# Be Bourne compatible
3857*a376eb32SXin Liif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
3858*a376eb32SXin Li  emulate sh
3859*a376eb32SXin Li  NULLCMD=:
3860*a376eb32SXin Li  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
3861*a376eb32SXin Li  # is contrary to our usage.  Disable this feature.
3862*a376eb32SXin Li  alias -g '\${1+\"\$@\"}'='\"\$@\"'
3863*a376eb32SXin Li  setopt NO_GLOB_SUBST
3864*a376eb32SXin Lielse
3865*a376eb32SXin Li  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
3866*a376eb32SXin Lifi
3867*a376eb32SXin LiBIN_SH=xpg4; export BIN_SH # for Tru64
3868*a376eb32SXin LiDUALCASE=1; export DUALCASE # for MKS sh
3869*a376eb32SXin Li
3870*a376eb32SXin Li# The HP-UX ksh and POSIX shell print the target directory to stdout
3871*a376eb32SXin Li# if CDPATH is set.
3872*a376eb32SXin Li(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
3873*a376eb32SXin Li
3874*a376eb32SXin Lirelink_command=\"$relink_command\"
3875*a376eb32SXin Li
3876*a376eb32SXin Li# This environment variable determines our operation mode.
3877*a376eb32SXin Liif test \"\$libtool_install_magic\" = \"$magic\"; then
3878*a376eb32SXin Li  # install mode needs the following variables:
3879*a376eb32SXin Li  generated_by_libtool_version='$macro_version'
3880*a376eb32SXin Li  notinst_deplibs='$notinst_deplibs'
3881*a376eb32SXin Lielse
3882*a376eb32SXin Li  # When we are sourced in execute mode, \$file and \$ECHO are already set.
3883*a376eb32SXin Li  if test \"\$libtool_execute_magic\" != \"$magic\"; then
3884*a376eb32SXin Li    file=\"\$0\""
3885*a376eb32SXin Li
3886*a376eb32SXin Li    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
3887*a376eb32SXin Li    $ECHO "\
3888*a376eb32SXin Li
3889*a376eb32SXin Li# A function that is used when there is no print builtin or printf.
3890*a376eb32SXin Lifunc_fallback_echo ()
3891*a376eb32SXin Li{
3892*a376eb32SXin Li  eval 'cat <<_LTECHO_EOF
3893*a376eb32SXin Li\$1
3894*a376eb32SXin Li_LTECHO_EOF'
3895*a376eb32SXin Li}
3896*a376eb32SXin Li    ECHO=\"$qECHO\"
3897*a376eb32SXin Li  fi
3898*a376eb32SXin Li
3899*a376eb32SXin Li# Very basic option parsing. These options are (a) specific to
3900*a376eb32SXin Li# the libtool wrapper, (b) are identical between the wrapper
3901*a376eb32SXin Li# /script/ and the wrapper /executable/ which is used only on
3902*a376eb32SXin Li# windows platforms, and (c) all begin with the string "--lt-"
3903*a376eb32SXin Li# (application programs are unlikely to have options which match
3904*a376eb32SXin Li# this pattern).
3905*a376eb32SXin Li#
3906*a376eb32SXin Li# There are only two supported options: --lt-debug and
3907*a376eb32SXin Li# --lt-dump-script. There is, deliberately, no --lt-help.
3908*a376eb32SXin Li#
3909*a376eb32SXin Li# The first argument to this parsing function should be the
3910*a376eb32SXin Li# script's $0 value, followed by "$@".
3911*a376eb32SXin Lilt_option_debug=
3912*a376eb32SXin Lifunc_parse_lt_options ()
3913*a376eb32SXin Li{
3914*a376eb32SXin Li  lt_script_arg0=\$0
3915*a376eb32SXin Li  shift
3916*a376eb32SXin Li  for lt_opt
3917*a376eb32SXin Li  do
3918*a376eb32SXin Li    case \"\$lt_opt\" in
3919*a376eb32SXin Li    --lt-debug) lt_option_debug=1 ;;
3920*a376eb32SXin Li    --lt-dump-script)
3921*a376eb32SXin Li        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
3922*a376eb32SXin Li        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
3923*a376eb32SXin Li        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
3924*a376eb32SXin Li        cat \"\$lt_dump_D/\$lt_dump_F\"
3925*a376eb32SXin Li        exit 0
3926*a376eb32SXin Li      ;;
3927*a376eb32SXin Li    --lt-*)
3928*a376eb32SXin Li        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
3929*a376eb32SXin Li        exit 1
3930*a376eb32SXin Li      ;;
3931*a376eb32SXin Li    esac
3932*a376eb32SXin Li  done
3933*a376eb32SXin Li
3934*a376eb32SXin Li  # Print the debug banner immediately:
3935*a376eb32SXin Li  if test -n \"\$lt_option_debug\"; then
3936*a376eb32SXin Li    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
3937*a376eb32SXin Li  fi
3938*a376eb32SXin Li}
3939*a376eb32SXin Li
3940*a376eb32SXin Li# Used when --lt-debug. Prints its arguments to stdout
3941*a376eb32SXin Li# (redirection is the responsibility of the caller)
3942*a376eb32SXin Lifunc_lt_dump_args ()
3943*a376eb32SXin Li{
3944*a376eb32SXin Li  lt_dump_args_N=1;
3945*a376eb32SXin Li  for lt_arg
3946*a376eb32SXin Li  do
3947*a376eb32SXin Li    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
3948*a376eb32SXin Li    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
3949*a376eb32SXin Li  done
3950*a376eb32SXin Li}
3951*a376eb32SXin Li
3952*a376eb32SXin Li# Core function for launching the target application
3953*a376eb32SXin Lifunc_exec_program_core ()
3954*a376eb32SXin Li{
3955*a376eb32SXin Li"
3956*a376eb32SXin Li  case $host in
3957*a376eb32SXin Li  # Backslashes separate directories on plain windows
3958*a376eb32SXin Li  *-*-mingw | *-*-os2* | *-cegcc*)
3959*a376eb32SXin Li    $ECHO "\
3960*a376eb32SXin Li      if test -n \"\$lt_option_debug\"; then
3961*a376eb32SXin Li        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
3962*a376eb32SXin Li        func_lt_dump_args \${1+\"\$@\"} 1>&2
3963*a376eb32SXin Li      fi
3964*a376eb32SXin Li      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
3965*a376eb32SXin Li"
3966*a376eb32SXin Li    ;;
3967*a376eb32SXin Li
3968*a376eb32SXin Li  *)
3969*a376eb32SXin Li    $ECHO "\
3970*a376eb32SXin Li      if test -n \"\$lt_option_debug\"; then
3971*a376eb32SXin Li        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
3972*a376eb32SXin Li        func_lt_dump_args \${1+\"\$@\"} 1>&2
3973*a376eb32SXin Li      fi
3974*a376eb32SXin Li      exec \"\$progdir/\$program\" \${1+\"\$@\"}
3975*a376eb32SXin Li"
3976*a376eb32SXin Li    ;;
3977*a376eb32SXin Li  esac
3978*a376eb32SXin Li  $ECHO "\
3979*a376eb32SXin Li      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
3980*a376eb32SXin Li      exit 1
3981*a376eb32SXin Li}
3982*a376eb32SXin Li
3983*a376eb32SXin Li# A function to encapsulate launching the target application
3984*a376eb32SXin Li# Strips options in the --lt-* namespace from \$@ and
3985*a376eb32SXin Li# launches target application with the remaining arguments.
3986*a376eb32SXin Lifunc_exec_program ()
3987*a376eb32SXin Li{
3988*a376eb32SXin Li  case \" \$* \" in
3989*a376eb32SXin Li  *\\ --lt-*)
3990*a376eb32SXin Li    for lt_wr_arg
3991*a376eb32SXin Li    do
3992*a376eb32SXin Li      case \$lt_wr_arg in
3993*a376eb32SXin Li      --lt-*) ;;
3994*a376eb32SXin Li      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
3995*a376eb32SXin Li      esac
3996*a376eb32SXin Li      shift
3997*a376eb32SXin Li    done ;;
3998*a376eb32SXin Li  esac
3999*a376eb32SXin Li  func_exec_program_core \${1+\"\$@\"}
4000*a376eb32SXin Li}
4001*a376eb32SXin Li
4002*a376eb32SXin Li  # Parse options
4003*a376eb32SXin Li  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
4004*a376eb32SXin Li
4005*a376eb32SXin Li  # Find the directory that this script lives in.
4006*a376eb32SXin Li  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
4007*a376eb32SXin Li  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
4008*a376eb32SXin Li
4009*a376eb32SXin Li  # Follow symbolic links until we get to the real thisdir.
4010*a376eb32SXin Li  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
4011*a376eb32SXin Li  while test -n \"\$file\"; do
4012*a376eb32SXin Li    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
4013*a376eb32SXin Li
4014*a376eb32SXin Li    # If there was a directory component, then change thisdir.
4015*a376eb32SXin Li    if test \"x\$destdir\" != \"x\$file\"; then
4016*a376eb32SXin Li      case \"\$destdir\" in
4017*a376eb32SXin Li      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
4018*a376eb32SXin Li      *) thisdir=\"\$thisdir/\$destdir\" ;;
4019*a376eb32SXin Li      esac
4020*a376eb32SXin Li    fi
4021*a376eb32SXin Li
4022*a376eb32SXin Li    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
4023*a376eb32SXin Li    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
4024*a376eb32SXin Li  done
4025*a376eb32SXin Li
4026*a376eb32SXin Li  # Usually 'no', except on cygwin/mingw when embedded into
4027*a376eb32SXin Li  # the cwrapper.
4028*a376eb32SXin Li  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
4029*a376eb32SXin Li  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
4030*a376eb32SXin Li    # special case for '.'
4031*a376eb32SXin Li    if test \"\$thisdir\" = \".\"; then
4032*a376eb32SXin Li      thisdir=\`pwd\`
4033*a376eb32SXin Li    fi
4034*a376eb32SXin Li    # remove .libs from thisdir
4035*a376eb32SXin Li    case \"\$thisdir\" in
4036*a376eb32SXin Li    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
4037*a376eb32SXin Li    $objdir )   thisdir=. ;;
4038*a376eb32SXin Li    esac
4039*a376eb32SXin Li  fi
4040*a376eb32SXin Li
4041*a376eb32SXin Li  # Try to get the absolute directory name.
4042*a376eb32SXin Li  absdir=\`cd \"\$thisdir\" && pwd\`
4043*a376eb32SXin Li  test -n \"\$absdir\" && thisdir=\"\$absdir\"
4044*a376eb32SXin Li"
4045*a376eb32SXin Li
4046*a376eb32SXin Li	if test "$fast_install" = yes; then
4047*a376eb32SXin Li	  $ECHO "\
4048*a376eb32SXin Li  program=lt-'$outputname'$exeext
4049*a376eb32SXin Li  progdir=\"\$thisdir/$objdir\"
4050*a376eb32SXin Li
4051*a376eb32SXin Li  if test ! -f \"\$progdir/\$program\" ||
4052*a376eb32SXin Li     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
4053*a376eb32SXin Li       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
4054*a376eb32SXin Li
4055*a376eb32SXin Li    file=\"\$\$-\$program\"
4056*a376eb32SXin Li
4057*a376eb32SXin Li    if test ! -d \"\$progdir\"; then
4058*a376eb32SXin Li      $MKDIR \"\$progdir\"
4059*a376eb32SXin Li    else
4060*a376eb32SXin Li      $RM \"\$progdir/\$file\"
4061*a376eb32SXin Li    fi"
4062*a376eb32SXin Li
4063*a376eb32SXin Li	  $ECHO "\
4064*a376eb32SXin Li
4065*a376eb32SXin Li    # relink executable if necessary
4066*a376eb32SXin Li    if test -n \"\$relink_command\"; then
4067*a376eb32SXin Li      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
4068*a376eb32SXin Li      else
4069*a376eb32SXin Li	$ECHO \"\$relink_command_output\" >&2
4070*a376eb32SXin Li	$RM \"\$progdir/\$file\"
4071*a376eb32SXin Li	exit 1
4072*a376eb32SXin Li      fi
4073*a376eb32SXin Li    fi
4074*a376eb32SXin Li
4075*a376eb32SXin Li    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
4076*a376eb32SXin Li    { $RM \"\$progdir/\$program\";
4077*a376eb32SXin Li      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
4078*a376eb32SXin Li    $RM \"\$progdir/\$file\"
4079*a376eb32SXin Li  fi"
4080*a376eb32SXin Li	else
4081*a376eb32SXin Li	  $ECHO "\
4082*a376eb32SXin Li  program='$outputname'
4083*a376eb32SXin Li  progdir=\"\$thisdir/$objdir\"
4084*a376eb32SXin Li"
4085*a376eb32SXin Li	fi
4086*a376eb32SXin Li
4087*a376eb32SXin Li	$ECHO "\
4088*a376eb32SXin Li
4089*a376eb32SXin Li  if test -f \"\$progdir/\$program\"; then"
4090*a376eb32SXin Li
4091*a376eb32SXin Li	# fixup the dll searchpath if we need to.
4092*a376eb32SXin Li	#
4093*a376eb32SXin Li	# Fix the DLL searchpath if we need to.  Do this before prepending
4094*a376eb32SXin Li	# to shlibpath, because on Windows, both are PATH and uninstalled
4095*a376eb32SXin Li	# libraries must come first.
4096*a376eb32SXin Li	if test -n "$dllsearchpath"; then
4097*a376eb32SXin Li	  $ECHO "\
4098*a376eb32SXin Li    # Add the dll search path components to the executable PATH
4099*a376eb32SXin Li    PATH=$dllsearchpath:\$PATH
4100*a376eb32SXin Li"
4101*a376eb32SXin Li	fi
4102*a376eb32SXin Li
4103*a376eb32SXin Li	# Export our shlibpath_var if we have one.
4104*a376eb32SXin Li	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4105*a376eb32SXin Li	  $ECHO "\
4106*a376eb32SXin Li    # Add our own library path to $shlibpath_var
4107*a376eb32SXin Li    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
4108*a376eb32SXin Li
4109*a376eb32SXin Li    # Some systems cannot cope with colon-terminated $shlibpath_var
4110*a376eb32SXin Li    # The second colon is a workaround for a bug in BeOS R4 sed
4111*a376eb32SXin Li    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
4112*a376eb32SXin Li
4113*a376eb32SXin Li    export $shlibpath_var
4114*a376eb32SXin Li"
4115*a376eb32SXin Li	fi
4116*a376eb32SXin Li
4117*a376eb32SXin Li	$ECHO "\
4118*a376eb32SXin Li    if test \"\$libtool_execute_magic\" != \"$magic\"; then
4119*a376eb32SXin Li      # Run the actual program with our arguments.
4120*a376eb32SXin Li      func_exec_program \${1+\"\$@\"}
4121*a376eb32SXin Li    fi
4122*a376eb32SXin Li  else
4123*a376eb32SXin Li    # The program doesn't exist.
4124*a376eb32SXin Li    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
4125*a376eb32SXin Li    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
4126*a376eb32SXin Li    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
4127*a376eb32SXin Li    exit 1
4128*a376eb32SXin Li  fi
4129*a376eb32SXin Lifi\
4130*a376eb32SXin Li"
4131*a376eb32SXin Li}
4132*a376eb32SXin Li
4133*a376eb32SXin Li
4134*a376eb32SXin Li# func_emit_cwrapperexe_src
4135*a376eb32SXin Li# emit the source code for a wrapper executable on stdout
4136*a376eb32SXin Li# Must ONLY be called from within func_mode_link because
4137*a376eb32SXin Li# it depends on a number of variable set therein.
4138*a376eb32SXin Lifunc_emit_cwrapperexe_src ()
4139*a376eb32SXin Li{
4140*a376eb32SXin Li	cat <<EOF
4141*a376eb32SXin Li
4142*a376eb32SXin Li/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
4143*a376eb32SXin Li   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
4144*a376eb32SXin Li
4145*a376eb32SXin Li   The $output program cannot be directly executed until all the libtool
4146*a376eb32SXin Li   libraries that it depends on are installed.
4147*a376eb32SXin Li
4148*a376eb32SXin Li   This wrapper executable should never be moved out of the build directory.
4149*a376eb32SXin Li   If it is, it will not operate correctly.
4150*a376eb32SXin Li*/
4151*a376eb32SXin LiEOF
4152*a376eb32SXin Li	    cat <<"EOF"
4153*a376eb32SXin Li#ifdef _MSC_VER
4154*a376eb32SXin Li# define _CRT_SECURE_NO_DEPRECATE 1
4155*a376eb32SXin Li#endif
4156*a376eb32SXin Li#include <stdio.h>
4157*a376eb32SXin Li#include <stdlib.h>
4158*a376eb32SXin Li#ifdef _MSC_VER
4159*a376eb32SXin Li# include <direct.h>
4160*a376eb32SXin Li# include <process.h>
4161*a376eb32SXin Li# include <io.h>
4162*a376eb32SXin Li#else
4163*a376eb32SXin Li# include <unistd.h>
4164*a376eb32SXin Li# include <stdint.h>
4165*a376eb32SXin Li# ifdef __CYGWIN__
4166*a376eb32SXin Li#  include <io.h>
4167*a376eb32SXin Li# endif
4168*a376eb32SXin Li#endif
4169*a376eb32SXin Li#include <malloc.h>
4170*a376eb32SXin Li#include <stdarg.h>
4171*a376eb32SXin Li#include <assert.h>
4172*a376eb32SXin Li#include <string.h>
4173*a376eb32SXin Li#include <ctype.h>
4174*a376eb32SXin Li#include <errno.h>
4175*a376eb32SXin Li#include <fcntl.h>
4176*a376eb32SXin Li#include <sys/stat.h>
4177*a376eb32SXin Li
4178*a376eb32SXin Li/* declarations of non-ANSI functions */
4179*a376eb32SXin Li#if defined(__MINGW32__)
4180*a376eb32SXin Li# ifdef __STRICT_ANSI__
4181*a376eb32SXin Liint _putenv (const char *);
4182*a376eb32SXin Li# endif
4183*a376eb32SXin Li#elif defined(__CYGWIN__)
4184*a376eb32SXin Li# ifdef __STRICT_ANSI__
4185*a376eb32SXin Lichar *realpath (const char *, char *);
4186*a376eb32SXin Liint putenv (char *);
4187*a376eb32SXin Liint setenv (const char *, const char *, int);
4188*a376eb32SXin Li# endif
4189*a376eb32SXin Li/* #elif defined (other platforms) ... */
4190*a376eb32SXin Li#endif
4191*a376eb32SXin Li
4192*a376eb32SXin Li/* portability defines, excluding path handling macros */
4193*a376eb32SXin Li#if defined(_MSC_VER)
4194*a376eb32SXin Li# define setmode _setmode
4195*a376eb32SXin Li# define stat    _stat
4196*a376eb32SXin Li# define chmod   _chmod
4197*a376eb32SXin Li# define getcwd  _getcwd
4198*a376eb32SXin Li# define putenv  _putenv
4199*a376eb32SXin Li# define S_IXUSR _S_IEXEC
4200*a376eb32SXin Li# ifndef _INTPTR_T_DEFINED
4201*a376eb32SXin Li#  define _INTPTR_T_DEFINED
4202*a376eb32SXin Li#  define intptr_t int
4203*a376eb32SXin Li# endif
4204*a376eb32SXin Li#elif defined(__MINGW32__)
4205*a376eb32SXin Li# define setmode _setmode
4206*a376eb32SXin Li# define stat    _stat
4207*a376eb32SXin Li# define chmod   _chmod
4208*a376eb32SXin Li# define getcwd  _getcwd
4209*a376eb32SXin Li# define putenv  _putenv
4210*a376eb32SXin Li#elif defined(__CYGWIN__)
4211*a376eb32SXin Li# define HAVE_SETENV
4212*a376eb32SXin Li# define FOPEN_WB "wb"
4213*a376eb32SXin Li/* #elif defined (other platforms) ... */
4214*a376eb32SXin Li#endif
4215*a376eb32SXin Li
4216*a376eb32SXin Li#if defined(PATH_MAX)
4217*a376eb32SXin Li# define LT_PATHMAX PATH_MAX
4218*a376eb32SXin Li#elif defined(MAXPATHLEN)
4219*a376eb32SXin Li# define LT_PATHMAX MAXPATHLEN
4220*a376eb32SXin Li#else
4221*a376eb32SXin Li# define LT_PATHMAX 1024
4222*a376eb32SXin Li#endif
4223*a376eb32SXin Li
4224*a376eb32SXin Li#ifndef S_IXOTH
4225*a376eb32SXin Li# define S_IXOTH 0
4226*a376eb32SXin Li#endif
4227*a376eb32SXin Li#ifndef S_IXGRP
4228*a376eb32SXin Li# define S_IXGRP 0
4229*a376eb32SXin Li#endif
4230*a376eb32SXin Li
4231*a376eb32SXin Li/* path handling portability macros */
4232*a376eb32SXin Li#ifndef DIR_SEPARATOR
4233*a376eb32SXin Li# define DIR_SEPARATOR '/'
4234*a376eb32SXin Li# define PATH_SEPARATOR ':'
4235*a376eb32SXin Li#endif
4236*a376eb32SXin Li
4237*a376eb32SXin Li#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
4238*a376eb32SXin Li  defined (__OS2__)
4239*a376eb32SXin Li# define HAVE_DOS_BASED_FILE_SYSTEM
4240*a376eb32SXin Li# define FOPEN_WB "wb"
4241*a376eb32SXin Li# ifndef DIR_SEPARATOR_2
4242*a376eb32SXin Li#  define DIR_SEPARATOR_2 '\\'
4243*a376eb32SXin Li# endif
4244*a376eb32SXin Li# ifndef PATH_SEPARATOR_2
4245*a376eb32SXin Li#  define PATH_SEPARATOR_2 ';'
4246*a376eb32SXin Li# endif
4247*a376eb32SXin Li#endif
4248*a376eb32SXin Li
4249*a376eb32SXin Li#ifndef DIR_SEPARATOR_2
4250*a376eb32SXin Li# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
4251*a376eb32SXin Li#else /* DIR_SEPARATOR_2 */
4252*a376eb32SXin Li# define IS_DIR_SEPARATOR(ch) \
4253*a376eb32SXin Li	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
4254*a376eb32SXin Li#endif /* DIR_SEPARATOR_2 */
4255*a376eb32SXin Li
4256*a376eb32SXin Li#ifndef PATH_SEPARATOR_2
4257*a376eb32SXin Li# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
4258*a376eb32SXin Li#else /* PATH_SEPARATOR_2 */
4259*a376eb32SXin Li# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
4260*a376eb32SXin Li#endif /* PATH_SEPARATOR_2 */
4261*a376eb32SXin Li
4262*a376eb32SXin Li#ifndef FOPEN_WB
4263*a376eb32SXin Li# define FOPEN_WB "w"
4264*a376eb32SXin Li#endif
4265*a376eb32SXin Li#ifndef _O_BINARY
4266*a376eb32SXin Li# define _O_BINARY 0
4267*a376eb32SXin Li#endif
4268*a376eb32SXin Li
4269*a376eb32SXin Li#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
4270*a376eb32SXin Li#define XFREE(stale) do { \
4271*a376eb32SXin Li  if (stale) { free ((void *) stale); stale = 0; } \
4272*a376eb32SXin Li} while (0)
4273*a376eb32SXin Li
4274*a376eb32SXin Li#if defined(LT_DEBUGWRAPPER)
4275*a376eb32SXin Listatic int lt_debug = 1;
4276*a376eb32SXin Li#else
4277*a376eb32SXin Listatic int lt_debug = 0;
4278*a376eb32SXin Li#endif
4279*a376eb32SXin Li
4280*a376eb32SXin Liconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
4281*a376eb32SXin Li
4282*a376eb32SXin Livoid *xmalloc (size_t num);
4283*a376eb32SXin Lichar *xstrdup (const char *string);
4284*a376eb32SXin Liconst char *base_name (const char *name);
4285*a376eb32SXin Lichar *find_executable (const char *wrapper);
4286*a376eb32SXin Lichar *chase_symlinks (const char *pathspec);
4287*a376eb32SXin Liint make_executable (const char *path);
4288*a376eb32SXin Liint check_executable (const char *path);
4289*a376eb32SXin Lichar *strendzap (char *str, const char *pat);
4290*a376eb32SXin Livoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
4291*a376eb32SXin Livoid lt_fatal (const char *file, int line, const char *message, ...);
4292*a376eb32SXin Listatic const char *nonnull (const char *s);
4293*a376eb32SXin Listatic const char *nonempty (const char *s);
4294*a376eb32SXin Livoid lt_setenv (const char *name, const char *value);
4295*a376eb32SXin Lichar *lt_extend_str (const char *orig_value, const char *add, int to_end);
4296*a376eb32SXin Livoid lt_update_exe_path (const char *name, const char *value);
4297*a376eb32SXin Livoid lt_update_lib_path (const char *name, const char *value);
4298*a376eb32SXin Lichar **prepare_spawn (char **argv);
4299*a376eb32SXin Livoid lt_dump_script (FILE *f);
4300*a376eb32SXin LiEOF
4301*a376eb32SXin Li
4302*a376eb32SXin Li	    cat <<EOF
4303*a376eb32SXin Livolatile const char * MAGIC_EXE = "$magic_exe";
4304*a376eb32SXin Liconst char * LIB_PATH_VARNAME = "$shlibpath_var";
4305*a376eb32SXin LiEOF
4306*a376eb32SXin Li
4307*a376eb32SXin Li	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4308*a376eb32SXin Li              func_to_host_path "$temp_rpath"
4309*a376eb32SXin Li	      cat <<EOF
4310*a376eb32SXin Liconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
4311*a376eb32SXin LiEOF
4312*a376eb32SXin Li	    else
4313*a376eb32SXin Li	      cat <<"EOF"
4314*a376eb32SXin Liconst char * LIB_PATH_VALUE   = "";
4315*a376eb32SXin LiEOF
4316*a376eb32SXin Li	    fi
4317*a376eb32SXin Li
4318*a376eb32SXin Li	    if test -n "$dllsearchpath"; then
4319*a376eb32SXin Li              func_to_host_path "$dllsearchpath:"
4320*a376eb32SXin Li	      cat <<EOF
4321*a376eb32SXin Liconst char * EXE_PATH_VARNAME = "PATH";
4322*a376eb32SXin Liconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
4323*a376eb32SXin LiEOF
4324*a376eb32SXin Li	    else
4325*a376eb32SXin Li	      cat <<"EOF"
4326*a376eb32SXin Liconst char * EXE_PATH_VARNAME = "";
4327*a376eb32SXin Liconst char * EXE_PATH_VALUE   = "";
4328*a376eb32SXin LiEOF
4329*a376eb32SXin Li	    fi
4330*a376eb32SXin Li
4331*a376eb32SXin Li	    if test "$fast_install" = yes; then
4332*a376eb32SXin Li	      cat <<EOF
4333*a376eb32SXin Liconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
4334*a376eb32SXin LiEOF
4335*a376eb32SXin Li	    else
4336*a376eb32SXin Li	      cat <<EOF
4337*a376eb32SXin Liconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
4338*a376eb32SXin LiEOF
4339*a376eb32SXin Li	    fi
4340*a376eb32SXin Li
4341*a376eb32SXin Li
4342*a376eb32SXin Li	    cat <<"EOF"
4343*a376eb32SXin Li
4344*a376eb32SXin Li#define LTWRAPPER_OPTION_PREFIX         "--lt-"
4345*a376eb32SXin Li
4346*a376eb32SXin Listatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
4347*a376eb32SXin Listatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
4348*a376eb32SXin Listatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
4349*a376eb32SXin Li
4350*a376eb32SXin Liint
4351*a376eb32SXin Limain (int argc, char *argv[])
4352*a376eb32SXin Li{
4353*a376eb32SXin Li  char **newargz;
4354*a376eb32SXin Li  int  newargc;
4355*a376eb32SXin Li  char *tmp_pathspec;
4356*a376eb32SXin Li  char *actual_cwrapper_path;
4357*a376eb32SXin Li  char *actual_cwrapper_name;
4358*a376eb32SXin Li  char *target_name;
4359*a376eb32SXin Li  char *lt_argv_zero;
4360*a376eb32SXin Li  intptr_t rval = 127;
4361*a376eb32SXin Li
4362*a376eb32SXin Li  int i;
4363*a376eb32SXin Li
4364*a376eb32SXin Li  program_name = (char *) xstrdup (base_name (argv[0]));
4365*a376eb32SXin Li  newargz = XMALLOC (char *, argc + 1);
4366*a376eb32SXin Li
4367*a376eb32SXin Li  /* very simple arg parsing; don't want to rely on getopt
4368*a376eb32SXin Li   * also, copy all non cwrapper options to newargz, except
4369*a376eb32SXin Li   * argz[0], which is handled differently
4370*a376eb32SXin Li   */
4371*a376eb32SXin Li  newargc=0;
4372*a376eb32SXin Li  for (i = 1; i < argc; i++)
4373*a376eb32SXin Li    {
4374*a376eb32SXin Li      if (strcmp (argv[i], dumpscript_opt) == 0)
4375*a376eb32SXin Li	{
4376*a376eb32SXin LiEOF
4377*a376eb32SXin Li	    case "$host" in
4378*a376eb32SXin Li	      *mingw* | *cygwin* )
4379*a376eb32SXin Li		# make stdout use "unix" line endings
4380*a376eb32SXin Li		echo "          setmode(1,_O_BINARY);"
4381*a376eb32SXin Li		;;
4382*a376eb32SXin Li	      esac
4383*a376eb32SXin Li
4384*a376eb32SXin Li	    cat <<"EOF"
4385*a376eb32SXin Li	  lt_dump_script (stdout);
4386*a376eb32SXin Li	  return 0;
4387*a376eb32SXin Li	}
4388*a376eb32SXin Li      if (strcmp (argv[i], debug_opt) == 0)
4389*a376eb32SXin Li	{
4390*a376eb32SXin Li          lt_debug = 1;
4391*a376eb32SXin Li          continue;
4392*a376eb32SXin Li	}
4393*a376eb32SXin Li      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
4394*a376eb32SXin Li        {
4395*a376eb32SXin Li          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
4396*a376eb32SXin Li             namespace, but it is not one of the ones we know about and
4397*a376eb32SXin Li             have already dealt with, above (inluding dump-script), then
4398*a376eb32SXin Li             report an error. Otherwise, targets might begin to believe
4399*a376eb32SXin Li             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
4400*a376eb32SXin Li             namespace. The first time any user complains about this, we'll
4401*a376eb32SXin Li             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
4402*a376eb32SXin Li             or a configure.ac-settable value.
4403*a376eb32SXin Li           */
4404*a376eb32SXin Li          lt_fatal (__FILE__, __LINE__,
4405*a376eb32SXin Li		    "unrecognized %s option: '%s'",
4406*a376eb32SXin Li                    ltwrapper_option_prefix, argv[i]);
4407*a376eb32SXin Li        }
4408*a376eb32SXin Li      /* otherwise ... */
4409*a376eb32SXin Li      newargz[++newargc] = xstrdup (argv[i]);
4410*a376eb32SXin Li    }
4411*a376eb32SXin Li  newargz[++newargc] = NULL;
4412*a376eb32SXin Li
4413*a376eb32SXin LiEOF
4414*a376eb32SXin Li	    cat <<EOF
4415*a376eb32SXin Li  /* The GNU banner must be the first non-error debug message */
4416*a376eb32SXin Li  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
4417*a376eb32SXin LiEOF
4418*a376eb32SXin Li	    cat <<"EOF"
4419*a376eb32SXin Li  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
4420*a376eb32SXin Li  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
4421*a376eb32SXin Li
4422*a376eb32SXin Li  tmp_pathspec = find_executable (argv[0]);
4423*a376eb32SXin Li  if (tmp_pathspec == NULL)
4424*a376eb32SXin Li    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
4425*a376eb32SXin Li  lt_debugprintf (__FILE__, __LINE__,
4426*a376eb32SXin Li                  "(main) found exe (before symlink chase) at: %s\n",
4427*a376eb32SXin Li		  tmp_pathspec);
4428*a376eb32SXin Li
4429*a376eb32SXin Li  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
4430*a376eb32SXin Li  lt_debugprintf (__FILE__, __LINE__,
4431*a376eb32SXin Li                  "(main) found exe (after symlink chase) at: %s\n",
4432*a376eb32SXin Li		  actual_cwrapper_path);
4433*a376eb32SXin Li  XFREE (tmp_pathspec);
4434*a376eb32SXin Li
4435*a376eb32SXin Li  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
4436*a376eb32SXin Li  strendzap (actual_cwrapper_path, actual_cwrapper_name);
4437*a376eb32SXin Li
4438*a376eb32SXin Li  /* wrapper name transforms */
4439*a376eb32SXin Li  strendzap (actual_cwrapper_name, ".exe");
4440*a376eb32SXin Li  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
4441*a376eb32SXin Li  XFREE (actual_cwrapper_name);
4442*a376eb32SXin Li  actual_cwrapper_name = tmp_pathspec;
4443*a376eb32SXin Li  tmp_pathspec = 0;
4444*a376eb32SXin Li
4445*a376eb32SXin Li  /* target_name transforms -- use actual target program name; might have lt- prefix */
4446*a376eb32SXin Li  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
4447*a376eb32SXin Li  strendzap (target_name, ".exe");
4448*a376eb32SXin Li  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
4449*a376eb32SXin Li  XFREE (target_name);
4450*a376eb32SXin Li  target_name = tmp_pathspec;
4451*a376eb32SXin Li  tmp_pathspec = 0;
4452*a376eb32SXin Li
4453*a376eb32SXin Li  lt_debugprintf (__FILE__, __LINE__,
4454*a376eb32SXin Li		  "(main) libtool target name: %s\n",
4455*a376eb32SXin Li		  target_name);
4456*a376eb32SXin LiEOF
4457*a376eb32SXin Li
4458*a376eb32SXin Li	    cat <<EOF
4459*a376eb32SXin Li  newargz[0] =
4460*a376eb32SXin Li    XMALLOC (char, (strlen (actual_cwrapper_path) +
4461*a376eb32SXin Li		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
4462*a376eb32SXin Li  strcpy (newargz[0], actual_cwrapper_path);
4463*a376eb32SXin Li  strcat (newargz[0], "$objdir");
4464*a376eb32SXin Li  strcat (newargz[0], "/");
4465*a376eb32SXin LiEOF
4466*a376eb32SXin Li
4467*a376eb32SXin Li	    cat <<"EOF"
4468*a376eb32SXin Li  /* stop here, and copy so we don't have to do this twice */
4469*a376eb32SXin Li  tmp_pathspec = xstrdup (newargz[0]);
4470*a376eb32SXin Li
4471*a376eb32SXin Li  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
4472*a376eb32SXin Li  strcat (newargz[0], actual_cwrapper_name);
4473*a376eb32SXin Li
4474*a376eb32SXin Li  /* DO want the lt- prefix here if it exists, so use target_name */
4475*a376eb32SXin Li  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
4476*a376eb32SXin Li  XFREE (tmp_pathspec);
4477*a376eb32SXin Li  tmp_pathspec = NULL;
4478*a376eb32SXin LiEOF
4479*a376eb32SXin Li
4480*a376eb32SXin Li	    case $host_os in
4481*a376eb32SXin Li	      mingw*)
4482*a376eb32SXin Li	    cat <<"EOF"
4483*a376eb32SXin Li  {
4484*a376eb32SXin Li    char* p;
4485*a376eb32SXin Li    while ((p = strchr (newargz[0], '\\')) != NULL)
4486*a376eb32SXin Li      {
4487*a376eb32SXin Li	*p = '/';
4488*a376eb32SXin Li      }
4489*a376eb32SXin Li    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
4490*a376eb32SXin Li      {
4491*a376eb32SXin Li	*p = '/';
4492*a376eb32SXin Li      }
4493*a376eb32SXin Li  }
4494*a376eb32SXin LiEOF
4495*a376eb32SXin Li	    ;;
4496*a376eb32SXin Li	    esac
4497*a376eb32SXin Li
4498*a376eb32SXin Li	    cat <<"EOF"
4499*a376eb32SXin Li  XFREE (target_name);
4500*a376eb32SXin Li  XFREE (actual_cwrapper_path);
4501*a376eb32SXin Li  XFREE (actual_cwrapper_name);
4502*a376eb32SXin Li
4503*a376eb32SXin Li  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
4504*a376eb32SXin Li  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
4505*a376eb32SXin Li  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
4506*a376eb32SXin Li     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
4507*a376eb32SXin Li     because on Windows, both *_VARNAMEs are PATH but uninstalled
4508*a376eb32SXin Li     libraries must come first. */
4509*a376eb32SXin Li  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
4510*a376eb32SXin Li  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
4511*a376eb32SXin Li
4512*a376eb32SXin Li  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
4513*a376eb32SXin Li		  nonnull (lt_argv_zero));
4514*a376eb32SXin Li  for (i = 0; i < newargc; i++)
4515*a376eb32SXin Li    {
4516*a376eb32SXin Li      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
4517*a376eb32SXin Li		      i, nonnull (newargz[i]));
4518*a376eb32SXin Li    }
4519*a376eb32SXin Li
4520*a376eb32SXin LiEOF
4521*a376eb32SXin Li
4522*a376eb32SXin Li	    case $host_os in
4523*a376eb32SXin Li	      mingw*)
4524*a376eb32SXin Li		cat <<"EOF"
4525*a376eb32SXin Li  /* execv doesn't actually work on mingw as expected on unix */
4526*a376eb32SXin Li  newargz = prepare_spawn (newargz);
4527*a376eb32SXin Li  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
4528*a376eb32SXin Li  if (rval == -1)
4529*a376eb32SXin Li    {
4530*a376eb32SXin Li      /* failed to start process */
4531*a376eb32SXin Li      lt_debugprintf (__FILE__, __LINE__,
4532*a376eb32SXin Li		      "(main) failed to launch target \"%s\": %s\n",
4533*a376eb32SXin Li		      lt_argv_zero, nonnull (strerror (errno)));
4534*a376eb32SXin Li      return 127;
4535*a376eb32SXin Li    }
4536*a376eb32SXin Li  return rval;
4537*a376eb32SXin LiEOF
4538*a376eb32SXin Li		;;
4539*a376eb32SXin Li	      *)
4540*a376eb32SXin Li		cat <<"EOF"
4541*a376eb32SXin Li  execv (lt_argv_zero, newargz);
4542*a376eb32SXin Li  return rval; /* =127, but avoids unused variable warning */
4543*a376eb32SXin LiEOF
4544*a376eb32SXin Li		;;
4545*a376eb32SXin Li	    esac
4546*a376eb32SXin Li
4547*a376eb32SXin Li	    cat <<"EOF"
4548*a376eb32SXin Li}
4549*a376eb32SXin Li
4550*a376eb32SXin Livoid *
4551*a376eb32SXin Lixmalloc (size_t num)
4552*a376eb32SXin Li{
4553*a376eb32SXin Li  void *p = (void *) malloc (num);
4554*a376eb32SXin Li  if (!p)
4555*a376eb32SXin Li    lt_fatal (__FILE__, __LINE__, "memory exhausted");
4556*a376eb32SXin Li
4557*a376eb32SXin Li  return p;
4558*a376eb32SXin Li}
4559*a376eb32SXin Li
4560*a376eb32SXin Lichar *
4561*a376eb32SXin Lixstrdup (const char *string)
4562*a376eb32SXin Li{
4563*a376eb32SXin Li  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
4564*a376eb32SXin Li			  string) : NULL;
4565*a376eb32SXin Li}
4566*a376eb32SXin Li
4567*a376eb32SXin Liconst char *
4568*a376eb32SXin Libase_name (const char *name)
4569*a376eb32SXin Li{
4570*a376eb32SXin Li  const char *base;
4571*a376eb32SXin Li
4572*a376eb32SXin Li#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4573*a376eb32SXin Li  /* Skip over the disk name in MSDOS pathnames. */
4574*a376eb32SXin Li  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
4575*a376eb32SXin Li    name += 2;
4576*a376eb32SXin Li#endif
4577*a376eb32SXin Li
4578*a376eb32SXin Li  for (base = name; *name; name++)
4579*a376eb32SXin Li    if (IS_DIR_SEPARATOR (*name))
4580*a376eb32SXin Li      base = name + 1;
4581*a376eb32SXin Li  return base;
4582*a376eb32SXin Li}
4583*a376eb32SXin Li
4584*a376eb32SXin Liint
4585*a376eb32SXin Licheck_executable (const char *path)
4586*a376eb32SXin Li{
4587*a376eb32SXin Li  struct stat st;
4588*a376eb32SXin Li
4589*a376eb32SXin Li  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
4590*a376eb32SXin Li                  nonempty (path));
4591*a376eb32SXin Li  if ((!path) || (!*path))
4592*a376eb32SXin Li    return 0;
4593*a376eb32SXin Li
4594*a376eb32SXin Li  if ((stat (path, &st) >= 0)
4595*a376eb32SXin Li      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
4596*a376eb32SXin Li    return 1;
4597*a376eb32SXin Li  else
4598*a376eb32SXin Li    return 0;
4599*a376eb32SXin Li}
4600*a376eb32SXin Li
4601*a376eb32SXin Liint
4602*a376eb32SXin Limake_executable (const char *path)
4603*a376eb32SXin Li{
4604*a376eb32SXin Li  int rval = 0;
4605*a376eb32SXin Li  struct stat st;
4606*a376eb32SXin Li
4607*a376eb32SXin Li  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
4608*a376eb32SXin Li                  nonempty (path));
4609*a376eb32SXin Li  if ((!path) || (!*path))
4610*a376eb32SXin Li    return 0;
4611*a376eb32SXin Li
4612*a376eb32SXin Li  if (stat (path, &st) >= 0)
4613*a376eb32SXin Li    {
4614*a376eb32SXin Li      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
4615*a376eb32SXin Li    }
4616*a376eb32SXin Li  return rval;
4617*a376eb32SXin Li}
4618*a376eb32SXin Li
4619*a376eb32SXin Li/* Searches for the full path of the wrapper.  Returns
4620*a376eb32SXin Li   newly allocated full path name if found, NULL otherwise
4621*a376eb32SXin Li   Does not chase symlinks, even on platforms that support them.
4622*a376eb32SXin Li*/
4623*a376eb32SXin Lichar *
4624*a376eb32SXin Lifind_executable (const char *wrapper)
4625*a376eb32SXin Li{
4626*a376eb32SXin Li  int has_slash = 0;
4627*a376eb32SXin Li  const char *p;
4628*a376eb32SXin Li  const char *p_next;
4629*a376eb32SXin Li  /* static buffer for getcwd */
4630*a376eb32SXin Li  char tmp[LT_PATHMAX + 1];
4631*a376eb32SXin Li  int tmp_len;
4632*a376eb32SXin Li  char *concat_name;
4633*a376eb32SXin Li
4634*a376eb32SXin Li  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
4635*a376eb32SXin Li                  nonempty (wrapper));
4636*a376eb32SXin Li
4637*a376eb32SXin Li  if ((wrapper == NULL) || (*wrapper == '\0'))
4638*a376eb32SXin Li    return NULL;
4639*a376eb32SXin Li
4640*a376eb32SXin Li  /* Absolute path? */
4641*a376eb32SXin Li#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4642*a376eb32SXin Li  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
4643*a376eb32SXin Li    {
4644*a376eb32SXin Li      concat_name = xstrdup (wrapper);
4645*a376eb32SXin Li      if (check_executable (concat_name))
4646*a376eb32SXin Li	return concat_name;
4647*a376eb32SXin Li      XFREE (concat_name);
4648*a376eb32SXin Li    }
4649*a376eb32SXin Li  else
4650*a376eb32SXin Li    {
4651*a376eb32SXin Li#endif
4652*a376eb32SXin Li      if (IS_DIR_SEPARATOR (wrapper[0]))
4653*a376eb32SXin Li	{
4654*a376eb32SXin Li	  concat_name = xstrdup (wrapper);
4655*a376eb32SXin Li	  if (check_executable (concat_name))
4656*a376eb32SXin Li	    return concat_name;
4657*a376eb32SXin Li	  XFREE (concat_name);
4658*a376eb32SXin Li	}
4659*a376eb32SXin Li#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4660*a376eb32SXin Li    }
4661*a376eb32SXin Li#endif
4662*a376eb32SXin Li
4663*a376eb32SXin Li  for (p = wrapper; *p; p++)
4664*a376eb32SXin Li    if (*p == '/')
4665*a376eb32SXin Li      {
4666*a376eb32SXin Li	has_slash = 1;
4667*a376eb32SXin Li	break;
4668*a376eb32SXin Li      }
4669*a376eb32SXin Li  if (!has_slash)
4670*a376eb32SXin Li    {
4671*a376eb32SXin Li      /* no slashes; search PATH */
4672*a376eb32SXin Li      const char *path = getenv ("PATH");
4673*a376eb32SXin Li      if (path != NULL)
4674*a376eb32SXin Li	{
4675*a376eb32SXin Li	  for (p = path; *p; p = p_next)
4676*a376eb32SXin Li	    {
4677*a376eb32SXin Li	      const char *q;
4678*a376eb32SXin Li	      size_t p_len;
4679*a376eb32SXin Li	      for (q = p; *q; q++)
4680*a376eb32SXin Li		if (IS_PATH_SEPARATOR (*q))
4681*a376eb32SXin Li		  break;
4682*a376eb32SXin Li	      p_len = q - p;
4683*a376eb32SXin Li	      p_next = (*q == '\0' ? q : q + 1);
4684*a376eb32SXin Li	      if (p_len == 0)
4685*a376eb32SXin Li		{
4686*a376eb32SXin Li		  /* empty path: current directory */
4687*a376eb32SXin Li		  if (getcwd (tmp, LT_PATHMAX) == NULL)
4688*a376eb32SXin Li		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
4689*a376eb32SXin Li                              nonnull (strerror (errno)));
4690*a376eb32SXin Li		  tmp_len = strlen (tmp);
4691*a376eb32SXin Li		  concat_name =
4692*a376eb32SXin Li		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
4693*a376eb32SXin Li		  memcpy (concat_name, tmp, tmp_len);
4694*a376eb32SXin Li		  concat_name[tmp_len] = '/';
4695*a376eb32SXin Li		  strcpy (concat_name + tmp_len + 1, wrapper);
4696*a376eb32SXin Li		}
4697*a376eb32SXin Li	      else
4698*a376eb32SXin Li		{
4699*a376eb32SXin Li		  concat_name =
4700*a376eb32SXin Li		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
4701*a376eb32SXin Li		  memcpy (concat_name, p, p_len);
4702*a376eb32SXin Li		  concat_name[p_len] = '/';
4703*a376eb32SXin Li		  strcpy (concat_name + p_len + 1, wrapper);
4704*a376eb32SXin Li		}
4705*a376eb32SXin Li	      if (check_executable (concat_name))
4706*a376eb32SXin Li		return concat_name;
4707*a376eb32SXin Li	      XFREE (concat_name);
4708*a376eb32SXin Li	    }
4709*a376eb32SXin Li	}
4710*a376eb32SXin Li      /* not found in PATH; assume curdir */
4711*a376eb32SXin Li    }
4712*a376eb32SXin Li  /* Relative path | not found in path: prepend cwd */
4713*a376eb32SXin Li  if (getcwd (tmp, LT_PATHMAX) == NULL)
4714*a376eb32SXin Li    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
4715*a376eb32SXin Li              nonnull (strerror (errno)));
4716*a376eb32SXin Li  tmp_len = strlen (tmp);
4717*a376eb32SXin Li  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
4718*a376eb32SXin Li  memcpy (concat_name, tmp, tmp_len);
4719*a376eb32SXin Li  concat_name[tmp_len] = '/';
4720*a376eb32SXin Li  strcpy (concat_name + tmp_len + 1, wrapper);
4721*a376eb32SXin Li
4722*a376eb32SXin Li  if (check_executable (concat_name))
4723*a376eb32SXin Li    return concat_name;
4724*a376eb32SXin Li  XFREE (concat_name);
4725*a376eb32SXin Li  return NULL;
4726*a376eb32SXin Li}
4727*a376eb32SXin Li
4728*a376eb32SXin Lichar *
4729*a376eb32SXin Lichase_symlinks (const char *pathspec)
4730*a376eb32SXin Li{
4731*a376eb32SXin Li#ifndef S_ISLNK
4732*a376eb32SXin Li  return xstrdup (pathspec);
4733*a376eb32SXin Li#else
4734*a376eb32SXin Li  char buf[LT_PATHMAX];
4735*a376eb32SXin Li  struct stat s;
4736*a376eb32SXin Li  char *tmp_pathspec = xstrdup (pathspec);
4737*a376eb32SXin Li  char *p;
4738*a376eb32SXin Li  int has_symlinks = 0;
4739*a376eb32SXin Li  while (strlen (tmp_pathspec) && !has_symlinks)
4740*a376eb32SXin Li    {
4741*a376eb32SXin Li      lt_debugprintf (__FILE__, __LINE__,
4742*a376eb32SXin Li		      "checking path component for symlinks: %s\n",
4743*a376eb32SXin Li		      tmp_pathspec);
4744*a376eb32SXin Li      if (lstat (tmp_pathspec, &s) == 0)
4745*a376eb32SXin Li	{
4746*a376eb32SXin Li	  if (S_ISLNK (s.st_mode) != 0)
4747*a376eb32SXin Li	    {
4748*a376eb32SXin Li	      has_symlinks = 1;
4749*a376eb32SXin Li	      break;
4750*a376eb32SXin Li	    }
4751*a376eb32SXin Li
4752*a376eb32SXin Li	  /* search backwards for last DIR_SEPARATOR */
4753*a376eb32SXin Li	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
4754*a376eb32SXin Li	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4755*a376eb32SXin Li	    p--;
4756*a376eb32SXin Li	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4757*a376eb32SXin Li	    {
4758*a376eb32SXin Li	      /* no more DIR_SEPARATORS left */
4759*a376eb32SXin Li	      break;
4760*a376eb32SXin Li	    }
4761*a376eb32SXin Li	  *p = '\0';
4762*a376eb32SXin Li	}
4763*a376eb32SXin Li      else
4764*a376eb32SXin Li	{
4765*a376eb32SXin Li	  lt_fatal (__FILE__, __LINE__,
4766*a376eb32SXin Li		    "error accessing file \"%s\": %s",
4767*a376eb32SXin Li		    tmp_pathspec, nonnull (strerror (errno)));
4768*a376eb32SXin Li	}
4769*a376eb32SXin Li    }
4770*a376eb32SXin Li  XFREE (tmp_pathspec);
4771*a376eb32SXin Li
4772*a376eb32SXin Li  if (!has_symlinks)
4773*a376eb32SXin Li    {
4774*a376eb32SXin Li      return xstrdup (pathspec);
4775*a376eb32SXin Li    }
4776*a376eb32SXin Li
4777*a376eb32SXin Li  tmp_pathspec = realpath (pathspec, buf);
4778*a376eb32SXin Li  if (tmp_pathspec == 0)
4779*a376eb32SXin Li    {
4780*a376eb32SXin Li      lt_fatal (__FILE__, __LINE__,
4781*a376eb32SXin Li		"could not follow symlinks for %s", pathspec);
4782*a376eb32SXin Li    }
4783*a376eb32SXin Li  return xstrdup (tmp_pathspec);
4784*a376eb32SXin Li#endif
4785*a376eb32SXin Li}
4786*a376eb32SXin Li
4787*a376eb32SXin Lichar *
4788*a376eb32SXin Listrendzap (char *str, const char *pat)
4789*a376eb32SXin Li{
4790*a376eb32SXin Li  size_t len, patlen;
4791*a376eb32SXin Li
4792*a376eb32SXin Li  assert (str != NULL);
4793*a376eb32SXin Li  assert (pat != NULL);
4794*a376eb32SXin Li
4795*a376eb32SXin Li  len = strlen (str);
4796*a376eb32SXin Li  patlen = strlen (pat);
4797*a376eb32SXin Li
4798*a376eb32SXin Li  if (patlen <= len)
4799*a376eb32SXin Li    {
4800*a376eb32SXin Li      str += len - patlen;
4801*a376eb32SXin Li      if (strcmp (str, pat) == 0)
4802*a376eb32SXin Li	*str = '\0';
4803*a376eb32SXin Li    }
4804*a376eb32SXin Li  return str;
4805*a376eb32SXin Li}
4806*a376eb32SXin Li
4807*a376eb32SXin Livoid
4808*a376eb32SXin Lilt_debugprintf (const char *file, int line, const char *fmt, ...)
4809*a376eb32SXin Li{
4810*a376eb32SXin Li  va_list args;
4811*a376eb32SXin Li  if (lt_debug)
4812*a376eb32SXin Li    {
4813*a376eb32SXin Li      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
4814*a376eb32SXin Li      va_start (args, fmt);
4815*a376eb32SXin Li      (void) vfprintf (stderr, fmt, args);
4816*a376eb32SXin Li      va_end (args);
4817*a376eb32SXin Li    }
4818*a376eb32SXin Li}
4819*a376eb32SXin Li
4820*a376eb32SXin Listatic void
4821*a376eb32SXin Lilt_error_core (int exit_status, const char *file,
4822*a376eb32SXin Li	       int line, const char *mode,
4823*a376eb32SXin Li	       const char *message, va_list ap)
4824*a376eb32SXin Li{
4825*a376eb32SXin Li  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
4826*a376eb32SXin Li  vfprintf (stderr, message, ap);
4827*a376eb32SXin Li  fprintf (stderr, ".\n");
4828*a376eb32SXin Li
4829*a376eb32SXin Li  if (exit_status >= 0)
4830*a376eb32SXin Li    exit (exit_status);
4831*a376eb32SXin Li}
4832*a376eb32SXin Li
4833*a376eb32SXin Livoid
4834*a376eb32SXin Lilt_fatal (const char *file, int line, const char *message, ...)
4835*a376eb32SXin Li{
4836*a376eb32SXin Li  va_list ap;
4837*a376eb32SXin Li  va_start (ap, message);
4838*a376eb32SXin Li  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
4839*a376eb32SXin Li  va_end (ap);
4840*a376eb32SXin Li}
4841*a376eb32SXin Li
4842*a376eb32SXin Listatic const char *
4843*a376eb32SXin Linonnull (const char *s)
4844*a376eb32SXin Li{
4845*a376eb32SXin Li  return s ? s : "(null)";
4846*a376eb32SXin Li}
4847*a376eb32SXin Li
4848*a376eb32SXin Listatic const char *
4849*a376eb32SXin Linonempty (const char *s)
4850*a376eb32SXin Li{
4851*a376eb32SXin Li  return (s && !*s) ? "(empty)" : nonnull (s);
4852*a376eb32SXin Li}
4853*a376eb32SXin Li
4854*a376eb32SXin Livoid
4855*a376eb32SXin Lilt_setenv (const char *name, const char *value)
4856*a376eb32SXin Li{
4857*a376eb32SXin Li  lt_debugprintf (__FILE__, __LINE__,
4858*a376eb32SXin Li		  "(lt_setenv) setting '%s' to '%s'\n",
4859*a376eb32SXin Li                  nonnull (name), nonnull (value));
4860*a376eb32SXin Li  {
4861*a376eb32SXin Li#ifdef HAVE_SETENV
4862*a376eb32SXin Li    /* always make a copy, for consistency with !HAVE_SETENV */
4863*a376eb32SXin Li    char *str = xstrdup (value);
4864*a376eb32SXin Li    setenv (name, str, 1);
4865*a376eb32SXin Li#else
4866*a376eb32SXin Li    int len = strlen (name) + 1 + strlen (value) + 1;
4867*a376eb32SXin Li    char *str = XMALLOC (char, len);
4868*a376eb32SXin Li    sprintf (str, "%s=%s", name, value);
4869*a376eb32SXin Li    if (putenv (str) != EXIT_SUCCESS)
4870*a376eb32SXin Li      {
4871*a376eb32SXin Li        XFREE (str);
4872*a376eb32SXin Li      }
4873*a376eb32SXin Li#endif
4874*a376eb32SXin Li  }
4875*a376eb32SXin Li}
4876*a376eb32SXin Li
4877*a376eb32SXin Lichar *
4878*a376eb32SXin Lilt_extend_str (const char *orig_value, const char *add, int to_end)
4879*a376eb32SXin Li{
4880*a376eb32SXin Li  char *new_value;
4881*a376eb32SXin Li  if (orig_value && *orig_value)
4882*a376eb32SXin Li    {
4883*a376eb32SXin Li      int orig_value_len = strlen (orig_value);
4884*a376eb32SXin Li      int add_len = strlen (add);
4885*a376eb32SXin Li      new_value = XMALLOC (char, add_len + orig_value_len + 1);
4886*a376eb32SXin Li      if (to_end)
4887*a376eb32SXin Li        {
4888*a376eb32SXin Li          strcpy (new_value, orig_value);
4889*a376eb32SXin Li          strcpy (new_value + orig_value_len, add);
4890*a376eb32SXin Li        }
4891*a376eb32SXin Li      else
4892*a376eb32SXin Li        {
4893*a376eb32SXin Li          strcpy (new_value, add);
4894*a376eb32SXin Li          strcpy (new_value + add_len, orig_value);
4895*a376eb32SXin Li        }
4896*a376eb32SXin Li    }
4897*a376eb32SXin Li  else
4898*a376eb32SXin Li    {
4899*a376eb32SXin Li      new_value = xstrdup (add);
4900*a376eb32SXin Li    }
4901*a376eb32SXin Li  return new_value;
4902*a376eb32SXin Li}
4903*a376eb32SXin Li
4904*a376eb32SXin Livoid
4905*a376eb32SXin Lilt_update_exe_path (const char *name, const char *value)
4906*a376eb32SXin Li{
4907*a376eb32SXin Li  lt_debugprintf (__FILE__, __LINE__,
4908*a376eb32SXin Li		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
4909*a376eb32SXin Li                  nonnull (name), nonnull (value));
4910*a376eb32SXin Li
4911*a376eb32SXin Li  if (name && *name && value && *value)
4912*a376eb32SXin Li    {
4913*a376eb32SXin Li      char *new_value = lt_extend_str (getenv (name), value, 0);
4914*a376eb32SXin Li      /* some systems can't cope with a ':'-terminated path #' */
4915*a376eb32SXin Li      int len = strlen (new_value);
4916*a376eb32SXin Li      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
4917*a376eb32SXin Li        {
4918*a376eb32SXin Li          new_value[len-1] = '\0';
4919*a376eb32SXin Li        }
4920*a376eb32SXin Li      lt_setenv (name, new_value);
4921*a376eb32SXin Li      XFREE (new_value);
4922*a376eb32SXin Li    }
4923*a376eb32SXin Li}
4924*a376eb32SXin Li
4925*a376eb32SXin Livoid
4926*a376eb32SXin Lilt_update_lib_path (const char *name, const char *value)
4927*a376eb32SXin Li{
4928*a376eb32SXin Li  lt_debugprintf (__FILE__, __LINE__,
4929*a376eb32SXin Li		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
4930*a376eb32SXin Li                  nonnull (name), nonnull (value));
4931*a376eb32SXin Li
4932*a376eb32SXin Li  if (name && *name && value && *value)
4933*a376eb32SXin Li    {
4934*a376eb32SXin Li      char *new_value = lt_extend_str (getenv (name), value, 0);
4935*a376eb32SXin Li      lt_setenv (name, new_value);
4936*a376eb32SXin Li      XFREE (new_value);
4937*a376eb32SXin Li    }
4938*a376eb32SXin Li}
4939*a376eb32SXin Li
4940*a376eb32SXin LiEOF
4941*a376eb32SXin Li	    case $host_os in
4942*a376eb32SXin Li	      mingw*)
4943*a376eb32SXin Li		cat <<"EOF"
4944*a376eb32SXin Li
4945*a376eb32SXin Li/* Prepares an argument vector before calling spawn().
4946*a376eb32SXin Li   Note that spawn() does not by itself call the command interpreter
4947*a376eb32SXin Li     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
4948*a376eb32SXin Li      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
4949*a376eb32SXin Li         GetVersionEx(&v);
4950*a376eb32SXin Li         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
4951*a376eb32SXin Li      }) ? "cmd.exe" : "command.com").
4952*a376eb32SXin Li   Instead it simply concatenates the arguments, separated by ' ', and calls
4953*a376eb32SXin Li   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
4954*a376eb32SXin Li   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
4955*a376eb32SXin Li   special way:
4956*a376eb32SXin Li   - Space and tab are interpreted as delimiters. They are not treated as
4957*a376eb32SXin Li     delimiters if they are surrounded by double quotes: "...".
4958*a376eb32SXin Li   - Unescaped double quotes are removed from the input. Their only effect is
4959*a376eb32SXin Li     that within double quotes, space and tab are treated like normal
4960*a376eb32SXin Li     characters.
4961*a376eb32SXin Li   - Backslashes not followed by double quotes are not special.
4962*a376eb32SXin Li   - But 2*n+1 backslashes followed by a double quote become
4963*a376eb32SXin Li     n backslashes followed by a double quote (n >= 0):
4964*a376eb32SXin Li       \" -> "
4965*a376eb32SXin Li       \\\" -> \"
4966*a376eb32SXin Li       \\\\\" -> \\"
4967*a376eb32SXin Li */
4968*a376eb32SXin Li#define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
4969*a376eb32SXin Li#define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
4970*a376eb32SXin Lichar **
4971*a376eb32SXin Liprepare_spawn (char **argv)
4972*a376eb32SXin Li{
4973*a376eb32SXin Li  size_t argc;
4974*a376eb32SXin Li  char **new_argv;
4975*a376eb32SXin Li  size_t i;
4976*a376eb32SXin Li
4977*a376eb32SXin Li  /* Count number of arguments.  */
4978*a376eb32SXin Li  for (argc = 0; argv[argc] != NULL; argc++)
4979*a376eb32SXin Li    ;
4980*a376eb32SXin Li
4981*a376eb32SXin Li  /* Allocate new argument vector.  */
4982*a376eb32SXin Li  new_argv = XMALLOC (char *, argc + 1);
4983*a376eb32SXin Li
4984*a376eb32SXin Li  /* Put quoted arguments into the new argument vector.  */
4985*a376eb32SXin Li  for (i = 0; i < argc; i++)
4986*a376eb32SXin Li    {
4987*a376eb32SXin Li      const char *string = argv[i];
4988*a376eb32SXin Li
4989*a376eb32SXin Li      if (string[0] == '\0')
4990*a376eb32SXin Li	new_argv[i] = xstrdup ("\"\"");
4991*a376eb32SXin Li      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
4992*a376eb32SXin Li	{
4993*a376eb32SXin Li	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
4994*a376eb32SXin Li	  size_t length;
4995*a376eb32SXin Li	  unsigned int backslashes;
4996*a376eb32SXin Li	  const char *s;
4997*a376eb32SXin Li	  char *quoted_string;
4998*a376eb32SXin Li	  char *p;
4999*a376eb32SXin Li
5000*a376eb32SXin Li	  length = 0;
5001*a376eb32SXin Li	  backslashes = 0;
5002*a376eb32SXin Li	  if (quote_around)
5003*a376eb32SXin Li	    length++;
5004*a376eb32SXin Li	  for (s = string; *s != '\0'; s++)
5005*a376eb32SXin Li	    {
5006*a376eb32SXin Li	      char c = *s;
5007*a376eb32SXin Li	      if (c == '"')
5008*a376eb32SXin Li		length += backslashes + 1;
5009*a376eb32SXin Li	      length++;
5010*a376eb32SXin Li	      if (c == '\\')
5011*a376eb32SXin Li		backslashes++;
5012*a376eb32SXin Li	      else
5013*a376eb32SXin Li		backslashes = 0;
5014*a376eb32SXin Li	    }
5015*a376eb32SXin Li	  if (quote_around)
5016*a376eb32SXin Li	    length += backslashes + 1;
5017*a376eb32SXin Li
5018*a376eb32SXin Li	  quoted_string = XMALLOC (char, length + 1);
5019*a376eb32SXin Li
5020*a376eb32SXin Li	  p = quoted_string;
5021*a376eb32SXin Li	  backslashes = 0;
5022*a376eb32SXin Li	  if (quote_around)
5023*a376eb32SXin Li	    *p++ = '"';
5024*a376eb32SXin Li	  for (s = string; *s != '\0'; s++)
5025*a376eb32SXin Li	    {
5026*a376eb32SXin Li	      char c = *s;
5027*a376eb32SXin Li	      if (c == '"')
5028*a376eb32SXin Li		{
5029*a376eb32SXin Li		  unsigned int j;
5030*a376eb32SXin Li		  for (j = backslashes + 1; j > 0; j--)
5031*a376eb32SXin Li		    *p++ = '\\';
5032*a376eb32SXin Li		}
5033*a376eb32SXin Li	      *p++ = c;
5034*a376eb32SXin Li	      if (c == '\\')
5035*a376eb32SXin Li		backslashes++;
5036*a376eb32SXin Li	      else
5037*a376eb32SXin Li		backslashes = 0;
5038*a376eb32SXin Li	    }
5039*a376eb32SXin Li	  if (quote_around)
5040*a376eb32SXin Li	    {
5041*a376eb32SXin Li	      unsigned int j;
5042*a376eb32SXin Li	      for (j = backslashes; j > 0; j--)
5043*a376eb32SXin Li		*p++ = '\\';
5044*a376eb32SXin Li	      *p++ = '"';
5045*a376eb32SXin Li	    }
5046*a376eb32SXin Li	  *p = '\0';
5047*a376eb32SXin Li
5048*a376eb32SXin Li	  new_argv[i] = quoted_string;
5049*a376eb32SXin Li	}
5050*a376eb32SXin Li      else
5051*a376eb32SXin Li	new_argv[i] = (char *) string;
5052*a376eb32SXin Li    }
5053*a376eb32SXin Li  new_argv[argc] = NULL;
5054*a376eb32SXin Li
5055*a376eb32SXin Li  return new_argv;
5056*a376eb32SXin Li}
5057*a376eb32SXin LiEOF
5058*a376eb32SXin Li		;;
5059*a376eb32SXin Li	    esac
5060*a376eb32SXin Li
5061*a376eb32SXin Li            cat <<"EOF"
5062*a376eb32SXin Livoid lt_dump_script (FILE* f)
5063*a376eb32SXin Li{
5064*a376eb32SXin LiEOF
5065*a376eb32SXin Li	    func_emit_wrapper yes |
5066*a376eb32SXin Li	      $SED -n -e '
5067*a376eb32SXin Lis/^\(.\{79\}\)\(..*\)/\1\
5068*a376eb32SXin Li\2/
5069*a376eb32SXin Lih
5070*a376eb32SXin Lis/\([\\"]\)/\\\1/g
5071*a376eb32SXin Lis/$/\\n/
5072*a376eb32SXin Lis/\([^\n]*\).*/  fputs ("\1", f);/p
5073*a376eb32SXin Lig
5074*a376eb32SXin LiD'
5075*a376eb32SXin Li            cat <<"EOF"
5076*a376eb32SXin Li}
5077*a376eb32SXin LiEOF
5078*a376eb32SXin Li}
5079*a376eb32SXin Li# end: func_emit_cwrapperexe_src
5080*a376eb32SXin Li
5081*a376eb32SXin Li# func_win32_import_lib_p ARG
5082*a376eb32SXin Li# True if ARG is an import lib, as indicated by $file_magic_cmd
5083*a376eb32SXin Lifunc_win32_import_lib_p ()
5084*a376eb32SXin Li{
5085*a376eb32SXin Li    $opt_debug
5086*a376eb32SXin Li    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
5087*a376eb32SXin Li    *import*) : ;;
5088*a376eb32SXin Li    *) false ;;
5089*a376eb32SXin Li    esac
5090*a376eb32SXin Li}
5091*a376eb32SXin Li
5092*a376eb32SXin Li# func_mode_link arg...
5093*a376eb32SXin Lifunc_mode_link ()
5094*a376eb32SXin Li{
5095*a376eb32SXin Li    $opt_debug
5096*a376eb32SXin Li    case $host in
5097*a376eb32SXin Li    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
5098*a376eb32SXin Li      # It is impossible to link a dll without this setting, and
5099*a376eb32SXin Li      # we shouldn't force the makefile maintainer to figure out
5100*a376eb32SXin Li      # which system we are compiling for in order to pass an extra
5101*a376eb32SXin Li      # flag for every libtool invocation.
5102*a376eb32SXin Li      # allow_undefined=no
5103*a376eb32SXin Li
5104*a376eb32SXin Li      # FIXME: Unfortunately, there are problems with the above when trying
5105*a376eb32SXin Li      # to make a dll which has undefined symbols, in which case not
5106*a376eb32SXin Li      # even a static library is built.  For now, we need to specify
5107*a376eb32SXin Li      # -no-undefined on the libtool link line when we can be certain
5108*a376eb32SXin Li      # that all symbols are satisfied, otherwise we get a static library.
5109*a376eb32SXin Li      allow_undefined=yes
5110*a376eb32SXin Li      ;;
5111*a376eb32SXin Li    *)
5112*a376eb32SXin Li      allow_undefined=yes
5113*a376eb32SXin Li      ;;
5114*a376eb32SXin Li    esac
5115*a376eb32SXin Li    libtool_args=$nonopt
5116*a376eb32SXin Li    base_compile="$nonopt $@"
5117*a376eb32SXin Li    compile_command=$nonopt
5118*a376eb32SXin Li    finalize_command=$nonopt
5119*a376eb32SXin Li
5120*a376eb32SXin Li    compile_rpath=
5121*a376eb32SXin Li    finalize_rpath=
5122*a376eb32SXin Li    compile_shlibpath=
5123*a376eb32SXin Li    finalize_shlibpath=
5124*a376eb32SXin Li    convenience=
5125*a376eb32SXin Li    old_convenience=
5126*a376eb32SXin Li    deplibs=
5127*a376eb32SXin Li    old_deplibs=
5128*a376eb32SXin Li    compiler_flags=
5129*a376eb32SXin Li    linker_flags=
5130*a376eb32SXin Li    dllsearchpath=
5131*a376eb32SXin Li    lib_search_path=`pwd`
5132*a376eb32SXin Li    inst_prefix_dir=
5133*a376eb32SXin Li    new_inherited_linker_flags=
5134*a376eb32SXin Li
5135*a376eb32SXin Li    avoid_version=no
5136*a376eb32SXin Li    bindir=
5137*a376eb32SXin Li    dlfiles=
5138*a376eb32SXin Li    dlprefiles=
5139*a376eb32SXin Li    dlself=no
5140*a376eb32SXin Li    export_dynamic=no
5141*a376eb32SXin Li    export_symbols=
5142*a376eb32SXin Li    export_symbols_regex=
5143*a376eb32SXin Li    generated=
5144*a376eb32SXin Li    libobjs=
5145*a376eb32SXin Li    ltlibs=
5146*a376eb32SXin Li    module=no
5147*a376eb32SXin Li    no_install=no
5148*a376eb32SXin Li    objs=
5149*a376eb32SXin Li    non_pic_objects=
5150*a376eb32SXin Li    precious_files_regex=
5151*a376eb32SXin Li    prefer_static_libs=no
5152*a376eb32SXin Li    preload=no
5153*a376eb32SXin Li    prev=
5154*a376eb32SXin Li    prevarg=
5155*a376eb32SXin Li    release=
5156*a376eb32SXin Li    rpath=
5157*a376eb32SXin Li    xrpath=
5158*a376eb32SXin Li    perm_rpath=
5159*a376eb32SXin Li    temp_rpath=
5160*a376eb32SXin Li    thread_safe=no
5161*a376eb32SXin Li    vinfo=
5162*a376eb32SXin Li    vinfo_number=no
5163*a376eb32SXin Li    weak_libs=
5164*a376eb32SXin Li    single_module="${wl}-single_module"
5165*a376eb32SXin Li    func_infer_tag $base_compile
5166*a376eb32SXin Li
5167*a376eb32SXin Li    # We need to know -static, to get the right output filenames.
5168*a376eb32SXin Li    for arg
5169*a376eb32SXin Li    do
5170*a376eb32SXin Li      case $arg in
5171*a376eb32SXin Li      -shared)
5172*a376eb32SXin Li	test "$build_libtool_libs" != yes && \
5173*a376eb32SXin Li	  func_fatal_configuration "can not build a shared library"
5174*a376eb32SXin Li	build_old_libs=no
5175*a376eb32SXin Li	break
5176*a376eb32SXin Li	;;
5177*a376eb32SXin Li      -all-static | -static | -static-libtool-libs)
5178*a376eb32SXin Li	case $arg in
5179*a376eb32SXin Li	-all-static)
5180*a376eb32SXin Li	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
5181*a376eb32SXin Li	    func_warning "complete static linking is impossible in this configuration"
5182*a376eb32SXin Li	  fi
5183*a376eb32SXin Li	  if test -n "$link_static_flag"; then
5184*a376eb32SXin Li	    dlopen_self=$dlopen_self_static
5185*a376eb32SXin Li	  fi
5186*a376eb32SXin Li	  prefer_static_libs=yes
5187*a376eb32SXin Li	  ;;
5188*a376eb32SXin Li	-static)
5189*a376eb32SXin Li	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
5190*a376eb32SXin Li	    dlopen_self=$dlopen_self_static
5191*a376eb32SXin Li	  fi
5192*a376eb32SXin Li	  prefer_static_libs=built
5193*a376eb32SXin Li	  ;;
5194*a376eb32SXin Li	-static-libtool-libs)
5195*a376eb32SXin Li	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
5196*a376eb32SXin Li	    dlopen_self=$dlopen_self_static
5197*a376eb32SXin Li	  fi
5198*a376eb32SXin Li	  prefer_static_libs=yes
5199*a376eb32SXin Li	  ;;
5200*a376eb32SXin Li	esac
5201*a376eb32SXin Li	build_libtool_libs=no
5202*a376eb32SXin Li	build_old_libs=yes
5203*a376eb32SXin Li	break
5204*a376eb32SXin Li	;;
5205*a376eb32SXin Li      esac
5206*a376eb32SXin Li    done
5207*a376eb32SXin Li
5208*a376eb32SXin Li    # See if our shared archives depend on static archives.
5209*a376eb32SXin Li    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
5210*a376eb32SXin Li
5211*a376eb32SXin Li    # Go through the arguments, transforming them on the way.
5212*a376eb32SXin Li    while test "$#" -gt 0; do
5213*a376eb32SXin Li      arg="$1"
5214*a376eb32SXin Li      shift
5215*a376eb32SXin Li      func_quote_for_eval "$arg"
5216*a376eb32SXin Li      qarg=$func_quote_for_eval_unquoted_result
5217*a376eb32SXin Li      func_append libtool_args " $func_quote_for_eval_result"
5218*a376eb32SXin Li
5219*a376eb32SXin Li      # If the previous option needs an argument, assign it.
5220*a376eb32SXin Li      if test -n "$prev"; then
5221*a376eb32SXin Li	case $prev in
5222*a376eb32SXin Li	output)
5223*a376eb32SXin Li	  func_append compile_command " @OUTPUT@"
5224*a376eb32SXin Li	  func_append finalize_command " @OUTPUT@"
5225*a376eb32SXin Li	  ;;
5226*a376eb32SXin Li	esac
5227*a376eb32SXin Li
5228*a376eb32SXin Li	case $prev in
5229*a376eb32SXin Li	bindir)
5230*a376eb32SXin Li	  bindir="$arg"
5231*a376eb32SXin Li	  prev=
5232*a376eb32SXin Li	  continue
5233*a376eb32SXin Li	  ;;
5234*a376eb32SXin Li	dlfiles|dlprefiles)
5235*a376eb32SXin Li	  if test "$preload" = no; then
5236*a376eb32SXin Li	    # Add the symbol object into the linking commands.
5237*a376eb32SXin Li	    func_append compile_command " @SYMFILE@"
5238*a376eb32SXin Li	    func_append finalize_command " @SYMFILE@"
5239*a376eb32SXin Li	    preload=yes
5240*a376eb32SXin Li	  fi
5241*a376eb32SXin Li	  case $arg in
5242*a376eb32SXin Li	  *.la | *.lo) ;;  # We handle these cases below.
5243*a376eb32SXin Li	  force)
5244*a376eb32SXin Li	    if test "$dlself" = no; then
5245*a376eb32SXin Li	      dlself=needless
5246*a376eb32SXin Li	      export_dynamic=yes
5247*a376eb32SXin Li	    fi
5248*a376eb32SXin Li	    prev=
5249*a376eb32SXin Li	    continue
5250*a376eb32SXin Li	    ;;
5251*a376eb32SXin Li	  self)
5252*a376eb32SXin Li	    if test "$prev" = dlprefiles; then
5253*a376eb32SXin Li	      dlself=yes
5254*a376eb32SXin Li	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
5255*a376eb32SXin Li	      dlself=yes
5256*a376eb32SXin Li	    else
5257*a376eb32SXin Li	      dlself=needless
5258*a376eb32SXin Li	      export_dynamic=yes
5259*a376eb32SXin Li	    fi
5260*a376eb32SXin Li	    prev=
5261*a376eb32SXin Li	    continue
5262*a376eb32SXin Li	    ;;
5263*a376eb32SXin Li	  *)
5264*a376eb32SXin Li	    if test "$prev" = dlfiles; then
5265*a376eb32SXin Li	      func_append dlfiles " $arg"
5266*a376eb32SXin Li	    else
5267*a376eb32SXin Li	      func_append dlprefiles " $arg"
5268*a376eb32SXin Li	    fi
5269*a376eb32SXin Li	    prev=
5270*a376eb32SXin Li	    continue
5271*a376eb32SXin Li	    ;;
5272*a376eb32SXin Li	  esac
5273*a376eb32SXin Li	  ;;
5274*a376eb32SXin Li	expsyms)
5275*a376eb32SXin Li	  export_symbols="$arg"
5276*a376eb32SXin Li	  test -f "$arg" \
5277*a376eb32SXin Li	    || func_fatal_error "symbol file \`$arg' does not exist"
5278*a376eb32SXin Li	  prev=
5279*a376eb32SXin Li	  continue
5280*a376eb32SXin Li	  ;;
5281*a376eb32SXin Li	expsyms_regex)
5282*a376eb32SXin Li	  export_symbols_regex="$arg"
5283*a376eb32SXin Li	  prev=
5284*a376eb32SXin Li	  continue
5285*a376eb32SXin Li	  ;;
5286*a376eb32SXin Li	framework)
5287*a376eb32SXin Li	  case $host in
5288*a376eb32SXin Li	    *-*-darwin*)
5289*a376eb32SXin Li	      case "$deplibs " in
5290*a376eb32SXin Li		*" $qarg.ltframework "*) ;;
5291*a376eb32SXin Li		*) func_append deplibs " $qarg.ltframework" # this is fixed later
5292*a376eb32SXin Li		   ;;
5293*a376eb32SXin Li	      esac
5294*a376eb32SXin Li	      ;;
5295*a376eb32SXin Li	  esac
5296*a376eb32SXin Li	  prev=
5297*a376eb32SXin Li	  continue
5298*a376eb32SXin Li	  ;;
5299*a376eb32SXin Li	inst_prefix)
5300*a376eb32SXin Li	  inst_prefix_dir="$arg"
5301*a376eb32SXin Li	  prev=
5302*a376eb32SXin Li	  continue
5303*a376eb32SXin Li	  ;;
5304*a376eb32SXin Li	objectlist)
5305*a376eb32SXin Li	  if test -f "$arg"; then
5306*a376eb32SXin Li	    save_arg=$arg
5307*a376eb32SXin Li	    moreargs=
5308*a376eb32SXin Li	    for fil in `cat "$save_arg"`
5309*a376eb32SXin Li	    do
5310*a376eb32SXin Li#	      func_append moreargs " $fil"
5311*a376eb32SXin Li	      arg=$fil
5312*a376eb32SXin Li	      # A libtool-controlled object.
5313*a376eb32SXin Li
5314*a376eb32SXin Li	      # Check to see that this really is a libtool object.
5315*a376eb32SXin Li	      if func_lalib_unsafe_p "$arg"; then
5316*a376eb32SXin Li		pic_object=
5317*a376eb32SXin Li		non_pic_object=
5318*a376eb32SXin Li
5319*a376eb32SXin Li		# Read the .lo file
5320*a376eb32SXin Li		func_source "$arg"
5321*a376eb32SXin Li
5322*a376eb32SXin Li		if test -z "$pic_object" ||
5323*a376eb32SXin Li		   test -z "$non_pic_object" ||
5324*a376eb32SXin Li		   test "$pic_object" = none &&
5325*a376eb32SXin Li		   test "$non_pic_object" = none; then
5326*a376eb32SXin Li		  func_fatal_error "cannot find name of object for \`$arg'"
5327*a376eb32SXin Li		fi
5328*a376eb32SXin Li
5329*a376eb32SXin Li		# Extract subdirectory from the argument.
5330*a376eb32SXin Li		func_dirname "$arg" "/" ""
5331*a376eb32SXin Li		xdir="$func_dirname_result"
5332*a376eb32SXin Li
5333*a376eb32SXin Li		if test "$pic_object" != none; then
5334*a376eb32SXin Li		  # Prepend the subdirectory the object is found in.
5335*a376eb32SXin Li		  pic_object="$xdir$pic_object"
5336*a376eb32SXin Li
5337*a376eb32SXin Li		  if test "$prev" = dlfiles; then
5338*a376eb32SXin Li		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5339*a376eb32SXin Li		      func_append dlfiles " $pic_object"
5340*a376eb32SXin Li		      prev=
5341*a376eb32SXin Li		      continue
5342*a376eb32SXin Li		    else
5343*a376eb32SXin Li		      # If libtool objects are unsupported, then we need to preload.
5344*a376eb32SXin Li		      prev=dlprefiles
5345*a376eb32SXin Li		    fi
5346*a376eb32SXin Li		  fi
5347*a376eb32SXin Li
5348*a376eb32SXin Li		  # CHECK ME:  I think I busted this.  -Ossama
5349*a376eb32SXin Li		  if test "$prev" = dlprefiles; then
5350*a376eb32SXin Li		    # Preload the old-style object.
5351*a376eb32SXin Li		    func_append dlprefiles " $pic_object"
5352*a376eb32SXin Li		    prev=
5353*a376eb32SXin Li		  fi
5354*a376eb32SXin Li
5355*a376eb32SXin Li		  # A PIC object.
5356*a376eb32SXin Li		  func_append libobjs " $pic_object"
5357*a376eb32SXin Li		  arg="$pic_object"
5358*a376eb32SXin Li		fi
5359*a376eb32SXin Li
5360*a376eb32SXin Li		# Non-PIC object.
5361*a376eb32SXin Li		if test "$non_pic_object" != none; then
5362*a376eb32SXin Li		  # Prepend the subdirectory the object is found in.
5363*a376eb32SXin Li		  non_pic_object="$xdir$non_pic_object"
5364*a376eb32SXin Li
5365*a376eb32SXin Li		  # A standard non-PIC object
5366*a376eb32SXin Li		  func_append non_pic_objects " $non_pic_object"
5367*a376eb32SXin Li		  if test -z "$pic_object" || test "$pic_object" = none ; then
5368*a376eb32SXin Li		    arg="$non_pic_object"
5369*a376eb32SXin Li		  fi
5370*a376eb32SXin Li		else
5371*a376eb32SXin Li		  # If the PIC object exists, use it instead.
5372*a376eb32SXin Li		  # $xdir was prepended to $pic_object above.
5373*a376eb32SXin Li		  non_pic_object="$pic_object"
5374*a376eb32SXin Li		  func_append non_pic_objects " $non_pic_object"
5375*a376eb32SXin Li		fi
5376*a376eb32SXin Li	      else
5377*a376eb32SXin Li		# Only an error if not doing a dry-run.
5378*a376eb32SXin Li		if $opt_dry_run; then
5379*a376eb32SXin Li		  # Extract subdirectory from the argument.
5380*a376eb32SXin Li		  func_dirname "$arg" "/" ""
5381*a376eb32SXin Li		  xdir="$func_dirname_result"
5382*a376eb32SXin Li
5383*a376eb32SXin Li		  func_lo2o "$arg"
5384*a376eb32SXin Li		  pic_object=$xdir$objdir/$func_lo2o_result
5385*a376eb32SXin Li		  non_pic_object=$xdir$func_lo2o_result
5386*a376eb32SXin Li		  func_append libobjs " $pic_object"
5387*a376eb32SXin Li		  func_append non_pic_objects " $non_pic_object"
5388*a376eb32SXin Li	        else
5389*a376eb32SXin Li		  func_fatal_error "\`$arg' is not a valid libtool object"
5390*a376eb32SXin Li		fi
5391*a376eb32SXin Li	      fi
5392*a376eb32SXin Li	    done
5393*a376eb32SXin Li	  else
5394*a376eb32SXin Li	    func_fatal_error "link input file \`$arg' does not exist"
5395*a376eb32SXin Li	  fi
5396*a376eb32SXin Li	  arg=$save_arg
5397*a376eb32SXin Li	  prev=
5398*a376eb32SXin Li	  continue
5399*a376eb32SXin Li	  ;;
5400*a376eb32SXin Li	precious_regex)
5401*a376eb32SXin Li	  precious_files_regex="$arg"
5402*a376eb32SXin Li	  prev=
5403*a376eb32SXin Li	  continue
5404*a376eb32SXin Li	  ;;
5405*a376eb32SXin Li	release)
5406*a376eb32SXin Li	  release="-$arg"
5407*a376eb32SXin Li	  prev=
5408*a376eb32SXin Li	  continue
5409*a376eb32SXin Li	  ;;
5410*a376eb32SXin Li	rpath | xrpath)
5411*a376eb32SXin Li	  # We need an absolute path.
5412*a376eb32SXin Li	  case $arg in
5413*a376eb32SXin Li	  [\\/]* | [A-Za-z]:[\\/]*) ;;
5414*a376eb32SXin Li	  *)
5415*a376eb32SXin Li	    func_fatal_error "only absolute run-paths are allowed"
5416*a376eb32SXin Li	    ;;
5417*a376eb32SXin Li	  esac
5418*a376eb32SXin Li	  if test "$prev" = rpath; then
5419*a376eb32SXin Li	    case "$rpath " in
5420*a376eb32SXin Li	    *" $arg "*) ;;
5421*a376eb32SXin Li	    *) func_append rpath " $arg" ;;
5422*a376eb32SXin Li	    esac
5423*a376eb32SXin Li	  else
5424*a376eb32SXin Li	    case "$xrpath " in
5425*a376eb32SXin Li	    *" $arg "*) ;;
5426*a376eb32SXin Li	    *) func_append xrpath " $arg" ;;
5427*a376eb32SXin Li	    esac
5428*a376eb32SXin Li	  fi
5429*a376eb32SXin Li	  prev=
5430*a376eb32SXin Li	  continue
5431*a376eb32SXin Li	  ;;
5432*a376eb32SXin Li	shrext)
5433*a376eb32SXin Li	  shrext_cmds="$arg"
5434*a376eb32SXin Li	  prev=
5435*a376eb32SXin Li	  continue
5436*a376eb32SXin Li	  ;;
5437*a376eb32SXin Li	weak)
5438*a376eb32SXin Li	  func_append weak_libs " $arg"
5439*a376eb32SXin Li	  prev=
5440*a376eb32SXin Li	  continue
5441*a376eb32SXin Li	  ;;
5442*a376eb32SXin Li	xcclinker)
5443*a376eb32SXin Li	  func_append linker_flags " $qarg"
5444*a376eb32SXin Li	  func_append compiler_flags " $qarg"
5445*a376eb32SXin Li	  prev=
5446*a376eb32SXin Li	  func_append compile_command " $qarg"
5447*a376eb32SXin Li	  func_append finalize_command " $qarg"
5448*a376eb32SXin Li	  continue
5449*a376eb32SXin Li	  ;;
5450*a376eb32SXin Li	xcompiler)
5451*a376eb32SXin Li	  func_append compiler_flags " $qarg"
5452*a376eb32SXin Li	  prev=
5453*a376eb32SXin Li	  func_append compile_command " $qarg"
5454*a376eb32SXin Li	  func_append finalize_command " $qarg"
5455*a376eb32SXin Li	  continue
5456*a376eb32SXin Li	  ;;
5457*a376eb32SXin Li	xlinker)
5458*a376eb32SXin Li	  func_append linker_flags " $qarg"
5459*a376eb32SXin Li	  func_append compiler_flags " $wl$qarg"
5460*a376eb32SXin Li	  prev=
5461*a376eb32SXin Li	  func_append compile_command " $wl$qarg"
5462*a376eb32SXin Li	  func_append finalize_command " $wl$qarg"
5463*a376eb32SXin Li	  continue
5464*a376eb32SXin Li	  ;;
5465*a376eb32SXin Li	*)
5466*a376eb32SXin Li	  eval "$prev=\"\$arg\""
5467*a376eb32SXin Li	  prev=
5468*a376eb32SXin Li	  continue
5469*a376eb32SXin Li	  ;;
5470*a376eb32SXin Li	esac
5471*a376eb32SXin Li      fi # test -n "$prev"
5472*a376eb32SXin Li
5473*a376eb32SXin Li      prevarg="$arg"
5474*a376eb32SXin Li
5475*a376eb32SXin Li      case $arg in
5476*a376eb32SXin Li      -all-static)
5477*a376eb32SXin Li	if test -n "$link_static_flag"; then
5478*a376eb32SXin Li	  # See comment for -static flag below, for more details.
5479*a376eb32SXin Li	  func_append compile_command " $link_static_flag"
5480*a376eb32SXin Li	  func_append finalize_command " $link_static_flag"
5481*a376eb32SXin Li	fi
5482*a376eb32SXin Li	continue
5483*a376eb32SXin Li	;;
5484*a376eb32SXin Li
5485*a376eb32SXin Li      -allow-undefined)
5486*a376eb32SXin Li	# FIXME: remove this flag sometime in the future.
5487*a376eb32SXin Li	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
5488*a376eb32SXin Li	;;
5489*a376eb32SXin Li
5490*a376eb32SXin Li      -avoid-version)
5491*a376eb32SXin Li	avoid_version=yes
5492*a376eb32SXin Li	continue
5493*a376eb32SXin Li	;;
5494*a376eb32SXin Li
5495*a376eb32SXin Li      -bindir)
5496*a376eb32SXin Li	prev=bindir
5497*a376eb32SXin Li	continue
5498*a376eb32SXin Li	;;
5499*a376eb32SXin Li
5500*a376eb32SXin Li      -dlopen)
5501*a376eb32SXin Li	prev=dlfiles
5502*a376eb32SXin Li	continue
5503*a376eb32SXin Li	;;
5504*a376eb32SXin Li
5505*a376eb32SXin Li      -dlpreopen)
5506*a376eb32SXin Li	prev=dlprefiles
5507*a376eb32SXin Li	continue
5508*a376eb32SXin Li	;;
5509*a376eb32SXin Li
5510*a376eb32SXin Li      -export-dynamic)
5511*a376eb32SXin Li	export_dynamic=yes
5512*a376eb32SXin Li	continue
5513*a376eb32SXin Li	;;
5514*a376eb32SXin Li
5515*a376eb32SXin Li      -export-symbols | -export-symbols-regex)
5516*a376eb32SXin Li	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
5517*a376eb32SXin Li	  func_fatal_error "more than one -exported-symbols argument is not allowed"
5518*a376eb32SXin Li	fi
5519*a376eb32SXin Li	if test "X$arg" = "X-export-symbols"; then
5520*a376eb32SXin Li	  prev=expsyms
5521*a376eb32SXin Li	else
5522*a376eb32SXin Li	  prev=expsyms_regex
5523*a376eb32SXin Li	fi
5524*a376eb32SXin Li	continue
5525*a376eb32SXin Li	;;
5526*a376eb32SXin Li
5527*a376eb32SXin Li      -framework)
5528*a376eb32SXin Li	prev=framework
5529*a376eb32SXin Li	continue
5530*a376eb32SXin Li	;;
5531*a376eb32SXin Li
5532*a376eb32SXin Li      -inst-prefix-dir)
5533*a376eb32SXin Li	prev=inst_prefix
5534*a376eb32SXin Li	continue
5535*a376eb32SXin Li	;;
5536*a376eb32SXin Li
5537*a376eb32SXin Li      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
5538*a376eb32SXin Li      # so, if we see these flags be careful not to treat them like -L
5539*a376eb32SXin Li      -L[A-Z][A-Z]*:*)
5540*a376eb32SXin Li	case $with_gcc/$host in
5541*a376eb32SXin Li	no/*-*-irix* | /*-*-irix*)
5542*a376eb32SXin Li	  func_append compile_command " $arg"
5543*a376eb32SXin Li	  func_append finalize_command " $arg"
5544*a376eb32SXin Li	  ;;
5545*a376eb32SXin Li	esac
5546*a376eb32SXin Li	continue
5547*a376eb32SXin Li	;;
5548*a376eb32SXin Li
5549*a376eb32SXin Li      -L*)
5550*a376eb32SXin Li	func_stripname "-L" '' "$arg"
5551*a376eb32SXin Li	if test -z "$func_stripname_result"; then
5552*a376eb32SXin Li	  if test "$#" -gt 0; then
5553*a376eb32SXin Li	    func_fatal_error "require no space between \`-L' and \`$1'"
5554*a376eb32SXin Li	  else
5555*a376eb32SXin Li	    func_fatal_error "need path for \`-L' option"
5556*a376eb32SXin Li	  fi
5557*a376eb32SXin Li	fi
5558*a376eb32SXin Li	func_resolve_sysroot "$func_stripname_result"
5559*a376eb32SXin Li	dir=$func_resolve_sysroot_result
5560*a376eb32SXin Li	# We need an absolute path.
5561*a376eb32SXin Li	case $dir in
5562*a376eb32SXin Li	[\\/]* | [A-Za-z]:[\\/]*) ;;
5563*a376eb32SXin Li	*)
5564*a376eb32SXin Li	  absdir=`cd "$dir" && pwd`
5565*a376eb32SXin Li	  test -z "$absdir" && \
5566*a376eb32SXin Li	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
5567*a376eb32SXin Li	  dir="$absdir"
5568*a376eb32SXin Li	  ;;
5569*a376eb32SXin Li	esac
5570*a376eb32SXin Li	case "$deplibs " in
5571*a376eb32SXin Li	*" -L$dir "* | *" $arg "*)
5572*a376eb32SXin Li	  # Will only happen for absolute or sysroot arguments
5573*a376eb32SXin Li	  ;;
5574*a376eb32SXin Li	*)
5575*a376eb32SXin Li	  # Preserve sysroot, but never include relative directories
5576*a376eb32SXin Li	  case $dir in
5577*a376eb32SXin Li	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
5578*a376eb32SXin Li	    *) func_append deplibs " -L$dir" ;;
5579*a376eb32SXin Li	  esac
5580*a376eb32SXin Li	  func_append lib_search_path " $dir"
5581*a376eb32SXin Li	  ;;
5582*a376eb32SXin Li	esac
5583*a376eb32SXin Li	case $host in
5584*a376eb32SXin Li	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
5585*a376eb32SXin Li	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
5586*a376eb32SXin Li	  case :$dllsearchpath: in
5587*a376eb32SXin Li	  *":$dir:"*) ;;
5588*a376eb32SXin Li	  ::) dllsearchpath=$dir;;
5589*a376eb32SXin Li	  *) func_append dllsearchpath ":$dir";;
5590*a376eb32SXin Li	  esac
5591*a376eb32SXin Li	  case :$dllsearchpath: in
5592*a376eb32SXin Li	  *":$testbindir:"*) ;;
5593*a376eb32SXin Li	  ::) dllsearchpath=$testbindir;;
5594*a376eb32SXin Li	  *) func_append dllsearchpath ":$testbindir";;
5595*a376eb32SXin Li	  esac
5596*a376eb32SXin Li	  ;;
5597*a376eb32SXin Li	esac
5598*a376eb32SXin Li	continue
5599*a376eb32SXin Li	;;
5600*a376eb32SXin Li
5601*a376eb32SXin Li      -l*)
5602*a376eb32SXin Li	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
5603*a376eb32SXin Li	  case $host in
5604*a376eb32SXin Li	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
5605*a376eb32SXin Li	    # These systems don't actually have a C or math library (as such)
5606*a376eb32SXin Li	    continue
5607*a376eb32SXin Li	    ;;
5608*a376eb32SXin Li	  *-*-os2*)
5609*a376eb32SXin Li	    # These systems don't actually have a C library (as such)
5610*a376eb32SXin Li	    test "X$arg" = "X-lc" && continue
5611*a376eb32SXin Li	    ;;
5612*a376eb32SXin Li	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5613*a376eb32SXin Li	    # Do not include libc due to us having libc/libc_r.
5614*a376eb32SXin Li	    test "X$arg" = "X-lc" && continue
5615*a376eb32SXin Li	    ;;
5616*a376eb32SXin Li	  *-*-rhapsody* | *-*-darwin1.[012])
5617*a376eb32SXin Li	    # Rhapsody C and math libraries are in the System framework
5618*a376eb32SXin Li	    func_append deplibs " System.ltframework"
5619*a376eb32SXin Li	    continue
5620*a376eb32SXin Li	    ;;
5621*a376eb32SXin Li	  *-*-sco3.2v5* | *-*-sco5v6*)
5622*a376eb32SXin Li	    # Causes problems with __ctype
5623*a376eb32SXin Li	    test "X$arg" = "X-lc" && continue
5624*a376eb32SXin Li	    ;;
5625*a376eb32SXin Li	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
5626*a376eb32SXin Li	    # Compiler inserts libc in the correct place for threads to work
5627*a376eb32SXin Li	    test "X$arg" = "X-lc" && continue
5628*a376eb32SXin Li	    ;;
5629*a376eb32SXin Li	  esac
5630*a376eb32SXin Li	elif test "X$arg" = "X-lc_r"; then
5631*a376eb32SXin Li	 case $host in
5632*a376eb32SXin Li	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5633*a376eb32SXin Li	   # Do not include libc_r directly, use -pthread flag.
5634*a376eb32SXin Li	   continue
5635*a376eb32SXin Li	   ;;
5636*a376eb32SXin Li	 esac
5637*a376eb32SXin Li	fi
5638*a376eb32SXin Li	func_append deplibs " $arg"
5639*a376eb32SXin Li	continue
5640*a376eb32SXin Li	;;
5641*a376eb32SXin Li
5642*a376eb32SXin Li      -module)
5643*a376eb32SXin Li	module=yes
5644*a376eb32SXin Li	continue
5645*a376eb32SXin Li	;;
5646*a376eb32SXin Li
5647*a376eb32SXin Li      # Tru64 UNIX uses -model [arg] to determine the layout of C++
5648*a376eb32SXin Li      # classes, name mangling, and exception handling.
5649*a376eb32SXin Li      # Darwin uses the -arch flag to determine output architecture.
5650*a376eb32SXin Li      -model|-arch|-isysroot|--sysroot)
5651*a376eb32SXin Li	func_append compiler_flags " $arg"
5652*a376eb32SXin Li	func_append compile_command " $arg"
5653*a376eb32SXin Li	func_append finalize_command " $arg"
5654*a376eb32SXin Li	prev=xcompiler
5655*a376eb32SXin Li	continue
5656*a376eb32SXin Li	;;
5657*a376eb32SXin Li
5658*a376eb32SXin Li      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
5659*a376eb32SXin Li      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
5660*a376eb32SXin Li	func_append compiler_flags " $arg"
5661*a376eb32SXin Li	func_append compile_command " $arg"
5662*a376eb32SXin Li	func_append finalize_command " $arg"
5663*a376eb32SXin Li	case "$new_inherited_linker_flags " in
5664*a376eb32SXin Li	    *" $arg "*) ;;
5665*a376eb32SXin Li	    * ) func_append new_inherited_linker_flags " $arg" ;;
5666*a376eb32SXin Li	esac
5667*a376eb32SXin Li	continue
5668*a376eb32SXin Li	;;
5669*a376eb32SXin Li
5670*a376eb32SXin Li      -multi_module)
5671*a376eb32SXin Li	single_module="${wl}-multi_module"
5672*a376eb32SXin Li	continue
5673*a376eb32SXin Li	;;
5674*a376eb32SXin Li
5675*a376eb32SXin Li      -no-fast-install)
5676*a376eb32SXin Li	fast_install=no
5677*a376eb32SXin Li	continue
5678*a376eb32SXin Li	;;
5679*a376eb32SXin Li
5680*a376eb32SXin Li      -no-install)
5681*a376eb32SXin Li	case $host in
5682*a376eb32SXin Li	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
5683*a376eb32SXin Li	  # The PATH hackery in wrapper scripts is required on Windows
5684*a376eb32SXin Li	  # and Darwin in order for the loader to find any dlls it needs.
5685*a376eb32SXin Li	  func_warning "\`-no-install' is ignored for $host"
5686*a376eb32SXin Li	  func_warning "assuming \`-no-fast-install' instead"
5687*a376eb32SXin Li	  fast_install=no
5688*a376eb32SXin Li	  ;;
5689*a376eb32SXin Li	*) no_install=yes ;;
5690*a376eb32SXin Li	esac
5691*a376eb32SXin Li	continue
5692*a376eb32SXin Li	;;
5693*a376eb32SXin Li
5694*a376eb32SXin Li      -no-undefined)
5695*a376eb32SXin Li	allow_undefined=no
5696*a376eb32SXin Li	continue
5697*a376eb32SXin Li	;;
5698*a376eb32SXin Li
5699*a376eb32SXin Li      -objectlist)
5700*a376eb32SXin Li	prev=objectlist
5701*a376eb32SXin Li	continue
5702*a376eb32SXin Li	;;
5703*a376eb32SXin Li
5704*a376eb32SXin Li      -o) prev=output ;;
5705*a376eb32SXin Li
5706*a376eb32SXin Li      -precious-files-regex)
5707*a376eb32SXin Li	prev=precious_regex
5708*a376eb32SXin Li	continue
5709*a376eb32SXin Li	;;
5710*a376eb32SXin Li
5711*a376eb32SXin Li      -release)
5712*a376eb32SXin Li	prev=release
5713*a376eb32SXin Li	continue
5714*a376eb32SXin Li	;;
5715*a376eb32SXin Li
5716*a376eb32SXin Li      -rpath)
5717*a376eb32SXin Li	prev=rpath
5718*a376eb32SXin Li	continue
5719*a376eb32SXin Li	;;
5720*a376eb32SXin Li
5721*a376eb32SXin Li      -R)
5722*a376eb32SXin Li	prev=xrpath
5723*a376eb32SXin Li	continue
5724*a376eb32SXin Li	;;
5725*a376eb32SXin Li
5726*a376eb32SXin Li      -R*)
5727*a376eb32SXin Li	func_stripname '-R' '' "$arg"
5728*a376eb32SXin Li	dir=$func_stripname_result
5729*a376eb32SXin Li	# We need an absolute path.
5730*a376eb32SXin Li	case $dir in
5731*a376eb32SXin Li	[\\/]* | [A-Za-z]:[\\/]*) ;;
5732*a376eb32SXin Li	=*)
5733*a376eb32SXin Li	  func_stripname '=' '' "$dir"
5734*a376eb32SXin Li	  dir=$lt_sysroot$func_stripname_result
5735*a376eb32SXin Li	  ;;
5736*a376eb32SXin Li	*)
5737*a376eb32SXin Li	  func_fatal_error "only absolute run-paths are allowed"
5738*a376eb32SXin Li	  ;;
5739*a376eb32SXin Li	esac
5740*a376eb32SXin Li	case "$xrpath " in
5741*a376eb32SXin Li	*" $dir "*) ;;
5742*a376eb32SXin Li	*) func_append xrpath " $dir" ;;
5743*a376eb32SXin Li	esac
5744*a376eb32SXin Li	continue
5745*a376eb32SXin Li	;;
5746*a376eb32SXin Li
5747*a376eb32SXin Li      -shared)
5748*a376eb32SXin Li	# The effects of -shared are defined in a previous loop.
5749*a376eb32SXin Li	continue
5750*a376eb32SXin Li	;;
5751*a376eb32SXin Li
5752*a376eb32SXin Li      -shrext)
5753*a376eb32SXin Li	prev=shrext
5754*a376eb32SXin Li	continue
5755*a376eb32SXin Li	;;
5756*a376eb32SXin Li
5757*a376eb32SXin Li      -static | -static-libtool-libs)
5758*a376eb32SXin Li	# The effects of -static are defined in a previous loop.
5759*a376eb32SXin Li	# We used to do the same as -all-static on platforms that
5760*a376eb32SXin Li	# didn't have a PIC flag, but the assumption that the effects
5761*a376eb32SXin Li	# would be equivalent was wrong.  It would break on at least
5762*a376eb32SXin Li	# Digital Unix and AIX.
5763*a376eb32SXin Li	continue
5764*a376eb32SXin Li	;;
5765*a376eb32SXin Li
5766*a376eb32SXin Li      -thread-safe)
5767*a376eb32SXin Li	thread_safe=yes
5768*a376eb32SXin Li	continue
5769*a376eb32SXin Li	;;
5770*a376eb32SXin Li
5771*a376eb32SXin Li      -version-info)
5772*a376eb32SXin Li	prev=vinfo
5773*a376eb32SXin Li	continue
5774*a376eb32SXin Li	;;
5775*a376eb32SXin Li
5776*a376eb32SXin Li      -version-number)
5777*a376eb32SXin Li	prev=vinfo
5778*a376eb32SXin Li	vinfo_number=yes
5779*a376eb32SXin Li	continue
5780*a376eb32SXin Li	;;
5781*a376eb32SXin Li
5782*a376eb32SXin Li      -weak)
5783*a376eb32SXin Li        prev=weak
5784*a376eb32SXin Li	continue
5785*a376eb32SXin Li	;;
5786*a376eb32SXin Li
5787*a376eb32SXin Li      -Wc,*)
5788*a376eb32SXin Li	func_stripname '-Wc,' '' "$arg"
5789*a376eb32SXin Li	args=$func_stripname_result
5790*a376eb32SXin Li	arg=
5791*a376eb32SXin Li	save_ifs="$IFS"; IFS=','
5792*a376eb32SXin Li	for flag in $args; do
5793*a376eb32SXin Li	  IFS="$save_ifs"
5794*a376eb32SXin Li          func_quote_for_eval "$flag"
5795*a376eb32SXin Li	  func_append arg " $func_quote_for_eval_result"
5796*a376eb32SXin Li	  func_append compiler_flags " $func_quote_for_eval_result"
5797*a376eb32SXin Li	done
5798*a376eb32SXin Li	IFS="$save_ifs"
5799*a376eb32SXin Li	func_stripname ' ' '' "$arg"
5800*a376eb32SXin Li	arg=$func_stripname_result
5801*a376eb32SXin Li	;;
5802*a376eb32SXin Li
5803*a376eb32SXin Li      -Wl,*)
5804*a376eb32SXin Li	func_stripname '-Wl,' '' "$arg"
5805*a376eb32SXin Li	args=$func_stripname_result
5806*a376eb32SXin Li	arg=
5807*a376eb32SXin Li	save_ifs="$IFS"; IFS=','
5808*a376eb32SXin Li	for flag in $args; do
5809*a376eb32SXin Li	  IFS="$save_ifs"
5810*a376eb32SXin Li          func_quote_for_eval "$flag"
5811*a376eb32SXin Li	  func_append arg " $wl$func_quote_for_eval_result"
5812*a376eb32SXin Li	  func_append compiler_flags " $wl$func_quote_for_eval_result"
5813*a376eb32SXin Li	  func_append linker_flags " $func_quote_for_eval_result"
5814*a376eb32SXin Li	done
5815*a376eb32SXin Li	IFS="$save_ifs"
5816*a376eb32SXin Li	func_stripname ' ' '' "$arg"
5817*a376eb32SXin Li	arg=$func_stripname_result
5818*a376eb32SXin Li	;;
5819*a376eb32SXin Li
5820*a376eb32SXin Li      -Xcompiler)
5821*a376eb32SXin Li	prev=xcompiler
5822*a376eb32SXin Li	continue
5823*a376eb32SXin Li	;;
5824*a376eb32SXin Li
5825*a376eb32SXin Li      -Xlinker)
5826*a376eb32SXin Li	prev=xlinker
5827*a376eb32SXin Li	continue
5828*a376eb32SXin Li	;;
5829*a376eb32SXin Li
5830*a376eb32SXin Li      -XCClinker)
5831*a376eb32SXin Li	prev=xcclinker
5832*a376eb32SXin Li	continue
5833*a376eb32SXin Li	;;
5834*a376eb32SXin Li
5835*a376eb32SXin Li      # -msg_* for osf cc
5836*a376eb32SXin Li      -msg_*)
5837*a376eb32SXin Li	func_quote_for_eval "$arg"
5838*a376eb32SXin Li	arg="$func_quote_for_eval_result"
5839*a376eb32SXin Li	;;
5840*a376eb32SXin Li
5841*a376eb32SXin Li      # Flags to be passed through unchanged, with rationale:
5842*a376eb32SXin Li      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
5843*a376eb32SXin Li      # -r[0-9][0-9]*        specify processor for the SGI compiler
5844*a376eb32SXin Li      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
5845*a376eb32SXin Li      # +DA*, +DD*           enable 64-bit mode for the HP compiler
5846*a376eb32SXin Li      # -q*                  compiler args for the IBM compiler
5847*a376eb32SXin Li      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
5848*a376eb32SXin Li      # -F/path              path to uninstalled frameworks, gcc on darwin
5849*a376eb32SXin Li      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
5850*a376eb32SXin Li      # @file                GCC response files
5851*a376eb32SXin Li      # -tp=*                Portland pgcc target processor selection
5852*a376eb32SXin Li      # --sysroot=*          for sysroot support
5853*a376eb32SXin Li      # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
5854*a376eb32SXin Li      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
5855*a376eb32SXin Li      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
5856*a376eb32SXin Li      -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
5857*a376eb32SXin Li        func_quote_for_eval "$arg"
5858*a376eb32SXin Li	arg="$func_quote_for_eval_result"
5859*a376eb32SXin Li        func_append compile_command " $arg"
5860*a376eb32SXin Li        func_append finalize_command " $arg"
5861*a376eb32SXin Li        func_append compiler_flags " $arg"
5862*a376eb32SXin Li        continue
5863*a376eb32SXin Li        ;;
5864*a376eb32SXin Li
5865*a376eb32SXin Li      # Some other compiler flag.
5866*a376eb32SXin Li      -* | +*)
5867*a376eb32SXin Li        func_quote_for_eval "$arg"
5868*a376eb32SXin Li	arg="$func_quote_for_eval_result"
5869*a376eb32SXin Li	;;
5870*a376eb32SXin Li
5871*a376eb32SXin Li      *.$objext)
5872*a376eb32SXin Li	# A standard object.
5873*a376eb32SXin Li	func_append objs " $arg"
5874*a376eb32SXin Li	;;
5875*a376eb32SXin Li
5876*a376eb32SXin Li      *.lo)
5877*a376eb32SXin Li	# A libtool-controlled object.
5878*a376eb32SXin Li
5879*a376eb32SXin Li	# Check to see that this really is a libtool object.
5880*a376eb32SXin Li	if func_lalib_unsafe_p "$arg"; then
5881*a376eb32SXin Li	  pic_object=
5882*a376eb32SXin Li	  non_pic_object=
5883*a376eb32SXin Li
5884*a376eb32SXin Li	  # Read the .lo file
5885*a376eb32SXin Li	  func_source "$arg"
5886*a376eb32SXin Li
5887*a376eb32SXin Li	  if test -z "$pic_object" ||
5888*a376eb32SXin Li	     test -z "$non_pic_object" ||
5889*a376eb32SXin Li	     test "$pic_object" = none &&
5890*a376eb32SXin Li	     test "$non_pic_object" = none; then
5891*a376eb32SXin Li	    func_fatal_error "cannot find name of object for \`$arg'"
5892*a376eb32SXin Li	  fi
5893*a376eb32SXin Li
5894*a376eb32SXin Li	  # Extract subdirectory from the argument.
5895*a376eb32SXin Li	  func_dirname "$arg" "/" ""
5896*a376eb32SXin Li	  xdir="$func_dirname_result"
5897*a376eb32SXin Li
5898*a376eb32SXin Li	  if test "$pic_object" != none; then
5899*a376eb32SXin Li	    # Prepend the subdirectory the object is found in.
5900*a376eb32SXin Li	    pic_object="$xdir$pic_object"
5901*a376eb32SXin Li
5902*a376eb32SXin Li	    if test "$prev" = dlfiles; then
5903*a376eb32SXin Li	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5904*a376eb32SXin Li		func_append dlfiles " $pic_object"
5905*a376eb32SXin Li		prev=
5906*a376eb32SXin Li		continue
5907*a376eb32SXin Li	      else
5908*a376eb32SXin Li		# If libtool objects are unsupported, then we need to preload.
5909*a376eb32SXin Li		prev=dlprefiles
5910*a376eb32SXin Li	      fi
5911*a376eb32SXin Li	    fi
5912*a376eb32SXin Li
5913*a376eb32SXin Li	    # CHECK ME:  I think I busted this.  -Ossama
5914*a376eb32SXin Li	    if test "$prev" = dlprefiles; then
5915*a376eb32SXin Li	      # Preload the old-style object.
5916*a376eb32SXin Li	      func_append dlprefiles " $pic_object"
5917*a376eb32SXin Li	      prev=
5918*a376eb32SXin Li	    fi
5919*a376eb32SXin Li
5920*a376eb32SXin Li	    # A PIC object.
5921*a376eb32SXin Li	    func_append libobjs " $pic_object"
5922*a376eb32SXin Li	    arg="$pic_object"
5923*a376eb32SXin Li	  fi
5924*a376eb32SXin Li
5925*a376eb32SXin Li	  # Non-PIC object.
5926*a376eb32SXin Li	  if test "$non_pic_object" != none; then
5927*a376eb32SXin Li	    # Prepend the subdirectory the object is found in.
5928*a376eb32SXin Li	    non_pic_object="$xdir$non_pic_object"
5929*a376eb32SXin Li
5930*a376eb32SXin Li	    # A standard non-PIC object
5931*a376eb32SXin Li	    func_append non_pic_objects " $non_pic_object"
5932*a376eb32SXin Li	    if test -z "$pic_object" || test "$pic_object" = none ; then
5933*a376eb32SXin Li	      arg="$non_pic_object"
5934*a376eb32SXin Li	    fi
5935*a376eb32SXin Li	  else
5936*a376eb32SXin Li	    # If the PIC object exists, use it instead.
5937*a376eb32SXin Li	    # $xdir was prepended to $pic_object above.
5938*a376eb32SXin Li	    non_pic_object="$pic_object"
5939*a376eb32SXin Li	    func_append non_pic_objects " $non_pic_object"
5940*a376eb32SXin Li	  fi
5941*a376eb32SXin Li	else
5942*a376eb32SXin Li	  # Only an error if not doing a dry-run.
5943*a376eb32SXin Li	  if $opt_dry_run; then
5944*a376eb32SXin Li	    # Extract subdirectory from the argument.
5945*a376eb32SXin Li	    func_dirname "$arg" "/" ""
5946*a376eb32SXin Li	    xdir="$func_dirname_result"
5947*a376eb32SXin Li
5948*a376eb32SXin Li	    func_lo2o "$arg"
5949*a376eb32SXin Li	    pic_object=$xdir$objdir/$func_lo2o_result
5950*a376eb32SXin Li	    non_pic_object=$xdir$func_lo2o_result
5951*a376eb32SXin Li	    func_append libobjs " $pic_object"
5952*a376eb32SXin Li	    func_append non_pic_objects " $non_pic_object"
5953*a376eb32SXin Li	  else
5954*a376eb32SXin Li	    func_fatal_error "\`$arg' is not a valid libtool object"
5955*a376eb32SXin Li	  fi
5956*a376eb32SXin Li	fi
5957*a376eb32SXin Li	;;
5958*a376eb32SXin Li
5959*a376eb32SXin Li      *.$libext)
5960*a376eb32SXin Li	# An archive.
5961*a376eb32SXin Li	func_append deplibs " $arg"
5962*a376eb32SXin Li	func_append old_deplibs " $arg"
5963*a376eb32SXin Li	continue
5964*a376eb32SXin Li	;;
5965*a376eb32SXin Li
5966*a376eb32SXin Li      *.la)
5967*a376eb32SXin Li	# A libtool-controlled library.
5968*a376eb32SXin Li
5969*a376eb32SXin Li	func_resolve_sysroot "$arg"
5970*a376eb32SXin Li	if test "$prev" = dlfiles; then
5971*a376eb32SXin Li	  # This library was specified with -dlopen.
5972*a376eb32SXin Li	  func_append dlfiles " $func_resolve_sysroot_result"
5973*a376eb32SXin Li	  prev=
5974*a376eb32SXin Li	elif test "$prev" = dlprefiles; then
5975*a376eb32SXin Li	  # The library was specified with -dlpreopen.
5976*a376eb32SXin Li	  func_append dlprefiles " $func_resolve_sysroot_result"
5977*a376eb32SXin Li	  prev=
5978*a376eb32SXin Li	else
5979*a376eb32SXin Li	  func_append deplibs " $func_resolve_sysroot_result"
5980*a376eb32SXin Li	fi
5981*a376eb32SXin Li	continue
5982*a376eb32SXin Li	;;
5983*a376eb32SXin Li
5984*a376eb32SXin Li      # Some other compiler argument.
5985*a376eb32SXin Li      *)
5986*a376eb32SXin Li	# Unknown arguments in both finalize_command and compile_command need
5987*a376eb32SXin Li	# to be aesthetically quoted because they are evaled later.
5988*a376eb32SXin Li	func_quote_for_eval "$arg"
5989*a376eb32SXin Li	arg="$func_quote_for_eval_result"
5990*a376eb32SXin Li	;;
5991*a376eb32SXin Li      esac # arg
5992*a376eb32SXin Li
5993*a376eb32SXin Li      # Now actually substitute the argument into the commands.
5994*a376eb32SXin Li      if test -n "$arg"; then
5995*a376eb32SXin Li	func_append compile_command " $arg"
5996*a376eb32SXin Li	func_append finalize_command " $arg"
5997*a376eb32SXin Li      fi
5998*a376eb32SXin Li    done # argument parsing loop
5999*a376eb32SXin Li
6000*a376eb32SXin Li    test -n "$prev" && \
6001*a376eb32SXin Li      func_fatal_help "the \`$prevarg' option requires an argument"
6002*a376eb32SXin Li
6003*a376eb32SXin Li    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
6004*a376eb32SXin Li      eval arg=\"$export_dynamic_flag_spec\"
6005*a376eb32SXin Li      func_append compile_command " $arg"
6006*a376eb32SXin Li      func_append finalize_command " $arg"
6007*a376eb32SXin Li    fi
6008*a376eb32SXin Li
6009*a376eb32SXin Li    oldlibs=
6010*a376eb32SXin Li    # calculate the name of the file, without its directory
6011*a376eb32SXin Li    func_basename "$output"
6012*a376eb32SXin Li    outputname="$func_basename_result"
6013*a376eb32SXin Li    libobjs_save="$libobjs"
6014*a376eb32SXin Li
6015*a376eb32SXin Li    if test -n "$shlibpath_var"; then
6016*a376eb32SXin Li      # get the directories listed in $shlibpath_var
6017*a376eb32SXin Li      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
6018*a376eb32SXin Li    else
6019*a376eb32SXin Li      shlib_search_path=
6020*a376eb32SXin Li    fi
6021*a376eb32SXin Li    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
6022*a376eb32SXin Li    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
6023*a376eb32SXin Li
6024*a376eb32SXin Li    func_dirname "$output" "/" ""
6025*a376eb32SXin Li    output_objdir="$func_dirname_result$objdir"
6026*a376eb32SXin Li    func_to_tool_file "$output_objdir/"
6027*a376eb32SXin Li    tool_output_objdir=$func_to_tool_file_result
6028*a376eb32SXin Li    # Create the object directory.
6029*a376eb32SXin Li    func_mkdir_p "$output_objdir"
6030*a376eb32SXin Li
6031*a376eb32SXin Li    # Determine the type of output
6032*a376eb32SXin Li    case $output in
6033*a376eb32SXin Li    "")
6034*a376eb32SXin Li      func_fatal_help "you must specify an output file"
6035*a376eb32SXin Li      ;;
6036*a376eb32SXin Li    *.$libext) linkmode=oldlib ;;
6037*a376eb32SXin Li    *.lo | *.$objext) linkmode=obj ;;
6038*a376eb32SXin Li    *.la) linkmode=lib ;;
6039*a376eb32SXin Li    *) linkmode=prog ;; # Anything else should be a program.
6040*a376eb32SXin Li    esac
6041*a376eb32SXin Li
6042*a376eb32SXin Li    specialdeplibs=
6043*a376eb32SXin Li
6044*a376eb32SXin Li    libs=
6045*a376eb32SXin Li    # Find all interdependent deplibs by searching for libraries
6046*a376eb32SXin Li    # that are linked more than once (e.g. -la -lb -la)
6047*a376eb32SXin Li    for deplib in $deplibs; do
6048*a376eb32SXin Li      if $opt_preserve_dup_deps ; then
6049*a376eb32SXin Li	case "$libs " in
6050*a376eb32SXin Li	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
6051*a376eb32SXin Li	esac
6052*a376eb32SXin Li      fi
6053*a376eb32SXin Li      func_append libs " $deplib"
6054*a376eb32SXin Li    done
6055*a376eb32SXin Li
6056*a376eb32SXin Li    if test "$linkmode" = lib; then
6057*a376eb32SXin Li      libs="$predeps $libs $compiler_lib_search_path $postdeps"
6058*a376eb32SXin Li
6059*a376eb32SXin Li      # Compute libraries that are listed more than once in $predeps
6060*a376eb32SXin Li      # $postdeps and mark them as special (i.e., whose duplicates are
6061*a376eb32SXin Li      # not to be eliminated).
6062*a376eb32SXin Li      pre_post_deps=
6063*a376eb32SXin Li      if $opt_duplicate_compiler_generated_deps; then
6064*a376eb32SXin Li	for pre_post_dep in $predeps $postdeps; do
6065*a376eb32SXin Li	  case "$pre_post_deps " in
6066*a376eb32SXin Li	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
6067*a376eb32SXin Li	  esac
6068*a376eb32SXin Li	  func_append pre_post_deps " $pre_post_dep"
6069*a376eb32SXin Li	done
6070*a376eb32SXin Li      fi
6071*a376eb32SXin Li      pre_post_deps=
6072*a376eb32SXin Li    fi
6073*a376eb32SXin Li
6074*a376eb32SXin Li    deplibs=
6075*a376eb32SXin Li    newdependency_libs=
6076*a376eb32SXin Li    newlib_search_path=
6077*a376eb32SXin Li    need_relink=no # whether we're linking any uninstalled libtool libraries
6078*a376eb32SXin Li    notinst_deplibs= # not-installed libtool libraries
6079*a376eb32SXin Li    notinst_path= # paths that contain not-installed libtool libraries
6080*a376eb32SXin Li
6081*a376eb32SXin Li    case $linkmode in
6082*a376eb32SXin Li    lib)
6083*a376eb32SXin Li	passes="conv dlpreopen link"
6084*a376eb32SXin Li	for file in $dlfiles $dlprefiles; do
6085*a376eb32SXin Li	  case $file in
6086*a376eb32SXin Li	  *.la) ;;
6087*a376eb32SXin Li	  *)
6088*a376eb32SXin Li	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
6089*a376eb32SXin Li	    ;;
6090*a376eb32SXin Li	  esac
6091*a376eb32SXin Li	done
6092*a376eb32SXin Li	;;
6093*a376eb32SXin Li    prog)
6094*a376eb32SXin Li	compile_deplibs=
6095*a376eb32SXin Li	finalize_deplibs=
6096*a376eb32SXin Li	alldeplibs=no
6097*a376eb32SXin Li	newdlfiles=
6098*a376eb32SXin Li	newdlprefiles=
6099*a376eb32SXin Li	passes="conv scan dlopen dlpreopen link"
6100*a376eb32SXin Li	;;
6101*a376eb32SXin Li    *)  passes="conv"
6102*a376eb32SXin Li	;;
6103*a376eb32SXin Li    esac
6104*a376eb32SXin Li
6105*a376eb32SXin Li    for pass in $passes; do
6106*a376eb32SXin Li      # The preopen pass in lib mode reverses $deplibs; put it back here
6107*a376eb32SXin Li      # so that -L comes before libs that need it for instance...
6108*a376eb32SXin Li      if test "$linkmode,$pass" = "lib,link"; then
6109*a376eb32SXin Li	## FIXME: Find the place where the list is rebuilt in the wrong
6110*a376eb32SXin Li	##        order, and fix it there properly
6111*a376eb32SXin Li        tmp_deplibs=
6112*a376eb32SXin Li	for deplib in $deplibs; do
6113*a376eb32SXin Li	  tmp_deplibs="$deplib $tmp_deplibs"
6114*a376eb32SXin Li	done
6115*a376eb32SXin Li	deplibs="$tmp_deplibs"
6116*a376eb32SXin Li      fi
6117*a376eb32SXin Li
6118*a376eb32SXin Li      if test "$linkmode,$pass" = "lib,link" ||
6119*a376eb32SXin Li	 test "$linkmode,$pass" = "prog,scan"; then
6120*a376eb32SXin Li	libs="$deplibs"
6121*a376eb32SXin Li	deplibs=
6122*a376eb32SXin Li      fi
6123*a376eb32SXin Li      if test "$linkmode" = prog; then
6124*a376eb32SXin Li	case $pass in
6125*a376eb32SXin Li	dlopen) libs="$dlfiles" ;;
6126*a376eb32SXin Li	dlpreopen) libs="$dlprefiles" ;;
6127*a376eb32SXin Li	link)
6128*a376eb32SXin Li	  libs="$deplibs %DEPLIBS%"
6129*a376eb32SXin Li	  test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
6130*a376eb32SXin Li	  ;;
6131*a376eb32SXin Li	esac
6132*a376eb32SXin Li      fi
6133*a376eb32SXin Li      if test "$linkmode,$pass" = "lib,dlpreopen"; then
6134*a376eb32SXin Li	# Collect and forward deplibs of preopened libtool libs
6135*a376eb32SXin Li	for lib in $dlprefiles; do
6136*a376eb32SXin Li	  # Ignore non-libtool-libs
6137*a376eb32SXin Li	  dependency_libs=
6138*a376eb32SXin Li	  func_resolve_sysroot "$lib"
6139*a376eb32SXin Li	  case $lib in
6140*a376eb32SXin Li	  *.la)	func_source "$func_resolve_sysroot_result" ;;
6141*a376eb32SXin Li	  esac
6142*a376eb32SXin Li
6143*a376eb32SXin Li	  # Collect preopened libtool deplibs, except any this library
6144*a376eb32SXin Li	  # has declared as weak libs
6145*a376eb32SXin Li	  for deplib in $dependency_libs; do
6146*a376eb32SXin Li	    func_basename "$deplib"
6147*a376eb32SXin Li            deplib_base=$func_basename_result
6148*a376eb32SXin Li	    case " $weak_libs " in
6149*a376eb32SXin Li	    *" $deplib_base "*) ;;
6150*a376eb32SXin Li	    *) func_append deplibs " $deplib" ;;
6151*a376eb32SXin Li	    esac
6152*a376eb32SXin Li	  done
6153*a376eb32SXin Li	done
6154*a376eb32SXin Li	libs="$dlprefiles"
6155*a376eb32SXin Li      fi
6156*a376eb32SXin Li      if test "$pass" = dlopen; then
6157*a376eb32SXin Li	# Collect dlpreopened libraries
6158*a376eb32SXin Li	save_deplibs="$deplibs"
6159*a376eb32SXin Li	deplibs=
6160*a376eb32SXin Li      fi
6161*a376eb32SXin Li
6162*a376eb32SXin Li      for deplib in $libs; do
6163*a376eb32SXin Li	lib=
6164*a376eb32SXin Li	found=no
6165*a376eb32SXin Li	case $deplib in
6166*a376eb32SXin Li	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
6167*a376eb32SXin Li        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
6168*a376eb32SXin Li	  if test "$linkmode,$pass" = "prog,link"; then
6169*a376eb32SXin Li	    compile_deplibs="$deplib $compile_deplibs"
6170*a376eb32SXin Li	    finalize_deplibs="$deplib $finalize_deplibs"
6171*a376eb32SXin Li	  else
6172*a376eb32SXin Li	    func_append compiler_flags " $deplib"
6173*a376eb32SXin Li	    if test "$linkmode" = lib ; then
6174*a376eb32SXin Li		case "$new_inherited_linker_flags " in
6175*a376eb32SXin Li		    *" $deplib "*) ;;
6176*a376eb32SXin Li		    * ) func_append new_inherited_linker_flags " $deplib" ;;
6177*a376eb32SXin Li		esac
6178*a376eb32SXin Li	    fi
6179*a376eb32SXin Li	  fi
6180*a376eb32SXin Li	  continue
6181*a376eb32SXin Li	  ;;
6182*a376eb32SXin Li	-l*)
6183*a376eb32SXin Li	  if test "$linkmode" != lib && test "$linkmode" != prog; then
6184*a376eb32SXin Li	    func_warning "\`-l' is ignored for archives/objects"
6185*a376eb32SXin Li	    continue
6186*a376eb32SXin Li	  fi
6187*a376eb32SXin Li	  func_stripname '-l' '' "$deplib"
6188*a376eb32SXin Li	  name=$func_stripname_result
6189*a376eb32SXin Li	  if test "$linkmode" = lib; then
6190*a376eb32SXin Li	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
6191*a376eb32SXin Li	  else
6192*a376eb32SXin Li	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
6193*a376eb32SXin Li	  fi
6194*a376eb32SXin Li	  for searchdir in $searchdirs; do
6195*a376eb32SXin Li	    for search_ext in .la $std_shrext .so .a; do
6196*a376eb32SXin Li	      # Search the libtool library
6197*a376eb32SXin Li	      lib="$searchdir/lib${name}${search_ext}"
6198*a376eb32SXin Li	      if test -f "$lib"; then
6199*a376eb32SXin Li		if test "$search_ext" = ".la"; then
6200*a376eb32SXin Li		  found=yes
6201*a376eb32SXin Li		else
6202*a376eb32SXin Li		  found=no
6203*a376eb32SXin Li		fi
6204*a376eb32SXin Li		break 2
6205*a376eb32SXin Li	      fi
6206*a376eb32SXin Li	    done
6207*a376eb32SXin Li	  done
6208*a376eb32SXin Li	  if test "$found" != yes; then
6209*a376eb32SXin Li	    # deplib doesn't seem to be a libtool library
6210*a376eb32SXin Li	    if test "$linkmode,$pass" = "prog,link"; then
6211*a376eb32SXin Li	      compile_deplibs="$deplib $compile_deplibs"
6212*a376eb32SXin Li	      finalize_deplibs="$deplib $finalize_deplibs"
6213*a376eb32SXin Li	    else
6214*a376eb32SXin Li	      deplibs="$deplib $deplibs"
6215*a376eb32SXin Li	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6216*a376eb32SXin Li	    fi
6217*a376eb32SXin Li	    continue
6218*a376eb32SXin Li	  else # deplib is a libtool library
6219*a376eb32SXin Li	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
6220*a376eb32SXin Li	    # We need to do some special things here, and not later.
6221*a376eb32SXin Li	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6222*a376eb32SXin Li	      case " $predeps $postdeps " in
6223*a376eb32SXin Li	      *" $deplib "*)
6224*a376eb32SXin Li		if func_lalib_p "$lib"; then
6225*a376eb32SXin Li		  library_names=
6226*a376eb32SXin Li		  old_library=
6227*a376eb32SXin Li		  func_source "$lib"
6228*a376eb32SXin Li		  for l in $old_library $library_names; do
6229*a376eb32SXin Li		    ll="$l"
6230*a376eb32SXin Li		  done
6231*a376eb32SXin Li		  if test "X$ll" = "X$old_library" ; then # only static version available
6232*a376eb32SXin Li		    found=no
6233*a376eb32SXin Li		    func_dirname "$lib" "" "."
6234*a376eb32SXin Li		    ladir="$func_dirname_result"
6235*a376eb32SXin Li		    lib=$ladir/$old_library
6236*a376eb32SXin Li		    if test "$linkmode,$pass" = "prog,link"; then
6237*a376eb32SXin Li		      compile_deplibs="$deplib $compile_deplibs"
6238*a376eb32SXin Li		      finalize_deplibs="$deplib $finalize_deplibs"
6239*a376eb32SXin Li		    else
6240*a376eb32SXin Li		      deplibs="$deplib $deplibs"
6241*a376eb32SXin Li		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6242*a376eb32SXin Li		    fi
6243*a376eb32SXin Li		    continue
6244*a376eb32SXin Li		  fi
6245*a376eb32SXin Li		fi
6246*a376eb32SXin Li		;;
6247*a376eb32SXin Li	      *) ;;
6248*a376eb32SXin Li	      esac
6249*a376eb32SXin Li	    fi
6250*a376eb32SXin Li	  fi
6251*a376eb32SXin Li	  ;; # -l
6252*a376eb32SXin Li	*.ltframework)
6253*a376eb32SXin Li	  if test "$linkmode,$pass" = "prog,link"; then
6254*a376eb32SXin Li	    compile_deplibs="$deplib $compile_deplibs"
6255*a376eb32SXin Li	    finalize_deplibs="$deplib $finalize_deplibs"
6256*a376eb32SXin Li	  else
6257*a376eb32SXin Li	    deplibs="$deplib $deplibs"
6258*a376eb32SXin Li	    if test "$linkmode" = lib ; then
6259*a376eb32SXin Li		case "$new_inherited_linker_flags " in
6260*a376eb32SXin Li		    *" $deplib "*) ;;
6261*a376eb32SXin Li		    * ) func_append new_inherited_linker_flags " $deplib" ;;
6262*a376eb32SXin Li		esac
6263*a376eb32SXin Li	    fi
6264*a376eb32SXin Li	  fi
6265*a376eb32SXin Li	  continue
6266*a376eb32SXin Li	  ;;
6267*a376eb32SXin Li	-L*)
6268*a376eb32SXin Li	  case $linkmode in
6269*a376eb32SXin Li	  lib)
6270*a376eb32SXin Li	    deplibs="$deplib $deplibs"
6271*a376eb32SXin Li	    test "$pass" = conv && continue
6272*a376eb32SXin Li	    newdependency_libs="$deplib $newdependency_libs"
6273*a376eb32SXin Li	    func_stripname '-L' '' "$deplib"
6274*a376eb32SXin Li	    func_resolve_sysroot "$func_stripname_result"
6275*a376eb32SXin Li	    func_append newlib_search_path " $func_resolve_sysroot_result"
6276*a376eb32SXin Li	    ;;
6277*a376eb32SXin Li	  prog)
6278*a376eb32SXin Li	    if test "$pass" = conv; then
6279*a376eb32SXin Li	      deplibs="$deplib $deplibs"
6280*a376eb32SXin Li	      continue
6281*a376eb32SXin Li	    fi
6282*a376eb32SXin Li	    if test "$pass" = scan; then
6283*a376eb32SXin Li	      deplibs="$deplib $deplibs"
6284*a376eb32SXin Li	    else
6285*a376eb32SXin Li	      compile_deplibs="$deplib $compile_deplibs"
6286*a376eb32SXin Li	      finalize_deplibs="$deplib $finalize_deplibs"
6287*a376eb32SXin Li	    fi
6288*a376eb32SXin Li	    func_stripname '-L' '' "$deplib"
6289*a376eb32SXin Li	    func_resolve_sysroot "$func_stripname_result"
6290*a376eb32SXin Li	    func_append newlib_search_path " $func_resolve_sysroot_result"
6291*a376eb32SXin Li	    ;;
6292*a376eb32SXin Li	  *)
6293*a376eb32SXin Li	    func_warning "\`-L' is ignored for archives/objects"
6294*a376eb32SXin Li	    ;;
6295*a376eb32SXin Li	  esac # linkmode
6296*a376eb32SXin Li	  continue
6297*a376eb32SXin Li	  ;; # -L
6298*a376eb32SXin Li	-R*)
6299*a376eb32SXin Li	  if test "$pass" = link; then
6300*a376eb32SXin Li	    func_stripname '-R' '' "$deplib"
6301*a376eb32SXin Li	    func_resolve_sysroot "$func_stripname_result"
6302*a376eb32SXin Li	    dir=$func_resolve_sysroot_result
6303*a376eb32SXin Li	    # Make sure the xrpath contains only unique directories.
6304*a376eb32SXin Li	    case "$xrpath " in
6305*a376eb32SXin Li	    *" $dir "*) ;;
6306*a376eb32SXin Li	    *) func_append xrpath " $dir" ;;
6307*a376eb32SXin Li	    esac
6308*a376eb32SXin Li	  fi
6309*a376eb32SXin Li	  deplibs="$deplib $deplibs"
6310*a376eb32SXin Li	  continue
6311*a376eb32SXin Li	  ;;
6312*a376eb32SXin Li	*.la)
6313*a376eb32SXin Li	  func_resolve_sysroot "$deplib"
6314*a376eb32SXin Li	  lib=$func_resolve_sysroot_result
6315*a376eb32SXin Li	  ;;
6316*a376eb32SXin Li	*.$libext)
6317*a376eb32SXin Li	  if test "$pass" = conv; then
6318*a376eb32SXin Li	    deplibs="$deplib $deplibs"
6319*a376eb32SXin Li	    continue
6320*a376eb32SXin Li	  fi
6321*a376eb32SXin Li	  case $linkmode in
6322*a376eb32SXin Li	  lib)
6323*a376eb32SXin Li	    # Linking convenience modules into shared libraries is allowed,
6324*a376eb32SXin Li	    # but linking other static libraries is non-portable.
6325*a376eb32SXin Li	    case " $dlpreconveniencelibs " in
6326*a376eb32SXin Li	    *" $deplib "*) ;;
6327*a376eb32SXin Li	    *)
6328*a376eb32SXin Li	      valid_a_lib=no
6329*a376eb32SXin Li	      case $deplibs_check_method in
6330*a376eb32SXin Li		match_pattern*)
6331*a376eb32SXin Li		  set dummy $deplibs_check_method; shift
6332*a376eb32SXin Li		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6333*a376eb32SXin Li		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
6334*a376eb32SXin Li		    | $EGREP "$match_pattern_regex" > /dev/null; then
6335*a376eb32SXin Li		    valid_a_lib=yes
6336*a376eb32SXin Li		  fi
6337*a376eb32SXin Li		;;
6338*a376eb32SXin Li		pass_all)
6339*a376eb32SXin Li		  valid_a_lib=yes
6340*a376eb32SXin Li		;;
6341*a376eb32SXin Li	      esac
6342*a376eb32SXin Li	      if test "$valid_a_lib" != yes; then
6343*a376eb32SXin Li		echo
6344*a376eb32SXin Li		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
6345*a376eb32SXin Li		echo "*** I have the capability to make that library automatically link in when"
6346*a376eb32SXin Li		echo "*** you link to this library.  But I can only do this if you have a"
6347*a376eb32SXin Li		echo "*** shared version of the library, which you do not appear to have"
6348*a376eb32SXin Li		echo "*** because the file extensions .$libext of this argument makes me believe"
6349*a376eb32SXin Li		echo "*** that it is just a static archive that I should not use here."
6350*a376eb32SXin Li	      else
6351*a376eb32SXin Li		echo
6352*a376eb32SXin Li		$ECHO "*** Warning: Linking the shared library $output against the"
6353*a376eb32SXin Li		$ECHO "*** static library $deplib is not portable!"
6354*a376eb32SXin Li		deplibs="$deplib $deplibs"
6355*a376eb32SXin Li	      fi
6356*a376eb32SXin Li	      ;;
6357*a376eb32SXin Li	    esac
6358*a376eb32SXin Li	    continue
6359*a376eb32SXin Li	    ;;
6360*a376eb32SXin Li	  prog)
6361*a376eb32SXin Li	    if test "$pass" != link; then
6362*a376eb32SXin Li	      deplibs="$deplib $deplibs"
6363*a376eb32SXin Li	    else
6364*a376eb32SXin Li	      compile_deplibs="$deplib $compile_deplibs"
6365*a376eb32SXin Li	      finalize_deplibs="$deplib $finalize_deplibs"
6366*a376eb32SXin Li	    fi
6367*a376eb32SXin Li	    continue
6368*a376eb32SXin Li	    ;;
6369*a376eb32SXin Li	  esac # linkmode
6370*a376eb32SXin Li	  ;; # *.$libext
6371*a376eb32SXin Li	*.lo | *.$objext)
6372*a376eb32SXin Li	  if test "$pass" = conv; then
6373*a376eb32SXin Li	    deplibs="$deplib $deplibs"
6374*a376eb32SXin Li	  elif test "$linkmode" = prog; then
6375*a376eb32SXin Li	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
6376*a376eb32SXin Li	      # If there is no dlopen support or we're linking statically,
6377*a376eb32SXin Li	      # we need to preload.
6378*a376eb32SXin Li	      func_append newdlprefiles " $deplib"
6379*a376eb32SXin Li	      compile_deplibs="$deplib $compile_deplibs"
6380*a376eb32SXin Li	      finalize_deplibs="$deplib $finalize_deplibs"
6381*a376eb32SXin Li	    else
6382*a376eb32SXin Li	      func_append newdlfiles " $deplib"
6383*a376eb32SXin Li	    fi
6384*a376eb32SXin Li	  fi
6385*a376eb32SXin Li	  continue
6386*a376eb32SXin Li	  ;;
6387*a376eb32SXin Li	%DEPLIBS%)
6388*a376eb32SXin Li	  alldeplibs=yes
6389*a376eb32SXin Li	  continue
6390*a376eb32SXin Li	  ;;
6391*a376eb32SXin Li	esac # case $deplib
6392*a376eb32SXin Li
6393*a376eb32SXin Li	if test "$found" = yes || test -f "$lib"; then :
6394*a376eb32SXin Li	else
6395*a376eb32SXin Li	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
6396*a376eb32SXin Li	fi
6397*a376eb32SXin Li
6398*a376eb32SXin Li	# Check to see that this really is a libtool archive.
6399*a376eb32SXin Li	func_lalib_unsafe_p "$lib" \
6400*a376eb32SXin Li	  || func_fatal_error "\`$lib' is not a valid libtool archive"
6401*a376eb32SXin Li
6402*a376eb32SXin Li	func_dirname "$lib" "" "."
6403*a376eb32SXin Li	ladir="$func_dirname_result"
6404*a376eb32SXin Li
6405*a376eb32SXin Li	dlname=
6406*a376eb32SXin Li	dlopen=
6407*a376eb32SXin Li	dlpreopen=
6408*a376eb32SXin Li	libdir=
6409*a376eb32SXin Li	library_names=
6410*a376eb32SXin Li	old_library=
6411*a376eb32SXin Li	inherited_linker_flags=
6412*a376eb32SXin Li	# If the library was installed with an old release of libtool,
6413*a376eb32SXin Li	# it will not redefine variables installed, or shouldnotlink
6414*a376eb32SXin Li	installed=yes
6415*a376eb32SXin Li	shouldnotlink=no
6416*a376eb32SXin Li	avoidtemprpath=
6417*a376eb32SXin Li
6418*a376eb32SXin Li
6419*a376eb32SXin Li	# Read the .la file
6420*a376eb32SXin Li	func_source "$lib"
6421*a376eb32SXin Li
6422*a376eb32SXin Li	# Convert "-framework foo" to "foo.ltframework"
6423*a376eb32SXin Li	if test -n "$inherited_linker_flags"; then
6424*a376eb32SXin Li	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
6425*a376eb32SXin Li	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
6426*a376eb32SXin Li	    case " $new_inherited_linker_flags " in
6427*a376eb32SXin Li	      *" $tmp_inherited_linker_flag "*) ;;
6428*a376eb32SXin Li	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
6429*a376eb32SXin Li	    esac
6430*a376eb32SXin Li	  done
6431*a376eb32SXin Li	fi
6432*a376eb32SXin Li	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
6433*a376eb32SXin Li	if test "$linkmode,$pass" = "lib,link" ||
6434*a376eb32SXin Li	   test "$linkmode,$pass" = "prog,scan" ||
6435*a376eb32SXin Li	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
6436*a376eb32SXin Li	  test -n "$dlopen" && func_append dlfiles " $dlopen"
6437*a376eb32SXin Li	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
6438*a376eb32SXin Li	fi
6439*a376eb32SXin Li
6440*a376eb32SXin Li	if test "$pass" = conv; then
6441*a376eb32SXin Li	  # Only check for convenience libraries
6442*a376eb32SXin Li	  deplibs="$lib $deplibs"
6443*a376eb32SXin Li	  if test -z "$libdir"; then
6444*a376eb32SXin Li	    if test -z "$old_library"; then
6445*a376eb32SXin Li	      func_fatal_error "cannot find name of link library for \`$lib'"
6446*a376eb32SXin Li	    fi
6447*a376eb32SXin Li	    # It is a libtool convenience library, so add in its objects.
6448*a376eb32SXin Li	    func_append convenience " $ladir/$objdir/$old_library"
6449*a376eb32SXin Li	    func_append old_convenience " $ladir/$objdir/$old_library"
6450*a376eb32SXin Li	    tmp_libs=
6451*a376eb32SXin Li	    for deplib in $dependency_libs; do
6452*a376eb32SXin Li	      deplibs="$deplib $deplibs"
6453*a376eb32SXin Li	      if $opt_preserve_dup_deps ; then
6454*a376eb32SXin Li		case "$tmp_libs " in
6455*a376eb32SXin Li		*" $deplib "*) func_append specialdeplibs " $deplib" ;;
6456*a376eb32SXin Li		esac
6457*a376eb32SXin Li	      fi
6458*a376eb32SXin Li	      func_append tmp_libs " $deplib"
6459*a376eb32SXin Li	    done
6460*a376eb32SXin Li	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
6461*a376eb32SXin Li	    func_fatal_error "\`$lib' is not a convenience library"
6462*a376eb32SXin Li	  fi
6463*a376eb32SXin Li	  continue
6464*a376eb32SXin Li	fi # $pass = conv
6465*a376eb32SXin Li
6466*a376eb32SXin Li
6467*a376eb32SXin Li	# Get the name of the library we link against.
6468*a376eb32SXin Li	linklib=
6469*a376eb32SXin Li	if test -n "$old_library" &&
6470*a376eb32SXin Li	   { test "$prefer_static_libs" = yes ||
6471*a376eb32SXin Li	     test "$prefer_static_libs,$installed" = "built,no"; }; then
6472*a376eb32SXin Li	  linklib=$old_library
6473*a376eb32SXin Li	else
6474*a376eb32SXin Li	  for l in $old_library $library_names; do
6475*a376eb32SXin Li	    linklib="$l"
6476*a376eb32SXin Li	  done
6477*a376eb32SXin Li	fi
6478*a376eb32SXin Li	if test -z "$linklib"; then
6479*a376eb32SXin Li	  func_fatal_error "cannot find name of link library for \`$lib'"
6480*a376eb32SXin Li	fi
6481*a376eb32SXin Li
6482*a376eb32SXin Li	# This library was specified with -dlopen.
6483*a376eb32SXin Li	if test "$pass" = dlopen; then
6484*a376eb32SXin Li	  if test -z "$libdir"; then
6485*a376eb32SXin Li	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
6486*a376eb32SXin Li	  fi
6487*a376eb32SXin Li	  if test -z "$dlname" ||
6488*a376eb32SXin Li	     test "$dlopen_support" != yes ||
6489*a376eb32SXin Li	     test "$build_libtool_libs" = no; then
6490*a376eb32SXin Li	    # If there is no dlname, no dlopen support or we're linking
6491*a376eb32SXin Li	    # statically, we need to preload.  We also need to preload any
6492*a376eb32SXin Li	    # dependent libraries so libltdl's deplib preloader doesn't
6493*a376eb32SXin Li	    # bomb out in the load deplibs phase.
6494*a376eb32SXin Li	    func_append dlprefiles " $lib $dependency_libs"
6495*a376eb32SXin Li	  else
6496*a376eb32SXin Li	    func_append newdlfiles " $lib"
6497*a376eb32SXin Li	  fi
6498*a376eb32SXin Li	  continue
6499*a376eb32SXin Li	fi # $pass = dlopen
6500*a376eb32SXin Li
6501*a376eb32SXin Li	# We need an absolute path.
6502*a376eb32SXin Li	case $ladir in
6503*a376eb32SXin Li	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
6504*a376eb32SXin Li	*)
6505*a376eb32SXin Li	  abs_ladir=`cd "$ladir" && pwd`
6506*a376eb32SXin Li	  if test -z "$abs_ladir"; then
6507*a376eb32SXin Li	    func_warning "cannot determine absolute directory name of \`$ladir'"
6508*a376eb32SXin Li	    func_warning "passing it literally to the linker, although it might fail"
6509*a376eb32SXin Li	    abs_ladir="$ladir"
6510*a376eb32SXin Li	  fi
6511*a376eb32SXin Li	  ;;
6512*a376eb32SXin Li	esac
6513*a376eb32SXin Li	func_basename "$lib"
6514*a376eb32SXin Li	laname="$func_basename_result"
6515*a376eb32SXin Li
6516*a376eb32SXin Li	# Find the relevant object directory and library name.
6517*a376eb32SXin Li	if test "X$installed" = Xyes; then
6518*a376eb32SXin Li	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6519*a376eb32SXin Li	    func_warning "library \`$lib' was moved."
6520*a376eb32SXin Li	    dir="$ladir"
6521*a376eb32SXin Li	    absdir="$abs_ladir"
6522*a376eb32SXin Li	    libdir="$abs_ladir"
6523*a376eb32SXin Li	  else
6524*a376eb32SXin Li	    dir="$lt_sysroot$libdir"
6525*a376eb32SXin Li	    absdir="$lt_sysroot$libdir"
6526*a376eb32SXin Li	  fi
6527*a376eb32SXin Li	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
6528*a376eb32SXin Li	else
6529*a376eb32SXin Li	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6530*a376eb32SXin Li	    dir="$ladir"
6531*a376eb32SXin Li	    absdir="$abs_ladir"
6532*a376eb32SXin Li	    # Remove this search path later
6533*a376eb32SXin Li	    func_append notinst_path " $abs_ladir"
6534*a376eb32SXin Li	  else
6535*a376eb32SXin Li	    dir="$ladir/$objdir"
6536*a376eb32SXin Li	    absdir="$abs_ladir/$objdir"
6537*a376eb32SXin Li	    # Remove this search path later
6538*a376eb32SXin Li	    func_append notinst_path " $abs_ladir"
6539*a376eb32SXin Li	  fi
6540*a376eb32SXin Li	fi # $installed = yes
6541*a376eb32SXin Li	func_stripname 'lib' '.la' "$laname"
6542*a376eb32SXin Li	name=$func_stripname_result
6543*a376eb32SXin Li
6544*a376eb32SXin Li	# This library was specified with -dlpreopen.
6545*a376eb32SXin Li	if test "$pass" = dlpreopen; then
6546*a376eb32SXin Li	  if test -z "$libdir" && test "$linkmode" = prog; then
6547*a376eb32SXin Li	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
6548*a376eb32SXin Li	  fi
6549*a376eb32SXin Li	  case "$host" in
6550*a376eb32SXin Li	    # special handling for platforms with PE-DLLs.
6551*a376eb32SXin Li	    *cygwin* | *mingw* | *cegcc* )
6552*a376eb32SXin Li	      # Linker will automatically link against shared library if both
6553*a376eb32SXin Li	      # static and shared are present.  Therefore, ensure we extract
6554*a376eb32SXin Li	      # symbols from the import library if a shared library is present
6555*a376eb32SXin Li	      # (otherwise, the dlopen module name will be incorrect).  We do
6556*a376eb32SXin Li	      # this by putting the import library name into $newdlprefiles.
6557*a376eb32SXin Li	      # We recover the dlopen module name by 'saving' the la file
6558*a376eb32SXin Li	      # name in a special purpose variable, and (later) extracting the
6559*a376eb32SXin Li	      # dlname from the la file.
6560*a376eb32SXin Li	      if test -n "$dlname"; then
6561*a376eb32SXin Li	        func_tr_sh "$dir/$linklib"
6562*a376eb32SXin Li	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
6563*a376eb32SXin Li	        func_append newdlprefiles " $dir/$linklib"
6564*a376eb32SXin Li	      else
6565*a376eb32SXin Li	        func_append newdlprefiles " $dir/$old_library"
6566*a376eb32SXin Li	        # Keep a list of preopened convenience libraries to check
6567*a376eb32SXin Li	        # that they are being used correctly in the link pass.
6568*a376eb32SXin Li	        test -z "$libdir" && \
6569*a376eb32SXin Li	          func_append dlpreconveniencelibs " $dir/$old_library"
6570*a376eb32SXin Li	      fi
6571*a376eb32SXin Li	    ;;
6572*a376eb32SXin Li	    * )
6573*a376eb32SXin Li	      # Prefer using a static library (so that no silly _DYNAMIC symbols
6574*a376eb32SXin Li	      # are required to link).
6575*a376eb32SXin Li	      if test -n "$old_library"; then
6576*a376eb32SXin Li	        func_append newdlprefiles " $dir/$old_library"
6577*a376eb32SXin Li	        # Keep a list of preopened convenience libraries to check
6578*a376eb32SXin Li	        # that they are being used correctly in the link pass.
6579*a376eb32SXin Li	        test -z "$libdir" && \
6580*a376eb32SXin Li	          func_append dlpreconveniencelibs " $dir/$old_library"
6581*a376eb32SXin Li	      # Otherwise, use the dlname, so that lt_dlopen finds it.
6582*a376eb32SXin Li	      elif test -n "$dlname"; then
6583*a376eb32SXin Li	        func_append newdlprefiles " $dir/$dlname"
6584*a376eb32SXin Li	      else
6585*a376eb32SXin Li	        func_append newdlprefiles " $dir/$linklib"
6586*a376eb32SXin Li	      fi
6587*a376eb32SXin Li	    ;;
6588*a376eb32SXin Li	  esac
6589*a376eb32SXin Li	fi # $pass = dlpreopen
6590*a376eb32SXin Li
6591*a376eb32SXin Li	if test -z "$libdir"; then
6592*a376eb32SXin Li	  # Link the convenience library
6593*a376eb32SXin Li	  if test "$linkmode" = lib; then
6594*a376eb32SXin Li	    deplibs="$dir/$old_library $deplibs"
6595*a376eb32SXin Li	  elif test "$linkmode,$pass" = "prog,link"; then
6596*a376eb32SXin Li	    compile_deplibs="$dir/$old_library $compile_deplibs"
6597*a376eb32SXin Li	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
6598*a376eb32SXin Li	  else
6599*a376eb32SXin Li	    deplibs="$lib $deplibs" # used for prog,scan pass
6600*a376eb32SXin Li	  fi
6601*a376eb32SXin Li	  continue
6602*a376eb32SXin Li	fi
6603*a376eb32SXin Li
6604*a376eb32SXin Li
6605*a376eb32SXin Li	if test "$linkmode" = prog && test "$pass" != link; then
6606*a376eb32SXin Li	  func_append newlib_search_path " $ladir"
6607*a376eb32SXin Li	  deplibs="$lib $deplibs"
6608*a376eb32SXin Li
6609*a376eb32SXin Li	  linkalldeplibs=no
6610*a376eb32SXin Li	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
6611*a376eb32SXin Li	     test "$build_libtool_libs" = no; then
6612*a376eb32SXin Li	    linkalldeplibs=yes
6613*a376eb32SXin Li	  fi
6614*a376eb32SXin Li
6615*a376eb32SXin Li	  tmp_libs=
6616*a376eb32SXin Li	  for deplib in $dependency_libs; do
6617*a376eb32SXin Li	    case $deplib in
6618*a376eb32SXin Li	    -L*) func_stripname '-L' '' "$deplib"
6619*a376eb32SXin Li	         func_resolve_sysroot "$func_stripname_result"
6620*a376eb32SXin Li	         func_append newlib_search_path " $func_resolve_sysroot_result"
6621*a376eb32SXin Li		 ;;
6622*a376eb32SXin Li	    esac
6623*a376eb32SXin Li	    # Need to link against all dependency_libs?
6624*a376eb32SXin Li	    if test "$linkalldeplibs" = yes; then
6625*a376eb32SXin Li	      deplibs="$deplib $deplibs"
6626*a376eb32SXin Li	    else
6627*a376eb32SXin Li	      # Need to hardcode shared library paths
6628*a376eb32SXin Li	      # or/and link against static libraries
6629*a376eb32SXin Li	      newdependency_libs="$deplib $newdependency_libs"
6630*a376eb32SXin Li	    fi
6631*a376eb32SXin Li	    if $opt_preserve_dup_deps ; then
6632*a376eb32SXin Li	      case "$tmp_libs " in
6633*a376eb32SXin Li	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
6634*a376eb32SXin Li	      esac
6635*a376eb32SXin Li	    fi
6636*a376eb32SXin Li	    func_append tmp_libs " $deplib"
6637*a376eb32SXin Li	  done # for deplib
6638*a376eb32SXin Li	  continue
6639*a376eb32SXin Li	fi # $linkmode = prog...
6640*a376eb32SXin Li
6641*a376eb32SXin Li	if test "$linkmode,$pass" = "prog,link"; then
6642*a376eb32SXin Li	  if test -n "$library_names" &&
6643*a376eb32SXin Li	     { { test "$prefer_static_libs" = no ||
6644*a376eb32SXin Li	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
6645*a376eb32SXin Li	       test -z "$old_library"; }; then
6646*a376eb32SXin Li	    # We need to hardcode the library path
6647*a376eb32SXin Li	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
6648*a376eb32SXin Li	      # Make sure the rpath contains only unique directories.
6649*a376eb32SXin Li	      case "$temp_rpath:" in
6650*a376eb32SXin Li	      *"$absdir:"*) ;;
6651*a376eb32SXin Li	      *) func_append temp_rpath "$absdir:" ;;
6652*a376eb32SXin Li	      esac
6653*a376eb32SXin Li	    fi
6654*a376eb32SXin Li
6655*a376eb32SXin Li	    # Hardcode the library path.
6656*a376eb32SXin Li	    # Skip directories that are in the system default run-time
6657*a376eb32SXin Li	    # search path.
6658*a376eb32SXin Li	    case " $sys_lib_dlsearch_path " in
6659*a376eb32SXin Li	    *" $absdir "*) ;;
6660*a376eb32SXin Li	    *)
6661*a376eb32SXin Li	      case "$compile_rpath " in
6662*a376eb32SXin Li	      *" $absdir "*) ;;
6663*a376eb32SXin Li	      *) func_append compile_rpath " $absdir" ;;
6664*a376eb32SXin Li	      esac
6665*a376eb32SXin Li	      ;;
6666*a376eb32SXin Li	    esac
6667*a376eb32SXin Li	    case " $sys_lib_dlsearch_path " in
6668*a376eb32SXin Li	    *" $libdir "*) ;;
6669*a376eb32SXin Li	    *)
6670*a376eb32SXin Li	      case "$finalize_rpath " in
6671*a376eb32SXin Li	      *" $libdir "*) ;;
6672*a376eb32SXin Li	      *) func_append finalize_rpath " $libdir" ;;
6673*a376eb32SXin Li	      esac
6674*a376eb32SXin Li	      ;;
6675*a376eb32SXin Li	    esac
6676*a376eb32SXin Li	  fi # $linkmode,$pass = prog,link...
6677*a376eb32SXin Li
6678*a376eb32SXin Li	  if test "$alldeplibs" = yes &&
6679*a376eb32SXin Li	     { test "$deplibs_check_method" = pass_all ||
6680*a376eb32SXin Li	       { test "$build_libtool_libs" = yes &&
6681*a376eb32SXin Li		 test -n "$library_names"; }; }; then
6682*a376eb32SXin Li	    # We only need to search for static libraries
6683*a376eb32SXin Li	    continue
6684*a376eb32SXin Li	  fi
6685*a376eb32SXin Li	fi
6686*a376eb32SXin Li
6687*a376eb32SXin Li	link_static=no # Whether the deplib will be linked statically
6688*a376eb32SXin Li	use_static_libs=$prefer_static_libs
6689*a376eb32SXin Li	if test "$use_static_libs" = built && test "$installed" = yes; then
6690*a376eb32SXin Li	  use_static_libs=no
6691*a376eb32SXin Li	fi
6692*a376eb32SXin Li	if test -n "$library_names" &&
6693*a376eb32SXin Li	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
6694*a376eb32SXin Li	  case $host in
6695*a376eb32SXin Li	  *cygwin* | *mingw* | *cegcc*)
6696*a376eb32SXin Li	      # No point in relinking DLLs because paths are not encoded
6697*a376eb32SXin Li	      func_append notinst_deplibs " $lib"
6698*a376eb32SXin Li	      need_relink=no
6699*a376eb32SXin Li	    ;;
6700*a376eb32SXin Li	  *)
6701*a376eb32SXin Li	    if test "$installed" = no; then
6702*a376eb32SXin Li	      func_append notinst_deplibs " $lib"
6703*a376eb32SXin Li	      need_relink=yes
6704*a376eb32SXin Li	    fi
6705*a376eb32SXin Li	    ;;
6706*a376eb32SXin Li	  esac
6707*a376eb32SXin Li	  # This is a shared library
6708*a376eb32SXin Li
6709*a376eb32SXin Li	  # Warn about portability, can't link against -module's on some
6710*a376eb32SXin Li	  # systems (darwin).  Don't bleat about dlopened modules though!
6711*a376eb32SXin Li	  dlopenmodule=""
6712*a376eb32SXin Li	  for dlpremoduletest in $dlprefiles; do
6713*a376eb32SXin Li	    if test "X$dlpremoduletest" = "X$lib"; then
6714*a376eb32SXin Li	      dlopenmodule="$dlpremoduletest"
6715*a376eb32SXin Li	      break
6716*a376eb32SXin Li	    fi
6717*a376eb32SXin Li	  done
6718*a376eb32SXin Li	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
6719*a376eb32SXin Li	    echo
6720*a376eb32SXin Li	    if test "$linkmode" = prog; then
6721*a376eb32SXin Li	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
6722*a376eb32SXin Li	    else
6723*a376eb32SXin Li	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
6724*a376eb32SXin Li	    fi
6725*a376eb32SXin Li	    $ECHO "*** $linklib is not portable!"
6726*a376eb32SXin Li	  fi
6727*a376eb32SXin Li	  if test "$linkmode" = lib &&
6728*a376eb32SXin Li	     test "$hardcode_into_libs" = yes; then
6729*a376eb32SXin Li	    # Hardcode the library path.
6730*a376eb32SXin Li	    # Skip directories that are in the system default run-time
6731*a376eb32SXin Li	    # search path.
6732*a376eb32SXin Li	    case " $sys_lib_dlsearch_path " in
6733*a376eb32SXin Li	    *" $absdir "*) ;;
6734*a376eb32SXin Li	    *)
6735*a376eb32SXin Li	      case "$compile_rpath " in
6736*a376eb32SXin Li	      *" $absdir "*) ;;
6737*a376eb32SXin Li	      *) func_append compile_rpath " $absdir" ;;
6738*a376eb32SXin Li	      esac
6739*a376eb32SXin Li	      ;;
6740*a376eb32SXin Li	    esac
6741*a376eb32SXin Li	    case " $sys_lib_dlsearch_path " in
6742*a376eb32SXin Li	    *" $libdir "*) ;;
6743*a376eb32SXin Li	    *)
6744*a376eb32SXin Li	      case "$finalize_rpath " in
6745*a376eb32SXin Li	      *" $libdir "*) ;;
6746*a376eb32SXin Li	      *) func_append finalize_rpath " $libdir" ;;
6747*a376eb32SXin Li	      esac
6748*a376eb32SXin Li	      ;;
6749*a376eb32SXin Li	    esac
6750*a376eb32SXin Li	  fi
6751*a376eb32SXin Li
6752*a376eb32SXin Li	  if test -n "$old_archive_from_expsyms_cmds"; then
6753*a376eb32SXin Li	    # figure out the soname
6754*a376eb32SXin Li	    set dummy $library_names
6755*a376eb32SXin Li	    shift
6756*a376eb32SXin Li	    realname="$1"
6757*a376eb32SXin Li	    shift
6758*a376eb32SXin Li	    libname=`eval "\\$ECHO \"$libname_spec\""`
6759*a376eb32SXin Li	    # use dlname if we got it. it's perfectly good, no?
6760*a376eb32SXin Li	    if test -n "$dlname"; then
6761*a376eb32SXin Li	      soname="$dlname"
6762*a376eb32SXin Li	    elif test -n "$soname_spec"; then
6763*a376eb32SXin Li	      # bleh windows
6764*a376eb32SXin Li	      case $host in
6765*a376eb32SXin Li	      *cygwin* | mingw* | *cegcc*)
6766*a376eb32SXin Li	        func_arith $current - $age
6767*a376eb32SXin Li		major=$func_arith_result
6768*a376eb32SXin Li		versuffix="-$major"
6769*a376eb32SXin Li		;;
6770*a376eb32SXin Li	      esac
6771*a376eb32SXin Li	      eval soname=\"$soname_spec\"
6772*a376eb32SXin Li	    else
6773*a376eb32SXin Li	      soname="$realname"
6774*a376eb32SXin Li	    fi
6775*a376eb32SXin Li
6776*a376eb32SXin Li	    # Make a new name for the extract_expsyms_cmds to use
6777*a376eb32SXin Li	    soroot="$soname"
6778*a376eb32SXin Li	    func_basename "$soroot"
6779*a376eb32SXin Li	    soname="$func_basename_result"
6780*a376eb32SXin Li	    func_stripname 'lib' '.dll' "$soname"
6781*a376eb32SXin Li	    newlib=libimp-$func_stripname_result.a
6782*a376eb32SXin Li
6783*a376eb32SXin Li	    # If the library has no export list, then create one now
6784*a376eb32SXin Li	    if test -f "$output_objdir/$soname-def"; then :
6785*a376eb32SXin Li	    else
6786*a376eb32SXin Li	      func_verbose "extracting exported symbol list from \`$soname'"
6787*a376eb32SXin Li	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
6788*a376eb32SXin Li	    fi
6789*a376eb32SXin Li
6790*a376eb32SXin Li	    # Create $newlib
6791*a376eb32SXin Li	    if test -f "$output_objdir/$newlib"; then :; else
6792*a376eb32SXin Li	      func_verbose "generating import library for \`$soname'"
6793*a376eb32SXin Li	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
6794*a376eb32SXin Li	    fi
6795*a376eb32SXin Li	    # make sure the library variables are pointing to the new library
6796*a376eb32SXin Li	    dir=$output_objdir
6797*a376eb32SXin Li	    linklib=$newlib
6798*a376eb32SXin Li	  fi # test -n "$old_archive_from_expsyms_cmds"
6799*a376eb32SXin Li
6800*a376eb32SXin Li	  if test "$linkmode" = prog || test "$opt_mode" != relink; then
6801*a376eb32SXin Li	    add_shlibpath=
6802*a376eb32SXin Li	    add_dir=
6803*a376eb32SXin Li	    add=
6804*a376eb32SXin Li	    lib_linked=yes
6805*a376eb32SXin Li	    case $hardcode_action in
6806*a376eb32SXin Li	    immediate | unsupported)
6807*a376eb32SXin Li	      if test "$hardcode_direct" = no; then
6808*a376eb32SXin Li		add="$dir/$linklib"
6809*a376eb32SXin Li		case $host in
6810*a376eb32SXin Li		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
6811*a376eb32SXin Li		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
6812*a376eb32SXin Li		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
6813*a376eb32SXin Li		    *-*-unixware7*) add_dir="-L$dir" ;;
6814*a376eb32SXin Li		  *-*-darwin* )
6815*a376eb32SXin Li		    # if the lib is a (non-dlopened) module then we can not
6816*a376eb32SXin Li		    # link against it, someone is ignoring the earlier warnings
6817*a376eb32SXin Li		    if /usr/bin/file -L $add 2> /dev/null |
6818*a376eb32SXin Li			 $GREP ": [^:]* bundle" >/dev/null ; then
6819*a376eb32SXin Li		      if test "X$dlopenmodule" != "X$lib"; then
6820*a376eb32SXin Li			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
6821*a376eb32SXin Li			if test -z "$old_library" ; then
6822*a376eb32SXin Li			  echo
6823*a376eb32SXin Li			  echo "*** And there doesn't seem to be a static archive available"
6824*a376eb32SXin Li			  echo "*** The link will probably fail, sorry"
6825*a376eb32SXin Li			else
6826*a376eb32SXin Li			  add="$dir/$old_library"
6827*a376eb32SXin Li			fi
6828*a376eb32SXin Li		      elif test -n "$old_library"; then
6829*a376eb32SXin Li			add="$dir/$old_library"
6830*a376eb32SXin Li		      fi
6831*a376eb32SXin Li		    fi
6832*a376eb32SXin Li		esac
6833*a376eb32SXin Li	      elif test "$hardcode_minus_L" = no; then
6834*a376eb32SXin Li		case $host in
6835*a376eb32SXin Li		*-*-sunos*) add_shlibpath="$dir" ;;
6836*a376eb32SXin Li		esac
6837*a376eb32SXin Li		add_dir="-L$dir"
6838*a376eb32SXin Li		add="-l$name"
6839*a376eb32SXin Li	      elif test "$hardcode_shlibpath_var" = no; then
6840*a376eb32SXin Li		add_shlibpath="$dir"
6841*a376eb32SXin Li		add="-l$name"
6842*a376eb32SXin Li	      else
6843*a376eb32SXin Li		lib_linked=no
6844*a376eb32SXin Li	      fi
6845*a376eb32SXin Li	      ;;
6846*a376eb32SXin Li	    relink)
6847*a376eb32SXin Li	      if test "$hardcode_direct" = yes &&
6848*a376eb32SXin Li	         test "$hardcode_direct_absolute" = no; then
6849*a376eb32SXin Li		add="$dir/$linklib"
6850*a376eb32SXin Li	      elif test "$hardcode_minus_L" = yes; then
6851*a376eb32SXin Li		add_dir="-L$absdir"
6852*a376eb32SXin Li		# Try looking first in the location we're being installed to.
6853*a376eb32SXin Li		if test -n "$inst_prefix_dir"; then
6854*a376eb32SXin Li		  case $libdir in
6855*a376eb32SXin Li		    [\\/]*)
6856*a376eb32SXin Li		      func_append add_dir " -L$inst_prefix_dir$libdir"
6857*a376eb32SXin Li		      ;;
6858*a376eb32SXin Li		  esac
6859*a376eb32SXin Li		fi
6860*a376eb32SXin Li		add="-l$name"
6861*a376eb32SXin Li	      elif test "$hardcode_shlibpath_var" = yes; then
6862*a376eb32SXin Li		add_shlibpath="$dir"
6863*a376eb32SXin Li		add="-l$name"
6864*a376eb32SXin Li	      else
6865*a376eb32SXin Li		lib_linked=no
6866*a376eb32SXin Li	      fi
6867*a376eb32SXin Li	      ;;
6868*a376eb32SXin Li	    *) lib_linked=no ;;
6869*a376eb32SXin Li	    esac
6870*a376eb32SXin Li
6871*a376eb32SXin Li	    if test "$lib_linked" != yes; then
6872*a376eb32SXin Li	      func_fatal_configuration "unsupported hardcode properties"
6873*a376eb32SXin Li	    fi
6874*a376eb32SXin Li
6875*a376eb32SXin Li	    if test -n "$add_shlibpath"; then
6876*a376eb32SXin Li	      case :$compile_shlibpath: in
6877*a376eb32SXin Li	      *":$add_shlibpath:"*) ;;
6878*a376eb32SXin Li	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
6879*a376eb32SXin Li	      esac
6880*a376eb32SXin Li	    fi
6881*a376eb32SXin Li	    if test "$linkmode" = prog; then
6882*a376eb32SXin Li	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
6883*a376eb32SXin Li	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
6884*a376eb32SXin Li	    else
6885*a376eb32SXin Li	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
6886*a376eb32SXin Li	      test -n "$add" && deplibs="$add $deplibs"
6887*a376eb32SXin Li	      if test "$hardcode_direct" != yes &&
6888*a376eb32SXin Li		 test "$hardcode_minus_L" != yes &&
6889*a376eb32SXin Li		 test "$hardcode_shlibpath_var" = yes; then
6890*a376eb32SXin Li		case :$finalize_shlibpath: in
6891*a376eb32SXin Li		*":$libdir:"*) ;;
6892*a376eb32SXin Li		*) func_append finalize_shlibpath "$libdir:" ;;
6893*a376eb32SXin Li		esac
6894*a376eb32SXin Li	      fi
6895*a376eb32SXin Li	    fi
6896*a376eb32SXin Li	  fi
6897*a376eb32SXin Li
6898*a376eb32SXin Li	  if test "$linkmode" = prog || test "$opt_mode" = relink; then
6899*a376eb32SXin Li	    add_shlibpath=
6900*a376eb32SXin Li	    add_dir=
6901*a376eb32SXin Li	    add=
6902*a376eb32SXin Li	    # Finalize command for both is simple: just hardcode it.
6903*a376eb32SXin Li	    if test "$hardcode_direct" = yes &&
6904*a376eb32SXin Li	       test "$hardcode_direct_absolute" = no; then
6905*a376eb32SXin Li	      add="$libdir/$linklib"
6906*a376eb32SXin Li	    elif test "$hardcode_minus_L" = yes; then
6907*a376eb32SXin Li	      add_dir="-L$libdir"
6908*a376eb32SXin Li	      add="-l$name"
6909*a376eb32SXin Li	    elif test "$hardcode_shlibpath_var" = yes; then
6910*a376eb32SXin Li	      case :$finalize_shlibpath: in
6911*a376eb32SXin Li	      *":$libdir:"*) ;;
6912*a376eb32SXin Li	      *) func_append finalize_shlibpath "$libdir:" ;;
6913*a376eb32SXin Li	      esac
6914*a376eb32SXin Li	      add="-l$name"
6915*a376eb32SXin Li	    elif test "$hardcode_automatic" = yes; then
6916*a376eb32SXin Li	      if test -n "$inst_prefix_dir" &&
6917*a376eb32SXin Li		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
6918*a376eb32SXin Li		add="$inst_prefix_dir$libdir/$linklib"
6919*a376eb32SXin Li	      else
6920*a376eb32SXin Li		add="$libdir/$linklib"
6921*a376eb32SXin Li	      fi
6922*a376eb32SXin Li	    else
6923*a376eb32SXin Li	      # We cannot seem to hardcode it, guess we'll fake it.
6924*a376eb32SXin Li	      add_dir="-L$libdir"
6925*a376eb32SXin Li	      # Try looking first in the location we're being installed to.
6926*a376eb32SXin Li	      if test -n "$inst_prefix_dir"; then
6927*a376eb32SXin Li		case $libdir in
6928*a376eb32SXin Li		  [\\/]*)
6929*a376eb32SXin Li		    func_append add_dir " -L$inst_prefix_dir$libdir"
6930*a376eb32SXin Li		    ;;
6931*a376eb32SXin Li		esac
6932*a376eb32SXin Li	      fi
6933*a376eb32SXin Li	      add="-l$name"
6934*a376eb32SXin Li	    fi
6935*a376eb32SXin Li
6936*a376eb32SXin Li	    if test "$linkmode" = prog; then
6937*a376eb32SXin Li	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
6938*a376eb32SXin Li	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
6939*a376eb32SXin Li	    else
6940*a376eb32SXin Li	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
6941*a376eb32SXin Li	      test -n "$add" && deplibs="$add $deplibs"
6942*a376eb32SXin Li	    fi
6943*a376eb32SXin Li	  fi
6944*a376eb32SXin Li	elif test "$linkmode" = prog; then
6945*a376eb32SXin Li	  # Here we assume that one of hardcode_direct or hardcode_minus_L
6946*a376eb32SXin Li	  # is not unsupported.  This is valid on all known static and
6947*a376eb32SXin Li	  # shared platforms.
6948*a376eb32SXin Li	  if test "$hardcode_direct" != unsupported; then
6949*a376eb32SXin Li	    test -n "$old_library" && linklib="$old_library"
6950*a376eb32SXin Li	    compile_deplibs="$dir/$linklib $compile_deplibs"
6951*a376eb32SXin Li	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
6952*a376eb32SXin Li	  else
6953*a376eb32SXin Li	    compile_deplibs="-l$name -L$dir $compile_deplibs"
6954*a376eb32SXin Li	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
6955*a376eb32SXin Li	  fi
6956*a376eb32SXin Li	elif test "$build_libtool_libs" = yes; then
6957*a376eb32SXin Li	  # Not a shared library
6958*a376eb32SXin Li	  if test "$deplibs_check_method" != pass_all; then
6959*a376eb32SXin Li	    # We're trying link a shared library against a static one
6960*a376eb32SXin Li	    # but the system doesn't support it.
6961*a376eb32SXin Li
6962*a376eb32SXin Li	    # Just print a warning and add the library to dependency_libs so
6963*a376eb32SXin Li	    # that the program can be linked against the static library.
6964*a376eb32SXin Li	    echo
6965*a376eb32SXin Li	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
6966*a376eb32SXin Li	    echo "*** I have the capability to make that library automatically link in when"
6967*a376eb32SXin Li	    echo "*** you link to this library.  But I can only do this if you have a"
6968*a376eb32SXin Li	    echo "*** shared version of the library, which you do not appear to have."
6969*a376eb32SXin Li	    if test "$module" = yes; then
6970*a376eb32SXin Li	      echo "*** But as you try to build a module library, libtool will still create "
6971*a376eb32SXin Li	      echo "*** a static module, that should work as long as the dlopening application"
6972*a376eb32SXin Li	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
6973*a376eb32SXin Li	      if test -z "$global_symbol_pipe"; then
6974*a376eb32SXin Li		echo
6975*a376eb32SXin Li		echo "*** However, this would only work if libtool was able to extract symbol"
6976*a376eb32SXin Li		echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
6977*a376eb32SXin Li		echo "*** not find such a program.  So, this module is probably useless."
6978*a376eb32SXin Li		echo "*** \`nm' from GNU binutils and a full rebuild may help."
6979*a376eb32SXin Li	      fi
6980*a376eb32SXin Li	      if test "$build_old_libs" = no; then
6981*a376eb32SXin Li		build_libtool_libs=module
6982*a376eb32SXin Li		build_old_libs=yes
6983*a376eb32SXin Li	      else
6984*a376eb32SXin Li		build_libtool_libs=no
6985*a376eb32SXin Li	      fi
6986*a376eb32SXin Li	    fi
6987*a376eb32SXin Li	  else
6988*a376eb32SXin Li	    deplibs="$dir/$old_library $deplibs"
6989*a376eb32SXin Li	    link_static=yes
6990*a376eb32SXin Li	  fi
6991*a376eb32SXin Li	fi # link shared/static library?
6992*a376eb32SXin Li
6993*a376eb32SXin Li	if test "$linkmode" = lib; then
6994*a376eb32SXin Li	  if test -n "$dependency_libs" &&
6995*a376eb32SXin Li	     { test "$hardcode_into_libs" != yes ||
6996*a376eb32SXin Li	       test "$build_old_libs" = yes ||
6997*a376eb32SXin Li	       test "$link_static" = yes; }; then
6998*a376eb32SXin Li	    # Extract -R from dependency_libs
6999*a376eb32SXin Li	    temp_deplibs=
7000*a376eb32SXin Li	    for libdir in $dependency_libs; do
7001*a376eb32SXin Li	      case $libdir in
7002*a376eb32SXin Li	      -R*) func_stripname '-R' '' "$libdir"
7003*a376eb32SXin Li	           temp_xrpath=$func_stripname_result
7004*a376eb32SXin Li		   case " $xrpath " in
7005*a376eb32SXin Li		   *" $temp_xrpath "*) ;;
7006*a376eb32SXin Li		   *) func_append xrpath " $temp_xrpath";;
7007*a376eb32SXin Li		   esac;;
7008*a376eb32SXin Li	      *) func_append temp_deplibs " $libdir";;
7009*a376eb32SXin Li	      esac
7010*a376eb32SXin Li	    done
7011*a376eb32SXin Li	    dependency_libs="$temp_deplibs"
7012*a376eb32SXin Li	  fi
7013*a376eb32SXin Li
7014*a376eb32SXin Li	  func_append newlib_search_path " $absdir"
7015*a376eb32SXin Li	  # Link against this library
7016*a376eb32SXin Li	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
7017*a376eb32SXin Li	  # ... and its dependency_libs
7018*a376eb32SXin Li	  tmp_libs=
7019*a376eb32SXin Li	  for deplib in $dependency_libs; do
7020*a376eb32SXin Li	    newdependency_libs="$deplib $newdependency_libs"
7021*a376eb32SXin Li	    case $deplib in
7022*a376eb32SXin Li              -L*) func_stripname '-L' '' "$deplib"
7023*a376eb32SXin Li                   func_resolve_sysroot "$func_stripname_result";;
7024*a376eb32SXin Li              *) func_resolve_sysroot "$deplib" ;;
7025*a376eb32SXin Li            esac
7026*a376eb32SXin Li	    if $opt_preserve_dup_deps ; then
7027*a376eb32SXin Li	      case "$tmp_libs " in
7028*a376eb32SXin Li	      *" $func_resolve_sysroot_result "*)
7029*a376eb32SXin Li                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
7030*a376eb32SXin Li	      esac
7031*a376eb32SXin Li	    fi
7032*a376eb32SXin Li	    func_append tmp_libs " $func_resolve_sysroot_result"
7033*a376eb32SXin Li	  done
7034*a376eb32SXin Li
7035*a376eb32SXin Li	  if test "$link_all_deplibs" != no; then
7036*a376eb32SXin Li	    # Add the search paths of all dependency libraries
7037*a376eb32SXin Li	    for deplib in $dependency_libs; do
7038*a376eb32SXin Li	      path=
7039*a376eb32SXin Li	      case $deplib in
7040*a376eb32SXin Li	      -L*) path="$deplib" ;;
7041*a376eb32SXin Li	      *.la)
7042*a376eb32SXin Li	        func_resolve_sysroot "$deplib"
7043*a376eb32SXin Li	        deplib=$func_resolve_sysroot_result
7044*a376eb32SXin Li	        func_dirname "$deplib" "" "."
7045*a376eb32SXin Li		dir=$func_dirname_result
7046*a376eb32SXin Li		# We need an absolute path.
7047*a376eb32SXin Li		case $dir in
7048*a376eb32SXin Li		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
7049*a376eb32SXin Li		*)
7050*a376eb32SXin Li		  absdir=`cd "$dir" && pwd`
7051*a376eb32SXin Li		  if test -z "$absdir"; then
7052*a376eb32SXin Li		    func_warning "cannot determine absolute directory name of \`$dir'"
7053*a376eb32SXin Li		    absdir="$dir"
7054*a376eb32SXin Li		  fi
7055*a376eb32SXin Li		  ;;
7056*a376eb32SXin Li		esac
7057*a376eb32SXin Li		if $GREP "^installed=no" $deplib > /dev/null; then
7058*a376eb32SXin Li		case $host in
7059*a376eb32SXin Li		*-*-darwin*)
7060*a376eb32SXin Li		  depdepl=
7061*a376eb32SXin Li		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
7062*a376eb32SXin Li		  if test -n "$deplibrary_names" ; then
7063*a376eb32SXin Li		    for tmp in $deplibrary_names ; do
7064*a376eb32SXin Li		      depdepl=$tmp
7065*a376eb32SXin Li		    done
7066*a376eb32SXin Li		    if test -f "$absdir/$objdir/$depdepl" ; then
7067*a376eb32SXin Li		      depdepl="$absdir/$objdir/$depdepl"
7068*a376eb32SXin Li		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
7069*a376eb32SXin Li                      if test -z "$darwin_install_name"; then
7070*a376eb32SXin Li                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
7071*a376eb32SXin Li                      fi
7072*a376eb32SXin Li		      func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
7073*a376eb32SXin Li		      func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
7074*a376eb32SXin Li		      path=
7075*a376eb32SXin Li		    fi
7076*a376eb32SXin Li		  fi
7077*a376eb32SXin Li		  ;;
7078*a376eb32SXin Li		*)
7079*a376eb32SXin Li		  path="-L$absdir/$objdir"
7080*a376eb32SXin Li		  ;;
7081*a376eb32SXin Li		esac
7082*a376eb32SXin Li		else
7083*a376eb32SXin Li		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
7084*a376eb32SXin Li		  test -z "$libdir" && \
7085*a376eb32SXin Li		    func_fatal_error "\`$deplib' is not a valid libtool archive"
7086*a376eb32SXin Li		  test "$absdir" != "$libdir" && \
7087*a376eb32SXin Li		    func_warning "\`$deplib' seems to be moved"
7088*a376eb32SXin Li
7089*a376eb32SXin Li		  path="-L$absdir"
7090*a376eb32SXin Li		fi
7091*a376eb32SXin Li		;;
7092*a376eb32SXin Li	      esac
7093*a376eb32SXin Li	      case " $deplibs " in
7094*a376eb32SXin Li	      *" $path "*) ;;
7095*a376eb32SXin Li	      *) deplibs="$path $deplibs" ;;
7096*a376eb32SXin Li	      esac
7097*a376eb32SXin Li	    done
7098*a376eb32SXin Li	  fi # link_all_deplibs != no
7099*a376eb32SXin Li	fi # linkmode = lib
7100*a376eb32SXin Li      done # for deplib in $libs
7101*a376eb32SXin Li      if test "$pass" = link; then
7102*a376eb32SXin Li	if test "$linkmode" = "prog"; then
7103*a376eb32SXin Li	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
7104*a376eb32SXin Li	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
7105*a376eb32SXin Li	else
7106*a376eb32SXin Li	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7107*a376eb32SXin Li	fi
7108*a376eb32SXin Li      fi
7109*a376eb32SXin Li      dependency_libs="$newdependency_libs"
7110*a376eb32SXin Li      if test "$pass" = dlpreopen; then
7111*a376eb32SXin Li	# Link the dlpreopened libraries before other libraries
7112*a376eb32SXin Li	for deplib in $save_deplibs; do
7113*a376eb32SXin Li	  deplibs="$deplib $deplibs"
7114*a376eb32SXin Li	done
7115*a376eb32SXin Li      fi
7116*a376eb32SXin Li      if test "$pass" != dlopen; then
7117*a376eb32SXin Li	if test "$pass" != conv; then
7118*a376eb32SXin Li	  # Make sure lib_search_path contains only unique directories.
7119*a376eb32SXin Li	  lib_search_path=
7120*a376eb32SXin Li	  for dir in $newlib_search_path; do
7121*a376eb32SXin Li	    case "$lib_search_path " in
7122*a376eb32SXin Li	    *" $dir "*) ;;
7123*a376eb32SXin Li	    *) func_append lib_search_path " $dir" ;;
7124*a376eb32SXin Li	    esac
7125*a376eb32SXin Li	  done
7126*a376eb32SXin Li	  newlib_search_path=
7127*a376eb32SXin Li	fi
7128*a376eb32SXin Li
7129*a376eb32SXin Li	if test "$linkmode,$pass" != "prog,link"; then
7130*a376eb32SXin Li	  vars="deplibs"
7131*a376eb32SXin Li	else
7132*a376eb32SXin Li	  vars="compile_deplibs finalize_deplibs"
7133*a376eb32SXin Li	fi
7134*a376eb32SXin Li	for var in $vars dependency_libs; do
7135*a376eb32SXin Li	  # Add libraries to $var in reverse order
7136*a376eb32SXin Li	  eval tmp_libs=\"\$$var\"
7137*a376eb32SXin Li	  new_libs=
7138*a376eb32SXin Li	  for deplib in $tmp_libs; do
7139*a376eb32SXin Li	    # FIXME: Pedantically, this is the right thing to do, so
7140*a376eb32SXin Li	    #        that some nasty dependency loop isn't accidentally
7141*a376eb32SXin Li	    #        broken:
7142*a376eb32SXin Li	    #new_libs="$deplib $new_libs"
7143*a376eb32SXin Li	    # Pragmatically, this seems to cause very few problems in
7144*a376eb32SXin Li	    # practice:
7145*a376eb32SXin Li	    case $deplib in
7146*a376eb32SXin Li	    -L*) new_libs="$deplib $new_libs" ;;
7147*a376eb32SXin Li	    -R*) ;;
7148*a376eb32SXin Li	    *)
7149*a376eb32SXin Li	      # And here is the reason: when a library appears more
7150*a376eb32SXin Li	      # than once as an explicit dependence of a library, or
7151*a376eb32SXin Li	      # is implicitly linked in more than once by the
7152*a376eb32SXin Li	      # compiler, it is considered special, and multiple
7153*a376eb32SXin Li	      # occurrences thereof are not removed.  Compare this
7154*a376eb32SXin Li	      # with having the same library being listed as a
7155*a376eb32SXin Li	      # dependency of multiple other libraries: in this case,
7156*a376eb32SXin Li	      # we know (pedantically, we assume) the library does not
7157*a376eb32SXin Li	      # need to be listed more than once, so we keep only the
7158*a376eb32SXin Li	      # last copy.  This is not always right, but it is rare
7159*a376eb32SXin Li	      # enough that we require users that really mean to play
7160*a376eb32SXin Li	      # such unportable linking tricks to link the library
7161*a376eb32SXin Li	      # using -Wl,-lname, so that libtool does not consider it
7162*a376eb32SXin Li	      # for duplicate removal.
7163*a376eb32SXin Li	      case " $specialdeplibs " in
7164*a376eb32SXin Li	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
7165*a376eb32SXin Li	      *)
7166*a376eb32SXin Li		case " $new_libs " in
7167*a376eb32SXin Li		*" $deplib "*) ;;
7168*a376eb32SXin Li		*) new_libs="$deplib $new_libs" ;;
7169*a376eb32SXin Li		esac
7170*a376eb32SXin Li		;;
7171*a376eb32SXin Li	      esac
7172*a376eb32SXin Li	      ;;
7173*a376eb32SXin Li	    esac
7174*a376eb32SXin Li	  done
7175*a376eb32SXin Li	  tmp_libs=
7176*a376eb32SXin Li	  for deplib in $new_libs; do
7177*a376eb32SXin Li	    case $deplib in
7178*a376eb32SXin Li	    -L*)
7179*a376eb32SXin Li	      case " $tmp_libs " in
7180*a376eb32SXin Li	      *" $deplib "*) ;;
7181*a376eb32SXin Li	      *) func_append tmp_libs " $deplib" ;;
7182*a376eb32SXin Li	      esac
7183*a376eb32SXin Li	      ;;
7184*a376eb32SXin Li	    *) func_append tmp_libs " $deplib" ;;
7185*a376eb32SXin Li	    esac
7186*a376eb32SXin Li	  done
7187*a376eb32SXin Li	  eval $var=\"$tmp_libs\"
7188*a376eb32SXin Li	done # for var
7189*a376eb32SXin Li      fi
7190*a376eb32SXin Li      # Last step: remove runtime libs from dependency_libs
7191*a376eb32SXin Li      # (they stay in deplibs)
7192*a376eb32SXin Li      tmp_libs=
7193*a376eb32SXin Li      for i in $dependency_libs ; do
7194*a376eb32SXin Li	case " $predeps $postdeps $compiler_lib_search_path " in
7195*a376eb32SXin Li	*" $i "*)
7196*a376eb32SXin Li	  i=""
7197*a376eb32SXin Li	  ;;
7198*a376eb32SXin Li	esac
7199*a376eb32SXin Li	if test -n "$i" ; then
7200*a376eb32SXin Li	  func_append tmp_libs " $i"
7201*a376eb32SXin Li	fi
7202*a376eb32SXin Li      done
7203*a376eb32SXin Li      dependency_libs=$tmp_libs
7204*a376eb32SXin Li    done # for pass
7205*a376eb32SXin Li    if test "$linkmode" = prog; then
7206*a376eb32SXin Li      dlfiles="$newdlfiles"
7207*a376eb32SXin Li    fi
7208*a376eb32SXin Li    if test "$linkmode" = prog || test "$linkmode" = lib; then
7209*a376eb32SXin Li      dlprefiles="$newdlprefiles"
7210*a376eb32SXin Li    fi
7211*a376eb32SXin Li
7212*a376eb32SXin Li    case $linkmode in
7213*a376eb32SXin Li    oldlib)
7214*a376eb32SXin Li      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
7215*a376eb32SXin Li	func_warning "\`-dlopen' is ignored for archives"
7216*a376eb32SXin Li      fi
7217*a376eb32SXin Li
7218*a376eb32SXin Li      case " $deplibs" in
7219*a376eb32SXin Li      *\ -l* | *\ -L*)
7220*a376eb32SXin Li	func_warning "\`-l' and \`-L' are ignored for archives" ;;
7221*a376eb32SXin Li      esac
7222*a376eb32SXin Li
7223*a376eb32SXin Li      test -n "$rpath" && \
7224*a376eb32SXin Li	func_warning "\`-rpath' is ignored for archives"
7225*a376eb32SXin Li
7226*a376eb32SXin Li      test -n "$xrpath" && \
7227*a376eb32SXin Li	func_warning "\`-R' is ignored for archives"
7228*a376eb32SXin Li
7229*a376eb32SXin Li      test -n "$vinfo" && \
7230*a376eb32SXin Li	func_warning "\`-version-info/-version-number' is ignored for archives"
7231*a376eb32SXin Li
7232*a376eb32SXin Li      test -n "$release" && \
7233*a376eb32SXin Li	func_warning "\`-release' is ignored for archives"
7234*a376eb32SXin Li
7235*a376eb32SXin Li      test -n "$export_symbols$export_symbols_regex" && \
7236*a376eb32SXin Li	func_warning "\`-export-symbols' is ignored for archives"
7237*a376eb32SXin Li
7238*a376eb32SXin Li      # Now set the variables for building old libraries.
7239*a376eb32SXin Li      build_libtool_libs=no
7240*a376eb32SXin Li      oldlibs="$output"
7241*a376eb32SXin Li      func_append objs "$old_deplibs"
7242*a376eb32SXin Li      ;;
7243*a376eb32SXin Li
7244*a376eb32SXin Li    lib)
7245*a376eb32SXin Li      # Make sure we only generate libraries of the form `libNAME.la'.
7246*a376eb32SXin Li      case $outputname in
7247*a376eb32SXin Li      lib*)
7248*a376eb32SXin Li	func_stripname 'lib' '.la' "$outputname"
7249*a376eb32SXin Li	name=$func_stripname_result
7250*a376eb32SXin Li	eval shared_ext=\"$shrext_cmds\"
7251*a376eb32SXin Li	eval libname=\"$libname_spec\"
7252*a376eb32SXin Li	;;
7253*a376eb32SXin Li      *)
7254*a376eb32SXin Li	test "$module" = no && \
7255*a376eb32SXin Li	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
7256*a376eb32SXin Li
7257*a376eb32SXin Li	if test "$need_lib_prefix" != no; then
7258*a376eb32SXin Li	  # Add the "lib" prefix for modules if required
7259*a376eb32SXin Li	  func_stripname '' '.la' "$outputname"
7260*a376eb32SXin Li	  name=$func_stripname_result
7261*a376eb32SXin Li	  eval shared_ext=\"$shrext_cmds\"
7262*a376eb32SXin Li	  eval libname=\"$libname_spec\"
7263*a376eb32SXin Li	else
7264*a376eb32SXin Li	  func_stripname '' '.la' "$outputname"
7265*a376eb32SXin Li	  libname=$func_stripname_result
7266*a376eb32SXin Li	fi
7267*a376eb32SXin Li	;;
7268*a376eb32SXin Li      esac
7269*a376eb32SXin Li
7270*a376eb32SXin Li      if test -n "$objs"; then
7271*a376eb32SXin Li	if test "$deplibs_check_method" != pass_all; then
7272*a376eb32SXin Li	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
7273*a376eb32SXin Li	else
7274*a376eb32SXin Li	  echo
7275*a376eb32SXin Li	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
7276*a376eb32SXin Li	  $ECHO "*** objects $objs is not portable!"
7277*a376eb32SXin Li	  func_append libobjs " $objs"
7278*a376eb32SXin Li	fi
7279*a376eb32SXin Li      fi
7280*a376eb32SXin Li
7281*a376eb32SXin Li      test "$dlself" != no && \
7282*a376eb32SXin Li	func_warning "\`-dlopen self' is ignored for libtool libraries"
7283*a376eb32SXin Li
7284*a376eb32SXin Li      set dummy $rpath
7285*a376eb32SXin Li      shift
7286*a376eb32SXin Li      test "$#" -gt 1 && \
7287*a376eb32SXin Li	func_warning "ignoring multiple \`-rpath's for a libtool library"
7288*a376eb32SXin Li
7289*a376eb32SXin Li      install_libdir="$1"
7290*a376eb32SXin Li
7291*a376eb32SXin Li      oldlibs=
7292*a376eb32SXin Li      if test -z "$rpath"; then
7293*a376eb32SXin Li	if test "$build_libtool_libs" = yes; then
7294*a376eb32SXin Li	  # Building a libtool convenience library.
7295*a376eb32SXin Li	  # Some compilers have problems with a `.al' extension so
7296*a376eb32SXin Li	  # convenience libraries should have the same extension an
7297*a376eb32SXin Li	  # archive normally would.
7298*a376eb32SXin Li	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
7299*a376eb32SXin Li	  build_libtool_libs=convenience
7300*a376eb32SXin Li	  build_old_libs=yes
7301*a376eb32SXin Li	fi
7302*a376eb32SXin Li
7303*a376eb32SXin Li	test -n "$vinfo" && \
7304*a376eb32SXin Li	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
7305*a376eb32SXin Li
7306*a376eb32SXin Li	test -n "$release" && \
7307*a376eb32SXin Li	  func_warning "\`-release' is ignored for convenience libraries"
7308*a376eb32SXin Li      else
7309*a376eb32SXin Li
7310*a376eb32SXin Li	# Parse the version information argument.
7311*a376eb32SXin Li	save_ifs="$IFS"; IFS=':'
7312*a376eb32SXin Li	set dummy $vinfo 0 0 0
7313*a376eb32SXin Li	shift
7314*a376eb32SXin Li	IFS="$save_ifs"
7315*a376eb32SXin Li
7316*a376eb32SXin Li	test -n "$7" && \
7317*a376eb32SXin Li	  func_fatal_help "too many parameters to \`-version-info'"
7318*a376eb32SXin Li
7319*a376eb32SXin Li	# convert absolute version numbers to libtool ages
7320*a376eb32SXin Li	# this retains compatibility with .la files and attempts
7321*a376eb32SXin Li	# to make the code below a bit more comprehensible
7322*a376eb32SXin Li
7323*a376eb32SXin Li	case $vinfo_number in
7324*a376eb32SXin Li	yes)
7325*a376eb32SXin Li	  number_major="$1"
7326*a376eb32SXin Li	  number_minor="$2"
7327*a376eb32SXin Li	  number_revision="$3"
7328*a376eb32SXin Li	  #
7329*a376eb32SXin Li	  # There are really only two kinds -- those that
7330*a376eb32SXin Li	  # use the current revision as the major version
7331*a376eb32SXin Li	  # and those that subtract age and use age as
7332*a376eb32SXin Li	  # a minor version.  But, then there is irix
7333*a376eb32SXin Li	  # which has an extra 1 added just for fun
7334*a376eb32SXin Li	  #
7335*a376eb32SXin Li	  case $version_type in
7336*a376eb32SXin Li	  # correct linux to gnu/linux during the next big refactor
7337*a376eb32SXin Li	  darwin|linux|osf|windows|none)
7338*a376eb32SXin Li	    func_arith $number_major + $number_minor
7339*a376eb32SXin Li	    current=$func_arith_result
7340*a376eb32SXin Li	    age="$number_minor"
7341*a376eb32SXin Li	    revision="$number_revision"
7342*a376eb32SXin Li	    ;;
7343*a376eb32SXin Li	  freebsd-aout|freebsd-elf|qnx|sunos)
7344*a376eb32SXin Li	    current="$number_major"
7345*a376eb32SXin Li	    revision="$number_minor"
7346*a376eb32SXin Li	    age="0"
7347*a376eb32SXin Li	    ;;
7348*a376eb32SXin Li	  irix|nonstopux)
7349*a376eb32SXin Li	    func_arith $number_major + $number_minor
7350*a376eb32SXin Li	    current=$func_arith_result
7351*a376eb32SXin Li	    age="$number_minor"
7352*a376eb32SXin Li	    revision="$number_minor"
7353*a376eb32SXin Li	    lt_irix_increment=no
7354*a376eb32SXin Li	    ;;
7355*a376eb32SXin Li	  *)
7356*a376eb32SXin Li	    func_fatal_configuration "$modename: unknown library version type \`$version_type'"
7357*a376eb32SXin Li	    ;;
7358*a376eb32SXin Li	  esac
7359*a376eb32SXin Li	  ;;
7360*a376eb32SXin Li	no)
7361*a376eb32SXin Li	  current="$1"
7362*a376eb32SXin Li	  revision="$2"
7363*a376eb32SXin Li	  age="$3"
7364*a376eb32SXin Li	  ;;
7365*a376eb32SXin Li	esac
7366*a376eb32SXin Li
7367*a376eb32SXin Li	# Check that each of the things are valid numbers.
7368*a376eb32SXin Li	case $current in
7369*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]) ;;
7370*a376eb32SXin Li	*)
7371*a376eb32SXin Li	  func_error "CURRENT \`$current' must be a nonnegative integer"
7372*a376eb32SXin Li	  func_fatal_error "\`$vinfo' is not valid version information"
7373*a376eb32SXin Li	  ;;
7374*a376eb32SXin Li	esac
7375*a376eb32SXin Li
7376*a376eb32SXin Li	case $revision in
7377*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]) ;;
7378*a376eb32SXin Li	*)
7379*a376eb32SXin Li	  func_error "REVISION \`$revision' must be a nonnegative integer"
7380*a376eb32SXin Li	  func_fatal_error "\`$vinfo' is not valid version information"
7381*a376eb32SXin Li	  ;;
7382*a376eb32SXin Li	esac
7383*a376eb32SXin Li
7384*a376eb32SXin Li	case $age in
7385*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]) ;;
7386*a376eb32SXin Li	*)
7387*a376eb32SXin Li	  func_error "AGE \`$age' must be a nonnegative integer"
7388*a376eb32SXin Li	  func_fatal_error "\`$vinfo' is not valid version information"
7389*a376eb32SXin Li	  ;;
7390*a376eb32SXin Li	esac
7391*a376eb32SXin Li
7392*a376eb32SXin Li	if test "$age" -gt "$current"; then
7393*a376eb32SXin Li	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
7394*a376eb32SXin Li	  func_fatal_error "\`$vinfo' is not valid version information"
7395*a376eb32SXin Li	fi
7396*a376eb32SXin Li
7397*a376eb32SXin Li	# Calculate the version variables.
7398*a376eb32SXin Li	major=
7399*a376eb32SXin Li	versuffix=
7400*a376eb32SXin Li	verstring=
7401*a376eb32SXin Li	case $version_type in
7402*a376eb32SXin Li	none) ;;
7403*a376eb32SXin Li
7404*a376eb32SXin Li	darwin)
7405*a376eb32SXin Li	  # Like Linux, but with the current version available in
7406*a376eb32SXin Li	  # verstring for coding it into the library header
7407*a376eb32SXin Li	  func_arith $current - $age
7408*a376eb32SXin Li	  major=.$func_arith_result
7409*a376eb32SXin Li	  versuffix="$major.$age.$revision"
7410*a376eb32SXin Li	  # Darwin ld doesn't like 0 for these options...
7411*a376eb32SXin Li	  func_arith $current + 1
7412*a376eb32SXin Li	  minor_current=$func_arith_result
7413*a376eb32SXin Li	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
7414*a376eb32SXin Li	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
7415*a376eb32SXin Li	  ;;
7416*a376eb32SXin Li
7417*a376eb32SXin Li	freebsd-aout)
7418*a376eb32SXin Li	  major=".$current"
7419*a376eb32SXin Li	  versuffix=".$current.$revision";
7420*a376eb32SXin Li	  ;;
7421*a376eb32SXin Li
7422*a376eb32SXin Li	freebsd-elf)
7423*a376eb32SXin Li	  major=".$current"
7424*a376eb32SXin Li	  versuffix=".$current"
7425*a376eb32SXin Li	  ;;
7426*a376eb32SXin Li
7427*a376eb32SXin Li	irix | nonstopux)
7428*a376eb32SXin Li	  if test "X$lt_irix_increment" = "Xno"; then
7429*a376eb32SXin Li	    func_arith $current - $age
7430*a376eb32SXin Li	  else
7431*a376eb32SXin Li	    func_arith $current - $age + 1
7432*a376eb32SXin Li	  fi
7433*a376eb32SXin Li	  major=$func_arith_result
7434*a376eb32SXin Li
7435*a376eb32SXin Li	  case $version_type in
7436*a376eb32SXin Li	    nonstopux) verstring_prefix=nonstopux ;;
7437*a376eb32SXin Li	    *)         verstring_prefix=sgi ;;
7438*a376eb32SXin Li	  esac
7439*a376eb32SXin Li	  verstring="$verstring_prefix$major.$revision"
7440*a376eb32SXin Li
7441*a376eb32SXin Li	  # Add in all the interfaces that we are compatible with.
7442*a376eb32SXin Li	  loop=$revision
7443*a376eb32SXin Li	  while test "$loop" -ne 0; do
7444*a376eb32SXin Li	    func_arith $revision - $loop
7445*a376eb32SXin Li	    iface=$func_arith_result
7446*a376eb32SXin Li	    func_arith $loop - 1
7447*a376eb32SXin Li	    loop=$func_arith_result
7448*a376eb32SXin Li	    verstring="$verstring_prefix$major.$iface:$verstring"
7449*a376eb32SXin Li	  done
7450*a376eb32SXin Li
7451*a376eb32SXin Li	  # Before this point, $major must not contain `.'.
7452*a376eb32SXin Li	  major=.$major
7453*a376eb32SXin Li	  versuffix="$major.$revision"
7454*a376eb32SXin Li	  ;;
7455*a376eb32SXin Li
7456*a376eb32SXin Li	linux) # correct to gnu/linux during the next big refactor
7457*a376eb32SXin Li	  func_arith $current - $age
7458*a376eb32SXin Li	  major=.$func_arith_result
7459*a376eb32SXin Li	  versuffix="$major.$age.$revision"
7460*a376eb32SXin Li	  ;;
7461*a376eb32SXin Li
7462*a376eb32SXin Li	osf)
7463*a376eb32SXin Li	  func_arith $current - $age
7464*a376eb32SXin Li	  major=.$func_arith_result
7465*a376eb32SXin Li	  versuffix=".$current.$age.$revision"
7466*a376eb32SXin Li	  verstring="$current.$age.$revision"
7467*a376eb32SXin Li
7468*a376eb32SXin Li	  # Add in all the interfaces that we are compatible with.
7469*a376eb32SXin Li	  loop=$age
7470*a376eb32SXin Li	  while test "$loop" -ne 0; do
7471*a376eb32SXin Li	    func_arith $current - $loop
7472*a376eb32SXin Li	    iface=$func_arith_result
7473*a376eb32SXin Li	    func_arith $loop - 1
7474*a376eb32SXin Li	    loop=$func_arith_result
7475*a376eb32SXin Li	    verstring="$verstring:${iface}.0"
7476*a376eb32SXin Li	  done
7477*a376eb32SXin Li
7478*a376eb32SXin Li	  # Make executables depend on our current version.
7479*a376eb32SXin Li	  func_append verstring ":${current}.0"
7480*a376eb32SXin Li	  ;;
7481*a376eb32SXin Li
7482*a376eb32SXin Li	qnx)
7483*a376eb32SXin Li	  major=".$current"
7484*a376eb32SXin Li	  versuffix=".$current"
7485*a376eb32SXin Li	  ;;
7486*a376eb32SXin Li
7487*a376eb32SXin Li	sunos)
7488*a376eb32SXin Li	  major=".$current"
7489*a376eb32SXin Li	  versuffix=".$current.$revision"
7490*a376eb32SXin Li	  ;;
7491*a376eb32SXin Li
7492*a376eb32SXin Li	windows)
7493*a376eb32SXin Li	  # Use '-' rather than '.', since we only want one
7494*a376eb32SXin Li	  # extension on DOS 8.3 filesystems.
7495*a376eb32SXin Li	  func_arith $current - $age
7496*a376eb32SXin Li	  major=$func_arith_result
7497*a376eb32SXin Li	  versuffix="-$major"
7498*a376eb32SXin Li	  ;;
7499*a376eb32SXin Li
7500*a376eb32SXin Li	*)
7501*a376eb32SXin Li	  func_fatal_configuration "unknown library version type \`$version_type'"
7502*a376eb32SXin Li	  ;;
7503*a376eb32SXin Li	esac
7504*a376eb32SXin Li
7505*a376eb32SXin Li	# Clear the version info if we defaulted, and they specified a release.
7506*a376eb32SXin Li	if test -z "$vinfo" && test -n "$release"; then
7507*a376eb32SXin Li	  major=
7508*a376eb32SXin Li	  case $version_type in
7509*a376eb32SXin Li	  darwin)
7510*a376eb32SXin Li	    # we can't check for "0.0" in archive_cmds due to quoting
7511*a376eb32SXin Li	    # problems, so we reset it completely
7512*a376eb32SXin Li	    verstring=
7513*a376eb32SXin Li	    ;;
7514*a376eb32SXin Li	  *)
7515*a376eb32SXin Li	    verstring="0.0"
7516*a376eb32SXin Li	    ;;
7517*a376eb32SXin Li	  esac
7518*a376eb32SXin Li	  if test "$need_version" = no; then
7519*a376eb32SXin Li	    versuffix=
7520*a376eb32SXin Li	  else
7521*a376eb32SXin Li	    versuffix=".0.0"
7522*a376eb32SXin Li	  fi
7523*a376eb32SXin Li	fi
7524*a376eb32SXin Li
7525*a376eb32SXin Li	# Remove version info from name if versioning should be avoided
7526*a376eb32SXin Li	if test "$avoid_version" = yes && test "$need_version" = no; then
7527*a376eb32SXin Li	  major=
7528*a376eb32SXin Li	  versuffix=
7529*a376eb32SXin Li	  verstring=""
7530*a376eb32SXin Li	fi
7531*a376eb32SXin Li
7532*a376eb32SXin Li	# Check to see if the archive will have undefined symbols.
7533*a376eb32SXin Li	if test "$allow_undefined" = yes; then
7534*a376eb32SXin Li	  if test "$allow_undefined_flag" = unsupported; then
7535*a376eb32SXin Li	    func_warning "undefined symbols not allowed in $host shared libraries"
7536*a376eb32SXin Li	    build_libtool_libs=no
7537*a376eb32SXin Li	    build_old_libs=yes
7538*a376eb32SXin Li	  fi
7539*a376eb32SXin Li	else
7540*a376eb32SXin Li	  # Don't allow undefined symbols.
7541*a376eb32SXin Li	  allow_undefined_flag="$no_undefined_flag"
7542*a376eb32SXin Li	fi
7543*a376eb32SXin Li
7544*a376eb32SXin Li      fi
7545*a376eb32SXin Li
7546*a376eb32SXin Li      func_generate_dlsyms "$libname" "$libname" "yes"
7547*a376eb32SXin Li      func_append libobjs " $symfileobj"
7548*a376eb32SXin Li      test "X$libobjs" = "X " && libobjs=
7549*a376eb32SXin Li
7550*a376eb32SXin Li      if test "$opt_mode" != relink; then
7551*a376eb32SXin Li	# Remove our outputs, but don't remove object files since they
7552*a376eb32SXin Li	# may have been created when compiling PIC objects.
7553*a376eb32SXin Li	removelist=
7554*a376eb32SXin Li	tempremovelist=`$ECHO "$output_objdir/*"`
7555*a376eb32SXin Li	for p in $tempremovelist; do
7556*a376eb32SXin Li	  case $p in
7557*a376eb32SXin Li	    *.$objext | *.gcno)
7558*a376eb32SXin Li	       ;;
7559*a376eb32SXin Li	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
7560*a376eb32SXin Li	       if test "X$precious_files_regex" != "X"; then
7561*a376eb32SXin Li		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
7562*a376eb32SXin Li		 then
7563*a376eb32SXin Li		   continue
7564*a376eb32SXin Li		 fi
7565*a376eb32SXin Li	       fi
7566*a376eb32SXin Li	       func_append removelist " $p"
7567*a376eb32SXin Li	       ;;
7568*a376eb32SXin Li	    *) ;;
7569*a376eb32SXin Li	  esac
7570*a376eb32SXin Li	done
7571*a376eb32SXin Li	test -n "$removelist" && \
7572*a376eb32SXin Li	  func_show_eval "${RM}r \$removelist"
7573*a376eb32SXin Li      fi
7574*a376eb32SXin Li
7575*a376eb32SXin Li      # Now set the variables for building old libraries.
7576*a376eb32SXin Li      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
7577*a376eb32SXin Li	func_append oldlibs " $output_objdir/$libname.$libext"
7578*a376eb32SXin Li
7579*a376eb32SXin Li	# Transform .lo files to .o files.
7580*a376eb32SXin Li	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
7581*a376eb32SXin Li      fi
7582*a376eb32SXin Li
7583*a376eb32SXin Li      # Eliminate all temporary directories.
7584*a376eb32SXin Li      #for path in $notinst_path; do
7585*a376eb32SXin Li      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
7586*a376eb32SXin Li      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
7587*a376eb32SXin Li      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
7588*a376eb32SXin Li      #done
7589*a376eb32SXin Li
7590*a376eb32SXin Li      if test -n "$xrpath"; then
7591*a376eb32SXin Li	# If the user specified any rpath flags, then add them.
7592*a376eb32SXin Li	temp_xrpath=
7593*a376eb32SXin Li	for libdir in $xrpath; do
7594*a376eb32SXin Li	  func_replace_sysroot "$libdir"
7595*a376eb32SXin Li	  func_append temp_xrpath " -R$func_replace_sysroot_result"
7596*a376eb32SXin Li	  case "$finalize_rpath " in
7597*a376eb32SXin Li	  *" $libdir "*) ;;
7598*a376eb32SXin Li	  *) func_append finalize_rpath " $libdir" ;;
7599*a376eb32SXin Li	  esac
7600*a376eb32SXin Li	done
7601*a376eb32SXin Li	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
7602*a376eb32SXin Li	  dependency_libs="$temp_xrpath $dependency_libs"
7603*a376eb32SXin Li	fi
7604*a376eb32SXin Li      fi
7605*a376eb32SXin Li
7606*a376eb32SXin Li      # Make sure dlfiles contains only unique files that won't be dlpreopened
7607*a376eb32SXin Li      old_dlfiles="$dlfiles"
7608*a376eb32SXin Li      dlfiles=
7609*a376eb32SXin Li      for lib in $old_dlfiles; do
7610*a376eb32SXin Li	case " $dlprefiles $dlfiles " in
7611*a376eb32SXin Li	*" $lib "*) ;;
7612*a376eb32SXin Li	*) func_append dlfiles " $lib" ;;
7613*a376eb32SXin Li	esac
7614*a376eb32SXin Li      done
7615*a376eb32SXin Li
7616*a376eb32SXin Li      # Make sure dlprefiles contains only unique files
7617*a376eb32SXin Li      old_dlprefiles="$dlprefiles"
7618*a376eb32SXin Li      dlprefiles=
7619*a376eb32SXin Li      for lib in $old_dlprefiles; do
7620*a376eb32SXin Li	case "$dlprefiles " in
7621*a376eb32SXin Li	*" $lib "*) ;;
7622*a376eb32SXin Li	*) func_append dlprefiles " $lib" ;;
7623*a376eb32SXin Li	esac
7624*a376eb32SXin Li      done
7625*a376eb32SXin Li
7626*a376eb32SXin Li      if test "$build_libtool_libs" = yes; then
7627*a376eb32SXin Li	if test -n "$rpath"; then
7628*a376eb32SXin Li	  case $host in
7629*a376eb32SXin Li	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
7630*a376eb32SXin Li	    # these systems don't actually have a c library (as such)!
7631*a376eb32SXin Li	    ;;
7632*a376eb32SXin Li	  *-*-rhapsody* | *-*-darwin1.[012])
7633*a376eb32SXin Li	    # Rhapsody C library is in the System framework
7634*a376eb32SXin Li	    func_append deplibs " System.ltframework"
7635*a376eb32SXin Li	    ;;
7636*a376eb32SXin Li	  *-*-netbsd*)
7637*a376eb32SXin Li	    # Don't link with libc until the a.out ld.so is fixed.
7638*a376eb32SXin Li	    ;;
7639*a376eb32SXin Li	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
7640*a376eb32SXin Li	    # Do not include libc due to us having libc/libc_r.
7641*a376eb32SXin Li	    ;;
7642*a376eb32SXin Li	  *-*-sco3.2v5* | *-*-sco5v6*)
7643*a376eb32SXin Li	    # Causes problems with __ctype
7644*a376eb32SXin Li	    ;;
7645*a376eb32SXin Li	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
7646*a376eb32SXin Li	    # Compiler inserts libc in the correct place for threads to work
7647*a376eb32SXin Li	    ;;
7648*a376eb32SXin Li	  *)
7649*a376eb32SXin Li	    # Add libc to deplibs on all other systems if necessary.
7650*a376eb32SXin Li	    if test "$build_libtool_need_lc" = "yes"; then
7651*a376eb32SXin Li	      func_append deplibs " -lc"
7652*a376eb32SXin Li	    fi
7653*a376eb32SXin Li	    ;;
7654*a376eb32SXin Li	  esac
7655*a376eb32SXin Li	fi
7656*a376eb32SXin Li
7657*a376eb32SXin Li	# Transform deplibs into only deplibs that can be linked in shared.
7658*a376eb32SXin Li	name_save=$name
7659*a376eb32SXin Li	libname_save=$libname
7660*a376eb32SXin Li	release_save=$release
7661*a376eb32SXin Li	versuffix_save=$versuffix
7662*a376eb32SXin Li	major_save=$major
7663*a376eb32SXin Li	# I'm not sure if I'm treating the release correctly.  I think
7664*a376eb32SXin Li	# release should show up in the -l (ie -lgmp5) so we don't want to
7665*a376eb32SXin Li	# add it in twice.  Is that correct?
7666*a376eb32SXin Li	release=""
7667*a376eb32SXin Li	versuffix=""
7668*a376eb32SXin Li	major=""
7669*a376eb32SXin Li	newdeplibs=
7670*a376eb32SXin Li	droppeddeps=no
7671*a376eb32SXin Li	case $deplibs_check_method in
7672*a376eb32SXin Li	pass_all)
7673*a376eb32SXin Li	  # Don't check for shared/static.  Everything works.
7674*a376eb32SXin Li	  # This might be a little naive.  We might want to check
7675*a376eb32SXin Li	  # whether the library exists or not.  But this is on
7676*a376eb32SXin Li	  # osf3 & osf4 and I'm not really sure... Just
7677*a376eb32SXin Li	  # implementing what was already the behavior.
7678*a376eb32SXin Li	  newdeplibs=$deplibs
7679*a376eb32SXin Li	  ;;
7680*a376eb32SXin Li	test_compile)
7681*a376eb32SXin Li	  # This code stresses the "libraries are programs" paradigm to its
7682*a376eb32SXin Li	  # limits. Maybe even breaks it.  We compile a program, linking it
7683*a376eb32SXin Li	  # against the deplibs as a proxy for the library.  Then we can check
7684*a376eb32SXin Li	  # whether they linked in statically or dynamically with ldd.
7685*a376eb32SXin Li	  $opt_dry_run || $RM conftest.c
7686*a376eb32SXin Li	  cat > conftest.c <<EOF
7687*a376eb32SXin Li	  int main() { return 0; }
7688*a376eb32SXin LiEOF
7689*a376eb32SXin Li	  $opt_dry_run || $RM conftest
7690*a376eb32SXin Li	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
7691*a376eb32SXin Li	    ldd_output=`ldd conftest`
7692*a376eb32SXin Li	    for i in $deplibs; do
7693*a376eb32SXin Li	      case $i in
7694*a376eb32SXin Li	      -l*)
7695*a376eb32SXin Li		func_stripname -l '' "$i"
7696*a376eb32SXin Li		name=$func_stripname_result
7697*a376eb32SXin Li		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7698*a376eb32SXin Li		  case " $predeps $postdeps " in
7699*a376eb32SXin Li		  *" $i "*)
7700*a376eb32SXin Li		    func_append newdeplibs " $i"
7701*a376eb32SXin Li		    i=""
7702*a376eb32SXin Li		    ;;
7703*a376eb32SXin Li		  esac
7704*a376eb32SXin Li		fi
7705*a376eb32SXin Li		if test -n "$i" ; then
7706*a376eb32SXin Li		  libname=`eval "\\$ECHO \"$libname_spec\""`
7707*a376eb32SXin Li		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
7708*a376eb32SXin Li		  set dummy $deplib_matches; shift
7709*a376eb32SXin Li		  deplib_match=$1
7710*a376eb32SXin Li		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7711*a376eb32SXin Li		    func_append newdeplibs " $i"
7712*a376eb32SXin Li		  else
7713*a376eb32SXin Li		    droppeddeps=yes
7714*a376eb32SXin Li		    echo
7715*a376eb32SXin Li		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
7716*a376eb32SXin Li		    echo "*** I have the capability to make that library automatically link in when"
7717*a376eb32SXin Li		    echo "*** you link to this library.  But I can only do this if you have a"
7718*a376eb32SXin Li		    echo "*** shared version of the library, which I believe you do not have"
7719*a376eb32SXin Li		    echo "*** because a test_compile did reveal that the linker did not use it for"
7720*a376eb32SXin Li		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
7721*a376eb32SXin Li		  fi
7722*a376eb32SXin Li		fi
7723*a376eb32SXin Li		;;
7724*a376eb32SXin Li	      *)
7725*a376eb32SXin Li		func_append newdeplibs " $i"
7726*a376eb32SXin Li		;;
7727*a376eb32SXin Li	      esac
7728*a376eb32SXin Li	    done
7729*a376eb32SXin Li	  else
7730*a376eb32SXin Li	    # Error occurred in the first compile.  Let's try to salvage
7731*a376eb32SXin Li	    # the situation: Compile a separate program for each library.
7732*a376eb32SXin Li	    for i in $deplibs; do
7733*a376eb32SXin Li	      case $i in
7734*a376eb32SXin Li	      -l*)
7735*a376eb32SXin Li		func_stripname -l '' "$i"
7736*a376eb32SXin Li		name=$func_stripname_result
7737*a376eb32SXin Li		$opt_dry_run || $RM conftest
7738*a376eb32SXin Li		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
7739*a376eb32SXin Li		  ldd_output=`ldd conftest`
7740*a376eb32SXin Li		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7741*a376eb32SXin Li		    case " $predeps $postdeps " in
7742*a376eb32SXin Li		    *" $i "*)
7743*a376eb32SXin Li		      func_append newdeplibs " $i"
7744*a376eb32SXin Li		      i=""
7745*a376eb32SXin Li		      ;;
7746*a376eb32SXin Li		    esac
7747*a376eb32SXin Li		  fi
7748*a376eb32SXin Li		  if test -n "$i" ; then
7749*a376eb32SXin Li		    libname=`eval "\\$ECHO \"$libname_spec\""`
7750*a376eb32SXin Li		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
7751*a376eb32SXin Li		    set dummy $deplib_matches; shift
7752*a376eb32SXin Li		    deplib_match=$1
7753*a376eb32SXin Li		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7754*a376eb32SXin Li		      func_append newdeplibs " $i"
7755*a376eb32SXin Li		    else
7756*a376eb32SXin Li		      droppeddeps=yes
7757*a376eb32SXin Li		      echo
7758*a376eb32SXin Li		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
7759*a376eb32SXin Li		      echo "*** I have the capability to make that library automatically link in when"
7760*a376eb32SXin Li		      echo "*** you link to this library.  But I can only do this if you have a"
7761*a376eb32SXin Li		      echo "*** shared version of the library, which you do not appear to have"
7762*a376eb32SXin Li		      echo "*** because a test_compile did reveal that the linker did not use this one"
7763*a376eb32SXin Li		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
7764*a376eb32SXin Li		    fi
7765*a376eb32SXin Li		  fi
7766*a376eb32SXin Li		else
7767*a376eb32SXin Li		  droppeddeps=yes
7768*a376eb32SXin Li		  echo
7769*a376eb32SXin Li		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
7770*a376eb32SXin Li		  echo "*** make it link in!  You will probably need to install it or some"
7771*a376eb32SXin Li		  echo "*** library that it depends on before this library will be fully"
7772*a376eb32SXin Li		  echo "*** functional.  Installing it before continuing would be even better."
7773*a376eb32SXin Li		fi
7774*a376eb32SXin Li		;;
7775*a376eb32SXin Li	      *)
7776*a376eb32SXin Li		func_append newdeplibs " $i"
7777*a376eb32SXin Li		;;
7778*a376eb32SXin Li	      esac
7779*a376eb32SXin Li	    done
7780*a376eb32SXin Li	  fi
7781*a376eb32SXin Li	  ;;
7782*a376eb32SXin Li	file_magic*)
7783*a376eb32SXin Li	  set dummy $deplibs_check_method; shift
7784*a376eb32SXin Li	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7785*a376eb32SXin Li	  for a_deplib in $deplibs; do
7786*a376eb32SXin Li	    case $a_deplib in
7787*a376eb32SXin Li	    -l*)
7788*a376eb32SXin Li	      func_stripname -l '' "$a_deplib"
7789*a376eb32SXin Li	      name=$func_stripname_result
7790*a376eb32SXin Li	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7791*a376eb32SXin Li		case " $predeps $postdeps " in
7792*a376eb32SXin Li		*" $a_deplib "*)
7793*a376eb32SXin Li		  func_append newdeplibs " $a_deplib"
7794*a376eb32SXin Li		  a_deplib=""
7795*a376eb32SXin Li		  ;;
7796*a376eb32SXin Li		esac
7797*a376eb32SXin Li	      fi
7798*a376eb32SXin Li	      if test -n "$a_deplib" ; then
7799*a376eb32SXin Li		libname=`eval "\\$ECHO \"$libname_spec\""`
7800*a376eb32SXin Li		if test -n "$file_magic_glob"; then
7801*a376eb32SXin Li		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
7802*a376eb32SXin Li		else
7803*a376eb32SXin Li		  libnameglob=$libname
7804*a376eb32SXin Li		fi
7805*a376eb32SXin Li		test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
7806*a376eb32SXin Li		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7807*a376eb32SXin Li		  if test "$want_nocaseglob" = yes; then
7808*a376eb32SXin Li		    shopt -s nocaseglob
7809*a376eb32SXin Li		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7810*a376eb32SXin Li		    $nocaseglob
7811*a376eb32SXin Li		  else
7812*a376eb32SXin Li		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7813*a376eb32SXin Li		  fi
7814*a376eb32SXin Li		  for potent_lib in $potential_libs; do
7815*a376eb32SXin Li		      # Follow soft links.
7816*a376eb32SXin Li		      if ls -lLd "$potent_lib" 2>/dev/null |
7817*a376eb32SXin Li			 $GREP " -> " >/dev/null; then
7818*a376eb32SXin Li			continue
7819*a376eb32SXin Li		      fi
7820*a376eb32SXin Li		      # The statement above tries to avoid entering an
7821*a376eb32SXin Li		      # endless loop below, in case of cyclic links.
7822*a376eb32SXin Li		      # We might still enter an endless loop, since a link
7823*a376eb32SXin Li		      # loop can be closed while we follow links,
7824*a376eb32SXin Li		      # but so what?
7825*a376eb32SXin Li		      potlib="$potent_lib"
7826*a376eb32SXin Li		      while test -h "$potlib" 2>/dev/null; do
7827*a376eb32SXin Li			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
7828*a376eb32SXin Li			case $potliblink in
7829*a376eb32SXin Li			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
7830*a376eb32SXin Li			*) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
7831*a376eb32SXin Li			esac
7832*a376eb32SXin Li		      done
7833*a376eb32SXin Li		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
7834*a376eb32SXin Li			 $SED -e 10q |
7835*a376eb32SXin Li			 $EGREP "$file_magic_regex" > /dev/null; then
7836*a376eb32SXin Li			func_append newdeplibs " $a_deplib"
7837*a376eb32SXin Li			a_deplib=""
7838*a376eb32SXin Li			break 2
7839*a376eb32SXin Li		      fi
7840*a376eb32SXin Li		  done
7841*a376eb32SXin Li		done
7842*a376eb32SXin Li	      fi
7843*a376eb32SXin Li	      if test -n "$a_deplib" ; then
7844*a376eb32SXin Li		droppeddeps=yes
7845*a376eb32SXin Li		echo
7846*a376eb32SXin Li		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
7847*a376eb32SXin Li		echo "*** I have the capability to make that library automatically link in when"
7848*a376eb32SXin Li		echo "*** you link to this library.  But I can only do this if you have a"
7849*a376eb32SXin Li		echo "*** shared version of the library, which you do not appear to have"
7850*a376eb32SXin Li		echo "*** because I did check the linker path looking for a file starting"
7851*a376eb32SXin Li		if test -z "$potlib" ; then
7852*a376eb32SXin Li		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
7853*a376eb32SXin Li		else
7854*a376eb32SXin Li		  $ECHO "*** with $libname and none of the candidates passed a file format test"
7855*a376eb32SXin Li		  $ECHO "*** using a file magic. Last file checked: $potlib"
7856*a376eb32SXin Li		fi
7857*a376eb32SXin Li	      fi
7858*a376eb32SXin Li	      ;;
7859*a376eb32SXin Li	    *)
7860*a376eb32SXin Li	      # Add a -L argument.
7861*a376eb32SXin Li	      func_append newdeplibs " $a_deplib"
7862*a376eb32SXin Li	      ;;
7863*a376eb32SXin Li	    esac
7864*a376eb32SXin Li	  done # Gone through all deplibs.
7865*a376eb32SXin Li	  ;;
7866*a376eb32SXin Li	match_pattern*)
7867*a376eb32SXin Li	  set dummy $deplibs_check_method; shift
7868*a376eb32SXin Li	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7869*a376eb32SXin Li	  for a_deplib in $deplibs; do
7870*a376eb32SXin Li	    case $a_deplib in
7871*a376eb32SXin Li	    -l*)
7872*a376eb32SXin Li	      func_stripname -l '' "$a_deplib"
7873*a376eb32SXin Li	      name=$func_stripname_result
7874*a376eb32SXin Li	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7875*a376eb32SXin Li		case " $predeps $postdeps " in
7876*a376eb32SXin Li		*" $a_deplib "*)
7877*a376eb32SXin Li		  func_append newdeplibs " $a_deplib"
7878*a376eb32SXin Li		  a_deplib=""
7879*a376eb32SXin Li		  ;;
7880*a376eb32SXin Li		esac
7881*a376eb32SXin Li	      fi
7882*a376eb32SXin Li	      if test -n "$a_deplib" ; then
7883*a376eb32SXin Li		libname=`eval "\\$ECHO \"$libname_spec\""`
7884*a376eb32SXin Li		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7885*a376eb32SXin Li		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
7886*a376eb32SXin Li		  for potent_lib in $potential_libs; do
7887*a376eb32SXin Li		    potlib="$potent_lib" # see symlink-check above in file_magic test
7888*a376eb32SXin Li		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
7889*a376eb32SXin Li		       $EGREP "$match_pattern_regex" > /dev/null; then
7890*a376eb32SXin Li		      func_append newdeplibs " $a_deplib"
7891*a376eb32SXin Li		      a_deplib=""
7892*a376eb32SXin Li		      break 2
7893*a376eb32SXin Li		    fi
7894*a376eb32SXin Li		  done
7895*a376eb32SXin Li		done
7896*a376eb32SXin Li	      fi
7897*a376eb32SXin Li	      if test -n "$a_deplib" ; then
7898*a376eb32SXin Li		droppeddeps=yes
7899*a376eb32SXin Li		echo
7900*a376eb32SXin Li		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
7901*a376eb32SXin Li		echo "*** I have the capability to make that library automatically link in when"
7902*a376eb32SXin Li		echo "*** you link to this library.  But I can only do this if you have a"
7903*a376eb32SXin Li		echo "*** shared version of the library, which you do not appear to have"
7904*a376eb32SXin Li		echo "*** because I did check the linker path looking for a file starting"
7905*a376eb32SXin Li		if test -z "$potlib" ; then
7906*a376eb32SXin Li		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
7907*a376eb32SXin Li		else
7908*a376eb32SXin Li		  $ECHO "*** with $libname and none of the candidates passed a file format test"
7909*a376eb32SXin Li		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
7910*a376eb32SXin Li		fi
7911*a376eb32SXin Li	      fi
7912*a376eb32SXin Li	      ;;
7913*a376eb32SXin Li	    *)
7914*a376eb32SXin Li	      # Add a -L argument.
7915*a376eb32SXin Li	      func_append newdeplibs " $a_deplib"
7916*a376eb32SXin Li	      ;;
7917*a376eb32SXin Li	    esac
7918*a376eb32SXin Li	  done # Gone through all deplibs.
7919*a376eb32SXin Li	  ;;
7920*a376eb32SXin Li	none | unknown | *)
7921*a376eb32SXin Li	  newdeplibs=""
7922*a376eb32SXin Li	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
7923*a376eb32SXin Li	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7924*a376eb32SXin Li	    for i in $predeps $postdeps ; do
7925*a376eb32SXin Li	      # can't use Xsed below, because $i might contain '/'
7926*a376eb32SXin Li	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
7927*a376eb32SXin Li	    done
7928*a376eb32SXin Li	  fi
7929*a376eb32SXin Li	  case $tmp_deplibs in
7930*a376eb32SXin Li	  *[!\	\ ]*)
7931*a376eb32SXin Li	    echo
7932*a376eb32SXin Li	    if test "X$deplibs_check_method" = "Xnone"; then
7933*a376eb32SXin Li	      echo "*** Warning: inter-library dependencies are not supported in this platform."
7934*a376eb32SXin Li	    else
7935*a376eb32SXin Li	      echo "*** Warning: inter-library dependencies are not known to be supported."
7936*a376eb32SXin Li	    fi
7937*a376eb32SXin Li	    echo "*** All declared inter-library dependencies are being dropped."
7938*a376eb32SXin Li	    droppeddeps=yes
7939*a376eb32SXin Li	    ;;
7940*a376eb32SXin Li	  esac
7941*a376eb32SXin Li	  ;;
7942*a376eb32SXin Li	esac
7943*a376eb32SXin Li	versuffix=$versuffix_save
7944*a376eb32SXin Li	major=$major_save
7945*a376eb32SXin Li	release=$release_save
7946*a376eb32SXin Li	libname=$libname_save
7947*a376eb32SXin Li	name=$name_save
7948*a376eb32SXin Li
7949*a376eb32SXin Li	case $host in
7950*a376eb32SXin Li	*-*-rhapsody* | *-*-darwin1.[012])
7951*a376eb32SXin Li	  # On Rhapsody replace the C library with the System framework
7952*a376eb32SXin Li	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
7953*a376eb32SXin Li	  ;;
7954*a376eb32SXin Li	esac
7955*a376eb32SXin Li
7956*a376eb32SXin Li	if test "$droppeddeps" = yes; then
7957*a376eb32SXin Li	  if test "$module" = yes; then
7958*a376eb32SXin Li	    echo
7959*a376eb32SXin Li	    echo "*** Warning: libtool could not satisfy all declared inter-library"
7960*a376eb32SXin Li	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
7961*a376eb32SXin Li	    echo "*** a static module, that should work as long as the dlopening"
7962*a376eb32SXin Li	    echo "*** application is linked with the -dlopen flag."
7963*a376eb32SXin Li	    if test -z "$global_symbol_pipe"; then
7964*a376eb32SXin Li	      echo
7965*a376eb32SXin Li	      echo "*** However, this would only work if libtool was able to extract symbol"
7966*a376eb32SXin Li	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
7967*a376eb32SXin Li	      echo "*** not find such a program.  So, this module is probably useless."
7968*a376eb32SXin Li	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
7969*a376eb32SXin Li	    fi
7970*a376eb32SXin Li	    if test "$build_old_libs" = no; then
7971*a376eb32SXin Li	      oldlibs="$output_objdir/$libname.$libext"
7972*a376eb32SXin Li	      build_libtool_libs=module
7973*a376eb32SXin Li	      build_old_libs=yes
7974*a376eb32SXin Li	    else
7975*a376eb32SXin Li	      build_libtool_libs=no
7976*a376eb32SXin Li	    fi
7977*a376eb32SXin Li	  else
7978*a376eb32SXin Li	    echo "*** The inter-library dependencies that have been dropped here will be"
7979*a376eb32SXin Li	    echo "*** automatically added whenever a program is linked with this library"
7980*a376eb32SXin Li	    echo "*** or is declared to -dlopen it."
7981*a376eb32SXin Li
7982*a376eb32SXin Li	    if test "$allow_undefined" = no; then
7983*a376eb32SXin Li	      echo
7984*a376eb32SXin Li	      echo "*** Since this library must not contain undefined symbols,"
7985*a376eb32SXin Li	      echo "*** because either the platform does not support them or"
7986*a376eb32SXin Li	      echo "*** it was explicitly requested with -no-undefined,"
7987*a376eb32SXin Li	      echo "*** libtool will only create a static version of it."
7988*a376eb32SXin Li	      if test "$build_old_libs" = no; then
7989*a376eb32SXin Li		oldlibs="$output_objdir/$libname.$libext"
7990*a376eb32SXin Li		build_libtool_libs=module
7991*a376eb32SXin Li		build_old_libs=yes
7992*a376eb32SXin Li	      else
7993*a376eb32SXin Li		build_libtool_libs=no
7994*a376eb32SXin Li	      fi
7995*a376eb32SXin Li	    fi
7996*a376eb32SXin Li	  fi
7997*a376eb32SXin Li	fi
7998*a376eb32SXin Li	# Done checking deplibs!
7999*a376eb32SXin Li	deplibs=$newdeplibs
8000*a376eb32SXin Li      fi
8001*a376eb32SXin Li      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
8002*a376eb32SXin Li      case $host in
8003*a376eb32SXin Li	*-*-darwin*)
8004*a376eb32SXin Li	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8005*a376eb32SXin Li	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8006*a376eb32SXin Li	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8007*a376eb32SXin Li	  ;;
8008*a376eb32SXin Li      esac
8009*a376eb32SXin Li
8010*a376eb32SXin Li      # move library search paths that coincide with paths to not yet
8011*a376eb32SXin Li      # installed libraries to the beginning of the library search list
8012*a376eb32SXin Li      new_libs=
8013*a376eb32SXin Li      for path in $notinst_path; do
8014*a376eb32SXin Li	case " $new_libs " in
8015*a376eb32SXin Li	*" -L$path/$objdir "*) ;;
8016*a376eb32SXin Li	*)
8017*a376eb32SXin Li	  case " $deplibs " in
8018*a376eb32SXin Li	  *" -L$path/$objdir "*)
8019*a376eb32SXin Li	    func_append new_libs " -L$path/$objdir" ;;
8020*a376eb32SXin Li	  esac
8021*a376eb32SXin Li	  ;;
8022*a376eb32SXin Li	esac
8023*a376eb32SXin Li      done
8024*a376eb32SXin Li      for deplib in $deplibs; do
8025*a376eb32SXin Li	case $deplib in
8026*a376eb32SXin Li	-L*)
8027*a376eb32SXin Li	  case " $new_libs " in
8028*a376eb32SXin Li	  *" $deplib "*) ;;
8029*a376eb32SXin Li	  *) func_append new_libs " $deplib" ;;
8030*a376eb32SXin Li	  esac
8031*a376eb32SXin Li	  ;;
8032*a376eb32SXin Li	*) func_append new_libs " $deplib" ;;
8033*a376eb32SXin Li	esac
8034*a376eb32SXin Li      done
8035*a376eb32SXin Li      deplibs="$new_libs"
8036*a376eb32SXin Li
8037*a376eb32SXin Li      # All the library-specific variables (install_libdir is set above).
8038*a376eb32SXin Li      library_names=
8039*a376eb32SXin Li      old_library=
8040*a376eb32SXin Li      dlname=
8041*a376eb32SXin Li
8042*a376eb32SXin Li      # Test again, we may have decided not to build it any more
8043*a376eb32SXin Li      if test "$build_libtool_libs" = yes; then
8044*a376eb32SXin Li	# Remove ${wl} instances when linking with ld.
8045*a376eb32SXin Li	# FIXME: should test the right _cmds variable.
8046*a376eb32SXin Li	case $archive_cmds in
8047*a376eb32SXin Li	  *\$LD\ *) wl= ;;
8048*a376eb32SXin Li        esac
8049*a376eb32SXin Li	if test "$hardcode_into_libs" = yes; then
8050*a376eb32SXin Li	  # Hardcode the library paths
8051*a376eb32SXin Li	  hardcode_libdirs=
8052*a376eb32SXin Li	  dep_rpath=
8053*a376eb32SXin Li	  rpath="$finalize_rpath"
8054*a376eb32SXin Li	  test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
8055*a376eb32SXin Li	  for libdir in $rpath; do
8056*a376eb32SXin Li	    if test -n "$hardcode_libdir_flag_spec"; then
8057*a376eb32SXin Li	      if test -n "$hardcode_libdir_separator"; then
8058*a376eb32SXin Li		func_replace_sysroot "$libdir"
8059*a376eb32SXin Li		libdir=$func_replace_sysroot_result
8060*a376eb32SXin Li		if test -z "$hardcode_libdirs"; then
8061*a376eb32SXin Li		  hardcode_libdirs="$libdir"
8062*a376eb32SXin Li		else
8063*a376eb32SXin Li		  # Just accumulate the unique libdirs.
8064*a376eb32SXin Li		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8065*a376eb32SXin Li		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8066*a376eb32SXin Li		    ;;
8067*a376eb32SXin Li		  *)
8068*a376eb32SXin Li		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8069*a376eb32SXin Li		    ;;
8070*a376eb32SXin Li		  esac
8071*a376eb32SXin Li		fi
8072*a376eb32SXin Li	      else
8073*a376eb32SXin Li		eval flag=\"$hardcode_libdir_flag_spec\"
8074*a376eb32SXin Li		func_append dep_rpath " $flag"
8075*a376eb32SXin Li	      fi
8076*a376eb32SXin Li	    elif test -n "$runpath_var"; then
8077*a376eb32SXin Li	      case "$perm_rpath " in
8078*a376eb32SXin Li	      *" $libdir "*) ;;
8079*a376eb32SXin Li	      *) func_append perm_rpath " $libdir" ;;
8080*a376eb32SXin Li	      esac
8081*a376eb32SXin Li	    fi
8082*a376eb32SXin Li	  done
8083*a376eb32SXin Li	  # Substitute the hardcoded libdirs into the rpath.
8084*a376eb32SXin Li	  if test -n "$hardcode_libdir_separator" &&
8085*a376eb32SXin Li	     test -n "$hardcode_libdirs"; then
8086*a376eb32SXin Li	    libdir="$hardcode_libdirs"
8087*a376eb32SXin Li	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
8088*a376eb32SXin Li	  fi
8089*a376eb32SXin Li	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
8090*a376eb32SXin Li	    # We should set the runpath_var.
8091*a376eb32SXin Li	    rpath=
8092*a376eb32SXin Li	    for dir in $perm_rpath; do
8093*a376eb32SXin Li	      func_append rpath "$dir:"
8094*a376eb32SXin Li	    done
8095*a376eb32SXin Li	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
8096*a376eb32SXin Li	  fi
8097*a376eb32SXin Li	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
8098*a376eb32SXin Li	fi
8099*a376eb32SXin Li
8100*a376eb32SXin Li	shlibpath="$finalize_shlibpath"
8101*a376eb32SXin Li	test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
8102*a376eb32SXin Li	if test -n "$shlibpath"; then
8103*a376eb32SXin Li	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
8104*a376eb32SXin Li	fi
8105*a376eb32SXin Li
8106*a376eb32SXin Li	# Get the real and link names of the library.
8107*a376eb32SXin Li	eval shared_ext=\"$shrext_cmds\"
8108*a376eb32SXin Li	eval library_names=\"$library_names_spec\"
8109*a376eb32SXin Li	set dummy $library_names
8110*a376eb32SXin Li	shift
8111*a376eb32SXin Li	realname="$1"
8112*a376eb32SXin Li	shift
8113*a376eb32SXin Li
8114*a376eb32SXin Li	if test -n "$soname_spec"; then
8115*a376eb32SXin Li	  eval soname=\"$soname_spec\"
8116*a376eb32SXin Li	else
8117*a376eb32SXin Li	  soname="$realname"
8118*a376eb32SXin Li	fi
8119*a376eb32SXin Li	if test -z "$dlname"; then
8120*a376eb32SXin Li	  dlname=$soname
8121*a376eb32SXin Li	fi
8122*a376eb32SXin Li
8123*a376eb32SXin Li	lib="$output_objdir/$realname"
8124*a376eb32SXin Li	linknames=
8125*a376eb32SXin Li	for link
8126*a376eb32SXin Li	do
8127*a376eb32SXin Li	  func_append linknames " $link"
8128*a376eb32SXin Li	done
8129*a376eb32SXin Li
8130*a376eb32SXin Li	# Use standard objects if they are pic
8131*a376eb32SXin Li	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
8132*a376eb32SXin Li	test "X$libobjs" = "X " && libobjs=
8133*a376eb32SXin Li
8134*a376eb32SXin Li	delfiles=
8135*a376eb32SXin Li	if test -n "$export_symbols" && test -n "$include_expsyms"; then
8136*a376eb32SXin Li	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
8137*a376eb32SXin Li	  export_symbols="$output_objdir/$libname.uexp"
8138*a376eb32SXin Li	  func_append delfiles " $export_symbols"
8139*a376eb32SXin Li	fi
8140*a376eb32SXin Li
8141*a376eb32SXin Li	orig_export_symbols=
8142*a376eb32SXin Li	case $host_os in
8143*a376eb32SXin Li	cygwin* | mingw* | cegcc*)
8144*a376eb32SXin Li	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
8145*a376eb32SXin Li	    # exporting using user supplied symfile
8146*a376eb32SXin Li	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
8147*a376eb32SXin Li	      # and it's NOT already a .def file. Must figure out
8148*a376eb32SXin Li	      # which of the given symbols are data symbols and tag
8149*a376eb32SXin Li	      # them as such. So, trigger use of export_symbols_cmds.
8150*a376eb32SXin Li	      # export_symbols gets reassigned inside the "prepare
8151*a376eb32SXin Li	      # the list of exported symbols" if statement, so the
8152*a376eb32SXin Li	      # include_expsyms logic still works.
8153*a376eb32SXin Li	      orig_export_symbols="$export_symbols"
8154*a376eb32SXin Li	      export_symbols=
8155*a376eb32SXin Li	      always_export_symbols=yes
8156*a376eb32SXin Li	    fi
8157*a376eb32SXin Li	  fi
8158*a376eb32SXin Li	  ;;
8159*a376eb32SXin Li	esac
8160*a376eb32SXin Li
8161*a376eb32SXin Li	# Prepare the list of exported symbols
8162*a376eb32SXin Li	if test -z "$export_symbols"; then
8163*a376eb32SXin Li	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
8164*a376eb32SXin Li	    func_verbose "generating symbol list for \`$libname.la'"
8165*a376eb32SXin Li	    export_symbols="$output_objdir/$libname.exp"
8166*a376eb32SXin Li	    $opt_dry_run || $RM $export_symbols
8167*a376eb32SXin Li	    cmds=$export_symbols_cmds
8168*a376eb32SXin Li	    save_ifs="$IFS"; IFS='~'
8169*a376eb32SXin Li	    for cmd1 in $cmds; do
8170*a376eb32SXin Li	      IFS="$save_ifs"
8171*a376eb32SXin Li	      # Take the normal branch if the nm_file_list_spec branch
8172*a376eb32SXin Li	      # doesn't work or if tool conversion is not needed.
8173*a376eb32SXin Li	      case $nm_file_list_spec~$to_tool_file_cmd in
8174*a376eb32SXin Li		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
8175*a376eb32SXin Li		  try_normal_branch=yes
8176*a376eb32SXin Li		  eval cmd=\"$cmd1\"
8177*a376eb32SXin Li		  func_len " $cmd"
8178*a376eb32SXin Li		  len=$func_len_result
8179*a376eb32SXin Li		  ;;
8180*a376eb32SXin Li		*)
8181*a376eb32SXin Li		  try_normal_branch=no
8182*a376eb32SXin Li		  ;;
8183*a376eb32SXin Li	      esac
8184*a376eb32SXin Li	      if test "$try_normal_branch" = yes \
8185*a376eb32SXin Li		 && { test "$len" -lt "$max_cmd_len" \
8186*a376eb32SXin Li		      || test "$max_cmd_len" -le -1; }
8187*a376eb32SXin Li	      then
8188*a376eb32SXin Li		func_show_eval "$cmd" 'exit $?'
8189*a376eb32SXin Li		skipped_export=false
8190*a376eb32SXin Li	      elif test -n "$nm_file_list_spec"; then
8191*a376eb32SXin Li		func_basename "$output"
8192*a376eb32SXin Li		output_la=$func_basename_result
8193*a376eb32SXin Li		save_libobjs=$libobjs
8194*a376eb32SXin Li		save_output=$output
8195*a376eb32SXin Li		output=${output_objdir}/${output_la}.nm
8196*a376eb32SXin Li		func_to_tool_file "$output"
8197*a376eb32SXin Li		libobjs=$nm_file_list_spec$func_to_tool_file_result
8198*a376eb32SXin Li		func_append delfiles " $output"
8199*a376eb32SXin Li		func_verbose "creating $NM input file list: $output"
8200*a376eb32SXin Li		for obj in $save_libobjs; do
8201*a376eb32SXin Li		  func_to_tool_file "$obj"
8202*a376eb32SXin Li		  $ECHO "$func_to_tool_file_result"
8203*a376eb32SXin Li		done > "$output"
8204*a376eb32SXin Li		eval cmd=\"$cmd1\"
8205*a376eb32SXin Li		func_show_eval "$cmd" 'exit $?'
8206*a376eb32SXin Li		output=$save_output
8207*a376eb32SXin Li		libobjs=$save_libobjs
8208*a376eb32SXin Li		skipped_export=false
8209*a376eb32SXin Li	      else
8210*a376eb32SXin Li		# The command line is too long to execute in one step.
8211*a376eb32SXin Li		func_verbose "using reloadable object file for export list..."
8212*a376eb32SXin Li		skipped_export=:
8213*a376eb32SXin Li		# Break out early, otherwise skipped_export may be
8214*a376eb32SXin Li		# set to false by a later but shorter cmd.
8215*a376eb32SXin Li		break
8216*a376eb32SXin Li	      fi
8217*a376eb32SXin Li	    done
8218*a376eb32SXin Li	    IFS="$save_ifs"
8219*a376eb32SXin Li	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
8220*a376eb32SXin Li	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8221*a376eb32SXin Li	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8222*a376eb32SXin Li	    fi
8223*a376eb32SXin Li	  fi
8224*a376eb32SXin Li	fi
8225*a376eb32SXin Li
8226*a376eb32SXin Li	if test -n "$export_symbols" && test -n "$include_expsyms"; then
8227*a376eb32SXin Li	  tmp_export_symbols="$export_symbols"
8228*a376eb32SXin Li	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
8229*a376eb32SXin Li	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8230*a376eb32SXin Li	fi
8231*a376eb32SXin Li
8232*a376eb32SXin Li	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
8233*a376eb32SXin Li	  # The given exports_symbols file has to be filtered, so filter it.
8234*a376eb32SXin Li	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8235*a376eb32SXin Li	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
8236*a376eb32SXin Li	  # 's' commands which not all seds can handle. GNU sed should be fine
8237*a376eb32SXin Li	  # though. Also, the filter scales superlinearly with the number of
8238*a376eb32SXin Li	  # global variables. join(1) would be nice here, but unfortunately
8239*a376eb32SXin Li	  # isn't a blessed tool.
8240*a376eb32SXin Li	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8241*a376eb32SXin Li	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
8242*a376eb32SXin Li	  export_symbols=$output_objdir/$libname.def
8243*a376eb32SXin Li	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
8244*a376eb32SXin Li	fi
8245*a376eb32SXin Li
8246*a376eb32SXin Li	tmp_deplibs=
8247*a376eb32SXin Li	for test_deplib in $deplibs; do
8248*a376eb32SXin Li	  case " $convenience " in
8249*a376eb32SXin Li	  *" $test_deplib "*) ;;
8250*a376eb32SXin Li	  *)
8251*a376eb32SXin Li	    func_append tmp_deplibs " $test_deplib"
8252*a376eb32SXin Li	    ;;
8253*a376eb32SXin Li	  esac
8254*a376eb32SXin Li	done
8255*a376eb32SXin Li	deplibs="$tmp_deplibs"
8256*a376eb32SXin Li
8257*a376eb32SXin Li	if test -n "$convenience"; then
8258*a376eb32SXin Li	  if test -n "$whole_archive_flag_spec" &&
8259*a376eb32SXin Li	    test "$compiler_needs_object" = yes &&
8260*a376eb32SXin Li	    test -z "$libobjs"; then
8261*a376eb32SXin Li	    # extract the archives, so we have objects to list.
8262*a376eb32SXin Li	    # TODO: could optimize this to just extract one archive.
8263*a376eb32SXin Li	    whole_archive_flag_spec=
8264*a376eb32SXin Li	  fi
8265*a376eb32SXin Li	  if test -n "$whole_archive_flag_spec"; then
8266*a376eb32SXin Li	    save_libobjs=$libobjs
8267*a376eb32SXin Li	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8268*a376eb32SXin Li	    test "X$libobjs" = "X " && libobjs=
8269*a376eb32SXin Li	  else
8270*a376eb32SXin Li	    gentop="$output_objdir/${outputname}x"
8271*a376eb32SXin Li	    func_append generated " $gentop"
8272*a376eb32SXin Li
8273*a376eb32SXin Li	    func_extract_archives $gentop $convenience
8274*a376eb32SXin Li	    func_append libobjs " $func_extract_archives_result"
8275*a376eb32SXin Li	    test "X$libobjs" = "X " && libobjs=
8276*a376eb32SXin Li	  fi
8277*a376eb32SXin Li	fi
8278*a376eb32SXin Li
8279*a376eb32SXin Li	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
8280*a376eb32SXin Li	  eval flag=\"$thread_safe_flag_spec\"
8281*a376eb32SXin Li	  func_append linker_flags " $flag"
8282*a376eb32SXin Li	fi
8283*a376eb32SXin Li
8284*a376eb32SXin Li	# Make a backup of the uninstalled library when relinking
8285*a376eb32SXin Li	if test "$opt_mode" = relink; then
8286*a376eb32SXin Li	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
8287*a376eb32SXin Li	fi
8288*a376eb32SXin Li
8289*a376eb32SXin Li	# Do each of the archive commands.
8290*a376eb32SXin Li	if test "$module" = yes && test -n "$module_cmds" ; then
8291*a376eb32SXin Li	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8292*a376eb32SXin Li	    eval test_cmds=\"$module_expsym_cmds\"
8293*a376eb32SXin Li	    cmds=$module_expsym_cmds
8294*a376eb32SXin Li	  else
8295*a376eb32SXin Li	    eval test_cmds=\"$module_cmds\"
8296*a376eb32SXin Li	    cmds=$module_cmds
8297*a376eb32SXin Li	  fi
8298*a376eb32SXin Li	else
8299*a376eb32SXin Li	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8300*a376eb32SXin Li	    eval test_cmds=\"$archive_expsym_cmds\"
8301*a376eb32SXin Li	    cmds=$archive_expsym_cmds
8302*a376eb32SXin Li	  else
8303*a376eb32SXin Li	    eval test_cmds=\"$archive_cmds\"
8304*a376eb32SXin Li	    cmds=$archive_cmds
8305*a376eb32SXin Li	  fi
8306*a376eb32SXin Li	fi
8307*a376eb32SXin Li
8308*a376eb32SXin Li	if test "X$skipped_export" != "X:" &&
8309*a376eb32SXin Li	   func_len " $test_cmds" &&
8310*a376eb32SXin Li	   len=$func_len_result &&
8311*a376eb32SXin Li	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
8312*a376eb32SXin Li	  :
8313*a376eb32SXin Li	else
8314*a376eb32SXin Li	  # The command line is too long to link in one step, link piecewise
8315*a376eb32SXin Li	  # or, if using GNU ld and skipped_export is not :, use a linker
8316*a376eb32SXin Li	  # script.
8317*a376eb32SXin Li
8318*a376eb32SXin Li	  # Save the value of $output and $libobjs because we want to
8319*a376eb32SXin Li	  # use them later.  If we have whole_archive_flag_spec, we
8320*a376eb32SXin Li	  # want to use save_libobjs as it was before
8321*a376eb32SXin Li	  # whole_archive_flag_spec was expanded, because we can't
8322*a376eb32SXin Li	  # assume the linker understands whole_archive_flag_spec.
8323*a376eb32SXin Li	  # This may have to be revisited, in case too many
8324*a376eb32SXin Li	  # convenience libraries get linked in and end up exceeding
8325*a376eb32SXin Li	  # the spec.
8326*a376eb32SXin Li	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
8327*a376eb32SXin Li	    save_libobjs=$libobjs
8328*a376eb32SXin Li	  fi
8329*a376eb32SXin Li	  save_output=$output
8330*a376eb32SXin Li	  func_basename "$output"
8331*a376eb32SXin Li	  output_la=$func_basename_result
8332*a376eb32SXin Li
8333*a376eb32SXin Li	  # Clear the reloadable object creation command queue and
8334*a376eb32SXin Li	  # initialize k to one.
8335*a376eb32SXin Li	  test_cmds=
8336*a376eb32SXin Li	  concat_cmds=
8337*a376eb32SXin Li	  objlist=
8338*a376eb32SXin Li	  last_robj=
8339*a376eb32SXin Li	  k=1
8340*a376eb32SXin Li
8341*a376eb32SXin Li	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
8342*a376eb32SXin Li	    output=${output_objdir}/${output_la}.lnkscript
8343*a376eb32SXin Li	    func_verbose "creating GNU ld script: $output"
8344*a376eb32SXin Li	    echo 'INPUT (' > $output
8345*a376eb32SXin Li	    for obj in $save_libobjs
8346*a376eb32SXin Li	    do
8347*a376eb32SXin Li	      func_to_tool_file "$obj"
8348*a376eb32SXin Li	      $ECHO "$func_to_tool_file_result" >> $output
8349*a376eb32SXin Li	    done
8350*a376eb32SXin Li	    echo ')' >> $output
8351*a376eb32SXin Li	    func_append delfiles " $output"
8352*a376eb32SXin Li	    func_to_tool_file "$output"
8353*a376eb32SXin Li	    output=$func_to_tool_file_result
8354*a376eb32SXin Li	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
8355*a376eb32SXin Li	    output=${output_objdir}/${output_la}.lnk
8356*a376eb32SXin Li	    func_verbose "creating linker input file list: $output"
8357*a376eb32SXin Li	    : > $output
8358*a376eb32SXin Li	    set x $save_libobjs
8359*a376eb32SXin Li	    shift
8360*a376eb32SXin Li	    firstobj=
8361*a376eb32SXin Li	    if test "$compiler_needs_object" = yes; then
8362*a376eb32SXin Li	      firstobj="$1 "
8363*a376eb32SXin Li	      shift
8364*a376eb32SXin Li	    fi
8365*a376eb32SXin Li	    for obj
8366*a376eb32SXin Li	    do
8367*a376eb32SXin Li	      func_to_tool_file "$obj"
8368*a376eb32SXin Li	      $ECHO "$func_to_tool_file_result" >> $output
8369*a376eb32SXin Li	    done
8370*a376eb32SXin Li	    func_append delfiles " $output"
8371*a376eb32SXin Li	    func_to_tool_file "$output"
8372*a376eb32SXin Li	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
8373*a376eb32SXin Li	  else
8374*a376eb32SXin Li	    if test -n "$save_libobjs"; then
8375*a376eb32SXin Li	      func_verbose "creating reloadable object files..."
8376*a376eb32SXin Li	      output=$output_objdir/$output_la-${k}.$objext
8377*a376eb32SXin Li	      eval test_cmds=\"$reload_cmds\"
8378*a376eb32SXin Li	      func_len " $test_cmds"
8379*a376eb32SXin Li	      len0=$func_len_result
8380*a376eb32SXin Li	      len=$len0
8381*a376eb32SXin Li
8382*a376eb32SXin Li	      # Loop over the list of objects to be linked.
8383*a376eb32SXin Li	      for obj in $save_libobjs
8384*a376eb32SXin Li	      do
8385*a376eb32SXin Li		func_len " $obj"
8386*a376eb32SXin Li		func_arith $len + $func_len_result
8387*a376eb32SXin Li		len=$func_arith_result
8388*a376eb32SXin Li		if test "X$objlist" = X ||
8389*a376eb32SXin Li		   test "$len" -lt "$max_cmd_len"; then
8390*a376eb32SXin Li		  func_append objlist " $obj"
8391*a376eb32SXin Li		else
8392*a376eb32SXin Li		  # The command $test_cmds is almost too long, add a
8393*a376eb32SXin Li		  # command to the queue.
8394*a376eb32SXin Li		  if test "$k" -eq 1 ; then
8395*a376eb32SXin Li		    # The first file doesn't have a previous command to add.
8396*a376eb32SXin Li		    reload_objs=$objlist
8397*a376eb32SXin Li		    eval concat_cmds=\"$reload_cmds\"
8398*a376eb32SXin Li		  else
8399*a376eb32SXin Li		    # All subsequent reloadable object files will link in
8400*a376eb32SXin Li		    # the last one created.
8401*a376eb32SXin Li		    reload_objs="$objlist $last_robj"
8402*a376eb32SXin Li		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
8403*a376eb32SXin Li		  fi
8404*a376eb32SXin Li		  last_robj=$output_objdir/$output_la-${k}.$objext
8405*a376eb32SXin Li		  func_arith $k + 1
8406*a376eb32SXin Li		  k=$func_arith_result
8407*a376eb32SXin Li		  output=$output_objdir/$output_la-${k}.$objext
8408*a376eb32SXin Li		  objlist=" $obj"
8409*a376eb32SXin Li		  func_len " $last_robj"
8410*a376eb32SXin Li		  func_arith $len0 + $func_len_result
8411*a376eb32SXin Li		  len=$func_arith_result
8412*a376eb32SXin Li		fi
8413*a376eb32SXin Li	      done
8414*a376eb32SXin Li	      # Handle the remaining objects by creating one last
8415*a376eb32SXin Li	      # reloadable object file.  All subsequent reloadable object
8416*a376eb32SXin Li	      # files will link in the last one created.
8417*a376eb32SXin Li	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8418*a376eb32SXin Li	      reload_objs="$objlist $last_robj"
8419*a376eb32SXin Li	      eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
8420*a376eb32SXin Li	      if test -n "$last_robj"; then
8421*a376eb32SXin Li	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
8422*a376eb32SXin Li	      fi
8423*a376eb32SXin Li	      func_append delfiles " $output"
8424*a376eb32SXin Li
8425*a376eb32SXin Li	    else
8426*a376eb32SXin Li	      output=
8427*a376eb32SXin Li	    fi
8428*a376eb32SXin Li
8429*a376eb32SXin Li	    if ${skipped_export-false}; then
8430*a376eb32SXin Li	      func_verbose "generating symbol list for \`$libname.la'"
8431*a376eb32SXin Li	      export_symbols="$output_objdir/$libname.exp"
8432*a376eb32SXin Li	      $opt_dry_run || $RM $export_symbols
8433*a376eb32SXin Li	      libobjs=$output
8434*a376eb32SXin Li	      # Append the command to create the export file.
8435*a376eb32SXin Li	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8436*a376eb32SXin Li	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
8437*a376eb32SXin Li	      if test -n "$last_robj"; then
8438*a376eb32SXin Li		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
8439*a376eb32SXin Li	      fi
8440*a376eb32SXin Li	    fi
8441*a376eb32SXin Li
8442*a376eb32SXin Li	    test -n "$save_libobjs" &&
8443*a376eb32SXin Li	      func_verbose "creating a temporary reloadable object file: $output"
8444*a376eb32SXin Li
8445*a376eb32SXin Li	    # Loop through the commands generated above and execute them.
8446*a376eb32SXin Li	    save_ifs="$IFS"; IFS='~'
8447*a376eb32SXin Li	    for cmd in $concat_cmds; do
8448*a376eb32SXin Li	      IFS="$save_ifs"
8449*a376eb32SXin Li	      $opt_silent || {
8450*a376eb32SXin Li		  func_quote_for_expand "$cmd"
8451*a376eb32SXin Li		  eval "func_echo $func_quote_for_expand_result"
8452*a376eb32SXin Li	      }
8453*a376eb32SXin Li	      $opt_dry_run || eval "$cmd" || {
8454*a376eb32SXin Li		lt_exit=$?
8455*a376eb32SXin Li
8456*a376eb32SXin Li		# Restore the uninstalled library and exit
8457*a376eb32SXin Li		if test "$opt_mode" = relink; then
8458*a376eb32SXin Li		  ( cd "$output_objdir" && \
8459*a376eb32SXin Li		    $RM "${realname}T" && \
8460*a376eb32SXin Li		    $MV "${realname}U" "$realname" )
8461*a376eb32SXin Li		fi
8462*a376eb32SXin Li
8463*a376eb32SXin Li		exit $lt_exit
8464*a376eb32SXin Li	      }
8465*a376eb32SXin Li	    done
8466*a376eb32SXin Li	    IFS="$save_ifs"
8467*a376eb32SXin Li
8468*a376eb32SXin Li	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
8469*a376eb32SXin Li	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8470*a376eb32SXin Li	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8471*a376eb32SXin Li	    fi
8472*a376eb32SXin Li	  fi
8473*a376eb32SXin Li
8474*a376eb32SXin Li          if ${skipped_export-false}; then
8475*a376eb32SXin Li	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
8476*a376eb32SXin Li	      tmp_export_symbols="$export_symbols"
8477*a376eb32SXin Li	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
8478*a376eb32SXin Li	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8479*a376eb32SXin Li	    fi
8480*a376eb32SXin Li
8481*a376eb32SXin Li	    if test -n "$orig_export_symbols"; then
8482*a376eb32SXin Li	      # The given exports_symbols file has to be filtered, so filter it.
8483*a376eb32SXin Li	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8484*a376eb32SXin Li	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
8485*a376eb32SXin Li	      # 's' commands which not all seds can handle. GNU sed should be fine
8486*a376eb32SXin Li	      # though. Also, the filter scales superlinearly with the number of
8487*a376eb32SXin Li	      # global variables. join(1) would be nice here, but unfortunately
8488*a376eb32SXin Li	      # isn't a blessed tool.
8489*a376eb32SXin Li	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8490*a376eb32SXin Li	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
8491*a376eb32SXin Li	      export_symbols=$output_objdir/$libname.def
8492*a376eb32SXin Li	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
8493*a376eb32SXin Li	    fi
8494*a376eb32SXin Li	  fi
8495*a376eb32SXin Li
8496*a376eb32SXin Li	  libobjs=$output
8497*a376eb32SXin Li	  # Restore the value of output.
8498*a376eb32SXin Li	  output=$save_output
8499*a376eb32SXin Li
8500*a376eb32SXin Li	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
8501*a376eb32SXin Li	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8502*a376eb32SXin Li	    test "X$libobjs" = "X " && libobjs=
8503*a376eb32SXin Li	  fi
8504*a376eb32SXin Li	  # Expand the library linking commands again to reset the
8505*a376eb32SXin Li	  # value of $libobjs for piecewise linking.
8506*a376eb32SXin Li
8507*a376eb32SXin Li	  # Do each of the archive commands.
8508*a376eb32SXin Li	  if test "$module" = yes && test -n "$module_cmds" ; then
8509*a376eb32SXin Li	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8510*a376eb32SXin Li	      cmds=$module_expsym_cmds
8511*a376eb32SXin Li	    else
8512*a376eb32SXin Li	      cmds=$module_cmds
8513*a376eb32SXin Li	    fi
8514*a376eb32SXin Li	  else
8515*a376eb32SXin Li	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8516*a376eb32SXin Li	      cmds=$archive_expsym_cmds
8517*a376eb32SXin Li	    else
8518*a376eb32SXin Li	      cmds=$archive_cmds
8519*a376eb32SXin Li	    fi
8520*a376eb32SXin Li	  fi
8521*a376eb32SXin Li	fi
8522*a376eb32SXin Li
8523*a376eb32SXin Li	if test -n "$delfiles"; then
8524*a376eb32SXin Li	  # Append the command to remove temporary files to $cmds.
8525*a376eb32SXin Li	  eval cmds=\"\$cmds~\$RM $delfiles\"
8526*a376eb32SXin Li	fi
8527*a376eb32SXin Li
8528*a376eb32SXin Li	# Add any objects from preloaded convenience libraries
8529*a376eb32SXin Li	if test -n "$dlprefiles"; then
8530*a376eb32SXin Li	  gentop="$output_objdir/${outputname}x"
8531*a376eb32SXin Li	  func_append generated " $gentop"
8532*a376eb32SXin Li
8533*a376eb32SXin Li	  func_extract_archives $gentop $dlprefiles
8534*a376eb32SXin Li	  func_append libobjs " $func_extract_archives_result"
8535*a376eb32SXin Li	  test "X$libobjs" = "X " && libobjs=
8536*a376eb32SXin Li	fi
8537*a376eb32SXin Li
8538*a376eb32SXin Li	save_ifs="$IFS"; IFS='~'
8539*a376eb32SXin Li	for cmd in $cmds; do
8540*a376eb32SXin Li	  IFS="$save_ifs"
8541*a376eb32SXin Li	  eval cmd=\"$cmd\"
8542*a376eb32SXin Li	  $opt_silent || {
8543*a376eb32SXin Li	    func_quote_for_expand "$cmd"
8544*a376eb32SXin Li	    eval "func_echo $func_quote_for_expand_result"
8545*a376eb32SXin Li	  }
8546*a376eb32SXin Li	  $opt_dry_run || eval "$cmd" || {
8547*a376eb32SXin Li	    lt_exit=$?
8548*a376eb32SXin Li
8549*a376eb32SXin Li	    # Restore the uninstalled library and exit
8550*a376eb32SXin Li	    if test "$opt_mode" = relink; then
8551*a376eb32SXin Li	      ( cd "$output_objdir" && \
8552*a376eb32SXin Li	        $RM "${realname}T" && \
8553*a376eb32SXin Li		$MV "${realname}U" "$realname" )
8554*a376eb32SXin Li	    fi
8555*a376eb32SXin Li
8556*a376eb32SXin Li	    exit $lt_exit
8557*a376eb32SXin Li	  }
8558*a376eb32SXin Li	done
8559*a376eb32SXin Li	IFS="$save_ifs"
8560*a376eb32SXin Li
8561*a376eb32SXin Li	# Restore the uninstalled library and exit
8562*a376eb32SXin Li	if test "$opt_mode" = relink; then
8563*a376eb32SXin Li	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
8564*a376eb32SXin Li
8565*a376eb32SXin Li	  if test -n "$convenience"; then
8566*a376eb32SXin Li	    if test -z "$whole_archive_flag_spec"; then
8567*a376eb32SXin Li	      func_show_eval '${RM}r "$gentop"'
8568*a376eb32SXin Li	    fi
8569*a376eb32SXin Li	  fi
8570*a376eb32SXin Li
8571*a376eb32SXin Li	  exit $EXIT_SUCCESS
8572*a376eb32SXin Li	fi
8573*a376eb32SXin Li
8574*a376eb32SXin Li	# Create links to the real library.
8575*a376eb32SXin Li	for linkname in $linknames; do
8576*a376eb32SXin Li	  if test "$realname" != "$linkname"; then
8577*a376eb32SXin Li	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
8578*a376eb32SXin Li	  fi
8579*a376eb32SXin Li	done
8580*a376eb32SXin Li
8581*a376eb32SXin Li	# If -module or -export-dynamic was specified, set the dlname.
8582*a376eb32SXin Li	if test "$module" = yes || test "$export_dynamic" = yes; then
8583*a376eb32SXin Li	  # On all known operating systems, these are identical.
8584*a376eb32SXin Li	  dlname="$soname"
8585*a376eb32SXin Li	fi
8586*a376eb32SXin Li      fi
8587*a376eb32SXin Li      ;;
8588*a376eb32SXin Li
8589*a376eb32SXin Li    obj)
8590*a376eb32SXin Li      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
8591*a376eb32SXin Li	func_warning "\`-dlopen' is ignored for objects"
8592*a376eb32SXin Li      fi
8593*a376eb32SXin Li
8594*a376eb32SXin Li      case " $deplibs" in
8595*a376eb32SXin Li      *\ -l* | *\ -L*)
8596*a376eb32SXin Li	func_warning "\`-l' and \`-L' are ignored for objects" ;;
8597*a376eb32SXin Li      esac
8598*a376eb32SXin Li
8599*a376eb32SXin Li      test -n "$rpath" && \
8600*a376eb32SXin Li	func_warning "\`-rpath' is ignored for objects"
8601*a376eb32SXin Li
8602*a376eb32SXin Li      test -n "$xrpath" && \
8603*a376eb32SXin Li	func_warning "\`-R' is ignored for objects"
8604*a376eb32SXin Li
8605*a376eb32SXin Li      test -n "$vinfo" && \
8606*a376eb32SXin Li	func_warning "\`-version-info' is ignored for objects"
8607*a376eb32SXin Li
8608*a376eb32SXin Li      test -n "$release" && \
8609*a376eb32SXin Li	func_warning "\`-release' is ignored for objects"
8610*a376eb32SXin Li
8611*a376eb32SXin Li      case $output in
8612*a376eb32SXin Li      *.lo)
8613*a376eb32SXin Li	test -n "$objs$old_deplibs" && \
8614*a376eb32SXin Li	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
8615*a376eb32SXin Li
8616*a376eb32SXin Li	libobj=$output
8617*a376eb32SXin Li	func_lo2o "$libobj"
8618*a376eb32SXin Li	obj=$func_lo2o_result
8619*a376eb32SXin Li	;;
8620*a376eb32SXin Li      *)
8621*a376eb32SXin Li	libobj=
8622*a376eb32SXin Li	obj="$output"
8623*a376eb32SXin Li	;;
8624*a376eb32SXin Li      esac
8625*a376eb32SXin Li
8626*a376eb32SXin Li      # Delete the old objects.
8627*a376eb32SXin Li      $opt_dry_run || $RM $obj $libobj
8628*a376eb32SXin Li
8629*a376eb32SXin Li      # Objects from convenience libraries.  This assumes
8630*a376eb32SXin Li      # single-version convenience libraries.  Whenever we create
8631*a376eb32SXin Li      # different ones for PIC/non-PIC, this we'll have to duplicate
8632*a376eb32SXin Li      # the extraction.
8633*a376eb32SXin Li      reload_conv_objs=
8634*a376eb32SXin Li      gentop=
8635*a376eb32SXin Li      # reload_cmds runs $LD directly, so let us get rid of
8636*a376eb32SXin Li      # -Wl from whole_archive_flag_spec and hope we can get by with
8637*a376eb32SXin Li      # turning comma into space..
8638*a376eb32SXin Li      wl=
8639*a376eb32SXin Li
8640*a376eb32SXin Li      if test -n "$convenience"; then
8641*a376eb32SXin Li	if test -n "$whole_archive_flag_spec"; then
8642*a376eb32SXin Li	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
8643*a376eb32SXin Li	  reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
8644*a376eb32SXin Li	else
8645*a376eb32SXin Li	  gentop="$output_objdir/${obj}x"
8646*a376eb32SXin Li	  func_append generated " $gentop"
8647*a376eb32SXin Li
8648*a376eb32SXin Li	  func_extract_archives $gentop $convenience
8649*a376eb32SXin Li	  reload_conv_objs="$reload_objs $func_extract_archives_result"
8650*a376eb32SXin Li	fi
8651*a376eb32SXin Li      fi
8652*a376eb32SXin Li
8653*a376eb32SXin Li      # If we're not building shared, we need to use non_pic_objs
8654*a376eb32SXin Li      test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
8655*a376eb32SXin Li
8656*a376eb32SXin Li      # Create the old-style object.
8657*a376eb32SXin Li      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
8658*a376eb32SXin Li
8659*a376eb32SXin Li      output="$obj"
8660*a376eb32SXin Li      func_execute_cmds "$reload_cmds" 'exit $?'
8661*a376eb32SXin Li
8662*a376eb32SXin Li      # Exit if we aren't doing a library object file.
8663*a376eb32SXin Li      if test -z "$libobj"; then
8664*a376eb32SXin Li	if test -n "$gentop"; then
8665*a376eb32SXin Li	  func_show_eval '${RM}r "$gentop"'
8666*a376eb32SXin Li	fi
8667*a376eb32SXin Li
8668*a376eb32SXin Li	exit $EXIT_SUCCESS
8669*a376eb32SXin Li      fi
8670*a376eb32SXin Li
8671*a376eb32SXin Li      if test "$build_libtool_libs" != yes; then
8672*a376eb32SXin Li	if test -n "$gentop"; then
8673*a376eb32SXin Li	  func_show_eval '${RM}r "$gentop"'
8674*a376eb32SXin Li	fi
8675*a376eb32SXin Li
8676*a376eb32SXin Li	# Create an invalid libtool object if no PIC, so that we don't
8677*a376eb32SXin Li	# accidentally link it into a program.
8678*a376eb32SXin Li	# $show "echo timestamp > $libobj"
8679*a376eb32SXin Li	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
8680*a376eb32SXin Li	exit $EXIT_SUCCESS
8681*a376eb32SXin Li      fi
8682*a376eb32SXin Li
8683*a376eb32SXin Li      if test -n "$pic_flag" || test "$pic_mode" != default; then
8684*a376eb32SXin Li	# Only do commands if we really have different PIC objects.
8685*a376eb32SXin Li	reload_objs="$libobjs $reload_conv_objs"
8686*a376eb32SXin Li	output="$libobj"
8687*a376eb32SXin Li	func_execute_cmds "$reload_cmds" 'exit $?'
8688*a376eb32SXin Li      fi
8689*a376eb32SXin Li
8690*a376eb32SXin Li      if test -n "$gentop"; then
8691*a376eb32SXin Li	func_show_eval '${RM}r "$gentop"'
8692*a376eb32SXin Li      fi
8693*a376eb32SXin Li
8694*a376eb32SXin Li      exit $EXIT_SUCCESS
8695*a376eb32SXin Li      ;;
8696*a376eb32SXin Li
8697*a376eb32SXin Li    prog)
8698*a376eb32SXin Li      case $host in
8699*a376eb32SXin Li	*cygwin*) func_stripname '' '.exe' "$output"
8700*a376eb32SXin Li	          output=$func_stripname_result.exe;;
8701*a376eb32SXin Li      esac
8702*a376eb32SXin Li      test -n "$vinfo" && \
8703*a376eb32SXin Li	func_warning "\`-version-info' is ignored for programs"
8704*a376eb32SXin Li
8705*a376eb32SXin Li      test -n "$release" && \
8706*a376eb32SXin Li	func_warning "\`-release' is ignored for programs"
8707*a376eb32SXin Li
8708*a376eb32SXin Li      test "$preload" = yes \
8709*a376eb32SXin Li        && test "$dlopen_support" = unknown \
8710*a376eb32SXin Li	&& test "$dlopen_self" = unknown \
8711*a376eb32SXin Li	&& test "$dlopen_self_static" = unknown && \
8712*a376eb32SXin Li	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
8713*a376eb32SXin Li
8714*a376eb32SXin Li      case $host in
8715*a376eb32SXin Li      *-*-rhapsody* | *-*-darwin1.[012])
8716*a376eb32SXin Li	# On Rhapsody replace the C library is the System framework
8717*a376eb32SXin Li	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
8718*a376eb32SXin Li	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
8719*a376eb32SXin Li	;;
8720*a376eb32SXin Li      esac
8721*a376eb32SXin Li
8722*a376eb32SXin Li      case $host in
8723*a376eb32SXin Li      *-*-darwin*)
8724*a376eb32SXin Li	# Don't allow lazy linking, it breaks C++ global constructors
8725*a376eb32SXin Li	# But is supposedly fixed on 10.4 or later (yay!).
8726*a376eb32SXin Li	if test "$tagname" = CXX ; then
8727*a376eb32SXin Li	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
8728*a376eb32SXin Li	    10.[0123])
8729*a376eb32SXin Li	      func_append compile_command " ${wl}-bind_at_load"
8730*a376eb32SXin Li	      func_append finalize_command " ${wl}-bind_at_load"
8731*a376eb32SXin Li	    ;;
8732*a376eb32SXin Li	  esac
8733*a376eb32SXin Li	fi
8734*a376eb32SXin Li	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
8735*a376eb32SXin Li	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8736*a376eb32SXin Li	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8737*a376eb32SXin Li	;;
8738*a376eb32SXin Li      esac
8739*a376eb32SXin Li
8740*a376eb32SXin Li
8741*a376eb32SXin Li      # move library search paths that coincide with paths to not yet
8742*a376eb32SXin Li      # installed libraries to the beginning of the library search list
8743*a376eb32SXin Li      new_libs=
8744*a376eb32SXin Li      for path in $notinst_path; do
8745*a376eb32SXin Li	case " $new_libs " in
8746*a376eb32SXin Li	*" -L$path/$objdir "*) ;;
8747*a376eb32SXin Li	*)
8748*a376eb32SXin Li	  case " $compile_deplibs " in
8749*a376eb32SXin Li	  *" -L$path/$objdir "*)
8750*a376eb32SXin Li	    func_append new_libs " -L$path/$objdir" ;;
8751*a376eb32SXin Li	  esac
8752*a376eb32SXin Li	  ;;
8753*a376eb32SXin Li	esac
8754*a376eb32SXin Li      done
8755*a376eb32SXin Li      for deplib in $compile_deplibs; do
8756*a376eb32SXin Li	case $deplib in
8757*a376eb32SXin Li	-L*)
8758*a376eb32SXin Li	  case " $new_libs " in
8759*a376eb32SXin Li	  *" $deplib "*) ;;
8760*a376eb32SXin Li	  *) func_append new_libs " $deplib" ;;
8761*a376eb32SXin Li	  esac
8762*a376eb32SXin Li	  ;;
8763*a376eb32SXin Li	*) func_append new_libs " $deplib" ;;
8764*a376eb32SXin Li	esac
8765*a376eb32SXin Li      done
8766*a376eb32SXin Li      compile_deplibs="$new_libs"
8767*a376eb32SXin Li
8768*a376eb32SXin Li
8769*a376eb32SXin Li      func_append compile_command " $compile_deplibs"
8770*a376eb32SXin Li      func_append finalize_command " $finalize_deplibs"
8771*a376eb32SXin Li
8772*a376eb32SXin Li      if test -n "$rpath$xrpath"; then
8773*a376eb32SXin Li	# If the user specified any rpath flags, then add them.
8774*a376eb32SXin Li	for libdir in $rpath $xrpath; do
8775*a376eb32SXin Li	  # This is the magic to use -rpath.
8776*a376eb32SXin Li	  case "$finalize_rpath " in
8777*a376eb32SXin Li	  *" $libdir "*) ;;
8778*a376eb32SXin Li	  *) func_append finalize_rpath " $libdir" ;;
8779*a376eb32SXin Li	  esac
8780*a376eb32SXin Li	done
8781*a376eb32SXin Li      fi
8782*a376eb32SXin Li
8783*a376eb32SXin Li      # Now hardcode the library paths
8784*a376eb32SXin Li      rpath=
8785*a376eb32SXin Li      hardcode_libdirs=
8786*a376eb32SXin Li      for libdir in $compile_rpath $finalize_rpath; do
8787*a376eb32SXin Li	if test -n "$hardcode_libdir_flag_spec"; then
8788*a376eb32SXin Li	  if test -n "$hardcode_libdir_separator"; then
8789*a376eb32SXin Li	    if test -z "$hardcode_libdirs"; then
8790*a376eb32SXin Li	      hardcode_libdirs="$libdir"
8791*a376eb32SXin Li	    else
8792*a376eb32SXin Li	      # Just accumulate the unique libdirs.
8793*a376eb32SXin Li	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8794*a376eb32SXin Li	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8795*a376eb32SXin Li		;;
8796*a376eb32SXin Li	      *)
8797*a376eb32SXin Li		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8798*a376eb32SXin Li		;;
8799*a376eb32SXin Li	      esac
8800*a376eb32SXin Li	    fi
8801*a376eb32SXin Li	  else
8802*a376eb32SXin Li	    eval flag=\"$hardcode_libdir_flag_spec\"
8803*a376eb32SXin Li	    func_append rpath " $flag"
8804*a376eb32SXin Li	  fi
8805*a376eb32SXin Li	elif test -n "$runpath_var"; then
8806*a376eb32SXin Li	  case "$perm_rpath " in
8807*a376eb32SXin Li	  *" $libdir "*) ;;
8808*a376eb32SXin Li	  *) func_append perm_rpath " $libdir" ;;
8809*a376eb32SXin Li	  esac
8810*a376eb32SXin Li	fi
8811*a376eb32SXin Li	case $host in
8812*a376eb32SXin Li	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
8813*a376eb32SXin Li	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
8814*a376eb32SXin Li	  case :$dllsearchpath: in
8815*a376eb32SXin Li	  *":$libdir:"*) ;;
8816*a376eb32SXin Li	  ::) dllsearchpath=$libdir;;
8817*a376eb32SXin Li	  *) func_append dllsearchpath ":$libdir";;
8818*a376eb32SXin Li	  esac
8819*a376eb32SXin Li	  case :$dllsearchpath: in
8820*a376eb32SXin Li	  *":$testbindir:"*) ;;
8821*a376eb32SXin Li	  ::) dllsearchpath=$testbindir;;
8822*a376eb32SXin Li	  *) func_append dllsearchpath ":$testbindir";;
8823*a376eb32SXin Li	  esac
8824*a376eb32SXin Li	  ;;
8825*a376eb32SXin Li	esac
8826*a376eb32SXin Li      done
8827*a376eb32SXin Li      # Substitute the hardcoded libdirs into the rpath.
8828*a376eb32SXin Li      if test -n "$hardcode_libdir_separator" &&
8829*a376eb32SXin Li	 test -n "$hardcode_libdirs"; then
8830*a376eb32SXin Li	libdir="$hardcode_libdirs"
8831*a376eb32SXin Li	eval rpath=\" $hardcode_libdir_flag_spec\"
8832*a376eb32SXin Li      fi
8833*a376eb32SXin Li      compile_rpath="$rpath"
8834*a376eb32SXin Li
8835*a376eb32SXin Li      rpath=
8836*a376eb32SXin Li      hardcode_libdirs=
8837*a376eb32SXin Li      for libdir in $finalize_rpath; do
8838*a376eb32SXin Li	if test -n "$hardcode_libdir_flag_spec"; then
8839*a376eb32SXin Li	  if test -n "$hardcode_libdir_separator"; then
8840*a376eb32SXin Li	    if test -z "$hardcode_libdirs"; then
8841*a376eb32SXin Li	      hardcode_libdirs="$libdir"
8842*a376eb32SXin Li	    else
8843*a376eb32SXin Li	      # Just accumulate the unique libdirs.
8844*a376eb32SXin Li	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8845*a376eb32SXin Li	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8846*a376eb32SXin Li		;;
8847*a376eb32SXin Li	      *)
8848*a376eb32SXin Li		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8849*a376eb32SXin Li		;;
8850*a376eb32SXin Li	      esac
8851*a376eb32SXin Li	    fi
8852*a376eb32SXin Li	  else
8853*a376eb32SXin Li	    eval flag=\"$hardcode_libdir_flag_spec\"
8854*a376eb32SXin Li	    func_append rpath " $flag"
8855*a376eb32SXin Li	  fi
8856*a376eb32SXin Li	elif test -n "$runpath_var"; then
8857*a376eb32SXin Li	  case "$finalize_perm_rpath " in
8858*a376eb32SXin Li	  *" $libdir "*) ;;
8859*a376eb32SXin Li	  *) func_append finalize_perm_rpath " $libdir" ;;
8860*a376eb32SXin Li	  esac
8861*a376eb32SXin Li	fi
8862*a376eb32SXin Li      done
8863*a376eb32SXin Li      # Substitute the hardcoded libdirs into the rpath.
8864*a376eb32SXin Li      if test -n "$hardcode_libdir_separator" &&
8865*a376eb32SXin Li	 test -n "$hardcode_libdirs"; then
8866*a376eb32SXin Li	libdir="$hardcode_libdirs"
8867*a376eb32SXin Li	eval rpath=\" $hardcode_libdir_flag_spec\"
8868*a376eb32SXin Li      fi
8869*a376eb32SXin Li      finalize_rpath="$rpath"
8870*a376eb32SXin Li
8871*a376eb32SXin Li      if test -n "$libobjs" && test "$build_old_libs" = yes; then
8872*a376eb32SXin Li	# Transform all the library objects into standard objects.
8873*a376eb32SXin Li	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
8874*a376eb32SXin Li	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
8875*a376eb32SXin Li      fi
8876*a376eb32SXin Li
8877*a376eb32SXin Li      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
8878*a376eb32SXin Li
8879*a376eb32SXin Li      # template prelinking step
8880*a376eb32SXin Li      if test -n "$prelink_cmds"; then
8881*a376eb32SXin Li	func_execute_cmds "$prelink_cmds" 'exit $?'
8882*a376eb32SXin Li      fi
8883*a376eb32SXin Li
8884*a376eb32SXin Li      wrappers_required=yes
8885*a376eb32SXin Li      case $host in
8886*a376eb32SXin Li      *cegcc* | *mingw32ce*)
8887*a376eb32SXin Li        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
8888*a376eb32SXin Li        wrappers_required=no
8889*a376eb32SXin Li        ;;
8890*a376eb32SXin Li      *cygwin* | *mingw* )
8891*a376eb32SXin Li        if test "$build_libtool_libs" != yes; then
8892*a376eb32SXin Li          wrappers_required=no
8893*a376eb32SXin Li        fi
8894*a376eb32SXin Li        ;;
8895*a376eb32SXin Li      *)
8896*a376eb32SXin Li        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
8897*a376eb32SXin Li          wrappers_required=no
8898*a376eb32SXin Li        fi
8899*a376eb32SXin Li        ;;
8900*a376eb32SXin Li      esac
8901*a376eb32SXin Li      if test "$wrappers_required" = no; then
8902*a376eb32SXin Li	# Replace the output file specification.
8903*a376eb32SXin Li	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
8904*a376eb32SXin Li	link_command="$compile_command$compile_rpath"
8905*a376eb32SXin Li
8906*a376eb32SXin Li	# We have no uninstalled library dependencies, so finalize right now.
8907*a376eb32SXin Li	exit_status=0
8908*a376eb32SXin Li	func_show_eval "$link_command" 'exit_status=$?'
8909*a376eb32SXin Li
8910*a376eb32SXin Li	if test -n "$postlink_cmds"; then
8911*a376eb32SXin Li	  func_to_tool_file "$output"
8912*a376eb32SXin Li	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8913*a376eb32SXin Li	  func_execute_cmds "$postlink_cmds" 'exit $?'
8914*a376eb32SXin Li	fi
8915*a376eb32SXin Li
8916*a376eb32SXin Li	# Delete the generated files.
8917*a376eb32SXin Li	if test -f "$output_objdir/${outputname}S.${objext}"; then
8918*a376eb32SXin Li	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
8919*a376eb32SXin Li	fi
8920*a376eb32SXin Li
8921*a376eb32SXin Li	exit $exit_status
8922*a376eb32SXin Li      fi
8923*a376eb32SXin Li
8924*a376eb32SXin Li      if test -n "$compile_shlibpath$finalize_shlibpath"; then
8925*a376eb32SXin Li	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
8926*a376eb32SXin Li      fi
8927*a376eb32SXin Li      if test -n "$finalize_shlibpath"; then
8928*a376eb32SXin Li	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
8929*a376eb32SXin Li      fi
8930*a376eb32SXin Li
8931*a376eb32SXin Li      compile_var=
8932*a376eb32SXin Li      finalize_var=
8933*a376eb32SXin Li      if test -n "$runpath_var"; then
8934*a376eb32SXin Li	if test -n "$perm_rpath"; then
8935*a376eb32SXin Li	  # We should set the runpath_var.
8936*a376eb32SXin Li	  rpath=
8937*a376eb32SXin Li	  for dir in $perm_rpath; do
8938*a376eb32SXin Li	    func_append rpath "$dir:"
8939*a376eb32SXin Li	  done
8940*a376eb32SXin Li	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
8941*a376eb32SXin Li	fi
8942*a376eb32SXin Li	if test -n "$finalize_perm_rpath"; then
8943*a376eb32SXin Li	  # We should set the runpath_var.
8944*a376eb32SXin Li	  rpath=
8945*a376eb32SXin Li	  for dir in $finalize_perm_rpath; do
8946*a376eb32SXin Li	    func_append rpath "$dir:"
8947*a376eb32SXin Li	  done
8948*a376eb32SXin Li	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
8949*a376eb32SXin Li	fi
8950*a376eb32SXin Li      fi
8951*a376eb32SXin Li
8952*a376eb32SXin Li      if test "$no_install" = yes; then
8953*a376eb32SXin Li	# We don't need to create a wrapper script.
8954*a376eb32SXin Li	link_command="$compile_var$compile_command$compile_rpath"
8955*a376eb32SXin Li	# Replace the output file specification.
8956*a376eb32SXin Li	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
8957*a376eb32SXin Li	# Delete the old output file.
8958*a376eb32SXin Li	$opt_dry_run || $RM $output
8959*a376eb32SXin Li	# Link the executable and exit
8960*a376eb32SXin Li	func_show_eval "$link_command" 'exit $?'
8961*a376eb32SXin Li
8962*a376eb32SXin Li	if test -n "$postlink_cmds"; then
8963*a376eb32SXin Li	  func_to_tool_file "$output"
8964*a376eb32SXin Li	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8965*a376eb32SXin Li	  func_execute_cmds "$postlink_cmds" 'exit $?'
8966*a376eb32SXin Li	fi
8967*a376eb32SXin Li
8968*a376eb32SXin Li	exit $EXIT_SUCCESS
8969*a376eb32SXin Li      fi
8970*a376eb32SXin Li
8971*a376eb32SXin Li      if test "$hardcode_action" = relink; then
8972*a376eb32SXin Li	# Fast installation is not supported
8973*a376eb32SXin Li	link_command="$compile_var$compile_command$compile_rpath"
8974*a376eb32SXin Li	relink_command="$finalize_var$finalize_command$finalize_rpath"
8975*a376eb32SXin Li
8976*a376eb32SXin Li	func_warning "this platform does not like uninstalled shared libraries"
8977*a376eb32SXin Li	func_warning "\`$output' will be relinked during installation"
8978*a376eb32SXin Li      else
8979*a376eb32SXin Li	if test "$fast_install" != no; then
8980*a376eb32SXin Li	  link_command="$finalize_var$compile_command$finalize_rpath"
8981*a376eb32SXin Li	  if test "$fast_install" = yes; then
8982*a376eb32SXin Li	    relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
8983*a376eb32SXin Li	  else
8984*a376eb32SXin Li	    # fast_install is set to needless
8985*a376eb32SXin Li	    relink_command=
8986*a376eb32SXin Li	  fi
8987*a376eb32SXin Li	else
8988*a376eb32SXin Li	  link_command="$compile_var$compile_command$compile_rpath"
8989*a376eb32SXin Li	  relink_command="$finalize_var$finalize_command$finalize_rpath"
8990*a376eb32SXin Li	fi
8991*a376eb32SXin Li      fi
8992*a376eb32SXin Li
8993*a376eb32SXin Li      # Replace the output file specification.
8994*a376eb32SXin Li      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
8995*a376eb32SXin Li
8996*a376eb32SXin Li      # Delete the old output files.
8997*a376eb32SXin Li      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
8998*a376eb32SXin Li
8999*a376eb32SXin Li      func_show_eval "$link_command" 'exit $?'
9000*a376eb32SXin Li
9001*a376eb32SXin Li      if test -n "$postlink_cmds"; then
9002*a376eb32SXin Li	func_to_tool_file "$output_objdir/$outputname"
9003*a376eb32SXin Li	postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
9004*a376eb32SXin Li	func_execute_cmds "$postlink_cmds" 'exit $?'
9005*a376eb32SXin Li      fi
9006*a376eb32SXin Li
9007*a376eb32SXin Li      # Now create the wrapper script.
9008*a376eb32SXin Li      func_verbose "creating $output"
9009*a376eb32SXin Li
9010*a376eb32SXin Li      # Quote the relink command for shipping.
9011*a376eb32SXin Li      if test -n "$relink_command"; then
9012*a376eb32SXin Li	# Preserve any variables that may affect compiler behavior
9013*a376eb32SXin Li	for var in $variables_saved_for_relink; do
9014*a376eb32SXin Li	  if eval test -z \"\${$var+set}\"; then
9015*a376eb32SXin Li	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
9016*a376eb32SXin Li	  elif eval var_value=\$$var; test -z "$var_value"; then
9017*a376eb32SXin Li	    relink_command="$var=; export $var; $relink_command"
9018*a376eb32SXin Li	  else
9019*a376eb32SXin Li	    func_quote_for_eval "$var_value"
9020*a376eb32SXin Li	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9021*a376eb32SXin Li	  fi
9022*a376eb32SXin Li	done
9023*a376eb32SXin Li	relink_command="(cd `pwd`; $relink_command)"
9024*a376eb32SXin Li	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9025*a376eb32SXin Li      fi
9026*a376eb32SXin Li
9027*a376eb32SXin Li      # Only actually do things if not in dry run mode.
9028*a376eb32SXin Li      $opt_dry_run || {
9029*a376eb32SXin Li	# win32 will think the script is a binary if it has
9030*a376eb32SXin Li	# a .exe suffix, so we strip it off here.
9031*a376eb32SXin Li	case $output in
9032*a376eb32SXin Li	  *.exe) func_stripname '' '.exe' "$output"
9033*a376eb32SXin Li	         output=$func_stripname_result ;;
9034*a376eb32SXin Li	esac
9035*a376eb32SXin Li	# test for cygwin because mv fails w/o .exe extensions
9036*a376eb32SXin Li	case $host in
9037*a376eb32SXin Li	  *cygwin*)
9038*a376eb32SXin Li	    exeext=.exe
9039*a376eb32SXin Li	    func_stripname '' '.exe' "$outputname"
9040*a376eb32SXin Li	    outputname=$func_stripname_result ;;
9041*a376eb32SXin Li	  *) exeext= ;;
9042*a376eb32SXin Li	esac
9043*a376eb32SXin Li	case $host in
9044*a376eb32SXin Li	  *cygwin* | *mingw* )
9045*a376eb32SXin Li	    func_dirname_and_basename "$output" "" "."
9046*a376eb32SXin Li	    output_name=$func_basename_result
9047*a376eb32SXin Li	    output_path=$func_dirname_result
9048*a376eb32SXin Li	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
9049*a376eb32SXin Li	    cwrapper="$output_path/$output_name.exe"
9050*a376eb32SXin Li	    $RM $cwrappersource $cwrapper
9051*a376eb32SXin Li	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
9052*a376eb32SXin Li
9053*a376eb32SXin Li	    func_emit_cwrapperexe_src > $cwrappersource
9054*a376eb32SXin Li
9055*a376eb32SXin Li	    # The wrapper executable is built using the $host compiler,
9056*a376eb32SXin Li	    # because it contains $host paths and files. If cross-
9057*a376eb32SXin Li	    # compiling, it, like the target executable, must be
9058*a376eb32SXin Li	    # executed on the $host or under an emulation environment.
9059*a376eb32SXin Li	    $opt_dry_run || {
9060*a376eb32SXin Li	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
9061*a376eb32SXin Li	      $STRIP $cwrapper
9062*a376eb32SXin Li	    }
9063*a376eb32SXin Li
9064*a376eb32SXin Li	    # Now, create the wrapper script for func_source use:
9065*a376eb32SXin Li	    func_ltwrapper_scriptname $cwrapper
9066*a376eb32SXin Li	    $RM $func_ltwrapper_scriptname_result
9067*a376eb32SXin Li	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
9068*a376eb32SXin Li	    $opt_dry_run || {
9069*a376eb32SXin Li	      # note: this script will not be executed, so do not chmod.
9070*a376eb32SXin Li	      if test "x$build" = "x$host" ; then
9071*a376eb32SXin Li		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
9072*a376eb32SXin Li	      else
9073*a376eb32SXin Li		func_emit_wrapper no > $func_ltwrapper_scriptname_result
9074*a376eb32SXin Li	      fi
9075*a376eb32SXin Li	    }
9076*a376eb32SXin Li	  ;;
9077*a376eb32SXin Li	  * )
9078*a376eb32SXin Li	    $RM $output
9079*a376eb32SXin Li	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
9080*a376eb32SXin Li
9081*a376eb32SXin Li	    func_emit_wrapper no > $output
9082*a376eb32SXin Li	    chmod +x $output
9083*a376eb32SXin Li	  ;;
9084*a376eb32SXin Li	esac
9085*a376eb32SXin Li      }
9086*a376eb32SXin Li      exit $EXIT_SUCCESS
9087*a376eb32SXin Li      ;;
9088*a376eb32SXin Li    esac
9089*a376eb32SXin Li
9090*a376eb32SXin Li    # See if we need to build an old-fashioned archive.
9091*a376eb32SXin Li    for oldlib in $oldlibs; do
9092*a376eb32SXin Li
9093*a376eb32SXin Li      if test "$build_libtool_libs" = convenience; then
9094*a376eb32SXin Li	oldobjs="$libobjs_save $symfileobj"
9095*a376eb32SXin Li	addlibs="$convenience"
9096*a376eb32SXin Li	build_libtool_libs=no
9097*a376eb32SXin Li      else
9098*a376eb32SXin Li	if test "$build_libtool_libs" = module; then
9099*a376eb32SXin Li	  oldobjs="$libobjs_save"
9100*a376eb32SXin Li	  build_libtool_libs=no
9101*a376eb32SXin Li	else
9102*a376eb32SXin Li	  oldobjs="$old_deplibs $non_pic_objects"
9103*a376eb32SXin Li	  if test "$preload" = yes && test -f "$symfileobj"; then
9104*a376eb32SXin Li	    func_append oldobjs " $symfileobj"
9105*a376eb32SXin Li	  fi
9106*a376eb32SXin Li	fi
9107*a376eb32SXin Li	addlibs="$old_convenience"
9108*a376eb32SXin Li      fi
9109*a376eb32SXin Li
9110*a376eb32SXin Li      if test -n "$addlibs"; then
9111*a376eb32SXin Li	gentop="$output_objdir/${outputname}x"
9112*a376eb32SXin Li	func_append generated " $gentop"
9113*a376eb32SXin Li
9114*a376eb32SXin Li	func_extract_archives $gentop $addlibs
9115*a376eb32SXin Li	func_append oldobjs " $func_extract_archives_result"
9116*a376eb32SXin Li      fi
9117*a376eb32SXin Li
9118*a376eb32SXin Li      # Do each command in the archive commands.
9119*a376eb32SXin Li      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
9120*a376eb32SXin Li	cmds=$old_archive_from_new_cmds
9121*a376eb32SXin Li      else
9122*a376eb32SXin Li
9123*a376eb32SXin Li	# Add any objects from preloaded convenience libraries
9124*a376eb32SXin Li	if test -n "$dlprefiles"; then
9125*a376eb32SXin Li	  gentop="$output_objdir/${outputname}x"
9126*a376eb32SXin Li	  func_append generated " $gentop"
9127*a376eb32SXin Li
9128*a376eb32SXin Li	  func_extract_archives $gentop $dlprefiles
9129*a376eb32SXin Li	  func_append oldobjs " $func_extract_archives_result"
9130*a376eb32SXin Li	fi
9131*a376eb32SXin Li
9132*a376eb32SXin Li	# POSIX demands no paths to be encoded in archives.  We have
9133*a376eb32SXin Li	# to avoid creating archives with duplicate basenames if we
9134*a376eb32SXin Li	# might have to extract them afterwards, e.g., when creating a
9135*a376eb32SXin Li	# static archive out of a convenience library, or when linking
9136*a376eb32SXin Li	# the entirety of a libtool archive into another (currently
9137*a376eb32SXin Li	# not supported by libtool).
9138*a376eb32SXin Li	if (for obj in $oldobjs
9139*a376eb32SXin Li	    do
9140*a376eb32SXin Li	      func_basename "$obj"
9141*a376eb32SXin Li	      $ECHO "$func_basename_result"
9142*a376eb32SXin Li	    done | sort | sort -uc >/dev/null 2>&1); then
9143*a376eb32SXin Li	  :
9144*a376eb32SXin Li	else
9145*a376eb32SXin Li	  echo "copying selected object files to avoid basename conflicts..."
9146*a376eb32SXin Li	  gentop="$output_objdir/${outputname}x"
9147*a376eb32SXin Li	  func_append generated " $gentop"
9148*a376eb32SXin Li	  func_mkdir_p "$gentop"
9149*a376eb32SXin Li	  save_oldobjs=$oldobjs
9150*a376eb32SXin Li	  oldobjs=
9151*a376eb32SXin Li	  counter=1
9152*a376eb32SXin Li	  for obj in $save_oldobjs
9153*a376eb32SXin Li	  do
9154*a376eb32SXin Li	    func_basename "$obj"
9155*a376eb32SXin Li	    objbase="$func_basename_result"
9156*a376eb32SXin Li	    case " $oldobjs " in
9157*a376eb32SXin Li	    " ") oldobjs=$obj ;;
9158*a376eb32SXin Li	    *[\ /]"$objbase "*)
9159*a376eb32SXin Li	      while :; do
9160*a376eb32SXin Li		# Make sure we don't pick an alternate name that also
9161*a376eb32SXin Li		# overlaps.
9162*a376eb32SXin Li		newobj=lt$counter-$objbase
9163*a376eb32SXin Li		func_arith $counter + 1
9164*a376eb32SXin Li		counter=$func_arith_result
9165*a376eb32SXin Li		case " $oldobjs " in
9166*a376eb32SXin Li		*[\ /]"$newobj "*) ;;
9167*a376eb32SXin Li		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
9168*a376eb32SXin Li		esac
9169*a376eb32SXin Li	      done
9170*a376eb32SXin Li	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
9171*a376eb32SXin Li	      func_append oldobjs " $gentop/$newobj"
9172*a376eb32SXin Li	      ;;
9173*a376eb32SXin Li	    *) func_append oldobjs " $obj" ;;
9174*a376eb32SXin Li	    esac
9175*a376eb32SXin Li	  done
9176*a376eb32SXin Li	fi
9177*a376eb32SXin Li	func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
9178*a376eb32SXin Li	tool_oldlib=$func_to_tool_file_result
9179*a376eb32SXin Li	eval cmds=\"$old_archive_cmds\"
9180*a376eb32SXin Li
9181*a376eb32SXin Li	func_len " $cmds"
9182*a376eb32SXin Li	len=$func_len_result
9183*a376eb32SXin Li	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
9184*a376eb32SXin Li	  cmds=$old_archive_cmds
9185*a376eb32SXin Li	elif test -n "$archiver_list_spec"; then
9186*a376eb32SXin Li	  func_verbose "using command file archive linking..."
9187*a376eb32SXin Li	  for obj in $oldobjs
9188*a376eb32SXin Li	  do
9189*a376eb32SXin Li	    func_to_tool_file "$obj"
9190*a376eb32SXin Li	    $ECHO "$func_to_tool_file_result"
9191*a376eb32SXin Li	  done > $output_objdir/$libname.libcmd
9192*a376eb32SXin Li	  func_to_tool_file "$output_objdir/$libname.libcmd"
9193*a376eb32SXin Li	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
9194*a376eb32SXin Li	  cmds=$old_archive_cmds
9195*a376eb32SXin Li	else
9196*a376eb32SXin Li	  # the command line is too long to link in one step, link in parts
9197*a376eb32SXin Li	  func_verbose "using piecewise archive linking..."
9198*a376eb32SXin Li	  save_RANLIB=$RANLIB
9199*a376eb32SXin Li	  RANLIB=:
9200*a376eb32SXin Li	  objlist=
9201*a376eb32SXin Li	  concat_cmds=
9202*a376eb32SXin Li	  save_oldobjs=$oldobjs
9203*a376eb32SXin Li	  oldobjs=
9204*a376eb32SXin Li	  # Is there a better way of finding the last object in the list?
9205*a376eb32SXin Li	  for obj in $save_oldobjs
9206*a376eb32SXin Li	  do
9207*a376eb32SXin Li	    last_oldobj=$obj
9208*a376eb32SXin Li	  done
9209*a376eb32SXin Li	  eval test_cmds=\"$old_archive_cmds\"
9210*a376eb32SXin Li	  func_len " $test_cmds"
9211*a376eb32SXin Li	  len0=$func_len_result
9212*a376eb32SXin Li	  len=$len0
9213*a376eb32SXin Li	  for obj in $save_oldobjs
9214*a376eb32SXin Li	  do
9215*a376eb32SXin Li	    func_len " $obj"
9216*a376eb32SXin Li	    func_arith $len + $func_len_result
9217*a376eb32SXin Li	    len=$func_arith_result
9218*a376eb32SXin Li	    func_append objlist " $obj"
9219*a376eb32SXin Li	    if test "$len" -lt "$max_cmd_len"; then
9220*a376eb32SXin Li	      :
9221*a376eb32SXin Li	    else
9222*a376eb32SXin Li	      # the above command should be used before it gets too long
9223*a376eb32SXin Li	      oldobjs=$objlist
9224*a376eb32SXin Li	      if test "$obj" = "$last_oldobj" ; then
9225*a376eb32SXin Li		RANLIB=$save_RANLIB
9226*a376eb32SXin Li	      fi
9227*a376eb32SXin Li	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9228*a376eb32SXin Li	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
9229*a376eb32SXin Li	      objlist=
9230*a376eb32SXin Li	      len=$len0
9231*a376eb32SXin Li	    fi
9232*a376eb32SXin Li	  done
9233*a376eb32SXin Li	  RANLIB=$save_RANLIB
9234*a376eb32SXin Li	  oldobjs=$objlist
9235*a376eb32SXin Li	  if test "X$oldobjs" = "X" ; then
9236*a376eb32SXin Li	    eval cmds=\"\$concat_cmds\"
9237*a376eb32SXin Li	  else
9238*a376eb32SXin Li	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
9239*a376eb32SXin Li	  fi
9240*a376eb32SXin Li	fi
9241*a376eb32SXin Li      fi
9242*a376eb32SXin Li      func_execute_cmds "$cmds" 'exit $?'
9243*a376eb32SXin Li    done
9244*a376eb32SXin Li
9245*a376eb32SXin Li    test -n "$generated" && \
9246*a376eb32SXin Li      func_show_eval "${RM}r$generated"
9247*a376eb32SXin Li
9248*a376eb32SXin Li    # Now create the libtool archive.
9249*a376eb32SXin Li    case $output in
9250*a376eb32SXin Li    *.la)
9251*a376eb32SXin Li      old_library=
9252*a376eb32SXin Li      test "$build_old_libs" = yes && old_library="$libname.$libext"
9253*a376eb32SXin Li      func_verbose "creating $output"
9254*a376eb32SXin Li
9255*a376eb32SXin Li      # Preserve any variables that may affect compiler behavior
9256*a376eb32SXin Li      for var in $variables_saved_for_relink; do
9257*a376eb32SXin Li	if eval test -z \"\${$var+set}\"; then
9258*a376eb32SXin Li	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
9259*a376eb32SXin Li	elif eval var_value=\$$var; test -z "$var_value"; then
9260*a376eb32SXin Li	  relink_command="$var=; export $var; $relink_command"
9261*a376eb32SXin Li	else
9262*a376eb32SXin Li	  func_quote_for_eval "$var_value"
9263*a376eb32SXin Li	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9264*a376eb32SXin Li	fi
9265*a376eb32SXin Li      done
9266*a376eb32SXin Li      # Quote the link command for shipping.
9267*a376eb32SXin Li      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
9268*a376eb32SXin Li      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9269*a376eb32SXin Li      if test "$hardcode_automatic" = yes ; then
9270*a376eb32SXin Li	relink_command=
9271*a376eb32SXin Li      fi
9272*a376eb32SXin Li
9273*a376eb32SXin Li      # Only create the output if not a dry run.
9274*a376eb32SXin Li      $opt_dry_run || {
9275*a376eb32SXin Li	for installed in no yes; do
9276*a376eb32SXin Li	  if test "$installed" = yes; then
9277*a376eb32SXin Li	    if test -z "$install_libdir"; then
9278*a376eb32SXin Li	      break
9279*a376eb32SXin Li	    fi
9280*a376eb32SXin Li	    output="$output_objdir/$outputname"i
9281*a376eb32SXin Li	    # Replace all uninstalled libtool libraries with the installed ones
9282*a376eb32SXin Li	    newdependency_libs=
9283*a376eb32SXin Li	    for deplib in $dependency_libs; do
9284*a376eb32SXin Li	      case $deplib in
9285*a376eb32SXin Li	      *.la)
9286*a376eb32SXin Li		func_basename "$deplib"
9287*a376eb32SXin Li		name="$func_basename_result"
9288*a376eb32SXin Li		func_resolve_sysroot "$deplib"
9289*a376eb32SXin Li		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
9290*a376eb32SXin Li		test -z "$libdir" && \
9291*a376eb32SXin Li		  func_fatal_error "\`$deplib' is not a valid libtool archive"
9292*a376eb32SXin Li		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
9293*a376eb32SXin Li		;;
9294*a376eb32SXin Li	      -L*)
9295*a376eb32SXin Li		func_stripname -L '' "$deplib"
9296*a376eb32SXin Li		func_replace_sysroot "$func_stripname_result"
9297*a376eb32SXin Li		func_append newdependency_libs " -L$func_replace_sysroot_result"
9298*a376eb32SXin Li		;;
9299*a376eb32SXin Li	      -R*)
9300*a376eb32SXin Li		func_stripname -R '' "$deplib"
9301*a376eb32SXin Li		func_replace_sysroot "$func_stripname_result"
9302*a376eb32SXin Li		func_append newdependency_libs " -R$func_replace_sysroot_result"
9303*a376eb32SXin Li		;;
9304*a376eb32SXin Li	      *) func_append newdependency_libs " $deplib" ;;
9305*a376eb32SXin Li	      esac
9306*a376eb32SXin Li	    done
9307*a376eb32SXin Li	    dependency_libs="$newdependency_libs"
9308*a376eb32SXin Li	    newdlfiles=
9309*a376eb32SXin Li
9310*a376eb32SXin Li	    for lib in $dlfiles; do
9311*a376eb32SXin Li	      case $lib in
9312*a376eb32SXin Li	      *.la)
9313*a376eb32SXin Li	        func_basename "$lib"
9314*a376eb32SXin Li		name="$func_basename_result"
9315*a376eb32SXin Li		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9316*a376eb32SXin Li		test -z "$libdir" && \
9317*a376eb32SXin Li		  func_fatal_error "\`$lib' is not a valid libtool archive"
9318*a376eb32SXin Li		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
9319*a376eb32SXin Li		;;
9320*a376eb32SXin Li	      *) func_append newdlfiles " $lib" ;;
9321*a376eb32SXin Li	      esac
9322*a376eb32SXin Li	    done
9323*a376eb32SXin Li	    dlfiles="$newdlfiles"
9324*a376eb32SXin Li	    newdlprefiles=
9325*a376eb32SXin Li	    for lib in $dlprefiles; do
9326*a376eb32SXin Li	      case $lib in
9327*a376eb32SXin Li	      *.la)
9328*a376eb32SXin Li		# Only pass preopened files to the pseudo-archive (for
9329*a376eb32SXin Li		# eventual linking with the app. that links it) if we
9330*a376eb32SXin Li		# didn't already link the preopened objects directly into
9331*a376eb32SXin Li		# the library:
9332*a376eb32SXin Li		func_basename "$lib"
9333*a376eb32SXin Li		name="$func_basename_result"
9334*a376eb32SXin Li		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9335*a376eb32SXin Li		test -z "$libdir" && \
9336*a376eb32SXin Li		  func_fatal_error "\`$lib' is not a valid libtool archive"
9337*a376eb32SXin Li		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
9338*a376eb32SXin Li		;;
9339*a376eb32SXin Li	      esac
9340*a376eb32SXin Li	    done
9341*a376eb32SXin Li	    dlprefiles="$newdlprefiles"
9342*a376eb32SXin Li	  else
9343*a376eb32SXin Li	    newdlfiles=
9344*a376eb32SXin Li	    for lib in $dlfiles; do
9345*a376eb32SXin Li	      case $lib in
9346*a376eb32SXin Li		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9347*a376eb32SXin Li		*) abs=`pwd`"/$lib" ;;
9348*a376eb32SXin Li	      esac
9349*a376eb32SXin Li	      func_append newdlfiles " $abs"
9350*a376eb32SXin Li	    done
9351*a376eb32SXin Li	    dlfiles="$newdlfiles"
9352*a376eb32SXin Li	    newdlprefiles=
9353*a376eb32SXin Li	    for lib in $dlprefiles; do
9354*a376eb32SXin Li	      case $lib in
9355*a376eb32SXin Li		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9356*a376eb32SXin Li		*) abs=`pwd`"/$lib" ;;
9357*a376eb32SXin Li	      esac
9358*a376eb32SXin Li	      func_append newdlprefiles " $abs"
9359*a376eb32SXin Li	    done
9360*a376eb32SXin Li	    dlprefiles="$newdlprefiles"
9361*a376eb32SXin Li	  fi
9362*a376eb32SXin Li	  $RM $output
9363*a376eb32SXin Li	  # place dlname in correct position for cygwin
9364*a376eb32SXin Li	  # In fact, it would be nice if we could use this code for all target
9365*a376eb32SXin Li	  # systems that can't hard-code library paths into their executables
9366*a376eb32SXin Li	  # and that have no shared library path variable independent of PATH,
9367*a376eb32SXin Li	  # but it turns out we can't easily determine that from inspecting
9368*a376eb32SXin Li	  # libtool variables, so we have to hard-code the OSs to which it
9369*a376eb32SXin Li	  # applies here; at the moment, that means platforms that use the PE
9370*a376eb32SXin Li	  # object format with DLL files.  See the long comment at the top of
9371*a376eb32SXin Li	  # tests/bindir.at for full details.
9372*a376eb32SXin Li	  tdlname=$dlname
9373*a376eb32SXin Li	  case $host,$output,$installed,$module,$dlname in
9374*a376eb32SXin Li	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
9375*a376eb32SXin Li	      # If a -bindir argument was supplied, place the dll there.
9376*a376eb32SXin Li	      if test "x$bindir" != x ;
9377*a376eb32SXin Li	      then
9378*a376eb32SXin Li		func_relative_path "$install_libdir" "$bindir"
9379*a376eb32SXin Li		tdlname=$func_relative_path_result$dlname
9380*a376eb32SXin Li	      else
9381*a376eb32SXin Li		# Otherwise fall back on heuristic.
9382*a376eb32SXin Li		tdlname=../bin/$dlname
9383*a376eb32SXin Li	      fi
9384*a376eb32SXin Li	      ;;
9385*a376eb32SXin Li	  esac
9386*a376eb32SXin Li	  $ECHO > $output "\
9387*a376eb32SXin Li# $outputname - a libtool library file
9388*a376eb32SXin Li# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
9389*a376eb32SXin Li#
9390*a376eb32SXin Li# Please DO NOT delete this file!
9391*a376eb32SXin Li# It is necessary for linking the library.
9392*a376eb32SXin Li
9393*a376eb32SXin Li# The name that we can dlopen(3).
9394*a376eb32SXin Lidlname='$tdlname'
9395*a376eb32SXin Li
9396*a376eb32SXin Li# Names of this library.
9397*a376eb32SXin Lilibrary_names='$library_names'
9398*a376eb32SXin Li
9399*a376eb32SXin Li# The name of the static archive.
9400*a376eb32SXin Liold_library='$old_library'
9401*a376eb32SXin Li
9402*a376eb32SXin Li# Linker flags that can not go in dependency_libs.
9403*a376eb32SXin Liinherited_linker_flags='$new_inherited_linker_flags'
9404*a376eb32SXin Li
9405*a376eb32SXin Li# Libraries that this one depends upon.
9406*a376eb32SXin Lidependency_libs='$dependency_libs'
9407*a376eb32SXin Li
9408*a376eb32SXin Li# Names of additional weak libraries provided by this library
9409*a376eb32SXin Liweak_library_names='$weak_libs'
9410*a376eb32SXin Li
9411*a376eb32SXin Li# Version information for $libname.
9412*a376eb32SXin Licurrent=$current
9413*a376eb32SXin Liage=$age
9414*a376eb32SXin Lirevision=$revision
9415*a376eb32SXin Li
9416*a376eb32SXin Li# Is this an already installed library?
9417*a376eb32SXin Liinstalled=$installed
9418*a376eb32SXin Li
9419*a376eb32SXin Li# Should we warn about portability when linking against -modules?
9420*a376eb32SXin Lishouldnotlink=$module
9421*a376eb32SXin Li
9422*a376eb32SXin Li# Files to dlopen/dlpreopen
9423*a376eb32SXin Lidlopen='$dlfiles'
9424*a376eb32SXin Lidlpreopen='$dlprefiles'
9425*a376eb32SXin Li
9426*a376eb32SXin Li# Directory that this library needs to be installed in:
9427*a376eb32SXin Lilibdir='$install_libdir'"
9428*a376eb32SXin Li	  if test "$installed" = no && test "$need_relink" = yes; then
9429*a376eb32SXin Li	    $ECHO >> $output "\
9430*a376eb32SXin Lirelink_command=\"$relink_command\""
9431*a376eb32SXin Li	  fi
9432*a376eb32SXin Li	done
9433*a376eb32SXin Li      }
9434*a376eb32SXin Li
9435*a376eb32SXin Li      # Do a symbolic link so that the libtool archive can be found in
9436*a376eb32SXin Li      # LD_LIBRARY_PATH before the program is installed.
9437*a376eb32SXin Li      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
9438*a376eb32SXin Li      ;;
9439*a376eb32SXin Li    esac
9440*a376eb32SXin Li    exit $EXIT_SUCCESS
9441*a376eb32SXin Li}
9442*a376eb32SXin Li
9443*a376eb32SXin Li{ test "$opt_mode" = link || test "$opt_mode" = relink; } &&
9444*a376eb32SXin Li    func_mode_link ${1+"$@"}
9445*a376eb32SXin Li
9446*a376eb32SXin Li
9447*a376eb32SXin Li# func_mode_uninstall arg...
9448*a376eb32SXin Lifunc_mode_uninstall ()
9449*a376eb32SXin Li{
9450*a376eb32SXin Li    $opt_debug
9451*a376eb32SXin Li    RM="$nonopt"
9452*a376eb32SXin Li    files=
9453*a376eb32SXin Li    rmforce=
9454*a376eb32SXin Li    exit_status=0
9455*a376eb32SXin Li
9456*a376eb32SXin Li    # This variable tells wrapper scripts just to set variables rather
9457*a376eb32SXin Li    # than running their programs.
9458*a376eb32SXin Li    libtool_install_magic="$magic"
9459*a376eb32SXin Li
9460*a376eb32SXin Li    for arg
9461*a376eb32SXin Li    do
9462*a376eb32SXin Li      case $arg in
9463*a376eb32SXin Li      -f) func_append RM " $arg"; rmforce=yes ;;
9464*a376eb32SXin Li      -*) func_append RM " $arg" ;;
9465*a376eb32SXin Li      *) func_append files " $arg" ;;
9466*a376eb32SXin Li      esac
9467*a376eb32SXin Li    done
9468*a376eb32SXin Li
9469*a376eb32SXin Li    test -z "$RM" && \
9470*a376eb32SXin Li      func_fatal_help "you must specify an RM program"
9471*a376eb32SXin Li
9472*a376eb32SXin Li    rmdirs=
9473*a376eb32SXin Li
9474*a376eb32SXin Li    for file in $files; do
9475*a376eb32SXin Li      func_dirname "$file" "" "."
9476*a376eb32SXin Li      dir="$func_dirname_result"
9477*a376eb32SXin Li      if test "X$dir" = X.; then
9478*a376eb32SXin Li	odir="$objdir"
9479*a376eb32SXin Li      else
9480*a376eb32SXin Li	odir="$dir/$objdir"
9481*a376eb32SXin Li      fi
9482*a376eb32SXin Li      func_basename "$file"
9483*a376eb32SXin Li      name="$func_basename_result"
9484*a376eb32SXin Li      test "$opt_mode" = uninstall && odir="$dir"
9485*a376eb32SXin Li
9486*a376eb32SXin Li      # Remember odir for removal later, being careful to avoid duplicates
9487*a376eb32SXin Li      if test "$opt_mode" = clean; then
9488*a376eb32SXin Li	case " $rmdirs " in
9489*a376eb32SXin Li	  *" $odir "*) ;;
9490*a376eb32SXin Li	  *) func_append rmdirs " $odir" ;;
9491*a376eb32SXin Li	esac
9492*a376eb32SXin Li      fi
9493*a376eb32SXin Li
9494*a376eb32SXin Li      # Don't error if the file doesn't exist and rm -f was used.
9495*a376eb32SXin Li      if { test -L "$file"; } >/dev/null 2>&1 ||
9496*a376eb32SXin Li	 { test -h "$file"; } >/dev/null 2>&1 ||
9497*a376eb32SXin Li	 test -f "$file"; then
9498*a376eb32SXin Li	:
9499*a376eb32SXin Li      elif test -d "$file"; then
9500*a376eb32SXin Li	exit_status=1
9501*a376eb32SXin Li	continue
9502*a376eb32SXin Li      elif test "$rmforce" = yes; then
9503*a376eb32SXin Li	continue
9504*a376eb32SXin Li      fi
9505*a376eb32SXin Li
9506*a376eb32SXin Li      rmfiles="$file"
9507*a376eb32SXin Li
9508*a376eb32SXin Li      case $name in
9509*a376eb32SXin Li      *.la)
9510*a376eb32SXin Li	# Possibly a libtool archive, so verify it.
9511*a376eb32SXin Li	if func_lalib_p "$file"; then
9512*a376eb32SXin Li	  func_source $dir/$name
9513*a376eb32SXin Li
9514*a376eb32SXin Li	  # Delete the libtool libraries and symlinks.
9515*a376eb32SXin Li	  for n in $library_names; do
9516*a376eb32SXin Li	    func_append rmfiles " $odir/$n"
9517*a376eb32SXin Li	  done
9518*a376eb32SXin Li	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
9519*a376eb32SXin Li
9520*a376eb32SXin Li	  case "$opt_mode" in
9521*a376eb32SXin Li	  clean)
9522*a376eb32SXin Li	    case " $library_names " in
9523*a376eb32SXin Li	    *" $dlname "*) ;;
9524*a376eb32SXin Li	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
9525*a376eb32SXin Li	    esac
9526*a376eb32SXin Li	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
9527*a376eb32SXin Li	    ;;
9528*a376eb32SXin Li	  uninstall)
9529*a376eb32SXin Li	    if test -n "$library_names"; then
9530*a376eb32SXin Li	      # Do each command in the postuninstall commands.
9531*a376eb32SXin Li	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
9532*a376eb32SXin Li	    fi
9533*a376eb32SXin Li
9534*a376eb32SXin Li	    if test -n "$old_library"; then
9535*a376eb32SXin Li	      # Do each command in the old_postuninstall commands.
9536*a376eb32SXin Li	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
9537*a376eb32SXin Li	    fi
9538*a376eb32SXin Li	    # FIXME: should reinstall the best remaining shared library.
9539*a376eb32SXin Li	    ;;
9540*a376eb32SXin Li	  esac
9541*a376eb32SXin Li	fi
9542*a376eb32SXin Li	;;
9543*a376eb32SXin Li
9544*a376eb32SXin Li      *.lo)
9545*a376eb32SXin Li	# Possibly a libtool object, so verify it.
9546*a376eb32SXin Li	if func_lalib_p "$file"; then
9547*a376eb32SXin Li
9548*a376eb32SXin Li	  # Read the .lo file
9549*a376eb32SXin Li	  func_source $dir/$name
9550*a376eb32SXin Li
9551*a376eb32SXin Li	  # Add PIC object to the list of files to remove.
9552*a376eb32SXin Li	  if test -n "$pic_object" &&
9553*a376eb32SXin Li	     test "$pic_object" != none; then
9554*a376eb32SXin Li	    func_append rmfiles " $dir/$pic_object"
9555*a376eb32SXin Li	  fi
9556*a376eb32SXin Li
9557*a376eb32SXin Li	  # Add non-PIC object to the list of files to remove.
9558*a376eb32SXin Li	  if test -n "$non_pic_object" &&
9559*a376eb32SXin Li	     test "$non_pic_object" != none; then
9560*a376eb32SXin Li	    func_append rmfiles " $dir/$non_pic_object"
9561*a376eb32SXin Li	  fi
9562*a376eb32SXin Li	fi
9563*a376eb32SXin Li	;;
9564*a376eb32SXin Li
9565*a376eb32SXin Li      *)
9566*a376eb32SXin Li	if test "$opt_mode" = clean ; then
9567*a376eb32SXin Li	  noexename=$name
9568*a376eb32SXin Li	  case $file in
9569*a376eb32SXin Li	  *.exe)
9570*a376eb32SXin Li	    func_stripname '' '.exe' "$file"
9571*a376eb32SXin Li	    file=$func_stripname_result
9572*a376eb32SXin Li	    func_stripname '' '.exe' "$name"
9573*a376eb32SXin Li	    noexename=$func_stripname_result
9574*a376eb32SXin Li	    # $file with .exe has already been added to rmfiles,
9575*a376eb32SXin Li	    # add $file without .exe
9576*a376eb32SXin Li	    func_append rmfiles " $file"
9577*a376eb32SXin Li	    ;;
9578*a376eb32SXin Li	  esac
9579*a376eb32SXin Li	  # Do a test to see if this is a libtool program.
9580*a376eb32SXin Li	  if func_ltwrapper_p "$file"; then
9581*a376eb32SXin Li	    if func_ltwrapper_executable_p "$file"; then
9582*a376eb32SXin Li	      func_ltwrapper_scriptname "$file"
9583*a376eb32SXin Li	      relink_command=
9584*a376eb32SXin Li	      func_source $func_ltwrapper_scriptname_result
9585*a376eb32SXin Li	      func_append rmfiles " $func_ltwrapper_scriptname_result"
9586*a376eb32SXin Li	    else
9587*a376eb32SXin Li	      relink_command=
9588*a376eb32SXin Li	      func_source $dir/$noexename
9589*a376eb32SXin Li	    fi
9590*a376eb32SXin Li
9591*a376eb32SXin Li	    # note $name still contains .exe if it was in $file originally
9592*a376eb32SXin Li	    # as does the version of $file that was added into $rmfiles
9593*a376eb32SXin Li	    func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
9594*a376eb32SXin Li	    if test "$fast_install" = yes && test -n "$relink_command"; then
9595*a376eb32SXin Li	      func_append rmfiles " $odir/lt-$name"
9596*a376eb32SXin Li	    fi
9597*a376eb32SXin Li	    if test "X$noexename" != "X$name" ; then
9598*a376eb32SXin Li	      func_append rmfiles " $odir/lt-${noexename}.c"
9599*a376eb32SXin Li	    fi
9600*a376eb32SXin Li	  fi
9601*a376eb32SXin Li	fi
9602*a376eb32SXin Li	;;
9603*a376eb32SXin Li      esac
9604*a376eb32SXin Li      func_show_eval "$RM $rmfiles" 'exit_status=1'
9605*a376eb32SXin Li    done
9606*a376eb32SXin Li
9607*a376eb32SXin Li    # Try to remove the ${objdir}s in the directories where we deleted files
9608*a376eb32SXin Li    for dir in $rmdirs; do
9609*a376eb32SXin Li      if test -d "$dir"; then
9610*a376eb32SXin Li	func_show_eval "rmdir $dir >/dev/null 2>&1"
9611*a376eb32SXin Li      fi
9612*a376eb32SXin Li    done
9613*a376eb32SXin Li
9614*a376eb32SXin Li    exit $exit_status
9615*a376eb32SXin Li}
9616*a376eb32SXin Li
9617*a376eb32SXin Li{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
9618*a376eb32SXin Li    func_mode_uninstall ${1+"$@"}
9619*a376eb32SXin Li
9620*a376eb32SXin Litest -z "$opt_mode" && {
9621*a376eb32SXin Li  help="$generic_help"
9622*a376eb32SXin Li  func_fatal_help "you must specify a MODE"
9623*a376eb32SXin Li}
9624*a376eb32SXin Li
9625*a376eb32SXin Litest -z "$exec_cmd" && \
9626*a376eb32SXin Li  func_fatal_help "invalid operation mode \`$opt_mode'"
9627*a376eb32SXin Li
9628*a376eb32SXin Liif test -n "$exec_cmd"; then
9629*a376eb32SXin Li  eval exec "$exec_cmd"
9630*a376eb32SXin Li  exit $EXIT_FAILURE
9631*a376eb32SXin Lifi
9632*a376eb32SXin Li
9633*a376eb32SXin Liexit $exit_status
9634*a376eb32SXin Li
9635*a376eb32SXin Li
9636*a376eb32SXin Li# The TAGs below are defined such that we never get into a situation
9637*a376eb32SXin Li# in which we disable both kinds of libraries.  Given conflicting
9638*a376eb32SXin Li# choices, we go for a static library, that is the most portable,
9639*a376eb32SXin Li# since we can't tell whether shared libraries were disabled because
9640*a376eb32SXin Li# the user asked for that or because the platform doesn't support
9641*a376eb32SXin Li# them.  This is particularly important on AIX, because we don't
9642*a376eb32SXin Li# support having both static and shared libraries enabled at the same
9643*a376eb32SXin Li# time on that platform, so we default to a shared-only configuration.
9644*a376eb32SXin Li# If a disable-shared tag is given, we'll fallback to a static-only
9645*a376eb32SXin Li# configuration.  But we'll never go from static-only to shared-only.
9646*a376eb32SXin Li
9647*a376eb32SXin Li# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
9648*a376eb32SXin Libuild_libtool_libs=no
9649*a376eb32SXin Libuild_old_libs=yes
9650*a376eb32SXin Li# ### END LIBTOOL TAG CONFIG: disable-shared
9651*a376eb32SXin Li
9652*a376eb32SXin Li# ### BEGIN LIBTOOL TAG CONFIG: disable-static
9653*a376eb32SXin Libuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
9654*a376eb32SXin Li# ### END LIBTOOL TAG CONFIG: disable-static
9655*a376eb32SXin Li
9656*a376eb32SXin Li# Local Variables:
9657*a376eb32SXin Li# mode:shell-script
9658*a376eb32SXin Li# sh-indentation:2
9659*a376eb32SXin Li# End:
9660*a376eb32SXin Li# vi:sw=2
9661*a376eb32SXin Li
9662