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