ltmain.sh revision cdbfa18a
1d5c3dbf1Smrg
2cdbfa18aSmrg# libtool (GNU libtool) 2.4.2
3d5c3dbf1Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
4d5c3dbf1Smrg
5fba89afeSmrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
6cdbfa18aSmrg# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
7d5c3dbf1Smrg# This is free software; see the source for copying conditions.  There is NO
8d5c3dbf1Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9d5c3dbf1Smrg
10d5c3dbf1Smrg# GNU Libtool is free software; you can redistribute it and/or modify
119f606849Smrg# it under the terms of the GNU General Public License as published by
129f606849Smrg# the Free Software Foundation; either version 2 of the License, or
139f606849Smrg# (at your option) any later version.
149f606849Smrg#
15d5c3dbf1Smrg# As a special exception to the GNU General Public License,
16d5c3dbf1Smrg# if you distribute this file as part of a program or library that
17d5c3dbf1Smrg# is built using GNU Libtool, you may include this file under the
18d5c3dbf1Smrg# same distribution terms that you use for the rest of that program.
19d5c3dbf1Smrg#
20d5c3dbf1Smrg# GNU Libtool is distributed in the hope that it will be useful, but
219f606849Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
229f606849Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
239f606849Smrg# General Public License for more details.
249f606849Smrg#
259f606849Smrg# You should have received a copy of the GNU General Public License
26d5c3dbf1Smrg# along with GNU Libtool; see the file COPYING.  If not, a copy
27d5c3dbf1Smrg# can be downloaded from http://www.gnu.org/licenses/gpl.html,
28d5c3dbf1Smrg# or obtained by writing to the Free Software Foundation, Inc.,
29d5c3dbf1Smrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
309f606849Smrg
31d5c3dbf1Smrg# Usage: $progname [OPTION]... [MODE-ARG]...
32d5c3dbf1Smrg#
33d5c3dbf1Smrg# Provide generalized library-building support services.
34d5c3dbf1Smrg#
35d5c3dbf1Smrg#       --config             show all configuration variables
36d5c3dbf1Smrg#       --debug              enable verbose shell tracing
37d5c3dbf1Smrg#   -n, --dry-run            display commands without modifying any files
38d5c3dbf1Smrg#       --features           display basic configuration information and exit
39d5c3dbf1Smrg#       --mode=MODE          use operation mode MODE
40d5c3dbf1Smrg#       --preserve-dup-deps  don't remove duplicate dependency libraries
41d5c3dbf1Smrg#       --quiet, --silent    don't print informational messages
42d5c3dbf1Smrg#       --no-quiet, --no-silent
43d5c3dbf1Smrg#                            print informational messages (default)
44cdbfa18aSmrg#       --no-warn            don't display warning messages
45d5c3dbf1Smrg#       --tag=TAG            use configuration variables from tag TAG
46d5c3dbf1Smrg#   -v, --verbose            print more informational messages than default
47d5c3dbf1Smrg#       --no-verbose         don't print the extra informational messages
48d5c3dbf1Smrg#       --version            print version information
49d5c3dbf1Smrg#   -h, --help, --help-all   print short, long, or detailed help message
50d5c3dbf1Smrg#
51d5c3dbf1Smrg# MODE must be one of the following:
52d5c3dbf1Smrg#
53d5c3dbf1Smrg#         clean              remove files from the build directory
54d5c3dbf1Smrg#         compile            compile a source file into a libtool object
55d5c3dbf1Smrg#         execute            automatically set library path, then run a program
56d5c3dbf1Smrg#         finish             complete the installation of libtool libraries
57d5c3dbf1Smrg#         install            install libraries or executables
58d5c3dbf1Smrg#         link               create a library or an executable
59d5c3dbf1Smrg#         uninstall          remove libraries from an installed directory
60d5c3dbf1Smrg#
61d5c3dbf1Smrg# MODE-ARGS vary depending on the MODE.  When passed as first option,
62d5c3dbf1Smrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
63d5c3dbf1Smrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
64d5c3dbf1Smrg#
65d5c3dbf1Smrg# When reporting a bug, please describe a test case to reproduce it and
66d5c3dbf1Smrg# include the following information:
67d5c3dbf1Smrg#
68d5c3dbf1Smrg#         host-triplet:	$host
69d5c3dbf1Smrg#         shell:		$SHELL
70d5c3dbf1Smrg#         compiler:		$LTCC
71d5c3dbf1Smrg#         compiler flags:		$LTCFLAGS
72d5c3dbf1Smrg#         linker:		$LD (gnu? $with_gnu_ld)
73cdbfa18aSmrg#         $progname:	(GNU libtool) 2.4.2
74d5c3dbf1Smrg#         automake:	$automake_version
75d5c3dbf1Smrg#         autoconf:	$autoconf_version
76d5c3dbf1Smrg#
77d5c3dbf1Smrg# Report bugs to <bug-libtool@gnu.org>.
78cdbfa18aSmrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
79cdbfa18aSmrg# General help using GNU software: <http://www.gnu.org/gethelp/>.
809f606849Smrg
81d5c3dbf1SmrgPROGRAM=libtool
829f606849SmrgPACKAGE=libtool
83cdbfa18aSmrgVERSION=2.4.2
84d5c3dbf1SmrgTIMESTAMP=""
85cdbfa18aSmrgpackage_revision=1.3337
86fba89afeSmrg
87d5c3dbf1Smrg# Be Bourne compatible
88fba89afeSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
89fba89afeSmrg  emulate sh
90fba89afeSmrg  NULLCMD=:
91fba89afeSmrg  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
92fba89afeSmrg  # is contrary to our usage.  Disable this feature.
93fba89afeSmrg  alias -g '${1+"$@"}'='"$@"'
949f606849Smrg  setopt NO_GLOB_SUBST
95fba89afeSmrgelse
96fba89afeSmrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
979f606849Smrgfi
98fba89afeSmrgBIN_SH=xpg4; export BIN_SH # for Tru64
99fba89afeSmrgDUALCASE=1; export DUALCASE # for MKS sh
1009f606849Smrg
101d5c3dbf1Smrg# A function that is used when there is no print builtin or printf.
102d5c3dbf1Smrgfunc_fallback_echo ()
103d5c3dbf1Smrg{
104d5c3dbf1Smrg  eval 'cat <<_LTECHO_EOF
105d5c3dbf1Smrg$1
106d5c3dbf1Smrg_LTECHO_EOF'
107d5c3dbf1Smrg}
1089f606849Smrg
109d5c3dbf1Smrg# NLS nuisances: We save the old values to restore during execute mode.
110d5c3dbf1Smrglt_user_locale=
111d5c3dbf1Smrglt_safe_locale=
112fba89afeSmrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
113fba89afeSmrgdo
114fba89afeSmrg  eval "if test \"\${$lt_var+set}\" = set; then
115d5c3dbf1Smrg          save_$lt_var=\$$lt_var
116d5c3dbf1Smrg          $lt_var=C
117fba89afeSmrg	  export $lt_var
118d5c3dbf1Smrg	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
119d5c3dbf1Smrg	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
120fba89afeSmrg	fi"
121fba89afeSmrgdone
122d5c3dbf1SmrgLC_ALL=C
123d5c3dbf1SmrgLANGUAGE=C
124d5c3dbf1Smrgexport LANGUAGE LC_ALL
125fba89afeSmrg
126d5c3dbf1Smrg$lt_unset CDPATH
127d5c3dbf1Smrg
128d5c3dbf1Smrg
129d5c3dbf1Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
130d5c3dbf1Smrg# is ksh but when the shell is invoked as "sh" and the current value of
131d5c3dbf1Smrg# the _XPG environment variable is not equal to 1 (one), the special
132d5c3dbf1Smrg# positional parameter $0, within a function call, is the name of the
133d5c3dbf1Smrg# function.
134d5c3dbf1Smrgprogpath="$0"
135d5c3dbf1Smrg
136d5c3dbf1Smrg
137d5c3dbf1Smrg
138d5c3dbf1Smrg: ${CP="cp -f"}
139d5c3dbf1Smrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
140d5c3dbf1Smrg: ${MAKE="make"}
141d5c3dbf1Smrg: ${MKDIR="mkdir"}
142d5c3dbf1Smrg: ${MV="mv -f"}
143d5c3dbf1Smrg: ${RM="rm -f"}
144d5c3dbf1Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
145d5c3dbf1Smrg: ${Xsed="$SED -e 1s/^X//"}
146d5c3dbf1Smrg
147d5c3dbf1Smrg# Global variables:
148d5c3dbf1SmrgEXIT_SUCCESS=0
149d5c3dbf1SmrgEXIT_FAILURE=1
150d5c3dbf1SmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
151d5c3dbf1SmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
152d5c3dbf1Smrg
153d5c3dbf1Smrgexit_status=$EXIT_SUCCESS
1549f606849Smrg
1559f606849Smrg# Make sure IFS has a sensible default
1569f606849Smrglt_nl='
1579f606849Smrg'
1589f606849SmrgIFS=" 	$lt_nl"
1599f606849Smrg
160d5c3dbf1Smrgdirname="s,/[^/]*$,,"
161d5c3dbf1Smrgbasename="s,^.*/,,"
162d5c3dbf1Smrg
163cdbfa18aSmrg# func_dirname file append nondir_replacement
164cdbfa18aSmrg# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
165cdbfa18aSmrg# otherwise set result to NONDIR_REPLACEMENT.
166cdbfa18aSmrgfunc_dirname ()
167cdbfa18aSmrg{
168cdbfa18aSmrg    func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
169cdbfa18aSmrg    if test "X$func_dirname_result" = "X${1}"; then
170cdbfa18aSmrg      func_dirname_result="${3}"
171cdbfa18aSmrg    else
172cdbfa18aSmrg      func_dirname_result="$func_dirname_result${2}"
173cdbfa18aSmrg    fi
174cdbfa18aSmrg} # func_dirname may be replaced by extended shell implementation
175cdbfa18aSmrg
176cdbfa18aSmrg
177cdbfa18aSmrg# func_basename file
178cdbfa18aSmrgfunc_basename ()
179cdbfa18aSmrg{
180cdbfa18aSmrg    func_basename_result=`$ECHO "${1}" | $SED "$basename"`
181cdbfa18aSmrg} # func_basename may be replaced by extended shell implementation
182cdbfa18aSmrg
183cdbfa18aSmrg
184d5c3dbf1Smrg# func_dirname_and_basename file append nondir_replacement
185d5c3dbf1Smrg# perform func_basename and func_dirname in a single function
186d5c3dbf1Smrg# call:
187d5c3dbf1Smrg#   dirname:  Compute the dirname of FILE.  If nonempty,
188d5c3dbf1Smrg#             add APPEND to the result, otherwise set result
189d5c3dbf1Smrg#             to NONDIR_REPLACEMENT.
190d5c3dbf1Smrg#             value returned in "$func_dirname_result"
191d5c3dbf1Smrg#   basename: Compute filename of FILE.
192d5c3dbf1Smrg#             value retuned in "$func_basename_result"
193d5c3dbf1Smrg# Implementation must be kept synchronized with func_dirname
194d5c3dbf1Smrg# and func_basename. For efficiency, we do not delegate to
195d5c3dbf1Smrg# those functions but instead duplicate the functionality here.
196d5c3dbf1Smrgfunc_dirname_and_basename ()
197d5c3dbf1Smrg{
198cdbfa18aSmrg    # Extract subdirectory from the argument.
199cdbfa18aSmrg    func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
200cdbfa18aSmrg    if test "X$func_dirname_result" = "X${1}"; then
201cdbfa18aSmrg      func_dirname_result="${3}"
202cdbfa18aSmrg    else
203cdbfa18aSmrg      func_dirname_result="$func_dirname_result${2}"
204cdbfa18aSmrg    fi
205cdbfa18aSmrg    func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
206cdbfa18aSmrg} # func_dirname_and_basename may be replaced by extended shell implementation
207cdbfa18aSmrg
208cdbfa18aSmrg
209cdbfa18aSmrg# func_stripname prefix suffix name
210cdbfa18aSmrg# strip PREFIX and SUFFIX off of NAME.
211cdbfa18aSmrg# PREFIX and SUFFIX must not contain globbing or regex special
212cdbfa18aSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading
213cdbfa18aSmrg# dot (in which case that matches only a dot).
214cdbfa18aSmrg# func_strip_suffix prefix name
215cdbfa18aSmrgfunc_stripname ()
216cdbfa18aSmrg{
217cdbfa18aSmrg    case ${2} in
218cdbfa18aSmrg      .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
219cdbfa18aSmrg      *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
220cdbfa18aSmrg    esac
221cdbfa18aSmrg} # func_stripname may be replaced by extended shell implementation
2229f606849Smrg
223d5c3dbf1Smrg
224d5c3dbf1Smrg# These SED scripts presuppose an absolute path with a trailing slash.
225d5c3dbf1Smrgpathcar='s,^/\([^/]*\).*$,\1,'
226d5c3dbf1Smrgpathcdr='s,^/[^/]*,,'
227d5c3dbf1Smrgremovedotparts=':dotsl
228d5c3dbf1Smrg		s@/\./@/@g
229d5c3dbf1Smrg		t dotsl
230d5c3dbf1Smrg		s,/\.$,/,'
231d5c3dbf1Smrgcollapseslashes='s@/\{1,\}@/@g'
232d5c3dbf1Smrgfinalslash='s,/*$,/,'
233d5c3dbf1Smrg
234d5c3dbf1Smrg# func_normal_abspath PATH
235d5c3dbf1Smrg# Remove doubled-up and trailing slashes, "." path components,
236d5c3dbf1Smrg# and cancel out any ".." path components in PATH after making
237d5c3dbf1Smrg# it an absolute path.
238d5c3dbf1Smrg#             value returned in "$func_normal_abspath_result"
239d5c3dbf1Smrgfunc_normal_abspath ()
240d5c3dbf1Smrg{
241d5c3dbf1Smrg  # Start from root dir and reassemble the path.
242d5c3dbf1Smrg  func_normal_abspath_result=
243d5c3dbf1Smrg  func_normal_abspath_tpath=$1
244d5c3dbf1Smrg  func_normal_abspath_altnamespace=
245d5c3dbf1Smrg  case $func_normal_abspath_tpath in
246d5c3dbf1Smrg    "")
247d5c3dbf1Smrg      # Empty path, that just means $cwd.
248d5c3dbf1Smrg      func_stripname '' '/' "`pwd`"
249d5c3dbf1Smrg      func_normal_abspath_result=$func_stripname_result
250d5c3dbf1Smrg      return
251d5c3dbf1Smrg    ;;
252d5c3dbf1Smrg    # The next three entries are used to spot a run of precisely
253d5c3dbf1Smrg    # two leading slashes without using negated character classes;
254d5c3dbf1Smrg    # we take advantage of case's first-match behaviour.
255d5c3dbf1Smrg    ///*)
256d5c3dbf1Smrg      # Unusual form of absolute path, do nothing.
257d5c3dbf1Smrg    ;;
258d5c3dbf1Smrg    //*)
259d5c3dbf1Smrg      # Not necessarily an ordinary path; POSIX reserves leading '//'
260d5c3dbf1Smrg      # and for example Cygwin uses it to access remote file shares
261d5c3dbf1Smrg      # over CIFS/SMB, so we conserve a leading double slash if found.
262d5c3dbf1Smrg      func_normal_abspath_altnamespace=/
263d5c3dbf1Smrg    ;;
264d5c3dbf1Smrg    /*)
265d5c3dbf1Smrg      # Absolute path, do nothing.
266d5c3dbf1Smrg    ;;
267d5c3dbf1Smrg    *)
268d5c3dbf1Smrg      # Relative path, prepend $cwd.
269d5c3dbf1Smrg      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
270d5c3dbf1Smrg    ;;
271d5c3dbf1Smrg  esac
272d5c3dbf1Smrg  # Cancel out all the simple stuff to save iterations.  We also want
273d5c3dbf1Smrg  # the path to end with a slash for ease of parsing, so make sure
274d5c3dbf1Smrg  # there is one (and only one) here.
275d5c3dbf1Smrg  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
276d5c3dbf1Smrg        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
277d5c3dbf1Smrg  while :; do
278d5c3dbf1Smrg    # Processed it all yet?
279d5c3dbf1Smrg    if test "$func_normal_abspath_tpath" = / ; then
280d5c3dbf1Smrg      # If we ascended to the root using ".." the result may be empty now.
281d5c3dbf1Smrg      if test -z "$func_normal_abspath_result" ; then
282d5c3dbf1Smrg        func_normal_abspath_result=/
283d5c3dbf1Smrg      fi
284d5c3dbf1Smrg      break
285d5c3dbf1Smrg    fi
286d5c3dbf1Smrg    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
287d5c3dbf1Smrg        -e "$pathcar"`
288d5c3dbf1Smrg    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
289d5c3dbf1Smrg        -e "$pathcdr"`
290d5c3dbf1Smrg    # Figure out what to do with it
291d5c3dbf1Smrg    case $func_normal_abspath_tcomponent in
292d5c3dbf1Smrg      "")
293d5c3dbf1Smrg        # Trailing empty path component, ignore it.
294d5c3dbf1Smrg      ;;
295d5c3dbf1Smrg      ..)
296d5c3dbf1Smrg        # Parent dir; strip last assembled component from result.
297d5c3dbf1Smrg        func_dirname "$func_normal_abspath_result"
298d5c3dbf1Smrg        func_normal_abspath_result=$func_dirname_result
299d5c3dbf1Smrg      ;;
300d5c3dbf1Smrg      *)
301d5c3dbf1Smrg        # Actual path component, append it.
302d5c3dbf1Smrg        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
303d5c3dbf1Smrg      ;;
304d5c3dbf1Smrg    esac
305d5c3dbf1Smrg  done
306d5c3dbf1Smrg  # Restore leading double-slash if one was found on entry.
307d5c3dbf1Smrg  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
308d5c3dbf1Smrg}
309d5c3dbf1Smrg
310d5c3dbf1Smrg# func_relative_path SRCDIR DSTDIR
311d5c3dbf1Smrg# generates a relative path from SRCDIR to DSTDIR, with a trailing
312d5c3dbf1Smrg# slash if non-empty, suitable for immediately appending a filename
313d5c3dbf1Smrg# without needing to append a separator.
314d5c3dbf1Smrg#             value returned in "$func_relative_path_result"
315d5c3dbf1Smrgfunc_relative_path ()
316d5c3dbf1Smrg{
317d5c3dbf1Smrg  func_relative_path_result=
318d5c3dbf1Smrg  func_normal_abspath "$1"
319d5c3dbf1Smrg  func_relative_path_tlibdir=$func_normal_abspath_result
320d5c3dbf1Smrg  func_normal_abspath "$2"
321d5c3dbf1Smrg  func_relative_path_tbindir=$func_normal_abspath_result
322d5c3dbf1Smrg
323d5c3dbf1Smrg  # Ascend the tree starting from libdir
324d5c3dbf1Smrg  while :; do
325d5c3dbf1Smrg    # check if we have found a prefix of bindir
326d5c3dbf1Smrg    case $func_relative_path_tbindir in
327d5c3dbf1Smrg      $func_relative_path_tlibdir)
328d5c3dbf1Smrg        # found an exact match
329d5c3dbf1Smrg        func_relative_path_tcancelled=
330d5c3dbf1Smrg        break
331d5c3dbf1Smrg        ;;
332d5c3dbf1Smrg      $func_relative_path_tlibdir*)
333d5c3dbf1Smrg        # found a matching prefix
334d5c3dbf1Smrg        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
335d5c3dbf1Smrg        func_relative_path_tcancelled=$func_stripname_result
336d5c3dbf1Smrg        if test -z "$func_relative_path_result"; then
337d5c3dbf1Smrg          func_relative_path_result=.
338d5c3dbf1Smrg        fi
339d5c3dbf1Smrg        break
340d5c3dbf1Smrg        ;;
341d5c3dbf1Smrg      *)
342d5c3dbf1Smrg        func_dirname $func_relative_path_tlibdir
343d5c3dbf1Smrg        func_relative_path_tlibdir=${func_dirname_result}
344d5c3dbf1Smrg        if test "x$func_relative_path_tlibdir" = x ; then
345d5c3dbf1Smrg          # Have to descend all the way to the root!
346d5c3dbf1Smrg          func_relative_path_result=../$func_relative_path_result
347d5c3dbf1Smrg          func_relative_path_tcancelled=$func_relative_path_tbindir
348d5c3dbf1Smrg          break
349d5c3dbf1Smrg        fi
350d5c3dbf1Smrg        func_relative_path_result=../$func_relative_path_result
351d5c3dbf1Smrg        ;;
352d5c3dbf1Smrg    esac
353d5c3dbf1Smrg  done
354d5c3dbf1Smrg
355d5c3dbf1Smrg  # Now calculate path; take care to avoid doubling-up slashes.
356d5c3dbf1Smrg  func_stripname '' '/' "$func_relative_path_result"
357d5c3dbf1Smrg  func_relative_path_result=$func_stripname_result
358d5c3dbf1Smrg  func_stripname '/' '/' "$func_relative_path_tcancelled"
359d5c3dbf1Smrg  if test "x$func_stripname_result" != x ; then
360d5c3dbf1Smrg    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
361d5c3dbf1Smrg  fi
362d5c3dbf1Smrg
363d5c3dbf1Smrg  # Normalisation. If bindir is libdir, return empty string,
364d5c3dbf1Smrg  # else relative path ending with a slash; either way, target
365d5c3dbf1Smrg  # file name can be directly appended.
366d5c3dbf1Smrg  if test ! -z "$func_relative_path_result"; then
367d5c3dbf1Smrg    func_stripname './' '' "$func_relative_path_result/"
368d5c3dbf1Smrg    func_relative_path_result=$func_stripname_result
369d5c3dbf1Smrg  fi
370d5c3dbf1Smrg}
371d5c3dbf1Smrg
372d5c3dbf1Smrg# The name of this program:
373d5c3dbf1Smrgfunc_dirname_and_basename "$progpath"
374d5c3dbf1Smrgprogname=$func_basename_result
375d5c3dbf1Smrg
376d5c3dbf1Smrg# Make sure we have an absolute path for reexecution:
377d5c3dbf1Smrgcase $progpath in
378d5c3dbf1Smrg  [\\/]*|[A-Za-z]:\\*) ;;
379d5c3dbf1Smrg  *[\\/]*)
380d5c3dbf1Smrg     progdir=$func_dirname_result
381d5c3dbf1Smrg     progdir=`cd "$progdir" && pwd`
382d5c3dbf1Smrg     progpath="$progdir/$progname"
383d5c3dbf1Smrg     ;;
384d5c3dbf1Smrg  *)
385d5c3dbf1Smrg     save_IFS="$IFS"
386cdbfa18aSmrg     IFS=${PATH_SEPARATOR-:}
387d5c3dbf1Smrg     for progdir in $PATH; do
388d5c3dbf1Smrg       IFS="$save_IFS"
389d5c3dbf1Smrg       test -x "$progdir/$progname" && break
390d5c3dbf1Smrg     done
391d5c3dbf1Smrg     IFS="$save_IFS"
392d5c3dbf1Smrg     test -n "$progdir" || progdir=`pwd`
393d5c3dbf1Smrg     progpath="$progdir/$progname"
394d5c3dbf1Smrg     ;;
395d5c3dbf1Smrgesac
396d5c3dbf1Smrg
397d5c3dbf1Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
398d5c3dbf1Smrg# metacharacters that are still active within double-quoted strings.
399d5c3dbf1SmrgXsed="${SED}"' -e 1s/^X//'
400d5c3dbf1Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g'
401d5c3dbf1Smrg
402d5c3dbf1Smrg# Same as above, but do not quote variable references.
403d5c3dbf1Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g'
404d5c3dbf1Smrg
405cdbfa18aSmrg# Sed substitution that turns a string into a regex matching for the
406cdbfa18aSmrg# string literally.
407cdbfa18aSmrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
408cdbfa18aSmrg
409cdbfa18aSmrg# Sed substitution that converts a w32 file name or path
410cdbfa18aSmrg# which contains forward slashes, into one that contains
411cdbfa18aSmrg# (escaped) backslashes.  A very naive implementation.
412cdbfa18aSmrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
413cdbfa18aSmrg
414d5c3dbf1Smrg# Re-`\' parameter expansions in output of double_quote_subst that were
415d5c3dbf1Smrg# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
416d5c3dbf1Smrg# in input to double_quote_subst, that '$' was protected from expansion.
417d5c3dbf1Smrg# Since each input `\' is now two `\'s, look for any number of runs of
418d5c3dbf1Smrg# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
419d5c3dbf1Smrgbs='\\'
420d5c3dbf1Smrgbs2='\\\\'
421d5c3dbf1Smrgbs4='\\\\\\\\'
422d5c3dbf1Smrgdollar='\$'
423d5c3dbf1Smrgsed_double_backslash="\
424d5c3dbf1Smrg  s/$bs4/&\\
425d5c3dbf1Smrg/g
426d5c3dbf1Smrg  s/^$bs2$dollar/$bs&/
427d5c3dbf1Smrg  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
428d5c3dbf1Smrg  s/\n//g"
429d5c3dbf1Smrg
430d5c3dbf1Smrg# Standard options:
431d5c3dbf1Smrgopt_dry_run=false
432d5c3dbf1Smrgopt_help=false
433d5c3dbf1Smrgopt_quiet=false
434d5c3dbf1Smrgopt_verbose=false
435d5c3dbf1Smrgopt_warning=:
436d5c3dbf1Smrg
437d5c3dbf1Smrg# func_echo arg...
438d5c3dbf1Smrg# Echo program name prefixed message, along with the current mode
439d5c3dbf1Smrg# name if it has been set yet.
440d5c3dbf1Smrgfunc_echo ()
441d5c3dbf1Smrg{
442cdbfa18aSmrg    $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
443d5c3dbf1Smrg}
444d5c3dbf1Smrg
445d5c3dbf1Smrg# func_verbose arg...
446d5c3dbf1Smrg# Echo program name prefixed message in verbose mode only.
447d5c3dbf1Smrgfunc_verbose ()
448d5c3dbf1Smrg{
449d5c3dbf1Smrg    $opt_verbose && func_echo ${1+"$@"}
450d5c3dbf1Smrg
451d5c3dbf1Smrg    # A bug in bash halts the script if the last line of a function
452d5c3dbf1Smrg    # fails when set -e is in force, so we need another command to
453d5c3dbf1Smrg    # work around that:
454d5c3dbf1Smrg    :
455d5c3dbf1Smrg}
456d5c3dbf1Smrg
457d5c3dbf1Smrg# func_echo_all arg...
458d5c3dbf1Smrg# Invoke $ECHO with all args, space-separated.
459d5c3dbf1Smrgfunc_echo_all ()
460d5c3dbf1Smrg{
461d5c3dbf1Smrg    $ECHO "$*"
462d5c3dbf1Smrg}
463d5c3dbf1Smrg
464d5c3dbf1Smrg# func_error arg...
465d5c3dbf1Smrg# Echo program name prefixed message to standard error.
466d5c3dbf1Smrgfunc_error ()
467d5c3dbf1Smrg{
468cdbfa18aSmrg    $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
469d5c3dbf1Smrg}
470d5c3dbf1Smrg
471d5c3dbf1Smrg# func_warning arg...
472d5c3dbf1Smrg# Echo program name prefixed warning message to standard error.
473d5c3dbf1Smrgfunc_warning ()
474d5c3dbf1Smrg{
475cdbfa18aSmrg    $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
476d5c3dbf1Smrg
477d5c3dbf1Smrg    # bash bug again:
478d5c3dbf1Smrg    :
479d5c3dbf1Smrg}
480d5c3dbf1Smrg
481d5c3dbf1Smrg# func_fatal_error arg...
482d5c3dbf1Smrg# Echo program name prefixed message to standard error, and exit.
483d5c3dbf1Smrgfunc_fatal_error ()
484d5c3dbf1Smrg{
485d5c3dbf1Smrg    func_error ${1+"$@"}
486d5c3dbf1Smrg    exit $EXIT_FAILURE
487d5c3dbf1Smrg}
488d5c3dbf1Smrg
489d5c3dbf1Smrg# func_fatal_help arg...
490d5c3dbf1Smrg# Echo program name prefixed message to standard error, followed by
491d5c3dbf1Smrg# a help hint, and exit.
492d5c3dbf1Smrgfunc_fatal_help ()
493d5c3dbf1Smrg{
494d5c3dbf1Smrg    func_error ${1+"$@"}
495d5c3dbf1Smrg    func_fatal_error "$help"
496d5c3dbf1Smrg}
497d5c3dbf1Smrghelp="Try \`$progname --help' for more information."  ## default
498d5c3dbf1Smrg
499d5c3dbf1Smrg
500d5c3dbf1Smrg# func_grep expression filename
501d5c3dbf1Smrg# Check whether EXPRESSION matches any line of FILENAME, without output.
502d5c3dbf1Smrgfunc_grep ()
503d5c3dbf1Smrg{
504d5c3dbf1Smrg    $GREP "$1" "$2" >/dev/null 2>&1
505d5c3dbf1Smrg}
506d5c3dbf1Smrg
507d5c3dbf1Smrg
508d5c3dbf1Smrg# func_mkdir_p directory-path
509d5c3dbf1Smrg# Make sure the entire path to DIRECTORY-PATH is available.
510d5c3dbf1Smrgfunc_mkdir_p ()
511d5c3dbf1Smrg{
512d5c3dbf1Smrg    my_directory_path="$1"
513d5c3dbf1Smrg    my_dir_list=
514d5c3dbf1Smrg
515d5c3dbf1Smrg    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
516d5c3dbf1Smrg
517d5c3dbf1Smrg      # Protect directory names starting with `-'
518d5c3dbf1Smrg      case $my_directory_path in
519d5c3dbf1Smrg        -*) my_directory_path="./$my_directory_path" ;;
520d5c3dbf1Smrg      esac
521d5c3dbf1Smrg
522d5c3dbf1Smrg      # While some portion of DIR does not yet exist...
523d5c3dbf1Smrg      while test ! -d "$my_directory_path"; do
524d5c3dbf1Smrg        # ...make a list in topmost first order.  Use a colon delimited
525d5c3dbf1Smrg	# list incase some portion of path contains whitespace.
526d5c3dbf1Smrg        my_dir_list="$my_directory_path:$my_dir_list"
527d5c3dbf1Smrg
528d5c3dbf1Smrg        # If the last portion added has no slash in it, the list is done
529d5c3dbf1Smrg        case $my_directory_path in */*) ;; *) break ;; esac
530d5c3dbf1Smrg
531d5c3dbf1Smrg        # ...otherwise throw away the child directory and loop
532d5c3dbf1Smrg        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
533d5c3dbf1Smrg      done
534d5c3dbf1Smrg      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
535d5c3dbf1Smrg
536d5c3dbf1Smrg      save_mkdir_p_IFS="$IFS"; IFS=':'
537d5c3dbf1Smrg      for my_dir in $my_dir_list; do
538d5c3dbf1Smrg	IFS="$save_mkdir_p_IFS"
539d5c3dbf1Smrg        # mkdir can fail with a `File exist' error if two processes
540d5c3dbf1Smrg        # try to create one of the directories concurrently.  Don't
541d5c3dbf1Smrg        # stop in that case!
542d5c3dbf1Smrg        $MKDIR "$my_dir" 2>/dev/null || :
543d5c3dbf1Smrg      done
544d5c3dbf1Smrg      IFS="$save_mkdir_p_IFS"
545d5c3dbf1Smrg
546d5c3dbf1Smrg      # Bail out if we (or some other process) failed to create a directory.
547d5c3dbf1Smrg      test -d "$my_directory_path" || \
548d5c3dbf1Smrg        func_fatal_error "Failed to create \`$1'"
549d5c3dbf1Smrg    fi
550d5c3dbf1Smrg}
5519f606849Smrg
5529f606849Smrg
5539f606849Smrg# func_mktempdir [string]
5549f606849Smrg# Make a temporary directory that won't clash with other running
5559f606849Smrg# libtool processes, and avoids race conditions if possible.  If
5569f606849Smrg# given, STRING is the basename for that directory.
5579f606849Smrgfunc_mktempdir ()
5589f606849Smrg{
5599f606849Smrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
5609f606849Smrg
561d5c3dbf1Smrg    if test "$opt_dry_run" = ":"; then
5629f606849Smrg      # Return a directory name, but don't create it in dry-run mode
5639f606849Smrg      my_tmpdir="${my_template}-$$"
5649f606849Smrg    else
5659f606849Smrg
5669f606849Smrg      # If mktemp works, use that first and foremost
5679f606849Smrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
5689f606849Smrg
5699f606849Smrg      if test ! -d "$my_tmpdir"; then
570d5c3dbf1Smrg        # Failing that, at least try and use $RANDOM to avoid a race
571d5c3dbf1Smrg        my_tmpdir="${my_template}-${RANDOM-0}$$"
5729f606849Smrg
573d5c3dbf1Smrg        save_mktempdir_umask=`umask`
574d5c3dbf1Smrg        umask 0077
575d5c3dbf1Smrg        $MKDIR "$my_tmpdir"
576d5c3dbf1Smrg        umask $save_mktempdir_umask
5779f606849Smrg      fi
5789f606849Smrg
5799f606849Smrg      # If we're not in dry-run mode, bomb out on failure
580d5c3dbf1Smrg      test -d "$my_tmpdir" || \
581d5c3dbf1Smrg        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
5829f606849Smrg    fi
5839f606849Smrg
584d5c3dbf1Smrg    $ECHO "$my_tmpdir"
5859f606849Smrg}
5869f606849Smrg
5879f606849Smrg
588d5c3dbf1Smrg# func_quote_for_eval arg
589d5c3dbf1Smrg# Aesthetically quote ARG to be evaled later.
590d5c3dbf1Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
591d5c3dbf1Smrg# is double-quoted, suitable for a subsequent eval, whereas
592d5c3dbf1Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
593d5c3dbf1Smrg# which are still active within double quotes backslashified.
594d5c3dbf1Smrgfunc_quote_for_eval ()
5959f606849Smrg{
596d5c3dbf1Smrg    case $1 in
597d5c3dbf1Smrg      *[\\\`\"\$]*)
598d5c3dbf1Smrg	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
599d5c3dbf1Smrg      *)
600d5c3dbf1Smrg        func_quote_for_eval_unquoted_result="$1" ;;
601d5c3dbf1Smrg    esac
602d5c3dbf1Smrg
603d5c3dbf1Smrg    case $func_quote_for_eval_unquoted_result in
604d5c3dbf1Smrg      # Double-quote args containing shell metacharacters to delay
605d5c3dbf1Smrg      # word splitting, command substitution and and variable
606d5c3dbf1Smrg      # expansion for a subsequent eval.
607d5c3dbf1Smrg      # Many Bourne shells cannot handle close brackets correctly
608d5c3dbf1Smrg      # in scan sets, so we specify it separately.
609d5c3dbf1Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
610d5c3dbf1Smrg        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
611d5c3dbf1Smrg        ;;
612d5c3dbf1Smrg      *)
613d5c3dbf1Smrg        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
6149f606849Smrg    esac
6159f606849Smrg}
6169f606849Smrg
6179f606849Smrg
618d5c3dbf1Smrg# func_quote_for_expand arg
619d5c3dbf1Smrg# Aesthetically quote ARG to be evaled later; same as above,
620d5c3dbf1Smrg# but do not quote variable references.
621d5c3dbf1Smrgfunc_quote_for_expand ()
6229f606849Smrg{
623d5c3dbf1Smrg    case $1 in
624d5c3dbf1Smrg      *[\\\`\"]*)
625d5c3dbf1Smrg	my_arg=`$ECHO "$1" | $SED \
626d5c3dbf1Smrg	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
6279f606849Smrg      *)
628d5c3dbf1Smrg        my_arg="$1" ;;
629d5c3dbf1Smrg    esac
630d5c3dbf1Smrg
631d5c3dbf1Smrg    case $my_arg in
632d5c3dbf1Smrg      # Double-quote args containing shell metacharacters to delay
633d5c3dbf1Smrg      # word splitting and command substitution for a subsequent eval.
634d5c3dbf1Smrg      # Many Bourne shells cannot handle close brackets correctly
635d5c3dbf1Smrg      # in scan sets, so we specify it separately.
636d5c3dbf1Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
637d5c3dbf1Smrg        my_arg="\"$my_arg\""
638d5c3dbf1Smrg        ;;
639d5c3dbf1Smrg    esac
640d5c3dbf1Smrg
641d5c3dbf1Smrg    func_quote_for_expand_result="$my_arg"
6429f606849Smrg}
6439f606849Smrg
6449f606849Smrg
645d5c3dbf1Smrg# func_show_eval cmd [fail_exp]
646d5c3dbf1Smrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
647d5c3dbf1Smrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
648d5c3dbf1Smrg# is given, then evaluate it.
649d5c3dbf1Smrgfunc_show_eval ()
6509f606849Smrg{
651d5c3dbf1Smrg    my_cmd="$1"
652d5c3dbf1Smrg    my_fail_exp="${2-:}"
6539f606849Smrg
654d5c3dbf1Smrg    ${opt_silent-false} || {
655d5c3dbf1Smrg      func_quote_for_expand "$my_cmd"
656d5c3dbf1Smrg      eval "func_echo $func_quote_for_expand_result"
657d5c3dbf1Smrg    }
658d5c3dbf1Smrg
659d5c3dbf1Smrg    if ${opt_dry_run-false}; then :; else
660d5c3dbf1Smrg      eval "$my_cmd"
661d5c3dbf1Smrg      my_status=$?
662d5c3dbf1Smrg      if test "$my_status" -eq 0; then :; else
663d5c3dbf1Smrg	eval "(exit $my_status); $my_fail_exp"
664d5c3dbf1Smrg      fi
6659f606849Smrg    fi
6669f606849Smrg}
6679f606849Smrg
668d5c3dbf1Smrg
669d5c3dbf1Smrg# func_show_eval_locale cmd [fail_exp]
670d5c3dbf1Smrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
671d5c3dbf1Smrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
672d5c3dbf1Smrg# is given, then evaluate it.  Use the saved locale for evaluation.
673d5c3dbf1Smrgfunc_show_eval_locale ()
6749f606849Smrg{
675d5c3dbf1Smrg    my_cmd="$1"
676d5c3dbf1Smrg    my_fail_exp="${2-:}"
6779f606849Smrg
678d5c3dbf1Smrg    ${opt_silent-false} || {
679d5c3dbf1Smrg      func_quote_for_expand "$my_cmd"
680d5c3dbf1Smrg      eval "func_echo $func_quote_for_expand_result"
681d5c3dbf1Smrg    }
6829f606849Smrg
683d5c3dbf1Smrg    if ${opt_dry_run-false}; then :; else
684d5c3dbf1Smrg      eval "$lt_user_locale
685d5c3dbf1Smrg	    $my_cmd"
686d5c3dbf1Smrg      my_status=$?
687d5c3dbf1Smrg      eval "$lt_safe_locale"
688d5c3dbf1Smrg      if test "$my_status" -eq 0; then :; else
689d5c3dbf1Smrg	eval "(exit $my_status); $my_fail_exp"
6909f606849Smrg      fi
691d5c3dbf1Smrg    fi
6929f606849Smrg}
6939f606849Smrg
694cdbfa18aSmrg# func_tr_sh
695cdbfa18aSmrg# Turn $1 into a string suitable for a shell variable name.
696cdbfa18aSmrg# Result is stored in $func_tr_sh_result.  All characters
697cdbfa18aSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
698cdbfa18aSmrg# if $1 begins with a digit, a '_' is prepended as well.
699cdbfa18aSmrgfunc_tr_sh ()
700cdbfa18aSmrg{
701cdbfa18aSmrg  case $1 in
702cdbfa18aSmrg  [0-9]* | *[!a-zA-Z0-9_]*)
703cdbfa18aSmrg    func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
704cdbfa18aSmrg    ;;
705cdbfa18aSmrg  * )
706cdbfa18aSmrg    func_tr_sh_result=$1
707cdbfa18aSmrg    ;;
708cdbfa18aSmrg  esac
709cdbfa18aSmrg}
710cdbfa18aSmrg
7119f606849Smrg
712d5c3dbf1Smrg# func_version
713d5c3dbf1Smrg# Echo version message to standard output and exit.
714d5c3dbf1Smrgfunc_version ()
715d5c3dbf1Smrg{
716cdbfa18aSmrg    $opt_debug
717cdbfa18aSmrg
718d5c3dbf1Smrg    $SED -n '/(C)/!b go
719d5c3dbf1Smrg	:more
720d5c3dbf1Smrg	/\./!{
721d5c3dbf1Smrg	  N
722d5c3dbf1Smrg	  s/\n# / /
723d5c3dbf1Smrg	  b more
724d5c3dbf1Smrg	}
725d5c3dbf1Smrg	:go
726d5c3dbf1Smrg	/^# '$PROGRAM' (GNU /,/# warranty; / {
727d5c3dbf1Smrg        s/^# //
728d5c3dbf1Smrg	s/^# *$//
729d5c3dbf1Smrg        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
730d5c3dbf1Smrg        p
731d5c3dbf1Smrg     }' < "$progpath"
732d5c3dbf1Smrg     exit $?
733d5c3dbf1Smrg}
7349f606849Smrg
735d5c3dbf1Smrg# func_usage
736d5c3dbf1Smrg# Echo short help message to standard output and exit.
737d5c3dbf1Smrgfunc_usage ()
738d5c3dbf1Smrg{
739cdbfa18aSmrg    $opt_debug
740cdbfa18aSmrg
741d5c3dbf1Smrg    $SED -n '/^# Usage:/,/^#  *.*--help/ {
742d5c3dbf1Smrg        s/^# //
743d5c3dbf1Smrg	s/^# *$//
744d5c3dbf1Smrg	s/\$progname/'$progname'/
745d5c3dbf1Smrg	p
746d5c3dbf1Smrg    }' < "$progpath"
747d5c3dbf1Smrg    echo
748d5c3dbf1Smrg    $ECHO "run \`$progname --help | more' for full usage"
749d5c3dbf1Smrg    exit $?
750d5c3dbf1Smrg}
7519f606849Smrg
752d5c3dbf1Smrg# func_help [NOEXIT]
753d5c3dbf1Smrg# Echo long help message to standard output and exit,
754d5c3dbf1Smrg# unless 'noexit' is passed as argument.
755d5c3dbf1Smrgfunc_help ()
756d5c3dbf1Smrg{
757cdbfa18aSmrg    $opt_debug
758cdbfa18aSmrg
759d5c3dbf1Smrg    $SED -n '/^# Usage:/,/# Report bugs to/ {
760cdbfa18aSmrg	:print
761d5c3dbf1Smrg        s/^# //
762d5c3dbf1Smrg	s/^# *$//
763d5c3dbf1Smrg	s*\$progname*'$progname'*
764d5c3dbf1Smrg	s*\$host*'"$host"'*
765d5c3dbf1Smrg	s*\$SHELL*'"$SHELL"'*
766d5c3dbf1Smrg	s*\$LTCC*'"$LTCC"'*
767d5c3dbf1Smrg	s*\$LTCFLAGS*'"$LTCFLAGS"'*
768d5c3dbf1Smrg	s*\$LD*'"$LD"'*
769d5c3dbf1Smrg	s/\$with_gnu_ld/'"$with_gnu_ld"'/
770cdbfa18aSmrg	s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/
771cdbfa18aSmrg	s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/
772d5c3dbf1Smrg	p
773cdbfa18aSmrg	d
774cdbfa18aSmrg     }
775cdbfa18aSmrg     /^# .* home page:/b print
776cdbfa18aSmrg     /^# General help using/b print
777cdbfa18aSmrg     ' < "$progpath"
778d5c3dbf1Smrg    ret=$?
779d5c3dbf1Smrg    if test -z "$1"; then
780d5c3dbf1Smrg      exit $ret
781d5c3dbf1Smrg    fi
782d5c3dbf1Smrg}
7839f606849Smrg
784d5c3dbf1Smrg# func_missing_arg argname
785d5c3dbf1Smrg# Echo program name prefixed message to standard error and set global
786d5c3dbf1Smrg# exit_cmd.
787d5c3dbf1Smrgfunc_missing_arg ()
788d5c3dbf1Smrg{
789cdbfa18aSmrg    $opt_debug
790cdbfa18aSmrg
791d5c3dbf1Smrg    func_error "missing argument for $1."
792d5c3dbf1Smrg    exit_cmd=exit
793d5c3dbf1Smrg}
7949f606849Smrg
7959f606849Smrg
796cdbfa18aSmrg# func_split_short_opt shortopt
797cdbfa18aSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell
798cdbfa18aSmrg# variables after splitting SHORTOPT after the 2nd character.
799cdbfa18aSmrgfunc_split_short_opt ()
800cdbfa18aSmrg{
801cdbfa18aSmrg    my_sed_short_opt='1s/^\(..\).*$/\1/;q'
802cdbfa18aSmrg    my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
803cdbfa18aSmrg
804cdbfa18aSmrg    func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
805cdbfa18aSmrg    func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
806cdbfa18aSmrg} # func_split_short_opt may be replaced by extended shell implementation
807cdbfa18aSmrg
808cdbfa18aSmrg
809cdbfa18aSmrg# func_split_long_opt longopt
810cdbfa18aSmrg# Set func_split_long_opt_name and func_split_long_opt_arg shell
811cdbfa18aSmrg# variables after splitting LONGOPT at the `=' sign.
812cdbfa18aSmrgfunc_split_long_opt ()
813cdbfa18aSmrg{
814cdbfa18aSmrg    my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
815cdbfa18aSmrg    my_sed_long_arg='1s/^--[^=]*=//'
816cdbfa18aSmrg
817cdbfa18aSmrg    func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
818cdbfa18aSmrg    func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
819cdbfa18aSmrg} # func_split_long_opt may be replaced by extended shell implementation
820cdbfa18aSmrg
821cdbfa18aSmrgexit_cmd=:
8229f606849Smrg
8239f606849Smrg
824fba89afeSmrg
8259f606849Smrg
826d5c3dbf1Smrg
827d5c3dbf1Smrgmagic="%%%MAGIC variable%%%"
828d5c3dbf1Smrgmagic_exe="%%%MAGIC EXE variable%%%"
829d5c3dbf1Smrg
830d5c3dbf1Smrg# Global variables.
831d5c3dbf1Smrgnonopt=
832d5c3dbf1Smrgpreserve_args=
833d5c3dbf1Smrglo2o="s/\\.lo\$/.${objext}/"
834d5c3dbf1Smrgo2lo="s/\\.${objext}\$/.lo/"
835d5c3dbf1Smrgextracted_archives=
836d5c3dbf1Smrgextracted_serial=0
837d5c3dbf1Smrg
838d5c3dbf1Smrg# If this variable is set in any of the actions, the command in it
839d5c3dbf1Smrg# will be execed at the end.  This prevents here-documents from being
840d5c3dbf1Smrg# left over by shells.
841d5c3dbf1Smrgexec_cmd=
842d5c3dbf1Smrg
843cdbfa18aSmrg# func_append var value
844cdbfa18aSmrg# Append VALUE to the end of shell variable VAR.
845cdbfa18aSmrgfunc_append ()
846cdbfa18aSmrg{
847cdbfa18aSmrg    eval "${1}=\$${1}\${2}"
848cdbfa18aSmrg} # func_append may be replaced by extended shell implementation
849cdbfa18aSmrg
850cdbfa18aSmrg# func_append_quoted var value
851cdbfa18aSmrg# Quote VALUE and append to the end of shell variable VAR, separated
852cdbfa18aSmrg# by a space.
853cdbfa18aSmrgfunc_append_quoted ()
854cdbfa18aSmrg{
855cdbfa18aSmrg    func_quote_for_eval "${2}"
856cdbfa18aSmrg    eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
857cdbfa18aSmrg} # func_append_quoted may be replaced by extended shell implementation
858cdbfa18aSmrg
859cdbfa18aSmrg
860cdbfa18aSmrg# func_arith arithmetic-term...
861cdbfa18aSmrgfunc_arith ()
862cdbfa18aSmrg{
863cdbfa18aSmrg    func_arith_result=`expr "${@}"`
864cdbfa18aSmrg} # func_arith may be replaced by extended shell implementation
865cdbfa18aSmrg
866cdbfa18aSmrg
867cdbfa18aSmrg# func_len string
868cdbfa18aSmrg# STRING may not start with a hyphen.
869cdbfa18aSmrgfunc_len ()
870cdbfa18aSmrg{
871cdbfa18aSmrg    func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
872cdbfa18aSmrg} # func_len may be replaced by extended shell implementation
873cdbfa18aSmrg
874cdbfa18aSmrg
875cdbfa18aSmrg# func_lo2o object
876cdbfa18aSmrgfunc_lo2o ()
877cdbfa18aSmrg{
878cdbfa18aSmrg    func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
879cdbfa18aSmrg} # func_lo2o may be replaced by extended shell implementation
880cdbfa18aSmrg
881cdbfa18aSmrg
882cdbfa18aSmrg# func_xform libobj-or-source
883cdbfa18aSmrgfunc_xform ()
884cdbfa18aSmrg{
885cdbfa18aSmrg    func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
886cdbfa18aSmrg} # func_xform may be replaced by extended shell implementation
887cdbfa18aSmrg
888cdbfa18aSmrg
889d5c3dbf1Smrg# func_fatal_configuration arg...
890d5c3dbf1Smrg# Echo program name prefixed message to standard error, followed by
891d5c3dbf1Smrg# a configuration failure hint, and exit.
892d5c3dbf1Smrgfunc_fatal_configuration ()
893d5c3dbf1Smrg{
894d5c3dbf1Smrg    func_error ${1+"$@"}
895d5c3dbf1Smrg    func_error "See the $PACKAGE documentation for more information."
896d5c3dbf1Smrg    func_fatal_error "Fatal configuration error."
897d5c3dbf1Smrg}
898d5c3dbf1Smrg
899d5c3dbf1Smrg
900d5c3dbf1Smrg# func_config
901d5c3dbf1Smrg# Display the configuration for all the tags in this script.
902d5c3dbf1Smrgfunc_config ()
903d5c3dbf1Smrg{
904d5c3dbf1Smrg    re_begincf='^# ### BEGIN LIBTOOL'
905d5c3dbf1Smrg    re_endcf='^# ### END LIBTOOL'
906d5c3dbf1Smrg
907d5c3dbf1Smrg    # Default configuration.
908d5c3dbf1Smrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
909d5c3dbf1Smrg
9109f606849Smrg    # Now print the configurations for the tags.
9119f606849Smrg    for tagname in $taglist; do
912d5c3dbf1Smrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
9139f606849Smrg    done
9149f606849Smrg
915d5c3dbf1Smrg    exit $?
916d5c3dbf1Smrg}
9179f606849Smrg
918d5c3dbf1Smrg# func_features
919d5c3dbf1Smrg# Display the features supported by this script.
920d5c3dbf1Smrgfunc_features ()
921d5c3dbf1Smrg{
922d5c3dbf1Smrg    echo "host: $host"
9239f606849Smrg    if test "$build_libtool_libs" = yes; then
924d5c3dbf1Smrg      echo "enable shared libraries"
9259f606849Smrg    else
926d5c3dbf1Smrg      echo "disable shared libraries"
9279f606849Smrg    fi
9289f606849Smrg    if test "$build_old_libs" = yes; then
929d5c3dbf1Smrg      echo "enable static libraries"
9309f606849Smrg    else
931d5c3dbf1Smrg      echo "disable static libraries"
9329f606849Smrg    fi
933d5c3dbf1Smrg
9349f606849Smrg    exit $?
935d5c3dbf1Smrg}
9369f606849Smrg
937d5c3dbf1Smrg# func_enable_tag tagname
938d5c3dbf1Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or
939d5c3dbf1Smrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
940d5c3dbf1Smrg# variable here.
941d5c3dbf1Smrgfunc_enable_tag ()
942d5c3dbf1Smrg{
943d5c3dbf1Smrg  # Global variable:
944d5c3dbf1Smrg  tagname="$1"
9459f606849Smrg
946d5c3dbf1Smrg  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
947d5c3dbf1Smrg  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
948d5c3dbf1Smrg  sed_extractcf="/$re_begincf/,/$re_endcf/p"
9499f606849Smrg
950d5c3dbf1Smrg  # Validate tagname.
951d5c3dbf1Smrg  case $tagname in
952d5c3dbf1Smrg    *[!-_A-Za-z0-9,/]*)
953d5c3dbf1Smrg      func_fatal_error "invalid tag name: $tagname"
954d5c3dbf1Smrg      ;;
955d5c3dbf1Smrg  esac
9569f606849Smrg
957d5c3dbf1Smrg  # Don't test for the "default" C tag, as we know it's
958d5c3dbf1Smrg  # there but not specially marked.
959d5c3dbf1Smrg  case $tagname in
960d5c3dbf1Smrg    CC) ;;
961d5c3dbf1Smrg    *)
962d5c3dbf1Smrg      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
963d5c3dbf1Smrg	taglist="$taglist $tagname"
964d5c3dbf1Smrg
965d5c3dbf1Smrg	# Evaluate the configuration.  Be careful to quote the path
966d5c3dbf1Smrg	# and the sed script, to avoid splitting on whitespace, but
967d5c3dbf1Smrg	# also don't use non-portable quotes within backquotes within
968d5c3dbf1Smrg	# quotes we have to do it in 2 steps:
969d5c3dbf1Smrg	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
970d5c3dbf1Smrg	eval "$extractedcf"
971d5c3dbf1Smrg      else
972d5c3dbf1Smrg	func_error "ignoring unknown tag $tagname"
973d5c3dbf1Smrg      fi
974d5c3dbf1Smrg      ;;
975d5c3dbf1Smrg  esac
976d5c3dbf1Smrg}
977d5c3dbf1Smrg
978cdbfa18aSmrg# func_check_version_match
979cdbfa18aSmrg# Ensure that we are using m4 macros, and libtool script from the same
980cdbfa18aSmrg# release of libtool.
981cdbfa18aSmrgfunc_check_version_match ()
982d5c3dbf1Smrg{
983cdbfa18aSmrg  if test "$package_revision" != "$macro_revision"; then
984cdbfa18aSmrg    if test "$VERSION" != "$macro_version"; then
985cdbfa18aSmrg      if test -z "$macro_version"; then
986cdbfa18aSmrg        cat >&2 <<_LT_EOF
987cdbfa18aSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
988cdbfa18aSmrg$progname: definition of this LT_INIT comes from an older release.
989cdbfa18aSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
990cdbfa18aSmrg$progname: and run autoconf again.
991cdbfa18aSmrg_LT_EOF
992cdbfa18aSmrg      else
993cdbfa18aSmrg        cat >&2 <<_LT_EOF
994cdbfa18aSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
995cdbfa18aSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
996cdbfa18aSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
997cdbfa18aSmrg$progname: and run autoconf again.
998cdbfa18aSmrg_LT_EOF
999cdbfa18aSmrg      fi
1000cdbfa18aSmrg    else
1001cdbfa18aSmrg      cat >&2 <<_LT_EOF
1002cdbfa18aSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
1003cdbfa18aSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
1004cdbfa18aSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
1005cdbfa18aSmrg$progname: of $PACKAGE $VERSION and run autoconf again.
1006cdbfa18aSmrg_LT_EOF
1007cdbfa18aSmrg    fi
1008cdbfa18aSmrg
1009cdbfa18aSmrg    exit $EXIT_MISMATCH
1010cdbfa18aSmrg  fi
1011cdbfa18aSmrg}
1012cdbfa18aSmrg
1013cdbfa18aSmrg
1014cdbfa18aSmrg# Shorthand for --mode=foo, only valid as the first argument
1015cdbfa18aSmrgcase $1 in
1016cdbfa18aSmrgclean|clea|cle|cl)
1017cdbfa18aSmrg  shift; set dummy --mode clean ${1+"$@"}; shift
1018cdbfa18aSmrg  ;;
1019cdbfa18aSmrgcompile|compil|compi|comp|com|co|c)
1020cdbfa18aSmrg  shift; set dummy --mode compile ${1+"$@"}; shift
1021cdbfa18aSmrg  ;;
1022cdbfa18aSmrgexecute|execut|execu|exec|exe|ex|e)
1023cdbfa18aSmrg  shift; set dummy --mode execute ${1+"$@"}; shift
1024cdbfa18aSmrg  ;;
1025cdbfa18aSmrgfinish|finis|fini|fin|fi|f)
1026cdbfa18aSmrg  shift; set dummy --mode finish ${1+"$@"}; shift
1027cdbfa18aSmrg  ;;
1028cdbfa18aSmrginstall|instal|insta|inst|ins|in|i)
1029cdbfa18aSmrg  shift; set dummy --mode install ${1+"$@"}; shift
1030cdbfa18aSmrg  ;;
1031cdbfa18aSmrglink|lin|li|l)
1032cdbfa18aSmrg  shift; set dummy --mode link ${1+"$@"}; shift
1033cdbfa18aSmrg  ;;
1034cdbfa18aSmrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
1035cdbfa18aSmrg  shift; set dummy --mode uninstall ${1+"$@"}; shift
1036cdbfa18aSmrg  ;;
1037cdbfa18aSmrgesac
1038cdbfa18aSmrg
1039cdbfa18aSmrg
1040cdbfa18aSmrg
1041cdbfa18aSmrg# Option defaults:
1042cdbfa18aSmrgopt_debug=:
1043cdbfa18aSmrgopt_dry_run=false
1044cdbfa18aSmrgopt_config=false
1045cdbfa18aSmrgopt_preserve_dup_deps=false
1046cdbfa18aSmrgopt_features=false
1047cdbfa18aSmrgopt_finish=false
1048cdbfa18aSmrgopt_help=false
1049cdbfa18aSmrgopt_help_all=false
1050cdbfa18aSmrgopt_silent=:
1051cdbfa18aSmrgopt_warning=:
1052cdbfa18aSmrgopt_verbose=:
1053cdbfa18aSmrgopt_silent=false
1054cdbfa18aSmrgopt_verbose=false
10559f606849Smrg
10569f606849Smrg
1057cdbfa18aSmrg# Parse options once, thoroughly.  This comes as soon as possible in the
1058cdbfa18aSmrg# script to make things like `--version' happen as quickly as we can.
1059cdbfa18aSmrg{
1060cdbfa18aSmrg  # this just eases exit handling
1061cdbfa18aSmrg  while test $# -gt 0; do
1062d5c3dbf1Smrg    opt="$1"
1063d5c3dbf1Smrg    shift
1064d5c3dbf1Smrg    case $opt in
1065cdbfa18aSmrg      --debug|-x)	opt_debug='set -x'
1066d5c3dbf1Smrg			func_echo "enabling shell trace mode"
1067d5c3dbf1Smrg			$opt_debug
1068d5c3dbf1Smrg			;;
1069cdbfa18aSmrg      --dry-run|--dryrun|-n)
1070cdbfa18aSmrg			opt_dry_run=:
1071d5c3dbf1Smrg			;;
1072cdbfa18aSmrg      --config)
1073cdbfa18aSmrg			opt_config=:
1074cdbfa18aSmrgfunc_config
1075cdbfa18aSmrg			;;
1076cdbfa18aSmrg      --dlopen|-dlopen)
1077cdbfa18aSmrg			optarg="$1"
1078cdbfa18aSmrg			opt_dlopen="${opt_dlopen+$opt_dlopen
1079cdbfa18aSmrg}$optarg"
1080d5c3dbf1Smrg			shift
1081d5c3dbf1Smrg			;;
1082d5c3dbf1Smrg      --preserve-dup-deps)
1083cdbfa18aSmrg			opt_preserve_dup_deps=:
1084d5c3dbf1Smrg			;;
1085cdbfa18aSmrg      --features)
1086cdbfa18aSmrg			opt_features=:
1087cdbfa18aSmrgfunc_features
1088d5c3dbf1Smrg			;;
1089cdbfa18aSmrg      --finish)
1090cdbfa18aSmrg			opt_finish=:
1091cdbfa18aSmrgset dummy --mode finish ${1+"$@"}; shift
1092cdbfa18aSmrg			;;
1093cdbfa18aSmrg      --help)
1094cdbfa18aSmrg			opt_help=:
1095cdbfa18aSmrg			;;
1096cdbfa18aSmrg      --help-all)
1097cdbfa18aSmrg			opt_help_all=:
1098cdbfa18aSmrgopt_help=': help-all'
1099cdbfa18aSmrg			;;
1100cdbfa18aSmrg      --mode)
1101cdbfa18aSmrg			test $# = 0 && func_missing_arg $opt && break
1102cdbfa18aSmrg			optarg="$1"
1103cdbfa18aSmrg			opt_mode="$optarg"
1104cdbfa18aSmrgcase $optarg in
1105cdbfa18aSmrg  # Valid mode arguments:
1106cdbfa18aSmrg  clean|compile|execute|finish|install|link|relink|uninstall) ;;
1107cdbfa18aSmrg
1108cdbfa18aSmrg  # Catch anything else as an error
1109cdbfa18aSmrg  *) func_error "invalid argument for $opt"
1110cdbfa18aSmrg     exit_cmd=exit
1111cdbfa18aSmrg     break
1112cdbfa18aSmrg     ;;
1113cdbfa18aSmrgesac
1114cdbfa18aSmrg			shift
1115cdbfa18aSmrg			;;
1116cdbfa18aSmrg      --no-silent|--no-quiet)
1117d5c3dbf1Smrg			opt_silent=false
1118cdbfa18aSmrgfunc_append preserve_args " $opt"
1119d5c3dbf1Smrg			;;
1120cdbfa18aSmrg      --no-warning|--no-warn)
1121cdbfa18aSmrg			opt_warning=false
1122cdbfa18aSmrgfunc_append preserve_args " $opt"
1123cdbfa18aSmrg			;;
1124cdbfa18aSmrg      --no-verbose)
1125d5c3dbf1Smrg			opt_verbose=false
1126cdbfa18aSmrgfunc_append preserve_args " $opt"
1127d5c3dbf1Smrg			;;
1128cdbfa18aSmrg      --silent|--quiet)
1129cdbfa18aSmrg			opt_silent=:
1130cdbfa18aSmrgfunc_append preserve_args " $opt"
1131cdbfa18aSmrg        opt_verbose=false
1132cdbfa18aSmrg			;;
1133cdbfa18aSmrg      --verbose|-v)
1134cdbfa18aSmrg			opt_verbose=:
1135cdbfa18aSmrgfunc_append preserve_args " $opt"
1136cdbfa18aSmrgopt_silent=false
1137cdbfa18aSmrg			;;
1138cdbfa18aSmrg      --tag)
1139cdbfa18aSmrg			test $# = 0 && func_missing_arg $opt && break
1140cdbfa18aSmrg			optarg="$1"
1141cdbfa18aSmrg			opt_tag="$optarg"
1142cdbfa18aSmrgfunc_append preserve_args " $opt $optarg"
1143cdbfa18aSmrgfunc_enable_tag "$optarg"
1144d5c3dbf1Smrg			shift
1145d5c3dbf1Smrg			;;
1146d5c3dbf1Smrg
1147cdbfa18aSmrg      -\?|-h)		func_usage				;;
1148cdbfa18aSmrg      --help)		func_help				;;
1149cdbfa18aSmrg      --version)	func_version				;;
1150cdbfa18aSmrg
1151d5c3dbf1Smrg      # Separate optargs to long options:
1152cdbfa18aSmrg      --*=*)
1153cdbfa18aSmrg			func_split_long_opt "$opt"
1154cdbfa18aSmrg			set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
1155d5c3dbf1Smrg			shift
1156d5c3dbf1Smrg			;;
1157d5c3dbf1Smrg
1158cdbfa18aSmrg      # Separate non-argument short options:
1159cdbfa18aSmrg      -\?*|-h*|-n*|-v*)
1160cdbfa18aSmrg			func_split_short_opt "$opt"
1161cdbfa18aSmrg			set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
1162cdbfa18aSmrg			shift
1163d5c3dbf1Smrg			;;
1164cdbfa18aSmrg
1165cdbfa18aSmrg      --)		break					;;
1166cdbfa18aSmrg      -*)		func_fatal_help "unrecognized option \`$opt'" ;;
1167cdbfa18aSmrg      *)		set dummy "$opt" ${1+"$@"};	shift; break  ;;
1168d5c3dbf1Smrg    esac
1169d5c3dbf1Smrg  done
1170d5c3dbf1Smrg
1171cdbfa18aSmrg  # Validate options:
1172cdbfa18aSmrg
1173cdbfa18aSmrg  # save first non-option argument
1174cdbfa18aSmrg  if test "$#" -gt 0; then
1175cdbfa18aSmrg    nonopt="$opt"
1176cdbfa18aSmrg    shift
1177cdbfa18aSmrg  fi
1178cdbfa18aSmrg
1179cdbfa18aSmrg  # preserve --debug
1180cdbfa18aSmrg  test "$opt_debug" = : || func_append preserve_args " --debug"
1181d5c3dbf1Smrg
1182d5c3dbf1Smrg  case $host in
1183d5c3dbf1Smrg    *cygwin* | *mingw* | *pw32* | *cegcc*)
1184d5c3dbf1Smrg      # don't eliminate duplications in $postdeps and $predeps
1185d5c3dbf1Smrg      opt_duplicate_compiler_generated_deps=:
11869f606849Smrg      ;;
11879f606849Smrg    *)
1188cdbfa18aSmrg      opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
1189d5c3dbf1Smrg      ;;
1190d5c3dbf1Smrg  esac
11919f606849Smrg
1192cdbfa18aSmrg  $opt_help || {
1193cdbfa18aSmrg    # Sanity checks first:
1194cdbfa18aSmrg    func_check_version_match
1195d5c3dbf1Smrg
1196cdbfa18aSmrg    if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
1197cdbfa18aSmrg      func_fatal_configuration "not configured to build any kind of library"
1198d5c3dbf1Smrg    fi
1199d5c3dbf1Smrg
1200cdbfa18aSmrg    # Darwin sucks
1201cdbfa18aSmrg    eval std_shrext=\"$shrext_cmds\"
1202d5c3dbf1Smrg
1203cdbfa18aSmrg    # Only execute mode is allowed to have -dlopen flags.
1204cdbfa18aSmrg    if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
1205cdbfa18aSmrg      func_error "unrecognized option \`-dlopen'"
1206cdbfa18aSmrg      $ECHO "$help" 1>&2
1207cdbfa18aSmrg      exit $EXIT_FAILURE
1208cdbfa18aSmrg    fi
1209d5c3dbf1Smrg
1210cdbfa18aSmrg    # Change the help message to a mode-specific one.
1211cdbfa18aSmrg    generic_help="$help"
1212cdbfa18aSmrg    help="Try \`$progname --help --mode=$opt_mode' for more information."
1213cdbfa18aSmrg  }
1214d5c3dbf1Smrg
1215d5c3dbf1Smrg
1216cdbfa18aSmrg  # Bail if the options were screwed
1217cdbfa18aSmrg  $exit_cmd $EXIT_FAILURE
1218cdbfa18aSmrg}
1219d5c3dbf1Smrg
1220d5c3dbf1Smrg
12219f606849Smrg
12229f606849Smrg
1223cdbfa18aSmrg## ----------- ##
1224cdbfa18aSmrg##    Main.    ##
1225cdbfa18aSmrg## ----------- ##
12269f606849Smrg
1227d5c3dbf1Smrg# func_lalib_p file
1228d5c3dbf1Smrg# True iff FILE is a libtool `.la' library or `.lo' object file.
1229d5c3dbf1Smrg# This function is only a basic sanity check; it will hardly flush out
1230d5c3dbf1Smrg# determined imposters.
1231d5c3dbf1Smrgfunc_lalib_p ()
1232d5c3dbf1Smrg{
1233d5c3dbf1Smrg    test -f "$1" &&
1234d5c3dbf1Smrg      $SED -e 4q "$1" 2>/dev/null \
1235d5c3dbf1Smrg        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
1236d5c3dbf1Smrg}
12379f606849Smrg
1238d5c3dbf1Smrg# func_lalib_unsafe_p file
1239d5c3dbf1Smrg# True iff FILE is a libtool `.la' library or `.lo' object file.
1240d5c3dbf1Smrg# This function implements the same check as func_lalib_p without
1241d5c3dbf1Smrg# resorting to external programs.  To this end, it redirects stdin and
1242d5c3dbf1Smrg# closes it afterwards, without saving the original file descriptor.
1243d5c3dbf1Smrg# As a safety measure, use it only where a negative result would be
1244d5c3dbf1Smrg# fatal anyway.  Works if `file' does not exist.
1245d5c3dbf1Smrgfunc_lalib_unsafe_p ()
1246d5c3dbf1Smrg{
1247d5c3dbf1Smrg    lalib_p=no
1248d5c3dbf1Smrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
1249d5c3dbf1Smrg	for lalib_p_l in 1 2 3 4
1250d5c3dbf1Smrg	do
1251d5c3dbf1Smrg	    read lalib_p_line
1252d5c3dbf1Smrg	    case "$lalib_p_line" in
1253d5c3dbf1Smrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
1254d5c3dbf1Smrg	    esac
1255d5c3dbf1Smrg	done
1256d5c3dbf1Smrg	exec 0<&5 5<&-
1257d5c3dbf1Smrg    fi
1258d5c3dbf1Smrg    test "$lalib_p" = yes
1259d5c3dbf1Smrg}
12609f606849Smrg
1261d5c3dbf1Smrg# func_ltwrapper_script_p file
1262d5c3dbf1Smrg# True iff FILE is a libtool wrapper script
1263d5c3dbf1Smrg# This function is only a basic sanity check; it will hardly flush out
1264d5c3dbf1Smrg# determined imposters.
1265d5c3dbf1Smrgfunc_ltwrapper_script_p ()
1266d5c3dbf1Smrg{
1267d5c3dbf1Smrg    func_lalib_p "$1"
1268d5c3dbf1Smrg}
12699f606849Smrg
1270d5c3dbf1Smrg# func_ltwrapper_executable_p file
1271d5c3dbf1Smrg# True iff FILE is a libtool wrapper executable
1272d5c3dbf1Smrg# This function is only a basic sanity check; it will hardly flush out
1273d5c3dbf1Smrg# determined imposters.
1274d5c3dbf1Smrgfunc_ltwrapper_executable_p ()
1275d5c3dbf1Smrg{
1276d5c3dbf1Smrg    func_ltwrapper_exec_suffix=
1277d5c3dbf1Smrg    case $1 in
1278d5c3dbf1Smrg    *.exe) ;;
1279d5c3dbf1Smrg    *) func_ltwrapper_exec_suffix=.exe ;;
1280d5c3dbf1Smrg    esac
1281d5c3dbf1Smrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
1282d5c3dbf1Smrg}
1283d5c3dbf1Smrg
1284d5c3dbf1Smrg# func_ltwrapper_scriptname file
1285d5c3dbf1Smrg# Assumes file is an ltwrapper_executable
1286d5c3dbf1Smrg# uses $file to determine the appropriate filename for a
1287d5c3dbf1Smrg# temporary ltwrapper_script.
1288d5c3dbf1Smrgfunc_ltwrapper_scriptname ()
1289d5c3dbf1Smrg{
1290cdbfa18aSmrg    func_dirname_and_basename "$1" "" "."
1291cdbfa18aSmrg    func_stripname '' '.exe' "$func_basename_result"
1292cdbfa18aSmrg    func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
1293d5c3dbf1Smrg}
1294d5c3dbf1Smrg
1295d5c3dbf1Smrg# func_ltwrapper_p file
1296d5c3dbf1Smrg# True iff FILE is a libtool wrapper script or wrapper executable
1297d5c3dbf1Smrg# This function is only a basic sanity check; it will hardly flush out
1298d5c3dbf1Smrg# determined imposters.
1299d5c3dbf1Smrgfunc_ltwrapper_p ()
1300d5c3dbf1Smrg{
1301d5c3dbf1Smrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
1302d5c3dbf1Smrg}
1303d5c3dbf1Smrg
1304d5c3dbf1Smrg
1305d5c3dbf1Smrg# func_execute_cmds commands fail_cmd
1306d5c3dbf1Smrg# Execute tilde-delimited COMMANDS.
1307d5c3dbf1Smrg# If FAIL_CMD is given, eval that upon failure.
1308d5c3dbf1Smrg# FAIL_CMD may read-access the current command in variable CMD!
1309d5c3dbf1Smrgfunc_execute_cmds ()
1310d5c3dbf1Smrg{
1311d5c3dbf1Smrg    $opt_debug
1312d5c3dbf1Smrg    save_ifs=$IFS; IFS='~'
1313d5c3dbf1Smrg    for cmd in $1; do
1314d5c3dbf1Smrg      IFS=$save_ifs
1315d5c3dbf1Smrg      eval cmd=\"$cmd\"
1316d5c3dbf1Smrg      func_show_eval "$cmd" "${2-:}"
1317d5c3dbf1Smrg    done
1318d5c3dbf1Smrg    IFS=$save_ifs
1319d5c3dbf1Smrg}
1320d5c3dbf1Smrg
1321d5c3dbf1Smrg
1322d5c3dbf1Smrg# func_source file
1323d5c3dbf1Smrg# Source FILE, adding directory component if necessary.
1324d5c3dbf1Smrg# Note that it is not necessary on cygwin/mingw to append a dot to
1325d5c3dbf1Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
1326d5c3dbf1Smrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
1327d5c3dbf1Smrg# `FILE.' does not work on cygwin managed mounts.
1328d5c3dbf1Smrgfunc_source ()
1329d5c3dbf1Smrg{
1330d5c3dbf1Smrg    $opt_debug
1331d5c3dbf1Smrg    case $1 in
1332d5c3dbf1Smrg    */* | *\\*)	. "$1" ;;
1333d5c3dbf1Smrg    *)		. "./$1" ;;
1334d5c3dbf1Smrg    esac
1335d5c3dbf1Smrg}
1336d5c3dbf1Smrg
1337d5c3dbf1Smrg
1338cdbfa18aSmrg# func_resolve_sysroot PATH
1339cdbfa18aSmrg# Replace a leading = in PATH with a sysroot.  Store the result into
1340cdbfa18aSmrg# func_resolve_sysroot_result
1341cdbfa18aSmrgfunc_resolve_sysroot ()
1342cdbfa18aSmrg{
1343cdbfa18aSmrg  func_resolve_sysroot_result=$1
1344cdbfa18aSmrg  case $func_resolve_sysroot_result in
1345cdbfa18aSmrg  =*)
1346cdbfa18aSmrg    func_stripname '=' '' "$func_resolve_sysroot_result"
1347cdbfa18aSmrg    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
1348cdbfa18aSmrg    ;;
1349cdbfa18aSmrg  esac
1350cdbfa18aSmrg}
1351cdbfa18aSmrg
1352cdbfa18aSmrg# func_replace_sysroot PATH
1353cdbfa18aSmrg# If PATH begins with the sysroot, replace it with = and
1354cdbfa18aSmrg# store the result into func_replace_sysroot_result.
1355cdbfa18aSmrgfunc_replace_sysroot ()
1356cdbfa18aSmrg{
1357cdbfa18aSmrg  case "$lt_sysroot:$1" in
1358cdbfa18aSmrg  ?*:"$lt_sysroot"*)
1359cdbfa18aSmrg    func_stripname "$lt_sysroot" '' "$1"
1360cdbfa18aSmrg    func_replace_sysroot_result="=$func_stripname_result"
1361cdbfa18aSmrg    ;;
1362cdbfa18aSmrg  *)
1363cdbfa18aSmrg    # Including no sysroot.
1364cdbfa18aSmrg    func_replace_sysroot_result=$1
1365cdbfa18aSmrg    ;;
1366cdbfa18aSmrg  esac
1367cdbfa18aSmrg}
1368cdbfa18aSmrg
1369d5c3dbf1Smrg# func_infer_tag arg
1370d5c3dbf1Smrg# Infer tagged configuration to use if any are available and
1371d5c3dbf1Smrg# if one wasn't chosen via the "--tag" command line option.
1372d5c3dbf1Smrg# Only attempt this if the compiler in the base compile
1373d5c3dbf1Smrg# command doesn't match the default compiler.
1374d5c3dbf1Smrg# arg is usually of the form 'gcc ...'
1375d5c3dbf1Smrgfunc_infer_tag ()
1376d5c3dbf1Smrg{
1377d5c3dbf1Smrg    $opt_debug
1378d5c3dbf1Smrg    if test -n "$available_tags" && test -z "$tagname"; then
1379d5c3dbf1Smrg      CC_quoted=
1380d5c3dbf1Smrg      for arg in $CC; do
1381cdbfa18aSmrg	func_append_quoted CC_quoted "$arg"
1382d5c3dbf1Smrg      done
1383d5c3dbf1Smrg      CC_expanded=`func_echo_all $CC`
1384d5c3dbf1Smrg      CC_quoted_expanded=`func_echo_all $CC_quoted`
1385d5c3dbf1Smrg      case $@ in
1386d5c3dbf1Smrg      # Blanks in the command may have been stripped by the calling shell,
1387d5c3dbf1Smrg      # but not from the CC environment variable when configure was run.
1388d5c3dbf1Smrg      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1389d5c3dbf1Smrg      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
1390d5c3dbf1Smrg      # Blanks at the start of $base_compile will cause this to fail
1391d5c3dbf1Smrg      # if we don't check for them as well.
1392d5c3dbf1Smrg      *)
1393d5c3dbf1Smrg	for z in $available_tags; do
1394d5c3dbf1Smrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
1395d5c3dbf1Smrg	    # Evaluate the configuration.
1396d5c3dbf1Smrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
1397d5c3dbf1Smrg	    CC_quoted=
1398d5c3dbf1Smrg	    for arg in $CC; do
1399d5c3dbf1Smrg	      # Double-quote args containing other shell metacharacters.
1400cdbfa18aSmrg	      func_append_quoted CC_quoted "$arg"
1401d5c3dbf1Smrg	    done
1402d5c3dbf1Smrg	    CC_expanded=`func_echo_all $CC`
1403d5c3dbf1Smrg	    CC_quoted_expanded=`func_echo_all $CC_quoted`
1404d5c3dbf1Smrg	    case "$@ " in
1405d5c3dbf1Smrg	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1406d5c3dbf1Smrg	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
1407d5c3dbf1Smrg	      # The compiler in the base compile command matches
1408d5c3dbf1Smrg	      # the one in the tagged configuration.
1409d5c3dbf1Smrg	      # Assume this is the tagged configuration we want.
1410d5c3dbf1Smrg	      tagname=$z
1411d5c3dbf1Smrg	      break
1412d5c3dbf1Smrg	      ;;
1413d5c3dbf1Smrg	    esac
1414d5c3dbf1Smrg	  fi
1415d5c3dbf1Smrg	done
1416d5c3dbf1Smrg	# If $tagname still isn't set, then no tagged configuration
1417d5c3dbf1Smrg	# was found and let the user know that the "--tag" command
1418d5c3dbf1Smrg	# line option must be used.
1419d5c3dbf1Smrg	if test -z "$tagname"; then
1420d5c3dbf1Smrg	  func_echo "unable to infer tagged configuration"
1421d5c3dbf1Smrg	  func_fatal_error "specify a tag with \`--tag'"
1422d5c3dbf1Smrg#	else
1423d5c3dbf1Smrg#	  func_verbose "using $tagname tagged configuration"
1424d5c3dbf1Smrg	fi
1425d5c3dbf1Smrg	;;
1426d5c3dbf1Smrg      esac
1427d5c3dbf1Smrg    fi
1428d5c3dbf1Smrg}
1429d5c3dbf1Smrg
1430d5c3dbf1Smrg
1431cdbfa18aSmrg
1432cdbfa18aSmrg# func_write_libtool_object output_name pic_name nonpic_name
1433cdbfa18aSmrg# Create a libtool object file (analogous to a ".la" file),
1434cdbfa18aSmrg# but don't create it if we're doing a dry run.
1435cdbfa18aSmrgfunc_write_libtool_object ()
1436cdbfa18aSmrg{
1437cdbfa18aSmrg    write_libobj=${1}
1438cdbfa18aSmrg    if test "$build_libtool_libs" = yes; then
1439cdbfa18aSmrg      write_lobj=\'${2}\'
1440cdbfa18aSmrg    else
1441cdbfa18aSmrg      write_lobj=none
1442cdbfa18aSmrg    fi
1443cdbfa18aSmrg
1444cdbfa18aSmrg    if test "$build_old_libs" = yes; then
1445cdbfa18aSmrg      write_oldobj=\'${3}\'
1446cdbfa18aSmrg    else
1447cdbfa18aSmrg      write_oldobj=none
1448cdbfa18aSmrg    fi
1449cdbfa18aSmrg
1450cdbfa18aSmrg    $opt_dry_run || {
1451cdbfa18aSmrg      cat >${write_libobj}T <<EOF
1452cdbfa18aSmrg# $write_libobj - a libtool object file
1453cdbfa18aSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1454cdbfa18aSmrg#
1455cdbfa18aSmrg# Please DO NOT delete this file!
1456cdbfa18aSmrg# It is necessary for linking the library.
1457cdbfa18aSmrg
1458cdbfa18aSmrg# Name of the PIC object.
1459cdbfa18aSmrgpic_object=$write_lobj
1460cdbfa18aSmrg
1461cdbfa18aSmrg# Name of the non-PIC object
1462cdbfa18aSmrgnon_pic_object=$write_oldobj
1463cdbfa18aSmrg
1464cdbfa18aSmrgEOF
1465cdbfa18aSmrg      $MV "${write_libobj}T" "${write_libobj}"
1466cdbfa18aSmrg    }
1467cdbfa18aSmrg}
1468cdbfa18aSmrg
1469cdbfa18aSmrg
1470cdbfa18aSmrg##################################################
1471cdbfa18aSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
1472cdbfa18aSmrg##################################################
1473cdbfa18aSmrg
1474cdbfa18aSmrg# func_convert_core_file_wine_to_w32 ARG
1475cdbfa18aSmrg# Helper function used by file name conversion functions when $build is *nix,
1476cdbfa18aSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a
1477cdbfa18aSmrg# correctly configured wine environment available, with the winepath program
1478cdbfa18aSmrg# in $build's $PATH.
1479cdbfa18aSmrg#
1480cdbfa18aSmrg# ARG is the $build file name to be converted to w32 format.
1481cdbfa18aSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will
1482cdbfa18aSmrg# be empty on error (or when ARG is empty)
1483cdbfa18aSmrgfunc_convert_core_file_wine_to_w32 ()
1484cdbfa18aSmrg{
1485cdbfa18aSmrg  $opt_debug
1486cdbfa18aSmrg  func_convert_core_file_wine_to_w32_result="$1"
1487cdbfa18aSmrg  if test -n "$1"; then
1488cdbfa18aSmrg    # Unfortunately, winepath does not exit with a non-zero error code, so we
1489cdbfa18aSmrg    # are forced to check the contents of stdout. On the other hand, if the
1490cdbfa18aSmrg    # command is not found, the shell will set an exit code of 127 and print
1491cdbfa18aSmrg    # *an error message* to stdout. So we must check for both error code of
1492cdbfa18aSmrg    # zero AND non-empty stdout, which explains the odd construction:
1493cdbfa18aSmrg    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
1494cdbfa18aSmrg    if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
1495cdbfa18aSmrg      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
1496cdbfa18aSmrg        $SED -e "$lt_sed_naive_backslashify"`
1497cdbfa18aSmrg    else
1498cdbfa18aSmrg      func_convert_core_file_wine_to_w32_result=
1499cdbfa18aSmrg    fi
1500cdbfa18aSmrg  fi
1501cdbfa18aSmrg}
1502cdbfa18aSmrg# end: func_convert_core_file_wine_to_w32
1503cdbfa18aSmrg
1504cdbfa18aSmrg
1505cdbfa18aSmrg# func_convert_core_path_wine_to_w32 ARG
1506cdbfa18aSmrg# Helper function used by path conversion functions when $build is *nix, and
1507cdbfa18aSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
1508cdbfa18aSmrg# configured wine environment available, with the winepath program in $build's
1509cdbfa18aSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters.
1510cdbfa18aSmrg#
1511cdbfa18aSmrg# ARG is path to be converted from $build format to win32.
1512cdbfa18aSmrg# Result is available in $func_convert_core_path_wine_to_w32_result.
1513cdbfa18aSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names
1514cdbfa18aSmrg# are convertible, then the result may be empty.
1515cdbfa18aSmrgfunc_convert_core_path_wine_to_w32 ()
1516cdbfa18aSmrg{
1517cdbfa18aSmrg  $opt_debug
1518cdbfa18aSmrg  # unfortunately, winepath doesn't convert paths, only file names
1519cdbfa18aSmrg  func_convert_core_path_wine_to_w32_result=""
1520cdbfa18aSmrg  if test -n "$1"; then
1521cdbfa18aSmrg    oldIFS=$IFS
1522cdbfa18aSmrg    IFS=:
1523cdbfa18aSmrg    for func_convert_core_path_wine_to_w32_f in $1; do
1524cdbfa18aSmrg      IFS=$oldIFS
1525cdbfa18aSmrg      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
1526cdbfa18aSmrg      if test -n "$func_convert_core_file_wine_to_w32_result" ; then
1527cdbfa18aSmrg        if test -z "$func_convert_core_path_wine_to_w32_result"; then
1528cdbfa18aSmrg          func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
1529cdbfa18aSmrg        else
1530cdbfa18aSmrg          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
1531cdbfa18aSmrg        fi
1532cdbfa18aSmrg      fi
1533cdbfa18aSmrg    done
1534cdbfa18aSmrg    IFS=$oldIFS
1535cdbfa18aSmrg  fi
1536cdbfa18aSmrg}
1537cdbfa18aSmrg# end: func_convert_core_path_wine_to_w32
1538cdbfa18aSmrg
1539cdbfa18aSmrg
1540cdbfa18aSmrg# func_cygpath ARGS...
1541cdbfa18aSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
1542cdbfa18aSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
1543cdbfa18aSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
1544cdbfa18aSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input
1545cdbfa18aSmrg# file name or path is assumed to be in w32 format, as previously converted
1546cdbfa18aSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name
1547cdbfa18aSmrg# or path in func_cygpath_result (input file name or path is assumed to be in
1548cdbfa18aSmrg# Cygwin format). Returns an empty string on error.
1549cdbfa18aSmrg#
1550cdbfa18aSmrg# ARGS are passed to cygpath, with the last one being the file name or path to
1551cdbfa18aSmrg# be converted.
1552cdbfa18aSmrg#
1553cdbfa18aSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
1554cdbfa18aSmrg# environment variable; do not put it in $PATH.
1555cdbfa18aSmrgfunc_cygpath ()
1556cdbfa18aSmrg{
1557cdbfa18aSmrg  $opt_debug
1558cdbfa18aSmrg  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
1559cdbfa18aSmrg    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
1560cdbfa18aSmrg    if test "$?" -ne 0; then
1561cdbfa18aSmrg      # on failure, ensure result is empty
1562cdbfa18aSmrg      func_cygpath_result=
1563cdbfa18aSmrg    fi
1564cdbfa18aSmrg  else
1565cdbfa18aSmrg    func_cygpath_result=
1566cdbfa18aSmrg    func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
1567cdbfa18aSmrg  fi
1568cdbfa18aSmrg}
1569cdbfa18aSmrg#end: func_cygpath
1570cdbfa18aSmrg
1571cdbfa18aSmrg
1572cdbfa18aSmrg# func_convert_core_msys_to_w32 ARG
1573cdbfa18aSmrg# Convert file name or path ARG from MSYS format to w32 format.  Return
1574cdbfa18aSmrg# result in func_convert_core_msys_to_w32_result.
1575cdbfa18aSmrgfunc_convert_core_msys_to_w32 ()
1576cdbfa18aSmrg{
1577cdbfa18aSmrg  $opt_debug
1578cdbfa18aSmrg  # awkward: cmd appends spaces to result
1579cdbfa18aSmrg  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
1580cdbfa18aSmrg    $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
1581cdbfa18aSmrg}
1582cdbfa18aSmrg#end: func_convert_core_msys_to_w32
1583cdbfa18aSmrg
1584cdbfa18aSmrg
1585cdbfa18aSmrg# func_convert_file_check ARG1 ARG2
1586cdbfa18aSmrg# Verify that ARG1 (a file name in $build format) was converted to $host
1587cdbfa18aSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting
1588cdbfa18aSmrg# func_to_host_file_result to ARG1).
1589cdbfa18aSmrgfunc_convert_file_check ()
1590cdbfa18aSmrg{
1591cdbfa18aSmrg  $opt_debug
1592cdbfa18aSmrg  if test -z "$2" && test -n "$1" ; then
1593cdbfa18aSmrg    func_error "Could not determine host file name corresponding to"
1594cdbfa18aSmrg    func_error "  \`$1'"
1595cdbfa18aSmrg    func_error "Continuing, but uninstalled executables may not work."
1596cdbfa18aSmrg    # Fallback:
1597cdbfa18aSmrg    func_to_host_file_result="$1"
1598cdbfa18aSmrg  fi
1599cdbfa18aSmrg}
1600cdbfa18aSmrg# end func_convert_file_check
1601cdbfa18aSmrg
1602cdbfa18aSmrg
1603cdbfa18aSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
1604cdbfa18aSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host
1605cdbfa18aSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
1606cdbfa18aSmrg# func_to_host_file_result to a simplistic fallback value (see below).
1607cdbfa18aSmrgfunc_convert_path_check ()
1608cdbfa18aSmrg{
1609cdbfa18aSmrg  $opt_debug
1610cdbfa18aSmrg  if test -z "$4" && test -n "$3"; then
1611cdbfa18aSmrg    func_error "Could not determine the host path corresponding to"
1612cdbfa18aSmrg    func_error "  \`$3'"
1613cdbfa18aSmrg    func_error "Continuing, but uninstalled executables may not work."
1614cdbfa18aSmrg    # Fallback.  This is a deliberately simplistic "conversion" and
1615cdbfa18aSmrg    # should not be "improved".  See libtool.info.
1616cdbfa18aSmrg    if test "x$1" != "x$2"; then
1617cdbfa18aSmrg      lt_replace_pathsep_chars="s|$1|$2|g"
1618cdbfa18aSmrg      func_to_host_path_result=`echo "$3" |
1619cdbfa18aSmrg        $SED -e "$lt_replace_pathsep_chars"`
1620cdbfa18aSmrg    else
1621cdbfa18aSmrg      func_to_host_path_result="$3"
1622cdbfa18aSmrg    fi
1623cdbfa18aSmrg  fi
1624cdbfa18aSmrg}
1625cdbfa18aSmrg# end func_convert_path_check
1626cdbfa18aSmrg
1627cdbfa18aSmrg
1628cdbfa18aSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
1629cdbfa18aSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
1630cdbfa18aSmrg# and appending REPL if ORIG matches BACKPAT.
1631cdbfa18aSmrgfunc_convert_path_front_back_pathsep ()
1632cdbfa18aSmrg{
1633cdbfa18aSmrg  $opt_debug
1634cdbfa18aSmrg  case $4 in
1635cdbfa18aSmrg  $1 ) func_to_host_path_result="$3$func_to_host_path_result"
1636cdbfa18aSmrg    ;;
1637cdbfa18aSmrg  esac
1638cdbfa18aSmrg  case $4 in
1639cdbfa18aSmrg  $2 ) func_append func_to_host_path_result "$3"
1640cdbfa18aSmrg    ;;
1641cdbfa18aSmrg  esac
1642cdbfa18aSmrg}
1643cdbfa18aSmrg# end func_convert_path_front_back_pathsep
1644cdbfa18aSmrg
1645cdbfa18aSmrg
1646cdbfa18aSmrg##################################################
1647cdbfa18aSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS #
1648cdbfa18aSmrg##################################################
1649cdbfa18aSmrg# invoked via `$to_host_file_cmd ARG'
1650cdbfa18aSmrg#
1651cdbfa18aSmrg# In each case, ARG is the path to be converted from $build to $host format.
1652cdbfa18aSmrg# Result will be available in $func_to_host_file_result.
1653cdbfa18aSmrg
1654cdbfa18aSmrg
1655cdbfa18aSmrg# func_to_host_file ARG
1656cdbfa18aSmrg# Converts the file name ARG from $build format to $host format. Return result
1657cdbfa18aSmrg# in func_to_host_file_result.
1658cdbfa18aSmrgfunc_to_host_file ()
1659cdbfa18aSmrg{
1660cdbfa18aSmrg  $opt_debug
1661cdbfa18aSmrg  $to_host_file_cmd "$1"
1662cdbfa18aSmrg}
1663cdbfa18aSmrg# end func_to_host_file
1664cdbfa18aSmrg
1665cdbfa18aSmrg
1666cdbfa18aSmrg# func_to_tool_file ARG LAZY
1667cdbfa18aSmrg# converts the file name ARG from $build format to toolchain format. Return
1668cdbfa18aSmrg# result in func_to_tool_file_result.  If the conversion in use is listed
1669cdbfa18aSmrg# in (the comma separated) LAZY, no conversion takes place.
1670cdbfa18aSmrgfunc_to_tool_file ()
1671cdbfa18aSmrg{
1672cdbfa18aSmrg  $opt_debug
1673cdbfa18aSmrg  case ,$2, in
1674cdbfa18aSmrg    *,"$to_tool_file_cmd",*)
1675cdbfa18aSmrg      func_to_tool_file_result=$1
1676cdbfa18aSmrg      ;;
1677cdbfa18aSmrg    *)
1678cdbfa18aSmrg      $to_tool_file_cmd "$1"
1679cdbfa18aSmrg      func_to_tool_file_result=$func_to_host_file_result
1680cdbfa18aSmrg      ;;
1681cdbfa18aSmrg  esac
1682cdbfa18aSmrg}
1683cdbfa18aSmrg# end func_to_tool_file
1684cdbfa18aSmrg
1685cdbfa18aSmrg
1686cdbfa18aSmrg# func_convert_file_noop ARG
1687cdbfa18aSmrg# Copy ARG to func_to_host_file_result.
1688cdbfa18aSmrgfunc_convert_file_noop ()
1689cdbfa18aSmrg{
1690cdbfa18aSmrg  func_to_host_file_result="$1"
1691cdbfa18aSmrg}
1692cdbfa18aSmrg# end func_convert_file_noop
1693cdbfa18aSmrg
1694cdbfa18aSmrg
1695cdbfa18aSmrg# func_convert_file_msys_to_w32 ARG
1696cdbfa18aSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
1697cdbfa18aSmrg# conversion to w32 is not available inside the cwrapper.  Returns result in
1698cdbfa18aSmrg# func_to_host_file_result.
1699cdbfa18aSmrgfunc_convert_file_msys_to_w32 ()
1700cdbfa18aSmrg{
1701cdbfa18aSmrg  $opt_debug
1702cdbfa18aSmrg  func_to_host_file_result="$1"
1703cdbfa18aSmrg  if test -n "$1"; then
1704cdbfa18aSmrg    func_convert_core_msys_to_w32 "$1"
1705cdbfa18aSmrg    func_to_host_file_result="$func_convert_core_msys_to_w32_result"
1706cdbfa18aSmrg  fi
1707cdbfa18aSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1708cdbfa18aSmrg}
1709cdbfa18aSmrg# end func_convert_file_msys_to_w32
1710cdbfa18aSmrg
1711cdbfa18aSmrg
1712cdbfa18aSmrg# func_convert_file_cygwin_to_w32 ARG
1713cdbfa18aSmrg# Convert file name ARG from Cygwin to w32 format.  Returns result in
1714cdbfa18aSmrg# func_to_host_file_result.
1715cdbfa18aSmrgfunc_convert_file_cygwin_to_w32 ()
1716cdbfa18aSmrg{
1717cdbfa18aSmrg  $opt_debug
1718cdbfa18aSmrg  func_to_host_file_result="$1"
1719cdbfa18aSmrg  if test -n "$1"; then
1720cdbfa18aSmrg    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
1721cdbfa18aSmrg    # LT_CYGPATH in this case.
1722cdbfa18aSmrg    func_to_host_file_result=`cygpath -m "$1"`
1723cdbfa18aSmrg  fi
1724cdbfa18aSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1725cdbfa18aSmrg}
1726cdbfa18aSmrg# end func_convert_file_cygwin_to_w32
1727cdbfa18aSmrg
1728cdbfa18aSmrg
1729cdbfa18aSmrg# func_convert_file_nix_to_w32 ARG
1730cdbfa18aSmrg# Convert file name ARG from *nix to w32 format.  Requires a wine environment
1731cdbfa18aSmrg# and a working winepath. Returns result in func_to_host_file_result.
1732cdbfa18aSmrgfunc_convert_file_nix_to_w32 ()
1733cdbfa18aSmrg{
1734cdbfa18aSmrg  $opt_debug
1735cdbfa18aSmrg  func_to_host_file_result="$1"
1736cdbfa18aSmrg  if test -n "$1"; then
1737cdbfa18aSmrg    func_convert_core_file_wine_to_w32 "$1"
1738cdbfa18aSmrg    func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
1739cdbfa18aSmrg  fi
1740cdbfa18aSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1741cdbfa18aSmrg}
1742cdbfa18aSmrg# end func_convert_file_nix_to_w32
1743cdbfa18aSmrg
1744cdbfa18aSmrg
1745cdbfa18aSmrg# func_convert_file_msys_to_cygwin ARG
1746cdbfa18aSmrg# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
1747cdbfa18aSmrg# Returns result in func_to_host_file_result.
1748cdbfa18aSmrgfunc_convert_file_msys_to_cygwin ()
1749cdbfa18aSmrg{
1750cdbfa18aSmrg  $opt_debug
1751cdbfa18aSmrg  func_to_host_file_result="$1"
1752cdbfa18aSmrg  if test -n "$1"; then
1753cdbfa18aSmrg    func_convert_core_msys_to_w32 "$1"
1754cdbfa18aSmrg    func_cygpath -u "$func_convert_core_msys_to_w32_result"
1755cdbfa18aSmrg    func_to_host_file_result="$func_cygpath_result"
1756cdbfa18aSmrg  fi
1757cdbfa18aSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1758cdbfa18aSmrg}
1759cdbfa18aSmrg# end func_convert_file_msys_to_cygwin
1760cdbfa18aSmrg
1761cdbfa18aSmrg
1762cdbfa18aSmrg# func_convert_file_nix_to_cygwin ARG
1763cdbfa18aSmrg# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
1764cdbfa18aSmrg# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
1765cdbfa18aSmrg# in func_to_host_file_result.
1766cdbfa18aSmrgfunc_convert_file_nix_to_cygwin ()
1767cdbfa18aSmrg{
1768cdbfa18aSmrg  $opt_debug
1769cdbfa18aSmrg  func_to_host_file_result="$1"
1770cdbfa18aSmrg  if test -n "$1"; then
1771cdbfa18aSmrg    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
1772cdbfa18aSmrg    func_convert_core_file_wine_to_w32 "$1"
1773cdbfa18aSmrg    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
1774cdbfa18aSmrg    func_to_host_file_result="$func_cygpath_result"
1775cdbfa18aSmrg  fi
1776cdbfa18aSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1777cdbfa18aSmrg}
1778cdbfa18aSmrg# end func_convert_file_nix_to_cygwin
1779cdbfa18aSmrg
1780cdbfa18aSmrg
1781cdbfa18aSmrg#############################################
1782cdbfa18aSmrg# $build to $host PATH CONVERSION FUNCTIONS #
1783cdbfa18aSmrg#############################################
1784cdbfa18aSmrg# invoked via `$to_host_path_cmd ARG'
1785cdbfa18aSmrg#
1786cdbfa18aSmrg# In each case, ARG is the path to be converted from $build to $host format.
1787cdbfa18aSmrg# The result will be available in $func_to_host_path_result.
1788cdbfa18aSmrg#
1789cdbfa18aSmrg# Path separators are also converted from $build format to $host format.  If
1790cdbfa18aSmrg# ARG begins or ends with a path separator character, it is preserved (but
1791cdbfa18aSmrg# converted to $host format) on output.
1792cdbfa18aSmrg#
1793cdbfa18aSmrg# All path conversion functions are named using the following convention:
1794cdbfa18aSmrg#   file name conversion function    : func_convert_file_X_to_Y ()
1795cdbfa18aSmrg#   path conversion function         : func_convert_path_X_to_Y ()
1796cdbfa18aSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the
1797cdbfa18aSmrg# same.  If conversion functions are added for new $build/$host combinations,
1798cdbfa18aSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd
1799cdbfa18aSmrg# will break.
1800cdbfa18aSmrg
1801cdbfa18aSmrg
1802cdbfa18aSmrg# func_init_to_host_path_cmd
1803cdbfa18aSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the
1804cdbfa18aSmrg# appropriate value, based on the value of $to_host_file_cmd.
1805cdbfa18aSmrgto_host_path_cmd=
1806cdbfa18aSmrgfunc_init_to_host_path_cmd ()
1807cdbfa18aSmrg{
1808cdbfa18aSmrg  $opt_debug
1809cdbfa18aSmrg  if test -z "$to_host_path_cmd"; then
1810cdbfa18aSmrg    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
1811cdbfa18aSmrg    to_host_path_cmd="func_convert_path_${func_stripname_result}"
1812cdbfa18aSmrg  fi
1813cdbfa18aSmrg}
1814cdbfa18aSmrg
1815cdbfa18aSmrg
1816cdbfa18aSmrg# func_to_host_path ARG
1817cdbfa18aSmrg# Converts the path ARG from $build format to $host format. Return result
1818cdbfa18aSmrg# in func_to_host_path_result.
1819cdbfa18aSmrgfunc_to_host_path ()
1820cdbfa18aSmrg{
1821cdbfa18aSmrg  $opt_debug
1822cdbfa18aSmrg  func_init_to_host_path_cmd
1823cdbfa18aSmrg  $to_host_path_cmd "$1"
1824cdbfa18aSmrg}
1825cdbfa18aSmrg# end func_to_host_path
1826cdbfa18aSmrg
1827cdbfa18aSmrg
1828cdbfa18aSmrg# func_convert_path_noop ARG
1829cdbfa18aSmrg# Copy ARG to func_to_host_path_result.
1830cdbfa18aSmrgfunc_convert_path_noop ()
1831cdbfa18aSmrg{
1832cdbfa18aSmrg  func_to_host_path_result="$1"
1833cdbfa18aSmrg}
1834cdbfa18aSmrg# end func_convert_path_noop
1835cdbfa18aSmrg
1836cdbfa18aSmrg
1837cdbfa18aSmrg# func_convert_path_msys_to_w32 ARG
1838cdbfa18aSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
1839cdbfa18aSmrg# conversion to w32 is not available inside the cwrapper.  Returns result in
1840cdbfa18aSmrg# func_to_host_path_result.
1841cdbfa18aSmrgfunc_convert_path_msys_to_w32 ()
1842cdbfa18aSmrg{
1843cdbfa18aSmrg  $opt_debug
1844cdbfa18aSmrg  func_to_host_path_result="$1"
1845cdbfa18aSmrg  if test -n "$1"; then
1846cdbfa18aSmrg    # Remove leading and trailing path separator characters from ARG.  MSYS
1847cdbfa18aSmrg    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
1848cdbfa18aSmrg    # and winepath ignores them completely.
1849cdbfa18aSmrg    func_stripname : : "$1"
1850cdbfa18aSmrg    func_to_host_path_tmp1=$func_stripname_result
1851cdbfa18aSmrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1852cdbfa18aSmrg    func_to_host_path_result="$func_convert_core_msys_to_w32_result"
1853cdbfa18aSmrg    func_convert_path_check : ";" \
1854cdbfa18aSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1855cdbfa18aSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1856cdbfa18aSmrg  fi
1857cdbfa18aSmrg}
1858cdbfa18aSmrg# end func_convert_path_msys_to_w32
1859cdbfa18aSmrg
1860cdbfa18aSmrg
1861cdbfa18aSmrg# func_convert_path_cygwin_to_w32 ARG
1862cdbfa18aSmrg# Convert path ARG from Cygwin to w32 format.  Returns result in
1863cdbfa18aSmrg# func_to_host_file_result.
1864cdbfa18aSmrgfunc_convert_path_cygwin_to_w32 ()
1865cdbfa18aSmrg{
1866cdbfa18aSmrg  $opt_debug
1867cdbfa18aSmrg  func_to_host_path_result="$1"
1868cdbfa18aSmrg  if test -n "$1"; then
1869cdbfa18aSmrg    # See func_convert_path_msys_to_w32:
1870cdbfa18aSmrg    func_stripname : : "$1"
1871cdbfa18aSmrg    func_to_host_path_tmp1=$func_stripname_result
1872cdbfa18aSmrg    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
1873cdbfa18aSmrg    func_convert_path_check : ";" \
1874cdbfa18aSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1875cdbfa18aSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1876cdbfa18aSmrg  fi
1877cdbfa18aSmrg}
1878cdbfa18aSmrg# end func_convert_path_cygwin_to_w32
1879cdbfa18aSmrg
1880cdbfa18aSmrg
1881cdbfa18aSmrg# func_convert_path_nix_to_w32 ARG
1882cdbfa18aSmrg# Convert path ARG from *nix to w32 format.  Requires a wine environment and
1883cdbfa18aSmrg# a working winepath.  Returns result in func_to_host_file_result.
1884cdbfa18aSmrgfunc_convert_path_nix_to_w32 ()
1885d5c3dbf1Smrg{
1886cdbfa18aSmrg  $opt_debug
1887cdbfa18aSmrg  func_to_host_path_result="$1"
1888cdbfa18aSmrg  if test -n "$1"; then
1889cdbfa18aSmrg    # See func_convert_path_msys_to_w32:
1890cdbfa18aSmrg    func_stripname : : "$1"
1891cdbfa18aSmrg    func_to_host_path_tmp1=$func_stripname_result
1892cdbfa18aSmrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1893cdbfa18aSmrg    func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
1894cdbfa18aSmrg    func_convert_path_check : ";" \
1895cdbfa18aSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1896cdbfa18aSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1897cdbfa18aSmrg  fi
1898cdbfa18aSmrg}
1899cdbfa18aSmrg# end func_convert_path_nix_to_w32
1900d5c3dbf1Smrg
1901d5c3dbf1Smrg
1902cdbfa18aSmrg# func_convert_path_msys_to_cygwin ARG
1903cdbfa18aSmrg# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
1904cdbfa18aSmrg# Returns result in func_to_host_file_result.
1905cdbfa18aSmrgfunc_convert_path_msys_to_cygwin ()
1906cdbfa18aSmrg{
1907cdbfa18aSmrg  $opt_debug
1908cdbfa18aSmrg  func_to_host_path_result="$1"
1909cdbfa18aSmrg  if test -n "$1"; then
1910cdbfa18aSmrg    # See func_convert_path_msys_to_w32:
1911cdbfa18aSmrg    func_stripname : : "$1"
1912cdbfa18aSmrg    func_to_host_path_tmp1=$func_stripname_result
1913cdbfa18aSmrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1914cdbfa18aSmrg    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
1915cdbfa18aSmrg    func_to_host_path_result="$func_cygpath_result"
1916cdbfa18aSmrg    func_convert_path_check : : \
1917cdbfa18aSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1918cdbfa18aSmrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1919cdbfa18aSmrg  fi
1920cdbfa18aSmrg}
1921cdbfa18aSmrg# end func_convert_path_msys_to_cygwin
1922d5c3dbf1Smrg
1923d5c3dbf1Smrg
1924cdbfa18aSmrg# func_convert_path_nix_to_cygwin ARG
1925cdbfa18aSmrg# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
1926cdbfa18aSmrg# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
1927cdbfa18aSmrg# func_to_host_file_result.
1928cdbfa18aSmrgfunc_convert_path_nix_to_cygwin ()
1929cdbfa18aSmrg{
1930cdbfa18aSmrg  $opt_debug
1931cdbfa18aSmrg  func_to_host_path_result="$1"
1932cdbfa18aSmrg  if test -n "$1"; then
1933cdbfa18aSmrg    # Remove leading and trailing path separator characters from
1934cdbfa18aSmrg    # ARG. msys behavior is inconsistent here, cygpath turns them
1935cdbfa18aSmrg    # into '.;' and ';.', and winepath ignores them completely.
1936cdbfa18aSmrg    func_stripname : : "$1"
1937cdbfa18aSmrg    func_to_host_path_tmp1=$func_stripname_result
1938cdbfa18aSmrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1939cdbfa18aSmrg    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
1940cdbfa18aSmrg    func_to_host_path_result="$func_cygpath_result"
1941cdbfa18aSmrg    func_convert_path_check : : \
1942cdbfa18aSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1943cdbfa18aSmrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1944cdbfa18aSmrg  fi
1945d5c3dbf1Smrg}
1946cdbfa18aSmrg# end func_convert_path_nix_to_cygwin
1947cdbfa18aSmrg
1948d5c3dbf1Smrg
1949d5c3dbf1Smrg# func_mode_compile arg...
1950d5c3dbf1Smrgfunc_mode_compile ()
1951d5c3dbf1Smrg{
1952d5c3dbf1Smrg    $opt_debug
1953d5c3dbf1Smrg    # Get the compilation command and the source file.
1954d5c3dbf1Smrg    base_compile=
1955d5c3dbf1Smrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
1956d5c3dbf1Smrg    suppress_opt=yes
1957d5c3dbf1Smrg    suppress_output=
1958d5c3dbf1Smrg    arg_mode=normal
1959d5c3dbf1Smrg    libobj=
1960d5c3dbf1Smrg    later=
1961d5c3dbf1Smrg    pie_flag=
1962d5c3dbf1Smrg
1963d5c3dbf1Smrg    for arg
1964d5c3dbf1Smrg    do
1965d5c3dbf1Smrg      case $arg_mode in
1966d5c3dbf1Smrg      arg  )
1967d5c3dbf1Smrg	# do not "continue".  Instead, add this to base_compile
1968d5c3dbf1Smrg	lastarg="$arg"
1969d5c3dbf1Smrg	arg_mode=normal
1970d5c3dbf1Smrg	;;
1971d5c3dbf1Smrg
1972d5c3dbf1Smrg      target )
1973d5c3dbf1Smrg	libobj="$arg"
1974d5c3dbf1Smrg	arg_mode=normal
1975d5c3dbf1Smrg	continue
1976d5c3dbf1Smrg	;;
1977d5c3dbf1Smrg
1978d5c3dbf1Smrg      normal )
1979d5c3dbf1Smrg	# Accept any command-line options.
1980d5c3dbf1Smrg	case $arg in
1981d5c3dbf1Smrg	-o)
1982d5c3dbf1Smrg	  test -n "$libobj" && \
1983d5c3dbf1Smrg	    func_fatal_error "you cannot specify \`-o' more than once"
1984d5c3dbf1Smrg	  arg_mode=target
1985d5c3dbf1Smrg	  continue
1986d5c3dbf1Smrg	  ;;
1987d5c3dbf1Smrg
1988d5c3dbf1Smrg	-pie | -fpie | -fPIE)
1989cdbfa18aSmrg          func_append pie_flag " $arg"
1990d5c3dbf1Smrg	  continue
1991d5c3dbf1Smrg	  ;;
1992d5c3dbf1Smrg
1993d5c3dbf1Smrg	-shared | -static | -prefer-pic | -prefer-non-pic)
1994cdbfa18aSmrg	  func_append later " $arg"
1995d5c3dbf1Smrg	  continue
1996d5c3dbf1Smrg	  ;;
19979f606849Smrg
19989f606849Smrg	-no-suppress)
19999f606849Smrg	  suppress_opt=no
20009f606849Smrg	  continue
20019f606849Smrg	  ;;
20029f606849Smrg
20039f606849Smrg	-Xcompiler)
20049f606849Smrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
20059f606849Smrg	  continue      #  The current "srcfile" will either be retained or
20069f606849Smrg	  ;;            #  replaced later.  I would guess that would be a bug.
20079f606849Smrg
20089f606849Smrg	-Wc,*)
2009d5c3dbf1Smrg	  func_stripname '-Wc,' '' "$arg"
2010d5c3dbf1Smrg	  args=$func_stripname_result
20119f606849Smrg	  lastarg=
20129f606849Smrg	  save_ifs="$IFS"; IFS=','
2013d5c3dbf1Smrg	  for arg in $args; do
20149f606849Smrg	    IFS="$save_ifs"
2015cdbfa18aSmrg	    func_append_quoted lastarg "$arg"
20169f606849Smrg	  done
20179f606849Smrg	  IFS="$save_ifs"
2018d5c3dbf1Smrg	  func_stripname ' ' '' "$lastarg"
2019d5c3dbf1Smrg	  lastarg=$func_stripname_result
20209f606849Smrg
20219f606849Smrg	  # Add the arguments to base_compile.
2022cdbfa18aSmrg	  func_append base_compile " $lastarg"
20239f606849Smrg	  continue
20249f606849Smrg	  ;;
20259f606849Smrg
2026d5c3dbf1Smrg	*)
20279f606849Smrg	  # Accept the current argument as the source file.
20289f606849Smrg	  # The previous "srcfile" becomes the current argument.
20299f606849Smrg	  #
20309f606849Smrg	  lastarg="$srcfile"
20319f606849Smrg	  srcfile="$arg"
20329f606849Smrg	  ;;
20339f606849Smrg	esac  #  case $arg
20349f606849Smrg	;;
20359f606849Smrg      esac    #  case $arg_mode
20369f606849Smrg
20379f606849Smrg      # Aesthetically quote the previous argument.
2038cdbfa18aSmrg      func_append_quoted base_compile "$lastarg"
20399f606849Smrg    done # for arg
20409f606849Smrg
20419f606849Smrg    case $arg_mode in
20429f606849Smrg    arg)
2043d5c3dbf1Smrg      func_fatal_error "you must specify an argument for -Xcompile"
20449f606849Smrg      ;;
20459f606849Smrg    target)
2046d5c3dbf1Smrg      func_fatal_error "you must specify a target with \`-o'"
20479f606849Smrg      ;;
20489f606849Smrg    *)
20499f606849Smrg      # Get the name of the library object.
2050d5c3dbf1Smrg      test -z "$libobj" && {
2051d5c3dbf1Smrg	func_basename "$srcfile"
2052d5c3dbf1Smrg	libobj="$func_basename_result"
2053d5c3dbf1Smrg      }
20549f606849Smrg      ;;
20559f606849Smrg    esac
20569f606849Smrg
20579f606849Smrg    # Recognize several different file suffixes.
20589f606849Smrg    # If the user specifies -o file.o, it is replaced with file.lo
20599f606849Smrg    case $libobj in
2060d5c3dbf1Smrg    *.[cCFSifmso] | \
2061d5c3dbf1Smrg    *.ada | *.adb | *.ads | *.asm | \
2062d5c3dbf1Smrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
2063cdbfa18aSmrg    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
2064d5c3dbf1Smrg      func_xform "$libobj"
2065d5c3dbf1Smrg      libobj=$func_xform_result
2066d5c3dbf1Smrg      ;;
20679f606849Smrg    esac
20689f606849Smrg
20699f606849Smrg    case $libobj in
2070d5c3dbf1Smrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
20719f606849Smrg    *)
2072d5c3dbf1Smrg      func_fatal_error "cannot determine name of library object from \`$libobj'"
20739f606849Smrg      ;;
20749f606849Smrg    esac
20759f606849Smrg
20769f606849Smrg    func_infer_tag $base_compile
20779f606849Smrg
20789f606849Smrg    for arg in $later; do
20799f606849Smrg      case $arg in
2080d5c3dbf1Smrg      -shared)
2081d5c3dbf1Smrg	test "$build_libtool_libs" != yes && \
2082d5c3dbf1Smrg	  func_fatal_configuration "can not build a shared library"
2083d5c3dbf1Smrg	build_old_libs=no
2084d5c3dbf1Smrg	continue
2085d5c3dbf1Smrg	;;
2086d5c3dbf1Smrg
20879f606849Smrg      -static)
2088d5c3dbf1Smrg	build_libtool_libs=no
20899f606849Smrg	build_old_libs=yes
20909f606849Smrg	continue
20919f606849Smrg	;;
20929f606849Smrg
20939f606849Smrg      -prefer-pic)
20949f606849Smrg	pic_mode=yes
20959f606849Smrg	continue
20969f606849Smrg	;;
20979f606849Smrg
20989f606849Smrg      -prefer-non-pic)
20999f606849Smrg	pic_mode=no
21009f606849Smrg	continue
21019f606849Smrg	;;
21029f606849Smrg      esac
21039f606849Smrg    done
21049f606849Smrg
2105d5c3dbf1Smrg    func_quote_for_eval "$libobj"
2106d5c3dbf1Smrg    test "X$libobj" != "X$func_quote_for_eval_result" \
2107d5c3dbf1Smrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
2108d5c3dbf1Smrg      && func_warning "libobj name \`$libobj' may not contain shell special characters."
2109d5c3dbf1Smrg    func_dirname_and_basename "$obj" "/" ""
2110d5c3dbf1Smrg    objname="$func_basename_result"
2111d5c3dbf1Smrg    xdir="$func_dirname_result"
21129f606849Smrg    lobj=${xdir}$objdir/$objname
21139f606849Smrg
2114d5c3dbf1Smrg    test -z "$base_compile" && \
2115d5c3dbf1Smrg      func_fatal_help "you must specify a compilation command"
21169f606849Smrg
21179f606849Smrg    # Delete any leftover library objects.
21189f606849Smrg    if test "$build_old_libs" = yes; then
21199f606849Smrg      removelist="$obj $lobj $libobj ${libobj}T"
21209f606849Smrg    else
21219f606849Smrg      removelist="$lobj $libobj ${libobj}T"
21229f606849Smrg    fi
21239f606849Smrg
21249f606849Smrg    # On Cygwin there's no "real" PIC flag so we must build both object types
21259f606849Smrg    case $host_os in
2126d5c3dbf1Smrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
21279f606849Smrg      pic_mode=default
21289f606849Smrg      ;;
21299f606849Smrg    esac
21309f606849Smrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
21319f606849Smrg      # non-PIC code in shared libraries is not supported
21329f606849Smrg      pic_mode=default
21339f606849Smrg    fi
21349f606849Smrg
21359f606849Smrg    # Calculate the filename of the output object if compiler does
21369f606849Smrg    # not support -o with -c
21379f606849Smrg    if test "$compiler_c_o" = no; then
2138d5c3dbf1Smrg      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
21399f606849Smrg      lockfile="$output_obj.lock"
21409f606849Smrg    else
21419f606849Smrg      output_obj=
21429f606849Smrg      need_locks=no
21439f606849Smrg      lockfile=
21449f606849Smrg    fi
21459f606849Smrg
21469f606849Smrg    # Lock this critical section if it is needed
21479f606849Smrg    # We use this script file to make the link, it avoids creating a new file
21489f606849Smrg    if test "$need_locks" = yes; then
2149d5c3dbf1Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
2150d5c3dbf1Smrg	func_echo "Waiting for $lockfile to be removed"
21519f606849Smrg	sleep 2
21529f606849Smrg      done
21539f606849Smrg    elif test "$need_locks" = warn; then
21549f606849Smrg      if test -f "$lockfile"; then
2155d5c3dbf1Smrg	$ECHO "\
21569f606849Smrg*** ERROR, $lockfile exists and contains:
21579f606849Smrg`cat $lockfile 2>/dev/null`
21589f606849Smrg
21599f606849SmrgThis indicates that another process is trying to use the same
21609f606849Smrgtemporary object file, and libtool could not work around it because
21619f606849Smrgyour compiler does not support \`-c' and \`-o' together.  If you
21629f606849Smrgrepeat this compilation, it may succeed, by chance, but you had better
21639f606849Smrgavoid parallel builds (make -j) in this platform, or get a better
21649f606849Smrgcompiler."
21659f606849Smrg
2166d5c3dbf1Smrg	$opt_dry_run || $RM $removelist
21679f606849Smrg	exit $EXIT_FAILURE
21689f606849Smrg      fi
2169cdbfa18aSmrg      func_append removelist " $output_obj"
2170d5c3dbf1Smrg      $ECHO "$srcfile" > "$lockfile"
21719f606849Smrg    fi
21729f606849Smrg
2173d5c3dbf1Smrg    $opt_dry_run || $RM $removelist
2174cdbfa18aSmrg    func_append removelist " $lockfile"
2175d5c3dbf1Smrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
2176d5c3dbf1Smrg
2177cdbfa18aSmrg    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
2178cdbfa18aSmrg    srcfile=$func_to_tool_file_result
2179d5c3dbf1Smrg    func_quote_for_eval "$srcfile"
2180d5c3dbf1Smrg    qsrcfile=$func_quote_for_eval_result
21819f606849Smrg
21829f606849Smrg    # Only build a PIC object if we are building libtool libraries.
21839f606849Smrg    if test "$build_libtool_libs" = yes; then
21849f606849Smrg      # Without this assignment, base_compile gets emptied.
21859f606849Smrg      fbsd_hideous_sh_bug=$base_compile
21869f606849Smrg
21879f606849Smrg      if test "$pic_mode" != no; then
21889f606849Smrg	command="$base_compile $qsrcfile $pic_flag"
21899f606849Smrg      else
21909f606849Smrg	# Don't build PIC code
21919f606849Smrg	command="$base_compile $qsrcfile"
21929f606849Smrg      fi
21939f606849Smrg
2194d5c3dbf1Smrg      func_mkdir_p "$xdir$objdir"
21959f606849Smrg
21969f606849Smrg      if test -z "$output_obj"; then
21979f606849Smrg	# Place PIC objects in $objdir
2198cdbfa18aSmrg	func_append command " -o $lobj"
21999f606849Smrg      fi
22009f606849Smrg
2201d5c3dbf1Smrg      func_show_eval_locale "$command"	\
2202d5c3dbf1Smrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
22039f606849Smrg
22049f606849Smrg      if test "$need_locks" = warn &&
22059f606849Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2206d5c3dbf1Smrg	$ECHO "\
22079f606849Smrg*** ERROR, $lockfile contains:
22089f606849Smrg`cat $lockfile 2>/dev/null`
22099f606849Smrg
22109f606849Smrgbut it should contain:
22119f606849Smrg$srcfile
22129f606849Smrg
22139f606849SmrgThis indicates that another process is trying to use the same
22149f606849Smrgtemporary object file, and libtool could not work around it because
22159f606849Smrgyour compiler does not support \`-c' and \`-o' together.  If you
22169f606849Smrgrepeat this compilation, it may succeed, by chance, but you had better
22179f606849Smrgavoid parallel builds (make -j) in this platform, or get a better
22189f606849Smrgcompiler."
22199f606849Smrg
2220d5c3dbf1Smrg	$opt_dry_run || $RM $removelist
22219f606849Smrg	exit $EXIT_FAILURE
22229f606849Smrg      fi
22239f606849Smrg
22249f606849Smrg      # Just move the object if needed, then go on to compile the next one
22259f606849Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
2226d5c3dbf1Smrg	func_show_eval '$MV "$output_obj" "$lobj"' \
2227d5c3dbf1Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
22289f606849Smrg      fi
22299f606849Smrg
22309f606849Smrg      # Allow error messages only from the first compilation.
22319f606849Smrg      if test "$suppress_opt" = yes; then
2232d5c3dbf1Smrg	suppress_output=' >/dev/null 2>&1'
22339f606849Smrg      fi
22349f606849Smrg    fi
22359f606849Smrg
22369f606849Smrg    # Only build a position-dependent object if we build old libraries.
22379f606849Smrg    if test "$build_old_libs" = yes; then
22389f606849Smrg      if test "$pic_mode" != yes; then
22399f606849Smrg	# Don't build PIC code
2240d5c3dbf1Smrg	command="$base_compile $qsrcfile$pie_flag"
22419f606849Smrg      else
22429f606849Smrg	command="$base_compile $qsrcfile $pic_flag"
22439f606849Smrg      fi
22449f606849Smrg      if test "$compiler_c_o" = yes; then
2245cdbfa18aSmrg	func_append command " -o $obj"
22469f606849Smrg      fi
22479f606849Smrg
22489f606849Smrg      # Suppress compiler output if we already did a PIC compilation.
2249cdbfa18aSmrg      func_append command "$suppress_output"
2250d5c3dbf1Smrg      func_show_eval_locale "$command" \
2251d5c3dbf1Smrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
22529f606849Smrg
22539f606849Smrg      if test "$need_locks" = warn &&
22549f606849Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2255d5c3dbf1Smrg	$ECHO "\
22569f606849Smrg*** ERROR, $lockfile contains:
22579f606849Smrg`cat $lockfile 2>/dev/null`
22589f606849Smrg
22599f606849Smrgbut it should contain:
22609f606849Smrg$srcfile
22619f606849Smrg
22629f606849SmrgThis indicates that another process is trying to use the same
22639f606849Smrgtemporary object file, and libtool could not work around it because
22649f606849Smrgyour compiler does not support \`-c' and \`-o' together.  If you
22659f606849Smrgrepeat this compilation, it may succeed, by chance, but you had better
22669f606849Smrgavoid parallel builds (make -j) in this platform, or get a better
22679f606849Smrgcompiler."
22689f606849Smrg
2269d5c3dbf1Smrg	$opt_dry_run || $RM $removelist
22709f606849Smrg	exit $EXIT_FAILURE
22719f606849Smrg      fi
22729f606849Smrg
22739f606849Smrg      # Just move the object if needed
22749f606849Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
2275d5c3dbf1Smrg	func_show_eval '$MV "$output_obj" "$obj"' \
2276d5c3dbf1Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
22779f606849Smrg      fi
22789f606849Smrg    fi
22799f606849Smrg
2280d5c3dbf1Smrg    $opt_dry_run || {
2281d5c3dbf1Smrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
22829f606849Smrg
2283d5c3dbf1Smrg      # Unlock the critical section if it was locked
2284d5c3dbf1Smrg      if test "$need_locks" != no; then
2285d5c3dbf1Smrg	removelist=$lockfile
2286d5c3dbf1Smrg        $RM "$lockfile"
2287d5c3dbf1Smrg      fi
2288d5c3dbf1Smrg    }
22899f606849Smrg
22909f606849Smrg    exit $EXIT_SUCCESS
2291d5c3dbf1Smrg}
22929f606849Smrg
2293d5c3dbf1Smrg$opt_help || {
2294cdbfa18aSmrg  test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
2295d5c3dbf1Smrg}
22969f606849Smrg
2297d5c3dbf1Smrgfunc_mode_help ()
2298d5c3dbf1Smrg{
2299d5c3dbf1Smrg    # We need to display help for each of the modes.
2300cdbfa18aSmrg    case $opt_mode in
2301d5c3dbf1Smrg      "")
2302d5c3dbf1Smrg        # Generic help is extracted from the usage comments
2303d5c3dbf1Smrg        # at the start of this file.
2304d5c3dbf1Smrg        func_help
2305d5c3dbf1Smrg        ;;
23069f606849Smrg
2307d5c3dbf1Smrg      clean)
2308d5c3dbf1Smrg        $ECHO \
2309d5c3dbf1Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
23109f606849Smrg
2311d5c3dbf1SmrgRemove files from the build directory.
23129f606849Smrg
2313d5c3dbf1SmrgRM is the name of the program to use to delete files associated with each FILE
2314d5c3dbf1Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
2315d5c3dbf1Smrgto RM.
23169f606849Smrg
2317d5c3dbf1SmrgIf FILE is a libtool library, object or program, all the files associated
2318d5c3dbf1Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
2319d5c3dbf1Smrg        ;;
23209f606849Smrg
2321d5c3dbf1Smrg      compile)
2322d5c3dbf1Smrg      $ECHO \
2323d5c3dbf1Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
23249f606849Smrg
2325d5c3dbf1SmrgCompile a source file into a libtool library object.
23269f606849Smrg
2327d5c3dbf1SmrgThis mode accepts the following additional options:
23289f606849Smrg
2329d5c3dbf1Smrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
2330d5c3dbf1Smrg  -no-suppress      do not suppress compiler output for multiple passes
2331d5c3dbf1Smrg  -prefer-pic       try to build PIC objects only
2332d5c3dbf1Smrg  -prefer-non-pic   try to build non-PIC objects only
2333d5c3dbf1Smrg  -shared           do not build a \`.o' file suitable for static linking
2334d5c3dbf1Smrg  -static           only build a \`.o' file suitable for static linking
2335d5c3dbf1Smrg  -Wc,FLAG          pass FLAG directly to the compiler
23369f606849Smrg
2337d5c3dbf1SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
2338d5c3dbf1Smrgfrom the given SOURCEFILE.
23399f606849Smrg
2340d5c3dbf1SmrgThe output file name is determined by removing the directory component from
2341d5c3dbf1SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
2342d5c3dbf1Smrglibrary object suffix, \`.lo'."
2343d5c3dbf1Smrg        ;;
23449f606849Smrg
2345d5c3dbf1Smrg      execute)
2346d5c3dbf1Smrg        $ECHO \
2347d5c3dbf1Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
23489f606849Smrg
2349d5c3dbf1SmrgAutomatically set library path, then run a program.
23509f606849Smrg
2351d5c3dbf1SmrgThis mode accepts the following additional options:
23529f606849Smrg
2353d5c3dbf1Smrg  -dlopen FILE      add the directory containing FILE to the library path
23549f606849Smrg
2355d5c3dbf1SmrgThis mode sets the library path environment variable according to \`-dlopen'
2356d5c3dbf1Smrgflags.
23579f606849Smrg
2358d5c3dbf1SmrgIf any of the ARGS are libtool executable wrappers, then they are translated
2359d5c3dbf1Smrginto their corresponding uninstalled binary, and any of their required library
2360d5c3dbf1Smrgdirectories are added to the library path.
23619f606849Smrg
2362d5c3dbf1SmrgThen, COMMAND is executed, with ARGS as arguments."
2363d5c3dbf1Smrg        ;;
23649f606849Smrg
2365d5c3dbf1Smrg      finish)
2366d5c3dbf1Smrg        $ECHO \
2367d5c3dbf1Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
23689f606849Smrg
2369d5c3dbf1SmrgComplete the installation of libtool libraries.
23709f606849Smrg
2371d5c3dbf1SmrgEach LIBDIR is a directory that contains libtool libraries.
23729f606849Smrg
2373d5c3dbf1SmrgThe commands that this mode executes may require superuser privileges.  Use
2374d5c3dbf1Smrgthe \`--dry-run' option if you just want to see what would be executed."
2375d5c3dbf1Smrg        ;;
23769f606849Smrg
2377d5c3dbf1Smrg      install)
2378d5c3dbf1Smrg        $ECHO \
2379d5c3dbf1Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
23809f606849Smrg
2381d5c3dbf1SmrgInstall executables or libraries.
23829f606849Smrg
2383d5c3dbf1SmrgINSTALL-COMMAND is the installation command.  The first component should be
2384d5c3dbf1Smrgeither the \`install' or \`cp' program.
23859f606849Smrg
2386d5c3dbf1SmrgThe following components of INSTALL-COMMAND are treated specially:
23879f606849Smrg
2388d5c3dbf1Smrg  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
23899f606849Smrg
2390d5c3dbf1SmrgThe rest of the components are interpreted as arguments to that command (only
2391d5c3dbf1SmrgBSD-compatible install options are recognized)."
2392d5c3dbf1Smrg        ;;
23939f606849Smrg
2394d5c3dbf1Smrg      link)
2395d5c3dbf1Smrg        $ECHO \
2396d5c3dbf1Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
23979f606849Smrg
2398d5c3dbf1SmrgLink object files or libraries together to form another library, or to
2399d5c3dbf1Smrgcreate an executable program.
24009f606849Smrg
2401d5c3dbf1SmrgLINK-COMMAND is a command using the C compiler that you would use to create
2402d5c3dbf1Smrga program from several object files.
24039f606849Smrg
2404d5c3dbf1SmrgThe following components of LINK-COMMAND are treated specially:
24059f606849Smrg
2406d5c3dbf1Smrg  -all-static       do not do any dynamic linking at all
2407d5c3dbf1Smrg  -avoid-version    do not add a version suffix if possible
2408d5c3dbf1Smrg  -bindir BINDIR    specify path to binaries directory (for systems where
2409d5c3dbf1Smrg                    libraries must be found in the PATH setting at runtime)
2410d5c3dbf1Smrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
2411d5c3dbf1Smrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
2412d5c3dbf1Smrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
2413d5c3dbf1Smrg  -export-symbols SYMFILE
2414d5c3dbf1Smrg                    try to export only the symbols listed in SYMFILE
2415d5c3dbf1Smrg  -export-symbols-regex REGEX
2416d5c3dbf1Smrg                    try to export only the symbols matching REGEX
2417d5c3dbf1Smrg  -LLIBDIR          search LIBDIR for required installed libraries
2418d5c3dbf1Smrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
2419d5c3dbf1Smrg  -module           build a library that can dlopened
2420d5c3dbf1Smrg  -no-fast-install  disable the fast-install mode
2421d5c3dbf1Smrg  -no-install       link a not-installable executable
2422d5c3dbf1Smrg  -no-undefined     declare that a library does not refer to external symbols
2423d5c3dbf1Smrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
2424d5c3dbf1Smrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
2425d5c3dbf1Smrg  -precious-files-regex REGEX
2426d5c3dbf1Smrg                    don't remove output files matching REGEX
2427d5c3dbf1Smrg  -release RELEASE  specify package release information
2428d5c3dbf1Smrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
2429d5c3dbf1Smrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
2430d5c3dbf1Smrg  -shared           only do dynamic linking of libtool libraries
2431d5c3dbf1Smrg  -shrext SUFFIX    override the standard shared library file extension
2432d5c3dbf1Smrg  -static           do not do any dynamic linking of uninstalled libtool libraries
2433d5c3dbf1Smrg  -static-libtool-libs
2434d5c3dbf1Smrg                    do not do any dynamic linking of libtool libraries
2435d5c3dbf1Smrg  -version-info CURRENT[:REVISION[:AGE]]
2436d5c3dbf1Smrg                    specify library version info [each variable defaults to 0]
2437d5c3dbf1Smrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
2438d5c3dbf1Smrg  -Wc,FLAG
2439d5c3dbf1Smrg  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
2440d5c3dbf1Smrg  -Wl,FLAG
2441d5c3dbf1Smrg  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
2442d5c3dbf1Smrg  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
24439f606849Smrg
2444d5c3dbf1SmrgAll other options (arguments beginning with \`-') are ignored.
24459f606849Smrg
2446d5c3dbf1SmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
2447d5c3dbf1Smrgtreated as uninstalled libtool libraries, other files are standard or library
2448d5c3dbf1Smrgobject files.
24499f606849Smrg
2450d5c3dbf1SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
2451d5c3dbf1Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
2452d5c3dbf1Smrgrequired, except when creating a convenience library.
24539f606849Smrg
2454d5c3dbf1SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
2455d5c3dbf1Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
2456fba89afeSmrg
2457d5c3dbf1SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
2458d5c3dbf1Smrgis created, otherwise an executable program is created."
2459d5c3dbf1Smrg        ;;
24609f606849Smrg
2461d5c3dbf1Smrg      uninstall)
2462d5c3dbf1Smrg        $ECHO \
2463d5c3dbf1Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
24649f606849Smrg
2465d5c3dbf1SmrgRemove libraries from an installation directory.
24669f606849Smrg
2467d5c3dbf1SmrgRM is the name of the program to use to delete files associated with each FILE
2468d5c3dbf1Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
2469d5c3dbf1Smrgto RM.
24709f606849Smrg
2471d5c3dbf1SmrgIf FILE is a libtool library, all the files associated with it are deleted.
2472d5c3dbf1SmrgOtherwise, only FILE itself is deleted using RM."
2473d5c3dbf1Smrg        ;;
24749f606849Smrg
2475d5c3dbf1Smrg      *)
2476cdbfa18aSmrg        func_fatal_help "invalid operation mode \`$opt_mode'"
2477d5c3dbf1Smrg        ;;
2478d5c3dbf1Smrg    esac
24799f606849Smrg
2480d5c3dbf1Smrg    echo
2481d5c3dbf1Smrg    $ECHO "Try \`$progname --help' for more information about other modes."
2482d5c3dbf1Smrg}
24839f606849Smrg
2484d5c3dbf1Smrg# Now that we've collected a possible --mode arg, show help if necessary
2485d5c3dbf1Smrgif $opt_help; then
2486d5c3dbf1Smrg  if test "$opt_help" = :; then
2487d5c3dbf1Smrg    func_mode_help
2488d5c3dbf1Smrg  else
2489d5c3dbf1Smrg    {
2490d5c3dbf1Smrg      func_help noexit
2491cdbfa18aSmrg      for opt_mode in compile link execute install finish uninstall clean; do
2492d5c3dbf1Smrg	func_mode_help
2493d5c3dbf1Smrg      done
2494d5c3dbf1Smrg    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
2495d5c3dbf1Smrg    {
2496d5c3dbf1Smrg      func_help noexit
2497cdbfa18aSmrg      for opt_mode in compile link execute install finish uninstall clean; do
2498d5c3dbf1Smrg	echo
2499d5c3dbf1Smrg	func_mode_help
2500d5c3dbf1Smrg      done
2501d5c3dbf1Smrg    } |
2502d5c3dbf1Smrg    sed '1d
2503d5c3dbf1Smrg      /^When reporting/,/^Report/{
2504d5c3dbf1Smrg	H
2505d5c3dbf1Smrg	d
2506d5c3dbf1Smrg      }
2507d5c3dbf1Smrg      $x
2508d5c3dbf1Smrg      /information about other modes/d
2509d5c3dbf1Smrg      /more detailed .*MODE/d
2510d5c3dbf1Smrg      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
2511d5c3dbf1Smrg  fi
2512d5c3dbf1Smrg  exit $?
2513d5c3dbf1Smrgfi
25149f606849Smrg
25159f606849Smrg
2516d5c3dbf1Smrg# func_mode_execute arg...
2517d5c3dbf1Smrgfunc_mode_execute ()
2518d5c3dbf1Smrg{
2519d5c3dbf1Smrg    $opt_debug
2520d5c3dbf1Smrg    # The first argument is the command name.
2521d5c3dbf1Smrg    cmd="$nonopt"
2522d5c3dbf1Smrg    test -z "$cmd" && \
2523d5c3dbf1Smrg      func_fatal_help "you must specify a COMMAND"
25249f606849Smrg
2525d5c3dbf1Smrg    # Handle -dlopen flags immediately.
2526cdbfa18aSmrg    for file in $opt_dlopen; do
2527d5c3dbf1Smrg      test -f "$file" \
2528d5c3dbf1Smrg	|| func_fatal_help "\`$file' is not a file"
25299f606849Smrg
2530d5c3dbf1Smrg      dir=
2531d5c3dbf1Smrg      case $file in
2532d5c3dbf1Smrg      *.la)
2533cdbfa18aSmrg	func_resolve_sysroot "$file"
2534cdbfa18aSmrg	file=$func_resolve_sysroot_result
2535cdbfa18aSmrg
2536d5c3dbf1Smrg	# Check to see that this really is a libtool archive.
2537d5c3dbf1Smrg	func_lalib_unsafe_p "$file" \
2538d5c3dbf1Smrg	  || func_fatal_help "\`$lib' is not a valid libtool archive"
25399f606849Smrg
2540d5c3dbf1Smrg	# Read the libtool library.
2541d5c3dbf1Smrg	dlname=
2542d5c3dbf1Smrg	library_names=
2543d5c3dbf1Smrg	func_source "$file"
25449f606849Smrg
2545d5c3dbf1Smrg	# Skip this library if it cannot be dlopened.
2546d5c3dbf1Smrg	if test -z "$dlname"; then
2547d5c3dbf1Smrg	  # Warn if it was a shared library.
2548d5c3dbf1Smrg	  test -n "$library_names" && \
2549d5c3dbf1Smrg	    func_warning "\`$file' was not linked with \`-export-dynamic'"
2550d5c3dbf1Smrg	  continue
2551d5c3dbf1Smrg	fi
25529f606849Smrg
2553d5c3dbf1Smrg	func_dirname "$file" "" "."
2554d5c3dbf1Smrg	dir="$func_dirname_result"
25559f606849Smrg
2556d5c3dbf1Smrg	if test -f "$dir/$objdir/$dlname"; then
2557cdbfa18aSmrg	  func_append dir "/$objdir"
2558d5c3dbf1Smrg	else
2559d5c3dbf1Smrg	  if test ! -f "$dir/$dlname"; then
2560d5c3dbf1Smrg	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
2561d5c3dbf1Smrg	  fi
2562d5c3dbf1Smrg	fi
25639f606849Smrg	;;
25649f606849Smrg
2565d5c3dbf1Smrg      *.lo)
2566d5c3dbf1Smrg	# Just add the directory containing the .lo file.
2567d5c3dbf1Smrg	func_dirname "$file" "" "."
2568d5c3dbf1Smrg	dir="$func_dirname_result"
25699f606849Smrg	;;
2570d5c3dbf1Smrg
2571d5c3dbf1Smrg      *)
2572d5c3dbf1Smrg	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
25739f606849Smrg	continue
25749f606849Smrg	;;
2575d5c3dbf1Smrg      esac
25769f606849Smrg
2577d5c3dbf1Smrg      # Get the absolute pathname.
2578d5c3dbf1Smrg      absdir=`cd "$dir" && pwd`
2579d5c3dbf1Smrg      test -n "$absdir" && dir="$absdir"
25809f606849Smrg
2581d5c3dbf1Smrg      # Now add the directory to shlibpath_var.
2582d5c3dbf1Smrg      if eval "test -z \"\$$shlibpath_var\""; then
2583d5c3dbf1Smrg	eval "$shlibpath_var=\"\$dir\""
2584d5c3dbf1Smrg      else
2585d5c3dbf1Smrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
2586d5c3dbf1Smrg      fi
2587d5c3dbf1Smrg    done
25889f606849Smrg
2589d5c3dbf1Smrg    # This variable tells wrapper scripts just to set shlibpath_var
2590d5c3dbf1Smrg    # rather than running their programs.
2591d5c3dbf1Smrg    libtool_execute_magic="$magic"
25929f606849Smrg
2593d5c3dbf1Smrg    # Check if any of the arguments is a wrapper script.
2594d5c3dbf1Smrg    args=
2595d5c3dbf1Smrg    for file
2596d5c3dbf1Smrg    do
2597d5c3dbf1Smrg      case $file in
2598d5c3dbf1Smrg      -* | *.la | *.lo ) ;;
2599d5c3dbf1Smrg      *)
2600d5c3dbf1Smrg	# Do a test to see if this is really a libtool program.
2601d5c3dbf1Smrg	if func_ltwrapper_script_p "$file"; then
2602d5c3dbf1Smrg	  func_source "$file"
2603d5c3dbf1Smrg	  # Transform arg to wrapped name.
2604d5c3dbf1Smrg	  file="$progdir/$program"
2605d5c3dbf1Smrg	elif func_ltwrapper_executable_p "$file"; then
2606d5c3dbf1Smrg	  func_ltwrapper_scriptname "$file"
2607d5c3dbf1Smrg	  func_source "$func_ltwrapper_scriptname_result"
2608d5c3dbf1Smrg	  # Transform arg to wrapped name.
2609d5c3dbf1Smrg	  file="$progdir/$program"
2610d5c3dbf1Smrg	fi
26119f606849Smrg	;;
2612d5c3dbf1Smrg      esac
2613d5c3dbf1Smrg      # Quote arguments (to preserve shell metacharacters).
2614cdbfa18aSmrg      func_append_quoted args "$file"
2615d5c3dbf1Smrg    done
26169f606849Smrg
2617d5c3dbf1Smrg    if test "X$opt_dry_run" = Xfalse; then
2618d5c3dbf1Smrg      if test -n "$shlibpath_var"; then
2619d5c3dbf1Smrg	# Export the shlibpath_var.
2620d5c3dbf1Smrg	eval "export $shlibpath_var"
2621d5c3dbf1Smrg      fi
26229f606849Smrg
2623d5c3dbf1Smrg      # Restore saved environment variables
2624d5c3dbf1Smrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
2625d5c3dbf1Smrg      do
2626d5c3dbf1Smrg	eval "if test \"\${save_$lt_var+set}\" = set; then
2627d5c3dbf1Smrg                $lt_var=\$save_$lt_var; export $lt_var
2628d5c3dbf1Smrg	      else
2629d5c3dbf1Smrg		$lt_unset $lt_var
2630d5c3dbf1Smrg	      fi"
2631d5c3dbf1Smrg      done
26329f606849Smrg
2633d5c3dbf1Smrg      # Now prepare to actually exec the command.
2634d5c3dbf1Smrg      exec_cmd="\$cmd$args"
2635d5c3dbf1Smrg    else
2636d5c3dbf1Smrg      # Display what would be done.
2637d5c3dbf1Smrg      if test -n "$shlibpath_var"; then
2638d5c3dbf1Smrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
2639d5c3dbf1Smrg	echo "export $shlibpath_var"
2640d5c3dbf1Smrg      fi
2641d5c3dbf1Smrg      $ECHO "$cmd$args"
2642d5c3dbf1Smrg      exit $EXIT_SUCCESS
2643d5c3dbf1Smrg    fi
2644d5c3dbf1Smrg}
26459f606849Smrg
2646cdbfa18aSmrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"}
26479f606849Smrg
26489f606849Smrg
2649d5c3dbf1Smrg# func_mode_finish arg...
2650d5c3dbf1Smrgfunc_mode_finish ()
2651d5c3dbf1Smrg{
2652d5c3dbf1Smrg    $opt_debug
2653cdbfa18aSmrg    libs=
2654cdbfa18aSmrg    libdirs=
2655d5c3dbf1Smrg    admincmds=
26569f606849Smrg
2657cdbfa18aSmrg    for opt in "$nonopt" ${1+"$@"}
2658cdbfa18aSmrg    do
2659cdbfa18aSmrg      if test -d "$opt"; then
2660cdbfa18aSmrg	func_append libdirs " $opt"
2661cdbfa18aSmrg
2662cdbfa18aSmrg      elif test -f "$opt"; then
2663cdbfa18aSmrg	if func_lalib_unsafe_p "$opt"; then
2664cdbfa18aSmrg	  func_append libs " $opt"
2665cdbfa18aSmrg	else
2666cdbfa18aSmrg	  func_warning "\`$opt' is not a valid libtool archive"
2667cdbfa18aSmrg	fi
2668cdbfa18aSmrg
2669cdbfa18aSmrg      else
2670cdbfa18aSmrg	func_fatal_error "invalid argument \`$opt'"
2671cdbfa18aSmrg      fi
2672cdbfa18aSmrg    done
2673cdbfa18aSmrg
2674cdbfa18aSmrg    if test -n "$libs"; then
2675cdbfa18aSmrg      if test -n "$lt_sysroot"; then
2676cdbfa18aSmrg        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
2677cdbfa18aSmrg        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
2678cdbfa18aSmrg      else
2679cdbfa18aSmrg        sysroot_cmd=
2680cdbfa18aSmrg      fi
2681cdbfa18aSmrg
2682cdbfa18aSmrg      # Remove sysroot references
2683cdbfa18aSmrg      if $opt_dry_run; then
2684cdbfa18aSmrg        for lib in $libs; do
2685cdbfa18aSmrg          echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
2686cdbfa18aSmrg        done
2687cdbfa18aSmrg      else
2688cdbfa18aSmrg        tmpdir=`func_mktempdir`
2689cdbfa18aSmrg        for lib in $libs; do
2690cdbfa18aSmrg	  sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
2691cdbfa18aSmrg	    > $tmpdir/tmp-la
2692cdbfa18aSmrg	  mv -f $tmpdir/tmp-la $lib
2693cdbfa18aSmrg	done
2694cdbfa18aSmrg        ${RM}r "$tmpdir"
2695cdbfa18aSmrg      fi
2696cdbfa18aSmrg    fi
26979f606849Smrg
2698cdbfa18aSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2699d5c3dbf1Smrg      for libdir in $libdirs; do
2700d5c3dbf1Smrg	if test -n "$finish_cmds"; then
2701d5c3dbf1Smrg	  # Do each command in the finish commands.
2702d5c3dbf1Smrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
2703d5c3dbf1Smrg'"$cmd"'"'
2704d5c3dbf1Smrg	fi
2705d5c3dbf1Smrg	if test -n "$finish_eval"; then
2706d5c3dbf1Smrg	  # Do the single finish_eval.
2707d5c3dbf1Smrg	  eval cmds=\"$finish_eval\"
2708cdbfa18aSmrg	  $opt_dry_run || eval "$cmds" || func_append admincmds "
2709d5c3dbf1Smrg       $cmds"
2710d5c3dbf1Smrg	fi
2711d5c3dbf1Smrg      done
2712d5c3dbf1Smrg    fi
27139f606849Smrg
2714d5c3dbf1Smrg    # Exit here if they wanted silent mode.
2715d5c3dbf1Smrg    $opt_silent && exit $EXIT_SUCCESS
27169f606849Smrg
2717cdbfa18aSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2718cdbfa18aSmrg      echo "----------------------------------------------------------------------"
2719cdbfa18aSmrg      echo "Libraries have been installed in:"
2720cdbfa18aSmrg      for libdir in $libdirs; do
2721cdbfa18aSmrg	$ECHO "   $libdir"
2722cdbfa18aSmrg      done
2723cdbfa18aSmrg      echo
2724cdbfa18aSmrg      echo "If you ever happen to want to link against installed libraries"
2725cdbfa18aSmrg      echo "in a given directory, LIBDIR, you must either use libtool, and"
2726cdbfa18aSmrg      echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
2727cdbfa18aSmrg      echo "flag during linking and do at least one of the following:"
2728cdbfa18aSmrg      if test -n "$shlibpath_var"; then
2729cdbfa18aSmrg	echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
2730cdbfa18aSmrg	echo "     during execution"
2731cdbfa18aSmrg      fi
2732cdbfa18aSmrg      if test -n "$runpath_var"; then
2733cdbfa18aSmrg	echo "   - add LIBDIR to the \`$runpath_var' environment variable"
2734cdbfa18aSmrg	echo "     during linking"
2735cdbfa18aSmrg      fi
2736cdbfa18aSmrg      if test -n "$hardcode_libdir_flag_spec"; then
2737cdbfa18aSmrg	libdir=LIBDIR
2738cdbfa18aSmrg	eval flag=\"$hardcode_libdir_flag_spec\"
27399f606849Smrg
2740cdbfa18aSmrg	$ECHO "   - use the \`$flag' linker flag"
2741cdbfa18aSmrg      fi
2742cdbfa18aSmrg      if test -n "$admincmds"; then
2743cdbfa18aSmrg	$ECHO "   - have your system administrator run these commands:$admincmds"
2744cdbfa18aSmrg      fi
2745cdbfa18aSmrg      if test -f /etc/ld.so.conf; then
2746cdbfa18aSmrg	echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
2747cdbfa18aSmrg      fi
2748cdbfa18aSmrg      echo
27499f606849Smrg
2750cdbfa18aSmrg      echo "See any operating system documentation about shared libraries for"
2751cdbfa18aSmrg      case $host in
2752cdbfa18aSmrg	solaris2.[6789]|solaris2.1[0-9])
2753cdbfa18aSmrg	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
2754cdbfa18aSmrg	  echo "pages."
2755cdbfa18aSmrg	  ;;
2756cdbfa18aSmrg	*)
2757cdbfa18aSmrg	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
2758cdbfa18aSmrg	  ;;
2759cdbfa18aSmrg      esac
2760cdbfa18aSmrg      echo "----------------------------------------------------------------------"
2761cdbfa18aSmrg    fi
2762d5c3dbf1Smrg    exit $EXIT_SUCCESS
2763d5c3dbf1Smrg}
27649f606849Smrg
2765cdbfa18aSmrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"}
27669f606849Smrg
27679f606849Smrg
2768d5c3dbf1Smrg# func_mode_install arg...
2769d5c3dbf1Smrgfunc_mode_install ()
2770d5c3dbf1Smrg{
2771d5c3dbf1Smrg    $opt_debug
2772d5c3dbf1Smrg    # There may be an optional sh(1) argument at the beginning of
2773d5c3dbf1Smrg    # install_prog (especially on Windows NT).
2774d5c3dbf1Smrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
2775d5c3dbf1Smrg       # Allow the use of GNU shtool's install command.
2776d5c3dbf1Smrg       case $nonopt in *shtool*) :;; *) false;; esac; then
2777d5c3dbf1Smrg      # Aesthetically quote it.
2778d5c3dbf1Smrg      func_quote_for_eval "$nonopt"
2779d5c3dbf1Smrg      install_prog="$func_quote_for_eval_result "
2780d5c3dbf1Smrg      arg=$1
2781d5c3dbf1Smrg      shift
2782d5c3dbf1Smrg    else
2783d5c3dbf1Smrg      install_prog=
2784d5c3dbf1Smrg      arg=$nonopt
2785d5c3dbf1Smrg    fi
27869f606849Smrg
2787d5c3dbf1Smrg    # The real first argument should be the name of the installation program.
2788d5c3dbf1Smrg    # Aesthetically quote it.
2789d5c3dbf1Smrg    func_quote_for_eval "$arg"
2790cdbfa18aSmrg    func_append install_prog "$func_quote_for_eval_result"
2791d5c3dbf1Smrg    install_shared_prog=$install_prog
2792d5c3dbf1Smrg    case " $install_prog " in
2793d5c3dbf1Smrg      *[\\\ /]cp\ *) install_cp=: ;;
2794d5c3dbf1Smrg      *) install_cp=false ;;
2795d5c3dbf1Smrg    esac
27969f606849Smrg
2797d5c3dbf1Smrg    # We need to accept at least all the BSD install flags.
2798d5c3dbf1Smrg    dest=
2799d5c3dbf1Smrg    files=
2800d5c3dbf1Smrg    opts=
2801d5c3dbf1Smrg    prev=
2802d5c3dbf1Smrg    install_type=
2803d5c3dbf1Smrg    isdir=no
2804d5c3dbf1Smrg    stripme=
2805d5c3dbf1Smrg    no_mode=:
2806d5c3dbf1Smrg    for arg
2807d5c3dbf1Smrg    do
2808d5c3dbf1Smrg      arg2=
2809d5c3dbf1Smrg      if test -n "$dest"; then
2810cdbfa18aSmrg	func_append files " $dest"
2811d5c3dbf1Smrg	dest=$arg
28129f606849Smrg	continue
2813d5c3dbf1Smrg      fi
28149f606849Smrg
2815d5c3dbf1Smrg      case $arg in
2816d5c3dbf1Smrg      -d) isdir=yes ;;
2817d5c3dbf1Smrg      -f)
2818d5c3dbf1Smrg	if $install_cp; then :; else
2819d5c3dbf1Smrg	  prev=$arg
28209f606849Smrg	fi
2821d5c3dbf1Smrg	;;
2822d5c3dbf1Smrg      -g | -m | -o)
2823d5c3dbf1Smrg	prev=$arg
2824d5c3dbf1Smrg	;;
2825d5c3dbf1Smrg      -s)
2826d5c3dbf1Smrg	stripme=" -s"
28279f606849Smrg	continue
28289f606849Smrg	;;
2829d5c3dbf1Smrg      -*)
2830d5c3dbf1Smrg	;;
28319f606849Smrg      *)
2832d5c3dbf1Smrg	# If the previous option needed an argument, then skip it.
2833d5c3dbf1Smrg	if test -n "$prev"; then
2834d5c3dbf1Smrg	  if test "x$prev" = x-m && test -n "$install_override_mode"; then
2835d5c3dbf1Smrg	    arg2=$install_override_mode
2836d5c3dbf1Smrg	    no_mode=false
2837d5c3dbf1Smrg	  fi
2838d5c3dbf1Smrg	  prev=
2839d5c3dbf1Smrg	else
2840d5c3dbf1Smrg	  dest=$arg
2841d5c3dbf1Smrg	  continue
2842d5c3dbf1Smrg	fi
28439f606849Smrg	;;
2844d5c3dbf1Smrg      esac
28459f606849Smrg
2846d5c3dbf1Smrg      # Aesthetically quote the argument.
2847d5c3dbf1Smrg      func_quote_for_eval "$arg"
2848cdbfa18aSmrg      func_append install_prog " $func_quote_for_eval_result"
2849d5c3dbf1Smrg      if test -n "$arg2"; then
2850d5c3dbf1Smrg	func_quote_for_eval "$arg2"
28519f606849Smrg      fi
2852cdbfa18aSmrg      func_append install_shared_prog " $func_quote_for_eval_result"
2853d5c3dbf1Smrg    done
28549f606849Smrg
2855d5c3dbf1Smrg    test -z "$install_prog" && \
2856d5c3dbf1Smrg      func_fatal_help "you must specify an install program"
28579f606849Smrg
2858d5c3dbf1Smrg    test -n "$prev" && \
2859d5c3dbf1Smrg      func_fatal_help "the \`$prev' option requires an argument"
28609f606849Smrg
2861d5c3dbf1Smrg    if test -n "$install_override_mode" && $no_mode; then
2862d5c3dbf1Smrg      if $install_cp; then :; else
2863d5c3dbf1Smrg	func_quote_for_eval "$install_override_mode"
2864cdbfa18aSmrg	func_append install_shared_prog " -m $func_quote_for_eval_result"
2865d5c3dbf1Smrg      fi
28669f606849Smrg    fi
28679f606849Smrg
2868d5c3dbf1Smrg    if test -z "$files"; then
2869d5c3dbf1Smrg      if test -z "$dest"; then
2870d5c3dbf1Smrg	func_fatal_help "no file or destination specified"
2871d5c3dbf1Smrg      else
2872d5c3dbf1Smrg	func_fatal_help "you must specify a destination"
28739f606849Smrg      fi
28749f606849Smrg    fi
28759f606849Smrg
2876d5c3dbf1Smrg    # Strip any trailing slash from the destination.
2877d5c3dbf1Smrg    func_stripname '' '/' "$dest"
2878d5c3dbf1Smrg    dest=$func_stripname_result
28799f606849Smrg
2880d5c3dbf1Smrg    # Check to see that the destination is a directory.
2881d5c3dbf1Smrg    test -d "$dest" && isdir=yes
2882d5c3dbf1Smrg    if test "$isdir" = yes; then
2883d5c3dbf1Smrg      destdir="$dest"
2884d5c3dbf1Smrg      destname=
2885d5c3dbf1Smrg    else
2886d5c3dbf1Smrg      func_dirname_and_basename "$dest" "" "."
2887d5c3dbf1Smrg      destdir="$func_dirname_result"
2888d5c3dbf1Smrg      destname="$func_basename_result"
2889d5c3dbf1Smrg
2890d5c3dbf1Smrg      # Not a directory, so check to see that there is only one file specified.
2891d5c3dbf1Smrg      set dummy $files; shift
2892d5c3dbf1Smrg      test "$#" -gt 1 && \
2893d5c3dbf1Smrg	func_fatal_help "\`$dest' is not a directory"
2894d5c3dbf1Smrg    fi
2895d5c3dbf1Smrg    case $destdir in
2896d5c3dbf1Smrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
28979f606849Smrg    *)
2898d5c3dbf1Smrg      for file in $files; do
2899d5c3dbf1Smrg	case $file in
2900d5c3dbf1Smrg	*.lo) ;;
2901d5c3dbf1Smrg	*)
2902d5c3dbf1Smrg	  func_fatal_help "\`$destdir' must be an absolute directory name"
2903d5c3dbf1Smrg	  ;;
2904d5c3dbf1Smrg	esac
2905d5c3dbf1Smrg      done
29069f606849Smrg      ;;
29079f606849Smrg    esac
29089f606849Smrg
2909d5c3dbf1Smrg    # This variable tells wrapper scripts just to set variables rather
2910d5c3dbf1Smrg    # than running their programs.
2911d5c3dbf1Smrg    libtool_install_magic="$magic"
29129f606849Smrg
2913d5c3dbf1Smrg    staticlibs=
2914d5c3dbf1Smrg    future_libdirs=
2915d5c3dbf1Smrg    current_libdirs=
2916d5c3dbf1Smrg    for file in $files; do
29179f606849Smrg
2918d5c3dbf1Smrg      # Do each installation.
2919d5c3dbf1Smrg      case $file in
2920d5c3dbf1Smrg      *.$libext)
2921d5c3dbf1Smrg	# Do the static libraries later.
2922cdbfa18aSmrg	func_append staticlibs " $file"
2923d5c3dbf1Smrg	;;
2924d5c3dbf1Smrg
2925d5c3dbf1Smrg      *.la)
2926cdbfa18aSmrg	func_resolve_sysroot "$file"
2927cdbfa18aSmrg	file=$func_resolve_sysroot_result
2928cdbfa18aSmrg
2929d5c3dbf1Smrg	# Check to see that this really is a libtool archive.
2930d5c3dbf1Smrg	func_lalib_unsafe_p "$file" \
2931d5c3dbf1Smrg	  || func_fatal_help "\`$file' is not a valid libtool archive"
2932d5c3dbf1Smrg
2933d5c3dbf1Smrg	library_names=
2934d5c3dbf1Smrg	old_library=
2935d5c3dbf1Smrg	relink_command=
2936d5c3dbf1Smrg	func_source "$file"
2937d5c3dbf1Smrg
2938d5c3dbf1Smrg	# Add the libdir to current_libdirs if it is the destination.
2939d5c3dbf1Smrg	if test "X$destdir" = "X$libdir"; then
2940d5c3dbf1Smrg	  case "$current_libdirs " in
2941d5c3dbf1Smrg	  *" $libdir "*) ;;
2942cdbfa18aSmrg	  *) func_append current_libdirs " $libdir" ;;
29439f606849Smrg	  esac
2944d5c3dbf1Smrg	else
2945d5c3dbf1Smrg	  # Note the libdir as a future libdir.
2946d5c3dbf1Smrg	  case "$future_libdirs " in
2947d5c3dbf1Smrg	  *" $libdir "*) ;;
2948cdbfa18aSmrg	  *) func_append future_libdirs " $libdir" ;;
2949d5c3dbf1Smrg	  esac
2950d5c3dbf1Smrg	fi
29519f606849Smrg
2952d5c3dbf1Smrg	func_dirname "$file" "/" ""
2953d5c3dbf1Smrg	dir="$func_dirname_result"
2954cdbfa18aSmrg	func_append dir "$objdir"
2955d5c3dbf1Smrg
2956d5c3dbf1Smrg	if test -n "$relink_command"; then
2957d5c3dbf1Smrg	  # Determine the prefix the user has applied to our future dir.
2958d5c3dbf1Smrg	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
2959d5c3dbf1Smrg
2960d5c3dbf1Smrg	  # Don't allow the user to place us outside of our expected
2961d5c3dbf1Smrg	  # location b/c this prevents finding dependent libraries that
2962d5c3dbf1Smrg	  # are installed to the same prefix.
2963d5c3dbf1Smrg	  # At present, this check doesn't affect windows .dll's that
2964d5c3dbf1Smrg	  # are installed into $libdir/../bin (currently, that works fine)
2965d5c3dbf1Smrg	  # but it's something to keep an eye on.
2966d5c3dbf1Smrg	  test "$inst_prefix_dir" = "$destdir" && \
2967d5c3dbf1Smrg	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
2968d5c3dbf1Smrg
2969d5c3dbf1Smrg	  if test -n "$inst_prefix_dir"; then
2970d5c3dbf1Smrg	    # Stick the inst_prefix_dir data into the link command.
2971d5c3dbf1Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
2972d5c3dbf1Smrg	  else
2973d5c3dbf1Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
2974d5c3dbf1Smrg	  fi
2975d5c3dbf1Smrg
2976d5c3dbf1Smrg	  func_warning "relinking \`$file'"
2977d5c3dbf1Smrg	  func_show_eval "$relink_command" \
2978d5c3dbf1Smrg	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
2979d5c3dbf1Smrg	fi
2980d5c3dbf1Smrg
2981d5c3dbf1Smrg	# See the names of the shared library.
2982d5c3dbf1Smrg	set dummy $library_names; shift
2983d5c3dbf1Smrg	if test -n "$1"; then
2984d5c3dbf1Smrg	  realname="$1"
2985d5c3dbf1Smrg	  shift
2986d5c3dbf1Smrg
2987d5c3dbf1Smrg	  srcname="$realname"
2988d5c3dbf1Smrg	  test -n "$relink_command" && srcname="$realname"T
2989d5c3dbf1Smrg
2990d5c3dbf1Smrg	  # Install the shared library and build the symlinks.
2991d5c3dbf1Smrg	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
2992d5c3dbf1Smrg	      'exit $?'
2993d5c3dbf1Smrg	  tstripme="$stripme"
2994d5c3dbf1Smrg	  case $host_os in
2995d5c3dbf1Smrg	  cygwin* | mingw* | pw32* | cegcc*)
2996d5c3dbf1Smrg	    case $realname in
2997d5c3dbf1Smrg	    *.dll.a)
2998d5c3dbf1Smrg	      tstripme=""
2999d5c3dbf1Smrg	      ;;
3000d5c3dbf1Smrg	    esac
30019f606849Smrg	    ;;
30029f606849Smrg	  esac
3003d5c3dbf1Smrg	  if test -n "$tstripme" && test -n "$striplib"; then
3004d5c3dbf1Smrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
3005d5c3dbf1Smrg	  fi
3006d5c3dbf1Smrg
3007d5c3dbf1Smrg	  if test "$#" -gt 0; then
3008d5c3dbf1Smrg	    # Delete the old symlinks, and create new ones.
3009d5c3dbf1Smrg	    # Try `ln -sf' first, because the `ln' binary might depend on
3010d5c3dbf1Smrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
3011d5c3dbf1Smrg	    # so we also need to try rm && ln -s.
3012d5c3dbf1Smrg	    for linkname
3013d5c3dbf1Smrg	    do
3014d5c3dbf1Smrg	      test "$linkname" != "$realname" \
3015d5c3dbf1Smrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
3016d5c3dbf1Smrg	    done
3017d5c3dbf1Smrg	  fi
3018d5c3dbf1Smrg
3019d5c3dbf1Smrg	  # Do each command in the postinstall commands.
3020d5c3dbf1Smrg	  lib="$destdir/$realname"
3021d5c3dbf1Smrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
3022d5c3dbf1Smrg	fi
3023d5c3dbf1Smrg
3024d5c3dbf1Smrg	# Install the pseudo-library for information purposes.
3025d5c3dbf1Smrg	func_basename "$file"
3026d5c3dbf1Smrg	name="$func_basename_result"
3027d5c3dbf1Smrg	instname="$dir/$name"i
3028d5c3dbf1Smrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
3029d5c3dbf1Smrg
3030d5c3dbf1Smrg	# Maybe install the static library, too.
3031cdbfa18aSmrg	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
30329f606849Smrg	;;
3033d5c3dbf1Smrg
3034d5c3dbf1Smrg      *.lo)
3035d5c3dbf1Smrg	# Install (i.e. copy) a libtool object.
3036d5c3dbf1Smrg
3037d5c3dbf1Smrg	# Figure out destination file name, if it wasn't already specified.
3038d5c3dbf1Smrg	if test -n "$destname"; then
3039d5c3dbf1Smrg	  destfile="$destdir/$destname"
3040d5c3dbf1Smrg	else
3041d5c3dbf1Smrg	  func_basename "$file"
3042d5c3dbf1Smrg	  destfile="$func_basename_result"
3043d5c3dbf1Smrg	  destfile="$destdir/$destfile"
3044d5c3dbf1Smrg	fi
3045d5c3dbf1Smrg
3046d5c3dbf1Smrg	# Deduce the name of the destination old-style object file.
3047d5c3dbf1Smrg	case $destfile in
3048d5c3dbf1Smrg	*.lo)
3049d5c3dbf1Smrg	  func_lo2o "$destfile"
3050d5c3dbf1Smrg	  staticdest=$func_lo2o_result
30519f606849Smrg	  ;;
3052d5c3dbf1Smrg	*.$objext)
3053d5c3dbf1Smrg	  staticdest="$destfile"
3054d5c3dbf1Smrg	  destfile=
30559f606849Smrg	  ;;
3056d5c3dbf1Smrg	*)
3057d5c3dbf1Smrg	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
30589f606849Smrg	  ;;
3059d5c3dbf1Smrg	esac
3060d5c3dbf1Smrg
3061d5c3dbf1Smrg	# Install the libtool object if requested.
3062d5c3dbf1Smrg	test -n "$destfile" && \
3063d5c3dbf1Smrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
3064d5c3dbf1Smrg
3065d5c3dbf1Smrg	# Install the old object if enabled.
3066d5c3dbf1Smrg	if test "$build_old_libs" = yes; then
3067d5c3dbf1Smrg	  # Deduce the name of the old-style object file.
3068d5c3dbf1Smrg	  func_lo2o "$file"
3069d5c3dbf1Smrg	  staticobj=$func_lo2o_result
3070d5c3dbf1Smrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
30719f606849Smrg	fi
3072d5c3dbf1Smrg	exit $EXIT_SUCCESS
3073d5c3dbf1Smrg	;;
30749f606849Smrg
3075d5c3dbf1Smrg      *)
3076d5c3dbf1Smrg	# Figure out destination file name, if it wasn't already specified.
3077d5c3dbf1Smrg	if test -n "$destname"; then
3078d5c3dbf1Smrg	  destfile="$destdir/$destname"
30799f606849Smrg	else
3080d5c3dbf1Smrg	  func_basename "$file"
3081d5c3dbf1Smrg	  destfile="$func_basename_result"
3082d5c3dbf1Smrg	  destfile="$destdir/$destfile"
30839f606849Smrg	fi
30849f606849Smrg
3085d5c3dbf1Smrg	# If the file is missing, and there is a .exe on the end, strip it
3086d5c3dbf1Smrg	# because it is most likely a libtool script we actually want to
3087d5c3dbf1Smrg	# install
3088d5c3dbf1Smrg	stripped_ext=""
3089d5c3dbf1Smrg	case $file in
3090d5c3dbf1Smrg	  *.exe)
3091d5c3dbf1Smrg	    if test ! -f "$file"; then
3092d5c3dbf1Smrg	      func_stripname '' '.exe' "$file"
3093d5c3dbf1Smrg	      file=$func_stripname_result
3094d5c3dbf1Smrg	      stripped_ext=".exe"
3095d5c3dbf1Smrg	    fi
3096d5c3dbf1Smrg	    ;;
3097d5c3dbf1Smrg	esac
30989f606849Smrg
3099d5c3dbf1Smrg	# Do a test to see if this is really a libtool program.
3100d5c3dbf1Smrg	case $host in
3101d5c3dbf1Smrg	*cygwin* | *mingw*)
3102d5c3dbf1Smrg	    if func_ltwrapper_executable_p "$file"; then
3103d5c3dbf1Smrg	      func_ltwrapper_scriptname "$file"
3104d5c3dbf1Smrg	      wrapper=$func_ltwrapper_scriptname_result
3105d5c3dbf1Smrg	    else
3106d5c3dbf1Smrg	      func_stripname '' '.exe' "$file"
3107d5c3dbf1Smrg	      wrapper=$func_stripname_result
3108d5c3dbf1Smrg	    fi
3109d5c3dbf1Smrg	    ;;
3110d5c3dbf1Smrg	*)
3111d5c3dbf1Smrg	    wrapper=$file
3112d5c3dbf1Smrg	    ;;
3113d5c3dbf1Smrg	esac
3114d5c3dbf1Smrg	if func_ltwrapper_script_p "$wrapper"; then
3115d5c3dbf1Smrg	  notinst_deplibs=
3116d5c3dbf1Smrg	  relink_command=
31179f606849Smrg
3118d5c3dbf1Smrg	  func_source "$wrapper"
31199f606849Smrg
3120d5c3dbf1Smrg	  # Check the variables that should have been set.
3121d5c3dbf1Smrg	  test -z "$generated_by_libtool_version" && \
3122d5c3dbf1Smrg	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
31239f606849Smrg
3124d5c3dbf1Smrg	  finalize=yes
3125d5c3dbf1Smrg	  for lib in $notinst_deplibs; do
3126d5c3dbf1Smrg	    # Check to see that each library is installed.
3127d5c3dbf1Smrg	    libdir=
3128d5c3dbf1Smrg	    if test -f "$lib"; then
3129d5c3dbf1Smrg	      func_source "$lib"
31309f606849Smrg	    fi
3131d5c3dbf1Smrg	    libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
3132d5c3dbf1Smrg	    if test -n "$libdir" && test ! -f "$libfile"; then
3133d5c3dbf1Smrg	      func_warning "\`$lib' has not been installed in \`$libdir'"
3134d5c3dbf1Smrg	      finalize=no
3135d5c3dbf1Smrg	    fi
3136d5c3dbf1Smrg	  done
31379f606849Smrg
3138d5c3dbf1Smrg	  relink_command=
3139d5c3dbf1Smrg	  func_source "$wrapper"
31409f606849Smrg
3141d5c3dbf1Smrg	  outputname=
3142d5c3dbf1Smrg	  if test "$fast_install" = no && test -n "$relink_command"; then
3143d5c3dbf1Smrg	    $opt_dry_run || {
3144d5c3dbf1Smrg	      if test "$finalize" = yes; then
3145d5c3dbf1Smrg	        tmpdir=`func_mktempdir`
3146d5c3dbf1Smrg		func_basename "$file$stripped_ext"
3147d5c3dbf1Smrg		file="$func_basename_result"
3148d5c3dbf1Smrg	        outputname="$tmpdir/$file"
3149d5c3dbf1Smrg	        # Replace the output file specification.
3150d5c3dbf1Smrg	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
3151d5c3dbf1Smrg
3152d5c3dbf1Smrg	        $opt_silent || {
3153d5c3dbf1Smrg	          func_quote_for_expand "$relink_command"
3154d5c3dbf1Smrg		  eval "func_echo $func_quote_for_expand_result"
3155d5c3dbf1Smrg	        }
3156d5c3dbf1Smrg	        if eval "$relink_command"; then :
3157d5c3dbf1Smrg	          else
3158d5c3dbf1Smrg		  func_error "error: relink \`$file' with the above command before installing it"
3159d5c3dbf1Smrg		  $opt_dry_run || ${RM}r "$tmpdir"
3160d5c3dbf1Smrg		  continue
3161d5c3dbf1Smrg	        fi
3162d5c3dbf1Smrg	        file="$outputname"
3163d5c3dbf1Smrg	      else
3164d5c3dbf1Smrg	        func_warning "cannot relink \`$file'"
3165d5c3dbf1Smrg	      fi
3166d5c3dbf1Smrg	    }
31679f606849Smrg	  else
3168d5c3dbf1Smrg	    # Install the binary that we compiled earlier.
3169d5c3dbf1Smrg	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
31709f606849Smrg	  fi
3171d5c3dbf1Smrg	fi
31729f606849Smrg
3173d5c3dbf1Smrg	# remove .exe since cygwin /usr/bin/install will append another
3174d5c3dbf1Smrg	# one anyway
3175d5c3dbf1Smrg	case $install_prog,$host in
3176d5c3dbf1Smrg	*/usr/bin/install*,*cygwin*)
3177d5c3dbf1Smrg	  case $file:$destfile in
3178d5c3dbf1Smrg	  *.exe:*.exe)
3179d5c3dbf1Smrg	    # this is ok
3180d5c3dbf1Smrg	    ;;
3181d5c3dbf1Smrg	  *.exe:*)
3182d5c3dbf1Smrg	    destfile=$destfile.exe
3183d5c3dbf1Smrg	    ;;
3184d5c3dbf1Smrg	  *:*.exe)
3185d5c3dbf1Smrg	    func_stripname '' '.exe' "$destfile"
3186d5c3dbf1Smrg	    destfile=$func_stripname_result
3187d5c3dbf1Smrg	    ;;
3188d5c3dbf1Smrg	  esac
31899f606849Smrg	  ;;
31909f606849Smrg	esac
3191d5c3dbf1Smrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
3192d5c3dbf1Smrg	$opt_dry_run || if test -n "$outputname"; then
3193d5c3dbf1Smrg	  ${RM}r "$tmpdir"
3194d5c3dbf1Smrg	fi
3195d5c3dbf1Smrg	;;
3196d5c3dbf1Smrg      esac
3197d5c3dbf1Smrg    done
31989f606849Smrg
3199d5c3dbf1Smrg    for file in $staticlibs; do
3200d5c3dbf1Smrg      func_basename "$file"
3201d5c3dbf1Smrg      name="$func_basename_result"
3202d5c3dbf1Smrg
3203d5c3dbf1Smrg      # Set up the ranlib parameters.
3204d5c3dbf1Smrg      oldlib="$destdir/$name"
3205cdbfa18aSmrg      func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
3206cdbfa18aSmrg      tool_oldlib=$func_to_tool_file_result
3207d5c3dbf1Smrg
3208d5c3dbf1Smrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
3209d5c3dbf1Smrg
3210d5c3dbf1Smrg      if test -n "$stripme" && test -n "$old_striplib"; then
3211cdbfa18aSmrg	func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
3212d5c3dbf1Smrg      fi
3213d5c3dbf1Smrg
3214d5c3dbf1Smrg      # Do each command in the postinstall commands.
3215d5c3dbf1Smrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
3216d5c3dbf1Smrg    done
3217d5c3dbf1Smrg
3218d5c3dbf1Smrg    test -n "$future_libdirs" && \
3219d5c3dbf1Smrg      func_warning "remember to run \`$progname --finish$future_libdirs'"
3220d5c3dbf1Smrg
3221d5c3dbf1Smrg    if test -n "$current_libdirs"; then
3222d5c3dbf1Smrg      # Maybe just do a dry run.
3223d5c3dbf1Smrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
3224d5c3dbf1Smrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
3225d5c3dbf1Smrg    else
3226d5c3dbf1Smrg      exit $EXIT_SUCCESS
3227d5c3dbf1Smrg    fi
3228d5c3dbf1Smrg}
3229d5c3dbf1Smrg
3230cdbfa18aSmrgtest "$opt_mode" = install && func_mode_install ${1+"$@"}
3231d5c3dbf1Smrg
3232d5c3dbf1Smrg
3233d5c3dbf1Smrg# func_generate_dlsyms outputname originator pic_p
3234d5c3dbf1Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with
3235d5c3dbf1Smrg# a dlpreopen symbol table.
3236d5c3dbf1Smrgfunc_generate_dlsyms ()
3237d5c3dbf1Smrg{
3238d5c3dbf1Smrg    $opt_debug
3239d5c3dbf1Smrg    my_outputname="$1"
3240d5c3dbf1Smrg    my_originator="$2"
3241d5c3dbf1Smrg    my_pic_p="${3-no}"
3242d5c3dbf1Smrg    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
3243d5c3dbf1Smrg    my_dlsyms=
3244d5c3dbf1Smrg
3245d5c3dbf1Smrg    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
3246d5c3dbf1Smrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
3247d5c3dbf1Smrg	my_dlsyms="${my_outputname}S.c"
3248d5c3dbf1Smrg      else
3249d5c3dbf1Smrg	func_error "not configured to extract global symbols from dlpreopened files"
3250d5c3dbf1Smrg      fi
3251d5c3dbf1Smrg    fi
3252d5c3dbf1Smrg
3253d5c3dbf1Smrg    if test -n "$my_dlsyms"; then
3254d5c3dbf1Smrg      case $my_dlsyms in
3255d5c3dbf1Smrg      "") ;;
3256d5c3dbf1Smrg      *.c)
3257d5c3dbf1Smrg	# Discover the nlist of each of the dlfiles.
3258d5c3dbf1Smrg	nlist="$output_objdir/${my_outputname}.nm"
3259d5c3dbf1Smrg
3260d5c3dbf1Smrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
3261d5c3dbf1Smrg
3262d5c3dbf1Smrg	# Parse the name list into a source file.
3263d5c3dbf1Smrg	func_verbose "creating $output_objdir/$my_dlsyms"
3264d5c3dbf1Smrg
3265d5c3dbf1Smrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
3266d5c3dbf1Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
3267d5c3dbf1Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
3268d5c3dbf1Smrg
3269d5c3dbf1Smrg#ifdef __cplusplus
3270d5c3dbf1Smrgextern \"C\" {
3271d5c3dbf1Smrg#endif
3272d5c3dbf1Smrg
3273d5c3dbf1Smrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
3274d5c3dbf1Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
3275d5c3dbf1Smrg#endif
3276d5c3dbf1Smrg
3277cdbfa18aSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
3278cdbfa18aSmrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
3279cdbfa18aSmrg/* DATA imports from DLLs on WIN32 con't be const, because runtime
3280cdbfa18aSmrg   relocations are performed -- see ld's documentation on pseudo-relocs.  */
3281cdbfa18aSmrg# define LT_DLSYM_CONST
3282cdbfa18aSmrg#elif defined(__osf__)
3283cdbfa18aSmrg/* This system does not cope well with relocations in const data.  */
3284cdbfa18aSmrg# define LT_DLSYM_CONST
3285cdbfa18aSmrg#else
3286cdbfa18aSmrg# define LT_DLSYM_CONST const
3287cdbfa18aSmrg#endif
3288cdbfa18aSmrg
3289d5c3dbf1Smrg/* External symbol declarations for the compiler. */\
3290d5c3dbf1Smrg"
3291d5c3dbf1Smrg
3292d5c3dbf1Smrg	if test "$dlself" = yes; then
3293d5c3dbf1Smrg	  func_verbose "generating symbol list for \`$output'"
3294d5c3dbf1Smrg
3295d5c3dbf1Smrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
3296d5c3dbf1Smrg
3297d5c3dbf1Smrg	  # Add our own program objects to the symbol list.
3298d5c3dbf1Smrg	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
3299d5c3dbf1Smrg	  for progfile in $progfiles; do
3300cdbfa18aSmrg	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
3301cdbfa18aSmrg	    func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
3302cdbfa18aSmrg	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
3303d5c3dbf1Smrg	  done
3304d5c3dbf1Smrg
3305d5c3dbf1Smrg	  if test -n "$exclude_expsyms"; then
3306d5c3dbf1Smrg	    $opt_dry_run || {
3307d5c3dbf1Smrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
3308d5c3dbf1Smrg	      eval '$MV "$nlist"T "$nlist"'
3309d5c3dbf1Smrg	    }
33109f606849Smrg	  fi
3311d5c3dbf1Smrg
3312d5c3dbf1Smrg	  if test -n "$export_symbols_regex"; then
3313d5c3dbf1Smrg	    $opt_dry_run || {
3314d5c3dbf1Smrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
3315d5c3dbf1Smrg	      eval '$MV "$nlist"T "$nlist"'
3316d5c3dbf1Smrg	    }
3317d5c3dbf1Smrg	  fi
3318d5c3dbf1Smrg
3319d5c3dbf1Smrg	  # Prepare the list of exported symbols
3320d5c3dbf1Smrg	  if test -z "$export_symbols"; then
3321d5c3dbf1Smrg	    export_symbols="$output_objdir/$outputname.exp"
3322d5c3dbf1Smrg	    $opt_dry_run || {
3323d5c3dbf1Smrg	      $RM $export_symbols
3324d5c3dbf1Smrg	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
3325d5c3dbf1Smrg	      case $host in
3326d5c3dbf1Smrg	      *cygwin* | *mingw* | *cegcc* )
3327d5c3dbf1Smrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3328d5c3dbf1Smrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
3329d5c3dbf1Smrg	        ;;
3330d5c3dbf1Smrg	      esac
3331d5c3dbf1Smrg	    }
33329f606849Smrg	  else
3333d5c3dbf1Smrg	    $opt_dry_run || {
3334d5c3dbf1Smrg	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
3335d5c3dbf1Smrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
3336d5c3dbf1Smrg	      eval '$MV "$nlist"T "$nlist"'
3337d5c3dbf1Smrg	      case $host in
3338d5c3dbf1Smrg	        *cygwin* | *mingw* | *cegcc* )
3339d5c3dbf1Smrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3340d5c3dbf1Smrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
3341d5c3dbf1Smrg	          ;;
3342d5c3dbf1Smrg	      esac
3343d5c3dbf1Smrg	    }
33449f606849Smrg	  fi
3345d5c3dbf1Smrg	fi
33469f606849Smrg
3347d5c3dbf1Smrg	for dlprefile in $dlprefiles; do
3348d5c3dbf1Smrg	  func_verbose "extracting global C symbols from \`$dlprefile'"
3349d5c3dbf1Smrg	  func_basename "$dlprefile"
3350d5c3dbf1Smrg	  name="$func_basename_result"
3351cdbfa18aSmrg          case $host in
3352cdbfa18aSmrg	    *cygwin* | *mingw* | *cegcc* )
3353cdbfa18aSmrg	      # if an import library, we need to obtain dlname
3354cdbfa18aSmrg	      if func_win32_import_lib_p "$dlprefile"; then
3355cdbfa18aSmrg	        func_tr_sh "$dlprefile"
3356cdbfa18aSmrg	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
3357cdbfa18aSmrg	        dlprefile_dlbasename=""
3358cdbfa18aSmrg	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
3359cdbfa18aSmrg	          # Use subshell, to avoid clobbering current variable values
3360cdbfa18aSmrg	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
3361cdbfa18aSmrg	          if test -n "$dlprefile_dlname" ; then
3362cdbfa18aSmrg	            func_basename "$dlprefile_dlname"
3363cdbfa18aSmrg	            dlprefile_dlbasename="$func_basename_result"
3364cdbfa18aSmrg	          else
3365cdbfa18aSmrg	            # no lafile. user explicitly requested -dlpreopen <import library>.
3366cdbfa18aSmrg	            $sharedlib_from_linklib_cmd "$dlprefile"
3367cdbfa18aSmrg	            dlprefile_dlbasename=$sharedlib_from_linklib_result
3368cdbfa18aSmrg	          fi
3369cdbfa18aSmrg	        fi
3370cdbfa18aSmrg	        $opt_dry_run || {
3371cdbfa18aSmrg	          if test -n "$dlprefile_dlbasename" ; then
3372cdbfa18aSmrg	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
3373cdbfa18aSmrg	          else
3374cdbfa18aSmrg	            func_warning "Could not compute DLL name from $name"
3375cdbfa18aSmrg	            eval '$ECHO ": $name " >> "$nlist"'
3376cdbfa18aSmrg	          fi
3377cdbfa18aSmrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3378cdbfa18aSmrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
3379cdbfa18aSmrg	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
3380cdbfa18aSmrg	        }
3381cdbfa18aSmrg	      else # not an import lib
3382cdbfa18aSmrg	        $opt_dry_run || {
3383cdbfa18aSmrg	          eval '$ECHO ": $name " >> "$nlist"'
3384cdbfa18aSmrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3385cdbfa18aSmrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3386cdbfa18aSmrg	        }
3387cdbfa18aSmrg	      fi
3388cdbfa18aSmrg	    ;;
3389cdbfa18aSmrg	    *)
3390cdbfa18aSmrg	      $opt_dry_run || {
3391cdbfa18aSmrg	        eval '$ECHO ": $name " >> "$nlist"'
3392cdbfa18aSmrg	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3393cdbfa18aSmrg	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3394cdbfa18aSmrg	      }
3395cdbfa18aSmrg	    ;;
3396cdbfa18aSmrg          esac
3397d5c3dbf1Smrg	done
3398d5c3dbf1Smrg
3399d5c3dbf1Smrg	$opt_dry_run || {
3400d5c3dbf1Smrg	  # Make sure we have at least an empty file.
3401d5c3dbf1Smrg	  test -f "$nlist" || : > "$nlist"
3402d5c3dbf1Smrg
3403d5c3dbf1Smrg	  if test -n "$exclude_expsyms"; then
3404d5c3dbf1Smrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
3405d5c3dbf1Smrg	    $MV "$nlist"T "$nlist"
34069f606849Smrg	  fi
3407d5c3dbf1Smrg
3408d5c3dbf1Smrg	  # Try sorting and uniquifying the output.
3409d5c3dbf1Smrg	  if $GREP -v "^: " < "$nlist" |
3410d5c3dbf1Smrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
3411d5c3dbf1Smrg		sort -k 3
3412d5c3dbf1Smrg	      else
3413d5c3dbf1Smrg		sort +2
3414d5c3dbf1Smrg	      fi |
3415d5c3dbf1Smrg	      uniq > "$nlist"S; then
3416d5c3dbf1Smrg	    :
34179f606849Smrg	  else
3418d5c3dbf1Smrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
34199f606849Smrg	  fi
34209f606849Smrg
3421d5c3dbf1Smrg	  if test -f "$nlist"S; then
3422d5c3dbf1Smrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
34239f606849Smrg	  else
3424d5c3dbf1Smrg	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
34259f606849Smrg	  fi
34269f606849Smrg
3427d5c3dbf1Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
34289f606849Smrg
3429d5c3dbf1Smrg/* The mapping between symbol names and symbols.  */
3430d5c3dbf1Smrgtypedef struct {
3431d5c3dbf1Smrg  const char *name;
3432d5c3dbf1Smrg  void *address;
3433d5c3dbf1Smrg} lt_dlsymlist;
3434cdbfa18aSmrgextern LT_DLSYM_CONST lt_dlsymlist
3435d5c3dbf1Smrglt_${my_prefix}_LTX_preloaded_symbols[];
3436cdbfa18aSmrgLT_DLSYM_CONST lt_dlsymlist
3437d5c3dbf1Smrglt_${my_prefix}_LTX_preloaded_symbols[] =
3438d5c3dbf1Smrg{\
3439d5c3dbf1Smrg  { \"$my_originator\", (void *) 0 },"
34409f606849Smrg
3441d5c3dbf1Smrg	  case $need_lib_prefix in
3442d5c3dbf1Smrg	  no)
3443d5c3dbf1Smrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
3444d5c3dbf1Smrg	    ;;
3445d5c3dbf1Smrg	  *)
3446d5c3dbf1Smrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
3447d5c3dbf1Smrg	    ;;
3448d5c3dbf1Smrg	  esac
3449d5c3dbf1Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
3450d5c3dbf1Smrg  {0, (void *) 0}
3451d5c3dbf1Smrg};
34529f606849Smrg
3453d5c3dbf1Smrg/* This works around a problem in FreeBSD linker */
3454d5c3dbf1Smrg#ifdef FREEBSD_WORKAROUND
3455d5c3dbf1Smrgstatic const void *lt_preloaded_setup() {
3456d5c3dbf1Smrg  return lt_${my_prefix}_LTX_preloaded_symbols;
3457d5c3dbf1Smrg}
3458d5c3dbf1Smrg#endif
34599f606849Smrg
3460d5c3dbf1Smrg#ifdef __cplusplus
3461d5c3dbf1Smrg}
3462d5c3dbf1Smrg#endif\
3463d5c3dbf1Smrg"
3464d5c3dbf1Smrg	} # !$opt_dry_run
34659f606849Smrg
3466d5c3dbf1Smrg	pic_flag_for_symtable=
3467d5c3dbf1Smrg	case "$compile_command " in
3468d5c3dbf1Smrg	*" -static "*) ;;
3469d5c3dbf1Smrg	*)
3470d5c3dbf1Smrg	  case $host in
3471d5c3dbf1Smrg	  # compiling the symbol table file with pic_flag works around
3472d5c3dbf1Smrg	  # a FreeBSD bug that causes programs to crash when -lm is
3473d5c3dbf1Smrg	  # linked before any other PIC object.  But we must not use
3474d5c3dbf1Smrg	  # pic_flag when linking with -static.  The problem exists in
3475d5c3dbf1Smrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
3476cdbfa18aSmrg	  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
3477d5c3dbf1Smrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
3478d5c3dbf1Smrg	  *-*-hpux*)
3479d5c3dbf1Smrg	    pic_flag_for_symtable=" $pic_flag"  ;;
3480d5c3dbf1Smrg	  *)
3481d5c3dbf1Smrg	    if test "X$my_pic_p" != Xno; then
3482d5c3dbf1Smrg	      pic_flag_for_symtable=" $pic_flag"
3483d5c3dbf1Smrg	    fi
3484d5c3dbf1Smrg	    ;;
3485d5c3dbf1Smrg	  esac
3486d5c3dbf1Smrg	  ;;
3487d5c3dbf1Smrg	esac
3488d5c3dbf1Smrg	symtab_cflags=
3489d5c3dbf1Smrg	for arg in $LTCFLAGS; do
3490d5c3dbf1Smrg	  case $arg in
3491d5c3dbf1Smrg	  -pie | -fpie | -fPIE) ;;
3492cdbfa18aSmrg	  *) func_append symtab_cflags " $arg" ;;
3493d5c3dbf1Smrg	  esac
3494d5c3dbf1Smrg	done
34959f606849Smrg
3496d5c3dbf1Smrg	# Now compile the dynamic symbol file.
3497d5c3dbf1Smrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
34989f606849Smrg
3499d5c3dbf1Smrg	# Clean up the generated files.
3500d5c3dbf1Smrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
35019f606849Smrg
3502d5c3dbf1Smrg	# Transform the symbol file into the correct name.
3503d5c3dbf1Smrg	symfileobj="$output_objdir/${my_outputname}S.$objext"
3504d5c3dbf1Smrg	case $host in
3505d5c3dbf1Smrg	*cygwin* | *mingw* | *cegcc* )
3506d5c3dbf1Smrg	  if test -f "$output_objdir/$my_outputname.def"; then
3507d5c3dbf1Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3508d5c3dbf1Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3509d5c3dbf1Smrg	  else
3510d5c3dbf1Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3511d5c3dbf1Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3512d5c3dbf1Smrg	  fi
3513d5c3dbf1Smrg	  ;;
3514d5c3dbf1Smrg	*)
3515d5c3dbf1Smrg	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3516d5c3dbf1Smrg	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3517d5c3dbf1Smrg	  ;;
3518d5c3dbf1Smrg	esac
3519d5c3dbf1Smrg	;;
3520d5c3dbf1Smrg      *)
3521d5c3dbf1Smrg	func_fatal_error "unknown suffix for \`$my_dlsyms'"
3522d5c3dbf1Smrg	;;
3523d5c3dbf1Smrg      esac
3524d5c3dbf1Smrg    else
3525d5c3dbf1Smrg      # We keep going just in case the user didn't refer to
3526d5c3dbf1Smrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
3527d5c3dbf1Smrg      # really was required.
35289f606849Smrg
3529d5c3dbf1Smrg      # Nullify the symbol file.
3530d5c3dbf1Smrg      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
3531d5c3dbf1Smrg      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
3532d5c3dbf1Smrg    fi
3533d5c3dbf1Smrg}
35349f606849Smrg
3535d5c3dbf1Smrg# func_win32_libid arg
3536d5c3dbf1Smrg# return the library type of file 'arg'
3537d5c3dbf1Smrg#
3538d5c3dbf1Smrg# Need a lot of goo to handle *both* DLLs and import libs
3539d5c3dbf1Smrg# Has to be a shell function in order to 'eat' the argument
3540d5c3dbf1Smrg# that is supplied when $file_magic_command is called.
3541d5c3dbf1Smrg# Despite the name, also deal with 64 bit binaries.
3542d5c3dbf1Smrgfunc_win32_libid ()
3543d5c3dbf1Smrg{
3544d5c3dbf1Smrg  $opt_debug
3545d5c3dbf1Smrg  win32_libid_type="unknown"
3546d5c3dbf1Smrg  win32_fileres=`file -L $1 2>/dev/null`
3547d5c3dbf1Smrg  case $win32_fileres in
3548d5c3dbf1Smrg  *ar\ archive\ import\ library*) # definitely import
3549d5c3dbf1Smrg    win32_libid_type="x86 archive import"
3550d5c3dbf1Smrg    ;;
3551d5c3dbf1Smrg  *ar\ archive*) # could be an import, or static
3552d5c3dbf1Smrg    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
3553d5c3dbf1Smrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
3554d5c3dbf1Smrg       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
3555cdbfa18aSmrg      func_to_tool_file "$1" func_convert_file_msys_to_w32
3556cdbfa18aSmrg      win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
3557d5c3dbf1Smrg	$SED -n -e '
3558d5c3dbf1Smrg	    1,100{
3559d5c3dbf1Smrg		/ I /{
3560d5c3dbf1Smrg		    s,.*,import,
3561d5c3dbf1Smrg		    p
3562d5c3dbf1Smrg		    q
3563d5c3dbf1Smrg		}
3564d5c3dbf1Smrg	    }'`
3565d5c3dbf1Smrg      case $win32_nmres in
3566d5c3dbf1Smrg      import*)  win32_libid_type="x86 archive import";;
3567d5c3dbf1Smrg      *)        win32_libid_type="x86 archive static";;
3568d5c3dbf1Smrg      esac
3569d5c3dbf1Smrg    fi
3570d5c3dbf1Smrg    ;;
3571d5c3dbf1Smrg  *DLL*)
3572d5c3dbf1Smrg    win32_libid_type="x86 DLL"
3573d5c3dbf1Smrg    ;;
3574d5c3dbf1Smrg  *executable*) # but shell scripts are "executable" too...
3575d5c3dbf1Smrg    case $win32_fileres in
3576d5c3dbf1Smrg    *MS\ Windows\ PE\ Intel*)
3577d5c3dbf1Smrg      win32_libid_type="x86 DLL"
3578d5c3dbf1Smrg      ;;
3579d5c3dbf1Smrg    esac
3580d5c3dbf1Smrg    ;;
3581d5c3dbf1Smrg  esac
3582d5c3dbf1Smrg  $ECHO "$win32_libid_type"
3583d5c3dbf1Smrg}
35849f606849Smrg
3585cdbfa18aSmrg# func_cygming_dll_for_implib ARG
3586cdbfa18aSmrg#
3587cdbfa18aSmrg# Platform-specific function to extract the
3588cdbfa18aSmrg# name of the DLL associated with the specified
3589cdbfa18aSmrg# import library ARG.
3590cdbfa18aSmrg# Invoked by eval'ing the libtool variable
3591cdbfa18aSmrg#    $sharedlib_from_linklib_cmd
3592cdbfa18aSmrg# Result is available in the variable
3593cdbfa18aSmrg#    $sharedlib_from_linklib_result
3594cdbfa18aSmrgfunc_cygming_dll_for_implib ()
3595cdbfa18aSmrg{
3596cdbfa18aSmrg  $opt_debug
3597cdbfa18aSmrg  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
3598cdbfa18aSmrg}
3599cdbfa18aSmrg
3600cdbfa18aSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
3601cdbfa18aSmrg#
3602cdbfa18aSmrg# The is the core of a fallback implementation of a
3603cdbfa18aSmrg# platform-specific function to extract the name of the
3604cdbfa18aSmrg# DLL associated with the specified import library LIBNAME.
3605cdbfa18aSmrg#
3606cdbfa18aSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending
3607cdbfa18aSmrg# on the platform and compiler that created the implib.
3608cdbfa18aSmrg#
3609cdbfa18aSmrg# Echos the name of the DLL associated with the
3610cdbfa18aSmrg# specified import library.
3611cdbfa18aSmrgfunc_cygming_dll_for_implib_fallback_core ()
3612cdbfa18aSmrg{
3613cdbfa18aSmrg  $opt_debug
3614cdbfa18aSmrg  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
3615cdbfa18aSmrg  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
3616cdbfa18aSmrg    $SED '/^Contents of section '"$match_literal"':/{
3617cdbfa18aSmrg      # Place marker at beginning of archive member dllname section
3618cdbfa18aSmrg      s/.*/====MARK====/
3619cdbfa18aSmrg      p
3620cdbfa18aSmrg      d
3621cdbfa18aSmrg    }
3622cdbfa18aSmrg    # These lines can sometimes be longer than 43 characters, but
3623cdbfa18aSmrg    # are always uninteresting
3624cdbfa18aSmrg    /:[	 ]*file format pe[i]\{,1\}-/d
3625cdbfa18aSmrg    /^In archive [^:]*:/d
3626cdbfa18aSmrg    # Ensure marker is printed
3627cdbfa18aSmrg    /^====MARK====/p
3628cdbfa18aSmrg    # Remove all lines with less than 43 characters
3629cdbfa18aSmrg    /^.\{43\}/!d
3630cdbfa18aSmrg    # From remaining lines, remove first 43 characters
3631cdbfa18aSmrg    s/^.\{43\}//' |
3632cdbfa18aSmrg    $SED -n '
3633cdbfa18aSmrg      # Join marker and all lines until next marker into a single line
3634cdbfa18aSmrg      /^====MARK====/ b para
3635cdbfa18aSmrg      H
3636cdbfa18aSmrg      $ b para
3637cdbfa18aSmrg      b
3638cdbfa18aSmrg      :para
3639cdbfa18aSmrg      x
3640cdbfa18aSmrg      s/\n//g
3641cdbfa18aSmrg      # Remove the marker
3642cdbfa18aSmrg      s/^====MARK====//
3643cdbfa18aSmrg      # Remove trailing dots and whitespace
3644cdbfa18aSmrg      s/[\. \t]*$//
3645cdbfa18aSmrg      # Print
3646cdbfa18aSmrg      /./p' |
3647cdbfa18aSmrg    # we now have a list, one entry per line, of the stringified
3648cdbfa18aSmrg    # contents of the appropriate section of all members of the
3649cdbfa18aSmrg    # archive which possess that section. Heuristic: eliminate
3650cdbfa18aSmrg    # all those which have a first or second character that is
3651cdbfa18aSmrg    # a '.' (that is, objdump's representation of an unprintable
3652cdbfa18aSmrg    # character.) This should work for all archives with less than
3653cdbfa18aSmrg    # 0x302f exports -- but will fail for DLLs whose name actually
3654cdbfa18aSmrg    # begins with a literal '.' or a single character followed by
3655cdbfa18aSmrg    # a '.'.
3656cdbfa18aSmrg    #
3657cdbfa18aSmrg    # Of those that remain, print the first one.
3658cdbfa18aSmrg    $SED -e '/^\./d;/^.\./d;q'
3659cdbfa18aSmrg}
3660cdbfa18aSmrg
3661cdbfa18aSmrg# func_cygming_gnu_implib_p ARG
3662cdbfa18aSmrg# This predicate returns with zero status (TRUE) if
3663cdbfa18aSmrg# ARG is a GNU/binutils-style import library. Returns
3664cdbfa18aSmrg# with nonzero status (FALSE) otherwise.
3665cdbfa18aSmrgfunc_cygming_gnu_implib_p ()
3666cdbfa18aSmrg{
3667cdbfa18aSmrg  $opt_debug
3668cdbfa18aSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
3669cdbfa18aSmrg  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)$'`
3670cdbfa18aSmrg  test -n "$func_cygming_gnu_implib_tmp"
3671cdbfa18aSmrg}
3672cdbfa18aSmrg
3673cdbfa18aSmrg# func_cygming_ms_implib_p ARG
3674cdbfa18aSmrg# This predicate returns with zero status (TRUE) if
3675cdbfa18aSmrg# ARG is an MS-style import library. Returns
3676cdbfa18aSmrg# with nonzero status (FALSE) otherwise.
3677cdbfa18aSmrgfunc_cygming_ms_implib_p ()
3678cdbfa18aSmrg{
3679cdbfa18aSmrg  $opt_debug
3680cdbfa18aSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
3681cdbfa18aSmrg  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
3682cdbfa18aSmrg  test -n "$func_cygming_ms_implib_tmp"
3683cdbfa18aSmrg}
3684cdbfa18aSmrg
3685cdbfa18aSmrg# func_cygming_dll_for_implib_fallback ARG
3686cdbfa18aSmrg# Platform-specific function to extract the
3687cdbfa18aSmrg# name of the DLL associated with the specified
3688cdbfa18aSmrg# import library ARG.
3689cdbfa18aSmrg#
3690cdbfa18aSmrg# This fallback implementation is for use when $DLLTOOL
3691cdbfa18aSmrg# does not support the --identify-strict option.
3692cdbfa18aSmrg# Invoked by eval'ing the libtool variable
3693cdbfa18aSmrg#    $sharedlib_from_linklib_cmd
3694cdbfa18aSmrg# Result is available in the variable
3695cdbfa18aSmrg#    $sharedlib_from_linklib_result
3696cdbfa18aSmrgfunc_cygming_dll_for_implib_fallback ()
3697cdbfa18aSmrg{
3698cdbfa18aSmrg  $opt_debug
3699cdbfa18aSmrg  if func_cygming_gnu_implib_p "$1" ; then
3700cdbfa18aSmrg    # binutils import library
3701cdbfa18aSmrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
3702cdbfa18aSmrg  elif func_cygming_ms_implib_p "$1" ; then
3703cdbfa18aSmrg    # ms-generated import library
3704cdbfa18aSmrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
3705cdbfa18aSmrg  else
3706cdbfa18aSmrg    # unknown
3707cdbfa18aSmrg    sharedlib_from_linklib_result=""
3708cdbfa18aSmrg  fi
3709cdbfa18aSmrg}
37109f606849Smrg
37119f606849Smrg
3712d5c3dbf1Smrg# func_extract_an_archive dir oldlib
3713d5c3dbf1Smrgfunc_extract_an_archive ()
3714d5c3dbf1Smrg{
3715d5c3dbf1Smrg    $opt_debug
3716d5c3dbf1Smrg    f_ex_an_ar_dir="$1"; shift
3717d5c3dbf1Smrg    f_ex_an_ar_oldlib="$1"
3718d5c3dbf1Smrg    if test "$lock_old_archive_extraction" = yes; then
3719d5c3dbf1Smrg      lockfile=$f_ex_an_ar_oldlib.lock
3720d5c3dbf1Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
3721d5c3dbf1Smrg	func_echo "Waiting for $lockfile to be removed"
3722d5c3dbf1Smrg	sleep 2
3723d5c3dbf1Smrg      done
3724d5c3dbf1Smrg    fi
3725d5c3dbf1Smrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
3726d5c3dbf1Smrg		   'stat=$?; rm -f "$lockfile"; exit $stat'
3727d5c3dbf1Smrg    if test "$lock_old_archive_extraction" = yes; then
3728d5c3dbf1Smrg      $opt_dry_run || rm -f "$lockfile"
3729d5c3dbf1Smrg    fi
3730d5c3dbf1Smrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
3731d5c3dbf1Smrg     :
3732d5c3dbf1Smrg    else
3733d5c3dbf1Smrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
3734d5c3dbf1Smrg    fi
3735d5c3dbf1Smrg}
37369f606849Smrg
37379f606849Smrg
3738d5c3dbf1Smrg# func_extract_archives gentop oldlib ...
3739d5c3dbf1Smrgfunc_extract_archives ()
3740d5c3dbf1Smrg{
3741d5c3dbf1Smrg    $opt_debug
3742d5c3dbf1Smrg    my_gentop="$1"; shift
3743d5c3dbf1Smrg    my_oldlibs=${1+"$@"}
3744d5c3dbf1Smrg    my_oldobjs=""
3745d5c3dbf1Smrg    my_xlib=""
3746d5c3dbf1Smrg    my_xabs=""
3747d5c3dbf1Smrg    my_xdir=""
37489f606849Smrg
3749d5c3dbf1Smrg    for my_xlib in $my_oldlibs; do
3750d5c3dbf1Smrg      # Extract the objects.
3751d5c3dbf1Smrg      case $my_xlib in
3752d5c3dbf1Smrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
3753d5c3dbf1Smrg	*) my_xabs=`pwd`"/$my_xlib" ;;
3754d5c3dbf1Smrg      esac
3755d5c3dbf1Smrg      func_basename "$my_xlib"
3756d5c3dbf1Smrg      my_xlib="$func_basename_result"
3757d5c3dbf1Smrg      my_xlib_u=$my_xlib
3758d5c3dbf1Smrg      while :; do
3759d5c3dbf1Smrg        case " $extracted_archives " in
3760d5c3dbf1Smrg	*" $my_xlib_u "*)
3761d5c3dbf1Smrg	  func_arith $extracted_serial + 1
3762d5c3dbf1Smrg	  extracted_serial=$func_arith_result
3763d5c3dbf1Smrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
3764d5c3dbf1Smrg	*) break ;;
3765d5c3dbf1Smrg	esac
3766d5c3dbf1Smrg      done
3767d5c3dbf1Smrg      extracted_archives="$extracted_archives $my_xlib_u"
3768d5c3dbf1Smrg      my_xdir="$my_gentop/$my_xlib_u"
37699f606849Smrg
3770d5c3dbf1Smrg      func_mkdir_p "$my_xdir"
3771d5c3dbf1Smrg
3772d5c3dbf1Smrg      case $host in
3773d5c3dbf1Smrg      *-darwin*)
3774d5c3dbf1Smrg	func_verbose "Extracting $my_xabs"
3775d5c3dbf1Smrg	# Do not bother doing anything if just a dry run
3776d5c3dbf1Smrg	$opt_dry_run || {
3777d5c3dbf1Smrg	  darwin_orig_dir=`pwd`
3778d5c3dbf1Smrg	  cd $my_xdir || exit $?
3779d5c3dbf1Smrg	  darwin_archive=$my_xabs
3780d5c3dbf1Smrg	  darwin_curdir=`pwd`
3781d5c3dbf1Smrg	  darwin_base_archive=`basename "$darwin_archive"`
3782d5c3dbf1Smrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
3783d5c3dbf1Smrg	  if test -n "$darwin_arches"; then
3784d5c3dbf1Smrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
3785d5c3dbf1Smrg	    darwin_arch=
3786d5c3dbf1Smrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
3787d5c3dbf1Smrg	    for darwin_arch in  $darwin_arches ; do
3788d5c3dbf1Smrg	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3789d5c3dbf1Smrg	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
3790d5c3dbf1Smrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3791d5c3dbf1Smrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
3792d5c3dbf1Smrg	      cd "$darwin_curdir"
3793d5c3dbf1Smrg	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
3794d5c3dbf1Smrg	    done # $darwin_arches
3795d5c3dbf1Smrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
3796d5c3dbf1Smrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
3797d5c3dbf1Smrg	    darwin_file=
3798d5c3dbf1Smrg	    darwin_files=
3799d5c3dbf1Smrg	    for darwin_file in $darwin_filelist; do
3800d5c3dbf1Smrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
3801d5c3dbf1Smrg	      $LIPO -create -output "$darwin_file" $darwin_files
3802d5c3dbf1Smrg	    done # $darwin_filelist
3803d5c3dbf1Smrg	    $RM -rf unfat-$$
3804d5c3dbf1Smrg	    cd "$darwin_orig_dir"
38059f606849Smrg	  else
3806d5c3dbf1Smrg	    cd $darwin_orig_dir
3807d5c3dbf1Smrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
3808d5c3dbf1Smrg	  fi # $darwin_arches
3809d5c3dbf1Smrg	} # !$opt_dry_run
3810d5c3dbf1Smrg	;;
3811d5c3dbf1Smrg      *)
3812d5c3dbf1Smrg        func_extract_an_archive "$my_xdir" "$my_xabs"
3813d5c3dbf1Smrg	;;
3814d5c3dbf1Smrg      esac
3815d5c3dbf1Smrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
3816d5c3dbf1Smrg    done
38179f606849Smrg
3818d5c3dbf1Smrg    func_extract_archives_result="$my_oldobjs"
3819d5c3dbf1Smrg}
38209f606849Smrg
38219f606849Smrg
3822d5c3dbf1Smrg# func_emit_wrapper [arg=no]
3823d5c3dbf1Smrg#
3824d5c3dbf1Smrg# Emit a libtool wrapper script on stdout.
3825d5c3dbf1Smrg# Don't directly open a file because we may want to
3826d5c3dbf1Smrg# incorporate the script contents within a cygwin/mingw
3827d5c3dbf1Smrg# wrapper executable.  Must ONLY be called from within
3828d5c3dbf1Smrg# func_mode_link because it depends on a number of variables
3829d5c3dbf1Smrg# set therein.
3830d5c3dbf1Smrg#
3831d5c3dbf1Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
3832d5c3dbf1Smrg# variable will take.  If 'yes', then the emitted script
3833d5c3dbf1Smrg# will assume that the directory in which it is stored is
3834d5c3dbf1Smrg# the $objdir directory.  This is a cygwin/mingw-specific
3835d5c3dbf1Smrg# behavior.
3836d5c3dbf1Smrgfunc_emit_wrapper ()
3837d5c3dbf1Smrg{
3838d5c3dbf1Smrg	func_emit_wrapper_arg1=${1-no}
38399f606849Smrg
3840d5c3dbf1Smrg	$ECHO "\
3841d5c3dbf1Smrg#! $SHELL
38429f606849Smrg
3843d5c3dbf1Smrg# $output - temporary wrapper script for $objdir/$outputname
3844d5c3dbf1Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
3845d5c3dbf1Smrg#
3846d5c3dbf1Smrg# The $output program cannot be directly executed until all the libtool
3847d5c3dbf1Smrg# libraries that it depends on are installed.
3848d5c3dbf1Smrg#
3849d5c3dbf1Smrg# This wrapper script should never be moved out of the build directory.
3850d5c3dbf1Smrg# If it is, it will not operate correctly.
38519f606849Smrg
3852d5c3dbf1Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
3853d5c3dbf1Smrg# metacharacters that are still active within double-quoted strings.
3854d5c3dbf1Smrgsed_quote_subst='$sed_quote_subst'
38559f606849Smrg
3856d5c3dbf1Smrg# Be Bourne compatible
3857d5c3dbf1Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
3858d5c3dbf1Smrg  emulate sh
3859d5c3dbf1Smrg  NULLCMD=:
3860d5c3dbf1Smrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
3861d5c3dbf1Smrg  # is contrary to our usage.  Disable this feature.
3862d5c3dbf1Smrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
3863d5c3dbf1Smrg  setopt NO_GLOB_SUBST
3864d5c3dbf1Smrgelse
3865d5c3dbf1Smrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
3866d5c3dbf1Smrgfi
3867d5c3dbf1SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
3868d5c3dbf1SmrgDUALCASE=1; export DUALCASE # for MKS sh
38699f606849Smrg
3870d5c3dbf1Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout
3871d5c3dbf1Smrg# if CDPATH is set.
3872d5c3dbf1Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
38739f606849Smrg
3874d5c3dbf1Smrgrelink_command=\"$relink_command\"
38759f606849Smrg
3876d5c3dbf1Smrg# This environment variable determines our operation mode.
3877d5c3dbf1Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then
3878d5c3dbf1Smrg  # install mode needs the following variables:
3879d5c3dbf1Smrg  generated_by_libtool_version='$macro_version'
3880d5c3dbf1Smrg  notinst_deplibs='$notinst_deplibs'
3881d5c3dbf1Smrgelse
3882d5c3dbf1Smrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
3883d5c3dbf1Smrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
3884d5c3dbf1Smrg    file=\"\$0\""
38859f606849Smrg
3886d5c3dbf1Smrg    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
3887d5c3dbf1Smrg    $ECHO "\
38889f606849Smrg
3889d5c3dbf1Smrg# A function that is used when there is no print builtin or printf.
3890d5c3dbf1Smrgfunc_fallback_echo ()
3891d5c3dbf1Smrg{
3892d5c3dbf1Smrg  eval 'cat <<_LTECHO_EOF
3893d5c3dbf1Smrg\$1
3894d5c3dbf1Smrg_LTECHO_EOF'
3895d5c3dbf1Smrg}
3896d5c3dbf1Smrg    ECHO=\"$qECHO\"
3897d5c3dbf1Smrg  fi
3898d5c3dbf1Smrg
3899d5c3dbf1Smrg# Very basic option parsing. These options are (a) specific to
3900d5c3dbf1Smrg# the libtool wrapper, (b) are identical between the wrapper
3901d5c3dbf1Smrg# /script/ and the wrapper /executable/ which is used only on
3902d5c3dbf1Smrg# windows platforms, and (c) all begin with the string "--lt-"
3903d5c3dbf1Smrg# (application programs are unlikely to have options which match
3904d5c3dbf1Smrg# this pattern).
3905d5c3dbf1Smrg#
3906d5c3dbf1Smrg# There are only two supported options: --lt-debug and
3907d5c3dbf1Smrg# --lt-dump-script. There is, deliberately, no --lt-help.
3908d5c3dbf1Smrg#
3909d5c3dbf1Smrg# The first argument to this parsing function should be the
3910d5c3dbf1Smrg# script's $0 value, followed by "$@".
3911d5c3dbf1Smrglt_option_debug=
3912d5c3dbf1Smrgfunc_parse_lt_options ()
3913d5c3dbf1Smrg{
3914d5c3dbf1Smrg  lt_script_arg0=\$0
3915d5c3dbf1Smrg  shift
3916d5c3dbf1Smrg  for lt_opt
3917d5c3dbf1Smrg  do
3918d5c3dbf1Smrg    case \"\$lt_opt\" in
3919d5c3dbf1Smrg    --lt-debug) lt_option_debug=1 ;;
3920d5c3dbf1Smrg    --lt-dump-script)
3921d5c3dbf1Smrg        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
3922d5c3dbf1Smrg        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
3923d5c3dbf1Smrg        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
3924d5c3dbf1Smrg        cat \"\$lt_dump_D/\$lt_dump_F\"
3925d5c3dbf1Smrg        exit 0
3926d5c3dbf1Smrg      ;;
3927d5c3dbf1Smrg    --lt-*)
3928d5c3dbf1Smrg        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
3929d5c3dbf1Smrg        exit 1
39309f606849Smrg      ;;
3931d5c3dbf1Smrg    esac
3932d5c3dbf1Smrg  done
39339f606849Smrg
3934d5c3dbf1Smrg  # Print the debug banner immediately:
3935d5c3dbf1Smrg  if test -n \"\$lt_option_debug\"; then
3936d5c3dbf1Smrg    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
3937d5c3dbf1Smrg  fi
3938d5c3dbf1Smrg}
39399f606849Smrg
3940d5c3dbf1Smrg# Used when --lt-debug. Prints its arguments to stdout
3941d5c3dbf1Smrg# (redirection is the responsibility of the caller)
3942d5c3dbf1Smrgfunc_lt_dump_args ()
3943d5c3dbf1Smrg{
3944d5c3dbf1Smrg  lt_dump_args_N=1;
3945d5c3dbf1Smrg  for lt_arg
3946d5c3dbf1Smrg  do
3947d5c3dbf1Smrg    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
3948d5c3dbf1Smrg    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
3949d5c3dbf1Smrg  done
3950d5c3dbf1Smrg}
39519f606849Smrg
3952d5c3dbf1Smrg# Core function for launching the target application
3953d5c3dbf1Smrgfunc_exec_program_core ()
3954d5c3dbf1Smrg{
3955d5c3dbf1Smrg"
3956d5c3dbf1Smrg  case $host in
3957d5c3dbf1Smrg  # Backslashes separate directories on plain windows
3958d5c3dbf1Smrg  *-*-mingw | *-*-os2* | *-cegcc*)
3959d5c3dbf1Smrg    $ECHO "\
3960d5c3dbf1Smrg      if test -n \"\$lt_option_debug\"; then
3961d5c3dbf1Smrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
3962d5c3dbf1Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
39639f606849Smrg      fi
3964d5c3dbf1Smrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
3965d5c3dbf1Smrg"
3966d5c3dbf1Smrg    ;;
39679f606849Smrg
3968d5c3dbf1Smrg  *)
3969d5c3dbf1Smrg    $ECHO "\
3970d5c3dbf1Smrg      if test -n \"\$lt_option_debug\"; then
3971d5c3dbf1Smrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
3972d5c3dbf1Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
39739f606849Smrg      fi
3974d5c3dbf1Smrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
3975d5c3dbf1Smrg"
3976d5c3dbf1Smrg    ;;
3977d5c3dbf1Smrg  esac
3978d5c3dbf1Smrg  $ECHO "\
3979d5c3dbf1Smrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
3980d5c3dbf1Smrg      exit 1
3981d5c3dbf1Smrg}
39829f606849Smrg
3983d5c3dbf1Smrg# A function to encapsulate launching the target application
3984d5c3dbf1Smrg# Strips options in the --lt-* namespace from \$@ and
3985d5c3dbf1Smrg# launches target application with the remaining arguments.
3986d5c3dbf1Smrgfunc_exec_program ()
3987d5c3dbf1Smrg{
3988cdbfa18aSmrg  case \" \$* \" in
3989cdbfa18aSmrg  *\\ --lt-*)
3990cdbfa18aSmrg    for lt_wr_arg
3991cdbfa18aSmrg    do
3992cdbfa18aSmrg      case \$lt_wr_arg in
3993cdbfa18aSmrg      --lt-*) ;;
3994cdbfa18aSmrg      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
3995cdbfa18aSmrg      esac
3996cdbfa18aSmrg      shift
3997cdbfa18aSmrg    done ;;
3998cdbfa18aSmrg  esac
3999d5c3dbf1Smrg  func_exec_program_core \${1+\"\$@\"}
4000d5c3dbf1Smrg}
40019f606849Smrg
4002d5c3dbf1Smrg  # Parse options
4003d5c3dbf1Smrg  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
40049f606849Smrg
4005d5c3dbf1Smrg  # Find the directory that this script lives in.
4006d5c3dbf1Smrg  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
4007d5c3dbf1Smrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
40089f606849Smrg
4009d5c3dbf1Smrg  # Follow symbolic links until we get to the real thisdir.
4010d5c3dbf1Smrg  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
4011d5c3dbf1Smrg  while test -n \"\$file\"; do
4012d5c3dbf1Smrg    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
40139f606849Smrg
4014d5c3dbf1Smrg    # If there was a directory component, then change thisdir.
4015d5c3dbf1Smrg    if test \"x\$destdir\" != \"x\$file\"; then
4016d5c3dbf1Smrg      case \"\$destdir\" in
4017d5c3dbf1Smrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
4018d5c3dbf1Smrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
4019d5c3dbf1Smrg      esac
4020d5c3dbf1Smrg    fi
40219f606849Smrg
4022d5c3dbf1Smrg    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
4023d5c3dbf1Smrg    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
4024d5c3dbf1Smrg  done
40259f606849Smrg
4026d5c3dbf1Smrg  # Usually 'no', except on cygwin/mingw when embedded into
4027d5c3dbf1Smrg  # the cwrapper.
4028d5c3dbf1Smrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
4029d5c3dbf1Smrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
4030d5c3dbf1Smrg    # special case for '.'
4031d5c3dbf1Smrg    if test \"\$thisdir\" = \".\"; then
4032d5c3dbf1Smrg      thisdir=\`pwd\`
4033d5c3dbf1Smrg    fi
4034d5c3dbf1Smrg    # remove .libs from thisdir
4035d5c3dbf1Smrg    case \"\$thisdir\" in
4036d5c3dbf1Smrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
4037d5c3dbf1Smrg    $objdir )   thisdir=. ;;
4038d5c3dbf1Smrg    esac
4039d5c3dbf1Smrg  fi
40409f606849Smrg
4041d5c3dbf1Smrg  # Try to get the absolute directory name.
4042d5c3dbf1Smrg  absdir=\`cd \"\$thisdir\" && pwd\`
4043d5c3dbf1Smrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
4044d5c3dbf1Smrg"
40459f606849Smrg
4046d5c3dbf1Smrg	if test "$fast_install" = yes; then
4047d5c3dbf1Smrg	  $ECHO "\
4048d5c3dbf1Smrg  program=lt-'$outputname'$exeext
4049d5c3dbf1Smrg  progdir=\"\$thisdir/$objdir\"
40509f606849Smrg
4051d5c3dbf1Smrg  if test ! -f \"\$progdir/\$program\" ||
4052d5c3dbf1Smrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
4053d5c3dbf1Smrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
40549f606849Smrg
4055d5c3dbf1Smrg    file=\"\$\$-\$program\"
40569f606849Smrg
4057d5c3dbf1Smrg    if test ! -d \"\$progdir\"; then
4058d5c3dbf1Smrg      $MKDIR \"\$progdir\"
4059d5c3dbf1Smrg    else
4060d5c3dbf1Smrg      $RM \"\$progdir/\$file\"
4061d5c3dbf1Smrg    fi"
40629f606849Smrg
4063d5c3dbf1Smrg	  $ECHO "\
40649f606849Smrg
4065d5c3dbf1Smrg    # relink executable if necessary
4066d5c3dbf1Smrg    if test -n \"\$relink_command\"; then
4067d5c3dbf1Smrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
4068d5c3dbf1Smrg      else
4069d5c3dbf1Smrg	$ECHO \"\$relink_command_output\" >&2
4070d5c3dbf1Smrg	$RM \"\$progdir/\$file\"
4071d5c3dbf1Smrg	exit 1
4072d5c3dbf1Smrg      fi
4073d5c3dbf1Smrg    fi
40749f606849Smrg
4075d5c3dbf1Smrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
4076d5c3dbf1Smrg    { $RM \"\$progdir/\$program\";
4077d5c3dbf1Smrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
4078d5c3dbf1Smrg    $RM \"\$progdir/\$file\"
4079d5c3dbf1Smrg  fi"
4080d5c3dbf1Smrg	else
4081d5c3dbf1Smrg	  $ECHO "\
4082d5c3dbf1Smrg  program='$outputname'
4083d5c3dbf1Smrg  progdir=\"\$thisdir/$objdir\"
4084d5c3dbf1Smrg"
4085d5c3dbf1Smrg	fi
40869f606849Smrg
4087d5c3dbf1Smrg	$ECHO "\
40889f606849Smrg
4089d5c3dbf1Smrg  if test -f \"\$progdir/\$program\"; then"
40909f606849Smrg
4091cdbfa18aSmrg	# fixup the dll searchpath if we need to.
4092cdbfa18aSmrg	#
4093cdbfa18aSmrg	# Fix the DLL searchpath if we need to.  Do this before prepending
4094cdbfa18aSmrg	# to shlibpath, because on Windows, both are PATH and uninstalled
4095cdbfa18aSmrg	# libraries must come first.
4096cdbfa18aSmrg	if test -n "$dllsearchpath"; then
4097cdbfa18aSmrg	  $ECHO "\
4098cdbfa18aSmrg    # Add the dll search path components to the executable PATH
4099cdbfa18aSmrg    PATH=$dllsearchpath:\$PATH
4100cdbfa18aSmrg"
4101cdbfa18aSmrg	fi
4102cdbfa18aSmrg
4103d5c3dbf1Smrg	# Export our shlibpath_var if we have one.
4104d5c3dbf1Smrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4105d5c3dbf1Smrg	  $ECHO "\
4106d5c3dbf1Smrg    # Add our own library path to $shlibpath_var
4107d5c3dbf1Smrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
41089f606849Smrg
4109d5c3dbf1Smrg    # Some systems cannot cope with colon-terminated $shlibpath_var
4110d5c3dbf1Smrg    # The second colon is a workaround for a bug in BeOS R4 sed
4111d5c3dbf1Smrg    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
41129f606849Smrg
4113d5c3dbf1Smrg    export $shlibpath_var
4114d5c3dbf1Smrg"
4115d5c3dbf1Smrg	fi
41169f606849Smrg
4117d5c3dbf1Smrg	$ECHO "\
4118d5c3dbf1Smrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
4119d5c3dbf1Smrg      # Run the actual program with our arguments.
4120d5c3dbf1Smrg      func_exec_program \${1+\"\$@\"}
4121d5c3dbf1Smrg    fi
4122d5c3dbf1Smrg  else
4123d5c3dbf1Smrg    # The program doesn't exist.
4124d5c3dbf1Smrg    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
4125d5c3dbf1Smrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
4126d5c3dbf1Smrg    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
4127d5c3dbf1Smrg    exit 1
4128d5c3dbf1Smrg  fi
4129d5c3dbf1Smrgfi\
4130d5c3dbf1Smrg"
4131d5c3dbf1Smrg}
41329f606849Smrg
41339f606849Smrg
4134d5c3dbf1Smrg# func_emit_cwrapperexe_src
4135d5c3dbf1Smrg# emit the source code for a wrapper executable on stdout
4136d5c3dbf1Smrg# Must ONLY be called from within func_mode_link because
4137d5c3dbf1Smrg# it depends on a number of variable set therein.
4138d5c3dbf1Smrgfunc_emit_cwrapperexe_src ()
4139d5c3dbf1Smrg{
4140d5c3dbf1Smrg	cat <<EOF
41419f606849Smrg
4142d5c3dbf1Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
4143d5c3dbf1Smrg   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
41449f606849Smrg
4145d5c3dbf1Smrg   The $output program cannot be directly executed until all the libtool
4146d5c3dbf1Smrg   libraries that it depends on are installed.
41479f606849Smrg
4148d5c3dbf1Smrg   This wrapper executable should never be moved out of the build directory.
4149d5c3dbf1Smrg   If it is, it will not operate correctly.
4150d5c3dbf1Smrg*/
4151d5c3dbf1SmrgEOF
4152d5c3dbf1Smrg	    cat <<"EOF"
4153d5c3dbf1Smrg#ifdef _MSC_VER
4154d5c3dbf1Smrg# define _CRT_SECURE_NO_DEPRECATE 1
4155d5c3dbf1Smrg#endif
4156d5c3dbf1Smrg#include <stdio.h>
4157d5c3dbf1Smrg#include <stdlib.h>
4158d5c3dbf1Smrg#ifdef _MSC_VER
4159d5c3dbf1Smrg# include <direct.h>
4160d5c3dbf1Smrg# include <process.h>
4161d5c3dbf1Smrg# include <io.h>
4162d5c3dbf1Smrg#else
4163d5c3dbf1Smrg# include <unistd.h>
4164d5c3dbf1Smrg# include <stdint.h>
4165d5c3dbf1Smrg# ifdef __CYGWIN__
4166d5c3dbf1Smrg#  include <io.h>
4167d5c3dbf1Smrg# endif
4168d5c3dbf1Smrg#endif
4169d5c3dbf1Smrg#include <malloc.h>
4170d5c3dbf1Smrg#include <stdarg.h>
4171d5c3dbf1Smrg#include <assert.h>
4172d5c3dbf1Smrg#include <string.h>
4173d5c3dbf1Smrg#include <ctype.h>
4174d5c3dbf1Smrg#include <errno.h>
4175d5c3dbf1Smrg#include <fcntl.h>
4176d5c3dbf1Smrg#include <sys/stat.h>
41779f606849Smrg
4178d5c3dbf1Smrg/* declarations of non-ANSI functions */
4179d5c3dbf1Smrg#if defined(__MINGW32__)
4180d5c3dbf1Smrg# ifdef __STRICT_ANSI__
4181d5c3dbf1Smrgint _putenv (const char *);
4182d5c3dbf1Smrg# endif
4183d5c3dbf1Smrg#elif defined(__CYGWIN__)
4184d5c3dbf1Smrg# ifdef __STRICT_ANSI__
4185d5c3dbf1Smrgchar *realpath (const char *, char *);
4186d5c3dbf1Smrgint putenv (char *);
4187d5c3dbf1Smrgint setenv (const char *, const char *, int);
4188d5c3dbf1Smrg# endif
4189d5c3dbf1Smrg/* #elif defined (other platforms) ... */
4190d5c3dbf1Smrg#endif
41919f606849Smrg
4192d5c3dbf1Smrg/* portability defines, excluding path handling macros */
4193d5c3dbf1Smrg#if defined(_MSC_VER)
4194d5c3dbf1Smrg# define setmode _setmode
4195d5c3dbf1Smrg# define stat    _stat
4196d5c3dbf1Smrg# define chmod   _chmod
4197d5c3dbf1Smrg# define getcwd  _getcwd
4198d5c3dbf1Smrg# define putenv  _putenv
4199d5c3dbf1Smrg# define S_IXUSR _S_IEXEC
4200d5c3dbf1Smrg# ifndef _INTPTR_T_DEFINED
4201d5c3dbf1Smrg#  define _INTPTR_T_DEFINED
4202d5c3dbf1Smrg#  define intptr_t int
4203d5c3dbf1Smrg# endif
4204d5c3dbf1Smrg#elif defined(__MINGW32__)
4205d5c3dbf1Smrg# define setmode _setmode
4206d5c3dbf1Smrg# define stat    _stat
4207d5c3dbf1Smrg# define chmod   _chmod
4208d5c3dbf1Smrg# define getcwd  _getcwd
4209d5c3dbf1Smrg# define putenv  _putenv
4210d5c3dbf1Smrg#elif defined(__CYGWIN__)
4211d5c3dbf1Smrg# define HAVE_SETENV
4212d5c3dbf1Smrg# define FOPEN_WB "wb"
4213d5c3dbf1Smrg/* #elif defined (other platforms) ... */
4214d5c3dbf1Smrg#endif
42159f606849Smrg
4216d5c3dbf1Smrg#if defined(PATH_MAX)
4217d5c3dbf1Smrg# define LT_PATHMAX PATH_MAX
4218d5c3dbf1Smrg#elif defined(MAXPATHLEN)
4219d5c3dbf1Smrg# define LT_PATHMAX MAXPATHLEN
4220d5c3dbf1Smrg#else
4221d5c3dbf1Smrg# define LT_PATHMAX 1024
4222d5c3dbf1Smrg#endif
42239f606849Smrg
4224d5c3dbf1Smrg#ifndef S_IXOTH
4225d5c3dbf1Smrg# define S_IXOTH 0
4226d5c3dbf1Smrg#endif
4227d5c3dbf1Smrg#ifndef S_IXGRP
4228d5c3dbf1Smrg# define S_IXGRP 0
4229d5c3dbf1Smrg#endif
42309f606849Smrg
4231d5c3dbf1Smrg/* path handling portability macros */
4232d5c3dbf1Smrg#ifndef DIR_SEPARATOR
4233d5c3dbf1Smrg# define DIR_SEPARATOR '/'
4234d5c3dbf1Smrg# define PATH_SEPARATOR ':'
4235d5c3dbf1Smrg#endif
42369f606849Smrg
4237d5c3dbf1Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
4238d5c3dbf1Smrg  defined (__OS2__)
4239d5c3dbf1Smrg# define HAVE_DOS_BASED_FILE_SYSTEM
4240d5c3dbf1Smrg# define FOPEN_WB "wb"
4241d5c3dbf1Smrg# ifndef DIR_SEPARATOR_2
4242d5c3dbf1Smrg#  define DIR_SEPARATOR_2 '\\'
4243d5c3dbf1Smrg# endif
4244d5c3dbf1Smrg# ifndef PATH_SEPARATOR_2
4245d5c3dbf1Smrg#  define PATH_SEPARATOR_2 ';'
4246d5c3dbf1Smrg# endif
4247d5c3dbf1Smrg#endif
42489f606849Smrg
4249d5c3dbf1Smrg#ifndef DIR_SEPARATOR_2
4250d5c3dbf1Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
4251d5c3dbf1Smrg#else /* DIR_SEPARATOR_2 */
4252d5c3dbf1Smrg# define IS_DIR_SEPARATOR(ch) \
4253d5c3dbf1Smrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
4254d5c3dbf1Smrg#endif /* DIR_SEPARATOR_2 */
42559f606849Smrg
4256d5c3dbf1Smrg#ifndef PATH_SEPARATOR_2
4257d5c3dbf1Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
4258d5c3dbf1Smrg#else /* PATH_SEPARATOR_2 */
4259d5c3dbf1Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
4260d5c3dbf1Smrg#endif /* PATH_SEPARATOR_2 */
4261d5c3dbf1Smrg
4262d5c3dbf1Smrg#ifndef FOPEN_WB
4263d5c3dbf1Smrg# define FOPEN_WB "w"
4264d5c3dbf1Smrg#endif
4265d5c3dbf1Smrg#ifndef _O_BINARY
4266d5c3dbf1Smrg# define _O_BINARY 0
4267d5c3dbf1Smrg#endif
4268d5c3dbf1Smrg
4269d5c3dbf1Smrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
4270d5c3dbf1Smrg#define XFREE(stale) do { \
4271d5c3dbf1Smrg  if (stale) { free ((void *) stale); stale = 0; } \
4272d5c3dbf1Smrg} while (0)
4273d5c3dbf1Smrg
4274d5c3dbf1Smrg#if defined(LT_DEBUGWRAPPER)
4275d5c3dbf1Smrgstatic int lt_debug = 1;
4276d5c3dbf1Smrg#else
4277d5c3dbf1Smrgstatic int lt_debug = 0;
4278d5c3dbf1Smrg#endif
4279d5c3dbf1Smrg
4280d5c3dbf1Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
4281d5c3dbf1Smrg
4282d5c3dbf1Smrgvoid *xmalloc (size_t num);
4283d5c3dbf1Smrgchar *xstrdup (const char *string);
4284d5c3dbf1Smrgconst char *base_name (const char *name);
4285d5c3dbf1Smrgchar *find_executable (const char *wrapper);
4286d5c3dbf1Smrgchar *chase_symlinks (const char *pathspec);
4287d5c3dbf1Smrgint make_executable (const char *path);
4288d5c3dbf1Smrgint check_executable (const char *path);
4289d5c3dbf1Smrgchar *strendzap (char *str, const char *pat);
4290d5c3dbf1Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
4291d5c3dbf1Smrgvoid lt_fatal (const char *file, int line, const char *message, ...);
4292d5c3dbf1Smrgstatic const char *nonnull (const char *s);
4293d5c3dbf1Smrgstatic const char *nonempty (const char *s);
4294d5c3dbf1Smrgvoid lt_setenv (const char *name, const char *value);
4295d5c3dbf1Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
4296d5c3dbf1Smrgvoid lt_update_exe_path (const char *name, const char *value);
4297d5c3dbf1Smrgvoid lt_update_lib_path (const char *name, const char *value);
4298d5c3dbf1Smrgchar **prepare_spawn (char **argv);
4299d5c3dbf1Smrgvoid lt_dump_script (FILE *f);
4300d5c3dbf1SmrgEOF
4301d5c3dbf1Smrg
4302d5c3dbf1Smrg	    cat <<EOF
4303cdbfa18aSmrgvolatile const char * MAGIC_EXE = "$magic_exe";
4304d5c3dbf1Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
4305d5c3dbf1SmrgEOF
4306d5c3dbf1Smrg
4307d5c3dbf1Smrg	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4308cdbfa18aSmrg              func_to_host_path "$temp_rpath"
4309d5c3dbf1Smrg	      cat <<EOF
4310cdbfa18aSmrgconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
43119f606849SmrgEOF
43129f606849Smrg	    else
4313d5c3dbf1Smrg	      cat <<"EOF"
4314d5c3dbf1Smrgconst char * LIB_PATH_VALUE   = "";
4315d5c3dbf1SmrgEOF
43169f606849Smrg	    fi
4317d5c3dbf1Smrg
4318d5c3dbf1Smrg	    if test -n "$dllsearchpath"; then
4319cdbfa18aSmrg              func_to_host_path "$dllsearchpath:"
4320d5c3dbf1Smrg	      cat <<EOF
4321d5c3dbf1Smrgconst char * EXE_PATH_VARNAME = "PATH";
4322cdbfa18aSmrgconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
4323d5c3dbf1SmrgEOF
43249f606849Smrg	    else
4325d5c3dbf1Smrg	      cat <<"EOF"
4326d5c3dbf1Smrgconst char * EXE_PATH_VARNAME = "";
4327d5c3dbf1Smrgconst char * EXE_PATH_VALUE   = "";
4328d5c3dbf1SmrgEOF
43299f606849Smrg	    fi
4330d5c3dbf1Smrg
4331d5c3dbf1Smrg	    if test "$fast_install" = yes; then
4332d5c3dbf1Smrg	      cat <<EOF
4333d5c3dbf1Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
4334d5c3dbf1SmrgEOF
43359f606849Smrg	    else
4336d5c3dbf1Smrg	      cat <<EOF
4337d5c3dbf1Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
4338d5c3dbf1SmrgEOF
43399f606849Smrg	    fi
43409f606849Smrg
43419f606849Smrg
4342d5c3dbf1Smrg	    cat <<"EOF"
43439f606849Smrg
4344d5c3dbf1Smrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
43459f606849Smrg
4346d5c3dbf1Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
4347d5c3dbf1Smrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
4348d5c3dbf1Smrgstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
43499f606849Smrg
4350d5c3dbf1Smrgint
4351d5c3dbf1Smrgmain (int argc, char *argv[])
4352d5c3dbf1Smrg{
4353d5c3dbf1Smrg  char **newargz;
4354d5c3dbf1Smrg  int  newargc;
4355d5c3dbf1Smrg  char *tmp_pathspec;
4356d5c3dbf1Smrg  char *actual_cwrapper_path;
4357d5c3dbf1Smrg  char *actual_cwrapper_name;
4358d5c3dbf1Smrg  char *target_name;
4359d5c3dbf1Smrg  char *lt_argv_zero;
4360d5c3dbf1Smrg  intptr_t rval = 127;
43619f606849Smrg
4362d5c3dbf1Smrg  int i;
43639f606849Smrg
4364d5c3dbf1Smrg  program_name = (char *) xstrdup (base_name (argv[0]));
4365d5c3dbf1Smrg  newargz = XMALLOC (char *, argc + 1);
43669f606849Smrg
4367d5c3dbf1Smrg  /* very simple arg parsing; don't want to rely on getopt
4368d5c3dbf1Smrg   * also, copy all non cwrapper options to newargz, except
4369d5c3dbf1Smrg   * argz[0], which is handled differently
4370d5c3dbf1Smrg   */
4371d5c3dbf1Smrg  newargc=0;
4372d5c3dbf1Smrg  for (i = 1; i < argc; i++)
4373d5c3dbf1Smrg    {
4374d5c3dbf1Smrg      if (strcmp (argv[i], dumpscript_opt) == 0)
4375d5c3dbf1Smrg	{
4376d5c3dbf1SmrgEOF
4377d5c3dbf1Smrg	    case "$host" in
4378d5c3dbf1Smrg	      *mingw* | *cygwin* )
4379d5c3dbf1Smrg		# make stdout use "unix" line endings
4380d5c3dbf1Smrg		echo "          setmode(1,_O_BINARY);"
4381d5c3dbf1Smrg		;;
4382fba89afeSmrg	      esac
43839f606849Smrg
4384d5c3dbf1Smrg	    cat <<"EOF"
4385d5c3dbf1Smrg	  lt_dump_script (stdout);
4386d5c3dbf1Smrg	  return 0;
4387d5c3dbf1Smrg	}
4388d5c3dbf1Smrg      if (strcmp (argv[i], debug_opt) == 0)
4389d5c3dbf1Smrg	{
4390d5c3dbf1Smrg          lt_debug = 1;
4391d5c3dbf1Smrg          continue;
4392d5c3dbf1Smrg	}
4393d5c3dbf1Smrg      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
4394d5c3dbf1Smrg        {
4395d5c3dbf1Smrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
4396d5c3dbf1Smrg             namespace, but it is not one of the ones we know about and
4397d5c3dbf1Smrg             have already dealt with, above (inluding dump-script), then
4398d5c3dbf1Smrg             report an error. Otherwise, targets might begin to believe
4399d5c3dbf1Smrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
4400d5c3dbf1Smrg             namespace. The first time any user complains about this, we'll
4401d5c3dbf1Smrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
4402d5c3dbf1Smrg             or a configure.ac-settable value.
4403d5c3dbf1Smrg           */
4404d5c3dbf1Smrg          lt_fatal (__FILE__, __LINE__,
4405d5c3dbf1Smrg		    "unrecognized %s option: '%s'",
4406d5c3dbf1Smrg                    ltwrapper_option_prefix, argv[i]);
4407d5c3dbf1Smrg        }
4408d5c3dbf1Smrg      /* otherwise ... */
4409d5c3dbf1Smrg      newargz[++newargc] = xstrdup (argv[i]);
4410d5c3dbf1Smrg    }
4411d5c3dbf1Smrg  newargz[++newargc] = NULL;
44129f606849Smrg
4413d5c3dbf1SmrgEOF
4414d5c3dbf1Smrg	    cat <<EOF
4415d5c3dbf1Smrg  /* The GNU banner must be the first non-error debug message */
4416d5c3dbf1Smrg  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
4417d5c3dbf1SmrgEOF
4418d5c3dbf1Smrg	    cat <<"EOF"
4419d5c3dbf1Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
4420d5c3dbf1Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
4421d5c3dbf1Smrg
4422d5c3dbf1Smrg  tmp_pathspec = find_executable (argv[0]);
4423d5c3dbf1Smrg  if (tmp_pathspec == NULL)
4424d5c3dbf1Smrg    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
4425d5c3dbf1Smrg  lt_debugprintf (__FILE__, __LINE__,
4426d5c3dbf1Smrg                  "(main) found exe (before symlink chase) at: %s\n",
4427d5c3dbf1Smrg		  tmp_pathspec);
4428d5c3dbf1Smrg
4429d5c3dbf1Smrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
4430d5c3dbf1Smrg  lt_debugprintf (__FILE__, __LINE__,
4431d5c3dbf1Smrg                  "(main) found exe (after symlink chase) at: %s\n",
4432d5c3dbf1Smrg		  actual_cwrapper_path);
4433d5c3dbf1Smrg  XFREE (tmp_pathspec);
4434d5c3dbf1Smrg
4435d5c3dbf1Smrg  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
4436d5c3dbf1Smrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
4437d5c3dbf1Smrg
4438d5c3dbf1Smrg  /* wrapper name transforms */
4439d5c3dbf1Smrg  strendzap (actual_cwrapper_name, ".exe");
4440d5c3dbf1Smrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
4441d5c3dbf1Smrg  XFREE (actual_cwrapper_name);
4442d5c3dbf1Smrg  actual_cwrapper_name = tmp_pathspec;
4443d5c3dbf1Smrg  tmp_pathspec = 0;
4444d5c3dbf1Smrg
4445d5c3dbf1Smrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
4446d5c3dbf1Smrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
4447d5c3dbf1Smrg  strendzap (target_name, ".exe");
4448d5c3dbf1Smrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
4449d5c3dbf1Smrg  XFREE (target_name);
4450d5c3dbf1Smrg  target_name = tmp_pathspec;
4451d5c3dbf1Smrg  tmp_pathspec = 0;
4452d5c3dbf1Smrg
4453d5c3dbf1Smrg  lt_debugprintf (__FILE__, __LINE__,
4454d5c3dbf1Smrg		  "(main) libtool target name: %s\n",
4455d5c3dbf1Smrg		  target_name);
4456d5c3dbf1SmrgEOF
44579f606849Smrg
4458d5c3dbf1Smrg	    cat <<EOF
4459d5c3dbf1Smrg  newargz[0] =
4460d5c3dbf1Smrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
4461d5c3dbf1Smrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
4462d5c3dbf1Smrg  strcpy (newargz[0], actual_cwrapper_path);
4463d5c3dbf1Smrg  strcat (newargz[0], "$objdir");
4464d5c3dbf1Smrg  strcat (newargz[0], "/");
4465d5c3dbf1SmrgEOF
44669f606849Smrg
4467d5c3dbf1Smrg	    cat <<"EOF"
4468d5c3dbf1Smrg  /* stop here, and copy so we don't have to do this twice */
4469d5c3dbf1Smrg  tmp_pathspec = xstrdup (newargz[0]);
44709f606849Smrg
4471d5c3dbf1Smrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
4472d5c3dbf1Smrg  strcat (newargz[0], actual_cwrapper_name);
44739f606849Smrg
4474d5c3dbf1Smrg  /* DO want the lt- prefix here if it exists, so use target_name */
4475d5c3dbf1Smrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
4476d5c3dbf1Smrg  XFREE (tmp_pathspec);
4477d5c3dbf1Smrg  tmp_pathspec = NULL;
4478d5c3dbf1SmrgEOF
44799f606849Smrg
4480d5c3dbf1Smrg	    case $host_os in
4481d5c3dbf1Smrg	      mingw*)
4482d5c3dbf1Smrg	    cat <<"EOF"
4483d5c3dbf1Smrg  {
4484d5c3dbf1Smrg    char* p;
4485d5c3dbf1Smrg    while ((p = strchr (newargz[0], '\\')) != NULL)
4486d5c3dbf1Smrg      {
4487d5c3dbf1Smrg	*p = '/';
4488d5c3dbf1Smrg      }
4489d5c3dbf1Smrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
4490d5c3dbf1Smrg      {
4491d5c3dbf1Smrg	*p = '/';
4492d5c3dbf1Smrg      }
4493d5c3dbf1Smrg  }
4494d5c3dbf1SmrgEOF
4495d5c3dbf1Smrg	    ;;
4496d5c3dbf1Smrg	    esac
44979f606849Smrg
4498d5c3dbf1Smrg	    cat <<"EOF"
4499d5c3dbf1Smrg  XFREE (target_name);
4500d5c3dbf1Smrg  XFREE (actual_cwrapper_path);
4501d5c3dbf1Smrg  XFREE (actual_cwrapper_name);
45029f606849Smrg
4503d5c3dbf1Smrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
4504d5c3dbf1Smrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
4505cdbfa18aSmrg  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
4506cdbfa18aSmrg     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
4507cdbfa18aSmrg     because on Windows, both *_VARNAMEs are PATH but uninstalled
4508cdbfa18aSmrg     libraries must come first. */
4509d5c3dbf1Smrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
4510cdbfa18aSmrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
45119f606849Smrg
4512d5c3dbf1Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
4513d5c3dbf1Smrg		  nonnull (lt_argv_zero));
4514d5c3dbf1Smrg  for (i = 0; i < newargc; i++)
4515d5c3dbf1Smrg    {
4516d5c3dbf1Smrg      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
4517d5c3dbf1Smrg		      i, nonnull (newargz[i]));
4518d5c3dbf1Smrg    }
45199f606849Smrg
4520d5c3dbf1SmrgEOF
45219f606849Smrg
4522d5c3dbf1Smrg	    case $host_os in
4523d5c3dbf1Smrg	      mingw*)
4524d5c3dbf1Smrg		cat <<"EOF"
4525d5c3dbf1Smrg  /* execv doesn't actually work on mingw as expected on unix */
4526d5c3dbf1Smrg  newargz = prepare_spawn (newargz);
4527d5c3dbf1Smrg  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
4528d5c3dbf1Smrg  if (rval == -1)
4529d5c3dbf1Smrg    {
4530d5c3dbf1Smrg      /* failed to start process */
4531d5c3dbf1Smrg      lt_debugprintf (__FILE__, __LINE__,
4532d5c3dbf1Smrg		      "(main) failed to launch target \"%s\": %s\n",
4533d5c3dbf1Smrg		      lt_argv_zero, nonnull (strerror (errno)));
4534d5c3dbf1Smrg      return 127;
4535d5c3dbf1Smrg    }
4536d5c3dbf1Smrg  return rval;
4537d5c3dbf1SmrgEOF
4538d5c3dbf1Smrg		;;
4539d5c3dbf1Smrg	      *)
4540d5c3dbf1Smrg		cat <<"EOF"
4541d5c3dbf1Smrg  execv (lt_argv_zero, newargz);
4542d5c3dbf1Smrg  return rval; /* =127, but avoids unused variable warning */
4543d5c3dbf1SmrgEOF
4544d5c3dbf1Smrg		;;
4545d5c3dbf1Smrg	    esac
45469f606849Smrg
4547d5c3dbf1Smrg	    cat <<"EOF"
4548d5c3dbf1Smrg}
45499f606849Smrg
4550d5c3dbf1Smrgvoid *
4551d5c3dbf1Smrgxmalloc (size_t num)
4552d5c3dbf1Smrg{
4553d5c3dbf1Smrg  void *p = (void *) malloc (num);
4554d5c3dbf1Smrg  if (!p)
4555d5c3dbf1Smrg    lt_fatal (__FILE__, __LINE__, "memory exhausted");
45569f606849Smrg
4557d5c3dbf1Smrg  return p;
4558d5c3dbf1Smrg}
45599f606849Smrg
4560d5c3dbf1Smrgchar *
4561d5c3dbf1Smrgxstrdup (const char *string)
4562d5c3dbf1Smrg{
4563d5c3dbf1Smrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
4564d5c3dbf1Smrg			  string) : NULL;
4565d5c3dbf1Smrg}
45669f606849Smrg
4567d5c3dbf1Smrgconst char *
4568d5c3dbf1Smrgbase_name (const char *name)
4569d5c3dbf1Smrg{
4570d5c3dbf1Smrg  const char *base;
45719f606849Smrg
4572d5c3dbf1Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4573d5c3dbf1Smrg  /* Skip over the disk name in MSDOS pathnames. */
4574d5c3dbf1Smrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
4575d5c3dbf1Smrg    name += 2;
4576d5c3dbf1Smrg#endif
45779f606849Smrg
4578d5c3dbf1Smrg  for (base = name; *name; name++)
4579d5c3dbf1Smrg    if (IS_DIR_SEPARATOR (*name))
4580d5c3dbf1Smrg      base = name + 1;
4581d5c3dbf1Smrg  return base;
4582d5c3dbf1Smrg}
45839f606849Smrg
4584d5c3dbf1Smrgint
4585d5c3dbf1Smrgcheck_executable (const char *path)
4586d5c3dbf1Smrg{
4587d5c3dbf1Smrg  struct stat st;
45889f606849Smrg
4589d5c3dbf1Smrg  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
4590d5c3dbf1Smrg                  nonempty (path));
4591d5c3dbf1Smrg  if ((!path) || (!*path))
4592d5c3dbf1Smrg    return 0;
45939f606849Smrg
4594d5c3dbf1Smrg  if ((stat (path, &st) >= 0)
4595d5c3dbf1Smrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
4596d5c3dbf1Smrg    return 1;
4597d5c3dbf1Smrg  else
4598d5c3dbf1Smrg    return 0;
4599d5c3dbf1Smrg}
46009f606849Smrg
4601d5c3dbf1Smrgint
4602d5c3dbf1Smrgmake_executable (const char *path)
4603d5c3dbf1Smrg{
4604d5c3dbf1Smrg  int rval = 0;
4605d5c3dbf1Smrg  struct stat st;
46069f606849Smrg
4607d5c3dbf1Smrg  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
4608d5c3dbf1Smrg                  nonempty (path));
4609d5c3dbf1Smrg  if ((!path) || (!*path))
4610d5c3dbf1Smrg    return 0;
46119f606849Smrg
4612d5c3dbf1Smrg  if (stat (path, &st) >= 0)
4613d5c3dbf1Smrg    {
4614d5c3dbf1Smrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
4615d5c3dbf1Smrg    }
4616d5c3dbf1Smrg  return rval;
4617d5c3dbf1Smrg}
46189f606849Smrg
4619d5c3dbf1Smrg/* Searches for the full path of the wrapper.  Returns
4620d5c3dbf1Smrg   newly allocated full path name if found, NULL otherwise
4621d5c3dbf1Smrg   Does not chase symlinks, even on platforms that support them.
4622d5c3dbf1Smrg*/
4623d5c3dbf1Smrgchar *
4624d5c3dbf1Smrgfind_executable (const char *wrapper)
4625d5c3dbf1Smrg{
4626d5c3dbf1Smrg  int has_slash = 0;
4627d5c3dbf1Smrg  const char *p;
4628d5c3dbf1Smrg  const char *p_next;
4629d5c3dbf1Smrg  /* static buffer for getcwd */
4630d5c3dbf1Smrg  char tmp[LT_PATHMAX + 1];
4631d5c3dbf1Smrg  int tmp_len;
4632d5c3dbf1Smrg  char *concat_name;
46339f606849Smrg
4634d5c3dbf1Smrg  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
4635d5c3dbf1Smrg                  nonempty (wrapper));
46369f606849Smrg
4637d5c3dbf1Smrg  if ((wrapper == NULL) || (*wrapper == '\0'))
4638d5c3dbf1Smrg    return NULL;
46399f606849Smrg
4640d5c3dbf1Smrg  /* Absolute path? */
4641d5c3dbf1Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4642d5c3dbf1Smrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
4643d5c3dbf1Smrg    {
4644d5c3dbf1Smrg      concat_name = xstrdup (wrapper);
4645d5c3dbf1Smrg      if (check_executable (concat_name))
4646d5c3dbf1Smrg	return concat_name;
4647d5c3dbf1Smrg      XFREE (concat_name);
4648d5c3dbf1Smrg    }
4649d5c3dbf1Smrg  else
4650d5c3dbf1Smrg    {
4651d5c3dbf1Smrg#endif
4652d5c3dbf1Smrg      if (IS_DIR_SEPARATOR (wrapper[0]))
4653d5c3dbf1Smrg	{
4654d5c3dbf1Smrg	  concat_name = xstrdup (wrapper);
4655d5c3dbf1Smrg	  if (check_executable (concat_name))
4656d5c3dbf1Smrg	    return concat_name;
4657d5c3dbf1Smrg	  XFREE (concat_name);
4658d5c3dbf1Smrg	}
4659d5c3dbf1Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4660d5c3dbf1Smrg    }
4661d5c3dbf1Smrg#endif
46629f606849Smrg
4663d5c3dbf1Smrg  for (p = wrapper; *p; p++)
4664d5c3dbf1Smrg    if (*p == '/')
4665d5c3dbf1Smrg      {
4666d5c3dbf1Smrg	has_slash = 1;
4667d5c3dbf1Smrg	break;
4668d5c3dbf1Smrg      }
4669d5c3dbf1Smrg  if (!has_slash)
4670d5c3dbf1Smrg    {
4671d5c3dbf1Smrg      /* no slashes; search PATH */
4672d5c3dbf1Smrg      const char *path = getenv ("PATH");
4673d5c3dbf1Smrg      if (path != NULL)
4674d5c3dbf1Smrg	{
4675d5c3dbf1Smrg	  for (p = path; *p; p = p_next)
4676d5c3dbf1Smrg	    {
4677d5c3dbf1Smrg	      const char *q;
4678d5c3dbf1Smrg	      size_t p_len;
4679d5c3dbf1Smrg	      for (q = p; *q; q++)
4680d5c3dbf1Smrg		if (IS_PATH_SEPARATOR (*q))
4681d5c3dbf1Smrg		  break;
4682d5c3dbf1Smrg	      p_len = q - p;
4683d5c3dbf1Smrg	      p_next = (*q == '\0' ? q : q + 1);
4684d5c3dbf1Smrg	      if (p_len == 0)
4685d5c3dbf1Smrg		{
4686d5c3dbf1Smrg		  /* empty path: current directory */
4687d5c3dbf1Smrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
4688d5c3dbf1Smrg		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
4689d5c3dbf1Smrg                              nonnull (strerror (errno)));
4690d5c3dbf1Smrg		  tmp_len = strlen (tmp);
4691d5c3dbf1Smrg		  concat_name =
4692d5c3dbf1Smrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
4693d5c3dbf1Smrg		  memcpy (concat_name, tmp, tmp_len);
4694d5c3dbf1Smrg		  concat_name[tmp_len] = '/';
4695d5c3dbf1Smrg		  strcpy (concat_name + tmp_len + 1, wrapper);
4696d5c3dbf1Smrg		}
4697d5c3dbf1Smrg	      else
4698d5c3dbf1Smrg		{
4699d5c3dbf1Smrg		  concat_name =
4700d5c3dbf1Smrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
4701d5c3dbf1Smrg		  memcpy (concat_name, p, p_len);
4702d5c3dbf1Smrg		  concat_name[p_len] = '/';
4703d5c3dbf1Smrg		  strcpy (concat_name + p_len + 1, wrapper);
4704d5c3dbf1Smrg		}
4705d5c3dbf1Smrg	      if (check_executable (concat_name))
4706d5c3dbf1Smrg		return concat_name;
4707d5c3dbf1Smrg	      XFREE (concat_name);
4708d5c3dbf1Smrg	    }
4709d5c3dbf1Smrg	}
4710d5c3dbf1Smrg      /* not found in PATH; assume curdir */
4711d5c3dbf1Smrg    }
4712d5c3dbf1Smrg  /* Relative path | not found in path: prepend cwd */
4713d5c3dbf1Smrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
4714d5c3dbf1Smrg    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
4715d5c3dbf1Smrg              nonnull (strerror (errno)));
4716d5c3dbf1Smrg  tmp_len = strlen (tmp);
4717d5c3dbf1Smrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
4718d5c3dbf1Smrg  memcpy (concat_name, tmp, tmp_len);
4719d5c3dbf1Smrg  concat_name[tmp_len] = '/';
4720d5c3dbf1Smrg  strcpy (concat_name + tmp_len + 1, wrapper);
47219f606849Smrg
4722d5c3dbf1Smrg  if (check_executable (concat_name))
4723d5c3dbf1Smrg    return concat_name;
4724d5c3dbf1Smrg  XFREE (concat_name);
4725d5c3dbf1Smrg  return NULL;
4726d5c3dbf1Smrg}
47279f606849Smrg
4728d5c3dbf1Smrgchar *
4729d5c3dbf1Smrgchase_symlinks (const char *pathspec)
4730d5c3dbf1Smrg{
4731d5c3dbf1Smrg#ifndef S_ISLNK
4732d5c3dbf1Smrg  return xstrdup (pathspec);
4733d5c3dbf1Smrg#else
4734d5c3dbf1Smrg  char buf[LT_PATHMAX];
4735d5c3dbf1Smrg  struct stat s;
4736d5c3dbf1Smrg  char *tmp_pathspec = xstrdup (pathspec);
4737d5c3dbf1Smrg  char *p;
4738d5c3dbf1Smrg  int has_symlinks = 0;
4739d5c3dbf1Smrg  while (strlen (tmp_pathspec) && !has_symlinks)
4740d5c3dbf1Smrg    {
4741d5c3dbf1Smrg      lt_debugprintf (__FILE__, __LINE__,
4742d5c3dbf1Smrg		      "checking path component for symlinks: %s\n",
4743d5c3dbf1Smrg		      tmp_pathspec);
4744d5c3dbf1Smrg      if (lstat (tmp_pathspec, &s) == 0)
4745d5c3dbf1Smrg	{
4746d5c3dbf1Smrg	  if (S_ISLNK (s.st_mode) != 0)
4747d5c3dbf1Smrg	    {
4748d5c3dbf1Smrg	      has_symlinks = 1;
4749d5c3dbf1Smrg	      break;
4750d5c3dbf1Smrg	    }
47519f606849Smrg
4752d5c3dbf1Smrg	  /* search backwards for last DIR_SEPARATOR */
4753d5c3dbf1Smrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
4754d5c3dbf1Smrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4755d5c3dbf1Smrg	    p--;
4756d5c3dbf1Smrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4757d5c3dbf1Smrg	    {
4758d5c3dbf1Smrg	      /* no more DIR_SEPARATORS left */
4759d5c3dbf1Smrg	      break;
4760d5c3dbf1Smrg	    }
4761d5c3dbf1Smrg	  *p = '\0';
4762d5c3dbf1Smrg	}
4763d5c3dbf1Smrg      else
4764d5c3dbf1Smrg	{
4765d5c3dbf1Smrg	  lt_fatal (__FILE__, __LINE__,
4766d5c3dbf1Smrg		    "error accessing file \"%s\": %s",
4767d5c3dbf1Smrg		    tmp_pathspec, nonnull (strerror (errno)));
4768d5c3dbf1Smrg	}
4769d5c3dbf1Smrg    }
4770d5c3dbf1Smrg  XFREE (tmp_pathspec);
47719f606849Smrg
4772d5c3dbf1Smrg  if (!has_symlinks)
4773d5c3dbf1Smrg    {
4774d5c3dbf1Smrg      return xstrdup (pathspec);
4775d5c3dbf1Smrg    }
47769f606849Smrg
4777d5c3dbf1Smrg  tmp_pathspec = realpath (pathspec, buf);
4778d5c3dbf1Smrg  if (tmp_pathspec == 0)
4779d5c3dbf1Smrg    {
4780d5c3dbf1Smrg      lt_fatal (__FILE__, __LINE__,
4781d5c3dbf1Smrg		"could not follow symlinks for %s", pathspec);
4782d5c3dbf1Smrg    }
4783d5c3dbf1Smrg  return xstrdup (tmp_pathspec);
4784d5c3dbf1Smrg#endif
4785d5c3dbf1Smrg}
47869f606849Smrg
4787d5c3dbf1Smrgchar *
4788d5c3dbf1Smrgstrendzap (char *str, const char *pat)
4789d5c3dbf1Smrg{
4790d5c3dbf1Smrg  size_t len, patlen;
47919f606849Smrg
4792d5c3dbf1Smrg  assert (str != NULL);
4793d5c3dbf1Smrg  assert (pat != NULL);
47949f606849Smrg
4795d5c3dbf1Smrg  len = strlen (str);
4796d5c3dbf1Smrg  patlen = strlen (pat);
47979f606849Smrg
4798d5c3dbf1Smrg  if (patlen <= len)
4799d5c3dbf1Smrg    {
4800d5c3dbf1Smrg      str += len - patlen;
4801d5c3dbf1Smrg      if (strcmp (str, pat) == 0)
4802d5c3dbf1Smrg	*str = '\0';
4803d5c3dbf1Smrg    }
4804d5c3dbf1Smrg  return str;
4805d5c3dbf1Smrg}
48069f606849Smrg
4807d5c3dbf1Smrgvoid
4808d5c3dbf1Smrglt_debugprintf (const char *file, int line, const char *fmt, ...)
4809d5c3dbf1Smrg{
4810d5c3dbf1Smrg  va_list args;
4811d5c3dbf1Smrg  if (lt_debug)
4812d5c3dbf1Smrg    {
4813d5c3dbf1Smrg      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
4814d5c3dbf1Smrg      va_start (args, fmt);
4815d5c3dbf1Smrg      (void) vfprintf (stderr, fmt, args);
4816d5c3dbf1Smrg      va_end (args);
4817d5c3dbf1Smrg    }
4818d5c3dbf1Smrg}
48199f606849Smrg
4820d5c3dbf1Smrgstatic void
4821d5c3dbf1Smrglt_error_core (int exit_status, const char *file,
4822d5c3dbf1Smrg	       int line, const char *mode,
4823d5c3dbf1Smrg	       const char *message, va_list ap)
4824d5c3dbf1Smrg{
4825d5c3dbf1Smrg  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
4826d5c3dbf1Smrg  vfprintf (stderr, message, ap);
4827d5c3dbf1Smrg  fprintf (stderr, ".\n");
48289f606849Smrg
4829d5c3dbf1Smrg  if (exit_status >= 0)
4830d5c3dbf1Smrg    exit (exit_status);
4831d5c3dbf1Smrg}
48329f606849Smrg
4833d5c3dbf1Smrgvoid
4834d5c3dbf1Smrglt_fatal (const char *file, int line, const char *message, ...)
4835d5c3dbf1Smrg{
4836d5c3dbf1Smrg  va_list ap;
4837d5c3dbf1Smrg  va_start (ap, message);
4838d5c3dbf1Smrg  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
4839d5c3dbf1Smrg  va_end (ap);
4840d5c3dbf1Smrg}
48419f606849Smrg
4842d5c3dbf1Smrgstatic const char *
4843d5c3dbf1Smrgnonnull (const char *s)
4844d5c3dbf1Smrg{
4845d5c3dbf1Smrg  return s ? s : "(null)";
4846d5c3dbf1Smrg}
48479f606849Smrg
4848d5c3dbf1Smrgstatic const char *
4849d5c3dbf1Smrgnonempty (const char *s)
4850d5c3dbf1Smrg{
4851d5c3dbf1Smrg  return (s && !*s) ? "(empty)" : nonnull (s);
4852d5c3dbf1Smrg}
48539f606849Smrg
4854d5c3dbf1Smrgvoid
4855d5c3dbf1Smrglt_setenv (const char *name, const char *value)
4856d5c3dbf1Smrg{
4857d5c3dbf1Smrg  lt_debugprintf (__FILE__, __LINE__,
4858d5c3dbf1Smrg		  "(lt_setenv) setting '%s' to '%s'\n",
4859d5c3dbf1Smrg                  nonnull (name), nonnull (value));
4860d5c3dbf1Smrg  {
4861d5c3dbf1Smrg#ifdef HAVE_SETENV
4862d5c3dbf1Smrg    /* always make a copy, for consistency with !HAVE_SETENV */
4863d5c3dbf1Smrg    char *str = xstrdup (value);
4864d5c3dbf1Smrg    setenv (name, str, 1);
4865d5c3dbf1Smrg#else
4866d5c3dbf1Smrg    int len = strlen (name) + 1 + strlen (value) + 1;
4867d5c3dbf1Smrg    char *str = XMALLOC (char, len);
4868d5c3dbf1Smrg    sprintf (str, "%s=%s", name, value);
4869d5c3dbf1Smrg    if (putenv (str) != EXIT_SUCCESS)
4870d5c3dbf1Smrg      {
4871d5c3dbf1Smrg        XFREE (str);
4872d5c3dbf1Smrg      }
4873d5c3dbf1Smrg#endif
4874d5c3dbf1Smrg  }
4875d5c3dbf1Smrg}
48769f606849Smrg
4877d5c3dbf1Smrgchar *
4878d5c3dbf1Smrglt_extend_str (const char *orig_value, const char *add, int to_end)
4879d5c3dbf1Smrg{
4880d5c3dbf1Smrg  char *new_value;
4881d5c3dbf1Smrg  if (orig_value && *orig_value)
4882d5c3dbf1Smrg    {
4883d5c3dbf1Smrg      int orig_value_len = strlen (orig_value);
4884d5c3dbf1Smrg      int add_len = strlen (add);
4885d5c3dbf1Smrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
4886d5c3dbf1Smrg      if (to_end)
4887d5c3dbf1Smrg        {
4888d5c3dbf1Smrg          strcpy (new_value, orig_value);
4889d5c3dbf1Smrg          strcpy (new_value + orig_value_len, add);
4890d5c3dbf1Smrg        }
4891d5c3dbf1Smrg      else
4892d5c3dbf1Smrg        {
4893d5c3dbf1Smrg          strcpy (new_value, add);
4894d5c3dbf1Smrg          strcpy (new_value + add_len, orig_value);
4895d5c3dbf1Smrg        }
4896d5c3dbf1Smrg    }
4897d5c3dbf1Smrg  else
4898d5c3dbf1Smrg    {
4899d5c3dbf1Smrg      new_value = xstrdup (add);
4900d5c3dbf1Smrg    }
4901d5c3dbf1Smrg  return new_value;
4902d5c3dbf1Smrg}
49039f606849Smrg
4904d5c3dbf1Smrgvoid
4905d5c3dbf1Smrglt_update_exe_path (const char *name, const char *value)
4906d5c3dbf1Smrg{
4907d5c3dbf1Smrg  lt_debugprintf (__FILE__, __LINE__,
4908d5c3dbf1Smrg		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
4909d5c3dbf1Smrg                  nonnull (name), nonnull (value));
49109f606849Smrg
4911d5c3dbf1Smrg  if (name && *name && value && *value)
4912d5c3dbf1Smrg    {
4913d5c3dbf1Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
4914d5c3dbf1Smrg      /* some systems can't cope with a ':'-terminated path #' */
4915d5c3dbf1Smrg      int len = strlen (new_value);
4916d5c3dbf1Smrg      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
4917d5c3dbf1Smrg        {
4918d5c3dbf1Smrg          new_value[len-1] = '\0';
4919d5c3dbf1Smrg        }
4920d5c3dbf1Smrg      lt_setenv (name, new_value);
4921d5c3dbf1Smrg      XFREE (new_value);
4922d5c3dbf1Smrg    }
4923d5c3dbf1Smrg}
49249f606849Smrg
4925d5c3dbf1Smrgvoid
4926d5c3dbf1Smrglt_update_lib_path (const char *name, const char *value)
4927d5c3dbf1Smrg{
4928d5c3dbf1Smrg  lt_debugprintf (__FILE__, __LINE__,
4929d5c3dbf1Smrg		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
4930d5c3dbf1Smrg                  nonnull (name), nonnull (value));
49319f606849Smrg
4932d5c3dbf1Smrg  if (name && *name && value && *value)
4933d5c3dbf1Smrg    {
4934d5c3dbf1Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
4935d5c3dbf1Smrg      lt_setenv (name, new_value);
4936d5c3dbf1Smrg      XFREE (new_value);
4937d5c3dbf1Smrg    }
4938d5c3dbf1Smrg}
49399f606849Smrg
4940d5c3dbf1SmrgEOF
4941d5c3dbf1Smrg	    case $host_os in
4942d5c3dbf1Smrg	      mingw*)
4943d5c3dbf1Smrg		cat <<"EOF"
4944d5c3dbf1Smrg
4945d5c3dbf1Smrg/* Prepares an argument vector before calling spawn().
4946d5c3dbf1Smrg   Note that spawn() does not by itself call the command interpreter
4947d5c3dbf1Smrg     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
4948d5c3dbf1Smrg      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
4949d5c3dbf1Smrg         GetVersionEx(&v);
4950d5c3dbf1Smrg         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
4951d5c3dbf1Smrg      }) ? "cmd.exe" : "command.com").
4952d5c3dbf1Smrg   Instead it simply concatenates the arguments, separated by ' ', and calls
4953d5c3dbf1Smrg   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
4954d5c3dbf1Smrg   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
4955d5c3dbf1Smrg   special way:
4956d5c3dbf1Smrg   - Space and tab are interpreted as delimiters. They are not treated as
4957d5c3dbf1Smrg     delimiters if they are surrounded by double quotes: "...".
4958d5c3dbf1Smrg   - Unescaped double quotes are removed from the input. Their only effect is
4959d5c3dbf1Smrg     that within double quotes, space and tab are treated like normal
4960d5c3dbf1Smrg     characters.
4961d5c3dbf1Smrg   - Backslashes not followed by double quotes are not special.
4962d5c3dbf1Smrg   - But 2*n+1 backslashes followed by a double quote become
4963d5c3dbf1Smrg     n backslashes followed by a double quote (n >= 0):
4964d5c3dbf1Smrg       \" -> "
4965d5c3dbf1Smrg       \\\" -> \"
4966d5c3dbf1Smrg       \\\\\" -> \\"
4967d5c3dbf1Smrg */
4968d5c3dbf1Smrg#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"
4969d5c3dbf1Smrg#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"
4970d5c3dbf1Smrgchar **
4971d5c3dbf1Smrgprepare_spawn (char **argv)
4972d5c3dbf1Smrg{
4973d5c3dbf1Smrg  size_t argc;
4974d5c3dbf1Smrg  char **new_argv;
4975d5c3dbf1Smrg  size_t i;
49769f606849Smrg
4977d5c3dbf1Smrg  /* Count number of arguments.  */
4978d5c3dbf1Smrg  for (argc = 0; argv[argc] != NULL; argc++)
4979d5c3dbf1Smrg    ;
49809f606849Smrg
4981d5c3dbf1Smrg  /* Allocate new argument vector.  */
4982d5c3dbf1Smrg  new_argv = XMALLOC (char *, argc + 1);
49839f606849Smrg
4984d5c3dbf1Smrg  /* Put quoted arguments into the new argument vector.  */
4985d5c3dbf1Smrg  for (i = 0; i < argc; i++)
4986d5c3dbf1Smrg    {
4987d5c3dbf1Smrg      const char *string = argv[i];
4988d5c3dbf1Smrg
4989d5c3dbf1Smrg      if (string[0] == '\0')
4990d5c3dbf1Smrg	new_argv[i] = xstrdup ("\"\"");
4991d5c3dbf1Smrg      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
4992d5c3dbf1Smrg	{
4993d5c3dbf1Smrg	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
4994d5c3dbf1Smrg	  size_t length;
4995d5c3dbf1Smrg	  unsigned int backslashes;
4996d5c3dbf1Smrg	  const char *s;
4997d5c3dbf1Smrg	  char *quoted_string;
4998d5c3dbf1Smrg	  char *p;
4999d5c3dbf1Smrg
5000d5c3dbf1Smrg	  length = 0;
5001d5c3dbf1Smrg	  backslashes = 0;
5002d5c3dbf1Smrg	  if (quote_around)
5003d5c3dbf1Smrg	    length++;
5004d5c3dbf1Smrg	  for (s = string; *s != '\0'; s++)
5005d5c3dbf1Smrg	    {
5006d5c3dbf1Smrg	      char c = *s;
5007d5c3dbf1Smrg	      if (c == '"')
5008d5c3dbf1Smrg		length += backslashes + 1;
5009d5c3dbf1Smrg	      length++;
5010d5c3dbf1Smrg	      if (c == '\\')
5011d5c3dbf1Smrg		backslashes++;
5012d5c3dbf1Smrg	      else
5013d5c3dbf1Smrg		backslashes = 0;
5014d5c3dbf1Smrg	    }
5015d5c3dbf1Smrg	  if (quote_around)
5016d5c3dbf1Smrg	    length += backslashes + 1;
5017d5c3dbf1Smrg
5018d5c3dbf1Smrg	  quoted_string = XMALLOC (char, length + 1);
5019d5c3dbf1Smrg
5020d5c3dbf1Smrg	  p = quoted_string;
5021d5c3dbf1Smrg	  backslashes = 0;
5022d5c3dbf1Smrg	  if (quote_around)
5023d5c3dbf1Smrg	    *p++ = '"';
5024d5c3dbf1Smrg	  for (s = string; *s != '\0'; s++)
5025d5c3dbf1Smrg	    {
5026d5c3dbf1Smrg	      char c = *s;
5027d5c3dbf1Smrg	      if (c == '"')
5028d5c3dbf1Smrg		{
5029d5c3dbf1Smrg		  unsigned int j;
5030d5c3dbf1Smrg		  for (j = backslashes + 1; j > 0; j--)
5031d5c3dbf1Smrg		    *p++ = '\\';
5032d5c3dbf1Smrg		}
5033d5c3dbf1Smrg	      *p++ = c;
5034d5c3dbf1Smrg	      if (c == '\\')
5035d5c3dbf1Smrg		backslashes++;
5036d5c3dbf1Smrg	      else
5037d5c3dbf1Smrg		backslashes = 0;
5038d5c3dbf1Smrg	    }
5039d5c3dbf1Smrg	  if (quote_around)
5040d5c3dbf1Smrg	    {
5041d5c3dbf1Smrg	      unsigned int j;
5042d5c3dbf1Smrg	      for (j = backslashes; j > 0; j--)
5043d5c3dbf1Smrg		*p++ = '\\';
5044d5c3dbf1Smrg	      *p++ = '"';
5045d5c3dbf1Smrg	    }
5046d5c3dbf1Smrg	  *p = '\0';
50479f606849Smrg
5048d5c3dbf1Smrg	  new_argv[i] = quoted_string;
5049d5c3dbf1Smrg	}
5050d5c3dbf1Smrg      else
5051d5c3dbf1Smrg	new_argv[i] = (char *) string;
5052d5c3dbf1Smrg    }
5053d5c3dbf1Smrg  new_argv[argc] = NULL;
50549f606849Smrg
5055d5c3dbf1Smrg  return new_argv;
5056d5c3dbf1Smrg}
5057d5c3dbf1SmrgEOF
50589f606849Smrg		;;
5059d5c3dbf1Smrg	    esac
50609f606849Smrg
5061d5c3dbf1Smrg            cat <<"EOF"
5062d5c3dbf1Smrgvoid lt_dump_script (FILE* f)
5063d5c3dbf1Smrg{
5064d5c3dbf1SmrgEOF
5065d5c3dbf1Smrg	    func_emit_wrapper yes |
5066cdbfa18aSmrg	      $SED -n -e '
5067cdbfa18aSmrgs/^\(.\{79\}\)\(..*\)/\1\
5068cdbfa18aSmrg\2/
5069cdbfa18aSmrgh
5070cdbfa18aSmrgs/\([\\"]\)/\\\1/g
5071cdbfa18aSmrgs/$/\\n/
5072cdbfa18aSmrgs/\([^\n]*\).*/  fputs ("\1", f);/p
5073cdbfa18aSmrgg
5074cdbfa18aSmrgD'
5075d5c3dbf1Smrg            cat <<"EOF"
5076d5c3dbf1Smrg}
5077d5c3dbf1SmrgEOF
5078d5c3dbf1Smrg}
5079d5c3dbf1Smrg# end: func_emit_cwrapperexe_src
50809f606849Smrg
5081d5c3dbf1Smrg# func_win32_import_lib_p ARG
5082d5c3dbf1Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd
5083d5c3dbf1Smrgfunc_win32_import_lib_p ()
5084d5c3dbf1Smrg{
5085d5c3dbf1Smrg    $opt_debug
5086d5c3dbf1Smrg    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
5087d5c3dbf1Smrg    *import*) : ;;
5088d5c3dbf1Smrg    *) false ;;
5089d5c3dbf1Smrg    esac
5090d5c3dbf1Smrg}
50919f606849Smrg
5092d5c3dbf1Smrg# func_mode_link arg...
5093d5c3dbf1Smrgfunc_mode_link ()
5094d5c3dbf1Smrg{
5095d5c3dbf1Smrg    $opt_debug
5096d5c3dbf1Smrg    case $host in
5097d5c3dbf1Smrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
5098d5c3dbf1Smrg      # It is impossible to link a dll without this setting, and
5099d5c3dbf1Smrg      # we shouldn't force the makefile maintainer to figure out
5100d5c3dbf1Smrg      # which system we are compiling for in order to pass an extra
5101d5c3dbf1Smrg      # flag for every libtool invocation.
5102d5c3dbf1Smrg      # allow_undefined=no
51039f606849Smrg
5104d5c3dbf1Smrg      # FIXME: Unfortunately, there are problems with the above when trying
5105d5c3dbf1Smrg      # to make a dll which has undefined symbols, in which case not
5106d5c3dbf1Smrg      # even a static library is built.  For now, we need to specify
5107d5c3dbf1Smrg      # -no-undefined on the libtool link line when we can be certain
5108d5c3dbf1Smrg      # that all symbols are satisfied, otherwise we get a static library.
5109d5c3dbf1Smrg      allow_undefined=yes
5110d5c3dbf1Smrg      ;;
5111d5c3dbf1Smrg    *)
5112d5c3dbf1Smrg      allow_undefined=yes
5113d5c3dbf1Smrg      ;;
5114d5c3dbf1Smrg    esac
5115d5c3dbf1Smrg    libtool_args=$nonopt
5116d5c3dbf1Smrg    base_compile="$nonopt $@"
5117d5c3dbf1Smrg    compile_command=$nonopt
5118d5c3dbf1Smrg    finalize_command=$nonopt
51199f606849Smrg
5120d5c3dbf1Smrg    compile_rpath=
5121d5c3dbf1Smrg    finalize_rpath=
5122d5c3dbf1Smrg    compile_shlibpath=
5123d5c3dbf1Smrg    finalize_shlibpath=
5124d5c3dbf1Smrg    convenience=
5125d5c3dbf1Smrg    old_convenience=
5126d5c3dbf1Smrg    deplibs=
5127d5c3dbf1Smrg    old_deplibs=
5128d5c3dbf1Smrg    compiler_flags=
5129d5c3dbf1Smrg    linker_flags=
5130d5c3dbf1Smrg    dllsearchpath=
5131d5c3dbf1Smrg    lib_search_path=`pwd`
5132d5c3dbf1Smrg    inst_prefix_dir=
5133d5c3dbf1Smrg    new_inherited_linker_flags=
51349f606849Smrg
5135d5c3dbf1Smrg    avoid_version=no
5136d5c3dbf1Smrg    bindir=
5137d5c3dbf1Smrg    dlfiles=
5138d5c3dbf1Smrg    dlprefiles=
5139d5c3dbf1Smrg    dlself=no
5140d5c3dbf1Smrg    export_dynamic=no
5141d5c3dbf1Smrg    export_symbols=
5142d5c3dbf1Smrg    export_symbols_regex=
5143d5c3dbf1Smrg    generated=
5144d5c3dbf1Smrg    libobjs=
5145d5c3dbf1Smrg    ltlibs=
5146d5c3dbf1Smrg    module=no
5147d5c3dbf1Smrg    no_install=no
5148d5c3dbf1Smrg    objs=
5149d5c3dbf1Smrg    non_pic_objects=
5150d5c3dbf1Smrg    precious_files_regex=
5151d5c3dbf1Smrg    prefer_static_libs=no
5152d5c3dbf1Smrg    preload=no
5153d5c3dbf1Smrg    prev=
5154d5c3dbf1Smrg    prevarg=
5155d5c3dbf1Smrg    release=
5156d5c3dbf1Smrg    rpath=
5157d5c3dbf1Smrg    xrpath=
5158d5c3dbf1Smrg    perm_rpath=
5159d5c3dbf1Smrg    temp_rpath=
5160d5c3dbf1Smrg    thread_safe=no
5161d5c3dbf1Smrg    vinfo=
5162d5c3dbf1Smrg    vinfo_number=no
5163d5c3dbf1Smrg    weak_libs=
5164d5c3dbf1Smrg    single_module="${wl}-single_module"
5165d5c3dbf1Smrg    func_infer_tag $base_compile
51669f606849Smrg
5167d5c3dbf1Smrg    # We need to know -static, to get the right output filenames.
5168d5c3dbf1Smrg    for arg
5169d5c3dbf1Smrg    do
5170d5c3dbf1Smrg      case $arg in
5171d5c3dbf1Smrg      -shared)
5172d5c3dbf1Smrg	test "$build_libtool_libs" != yes && \
5173d5c3dbf1Smrg	  func_fatal_configuration "can not build a shared library"
5174d5c3dbf1Smrg	build_old_libs=no
5175d5c3dbf1Smrg	break
5176d5c3dbf1Smrg	;;
5177d5c3dbf1Smrg      -all-static | -static | -static-libtool-libs)
5178d5c3dbf1Smrg	case $arg in
5179d5c3dbf1Smrg	-all-static)
5180d5c3dbf1Smrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
5181d5c3dbf1Smrg	    func_warning "complete static linking is impossible in this configuration"
5182d5c3dbf1Smrg	  fi
5183d5c3dbf1Smrg	  if test -n "$link_static_flag"; then
5184d5c3dbf1Smrg	    dlopen_self=$dlopen_self_static
5185d5c3dbf1Smrg	  fi
5186d5c3dbf1Smrg	  prefer_static_libs=yes
5187d5c3dbf1Smrg	  ;;
5188d5c3dbf1Smrg	-static)
5189d5c3dbf1Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
5190d5c3dbf1Smrg	    dlopen_self=$dlopen_self_static
5191d5c3dbf1Smrg	  fi
5192d5c3dbf1Smrg	  prefer_static_libs=built
5193d5c3dbf1Smrg	  ;;
5194d5c3dbf1Smrg	-static-libtool-libs)
5195d5c3dbf1Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
5196d5c3dbf1Smrg	    dlopen_self=$dlopen_self_static
5197d5c3dbf1Smrg	  fi
5198d5c3dbf1Smrg	  prefer_static_libs=yes
5199d5c3dbf1Smrg	  ;;
5200d5c3dbf1Smrg	esac
5201d5c3dbf1Smrg	build_libtool_libs=no
5202d5c3dbf1Smrg	build_old_libs=yes
5203d5c3dbf1Smrg	break
5204d5c3dbf1Smrg	;;
5205d5c3dbf1Smrg      esac
5206d5c3dbf1Smrg    done
52079f606849Smrg
5208d5c3dbf1Smrg    # See if our shared archives depend on static archives.
5209d5c3dbf1Smrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
52109f606849Smrg
5211d5c3dbf1Smrg    # Go through the arguments, transforming them on the way.
5212d5c3dbf1Smrg    while test "$#" -gt 0; do
5213d5c3dbf1Smrg      arg="$1"
5214d5c3dbf1Smrg      shift
5215d5c3dbf1Smrg      func_quote_for_eval "$arg"
5216d5c3dbf1Smrg      qarg=$func_quote_for_eval_unquoted_result
5217d5c3dbf1Smrg      func_append libtool_args " $func_quote_for_eval_result"
52189f606849Smrg
5219d5c3dbf1Smrg      # If the previous option needs an argument, assign it.
5220d5c3dbf1Smrg      if test -n "$prev"; then
5221d5c3dbf1Smrg	case $prev in
5222d5c3dbf1Smrg	output)
5223d5c3dbf1Smrg	  func_append compile_command " @OUTPUT@"
5224d5c3dbf1Smrg	  func_append finalize_command " @OUTPUT@"
5225d5c3dbf1Smrg	  ;;
5226d5c3dbf1Smrg	esac
52279f606849Smrg
5228d5c3dbf1Smrg	case $prev in
5229d5c3dbf1Smrg	bindir)
5230d5c3dbf1Smrg	  bindir="$arg"
5231d5c3dbf1Smrg	  prev=
5232d5c3dbf1Smrg	  continue
5233d5c3dbf1Smrg	  ;;
5234d5c3dbf1Smrg	dlfiles|dlprefiles)
5235d5c3dbf1Smrg	  if test "$preload" = no; then
5236d5c3dbf1Smrg	    # Add the symbol object into the linking commands.
5237d5c3dbf1Smrg	    func_append compile_command " @SYMFILE@"
5238d5c3dbf1Smrg	    func_append finalize_command " @SYMFILE@"
5239d5c3dbf1Smrg	    preload=yes
52409f606849Smrg	  fi
5241d5c3dbf1Smrg	  case $arg in
5242d5c3dbf1Smrg	  *.la | *.lo) ;;  # We handle these cases below.
5243d5c3dbf1Smrg	  force)
5244d5c3dbf1Smrg	    if test "$dlself" = no; then
5245d5c3dbf1Smrg	      dlself=needless
5246d5c3dbf1Smrg	      export_dynamic=yes
52479f606849Smrg	    fi
5248d5c3dbf1Smrg	    prev=
5249d5c3dbf1Smrg	    continue
5250d5c3dbf1Smrg	    ;;
5251d5c3dbf1Smrg	  self)
5252d5c3dbf1Smrg	    if test "$prev" = dlprefiles; then
5253d5c3dbf1Smrg	      dlself=yes
5254d5c3dbf1Smrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
5255d5c3dbf1Smrg	      dlself=yes
52569f606849Smrg	    else
5257d5c3dbf1Smrg	      dlself=needless
5258d5c3dbf1Smrg	      export_dynamic=yes
52599f606849Smrg	    fi
5260d5c3dbf1Smrg	    prev=
5261d5c3dbf1Smrg	    continue
5262d5c3dbf1Smrg	    ;;
5263d5c3dbf1Smrg	  *)
5264d5c3dbf1Smrg	    if test "$prev" = dlfiles; then
5265cdbfa18aSmrg	      func_append dlfiles " $arg"
52669f606849Smrg	    else
5267cdbfa18aSmrg	      func_append dlprefiles " $arg"
52689f606849Smrg	    fi
5269d5c3dbf1Smrg	    prev=
5270d5c3dbf1Smrg	    continue
5271d5c3dbf1Smrg	    ;;
5272d5c3dbf1Smrg	  esac
5273d5c3dbf1Smrg	  ;;
5274d5c3dbf1Smrg	expsyms)
5275d5c3dbf1Smrg	  export_symbols="$arg"
5276d5c3dbf1Smrg	  test -f "$arg" \
5277d5c3dbf1Smrg	    || func_fatal_error "symbol file \`$arg' does not exist"
5278d5c3dbf1Smrg	  prev=
5279d5c3dbf1Smrg	  continue
5280d5c3dbf1Smrg	  ;;
5281d5c3dbf1Smrg	expsyms_regex)
5282d5c3dbf1Smrg	  export_symbols_regex="$arg"
5283d5c3dbf1Smrg	  prev=
5284d5c3dbf1Smrg	  continue
5285d5c3dbf1Smrg	  ;;
5286d5c3dbf1Smrg	framework)
52879f606849Smrg	  case $host in
5288d5c3dbf1Smrg	    *-*-darwin*)
5289d5c3dbf1Smrg	      case "$deplibs " in
5290d5c3dbf1Smrg		*" $qarg.ltframework "*) ;;
5291cdbfa18aSmrg		*) func_append deplibs " $qarg.ltframework" # this is fixed later
5292d5c3dbf1Smrg		   ;;
5293d5c3dbf1Smrg	      esac
5294d5c3dbf1Smrg	      ;;
52959f606849Smrg	  esac
5296d5c3dbf1Smrg	  prev=
5297d5c3dbf1Smrg	  continue
52989f606849Smrg	  ;;
5299d5c3dbf1Smrg	inst_prefix)
5300d5c3dbf1Smrg	  inst_prefix_dir="$arg"
5301d5c3dbf1Smrg	  prev=
5302d5c3dbf1Smrg	  continue
53039f606849Smrg	  ;;
5304d5c3dbf1Smrg	objectlist)
5305d5c3dbf1Smrg	  if test -f "$arg"; then
5306d5c3dbf1Smrg	    save_arg=$arg
5307d5c3dbf1Smrg	    moreargs=
5308d5c3dbf1Smrg	    for fil in `cat "$save_arg"`
5309d5c3dbf1Smrg	    do
5310cdbfa18aSmrg#	      func_append moreargs " $fil"
5311d5c3dbf1Smrg	      arg=$fil
5312d5c3dbf1Smrg	      # A libtool-controlled object.
53139f606849Smrg
5314d5c3dbf1Smrg	      # Check to see that this really is a libtool object.
5315d5c3dbf1Smrg	      if func_lalib_unsafe_p "$arg"; then
5316d5c3dbf1Smrg		pic_object=
5317d5c3dbf1Smrg		non_pic_object=
53189f606849Smrg
5319d5c3dbf1Smrg		# Read the .lo file
5320d5c3dbf1Smrg		func_source "$arg"
53219f606849Smrg
5322d5c3dbf1Smrg		if test -z "$pic_object" ||
5323d5c3dbf1Smrg		   test -z "$non_pic_object" ||
5324d5c3dbf1Smrg		   test "$pic_object" = none &&
5325d5c3dbf1Smrg		   test "$non_pic_object" = none; then
5326d5c3dbf1Smrg		  func_fatal_error "cannot find name of object for \`$arg'"
5327d5c3dbf1Smrg		fi
53289f606849Smrg
5329d5c3dbf1Smrg		# Extract subdirectory from the argument.
5330d5c3dbf1Smrg		func_dirname "$arg" "/" ""
5331d5c3dbf1Smrg		xdir="$func_dirname_result"
53329f606849Smrg
5333d5c3dbf1Smrg		if test "$pic_object" != none; then
5334d5c3dbf1Smrg		  # Prepend the subdirectory the object is found in.
5335d5c3dbf1Smrg		  pic_object="$xdir$pic_object"
53369f606849Smrg
5337d5c3dbf1Smrg		  if test "$prev" = dlfiles; then
5338d5c3dbf1Smrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5339cdbfa18aSmrg		      func_append dlfiles " $pic_object"
5340d5c3dbf1Smrg		      prev=
5341d5c3dbf1Smrg		      continue
5342d5c3dbf1Smrg		    else
5343d5c3dbf1Smrg		      # If libtool objects are unsupported, then we need to preload.
5344d5c3dbf1Smrg		      prev=dlprefiles
5345d5c3dbf1Smrg		    fi
5346d5c3dbf1Smrg		  fi
53479f606849Smrg
5348d5c3dbf1Smrg		  # CHECK ME:  I think I busted this.  -Ossama
5349d5c3dbf1Smrg		  if test "$prev" = dlprefiles; then
5350d5c3dbf1Smrg		    # Preload the old-style object.
5351cdbfa18aSmrg		    func_append dlprefiles " $pic_object"
5352d5c3dbf1Smrg		    prev=
5353d5c3dbf1Smrg		  fi
53549f606849Smrg
5355d5c3dbf1Smrg		  # A PIC object.
5356d5c3dbf1Smrg		  func_append libobjs " $pic_object"
5357d5c3dbf1Smrg		  arg="$pic_object"
5358d5c3dbf1Smrg		fi
53599f606849Smrg
5360d5c3dbf1Smrg		# Non-PIC object.
5361d5c3dbf1Smrg		if test "$non_pic_object" != none; then
5362d5c3dbf1Smrg		  # Prepend the subdirectory the object is found in.
5363d5c3dbf1Smrg		  non_pic_object="$xdir$non_pic_object"
53649f606849Smrg
5365d5c3dbf1Smrg		  # A standard non-PIC object
5366d5c3dbf1Smrg		  func_append non_pic_objects " $non_pic_object"
5367d5c3dbf1Smrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
5368d5c3dbf1Smrg		    arg="$non_pic_object"
5369d5c3dbf1Smrg		  fi
5370d5c3dbf1Smrg		else
5371d5c3dbf1Smrg		  # If the PIC object exists, use it instead.
5372d5c3dbf1Smrg		  # $xdir was prepended to $pic_object above.
5373d5c3dbf1Smrg		  non_pic_object="$pic_object"
5374d5c3dbf1Smrg		  func_append non_pic_objects " $non_pic_object"
5375d5c3dbf1Smrg		fi
5376d5c3dbf1Smrg	      else
5377d5c3dbf1Smrg		# Only an error if not doing a dry-run.
5378d5c3dbf1Smrg		if $opt_dry_run; then
5379d5c3dbf1Smrg		  # Extract subdirectory from the argument.
5380d5c3dbf1Smrg		  func_dirname "$arg" "/" ""
5381d5c3dbf1Smrg		  xdir="$func_dirname_result"
5382d5c3dbf1Smrg
5383d5c3dbf1Smrg		  func_lo2o "$arg"
5384d5c3dbf1Smrg		  pic_object=$xdir$objdir/$func_lo2o_result
5385d5c3dbf1Smrg		  non_pic_object=$xdir$func_lo2o_result
5386d5c3dbf1Smrg		  func_append libobjs " $pic_object"
5387d5c3dbf1Smrg		  func_append non_pic_objects " $non_pic_object"
5388d5c3dbf1Smrg	        else
5389d5c3dbf1Smrg		  func_fatal_error "\`$arg' is not a valid libtool object"
5390d5c3dbf1Smrg		fi
5391d5c3dbf1Smrg	      fi
5392d5c3dbf1Smrg	    done
53939f606849Smrg	  else
5394d5c3dbf1Smrg	    func_fatal_error "link input file \`$arg' does not exist"
53959f606849Smrg	  fi
5396d5c3dbf1Smrg	  arg=$save_arg
5397d5c3dbf1Smrg	  prev=
5398d5c3dbf1Smrg	  continue
5399d5c3dbf1Smrg	  ;;
5400d5c3dbf1Smrg	precious_regex)
5401d5c3dbf1Smrg	  precious_files_regex="$arg"
5402d5c3dbf1Smrg	  prev=
5403d5c3dbf1Smrg	  continue
5404d5c3dbf1Smrg	  ;;
5405d5c3dbf1Smrg	release)
5406d5c3dbf1Smrg	  release="-$arg"
5407d5c3dbf1Smrg	  prev=
5408d5c3dbf1Smrg	  continue
5409d5c3dbf1Smrg	  ;;
5410d5c3dbf1Smrg	rpath | xrpath)
5411d5c3dbf1Smrg	  # We need an absolute path.
5412d5c3dbf1Smrg	  case $arg in
5413d5c3dbf1Smrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
5414d5c3dbf1Smrg	  *)
5415d5c3dbf1Smrg	    func_fatal_error "only absolute run-paths are allowed"
5416d5c3dbf1Smrg	    ;;
5417d5c3dbf1Smrg	  esac
5418d5c3dbf1Smrg	  if test "$prev" = rpath; then
5419d5c3dbf1Smrg	    case "$rpath " in
5420d5c3dbf1Smrg	    *" $arg "*) ;;
5421cdbfa18aSmrg	    *) func_append rpath " $arg" ;;
5422d5c3dbf1Smrg	    esac
54239f606849Smrg	  else
5424d5c3dbf1Smrg	    case "$xrpath " in
5425d5c3dbf1Smrg	    *" $arg "*) ;;
5426cdbfa18aSmrg	    *) func_append xrpath " $arg" ;;
5427d5c3dbf1Smrg	    esac
54289f606849Smrg	  fi
5429d5c3dbf1Smrg	  prev=
5430d5c3dbf1Smrg	  continue
5431d5c3dbf1Smrg	  ;;
5432d5c3dbf1Smrg	shrext)
5433d5c3dbf1Smrg	  shrext_cmds="$arg"
5434d5c3dbf1Smrg	  prev=
5435d5c3dbf1Smrg	  continue
5436d5c3dbf1Smrg	  ;;
5437d5c3dbf1Smrg	weak)
5438cdbfa18aSmrg	  func_append weak_libs " $arg"
5439d5c3dbf1Smrg	  prev=
5440d5c3dbf1Smrg	  continue
5441d5c3dbf1Smrg	  ;;
5442d5c3dbf1Smrg	xcclinker)
5443cdbfa18aSmrg	  func_append linker_flags " $qarg"
5444cdbfa18aSmrg	  func_append compiler_flags " $qarg"
5445d5c3dbf1Smrg	  prev=
5446d5c3dbf1Smrg	  func_append compile_command " $qarg"
5447d5c3dbf1Smrg	  func_append finalize_command " $qarg"
5448d5c3dbf1Smrg	  continue
5449d5c3dbf1Smrg	  ;;
5450d5c3dbf1Smrg	xcompiler)
5451cdbfa18aSmrg	  func_append compiler_flags " $qarg"
5452d5c3dbf1Smrg	  prev=
5453d5c3dbf1Smrg	  func_append compile_command " $qarg"
5454d5c3dbf1Smrg	  func_append finalize_command " $qarg"
5455d5c3dbf1Smrg	  continue
5456d5c3dbf1Smrg	  ;;
5457d5c3dbf1Smrg	xlinker)
5458cdbfa18aSmrg	  func_append linker_flags " $qarg"
5459cdbfa18aSmrg	  func_append compiler_flags " $wl$qarg"
5460d5c3dbf1Smrg	  prev=
5461d5c3dbf1Smrg	  func_append compile_command " $wl$qarg"
5462d5c3dbf1Smrg	  func_append finalize_command " $wl$qarg"
5463d5c3dbf1Smrg	  continue
5464d5c3dbf1Smrg	  ;;
5465d5c3dbf1Smrg	*)
5466d5c3dbf1Smrg	  eval "$prev=\"\$arg\""
5467d5c3dbf1Smrg	  prev=
5468d5c3dbf1Smrg	  continue
5469d5c3dbf1Smrg	  ;;
54709f606849Smrg	esac
5471d5c3dbf1Smrg      fi # test -n "$prev"
54729f606849Smrg
5473d5c3dbf1Smrg      prevarg="$arg"
54749f606849Smrg
5475d5c3dbf1Smrg      case $arg in
5476d5c3dbf1Smrg      -all-static)
5477d5c3dbf1Smrg	if test -n "$link_static_flag"; then
5478d5c3dbf1Smrg	  # See comment for -static flag below, for more details.
5479d5c3dbf1Smrg	  func_append compile_command " $link_static_flag"
5480d5c3dbf1Smrg	  func_append finalize_command " $link_static_flag"
5481d5c3dbf1Smrg	fi
5482d5c3dbf1Smrg	continue
5483d5c3dbf1Smrg	;;
54849f606849Smrg
5485d5c3dbf1Smrg      -allow-undefined)
5486d5c3dbf1Smrg	# FIXME: remove this flag sometime in the future.
5487d5c3dbf1Smrg	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
5488d5c3dbf1Smrg	;;
54899f606849Smrg
5490d5c3dbf1Smrg      -avoid-version)
5491d5c3dbf1Smrg	avoid_version=yes
5492d5c3dbf1Smrg	continue
5493d5c3dbf1Smrg	;;
54949f606849Smrg
5495d5c3dbf1Smrg      -bindir)
5496d5c3dbf1Smrg	prev=bindir
5497d5c3dbf1Smrg	continue
5498d5c3dbf1Smrg	;;
54999f606849Smrg
5500d5c3dbf1Smrg      -dlopen)
5501d5c3dbf1Smrg	prev=dlfiles
5502d5c3dbf1Smrg	continue
5503d5c3dbf1Smrg	;;
55049f606849Smrg
5505d5c3dbf1Smrg      -dlpreopen)
5506d5c3dbf1Smrg	prev=dlprefiles
5507d5c3dbf1Smrg	continue
5508d5c3dbf1Smrg	;;
55099f606849Smrg
5510d5c3dbf1Smrg      -export-dynamic)
5511d5c3dbf1Smrg	export_dynamic=yes
5512d5c3dbf1Smrg	continue
5513d5c3dbf1Smrg	;;
55149f606849Smrg
5515d5c3dbf1Smrg      -export-symbols | -export-symbols-regex)
5516d5c3dbf1Smrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
5517d5c3dbf1Smrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
5518d5c3dbf1Smrg	fi
5519d5c3dbf1Smrg	if test "X$arg" = "X-export-symbols"; then
5520d5c3dbf1Smrg	  prev=expsyms
5521d5c3dbf1Smrg	else
5522d5c3dbf1Smrg	  prev=expsyms_regex
5523d5c3dbf1Smrg	fi
5524d5c3dbf1Smrg	continue
5525d5c3dbf1Smrg	;;
55269f606849Smrg
5527d5c3dbf1Smrg      -framework)
5528d5c3dbf1Smrg	prev=framework
5529d5c3dbf1Smrg	continue
5530d5c3dbf1Smrg	;;
55319f606849Smrg
5532d5c3dbf1Smrg      -inst-prefix-dir)
5533d5c3dbf1Smrg	prev=inst_prefix
5534d5c3dbf1Smrg	continue
5535d5c3dbf1Smrg	;;
55369f606849Smrg
5537d5c3dbf1Smrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
5538d5c3dbf1Smrg      # so, if we see these flags be careful not to treat them like -L
5539d5c3dbf1Smrg      -L[A-Z][A-Z]*:*)
5540d5c3dbf1Smrg	case $with_gcc/$host in
5541d5c3dbf1Smrg	no/*-*-irix* | /*-*-irix*)
5542d5c3dbf1Smrg	  func_append compile_command " $arg"
5543d5c3dbf1Smrg	  func_append finalize_command " $arg"
5544d5c3dbf1Smrg	  ;;
5545d5c3dbf1Smrg	esac
5546d5c3dbf1Smrg	continue
5547d5c3dbf1Smrg	;;
55489f606849Smrg
5549d5c3dbf1Smrg      -L*)
5550cdbfa18aSmrg	func_stripname "-L" '' "$arg"
5551cdbfa18aSmrg	if test -z "$func_stripname_result"; then
5552d5c3dbf1Smrg	  if test "$#" -gt 0; then
5553d5c3dbf1Smrg	    func_fatal_error "require no space between \`-L' and \`$1'"
5554d5c3dbf1Smrg	  else
5555d5c3dbf1Smrg	    func_fatal_error "need path for \`-L' option"
5556d5c3dbf1Smrg	  fi
5557d5c3dbf1Smrg	fi
5558cdbfa18aSmrg	func_resolve_sysroot "$func_stripname_result"
5559cdbfa18aSmrg	dir=$func_resolve_sysroot_result
5560d5c3dbf1Smrg	# We need an absolute path.
5561d5c3dbf1Smrg	case $dir in
5562d5c3dbf1Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
5563d5c3dbf1Smrg	*)
5564d5c3dbf1Smrg	  absdir=`cd "$dir" && pwd`
5565d5c3dbf1Smrg	  test -z "$absdir" && \
5566d5c3dbf1Smrg	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
5567d5c3dbf1Smrg	  dir="$absdir"
5568d5c3dbf1Smrg	  ;;
5569d5c3dbf1Smrg	esac
5570d5c3dbf1Smrg	case "$deplibs " in
5571cdbfa18aSmrg	*" -L$dir "* | *" $arg "*)
5572cdbfa18aSmrg	  # Will only happen for absolute or sysroot arguments
5573cdbfa18aSmrg	  ;;
5574d5c3dbf1Smrg	*)
5575cdbfa18aSmrg	  # Preserve sysroot, but never include relative directories
5576cdbfa18aSmrg	  case $dir in
5577cdbfa18aSmrg	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
5578cdbfa18aSmrg	    *) func_append deplibs " -L$dir" ;;
5579cdbfa18aSmrg	  esac
5580cdbfa18aSmrg	  func_append lib_search_path " $dir"
5581d5c3dbf1Smrg	  ;;
5582d5c3dbf1Smrg	esac
5583d5c3dbf1Smrg	case $host in
5584d5c3dbf1Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
5585d5c3dbf1Smrg	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
5586d5c3dbf1Smrg	  case :$dllsearchpath: in
5587d5c3dbf1Smrg	  *":$dir:"*) ;;
5588d5c3dbf1Smrg	  ::) dllsearchpath=$dir;;
5589cdbfa18aSmrg	  *) func_append dllsearchpath ":$dir";;
5590d5c3dbf1Smrg	  esac
5591d5c3dbf1Smrg	  case :$dllsearchpath: in
5592d5c3dbf1Smrg	  *":$testbindir:"*) ;;
5593d5c3dbf1Smrg	  ::) dllsearchpath=$testbindir;;
5594cdbfa18aSmrg	  *) func_append dllsearchpath ":$testbindir";;
5595d5c3dbf1Smrg	  esac
5596d5c3dbf1Smrg	  ;;
5597d5c3dbf1Smrg	esac
5598d5c3dbf1Smrg	continue
5599d5c3dbf1Smrg	;;
56009f606849Smrg
5601d5c3dbf1Smrg      -l*)
5602d5c3dbf1Smrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
5603d5c3dbf1Smrg	  case $host in
5604d5c3dbf1Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
5605d5c3dbf1Smrg	    # These systems don't actually have a C or math library (as such)
5606d5c3dbf1Smrg	    continue
5607d5c3dbf1Smrg	    ;;
5608d5c3dbf1Smrg	  *-*-os2*)
5609d5c3dbf1Smrg	    # These systems don't actually have a C library (as such)
5610d5c3dbf1Smrg	    test "X$arg" = "X-lc" && continue
5611d5c3dbf1Smrg	    ;;
5612d5c3dbf1Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5613d5c3dbf1Smrg	    # Do not include libc due to us having libc/libc_r.
5614d5c3dbf1Smrg	    test "X$arg" = "X-lc" && continue
5615d5c3dbf1Smrg	    ;;
5616d5c3dbf1Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
5617d5c3dbf1Smrg	    # Rhapsody C and math libraries are in the System framework
5618cdbfa18aSmrg	    func_append deplibs " System.ltframework"
5619d5c3dbf1Smrg	    continue
5620d5c3dbf1Smrg	    ;;
5621d5c3dbf1Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
5622d5c3dbf1Smrg	    # Causes problems with __ctype
5623d5c3dbf1Smrg	    test "X$arg" = "X-lc" && continue
5624d5c3dbf1Smrg	    ;;
5625d5c3dbf1Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
5626d5c3dbf1Smrg	    # Compiler inserts libc in the correct place for threads to work
5627d5c3dbf1Smrg	    test "X$arg" = "X-lc" && continue
5628d5c3dbf1Smrg	    ;;
5629d5c3dbf1Smrg	  esac
5630d5c3dbf1Smrg	elif test "X$arg" = "X-lc_r"; then
5631d5c3dbf1Smrg	 case $host in
5632d5c3dbf1Smrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5633d5c3dbf1Smrg	   # Do not include libc_r directly, use -pthread flag.
5634d5c3dbf1Smrg	   continue
5635d5c3dbf1Smrg	   ;;
5636d5c3dbf1Smrg	 esac
5637d5c3dbf1Smrg	fi
5638cdbfa18aSmrg	func_append deplibs " $arg"
5639d5c3dbf1Smrg	continue
5640d5c3dbf1Smrg	;;
56419f606849Smrg
5642d5c3dbf1Smrg      -module)
5643d5c3dbf1Smrg	module=yes
5644d5c3dbf1Smrg	continue
5645d5c3dbf1Smrg	;;
56469f606849Smrg
5647d5c3dbf1Smrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
5648d5c3dbf1Smrg      # classes, name mangling, and exception handling.
5649d5c3dbf1Smrg      # Darwin uses the -arch flag to determine output architecture.
5650cdbfa18aSmrg      -model|-arch|-isysroot|--sysroot)
5651cdbfa18aSmrg	func_append compiler_flags " $arg"
5652d5c3dbf1Smrg	func_append compile_command " $arg"
5653d5c3dbf1Smrg	func_append finalize_command " $arg"
5654d5c3dbf1Smrg	prev=xcompiler
5655d5c3dbf1Smrg	continue
5656d5c3dbf1Smrg	;;
56579f606849Smrg
5658cdbfa18aSmrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
5659cdbfa18aSmrg      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
5660cdbfa18aSmrg	func_append compiler_flags " $arg"
5661d5c3dbf1Smrg	func_append compile_command " $arg"
5662d5c3dbf1Smrg	func_append finalize_command " $arg"
5663d5c3dbf1Smrg	case "$new_inherited_linker_flags " in
5664d5c3dbf1Smrg	    *" $arg "*) ;;
5665cdbfa18aSmrg	    * ) func_append new_inherited_linker_flags " $arg" ;;
5666d5c3dbf1Smrg	esac
5667d5c3dbf1Smrg	continue
5668d5c3dbf1Smrg	;;
56699f606849Smrg
5670d5c3dbf1Smrg      -multi_module)
5671d5c3dbf1Smrg	single_module="${wl}-multi_module"
5672d5c3dbf1Smrg	continue
5673d5c3dbf1Smrg	;;
56749f606849Smrg
5675d5c3dbf1Smrg      -no-fast-install)
5676d5c3dbf1Smrg	fast_install=no
5677d5c3dbf1Smrg	continue
5678d5c3dbf1Smrg	;;
56799f606849Smrg
5680d5c3dbf1Smrg      -no-install)
5681d5c3dbf1Smrg	case $host in
5682d5c3dbf1Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
5683d5c3dbf1Smrg	  # The PATH hackery in wrapper scripts is required on Windows
5684d5c3dbf1Smrg	  # and Darwin in order for the loader to find any dlls it needs.
5685d5c3dbf1Smrg	  func_warning "\`-no-install' is ignored for $host"
5686d5c3dbf1Smrg	  func_warning "assuming \`-no-fast-install' instead"
5687d5c3dbf1Smrg	  fast_install=no
5688d5c3dbf1Smrg	  ;;
5689d5c3dbf1Smrg	*) no_install=yes ;;
5690d5c3dbf1Smrg	esac
5691d5c3dbf1Smrg	continue
5692d5c3dbf1Smrg	;;
56939f606849Smrg
5694d5c3dbf1Smrg      -no-undefined)
5695d5c3dbf1Smrg	allow_undefined=no
5696d5c3dbf1Smrg	continue
5697d5c3dbf1Smrg	;;
56989f606849Smrg
5699d5c3dbf1Smrg      -objectlist)
5700d5c3dbf1Smrg	prev=objectlist
5701d5c3dbf1Smrg	continue
5702d5c3dbf1Smrg	;;
57039f606849Smrg
5704d5c3dbf1Smrg      -o) prev=output ;;
57059f606849Smrg
5706d5c3dbf1Smrg      -precious-files-regex)
5707d5c3dbf1Smrg	prev=precious_regex
5708d5c3dbf1Smrg	continue
5709d5c3dbf1Smrg	;;
57109f606849Smrg
5711d5c3dbf1Smrg      -release)
5712d5c3dbf1Smrg	prev=release
5713d5c3dbf1Smrg	continue
5714d5c3dbf1Smrg	;;
57159f606849Smrg
5716d5c3dbf1Smrg      -rpath)
5717d5c3dbf1Smrg	prev=rpath
5718d5c3dbf1Smrg	continue
5719d5c3dbf1Smrg	;;
57209f606849Smrg
5721d5c3dbf1Smrg      -R)
5722d5c3dbf1Smrg	prev=xrpath
5723d5c3dbf1Smrg	continue
5724d5c3dbf1Smrg	;;
57259f606849Smrg
5726d5c3dbf1Smrg      -R*)
5727d5c3dbf1Smrg	func_stripname '-R' '' "$arg"
5728d5c3dbf1Smrg	dir=$func_stripname_result
5729d5c3dbf1Smrg	# We need an absolute path.
5730d5c3dbf1Smrg	case $dir in
5731d5c3dbf1Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
5732cdbfa18aSmrg	=*)
5733cdbfa18aSmrg	  func_stripname '=' '' "$dir"
5734cdbfa18aSmrg	  dir=$lt_sysroot$func_stripname_result
5735cdbfa18aSmrg	  ;;
5736d5c3dbf1Smrg	*)
5737d5c3dbf1Smrg	  func_fatal_error "only absolute run-paths are allowed"
5738d5c3dbf1Smrg	  ;;
5739d5c3dbf1Smrg	esac
5740d5c3dbf1Smrg	case "$xrpath " in
5741d5c3dbf1Smrg	*" $dir "*) ;;
5742cdbfa18aSmrg	*) func_append xrpath " $dir" ;;
5743d5c3dbf1Smrg	esac
5744d5c3dbf1Smrg	continue
5745d5c3dbf1Smrg	;;
57469f606849Smrg
5747d5c3dbf1Smrg      -shared)
5748d5c3dbf1Smrg	# The effects of -shared are defined in a previous loop.
5749d5c3dbf1Smrg	continue
5750d5c3dbf1Smrg	;;
57519f606849Smrg
5752d5c3dbf1Smrg      -shrext)
5753d5c3dbf1Smrg	prev=shrext
5754d5c3dbf1Smrg	continue
5755d5c3dbf1Smrg	;;
57569f606849Smrg
5757d5c3dbf1Smrg      -static | -static-libtool-libs)
5758d5c3dbf1Smrg	# The effects of -static are defined in a previous loop.
5759d5c3dbf1Smrg	# We used to do the same as -all-static on platforms that
5760d5c3dbf1Smrg	# didn't have a PIC flag, but the assumption that the effects
5761d5c3dbf1Smrg	# would be equivalent was wrong.  It would break on at least
5762d5c3dbf1Smrg	# Digital Unix and AIX.
5763d5c3dbf1Smrg	continue
5764d5c3dbf1Smrg	;;
57659f606849Smrg
5766d5c3dbf1Smrg      -thread-safe)
5767d5c3dbf1Smrg	thread_safe=yes
5768d5c3dbf1Smrg	continue
5769d5c3dbf1Smrg	;;
57709f606849Smrg
5771d5c3dbf1Smrg      -version-info)
5772d5c3dbf1Smrg	prev=vinfo
5773d5c3dbf1Smrg	continue
5774d5c3dbf1Smrg	;;
57759f606849Smrg
5776d5c3dbf1Smrg      -version-number)
5777d5c3dbf1Smrg	prev=vinfo
5778d5c3dbf1Smrg	vinfo_number=yes
5779d5c3dbf1Smrg	continue
5780d5c3dbf1Smrg	;;
57819f606849Smrg
5782d5c3dbf1Smrg      -weak)
5783d5c3dbf1Smrg        prev=weak
5784d5c3dbf1Smrg	continue
5785d5c3dbf1Smrg	;;
57869f606849Smrg
5787d5c3dbf1Smrg      -Wc,*)
5788d5c3dbf1Smrg	func_stripname '-Wc,' '' "$arg"
5789d5c3dbf1Smrg	args=$func_stripname_result
5790d5c3dbf1Smrg	arg=
5791d5c3dbf1Smrg	save_ifs="$IFS"; IFS=','
5792d5c3dbf1Smrg	for flag in $args; do
5793d5c3dbf1Smrg	  IFS="$save_ifs"
5794d5c3dbf1Smrg          func_quote_for_eval "$flag"
5795cdbfa18aSmrg	  func_append arg " $func_quote_for_eval_result"
5796cdbfa18aSmrg	  func_append compiler_flags " $func_quote_for_eval_result"
5797d5c3dbf1Smrg	done
5798d5c3dbf1Smrg	IFS="$save_ifs"
5799d5c3dbf1Smrg	func_stripname ' ' '' "$arg"
5800d5c3dbf1Smrg	arg=$func_stripname_result
5801d5c3dbf1Smrg	;;
58029f606849Smrg
5803d5c3dbf1Smrg      -Wl,*)
5804d5c3dbf1Smrg	func_stripname '-Wl,' '' "$arg"
5805d5c3dbf1Smrg	args=$func_stripname_result
5806d5c3dbf1Smrg	arg=
5807d5c3dbf1Smrg	save_ifs="$IFS"; IFS=','
5808d5c3dbf1Smrg	for flag in $args; do
5809d5c3dbf1Smrg	  IFS="$save_ifs"
5810d5c3dbf1Smrg          func_quote_for_eval "$flag"
5811cdbfa18aSmrg	  func_append arg " $wl$func_quote_for_eval_result"
5812cdbfa18aSmrg	  func_append compiler_flags " $wl$func_quote_for_eval_result"
5813cdbfa18aSmrg	  func_append linker_flags " $func_quote_for_eval_result"
5814d5c3dbf1Smrg	done
5815d5c3dbf1Smrg	IFS="$save_ifs"
5816d5c3dbf1Smrg	func_stripname ' ' '' "$arg"
5817d5c3dbf1Smrg	arg=$func_stripname_result
5818d5c3dbf1Smrg	;;
58199f606849Smrg
5820d5c3dbf1Smrg      -Xcompiler)
5821d5c3dbf1Smrg	prev=xcompiler
5822d5c3dbf1Smrg	continue
5823d5c3dbf1Smrg	;;
58249f606849Smrg
5825d5c3dbf1Smrg      -Xlinker)
5826d5c3dbf1Smrg	prev=xlinker
5827d5c3dbf1Smrg	continue
5828d5c3dbf1Smrg	;;
58299f606849Smrg
5830d5c3dbf1Smrg      -XCClinker)
5831d5c3dbf1Smrg	prev=xcclinker
5832d5c3dbf1Smrg	continue
5833d5c3dbf1Smrg	;;
58349f606849Smrg
5835d5c3dbf1Smrg      # -msg_* for osf cc
5836d5c3dbf1Smrg      -msg_*)
5837d5c3dbf1Smrg	func_quote_for_eval "$arg"
5838d5c3dbf1Smrg	arg="$func_quote_for_eval_result"
5839d5c3dbf1Smrg	;;
58409f606849Smrg
5841d5c3dbf1Smrg      # Flags to be passed through unchanged, with rationale:
5842d5c3dbf1Smrg      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
5843d5c3dbf1Smrg      # -r[0-9][0-9]*        specify processor for the SGI compiler
5844d5c3dbf1Smrg      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
5845d5c3dbf1Smrg      # +DA*, +DD*           enable 64-bit mode for the HP compiler
5846d5c3dbf1Smrg      # -q*                  compiler args for the IBM compiler
5847d5c3dbf1Smrg      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
5848d5c3dbf1Smrg      # -F/path              path to uninstalled frameworks, gcc on darwin
5849d5c3dbf1Smrg      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
5850d5c3dbf1Smrg      # @file                GCC response files
5851d5c3dbf1Smrg      # -tp=*                Portland pgcc target processor selection
5852cdbfa18aSmrg      # --sysroot=*          for sysroot support
5853cdbfa18aSmrg      # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
5854d5c3dbf1Smrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
5855cdbfa18aSmrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
5856cdbfa18aSmrg      -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
5857d5c3dbf1Smrg        func_quote_for_eval "$arg"
5858d5c3dbf1Smrg	arg="$func_quote_for_eval_result"
5859d5c3dbf1Smrg        func_append compile_command " $arg"
5860d5c3dbf1Smrg        func_append finalize_command " $arg"
5861cdbfa18aSmrg        func_append compiler_flags " $arg"
5862d5c3dbf1Smrg        continue
5863d5c3dbf1Smrg        ;;
58649f606849Smrg
5865d5c3dbf1Smrg      # Some other compiler flag.
5866d5c3dbf1Smrg      -* | +*)
5867d5c3dbf1Smrg        func_quote_for_eval "$arg"
5868d5c3dbf1Smrg	arg="$func_quote_for_eval_result"
5869d5c3dbf1Smrg	;;
58709f606849Smrg
5871d5c3dbf1Smrg      *.$objext)
5872d5c3dbf1Smrg	# A standard object.
5873cdbfa18aSmrg	func_append objs " $arg"
5874d5c3dbf1Smrg	;;
58759f606849Smrg
5876d5c3dbf1Smrg      *.lo)
5877d5c3dbf1Smrg	# A libtool-controlled object.
58789f606849Smrg
5879d5c3dbf1Smrg	# Check to see that this really is a libtool object.
5880d5c3dbf1Smrg	if func_lalib_unsafe_p "$arg"; then
5881d5c3dbf1Smrg	  pic_object=
5882d5c3dbf1Smrg	  non_pic_object=
58839f606849Smrg
5884d5c3dbf1Smrg	  # Read the .lo file
5885d5c3dbf1Smrg	  func_source "$arg"
58869f606849Smrg
5887d5c3dbf1Smrg	  if test -z "$pic_object" ||
5888d5c3dbf1Smrg	     test -z "$non_pic_object" ||
5889d5c3dbf1Smrg	     test "$pic_object" = none &&
5890d5c3dbf1Smrg	     test "$non_pic_object" = none; then
5891d5c3dbf1Smrg	    func_fatal_error "cannot find name of object for \`$arg'"
5892d5c3dbf1Smrg	  fi
5893fba89afeSmrg
5894d5c3dbf1Smrg	  # Extract subdirectory from the argument.
5895d5c3dbf1Smrg	  func_dirname "$arg" "/" ""
5896d5c3dbf1Smrg	  xdir="$func_dirname_result"
58979f606849Smrg
5898d5c3dbf1Smrg	  if test "$pic_object" != none; then
5899d5c3dbf1Smrg	    # Prepend the subdirectory the object is found in.
5900d5c3dbf1Smrg	    pic_object="$xdir$pic_object"
59019f606849Smrg
5902d5c3dbf1Smrg	    if test "$prev" = dlfiles; then
5903d5c3dbf1Smrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5904cdbfa18aSmrg		func_append dlfiles " $pic_object"
5905d5c3dbf1Smrg		prev=
5906d5c3dbf1Smrg		continue
5907d5c3dbf1Smrg	      else
5908d5c3dbf1Smrg		# If libtool objects are unsupported, then we need to preload.
5909d5c3dbf1Smrg		prev=dlprefiles
5910d5c3dbf1Smrg	      fi
5911d5c3dbf1Smrg	    fi
5912d5c3dbf1Smrg
5913d5c3dbf1Smrg	    # CHECK ME:  I think I busted this.  -Ossama
5914d5c3dbf1Smrg	    if test "$prev" = dlprefiles; then
5915d5c3dbf1Smrg	      # Preload the old-style object.
5916cdbfa18aSmrg	      func_append dlprefiles " $pic_object"
5917d5c3dbf1Smrg	      prev=
5918d5c3dbf1Smrg	    fi
5919d5c3dbf1Smrg
5920d5c3dbf1Smrg	    # A PIC object.
5921d5c3dbf1Smrg	    func_append libobjs " $pic_object"
5922d5c3dbf1Smrg	    arg="$pic_object"
5923d5c3dbf1Smrg	  fi
5924d5c3dbf1Smrg
5925d5c3dbf1Smrg	  # Non-PIC object.
5926d5c3dbf1Smrg	  if test "$non_pic_object" != none; then
5927d5c3dbf1Smrg	    # Prepend the subdirectory the object is found in.
5928d5c3dbf1Smrg	    non_pic_object="$xdir$non_pic_object"
5929d5c3dbf1Smrg
5930d5c3dbf1Smrg	    # A standard non-PIC object
5931d5c3dbf1Smrg	    func_append non_pic_objects " $non_pic_object"
5932d5c3dbf1Smrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
5933d5c3dbf1Smrg	      arg="$non_pic_object"
5934d5c3dbf1Smrg	    fi
5935d5c3dbf1Smrg	  else
5936d5c3dbf1Smrg	    # If the PIC object exists, use it instead.
5937d5c3dbf1Smrg	    # $xdir was prepended to $pic_object above.
5938d5c3dbf1Smrg	    non_pic_object="$pic_object"
5939d5c3dbf1Smrg	    func_append non_pic_objects " $non_pic_object"
5940d5c3dbf1Smrg	  fi
5941d5c3dbf1Smrg	else
5942d5c3dbf1Smrg	  # Only an error if not doing a dry-run.
5943d5c3dbf1Smrg	  if $opt_dry_run; then
5944d5c3dbf1Smrg	    # Extract subdirectory from the argument.
5945d5c3dbf1Smrg	    func_dirname "$arg" "/" ""
5946d5c3dbf1Smrg	    xdir="$func_dirname_result"
5947d5c3dbf1Smrg
5948d5c3dbf1Smrg	    func_lo2o "$arg"
5949d5c3dbf1Smrg	    pic_object=$xdir$objdir/$func_lo2o_result
5950d5c3dbf1Smrg	    non_pic_object=$xdir$func_lo2o_result
5951d5c3dbf1Smrg	    func_append libobjs " $pic_object"
5952d5c3dbf1Smrg	    func_append non_pic_objects " $non_pic_object"
5953d5c3dbf1Smrg	  else
5954d5c3dbf1Smrg	    func_fatal_error "\`$arg' is not a valid libtool object"
5955d5c3dbf1Smrg	  fi
5956d5c3dbf1Smrg	fi
5957d5c3dbf1Smrg	;;
5958d5c3dbf1Smrg
5959d5c3dbf1Smrg      *.$libext)
5960d5c3dbf1Smrg	# An archive.
5961cdbfa18aSmrg	func_append deplibs " $arg"
5962cdbfa18aSmrg	func_append old_deplibs " $arg"
5963d5c3dbf1Smrg	continue
5964d5c3dbf1Smrg	;;
5965d5c3dbf1Smrg
5966d5c3dbf1Smrg      *.la)
5967d5c3dbf1Smrg	# A libtool-controlled library.
5968d5c3dbf1Smrg
5969cdbfa18aSmrg	func_resolve_sysroot "$arg"
5970d5c3dbf1Smrg	if test "$prev" = dlfiles; then
5971d5c3dbf1Smrg	  # This library was specified with -dlopen.
5972cdbfa18aSmrg	  func_append dlfiles " $func_resolve_sysroot_result"
5973d5c3dbf1Smrg	  prev=
5974d5c3dbf1Smrg	elif test "$prev" = dlprefiles; then
5975d5c3dbf1Smrg	  # The library was specified with -dlpreopen.
5976cdbfa18aSmrg	  func_append dlprefiles " $func_resolve_sysroot_result"
5977d5c3dbf1Smrg	  prev=
5978d5c3dbf1Smrg	else
5979cdbfa18aSmrg	  func_append deplibs " $func_resolve_sysroot_result"
5980d5c3dbf1Smrg	fi
5981d5c3dbf1Smrg	continue
5982d5c3dbf1Smrg	;;
5983d5c3dbf1Smrg
5984d5c3dbf1Smrg      # Some other compiler argument.
5985d5c3dbf1Smrg      *)
5986d5c3dbf1Smrg	# Unknown arguments in both finalize_command and compile_command need
5987d5c3dbf1Smrg	# to be aesthetically quoted because they are evaled later.
5988d5c3dbf1Smrg	func_quote_for_eval "$arg"
5989d5c3dbf1Smrg	arg="$func_quote_for_eval_result"
5990d5c3dbf1Smrg	;;
5991d5c3dbf1Smrg      esac # arg
5992d5c3dbf1Smrg
5993d5c3dbf1Smrg      # Now actually substitute the argument into the commands.
5994d5c3dbf1Smrg      if test -n "$arg"; then
5995d5c3dbf1Smrg	func_append compile_command " $arg"
5996d5c3dbf1Smrg	func_append finalize_command " $arg"
5997d5c3dbf1Smrg      fi
5998d5c3dbf1Smrg    done # argument parsing loop
5999d5c3dbf1Smrg
6000d5c3dbf1Smrg    test -n "$prev" && \
6001d5c3dbf1Smrg      func_fatal_help "the \`$prevarg' option requires an argument"
6002d5c3dbf1Smrg
6003d5c3dbf1Smrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
6004d5c3dbf1Smrg      eval arg=\"$export_dynamic_flag_spec\"
6005d5c3dbf1Smrg      func_append compile_command " $arg"
6006d5c3dbf1Smrg      func_append finalize_command " $arg"
6007d5c3dbf1Smrg    fi
6008d5c3dbf1Smrg
6009d5c3dbf1Smrg    oldlibs=
6010d5c3dbf1Smrg    # calculate the name of the file, without its directory
6011d5c3dbf1Smrg    func_basename "$output"
6012d5c3dbf1Smrg    outputname="$func_basename_result"
6013d5c3dbf1Smrg    libobjs_save="$libobjs"
6014d5c3dbf1Smrg
6015d5c3dbf1Smrg    if test -n "$shlibpath_var"; then
6016d5c3dbf1Smrg      # get the directories listed in $shlibpath_var
6017d5c3dbf1Smrg      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
60189f606849Smrg    else
6019d5c3dbf1Smrg      shlib_search_path=
60209f606849Smrg    fi
6021d5c3dbf1Smrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
6022d5c3dbf1Smrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
60239f606849Smrg
6024d5c3dbf1Smrg    func_dirname "$output" "/" ""
6025d5c3dbf1Smrg    output_objdir="$func_dirname_result$objdir"
6026cdbfa18aSmrg    func_to_tool_file "$output_objdir/"
6027cdbfa18aSmrg    tool_output_objdir=$func_to_tool_file_result
6028d5c3dbf1Smrg    # Create the object directory.
6029d5c3dbf1Smrg    func_mkdir_p "$output_objdir"
60309f606849Smrg
6031d5c3dbf1Smrg    # Determine the type of output
6032d5c3dbf1Smrg    case $output in
6033d5c3dbf1Smrg    "")
6034d5c3dbf1Smrg      func_fatal_help "you must specify an output file"
6035d5c3dbf1Smrg      ;;
6036d5c3dbf1Smrg    *.$libext) linkmode=oldlib ;;
6037d5c3dbf1Smrg    *.lo | *.$objext) linkmode=obj ;;
6038d5c3dbf1Smrg    *.la) linkmode=lib ;;
6039d5c3dbf1Smrg    *) linkmode=prog ;; # Anything else should be a program.
6040d5c3dbf1Smrg    esac
6041d5c3dbf1Smrg
6042d5c3dbf1Smrg    specialdeplibs=
6043d5c3dbf1Smrg
6044d5c3dbf1Smrg    libs=
6045d5c3dbf1Smrg    # Find all interdependent deplibs by searching for libraries
6046d5c3dbf1Smrg    # that are linked more than once (e.g. -la -lb -la)
6047d5c3dbf1Smrg    for deplib in $deplibs; do
6048cdbfa18aSmrg      if $opt_preserve_dup_deps ; then
6049d5c3dbf1Smrg	case "$libs " in
6050cdbfa18aSmrg	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
6051d5c3dbf1Smrg	esac
6052d5c3dbf1Smrg      fi
6053cdbfa18aSmrg      func_append libs " $deplib"
6054d5c3dbf1Smrg    done
6055d5c3dbf1Smrg
6056d5c3dbf1Smrg    if test "$linkmode" = lib; then
6057d5c3dbf1Smrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
6058d5c3dbf1Smrg
6059d5c3dbf1Smrg      # Compute libraries that are listed more than once in $predeps
6060d5c3dbf1Smrg      # $postdeps and mark them as special (i.e., whose duplicates are
6061d5c3dbf1Smrg      # not to be eliminated).
6062d5c3dbf1Smrg      pre_post_deps=
6063d5c3dbf1Smrg      if $opt_duplicate_compiler_generated_deps; then
6064d5c3dbf1Smrg	for pre_post_dep in $predeps $postdeps; do
6065d5c3dbf1Smrg	  case "$pre_post_deps " in
6066cdbfa18aSmrg	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
6067d5c3dbf1Smrg	  esac
6068cdbfa18aSmrg	  func_append pre_post_deps " $pre_post_dep"
6069d5c3dbf1Smrg	done
6070d5c3dbf1Smrg      fi
6071d5c3dbf1Smrg      pre_post_deps=
6072d5c3dbf1Smrg    fi
6073d5c3dbf1Smrg
6074d5c3dbf1Smrg    deplibs=
6075d5c3dbf1Smrg    newdependency_libs=
6076d5c3dbf1Smrg    newlib_search_path=
6077d5c3dbf1Smrg    need_relink=no # whether we're linking any uninstalled libtool libraries
6078d5c3dbf1Smrg    notinst_deplibs= # not-installed libtool libraries
6079d5c3dbf1Smrg    notinst_path= # paths that contain not-installed libtool libraries
6080d5c3dbf1Smrg
6081d5c3dbf1Smrg    case $linkmode in
6082d5c3dbf1Smrg    lib)
6083d5c3dbf1Smrg	passes="conv dlpreopen link"
6084d5c3dbf1Smrg	for file in $dlfiles $dlprefiles; do
6085d5c3dbf1Smrg	  case $file in
6086d5c3dbf1Smrg	  *.la) ;;
6087d5c3dbf1Smrg	  *)
6088d5c3dbf1Smrg	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
6089d5c3dbf1Smrg	    ;;
6090d5c3dbf1Smrg	  esac
6091d5c3dbf1Smrg	done
6092d5c3dbf1Smrg	;;
6093d5c3dbf1Smrg    prog)
6094d5c3dbf1Smrg	compile_deplibs=
6095d5c3dbf1Smrg	finalize_deplibs=
6096d5c3dbf1Smrg	alldeplibs=no
6097d5c3dbf1Smrg	newdlfiles=
6098d5c3dbf1Smrg	newdlprefiles=
6099d5c3dbf1Smrg	passes="conv scan dlopen dlpreopen link"
6100d5c3dbf1Smrg	;;
6101d5c3dbf1Smrg    *)  passes="conv"
6102d5c3dbf1Smrg	;;
6103d5c3dbf1Smrg    esac
6104d5c3dbf1Smrg
6105d5c3dbf1Smrg    for pass in $passes; do
6106d5c3dbf1Smrg      # The preopen pass in lib mode reverses $deplibs; put it back here
6107d5c3dbf1Smrg      # so that -L comes before libs that need it for instance...
6108d5c3dbf1Smrg      if test "$linkmode,$pass" = "lib,link"; then
6109d5c3dbf1Smrg	## FIXME: Find the place where the list is rebuilt in the wrong
6110d5c3dbf1Smrg	##        order, and fix it there properly
6111d5c3dbf1Smrg        tmp_deplibs=
6112d5c3dbf1Smrg	for deplib in $deplibs; do
6113d5c3dbf1Smrg	  tmp_deplibs="$deplib $tmp_deplibs"
6114d5c3dbf1Smrg	done
6115d5c3dbf1Smrg	deplibs="$tmp_deplibs"
6116d5c3dbf1Smrg      fi
6117d5c3dbf1Smrg
6118d5c3dbf1Smrg      if test "$linkmode,$pass" = "lib,link" ||
6119d5c3dbf1Smrg	 test "$linkmode,$pass" = "prog,scan"; then
6120d5c3dbf1Smrg	libs="$deplibs"
6121d5c3dbf1Smrg	deplibs=
6122d5c3dbf1Smrg      fi
6123d5c3dbf1Smrg      if test "$linkmode" = prog; then
6124d5c3dbf1Smrg	case $pass in
6125d5c3dbf1Smrg	dlopen) libs="$dlfiles" ;;
6126d5c3dbf1Smrg	dlpreopen) libs="$dlprefiles" ;;
6127d5c3dbf1Smrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
6128d5c3dbf1Smrg	esac
6129d5c3dbf1Smrg      fi
6130d5c3dbf1Smrg      if test "$linkmode,$pass" = "lib,dlpreopen"; then
6131d5c3dbf1Smrg	# Collect and forward deplibs of preopened libtool libs
6132d5c3dbf1Smrg	for lib in $dlprefiles; do
6133d5c3dbf1Smrg	  # Ignore non-libtool-libs
6134d5c3dbf1Smrg	  dependency_libs=
6135cdbfa18aSmrg	  func_resolve_sysroot "$lib"
6136d5c3dbf1Smrg	  case $lib in
6137cdbfa18aSmrg	  *.la)	func_source "$func_resolve_sysroot_result" ;;
6138d5c3dbf1Smrg	  esac
6139d5c3dbf1Smrg
6140d5c3dbf1Smrg	  # Collect preopened libtool deplibs, except any this library
6141d5c3dbf1Smrg	  # has declared as weak libs
6142d5c3dbf1Smrg	  for deplib in $dependency_libs; do
6143d5c3dbf1Smrg	    func_basename "$deplib"
6144d5c3dbf1Smrg            deplib_base=$func_basename_result
6145d5c3dbf1Smrg	    case " $weak_libs " in
6146d5c3dbf1Smrg	    *" $deplib_base "*) ;;
6147cdbfa18aSmrg	    *) func_append deplibs " $deplib" ;;
6148d5c3dbf1Smrg	    esac
6149d5c3dbf1Smrg	  done
6150d5c3dbf1Smrg	done
6151d5c3dbf1Smrg	libs="$dlprefiles"
6152d5c3dbf1Smrg      fi
6153d5c3dbf1Smrg      if test "$pass" = dlopen; then
6154d5c3dbf1Smrg	# Collect dlpreopened libraries
6155d5c3dbf1Smrg	save_deplibs="$deplibs"
6156d5c3dbf1Smrg	deplibs=
6157d5c3dbf1Smrg      fi
6158d5c3dbf1Smrg
6159d5c3dbf1Smrg      for deplib in $libs; do
6160d5c3dbf1Smrg	lib=
6161d5c3dbf1Smrg	found=no
6162d5c3dbf1Smrg	case $deplib in
6163cdbfa18aSmrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
6164cdbfa18aSmrg        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
6165d5c3dbf1Smrg	  if test "$linkmode,$pass" = "prog,link"; then
6166d5c3dbf1Smrg	    compile_deplibs="$deplib $compile_deplibs"
6167d5c3dbf1Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
6168d5c3dbf1Smrg	  else
6169cdbfa18aSmrg	    func_append compiler_flags " $deplib"
6170d5c3dbf1Smrg	    if test "$linkmode" = lib ; then
6171d5c3dbf1Smrg		case "$new_inherited_linker_flags " in
6172d5c3dbf1Smrg		    *" $deplib "*) ;;
6173cdbfa18aSmrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
6174d5c3dbf1Smrg		esac
6175d5c3dbf1Smrg	    fi
6176d5c3dbf1Smrg	  fi
6177d5c3dbf1Smrg	  continue
6178d5c3dbf1Smrg	  ;;
6179d5c3dbf1Smrg	-l*)
6180d5c3dbf1Smrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
6181d5c3dbf1Smrg	    func_warning "\`-l' is ignored for archives/objects"
6182d5c3dbf1Smrg	    continue
6183d5c3dbf1Smrg	  fi
6184d5c3dbf1Smrg	  func_stripname '-l' '' "$deplib"
6185d5c3dbf1Smrg	  name=$func_stripname_result
6186d5c3dbf1Smrg	  if test "$linkmode" = lib; then
6187d5c3dbf1Smrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
6188d5c3dbf1Smrg	  else
6189d5c3dbf1Smrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
6190d5c3dbf1Smrg	  fi
6191d5c3dbf1Smrg	  for searchdir in $searchdirs; do
6192d5c3dbf1Smrg	    for search_ext in .la $std_shrext .so .a; do
6193d5c3dbf1Smrg	      # Search the libtool library
6194d5c3dbf1Smrg	      lib="$searchdir/lib${name}${search_ext}"
6195d5c3dbf1Smrg	      if test -f "$lib"; then
6196d5c3dbf1Smrg		if test "$search_ext" = ".la"; then
6197d5c3dbf1Smrg		  found=yes
6198d5c3dbf1Smrg		else
6199d5c3dbf1Smrg		  found=no
6200d5c3dbf1Smrg		fi
6201d5c3dbf1Smrg		break 2
6202d5c3dbf1Smrg	      fi
6203d5c3dbf1Smrg	    done
6204d5c3dbf1Smrg	  done
6205d5c3dbf1Smrg	  if test "$found" != yes; then
6206d5c3dbf1Smrg	    # deplib doesn't seem to be a libtool library
6207d5c3dbf1Smrg	    if test "$linkmode,$pass" = "prog,link"; then
6208d5c3dbf1Smrg	      compile_deplibs="$deplib $compile_deplibs"
6209d5c3dbf1Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
6210d5c3dbf1Smrg	    else
6211d5c3dbf1Smrg	      deplibs="$deplib $deplibs"
6212d5c3dbf1Smrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6213d5c3dbf1Smrg	    fi
6214d5c3dbf1Smrg	    continue
6215d5c3dbf1Smrg	  else # deplib is a libtool library
6216d5c3dbf1Smrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
6217d5c3dbf1Smrg	    # We need to do some special things here, and not later.
6218d5c3dbf1Smrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6219d5c3dbf1Smrg	      case " $predeps $postdeps " in
6220d5c3dbf1Smrg	      *" $deplib "*)
6221d5c3dbf1Smrg		if func_lalib_p "$lib"; then
6222d5c3dbf1Smrg		  library_names=
6223d5c3dbf1Smrg		  old_library=
6224d5c3dbf1Smrg		  func_source "$lib"
6225d5c3dbf1Smrg		  for l in $old_library $library_names; do
6226d5c3dbf1Smrg		    ll="$l"
6227d5c3dbf1Smrg		  done
6228d5c3dbf1Smrg		  if test "X$ll" = "X$old_library" ; then # only static version available
6229d5c3dbf1Smrg		    found=no
6230d5c3dbf1Smrg		    func_dirname "$lib" "" "."
6231d5c3dbf1Smrg		    ladir="$func_dirname_result"
6232d5c3dbf1Smrg		    lib=$ladir/$old_library
6233d5c3dbf1Smrg		    if test "$linkmode,$pass" = "prog,link"; then
6234d5c3dbf1Smrg		      compile_deplibs="$deplib $compile_deplibs"
6235d5c3dbf1Smrg		      finalize_deplibs="$deplib $finalize_deplibs"
6236d5c3dbf1Smrg		    else
6237d5c3dbf1Smrg		      deplibs="$deplib $deplibs"
6238d5c3dbf1Smrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6239d5c3dbf1Smrg		    fi
6240d5c3dbf1Smrg		    continue
6241d5c3dbf1Smrg		  fi
6242d5c3dbf1Smrg		fi
6243d5c3dbf1Smrg		;;
6244d5c3dbf1Smrg	      *) ;;
6245d5c3dbf1Smrg	      esac
6246d5c3dbf1Smrg	    fi
6247d5c3dbf1Smrg	  fi
6248d5c3dbf1Smrg	  ;; # -l
6249d5c3dbf1Smrg	*.ltframework)
6250d5c3dbf1Smrg	  if test "$linkmode,$pass" = "prog,link"; then
6251d5c3dbf1Smrg	    compile_deplibs="$deplib $compile_deplibs"
6252d5c3dbf1Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
6253d5c3dbf1Smrg	  else
6254d5c3dbf1Smrg	    deplibs="$deplib $deplibs"
6255d5c3dbf1Smrg	    if test "$linkmode" = lib ; then
6256d5c3dbf1Smrg		case "$new_inherited_linker_flags " in
6257d5c3dbf1Smrg		    *" $deplib "*) ;;
6258cdbfa18aSmrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
6259d5c3dbf1Smrg		esac
6260d5c3dbf1Smrg	    fi
6261d5c3dbf1Smrg	  fi
6262d5c3dbf1Smrg	  continue
6263d5c3dbf1Smrg	  ;;
6264d5c3dbf1Smrg	-L*)
6265d5c3dbf1Smrg	  case $linkmode in
6266d5c3dbf1Smrg	  lib)
6267d5c3dbf1Smrg	    deplibs="$deplib $deplibs"
6268d5c3dbf1Smrg	    test "$pass" = conv && continue
6269d5c3dbf1Smrg	    newdependency_libs="$deplib $newdependency_libs"
6270d5c3dbf1Smrg	    func_stripname '-L' '' "$deplib"
6271cdbfa18aSmrg	    func_resolve_sysroot "$func_stripname_result"
6272cdbfa18aSmrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
6273d5c3dbf1Smrg	    ;;
6274d5c3dbf1Smrg	  prog)
6275d5c3dbf1Smrg	    if test "$pass" = conv; then
6276d5c3dbf1Smrg	      deplibs="$deplib $deplibs"
6277d5c3dbf1Smrg	      continue
6278d5c3dbf1Smrg	    fi
6279d5c3dbf1Smrg	    if test "$pass" = scan; then
6280d5c3dbf1Smrg	      deplibs="$deplib $deplibs"
6281d5c3dbf1Smrg	    else
6282d5c3dbf1Smrg	      compile_deplibs="$deplib $compile_deplibs"
6283d5c3dbf1Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
6284d5c3dbf1Smrg	    fi
6285d5c3dbf1Smrg	    func_stripname '-L' '' "$deplib"
6286cdbfa18aSmrg	    func_resolve_sysroot "$func_stripname_result"
6287cdbfa18aSmrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
6288d5c3dbf1Smrg	    ;;
6289d5c3dbf1Smrg	  *)
6290d5c3dbf1Smrg	    func_warning "\`-L' is ignored for archives/objects"
6291d5c3dbf1Smrg	    ;;
6292d5c3dbf1Smrg	  esac # linkmode
6293d5c3dbf1Smrg	  continue
6294d5c3dbf1Smrg	  ;; # -L
6295d5c3dbf1Smrg	-R*)
6296d5c3dbf1Smrg	  if test "$pass" = link; then
6297d5c3dbf1Smrg	    func_stripname '-R' '' "$deplib"
6298cdbfa18aSmrg	    func_resolve_sysroot "$func_stripname_result"
6299cdbfa18aSmrg	    dir=$func_resolve_sysroot_result
6300d5c3dbf1Smrg	    # Make sure the xrpath contains only unique directories.
6301d5c3dbf1Smrg	    case "$xrpath " in
6302d5c3dbf1Smrg	    *" $dir "*) ;;
6303cdbfa18aSmrg	    *) func_append xrpath " $dir" ;;
6304d5c3dbf1Smrg	    esac
6305d5c3dbf1Smrg	  fi
6306d5c3dbf1Smrg	  deplibs="$deplib $deplibs"
6307d5c3dbf1Smrg	  continue
6308d5c3dbf1Smrg	  ;;
6309cdbfa18aSmrg	*.la)
6310cdbfa18aSmrg	  func_resolve_sysroot "$deplib"
6311cdbfa18aSmrg	  lib=$func_resolve_sysroot_result
6312cdbfa18aSmrg	  ;;
6313d5c3dbf1Smrg	*.$libext)
6314d5c3dbf1Smrg	  if test "$pass" = conv; then
6315d5c3dbf1Smrg	    deplibs="$deplib $deplibs"
6316d5c3dbf1Smrg	    continue
6317d5c3dbf1Smrg	  fi
6318d5c3dbf1Smrg	  case $linkmode in
6319d5c3dbf1Smrg	  lib)
6320d5c3dbf1Smrg	    # Linking convenience modules into shared libraries is allowed,
6321d5c3dbf1Smrg	    # but linking other static libraries is non-portable.
6322d5c3dbf1Smrg	    case " $dlpreconveniencelibs " in
6323d5c3dbf1Smrg	    *" $deplib "*) ;;
6324d5c3dbf1Smrg	    *)
6325d5c3dbf1Smrg	      valid_a_lib=no
6326d5c3dbf1Smrg	      case $deplibs_check_method in
6327d5c3dbf1Smrg		match_pattern*)
6328d5c3dbf1Smrg		  set dummy $deplibs_check_method; shift
6329d5c3dbf1Smrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6330d5c3dbf1Smrg		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
6331d5c3dbf1Smrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
6332d5c3dbf1Smrg		    valid_a_lib=yes
6333d5c3dbf1Smrg		  fi
6334d5c3dbf1Smrg		;;
6335d5c3dbf1Smrg		pass_all)
6336d5c3dbf1Smrg		  valid_a_lib=yes
6337d5c3dbf1Smrg		;;
6338d5c3dbf1Smrg	      esac
6339d5c3dbf1Smrg	      if test "$valid_a_lib" != yes; then
6340d5c3dbf1Smrg		echo
6341d5c3dbf1Smrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
6342d5c3dbf1Smrg		echo "*** I have the capability to make that library automatically link in when"
6343d5c3dbf1Smrg		echo "*** you link to this library.  But I can only do this if you have a"
6344d5c3dbf1Smrg		echo "*** shared version of the library, which you do not appear to have"
6345d5c3dbf1Smrg		echo "*** because the file extensions .$libext of this argument makes me believe"
6346d5c3dbf1Smrg		echo "*** that it is just a static archive that I should not use here."
6347d5c3dbf1Smrg	      else
6348d5c3dbf1Smrg		echo
6349d5c3dbf1Smrg		$ECHO "*** Warning: Linking the shared library $output against the"
6350d5c3dbf1Smrg		$ECHO "*** static library $deplib is not portable!"
6351d5c3dbf1Smrg		deplibs="$deplib $deplibs"
6352d5c3dbf1Smrg	      fi
6353d5c3dbf1Smrg	      ;;
6354d5c3dbf1Smrg	    esac
6355d5c3dbf1Smrg	    continue
6356d5c3dbf1Smrg	    ;;
6357d5c3dbf1Smrg	  prog)
6358d5c3dbf1Smrg	    if test "$pass" != link; then
6359d5c3dbf1Smrg	      deplibs="$deplib $deplibs"
6360d5c3dbf1Smrg	    else
6361d5c3dbf1Smrg	      compile_deplibs="$deplib $compile_deplibs"
6362d5c3dbf1Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
6363d5c3dbf1Smrg	    fi
6364d5c3dbf1Smrg	    continue
6365d5c3dbf1Smrg	    ;;
6366d5c3dbf1Smrg	  esac # linkmode
6367d5c3dbf1Smrg	  ;; # *.$libext
6368d5c3dbf1Smrg	*.lo | *.$objext)
6369d5c3dbf1Smrg	  if test "$pass" = conv; then
6370d5c3dbf1Smrg	    deplibs="$deplib $deplibs"
6371d5c3dbf1Smrg	  elif test "$linkmode" = prog; then
6372d5c3dbf1Smrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
6373d5c3dbf1Smrg	      # If there is no dlopen support or we're linking statically,
6374d5c3dbf1Smrg	      # we need to preload.
6375cdbfa18aSmrg	      func_append newdlprefiles " $deplib"
6376d5c3dbf1Smrg	      compile_deplibs="$deplib $compile_deplibs"
6377d5c3dbf1Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
6378d5c3dbf1Smrg	    else
6379cdbfa18aSmrg	      func_append newdlfiles " $deplib"
6380d5c3dbf1Smrg	    fi
6381d5c3dbf1Smrg	  fi
6382d5c3dbf1Smrg	  continue
6383d5c3dbf1Smrg	  ;;
6384d5c3dbf1Smrg	%DEPLIBS%)
6385d5c3dbf1Smrg	  alldeplibs=yes
6386d5c3dbf1Smrg	  continue
6387d5c3dbf1Smrg	  ;;
6388d5c3dbf1Smrg	esac # case $deplib
6389d5c3dbf1Smrg
6390d5c3dbf1Smrg	if test "$found" = yes || test -f "$lib"; then :
6391d5c3dbf1Smrg	else
6392d5c3dbf1Smrg	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
6393d5c3dbf1Smrg	fi
6394d5c3dbf1Smrg
6395d5c3dbf1Smrg	# Check to see that this really is a libtool archive.
6396d5c3dbf1Smrg	func_lalib_unsafe_p "$lib" \
6397d5c3dbf1Smrg	  || func_fatal_error "\`$lib' is not a valid libtool archive"
6398d5c3dbf1Smrg
6399d5c3dbf1Smrg	func_dirname "$lib" "" "."
6400d5c3dbf1Smrg	ladir="$func_dirname_result"
6401d5c3dbf1Smrg
6402d5c3dbf1Smrg	dlname=
6403d5c3dbf1Smrg	dlopen=
6404d5c3dbf1Smrg	dlpreopen=
6405d5c3dbf1Smrg	libdir=
6406d5c3dbf1Smrg	library_names=
6407d5c3dbf1Smrg	old_library=
6408d5c3dbf1Smrg	inherited_linker_flags=
6409d5c3dbf1Smrg	# If the library was installed with an old release of libtool,
6410d5c3dbf1Smrg	# it will not redefine variables installed, or shouldnotlink
6411d5c3dbf1Smrg	installed=yes
6412d5c3dbf1Smrg	shouldnotlink=no
6413d5c3dbf1Smrg	avoidtemprpath=
6414d5c3dbf1Smrg
6415d5c3dbf1Smrg
6416d5c3dbf1Smrg	# Read the .la file
6417d5c3dbf1Smrg	func_source "$lib"
6418d5c3dbf1Smrg
6419d5c3dbf1Smrg	# Convert "-framework foo" to "foo.ltframework"
6420d5c3dbf1Smrg	if test -n "$inherited_linker_flags"; then
6421d5c3dbf1Smrg	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
6422d5c3dbf1Smrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
6423d5c3dbf1Smrg	    case " $new_inherited_linker_flags " in
6424d5c3dbf1Smrg	      *" $tmp_inherited_linker_flag "*) ;;
6425cdbfa18aSmrg	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
6426d5c3dbf1Smrg	    esac
6427d5c3dbf1Smrg	  done
6428d5c3dbf1Smrg	fi
6429d5c3dbf1Smrg	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
6430d5c3dbf1Smrg	if test "$linkmode,$pass" = "lib,link" ||
6431d5c3dbf1Smrg	   test "$linkmode,$pass" = "prog,scan" ||
6432d5c3dbf1Smrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
6433cdbfa18aSmrg	  test -n "$dlopen" && func_append dlfiles " $dlopen"
6434cdbfa18aSmrg	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
6435d5c3dbf1Smrg	fi
6436d5c3dbf1Smrg
6437d5c3dbf1Smrg	if test "$pass" = conv; then
6438d5c3dbf1Smrg	  # Only check for convenience libraries
6439d5c3dbf1Smrg	  deplibs="$lib $deplibs"
6440d5c3dbf1Smrg	  if test -z "$libdir"; then
6441d5c3dbf1Smrg	    if test -z "$old_library"; then
6442d5c3dbf1Smrg	      func_fatal_error "cannot find name of link library for \`$lib'"
6443d5c3dbf1Smrg	    fi
6444d5c3dbf1Smrg	    # It is a libtool convenience library, so add in its objects.
6445cdbfa18aSmrg	    func_append convenience " $ladir/$objdir/$old_library"
6446cdbfa18aSmrg	    func_append old_convenience " $ladir/$objdir/$old_library"
6447d5c3dbf1Smrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
6448d5c3dbf1Smrg	    func_fatal_error "\`$lib' is not a convenience library"
6449d5c3dbf1Smrg	  fi
6450d5c3dbf1Smrg	  tmp_libs=
6451d5c3dbf1Smrg	  for deplib in $dependency_libs; do
6452d5c3dbf1Smrg	    deplibs="$deplib $deplibs"
6453cdbfa18aSmrg	    if $opt_preserve_dup_deps ; then
6454d5c3dbf1Smrg	      case "$tmp_libs " in
6455cdbfa18aSmrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
6456d5c3dbf1Smrg	      esac
6457d5c3dbf1Smrg	    fi
6458cdbfa18aSmrg	    func_append tmp_libs " $deplib"
6459d5c3dbf1Smrg	  done
6460d5c3dbf1Smrg	  continue
6461d5c3dbf1Smrg	fi # $pass = conv
6462d5c3dbf1Smrg
6463d5c3dbf1Smrg
6464d5c3dbf1Smrg	# Get the name of the library we link against.
6465d5c3dbf1Smrg	linklib=
6466cdbfa18aSmrg	if test -n "$old_library" &&
6467cdbfa18aSmrg	   { test "$prefer_static_libs" = yes ||
6468cdbfa18aSmrg	     test "$prefer_static_libs,$installed" = "built,no"; }; then
6469cdbfa18aSmrg	  linklib=$old_library
6470cdbfa18aSmrg	else
6471cdbfa18aSmrg	  for l in $old_library $library_names; do
6472cdbfa18aSmrg	    linklib="$l"
6473cdbfa18aSmrg	  done
6474cdbfa18aSmrg	fi
6475d5c3dbf1Smrg	if test -z "$linklib"; then
6476d5c3dbf1Smrg	  func_fatal_error "cannot find name of link library for \`$lib'"
6477d5c3dbf1Smrg	fi
6478d5c3dbf1Smrg
6479d5c3dbf1Smrg	# This library was specified with -dlopen.
6480d5c3dbf1Smrg	if test "$pass" = dlopen; then
6481d5c3dbf1Smrg	  if test -z "$libdir"; then
6482d5c3dbf1Smrg	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
6483d5c3dbf1Smrg	  fi
6484d5c3dbf1Smrg	  if test -z "$dlname" ||
6485d5c3dbf1Smrg	     test "$dlopen_support" != yes ||
6486d5c3dbf1Smrg	     test "$build_libtool_libs" = no; then
6487d5c3dbf1Smrg	    # If there is no dlname, no dlopen support or we're linking
6488d5c3dbf1Smrg	    # statically, we need to preload.  We also need to preload any
6489d5c3dbf1Smrg	    # dependent libraries so libltdl's deplib preloader doesn't
6490d5c3dbf1Smrg	    # bomb out in the load deplibs phase.
6491cdbfa18aSmrg	    func_append dlprefiles " $lib $dependency_libs"
6492d5c3dbf1Smrg	  else
6493cdbfa18aSmrg	    func_append newdlfiles " $lib"
6494d5c3dbf1Smrg	  fi
6495d5c3dbf1Smrg	  continue
6496d5c3dbf1Smrg	fi # $pass = dlopen
6497d5c3dbf1Smrg
6498d5c3dbf1Smrg	# We need an absolute path.
6499d5c3dbf1Smrg	case $ladir in
6500d5c3dbf1Smrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
6501d5c3dbf1Smrg	*)
6502d5c3dbf1Smrg	  abs_ladir=`cd "$ladir" && pwd`
6503d5c3dbf1Smrg	  if test -z "$abs_ladir"; then
6504d5c3dbf1Smrg	    func_warning "cannot determine absolute directory name of \`$ladir'"
6505d5c3dbf1Smrg	    func_warning "passing it literally to the linker, although it might fail"
6506d5c3dbf1Smrg	    abs_ladir="$ladir"
6507d5c3dbf1Smrg	  fi
6508d5c3dbf1Smrg	  ;;
6509d5c3dbf1Smrg	esac
6510d5c3dbf1Smrg	func_basename "$lib"
6511d5c3dbf1Smrg	laname="$func_basename_result"
6512d5c3dbf1Smrg
6513d5c3dbf1Smrg	# Find the relevant object directory and library name.
6514d5c3dbf1Smrg	if test "X$installed" = Xyes; then
6515cdbfa18aSmrg	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6516d5c3dbf1Smrg	    func_warning "library \`$lib' was moved."
6517d5c3dbf1Smrg	    dir="$ladir"
6518d5c3dbf1Smrg	    absdir="$abs_ladir"
6519d5c3dbf1Smrg	    libdir="$abs_ladir"
6520d5c3dbf1Smrg	  else
6521cdbfa18aSmrg	    dir="$lt_sysroot$libdir"
6522cdbfa18aSmrg	    absdir="$lt_sysroot$libdir"
6523d5c3dbf1Smrg	  fi
6524d5c3dbf1Smrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
6525d5c3dbf1Smrg	else
6526d5c3dbf1Smrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6527d5c3dbf1Smrg	    dir="$ladir"
6528d5c3dbf1Smrg	    absdir="$abs_ladir"
6529d5c3dbf1Smrg	    # Remove this search path later
6530cdbfa18aSmrg	    func_append notinst_path " $abs_ladir"
6531d5c3dbf1Smrg	  else
6532d5c3dbf1Smrg	    dir="$ladir/$objdir"
6533d5c3dbf1Smrg	    absdir="$abs_ladir/$objdir"
6534d5c3dbf1Smrg	    # Remove this search path later
6535cdbfa18aSmrg	    func_append notinst_path " $abs_ladir"
6536d5c3dbf1Smrg	  fi
6537d5c3dbf1Smrg	fi # $installed = yes
6538d5c3dbf1Smrg	func_stripname 'lib' '.la' "$laname"
6539d5c3dbf1Smrg	name=$func_stripname_result
6540d5c3dbf1Smrg
6541d5c3dbf1Smrg	# This library was specified with -dlpreopen.
6542d5c3dbf1Smrg	if test "$pass" = dlpreopen; then
6543d5c3dbf1Smrg	  if test -z "$libdir" && test "$linkmode" = prog; then
6544d5c3dbf1Smrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
6545d5c3dbf1Smrg	  fi
6546cdbfa18aSmrg	  case "$host" in
6547cdbfa18aSmrg	    # special handling for platforms with PE-DLLs.
6548cdbfa18aSmrg	    *cygwin* | *mingw* | *cegcc* )
6549cdbfa18aSmrg	      # Linker will automatically link against shared library if both
6550cdbfa18aSmrg	      # static and shared are present.  Therefore, ensure we extract
6551cdbfa18aSmrg	      # symbols from the import library if a shared library is present
6552cdbfa18aSmrg	      # (otherwise, the dlopen module name will be incorrect).  We do
6553cdbfa18aSmrg	      # this by putting the import library name into $newdlprefiles.
6554cdbfa18aSmrg	      # We recover the dlopen module name by 'saving' the la file
6555cdbfa18aSmrg	      # name in a special purpose variable, and (later) extracting the
6556cdbfa18aSmrg	      # dlname from the la file.
6557cdbfa18aSmrg	      if test -n "$dlname"; then
6558cdbfa18aSmrg	        func_tr_sh "$dir/$linklib"
6559cdbfa18aSmrg	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
6560cdbfa18aSmrg	        func_append newdlprefiles " $dir/$linklib"
6561cdbfa18aSmrg	      else
6562cdbfa18aSmrg	        func_append newdlprefiles " $dir/$old_library"
6563cdbfa18aSmrg	        # Keep a list of preopened convenience libraries to check
6564cdbfa18aSmrg	        # that they are being used correctly in the link pass.
6565cdbfa18aSmrg	        test -z "$libdir" && \
6566cdbfa18aSmrg	          func_append dlpreconveniencelibs " $dir/$old_library"
6567cdbfa18aSmrg	      fi
6568cdbfa18aSmrg	    ;;
6569cdbfa18aSmrg	    * )
6570cdbfa18aSmrg	      # Prefer using a static library (so that no silly _DYNAMIC symbols
6571cdbfa18aSmrg	      # are required to link).
6572cdbfa18aSmrg	      if test -n "$old_library"; then
6573cdbfa18aSmrg	        func_append newdlprefiles " $dir/$old_library"
6574cdbfa18aSmrg	        # Keep a list of preopened convenience libraries to check
6575cdbfa18aSmrg	        # that they are being used correctly in the link pass.
6576cdbfa18aSmrg	        test -z "$libdir" && \
6577cdbfa18aSmrg	          func_append dlpreconveniencelibs " $dir/$old_library"
6578cdbfa18aSmrg	      # Otherwise, use the dlname, so that lt_dlopen finds it.
6579cdbfa18aSmrg	      elif test -n "$dlname"; then
6580cdbfa18aSmrg	        func_append newdlprefiles " $dir/$dlname"
6581cdbfa18aSmrg	      else
6582cdbfa18aSmrg	        func_append newdlprefiles " $dir/$linklib"
6583cdbfa18aSmrg	      fi
6584cdbfa18aSmrg	    ;;
6585cdbfa18aSmrg	  esac
6586d5c3dbf1Smrg	fi # $pass = dlpreopen
6587d5c3dbf1Smrg
6588d5c3dbf1Smrg	if test -z "$libdir"; then
6589d5c3dbf1Smrg	  # Link the convenience library
6590d5c3dbf1Smrg	  if test "$linkmode" = lib; then
6591d5c3dbf1Smrg	    deplibs="$dir/$old_library $deplibs"
6592d5c3dbf1Smrg	  elif test "$linkmode,$pass" = "prog,link"; then
6593d5c3dbf1Smrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
6594d5c3dbf1Smrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
6595d5c3dbf1Smrg	  else
6596d5c3dbf1Smrg	    deplibs="$lib $deplibs" # used for prog,scan pass
6597d5c3dbf1Smrg	  fi
6598d5c3dbf1Smrg	  continue
6599d5c3dbf1Smrg	fi
6600d5c3dbf1Smrg
6601d5c3dbf1Smrg
6602d5c3dbf1Smrg	if test "$linkmode" = prog && test "$pass" != link; then
6603cdbfa18aSmrg	  func_append newlib_search_path " $ladir"
6604d5c3dbf1Smrg	  deplibs="$lib $deplibs"
6605d5c3dbf1Smrg
6606d5c3dbf1Smrg	  linkalldeplibs=no
6607d5c3dbf1Smrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
6608d5c3dbf1Smrg	     test "$build_libtool_libs" = no; then
6609d5c3dbf1Smrg	    linkalldeplibs=yes
6610d5c3dbf1Smrg	  fi
6611d5c3dbf1Smrg
6612d5c3dbf1Smrg	  tmp_libs=
6613d5c3dbf1Smrg	  for deplib in $dependency_libs; do
6614d5c3dbf1Smrg	    case $deplib in
6615d5c3dbf1Smrg	    -L*) func_stripname '-L' '' "$deplib"
6616cdbfa18aSmrg	         func_resolve_sysroot "$func_stripname_result"
6617cdbfa18aSmrg	         func_append newlib_search_path " $func_resolve_sysroot_result"
6618d5c3dbf1Smrg		 ;;
6619d5c3dbf1Smrg	    esac
6620d5c3dbf1Smrg	    # Need to link against all dependency_libs?
6621d5c3dbf1Smrg	    if test "$linkalldeplibs" = yes; then
6622d5c3dbf1Smrg	      deplibs="$deplib $deplibs"
6623d5c3dbf1Smrg	    else
6624d5c3dbf1Smrg	      # Need to hardcode shared library paths
6625d5c3dbf1Smrg	      # or/and link against static libraries
6626d5c3dbf1Smrg	      newdependency_libs="$deplib $newdependency_libs"
6627d5c3dbf1Smrg	    fi
6628cdbfa18aSmrg	    if $opt_preserve_dup_deps ; then
6629d5c3dbf1Smrg	      case "$tmp_libs " in
6630cdbfa18aSmrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
6631d5c3dbf1Smrg	      esac
6632d5c3dbf1Smrg	    fi
6633cdbfa18aSmrg	    func_append tmp_libs " $deplib"
6634d5c3dbf1Smrg	  done # for deplib
6635d5c3dbf1Smrg	  continue
6636d5c3dbf1Smrg	fi # $linkmode = prog...
6637d5c3dbf1Smrg
6638d5c3dbf1Smrg	if test "$linkmode,$pass" = "prog,link"; then
6639d5c3dbf1Smrg	  if test -n "$library_names" &&
6640d5c3dbf1Smrg	     { { test "$prefer_static_libs" = no ||
6641d5c3dbf1Smrg	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
6642d5c3dbf1Smrg	       test -z "$old_library"; }; then
6643d5c3dbf1Smrg	    # We need to hardcode the library path
6644d5c3dbf1Smrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
6645d5c3dbf1Smrg	      # Make sure the rpath contains only unique directories.
6646d5c3dbf1Smrg	      case "$temp_rpath:" in
6647d5c3dbf1Smrg	      *"$absdir:"*) ;;
6648cdbfa18aSmrg	      *) func_append temp_rpath "$absdir:" ;;
6649d5c3dbf1Smrg	      esac
6650d5c3dbf1Smrg	    fi
6651d5c3dbf1Smrg
6652d5c3dbf1Smrg	    # Hardcode the library path.
6653d5c3dbf1Smrg	    # Skip directories that are in the system default run-time
6654d5c3dbf1Smrg	    # search path.
6655d5c3dbf1Smrg	    case " $sys_lib_dlsearch_path " in
6656d5c3dbf1Smrg	    *" $absdir "*) ;;
6657d5c3dbf1Smrg	    *)
6658d5c3dbf1Smrg	      case "$compile_rpath " in
6659d5c3dbf1Smrg	      *" $absdir "*) ;;
6660cdbfa18aSmrg	      *) func_append compile_rpath " $absdir" ;;
6661d5c3dbf1Smrg	      esac
6662d5c3dbf1Smrg	      ;;
6663d5c3dbf1Smrg	    esac
6664d5c3dbf1Smrg	    case " $sys_lib_dlsearch_path " in
6665d5c3dbf1Smrg	    *" $libdir "*) ;;
6666d5c3dbf1Smrg	    *)
6667d5c3dbf1Smrg	      case "$finalize_rpath " in
6668d5c3dbf1Smrg	      *" $libdir "*) ;;
6669cdbfa18aSmrg	      *) func_append finalize_rpath " $libdir" ;;
6670d5c3dbf1Smrg	      esac
6671d5c3dbf1Smrg	      ;;
6672d5c3dbf1Smrg	    esac
6673d5c3dbf1Smrg	  fi # $linkmode,$pass = prog,link...
6674d5c3dbf1Smrg
6675d5c3dbf1Smrg	  if test "$alldeplibs" = yes &&
6676d5c3dbf1Smrg	     { test "$deplibs_check_method" = pass_all ||
6677d5c3dbf1Smrg	       { test "$build_libtool_libs" = yes &&
6678d5c3dbf1Smrg		 test -n "$library_names"; }; }; then
6679d5c3dbf1Smrg	    # We only need to search for static libraries
6680d5c3dbf1Smrg	    continue
6681d5c3dbf1Smrg	  fi
6682d5c3dbf1Smrg	fi
6683d5c3dbf1Smrg
6684d5c3dbf1Smrg	link_static=no # Whether the deplib will be linked statically
6685d5c3dbf1Smrg	use_static_libs=$prefer_static_libs
6686d5c3dbf1Smrg	if test "$use_static_libs" = built && test "$installed" = yes; then
6687d5c3dbf1Smrg	  use_static_libs=no
6688d5c3dbf1Smrg	fi
6689d5c3dbf1Smrg	if test -n "$library_names" &&
6690d5c3dbf1Smrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
6691d5c3dbf1Smrg	  case $host in
6692d5c3dbf1Smrg	  *cygwin* | *mingw* | *cegcc*)
6693d5c3dbf1Smrg	      # No point in relinking DLLs because paths are not encoded
6694cdbfa18aSmrg	      func_append notinst_deplibs " $lib"
6695d5c3dbf1Smrg	      need_relink=no
6696d5c3dbf1Smrg	    ;;
6697d5c3dbf1Smrg	  *)
6698d5c3dbf1Smrg	    if test "$installed" = no; then
6699cdbfa18aSmrg	      func_append notinst_deplibs " $lib"
6700d5c3dbf1Smrg	      need_relink=yes
6701d5c3dbf1Smrg	    fi
6702d5c3dbf1Smrg	    ;;
6703d5c3dbf1Smrg	  esac
6704d5c3dbf1Smrg	  # This is a shared library
6705d5c3dbf1Smrg
6706d5c3dbf1Smrg	  # Warn about portability, can't link against -module's on some
6707d5c3dbf1Smrg	  # systems (darwin).  Don't bleat about dlopened modules though!
6708d5c3dbf1Smrg	  dlopenmodule=""
6709d5c3dbf1Smrg	  for dlpremoduletest in $dlprefiles; do
6710d5c3dbf1Smrg	    if test "X$dlpremoduletest" = "X$lib"; then
6711d5c3dbf1Smrg	      dlopenmodule="$dlpremoduletest"
6712d5c3dbf1Smrg	      break
6713d5c3dbf1Smrg	    fi
6714d5c3dbf1Smrg	  done
6715d5c3dbf1Smrg	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
6716d5c3dbf1Smrg	    echo
6717d5c3dbf1Smrg	    if test "$linkmode" = prog; then
6718d5c3dbf1Smrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
6719d5c3dbf1Smrg	    else
6720d5c3dbf1Smrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
6721d5c3dbf1Smrg	    fi
6722d5c3dbf1Smrg	    $ECHO "*** $linklib is not portable!"
6723d5c3dbf1Smrg	  fi
6724d5c3dbf1Smrg	  if test "$linkmode" = lib &&
6725d5c3dbf1Smrg	     test "$hardcode_into_libs" = yes; then
6726d5c3dbf1Smrg	    # Hardcode the library path.
6727d5c3dbf1Smrg	    # Skip directories that are in the system default run-time
6728d5c3dbf1Smrg	    # search path.
6729d5c3dbf1Smrg	    case " $sys_lib_dlsearch_path " in
6730d5c3dbf1Smrg	    *" $absdir "*) ;;
6731d5c3dbf1Smrg	    *)
6732d5c3dbf1Smrg	      case "$compile_rpath " in
6733d5c3dbf1Smrg	      *" $absdir "*) ;;
6734cdbfa18aSmrg	      *) func_append compile_rpath " $absdir" ;;
6735d5c3dbf1Smrg	      esac
6736d5c3dbf1Smrg	      ;;
6737d5c3dbf1Smrg	    esac
6738d5c3dbf1Smrg	    case " $sys_lib_dlsearch_path " in
6739d5c3dbf1Smrg	    *" $libdir "*) ;;
6740d5c3dbf1Smrg	    *)
6741d5c3dbf1Smrg	      case "$finalize_rpath " in
6742d5c3dbf1Smrg	      *" $libdir "*) ;;
6743cdbfa18aSmrg	      *) func_append finalize_rpath " $libdir" ;;
6744d5c3dbf1Smrg	      esac
6745d5c3dbf1Smrg	      ;;
6746d5c3dbf1Smrg	    esac
6747d5c3dbf1Smrg	  fi
6748d5c3dbf1Smrg
6749d5c3dbf1Smrg	  if test -n "$old_archive_from_expsyms_cmds"; then
6750d5c3dbf1Smrg	    # figure out the soname
6751d5c3dbf1Smrg	    set dummy $library_names
6752d5c3dbf1Smrg	    shift
6753d5c3dbf1Smrg	    realname="$1"
6754d5c3dbf1Smrg	    shift
6755d5c3dbf1Smrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
6756d5c3dbf1Smrg	    # use dlname if we got it. it's perfectly good, no?
6757d5c3dbf1Smrg	    if test -n "$dlname"; then
6758d5c3dbf1Smrg	      soname="$dlname"
6759d5c3dbf1Smrg	    elif test -n "$soname_spec"; then
6760d5c3dbf1Smrg	      # bleh windows
6761d5c3dbf1Smrg	      case $host in
6762d5c3dbf1Smrg	      *cygwin* | mingw* | *cegcc*)
6763d5c3dbf1Smrg	        func_arith $current - $age
6764d5c3dbf1Smrg		major=$func_arith_result
6765d5c3dbf1Smrg		versuffix="-$major"
6766d5c3dbf1Smrg		;;
6767d5c3dbf1Smrg	      esac
6768d5c3dbf1Smrg	      eval soname=\"$soname_spec\"
6769d5c3dbf1Smrg	    else
6770d5c3dbf1Smrg	      soname="$realname"
6771d5c3dbf1Smrg	    fi
6772d5c3dbf1Smrg
6773d5c3dbf1Smrg	    # Make a new name for the extract_expsyms_cmds to use
6774d5c3dbf1Smrg	    soroot="$soname"
6775d5c3dbf1Smrg	    func_basename "$soroot"
6776d5c3dbf1Smrg	    soname="$func_basename_result"
6777d5c3dbf1Smrg	    func_stripname 'lib' '.dll' "$soname"
6778d5c3dbf1Smrg	    newlib=libimp-$func_stripname_result.a
6779d5c3dbf1Smrg
6780d5c3dbf1Smrg	    # If the library has no export list, then create one now
6781d5c3dbf1Smrg	    if test -f "$output_objdir/$soname-def"; then :
6782d5c3dbf1Smrg	    else
6783d5c3dbf1Smrg	      func_verbose "extracting exported symbol list from \`$soname'"
6784d5c3dbf1Smrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
6785d5c3dbf1Smrg	    fi
6786d5c3dbf1Smrg
6787d5c3dbf1Smrg	    # Create $newlib
6788d5c3dbf1Smrg	    if test -f "$output_objdir/$newlib"; then :; else
6789d5c3dbf1Smrg	      func_verbose "generating import library for \`$soname'"
6790d5c3dbf1Smrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
6791d5c3dbf1Smrg	    fi
6792d5c3dbf1Smrg	    # make sure the library variables are pointing to the new library
6793d5c3dbf1Smrg	    dir=$output_objdir
6794d5c3dbf1Smrg	    linklib=$newlib
6795d5c3dbf1Smrg	  fi # test -n "$old_archive_from_expsyms_cmds"
6796d5c3dbf1Smrg
6797cdbfa18aSmrg	  if test "$linkmode" = prog || test "$opt_mode" != relink; then
6798d5c3dbf1Smrg	    add_shlibpath=
6799d5c3dbf1Smrg	    add_dir=
6800d5c3dbf1Smrg	    add=
6801d5c3dbf1Smrg	    lib_linked=yes
6802d5c3dbf1Smrg	    case $hardcode_action in
6803d5c3dbf1Smrg	    immediate | unsupported)
6804d5c3dbf1Smrg	      if test "$hardcode_direct" = no; then
6805d5c3dbf1Smrg		add="$dir/$linklib"
6806d5c3dbf1Smrg		case $host in
6807d5c3dbf1Smrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
6808d5c3dbf1Smrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
6809d5c3dbf1Smrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
6810d5c3dbf1Smrg		    *-*-unixware7*) add_dir="-L$dir" ;;
6811d5c3dbf1Smrg		  *-*-darwin* )
6812d5c3dbf1Smrg		    # if the lib is a (non-dlopened) module then we can not
6813d5c3dbf1Smrg		    # link against it, someone is ignoring the earlier warnings
6814d5c3dbf1Smrg		    if /usr/bin/file -L $add 2> /dev/null |
6815d5c3dbf1Smrg			 $GREP ": [^:]* bundle" >/dev/null ; then
6816d5c3dbf1Smrg		      if test "X$dlopenmodule" != "X$lib"; then
6817d5c3dbf1Smrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
6818d5c3dbf1Smrg			if test -z "$old_library" ; then
6819d5c3dbf1Smrg			  echo
6820d5c3dbf1Smrg			  echo "*** And there doesn't seem to be a static archive available"
6821d5c3dbf1Smrg			  echo "*** The link will probably fail, sorry"
6822d5c3dbf1Smrg			else
6823d5c3dbf1Smrg			  add="$dir/$old_library"
6824d5c3dbf1Smrg			fi
6825d5c3dbf1Smrg		      elif test -n "$old_library"; then
6826d5c3dbf1Smrg			add="$dir/$old_library"
6827d5c3dbf1Smrg		      fi
6828d5c3dbf1Smrg		    fi
6829d5c3dbf1Smrg		esac
6830d5c3dbf1Smrg	      elif test "$hardcode_minus_L" = no; then
6831d5c3dbf1Smrg		case $host in
6832d5c3dbf1Smrg		*-*-sunos*) add_shlibpath="$dir" ;;
6833d5c3dbf1Smrg		esac
6834d5c3dbf1Smrg		add_dir="-L$dir"
6835d5c3dbf1Smrg		add="-l$name"
6836d5c3dbf1Smrg	      elif test "$hardcode_shlibpath_var" = no; then
6837d5c3dbf1Smrg		add_shlibpath="$dir"
6838d5c3dbf1Smrg		add="-l$name"
6839d5c3dbf1Smrg	      else
6840d5c3dbf1Smrg		lib_linked=no
6841d5c3dbf1Smrg	      fi
6842d5c3dbf1Smrg	      ;;
6843d5c3dbf1Smrg	    relink)
6844d5c3dbf1Smrg	      if test "$hardcode_direct" = yes &&
6845d5c3dbf1Smrg	         test "$hardcode_direct_absolute" = no; then
6846d5c3dbf1Smrg		add="$dir/$linklib"
6847d5c3dbf1Smrg	      elif test "$hardcode_minus_L" = yes; then
6848cdbfa18aSmrg		add_dir="-L$absdir"
6849d5c3dbf1Smrg		# Try looking first in the location we're being installed to.
6850d5c3dbf1Smrg		if test -n "$inst_prefix_dir"; then
6851d5c3dbf1Smrg		  case $libdir in
6852d5c3dbf1Smrg		    [\\/]*)
6853cdbfa18aSmrg		      func_append add_dir " -L$inst_prefix_dir$libdir"
6854d5c3dbf1Smrg		      ;;
6855d5c3dbf1Smrg		  esac
6856d5c3dbf1Smrg		fi
6857d5c3dbf1Smrg		add="-l$name"
6858d5c3dbf1Smrg	      elif test "$hardcode_shlibpath_var" = yes; then
6859d5c3dbf1Smrg		add_shlibpath="$dir"
6860d5c3dbf1Smrg		add="-l$name"
6861d5c3dbf1Smrg	      else
6862d5c3dbf1Smrg		lib_linked=no
6863d5c3dbf1Smrg	      fi
6864d5c3dbf1Smrg	      ;;
6865d5c3dbf1Smrg	    *) lib_linked=no ;;
6866d5c3dbf1Smrg	    esac
6867d5c3dbf1Smrg
6868d5c3dbf1Smrg	    if test "$lib_linked" != yes; then
6869d5c3dbf1Smrg	      func_fatal_configuration "unsupported hardcode properties"
6870d5c3dbf1Smrg	    fi
6871d5c3dbf1Smrg
6872d5c3dbf1Smrg	    if test -n "$add_shlibpath"; then
6873d5c3dbf1Smrg	      case :$compile_shlibpath: in
6874d5c3dbf1Smrg	      *":$add_shlibpath:"*) ;;
6875cdbfa18aSmrg	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
6876d5c3dbf1Smrg	      esac
6877d5c3dbf1Smrg	    fi
6878d5c3dbf1Smrg	    if test "$linkmode" = prog; then
6879d5c3dbf1Smrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
6880d5c3dbf1Smrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
6881d5c3dbf1Smrg	    else
6882d5c3dbf1Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
6883d5c3dbf1Smrg	      test -n "$add" && deplibs="$add $deplibs"
6884d5c3dbf1Smrg	      if test "$hardcode_direct" != yes &&
6885d5c3dbf1Smrg		 test "$hardcode_minus_L" != yes &&
6886d5c3dbf1Smrg		 test "$hardcode_shlibpath_var" = yes; then
6887d5c3dbf1Smrg		case :$finalize_shlibpath: in
6888d5c3dbf1Smrg		*":$libdir:"*) ;;
6889cdbfa18aSmrg		*) func_append finalize_shlibpath "$libdir:" ;;
6890d5c3dbf1Smrg		esac
6891d5c3dbf1Smrg	      fi
6892d5c3dbf1Smrg	    fi
6893d5c3dbf1Smrg	  fi
6894d5c3dbf1Smrg
6895cdbfa18aSmrg	  if test "$linkmode" = prog || test "$opt_mode" = relink; then
6896d5c3dbf1Smrg	    add_shlibpath=
6897d5c3dbf1Smrg	    add_dir=
6898d5c3dbf1Smrg	    add=
6899d5c3dbf1Smrg	    # Finalize command for both is simple: just hardcode it.
6900d5c3dbf1Smrg	    if test "$hardcode_direct" = yes &&
6901d5c3dbf1Smrg	       test "$hardcode_direct_absolute" = no; then
6902d5c3dbf1Smrg	      add="$libdir/$linklib"
6903d5c3dbf1Smrg	    elif test "$hardcode_minus_L" = yes; then
6904d5c3dbf1Smrg	      add_dir="-L$libdir"
6905d5c3dbf1Smrg	      add="-l$name"
6906d5c3dbf1Smrg	    elif test "$hardcode_shlibpath_var" = yes; then
6907d5c3dbf1Smrg	      case :$finalize_shlibpath: in
6908d5c3dbf1Smrg	      *":$libdir:"*) ;;
6909cdbfa18aSmrg	      *) func_append finalize_shlibpath "$libdir:" ;;
6910d5c3dbf1Smrg	      esac
6911d5c3dbf1Smrg	      add="-l$name"
6912d5c3dbf1Smrg	    elif test "$hardcode_automatic" = yes; then
6913d5c3dbf1Smrg	      if test -n "$inst_prefix_dir" &&
6914d5c3dbf1Smrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
6915d5c3dbf1Smrg		add="$inst_prefix_dir$libdir/$linklib"
6916d5c3dbf1Smrg	      else
6917d5c3dbf1Smrg		add="$libdir/$linklib"
6918d5c3dbf1Smrg	      fi
6919d5c3dbf1Smrg	    else
6920d5c3dbf1Smrg	      # We cannot seem to hardcode it, guess we'll fake it.
6921d5c3dbf1Smrg	      add_dir="-L$libdir"
6922d5c3dbf1Smrg	      # Try looking first in the location we're being installed to.
6923d5c3dbf1Smrg	      if test -n "$inst_prefix_dir"; then
6924d5c3dbf1Smrg		case $libdir in
6925d5c3dbf1Smrg		  [\\/]*)
6926cdbfa18aSmrg		    func_append add_dir " -L$inst_prefix_dir$libdir"
6927d5c3dbf1Smrg		    ;;
6928d5c3dbf1Smrg		esac
6929d5c3dbf1Smrg	      fi
6930d5c3dbf1Smrg	      add="-l$name"
6931d5c3dbf1Smrg	    fi
6932d5c3dbf1Smrg
6933d5c3dbf1Smrg	    if test "$linkmode" = prog; then
6934d5c3dbf1Smrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
6935d5c3dbf1Smrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
6936d5c3dbf1Smrg	    else
6937d5c3dbf1Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
6938d5c3dbf1Smrg	      test -n "$add" && deplibs="$add $deplibs"
6939d5c3dbf1Smrg	    fi
6940d5c3dbf1Smrg	  fi
6941d5c3dbf1Smrg	elif test "$linkmode" = prog; then
6942d5c3dbf1Smrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
6943d5c3dbf1Smrg	  # is not unsupported.  This is valid on all known static and
6944d5c3dbf1Smrg	  # shared platforms.
6945d5c3dbf1Smrg	  if test "$hardcode_direct" != unsupported; then
6946d5c3dbf1Smrg	    test -n "$old_library" && linklib="$old_library"
6947d5c3dbf1Smrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
6948d5c3dbf1Smrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
6949d5c3dbf1Smrg	  else
6950d5c3dbf1Smrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
6951d5c3dbf1Smrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
6952d5c3dbf1Smrg	  fi
6953d5c3dbf1Smrg	elif test "$build_libtool_libs" = yes; then
6954d5c3dbf1Smrg	  # Not a shared library
6955d5c3dbf1Smrg	  if test "$deplibs_check_method" != pass_all; then
6956d5c3dbf1Smrg	    # We're trying link a shared library against a static one
6957d5c3dbf1Smrg	    # but the system doesn't support it.
6958d5c3dbf1Smrg
6959d5c3dbf1Smrg	    # Just print a warning and add the library to dependency_libs so
6960d5c3dbf1Smrg	    # that the program can be linked against the static library.
6961d5c3dbf1Smrg	    echo
6962d5c3dbf1Smrg	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
6963d5c3dbf1Smrg	    echo "*** I have the capability to make that library automatically link in when"
6964d5c3dbf1Smrg	    echo "*** you link to this library.  But I can only do this if you have a"
6965d5c3dbf1Smrg	    echo "*** shared version of the library, which you do not appear to have."
6966d5c3dbf1Smrg	    if test "$module" = yes; then
6967d5c3dbf1Smrg	      echo "*** But as you try to build a module library, libtool will still create "
6968d5c3dbf1Smrg	      echo "*** a static module, that should work as long as the dlopening application"
6969d5c3dbf1Smrg	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
6970d5c3dbf1Smrg	      if test -z "$global_symbol_pipe"; then
6971d5c3dbf1Smrg		echo
6972d5c3dbf1Smrg		echo "*** However, this would only work if libtool was able to extract symbol"
6973d5c3dbf1Smrg		echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
6974d5c3dbf1Smrg		echo "*** not find such a program.  So, this module is probably useless."
6975d5c3dbf1Smrg		echo "*** \`nm' from GNU binutils and a full rebuild may help."
6976d5c3dbf1Smrg	      fi
6977d5c3dbf1Smrg	      if test "$build_old_libs" = no; then
6978d5c3dbf1Smrg		build_libtool_libs=module
6979d5c3dbf1Smrg		build_old_libs=yes
6980d5c3dbf1Smrg	      else
6981d5c3dbf1Smrg		build_libtool_libs=no
6982d5c3dbf1Smrg	      fi
6983d5c3dbf1Smrg	    fi
6984d5c3dbf1Smrg	  else
6985d5c3dbf1Smrg	    deplibs="$dir/$old_library $deplibs"
6986d5c3dbf1Smrg	    link_static=yes
6987d5c3dbf1Smrg	  fi
6988d5c3dbf1Smrg	fi # link shared/static library?
6989d5c3dbf1Smrg
6990d5c3dbf1Smrg	if test "$linkmode" = lib; then
6991d5c3dbf1Smrg	  if test -n "$dependency_libs" &&
6992d5c3dbf1Smrg	     { test "$hardcode_into_libs" != yes ||
6993d5c3dbf1Smrg	       test "$build_old_libs" = yes ||
6994d5c3dbf1Smrg	       test "$link_static" = yes; }; then
6995d5c3dbf1Smrg	    # Extract -R from dependency_libs
6996d5c3dbf1Smrg	    temp_deplibs=
6997d5c3dbf1Smrg	    for libdir in $dependency_libs; do
6998d5c3dbf1Smrg	      case $libdir in
6999d5c3dbf1Smrg	      -R*) func_stripname '-R' '' "$libdir"
7000d5c3dbf1Smrg	           temp_xrpath=$func_stripname_result
7001d5c3dbf1Smrg		   case " $xrpath " in
7002d5c3dbf1Smrg		   *" $temp_xrpath "*) ;;
7003cdbfa18aSmrg		   *) func_append xrpath " $temp_xrpath";;
7004d5c3dbf1Smrg		   esac;;
7005cdbfa18aSmrg	      *) func_append temp_deplibs " $libdir";;
7006d5c3dbf1Smrg	      esac
7007d5c3dbf1Smrg	    done
7008d5c3dbf1Smrg	    dependency_libs="$temp_deplibs"
7009d5c3dbf1Smrg	  fi
7010d5c3dbf1Smrg
7011cdbfa18aSmrg	  func_append newlib_search_path " $absdir"
7012d5c3dbf1Smrg	  # Link against this library
7013d5c3dbf1Smrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
7014d5c3dbf1Smrg	  # ... and its dependency_libs
7015d5c3dbf1Smrg	  tmp_libs=
7016d5c3dbf1Smrg	  for deplib in $dependency_libs; do
7017d5c3dbf1Smrg	    newdependency_libs="$deplib $newdependency_libs"
7018cdbfa18aSmrg	    case $deplib in
7019cdbfa18aSmrg              -L*) func_stripname '-L' '' "$deplib"
7020cdbfa18aSmrg                   func_resolve_sysroot "$func_stripname_result";;
7021cdbfa18aSmrg              *) func_resolve_sysroot "$deplib" ;;
7022cdbfa18aSmrg            esac
7023cdbfa18aSmrg	    if $opt_preserve_dup_deps ; then
7024d5c3dbf1Smrg	      case "$tmp_libs " in
7025cdbfa18aSmrg	      *" $func_resolve_sysroot_result "*)
7026cdbfa18aSmrg                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
7027d5c3dbf1Smrg	      esac
7028d5c3dbf1Smrg	    fi
7029cdbfa18aSmrg	    func_append tmp_libs " $func_resolve_sysroot_result"
7030d5c3dbf1Smrg	  done
7031d5c3dbf1Smrg
7032d5c3dbf1Smrg	  if test "$link_all_deplibs" != no; then
7033d5c3dbf1Smrg	    # Add the search paths of all dependency libraries
7034d5c3dbf1Smrg	    for deplib in $dependency_libs; do
7035d5c3dbf1Smrg	      path=
7036d5c3dbf1Smrg	      case $deplib in
7037d5c3dbf1Smrg	      -L*) path="$deplib" ;;
7038d5c3dbf1Smrg	      *.la)
7039cdbfa18aSmrg	        func_resolve_sysroot "$deplib"
7040cdbfa18aSmrg	        deplib=$func_resolve_sysroot_result
7041d5c3dbf1Smrg	        func_dirname "$deplib" "" "."
7042cdbfa18aSmrg		dir=$func_dirname_result
7043d5c3dbf1Smrg		# We need an absolute path.
7044d5c3dbf1Smrg		case $dir in
7045d5c3dbf1Smrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
7046d5c3dbf1Smrg		*)
7047d5c3dbf1Smrg		  absdir=`cd "$dir" && pwd`
7048d5c3dbf1Smrg		  if test -z "$absdir"; then
7049d5c3dbf1Smrg		    func_warning "cannot determine absolute directory name of \`$dir'"
7050d5c3dbf1Smrg		    absdir="$dir"
7051d5c3dbf1Smrg		  fi
7052d5c3dbf1Smrg		  ;;
7053d5c3dbf1Smrg		esac
7054d5c3dbf1Smrg		if $GREP "^installed=no" $deplib > /dev/null; then
7055d5c3dbf1Smrg		case $host in
7056d5c3dbf1Smrg		*-*-darwin*)
7057d5c3dbf1Smrg		  depdepl=
7058d5c3dbf1Smrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
7059d5c3dbf1Smrg		  if test -n "$deplibrary_names" ; then
7060d5c3dbf1Smrg		    for tmp in $deplibrary_names ; do
7061d5c3dbf1Smrg		      depdepl=$tmp
7062d5c3dbf1Smrg		    done
7063d5c3dbf1Smrg		    if test -f "$absdir/$objdir/$depdepl" ; then
7064d5c3dbf1Smrg		      depdepl="$absdir/$objdir/$depdepl"
7065d5c3dbf1Smrg		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
7066d5c3dbf1Smrg                      if test -z "$darwin_install_name"; then
7067d5c3dbf1Smrg                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
7068d5c3dbf1Smrg                      fi
7069cdbfa18aSmrg		      func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
7070cdbfa18aSmrg		      func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
7071d5c3dbf1Smrg		      path=
7072d5c3dbf1Smrg		    fi
7073d5c3dbf1Smrg		  fi
7074d5c3dbf1Smrg		  ;;
7075d5c3dbf1Smrg		*)
7076d5c3dbf1Smrg		  path="-L$absdir/$objdir"
7077d5c3dbf1Smrg		  ;;
7078d5c3dbf1Smrg		esac
7079d5c3dbf1Smrg		else
7080d5c3dbf1Smrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
7081d5c3dbf1Smrg		  test -z "$libdir" && \
7082d5c3dbf1Smrg		    func_fatal_error "\`$deplib' is not a valid libtool archive"
7083d5c3dbf1Smrg		  test "$absdir" != "$libdir" && \
7084d5c3dbf1Smrg		    func_warning "\`$deplib' seems to be moved"
7085d5c3dbf1Smrg
7086d5c3dbf1Smrg		  path="-L$absdir"
7087d5c3dbf1Smrg		fi
7088d5c3dbf1Smrg		;;
7089d5c3dbf1Smrg	      esac
7090d5c3dbf1Smrg	      case " $deplibs " in
7091d5c3dbf1Smrg	      *" $path "*) ;;
7092d5c3dbf1Smrg	      *) deplibs="$path $deplibs" ;;
7093d5c3dbf1Smrg	      esac
7094d5c3dbf1Smrg	    done
7095d5c3dbf1Smrg	  fi # link_all_deplibs != no
7096d5c3dbf1Smrg	fi # linkmode = lib
7097d5c3dbf1Smrg      done # for deplib in $libs
7098d5c3dbf1Smrg      if test "$pass" = link; then
7099d5c3dbf1Smrg	if test "$linkmode" = "prog"; then
7100d5c3dbf1Smrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
7101d5c3dbf1Smrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
7102d5c3dbf1Smrg	else
7103d5c3dbf1Smrg	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7104d5c3dbf1Smrg	fi
7105d5c3dbf1Smrg      fi
7106d5c3dbf1Smrg      dependency_libs="$newdependency_libs"
7107d5c3dbf1Smrg      if test "$pass" = dlpreopen; then
7108d5c3dbf1Smrg	# Link the dlpreopened libraries before other libraries
7109d5c3dbf1Smrg	for deplib in $save_deplibs; do
7110d5c3dbf1Smrg	  deplibs="$deplib $deplibs"
7111d5c3dbf1Smrg	done
7112d5c3dbf1Smrg      fi
7113d5c3dbf1Smrg      if test "$pass" != dlopen; then
7114d5c3dbf1Smrg	if test "$pass" != conv; then
7115d5c3dbf1Smrg	  # Make sure lib_search_path contains only unique directories.
7116d5c3dbf1Smrg	  lib_search_path=
7117d5c3dbf1Smrg	  for dir in $newlib_search_path; do
7118d5c3dbf1Smrg	    case "$lib_search_path " in
7119d5c3dbf1Smrg	    *" $dir "*) ;;
7120cdbfa18aSmrg	    *) func_append lib_search_path " $dir" ;;
7121d5c3dbf1Smrg	    esac
7122d5c3dbf1Smrg	  done
7123d5c3dbf1Smrg	  newlib_search_path=
7124d5c3dbf1Smrg	fi
7125d5c3dbf1Smrg
7126d5c3dbf1Smrg	if test "$linkmode,$pass" != "prog,link"; then
7127d5c3dbf1Smrg	  vars="deplibs"
7128d5c3dbf1Smrg	else
7129d5c3dbf1Smrg	  vars="compile_deplibs finalize_deplibs"
7130d5c3dbf1Smrg	fi
7131d5c3dbf1Smrg	for var in $vars dependency_libs; do
7132d5c3dbf1Smrg	  # Add libraries to $var in reverse order
7133d5c3dbf1Smrg	  eval tmp_libs=\"\$$var\"
7134d5c3dbf1Smrg	  new_libs=
7135d5c3dbf1Smrg	  for deplib in $tmp_libs; do
7136d5c3dbf1Smrg	    # FIXME: Pedantically, this is the right thing to do, so
7137d5c3dbf1Smrg	    #        that some nasty dependency loop isn't accidentally
7138d5c3dbf1Smrg	    #        broken:
7139d5c3dbf1Smrg	    #new_libs="$deplib $new_libs"
7140d5c3dbf1Smrg	    # Pragmatically, this seems to cause very few problems in
7141d5c3dbf1Smrg	    # practice:
7142d5c3dbf1Smrg	    case $deplib in
7143d5c3dbf1Smrg	    -L*) new_libs="$deplib $new_libs" ;;
7144d5c3dbf1Smrg	    -R*) ;;
7145d5c3dbf1Smrg	    *)
7146d5c3dbf1Smrg	      # And here is the reason: when a library appears more
7147d5c3dbf1Smrg	      # than once as an explicit dependence of a library, or
7148d5c3dbf1Smrg	      # is implicitly linked in more than once by the
7149d5c3dbf1Smrg	      # compiler, it is considered special, and multiple
7150d5c3dbf1Smrg	      # occurrences thereof are not removed.  Compare this
7151d5c3dbf1Smrg	      # with having the same library being listed as a
7152d5c3dbf1Smrg	      # dependency of multiple other libraries: in this case,
7153d5c3dbf1Smrg	      # we know (pedantically, we assume) the library does not
7154d5c3dbf1Smrg	      # need to be listed more than once, so we keep only the
7155d5c3dbf1Smrg	      # last copy.  This is not always right, but it is rare
7156d5c3dbf1Smrg	      # enough that we require users that really mean to play
7157d5c3dbf1Smrg	      # such unportable linking tricks to link the library
7158d5c3dbf1Smrg	      # using -Wl,-lname, so that libtool does not consider it
7159d5c3dbf1Smrg	      # for duplicate removal.
7160d5c3dbf1Smrg	      case " $specialdeplibs " in
7161d5c3dbf1Smrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
7162d5c3dbf1Smrg	      *)
7163d5c3dbf1Smrg		case " $new_libs " in
7164d5c3dbf1Smrg		*" $deplib "*) ;;
7165d5c3dbf1Smrg		*) new_libs="$deplib $new_libs" ;;
7166d5c3dbf1Smrg		esac
7167d5c3dbf1Smrg		;;
7168d5c3dbf1Smrg	      esac
7169d5c3dbf1Smrg	      ;;
7170d5c3dbf1Smrg	    esac
7171d5c3dbf1Smrg	  done
7172d5c3dbf1Smrg	  tmp_libs=
7173d5c3dbf1Smrg	  for deplib in $new_libs; do
7174d5c3dbf1Smrg	    case $deplib in
7175d5c3dbf1Smrg	    -L*)
7176d5c3dbf1Smrg	      case " $tmp_libs " in
7177d5c3dbf1Smrg	      *" $deplib "*) ;;
7178cdbfa18aSmrg	      *) func_append tmp_libs " $deplib" ;;
7179d5c3dbf1Smrg	      esac
7180d5c3dbf1Smrg	      ;;
7181cdbfa18aSmrg	    *) func_append tmp_libs " $deplib" ;;
7182d5c3dbf1Smrg	    esac
7183d5c3dbf1Smrg	  done
7184d5c3dbf1Smrg	  eval $var=\"$tmp_libs\"
7185d5c3dbf1Smrg	done # for var
7186d5c3dbf1Smrg      fi
7187d5c3dbf1Smrg      # Last step: remove runtime libs from dependency_libs
7188d5c3dbf1Smrg      # (they stay in deplibs)
7189d5c3dbf1Smrg      tmp_libs=
7190d5c3dbf1Smrg      for i in $dependency_libs ; do
7191d5c3dbf1Smrg	case " $predeps $postdeps $compiler_lib_search_path " in
7192d5c3dbf1Smrg	*" $i "*)
7193d5c3dbf1Smrg	  i=""
7194d5c3dbf1Smrg	  ;;
7195d5c3dbf1Smrg	esac
7196d5c3dbf1Smrg	if test -n "$i" ; then
7197cdbfa18aSmrg	  func_append tmp_libs " $i"
7198d5c3dbf1Smrg	fi
7199d5c3dbf1Smrg      done
7200d5c3dbf1Smrg      dependency_libs=$tmp_libs
7201d5c3dbf1Smrg    done # for pass
7202d5c3dbf1Smrg    if test "$linkmode" = prog; then
7203d5c3dbf1Smrg      dlfiles="$newdlfiles"
7204d5c3dbf1Smrg    fi
7205d5c3dbf1Smrg    if test "$linkmode" = prog || test "$linkmode" = lib; then
7206d5c3dbf1Smrg      dlprefiles="$newdlprefiles"
7207d5c3dbf1Smrg    fi
7208d5c3dbf1Smrg
7209d5c3dbf1Smrg    case $linkmode in
7210d5c3dbf1Smrg    oldlib)
7211d5c3dbf1Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
7212d5c3dbf1Smrg	func_warning "\`-dlopen' is ignored for archives"
7213d5c3dbf1Smrg      fi
7214d5c3dbf1Smrg
7215d5c3dbf1Smrg      case " $deplibs" in
7216d5c3dbf1Smrg      *\ -l* | *\ -L*)
7217d5c3dbf1Smrg	func_warning "\`-l' and \`-L' are ignored for archives" ;;
7218d5c3dbf1Smrg      esac
7219d5c3dbf1Smrg
7220d5c3dbf1Smrg      test -n "$rpath" && \
7221d5c3dbf1Smrg	func_warning "\`-rpath' is ignored for archives"
7222d5c3dbf1Smrg
7223d5c3dbf1Smrg      test -n "$xrpath" && \
7224d5c3dbf1Smrg	func_warning "\`-R' is ignored for archives"
7225d5c3dbf1Smrg
7226d5c3dbf1Smrg      test -n "$vinfo" && \
7227d5c3dbf1Smrg	func_warning "\`-version-info/-version-number' is ignored for archives"
7228d5c3dbf1Smrg
7229d5c3dbf1Smrg      test -n "$release" && \
7230d5c3dbf1Smrg	func_warning "\`-release' is ignored for archives"
7231d5c3dbf1Smrg
7232d5c3dbf1Smrg      test -n "$export_symbols$export_symbols_regex" && \
7233d5c3dbf1Smrg	func_warning "\`-export-symbols' is ignored for archives"
7234d5c3dbf1Smrg
7235d5c3dbf1Smrg      # Now set the variables for building old libraries.
7236d5c3dbf1Smrg      build_libtool_libs=no
7237d5c3dbf1Smrg      oldlibs="$output"
7238cdbfa18aSmrg      func_append objs "$old_deplibs"
7239d5c3dbf1Smrg      ;;
7240d5c3dbf1Smrg
7241d5c3dbf1Smrg    lib)
7242d5c3dbf1Smrg      # Make sure we only generate libraries of the form `libNAME.la'.
7243d5c3dbf1Smrg      case $outputname in
7244d5c3dbf1Smrg      lib*)
7245d5c3dbf1Smrg	func_stripname 'lib' '.la' "$outputname"
7246d5c3dbf1Smrg	name=$func_stripname_result
7247d5c3dbf1Smrg	eval shared_ext=\"$shrext_cmds\"
7248d5c3dbf1Smrg	eval libname=\"$libname_spec\"
7249d5c3dbf1Smrg	;;
7250d5c3dbf1Smrg      *)
7251d5c3dbf1Smrg	test "$module" = no && \
7252d5c3dbf1Smrg	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
7253d5c3dbf1Smrg
7254d5c3dbf1Smrg	if test "$need_lib_prefix" != no; then
7255d5c3dbf1Smrg	  # Add the "lib" prefix for modules if required
7256d5c3dbf1Smrg	  func_stripname '' '.la' "$outputname"
7257d5c3dbf1Smrg	  name=$func_stripname_result
7258d5c3dbf1Smrg	  eval shared_ext=\"$shrext_cmds\"
7259d5c3dbf1Smrg	  eval libname=\"$libname_spec\"
7260d5c3dbf1Smrg	else
7261d5c3dbf1Smrg	  func_stripname '' '.la' "$outputname"
7262d5c3dbf1Smrg	  libname=$func_stripname_result
7263d5c3dbf1Smrg	fi
7264d5c3dbf1Smrg	;;
7265d5c3dbf1Smrg      esac
7266d5c3dbf1Smrg
7267d5c3dbf1Smrg      if test -n "$objs"; then
7268d5c3dbf1Smrg	if test "$deplibs_check_method" != pass_all; then
7269d5c3dbf1Smrg	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
7270d5c3dbf1Smrg	else
7271d5c3dbf1Smrg	  echo
7272d5c3dbf1Smrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
7273d5c3dbf1Smrg	  $ECHO "*** objects $objs is not portable!"
7274cdbfa18aSmrg	  func_append libobjs " $objs"
7275d5c3dbf1Smrg	fi
7276d5c3dbf1Smrg      fi
7277d5c3dbf1Smrg
7278d5c3dbf1Smrg      test "$dlself" != no && \
7279d5c3dbf1Smrg	func_warning "\`-dlopen self' is ignored for libtool libraries"
7280d5c3dbf1Smrg
7281d5c3dbf1Smrg      set dummy $rpath
7282d5c3dbf1Smrg      shift
7283d5c3dbf1Smrg      test "$#" -gt 1 && \
7284d5c3dbf1Smrg	func_warning "ignoring multiple \`-rpath's for a libtool library"
7285d5c3dbf1Smrg
7286d5c3dbf1Smrg      install_libdir="$1"
7287d5c3dbf1Smrg
7288d5c3dbf1Smrg      oldlibs=
7289d5c3dbf1Smrg      if test -z "$rpath"; then
7290d5c3dbf1Smrg	if test "$build_libtool_libs" = yes; then
7291d5c3dbf1Smrg	  # Building a libtool convenience library.
7292d5c3dbf1Smrg	  # Some compilers have problems with a `.al' extension so
7293d5c3dbf1Smrg	  # convenience libraries should have the same extension an
7294d5c3dbf1Smrg	  # archive normally would.
7295d5c3dbf1Smrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
7296d5c3dbf1Smrg	  build_libtool_libs=convenience
7297d5c3dbf1Smrg	  build_old_libs=yes
7298d5c3dbf1Smrg	fi
7299d5c3dbf1Smrg
7300d5c3dbf1Smrg	test -n "$vinfo" && \
7301d5c3dbf1Smrg	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
7302d5c3dbf1Smrg
7303d5c3dbf1Smrg	test -n "$release" && \
7304d5c3dbf1Smrg	  func_warning "\`-release' is ignored for convenience libraries"
7305d5c3dbf1Smrg      else
7306d5c3dbf1Smrg
7307d5c3dbf1Smrg	# Parse the version information argument.
7308d5c3dbf1Smrg	save_ifs="$IFS"; IFS=':'
7309d5c3dbf1Smrg	set dummy $vinfo 0 0 0
7310d5c3dbf1Smrg	shift
7311d5c3dbf1Smrg	IFS="$save_ifs"
7312d5c3dbf1Smrg
7313d5c3dbf1Smrg	test -n "$7" && \
7314d5c3dbf1Smrg	  func_fatal_help "too many parameters to \`-version-info'"
7315d5c3dbf1Smrg
7316d5c3dbf1Smrg	# convert absolute version numbers to libtool ages
7317d5c3dbf1Smrg	# this retains compatibility with .la files and attempts
7318d5c3dbf1Smrg	# to make the code below a bit more comprehensible
7319d5c3dbf1Smrg
7320d5c3dbf1Smrg	case $vinfo_number in
7321d5c3dbf1Smrg	yes)
7322d5c3dbf1Smrg	  number_major="$1"
7323d5c3dbf1Smrg	  number_minor="$2"
7324d5c3dbf1Smrg	  number_revision="$3"
7325d5c3dbf1Smrg	  #
7326d5c3dbf1Smrg	  # There are really only two kinds -- those that
7327d5c3dbf1Smrg	  # use the current revision as the major version
7328d5c3dbf1Smrg	  # and those that subtract age and use age as
7329d5c3dbf1Smrg	  # a minor version.  But, then there is irix
7330d5c3dbf1Smrg	  # which has an extra 1 added just for fun
7331d5c3dbf1Smrg	  #
7332d5c3dbf1Smrg	  case $version_type in
7333cdbfa18aSmrg	  # correct linux to gnu/linux during the next big refactor
7334d5c3dbf1Smrg	  darwin|linux|osf|windows|none)
7335d5c3dbf1Smrg	    func_arith $number_major + $number_minor
7336d5c3dbf1Smrg	    current=$func_arith_result
7337d5c3dbf1Smrg	    age="$number_minor"
7338d5c3dbf1Smrg	    revision="$number_revision"
7339d5c3dbf1Smrg	    ;;
7340d5c3dbf1Smrg	  freebsd-aout|freebsd-elf|qnx|sunos)
7341d5c3dbf1Smrg	    current="$number_major"
7342d5c3dbf1Smrg	    revision="$number_minor"
7343d5c3dbf1Smrg	    age="0"
7344d5c3dbf1Smrg	    ;;
7345d5c3dbf1Smrg	  irix|nonstopux)
7346d5c3dbf1Smrg	    func_arith $number_major + $number_minor
7347d5c3dbf1Smrg	    current=$func_arith_result
7348d5c3dbf1Smrg	    age="$number_minor"
7349d5c3dbf1Smrg	    revision="$number_minor"
7350d5c3dbf1Smrg	    lt_irix_increment=no
7351d5c3dbf1Smrg	    ;;
7352d5c3dbf1Smrg	  esac
7353d5c3dbf1Smrg	  ;;
7354d5c3dbf1Smrg	no)
7355d5c3dbf1Smrg	  current="$1"
7356d5c3dbf1Smrg	  revision="$2"
7357d5c3dbf1Smrg	  age="$3"
7358d5c3dbf1Smrg	  ;;
7359d5c3dbf1Smrg	esac
7360d5c3dbf1Smrg
7361d5c3dbf1Smrg	# Check that each of the things are valid numbers.
7362d5c3dbf1Smrg	case $current in
7363d5c3dbf1Smrg	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]) ;;
7364d5c3dbf1Smrg	*)
7365d5c3dbf1Smrg	  func_error "CURRENT \`$current' must be a nonnegative integer"
7366d5c3dbf1Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
7367d5c3dbf1Smrg	  ;;
7368d5c3dbf1Smrg	esac
7369d5c3dbf1Smrg
7370d5c3dbf1Smrg	case $revision in
7371d5c3dbf1Smrg	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]) ;;
7372d5c3dbf1Smrg	*)
7373d5c3dbf1Smrg	  func_error "REVISION \`$revision' must be a nonnegative integer"
7374d5c3dbf1Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
7375d5c3dbf1Smrg	  ;;
7376d5c3dbf1Smrg	esac
7377d5c3dbf1Smrg
7378d5c3dbf1Smrg	case $age in
7379d5c3dbf1Smrg	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]) ;;
7380d5c3dbf1Smrg	*)
7381d5c3dbf1Smrg	  func_error "AGE \`$age' must be a nonnegative integer"
7382d5c3dbf1Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
7383d5c3dbf1Smrg	  ;;
7384d5c3dbf1Smrg	esac
7385d5c3dbf1Smrg
7386d5c3dbf1Smrg	if test "$age" -gt "$current"; then
7387d5c3dbf1Smrg	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
7388d5c3dbf1Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
7389d5c3dbf1Smrg	fi
7390d5c3dbf1Smrg
7391d5c3dbf1Smrg	# Calculate the version variables.
7392d5c3dbf1Smrg	major=
7393d5c3dbf1Smrg	versuffix=
7394d5c3dbf1Smrg	verstring=
7395d5c3dbf1Smrg	case $version_type in
7396d5c3dbf1Smrg	none) ;;
7397d5c3dbf1Smrg
7398d5c3dbf1Smrg	darwin)
7399d5c3dbf1Smrg	  # Like Linux, but with the current version available in
7400d5c3dbf1Smrg	  # verstring for coding it into the library header
7401d5c3dbf1Smrg	  func_arith $current - $age
7402d5c3dbf1Smrg	  major=.$func_arith_result
7403d5c3dbf1Smrg	  versuffix="$major.$age.$revision"
7404d5c3dbf1Smrg	  # Darwin ld doesn't like 0 for these options...
7405d5c3dbf1Smrg	  func_arith $current + 1
7406d5c3dbf1Smrg	  minor_current=$func_arith_result
7407d5c3dbf1Smrg	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
7408d5c3dbf1Smrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
7409d5c3dbf1Smrg	  ;;
7410d5c3dbf1Smrg
7411d5c3dbf1Smrg	freebsd-aout)
7412d5c3dbf1Smrg	  major=".$current"
7413d5c3dbf1Smrg	  versuffix=".$current.$revision";
7414d5c3dbf1Smrg	  ;;
7415d5c3dbf1Smrg
7416d5c3dbf1Smrg	freebsd-elf)
7417d5c3dbf1Smrg	  major=".$current"
7418d5c3dbf1Smrg	  versuffix=".$current"
7419d5c3dbf1Smrg	  ;;
7420d5c3dbf1Smrg
7421d5c3dbf1Smrg	irix | nonstopux)
7422d5c3dbf1Smrg	  if test "X$lt_irix_increment" = "Xno"; then
7423d5c3dbf1Smrg	    func_arith $current - $age
7424d5c3dbf1Smrg	  else
7425d5c3dbf1Smrg	    func_arith $current - $age + 1
7426d5c3dbf1Smrg	  fi
7427d5c3dbf1Smrg	  major=$func_arith_result
7428d5c3dbf1Smrg
7429d5c3dbf1Smrg	  case $version_type in
7430d5c3dbf1Smrg	    nonstopux) verstring_prefix=nonstopux ;;
7431d5c3dbf1Smrg	    *)         verstring_prefix=sgi ;;
7432d5c3dbf1Smrg	  esac
7433d5c3dbf1Smrg	  verstring="$verstring_prefix$major.$revision"
7434d5c3dbf1Smrg
7435d5c3dbf1Smrg	  # Add in all the interfaces that we are compatible with.
7436d5c3dbf1Smrg	  loop=$revision
7437d5c3dbf1Smrg	  while test "$loop" -ne 0; do
7438d5c3dbf1Smrg	    func_arith $revision - $loop
7439d5c3dbf1Smrg	    iface=$func_arith_result
7440d5c3dbf1Smrg	    func_arith $loop - 1
7441d5c3dbf1Smrg	    loop=$func_arith_result
7442d5c3dbf1Smrg	    verstring="$verstring_prefix$major.$iface:$verstring"
7443d5c3dbf1Smrg	  done
7444d5c3dbf1Smrg
7445d5c3dbf1Smrg	  # Before this point, $major must not contain `.'.
7446d5c3dbf1Smrg	  major=.$major
7447d5c3dbf1Smrg	  versuffix="$major.$revision"
7448d5c3dbf1Smrg	  ;;
7449d5c3dbf1Smrg
7450cdbfa18aSmrg	linux) # correct to gnu/linux during the next big refactor
7451d5c3dbf1Smrg	  func_arith $current - $age
7452d5c3dbf1Smrg	  major=.$func_arith_result
7453d5c3dbf1Smrg	  versuffix="$major.$age.$revision"
7454d5c3dbf1Smrg	  ;;
7455d5c3dbf1Smrg
7456d5c3dbf1Smrg	osf)
7457d5c3dbf1Smrg	  func_arith $current - $age
7458d5c3dbf1Smrg	  major=.$func_arith_result
7459d5c3dbf1Smrg	  versuffix=".$current.$age.$revision"
7460d5c3dbf1Smrg	  verstring="$current.$age.$revision"
7461d5c3dbf1Smrg
7462d5c3dbf1Smrg	  # Add in all the interfaces that we are compatible with.
7463d5c3dbf1Smrg	  loop=$age
7464d5c3dbf1Smrg	  while test "$loop" -ne 0; do
7465d5c3dbf1Smrg	    func_arith $current - $loop
7466d5c3dbf1Smrg	    iface=$func_arith_result
7467d5c3dbf1Smrg	    func_arith $loop - 1
7468d5c3dbf1Smrg	    loop=$func_arith_result
7469d5c3dbf1Smrg	    verstring="$verstring:${iface}.0"
7470d5c3dbf1Smrg	  done
7471d5c3dbf1Smrg
7472d5c3dbf1Smrg	  # Make executables depend on our current version.
7473cdbfa18aSmrg	  func_append verstring ":${current}.0"
7474d5c3dbf1Smrg	  ;;
7475d5c3dbf1Smrg
7476d5c3dbf1Smrg	qnx)
7477d5c3dbf1Smrg	  major=".$current"
7478d5c3dbf1Smrg	  versuffix=".$current"
7479d5c3dbf1Smrg	  ;;
7480d5c3dbf1Smrg
7481d5c3dbf1Smrg	sunos)
7482d5c3dbf1Smrg	  major=".$current"
7483d5c3dbf1Smrg	  versuffix=".$current.$revision"
7484d5c3dbf1Smrg	  ;;
7485d5c3dbf1Smrg
7486d5c3dbf1Smrg	windows)
7487d5c3dbf1Smrg	  # Use '-' rather than '.', since we only want one
7488d5c3dbf1Smrg	  # extension on DOS 8.3 filesystems.
7489d5c3dbf1Smrg	  func_arith $current - $age
7490d5c3dbf1Smrg	  major=$func_arith_result
7491d5c3dbf1Smrg	  versuffix="-$major"
7492d5c3dbf1Smrg	  ;;
7493d5c3dbf1Smrg
7494d5c3dbf1Smrg	*)
7495d5c3dbf1Smrg	  func_fatal_configuration "unknown library version type \`$version_type'"
7496d5c3dbf1Smrg	  ;;
7497d5c3dbf1Smrg	esac
7498d5c3dbf1Smrg
7499d5c3dbf1Smrg	# Clear the version info if we defaulted, and they specified a release.
7500d5c3dbf1Smrg	if test -z "$vinfo" && test -n "$release"; then
7501d5c3dbf1Smrg	  major=
7502d5c3dbf1Smrg	  case $version_type in
7503d5c3dbf1Smrg	  darwin)
7504d5c3dbf1Smrg	    # we can't check for "0.0" in archive_cmds due to quoting
7505d5c3dbf1Smrg	    # problems, so we reset it completely
7506d5c3dbf1Smrg	    verstring=
7507d5c3dbf1Smrg	    ;;
7508d5c3dbf1Smrg	  *)
7509d5c3dbf1Smrg	    verstring="0.0"
7510d5c3dbf1Smrg	    ;;
7511d5c3dbf1Smrg	  esac
7512d5c3dbf1Smrg	  if test "$need_version" = no; then
7513d5c3dbf1Smrg	    versuffix=
7514d5c3dbf1Smrg	  else
7515d5c3dbf1Smrg	    versuffix=".0.0"
7516d5c3dbf1Smrg	  fi
7517d5c3dbf1Smrg	fi
7518d5c3dbf1Smrg
7519d5c3dbf1Smrg	# Remove version info from name if versioning should be avoided
7520d5c3dbf1Smrg	if test "$avoid_version" = yes && test "$need_version" = no; then
7521d5c3dbf1Smrg	  major=
7522d5c3dbf1Smrg	  versuffix=
7523d5c3dbf1Smrg	  verstring=""
7524d5c3dbf1Smrg	fi
7525d5c3dbf1Smrg
7526d5c3dbf1Smrg	# Check to see if the archive will have undefined symbols.
7527d5c3dbf1Smrg	if test "$allow_undefined" = yes; then
7528d5c3dbf1Smrg	  if test "$allow_undefined_flag" = unsupported; then
7529d5c3dbf1Smrg	    func_warning "undefined symbols not allowed in $host shared libraries"
7530d5c3dbf1Smrg	    build_libtool_libs=no
7531d5c3dbf1Smrg	    build_old_libs=yes
7532d5c3dbf1Smrg	  fi
7533d5c3dbf1Smrg	else
7534d5c3dbf1Smrg	  # Don't allow undefined symbols.
7535d5c3dbf1Smrg	  allow_undefined_flag="$no_undefined_flag"
7536d5c3dbf1Smrg	fi
7537d5c3dbf1Smrg
7538d5c3dbf1Smrg      fi
7539d5c3dbf1Smrg
7540d5c3dbf1Smrg      func_generate_dlsyms "$libname" "$libname" "yes"
7541cdbfa18aSmrg      func_append libobjs " $symfileobj"
7542d5c3dbf1Smrg      test "X$libobjs" = "X " && libobjs=
7543d5c3dbf1Smrg
7544cdbfa18aSmrg      if test "$opt_mode" != relink; then
7545d5c3dbf1Smrg	# Remove our outputs, but don't remove object files since they
7546d5c3dbf1Smrg	# may have been created when compiling PIC objects.
7547d5c3dbf1Smrg	removelist=
7548d5c3dbf1Smrg	tempremovelist=`$ECHO "$output_objdir/*"`
7549d5c3dbf1Smrg	for p in $tempremovelist; do
7550d5c3dbf1Smrg	  case $p in
7551d5c3dbf1Smrg	    *.$objext | *.gcno)
7552d5c3dbf1Smrg	       ;;
7553d5c3dbf1Smrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
7554d5c3dbf1Smrg	       if test "X$precious_files_regex" != "X"; then
7555d5c3dbf1Smrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
7556d5c3dbf1Smrg		 then
7557d5c3dbf1Smrg		   continue
7558d5c3dbf1Smrg		 fi
7559d5c3dbf1Smrg	       fi
7560cdbfa18aSmrg	       func_append removelist " $p"
7561d5c3dbf1Smrg	       ;;
7562d5c3dbf1Smrg	    *) ;;
7563d5c3dbf1Smrg	  esac
7564d5c3dbf1Smrg	done
7565d5c3dbf1Smrg	test -n "$removelist" && \
7566d5c3dbf1Smrg	  func_show_eval "${RM}r \$removelist"
7567d5c3dbf1Smrg      fi
7568d5c3dbf1Smrg
7569d5c3dbf1Smrg      # Now set the variables for building old libraries.
7570d5c3dbf1Smrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
7571cdbfa18aSmrg	func_append oldlibs " $output_objdir/$libname.$libext"
7572d5c3dbf1Smrg
7573d5c3dbf1Smrg	# Transform .lo files to .o files.
7574d5c3dbf1Smrg	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
7575d5c3dbf1Smrg      fi
7576d5c3dbf1Smrg
7577d5c3dbf1Smrg      # Eliminate all temporary directories.
7578d5c3dbf1Smrg      #for path in $notinst_path; do
7579d5c3dbf1Smrg      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
7580d5c3dbf1Smrg      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
7581d5c3dbf1Smrg      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
7582d5c3dbf1Smrg      #done
7583d5c3dbf1Smrg
7584d5c3dbf1Smrg      if test -n "$xrpath"; then
7585d5c3dbf1Smrg	# If the user specified any rpath flags, then add them.
7586d5c3dbf1Smrg	temp_xrpath=
7587d5c3dbf1Smrg	for libdir in $xrpath; do
7588cdbfa18aSmrg	  func_replace_sysroot "$libdir"
7589cdbfa18aSmrg	  func_append temp_xrpath " -R$func_replace_sysroot_result"
7590d5c3dbf1Smrg	  case "$finalize_rpath " in
7591d5c3dbf1Smrg	  *" $libdir "*) ;;
7592cdbfa18aSmrg	  *) func_append finalize_rpath " $libdir" ;;
7593d5c3dbf1Smrg	  esac
7594d5c3dbf1Smrg	done
7595d5c3dbf1Smrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
7596d5c3dbf1Smrg	  dependency_libs="$temp_xrpath $dependency_libs"
7597d5c3dbf1Smrg	fi
7598d5c3dbf1Smrg      fi
7599d5c3dbf1Smrg
7600d5c3dbf1Smrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
7601d5c3dbf1Smrg      old_dlfiles="$dlfiles"
7602d5c3dbf1Smrg      dlfiles=
7603d5c3dbf1Smrg      for lib in $old_dlfiles; do
7604d5c3dbf1Smrg	case " $dlprefiles $dlfiles " in
7605d5c3dbf1Smrg	*" $lib "*) ;;
7606cdbfa18aSmrg	*) func_append dlfiles " $lib" ;;
7607d5c3dbf1Smrg	esac
7608d5c3dbf1Smrg      done
7609d5c3dbf1Smrg
7610d5c3dbf1Smrg      # Make sure dlprefiles contains only unique files
7611d5c3dbf1Smrg      old_dlprefiles="$dlprefiles"
7612d5c3dbf1Smrg      dlprefiles=
7613d5c3dbf1Smrg      for lib in $old_dlprefiles; do
7614d5c3dbf1Smrg	case "$dlprefiles " in
7615d5c3dbf1Smrg	*" $lib "*) ;;
7616cdbfa18aSmrg	*) func_append dlprefiles " $lib" ;;
7617d5c3dbf1Smrg	esac
7618d5c3dbf1Smrg      done
7619d5c3dbf1Smrg
7620d5c3dbf1Smrg      if test "$build_libtool_libs" = yes; then
7621d5c3dbf1Smrg	if test -n "$rpath"; then
7622d5c3dbf1Smrg	  case $host in
7623d5c3dbf1Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
7624d5c3dbf1Smrg	    # these systems don't actually have a c library (as such)!
7625d5c3dbf1Smrg	    ;;
7626d5c3dbf1Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
7627d5c3dbf1Smrg	    # Rhapsody C library is in the System framework
7628cdbfa18aSmrg	    func_append deplibs " System.ltframework"
7629d5c3dbf1Smrg	    ;;
7630d5c3dbf1Smrg	  *-*-netbsd*)
7631d5c3dbf1Smrg	    # Don't link with libc until the a.out ld.so is fixed.
7632d5c3dbf1Smrg	    ;;
7633d5c3dbf1Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
7634d5c3dbf1Smrg	    # Do not include libc due to us having libc/libc_r.
7635d5c3dbf1Smrg	    ;;
7636d5c3dbf1Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
7637d5c3dbf1Smrg	    # Causes problems with __ctype
7638d5c3dbf1Smrg	    ;;
7639d5c3dbf1Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
7640d5c3dbf1Smrg	    # Compiler inserts libc in the correct place for threads to work
7641d5c3dbf1Smrg	    ;;
7642d5c3dbf1Smrg	  *)
7643d5c3dbf1Smrg	    # Add libc to deplibs on all other systems if necessary.
7644d5c3dbf1Smrg	    if test "$build_libtool_need_lc" = "yes"; then
7645cdbfa18aSmrg	      func_append deplibs " -lc"
7646d5c3dbf1Smrg	    fi
7647d5c3dbf1Smrg	    ;;
7648d5c3dbf1Smrg	  esac
7649d5c3dbf1Smrg	fi
7650d5c3dbf1Smrg
7651d5c3dbf1Smrg	# Transform deplibs into only deplibs that can be linked in shared.
7652d5c3dbf1Smrg	name_save=$name
7653d5c3dbf1Smrg	libname_save=$libname
7654d5c3dbf1Smrg	release_save=$release
7655d5c3dbf1Smrg	versuffix_save=$versuffix
7656d5c3dbf1Smrg	major_save=$major
7657d5c3dbf1Smrg	# I'm not sure if I'm treating the release correctly.  I think
7658d5c3dbf1Smrg	# release should show up in the -l (ie -lgmp5) so we don't want to
7659d5c3dbf1Smrg	# add it in twice.  Is that correct?
7660d5c3dbf1Smrg	release=""
7661d5c3dbf1Smrg	versuffix=""
7662d5c3dbf1Smrg	major=""
7663d5c3dbf1Smrg	newdeplibs=
7664d5c3dbf1Smrg	droppeddeps=no
7665d5c3dbf1Smrg	case $deplibs_check_method in
7666d5c3dbf1Smrg	pass_all)
7667d5c3dbf1Smrg	  # Don't check for shared/static.  Everything works.
7668d5c3dbf1Smrg	  # This might be a little naive.  We might want to check
7669d5c3dbf1Smrg	  # whether the library exists or not.  But this is on
7670d5c3dbf1Smrg	  # osf3 & osf4 and I'm not really sure... Just
7671d5c3dbf1Smrg	  # implementing what was already the behavior.
7672d5c3dbf1Smrg	  newdeplibs=$deplibs
7673d5c3dbf1Smrg	  ;;
7674d5c3dbf1Smrg	test_compile)
7675d5c3dbf1Smrg	  # This code stresses the "libraries are programs" paradigm to its
7676d5c3dbf1Smrg	  # limits. Maybe even breaks it.  We compile a program, linking it
7677d5c3dbf1Smrg	  # against the deplibs as a proxy for the library.  Then we can check
7678d5c3dbf1Smrg	  # whether they linked in statically or dynamically with ldd.
7679d5c3dbf1Smrg	  $opt_dry_run || $RM conftest.c
7680d5c3dbf1Smrg	  cat > conftest.c <<EOF
7681d5c3dbf1Smrg	  int main() { return 0; }
7682d5c3dbf1SmrgEOF
7683d5c3dbf1Smrg	  $opt_dry_run || $RM conftest
7684d5c3dbf1Smrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
7685d5c3dbf1Smrg	    ldd_output=`ldd conftest`
7686d5c3dbf1Smrg	    for i in $deplibs; do
7687d5c3dbf1Smrg	      case $i in
7688d5c3dbf1Smrg	      -l*)
7689d5c3dbf1Smrg		func_stripname -l '' "$i"
7690d5c3dbf1Smrg		name=$func_stripname_result
7691d5c3dbf1Smrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7692d5c3dbf1Smrg		  case " $predeps $postdeps " in
7693d5c3dbf1Smrg		  *" $i "*)
7694cdbfa18aSmrg		    func_append newdeplibs " $i"
7695d5c3dbf1Smrg		    i=""
7696d5c3dbf1Smrg		    ;;
7697d5c3dbf1Smrg		  esac
7698d5c3dbf1Smrg		fi
7699d5c3dbf1Smrg		if test -n "$i" ; then
7700d5c3dbf1Smrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
7701d5c3dbf1Smrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
7702d5c3dbf1Smrg		  set dummy $deplib_matches; shift
7703d5c3dbf1Smrg		  deplib_match=$1
7704d5c3dbf1Smrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7705cdbfa18aSmrg		    func_append newdeplibs " $i"
7706d5c3dbf1Smrg		  else
7707d5c3dbf1Smrg		    droppeddeps=yes
7708d5c3dbf1Smrg		    echo
7709d5c3dbf1Smrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
7710d5c3dbf1Smrg		    echo "*** I have the capability to make that library automatically link in when"
7711d5c3dbf1Smrg		    echo "*** you link to this library.  But I can only do this if you have a"
7712d5c3dbf1Smrg		    echo "*** shared version of the library, which I believe you do not have"
7713d5c3dbf1Smrg		    echo "*** because a test_compile did reveal that the linker did not use it for"
7714d5c3dbf1Smrg		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
7715d5c3dbf1Smrg		  fi
7716d5c3dbf1Smrg		fi
7717d5c3dbf1Smrg		;;
7718d5c3dbf1Smrg	      *)
7719cdbfa18aSmrg		func_append newdeplibs " $i"
7720d5c3dbf1Smrg		;;
7721d5c3dbf1Smrg	      esac
7722d5c3dbf1Smrg	    done
7723d5c3dbf1Smrg	  else
7724d5c3dbf1Smrg	    # Error occurred in the first compile.  Let's try to salvage
7725d5c3dbf1Smrg	    # the situation: Compile a separate program for each library.
7726d5c3dbf1Smrg	    for i in $deplibs; do
7727d5c3dbf1Smrg	      case $i in
7728d5c3dbf1Smrg	      -l*)
7729d5c3dbf1Smrg		func_stripname -l '' "$i"
7730d5c3dbf1Smrg		name=$func_stripname_result
7731d5c3dbf1Smrg		$opt_dry_run || $RM conftest
7732d5c3dbf1Smrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
7733d5c3dbf1Smrg		  ldd_output=`ldd conftest`
7734d5c3dbf1Smrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7735d5c3dbf1Smrg		    case " $predeps $postdeps " in
7736d5c3dbf1Smrg		    *" $i "*)
7737cdbfa18aSmrg		      func_append newdeplibs " $i"
7738d5c3dbf1Smrg		      i=""
7739d5c3dbf1Smrg		      ;;
7740d5c3dbf1Smrg		    esac
7741d5c3dbf1Smrg		  fi
7742d5c3dbf1Smrg		  if test -n "$i" ; then
7743d5c3dbf1Smrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
7744d5c3dbf1Smrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
7745d5c3dbf1Smrg		    set dummy $deplib_matches; shift
7746d5c3dbf1Smrg		    deplib_match=$1
7747d5c3dbf1Smrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7748cdbfa18aSmrg		      func_append newdeplibs " $i"
7749d5c3dbf1Smrg		    else
7750d5c3dbf1Smrg		      droppeddeps=yes
7751d5c3dbf1Smrg		      echo
7752d5c3dbf1Smrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
7753d5c3dbf1Smrg		      echo "*** I have the capability to make that library automatically link in when"
7754d5c3dbf1Smrg		      echo "*** you link to this library.  But I can only do this if you have a"
7755d5c3dbf1Smrg		      echo "*** shared version of the library, which you do not appear to have"
7756d5c3dbf1Smrg		      echo "*** because a test_compile did reveal that the linker did not use this one"
7757d5c3dbf1Smrg		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
7758d5c3dbf1Smrg		    fi
7759d5c3dbf1Smrg		  fi
7760d5c3dbf1Smrg		else
7761d5c3dbf1Smrg		  droppeddeps=yes
7762d5c3dbf1Smrg		  echo
7763d5c3dbf1Smrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
7764d5c3dbf1Smrg		  echo "*** make it link in!  You will probably need to install it or some"
7765d5c3dbf1Smrg		  echo "*** library that it depends on before this library will be fully"
7766d5c3dbf1Smrg		  echo "*** functional.  Installing it before continuing would be even better."
7767d5c3dbf1Smrg		fi
7768d5c3dbf1Smrg		;;
7769d5c3dbf1Smrg	      *)
7770cdbfa18aSmrg		func_append newdeplibs " $i"
7771d5c3dbf1Smrg		;;
7772d5c3dbf1Smrg	      esac
7773d5c3dbf1Smrg	    done
7774d5c3dbf1Smrg	  fi
7775d5c3dbf1Smrg	  ;;
7776d5c3dbf1Smrg	file_magic*)
7777d5c3dbf1Smrg	  set dummy $deplibs_check_method; shift
7778d5c3dbf1Smrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7779d5c3dbf1Smrg	  for a_deplib in $deplibs; do
7780d5c3dbf1Smrg	    case $a_deplib in
7781d5c3dbf1Smrg	    -l*)
7782d5c3dbf1Smrg	      func_stripname -l '' "$a_deplib"
7783d5c3dbf1Smrg	      name=$func_stripname_result
7784d5c3dbf1Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7785d5c3dbf1Smrg		case " $predeps $postdeps " in
7786d5c3dbf1Smrg		*" $a_deplib "*)
7787cdbfa18aSmrg		  func_append newdeplibs " $a_deplib"
7788d5c3dbf1Smrg		  a_deplib=""
7789d5c3dbf1Smrg		  ;;
7790d5c3dbf1Smrg		esac
7791d5c3dbf1Smrg	      fi
7792d5c3dbf1Smrg	      if test -n "$a_deplib" ; then
7793d5c3dbf1Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
7794cdbfa18aSmrg		if test -n "$file_magic_glob"; then
7795cdbfa18aSmrg		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
7796cdbfa18aSmrg		else
7797cdbfa18aSmrg		  libnameglob=$libname
7798cdbfa18aSmrg		fi
7799cdbfa18aSmrg		test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
7800d5c3dbf1Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7801cdbfa18aSmrg		  if test "$want_nocaseglob" = yes; then
7802cdbfa18aSmrg		    shopt -s nocaseglob
7803cdbfa18aSmrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7804cdbfa18aSmrg		    $nocaseglob
7805cdbfa18aSmrg		  else
7806cdbfa18aSmrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7807cdbfa18aSmrg		  fi
7808d5c3dbf1Smrg		  for potent_lib in $potential_libs; do
7809d5c3dbf1Smrg		      # Follow soft links.
7810d5c3dbf1Smrg		      if ls -lLd "$potent_lib" 2>/dev/null |
7811d5c3dbf1Smrg			 $GREP " -> " >/dev/null; then
7812d5c3dbf1Smrg			continue
7813d5c3dbf1Smrg		      fi
7814d5c3dbf1Smrg		      # The statement above tries to avoid entering an
7815d5c3dbf1Smrg		      # endless loop below, in case of cyclic links.
7816d5c3dbf1Smrg		      # We might still enter an endless loop, since a link
7817d5c3dbf1Smrg		      # loop can be closed while we follow links,
7818d5c3dbf1Smrg		      # but so what?
7819d5c3dbf1Smrg		      potlib="$potent_lib"
7820d5c3dbf1Smrg		      while test -h "$potlib" 2>/dev/null; do
7821d5c3dbf1Smrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
7822d5c3dbf1Smrg			case $potliblink in
7823d5c3dbf1Smrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
7824d5c3dbf1Smrg			*) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
7825d5c3dbf1Smrg			esac
7826d5c3dbf1Smrg		      done
7827d5c3dbf1Smrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
7828d5c3dbf1Smrg			 $SED -e 10q |
7829d5c3dbf1Smrg			 $EGREP "$file_magic_regex" > /dev/null; then
7830cdbfa18aSmrg			func_append newdeplibs " $a_deplib"
7831d5c3dbf1Smrg			a_deplib=""
7832d5c3dbf1Smrg			break 2
7833d5c3dbf1Smrg		      fi
7834d5c3dbf1Smrg		  done
7835d5c3dbf1Smrg		done
7836d5c3dbf1Smrg	      fi
7837d5c3dbf1Smrg	      if test -n "$a_deplib" ; then
7838d5c3dbf1Smrg		droppeddeps=yes
7839d5c3dbf1Smrg		echo
7840d5c3dbf1Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
7841d5c3dbf1Smrg		echo "*** I have the capability to make that library automatically link in when"
7842d5c3dbf1Smrg		echo "*** you link to this library.  But I can only do this if you have a"
7843d5c3dbf1Smrg		echo "*** shared version of the library, which you do not appear to have"
7844d5c3dbf1Smrg		echo "*** because I did check the linker path looking for a file starting"
7845d5c3dbf1Smrg		if test -z "$potlib" ; then
7846d5c3dbf1Smrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
7847d5c3dbf1Smrg		else
7848d5c3dbf1Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
7849d5c3dbf1Smrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
7850d5c3dbf1Smrg		fi
7851d5c3dbf1Smrg	      fi
7852d5c3dbf1Smrg	      ;;
7853d5c3dbf1Smrg	    *)
7854d5c3dbf1Smrg	      # Add a -L argument.
7855cdbfa18aSmrg	      func_append newdeplibs " $a_deplib"
7856d5c3dbf1Smrg	      ;;
7857d5c3dbf1Smrg	    esac
7858d5c3dbf1Smrg	  done # Gone through all deplibs.
7859d5c3dbf1Smrg	  ;;
7860d5c3dbf1Smrg	match_pattern*)
7861d5c3dbf1Smrg	  set dummy $deplibs_check_method; shift
7862d5c3dbf1Smrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7863d5c3dbf1Smrg	  for a_deplib in $deplibs; do
7864d5c3dbf1Smrg	    case $a_deplib in
7865d5c3dbf1Smrg	    -l*)
7866d5c3dbf1Smrg	      func_stripname -l '' "$a_deplib"
7867d5c3dbf1Smrg	      name=$func_stripname_result
7868d5c3dbf1Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7869d5c3dbf1Smrg		case " $predeps $postdeps " in
7870d5c3dbf1Smrg		*" $a_deplib "*)
7871cdbfa18aSmrg		  func_append newdeplibs " $a_deplib"
7872d5c3dbf1Smrg		  a_deplib=""
7873d5c3dbf1Smrg		  ;;
7874d5c3dbf1Smrg		esac
7875d5c3dbf1Smrg	      fi
7876d5c3dbf1Smrg	      if test -n "$a_deplib" ; then
7877d5c3dbf1Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
7878d5c3dbf1Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7879d5c3dbf1Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
7880d5c3dbf1Smrg		  for potent_lib in $potential_libs; do
7881d5c3dbf1Smrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
7882d5c3dbf1Smrg		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
7883d5c3dbf1Smrg		       $EGREP "$match_pattern_regex" > /dev/null; then
7884cdbfa18aSmrg		      func_append newdeplibs " $a_deplib"
7885d5c3dbf1Smrg		      a_deplib=""
7886d5c3dbf1Smrg		      break 2
7887d5c3dbf1Smrg		    fi
7888d5c3dbf1Smrg		  done
7889d5c3dbf1Smrg		done
7890d5c3dbf1Smrg	      fi
7891d5c3dbf1Smrg	      if test -n "$a_deplib" ; then
7892d5c3dbf1Smrg		droppeddeps=yes
7893d5c3dbf1Smrg		echo
7894d5c3dbf1Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
7895d5c3dbf1Smrg		echo "*** I have the capability to make that library automatically link in when"
7896d5c3dbf1Smrg		echo "*** you link to this library.  But I can only do this if you have a"
7897d5c3dbf1Smrg		echo "*** shared version of the library, which you do not appear to have"
7898d5c3dbf1Smrg		echo "*** because I did check the linker path looking for a file starting"
7899d5c3dbf1Smrg		if test -z "$potlib" ; then
7900d5c3dbf1Smrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
7901d5c3dbf1Smrg		else
7902d5c3dbf1Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
7903d5c3dbf1Smrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
7904d5c3dbf1Smrg		fi
7905d5c3dbf1Smrg	      fi
7906d5c3dbf1Smrg	      ;;
7907d5c3dbf1Smrg	    *)
7908d5c3dbf1Smrg	      # Add a -L argument.
7909cdbfa18aSmrg	      func_append newdeplibs " $a_deplib"
7910d5c3dbf1Smrg	      ;;
7911d5c3dbf1Smrg	    esac
7912d5c3dbf1Smrg	  done # Gone through all deplibs.
7913d5c3dbf1Smrg	  ;;
7914d5c3dbf1Smrg	none | unknown | *)
7915d5c3dbf1Smrg	  newdeplibs=""
7916d5c3dbf1Smrg	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
7917d5c3dbf1Smrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7918d5c3dbf1Smrg	    for i in $predeps $postdeps ; do
7919d5c3dbf1Smrg	      # can't use Xsed below, because $i might contain '/'
7920d5c3dbf1Smrg	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
7921d5c3dbf1Smrg	    done
7922d5c3dbf1Smrg	  fi
7923d5c3dbf1Smrg	  case $tmp_deplibs in
7924d5c3dbf1Smrg	  *[!\	\ ]*)
7925d5c3dbf1Smrg	    echo
7926d5c3dbf1Smrg	    if test "X$deplibs_check_method" = "Xnone"; then
7927d5c3dbf1Smrg	      echo "*** Warning: inter-library dependencies are not supported in this platform."
7928d5c3dbf1Smrg	    else
7929d5c3dbf1Smrg	      echo "*** Warning: inter-library dependencies are not known to be supported."
7930d5c3dbf1Smrg	    fi
7931d5c3dbf1Smrg	    echo "*** All declared inter-library dependencies are being dropped."
7932d5c3dbf1Smrg	    droppeddeps=yes
7933d5c3dbf1Smrg	    ;;
7934d5c3dbf1Smrg	  esac
7935d5c3dbf1Smrg	  ;;
7936d5c3dbf1Smrg	esac
7937d5c3dbf1Smrg	versuffix=$versuffix_save
7938d5c3dbf1Smrg	major=$major_save
7939d5c3dbf1Smrg	release=$release_save
7940d5c3dbf1Smrg	libname=$libname_save
7941d5c3dbf1Smrg	name=$name_save
7942d5c3dbf1Smrg
7943d5c3dbf1Smrg	case $host in
7944d5c3dbf1Smrg	*-*-rhapsody* | *-*-darwin1.[012])
7945d5c3dbf1Smrg	  # On Rhapsody replace the C library with the System framework
7946d5c3dbf1Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
7947d5c3dbf1Smrg	  ;;
7948d5c3dbf1Smrg	esac
7949d5c3dbf1Smrg
7950d5c3dbf1Smrg	if test "$droppeddeps" = yes; then
7951d5c3dbf1Smrg	  if test "$module" = yes; then
7952d5c3dbf1Smrg	    echo
7953d5c3dbf1Smrg	    echo "*** Warning: libtool could not satisfy all declared inter-library"
7954d5c3dbf1Smrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
7955d5c3dbf1Smrg	    echo "*** a static module, that should work as long as the dlopening"
7956d5c3dbf1Smrg	    echo "*** application is linked with the -dlopen flag."
7957d5c3dbf1Smrg	    if test -z "$global_symbol_pipe"; then
7958d5c3dbf1Smrg	      echo
7959d5c3dbf1Smrg	      echo "*** However, this would only work if libtool was able to extract symbol"
7960d5c3dbf1Smrg	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
7961d5c3dbf1Smrg	      echo "*** not find such a program.  So, this module is probably useless."
7962d5c3dbf1Smrg	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
7963d5c3dbf1Smrg	    fi
7964d5c3dbf1Smrg	    if test "$build_old_libs" = no; then
7965d5c3dbf1Smrg	      oldlibs="$output_objdir/$libname.$libext"
7966d5c3dbf1Smrg	      build_libtool_libs=module
7967d5c3dbf1Smrg	      build_old_libs=yes
7968d5c3dbf1Smrg	    else
7969d5c3dbf1Smrg	      build_libtool_libs=no
7970d5c3dbf1Smrg	    fi
7971d5c3dbf1Smrg	  else
7972d5c3dbf1Smrg	    echo "*** The inter-library dependencies that have been dropped here will be"
7973d5c3dbf1Smrg	    echo "*** automatically added whenever a program is linked with this library"
7974d5c3dbf1Smrg	    echo "*** or is declared to -dlopen it."
7975d5c3dbf1Smrg
7976d5c3dbf1Smrg	    if test "$allow_undefined" = no; then
7977d5c3dbf1Smrg	      echo
7978d5c3dbf1Smrg	      echo "*** Since this library must not contain undefined symbols,"
7979d5c3dbf1Smrg	      echo "*** because either the platform does not support them or"
7980d5c3dbf1Smrg	      echo "*** it was explicitly requested with -no-undefined,"
7981d5c3dbf1Smrg	      echo "*** libtool will only create a static version of it."
7982d5c3dbf1Smrg	      if test "$build_old_libs" = no; then
7983d5c3dbf1Smrg		oldlibs="$output_objdir/$libname.$libext"
7984d5c3dbf1Smrg		build_libtool_libs=module
7985d5c3dbf1Smrg		build_old_libs=yes
7986d5c3dbf1Smrg	      else
7987d5c3dbf1Smrg		build_libtool_libs=no
7988d5c3dbf1Smrg	      fi
7989d5c3dbf1Smrg	    fi
7990d5c3dbf1Smrg	  fi
7991d5c3dbf1Smrg	fi
7992d5c3dbf1Smrg	# Done checking deplibs!
7993d5c3dbf1Smrg	deplibs=$newdeplibs
7994d5c3dbf1Smrg      fi
7995d5c3dbf1Smrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
7996d5c3dbf1Smrg      case $host in
7997d5c3dbf1Smrg	*-*-darwin*)
7998d5c3dbf1Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7999d5c3dbf1Smrg	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8000d5c3dbf1Smrg	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8001d5c3dbf1Smrg	  ;;
8002d5c3dbf1Smrg      esac
8003d5c3dbf1Smrg
8004d5c3dbf1Smrg      # move library search paths that coincide with paths to not yet
8005d5c3dbf1Smrg      # installed libraries to the beginning of the library search list
8006d5c3dbf1Smrg      new_libs=
8007d5c3dbf1Smrg      for path in $notinst_path; do
8008d5c3dbf1Smrg	case " $new_libs " in
8009d5c3dbf1Smrg	*" -L$path/$objdir "*) ;;
8010d5c3dbf1Smrg	*)
8011d5c3dbf1Smrg	  case " $deplibs " in
8012d5c3dbf1Smrg	  *" -L$path/$objdir "*)
8013cdbfa18aSmrg	    func_append new_libs " -L$path/$objdir" ;;
8014d5c3dbf1Smrg	  esac
8015d5c3dbf1Smrg	  ;;
8016d5c3dbf1Smrg	esac
8017d5c3dbf1Smrg      done
8018d5c3dbf1Smrg      for deplib in $deplibs; do
8019d5c3dbf1Smrg	case $deplib in
8020d5c3dbf1Smrg	-L*)
8021d5c3dbf1Smrg	  case " $new_libs " in
8022d5c3dbf1Smrg	  *" $deplib "*) ;;
8023cdbfa18aSmrg	  *) func_append new_libs " $deplib" ;;
8024d5c3dbf1Smrg	  esac
8025d5c3dbf1Smrg	  ;;
8026cdbfa18aSmrg	*) func_append new_libs " $deplib" ;;
8027d5c3dbf1Smrg	esac
8028d5c3dbf1Smrg      done
8029d5c3dbf1Smrg      deplibs="$new_libs"
8030d5c3dbf1Smrg
8031d5c3dbf1Smrg      # All the library-specific variables (install_libdir is set above).
8032d5c3dbf1Smrg      library_names=
8033d5c3dbf1Smrg      old_library=
8034d5c3dbf1Smrg      dlname=
8035d5c3dbf1Smrg
8036d5c3dbf1Smrg      # Test again, we may have decided not to build it any more
8037d5c3dbf1Smrg      if test "$build_libtool_libs" = yes; then
8038cdbfa18aSmrg	# Remove ${wl} instances when linking with ld.
8039cdbfa18aSmrg	# FIXME: should test the right _cmds variable.
8040cdbfa18aSmrg	case $archive_cmds in
8041cdbfa18aSmrg	  *\$LD\ *) wl= ;;
8042cdbfa18aSmrg        esac
8043d5c3dbf1Smrg	if test "$hardcode_into_libs" = yes; then
8044d5c3dbf1Smrg	  # Hardcode the library paths
8045d5c3dbf1Smrg	  hardcode_libdirs=
8046d5c3dbf1Smrg	  dep_rpath=
8047d5c3dbf1Smrg	  rpath="$finalize_rpath"
8048cdbfa18aSmrg	  test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
8049d5c3dbf1Smrg	  for libdir in $rpath; do
8050d5c3dbf1Smrg	    if test -n "$hardcode_libdir_flag_spec"; then
8051d5c3dbf1Smrg	      if test -n "$hardcode_libdir_separator"; then
8052cdbfa18aSmrg		func_replace_sysroot "$libdir"
8053cdbfa18aSmrg		libdir=$func_replace_sysroot_result
8054d5c3dbf1Smrg		if test -z "$hardcode_libdirs"; then
8055d5c3dbf1Smrg		  hardcode_libdirs="$libdir"
8056d5c3dbf1Smrg		else
8057d5c3dbf1Smrg		  # Just accumulate the unique libdirs.
8058d5c3dbf1Smrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8059d5c3dbf1Smrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8060d5c3dbf1Smrg		    ;;
8061d5c3dbf1Smrg		  *)
8062cdbfa18aSmrg		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8063d5c3dbf1Smrg		    ;;
8064d5c3dbf1Smrg		  esac
8065d5c3dbf1Smrg		fi
8066d5c3dbf1Smrg	      else
8067d5c3dbf1Smrg		eval flag=\"$hardcode_libdir_flag_spec\"
8068cdbfa18aSmrg		func_append dep_rpath " $flag"
8069d5c3dbf1Smrg	      fi
8070d5c3dbf1Smrg	    elif test -n "$runpath_var"; then
8071d5c3dbf1Smrg	      case "$perm_rpath " in
8072d5c3dbf1Smrg	      *" $libdir "*) ;;
8073cdbfa18aSmrg	      *) func_append perm_rpath " $libdir" ;;
8074d5c3dbf1Smrg	      esac
8075d5c3dbf1Smrg	    fi
8076d5c3dbf1Smrg	  done
8077d5c3dbf1Smrg	  # Substitute the hardcoded libdirs into the rpath.
8078d5c3dbf1Smrg	  if test -n "$hardcode_libdir_separator" &&
8079d5c3dbf1Smrg	     test -n "$hardcode_libdirs"; then
8080d5c3dbf1Smrg	    libdir="$hardcode_libdirs"
8081cdbfa18aSmrg	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
8082d5c3dbf1Smrg	  fi
8083d5c3dbf1Smrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
8084d5c3dbf1Smrg	    # We should set the runpath_var.
8085d5c3dbf1Smrg	    rpath=
8086d5c3dbf1Smrg	    for dir in $perm_rpath; do
8087cdbfa18aSmrg	      func_append rpath "$dir:"
8088d5c3dbf1Smrg	    done
8089d5c3dbf1Smrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
8090d5c3dbf1Smrg	  fi
8091d5c3dbf1Smrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
8092d5c3dbf1Smrg	fi
80939f606849Smrg
8094d5c3dbf1Smrg	shlibpath="$finalize_shlibpath"
8095cdbfa18aSmrg	test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
8096d5c3dbf1Smrg	if test -n "$shlibpath"; then
8097d5c3dbf1Smrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
8098d5c3dbf1Smrg	fi
80999f606849Smrg
8100d5c3dbf1Smrg	# Get the real and link names of the library.
8101d5c3dbf1Smrg	eval shared_ext=\"$shrext_cmds\"
8102d5c3dbf1Smrg	eval library_names=\"$library_names_spec\"
8103d5c3dbf1Smrg	set dummy $library_names
8104d5c3dbf1Smrg	shift
8105d5c3dbf1Smrg	realname="$1"
8106d5c3dbf1Smrg	shift
81079f606849Smrg
8108d5c3dbf1Smrg	if test -n "$soname_spec"; then
8109d5c3dbf1Smrg	  eval soname=\"$soname_spec\"
8110d5c3dbf1Smrg	else
8111d5c3dbf1Smrg	  soname="$realname"
8112d5c3dbf1Smrg	fi
8113d5c3dbf1Smrg	if test -z "$dlname"; then
8114d5c3dbf1Smrg	  dlname=$soname
8115d5c3dbf1Smrg	fi
81169f606849Smrg
8117d5c3dbf1Smrg	lib="$output_objdir/$realname"
8118d5c3dbf1Smrg	linknames=
8119d5c3dbf1Smrg	for link
8120d5c3dbf1Smrg	do
8121cdbfa18aSmrg	  func_append linknames " $link"
8122d5c3dbf1Smrg	done
81239f606849Smrg
8124d5c3dbf1Smrg	# Use standard objects if they are pic
8125d5c3dbf1Smrg	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
8126d5c3dbf1Smrg	test "X$libobjs" = "X " && libobjs=
81279f606849Smrg
8128d5c3dbf1Smrg	delfiles=
8129d5c3dbf1Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
8130d5c3dbf1Smrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
8131d5c3dbf1Smrg	  export_symbols="$output_objdir/$libname.uexp"
8132cdbfa18aSmrg	  func_append delfiles " $export_symbols"
8133d5c3dbf1Smrg	fi
81349f606849Smrg
8135d5c3dbf1Smrg	orig_export_symbols=
8136d5c3dbf1Smrg	case $host_os in
8137d5c3dbf1Smrg	cygwin* | mingw* | cegcc*)
8138d5c3dbf1Smrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
8139d5c3dbf1Smrg	    # exporting using user supplied symfile
8140d5c3dbf1Smrg	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
8141d5c3dbf1Smrg	      # and it's NOT already a .def file. Must figure out
8142d5c3dbf1Smrg	      # which of the given symbols are data symbols and tag
8143d5c3dbf1Smrg	      # them as such. So, trigger use of export_symbols_cmds.
8144d5c3dbf1Smrg	      # export_symbols gets reassigned inside the "prepare
8145d5c3dbf1Smrg	      # the list of exported symbols" if statement, so the
8146d5c3dbf1Smrg	      # include_expsyms logic still works.
8147d5c3dbf1Smrg	      orig_export_symbols="$export_symbols"
8148d5c3dbf1Smrg	      export_symbols=
8149d5c3dbf1Smrg	      always_export_symbols=yes
8150d5c3dbf1Smrg	    fi
8151d5c3dbf1Smrg	  fi
8152d5c3dbf1Smrg	  ;;
8153d5c3dbf1Smrg	esac
81549f606849Smrg
8155d5c3dbf1Smrg	# Prepare the list of exported symbols
8156d5c3dbf1Smrg	if test -z "$export_symbols"; then
8157d5c3dbf1Smrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
8158d5c3dbf1Smrg	    func_verbose "generating symbol list for \`$libname.la'"
8159d5c3dbf1Smrg	    export_symbols="$output_objdir/$libname.exp"
8160d5c3dbf1Smrg	    $opt_dry_run || $RM $export_symbols
8161d5c3dbf1Smrg	    cmds=$export_symbols_cmds
8162d5c3dbf1Smrg	    save_ifs="$IFS"; IFS='~'
8163cdbfa18aSmrg	    for cmd1 in $cmds; do
8164d5c3dbf1Smrg	      IFS="$save_ifs"
8165cdbfa18aSmrg	      # Take the normal branch if the nm_file_list_spec branch
8166cdbfa18aSmrg	      # doesn't work or if tool conversion is not needed.
8167cdbfa18aSmrg	      case $nm_file_list_spec~$to_tool_file_cmd in
8168cdbfa18aSmrg		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
8169cdbfa18aSmrg		  try_normal_branch=yes
8170cdbfa18aSmrg		  eval cmd=\"$cmd1\"
8171cdbfa18aSmrg		  func_len " $cmd"
8172cdbfa18aSmrg		  len=$func_len_result
8173cdbfa18aSmrg		  ;;
8174cdbfa18aSmrg		*)
8175cdbfa18aSmrg		  try_normal_branch=no
8176cdbfa18aSmrg		  ;;
8177cdbfa18aSmrg	      esac
8178cdbfa18aSmrg	      if test "$try_normal_branch" = yes \
8179cdbfa18aSmrg		 && { test "$len" -lt "$max_cmd_len" \
8180cdbfa18aSmrg		      || test "$max_cmd_len" -le -1; }
8181cdbfa18aSmrg	      then
8182cdbfa18aSmrg		func_show_eval "$cmd" 'exit $?'
8183cdbfa18aSmrg		skipped_export=false
8184cdbfa18aSmrg	      elif test -n "$nm_file_list_spec"; then
8185cdbfa18aSmrg		func_basename "$output"
8186cdbfa18aSmrg		output_la=$func_basename_result
8187cdbfa18aSmrg		save_libobjs=$libobjs
8188cdbfa18aSmrg		save_output=$output
8189cdbfa18aSmrg		output=${output_objdir}/${output_la}.nm
8190cdbfa18aSmrg		func_to_tool_file "$output"
8191cdbfa18aSmrg		libobjs=$nm_file_list_spec$func_to_tool_file_result
8192cdbfa18aSmrg		func_append delfiles " $output"
8193cdbfa18aSmrg		func_verbose "creating $NM input file list: $output"
8194cdbfa18aSmrg		for obj in $save_libobjs; do
8195cdbfa18aSmrg		  func_to_tool_file "$obj"
8196cdbfa18aSmrg		  $ECHO "$func_to_tool_file_result"
8197cdbfa18aSmrg		done > "$output"
8198cdbfa18aSmrg		eval cmd=\"$cmd1\"
8199d5c3dbf1Smrg		func_show_eval "$cmd" 'exit $?'
8200cdbfa18aSmrg		output=$save_output
8201cdbfa18aSmrg		libobjs=$save_libobjs
8202d5c3dbf1Smrg		skipped_export=false
8203d5c3dbf1Smrg	      else
8204d5c3dbf1Smrg		# The command line is too long to execute in one step.
8205d5c3dbf1Smrg		func_verbose "using reloadable object file for export list..."
8206d5c3dbf1Smrg		skipped_export=:
8207d5c3dbf1Smrg		# Break out early, otherwise skipped_export may be
8208d5c3dbf1Smrg		# set to false by a later but shorter cmd.
8209d5c3dbf1Smrg		break
8210d5c3dbf1Smrg	      fi
8211d5c3dbf1Smrg	    done
8212d5c3dbf1Smrg	    IFS="$save_ifs"
8213d5c3dbf1Smrg	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
8214d5c3dbf1Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8215d5c3dbf1Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8216d5c3dbf1Smrg	    fi
8217d5c3dbf1Smrg	  fi
8218d5c3dbf1Smrg	fi
82199f606849Smrg
8220d5c3dbf1Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
8221d5c3dbf1Smrg	  tmp_export_symbols="$export_symbols"
8222d5c3dbf1Smrg	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
8223d5c3dbf1Smrg	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8224d5c3dbf1Smrg	fi
82259f606849Smrg
8226d5c3dbf1Smrg	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
8227d5c3dbf1Smrg	  # The given exports_symbols file has to be filtered, so filter it.
8228d5c3dbf1Smrg	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8229d5c3dbf1Smrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
8230d5c3dbf1Smrg	  # 's' commands which not all seds can handle. GNU sed should be fine
8231d5c3dbf1Smrg	  # though. Also, the filter scales superlinearly with the number of
8232d5c3dbf1Smrg	  # global variables. join(1) would be nice here, but unfortunately
8233d5c3dbf1Smrg	  # isn't a blessed tool.
8234d5c3dbf1Smrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8235cdbfa18aSmrg	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
8236d5c3dbf1Smrg	  export_symbols=$output_objdir/$libname.def
8237d5c3dbf1Smrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
82389f606849Smrg	fi
82399f606849Smrg
8240d5c3dbf1Smrg	tmp_deplibs=
8241d5c3dbf1Smrg	for test_deplib in $deplibs; do
8242d5c3dbf1Smrg	  case " $convenience " in
8243d5c3dbf1Smrg	  *" $test_deplib "*) ;;
8244d5c3dbf1Smrg	  *)
8245cdbfa18aSmrg	    func_append tmp_deplibs " $test_deplib"
8246d5c3dbf1Smrg	    ;;
8247d5c3dbf1Smrg	  esac
8248d5c3dbf1Smrg	done
8249d5c3dbf1Smrg	deplibs="$tmp_deplibs"
82509f606849Smrg
8251d5c3dbf1Smrg	if test -n "$convenience"; then
8252d5c3dbf1Smrg	  if test -n "$whole_archive_flag_spec" &&
8253d5c3dbf1Smrg	    test "$compiler_needs_object" = yes &&
8254d5c3dbf1Smrg	    test -z "$libobjs"; then
8255d5c3dbf1Smrg	    # extract the archives, so we have objects to list.
8256d5c3dbf1Smrg	    # TODO: could optimize this to just extract one archive.
8257d5c3dbf1Smrg	    whole_archive_flag_spec=
8258d5c3dbf1Smrg	  fi
8259d5c3dbf1Smrg	  if test -n "$whole_archive_flag_spec"; then
8260d5c3dbf1Smrg	    save_libobjs=$libobjs
8261d5c3dbf1Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8262d5c3dbf1Smrg	    test "X$libobjs" = "X " && libobjs=
8263d5c3dbf1Smrg	  else
8264d5c3dbf1Smrg	    gentop="$output_objdir/${outputname}x"
8265cdbfa18aSmrg	    func_append generated " $gentop"
82669f606849Smrg
8267d5c3dbf1Smrg	    func_extract_archives $gentop $convenience
8268cdbfa18aSmrg	    func_append libobjs " $func_extract_archives_result"
8269d5c3dbf1Smrg	    test "X$libobjs" = "X " && libobjs=
8270d5c3dbf1Smrg	  fi
8271d5c3dbf1Smrg	fi
82729f606849Smrg
8273d5c3dbf1Smrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
8274d5c3dbf1Smrg	  eval flag=\"$thread_safe_flag_spec\"
8275cdbfa18aSmrg	  func_append linker_flags " $flag"
8276d5c3dbf1Smrg	fi
82779f606849Smrg
8278d5c3dbf1Smrg	# Make a backup of the uninstalled library when relinking
8279cdbfa18aSmrg	if test "$opt_mode" = relink; then
8280d5c3dbf1Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
82819f606849Smrg	fi
82829f606849Smrg
8283d5c3dbf1Smrg	# Do each of the archive commands.
8284d5c3dbf1Smrg	if test "$module" = yes && test -n "$module_cmds" ; then
8285d5c3dbf1Smrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8286d5c3dbf1Smrg	    eval test_cmds=\"$module_expsym_cmds\"
8287d5c3dbf1Smrg	    cmds=$module_expsym_cmds
8288d5c3dbf1Smrg	  else
8289d5c3dbf1Smrg	    eval test_cmds=\"$module_cmds\"
8290d5c3dbf1Smrg	    cmds=$module_cmds
8291d5c3dbf1Smrg	  fi
8292d5c3dbf1Smrg	else
8293d5c3dbf1Smrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8294d5c3dbf1Smrg	    eval test_cmds=\"$archive_expsym_cmds\"
8295d5c3dbf1Smrg	    cmds=$archive_expsym_cmds
8296d5c3dbf1Smrg	  else
8297d5c3dbf1Smrg	    eval test_cmds=\"$archive_cmds\"
8298d5c3dbf1Smrg	    cmds=$archive_cmds
8299d5c3dbf1Smrg	  fi
83009f606849Smrg	fi
83019f606849Smrg
8302d5c3dbf1Smrg	if test "X$skipped_export" != "X:" &&
8303d5c3dbf1Smrg	   func_len " $test_cmds" &&
8304d5c3dbf1Smrg	   len=$func_len_result &&
8305d5c3dbf1Smrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
8306d5c3dbf1Smrg	  :
8307d5c3dbf1Smrg	else
8308d5c3dbf1Smrg	  # The command line is too long to link in one step, link piecewise
8309d5c3dbf1Smrg	  # or, if using GNU ld and skipped_export is not :, use a linker
8310d5c3dbf1Smrg	  # script.
83119f606849Smrg
8312d5c3dbf1Smrg	  # Save the value of $output and $libobjs because we want to
8313d5c3dbf1Smrg	  # use them later.  If we have whole_archive_flag_spec, we
8314d5c3dbf1Smrg	  # want to use save_libobjs as it was before
8315d5c3dbf1Smrg	  # whole_archive_flag_spec was expanded, because we can't
8316d5c3dbf1Smrg	  # assume the linker understands whole_archive_flag_spec.
8317d5c3dbf1Smrg	  # This may have to be revisited, in case too many
8318d5c3dbf1Smrg	  # convenience libraries get linked in and end up exceeding
8319d5c3dbf1Smrg	  # the spec.
8320d5c3dbf1Smrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
8321d5c3dbf1Smrg	    save_libobjs=$libobjs
8322d5c3dbf1Smrg	  fi
8323d5c3dbf1Smrg	  save_output=$output
8324d5c3dbf1Smrg	  func_basename "$output"
8325d5c3dbf1Smrg	  output_la=$func_basename_result
83269f606849Smrg
8327d5c3dbf1Smrg	  # Clear the reloadable object creation command queue and
8328d5c3dbf1Smrg	  # initialize k to one.
8329d5c3dbf1Smrg	  test_cmds=
8330d5c3dbf1Smrg	  concat_cmds=
8331d5c3dbf1Smrg	  objlist=
8332d5c3dbf1Smrg	  last_robj=
8333d5c3dbf1Smrg	  k=1
83349f606849Smrg
8335d5c3dbf1Smrg	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
8336d5c3dbf1Smrg	    output=${output_objdir}/${output_la}.lnkscript
8337d5c3dbf1Smrg	    func_verbose "creating GNU ld script: $output"
8338d5c3dbf1Smrg	    echo 'INPUT (' > $output
8339d5c3dbf1Smrg	    for obj in $save_libobjs
8340d5c3dbf1Smrg	    do
8341cdbfa18aSmrg	      func_to_tool_file "$obj"
8342cdbfa18aSmrg	      $ECHO "$func_to_tool_file_result" >> $output
8343d5c3dbf1Smrg	    done
8344d5c3dbf1Smrg	    echo ')' >> $output
8345cdbfa18aSmrg	    func_append delfiles " $output"
8346cdbfa18aSmrg	    func_to_tool_file "$output"
8347cdbfa18aSmrg	    output=$func_to_tool_file_result
8348d5c3dbf1Smrg	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
8349d5c3dbf1Smrg	    output=${output_objdir}/${output_la}.lnk
8350d5c3dbf1Smrg	    func_verbose "creating linker input file list: $output"
8351d5c3dbf1Smrg	    : > $output
8352d5c3dbf1Smrg	    set x $save_libobjs
8353d5c3dbf1Smrg	    shift
8354d5c3dbf1Smrg	    firstobj=
8355d5c3dbf1Smrg	    if test "$compiler_needs_object" = yes; then
8356d5c3dbf1Smrg	      firstobj="$1 "
8357d5c3dbf1Smrg	      shift
8358d5c3dbf1Smrg	    fi
8359d5c3dbf1Smrg	    for obj
8360d5c3dbf1Smrg	    do
8361cdbfa18aSmrg	      func_to_tool_file "$obj"
8362cdbfa18aSmrg	      $ECHO "$func_to_tool_file_result" >> $output
8363d5c3dbf1Smrg	    done
8364cdbfa18aSmrg	    func_append delfiles " $output"
8365cdbfa18aSmrg	    func_to_tool_file "$output"
8366cdbfa18aSmrg	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
8367d5c3dbf1Smrg	  else
8368d5c3dbf1Smrg	    if test -n "$save_libobjs"; then
8369d5c3dbf1Smrg	      func_verbose "creating reloadable object files..."
8370d5c3dbf1Smrg	      output=$output_objdir/$output_la-${k}.$objext
8371d5c3dbf1Smrg	      eval test_cmds=\"$reload_cmds\"
8372d5c3dbf1Smrg	      func_len " $test_cmds"
8373d5c3dbf1Smrg	      len0=$func_len_result
8374d5c3dbf1Smrg	      len=$len0
8375d5c3dbf1Smrg
8376d5c3dbf1Smrg	      # Loop over the list of objects to be linked.
8377d5c3dbf1Smrg	      for obj in $save_libobjs
8378d5c3dbf1Smrg	      do
8379d5c3dbf1Smrg		func_len " $obj"
8380d5c3dbf1Smrg		func_arith $len + $func_len_result
8381d5c3dbf1Smrg		len=$func_arith_result
8382d5c3dbf1Smrg		if test "X$objlist" = X ||
8383d5c3dbf1Smrg		   test "$len" -lt "$max_cmd_len"; then
8384d5c3dbf1Smrg		  func_append objlist " $obj"
8385d5c3dbf1Smrg		else
8386d5c3dbf1Smrg		  # The command $test_cmds is almost too long, add a
8387d5c3dbf1Smrg		  # command to the queue.
8388d5c3dbf1Smrg		  if test "$k" -eq 1 ; then
8389d5c3dbf1Smrg		    # The first file doesn't have a previous command to add.
8390d5c3dbf1Smrg		    reload_objs=$objlist
8391d5c3dbf1Smrg		    eval concat_cmds=\"$reload_cmds\"
8392d5c3dbf1Smrg		  else
8393d5c3dbf1Smrg		    # All subsequent reloadable object files will link in
8394d5c3dbf1Smrg		    # the last one created.
8395d5c3dbf1Smrg		    reload_objs="$objlist $last_robj"
8396d5c3dbf1Smrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
8397d5c3dbf1Smrg		  fi
8398d5c3dbf1Smrg		  last_robj=$output_objdir/$output_la-${k}.$objext
8399d5c3dbf1Smrg		  func_arith $k + 1
8400d5c3dbf1Smrg		  k=$func_arith_result
8401d5c3dbf1Smrg		  output=$output_objdir/$output_la-${k}.$objext
8402d5c3dbf1Smrg		  objlist=" $obj"
8403d5c3dbf1Smrg		  func_len " $last_robj"
8404d5c3dbf1Smrg		  func_arith $len0 + $func_len_result
8405d5c3dbf1Smrg		  len=$func_arith_result
8406d5c3dbf1Smrg		fi
8407d5c3dbf1Smrg	      done
8408d5c3dbf1Smrg	      # Handle the remaining objects by creating one last
8409d5c3dbf1Smrg	      # reloadable object file.  All subsequent reloadable object
8410d5c3dbf1Smrg	      # files will link in the last one created.
8411d5c3dbf1Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8412d5c3dbf1Smrg	      reload_objs="$objlist $last_robj"
8413d5c3dbf1Smrg	      eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
8414d5c3dbf1Smrg	      if test -n "$last_robj"; then
8415d5c3dbf1Smrg	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
8416d5c3dbf1Smrg	      fi
8417cdbfa18aSmrg	      func_append delfiles " $output"
8418d5c3dbf1Smrg
8419d5c3dbf1Smrg	    else
8420d5c3dbf1Smrg	      output=
8421d5c3dbf1Smrg	    fi
84229f606849Smrg
8423d5c3dbf1Smrg	    if ${skipped_export-false}; then
8424d5c3dbf1Smrg	      func_verbose "generating symbol list for \`$libname.la'"
8425d5c3dbf1Smrg	      export_symbols="$output_objdir/$libname.exp"
8426d5c3dbf1Smrg	      $opt_dry_run || $RM $export_symbols
8427d5c3dbf1Smrg	      libobjs=$output
8428d5c3dbf1Smrg	      # Append the command to create the export file.
8429d5c3dbf1Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8430d5c3dbf1Smrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
8431d5c3dbf1Smrg	      if test -n "$last_robj"; then
8432d5c3dbf1Smrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
8433d5c3dbf1Smrg	      fi
8434d5c3dbf1Smrg	    fi
84359f606849Smrg
8436d5c3dbf1Smrg	    test -n "$save_libobjs" &&
8437d5c3dbf1Smrg	      func_verbose "creating a temporary reloadable object file: $output"
84389f606849Smrg
8439d5c3dbf1Smrg	    # Loop through the commands generated above and execute them.
8440d5c3dbf1Smrg	    save_ifs="$IFS"; IFS='~'
8441d5c3dbf1Smrg	    for cmd in $concat_cmds; do
8442d5c3dbf1Smrg	      IFS="$save_ifs"
8443d5c3dbf1Smrg	      $opt_silent || {
8444d5c3dbf1Smrg		  func_quote_for_expand "$cmd"
8445d5c3dbf1Smrg		  eval "func_echo $func_quote_for_expand_result"
8446d5c3dbf1Smrg	      }
8447d5c3dbf1Smrg	      $opt_dry_run || eval "$cmd" || {
8448d5c3dbf1Smrg		lt_exit=$?
8449d5c3dbf1Smrg
8450d5c3dbf1Smrg		# Restore the uninstalled library and exit
8451cdbfa18aSmrg		if test "$opt_mode" = relink; then
8452d5c3dbf1Smrg		  ( cd "$output_objdir" && \
8453d5c3dbf1Smrg		    $RM "${realname}T" && \
8454d5c3dbf1Smrg		    $MV "${realname}U" "$realname" )
8455d5c3dbf1Smrg		fi
84569f606849Smrg
8457d5c3dbf1Smrg		exit $lt_exit
8458d5c3dbf1Smrg	      }
8459d5c3dbf1Smrg	    done
8460d5c3dbf1Smrg	    IFS="$save_ifs"
84619f606849Smrg
8462d5c3dbf1Smrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
8463d5c3dbf1Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8464d5c3dbf1Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
84659f606849Smrg	    fi
84669f606849Smrg	  fi
84679f606849Smrg
8468d5c3dbf1Smrg          if ${skipped_export-false}; then
8469d5c3dbf1Smrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
8470d5c3dbf1Smrg	      tmp_export_symbols="$export_symbols"
8471d5c3dbf1Smrg	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
8472d5c3dbf1Smrg	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8473d5c3dbf1Smrg	    fi
84749f606849Smrg
8475d5c3dbf1Smrg	    if test -n "$orig_export_symbols"; then
8476d5c3dbf1Smrg	      # The given exports_symbols file has to be filtered, so filter it.
8477d5c3dbf1Smrg	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8478d5c3dbf1Smrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
8479d5c3dbf1Smrg	      # 's' commands which not all seds can handle. GNU sed should be fine
8480d5c3dbf1Smrg	      # though. Also, the filter scales superlinearly with the number of
8481d5c3dbf1Smrg	      # global variables. join(1) would be nice here, but unfortunately
8482d5c3dbf1Smrg	      # isn't a blessed tool.
8483d5c3dbf1Smrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8484cdbfa18aSmrg	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
8485d5c3dbf1Smrg	      export_symbols=$output_objdir/$libname.def
8486d5c3dbf1Smrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
8487d5c3dbf1Smrg	    fi
8488d5c3dbf1Smrg	  fi
84899f606849Smrg
8490d5c3dbf1Smrg	  libobjs=$output
8491d5c3dbf1Smrg	  # Restore the value of output.
8492d5c3dbf1Smrg	  output=$save_output
84939f606849Smrg
8494d5c3dbf1Smrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
8495d5c3dbf1Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8496d5c3dbf1Smrg	    test "X$libobjs" = "X " && libobjs=
8497d5c3dbf1Smrg	  fi
8498d5c3dbf1Smrg	  # Expand the library linking commands again to reset the
8499d5c3dbf1Smrg	  # value of $libobjs for piecewise linking.
8500d5c3dbf1Smrg
8501d5c3dbf1Smrg	  # Do each of the archive commands.
8502d5c3dbf1Smrg	  if test "$module" = yes && test -n "$module_cmds" ; then
8503d5c3dbf1Smrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8504d5c3dbf1Smrg	      cmds=$module_expsym_cmds
85059f606849Smrg	    else
8506d5c3dbf1Smrg	      cmds=$module_cmds
85079f606849Smrg	    fi
85089f606849Smrg	  else
8509d5c3dbf1Smrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8510d5c3dbf1Smrg	      cmds=$archive_expsym_cmds
8511d5c3dbf1Smrg	    else
8512d5c3dbf1Smrg	      cmds=$archive_cmds
8513d5c3dbf1Smrg	    fi
85149f606849Smrg	  fi
85159f606849Smrg	fi
85169f606849Smrg
8517d5c3dbf1Smrg	if test -n "$delfiles"; then
8518d5c3dbf1Smrg	  # Append the command to remove temporary files to $cmds.
8519d5c3dbf1Smrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
8520d5c3dbf1Smrg	fi
85219f606849Smrg
8522d5c3dbf1Smrg	# Add any objects from preloaded convenience libraries
8523d5c3dbf1Smrg	if test -n "$dlprefiles"; then
8524d5c3dbf1Smrg	  gentop="$output_objdir/${outputname}x"
8525cdbfa18aSmrg	  func_append generated " $gentop"
85269f606849Smrg
8527d5c3dbf1Smrg	  func_extract_archives $gentop $dlprefiles
8528cdbfa18aSmrg	  func_append libobjs " $func_extract_archives_result"
8529d5c3dbf1Smrg	  test "X$libobjs" = "X " && libobjs=
85309f606849Smrg	fi
85319f606849Smrg
8532d5c3dbf1Smrg	save_ifs="$IFS"; IFS='~'
8533d5c3dbf1Smrg	for cmd in $cmds; do
8534d5c3dbf1Smrg	  IFS="$save_ifs"
8535d5c3dbf1Smrg	  eval cmd=\"$cmd\"
8536d5c3dbf1Smrg	  $opt_silent || {
8537d5c3dbf1Smrg	    func_quote_for_expand "$cmd"
8538d5c3dbf1Smrg	    eval "func_echo $func_quote_for_expand_result"
8539d5c3dbf1Smrg	  }
8540d5c3dbf1Smrg	  $opt_dry_run || eval "$cmd" || {
8541d5c3dbf1Smrg	    lt_exit=$?
85429f606849Smrg
8543d5c3dbf1Smrg	    # Restore the uninstalled library and exit
8544cdbfa18aSmrg	    if test "$opt_mode" = relink; then
8545d5c3dbf1Smrg	      ( cd "$output_objdir" && \
8546d5c3dbf1Smrg	        $RM "${realname}T" && \
8547d5c3dbf1Smrg		$MV "${realname}U" "$realname" )
85489f606849Smrg	    fi
85499f606849Smrg
8550d5c3dbf1Smrg	    exit $lt_exit
8551d5c3dbf1Smrg	  }
8552d5c3dbf1Smrg	done
8553d5c3dbf1Smrg	IFS="$save_ifs"
85549f606849Smrg
8555d5c3dbf1Smrg	# Restore the uninstalled library and exit
8556cdbfa18aSmrg	if test "$opt_mode" = relink; then
8557d5c3dbf1Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
85589f606849Smrg
8559d5c3dbf1Smrg	  if test -n "$convenience"; then
8560d5c3dbf1Smrg	    if test -z "$whole_archive_flag_spec"; then
8561d5c3dbf1Smrg	      func_show_eval '${RM}r "$gentop"'
8562d5c3dbf1Smrg	    fi
8563d5c3dbf1Smrg	  fi
85649f606849Smrg
8565d5c3dbf1Smrg	  exit $EXIT_SUCCESS
8566d5c3dbf1Smrg	fi
85679f606849Smrg
8568d5c3dbf1Smrg	# Create links to the real library.
8569d5c3dbf1Smrg	for linkname in $linknames; do
8570d5c3dbf1Smrg	  if test "$realname" != "$linkname"; then
8571d5c3dbf1Smrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
8572d5c3dbf1Smrg	  fi
8573d5c3dbf1Smrg	done
85749f606849Smrg
8575d5c3dbf1Smrg	# If -module or -export-dynamic was specified, set the dlname.
8576d5c3dbf1Smrg	if test "$module" = yes || test "$export_dynamic" = yes; then
8577d5c3dbf1Smrg	  # On all known operating systems, these are identical.
8578d5c3dbf1Smrg	  dlname="$soname"
8579d5c3dbf1Smrg	fi
8580d5c3dbf1Smrg      fi
8581d5c3dbf1Smrg      ;;
85829f606849Smrg
8583d5c3dbf1Smrg    obj)
8584d5c3dbf1Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
8585d5c3dbf1Smrg	func_warning "\`-dlopen' is ignored for objects"
8586d5c3dbf1Smrg      fi
85879f606849Smrg
8588d5c3dbf1Smrg      case " $deplibs" in
8589d5c3dbf1Smrg      *\ -l* | *\ -L*)
8590d5c3dbf1Smrg	func_warning "\`-l' and \`-L' are ignored for objects" ;;
8591d5c3dbf1Smrg      esac
85929f606849Smrg
8593d5c3dbf1Smrg      test -n "$rpath" && \
8594d5c3dbf1Smrg	func_warning "\`-rpath' is ignored for objects"
85959f606849Smrg
8596d5c3dbf1Smrg      test -n "$xrpath" && \
8597d5c3dbf1Smrg	func_warning "\`-R' is ignored for objects"
8598d5c3dbf1Smrg
8599d5c3dbf1Smrg      test -n "$vinfo" && \
8600d5c3dbf1Smrg	func_warning "\`-version-info' is ignored for objects"
86019f606849Smrg
8602d5c3dbf1Smrg      test -n "$release" && \
8603d5c3dbf1Smrg	func_warning "\`-release' is ignored for objects"
86049f606849Smrg
8605d5c3dbf1Smrg      case $output in
8606d5c3dbf1Smrg      *.lo)
8607d5c3dbf1Smrg	test -n "$objs$old_deplibs" && \
8608d5c3dbf1Smrg	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
8609d5c3dbf1Smrg
8610d5c3dbf1Smrg	libobj=$output
8611d5c3dbf1Smrg	func_lo2o "$libobj"
8612d5c3dbf1Smrg	obj=$func_lo2o_result
8613d5c3dbf1Smrg	;;
8614d5c3dbf1Smrg      *)
8615d5c3dbf1Smrg	libobj=
8616d5c3dbf1Smrg	obj="$output"
86179f606849Smrg	;;
86189f606849Smrg      esac
86199f606849Smrg
8620d5c3dbf1Smrg      # Delete the old objects.
8621d5c3dbf1Smrg      $opt_dry_run || $RM $obj $libobj
86229f606849Smrg
8623d5c3dbf1Smrg      # Objects from convenience libraries.  This assumes
8624d5c3dbf1Smrg      # single-version convenience libraries.  Whenever we create
8625d5c3dbf1Smrg      # different ones for PIC/non-PIC, this we'll have to duplicate
8626d5c3dbf1Smrg      # the extraction.
8627d5c3dbf1Smrg      reload_conv_objs=
8628d5c3dbf1Smrg      gentop=
8629d5c3dbf1Smrg      # reload_cmds runs $LD directly, so let us get rid of
8630d5c3dbf1Smrg      # -Wl from whole_archive_flag_spec and hope we can get by with
8631d5c3dbf1Smrg      # turning comma into space..
8632d5c3dbf1Smrg      wl=
86339f606849Smrg
8634d5c3dbf1Smrg      if test -n "$convenience"; then
8635d5c3dbf1Smrg	if test -n "$whole_archive_flag_spec"; then
8636d5c3dbf1Smrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
8637d5c3dbf1Smrg	  reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
86389f606849Smrg	else
8639d5c3dbf1Smrg	  gentop="$output_objdir/${obj}x"
8640cdbfa18aSmrg	  func_append generated " $gentop"
8641d5c3dbf1Smrg
8642d5c3dbf1Smrg	  func_extract_archives $gentop $convenience
8643d5c3dbf1Smrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
86449f606849Smrg	fi
8645d5c3dbf1Smrg      fi
86469f606849Smrg
8647cdbfa18aSmrg      # If we're not building shared, we need to use non_pic_objs
8648cdbfa18aSmrg      test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
8649cdbfa18aSmrg
8650d5c3dbf1Smrg      # Create the old-style object.
8651d5c3dbf1Smrg      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
86529f606849Smrg
8653d5c3dbf1Smrg      output="$obj"
8654d5c3dbf1Smrg      func_execute_cmds "$reload_cmds" 'exit $?'
86559f606849Smrg
8656d5c3dbf1Smrg      # Exit if we aren't doing a library object file.
8657d5c3dbf1Smrg      if test -z "$libobj"; then
8658d5c3dbf1Smrg	if test -n "$gentop"; then
8659d5c3dbf1Smrg	  func_show_eval '${RM}r "$gentop"'
8660d5c3dbf1Smrg	fi
86619f606849Smrg
8662d5c3dbf1Smrg	exit $EXIT_SUCCESS
86639f606849Smrg      fi
86649f606849Smrg
8665d5c3dbf1Smrg      if test "$build_libtool_libs" != yes; then
8666d5c3dbf1Smrg	if test -n "$gentop"; then
8667d5c3dbf1Smrg	  func_show_eval '${RM}r "$gentop"'
8668d5c3dbf1Smrg	fi
86699f606849Smrg
8670d5c3dbf1Smrg	# Create an invalid libtool object if no PIC, so that we don't
8671d5c3dbf1Smrg	# accidentally link it into a program.
8672d5c3dbf1Smrg	# $show "echo timestamp > $libobj"
8673d5c3dbf1Smrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
8674d5c3dbf1Smrg	exit $EXIT_SUCCESS
8675d5c3dbf1Smrg      fi
86769f606849Smrg
8677d5c3dbf1Smrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
8678d5c3dbf1Smrg	# Only do commands if we really have different PIC objects.
8679d5c3dbf1Smrg	reload_objs="$libobjs $reload_conv_objs"
8680d5c3dbf1Smrg	output="$libobj"
8681d5c3dbf1Smrg	func_execute_cmds "$reload_cmds" 'exit $?'
86829f606849Smrg      fi
8683d5c3dbf1Smrg
8684d5c3dbf1Smrg      if test -n "$gentop"; then
8685d5c3dbf1Smrg	func_show_eval '${RM}r "$gentop"'
8686d5c3dbf1Smrg      fi
8687d5c3dbf1Smrg
8688d5c3dbf1Smrg      exit $EXIT_SUCCESS
86899f606849Smrg      ;;
86909f606849Smrg
8691d5c3dbf1Smrg    prog)
8692d5c3dbf1Smrg      case $host in
8693d5c3dbf1Smrg	*cygwin*) func_stripname '' '.exe' "$output"
8694d5c3dbf1Smrg	          output=$func_stripname_result.exe;;
8695d5c3dbf1Smrg      esac
8696d5c3dbf1Smrg      test -n "$vinfo" && \
8697d5c3dbf1Smrg	func_warning "\`-version-info' is ignored for programs"
86989f606849Smrg
8699d5c3dbf1Smrg      test -n "$release" && \
8700d5c3dbf1Smrg	func_warning "\`-release' is ignored for programs"
87019f606849Smrg
8702d5c3dbf1Smrg      test "$preload" = yes \
8703d5c3dbf1Smrg        && test "$dlopen_support" = unknown \
8704d5c3dbf1Smrg	&& test "$dlopen_self" = unknown \
8705d5c3dbf1Smrg	&& test "$dlopen_self_static" = unknown && \
8706d5c3dbf1Smrg	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
8707d5c3dbf1Smrg
8708d5c3dbf1Smrg      case $host in
8709d5c3dbf1Smrg      *-*-rhapsody* | *-*-darwin1.[012])
8710d5c3dbf1Smrg	# On Rhapsody replace the C library is the System framework
8711d5c3dbf1Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
8712d5c3dbf1Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
87139f606849Smrg	;;
8714d5c3dbf1Smrg      esac
87159f606849Smrg
8716d5c3dbf1Smrg      case $host in
8717d5c3dbf1Smrg      *-*-darwin*)
8718d5c3dbf1Smrg	# Don't allow lazy linking, it breaks C++ global constructors
8719d5c3dbf1Smrg	# But is supposedly fixed on 10.4 or later (yay!).
8720d5c3dbf1Smrg	if test "$tagname" = CXX ; then
8721d5c3dbf1Smrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
8722d5c3dbf1Smrg	    10.[0123])
8723cdbfa18aSmrg	      func_append compile_command " ${wl}-bind_at_load"
8724cdbfa18aSmrg	      func_append finalize_command " ${wl}-bind_at_load"
8725d5c3dbf1Smrg	    ;;
8726d5c3dbf1Smrg	  esac
87279f606849Smrg	fi
8728d5c3dbf1Smrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
8729d5c3dbf1Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8730d5c3dbf1Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8731d5c3dbf1Smrg	;;
8732d5c3dbf1Smrg      esac
87339f606849Smrg
87349f606849Smrg
8735d5c3dbf1Smrg      # move library search paths that coincide with paths to not yet
8736d5c3dbf1Smrg      # installed libraries to the beginning of the library search list
8737d5c3dbf1Smrg      new_libs=
8738d5c3dbf1Smrg      for path in $notinst_path; do
8739d5c3dbf1Smrg	case " $new_libs " in
8740d5c3dbf1Smrg	*" -L$path/$objdir "*) ;;
8741d5c3dbf1Smrg	*)
8742d5c3dbf1Smrg	  case " $compile_deplibs " in
8743d5c3dbf1Smrg	  *" -L$path/$objdir "*)
8744cdbfa18aSmrg	    func_append new_libs " -L$path/$objdir" ;;
87459f606849Smrg	  esac
8746d5c3dbf1Smrg	  ;;
8747d5c3dbf1Smrg	esac
8748d5c3dbf1Smrg      done
8749d5c3dbf1Smrg      for deplib in $compile_deplibs; do
8750d5c3dbf1Smrg	case $deplib in
8751d5c3dbf1Smrg	-L*)
8752d5c3dbf1Smrg	  case " $new_libs " in
8753d5c3dbf1Smrg	  *" $deplib "*) ;;
8754cdbfa18aSmrg	  *) func_append new_libs " $deplib" ;;
87559f606849Smrg	  esac
8756d5c3dbf1Smrg	  ;;
8757cdbfa18aSmrg	*) func_append new_libs " $deplib" ;;
8758d5c3dbf1Smrg	esac
8759d5c3dbf1Smrg      done
8760d5c3dbf1Smrg      compile_deplibs="$new_libs"
87619f606849Smrg
87629f606849Smrg
8763cdbfa18aSmrg      func_append compile_command " $compile_deplibs"
8764cdbfa18aSmrg      func_append finalize_command " $finalize_deplibs"
87659f606849Smrg
8766d5c3dbf1Smrg      if test -n "$rpath$xrpath"; then
8767d5c3dbf1Smrg	# If the user specified any rpath flags, then add them.
8768d5c3dbf1Smrg	for libdir in $rpath $xrpath; do
8769d5c3dbf1Smrg	  # This is the magic to use -rpath.
8770d5c3dbf1Smrg	  case "$finalize_rpath " in
8771d5c3dbf1Smrg	  *" $libdir "*) ;;
8772cdbfa18aSmrg	  *) func_append finalize_rpath " $libdir" ;;
8773d5c3dbf1Smrg	  esac
8774d5c3dbf1Smrg	done
8775d5c3dbf1Smrg      fi
87769f606849Smrg
8777d5c3dbf1Smrg      # Now hardcode the library paths
8778d5c3dbf1Smrg      rpath=
8779d5c3dbf1Smrg      hardcode_libdirs=
8780d5c3dbf1Smrg      for libdir in $compile_rpath $finalize_rpath; do
8781d5c3dbf1Smrg	if test -n "$hardcode_libdir_flag_spec"; then
8782d5c3dbf1Smrg	  if test -n "$hardcode_libdir_separator"; then
8783d5c3dbf1Smrg	    if test -z "$hardcode_libdirs"; then
8784d5c3dbf1Smrg	      hardcode_libdirs="$libdir"
8785d5c3dbf1Smrg	    else
8786d5c3dbf1Smrg	      # Just accumulate the unique libdirs.
8787d5c3dbf1Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8788d5c3dbf1Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8789d5c3dbf1Smrg		;;
8790d5c3dbf1Smrg	      *)
8791cdbfa18aSmrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8792d5c3dbf1Smrg		;;
8793d5c3dbf1Smrg	      esac
8794d5c3dbf1Smrg	    fi
87959f606849Smrg	  else
8796d5c3dbf1Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
8797cdbfa18aSmrg	    func_append rpath " $flag"
87989f606849Smrg	  fi
8799d5c3dbf1Smrg	elif test -n "$runpath_var"; then
8800d5c3dbf1Smrg	  case "$perm_rpath " in
8801d5c3dbf1Smrg	  *" $libdir "*) ;;
8802cdbfa18aSmrg	  *) func_append perm_rpath " $libdir" ;;
8803d5c3dbf1Smrg	  esac
8804d5c3dbf1Smrg	fi
8805d5c3dbf1Smrg	case $host in
8806d5c3dbf1Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
8807d5c3dbf1Smrg	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
8808d5c3dbf1Smrg	  case :$dllsearchpath: in
8809d5c3dbf1Smrg	  *":$libdir:"*) ;;
8810d5c3dbf1Smrg	  ::) dllsearchpath=$libdir;;
8811cdbfa18aSmrg	  *) func_append dllsearchpath ":$libdir";;
8812d5c3dbf1Smrg	  esac
8813d5c3dbf1Smrg	  case :$dllsearchpath: in
8814d5c3dbf1Smrg	  *":$testbindir:"*) ;;
8815d5c3dbf1Smrg	  ::) dllsearchpath=$testbindir;;
8816cdbfa18aSmrg	  *) func_append dllsearchpath ":$testbindir";;
8817d5c3dbf1Smrg	  esac
8818d5c3dbf1Smrg	  ;;
8819d5c3dbf1Smrg	esac
8820d5c3dbf1Smrg      done
8821d5c3dbf1Smrg      # Substitute the hardcoded libdirs into the rpath.
8822d5c3dbf1Smrg      if test -n "$hardcode_libdir_separator" &&
8823d5c3dbf1Smrg	 test -n "$hardcode_libdirs"; then
8824d5c3dbf1Smrg	libdir="$hardcode_libdirs"
8825d5c3dbf1Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
8826d5c3dbf1Smrg      fi
8827d5c3dbf1Smrg      compile_rpath="$rpath"
88289f606849Smrg
8829d5c3dbf1Smrg      rpath=
8830d5c3dbf1Smrg      hardcode_libdirs=
8831d5c3dbf1Smrg      for libdir in $finalize_rpath; do
8832d5c3dbf1Smrg	if test -n "$hardcode_libdir_flag_spec"; then
8833d5c3dbf1Smrg	  if test -n "$hardcode_libdir_separator"; then
8834d5c3dbf1Smrg	    if test -z "$hardcode_libdirs"; then
8835d5c3dbf1Smrg	      hardcode_libdirs="$libdir"
8836d5c3dbf1Smrg	    else
8837d5c3dbf1Smrg	      # Just accumulate the unique libdirs.
8838d5c3dbf1Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8839d5c3dbf1Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8840d5c3dbf1Smrg		;;
8841d5c3dbf1Smrg	      *)
8842cdbfa18aSmrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8843d5c3dbf1Smrg		;;
8844d5c3dbf1Smrg	      esac
8845d5c3dbf1Smrg	    fi
88469f606849Smrg	  else
8847d5c3dbf1Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
8848cdbfa18aSmrg	    func_append rpath " $flag"
88499f606849Smrg	  fi
8850d5c3dbf1Smrg	elif test -n "$runpath_var"; then
8851d5c3dbf1Smrg	  case "$finalize_perm_rpath " in
8852d5c3dbf1Smrg	  *" $libdir "*) ;;
8853cdbfa18aSmrg	  *) func_append finalize_perm_rpath " $libdir" ;;
8854d5c3dbf1Smrg	  esac
88559f606849Smrg	fi
8856d5c3dbf1Smrg      done
8857d5c3dbf1Smrg      # Substitute the hardcoded libdirs into the rpath.
8858d5c3dbf1Smrg      if test -n "$hardcode_libdir_separator" &&
8859d5c3dbf1Smrg	 test -n "$hardcode_libdirs"; then
8860d5c3dbf1Smrg	libdir="$hardcode_libdirs"
8861d5c3dbf1Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
8862d5c3dbf1Smrg      fi
8863d5c3dbf1Smrg      finalize_rpath="$rpath"
88649f606849Smrg
8865d5c3dbf1Smrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
8866d5c3dbf1Smrg	# Transform all the library objects into standard objects.
8867d5c3dbf1Smrg	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
8868d5c3dbf1Smrg	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
8869d5c3dbf1Smrg      fi
88709f606849Smrg
8871d5c3dbf1Smrg      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
88729f606849Smrg
8873d5c3dbf1Smrg      # template prelinking step
8874d5c3dbf1Smrg      if test -n "$prelink_cmds"; then
8875d5c3dbf1Smrg	func_execute_cmds "$prelink_cmds" 'exit $?'
8876d5c3dbf1Smrg      fi
88779f606849Smrg
8878d5c3dbf1Smrg      wrappers_required=yes
8879d5c3dbf1Smrg      case $host in
8880d5c3dbf1Smrg      *cegcc* | *mingw32ce*)
8881d5c3dbf1Smrg        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
8882d5c3dbf1Smrg        wrappers_required=no
8883d5c3dbf1Smrg        ;;
8884d5c3dbf1Smrg      *cygwin* | *mingw* )
8885d5c3dbf1Smrg        if test "$build_libtool_libs" != yes; then
8886d5c3dbf1Smrg          wrappers_required=no
8887d5c3dbf1Smrg        fi
8888d5c3dbf1Smrg        ;;
8889d5c3dbf1Smrg      *)
8890d5c3dbf1Smrg        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
8891d5c3dbf1Smrg          wrappers_required=no
8892d5c3dbf1Smrg        fi
8893d5c3dbf1Smrg        ;;
8894d5c3dbf1Smrg      esac
8895d5c3dbf1Smrg      if test "$wrappers_required" = no; then
8896d5c3dbf1Smrg	# Replace the output file specification.
8897d5c3dbf1Smrg	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
8898d5c3dbf1Smrg	link_command="$compile_command$compile_rpath"
88999f606849Smrg
8900d5c3dbf1Smrg	# We have no uninstalled library dependencies, so finalize right now.
8901d5c3dbf1Smrg	exit_status=0
8902d5c3dbf1Smrg	func_show_eval "$link_command" 'exit_status=$?'
89039f606849Smrg
8904cdbfa18aSmrg	if test -n "$postlink_cmds"; then
8905cdbfa18aSmrg	  func_to_tool_file "$output"
8906cdbfa18aSmrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8907cdbfa18aSmrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
8908cdbfa18aSmrg	fi
8909cdbfa18aSmrg
8910d5c3dbf1Smrg	# Delete the generated files.
8911d5c3dbf1Smrg	if test -f "$output_objdir/${outputname}S.${objext}"; then
8912d5c3dbf1Smrg	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
89139f606849Smrg	fi
89149f606849Smrg
8915d5c3dbf1Smrg	exit $exit_status
8916d5c3dbf1Smrg      fi
89179f606849Smrg
8918d5c3dbf1Smrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
8919d5c3dbf1Smrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
8920d5c3dbf1Smrg      fi
8921d5c3dbf1Smrg      if test -n "$finalize_shlibpath"; then
8922d5c3dbf1Smrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
8923d5c3dbf1Smrg      fi
89249f606849Smrg
8925d5c3dbf1Smrg      compile_var=
8926d5c3dbf1Smrg      finalize_var=
8927d5c3dbf1Smrg      if test -n "$runpath_var"; then
8928d5c3dbf1Smrg	if test -n "$perm_rpath"; then
8929d5c3dbf1Smrg	  # We should set the runpath_var.
8930d5c3dbf1Smrg	  rpath=
8931d5c3dbf1Smrg	  for dir in $perm_rpath; do
8932cdbfa18aSmrg	    func_append rpath "$dir:"
8933d5c3dbf1Smrg	  done
8934d5c3dbf1Smrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
89359f606849Smrg	fi
8936d5c3dbf1Smrg	if test -n "$finalize_perm_rpath"; then
8937d5c3dbf1Smrg	  # We should set the runpath_var.
8938d5c3dbf1Smrg	  rpath=
8939d5c3dbf1Smrg	  for dir in $finalize_perm_rpath; do
8940cdbfa18aSmrg	    func_append rpath "$dir:"
8941d5c3dbf1Smrg	  done
8942d5c3dbf1Smrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
89439f606849Smrg	fi
8944d5c3dbf1Smrg      fi
89459f606849Smrg
8946d5c3dbf1Smrg      if test "$no_install" = yes; then
8947d5c3dbf1Smrg	# We don't need to create a wrapper script.
8948d5c3dbf1Smrg	link_command="$compile_var$compile_command$compile_rpath"
8949d5c3dbf1Smrg	# Replace the output file specification.
8950d5c3dbf1Smrg	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
8951d5c3dbf1Smrg	# Delete the old output file.
8952d5c3dbf1Smrg	$opt_dry_run || $RM $output
8953d5c3dbf1Smrg	# Link the executable and exit
8954d5c3dbf1Smrg	func_show_eval "$link_command" 'exit $?'
8955cdbfa18aSmrg
8956cdbfa18aSmrg	if test -n "$postlink_cmds"; then
8957cdbfa18aSmrg	  func_to_tool_file "$output"
8958cdbfa18aSmrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8959cdbfa18aSmrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
8960cdbfa18aSmrg	fi
8961cdbfa18aSmrg
89629f606849Smrg	exit $EXIT_SUCCESS
8963d5c3dbf1Smrg      fi
89649f606849Smrg
8965d5c3dbf1Smrg      if test "$hardcode_action" = relink; then
8966d5c3dbf1Smrg	# Fast installation is not supported
8967d5c3dbf1Smrg	link_command="$compile_var$compile_command$compile_rpath"
8968d5c3dbf1Smrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
8969d5c3dbf1Smrg
8970d5c3dbf1Smrg	func_warning "this platform does not like uninstalled shared libraries"
8971d5c3dbf1Smrg	func_warning "\`$output' will be relinked during installation"
8972d5c3dbf1Smrg      else
8973d5c3dbf1Smrg	if test "$fast_install" != no; then
8974d5c3dbf1Smrg	  link_command="$finalize_var$compile_command$finalize_rpath"
8975d5c3dbf1Smrg	  if test "$fast_install" = yes; then
8976d5c3dbf1Smrg	    relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
8977d5c3dbf1Smrg	  else
8978d5c3dbf1Smrg	    # fast_install is set to needless
8979d5c3dbf1Smrg	    relink_command=
8980d5c3dbf1Smrg	  fi
89819f606849Smrg	else
8982d5c3dbf1Smrg	  link_command="$compile_var$compile_command$compile_rpath"
8983d5c3dbf1Smrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
89849f606849Smrg	fi
8985d5c3dbf1Smrg      fi
89869f606849Smrg
8987d5c3dbf1Smrg      # Replace the output file specification.
8988d5c3dbf1Smrg      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
89899f606849Smrg
8990d5c3dbf1Smrg      # Delete the old output files.
8991d5c3dbf1Smrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
89929f606849Smrg
8993d5c3dbf1Smrg      func_show_eval "$link_command" 'exit $?'
89949f606849Smrg
8995cdbfa18aSmrg      if test -n "$postlink_cmds"; then
8996cdbfa18aSmrg	func_to_tool_file "$output_objdir/$outputname"
8997cdbfa18aSmrg	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'`
8998cdbfa18aSmrg	func_execute_cmds "$postlink_cmds" 'exit $?'
8999cdbfa18aSmrg      fi
9000cdbfa18aSmrg
9001d5c3dbf1Smrg      # Now create the wrapper script.
9002d5c3dbf1Smrg      func_verbose "creating $output"
90039f606849Smrg
9004d5c3dbf1Smrg      # Quote the relink command for shipping.
9005d5c3dbf1Smrg      if test -n "$relink_command"; then
9006d5c3dbf1Smrg	# Preserve any variables that may affect compiler behavior
9007d5c3dbf1Smrg	for var in $variables_saved_for_relink; do
9008d5c3dbf1Smrg	  if eval test -z \"\${$var+set}\"; then
9009d5c3dbf1Smrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
9010d5c3dbf1Smrg	  elif eval var_value=\$$var; test -z "$var_value"; then
9011d5c3dbf1Smrg	    relink_command="$var=; export $var; $relink_command"
90129f606849Smrg	  else
9013d5c3dbf1Smrg	    func_quote_for_eval "$var_value"
9014d5c3dbf1Smrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
90159f606849Smrg	  fi
9016d5c3dbf1Smrg	done
9017d5c3dbf1Smrg	relink_command="(cd `pwd`; $relink_command)"
9018d5c3dbf1Smrg	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9019d5c3dbf1Smrg      fi
90209f606849Smrg
9021d5c3dbf1Smrg      # Only actually do things if not in dry run mode.
9022d5c3dbf1Smrg      $opt_dry_run || {
9023d5c3dbf1Smrg	# win32 will think the script is a binary if it has
9024d5c3dbf1Smrg	# a .exe suffix, so we strip it off here.
9025d5c3dbf1Smrg	case $output in
9026d5c3dbf1Smrg	  *.exe) func_stripname '' '.exe' "$output"
9027d5c3dbf1Smrg	         output=$func_stripname_result ;;
9028d5c3dbf1Smrg	esac
9029d5c3dbf1Smrg	# test for cygwin because mv fails w/o .exe extensions
9030d5c3dbf1Smrg	case $host in
9031d5c3dbf1Smrg	  *cygwin*)
9032d5c3dbf1Smrg	    exeext=.exe
9033d5c3dbf1Smrg	    func_stripname '' '.exe' "$outputname"
9034d5c3dbf1Smrg	    outputname=$func_stripname_result ;;
9035d5c3dbf1Smrg	  *) exeext= ;;
90369f606849Smrg	esac
9037d5c3dbf1Smrg	case $host in
9038d5c3dbf1Smrg	  *cygwin* | *mingw* )
9039d5c3dbf1Smrg	    func_dirname_and_basename "$output" "" "."
9040d5c3dbf1Smrg	    output_name=$func_basename_result
9041d5c3dbf1Smrg	    output_path=$func_dirname_result
9042d5c3dbf1Smrg	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
9043d5c3dbf1Smrg	    cwrapper="$output_path/$output_name.exe"
9044d5c3dbf1Smrg	    $RM $cwrappersource $cwrapper
9045d5c3dbf1Smrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
9046d5c3dbf1Smrg
9047d5c3dbf1Smrg	    func_emit_cwrapperexe_src > $cwrappersource
9048d5c3dbf1Smrg
9049d5c3dbf1Smrg	    # The wrapper executable is built using the $host compiler,
9050d5c3dbf1Smrg	    # because it contains $host paths and files. If cross-
9051d5c3dbf1Smrg	    # compiling, it, like the target executable, must be
9052d5c3dbf1Smrg	    # executed on the $host or under an emulation environment.
9053d5c3dbf1Smrg	    $opt_dry_run || {
9054d5c3dbf1Smrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
9055d5c3dbf1Smrg	      $STRIP $cwrapper
9056d5c3dbf1Smrg	    }
90579f606849Smrg
9058d5c3dbf1Smrg	    # Now, create the wrapper script for func_source use:
9059d5c3dbf1Smrg	    func_ltwrapper_scriptname $cwrapper
9060d5c3dbf1Smrg	    $RM $func_ltwrapper_scriptname_result
9061d5c3dbf1Smrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
9062d5c3dbf1Smrg	    $opt_dry_run || {
9063d5c3dbf1Smrg	      # note: this script will not be executed, so do not chmod.
9064d5c3dbf1Smrg	      if test "x$build" = "x$host" ; then
9065d5c3dbf1Smrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
9066d5c3dbf1Smrg	      else
9067d5c3dbf1Smrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
9068d5c3dbf1Smrg	      fi
9069d5c3dbf1Smrg	    }
9070d5c3dbf1Smrg	  ;;
9071d5c3dbf1Smrg	  * )
9072d5c3dbf1Smrg	    $RM $output
9073d5c3dbf1Smrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
90749f606849Smrg
9075d5c3dbf1Smrg	    func_emit_wrapper no > $output
9076d5c3dbf1Smrg	    chmod +x $output
9077d5c3dbf1Smrg	  ;;
9078d5c3dbf1Smrg	esac
9079d5c3dbf1Smrg      }
9080d5c3dbf1Smrg      exit $EXIT_SUCCESS
9081d5c3dbf1Smrg      ;;
9082d5c3dbf1Smrg    esac
90839f606849Smrg
9084d5c3dbf1Smrg    # See if we need to build an old-fashioned archive.
9085d5c3dbf1Smrg    for oldlib in $oldlibs; do
90869f606849Smrg
9087d5c3dbf1Smrg      if test "$build_libtool_libs" = convenience; then
9088d5c3dbf1Smrg	oldobjs="$libobjs_save $symfileobj"
9089d5c3dbf1Smrg	addlibs="$convenience"
9090d5c3dbf1Smrg	build_libtool_libs=no
9091d5c3dbf1Smrg      else
9092d5c3dbf1Smrg	if test "$build_libtool_libs" = module; then
9093d5c3dbf1Smrg	  oldobjs="$libobjs_save"
9094d5c3dbf1Smrg	  build_libtool_libs=no
9095d5c3dbf1Smrg	else
9096d5c3dbf1Smrg	  oldobjs="$old_deplibs $non_pic_objects"
9097d5c3dbf1Smrg	  if test "$preload" = yes && test -f "$symfileobj"; then
9098cdbfa18aSmrg	    func_append oldobjs " $symfileobj"
9099d5c3dbf1Smrg	  fi
9100d5c3dbf1Smrg	fi
9101d5c3dbf1Smrg	addlibs="$old_convenience"
91029f606849Smrg      fi
91039f606849Smrg
9104d5c3dbf1Smrg      if test -n "$addlibs"; then
9105d5c3dbf1Smrg	gentop="$output_objdir/${outputname}x"
9106cdbfa18aSmrg	func_append generated " $gentop"
91079f606849Smrg
9108d5c3dbf1Smrg	func_extract_archives $gentop $addlibs
9109cdbfa18aSmrg	func_append oldobjs " $func_extract_archives_result"
9110d5c3dbf1Smrg      fi
91119f606849Smrg
9112d5c3dbf1Smrg      # Do each command in the archive commands.
9113d5c3dbf1Smrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
9114d5c3dbf1Smrg	cmds=$old_archive_from_new_cmds
9115d5c3dbf1Smrg      else
91169f606849Smrg
9117d5c3dbf1Smrg	# Add any objects from preloaded convenience libraries
9118d5c3dbf1Smrg	if test -n "$dlprefiles"; then
9119d5c3dbf1Smrg	  gentop="$output_objdir/${outputname}x"
9120cdbfa18aSmrg	  func_append generated " $gentop"
91219f606849Smrg
9122d5c3dbf1Smrg	  func_extract_archives $gentop $dlprefiles
9123cdbfa18aSmrg	  func_append oldobjs " $func_extract_archives_result"
9124d5c3dbf1Smrg	fi
91259f606849Smrg
9126d5c3dbf1Smrg	# POSIX demands no paths to be encoded in archives.  We have
9127d5c3dbf1Smrg	# to avoid creating archives with duplicate basenames if we
9128d5c3dbf1Smrg	# might have to extract them afterwards, e.g., when creating a
9129d5c3dbf1Smrg	# static archive out of a convenience library, or when linking
9130d5c3dbf1Smrg	# the entirety of a libtool archive into another (currently
9131d5c3dbf1Smrg	# not supported by libtool).
9132d5c3dbf1Smrg	if (for obj in $oldobjs
9133d5c3dbf1Smrg	    do
9134d5c3dbf1Smrg	      func_basename "$obj"
9135d5c3dbf1Smrg	      $ECHO "$func_basename_result"
9136d5c3dbf1Smrg	    done | sort | sort -uc >/dev/null 2>&1); then
9137d5c3dbf1Smrg	  :
9138d5c3dbf1Smrg	else
9139d5c3dbf1Smrg	  echo "copying selected object files to avoid basename conflicts..."
9140d5c3dbf1Smrg	  gentop="$output_objdir/${outputname}x"
9141cdbfa18aSmrg	  func_append generated " $gentop"
9142d5c3dbf1Smrg	  func_mkdir_p "$gentop"
9143d5c3dbf1Smrg	  save_oldobjs=$oldobjs
9144d5c3dbf1Smrg	  oldobjs=
9145d5c3dbf1Smrg	  counter=1
9146d5c3dbf1Smrg	  for obj in $save_oldobjs
9147d5c3dbf1Smrg	  do
9148d5c3dbf1Smrg	    func_basename "$obj"
9149d5c3dbf1Smrg	    objbase="$func_basename_result"
9150d5c3dbf1Smrg	    case " $oldobjs " in
9151d5c3dbf1Smrg	    " ") oldobjs=$obj ;;
9152d5c3dbf1Smrg	    *[\ /]"$objbase "*)
9153d5c3dbf1Smrg	      while :; do
9154d5c3dbf1Smrg		# Make sure we don't pick an alternate name that also
9155d5c3dbf1Smrg		# overlaps.
9156d5c3dbf1Smrg		newobj=lt$counter-$objbase
9157d5c3dbf1Smrg		func_arith $counter + 1
9158d5c3dbf1Smrg		counter=$func_arith_result
9159d5c3dbf1Smrg		case " $oldobjs " in
9160d5c3dbf1Smrg		*[\ /]"$newobj "*) ;;
9161d5c3dbf1Smrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
9162d5c3dbf1Smrg		esac
9163d5c3dbf1Smrg	      done
9164d5c3dbf1Smrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
9165cdbfa18aSmrg	      func_append oldobjs " $gentop/$newobj"
9166d5c3dbf1Smrg	      ;;
9167cdbfa18aSmrg	    *) func_append oldobjs " $obj" ;;
9168d5c3dbf1Smrg	    esac
91699f606849Smrg	  done
91709f606849Smrg	fi
9171cdbfa18aSmrg	func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
9172cdbfa18aSmrg	tool_oldlib=$func_to_tool_file_result
9173d5c3dbf1Smrg	eval cmds=\"$old_archive_cmds\"
91749f606849Smrg
9175d5c3dbf1Smrg	func_len " $cmds"
9176d5c3dbf1Smrg	len=$func_len_result
9177d5c3dbf1Smrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
9178d5c3dbf1Smrg	  cmds=$old_archive_cmds
9179cdbfa18aSmrg	elif test -n "$archiver_list_spec"; then
9180cdbfa18aSmrg	  func_verbose "using command file archive linking..."
9181cdbfa18aSmrg	  for obj in $oldobjs
9182cdbfa18aSmrg	  do
9183cdbfa18aSmrg	    func_to_tool_file "$obj"
9184cdbfa18aSmrg	    $ECHO "$func_to_tool_file_result"
9185cdbfa18aSmrg	  done > $output_objdir/$libname.libcmd
9186cdbfa18aSmrg	  func_to_tool_file "$output_objdir/$libname.libcmd"
9187cdbfa18aSmrg	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
9188cdbfa18aSmrg	  cmds=$old_archive_cmds
9189d5c3dbf1Smrg	else
9190d5c3dbf1Smrg	  # the command line is too long to link in one step, link in parts
9191d5c3dbf1Smrg	  func_verbose "using piecewise archive linking..."
9192d5c3dbf1Smrg	  save_RANLIB=$RANLIB
9193d5c3dbf1Smrg	  RANLIB=:
9194d5c3dbf1Smrg	  objlist=
9195d5c3dbf1Smrg	  concat_cmds=
9196d5c3dbf1Smrg	  save_oldobjs=$oldobjs
9197d5c3dbf1Smrg	  oldobjs=
9198d5c3dbf1Smrg	  # Is there a better way of finding the last object in the list?
9199d5c3dbf1Smrg	  for obj in $save_oldobjs
9200d5c3dbf1Smrg	  do
9201d5c3dbf1Smrg	    last_oldobj=$obj
9202d5c3dbf1Smrg	  done
9203d5c3dbf1Smrg	  eval test_cmds=\"$old_archive_cmds\"
9204d5c3dbf1Smrg	  func_len " $test_cmds"
9205d5c3dbf1Smrg	  len0=$func_len_result
9206d5c3dbf1Smrg	  len=$len0
9207d5c3dbf1Smrg	  for obj in $save_oldobjs
9208d5c3dbf1Smrg	  do
9209d5c3dbf1Smrg	    func_len " $obj"
9210d5c3dbf1Smrg	    func_arith $len + $func_len_result
9211d5c3dbf1Smrg	    len=$func_arith_result
9212d5c3dbf1Smrg	    func_append objlist " $obj"
9213d5c3dbf1Smrg	    if test "$len" -lt "$max_cmd_len"; then
9214d5c3dbf1Smrg	      :
9215d5c3dbf1Smrg	    else
9216d5c3dbf1Smrg	      # the above command should be used before it gets too long
9217d5c3dbf1Smrg	      oldobjs=$objlist
9218d5c3dbf1Smrg	      if test "$obj" = "$last_oldobj" ; then
9219d5c3dbf1Smrg		RANLIB=$save_RANLIB
9220d5c3dbf1Smrg	      fi
9221d5c3dbf1Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9222d5c3dbf1Smrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
9223d5c3dbf1Smrg	      objlist=
9224d5c3dbf1Smrg	      len=$len0
9225d5c3dbf1Smrg	    fi
9226d5c3dbf1Smrg	  done
9227d5c3dbf1Smrg	  RANLIB=$save_RANLIB
9228d5c3dbf1Smrg	  oldobjs=$objlist
9229d5c3dbf1Smrg	  if test "X$oldobjs" = "X" ; then
9230d5c3dbf1Smrg	    eval cmds=\"\$concat_cmds\"
9231d5c3dbf1Smrg	  else
9232d5c3dbf1Smrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
9233d5c3dbf1Smrg	  fi
9234d5c3dbf1Smrg	fi
9235d5c3dbf1Smrg      fi
9236d5c3dbf1Smrg      func_execute_cmds "$cmds" 'exit $?'
92379f606849Smrg    done
92389f606849Smrg
9239d5c3dbf1Smrg    test -n "$generated" && \
9240d5c3dbf1Smrg      func_show_eval "${RM}r$generated"
92419f606849Smrg
9242d5c3dbf1Smrg    # Now create the libtool archive.
9243d5c3dbf1Smrg    case $output in
9244d5c3dbf1Smrg    *.la)
9245d5c3dbf1Smrg      old_library=
9246d5c3dbf1Smrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
9247d5c3dbf1Smrg      func_verbose "creating $output"
92489f606849Smrg
9249d5c3dbf1Smrg      # Preserve any variables that may affect compiler behavior
9250d5c3dbf1Smrg      for var in $variables_saved_for_relink; do
9251d5c3dbf1Smrg	if eval test -z \"\${$var+set}\"; then
9252d5c3dbf1Smrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
9253d5c3dbf1Smrg	elif eval var_value=\$$var; test -z "$var_value"; then
9254d5c3dbf1Smrg	  relink_command="$var=; export $var; $relink_command"
92559f606849Smrg	else
9256d5c3dbf1Smrg	  func_quote_for_eval "$var_value"
9257d5c3dbf1Smrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
92589f606849Smrg	fi
9259d5c3dbf1Smrg      done
9260d5c3dbf1Smrg      # Quote the link command for shipping.
9261d5c3dbf1Smrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
9262d5c3dbf1Smrg      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9263d5c3dbf1Smrg      if test "$hardcode_automatic" = yes ; then
9264d5c3dbf1Smrg	relink_command=
9265d5c3dbf1Smrg      fi
92669f606849Smrg
9267d5c3dbf1Smrg      # Only create the output if not a dry run.
9268d5c3dbf1Smrg      $opt_dry_run || {
9269d5c3dbf1Smrg	for installed in no yes; do
9270d5c3dbf1Smrg	  if test "$installed" = yes; then
9271d5c3dbf1Smrg	    if test -z "$install_libdir"; then
9272d5c3dbf1Smrg	      break
9273d5c3dbf1Smrg	    fi
9274d5c3dbf1Smrg	    output="$output_objdir/$outputname"i
9275d5c3dbf1Smrg	    # Replace all uninstalled libtool libraries with the installed ones
9276d5c3dbf1Smrg	    newdependency_libs=
9277d5c3dbf1Smrg	    for deplib in $dependency_libs; do
9278d5c3dbf1Smrg	      case $deplib in
9279d5c3dbf1Smrg	      *.la)
9280d5c3dbf1Smrg		func_basename "$deplib"
9281d5c3dbf1Smrg		name="$func_basename_result"
9282cdbfa18aSmrg		func_resolve_sysroot "$deplib"
9283cdbfa18aSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
9284d5c3dbf1Smrg		test -z "$libdir" && \
9285d5c3dbf1Smrg		  func_fatal_error "\`$deplib' is not a valid libtool archive"
9286cdbfa18aSmrg		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
9287cdbfa18aSmrg		;;
9288cdbfa18aSmrg	      -L*)
9289cdbfa18aSmrg		func_stripname -L '' "$deplib"
9290cdbfa18aSmrg		func_replace_sysroot "$func_stripname_result"
9291cdbfa18aSmrg		func_append newdependency_libs " -L$func_replace_sysroot_result"
9292cdbfa18aSmrg		;;
9293cdbfa18aSmrg	      -R*)
9294cdbfa18aSmrg		func_stripname -R '' "$deplib"
9295cdbfa18aSmrg		func_replace_sysroot "$func_stripname_result"
9296cdbfa18aSmrg		func_append newdependency_libs " -R$func_replace_sysroot_result"
9297d5c3dbf1Smrg		;;
9298cdbfa18aSmrg	      *) func_append newdependency_libs " $deplib" ;;
9299d5c3dbf1Smrg	      esac
9300d5c3dbf1Smrg	    done
9301d5c3dbf1Smrg	    dependency_libs="$newdependency_libs"
9302d5c3dbf1Smrg	    newdlfiles=
9303d5c3dbf1Smrg
9304d5c3dbf1Smrg	    for lib in $dlfiles; do
9305d5c3dbf1Smrg	      case $lib in
9306d5c3dbf1Smrg	      *.la)
9307d5c3dbf1Smrg	        func_basename "$lib"
9308d5c3dbf1Smrg		name="$func_basename_result"
9309d5c3dbf1Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9310d5c3dbf1Smrg		test -z "$libdir" && \
9311d5c3dbf1Smrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
9312cdbfa18aSmrg		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
9313d5c3dbf1Smrg		;;
9314cdbfa18aSmrg	      *) func_append newdlfiles " $lib" ;;
9315d5c3dbf1Smrg	      esac
9316d5c3dbf1Smrg	    done
9317d5c3dbf1Smrg	    dlfiles="$newdlfiles"
9318d5c3dbf1Smrg	    newdlprefiles=
9319d5c3dbf1Smrg	    for lib in $dlprefiles; do
9320d5c3dbf1Smrg	      case $lib in
9321d5c3dbf1Smrg	      *.la)
9322d5c3dbf1Smrg		# Only pass preopened files to the pseudo-archive (for
9323d5c3dbf1Smrg		# eventual linking with the app. that links it) if we
9324d5c3dbf1Smrg		# didn't already link the preopened objects directly into
9325d5c3dbf1Smrg		# the library:
9326d5c3dbf1Smrg		func_basename "$lib"
9327d5c3dbf1Smrg		name="$func_basename_result"
9328d5c3dbf1Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9329d5c3dbf1Smrg		test -z "$libdir" && \
9330d5c3dbf1Smrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
9331cdbfa18aSmrg		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
9332d5c3dbf1Smrg		;;
9333d5c3dbf1Smrg	      esac
9334d5c3dbf1Smrg	    done
9335d5c3dbf1Smrg	    dlprefiles="$newdlprefiles"
9336d5c3dbf1Smrg	  else
9337d5c3dbf1Smrg	    newdlfiles=
9338d5c3dbf1Smrg	    for lib in $dlfiles; do
9339d5c3dbf1Smrg	      case $lib in
9340d5c3dbf1Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9341d5c3dbf1Smrg		*) abs=`pwd`"/$lib" ;;
9342d5c3dbf1Smrg	      esac
9343cdbfa18aSmrg	      func_append newdlfiles " $abs"
9344d5c3dbf1Smrg	    done
9345d5c3dbf1Smrg	    dlfiles="$newdlfiles"
9346d5c3dbf1Smrg	    newdlprefiles=
9347d5c3dbf1Smrg	    for lib in $dlprefiles; do
9348d5c3dbf1Smrg	      case $lib in
9349d5c3dbf1Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9350d5c3dbf1Smrg		*) abs=`pwd`"/$lib" ;;
9351d5c3dbf1Smrg	      esac
9352cdbfa18aSmrg	      func_append newdlprefiles " $abs"
9353d5c3dbf1Smrg	    done
9354d5c3dbf1Smrg	    dlprefiles="$newdlprefiles"
9355d5c3dbf1Smrg	  fi
9356d5c3dbf1Smrg	  $RM $output
9357d5c3dbf1Smrg	  # place dlname in correct position for cygwin
9358d5c3dbf1Smrg	  # In fact, it would be nice if we could use this code for all target
9359d5c3dbf1Smrg	  # systems that can't hard-code library paths into their executables
9360d5c3dbf1Smrg	  # and that have no shared library path variable independent of PATH,
9361d5c3dbf1Smrg	  # but it turns out we can't easily determine that from inspecting
9362d5c3dbf1Smrg	  # libtool variables, so we have to hard-code the OSs to which it
9363d5c3dbf1Smrg	  # applies here; at the moment, that means platforms that use the PE
9364d5c3dbf1Smrg	  # object format with DLL files.  See the long comment at the top of
9365d5c3dbf1Smrg	  # tests/bindir.at for full details.
9366d5c3dbf1Smrg	  tdlname=$dlname
9367d5c3dbf1Smrg	  case $host,$output,$installed,$module,$dlname in
9368d5c3dbf1Smrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
9369d5c3dbf1Smrg	      # If a -bindir argument was supplied, place the dll there.
9370d5c3dbf1Smrg	      if test "x$bindir" != x ;
9371d5c3dbf1Smrg	      then
9372d5c3dbf1Smrg		func_relative_path "$install_libdir" "$bindir"
9373d5c3dbf1Smrg		tdlname=$func_relative_path_result$dlname
9374d5c3dbf1Smrg	      else
9375d5c3dbf1Smrg		# Otherwise fall back on heuristic.
9376d5c3dbf1Smrg		tdlname=../bin/$dlname
9377d5c3dbf1Smrg	      fi
9378d5c3dbf1Smrg	      ;;
9379d5c3dbf1Smrg	  esac
9380d5c3dbf1Smrg	  $ECHO > $output "\
9381d5c3dbf1Smrg# $outputname - a libtool library file
9382d5c3dbf1Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
9383d5c3dbf1Smrg#
9384d5c3dbf1Smrg# Please DO NOT delete this file!
9385d5c3dbf1Smrg# It is necessary for linking the library.
93869f606849Smrg
9387d5c3dbf1Smrg# The name that we can dlopen(3).
9388d5c3dbf1Smrgdlname='$tdlname'
93899f606849Smrg
9390d5c3dbf1Smrg# Names of this library.
9391d5c3dbf1Smrglibrary_names='$library_names'
93929f606849Smrg
9393d5c3dbf1Smrg# The name of the static archive.
9394d5c3dbf1Smrgold_library='$old_library'
93959f606849Smrg
9396d5c3dbf1Smrg# Linker flags that can not go in dependency_libs.
9397d5c3dbf1Smrginherited_linker_flags='$new_inherited_linker_flags'
93989f606849Smrg
9399d5c3dbf1Smrg# Libraries that this one depends upon.
9400d5c3dbf1Smrgdependency_libs='$dependency_libs'
94019f606849Smrg
9402d5c3dbf1Smrg# Names of additional weak libraries provided by this library
9403d5c3dbf1Smrgweak_library_names='$weak_libs'
94049f606849Smrg
9405d5c3dbf1Smrg# Version information for $libname.
9406d5c3dbf1Smrgcurrent=$current
9407d5c3dbf1Smrgage=$age
9408d5c3dbf1Smrgrevision=$revision
94099f606849Smrg
9410d5c3dbf1Smrg# Is this an already installed library?
9411d5c3dbf1Smrginstalled=$installed
94129f606849Smrg
9413d5c3dbf1Smrg# Should we warn about portability when linking against -modules?
9414d5c3dbf1Smrgshouldnotlink=$module
94159f606849Smrg
9416d5c3dbf1Smrg# Files to dlopen/dlpreopen
9417d5c3dbf1Smrgdlopen='$dlfiles'
9418d5c3dbf1Smrgdlpreopen='$dlprefiles'
94199f606849Smrg
9420d5c3dbf1Smrg# Directory that this library needs to be installed in:
9421d5c3dbf1Smrglibdir='$install_libdir'"
9422d5c3dbf1Smrg	  if test "$installed" = no && test "$need_relink" = yes; then
9423d5c3dbf1Smrg	    $ECHO >> $output "\
9424d5c3dbf1Smrgrelink_command=\"$relink_command\""
9425d5c3dbf1Smrg	  fi
9426d5c3dbf1Smrg	done
9427d5c3dbf1Smrg      }
94289f606849Smrg
9429d5c3dbf1Smrg      # Do a symbolic link so that the libtool archive can be found in
9430d5c3dbf1Smrg      # LD_LIBRARY_PATH before the program is installed.
9431d5c3dbf1Smrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
9432d5c3dbf1Smrg      ;;
9433d5c3dbf1Smrg    esac
9434d5c3dbf1Smrg    exit $EXIT_SUCCESS
9435d5c3dbf1Smrg}
94369f606849Smrg
9437cdbfa18aSmrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } &&
9438d5c3dbf1Smrg    func_mode_link ${1+"$@"}
94399f606849Smrg
94409f606849Smrg
9441d5c3dbf1Smrg# func_mode_uninstall arg...
9442d5c3dbf1Smrgfunc_mode_uninstall ()
9443d5c3dbf1Smrg{
9444d5c3dbf1Smrg    $opt_debug
9445d5c3dbf1Smrg    RM="$nonopt"
94469f606849Smrg    files=
94479f606849Smrg    rmforce=
94489f606849Smrg    exit_status=0
94499f606849Smrg
94509f606849Smrg    # This variable tells wrapper scripts just to set variables rather
94519f606849Smrg    # than running their programs.
94529f606849Smrg    libtool_install_magic="$magic"
94539f606849Smrg
94549f606849Smrg    for arg
94559f606849Smrg    do
94569f606849Smrg      case $arg in
9457cdbfa18aSmrg      -f) func_append RM " $arg"; rmforce=yes ;;
9458cdbfa18aSmrg      -*) func_append RM " $arg" ;;
9459cdbfa18aSmrg      *) func_append files " $arg" ;;
94609f606849Smrg      esac
94619f606849Smrg    done
94629f606849Smrg
9463d5c3dbf1Smrg    test -z "$RM" && \
9464d5c3dbf1Smrg      func_fatal_help "you must specify an RM program"
94659f606849Smrg
94669f606849Smrg    rmdirs=
94679f606849Smrg
94689f606849Smrg    for file in $files; do
9469d5c3dbf1Smrg      func_dirname "$file" "" "."
9470d5c3dbf1Smrg      dir="$func_dirname_result"
9471d5c3dbf1Smrg      if test "X$dir" = X.; then
9472cdbfa18aSmrg	odir="$objdir"
94739f606849Smrg      else
9474cdbfa18aSmrg	odir="$dir/$objdir"
94759f606849Smrg      fi
9476d5c3dbf1Smrg      func_basename "$file"
9477d5c3dbf1Smrg      name="$func_basename_result"
9478cdbfa18aSmrg      test "$opt_mode" = uninstall && odir="$dir"
94799f606849Smrg
9480cdbfa18aSmrg      # Remember odir for removal later, being careful to avoid duplicates
9481cdbfa18aSmrg      if test "$opt_mode" = clean; then
94829f606849Smrg	case " $rmdirs " in
9483cdbfa18aSmrg	  *" $odir "*) ;;
9484cdbfa18aSmrg	  *) func_append rmdirs " $odir" ;;
94859f606849Smrg	esac
94869f606849Smrg      fi
94879f606849Smrg
94889f606849Smrg      # Don't error if the file doesn't exist and rm -f was used.
9489d5c3dbf1Smrg      if { test -L "$file"; } >/dev/null 2>&1 ||
9490d5c3dbf1Smrg	 { test -h "$file"; } >/dev/null 2>&1 ||
9491d5c3dbf1Smrg	 test -f "$file"; then
94929f606849Smrg	:
94939f606849Smrg      elif test -d "$file"; then
94949f606849Smrg	exit_status=1
94959f606849Smrg	continue
94969f606849Smrg      elif test "$rmforce" = yes; then
94979f606849Smrg	continue
94989f606849Smrg      fi
94999f606849Smrg
95009f606849Smrg      rmfiles="$file"
95019f606849Smrg
95029f606849Smrg      case $name in
95039f606849Smrg      *.la)
95049f606849Smrg	# Possibly a libtool archive, so verify it.
9505d5c3dbf1Smrg	if func_lalib_p "$file"; then
9506d5c3dbf1Smrg	  func_source $dir/$name
95079f606849Smrg
95089f606849Smrg	  # Delete the libtool libraries and symlinks.
95099f606849Smrg	  for n in $library_names; do
9510cdbfa18aSmrg	    func_append rmfiles " $odir/$n"
95119f606849Smrg	  done
9512cdbfa18aSmrg	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
95139f606849Smrg
9514cdbfa18aSmrg	  case "$opt_mode" in
95159f606849Smrg	  clean)
9516cdbfa18aSmrg	    case " $library_names " in
95179f606849Smrg	    *" $dlname "*) ;;
9518cdbfa18aSmrg	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
95199f606849Smrg	    esac
9520cdbfa18aSmrg	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
95219f606849Smrg	    ;;
95229f606849Smrg	  uninstall)
95239f606849Smrg	    if test -n "$library_names"; then
95249f606849Smrg	      # Do each command in the postuninstall commands.
9525d5c3dbf1Smrg	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
95269f606849Smrg	    fi
95279f606849Smrg
95289f606849Smrg	    if test -n "$old_library"; then
95299f606849Smrg	      # Do each command in the old_postuninstall commands.
9530d5c3dbf1Smrg	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
95319f606849Smrg	    fi
95329f606849Smrg	    # FIXME: should reinstall the best remaining shared library.
95339f606849Smrg	    ;;
95349f606849Smrg	  esac
95359f606849Smrg	fi
95369f606849Smrg	;;
95379f606849Smrg
95389f606849Smrg      *.lo)
95399f606849Smrg	# Possibly a libtool object, so verify it.
9540d5c3dbf1Smrg	if func_lalib_p "$file"; then
95419f606849Smrg
95429f606849Smrg	  # Read the .lo file
9543d5c3dbf1Smrg	  func_source $dir/$name
95449f606849Smrg
95459f606849Smrg	  # Add PIC object to the list of files to remove.
9546d5c3dbf1Smrg	  if test -n "$pic_object" &&
9547d5c3dbf1Smrg	     test "$pic_object" != none; then
9548cdbfa18aSmrg	    func_append rmfiles " $dir/$pic_object"
95499f606849Smrg	  fi
95509f606849Smrg
95519f606849Smrg	  # Add non-PIC object to the list of files to remove.
9552d5c3dbf1Smrg	  if test -n "$non_pic_object" &&
9553d5c3dbf1Smrg	     test "$non_pic_object" != none; then
9554cdbfa18aSmrg	    func_append rmfiles " $dir/$non_pic_object"
95559f606849Smrg	  fi
95569f606849Smrg	fi
95579f606849Smrg	;;
95589f606849Smrg
95599f606849Smrg      *)
9560cdbfa18aSmrg	if test "$opt_mode" = clean ; then
95619f606849Smrg	  noexename=$name
95629f606849Smrg	  case $file in
95639f606849Smrg	  *.exe)
9564d5c3dbf1Smrg	    func_stripname '' '.exe' "$file"
9565d5c3dbf1Smrg	    file=$func_stripname_result
9566d5c3dbf1Smrg	    func_stripname '' '.exe' "$name"
9567d5c3dbf1Smrg	    noexename=$func_stripname_result
95689f606849Smrg	    # $file with .exe has already been added to rmfiles,
95699f606849Smrg	    # add $file without .exe
9570cdbfa18aSmrg	    func_append rmfiles " $file"
95719f606849Smrg	    ;;
95729f606849Smrg	  esac
95739f606849Smrg	  # Do a test to see if this is a libtool program.
9574d5c3dbf1Smrg	  if func_ltwrapper_p "$file"; then
9575d5c3dbf1Smrg	    if func_ltwrapper_executable_p "$file"; then
9576d5c3dbf1Smrg	      func_ltwrapper_scriptname "$file"
9577d5c3dbf1Smrg	      relink_command=
9578d5c3dbf1Smrg	      func_source $func_ltwrapper_scriptname_result
9579cdbfa18aSmrg	      func_append rmfiles " $func_ltwrapper_scriptname_result"
9580d5c3dbf1Smrg	    else
9581d5c3dbf1Smrg	      relink_command=
9582d5c3dbf1Smrg	      func_source $dir/$noexename
9583d5c3dbf1Smrg	    fi
95849f606849Smrg
95859f606849Smrg	    # note $name still contains .exe if it was in $file originally
95869f606849Smrg	    # as does the version of $file that was added into $rmfiles
9587cdbfa18aSmrg	    func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
95889f606849Smrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
9589cdbfa18aSmrg	      func_append rmfiles " $odir/lt-$name"
95909f606849Smrg	    fi
95919f606849Smrg	    if test "X$noexename" != "X$name" ; then
9592cdbfa18aSmrg	      func_append rmfiles " $odir/lt-${noexename}.c"
95939f606849Smrg	    fi
95949f606849Smrg	  fi
95959f606849Smrg	fi
95969f606849Smrg	;;
95979f606849Smrg      esac
9598d5c3dbf1Smrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
95999f606849Smrg    done
96009f606849Smrg
96019f606849Smrg    # Try to remove the ${objdir}s in the directories where we deleted files
96029f606849Smrg    for dir in $rmdirs; do
96039f606849Smrg      if test -d "$dir"; then
9604d5c3dbf1Smrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
96059f606849Smrg      fi
96069f606849Smrg    done
96079f606849Smrg
96089f606849Smrg    exit $exit_status
9609d5c3dbf1Smrg}
96109f606849Smrg
9611cdbfa18aSmrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
9612d5c3dbf1Smrg    func_mode_uninstall ${1+"$@"}
96139f606849Smrg
9614cdbfa18aSmrgtest -z "$opt_mode" && {
9615d5c3dbf1Smrg  help="$generic_help"
9616d5c3dbf1Smrg  func_fatal_help "you must specify a MODE"
9617d5c3dbf1Smrg}
9618d5c3dbf1Smrg
9619d5c3dbf1Smrgtest -z "$exec_cmd" && \
9620cdbfa18aSmrg  func_fatal_help "invalid operation mode \`$opt_mode'"
96219f606849Smrg
96229f606849Smrgif test -n "$exec_cmd"; then
9623d5c3dbf1Smrg  eval exec "$exec_cmd"
96249f606849Smrg  exit $EXIT_FAILURE
96259f606849Smrgfi
96269f606849Smrg
9627d5c3dbf1Smrgexit $exit_status
96289f606849Smrg
96299f606849Smrg
96309f606849Smrg# The TAGs below are defined such that we never get into a situation
96319f606849Smrg# in which we disable both kinds of libraries.  Given conflicting
96329f606849Smrg# choices, we go for a static library, that is the most portable,
96339f606849Smrg# since we can't tell whether shared libraries were disabled because
96349f606849Smrg# the user asked for that or because the platform doesn't support
96359f606849Smrg# them.  This is particularly important on AIX, because we don't
96369f606849Smrg# support having both static and shared libraries enabled at the same
96379f606849Smrg# time on that platform, so we default to a shared-only configuration.
96389f606849Smrg# If a disable-shared tag is given, we'll fallback to a static-only
96399f606849Smrg# configuration.  But we'll never go from static-only to shared-only.
96409f606849Smrg
96419f606849Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
9642d5c3dbf1Smrgbuild_libtool_libs=no
9643d5c3dbf1Smrgbuild_old_libs=yes
96449f606849Smrg# ### END LIBTOOL TAG CONFIG: disable-shared
96459f606849Smrg
96469f606849Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
9647d5c3dbf1Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
96489f606849Smrg# ### END LIBTOOL TAG CONFIG: disable-static
96499f606849Smrg
96509f606849Smrg# Local Variables:
96519f606849Smrg# mode:shell-script
96529f606849Smrg# sh-indentation:2
96539f606849Smrg# End:
9654d5c3dbf1Smrg# vi:sw=2
9655d5c3dbf1Smrg
9656