ltmain.sh revision 555991fd
1d656433aSmrg# Generated from ltmain.m4sh.
2d656433aSmrg
3555991fdSmrg# libtool (GNU libtool) 2.2.10
4d656433aSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
5d656433aSmrg
6555991fdSmrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
7555991fdSmrg# 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
8d656433aSmrg# This is free software; see the source for copying conditions.  There is NO
9d656433aSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10d656433aSmrg
11d656433aSmrg# GNU Libtool is free software; you can redistribute it and/or modify
12126a8a12Smrg# it under the terms of the GNU General Public License as published by
13126a8a12Smrg# the Free Software Foundation; either version 2 of the License, or
14126a8a12Smrg# (at your option) any later version.
15126a8a12Smrg#
16d656433aSmrg# As a special exception to the GNU General Public License,
17d656433aSmrg# if you distribute this file as part of a program or library that
18d656433aSmrg# is built using GNU Libtool, you may include this file under the
19d656433aSmrg# same distribution terms that you use for the rest of that program.
20d656433aSmrg#
21d656433aSmrg# GNU Libtool is distributed in the hope that it will be useful, but
22126a8a12Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
23126a8a12Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
24126a8a12Smrg# General Public License for more details.
25126a8a12Smrg#
26126a8a12Smrg# You should have received a copy of the GNU General Public License
27d656433aSmrg# along with GNU Libtool; see the file COPYING.  If not, a copy
28d656433aSmrg# can be downloaded from http://www.gnu.org/licenses/gpl.html,
29d656433aSmrg# or obtained by writing to the Free Software Foundation, Inc.,
30d656433aSmrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
31d656433aSmrg
32d656433aSmrg# Usage: $progname [OPTION]... [MODE-ARG]...
33d656433aSmrg#
34d656433aSmrg# Provide generalized library-building support services.
35126a8a12Smrg#
36555991fdSmrg#       --config             show all configuration variables
37555991fdSmrg#       --debug              enable verbose shell tracing
38555991fdSmrg#   -n, --dry-run            display commands without modifying any files
39555991fdSmrg#       --features           display basic configuration information and exit
40555991fdSmrg#       --mode=MODE          use operation mode MODE
41555991fdSmrg#       --preserve-dup-deps  don't remove duplicate dependency libraries
42555991fdSmrg#       --quiet, --silent    don't print informational messages
43555991fdSmrg#       --no-quiet, --no-silent
44555991fdSmrg#                            print informational messages (default)
45555991fdSmrg#       --tag=TAG            use configuration variables from tag TAG
46555991fdSmrg#   -v, --verbose            print more informational messages than default
47555991fdSmrg#       --no-verbose         don't print the extra informational messages
48555991fdSmrg#       --version            print version information
49555991fdSmrg#   -h, --help, --help-all   print short, long, or detailed help message
50d656433aSmrg#
51d656433aSmrg# MODE must be one of the following:
52d656433aSmrg#
53555991fdSmrg#         clean              remove files from the build directory
54555991fdSmrg#         compile            compile a source file into a libtool object
55555991fdSmrg#         execute            automatically set library path, then run a program
56555991fdSmrg#         finish             complete the installation of libtool libraries
57555991fdSmrg#         install            install libraries or executables
58555991fdSmrg#         link               create a library or an executable
59555991fdSmrg#         uninstall          remove libraries from an installed directory
60d656433aSmrg#
61555991fdSmrg# MODE-ARGS vary depending on the MODE.  When passed as first option,
62555991fdSmrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
63d656433aSmrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
64d656433aSmrg#
65d656433aSmrg# When reporting a bug, please describe a test case to reproduce it and
66d656433aSmrg# include the following information:
67d656433aSmrg#
68555991fdSmrg#         host-triplet:	$host
69555991fdSmrg#         shell:		$SHELL
70555991fdSmrg#         compiler:		$LTCC
71555991fdSmrg#         compiler flags:		$LTCFLAGS
72555991fdSmrg#         linker:		$LD (gnu? $with_gnu_ld)
73555991fdSmrg#         $progname:	(GNU libtool) 2.2.10
74555991fdSmrg#         automake:	$automake_version
75555991fdSmrg#         autoconf:	$autoconf_version
76d656433aSmrg#
77d656433aSmrg# Report bugs to <bug-libtool@gnu.org>.
78d656433aSmrg
79555991fdSmrgPROGRAM=libtool
80d656433aSmrgPACKAGE=libtool
81555991fdSmrgVERSION=2.2.10
82d656433aSmrgTIMESTAMP=""
83555991fdSmrgpackage_revision=1.3175
84d656433aSmrg
85d656433aSmrg# Be Bourne compatible
86d656433aSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
87d656433aSmrg  emulate sh
88d656433aSmrg  NULLCMD=:
89d656433aSmrg  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
90d656433aSmrg  # is contrary to our usage.  Disable this feature.
91d656433aSmrg  alias -g '${1+"$@"}'='"$@"'
92d656433aSmrg  setopt NO_GLOB_SUBST
93d656433aSmrgelse
94d656433aSmrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
95d656433aSmrgfi
96d656433aSmrgBIN_SH=xpg4; export BIN_SH # for Tru64
97d656433aSmrgDUALCASE=1; export DUALCASE # for MKS sh
98d656433aSmrg
99555991fdSmrg# A function that is used when there is no print builtin or printf.
100555991fdSmrgfunc_fallback_echo ()
101555991fdSmrg{
102555991fdSmrg  eval 'cat <<_LTECHO_EOF
103555991fdSmrg$1
104555991fdSmrg_LTECHO_EOF'
105555991fdSmrg}
106555991fdSmrg
107d656433aSmrg# NLS nuisances: We save the old values to restore during execute mode.
108d656433aSmrglt_user_locale=
109d656433aSmrglt_safe_locale=
110d656433aSmrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
111d656433aSmrgdo
112d656433aSmrg  eval "if test \"\${$lt_var+set}\" = set; then
113d656433aSmrg          save_$lt_var=\$$lt_var
114d656433aSmrg          $lt_var=C
115d656433aSmrg	  export $lt_var
116d656433aSmrg	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
117d656433aSmrg	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
118d656433aSmrg	fi"
119d656433aSmrgdone
120555991fdSmrgLC_ALL=C
121555991fdSmrgLANGUAGE=C
122555991fdSmrgexport LANGUAGE LC_ALL
123d656433aSmrg
124d656433aSmrg$lt_unset CDPATH
125d656433aSmrg
126d656433aSmrg
127555991fdSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
128555991fdSmrg# is ksh but when the shell is invoked as "sh" and the current value of
129555991fdSmrg# the _XPG environment variable is not equal to 1 (one), the special
130555991fdSmrg# positional parameter $0, within a function call, is the name of the
131555991fdSmrg# function.
132555991fdSmrgprogpath="$0"
133d656433aSmrg
134d656433aSmrg
135d656433aSmrg
136d656433aSmrg: ${CP="cp -f"}
137555991fdSmrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
138555991fdSmrg: ${EGREP="grep -E"}
139555991fdSmrg: ${FGREP="grep -F"}
140555991fdSmrg: ${GREP="grep"}
141d656433aSmrg: ${LN_S="ln -s"}
142d656433aSmrg: ${MAKE="make"}
143d656433aSmrg: ${MKDIR="mkdir"}
144d656433aSmrg: ${MV="mv -f"}
145d656433aSmrg: ${RM="rm -f"}
146555991fdSmrg: ${SED="sed"}
147d656433aSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
148d656433aSmrg: ${Xsed="$SED -e 1s/^X//"}
149126a8a12Smrg
150d656433aSmrg# Global variables:
151d656433aSmrgEXIT_SUCCESS=0
152d656433aSmrgEXIT_FAILURE=1
153d656433aSmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
154d656433aSmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
155d656433aSmrg
156d656433aSmrgexit_status=$EXIT_SUCCESS
157d656433aSmrg
158d656433aSmrg# Make sure IFS has a sensible default
159d656433aSmrglt_nl='
160d656433aSmrg'
161d656433aSmrgIFS=" 	$lt_nl"
162d656433aSmrg
163d656433aSmrgdirname="s,/[^/]*$,,"
164d656433aSmrgbasename="s,^.*/,,"
165d656433aSmrg
166d656433aSmrg# func_dirname_and_basename file append nondir_replacement
167d656433aSmrg# perform func_basename and func_dirname in a single function
168d656433aSmrg# call:
169d656433aSmrg#   dirname:  Compute the dirname of FILE.  If nonempty,
170d656433aSmrg#             add APPEND to the result, otherwise set result
171d656433aSmrg#             to NONDIR_REPLACEMENT.
172d656433aSmrg#             value returned in "$func_dirname_result"
173d656433aSmrg#   basename: Compute filename of FILE.
174d656433aSmrg#             value retuned in "$func_basename_result"
175d656433aSmrg# Implementation must be kept synchronized with func_dirname
176d656433aSmrg# and func_basename. For efficiency, we do not delegate to
177d656433aSmrg# those functions but instead duplicate the functionality here.
178d656433aSmrgfunc_dirname_and_basename ()
179d656433aSmrg{
180d656433aSmrg  # Extract subdirectory from the argument.
181555991fdSmrg  func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
182d656433aSmrg  if test "X$func_dirname_result" = "X${1}"; then
183d656433aSmrg    func_dirname_result="${3}"
184d656433aSmrg  else
185d656433aSmrg    func_dirname_result="$func_dirname_result${2}"
186d656433aSmrg  fi
187555991fdSmrg  func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
188d656433aSmrg}
189d656433aSmrg
190d656433aSmrg# Generated shell functions inserted here.
191126a8a12Smrg
192555991fdSmrg# These SED scripts presuppose an absolute path with a trailing slash.
193555991fdSmrgpathcar='s,^/\([^/]*\).*$,\1,'
194555991fdSmrgpathcdr='s,^/[^/]*,,'
195555991fdSmrgremovedotparts=':dotsl
196555991fdSmrg		s@/\./@/@g
197555991fdSmrg		t dotsl
198555991fdSmrg		s,/\.$,/,'
199555991fdSmrgcollapseslashes='s@/\{1,\}@/@g'
200555991fdSmrgfinalslash='s,/*$,/,'
201555991fdSmrg
202555991fdSmrg# func_normal_abspath PATH
203555991fdSmrg# Remove doubled-up and trailing slashes, "." path components,
204555991fdSmrg# and cancel out any ".." path components in PATH after making
205555991fdSmrg# it an absolute path.
206555991fdSmrg#             value returned in "$func_normal_abspath_result"
207555991fdSmrgfunc_normal_abspath ()
208555991fdSmrg{
209555991fdSmrg  # Start from root dir and reassemble the path.
210555991fdSmrg  func_normal_abspath_result=
211555991fdSmrg  func_normal_abspath_tpath=$1
212555991fdSmrg  func_normal_abspath_altnamespace=
213555991fdSmrg  case $func_normal_abspath_tpath in
214555991fdSmrg    "")
215555991fdSmrg      # Empty path, that just means $cwd.
216555991fdSmrg      func_stripname '' '/' "`pwd`"
217555991fdSmrg      func_normal_abspath_result=$func_stripname_result
218555991fdSmrg      return
219555991fdSmrg    ;;
220555991fdSmrg    # The next three entries are used to spot a run of precisely
221555991fdSmrg    # two leading slashes without using negated character classes;
222555991fdSmrg    # we take advantage of case's first-match behaviour.
223555991fdSmrg    ///*)
224555991fdSmrg      # Unusual form of absolute path, do nothing.
225555991fdSmrg    ;;
226555991fdSmrg    //*)
227555991fdSmrg      # Not necessarily an ordinary path; POSIX reserves leading '//'
228555991fdSmrg      # and for example Cygwin uses it to access remote file shares
229555991fdSmrg      # over CIFS/SMB, so we conserve a leading double slash if found.
230555991fdSmrg      func_normal_abspath_altnamespace=/
231555991fdSmrg    ;;
232555991fdSmrg    /*)
233555991fdSmrg      # Absolute path, do nothing.
234555991fdSmrg    ;;
235555991fdSmrg    *)
236555991fdSmrg      # Relative path, prepend $cwd.
237555991fdSmrg      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
238555991fdSmrg    ;;
239555991fdSmrg  esac
240555991fdSmrg  # Cancel out all the simple stuff to save iterations.  We also want
241555991fdSmrg  # the path to end with a slash for ease of parsing, so make sure
242555991fdSmrg  # there is one (and only one) here.
243555991fdSmrg  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
244555991fdSmrg        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
245555991fdSmrg  while :; do
246555991fdSmrg    # Processed it all yet?
247555991fdSmrg    if test "$func_normal_abspath_tpath" = / ; then
248555991fdSmrg      # If we ascended to the root using ".." the result may be empty now.
249555991fdSmrg      if test -z "$func_normal_abspath_result" ; then
250555991fdSmrg        func_normal_abspath_result=/
251555991fdSmrg      fi
252555991fdSmrg      break
253555991fdSmrg    fi
254555991fdSmrg    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
255555991fdSmrg        -e "$pathcar"`
256555991fdSmrg    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
257555991fdSmrg        -e "$pathcdr"`
258555991fdSmrg    # Figure out what to do with it
259555991fdSmrg    case $func_normal_abspath_tcomponent in
260555991fdSmrg      "")
261555991fdSmrg        # Trailing empty path component, ignore it.
262555991fdSmrg      ;;
263555991fdSmrg      ..)
264555991fdSmrg        # Parent dir; strip last assembled component from result.
265555991fdSmrg        func_dirname "$func_normal_abspath_result"
266555991fdSmrg        func_normal_abspath_result=$func_dirname_result
267555991fdSmrg      ;;
268555991fdSmrg      *)
269555991fdSmrg        # Actual path component, append it.
270555991fdSmrg        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
271555991fdSmrg      ;;
272555991fdSmrg    esac
273555991fdSmrg  done
274555991fdSmrg  # Restore leading double-slash if one was found on entry.
275555991fdSmrg  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
276555991fdSmrg}
277555991fdSmrg
278555991fdSmrg# func_relative_path SRCDIR DSTDIR
279555991fdSmrg# generates a relative path from SRCDIR to DSTDIR, with a trailing
280555991fdSmrg# slash if non-empty, suitable for immediately appending a filename
281555991fdSmrg# without needing to append a separator.
282555991fdSmrg#             value returned in "$func_relative_path_result"
283555991fdSmrgfunc_relative_path ()
284555991fdSmrg{
285555991fdSmrg  func_relative_path_result=
286555991fdSmrg  func_normal_abspath "$1"
287555991fdSmrg  func_relative_path_tlibdir=$func_normal_abspath_result
288555991fdSmrg  func_normal_abspath "$2"
289555991fdSmrg  func_relative_path_tbindir=$func_normal_abspath_result
290555991fdSmrg
291555991fdSmrg  # Ascend the tree starting from libdir
292555991fdSmrg  while :; do
293555991fdSmrg    # check if we have found a prefix of bindir
294555991fdSmrg    case $func_relative_path_tbindir in
295555991fdSmrg      $func_relative_path_tlibdir)
296555991fdSmrg        # found an exact match
297555991fdSmrg        func_relative_path_tcancelled=
298555991fdSmrg        break
299555991fdSmrg        ;;
300555991fdSmrg      $func_relative_path_tlibdir*)
301555991fdSmrg        # found a matching prefix
302555991fdSmrg        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
303555991fdSmrg        func_relative_path_tcancelled=$func_stripname_result
304555991fdSmrg        if test -z "$func_relative_path_result"; then
305555991fdSmrg          func_relative_path_result=.
306555991fdSmrg        fi
307555991fdSmrg        break
308555991fdSmrg        ;;
309555991fdSmrg      *)
310555991fdSmrg        func_dirname $func_relative_path_tlibdir
311555991fdSmrg        func_relative_path_tlibdir=${func_dirname_result}
312555991fdSmrg        if test "x$func_relative_path_tlibdir" = x ; then
313555991fdSmrg          # Have to descend all the way to the root!
314555991fdSmrg          func_relative_path_result=../$func_relative_path_result
315555991fdSmrg          func_relative_path_tcancelled=$func_relative_path_tbindir
316555991fdSmrg          break
317555991fdSmrg        fi
318555991fdSmrg        func_relative_path_result=../$func_relative_path_result
319555991fdSmrg        ;;
320555991fdSmrg    esac
321555991fdSmrg  done
322555991fdSmrg
323555991fdSmrg  # Now calculate path; take care to avoid doubling-up slashes.
324555991fdSmrg  func_stripname '' '/' "$func_relative_path_result"
325555991fdSmrg  func_relative_path_result=$func_stripname_result
326555991fdSmrg  func_stripname '/' '/' "$func_relative_path_tcancelled"
327555991fdSmrg  if test "x$func_stripname_result" != x ; then
328555991fdSmrg    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
329555991fdSmrg  fi
330555991fdSmrg
331555991fdSmrg  # Normalisation. If bindir is libdir, return empty string,
332555991fdSmrg  # else relative path ending with a slash; either way, target
333555991fdSmrg  # file name can be directly appended.
334555991fdSmrg  if test ! -z "$func_relative_path_result"; then
335555991fdSmrg    func_stripname './' '' "$func_relative_path_result/"
336555991fdSmrg    func_relative_path_result=$func_stripname_result
337555991fdSmrg  fi
338555991fdSmrg}
339126a8a12Smrg
340126a8a12Smrg# The name of this program:
341d656433aSmrgfunc_dirname_and_basename "$progpath"
342d656433aSmrgprogname=$func_basename_result
343126a8a12Smrg
344d656433aSmrg# Make sure we have an absolute path for reexecution:
345d656433aSmrgcase $progpath in
346d656433aSmrg  [\\/]*|[A-Za-z]:\\*) ;;
347d656433aSmrg  *[\\/]*)
348d656433aSmrg     progdir=$func_dirname_result
349d656433aSmrg     progdir=`cd "$progdir" && pwd`
350d656433aSmrg     progpath="$progdir/$progname"
351d656433aSmrg     ;;
352d656433aSmrg  *)
353d656433aSmrg     save_IFS="$IFS"
354d656433aSmrg     IFS=:
355d656433aSmrg     for progdir in $PATH; do
356d656433aSmrg       IFS="$save_IFS"
357d656433aSmrg       test -x "$progdir/$progname" && break
358d656433aSmrg     done
359d656433aSmrg     IFS="$save_IFS"
360d656433aSmrg     test -n "$progdir" || progdir=`pwd`
361d656433aSmrg     progpath="$progdir/$progname"
362d656433aSmrg     ;;
363d656433aSmrgesac
364126a8a12Smrg
365d656433aSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
366d656433aSmrg# metacharacters that are still active within double-quoted strings.
367d656433aSmrgXsed="${SED}"' -e 1s/^X//'
368d656433aSmrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g'
369d656433aSmrg
370d656433aSmrg# Same as above, but do not quote variable references.
371d656433aSmrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g'
372d656433aSmrg
373d656433aSmrg# Re-`\' parameter expansions in output of double_quote_subst that were
374d656433aSmrg# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
375d656433aSmrg# in input to double_quote_subst, that '$' was protected from expansion.
376d656433aSmrg# Since each input `\' is now two `\'s, look for any number of runs of
377d656433aSmrg# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
378d656433aSmrgbs='\\'
379d656433aSmrgbs2='\\\\'
380d656433aSmrgbs4='\\\\\\\\'
381d656433aSmrgdollar='\$'
382d656433aSmrgsed_double_backslash="\
383d656433aSmrg  s/$bs4/&\\
384d656433aSmrg/g
385d656433aSmrg  s/^$bs2$dollar/$bs&/
386d656433aSmrg  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
387d656433aSmrg  s/\n//g"
388d656433aSmrg
389d656433aSmrg# Standard options:
390d656433aSmrgopt_dry_run=false
391d656433aSmrgopt_help=false
392d656433aSmrgopt_quiet=false
393d656433aSmrgopt_verbose=false
394d656433aSmrgopt_warning=:
395d656433aSmrg
396d656433aSmrg# func_echo arg...
397d656433aSmrg# Echo program name prefixed message, along with the current mode
398d656433aSmrg# name if it has been set yet.
399d656433aSmrgfunc_echo ()
400d656433aSmrg{
401d656433aSmrg    $ECHO "$progname${mode+: }$mode: $*"
402d656433aSmrg}
403126a8a12Smrg
404d656433aSmrg# func_verbose arg...
405d656433aSmrg# Echo program name prefixed message in verbose mode only.
406d656433aSmrgfunc_verbose ()
407d656433aSmrg{
408d656433aSmrg    $opt_verbose && func_echo ${1+"$@"}
409126a8a12Smrg
410d656433aSmrg    # A bug in bash halts the script if the last line of a function
411d656433aSmrg    # fails when set -e is in force, so we need another command to
412d656433aSmrg    # work around that:
413d656433aSmrg    :
414d656433aSmrg}
415126a8a12Smrg
416555991fdSmrg# func_echo_all arg...
417555991fdSmrg# Invoke $ECHO with all args, space-separated.
418555991fdSmrgfunc_echo_all ()
419555991fdSmrg{
420555991fdSmrg    $ECHO "$*"
421555991fdSmrg}
422555991fdSmrg
423d656433aSmrg# func_error arg...
424d656433aSmrg# Echo program name prefixed message to standard error.
425d656433aSmrgfunc_error ()
426d656433aSmrg{
427d656433aSmrg    $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2
428d656433aSmrg}
429126a8a12Smrg
430d656433aSmrg# func_warning arg...
431d656433aSmrg# Echo program name prefixed warning message to standard error.
432d656433aSmrgfunc_warning ()
433d656433aSmrg{
434d656433aSmrg    $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2
435126a8a12Smrg
436d656433aSmrg    # bash bug again:
437d656433aSmrg    :
438d656433aSmrg}
439126a8a12Smrg
440d656433aSmrg# func_fatal_error arg...
441d656433aSmrg# Echo program name prefixed message to standard error, and exit.
442d656433aSmrgfunc_fatal_error ()
443d656433aSmrg{
444d656433aSmrg    func_error ${1+"$@"}
445d656433aSmrg    exit $EXIT_FAILURE
446d656433aSmrg}
447126a8a12Smrg
448d656433aSmrg# func_fatal_help arg...
449d656433aSmrg# Echo program name prefixed message to standard error, followed by
450d656433aSmrg# a help hint, and exit.
451d656433aSmrgfunc_fatal_help ()
452d656433aSmrg{
453d656433aSmrg    func_error ${1+"$@"}
454d656433aSmrg    func_fatal_error "$help"
455d656433aSmrg}
456d656433aSmrghelp="Try \`$progname --help' for more information."  ## default
457126a8a12Smrg
458126a8a12Smrg
459d656433aSmrg# func_grep expression filename
460d656433aSmrg# Check whether EXPRESSION matches any line of FILENAME, without output.
461d656433aSmrgfunc_grep ()
462d656433aSmrg{
463d656433aSmrg    $GREP "$1" "$2" >/dev/null 2>&1
464d656433aSmrg}
465d656433aSmrg
466d656433aSmrg
467d656433aSmrg# func_mkdir_p directory-path
468d656433aSmrg# Make sure the entire path to DIRECTORY-PATH is available.
469d656433aSmrgfunc_mkdir_p ()
470d656433aSmrg{
471d656433aSmrg    my_directory_path="$1"
472d656433aSmrg    my_dir_list=
473d656433aSmrg
474d656433aSmrg    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
475d656433aSmrg
476d656433aSmrg      # Protect directory names starting with `-'
477d656433aSmrg      case $my_directory_path in
478d656433aSmrg        -*) my_directory_path="./$my_directory_path" ;;
479d656433aSmrg      esac
480d656433aSmrg
481d656433aSmrg      # While some portion of DIR does not yet exist...
482d656433aSmrg      while test ! -d "$my_directory_path"; do
483d656433aSmrg        # ...make a list in topmost first order.  Use a colon delimited
484d656433aSmrg	# list incase some portion of path contains whitespace.
485d656433aSmrg        my_dir_list="$my_directory_path:$my_dir_list"
486d656433aSmrg
487d656433aSmrg        # If the last portion added has no slash in it, the list is done
488d656433aSmrg        case $my_directory_path in */*) ;; *) break ;; esac
489d656433aSmrg
490d656433aSmrg        # ...otherwise throw away the child directory and loop
491555991fdSmrg        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
492d656433aSmrg      done
493555991fdSmrg      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
494d656433aSmrg
495d656433aSmrg      save_mkdir_p_IFS="$IFS"; IFS=':'
496d656433aSmrg      for my_dir in $my_dir_list; do
497d656433aSmrg	IFS="$save_mkdir_p_IFS"
498d656433aSmrg        # mkdir can fail with a `File exist' error if two processes
499d656433aSmrg        # try to create one of the directories concurrently.  Don't
500d656433aSmrg        # stop in that case!
501d656433aSmrg        $MKDIR "$my_dir" 2>/dev/null || :
502d656433aSmrg      done
503d656433aSmrg      IFS="$save_mkdir_p_IFS"
504d656433aSmrg
505d656433aSmrg      # Bail out if we (or some other process) failed to create a directory.
506d656433aSmrg      test -d "$my_directory_path" || \
507d656433aSmrg        func_fatal_error "Failed to create \`$1'"
508d656433aSmrg    fi
509d656433aSmrg}
510126a8a12Smrg
511126a8a12Smrg
512126a8a12Smrg# func_mktempdir [string]
513126a8a12Smrg# Make a temporary directory that won't clash with other running
514126a8a12Smrg# libtool processes, and avoids race conditions if possible.  If
515126a8a12Smrg# given, STRING is the basename for that directory.
516126a8a12Smrgfunc_mktempdir ()
517126a8a12Smrg{
518126a8a12Smrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
519126a8a12Smrg
520d656433aSmrg    if test "$opt_dry_run" = ":"; then
521126a8a12Smrg      # Return a directory name, but don't create it in dry-run mode
522126a8a12Smrg      my_tmpdir="${my_template}-$$"
523126a8a12Smrg    else
524126a8a12Smrg
525126a8a12Smrg      # If mktemp works, use that first and foremost
526126a8a12Smrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
527126a8a12Smrg
528126a8a12Smrg      if test ! -d "$my_tmpdir"; then
529d656433aSmrg        # Failing that, at least try and use $RANDOM to avoid a race
530d656433aSmrg        my_tmpdir="${my_template}-${RANDOM-0}$$"
531126a8a12Smrg
532d656433aSmrg        save_mktempdir_umask=`umask`
533d656433aSmrg        umask 0077
534d656433aSmrg        $MKDIR "$my_tmpdir"
535d656433aSmrg        umask $save_mktempdir_umask
536126a8a12Smrg      fi
537126a8a12Smrg
538126a8a12Smrg      # If we're not in dry-run mode, bomb out on failure
539d656433aSmrg      test -d "$my_tmpdir" || \
540d656433aSmrg        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
541126a8a12Smrg    fi
542126a8a12Smrg
543555991fdSmrg    $ECHO "$my_tmpdir"
544126a8a12Smrg}
545126a8a12Smrg
546126a8a12Smrg
547d656433aSmrg# func_quote_for_eval arg
548d656433aSmrg# Aesthetically quote ARG to be evaled later.
549d656433aSmrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
550d656433aSmrg# is double-quoted, suitable for a subsequent eval, whereas
551d656433aSmrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
552d656433aSmrg# which are still active within double quotes backslashified.
553d656433aSmrgfunc_quote_for_eval ()
554126a8a12Smrg{
555d656433aSmrg    case $1 in
556d656433aSmrg      *[\\\`\"\$]*)
557555991fdSmrg	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
558d656433aSmrg      *)
559d656433aSmrg        func_quote_for_eval_unquoted_result="$1" ;;
560d656433aSmrg    esac
561d656433aSmrg
562d656433aSmrg    case $func_quote_for_eval_unquoted_result in
563d656433aSmrg      # Double-quote args containing shell metacharacters to delay
564d656433aSmrg      # word splitting, command substitution and and variable
565d656433aSmrg      # expansion for a subsequent eval.
566d656433aSmrg      # Many Bourne shells cannot handle close brackets correctly
567d656433aSmrg      # in scan sets, so we specify it separately.
568d656433aSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
569d656433aSmrg        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
570d656433aSmrg        ;;
571d656433aSmrg      *)
572d656433aSmrg        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
573126a8a12Smrg    esac
574126a8a12Smrg}
575126a8a12Smrg
576126a8a12Smrg
577d656433aSmrg# func_quote_for_expand arg
578d656433aSmrg# Aesthetically quote ARG to be evaled later; same as above,
579d656433aSmrg# but do not quote variable references.
580d656433aSmrgfunc_quote_for_expand ()
581126a8a12Smrg{
582d656433aSmrg    case $1 in
583d656433aSmrg      *[\\\`\"]*)
584555991fdSmrg	my_arg=`$ECHO "$1" | $SED \
585d656433aSmrg	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
586126a8a12Smrg      *)
587d656433aSmrg        my_arg="$1" ;;
588d656433aSmrg    esac
589d656433aSmrg
590d656433aSmrg    case $my_arg in
591d656433aSmrg      # Double-quote args containing shell metacharacters to delay
592d656433aSmrg      # word splitting and command substitution for a subsequent eval.
593d656433aSmrg      # Many Bourne shells cannot handle close brackets correctly
594d656433aSmrg      # in scan sets, so we specify it separately.
595d656433aSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
596d656433aSmrg        my_arg="\"$my_arg\""
597d656433aSmrg        ;;
598d656433aSmrg    esac
599d656433aSmrg
600d656433aSmrg    func_quote_for_expand_result="$my_arg"
601126a8a12Smrg}
602126a8a12Smrg
603126a8a12Smrg
604d656433aSmrg# func_show_eval cmd [fail_exp]
605d656433aSmrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
606d656433aSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
607d656433aSmrg# is given, then evaluate it.
608d656433aSmrgfunc_show_eval ()
609126a8a12Smrg{
610d656433aSmrg    my_cmd="$1"
611d656433aSmrg    my_fail_exp="${2-:}"
612126a8a12Smrg
613d656433aSmrg    ${opt_silent-false} || {
614d656433aSmrg      func_quote_for_expand "$my_cmd"
615d656433aSmrg      eval "func_echo $func_quote_for_expand_result"
616d656433aSmrg    }
617d656433aSmrg
618d656433aSmrg    if ${opt_dry_run-false}; then :; else
619d656433aSmrg      eval "$my_cmd"
620d656433aSmrg      my_status=$?
621d656433aSmrg      if test "$my_status" -eq 0; then :; else
622d656433aSmrg	eval "(exit $my_status); $my_fail_exp"
623d656433aSmrg      fi
624126a8a12Smrg    fi
625126a8a12Smrg}
626126a8a12Smrg
627d656433aSmrg
628d656433aSmrg# func_show_eval_locale cmd [fail_exp]
629d656433aSmrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
630d656433aSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
631d656433aSmrg# is given, then evaluate it.  Use the saved locale for evaluation.
632d656433aSmrgfunc_show_eval_locale ()
633126a8a12Smrg{
634d656433aSmrg    my_cmd="$1"
635d656433aSmrg    my_fail_exp="${2-:}"
636126a8a12Smrg
637d656433aSmrg    ${opt_silent-false} || {
638d656433aSmrg      func_quote_for_expand "$my_cmd"
639d656433aSmrg      eval "func_echo $func_quote_for_expand_result"
640d656433aSmrg    }
641d656433aSmrg
642d656433aSmrg    if ${opt_dry_run-false}; then :; else
643d656433aSmrg      eval "$lt_user_locale
644d656433aSmrg	    $my_cmd"
645d656433aSmrg      my_status=$?
646d656433aSmrg      eval "$lt_safe_locale"
647d656433aSmrg      if test "$my_status" -eq 0; then :; else
648d656433aSmrg	eval "(exit $my_status); $my_fail_exp"
649126a8a12Smrg      fi
650d656433aSmrg    fi
651126a8a12Smrg}
652126a8a12Smrg
653126a8a12Smrg
654d656433aSmrg# func_version
655d656433aSmrg# Echo version message to standard output and exit.
656d656433aSmrgfunc_version ()
657d656433aSmrg{
658555991fdSmrg    $SED -n '/(C)/!b go
659555991fdSmrg	:more
660555991fdSmrg	/\./!{
661555991fdSmrg	  N
662555991fdSmrg	  s/\n# / /
663555991fdSmrg	  b more
664555991fdSmrg	}
665555991fdSmrg	:go
666555991fdSmrg	/^# '$PROGRAM' (GNU /,/# warranty; / {
667d656433aSmrg        s/^# //
668d656433aSmrg	s/^# *$//
669d656433aSmrg        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
670d656433aSmrg        p
671d656433aSmrg     }' < "$progpath"
672d656433aSmrg     exit $?
673d656433aSmrg}
674d656433aSmrg
675d656433aSmrg# func_usage
676d656433aSmrg# Echo short help message to standard output and exit.
677d656433aSmrgfunc_usage ()
678d656433aSmrg{
679555991fdSmrg    $SED -n '/^# Usage:/,/^#  *.*--help/ {
680d656433aSmrg        s/^# //
681d656433aSmrg	s/^# *$//
682d656433aSmrg	s/\$progname/'$progname'/
683d656433aSmrg	p
684d656433aSmrg    }' < "$progpath"
685555991fdSmrg    echo
686d656433aSmrg    $ECHO "run \`$progname --help | more' for full usage"
687d656433aSmrg    exit $?
688d656433aSmrg}
689d656433aSmrg
690555991fdSmrg# func_help [NOEXIT]
691555991fdSmrg# Echo long help message to standard output and exit,
692555991fdSmrg# unless 'noexit' is passed as argument.
693d656433aSmrgfunc_help ()
694d656433aSmrg{
695d656433aSmrg    $SED -n '/^# Usage:/,/# Report bugs to/ {
696d656433aSmrg        s/^# //
697d656433aSmrg	s/^# *$//
698d656433aSmrg	s*\$progname*'$progname'*
699d656433aSmrg	s*\$host*'"$host"'*
700d656433aSmrg	s*\$SHELL*'"$SHELL"'*
701d656433aSmrg	s*\$LTCC*'"$LTCC"'*
702d656433aSmrg	s*\$LTCFLAGS*'"$LTCFLAGS"'*
703d656433aSmrg	s*\$LD*'"$LD"'*
704d656433aSmrg	s/\$with_gnu_ld/'"$with_gnu_ld"'/
705d656433aSmrg	s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
706d656433aSmrg	s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
707d656433aSmrg	p
708d656433aSmrg     }' < "$progpath"
709555991fdSmrg    ret=$?
710555991fdSmrg    if test -z "$1"; then
711555991fdSmrg      exit $ret
712555991fdSmrg    fi
713d656433aSmrg}
714d656433aSmrg
715d656433aSmrg# func_missing_arg argname
716d656433aSmrg# Echo program name prefixed message to standard error and set global
717d656433aSmrg# exit_cmd.
718d656433aSmrgfunc_missing_arg ()
719d656433aSmrg{
720555991fdSmrg    func_error "missing argument for $1."
721d656433aSmrg    exit_cmd=exit
722d656433aSmrg}
723d656433aSmrg
724d656433aSmrgexit_cmd=:
725d656433aSmrg
726d656433aSmrg
727d656433aSmrg
728d656433aSmrg
729d656433aSmrg
730126a8a12Smrg
731d656433aSmrgmagic="%%%MAGIC variable%%%"
732d656433aSmrgmagic_exe="%%%MAGIC EXE variable%%%"
733126a8a12Smrg
734d656433aSmrg# Global variables.
735d656433aSmrg# $mode is unset
736d656433aSmrgnonopt=
737d656433aSmrgexecute_dlfiles=
738d656433aSmrgpreserve_args=
739d656433aSmrglo2o="s/\\.lo\$/.${objext}/"
740d656433aSmrgo2lo="s/\\.${objext}\$/.lo/"
741d656433aSmrgextracted_archives=
742d656433aSmrgextracted_serial=0
743126a8a12Smrg
744d656433aSmrgopt_dry_run=false
745d656433aSmrgopt_duplicate_deps=false
746d656433aSmrgopt_silent=false
747d656433aSmrgopt_debug=:
748126a8a12Smrg
749d656433aSmrg# If this variable is set in any of the actions, the command in it
750d656433aSmrg# will be execed at the end.  This prevents here-documents from being
751d656433aSmrg# left over by shells.
752d656433aSmrgexec_cmd=
753126a8a12Smrg
754d656433aSmrg# func_fatal_configuration arg...
755d656433aSmrg# Echo program name prefixed message to standard error, followed by
756d656433aSmrg# a configuration failure hint, and exit.
757d656433aSmrgfunc_fatal_configuration ()
758d656433aSmrg{
759d656433aSmrg    func_error ${1+"$@"}
760d656433aSmrg    func_error "See the $PACKAGE documentation for more information."
761d656433aSmrg    func_fatal_error "Fatal configuration error."
762d656433aSmrg}
763d656433aSmrg
764d656433aSmrg
765d656433aSmrg# func_config
766d656433aSmrg# Display the configuration for all the tags in this script.
767d656433aSmrgfunc_config ()
768d656433aSmrg{
769d656433aSmrg    re_begincf='^# ### BEGIN LIBTOOL'
770d656433aSmrg    re_endcf='^# ### END LIBTOOL'
771d656433aSmrg
772d656433aSmrg    # Default configuration.
773d656433aSmrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
774126a8a12Smrg
775126a8a12Smrg    # Now print the configurations for the tags.
776126a8a12Smrg    for tagname in $taglist; do
777d656433aSmrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
778126a8a12Smrg    done
779126a8a12Smrg
780d656433aSmrg    exit $?
781d656433aSmrg}
782126a8a12Smrg
783d656433aSmrg# func_features
784d656433aSmrg# Display the features supported by this script.
785d656433aSmrgfunc_features ()
786d656433aSmrg{
787555991fdSmrg    echo "host: $host"
788126a8a12Smrg    if test "$build_libtool_libs" = yes; then
789555991fdSmrg      echo "enable shared libraries"
790126a8a12Smrg    else
791555991fdSmrg      echo "disable shared libraries"
792126a8a12Smrg    fi
793126a8a12Smrg    if test "$build_old_libs" = yes; then
794555991fdSmrg      echo "enable static libraries"
795126a8a12Smrg    else
796555991fdSmrg      echo "disable static libraries"
797126a8a12Smrg    fi
798d656433aSmrg
799126a8a12Smrg    exit $?
800d656433aSmrg}
801126a8a12Smrg
802d656433aSmrg# func_enable_tag tagname
803d656433aSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or
804d656433aSmrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
805d656433aSmrg# variable here.
806d656433aSmrgfunc_enable_tag ()
807d656433aSmrg{
808d656433aSmrg  # Global variable:
809d656433aSmrg  tagname="$1"
810126a8a12Smrg
811d656433aSmrg  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
812d656433aSmrg  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
813d656433aSmrg  sed_extractcf="/$re_begincf/,/$re_endcf/p"
814126a8a12Smrg
815d656433aSmrg  # Validate tagname.
816d656433aSmrg  case $tagname in
817d656433aSmrg    *[!-_A-Za-z0-9,/]*)
818d656433aSmrg      func_fatal_error "invalid tag name: $tagname"
819d656433aSmrg      ;;
820d656433aSmrg  esac
821126a8a12Smrg
822d656433aSmrg  # Don't test for the "default" C tag, as we know it's
823d656433aSmrg  # there but not specially marked.
824d656433aSmrg  case $tagname in
825d656433aSmrg    CC) ;;
826d656433aSmrg    *)
827d656433aSmrg      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
828d656433aSmrg	taglist="$taglist $tagname"
829d656433aSmrg
830d656433aSmrg	# Evaluate the configuration.  Be careful to quote the path
831d656433aSmrg	# and the sed script, to avoid splitting on whitespace, but
832d656433aSmrg	# also don't use non-portable quotes within backquotes within
833d656433aSmrg	# quotes we have to do it in 2 steps:
834d656433aSmrg	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
835d656433aSmrg	eval "$extractedcf"
836d656433aSmrg      else
837d656433aSmrg	func_error "ignoring unknown tag $tagname"
838d656433aSmrg      fi
839d656433aSmrg      ;;
840d656433aSmrg  esac
841d656433aSmrg}
842d656433aSmrg
843d656433aSmrg# Parse options once, thoroughly.  This comes as soon as possible in
844d656433aSmrg# the script to make things like `libtool --version' happen quickly.
845d656433aSmrg{
846126a8a12Smrg
847d656433aSmrg  # Shorthand for --mode=foo, only valid as the first argument
848d656433aSmrg  case $1 in
849d656433aSmrg  clean|clea|cle|cl)
850d656433aSmrg    shift; set dummy --mode clean ${1+"$@"}; shift
851126a8a12Smrg    ;;
852d656433aSmrg  compile|compil|compi|comp|com|co|c)
853d656433aSmrg    shift; set dummy --mode compile ${1+"$@"}; shift
854126a8a12Smrg    ;;
855d656433aSmrg  execute|execut|execu|exec|exe|ex|e)
856d656433aSmrg    shift; set dummy --mode execute ${1+"$@"}; shift
857126a8a12Smrg    ;;
858d656433aSmrg  finish|finis|fini|fin|fi|f)
859d656433aSmrg    shift; set dummy --mode finish ${1+"$@"}; shift
860126a8a12Smrg    ;;
861d656433aSmrg  install|instal|insta|inst|ins|in|i)
862d656433aSmrg    shift; set dummy --mode install ${1+"$@"}; shift
863d656433aSmrg    ;;
864d656433aSmrg  link|lin|li|l)
865d656433aSmrg    shift; set dummy --mode link ${1+"$@"}; shift
866d656433aSmrg    ;;
867d656433aSmrg  uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
868d656433aSmrg    shift; set dummy --mode uninstall ${1+"$@"}; shift
869126a8a12Smrg    ;;
870126a8a12Smrg  esac
871126a8a12Smrg
872d656433aSmrg  # Parse non-mode specific arguments:
873d656433aSmrg  while test "$#" -gt 0; do
874d656433aSmrg    opt="$1"
875d656433aSmrg    shift
876126a8a12Smrg
877d656433aSmrg    case $opt in
878d656433aSmrg      --config)		func_config					;;
879126a8a12Smrg
880d656433aSmrg      --debug)		preserve_args="$preserve_args $opt"
881d656433aSmrg			func_echo "enabling shell trace mode"
882d656433aSmrg			opt_debug='set -x'
883d656433aSmrg			$opt_debug
884d656433aSmrg			;;
885d656433aSmrg
886d656433aSmrg      -dlopen)		test "$#" -eq 0 && func_missing_arg "$opt" && break
887d656433aSmrg			execute_dlfiles="$execute_dlfiles $1"
888d656433aSmrg			shift
889d656433aSmrg			;;
890126a8a12Smrg
891d656433aSmrg      --dry-run | -n)	opt_dry_run=:					;;
892d656433aSmrg      --features)       func_features					;;
893d656433aSmrg      --finish)		mode="finish"					;;
894d656433aSmrg
895d656433aSmrg      --mode)		test "$#" -eq 0 && func_missing_arg "$opt" && break
896d656433aSmrg			case $1 in
897d656433aSmrg			  # Valid mode arguments:
898d656433aSmrg			  clean)	;;
899d656433aSmrg			  compile)	;;
900d656433aSmrg			  execute)	;;
901d656433aSmrg			  finish)	;;
902d656433aSmrg			  install)	;;
903d656433aSmrg			  link)		;;
904d656433aSmrg			  relink)	;;
905d656433aSmrg			  uninstall)	;;
906d656433aSmrg
907d656433aSmrg			  # Catch anything else as an error
908d656433aSmrg			  *) func_error "invalid argument for $opt"
909d656433aSmrg			     exit_cmd=exit
910d656433aSmrg			     break
911d656433aSmrg			     ;;
912d656433aSmrg		        esac
913d656433aSmrg
914d656433aSmrg			mode="$1"
915d656433aSmrg			shift
916d656433aSmrg			;;
917126a8a12Smrg
918d656433aSmrg      --preserve-dup-deps)
919d656433aSmrg			opt_duplicate_deps=:				;;
920d656433aSmrg
921d656433aSmrg      --quiet|--silent)	preserve_args="$preserve_args $opt"
922d656433aSmrg			opt_silent=:
923555991fdSmrg			opt_verbose=false
924555991fdSmrg			;;
925555991fdSmrg
926555991fdSmrg      --no-quiet|--no-silent)
927555991fdSmrg			preserve_args="$preserve_args $opt"
928555991fdSmrg			opt_silent=false
929d656433aSmrg			;;
930d656433aSmrg
931d656433aSmrg      --verbose| -v)	preserve_args="$preserve_args $opt"
932d656433aSmrg			opt_silent=false
933555991fdSmrg			opt_verbose=:
934555991fdSmrg			;;
935555991fdSmrg
936555991fdSmrg      --no-verbose)	preserve_args="$preserve_args $opt"
937555991fdSmrg			opt_verbose=false
938d656433aSmrg			;;
939d656433aSmrg
940d656433aSmrg      --tag)		test "$#" -eq 0 && func_missing_arg "$opt" && break
941d656433aSmrg			preserve_args="$preserve_args $opt $1"
942d656433aSmrg			func_enable_tag "$1"	# tagname is set here
943d656433aSmrg			shift
944d656433aSmrg			;;
945d656433aSmrg
946d656433aSmrg      # Separate optargs to long options:
947d656433aSmrg      -dlopen=*|--mode=*|--tag=*)
948d656433aSmrg			func_opt_split "$opt"
949d656433aSmrg			set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"}
950d656433aSmrg			shift
951d656433aSmrg			;;
952d656433aSmrg
953d656433aSmrg      -\?|-h)		func_usage					;;
954d656433aSmrg      --help)		opt_help=:					;;
955555991fdSmrg      --help-all)	opt_help=': help-all'				;;
956d656433aSmrg      --version)	func_version					;;
957d656433aSmrg
958d656433aSmrg      -*)		func_fatal_help "unrecognized option \`$opt'"	;;
959d656433aSmrg
960d656433aSmrg      *)		nonopt="$opt"
961d656433aSmrg			break
962d656433aSmrg			;;
963d656433aSmrg    esac
964d656433aSmrg  done
965d656433aSmrg
966d656433aSmrg
967d656433aSmrg  case $host in
968d656433aSmrg    *cygwin* | *mingw* | *pw32* | *cegcc*)
969d656433aSmrg      # don't eliminate duplications in $postdeps and $predeps
970d656433aSmrg      opt_duplicate_compiler_generated_deps=:
971126a8a12Smrg      ;;
972126a8a12Smrg    *)
973d656433aSmrg      opt_duplicate_compiler_generated_deps=$opt_duplicate_deps
974d656433aSmrg      ;;
975d656433aSmrg  esac
976126a8a12Smrg
977d656433aSmrg  # Having warned about all mis-specified options, bail out if
978d656433aSmrg  # anything was wrong.
979d656433aSmrg  $exit_cmd $EXIT_FAILURE
980d656433aSmrg}
981d656433aSmrg
982d656433aSmrg# func_check_version_match
983d656433aSmrg# Ensure that we are using m4 macros, and libtool script from the same
984d656433aSmrg# release of libtool.
985d656433aSmrgfunc_check_version_match ()
986d656433aSmrg{
987d656433aSmrg  if test "$package_revision" != "$macro_revision"; then
988d656433aSmrg    if test "$VERSION" != "$macro_version"; then
989d656433aSmrg      if test -z "$macro_version"; then
990d656433aSmrg        cat >&2 <<_LT_EOF
991d656433aSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
992d656433aSmrg$progname: definition of this LT_INIT comes from an older release.
993d656433aSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
994d656433aSmrg$progname: and run autoconf again.
995d656433aSmrg_LT_EOF
996d656433aSmrg      else
997d656433aSmrg        cat >&2 <<_LT_EOF
998d656433aSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
999d656433aSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
1000d656433aSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
1001d656433aSmrg$progname: and run autoconf again.
1002d656433aSmrg_LT_EOF
1003126a8a12Smrg      fi
1004d656433aSmrg    else
1005d656433aSmrg      cat >&2 <<_LT_EOF
1006d656433aSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
1007d656433aSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
1008d656433aSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
1009d656433aSmrg$progname: of $PACKAGE $VERSION and run autoconf again.
1010d656433aSmrg_LT_EOF
1011d656433aSmrg    fi
1012d656433aSmrg
1013d656433aSmrg    exit $EXIT_MISMATCH
1014126a8a12Smrg  fi
1015d656433aSmrg}
1016d656433aSmrg
1017d656433aSmrg
1018d656433aSmrg## ----------- ##
1019d656433aSmrg##    Main.    ##
1020d656433aSmrg## ----------- ##
1021d656433aSmrg
1022d656433aSmrg$opt_help || {
1023d656433aSmrg  # Sanity checks first:
1024d656433aSmrg  func_check_version_match
1025d656433aSmrg
1026d656433aSmrg  if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
1027d656433aSmrg    func_fatal_configuration "not configured to build any kind of library"
1028d656433aSmrg  fi
1029d656433aSmrg
1030d656433aSmrg  test -z "$mode" && func_fatal_error "error: you must specify a MODE."
1031d656433aSmrg
1032d656433aSmrg
1033d656433aSmrg  # Darwin sucks
1034d656433aSmrg  eval std_shrext=\"$shrext_cmds\"
1035d656433aSmrg
1036126a8a12Smrg
1037126a8a12Smrg  # Only execute mode is allowed to have -dlopen flags.
1038126a8a12Smrg  if test -n "$execute_dlfiles" && test "$mode" != execute; then
1039d656433aSmrg    func_error "unrecognized option \`-dlopen'"
1040d656433aSmrg    $ECHO "$help" 1>&2
1041126a8a12Smrg    exit $EXIT_FAILURE
1042126a8a12Smrg  fi
1043126a8a12Smrg
1044126a8a12Smrg  # Change the help message to a mode-specific one.
1045126a8a12Smrg  generic_help="$help"
1046d656433aSmrg  help="Try \`$progname --help --mode=$mode' for more information."
1047d656433aSmrg}
1048126a8a12Smrg
1049126a8a12Smrg
1050d656433aSmrg# func_lalib_p file
1051d656433aSmrg# True iff FILE is a libtool `.la' library or `.lo' object file.
1052d656433aSmrg# This function is only a basic sanity check; it will hardly flush out
1053d656433aSmrg# determined imposters.
1054d656433aSmrgfunc_lalib_p ()
1055d656433aSmrg{
1056d656433aSmrg    test -f "$1" &&
1057d656433aSmrg      $SED -e 4q "$1" 2>/dev/null \
1058d656433aSmrg        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
1059d656433aSmrg}
1060126a8a12Smrg
1061d656433aSmrg# func_lalib_unsafe_p file
1062d656433aSmrg# True iff FILE is a libtool `.la' library or `.lo' object file.
1063d656433aSmrg# This function implements the same check as func_lalib_p without
1064d656433aSmrg# resorting to external programs.  To this end, it redirects stdin and
1065d656433aSmrg# closes it afterwards, without saving the original file descriptor.
1066d656433aSmrg# As a safety measure, use it only where a negative result would be
1067d656433aSmrg# fatal anyway.  Works if `file' does not exist.
1068d656433aSmrgfunc_lalib_unsafe_p ()
1069d656433aSmrg{
1070d656433aSmrg    lalib_p=no
1071d656433aSmrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
1072d656433aSmrg	for lalib_p_l in 1 2 3 4
1073d656433aSmrg	do
1074d656433aSmrg	    read lalib_p_line
1075d656433aSmrg	    case "$lalib_p_line" in
1076d656433aSmrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
1077d656433aSmrg	    esac
1078d656433aSmrg	done
1079d656433aSmrg	exec 0<&5 5<&-
1080d656433aSmrg    fi
1081d656433aSmrg    test "$lalib_p" = yes
1082d656433aSmrg}
1083126a8a12Smrg
1084d656433aSmrg# func_ltwrapper_script_p file
1085d656433aSmrg# True iff FILE is a libtool wrapper script
1086d656433aSmrg# This function is only a basic sanity check; it will hardly flush out
1087d656433aSmrg# determined imposters.
1088d656433aSmrgfunc_ltwrapper_script_p ()
1089d656433aSmrg{
1090d656433aSmrg    func_lalib_p "$1"
1091d656433aSmrg}
1092126a8a12Smrg
1093d656433aSmrg# func_ltwrapper_executable_p file
1094d656433aSmrg# True iff FILE is a libtool wrapper executable
1095d656433aSmrg# This function is only a basic sanity check; it will hardly flush out
1096d656433aSmrg# determined imposters.
1097d656433aSmrgfunc_ltwrapper_executable_p ()
1098d656433aSmrg{
1099d656433aSmrg    func_ltwrapper_exec_suffix=
1100d656433aSmrg    case $1 in
1101d656433aSmrg    *.exe) ;;
1102d656433aSmrg    *) func_ltwrapper_exec_suffix=.exe ;;
1103d656433aSmrg    esac
1104d656433aSmrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
1105d656433aSmrg}
1106126a8a12Smrg
1107d656433aSmrg# func_ltwrapper_scriptname file
1108d656433aSmrg# Assumes file is an ltwrapper_executable
1109d656433aSmrg# uses $file to determine the appropriate filename for a
1110d656433aSmrg# temporary ltwrapper_script.
1111d656433aSmrgfunc_ltwrapper_scriptname ()
1112d656433aSmrg{
1113d656433aSmrg    func_ltwrapper_scriptname_result=""
1114d656433aSmrg    if func_ltwrapper_executable_p "$1"; then
1115d656433aSmrg	func_dirname_and_basename "$1" "" "."
1116d656433aSmrg	func_stripname '' '.exe' "$func_basename_result"
1117d656433aSmrg	func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
1118d656433aSmrg    fi
1119d656433aSmrg}
1120126a8a12Smrg
1121d656433aSmrg# func_ltwrapper_p file
1122d656433aSmrg# True iff FILE is a libtool wrapper script or wrapper executable
1123d656433aSmrg# This function is only a basic sanity check; it will hardly flush out
1124d656433aSmrg# determined imposters.
1125d656433aSmrgfunc_ltwrapper_p ()
1126d656433aSmrg{
1127d656433aSmrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
1128d656433aSmrg}
1129126a8a12Smrg
1130126a8a12Smrg
1131d656433aSmrg# func_execute_cmds commands fail_cmd
1132d656433aSmrg# Execute tilde-delimited COMMANDS.
1133d656433aSmrg# If FAIL_CMD is given, eval that upon failure.
1134d656433aSmrg# FAIL_CMD may read-access the current command in variable CMD!
1135d656433aSmrgfunc_execute_cmds ()
1136d656433aSmrg{
1137d656433aSmrg    $opt_debug
1138d656433aSmrg    save_ifs=$IFS; IFS='~'
1139d656433aSmrg    for cmd in $1; do
1140d656433aSmrg      IFS=$save_ifs
1141d656433aSmrg      eval cmd=\"$cmd\"
1142d656433aSmrg      func_show_eval "$cmd" "${2-:}"
1143d656433aSmrg    done
1144d656433aSmrg    IFS=$save_ifs
1145d656433aSmrg}
1146d656433aSmrg
1147d656433aSmrg
1148d656433aSmrg# func_source file
1149d656433aSmrg# Source FILE, adding directory component if necessary.
1150d656433aSmrg# Note that it is not necessary on cygwin/mingw to append a dot to
1151d656433aSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
1152d656433aSmrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
1153d656433aSmrg# `FILE.' does not work on cygwin managed mounts.
1154d656433aSmrgfunc_source ()
1155d656433aSmrg{
1156d656433aSmrg    $opt_debug
1157d656433aSmrg    case $1 in
1158d656433aSmrg    */* | *\\*)	. "$1" ;;
1159d656433aSmrg    *)		. "./$1" ;;
1160d656433aSmrg    esac
1161d656433aSmrg}
1162d656433aSmrg
1163d656433aSmrg
1164d656433aSmrg# func_infer_tag arg
1165d656433aSmrg# Infer tagged configuration to use if any are available and
1166d656433aSmrg# if one wasn't chosen via the "--tag" command line option.
1167d656433aSmrg# Only attempt this if the compiler in the base compile
1168d656433aSmrg# command doesn't match the default compiler.
1169d656433aSmrg# arg is usually of the form 'gcc ...'
1170d656433aSmrgfunc_infer_tag ()
1171d656433aSmrg{
1172d656433aSmrg    $opt_debug
1173d656433aSmrg    if test -n "$available_tags" && test -z "$tagname"; then
1174d656433aSmrg      CC_quoted=
1175d656433aSmrg      for arg in $CC; do
1176d656433aSmrg        func_quote_for_eval "$arg"
1177d656433aSmrg	CC_quoted="$CC_quoted $func_quote_for_eval_result"
1178d656433aSmrg      done
1179555991fdSmrg      CC_expanded=`func_echo_all $CC`
1180555991fdSmrg      CC_quoted_expanded=`func_echo_all $CC_quoted`
1181d656433aSmrg      case $@ in
1182d656433aSmrg      # Blanks in the command may have been stripped by the calling shell,
1183d656433aSmrg      # but not from the CC environment variable when configure was run.
1184555991fdSmrg      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1185555991fdSmrg      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
1186d656433aSmrg      # Blanks at the start of $base_compile will cause this to fail
1187d656433aSmrg      # if we don't check for them as well.
1188d656433aSmrg      *)
1189d656433aSmrg	for z in $available_tags; do
1190d656433aSmrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
1191d656433aSmrg	    # Evaluate the configuration.
1192d656433aSmrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
1193d656433aSmrg	    CC_quoted=
1194d656433aSmrg	    for arg in $CC; do
1195d656433aSmrg	      # Double-quote args containing other shell metacharacters.
1196d656433aSmrg	      func_quote_for_eval "$arg"
1197d656433aSmrg	      CC_quoted="$CC_quoted $func_quote_for_eval_result"
1198d656433aSmrg	    done
1199555991fdSmrg	    CC_expanded=`func_echo_all $CC`
1200555991fdSmrg	    CC_quoted_expanded=`func_echo_all $CC_quoted`
1201d656433aSmrg	    case "$@ " in
1202555991fdSmrg	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1203555991fdSmrg	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
1204d656433aSmrg	      # The compiler in the base compile command matches
1205d656433aSmrg	      # the one in the tagged configuration.
1206d656433aSmrg	      # Assume this is the tagged configuration we want.
1207d656433aSmrg	      tagname=$z
1208d656433aSmrg	      break
1209126a8a12Smrg	      ;;
1210126a8a12Smrg	    esac
1211d656433aSmrg	  fi
1212d656433aSmrg	done
1213d656433aSmrg	# If $tagname still isn't set, then no tagged configuration
1214d656433aSmrg	# was found and let the user know that the "--tag" command
1215d656433aSmrg	# line option must be used.
1216d656433aSmrg	if test -z "$tagname"; then
1217d656433aSmrg	  func_echo "unable to infer tagged configuration"
1218d656433aSmrg	  func_fatal_error "specify a tag with \`--tag'"
1219d656433aSmrg#	else
1220d656433aSmrg#	  func_verbose "using $tagname tagged configuration"
1221d656433aSmrg	fi
1222d656433aSmrg	;;
1223d656433aSmrg      esac
1224d656433aSmrg    fi
1225d656433aSmrg}
1226d656433aSmrg
1227d656433aSmrg
1228d656433aSmrg
1229d656433aSmrg# func_write_libtool_object output_name pic_name nonpic_name
1230d656433aSmrg# Create a libtool object file (analogous to a ".la" file),
1231d656433aSmrg# but don't create it if we're doing a dry run.
1232d656433aSmrgfunc_write_libtool_object ()
1233d656433aSmrg{
1234d656433aSmrg    write_libobj=${1}
1235d656433aSmrg    if test "$build_libtool_libs" = yes; then
1236d656433aSmrg      write_lobj=\'${2}\'
1237d656433aSmrg    else
1238d656433aSmrg      write_lobj=none
1239d656433aSmrg    fi
1240d656433aSmrg
1241d656433aSmrg    if test "$build_old_libs" = yes; then
1242d656433aSmrg      write_oldobj=\'${3}\'
1243d656433aSmrg    else
1244d656433aSmrg      write_oldobj=none
1245d656433aSmrg    fi
1246d656433aSmrg
1247d656433aSmrg    $opt_dry_run || {
1248d656433aSmrg      cat >${write_libobj}T <<EOF
1249d656433aSmrg# $write_libobj - a libtool object file
1250d656433aSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1251d656433aSmrg#
1252d656433aSmrg# Please DO NOT delete this file!
1253d656433aSmrg# It is necessary for linking the library.
1254d656433aSmrg
1255d656433aSmrg# Name of the PIC object.
1256d656433aSmrgpic_object=$write_lobj
1257d656433aSmrg
1258d656433aSmrg# Name of the non-PIC object
1259d656433aSmrgnon_pic_object=$write_oldobj
1260d656433aSmrg
1261d656433aSmrgEOF
1262d656433aSmrg      $MV "${write_libobj}T" "${write_libobj}"
1263d656433aSmrg    }
1264d656433aSmrg}
1265d656433aSmrg
1266d656433aSmrg# func_mode_compile arg...
1267d656433aSmrgfunc_mode_compile ()
1268d656433aSmrg{
1269d656433aSmrg    $opt_debug
1270d656433aSmrg    # Get the compilation command and the source file.
1271d656433aSmrg    base_compile=
1272d656433aSmrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
1273d656433aSmrg    suppress_opt=yes
1274d656433aSmrg    suppress_output=
1275d656433aSmrg    arg_mode=normal
1276d656433aSmrg    libobj=
1277d656433aSmrg    later=
1278d656433aSmrg    pie_flag=
1279d656433aSmrg
1280d656433aSmrg    for arg
1281d656433aSmrg    do
1282d656433aSmrg      case $arg_mode in
1283d656433aSmrg      arg  )
1284d656433aSmrg	# do not "continue".  Instead, add this to base_compile
1285d656433aSmrg	lastarg="$arg"
1286d656433aSmrg	arg_mode=normal
1287d656433aSmrg	;;
1288d656433aSmrg
1289d656433aSmrg      target )
1290d656433aSmrg	libobj="$arg"
1291d656433aSmrg	arg_mode=normal
1292d656433aSmrg	continue
1293d656433aSmrg	;;
1294d656433aSmrg
1295d656433aSmrg      normal )
1296d656433aSmrg	# Accept any command-line options.
1297d656433aSmrg	case $arg in
1298d656433aSmrg	-o)
1299d656433aSmrg	  test -n "$libobj" && \
1300d656433aSmrg	    func_fatal_error "you cannot specify \`-o' more than once"
1301d656433aSmrg	  arg_mode=target
1302d656433aSmrg	  continue
1303d656433aSmrg	  ;;
1304d656433aSmrg
1305d656433aSmrg	-pie | -fpie | -fPIE)
1306d656433aSmrg          pie_flag="$pie_flag $arg"
1307d656433aSmrg	  continue
1308d656433aSmrg	  ;;
1309d656433aSmrg
1310d656433aSmrg	-shared | -static | -prefer-pic | -prefer-non-pic)
1311d656433aSmrg	  later="$later $arg"
1312d656433aSmrg	  continue
1313d656433aSmrg	  ;;
1314d656433aSmrg
1315d656433aSmrg	-no-suppress)
1316d656433aSmrg	  suppress_opt=no
1317d656433aSmrg	  continue
1318d656433aSmrg	  ;;
1319d656433aSmrg
1320d656433aSmrg	-Xcompiler)
1321d656433aSmrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
1322d656433aSmrg	  continue      #  The current "srcfile" will either be retained or
1323d656433aSmrg	  ;;            #  replaced later.  I would guess that would be a bug.
1324d656433aSmrg
1325d656433aSmrg	-Wc,*)
1326d656433aSmrg	  func_stripname '-Wc,' '' "$arg"
1327d656433aSmrg	  args=$func_stripname_result
1328d656433aSmrg	  lastarg=
1329d656433aSmrg	  save_ifs="$IFS"; IFS=','
1330d656433aSmrg	  for arg in $args; do
1331d656433aSmrg	    IFS="$save_ifs"
1332d656433aSmrg	    func_quote_for_eval "$arg"
1333d656433aSmrg	    lastarg="$lastarg $func_quote_for_eval_result"
1334126a8a12Smrg	  done
1335126a8a12Smrg	  IFS="$save_ifs"
1336d656433aSmrg	  func_stripname ' ' '' "$lastarg"
1337d656433aSmrg	  lastarg=$func_stripname_result
1338126a8a12Smrg
1339126a8a12Smrg	  # Add the arguments to base_compile.
1340126a8a12Smrg	  base_compile="$base_compile $lastarg"
1341126a8a12Smrg	  continue
1342126a8a12Smrg	  ;;
1343126a8a12Smrg
1344d656433aSmrg	*)
1345126a8a12Smrg	  # Accept the current argument as the source file.
1346126a8a12Smrg	  # The previous "srcfile" becomes the current argument.
1347126a8a12Smrg	  #
1348126a8a12Smrg	  lastarg="$srcfile"
1349126a8a12Smrg	  srcfile="$arg"
1350126a8a12Smrg	  ;;
1351126a8a12Smrg	esac  #  case $arg
1352126a8a12Smrg	;;
1353126a8a12Smrg      esac    #  case $arg_mode
1354126a8a12Smrg
1355126a8a12Smrg      # Aesthetically quote the previous argument.
1356d656433aSmrg      func_quote_for_eval "$lastarg"
1357d656433aSmrg      base_compile="$base_compile $func_quote_for_eval_result"
1358126a8a12Smrg    done # for arg
1359126a8a12Smrg
1360126a8a12Smrg    case $arg_mode in
1361126a8a12Smrg    arg)
1362d656433aSmrg      func_fatal_error "you must specify an argument for -Xcompile"
1363126a8a12Smrg      ;;
1364126a8a12Smrg    target)
1365d656433aSmrg      func_fatal_error "you must specify a target with \`-o'"
1366126a8a12Smrg      ;;
1367126a8a12Smrg    *)
1368126a8a12Smrg      # Get the name of the library object.
1369d656433aSmrg      test -z "$libobj" && {
1370d656433aSmrg	func_basename "$srcfile"
1371d656433aSmrg	libobj="$func_basename_result"
1372d656433aSmrg      }
1373126a8a12Smrg      ;;
1374126a8a12Smrg    esac
1375126a8a12Smrg
1376126a8a12Smrg    # Recognize several different file suffixes.
1377126a8a12Smrg    # If the user specifies -o file.o, it is replaced with file.lo
1378126a8a12Smrg    case $libobj in
1379d656433aSmrg    *.[cCFSifmso] | \
1380d656433aSmrg    *.ada | *.adb | *.ads | *.asm | \
1381d656433aSmrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
1382555991fdSmrg    *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup)
1383d656433aSmrg      func_xform "$libobj"
1384d656433aSmrg      libobj=$func_xform_result
1385d656433aSmrg      ;;
1386126a8a12Smrg    esac
1387126a8a12Smrg
1388126a8a12Smrg    case $libobj in
1389d656433aSmrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
1390126a8a12Smrg    *)
1391d656433aSmrg      func_fatal_error "cannot determine name of library object from \`$libobj'"
1392126a8a12Smrg      ;;
1393126a8a12Smrg    esac
1394126a8a12Smrg
1395126a8a12Smrg    func_infer_tag $base_compile
1396126a8a12Smrg
1397126a8a12Smrg    for arg in $later; do
1398126a8a12Smrg      case $arg in
1399d656433aSmrg      -shared)
1400d656433aSmrg	test "$build_libtool_libs" != yes && \
1401d656433aSmrg	  func_fatal_configuration "can not build a shared library"
1402d656433aSmrg	build_old_libs=no
1403d656433aSmrg	continue
1404d656433aSmrg	;;
1405d656433aSmrg
1406126a8a12Smrg      -static)
1407d656433aSmrg	build_libtool_libs=no
1408126a8a12Smrg	build_old_libs=yes
1409126a8a12Smrg	continue
1410126a8a12Smrg	;;
1411126a8a12Smrg
1412126a8a12Smrg      -prefer-pic)
1413126a8a12Smrg	pic_mode=yes
1414126a8a12Smrg	continue
1415126a8a12Smrg	;;
1416126a8a12Smrg
1417126a8a12Smrg      -prefer-non-pic)
1418126a8a12Smrg	pic_mode=no
1419126a8a12Smrg	continue
1420126a8a12Smrg	;;
1421126a8a12Smrg      esac
1422126a8a12Smrg    done
1423126a8a12Smrg
1424d656433aSmrg    func_quote_for_eval "$libobj"
1425d656433aSmrg    test "X$libobj" != "X$func_quote_for_eval_result" \
1426d656433aSmrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
1427d656433aSmrg      && func_warning "libobj name \`$libobj' may not contain shell special characters."
1428d656433aSmrg    func_dirname_and_basename "$obj" "/" ""
1429d656433aSmrg    objname="$func_basename_result"
1430d656433aSmrg    xdir="$func_dirname_result"
1431126a8a12Smrg    lobj=${xdir}$objdir/$objname
1432126a8a12Smrg
1433d656433aSmrg    test -z "$base_compile" && \
1434d656433aSmrg      func_fatal_help "you must specify a compilation command"
1435126a8a12Smrg
1436126a8a12Smrg    # Delete any leftover library objects.
1437126a8a12Smrg    if test "$build_old_libs" = yes; then
1438126a8a12Smrg      removelist="$obj $lobj $libobj ${libobj}T"
1439126a8a12Smrg    else
1440126a8a12Smrg      removelist="$lobj $libobj ${libobj}T"
1441126a8a12Smrg    fi
1442126a8a12Smrg
1443126a8a12Smrg    # On Cygwin there's no "real" PIC flag so we must build both object types
1444126a8a12Smrg    case $host_os in
1445d656433aSmrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
1446126a8a12Smrg      pic_mode=default
1447126a8a12Smrg      ;;
1448126a8a12Smrg    esac
1449126a8a12Smrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
1450126a8a12Smrg      # non-PIC code in shared libraries is not supported
1451126a8a12Smrg      pic_mode=default
1452126a8a12Smrg    fi
1453126a8a12Smrg
1454126a8a12Smrg    # Calculate the filename of the output object if compiler does
1455126a8a12Smrg    # not support -o with -c
1456126a8a12Smrg    if test "$compiler_c_o" = no; then
1457555991fdSmrg      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
1458126a8a12Smrg      lockfile="$output_obj.lock"
1459126a8a12Smrg    else
1460126a8a12Smrg      output_obj=
1461126a8a12Smrg      need_locks=no
1462126a8a12Smrg      lockfile=
1463126a8a12Smrg    fi
1464126a8a12Smrg
1465126a8a12Smrg    # Lock this critical section if it is needed
1466126a8a12Smrg    # We use this script file to make the link, it avoids creating a new file
1467126a8a12Smrg    if test "$need_locks" = yes; then
1468d656433aSmrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
1469d656433aSmrg	func_echo "Waiting for $lockfile to be removed"
1470126a8a12Smrg	sleep 2
1471126a8a12Smrg      done
1472126a8a12Smrg    elif test "$need_locks" = warn; then
1473126a8a12Smrg      if test -f "$lockfile"; then
1474d656433aSmrg	$ECHO "\
1475126a8a12Smrg*** ERROR, $lockfile exists and contains:
1476126a8a12Smrg`cat $lockfile 2>/dev/null`
1477126a8a12Smrg
1478126a8a12SmrgThis indicates that another process is trying to use the same
1479126a8a12Smrgtemporary object file, and libtool could not work around it because
1480126a8a12Smrgyour compiler does not support \`-c' and \`-o' together.  If you
1481126a8a12Smrgrepeat this compilation, it may succeed, by chance, but you had better
1482126a8a12Smrgavoid parallel builds (make -j) in this platform, or get a better
1483126a8a12Smrgcompiler."
1484126a8a12Smrg
1485d656433aSmrg	$opt_dry_run || $RM $removelist
1486126a8a12Smrg	exit $EXIT_FAILURE
1487126a8a12Smrg      fi
1488d656433aSmrg      removelist="$removelist $output_obj"
1489d656433aSmrg      $ECHO "$srcfile" > "$lockfile"
1490126a8a12Smrg    fi
1491126a8a12Smrg
1492d656433aSmrg    $opt_dry_run || $RM $removelist
1493d656433aSmrg    removelist="$removelist $lockfile"
1494d656433aSmrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
1495d656433aSmrg
1496126a8a12Smrg    if test -n "$fix_srcfile_path"; then
1497126a8a12Smrg      eval srcfile=\"$fix_srcfile_path\"
1498126a8a12Smrg    fi
1499d656433aSmrg    func_quote_for_eval "$srcfile"
1500d656433aSmrg    qsrcfile=$func_quote_for_eval_result
1501126a8a12Smrg
1502126a8a12Smrg    # Only build a PIC object if we are building libtool libraries.
1503126a8a12Smrg    if test "$build_libtool_libs" = yes; then
1504126a8a12Smrg      # Without this assignment, base_compile gets emptied.
1505126a8a12Smrg      fbsd_hideous_sh_bug=$base_compile
1506126a8a12Smrg
1507126a8a12Smrg      if test "$pic_mode" != no; then
1508126a8a12Smrg	command="$base_compile $qsrcfile $pic_flag"
1509126a8a12Smrg      else
1510126a8a12Smrg	# Don't build PIC code
1511126a8a12Smrg	command="$base_compile $qsrcfile"
1512126a8a12Smrg      fi
1513126a8a12Smrg
1514d656433aSmrg      func_mkdir_p "$xdir$objdir"
1515126a8a12Smrg
1516126a8a12Smrg      if test -z "$output_obj"; then
1517126a8a12Smrg	# Place PIC objects in $objdir
1518126a8a12Smrg	command="$command -o $lobj"
1519126a8a12Smrg      fi
1520126a8a12Smrg
1521d656433aSmrg      func_show_eval_locale "$command"	\
1522d656433aSmrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
1523126a8a12Smrg
1524126a8a12Smrg      if test "$need_locks" = warn &&
1525126a8a12Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
1526d656433aSmrg	$ECHO "\
1527126a8a12Smrg*** ERROR, $lockfile contains:
1528126a8a12Smrg`cat $lockfile 2>/dev/null`
1529126a8a12Smrg
1530126a8a12Smrgbut it should contain:
1531126a8a12Smrg$srcfile
1532126a8a12Smrg
1533126a8a12SmrgThis indicates that another process is trying to use the same
1534126a8a12Smrgtemporary object file, and libtool could not work around it because
1535126a8a12Smrgyour compiler does not support \`-c' and \`-o' together.  If you
1536126a8a12Smrgrepeat this compilation, it may succeed, by chance, but you had better
1537126a8a12Smrgavoid parallel builds (make -j) in this platform, or get a better
1538126a8a12Smrgcompiler."
1539126a8a12Smrg
1540d656433aSmrg	$opt_dry_run || $RM $removelist
1541126a8a12Smrg	exit $EXIT_FAILURE
1542126a8a12Smrg      fi
1543126a8a12Smrg
1544126a8a12Smrg      # Just move the object if needed, then go on to compile the next one
1545126a8a12Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
1546d656433aSmrg	func_show_eval '$MV "$output_obj" "$lobj"' \
1547d656433aSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
1548126a8a12Smrg      fi
1549126a8a12Smrg
1550126a8a12Smrg      # Allow error messages only from the first compilation.
1551126a8a12Smrg      if test "$suppress_opt" = yes; then
1552d656433aSmrg	suppress_output=' >/dev/null 2>&1'
1553126a8a12Smrg      fi
1554126a8a12Smrg    fi
1555126a8a12Smrg
1556126a8a12Smrg    # Only build a position-dependent object if we build old libraries.
1557126a8a12Smrg    if test "$build_old_libs" = yes; then
1558126a8a12Smrg      if test "$pic_mode" != yes; then
1559126a8a12Smrg	# Don't build PIC code
1560d656433aSmrg	command="$base_compile $qsrcfile$pie_flag"
1561126a8a12Smrg      else
1562126a8a12Smrg	command="$base_compile $qsrcfile $pic_flag"
1563126a8a12Smrg      fi
1564126a8a12Smrg      if test "$compiler_c_o" = yes; then
1565126a8a12Smrg	command="$command -o $obj"
1566126a8a12Smrg      fi
1567126a8a12Smrg
1568126a8a12Smrg      # Suppress compiler output if we already did a PIC compilation.
1569126a8a12Smrg      command="$command$suppress_output"
1570d656433aSmrg      func_show_eval_locale "$command" \
1571d656433aSmrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
1572126a8a12Smrg
1573126a8a12Smrg      if test "$need_locks" = warn &&
1574126a8a12Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
1575d656433aSmrg	$ECHO "\
1576126a8a12Smrg*** ERROR, $lockfile contains:
1577126a8a12Smrg`cat $lockfile 2>/dev/null`
1578126a8a12Smrg
1579126a8a12Smrgbut it should contain:
1580126a8a12Smrg$srcfile
1581126a8a12Smrg
1582126a8a12SmrgThis indicates that another process is trying to use the same
1583126a8a12Smrgtemporary object file, and libtool could not work around it because
1584126a8a12Smrgyour compiler does not support \`-c' and \`-o' together.  If you
1585126a8a12Smrgrepeat this compilation, it may succeed, by chance, but you had better
1586126a8a12Smrgavoid parallel builds (make -j) in this platform, or get a better
1587126a8a12Smrgcompiler."
1588126a8a12Smrg
1589d656433aSmrg	$opt_dry_run || $RM $removelist
1590126a8a12Smrg	exit $EXIT_FAILURE
1591126a8a12Smrg      fi
1592126a8a12Smrg
1593126a8a12Smrg      # Just move the object if needed
1594126a8a12Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
1595d656433aSmrg	func_show_eval '$MV "$output_obj" "$obj"' \
1596d656433aSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
1597126a8a12Smrg      fi
1598126a8a12Smrg    fi
1599126a8a12Smrg
1600d656433aSmrg    $opt_dry_run || {
1601d656433aSmrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
1602126a8a12Smrg
1603d656433aSmrg      # Unlock the critical section if it was locked
1604d656433aSmrg      if test "$need_locks" != no; then
1605d656433aSmrg	removelist=$lockfile
1606d656433aSmrg        $RM "$lockfile"
1607d656433aSmrg      fi
1608d656433aSmrg    }
1609126a8a12Smrg
1610126a8a12Smrg    exit $EXIT_SUCCESS
1611d656433aSmrg}
1612126a8a12Smrg
1613d656433aSmrg$opt_help || {
1614555991fdSmrg  test "$mode" = compile && func_mode_compile ${1+"$@"}
1615d656433aSmrg}
1616126a8a12Smrg
1617d656433aSmrgfunc_mode_help ()
1618d656433aSmrg{
1619d656433aSmrg    # We need to display help for each of the modes.
1620d656433aSmrg    case $mode in
1621d656433aSmrg      "")
1622d656433aSmrg        # Generic help is extracted from the usage comments
1623d656433aSmrg        # at the start of this file.
1624d656433aSmrg        func_help
1625d656433aSmrg        ;;
1626126a8a12Smrg
1627d656433aSmrg      clean)
1628d656433aSmrg        $ECHO \
1629d656433aSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
1630126a8a12Smrg
1631d656433aSmrgRemove files from the build directory.
1632126a8a12Smrg
1633d656433aSmrgRM is the name of the program to use to delete files associated with each FILE
1634d656433aSmrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
1635d656433aSmrgto RM.
1636126a8a12Smrg
1637d656433aSmrgIf FILE is a libtool library, object or program, all the files associated
1638d656433aSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
1639d656433aSmrg        ;;
1640126a8a12Smrg
1641d656433aSmrg      compile)
1642d656433aSmrg      $ECHO \
1643d656433aSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
1644126a8a12Smrg
1645d656433aSmrgCompile a source file into a libtool library object.
1646126a8a12Smrg
1647d656433aSmrgThis mode accepts the following additional options:
1648126a8a12Smrg
1649d656433aSmrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
1650d656433aSmrg  -no-suppress      do not suppress compiler output for multiple passes
1651555991fdSmrg  -prefer-pic       try to build PIC objects only
1652555991fdSmrg  -prefer-non-pic   try to build non-PIC objects only
1653d656433aSmrg  -shared           do not build a \`.o' file suitable for static linking
1654d656433aSmrg  -static           only build a \`.o' file suitable for static linking
1655555991fdSmrg  -Wc,FLAG          pass FLAG directly to the compiler
1656126a8a12Smrg
1657d656433aSmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
1658d656433aSmrgfrom the given SOURCEFILE.
1659126a8a12Smrg
1660d656433aSmrgThe output file name is determined by removing the directory component from
1661d656433aSmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
1662d656433aSmrglibrary object suffix, \`.lo'."
1663d656433aSmrg        ;;
1664126a8a12Smrg
1665d656433aSmrg      execute)
1666d656433aSmrg        $ECHO \
1667d656433aSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
1668126a8a12Smrg
1669d656433aSmrgAutomatically set library path, then run a program.
1670126a8a12Smrg
1671d656433aSmrgThis mode accepts the following additional options:
1672126a8a12Smrg
1673d656433aSmrg  -dlopen FILE      add the directory containing FILE to the library path
1674126a8a12Smrg
1675d656433aSmrgThis mode sets the library path environment variable according to \`-dlopen'
1676d656433aSmrgflags.
1677126a8a12Smrg
1678d656433aSmrgIf any of the ARGS are libtool executable wrappers, then they are translated
1679d656433aSmrginto their corresponding uninstalled binary, and any of their required library
1680d656433aSmrgdirectories are added to the library path.
1681126a8a12Smrg
1682d656433aSmrgThen, COMMAND is executed, with ARGS as arguments."
1683d656433aSmrg        ;;
1684126a8a12Smrg
1685d656433aSmrg      finish)
1686d656433aSmrg        $ECHO \
1687d656433aSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
1688126a8a12Smrg
1689d656433aSmrgComplete the installation of libtool libraries.
1690126a8a12Smrg
1691d656433aSmrgEach LIBDIR is a directory that contains libtool libraries.
1692126a8a12Smrg
1693d656433aSmrgThe commands that this mode executes may require superuser privileges.  Use
1694d656433aSmrgthe \`--dry-run' option if you just want to see what would be executed."
1695d656433aSmrg        ;;
1696126a8a12Smrg
1697d656433aSmrg      install)
1698d656433aSmrg        $ECHO \
1699d656433aSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
1700126a8a12Smrg
1701d656433aSmrgInstall executables or libraries.
1702126a8a12Smrg
1703d656433aSmrgINSTALL-COMMAND is the installation command.  The first component should be
1704d656433aSmrgeither the \`install' or \`cp' program.
1705126a8a12Smrg
1706d656433aSmrgThe following components of INSTALL-COMMAND are treated specially:
1707126a8a12Smrg
1708555991fdSmrg  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
1709126a8a12Smrg
1710d656433aSmrgThe rest of the components are interpreted as arguments to that command (only
1711d656433aSmrgBSD-compatible install options are recognized)."
1712d656433aSmrg        ;;
1713126a8a12Smrg
1714d656433aSmrg      link)
1715d656433aSmrg        $ECHO \
1716d656433aSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
1717126a8a12Smrg
1718d656433aSmrgLink object files or libraries together to form another library, or to
1719d656433aSmrgcreate an executable program.
1720126a8a12Smrg
1721d656433aSmrgLINK-COMMAND is a command using the C compiler that you would use to create
1722d656433aSmrga program from several object files.
1723126a8a12Smrg
1724d656433aSmrgThe following components of LINK-COMMAND are treated specially:
1725126a8a12Smrg
1726d656433aSmrg  -all-static       do not do any dynamic linking at all
1727d656433aSmrg  -avoid-version    do not add a version suffix if possible
1728555991fdSmrg  -bindir BINDIR    specify path to binaries directory (for systems where
1729555991fdSmrg                    libraries must be found in the PATH setting at runtime)
1730d656433aSmrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
1731d656433aSmrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
1732d656433aSmrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
1733d656433aSmrg  -export-symbols SYMFILE
1734d656433aSmrg                    try to export only the symbols listed in SYMFILE
1735d656433aSmrg  -export-symbols-regex REGEX
1736d656433aSmrg                    try to export only the symbols matching REGEX
1737d656433aSmrg  -LLIBDIR          search LIBDIR for required installed libraries
1738d656433aSmrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
1739d656433aSmrg  -module           build a library that can dlopened
1740d656433aSmrg  -no-fast-install  disable the fast-install mode
1741d656433aSmrg  -no-install       link a not-installable executable
1742d656433aSmrg  -no-undefined     declare that a library does not refer to external symbols
1743d656433aSmrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
1744d656433aSmrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
1745d656433aSmrg  -precious-files-regex REGEX
1746d656433aSmrg                    don't remove output files matching REGEX
1747d656433aSmrg  -release RELEASE  specify package release information
1748d656433aSmrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
1749d656433aSmrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
1750d656433aSmrg  -shared           only do dynamic linking of libtool libraries
1751d656433aSmrg  -shrext SUFFIX    override the standard shared library file extension
1752d656433aSmrg  -static           do not do any dynamic linking of uninstalled libtool libraries
1753d656433aSmrg  -static-libtool-libs
1754d656433aSmrg                    do not do any dynamic linking of libtool libraries
1755d656433aSmrg  -version-info CURRENT[:REVISION[:AGE]]
1756d656433aSmrg                    specify library version info [each variable defaults to 0]
1757d656433aSmrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
1758555991fdSmrg  -Wc,FLAG
1759555991fdSmrg  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
1760555991fdSmrg  -Wl,FLAG
1761555991fdSmrg  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
1762555991fdSmrg  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
1763126a8a12Smrg
1764d656433aSmrgAll other options (arguments beginning with \`-') are ignored.
1765126a8a12Smrg
1766d656433aSmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
1767d656433aSmrgtreated as uninstalled libtool libraries, other files are standard or library
1768d656433aSmrgobject files.
1769126a8a12Smrg
1770d656433aSmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
1771d656433aSmrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
1772d656433aSmrgrequired, except when creating a convenience library.
1773126a8a12Smrg
1774d656433aSmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
1775d656433aSmrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
1776126a8a12Smrg
1777d656433aSmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
1778d656433aSmrgis created, otherwise an executable program is created."
1779126a8a12Smrg        ;;
1780126a8a12Smrg
1781d656433aSmrg      uninstall)
1782d656433aSmrg        $ECHO \
1783d656433aSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
1784126a8a12Smrg
1785d656433aSmrgRemove libraries from an installation directory.
1786126a8a12Smrg
1787d656433aSmrgRM is the name of the program to use to delete files associated with each FILE
1788d656433aSmrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
1789d656433aSmrgto RM.
1790126a8a12Smrg
1791d656433aSmrgIf FILE is a libtool library, all the files associated with it are deleted.
1792d656433aSmrgOtherwise, only FILE itself is deleted using RM."
1793d656433aSmrg        ;;
1794126a8a12Smrg
1795d656433aSmrg      *)
1796d656433aSmrg        func_fatal_help "invalid operation mode \`$mode'"
1797d656433aSmrg        ;;
1798d656433aSmrg    esac
1799126a8a12Smrg
1800555991fdSmrg    echo
1801d656433aSmrg    $ECHO "Try \`$progname --help' for more information about other modes."
1802d656433aSmrg}
1803126a8a12Smrg
1804555991fdSmrg# Now that we've collected a possible --mode arg, show help if necessary
1805555991fdSmrgif $opt_help; then
1806555991fdSmrg  if test "$opt_help" = :; then
1807555991fdSmrg    func_mode_help
1808555991fdSmrg  else
1809555991fdSmrg    {
1810555991fdSmrg      func_help noexit
1811555991fdSmrg      for mode in compile link execute install finish uninstall clean; do
1812555991fdSmrg	func_mode_help
1813555991fdSmrg      done
1814555991fdSmrg    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
1815555991fdSmrg    {
1816555991fdSmrg      func_help noexit
1817555991fdSmrg      for mode in compile link execute install finish uninstall clean; do
1818555991fdSmrg	echo
1819555991fdSmrg	func_mode_help
1820555991fdSmrg      done
1821555991fdSmrg    } |
1822555991fdSmrg    sed '1d
1823555991fdSmrg      /^When reporting/,/^Report/{
1824555991fdSmrg	H
1825555991fdSmrg	d
1826555991fdSmrg      }
1827555991fdSmrg      $x
1828555991fdSmrg      /information about other modes/d
1829555991fdSmrg      /more detailed .*MODE/d
1830555991fdSmrg      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
1831555991fdSmrg  fi
1832555991fdSmrg  exit $?
1833555991fdSmrgfi
1834126a8a12Smrg
1835126a8a12Smrg
1836d656433aSmrg# func_mode_execute arg...
1837d656433aSmrgfunc_mode_execute ()
1838d656433aSmrg{
1839d656433aSmrg    $opt_debug
1840d656433aSmrg    # The first argument is the command name.
1841d656433aSmrg    cmd="$nonopt"
1842d656433aSmrg    test -z "$cmd" && \
1843d656433aSmrg      func_fatal_help "you must specify a COMMAND"
1844126a8a12Smrg
1845d656433aSmrg    # Handle -dlopen flags immediately.
1846d656433aSmrg    for file in $execute_dlfiles; do
1847d656433aSmrg      test -f "$file" \
1848d656433aSmrg	|| func_fatal_help "\`$file' is not a file"
1849126a8a12Smrg
1850d656433aSmrg      dir=
1851d656433aSmrg      case $file in
1852d656433aSmrg      *.la)
1853d656433aSmrg	# Check to see that this really is a libtool archive.
1854d656433aSmrg	func_lalib_unsafe_p "$file" \
1855d656433aSmrg	  || func_fatal_help "\`$lib' is not a valid libtool archive"
1856126a8a12Smrg
1857d656433aSmrg	# Read the libtool library.
1858d656433aSmrg	dlname=
1859d656433aSmrg	library_names=
1860d656433aSmrg	func_source "$file"
1861126a8a12Smrg
1862d656433aSmrg	# Skip this library if it cannot be dlopened.
1863d656433aSmrg	if test -z "$dlname"; then
1864d656433aSmrg	  # Warn if it was a shared library.
1865d656433aSmrg	  test -n "$library_names" && \
1866d656433aSmrg	    func_warning "\`$file' was not linked with \`-export-dynamic'"
1867d656433aSmrg	  continue
1868d656433aSmrg	fi
1869126a8a12Smrg
1870d656433aSmrg	func_dirname "$file" "" "."
1871d656433aSmrg	dir="$func_dirname_result"
1872126a8a12Smrg
1873d656433aSmrg	if test -f "$dir/$objdir/$dlname"; then
1874d656433aSmrg	  dir="$dir/$objdir"
1875d656433aSmrg	else
1876d656433aSmrg	  if test ! -f "$dir/$dlname"; then
1877d656433aSmrg	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
1878d656433aSmrg	  fi
1879d656433aSmrg	fi
1880126a8a12Smrg	;;
1881126a8a12Smrg
1882d656433aSmrg      *.lo)
1883d656433aSmrg	# Just add the directory containing the .lo file.
1884d656433aSmrg	func_dirname "$file" "" "."
1885d656433aSmrg	dir="$func_dirname_result"
1886126a8a12Smrg	;;
1887126a8a12Smrg
1888d656433aSmrg      *)
1889d656433aSmrg	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
1890126a8a12Smrg	continue
1891126a8a12Smrg	;;
1892d656433aSmrg      esac
1893126a8a12Smrg
1894d656433aSmrg      # Get the absolute pathname.
1895d656433aSmrg      absdir=`cd "$dir" && pwd`
1896d656433aSmrg      test -n "$absdir" && dir="$absdir"
1897126a8a12Smrg
1898d656433aSmrg      # Now add the directory to shlibpath_var.
1899d656433aSmrg      if eval "test -z \"\$$shlibpath_var\""; then
1900d656433aSmrg	eval "$shlibpath_var=\"\$dir\""
1901d656433aSmrg      else
1902d656433aSmrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
1903d656433aSmrg      fi
1904d656433aSmrg    done
1905126a8a12Smrg
1906d656433aSmrg    # This variable tells wrapper scripts just to set shlibpath_var
1907d656433aSmrg    # rather than running their programs.
1908d656433aSmrg    libtool_execute_magic="$magic"
1909126a8a12Smrg
1910d656433aSmrg    # Check if any of the arguments is a wrapper script.
1911d656433aSmrg    args=
1912d656433aSmrg    for file
1913d656433aSmrg    do
1914d656433aSmrg      case $file in
1915555991fdSmrg      -* | *.la | *.lo ) ;;
1916d656433aSmrg      *)
1917d656433aSmrg	# Do a test to see if this is really a libtool program.
1918d656433aSmrg	if func_ltwrapper_script_p "$file"; then
1919d656433aSmrg	  func_source "$file"
1920d656433aSmrg	  # Transform arg to wrapped name.
1921d656433aSmrg	  file="$progdir/$program"
1922d656433aSmrg	elif func_ltwrapper_executable_p "$file"; then
1923d656433aSmrg	  func_ltwrapper_scriptname "$file"
1924d656433aSmrg	  func_source "$func_ltwrapper_scriptname_result"
1925d656433aSmrg	  # Transform arg to wrapped name.
1926d656433aSmrg	  file="$progdir/$program"
1927d656433aSmrg	fi
1928d656433aSmrg	;;
1929d656433aSmrg      esac
1930d656433aSmrg      # Quote arguments (to preserve shell metacharacters).
1931d656433aSmrg      func_quote_for_eval "$file"
1932d656433aSmrg      args="$args $func_quote_for_eval_result"
1933d656433aSmrg    done
1934126a8a12Smrg
1935d656433aSmrg    if test "X$opt_dry_run" = Xfalse; then
1936d656433aSmrg      if test -n "$shlibpath_var"; then
1937d656433aSmrg	# Export the shlibpath_var.
1938d656433aSmrg	eval "export $shlibpath_var"
1939d656433aSmrg      fi
1940126a8a12Smrg
1941d656433aSmrg      # Restore saved environment variables
1942d656433aSmrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
1943d656433aSmrg      do
1944d656433aSmrg	eval "if test \"\${save_$lt_var+set}\" = set; then
1945d656433aSmrg                $lt_var=\$save_$lt_var; export $lt_var
1946d656433aSmrg	      else
1947d656433aSmrg		$lt_unset $lt_var
1948d656433aSmrg	      fi"
1949d656433aSmrg      done
1950126a8a12Smrg
1951d656433aSmrg      # Now prepare to actually exec the command.
1952d656433aSmrg      exec_cmd="\$cmd$args"
1953d656433aSmrg    else
1954d656433aSmrg      # Display what would be done.
1955d656433aSmrg      if test -n "$shlibpath_var"; then
1956d656433aSmrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
1957555991fdSmrg	echo "export $shlibpath_var"
1958d656433aSmrg      fi
1959d656433aSmrg      $ECHO "$cmd$args"
1960d656433aSmrg      exit $EXIT_SUCCESS
1961d656433aSmrg    fi
1962d656433aSmrg}
1963126a8a12Smrg
1964d656433aSmrgtest "$mode" = execute && func_mode_execute ${1+"$@"}
1965126a8a12Smrg
1966126a8a12Smrg
1967d656433aSmrg# func_mode_finish arg...
1968d656433aSmrgfunc_mode_finish ()
1969d656433aSmrg{
1970d656433aSmrg    $opt_debug
1971d656433aSmrg    libdirs="$nonopt"
1972d656433aSmrg    admincmds=
1973126a8a12Smrg
1974d656433aSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
1975d656433aSmrg      for dir
1976d656433aSmrg      do
1977d656433aSmrg	libdirs="$libdirs $dir"
1978d656433aSmrg      done
1979126a8a12Smrg
1980d656433aSmrg      for libdir in $libdirs; do
1981d656433aSmrg	if test -n "$finish_cmds"; then
1982d656433aSmrg	  # Do each command in the finish commands.
1983d656433aSmrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
1984d656433aSmrg'"$cmd"'"'
1985d656433aSmrg	fi
1986d656433aSmrg	if test -n "$finish_eval"; then
1987d656433aSmrg	  # Do the single finish_eval.
1988d656433aSmrg	  eval cmds=\"$finish_eval\"
1989d656433aSmrg	  $opt_dry_run || eval "$cmds" || admincmds="$admincmds
1990d656433aSmrg       $cmds"
1991d656433aSmrg	fi
1992d656433aSmrg      done
1993d656433aSmrg    fi
1994126a8a12Smrg
1995d656433aSmrg    # Exit here if they wanted silent mode.
1996d656433aSmrg    $opt_silent && exit $EXIT_SUCCESS
1997126a8a12Smrg
1998555991fdSmrg    echo "----------------------------------------------------------------------"
1999555991fdSmrg    echo "Libraries have been installed in:"
2000d656433aSmrg    for libdir in $libdirs; do
2001d656433aSmrg      $ECHO "   $libdir"
2002d656433aSmrg    done
2003555991fdSmrg    echo
2004555991fdSmrg    echo "If you ever happen to want to link against installed libraries"
2005555991fdSmrg    echo "in a given directory, LIBDIR, you must either use libtool, and"
2006555991fdSmrg    echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
2007555991fdSmrg    echo "flag during linking and do at least one of the following:"
2008d656433aSmrg    if test -n "$shlibpath_var"; then
2009555991fdSmrg      echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
2010555991fdSmrg      echo "     during execution"
2011d656433aSmrg    fi
2012d656433aSmrg    if test -n "$runpath_var"; then
2013555991fdSmrg      echo "   - add LIBDIR to the \`$runpath_var' environment variable"
2014555991fdSmrg      echo "     during linking"
2015d656433aSmrg    fi
2016d656433aSmrg    if test -n "$hardcode_libdir_flag_spec"; then
2017d656433aSmrg      libdir=LIBDIR
2018d656433aSmrg      eval flag=\"$hardcode_libdir_flag_spec\"
2019126a8a12Smrg
2020d656433aSmrg      $ECHO "   - use the \`$flag' linker flag"
2021d656433aSmrg    fi
2022d656433aSmrg    if test -n "$admincmds"; then
2023d656433aSmrg      $ECHO "   - have your system administrator run these commands:$admincmds"
2024d656433aSmrg    fi
2025d656433aSmrg    if test -f /etc/ld.so.conf; then
2026555991fdSmrg      echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
2027d656433aSmrg    fi
2028555991fdSmrg    echo
2029126a8a12Smrg
2030555991fdSmrg    echo "See any operating system documentation about shared libraries for"
2031d656433aSmrg    case $host in
2032d656433aSmrg      solaris2.[6789]|solaris2.1[0-9])
2033555991fdSmrg        echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
2034555991fdSmrg	echo "pages."
2035126a8a12Smrg	;;
2036d656433aSmrg      *)
2037555991fdSmrg        echo "more information, such as the ld(1) and ld.so(8) manual pages."
2038d656433aSmrg        ;;
2039d656433aSmrg    esac
2040555991fdSmrg    echo "----------------------------------------------------------------------"
2041d656433aSmrg    exit $EXIT_SUCCESS
2042d656433aSmrg}
2043126a8a12Smrg
2044d656433aSmrgtest "$mode" = finish && func_mode_finish ${1+"$@"}
2045126a8a12Smrg
2046126a8a12Smrg
2047d656433aSmrg# func_mode_install arg...
2048d656433aSmrgfunc_mode_install ()
2049d656433aSmrg{
2050d656433aSmrg    $opt_debug
2051d656433aSmrg    # There may be an optional sh(1) argument at the beginning of
2052d656433aSmrg    # install_prog (especially on Windows NT).
2053d656433aSmrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
2054d656433aSmrg       # Allow the use of GNU shtool's install command.
2055555991fdSmrg       case $nonopt in *shtool*) :;; *) false;; esac; then
2056d656433aSmrg      # Aesthetically quote it.
2057d656433aSmrg      func_quote_for_eval "$nonopt"
2058d656433aSmrg      install_prog="$func_quote_for_eval_result "
2059d656433aSmrg      arg=$1
2060d656433aSmrg      shift
2061d656433aSmrg    else
2062d656433aSmrg      install_prog=
2063d656433aSmrg      arg=$nonopt
2064d656433aSmrg    fi
2065126a8a12Smrg
2066d656433aSmrg    # The real first argument should be the name of the installation program.
2067d656433aSmrg    # Aesthetically quote it.
2068d656433aSmrg    func_quote_for_eval "$arg"
2069d656433aSmrg    install_prog="$install_prog$func_quote_for_eval_result"
2070555991fdSmrg    install_shared_prog=$install_prog
2071555991fdSmrg    case " $install_prog " in
2072555991fdSmrg      *[\\\ /]cp\ *) install_cp=: ;;
2073555991fdSmrg      *) install_cp=false ;;
2074555991fdSmrg    esac
2075d656433aSmrg
2076d656433aSmrg    # We need to accept at least all the BSD install flags.
2077d656433aSmrg    dest=
2078d656433aSmrg    files=
2079d656433aSmrg    opts=
2080d656433aSmrg    prev=
2081d656433aSmrg    install_type=
2082d656433aSmrg    isdir=no
2083d656433aSmrg    stripme=
2084555991fdSmrg    no_mode=:
2085d656433aSmrg    for arg
2086d656433aSmrg    do
2087555991fdSmrg      arg2=
2088d656433aSmrg      if test -n "$dest"; then
2089d656433aSmrg	files="$files $dest"
2090d656433aSmrg	dest=$arg
2091d656433aSmrg	continue
2092126a8a12Smrg      fi
2093126a8a12Smrg
2094d656433aSmrg      case $arg in
2095d656433aSmrg      -d) isdir=yes ;;
2096d656433aSmrg      -f)
2097555991fdSmrg	if $install_cp; then :; else
2098555991fdSmrg	  prev=$arg
2099555991fdSmrg	fi
2100d656433aSmrg	;;
2101d656433aSmrg      -g | -m | -o)
2102d656433aSmrg	prev=$arg
2103d656433aSmrg	;;
2104d656433aSmrg      -s)
2105d656433aSmrg	stripme=" -s"
2106d656433aSmrg	continue
2107d656433aSmrg	;;
2108d656433aSmrg      -*)
2109d656433aSmrg	;;
2110d656433aSmrg      *)
2111d656433aSmrg	# If the previous option needed an argument, then skip it.
2112d656433aSmrg	if test -n "$prev"; then
2113555991fdSmrg	  if test "x$prev" = x-m && test -n "$install_override_mode"; then
2114555991fdSmrg	    arg2=$install_override_mode
2115555991fdSmrg	    no_mode=false
2116555991fdSmrg	  fi
2117d656433aSmrg	  prev=
2118d656433aSmrg	else
2119d656433aSmrg	  dest=$arg
2120d656433aSmrg	  continue
2121d656433aSmrg	fi
2122d656433aSmrg	;;
2123d656433aSmrg      esac
2124126a8a12Smrg
2125d656433aSmrg      # Aesthetically quote the argument.
2126d656433aSmrg      func_quote_for_eval "$arg"
2127d656433aSmrg      install_prog="$install_prog $func_quote_for_eval_result"
2128555991fdSmrg      if test -n "$arg2"; then
2129555991fdSmrg	func_quote_for_eval "$arg2"
2130555991fdSmrg      fi
2131555991fdSmrg      install_shared_prog="$install_shared_prog $func_quote_for_eval_result"
2132d656433aSmrg    done
2133126a8a12Smrg
2134d656433aSmrg    test -z "$install_prog" && \
2135d656433aSmrg      func_fatal_help "you must specify an install program"
2136126a8a12Smrg
2137d656433aSmrg    test -n "$prev" && \
2138d656433aSmrg      func_fatal_help "the \`$prev' option requires an argument"
2139126a8a12Smrg
2140555991fdSmrg    if test -n "$install_override_mode" && $no_mode; then
2141555991fdSmrg      if $install_cp; then :; else
2142555991fdSmrg	func_quote_for_eval "$install_override_mode"
2143555991fdSmrg	install_shared_prog="$install_shared_prog -m $func_quote_for_eval_result"
2144555991fdSmrg      fi
2145555991fdSmrg    fi
2146555991fdSmrg
2147d656433aSmrg    if test -z "$files"; then
2148d656433aSmrg      if test -z "$dest"; then
2149d656433aSmrg	func_fatal_help "no file or destination specified"
2150d656433aSmrg      else
2151d656433aSmrg	func_fatal_help "you must specify a destination"
2152126a8a12Smrg      fi
2153126a8a12Smrg    fi
2154126a8a12Smrg
2155d656433aSmrg    # Strip any trailing slash from the destination.
2156d656433aSmrg    func_stripname '' '/' "$dest"
2157d656433aSmrg    dest=$func_stripname_result
2158126a8a12Smrg
2159d656433aSmrg    # Check to see that the destination is a directory.
2160d656433aSmrg    test -d "$dest" && isdir=yes
2161d656433aSmrg    if test "$isdir" = yes; then
2162d656433aSmrg      destdir="$dest"
2163d656433aSmrg      destname=
2164d656433aSmrg    else
2165d656433aSmrg      func_dirname_and_basename "$dest" "" "."
2166d656433aSmrg      destdir="$func_dirname_result"
2167d656433aSmrg      destname="$func_basename_result"
2168d656433aSmrg
2169d656433aSmrg      # Not a directory, so check to see that there is only one file specified.
2170d656433aSmrg      set dummy $files; shift
2171d656433aSmrg      test "$#" -gt 1 && \
2172d656433aSmrg	func_fatal_help "\`$dest' is not a directory"
2173d656433aSmrg    fi
2174d656433aSmrg    case $destdir in
2175d656433aSmrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
2176126a8a12Smrg    *)
2177d656433aSmrg      for file in $files; do
2178d656433aSmrg	case $file in
2179d656433aSmrg	*.lo) ;;
2180d656433aSmrg	*)
2181d656433aSmrg	  func_fatal_help "\`$destdir' must be an absolute directory name"
2182d656433aSmrg	  ;;
2183d656433aSmrg	esac
2184d656433aSmrg      done
2185126a8a12Smrg      ;;
2186126a8a12Smrg    esac
2187126a8a12Smrg
2188d656433aSmrg    # This variable tells wrapper scripts just to set variables rather
2189d656433aSmrg    # than running their programs.
2190d656433aSmrg    libtool_install_magic="$magic"
2191126a8a12Smrg
2192d656433aSmrg    staticlibs=
2193d656433aSmrg    future_libdirs=
2194d656433aSmrg    current_libdirs=
2195d656433aSmrg    for file in $files; do
2196126a8a12Smrg
2197d656433aSmrg      # Do each installation.
2198d656433aSmrg      case $file in
2199d656433aSmrg      *.$libext)
2200d656433aSmrg	# Do the static libraries later.
2201d656433aSmrg	staticlibs="$staticlibs $file"
2202d656433aSmrg	;;
2203d656433aSmrg
2204d656433aSmrg      *.la)
2205d656433aSmrg	# Check to see that this really is a libtool archive.
2206d656433aSmrg	func_lalib_unsafe_p "$file" \
2207d656433aSmrg	  || func_fatal_help "\`$file' is not a valid libtool archive"
2208d656433aSmrg
2209d656433aSmrg	library_names=
2210d656433aSmrg	old_library=
2211d656433aSmrg	relink_command=
2212d656433aSmrg	func_source "$file"
2213d656433aSmrg
2214d656433aSmrg	# Add the libdir to current_libdirs if it is the destination.
2215d656433aSmrg	if test "X$destdir" = "X$libdir"; then
2216d656433aSmrg	  case "$current_libdirs " in
2217d656433aSmrg	  *" $libdir "*) ;;
2218d656433aSmrg	  *) current_libdirs="$current_libdirs $libdir" ;;
2219126a8a12Smrg	  esac
2220d656433aSmrg	else
2221d656433aSmrg	  # Note the libdir as a future libdir.
2222d656433aSmrg	  case "$future_libdirs " in
2223d656433aSmrg	  *" $libdir "*) ;;
2224d656433aSmrg	  *) future_libdirs="$future_libdirs $libdir" ;;
2225d656433aSmrg	  esac
2226d656433aSmrg	fi
2227126a8a12Smrg
2228d656433aSmrg	func_dirname "$file" "/" ""
2229d656433aSmrg	dir="$func_dirname_result"
2230d656433aSmrg	dir="$dir$objdir"
2231d656433aSmrg
2232d656433aSmrg	if test -n "$relink_command"; then
2233d656433aSmrg	  # Determine the prefix the user has applied to our future dir.
2234555991fdSmrg	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
2235d656433aSmrg
2236d656433aSmrg	  # Don't allow the user to place us outside of our expected
2237d656433aSmrg	  # location b/c this prevents finding dependent libraries that
2238d656433aSmrg	  # are installed to the same prefix.
2239d656433aSmrg	  # At present, this check doesn't affect windows .dll's that
2240d656433aSmrg	  # are installed into $libdir/../bin (currently, that works fine)
2241d656433aSmrg	  # but it's something to keep an eye on.
2242d656433aSmrg	  test "$inst_prefix_dir" = "$destdir" && \
2243d656433aSmrg	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
2244d656433aSmrg
2245d656433aSmrg	  if test -n "$inst_prefix_dir"; then
2246d656433aSmrg	    # Stick the inst_prefix_dir data into the link command.
2247555991fdSmrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
2248d656433aSmrg	  else
2249555991fdSmrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
2250d656433aSmrg	  fi
2251d656433aSmrg
2252d656433aSmrg	  func_warning "relinking \`$file'"
2253d656433aSmrg	  func_show_eval "$relink_command" \
2254d656433aSmrg	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
2255d656433aSmrg	fi
2256d656433aSmrg
2257d656433aSmrg	# See the names of the shared library.
2258d656433aSmrg	set dummy $library_names; shift
2259d656433aSmrg	if test -n "$1"; then
2260d656433aSmrg	  realname="$1"
2261d656433aSmrg	  shift
2262d656433aSmrg
2263d656433aSmrg	  srcname="$realname"
2264d656433aSmrg	  test -n "$relink_command" && srcname="$realname"T
2265d656433aSmrg
2266d656433aSmrg	  # Install the shared library and build the symlinks.
2267555991fdSmrg	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
2268d656433aSmrg	      'exit $?'
2269d656433aSmrg	  tstripme="$stripme"
2270d656433aSmrg	  case $host_os in
2271d656433aSmrg	  cygwin* | mingw* | pw32* | cegcc*)
2272d656433aSmrg	    case $realname in
2273d656433aSmrg	    *.dll.a)
2274d656433aSmrg	      tstripme=""
2275d656433aSmrg	      ;;
2276d656433aSmrg	    esac
2277126a8a12Smrg	    ;;
2278126a8a12Smrg	  esac
2279d656433aSmrg	  if test -n "$tstripme" && test -n "$striplib"; then
2280d656433aSmrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
2281126a8a12Smrg	  fi
2282d656433aSmrg
2283d656433aSmrg	  if test "$#" -gt 0; then
2284d656433aSmrg	    # Delete the old symlinks, and create new ones.
2285d656433aSmrg	    # Try `ln -sf' first, because the `ln' binary might depend on
2286d656433aSmrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
2287d656433aSmrg	    # so we also need to try rm && ln -s.
2288d656433aSmrg	    for linkname
2289d656433aSmrg	    do
2290d656433aSmrg	      test "$linkname" != "$realname" \
2291d656433aSmrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
2292126a8a12Smrg	    done
2293126a8a12Smrg	  fi
2294126a8a12Smrg
2295d656433aSmrg	  # Do each command in the postinstall commands.
2296d656433aSmrg	  lib="$destdir/$realname"
2297d656433aSmrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
2298126a8a12Smrg	fi
2299126a8a12Smrg
2300d656433aSmrg	# Install the pseudo-library for information purposes.
2301d656433aSmrg	func_basename "$file"
2302d656433aSmrg	name="$func_basename_result"
2303d656433aSmrg	instname="$dir/$name"i
2304d656433aSmrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
2305126a8a12Smrg
2306d656433aSmrg	# Maybe install the static library, too.
2307d656433aSmrg	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
2308d656433aSmrg	;;
2309126a8a12Smrg
2310d656433aSmrg      *.lo)
2311d656433aSmrg	# Install (i.e. copy) a libtool object.
2312126a8a12Smrg
2313d656433aSmrg	# Figure out destination file name, if it wasn't already specified.
2314d656433aSmrg	if test -n "$destname"; then
2315d656433aSmrg	  destfile="$destdir/$destname"
2316d656433aSmrg	else
2317d656433aSmrg	  func_basename "$file"
2318d656433aSmrg	  destfile="$func_basename_result"
2319d656433aSmrg	  destfile="$destdir/$destfile"
2320d656433aSmrg	fi
2321d656433aSmrg
2322d656433aSmrg	# Deduce the name of the destination old-style object file.
2323d656433aSmrg	case $destfile in
2324d656433aSmrg	*.lo)
2325d656433aSmrg	  func_lo2o "$destfile"
2326d656433aSmrg	  staticdest=$func_lo2o_result
2327d656433aSmrg	  ;;
2328d656433aSmrg	*.$objext)
2329d656433aSmrg	  staticdest="$destfile"
2330d656433aSmrg	  destfile=
2331d656433aSmrg	  ;;
2332d656433aSmrg	*)
2333d656433aSmrg	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
2334d656433aSmrg	  ;;
2335126a8a12Smrg	esac
2336126a8a12Smrg
2337d656433aSmrg	# Install the libtool object if requested.
2338d656433aSmrg	test -n "$destfile" && \
2339d656433aSmrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
2340d656433aSmrg
2341d656433aSmrg	# Install the old object if enabled.
2342d656433aSmrg	if test "$build_old_libs" = yes; then
2343d656433aSmrg	  # Deduce the name of the old-style object file.
2344d656433aSmrg	  func_lo2o "$file"
2345d656433aSmrg	  staticobj=$func_lo2o_result
2346d656433aSmrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
2347126a8a12Smrg	fi
2348d656433aSmrg	exit $EXIT_SUCCESS
2349d656433aSmrg	;;
2350126a8a12Smrg
2351d656433aSmrg      *)
2352d656433aSmrg	# Figure out destination file name, if it wasn't already specified.
2353d656433aSmrg	if test -n "$destname"; then
2354d656433aSmrg	  destfile="$destdir/$destname"
2355d656433aSmrg	else
2356d656433aSmrg	  func_basename "$file"
2357d656433aSmrg	  destfile="$func_basename_result"
2358d656433aSmrg	  destfile="$destdir/$destfile"
2359d656433aSmrg	fi
2360d656433aSmrg
2361d656433aSmrg	# If the file is missing, and there is a .exe on the end, strip it
2362d656433aSmrg	# because it is most likely a libtool script we actually want to
2363d656433aSmrg	# install
2364d656433aSmrg	stripped_ext=""
2365d656433aSmrg	case $file in
2366d656433aSmrg	  *.exe)
2367d656433aSmrg	    if test ! -f "$file"; then
2368d656433aSmrg	      func_stripname '' '.exe' "$file"
2369d656433aSmrg	      file=$func_stripname_result
2370d656433aSmrg	      stripped_ext=".exe"
2371126a8a12Smrg	    fi
2372d656433aSmrg	    ;;
2373d656433aSmrg	esac
2374126a8a12Smrg
2375d656433aSmrg	# Do a test to see if this is really a libtool program.
2376d656433aSmrg	case $host in
2377d656433aSmrg	*cygwin* | *mingw*)
2378d656433aSmrg	    if func_ltwrapper_executable_p "$file"; then
2379d656433aSmrg	      func_ltwrapper_scriptname "$file"
2380d656433aSmrg	      wrapper=$func_ltwrapper_scriptname_result
2381d656433aSmrg	    else
2382d656433aSmrg	      func_stripname '' '.exe' "$file"
2383d656433aSmrg	      wrapper=$func_stripname_result
2384d656433aSmrg	    fi
2385d656433aSmrg	    ;;
2386d656433aSmrg	*)
2387d656433aSmrg	    wrapper=$file
2388d656433aSmrg	    ;;
2389d656433aSmrg	esac
2390d656433aSmrg	if func_ltwrapper_script_p "$wrapper"; then
2391d656433aSmrg	  notinst_deplibs=
2392d656433aSmrg	  relink_command=
2393126a8a12Smrg
2394d656433aSmrg	  func_source "$wrapper"
2395126a8a12Smrg
2396d656433aSmrg	  # Check the variables that should have been set.
2397d656433aSmrg	  test -z "$generated_by_libtool_version" && \
2398d656433aSmrg	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
2399d656433aSmrg
2400d656433aSmrg	  finalize=yes
2401d656433aSmrg	  for lib in $notinst_deplibs; do
2402d656433aSmrg	    # Check to see that each library is installed.
2403d656433aSmrg	    libdir=
2404d656433aSmrg	    if test -f "$lib"; then
2405d656433aSmrg	      func_source "$lib"
2406d656433aSmrg	    fi
2407555991fdSmrg	    libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
2408d656433aSmrg	    if test -n "$libdir" && test ! -f "$libfile"; then
2409d656433aSmrg	      func_warning "\`$lib' has not been installed in \`$libdir'"
2410d656433aSmrg	      finalize=no
2411d656433aSmrg	    fi
2412d656433aSmrg	  done
2413d656433aSmrg
2414d656433aSmrg	  relink_command=
2415d656433aSmrg	  func_source "$wrapper"
2416d656433aSmrg
2417d656433aSmrg	  outputname=
2418d656433aSmrg	  if test "$fast_install" = no && test -n "$relink_command"; then
2419d656433aSmrg	    $opt_dry_run || {
2420d656433aSmrg	      if test "$finalize" = yes; then
2421d656433aSmrg	        tmpdir=`func_mktempdir`
2422d656433aSmrg		func_basename "$file$stripped_ext"
2423d656433aSmrg		file="$func_basename_result"
2424d656433aSmrg	        outputname="$tmpdir/$file"
2425d656433aSmrg	        # Replace the output file specification.
2426555991fdSmrg	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
2427d656433aSmrg
2428d656433aSmrg	        $opt_silent || {
2429d656433aSmrg	          func_quote_for_expand "$relink_command"
2430d656433aSmrg		  eval "func_echo $func_quote_for_expand_result"
2431d656433aSmrg	        }
2432d656433aSmrg	        if eval "$relink_command"; then :
2433d656433aSmrg	          else
2434d656433aSmrg		  func_error "error: relink \`$file' with the above command before installing it"
2435d656433aSmrg		  $opt_dry_run || ${RM}r "$tmpdir"
2436d656433aSmrg		  continue
2437d656433aSmrg	        fi
2438d656433aSmrg	        file="$outputname"
2439d656433aSmrg	      else
2440d656433aSmrg	        func_warning "cannot relink \`$file'"
2441d656433aSmrg	      fi
2442d656433aSmrg	    }
2443126a8a12Smrg	  else
2444d656433aSmrg	    # Install the binary that we compiled earlier.
2445555991fdSmrg	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
2446126a8a12Smrg	  fi
2447d656433aSmrg	fi
2448126a8a12Smrg
2449d656433aSmrg	# remove .exe since cygwin /usr/bin/install will append another
2450d656433aSmrg	# one anyway
2451d656433aSmrg	case $install_prog,$host in
2452d656433aSmrg	*/usr/bin/install*,*cygwin*)
2453d656433aSmrg	  case $file:$destfile in
2454d656433aSmrg	  *.exe:*.exe)
2455d656433aSmrg	    # this is ok
2456d656433aSmrg	    ;;
2457d656433aSmrg	  *.exe:*)
2458d656433aSmrg	    destfile=$destfile.exe
2459d656433aSmrg	    ;;
2460d656433aSmrg	  *:*.exe)
2461d656433aSmrg	    func_stripname '' '.exe' "$destfile"
2462d656433aSmrg	    destfile=$func_stripname_result
2463d656433aSmrg	    ;;
2464d656433aSmrg	  esac
2465126a8a12Smrg	  ;;
2466126a8a12Smrg	esac
2467d656433aSmrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
2468d656433aSmrg	$opt_dry_run || if test -n "$outputname"; then
2469d656433aSmrg	  ${RM}r "$tmpdir"
2470d656433aSmrg	fi
2471d656433aSmrg	;;
2472d656433aSmrg      esac
2473d656433aSmrg    done
2474126a8a12Smrg
2475d656433aSmrg    for file in $staticlibs; do
2476d656433aSmrg      func_basename "$file"
2477d656433aSmrg      name="$func_basename_result"
2478126a8a12Smrg
2479d656433aSmrg      # Set up the ranlib parameters.
2480d656433aSmrg      oldlib="$destdir/$name"
2481126a8a12Smrg
2482d656433aSmrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
2483126a8a12Smrg
2484d656433aSmrg      if test -n "$stripme" && test -n "$old_striplib"; then
2485d656433aSmrg	func_show_eval "$old_striplib $oldlib" 'exit $?'
2486d656433aSmrg      fi
2487126a8a12Smrg
2488d656433aSmrg      # Do each command in the postinstall commands.
2489d656433aSmrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
2490d656433aSmrg    done
2491126a8a12Smrg
2492d656433aSmrg    test -n "$future_libdirs" && \
2493d656433aSmrg      func_warning "remember to run \`$progname --finish$future_libdirs'"
2494126a8a12Smrg
2495d656433aSmrg    if test -n "$current_libdirs"; then
2496d656433aSmrg      # Maybe just do a dry run.
2497d656433aSmrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
2498d656433aSmrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
2499d656433aSmrg    else
2500d656433aSmrg      exit $EXIT_SUCCESS
2501d656433aSmrg    fi
2502d656433aSmrg}
2503126a8a12Smrg
2504d656433aSmrgtest "$mode" = install && func_mode_install ${1+"$@"}
2505126a8a12Smrg
2506126a8a12Smrg
2507d656433aSmrg# func_generate_dlsyms outputname originator pic_p
2508d656433aSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with
2509d656433aSmrg# a dlpreopen symbol table.
2510d656433aSmrgfunc_generate_dlsyms ()
2511d656433aSmrg{
2512d656433aSmrg    $opt_debug
2513d656433aSmrg    my_outputname="$1"
2514d656433aSmrg    my_originator="$2"
2515d656433aSmrg    my_pic_p="${3-no}"
2516d656433aSmrg    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
2517d656433aSmrg    my_dlsyms=
2518d656433aSmrg
2519d656433aSmrg    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
2520d656433aSmrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
2521d656433aSmrg	my_dlsyms="${my_outputname}S.c"
2522d656433aSmrg      else
2523d656433aSmrg	func_error "not configured to extract global symbols from dlpreopened files"
2524d656433aSmrg      fi
2525d656433aSmrg    fi
2526126a8a12Smrg
2527d656433aSmrg    if test -n "$my_dlsyms"; then
2528d656433aSmrg      case $my_dlsyms in
2529d656433aSmrg      "") ;;
2530d656433aSmrg      *.c)
2531d656433aSmrg	# Discover the nlist of each of the dlfiles.
2532d656433aSmrg	nlist="$output_objdir/${my_outputname}.nm"
2533d656433aSmrg
2534d656433aSmrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
2535d656433aSmrg
2536d656433aSmrg	# Parse the name list into a source file.
2537d656433aSmrg	func_verbose "creating $output_objdir/$my_dlsyms"
2538d656433aSmrg
2539d656433aSmrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
2540d656433aSmrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
2541d656433aSmrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
2542d656433aSmrg
2543d656433aSmrg#ifdef __cplusplus
2544d656433aSmrgextern \"C\" {
2545d656433aSmrg#endif
2546d656433aSmrg
2547555991fdSmrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
2548555991fdSmrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
2549555991fdSmrg#endif
2550555991fdSmrg
2551d656433aSmrg/* External symbol declarations for the compiler. */\
2552d656433aSmrg"
2553d656433aSmrg
2554d656433aSmrg	if test "$dlself" = yes; then
2555d656433aSmrg	  func_verbose "generating symbol list for \`$output'"
2556d656433aSmrg
2557d656433aSmrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
2558d656433aSmrg
2559d656433aSmrg	  # Add our own program objects to the symbol list.
2560555991fdSmrg	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
2561d656433aSmrg	  for progfile in $progfiles; do
2562d656433aSmrg	    func_verbose "extracting global C symbols from \`$progfile'"
2563d656433aSmrg	    $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'"
2564d656433aSmrg	  done
2565d656433aSmrg
2566d656433aSmrg	  if test -n "$exclude_expsyms"; then
2567d656433aSmrg	    $opt_dry_run || {
2568d656433aSmrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
2569d656433aSmrg	      eval '$MV "$nlist"T "$nlist"'
2570d656433aSmrg	    }
2571126a8a12Smrg	  fi
2572126a8a12Smrg
2573d656433aSmrg	  if test -n "$export_symbols_regex"; then
2574d656433aSmrg	    $opt_dry_run || {
2575d656433aSmrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
2576d656433aSmrg	      eval '$MV "$nlist"T "$nlist"'
2577d656433aSmrg	    }
2578126a8a12Smrg	  fi
2579d656433aSmrg
2580d656433aSmrg	  # Prepare the list of exported symbols
2581d656433aSmrg	  if test -z "$export_symbols"; then
2582d656433aSmrg	    export_symbols="$output_objdir/$outputname.exp"
2583d656433aSmrg	    $opt_dry_run || {
2584d656433aSmrg	      $RM $export_symbols
2585d656433aSmrg	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
2586d656433aSmrg	      case $host in
2587d656433aSmrg	      *cygwin* | *mingw* | *cegcc* )
2588d656433aSmrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
2589d656433aSmrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
2590d656433aSmrg	        ;;
2591126a8a12Smrg	      esac
2592d656433aSmrg	    }
2593d656433aSmrg	  else
2594d656433aSmrg	    $opt_dry_run || {
2595d656433aSmrg	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
2596d656433aSmrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
2597d656433aSmrg	      eval '$MV "$nlist"T "$nlist"'
2598d656433aSmrg	      case $host in
2599555991fdSmrg	        *cygwin* | *mingw* | *cegcc* )
2600d656433aSmrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
2601d656433aSmrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
2602d656433aSmrg	          ;;
2603126a8a12Smrg	      esac
2604d656433aSmrg	    }
2605126a8a12Smrg	  fi
2606d656433aSmrg	fi
2607126a8a12Smrg
2608d656433aSmrg	for dlprefile in $dlprefiles; do
2609d656433aSmrg	  func_verbose "extracting global C symbols from \`$dlprefile'"
2610d656433aSmrg	  func_basename "$dlprefile"
2611d656433aSmrg	  name="$func_basename_result"
2612d656433aSmrg	  $opt_dry_run || {
2613d656433aSmrg	    eval '$ECHO ": $name " >> "$nlist"'
2614d656433aSmrg	    eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'"
2615d656433aSmrg	  }
2616d656433aSmrg	done
2617126a8a12Smrg
2618d656433aSmrg	$opt_dry_run || {
2619d656433aSmrg	  # Make sure we have at least an empty file.
2620d656433aSmrg	  test -f "$nlist" || : > "$nlist"
2621126a8a12Smrg
2622d656433aSmrg	  if test -n "$exclude_expsyms"; then
2623d656433aSmrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
2624d656433aSmrg	    $MV "$nlist"T "$nlist"
2625126a8a12Smrg	  fi
2626126a8a12Smrg
2627d656433aSmrg	  # Try sorting and uniquifying the output.
2628d656433aSmrg	  if $GREP -v "^: " < "$nlist" |
2629d656433aSmrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
2630d656433aSmrg		sort -k 3
2631126a8a12Smrg	      else
2632d656433aSmrg		sort +2
2633d656433aSmrg	      fi |
2634d656433aSmrg	      uniq > "$nlist"S; then
2635d656433aSmrg	    :
2636126a8a12Smrg	  else
2637d656433aSmrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
2638126a8a12Smrg	  fi
2639126a8a12Smrg
2640d656433aSmrg	  if test -f "$nlist"S; then
2641d656433aSmrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
2642126a8a12Smrg	  else
2643555991fdSmrg	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
2644126a8a12Smrg	  fi
2645126a8a12Smrg
2646555991fdSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
2647126a8a12Smrg
2648d656433aSmrg/* The mapping between symbol names and symbols.  */
2649d656433aSmrgtypedef struct {
2650d656433aSmrg  const char *name;
2651d656433aSmrg  void *address;
2652d656433aSmrg} lt_dlsymlist;
2653d656433aSmrg"
2654d656433aSmrg	  case $host in
2655d656433aSmrg	  *cygwin* | *mingw* | *cegcc* )
2656555991fdSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
2657d656433aSmrg/* DATA imports from DLLs on WIN32 con't be const, because
2658d656433aSmrg   runtime relocations are performed -- see ld's documentation
2659d656433aSmrg   on pseudo-relocs.  */"
2660d656433aSmrg	    lt_dlsym_const= ;;
2661d656433aSmrg	  *osf5*)
2662d656433aSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
2663d656433aSmrg/* This system does not cope well with relocations in const data */"
2664d656433aSmrg	    lt_dlsym_const= ;;
2665d656433aSmrg	  *)
2666d656433aSmrg	    lt_dlsym_const=const ;;
2667d656433aSmrg	  esac
2668d656433aSmrg
2669555991fdSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
2670d656433aSmrgextern $lt_dlsym_const lt_dlsymlist
2671d656433aSmrglt_${my_prefix}_LTX_preloaded_symbols[];
2672d656433aSmrg$lt_dlsym_const lt_dlsymlist
2673d656433aSmrglt_${my_prefix}_LTX_preloaded_symbols[] =
2674d656433aSmrg{\
2675d656433aSmrg  { \"$my_originator\", (void *) 0 },"
2676d656433aSmrg
2677d656433aSmrg	  case $need_lib_prefix in
2678d656433aSmrg	  no)
2679d656433aSmrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
2680d656433aSmrg	    ;;
2681d656433aSmrg	  *)
2682d656433aSmrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
2683d656433aSmrg	    ;;
2684d656433aSmrg	  esac
2685555991fdSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
2686d656433aSmrg  {0, (void *) 0}
2687d656433aSmrg};
2688d656433aSmrg
2689d656433aSmrg/* This works around a problem in FreeBSD linker */
2690d656433aSmrg#ifdef FREEBSD_WORKAROUND
2691d656433aSmrgstatic const void *lt_preloaded_setup() {
2692d656433aSmrg  return lt_${my_prefix}_LTX_preloaded_symbols;
2693d656433aSmrg}
2694d656433aSmrg#endif
2695d656433aSmrg
2696d656433aSmrg#ifdef __cplusplus
2697d656433aSmrg}
2698d656433aSmrg#endif\
2699d656433aSmrg"
2700d656433aSmrg	} # !$opt_dry_run
2701d656433aSmrg
2702d656433aSmrg	pic_flag_for_symtable=
2703d656433aSmrg	case "$compile_command " in
2704d656433aSmrg	*" -static "*) ;;
2705d656433aSmrg	*)
2706d656433aSmrg	  case $host in
2707d656433aSmrg	  # compiling the symbol table file with pic_flag works around
2708d656433aSmrg	  # a FreeBSD bug that causes programs to crash when -lm is
2709d656433aSmrg	  # linked before any other PIC object.  But we must not use
2710d656433aSmrg	  # pic_flag when linking with -static.  The problem exists in
2711d656433aSmrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
2712d656433aSmrg	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
2713d656433aSmrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
2714d656433aSmrg	  *-*-hpux*)
2715d656433aSmrg	    pic_flag_for_symtable=" $pic_flag"  ;;
2716d656433aSmrg	  *)
2717d656433aSmrg	    if test "X$my_pic_p" != Xno; then
2718d656433aSmrg	      pic_flag_for_symtable=" $pic_flag"
2719126a8a12Smrg	    fi
2720d656433aSmrg	    ;;
2721d656433aSmrg	  esac
2722d656433aSmrg	  ;;
2723d656433aSmrg	esac
2724d656433aSmrg	symtab_cflags=
2725d656433aSmrg	for arg in $LTCFLAGS; do
2726d656433aSmrg	  case $arg in
2727d656433aSmrg	  -pie | -fpie | -fPIE) ;;
2728d656433aSmrg	  *) symtab_cflags="$symtab_cflags $arg" ;;
2729d656433aSmrg	  esac
2730d656433aSmrg	done
2731126a8a12Smrg
2732d656433aSmrg	# Now compile the dynamic symbol file.
2733d656433aSmrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
2734126a8a12Smrg
2735d656433aSmrg	# Clean up the generated files.
2736d656433aSmrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
2737d656433aSmrg
2738d656433aSmrg	# Transform the symbol file into the correct name.
2739d656433aSmrg	symfileobj="$output_objdir/${my_outputname}S.$objext"
2740d656433aSmrg	case $host in
2741d656433aSmrg	*cygwin* | *mingw* | *cegcc* )
2742d656433aSmrg	  if test -f "$output_objdir/$my_outputname.def"; then
2743555991fdSmrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
2744555991fdSmrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
2745d656433aSmrg	  else
2746555991fdSmrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
2747555991fdSmrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
2748d656433aSmrg	  fi
2749d656433aSmrg	  ;;
2750d656433aSmrg	*)
2751555991fdSmrg	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
2752555991fdSmrg	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
2753126a8a12Smrg	  ;;
2754126a8a12Smrg	esac
2755d656433aSmrg	;;
2756d656433aSmrg      *)
2757d656433aSmrg	func_fatal_error "unknown suffix for \`$my_dlsyms'"
2758d656433aSmrg	;;
2759d656433aSmrg      esac
2760d656433aSmrg    else
2761d656433aSmrg      # We keep going just in case the user didn't refer to
2762d656433aSmrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
2763d656433aSmrg      # really was required.
2764d656433aSmrg
2765d656433aSmrg      # Nullify the symbol file.
2766555991fdSmrg      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
2767555991fdSmrg      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
2768126a8a12Smrg    fi
2769d656433aSmrg}
2770126a8a12Smrg
2771d656433aSmrg# func_win32_libid arg
2772d656433aSmrg# return the library type of file 'arg'
2773d656433aSmrg#
2774d656433aSmrg# Need a lot of goo to handle *both* DLLs and import libs
2775d656433aSmrg# Has to be a shell function in order to 'eat' the argument
2776d656433aSmrg# that is supplied when $file_magic_command is called.
2777555991fdSmrg# Despite the name, also deal with 64 bit binaries.
2778d656433aSmrgfunc_win32_libid ()
2779d656433aSmrg{
2780d656433aSmrg  $opt_debug
2781d656433aSmrg  win32_libid_type="unknown"
2782d656433aSmrg  win32_fileres=`file -L $1 2>/dev/null`
2783d656433aSmrg  case $win32_fileres in
2784d656433aSmrg  *ar\ archive\ import\ library*) # definitely import
2785d656433aSmrg    win32_libid_type="x86 archive import"
2786d656433aSmrg    ;;
2787d656433aSmrg  *ar\ archive*) # could be an import, or static
2788555991fdSmrg    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
2789d656433aSmrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
2790555991fdSmrg       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
2791d656433aSmrg      win32_nmres=`eval $NM -f posix -A $1 |
2792d656433aSmrg	$SED -n -e '
2793d656433aSmrg	    1,100{
2794d656433aSmrg		/ I /{
2795d656433aSmrg		    s,.*,import,
2796d656433aSmrg		    p
2797d656433aSmrg		    q
2798d656433aSmrg		}
2799d656433aSmrg	    }'`
2800d656433aSmrg      case $win32_nmres in
2801d656433aSmrg      import*)  win32_libid_type="x86 archive import";;
2802d656433aSmrg      *)        win32_libid_type="x86 archive static";;
2803d656433aSmrg      esac
2804d656433aSmrg    fi
2805d656433aSmrg    ;;
2806d656433aSmrg  *DLL*)
2807d656433aSmrg    win32_libid_type="x86 DLL"
2808d656433aSmrg    ;;
2809d656433aSmrg  *executable*) # but shell scripts are "executable" too...
2810d656433aSmrg    case $win32_fileres in
2811d656433aSmrg    *MS\ Windows\ PE\ Intel*)
2812d656433aSmrg      win32_libid_type="x86 DLL"
2813d656433aSmrg      ;;
2814d656433aSmrg    esac
2815d656433aSmrg    ;;
2816d656433aSmrg  esac
2817d656433aSmrg  $ECHO "$win32_libid_type"
2818d656433aSmrg}
2819126a8a12Smrg
2820126a8a12Smrg
2821126a8a12Smrg
2822d656433aSmrg# func_extract_an_archive dir oldlib
2823d656433aSmrgfunc_extract_an_archive ()
2824d656433aSmrg{
2825d656433aSmrg    $opt_debug
2826d656433aSmrg    f_ex_an_ar_dir="$1"; shift
2827d656433aSmrg    f_ex_an_ar_oldlib="$1"
2828555991fdSmrg    if test "$lock_old_archive_extraction" = yes; then
2829555991fdSmrg      lockfile=$f_ex_an_ar_oldlib.lock
2830555991fdSmrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
2831555991fdSmrg	func_echo "Waiting for $lockfile to be removed"
2832555991fdSmrg	sleep 2
2833555991fdSmrg      done
2834555991fdSmrg    fi
2835555991fdSmrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
2836555991fdSmrg		   'stat=$?; rm -f "$lockfile"; exit $stat'
2837555991fdSmrg    if test "$lock_old_archive_extraction" = yes; then
2838555991fdSmrg      $opt_dry_run || rm -f "$lockfile"
2839555991fdSmrg    fi
2840d656433aSmrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
2841d656433aSmrg     :
2842d656433aSmrg    else
2843d656433aSmrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
2844d656433aSmrg    fi
2845d656433aSmrg}
2846126a8a12Smrg
2847126a8a12Smrg
2848d656433aSmrg# func_extract_archives gentop oldlib ...
2849d656433aSmrgfunc_extract_archives ()
2850d656433aSmrg{
2851d656433aSmrg    $opt_debug
2852d656433aSmrg    my_gentop="$1"; shift
2853d656433aSmrg    my_oldlibs=${1+"$@"}
2854d656433aSmrg    my_oldobjs=""
2855d656433aSmrg    my_xlib=""
2856d656433aSmrg    my_xabs=""
2857d656433aSmrg    my_xdir=""
2858126a8a12Smrg
2859d656433aSmrg    for my_xlib in $my_oldlibs; do
2860d656433aSmrg      # Extract the objects.
2861d656433aSmrg      case $my_xlib in
2862d656433aSmrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
2863d656433aSmrg	*) my_xabs=`pwd`"/$my_xlib" ;;
2864d656433aSmrg      esac
2865d656433aSmrg      func_basename "$my_xlib"
2866d656433aSmrg      my_xlib="$func_basename_result"
2867d656433aSmrg      my_xlib_u=$my_xlib
2868d656433aSmrg      while :; do
2869d656433aSmrg        case " $extracted_archives " in
2870d656433aSmrg	*" $my_xlib_u "*)
2871d656433aSmrg	  func_arith $extracted_serial + 1
2872d656433aSmrg	  extracted_serial=$func_arith_result
2873d656433aSmrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
2874d656433aSmrg	*) break ;;
2875d656433aSmrg	esac
2876d656433aSmrg      done
2877d656433aSmrg      extracted_archives="$extracted_archives $my_xlib_u"
2878d656433aSmrg      my_xdir="$my_gentop/$my_xlib_u"
2879126a8a12Smrg
2880d656433aSmrg      func_mkdir_p "$my_xdir"
2881126a8a12Smrg
2882d656433aSmrg      case $host in
2883d656433aSmrg      *-darwin*)
2884d656433aSmrg	func_verbose "Extracting $my_xabs"
2885d656433aSmrg	# Do not bother doing anything if just a dry run
2886d656433aSmrg	$opt_dry_run || {
2887d656433aSmrg	  darwin_orig_dir=`pwd`
2888d656433aSmrg	  cd $my_xdir || exit $?
2889d656433aSmrg	  darwin_archive=$my_xabs
2890d656433aSmrg	  darwin_curdir=`pwd`
2891d656433aSmrg	  darwin_base_archive=`basename "$darwin_archive"`
2892d656433aSmrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
2893d656433aSmrg	  if test -n "$darwin_arches"; then
2894d656433aSmrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
2895d656433aSmrg	    darwin_arch=
2896d656433aSmrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
2897d656433aSmrg	    for darwin_arch in  $darwin_arches ; do
2898d656433aSmrg	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
2899d656433aSmrg	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
2900d656433aSmrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
2901d656433aSmrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
2902d656433aSmrg	      cd "$darwin_curdir"
2903d656433aSmrg	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
2904d656433aSmrg	    done # $darwin_arches
2905d656433aSmrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
2906d656433aSmrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
2907d656433aSmrg	    darwin_file=
2908d656433aSmrg	    darwin_files=
2909d656433aSmrg	    for darwin_file in $darwin_filelist; do
2910555991fdSmrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
2911d656433aSmrg	      $LIPO -create -output "$darwin_file" $darwin_files
2912d656433aSmrg	    done # $darwin_filelist
2913d656433aSmrg	    $RM -rf unfat-$$
2914d656433aSmrg	    cd "$darwin_orig_dir"
2915d656433aSmrg	  else
2916d656433aSmrg	    cd $darwin_orig_dir
2917d656433aSmrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
2918d656433aSmrg	  fi # $darwin_arches
2919d656433aSmrg	} # !$opt_dry_run
2920d656433aSmrg	;;
2921d656433aSmrg      *)
2922d656433aSmrg        func_extract_an_archive "$my_xdir" "$my_xabs"
2923d656433aSmrg	;;
2924126a8a12Smrg      esac
2925555991fdSmrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
2926d656433aSmrg    done
2927126a8a12Smrg
2928d656433aSmrg    func_extract_archives_result="$my_oldobjs"
2929d656433aSmrg}
2930126a8a12Smrg
2931126a8a12Smrg
2932555991fdSmrg# func_emit_wrapper [arg=no]
2933d656433aSmrg#
2934555991fdSmrg# Emit a libtool wrapper script on stdout.
2935555991fdSmrg# Don't directly open a file because we may want to
2936555991fdSmrg# incorporate the script contents within a cygwin/mingw
2937555991fdSmrg# wrapper executable.  Must ONLY be called from within
2938555991fdSmrg# func_mode_link because it depends on a number of variables
2939555991fdSmrg# set therein.
2940555991fdSmrg#
2941555991fdSmrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
2942555991fdSmrg# variable will take.  If 'yes', then the emitted script
2943555991fdSmrg# will assume that the directory in which it is stored is
2944555991fdSmrg# the $objdir directory.  This is a cygwin/mingw-specific
2945555991fdSmrg# behavior.
2946555991fdSmrgfunc_emit_wrapper ()
2947d656433aSmrg{
2948555991fdSmrg	func_emit_wrapper_arg1=${1-no}
2949126a8a12Smrg
2950d656433aSmrg	$ECHO "\
2951d656433aSmrg#! $SHELL
2952126a8a12Smrg
2953d656433aSmrg# $output - temporary wrapper script for $objdir/$outputname
2954d656433aSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
2955d656433aSmrg#
2956d656433aSmrg# The $output program cannot be directly executed until all the libtool
2957d656433aSmrg# libraries that it depends on are installed.
2958d656433aSmrg#
2959d656433aSmrg# This wrapper script should never be moved out of the build directory.
2960d656433aSmrg# If it is, it will not operate correctly.
2961126a8a12Smrg
2962d656433aSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
2963d656433aSmrg# metacharacters that are still active within double-quoted strings.
2964d656433aSmrgsed_quote_subst='$sed_quote_subst'
2965126a8a12Smrg
2966d656433aSmrg# Be Bourne compatible
2967d656433aSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
2968d656433aSmrg  emulate sh
2969d656433aSmrg  NULLCMD=:
2970d656433aSmrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
2971d656433aSmrg  # is contrary to our usage.  Disable this feature.
2972d656433aSmrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
2973d656433aSmrg  setopt NO_GLOB_SUBST
2974d656433aSmrgelse
2975d656433aSmrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
2976d656433aSmrgfi
2977d656433aSmrgBIN_SH=xpg4; export BIN_SH # for Tru64
2978d656433aSmrgDUALCASE=1; export DUALCASE # for MKS sh
2979126a8a12Smrg
2980d656433aSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout
2981d656433aSmrg# if CDPATH is set.
2982d656433aSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
2983126a8a12Smrg
2984d656433aSmrgrelink_command=\"$relink_command\"
2985126a8a12Smrg
2986d656433aSmrg# This environment variable determines our operation mode.
2987d656433aSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then
2988d656433aSmrg  # install mode needs the following variables:
2989d656433aSmrg  generated_by_libtool_version='$macro_version'
2990d656433aSmrg  notinst_deplibs='$notinst_deplibs'
2991d656433aSmrgelse
2992d656433aSmrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
2993d656433aSmrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
2994555991fdSmrg    file=\"\$0\""
2995555991fdSmrg
2996555991fdSmrg    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
2997555991fdSmrg    $ECHO "\
2998555991fdSmrg
2999555991fdSmrg# A function that is used when there is no print builtin or printf.
3000555991fdSmrgfunc_fallback_echo ()
3001555991fdSmrg{
3002555991fdSmrg  eval 'cat <<_LTECHO_EOF
3003555991fdSmrg\$1
3004555991fdSmrg_LTECHO_EOF'
3005555991fdSmrg}
3006555991fdSmrg    ECHO=\"$qECHO\"
3007555991fdSmrg  fi
3008555991fdSmrg
3009555991fdSmrg# Very basic option parsing. These options are (a) specific to
3010555991fdSmrg# the libtool wrapper, (b) are identical between the wrapper
3011555991fdSmrg# /script/ and the wrapper /executable/ which is used only on
3012555991fdSmrg# windows platforms, and (c) all begin with the string "--lt-"
3013555991fdSmrg# (application programs are unlikely to have options which match
3014555991fdSmrg# this pattern).
3015555991fdSmrg#
3016555991fdSmrg# There are only two supported options: --lt-debug and
3017555991fdSmrg# --lt-dump-script. There is, deliberately, no --lt-help.
3018555991fdSmrg#
3019555991fdSmrg# The first argument to this parsing function should be the
3020555991fdSmrg# script's $0 value, followed by "$@".
3021555991fdSmrglt_option_debug=
3022555991fdSmrgfunc_parse_lt_options ()
3023555991fdSmrg{
3024555991fdSmrg  lt_script_arg0=\$0
3025555991fdSmrg  shift
3026555991fdSmrg  for lt_opt
3027555991fdSmrg  do
3028555991fdSmrg    case \"\$lt_opt\" in
3029555991fdSmrg    --lt-debug) lt_option_debug=1 ;;
3030555991fdSmrg    --lt-dump-script)
3031555991fdSmrg        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
3032555991fdSmrg        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
3033555991fdSmrg        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
3034555991fdSmrg        cat \"\$lt_dump_D/\$lt_dump_F\"
3035555991fdSmrg        exit 0
3036555991fdSmrg      ;;
3037555991fdSmrg    --lt-*)
3038555991fdSmrg        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
3039555991fdSmrg        exit 1
3040555991fdSmrg      ;;
3041555991fdSmrg    esac
3042555991fdSmrg  done
3043555991fdSmrg
3044555991fdSmrg  # Print the debug banner immediately:
3045555991fdSmrg  if test -n \"\$lt_option_debug\"; then
3046555991fdSmrg    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
3047555991fdSmrg  fi
3048555991fdSmrg}
3049555991fdSmrg
3050555991fdSmrg# Used when --lt-debug. Prints its arguments to stdout
3051555991fdSmrg# (redirection is the responsibility of the caller)
3052555991fdSmrgfunc_lt_dump_args ()
3053555991fdSmrg{
3054555991fdSmrg  lt_dump_args_N=1;
3055555991fdSmrg  for lt_arg
3056555991fdSmrg  do
3057555991fdSmrg    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
3058555991fdSmrg    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
3059555991fdSmrg  done
3060555991fdSmrg}
3061555991fdSmrg
3062555991fdSmrg# Core function for launching the target application
3063555991fdSmrgfunc_exec_program_core ()
3064555991fdSmrg{
3065d656433aSmrg"
3066555991fdSmrg  case $host in
3067555991fdSmrg  # Backslashes separate directories on plain windows
3068555991fdSmrg  *-*-mingw | *-*-os2* | *-cegcc*)
3069555991fdSmrg    $ECHO "\
3070555991fdSmrg      if test -n \"\$lt_option_debug\"; then
3071555991fdSmrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
3072555991fdSmrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
3073555991fdSmrg      fi
3074555991fdSmrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
3075555991fdSmrg"
3076555991fdSmrg    ;;
3077555991fdSmrg
3078555991fdSmrg  *)
3079555991fdSmrg    $ECHO "\
3080555991fdSmrg      if test -n \"\$lt_option_debug\"; then
3081555991fdSmrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
3082555991fdSmrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
3083555991fdSmrg      fi
3084555991fdSmrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
3085555991fdSmrg"
3086555991fdSmrg    ;;
3087555991fdSmrg  esac
3088555991fdSmrg  $ECHO "\
3089555991fdSmrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
3090555991fdSmrg      exit 1
3091555991fdSmrg}
3092555991fdSmrg
3093555991fdSmrg# A function to encapsulate launching the target application
3094555991fdSmrg# Strips options in the --lt-* namespace from \$@ and
3095555991fdSmrg# launches target application with the remaining arguments.
3096555991fdSmrgfunc_exec_program ()
3097555991fdSmrg{
3098555991fdSmrg  for lt_wr_arg
3099555991fdSmrg  do
3100555991fdSmrg    case \$lt_wr_arg in
3101555991fdSmrg    --lt-*) ;;
3102555991fdSmrg    *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
3103555991fdSmrg    esac
3104555991fdSmrg    shift
3105555991fdSmrg  done
3106555991fdSmrg  func_exec_program_core \${1+\"\$@\"}
3107555991fdSmrg}
3108555991fdSmrg
3109555991fdSmrg  # Parse options
3110555991fdSmrg  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
3111126a8a12Smrg
3112d656433aSmrg  # Find the directory that this script lives in.
3113555991fdSmrg  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
3114d656433aSmrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
3115126a8a12Smrg
3116d656433aSmrg  # Follow symbolic links until we get to the real thisdir.
3117555991fdSmrg  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
3118d656433aSmrg  while test -n \"\$file\"; do
3119555991fdSmrg    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
3120126a8a12Smrg
3121d656433aSmrg    # If there was a directory component, then change thisdir.
3122d656433aSmrg    if test \"x\$destdir\" != \"x\$file\"; then
3123d656433aSmrg      case \"\$destdir\" in
3124d656433aSmrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
3125d656433aSmrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
3126d656433aSmrg      esac
3127d656433aSmrg    fi
3128126a8a12Smrg
3129555991fdSmrg    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
3130555991fdSmrg    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
3131d656433aSmrg  done
3132126a8a12Smrg
3133d656433aSmrg  # Usually 'no', except on cygwin/mingw when embedded into
3134d656433aSmrg  # the cwrapper.
3135555991fdSmrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
3136d656433aSmrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
3137d656433aSmrg    # special case for '.'
3138d656433aSmrg    if test \"\$thisdir\" = \".\"; then
3139d656433aSmrg      thisdir=\`pwd\`
3140d656433aSmrg    fi
3141d656433aSmrg    # remove .libs from thisdir
3142d656433aSmrg    case \"\$thisdir\" in
3143555991fdSmrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
3144d656433aSmrg    $objdir )   thisdir=. ;;
3145d656433aSmrg    esac
3146d656433aSmrg  fi
3147126a8a12Smrg
3148d656433aSmrg  # Try to get the absolute directory name.
3149d656433aSmrg  absdir=\`cd \"\$thisdir\" && pwd\`
3150d656433aSmrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
3151d656433aSmrg"
3152126a8a12Smrg
3153d656433aSmrg	if test "$fast_install" = yes; then
3154d656433aSmrg	  $ECHO "\
3155d656433aSmrg  program=lt-'$outputname'$exeext
3156d656433aSmrg  progdir=\"\$thisdir/$objdir\"
3157126a8a12Smrg
3158d656433aSmrg  if test ! -f \"\$progdir/\$program\" ||
3159d656433aSmrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
3160d656433aSmrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
3161126a8a12Smrg
3162d656433aSmrg    file=\"\$\$-\$program\"
3163126a8a12Smrg
3164d656433aSmrg    if test ! -d \"\$progdir\"; then
3165d656433aSmrg      $MKDIR \"\$progdir\"
3166d656433aSmrg    else
3167d656433aSmrg      $RM \"\$progdir/\$file\"
3168d656433aSmrg    fi"
3169126a8a12Smrg
3170d656433aSmrg	  $ECHO "\
3171126a8a12Smrg
3172d656433aSmrg    # relink executable if necessary
3173d656433aSmrg    if test -n \"\$relink_command\"; then
3174d656433aSmrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
3175d656433aSmrg      else
3176d656433aSmrg	$ECHO \"\$relink_command_output\" >&2
3177d656433aSmrg	$RM \"\$progdir/\$file\"
3178d656433aSmrg	exit 1
3179d656433aSmrg      fi
3180d656433aSmrg    fi
3181126a8a12Smrg
3182d656433aSmrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
3183d656433aSmrg    { $RM \"\$progdir/\$program\";
3184d656433aSmrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
3185d656433aSmrg    $RM \"\$progdir/\$file\"
3186d656433aSmrg  fi"
3187d656433aSmrg	else
3188d656433aSmrg	  $ECHO "\
3189d656433aSmrg  program='$outputname'
3190d656433aSmrg  progdir=\"\$thisdir/$objdir\"
3191d656433aSmrg"
3192d656433aSmrg	fi
3193126a8a12Smrg
3194d656433aSmrg	$ECHO "\
3195126a8a12Smrg
3196d656433aSmrg  if test -f \"\$progdir/\$program\"; then"
3197126a8a12Smrg
3198d656433aSmrg	# Export our shlibpath_var if we have one.
3199d656433aSmrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
3200d656433aSmrg	  $ECHO "\
3201d656433aSmrg    # Add our own library path to $shlibpath_var
3202d656433aSmrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
3203126a8a12Smrg
3204d656433aSmrg    # Some systems cannot cope with colon-terminated $shlibpath_var
3205d656433aSmrg    # The second colon is a workaround for a bug in BeOS R4 sed
3206555991fdSmrg    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
3207126a8a12Smrg
3208d656433aSmrg    export $shlibpath_var
3209d656433aSmrg"
3210126a8a12Smrg	fi
3211126a8a12Smrg
3212d656433aSmrg	# fixup the dll searchpath if we need to.
3213d656433aSmrg	if test -n "$dllsearchpath"; then
3214d656433aSmrg	  $ECHO "\
3215d656433aSmrg    # Add the dll search path components to the executable PATH
3216d656433aSmrg    PATH=$dllsearchpath:\$PATH
3217d656433aSmrg"
3218126a8a12Smrg	fi
3219126a8a12Smrg
3220d656433aSmrg	$ECHO "\
3221d656433aSmrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
3222d656433aSmrg      # Run the actual program with our arguments.
3223555991fdSmrg      func_exec_program \${1+\"\$@\"}
3224d656433aSmrg    fi
3225d656433aSmrg  else
3226d656433aSmrg    # The program doesn't exist.
3227d656433aSmrg    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
3228d656433aSmrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
3229555991fdSmrg    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
3230d656433aSmrg    exit 1
3231d656433aSmrg  fi
3232d656433aSmrgfi\
3233d656433aSmrg"
3234d656433aSmrg}
3235126a8a12Smrg
3236126a8a12Smrg
3237d656433aSmrg# func_to_host_path arg
3238d656433aSmrg#
3239d656433aSmrg# Convert paths to host format when used with build tools.
3240d656433aSmrg# Intended for use with "native" mingw (where libtool itself
3241d656433aSmrg# is running under the msys shell), or in the following cross-
3242d656433aSmrg# build environments:
3243d656433aSmrg#    $build          $host
3244d656433aSmrg#    mingw (msys)    mingw  [e.g. native]
3245d656433aSmrg#    cygwin          mingw
3246d656433aSmrg#    *nix + wine     mingw
3247d656433aSmrg# where wine is equipped with the `winepath' executable.
3248d656433aSmrg# In the native mingw case, the (msys) shell automatically
3249d656433aSmrg# converts paths for any non-msys applications it launches,
3250d656433aSmrg# but that facility isn't available from inside the cwrapper.
3251d656433aSmrg# Similar accommodations are necessary for $host mingw and
3252d656433aSmrg# $build cygwin.  Calling this function does no harm for other
3253d656433aSmrg# $host/$build combinations not listed above.
3254d656433aSmrg#
3255d656433aSmrg# ARG is the path (on $build) that should be converted to
3256d656433aSmrg# the proper representation for $host. The result is stored
3257d656433aSmrg# in $func_to_host_path_result.
3258d656433aSmrgfunc_to_host_path ()
3259d656433aSmrg{
3260d656433aSmrg  func_to_host_path_result="$1"
3261555991fdSmrg  if test -n "$1"; then
3262d656433aSmrg    case $host in
3263d656433aSmrg      *mingw* )
3264d656433aSmrg        lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
3265d656433aSmrg        case $build in
3266d656433aSmrg          *mingw* ) # actually, msys
3267d656433aSmrg            # awkward: cmd appends spaces to result
3268555991fdSmrg            func_to_host_path_result=`( cmd //c echo "$1" ) 2>/dev/null |
3269555991fdSmrg              $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
3270d656433aSmrg            ;;
3271d656433aSmrg          *cygwin* )
3272555991fdSmrg            func_to_host_path_result=`cygpath -w "$1" |
3273555991fdSmrg	      $SED -e "$lt_sed_naive_backslashify"`
3274d656433aSmrg            ;;
3275d656433aSmrg          * )
3276d656433aSmrg            # Unfortunately, winepath does not exit with a non-zero
3277d656433aSmrg            # error code, so we are forced to check the contents of
3278d656433aSmrg            # stdout. On the other hand, if the command is not
3279d656433aSmrg            # found, the shell will set an exit code of 127 and print
3280d656433aSmrg            # *an error message* to stdout. So we must check for both
3281d656433aSmrg            # error code of zero AND non-empty stdout, which explains
3282d656433aSmrg            # the odd construction:
3283d656433aSmrg            func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null`
3284d656433aSmrg            if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then
3285555991fdSmrg              func_to_host_path_result=`$ECHO "$func_to_host_path_tmp1" |
3286d656433aSmrg                $SED -e "$lt_sed_naive_backslashify"`
3287d656433aSmrg            else
3288d656433aSmrg              # Allow warning below.
3289555991fdSmrg              func_to_host_path_result=
3290d656433aSmrg            fi
3291d656433aSmrg            ;;
3292d656433aSmrg        esac
3293d656433aSmrg        if test -z "$func_to_host_path_result" ; then
3294d656433aSmrg          func_error "Could not determine host path corresponding to"
3295555991fdSmrg          func_error "  \`$1'"
3296d656433aSmrg          func_error "Continuing, but uninstalled executables may not work."
3297d656433aSmrg          # Fallback:
3298d656433aSmrg          func_to_host_path_result="$1"
3299d656433aSmrg        fi
3300d656433aSmrg        ;;
3301d656433aSmrg    esac
3302d656433aSmrg  fi
3303d656433aSmrg}
3304d656433aSmrg# end: func_to_host_path
3305126a8a12Smrg
3306d656433aSmrg# func_to_host_pathlist arg
3307d656433aSmrg#
3308d656433aSmrg# Convert pathlists to host format when used with build tools.
3309d656433aSmrg# See func_to_host_path(), above. This function supports the
3310d656433aSmrg# following $build/$host combinations (but does no harm for
3311d656433aSmrg# combinations not listed here):
3312d656433aSmrg#    $build          $host
3313d656433aSmrg#    mingw (msys)    mingw  [e.g. native]
3314d656433aSmrg#    cygwin          mingw
3315d656433aSmrg#    *nix + wine     mingw
3316d656433aSmrg#
3317d656433aSmrg# Path separators are also converted from $build format to
3318d656433aSmrg# $host format. If ARG begins or ends with a path separator
3319d656433aSmrg# character, it is preserved (but converted to $host format)
3320d656433aSmrg# on output.
3321d656433aSmrg#
3322d656433aSmrg# ARG is a pathlist (on $build) that should be converted to
3323d656433aSmrg# the proper representation on $host. The result is stored
3324d656433aSmrg# in $func_to_host_pathlist_result.
3325d656433aSmrgfunc_to_host_pathlist ()
3326d656433aSmrg{
3327d656433aSmrg  func_to_host_pathlist_result="$1"
3328555991fdSmrg  if test -n "$1"; then
3329d656433aSmrg    case $host in
3330d656433aSmrg      *mingw* )
3331d656433aSmrg        lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
3332d656433aSmrg        # Remove leading and trailing path separator characters from
3333d656433aSmrg        # ARG. msys behavior is inconsistent here, cygpath turns them
3334d656433aSmrg        # into '.;' and ';.', and winepath ignores them completely.
3335555991fdSmrg	func_stripname : : "$1"
3336555991fdSmrg        func_to_host_pathlist_tmp1=$func_stripname_result
3337d656433aSmrg        case $build in
3338d656433aSmrg          *mingw* ) # Actually, msys.
3339d656433aSmrg            # Awkward: cmd appends spaces to result.
3340555991fdSmrg            func_to_host_pathlist_result=`
3341555991fdSmrg	      ( cmd //c echo "$func_to_host_pathlist_tmp1" ) 2>/dev/null |
3342555991fdSmrg	      $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
3343d656433aSmrg            ;;
3344d656433aSmrg          *cygwin* )
3345555991fdSmrg            func_to_host_pathlist_result=`cygpath -w -p "$func_to_host_pathlist_tmp1" |
3346d656433aSmrg              $SED -e "$lt_sed_naive_backslashify"`
3347d656433aSmrg            ;;
3348d656433aSmrg          * )
3349d656433aSmrg            # unfortunately, winepath doesn't convert pathlists
3350d656433aSmrg            func_to_host_pathlist_result=""
3351d656433aSmrg            func_to_host_pathlist_oldIFS=$IFS
3352d656433aSmrg            IFS=:
3353d656433aSmrg            for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do
3354d656433aSmrg              IFS=$func_to_host_pathlist_oldIFS
3355d656433aSmrg              if test -n "$func_to_host_pathlist_f" ; then
3356d656433aSmrg                func_to_host_path "$func_to_host_pathlist_f"
3357d656433aSmrg                if test -n "$func_to_host_path_result" ; then
3358d656433aSmrg                  if test -z "$func_to_host_pathlist_result" ; then
3359d656433aSmrg                    func_to_host_pathlist_result="$func_to_host_path_result"
3360d656433aSmrg                  else
3361555991fdSmrg                    func_append func_to_host_pathlist_result ";$func_to_host_path_result"
3362d656433aSmrg                  fi
3363d656433aSmrg                fi
3364d656433aSmrg              fi
3365d656433aSmrg            done
3366d656433aSmrg            IFS=$func_to_host_pathlist_oldIFS
3367d656433aSmrg            ;;
3368d656433aSmrg        esac
3369555991fdSmrg        if test -z "$func_to_host_pathlist_result"; then
3370d656433aSmrg          func_error "Could not determine the host path(s) corresponding to"
3371555991fdSmrg          func_error "  \`$1'"
3372d656433aSmrg          func_error "Continuing, but uninstalled executables may not work."
3373d656433aSmrg          # Fallback. This may break if $1 contains DOS-style drive
3374d656433aSmrg          # specifications. The fix is not to complicate the expression
3375d656433aSmrg          # below, but for the user to provide a working wine installation
3376d656433aSmrg          # with winepath so that path translation in the cross-to-mingw
3377d656433aSmrg          # case works properly.
3378d656433aSmrg          lt_replace_pathsep_nix_to_dos="s|:|;|g"
3379d656433aSmrg          func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\
3380d656433aSmrg            $SED -e "$lt_replace_pathsep_nix_to_dos"`
3381d656433aSmrg        fi
3382d656433aSmrg        # Now, add the leading and trailing path separators back
3383d656433aSmrg        case "$1" in
3384d656433aSmrg          :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result"
3385d656433aSmrg            ;;
3386d656433aSmrg        esac
3387d656433aSmrg        case "$1" in
3388555991fdSmrg          *: ) func_append func_to_host_pathlist_result ";"
3389d656433aSmrg            ;;
3390d656433aSmrg        esac
3391d656433aSmrg        ;;
3392d656433aSmrg    esac
3393d656433aSmrg  fi
3394d656433aSmrg}
3395d656433aSmrg# end: func_to_host_pathlist
3396126a8a12Smrg
3397d656433aSmrg# func_emit_cwrapperexe_src
3398d656433aSmrg# emit the source code for a wrapper executable on stdout
3399d656433aSmrg# Must ONLY be called from within func_mode_link because
3400d656433aSmrg# it depends on a number of variable set therein.
3401d656433aSmrgfunc_emit_cwrapperexe_src ()
3402d656433aSmrg{
3403d656433aSmrg	cat <<EOF
3404126a8a12Smrg
3405d656433aSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
3406d656433aSmrg   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
3407126a8a12Smrg
3408d656433aSmrg   The $output program cannot be directly executed until all the libtool
3409d656433aSmrg   libraries that it depends on are installed.
3410126a8a12Smrg
3411d656433aSmrg   This wrapper executable should never be moved out of the build directory.
3412d656433aSmrg   If it is, it will not operate correctly.
3413d656433aSmrg*/
3414d656433aSmrgEOF
3415d656433aSmrg	    cat <<"EOF"
3416555991fdSmrg#ifdef _MSC_VER
3417555991fdSmrg# define _CRT_SECURE_NO_DEPRECATE 1
3418555991fdSmrg#endif
3419d656433aSmrg#include <stdio.h>
3420d656433aSmrg#include <stdlib.h>
3421d656433aSmrg#ifdef _MSC_VER
3422d656433aSmrg# include <direct.h>
3423d656433aSmrg# include <process.h>
3424d656433aSmrg# include <io.h>
3425d656433aSmrg#else
3426d656433aSmrg# include <unistd.h>
3427d656433aSmrg# include <stdint.h>
3428d656433aSmrg# ifdef __CYGWIN__
3429d656433aSmrg#  include <io.h>
3430d656433aSmrg# endif
3431d656433aSmrg#endif
3432d656433aSmrg#include <malloc.h>
3433d656433aSmrg#include <stdarg.h>
3434d656433aSmrg#include <assert.h>
3435d656433aSmrg#include <string.h>
3436d656433aSmrg#include <ctype.h>
3437d656433aSmrg#include <errno.h>
3438d656433aSmrg#include <fcntl.h>
3439d656433aSmrg#include <sys/stat.h>
3440d656433aSmrg
3441555991fdSmrg/* declarations of non-ANSI functions */
3442555991fdSmrg#if defined(__MINGW32__)
3443555991fdSmrg# ifdef __STRICT_ANSI__
3444555991fdSmrgint _putenv (const char *);
3445555991fdSmrg# endif
3446555991fdSmrg#elif defined(__CYGWIN__)
3447555991fdSmrg# ifdef __STRICT_ANSI__
3448555991fdSmrgchar *realpath (const char *, char *);
3449555991fdSmrgint putenv (char *);
3450555991fdSmrgint setenv (const char *, const char *, int);
3451555991fdSmrg# endif
3452555991fdSmrg/* #elif defined (other platforms) ... */
3453555991fdSmrg#endif
3454555991fdSmrg
3455555991fdSmrg/* portability defines, excluding path handling macros */
3456555991fdSmrg#if defined(_MSC_VER)
3457555991fdSmrg# define setmode _setmode
3458555991fdSmrg# define stat    _stat
3459555991fdSmrg# define chmod   _chmod
3460555991fdSmrg# define getcwd  _getcwd
3461555991fdSmrg# define putenv  _putenv
3462555991fdSmrg# define S_IXUSR _S_IEXEC
3463555991fdSmrg# ifndef _INTPTR_T_DEFINED
3464555991fdSmrg#  define _INTPTR_T_DEFINED
3465555991fdSmrg#  define intptr_t int
3466555991fdSmrg# endif
3467555991fdSmrg#elif defined(__MINGW32__)
3468555991fdSmrg# define setmode _setmode
3469555991fdSmrg# define stat    _stat
3470555991fdSmrg# define chmod   _chmod
3471555991fdSmrg# define getcwd  _getcwd
3472555991fdSmrg# define putenv  _putenv
3473555991fdSmrg#elif defined(__CYGWIN__)
3474555991fdSmrg# define HAVE_SETENV
3475555991fdSmrg# define FOPEN_WB "wb"
3476555991fdSmrg/* #elif defined (other platforms) ... */
3477555991fdSmrg#endif
3478555991fdSmrg
3479d656433aSmrg#if defined(PATH_MAX)
3480d656433aSmrg# define LT_PATHMAX PATH_MAX
3481d656433aSmrg#elif defined(MAXPATHLEN)
3482d656433aSmrg# define LT_PATHMAX MAXPATHLEN
3483d656433aSmrg#else
3484d656433aSmrg# define LT_PATHMAX 1024
3485d656433aSmrg#endif
3486d656433aSmrg
3487d656433aSmrg#ifndef S_IXOTH
3488d656433aSmrg# define S_IXOTH 0
3489d656433aSmrg#endif
3490d656433aSmrg#ifndef S_IXGRP
3491d656433aSmrg# define S_IXGRP 0
3492d656433aSmrg#endif
3493d656433aSmrg
3494555991fdSmrg/* path handling portability macros */
3495d656433aSmrg#ifndef DIR_SEPARATOR
3496d656433aSmrg# define DIR_SEPARATOR '/'
3497d656433aSmrg# define PATH_SEPARATOR ':'
3498d656433aSmrg#endif
3499d656433aSmrg
3500d656433aSmrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
3501d656433aSmrg  defined (__OS2__)
3502d656433aSmrg# define HAVE_DOS_BASED_FILE_SYSTEM
3503d656433aSmrg# define FOPEN_WB "wb"
3504d656433aSmrg# ifndef DIR_SEPARATOR_2
3505d656433aSmrg#  define DIR_SEPARATOR_2 '\\'
3506d656433aSmrg# endif
3507d656433aSmrg# ifndef PATH_SEPARATOR_2
3508d656433aSmrg#  define PATH_SEPARATOR_2 ';'
3509d656433aSmrg# endif
3510d656433aSmrg#endif
3511d656433aSmrg
3512d656433aSmrg#ifndef DIR_SEPARATOR_2
3513d656433aSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
3514d656433aSmrg#else /* DIR_SEPARATOR_2 */
3515d656433aSmrg# define IS_DIR_SEPARATOR(ch) \
3516d656433aSmrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
3517d656433aSmrg#endif /* DIR_SEPARATOR_2 */
3518d656433aSmrg
3519d656433aSmrg#ifndef PATH_SEPARATOR_2
3520d656433aSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
3521d656433aSmrg#else /* PATH_SEPARATOR_2 */
3522d656433aSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
3523d656433aSmrg#endif /* PATH_SEPARATOR_2 */
3524d656433aSmrg
3525d656433aSmrg#ifndef FOPEN_WB
3526d656433aSmrg# define FOPEN_WB "w"
3527d656433aSmrg#endif
3528d656433aSmrg#ifndef _O_BINARY
3529d656433aSmrg# define _O_BINARY 0
3530d656433aSmrg#endif
3531d656433aSmrg
3532d656433aSmrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
3533d656433aSmrg#define XFREE(stale) do { \
3534d656433aSmrg  if (stale) { free ((void *) stale); stale = 0; } \
3535d656433aSmrg} while (0)
3536d656433aSmrg
3537555991fdSmrg#if defined(LT_DEBUGWRAPPER)
3538555991fdSmrgstatic int lt_debug = 1;
3539d656433aSmrg#else
3540555991fdSmrgstatic int lt_debug = 0;
3541d656433aSmrg#endif
3542d656433aSmrg
3543555991fdSmrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
3544d656433aSmrg
3545d656433aSmrgvoid *xmalloc (size_t num);
3546d656433aSmrgchar *xstrdup (const char *string);
3547d656433aSmrgconst char *base_name (const char *name);
3548d656433aSmrgchar *find_executable (const char *wrapper);
3549d656433aSmrgchar *chase_symlinks (const char *pathspec);
3550d656433aSmrgint make_executable (const char *path);
3551d656433aSmrgint check_executable (const char *path);
3552d656433aSmrgchar *strendzap (char *str, const char *pat);
3553555991fdSmrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
3554555991fdSmrgvoid lt_fatal (const char *file, int line, const char *message, ...);
3555555991fdSmrgstatic const char *nonnull (const char *s);
3556555991fdSmrgstatic const char *nonempty (const char *s);
3557d656433aSmrgvoid lt_setenv (const char *name, const char *value);
3558d656433aSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
3559d656433aSmrgvoid lt_update_exe_path (const char *name, const char *value);
3560d656433aSmrgvoid lt_update_lib_path (const char *name, const char *value);
3561555991fdSmrgchar **prepare_spawn (char **argv);
3562555991fdSmrgvoid lt_dump_script (FILE *f);
3563d656433aSmrgEOF
3564d656433aSmrg
3565d656433aSmrg	    cat <<EOF
3566d656433aSmrgconst char * MAGIC_EXE = "$magic_exe";
3567d656433aSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
3568d656433aSmrgEOF
3569d656433aSmrg
3570d656433aSmrg	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
3571d656433aSmrg              func_to_host_pathlist "$temp_rpath"
3572d656433aSmrg	      cat <<EOF
3573d656433aSmrgconst char * LIB_PATH_VALUE   = "$func_to_host_pathlist_result";
3574126a8a12SmrgEOF
3575126a8a12Smrg	    else
3576d656433aSmrg	      cat <<"EOF"
3577d656433aSmrgconst char * LIB_PATH_VALUE   = "";
3578d656433aSmrgEOF
3579126a8a12Smrg	    fi
3580d656433aSmrg
3581d656433aSmrg	    if test -n "$dllsearchpath"; then
3582d656433aSmrg              func_to_host_pathlist "$dllsearchpath:"
3583d656433aSmrg	      cat <<EOF
3584d656433aSmrgconst char * EXE_PATH_VARNAME = "PATH";
3585d656433aSmrgconst char * EXE_PATH_VALUE   = "$func_to_host_pathlist_result";
3586d656433aSmrgEOF
3587126a8a12Smrg	    else
3588d656433aSmrg	      cat <<"EOF"
3589d656433aSmrgconst char * EXE_PATH_VARNAME = "";
3590d656433aSmrgconst char * EXE_PATH_VALUE   = "";
3591d656433aSmrgEOF
3592126a8a12Smrg	    fi
3593d656433aSmrg
3594d656433aSmrg	    if test "$fast_install" = yes; then
3595d656433aSmrg	      cat <<EOF
3596d656433aSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
3597d656433aSmrgEOF
3598126a8a12Smrg	    else
3599d656433aSmrg	      cat <<EOF
3600d656433aSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
3601d656433aSmrgEOF
3602126a8a12Smrg	    fi
3603126a8a12Smrg
3604126a8a12Smrg
3605d656433aSmrg	    cat <<"EOF"
3606126a8a12Smrg
3607d656433aSmrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
3608126a8a12Smrg
3609d656433aSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
3610d656433aSmrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
3611555991fdSmrgstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
3612126a8a12Smrg
3613d656433aSmrgint
3614d656433aSmrgmain (int argc, char *argv[])
3615d656433aSmrg{
3616d656433aSmrg  char **newargz;
3617d656433aSmrg  int  newargc;
3618d656433aSmrg  char *tmp_pathspec;
3619d656433aSmrg  char *actual_cwrapper_path;
3620d656433aSmrg  char *actual_cwrapper_name;
3621d656433aSmrg  char *target_name;
3622d656433aSmrg  char *lt_argv_zero;
3623d656433aSmrg  intptr_t rval = 127;
3624126a8a12Smrg
3625d656433aSmrg  int i;
3626126a8a12Smrg
3627d656433aSmrg  program_name = (char *) xstrdup (base_name (argv[0]));
3628555991fdSmrg  newargz = XMALLOC (char *, argc + 1);
3629126a8a12Smrg
3630555991fdSmrg  /* very simple arg parsing; don't want to rely on getopt
3631555991fdSmrg   * also, copy all non cwrapper options to newargz, except
3632555991fdSmrg   * argz[0], which is handled differently
3633555991fdSmrg   */
3634555991fdSmrg  newargc=0;
3635d656433aSmrg  for (i = 1; i < argc; i++)
3636d656433aSmrg    {
3637d656433aSmrg      if (strcmp (argv[i], dumpscript_opt) == 0)
3638d656433aSmrg	{
3639d656433aSmrgEOF
3640d656433aSmrg	    case "$host" in
3641d656433aSmrg	      *mingw* | *cygwin* )
3642d656433aSmrg		# make stdout use "unix" line endings
3643d656433aSmrg		echo "          setmode(1,_O_BINARY);"
3644d656433aSmrg		;;
3645d656433aSmrg	      esac
3646126a8a12Smrg
3647d656433aSmrg	    cat <<"EOF"
3648555991fdSmrg	  lt_dump_script (stdout);
3649d656433aSmrg	  return 0;
3650d656433aSmrg	}
3651555991fdSmrg      if (strcmp (argv[i], debug_opt) == 0)
3652555991fdSmrg	{
3653555991fdSmrg          lt_debug = 1;
3654555991fdSmrg          continue;
3655555991fdSmrg	}
3656555991fdSmrg      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
3657555991fdSmrg        {
3658555991fdSmrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
3659555991fdSmrg             namespace, but it is not one of the ones we know about and
3660555991fdSmrg             have already dealt with, above (inluding dump-script), then
3661555991fdSmrg             report an error. Otherwise, targets might begin to believe
3662555991fdSmrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
3663555991fdSmrg             namespace. The first time any user complains about this, we'll
3664555991fdSmrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
3665555991fdSmrg             or a configure.ac-settable value.
3666555991fdSmrg           */
3667555991fdSmrg          lt_fatal (__FILE__, __LINE__,
3668555991fdSmrg		    "unrecognized %s option: '%s'",
3669555991fdSmrg                    ltwrapper_option_prefix, argv[i]);
3670555991fdSmrg        }
3671555991fdSmrg      /* otherwise ... */
3672555991fdSmrg      newargz[++newargc] = xstrdup (argv[i]);
3673d656433aSmrg    }
3674555991fdSmrg  newargz[++newargc] = NULL;
3675555991fdSmrg
3676555991fdSmrgEOF
3677555991fdSmrg	    cat <<EOF
3678555991fdSmrg  /* The GNU banner must be the first non-error debug message */
3679555991fdSmrg  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
3680555991fdSmrgEOF
3681555991fdSmrg	    cat <<"EOF"
3682555991fdSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
3683555991fdSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
3684126a8a12Smrg
3685d656433aSmrg  tmp_pathspec = find_executable (argv[0]);
3686d656433aSmrg  if (tmp_pathspec == NULL)
3687555991fdSmrg    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
3688555991fdSmrg  lt_debugprintf (__FILE__, __LINE__,
3689555991fdSmrg                  "(main) found exe (before symlink chase) at: %s\n",
3690555991fdSmrg		  tmp_pathspec);
3691d656433aSmrg
3692d656433aSmrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
3693555991fdSmrg  lt_debugprintf (__FILE__, __LINE__,
3694555991fdSmrg                  "(main) found exe (after symlink chase) at: %s\n",
3695555991fdSmrg		  actual_cwrapper_path);
3696d656433aSmrg  XFREE (tmp_pathspec);
3697d656433aSmrg
3698555991fdSmrg  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
3699d656433aSmrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
3700d656433aSmrg
3701d656433aSmrg  /* wrapper name transforms */
3702d656433aSmrg  strendzap (actual_cwrapper_name, ".exe");
3703d656433aSmrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
3704d656433aSmrg  XFREE (actual_cwrapper_name);
3705d656433aSmrg  actual_cwrapper_name = tmp_pathspec;
3706d656433aSmrg  tmp_pathspec = 0;
3707d656433aSmrg
3708d656433aSmrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
3709d656433aSmrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
3710d656433aSmrg  strendzap (target_name, ".exe");
3711d656433aSmrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
3712d656433aSmrg  XFREE (target_name);
3713d656433aSmrg  target_name = tmp_pathspec;
3714d656433aSmrg  tmp_pathspec = 0;
3715d656433aSmrg
3716555991fdSmrg  lt_debugprintf (__FILE__, __LINE__,
3717555991fdSmrg		  "(main) libtool target name: %s\n",
3718555991fdSmrg		  target_name);
3719d656433aSmrgEOF
3720126a8a12Smrg
3721d656433aSmrg	    cat <<EOF
3722d656433aSmrg  newargz[0] =
3723d656433aSmrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
3724d656433aSmrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
3725d656433aSmrg  strcpy (newargz[0], actual_cwrapper_path);
3726d656433aSmrg  strcat (newargz[0], "$objdir");
3727d656433aSmrg  strcat (newargz[0], "/");
3728d656433aSmrgEOF
3729126a8a12Smrg
3730d656433aSmrg	    cat <<"EOF"
3731d656433aSmrg  /* stop here, and copy so we don't have to do this twice */
3732d656433aSmrg  tmp_pathspec = xstrdup (newargz[0]);
3733126a8a12Smrg
3734d656433aSmrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
3735d656433aSmrg  strcat (newargz[0], actual_cwrapper_name);
3736126a8a12Smrg
3737d656433aSmrg  /* DO want the lt- prefix here if it exists, so use target_name */
3738d656433aSmrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
3739d656433aSmrg  XFREE (tmp_pathspec);
3740d656433aSmrg  tmp_pathspec = NULL;
3741d656433aSmrgEOF
3742126a8a12Smrg
3743d656433aSmrg	    case $host_os in
3744d656433aSmrg	      mingw*)
3745d656433aSmrg	    cat <<"EOF"
3746d656433aSmrg  {
3747d656433aSmrg    char* p;
3748d656433aSmrg    while ((p = strchr (newargz[0], '\\')) != NULL)
3749d656433aSmrg      {
3750d656433aSmrg	*p = '/';
3751d656433aSmrg      }
3752d656433aSmrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
3753d656433aSmrg      {
3754d656433aSmrg	*p = '/';
3755d656433aSmrg      }
3756d656433aSmrg  }
3757d656433aSmrgEOF
3758d656433aSmrg	    ;;
3759d656433aSmrg	    esac
3760126a8a12Smrg
3761d656433aSmrg	    cat <<"EOF"
3762d656433aSmrg  XFREE (target_name);
3763d656433aSmrg  XFREE (actual_cwrapper_path);
3764d656433aSmrg  XFREE (actual_cwrapper_name);
3765126a8a12Smrg
3766d656433aSmrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
3767d656433aSmrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
3768d656433aSmrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
3769d656433aSmrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
3770126a8a12Smrg
3771555991fdSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
3772555991fdSmrg		  nonnull (lt_argv_zero));
3773d656433aSmrg  for (i = 0; i < newargc; i++)
3774d656433aSmrg    {
3775555991fdSmrg      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
3776555991fdSmrg		      i, nonnull (newargz[i]));
3777d656433aSmrg    }
3778126a8a12Smrg
3779d656433aSmrgEOF
3780126a8a12Smrg
3781d656433aSmrg	    case $host_os in
3782d656433aSmrg	      mingw*)
3783d656433aSmrg		cat <<"EOF"
3784d656433aSmrg  /* execv doesn't actually work on mingw as expected on unix */
3785555991fdSmrg  newargz = prepare_spawn (newargz);
3786d656433aSmrg  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
3787d656433aSmrg  if (rval == -1)
3788d656433aSmrg    {
3789d656433aSmrg      /* failed to start process */
3790555991fdSmrg      lt_debugprintf (__FILE__, __LINE__,
3791555991fdSmrg		      "(main) failed to launch target \"%s\": %s\n",
3792555991fdSmrg		      lt_argv_zero, nonnull (strerror (errno)));
3793d656433aSmrg      return 127;
3794d656433aSmrg    }
3795d656433aSmrg  return rval;
3796d656433aSmrgEOF
3797d656433aSmrg		;;
3798d656433aSmrg	      *)
3799d656433aSmrg		cat <<"EOF"
3800d656433aSmrg  execv (lt_argv_zero, newargz);
3801d656433aSmrg  return rval; /* =127, but avoids unused variable warning */
3802d656433aSmrgEOF
3803d656433aSmrg		;;
3804d656433aSmrg	    esac
3805126a8a12Smrg
3806d656433aSmrg	    cat <<"EOF"
3807d656433aSmrg}
3808126a8a12Smrg
3809d656433aSmrgvoid *
3810d656433aSmrgxmalloc (size_t num)
3811d656433aSmrg{
3812d656433aSmrg  void *p = (void *) malloc (num);
3813d656433aSmrg  if (!p)
3814555991fdSmrg    lt_fatal (__FILE__, __LINE__, "memory exhausted");
3815126a8a12Smrg
3816d656433aSmrg  return p;
3817d656433aSmrg}
3818126a8a12Smrg
3819d656433aSmrgchar *
3820d656433aSmrgxstrdup (const char *string)
3821d656433aSmrg{
3822d656433aSmrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
3823d656433aSmrg			  string) : NULL;
3824d656433aSmrg}
3825126a8a12Smrg
3826d656433aSmrgconst char *
3827d656433aSmrgbase_name (const char *name)
3828d656433aSmrg{
3829d656433aSmrg  const char *base;
3830126a8a12Smrg
3831d656433aSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3832d656433aSmrg  /* Skip over the disk name in MSDOS pathnames. */
3833d656433aSmrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
3834d656433aSmrg    name += 2;
3835d656433aSmrg#endif
3836126a8a12Smrg
3837d656433aSmrg  for (base = name; *name; name++)
3838d656433aSmrg    if (IS_DIR_SEPARATOR (*name))
3839d656433aSmrg      base = name + 1;
3840d656433aSmrg  return base;
3841d656433aSmrg}
3842126a8a12Smrg
3843d656433aSmrgint
3844d656433aSmrgcheck_executable (const char *path)
3845d656433aSmrg{
3846d656433aSmrg  struct stat st;
3847126a8a12Smrg
3848555991fdSmrg  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
3849555991fdSmrg                  nonempty (path));
3850d656433aSmrg  if ((!path) || (!*path))
3851d656433aSmrg    return 0;
3852126a8a12Smrg
3853d656433aSmrg  if ((stat (path, &st) >= 0)
3854d656433aSmrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
3855d656433aSmrg    return 1;
3856d656433aSmrg  else
3857d656433aSmrg    return 0;
3858d656433aSmrg}
3859126a8a12Smrg
3860d656433aSmrgint
3861d656433aSmrgmake_executable (const char *path)
3862d656433aSmrg{
3863d656433aSmrg  int rval = 0;
3864d656433aSmrg  struct stat st;
3865126a8a12Smrg
3866555991fdSmrg  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
3867555991fdSmrg                  nonempty (path));
3868d656433aSmrg  if ((!path) || (!*path))
3869d656433aSmrg    return 0;
3870126a8a12Smrg
3871d656433aSmrg  if (stat (path, &st) >= 0)
3872d656433aSmrg    {
3873d656433aSmrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
3874d656433aSmrg    }
3875d656433aSmrg  return rval;
3876d656433aSmrg}
3877126a8a12Smrg
3878d656433aSmrg/* Searches for the full path of the wrapper.  Returns
3879d656433aSmrg   newly allocated full path name if found, NULL otherwise
3880d656433aSmrg   Does not chase symlinks, even on platforms that support them.
3881d656433aSmrg*/
3882d656433aSmrgchar *
3883d656433aSmrgfind_executable (const char *wrapper)
3884d656433aSmrg{
3885d656433aSmrg  int has_slash = 0;
3886d656433aSmrg  const char *p;
3887d656433aSmrg  const char *p_next;
3888d656433aSmrg  /* static buffer for getcwd */
3889d656433aSmrg  char tmp[LT_PATHMAX + 1];
3890d656433aSmrg  int tmp_len;
3891d656433aSmrg  char *concat_name;
3892126a8a12Smrg
3893555991fdSmrg  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
3894555991fdSmrg                  nonempty (wrapper));
3895126a8a12Smrg
3896d656433aSmrg  if ((wrapper == NULL) || (*wrapper == '\0'))
3897d656433aSmrg    return NULL;
3898126a8a12Smrg
3899d656433aSmrg  /* Absolute path? */
3900d656433aSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3901d656433aSmrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
3902d656433aSmrg    {
3903d656433aSmrg      concat_name = xstrdup (wrapper);
3904d656433aSmrg      if (check_executable (concat_name))
3905d656433aSmrg	return concat_name;
3906d656433aSmrg      XFREE (concat_name);
3907d656433aSmrg    }
3908d656433aSmrg  else
3909d656433aSmrg    {
3910d656433aSmrg#endif
3911d656433aSmrg      if (IS_DIR_SEPARATOR (wrapper[0]))
3912d656433aSmrg	{
3913d656433aSmrg	  concat_name = xstrdup (wrapper);
3914d656433aSmrg	  if (check_executable (concat_name))
3915d656433aSmrg	    return concat_name;
3916d656433aSmrg	  XFREE (concat_name);
3917d656433aSmrg	}
3918d656433aSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3919d656433aSmrg    }
3920d656433aSmrg#endif
3921126a8a12Smrg
3922d656433aSmrg  for (p = wrapper; *p; p++)
3923d656433aSmrg    if (*p == '/')
3924d656433aSmrg      {
3925d656433aSmrg	has_slash = 1;
3926d656433aSmrg	break;
3927d656433aSmrg      }
3928d656433aSmrg  if (!has_slash)
3929d656433aSmrg    {
3930d656433aSmrg      /* no slashes; search PATH */
3931d656433aSmrg      const char *path = getenv ("PATH");
3932d656433aSmrg      if (path != NULL)
3933d656433aSmrg	{
3934d656433aSmrg	  for (p = path; *p; p = p_next)
3935d656433aSmrg	    {
3936d656433aSmrg	      const char *q;
3937d656433aSmrg	      size_t p_len;
3938d656433aSmrg	      for (q = p; *q; q++)
3939d656433aSmrg		if (IS_PATH_SEPARATOR (*q))
3940d656433aSmrg		  break;
3941d656433aSmrg	      p_len = q - p;
3942d656433aSmrg	      p_next = (*q == '\0' ? q : q + 1);
3943d656433aSmrg	      if (p_len == 0)
3944d656433aSmrg		{
3945d656433aSmrg		  /* empty path: current directory */
3946d656433aSmrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
3947555991fdSmrg		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
3948555991fdSmrg                              nonnull (strerror (errno)));
3949d656433aSmrg		  tmp_len = strlen (tmp);
3950d656433aSmrg		  concat_name =
3951d656433aSmrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
3952d656433aSmrg		  memcpy (concat_name, tmp, tmp_len);
3953d656433aSmrg		  concat_name[tmp_len] = '/';
3954d656433aSmrg		  strcpy (concat_name + tmp_len + 1, wrapper);
3955d656433aSmrg		}
3956d656433aSmrg	      else
3957d656433aSmrg		{
3958d656433aSmrg		  concat_name =
3959d656433aSmrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
3960d656433aSmrg		  memcpy (concat_name, p, p_len);
3961d656433aSmrg		  concat_name[p_len] = '/';
3962d656433aSmrg		  strcpy (concat_name + p_len + 1, wrapper);
3963d656433aSmrg		}
3964d656433aSmrg	      if (check_executable (concat_name))
3965d656433aSmrg		return concat_name;
3966d656433aSmrg	      XFREE (concat_name);
3967d656433aSmrg	    }
3968d656433aSmrg	}
3969d656433aSmrg      /* not found in PATH; assume curdir */
3970d656433aSmrg    }
3971d656433aSmrg  /* Relative path | not found in path: prepend cwd */
3972d656433aSmrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
3973555991fdSmrg    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
3974555991fdSmrg              nonnull (strerror (errno)));
3975d656433aSmrg  tmp_len = strlen (tmp);
3976d656433aSmrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
3977d656433aSmrg  memcpy (concat_name, tmp, tmp_len);
3978d656433aSmrg  concat_name[tmp_len] = '/';
3979d656433aSmrg  strcpy (concat_name + tmp_len + 1, wrapper);
3980126a8a12Smrg
3981d656433aSmrg  if (check_executable (concat_name))
3982d656433aSmrg    return concat_name;
3983d656433aSmrg  XFREE (concat_name);
3984d656433aSmrg  return NULL;
3985d656433aSmrg}
3986126a8a12Smrg
3987d656433aSmrgchar *
3988d656433aSmrgchase_symlinks (const char *pathspec)
3989d656433aSmrg{
3990d656433aSmrg#ifndef S_ISLNK
3991d656433aSmrg  return xstrdup (pathspec);
3992d656433aSmrg#else
3993d656433aSmrg  char buf[LT_PATHMAX];
3994d656433aSmrg  struct stat s;
3995d656433aSmrg  char *tmp_pathspec = xstrdup (pathspec);
3996d656433aSmrg  char *p;
3997d656433aSmrg  int has_symlinks = 0;
3998d656433aSmrg  while (strlen (tmp_pathspec) && !has_symlinks)
3999d656433aSmrg    {
4000555991fdSmrg      lt_debugprintf (__FILE__, __LINE__,
4001555991fdSmrg		      "checking path component for symlinks: %s\n",
4002555991fdSmrg		      tmp_pathspec);
4003d656433aSmrg      if (lstat (tmp_pathspec, &s) == 0)
4004d656433aSmrg	{
4005d656433aSmrg	  if (S_ISLNK (s.st_mode) != 0)
4006d656433aSmrg	    {
4007d656433aSmrg	      has_symlinks = 1;
4008d656433aSmrg	      break;
4009d656433aSmrg	    }
4010126a8a12Smrg
4011d656433aSmrg	  /* search backwards for last DIR_SEPARATOR */
4012d656433aSmrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
4013d656433aSmrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4014d656433aSmrg	    p--;
4015d656433aSmrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4016d656433aSmrg	    {
4017d656433aSmrg	      /* no more DIR_SEPARATORS left */
4018d656433aSmrg	      break;
4019d656433aSmrg	    }
4020d656433aSmrg	  *p = '\0';
4021d656433aSmrg	}
4022d656433aSmrg      else
4023d656433aSmrg	{
4024555991fdSmrg	  lt_fatal (__FILE__, __LINE__,
4025555991fdSmrg		    "error accessing file \"%s\": %s",
4026555991fdSmrg		    tmp_pathspec, nonnull (strerror (errno)));
4027d656433aSmrg	}
4028d656433aSmrg    }
4029d656433aSmrg  XFREE (tmp_pathspec);
4030126a8a12Smrg
4031d656433aSmrg  if (!has_symlinks)
4032d656433aSmrg    {
4033d656433aSmrg      return xstrdup (pathspec);
4034d656433aSmrg    }
4035126a8a12Smrg
4036d656433aSmrg  tmp_pathspec = realpath (pathspec, buf);
4037d656433aSmrg  if (tmp_pathspec == 0)
4038d656433aSmrg    {
4039555991fdSmrg      lt_fatal (__FILE__, __LINE__,
4040555991fdSmrg		"could not follow symlinks for %s", pathspec);
4041d656433aSmrg    }
4042d656433aSmrg  return xstrdup (tmp_pathspec);
4043d656433aSmrg#endif
4044d656433aSmrg}
4045126a8a12Smrg
4046d656433aSmrgchar *
4047d656433aSmrgstrendzap (char *str, const char *pat)
4048d656433aSmrg{
4049d656433aSmrg  size_t len, patlen;
4050126a8a12Smrg
4051d656433aSmrg  assert (str != NULL);
4052d656433aSmrg  assert (pat != NULL);
4053126a8a12Smrg
4054d656433aSmrg  len = strlen (str);
4055d656433aSmrg  patlen = strlen (pat);
4056126a8a12Smrg
4057d656433aSmrg  if (patlen <= len)
4058d656433aSmrg    {
4059d656433aSmrg      str += len - patlen;
4060d656433aSmrg      if (strcmp (str, pat) == 0)
4061d656433aSmrg	*str = '\0';
4062d656433aSmrg    }
4063d656433aSmrg  return str;
4064d656433aSmrg}
4065126a8a12Smrg
4066555991fdSmrgvoid
4067555991fdSmrglt_debugprintf (const char *file, int line, const char *fmt, ...)
4068555991fdSmrg{
4069555991fdSmrg  va_list args;
4070555991fdSmrg  if (lt_debug)
4071555991fdSmrg    {
4072555991fdSmrg      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
4073555991fdSmrg      va_start (args, fmt);
4074555991fdSmrg      (void) vfprintf (stderr, fmt, args);
4075555991fdSmrg      va_end (args);
4076555991fdSmrg    }
4077555991fdSmrg}
4078555991fdSmrg
4079d656433aSmrgstatic void
4080555991fdSmrglt_error_core (int exit_status, const char *file,
4081555991fdSmrg	       int line, const char *mode,
4082d656433aSmrg	       const char *message, va_list ap)
4083d656433aSmrg{
4084555991fdSmrg  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
4085d656433aSmrg  vfprintf (stderr, message, ap);
4086d656433aSmrg  fprintf (stderr, ".\n");
4087126a8a12Smrg
4088d656433aSmrg  if (exit_status >= 0)
4089d656433aSmrg    exit (exit_status);
4090d656433aSmrg}
4091126a8a12Smrg
4092d656433aSmrgvoid
4093555991fdSmrglt_fatal (const char *file, int line, const char *message, ...)
4094d656433aSmrg{
4095d656433aSmrg  va_list ap;
4096d656433aSmrg  va_start (ap, message);
4097555991fdSmrg  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
4098d656433aSmrg  va_end (ap);
4099d656433aSmrg}
4100126a8a12Smrg
4101555991fdSmrgstatic const char *
4102555991fdSmrgnonnull (const char *s)
4103555991fdSmrg{
4104555991fdSmrg  return s ? s : "(null)";
4105555991fdSmrg}
4106555991fdSmrg
4107555991fdSmrgstatic const char *
4108555991fdSmrgnonempty (const char *s)
4109555991fdSmrg{
4110555991fdSmrg  return (s && !*s) ? "(empty)" : nonnull (s);
4111555991fdSmrg}
4112555991fdSmrg
4113d656433aSmrgvoid
4114d656433aSmrglt_setenv (const char *name, const char *value)
4115d656433aSmrg{
4116555991fdSmrg  lt_debugprintf (__FILE__, __LINE__,
4117555991fdSmrg		  "(lt_setenv) setting '%s' to '%s'\n",
4118555991fdSmrg                  nonnull (name), nonnull (value));
4119d656433aSmrg  {
4120d656433aSmrg#ifdef HAVE_SETENV
4121d656433aSmrg    /* always make a copy, for consistency with !HAVE_SETENV */
4122d656433aSmrg    char *str = xstrdup (value);
4123d656433aSmrg    setenv (name, str, 1);
4124d656433aSmrg#else
4125d656433aSmrg    int len = strlen (name) + 1 + strlen (value) + 1;
4126d656433aSmrg    char *str = XMALLOC (char, len);
4127d656433aSmrg    sprintf (str, "%s=%s", name, value);
4128d656433aSmrg    if (putenv (str) != EXIT_SUCCESS)
4129d656433aSmrg      {
4130d656433aSmrg        XFREE (str);
4131d656433aSmrg      }
4132d656433aSmrg#endif
4133d656433aSmrg  }
4134d656433aSmrg}
4135126a8a12Smrg
4136d656433aSmrgchar *
4137d656433aSmrglt_extend_str (const char *orig_value, const char *add, int to_end)
4138d656433aSmrg{
4139d656433aSmrg  char *new_value;
4140d656433aSmrg  if (orig_value && *orig_value)
4141d656433aSmrg    {
4142d656433aSmrg      int orig_value_len = strlen (orig_value);
4143d656433aSmrg      int add_len = strlen (add);
4144d656433aSmrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
4145d656433aSmrg      if (to_end)
4146d656433aSmrg        {
4147d656433aSmrg          strcpy (new_value, orig_value);
4148d656433aSmrg          strcpy (new_value + orig_value_len, add);
4149d656433aSmrg        }
4150d656433aSmrg      else
4151d656433aSmrg        {
4152d656433aSmrg          strcpy (new_value, add);
4153d656433aSmrg          strcpy (new_value + add_len, orig_value);
4154d656433aSmrg        }
4155d656433aSmrg    }
4156d656433aSmrg  else
4157d656433aSmrg    {
4158d656433aSmrg      new_value = xstrdup (add);
4159d656433aSmrg    }
4160d656433aSmrg  return new_value;
4161d656433aSmrg}
4162126a8a12Smrg
4163d656433aSmrgvoid
4164d656433aSmrglt_update_exe_path (const char *name, const char *value)
4165d656433aSmrg{
4166555991fdSmrg  lt_debugprintf (__FILE__, __LINE__,
4167555991fdSmrg		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
4168555991fdSmrg                  nonnull (name), nonnull (value));
4169126a8a12Smrg
4170d656433aSmrg  if (name && *name && value && *value)
4171d656433aSmrg    {
4172d656433aSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
4173d656433aSmrg      /* some systems can't cope with a ':'-terminated path #' */
4174d656433aSmrg      int len = strlen (new_value);
4175d656433aSmrg      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
4176d656433aSmrg        {
4177d656433aSmrg          new_value[len-1] = '\0';
4178d656433aSmrg        }
4179d656433aSmrg      lt_setenv (name, new_value);
4180d656433aSmrg      XFREE (new_value);
4181d656433aSmrg    }
4182d656433aSmrg}
4183126a8a12Smrg
4184d656433aSmrgvoid
4185d656433aSmrglt_update_lib_path (const char *name, const char *value)
4186d656433aSmrg{
4187555991fdSmrg  lt_debugprintf (__FILE__, __LINE__,
4188555991fdSmrg		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
4189555991fdSmrg                  nonnull (name), nonnull (value));
4190126a8a12Smrg
4191d656433aSmrg  if (name && *name && value && *value)
4192d656433aSmrg    {
4193d656433aSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
4194d656433aSmrg      lt_setenv (name, new_value);
4195d656433aSmrg      XFREE (new_value);
4196d656433aSmrg    }
4197d656433aSmrg}
4198126a8a12Smrg
4199555991fdSmrgEOF
4200555991fdSmrg	    case $host_os in
4201555991fdSmrg	      mingw*)
4202555991fdSmrg		cat <<"EOF"
4203555991fdSmrg
4204555991fdSmrg/* Prepares an argument vector before calling spawn().
4205555991fdSmrg   Note that spawn() does not by itself call the command interpreter
4206555991fdSmrg     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
4207555991fdSmrg      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
4208555991fdSmrg         GetVersionEx(&v);
4209555991fdSmrg         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
4210555991fdSmrg      }) ? "cmd.exe" : "command.com").
4211555991fdSmrg   Instead it simply concatenates the arguments, separated by ' ', and calls
4212555991fdSmrg   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
4213555991fdSmrg   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
4214555991fdSmrg   special way:
4215555991fdSmrg   - Space and tab are interpreted as delimiters. They are not treated as
4216555991fdSmrg     delimiters if they are surrounded by double quotes: "...".
4217555991fdSmrg   - Unescaped double quotes are removed from the input. Their only effect is
4218555991fdSmrg     that within double quotes, space and tab are treated like normal
4219555991fdSmrg     characters.
4220555991fdSmrg   - Backslashes not followed by double quotes are not special.
4221555991fdSmrg   - But 2*n+1 backslashes followed by a double quote become
4222555991fdSmrg     n backslashes followed by a double quote (n >= 0):
4223555991fdSmrg       \" -> "
4224555991fdSmrg       \\\" -> \"
4225555991fdSmrg       \\\\\" -> \\"
4226555991fdSmrg */
4227555991fdSmrg#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"
4228555991fdSmrg#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"
4229555991fdSmrgchar **
4230555991fdSmrgprepare_spawn (char **argv)
4231555991fdSmrg{
4232555991fdSmrg  size_t argc;
4233555991fdSmrg  char **new_argv;
4234555991fdSmrg  size_t i;
4235555991fdSmrg
4236555991fdSmrg  /* Count number of arguments.  */
4237555991fdSmrg  for (argc = 0; argv[argc] != NULL; argc++)
4238555991fdSmrg    ;
4239555991fdSmrg
4240555991fdSmrg  /* Allocate new argument vector.  */
4241555991fdSmrg  new_argv = XMALLOC (char *, argc + 1);
4242555991fdSmrg
4243555991fdSmrg  /* Put quoted arguments into the new argument vector.  */
4244555991fdSmrg  for (i = 0; i < argc; i++)
4245555991fdSmrg    {
4246555991fdSmrg      const char *string = argv[i];
4247555991fdSmrg
4248555991fdSmrg      if (string[0] == '\0')
4249555991fdSmrg	new_argv[i] = xstrdup ("\"\"");
4250555991fdSmrg      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
4251555991fdSmrg	{
4252555991fdSmrg	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
4253555991fdSmrg	  size_t length;
4254555991fdSmrg	  unsigned int backslashes;
4255555991fdSmrg	  const char *s;
4256555991fdSmrg	  char *quoted_string;
4257555991fdSmrg	  char *p;
4258555991fdSmrg
4259555991fdSmrg	  length = 0;
4260555991fdSmrg	  backslashes = 0;
4261555991fdSmrg	  if (quote_around)
4262555991fdSmrg	    length++;
4263555991fdSmrg	  for (s = string; *s != '\0'; s++)
4264555991fdSmrg	    {
4265555991fdSmrg	      char c = *s;
4266555991fdSmrg	      if (c == '"')
4267555991fdSmrg		length += backslashes + 1;
4268555991fdSmrg	      length++;
4269555991fdSmrg	      if (c == '\\')
4270555991fdSmrg		backslashes++;
4271555991fdSmrg	      else
4272555991fdSmrg		backslashes = 0;
4273555991fdSmrg	    }
4274555991fdSmrg	  if (quote_around)
4275555991fdSmrg	    length += backslashes + 1;
4276555991fdSmrg
4277555991fdSmrg	  quoted_string = XMALLOC (char, length + 1);
4278555991fdSmrg
4279555991fdSmrg	  p = quoted_string;
4280555991fdSmrg	  backslashes = 0;
4281555991fdSmrg	  if (quote_around)
4282555991fdSmrg	    *p++ = '"';
4283555991fdSmrg	  for (s = string; *s != '\0'; s++)
4284555991fdSmrg	    {
4285555991fdSmrg	      char c = *s;
4286555991fdSmrg	      if (c == '"')
4287555991fdSmrg		{
4288555991fdSmrg		  unsigned int j;
4289555991fdSmrg		  for (j = backslashes + 1; j > 0; j--)
4290555991fdSmrg		    *p++ = '\\';
4291555991fdSmrg		}
4292555991fdSmrg	      *p++ = c;
4293555991fdSmrg	      if (c == '\\')
4294555991fdSmrg		backslashes++;
4295555991fdSmrg	      else
4296555991fdSmrg		backslashes = 0;
4297555991fdSmrg	    }
4298555991fdSmrg	  if (quote_around)
4299555991fdSmrg	    {
4300555991fdSmrg	      unsigned int j;
4301555991fdSmrg	      for (j = backslashes; j > 0; j--)
4302555991fdSmrg		*p++ = '\\';
4303555991fdSmrg	      *p++ = '"';
4304555991fdSmrg	    }
4305555991fdSmrg	  *p = '\0';
4306555991fdSmrg
4307555991fdSmrg	  new_argv[i] = quoted_string;
4308555991fdSmrg	}
4309555991fdSmrg      else
4310555991fdSmrg	new_argv[i] = (char *) string;
4311555991fdSmrg    }
4312555991fdSmrg  new_argv[argc] = NULL;
4313555991fdSmrg
4314555991fdSmrg  return new_argv;
4315555991fdSmrg}
4316555991fdSmrgEOF
4317555991fdSmrg		;;
4318555991fdSmrg	    esac
4319555991fdSmrg
4320555991fdSmrg            cat <<"EOF"
4321555991fdSmrgvoid lt_dump_script (FILE* f)
4322555991fdSmrg{
4323555991fdSmrgEOF
4324555991fdSmrg	    func_emit_wrapper yes |
4325555991fdSmrg              $SED -e 's/\([\\"]\)/\\\1/g' \
4326555991fdSmrg	           -e 's/^/  fputs ("/' -e 's/$/\\n", f);/'
4327126a8a12Smrg
4328555991fdSmrg            cat <<"EOF"
4329555991fdSmrg}
4330d656433aSmrgEOF
4331d656433aSmrg}
4332d656433aSmrg# end: func_emit_cwrapperexe_src
4333126a8a12Smrg
4334555991fdSmrg# func_win32_import_lib_p ARG
4335555991fdSmrg# True if ARG is an import lib, as indicated by $file_magic_cmd
4336555991fdSmrgfunc_win32_import_lib_p ()
4337555991fdSmrg{
4338555991fdSmrg    $opt_debug
4339555991fdSmrg    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
4340555991fdSmrg    *import*) : ;;
4341555991fdSmrg    *) false ;;
4342555991fdSmrg    esac
4343555991fdSmrg}
4344555991fdSmrg
4345d656433aSmrg# func_mode_link arg...
4346d656433aSmrgfunc_mode_link ()
4347d656433aSmrg{
4348d656433aSmrg    $opt_debug
4349d656433aSmrg    case $host in
4350d656433aSmrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
4351d656433aSmrg      # It is impossible to link a dll without this setting, and
4352d656433aSmrg      # we shouldn't force the makefile maintainer to figure out
4353d656433aSmrg      # which system we are compiling for in order to pass an extra
4354d656433aSmrg      # flag for every libtool invocation.
4355d656433aSmrg      # allow_undefined=no
4356126a8a12Smrg
4357d656433aSmrg      # FIXME: Unfortunately, there are problems with the above when trying
4358d656433aSmrg      # to make a dll which has undefined symbols, in which case not
4359d656433aSmrg      # even a static library is built.  For now, we need to specify
4360d656433aSmrg      # -no-undefined on the libtool link line when we can be certain
4361d656433aSmrg      # that all symbols are satisfied, otherwise we get a static library.
4362d656433aSmrg      allow_undefined=yes
4363d656433aSmrg      ;;
4364d656433aSmrg    *)
4365d656433aSmrg      allow_undefined=yes
4366d656433aSmrg      ;;
4367d656433aSmrg    esac
4368d656433aSmrg    libtool_args=$nonopt
4369d656433aSmrg    base_compile="$nonopt $@"
4370d656433aSmrg    compile_command=$nonopt
4371d656433aSmrg    finalize_command=$nonopt
4372126a8a12Smrg
4373d656433aSmrg    compile_rpath=
4374d656433aSmrg    finalize_rpath=
4375d656433aSmrg    compile_shlibpath=
4376d656433aSmrg    finalize_shlibpath=
4377d656433aSmrg    convenience=
4378d656433aSmrg    old_convenience=
4379d656433aSmrg    deplibs=
4380d656433aSmrg    old_deplibs=
4381d656433aSmrg    compiler_flags=
4382d656433aSmrg    linker_flags=
4383d656433aSmrg    dllsearchpath=
4384d656433aSmrg    lib_search_path=`pwd`
4385d656433aSmrg    inst_prefix_dir=
4386d656433aSmrg    new_inherited_linker_flags=
4387126a8a12Smrg
4388d656433aSmrg    avoid_version=no
4389555991fdSmrg    bindir=
4390d656433aSmrg    dlfiles=
4391d656433aSmrg    dlprefiles=
4392d656433aSmrg    dlself=no
4393d656433aSmrg    export_dynamic=no
4394d656433aSmrg    export_symbols=
4395d656433aSmrg    export_symbols_regex=
4396d656433aSmrg    generated=
4397d656433aSmrg    libobjs=
4398d656433aSmrg    ltlibs=
4399d656433aSmrg    module=no
4400d656433aSmrg    no_install=no
4401d656433aSmrg    objs=
4402d656433aSmrg    non_pic_objects=
4403d656433aSmrg    precious_files_regex=
4404d656433aSmrg    prefer_static_libs=no
4405d656433aSmrg    preload=no
4406d656433aSmrg    prev=
4407d656433aSmrg    prevarg=
4408d656433aSmrg    release=
4409d656433aSmrg    rpath=
4410d656433aSmrg    xrpath=
4411d656433aSmrg    perm_rpath=
4412d656433aSmrg    temp_rpath=
4413d656433aSmrg    thread_safe=no
4414d656433aSmrg    vinfo=
4415d656433aSmrg    vinfo_number=no
4416d656433aSmrg    weak_libs=
4417d656433aSmrg    single_module="${wl}-single_module"
4418d656433aSmrg    func_infer_tag $base_compile
4419126a8a12Smrg
4420d656433aSmrg    # We need to know -static, to get the right output filenames.
4421d656433aSmrg    for arg
4422d656433aSmrg    do
4423d656433aSmrg      case $arg in
4424d656433aSmrg      -shared)
4425d656433aSmrg	test "$build_libtool_libs" != yes && \
4426d656433aSmrg	  func_fatal_configuration "can not build a shared library"
4427d656433aSmrg	build_old_libs=no
4428d656433aSmrg	break
4429d656433aSmrg	;;
4430d656433aSmrg      -all-static | -static | -static-libtool-libs)
4431d656433aSmrg	case $arg in
4432d656433aSmrg	-all-static)
4433d656433aSmrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
4434d656433aSmrg	    func_warning "complete static linking is impossible in this configuration"
4435126a8a12Smrg	  fi
4436d656433aSmrg	  if test -n "$link_static_flag"; then
4437d656433aSmrg	    dlopen_self=$dlopen_self_static
4438126a8a12Smrg	  fi
4439d656433aSmrg	  prefer_static_libs=yes
4440126a8a12Smrg	  ;;
4441d656433aSmrg	-static)
4442d656433aSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
4443d656433aSmrg	    dlopen_self=$dlopen_self_static
4444d656433aSmrg	  fi
4445d656433aSmrg	  prefer_static_libs=built
4446d656433aSmrg	  ;;
4447d656433aSmrg	-static-libtool-libs)
4448d656433aSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
4449d656433aSmrg	    dlopen_self=$dlopen_self_static
4450d656433aSmrg	  fi
4451d656433aSmrg	  prefer_static_libs=yes
4452126a8a12Smrg	  ;;
4453126a8a12Smrg	esac
4454d656433aSmrg	build_libtool_libs=no
4455d656433aSmrg	build_old_libs=yes
4456d656433aSmrg	break
4457d656433aSmrg	;;
4458d656433aSmrg      esac
4459d656433aSmrg    done
4460126a8a12Smrg
4461d656433aSmrg    # See if our shared archives depend on static archives.
4462d656433aSmrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
4463126a8a12Smrg
4464d656433aSmrg    # Go through the arguments, transforming them on the way.
4465d656433aSmrg    while test "$#" -gt 0; do
4466d656433aSmrg      arg="$1"
4467d656433aSmrg      shift
4468d656433aSmrg      func_quote_for_eval "$arg"
4469d656433aSmrg      qarg=$func_quote_for_eval_unquoted_result
4470d656433aSmrg      func_append libtool_args " $func_quote_for_eval_result"
4471126a8a12Smrg
4472d656433aSmrg      # If the previous option needs an argument, assign it.
4473d656433aSmrg      if test -n "$prev"; then
4474d656433aSmrg	case $prev in
4475d656433aSmrg	output)
4476d656433aSmrg	  func_append compile_command " @OUTPUT@"
4477d656433aSmrg	  func_append finalize_command " @OUTPUT@"
4478d656433aSmrg	  ;;
4479d656433aSmrg	esac
4480126a8a12Smrg
4481d656433aSmrg	case $prev in
4482555991fdSmrg	bindir)
4483555991fdSmrg	  bindir="$arg"
4484555991fdSmrg	  prev=
4485555991fdSmrg	  continue
4486555991fdSmrg	  ;;
4487d656433aSmrg	dlfiles|dlprefiles)
4488d656433aSmrg	  if test "$preload" = no; then
4489d656433aSmrg	    # Add the symbol object into the linking commands.
4490d656433aSmrg	    func_append compile_command " @SYMFILE@"
4491d656433aSmrg	    func_append finalize_command " @SYMFILE@"
4492d656433aSmrg	    preload=yes
4493d656433aSmrg	  fi
4494d656433aSmrg	  case $arg in
4495d656433aSmrg	  *.la | *.lo) ;;  # We handle these cases below.
4496d656433aSmrg	  force)
4497d656433aSmrg	    if test "$dlself" = no; then
4498d656433aSmrg	      dlself=needless
4499d656433aSmrg	      export_dynamic=yes
4500d656433aSmrg	    fi
4501d656433aSmrg	    prev=
4502d656433aSmrg	    continue
4503d656433aSmrg	    ;;
4504d656433aSmrg	  self)
4505d656433aSmrg	    if test "$prev" = dlprefiles; then
4506d656433aSmrg	      dlself=yes
4507d656433aSmrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
4508d656433aSmrg	      dlself=yes
4509d656433aSmrg	    else
4510d656433aSmrg	      dlself=needless
4511d656433aSmrg	      export_dynamic=yes
4512d656433aSmrg	    fi
4513d656433aSmrg	    prev=
4514d656433aSmrg	    continue
4515126a8a12Smrg	    ;;
4516126a8a12Smrg	  *)
4517d656433aSmrg	    if test "$prev" = dlfiles; then
4518d656433aSmrg	      dlfiles="$dlfiles $arg"
4519d656433aSmrg	    else
4520d656433aSmrg	      dlprefiles="$dlprefiles $arg"
4521d656433aSmrg	    fi
4522d656433aSmrg	    prev=
4523d656433aSmrg	    continue
4524126a8a12Smrg	    ;;
4525126a8a12Smrg	  esac
4526d656433aSmrg	  ;;
4527d656433aSmrg	expsyms)
4528d656433aSmrg	  export_symbols="$arg"
4529d656433aSmrg	  test -f "$arg" \
4530d656433aSmrg	    || func_fatal_error "symbol file \`$arg' does not exist"
4531d656433aSmrg	  prev=
4532d656433aSmrg	  continue
4533d656433aSmrg	  ;;
4534d656433aSmrg	expsyms_regex)
4535d656433aSmrg	  export_symbols_regex="$arg"
4536d656433aSmrg	  prev=
4537d656433aSmrg	  continue
4538d656433aSmrg	  ;;
4539d656433aSmrg	framework)
4540d656433aSmrg	  case $host in
4541d656433aSmrg	    *-*-darwin*)
4542d656433aSmrg	      case "$deplibs " in
4543d656433aSmrg		*" $qarg.ltframework "*) ;;
4544d656433aSmrg		*) deplibs="$deplibs $qarg.ltframework" # this is fixed later
4545d656433aSmrg		   ;;
4546d656433aSmrg	      esac
4547d656433aSmrg	      ;;
4548d656433aSmrg	  esac
4549d656433aSmrg	  prev=
4550d656433aSmrg	  continue
4551d656433aSmrg	  ;;
4552d656433aSmrg	inst_prefix)
4553d656433aSmrg	  inst_prefix_dir="$arg"
4554d656433aSmrg	  prev=
4555d656433aSmrg	  continue
4556d656433aSmrg	  ;;
4557d656433aSmrg	objectlist)
4558d656433aSmrg	  if test -f "$arg"; then
4559d656433aSmrg	    save_arg=$arg
4560d656433aSmrg	    moreargs=
4561d656433aSmrg	    for fil in `cat "$save_arg"`
4562d656433aSmrg	    do
4563d656433aSmrg#	      moreargs="$moreargs $fil"
4564d656433aSmrg	      arg=$fil
4565d656433aSmrg	      # A libtool-controlled object.
4566126a8a12Smrg
4567d656433aSmrg	      # Check to see that this really is a libtool object.
4568d656433aSmrg	      if func_lalib_unsafe_p "$arg"; then
4569d656433aSmrg		pic_object=
4570d656433aSmrg		non_pic_object=
4571126a8a12Smrg
4572d656433aSmrg		# Read the .lo file
4573d656433aSmrg		func_source "$arg"
4574126a8a12Smrg
4575d656433aSmrg		if test -z "$pic_object" ||
4576d656433aSmrg		   test -z "$non_pic_object" ||
4577d656433aSmrg		   test "$pic_object" = none &&
4578d656433aSmrg		   test "$non_pic_object" = none; then
4579d656433aSmrg		  func_fatal_error "cannot find name of object for \`$arg'"
4580d656433aSmrg		fi
4581126a8a12Smrg
4582d656433aSmrg		# Extract subdirectory from the argument.
4583d656433aSmrg		func_dirname "$arg" "/" ""
4584d656433aSmrg		xdir="$func_dirname_result"
4585126a8a12Smrg
4586d656433aSmrg		if test "$pic_object" != none; then
4587d656433aSmrg		  # Prepend the subdirectory the object is found in.
4588d656433aSmrg		  pic_object="$xdir$pic_object"
4589126a8a12Smrg
4590d656433aSmrg		  if test "$prev" = dlfiles; then
4591d656433aSmrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
4592d656433aSmrg		      dlfiles="$dlfiles $pic_object"
4593d656433aSmrg		      prev=
4594d656433aSmrg		      continue
4595d656433aSmrg		    else
4596d656433aSmrg		      # If libtool objects are unsupported, then we need to preload.
4597d656433aSmrg		      prev=dlprefiles
4598d656433aSmrg		    fi
4599d656433aSmrg		  fi
4600126a8a12Smrg
4601d656433aSmrg		  # CHECK ME:  I think I busted this.  -Ossama
4602d656433aSmrg		  if test "$prev" = dlprefiles; then
4603d656433aSmrg		    # Preload the old-style object.
4604d656433aSmrg		    dlprefiles="$dlprefiles $pic_object"
4605d656433aSmrg		    prev=
4606d656433aSmrg		  fi
4607126a8a12Smrg
4608d656433aSmrg		  # A PIC object.
4609d656433aSmrg		  func_append libobjs " $pic_object"
4610d656433aSmrg		  arg="$pic_object"
4611d656433aSmrg		fi
4612126a8a12Smrg
4613d656433aSmrg		# Non-PIC object.
4614d656433aSmrg		if test "$non_pic_object" != none; then
4615d656433aSmrg		  # Prepend the subdirectory the object is found in.
4616d656433aSmrg		  non_pic_object="$xdir$non_pic_object"
4617126a8a12Smrg
4618d656433aSmrg		  # A standard non-PIC object
4619d656433aSmrg		  func_append non_pic_objects " $non_pic_object"
4620d656433aSmrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
4621d656433aSmrg		    arg="$non_pic_object"
4622d656433aSmrg		  fi
4623d656433aSmrg		else
4624d656433aSmrg		  # If the PIC object exists, use it instead.
4625d656433aSmrg		  # $xdir was prepended to $pic_object above.
4626d656433aSmrg		  non_pic_object="$pic_object"
4627d656433aSmrg		  func_append non_pic_objects " $non_pic_object"
4628d656433aSmrg		fi
4629d656433aSmrg	      else
4630d656433aSmrg		# Only an error if not doing a dry-run.
4631d656433aSmrg		if $opt_dry_run; then
4632d656433aSmrg		  # Extract subdirectory from the argument.
4633d656433aSmrg		  func_dirname "$arg" "/" ""
4634d656433aSmrg		  xdir="$func_dirname_result"
4635d656433aSmrg
4636d656433aSmrg		  func_lo2o "$arg"
4637d656433aSmrg		  pic_object=$xdir$objdir/$func_lo2o_result
4638d656433aSmrg		  non_pic_object=$xdir$func_lo2o_result
4639d656433aSmrg		  func_append libobjs " $pic_object"
4640d656433aSmrg		  func_append non_pic_objects " $non_pic_object"
4641d656433aSmrg	        else
4642d656433aSmrg		  func_fatal_error "\`$arg' is not a valid libtool object"
4643d656433aSmrg		fi
4644d656433aSmrg	      fi
4645d656433aSmrg	    done
4646d656433aSmrg	  else
4647d656433aSmrg	    func_fatal_error "link input file \`$arg' does not exist"
4648d656433aSmrg	  fi
4649d656433aSmrg	  arg=$save_arg
4650d656433aSmrg	  prev=
4651d656433aSmrg	  continue
4652d656433aSmrg	  ;;
4653d656433aSmrg	precious_regex)
4654d656433aSmrg	  precious_files_regex="$arg"
4655d656433aSmrg	  prev=
4656d656433aSmrg	  continue
4657d656433aSmrg	  ;;
4658d656433aSmrg	release)
4659d656433aSmrg	  release="-$arg"
4660d656433aSmrg	  prev=
4661d656433aSmrg	  continue
4662d656433aSmrg	  ;;
4663d656433aSmrg	rpath | xrpath)
4664d656433aSmrg	  # We need an absolute path.
4665d656433aSmrg	  case $arg in
4666d656433aSmrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
4667d656433aSmrg	  *)
4668d656433aSmrg	    func_fatal_error "only absolute run-paths are allowed"
4669d656433aSmrg	    ;;
4670d656433aSmrg	  esac
4671d656433aSmrg	  if test "$prev" = rpath; then
4672d656433aSmrg	    case "$rpath " in
4673d656433aSmrg	    *" $arg "*) ;;
4674d656433aSmrg	    *) rpath="$rpath $arg" ;;
4675d656433aSmrg	    esac
4676d656433aSmrg	  else
4677d656433aSmrg	    case "$xrpath " in
4678d656433aSmrg	    *" $arg "*) ;;
4679d656433aSmrg	    *) xrpath="$xrpath $arg" ;;
4680d656433aSmrg	    esac
4681d656433aSmrg	  fi
4682d656433aSmrg	  prev=
4683d656433aSmrg	  continue
4684d656433aSmrg	  ;;
4685d656433aSmrg	shrext)
4686d656433aSmrg	  shrext_cmds="$arg"
4687d656433aSmrg	  prev=
4688d656433aSmrg	  continue
4689d656433aSmrg	  ;;
4690d656433aSmrg	weak)
4691d656433aSmrg	  weak_libs="$weak_libs $arg"
4692d656433aSmrg	  prev=
4693d656433aSmrg	  continue
4694d656433aSmrg	  ;;
4695d656433aSmrg	xcclinker)
4696d656433aSmrg	  linker_flags="$linker_flags $qarg"
4697d656433aSmrg	  compiler_flags="$compiler_flags $qarg"
4698d656433aSmrg	  prev=
4699d656433aSmrg	  func_append compile_command " $qarg"
4700d656433aSmrg	  func_append finalize_command " $qarg"
4701d656433aSmrg	  continue
4702d656433aSmrg	  ;;
4703d656433aSmrg	xcompiler)
4704d656433aSmrg	  compiler_flags="$compiler_flags $qarg"
4705d656433aSmrg	  prev=
4706d656433aSmrg	  func_append compile_command " $qarg"
4707d656433aSmrg	  func_append finalize_command " $qarg"
4708d656433aSmrg	  continue
4709d656433aSmrg	  ;;
4710d656433aSmrg	xlinker)
4711d656433aSmrg	  linker_flags="$linker_flags $qarg"
4712d656433aSmrg	  compiler_flags="$compiler_flags $wl$qarg"
4713d656433aSmrg	  prev=
4714d656433aSmrg	  func_append compile_command " $wl$qarg"
4715d656433aSmrg	  func_append finalize_command " $wl$qarg"
4716d656433aSmrg	  continue
4717d656433aSmrg	  ;;
4718d656433aSmrg	*)
4719d656433aSmrg	  eval "$prev=\"\$arg\""
4720d656433aSmrg	  prev=
4721d656433aSmrg	  continue
4722d656433aSmrg	  ;;
4723126a8a12Smrg	esac
4724d656433aSmrg      fi # test -n "$prev"
4725126a8a12Smrg
4726d656433aSmrg      prevarg="$arg"
4727126a8a12Smrg
4728d656433aSmrg      case $arg in
4729d656433aSmrg      -all-static)
4730d656433aSmrg	if test -n "$link_static_flag"; then
4731d656433aSmrg	  # See comment for -static flag below, for more details.
4732d656433aSmrg	  func_append compile_command " $link_static_flag"
4733d656433aSmrg	  func_append finalize_command " $link_static_flag"
4734d656433aSmrg	fi
4735d656433aSmrg	continue
4736d656433aSmrg	;;
4737126a8a12Smrg
4738d656433aSmrg      -allow-undefined)
4739d656433aSmrg	# FIXME: remove this flag sometime in the future.
4740d656433aSmrg	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
4741d656433aSmrg	;;
4742126a8a12Smrg
4743d656433aSmrg      -avoid-version)
4744d656433aSmrg	avoid_version=yes
4745d656433aSmrg	continue
4746d656433aSmrg	;;
4747126a8a12Smrg
4748555991fdSmrg      -bindir)
4749555991fdSmrg	prev=bindir
4750555991fdSmrg	continue
4751555991fdSmrg	;;
4752555991fdSmrg
4753d656433aSmrg      -dlopen)
4754d656433aSmrg	prev=dlfiles
4755d656433aSmrg	continue
4756d656433aSmrg	;;
4757126a8a12Smrg
4758d656433aSmrg      -dlpreopen)
4759d656433aSmrg	prev=dlprefiles
4760d656433aSmrg	continue
4761d656433aSmrg	;;
4762126a8a12Smrg
4763d656433aSmrg      -export-dynamic)
4764d656433aSmrg	export_dynamic=yes
4765d656433aSmrg	continue
4766d656433aSmrg	;;
4767126a8a12Smrg
4768d656433aSmrg      -export-symbols | -export-symbols-regex)
4769d656433aSmrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
4770d656433aSmrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
4771d656433aSmrg	fi
4772d656433aSmrg	if test "X$arg" = "X-export-symbols"; then
4773d656433aSmrg	  prev=expsyms
4774d656433aSmrg	else
4775d656433aSmrg	  prev=expsyms_regex
4776d656433aSmrg	fi
4777d656433aSmrg	continue
4778d656433aSmrg	;;
4779126a8a12Smrg
4780d656433aSmrg      -framework)
4781d656433aSmrg	prev=framework
4782d656433aSmrg	continue
4783d656433aSmrg	;;
4784126a8a12Smrg
4785d656433aSmrg      -inst-prefix-dir)
4786d656433aSmrg	prev=inst_prefix
4787d656433aSmrg	continue
4788d656433aSmrg	;;
4789126a8a12Smrg
4790d656433aSmrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
4791d656433aSmrg      # so, if we see these flags be careful not to treat them like -L
4792d656433aSmrg      -L[A-Z][A-Z]*:*)
4793d656433aSmrg	case $with_gcc/$host in
4794d656433aSmrg	no/*-*-irix* | /*-*-irix*)
4795d656433aSmrg	  func_append compile_command " $arg"
4796d656433aSmrg	  func_append finalize_command " $arg"
4797d656433aSmrg	  ;;
4798d656433aSmrg	esac
4799d656433aSmrg	continue
4800d656433aSmrg	;;
4801126a8a12Smrg
4802d656433aSmrg      -L*)
4803d656433aSmrg	func_stripname '-L' '' "$arg"
4804d656433aSmrg	dir=$func_stripname_result
4805d656433aSmrg	if test -z "$dir"; then
4806d656433aSmrg	  if test "$#" -gt 0; then
4807d656433aSmrg	    func_fatal_error "require no space between \`-L' and \`$1'"
4808d656433aSmrg	  else
4809d656433aSmrg	    func_fatal_error "need path for \`-L' option"
4810d656433aSmrg	  fi
4811d656433aSmrg	fi
4812d656433aSmrg	# We need an absolute path.
4813d656433aSmrg	case $dir in
4814d656433aSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
4815d656433aSmrg	*)
4816d656433aSmrg	  absdir=`cd "$dir" && pwd`
4817d656433aSmrg	  test -z "$absdir" && \
4818d656433aSmrg	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
4819d656433aSmrg	  dir="$absdir"
4820d656433aSmrg	  ;;
4821d656433aSmrg	esac
4822d656433aSmrg	case "$deplibs " in
4823d656433aSmrg	*" -L$dir "*) ;;
4824d656433aSmrg	*)
4825d656433aSmrg	  deplibs="$deplibs -L$dir"
4826d656433aSmrg	  lib_search_path="$lib_search_path $dir"
4827d656433aSmrg	  ;;
4828d656433aSmrg	esac
4829d656433aSmrg	case $host in
4830d656433aSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
4831555991fdSmrg	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
4832d656433aSmrg	  case :$dllsearchpath: in
4833d656433aSmrg	  *":$dir:"*) ;;
4834d656433aSmrg	  ::) dllsearchpath=$dir;;
4835d656433aSmrg	  *) dllsearchpath="$dllsearchpath:$dir";;
4836d656433aSmrg	  esac
4837d656433aSmrg	  case :$dllsearchpath: in
4838d656433aSmrg	  *":$testbindir:"*) ;;
4839d656433aSmrg	  ::) dllsearchpath=$testbindir;;
4840d656433aSmrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
4841d656433aSmrg	  esac
4842d656433aSmrg	  ;;
4843d656433aSmrg	esac
4844d656433aSmrg	continue
4845d656433aSmrg	;;
4846126a8a12Smrg
4847d656433aSmrg      -l*)
4848d656433aSmrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
4849d656433aSmrg	  case $host in
4850555991fdSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
4851d656433aSmrg	    # These systems don't actually have a C or math library (as such)
4852d656433aSmrg	    continue
4853d656433aSmrg	    ;;
4854d656433aSmrg	  *-*-os2*)
4855d656433aSmrg	    # These systems don't actually have a C library (as such)
4856d656433aSmrg	    test "X$arg" = "X-lc" && continue
4857d656433aSmrg	    ;;
4858d656433aSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
4859d656433aSmrg	    # Do not include libc due to us having libc/libc_r.
4860d656433aSmrg	    test "X$arg" = "X-lc" && continue
4861d656433aSmrg	    ;;
4862d656433aSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
4863d656433aSmrg	    # Rhapsody C and math libraries are in the System framework
4864d656433aSmrg	    deplibs="$deplibs System.ltframework"
4865d656433aSmrg	    continue
4866d656433aSmrg	    ;;
4867d656433aSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
4868d656433aSmrg	    # Causes problems with __ctype
4869d656433aSmrg	    test "X$arg" = "X-lc" && continue
4870d656433aSmrg	    ;;
4871d656433aSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
4872d656433aSmrg	    # Compiler inserts libc in the correct place for threads to work
4873d656433aSmrg	    test "X$arg" = "X-lc" && continue
4874d656433aSmrg	    ;;
4875d656433aSmrg	  esac
4876d656433aSmrg	elif test "X$arg" = "X-lc_r"; then
4877d656433aSmrg	 case $host in
4878d656433aSmrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
4879d656433aSmrg	   # Do not include libc_r directly, use -pthread flag.
4880d656433aSmrg	   continue
4881d656433aSmrg	   ;;
4882d656433aSmrg	 esac
4883d656433aSmrg	fi
4884d656433aSmrg	deplibs="$deplibs $arg"
4885d656433aSmrg	continue
4886d656433aSmrg	;;
4887126a8a12Smrg
4888d656433aSmrg      -module)
4889d656433aSmrg	module=yes
4890d656433aSmrg	continue
4891d656433aSmrg	;;
4892126a8a12Smrg
4893d656433aSmrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
4894d656433aSmrg      # classes, name mangling, and exception handling.
4895d656433aSmrg      # Darwin uses the -arch flag to determine output architecture.
4896d656433aSmrg      -model|-arch|-isysroot)
4897d656433aSmrg	compiler_flags="$compiler_flags $arg"
4898d656433aSmrg	func_append compile_command " $arg"
4899d656433aSmrg	func_append finalize_command " $arg"
4900d656433aSmrg	prev=xcompiler
4901d656433aSmrg	continue
4902d656433aSmrg	;;
4903126a8a12Smrg
4904d656433aSmrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
4905d656433aSmrg	compiler_flags="$compiler_flags $arg"
4906d656433aSmrg	func_append compile_command " $arg"
4907d656433aSmrg	func_append finalize_command " $arg"
4908d656433aSmrg	case "$new_inherited_linker_flags " in
4909d656433aSmrg	    *" $arg "*) ;;
4910d656433aSmrg	    * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;;
4911d656433aSmrg	esac
4912d656433aSmrg	continue
4913d656433aSmrg	;;
4914126a8a12Smrg
4915d656433aSmrg      -multi_module)
4916d656433aSmrg	single_module="${wl}-multi_module"
4917d656433aSmrg	continue
4918d656433aSmrg	;;
4919126a8a12Smrg
4920d656433aSmrg      -no-fast-install)
4921d656433aSmrg	fast_install=no
4922d656433aSmrg	continue
4923d656433aSmrg	;;
4924126a8a12Smrg
4925d656433aSmrg      -no-install)
4926d656433aSmrg	case $host in
4927d656433aSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
4928d656433aSmrg	  # The PATH hackery in wrapper scripts is required on Windows
4929d656433aSmrg	  # and Darwin in order for the loader to find any dlls it needs.
4930d656433aSmrg	  func_warning "\`-no-install' is ignored for $host"
4931d656433aSmrg	  func_warning "assuming \`-no-fast-install' instead"
4932d656433aSmrg	  fast_install=no
4933d656433aSmrg	  ;;
4934d656433aSmrg	*) no_install=yes ;;
4935d656433aSmrg	esac
4936d656433aSmrg	continue
4937d656433aSmrg	;;
4938126a8a12Smrg
4939d656433aSmrg      -no-undefined)
4940d656433aSmrg	allow_undefined=no
4941d656433aSmrg	continue
4942d656433aSmrg	;;
4943126a8a12Smrg
4944d656433aSmrg      -objectlist)
4945d656433aSmrg	prev=objectlist
4946d656433aSmrg	continue
4947d656433aSmrg	;;
4948126a8a12Smrg
4949d656433aSmrg      -o) prev=output ;;
4950126a8a12Smrg
4951d656433aSmrg      -precious-files-regex)
4952d656433aSmrg	prev=precious_regex
4953d656433aSmrg	continue
4954d656433aSmrg	;;
4955126a8a12Smrg
4956d656433aSmrg      -release)
4957d656433aSmrg	prev=release
4958d656433aSmrg	continue
4959d656433aSmrg	;;
4960126a8a12Smrg
4961d656433aSmrg      -rpath)
4962d656433aSmrg	prev=rpath
4963d656433aSmrg	continue
4964d656433aSmrg	;;
4965126a8a12Smrg
4966d656433aSmrg      -R)
4967d656433aSmrg	prev=xrpath
4968d656433aSmrg	continue
4969d656433aSmrg	;;
4970126a8a12Smrg
4971d656433aSmrg      -R*)
4972d656433aSmrg	func_stripname '-R' '' "$arg"
4973d656433aSmrg	dir=$func_stripname_result
4974d656433aSmrg	# We need an absolute path.
4975d656433aSmrg	case $dir in
4976d656433aSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
4977d656433aSmrg	*)
4978d656433aSmrg	  func_fatal_error "only absolute run-paths are allowed"
4979d656433aSmrg	  ;;
4980d656433aSmrg	esac
4981d656433aSmrg	case "$xrpath " in
4982d656433aSmrg	*" $dir "*) ;;
4983d656433aSmrg	*) xrpath="$xrpath $dir" ;;
4984d656433aSmrg	esac
4985d656433aSmrg	continue
4986d656433aSmrg	;;
4987126a8a12Smrg
4988d656433aSmrg      -shared)
4989d656433aSmrg	# The effects of -shared are defined in a previous loop.
4990d656433aSmrg	continue
4991d656433aSmrg	;;
4992126a8a12Smrg
4993d656433aSmrg      -shrext)
4994d656433aSmrg	prev=shrext
4995d656433aSmrg	continue
4996d656433aSmrg	;;
4997126a8a12Smrg
4998d656433aSmrg      -static | -static-libtool-libs)
4999d656433aSmrg	# The effects of -static are defined in a previous loop.
5000d656433aSmrg	# We used to do the same as -all-static on platforms that
5001d656433aSmrg	# didn't have a PIC flag, but the assumption that the effects
5002d656433aSmrg	# would be equivalent was wrong.  It would break on at least
5003d656433aSmrg	# Digital Unix and AIX.
5004d656433aSmrg	continue
5005d656433aSmrg	;;
5006126a8a12Smrg
5007d656433aSmrg      -thread-safe)
5008d656433aSmrg	thread_safe=yes
5009d656433aSmrg	continue
5010d656433aSmrg	;;
5011126a8a12Smrg
5012d656433aSmrg      -version-info)
5013d656433aSmrg	prev=vinfo
5014d656433aSmrg	continue
5015d656433aSmrg	;;
5016126a8a12Smrg
5017d656433aSmrg      -version-number)
5018d656433aSmrg	prev=vinfo
5019d656433aSmrg	vinfo_number=yes
5020d656433aSmrg	continue
5021d656433aSmrg	;;
5022126a8a12Smrg
5023d656433aSmrg      -weak)
5024d656433aSmrg        prev=weak
5025d656433aSmrg	continue
5026d656433aSmrg	;;
5027126a8a12Smrg
5028d656433aSmrg      -Wc,*)
5029d656433aSmrg	func_stripname '-Wc,' '' "$arg"
5030d656433aSmrg	args=$func_stripname_result
5031d656433aSmrg	arg=
5032d656433aSmrg	save_ifs="$IFS"; IFS=','
5033d656433aSmrg	for flag in $args; do
5034d656433aSmrg	  IFS="$save_ifs"
5035d656433aSmrg          func_quote_for_eval "$flag"
5036555991fdSmrg	  arg="$arg $func_quote_for_eval_result"
5037d656433aSmrg	  compiler_flags="$compiler_flags $func_quote_for_eval_result"
5038d656433aSmrg	done
5039d656433aSmrg	IFS="$save_ifs"
5040d656433aSmrg	func_stripname ' ' '' "$arg"
5041d656433aSmrg	arg=$func_stripname_result
5042d656433aSmrg	;;
5043126a8a12Smrg
5044d656433aSmrg      -Wl,*)
5045d656433aSmrg	func_stripname '-Wl,' '' "$arg"
5046d656433aSmrg	args=$func_stripname_result
5047d656433aSmrg	arg=
5048d656433aSmrg	save_ifs="$IFS"; IFS=','
5049d656433aSmrg	for flag in $args; do
5050d656433aSmrg	  IFS="$save_ifs"
5051d656433aSmrg          func_quote_for_eval "$flag"
5052d656433aSmrg	  arg="$arg $wl$func_quote_for_eval_result"
5053d656433aSmrg	  compiler_flags="$compiler_flags $wl$func_quote_for_eval_result"
5054d656433aSmrg	  linker_flags="$linker_flags $func_quote_for_eval_result"
5055d656433aSmrg	done
5056d656433aSmrg	IFS="$save_ifs"
5057d656433aSmrg	func_stripname ' ' '' "$arg"
5058d656433aSmrg	arg=$func_stripname_result
5059d656433aSmrg	;;
5060126a8a12Smrg
5061d656433aSmrg      -Xcompiler)
5062d656433aSmrg	prev=xcompiler
5063d656433aSmrg	continue
5064d656433aSmrg	;;
5065126a8a12Smrg
5066d656433aSmrg      -Xlinker)
5067d656433aSmrg	prev=xlinker
5068d656433aSmrg	continue
5069d656433aSmrg	;;
5070126a8a12Smrg
5071d656433aSmrg      -XCClinker)
5072d656433aSmrg	prev=xcclinker
5073d656433aSmrg	continue
5074d656433aSmrg	;;
5075126a8a12Smrg
5076d656433aSmrg      # -msg_* for osf cc
5077d656433aSmrg      -msg_*)
5078d656433aSmrg	func_quote_for_eval "$arg"
5079d656433aSmrg	arg="$func_quote_for_eval_result"
5080d656433aSmrg	;;
5081126a8a12Smrg
5082555991fdSmrg      # Flags to be passed through unchanged, with rationale:
5083555991fdSmrg      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
5084555991fdSmrg      # -r[0-9][0-9]*        specify processor for the SGI compiler
5085555991fdSmrg      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
5086555991fdSmrg      # +DA*, +DD*           enable 64-bit mode for the HP compiler
5087555991fdSmrg      # -q*                  compiler args for the IBM compiler
5088555991fdSmrg      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
5089555991fdSmrg      # -F/path              path to uninstalled frameworks, gcc on darwin
5090555991fdSmrg      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
5091555991fdSmrg      # @file                GCC response files
5092555991fdSmrg      # -tp=*                Portland pgcc target processor selection
5093d656433aSmrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
5094555991fdSmrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*)
5095d656433aSmrg        func_quote_for_eval "$arg"
5096d656433aSmrg	arg="$func_quote_for_eval_result"
5097d656433aSmrg        func_append compile_command " $arg"
5098d656433aSmrg        func_append finalize_command " $arg"
5099d656433aSmrg        compiler_flags="$compiler_flags $arg"
5100d656433aSmrg        continue
5101d656433aSmrg        ;;
5102126a8a12Smrg
5103d656433aSmrg      # Some other compiler flag.
5104d656433aSmrg      -* | +*)
5105d656433aSmrg        func_quote_for_eval "$arg"
5106d656433aSmrg	arg="$func_quote_for_eval_result"
5107d656433aSmrg	;;
5108126a8a12Smrg
5109d656433aSmrg      *.$objext)
5110d656433aSmrg	# A standard object.
5111d656433aSmrg	objs="$objs $arg"
5112d656433aSmrg	;;
5113d656433aSmrg
5114d656433aSmrg      *.lo)
5115d656433aSmrg	# A libtool-controlled object.
5116d656433aSmrg
5117d656433aSmrg	# Check to see that this really is a libtool object.
5118d656433aSmrg	if func_lalib_unsafe_p "$arg"; then
5119d656433aSmrg	  pic_object=
5120d656433aSmrg	  non_pic_object=
5121d656433aSmrg
5122d656433aSmrg	  # Read the .lo file
5123d656433aSmrg	  func_source "$arg"
5124d656433aSmrg
5125d656433aSmrg	  if test -z "$pic_object" ||
5126d656433aSmrg	     test -z "$non_pic_object" ||
5127d656433aSmrg	     test "$pic_object" = none &&
5128d656433aSmrg	     test "$non_pic_object" = none; then
5129d656433aSmrg	    func_fatal_error "cannot find name of object for \`$arg'"
5130d656433aSmrg	  fi
5131d656433aSmrg
5132d656433aSmrg	  # Extract subdirectory from the argument.
5133d656433aSmrg	  func_dirname "$arg" "/" ""
5134d656433aSmrg	  xdir="$func_dirname_result"
5135d656433aSmrg
5136d656433aSmrg	  if test "$pic_object" != none; then
5137d656433aSmrg	    # Prepend the subdirectory the object is found in.
5138d656433aSmrg	    pic_object="$xdir$pic_object"
5139d656433aSmrg
5140d656433aSmrg	    if test "$prev" = dlfiles; then
5141d656433aSmrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5142d656433aSmrg		dlfiles="$dlfiles $pic_object"
5143d656433aSmrg		prev=
5144d656433aSmrg		continue
5145d656433aSmrg	      else
5146d656433aSmrg		# If libtool objects are unsupported, then we need to preload.
5147d656433aSmrg		prev=dlprefiles
5148d656433aSmrg	      fi
5149d656433aSmrg	    fi
5150d656433aSmrg
5151d656433aSmrg	    # CHECK ME:  I think I busted this.  -Ossama
5152d656433aSmrg	    if test "$prev" = dlprefiles; then
5153d656433aSmrg	      # Preload the old-style object.
5154d656433aSmrg	      dlprefiles="$dlprefiles $pic_object"
5155d656433aSmrg	      prev=
5156d656433aSmrg	    fi
5157d656433aSmrg
5158d656433aSmrg	    # A PIC object.
5159d656433aSmrg	    func_append libobjs " $pic_object"
5160d656433aSmrg	    arg="$pic_object"
5161d656433aSmrg	  fi
5162d656433aSmrg
5163d656433aSmrg	  # Non-PIC object.
5164d656433aSmrg	  if test "$non_pic_object" != none; then
5165d656433aSmrg	    # Prepend the subdirectory the object is found in.
5166d656433aSmrg	    non_pic_object="$xdir$non_pic_object"
5167d656433aSmrg
5168d656433aSmrg	    # A standard non-PIC object
5169d656433aSmrg	    func_append non_pic_objects " $non_pic_object"
5170d656433aSmrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
5171d656433aSmrg	      arg="$non_pic_object"
5172d656433aSmrg	    fi
5173d656433aSmrg	  else
5174d656433aSmrg	    # If the PIC object exists, use it instead.
5175d656433aSmrg	    # $xdir was prepended to $pic_object above.
5176d656433aSmrg	    non_pic_object="$pic_object"
5177d656433aSmrg	    func_append non_pic_objects " $non_pic_object"
5178d656433aSmrg	  fi
5179d656433aSmrg	else
5180d656433aSmrg	  # Only an error if not doing a dry-run.
5181d656433aSmrg	  if $opt_dry_run; then
5182d656433aSmrg	    # Extract subdirectory from the argument.
5183d656433aSmrg	    func_dirname "$arg" "/" ""
5184d656433aSmrg	    xdir="$func_dirname_result"
5185d656433aSmrg
5186d656433aSmrg	    func_lo2o "$arg"
5187d656433aSmrg	    pic_object=$xdir$objdir/$func_lo2o_result
5188d656433aSmrg	    non_pic_object=$xdir$func_lo2o_result
5189d656433aSmrg	    func_append libobjs " $pic_object"
5190d656433aSmrg	    func_append non_pic_objects " $non_pic_object"
5191d656433aSmrg	  else
5192d656433aSmrg	    func_fatal_error "\`$arg' is not a valid libtool object"
5193d656433aSmrg	  fi
5194d656433aSmrg	fi
5195d656433aSmrg	;;
5196d656433aSmrg
5197d656433aSmrg      *.$libext)
5198d656433aSmrg	# An archive.
5199d656433aSmrg	deplibs="$deplibs $arg"
5200d656433aSmrg	old_deplibs="$old_deplibs $arg"
5201d656433aSmrg	continue
5202d656433aSmrg	;;
5203d656433aSmrg
5204d656433aSmrg      *.la)
5205d656433aSmrg	# A libtool-controlled library.
5206d656433aSmrg
5207d656433aSmrg	if test "$prev" = dlfiles; then
5208d656433aSmrg	  # This library was specified with -dlopen.
5209d656433aSmrg	  dlfiles="$dlfiles $arg"
5210d656433aSmrg	  prev=
5211d656433aSmrg	elif test "$prev" = dlprefiles; then
5212d656433aSmrg	  # The library was specified with -dlpreopen.
5213d656433aSmrg	  dlprefiles="$dlprefiles $arg"
5214d656433aSmrg	  prev=
5215d656433aSmrg	else
5216d656433aSmrg	  deplibs="$deplibs $arg"
5217d656433aSmrg	fi
5218d656433aSmrg	continue
5219d656433aSmrg	;;
5220d656433aSmrg
5221d656433aSmrg      # Some other compiler argument.
5222d656433aSmrg      *)
5223d656433aSmrg	# Unknown arguments in both finalize_command and compile_command need
5224d656433aSmrg	# to be aesthetically quoted because they are evaled later.
5225d656433aSmrg	func_quote_for_eval "$arg"
5226d656433aSmrg	arg="$func_quote_for_eval_result"
5227d656433aSmrg	;;
5228d656433aSmrg      esac # arg
5229d656433aSmrg
5230d656433aSmrg      # Now actually substitute the argument into the commands.
5231d656433aSmrg      if test -n "$arg"; then
5232d656433aSmrg	func_append compile_command " $arg"
5233d656433aSmrg	func_append finalize_command " $arg"
5234d656433aSmrg      fi
5235d656433aSmrg    done # argument parsing loop
5236d656433aSmrg
5237d656433aSmrg    test -n "$prev" && \
5238d656433aSmrg      func_fatal_help "the \`$prevarg' option requires an argument"
5239d656433aSmrg
5240d656433aSmrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
5241d656433aSmrg      eval arg=\"$export_dynamic_flag_spec\"
5242d656433aSmrg      func_append compile_command " $arg"
5243d656433aSmrg      func_append finalize_command " $arg"
5244d656433aSmrg    fi
5245d656433aSmrg
5246d656433aSmrg    oldlibs=
5247d656433aSmrg    # calculate the name of the file, without its directory
5248d656433aSmrg    func_basename "$output"
5249d656433aSmrg    outputname="$func_basename_result"
5250d656433aSmrg    libobjs_save="$libobjs"
5251d656433aSmrg
5252d656433aSmrg    if test -n "$shlibpath_var"; then
5253d656433aSmrg      # get the directories listed in $shlibpath_var
5254555991fdSmrg      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
5255126a8a12Smrg    else
5256d656433aSmrg      shlib_search_path=
5257126a8a12Smrg    fi
5258d656433aSmrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
5259d656433aSmrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
5260126a8a12Smrg
5261d656433aSmrg    func_dirname "$output" "/" ""
5262d656433aSmrg    output_objdir="$func_dirname_result$objdir"
5263d656433aSmrg    # Create the object directory.
5264d656433aSmrg    func_mkdir_p "$output_objdir"
5265126a8a12Smrg
5266d656433aSmrg    # Determine the type of output
5267d656433aSmrg    case $output in
5268d656433aSmrg    "")
5269d656433aSmrg      func_fatal_help "you must specify an output file"
5270d656433aSmrg      ;;
5271d656433aSmrg    *.$libext) linkmode=oldlib ;;
5272d656433aSmrg    *.lo | *.$objext) linkmode=obj ;;
5273d656433aSmrg    *.la) linkmode=lib ;;
5274d656433aSmrg    *) linkmode=prog ;; # Anything else should be a program.
5275d656433aSmrg    esac
5276d656433aSmrg
5277d656433aSmrg    specialdeplibs=
5278d656433aSmrg
5279d656433aSmrg    libs=
5280d656433aSmrg    # Find all interdependent deplibs by searching for libraries
5281d656433aSmrg    # that are linked more than once (e.g. -la -lb -la)
5282d656433aSmrg    for deplib in $deplibs; do
5283d656433aSmrg      if $opt_duplicate_deps ; then
5284d656433aSmrg	case "$libs " in
5285d656433aSmrg	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
5286d656433aSmrg	esac
5287d656433aSmrg      fi
5288d656433aSmrg      libs="$libs $deplib"
5289d656433aSmrg    done
5290d656433aSmrg
5291d656433aSmrg    if test "$linkmode" = lib; then
5292d656433aSmrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
5293d656433aSmrg
5294d656433aSmrg      # Compute libraries that are listed more than once in $predeps
5295d656433aSmrg      # $postdeps and mark them as special (i.e., whose duplicates are
5296d656433aSmrg      # not to be eliminated).
5297d656433aSmrg      pre_post_deps=
5298d656433aSmrg      if $opt_duplicate_compiler_generated_deps; then
5299d656433aSmrg	for pre_post_dep in $predeps $postdeps; do
5300d656433aSmrg	  case "$pre_post_deps " in
5301d656433aSmrg	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
5302d656433aSmrg	  esac
5303d656433aSmrg	  pre_post_deps="$pre_post_deps $pre_post_dep"
5304d656433aSmrg	done
5305d656433aSmrg      fi
5306d656433aSmrg      pre_post_deps=
5307d656433aSmrg    fi
5308d656433aSmrg
5309d656433aSmrg    deplibs=
5310d656433aSmrg    newdependency_libs=
5311d656433aSmrg    newlib_search_path=
5312d656433aSmrg    need_relink=no # whether we're linking any uninstalled libtool libraries
5313d656433aSmrg    notinst_deplibs= # not-installed libtool libraries
5314d656433aSmrg    notinst_path= # paths that contain not-installed libtool libraries
5315d656433aSmrg
5316d656433aSmrg    case $linkmode in
5317d656433aSmrg    lib)
5318d656433aSmrg	passes="conv dlpreopen link"
5319d656433aSmrg	for file in $dlfiles $dlprefiles; do
5320d656433aSmrg	  case $file in
5321d656433aSmrg	  *.la) ;;
5322d656433aSmrg	  *)
5323d656433aSmrg	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
5324d656433aSmrg	    ;;
5325d656433aSmrg	  esac
5326d656433aSmrg	done
5327d656433aSmrg	;;
5328d656433aSmrg    prog)
5329d656433aSmrg	compile_deplibs=
5330d656433aSmrg	finalize_deplibs=
5331d656433aSmrg	alldeplibs=no
5332d656433aSmrg	newdlfiles=
5333d656433aSmrg	newdlprefiles=
5334d656433aSmrg	passes="conv scan dlopen dlpreopen link"
5335d656433aSmrg	;;
5336d656433aSmrg    *)  passes="conv"
5337d656433aSmrg	;;
5338d656433aSmrg    esac
5339d656433aSmrg
5340d656433aSmrg    for pass in $passes; do
5341d656433aSmrg      # The preopen pass in lib mode reverses $deplibs; put it back here
5342d656433aSmrg      # so that -L comes before libs that need it for instance...
5343d656433aSmrg      if test "$linkmode,$pass" = "lib,link"; then
5344d656433aSmrg	## FIXME: Find the place where the list is rebuilt in the wrong
5345d656433aSmrg	##        order, and fix it there properly
5346d656433aSmrg        tmp_deplibs=
5347d656433aSmrg	for deplib in $deplibs; do
5348d656433aSmrg	  tmp_deplibs="$deplib $tmp_deplibs"
5349d656433aSmrg	done
5350d656433aSmrg	deplibs="$tmp_deplibs"
5351d656433aSmrg      fi
5352d656433aSmrg
5353d656433aSmrg      if test "$linkmode,$pass" = "lib,link" ||
5354d656433aSmrg	 test "$linkmode,$pass" = "prog,scan"; then
5355d656433aSmrg	libs="$deplibs"
5356d656433aSmrg	deplibs=
5357d656433aSmrg      fi
5358d656433aSmrg      if test "$linkmode" = prog; then
5359d656433aSmrg	case $pass in
5360d656433aSmrg	dlopen) libs="$dlfiles" ;;
5361d656433aSmrg	dlpreopen) libs="$dlprefiles" ;;
5362d656433aSmrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
5363d656433aSmrg	esac
5364d656433aSmrg      fi
5365d656433aSmrg      if test "$linkmode,$pass" = "lib,dlpreopen"; then
5366d656433aSmrg	# Collect and forward deplibs of preopened libtool libs
5367d656433aSmrg	for lib in $dlprefiles; do
5368d656433aSmrg	  # Ignore non-libtool-libs
5369d656433aSmrg	  dependency_libs=
5370d656433aSmrg	  case $lib in
5371d656433aSmrg	  *.la)	func_source "$lib" ;;
5372d656433aSmrg	  esac
5373d656433aSmrg
5374d656433aSmrg	  # Collect preopened libtool deplibs, except any this library
5375d656433aSmrg	  # has declared as weak libs
5376d656433aSmrg	  for deplib in $dependency_libs; do
5377555991fdSmrg	    func_basename "$deplib"
5378555991fdSmrg            deplib_base=$func_basename_result
5379d656433aSmrg	    case " $weak_libs " in
5380d656433aSmrg	    *" $deplib_base "*) ;;
5381d656433aSmrg	    *) deplibs="$deplibs $deplib" ;;
5382d656433aSmrg	    esac
5383d656433aSmrg	  done
5384d656433aSmrg	done
5385d656433aSmrg	libs="$dlprefiles"
5386d656433aSmrg      fi
5387d656433aSmrg      if test "$pass" = dlopen; then
5388d656433aSmrg	# Collect dlpreopened libraries
5389d656433aSmrg	save_deplibs="$deplibs"
5390d656433aSmrg	deplibs=
5391d656433aSmrg      fi
5392d656433aSmrg
5393d656433aSmrg      for deplib in $libs; do
5394d656433aSmrg	lib=
5395d656433aSmrg	found=no
5396d656433aSmrg	case $deplib in
5397d656433aSmrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
5398d656433aSmrg	  if test "$linkmode,$pass" = "prog,link"; then
5399d656433aSmrg	    compile_deplibs="$deplib $compile_deplibs"
5400d656433aSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
5401d656433aSmrg	  else
5402d656433aSmrg	    compiler_flags="$compiler_flags $deplib"
5403d656433aSmrg	    if test "$linkmode" = lib ; then
5404d656433aSmrg		case "$new_inherited_linker_flags " in
5405d656433aSmrg		    *" $deplib "*) ;;
5406d656433aSmrg		    * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
5407d656433aSmrg		esac
5408d656433aSmrg	    fi
5409d656433aSmrg	  fi
5410d656433aSmrg	  continue
5411d656433aSmrg	  ;;
5412d656433aSmrg	-l*)
5413d656433aSmrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
5414d656433aSmrg	    func_warning "\`-l' is ignored for archives/objects"
5415d656433aSmrg	    continue
5416d656433aSmrg	  fi
5417d656433aSmrg	  func_stripname '-l' '' "$deplib"
5418d656433aSmrg	  name=$func_stripname_result
5419d656433aSmrg	  if test "$linkmode" = lib; then
5420d656433aSmrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
5421d656433aSmrg	  else
5422d656433aSmrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
5423d656433aSmrg	  fi
5424d656433aSmrg	  for searchdir in $searchdirs; do
5425d656433aSmrg	    for search_ext in .la $std_shrext .so .a; do
5426d656433aSmrg	      # Search the libtool library
5427d656433aSmrg	      lib="$searchdir/lib${name}${search_ext}"
5428d656433aSmrg	      if test -f "$lib"; then
5429d656433aSmrg		if test "$search_ext" = ".la"; then
5430d656433aSmrg		  found=yes
5431d656433aSmrg		else
5432d656433aSmrg		  found=no
5433d656433aSmrg		fi
5434d656433aSmrg		break 2
5435d656433aSmrg	      fi
5436d656433aSmrg	    done
5437d656433aSmrg	  done
5438d656433aSmrg	  if test "$found" != yes; then
5439d656433aSmrg	    # deplib doesn't seem to be a libtool library
5440d656433aSmrg	    if test "$linkmode,$pass" = "prog,link"; then
5441d656433aSmrg	      compile_deplibs="$deplib $compile_deplibs"
5442d656433aSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
5443d656433aSmrg	    else
5444d656433aSmrg	      deplibs="$deplib $deplibs"
5445d656433aSmrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
5446d656433aSmrg	    fi
5447d656433aSmrg	    continue
5448d656433aSmrg	  else # deplib is a libtool library
5449d656433aSmrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
5450d656433aSmrg	    # We need to do some special things here, and not later.
5451d656433aSmrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
5452d656433aSmrg	      case " $predeps $postdeps " in
5453d656433aSmrg	      *" $deplib "*)
5454d656433aSmrg		if func_lalib_p "$lib"; then
5455d656433aSmrg		  library_names=
5456d656433aSmrg		  old_library=
5457d656433aSmrg		  func_source "$lib"
5458d656433aSmrg		  for l in $old_library $library_names; do
5459d656433aSmrg		    ll="$l"
5460d656433aSmrg		  done
5461d656433aSmrg		  if test "X$ll" = "X$old_library" ; then # only static version available
5462d656433aSmrg		    found=no
5463d656433aSmrg		    func_dirname "$lib" "" "."
5464d656433aSmrg		    ladir="$func_dirname_result"
5465d656433aSmrg		    lib=$ladir/$old_library
5466d656433aSmrg		    if test "$linkmode,$pass" = "prog,link"; then
5467d656433aSmrg		      compile_deplibs="$deplib $compile_deplibs"
5468d656433aSmrg		      finalize_deplibs="$deplib $finalize_deplibs"
5469d656433aSmrg		    else
5470d656433aSmrg		      deplibs="$deplib $deplibs"
5471d656433aSmrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
5472d656433aSmrg		    fi
5473d656433aSmrg		    continue
5474d656433aSmrg		  fi
5475d656433aSmrg		fi
5476d656433aSmrg		;;
5477d656433aSmrg	      *) ;;
5478d656433aSmrg	      esac
5479d656433aSmrg	    fi
5480d656433aSmrg	  fi
5481d656433aSmrg	  ;; # -l
5482d656433aSmrg	*.ltframework)
5483d656433aSmrg	  if test "$linkmode,$pass" = "prog,link"; then
5484d656433aSmrg	    compile_deplibs="$deplib $compile_deplibs"
5485d656433aSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
5486d656433aSmrg	  else
5487d656433aSmrg	    deplibs="$deplib $deplibs"
5488d656433aSmrg	    if test "$linkmode" = lib ; then
5489d656433aSmrg		case "$new_inherited_linker_flags " in
5490d656433aSmrg		    *" $deplib "*) ;;
5491d656433aSmrg		    * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
5492d656433aSmrg		esac
5493d656433aSmrg	    fi
5494d656433aSmrg	  fi
5495d656433aSmrg	  continue
5496d656433aSmrg	  ;;
5497d656433aSmrg	-L*)
5498d656433aSmrg	  case $linkmode in
5499d656433aSmrg	  lib)
5500d656433aSmrg	    deplibs="$deplib $deplibs"
5501d656433aSmrg	    test "$pass" = conv && continue
5502d656433aSmrg	    newdependency_libs="$deplib $newdependency_libs"
5503d656433aSmrg	    func_stripname '-L' '' "$deplib"
5504d656433aSmrg	    newlib_search_path="$newlib_search_path $func_stripname_result"
5505d656433aSmrg	    ;;
5506d656433aSmrg	  prog)
5507d656433aSmrg	    if test "$pass" = conv; then
5508d656433aSmrg	      deplibs="$deplib $deplibs"
5509d656433aSmrg	      continue
5510d656433aSmrg	    fi
5511d656433aSmrg	    if test "$pass" = scan; then
5512d656433aSmrg	      deplibs="$deplib $deplibs"
5513d656433aSmrg	    else
5514d656433aSmrg	      compile_deplibs="$deplib $compile_deplibs"
5515d656433aSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
5516d656433aSmrg	    fi
5517d656433aSmrg	    func_stripname '-L' '' "$deplib"
5518d656433aSmrg	    newlib_search_path="$newlib_search_path $func_stripname_result"
5519d656433aSmrg	    ;;
5520d656433aSmrg	  *)
5521d656433aSmrg	    func_warning "\`-L' is ignored for archives/objects"
5522d656433aSmrg	    ;;
5523d656433aSmrg	  esac # linkmode
5524d656433aSmrg	  continue
5525d656433aSmrg	  ;; # -L
5526d656433aSmrg	-R*)
5527d656433aSmrg	  if test "$pass" = link; then
5528d656433aSmrg	    func_stripname '-R' '' "$deplib"
5529d656433aSmrg	    dir=$func_stripname_result
5530d656433aSmrg	    # Make sure the xrpath contains only unique directories.
5531d656433aSmrg	    case "$xrpath " in
5532d656433aSmrg	    *" $dir "*) ;;
5533d656433aSmrg	    *) xrpath="$xrpath $dir" ;;
5534d656433aSmrg	    esac
5535d656433aSmrg	  fi
5536d656433aSmrg	  deplibs="$deplib $deplibs"
5537d656433aSmrg	  continue
5538d656433aSmrg	  ;;
5539d656433aSmrg	*.la) lib="$deplib" ;;
5540d656433aSmrg	*.$libext)
5541d656433aSmrg	  if test "$pass" = conv; then
5542d656433aSmrg	    deplibs="$deplib $deplibs"
5543d656433aSmrg	    continue
5544d656433aSmrg	  fi
5545d656433aSmrg	  case $linkmode in
5546d656433aSmrg	  lib)
5547d656433aSmrg	    # Linking convenience modules into shared libraries is allowed,
5548d656433aSmrg	    # but linking other static libraries is non-portable.
5549d656433aSmrg	    case " $dlpreconveniencelibs " in
5550d656433aSmrg	    *" $deplib "*) ;;
5551d656433aSmrg	    *)
5552d656433aSmrg	      valid_a_lib=no
5553d656433aSmrg	      case $deplibs_check_method in
5554d656433aSmrg		match_pattern*)
5555d656433aSmrg		  set dummy $deplibs_check_method; shift
5556d656433aSmrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
5557555991fdSmrg		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
5558d656433aSmrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
5559d656433aSmrg		    valid_a_lib=yes
5560d656433aSmrg		  fi
5561d656433aSmrg		;;
5562d656433aSmrg		pass_all)
5563d656433aSmrg		  valid_a_lib=yes
5564d656433aSmrg		;;
5565d656433aSmrg	      esac
5566d656433aSmrg	      if test "$valid_a_lib" != yes; then
5567555991fdSmrg		echo
5568d656433aSmrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
5569555991fdSmrg		echo "*** I have the capability to make that library automatically link in when"
5570555991fdSmrg		echo "*** you link to this library.  But I can only do this if you have a"
5571555991fdSmrg		echo "*** shared version of the library, which you do not appear to have"
5572555991fdSmrg		echo "*** because the file extensions .$libext of this argument makes me believe"
5573555991fdSmrg		echo "*** that it is just a static archive that I should not use here."
5574d656433aSmrg	      else
5575555991fdSmrg		echo
5576d656433aSmrg		$ECHO "*** Warning: Linking the shared library $output against the"
5577d656433aSmrg		$ECHO "*** static library $deplib is not portable!"
5578d656433aSmrg		deplibs="$deplib $deplibs"
5579d656433aSmrg	      fi
5580d656433aSmrg	      ;;
5581d656433aSmrg	    esac
5582d656433aSmrg	    continue
5583d656433aSmrg	    ;;
5584d656433aSmrg	  prog)
5585d656433aSmrg	    if test "$pass" != link; then
5586d656433aSmrg	      deplibs="$deplib $deplibs"
5587d656433aSmrg	    else
5588d656433aSmrg	      compile_deplibs="$deplib $compile_deplibs"
5589d656433aSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
5590d656433aSmrg	    fi
5591d656433aSmrg	    continue
5592d656433aSmrg	    ;;
5593d656433aSmrg	  esac # linkmode
5594d656433aSmrg	  ;; # *.$libext
5595d656433aSmrg	*.lo | *.$objext)
5596d656433aSmrg	  if test "$pass" = conv; then
5597d656433aSmrg	    deplibs="$deplib $deplibs"
5598d656433aSmrg	  elif test "$linkmode" = prog; then
5599d656433aSmrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
5600d656433aSmrg	      # If there is no dlopen support or we're linking statically,
5601d656433aSmrg	      # we need to preload.
5602d656433aSmrg	      newdlprefiles="$newdlprefiles $deplib"
5603d656433aSmrg	      compile_deplibs="$deplib $compile_deplibs"
5604d656433aSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
5605d656433aSmrg	    else
5606d656433aSmrg	      newdlfiles="$newdlfiles $deplib"
5607d656433aSmrg	    fi
5608d656433aSmrg	  fi
5609d656433aSmrg	  continue
5610d656433aSmrg	  ;;
5611d656433aSmrg	%DEPLIBS%)
5612d656433aSmrg	  alldeplibs=yes
5613d656433aSmrg	  continue
5614d656433aSmrg	  ;;
5615d656433aSmrg	esac # case $deplib
5616d656433aSmrg
5617d656433aSmrg	if test "$found" = yes || test -f "$lib"; then :
5618d656433aSmrg	else
5619d656433aSmrg	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
5620d656433aSmrg	fi
5621d656433aSmrg
5622d656433aSmrg	# Check to see that this really is a libtool archive.
5623d656433aSmrg	func_lalib_unsafe_p "$lib" \
5624d656433aSmrg	  || func_fatal_error "\`$lib' is not a valid libtool archive"
5625d656433aSmrg
5626d656433aSmrg	func_dirname "$lib" "" "."
5627d656433aSmrg	ladir="$func_dirname_result"
5628d656433aSmrg
5629d656433aSmrg	dlname=
5630d656433aSmrg	dlopen=
5631d656433aSmrg	dlpreopen=
5632d656433aSmrg	libdir=
5633d656433aSmrg	library_names=
5634d656433aSmrg	old_library=
5635d656433aSmrg	inherited_linker_flags=
5636d656433aSmrg	# If the library was installed with an old release of libtool,
5637d656433aSmrg	# it will not redefine variables installed, or shouldnotlink
5638d656433aSmrg	installed=yes
5639d656433aSmrg	shouldnotlink=no
5640d656433aSmrg	avoidtemprpath=
5641d656433aSmrg
5642d656433aSmrg
5643d656433aSmrg	# Read the .la file
5644d656433aSmrg	func_source "$lib"
5645d656433aSmrg
5646d656433aSmrg	# Convert "-framework foo" to "foo.ltframework"
5647d656433aSmrg	if test -n "$inherited_linker_flags"; then
5648555991fdSmrg	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
5649d656433aSmrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
5650d656433aSmrg	    case " $new_inherited_linker_flags " in
5651d656433aSmrg	      *" $tmp_inherited_linker_flag "*) ;;
5652d656433aSmrg	      *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";;
5653d656433aSmrg	    esac
5654d656433aSmrg	  done
5655d656433aSmrg	fi
5656555991fdSmrg	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
5657d656433aSmrg	if test "$linkmode,$pass" = "lib,link" ||
5658d656433aSmrg	   test "$linkmode,$pass" = "prog,scan" ||
5659d656433aSmrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
5660d656433aSmrg	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
5661d656433aSmrg	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
5662d656433aSmrg	fi
5663d656433aSmrg
5664d656433aSmrg	if test "$pass" = conv; then
5665d656433aSmrg	  # Only check for convenience libraries
5666d656433aSmrg	  deplibs="$lib $deplibs"
5667d656433aSmrg	  if test -z "$libdir"; then
5668d656433aSmrg	    if test -z "$old_library"; then
5669d656433aSmrg	      func_fatal_error "cannot find name of link library for \`$lib'"
5670d656433aSmrg	    fi
5671d656433aSmrg	    # It is a libtool convenience library, so add in its objects.
5672d656433aSmrg	    convenience="$convenience $ladir/$objdir/$old_library"
5673d656433aSmrg	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
5674d656433aSmrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
5675d656433aSmrg	    func_fatal_error "\`$lib' is not a convenience library"
5676d656433aSmrg	  fi
5677d656433aSmrg	  tmp_libs=
5678d656433aSmrg	  for deplib in $dependency_libs; do
5679d656433aSmrg	    deplibs="$deplib $deplibs"
5680d656433aSmrg	    if $opt_duplicate_deps ; then
5681d656433aSmrg	      case "$tmp_libs " in
5682d656433aSmrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
5683d656433aSmrg	      esac
5684d656433aSmrg	    fi
5685d656433aSmrg	    tmp_libs="$tmp_libs $deplib"
5686d656433aSmrg	  done
5687d656433aSmrg	  continue
5688d656433aSmrg	fi # $pass = conv
5689d656433aSmrg
5690d656433aSmrg
5691d656433aSmrg	# Get the name of the library we link against.
5692d656433aSmrg	linklib=
5693d656433aSmrg	for l in $old_library $library_names; do
5694d656433aSmrg	  linklib="$l"
5695d656433aSmrg	done
5696d656433aSmrg	if test -z "$linklib"; then
5697d656433aSmrg	  func_fatal_error "cannot find name of link library for \`$lib'"
5698d656433aSmrg	fi
5699d656433aSmrg
5700d656433aSmrg	# This library was specified with -dlopen.
5701d656433aSmrg	if test "$pass" = dlopen; then
5702d656433aSmrg	  if test -z "$libdir"; then
5703d656433aSmrg	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
5704d656433aSmrg	  fi
5705d656433aSmrg	  if test -z "$dlname" ||
5706d656433aSmrg	     test "$dlopen_support" != yes ||
5707d656433aSmrg	     test "$build_libtool_libs" = no; then
5708d656433aSmrg	    # If there is no dlname, no dlopen support or we're linking
5709d656433aSmrg	    # statically, we need to preload.  We also need to preload any
5710d656433aSmrg	    # dependent libraries so libltdl's deplib preloader doesn't
5711d656433aSmrg	    # bomb out in the load deplibs phase.
5712d656433aSmrg	    dlprefiles="$dlprefiles $lib $dependency_libs"
5713d656433aSmrg	  else
5714d656433aSmrg	    newdlfiles="$newdlfiles $lib"
5715d656433aSmrg	  fi
5716d656433aSmrg	  continue
5717d656433aSmrg	fi # $pass = dlopen
5718d656433aSmrg
5719d656433aSmrg	# We need an absolute path.
5720d656433aSmrg	case $ladir in
5721d656433aSmrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
5722d656433aSmrg	*)
5723d656433aSmrg	  abs_ladir=`cd "$ladir" && pwd`
5724d656433aSmrg	  if test -z "$abs_ladir"; then
5725d656433aSmrg	    func_warning "cannot determine absolute directory name of \`$ladir'"
5726d656433aSmrg	    func_warning "passing it literally to the linker, although it might fail"
5727d656433aSmrg	    abs_ladir="$ladir"
5728d656433aSmrg	  fi
5729d656433aSmrg	  ;;
5730d656433aSmrg	esac
5731d656433aSmrg	func_basename "$lib"
5732d656433aSmrg	laname="$func_basename_result"
5733d656433aSmrg
5734d656433aSmrg	# Find the relevant object directory and library name.
5735d656433aSmrg	if test "X$installed" = Xyes; then
5736d656433aSmrg	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
5737d656433aSmrg	    func_warning "library \`$lib' was moved."
5738d656433aSmrg	    dir="$ladir"
5739d656433aSmrg	    absdir="$abs_ladir"
5740d656433aSmrg	    libdir="$abs_ladir"
5741d656433aSmrg	  else
5742d656433aSmrg	    dir="$libdir"
5743d656433aSmrg	    absdir="$libdir"
5744d656433aSmrg	  fi
5745d656433aSmrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
5746d656433aSmrg	else
5747d656433aSmrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
5748d656433aSmrg	    dir="$ladir"
5749d656433aSmrg	    absdir="$abs_ladir"
5750d656433aSmrg	    # Remove this search path later
5751d656433aSmrg	    notinst_path="$notinst_path $abs_ladir"
5752d656433aSmrg	  else
5753d656433aSmrg	    dir="$ladir/$objdir"
5754d656433aSmrg	    absdir="$abs_ladir/$objdir"
5755d656433aSmrg	    # Remove this search path later
5756d656433aSmrg	    notinst_path="$notinst_path $abs_ladir"
5757d656433aSmrg	  fi
5758d656433aSmrg	fi # $installed = yes
5759d656433aSmrg	func_stripname 'lib' '.la' "$laname"
5760d656433aSmrg	name=$func_stripname_result
5761d656433aSmrg
5762d656433aSmrg	# This library was specified with -dlpreopen.
5763d656433aSmrg	if test "$pass" = dlpreopen; then
5764d656433aSmrg	  if test -z "$libdir" && test "$linkmode" = prog; then
5765d656433aSmrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
5766d656433aSmrg	  fi
5767d656433aSmrg	  # Prefer using a static library (so that no silly _DYNAMIC symbols
5768d656433aSmrg	  # are required to link).
5769d656433aSmrg	  if test -n "$old_library"; then
5770d656433aSmrg	    newdlprefiles="$newdlprefiles $dir/$old_library"
5771d656433aSmrg	    # Keep a list of preopened convenience libraries to check
5772d656433aSmrg	    # that they are being used correctly in the link pass.
5773d656433aSmrg	    test -z "$libdir" && \
5774d656433aSmrg		dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library"
5775d656433aSmrg	  # Otherwise, use the dlname, so that lt_dlopen finds it.
5776d656433aSmrg	  elif test -n "$dlname"; then
5777d656433aSmrg	    newdlprefiles="$newdlprefiles $dir/$dlname"
5778d656433aSmrg	  else
5779d656433aSmrg	    newdlprefiles="$newdlprefiles $dir/$linklib"
5780d656433aSmrg	  fi
5781d656433aSmrg	fi # $pass = dlpreopen
5782d656433aSmrg
5783d656433aSmrg	if test -z "$libdir"; then
5784d656433aSmrg	  # Link the convenience library
5785d656433aSmrg	  if test "$linkmode" = lib; then
5786d656433aSmrg	    deplibs="$dir/$old_library $deplibs"
5787d656433aSmrg	  elif test "$linkmode,$pass" = "prog,link"; then
5788d656433aSmrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
5789d656433aSmrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
5790d656433aSmrg	  else
5791d656433aSmrg	    deplibs="$lib $deplibs" # used for prog,scan pass
5792d656433aSmrg	  fi
5793d656433aSmrg	  continue
5794d656433aSmrg	fi
5795d656433aSmrg
5796d656433aSmrg
5797d656433aSmrg	if test "$linkmode" = prog && test "$pass" != link; then
5798d656433aSmrg	  newlib_search_path="$newlib_search_path $ladir"
5799d656433aSmrg	  deplibs="$lib $deplibs"
5800d656433aSmrg
5801d656433aSmrg	  linkalldeplibs=no
5802d656433aSmrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
5803d656433aSmrg	     test "$build_libtool_libs" = no; then
5804d656433aSmrg	    linkalldeplibs=yes
5805d656433aSmrg	  fi
5806d656433aSmrg
5807d656433aSmrg	  tmp_libs=
5808d656433aSmrg	  for deplib in $dependency_libs; do
5809d656433aSmrg	    case $deplib in
5810d656433aSmrg	    -L*) func_stripname '-L' '' "$deplib"
5811d656433aSmrg	         newlib_search_path="$newlib_search_path $func_stripname_result"
5812d656433aSmrg		 ;;
5813d656433aSmrg	    esac
5814d656433aSmrg	    # Need to link against all dependency_libs?
5815d656433aSmrg	    if test "$linkalldeplibs" = yes; then
5816d656433aSmrg	      deplibs="$deplib $deplibs"
5817d656433aSmrg	    else
5818d656433aSmrg	      # Need to hardcode shared library paths
5819d656433aSmrg	      # or/and link against static libraries
5820d656433aSmrg	      newdependency_libs="$deplib $newdependency_libs"
5821d656433aSmrg	    fi
5822d656433aSmrg	    if $opt_duplicate_deps ; then
5823d656433aSmrg	      case "$tmp_libs " in
5824d656433aSmrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
5825d656433aSmrg	      esac
5826d656433aSmrg	    fi
5827d656433aSmrg	    tmp_libs="$tmp_libs $deplib"
5828d656433aSmrg	  done # for deplib
5829d656433aSmrg	  continue
5830d656433aSmrg	fi # $linkmode = prog...
5831d656433aSmrg
5832d656433aSmrg	if test "$linkmode,$pass" = "prog,link"; then
5833d656433aSmrg	  if test -n "$library_names" &&
5834d656433aSmrg	     { { test "$prefer_static_libs" = no ||
5835d656433aSmrg	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
5836d656433aSmrg	       test -z "$old_library"; }; then
5837d656433aSmrg	    # We need to hardcode the library path
5838d656433aSmrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
5839d656433aSmrg	      # Make sure the rpath contains only unique directories.
5840d656433aSmrg	      case "$temp_rpath:" in
5841d656433aSmrg	      *"$absdir:"*) ;;
5842d656433aSmrg	      *) temp_rpath="$temp_rpath$absdir:" ;;
5843d656433aSmrg	      esac
5844d656433aSmrg	    fi
5845d656433aSmrg
5846d656433aSmrg	    # Hardcode the library path.
5847d656433aSmrg	    # Skip directories that are in the system default run-time
5848d656433aSmrg	    # search path.
5849d656433aSmrg	    case " $sys_lib_dlsearch_path " in
5850d656433aSmrg	    *" $absdir "*) ;;
5851d656433aSmrg	    *)
5852d656433aSmrg	      case "$compile_rpath " in
5853d656433aSmrg	      *" $absdir "*) ;;
5854d656433aSmrg	      *) compile_rpath="$compile_rpath $absdir"
5855d656433aSmrg	      esac
5856d656433aSmrg	      ;;
5857d656433aSmrg	    esac
5858d656433aSmrg	    case " $sys_lib_dlsearch_path " in
5859d656433aSmrg	    *" $libdir "*) ;;
5860d656433aSmrg	    *)
5861d656433aSmrg	      case "$finalize_rpath " in
5862d656433aSmrg	      *" $libdir "*) ;;
5863d656433aSmrg	      *) finalize_rpath="$finalize_rpath $libdir"
5864d656433aSmrg	      esac
5865d656433aSmrg	      ;;
5866d656433aSmrg	    esac
5867d656433aSmrg	  fi # $linkmode,$pass = prog,link...
5868d656433aSmrg
5869d656433aSmrg	  if test "$alldeplibs" = yes &&
5870d656433aSmrg	     { test "$deplibs_check_method" = pass_all ||
5871d656433aSmrg	       { test "$build_libtool_libs" = yes &&
5872d656433aSmrg		 test -n "$library_names"; }; }; then
5873d656433aSmrg	    # We only need to search for static libraries
5874d656433aSmrg	    continue
5875d656433aSmrg	  fi
5876d656433aSmrg	fi
5877d656433aSmrg
5878d656433aSmrg	link_static=no # Whether the deplib will be linked statically
5879d656433aSmrg	use_static_libs=$prefer_static_libs
5880d656433aSmrg	if test "$use_static_libs" = built && test "$installed" = yes; then
5881d656433aSmrg	  use_static_libs=no
5882d656433aSmrg	fi
5883d656433aSmrg	if test -n "$library_names" &&
5884d656433aSmrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
5885d656433aSmrg	  case $host in
5886d656433aSmrg	  *cygwin* | *mingw* | *cegcc*)
5887d656433aSmrg	      # No point in relinking DLLs because paths are not encoded
5888d656433aSmrg	      notinst_deplibs="$notinst_deplibs $lib"
5889d656433aSmrg	      need_relink=no
5890d656433aSmrg	    ;;
5891d656433aSmrg	  *)
5892d656433aSmrg	    if test "$installed" = no; then
5893d656433aSmrg	      notinst_deplibs="$notinst_deplibs $lib"
5894d656433aSmrg	      need_relink=yes
5895d656433aSmrg	    fi
5896d656433aSmrg	    ;;
5897d656433aSmrg	  esac
5898d656433aSmrg	  # This is a shared library
5899d656433aSmrg
5900d656433aSmrg	  # Warn about portability, can't link against -module's on some
5901d656433aSmrg	  # systems (darwin).  Don't bleat about dlopened modules though!
5902d656433aSmrg	  dlopenmodule=""
5903d656433aSmrg	  for dlpremoduletest in $dlprefiles; do
5904d656433aSmrg	    if test "X$dlpremoduletest" = "X$lib"; then
5905d656433aSmrg	      dlopenmodule="$dlpremoduletest"
5906d656433aSmrg	      break
5907d656433aSmrg	    fi
5908d656433aSmrg	  done
5909d656433aSmrg	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
5910555991fdSmrg	    echo
5911d656433aSmrg	    if test "$linkmode" = prog; then
5912d656433aSmrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
5913d656433aSmrg	    else
5914d656433aSmrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
5915d656433aSmrg	    fi
5916d656433aSmrg	    $ECHO "*** $linklib is not portable!"
5917d656433aSmrg	  fi
5918d656433aSmrg	  if test "$linkmode" = lib &&
5919d656433aSmrg	     test "$hardcode_into_libs" = yes; then
5920d656433aSmrg	    # Hardcode the library path.
5921d656433aSmrg	    # Skip directories that are in the system default run-time
5922d656433aSmrg	    # search path.
5923d656433aSmrg	    case " $sys_lib_dlsearch_path " in
5924d656433aSmrg	    *" $absdir "*) ;;
5925d656433aSmrg	    *)
5926d656433aSmrg	      case "$compile_rpath " in
5927d656433aSmrg	      *" $absdir "*) ;;
5928d656433aSmrg	      *) compile_rpath="$compile_rpath $absdir"
5929d656433aSmrg	      esac
5930d656433aSmrg	      ;;
5931d656433aSmrg	    esac
5932d656433aSmrg	    case " $sys_lib_dlsearch_path " in
5933d656433aSmrg	    *" $libdir "*) ;;
5934d656433aSmrg	    *)
5935d656433aSmrg	      case "$finalize_rpath " in
5936d656433aSmrg	      *" $libdir "*) ;;
5937d656433aSmrg	      *) finalize_rpath="$finalize_rpath $libdir"
5938d656433aSmrg	      esac
5939d656433aSmrg	      ;;
5940d656433aSmrg	    esac
5941d656433aSmrg	  fi
5942d656433aSmrg
5943d656433aSmrg	  if test -n "$old_archive_from_expsyms_cmds"; then
5944d656433aSmrg	    # figure out the soname
5945d656433aSmrg	    set dummy $library_names
5946d656433aSmrg	    shift
5947d656433aSmrg	    realname="$1"
5948d656433aSmrg	    shift
5949d656433aSmrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
5950d656433aSmrg	    # use dlname if we got it. it's perfectly good, no?
5951d656433aSmrg	    if test -n "$dlname"; then
5952d656433aSmrg	      soname="$dlname"
5953d656433aSmrg	    elif test -n "$soname_spec"; then
5954d656433aSmrg	      # bleh windows
5955d656433aSmrg	      case $host in
5956d656433aSmrg	      *cygwin* | mingw* | *cegcc*)
5957d656433aSmrg	        func_arith $current - $age
5958d656433aSmrg		major=$func_arith_result
5959d656433aSmrg		versuffix="-$major"
5960d656433aSmrg		;;
5961d656433aSmrg	      esac
5962d656433aSmrg	      eval soname=\"$soname_spec\"
5963d656433aSmrg	    else
5964d656433aSmrg	      soname="$realname"
5965d656433aSmrg	    fi
5966d656433aSmrg
5967d656433aSmrg	    # Make a new name for the extract_expsyms_cmds to use
5968d656433aSmrg	    soroot="$soname"
5969d656433aSmrg	    func_basename "$soroot"
5970d656433aSmrg	    soname="$func_basename_result"
5971d656433aSmrg	    func_stripname 'lib' '.dll' "$soname"
5972d656433aSmrg	    newlib=libimp-$func_stripname_result.a
5973d656433aSmrg
5974d656433aSmrg	    # If the library has no export list, then create one now
5975d656433aSmrg	    if test -f "$output_objdir/$soname-def"; then :
5976d656433aSmrg	    else
5977d656433aSmrg	      func_verbose "extracting exported symbol list from \`$soname'"
5978d656433aSmrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
5979d656433aSmrg	    fi
5980d656433aSmrg
5981d656433aSmrg	    # Create $newlib
5982d656433aSmrg	    if test -f "$output_objdir/$newlib"; then :; else
5983d656433aSmrg	      func_verbose "generating import library for \`$soname'"
5984d656433aSmrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
5985d656433aSmrg	    fi
5986d656433aSmrg	    # make sure the library variables are pointing to the new library
5987d656433aSmrg	    dir=$output_objdir
5988d656433aSmrg	    linklib=$newlib
5989d656433aSmrg	  fi # test -n "$old_archive_from_expsyms_cmds"
5990d656433aSmrg
5991d656433aSmrg	  if test "$linkmode" = prog || test "$mode" != relink; then
5992d656433aSmrg	    add_shlibpath=
5993d656433aSmrg	    add_dir=
5994d656433aSmrg	    add=
5995d656433aSmrg	    lib_linked=yes
5996d656433aSmrg	    case $hardcode_action in
5997d656433aSmrg	    immediate | unsupported)
5998d656433aSmrg	      if test "$hardcode_direct" = no; then
5999d656433aSmrg		add="$dir/$linklib"
6000d656433aSmrg		case $host in
6001d656433aSmrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
6002d656433aSmrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
6003d656433aSmrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
6004d656433aSmrg		    *-*-unixware7*) add_dir="-L$dir" ;;
6005d656433aSmrg		  *-*-darwin* )
6006d656433aSmrg		    # if the lib is a (non-dlopened) module then we can not
6007d656433aSmrg		    # link against it, someone is ignoring the earlier warnings
6008d656433aSmrg		    if /usr/bin/file -L $add 2> /dev/null |
6009d656433aSmrg			 $GREP ": [^:]* bundle" >/dev/null ; then
6010d656433aSmrg		      if test "X$dlopenmodule" != "X$lib"; then
6011d656433aSmrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
6012d656433aSmrg			if test -z "$old_library" ; then
6013555991fdSmrg			  echo
6014555991fdSmrg			  echo "*** And there doesn't seem to be a static archive available"
6015555991fdSmrg			  echo "*** The link will probably fail, sorry"
6016d656433aSmrg			else
6017d656433aSmrg			  add="$dir/$old_library"
6018d656433aSmrg			fi
6019d656433aSmrg		      elif test -n "$old_library"; then
6020d656433aSmrg			add="$dir/$old_library"
6021d656433aSmrg		      fi
6022d656433aSmrg		    fi
6023d656433aSmrg		esac
6024d656433aSmrg	      elif test "$hardcode_minus_L" = no; then
6025d656433aSmrg		case $host in
6026d656433aSmrg		*-*-sunos*) add_shlibpath="$dir" ;;
6027d656433aSmrg		esac
6028d656433aSmrg		add_dir="-L$dir"
6029d656433aSmrg		add="-l$name"
6030d656433aSmrg	      elif test "$hardcode_shlibpath_var" = no; then
6031d656433aSmrg		add_shlibpath="$dir"
6032d656433aSmrg		add="-l$name"
6033d656433aSmrg	      else
6034d656433aSmrg		lib_linked=no
6035d656433aSmrg	      fi
6036d656433aSmrg	      ;;
6037d656433aSmrg	    relink)
6038d656433aSmrg	      if test "$hardcode_direct" = yes &&
6039d656433aSmrg	         test "$hardcode_direct_absolute" = no; then
6040d656433aSmrg		add="$dir/$linklib"
6041d656433aSmrg	      elif test "$hardcode_minus_L" = yes; then
6042d656433aSmrg		add_dir="-L$dir"
6043d656433aSmrg		# Try looking first in the location we're being installed to.
6044d656433aSmrg		if test -n "$inst_prefix_dir"; then
6045d656433aSmrg		  case $libdir in
6046d656433aSmrg		    [\\/]*)
6047d656433aSmrg		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
6048d656433aSmrg		      ;;
6049d656433aSmrg		  esac
6050d656433aSmrg		fi
6051d656433aSmrg		add="-l$name"
6052d656433aSmrg	      elif test "$hardcode_shlibpath_var" = yes; then
6053d656433aSmrg		add_shlibpath="$dir"
6054d656433aSmrg		add="-l$name"
6055d656433aSmrg	      else
6056d656433aSmrg		lib_linked=no
6057d656433aSmrg	      fi
6058d656433aSmrg	      ;;
6059d656433aSmrg	    *) lib_linked=no ;;
6060d656433aSmrg	    esac
6061d656433aSmrg
6062d656433aSmrg	    if test "$lib_linked" != yes; then
6063d656433aSmrg	      func_fatal_configuration "unsupported hardcode properties"
6064d656433aSmrg	    fi
6065d656433aSmrg
6066d656433aSmrg	    if test -n "$add_shlibpath"; then
6067d656433aSmrg	      case :$compile_shlibpath: in
6068d656433aSmrg	      *":$add_shlibpath:"*) ;;
6069d656433aSmrg	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
6070d656433aSmrg	      esac
6071d656433aSmrg	    fi
6072d656433aSmrg	    if test "$linkmode" = prog; then
6073d656433aSmrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
6074d656433aSmrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
6075d656433aSmrg	    else
6076d656433aSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
6077d656433aSmrg	      test -n "$add" && deplibs="$add $deplibs"
6078d656433aSmrg	      if test "$hardcode_direct" != yes &&
6079d656433aSmrg		 test "$hardcode_minus_L" != yes &&
6080d656433aSmrg		 test "$hardcode_shlibpath_var" = yes; then
6081d656433aSmrg		case :$finalize_shlibpath: in
6082d656433aSmrg		*":$libdir:"*) ;;
6083d656433aSmrg		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
6084d656433aSmrg		esac
6085d656433aSmrg	      fi
6086d656433aSmrg	    fi
6087d656433aSmrg	  fi
6088d656433aSmrg
6089d656433aSmrg	  if test "$linkmode" = prog || test "$mode" = relink; then
6090d656433aSmrg	    add_shlibpath=
6091d656433aSmrg	    add_dir=
6092d656433aSmrg	    add=
6093d656433aSmrg	    # Finalize command for both is simple: just hardcode it.
6094d656433aSmrg	    if test "$hardcode_direct" = yes &&
6095d656433aSmrg	       test "$hardcode_direct_absolute" = no; then
6096d656433aSmrg	      add="$libdir/$linklib"
6097d656433aSmrg	    elif test "$hardcode_minus_L" = yes; then
6098d656433aSmrg	      add_dir="-L$libdir"
6099d656433aSmrg	      add="-l$name"
6100d656433aSmrg	    elif test "$hardcode_shlibpath_var" = yes; then
6101d656433aSmrg	      case :$finalize_shlibpath: in
6102d656433aSmrg	      *":$libdir:"*) ;;
6103d656433aSmrg	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
6104d656433aSmrg	      esac
6105d656433aSmrg	      add="-l$name"
6106d656433aSmrg	    elif test "$hardcode_automatic" = yes; then
6107d656433aSmrg	      if test -n "$inst_prefix_dir" &&
6108d656433aSmrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
6109d656433aSmrg		add="$inst_prefix_dir$libdir/$linklib"
6110d656433aSmrg	      else
6111d656433aSmrg		add="$libdir/$linklib"
6112d656433aSmrg	      fi
6113d656433aSmrg	    else
6114d656433aSmrg	      # We cannot seem to hardcode it, guess we'll fake it.
6115d656433aSmrg	      add_dir="-L$libdir"
6116d656433aSmrg	      # Try looking first in the location we're being installed to.
6117d656433aSmrg	      if test -n "$inst_prefix_dir"; then
6118d656433aSmrg		case $libdir in
6119d656433aSmrg		  [\\/]*)
6120d656433aSmrg		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
6121d656433aSmrg		    ;;
6122d656433aSmrg		esac
6123d656433aSmrg	      fi
6124d656433aSmrg	      add="-l$name"
6125d656433aSmrg	    fi
6126d656433aSmrg
6127d656433aSmrg	    if test "$linkmode" = prog; then
6128d656433aSmrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
6129d656433aSmrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
6130d656433aSmrg	    else
6131d656433aSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
6132d656433aSmrg	      test -n "$add" && deplibs="$add $deplibs"
6133d656433aSmrg	    fi
6134d656433aSmrg	  fi
6135d656433aSmrg	elif test "$linkmode" = prog; then
6136d656433aSmrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
6137d656433aSmrg	  # is not unsupported.  This is valid on all known static and
6138d656433aSmrg	  # shared platforms.
6139d656433aSmrg	  if test "$hardcode_direct" != unsupported; then
6140d656433aSmrg	    test -n "$old_library" && linklib="$old_library"
6141d656433aSmrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
6142d656433aSmrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
6143d656433aSmrg	  else
6144d656433aSmrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
6145d656433aSmrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
6146d656433aSmrg	  fi
6147d656433aSmrg	elif test "$build_libtool_libs" = yes; then
6148d656433aSmrg	  # Not a shared library
6149d656433aSmrg	  if test "$deplibs_check_method" != pass_all; then
6150d656433aSmrg	    # We're trying link a shared library against a static one
6151d656433aSmrg	    # but the system doesn't support it.
6152d656433aSmrg
6153d656433aSmrg	    # Just print a warning and add the library to dependency_libs so
6154d656433aSmrg	    # that the program can be linked against the static library.
6155555991fdSmrg	    echo
6156d656433aSmrg	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
6157555991fdSmrg	    echo "*** I have the capability to make that library automatically link in when"
6158555991fdSmrg	    echo "*** you link to this library.  But I can only do this if you have a"
6159555991fdSmrg	    echo "*** shared version of the library, which you do not appear to have."
6160d656433aSmrg	    if test "$module" = yes; then
6161555991fdSmrg	      echo "*** But as you try to build a module library, libtool will still create "
6162555991fdSmrg	      echo "*** a static module, that should work as long as the dlopening application"
6163555991fdSmrg	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
6164d656433aSmrg	      if test -z "$global_symbol_pipe"; then
6165555991fdSmrg		echo
6166555991fdSmrg		echo "*** However, this would only work if libtool was able to extract symbol"
6167555991fdSmrg		echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
6168555991fdSmrg		echo "*** not find such a program.  So, this module is probably useless."
6169555991fdSmrg		echo "*** \`nm' from GNU binutils and a full rebuild may help."
6170d656433aSmrg	      fi
6171d656433aSmrg	      if test "$build_old_libs" = no; then
6172d656433aSmrg		build_libtool_libs=module
6173d656433aSmrg		build_old_libs=yes
6174d656433aSmrg	      else
6175d656433aSmrg		build_libtool_libs=no
6176d656433aSmrg	      fi
6177d656433aSmrg	    fi
6178d656433aSmrg	  else
6179d656433aSmrg	    deplibs="$dir/$old_library $deplibs"
6180d656433aSmrg	    link_static=yes
6181d656433aSmrg	  fi
6182d656433aSmrg	fi # link shared/static library?
6183d656433aSmrg
6184d656433aSmrg	if test "$linkmode" = lib; then
6185d656433aSmrg	  if test -n "$dependency_libs" &&
6186d656433aSmrg	     { test "$hardcode_into_libs" != yes ||
6187d656433aSmrg	       test "$build_old_libs" = yes ||
6188d656433aSmrg	       test "$link_static" = yes; }; then
6189d656433aSmrg	    # Extract -R from dependency_libs
6190d656433aSmrg	    temp_deplibs=
6191d656433aSmrg	    for libdir in $dependency_libs; do
6192d656433aSmrg	      case $libdir in
6193d656433aSmrg	      -R*) func_stripname '-R' '' "$libdir"
6194d656433aSmrg	           temp_xrpath=$func_stripname_result
6195d656433aSmrg		   case " $xrpath " in
6196d656433aSmrg		   *" $temp_xrpath "*) ;;
6197d656433aSmrg		   *) xrpath="$xrpath $temp_xrpath";;
6198d656433aSmrg		   esac;;
6199d656433aSmrg	      *) temp_deplibs="$temp_deplibs $libdir";;
6200d656433aSmrg	      esac
6201d656433aSmrg	    done
6202d656433aSmrg	    dependency_libs="$temp_deplibs"
6203d656433aSmrg	  fi
6204d656433aSmrg
6205d656433aSmrg	  newlib_search_path="$newlib_search_path $absdir"
6206d656433aSmrg	  # Link against this library
6207d656433aSmrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
6208d656433aSmrg	  # ... and its dependency_libs
6209d656433aSmrg	  tmp_libs=
6210d656433aSmrg	  for deplib in $dependency_libs; do
6211d656433aSmrg	    newdependency_libs="$deplib $newdependency_libs"
6212d656433aSmrg	    if $opt_duplicate_deps ; then
6213d656433aSmrg	      case "$tmp_libs " in
6214d656433aSmrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
6215d656433aSmrg	      esac
6216d656433aSmrg	    fi
6217d656433aSmrg	    tmp_libs="$tmp_libs $deplib"
6218d656433aSmrg	  done
6219d656433aSmrg
6220d656433aSmrg	  if test "$link_all_deplibs" != no; then
6221d656433aSmrg	    # Add the search paths of all dependency libraries
6222d656433aSmrg	    for deplib in $dependency_libs; do
6223555991fdSmrg	      path=
6224d656433aSmrg	      case $deplib in
6225d656433aSmrg	      -L*) path="$deplib" ;;
6226d656433aSmrg	      *.la)
6227d656433aSmrg	        func_dirname "$deplib" "" "."
6228d656433aSmrg		dir="$func_dirname_result"
6229d656433aSmrg		# We need an absolute path.
6230d656433aSmrg		case $dir in
6231d656433aSmrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
6232d656433aSmrg		*)
6233d656433aSmrg		  absdir=`cd "$dir" && pwd`
6234d656433aSmrg		  if test -z "$absdir"; then
6235d656433aSmrg		    func_warning "cannot determine absolute directory name of \`$dir'"
6236d656433aSmrg		    absdir="$dir"
6237d656433aSmrg		  fi
6238d656433aSmrg		  ;;
6239d656433aSmrg		esac
6240d656433aSmrg		if $GREP "^installed=no" $deplib > /dev/null; then
6241d656433aSmrg		case $host in
6242d656433aSmrg		*-*-darwin*)
6243d656433aSmrg		  depdepl=
6244d656433aSmrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
6245d656433aSmrg		  if test -n "$deplibrary_names" ; then
6246d656433aSmrg		    for tmp in $deplibrary_names ; do
6247d656433aSmrg		      depdepl=$tmp
6248d656433aSmrg		    done
6249d656433aSmrg		    if test -f "$absdir/$objdir/$depdepl" ; then
6250d656433aSmrg		      depdepl="$absdir/$objdir/$depdepl"
6251d656433aSmrg		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
6252d656433aSmrg                      if test -z "$darwin_install_name"; then
6253d656433aSmrg                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
6254d656433aSmrg                      fi
6255d656433aSmrg		      compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
6256d656433aSmrg		      linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}"
6257d656433aSmrg		      path=
6258d656433aSmrg		    fi
6259d656433aSmrg		  fi
6260d656433aSmrg		  ;;
6261d656433aSmrg		*)
6262d656433aSmrg		  path="-L$absdir/$objdir"
6263d656433aSmrg		  ;;
6264d656433aSmrg		esac
6265d656433aSmrg		else
6266d656433aSmrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
6267d656433aSmrg		  test -z "$libdir" && \
6268d656433aSmrg		    func_fatal_error "\`$deplib' is not a valid libtool archive"
6269d656433aSmrg		  test "$absdir" != "$libdir" && \
6270d656433aSmrg		    func_warning "\`$deplib' seems to be moved"
6271d656433aSmrg
6272d656433aSmrg		  path="-L$absdir"
6273d656433aSmrg		fi
6274d656433aSmrg		;;
6275d656433aSmrg	      esac
6276d656433aSmrg	      case " $deplibs " in
6277d656433aSmrg	      *" $path "*) ;;
6278d656433aSmrg	      *) deplibs="$path $deplibs" ;;
6279d656433aSmrg	      esac
6280d656433aSmrg	    done
6281d656433aSmrg	  fi # link_all_deplibs != no
6282d656433aSmrg	fi # linkmode = lib
6283d656433aSmrg      done # for deplib in $libs
6284d656433aSmrg      if test "$pass" = link; then
6285d656433aSmrg	if test "$linkmode" = "prog"; then
6286d656433aSmrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
6287d656433aSmrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
6288d656433aSmrg	else
6289555991fdSmrg	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
6290d656433aSmrg	fi
6291d656433aSmrg      fi
6292d656433aSmrg      dependency_libs="$newdependency_libs"
6293d656433aSmrg      if test "$pass" = dlpreopen; then
6294d656433aSmrg	# Link the dlpreopened libraries before other libraries
6295d656433aSmrg	for deplib in $save_deplibs; do
6296d656433aSmrg	  deplibs="$deplib $deplibs"
6297d656433aSmrg	done
6298d656433aSmrg      fi
6299d656433aSmrg      if test "$pass" != dlopen; then
6300d656433aSmrg	if test "$pass" != conv; then
6301d656433aSmrg	  # Make sure lib_search_path contains only unique directories.
6302d656433aSmrg	  lib_search_path=
6303d656433aSmrg	  for dir in $newlib_search_path; do
6304d656433aSmrg	    case "$lib_search_path " in
6305d656433aSmrg	    *" $dir "*) ;;
6306d656433aSmrg	    *) lib_search_path="$lib_search_path $dir" ;;
6307d656433aSmrg	    esac
6308d656433aSmrg	  done
6309d656433aSmrg	  newlib_search_path=
6310d656433aSmrg	fi
6311d656433aSmrg
6312d656433aSmrg	if test "$linkmode,$pass" != "prog,link"; then
6313d656433aSmrg	  vars="deplibs"
6314d656433aSmrg	else
6315d656433aSmrg	  vars="compile_deplibs finalize_deplibs"
6316d656433aSmrg	fi
6317d656433aSmrg	for var in $vars dependency_libs; do
6318d656433aSmrg	  # Add libraries to $var in reverse order
6319d656433aSmrg	  eval tmp_libs=\"\$$var\"
6320d656433aSmrg	  new_libs=
6321d656433aSmrg	  for deplib in $tmp_libs; do
6322d656433aSmrg	    # FIXME: Pedantically, this is the right thing to do, so
6323d656433aSmrg	    #        that some nasty dependency loop isn't accidentally
6324d656433aSmrg	    #        broken:
6325d656433aSmrg	    #new_libs="$deplib $new_libs"
6326d656433aSmrg	    # Pragmatically, this seems to cause very few problems in
6327d656433aSmrg	    # practice:
6328d656433aSmrg	    case $deplib in
6329d656433aSmrg	    -L*) new_libs="$deplib $new_libs" ;;
6330d656433aSmrg	    -R*) ;;
6331d656433aSmrg	    *)
6332d656433aSmrg	      # And here is the reason: when a library appears more
6333d656433aSmrg	      # than once as an explicit dependence of a library, or
6334d656433aSmrg	      # is implicitly linked in more than once by the
6335d656433aSmrg	      # compiler, it is considered special, and multiple
6336d656433aSmrg	      # occurrences thereof are not removed.  Compare this
6337d656433aSmrg	      # with having the same library being listed as a
6338d656433aSmrg	      # dependency of multiple other libraries: in this case,
6339d656433aSmrg	      # we know (pedantically, we assume) the library does not
6340d656433aSmrg	      # need to be listed more than once, so we keep only the
6341d656433aSmrg	      # last copy.  This is not always right, but it is rare
6342d656433aSmrg	      # enough that we require users that really mean to play
6343d656433aSmrg	      # such unportable linking tricks to link the library
6344d656433aSmrg	      # using -Wl,-lname, so that libtool does not consider it
6345d656433aSmrg	      # for duplicate removal.
6346d656433aSmrg	      case " $specialdeplibs " in
6347d656433aSmrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
6348d656433aSmrg	      *)
6349d656433aSmrg		case " $new_libs " in
6350d656433aSmrg		*" $deplib "*) ;;
6351d656433aSmrg		*) new_libs="$deplib $new_libs" ;;
6352d656433aSmrg		esac
6353d656433aSmrg		;;
6354d656433aSmrg	      esac
6355d656433aSmrg	      ;;
6356d656433aSmrg	    esac
6357d656433aSmrg	  done
6358d656433aSmrg	  tmp_libs=
6359d656433aSmrg	  for deplib in $new_libs; do
6360d656433aSmrg	    case $deplib in
6361d656433aSmrg	    -L*)
6362d656433aSmrg	      case " $tmp_libs " in
6363d656433aSmrg	      *" $deplib "*) ;;
6364d656433aSmrg	      *) tmp_libs="$tmp_libs $deplib" ;;
6365d656433aSmrg	      esac
6366d656433aSmrg	      ;;
6367d656433aSmrg	    *) tmp_libs="$tmp_libs $deplib" ;;
6368d656433aSmrg	    esac
6369d656433aSmrg	  done
6370d656433aSmrg	  eval $var=\"$tmp_libs\"
6371d656433aSmrg	done # for var
6372d656433aSmrg      fi
6373d656433aSmrg      # Last step: remove runtime libs from dependency_libs
6374d656433aSmrg      # (they stay in deplibs)
6375d656433aSmrg      tmp_libs=
6376d656433aSmrg      for i in $dependency_libs ; do
6377d656433aSmrg	case " $predeps $postdeps $compiler_lib_search_path " in
6378d656433aSmrg	*" $i "*)
6379d656433aSmrg	  i=""
6380d656433aSmrg	  ;;
6381d656433aSmrg	esac
6382d656433aSmrg	if test -n "$i" ; then
6383d656433aSmrg	  tmp_libs="$tmp_libs $i"
6384d656433aSmrg	fi
6385d656433aSmrg      done
6386d656433aSmrg      dependency_libs=$tmp_libs
6387d656433aSmrg    done # for pass
6388d656433aSmrg    if test "$linkmode" = prog; then
6389d656433aSmrg      dlfiles="$newdlfiles"
6390d656433aSmrg    fi
6391d656433aSmrg    if test "$linkmode" = prog || test "$linkmode" = lib; then
6392d656433aSmrg      dlprefiles="$newdlprefiles"
6393d656433aSmrg    fi
6394d656433aSmrg
6395d656433aSmrg    case $linkmode in
6396d656433aSmrg    oldlib)
6397d656433aSmrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
6398d656433aSmrg	func_warning "\`-dlopen' is ignored for archives"
6399d656433aSmrg      fi
6400d656433aSmrg
6401d656433aSmrg      case " $deplibs" in
6402d656433aSmrg      *\ -l* | *\ -L*)
6403d656433aSmrg	func_warning "\`-l' and \`-L' are ignored for archives" ;;
6404d656433aSmrg      esac
6405d656433aSmrg
6406d656433aSmrg      test -n "$rpath" && \
6407d656433aSmrg	func_warning "\`-rpath' is ignored for archives"
6408d656433aSmrg
6409d656433aSmrg      test -n "$xrpath" && \
6410d656433aSmrg	func_warning "\`-R' is ignored for archives"
6411d656433aSmrg
6412d656433aSmrg      test -n "$vinfo" && \
6413d656433aSmrg	func_warning "\`-version-info/-version-number' is ignored for archives"
6414d656433aSmrg
6415d656433aSmrg      test -n "$release" && \
6416d656433aSmrg	func_warning "\`-release' is ignored for archives"
6417d656433aSmrg
6418d656433aSmrg      test -n "$export_symbols$export_symbols_regex" && \
6419d656433aSmrg	func_warning "\`-export-symbols' is ignored for archives"
6420d656433aSmrg
6421d656433aSmrg      # Now set the variables for building old libraries.
6422d656433aSmrg      build_libtool_libs=no
6423d656433aSmrg      oldlibs="$output"
6424d656433aSmrg      objs="$objs$old_deplibs"
6425d656433aSmrg      ;;
6426d656433aSmrg
6427d656433aSmrg    lib)
6428d656433aSmrg      # Make sure we only generate libraries of the form `libNAME.la'.
6429d656433aSmrg      case $outputname in
6430d656433aSmrg      lib*)
6431d656433aSmrg	func_stripname 'lib' '.la' "$outputname"
6432d656433aSmrg	name=$func_stripname_result
6433d656433aSmrg	eval shared_ext=\"$shrext_cmds\"
6434d656433aSmrg	eval libname=\"$libname_spec\"
6435d656433aSmrg	;;
6436d656433aSmrg      *)
6437d656433aSmrg	test "$module" = no && \
6438d656433aSmrg	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
6439d656433aSmrg
6440d656433aSmrg	if test "$need_lib_prefix" != no; then
6441d656433aSmrg	  # Add the "lib" prefix for modules if required
6442d656433aSmrg	  func_stripname '' '.la' "$outputname"
6443d656433aSmrg	  name=$func_stripname_result
6444d656433aSmrg	  eval shared_ext=\"$shrext_cmds\"
6445d656433aSmrg	  eval libname=\"$libname_spec\"
6446d656433aSmrg	else
6447d656433aSmrg	  func_stripname '' '.la' "$outputname"
6448d656433aSmrg	  libname=$func_stripname_result
6449d656433aSmrg	fi
6450d656433aSmrg	;;
6451d656433aSmrg      esac
6452d656433aSmrg
6453d656433aSmrg      if test -n "$objs"; then
6454d656433aSmrg	if test "$deplibs_check_method" != pass_all; then
6455d656433aSmrg	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
6456d656433aSmrg	else
6457555991fdSmrg	  echo
6458d656433aSmrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
6459d656433aSmrg	  $ECHO "*** objects $objs is not portable!"
6460d656433aSmrg	  libobjs="$libobjs $objs"
6461d656433aSmrg	fi
6462d656433aSmrg      fi
6463d656433aSmrg
6464d656433aSmrg      test "$dlself" != no && \
6465d656433aSmrg	func_warning "\`-dlopen self' is ignored for libtool libraries"
6466d656433aSmrg
6467d656433aSmrg      set dummy $rpath
6468d656433aSmrg      shift
6469d656433aSmrg      test "$#" -gt 1 && \
6470d656433aSmrg	func_warning "ignoring multiple \`-rpath's for a libtool library"
6471d656433aSmrg
6472d656433aSmrg      install_libdir="$1"
6473d656433aSmrg
6474d656433aSmrg      oldlibs=
6475d656433aSmrg      if test -z "$rpath"; then
6476d656433aSmrg	if test "$build_libtool_libs" = yes; then
6477d656433aSmrg	  # Building a libtool convenience library.
6478d656433aSmrg	  # Some compilers have problems with a `.al' extension so
6479d656433aSmrg	  # convenience libraries should have the same extension an
6480d656433aSmrg	  # archive normally would.
6481d656433aSmrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
6482d656433aSmrg	  build_libtool_libs=convenience
6483d656433aSmrg	  build_old_libs=yes
6484d656433aSmrg	fi
6485d656433aSmrg
6486d656433aSmrg	test -n "$vinfo" && \
6487d656433aSmrg	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
6488d656433aSmrg
6489d656433aSmrg	test -n "$release" && \
6490d656433aSmrg	  func_warning "\`-release' is ignored for convenience libraries"
6491d656433aSmrg      else
6492d656433aSmrg
6493d656433aSmrg	# Parse the version information argument.
6494d656433aSmrg	save_ifs="$IFS"; IFS=':'
6495d656433aSmrg	set dummy $vinfo 0 0 0
6496d656433aSmrg	shift
6497d656433aSmrg	IFS="$save_ifs"
6498d656433aSmrg
6499d656433aSmrg	test -n "$7" && \
6500d656433aSmrg	  func_fatal_help "too many parameters to \`-version-info'"
6501d656433aSmrg
6502d656433aSmrg	# convert absolute version numbers to libtool ages
6503d656433aSmrg	# this retains compatibility with .la files and attempts
6504d656433aSmrg	# to make the code below a bit more comprehensible
6505d656433aSmrg
6506d656433aSmrg	case $vinfo_number in
6507d656433aSmrg	yes)
6508d656433aSmrg	  number_major="$1"
6509d656433aSmrg	  number_minor="$2"
6510d656433aSmrg	  number_revision="$3"
6511d656433aSmrg	  #
6512d656433aSmrg	  # There are really only two kinds -- those that
6513d656433aSmrg	  # use the current revision as the major version
6514d656433aSmrg	  # and those that subtract age and use age as
6515d656433aSmrg	  # a minor version.  But, then there is irix
6516d656433aSmrg	  # which has an extra 1 added just for fun
6517d656433aSmrg	  #
6518d656433aSmrg	  case $version_type in
6519d656433aSmrg	  darwin|linux|osf|windows|none)
6520d656433aSmrg	    func_arith $number_major + $number_minor
6521d656433aSmrg	    current=$func_arith_result
6522d656433aSmrg	    age="$number_minor"
6523d656433aSmrg	    revision="$number_revision"
6524d656433aSmrg	    ;;
6525555991fdSmrg	  freebsd-aout|freebsd-elf|qnx|sunos)
6526d656433aSmrg	    current="$number_major"
6527d656433aSmrg	    revision="$number_minor"
6528d656433aSmrg	    age="0"
6529d656433aSmrg	    ;;
6530d656433aSmrg	  irix|nonstopux)
6531d656433aSmrg	    func_arith $number_major + $number_minor
6532d656433aSmrg	    current=$func_arith_result
6533d656433aSmrg	    age="$number_minor"
6534d656433aSmrg	    revision="$number_minor"
6535d656433aSmrg	    lt_irix_increment=no
6536d656433aSmrg	    ;;
6537d656433aSmrg	  esac
6538d656433aSmrg	  ;;
6539d656433aSmrg	no)
6540d656433aSmrg	  current="$1"
6541d656433aSmrg	  revision="$2"
6542d656433aSmrg	  age="$3"
6543d656433aSmrg	  ;;
6544d656433aSmrg	esac
6545d656433aSmrg
6546d656433aSmrg	# Check that each of the things are valid numbers.
6547d656433aSmrg	case $current in
6548d656433aSmrg	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]) ;;
6549d656433aSmrg	*)
6550d656433aSmrg	  func_error "CURRENT \`$current' must be a nonnegative integer"
6551d656433aSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
6552d656433aSmrg	  ;;
6553d656433aSmrg	esac
6554d656433aSmrg
6555d656433aSmrg	case $revision in
6556d656433aSmrg	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]) ;;
6557d656433aSmrg	*)
6558d656433aSmrg	  func_error "REVISION \`$revision' must be a nonnegative integer"
6559d656433aSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
6560d656433aSmrg	  ;;
6561d656433aSmrg	esac
6562d656433aSmrg
6563d656433aSmrg	case $age in
6564d656433aSmrg	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]) ;;
6565d656433aSmrg	*)
6566d656433aSmrg	  func_error "AGE \`$age' must be a nonnegative integer"
6567d656433aSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
6568d656433aSmrg	  ;;
6569d656433aSmrg	esac
6570d656433aSmrg
6571d656433aSmrg	if test "$age" -gt "$current"; then
6572d656433aSmrg	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
6573d656433aSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
6574d656433aSmrg	fi
6575d656433aSmrg
6576d656433aSmrg	# Calculate the version variables.
6577d656433aSmrg	major=
6578d656433aSmrg	versuffix=
6579d656433aSmrg	verstring=
6580d656433aSmrg	case $version_type in
6581d656433aSmrg	none) ;;
6582d656433aSmrg
6583d656433aSmrg	darwin)
6584d656433aSmrg	  # Like Linux, but with the current version available in
6585d656433aSmrg	  # verstring for coding it into the library header
6586d656433aSmrg	  func_arith $current - $age
6587d656433aSmrg	  major=.$func_arith_result
6588d656433aSmrg	  versuffix="$major.$age.$revision"
6589d656433aSmrg	  # Darwin ld doesn't like 0 for these options...
6590d656433aSmrg	  func_arith $current + 1
6591d656433aSmrg	  minor_current=$func_arith_result
6592d656433aSmrg	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
6593d656433aSmrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
6594d656433aSmrg	  ;;
6595d656433aSmrg
6596d656433aSmrg	freebsd-aout)
6597d656433aSmrg	  major=".$current"
6598d656433aSmrg	  versuffix=".$current.$revision";
6599d656433aSmrg	  ;;
6600d656433aSmrg
6601d656433aSmrg	freebsd-elf)
6602d656433aSmrg	  major=".$current"
6603d656433aSmrg	  versuffix=".$current"
6604d656433aSmrg	  ;;
6605d656433aSmrg
6606d656433aSmrg	irix | nonstopux)
6607d656433aSmrg	  if test "X$lt_irix_increment" = "Xno"; then
6608d656433aSmrg	    func_arith $current - $age
6609d656433aSmrg	  else
6610d656433aSmrg	    func_arith $current - $age + 1
6611d656433aSmrg	  fi
6612d656433aSmrg	  major=$func_arith_result
6613d656433aSmrg
6614d656433aSmrg	  case $version_type in
6615d656433aSmrg	    nonstopux) verstring_prefix=nonstopux ;;
6616d656433aSmrg	    *)         verstring_prefix=sgi ;;
6617d656433aSmrg	  esac
6618d656433aSmrg	  verstring="$verstring_prefix$major.$revision"
6619d656433aSmrg
6620d656433aSmrg	  # Add in all the interfaces that we are compatible with.
6621d656433aSmrg	  loop=$revision
6622d656433aSmrg	  while test "$loop" -ne 0; do
6623d656433aSmrg	    func_arith $revision - $loop
6624d656433aSmrg	    iface=$func_arith_result
6625d656433aSmrg	    func_arith $loop - 1
6626d656433aSmrg	    loop=$func_arith_result
6627d656433aSmrg	    verstring="$verstring_prefix$major.$iface:$verstring"
6628d656433aSmrg	  done
6629d656433aSmrg
6630d656433aSmrg	  # Before this point, $major must not contain `.'.
6631d656433aSmrg	  major=.$major
6632d656433aSmrg	  versuffix="$major.$revision"
6633d656433aSmrg	  ;;
6634d656433aSmrg
6635d656433aSmrg	linux)
6636d656433aSmrg	  func_arith $current - $age
6637d656433aSmrg	  major=.$func_arith_result
6638d656433aSmrg	  versuffix="$major.$age.$revision"
6639d656433aSmrg	  ;;
6640d656433aSmrg
6641d656433aSmrg	osf)
6642d656433aSmrg	  func_arith $current - $age
6643d656433aSmrg	  major=.$func_arith_result
6644d656433aSmrg	  versuffix=".$current.$age.$revision"
6645d656433aSmrg	  verstring="$current.$age.$revision"
6646d656433aSmrg
6647d656433aSmrg	  # Add in all the interfaces that we are compatible with.
6648d656433aSmrg	  loop=$age
6649d656433aSmrg	  while test "$loop" -ne 0; do
6650d656433aSmrg	    func_arith $current - $loop
6651d656433aSmrg	    iface=$func_arith_result
6652d656433aSmrg	    func_arith $loop - 1
6653d656433aSmrg	    loop=$func_arith_result
6654d656433aSmrg	    verstring="$verstring:${iface}.0"
6655d656433aSmrg	  done
6656d656433aSmrg
6657d656433aSmrg	  # Make executables depend on our current version.
6658d656433aSmrg	  verstring="$verstring:${current}.0"
6659d656433aSmrg	  ;;
6660d656433aSmrg
6661d656433aSmrg	qnx)
6662d656433aSmrg	  major=".$current"
6663d656433aSmrg	  versuffix=".$current"
6664d656433aSmrg	  ;;
6665d656433aSmrg
6666d656433aSmrg	sunos)
6667d656433aSmrg	  major=".$current"
6668d656433aSmrg	  versuffix=".$current.$revision"
6669d656433aSmrg	  ;;
6670d656433aSmrg
6671d656433aSmrg	windows)
6672d656433aSmrg	  # Use '-' rather than '.', since we only want one
6673d656433aSmrg	  # extension on DOS 8.3 filesystems.
6674d656433aSmrg	  func_arith $current - $age
6675d656433aSmrg	  major=$func_arith_result
6676d656433aSmrg	  versuffix="-$major"
6677d656433aSmrg	  ;;
6678d656433aSmrg
6679d656433aSmrg	*)
6680d656433aSmrg	  func_fatal_configuration "unknown library version type \`$version_type'"
6681d656433aSmrg	  ;;
6682d656433aSmrg	esac
6683d656433aSmrg
6684d656433aSmrg	# Clear the version info if we defaulted, and they specified a release.
6685d656433aSmrg	if test -z "$vinfo" && test -n "$release"; then
6686d656433aSmrg	  major=
6687d656433aSmrg	  case $version_type in
6688d656433aSmrg	  darwin)
6689d656433aSmrg	    # we can't check for "0.0" in archive_cmds due to quoting
6690d656433aSmrg	    # problems, so we reset it completely
6691d656433aSmrg	    verstring=
6692d656433aSmrg	    ;;
6693d656433aSmrg	  *)
6694d656433aSmrg	    verstring="0.0"
6695d656433aSmrg	    ;;
6696d656433aSmrg	  esac
6697d656433aSmrg	  if test "$need_version" = no; then
6698d656433aSmrg	    versuffix=
6699d656433aSmrg	  else
6700d656433aSmrg	    versuffix=".0.0"
6701d656433aSmrg	  fi
6702d656433aSmrg	fi
6703d656433aSmrg
6704d656433aSmrg	# Remove version info from name if versioning should be avoided
6705d656433aSmrg	if test "$avoid_version" = yes && test "$need_version" = no; then
6706d656433aSmrg	  major=
6707d656433aSmrg	  versuffix=
6708d656433aSmrg	  verstring=""
6709d656433aSmrg	fi
6710d656433aSmrg
6711d656433aSmrg	# Check to see if the archive will have undefined symbols.
6712d656433aSmrg	if test "$allow_undefined" = yes; then
6713d656433aSmrg	  if test "$allow_undefined_flag" = unsupported; then
6714d656433aSmrg	    func_warning "undefined symbols not allowed in $host shared libraries"
6715d656433aSmrg	    build_libtool_libs=no
6716d656433aSmrg	    build_old_libs=yes
6717d656433aSmrg	  fi
6718d656433aSmrg	else
6719d656433aSmrg	  # Don't allow undefined symbols.
6720d656433aSmrg	  allow_undefined_flag="$no_undefined_flag"
6721d656433aSmrg	fi
6722d656433aSmrg
6723d656433aSmrg      fi
6724d656433aSmrg
6725d656433aSmrg      func_generate_dlsyms "$libname" "$libname" "yes"
6726d656433aSmrg      libobjs="$libobjs $symfileobj"
6727d656433aSmrg      test "X$libobjs" = "X " && libobjs=
6728d656433aSmrg
6729d656433aSmrg      if test "$mode" != relink; then
6730d656433aSmrg	# Remove our outputs, but don't remove object files since they
6731d656433aSmrg	# may have been created when compiling PIC objects.
6732d656433aSmrg	removelist=
6733d656433aSmrg	tempremovelist=`$ECHO "$output_objdir/*"`
6734d656433aSmrg	for p in $tempremovelist; do
6735d656433aSmrg	  case $p in
6736d656433aSmrg	    *.$objext | *.gcno)
6737d656433aSmrg	       ;;
6738d656433aSmrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
6739d656433aSmrg	       if test "X$precious_files_regex" != "X"; then
6740d656433aSmrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
6741d656433aSmrg		 then
6742d656433aSmrg		   continue
6743d656433aSmrg		 fi
6744d656433aSmrg	       fi
6745d656433aSmrg	       removelist="$removelist $p"
6746d656433aSmrg	       ;;
6747d656433aSmrg	    *) ;;
6748d656433aSmrg	  esac
6749d656433aSmrg	done
6750d656433aSmrg	test -n "$removelist" && \
6751d656433aSmrg	  func_show_eval "${RM}r \$removelist"
6752d656433aSmrg      fi
6753d656433aSmrg
6754d656433aSmrg      # Now set the variables for building old libraries.
6755d656433aSmrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
6756d656433aSmrg	oldlibs="$oldlibs $output_objdir/$libname.$libext"
6757d656433aSmrg
6758d656433aSmrg	# Transform .lo files to .o files.
6759555991fdSmrg	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
6760d656433aSmrg      fi
6761d656433aSmrg
6762d656433aSmrg      # Eliminate all temporary directories.
6763d656433aSmrg      #for path in $notinst_path; do
6764555991fdSmrg      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
6765555991fdSmrg      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
6766555991fdSmrg      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
6767d656433aSmrg      #done
6768d656433aSmrg
6769d656433aSmrg      if test -n "$xrpath"; then
6770d656433aSmrg	# If the user specified any rpath flags, then add them.
6771d656433aSmrg	temp_xrpath=
6772d656433aSmrg	for libdir in $xrpath; do
6773d656433aSmrg	  temp_xrpath="$temp_xrpath -R$libdir"
6774d656433aSmrg	  case "$finalize_rpath " in
6775d656433aSmrg	  *" $libdir "*) ;;
6776d656433aSmrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
6777d656433aSmrg	  esac
6778d656433aSmrg	done
6779d656433aSmrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
6780d656433aSmrg	  dependency_libs="$temp_xrpath $dependency_libs"
6781d656433aSmrg	fi
6782d656433aSmrg      fi
6783d656433aSmrg
6784d656433aSmrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
6785d656433aSmrg      old_dlfiles="$dlfiles"
6786d656433aSmrg      dlfiles=
6787d656433aSmrg      for lib in $old_dlfiles; do
6788d656433aSmrg	case " $dlprefiles $dlfiles " in
6789d656433aSmrg	*" $lib "*) ;;
6790d656433aSmrg	*) dlfiles="$dlfiles $lib" ;;
6791d656433aSmrg	esac
6792d656433aSmrg      done
6793d656433aSmrg
6794d656433aSmrg      # Make sure dlprefiles contains only unique files
6795d656433aSmrg      old_dlprefiles="$dlprefiles"
6796d656433aSmrg      dlprefiles=
6797d656433aSmrg      for lib in $old_dlprefiles; do
6798d656433aSmrg	case "$dlprefiles " in
6799d656433aSmrg	*" $lib "*) ;;
6800d656433aSmrg	*) dlprefiles="$dlprefiles $lib" ;;
6801d656433aSmrg	esac
6802d656433aSmrg      done
6803d656433aSmrg
6804d656433aSmrg      if test "$build_libtool_libs" = yes; then
6805d656433aSmrg	if test -n "$rpath"; then
6806d656433aSmrg	  case $host in
6807555991fdSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
6808d656433aSmrg	    # these systems don't actually have a c library (as such)!
6809d656433aSmrg	    ;;
6810d656433aSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
6811d656433aSmrg	    # Rhapsody C library is in the System framework
6812d656433aSmrg	    deplibs="$deplibs System.ltframework"
6813d656433aSmrg	    ;;
6814d656433aSmrg	  *-*-netbsd*)
6815d656433aSmrg	    # Don't link with libc until the a.out ld.so is fixed.
6816d656433aSmrg	    ;;
6817d656433aSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
6818d656433aSmrg	    # Do not include libc due to us having libc/libc_r.
6819d656433aSmrg	    ;;
6820d656433aSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
6821d656433aSmrg	    # Causes problems with __ctype
6822d656433aSmrg	    ;;
6823d656433aSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
6824d656433aSmrg	    # Compiler inserts libc in the correct place for threads to work
6825d656433aSmrg	    ;;
6826d656433aSmrg	  *)
6827d656433aSmrg	    # Add libc to deplibs on all other systems if necessary.
6828d656433aSmrg	    if test "$build_libtool_need_lc" = "yes"; then
6829d656433aSmrg	      deplibs="$deplibs -lc"
6830d656433aSmrg	    fi
6831d656433aSmrg	    ;;
6832d656433aSmrg	  esac
6833d656433aSmrg	fi
6834d656433aSmrg
6835d656433aSmrg	# Transform deplibs into only deplibs that can be linked in shared.
6836d656433aSmrg	name_save=$name
6837d656433aSmrg	libname_save=$libname
6838d656433aSmrg	release_save=$release
6839d656433aSmrg	versuffix_save=$versuffix
6840d656433aSmrg	major_save=$major
6841d656433aSmrg	# I'm not sure if I'm treating the release correctly.  I think
6842d656433aSmrg	# release should show up in the -l (ie -lgmp5) so we don't want to
6843d656433aSmrg	# add it in twice.  Is that correct?
6844d656433aSmrg	release=""
6845d656433aSmrg	versuffix=""
6846d656433aSmrg	major=""
6847d656433aSmrg	newdeplibs=
6848d656433aSmrg	droppeddeps=no
6849d656433aSmrg	case $deplibs_check_method in
6850d656433aSmrg	pass_all)
6851d656433aSmrg	  # Don't check for shared/static.  Everything works.
6852d656433aSmrg	  # This might be a little naive.  We might want to check
6853d656433aSmrg	  # whether the library exists or not.  But this is on
6854d656433aSmrg	  # osf3 & osf4 and I'm not really sure... Just
6855d656433aSmrg	  # implementing what was already the behavior.
6856d656433aSmrg	  newdeplibs=$deplibs
6857d656433aSmrg	  ;;
6858d656433aSmrg	test_compile)
6859d656433aSmrg	  # This code stresses the "libraries are programs" paradigm to its
6860d656433aSmrg	  # limits. Maybe even breaks it.  We compile a program, linking it
6861d656433aSmrg	  # against the deplibs as a proxy for the library.  Then we can check
6862d656433aSmrg	  # whether they linked in statically or dynamically with ldd.
6863d656433aSmrg	  $opt_dry_run || $RM conftest.c
6864d656433aSmrg	  cat > conftest.c <<EOF
6865d656433aSmrg	  int main() { return 0; }
6866d656433aSmrgEOF
6867d656433aSmrg	  $opt_dry_run || $RM conftest
6868d656433aSmrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
6869d656433aSmrg	    ldd_output=`ldd conftest`
6870d656433aSmrg	    for i in $deplibs; do
6871d656433aSmrg	      case $i in
6872d656433aSmrg	      -l*)
6873d656433aSmrg		func_stripname -l '' "$i"
6874d656433aSmrg		name=$func_stripname_result
6875d656433aSmrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6876d656433aSmrg		  case " $predeps $postdeps " in
6877d656433aSmrg		  *" $i "*)
6878d656433aSmrg		    newdeplibs="$newdeplibs $i"
6879d656433aSmrg		    i=""
6880d656433aSmrg		    ;;
6881d656433aSmrg		  esac
6882d656433aSmrg		fi
6883d656433aSmrg		if test -n "$i" ; then
6884d656433aSmrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
6885d656433aSmrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
6886d656433aSmrg		  set dummy $deplib_matches; shift
6887d656433aSmrg		  deplib_match=$1
6888d656433aSmrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
6889d656433aSmrg		    newdeplibs="$newdeplibs $i"
6890d656433aSmrg		  else
6891d656433aSmrg		    droppeddeps=yes
6892555991fdSmrg		    echo
6893d656433aSmrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
6894555991fdSmrg		    echo "*** I have the capability to make that library automatically link in when"
6895555991fdSmrg		    echo "*** you link to this library.  But I can only do this if you have a"
6896555991fdSmrg		    echo "*** shared version of the library, which I believe you do not have"
6897555991fdSmrg		    echo "*** because a test_compile did reveal that the linker did not use it for"
6898555991fdSmrg		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
6899d656433aSmrg		  fi
6900d656433aSmrg		fi
6901d656433aSmrg		;;
6902d656433aSmrg	      *)
6903d656433aSmrg		newdeplibs="$newdeplibs $i"
6904d656433aSmrg		;;
6905d656433aSmrg	      esac
6906d656433aSmrg	    done
6907d656433aSmrg	  else
6908d656433aSmrg	    # Error occurred in the first compile.  Let's try to salvage
6909d656433aSmrg	    # the situation: Compile a separate program for each library.
6910d656433aSmrg	    for i in $deplibs; do
6911d656433aSmrg	      case $i in
6912d656433aSmrg	      -l*)
6913d656433aSmrg		func_stripname -l '' "$i"
6914d656433aSmrg		name=$func_stripname_result
6915d656433aSmrg		$opt_dry_run || $RM conftest
6916d656433aSmrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
6917d656433aSmrg		  ldd_output=`ldd conftest`
6918d656433aSmrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6919d656433aSmrg		    case " $predeps $postdeps " in
6920d656433aSmrg		    *" $i "*)
6921d656433aSmrg		      newdeplibs="$newdeplibs $i"
6922d656433aSmrg		      i=""
6923d656433aSmrg		      ;;
6924d656433aSmrg		    esac
6925d656433aSmrg		  fi
6926d656433aSmrg		  if test -n "$i" ; then
6927d656433aSmrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
6928d656433aSmrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
6929d656433aSmrg		    set dummy $deplib_matches; shift
6930d656433aSmrg		    deplib_match=$1
6931d656433aSmrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
6932d656433aSmrg		      newdeplibs="$newdeplibs $i"
6933d656433aSmrg		    else
6934d656433aSmrg		      droppeddeps=yes
6935555991fdSmrg		      echo
6936d656433aSmrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
6937555991fdSmrg		      echo "*** I have the capability to make that library automatically link in when"
6938555991fdSmrg		      echo "*** you link to this library.  But I can only do this if you have a"
6939555991fdSmrg		      echo "*** shared version of the library, which you do not appear to have"
6940555991fdSmrg		      echo "*** because a test_compile did reveal that the linker did not use this one"
6941555991fdSmrg		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
6942d656433aSmrg		    fi
6943d656433aSmrg		  fi
6944d656433aSmrg		else
6945d656433aSmrg		  droppeddeps=yes
6946555991fdSmrg		  echo
6947d656433aSmrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
6948555991fdSmrg		  echo "*** make it link in!  You will probably need to install it or some"
6949555991fdSmrg		  echo "*** library that it depends on before this library will be fully"
6950555991fdSmrg		  echo "*** functional.  Installing it before continuing would be even better."
6951d656433aSmrg		fi
6952d656433aSmrg		;;
6953d656433aSmrg	      *)
6954d656433aSmrg		newdeplibs="$newdeplibs $i"
6955d656433aSmrg		;;
6956d656433aSmrg	      esac
6957d656433aSmrg	    done
6958d656433aSmrg	  fi
6959d656433aSmrg	  ;;
6960d656433aSmrg	file_magic*)
6961d656433aSmrg	  set dummy $deplibs_check_method; shift
6962d656433aSmrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6963d656433aSmrg	  for a_deplib in $deplibs; do
6964d656433aSmrg	    case $a_deplib in
6965d656433aSmrg	    -l*)
6966d656433aSmrg	      func_stripname -l '' "$a_deplib"
6967d656433aSmrg	      name=$func_stripname_result
6968d656433aSmrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6969d656433aSmrg		case " $predeps $postdeps " in
6970d656433aSmrg		*" $a_deplib "*)
6971d656433aSmrg		  newdeplibs="$newdeplibs $a_deplib"
6972d656433aSmrg		  a_deplib=""
6973d656433aSmrg		  ;;
6974d656433aSmrg		esac
6975d656433aSmrg	      fi
6976d656433aSmrg	      if test -n "$a_deplib" ; then
6977d656433aSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
6978d656433aSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
6979d656433aSmrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
6980d656433aSmrg		  for potent_lib in $potential_libs; do
6981d656433aSmrg		      # Follow soft links.
6982d656433aSmrg		      if ls -lLd "$potent_lib" 2>/dev/null |
6983d656433aSmrg			 $GREP " -> " >/dev/null; then
6984d656433aSmrg			continue
6985d656433aSmrg		      fi
6986d656433aSmrg		      # The statement above tries to avoid entering an
6987d656433aSmrg		      # endless loop below, in case of cyclic links.
6988d656433aSmrg		      # We might still enter an endless loop, since a link
6989d656433aSmrg		      # loop can be closed while we follow links,
6990d656433aSmrg		      # but so what?
6991d656433aSmrg		      potlib="$potent_lib"
6992d656433aSmrg		      while test -h "$potlib" 2>/dev/null; do
6993d656433aSmrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
6994d656433aSmrg			case $potliblink in
6995d656433aSmrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
6996555991fdSmrg			*) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
6997d656433aSmrg			esac
6998d656433aSmrg		      done
6999d656433aSmrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
7000d656433aSmrg			 $SED -e 10q |
7001d656433aSmrg			 $EGREP "$file_magic_regex" > /dev/null; then
7002d656433aSmrg			newdeplibs="$newdeplibs $a_deplib"
7003d656433aSmrg			a_deplib=""
7004d656433aSmrg			break 2
7005d656433aSmrg		      fi
7006d656433aSmrg		  done
7007d656433aSmrg		done
7008d656433aSmrg	      fi
7009d656433aSmrg	      if test -n "$a_deplib" ; then
7010d656433aSmrg		droppeddeps=yes
7011555991fdSmrg		echo
7012d656433aSmrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
7013555991fdSmrg		echo "*** I have the capability to make that library automatically link in when"
7014555991fdSmrg		echo "*** you link to this library.  But I can only do this if you have a"
7015555991fdSmrg		echo "*** shared version of the library, which you do not appear to have"
7016555991fdSmrg		echo "*** because I did check the linker path looking for a file starting"
7017d656433aSmrg		if test -z "$potlib" ; then
7018d656433aSmrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
7019d656433aSmrg		else
7020d656433aSmrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
7021d656433aSmrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
7022d656433aSmrg		fi
7023d656433aSmrg	      fi
7024d656433aSmrg	      ;;
7025d656433aSmrg	    *)
7026d656433aSmrg	      # Add a -L argument.
7027d656433aSmrg	      newdeplibs="$newdeplibs $a_deplib"
7028d656433aSmrg	      ;;
7029d656433aSmrg	    esac
7030d656433aSmrg	  done # Gone through all deplibs.
7031d656433aSmrg	  ;;
7032d656433aSmrg	match_pattern*)
7033d656433aSmrg	  set dummy $deplibs_check_method; shift
7034d656433aSmrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7035d656433aSmrg	  for a_deplib in $deplibs; do
7036d656433aSmrg	    case $a_deplib in
7037d656433aSmrg	    -l*)
7038d656433aSmrg	      func_stripname -l '' "$a_deplib"
7039d656433aSmrg	      name=$func_stripname_result
7040d656433aSmrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7041d656433aSmrg		case " $predeps $postdeps " in
7042d656433aSmrg		*" $a_deplib "*)
7043d656433aSmrg		  newdeplibs="$newdeplibs $a_deplib"
7044d656433aSmrg		  a_deplib=""
7045d656433aSmrg		  ;;
7046d656433aSmrg		esac
7047d656433aSmrg	      fi
7048d656433aSmrg	      if test -n "$a_deplib" ; then
7049d656433aSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
7050d656433aSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7051d656433aSmrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
7052d656433aSmrg		  for potent_lib in $potential_libs; do
7053d656433aSmrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
7054555991fdSmrg		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
7055d656433aSmrg		       $EGREP "$match_pattern_regex" > /dev/null; then
7056d656433aSmrg		      newdeplibs="$newdeplibs $a_deplib"
7057d656433aSmrg		      a_deplib=""
7058d656433aSmrg		      break 2
7059d656433aSmrg		    fi
7060d656433aSmrg		  done
7061d656433aSmrg		done
7062d656433aSmrg	      fi
7063d656433aSmrg	      if test -n "$a_deplib" ; then
7064d656433aSmrg		droppeddeps=yes
7065555991fdSmrg		echo
7066d656433aSmrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
7067555991fdSmrg		echo "*** I have the capability to make that library automatically link in when"
7068555991fdSmrg		echo "*** you link to this library.  But I can only do this if you have a"
7069555991fdSmrg		echo "*** shared version of the library, which you do not appear to have"
7070555991fdSmrg		echo "*** because I did check the linker path looking for a file starting"
7071d656433aSmrg		if test -z "$potlib" ; then
7072d656433aSmrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
7073d656433aSmrg		else
7074d656433aSmrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
7075d656433aSmrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
7076d656433aSmrg		fi
7077d656433aSmrg	      fi
7078d656433aSmrg	      ;;
7079d656433aSmrg	    *)
7080d656433aSmrg	      # Add a -L argument.
7081d656433aSmrg	      newdeplibs="$newdeplibs $a_deplib"
7082d656433aSmrg	      ;;
7083d656433aSmrg	    esac
7084d656433aSmrg	  done # Gone through all deplibs.
7085d656433aSmrg	  ;;
7086d656433aSmrg	none | unknown | *)
7087d656433aSmrg	  newdeplibs=""
7088555991fdSmrg	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
7089d656433aSmrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7090d656433aSmrg	    for i in $predeps $postdeps ; do
7091d656433aSmrg	      # can't use Xsed below, because $i might contain '/'
7092555991fdSmrg	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
7093d656433aSmrg	    done
7094d656433aSmrg	  fi
7095555991fdSmrg	  case $tmp_deplibs in
7096555991fdSmrg	  *[!\	\ ]*)
7097555991fdSmrg	    echo
7098d656433aSmrg	    if test "X$deplibs_check_method" = "Xnone"; then
7099555991fdSmrg	      echo "*** Warning: inter-library dependencies are not supported in this platform."
7100d656433aSmrg	    else
7101555991fdSmrg	      echo "*** Warning: inter-library dependencies are not known to be supported."
7102d656433aSmrg	    fi
7103555991fdSmrg	    echo "*** All declared inter-library dependencies are being dropped."
7104d656433aSmrg	    droppeddeps=yes
7105555991fdSmrg	    ;;
7106555991fdSmrg	  esac
7107d656433aSmrg	  ;;
7108d656433aSmrg	esac
7109d656433aSmrg	versuffix=$versuffix_save
7110d656433aSmrg	major=$major_save
7111d656433aSmrg	release=$release_save
7112d656433aSmrg	libname=$libname_save
7113d656433aSmrg	name=$name_save
7114d656433aSmrg
7115d656433aSmrg	case $host in
7116d656433aSmrg	*-*-rhapsody* | *-*-darwin1.[012])
7117d656433aSmrg	  # On Rhapsody replace the C library with the System framework
7118555991fdSmrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
7119d656433aSmrg	  ;;
7120d656433aSmrg	esac
7121d656433aSmrg
7122d656433aSmrg	if test "$droppeddeps" = yes; then
7123d656433aSmrg	  if test "$module" = yes; then
7124555991fdSmrg	    echo
7125555991fdSmrg	    echo "*** Warning: libtool could not satisfy all declared inter-library"
7126d656433aSmrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
7127555991fdSmrg	    echo "*** a static module, that should work as long as the dlopening"
7128555991fdSmrg	    echo "*** application is linked with the -dlopen flag."
7129d656433aSmrg	    if test -z "$global_symbol_pipe"; then
7130555991fdSmrg	      echo
7131555991fdSmrg	      echo "*** However, this would only work if libtool was able to extract symbol"
7132555991fdSmrg	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
7133555991fdSmrg	      echo "*** not find such a program.  So, this module is probably useless."
7134555991fdSmrg	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
7135d656433aSmrg	    fi
7136d656433aSmrg	    if test "$build_old_libs" = no; then
7137d656433aSmrg	      oldlibs="$output_objdir/$libname.$libext"
7138d656433aSmrg	      build_libtool_libs=module
7139d656433aSmrg	      build_old_libs=yes
7140d656433aSmrg	    else
7141d656433aSmrg	      build_libtool_libs=no
7142d656433aSmrg	    fi
7143d656433aSmrg	  else
7144555991fdSmrg	    echo "*** The inter-library dependencies that have been dropped here will be"
7145555991fdSmrg	    echo "*** automatically added whenever a program is linked with this library"
7146555991fdSmrg	    echo "*** or is declared to -dlopen it."
7147d656433aSmrg
7148d656433aSmrg	    if test "$allow_undefined" = no; then
7149555991fdSmrg	      echo
7150555991fdSmrg	      echo "*** Since this library must not contain undefined symbols,"
7151555991fdSmrg	      echo "*** because either the platform does not support them or"
7152555991fdSmrg	      echo "*** it was explicitly requested with -no-undefined,"
7153555991fdSmrg	      echo "*** libtool will only create a static version of it."
7154d656433aSmrg	      if test "$build_old_libs" = no; then
7155d656433aSmrg		oldlibs="$output_objdir/$libname.$libext"
7156d656433aSmrg		build_libtool_libs=module
7157d656433aSmrg		build_old_libs=yes
7158d656433aSmrg	      else
7159d656433aSmrg		build_libtool_libs=no
7160d656433aSmrg	      fi
7161d656433aSmrg	    fi
7162d656433aSmrg	  fi
7163d656433aSmrg	fi
7164d656433aSmrg	# Done checking deplibs!
7165d656433aSmrg	deplibs=$newdeplibs
7166d656433aSmrg      fi
7167d656433aSmrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
7168d656433aSmrg      case $host in
7169d656433aSmrg	*-*-darwin*)
7170555991fdSmrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7171555991fdSmrg	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7172555991fdSmrg	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7173d656433aSmrg	  ;;
7174d656433aSmrg      esac
7175d656433aSmrg
7176d656433aSmrg      # move library search paths that coincide with paths to not yet
7177d656433aSmrg      # installed libraries to the beginning of the library search list
7178d656433aSmrg      new_libs=
7179d656433aSmrg      for path in $notinst_path; do
7180d656433aSmrg	case " $new_libs " in
7181d656433aSmrg	*" -L$path/$objdir "*) ;;
7182d656433aSmrg	*)
7183d656433aSmrg	  case " $deplibs " in
7184d656433aSmrg	  *" -L$path/$objdir "*)
7185d656433aSmrg	    new_libs="$new_libs -L$path/$objdir" ;;
7186d656433aSmrg	  esac
7187d656433aSmrg	  ;;
7188d656433aSmrg	esac
7189d656433aSmrg      done
7190d656433aSmrg      for deplib in $deplibs; do
7191d656433aSmrg	case $deplib in
7192d656433aSmrg	-L*)
7193d656433aSmrg	  case " $new_libs " in
7194d656433aSmrg	  *" $deplib "*) ;;
7195d656433aSmrg	  *) new_libs="$new_libs $deplib" ;;
7196d656433aSmrg	  esac
7197d656433aSmrg	  ;;
7198d656433aSmrg	*) new_libs="$new_libs $deplib" ;;
7199d656433aSmrg	esac
7200d656433aSmrg      done
7201d656433aSmrg      deplibs="$new_libs"
7202d656433aSmrg
7203d656433aSmrg      # All the library-specific variables (install_libdir is set above).
7204d656433aSmrg      library_names=
7205d656433aSmrg      old_library=
7206d656433aSmrg      dlname=
7207d656433aSmrg
7208d656433aSmrg      # Test again, we may have decided not to build it any more
7209d656433aSmrg      if test "$build_libtool_libs" = yes; then
7210d656433aSmrg	if test "$hardcode_into_libs" = yes; then
7211d656433aSmrg	  # Hardcode the library paths
7212d656433aSmrg	  hardcode_libdirs=
7213d656433aSmrg	  dep_rpath=
7214d656433aSmrg	  rpath="$finalize_rpath"
7215d656433aSmrg	  test "$mode" != relink && rpath="$compile_rpath$rpath"
7216d656433aSmrg	  for libdir in $rpath; do
7217d656433aSmrg	    if test -n "$hardcode_libdir_flag_spec"; then
7218d656433aSmrg	      if test -n "$hardcode_libdir_separator"; then
7219d656433aSmrg		if test -z "$hardcode_libdirs"; then
7220d656433aSmrg		  hardcode_libdirs="$libdir"
7221d656433aSmrg		else
7222d656433aSmrg		  # Just accumulate the unique libdirs.
7223d656433aSmrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
7224d656433aSmrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
7225d656433aSmrg		    ;;
7226d656433aSmrg		  *)
7227d656433aSmrg		    hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
7228d656433aSmrg		    ;;
7229d656433aSmrg		  esac
7230d656433aSmrg		fi
7231d656433aSmrg	      else
7232d656433aSmrg		eval flag=\"$hardcode_libdir_flag_spec\"
7233d656433aSmrg		dep_rpath="$dep_rpath $flag"
7234d656433aSmrg	      fi
7235d656433aSmrg	    elif test -n "$runpath_var"; then
7236d656433aSmrg	      case "$perm_rpath " in
7237d656433aSmrg	      *" $libdir "*) ;;
7238d656433aSmrg	      *) perm_rpath="$perm_rpath $libdir" ;;
7239d656433aSmrg	      esac
7240d656433aSmrg	    fi
7241d656433aSmrg	  done
7242d656433aSmrg	  # Substitute the hardcoded libdirs into the rpath.
7243d656433aSmrg	  if test -n "$hardcode_libdir_separator" &&
7244d656433aSmrg	     test -n "$hardcode_libdirs"; then
7245d656433aSmrg	    libdir="$hardcode_libdirs"
7246d656433aSmrg	    if test -n "$hardcode_libdir_flag_spec_ld"; then
7247d656433aSmrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
7248d656433aSmrg	    else
7249d656433aSmrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
7250d656433aSmrg	    fi
7251d656433aSmrg	  fi
7252d656433aSmrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
7253d656433aSmrg	    # We should set the runpath_var.
7254d656433aSmrg	    rpath=
7255d656433aSmrg	    for dir in $perm_rpath; do
7256d656433aSmrg	      rpath="$rpath$dir:"
7257d656433aSmrg	    done
7258d656433aSmrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
7259d656433aSmrg	  fi
7260d656433aSmrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
7261d656433aSmrg	fi
7262126a8a12Smrg
7263d656433aSmrg	shlibpath="$finalize_shlibpath"
7264d656433aSmrg	test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
7265d656433aSmrg	if test -n "$shlibpath"; then
7266d656433aSmrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
7267d656433aSmrg	fi
7268126a8a12Smrg
7269d656433aSmrg	# Get the real and link names of the library.
7270d656433aSmrg	eval shared_ext=\"$shrext_cmds\"
7271d656433aSmrg	eval library_names=\"$library_names_spec\"
7272d656433aSmrg	set dummy $library_names
7273d656433aSmrg	shift
7274d656433aSmrg	realname="$1"
7275d656433aSmrg	shift
7276126a8a12Smrg
7277d656433aSmrg	if test -n "$soname_spec"; then
7278d656433aSmrg	  eval soname=\"$soname_spec\"
7279d656433aSmrg	else
7280d656433aSmrg	  soname="$realname"
7281d656433aSmrg	fi
7282d656433aSmrg	if test -z "$dlname"; then
7283d656433aSmrg	  dlname=$soname
7284d656433aSmrg	fi
7285126a8a12Smrg
7286d656433aSmrg	lib="$output_objdir/$realname"
7287d656433aSmrg	linknames=
7288d656433aSmrg	for link
7289d656433aSmrg	do
7290d656433aSmrg	  linknames="$linknames $link"
7291d656433aSmrg	done
7292126a8a12Smrg
7293d656433aSmrg	# Use standard objects if they are pic
7294555991fdSmrg	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
7295d656433aSmrg	test "X$libobjs" = "X " && libobjs=
7296126a8a12Smrg
7297d656433aSmrg	delfiles=
7298d656433aSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
7299d656433aSmrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
7300d656433aSmrg	  export_symbols="$output_objdir/$libname.uexp"
7301d656433aSmrg	  delfiles="$delfiles $export_symbols"
7302d656433aSmrg	fi
7303126a8a12Smrg
7304d656433aSmrg	orig_export_symbols=
7305d656433aSmrg	case $host_os in
7306d656433aSmrg	cygwin* | mingw* | cegcc*)
7307d656433aSmrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
7308d656433aSmrg	    # exporting using user supplied symfile
7309d656433aSmrg	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
7310d656433aSmrg	      # and it's NOT already a .def file. Must figure out
7311d656433aSmrg	      # which of the given symbols are data symbols and tag
7312d656433aSmrg	      # them as such. So, trigger use of export_symbols_cmds.
7313d656433aSmrg	      # export_symbols gets reassigned inside the "prepare
7314d656433aSmrg	      # the list of exported symbols" if statement, so the
7315d656433aSmrg	      # include_expsyms logic still works.
7316d656433aSmrg	      orig_export_symbols="$export_symbols"
7317d656433aSmrg	      export_symbols=
7318d656433aSmrg	      always_export_symbols=yes
7319d656433aSmrg	    fi
7320d656433aSmrg	  fi
7321d656433aSmrg	  ;;
7322d656433aSmrg	esac
7323126a8a12Smrg
7324d656433aSmrg	# Prepare the list of exported symbols
7325d656433aSmrg	if test -z "$export_symbols"; then
7326d656433aSmrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
7327d656433aSmrg	    func_verbose "generating symbol list for \`$libname.la'"
7328d656433aSmrg	    export_symbols="$output_objdir/$libname.exp"
7329d656433aSmrg	    $opt_dry_run || $RM $export_symbols
7330d656433aSmrg	    cmds=$export_symbols_cmds
7331d656433aSmrg	    save_ifs="$IFS"; IFS='~'
7332d656433aSmrg	    for cmd in $cmds; do
7333d656433aSmrg	      IFS="$save_ifs"
7334d656433aSmrg	      eval cmd=\"$cmd\"
7335d656433aSmrg	      func_len " $cmd"
7336d656433aSmrg	      len=$func_len_result
7337d656433aSmrg	      if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
7338d656433aSmrg		func_show_eval "$cmd" 'exit $?'
7339d656433aSmrg		skipped_export=false
7340d656433aSmrg	      else
7341d656433aSmrg		# The command line is too long to execute in one step.
7342d656433aSmrg		func_verbose "using reloadable object file for export list..."
7343d656433aSmrg		skipped_export=:
7344d656433aSmrg		# Break out early, otherwise skipped_export may be
7345d656433aSmrg		# set to false by a later but shorter cmd.
7346d656433aSmrg		break
7347d656433aSmrg	      fi
7348d656433aSmrg	    done
7349d656433aSmrg	    IFS="$save_ifs"
7350d656433aSmrg	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
7351d656433aSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
7352d656433aSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
7353d656433aSmrg	    fi
7354d656433aSmrg	  fi
7355d656433aSmrg	fi
7356126a8a12Smrg
7357d656433aSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
7358d656433aSmrg	  tmp_export_symbols="$export_symbols"
7359d656433aSmrg	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
7360555991fdSmrg	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
7361d656433aSmrg	fi
7362126a8a12Smrg
7363d656433aSmrg	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
7364d656433aSmrg	  # The given exports_symbols file has to be filtered, so filter it.
7365d656433aSmrg	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
7366d656433aSmrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
7367d656433aSmrg	  # 's' commands which not all seds can handle. GNU sed should be fine
7368d656433aSmrg	  # though. Also, the filter scales superlinearly with the number of
7369d656433aSmrg	  # global variables. join(1) would be nice here, but unfortunately
7370d656433aSmrg	  # isn't a blessed tool.
7371d656433aSmrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
7372d656433aSmrg	  delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
7373d656433aSmrg	  export_symbols=$output_objdir/$libname.def
7374d656433aSmrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
7375126a8a12Smrg	fi
7376126a8a12Smrg
7377d656433aSmrg	tmp_deplibs=
7378d656433aSmrg	for test_deplib in $deplibs; do
7379d656433aSmrg	  case " $convenience " in
7380d656433aSmrg	  *" $test_deplib "*) ;;
7381d656433aSmrg	  *)
7382d656433aSmrg	    tmp_deplibs="$tmp_deplibs $test_deplib"
7383d656433aSmrg	    ;;
7384d656433aSmrg	  esac
7385d656433aSmrg	done
7386d656433aSmrg	deplibs="$tmp_deplibs"
7387126a8a12Smrg
7388d656433aSmrg	if test -n "$convenience"; then
7389d656433aSmrg	  if test -n "$whole_archive_flag_spec" &&
7390d656433aSmrg	    test "$compiler_needs_object" = yes &&
7391d656433aSmrg	    test -z "$libobjs"; then
7392d656433aSmrg	    # extract the archives, so we have objects to list.
7393d656433aSmrg	    # TODO: could optimize this to just extract one archive.
7394d656433aSmrg	    whole_archive_flag_spec=
7395d656433aSmrg	  fi
7396d656433aSmrg	  if test -n "$whole_archive_flag_spec"; then
7397d656433aSmrg	    save_libobjs=$libobjs
7398d656433aSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
7399d656433aSmrg	    test "X$libobjs" = "X " && libobjs=
7400d656433aSmrg	  else
7401d656433aSmrg	    gentop="$output_objdir/${outputname}x"
7402d656433aSmrg	    generated="$generated $gentop"
7403126a8a12Smrg
7404d656433aSmrg	    func_extract_archives $gentop $convenience
7405d656433aSmrg	    libobjs="$libobjs $func_extract_archives_result"
7406d656433aSmrg	    test "X$libobjs" = "X " && libobjs=
7407d656433aSmrg	  fi
7408d656433aSmrg	fi
7409126a8a12Smrg
7410d656433aSmrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
7411d656433aSmrg	  eval flag=\"$thread_safe_flag_spec\"
7412d656433aSmrg	  linker_flags="$linker_flags $flag"
7413d656433aSmrg	fi
7414126a8a12Smrg
7415d656433aSmrg	# Make a backup of the uninstalled library when relinking
7416d656433aSmrg	if test "$mode" = relink; then
7417d656433aSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
7418126a8a12Smrg	fi
7419126a8a12Smrg
7420d656433aSmrg	# Do each of the archive commands.
7421d656433aSmrg	if test "$module" = yes && test -n "$module_cmds" ; then
7422d656433aSmrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
7423d656433aSmrg	    eval test_cmds=\"$module_expsym_cmds\"
7424d656433aSmrg	    cmds=$module_expsym_cmds
7425d656433aSmrg	  else
7426d656433aSmrg	    eval test_cmds=\"$module_cmds\"
7427d656433aSmrg	    cmds=$module_cmds
7428d656433aSmrg	  fi
7429d656433aSmrg	else
7430d656433aSmrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
7431d656433aSmrg	    eval test_cmds=\"$archive_expsym_cmds\"
7432d656433aSmrg	    cmds=$archive_expsym_cmds
7433d656433aSmrg	  else
7434d656433aSmrg	    eval test_cmds=\"$archive_cmds\"
7435d656433aSmrg	    cmds=$archive_cmds
7436d656433aSmrg	  fi
7437126a8a12Smrg	fi
7438126a8a12Smrg
7439d656433aSmrg	if test "X$skipped_export" != "X:" &&
7440d656433aSmrg	   func_len " $test_cmds" &&
7441d656433aSmrg	   len=$func_len_result &&
7442d656433aSmrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
7443d656433aSmrg	  :
7444d656433aSmrg	else
7445d656433aSmrg	  # The command line is too long to link in one step, link piecewise
7446d656433aSmrg	  # or, if using GNU ld and skipped_export is not :, use a linker
7447d656433aSmrg	  # script.
7448126a8a12Smrg
7449d656433aSmrg	  # Save the value of $output and $libobjs because we want to
7450d656433aSmrg	  # use them later.  If we have whole_archive_flag_spec, we
7451d656433aSmrg	  # want to use save_libobjs as it was before
7452d656433aSmrg	  # whole_archive_flag_spec was expanded, because we can't
7453d656433aSmrg	  # assume the linker understands whole_archive_flag_spec.
7454d656433aSmrg	  # This may have to be revisited, in case too many
7455d656433aSmrg	  # convenience libraries get linked in and end up exceeding
7456d656433aSmrg	  # the spec.
7457d656433aSmrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
7458d656433aSmrg	    save_libobjs=$libobjs
7459d656433aSmrg	  fi
7460d656433aSmrg	  save_output=$output
7461555991fdSmrg	  func_basename "$output"
7462555991fdSmrg	  output_la=$func_basename_result
7463126a8a12Smrg
7464d656433aSmrg	  # Clear the reloadable object creation command queue and
7465d656433aSmrg	  # initialize k to one.
7466d656433aSmrg	  test_cmds=
7467d656433aSmrg	  concat_cmds=
7468d656433aSmrg	  objlist=
7469d656433aSmrg	  last_robj=
7470d656433aSmrg	  k=1
7471126a8a12Smrg
7472d656433aSmrg	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
7473d656433aSmrg	    output=${output_objdir}/${output_la}.lnkscript
7474d656433aSmrg	    func_verbose "creating GNU ld script: $output"
7475555991fdSmrg	    echo 'INPUT (' > $output
7476d656433aSmrg	    for obj in $save_libobjs
7477d656433aSmrg	    do
7478d656433aSmrg	      $ECHO "$obj" >> $output
7479d656433aSmrg	    done
7480555991fdSmrg	    echo ')' >> $output
7481d656433aSmrg	    delfiles="$delfiles $output"
7482d656433aSmrg	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
7483d656433aSmrg	    output=${output_objdir}/${output_la}.lnk
7484d656433aSmrg	    func_verbose "creating linker input file list: $output"
7485d656433aSmrg	    : > $output
7486d656433aSmrg	    set x $save_libobjs
7487d656433aSmrg	    shift
7488d656433aSmrg	    firstobj=
7489d656433aSmrg	    if test "$compiler_needs_object" = yes; then
7490d656433aSmrg	      firstobj="$1 "
7491d656433aSmrg	      shift
7492d656433aSmrg	    fi
7493d656433aSmrg	    for obj
7494d656433aSmrg	    do
7495d656433aSmrg	      $ECHO "$obj" >> $output
7496d656433aSmrg	    done
7497d656433aSmrg	    delfiles="$delfiles $output"
7498d656433aSmrg	    output=$firstobj\"$file_list_spec$output\"
7499d656433aSmrg	  else
7500d656433aSmrg	    if test -n "$save_libobjs"; then
7501d656433aSmrg	      func_verbose "creating reloadable object files..."
7502d656433aSmrg	      output=$output_objdir/$output_la-${k}.$objext
7503d656433aSmrg	      eval test_cmds=\"$reload_cmds\"
7504d656433aSmrg	      func_len " $test_cmds"
7505d656433aSmrg	      len0=$func_len_result
7506d656433aSmrg	      len=$len0
7507d656433aSmrg
7508d656433aSmrg	      # Loop over the list of objects to be linked.
7509d656433aSmrg	      for obj in $save_libobjs
7510d656433aSmrg	      do
7511d656433aSmrg		func_len " $obj"
7512d656433aSmrg		func_arith $len + $func_len_result
7513d656433aSmrg		len=$func_arith_result
7514d656433aSmrg		if test "X$objlist" = X ||
7515d656433aSmrg		   test "$len" -lt "$max_cmd_len"; then
7516d656433aSmrg		  func_append objlist " $obj"
7517d656433aSmrg		else
7518d656433aSmrg		  # The command $test_cmds is almost too long, add a
7519d656433aSmrg		  # command to the queue.
7520d656433aSmrg		  if test "$k" -eq 1 ; then
7521d656433aSmrg		    # The first file doesn't have a previous command to add.
7522555991fdSmrg		    reload_objs=$objlist
7523555991fdSmrg		    eval concat_cmds=\"$reload_cmds\"
7524d656433aSmrg		  else
7525d656433aSmrg		    # All subsequent reloadable object files will link in
7526d656433aSmrg		    # the last one created.
7527555991fdSmrg		    reload_objs="$objlist $last_robj"
7528555991fdSmrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
7529d656433aSmrg		  fi
7530d656433aSmrg		  last_robj=$output_objdir/$output_la-${k}.$objext
7531d656433aSmrg		  func_arith $k + 1
7532d656433aSmrg		  k=$func_arith_result
7533d656433aSmrg		  output=$output_objdir/$output_la-${k}.$objext
7534555991fdSmrg		  objlist=" $obj"
7535d656433aSmrg		  func_len " $last_robj"
7536d656433aSmrg		  func_arith $len0 + $func_len_result
7537d656433aSmrg		  len=$func_arith_result
7538d656433aSmrg		fi
7539d656433aSmrg	      done
7540d656433aSmrg	      # Handle the remaining objects by creating one last
7541d656433aSmrg	      # reloadable object file.  All subsequent reloadable object
7542d656433aSmrg	      # files will link in the last one created.
7543d656433aSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
7544555991fdSmrg	      reload_objs="$objlist $last_robj"
7545555991fdSmrg	      eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
7546d656433aSmrg	      if test -n "$last_robj"; then
7547d656433aSmrg	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
7548d656433aSmrg	      fi
7549d656433aSmrg	      delfiles="$delfiles $output"
7550126a8a12Smrg
7551d656433aSmrg	    else
7552d656433aSmrg	      output=
7553d656433aSmrg	    fi
7554d656433aSmrg
7555d656433aSmrg	    if ${skipped_export-false}; then
7556d656433aSmrg	      func_verbose "generating symbol list for \`$libname.la'"
7557d656433aSmrg	      export_symbols="$output_objdir/$libname.exp"
7558d656433aSmrg	      $opt_dry_run || $RM $export_symbols
7559d656433aSmrg	      libobjs=$output
7560d656433aSmrg	      # Append the command to create the export file.
7561d656433aSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
7562d656433aSmrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
7563d656433aSmrg	      if test -n "$last_robj"; then
7564d656433aSmrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
7565d656433aSmrg	      fi
7566d656433aSmrg	    fi
7567126a8a12Smrg
7568d656433aSmrg	    test -n "$save_libobjs" &&
7569d656433aSmrg	      func_verbose "creating a temporary reloadable object file: $output"
7570126a8a12Smrg
7571d656433aSmrg	    # Loop through the commands generated above and execute them.
7572d656433aSmrg	    save_ifs="$IFS"; IFS='~'
7573d656433aSmrg	    for cmd in $concat_cmds; do
7574d656433aSmrg	      IFS="$save_ifs"
7575d656433aSmrg	      $opt_silent || {
7576d656433aSmrg		  func_quote_for_expand "$cmd"
7577d656433aSmrg		  eval "func_echo $func_quote_for_expand_result"
7578d656433aSmrg	      }
7579d656433aSmrg	      $opt_dry_run || eval "$cmd" || {
7580d656433aSmrg		lt_exit=$?
7581d656433aSmrg
7582d656433aSmrg		# Restore the uninstalled library and exit
7583d656433aSmrg		if test "$mode" = relink; then
7584d656433aSmrg		  ( cd "$output_objdir" && \
7585d656433aSmrg		    $RM "${realname}T" && \
7586d656433aSmrg		    $MV "${realname}U" "$realname" )
7587d656433aSmrg		fi
7588126a8a12Smrg
7589d656433aSmrg		exit $lt_exit
7590d656433aSmrg	      }
7591d656433aSmrg	    done
7592d656433aSmrg	    IFS="$save_ifs"
7593126a8a12Smrg
7594d656433aSmrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
7595d656433aSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
7596d656433aSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
7597126a8a12Smrg	    fi
7598126a8a12Smrg	  fi
7599126a8a12Smrg
7600d656433aSmrg          if ${skipped_export-false}; then
7601d656433aSmrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
7602d656433aSmrg	      tmp_export_symbols="$export_symbols"
7603d656433aSmrg	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
7604555991fdSmrg	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
7605d656433aSmrg	    fi
7606126a8a12Smrg
7607d656433aSmrg	    if test -n "$orig_export_symbols"; then
7608d656433aSmrg	      # The given exports_symbols file has to be filtered, so filter it.
7609d656433aSmrg	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
7610d656433aSmrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
7611d656433aSmrg	      # 's' commands which not all seds can handle. GNU sed should be fine
7612d656433aSmrg	      # though. Also, the filter scales superlinearly with the number of
7613d656433aSmrg	      # global variables. join(1) would be nice here, but unfortunately
7614d656433aSmrg	      # isn't a blessed tool.
7615d656433aSmrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
7616d656433aSmrg	      delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
7617d656433aSmrg	      export_symbols=$output_objdir/$libname.def
7618d656433aSmrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
7619d656433aSmrg	    fi
7620d656433aSmrg	  fi
7621126a8a12Smrg
7622d656433aSmrg	  libobjs=$output
7623d656433aSmrg	  # Restore the value of output.
7624d656433aSmrg	  output=$save_output
7625126a8a12Smrg
7626d656433aSmrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
7627d656433aSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
7628d656433aSmrg	    test "X$libobjs" = "X " && libobjs=
7629d656433aSmrg	  fi
7630d656433aSmrg	  # Expand the library linking commands again to reset the
7631d656433aSmrg	  # value of $libobjs for piecewise linking.
7632d656433aSmrg
7633d656433aSmrg	  # Do each of the archive commands.
7634d656433aSmrg	  if test "$module" = yes && test -n "$module_cmds" ; then
7635d656433aSmrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
7636d656433aSmrg	      cmds=$module_expsym_cmds
7637126a8a12Smrg	    else
7638d656433aSmrg	      cmds=$module_cmds
7639126a8a12Smrg	    fi
7640126a8a12Smrg	  else
7641d656433aSmrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
7642d656433aSmrg	      cmds=$archive_expsym_cmds
7643d656433aSmrg	    else
7644d656433aSmrg	      cmds=$archive_cmds
7645d656433aSmrg	    fi
7646126a8a12Smrg	  fi
7647126a8a12Smrg	fi
7648126a8a12Smrg
7649d656433aSmrg	if test -n "$delfiles"; then
7650d656433aSmrg	  # Append the command to remove temporary files to $cmds.
7651d656433aSmrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
7652d656433aSmrg	fi
7653126a8a12Smrg
7654d656433aSmrg	# Add any objects from preloaded convenience libraries
7655d656433aSmrg	if test -n "$dlprefiles"; then
7656d656433aSmrg	  gentop="$output_objdir/${outputname}x"
7657d656433aSmrg	  generated="$generated $gentop"
7658126a8a12Smrg
7659d656433aSmrg	  func_extract_archives $gentop $dlprefiles
7660d656433aSmrg	  libobjs="$libobjs $func_extract_archives_result"
7661d656433aSmrg	  test "X$libobjs" = "X " && libobjs=
7662126a8a12Smrg	fi
7663126a8a12Smrg
7664d656433aSmrg	save_ifs="$IFS"; IFS='~'
7665d656433aSmrg	for cmd in $cmds; do
7666d656433aSmrg	  IFS="$save_ifs"
7667d656433aSmrg	  eval cmd=\"$cmd\"
7668d656433aSmrg	  $opt_silent || {
7669d656433aSmrg	    func_quote_for_expand "$cmd"
7670d656433aSmrg	    eval "func_echo $func_quote_for_expand_result"
7671d656433aSmrg	  }
7672d656433aSmrg	  $opt_dry_run || eval "$cmd" || {
7673d656433aSmrg	    lt_exit=$?
7674126a8a12Smrg
7675d656433aSmrg	    # Restore the uninstalled library and exit
7676d656433aSmrg	    if test "$mode" = relink; then
7677d656433aSmrg	      ( cd "$output_objdir" && \
7678d656433aSmrg	        $RM "${realname}T" && \
7679d656433aSmrg		$MV "${realname}U" "$realname" )
7680126a8a12Smrg	    fi
7681126a8a12Smrg
7682d656433aSmrg	    exit $lt_exit
7683d656433aSmrg	  }
7684d656433aSmrg	done
7685d656433aSmrg	IFS="$save_ifs"
7686126a8a12Smrg
7687d656433aSmrg	# Restore the uninstalled library and exit
7688d656433aSmrg	if test "$mode" = relink; then
7689d656433aSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
7690126a8a12Smrg
7691d656433aSmrg	  if test -n "$convenience"; then
7692d656433aSmrg	    if test -z "$whole_archive_flag_spec"; then
7693d656433aSmrg	      func_show_eval '${RM}r "$gentop"'
7694d656433aSmrg	    fi
7695d656433aSmrg	  fi
7696126a8a12Smrg
7697d656433aSmrg	  exit $EXIT_SUCCESS
7698d656433aSmrg	fi
7699126a8a12Smrg
7700d656433aSmrg	# Create links to the real library.
7701d656433aSmrg	for linkname in $linknames; do
7702d656433aSmrg	  if test "$realname" != "$linkname"; then
7703d656433aSmrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
7704126a8a12Smrg	  fi
7705126a8a12Smrg	done
7706126a8a12Smrg
7707d656433aSmrg	# If -module or -export-dynamic was specified, set the dlname.
7708d656433aSmrg	if test "$module" = yes || test "$export_dynamic" = yes; then
7709d656433aSmrg	  # On all known operating systems, these are identical.
7710d656433aSmrg	  dlname="$soname"
7711d656433aSmrg	fi
7712d656433aSmrg      fi
7713126a8a12Smrg      ;;
7714126a8a12Smrg
7715d656433aSmrg    obj)
7716d656433aSmrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
7717d656433aSmrg	func_warning "\`-dlopen' is ignored for objects"
7718d656433aSmrg      fi
7719126a8a12Smrg
7720d656433aSmrg      case " $deplibs" in
7721d656433aSmrg      *\ -l* | *\ -L*)
7722d656433aSmrg	func_warning "\`-l' and \`-L' are ignored for objects" ;;
7723126a8a12Smrg      esac
7724126a8a12Smrg
7725d656433aSmrg      test -n "$rpath" && \
7726d656433aSmrg	func_warning "\`-rpath' is ignored for objects"
7727126a8a12Smrg
7728d656433aSmrg      test -n "$xrpath" && \
7729d656433aSmrg	func_warning "\`-R' is ignored for objects"
7730126a8a12Smrg
7731d656433aSmrg      test -n "$vinfo" && \
7732d656433aSmrg	func_warning "\`-version-info' is ignored for objects"
7733d656433aSmrg
7734d656433aSmrg      test -n "$release" && \
7735d656433aSmrg	func_warning "\`-release' is ignored for objects"
7736d656433aSmrg
7737d656433aSmrg      case $output in
7738d656433aSmrg      *.lo)
7739d656433aSmrg	test -n "$objs$old_deplibs" && \
7740d656433aSmrg	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
7741d656433aSmrg
7742d656433aSmrg	libobj=$output
7743d656433aSmrg	func_lo2o "$libobj"
7744d656433aSmrg	obj=$func_lo2o_result
7745126a8a12Smrg	;;
7746126a8a12Smrg      *)
7747d656433aSmrg	libobj=
7748d656433aSmrg	obj="$output"
7749126a8a12Smrg	;;
7750126a8a12Smrg      esac
7751126a8a12Smrg
7752d656433aSmrg      # Delete the old objects.
7753d656433aSmrg      $opt_dry_run || $RM $obj $libobj
7754126a8a12Smrg
7755d656433aSmrg      # Objects from convenience libraries.  This assumes
7756d656433aSmrg      # single-version convenience libraries.  Whenever we create
7757d656433aSmrg      # different ones for PIC/non-PIC, this we'll have to duplicate
7758d656433aSmrg      # the extraction.
7759d656433aSmrg      reload_conv_objs=
7760d656433aSmrg      gentop=
7761d656433aSmrg      # reload_cmds runs $LD directly, so let us get rid of
7762d656433aSmrg      # -Wl from whole_archive_flag_spec and hope we can get by with
7763d656433aSmrg      # turning comma into space..
7764d656433aSmrg      wl=
7765126a8a12Smrg
7766d656433aSmrg      if test -n "$convenience"; then
7767d656433aSmrg	if test -n "$whole_archive_flag_spec"; then
7768d656433aSmrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
7769555991fdSmrg	  reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
7770d656433aSmrg	else
7771d656433aSmrg	  gentop="$output_objdir/${obj}x"
7772d656433aSmrg	  generated="$generated $gentop"
7773126a8a12Smrg
7774d656433aSmrg	  func_extract_archives $gentop $convenience
7775d656433aSmrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
7776d656433aSmrg	fi
7777126a8a12Smrg      fi
7778126a8a12Smrg
7779d656433aSmrg      # Create the old-style object.
7780555991fdSmrg      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
7781126a8a12Smrg
7782d656433aSmrg      output="$obj"
7783d656433aSmrg      func_execute_cmds "$reload_cmds" 'exit $?'
7784126a8a12Smrg
7785d656433aSmrg      # Exit if we aren't doing a library object file.
7786d656433aSmrg      if test -z "$libobj"; then
7787d656433aSmrg	if test -n "$gentop"; then
7788d656433aSmrg	  func_show_eval '${RM}r "$gentop"'
7789d656433aSmrg	fi
7790d656433aSmrg
7791d656433aSmrg	exit $EXIT_SUCCESS
7792126a8a12Smrg      fi
7793d656433aSmrg
7794d656433aSmrg      if test "$build_libtool_libs" != yes; then
7795d656433aSmrg	if test -n "$gentop"; then
7796d656433aSmrg	  func_show_eval '${RM}r "$gentop"'
7797d656433aSmrg	fi
7798d656433aSmrg
7799d656433aSmrg	# Create an invalid libtool object if no PIC, so that we don't
7800d656433aSmrg	# accidentally link it into a program.
7801d656433aSmrg	# $show "echo timestamp > $libobj"
7802d656433aSmrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
7803d656433aSmrg	exit $EXIT_SUCCESS
7804d656433aSmrg      fi
7805d656433aSmrg
7806d656433aSmrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
7807d656433aSmrg	# Only do commands if we really have different PIC objects.
7808d656433aSmrg	reload_objs="$libobjs $reload_conv_objs"
7809d656433aSmrg	output="$libobj"
7810d656433aSmrg	func_execute_cmds "$reload_cmds" 'exit $?'
7811d656433aSmrg      fi
7812d656433aSmrg
7813d656433aSmrg      if test -n "$gentop"; then
7814d656433aSmrg	func_show_eval '${RM}r "$gentop"'
7815d656433aSmrg      fi
7816d656433aSmrg
7817d656433aSmrg      exit $EXIT_SUCCESS
7818126a8a12Smrg      ;;
7819126a8a12Smrg
7820d656433aSmrg    prog)
7821d656433aSmrg      case $host in
7822d656433aSmrg	*cygwin*) func_stripname '' '.exe' "$output"
7823d656433aSmrg	          output=$func_stripname_result.exe;;
7824d656433aSmrg      esac
7825d656433aSmrg      test -n "$vinfo" && \
7826d656433aSmrg	func_warning "\`-version-info' is ignored for programs"
7827126a8a12Smrg
7828d656433aSmrg      test -n "$release" && \
7829d656433aSmrg	func_warning "\`-release' is ignored for programs"
7830126a8a12Smrg
7831d656433aSmrg      test "$preload" = yes \
7832d656433aSmrg        && test "$dlopen_support" = unknown \
7833d656433aSmrg	&& test "$dlopen_self" = unknown \
7834d656433aSmrg	&& test "$dlopen_self_static" = unknown && \
7835d656433aSmrg	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
7836d656433aSmrg
7837d656433aSmrg      case $host in
7838d656433aSmrg      *-*-rhapsody* | *-*-darwin1.[012])
7839d656433aSmrg	# On Rhapsody replace the C library is the System framework
7840555991fdSmrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
7841555991fdSmrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
7842126a8a12Smrg	;;
7843d656433aSmrg      esac
7844126a8a12Smrg
7845d656433aSmrg      case $host in
7846d656433aSmrg      *-*-darwin*)
7847d656433aSmrg	# Don't allow lazy linking, it breaks C++ global constructors
7848d656433aSmrg	# But is supposedly fixed on 10.4 or later (yay!).
7849d656433aSmrg	if test "$tagname" = CXX ; then
7850d656433aSmrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
7851d656433aSmrg	    10.[0123])
7852d656433aSmrg	      compile_command="$compile_command ${wl}-bind_at_load"
7853d656433aSmrg	      finalize_command="$finalize_command ${wl}-bind_at_load"
7854d656433aSmrg	    ;;
7855d656433aSmrg	  esac
7856126a8a12Smrg	fi
7857d656433aSmrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
7858555991fdSmrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7859555991fdSmrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7860d656433aSmrg	;;
7861d656433aSmrg      esac
7862126a8a12Smrg
7863126a8a12Smrg
7864d656433aSmrg      # move library search paths that coincide with paths to not yet
7865d656433aSmrg      # installed libraries to the beginning of the library search list
7866d656433aSmrg      new_libs=
7867d656433aSmrg      for path in $notinst_path; do
7868d656433aSmrg	case " $new_libs " in
7869d656433aSmrg	*" -L$path/$objdir "*) ;;
7870d656433aSmrg	*)
7871d656433aSmrg	  case " $compile_deplibs " in
7872d656433aSmrg	  *" -L$path/$objdir "*)
7873d656433aSmrg	    new_libs="$new_libs -L$path/$objdir" ;;
7874126a8a12Smrg	  esac
7875d656433aSmrg	  ;;
7876d656433aSmrg	esac
7877d656433aSmrg      done
7878d656433aSmrg      for deplib in $compile_deplibs; do
7879d656433aSmrg	case $deplib in
7880d656433aSmrg	-L*)
7881d656433aSmrg	  case " $new_libs " in
7882d656433aSmrg	  *" $deplib "*) ;;
7883d656433aSmrg	  *) new_libs="$new_libs $deplib" ;;
7884126a8a12Smrg	  esac
7885d656433aSmrg	  ;;
7886d656433aSmrg	*) new_libs="$new_libs $deplib" ;;
7887d656433aSmrg	esac
7888d656433aSmrg      done
7889d656433aSmrg      compile_deplibs="$new_libs"
7890126a8a12Smrg
7891126a8a12Smrg
7892d656433aSmrg      compile_command="$compile_command $compile_deplibs"
7893d656433aSmrg      finalize_command="$finalize_command $finalize_deplibs"
7894126a8a12Smrg
7895d656433aSmrg      if test -n "$rpath$xrpath"; then
7896d656433aSmrg	# If the user specified any rpath flags, then add them.
7897d656433aSmrg	for libdir in $rpath $xrpath; do
7898d656433aSmrg	  # This is the magic to use -rpath.
7899d656433aSmrg	  case "$finalize_rpath " in
7900d656433aSmrg	  *" $libdir "*) ;;
7901d656433aSmrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
7902d656433aSmrg	  esac
7903d656433aSmrg	done
7904d656433aSmrg      fi
7905126a8a12Smrg
7906d656433aSmrg      # Now hardcode the library paths
7907d656433aSmrg      rpath=
7908d656433aSmrg      hardcode_libdirs=
7909d656433aSmrg      for libdir in $compile_rpath $finalize_rpath; do
7910d656433aSmrg	if test -n "$hardcode_libdir_flag_spec"; then
7911d656433aSmrg	  if test -n "$hardcode_libdir_separator"; then
7912d656433aSmrg	    if test -z "$hardcode_libdirs"; then
7913d656433aSmrg	      hardcode_libdirs="$libdir"
7914d656433aSmrg	    else
7915d656433aSmrg	      # Just accumulate the unique libdirs.
7916d656433aSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
7917d656433aSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
7918d656433aSmrg		;;
7919d656433aSmrg	      *)
7920d656433aSmrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
7921d656433aSmrg		;;
7922d656433aSmrg	      esac
7923d656433aSmrg	    fi
7924126a8a12Smrg	  else
7925d656433aSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
7926d656433aSmrg	    rpath="$rpath $flag"
7927126a8a12Smrg	  fi
7928d656433aSmrg	elif test -n "$runpath_var"; then
7929d656433aSmrg	  case "$perm_rpath " in
7930d656433aSmrg	  *" $libdir "*) ;;
7931d656433aSmrg	  *) perm_rpath="$perm_rpath $libdir" ;;
7932d656433aSmrg	  esac
7933d656433aSmrg	fi
7934d656433aSmrg	case $host in
7935d656433aSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
7936d656433aSmrg	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
7937d656433aSmrg	  case :$dllsearchpath: in
7938d656433aSmrg	  *":$libdir:"*) ;;
7939d656433aSmrg	  ::) dllsearchpath=$libdir;;
7940d656433aSmrg	  *) dllsearchpath="$dllsearchpath:$libdir";;
7941d656433aSmrg	  esac
7942d656433aSmrg	  case :$dllsearchpath: in
7943d656433aSmrg	  *":$testbindir:"*) ;;
7944d656433aSmrg	  ::) dllsearchpath=$testbindir;;
7945d656433aSmrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
7946d656433aSmrg	  esac
7947d656433aSmrg	  ;;
7948d656433aSmrg	esac
7949d656433aSmrg      done
7950d656433aSmrg      # Substitute the hardcoded libdirs into the rpath.
7951d656433aSmrg      if test -n "$hardcode_libdir_separator" &&
7952d656433aSmrg	 test -n "$hardcode_libdirs"; then
7953d656433aSmrg	libdir="$hardcode_libdirs"
7954d656433aSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
7955d656433aSmrg      fi
7956d656433aSmrg      compile_rpath="$rpath"
7957126a8a12Smrg
7958d656433aSmrg      rpath=
7959d656433aSmrg      hardcode_libdirs=
7960d656433aSmrg      for libdir in $finalize_rpath; do
7961d656433aSmrg	if test -n "$hardcode_libdir_flag_spec"; then
7962d656433aSmrg	  if test -n "$hardcode_libdir_separator"; then
7963d656433aSmrg	    if test -z "$hardcode_libdirs"; then
7964d656433aSmrg	      hardcode_libdirs="$libdir"
7965d656433aSmrg	    else
7966d656433aSmrg	      # Just accumulate the unique libdirs.
7967d656433aSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
7968d656433aSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
7969d656433aSmrg		;;
7970d656433aSmrg	      *)
7971d656433aSmrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
7972d656433aSmrg		;;
7973d656433aSmrg	      esac
7974d656433aSmrg	    fi
7975126a8a12Smrg	  else
7976d656433aSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
7977d656433aSmrg	    rpath="$rpath $flag"
7978126a8a12Smrg	  fi
7979d656433aSmrg	elif test -n "$runpath_var"; then
7980d656433aSmrg	  case "$finalize_perm_rpath " in
7981d656433aSmrg	  *" $libdir "*) ;;
7982d656433aSmrg	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
7983d656433aSmrg	  esac
7984126a8a12Smrg	fi
7985d656433aSmrg      done
7986d656433aSmrg      # Substitute the hardcoded libdirs into the rpath.
7987d656433aSmrg      if test -n "$hardcode_libdir_separator" &&
7988d656433aSmrg	 test -n "$hardcode_libdirs"; then
7989d656433aSmrg	libdir="$hardcode_libdirs"
7990d656433aSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
7991d656433aSmrg      fi
7992d656433aSmrg      finalize_rpath="$rpath"
7993126a8a12Smrg
7994d656433aSmrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
7995d656433aSmrg	# Transform all the library objects into standard objects.
7996555991fdSmrg	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
7997555991fdSmrg	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
7998d656433aSmrg      fi
7999126a8a12Smrg
8000d656433aSmrg      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
8001126a8a12Smrg
8002d656433aSmrg      # template prelinking step
8003d656433aSmrg      if test -n "$prelink_cmds"; then
8004d656433aSmrg	func_execute_cmds "$prelink_cmds" 'exit $?'
8005d656433aSmrg      fi
8006126a8a12Smrg
8007d656433aSmrg      wrappers_required=yes
8008d656433aSmrg      case $host in
8009555991fdSmrg      *cegcc* | *mingw32ce*)
8010555991fdSmrg        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
8011555991fdSmrg        wrappers_required=no
8012555991fdSmrg        ;;
8013d656433aSmrg      *cygwin* | *mingw* )
8014d656433aSmrg        if test "$build_libtool_libs" != yes; then
8015d656433aSmrg          wrappers_required=no
8016d656433aSmrg        fi
8017d656433aSmrg        ;;
8018d656433aSmrg      *)
8019d656433aSmrg        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
8020d656433aSmrg          wrappers_required=no
8021d656433aSmrg        fi
8022d656433aSmrg        ;;
8023d656433aSmrg      esac
8024d656433aSmrg      if test "$wrappers_required" = no; then
8025d656433aSmrg	# Replace the output file specification.
8026555991fdSmrg	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
8027d656433aSmrg	link_command="$compile_command$compile_rpath"
8028126a8a12Smrg
8029d656433aSmrg	# We have no uninstalled library dependencies, so finalize right now.
8030d656433aSmrg	exit_status=0
8031d656433aSmrg	func_show_eval "$link_command" 'exit_status=$?'
8032126a8a12Smrg
8033d656433aSmrg	# Delete the generated files.
8034d656433aSmrg	if test -f "$output_objdir/${outputname}S.${objext}"; then
8035d656433aSmrg	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
8036126a8a12Smrg	fi
8037126a8a12Smrg
8038d656433aSmrg	exit $exit_status
8039d656433aSmrg      fi
8040126a8a12Smrg
8041d656433aSmrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
8042d656433aSmrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
8043d656433aSmrg      fi
8044d656433aSmrg      if test -n "$finalize_shlibpath"; then
8045d656433aSmrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
8046d656433aSmrg      fi
8047126a8a12Smrg
8048d656433aSmrg      compile_var=
8049d656433aSmrg      finalize_var=
8050d656433aSmrg      if test -n "$runpath_var"; then
8051d656433aSmrg	if test -n "$perm_rpath"; then
8052d656433aSmrg	  # We should set the runpath_var.
8053d656433aSmrg	  rpath=
8054d656433aSmrg	  for dir in $perm_rpath; do
8055d656433aSmrg	    rpath="$rpath$dir:"
8056d656433aSmrg	  done
8057d656433aSmrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
8058126a8a12Smrg	fi
8059d656433aSmrg	if test -n "$finalize_perm_rpath"; then
8060d656433aSmrg	  # We should set the runpath_var.
8061d656433aSmrg	  rpath=
8062d656433aSmrg	  for dir in $finalize_perm_rpath; do
8063d656433aSmrg	    rpath="$rpath$dir:"
8064d656433aSmrg	  done
8065d656433aSmrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
8066126a8a12Smrg	fi
8067d656433aSmrg      fi
8068126a8a12Smrg
8069d656433aSmrg      if test "$no_install" = yes; then
8070d656433aSmrg	# We don't need to create a wrapper script.
8071d656433aSmrg	link_command="$compile_var$compile_command$compile_rpath"
8072d656433aSmrg	# Replace the output file specification.
8073555991fdSmrg	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
8074d656433aSmrg	# Delete the old output file.
8075d656433aSmrg	$opt_dry_run || $RM $output
8076d656433aSmrg	# Link the executable and exit
8077d656433aSmrg	func_show_eval "$link_command" 'exit $?'
8078126a8a12Smrg	exit $EXIT_SUCCESS
8079d656433aSmrg      fi
8080126a8a12Smrg
8081d656433aSmrg      if test "$hardcode_action" = relink; then
8082d656433aSmrg	# Fast installation is not supported
8083d656433aSmrg	link_command="$compile_var$compile_command$compile_rpath"
8084d656433aSmrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
8085d656433aSmrg
8086d656433aSmrg	func_warning "this platform does not like uninstalled shared libraries"
8087d656433aSmrg	func_warning "\`$output' will be relinked during installation"
8088d656433aSmrg      else
8089d656433aSmrg	if test "$fast_install" != no; then
8090d656433aSmrg	  link_command="$finalize_var$compile_command$finalize_rpath"
8091d656433aSmrg	  if test "$fast_install" = yes; then
8092555991fdSmrg	    relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
8093d656433aSmrg	  else
8094d656433aSmrg	    # fast_install is set to needless
8095d656433aSmrg	    relink_command=
8096d656433aSmrg	  fi
8097126a8a12Smrg	else
8098d656433aSmrg	  link_command="$compile_var$compile_command$compile_rpath"
8099d656433aSmrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
8100126a8a12Smrg	fi
8101d656433aSmrg      fi
8102126a8a12Smrg
8103d656433aSmrg      # Replace the output file specification.
8104555991fdSmrg      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
8105126a8a12Smrg
8106d656433aSmrg      # Delete the old output files.
8107d656433aSmrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
8108126a8a12Smrg
8109d656433aSmrg      func_show_eval "$link_command" 'exit $?'
8110126a8a12Smrg
8111d656433aSmrg      # Now create the wrapper script.
8112d656433aSmrg      func_verbose "creating $output"
8113126a8a12Smrg
8114d656433aSmrg      # Quote the relink command for shipping.
8115d656433aSmrg      if test -n "$relink_command"; then
8116d656433aSmrg	# Preserve any variables that may affect compiler behavior
8117d656433aSmrg	for var in $variables_saved_for_relink; do
8118d656433aSmrg	  if eval test -z \"\${$var+set}\"; then
8119d656433aSmrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
8120d656433aSmrg	  elif eval var_value=\$$var; test -z "$var_value"; then
8121d656433aSmrg	    relink_command="$var=; export $var; $relink_command"
8122126a8a12Smrg	  else
8123d656433aSmrg	    func_quote_for_eval "$var_value"
8124d656433aSmrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
8125126a8a12Smrg	  fi
8126d656433aSmrg	done
8127d656433aSmrg	relink_command="(cd `pwd`; $relink_command)"
8128555991fdSmrg	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
8129d656433aSmrg      fi
8130d656433aSmrg
8131d656433aSmrg      # Only actually do things if not in dry run mode.
8132d656433aSmrg      $opt_dry_run || {
8133d656433aSmrg	# win32 will think the script is a binary if it has
8134d656433aSmrg	# a .exe suffix, so we strip it off here.
8135d656433aSmrg	case $output in
8136d656433aSmrg	  *.exe) func_stripname '' '.exe' "$output"
8137d656433aSmrg	         output=$func_stripname_result ;;
8138d656433aSmrg	esac
8139d656433aSmrg	# test for cygwin because mv fails w/o .exe extensions
8140d656433aSmrg	case $host in
8141d656433aSmrg	  *cygwin*)
8142d656433aSmrg	    exeext=.exe
8143d656433aSmrg	    func_stripname '' '.exe' "$outputname"
8144d656433aSmrg	    outputname=$func_stripname_result ;;
8145d656433aSmrg	  *) exeext= ;;
8146126a8a12Smrg	esac
8147d656433aSmrg	case $host in
8148d656433aSmrg	  *cygwin* | *mingw* )
8149d656433aSmrg	    func_dirname_and_basename "$output" "" "."
8150d656433aSmrg	    output_name=$func_basename_result
8151d656433aSmrg	    output_path=$func_dirname_result
8152d656433aSmrg	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
8153d656433aSmrg	    cwrapper="$output_path/$output_name.exe"
8154d656433aSmrg	    $RM $cwrappersource $cwrapper
8155d656433aSmrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
8156d656433aSmrg
8157d656433aSmrg	    func_emit_cwrapperexe_src > $cwrappersource
8158d656433aSmrg
8159d656433aSmrg	    # The wrapper executable is built using the $host compiler,
8160d656433aSmrg	    # because it contains $host paths and files. If cross-
8161d656433aSmrg	    # compiling, it, like the target executable, must be
8162d656433aSmrg	    # executed on the $host or under an emulation environment.
8163d656433aSmrg	    $opt_dry_run || {
8164d656433aSmrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
8165d656433aSmrg	      $STRIP $cwrapper
8166d656433aSmrg	    }
8167126a8a12Smrg
8168d656433aSmrg	    # Now, create the wrapper script for func_source use:
8169d656433aSmrg	    func_ltwrapper_scriptname $cwrapper
8170d656433aSmrg	    $RM $func_ltwrapper_scriptname_result
8171d656433aSmrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
8172d656433aSmrg	    $opt_dry_run || {
8173d656433aSmrg	      # note: this script will not be executed, so do not chmod.
8174d656433aSmrg	      if test "x$build" = "x$host" ; then
8175d656433aSmrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
8176d656433aSmrg	      else
8177d656433aSmrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
8178d656433aSmrg	      fi
8179d656433aSmrg	    }
8180d656433aSmrg	  ;;
8181d656433aSmrg	  * )
8182d656433aSmrg	    $RM $output
8183d656433aSmrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
8184126a8a12Smrg
8185d656433aSmrg	    func_emit_wrapper no > $output
8186d656433aSmrg	    chmod +x $output
8187d656433aSmrg	  ;;
8188d656433aSmrg	esac
8189d656433aSmrg      }
8190d656433aSmrg      exit $EXIT_SUCCESS
8191d656433aSmrg      ;;
8192d656433aSmrg    esac
8193126a8a12Smrg
8194d656433aSmrg    # See if we need to build an old-fashioned archive.
8195d656433aSmrg    for oldlib in $oldlibs; do
8196126a8a12Smrg
8197d656433aSmrg      if test "$build_libtool_libs" = convenience; then
8198d656433aSmrg	oldobjs="$libobjs_save $symfileobj"
8199d656433aSmrg	addlibs="$convenience"
8200d656433aSmrg	build_libtool_libs=no
8201d656433aSmrg      else
8202d656433aSmrg	if test "$build_libtool_libs" = module; then
8203d656433aSmrg	  oldobjs="$libobjs_save"
8204d656433aSmrg	  build_libtool_libs=no
8205d656433aSmrg	else
8206d656433aSmrg	  oldobjs="$old_deplibs $non_pic_objects"
8207d656433aSmrg	  if test "$preload" = yes && test -f "$symfileobj"; then
8208d656433aSmrg	    oldobjs="$oldobjs $symfileobj"
8209d656433aSmrg	  fi
8210d656433aSmrg	fi
8211d656433aSmrg	addlibs="$old_convenience"
8212126a8a12Smrg      fi
8213126a8a12Smrg
8214d656433aSmrg      if test -n "$addlibs"; then
8215d656433aSmrg	gentop="$output_objdir/${outputname}x"
8216d656433aSmrg	generated="$generated $gentop"
8217126a8a12Smrg
8218d656433aSmrg	func_extract_archives $gentop $addlibs
8219d656433aSmrg	oldobjs="$oldobjs $func_extract_archives_result"
8220d656433aSmrg      fi
8221126a8a12Smrg
8222d656433aSmrg      # Do each command in the archive commands.
8223d656433aSmrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
8224d656433aSmrg	cmds=$old_archive_from_new_cmds
8225d656433aSmrg      else
8226126a8a12Smrg
8227d656433aSmrg	# Add any objects from preloaded convenience libraries
8228d656433aSmrg	if test -n "$dlprefiles"; then
8229d656433aSmrg	  gentop="$output_objdir/${outputname}x"
8230d656433aSmrg	  generated="$generated $gentop"
8231126a8a12Smrg
8232d656433aSmrg	  func_extract_archives $gentop $dlprefiles
8233d656433aSmrg	  oldobjs="$oldobjs $func_extract_archives_result"
8234d656433aSmrg	fi
8235126a8a12Smrg
8236d656433aSmrg	# POSIX demands no paths to be encoded in archives.  We have
8237d656433aSmrg	# to avoid creating archives with duplicate basenames if we
8238d656433aSmrg	# might have to extract them afterwards, e.g., when creating a
8239d656433aSmrg	# static archive out of a convenience library, or when linking
8240d656433aSmrg	# the entirety of a libtool archive into another (currently
8241d656433aSmrg	# not supported by libtool).
8242d656433aSmrg	if (for obj in $oldobjs
8243d656433aSmrg	    do
8244d656433aSmrg	      func_basename "$obj"
8245d656433aSmrg	      $ECHO "$func_basename_result"
8246d656433aSmrg	    done | sort | sort -uc >/dev/null 2>&1); then
8247d656433aSmrg	  :
8248d656433aSmrg	else
8249555991fdSmrg	  echo "copying selected object files to avoid basename conflicts..."
8250d656433aSmrg	  gentop="$output_objdir/${outputname}x"
8251d656433aSmrg	  generated="$generated $gentop"
8252d656433aSmrg	  func_mkdir_p "$gentop"
8253d656433aSmrg	  save_oldobjs=$oldobjs
8254d656433aSmrg	  oldobjs=
8255d656433aSmrg	  counter=1
8256d656433aSmrg	  for obj in $save_oldobjs
8257d656433aSmrg	  do
8258d656433aSmrg	    func_basename "$obj"
8259d656433aSmrg	    objbase="$func_basename_result"
8260d656433aSmrg	    case " $oldobjs " in
8261d656433aSmrg	    " ") oldobjs=$obj ;;
8262d656433aSmrg	    *[\ /]"$objbase "*)
8263d656433aSmrg	      while :; do
8264d656433aSmrg		# Make sure we don't pick an alternate name that also
8265d656433aSmrg		# overlaps.
8266d656433aSmrg		newobj=lt$counter-$objbase
8267d656433aSmrg		func_arith $counter + 1
8268d656433aSmrg		counter=$func_arith_result
8269d656433aSmrg		case " $oldobjs " in
8270d656433aSmrg		*[\ /]"$newobj "*) ;;
8271d656433aSmrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
8272d656433aSmrg		esac
8273d656433aSmrg	      done
8274d656433aSmrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
8275d656433aSmrg	      oldobjs="$oldobjs $gentop/$newobj"
8276d656433aSmrg	      ;;
8277d656433aSmrg	    *) oldobjs="$oldobjs $obj" ;;
8278d656433aSmrg	    esac
8279126a8a12Smrg	  done
8280126a8a12Smrg	fi
8281d656433aSmrg	eval cmds=\"$old_archive_cmds\"
8282126a8a12Smrg
8283d656433aSmrg	func_len " $cmds"
8284d656433aSmrg	len=$func_len_result
8285d656433aSmrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
8286d656433aSmrg	  cmds=$old_archive_cmds
8287d656433aSmrg	else
8288d656433aSmrg	  # the command line is too long to link in one step, link in parts
8289d656433aSmrg	  func_verbose "using piecewise archive linking..."
8290d656433aSmrg	  save_RANLIB=$RANLIB
8291d656433aSmrg	  RANLIB=:
8292d656433aSmrg	  objlist=
8293d656433aSmrg	  concat_cmds=
8294d656433aSmrg	  save_oldobjs=$oldobjs
8295d656433aSmrg	  oldobjs=
8296d656433aSmrg	  # Is there a better way of finding the last object in the list?
8297d656433aSmrg	  for obj in $save_oldobjs
8298d656433aSmrg	  do
8299d656433aSmrg	    last_oldobj=$obj
8300d656433aSmrg	  done
8301d656433aSmrg	  eval test_cmds=\"$old_archive_cmds\"
8302d656433aSmrg	  func_len " $test_cmds"
8303d656433aSmrg	  len0=$func_len_result
8304d656433aSmrg	  len=$len0
8305d656433aSmrg	  for obj in $save_oldobjs
8306d656433aSmrg	  do
8307d656433aSmrg	    func_len " $obj"
8308d656433aSmrg	    func_arith $len + $func_len_result
8309d656433aSmrg	    len=$func_arith_result
8310d656433aSmrg	    func_append objlist " $obj"
8311d656433aSmrg	    if test "$len" -lt "$max_cmd_len"; then
8312d656433aSmrg	      :
8313d656433aSmrg	    else
8314d656433aSmrg	      # the above command should be used before it gets too long
8315d656433aSmrg	      oldobjs=$objlist
8316d656433aSmrg	      if test "$obj" = "$last_oldobj" ; then
8317d656433aSmrg		RANLIB=$save_RANLIB
8318d656433aSmrg	      fi
8319d656433aSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8320d656433aSmrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
8321d656433aSmrg	      objlist=
8322d656433aSmrg	      len=$len0
8323d656433aSmrg	    fi
8324d656433aSmrg	  done
8325d656433aSmrg	  RANLIB=$save_RANLIB
8326d656433aSmrg	  oldobjs=$objlist
8327d656433aSmrg	  if test "X$oldobjs" = "X" ; then
8328d656433aSmrg	    eval cmds=\"\$concat_cmds\"
8329d656433aSmrg	  else
8330d656433aSmrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
8331d656433aSmrg	  fi
8332d656433aSmrg	fi
8333d656433aSmrg      fi
8334d656433aSmrg      func_execute_cmds "$cmds" 'exit $?'
8335126a8a12Smrg    done
8336126a8a12Smrg
8337d656433aSmrg    test -n "$generated" && \
8338d656433aSmrg      func_show_eval "${RM}r$generated"
8339126a8a12Smrg
8340d656433aSmrg    # Now create the libtool archive.
8341d656433aSmrg    case $output in
8342d656433aSmrg    *.la)
8343d656433aSmrg      old_library=
8344d656433aSmrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
8345d656433aSmrg      func_verbose "creating $output"
8346126a8a12Smrg
8347d656433aSmrg      # Preserve any variables that may affect compiler behavior
8348d656433aSmrg      for var in $variables_saved_for_relink; do
8349d656433aSmrg	if eval test -z \"\${$var+set}\"; then
8350d656433aSmrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
8351d656433aSmrg	elif eval var_value=\$$var; test -z "$var_value"; then
8352d656433aSmrg	  relink_command="$var=; export $var; $relink_command"
8353126a8a12Smrg	else
8354d656433aSmrg	  func_quote_for_eval "$var_value"
8355d656433aSmrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
8356126a8a12Smrg	fi
8357d656433aSmrg      done
8358d656433aSmrg      # Quote the link command for shipping.
8359d656433aSmrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
8360555991fdSmrg      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
8361d656433aSmrg      if test "$hardcode_automatic" = yes ; then
8362d656433aSmrg	relink_command=
8363d656433aSmrg      fi
8364126a8a12Smrg
8365d656433aSmrg      # Only create the output if not a dry run.
8366d656433aSmrg      $opt_dry_run || {
8367d656433aSmrg	for installed in no yes; do
8368d656433aSmrg	  if test "$installed" = yes; then
8369d656433aSmrg	    if test -z "$install_libdir"; then
8370d656433aSmrg	      break
8371d656433aSmrg	    fi
8372d656433aSmrg	    output="$output_objdir/$outputname"i
8373d656433aSmrg	    # Replace all uninstalled libtool libraries with the installed ones
8374d656433aSmrg	    newdependency_libs=
8375d656433aSmrg	    for deplib in $dependency_libs; do
8376d656433aSmrg	      case $deplib in
8377d656433aSmrg	      *.la)
8378d656433aSmrg		func_basename "$deplib"
8379d656433aSmrg		name="$func_basename_result"
8380d656433aSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
8381d656433aSmrg		test -z "$libdir" && \
8382d656433aSmrg		  func_fatal_error "\`$deplib' is not a valid libtool archive"
8383555991fdSmrg		newdependency_libs="$newdependency_libs $libdir/$name"
8384d656433aSmrg		;;
8385555991fdSmrg	      *) newdependency_libs="$newdependency_libs $deplib" ;;
8386d656433aSmrg	      esac
8387d656433aSmrg	    done
8388d656433aSmrg	    dependency_libs="$newdependency_libs"
8389d656433aSmrg	    newdlfiles=
8390d656433aSmrg
8391d656433aSmrg	    for lib in $dlfiles; do
8392d656433aSmrg	      case $lib in
8393d656433aSmrg	      *.la)
8394d656433aSmrg	        func_basename "$lib"
8395d656433aSmrg		name="$func_basename_result"
8396d656433aSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
8397d656433aSmrg		test -z "$libdir" && \
8398d656433aSmrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
8399d656433aSmrg		newdlfiles="$newdlfiles $libdir/$name"
8400d656433aSmrg		;;
8401d656433aSmrg	      *) newdlfiles="$newdlfiles $lib" ;;
8402d656433aSmrg	      esac
8403d656433aSmrg	    done
8404d656433aSmrg	    dlfiles="$newdlfiles"
8405d656433aSmrg	    newdlprefiles=
8406d656433aSmrg	    for lib in $dlprefiles; do
8407d656433aSmrg	      case $lib in
8408d656433aSmrg	      *.la)
8409d656433aSmrg		# Only pass preopened files to the pseudo-archive (for
8410d656433aSmrg		# eventual linking with the app. that links it) if we
8411d656433aSmrg		# didn't already link the preopened objects directly into
8412d656433aSmrg		# the library:
8413d656433aSmrg		func_basename "$lib"
8414d656433aSmrg		name="$func_basename_result"
8415d656433aSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
8416d656433aSmrg		test -z "$libdir" && \
8417d656433aSmrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
8418d656433aSmrg		newdlprefiles="$newdlprefiles $libdir/$name"
8419d656433aSmrg		;;
8420d656433aSmrg	      esac
8421d656433aSmrg	    done
8422d656433aSmrg	    dlprefiles="$newdlprefiles"
8423d656433aSmrg	  else
8424d656433aSmrg	    newdlfiles=
8425d656433aSmrg	    for lib in $dlfiles; do
8426d656433aSmrg	      case $lib in
8427d656433aSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
8428d656433aSmrg		*) abs=`pwd`"/$lib" ;;
8429d656433aSmrg	      esac
8430d656433aSmrg	      newdlfiles="$newdlfiles $abs"
8431d656433aSmrg	    done
8432d656433aSmrg	    dlfiles="$newdlfiles"
8433d656433aSmrg	    newdlprefiles=
8434d656433aSmrg	    for lib in $dlprefiles; do
8435d656433aSmrg	      case $lib in
8436d656433aSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
8437d656433aSmrg		*) abs=`pwd`"/$lib" ;;
8438d656433aSmrg	      esac
8439d656433aSmrg	      newdlprefiles="$newdlprefiles $abs"
8440d656433aSmrg	    done
8441d656433aSmrg	    dlprefiles="$newdlprefiles"
8442d656433aSmrg	  fi
8443d656433aSmrg	  $RM $output
8444d656433aSmrg	  # place dlname in correct position for cygwin
8445555991fdSmrg	  # In fact, it would be nice if we could use this code for all target
8446555991fdSmrg	  # systems that can't hard-code library paths into their executables
8447555991fdSmrg	  # and that have no shared library path variable independent of PATH,
8448555991fdSmrg	  # but it turns out we can't easily determine that from inspecting
8449555991fdSmrg	  # libtool variables, so we have to hard-code the OSs to which it
8450555991fdSmrg	  # applies here; at the moment, that means platforms that use the PE
8451555991fdSmrg	  # object format with DLL files.  See the long comment at the top of
8452555991fdSmrg	  # tests/bindir.at for full details.
8453d656433aSmrg	  tdlname=$dlname
8454d656433aSmrg	  case $host,$output,$installed,$module,$dlname in
8455555991fdSmrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
8456555991fdSmrg	      # If a -bindir argument was supplied, place the dll there.
8457555991fdSmrg	      if test "x$bindir" != x ;
8458555991fdSmrg	      then
8459555991fdSmrg		func_relative_path "$install_libdir" "$bindir"
8460555991fdSmrg		tdlname=$func_relative_path_result$dlname
8461555991fdSmrg	      else
8462555991fdSmrg		# Otherwise fall back on heuristic.
8463555991fdSmrg		tdlname=../bin/$dlname
8464555991fdSmrg	      fi
8465555991fdSmrg	      ;;
8466d656433aSmrg	  esac
8467d656433aSmrg	  $ECHO > $output "\
8468d656433aSmrg# $outputname - a libtool library file
8469d656433aSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
8470d656433aSmrg#
8471d656433aSmrg# Please DO NOT delete this file!
8472d656433aSmrg# It is necessary for linking the library.
8473126a8a12Smrg
8474d656433aSmrg# The name that we can dlopen(3).
8475d656433aSmrgdlname='$tdlname'
8476126a8a12Smrg
8477d656433aSmrg# Names of this library.
8478d656433aSmrglibrary_names='$library_names'
8479126a8a12Smrg
8480d656433aSmrg# The name of the static archive.
8481d656433aSmrgold_library='$old_library'
8482126a8a12Smrg
8483d656433aSmrg# Linker flags that can not go in dependency_libs.
8484d656433aSmrginherited_linker_flags='$new_inherited_linker_flags'
8485126a8a12Smrg
8486d656433aSmrg# Libraries that this one depends upon.
8487d656433aSmrgdependency_libs='$dependency_libs'
8488126a8a12Smrg
8489d656433aSmrg# Names of additional weak libraries provided by this library
8490d656433aSmrgweak_library_names='$weak_libs'
8491126a8a12Smrg
8492d656433aSmrg# Version information for $libname.
8493d656433aSmrgcurrent=$current
8494d656433aSmrgage=$age
8495d656433aSmrgrevision=$revision
8496126a8a12Smrg
8497d656433aSmrg# Is this an already installed library?
8498d656433aSmrginstalled=$installed
8499126a8a12Smrg
8500d656433aSmrg# Should we warn about portability when linking against -modules?
8501d656433aSmrgshouldnotlink=$module
8502126a8a12Smrg
8503d656433aSmrg# Files to dlopen/dlpreopen
8504d656433aSmrgdlopen='$dlfiles'
8505d656433aSmrgdlpreopen='$dlprefiles'
8506126a8a12Smrg
8507d656433aSmrg# Directory that this library needs to be installed in:
8508d656433aSmrglibdir='$install_libdir'"
8509d656433aSmrg	  if test "$installed" = no && test "$need_relink" = yes; then
8510d656433aSmrg	    $ECHO >> $output "\
8511d656433aSmrgrelink_command=\"$relink_command\""
8512d656433aSmrg	  fi
8513d656433aSmrg	done
8514d656433aSmrg      }
8515126a8a12Smrg
8516d656433aSmrg      # Do a symbolic link so that the libtool archive can be found in
8517d656433aSmrg      # LD_LIBRARY_PATH before the program is installed.
8518d656433aSmrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
8519d656433aSmrg      ;;
8520d656433aSmrg    esac
8521d656433aSmrg    exit $EXIT_SUCCESS
8522d656433aSmrg}
8523126a8a12Smrg
8524d656433aSmrg{ test "$mode" = link || test "$mode" = relink; } &&
8525d656433aSmrg    func_mode_link ${1+"$@"}
8526126a8a12Smrg
8527126a8a12Smrg
8528d656433aSmrg# func_mode_uninstall arg...
8529d656433aSmrgfunc_mode_uninstall ()
8530d656433aSmrg{
8531d656433aSmrg    $opt_debug
8532d656433aSmrg    RM="$nonopt"
8533126a8a12Smrg    files=
8534126a8a12Smrg    rmforce=
8535126a8a12Smrg    exit_status=0
8536126a8a12Smrg
8537126a8a12Smrg    # This variable tells wrapper scripts just to set variables rather
8538126a8a12Smrg    # than running their programs.
8539126a8a12Smrg    libtool_install_magic="$magic"
8540126a8a12Smrg
8541126a8a12Smrg    for arg
8542126a8a12Smrg    do
8543126a8a12Smrg      case $arg in
8544d656433aSmrg      -f) RM="$RM $arg"; rmforce=yes ;;
8545d656433aSmrg      -*) RM="$RM $arg" ;;
8546126a8a12Smrg      *) files="$files $arg" ;;
8547126a8a12Smrg      esac
8548126a8a12Smrg    done
8549126a8a12Smrg
8550d656433aSmrg    test -z "$RM" && \
8551d656433aSmrg      func_fatal_help "you must specify an RM program"
8552126a8a12Smrg
8553126a8a12Smrg    rmdirs=
8554126a8a12Smrg
8555126a8a12Smrg    origobjdir="$objdir"
8556126a8a12Smrg    for file in $files; do
8557d656433aSmrg      func_dirname "$file" "" "."
8558d656433aSmrg      dir="$func_dirname_result"
8559d656433aSmrg      if test "X$dir" = X.; then
8560126a8a12Smrg	objdir="$origobjdir"
8561126a8a12Smrg      else
8562126a8a12Smrg	objdir="$dir/$origobjdir"
8563126a8a12Smrg      fi
8564d656433aSmrg      func_basename "$file"
8565d656433aSmrg      name="$func_basename_result"
8566126a8a12Smrg      test "$mode" = uninstall && objdir="$dir"
8567126a8a12Smrg
8568126a8a12Smrg      # Remember objdir for removal later, being careful to avoid duplicates
8569126a8a12Smrg      if test "$mode" = clean; then
8570126a8a12Smrg	case " $rmdirs " in
8571126a8a12Smrg	  *" $objdir "*) ;;
8572126a8a12Smrg	  *) rmdirs="$rmdirs $objdir" ;;
8573126a8a12Smrg	esac
8574126a8a12Smrg      fi
8575126a8a12Smrg
8576126a8a12Smrg      # Don't error if the file doesn't exist and rm -f was used.
8577d656433aSmrg      if { test -L "$file"; } >/dev/null 2>&1 ||
8578d656433aSmrg	 { test -h "$file"; } >/dev/null 2>&1 ||
8579d656433aSmrg	 test -f "$file"; then
8580126a8a12Smrg	:
8581126a8a12Smrg      elif test -d "$file"; then
8582126a8a12Smrg	exit_status=1
8583126a8a12Smrg	continue
8584126a8a12Smrg      elif test "$rmforce" = yes; then
8585126a8a12Smrg	continue
8586126a8a12Smrg      fi
8587126a8a12Smrg
8588126a8a12Smrg      rmfiles="$file"
8589126a8a12Smrg
8590126a8a12Smrg      case $name in
8591126a8a12Smrg      *.la)
8592126a8a12Smrg	# Possibly a libtool archive, so verify it.
8593d656433aSmrg	if func_lalib_p "$file"; then
8594d656433aSmrg	  func_source $dir/$name
8595126a8a12Smrg
8596126a8a12Smrg	  # Delete the libtool libraries and symlinks.
8597126a8a12Smrg	  for n in $library_names; do
8598126a8a12Smrg	    rmfiles="$rmfiles $objdir/$n"
8599126a8a12Smrg	  done
8600126a8a12Smrg	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
8601126a8a12Smrg
8602126a8a12Smrg	  case "$mode" in
8603126a8a12Smrg	  clean)
8604126a8a12Smrg	    case "  $library_names " in
8605126a8a12Smrg	    # "  " in the beginning catches empty $dlname
8606126a8a12Smrg	    *" $dlname "*) ;;
8607126a8a12Smrg	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
8608126a8a12Smrg	    esac
8609d656433aSmrg	    test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
8610126a8a12Smrg	    ;;
8611126a8a12Smrg	  uninstall)
8612126a8a12Smrg	    if test -n "$library_names"; then
8613126a8a12Smrg	      # Do each command in the postuninstall commands.
8614d656433aSmrg	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
8615126a8a12Smrg	    fi
8616126a8a12Smrg
8617126a8a12Smrg	    if test -n "$old_library"; then
8618126a8a12Smrg	      # Do each command in the old_postuninstall commands.
8619d656433aSmrg	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
8620126a8a12Smrg	    fi
8621126a8a12Smrg	    # FIXME: should reinstall the best remaining shared library.
8622126a8a12Smrg	    ;;
8623126a8a12Smrg	  esac
8624126a8a12Smrg	fi
8625126a8a12Smrg	;;
8626126a8a12Smrg
8627126a8a12Smrg      *.lo)
8628126a8a12Smrg	# Possibly a libtool object, so verify it.
8629d656433aSmrg	if func_lalib_p "$file"; then
8630126a8a12Smrg
8631126a8a12Smrg	  # Read the .lo file
8632d656433aSmrg	  func_source $dir/$name
8633126a8a12Smrg
8634126a8a12Smrg	  # Add PIC object to the list of files to remove.
8635d656433aSmrg	  if test -n "$pic_object" &&
8636d656433aSmrg	     test "$pic_object" != none; then
8637126a8a12Smrg	    rmfiles="$rmfiles $dir/$pic_object"
8638126a8a12Smrg	  fi
8639126a8a12Smrg
8640126a8a12Smrg	  # Add non-PIC object to the list of files to remove.
8641d656433aSmrg	  if test -n "$non_pic_object" &&
8642d656433aSmrg	     test "$non_pic_object" != none; then
8643126a8a12Smrg	    rmfiles="$rmfiles $dir/$non_pic_object"
8644126a8a12Smrg	  fi
8645126a8a12Smrg	fi
8646126a8a12Smrg	;;
8647126a8a12Smrg
8648126a8a12Smrg      *)
8649126a8a12Smrg	if test "$mode" = clean ; then
8650126a8a12Smrg	  noexename=$name
8651126a8a12Smrg	  case $file in
8652126a8a12Smrg	  *.exe)
8653d656433aSmrg	    func_stripname '' '.exe' "$file"
8654d656433aSmrg	    file=$func_stripname_result
8655d656433aSmrg	    func_stripname '' '.exe' "$name"
8656d656433aSmrg	    noexename=$func_stripname_result
8657126a8a12Smrg	    # $file with .exe has already been added to rmfiles,
8658126a8a12Smrg	    # add $file without .exe
8659126a8a12Smrg	    rmfiles="$rmfiles $file"
8660126a8a12Smrg	    ;;
8661126a8a12Smrg	  esac
8662126a8a12Smrg	  # Do a test to see if this is a libtool program.
8663d656433aSmrg	  if func_ltwrapper_p "$file"; then
8664d656433aSmrg	    if func_ltwrapper_executable_p "$file"; then
8665d656433aSmrg	      func_ltwrapper_scriptname "$file"
8666d656433aSmrg	      relink_command=
8667d656433aSmrg	      func_source $func_ltwrapper_scriptname_result
8668d656433aSmrg	      rmfiles="$rmfiles $func_ltwrapper_scriptname_result"
8669d656433aSmrg	    else
8670d656433aSmrg	      relink_command=
8671d656433aSmrg	      func_source $dir/$noexename
8672d656433aSmrg	    fi
8673126a8a12Smrg
8674126a8a12Smrg	    # note $name still contains .exe if it was in $file originally
8675126a8a12Smrg	    # as does the version of $file that was added into $rmfiles
8676126a8a12Smrg	    rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
8677126a8a12Smrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
8678126a8a12Smrg	      rmfiles="$rmfiles $objdir/lt-$name"
8679126a8a12Smrg	    fi
8680126a8a12Smrg	    if test "X$noexename" != "X$name" ; then
8681126a8a12Smrg	      rmfiles="$rmfiles $objdir/lt-${noexename}.c"
8682126a8a12Smrg	    fi
8683126a8a12Smrg	  fi
8684126a8a12Smrg	fi
8685126a8a12Smrg	;;
8686126a8a12Smrg      esac
8687d656433aSmrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
8688126a8a12Smrg    done
8689126a8a12Smrg    objdir="$origobjdir"
8690126a8a12Smrg
8691126a8a12Smrg    # Try to remove the ${objdir}s in the directories where we deleted files
8692126a8a12Smrg    for dir in $rmdirs; do
8693126a8a12Smrg      if test -d "$dir"; then
8694d656433aSmrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
8695126a8a12Smrg      fi
8696126a8a12Smrg    done
8697126a8a12Smrg
8698126a8a12Smrg    exit $exit_status
8699d656433aSmrg}
8700126a8a12Smrg
8701d656433aSmrg{ test "$mode" = uninstall || test "$mode" = clean; } &&
8702d656433aSmrg    func_mode_uninstall ${1+"$@"}
8703126a8a12Smrg
8704d656433aSmrgtest -z "$mode" && {
8705d656433aSmrg  help="$generic_help"
8706d656433aSmrg  func_fatal_help "you must specify a MODE"
8707d656433aSmrg}
8708d656433aSmrg
8709d656433aSmrgtest -z "$exec_cmd" && \
8710d656433aSmrg  func_fatal_help "invalid operation mode \`$mode'"
8711126a8a12Smrg
8712126a8a12Smrgif test -n "$exec_cmd"; then
8713d656433aSmrg  eval exec "$exec_cmd"
8714126a8a12Smrg  exit $EXIT_FAILURE
8715126a8a12Smrgfi
8716126a8a12Smrg
8717d656433aSmrgexit $exit_status
8718126a8a12Smrg
8719126a8a12Smrg
8720126a8a12Smrg# The TAGs below are defined such that we never get into a situation
8721126a8a12Smrg# in which we disable both kinds of libraries.  Given conflicting
8722126a8a12Smrg# choices, we go for a static library, that is the most portable,
8723126a8a12Smrg# since we can't tell whether shared libraries were disabled because
8724126a8a12Smrg# the user asked for that or because the platform doesn't support
8725126a8a12Smrg# them.  This is particularly important on AIX, because we don't
8726126a8a12Smrg# support having both static and shared libraries enabled at the same
8727126a8a12Smrg# time on that platform, so we default to a shared-only configuration.
8728126a8a12Smrg# If a disable-shared tag is given, we'll fallback to a static-only
8729126a8a12Smrg# configuration.  But we'll never go from static-only to shared-only.
8730126a8a12Smrg
8731126a8a12Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
8732d656433aSmrgbuild_libtool_libs=no
8733d656433aSmrgbuild_old_libs=yes
8734126a8a12Smrg# ### END LIBTOOL TAG CONFIG: disable-shared
8735126a8a12Smrg
8736126a8a12Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
8737d656433aSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
8738126a8a12Smrg# ### END LIBTOOL TAG CONFIG: disable-static
8739126a8a12Smrg
8740126a8a12Smrg# Local Variables:
8741126a8a12Smrg# mode:shell-script
8742126a8a12Smrg# sh-indentation:2
8743126a8a12Smrg# End:
8744d656433aSmrg# vi:sw=2
8745d656433aSmrg
8746