ltmain.sh revision e9fcaa8a
188de56ccSmrg
2e9fcaa8aSmrg# libtool (GNU libtool) 2.4
388de56ccSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
488de56ccSmrg
5e9fcaa8aSmrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
6e9fcaa8aSmrg# 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
788de56ccSmrg# This is free software; see the source for copying conditions.  There is NO
888de56ccSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
988de56ccSmrg
1088de56ccSmrg# GNU Libtool is free software; you can redistribute it and/or modify
111ab64890Smrg# it under the terms of the GNU General Public License as published by
121ab64890Smrg# the Free Software Foundation; either version 2 of the License, or
131ab64890Smrg# (at your option) any later version.
141ab64890Smrg#
1588de56ccSmrg# As a special exception to the GNU General Public License,
1688de56ccSmrg# if you distribute this file as part of a program or library that
1788de56ccSmrg# is built using GNU Libtool, you may include this file under the
1888de56ccSmrg# same distribution terms that you use for the rest of that program.
1988de56ccSmrg#
2088de56ccSmrg# GNU Libtool is distributed in the hope that it will be useful, but
211ab64890Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
221ab64890Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
231ab64890Smrg# General Public License for more details.
241ab64890Smrg#
251ab64890Smrg# You should have received a copy of the GNU General Public License
2688de56ccSmrg# along with GNU Libtool; see the file COPYING.  If not, a copy
2788de56ccSmrg# can be downloaded from http://www.gnu.org/licenses/gpl.html,
2888de56ccSmrg# or obtained by writing to the Free Software Foundation, Inc.,
2988de56ccSmrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30b4ee4795Smrg
3188de56ccSmrg# Usage: $progname [OPTION]... [MODE-ARG]...
3288de56ccSmrg#
3388de56ccSmrg# Provide generalized library-building support services.
3488de56ccSmrg#
35e9fcaa8aSmrg#       --config             show all configuration variables
36e9fcaa8aSmrg#       --debug              enable verbose shell tracing
37e9fcaa8aSmrg#   -n, --dry-run            display commands without modifying any files
38e9fcaa8aSmrg#       --features           display basic configuration information and exit
39e9fcaa8aSmrg#       --mode=MODE          use operation mode MODE
40e9fcaa8aSmrg#       --preserve-dup-deps  don't remove duplicate dependency libraries
41e9fcaa8aSmrg#       --quiet, --silent    don't print informational messages
42e9fcaa8aSmrg#       --no-quiet, --no-silent
43e9fcaa8aSmrg#                            print informational messages (default)
44e9fcaa8aSmrg#       --tag=TAG            use configuration variables from tag TAG
45e9fcaa8aSmrg#   -v, --verbose            print more informational messages than default
46e9fcaa8aSmrg#       --no-verbose         don't print the extra informational messages
47e9fcaa8aSmrg#       --version            print version information
48e9fcaa8aSmrg#   -h, --help, --help-all   print short, long, or detailed help message
4988de56ccSmrg#
5088de56ccSmrg# MODE must be one of the following:
5188de56ccSmrg#
52e9fcaa8aSmrg#         clean              remove files from the build directory
53e9fcaa8aSmrg#         compile            compile a source file into a libtool object
54e9fcaa8aSmrg#         execute            automatically set library path, then run a program
55e9fcaa8aSmrg#         finish             complete the installation of libtool libraries
56e9fcaa8aSmrg#         install            install libraries or executables
57e9fcaa8aSmrg#         link               create a library or an executable
58e9fcaa8aSmrg#         uninstall          remove libraries from an installed directory
5988de56ccSmrg#
60e9fcaa8aSmrg# MODE-ARGS vary depending on the MODE.  When passed as first option,
61e9fcaa8aSmrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
6288de56ccSmrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
6388de56ccSmrg#
6488de56ccSmrg# When reporting a bug, please describe a test case to reproduce it and
6588de56ccSmrg# include the following information:
6688de56ccSmrg#
67e9fcaa8aSmrg#         host-triplet:	$host
68e9fcaa8aSmrg#         shell:		$SHELL
69e9fcaa8aSmrg#         compiler:		$LTCC
70e9fcaa8aSmrg#         compiler flags:		$LTCFLAGS
71e9fcaa8aSmrg#         linker:		$LD (gnu? $with_gnu_ld)
72e9fcaa8aSmrg#         $progname:	(GNU libtool) 2.4
73e9fcaa8aSmrg#         automake:	$automake_version
74e9fcaa8aSmrg#         autoconf:	$autoconf_version
7588de56ccSmrg#
7688de56ccSmrg# Report bugs to <bug-libtool@gnu.org>.
77e9fcaa8aSmrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
78e9fcaa8aSmrg# General help using GNU software: <http://www.gnu.org/gethelp/>.
791ab64890Smrg
80e9fcaa8aSmrgPROGRAM=libtool
811ab64890SmrgPACKAGE=libtool
82e9fcaa8aSmrgVERSION=2.4
8388de56ccSmrgTIMESTAMP=""
84e9fcaa8aSmrgpackage_revision=1.3293
851ab64890Smrg
8688de56ccSmrg# Be Bourne compatible
871ab64890Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
881ab64890Smrg  emulate sh
891ab64890Smrg  NULLCMD=:
901ab64890Smrg  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
911ab64890Smrg  # is contrary to our usage.  Disable this feature.
921ab64890Smrg  alias -g '${1+"$@"}'='"$@"'
931ab64890Smrg  setopt NO_GLOB_SUBST
941ab64890Smrgelse
951ab64890Smrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
961ab64890Smrgfi
971ab64890SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
981ab64890SmrgDUALCASE=1; export DUALCASE # for MKS sh
991ab64890Smrg
100e9fcaa8aSmrg# A function that is used when there is no print builtin or printf.
101e9fcaa8aSmrgfunc_fallback_echo ()
102e9fcaa8aSmrg{
103e9fcaa8aSmrg  eval 'cat <<_LTECHO_EOF
104e9fcaa8aSmrg$1
105e9fcaa8aSmrg_LTECHO_EOF'
106e9fcaa8aSmrg}
107e9fcaa8aSmrg
10888de56ccSmrg# NLS nuisances: We save the old values to restore during execute mode.
10988de56ccSmrglt_user_locale=
11088de56ccSmrglt_safe_locale=
11161b2299dSmrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
1121ab64890Smrgdo
1131ab64890Smrg  eval "if test \"\${$lt_var+set}\" = set; then
11488de56ccSmrg          save_$lt_var=\$$lt_var
11588de56ccSmrg          $lt_var=C
1161ab64890Smrg	  export $lt_var
11788de56ccSmrg	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
11888de56ccSmrg	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
1191ab64890Smrg	fi"
1201ab64890Smrgdone
121e9fcaa8aSmrgLC_ALL=C
122e9fcaa8aSmrgLANGUAGE=C
123e9fcaa8aSmrgexport LANGUAGE LC_ALL
1241ab64890Smrg
12588de56ccSmrg$lt_unset CDPATH
12688de56ccSmrg
12788de56ccSmrg
128e9fcaa8aSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
129e9fcaa8aSmrg# is ksh but when the shell is invoked as "sh" and the current value of
130e9fcaa8aSmrg# the _XPG environment variable is not equal to 1 (one), the special
131e9fcaa8aSmrg# positional parameter $0, within a function call, is the name of the
132e9fcaa8aSmrg# function.
133e9fcaa8aSmrgprogpath="$0"
13488de56ccSmrg
13588de56ccSmrg
13688de56ccSmrg
13788de56ccSmrg: ${CP="cp -f"}
138e9fcaa8aSmrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
139e9fcaa8aSmrg: ${EGREP="grep -E"}
140e9fcaa8aSmrg: ${FGREP="grep -F"}
141e9fcaa8aSmrg: ${GREP="grep"}
14288de56ccSmrg: ${LN_S="ln -s"}
14388de56ccSmrg: ${MAKE="make"}
14488de56ccSmrg: ${MKDIR="mkdir"}
14588de56ccSmrg: ${MV="mv -f"}
14688de56ccSmrg: ${RM="rm -f"}
147e9fcaa8aSmrg: ${SED="sed"}
14888de56ccSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
14988de56ccSmrg: ${Xsed="$SED -e 1s/^X//"}
15088de56ccSmrg
15188de56ccSmrg# Global variables:
15288de56ccSmrgEXIT_SUCCESS=0
15388de56ccSmrgEXIT_FAILURE=1
15488de56ccSmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
15588de56ccSmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
15688de56ccSmrg
15788de56ccSmrgexit_status=$EXIT_SUCCESS
15861b2299dSmrg
1591ab64890Smrg# Make sure IFS has a sensible default
1601ab64890Smrglt_nl='
1611ab64890Smrg'
1621ab64890SmrgIFS=" 	$lt_nl"
1631ab64890Smrg
16488de56ccSmrgdirname="s,/[^/]*$,,"
16588de56ccSmrgbasename="s,^.*/,,"
16688de56ccSmrg
167e9fcaa8aSmrg# func_dirname file append nondir_replacement
168e9fcaa8aSmrg# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
169e9fcaa8aSmrg# otherwise set result to NONDIR_REPLACEMENT.
170e9fcaa8aSmrgfunc_dirname ()
171e9fcaa8aSmrg{
172e9fcaa8aSmrg    func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
173e9fcaa8aSmrg    if test "X$func_dirname_result" = "X${1}"; then
174e9fcaa8aSmrg      func_dirname_result="${3}"
175e9fcaa8aSmrg    else
176e9fcaa8aSmrg      func_dirname_result="$func_dirname_result${2}"
177e9fcaa8aSmrg    fi
178e9fcaa8aSmrg} # func_dirname may be replaced by extended shell implementation
179e9fcaa8aSmrg
180e9fcaa8aSmrg
181e9fcaa8aSmrg# func_basename file
182e9fcaa8aSmrgfunc_basename ()
183e9fcaa8aSmrg{
184e9fcaa8aSmrg    func_basename_result=`$ECHO "${1}" | $SED "$basename"`
185e9fcaa8aSmrg} # func_basename may be replaced by extended shell implementation
186e9fcaa8aSmrg
187e9fcaa8aSmrg
18888de56ccSmrg# func_dirname_and_basename file append nondir_replacement
18988de56ccSmrg# perform func_basename and func_dirname in a single function
19088de56ccSmrg# call:
19188de56ccSmrg#   dirname:  Compute the dirname of FILE.  If nonempty,
19288de56ccSmrg#             add APPEND to the result, otherwise set result
19388de56ccSmrg#             to NONDIR_REPLACEMENT.
19488de56ccSmrg#             value returned in "$func_dirname_result"
19588de56ccSmrg#   basename: Compute filename of FILE.
19688de56ccSmrg#             value retuned in "$func_basename_result"
19788de56ccSmrg# Implementation must be kept synchronized with func_dirname
19888de56ccSmrg# and func_basename. For efficiency, we do not delegate to
19988de56ccSmrg# those functions but instead duplicate the functionality here.
20088de56ccSmrgfunc_dirname_and_basename ()
20188de56ccSmrg{
202e9fcaa8aSmrg    # Extract subdirectory from the argument.
203e9fcaa8aSmrg    func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
204e9fcaa8aSmrg    if test "X$func_dirname_result" = "X${1}"; then
205e9fcaa8aSmrg      func_dirname_result="${3}"
206e9fcaa8aSmrg    else
207e9fcaa8aSmrg      func_dirname_result="$func_dirname_result${2}"
208e9fcaa8aSmrg    fi
209e9fcaa8aSmrg    func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
210e9fcaa8aSmrg} # func_dirname_and_basename may be replaced by extended shell implementation
211e9fcaa8aSmrg
212e9fcaa8aSmrg
213e9fcaa8aSmrg# func_stripname prefix suffix name
214e9fcaa8aSmrg# strip PREFIX and SUFFIX off of NAME.
215e9fcaa8aSmrg# PREFIX and SUFFIX must not contain globbing or regex special
216e9fcaa8aSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading
217e9fcaa8aSmrg# dot (in which case that matches only a dot).
218e9fcaa8aSmrg# func_strip_suffix prefix name
219e9fcaa8aSmrgfunc_stripname ()
220e9fcaa8aSmrg{
221e9fcaa8aSmrg    case ${2} in
222e9fcaa8aSmrg      .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
223e9fcaa8aSmrg      *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
224e9fcaa8aSmrg    esac
225e9fcaa8aSmrg} # func_stripname may be replaced by extended shell implementation
226e9fcaa8aSmrg
227e9fcaa8aSmrg
228e9fcaa8aSmrg# These SED scripts presuppose an absolute path with a trailing slash.
229e9fcaa8aSmrgpathcar='s,^/\([^/]*\).*$,\1,'
230e9fcaa8aSmrgpathcdr='s,^/[^/]*,,'
231e9fcaa8aSmrgremovedotparts=':dotsl
232e9fcaa8aSmrg		s@/\./@/@g
233e9fcaa8aSmrg		t dotsl
234e9fcaa8aSmrg		s,/\.$,/,'
235e9fcaa8aSmrgcollapseslashes='s@/\{1,\}@/@g'
236e9fcaa8aSmrgfinalslash='s,/*$,/,'
237e9fcaa8aSmrg
238e9fcaa8aSmrg# func_normal_abspath PATH
239e9fcaa8aSmrg# Remove doubled-up and trailing slashes, "." path components,
240e9fcaa8aSmrg# and cancel out any ".." path components in PATH after making
241e9fcaa8aSmrg# it an absolute path.
242e9fcaa8aSmrg#             value returned in "$func_normal_abspath_result"
243e9fcaa8aSmrgfunc_normal_abspath ()
244e9fcaa8aSmrg{
245e9fcaa8aSmrg  # Start from root dir and reassemble the path.
246e9fcaa8aSmrg  func_normal_abspath_result=
247e9fcaa8aSmrg  func_normal_abspath_tpath=$1
248e9fcaa8aSmrg  func_normal_abspath_altnamespace=
249e9fcaa8aSmrg  case $func_normal_abspath_tpath in
250e9fcaa8aSmrg    "")
251e9fcaa8aSmrg      # Empty path, that just means $cwd.
252e9fcaa8aSmrg      func_stripname '' '/' "`pwd`"
253e9fcaa8aSmrg      func_normal_abspath_result=$func_stripname_result
254e9fcaa8aSmrg      return
255e9fcaa8aSmrg    ;;
256e9fcaa8aSmrg    # The next three entries are used to spot a run of precisely
257e9fcaa8aSmrg    # two leading slashes without using negated character classes;
258e9fcaa8aSmrg    # we take advantage of case's first-match behaviour.
259e9fcaa8aSmrg    ///*)
260e9fcaa8aSmrg      # Unusual form of absolute path, do nothing.
261e9fcaa8aSmrg    ;;
262e9fcaa8aSmrg    //*)
263e9fcaa8aSmrg      # Not necessarily an ordinary path; POSIX reserves leading '//'
264e9fcaa8aSmrg      # and for example Cygwin uses it to access remote file shares
265e9fcaa8aSmrg      # over CIFS/SMB, so we conserve a leading double slash if found.
266e9fcaa8aSmrg      func_normal_abspath_altnamespace=/
267e9fcaa8aSmrg    ;;
268e9fcaa8aSmrg    /*)
269e9fcaa8aSmrg      # Absolute path, do nothing.
270e9fcaa8aSmrg    ;;
271e9fcaa8aSmrg    *)
272e9fcaa8aSmrg      # Relative path, prepend $cwd.
273e9fcaa8aSmrg      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
274e9fcaa8aSmrg    ;;
275e9fcaa8aSmrg  esac
276e9fcaa8aSmrg  # Cancel out all the simple stuff to save iterations.  We also want
277e9fcaa8aSmrg  # the path to end with a slash for ease of parsing, so make sure
278e9fcaa8aSmrg  # there is one (and only one) here.
279e9fcaa8aSmrg  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
280e9fcaa8aSmrg        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
281e9fcaa8aSmrg  while :; do
282e9fcaa8aSmrg    # Processed it all yet?
283e9fcaa8aSmrg    if test "$func_normal_abspath_tpath" = / ; then
284e9fcaa8aSmrg      # If we ascended to the root using ".." the result may be empty now.
285e9fcaa8aSmrg      if test -z "$func_normal_abspath_result" ; then
286e9fcaa8aSmrg        func_normal_abspath_result=/
287e9fcaa8aSmrg      fi
288e9fcaa8aSmrg      break
289e9fcaa8aSmrg    fi
290e9fcaa8aSmrg    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
291e9fcaa8aSmrg        -e "$pathcar"`
292e9fcaa8aSmrg    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
293e9fcaa8aSmrg        -e "$pathcdr"`
294e9fcaa8aSmrg    # Figure out what to do with it
295e9fcaa8aSmrg    case $func_normal_abspath_tcomponent in
296e9fcaa8aSmrg      "")
297e9fcaa8aSmrg        # Trailing empty path component, ignore it.
298e9fcaa8aSmrg      ;;
299e9fcaa8aSmrg      ..)
300e9fcaa8aSmrg        # Parent dir; strip last assembled component from result.
301e9fcaa8aSmrg        func_dirname "$func_normal_abspath_result"
302e9fcaa8aSmrg        func_normal_abspath_result=$func_dirname_result
303e9fcaa8aSmrg      ;;
304e9fcaa8aSmrg      *)
305e9fcaa8aSmrg        # Actual path component, append it.
306e9fcaa8aSmrg        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
307e9fcaa8aSmrg      ;;
308e9fcaa8aSmrg    esac
309e9fcaa8aSmrg  done
310e9fcaa8aSmrg  # Restore leading double-slash if one was found on entry.
311e9fcaa8aSmrg  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
31288de56ccSmrg}
3132e9c7c8cSmrg
314e9fcaa8aSmrg# func_relative_path SRCDIR DSTDIR
315e9fcaa8aSmrg# generates a relative path from SRCDIR to DSTDIR, with a trailing
316e9fcaa8aSmrg# slash if non-empty, suitable for immediately appending a filename
317e9fcaa8aSmrg# without needing to append a separator.
318e9fcaa8aSmrg#             value returned in "$func_relative_path_result"
319e9fcaa8aSmrgfunc_relative_path ()
320e9fcaa8aSmrg{
321e9fcaa8aSmrg  func_relative_path_result=
322e9fcaa8aSmrg  func_normal_abspath "$1"
323e9fcaa8aSmrg  func_relative_path_tlibdir=$func_normal_abspath_result
324e9fcaa8aSmrg  func_normal_abspath "$2"
325e9fcaa8aSmrg  func_relative_path_tbindir=$func_normal_abspath_result
326e9fcaa8aSmrg
327e9fcaa8aSmrg  # Ascend the tree starting from libdir
328e9fcaa8aSmrg  while :; do
329e9fcaa8aSmrg    # check if we have found a prefix of bindir
330e9fcaa8aSmrg    case $func_relative_path_tbindir in
331e9fcaa8aSmrg      $func_relative_path_tlibdir)
332e9fcaa8aSmrg        # found an exact match
333e9fcaa8aSmrg        func_relative_path_tcancelled=
334e9fcaa8aSmrg        break
335e9fcaa8aSmrg        ;;
336e9fcaa8aSmrg      $func_relative_path_tlibdir*)
337e9fcaa8aSmrg        # found a matching prefix
338e9fcaa8aSmrg        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
339e9fcaa8aSmrg        func_relative_path_tcancelled=$func_stripname_result
340e9fcaa8aSmrg        if test -z "$func_relative_path_result"; then
341e9fcaa8aSmrg          func_relative_path_result=.
342e9fcaa8aSmrg        fi
343e9fcaa8aSmrg        break
344e9fcaa8aSmrg        ;;
345e9fcaa8aSmrg      *)
346e9fcaa8aSmrg        func_dirname $func_relative_path_tlibdir
347e9fcaa8aSmrg        func_relative_path_tlibdir=${func_dirname_result}
348e9fcaa8aSmrg        if test "x$func_relative_path_tlibdir" = x ; then
349e9fcaa8aSmrg          # Have to descend all the way to the root!
350e9fcaa8aSmrg          func_relative_path_result=../$func_relative_path_result
351e9fcaa8aSmrg          func_relative_path_tcancelled=$func_relative_path_tbindir
352e9fcaa8aSmrg          break
353e9fcaa8aSmrg        fi
354e9fcaa8aSmrg        func_relative_path_result=../$func_relative_path_result
355e9fcaa8aSmrg        ;;
356e9fcaa8aSmrg    esac
357e9fcaa8aSmrg  done
35888de56ccSmrg
359e9fcaa8aSmrg  # Now calculate path; take care to avoid doubling-up slashes.
360e9fcaa8aSmrg  func_stripname '' '/' "$func_relative_path_result"
361e9fcaa8aSmrg  func_relative_path_result=$func_stripname_result
362e9fcaa8aSmrg  func_stripname '/' '/' "$func_relative_path_tcancelled"
363e9fcaa8aSmrg  if test "x$func_stripname_result" != x ; then
364e9fcaa8aSmrg    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
365e9fcaa8aSmrg  fi
366e9fcaa8aSmrg
367e9fcaa8aSmrg  # Normalisation. If bindir is libdir, return empty string,
368e9fcaa8aSmrg  # else relative path ending with a slash; either way, target
369e9fcaa8aSmrg  # file name can be directly appended.
370e9fcaa8aSmrg  if test ! -z "$func_relative_path_result"; then
371e9fcaa8aSmrg    func_stripname './' '' "$func_relative_path_result/"
372e9fcaa8aSmrg    func_relative_path_result=$func_stripname_result
373e9fcaa8aSmrg  fi
374e9fcaa8aSmrg}
37588de56ccSmrg
37688de56ccSmrg# The name of this program:
37788de56ccSmrgfunc_dirname_and_basename "$progpath"
37888de56ccSmrgprogname=$func_basename_result
37988de56ccSmrg
38088de56ccSmrg# Make sure we have an absolute path for reexecution:
38188de56ccSmrgcase $progpath in
38288de56ccSmrg  [\\/]*|[A-Za-z]:\\*) ;;
38388de56ccSmrg  *[\\/]*)
38488de56ccSmrg     progdir=$func_dirname_result
38588de56ccSmrg     progdir=`cd "$progdir" && pwd`
38688de56ccSmrg     progpath="$progdir/$progname"
38788de56ccSmrg     ;;
38888de56ccSmrg  *)
38988de56ccSmrg     save_IFS="$IFS"
39088de56ccSmrg     IFS=:
39188de56ccSmrg     for progdir in $PATH; do
39288de56ccSmrg       IFS="$save_IFS"
39388de56ccSmrg       test -x "$progdir/$progname" && break
39488de56ccSmrg     done
39588de56ccSmrg     IFS="$save_IFS"
39688de56ccSmrg     test -n "$progdir" || progdir=`pwd`
39788de56ccSmrg     progpath="$progdir/$progname"
39888de56ccSmrg     ;;
39988de56ccSmrgesac
40088de56ccSmrg
40188de56ccSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
40288de56ccSmrg# metacharacters that are still active within double-quoted strings.
40388de56ccSmrgXsed="${SED}"' -e 1s/^X//'
40488de56ccSmrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g'
40588de56ccSmrg
40688de56ccSmrg# Same as above, but do not quote variable references.
40788de56ccSmrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g'
40888de56ccSmrg
409e9fcaa8aSmrg# Sed substitution that turns a string into a regex matching for the
410e9fcaa8aSmrg# string literally.
411e9fcaa8aSmrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
412e9fcaa8aSmrg
413e9fcaa8aSmrg# Sed substitution that converts a w32 file name or path
414e9fcaa8aSmrg# which contains forward slashes, into one that contains
415e9fcaa8aSmrg# (escaped) backslashes.  A very naive implementation.
416e9fcaa8aSmrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
417e9fcaa8aSmrg
41888de56ccSmrg# Re-`\' parameter expansions in output of double_quote_subst that were
41988de56ccSmrg# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
42088de56ccSmrg# in input to double_quote_subst, that '$' was protected from expansion.
42188de56ccSmrg# Since each input `\' is now two `\'s, look for any number of runs of
42288de56ccSmrg# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
42388de56ccSmrgbs='\\'
42488de56ccSmrgbs2='\\\\'
42588de56ccSmrgbs4='\\\\\\\\'
42688de56ccSmrgdollar='\$'
42788de56ccSmrgsed_double_backslash="\
42888de56ccSmrg  s/$bs4/&\\
42988de56ccSmrg/g
43088de56ccSmrg  s/^$bs2$dollar/$bs&/
43188de56ccSmrg  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
43288de56ccSmrg  s/\n//g"
43388de56ccSmrg
43488de56ccSmrg# Standard options:
43588de56ccSmrgopt_dry_run=false
43688de56ccSmrgopt_help=false
43788de56ccSmrgopt_quiet=false
43888de56ccSmrgopt_verbose=false
43988de56ccSmrgopt_warning=:
44088de56ccSmrg
44188de56ccSmrg# func_echo arg...
44288de56ccSmrg# Echo program name prefixed message, along with the current mode
44388de56ccSmrg# name if it has been set yet.
44488de56ccSmrgfunc_echo ()
44588de56ccSmrg{
446e9fcaa8aSmrg    $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
44788de56ccSmrg}
44888de56ccSmrg
44988de56ccSmrg# func_verbose arg...
45088de56ccSmrg# Echo program name prefixed message in verbose mode only.
45188de56ccSmrgfunc_verbose ()
45288de56ccSmrg{
45388de56ccSmrg    $opt_verbose && func_echo ${1+"$@"}
45488de56ccSmrg
45588de56ccSmrg    # A bug in bash halts the script if the last line of a function
45688de56ccSmrg    # fails when set -e is in force, so we need another command to
45788de56ccSmrg    # work around that:
45888de56ccSmrg    :
45988de56ccSmrg}
46088de56ccSmrg
461e9fcaa8aSmrg# func_echo_all arg...
462e9fcaa8aSmrg# Invoke $ECHO with all args, space-separated.
463e9fcaa8aSmrgfunc_echo_all ()
464e9fcaa8aSmrg{
465e9fcaa8aSmrg    $ECHO "$*"
466e9fcaa8aSmrg}
467e9fcaa8aSmrg
46888de56ccSmrg# func_error arg...
46988de56ccSmrg# Echo program name prefixed message to standard error.
47088de56ccSmrgfunc_error ()
47188de56ccSmrg{
472e9fcaa8aSmrg    $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
47388de56ccSmrg}
47488de56ccSmrg
47588de56ccSmrg# func_warning arg...
47688de56ccSmrg# Echo program name prefixed warning message to standard error.
47788de56ccSmrgfunc_warning ()
47888de56ccSmrg{
479e9fcaa8aSmrg    $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
48088de56ccSmrg
48188de56ccSmrg    # bash bug again:
48288de56ccSmrg    :
48388de56ccSmrg}
48488de56ccSmrg
48588de56ccSmrg# func_fatal_error arg...
48688de56ccSmrg# Echo program name prefixed message to standard error, and exit.
48788de56ccSmrgfunc_fatal_error ()
48888de56ccSmrg{
48988de56ccSmrg    func_error ${1+"$@"}
49088de56ccSmrg    exit $EXIT_FAILURE
49188de56ccSmrg}
49288de56ccSmrg
49388de56ccSmrg# func_fatal_help arg...
49488de56ccSmrg# Echo program name prefixed message to standard error, followed by
49588de56ccSmrg# a help hint, and exit.
49688de56ccSmrgfunc_fatal_help ()
49788de56ccSmrg{
49888de56ccSmrg    func_error ${1+"$@"}
49988de56ccSmrg    func_fatal_error "$help"
50088de56ccSmrg}
50188de56ccSmrghelp="Try \`$progname --help' for more information."  ## default
50288de56ccSmrg
50388de56ccSmrg
50488de56ccSmrg# func_grep expression filename
50588de56ccSmrg# Check whether EXPRESSION matches any line of FILENAME, without output.
50688de56ccSmrgfunc_grep ()
50788de56ccSmrg{
50888de56ccSmrg    $GREP "$1" "$2" >/dev/null 2>&1
50988de56ccSmrg}
51088de56ccSmrg
51188de56ccSmrg
51288de56ccSmrg# func_mkdir_p directory-path
51388de56ccSmrg# Make sure the entire path to DIRECTORY-PATH is available.
51488de56ccSmrgfunc_mkdir_p ()
51588de56ccSmrg{
51688de56ccSmrg    my_directory_path="$1"
51788de56ccSmrg    my_dir_list=
51888de56ccSmrg
51988de56ccSmrg    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
52088de56ccSmrg
52188de56ccSmrg      # Protect directory names starting with `-'
52288de56ccSmrg      case $my_directory_path in
52388de56ccSmrg        -*) my_directory_path="./$my_directory_path" ;;
52488de56ccSmrg      esac
52588de56ccSmrg
52688de56ccSmrg      # While some portion of DIR does not yet exist...
52788de56ccSmrg      while test ! -d "$my_directory_path"; do
52888de56ccSmrg        # ...make a list in topmost first order.  Use a colon delimited
52988de56ccSmrg	# list incase some portion of path contains whitespace.
53088de56ccSmrg        my_dir_list="$my_directory_path:$my_dir_list"
53188de56ccSmrg
53288de56ccSmrg        # If the last portion added has no slash in it, the list is done
53388de56ccSmrg        case $my_directory_path in */*) ;; *) break ;; esac
53488de56ccSmrg
53588de56ccSmrg        # ...otherwise throw away the child directory and loop
536e9fcaa8aSmrg        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
53788de56ccSmrg      done
538e9fcaa8aSmrg      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
53988de56ccSmrg
54088de56ccSmrg      save_mkdir_p_IFS="$IFS"; IFS=':'
54188de56ccSmrg      for my_dir in $my_dir_list; do
54288de56ccSmrg	IFS="$save_mkdir_p_IFS"
54388de56ccSmrg        # mkdir can fail with a `File exist' error if two processes
54488de56ccSmrg        # try to create one of the directories concurrently.  Don't
54588de56ccSmrg        # stop in that case!
54688de56ccSmrg        $MKDIR "$my_dir" 2>/dev/null || :
54788de56ccSmrg      done
54888de56ccSmrg      IFS="$save_mkdir_p_IFS"
54988de56ccSmrg
55088de56ccSmrg      # Bail out if we (or some other process) failed to create a directory.
55188de56ccSmrg      test -d "$my_directory_path" || \
55288de56ccSmrg        func_fatal_error "Failed to create \`$1'"
55388de56ccSmrg    fi
55488de56ccSmrg}
5551ab64890Smrg
5561ab64890Smrg
5571ab64890Smrg# func_mktempdir [string]
5581ab64890Smrg# Make a temporary directory that won't clash with other running
5591ab64890Smrg# libtool processes, and avoids race conditions if possible.  If
5601ab64890Smrg# given, STRING is the basename for that directory.
5611ab64890Smrgfunc_mktempdir ()
5621ab64890Smrg{
5631ab64890Smrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
5641ab64890Smrg
56588de56ccSmrg    if test "$opt_dry_run" = ":"; then
5661ab64890Smrg      # Return a directory name, but don't create it in dry-run mode
5671ab64890Smrg      my_tmpdir="${my_template}-$$"
5681ab64890Smrg    else
5691ab64890Smrg
5701ab64890Smrg      # If mktemp works, use that first and foremost
5711ab64890Smrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
5721ab64890Smrg
5731ab64890Smrg      if test ! -d "$my_tmpdir"; then
57488de56ccSmrg        # Failing that, at least try and use $RANDOM to avoid a race
57588de56ccSmrg        my_tmpdir="${my_template}-${RANDOM-0}$$"
5761ab64890Smrg
57788de56ccSmrg        save_mktempdir_umask=`umask`
57888de56ccSmrg        umask 0077
57988de56ccSmrg        $MKDIR "$my_tmpdir"
58088de56ccSmrg        umask $save_mktempdir_umask
5811ab64890Smrg      fi
5821ab64890Smrg
5831ab64890Smrg      # If we're not in dry-run mode, bomb out on failure
58488de56ccSmrg      test -d "$my_tmpdir" || \
58588de56ccSmrg        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
5861ab64890Smrg    fi
5871ab64890Smrg
588e9fcaa8aSmrg    $ECHO "$my_tmpdir"
5891ab64890Smrg}
5901ab64890Smrg
5911ab64890Smrg
59288de56ccSmrg# func_quote_for_eval arg
59388de56ccSmrg# Aesthetically quote ARG to be evaled later.
59488de56ccSmrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
59588de56ccSmrg# is double-quoted, suitable for a subsequent eval, whereas
59688de56ccSmrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
59788de56ccSmrg# which are still active within double quotes backslashified.
59888de56ccSmrgfunc_quote_for_eval ()
5991ab64890Smrg{
60088de56ccSmrg    case $1 in
60188de56ccSmrg      *[\\\`\"\$]*)
602e9fcaa8aSmrg	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
60388de56ccSmrg      *)
60488de56ccSmrg        func_quote_for_eval_unquoted_result="$1" ;;
60588de56ccSmrg    esac
60688de56ccSmrg
60788de56ccSmrg    case $func_quote_for_eval_unquoted_result in
60888de56ccSmrg      # Double-quote args containing shell metacharacters to delay
60988de56ccSmrg      # word splitting, command substitution and and variable
61088de56ccSmrg      # expansion for a subsequent eval.
61188de56ccSmrg      # Many Bourne shells cannot handle close brackets correctly
61288de56ccSmrg      # in scan sets, so we specify it separately.
61388de56ccSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
61488de56ccSmrg        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
61588de56ccSmrg        ;;
61688de56ccSmrg      *)
61788de56ccSmrg        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
6181ab64890Smrg    esac
6191ab64890Smrg}
6201ab64890Smrg
6211ab64890Smrg
62288de56ccSmrg# func_quote_for_expand arg
62388de56ccSmrg# Aesthetically quote ARG to be evaled later; same as above,
62488de56ccSmrg# but do not quote variable references.
62588de56ccSmrgfunc_quote_for_expand ()
6261ab64890Smrg{
62788de56ccSmrg    case $1 in
62888de56ccSmrg      *[\\\`\"]*)
629e9fcaa8aSmrg	my_arg=`$ECHO "$1" | $SED \
63088de56ccSmrg	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
6311ab64890Smrg      *)
63288de56ccSmrg        my_arg="$1" ;;
63388de56ccSmrg    esac
63488de56ccSmrg
63588de56ccSmrg    case $my_arg in
63688de56ccSmrg      # Double-quote args containing shell metacharacters to delay
63788de56ccSmrg      # word splitting and command substitution for a subsequent eval.
63888de56ccSmrg      # Many Bourne shells cannot handle close brackets correctly
63988de56ccSmrg      # in scan sets, so we specify it separately.
64088de56ccSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
64188de56ccSmrg        my_arg="\"$my_arg\""
64288de56ccSmrg        ;;
64388de56ccSmrg    esac
64488de56ccSmrg
64588de56ccSmrg    func_quote_for_expand_result="$my_arg"
6461ab64890Smrg}
6471ab64890Smrg
6481ab64890Smrg
64988de56ccSmrg# func_show_eval cmd [fail_exp]
65088de56ccSmrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
65188de56ccSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
65288de56ccSmrg# is given, then evaluate it.
65388de56ccSmrgfunc_show_eval ()
6541ab64890Smrg{
65588de56ccSmrg    my_cmd="$1"
65688de56ccSmrg    my_fail_exp="${2-:}"
6572e9c7c8cSmrg
65888de56ccSmrg    ${opt_silent-false} || {
65988de56ccSmrg      func_quote_for_expand "$my_cmd"
66088de56ccSmrg      eval "func_echo $func_quote_for_expand_result"
66188de56ccSmrg    }
66288de56ccSmrg
66388de56ccSmrg    if ${opt_dry_run-false}; then :; else
66488de56ccSmrg      eval "$my_cmd"
66588de56ccSmrg      my_status=$?
66688de56ccSmrg      if test "$my_status" -eq 0; then :; else
66788de56ccSmrg	eval "(exit $my_status); $my_fail_exp"
66888de56ccSmrg      fi
6691ab64890Smrg    fi
6701ab64890Smrg}
6711ab64890Smrg
67288de56ccSmrg
67388de56ccSmrg# func_show_eval_locale cmd [fail_exp]
67488de56ccSmrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
67588de56ccSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
67688de56ccSmrg# is given, then evaluate it.  Use the saved locale for evaluation.
67788de56ccSmrgfunc_show_eval_locale ()
6781ab64890Smrg{
67988de56ccSmrg    my_cmd="$1"
68088de56ccSmrg    my_fail_exp="${2-:}"
68188de56ccSmrg
68288de56ccSmrg    ${opt_silent-false} || {
68388de56ccSmrg      func_quote_for_expand "$my_cmd"
68488de56ccSmrg      eval "func_echo $func_quote_for_expand_result"
68588de56ccSmrg    }
68688de56ccSmrg
68788de56ccSmrg    if ${opt_dry_run-false}; then :; else
68888de56ccSmrg      eval "$lt_user_locale
68988de56ccSmrg	    $my_cmd"
69088de56ccSmrg      my_status=$?
69188de56ccSmrg      eval "$lt_safe_locale"
69288de56ccSmrg      if test "$my_status" -eq 0; then :; else
69388de56ccSmrg	eval "(exit $my_status); $my_fail_exp"
69488de56ccSmrg      fi
6951ab64890Smrg    fi
69688de56ccSmrg}
6971ab64890Smrg
698e9fcaa8aSmrg# func_tr_sh
699e9fcaa8aSmrg# Turn $1 into a string suitable for a shell variable name.
700e9fcaa8aSmrg# Result is stored in $func_tr_sh_result.  All characters
701e9fcaa8aSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
702e9fcaa8aSmrg# if $1 begins with a digit, a '_' is prepended as well.
703e9fcaa8aSmrgfunc_tr_sh ()
704e9fcaa8aSmrg{
705e9fcaa8aSmrg  case $1 in
706e9fcaa8aSmrg  [0-9]* | *[!a-zA-Z0-9_]*)
707e9fcaa8aSmrg    func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
708e9fcaa8aSmrg    ;;
709e9fcaa8aSmrg  * )
710e9fcaa8aSmrg    func_tr_sh_result=$1
711e9fcaa8aSmrg    ;;
712e9fcaa8aSmrg  esac
713e9fcaa8aSmrg}
71488de56ccSmrg
71588de56ccSmrg
71688de56ccSmrg# func_version
71788de56ccSmrg# Echo version message to standard output and exit.
71888de56ccSmrgfunc_version ()
71988de56ccSmrg{
720e9fcaa8aSmrg    $opt_debug
721e9fcaa8aSmrg
722e9fcaa8aSmrg    $SED -n '/(C)/!b go
723e9fcaa8aSmrg	:more
724e9fcaa8aSmrg	/\./!{
725e9fcaa8aSmrg	  N
726e9fcaa8aSmrg	  s/\n# / /
727e9fcaa8aSmrg	  b more
728e9fcaa8aSmrg	}
729e9fcaa8aSmrg	:go
730e9fcaa8aSmrg	/^# '$PROGRAM' (GNU /,/# warranty; / {
73188de56ccSmrg        s/^# //
73288de56ccSmrg	s/^# *$//
73388de56ccSmrg        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
73488de56ccSmrg        p
73588de56ccSmrg     }' < "$progpath"
73688de56ccSmrg     exit $?
73788de56ccSmrg}
73888de56ccSmrg
73988de56ccSmrg# func_usage
74088de56ccSmrg# Echo short help message to standard output and exit.
74188de56ccSmrgfunc_usage ()
74288de56ccSmrg{
743e9fcaa8aSmrg    $opt_debug
744e9fcaa8aSmrg
745e9fcaa8aSmrg    $SED -n '/^# Usage:/,/^#  *.*--help/ {
74688de56ccSmrg        s/^# //
74788de56ccSmrg	s/^# *$//
74888de56ccSmrg	s/\$progname/'$progname'/
74988de56ccSmrg	p
75088de56ccSmrg    }' < "$progpath"
751e9fcaa8aSmrg    echo
75288de56ccSmrg    $ECHO "run \`$progname --help | more' for full usage"
75388de56ccSmrg    exit $?
75488de56ccSmrg}
75588de56ccSmrg
756e9fcaa8aSmrg# func_help [NOEXIT]
757e9fcaa8aSmrg# Echo long help message to standard output and exit,
758e9fcaa8aSmrg# unless 'noexit' is passed as argument.
75988de56ccSmrgfunc_help ()
76088de56ccSmrg{
761e9fcaa8aSmrg    $opt_debug
762e9fcaa8aSmrg
76388de56ccSmrg    $SED -n '/^# Usage:/,/# Report bugs to/ {
764e9fcaa8aSmrg	:print
76588de56ccSmrg        s/^# //
76688de56ccSmrg	s/^# *$//
76788de56ccSmrg	s*\$progname*'$progname'*
76888de56ccSmrg	s*\$host*'"$host"'*
76988de56ccSmrg	s*\$SHELL*'"$SHELL"'*
77088de56ccSmrg	s*\$LTCC*'"$LTCC"'*
77188de56ccSmrg	s*\$LTCFLAGS*'"$LTCFLAGS"'*
77288de56ccSmrg	s*\$LD*'"$LD"'*
77388de56ccSmrg	s/\$with_gnu_ld/'"$with_gnu_ld"'/
77488de56ccSmrg	s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
77588de56ccSmrg	s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
77688de56ccSmrg	p
777e9fcaa8aSmrg	d
778e9fcaa8aSmrg     }
779e9fcaa8aSmrg     /^# .* home page:/b print
780e9fcaa8aSmrg     /^# General help using/b print
781e9fcaa8aSmrg     ' < "$progpath"
782e9fcaa8aSmrg    ret=$?
783e9fcaa8aSmrg    if test -z "$1"; then
784e9fcaa8aSmrg      exit $ret
785e9fcaa8aSmrg    fi
78688de56ccSmrg}
78788de56ccSmrg
78888de56ccSmrg# func_missing_arg argname
78988de56ccSmrg# Echo program name prefixed message to standard error and set global
79088de56ccSmrg# exit_cmd.
79188de56ccSmrgfunc_missing_arg ()
79288de56ccSmrg{
793e9fcaa8aSmrg    $opt_debug
794e9fcaa8aSmrg
795e9fcaa8aSmrg    func_error "missing argument for $1."
79688de56ccSmrg    exit_cmd=exit
7971ab64890Smrg}
7981ab64890Smrg
7992e9c7c8cSmrg
800e9fcaa8aSmrg# func_split_short_opt shortopt
801e9fcaa8aSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell
802e9fcaa8aSmrg# variables after splitting SHORTOPT after the 2nd character.
803e9fcaa8aSmrgfunc_split_short_opt ()
804e9fcaa8aSmrg{
805e9fcaa8aSmrg    my_sed_short_opt='1s/^\(..\).*$/\1/;q'
806e9fcaa8aSmrg    my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
807e9fcaa8aSmrg
808e9fcaa8aSmrg    func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
809e9fcaa8aSmrg    func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
810e9fcaa8aSmrg} # func_split_short_opt may be replaced by extended shell implementation
8112e9c7c8cSmrg
81288de56ccSmrg
813e9fcaa8aSmrg# func_split_long_opt longopt
814e9fcaa8aSmrg# Set func_split_long_opt_name and func_split_long_opt_arg shell
815e9fcaa8aSmrg# variables after splitting LONGOPT at the `=' sign.
816e9fcaa8aSmrgfunc_split_long_opt ()
817e9fcaa8aSmrg{
818e9fcaa8aSmrg    my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
819e9fcaa8aSmrg    my_sed_long_arg='1s/^--[^=]*=//'
820e9fcaa8aSmrg
821e9fcaa8aSmrg    func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
822e9fcaa8aSmrg    func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
823e9fcaa8aSmrg} # func_split_long_opt may be replaced by extended shell implementation
824e9fcaa8aSmrg
825e9fcaa8aSmrgexit_cmd=:
826e9fcaa8aSmrg
82788de56ccSmrg
82888de56ccSmrg
8291ab64890Smrg
8301ab64890Smrg
83188de56ccSmrgmagic="%%%MAGIC variable%%%"
83288de56ccSmrgmagic_exe="%%%MAGIC EXE variable%%%"
8331ab64890Smrg
83488de56ccSmrg# Global variables.
83588de56ccSmrgnonopt=
83688de56ccSmrgpreserve_args=
83788de56ccSmrglo2o="s/\\.lo\$/.${objext}/"
83888de56ccSmrgo2lo="s/\\.${objext}\$/.lo/"
83988de56ccSmrgextracted_archives=
84088de56ccSmrgextracted_serial=0
8412e9c7c8cSmrg
84288de56ccSmrg# If this variable is set in any of the actions, the command in it
84388de56ccSmrg# will be execed at the end.  This prevents here-documents from being
84488de56ccSmrg# left over by shells.
84588de56ccSmrgexec_cmd=
84688de56ccSmrg
847e9fcaa8aSmrg# func_append var value
848e9fcaa8aSmrg# Append VALUE to the end of shell variable VAR.
849e9fcaa8aSmrgfunc_append ()
850e9fcaa8aSmrg{
851e9fcaa8aSmrg    eval "${1}=\$${1}\${2}"
852e9fcaa8aSmrg} # func_append may be replaced by extended shell implementation
853e9fcaa8aSmrg
854e9fcaa8aSmrg# func_append_quoted var value
855e9fcaa8aSmrg# Quote VALUE and append to the end of shell variable VAR, separated
856e9fcaa8aSmrg# by a space.
857e9fcaa8aSmrgfunc_append_quoted ()
858e9fcaa8aSmrg{
859e9fcaa8aSmrg    func_quote_for_eval "${2}"
860e9fcaa8aSmrg    eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
861e9fcaa8aSmrg} # func_append_quoted may be replaced by extended shell implementation
862e9fcaa8aSmrg
863e9fcaa8aSmrg
864e9fcaa8aSmrg# func_arith arithmetic-term...
865e9fcaa8aSmrgfunc_arith ()
866e9fcaa8aSmrg{
867e9fcaa8aSmrg    func_arith_result=`expr "${@}"`
868e9fcaa8aSmrg} # func_arith may be replaced by extended shell implementation
869e9fcaa8aSmrg
870e9fcaa8aSmrg
871e9fcaa8aSmrg# func_len string
872e9fcaa8aSmrg# STRING may not start with a hyphen.
873e9fcaa8aSmrgfunc_len ()
874e9fcaa8aSmrg{
875e9fcaa8aSmrg    func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
876e9fcaa8aSmrg} # func_len may be replaced by extended shell implementation
877e9fcaa8aSmrg
878e9fcaa8aSmrg
879e9fcaa8aSmrg# func_lo2o object
880e9fcaa8aSmrgfunc_lo2o ()
881e9fcaa8aSmrg{
882e9fcaa8aSmrg    func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
883e9fcaa8aSmrg} # func_lo2o may be replaced by extended shell implementation
884e9fcaa8aSmrg
885e9fcaa8aSmrg
886e9fcaa8aSmrg# func_xform libobj-or-source
887e9fcaa8aSmrgfunc_xform ()
888e9fcaa8aSmrg{
889e9fcaa8aSmrg    func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
890e9fcaa8aSmrg} # func_xform may be replaced by extended shell implementation
891e9fcaa8aSmrg
892e9fcaa8aSmrg
89388de56ccSmrg# func_fatal_configuration arg...
89488de56ccSmrg# Echo program name prefixed message to standard error, followed by
89588de56ccSmrg# a configuration failure hint, and exit.
89688de56ccSmrgfunc_fatal_configuration ()
89788de56ccSmrg{
89888de56ccSmrg    func_error ${1+"$@"}
89988de56ccSmrg    func_error "See the $PACKAGE documentation for more information."
90088de56ccSmrg    func_fatal_error "Fatal configuration error."
90188de56ccSmrg}
9021ab64890Smrg
9032e9c7c8cSmrg
90488de56ccSmrg# func_config
90588de56ccSmrg# Display the configuration for all the tags in this script.
90688de56ccSmrgfunc_config ()
90788de56ccSmrg{
90888de56ccSmrg    re_begincf='^# ### BEGIN LIBTOOL'
90988de56ccSmrg    re_endcf='^# ### END LIBTOOL'
91088de56ccSmrg
91188de56ccSmrg    # Default configuration.
91288de56ccSmrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
9131ab64890Smrg
9141ab64890Smrg    # Now print the configurations for the tags.
9151ab64890Smrg    for tagname in $taglist; do
91688de56ccSmrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
9171ab64890Smrg    done
918b4ee4795Smrg
91988de56ccSmrg    exit $?
92088de56ccSmrg}
921b4ee4795Smrg
92288de56ccSmrg# func_features
92388de56ccSmrg# Display the features supported by this script.
92488de56ccSmrgfunc_features ()
92588de56ccSmrg{
926e9fcaa8aSmrg    echo "host: $host"
9271ab64890Smrg    if test "$build_libtool_libs" = yes; then
928e9fcaa8aSmrg      echo "enable shared libraries"
9291ab64890Smrg    else
930e9fcaa8aSmrg      echo "disable shared libraries"
9311ab64890Smrg    fi
9321ab64890Smrg    if test "$build_old_libs" = yes; then
933e9fcaa8aSmrg      echo "enable static libraries"
9341ab64890Smrg    else
935e9fcaa8aSmrg      echo "disable static libraries"
9361ab64890Smrg    fi
93788de56ccSmrg
9381ab64890Smrg    exit $?
93988de56ccSmrg}
9401ab64890Smrg
94188de56ccSmrg# func_enable_tag tagname
94288de56ccSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or
94388de56ccSmrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
94488de56ccSmrg# variable here.
94588de56ccSmrgfunc_enable_tag ()
94688de56ccSmrg{
94788de56ccSmrg  # Global variable:
94888de56ccSmrg  tagname="$1"
9491ab64890Smrg
95088de56ccSmrg  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
95188de56ccSmrg  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
95288de56ccSmrg  sed_extractcf="/$re_begincf/,/$re_endcf/p"
9532e9c7c8cSmrg
95488de56ccSmrg  # Validate tagname.
95588de56ccSmrg  case $tagname in
95688de56ccSmrg    *[!-_A-Za-z0-9,/]*)
95788de56ccSmrg      func_fatal_error "invalid tag name: $tagname"
95888de56ccSmrg      ;;
95988de56ccSmrg  esac
9601ab64890Smrg
96188de56ccSmrg  # Don't test for the "default" C tag, as we know it's
96288de56ccSmrg  # there but not specially marked.
96388de56ccSmrg  case $tagname in
96488de56ccSmrg    CC) ;;
96588de56ccSmrg    *)
96688de56ccSmrg      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
96788de56ccSmrg	taglist="$taglist $tagname"
96888de56ccSmrg
96988de56ccSmrg	# Evaluate the configuration.  Be careful to quote the path
97088de56ccSmrg	# and the sed script, to avoid splitting on whitespace, but
97188de56ccSmrg	# also don't use non-portable quotes within backquotes within
97288de56ccSmrg	# quotes we have to do it in 2 steps:
97388de56ccSmrg	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
97488de56ccSmrg	eval "$extractedcf"
97588de56ccSmrg      else
97688de56ccSmrg	func_error "ignoring unknown tag $tagname"
97788de56ccSmrg      fi
97888de56ccSmrg      ;;
97988de56ccSmrg  esac
98088de56ccSmrg}
98188de56ccSmrg
982e9fcaa8aSmrg# func_check_version_match
983e9fcaa8aSmrg# Ensure that we are using m4 macros, and libtool script from the same
984e9fcaa8aSmrg# release of libtool.
985e9fcaa8aSmrgfunc_check_version_match ()
98688de56ccSmrg{
987e9fcaa8aSmrg  if test "$package_revision" != "$macro_revision"; then
988e9fcaa8aSmrg    if test "$VERSION" != "$macro_version"; then
989e9fcaa8aSmrg      if test -z "$macro_version"; then
990e9fcaa8aSmrg        cat >&2 <<_LT_EOF
991e9fcaa8aSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
992e9fcaa8aSmrg$progname: definition of this LT_INIT comes from an older release.
993e9fcaa8aSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
994e9fcaa8aSmrg$progname: and run autoconf again.
995e9fcaa8aSmrg_LT_EOF
996e9fcaa8aSmrg      else
997e9fcaa8aSmrg        cat >&2 <<_LT_EOF
998e9fcaa8aSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
999e9fcaa8aSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
1000e9fcaa8aSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
1001e9fcaa8aSmrg$progname: and run autoconf again.
1002e9fcaa8aSmrg_LT_EOF
1003e9fcaa8aSmrg      fi
1004e9fcaa8aSmrg    else
1005e9fcaa8aSmrg      cat >&2 <<_LT_EOF
1006e9fcaa8aSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
1007e9fcaa8aSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
1008e9fcaa8aSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
1009e9fcaa8aSmrg$progname: of $PACKAGE $VERSION and run autoconf again.
1010e9fcaa8aSmrg_LT_EOF
1011e9fcaa8aSmrg    fi
1012e9fcaa8aSmrg
1013e9fcaa8aSmrg    exit $EXIT_MISMATCH
1014e9fcaa8aSmrg  fi
1015e9fcaa8aSmrg}
1016e9fcaa8aSmrg
1017e9fcaa8aSmrg
1018e9fcaa8aSmrg# Shorthand for --mode=foo, only valid as the first argument
1019e9fcaa8aSmrgcase $1 in
1020e9fcaa8aSmrgclean|clea|cle|cl)
1021e9fcaa8aSmrg  shift; set dummy --mode clean ${1+"$@"}; shift
1022e9fcaa8aSmrg  ;;
1023e9fcaa8aSmrgcompile|compil|compi|comp|com|co|c)
1024e9fcaa8aSmrg  shift; set dummy --mode compile ${1+"$@"}; shift
1025e9fcaa8aSmrg  ;;
1026e9fcaa8aSmrgexecute|execut|execu|exec|exe|ex|e)
1027e9fcaa8aSmrg  shift; set dummy --mode execute ${1+"$@"}; shift
1028e9fcaa8aSmrg  ;;
1029e9fcaa8aSmrgfinish|finis|fini|fin|fi|f)
1030e9fcaa8aSmrg  shift; set dummy --mode finish ${1+"$@"}; shift
1031e9fcaa8aSmrg  ;;
1032e9fcaa8aSmrginstall|instal|insta|inst|ins|in|i)
1033e9fcaa8aSmrg  shift; set dummy --mode install ${1+"$@"}; shift
1034e9fcaa8aSmrg  ;;
1035e9fcaa8aSmrglink|lin|li|l)
1036e9fcaa8aSmrg  shift; set dummy --mode link ${1+"$@"}; shift
1037e9fcaa8aSmrg  ;;
1038e9fcaa8aSmrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
1039e9fcaa8aSmrg  shift; set dummy --mode uninstall ${1+"$@"}; shift
1040e9fcaa8aSmrg  ;;
1041e9fcaa8aSmrgesac
1042b4ee4795Smrg
10431ab64890Smrg
1044e9fcaa8aSmrg
1045e9fcaa8aSmrg# Option defaults:
1046e9fcaa8aSmrgopt_debug=:
1047e9fcaa8aSmrgopt_dry_run=false
1048e9fcaa8aSmrgopt_config=false
1049e9fcaa8aSmrgopt_preserve_dup_deps=false
1050e9fcaa8aSmrgopt_features=false
1051e9fcaa8aSmrgopt_finish=false
1052e9fcaa8aSmrgopt_help=false
1053e9fcaa8aSmrgopt_help_all=false
1054e9fcaa8aSmrgopt_silent=:
1055e9fcaa8aSmrgopt_verbose=:
1056e9fcaa8aSmrgopt_silent=false
1057e9fcaa8aSmrgopt_verbose=false
1058e9fcaa8aSmrg
1059e9fcaa8aSmrg
1060e9fcaa8aSmrg# Parse options once, thoroughly.  This comes as soon as possible in the
1061e9fcaa8aSmrg# script to make things like `--version' happen as quickly as we can.
1062e9fcaa8aSmrg{
1063e9fcaa8aSmrg  # this just eases exit handling
1064e9fcaa8aSmrg  while test $# -gt 0; do
106588de56ccSmrg    opt="$1"
106688de56ccSmrg    shift
106788de56ccSmrg    case $opt in
1068e9fcaa8aSmrg      --debug|-x)	opt_debug='set -x'
106988de56ccSmrg			func_echo "enabling shell trace mode"
107088de56ccSmrg			$opt_debug
107188de56ccSmrg			;;
1072e9fcaa8aSmrg      --dry-run|--dryrun|-n)
1073e9fcaa8aSmrg			opt_dry_run=:
107488de56ccSmrg			;;
1075e9fcaa8aSmrg      --config)
1076e9fcaa8aSmrg			opt_config=:
1077e9fcaa8aSmrgfunc_config
1078e9fcaa8aSmrg			;;
1079e9fcaa8aSmrg      --dlopen|-dlopen)
1080e9fcaa8aSmrg			optarg="$1"
1081e9fcaa8aSmrg			opt_dlopen="${opt_dlopen+$opt_dlopen
1082e9fcaa8aSmrg}$optarg"
108388de56ccSmrg			shift
108488de56ccSmrg			;;
108588de56ccSmrg      --preserve-dup-deps)
1086e9fcaa8aSmrg			opt_preserve_dup_deps=:
108788de56ccSmrg			;;
1088e9fcaa8aSmrg      --features)
1089e9fcaa8aSmrg			opt_features=:
1090e9fcaa8aSmrgfunc_features
1091e9fcaa8aSmrg			;;
1092e9fcaa8aSmrg      --finish)
1093e9fcaa8aSmrg			opt_finish=:
1094e9fcaa8aSmrgset dummy --mode finish ${1+"$@"}; shift
1095e9fcaa8aSmrg			;;
1096e9fcaa8aSmrg      --help)
1097e9fcaa8aSmrg			opt_help=:
1098e9fcaa8aSmrg			;;
1099e9fcaa8aSmrg      --help-all)
1100e9fcaa8aSmrg			opt_help_all=:
1101e9fcaa8aSmrgopt_help=': help-all'
1102e9fcaa8aSmrg			;;
1103e9fcaa8aSmrg      --mode)
1104e9fcaa8aSmrg			test $# = 0 && func_missing_arg $opt && break
1105e9fcaa8aSmrg			optarg="$1"
1106e9fcaa8aSmrg			opt_mode="$optarg"
1107e9fcaa8aSmrgcase $optarg in
1108e9fcaa8aSmrg  # Valid mode arguments:
1109e9fcaa8aSmrg  clean|compile|execute|finish|install|link|relink|uninstall) ;;
1110e9fcaa8aSmrg
1111e9fcaa8aSmrg  # Catch anything else as an error
1112e9fcaa8aSmrg  *) func_error "invalid argument for $opt"
1113e9fcaa8aSmrg     exit_cmd=exit
1114e9fcaa8aSmrg     break
1115e9fcaa8aSmrg     ;;
1116e9fcaa8aSmrgesac
1117e9fcaa8aSmrg			shift
1118e9fcaa8aSmrg			;;
1119e9fcaa8aSmrg      --no-silent|--no-quiet)
112088de56ccSmrg			opt_silent=false
1121e9fcaa8aSmrgfunc_append preserve_args " $opt"
112288de56ccSmrg			;;
1123e9fcaa8aSmrg      --no-verbose)
1124e9fcaa8aSmrg			opt_verbose=false
1125e9fcaa8aSmrgfunc_append preserve_args " $opt"
1126e9fcaa8aSmrg			;;
1127e9fcaa8aSmrg      --silent|--quiet)
1128e9fcaa8aSmrg			opt_silent=:
1129e9fcaa8aSmrgfunc_append preserve_args " $opt"
1130e9fcaa8aSmrg        opt_verbose=false
1131e9fcaa8aSmrg			;;
1132e9fcaa8aSmrg      --verbose|-v)
1133e9fcaa8aSmrg			opt_verbose=:
1134e9fcaa8aSmrgfunc_append preserve_args " $opt"
1135e9fcaa8aSmrgopt_silent=false
1136e9fcaa8aSmrg			;;
1137e9fcaa8aSmrg      --tag)
1138e9fcaa8aSmrg			test $# = 0 && func_missing_arg $opt && break
1139e9fcaa8aSmrg			optarg="$1"
1140e9fcaa8aSmrg			opt_tag="$optarg"
1141e9fcaa8aSmrgfunc_append preserve_args " $opt $optarg"
1142e9fcaa8aSmrgfunc_enable_tag "$optarg"
114388de56ccSmrg			shift
114488de56ccSmrg			;;
114588de56ccSmrg
1146e9fcaa8aSmrg      -\?|-h)		func_usage				;;
1147e9fcaa8aSmrg      --help)		func_help				;;
1148e9fcaa8aSmrg      --version)	func_version				;;
1149e9fcaa8aSmrg
115088de56ccSmrg      # Separate optargs to long options:
1151e9fcaa8aSmrg      --*=*)
1152e9fcaa8aSmrg			func_split_long_opt "$opt"
1153e9fcaa8aSmrg			set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
115488de56ccSmrg			shift
115588de56ccSmrg			;;
115688de56ccSmrg
1157e9fcaa8aSmrg      # Separate non-argument short options:
1158e9fcaa8aSmrg      -\?*|-h*|-n*|-v*)
1159e9fcaa8aSmrg			func_split_short_opt "$opt"
1160e9fcaa8aSmrg			set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
1161e9fcaa8aSmrg			shift
116288de56ccSmrg			;;
1163e9fcaa8aSmrg
1164e9fcaa8aSmrg      --)		break					;;
1165e9fcaa8aSmrg      -*)		func_fatal_help "unrecognized option \`$opt'" ;;
1166e9fcaa8aSmrg      *)		set dummy "$opt" ${1+"$@"};	shift; break  ;;
116788de56ccSmrg    esac
116888de56ccSmrg  done
116988de56ccSmrg
1170e9fcaa8aSmrg  # Validate options:
1171e9fcaa8aSmrg
1172e9fcaa8aSmrg  # save first non-option argument
1173e9fcaa8aSmrg  if test "$#" -gt 0; then
1174e9fcaa8aSmrg    nonopt="$opt"
1175e9fcaa8aSmrg    shift
1176e9fcaa8aSmrg  fi
1177e9fcaa8aSmrg
1178e9fcaa8aSmrg  # preserve --debug
1179e9fcaa8aSmrg  test "$opt_debug" = : || func_append preserve_args " --debug"
118088de56ccSmrg
118188de56ccSmrg  case $host in
118288de56ccSmrg    *cygwin* | *mingw* | *pw32* | *cegcc*)
118388de56ccSmrg      # don't eliminate duplications in $postdeps and $predeps
118488de56ccSmrg      opt_duplicate_compiler_generated_deps=:
1185b4ee4795Smrg      ;;
1186b4ee4795Smrg    *)
1187e9fcaa8aSmrg      opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
118888de56ccSmrg      ;;
118988de56ccSmrg  esac
11902e9c7c8cSmrg
1191e9fcaa8aSmrg  $opt_help || {
1192e9fcaa8aSmrg    # Sanity checks first:
1193e9fcaa8aSmrg    func_check_version_match
119488de56ccSmrg
1195e9fcaa8aSmrg    if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
1196e9fcaa8aSmrg      func_fatal_configuration "not configured to build any kind of library"
119788de56ccSmrg    fi
119888de56ccSmrg
1199e9fcaa8aSmrg    # Darwin sucks
1200e9fcaa8aSmrg    eval std_shrext=\"$shrext_cmds\"
120188de56ccSmrg
1202e9fcaa8aSmrg    # Only execute mode is allowed to have -dlopen flags.
1203e9fcaa8aSmrg    if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
1204e9fcaa8aSmrg      func_error "unrecognized option \`-dlopen'"
1205e9fcaa8aSmrg      $ECHO "$help" 1>&2
1206e9fcaa8aSmrg      exit $EXIT_FAILURE
1207e9fcaa8aSmrg    fi
12081ab64890Smrg
1209e9fcaa8aSmrg    # Change the help message to a mode-specific one.
1210e9fcaa8aSmrg    generic_help="$help"
1211e9fcaa8aSmrg    help="Try \`$progname --help --mode=$opt_mode' for more information."
1212e9fcaa8aSmrg  }
121388de56ccSmrg
121488de56ccSmrg
1215e9fcaa8aSmrg  # Bail if the options were screwed
1216e9fcaa8aSmrg  $exit_cmd $EXIT_FAILURE
1217e9fcaa8aSmrg}
121888de56ccSmrg
121988de56ccSmrg
12201ab64890Smrg
12211ab64890Smrg
1222e9fcaa8aSmrg## ----------- ##
1223e9fcaa8aSmrg##    Main.    ##
1224e9fcaa8aSmrg## ----------- ##
12251ab64890Smrg
122688de56ccSmrg# func_lalib_p file
122788de56ccSmrg# True iff FILE is a libtool `.la' library or `.lo' object file.
122888de56ccSmrg# This function is only a basic sanity check; it will hardly flush out
122988de56ccSmrg# determined imposters.
123088de56ccSmrgfunc_lalib_p ()
123188de56ccSmrg{
123288de56ccSmrg    test -f "$1" &&
123388de56ccSmrg      $SED -e 4q "$1" 2>/dev/null \
123488de56ccSmrg        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
123588de56ccSmrg}
12361ab64890Smrg
123788de56ccSmrg# func_lalib_unsafe_p file
123888de56ccSmrg# True iff FILE is a libtool `.la' library or `.lo' object file.
123988de56ccSmrg# This function implements the same check as func_lalib_p without
124088de56ccSmrg# resorting to external programs.  To this end, it redirects stdin and
124188de56ccSmrg# closes it afterwards, without saving the original file descriptor.
124288de56ccSmrg# As a safety measure, use it only where a negative result would be
124388de56ccSmrg# fatal anyway.  Works if `file' does not exist.
124488de56ccSmrgfunc_lalib_unsafe_p ()
124588de56ccSmrg{
124688de56ccSmrg    lalib_p=no
124788de56ccSmrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
124888de56ccSmrg	for lalib_p_l in 1 2 3 4
124988de56ccSmrg	do
125088de56ccSmrg	    read lalib_p_line
125188de56ccSmrg	    case "$lalib_p_line" in
125288de56ccSmrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
125388de56ccSmrg	    esac
125488de56ccSmrg	done
125588de56ccSmrg	exec 0<&5 5<&-
125688de56ccSmrg    fi
125788de56ccSmrg    test "$lalib_p" = yes
125888de56ccSmrg}
12591ab64890Smrg
126088de56ccSmrg# func_ltwrapper_script_p file
126188de56ccSmrg# True iff FILE is a libtool wrapper script
126288de56ccSmrg# This function is only a basic sanity check; it will hardly flush out
126388de56ccSmrg# determined imposters.
126488de56ccSmrgfunc_ltwrapper_script_p ()
126588de56ccSmrg{
126688de56ccSmrg    func_lalib_p "$1"
126788de56ccSmrg}
12681ab64890Smrg
126988de56ccSmrg# func_ltwrapper_executable_p file
127088de56ccSmrg# True iff FILE is a libtool wrapper executable
127188de56ccSmrg# This function is only a basic sanity check; it will hardly flush out
127288de56ccSmrg# determined imposters.
127388de56ccSmrgfunc_ltwrapper_executable_p ()
127488de56ccSmrg{
127588de56ccSmrg    func_ltwrapper_exec_suffix=
127688de56ccSmrg    case $1 in
127788de56ccSmrg    *.exe) ;;
127888de56ccSmrg    *) func_ltwrapper_exec_suffix=.exe ;;
127988de56ccSmrg    esac
128088de56ccSmrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
128188de56ccSmrg}
12822e9c7c8cSmrg
128388de56ccSmrg# func_ltwrapper_scriptname file
128488de56ccSmrg# Assumes file is an ltwrapper_executable
128588de56ccSmrg# uses $file to determine the appropriate filename for a
128688de56ccSmrg# temporary ltwrapper_script.
128788de56ccSmrgfunc_ltwrapper_scriptname ()
128888de56ccSmrg{
1289e9fcaa8aSmrg    func_dirname_and_basename "$1" "" "."
1290e9fcaa8aSmrg    func_stripname '' '.exe' "$func_basename_result"
1291e9fcaa8aSmrg    func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
129288de56ccSmrg}
129388de56ccSmrg
129488de56ccSmrg# func_ltwrapper_p file
129588de56ccSmrg# True iff FILE is a libtool wrapper script or wrapper executable
129688de56ccSmrg# This function is only a basic sanity check; it will hardly flush out
129788de56ccSmrg# determined imposters.
129888de56ccSmrgfunc_ltwrapper_p ()
129988de56ccSmrg{
130088de56ccSmrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
130188de56ccSmrg}
130288de56ccSmrg
130388de56ccSmrg
130488de56ccSmrg# func_execute_cmds commands fail_cmd
130588de56ccSmrg# Execute tilde-delimited COMMANDS.
130688de56ccSmrg# If FAIL_CMD is given, eval that upon failure.
130788de56ccSmrg# FAIL_CMD may read-access the current command in variable CMD!
130888de56ccSmrgfunc_execute_cmds ()
130988de56ccSmrg{
131088de56ccSmrg    $opt_debug
131188de56ccSmrg    save_ifs=$IFS; IFS='~'
131288de56ccSmrg    for cmd in $1; do
131388de56ccSmrg      IFS=$save_ifs
131488de56ccSmrg      eval cmd=\"$cmd\"
131588de56ccSmrg      func_show_eval "$cmd" "${2-:}"
131688de56ccSmrg    done
131788de56ccSmrg    IFS=$save_ifs
131888de56ccSmrg}
131988de56ccSmrg
132088de56ccSmrg
132188de56ccSmrg# func_source file
132288de56ccSmrg# Source FILE, adding directory component if necessary.
132388de56ccSmrg# Note that it is not necessary on cygwin/mingw to append a dot to
132488de56ccSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
132588de56ccSmrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
132688de56ccSmrg# `FILE.' does not work on cygwin managed mounts.
132788de56ccSmrgfunc_source ()
132888de56ccSmrg{
132988de56ccSmrg    $opt_debug
133088de56ccSmrg    case $1 in
133188de56ccSmrg    */* | *\\*)	. "$1" ;;
133288de56ccSmrg    *)		. "./$1" ;;
133388de56ccSmrg    esac
133488de56ccSmrg}
133588de56ccSmrg
133688de56ccSmrg
1337e9fcaa8aSmrg# func_resolve_sysroot PATH
1338e9fcaa8aSmrg# Replace a leading = in PATH with a sysroot.  Store the result into
1339e9fcaa8aSmrg# func_resolve_sysroot_result
1340e9fcaa8aSmrgfunc_resolve_sysroot ()
1341e9fcaa8aSmrg{
1342e9fcaa8aSmrg  func_resolve_sysroot_result=$1
1343e9fcaa8aSmrg  case $func_resolve_sysroot_result in
1344e9fcaa8aSmrg  =*)
1345e9fcaa8aSmrg    func_stripname '=' '' "$func_resolve_sysroot_result"
1346e9fcaa8aSmrg    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
1347e9fcaa8aSmrg    ;;
1348e9fcaa8aSmrg  esac
1349e9fcaa8aSmrg}
1350e9fcaa8aSmrg
1351e9fcaa8aSmrg# func_replace_sysroot PATH
1352e9fcaa8aSmrg# If PATH begins with the sysroot, replace it with = and
1353e9fcaa8aSmrg# store the result into func_replace_sysroot_result.
1354e9fcaa8aSmrgfunc_replace_sysroot ()
1355e9fcaa8aSmrg{
1356e9fcaa8aSmrg  case "$lt_sysroot:$1" in
1357e9fcaa8aSmrg  ?*:"$lt_sysroot"*)
1358e9fcaa8aSmrg    func_stripname "$lt_sysroot" '' "$1"
1359e9fcaa8aSmrg    func_replace_sysroot_result="=$func_stripname_result"
1360e9fcaa8aSmrg    ;;
1361e9fcaa8aSmrg  *)
1362e9fcaa8aSmrg    # Including no sysroot.
1363e9fcaa8aSmrg    func_replace_sysroot_result=$1
1364e9fcaa8aSmrg    ;;
1365e9fcaa8aSmrg  esac
1366e9fcaa8aSmrg}
1367e9fcaa8aSmrg
136888de56ccSmrg# func_infer_tag arg
136988de56ccSmrg# Infer tagged configuration to use if any are available and
137088de56ccSmrg# if one wasn't chosen via the "--tag" command line option.
137188de56ccSmrg# Only attempt this if the compiler in the base compile
137288de56ccSmrg# command doesn't match the default compiler.
137388de56ccSmrg# arg is usually of the form 'gcc ...'
137488de56ccSmrgfunc_infer_tag ()
137588de56ccSmrg{
137688de56ccSmrg    $opt_debug
137788de56ccSmrg    if test -n "$available_tags" && test -z "$tagname"; then
137888de56ccSmrg      CC_quoted=
137988de56ccSmrg      for arg in $CC; do
1380e9fcaa8aSmrg	func_append_quoted CC_quoted "$arg"
138188de56ccSmrg      done
1382e9fcaa8aSmrg      CC_expanded=`func_echo_all $CC`
1383e9fcaa8aSmrg      CC_quoted_expanded=`func_echo_all $CC_quoted`
138488de56ccSmrg      case $@ in
138588de56ccSmrg      # Blanks in the command may have been stripped by the calling shell,
138688de56ccSmrg      # but not from the CC environment variable when configure was run.
1387e9fcaa8aSmrg      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1388e9fcaa8aSmrg      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
138988de56ccSmrg      # Blanks at the start of $base_compile will cause this to fail
139088de56ccSmrg      # if we don't check for them as well.
139188de56ccSmrg      *)
139288de56ccSmrg	for z in $available_tags; do
139388de56ccSmrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
139488de56ccSmrg	    # Evaluate the configuration.
139588de56ccSmrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
139688de56ccSmrg	    CC_quoted=
139788de56ccSmrg	    for arg in $CC; do
139888de56ccSmrg	      # Double-quote args containing other shell metacharacters.
1399e9fcaa8aSmrg	      func_append_quoted CC_quoted "$arg"
140088de56ccSmrg	    done
1401e9fcaa8aSmrg	    CC_expanded=`func_echo_all $CC`
1402e9fcaa8aSmrg	    CC_quoted_expanded=`func_echo_all $CC_quoted`
140388de56ccSmrg	    case "$@ " in
1404e9fcaa8aSmrg	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1405e9fcaa8aSmrg	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
140688de56ccSmrg	      # The compiler in the base compile command matches
140788de56ccSmrg	      # the one in the tagged configuration.
140888de56ccSmrg	      # Assume this is the tagged configuration we want.
140988de56ccSmrg	      tagname=$z
141088de56ccSmrg	      break
141188de56ccSmrg	      ;;
141288de56ccSmrg	    esac
141388de56ccSmrg	  fi
141488de56ccSmrg	done
141588de56ccSmrg	# If $tagname still isn't set, then no tagged configuration
141688de56ccSmrg	# was found and let the user know that the "--tag" command
141788de56ccSmrg	# line option must be used.
141888de56ccSmrg	if test -z "$tagname"; then
141988de56ccSmrg	  func_echo "unable to infer tagged configuration"
142088de56ccSmrg	  func_fatal_error "specify a tag with \`--tag'"
142188de56ccSmrg#	else
142288de56ccSmrg#	  func_verbose "using $tagname tagged configuration"
142388de56ccSmrg	fi
142488de56ccSmrg	;;
142588de56ccSmrg      esac
142688de56ccSmrg    fi
142788de56ccSmrg}
142888de56ccSmrg
142988de56ccSmrg
143088de56ccSmrg
143188de56ccSmrg# func_write_libtool_object output_name pic_name nonpic_name
143288de56ccSmrg# Create a libtool object file (analogous to a ".la" file),
143388de56ccSmrg# but don't create it if we're doing a dry run.
143488de56ccSmrgfunc_write_libtool_object ()
143588de56ccSmrg{
143688de56ccSmrg    write_libobj=${1}
143788de56ccSmrg    if test "$build_libtool_libs" = yes; then
143888de56ccSmrg      write_lobj=\'${2}\'
143988de56ccSmrg    else
144088de56ccSmrg      write_lobj=none
144188de56ccSmrg    fi
144288de56ccSmrg
144388de56ccSmrg    if test "$build_old_libs" = yes; then
144488de56ccSmrg      write_oldobj=\'${3}\'
144588de56ccSmrg    else
144688de56ccSmrg      write_oldobj=none
144788de56ccSmrg    fi
144888de56ccSmrg
144988de56ccSmrg    $opt_dry_run || {
145088de56ccSmrg      cat >${write_libobj}T <<EOF
145188de56ccSmrg# $write_libobj - a libtool object file
145288de56ccSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
145388de56ccSmrg#
145488de56ccSmrg# Please DO NOT delete this file!
145588de56ccSmrg# It is necessary for linking the library.
145688de56ccSmrg
145788de56ccSmrg# Name of the PIC object.
145888de56ccSmrgpic_object=$write_lobj
145988de56ccSmrg
146088de56ccSmrg# Name of the non-PIC object
146188de56ccSmrgnon_pic_object=$write_oldobj
146288de56ccSmrg
146388de56ccSmrgEOF
146488de56ccSmrg      $MV "${write_libobj}T" "${write_libobj}"
146588de56ccSmrg    }
146688de56ccSmrg}
146788de56ccSmrg
1468e9fcaa8aSmrg
1469e9fcaa8aSmrg##################################################
1470e9fcaa8aSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
1471e9fcaa8aSmrg##################################################
1472e9fcaa8aSmrg
1473e9fcaa8aSmrg# func_convert_core_file_wine_to_w32 ARG
1474e9fcaa8aSmrg# Helper function used by file name conversion functions when $build is *nix,
1475e9fcaa8aSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a
1476e9fcaa8aSmrg# correctly configured wine environment available, with the winepath program
1477e9fcaa8aSmrg# in $build's $PATH.
1478e9fcaa8aSmrg#
1479e9fcaa8aSmrg# ARG is the $build file name to be converted to w32 format.
1480e9fcaa8aSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will
1481e9fcaa8aSmrg# be empty on error (or when ARG is empty)
1482e9fcaa8aSmrgfunc_convert_core_file_wine_to_w32 ()
1483e9fcaa8aSmrg{
1484e9fcaa8aSmrg  $opt_debug
1485e9fcaa8aSmrg  func_convert_core_file_wine_to_w32_result="$1"
1486e9fcaa8aSmrg  if test -n "$1"; then
1487e9fcaa8aSmrg    # Unfortunately, winepath does not exit with a non-zero error code, so we
1488e9fcaa8aSmrg    # are forced to check the contents of stdout. On the other hand, if the
1489e9fcaa8aSmrg    # command is not found, the shell will set an exit code of 127 and print
1490e9fcaa8aSmrg    # *an error message* to stdout. So we must check for both error code of
1491e9fcaa8aSmrg    # zero AND non-empty stdout, which explains the odd construction:
1492e9fcaa8aSmrg    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
1493e9fcaa8aSmrg    if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
1494e9fcaa8aSmrg      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
1495e9fcaa8aSmrg        $SED -e "$lt_sed_naive_backslashify"`
1496e9fcaa8aSmrg    else
1497e9fcaa8aSmrg      func_convert_core_file_wine_to_w32_result=
1498e9fcaa8aSmrg    fi
1499e9fcaa8aSmrg  fi
1500e9fcaa8aSmrg}
1501e9fcaa8aSmrg# end: func_convert_core_file_wine_to_w32
1502e9fcaa8aSmrg
1503e9fcaa8aSmrg
1504e9fcaa8aSmrg# func_convert_core_path_wine_to_w32 ARG
1505e9fcaa8aSmrg# Helper function used by path conversion functions when $build is *nix, and
1506e9fcaa8aSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
1507e9fcaa8aSmrg# configured wine environment available, with the winepath program in $build's
1508e9fcaa8aSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters.
1509e9fcaa8aSmrg#
1510e9fcaa8aSmrg# ARG is path to be converted from $build format to win32.
1511e9fcaa8aSmrg# Result is available in $func_convert_core_path_wine_to_w32_result.
1512e9fcaa8aSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names
1513e9fcaa8aSmrg# are convertible, then the result may be empty.
1514e9fcaa8aSmrgfunc_convert_core_path_wine_to_w32 ()
1515e9fcaa8aSmrg{
1516e9fcaa8aSmrg  $opt_debug
1517e9fcaa8aSmrg  # unfortunately, winepath doesn't convert paths, only file names
1518e9fcaa8aSmrg  func_convert_core_path_wine_to_w32_result=""
1519e9fcaa8aSmrg  if test -n "$1"; then
1520e9fcaa8aSmrg    oldIFS=$IFS
1521e9fcaa8aSmrg    IFS=:
1522e9fcaa8aSmrg    for func_convert_core_path_wine_to_w32_f in $1; do
1523e9fcaa8aSmrg      IFS=$oldIFS
1524e9fcaa8aSmrg      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
1525e9fcaa8aSmrg      if test -n "$func_convert_core_file_wine_to_w32_result" ; then
1526e9fcaa8aSmrg        if test -z "$func_convert_core_path_wine_to_w32_result"; then
1527e9fcaa8aSmrg          func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
1528e9fcaa8aSmrg        else
1529e9fcaa8aSmrg          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
1530e9fcaa8aSmrg        fi
1531e9fcaa8aSmrg      fi
1532e9fcaa8aSmrg    done
1533e9fcaa8aSmrg    IFS=$oldIFS
1534e9fcaa8aSmrg  fi
1535e9fcaa8aSmrg}
1536e9fcaa8aSmrg# end: func_convert_core_path_wine_to_w32
1537e9fcaa8aSmrg
1538e9fcaa8aSmrg
1539e9fcaa8aSmrg# func_cygpath ARGS...
1540e9fcaa8aSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
1541e9fcaa8aSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
1542e9fcaa8aSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
1543e9fcaa8aSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input
1544e9fcaa8aSmrg# file name or path is assumed to be in w32 format, as previously converted
1545e9fcaa8aSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name
1546e9fcaa8aSmrg# or path in func_cygpath_result (input file name or path is assumed to be in
1547e9fcaa8aSmrg# Cygwin format). Returns an empty string on error.
1548e9fcaa8aSmrg#
1549e9fcaa8aSmrg# ARGS are passed to cygpath, with the last one being the file name or path to
1550e9fcaa8aSmrg# be converted.
1551e9fcaa8aSmrg#
1552e9fcaa8aSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
1553e9fcaa8aSmrg# environment variable; do not put it in $PATH.
1554e9fcaa8aSmrgfunc_cygpath ()
1555e9fcaa8aSmrg{
1556e9fcaa8aSmrg  $opt_debug
1557e9fcaa8aSmrg  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
1558e9fcaa8aSmrg    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
1559e9fcaa8aSmrg    if test "$?" -ne 0; then
1560e9fcaa8aSmrg      # on failure, ensure result is empty
1561e9fcaa8aSmrg      func_cygpath_result=
1562e9fcaa8aSmrg    fi
1563e9fcaa8aSmrg  else
1564e9fcaa8aSmrg    func_cygpath_result=
1565e9fcaa8aSmrg    func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
1566e9fcaa8aSmrg  fi
1567e9fcaa8aSmrg}
1568e9fcaa8aSmrg#end: func_cygpath
1569e9fcaa8aSmrg
1570e9fcaa8aSmrg
1571e9fcaa8aSmrg# func_convert_core_msys_to_w32 ARG
1572e9fcaa8aSmrg# Convert file name or path ARG from MSYS format to w32 format.  Return
1573e9fcaa8aSmrg# result in func_convert_core_msys_to_w32_result.
1574e9fcaa8aSmrgfunc_convert_core_msys_to_w32 ()
1575e9fcaa8aSmrg{
1576e9fcaa8aSmrg  $opt_debug
1577e9fcaa8aSmrg  # awkward: cmd appends spaces to result
1578e9fcaa8aSmrg  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
1579e9fcaa8aSmrg    $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
1580e9fcaa8aSmrg}
1581e9fcaa8aSmrg#end: func_convert_core_msys_to_w32
1582e9fcaa8aSmrg
1583e9fcaa8aSmrg
1584e9fcaa8aSmrg# func_convert_file_check ARG1 ARG2
1585e9fcaa8aSmrg# Verify that ARG1 (a file name in $build format) was converted to $host
1586e9fcaa8aSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting
1587e9fcaa8aSmrg# func_to_host_file_result to ARG1).
1588e9fcaa8aSmrgfunc_convert_file_check ()
1589e9fcaa8aSmrg{
1590e9fcaa8aSmrg  $opt_debug
1591e9fcaa8aSmrg  if test -z "$2" && test -n "$1" ; then
1592e9fcaa8aSmrg    func_error "Could not determine host file name corresponding to"
1593e9fcaa8aSmrg    func_error "  \`$1'"
1594e9fcaa8aSmrg    func_error "Continuing, but uninstalled executables may not work."
1595e9fcaa8aSmrg    # Fallback:
1596e9fcaa8aSmrg    func_to_host_file_result="$1"
1597e9fcaa8aSmrg  fi
1598e9fcaa8aSmrg}
1599e9fcaa8aSmrg# end func_convert_file_check
1600e9fcaa8aSmrg
1601e9fcaa8aSmrg
1602e9fcaa8aSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
1603e9fcaa8aSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host
1604e9fcaa8aSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
1605e9fcaa8aSmrg# func_to_host_file_result to a simplistic fallback value (see below).
1606e9fcaa8aSmrgfunc_convert_path_check ()
1607e9fcaa8aSmrg{
1608e9fcaa8aSmrg  $opt_debug
1609e9fcaa8aSmrg  if test -z "$4" && test -n "$3"; then
1610e9fcaa8aSmrg    func_error "Could not determine the host path corresponding to"
1611e9fcaa8aSmrg    func_error "  \`$3'"
1612e9fcaa8aSmrg    func_error "Continuing, but uninstalled executables may not work."
1613e9fcaa8aSmrg    # Fallback.  This is a deliberately simplistic "conversion" and
1614e9fcaa8aSmrg    # should not be "improved".  See libtool.info.
1615e9fcaa8aSmrg    if test "x$1" != "x$2"; then
1616e9fcaa8aSmrg      lt_replace_pathsep_chars="s|$1|$2|g"
1617e9fcaa8aSmrg      func_to_host_path_result=`echo "$3" |
1618e9fcaa8aSmrg        $SED -e "$lt_replace_pathsep_chars"`
1619e9fcaa8aSmrg    else
1620e9fcaa8aSmrg      func_to_host_path_result="$3"
1621e9fcaa8aSmrg    fi
1622e9fcaa8aSmrg  fi
1623e9fcaa8aSmrg}
1624e9fcaa8aSmrg# end func_convert_path_check
1625e9fcaa8aSmrg
1626e9fcaa8aSmrg
1627e9fcaa8aSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
1628e9fcaa8aSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
1629e9fcaa8aSmrg# and appending REPL if ORIG matches BACKPAT.
1630e9fcaa8aSmrgfunc_convert_path_front_back_pathsep ()
1631e9fcaa8aSmrg{
1632e9fcaa8aSmrg  $opt_debug
1633e9fcaa8aSmrg  case $4 in
1634e9fcaa8aSmrg  $1 ) func_to_host_path_result="$3$func_to_host_path_result"
1635e9fcaa8aSmrg    ;;
1636e9fcaa8aSmrg  esac
1637e9fcaa8aSmrg  case $4 in
1638e9fcaa8aSmrg  $2 ) func_append func_to_host_path_result "$3"
1639e9fcaa8aSmrg    ;;
1640e9fcaa8aSmrg  esac
1641e9fcaa8aSmrg}
1642e9fcaa8aSmrg# end func_convert_path_front_back_pathsep
1643e9fcaa8aSmrg
1644e9fcaa8aSmrg
1645e9fcaa8aSmrg##################################################
1646e9fcaa8aSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS #
1647e9fcaa8aSmrg##################################################
1648e9fcaa8aSmrg# invoked via `$to_host_file_cmd ARG'
1649e9fcaa8aSmrg#
1650e9fcaa8aSmrg# In each case, ARG is the path to be converted from $build to $host format.
1651e9fcaa8aSmrg# Result will be available in $func_to_host_file_result.
1652e9fcaa8aSmrg
1653e9fcaa8aSmrg
1654e9fcaa8aSmrg# func_to_host_file ARG
1655e9fcaa8aSmrg# Converts the file name ARG from $build format to $host format. Return result
1656e9fcaa8aSmrg# in func_to_host_file_result.
1657e9fcaa8aSmrgfunc_to_host_file ()
1658e9fcaa8aSmrg{
1659e9fcaa8aSmrg  $opt_debug
1660e9fcaa8aSmrg  $to_host_file_cmd "$1"
1661e9fcaa8aSmrg}
1662e9fcaa8aSmrg# end func_to_host_file
1663e9fcaa8aSmrg
1664e9fcaa8aSmrg
1665e9fcaa8aSmrg# func_to_tool_file ARG LAZY
1666e9fcaa8aSmrg# converts the file name ARG from $build format to toolchain format. Return
1667e9fcaa8aSmrg# result in func_to_tool_file_result.  If the conversion in use is listed
1668e9fcaa8aSmrg# in (the comma separated) LAZY, no conversion takes place.
1669e9fcaa8aSmrgfunc_to_tool_file ()
1670e9fcaa8aSmrg{
1671e9fcaa8aSmrg  $opt_debug
1672e9fcaa8aSmrg  case ,$2, in
1673e9fcaa8aSmrg    *,"$to_tool_file_cmd",*)
1674e9fcaa8aSmrg      func_to_tool_file_result=$1
1675e9fcaa8aSmrg      ;;
1676e9fcaa8aSmrg    *)
1677e9fcaa8aSmrg      $to_tool_file_cmd "$1"
1678e9fcaa8aSmrg      func_to_tool_file_result=$func_to_host_file_result
1679e9fcaa8aSmrg      ;;
1680e9fcaa8aSmrg  esac
1681e9fcaa8aSmrg}
1682e9fcaa8aSmrg# end func_to_tool_file
1683e9fcaa8aSmrg
1684e9fcaa8aSmrg
1685e9fcaa8aSmrg# func_convert_file_noop ARG
1686e9fcaa8aSmrg# Copy ARG to func_to_host_file_result.
1687e9fcaa8aSmrgfunc_convert_file_noop ()
1688e9fcaa8aSmrg{
1689e9fcaa8aSmrg  func_to_host_file_result="$1"
1690e9fcaa8aSmrg}
1691e9fcaa8aSmrg# end func_convert_file_noop
1692e9fcaa8aSmrg
1693e9fcaa8aSmrg
1694e9fcaa8aSmrg# func_convert_file_msys_to_w32 ARG
1695e9fcaa8aSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
1696e9fcaa8aSmrg# conversion to w32 is not available inside the cwrapper.  Returns result in
1697e9fcaa8aSmrg# func_to_host_file_result.
1698e9fcaa8aSmrgfunc_convert_file_msys_to_w32 ()
1699e9fcaa8aSmrg{
1700e9fcaa8aSmrg  $opt_debug
1701e9fcaa8aSmrg  func_to_host_file_result="$1"
1702e9fcaa8aSmrg  if test -n "$1"; then
1703e9fcaa8aSmrg    func_convert_core_msys_to_w32 "$1"
1704e9fcaa8aSmrg    func_to_host_file_result="$func_convert_core_msys_to_w32_result"
1705e9fcaa8aSmrg  fi
1706e9fcaa8aSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1707e9fcaa8aSmrg}
1708e9fcaa8aSmrg# end func_convert_file_msys_to_w32
1709e9fcaa8aSmrg
1710e9fcaa8aSmrg
1711e9fcaa8aSmrg# func_convert_file_cygwin_to_w32 ARG
1712e9fcaa8aSmrg# Convert file name ARG from Cygwin to w32 format.  Returns result in
1713e9fcaa8aSmrg# func_to_host_file_result.
1714e9fcaa8aSmrgfunc_convert_file_cygwin_to_w32 ()
1715e9fcaa8aSmrg{
1716e9fcaa8aSmrg  $opt_debug
1717e9fcaa8aSmrg  func_to_host_file_result="$1"
1718e9fcaa8aSmrg  if test -n "$1"; then
1719e9fcaa8aSmrg    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
1720e9fcaa8aSmrg    # LT_CYGPATH in this case.
1721e9fcaa8aSmrg    func_to_host_file_result=`cygpath -m "$1"`
1722e9fcaa8aSmrg  fi
1723e9fcaa8aSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1724e9fcaa8aSmrg}
1725e9fcaa8aSmrg# end func_convert_file_cygwin_to_w32
1726e9fcaa8aSmrg
1727e9fcaa8aSmrg
1728e9fcaa8aSmrg# func_convert_file_nix_to_w32 ARG
1729e9fcaa8aSmrg# Convert file name ARG from *nix to w32 format.  Requires a wine environment
1730e9fcaa8aSmrg# and a working winepath. Returns result in func_to_host_file_result.
1731e9fcaa8aSmrgfunc_convert_file_nix_to_w32 ()
1732e9fcaa8aSmrg{
1733e9fcaa8aSmrg  $opt_debug
1734e9fcaa8aSmrg  func_to_host_file_result="$1"
1735e9fcaa8aSmrg  if test -n "$1"; then
1736e9fcaa8aSmrg    func_convert_core_file_wine_to_w32 "$1"
1737e9fcaa8aSmrg    func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
1738e9fcaa8aSmrg  fi
1739e9fcaa8aSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1740e9fcaa8aSmrg}
1741e9fcaa8aSmrg# end func_convert_file_nix_to_w32
1742e9fcaa8aSmrg
1743e9fcaa8aSmrg
1744e9fcaa8aSmrg# func_convert_file_msys_to_cygwin ARG
1745e9fcaa8aSmrg# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
1746e9fcaa8aSmrg# Returns result in func_to_host_file_result.
1747e9fcaa8aSmrgfunc_convert_file_msys_to_cygwin ()
1748e9fcaa8aSmrg{
1749e9fcaa8aSmrg  $opt_debug
1750e9fcaa8aSmrg  func_to_host_file_result="$1"
1751e9fcaa8aSmrg  if test -n "$1"; then
1752e9fcaa8aSmrg    func_convert_core_msys_to_w32 "$1"
1753e9fcaa8aSmrg    func_cygpath -u "$func_convert_core_msys_to_w32_result"
1754e9fcaa8aSmrg    func_to_host_file_result="$func_cygpath_result"
1755e9fcaa8aSmrg  fi
1756e9fcaa8aSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1757e9fcaa8aSmrg}
1758e9fcaa8aSmrg# end func_convert_file_msys_to_cygwin
1759e9fcaa8aSmrg
1760e9fcaa8aSmrg
1761e9fcaa8aSmrg# func_convert_file_nix_to_cygwin ARG
1762e9fcaa8aSmrg# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
1763e9fcaa8aSmrg# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
1764e9fcaa8aSmrg# in func_to_host_file_result.
1765e9fcaa8aSmrgfunc_convert_file_nix_to_cygwin ()
1766e9fcaa8aSmrg{
1767e9fcaa8aSmrg  $opt_debug
1768e9fcaa8aSmrg  func_to_host_file_result="$1"
1769e9fcaa8aSmrg  if test -n "$1"; then
1770e9fcaa8aSmrg    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
1771e9fcaa8aSmrg    func_convert_core_file_wine_to_w32 "$1"
1772e9fcaa8aSmrg    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
1773e9fcaa8aSmrg    func_to_host_file_result="$func_cygpath_result"
1774e9fcaa8aSmrg  fi
1775e9fcaa8aSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1776e9fcaa8aSmrg}
1777e9fcaa8aSmrg# end func_convert_file_nix_to_cygwin
1778e9fcaa8aSmrg
1779e9fcaa8aSmrg
1780e9fcaa8aSmrg#############################################
1781e9fcaa8aSmrg# $build to $host PATH CONVERSION FUNCTIONS #
1782e9fcaa8aSmrg#############################################
1783e9fcaa8aSmrg# invoked via `$to_host_path_cmd ARG'
1784e9fcaa8aSmrg#
1785e9fcaa8aSmrg# In each case, ARG is the path to be converted from $build to $host format.
1786e9fcaa8aSmrg# The result will be available in $func_to_host_path_result.
1787e9fcaa8aSmrg#
1788e9fcaa8aSmrg# Path separators are also converted from $build format to $host format.  If
1789e9fcaa8aSmrg# ARG begins or ends with a path separator character, it is preserved (but
1790e9fcaa8aSmrg# converted to $host format) on output.
1791e9fcaa8aSmrg#
1792e9fcaa8aSmrg# All path conversion functions are named using the following convention:
1793e9fcaa8aSmrg#   file name conversion function    : func_convert_file_X_to_Y ()
1794e9fcaa8aSmrg#   path conversion function         : func_convert_path_X_to_Y ()
1795e9fcaa8aSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the
1796e9fcaa8aSmrg# same.  If conversion functions are added for new $build/$host combinations,
1797e9fcaa8aSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd
1798e9fcaa8aSmrg# will break.
1799e9fcaa8aSmrg
1800e9fcaa8aSmrg
1801e9fcaa8aSmrg# func_init_to_host_path_cmd
1802e9fcaa8aSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the
1803e9fcaa8aSmrg# appropriate value, based on the value of $to_host_file_cmd.
1804e9fcaa8aSmrgto_host_path_cmd=
1805e9fcaa8aSmrgfunc_init_to_host_path_cmd ()
1806e9fcaa8aSmrg{
1807e9fcaa8aSmrg  $opt_debug
1808e9fcaa8aSmrg  if test -z "$to_host_path_cmd"; then
1809e9fcaa8aSmrg    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
1810e9fcaa8aSmrg    to_host_path_cmd="func_convert_path_${func_stripname_result}"
1811e9fcaa8aSmrg  fi
1812e9fcaa8aSmrg}
1813e9fcaa8aSmrg
1814e9fcaa8aSmrg
1815e9fcaa8aSmrg# func_to_host_path ARG
1816e9fcaa8aSmrg# Converts the path ARG from $build format to $host format. Return result
1817e9fcaa8aSmrg# in func_to_host_path_result.
1818e9fcaa8aSmrgfunc_to_host_path ()
1819e9fcaa8aSmrg{
1820e9fcaa8aSmrg  $opt_debug
1821e9fcaa8aSmrg  func_init_to_host_path_cmd
1822e9fcaa8aSmrg  $to_host_path_cmd "$1"
1823e9fcaa8aSmrg}
1824e9fcaa8aSmrg# end func_to_host_path
1825e9fcaa8aSmrg
1826e9fcaa8aSmrg
1827e9fcaa8aSmrg# func_convert_path_noop ARG
1828e9fcaa8aSmrg# Copy ARG to func_to_host_path_result.
1829e9fcaa8aSmrgfunc_convert_path_noop ()
1830e9fcaa8aSmrg{
1831e9fcaa8aSmrg  func_to_host_path_result="$1"
1832e9fcaa8aSmrg}
1833e9fcaa8aSmrg# end func_convert_path_noop
1834e9fcaa8aSmrg
1835e9fcaa8aSmrg
1836e9fcaa8aSmrg# func_convert_path_msys_to_w32 ARG
1837e9fcaa8aSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
1838e9fcaa8aSmrg# conversion to w32 is not available inside the cwrapper.  Returns result in
1839e9fcaa8aSmrg# func_to_host_path_result.
1840e9fcaa8aSmrgfunc_convert_path_msys_to_w32 ()
1841e9fcaa8aSmrg{
1842e9fcaa8aSmrg  $opt_debug
1843e9fcaa8aSmrg  func_to_host_path_result="$1"
1844e9fcaa8aSmrg  if test -n "$1"; then
1845e9fcaa8aSmrg    # Remove leading and trailing path separator characters from ARG.  MSYS
1846e9fcaa8aSmrg    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
1847e9fcaa8aSmrg    # and winepath ignores them completely.
1848e9fcaa8aSmrg    func_stripname : : "$1"
1849e9fcaa8aSmrg    func_to_host_path_tmp1=$func_stripname_result
1850e9fcaa8aSmrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1851e9fcaa8aSmrg    func_to_host_path_result="$func_convert_core_msys_to_w32_result"
1852e9fcaa8aSmrg    func_convert_path_check : ";" \
1853e9fcaa8aSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1854e9fcaa8aSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1855e9fcaa8aSmrg  fi
1856e9fcaa8aSmrg}
1857e9fcaa8aSmrg# end func_convert_path_msys_to_w32
1858e9fcaa8aSmrg
1859e9fcaa8aSmrg
1860e9fcaa8aSmrg# func_convert_path_cygwin_to_w32 ARG
1861e9fcaa8aSmrg# Convert path ARG from Cygwin to w32 format.  Returns result in
1862e9fcaa8aSmrg# func_to_host_file_result.
1863e9fcaa8aSmrgfunc_convert_path_cygwin_to_w32 ()
1864e9fcaa8aSmrg{
1865e9fcaa8aSmrg  $opt_debug
1866e9fcaa8aSmrg  func_to_host_path_result="$1"
1867e9fcaa8aSmrg  if test -n "$1"; then
1868e9fcaa8aSmrg    # See func_convert_path_msys_to_w32:
1869e9fcaa8aSmrg    func_stripname : : "$1"
1870e9fcaa8aSmrg    func_to_host_path_tmp1=$func_stripname_result
1871e9fcaa8aSmrg    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
1872e9fcaa8aSmrg    func_convert_path_check : ";" \
1873e9fcaa8aSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1874e9fcaa8aSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1875e9fcaa8aSmrg  fi
1876e9fcaa8aSmrg}
1877e9fcaa8aSmrg# end func_convert_path_cygwin_to_w32
1878e9fcaa8aSmrg
1879e9fcaa8aSmrg
1880e9fcaa8aSmrg# func_convert_path_nix_to_w32 ARG
1881e9fcaa8aSmrg# Convert path ARG from *nix to w32 format.  Requires a wine environment and
1882e9fcaa8aSmrg# a working winepath.  Returns result in func_to_host_file_result.
1883e9fcaa8aSmrgfunc_convert_path_nix_to_w32 ()
1884e9fcaa8aSmrg{
1885e9fcaa8aSmrg  $opt_debug
1886e9fcaa8aSmrg  func_to_host_path_result="$1"
1887e9fcaa8aSmrg  if test -n "$1"; then
1888e9fcaa8aSmrg    # See func_convert_path_msys_to_w32:
1889e9fcaa8aSmrg    func_stripname : : "$1"
1890e9fcaa8aSmrg    func_to_host_path_tmp1=$func_stripname_result
1891e9fcaa8aSmrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1892e9fcaa8aSmrg    func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
1893e9fcaa8aSmrg    func_convert_path_check : ";" \
1894e9fcaa8aSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1895e9fcaa8aSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1896e9fcaa8aSmrg  fi
1897e9fcaa8aSmrg}
1898e9fcaa8aSmrg# end func_convert_path_nix_to_w32
1899e9fcaa8aSmrg
1900e9fcaa8aSmrg
1901e9fcaa8aSmrg# func_convert_path_msys_to_cygwin ARG
1902e9fcaa8aSmrg# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
1903e9fcaa8aSmrg# Returns result in func_to_host_file_result.
1904e9fcaa8aSmrgfunc_convert_path_msys_to_cygwin ()
1905e9fcaa8aSmrg{
1906e9fcaa8aSmrg  $opt_debug
1907e9fcaa8aSmrg  func_to_host_path_result="$1"
1908e9fcaa8aSmrg  if test -n "$1"; then
1909e9fcaa8aSmrg    # See func_convert_path_msys_to_w32:
1910e9fcaa8aSmrg    func_stripname : : "$1"
1911e9fcaa8aSmrg    func_to_host_path_tmp1=$func_stripname_result
1912e9fcaa8aSmrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1913e9fcaa8aSmrg    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
1914e9fcaa8aSmrg    func_to_host_path_result="$func_cygpath_result"
1915e9fcaa8aSmrg    func_convert_path_check : : \
1916e9fcaa8aSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1917e9fcaa8aSmrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1918e9fcaa8aSmrg  fi
1919e9fcaa8aSmrg}
1920e9fcaa8aSmrg# end func_convert_path_msys_to_cygwin
1921e9fcaa8aSmrg
1922e9fcaa8aSmrg
1923e9fcaa8aSmrg# func_convert_path_nix_to_cygwin ARG
1924e9fcaa8aSmrg# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
1925e9fcaa8aSmrg# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
1926e9fcaa8aSmrg# func_to_host_file_result.
1927e9fcaa8aSmrgfunc_convert_path_nix_to_cygwin ()
1928e9fcaa8aSmrg{
1929e9fcaa8aSmrg  $opt_debug
1930e9fcaa8aSmrg  func_to_host_path_result="$1"
1931e9fcaa8aSmrg  if test -n "$1"; then
1932e9fcaa8aSmrg    # Remove leading and trailing path separator characters from
1933e9fcaa8aSmrg    # ARG. msys behavior is inconsistent here, cygpath turns them
1934e9fcaa8aSmrg    # into '.;' and ';.', and winepath ignores them completely.
1935e9fcaa8aSmrg    func_stripname : : "$1"
1936e9fcaa8aSmrg    func_to_host_path_tmp1=$func_stripname_result
1937e9fcaa8aSmrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1938e9fcaa8aSmrg    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
1939e9fcaa8aSmrg    func_to_host_path_result="$func_cygpath_result"
1940e9fcaa8aSmrg    func_convert_path_check : : \
1941e9fcaa8aSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1942e9fcaa8aSmrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1943e9fcaa8aSmrg  fi
1944e9fcaa8aSmrg}
1945e9fcaa8aSmrg# end func_convert_path_nix_to_cygwin
1946e9fcaa8aSmrg
1947e9fcaa8aSmrg
194888de56ccSmrg# func_mode_compile arg...
194988de56ccSmrgfunc_mode_compile ()
195088de56ccSmrg{
195188de56ccSmrg    $opt_debug
195288de56ccSmrg    # Get the compilation command and the source file.
195388de56ccSmrg    base_compile=
195488de56ccSmrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
195588de56ccSmrg    suppress_opt=yes
195688de56ccSmrg    suppress_output=
195788de56ccSmrg    arg_mode=normal
195888de56ccSmrg    libobj=
195988de56ccSmrg    later=
196088de56ccSmrg    pie_flag=
196188de56ccSmrg
196288de56ccSmrg    for arg
196388de56ccSmrg    do
196488de56ccSmrg      case $arg_mode in
196588de56ccSmrg      arg  )
196688de56ccSmrg	# do not "continue".  Instead, add this to base_compile
196788de56ccSmrg	lastarg="$arg"
196888de56ccSmrg	arg_mode=normal
196988de56ccSmrg	;;
197088de56ccSmrg
197188de56ccSmrg      target )
197288de56ccSmrg	libobj="$arg"
197388de56ccSmrg	arg_mode=normal
197488de56ccSmrg	continue
197588de56ccSmrg	;;
197688de56ccSmrg
197788de56ccSmrg      normal )
197888de56ccSmrg	# Accept any command-line options.
197988de56ccSmrg	case $arg in
198088de56ccSmrg	-o)
198188de56ccSmrg	  test -n "$libobj" && \
198288de56ccSmrg	    func_fatal_error "you cannot specify \`-o' more than once"
198388de56ccSmrg	  arg_mode=target
198488de56ccSmrg	  continue
198588de56ccSmrg	  ;;
198688de56ccSmrg
198788de56ccSmrg	-pie | -fpie | -fPIE)
1988e9fcaa8aSmrg          func_append pie_flag " $arg"
198988de56ccSmrg	  continue
199088de56ccSmrg	  ;;
199188de56ccSmrg
199288de56ccSmrg	-shared | -static | -prefer-pic | -prefer-non-pic)
1993e9fcaa8aSmrg	  func_append later " $arg"
199488de56ccSmrg	  continue
199588de56ccSmrg	  ;;
199688de56ccSmrg
199788de56ccSmrg	-no-suppress)
19981ab64890Smrg	  suppress_opt=no
19991ab64890Smrg	  continue
20001ab64890Smrg	  ;;
20011ab64890Smrg
20021ab64890Smrg	-Xcompiler)
20031ab64890Smrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
20041ab64890Smrg	  continue      #  The current "srcfile" will either be retained or
20051ab64890Smrg	  ;;            #  replaced later.  I would guess that would be a bug.
20061ab64890Smrg
20071ab64890Smrg	-Wc,*)
200888de56ccSmrg	  func_stripname '-Wc,' '' "$arg"
200988de56ccSmrg	  args=$func_stripname_result
20101ab64890Smrg	  lastarg=
20111ab64890Smrg	  save_ifs="$IFS"; IFS=','
201288de56ccSmrg	  for arg in $args; do
20131ab64890Smrg	    IFS="$save_ifs"
2014e9fcaa8aSmrg	    func_append_quoted lastarg "$arg"
20151ab64890Smrg	  done
20161ab64890Smrg	  IFS="$save_ifs"
201788de56ccSmrg	  func_stripname ' ' '' "$lastarg"
201888de56ccSmrg	  lastarg=$func_stripname_result
20191ab64890Smrg
20201ab64890Smrg	  # Add the arguments to base_compile.
2021e9fcaa8aSmrg	  func_append base_compile " $lastarg"
20221ab64890Smrg	  continue
20231ab64890Smrg	  ;;
20241ab64890Smrg
202588de56ccSmrg	*)
20261ab64890Smrg	  # Accept the current argument as the source file.
20271ab64890Smrg	  # The previous "srcfile" becomes the current argument.
20281ab64890Smrg	  #
20291ab64890Smrg	  lastarg="$srcfile"
20301ab64890Smrg	  srcfile="$arg"
20311ab64890Smrg	  ;;
20321ab64890Smrg	esac  #  case $arg
20331ab64890Smrg	;;
20341ab64890Smrg      esac    #  case $arg_mode
20351ab64890Smrg
20361ab64890Smrg      # Aesthetically quote the previous argument.
2037e9fcaa8aSmrg      func_append_quoted base_compile "$lastarg"
20381ab64890Smrg    done # for arg
20391ab64890Smrg
20401ab64890Smrg    case $arg_mode in
20411ab64890Smrg    arg)
204288de56ccSmrg      func_fatal_error "you must specify an argument for -Xcompile"
20431ab64890Smrg      ;;
20441ab64890Smrg    target)
204588de56ccSmrg      func_fatal_error "you must specify a target with \`-o'"
20461ab64890Smrg      ;;
20471ab64890Smrg    *)
20481ab64890Smrg      # Get the name of the library object.
204988de56ccSmrg      test -z "$libobj" && {
205088de56ccSmrg	func_basename "$srcfile"
205188de56ccSmrg	libobj="$func_basename_result"
205288de56ccSmrg      }
20531ab64890Smrg      ;;
20541ab64890Smrg    esac
20551ab64890Smrg
20561ab64890Smrg    # Recognize several different file suffixes.
20571ab64890Smrg    # If the user specifies -o file.o, it is replaced with file.lo
20581ab64890Smrg    case $libobj in
205988de56ccSmrg    *.[cCFSifmso] | \
206088de56ccSmrg    *.ada | *.adb | *.ads | *.asm | \
206188de56ccSmrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
2062e9fcaa8aSmrg    *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup)
206388de56ccSmrg      func_xform "$libobj"
206488de56ccSmrg      libobj=$func_xform_result
206588de56ccSmrg      ;;
20661ab64890Smrg    esac
20671ab64890Smrg
20681ab64890Smrg    case $libobj in
206988de56ccSmrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
20701ab64890Smrg    *)
207188de56ccSmrg      func_fatal_error "cannot determine name of library object from \`$libobj'"
20721ab64890Smrg      ;;
20731ab64890Smrg    esac
20741ab64890Smrg
20751ab64890Smrg    func_infer_tag $base_compile
20761ab64890Smrg
20771ab64890Smrg    for arg in $later; do
20781ab64890Smrg      case $arg in
207988de56ccSmrg      -shared)
208088de56ccSmrg	test "$build_libtool_libs" != yes && \
208188de56ccSmrg	  func_fatal_configuration "can not build a shared library"
208288de56ccSmrg	build_old_libs=no
208388de56ccSmrg	continue
208488de56ccSmrg	;;
208588de56ccSmrg
20861ab64890Smrg      -static)
208788de56ccSmrg	build_libtool_libs=no
20881ab64890Smrg	build_old_libs=yes
20891ab64890Smrg	continue
20901ab64890Smrg	;;
20911ab64890Smrg
20921ab64890Smrg      -prefer-pic)
20931ab64890Smrg	pic_mode=yes
20941ab64890Smrg	continue
20951ab64890Smrg	;;
20961ab64890Smrg
20971ab64890Smrg      -prefer-non-pic)
20981ab64890Smrg	pic_mode=no
20991ab64890Smrg	continue
21001ab64890Smrg	;;
21011ab64890Smrg      esac
21021ab64890Smrg    done
21031ab64890Smrg
210488de56ccSmrg    func_quote_for_eval "$libobj"
210588de56ccSmrg    test "X$libobj" != "X$func_quote_for_eval_result" \
210688de56ccSmrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
210788de56ccSmrg      && func_warning "libobj name \`$libobj' may not contain shell special characters."
210888de56ccSmrg    func_dirname_and_basename "$obj" "/" ""
210988de56ccSmrg    objname="$func_basename_result"
211088de56ccSmrg    xdir="$func_dirname_result"
21111ab64890Smrg    lobj=${xdir}$objdir/$objname
21121ab64890Smrg
211388de56ccSmrg    test -z "$base_compile" && \
211488de56ccSmrg      func_fatal_help "you must specify a compilation command"
21151ab64890Smrg
21161ab64890Smrg    # Delete any leftover library objects.
21171ab64890Smrg    if test "$build_old_libs" = yes; then
21181ab64890Smrg      removelist="$obj $lobj $libobj ${libobj}T"
21191ab64890Smrg    else
21201ab64890Smrg      removelist="$lobj $libobj ${libobj}T"
21211ab64890Smrg    fi
21221ab64890Smrg
21231ab64890Smrg    # On Cygwin there's no "real" PIC flag so we must build both object types
21241ab64890Smrg    case $host_os in
212588de56ccSmrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
21261ab64890Smrg      pic_mode=default
21271ab64890Smrg      ;;
21281ab64890Smrg    esac
21291ab64890Smrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
21301ab64890Smrg      # non-PIC code in shared libraries is not supported
21311ab64890Smrg      pic_mode=default
21321ab64890Smrg    fi
21331ab64890Smrg
21341ab64890Smrg    # Calculate the filename of the output object if compiler does
21351ab64890Smrg    # not support -o with -c
21361ab64890Smrg    if test "$compiler_c_o" = no; then
2137e9fcaa8aSmrg      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
21381ab64890Smrg      lockfile="$output_obj.lock"
21391ab64890Smrg    else
21401ab64890Smrg      output_obj=
21411ab64890Smrg      need_locks=no
21421ab64890Smrg      lockfile=
21431ab64890Smrg    fi
21441ab64890Smrg
21451ab64890Smrg    # Lock this critical section if it is needed
21461ab64890Smrg    # We use this script file to make the link, it avoids creating a new file
21471ab64890Smrg    if test "$need_locks" = yes; then
214888de56ccSmrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
214988de56ccSmrg	func_echo "Waiting for $lockfile to be removed"
21501ab64890Smrg	sleep 2
21511ab64890Smrg      done
21521ab64890Smrg    elif test "$need_locks" = warn; then
21531ab64890Smrg      if test -f "$lockfile"; then
215488de56ccSmrg	$ECHO "\
21551ab64890Smrg*** ERROR, $lockfile exists and contains:
21561ab64890Smrg`cat $lockfile 2>/dev/null`
21571ab64890Smrg
21581ab64890SmrgThis indicates that another process is trying to use the same
21591ab64890Smrgtemporary object file, and libtool could not work around it because
21601ab64890Smrgyour compiler does not support \`-c' and \`-o' together.  If you
21611ab64890Smrgrepeat this compilation, it may succeed, by chance, but you had better
21621ab64890Smrgavoid parallel builds (make -j) in this platform, or get a better
21631ab64890Smrgcompiler."
21641ab64890Smrg
216588de56ccSmrg	$opt_dry_run || $RM $removelist
21661ab64890Smrg	exit $EXIT_FAILURE
21671ab64890Smrg      fi
2168e9fcaa8aSmrg      func_append removelist " $output_obj"
216988de56ccSmrg      $ECHO "$srcfile" > "$lockfile"
21701ab64890Smrg    fi
21711ab64890Smrg
217288de56ccSmrg    $opt_dry_run || $RM $removelist
2173e9fcaa8aSmrg    func_append removelist " $lockfile"
217488de56ccSmrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
217588de56ccSmrg
2176e9fcaa8aSmrg    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
2177e9fcaa8aSmrg    srcfile=$func_to_tool_file_result
217888de56ccSmrg    func_quote_for_eval "$srcfile"
217988de56ccSmrg    qsrcfile=$func_quote_for_eval_result
21801ab64890Smrg
21811ab64890Smrg    # Only build a PIC object if we are building libtool libraries.
21821ab64890Smrg    if test "$build_libtool_libs" = yes; then
21831ab64890Smrg      # Without this assignment, base_compile gets emptied.
21841ab64890Smrg      fbsd_hideous_sh_bug=$base_compile
21851ab64890Smrg
21861ab64890Smrg      if test "$pic_mode" != no; then
21871ab64890Smrg	command="$base_compile $qsrcfile $pic_flag"
21881ab64890Smrg      else
21891ab64890Smrg	# Don't build PIC code
21901ab64890Smrg	command="$base_compile $qsrcfile"
21911ab64890Smrg      fi
21921ab64890Smrg
219388de56ccSmrg      func_mkdir_p "$xdir$objdir"
21941ab64890Smrg
21951ab64890Smrg      if test -z "$output_obj"; then
21961ab64890Smrg	# Place PIC objects in $objdir
2197e9fcaa8aSmrg	func_append command " -o $lobj"
21981ab64890Smrg      fi
21991ab64890Smrg
220088de56ccSmrg      func_show_eval_locale "$command"	\
220188de56ccSmrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
22021ab64890Smrg
22031ab64890Smrg      if test "$need_locks" = warn &&
22041ab64890Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
220588de56ccSmrg	$ECHO "\
22061ab64890Smrg*** ERROR, $lockfile contains:
22071ab64890Smrg`cat $lockfile 2>/dev/null`
22081ab64890Smrg
22091ab64890Smrgbut it should contain:
22101ab64890Smrg$srcfile
22111ab64890Smrg
22121ab64890SmrgThis indicates that another process is trying to use the same
22131ab64890Smrgtemporary object file, and libtool could not work around it because
22141ab64890Smrgyour compiler does not support \`-c' and \`-o' together.  If you
22151ab64890Smrgrepeat this compilation, it may succeed, by chance, but you had better
22161ab64890Smrgavoid parallel builds (make -j) in this platform, or get a better
22171ab64890Smrgcompiler."
22181ab64890Smrg
221988de56ccSmrg	$opt_dry_run || $RM $removelist
22201ab64890Smrg	exit $EXIT_FAILURE
22211ab64890Smrg      fi
22221ab64890Smrg
22231ab64890Smrg      # Just move the object if needed, then go on to compile the next one
22241ab64890Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
222588de56ccSmrg	func_show_eval '$MV "$output_obj" "$lobj"' \
222688de56ccSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
22271ab64890Smrg      fi
22281ab64890Smrg
22291ab64890Smrg      # Allow error messages only from the first compilation.
22301ab64890Smrg      if test "$suppress_opt" = yes; then
223188de56ccSmrg	suppress_output=' >/dev/null 2>&1'
22321ab64890Smrg      fi
22331ab64890Smrg    fi
22341ab64890Smrg
22351ab64890Smrg    # Only build a position-dependent object if we build old libraries.
22361ab64890Smrg    if test "$build_old_libs" = yes; then
22371ab64890Smrg      if test "$pic_mode" != yes; then
22381ab64890Smrg	# Don't build PIC code
223988de56ccSmrg	command="$base_compile $qsrcfile$pie_flag"
22401ab64890Smrg      else
22411ab64890Smrg	command="$base_compile $qsrcfile $pic_flag"
22421ab64890Smrg      fi
22431ab64890Smrg      if test "$compiler_c_o" = yes; then
2244e9fcaa8aSmrg	func_append command " -o $obj"
22451ab64890Smrg      fi
22461ab64890Smrg
22471ab64890Smrg      # Suppress compiler output if we already did a PIC compilation.
2248e9fcaa8aSmrg      func_append command "$suppress_output"
224988de56ccSmrg      func_show_eval_locale "$command" \
225088de56ccSmrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
22511ab64890Smrg
22521ab64890Smrg      if test "$need_locks" = warn &&
22531ab64890Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
225488de56ccSmrg	$ECHO "\
22551ab64890Smrg*** ERROR, $lockfile contains:
22561ab64890Smrg`cat $lockfile 2>/dev/null`
22571ab64890Smrg
22581ab64890Smrgbut it should contain:
22591ab64890Smrg$srcfile
22601ab64890Smrg
22611ab64890SmrgThis indicates that another process is trying to use the same
22621ab64890Smrgtemporary object file, and libtool could not work around it because
22631ab64890Smrgyour compiler does not support \`-c' and \`-o' together.  If you
22641ab64890Smrgrepeat this compilation, it may succeed, by chance, but you had better
22651ab64890Smrgavoid parallel builds (make -j) in this platform, or get a better
22661ab64890Smrgcompiler."
22671ab64890Smrg
226888de56ccSmrg	$opt_dry_run || $RM $removelist
22691ab64890Smrg	exit $EXIT_FAILURE
22701ab64890Smrg      fi
22711ab64890Smrg
22721ab64890Smrg      # Just move the object if needed
22731ab64890Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
227488de56ccSmrg	func_show_eval '$MV "$output_obj" "$obj"' \
227588de56ccSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
22761ab64890Smrg      fi
22771ab64890Smrg    fi
22781ab64890Smrg
227988de56ccSmrg    $opt_dry_run || {
228088de56ccSmrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
22811ab64890Smrg
228288de56ccSmrg      # Unlock the critical section if it was locked
228388de56ccSmrg      if test "$need_locks" != no; then
228488de56ccSmrg	removelist=$lockfile
228588de56ccSmrg        $RM "$lockfile"
228688de56ccSmrg      fi
228788de56ccSmrg    }
22881ab64890Smrg
22891ab64890Smrg    exit $EXIT_SUCCESS
229088de56ccSmrg}
22911ab64890Smrg
229288de56ccSmrg$opt_help || {
2293e9fcaa8aSmrg  test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
229488de56ccSmrg}
22951ab64890Smrg
229688de56ccSmrgfunc_mode_help ()
229788de56ccSmrg{
229888de56ccSmrg    # We need to display help for each of the modes.
2299e9fcaa8aSmrg    case $opt_mode in
230088de56ccSmrg      "")
230188de56ccSmrg        # Generic help is extracted from the usage comments
230288de56ccSmrg        # at the start of this file.
230388de56ccSmrg        func_help
230488de56ccSmrg        ;;
23051ab64890Smrg
230688de56ccSmrg      clean)
230788de56ccSmrg        $ECHO \
230888de56ccSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
23091ab64890Smrg
231088de56ccSmrgRemove files from the build directory.
23111ab64890Smrg
231288de56ccSmrgRM is the name of the program to use to delete files associated with each FILE
231388de56ccSmrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
231488de56ccSmrgto RM.
23151ab64890Smrg
231688de56ccSmrgIf FILE is a libtool library, object or program, all the files associated
231788de56ccSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
231888de56ccSmrg        ;;
23191ab64890Smrg
232088de56ccSmrg      compile)
232188de56ccSmrg      $ECHO \
232288de56ccSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
23231ab64890Smrg
232488de56ccSmrgCompile a source file into a libtool library object.
23251ab64890Smrg
232688de56ccSmrgThis mode accepts the following additional options:
23271ab64890Smrg
232888de56ccSmrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
232988de56ccSmrg  -no-suppress      do not suppress compiler output for multiple passes
2330e9fcaa8aSmrg  -prefer-pic       try to build PIC objects only
2331e9fcaa8aSmrg  -prefer-non-pic   try to build non-PIC objects only
233288de56ccSmrg  -shared           do not build a \`.o' file suitable for static linking
233388de56ccSmrg  -static           only build a \`.o' file suitable for static linking
2334e9fcaa8aSmrg  -Wc,FLAG          pass FLAG directly to the compiler
23351ab64890Smrg
233688de56ccSmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
233788de56ccSmrgfrom the given SOURCEFILE.
23381ab64890Smrg
233988de56ccSmrgThe output file name is determined by removing the directory component from
234088de56ccSmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
234188de56ccSmrglibrary object suffix, \`.lo'."
234288de56ccSmrg        ;;
23431ab64890Smrg
234488de56ccSmrg      execute)
234588de56ccSmrg        $ECHO \
234688de56ccSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
23471ab64890Smrg
234888de56ccSmrgAutomatically set library path, then run a program.
23491ab64890Smrg
235088de56ccSmrgThis mode accepts the following additional options:
23511ab64890Smrg
235288de56ccSmrg  -dlopen FILE      add the directory containing FILE to the library path
23531ab64890Smrg
235488de56ccSmrgThis mode sets the library path environment variable according to \`-dlopen'
235588de56ccSmrgflags.
23561ab64890Smrg
235788de56ccSmrgIf any of the ARGS are libtool executable wrappers, then they are translated
235888de56ccSmrginto their corresponding uninstalled binary, and any of their required library
235988de56ccSmrgdirectories are added to the library path.
23601ab64890Smrg
236188de56ccSmrgThen, COMMAND is executed, with ARGS as arguments."
236288de56ccSmrg        ;;
23631ab64890Smrg
236488de56ccSmrg      finish)
236588de56ccSmrg        $ECHO \
236688de56ccSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
23671ab64890Smrg
236888de56ccSmrgComplete the installation of libtool libraries.
23691ab64890Smrg
237088de56ccSmrgEach LIBDIR is a directory that contains libtool libraries.
23711ab64890Smrg
237288de56ccSmrgThe commands that this mode executes may require superuser privileges.  Use
237388de56ccSmrgthe \`--dry-run' option if you just want to see what would be executed."
237488de56ccSmrg        ;;
23751ab64890Smrg
237688de56ccSmrg      install)
237788de56ccSmrg        $ECHO \
237888de56ccSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
23791ab64890Smrg
238088de56ccSmrgInstall executables or libraries.
23811ab64890Smrg
238288de56ccSmrgINSTALL-COMMAND is the installation command.  The first component should be
238388de56ccSmrgeither the \`install' or \`cp' program.
23841ab64890Smrg
238588de56ccSmrgThe following components of INSTALL-COMMAND are treated specially:
23861ab64890Smrg
2387e9fcaa8aSmrg  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
23881ab64890Smrg
238988de56ccSmrgThe rest of the components are interpreted as arguments to that command (only
239088de56ccSmrgBSD-compatible install options are recognized)."
239188de56ccSmrg        ;;
23921ab64890Smrg
239388de56ccSmrg      link)
239488de56ccSmrg        $ECHO \
239588de56ccSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
23961ab64890Smrg
239788de56ccSmrgLink object files or libraries together to form another library, or to
239888de56ccSmrgcreate an executable program.
23991ab64890Smrg
240088de56ccSmrgLINK-COMMAND is a command using the C compiler that you would use to create
240188de56ccSmrga program from several object files.
24021ab64890Smrg
240388de56ccSmrgThe following components of LINK-COMMAND are treated specially:
24041ab64890Smrg
240588de56ccSmrg  -all-static       do not do any dynamic linking at all
240688de56ccSmrg  -avoid-version    do not add a version suffix if possible
2407e9fcaa8aSmrg  -bindir BINDIR    specify path to binaries directory (for systems where
2408e9fcaa8aSmrg                    libraries must be found in the PATH setting at runtime)
240988de56ccSmrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
241088de56ccSmrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
241188de56ccSmrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
241288de56ccSmrg  -export-symbols SYMFILE
241388de56ccSmrg                    try to export only the symbols listed in SYMFILE
241488de56ccSmrg  -export-symbols-regex REGEX
241588de56ccSmrg                    try to export only the symbols matching REGEX
241688de56ccSmrg  -LLIBDIR          search LIBDIR for required installed libraries
241788de56ccSmrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
241888de56ccSmrg  -module           build a library that can dlopened
241988de56ccSmrg  -no-fast-install  disable the fast-install mode
242088de56ccSmrg  -no-install       link a not-installable executable
242188de56ccSmrg  -no-undefined     declare that a library does not refer to external symbols
242288de56ccSmrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
242388de56ccSmrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
242488de56ccSmrg  -precious-files-regex REGEX
242588de56ccSmrg                    don't remove output files matching REGEX
242688de56ccSmrg  -release RELEASE  specify package release information
242788de56ccSmrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
242888de56ccSmrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
242988de56ccSmrg  -shared           only do dynamic linking of libtool libraries
243088de56ccSmrg  -shrext SUFFIX    override the standard shared library file extension
243188de56ccSmrg  -static           do not do any dynamic linking of uninstalled libtool libraries
243288de56ccSmrg  -static-libtool-libs
243388de56ccSmrg                    do not do any dynamic linking of libtool libraries
243488de56ccSmrg  -version-info CURRENT[:REVISION[:AGE]]
243588de56ccSmrg                    specify library version info [each variable defaults to 0]
243688de56ccSmrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
2437e9fcaa8aSmrg  -Wc,FLAG
2438e9fcaa8aSmrg  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
2439e9fcaa8aSmrg  -Wl,FLAG
2440e9fcaa8aSmrg  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
2441e9fcaa8aSmrg  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
24421ab64890Smrg
244388de56ccSmrgAll other options (arguments beginning with \`-') are ignored.
24441ab64890Smrg
244588de56ccSmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
244688de56ccSmrgtreated as uninstalled libtool libraries, other files are standard or library
244788de56ccSmrgobject files.
24481ab64890Smrg
244988de56ccSmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
245088de56ccSmrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
245188de56ccSmrgrequired, except when creating a convenience library.
24521ab64890Smrg
245388de56ccSmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
245488de56ccSmrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
24551ab64890Smrg
245688de56ccSmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
245788de56ccSmrgis created, otherwise an executable program is created."
2458b4ee4795Smrg        ;;
24591ab64890Smrg
246088de56ccSmrg      uninstall)
246188de56ccSmrg        $ECHO \
246288de56ccSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
24631ab64890Smrg
246488de56ccSmrgRemove libraries from an installation directory.
24651ab64890Smrg
246688de56ccSmrgRM is the name of the program to use to delete files associated with each FILE
246788de56ccSmrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
246888de56ccSmrgto RM.
24692e9c7c8cSmrg
247088de56ccSmrgIf FILE is a libtool library, all the files associated with it are deleted.
247188de56ccSmrgOtherwise, only FILE itself is deleted using RM."
247288de56ccSmrg        ;;
24732e9c7c8cSmrg
247488de56ccSmrg      *)
2475e9fcaa8aSmrg        func_fatal_help "invalid operation mode \`$opt_mode'"
247688de56ccSmrg        ;;
247788de56ccSmrg    esac
24782e9c7c8cSmrg
2479e9fcaa8aSmrg    echo
248088de56ccSmrg    $ECHO "Try \`$progname --help' for more information about other modes."
248188de56ccSmrg}
24822e9c7c8cSmrg
2483e9fcaa8aSmrg# Now that we've collected a possible --mode arg, show help if necessary
2484e9fcaa8aSmrgif $opt_help; then
2485e9fcaa8aSmrg  if test "$opt_help" = :; then
2486e9fcaa8aSmrg    func_mode_help
2487e9fcaa8aSmrg  else
2488e9fcaa8aSmrg    {
2489e9fcaa8aSmrg      func_help noexit
2490e9fcaa8aSmrg      for opt_mode in compile link execute install finish uninstall clean; do
2491e9fcaa8aSmrg	func_mode_help
2492e9fcaa8aSmrg      done
2493e9fcaa8aSmrg    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
2494e9fcaa8aSmrg    {
2495e9fcaa8aSmrg      func_help noexit
2496e9fcaa8aSmrg      for opt_mode in compile link execute install finish uninstall clean; do
2497e9fcaa8aSmrg	echo
2498e9fcaa8aSmrg	func_mode_help
2499e9fcaa8aSmrg      done
2500e9fcaa8aSmrg    } |
2501e9fcaa8aSmrg    sed '1d
2502e9fcaa8aSmrg      /^When reporting/,/^Report/{
2503e9fcaa8aSmrg	H
2504e9fcaa8aSmrg	d
2505e9fcaa8aSmrg      }
2506e9fcaa8aSmrg      $x
2507e9fcaa8aSmrg      /information about other modes/d
2508e9fcaa8aSmrg      /more detailed .*MODE/d
2509e9fcaa8aSmrg      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
2510e9fcaa8aSmrg  fi
2511e9fcaa8aSmrg  exit $?
2512e9fcaa8aSmrgfi
25132e9c7c8cSmrg
25142e9c7c8cSmrg
251588de56ccSmrg# func_mode_execute arg...
251688de56ccSmrgfunc_mode_execute ()
251788de56ccSmrg{
251888de56ccSmrg    $opt_debug
251988de56ccSmrg    # The first argument is the command name.
252088de56ccSmrg    cmd="$nonopt"
252188de56ccSmrg    test -z "$cmd" && \
252288de56ccSmrg      func_fatal_help "you must specify a COMMAND"
2523b4ee4795Smrg
252488de56ccSmrg    # Handle -dlopen flags immediately.
2525e9fcaa8aSmrg    for file in $opt_dlopen; do
252688de56ccSmrg      test -f "$file" \
252788de56ccSmrg	|| func_fatal_help "\`$file' is not a file"
2528b4ee4795Smrg
252988de56ccSmrg      dir=
253088de56ccSmrg      case $file in
253188de56ccSmrg      *.la)
2532e9fcaa8aSmrg	func_resolve_sysroot "$file"
2533e9fcaa8aSmrg	file=$func_resolve_sysroot_result
2534e9fcaa8aSmrg
253588de56ccSmrg	# Check to see that this really is a libtool archive.
253688de56ccSmrg	func_lalib_unsafe_p "$file" \
253788de56ccSmrg	  || func_fatal_help "\`$lib' is not a valid libtool archive"
2538b4ee4795Smrg
253988de56ccSmrg	# Read the libtool library.
254088de56ccSmrg	dlname=
254188de56ccSmrg	library_names=
254288de56ccSmrg	func_source "$file"
25431ab64890Smrg
254488de56ccSmrg	# Skip this library if it cannot be dlopened.
254588de56ccSmrg	if test -z "$dlname"; then
254688de56ccSmrg	  # Warn if it was a shared library.
254788de56ccSmrg	  test -n "$library_names" && \
254888de56ccSmrg	    func_warning "\`$file' was not linked with \`-export-dynamic'"
254988de56ccSmrg	  continue
255088de56ccSmrg	fi
25511ab64890Smrg
255288de56ccSmrg	func_dirname "$file" "" "."
255388de56ccSmrg	dir="$func_dirname_result"
25541ab64890Smrg
255588de56ccSmrg	if test -f "$dir/$objdir/$dlname"; then
2556e9fcaa8aSmrg	  func_append dir "/$objdir"
255788de56ccSmrg	else
255888de56ccSmrg	  if test ! -f "$dir/$dlname"; then
255988de56ccSmrg	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
256088de56ccSmrg	  fi
256188de56ccSmrg	fi
2562b4ee4795Smrg	;;
25631ab64890Smrg
256488de56ccSmrg      *.lo)
256588de56ccSmrg	# Just add the directory containing the .lo file.
256688de56ccSmrg	func_dirname "$file" "" "."
256788de56ccSmrg	dir="$func_dirname_result"
2568b4ee4795Smrg	;;
25691ab64890Smrg
257088de56ccSmrg      *)
257188de56ccSmrg	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
2572b4ee4795Smrg	continue
2573b4ee4795Smrg	;;
257488de56ccSmrg      esac
25751ab64890Smrg
257688de56ccSmrg      # Get the absolute pathname.
257788de56ccSmrg      absdir=`cd "$dir" && pwd`
257888de56ccSmrg      test -n "$absdir" && dir="$absdir"
25792e9c7c8cSmrg
258088de56ccSmrg      # Now add the directory to shlibpath_var.
258188de56ccSmrg      if eval "test -z \"\$$shlibpath_var\""; then
258288de56ccSmrg	eval "$shlibpath_var=\"\$dir\""
258388de56ccSmrg      else
258488de56ccSmrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
258588de56ccSmrg      fi
258688de56ccSmrg    done
25872e9c7c8cSmrg
258888de56ccSmrg    # This variable tells wrapper scripts just to set shlibpath_var
258988de56ccSmrg    # rather than running their programs.
259088de56ccSmrg    libtool_execute_magic="$magic"
25912e9c7c8cSmrg
259288de56ccSmrg    # Check if any of the arguments is a wrapper script.
259388de56ccSmrg    args=
259488de56ccSmrg    for file
259588de56ccSmrg    do
259688de56ccSmrg      case $file in
2597e9fcaa8aSmrg      -* | *.la | *.lo ) ;;
259888de56ccSmrg      *)
259988de56ccSmrg	# Do a test to see if this is really a libtool program.
260088de56ccSmrg	if func_ltwrapper_script_p "$file"; then
260188de56ccSmrg	  func_source "$file"
260288de56ccSmrg	  # Transform arg to wrapped name.
260388de56ccSmrg	  file="$progdir/$program"
260488de56ccSmrg	elif func_ltwrapper_executable_p "$file"; then
260588de56ccSmrg	  func_ltwrapper_scriptname "$file"
260688de56ccSmrg	  func_source "$func_ltwrapper_scriptname_result"
260788de56ccSmrg	  # Transform arg to wrapped name.
260888de56ccSmrg	  file="$progdir/$program"
260988de56ccSmrg	fi
261088de56ccSmrg	;;
261188de56ccSmrg      esac
261288de56ccSmrg      # Quote arguments (to preserve shell metacharacters).
2613e9fcaa8aSmrg      func_append_quoted args "$file"
261488de56ccSmrg    done
26152e9c7c8cSmrg
261688de56ccSmrg    if test "X$opt_dry_run" = Xfalse; then
261788de56ccSmrg      if test -n "$shlibpath_var"; then
261888de56ccSmrg	# Export the shlibpath_var.
261988de56ccSmrg	eval "export $shlibpath_var"
262088de56ccSmrg      fi
26212e9c7c8cSmrg
262288de56ccSmrg      # Restore saved environment variables
262388de56ccSmrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
262488de56ccSmrg      do
262588de56ccSmrg	eval "if test \"\${save_$lt_var+set}\" = set; then
262688de56ccSmrg                $lt_var=\$save_$lt_var; export $lt_var
2627b4ee4795Smrg	      else
262888de56ccSmrg		$lt_unset $lt_var
262988de56ccSmrg	      fi"
263088de56ccSmrg      done
26312e9c7c8cSmrg
263288de56ccSmrg      # Now prepare to actually exec the command.
263388de56ccSmrg      exec_cmd="\$cmd$args"
263488de56ccSmrg    else
263588de56ccSmrg      # Display what would be done.
263688de56ccSmrg      if test -n "$shlibpath_var"; then
263788de56ccSmrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
2638e9fcaa8aSmrg	echo "export $shlibpath_var"
263988de56ccSmrg      fi
264088de56ccSmrg      $ECHO "$cmd$args"
264188de56ccSmrg      exit $EXIT_SUCCESS
264288de56ccSmrg    fi
264388de56ccSmrg}
26442e9c7c8cSmrg
2645e9fcaa8aSmrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"}
26462e9c7c8cSmrg
2647b4ee4795Smrg
264888de56ccSmrg# func_mode_finish arg...
264988de56ccSmrgfunc_mode_finish ()
265088de56ccSmrg{
265188de56ccSmrg    $opt_debug
2652e9fcaa8aSmrg    libs=
2653e9fcaa8aSmrg    libdirs=
265488de56ccSmrg    admincmds=
26551ab64890Smrg
2656e9fcaa8aSmrg    for opt in "$nonopt" ${1+"$@"}
2657e9fcaa8aSmrg    do
2658e9fcaa8aSmrg      if test -d "$opt"; then
2659e9fcaa8aSmrg	func_append libdirs " $opt"
2660e9fcaa8aSmrg
2661e9fcaa8aSmrg      elif test -f "$opt"; then
2662e9fcaa8aSmrg	if func_lalib_unsafe_p "$opt"; then
2663e9fcaa8aSmrg	  func_append libs " $opt"
2664e9fcaa8aSmrg	else
2665e9fcaa8aSmrg	  func_warning "\`$opt' is not a valid libtool archive"
2666e9fcaa8aSmrg	fi
2667e9fcaa8aSmrg
2668e9fcaa8aSmrg      else
2669e9fcaa8aSmrg	func_fatal_error "invalid argument \`$opt'"
2670e9fcaa8aSmrg      fi
2671e9fcaa8aSmrg    done
2672e9fcaa8aSmrg
2673e9fcaa8aSmrg    if test -n "$libs"; then
2674e9fcaa8aSmrg      if test -n "$lt_sysroot"; then
2675e9fcaa8aSmrg        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
2676e9fcaa8aSmrg        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
2677e9fcaa8aSmrg      else
2678e9fcaa8aSmrg        sysroot_cmd=
2679e9fcaa8aSmrg      fi
26801ab64890Smrg
2681e9fcaa8aSmrg      # Remove sysroot references
2682e9fcaa8aSmrg      if $opt_dry_run; then
2683e9fcaa8aSmrg        for lib in $libs; do
2684e9fcaa8aSmrg          echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
2685e9fcaa8aSmrg        done
2686e9fcaa8aSmrg      else
2687e9fcaa8aSmrg        tmpdir=`func_mktempdir`
2688e9fcaa8aSmrg        for lib in $libs; do
2689e9fcaa8aSmrg	  sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
2690e9fcaa8aSmrg	    > $tmpdir/tmp-la
2691e9fcaa8aSmrg	  mv -f $tmpdir/tmp-la $lib
2692e9fcaa8aSmrg	done
2693e9fcaa8aSmrg        ${RM}r "$tmpdir"
2694e9fcaa8aSmrg      fi
2695e9fcaa8aSmrg    fi
2696e9fcaa8aSmrg
2697e9fcaa8aSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
269888de56ccSmrg      for libdir in $libdirs; do
269988de56ccSmrg	if test -n "$finish_cmds"; then
270088de56ccSmrg	  # Do each command in the finish commands.
270188de56ccSmrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
270288de56ccSmrg'"$cmd"'"'
2703b4ee4795Smrg	fi
270488de56ccSmrg	if test -n "$finish_eval"; then
270588de56ccSmrg	  # Do the single finish_eval.
270688de56ccSmrg	  eval cmds=\"$finish_eval\"
2707e9fcaa8aSmrg	  $opt_dry_run || eval "$cmds" || func_append admincmds "
270888de56ccSmrg       $cmds"
270988de56ccSmrg	fi
271088de56ccSmrg      done
271188de56ccSmrg    fi
27121ab64890Smrg
271388de56ccSmrg    # Exit here if they wanted silent mode.
271488de56ccSmrg    $opt_silent && exit $EXIT_SUCCESS
27151ab64890Smrg
2716e9fcaa8aSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2717e9fcaa8aSmrg      echo "----------------------------------------------------------------------"
2718e9fcaa8aSmrg      echo "Libraries have been installed in:"
2719e9fcaa8aSmrg      for libdir in $libdirs; do
2720e9fcaa8aSmrg	$ECHO "   $libdir"
2721e9fcaa8aSmrg      done
2722e9fcaa8aSmrg      echo
2723e9fcaa8aSmrg      echo "If you ever happen to want to link against installed libraries"
2724e9fcaa8aSmrg      echo "in a given directory, LIBDIR, you must either use libtool, and"
2725e9fcaa8aSmrg      echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
2726e9fcaa8aSmrg      echo "flag during linking and do at least one of the following:"
2727e9fcaa8aSmrg      if test -n "$shlibpath_var"; then
2728e9fcaa8aSmrg	echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
2729e9fcaa8aSmrg	echo "     during execution"
2730e9fcaa8aSmrg      fi
2731e9fcaa8aSmrg      if test -n "$runpath_var"; then
2732e9fcaa8aSmrg	echo "   - add LIBDIR to the \`$runpath_var' environment variable"
2733e9fcaa8aSmrg	echo "     during linking"
2734e9fcaa8aSmrg      fi
2735e9fcaa8aSmrg      if test -n "$hardcode_libdir_flag_spec"; then
2736e9fcaa8aSmrg	libdir=LIBDIR
2737e9fcaa8aSmrg	eval flag=\"$hardcode_libdir_flag_spec\"
273888de56ccSmrg
2739e9fcaa8aSmrg	$ECHO "   - use the \`$flag' linker flag"
2740e9fcaa8aSmrg      fi
2741e9fcaa8aSmrg      if test -n "$admincmds"; then
2742e9fcaa8aSmrg	$ECHO "   - have your system administrator run these commands:$admincmds"
2743e9fcaa8aSmrg      fi
2744e9fcaa8aSmrg      if test -f /etc/ld.so.conf; then
2745e9fcaa8aSmrg	echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
2746e9fcaa8aSmrg      fi
2747e9fcaa8aSmrg      echo
274888de56ccSmrg
2749e9fcaa8aSmrg      echo "See any operating system documentation about shared libraries for"
2750e9fcaa8aSmrg      case $host in
2751e9fcaa8aSmrg	solaris2.[6789]|solaris2.1[0-9])
2752e9fcaa8aSmrg	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
2753e9fcaa8aSmrg	  echo "pages."
2754e9fcaa8aSmrg	  ;;
2755e9fcaa8aSmrg	*)
2756e9fcaa8aSmrg	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
2757e9fcaa8aSmrg	  ;;
2758e9fcaa8aSmrg      esac
2759e9fcaa8aSmrg      echo "----------------------------------------------------------------------"
2760e9fcaa8aSmrg    fi
276188de56ccSmrg    exit $EXIT_SUCCESS
276288de56ccSmrg}
276388de56ccSmrg
2764e9fcaa8aSmrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"}
276588de56ccSmrg
276688de56ccSmrg
276788de56ccSmrg# func_mode_install arg...
276888de56ccSmrgfunc_mode_install ()
276988de56ccSmrg{
277088de56ccSmrg    $opt_debug
277188de56ccSmrg    # There may be an optional sh(1) argument at the beginning of
277288de56ccSmrg    # install_prog (especially on Windows NT).
277388de56ccSmrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
277488de56ccSmrg       # Allow the use of GNU shtool's install command.
2775e9fcaa8aSmrg       case $nonopt in *shtool*) :;; *) false;; esac; then
277688de56ccSmrg      # Aesthetically quote it.
277788de56ccSmrg      func_quote_for_eval "$nonopt"
277888de56ccSmrg      install_prog="$func_quote_for_eval_result "
277988de56ccSmrg      arg=$1
278088de56ccSmrg      shift
278188de56ccSmrg    else
278288de56ccSmrg      install_prog=
278388de56ccSmrg      arg=$nonopt
278488de56ccSmrg    fi
278588de56ccSmrg
278688de56ccSmrg    # The real first argument should be the name of the installation program.
278788de56ccSmrg    # Aesthetically quote it.
278888de56ccSmrg    func_quote_for_eval "$arg"
2789e9fcaa8aSmrg    func_append install_prog "$func_quote_for_eval_result"
2790e9fcaa8aSmrg    install_shared_prog=$install_prog
2791e9fcaa8aSmrg    case " $install_prog " in
2792e9fcaa8aSmrg      *[\\\ /]cp\ *) install_cp=: ;;
2793e9fcaa8aSmrg      *) install_cp=false ;;
2794e9fcaa8aSmrg    esac
279588de56ccSmrg
279688de56ccSmrg    # We need to accept at least all the BSD install flags.
279788de56ccSmrg    dest=
279888de56ccSmrg    files=
279988de56ccSmrg    opts=
280088de56ccSmrg    prev=
280188de56ccSmrg    install_type=
280288de56ccSmrg    isdir=no
280388de56ccSmrg    stripme=
2804e9fcaa8aSmrg    no_mode=:
280588de56ccSmrg    for arg
280688de56ccSmrg    do
2807e9fcaa8aSmrg      arg2=
280888de56ccSmrg      if test -n "$dest"; then
2809e9fcaa8aSmrg	func_append files " $dest"
281088de56ccSmrg	dest=$arg
281188de56ccSmrg	continue
281288de56ccSmrg      fi
281388de56ccSmrg
281488de56ccSmrg      case $arg in
281588de56ccSmrg      -d) isdir=yes ;;
281688de56ccSmrg      -f)
2817e9fcaa8aSmrg	if $install_cp; then :; else
2818e9fcaa8aSmrg	  prev=$arg
2819e9fcaa8aSmrg	fi
282088de56ccSmrg	;;
282188de56ccSmrg      -g | -m | -o)
282288de56ccSmrg	prev=$arg
282388de56ccSmrg	;;
282488de56ccSmrg      -s)
282588de56ccSmrg	stripme=" -s"
282688de56ccSmrg	continue
282788de56ccSmrg	;;
282888de56ccSmrg      -*)
282988de56ccSmrg	;;
283088de56ccSmrg      *)
283188de56ccSmrg	# If the previous option needed an argument, then skip it.
283288de56ccSmrg	if test -n "$prev"; then
2833e9fcaa8aSmrg	  if test "x$prev" = x-m && test -n "$install_override_mode"; then
2834e9fcaa8aSmrg	    arg2=$install_override_mode
2835e9fcaa8aSmrg	    no_mode=false
2836e9fcaa8aSmrg	  fi
2837b4ee4795Smrg	  prev=
28382e9c7c8cSmrg	else
283988de56ccSmrg	  dest=$arg
284088de56ccSmrg	  continue
28411ab64890Smrg	fi
2842b4ee4795Smrg	;;
284388de56ccSmrg      esac
28441ab64890Smrg
284588de56ccSmrg      # Aesthetically quote the argument.
284688de56ccSmrg      func_quote_for_eval "$arg"
2847e9fcaa8aSmrg      func_append install_prog " $func_quote_for_eval_result"
2848e9fcaa8aSmrg      if test -n "$arg2"; then
2849e9fcaa8aSmrg	func_quote_for_eval "$arg2"
2850e9fcaa8aSmrg      fi
2851e9fcaa8aSmrg      func_append install_shared_prog " $func_quote_for_eval_result"
285288de56ccSmrg    done
28531ab64890Smrg
285488de56ccSmrg    test -z "$install_prog" && \
285588de56ccSmrg      func_fatal_help "you must specify an install program"
28561ab64890Smrg
285788de56ccSmrg    test -n "$prev" && \
285888de56ccSmrg      func_fatal_help "the \`$prev' option requires an argument"
28592e9c7c8cSmrg
2860e9fcaa8aSmrg    if test -n "$install_override_mode" && $no_mode; then
2861e9fcaa8aSmrg      if $install_cp; then :; else
2862e9fcaa8aSmrg	func_quote_for_eval "$install_override_mode"
2863e9fcaa8aSmrg	func_append install_shared_prog " -m $func_quote_for_eval_result"
2864e9fcaa8aSmrg      fi
2865e9fcaa8aSmrg    fi
2866e9fcaa8aSmrg
286788de56ccSmrg    if test -z "$files"; then
286888de56ccSmrg      if test -z "$dest"; then
286988de56ccSmrg	func_fatal_help "no file or destination specified"
287088de56ccSmrg      else
287188de56ccSmrg	func_fatal_help "you must specify a destination"
287288de56ccSmrg      fi
2873b4ee4795Smrg    fi
28742e9c7c8cSmrg
287588de56ccSmrg    # Strip any trailing slash from the destination.
287688de56ccSmrg    func_stripname '' '/' "$dest"
287788de56ccSmrg    dest=$func_stripname_result
28782e9c7c8cSmrg
287988de56ccSmrg    # Check to see that the destination is a directory.
288088de56ccSmrg    test -d "$dest" && isdir=yes
288188de56ccSmrg    if test "$isdir" = yes; then
288288de56ccSmrg      destdir="$dest"
288388de56ccSmrg      destname=
2884b4ee4795Smrg    else
288588de56ccSmrg      func_dirname_and_basename "$dest" "" "."
288688de56ccSmrg      destdir="$func_dirname_result"
288788de56ccSmrg      destname="$func_basename_result"
28882e9c7c8cSmrg
288988de56ccSmrg      # Not a directory, so check to see that there is only one file specified.
289088de56ccSmrg      set dummy $files; shift
289188de56ccSmrg      test "$#" -gt 1 && \
289288de56ccSmrg	func_fatal_help "\`$dest' is not a directory"
28932e9c7c8cSmrg    fi
289488de56ccSmrg    case $destdir in
289588de56ccSmrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
2896b4ee4795Smrg    *)
289788de56ccSmrg      for file in $files; do
289888de56ccSmrg	case $file in
289988de56ccSmrg	*.lo) ;;
290088de56ccSmrg	*)
290188de56ccSmrg	  func_fatal_help "\`$destdir' must be an absolute directory name"
290288de56ccSmrg	  ;;
290388de56ccSmrg	esac
290488de56ccSmrg      done
2905b4ee4795Smrg      ;;
2906b4ee4795Smrg    esac
29071ab64890Smrg
290888de56ccSmrg    # This variable tells wrapper scripts just to set variables rather
290988de56ccSmrg    # than running their programs.
291088de56ccSmrg    libtool_install_magic="$magic"
29111ab64890Smrg
291288de56ccSmrg    staticlibs=
291388de56ccSmrg    future_libdirs=
291488de56ccSmrg    current_libdirs=
291588de56ccSmrg    for file in $files; do
29161ab64890Smrg
291788de56ccSmrg      # Do each installation.
291888de56ccSmrg      case $file in
291988de56ccSmrg      *.$libext)
292088de56ccSmrg	# Do the static libraries later.
2921e9fcaa8aSmrg	func_append staticlibs " $file"
292288de56ccSmrg	;;
292388de56ccSmrg
292488de56ccSmrg      *.la)
2925e9fcaa8aSmrg	func_resolve_sysroot "$file"
2926e9fcaa8aSmrg	file=$func_resolve_sysroot_result
2927e9fcaa8aSmrg
292888de56ccSmrg	# Check to see that this really is a libtool archive.
292988de56ccSmrg	func_lalib_unsafe_p "$file" \
293088de56ccSmrg	  || func_fatal_help "\`$file' is not a valid libtool archive"
293188de56ccSmrg
293288de56ccSmrg	library_names=
293388de56ccSmrg	old_library=
293488de56ccSmrg	relink_command=
293588de56ccSmrg	func_source "$file"
293688de56ccSmrg
293788de56ccSmrg	# Add the libdir to current_libdirs if it is the destination.
293888de56ccSmrg	if test "X$destdir" = "X$libdir"; then
293988de56ccSmrg	  case "$current_libdirs " in
294088de56ccSmrg	  *" $libdir "*) ;;
2941e9fcaa8aSmrg	  *) func_append current_libdirs " $libdir" ;;
29422e9c7c8cSmrg	  esac
294388de56ccSmrg	else
294488de56ccSmrg	  # Note the libdir as a future libdir.
294588de56ccSmrg	  case "$future_libdirs " in
294688de56ccSmrg	  *" $libdir "*) ;;
2947e9fcaa8aSmrg	  *) func_append future_libdirs " $libdir" ;;
294888de56ccSmrg	  esac
294988de56ccSmrg	fi
29502e9c7c8cSmrg
295188de56ccSmrg	func_dirname "$file" "/" ""
295288de56ccSmrg	dir="$func_dirname_result"
2953e9fcaa8aSmrg	func_append dir "$objdir"
295488de56ccSmrg
295588de56ccSmrg	if test -n "$relink_command"; then
295688de56ccSmrg	  # Determine the prefix the user has applied to our future dir.
2957e9fcaa8aSmrg	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
295888de56ccSmrg
295988de56ccSmrg	  # Don't allow the user to place us outside of our expected
296088de56ccSmrg	  # location b/c this prevents finding dependent libraries that
296188de56ccSmrg	  # are installed to the same prefix.
296288de56ccSmrg	  # At present, this check doesn't affect windows .dll's that
296388de56ccSmrg	  # are installed into $libdir/../bin (currently, that works fine)
296488de56ccSmrg	  # but it's something to keep an eye on.
296588de56ccSmrg	  test "$inst_prefix_dir" = "$destdir" && \
296688de56ccSmrg	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
296788de56ccSmrg
296888de56ccSmrg	  if test -n "$inst_prefix_dir"; then
296988de56ccSmrg	    # Stick the inst_prefix_dir data into the link command.
2970e9fcaa8aSmrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
297188de56ccSmrg	  else
2972e9fcaa8aSmrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
297388de56ccSmrg	  fi
297488de56ccSmrg
297588de56ccSmrg	  func_warning "relinking \`$file'"
297688de56ccSmrg	  func_show_eval "$relink_command" \
297788de56ccSmrg	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
297888de56ccSmrg	fi
297988de56ccSmrg
298088de56ccSmrg	# See the names of the shared library.
298188de56ccSmrg	set dummy $library_names; shift
298288de56ccSmrg	if test -n "$1"; then
298388de56ccSmrg	  realname="$1"
298488de56ccSmrg	  shift
298588de56ccSmrg
298688de56ccSmrg	  srcname="$realname"
298788de56ccSmrg	  test -n "$relink_command" && srcname="$realname"T
298888de56ccSmrg
298988de56ccSmrg	  # Install the shared library and build the symlinks.
2990e9fcaa8aSmrg	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
299188de56ccSmrg	      'exit $?'
299288de56ccSmrg	  tstripme="$stripme"
299388de56ccSmrg	  case $host_os in
299488de56ccSmrg	  cygwin* | mingw* | pw32* | cegcc*)
299588de56ccSmrg	    case $realname in
299688de56ccSmrg	    *.dll.a)
299788de56ccSmrg	      tstripme=""
299888de56ccSmrg	      ;;
299988de56ccSmrg	    esac
30002e9c7c8cSmrg	    ;;
30012e9c7c8cSmrg	  esac
300288de56ccSmrg	  if test -n "$tstripme" && test -n "$striplib"; then
300388de56ccSmrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
3004b4ee4795Smrg	  fi
300588de56ccSmrg
300688de56ccSmrg	  if test "$#" -gt 0; then
300788de56ccSmrg	    # Delete the old symlinks, and create new ones.
300888de56ccSmrg	    # Try `ln -sf' first, because the `ln' binary might depend on
300988de56ccSmrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
301088de56ccSmrg	    # so we also need to try rm && ln -s.
301188de56ccSmrg	    for linkname
301288de56ccSmrg	    do
301388de56ccSmrg	      test "$linkname" != "$realname" \
301488de56ccSmrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
3015b4ee4795Smrg	    done
3016b4ee4795Smrg	  fi
30171ab64890Smrg
301888de56ccSmrg	  # Do each command in the postinstall commands.
301988de56ccSmrg	  lib="$destdir/$realname"
302088de56ccSmrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
3021b4ee4795Smrg	fi
30221ab64890Smrg
302388de56ccSmrg	# Install the pseudo-library for information purposes.
302488de56ccSmrg	func_basename "$file"
302588de56ccSmrg	name="$func_basename_result"
302688de56ccSmrg	instname="$dir/$name"i
302788de56ccSmrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
30281ab64890Smrg
302988de56ccSmrg	# Maybe install the static library, too.
3030e9fcaa8aSmrg	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
303188de56ccSmrg	;;
30321ab64890Smrg
303388de56ccSmrg      *.lo)
303488de56ccSmrg	# Install (i.e. copy) a libtool object.
30351ab64890Smrg
303688de56ccSmrg	# Figure out destination file name, if it wasn't already specified.
303788de56ccSmrg	if test -n "$destname"; then
303888de56ccSmrg	  destfile="$destdir/$destname"
303988de56ccSmrg	else
304088de56ccSmrg	  func_basename "$file"
304188de56ccSmrg	  destfile="$func_basename_result"
304288de56ccSmrg	  destfile="$destdir/$destfile"
3043b4ee4795Smrg	fi
30441ab64890Smrg
304588de56ccSmrg	# Deduce the name of the destination old-style object file.
304688de56ccSmrg	case $destfile in
304788de56ccSmrg	*.lo)
304888de56ccSmrg	  func_lo2o "$destfile"
304988de56ccSmrg	  staticdest=$func_lo2o_result
305088de56ccSmrg	  ;;
305188de56ccSmrg	*.$objext)
305288de56ccSmrg	  staticdest="$destfile"
305388de56ccSmrg	  destfile=
305488de56ccSmrg	  ;;
305588de56ccSmrg	*)
305688de56ccSmrg	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
305788de56ccSmrg	  ;;
305888de56ccSmrg	esac
30591ab64890Smrg
306088de56ccSmrg	# Install the libtool object if requested.
306188de56ccSmrg	test -n "$destfile" && \
306288de56ccSmrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
30631ab64890Smrg
306488de56ccSmrg	# Install the old object if enabled.
306588de56ccSmrg	if test "$build_old_libs" = yes; then
306688de56ccSmrg	  # Deduce the name of the old-style object file.
306788de56ccSmrg	  func_lo2o "$file"
306888de56ccSmrg	  staticobj=$func_lo2o_result
306988de56ccSmrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
30701ab64890Smrg	fi
307188de56ccSmrg	exit $EXIT_SUCCESS
307288de56ccSmrg	;;
30731ab64890Smrg
307488de56ccSmrg      *)
307588de56ccSmrg	# Figure out destination file name, if it wasn't already specified.
307688de56ccSmrg	if test -n "$destname"; then
307788de56ccSmrg	  destfile="$destdir/$destname"
307888de56ccSmrg	else
307988de56ccSmrg	  func_basename "$file"
308088de56ccSmrg	  destfile="$func_basename_result"
308188de56ccSmrg	  destfile="$destdir/$destfile"
308288de56ccSmrg	fi
30831ab64890Smrg
308488de56ccSmrg	# If the file is missing, and there is a .exe on the end, strip it
308588de56ccSmrg	# because it is most likely a libtool script we actually want to
308688de56ccSmrg	# install
308788de56ccSmrg	stripped_ext=""
308888de56ccSmrg	case $file in
308988de56ccSmrg	  *.exe)
309088de56ccSmrg	    if test ! -f "$file"; then
309188de56ccSmrg	      func_stripname '' '.exe' "$file"
309288de56ccSmrg	      file=$func_stripname_result
309388de56ccSmrg	      stripped_ext=".exe"
309488de56ccSmrg	    fi
309588de56ccSmrg	    ;;
309688de56ccSmrg	esac
309788de56ccSmrg
309888de56ccSmrg	# Do a test to see if this is really a libtool program.
309988de56ccSmrg	case $host in
310088de56ccSmrg	*cygwin* | *mingw*)
310188de56ccSmrg	    if func_ltwrapper_executable_p "$file"; then
310288de56ccSmrg	      func_ltwrapper_scriptname "$file"
310388de56ccSmrg	      wrapper=$func_ltwrapper_scriptname_result
310488de56ccSmrg	    else
310588de56ccSmrg	      func_stripname '' '.exe' "$file"
310688de56ccSmrg	      wrapper=$func_stripname_result
310788de56ccSmrg	    fi
310888de56ccSmrg	    ;;
3109b4ee4795Smrg	*)
311088de56ccSmrg	    wrapper=$file
311188de56ccSmrg	    ;;
311288de56ccSmrg	esac
311388de56ccSmrg	if func_ltwrapper_script_p "$wrapper"; then
311488de56ccSmrg	  notinst_deplibs=
311588de56ccSmrg	  relink_command=
311688de56ccSmrg
311788de56ccSmrg	  func_source "$wrapper"
311888de56ccSmrg
311988de56ccSmrg	  # Check the variables that should have been set.
312088de56ccSmrg	  test -z "$generated_by_libtool_version" && \
312188de56ccSmrg	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
312288de56ccSmrg
312388de56ccSmrg	  finalize=yes
312488de56ccSmrg	  for lib in $notinst_deplibs; do
312588de56ccSmrg	    # Check to see that each library is installed.
312688de56ccSmrg	    libdir=
312788de56ccSmrg	    if test -f "$lib"; then
312888de56ccSmrg	      func_source "$lib"
312988de56ccSmrg	    fi
3130e9fcaa8aSmrg	    libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
313188de56ccSmrg	    if test -n "$libdir" && test ! -f "$libfile"; then
313288de56ccSmrg	      func_warning "\`$lib' has not been installed in \`$libdir'"
313388de56ccSmrg	      finalize=no
313488de56ccSmrg	    fi
313588de56ccSmrg	  done
313688de56ccSmrg
313788de56ccSmrg	  relink_command=
313888de56ccSmrg	  func_source "$wrapper"
313988de56ccSmrg
314088de56ccSmrg	  outputname=
314188de56ccSmrg	  if test "$fast_install" = no && test -n "$relink_command"; then
314288de56ccSmrg	    $opt_dry_run || {
314388de56ccSmrg	      if test "$finalize" = yes; then
314488de56ccSmrg	        tmpdir=`func_mktempdir`
314588de56ccSmrg		func_basename "$file$stripped_ext"
314688de56ccSmrg		file="$func_basename_result"
314788de56ccSmrg	        outputname="$tmpdir/$file"
314888de56ccSmrg	        # Replace the output file specification.
3149e9fcaa8aSmrg	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
315088de56ccSmrg
315188de56ccSmrg	        $opt_silent || {
315288de56ccSmrg	          func_quote_for_expand "$relink_command"
315388de56ccSmrg		  eval "func_echo $func_quote_for_expand_result"
315488de56ccSmrg	        }
315588de56ccSmrg	        if eval "$relink_command"; then :
315688de56ccSmrg	          else
315788de56ccSmrg		  func_error "error: relink \`$file' with the above command before installing it"
315888de56ccSmrg		  $opt_dry_run || ${RM}r "$tmpdir"
315988de56ccSmrg		  continue
316088de56ccSmrg	        fi
316188de56ccSmrg	        file="$outputname"
316288de56ccSmrg	      else
316388de56ccSmrg	        func_warning "cannot relink \`$file'"
316488de56ccSmrg	      fi
316588de56ccSmrg	    }
316688de56ccSmrg	  else
316788de56ccSmrg	    # Install the binary that we compiled earlier.
3168e9fcaa8aSmrg	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
3169b4ee4795Smrg	  fi
317088de56ccSmrg	fi
317188de56ccSmrg
317288de56ccSmrg	# remove .exe since cygwin /usr/bin/install will append another
317388de56ccSmrg	# one anyway
317488de56ccSmrg	case $install_prog,$host in
317588de56ccSmrg	*/usr/bin/install*,*cygwin*)
317688de56ccSmrg	  case $file:$destfile in
317788de56ccSmrg	  *.exe:*.exe)
317888de56ccSmrg	    # this is ok
317988de56ccSmrg	    ;;
318088de56ccSmrg	  *.exe:*)
318188de56ccSmrg	    destfile=$destfile.exe
318288de56ccSmrg	    ;;
318388de56ccSmrg	  *:*.exe)
318488de56ccSmrg	    func_stripname '' '.exe' "$destfile"
318588de56ccSmrg	    destfile=$func_stripname_result
318688de56ccSmrg	    ;;
318788de56ccSmrg	  esac
3188b4ee4795Smrg	  ;;
3189b4ee4795Smrg	esac
319088de56ccSmrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
319188de56ccSmrg	$opt_dry_run || if test -n "$outputname"; then
319288de56ccSmrg	  ${RM}r "$tmpdir"
319388de56ccSmrg	fi
319488de56ccSmrg	;;
319588de56ccSmrg      esac
319688de56ccSmrg    done
31971ab64890Smrg
319888de56ccSmrg    for file in $staticlibs; do
319988de56ccSmrg      func_basename "$file"
320088de56ccSmrg      name="$func_basename_result"
320188de56ccSmrg
320288de56ccSmrg      # Set up the ranlib parameters.
320388de56ccSmrg      oldlib="$destdir/$name"
320488de56ccSmrg
320588de56ccSmrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
320688de56ccSmrg
320788de56ccSmrg      if test -n "$stripme" && test -n "$old_striplib"; then
320888de56ccSmrg	func_show_eval "$old_striplib $oldlib" 'exit $?'
320988de56ccSmrg      fi
321088de56ccSmrg
321188de56ccSmrg      # Do each command in the postinstall commands.
321288de56ccSmrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
321388de56ccSmrg    done
321488de56ccSmrg
321588de56ccSmrg    test -n "$future_libdirs" && \
321688de56ccSmrg      func_warning "remember to run \`$progname --finish$future_libdirs'"
321788de56ccSmrg
321888de56ccSmrg    if test -n "$current_libdirs"; then
321988de56ccSmrg      # Maybe just do a dry run.
322088de56ccSmrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
322188de56ccSmrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
322288de56ccSmrg    else
322388de56ccSmrg      exit $EXIT_SUCCESS
322488de56ccSmrg    fi
322588de56ccSmrg}
322688de56ccSmrg
3227e9fcaa8aSmrgtest "$opt_mode" = install && func_mode_install ${1+"$@"}
322888de56ccSmrg
322988de56ccSmrg
323088de56ccSmrg# func_generate_dlsyms outputname originator pic_p
323188de56ccSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with
323288de56ccSmrg# a dlpreopen symbol table.
323388de56ccSmrgfunc_generate_dlsyms ()
323488de56ccSmrg{
323588de56ccSmrg    $opt_debug
323688de56ccSmrg    my_outputname="$1"
323788de56ccSmrg    my_originator="$2"
323888de56ccSmrg    my_pic_p="${3-no}"
323988de56ccSmrg    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
324088de56ccSmrg    my_dlsyms=
324188de56ccSmrg
324288de56ccSmrg    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
324388de56ccSmrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
324488de56ccSmrg	my_dlsyms="${my_outputname}S.c"
324588de56ccSmrg      else
324688de56ccSmrg	func_error "not configured to extract global symbols from dlpreopened files"
324788de56ccSmrg      fi
324888de56ccSmrg    fi
324988de56ccSmrg
325088de56ccSmrg    if test -n "$my_dlsyms"; then
325188de56ccSmrg      case $my_dlsyms in
325288de56ccSmrg      "") ;;
325388de56ccSmrg      *.c)
325488de56ccSmrg	# Discover the nlist of each of the dlfiles.
325588de56ccSmrg	nlist="$output_objdir/${my_outputname}.nm"
325688de56ccSmrg
325788de56ccSmrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
325888de56ccSmrg
325988de56ccSmrg	# Parse the name list into a source file.
326088de56ccSmrg	func_verbose "creating $output_objdir/$my_dlsyms"
326188de56ccSmrg
326288de56ccSmrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
326388de56ccSmrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
326488de56ccSmrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
326588de56ccSmrg
326688de56ccSmrg#ifdef __cplusplus
326788de56ccSmrgextern \"C\" {
326888de56ccSmrg#endif
326988de56ccSmrg
3270e9fcaa8aSmrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
3271e9fcaa8aSmrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
3272e9fcaa8aSmrg#endif
3273e9fcaa8aSmrg
3274e9fcaa8aSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
3275e9fcaa8aSmrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
3276e9fcaa8aSmrg/* DATA imports from DLLs on WIN32 con't be const, because runtime
3277e9fcaa8aSmrg   relocations are performed -- see ld's documentation on pseudo-relocs.  */
3278e9fcaa8aSmrg# define LT_DLSYM_CONST
3279e9fcaa8aSmrg#elif defined(__osf__)
3280e9fcaa8aSmrg/* This system does not cope well with relocations in const data.  */
3281e9fcaa8aSmrg# define LT_DLSYM_CONST
3282e9fcaa8aSmrg#else
3283e9fcaa8aSmrg# define LT_DLSYM_CONST const
3284e9fcaa8aSmrg#endif
3285e9fcaa8aSmrg
328688de56ccSmrg/* External symbol declarations for the compiler. */\
328788de56ccSmrg"
328888de56ccSmrg
328988de56ccSmrg	if test "$dlself" = yes; then
329088de56ccSmrg	  func_verbose "generating symbol list for \`$output'"
329188de56ccSmrg
329288de56ccSmrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
329388de56ccSmrg
329488de56ccSmrg	  # Add our own program objects to the symbol list.
3295e9fcaa8aSmrg	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
329688de56ccSmrg	  for progfile in $progfiles; do
3297e9fcaa8aSmrg	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
3298e9fcaa8aSmrg	    func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
3299e9fcaa8aSmrg	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
330088de56ccSmrg	  done
330188de56ccSmrg
330288de56ccSmrg	  if test -n "$exclude_expsyms"; then
330388de56ccSmrg	    $opt_dry_run || {
330488de56ccSmrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
330588de56ccSmrg	      eval '$MV "$nlist"T "$nlist"'
330688de56ccSmrg	    }
3307b4ee4795Smrg	  fi
330888de56ccSmrg
330988de56ccSmrg	  if test -n "$export_symbols_regex"; then
331088de56ccSmrg	    $opt_dry_run || {
331188de56ccSmrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
331288de56ccSmrg	      eval '$MV "$nlist"T "$nlist"'
331388de56ccSmrg	    }
331488de56ccSmrg	  fi
331588de56ccSmrg
331688de56ccSmrg	  # Prepare the list of exported symbols
331788de56ccSmrg	  if test -z "$export_symbols"; then
331888de56ccSmrg	    export_symbols="$output_objdir/$outputname.exp"
331988de56ccSmrg	    $opt_dry_run || {
332088de56ccSmrg	      $RM $export_symbols
332188de56ccSmrg	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
332288de56ccSmrg	      case $host in
332388de56ccSmrg	      *cygwin* | *mingw* | *cegcc* )
332488de56ccSmrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
332588de56ccSmrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
332688de56ccSmrg	        ;;
332788de56ccSmrg	      esac
332888de56ccSmrg	    }
3329b4ee4795Smrg	  else
333088de56ccSmrg	    $opt_dry_run || {
333188de56ccSmrg	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
333288de56ccSmrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
333388de56ccSmrg	      eval '$MV "$nlist"T "$nlist"'
333488de56ccSmrg	      case $host in
3335e9fcaa8aSmrg	        *cygwin* | *mingw* | *cegcc* )
333688de56ccSmrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
333788de56ccSmrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
333888de56ccSmrg	          ;;
333988de56ccSmrg	      esac
334088de56ccSmrg	    }
3341b4ee4795Smrg	  fi
334288de56ccSmrg	fi
33431ab64890Smrg
334488de56ccSmrg	for dlprefile in $dlprefiles; do
334588de56ccSmrg	  func_verbose "extracting global C symbols from \`$dlprefile'"
334688de56ccSmrg	  func_basename "$dlprefile"
334788de56ccSmrg	  name="$func_basename_result"
3348e9fcaa8aSmrg          case $host in
3349e9fcaa8aSmrg	    *cygwin* | *mingw* | *cegcc* )
3350e9fcaa8aSmrg	      # if an import library, we need to obtain dlname
3351e9fcaa8aSmrg	      if func_win32_import_lib_p "$dlprefile"; then
3352e9fcaa8aSmrg	        func_tr_sh "$dlprefile"
3353e9fcaa8aSmrg	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
3354e9fcaa8aSmrg	        dlprefile_dlbasename=""
3355e9fcaa8aSmrg	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
3356e9fcaa8aSmrg	          # Use subshell, to avoid clobbering current variable values
3357e9fcaa8aSmrg	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
3358e9fcaa8aSmrg	          if test -n "$dlprefile_dlname" ; then
3359e9fcaa8aSmrg	            func_basename "$dlprefile_dlname"
3360e9fcaa8aSmrg	            dlprefile_dlbasename="$func_basename_result"
3361e9fcaa8aSmrg	          else
3362e9fcaa8aSmrg	            # no lafile. user explicitly requested -dlpreopen <import library>.
3363e9fcaa8aSmrg	            $sharedlib_from_linklib_cmd "$dlprefile"
3364e9fcaa8aSmrg	            dlprefile_dlbasename=$sharedlib_from_linklib_result
3365e9fcaa8aSmrg	          fi
3366e9fcaa8aSmrg	        fi
3367e9fcaa8aSmrg	        $opt_dry_run || {
3368e9fcaa8aSmrg	          if test -n "$dlprefile_dlbasename" ; then
3369e9fcaa8aSmrg	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
3370e9fcaa8aSmrg	          else
3371e9fcaa8aSmrg	            func_warning "Could not compute DLL name from $name"
3372e9fcaa8aSmrg	            eval '$ECHO ": $name " >> "$nlist"'
3373e9fcaa8aSmrg	          fi
3374e9fcaa8aSmrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3375e9fcaa8aSmrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
3376e9fcaa8aSmrg	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
3377e9fcaa8aSmrg	        }
3378e9fcaa8aSmrg	      else # not an import lib
3379e9fcaa8aSmrg	        $opt_dry_run || {
3380e9fcaa8aSmrg	          eval '$ECHO ": $name " >> "$nlist"'
3381e9fcaa8aSmrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3382e9fcaa8aSmrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3383e9fcaa8aSmrg	        }
3384e9fcaa8aSmrg	      fi
3385e9fcaa8aSmrg	    ;;
3386e9fcaa8aSmrg	    *)
3387e9fcaa8aSmrg	      $opt_dry_run || {
3388e9fcaa8aSmrg	        eval '$ECHO ": $name " >> "$nlist"'
3389e9fcaa8aSmrg	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3390e9fcaa8aSmrg	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3391e9fcaa8aSmrg	      }
3392e9fcaa8aSmrg	    ;;
3393e9fcaa8aSmrg          esac
339488de56ccSmrg	done
339588de56ccSmrg
339688de56ccSmrg	$opt_dry_run || {
339788de56ccSmrg	  # Make sure we have at least an empty file.
339888de56ccSmrg	  test -f "$nlist" || : > "$nlist"
339988de56ccSmrg
340088de56ccSmrg	  if test -n "$exclude_expsyms"; then
340188de56ccSmrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
340288de56ccSmrg	    $MV "$nlist"T "$nlist"
3403b4ee4795Smrg	  fi
340488de56ccSmrg
340588de56ccSmrg	  # Try sorting and uniquifying the output.
340688de56ccSmrg	  if $GREP -v "^: " < "$nlist" |
340788de56ccSmrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
340888de56ccSmrg		sort -k 3
340988de56ccSmrg	      else
341088de56ccSmrg		sort +2
341188de56ccSmrg	      fi |
341288de56ccSmrg	      uniq > "$nlist"S; then
341388de56ccSmrg	    :
3414b4ee4795Smrg	  else
341588de56ccSmrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
3416b4ee4795Smrg	  fi
34171ab64890Smrg
341888de56ccSmrg	  if test -f "$nlist"S; then
341988de56ccSmrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
3420b4ee4795Smrg	  else
3421e9fcaa8aSmrg	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
3422b4ee4795Smrg	  fi
34231ab64890Smrg
3424e9fcaa8aSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
34251ab64890Smrg
342688de56ccSmrg/* The mapping between symbol names and symbols.  */
342788de56ccSmrgtypedef struct {
342888de56ccSmrg  const char *name;
342988de56ccSmrg  void *address;
343088de56ccSmrg} lt_dlsymlist;
3431e9fcaa8aSmrgextern LT_DLSYM_CONST lt_dlsymlist
343288de56ccSmrglt_${my_prefix}_LTX_preloaded_symbols[];
3433e9fcaa8aSmrgLT_DLSYM_CONST lt_dlsymlist
343488de56ccSmrglt_${my_prefix}_LTX_preloaded_symbols[] =
343588de56ccSmrg{\
343688de56ccSmrg  { \"$my_originator\", (void *) 0 },"
34371ab64890Smrg
343888de56ccSmrg	  case $need_lib_prefix in
343988de56ccSmrg	  no)
344088de56ccSmrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
344188de56ccSmrg	    ;;
344288de56ccSmrg	  *)
344388de56ccSmrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
344488de56ccSmrg	    ;;
344588de56ccSmrg	  esac
3446e9fcaa8aSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
344788de56ccSmrg  {0, (void *) 0}
344888de56ccSmrg};
34491ab64890Smrg
345088de56ccSmrg/* This works around a problem in FreeBSD linker */
345188de56ccSmrg#ifdef FREEBSD_WORKAROUND
345288de56ccSmrgstatic const void *lt_preloaded_setup() {
345388de56ccSmrg  return lt_${my_prefix}_LTX_preloaded_symbols;
345488de56ccSmrg}
345588de56ccSmrg#endif
345688de56ccSmrg
345788de56ccSmrg#ifdef __cplusplus
345888de56ccSmrg}
345988de56ccSmrg#endif\
346088de56ccSmrg"
346188de56ccSmrg	} # !$opt_dry_run
346288de56ccSmrg
346388de56ccSmrg	pic_flag_for_symtable=
346488de56ccSmrg	case "$compile_command " in
346588de56ccSmrg	*" -static "*) ;;
346688de56ccSmrg	*)
346788de56ccSmrg	  case $host in
346888de56ccSmrg	  # compiling the symbol table file with pic_flag works around
346988de56ccSmrg	  # a FreeBSD bug that causes programs to crash when -lm is
347088de56ccSmrg	  # linked before any other PIC object.  But we must not use
347188de56ccSmrg	  # pic_flag when linking with -static.  The problem exists in
347288de56ccSmrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
347388de56ccSmrg	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
347488de56ccSmrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
347588de56ccSmrg	  *-*-hpux*)
347688de56ccSmrg	    pic_flag_for_symtable=" $pic_flag"  ;;
347788de56ccSmrg	  *)
347888de56ccSmrg	    if test "X$my_pic_p" != Xno; then
347988de56ccSmrg	      pic_flag_for_symtable=" $pic_flag"
3480b4ee4795Smrg	    fi
348188de56ccSmrg	    ;;
348288de56ccSmrg	  esac
348388de56ccSmrg	  ;;
348488de56ccSmrg	esac
348588de56ccSmrg	symtab_cflags=
348688de56ccSmrg	for arg in $LTCFLAGS; do
348788de56ccSmrg	  case $arg in
348888de56ccSmrg	  -pie | -fpie | -fPIE) ;;
3489e9fcaa8aSmrg	  *) func_append symtab_cflags " $arg" ;;
349088de56ccSmrg	  esac
349188de56ccSmrg	done
34921ab64890Smrg
349388de56ccSmrg	# Now compile the dynamic symbol file.
349488de56ccSmrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
34952e9c7c8cSmrg
349688de56ccSmrg	# Clean up the generated files.
349788de56ccSmrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
34981ab64890Smrg
349988de56ccSmrg	# Transform the symbol file into the correct name.
350088de56ccSmrg	symfileobj="$output_objdir/${my_outputname}S.$objext"
350188de56ccSmrg	case $host in
350288de56ccSmrg	*cygwin* | *mingw* | *cegcc* )
350388de56ccSmrg	  if test -f "$output_objdir/$my_outputname.def"; then
3504e9fcaa8aSmrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3505e9fcaa8aSmrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
350688de56ccSmrg	  else
3507e9fcaa8aSmrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3508e9fcaa8aSmrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3509b4ee4795Smrg	  fi
351088de56ccSmrg	  ;;
351188de56ccSmrg	*)
3512e9fcaa8aSmrg	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3513e9fcaa8aSmrg	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
351488de56ccSmrg	  ;;
351588de56ccSmrg	esac
351688de56ccSmrg	;;
351788de56ccSmrg      *)
351888de56ccSmrg	func_fatal_error "unknown suffix for \`$my_dlsyms'"
351988de56ccSmrg	;;
352088de56ccSmrg      esac
352188de56ccSmrg    else
352288de56ccSmrg      # We keep going just in case the user didn't refer to
352388de56ccSmrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
352488de56ccSmrg      # really was required.
35251ab64890Smrg
352688de56ccSmrg      # Nullify the symbol file.
3527e9fcaa8aSmrg      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
3528e9fcaa8aSmrg      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
352988de56ccSmrg    fi
353088de56ccSmrg}
35312e9c7c8cSmrg
353288de56ccSmrg# func_win32_libid arg
353388de56ccSmrg# return the library type of file 'arg'
353488de56ccSmrg#
353588de56ccSmrg# Need a lot of goo to handle *both* DLLs and import libs
353688de56ccSmrg# Has to be a shell function in order to 'eat' the argument
353788de56ccSmrg# that is supplied when $file_magic_command is called.
3538e9fcaa8aSmrg# Despite the name, also deal with 64 bit binaries.
353988de56ccSmrgfunc_win32_libid ()
354088de56ccSmrg{
354188de56ccSmrg  $opt_debug
354288de56ccSmrg  win32_libid_type="unknown"
354388de56ccSmrg  win32_fileres=`file -L $1 2>/dev/null`
354488de56ccSmrg  case $win32_fileres in
354588de56ccSmrg  *ar\ archive\ import\ library*) # definitely import
354688de56ccSmrg    win32_libid_type="x86 archive import"
354788de56ccSmrg    ;;
354888de56ccSmrg  *ar\ archive*) # could be an import, or static
3549e9fcaa8aSmrg    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
355088de56ccSmrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
3551e9fcaa8aSmrg       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
3552e9fcaa8aSmrg      func_to_tool_file "$1" func_convert_file_msys_to_w32
3553e9fcaa8aSmrg      win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
355488de56ccSmrg	$SED -n -e '
355588de56ccSmrg	    1,100{
355688de56ccSmrg		/ I /{
355788de56ccSmrg		    s,.*,import,
355888de56ccSmrg		    p
355988de56ccSmrg		    q
356088de56ccSmrg		}
356188de56ccSmrg	    }'`
356288de56ccSmrg      case $win32_nmres in
356388de56ccSmrg      import*)  win32_libid_type="x86 archive import";;
356488de56ccSmrg      *)        win32_libid_type="x86 archive static";;
356588de56ccSmrg      esac
356688de56ccSmrg    fi
356788de56ccSmrg    ;;
356888de56ccSmrg  *DLL*)
356988de56ccSmrg    win32_libid_type="x86 DLL"
357088de56ccSmrg    ;;
357188de56ccSmrg  *executable*) # but shell scripts are "executable" too...
357288de56ccSmrg    case $win32_fileres in
357388de56ccSmrg    *MS\ Windows\ PE\ Intel*)
357488de56ccSmrg      win32_libid_type="x86 DLL"
357588de56ccSmrg      ;;
357688de56ccSmrg    esac
357788de56ccSmrg    ;;
357888de56ccSmrg  esac
357988de56ccSmrg  $ECHO "$win32_libid_type"
358088de56ccSmrg}
35812e9c7c8cSmrg
3582e9fcaa8aSmrg# func_cygming_dll_for_implib ARG
3583e9fcaa8aSmrg#
3584e9fcaa8aSmrg# Platform-specific function to extract the
3585e9fcaa8aSmrg# name of the DLL associated with the specified
3586e9fcaa8aSmrg# import library ARG.
3587e9fcaa8aSmrg# Invoked by eval'ing the libtool variable
3588e9fcaa8aSmrg#    $sharedlib_from_linklib_cmd
3589e9fcaa8aSmrg# Result is available in the variable
3590e9fcaa8aSmrg#    $sharedlib_from_linklib_result
3591e9fcaa8aSmrgfunc_cygming_dll_for_implib ()
3592e9fcaa8aSmrg{
3593e9fcaa8aSmrg  $opt_debug
3594e9fcaa8aSmrg  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
3595e9fcaa8aSmrg}
3596e9fcaa8aSmrg
3597e9fcaa8aSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
3598e9fcaa8aSmrg#
3599e9fcaa8aSmrg# The is the core of a fallback implementation of a
3600e9fcaa8aSmrg# platform-specific function to extract the name of the
3601e9fcaa8aSmrg# DLL associated with the specified import library LIBNAME.
3602e9fcaa8aSmrg#
3603e9fcaa8aSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending
3604e9fcaa8aSmrg# on the platform and compiler that created the implib.
3605e9fcaa8aSmrg#
3606e9fcaa8aSmrg# Echos the name of the DLL associated with the
3607e9fcaa8aSmrg# specified import library.
3608e9fcaa8aSmrgfunc_cygming_dll_for_implib_fallback_core ()
3609e9fcaa8aSmrg{
3610e9fcaa8aSmrg  $opt_debug
3611e9fcaa8aSmrg  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
3612e9fcaa8aSmrg  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
3613e9fcaa8aSmrg    $SED '/^Contents of section '"$match_literal"':/{
3614e9fcaa8aSmrg      # Place marker at beginning of archive member dllname section
3615e9fcaa8aSmrg      s/.*/====MARK====/
3616e9fcaa8aSmrg      p
3617e9fcaa8aSmrg      d
3618e9fcaa8aSmrg    }
3619e9fcaa8aSmrg    # These lines can sometimes be longer than 43 characters, but
3620e9fcaa8aSmrg    # are always uninteresting
3621e9fcaa8aSmrg    /:[	 ]*file format pe[i]\{,1\}-/d
3622e9fcaa8aSmrg    /^In archive [^:]*:/d
3623e9fcaa8aSmrg    # Ensure marker is printed
3624e9fcaa8aSmrg    /^====MARK====/p
3625e9fcaa8aSmrg    # Remove all lines with less than 43 characters
3626e9fcaa8aSmrg    /^.\{43\}/!d
3627e9fcaa8aSmrg    # From remaining lines, remove first 43 characters
3628e9fcaa8aSmrg    s/^.\{43\}//' |
3629e9fcaa8aSmrg    $SED -n '
3630e9fcaa8aSmrg      # Join marker and all lines until next marker into a single line
3631e9fcaa8aSmrg      /^====MARK====/ b para
3632e9fcaa8aSmrg      H
3633e9fcaa8aSmrg      $ b para
3634e9fcaa8aSmrg      b
3635e9fcaa8aSmrg      :para
3636e9fcaa8aSmrg      x
3637e9fcaa8aSmrg      s/\n//g
3638e9fcaa8aSmrg      # Remove the marker
3639e9fcaa8aSmrg      s/^====MARK====//
3640e9fcaa8aSmrg      # Remove trailing dots and whitespace
3641e9fcaa8aSmrg      s/[\. \t]*$//
3642e9fcaa8aSmrg      # Print
3643e9fcaa8aSmrg      /./p' |
3644e9fcaa8aSmrg    # we now have a list, one entry per line, of the stringified
3645e9fcaa8aSmrg    # contents of the appropriate section of all members of the
3646e9fcaa8aSmrg    # archive which possess that section. Heuristic: eliminate
3647e9fcaa8aSmrg    # all those which have a first or second character that is
3648e9fcaa8aSmrg    # a '.' (that is, objdump's representation of an unprintable
3649e9fcaa8aSmrg    # character.) This should work for all archives with less than
3650e9fcaa8aSmrg    # 0x302f exports -- but will fail for DLLs whose name actually
3651e9fcaa8aSmrg    # begins with a literal '.' or a single character followed by
3652e9fcaa8aSmrg    # a '.'.
3653e9fcaa8aSmrg    #
3654e9fcaa8aSmrg    # Of those that remain, print the first one.
3655e9fcaa8aSmrg    $SED -e '/^\./d;/^.\./d;q'
3656e9fcaa8aSmrg}
3657e9fcaa8aSmrg
3658e9fcaa8aSmrg# func_cygming_gnu_implib_p ARG
3659e9fcaa8aSmrg# This predicate returns with zero status (TRUE) if
3660e9fcaa8aSmrg# ARG is a GNU/binutils-style import library. Returns
3661e9fcaa8aSmrg# with nonzero status (FALSE) otherwise.
3662e9fcaa8aSmrgfunc_cygming_gnu_implib_p ()
3663e9fcaa8aSmrg{
3664e9fcaa8aSmrg  $opt_debug
3665e9fcaa8aSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
3666e9fcaa8aSmrg  func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'`
3667e9fcaa8aSmrg  test -n "$func_cygming_gnu_implib_tmp"
3668e9fcaa8aSmrg}
3669e9fcaa8aSmrg
3670e9fcaa8aSmrg# func_cygming_ms_implib_p ARG
3671e9fcaa8aSmrg# This predicate returns with zero status (TRUE) if
3672e9fcaa8aSmrg# ARG is an MS-style import library. Returns
3673e9fcaa8aSmrg# with nonzero status (FALSE) otherwise.
3674e9fcaa8aSmrgfunc_cygming_ms_implib_p ()
3675e9fcaa8aSmrg{
3676e9fcaa8aSmrg  $opt_debug
3677e9fcaa8aSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
3678e9fcaa8aSmrg  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
3679e9fcaa8aSmrg  test -n "$func_cygming_ms_implib_tmp"
3680e9fcaa8aSmrg}
3681e9fcaa8aSmrg
3682e9fcaa8aSmrg# func_cygming_dll_for_implib_fallback ARG
3683e9fcaa8aSmrg# Platform-specific function to extract the
3684e9fcaa8aSmrg# name of the DLL associated with the specified
3685e9fcaa8aSmrg# import library ARG.
3686e9fcaa8aSmrg#
3687e9fcaa8aSmrg# This fallback implementation is for use when $DLLTOOL
3688e9fcaa8aSmrg# does not support the --identify-strict option.
3689e9fcaa8aSmrg# Invoked by eval'ing the libtool variable
3690e9fcaa8aSmrg#    $sharedlib_from_linklib_cmd
3691e9fcaa8aSmrg# Result is available in the variable
3692e9fcaa8aSmrg#    $sharedlib_from_linklib_result
3693e9fcaa8aSmrgfunc_cygming_dll_for_implib_fallback ()
3694e9fcaa8aSmrg{
3695e9fcaa8aSmrg  $opt_debug
3696e9fcaa8aSmrg  if func_cygming_gnu_implib_p "$1" ; then
3697e9fcaa8aSmrg    # binutils import library
3698e9fcaa8aSmrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
3699e9fcaa8aSmrg  elif func_cygming_ms_implib_p "$1" ; then
3700e9fcaa8aSmrg    # ms-generated import library
3701e9fcaa8aSmrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
3702e9fcaa8aSmrg  else
3703e9fcaa8aSmrg    # unknown
3704e9fcaa8aSmrg    sharedlib_from_linklib_result=""
3705e9fcaa8aSmrg  fi
3706e9fcaa8aSmrg}
37072e9c7c8cSmrg
37082e9c7c8cSmrg
370988de56ccSmrg# func_extract_an_archive dir oldlib
371088de56ccSmrgfunc_extract_an_archive ()
371188de56ccSmrg{
371288de56ccSmrg    $opt_debug
371388de56ccSmrg    f_ex_an_ar_dir="$1"; shift
371488de56ccSmrg    f_ex_an_ar_oldlib="$1"
3715e9fcaa8aSmrg    if test "$lock_old_archive_extraction" = yes; then
3716e9fcaa8aSmrg      lockfile=$f_ex_an_ar_oldlib.lock
3717e9fcaa8aSmrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
3718e9fcaa8aSmrg	func_echo "Waiting for $lockfile to be removed"
3719e9fcaa8aSmrg	sleep 2
3720e9fcaa8aSmrg      done
3721e9fcaa8aSmrg    fi
3722e9fcaa8aSmrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
3723e9fcaa8aSmrg		   'stat=$?; rm -f "$lockfile"; exit $stat'
3724e9fcaa8aSmrg    if test "$lock_old_archive_extraction" = yes; then
3725e9fcaa8aSmrg      $opt_dry_run || rm -f "$lockfile"
3726e9fcaa8aSmrg    fi
372788de56ccSmrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
372888de56ccSmrg     :
372988de56ccSmrg    else
373088de56ccSmrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
373188de56ccSmrg    fi
373288de56ccSmrg}
37331ab64890Smrg
37341ab64890Smrg
373588de56ccSmrg# func_extract_archives gentop oldlib ...
373688de56ccSmrgfunc_extract_archives ()
373788de56ccSmrg{
373888de56ccSmrg    $opt_debug
373988de56ccSmrg    my_gentop="$1"; shift
374088de56ccSmrg    my_oldlibs=${1+"$@"}
374188de56ccSmrg    my_oldobjs=""
374288de56ccSmrg    my_xlib=""
374388de56ccSmrg    my_xabs=""
374488de56ccSmrg    my_xdir=""
37451ab64890Smrg
374688de56ccSmrg    for my_xlib in $my_oldlibs; do
374788de56ccSmrg      # Extract the objects.
374888de56ccSmrg      case $my_xlib in
374988de56ccSmrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
375088de56ccSmrg	*) my_xabs=`pwd`"/$my_xlib" ;;
375188de56ccSmrg      esac
375288de56ccSmrg      func_basename "$my_xlib"
375388de56ccSmrg      my_xlib="$func_basename_result"
375488de56ccSmrg      my_xlib_u=$my_xlib
375588de56ccSmrg      while :; do
375688de56ccSmrg        case " $extracted_archives " in
375788de56ccSmrg	*" $my_xlib_u "*)
375888de56ccSmrg	  func_arith $extracted_serial + 1
375988de56ccSmrg	  extracted_serial=$func_arith_result
376088de56ccSmrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
376188de56ccSmrg	*) break ;;
376288de56ccSmrg	esac
376388de56ccSmrg      done
376488de56ccSmrg      extracted_archives="$extracted_archives $my_xlib_u"
376588de56ccSmrg      my_xdir="$my_gentop/$my_xlib_u"
37661ab64890Smrg
376788de56ccSmrg      func_mkdir_p "$my_xdir"
37682e9c7c8cSmrg
376988de56ccSmrg      case $host in
377088de56ccSmrg      *-darwin*)
377188de56ccSmrg	func_verbose "Extracting $my_xabs"
377288de56ccSmrg	# Do not bother doing anything if just a dry run
377388de56ccSmrg	$opt_dry_run || {
377488de56ccSmrg	  darwin_orig_dir=`pwd`
377588de56ccSmrg	  cd $my_xdir || exit $?
377688de56ccSmrg	  darwin_archive=$my_xabs
377788de56ccSmrg	  darwin_curdir=`pwd`
377888de56ccSmrg	  darwin_base_archive=`basename "$darwin_archive"`
377988de56ccSmrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
378088de56ccSmrg	  if test -n "$darwin_arches"; then
378188de56ccSmrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
378288de56ccSmrg	    darwin_arch=
378388de56ccSmrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
378488de56ccSmrg	    for darwin_arch in  $darwin_arches ; do
378588de56ccSmrg	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
378688de56ccSmrg	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
378788de56ccSmrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
378888de56ccSmrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
378988de56ccSmrg	      cd "$darwin_curdir"
379088de56ccSmrg	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
379188de56ccSmrg	    done # $darwin_arches
379288de56ccSmrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
379388de56ccSmrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
379488de56ccSmrg	    darwin_file=
379588de56ccSmrg	    darwin_files=
379688de56ccSmrg	    for darwin_file in $darwin_filelist; do
3797e9fcaa8aSmrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
379888de56ccSmrg	      $LIPO -create -output "$darwin_file" $darwin_files
379988de56ccSmrg	    done # $darwin_filelist
380088de56ccSmrg	    $RM -rf unfat-$$
380188de56ccSmrg	    cd "$darwin_orig_dir"
3802b4ee4795Smrg	  else
380388de56ccSmrg	    cd $darwin_orig_dir
380488de56ccSmrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
380588de56ccSmrg	  fi # $darwin_arches
380688de56ccSmrg	} # !$opt_dry_run
380788de56ccSmrg	;;
380888de56ccSmrg      *)
380988de56ccSmrg        func_extract_an_archive "$my_xdir" "$my_xabs"
381088de56ccSmrg	;;
381188de56ccSmrg      esac
3812e9fcaa8aSmrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
381388de56ccSmrg    done
38141ab64890Smrg
381588de56ccSmrg    func_extract_archives_result="$my_oldobjs"
381688de56ccSmrg}
38171ab64890Smrg
38181ab64890Smrg
3819e9fcaa8aSmrg# func_emit_wrapper [arg=no]
3820e9fcaa8aSmrg#
3821e9fcaa8aSmrg# Emit a libtool wrapper script on stdout.
3822e9fcaa8aSmrg# Don't directly open a file because we may want to
3823e9fcaa8aSmrg# incorporate the script contents within a cygwin/mingw
3824e9fcaa8aSmrg# wrapper executable.  Must ONLY be called from within
3825e9fcaa8aSmrg# func_mode_link because it depends on a number of variables
3826e9fcaa8aSmrg# set therein.
382788de56ccSmrg#
3828e9fcaa8aSmrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
3829e9fcaa8aSmrg# variable will take.  If 'yes', then the emitted script
3830e9fcaa8aSmrg# will assume that the directory in which it is stored is
3831e9fcaa8aSmrg# the $objdir directory.  This is a cygwin/mingw-specific
3832e9fcaa8aSmrg# behavior.
3833e9fcaa8aSmrgfunc_emit_wrapper ()
383488de56ccSmrg{
3835e9fcaa8aSmrg	func_emit_wrapper_arg1=${1-no}
3836b4ee4795Smrg
383788de56ccSmrg	$ECHO "\
383888de56ccSmrg#! $SHELL
38391ab64890Smrg
384088de56ccSmrg# $output - temporary wrapper script for $objdir/$outputname
384188de56ccSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
384288de56ccSmrg#
384388de56ccSmrg# The $output program cannot be directly executed until all the libtool
384488de56ccSmrg# libraries that it depends on are installed.
384588de56ccSmrg#
384688de56ccSmrg# This wrapper script should never be moved out of the build directory.
384788de56ccSmrg# If it is, it will not operate correctly.
38481ab64890Smrg
384988de56ccSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
385088de56ccSmrg# metacharacters that are still active within double-quoted strings.
385188de56ccSmrgsed_quote_subst='$sed_quote_subst'
38521ab64890Smrg
385388de56ccSmrg# Be Bourne compatible
385488de56ccSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
385588de56ccSmrg  emulate sh
385688de56ccSmrg  NULLCMD=:
385788de56ccSmrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
385888de56ccSmrg  # is contrary to our usage.  Disable this feature.
385988de56ccSmrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
386088de56ccSmrg  setopt NO_GLOB_SUBST
386188de56ccSmrgelse
386288de56ccSmrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
386388de56ccSmrgfi
386488de56ccSmrgBIN_SH=xpg4; export BIN_SH # for Tru64
386588de56ccSmrgDUALCASE=1; export DUALCASE # for MKS sh
38661ab64890Smrg
386788de56ccSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout
386888de56ccSmrg# if CDPATH is set.
386988de56ccSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
38701ab64890Smrg
387188de56ccSmrgrelink_command=\"$relink_command\"
38721ab64890Smrg
387388de56ccSmrg# This environment variable determines our operation mode.
387488de56ccSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then
387588de56ccSmrg  # install mode needs the following variables:
387688de56ccSmrg  generated_by_libtool_version='$macro_version'
387788de56ccSmrg  notinst_deplibs='$notinst_deplibs'
387888de56ccSmrgelse
387988de56ccSmrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
388088de56ccSmrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
3881e9fcaa8aSmrg    file=\"\$0\""
3882e9fcaa8aSmrg
3883e9fcaa8aSmrg    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
3884e9fcaa8aSmrg    $ECHO "\
3885e9fcaa8aSmrg
3886e9fcaa8aSmrg# A function that is used when there is no print builtin or printf.
3887e9fcaa8aSmrgfunc_fallback_echo ()
3888e9fcaa8aSmrg{
3889e9fcaa8aSmrg  eval 'cat <<_LTECHO_EOF
3890e9fcaa8aSmrg\$1
3891e9fcaa8aSmrg_LTECHO_EOF'
3892e9fcaa8aSmrg}
3893e9fcaa8aSmrg    ECHO=\"$qECHO\"
3894e9fcaa8aSmrg  fi
3895e9fcaa8aSmrg
3896e9fcaa8aSmrg# Very basic option parsing. These options are (a) specific to
3897e9fcaa8aSmrg# the libtool wrapper, (b) are identical between the wrapper
3898e9fcaa8aSmrg# /script/ and the wrapper /executable/ which is used only on
3899e9fcaa8aSmrg# windows platforms, and (c) all begin with the string "--lt-"
3900e9fcaa8aSmrg# (application programs are unlikely to have options which match
3901e9fcaa8aSmrg# this pattern).
3902e9fcaa8aSmrg#
3903e9fcaa8aSmrg# There are only two supported options: --lt-debug and
3904e9fcaa8aSmrg# --lt-dump-script. There is, deliberately, no --lt-help.
3905e9fcaa8aSmrg#
3906e9fcaa8aSmrg# The first argument to this parsing function should be the
3907e9fcaa8aSmrg# script's $0 value, followed by "$@".
3908e9fcaa8aSmrglt_option_debug=
3909e9fcaa8aSmrgfunc_parse_lt_options ()
3910e9fcaa8aSmrg{
3911e9fcaa8aSmrg  lt_script_arg0=\$0
3912e9fcaa8aSmrg  shift
3913e9fcaa8aSmrg  for lt_opt
3914e9fcaa8aSmrg  do
3915e9fcaa8aSmrg    case \"\$lt_opt\" in
3916e9fcaa8aSmrg    --lt-debug) lt_option_debug=1 ;;
3917e9fcaa8aSmrg    --lt-dump-script)
3918e9fcaa8aSmrg        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
3919e9fcaa8aSmrg        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
3920e9fcaa8aSmrg        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
3921e9fcaa8aSmrg        cat \"\$lt_dump_D/\$lt_dump_F\"
3922e9fcaa8aSmrg        exit 0
3923e9fcaa8aSmrg      ;;
3924e9fcaa8aSmrg    --lt-*)
3925e9fcaa8aSmrg        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
3926e9fcaa8aSmrg        exit 1
3927e9fcaa8aSmrg      ;;
3928e9fcaa8aSmrg    esac
3929e9fcaa8aSmrg  done
3930e9fcaa8aSmrg
3931e9fcaa8aSmrg  # Print the debug banner immediately:
3932e9fcaa8aSmrg  if test -n \"\$lt_option_debug\"; then
3933e9fcaa8aSmrg    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
3934e9fcaa8aSmrg  fi
3935e9fcaa8aSmrg}
3936e9fcaa8aSmrg
3937e9fcaa8aSmrg# Used when --lt-debug. Prints its arguments to stdout
3938e9fcaa8aSmrg# (redirection is the responsibility of the caller)
3939e9fcaa8aSmrgfunc_lt_dump_args ()
3940e9fcaa8aSmrg{
3941e9fcaa8aSmrg  lt_dump_args_N=1;
3942e9fcaa8aSmrg  for lt_arg
3943e9fcaa8aSmrg  do
3944e9fcaa8aSmrg    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
3945e9fcaa8aSmrg    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
3946e9fcaa8aSmrg  done
3947e9fcaa8aSmrg}
3948e9fcaa8aSmrg
3949e9fcaa8aSmrg# Core function for launching the target application
3950e9fcaa8aSmrgfunc_exec_program_core ()
3951e9fcaa8aSmrg{
395288de56ccSmrg"
3953e9fcaa8aSmrg  case $host in
3954e9fcaa8aSmrg  # Backslashes separate directories on plain windows
3955e9fcaa8aSmrg  *-*-mingw | *-*-os2* | *-cegcc*)
3956e9fcaa8aSmrg    $ECHO "\
3957e9fcaa8aSmrg      if test -n \"\$lt_option_debug\"; then
3958e9fcaa8aSmrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
3959e9fcaa8aSmrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
3960e9fcaa8aSmrg      fi
3961e9fcaa8aSmrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
3962e9fcaa8aSmrg"
3963e9fcaa8aSmrg    ;;
3964e9fcaa8aSmrg
3965e9fcaa8aSmrg  *)
3966e9fcaa8aSmrg    $ECHO "\
3967e9fcaa8aSmrg      if test -n \"\$lt_option_debug\"; then
3968e9fcaa8aSmrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
3969e9fcaa8aSmrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
3970e9fcaa8aSmrg      fi
3971e9fcaa8aSmrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
3972e9fcaa8aSmrg"
3973e9fcaa8aSmrg    ;;
3974e9fcaa8aSmrg  esac
3975e9fcaa8aSmrg  $ECHO "\
3976e9fcaa8aSmrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
3977e9fcaa8aSmrg      exit 1
3978e9fcaa8aSmrg}
3979e9fcaa8aSmrg
3980e9fcaa8aSmrg# A function to encapsulate launching the target application
3981e9fcaa8aSmrg# Strips options in the --lt-* namespace from \$@ and
3982e9fcaa8aSmrg# launches target application with the remaining arguments.
3983e9fcaa8aSmrgfunc_exec_program ()
3984e9fcaa8aSmrg{
3985e9fcaa8aSmrg  for lt_wr_arg
3986e9fcaa8aSmrg  do
3987e9fcaa8aSmrg    case \$lt_wr_arg in
3988e9fcaa8aSmrg    --lt-*) ;;
3989e9fcaa8aSmrg    *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
3990e9fcaa8aSmrg    esac
3991e9fcaa8aSmrg    shift
3992e9fcaa8aSmrg  done
3993e9fcaa8aSmrg  func_exec_program_core \${1+\"\$@\"}
3994e9fcaa8aSmrg}
3995e9fcaa8aSmrg
3996e9fcaa8aSmrg  # Parse options
3997e9fcaa8aSmrg  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
39981ab64890Smrg
399988de56ccSmrg  # Find the directory that this script lives in.
4000e9fcaa8aSmrg  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
400188de56ccSmrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
40021ab64890Smrg
400388de56ccSmrg  # Follow symbolic links until we get to the real thisdir.
4004e9fcaa8aSmrg  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
400588de56ccSmrg  while test -n \"\$file\"; do
4006e9fcaa8aSmrg    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
40071ab64890Smrg
400888de56ccSmrg    # If there was a directory component, then change thisdir.
400988de56ccSmrg    if test \"x\$destdir\" != \"x\$file\"; then
401088de56ccSmrg      case \"\$destdir\" in
401188de56ccSmrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
401288de56ccSmrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
4013b4ee4795Smrg      esac
401488de56ccSmrg    fi
40151ab64890Smrg
4016e9fcaa8aSmrg    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
4017e9fcaa8aSmrg    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
401888de56ccSmrg  done
40191ab64890Smrg
402088de56ccSmrg  # Usually 'no', except on cygwin/mingw when embedded into
402188de56ccSmrg  # the cwrapper.
4022e9fcaa8aSmrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
402388de56ccSmrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
402488de56ccSmrg    # special case for '.'
402588de56ccSmrg    if test \"\$thisdir\" = \".\"; then
402688de56ccSmrg      thisdir=\`pwd\`
402788de56ccSmrg    fi
402888de56ccSmrg    # remove .libs from thisdir
402988de56ccSmrg    case \"\$thisdir\" in
4030e9fcaa8aSmrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
403188de56ccSmrg    $objdir )   thisdir=. ;;
403288de56ccSmrg    esac
403388de56ccSmrg  fi
403488de56ccSmrg
403588de56ccSmrg  # Try to get the absolute directory name.
403688de56ccSmrg  absdir=\`cd \"\$thisdir\" && pwd\`
403788de56ccSmrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
403888de56ccSmrg"
403988de56ccSmrg
404088de56ccSmrg	if test "$fast_install" = yes; then
404188de56ccSmrg	  $ECHO "\
404288de56ccSmrg  program=lt-'$outputname'$exeext
404388de56ccSmrg  progdir=\"\$thisdir/$objdir\"
404488de56ccSmrg
404588de56ccSmrg  if test ! -f \"\$progdir/\$program\" ||
404688de56ccSmrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
404788de56ccSmrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
404888de56ccSmrg
404988de56ccSmrg    file=\"\$\$-\$program\"
405088de56ccSmrg
405188de56ccSmrg    if test ! -d \"\$progdir\"; then
405288de56ccSmrg      $MKDIR \"\$progdir\"
405388de56ccSmrg    else
405488de56ccSmrg      $RM \"\$progdir/\$file\"
405588de56ccSmrg    fi"
405688de56ccSmrg
405788de56ccSmrg	  $ECHO "\
405888de56ccSmrg
405988de56ccSmrg    # relink executable if necessary
406088de56ccSmrg    if test -n \"\$relink_command\"; then
406188de56ccSmrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
406288de56ccSmrg      else
406388de56ccSmrg	$ECHO \"\$relink_command_output\" >&2
406488de56ccSmrg	$RM \"\$progdir/\$file\"
406588de56ccSmrg	exit 1
4066b4ee4795Smrg      fi
406788de56ccSmrg    fi
40681ab64890Smrg
406988de56ccSmrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
407088de56ccSmrg    { $RM \"\$progdir/\$program\";
407188de56ccSmrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
407288de56ccSmrg    $RM \"\$progdir/\$file\"
407388de56ccSmrg  fi"
407488de56ccSmrg	else
407588de56ccSmrg	  $ECHO "\
407688de56ccSmrg  program='$outputname'
407788de56ccSmrg  progdir=\"\$thisdir/$objdir\"
407888de56ccSmrg"
4079b4ee4795Smrg	fi
40801ab64890Smrg
408188de56ccSmrg	$ECHO "\
40821ab64890Smrg
408388de56ccSmrg  if test -f \"\$progdir/\$program\"; then"
40841ab64890Smrg
4085e9fcaa8aSmrg	# fixup the dll searchpath if we need to.
4086e9fcaa8aSmrg	#
4087e9fcaa8aSmrg	# Fix the DLL searchpath if we need to.  Do this before prepending
4088e9fcaa8aSmrg	# to shlibpath, because on Windows, both are PATH and uninstalled
4089e9fcaa8aSmrg	# libraries must come first.
4090e9fcaa8aSmrg	if test -n "$dllsearchpath"; then
4091e9fcaa8aSmrg	  $ECHO "\
4092e9fcaa8aSmrg    # Add the dll search path components to the executable PATH
4093e9fcaa8aSmrg    PATH=$dllsearchpath:\$PATH
4094e9fcaa8aSmrg"
4095e9fcaa8aSmrg	fi
4096e9fcaa8aSmrg
409788de56ccSmrg	# Export our shlibpath_var if we have one.
409888de56ccSmrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
409988de56ccSmrg	  $ECHO "\
410088de56ccSmrg    # Add our own library path to $shlibpath_var
410188de56ccSmrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
410288de56ccSmrg
410388de56ccSmrg    # Some systems cannot cope with colon-terminated $shlibpath_var
410488de56ccSmrg    # The second colon is a workaround for a bug in BeOS R4 sed
4105e9fcaa8aSmrg    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
41061ab64890Smrg
410788de56ccSmrg    export $shlibpath_var
410888de56ccSmrg"
4109b4ee4795Smrg	fi
41101ab64890Smrg
411188de56ccSmrg	$ECHO "\
411288de56ccSmrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
411388de56ccSmrg      # Run the actual program with our arguments.
4114e9fcaa8aSmrg      func_exec_program \${1+\"\$@\"}
411588de56ccSmrg    fi
411688de56ccSmrg  else
411788de56ccSmrg    # The program doesn't exist.
411888de56ccSmrg    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
411988de56ccSmrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
4120e9fcaa8aSmrg    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
412188de56ccSmrg    exit 1
412288de56ccSmrg  fi
412388de56ccSmrgfi\
412488de56ccSmrg"
412588de56ccSmrg}
41261ab64890Smrg
41271ab64890Smrg
412888de56ccSmrg# func_emit_cwrapperexe_src
412988de56ccSmrg# emit the source code for a wrapper executable on stdout
413088de56ccSmrg# Must ONLY be called from within func_mode_link because
413188de56ccSmrg# it depends on a number of variable set therein.
413288de56ccSmrgfunc_emit_cwrapperexe_src ()
413388de56ccSmrg{
413488de56ccSmrg	cat <<EOF
41351ab64890Smrg
413688de56ccSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
413788de56ccSmrg   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
41381ab64890Smrg
413988de56ccSmrg   The $output program cannot be directly executed until all the libtool
414088de56ccSmrg   libraries that it depends on are installed.
41411ab64890Smrg
414288de56ccSmrg   This wrapper executable should never be moved out of the build directory.
414388de56ccSmrg   If it is, it will not operate correctly.
414488de56ccSmrg*/
414588de56ccSmrgEOF
414688de56ccSmrg	    cat <<"EOF"
4147e9fcaa8aSmrg#ifdef _MSC_VER
4148e9fcaa8aSmrg# define _CRT_SECURE_NO_DEPRECATE 1
4149e9fcaa8aSmrg#endif
415088de56ccSmrg#include <stdio.h>
415188de56ccSmrg#include <stdlib.h>
415288de56ccSmrg#ifdef _MSC_VER
415388de56ccSmrg# include <direct.h>
415488de56ccSmrg# include <process.h>
415588de56ccSmrg# include <io.h>
415688de56ccSmrg#else
415788de56ccSmrg# include <unistd.h>
415888de56ccSmrg# include <stdint.h>
415988de56ccSmrg# ifdef __CYGWIN__
416088de56ccSmrg#  include <io.h>
4161e9fcaa8aSmrg# endif
4162e9fcaa8aSmrg#endif
4163e9fcaa8aSmrg#include <malloc.h>
4164e9fcaa8aSmrg#include <stdarg.h>
4165e9fcaa8aSmrg#include <assert.h>
4166e9fcaa8aSmrg#include <string.h>
4167e9fcaa8aSmrg#include <ctype.h>
4168e9fcaa8aSmrg#include <errno.h>
4169e9fcaa8aSmrg#include <fcntl.h>
4170e9fcaa8aSmrg#include <sys/stat.h>
4171e9fcaa8aSmrg
4172e9fcaa8aSmrg/* declarations of non-ANSI functions */
4173e9fcaa8aSmrg#if defined(__MINGW32__)
4174e9fcaa8aSmrg# ifdef __STRICT_ANSI__
4175e9fcaa8aSmrgint _putenv (const char *);
4176e9fcaa8aSmrg# endif
4177e9fcaa8aSmrg#elif defined(__CYGWIN__)
4178e9fcaa8aSmrg# ifdef __STRICT_ANSI__
417988de56ccSmrgchar *realpath (const char *, char *);
418088de56ccSmrgint putenv (char *);
418188de56ccSmrgint setenv (const char *, const char *, int);
418288de56ccSmrg# endif
4183e9fcaa8aSmrg/* #elif defined (other platforms) ... */
4184e9fcaa8aSmrg#endif
4185e9fcaa8aSmrg
4186e9fcaa8aSmrg/* portability defines, excluding path handling macros */
4187e9fcaa8aSmrg#if defined(_MSC_VER)
4188e9fcaa8aSmrg# define setmode _setmode
4189e9fcaa8aSmrg# define stat    _stat
4190e9fcaa8aSmrg# define chmod   _chmod
4191e9fcaa8aSmrg# define getcwd  _getcwd
4192e9fcaa8aSmrg# define putenv  _putenv
4193e9fcaa8aSmrg# define S_IXUSR _S_IEXEC
4194e9fcaa8aSmrg# ifndef _INTPTR_T_DEFINED
4195e9fcaa8aSmrg#  define _INTPTR_T_DEFINED
4196e9fcaa8aSmrg#  define intptr_t int
4197e9fcaa8aSmrg# endif
4198e9fcaa8aSmrg#elif defined(__MINGW32__)
4199e9fcaa8aSmrg# define setmode _setmode
4200e9fcaa8aSmrg# define stat    _stat
4201e9fcaa8aSmrg# define chmod   _chmod
4202e9fcaa8aSmrg# define getcwd  _getcwd
4203e9fcaa8aSmrg# define putenv  _putenv
4204e9fcaa8aSmrg#elif defined(__CYGWIN__)
4205e9fcaa8aSmrg# define HAVE_SETENV
4206e9fcaa8aSmrg# define FOPEN_WB "wb"
4207e9fcaa8aSmrg/* #elif defined (other platforms) ... */
420888de56ccSmrg#endif
42091ab64890Smrg
421088de56ccSmrg#if defined(PATH_MAX)
421188de56ccSmrg# define LT_PATHMAX PATH_MAX
421288de56ccSmrg#elif defined(MAXPATHLEN)
421388de56ccSmrg# define LT_PATHMAX MAXPATHLEN
421488de56ccSmrg#else
421588de56ccSmrg# define LT_PATHMAX 1024
421688de56ccSmrg#endif
42171ab64890Smrg
421888de56ccSmrg#ifndef S_IXOTH
421988de56ccSmrg# define S_IXOTH 0
422088de56ccSmrg#endif
422188de56ccSmrg#ifndef S_IXGRP
422288de56ccSmrg# define S_IXGRP 0
422388de56ccSmrg#endif
42241ab64890Smrg
4225e9fcaa8aSmrg/* path handling portability macros */
422688de56ccSmrg#ifndef DIR_SEPARATOR
422788de56ccSmrg# define DIR_SEPARATOR '/'
422888de56ccSmrg# define PATH_SEPARATOR ':'
422988de56ccSmrg#endif
42301ab64890Smrg
423188de56ccSmrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
423288de56ccSmrg  defined (__OS2__)
423388de56ccSmrg# define HAVE_DOS_BASED_FILE_SYSTEM
423488de56ccSmrg# define FOPEN_WB "wb"
423588de56ccSmrg# ifndef DIR_SEPARATOR_2
423688de56ccSmrg#  define DIR_SEPARATOR_2 '\\'
423788de56ccSmrg# endif
423888de56ccSmrg# ifndef PATH_SEPARATOR_2
423988de56ccSmrg#  define PATH_SEPARATOR_2 ';'
424088de56ccSmrg# endif
424188de56ccSmrg#endif
42421ab64890Smrg
424388de56ccSmrg#ifndef DIR_SEPARATOR_2
424488de56ccSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
424588de56ccSmrg#else /* DIR_SEPARATOR_2 */
424688de56ccSmrg# define IS_DIR_SEPARATOR(ch) \
424788de56ccSmrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
424888de56ccSmrg#endif /* DIR_SEPARATOR_2 */
42491ab64890Smrg
425088de56ccSmrg#ifndef PATH_SEPARATOR_2
425188de56ccSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
425288de56ccSmrg#else /* PATH_SEPARATOR_2 */
425388de56ccSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
425488de56ccSmrg#endif /* PATH_SEPARATOR_2 */
42551ab64890Smrg
425688de56ccSmrg#ifndef FOPEN_WB
425788de56ccSmrg# define FOPEN_WB "w"
425888de56ccSmrg#endif
425988de56ccSmrg#ifndef _O_BINARY
426088de56ccSmrg# define _O_BINARY 0
426188de56ccSmrg#endif
42621ab64890Smrg
426388de56ccSmrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
426488de56ccSmrg#define XFREE(stale) do { \
426588de56ccSmrg  if (stale) { free ((void *) stale); stale = 0; } \
426688de56ccSmrg} while (0)
42671ab64890Smrg
4268e9fcaa8aSmrg#if defined(LT_DEBUGWRAPPER)
4269e9fcaa8aSmrgstatic int lt_debug = 1;
427088de56ccSmrg#else
4271e9fcaa8aSmrgstatic int lt_debug = 0;
427288de56ccSmrg#endif
42731ab64890Smrg
4274e9fcaa8aSmrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
42751ab64890Smrg
427688de56ccSmrgvoid *xmalloc (size_t num);
427788de56ccSmrgchar *xstrdup (const char *string);
427888de56ccSmrgconst char *base_name (const char *name);
427988de56ccSmrgchar *find_executable (const char *wrapper);
428088de56ccSmrgchar *chase_symlinks (const char *pathspec);
428188de56ccSmrgint make_executable (const char *path);
428288de56ccSmrgint check_executable (const char *path);
428388de56ccSmrgchar *strendzap (char *str, const char *pat);
4284e9fcaa8aSmrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
4285e9fcaa8aSmrgvoid lt_fatal (const char *file, int line, const char *message, ...);
4286e9fcaa8aSmrgstatic const char *nonnull (const char *s);
4287e9fcaa8aSmrgstatic const char *nonempty (const char *s);
428888de56ccSmrgvoid lt_setenv (const char *name, const char *value);
428988de56ccSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
429088de56ccSmrgvoid lt_update_exe_path (const char *name, const char *value);
429188de56ccSmrgvoid lt_update_lib_path (const char *name, const char *value);
4292e9fcaa8aSmrgchar **prepare_spawn (char **argv);
4293e9fcaa8aSmrgvoid lt_dump_script (FILE *f);
429488de56ccSmrgEOF
429588de56ccSmrg
429688de56ccSmrg	    cat <<EOF
4297e9fcaa8aSmrgvolatile const char * MAGIC_EXE = "$magic_exe";
429888de56ccSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
429988de56ccSmrgEOF
43001ab64890Smrg
430188de56ccSmrg	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4302e9fcaa8aSmrg              func_to_host_path "$temp_rpath"
430388de56ccSmrg	      cat <<EOF
4304e9fcaa8aSmrgconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
430588de56ccSmrgEOF
430688de56ccSmrg	    else
430788de56ccSmrg	      cat <<"EOF"
430888de56ccSmrgconst char * LIB_PATH_VALUE   = "";
430988de56ccSmrgEOF
4310b4ee4795Smrg	    fi
43111ab64890Smrg
431288de56ccSmrg	    if test -n "$dllsearchpath"; then
4313e9fcaa8aSmrg              func_to_host_path "$dllsearchpath:"
431488de56ccSmrg	      cat <<EOF
431588de56ccSmrgconst char * EXE_PATH_VARNAME = "PATH";
4316e9fcaa8aSmrgconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
4317b4ee4795SmrgEOF
4318b4ee4795Smrg	    else
431988de56ccSmrg	      cat <<"EOF"
432088de56ccSmrgconst char * EXE_PATH_VARNAME = "";
432188de56ccSmrgconst char * EXE_PATH_VALUE   = "";
432288de56ccSmrgEOF
4323b4ee4795Smrg	    fi
432488de56ccSmrg
432588de56ccSmrg	    if test "$fast_install" = yes; then
432688de56ccSmrg	      cat <<EOF
432788de56ccSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
432888de56ccSmrgEOF
4329b4ee4795Smrg	    else
433088de56ccSmrg	      cat <<EOF
433188de56ccSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
433288de56ccSmrgEOF
4333b4ee4795Smrg	    fi
43341ab64890Smrg
43351ab64890Smrg
433688de56ccSmrg	    cat <<"EOF"
43371ab64890Smrg
433888de56ccSmrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
43391ab64890Smrg
434088de56ccSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
434188de56ccSmrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
4342e9fcaa8aSmrgstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
43431ab64890Smrg
434488de56ccSmrgint
434588de56ccSmrgmain (int argc, char *argv[])
434688de56ccSmrg{
434788de56ccSmrg  char **newargz;
434888de56ccSmrg  int  newargc;
434988de56ccSmrg  char *tmp_pathspec;
435088de56ccSmrg  char *actual_cwrapper_path;
435188de56ccSmrg  char *actual_cwrapper_name;
435288de56ccSmrg  char *target_name;
435388de56ccSmrg  char *lt_argv_zero;
435488de56ccSmrg  intptr_t rval = 127;
43551ab64890Smrg
435688de56ccSmrg  int i;
43571ab64890Smrg
435888de56ccSmrg  program_name = (char *) xstrdup (base_name (argv[0]));
4359e9fcaa8aSmrg  newargz = XMALLOC (char *, argc + 1);
43601ab64890Smrg
4361e9fcaa8aSmrg  /* very simple arg parsing; don't want to rely on getopt
4362e9fcaa8aSmrg   * also, copy all non cwrapper options to newargz, except
4363e9fcaa8aSmrg   * argz[0], which is handled differently
4364e9fcaa8aSmrg   */
4365e9fcaa8aSmrg  newargc=0;
436688de56ccSmrg  for (i = 1; i < argc; i++)
436788de56ccSmrg    {
436888de56ccSmrg      if (strcmp (argv[i], dumpscript_opt) == 0)
436988de56ccSmrg	{
437088de56ccSmrgEOF
437188de56ccSmrg	    case "$host" in
437288de56ccSmrg	      *mingw* | *cygwin* )
437388de56ccSmrg		# make stdout use "unix" line endings
437488de56ccSmrg		echo "          setmode(1,_O_BINARY);"
437588de56ccSmrg		;;
437688de56ccSmrg	      esac
43771ab64890Smrg
437888de56ccSmrg	    cat <<"EOF"
4379e9fcaa8aSmrg	  lt_dump_script (stdout);
438088de56ccSmrg	  return 0;
438188de56ccSmrg	}
4382e9fcaa8aSmrg      if (strcmp (argv[i], debug_opt) == 0)
4383e9fcaa8aSmrg	{
4384e9fcaa8aSmrg          lt_debug = 1;
4385e9fcaa8aSmrg          continue;
4386e9fcaa8aSmrg	}
4387e9fcaa8aSmrg      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
4388e9fcaa8aSmrg        {
4389e9fcaa8aSmrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
4390e9fcaa8aSmrg             namespace, but it is not one of the ones we know about and
4391e9fcaa8aSmrg             have already dealt with, above (inluding dump-script), then
4392e9fcaa8aSmrg             report an error. Otherwise, targets might begin to believe
4393e9fcaa8aSmrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
4394e9fcaa8aSmrg             namespace. The first time any user complains about this, we'll
4395e9fcaa8aSmrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
4396e9fcaa8aSmrg             or a configure.ac-settable value.
4397e9fcaa8aSmrg           */
4398e9fcaa8aSmrg          lt_fatal (__FILE__, __LINE__,
4399e9fcaa8aSmrg		    "unrecognized %s option: '%s'",
4400e9fcaa8aSmrg                    ltwrapper_option_prefix, argv[i]);
4401e9fcaa8aSmrg        }
4402e9fcaa8aSmrg      /* otherwise ... */
4403e9fcaa8aSmrg      newargz[++newargc] = xstrdup (argv[i]);
440488de56ccSmrg    }
4405e9fcaa8aSmrg  newargz[++newargc] = NULL;
4406e9fcaa8aSmrg
4407e9fcaa8aSmrgEOF
4408e9fcaa8aSmrg	    cat <<EOF
4409e9fcaa8aSmrg  /* The GNU banner must be the first non-error debug message */
4410e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
4411e9fcaa8aSmrgEOF
4412e9fcaa8aSmrg	    cat <<"EOF"
4413e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
4414e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
44151ab64890Smrg
441688de56ccSmrg  tmp_pathspec = find_executable (argv[0]);
441788de56ccSmrg  if (tmp_pathspec == NULL)
4418e9fcaa8aSmrg    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
4419e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__,
4420e9fcaa8aSmrg                  "(main) found exe (before symlink chase) at: %s\n",
4421e9fcaa8aSmrg		  tmp_pathspec);
442288de56ccSmrg
442388de56ccSmrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
4424e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__,
4425e9fcaa8aSmrg                  "(main) found exe (after symlink chase) at: %s\n",
4426e9fcaa8aSmrg		  actual_cwrapper_path);
442788de56ccSmrg  XFREE (tmp_pathspec);
442888de56ccSmrg
4429e9fcaa8aSmrg  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
443088de56ccSmrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
443188de56ccSmrg
443288de56ccSmrg  /* wrapper name transforms */
443388de56ccSmrg  strendzap (actual_cwrapper_name, ".exe");
443488de56ccSmrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
443588de56ccSmrg  XFREE (actual_cwrapper_name);
443688de56ccSmrg  actual_cwrapper_name = tmp_pathspec;
443788de56ccSmrg  tmp_pathspec = 0;
443888de56ccSmrg
443988de56ccSmrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
444088de56ccSmrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
444188de56ccSmrg  strendzap (target_name, ".exe");
444288de56ccSmrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
444388de56ccSmrg  XFREE (target_name);
444488de56ccSmrg  target_name = tmp_pathspec;
444588de56ccSmrg  tmp_pathspec = 0;
444688de56ccSmrg
4447e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__,
4448e9fcaa8aSmrg		  "(main) libtool target name: %s\n",
4449e9fcaa8aSmrg		  target_name);
445088de56ccSmrgEOF
44511ab64890Smrg
445288de56ccSmrg	    cat <<EOF
445388de56ccSmrg  newargz[0] =
445488de56ccSmrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
445588de56ccSmrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
445688de56ccSmrg  strcpy (newargz[0], actual_cwrapper_path);
445788de56ccSmrg  strcat (newargz[0], "$objdir");
445888de56ccSmrg  strcat (newargz[0], "/");
445988de56ccSmrgEOF
44601ab64890Smrg
446188de56ccSmrg	    cat <<"EOF"
446288de56ccSmrg  /* stop here, and copy so we don't have to do this twice */
446388de56ccSmrg  tmp_pathspec = xstrdup (newargz[0]);
44641ab64890Smrg
446588de56ccSmrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
446688de56ccSmrg  strcat (newargz[0], actual_cwrapper_name);
44671ab64890Smrg
446888de56ccSmrg  /* DO want the lt- prefix here if it exists, so use target_name */
446988de56ccSmrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
447088de56ccSmrg  XFREE (tmp_pathspec);
447188de56ccSmrg  tmp_pathspec = NULL;
447288de56ccSmrgEOF
44731ab64890Smrg
447488de56ccSmrg	    case $host_os in
447588de56ccSmrg	      mingw*)
447688de56ccSmrg	    cat <<"EOF"
447788de56ccSmrg  {
447888de56ccSmrg    char* p;
447988de56ccSmrg    while ((p = strchr (newargz[0], '\\')) != NULL)
448088de56ccSmrg      {
448188de56ccSmrg	*p = '/';
448288de56ccSmrg      }
448388de56ccSmrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
448488de56ccSmrg      {
448588de56ccSmrg	*p = '/';
448688de56ccSmrg      }
448788de56ccSmrg  }
448888de56ccSmrgEOF
448988de56ccSmrg	    ;;
449088de56ccSmrg	    esac
44911ab64890Smrg
449288de56ccSmrg	    cat <<"EOF"
449388de56ccSmrg  XFREE (target_name);
449488de56ccSmrg  XFREE (actual_cwrapper_path);
449588de56ccSmrg  XFREE (actual_cwrapper_name);
44961ab64890Smrg
449788de56ccSmrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
449888de56ccSmrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
4499e9fcaa8aSmrg  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
4500e9fcaa8aSmrg     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
4501e9fcaa8aSmrg     because on Windows, both *_VARNAMEs are PATH but uninstalled
4502e9fcaa8aSmrg     libraries must come first. */
450388de56ccSmrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
4504e9fcaa8aSmrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
45051ab64890Smrg
4506e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
4507e9fcaa8aSmrg		  nonnull (lt_argv_zero));
450888de56ccSmrg  for (i = 0; i < newargc; i++)
450988de56ccSmrg    {
4510e9fcaa8aSmrg      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
4511e9fcaa8aSmrg		      i, nonnull (newargz[i]));
451288de56ccSmrg    }
45131ab64890Smrg
451488de56ccSmrgEOF
45151ab64890Smrg
451688de56ccSmrg	    case $host_os in
451788de56ccSmrg	      mingw*)
451888de56ccSmrg		cat <<"EOF"
451988de56ccSmrg  /* execv doesn't actually work on mingw as expected on unix */
4520e9fcaa8aSmrg  newargz = prepare_spawn (newargz);
452188de56ccSmrg  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
452288de56ccSmrg  if (rval == -1)
452388de56ccSmrg    {
452488de56ccSmrg      /* failed to start process */
4525e9fcaa8aSmrg      lt_debugprintf (__FILE__, __LINE__,
4526e9fcaa8aSmrg		      "(main) failed to launch target \"%s\": %s\n",
4527e9fcaa8aSmrg		      lt_argv_zero, nonnull (strerror (errno)));
452888de56ccSmrg      return 127;
452988de56ccSmrg    }
453088de56ccSmrg  return rval;
453188de56ccSmrgEOF
453288de56ccSmrg		;;
453388de56ccSmrg	      *)
453488de56ccSmrg		cat <<"EOF"
453588de56ccSmrg  execv (lt_argv_zero, newargz);
453688de56ccSmrg  return rval; /* =127, but avoids unused variable warning */
453788de56ccSmrgEOF
453888de56ccSmrg		;;
453988de56ccSmrg	    esac
45401ab64890Smrg
454188de56ccSmrg	    cat <<"EOF"
454288de56ccSmrg}
45431ab64890Smrg
454488de56ccSmrgvoid *
454588de56ccSmrgxmalloc (size_t num)
454688de56ccSmrg{
454788de56ccSmrg  void *p = (void *) malloc (num);
454888de56ccSmrg  if (!p)
4549e9fcaa8aSmrg    lt_fatal (__FILE__, __LINE__, "memory exhausted");
45501ab64890Smrg
455188de56ccSmrg  return p;
455288de56ccSmrg}
45531ab64890Smrg
455488de56ccSmrgchar *
455588de56ccSmrgxstrdup (const char *string)
455688de56ccSmrg{
455788de56ccSmrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
455888de56ccSmrg			  string) : NULL;
455988de56ccSmrg}
45601ab64890Smrg
456188de56ccSmrgconst char *
456288de56ccSmrgbase_name (const char *name)
456388de56ccSmrg{
456488de56ccSmrg  const char *base;
4565b4ee4795Smrg
456688de56ccSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
456788de56ccSmrg  /* Skip over the disk name in MSDOS pathnames. */
456888de56ccSmrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
456988de56ccSmrg    name += 2;
457088de56ccSmrg#endif
4571b4ee4795Smrg
457288de56ccSmrg  for (base = name; *name; name++)
457388de56ccSmrg    if (IS_DIR_SEPARATOR (*name))
457488de56ccSmrg      base = name + 1;
457588de56ccSmrg  return base;
457688de56ccSmrg}
4577b4ee4795Smrg
457888de56ccSmrgint
457988de56ccSmrgcheck_executable (const char *path)
458088de56ccSmrg{
458188de56ccSmrg  struct stat st;
4582b4ee4795Smrg
4583e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
4584e9fcaa8aSmrg                  nonempty (path));
458588de56ccSmrg  if ((!path) || (!*path))
458688de56ccSmrg    return 0;
4587b4ee4795Smrg
458888de56ccSmrg  if ((stat (path, &st) >= 0)
458988de56ccSmrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
459088de56ccSmrg    return 1;
459188de56ccSmrg  else
459288de56ccSmrg    return 0;
459388de56ccSmrg}
45941ab64890Smrg
459588de56ccSmrgint
459688de56ccSmrgmake_executable (const char *path)
459788de56ccSmrg{
459888de56ccSmrg  int rval = 0;
459988de56ccSmrg  struct stat st;
46001ab64890Smrg
4601e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
4602e9fcaa8aSmrg                  nonempty (path));
460388de56ccSmrg  if ((!path) || (!*path))
460488de56ccSmrg    return 0;
46051ab64890Smrg
460688de56ccSmrg  if (stat (path, &st) >= 0)
460788de56ccSmrg    {
460888de56ccSmrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
460988de56ccSmrg    }
461088de56ccSmrg  return rval;
461188de56ccSmrg}
4612b4ee4795Smrg
461388de56ccSmrg/* Searches for the full path of the wrapper.  Returns
461488de56ccSmrg   newly allocated full path name if found, NULL otherwise
461588de56ccSmrg   Does not chase symlinks, even on platforms that support them.
461688de56ccSmrg*/
461788de56ccSmrgchar *
461888de56ccSmrgfind_executable (const char *wrapper)
461988de56ccSmrg{
462088de56ccSmrg  int has_slash = 0;
462188de56ccSmrg  const char *p;
462288de56ccSmrg  const char *p_next;
462388de56ccSmrg  /* static buffer for getcwd */
462488de56ccSmrg  char tmp[LT_PATHMAX + 1];
462588de56ccSmrg  int tmp_len;
462688de56ccSmrg  char *concat_name;
4627b4ee4795Smrg
4628e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
4629e9fcaa8aSmrg                  nonempty (wrapper));
4630b4ee4795Smrg
463188de56ccSmrg  if ((wrapper == NULL) || (*wrapper == '\0'))
463288de56ccSmrg    return NULL;
4633b4ee4795Smrg
463488de56ccSmrg  /* Absolute path? */
463588de56ccSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
463688de56ccSmrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
463788de56ccSmrg    {
463888de56ccSmrg      concat_name = xstrdup (wrapper);
463988de56ccSmrg      if (check_executable (concat_name))
464088de56ccSmrg	return concat_name;
464188de56ccSmrg      XFREE (concat_name);
464288de56ccSmrg    }
464388de56ccSmrg  else
464488de56ccSmrg    {
464588de56ccSmrg#endif
464688de56ccSmrg      if (IS_DIR_SEPARATOR (wrapper[0]))
464788de56ccSmrg	{
464888de56ccSmrg	  concat_name = xstrdup (wrapper);
464988de56ccSmrg	  if (check_executable (concat_name))
465088de56ccSmrg	    return concat_name;
465188de56ccSmrg	  XFREE (concat_name);
465288de56ccSmrg	}
465388de56ccSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
465488de56ccSmrg    }
465588de56ccSmrg#endif
46561ab64890Smrg
465788de56ccSmrg  for (p = wrapper; *p; p++)
465888de56ccSmrg    if (*p == '/')
465988de56ccSmrg      {
466088de56ccSmrg	has_slash = 1;
466188de56ccSmrg	break;
466288de56ccSmrg      }
466388de56ccSmrg  if (!has_slash)
466488de56ccSmrg    {
466588de56ccSmrg      /* no slashes; search PATH */
466688de56ccSmrg      const char *path = getenv ("PATH");
466788de56ccSmrg      if (path != NULL)
466888de56ccSmrg	{
466988de56ccSmrg	  for (p = path; *p; p = p_next)
467088de56ccSmrg	    {
467188de56ccSmrg	      const char *q;
467288de56ccSmrg	      size_t p_len;
467388de56ccSmrg	      for (q = p; *q; q++)
467488de56ccSmrg		if (IS_PATH_SEPARATOR (*q))
467588de56ccSmrg		  break;
467688de56ccSmrg	      p_len = q - p;
467788de56ccSmrg	      p_next = (*q == '\0' ? q : q + 1);
467888de56ccSmrg	      if (p_len == 0)
467988de56ccSmrg		{
468088de56ccSmrg		  /* empty path: current directory */
468188de56ccSmrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
4682e9fcaa8aSmrg		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
4683e9fcaa8aSmrg                              nonnull (strerror (errno)));
468488de56ccSmrg		  tmp_len = strlen (tmp);
468588de56ccSmrg		  concat_name =
468688de56ccSmrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
468788de56ccSmrg		  memcpy (concat_name, tmp, tmp_len);
468888de56ccSmrg		  concat_name[tmp_len] = '/';
468988de56ccSmrg		  strcpy (concat_name + tmp_len + 1, wrapper);
469088de56ccSmrg		}
469188de56ccSmrg	      else
469288de56ccSmrg		{
469388de56ccSmrg		  concat_name =
469488de56ccSmrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
469588de56ccSmrg		  memcpy (concat_name, p, p_len);
469688de56ccSmrg		  concat_name[p_len] = '/';
469788de56ccSmrg		  strcpy (concat_name + p_len + 1, wrapper);
469888de56ccSmrg		}
469988de56ccSmrg	      if (check_executable (concat_name))
470088de56ccSmrg		return concat_name;
470188de56ccSmrg	      XFREE (concat_name);
470288de56ccSmrg	    }
470388de56ccSmrg	}
470488de56ccSmrg      /* not found in PATH; assume curdir */
470588de56ccSmrg    }
470688de56ccSmrg  /* Relative path | not found in path: prepend cwd */
470788de56ccSmrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
4708e9fcaa8aSmrg    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
4709e9fcaa8aSmrg              nonnull (strerror (errno)));
471088de56ccSmrg  tmp_len = strlen (tmp);
471188de56ccSmrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
471288de56ccSmrg  memcpy (concat_name, tmp, tmp_len);
471388de56ccSmrg  concat_name[tmp_len] = '/';
471488de56ccSmrg  strcpy (concat_name + tmp_len + 1, wrapper);
47151ab64890Smrg
471688de56ccSmrg  if (check_executable (concat_name))
471788de56ccSmrg    return concat_name;
471888de56ccSmrg  XFREE (concat_name);
471988de56ccSmrg  return NULL;
472088de56ccSmrg}
47211ab64890Smrg
472288de56ccSmrgchar *
472388de56ccSmrgchase_symlinks (const char *pathspec)
472488de56ccSmrg{
472588de56ccSmrg#ifndef S_ISLNK
472688de56ccSmrg  return xstrdup (pathspec);
472788de56ccSmrg#else
472888de56ccSmrg  char buf[LT_PATHMAX];
472988de56ccSmrg  struct stat s;
473088de56ccSmrg  char *tmp_pathspec = xstrdup (pathspec);
473188de56ccSmrg  char *p;
473288de56ccSmrg  int has_symlinks = 0;
473388de56ccSmrg  while (strlen (tmp_pathspec) && !has_symlinks)
473488de56ccSmrg    {
4735e9fcaa8aSmrg      lt_debugprintf (__FILE__, __LINE__,
4736e9fcaa8aSmrg		      "checking path component for symlinks: %s\n",
4737e9fcaa8aSmrg		      tmp_pathspec);
473888de56ccSmrg      if (lstat (tmp_pathspec, &s) == 0)
473988de56ccSmrg	{
474088de56ccSmrg	  if (S_ISLNK (s.st_mode) != 0)
474188de56ccSmrg	    {
474288de56ccSmrg	      has_symlinks = 1;
474388de56ccSmrg	      break;
474488de56ccSmrg	    }
47451ab64890Smrg
474688de56ccSmrg	  /* search backwards for last DIR_SEPARATOR */
474788de56ccSmrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
474888de56ccSmrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
474988de56ccSmrg	    p--;
475088de56ccSmrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
475188de56ccSmrg	    {
475288de56ccSmrg	      /* no more DIR_SEPARATORS left */
475388de56ccSmrg	      break;
475488de56ccSmrg	    }
475588de56ccSmrg	  *p = '\0';
475688de56ccSmrg	}
475788de56ccSmrg      else
475888de56ccSmrg	{
4759e9fcaa8aSmrg	  lt_fatal (__FILE__, __LINE__,
4760e9fcaa8aSmrg		    "error accessing file \"%s\": %s",
4761e9fcaa8aSmrg		    tmp_pathspec, nonnull (strerror (errno)));
476288de56ccSmrg	}
476388de56ccSmrg    }
476488de56ccSmrg  XFREE (tmp_pathspec);
47651ab64890Smrg
476688de56ccSmrg  if (!has_symlinks)
476788de56ccSmrg    {
476888de56ccSmrg      return xstrdup (pathspec);
476988de56ccSmrg    }
47701ab64890Smrg
477188de56ccSmrg  tmp_pathspec = realpath (pathspec, buf);
477288de56ccSmrg  if (tmp_pathspec == 0)
477388de56ccSmrg    {
4774e9fcaa8aSmrg      lt_fatal (__FILE__, __LINE__,
4775e9fcaa8aSmrg		"could not follow symlinks for %s", pathspec);
477688de56ccSmrg    }
477788de56ccSmrg  return xstrdup (tmp_pathspec);
477888de56ccSmrg#endif
477988de56ccSmrg}
47801ab64890Smrg
478188de56ccSmrgchar *
478288de56ccSmrgstrendzap (char *str, const char *pat)
478388de56ccSmrg{
478488de56ccSmrg  size_t len, patlen;
47851ab64890Smrg
478688de56ccSmrg  assert (str != NULL);
478788de56ccSmrg  assert (pat != NULL);
47881ab64890Smrg
478988de56ccSmrg  len = strlen (str);
479088de56ccSmrg  patlen = strlen (pat);
47911ab64890Smrg
479288de56ccSmrg  if (patlen <= len)
479388de56ccSmrg    {
479488de56ccSmrg      str += len - patlen;
479588de56ccSmrg      if (strcmp (str, pat) == 0)
479688de56ccSmrg	*str = '\0';
479788de56ccSmrg    }
479888de56ccSmrg  return str;
479988de56ccSmrg}
48001ab64890Smrg
4801e9fcaa8aSmrgvoid
4802e9fcaa8aSmrglt_debugprintf (const char *file, int line, const char *fmt, ...)
4803e9fcaa8aSmrg{
4804e9fcaa8aSmrg  va_list args;
4805e9fcaa8aSmrg  if (lt_debug)
4806e9fcaa8aSmrg    {
4807e9fcaa8aSmrg      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
4808e9fcaa8aSmrg      va_start (args, fmt);
4809e9fcaa8aSmrg      (void) vfprintf (stderr, fmt, args);
4810e9fcaa8aSmrg      va_end (args);
4811e9fcaa8aSmrg    }
4812e9fcaa8aSmrg}
4813e9fcaa8aSmrg
481488de56ccSmrgstatic void
4815e9fcaa8aSmrglt_error_core (int exit_status, const char *file,
4816e9fcaa8aSmrg	       int line, const char *mode,
481788de56ccSmrg	       const char *message, va_list ap)
481888de56ccSmrg{
4819e9fcaa8aSmrg  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
482088de56ccSmrg  vfprintf (stderr, message, ap);
482188de56ccSmrg  fprintf (stderr, ".\n");
48221ab64890Smrg
482388de56ccSmrg  if (exit_status >= 0)
482488de56ccSmrg    exit (exit_status);
482588de56ccSmrg}
48261ab64890Smrg
482788de56ccSmrgvoid
4828e9fcaa8aSmrglt_fatal (const char *file, int line, const char *message, ...)
482988de56ccSmrg{
483088de56ccSmrg  va_list ap;
483188de56ccSmrg  va_start (ap, message);
4832e9fcaa8aSmrg  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
483388de56ccSmrg  va_end (ap);
483488de56ccSmrg}
48352e9c7c8cSmrg
4836e9fcaa8aSmrgstatic const char *
4837e9fcaa8aSmrgnonnull (const char *s)
4838e9fcaa8aSmrg{
4839e9fcaa8aSmrg  return s ? s : "(null)";
4840e9fcaa8aSmrg}
4841e9fcaa8aSmrg
4842e9fcaa8aSmrgstatic const char *
4843e9fcaa8aSmrgnonempty (const char *s)
4844e9fcaa8aSmrg{
4845e9fcaa8aSmrg  return (s && !*s) ? "(empty)" : nonnull (s);
4846e9fcaa8aSmrg}
4847e9fcaa8aSmrg
484888de56ccSmrgvoid
484988de56ccSmrglt_setenv (const char *name, const char *value)
485088de56ccSmrg{
4851e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__,
4852e9fcaa8aSmrg		  "(lt_setenv) setting '%s' to '%s'\n",
4853e9fcaa8aSmrg                  nonnull (name), nonnull (value));
485488de56ccSmrg  {
485588de56ccSmrg#ifdef HAVE_SETENV
485688de56ccSmrg    /* always make a copy, for consistency with !HAVE_SETENV */
485788de56ccSmrg    char *str = xstrdup (value);
485888de56ccSmrg    setenv (name, str, 1);
485988de56ccSmrg#else
486088de56ccSmrg    int len = strlen (name) + 1 + strlen (value) + 1;
486188de56ccSmrg    char *str = XMALLOC (char, len);
486288de56ccSmrg    sprintf (str, "%s=%s", name, value);
486388de56ccSmrg    if (putenv (str) != EXIT_SUCCESS)
486488de56ccSmrg      {
486588de56ccSmrg        XFREE (str);
486688de56ccSmrg      }
486788de56ccSmrg#endif
486888de56ccSmrg  }
486988de56ccSmrg}
48701ab64890Smrg
487188de56ccSmrgchar *
487288de56ccSmrglt_extend_str (const char *orig_value, const char *add, int to_end)
487388de56ccSmrg{
487488de56ccSmrg  char *new_value;
487588de56ccSmrg  if (orig_value && *orig_value)
487688de56ccSmrg    {
487788de56ccSmrg      int orig_value_len = strlen (orig_value);
487888de56ccSmrg      int add_len = strlen (add);
487988de56ccSmrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
488088de56ccSmrg      if (to_end)
488188de56ccSmrg        {
488288de56ccSmrg          strcpy (new_value, orig_value);
488388de56ccSmrg          strcpy (new_value + orig_value_len, add);
488488de56ccSmrg        }
488588de56ccSmrg      else
488688de56ccSmrg        {
488788de56ccSmrg          strcpy (new_value, add);
488888de56ccSmrg          strcpy (new_value + add_len, orig_value);
488988de56ccSmrg        }
489088de56ccSmrg    }
489188de56ccSmrg  else
489288de56ccSmrg    {
489388de56ccSmrg      new_value = xstrdup (add);
489488de56ccSmrg    }
489588de56ccSmrg  return new_value;
489688de56ccSmrg}
48971ab64890Smrg
489888de56ccSmrgvoid
489988de56ccSmrglt_update_exe_path (const char *name, const char *value)
490088de56ccSmrg{
4901e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__,
4902e9fcaa8aSmrg		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
4903e9fcaa8aSmrg                  nonnull (name), nonnull (value));
49041ab64890Smrg
490588de56ccSmrg  if (name && *name && value && *value)
490688de56ccSmrg    {
490788de56ccSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
490888de56ccSmrg      /* some systems can't cope with a ':'-terminated path #' */
490988de56ccSmrg      int len = strlen (new_value);
491088de56ccSmrg      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
491188de56ccSmrg        {
491288de56ccSmrg          new_value[len-1] = '\0';
491388de56ccSmrg        }
491488de56ccSmrg      lt_setenv (name, new_value);
491588de56ccSmrg      XFREE (new_value);
491688de56ccSmrg    }
491788de56ccSmrg}
49181ab64890Smrg
491988de56ccSmrgvoid
492088de56ccSmrglt_update_lib_path (const char *name, const char *value)
492188de56ccSmrg{
4922e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__,
4923e9fcaa8aSmrg		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
4924e9fcaa8aSmrg                  nonnull (name), nonnull (value));
49251ab64890Smrg
492688de56ccSmrg  if (name && *name && value && *value)
492788de56ccSmrg    {
492888de56ccSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
492988de56ccSmrg      lt_setenv (name, new_value);
493088de56ccSmrg      XFREE (new_value);
493188de56ccSmrg    }
493288de56ccSmrg}
49331ab64890Smrg
4934e9fcaa8aSmrgEOF
4935e9fcaa8aSmrg	    case $host_os in
4936e9fcaa8aSmrg	      mingw*)
4937e9fcaa8aSmrg		cat <<"EOF"
4938e9fcaa8aSmrg
4939e9fcaa8aSmrg/* Prepares an argument vector before calling spawn().
4940e9fcaa8aSmrg   Note that spawn() does not by itself call the command interpreter
4941e9fcaa8aSmrg     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
4942e9fcaa8aSmrg      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
4943e9fcaa8aSmrg         GetVersionEx(&v);
4944e9fcaa8aSmrg         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
4945e9fcaa8aSmrg      }) ? "cmd.exe" : "command.com").
4946e9fcaa8aSmrg   Instead it simply concatenates the arguments, separated by ' ', and calls
4947e9fcaa8aSmrg   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
4948e9fcaa8aSmrg   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
4949e9fcaa8aSmrg   special way:
4950e9fcaa8aSmrg   - Space and tab are interpreted as delimiters. They are not treated as
4951e9fcaa8aSmrg     delimiters if they are surrounded by double quotes: "...".
4952e9fcaa8aSmrg   - Unescaped double quotes are removed from the input. Their only effect is
4953e9fcaa8aSmrg     that within double quotes, space and tab are treated like normal
4954e9fcaa8aSmrg     characters.
4955e9fcaa8aSmrg   - Backslashes not followed by double quotes are not special.
4956e9fcaa8aSmrg   - But 2*n+1 backslashes followed by a double quote become
4957e9fcaa8aSmrg     n backslashes followed by a double quote (n >= 0):
4958e9fcaa8aSmrg       \" -> "
4959e9fcaa8aSmrg       \\\" -> \"
4960e9fcaa8aSmrg       \\\\\" -> \\"
4961e9fcaa8aSmrg */
4962e9fcaa8aSmrg#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"
4963e9fcaa8aSmrg#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"
4964e9fcaa8aSmrgchar **
4965e9fcaa8aSmrgprepare_spawn (char **argv)
4966e9fcaa8aSmrg{
4967e9fcaa8aSmrg  size_t argc;
4968e9fcaa8aSmrg  char **new_argv;
4969e9fcaa8aSmrg  size_t i;
4970e9fcaa8aSmrg
4971e9fcaa8aSmrg  /* Count number of arguments.  */
4972e9fcaa8aSmrg  for (argc = 0; argv[argc] != NULL; argc++)
4973e9fcaa8aSmrg    ;
4974e9fcaa8aSmrg
4975e9fcaa8aSmrg  /* Allocate new argument vector.  */
4976e9fcaa8aSmrg  new_argv = XMALLOC (char *, argc + 1);
4977e9fcaa8aSmrg
4978e9fcaa8aSmrg  /* Put quoted arguments into the new argument vector.  */
4979e9fcaa8aSmrg  for (i = 0; i < argc; i++)
4980e9fcaa8aSmrg    {
4981e9fcaa8aSmrg      const char *string = argv[i];
4982e9fcaa8aSmrg
4983e9fcaa8aSmrg      if (string[0] == '\0')
4984e9fcaa8aSmrg	new_argv[i] = xstrdup ("\"\"");
4985e9fcaa8aSmrg      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
4986e9fcaa8aSmrg	{
4987e9fcaa8aSmrg	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
4988e9fcaa8aSmrg	  size_t length;
4989e9fcaa8aSmrg	  unsigned int backslashes;
4990e9fcaa8aSmrg	  const char *s;
4991e9fcaa8aSmrg	  char *quoted_string;
4992e9fcaa8aSmrg	  char *p;
4993e9fcaa8aSmrg
4994e9fcaa8aSmrg	  length = 0;
4995e9fcaa8aSmrg	  backslashes = 0;
4996e9fcaa8aSmrg	  if (quote_around)
4997e9fcaa8aSmrg	    length++;
4998e9fcaa8aSmrg	  for (s = string; *s != '\0'; s++)
4999e9fcaa8aSmrg	    {
5000e9fcaa8aSmrg	      char c = *s;
5001e9fcaa8aSmrg	      if (c == '"')
5002e9fcaa8aSmrg		length += backslashes + 1;
5003e9fcaa8aSmrg	      length++;
5004e9fcaa8aSmrg	      if (c == '\\')
5005e9fcaa8aSmrg		backslashes++;
5006e9fcaa8aSmrg	      else
5007e9fcaa8aSmrg		backslashes = 0;
5008e9fcaa8aSmrg	    }
5009e9fcaa8aSmrg	  if (quote_around)
5010e9fcaa8aSmrg	    length += backslashes + 1;
5011e9fcaa8aSmrg
5012e9fcaa8aSmrg	  quoted_string = XMALLOC (char, length + 1);
5013e9fcaa8aSmrg
5014e9fcaa8aSmrg	  p = quoted_string;
5015e9fcaa8aSmrg	  backslashes = 0;
5016e9fcaa8aSmrg	  if (quote_around)
5017e9fcaa8aSmrg	    *p++ = '"';
5018e9fcaa8aSmrg	  for (s = string; *s != '\0'; s++)
5019e9fcaa8aSmrg	    {
5020e9fcaa8aSmrg	      char c = *s;
5021e9fcaa8aSmrg	      if (c == '"')
5022e9fcaa8aSmrg		{
5023e9fcaa8aSmrg		  unsigned int j;
5024e9fcaa8aSmrg		  for (j = backslashes + 1; j > 0; j--)
5025e9fcaa8aSmrg		    *p++ = '\\';
5026e9fcaa8aSmrg		}
5027e9fcaa8aSmrg	      *p++ = c;
5028e9fcaa8aSmrg	      if (c == '\\')
5029e9fcaa8aSmrg		backslashes++;
5030e9fcaa8aSmrg	      else
5031e9fcaa8aSmrg		backslashes = 0;
5032e9fcaa8aSmrg	    }
5033e9fcaa8aSmrg	  if (quote_around)
5034e9fcaa8aSmrg	    {
5035e9fcaa8aSmrg	      unsigned int j;
5036e9fcaa8aSmrg	      for (j = backslashes; j > 0; j--)
5037e9fcaa8aSmrg		*p++ = '\\';
5038e9fcaa8aSmrg	      *p++ = '"';
5039e9fcaa8aSmrg	    }
5040e9fcaa8aSmrg	  *p = '\0';
5041e9fcaa8aSmrg
5042e9fcaa8aSmrg	  new_argv[i] = quoted_string;
5043e9fcaa8aSmrg	}
5044e9fcaa8aSmrg      else
5045e9fcaa8aSmrg	new_argv[i] = (char *) string;
5046e9fcaa8aSmrg    }
5047e9fcaa8aSmrg  new_argv[argc] = NULL;
5048e9fcaa8aSmrg
5049e9fcaa8aSmrg  return new_argv;
5050e9fcaa8aSmrg}
5051e9fcaa8aSmrgEOF
5052e9fcaa8aSmrg		;;
5053e9fcaa8aSmrg	    esac
5054e9fcaa8aSmrg
5055e9fcaa8aSmrg            cat <<"EOF"
5056e9fcaa8aSmrgvoid lt_dump_script (FILE* f)
5057e9fcaa8aSmrg{
5058e9fcaa8aSmrgEOF
5059e9fcaa8aSmrg	    func_emit_wrapper yes |
5060e9fcaa8aSmrg              $SED -e 's/\([\\"]\)/\\\1/g' \
5061e9fcaa8aSmrg	           -e 's/^/  fputs ("/' -e 's/$/\\n", f);/'
50621ab64890Smrg
5063e9fcaa8aSmrg            cat <<"EOF"
5064e9fcaa8aSmrg}
506588de56ccSmrgEOF
506688de56ccSmrg}
506788de56ccSmrg# end: func_emit_cwrapperexe_src
50681ab64890Smrg
5069e9fcaa8aSmrg# func_win32_import_lib_p ARG
5070e9fcaa8aSmrg# True if ARG is an import lib, as indicated by $file_magic_cmd
5071e9fcaa8aSmrgfunc_win32_import_lib_p ()
5072e9fcaa8aSmrg{
5073e9fcaa8aSmrg    $opt_debug
5074e9fcaa8aSmrg    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
5075e9fcaa8aSmrg    *import*) : ;;
5076e9fcaa8aSmrg    *) false ;;
5077e9fcaa8aSmrg    esac
5078e9fcaa8aSmrg}
5079e9fcaa8aSmrg
508088de56ccSmrg# func_mode_link arg...
508188de56ccSmrgfunc_mode_link ()
508288de56ccSmrg{
508388de56ccSmrg    $opt_debug
508488de56ccSmrg    case $host in
508588de56ccSmrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
508688de56ccSmrg      # It is impossible to link a dll without this setting, and
508788de56ccSmrg      # we shouldn't force the makefile maintainer to figure out
508888de56ccSmrg      # which system we are compiling for in order to pass an extra
508988de56ccSmrg      # flag for every libtool invocation.
509088de56ccSmrg      # allow_undefined=no
50911ab64890Smrg
509288de56ccSmrg      # FIXME: Unfortunately, there are problems with the above when trying
509388de56ccSmrg      # to make a dll which has undefined symbols, in which case not
509488de56ccSmrg      # even a static library is built.  For now, we need to specify
509588de56ccSmrg      # -no-undefined on the libtool link line when we can be certain
509688de56ccSmrg      # that all symbols are satisfied, otherwise we get a static library.
509788de56ccSmrg      allow_undefined=yes
509888de56ccSmrg      ;;
509988de56ccSmrg    *)
510088de56ccSmrg      allow_undefined=yes
510188de56ccSmrg      ;;
510288de56ccSmrg    esac
510388de56ccSmrg    libtool_args=$nonopt
510488de56ccSmrg    base_compile="$nonopt $@"
510588de56ccSmrg    compile_command=$nonopt
510688de56ccSmrg    finalize_command=$nonopt
51071ab64890Smrg
510888de56ccSmrg    compile_rpath=
510988de56ccSmrg    finalize_rpath=
511088de56ccSmrg    compile_shlibpath=
511188de56ccSmrg    finalize_shlibpath=
511288de56ccSmrg    convenience=
511388de56ccSmrg    old_convenience=
511488de56ccSmrg    deplibs=
511588de56ccSmrg    old_deplibs=
511688de56ccSmrg    compiler_flags=
511788de56ccSmrg    linker_flags=
511888de56ccSmrg    dllsearchpath=
511988de56ccSmrg    lib_search_path=`pwd`
512088de56ccSmrg    inst_prefix_dir=
512188de56ccSmrg    new_inherited_linker_flags=
51221ab64890Smrg
512388de56ccSmrg    avoid_version=no
5124e9fcaa8aSmrg    bindir=
512588de56ccSmrg    dlfiles=
512688de56ccSmrg    dlprefiles=
512788de56ccSmrg    dlself=no
512888de56ccSmrg    export_dynamic=no
512988de56ccSmrg    export_symbols=
513088de56ccSmrg    export_symbols_regex=
513188de56ccSmrg    generated=
513288de56ccSmrg    libobjs=
513388de56ccSmrg    ltlibs=
513488de56ccSmrg    module=no
513588de56ccSmrg    no_install=no
513688de56ccSmrg    objs=
513788de56ccSmrg    non_pic_objects=
513888de56ccSmrg    precious_files_regex=
513988de56ccSmrg    prefer_static_libs=no
514088de56ccSmrg    preload=no
514188de56ccSmrg    prev=
514288de56ccSmrg    prevarg=
514388de56ccSmrg    release=
514488de56ccSmrg    rpath=
514588de56ccSmrg    xrpath=
514688de56ccSmrg    perm_rpath=
514788de56ccSmrg    temp_rpath=
514888de56ccSmrg    thread_safe=no
514988de56ccSmrg    vinfo=
515088de56ccSmrg    vinfo_number=no
515188de56ccSmrg    weak_libs=
515288de56ccSmrg    single_module="${wl}-single_module"
515388de56ccSmrg    func_infer_tag $base_compile
515488de56ccSmrg
515588de56ccSmrg    # We need to know -static, to get the right output filenames.
515688de56ccSmrg    for arg
515788de56ccSmrg    do
515888de56ccSmrg      case $arg in
515988de56ccSmrg      -shared)
516088de56ccSmrg	test "$build_libtool_libs" != yes && \
516188de56ccSmrg	  func_fatal_configuration "can not build a shared library"
516288de56ccSmrg	build_old_libs=no
516388de56ccSmrg	break
516488de56ccSmrg	;;
516588de56ccSmrg      -all-static | -static | -static-libtool-libs)
516688de56ccSmrg	case $arg in
516788de56ccSmrg	-all-static)
516888de56ccSmrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
516988de56ccSmrg	    func_warning "complete static linking is impossible in this configuration"
517088de56ccSmrg	  fi
517188de56ccSmrg	  if test -n "$link_static_flag"; then
517288de56ccSmrg	    dlopen_self=$dlopen_self_static
517388de56ccSmrg	  fi
517488de56ccSmrg	  prefer_static_libs=yes
517588de56ccSmrg	  ;;
517688de56ccSmrg	-static)
517788de56ccSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
517888de56ccSmrg	    dlopen_self=$dlopen_self_static
517988de56ccSmrg	  fi
518088de56ccSmrg	  prefer_static_libs=built
518188de56ccSmrg	  ;;
518288de56ccSmrg	-static-libtool-libs)
518388de56ccSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
518488de56ccSmrg	    dlopen_self=$dlopen_self_static
5185b4ee4795Smrg	  fi
518688de56ccSmrg	  prefer_static_libs=yes
518788de56ccSmrg	  ;;
518888de56ccSmrg	esac
518988de56ccSmrg	build_libtool_libs=no
519088de56ccSmrg	build_old_libs=yes
519188de56ccSmrg	break
519288de56ccSmrg	;;
519388de56ccSmrg      esac
519488de56ccSmrg    done
51951ab64890Smrg
519688de56ccSmrg    # See if our shared archives depend on static archives.
519788de56ccSmrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
51981ab64890Smrg
519988de56ccSmrg    # Go through the arguments, transforming them on the way.
520088de56ccSmrg    while test "$#" -gt 0; do
520188de56ccSmrg      arg="$1"
520288de56ccSmrg      shift
520388de56ccSmrg      func_quote_for_eval "$arg"
520488de56ccSmrg      qarg=$func_quote_for_eval_unquoted_result
520588de56ccSmrg      func_append libtool_args " $func_quote_for_eval_result"
52061ab64890Smrg
520788de56ccSmrg      # If the previous option needs an argument, assign it.
520888de56ccSmrg      if test -n "$prev"; then
520988de56ccSmrg	case $prev in
521088de56ccSmrg	output)
521188de56ccSmrg	  func_append compile_command " @OUTPUT@"
521288de56ccSmrg	  func_append finalize_command " @OUTPUT@"
521388de56ccSmrg	  ;;
521488de56ccSmrg	esac
52151ab64890Smrg
521688de56ccSmrg	case $prev in
5217e9fcaa8aSmrg	bindir)
5218e9fcaa8aSmrg	  bindir="$arg"
5219e9fcaa8aSmrg	  prev=
5220e9fcaa8aSmrg	  continue
5221e9fcaa8aSmrg	  ;;
522288de56ccSmrg	dlfiles|dlprefiles)
522388de56ccSmrg	  if test "$preload" = no; then
522488de56ccSmrg	    # Add the symbol object into the linking commands.
522588de56ccSmrg	    func_append compile_command " @SYMFILE@"
522688de56ccSmrg	    func_append finalize_command " @SYMFILE@"
522788de56ccSmrg	    preload=yes
522888de56ccSmrg	  fi
522988de56ccSmrg	  case $arg in
523088de56ccSmrg	  *.la | *.lo) ;;  # We handle these cases below.
523188de56ccSmrg	  force)
523288de56ccSmrg	    if test "$dlself" = no; then
523388de56ccSmrg	      dlself=needless
523488de56ccSmrg	      export_dynamic=yes
523588de56ccSmrg	    fi
523688de56ccSmrg	    prev=
523788de56ccSmrg	    continue
523888de56ccSmrg	    ;;
523988de56ccSmrg	  self)
524088de56ccSmrg	    if test "$prev" = dlprefiles; then
524188de56ccSmrg	      dlself=yes
524288de56ccSmrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
524388de56ccSmrg	      dlself=yes
5244b4ee4795Smrg	    else
524588de56ccSmrg	      dlself=needless
524688de56ccSmrg	      export_dynamic=yes
5247b4ee4795Smrg	    fi
524888de56ccSmrg	    prev=
524988de56ccSmrg	    continue
525088de56ccSmrg	    ;;
525188de56ccSmrg	  *)
525288de56ccSmrg	    if test "$prev" = dlfiles; then
5253e9fcaa8aSmrg	      func_append dlfiles " $arg"
5254b4ee4795Smrg	    else
5255e9fcaa8aSmrg	      func_append dlprefiles " $arg"
5256b4ee4795Smrg	    fi
525788de56ccSmrg	    prev=
525888de56ccSmrg	    continue
525988de56ccSmrg	    ;;
526088de56ccSmrg	  esac
526188de56ccSmrg	  ;;
526288de56ccSmrg	expsyms)
526388de56ccSmrg	  export_symbols="$arg"
526488de56ccSmrg	  test -f "$arg" \
526588de56ccSmrg	    || func_fatal_error "symbol file \`$arg' does not exist"
526688de56ccSmrg	  prev=
526788de56ccSmrg	  continue
526888de56ccSmrg	  ;;
526988de56ccSmrg	expsyms_regex)
527088de56ccSmrg	  export_symbols_regex="$arg"
527188de56ccSmrg	  prev=
527288de56ccSmrg	  continue
527388de56ccSmrg	  ;;
527488de56ccSmrg	framework)
5275b4ee4795Smrg	  case $host in
527688de56ccSmrg	    *-*-darwin*)
527788de56ccSmrg	      case "$deplibs " in
527888de56ccSmrg		*" $qarg.ltframework "*) ;;
5279e9fcaa8aSmrg		*) func_append deplibs " $qarg.ltframework" # this is fixed later
528088de56ccSmrg		   ;;
528188de56ccSmrg	      esac
528288de56ccSmrg	      ;;
5283b4ee4795Smrg	  esac
528488de56ccSmrg	  prev=
528588de56ccSmrg	  continue
5286b4ee4795Smrg	  ;;
528788de56ccSmrg	inst_prefix)
528888de56ccSmrg	  inst_prefix_dir="$arg"
528988de56ccSmrg	  prev=
529088de56ccSmrg	  continue
5291b4ee4795Smrg	  ;;
529288de56ccSmrg	objectlist)
529388de56ccSmrg	  if test -f "$arg"; then
529488de56ccSmrg	    save_arg=$arg
529588de56ccSmrg	    moreargs=
529688de56ccSmrg	    for fil in `cat "$save_arg"`
529788de56ccSmrg	    do
5298e9fcaa8aSmrg#	      func_append moreargs " $fil"
529988de56ccSmrg	      arg=$fil
530088de56ccSmrg	      # A libtool-controlled object.
53012e9c7c8cSmrg
530288de56ccSmrg	      # Check to see that this really is a libtool object.
530388de56ccSmrg	      if func_lalib_unsafe_p "$arg"; then
530488de56ccSmrg		pic_object=
530588de56ccSmrg		non_pic_object=
53062e9c7c8cSmrg
530788de56ccSmrg		# Read the .lo file
530888de56ccSmrg		func_source "$arg"
53092e9c7c8cSmrg
531088de56ccSmrg		if test -z "$pic_object" ||
531188de56ccSmrg		   test -z "$non_pic_object" ||
531288de56ccSmrg		   test "$pic_object" = none &&
531388de56ccSmrg		   test "$non_pic_object" = none; then
531488de56ccSmrg		  func_fatal_error "cannot find name of object for \`$arg'"
531588de56ccSmrg		fi
53162e9c7c8cSmrg
531788de56ccSmrg		# Extract subdirectory from the argument.
531888de56ccSmrg		func_dirname "$arg" "/" ""
531988de56ccSmrg		xdir="$func_dirname_result"
53202e9c7c8cSmrg
532188de56ccSmrg		if test "$pic_object" != none; then
532288de56ccSmrg		  # Prepend the subdirectory the object is found in.
532388de56ccSmrg		  pic_object="$xdir$pic_object"
53242e9c7c8cSmrg
532588de56ccSmrg		  if test "$prev" = dlfiles; then
532688de56ccSmrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5327e9fcaa8aSmrg		      func_append dlfiles " $pic_object"
532888de56ccSmrg		      prev=
532988de56ccSmrg		      continue
533088de56ccSmrg		    else
533188de56ccSmrg		      # If libtool objects are unsupported, then we need to preload.
533288de56ccSmrg		      prev=dlprefiles
533388de56ccSmrg		    fi
533488de56ccSmrg		  fi
53352e9c7c8cSmrg
533688de56ccSmrg		  # CHECK ME:  I think I busted this.  -Ossama
533788de56ccSmrg		  if test "$prev" = dlprefiles; then
533888de56ccSmrg		    # Preload the old-style object.
5339e9fcaa8aSmrg		    func_append dlprefiles " $pic_object"
534088de56ccSmrg		    prev=
534188de56ccSmrg		  fi
53422e9c7c8cSmrg
534388de56ccSmrg		  # A PIC object.
534488de56ccSmrg		  func_append libobjs " $pic_object"
534588de56ccSmrg		  arg="$pic_object"
534688de56ccSmrg		fi
53472e9c7c8cSmrg
534888de56ccSmrg		# Non-PIC object.
534988de56ccSmrg		if test "$non_pic_object" != none; then
535088de56ccSmrg		  # Prepend the subdirectory the object is found in.
535188de56ccSmrg		  non_pic_object="$xdir$non_pic_object"
53522e9c7c8cSmrg
535388de56ccSmrg		  # A standard non-PIC object
535488de56ccSmrg		  func_append non_pic_objects " $non_pic_object"
535588de56ccSmrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
535688de56ccSmrg		    arg="$non_pic_object"
535788de56ccSmrg		  fi
535888de56ccSmrg		else
535988de56ccSmrg		  # If the PIC object exists, use it instead.
536088de56ccSmrg		  # $xdir was prepended to $pic_object above.
536188de56ccSmrg		  non_pic_object="$pic_object"
536288de56ccSmrg		  func_append non_pic_objects " $non_pic_object"
536388de56ccSmrg		fi
536488de56ccSmrg	      else
536588de56ccSmrg		# Only an error if not doing a dry-run.
536688de56ccSmrg		if $opt_dry_run; then
536788de56ccSmrg		  # Extract subdirectory from the argument.
536888de56ccSmrg		  func_dirname "$arg" "/" ""
536988de56ccSmrg		  xdir="$func_dirname_result"
537088de56ccSmrg
537188de56ccSmrg		  func_lo2o "$arg"
537288de56ccSmrg		  pic_object=$xdir$objdir/$func_lo2o_result
537388de56ccSmrg		  non_pic_object=$xdir$func_lo2o_result
537488de56ccSmrg		  func_append libobjs " $pic_object"
537588de56ccSmrg		  func_append non_pic_objects " $non_pic_object"
537688de56ccSmrg	        else
537788de56ccSmrg		  func_fatal_error "\`$arg' is not a valid libtool object"
537888de56ccSmrg		fi
537988de56ccSmrg	      fi
538088de56ccSmrg	    done
5381b4ee4795Smrg	  else
538288de56ccSmrg	    func_fatal_error "link input file \`$arg' does not exist"
5383b4ee4795Smrg	  fi
538488de56ccSmrg	  arg=$save_arg
538588de56ccSmrg	  prev=
538688de56ccSmrg	  continue
538788de56ccSmrg	  ;;
538888de56ccSmrg	precious_regex)
538988de56ccSmrg	  precious_files_regex="$arg"
539088de56ccSmrg	  prev=
539188de56ccSmrg	  continue
539288de56ccSmrg	  ;;
539388de56ccSmrg	release)
539488de56ccSmrg	  release="-$arg"
539588de56ccSmrg	  prev=
539688de56ccSmrg	  continue
539788de56ccSmrg	  ;;
539888de56ccSmrg	rpath | xrpath)
539988de56ccSmrg	  # We need an absolute path.
540088de56ccSmrg	  case $arg in
540188de56ccSmrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
540288de56ccSmrg	  *)
540388de56ccSmrg	    func_fatal_error "only absolute run-paths are allowed"
540488de56ccSmrg	    ;;
540588de56ccSmrg	  esac
540688de56ccSmrg	  if test "$prev" = rpath; then
540788de56ccSmrg	    case "$rpath " in
540888de56ccSmrg	    *" $arg "*) ;;
5409e9fcaa8aSmrg	    *) func_append rpath " $arg" ;;
541088de56ccSmrg	    esac
5411b4ee4795Smrg	  else
541288de56ccSmrg	    case "$xrpath " in
541388de56ccSmrg	    *" $arg "*) ;;
5414e9fcaa8aSmrg	    *) func_append xrpath " $arg" ;;
541588de56ccSmrg	    esac
5416b4ee4795Smrg	  fi
541788de56ccSmrg	  prev=
541888de56ccSmrg	  continue
541988de56ccSmrg	  ;;
542088de56ccSmrg	shrext)
542188de56ccSmrg	  shrext_cmds="$arg"
542288de56ccSmrg	  prev=
542388de56ccSmrg	  continue
542488de56ccSmrg	  ;;
542588de56ccSmrg	weak)
5426e9fcaa8aSmrg	  func_append weak_libs " $arg"
542788de56ccSmrg	  prev=
542888de56ccSmrg	  continue
542988de56ccSmrg	  ;;
543088de56ccSmrg	xcclinker)
5431e9fcaa8aSmrg	  func_append linker_flags " $qarg"
5432e9fcaa8aSmrg	  func_append compiler_flags " $qarg"
543388de56ccSmrg	  prev=
543488de56ccSmrg	  func_append compile_command " $qarg"
543588de56ccSmrg	  func_append finalize_command " $qarg"
543688de56ccSmrg	  continue
543788de56ccSmrg	  ;;
543888de56ccSmrg	xcompiler)
5439e9fcaa8aSmrg	  func_append compiler_flags " $qarg"
544088de56ccSmrg	  prev=
544188de56ccSmrg	  func_append compile_command " $qarg"
544288de56ccSmrg	  func_append finalize_command " $qarg"
544388de56ccSmrg	  continue
544488de56ccSmrg	  ;;
544588de56ccSmrg	xlinker)
5446e9fcaa8aSmrg	  func_append linker_flags " $qarg"
5447e9fcaa8aSmrg	  func_append compiler_flags " $wl$qarg"
544888de56ccSmrg	  prev=
544988de56ccSmrg	  func_append compile_command " $wl$qarg"
545088de56ccSmrg	  func_append finalize_command " $wl$qarg"
545188de56ccSmrg	  continue
545288de56ccSmrg	  ;;
545388de56ccSmrg	*)
545488de56ccSmrg	  eval "$prev=\"\$arg\""
545588de56ccSmrg	  prev=
545688de56ccSmrg	  continue
545788de56ccSmrg	  ;;
54582e9c7c8cSmrg	esac
545988de56ccSmrg      fi # test -n "$prev"
54602e9c7c8cSmrg
546188de56ccSmrg      prevarg="$arg"
54622e9c7c8cSmrg
546388de56ccSmrg      case $arg in
546488de56ccSmrg      -all-static)
546588de56ccSmrg	if test -n "$link_static_flag"; then
546688de56ccSmrg	  # See comment for -static flag below, for more details.
546788de56ccSmrg	  func_append compile_command " $link_static_flag"
546888de56ccSmrg	  func_append finalize_command " $link_static_flag"
546988de56ccSmrg	fi
547088de56ccSmrg	continue
547188de56ccSmrg	;;
54722e9c7c8cSmrg
547388de56ccSmrg      -allow-undefined)
547488de56ccSmrg	# FIXME: remove this flag sometime in the future.
547588de56ccSmrg	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
547688de56ccSmrg	;;
54772e9c7c8cSmrg
547888de56ccSmrg      -avoid-version)
547988de56ccSmrg	avoid_version=yes
548088de56ccSmrg	continue
548188de56ccSmrg	;;
54822e9c7c8cSmrg
5483e9fcaa8aSmrg      -bindir)
5484e9fcaa8aSmrg	prev=bindir
5485e9fcaa8aSmrg	continue
5486e9fcaa8aSmrg	;;
5487e9fcaa8aSmrg
548888de56ccSmrg      -dlopen)
548988de56ccSmrg	prev=dlfiles
549088de56ccSmrg	continue
549188de56ccSmrg	;;
54922e9c7c8cSmrg
549388de56ccSmrg      -dlpreopen)
549488de56ccSmrg	prev=dlprefiles
549588de56ccSmrg	continue
549688de56ccSmrg	;;
54972e9c7c8cSmrg
549888de56ccSmrg      -export-dynamic)
549988de56ccSmrg	export_dynamic=yes
550088de56ccSmrg	continue
550188de56ccSmrg	;;
55022e9c7c8cSmrg
550388de56ccSmrg      -export-symbols | -export-symbols-regex)
550488de56ccSmrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
550588de56ccSmrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
550688de56ccSmrg	fi
550788de56ccSmrg	if test "X$arg" = "X-export-symbols"; then
550888de56ccSmrg	  prev=expsyms
550988de56ccSmrg	else
551088de56ccSmrg	  prev=expsyms_regex
551188de56ccSmrg	fi
551288de56ccSmrg	continue
551388de56ccSmrg	;;
55142e9c7c8cSmrg
551588de56ccSmrg      -framework)
551688de56ccSmrg	prev=framework
551788de56ccSmrg	continue
551888de56ccSmrg	;;
55192e9c7c8cSmrg
552088de56ccSmrg      -inst-prefix-dir)
552188de56ccSmrg	prev=inst_prefix
552288de56ccSmrg	continue
552388de56ccSmrg	;;
55242e9c7c8cSmrg
552588de56ccSmrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
552688de56ccSmrg      # so, if we see these flags be careful not to treat them like -L
552788de56ccSmrg      -L[A-Z][A-Z]*:*)
552888de56ccSmrg	case $with_gcc/$host in
552988de56ccSmrg	no/*-*-irix* | /*-*-irix*)
553088de56ccSmrg	  func_append compile_command " $arg"
553188de56ccSmrg	  func_append finalize_command " $arg"
553288de56ccSmrg	  ;;
553388de56ccSmrg	esac
553488de56ccSmrg	continue
553588de56ccSmrg	;;
55362e9c7c8cSmrg
553788de56ccSmrg      -L*)
5538e9fcaa8aSmrg	func_stripname "-L" '' "$arg"
5539e9fcaa8aSmrg	if test -z "$func_stripname_result"; then
554088de56ccSmrg	  if test "$#" -gt 0; then
554188de56ccSmrg	    func_fatal_error "require no space between \`-L' and \`$1'"
554288de56ccSmrg	  else
554388de56ccSmrg	    func_fatal_error "need path for \`-L' option"
554488de56ccSmrg	  fi
554588de56ccSmrg	fi
5546e9fcaa8aSmrg	func_resolve_sysroot "$func_stripname_result"
5547e9fcaa8aSmrg	dir=$func_resolve_sysroot_result
554888de56ccSmrg	# We need an absolute path.
554988de56ccSmrg	case $dir in
555088de56ccSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
555188de56ccSmrg	*)
555288de56ccSmrg	  absdir=`cd "$dir" && pwd`
555388de56ccSmrg	  test -z "$absdir" && \
555488de56ccSmrg	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
555588de56ccSmrg	  dir="$absdir"
555688de56ccSmrg	  ;;
555788de56ccSmrg	esac
555888de56ccSmrg	case "$deplibs " in
5559e9fcaa8aSmrg	*" -L$dir "* | *" $arg "*)
5560e9fcaa8aSmrg	  # Will only happen for absolute or sysroot arguments
5561e9fcaa8aSmrg	  ;;
556288de56ccSmrg	*)
5563e9fcaa8aSmrg	  # Preserve sysroot, but never include relative directories
5564e9fcaa8aSmrg	  case $dir in
5565e9fcaa8aSmrg	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
5566e9fcaa8aSmrg	    *) func_append deplibs " -L$dir" ;;
5567e9fcaa8aSmrg	  esac
5568e9fcaa8aSmrg	  func_append lib_search_path " $dir"
556988de56ccSmrg	  ;;
557088de56ccSmrg	esac
557188de56ccSmrg	case $host in
557288de56ccSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
5573e9fcaa8aSmrg	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
557488de56ccSmrg	  case :$dllsearchpath: in
557588de56ccSmrg	  *":$dir:"*) ;;
557688de56ccSmrg	  ::) dllsearchpath=$dir;;
5577e9fcaa8aSmrg	  *) func_append dllsearchpath ":$dir";;
557888de56ccSmrg	  esac
557988de56ccSmrg	  case :$dllsearchpath: in
558088de56ccSmrg	  *":$testbindir:"*) ;;
558188de56ccSmrg	  ::) dllsearchpath=$testbindir;;
5582e9fcaa8aSmrg	  *) func_append dllsearchpath ":$testbindir";;
558388de56ccSmrg	  esac
558488de56ccSmrg	  ;;
558588de56ccSmrg	esac
558688de56ccSmrg	continue
558788de56ccSmrg	;;
55882e9c7c8cSmrg
558988de56ccSmrg      -l*)
559088de56ccSmrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
559188de56ccSmrg	  case $host in
5592e9fcaa8aSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
559388de56ccSmrg	    # These systems don't actually have a C or math library (as such)
559488de56ccSmrg	    continue
559588de56ccSmrg	    ;;
559688de56ccSmrg	  *-*-os2*)
559788de56ccSmrg	    # These systems don't actually have a C library (as such)
559888de56ccSmrg	    test "X$arg" = "X-lc" && continue
559988de56ccSmrg	    ;;
560088de56ccSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
560188de56ccSmrg	    # Do not include libc due to us having libc/libc_r.
560288de56ccSmrg	    test "X$arg" = "X-lc" && continue
560388de56ccSmrg	    ;;
560488de56ccSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
560588de56ccSmrg	    # Rhapsody C and math libraries are in the System framework
5606e9fcaa8aSmrg	    func_append deplibs " System.ltframework"
560788de56ccSmrg	    continue
560888de56ccSmrg	    ;;
560988de56ccSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
561088de56ccSmrg	    # Causes problems with __ctype
561188de56ccSmrg	    test "X$arg" = "X-lc" && continue
561288de56ccSmrg	    ;;
561388de56ccSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
561488de56ccSmrg	    # Compiler inserts libc in the correct place for threads to work
561588de56ccSmrg	    test "X$arg" = "X-lc" && continue
561688de56ccSmrg	    ;;
561788de56ccSmrg	  esac
561888de56ccSmrg	elif test "X$arg" = "X-lc_r"; then
561988de56ccSmrg	 case $host in
562088de56ccSmrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
562188de56ccSmrg	   # Do not include libc_r directly, use -pthread flag.
562288de56ccSmrg	   continue
562388de56ccSmrg	   ;;
562488de56ccSmrg	 esac
562588de56ccSmrg	fi
5626e9fcaa8aSmrg	func_append deplibs " $arg"
562788de56ccSmrg	continue
562888de56ccSmrg	;;
56292e9c7c8cSmrg
563088de56ccSmrg      -module)
563188de56ccSmrg	module=yes
563288de56ccSmrg	continue
563388de56ccSmrg	;;
56342e9c7c8cSmrg
563588de56ccSmrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
563688de56ccSmrg      # classes, name mangling, and exception handling.
563788de56ccSmrg      # Darwin uses the -arch flag to determine output architecture.
5638e9fcaa8aSmrg      -model|-arch|-isysroot|--sysroot)
5639e9fcaa8aSmrg	func_append compiler_flags " $arg"
564088de56ccSmrg	func_append compile_command " $arg"
564188de56ccSmrg	func_append finalize_command " $arg"
564288de56ccSmrg	prev=xcompiler
564388de56ccSmrg	continue
564488de56ccSmrg	;;
56452e9c7c8cSmrg
564688de56ccSmrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
5647e9fcaa8aSmrg	func_append compiler_flags " $arg"
564888de56ccSmrg	func_append compile_command " $arg"
564988de56ccSmrg	func_append finalize_command " $arg"
565088de56ccSmrg	case "$new_inherited_linker_flags " in
565188de56ccSmrg	    *" $arg "*) ;;
5652e9fcaa8aSmrg	    * ) func_append new_inherited_linker_flags " $arg" ;;
565388de56ccSmrg	esac
565488de56ccSmrg	continue
565588de56ccSmrg	;;
56562e9c7c8cSmrg
565788de56ccSmrg      -multi_module)
565888de56ccSmrg	single_module="${wl}-multi_module"
565988de56ccSmrg	continue
566088de56ccSmrg	;;
56612e9c7c8cSmrg
566288de56ccSmrg      -no-fast-install)
566388de56ccSmrg	fast_install=no
566488de56ccSmrg	continue
566588de56ccSmrg	;;
56662e9c7c8cSmrg
566788de56ccSmrg      -no-install)
566888de56ccSmrg	case $host in
566988de56ccSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
567088de56ccSmrg	  # The PATH hackery in wrapper scripts is required on Windows
567188de56ccSmrg	  # and Darwin in order for the loader to find any dlls it needs.
567288de56ccSmrg	  func_warning "\`-no-install' is ignored for $host"
567388de56ccSmrg	  func_warning "assuming \`-no-fast-install' instead"
567488de56ccSmrg	  fast_install=no
567588de56ccSmrg	  ;;
567688de56ccSmrg	*) no_install=yes ;;
567788de56ccSmrg	esac
567888de56ccSmrg	continue
567988de56ccSmrg	;;
56802e9c7c8cSmrg
568188de56ccSmrg      -no-undefined)
568288de56ccSmrg	allow_undefined=no
568388de56ccSmrg	continue
568488de56ccSmrg	;;
56852e9c7c8cSmrg
568688de56ccSmrg      -objectlist)
568788de56ccSmrg	prev=objectlist
568888de56ccSmrg	continue
568988de56ccSmrg	;;
56902e9c7c8cSmrg
569188de56ccSmrg      -o) prev=output ;;
56922e9c7c8cSmrg
569388de56ccSmrg      -precious-files-regex)
569488de56ccSmrg	prev=precious_regex
569588de56ccSmrg	continue
569688de56ccSmrg	;;
56972e9c7c8cSmrg
569888de56ccSmrg      -release)
569988de56ccSmrg	prev=release
570088de56ccSmrg	continue
570188de56ccSmrg	;;
57022e9c7c8cSmrg
570388de56ccSmrg      -rpath)
570488de56ccSmrg	prev=rpath
570588de56ccSmrg	continue
570688de56ccSmrg	;;
57072e9c7c8cSmrg
570888de56ccSmrg      -R)
570988de56ccSmrg	prev=xrpath
571088de56ccSmrg	continue
571188de56ccSmrg	;;
57122e9c7c8cSmrg
571388de56ccSmrg      -R*)
571488de56ccSmrg	func_stripname '-R' '' "$arg"
571588de56ccSmrg	dir=$func_stripname_result
571688de56ccSmrg	# We need an absolute path.
571788de56ccSmrg	case $dir in
571888de56ccSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
5719e9fcaa8aSmrg	=*)
5720e9fcaa8aSmrg	  func_stripname '=' '' "$dir"
5721e9fcaa8aSmrg	  dir=$lt_sysroot$func_stripname_result
5722e9fcaa8aSmrg	  ;;
572388de56ccSmrg	*)
572488de56ccSmrg	  func_fatal_error "only absolute run-paths are allowed"
572588de56ccSmrg	  ;;
572688de56ccSmrg	esac
572788de56ccSmrg	case "$xrpath " in
572888de56ccSmrg	*" $dir "*) ;;
5729e9fcaa8aSmrg	*) func_append xrpath " $dir" ;;
573088de56ccSmrg	esac
573188de56ccSmrg	continue
573288de56ccSmrg	;;
57332e9c7c8cSmrg
573488de56ccSmrg      -shared)
573588de56ccSmrg	# The effects of -shared are defined in a previous loop.
573688de56ccSmrg	continue
573788de56ccSmrg	;;
57382e9c7c8cSmrg
573988de56ccSmrg      -shrext)
574088de56ccSmrg	prev=shrext
574188de56ccSmrg	continue
574288de56ccSmrg	;;
57432e9c7c8cSmrg
574488de56ccSmrg      -static | -static-libtool-libs)
574588de56ccSmrg	# The effects of -static are defined in a previous loop.
574688de56ccSmrg	# We used to do the same as -all-static on platforms that
574788de56ccSmrg	# didn't have a PIC flag, but the assumption that the effects
574888de56ccSmrg	# would be equivalent was wrong.  It would break on at least
574988de56ccSmrg	# Digital Unix and AIX.
575088de56ccSmrg	continue
575188de56ccSmrg	;;
57522e9c7c8cSmrg
575388de56ccSmrg      -thread-safe)
575488de56ccSmrg	thread_safe=yes
575588de56ccSmrg	continue
575688de56ccSmrg	;;
57572e9c7c8cSmrg
575888de56ccSmrg      -version-info)
575988de56ccSmrg	prev=vinfo
576088de56ccSmrg	continue
576188de56ccSmrg	;;
57622e9c7c8cSmrg
576388de56ccSmrg      -version-number)
576488de56ccSmrg	prev=vinfo
576588de56ccSmrg	vinfo_number=yes
576688de56ccSmrg	continue
576788de56ccSmrg	;;
57682e9c7c8cSmrg
576988de56ccSmrg      -weak)
577088de56ccSmrg        prev=weak
577188de56ccSmrg	continue
577288de56ccSmrg	;;
57731ab64890Smrg
577488de56ccSmrg      -Wc,*)
577588de56ccSmrg	func_stripname '-Wc,' '' "$arg"
577688de56ccSmrg	args=$func_stripname_result
577788de56ccSmrg	arg=
577888de56ccSmrg	save_ifs="$IFS"; IFS=','
577988de56ccSmrg	for flag in $args; do
578088de56ccSmrg	  IFS="$save_ifs"
578188de56ccSmrg          func_quote_for_eval "$flag"
5782e9fcaa8aSmrg	  func_append arg " $func_quote_for_eval_result"
5783e9fcaa8aSmrg	  func_append compiler_flags " $func_quote_for_eval_result"
578488de56ccSmrg	done
578588de56ccSmrg	IFS="$save_ifs"
578688de56ccSmrg	func_stripname ' ' '' "$arg"
578788de56ccSmrg	arg=$func_stripname_result
578888de56ccSmrg	;;
5789b4ee4795Smrg
579088de56ccSmrg      -Wl,*)
579188de56ccSmrg	func_stripname '-Wl,' '' "$arg"
579288de56ccSmrg	args=$func_stripname_result
579388de56ccSmrg	arg=
579488de56ccSmrg	save_ifs="$IFS"; IFS=','
579588de56ccSmrg	for flag in $args; do
579688de56ccSmrg	  IFS="$save_ifs"
579788de56ccSmrg          func_quote_for_eval "$flag"
5798e9fcaa8aSmrg	  func_append arg " $wl$func_quote_for_eval_result"
5799e9fcaa8aSmrg	  func_append compiler_flags " $wl$func_quote_for_eval_result"
5800e9fcaa8aSmrg	  func_append linker_flags " $func_quote_for_eval_result"
580188de56ccSmrg	done
580288de56ccSmrg	IFS="$save_ifs"
580388de56ccSmrg	func_stripname ' ' '' "$arg"
580488de56ccSmrg	arg=$func_stripname_result
580588de56ccSmrg	;;
5806b4ee4795Smrg
580788de56ccSmrg      -Xcompiler)
580888de56ccSmrg	prev=xcompiler
580988de56ccSmrg	continue
581088de56ccSmrg	;;
5811b4ee4795Smrg
581288de56ccSmrg      -Xlinker)
581388de56ccSmrg	prev=xlinker
581488de56ccSmrg	continue
581588de56ccSmrg	;;
5816b4ee4795Smrg
581788de56ccSmrg      -XCClinker)
581888de56ccSmrg	prev=xcclinker
581988de56ccSmrg	continue
582088de56ccSmrg	;;
5821b4ee4795Smrg
582288de56ccSmrg      # -msg_* for osf cc
582388de56ccSmrg      -msg_*)
582488de56ccSmrg	func_quote_for_eval "$arg"
582588de56ccSmrg	arg="$func_quote_for_eval_result"
582688de56ccSmrg	;;
5827b4ee4795Smrg
5828e9fcaa8aSmrg      # Flags to be passed through unchanged, with rationale:
5829e9fcaa8aSmrg      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
5830e9fcaa8aSmrg      # -r[0-9][0-9]*        specify processor for the SGI compiler
5831e9fcaa8aSmrg      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
5832e9fcaa8aSmrg      # +DA*, +DD*           enable 64-bit mode for the HP compiler
5833e9fcaa8aSmrg      # -q*                  compiler args for the IBM compiler
5834e9fcaa8aSmrg      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
5835e9fcaa8aSmrg      # -F/path              path to uninstalled frameworks, gcc on darwin
5836e9fcaa8aSmrg      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
5837e9fcaa8aSmrg      # @file                GCC response files
5838e9fcaa8aSmrg      # -tp=*                Portland pgcc target processor selection
5839e9fcaa8aSmrg      # --sysroot=*          for sysroot support
5840e9fcaa8aSmrg      # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
584188de56ccSmrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
5842e9fcaa8aSmrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
5843e9fcaa8aSmrg      -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
584488de56ccSmrg        func_quote_for_eval "$arg"
584588de56ccSmrg	arg="$func_quote_for_eval_result"
584688de56ccSmrg        func_append compile_command " $arg"
584788de56ccSmrg        func_append finalize_command " $arg"
5848e9fcaa8aSmrg        func_append compiler_flags " $arg"
584988de56ccSmrg        continue
585088de56ccSmrg        ;;
5851b4ee4795Smrg
585288de56ccSmrg      # Some other compiler flag.
585388de56ccSmrg      -* | +*)
585488de56ccSmrg        func_quote_for_eval "$arg"
585588de56ccSmrg	arg="$func_quote_for_eval_result"
585688de56ccSmrg	;;
5857b4ee4795Smrg
585888de56ccSmrg      *.$objext)
585988de56ccSmrg	# A standard object.
5860e9fcaa8aSmrg	func_append objs " $arg"
586188de56ccSmrg	;;
5862b4ee4795Smrg
586388de56ccSmrg      *.lo)
586488de56ccSmrg	# A libtool-controlled object.
5865b4ee4795Smrg
586688de56ccSmrg	# Check to see that this really is a libtool object.
586788de56ccSmrg	if func_lalib_unsafe_p "$arg"; then
586888de56ccSmrg	  pic_object=
586988de56ccSmrg	  non_pic_object=
5870b4ee4795Smrg
587188de56ccSmrg	  # Read the .lo file
587288de56ccSmrg	  func_source "$arg"
5873b4ee4795Smrg
587488de56ccSmrg	  if test -z "$pic_object" ||
587588de56ccSmrg	     test -z "$non_pic_object" ||
587688de56ccSmrg	     test "$pic_object" = none &&
587788de56ccSmrg	     test "$non_pic_object" = none; then
587888de56ccSmrg	    func_fatal_error "cannot find name of object for \`$arg'"
587988de56ccSmrg	  fi
5880b4ee4795Smrg
588188de56ccSmrg	  # Extract subdirectory from the argument.
588288de56ccSmrg	  func_dirname "$arg" "/" ""
588388de56ccSmrg	  xdir="$func_dirname_result"
5884b4ee4795Smrg
588588de56ccSmrg	  if test "$pic_object" != none; then
588688de56ccSmrg	    # Prepend the subdirectory the object is found in.
588788de56ccSmrg	    pic_object="$xdir$pic_object"
5888b4ee4795Smrg
588988de56ccSmrg	    if test "$prev" = dlfiles; then
589088de56ccSmrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5891e9fcaa8aSmrg		func_append dlfiles " $pic_object"
589288de56ccSmrg		prev=
589388de56ccSmrg		continue
589488de56ccSmrg	      else
589588de56ccSmrg		# If libtool objects are unsupported, then we need to preload.
589688de56ccSmrg		prev=dlprefiles
589788de56ccSmrg	      fi
589888de56ccSmrg	    fi
5899b4ee4795Smrg
590088de56ccSmrg	    # CHECK ME:  I think I busted this.  -Ossama
590188de56ccSmrg	    if test "$prev" = dlprefiles; then
590288de56ccSmrg	      # Preload the old-style object.
5903e9fcaa8aSmrg	      func_append dlprefiles " $pic_object"
590488de56ccSmrg	      prev=
590588de56ccSmrg	    fi
59061ab64890Smrg
590788de56ccSmrg	    # A PIC object.
590888de56ccSmrg	    func_append libobjs " $pic_object"
590988de56ccSmrg	    arg="$pic_object"
591088de56ccSmrg	  fi
59111ab64890Smrg
591288de56ccSmrg	  # Non-PIC object.
591388de56ccSmrg	  if test "$non_pic_object" != none; then
591488de56ccSmrg	    # Prepend the subdirectory the object is found in.
591588de56ccSmrg	    non_pic_object="$xdir$non_pic_object"
59161ab64890Smrg
591788de56ccSmrg	    # A standard non-PIC object
591888de56ccSmrg	    func_append non_pic_objects " $non_pic_object"
591988de56ccSmrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
592088de56ccSmrg	      arg="$non_pic_object"
592188de56ccSmrg	    fi
592288de56ccSmrg	  else
592388de56ccSmrg	    # If the PIC object exists, use it instead.
592488de56ccSmrg	    # $xdir was prepended to $pic_object above.
592588de56ccSmrg	    non_pic_object="$pic_object"
592688de56ccSmrg	    func_append non_pic_objects " $non_pic_object"
592788de56ccSmrg	  fi
592888de56ccSmrg	else
592988de56ccSmrg	  # Only an error if not doing a dry-run.
593088de56ccSmrg	  if $opt_dry_run; then
593188de56ccSmrg	    # Extract subdirectory from the argument.
593288de56ccSmrg	    func_dirname "$arg" "/" ""
593388de56ccSmrg	    xdir="$func_dirname_result"
593488de56ccSmrg
593588de56ccSmrg	    func_lo2o "$arg"
593688de56ccSmrg	    pic_object=$xdir$objdir/$func_lo2o_result
593788de56ccSmrg	    non_pic_object=$xdir$func_lo2o_result
593888de56ccSmrg	    func_append libobjs " $pic_object"
593988de56ccSmrg	    func_append non_pic_objects " $non_pic_object"
594088de56ccSmrg	  else
594188de56ccSmrg	    func_fatal_error "\`$arg' is not a valid libtool object"
594288de56ccSmrg	  fi
594388de56ccSmrg	fi
594488de56ccSmrg	;;
59451ab64890Smrg
594688de56ccSmrg      *.$libext)
594788de56ccSmrg	# An archive.
5948e9fcaa8aSmrg	func_append deplibs " $arg"
5949e9fcaa8aSmrg	func_append old_deplibs " $arg"
595088de56ccSmrg	continue
595188de56ccSmrg	;;
595288de56ccSmrg
595388de56ccSmrg      *.la)
595488de56ccSmrg	# A libtool-controlled library.
595588de56ccSmrg
5956e9fcaa8aSmrg	func_resolve_sysroot "$arg"
595788de56ccSmrg	if test "$prev" = dlfiles; then
595888de56ccSmrg	  # This library was specified with -dlopen.
5959e9fcaa8aSmrg	  func_append dlfiles " $func_resolve_sysroot_result"
596088de56ccSmrg	  prev=
596188de56ccSmrg	elif test "$prev" = dlprefiles; then
596288de56ccSmrg	  # The library was specified with -dlpreopen.
5963e9fcaa8aSmrg	  func_append dlprefiles " $func_resolve_sysroot_result"
596488de56ccSmrg	  prev=
596588de56ccSmrg	else
5966e9fcaa8aSmrg	  func_append deplibs " $func_resolve_sysroot_result"
596788de56ccSmrg	fi
596888de56ccSmrg	continue
596988de56ccSmrg	;;
597088de56ccSmrg
597188de56ccSmrg      # Some other compiler argument.
597288de56ccSmrg      *)
597388de56ccSmrg	# Unknown arguments in both finalize_command and compile_command need
597488de56ccSmrg	# to be aesthetically quoted because they are evaled later.
597588de56ccSmrg	func_quote_for_eval "$arg"
597688de56ccSmrg	arg="$func_quote_for_eval_result"
597788de56ccSmrg	;;
597888de56ccSmrg      esac # arg
597988de56ccSmrg
598088de56ccSmrg      # Now actually substitute the argument into the commands.
598188de56ccSmrg      if test -n "$arg"; then
598288de56ccSmrg	func_append compile_command " $arg"
598388de56ccSmrg	func_append finalize_command " $arg"
598488de56ccSmrg      fi
598588de56ccSmrg    done # argument parsing loop
598688de56ccSmrg
598788de56ccSmrg    test -n "$prev" && \
598888de56ccSmrg      func_fatal_help "the \`$prevarg' option requires an argument"
598988de56ccSmrg
599088de56ccSmrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
599188de56ccSmrg      eval arg=\"$export_dynamic_flag_spec\"
599288de56ccSmrg      func_append compile_command " $arg"
599388de56ccSmrg      func_append finalize_command " $arg"
599488de56ccSmrg    fi
599588de56ccSmrg
599688de56ccSmrg    oldlibs=
599788de56ccSmrg    # calculate the name of the file, without its directory
599888de56ccSmrg    func_basename "$output"
599988de56ccSmrg    outputname="$func_basename_result"
600088de56ccSmrg    libobjs_save="$libobjs"
600188de56ccSmrg
600288de56ccSmrg    if test -n "$shlibpath_var"; then
600388de56ccSmrg      # get the directories listed in $shlibpath_var
6004e9fcaa8aSmrg      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
600588de56ccSmrg    else
600688de56ccSmrg      shlib_search_path=
600788de56ccSmrg    fi
600888de56ccSmrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
600988de56ccSmrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
601088de56ccSmrg
601188de56ccSmrg    func_dirname "$output" "/" ""
601288de56ccSmrg    output_objdir="$func_dirname_result$objdir"
6013e9fcaa8aSmrg    func_to_tool_file "$output_objdir/"
6014e9fcaa8aSmrg    tool_output_objdir=$func_to_tool_file_result
601588de56ccSmrg    # Create the object directory.
601688de56ccSmrg    func_mkdir_p "$output_objdir"
601788de56ccSmrg
601888de56ccSmrg    # Determine the type of output
601988de56ccSmrg    case $output in
602088de56ccSmrg    "")
602188de56ccSmrg      func_fatal_help "you must specify an output file"
602288de56ccSmrg      ;;
602388de56ccSmrg    *.$libext) linkmode=oldlib ;;
602488de56ccSmrg    *.lo | *.$objext) linkmode=obj ;;
602588de56ccSmrg    *.la) linkmode=lib ;;
602688de56ccSmrg    *) linkmode=prog ;; # Anything else should be a program.
602788de56ccSmrg    esac
602888de56ccSmrg
602988de56ccSmrg    specialdeplibs=
603088de56ccSmrg
603188de56ccSmrg    libs=
603288de56ccSmrg    # Find all interdependent deplibs by searching for libraries
603388de56ccSmrg    # that are linked more than once (e.g. -la -lb -la)
603488de56ccSmrg    for deplib in $deplibs; do
6035e9fcaa8aSmrg      if $opt_preserve_dup_deps ; then
603688de56ccSmrg	case "$libs " in
6037e9fcaa8aSmrg	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
603888de56ccSmrg	esac
603988de56ccSmrg      fi
6040e9fcaa8aSmrg      func_append libs " $deplib"
604188de56ccSmrg    done
604288de56ccSmrg
604388de56ccSmrg    if test "$linkmode" = lib; then
604488de56ccSmrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
604588de56ccSmrg
604688de56ccSmrg      # Compute libraries that are listed more than once in $predeps
604788de56ccSmrg      # $postdeps and mark them as special (i.e., whose duplicates are
604888de56ccSmrg      # not to be eliminated).
604988de56ccSmrg      pre_post_deps=
605088de56ccSmrg      if $opt_duplicate_compiler_generated_deps; then
605188de56ccSmrg	for pre_post_dep in $predeps $postdeps; do
605288de56ccSmrg	  case "$pre_post_deps " in
6053e9fcaa8aSmrg	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
605488de56ccSmrg	  esac
6055e9fcaa8aSmrg	  func_append pre_post_deps " $pre_post_dep"
605688de56ccSmrg	done
605788de56ccSmrg      fi
605888de56ccSmrg      pre_post_deps=
605988de56ccSmrg    fi
606088de56ccSmrg
606188de56ccSmrg    deplibs=
606288de56ccSmrg    newdependency_libs=
606388de56ccSmrg    newlib_search_path=
606488de56ccSmrg    need_relink=no # whether we're linking any uninstalled libtool libraries
606588de56ccSmrg    notinst_deplibs= # not-installed libtool libraries
606688de56ccSmrg    notinst_path= # paths that contain not-installed libtool libraries
606788de56ccSmrg
606888de56ccSmrg    case $linkmode in
606988de56ccSmrg    lib)
607088de56ccSmrg	passes="conv dlpreopen link"
607188de56ccSmrg	for file in $dlfiles $dlprefiles; do
607288de56ccSmrg	  case $file in
607388de56ccSmrg	  *.la) ;;
607488de56ccSmrg	  *)
607588de56ccSmrg	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
607688de56ccSmrg	    ;;
607788de56ccSmrg	  esac
607888de56ccSmrg	done
607988de56ccSmrg	;;
608088de56ccSmrg    prog)
608188de56ccSmrg	compile_deplibs=
608288de56ccSmrg	finalize_deplibs=
608388de56ccSmrg	alldeplibs=no
608488de56ccSmrg	newdlfiles=
608588de56ccSmrg	newdlprefiles=
608688de56ccSmrg	passes="conv scan dlopen dlpreopen link"
608788de56ccSmrg	;;
608888de56ccSmrg    *)  passes="conv"
608988de56ccSmrg	;;
609088de56ccSmrg    esac
609188de56ccSmrg
609288de56ccSmrg    for pass in $passes; do
609388de56ccSmrg      # The preopen pass in lib mode reverses $deplibs; put it back here
609488de56ccSmrg      # so that -L comes before libs that need it for instance...
609588de56ccSmrg      if test "$linkmode,$pass" = "lib,link"; then
609688de56ccSmrg	## FIXME: Find the place where the list is rebuilt in the wrong
609788de56ccSmrg	##        order, and fix it there properly
609888de56ccSmrg        tmp_deplibs=
609988de56ccSmrg	for deplib in $deplibs; do
610088de56ccSmrg	  tmp_deplibs="$deplib $tmp_deplibs"
610188de56ccSmrg	done
610288de56ccSmrg	deplibs="$tmp_deplibs"
610388de56ccSmrg      fi
610488de56ccSmrg
610588de56ccSmrg      if test "$linkmode,$pass" = "lib,link" ||
610688de56ccSmrg	 test "$linkmode,$pass" = "prog,scan"; then
610788de56ccSmrg	libs="$deplibs"
610888de56ccSmrg	deplibs=
610988de56ccSmrg      fi
611088de56ccSmrg      if test "$linkmode" = prog; then
611188de56ccSmrg	case $pass in
611288de56ccSmrg	dlopen) libs="$dlfiles" ;;
611388de56ccSmrg	dlpreopen) libs="$dlprefiles" ;;
6114e9fcaa8aSmrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
611588de56ccSmrg	esac
611688de56ccSmrg      fi
611788de56ccSmrg      if test "$linkmode,$pass" = "lib,dlpreopen"; then
611888de56ccSmrg	# Collect and forward deplibs of preopened libtool libs
611988de56ccSmrg	for lib in $dlprefiles; do
612088de56ccSmrg	  # Ignore non-libtool-libs
612188de56ccSmrg	  dependency_libs=
6122e9fcaa8aSmrg	  func_resolve_sysroot "$lib"
612388de56ccSmrg	  case $lib in
6124e9fcaa8aSmrg	  *.la)	func_source "$func_resolve_sysroot_result" ;;
612588de56ccSmrg	  esac
612688de56ccSmrg
612788de56ccSmrg	  # Collect preopened libtool deplibs, except any this library
612888de56ccSmrg	  # has declared as weak libs
612988de56ccSmrg	  for deplib in $dependency_libs; do
6130e9fcaa8aSmrg	    func_basename "$deplib"
6131e9fcaa8aSmrg            deplib_base=$func_basename_result
613288de56ccSmrg	    case " $weak_libs " in
613388de56ccSmrg	    *" $deplib_base "*) ;;
6134e9fcaa8aSmrg	    *) func_append deplibs " $deplib" ;;
613588de56ccSmrg	    esac
613688de56ccSmrg	  done
613788de56ccSmrg	done
613888de56ccSmrg	libs="$dlprefiles"
613988de56ccSmrg      fi
614088de56ccSmrg      if test "$pass" = dlopen; then
614188de56ccSmrg	# Collect dlpreopened libraries
614288de56ccSmrg	save_deplibs="$deplibs"
614388de56ccSmrg	deplibs=
614488de56ccSmrg      fi
614588de56ccSmrg
614688de56ccSmrg      for deplib in $libs; do
614788de56ccSmrg	lib=
614888de56ccSmrg	found=no
614988de56ccSmrg	case $deplib in
615088de56ccSmrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
615188de56ccSmrg	  if test "$linkmode,$pass" = "prog,link"; then
615288de56ccSmrg	    compile_deplibs="$deplib $compile_deplibs"
615388de56ccSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
615488de56ccSmrg	  else
6155e9fcaa8aSmrg	    func_append compiler_flags " $deplib"
615688de56ccSmrg	    if test "$linkmode" = lib ; then
615788de56ccSmrg		case "$new_inherited_linker_flags " in
615888de56ccSmrg		    *" $deplib "*) ;;
6159e9fcaa8aSmrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
616088de56ccSmrg		esac
616188de56ccSmrg	    fi
616288de56ccSmrg	  fi
616388de56ccSmrg	  continue
616488de56ccSmrg	  ;;
616588de56ccSmrg	-l*)
616688de56ccSmrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
616788de56ccSmrg	    func_warning "\`-l' is ignored for archives/objects"
616888de56ccSmrg	    continue
616988de56ccSmrg	  fi
617088de56ccSmrg	  func_stripname '-l' '' "$deplib"
617188de56ccSmrg	  name=$func_stripname_result
617288de56ccSmrg	  if test "$linkmode" = lib; then
617388de56ccSmrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
617488de56ccSmrg	  else
617588de56ccSmrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
617688de56ccSmrg	  fi
617788de56ccSmrg	  for searchdir in $searchdirs; do
617888de56ccSmrg	    for search_ext in .la $std_shrext .so .a; do
617988de56ccSmrg	      # Search the libtool library
618088de56ccSmrg	      lib="$searchdir/lib${name}${search_ext}"
618188de56ccSmrg	      if test -f "$lib"; then
618288de56ccSmrg		if test "$search_ext" = ".la"; then
618388de56ccSmrg		  found=yes
618488de56ccSmrg		else
618588de56ccSmrg		  found=no
618688de56ccSmrg		fi
618788de56ccSmrg		break 2
618888de56ccSmrg	      fi
618988de56ccSmrg	    done
619088de56ccSmrg	  done
619188de56ccSmrg	  if test "$found" != yes; then
619288de56ccSmrg	    # deplib doesn't seem to be a libtool library
619388de56ccSmrg	    if test "$linkmode,$pass" = "prog,link"; then
619488de56ccSmrg	      compile_deplibs="$deplib $compile_deplibs"
619588de56ccSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
619688de56ccSmrg	    else
619788de56ccSmrg	      deplibs="$deplib $deplibs"
619888de56ccSmrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
619988de56ccSmrg	    fi
620088de56ccSmrg	    continue
620188de56ccSmrg	  else # deplib is a libtool library
620288de56ccSmrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
620388de56ccSmrg	    # We need to do some special things here, and not later.
620488de56ccSmrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
620588de56ccSmrg	      case " $predeps $postdeps " in
620688de56ccSmrg	      *" $deplib "*)
620788de56ccSmrg		if func_lalib_p "$lib"; then
620888de56ccSmrg		  library_names=
620988de56ccSmrg		  old_library=
621088de56ccSmrg		  func_source "$lib"
621188de56ccSmrg		  for l in $old_library $library_names; do
621288de56ccSmrg		    ll="$l"
621388de56ccSmrg		  done
621488de56ccSmrg		  if test "X$ll" = "X$old_library" ; then # only static version available
621588de56ccSmrg		    found=no
621688de56ccSmrg		    func_dirname "$lib" "" "."
621788de56ccSmrg		    ladir="$func_dirname_result"
621888de56ccSmrg		    lib=$ladir/$old_library
621988de56ccSmrg		    if test "$linkmode,$pass" = "prog,link"; then
622088de56ccSmrg		      compile_deplibs="$deplib $compile_deplibs"
622188de56ccSmrg		      finalize_deplibs="$deplib $finalize_deplibs"
622288de56ccSmrg		    else
622388de56ccSmrg		      deplibs="$deplib $deplibs"
622488de56ccSmrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
622588de56ccSmrg		    fi
622688de56ccSmrg		    continue
622788de56ccSmrg		  fi
622888de56ccSmrg		fi
622988de56ccSmrg		;;
623088de56ccSmrg	      *) ;;
623188de56ccSmrg	      esac
623288de56ccSmrg	    fi
623388de56ccSmrg	  fi
623488de56ccSmrg	  ;; # -l
623588de56ccSmrg	*.ltframework)
623688de56ccSmrg	  if test "$linkmode,$pass" = "prog,link"; then
623788de56ccSmrg	    compile_deplibs="$deplib $compile_deplibs"
623888de56ccSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
623988de56ccSmrg	  else
624088de56ccSmrg	    deplibs="$deplib $deplibs"
624188de56ccSmrg	    if test "$linkmode" = lib ; then
624288de56ccSmrg		case "$new_inherited_linker_flags " in
624388de56ccSmrg		    *" $deplib "*) ;;
6244e9fcaa8aSmrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
624588de56ccSmrg		esac
624688de56ccSmrg	    fi
624788de56ccSmrg	  fi
624888de56ccSmrg	  continue
624988de56ccSmrg	  ;;
625088de56ccSmrg	-L*)
625188de56ccSmrg	  case $linkmode in
625288de56ccSmrg	  lib)
625388de56ccSmrg	    deplibs="$deplib $deplibs"
625488de56ccSmrg	    test "$pass" = conv && continue
625588de56ccSmrg	    newdependency_libs="$deplib $newdependency_libs"
625688de56ccSmrg	    func_stripname '-L' '' "$deplib"
6257e9fcaa8aSmrg	    func_resolve_sysroot "$func_stripname_result"
6258e9fcaa8aSmrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
625988de56ccSmrg	    ;;
626088de56ccSmrg	  prog)
626188de56ccSmrg	    if test "$pass" = conv; then
626288de56ccSmrg	      deplibs="$deplib $deplibs"
626388de56ccSmrg	      continue
626488de56ccSmrg	    fi
626588de56ccSmrg	    if test "$pass" = scan; then
626688de56ccSmrg	      deplibs="$deplib $deplibs"
626788de56ccSmrg	    else
626888de56ccSmrg	      compile_deplibs="$deplib $compile_deplibs"
626988de56ccSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
627088de56ccSmrg	    fi
627188de56ccSmrg	    func_stripname '-L' '' "$deplib"
6272e9fcaa8aSmrg	    func_resolve_sysroot "$func_stripname_result"
6273e9fcaa8aSmrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
627488de56ccSmrg	    ;;
627588de56ccSmrg	  *)
627688de56ccSmrg	    func_warning "\`-L' is ignored for archives/objects"
627788de56ccSmrg	    ;;
627888de56ccSmrg	  esac # linkmode
627988de56ccSmrg	  continue
628088de56ccSmrg	  ;; # -L
628188de56ccSmrg	-R*)
628288de56ccSmrg	  if test "$pass" = link; then
628388de56ccSmrg	    func_stripname '-R' '' "$deplib"
6284e9fcaa8aSmrg	    func_resolve_sysroot "$func_stripname_result"
6285e9fcaa8aSmrg	    dir=$func_resolve_sysroot_result
628688de56ccSmrg	    # Make sure the xrpath contains only unique directories.
628788de56ccSmrg	    case "$xrpath " in
628888de56ccSmrg	    *" $dir "*) ;;
6289e9fcaa8aSmrg	    *) func_append xrpath " $dir" ;;
629088de56ccSmrg	    esac
629188de56ccSmrg	  fi
629288de56ccSmrg	  deplibs="$deplib $deplibs"
629388de56ccSmrg	  continue
629488de56ccSmrg	  ;;
6295e9fcaa8aSmrg	*.la)
6296e9fcaa8aSmrg	  func_resolve_sysroot "$deplib"
6297e9fcaa8aSmrg	  lib=$func_resolve_sysroot_result
6298e9fcaa8aSmrg	  ;;
629988de56ccSmrg	*.$libext)
630088de56ccSmrg	  if test "$pass" = conv; then
630188de56ccSmrg	    deplibs="$deplib $deplibs"
630288de56ccSmrg	    continue
630388de56ccSmrg	  fi
630488de56ccSmrg	  case $linkmode in
630588de56ccSmrg	  lib)
630688de56ccSmrg	    # Linking convenience modules into shared libraries is allowed,
630788de56ccSmrg	    # but linking other static libraries is non-portable.
630888de56ccSmrg	    case " $dlpreconveniencelibs " in
630988de56ccSmrg	    *" $deplib "*) ;;
631088de56ccSmrg	    *)
631188de56ccSmrg	      valid_a_lib=no
631288de56ccSmrg	      case $deplibs_check_method in
631388de56ccSmrg		match_pattern*)
631488de56ccSmrg		  set dummy $deplibs_check_method; shift
631588de56ccSmrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6316e9fcaa8aSmrg		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
631788de56ccSmrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
631888de56ccSmrg		    valid_a_lib=yes
631988de56ccSmrg		  fi
632088de56ccSmrg		;;
632188de56ccSmrg		pass_all)
632288de56ccSmrg		  valid_a_lib=yes
632388de56ccSmrg		;;
632488de56ccSmrg	      esac
632588de56ccSmrg	      if test "$valid_a_lib" != yes; then
6326e9fcaa8aSmrg		echo
632788de56ccSmrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
6328e9fcaa8aSmrg		echo "*** I have the capability to make that library automatically link in when"
6329e9fcaa8aSmrg		echo "*** you link to this library.  But I can only do this if you have a"
6330e9fcaa8aSmrg		echo "*** shared version of the library, which you do not appear to have"
6331e9fcaa8aSmrg		echo "*** because the file extensions .$libext of this argument makes me believe"
6332e9fcaa8aSmrg		echo "*** that it is just a static archive that I should not use here."
633388de56ccSmrg	      else
6334e9fcaa8aSmrg		echo
633588de56ccSmrg		$ECHO "*** Warning: Linking the shared library $output against the"
633688de56ccSmrg		$ECHO "*** static library $deplib is not portable!"
633788de56ccSmrg		deplibs="$deplib $deplibs"
633888de56ccSmrg	      fi
633988de56ccSmrg	      ;;
634088de56ccSmrg	    esac
634188de56ccSmrg	    continue
634288de56ccSmrg	    ;;
634388de56ccSmrg	  prog)
634488de56ccSmrg	    if test "$pass" != link; then
634588de56ccSmrg	      deplibs="$deplib $deplibs"
634688de56ccSmrg	    else
634788de56ccSmrg	      compile_deplibs="$deplib $compile_deplibs"
634888de56ccSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
634988de56ccSmrg	    fi
635088de56ccSmrg	    continue
635188de56ccSmrg	    ;;
635288de56ccSmrg	  esac # linkmode
635388de56ccSmrg	  ;; # *.$libext
635488de56ccSmrg	*.lo | *.$objext)
635588de56ccSmrg	  if test "$pass" = conv; then
635688de56ccSmrg	    deplibs="$deplib $deplibs"
635788de56ccSmrg	  elif test "$linkmode" = prog; then
635888de56ccSmrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
635988de56ccSmrg	      # If there is no dlopen support or we're linking statically,
636088de56ccSmrg	      # we need to preload.
6361e9fcaa8aSmrg	      func_append newdlprefiles " $deplib"
636288de56ccSmrg	      compile_deplibs="$deplib $compile_deplibs"
636388de56ccSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
636488de56ccSmrg	    else
6365e9fcaa8aSmrg	      func_append newdlfiles " $deplib"
636688de56ccSmrg	    fi
636788de56ccSmrg	  fi
636888de56ccSmrg	  continue
636988de56ccSmrg	  ;;
637088de56ccSmrg	%DEPLIBS%)
637188de56ccSmrg	  alldeplibs=yes
637288de56ccSmrg	  continue
637388de56ccSmrg	  ;;
637488de56ccSmrg	esac # case $deplib
637588de56ccSmrg
637688de56ccSmrg	if test "$found" = yes || test -f "$lib"; then :
637788de56ccSmrg	else
637888de56ccSmrg	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
637988de56ccSmrg	fi
638088de56ccSmrg
638188de56ccSmrg	# Check to see that this really is a libtool archive.
638288de56ccSmrg	func_lalib_unsafe_p "$lib" \
638388de56ccSmrg	  || func_fatal_error "\`$lib' is not a valid libtool archive"
638488de56ccSmrg
638588de56ccSmrg	func_dirname "$lib" "" "."
638688de56ccSmrg	ladir="$func_dirname_result"
638788de56ccSmrg
638888de56ccSmrg	dlname=
638988de56ccSmrg	dlopen=
639088de56ccSmrg	dlpreopen=
639188de56ccSmrg	libdir=
639288de56ccSmrg	library_names=
639388de56ccSmrg	old_library=
639488de56ccSmrg	inherited_linker_flags=
639588de56ccSmrg	# If the library was installed with an old release of libtool,
639688de56ccSmrg	# it will not redefine variables installed, or shouldnotlink
639788de56ccSmrg	installed=yes
639888de56ccSmrg	shouldnotlink=no
639988de56ccSmrg	avoidtemprpath=
640088de56ccSmrg
640188de56ccSmrg
640288de56ccSmrg	# Read the .la file
640388de56ccSmrg	func_source "$lib"
640488de56ccSmrg
640588de56ccSmrg	# Convert "-framework foo" to "foo.ltframework"
640688de56ccSmrg	if test -n "$inherited_linker_flags"; then
6407e9fcaa8aSmrg	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
640888de56ccSmrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
640988de56ccSmrg	    case " $new_inherited_linker_flags " in
641088de56ccSmrg	      *" $tmp_inherited_linker_flag "*) ;;
6411e9fcaa8aSmrg	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
641288de56ccSmrg	    esac
641388de56ccSmrg	  done
641488de56ccSmrg	fi
6415e9fcaa8aSmrg	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
641688de56ccSmrg	if test "$linkmode,$pass" = "lib,link" ||
641788de56ccSmrg	   test "$linkmode,$pass" = "prog,scan" ||
641888de56ccSmrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
6419e9fcaa8aSmrg	  test -n "$dlopen" && func_append dlfiles " $dlopen"
6420e9fcaa8aSmrg	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
642188de56ccSmrg	fi
642288de56ccSmrg
642388de56ccSmrg	if test "$pass" = conv; then
642488de56ccSmrg	  # Only check for convenience libraries
642588de56ccSmrg	  deplibs="$lib $deplibs"
642688de56ccSmrg	  if test -z "$libdir"; then
642788de56ccSmrg	    if test -z "$old_library"; then
642888de56ccSmrg	      func_fatal_error "cannot find name of link library for \`$lib'"
642988de56ccSmrg	    fi
643088de56ccSmrg	    # It is a libtool convenience library, so add in its objects.
6431e9fcaa8aSmrg	    func_append convenience " $ladir/$objdir/$old_library"
6432e9fcaa8aSmrg	    func_append old_convenience " $ladir/$objdir/$old_library"
643388de56ccSmrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
643488de56ccSmrg	    func_fatal_error "\`$lib' is not a convenience library"
643588de56ccSmrg	  fi
6436e9fcaa8aSmrg	  tmp_libs=
6437e9fcaa8aSmrg	  for deplib in $dependency_libs; do
6438e9fcaa8aSmrg	    deplibs="$deplib $deplibs"
6439e9fcaa8aSmrg	    if $opt_preserve_dup_deps ; then
6440e9fcaa8aSmrg	      case "$tmp_libs " in
6441e9fcaa8aSmrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
6442e9fcaa8aSmrg	      esac
6443e9fcaa8aSmrg	    fi
6444e9fcaa8aSmrg	    func_append tmp_libs " $deplib"
6445e9fcaa8aSmrg	  done
644688de56ccSmrg	  continue
644788de56ccSmrg	fi # $pass = conv
644888de56ccSmrg
644988de56ccSmrg
645088de56ccSmrg	# Get the name of the library we link against.
645188de56ccSmrg	linklib=
6452e9fcaa8aSmrg	if test -n "$old_library" &&
6453e9fcaa8aSmrg	   { test "$prefer_static_libs" = yes ||
6454e9fcaa8aSmrg	     test "$prefer_static_libs,$installed" = "built,no"; }; then
6455e9fcaa8aSmrg	  linklib=$old_library
6456e9fcaa8aSmrg	else
6457e9fcaa8aSmrg	  for l in $old_library $library_names; do
6458e9fcaa8aSmrg	    linklib="$l"
6459e9fcaa8aSmrg	  done
6460e9fcaa8aSmrg	fi
646188de56ccSmrg	if test -z "$linklib"; then
646288de56ccSmrg	  func_fatal_error "cannot find name of link library for \`$lib'"
646388de56ccSmrg	fi
646488de56ccSmrg
646588de56ccSmrg	# This library was specified with -dlopen.
646688de56ccSmrg	if test "$pass" = dlopen; then
646788de56ccSmrg	  if test -z "$libdir"; then
646888de56ccSmrg	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
646988de56ccSmrg	  fi
647088de56ccSmrg	  if test -z "$dlname" ||
647188de56ccSmrg	     test "$dlopen_support" != yes ||
647288de56ccSmrg	     test "$build_libtool_libs" = no; then
647388de56ccSmrg	    # If there is no dlname, no dlopen support or we're linking
647488de56ccSmrg	    # statically, we need to preload.  We also need to preload any
647588de56ccSmrg	    # dependent libraries so libltdl's deplib preloader doesn't
647688de56ccSmrg	    # bomb out in the load deplibs phase.
6477e9fcaa8aSmrg	    func_append dlprefiles " $lib $dependency_libs"
647888de56ccSmrg	  else
6479e9fcaa8aSmrg	    func_append newdlfiles " $lib"
648088de56ccSmrg	  fi
648188de56ccSmrg	  continue
648288de56ccSmrg	fi # $pass = dlopen
648388de56ccSmrg
648488de56ccSmrg	# We need an absolute path.
648588de56ccSmrg	case $ladir in
648688de56ccSmrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
648788de56ccSmrg	*)
648888de56ccSmrg	  abs_ladir=`cd "$ladir" && pwd`
648988de56ccSmrg	  if test -z "$abs_ladir"; then
649088de56ccSmrg	    func_warning "cannot determine absolute directory name of \`$ladir'"
649188de56ccSmrg	    func_warning "passing it literally to the linker, although it might fail"
649288de56ccSmrg	    abs_ladir="$ladir"
649388de56ccSmrg	  fi
649488de56ccSmrg	  ;;
649588de56ccSmrg	esac
649688de56ccSmrg	func_basename "$lib"
649788de56ccSmrg	laname="$func_basename_result"
649888de56ccSmrg
649988de56ccSmrg	# Find the relevant object directory and library name.
650088de56ccSmrg	if test "X$installed" = Xyes; then
6501e9fcaa8aSmrg	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
650288de56ccSmrg	    func_warning "library \`$lib' was moved."
650388de56ccSmrg	    dir="$ladir"
650488de56ccSmrg	    absdir="$abs_ladir"
650588de56ccSmrg	    libdir="$abs_ladir"
650688de56ccSmrg	  else
6507e9fcaa8aSmrg	    dir="$lt_sysroot$libdir"
6508e9fcaa8aSmrg	    absdir="$lt_sysroot$libdir"
650988de56ccSmrg	  fi
651088de56ccSmrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
651188de56ccSmrg	else
651288de56ccSmrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
651388de56ccSmrg	    dir="$ladir"
651488de56ccSmrg	    absdir="$abs_ladir"
651588de56ccSmrg	    # Remove this search path later
6516e9fcaa8aSmrg	    func_append notinst_path " $abs_ladir"
651788de56ccSmrg	  else
651888de56ccSmrg	    dir="$ladir/$objdir"
651988de56ccSmrg	    absdir="$abs_ladir/$objdir"
652088de56ccSmrg	    # Remove this search path later
6521e9fcaa8aSmrg	    func_append notinst_path " $abs_ladir"
652288de56ccSmrg	  fi
652388de56ccSmrg	fi # $installed = yes
652488de56ccSmrg	func_stripname 'lib' '.la' "$laname"
652588de56ccSmrg	name=$func_stripname_result
652688de56ccSmrg
652788de56ccSmrg	# This library was specified with -dlpreopen.
652888de56ccSmrg	if test "$pass" = dlpreopen; then
652988de56ccSmrg	  if test -z "$libdir" && test "$linkmode" = prog; then
653088de56ccSmrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
653188de56ccSmrg	  fi
6532e9fcaa8aSmrg	  case "$host" in
6533e9fcaa8aSmrg	    # special handling for platforms with PE-DLLs.
6534e9fcaa8aSmrg	    *cygwin* | *mingw* | *cegcc* )
6535e9fcaa8aSmrg	      # Linker will automatically link against shared library if both
6536e9fcaa8aSmrg	      # static and shared are present.  Therefore, ensure we extract
6537e9fcaa8aSmrg	      # symbols from the import library if a shared library is present
6538e9fcaa8aSmrg	      # (otherwise, the dlopen module name will be incorrect).  We do
6539e9fcaa8aSmrg	      # this by putting the import library name into $newdlprefiles.
6540e9fcaa8aSmrg	      # We recover the dlopen module name by 'saving' the la file
6541e9fcaa8aSmrg	      # name in a special purpose variable, and (later) extracting the
6542e9fcaa8aSmrg	      # dlname from the la file.
6543e9fcaa8aSmrg	      if test -n "$dlname"; then
6544e9fcaa8aSmrg	        func_tr_sh "$dir/$linklib"
6545e9fcaa8aSmrg	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
6546e9fcaa8aSmrg	        func_append newdlprefiles " $dir/$linklib"
6547e9fcaa8aSmrg	      else
6548e9fcaa8aSmrg	        func_append newdlprefiles " $dir/$old_library"
6549e9fcaa8aSmrg	        # Keep a list of preopened convenience libraries to check
6550e9fcaa8aSmrg	        # that they are being used correctly in the link pass.
6551e9fcaa8aSmrg	        test -z "$libdir" && \
6552e9fcaa8aSmrg	          func_append dlpreconveniencelibs " $dir/$old_library"
6553e9fcaa8aSmrg	      fi
6554e9fcaa8aSmrg	    ;;
6555e9fcaa8aSmrg	    * )
6556e9fcaa8aSmrg	      # Prefer using a static library (so that no silly _DYNAMIC symbols
6557e9fcaa8aSmrg	      # are required to link).
6558e9fcaa8aSmrg	      if test -n "$old_library"; then
6559e9fcaa8aSmrg	        func_append newdlprefiles " $dir/$old_library"
6560e9fcaa8aSmrg	        # Keep a list of preopened convenience libraries to check
6561e9fcaa8aSmrg	        # that they are being used correctly in the link pass.
6562e9fcaa8aSmrg	        test -z "$libdir" && \
6563e9fcaa8aSmrg	          func_append dlpreconveniencelibs " $dir/$old_library"
6564e9fcaa8aSmrg	      # Otherwise, use the dlname, so that lt_dlopen finds it.
6565e9fcaa8aSmrg	      elif test -n "$dlname"; then
6566e9fcaa8aSmrg	        func_append newdlprefiles " $dir/$dlname"
6567e9fcaa8aSmrg	      else
6568e9fcaa8aSmrg	        func_append newdlprefiles " $dir/$linklib"
6569e9fcaa8aSmrg	      fi
6570e9fcaa8aSmrg	    ;;
6571e9fcaa8aSmrg	  esac
657288de56ccSmrg	fi # $pass = dlpreopen
657388de56ccSmrg
657488de56ccSmrg	if test -z "$libdir"; then
657588de56ccSmrg	  # Link the convenience library
657688de56ccSmrg	  if test "$linkmode" = lib; then
657788de56ccSmrg	    deplibs="$dir/$old_library $deplibs"
657888de56ccSmrg	  elif test "$linkmode,$pass" = "prog,link"; then
657988de56ccSmrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
658088de56ccSmrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
658188de56ccSmrg	  else
658288de56ccSmrg	    deplibs="$lib $deplibs" # used for prog,scan pass
658388de56ccSmrg	  fi
658488de56ccSmrg	  continue
658588de56ccSmrg	fi
658688de56ccSmrg
658788de56ccSmrg
658888de56ccSmrg	if test "$linkmode" = prog && test "$pass" != link; then
6589e9fcaa8aSmrg	  func_append newlib_search_path " $ladir"
659088de56ccSmrg	  deplibs="$lib $deplibs"
659188de56ccSmrg
659288de56ccSmrg	  linkalldeplibs=no
659388de56ccSmrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
659488de56ccSmrg	     test "$build_libtool_libs" = no; then
659588de56ccSmrg	    linkalldeplibs=yes
659688de56ccSmrg	  fi
659788de56ccSmrg
659888de56ccSmrg	  tmp_libs=
659988de56ccSmrg	  for deplib in $dependency_libs; do
660088de56ccSmrg	    case $deplib in
660188de56ccSmrg	    -L*) func_stripname '-L' '' "$deplib"
6602e9fcaa8aSmrg	         func_resolve_sysroot "$func_stripname_result"
6603e9fcaa8aSmrg	         func_append newlib_search_path " $func_resolve_sysroot_result"
660488de56ccSmrg		 ;;
660588de56ccSmrg	    esac
660688de56ccSmrg	    # Need to link against all dependency_libs?
660788de56ccSmrg	    if test "$linkalldeplibs" = yes; then
660888de56ccSmrg	      deplibs="$deplib $deplibs"
660988de56ccSmrg	    else
661088de56ccSmrg	      # Need to hardcode shared library paths
661188de56ccSmrg	      # or/and link against static libraries
661288de56ccSmrg	      newdependency_libs="$deplib $newdependency_libs"
661388de56ccSmrg	    fi
6614e9fcaa8aSmrg	    if $opt_preserve_dup_deps ; then
661588de56ccSmrg	      case "$tmp_libs " in
6616e9fcaa8aSmrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
661788de56ccSmrg	      esac
661888de56ccSmrg	    fi
6619e9fcaa8aSmrg	    func_append tmp_libs " $deplib"
662088de56ccSmrg	  done # for deplib
662188de56ccSmrg	  continue
662288de56ccSmrg	fi # $linkmode = prog...
662388de56ccSmrg
662488de56ccSmrg	if test "$linkmode,$pass" = "prog,link"; then
662588de56ccSmrg	  if test -n "$library_names" &&
662688de56ccSmrg	     { { test "$prefer_static_libs" = no ||
662788de56ccSmrg	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
662888de56ccSmrg	       test -z "$old_library"; }; then
662988de56ccSmrg	    # We need to hardcode the library path
663088de56ccSmrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
663188de56ccSmrg	      # Make sure the rpath contains only unique directories.
663288de56ccSmrg	      case "$temp_rpath:" in
663388de56ccSmrg	      *"$absdir:"*) ;;
6634e9fcaa8aSmrg	      *) func_append temp_rpath "$absdir:" ;;
663588de56ccSmrg	      esac
663688de56ccSmrg	    fi
663788de56ccSmrg
663888de56ccSmrg	    # Hardcode the library path.
663988de56ccSmrg	    # Skip directories that are in the system default run-time
664088de56ccSmrg	    # search path.
664188de56ccSmrg	    case " $sys_lib_dlsearch_path " in
664288de56ccSmrg	    *" $absdir "*) ;;
664388de56ccSmrg	    *)
664488de56ccSmrg	      case "$compile_rpath " in
664588de56ccSmrg	      *" $absdir "*) ;;
6646e9fcaa8aSmrg	      *) func_append compile_rpath " $absdir" ;;
664788de56ccSmrg	      esac
664888de56ccSmrg	      ;;
664988de56ccSmrg	    esac
665088de56ccSmrg	    case " $sys_lib_dlsearch_path " in
665188de56ccSmrg	    *" $libdir "*) ;;
665288de56ccSmrg	    *)
665388de56ccSmrg	      case "$finalize_rpath " in
665488de56ccSmrg	      *" $libdir "*) ;;
6655e9fcaa8aSmrg	      *) func_append finalize_rpath " $libdir" ;;
665688de56ccSmrg	      esac
665788de56ccSmrg	      ;;
665888de56ccSmrg	    esac
665988de56ccSmrg	  fi # $linkmode,$pass = prog,link...
666088de56ccSmrg
666188de56ccSmrg	  if test "$alldeplibs" = yes &&
666288de56ccSmrg	     { test "$deplibs_check_method" = pass_all ||
666388de56ccSmrg	       { test "$build_libtool_libs" = yes &&
666488de56ccSmrg		 test -n "$library_names"; }; }; then
666588de56ccSmrg	    # We only need to search for static libraries
666688de56ccSmrg	    continue
666788de56ccSmrg	  fi
666888de56ccSmrg	fi
666988de56ccSmrg
667088de56ccSmrg	link_static=no # Whether the deplib will be linked statically
667188de56ccSmrg	use_static_libs=$prefer_static_libs
667288de56ccSmrg	if test "$use_static_libs" = built && test "$installed" = yes; then
667388de56ccSmrg	  use_static_libs=no
667488de56ccSmrg	fi
667588de56ccSmrg	if test -n "$library_names" &&
667688de56ccSmrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
667788de56ccSmrg	  case $host in
667888de56ccSmrg	  *cygwin* | *mingw* | *cegcc*)
667988de56ccSmrg	      # No point in relinking DLLs because paths are not encoded
6680e9fcaa8aSmrg	      func_append notinst_deplibs " $lib"
668188de56ccSmrg	      need_relink=no
668288de56ccSmrg	    ;;
668388de56ccSmrg	  *)
668488de56ccSmrg	    if test "$installed" = no; then
6685e9fcaa8aSmrg	      func_append notinst_deplibs " $lib"
668688de56ccSmrg	      need_relink=yes
668788de56ccSmrg	    fi
668888de56ccSmrg	    ;;
668988de56ccSmrg	  esac
669088de56ccSmrg	  # This is a shared library
669188de56ccSmrg
669288de56ccSmrg	  # Warn about portability, can't link against -module's on some
669388de56ccSmrg	  # systems (darwin).  Don't bleat about dlopened modules though!
669488de56ccSmrg	  dlopenmodule=""
669588de56ccSmrg	  for dlpremoduletest in $dlprefiles; do
669688de56ccSmrg	    if test "X$dlpremoduletest" = "X$lib"; then
669788de56ccSmrg	      dlopenmodule="$dlpremoduletest"
669888de56ccSmrg	      break
669988de56ccSmrg	    fi
670088de56ccSmrg	  done
670188de56ccSmrg	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
6702e9fcaa8aSmrg	    echo
670388de56ccSmrg	    if test "$linkmode" = prog; then
670488de56ccSmrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
670588de56ccSmrg	    else
670688de56ccSmrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
670788de56ccSmrg	    fi
670888de56ccSmrg	    $ECHO "*** $linklib is not portable!"
670988de56ccSmrg	  fi
671088de56ccSmrg	  if test "$linkmode" = lib &&
671188de56ccSmrg	     test "$hardcode_into_libs" = yes; then
671288de56ccSmrg	    # Hardcode the library path.
671388de56ccSmrg	    # Skip directories that are in the system default run-time
671488de56ccSmrg	    # search path.
671588de56ccSmrg	    case " $sys_lib_dlsearch_path " in
671688de56ccSmrg	    *" $absdir "*) ;;
671788de56ccSmrg	    *)
671888de56ccSmrg	      case "$compile_rpath " in
671988de56ccSmrg	      *" $absdir "*) ;;
6720e9fcaa8aSmrg	      *) func_append compile_rpath " $absdir" ;;
672188de56ccSmrg	      esac
672288de56ccSmrg	      ;;
672388de56ccSmrg	    esac
672488de56ccSmrg	    case " $sys_lib_dlsearch_path " in
672588de56ccSmrg	    *" $libdir "*) ;;
672688de56ccSmrg	    *)
672788de56ccSmrg	      case "$finalize_rpath " in
672888de56ccSmrg	      *" $libdir "*) ;;
6729e9fcaa8aSmrg	      *) func_append finalize_rpath " $libdir" ;;
673088de56ccSmrg	      esac
673188de56ccSmrg	      ;;
673288de56ccSmrg	    esac
673388de56ccSmrg	  fi
673488de56ccSmrg
673588de56ccSmrg	  if test -n "$old_archive_from_expsyms_cmds"; then
673688de56ccSmrg	    # figure out the soname
673788de56ccSmrg	    set dummy $library_names
673888de56ccSmrg	    shift
673988de56ccSmrg	    realname="$1"
674088de56ccSmrg	    shift
674188de56ccSmrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
674288de56ccSmrg	    # use dlname if we got it. it's perfectly good, no?
674388de56ccSmrg	    if test -n "$dlname"; then
674488de56ccSmrg	      soname="$dlname"
674588de56ccSmrg	    elif test -n "$soname_spec"; then
674688de56ccSmrg	      # bleh windows
674788de56ccSmrg	      case $host in
674888de56ccSmrg	      *cygwin* | mingw* | *cegcc*)
674988de56ccSmrg	        func_arith $current - $age
675088de56ccSmrg		major=$func_arith_result
675188de56ccSmrg		versuffix="-$major"
675288de56ccSmrg		;;
675388de56ccSmrg	      esac
675488de56ccSmrg	      eval soname=\"$soname_spec\"
675588de56ccSmrg	    else
675688de56ccSmrg	      soname="$realname"
675788de56ccSmrg	    fi
675888de56ccSmrg
675988de56ccSmrg	    # Make a new name for the extract_expsyms_cmds to use
676088de56ccSmrg	    soroot="$soname"
676188de56ccSmrg	    func_basename "$soroot"
676288de56ccSmrg	    soname="$func_basename_result"
676388de56ccSmrg	    func_stripname 'lib' '.dll' "$soname"
676488de56ccSmrg	    newlib=libimp-$func_stripname_result.a
676588de56ccSmrg
676688de56ccSmrg	    # If the library has no export list, then create one now
676788de56ccSmrg	    if test -f "$output_objdir/$soname-def"; then :
676888de56ccSmrg	    else
676988de56ccSmrg	      func_verbose "extracting exported symbol list from \`$soname'"
677088de56ccSmrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
677188de56ccSmrg	    fi
677288de56ccSmrg
677388de56ccSmrg	    # Create $newlib
677488de56ccSmrg	    if test -f "$output_objdir/$newlib"; then :; else
677588de56ccSmrg	      func_verbose "generating import library for \`$soname'"
677688de56ccSmrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
677788de56ccSmrg	    fi
677888de56ccSmrg	    # make sure the library variables are pointing to the new library
677988de56ccSmrg	    dir=$output_objdir
678088de56ccSmrg	    linklib=$newlib
678188de56ccSmrg	  fi # test -n "$old_archive_from_expsyms_cmds"
678288de56ccSmrg
6783e9fcaa8aSmrg	  if test "$linkmode" = prog || test "$opt_mode" != relink; then
678488de56ccSmrg	    add_shlibpath=
678588de56ccSmrg	    add_dir=
678688de56ccSmrg	    add=
678788de56ccSmrg	    lib_linked=yes
678888de56ccSmrg	    case $hardcode_action in
678988de56ccSmrg	    immediate | unsupported)
679088de56ccSmrg	      if test "$hardcode_direct" = no; then
679188de56ccSmrg		add="$dir/$linklib"
679288de56ccSmrg		case $host in
679388de56ccSmrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
679488de56ccSmrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
679588de56ccSmrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
679688de56ccSmrg		    *-*-unixware7*) add_dir="-L$dir" ;;
679788de56ccSmrg		  *-*-darwin* )
679888de56ccSmrg		    # if the lib is a (non-dlopened) module then we can not
679988de56ccSmrg		    # link against it, someone is ignoring the earlier warnings
680088de56ccSmrg		    if /usr/bin/file -L $add 2> /dev/null |
680188de56ccSmrg			 $GREP ": [^:]* bundle" >/dev/null ; then
680288de56ccSmrg		      if test "X$dlopenmodule" != "X$lib"; then
680388de56ccSmrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
680488de56ccSmrg			if test -z "$old_library" ; then
6805e9fcaa8aSmrg			  echo
6806e9fcaa8aSmrg			  echo "*** And there doesn't seem to be a static archive available"
6807e9fcaa8aSmrg			  echo "*** The link will probably fail, sorry"
680888de56ccSmrg			else
680988de56ccSmrg			  add="$dir/$old_library"
681088de56ccSmrg			fi
681188de56ccSmrg		      elif test -n "$old_library"; then
681288de56ccSmrg			add="$dir/$old_library"
681388de56ccSmrg		      fi
681488de56ccSmrg		    fi
681588de56ccSmrg		esac
681688de56ccSmrg	      elif test "$hardcode_minus_L" = no; then
681788de56ccSmrg		case $host in
681888de56ccSmrg		*-*-sunos*) add_shlibpath="$dir" ;;
681988de56ccSmrg		esac
682088de56ccSmrg		add_dir="-L$dir"
682188de56ccSmrg		add="-l$name"
682288de56ccSmrg	      elif test "$hardcode_shlibpath_var" = no; then
682388de56ccSmrg		add_shlibpath="$dir"
682488de56ccSmrg		add="-l$name"
682588de56ccSmrg	      else
682688de56ccSmrg		lib_linked=no
682788de56ccSmrg	      fi
682888de56ccSmrg	      ;;
682988de56ccSmrg	    relink)
683088de56ccSmrg	      if test "$hardcode_direct" = yes &&
683188de56ccSmrg	         test "$hardcode_direct_absolute" = no; then
683288de56ccSmrg		add="$dir/$linklib"
683388de56ccSmrg	      elif test "$hardcode_minus_L" = yes; then
683488de56ccSmrg		add_dir="-L$dir"
683588de56ccSmrg		# Try looking first in the location we're being installed to.
683688de56ccSmrg		if test -n "$inst_prefix_dir"; then
683788de56ccSmrg		  case $libdir in
683888de56ccSmrg		    [\\/]*)
6839e9fcaa8aSmrg		      func_append add_dir " -L$inst_prefix_dir$libdir"
684088de56ccSmrg		      ;;
684188de56ccSmrg		  esac
684288de56ccSmrg		fi
684388de56ccSmrg		add="-l$name"
684488de56ccSmrg	      elif test "$hardcode_shlibpath_var" = yes; then
684588de56ccSmrg		add_shlibpath="$dir"
684688de56ccSmrg		add="-l$name"
684788de56ccSmrg	      else
684888de56ccSmrg		lib_linked=no
684988de56ccSmrg	      fi
685088de56ccSmrg	      ;;
685188de56ccSmrg	    *) lib_linked=no ;;
685288de56ccSmrg	    esac
685388de56ccSmrg
685488de56ccSmrg	    if test "$lib_linked" != yes; then
685588de56ccSmrg	      func_fatal_configuration "unsupported hardcode properties"
685688de56ccSmrg	    fi
685788de56ccSmrg
685888de56ccSmrg	    if test -n "$add_shlibpath"; then
685988de56ccSmrg	      case :$compile_shlibpath: in
686088de56ccSmrg	      *":$add_shlibpath:"*) ;;
6861e9fcaa8aSmrg	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
686288de56ccSmrg	      esac
686388de56ccSmrg	    fi
686488de56ccSmrg	    if test "$linkmode" = prog; then
686588de56ccSmrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
686688de56ccSmrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
686788de56ccSmrg	    else
686888de56ccSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
686988de56ccSmrg	      test -n "$add" && deplibs="$add $deplibs"
687088de56ccSmrg	      if test "$hardcode_direct" != yes &&
687188de56ccSmrg		 test "$hardcode_minus_L" != yes &&
687288de56ccSmrg		 test "$hardcode_shlibpath_var" = yes; then
687388de56ccSmrg		case :$finalize_shlibpath: in
687488de56ccSmrg		*":$libdir:"*) ;;
6875e9fcaa8aSmrg		*) func_append finalize_shlibpath "$libdir:" ;;
687688de56ccSmrg		esac
687788de56ccSmrg	      fi
687888de56ccSmrg	    fi
687988de56ccSmrg	  fi
688088de56ccSmrg
6881e9fcaa8aSmrg	  if test "$linkmode" = prog || test "$opt_mode" = relink; then
688288de56ccSmrg	    add_shlibpath=
688388de56ccSmrg	    add_dir=
688488de56ccSmrg	    add=
688588de56ccSmrg	    # Finalize command for both is simple: just hardcode it.
688688de56ccSmrg	    if test "$hardcode_direct" = yes &&
688788de56ccSmrg	       test "$hardcode_direct_absolute" = no; then
688888de56ccSmrg	      add="$libdir/$linklib"
688988de56ccSmrg	    elif test "$hardcode_minus_L" = yes; then
689088de56ccSmrg	      add_dir="-L$libdir"
689188de56ccSmrg	      add="-l$name"
689288de56ccSmrg	    elif test "$hardcode_shlibpath_var" = yes; then
689388de56ccSmrg	      case :$finalize_shlibpath: in
689488de56ccSmrg	      *":$libdir:"*) ;;
6895e9fcaa8aSmrg	      *) func_append finalize_shlibpath "$libdir:" ;;
689688de56ccSmrg	      esac
689788de56ccSmrg	      add="-l$name"
689888de56ccSmrg	    elif test "$hardcode_automatic" = yes; then
689988de56ccSmrg	      if test -n "$inst_prefix_dir" &&
690088de56ccSmrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
690188de56ccSmrg		add="$inst_prefix_dir$libdir/$linklib"
690288de56ccSmrg	      else
690388de56ccSmrg		add="$libdir/$linklib"
690488de56ccSmrg	      fi
690588de56ccSmrg	    else
690688de56ccSmrg	      # We cannot seem to hardcode it, guess we'll fake it.
690788de56ccSmrg	      add_dir="-L$libdir"
690888de56ccSmrg	      # Try looking first in the location we're being installed to.
690988de56ccSmrg	      if test -n "$inst_prefix_dir"; then
691088de56ccSmrg		case $libdir in
691188de56ccSmrg		  [\\/]*)
6912e9fcaa8aSmrg		    func_append add_dir " -L$inst_prefix_dir$libdir"
691388de56ccSmrg		    ;;
691488de56ccSmrg		esac
691588de56ccSmrg	      fi
691688de56ccSmrg	      add="-l$name"
691788de56ccSmrg	    fi
691888de56ccSmrg
691988de56ccSmrg	    if test "$linkmode" = prog; then
692088de56ccSmrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
692188de56ccSmrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
692288de56ccSmrg	    else
692388de56ccSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
692488de56ccSmrg	      test -n "$add" && deplibs="$add $deplibs"
692588de56ccSmrg	    fi
692688de56ccSmrg	  fi
692788de56ccSmrg	elif test "$linkmode" = prog; then
692888de56ccSmrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
692988de56ccSmrg	  # is not unsupported.  This is valid on all known static and
693088de56ccSmrg	  # shared platforms.
693188de56ccSmrg	  if test "$hardcode_direct" != unsupported; then
693288de56ccSmrg	    test -n "$old_library" && linklib="$old_library"
693388de56ccSmrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
693488de56ccSmrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
693588de56ccSmrg	  else
693688de56ccSmrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
693788de56ccSmrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
693888de56ccSmrg	  fi
693988de56ccSmrg	elif test "$build_libtool_libs" = yes; then
694088de56ccSmrg	  # Not a shared library
694188de56ccSmrg	  if test "$deplibs_check_method" != pass_all; then
694288de56ccSmrg	    # We're trying link a shared library against a static one
694388de56ccSmrg	    # but the system doesn't support it.
694488de56ccSmrg
694588de56ccSmrg	    # Just print a warning and add the library to dependency_libs so
694688de56ccSmrg	    # that the program can be linked against the static library.
6947e9fcaa8aSmrg	    echo
694888de56ccSmrg	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
6949e9fcaa8aSmrg	    echo "*** I have the capability to make that library automatically link in when"
6950e9fcaa8aSmrg	    echo "*** you link to this library.  But I can only do this if you have a"
6951e9fcaa8aSmrg	    echo "*** shared version of the library, which you do not appear to have."
695288de56ccSmrg	    if test "$module" = yes; then
6953e9fcaa8aSmrg	      echo "*** But as you try to build a module library, libtool will still create "
6954e9fcaa8aSmrg	      echo "*** a static module, that should work as long as the dlopening application"
6955e9fcaa8aSmrg	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
695688de56ccSmrg	      if test -z "$global_symbol_pipe"; then
6957e9fcaa8aSmrg		echo
6958e9fcaa8aSmrg		echo "*** However, this would only work if libtool was able to extract symbol"
6959e9fcaa8aSmrg		echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
6960e9fcaa8aSmrg		echo "*** not find such a program.  So, this module is probably useless."
6961e9fcaa8aSmrg		echo "*** \`nm' from GNU binutils and a full rebuild may help."
696288de56ccSmrg	      fi
696388de56ccSmrg	      if test "$build_old_libs" = no; then
696488de56ccSmrg		build_libtool_libs=module
696588de56ccSmrg		build_old_libs=yes
696688de56ccSmrg	      else
696788de56ccSmrg		build_libtool_libs=no
696888de56ccSmrg	      fi
696988de56ccSmrg	    fi
697088de56ccSmrg	  else
697188de56ccSmrg	    deplibs="$dir/$old_library $deplibs"
697288de56ccSmrg	    link_static=yes
697388de56ccSmrg	  fi
697488de56ccSmrg	fi # link shared/static library?
697588de56ccSmrg
697688de56ccSmrg	if test "$linkmode" = lib; then
697788de56ccSmrg	  if test -n "$dependency_libs" &&
697888de56ccSmrg	     { test "$hardcode_into_libs" != yes ||
697988de56ccSmrg	       test "$build_old_libs" = yes ||
698088de56ccSmrg	       test "$link_static" = yes; }; then
698188de56ccSmrg	    # Extract -R from dependency_libs
698288de56ccSmrg	    temp_deplibs=
698388de56ccSmrg	    for libdir in $dependency_libs; do
698488de56ccSmrg	      case $libdir in
698588de56ccSmrg	      -R*) func_stripname '-R' '' "$libdir"
698688de56ccSmrg	           temp_xrpath=$func_stripname_result
698788de56ccSmrg		   case " $xrpath " in
698888de56ccSmrg		   *" $temp_xrpath "*) ;;
6989e9fcaa8aSmrg		   *) func_append xrpath " $temp_xrpath";;
699088de56ccSmrg		   esac;;
6991e9fcaa8aSmrg	      *) func_append temp_deplibs " $libdir";;
699288de56ccSmrg	      esac
699388de56ccSmrg	    done
699488de56ccSmrg	    dependency_libs="$temp_deplibs"
699588de56ccSmrg	  fi
699688de56ccSmrg
6997e9fcaa8aSmrg	  func_append newlib_search_path " $absdir"
699888de56ccSmrg	  # Link against this library
699988de56ccSmrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
700088de56ccSmrg	  # ... and its dependency_libs
700188de56ccSmrg	  tmp_libs=
700288de56ccSmrg	  for deplib in $dependency_libs; do
700388de56ccSmrg	    newdependency_libs="$deplib $newdependency_libs"
7004e9fcaa8aSmrg	    case $deplib in
7005e9fcaa8aSmrg              -L*) func_stripname '-L' '' "$deplib"
7006e9fcaa8aSmrg                   func_resolve_sysroot "$func_stripname_result";;
7007e9fcaa8aSmrg              *) func_resolve_sysroot "$deplib" ;;
7008e9fcaa8aSmrg            esac
7009e9fcaa8aSmrg	    if $opt_preserve_dup_deps ; then
701088de56ccSmrg	      case "$tmp_libs " in
7011e9fcaa8aSmrg	      *" $func_resolve_sysroot_result "*)
7012e9fcaa8aSmrg                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
701388de56ccSmrg	      esac
701488de56ccSmrg	    fi
7015e9fcaa8aSmrg	    func_append tmp_libs " $func_resolve_sysroot_result"
701688de56ccSmrg	  done
701788de56ccSmrg
701888de56ccSmrg	  if test "$link_all_deplibs" != no; then
701988de56ccSmrg	    # Add the search paths of all dependency libraries
702088de56ccSmrg	    for deplib in $dependency_libs; do
702147f86ac1Smrg	      path=
702288de56ccSmrg	      case $deplib in
702388de56ccSmrg	      -L*) path="$deplib" ;;
702488de56ccSmrg	      *.la)
7025e9fcaa8aSmrg	        func_resolve_sysroot "$deplib"
7026e9fcaa8aSmrg	        deplib=$func_resolve_sysroot_result
702788de56ccSmrg	        func_dirname "$deplib" "" "."
7028e9fcaa8aSmrg		dir=$func_dirname_result
702988de56ccSmrg		# We need an absolute path.
703088de56ccSmrg		case $dir in
703188de56ccSmrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
703288de56ccSmrg		*)
703388de56ccSmrg		  absdir=`cd "$dir" && pwd`
703488de56ccSmrg		  if test -z "$absdir"; then
703588de56ccSmrg		    func_warning "cannot determine absolute directory name of \`$dir'"
703688de56ccSmrg		    absdir="$dir"
703788de56ccSmrg		  fi
703888de56ccSmrg		  ;;
703988de56ccSmrg		esac
704088de56ccSmrg		if $GREP "^installed=no" $deplib > /dev/null; then
704188de56ccSmrg		case $host in
704288de56ccSmrg		*-*-darwin*)
704388de56ccSmrg		  depdepl=
704488de56ccSmrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
704588de56ccSmrg		  if test -n "$deplibrary_names" ; then
704688de56ccSmrg		    for tmp in $deplibrary_names ; do
704788de56ccSmrg		      depdepl=$tmp
704888de56ccSmrg		    done
704988de56ccSmrg		    if test -f "$absdir/$objdir/$depdepl" ; then
705088de56ccSmrg		      depdepl="$absdir/$objdir/$depdepl"
705188de56ccSmrg		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
705288de56ccSmrg                      if test -z "$darwin_install_name"; then
705388de56ccSmrg                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
705488de56ccSmrg                      fi
7055e9fcaa8aSmrg		      func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
7056e9fcaa8aSmrg		      func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
705788de56ccSmrg		      path=
705888de56ccSmrg		    fi
705988de56ccSmrg		  fi
706088de56ccSmrg		  ;;
706188de56ccSmrg		*)
706288de56ccSmrg		  path="-L$absdir/$objdir"
706388de56ccSmrg		  ;;
706488de56ccSmrg		esac
706588de56ccSmrg		else
706688de56ccSmrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
706788de56ccSmrg		  test -z "$libdir" && \
706888de56ccSmrg		    func_fatal_error "\`$deplib' is not a valid libtool archive"
706988de56ccSmrg		  test "$absdir" != "$libdir" && \
707088de56ccSmrg		    func_warning "\`$deplib' seems to be moved"
707188de56ccSmrg
707288de56ccSmrg		  path="-L$absdir"
707388de56ccSmrg		fi
707488de56ccSmrg		;;
707588de56ccSmrg	      esac
707688de56ccSmrg	      case " $deplibs " in
707788de56ccSmrg	      *" $path "*) ;;
707888de56ccSmrg	      *) deplibs="$path $deplibs" ;;
707988de56ccSmrg	      esac
708088de56ccSmrg	    done
708188de56ccSmrg	  fi # link_all_deplibs != no
708288de56ccSmrg	fi # linkmode = lib
708388de56ccSmrg      done # for deplib in $libs
708488de56ccSmrg      if test "$pass" = link; then
708588de56ccSmrg	if test "$linkmode" = "prog"; then
708688de56ccSmrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
708788de56ccSmrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
708888de56ccSmrg	else
7089e9fcaa8aSmrg	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
709088de56ccSmrg	fi
709188de56ccSmrg      fi
709288de56ccSmrg      dependency_libs="$newdependency_libs"
709388de56ccSmrg      if test "$pass" = dlpreopen; then
709488de56ccSmrg	# Link the dlpreopened libraries before other libraries
709588de56ccSmrg	for deplib in $save_deplibs; do
709688de56ccSmrg	  deplibs="$deplib $deplibs"
709788de56ccSmrg	done
709888de56ccSmrg      fi
709988de56ccSmrg      if test "$pass" != dlopen; then
710088de56ccSmrg	if test "$pass" != conv; then
710188de56ccSmrg	  # Make sure lib_search_path contains only unique directories.
710288de56ccSmrg	  lib_search_path=
710388de56ccSmrg	  for dir in $newlib_search_path; do
710488de56ccSmrg	    case "$lib_search_path " in
710588de56ccSmrg	    *" $dir "*) ;;
7106e9fcaa8aSmrg	    *) func_append lib_search_path " $dir" ;;
710788de56ccSmrg	    esac
710888de56ccSmrg	  done
710988de56ccSmrg	  newlib_search_path=
711088de56ccSmrg	fi
711188de56ccSmrg
711288de56ccSmrg	if test "$linkmode,$pass" != "prog,link"; then
711388de56ccSmrg	  vars="deplibs"
711488de56ccSmrg	else
711588de56ccSmrg	  vars="compile_deplibs finalize_deplibs"
711688de56ccSmrg	fi
711788de56ccSmrg	for var in $vars dependency_libs; do
711888de56ccSmrg	  # Add libraries to $var in reverse order
711988de56ccSmrg	  eval tmp_libs=\"\$$var\"
712088de56ccSmrg	  new_libs=
712188de56ccSmrg	  for deplib in $tmp_libs; do
712288de56ccSmrg	    # FIXME: Pedantically, this is the right thing to do, so
712388de56ccSmrg	    #        that some nasty dependency loop isn't accidentally
712488de56ccSmrg	    #        broken:
712588de56ccSmrg	    #new_libs="$deplib $new_libs"
712688de56ccSmrg	    # Pragmatically, this seems to cause very few problems in
712788de56ccSmrg	    # practice:
712888de56ccSmrg	    case $deplib in
712988de56ccSmrg	    -L*) new_libs="$deplib $new_libs" ;;
713088de56ccSmrg	    -R*) ;;
713188de56ccSmrg	    *)
713288de56ccSmrg	      # And here is the reason: when a library appears more
713388de56ccSmrg	      # than once as an explicit dependence of a library, or
713488de56ccSmrg	      # is implicitly linked in more than once by the
713588de56ccSmrg	      # compiler, it is considered special, and multiple
713688de56ccSmrg	      # occurrences thereof are not removed.  Compare this
713788de56ccSmrg	      # with having the same library being listed as a
713888de56ccSmrg	      # dependency of multiple other libraries: in this case,
713988de56ccSmrg	      # we know (pedantically, we assume) the library does not
714088de56ccSmrg	      # need to be listed more than once, so we keep only the
714188de56ccSmrg	      # last copy.  This is not always right, but it is rare
714288de56ccSmrg	      # enough that we require users that really mean to play
714388de56ccSmrg	      # such unportable linking tricks to link the library
714488de56ccSmrg	      # using -Wl,-lname, so that libtool does not consider it
714588de56ccSmrg	      # for duplicate removal.
714688de56ccSmrg	      case " $specialdeplibs " in
714788de56ccSmrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
714888de56ccSmrg	      *)
714988de56ccSmrg		case " $new_libs " in
715088de56ccSmrg		*" $deplib "*) ;;
715188de56ccSmrg		*) new_libs="$deplib $new_libs" ;;
715288de56ccSmrg		esac
715388de56ccSmrg		;;
715488de56ccSmrg	      esac
715588de56ccSmrg	      ;;
715688de56ccSmrg	    esac
715788de56ccSmrg	  done
715888de56ccSmrg	  tmp_libs=
715988de56ccSmrg	  for deplib in $new_libs; do
716088de56ccSmrg	    case $deplib in
716188de56ccSmrg	    -L*)
716288de56ccSmrg	      case " $tmp_libs " in
716388de56ccSmrg	      *" $deplib "*) ;;
7164e9fcaa8aSmrg	      *) func_append tmp_libs " $deplib" ;;
716588de56ccSmrg	      esac
716688de56ccSmrg	      ;;
7167e9fcaa8aSmrg	    *) func_append tmp_libs " $deplib" ;;
716888de56ccSmrg	    esac
716988de56ccSmrg	  done
717088de56ccSmrg	  eval $var=\"$tmp_libs\"
717188de56ccSmrg	done # for var
717288de56ccSmrg      fi
717388de56ccSmrg      # Last step: remove runtime libs from dependency_libs
717488de56ccSmrg      # (they stay in deplibs)
717588de56ccSmrg      tmp_libs=
717688de56ccSmrg      for i in $dependency_libs ; do
717788de56ccSmrg	case " $predeps $postdeps $compiler_lib_search_path " in
717888de56ccSmrg	*" $i "*)
717988de56ccSmrg	  i=""
718088de56ccSmrg	  ;;
718188de56ccSmrg	esac
718288de56ccSmrg	if test -n "$i" ; then
7183e9fcaa8aSmrg	  func_append tmp_libs " $i"
718488de56ccSmrg	fi
718588de56ccSmrg      done
718688de56ccSmrg      dependency_libs=$tmp_libs
718788de56ccSmrg    done # for pass
718888de56ccSmrg    if test "$linkmode" = prog; then
718988de56ccSmrg      dlfiles="$newdlfiles"
719088de56ccSmrg    fi
719188de56ccSmrg    if test "$linkmode" = prog || test "$linkmode" = lib; then
719288de56ccSmrg      dlprefiles="$newdlprefiles"
719388de56ccSmrg    fi
719488de56ccSmrg
719588de56ccSmrg    case $linkmode in
719688de56ccSmrg    oldlib)
719788de56ccSmrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
719888de56ccSmrg	func_warning "\`-dlopen' is ignored for archives"
719988de56ccSmrg      fi
720088de56ccSmrg
720188de56ccSmrg      case " $deplibs" in
720288de56ccSmrg      *\ -l* | *\ -L*)
720388de56ccSmrg	func_warning "\`-l' and \`-L' are ignored for archives" ;;
720488de56ccSmrg      esac
720588de56ccSmrg
720688de56ccSmrg      test -n "$rpath" && \
720788de56ccSmrg	func_warning "\`-rpath' is ignored for archives"
720888de56ccSmrg
720988de56ccSmrg      test -n "$xrpath" && \
721088de56ccSmrg	func_warning "\`-R' is ignored for archives"
721188de56ccSmrg
721288de56ccSmrg      test -n "$vinfo" && \
721388de56ccSmrg	func_warning "\`-version-info/-version-number' is ignored for archives"
721488de56ccSmrg
721588de56ccSmrg      test -n "$release" && \
721688de56ccSmrg	func_warning "\`-release' is ignored for archives"
721788de56ccSmrg
721888de56ccSmrg      test -n "$export_symbols$export_symbols_regex" && \
721988de56ccSmrg	func_warning "\`-export-symbols' is ignored for archives"
722088de56ccSmrg
722188de56ccSmrg      # Now set the variables for building old libraries.
722288de56ccSmrg      build_libtool_libs=no
722388de56ccSmrg      oldlibs="$output"
7224e9fcaa8aSmrg      func_append objs "$old_deplibs"
722588de56ccSmrg      ;;
722688de56ccSmrg
722788de56ccSmrg    lib)
722888de56ccSmrg      # Make sure we only generate libraries of the form `libNAME.la'.
722988de56ccSmrg      case $outputname in
723088de56ccSmrg      lib*)
723188de56ccSmrg	func_stripname 'lib' '.la' "$outputname"
723288de56ccSmrg	name=$func_stripname_result
723388de56ccSmrg	eval shared_ext=\"$shrext_cmds\"
723488de56ccSmrg	eval libname=\"$libname_spec\"
723588de56ccSmrg	;;
723688de56ccSmrg      *)
723788de56ccSmrg	test "$module" = no && \
723888de56ccSmrg	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
723988de56ccSmrg
724088de56ccSmrg	if test "$need_lib_prefix" != no; then
724188de56ccSmrg	  # Add the "lib" prefix for modules if required
724288de56ccSmrg	  func_stripname '' '.la' "$outputname"
724388de56ccSmrg	  name=$func_stripname_result
724488de56ccSmrg	  eval shared_ext=\"$shrext_cmds\"
724588de56ccSmrg	  eval libname=\"$libname_spec\"
724688de56ccSmrg	else
724788de56ccSmrg	  func_stripname '' '.la' "$outputname"
724888de56ccSmrg	  libname=$func_stripname_result
724988de56ccSmrg	fi
725088de56ccSmrg	;;
725188de56ccSmrg      esac
725288de56ccSmrg
725388de56ccSmrg      if test -n "$objs"; then
725488de56ccSmrg	if test "$deplibs_check_method" != pass_all; then
725588de56ccSmrg	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
725688de56ccSmrg	else
7257e9fcaa8aSmrg	  echo
725888de56ccSmrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
725988de56ccSmrg	  $ECHO "*** objects $objs is not portable!"
7260e9fcaa8aSmrg	  func_append libobjs " $objs"
726188de56ccSmrg	fi
726288de56ccSmrg      fi
726388de56ccSmrg
726488de56ccSmrg      test "$dlself" != no && \
726588de56ccSmrg	func_warning "\`-dlopen self' is ignored for libtool libraries"
726688de56ccSmrg
726788de56ccSmrg      set dummy $rpath
726888de56ccSmrg      shift
726988de56ccSmrg      test "$#" -gt 1 && \
727088de56ccSmrg	func_warning "ignoring multiple \`-rpath's for a libtool library"
727188de56ccSmrg
727288de56ccSmrg      install_libdir="$1"
727388de56ccSmrg
727488de56ccSmrg      oldlibs=
727588de56ccSmrg      if test -z "$rpath"; then
727688de56ccSmrg	if test "$build_libtool_libs" = yes; then
727788de56ccSmrg	  # Building a libtool convenience library.
727888de56ccSmrg	  # Some compilers have problems with a `.al' extension so
727988de56ccSmrg	  # convenience libraries should have the same extension an
728088de56ccSmrg	  # archive normally would.
728188de56ccSmrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
728288de56ccSmrg	  build_libtool_libs=convenience
728388de56ccSmrg	  build_old_libs=yes
728488de56ccSmrg	fi
728588de56ccSmrg
728688de56ccSmrg	test -n "$vinfo" && \
728788de56ccSmrg	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
728888de56ccSmrg
728988de56ccSmrg	test -n "$release" && \
729088de56ccSmrg	  func_warning "\`-release' is ignored for convenience libraries"
729188de56ccSmrg      else
729288de56ccSmrg
729388de56ccSmrg	# Parse the version information argument.
729488de56ccSmrg	save_ifs="$IFS"; IFS=':'
729588de56ccSmrg	set dummy $vinfo 0 0 0
729688de56ccSmrg	shift
729788de56ccSmrg	IFS="$save_ifs"
729888de56ccSmrg
729988de56ccSmrg	test -n "$7" && \
730088de56ccSmrg	  func_fatal_help "too many parameters to \`-version-info'"
730188de56ccSmrg
730288de56ccSmrg	# convert absolute version numbers to libtool ages
730388de56ccSmrg	# this retains compatibility with .la files and attempts
730488de56ccSmrg	# to make the code below a bit more comprehensible
730588de56ccSmrg
730688de56ccSmrg	case $vinfo_number in
730788de56ccSmrg	yes)
730888de56ccSmrg	  number_major="$1"
730988de56ccSmrg	  number_minor="$2"
731088de56ccSmrg	  number_revision="$3"
731188de56ccSmrg	  #
731288de56ccSmrg	  # There are really only two kinds -- those that
731388de56ccSmrg	  # use the current revision as the major version
731488de56ccSmrg	  # and those that subtract age and use age as
731588de56ccSmrg	  # a minor version.  But, then there is irix
731688de56ccSmrg	  # which has an extra 1 added just for fun
731788de56ccSmrg	  #
731888de56ccSmrg	  case $version_type in
731988de56ccSmrg	  darwin|linux|osf|windows|none)
732088de56ccSmrg	    func_arith $number_major + $number_minor
732188de56ccSmrg	    current=$func_arith_result
732288de56ccSmrg	    age="$number_minor"
732388de56ccSmrg	    revision="$number_revision"
732488de56ccSmrg	    ;;
7325e9fcaa8aSmrg	  freebsd-aout|freebsd-elf|qnx|sunos)
732688de56ccSmrg	    current="$number_major"
732788de56ccSmrg	    revision="$number_minor"
732888de56ccSmrg	    age="0"
732988de56ccSmrg	    ;;
733088de56ccSmrg	  irix|nonstopux)
733188de56ccSmrg	    func_arith $number_major + $number_minor
733288de56ccSmrg	    current=$func_arith_result
733388de56ccSmrg	    age="$number_minor"
733488de56ccSmrg	    revision="$number_minor"
733588de56ccSmrg	    lt_irix_increment=no
733688de56ccSmrg	    ;;
733788de56ccSmrg	  esac
733888de56ccSmrg	  ;;
733988de56ccSmrg	no)
734088de56ccSmrg	  current="$1"
734188de56ccSmrg	  revision="$2"
734288de56ccSmrg	  age="$3"
734388de56ccSmrg	  ;;
734488de56ccSmrg	esac
734588de56ccSmrg
734688de56ccSmrg	# Check that each of the things are valid numbers.
734788de56ccSmrg	case $current in
734888de56ccSmrg	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]) ;;
734988de56ccSmrg	*)
735088de56ccSmrg	  func_error "CURRENT \`$current' must be a nonnegative integer"
735188de56ccSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
735288de56ccSmrg	  ;;
735388de56ccSmrg	esac
735488de56ccSmrg
735588de56ccSmrg	case $revision in
735688de56ccSmrg	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]) ;;
735788de56ccSmrg	*)
735888de56ccSmrg	  func_error "REVISION \`$revision' must be a nonnegative integer"
735988de56ccSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
736088de56ccSmrg	  ;;
736188de56ccSmrg	esac
736288de56ccSmrg
736388de56ccSmrg	case $age in
736488de56ccSmrg	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]) ;;
736588de56ccSmrg	*)
736688de56ccSmrg	  func_error "AGE \`$age' must be a nonnegative integer"
736788de56ccSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
736888de56ccSmrg	  ;;
736988de56ccSmrg	esac
737088de56ccSmrg
737188de56ccSmrg	if test "$age" -gt "$current"; then
737288de56ccSmrg	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
737388de56ccSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
737488de56ccSmrg	fi
737588de56ccSmrg
737688de56ccSmrg	# Calculate the version variables.
737788de56ccSmrg	major=
737888de56ccSmrg	versuffix=
737988de56ccSmrg	verstring=
738088de56ccSmrg	case $version_type in
738188de56ccSmrg	none) ;;
738288de56ccSmrg
738388de56ccSmrg	darwin)
738488de56ccSmrg	  # Like Linux, but with the current version available in
738588de56ccSmrg	  # verstring for coding it into the library header
738688de56ccSmrg	  func_arith $current - $age
738788de56ccSmrg	  major=.$func_arith_result
738888de56ccSmrg	  versuffix="$major.$age.$revision"
738988de56ccSmrg	  # Darwin ld doesn't like 0 for these options...
739088de56ccSmrg	  func_arith $current + 1
739188de56ccSmrg	  minor_current=$func_arith_result
739288de56ccSmrg	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
739388de56ccSmrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
739488de56ccSmrg	  ;;
739588de56ccSmrg
739688de56ccSmrg	freebsd-aout)
739788de56ccSmrg	  major=".$current"
739888de56ccSmrg	  versuffix=".$current.$revision";
739988de56ccSmrg	  ;;
740088de56ccSmrg
740188de56ccSmrg	freebsd-elf)
740288de56ccSmrg	  major=".$current"
740388de56ccSmrg	  versuffix=".$current"
740488de56ccSmrg	  ;;
740588de56ccSmrg
740688de56ccSmrg	irix | nonstopux)
740788de56ccSmrg	  if test "X$lt_irix_increment" = "Xno"; then
740888de56ccSmrg	    func_arith $current - $age
740988de56ccSmrg	  else
741088de56ccSmrg	    func_arith $current - $age + 1
741188de56ccSmrg	  fi
741288de56ccSmrg	  major=$func_arith_result
741388de56ccSmrg
741488de56ccSmrg	  case $version_type in
741588de56ccSmrg	    nonstopux) verstring_prefix=nonstopux ;;
741688de56ccSmrg	    *)         verstring_prefix=sgi ;;
741788de56ccSmrg	  esac
741888de56ccSmrg	  verstring="$verstring_prefix$major.$revision"
741988de56ccSmrg
742088de56ccSmrg	  # Add in all the interfaces that we are compatible with.
742188de56ccSmrg	  loop=$revision
742288de56ccSmrg	  while test "$loop" -ne 0; do
742388de56ccSmrg	    func_arith $revision - $loop
742488de56ccSmrg	    iface=$func_arith_result
742588de56ccSmrg	    func_arith $loop - 1
742688de56ccSmrg	    loop=$func_arith_result
742788de56ccSmrg	    verstring="$verstring_prefix$major.$iface:$verstring"
742888de56ccSmrg	  done
742988de56ccSmrg
743088de56ccSmrg	  # Before this point, $major must not contain `.'.
743188de56ccSmrg	  major=.$major
743288de56ccSmrg	  versuffix="$major.$revision"
743388de56ccSmrg	  ;;
743488de56ccSmrg
743588de56ccSmrg	linux)
743688de56ccSmrg	  func_arith $current - $age
743788de56ccSmrg	  major=.$func_arith_result
743888de56ccSmrg	  versuffix="$major.$age.$revision"
743988de56ccSmrg	  ;;
744088de56ccSmrg
744188de56ccSmrg	osf)
744288de56ccSmrg	  func_arith $current - $age
744388de56ccSmrg	  major=.$func_arith_result
744488de56ccSmrg	  versuffix=".$current.$age.$revision"
744588de56ccSmrg	  verstring="$current.$age.$revision"
744688de56ccSmrg
744788de56ccSmrg	  # Add in all the interfaces that we are compatible with.
744888de56ccSmrg	  loop=$age
744988de56ccSmrg	  while test "$loop" -ne 0; do
745088de56ccSmrg	    func_arith $current - $loop
745188de56ccSmrg	    iface=$func_arith_result
745288de56ccSmrg	    func_arith $loop - 1
745388de56ccSmrg	    loop=$func_arith_result
745488de56ccSmrg	    verstring="$verstring:${iface}.0"
745588de56ccSmrg	  done
745688de56ccSmrg
745788de56ccSmrg	  # Make executables depend on our current version.
7458e9fcaa8aSmrg	  func_append verstring ":${current}.0"
745988de56ccSmrg	  ;;
746088de56ccSmrg
746188de56ccSmrg	qnx)
746288de56ccSmrg	  major=".$current"
746388de56ccSmrg	  versuffix=".$current"
746488de56ccSmrg	  ;;
746588de56ccSmrg
746688de56ccSmrg	sunos)
746788de56ccSmrg	  major=".$current"
746888de56ccSmrg	  versuffix=".$current.$revision"
746988de56ccSmrg	  ;;
747088de56ccSmrg
747188de56ccSmrg	windows)
747288de56ccSmrg	  # Use '-' rather than '.', since we only want one
747388de56ccSmrg	  # extension on DOS 8.3 filesystems.
747488de56ccSmrg	  func_arith $current - $age
747588de56ccSmrg	  major=$func_arith_result
747688de56ccSmrg	  versuffix="-$major"
747788de56ccSmrg	  ;;
747888de56ccSmrg
747988de56ccSmrg	*)
748088de56ccSmrg	  func_fatal_configuration "unknown library version type \`$version_type'"
748188de56ccSmrg	  ;;
748288de56ccSmrg	esac
748388de56ccSmrg
748488de56ccSmrg	# Clear the version info if we defaulted, and they specified a release.
748588de56ccSmrg	if test -z "$vinfo" && test -n "$release"; then
748688de56ccSmrg	  major=
748788de56ccSmrg	  case $version_type in
748888de56ccSmrg	  darwin)
748988de56ccSmrg	    # we can't check for "0.0" in archive_cmds due to quoting
749088de56ccSmrg	    # problems, so we reset it completely
749188de56ccSmrg	    verstring=
749288de56ccSmrg	    ;;
749388de56ccSmrg	  *)
749488de56ccSmrg	    verstring="0.0"
749588de56ccSmrg	    ;;
749688de56ccSmrg	  esac
749788de56ccSmrg	  if test "$need_version" = no; then
749888de56ccSmrg	    versuffix=
749988de56ccSmrg	  else
750088de56ccSmrg	    versuffix=".0.0"
750188de56ccSmrg	  fi
750288de56ccSmrg	fi
750388de56ccSmrg
750488de56ccSmrg	# Remove version info from name if versioning should be avoided
750588de56ccSmrg	if test "$avoid_version" = yes && test "$need_version" = no; then
750688de56ccSmrg	  major=
750788de56ccSmrg	  versuffix=
750888de56ccSmrg	  verstring=""
750988de56ccSmrg	fi
751088de56ccSmrg
751188de56ccSmrg	# Check to see if the archive will have undefined symbols.
751288de56ccSmrg	if test "$allow_undefined" = yes; then
751388de56ccSmrg	  if test "$allow_undefined_flag" = unsupported; then
751488de56ccSmrg	    func_warning "undefined symbols not allowed in $host shared libraries"
751588de56ccSmrg	    build_libtool_libs=no
751688de56ccSmrg	    build_old_libs=yes
751788de56ccSmrg	  fi
751888de56ccSmrg	else
751988de56ccSmrg	  # Don't allow undefined symbols.
752088de56ccSmrg	  allow_undefined_flag="$no_undefined_flag"
752188de56ccSmrg	fi
752288de56ccSmrg
752388de56ccSmrg      fi
752488de56ccSmrg
752588de56ccSmrg      func_generate_dlsyms "$libname" "$libname" "yes"
7526e9fcaa8aSmrg      func_append libobjs " $symfileobj"
752788de56ccSmrg      test "X$libobjs" = "X " && libobjs=
752888de56ccSmrg
7529e9fcaa8aSmrg      if test "$opt_mode" != relink; then
753088de56ccSmrg	# Remove our outputs, but don't remove object files since they
753188de56ccSmrg	# may have been created when compiling PIC objects.
753288de56ccSmrg	removelist=
753388de56ccSmrg	tempremovelist=`$ECHO "$output_objdir/*"`
753488de56ccSmrg	for p in $tempremovelist; do
753588de56ccSmrg	  case $p in
753688de56ccSmrg	    *.$objext | *.gcno)
753788de56ccSmrg	       ;;
753888de56ccSmrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
753988de56ccSmrg	       if test "X$precious_files_regex" != "X"; then
754088de56ccSmrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
754188de56ccSmrg		 then
754288de56ccSmrg		   continue
754388de56ccSmrg		 fi
754488de56ccSmrg	       fi
7545e9fcaa8aSmrg	       func_append removelist " $p"
754688de56ccSmrg	       ;;
754788de56ccSmrg	    *) ;;
754888de56ccSmrg	  esac
754988de56ccSmrg	done
755088de56ccSmrg	test -n "$removelist" && \
755188de56ccSmrg	  func_show_eval "${RM}r \$removelist"
755288de56ccSmrg      fi
755388de56ccSmrg
755488de56ccSmrg      # Now set the variables for building old libraries.
755588de56ccSmrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
7556e9fcaa8aSmrg	func_append oldlibs " $output_objdir/$libname.$libext"
755788de56ccSmrg
755888de56ccSmrg	# Transform .lo files to .o files.
7559e9fcaa8aSmrg	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
756088de56ccSmrg      fi
756188de56ccSmrg
756288de56ccSmrg      # Eliminate all temporary directories.
756388de56ccSmrg      #for path in $notinst_path; do
7564e9fcaa8aSmrg      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
7565e9fcaa8aSmrg      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
7566e9fcaa8aSmrg      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
756788de56ccSmrg      #done
756888de56ccSmrg
756988de56ccSmrg      if test -n "$xrpath"; then
757088de56ccSmrg	# If the user specified any rpath flags, then add them.
757188de56ccSmrg	temp_xrpath=
757288de56ccSmrg	for libdir in $xrpath; do
7573e9fcaa8aSmrg	  func_replace_sysroot "$libdir"
7574e9fcaa8aSmrg	  func_append temp_xrpath " -R$func_replace_sysroot_result"
757588de56ccSmrg	  case "$finalize_rpath " in
757688de56ccSmrg	  *" $libdir "*) ;;
7577e9fcaa8aSmrg	  *) func_append finalize_rpath " $libdir" ;;
757888de56ccSmrg	  esac
757988de56ccSmrg	done
758088de56ccSmrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
758188de56ccSmrg	  dependency_libs="$temp_xrpath $dependency_libs"
758288de56ccSmrg	fi
758388de56ccSmrg      fi
758488de56ccSmrg
758588de56ccSmrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
758688de56ccSmrg      old_dlfiles="$dlfiles"
758788de56ccSmrg      dlfiles=
758888de56ccSmrg      for lib in $old_dlfiles; do
758988de56ccSmrg	case " $dlprefiles $dlfiles " in
759088de56ccSmrg	*" $lib "*) ;;
7591e9fcaa8aSmrg	*) func_append dlfiles " $lib" ;;
759288de56ccSmrg	esac
759388de56ccSmrg      done
759488de56ccSmrg
759588de56ccSmrg      # Make sure dlprefiles contains only unique files
759688de56ccSmrg      old_dlprefiles="$dlprefiles"
759788de56ccSmrg      dlprefiles=
759888de56ccSmrg      for lib in $old_dlprefiles; do
759988de56ccSmrg	case "$dlprefiles " in
760088de56ccSmrg	*" $lib "*) ;;
7601e9fcaa8aSmrg	*) func_append dlprefiles " $lib" ;;
760288de56ccSmrg	esac
760388de56ccSmrg      done
760488de56ccSmrg
760588de56ccSmrg      if test "$build_libtool_libs" = yes; then
760688de56ccSmrg	if test -n "$rpath"; then
760788de56ccSmrg	  case $host in
7608e9fcaa8aSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
760988de56ccSmrg	    # these systems don't actually have a c library (as such)!
761088de56ccSmrg	    ;;
761188de56ccSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
761288de56ccSmrg	    # Rhapsody C library is in the System framework
7613e9fcaa8aSmrg	    func_append deplibs " System.ltframework"
761488de56ccSmrg	    ;;
761588de56ccSmrg	  *-*-netbsd*)
761688de56ccSmrg	    # Don't link with libc until the a.out ld.so is fixed.
761788de56ccSmrg	    ;;
761888de56ccSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
761988de56ccSmrg	    # Do not include libc due to us having libc/libc_r.
762088de56ccSmrg	    ;;
762188de56ccSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
762288de56ccSmrg	    # Causes problems with __ctype
762388de56ccSmrg	    ;;
762488de56ccSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
762588de56ccSmrg	    # Compiler inserts libc in the correct place for threads to work
762688de56ccSmrg	    ;;
762788de56ccSmrg	  *)
762888de56ccSmrg	    # Add libc to deplibs on all other systems if necessary.
762988de56ccSmrg	    if test "$build_libtool_need_lc" = "yes"; then
7630e9fcaa8aSmrg	      func_append deplibs " -lc"
763188de56ccSmrg	    fi
763288de56ccSmrg	    ;;
763388de56ccSmrg	  esac
763488de56ccSmrg	fi
763588de56ccSmrg
763688de56ccSmrg	# Transform deplibs into only deplibs that can be linked in shared.
763788de56ccSmrg	name_save=$name
763888de56ccSmrg	libname_save=$libname
763988de56ccSmrg	release_save=$release
764088de56ccSmrg	versuffix_save=$versuffix
764188de56ccSmrg	major_save=$major
764288de56ccSmrg	# I'm not sure if I'm treating the release correctly.  I think
764388de56ccSmrg	# release should show up in the -l (ie -lgmp5) so we don't want to
764488de56ccSmrg	# add it in twice.  Is that correct?
764588de56ccSmrg	release=""
764688de56ccSmrg	versuffix=""
764788de56ccSmrg	major=""
764888de56ccSmrg	newdeplibs=
764988de56ccSmrg	droppeddeps=no
765088de56ccSmrg	case $deplibs_check_method in
765188de56ccSmrg	pass_all)
765288de56ccSmrg	  # Don't check for shared/static.  Everything works.
765388de56ccSmrg	  # This might be a little naive.  We might want to check
765488de56ccSmrg	  # whether the library exists or not.  But this is on
765588de56ccSmrg	  # osf3 & osf4 and I'm not really sure... Just
765688de56ccSmrg	  # implementing what was already the behavior.
765788de56ccSmrg	  newdeplibs=$deplibs
765888de56ccSmrg	  ;;
765988de56ccSmrg	test_compile)
766088de56ccSmrg	  # This code stresses the "libraries are programs" paradigm to its
766188de56ccSmrg	  # limits. Maybe even breaks it.  We compile a program, linking it
766288de56ccSmrg	  # against the deplibs as a proxy for the library.  Then we can check
766388de56ccSmrg	  # whether they linked in statically or dynamically with ldd.
766488de56ccSmrg	  $opt_dry_run || $RM conftest.c
766588de56ccSmrg	  cat > conftest.c <<EOF
766688de56ccSmrg	  int main() { return 0; }
766788de56ccSmrgEOF
766888de56ccSmrg	  $opt_dry_run || $RM conftest
766988de56ccSmrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
767088de56ccSmrg	    ldd_output=`ldd conftest`
767188de56ccSmrg	    for i in $deplibs; do
767288de56ccSmrg	      case $i in
767388de56ccSmrg	      -l*)
767488de56ccSmrg		func_stripname -l '' "$i"
767588de56ccSmrg		name=$func_stripname_result
767688de56ccSmrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
767788de56ccSmrg		  case " $predeps $postdeps " in
767888de56ccSmrg		  *" $i "*)
7679e9fcaa8aSmrg		    func_append newdeplibs " $i"
768088de56ccSmrg		    i=""
768188de56ccSmrg		    ;;
768288de56ccSmrg		  esac
768388de56ccSmrg		fi
768488de56ccSmrg		if test -n "$i" ; then
768588de56ccSmrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
768688de56ccSmrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
768788de56ccSmrg		  set dummy $deplib_matches; shift
768888de56ccSmrg		  deplib_match=$1
768988de56ccSmrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7690e9fcaa8aSmrg		    func_append newdeplibs " $i"
769188de56ccSmrg		  else
769288de56ccSmrg		    droppeddeps=yes
7693e9fcaa8aSmrg		    echo
769488de56ccSmrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
7695e9fcaa8aSmrg		    echo "*** I have the capability to make that library automatically link in when"
7696e9fcaa8aSmrg		    echo "*** you link to this library.  But I can only do this if you have a"
7697e9fcaa8aSmrg		    echo "*** shared version of the library, which I believe you do not have"
7698e9fcaa8aSmrg		    echo "*** because a test_compile did reveal that the linker did not use it for"
7699e9fcaa8aSmrg		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
770088de56ccSmrg		  fi
770188de56ccSmrg		fi
770288de56ccSmrg		;;
770388de56ccSmrg	      *)
7704e9fcaa8aSmrg		func_append newdeplibs " $i"
770588de56ccSmrg		;;
770688de56ccSmrg	      esac
770788de56ccSmrg	    done
770888de56ccSmrg	  else
770988de56ccSmrg	    # Error occurred in the first compile.  Let's try to salvage
771088de56ccSmrg	    # the situation: Compile a separate program for each library.
771188de56ccSmrg	    for i in $deplibs; do
771288de56ccSmrg	      case $i in
771388de56ccSmrg	      -l*)
771488de56ccSmrg		func_stripname -l '' "$i"
771588de56ccSmrg		name=$func_stripname_result
771688de56ccSmrg		$opt_dry_run || $RM conftest
771788de56ccSmrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
771888de56ccSmrg		  ldd_output=`ldd conftest`
771988de56ccSmrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
772088de56ccSmrg		    case " $predeps $postdeps " in
772188de56ccSmrg		    *" $i "*)
7722e9fcaa8aSmrg		      func_append newdeplibs " $i"
772388de56ccSmrg		      i=""
772488de56ccSmrg		      ;;
772588de56ccSmrg		    esac
772688de56ccSmrg		  fi
772788de56ccSmrg		  if test -n "$i" ; then
772888de56ccSmrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
772988de56ccSmrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
773088de56ccSmrg		    set dummy $deplib_matches; shift
773188de56ccSmrg		    deplib_match=$1
773288de56ccSmrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7733e9fcaa8aSmrg		      func_append newdeplibs " $i"
773488de56ccSmrg		    else
773588de56ccSmrg		      droppeddeps=yes
7736e9fcaa8aSmrg		      echo
773788de56ccSmrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
7738e9fcaa8aSmrg		      echo "*** I have the capability to make that library automatically link in when"
7739e9fcaa8aSmrg		      echo "*** you link to this library.  But I can only do this if you have a"
7740e9fcaa8aSmrg		      echo "*** shared version of the library, which you do not appear to have"
7741e9fcaa8aSmrg		      echo "*** because a test_compile did reveal that the linker did not use this one"
7742e9fcaa8aSmrg		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
774388de56ccSmrg		    fi
774488de56ccSmrg		  fi
774588de56ccSmrg		else
774688de56ccSmrg		  droppeddeps=yes
7747e9fcaa8aSmrg		  echo
774888de56ccSmrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
7749e9fcaa8aSmrg		  echo "*** make it link in!  You will probably need to install it or some"
7750e9fcaa8aSmrg		  echo "*** library that it depends on before this library will be fully"
7751e9fcaa8aSmrg		  echo "*** functional.  Installing it before continuing would be even better."
775288de56ccSmrg		fi
775388de56ccSmrg		;;
775488de56ccSmrg	      *)
7755e9fcaa8aSmrg		func_append newdeplibs " $i"
775688de56ccSmrg		;;
775788de56ccSmrg	      esac
775888de56ccSmrg	    done
775988de56ccSmrg	  fi
776088de56ccSmrg	  ;;
776188de56ccSmrg	file_magic*)
776288de56ccSmrg	  set dummy $deplibs_check_method; shift
776388de56ccSmrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
776488de56ccSmrg	  for a_deplib in $deplibs; do
776588de56ccSmrg	    case $a_deplib in
776688de56ccSmrg	    -l*)
776788de56ccSmrg	      func_stripname -l '' "$a_deplib"
776888de56ccSmrg	      name=$func_stripname_result
776988de56ccSmrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
777088de56ccSmrg		case " $predeps $postdeps " in
777188de56ccSmrg		*" $a_deplib "*)
7772e9fcaa8aSmrg		  func_append newdeplibs " $a_deplib"
777388de56ccSmrg		  a_deplib=""
777488de56ccSmrg		  ;;
777588de56ccSmrg		esac
777688de56ccSmrg	      fi
777788de56ccSmrg	      if test -n "$a_deplib" ; then
777888de56ccSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
7779e9fcaa8aSmrg		if test -n "$file_magic_glob"; then
7780e9fcaa8aSmrg		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
7781e9fcaa8aSmrg		else
7782e9fcaa8aSmrg		  libnameglob=$libname
7783e9fcaa8aSmrg		fi
7784e9fcaa8aSmrg		test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
778588de56ccSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7786e9fcaa8aSmrg		  if test "$want_nocaseglob" = yes; then
7787e9fcaa8aSmrg		    shopt -s nocaseglob
7788e9fcaa8aSmrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7789e9fcaa8aSmrg		    $nocaseglob
7790e9fcaa8aSmrg		  else
7791e9fcaa8aSmrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7792e9fcaa8aSmrg		  fi
779388de56ccSmrg		  for potent_lib in $potential_libs; do
779488de56ccSmrg		      # Follow soft links.
779588de56ccSmrg		      if ls -lLd "$potent_lib" 2>/dev/null |
779688de56ccSmrg			 $GREP " -> " >/dev/null; then
779788de56ccSmrg			continue
779888de56ccSmrg		      fi
779988de56ccSmrg		      # The statement above tries to avoid entering an
780088de56ccSmrg		      # endless loop below, in case of cyclic links.
780188de56ccSmrg		      # We might still enter an endless loop, since a link
780288de56ccSmrg		      # loop can be closed while we follow links,
780388de56ccSmrg		      # but so what?
780488de56ccSmrg		      potlib="$potent_lib"
780588de56ccSmrg		      while test -h "$potlib" 2>/dev/null; do
780688de56ccSmrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
780788de56ccSmrg			case $potliblink in
780888de56ccSmrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
7809e9fcaa8aSmrg			*) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
781088de56ccSmrg			esac
781188de56ccSmrg		      done
781288de56ccSmrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
781388de56ccSmrg			 $SED -e 10q |
781488de56ccSmrg			 $EGREP "$file_magic_regex" > /dev/null; then
7815e9fcaa8aSmrg			func_append newdeplibs " $a_deplib"
781688de56ccSmrg			a_deplib=""
781788de56ccSmrg			break 2
781888de56ccSmrg		      fi
781988de56ccSmrg		  done
782088de56ccSmrg		done
782188de56ccSmrg	      fi
782288de56ccSmrg	      if test -n "$a_deplib" ; then
782388de56ccSmrg		droppeddeps=yes
7824e9fcaa8aSmrg		echo
782588de56ccSmrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
7826e9fcaa8aSmrg		echo "*** I have the capability to make that library automatically link in when"
7827e9fcaa8aSmrg		echo "*** you link to this library.  But I can only do this if you have a"
7828e9fcaa8aSmrg		echo "*** shared version of the library, which you do not appear to have"
7829e9fcaa8aSmrg		echo "*** because I did check the linker path looking for a file starting"
783088de56ccSmrg		if test -z "$potlib" ; then
783188de56ccSmrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
783288de56ccSmrg		else
783388de56ccSmrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
783488de56ccSmrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
783588de56ccSmrg		fi
783688de56ccSmrg	      fi
783788de56ccSmrg	      ;;
783888de56ccSmrg	    *)
783988de56ccSmrg	      # Add a -L argument.
7840e9fcaa8aSmrg	      func_append newdeplibs " $a_deplib"
784188de56ccSmrg	      ;;
784288de56ccSmrg	    esac
784388de56ccSmrg	  done # Gone through all deplibs.
784488de56ccSmrg	  ;;
784588de56ccSmrg	match_pattern*)
784688de56ccSmrg	  set dummy $deplibs_check_method; shift
784788de56ccSmrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
784888de56ccSmrg	  for a_deplib in $deplibs; do
784988de56ccSmrg	    case $a_deplib in
785088de56ccSmrg	    -l*)
785188de56ccSmrg	      func_stripname -l '' "$a_deplib"
785288de56ccSmrg	      name=$func_stripname_result
785388de56ccSmrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
785488de56ccSmrg		case " $predeps $postdeps " in
785588de56ccSmrg		*" $a_deplib "*)
7856e9fcaa8aSmrg		  func_append newdeplibs " $a_deplib"
785788de56ccSmrg		  a_deplib=""
785888de56ccSmrg		  ;;
785988de56ccSmrg		esac
786088de56ccSmrg	      fi
786188de56ccSmrg	      if test -n "$a_deplib" ; then
786288de56ccSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
786388de56ccSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
786488de56ccSmrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
786588de56ccSmrg		  for potent_lib in $potential_libs; do
786688de56ccSmrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
7867e9fcaa8aSmrg		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
786888de56ccSmrg		       $EGREP "$match_pattern_regex" > /dev/null; then
7869e9fcaa8aSmrg		      func_append newdeplibs " $a_deplib"
787088de56ccSmrg		      a_deplib=""
787188de56ccSmrg		      break 2
787288de56ccSmrg		    fi
787388de56ccSmrg		  done
787488de56ccSmrg		done
787588de56ccSmrg	      fi
787688de56ccSmrg	      if test -n "$a_deplib" ; then
787788de56ccSmrg		droppeddeps=yes
7878e9fcaa8aSmrg		echo
787988de56ccSmrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
7880e9fcaa8aSmrg		echo "*** I have the capability to make that library automatically link in when"
7881e9fcaa8aSmrg		echo "*** you link to this library.  But I can only do this if you have a"
7882e9fcaa8aSmrg		echo "*** shared version of the library, which you do not appear to have"
7883e9fcaa8aSmrg		echo "*** because I did check the linker path looking for a file starting"
788488de56ccSmrg		if test -z "$potlib" ; then
788588de56ccSmrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
788688de56ccSmrg		else
788788de56ccSmrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
788888de56ccSmrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
788988de56ccSmrg		fi
789088de56ccSmrg	      fi
789188de56ccSmrg	      ;;
789288de56ccSmrg	    *)
789388de56ccSmrg	      # Add a -L argument.
7894e9fcaa8aSmrg	      func_append newdeplibs " $a_deplib"
789588de56ccSmrg	      ;;
789688de56ccSmrg	    esac
789788de56ccSmrg	  done # Gone through all deplibs.
789888de56ccSmrg	  ;;
789988de56ccSmrg	none | unknown | *)
790088de56ccSmrg	  newdeplibs=""
7901e9fcaa8aSmrg	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
790288de56ccSmrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
790388de56ccSmrg	    for i in $predeps $postdeps ; do
790488de56ccSmrg	      # can't use Xsed below, because $i might contain '/'
7905e9fcaa8aSmrg	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
790688de56ccSmrg	    done
790788de56ccSmrg	  fi
7908e9fcaa8aSmrg	  case $tmp_deplibs in
7909e9fcaa8aSmrg	  *[!\	\ ]*)
7910e9fcaa8aSmrg	    echo
791188de56ccSmrg	    if test "X$deplibs_check_method" = "Xnone"; then
7912e9fcaa8aSmrg	      echo "*** Warning: inter-library dependencies are not supported in this platform."
791388de56ccSmrg	    else
7914e9fcaa8aSmrg	      echo "*** Warning: inter-library dependencies are not known to be supported."
791588de56ccSmrg	    fi
7916e9fcaa8aSmrg	    echo "*** All declared inter-library dependencies are being dropped."
791788de56ccSmrg	    droppeddeps=yes
7918e9fcaa8aSmrg	    ;;
7919e9fcaa8aSmrg	  esac
792088de56ccSmrg	  ;;
792188de56ccSmrg	esac
792288de56ccSmrg	versuffix=$versuffix_save
792388de56ccSmrg	major=$major_save
792488de56ccSmrg	release=$release_save
792588de56ccSmrg	libname=$libname_save
792688de56ccSmrg	name=$name_save
792788de56ccSmrg
792888de56ccSmrg	case $host in
792988de56ccSmrg	*-*-rhapsody* | *-*-darwin1.[012])
793088de56ccSmrg	  # On Rhapsody replace the C library with the System framework
7931e9fcaa8aSmrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
793288de56ccSmrg	  ;;
793388de56ccSmrg	esac
793488de56ccSmrg
793588de56ccSmrg	if test "$droppeddeps" = yes; then
793688de56ccSmrg	  if test "$module" = yes; then
7937e9fcaa8aSmrg	    echo
7938e9fcaa8aSmrg	    echo "*** Warning: libtool could not satisfy all declared inter-library"
793988de56ccSmrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
7940e9fcaa8aSmrg	    echo "*** a static module, that should work as long as the dlopening"
7941e9fcaa8aSmrg	    echo "*** application is linked with the -dlopen flag."
794288de56ccSmrg	    if test -z "$global_symbol_pipe"; then
7943e9fcaa8aSmrg	      echo
7944e9fcaa8aSmrg	      echo "*** However, this would only work if libtool was able to extract symbol"
7945e9fcaa8aSmrg	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
7946e9fcaa8aSmrg	      echo "*** not find such a program.  So, this module is probably useless."
7947e9fcaa8aSmrg	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
794888de56ccSmrg	    fi
794988de56ccSmrg	    if test "$build_old_libs" = no; then
795088de56ccSmrg	      oldlibs="$output_objdir/$libname.$libext"
795188de56ccSmrg	      build_libtool_libs=module
795288de56ccSmrg	      build_old_libs=yes
795388de56ccSmrg	    else
795488de56ccSmrg	      build_libtool_libs=no
795588de56ccSmrg	    fi
795688de56ccSmrg	  else
7957e9fcaa8aSmrg	    echo "*** The inter-library dependencies that have been dropped here will be"
7958e9fcaa8aSmrg	    echo "*** automatically added whenever a program is linked with this library"
7959e9fcaa8aSmrg	    echo "*** or is declared to -dlopen it."
796088de56ccSmrg
796188de56ccSmrg	    if test "$allow_undefined" = no; then
7962e9fcaa8aSmrg	      echo
7963e9fcaa8aSmrg	      echo "*** Since this library must not contain undefined symbols,"
7964e9fcaa8aSmrg	      echo "*** because either the platform does not support them or"
7965e9fcaa8aSmrg	      echo "*** it was explicitly requested with -no-undefined,"
7966e9fcaa8aSmrg	      echo "*** libtool will only create a static version of it."
796788de56ccSmrg	      if test "$build_old_libs" = no; then
796888de56ccSmrg		oldlibs="$output_objdir/$libname.$libext"
796988de56ccSmrg		build_libtool_libs=module
797088de56ccSmrg		build_old_libs=yes
797188de56ccSmrg	      else
797288de56ccSmrg		build_libtool_libs=no
797388de56ccSmrg	      fi
797488de56ccSmrg	    fi
797588de56ccSmrg	  fi
797688de56ccSmrg	fi
797788de56ccSmrg	# Done checking deplibs!
797888de56ccSmrg	deplibs=$newdeplibs
797988de56ccSmrg      fi
798088de56ccSmrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
798188de56ccSmrg      case $host in
798288de56ccSmrg	*-*-darwin*)
7983e9fcaa8aSmrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7984e9fcaa8aSmrg	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7985e9fcaa8aSmrg	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
798688de56ccSmrg	  ;;
798788de56ccSmrg      esac
798888de56ccSmrg
798988de56ccSmrg      # move library search paths that coincide with paths to not yet
799088de56ccSmrg      # installed libraries to the beginning of the library search list
799188de56ccSmrg      new_libs=
799288de56ccSmrg      for path in $notinst_path; do
799388de56ccSmrg	case " $new_libs " in
799488de56ccSmrg	*" -L$path/$objdir "*) ;;
799588de56ccSmrg	*)
799688de56ccSmrg	  case " $deplibs " in
799788de56ccSmrg	  *" -L$path/$objdir "*)
7998e9fcaa8aSmrg	    func_append new_libs " -L$path/$objdir" ;;
799988de56ccSmrg	  esac
800088de56ccSmrg	  ;;
800188de56ccSmrg	esac
800288de56ccSmrg      done
800388de56ccSmrg      for deplib in $deplibs; do
800488de56ccSmrg	case $deplib in
800588de56ccSmrg	-L*)
800688de56ccSmrg	  case " $new_libs " in
800788de56ccSmrg	  *" $deplib "*) ;;
8008e9fcaa8aSmrg	  *) func_append new_libs " $deplib" ;;
800988de56ccSmrg	  esac
801088de56ccSmrg	  ;;
8011e9fcaa8aSmrg	*) func_append new_libs " $deplib" ;;
801288de56ccSmrg	esac
801388de56ccSmrg      done
801488de56ccSmrg      deplibs="$new_libs"
801588de56ccSmrg
801688de56ccSmrg      # All the library-specific variables (install_libdir is set above).
801788de56ccSmrg      library_names=
801888de56ccSmrg      old_library=
801988de56ccSmrg      dlname=
802088de56ccSmrg
802188de56ccSmrg      # Test again, we may have decided not to build it any more
802288de56ccSmrg      if test "$build_libtool_libs" = yes; then
802388de56ccSmrg	if test "$hardcode_into_libs" = yes; then
802488de56ccSmrg	  # Hardcode the library paths
802588de56ccSmrg	  hardcode_libdirs=
802688de56ccSmrg	  dep_rpath=
802788de56ccSmrg	  rpath="$finalize_rpath"
8028e9fcaa8aSmrg	  test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
802988de56ccSmrg	  for libdir in $rpath; do
803088de56ccSmrg	    if test -n "$hardcode_libdir_flag_spec"; then
803188de56ccSmrg	      if test -n "$hardcode_libdir_separator"; then
8032e9fcaa8aSmrg		func_replace_sysroot "$libdir"
8033e9fcaa8aSmrg		libdir=$func_replace_sysroot_result
803488de56ccSmrg		if test -z "$hardcode_libdirs"; then
803588de56ccSmrg		  hardcode_libdirs="$libdir"
803688de56ccSmrg		else
803788de56ccSmrg		  # Just accumulate the unique libdirs.
803888de56ccSmrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
803988de56ccSmrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
804088de56ccSmrg		    ;;
804188de56ccSmrg		  *)
8042e9fcaa8aSmrg		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
804388de56ccSmrg		    ;;
804488de56ccSmrg		  esac
804588de56ccSmrg		fi
804688de56ccSmrg	      else
804788de56ccSmrg		eval flag=\"$hardcode_libdir_flag_spec\"
8048e9fcaa8aSmrg		func_append dep_rpath " $flag"
804988de56ccSmrg	      fi
805088de56ccSmrg	    elif test -n "$runpath_var"; then
805188de56ccSmrg	      case "$perm_rpath " in
805288de56ccSmrg	      *" $libdir "*) ;;
8053e9fcaa8aSmrg	      *) func_apped perm_rpath " $libdir" ;;
805488de56ccSmrg	      esac
805588de56ccSmrg	    fi
805688de56ccSmrg	  done
805788de56ccSmrg	  # Substitute the hardcoded libdirs into the rpath.
805888de56ccSmrg	  if test -n "$hardcode_libdir_separator" &&
805988de56ccSmrg	     test -n "$hardcode_libdirs"; then
806088de56ccSmrg	    libdir="$hardcode_libdirs"
806188de56ccSmrg	    if test -n "$hardcode_libdir_flag_spec_ld"; then
806288de56ccSmrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
806388de56ccSmrg	    else
806488de56ccSmrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
806588de56ccSmrg	    fi
806688de56ccSmrg	  fi
806788de56ccSmrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
806888de56ccSmrg	    # We should set the runpath_var.
806988de56ccSmrg	    rpath=
807088de56ccSmrg	    for dir in $perm_rpath; do
8071e9fcaa8aSmrg	      func_append rpath "$dir:"
807288de56ccSmrg	    done
807388de56ccSmrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
807488de56ccSmrg	  fi
807588de56ccSmrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
807688de56ccSmrg	fi
80771ab64890Smrg
807888de56ccSmrg	shlibpath="$finalize_shlibpath"
8079e9fcaa8aSmrg	test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
808088de56ccSmrg	if test -n "$shlibpath"; then
808188de56ccSmrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
808288de56ccSmrg	fi
80831ab64890Smrg
808488de56ccSmrg	# Get the real and link names of the library.
808588de56ccSmrg	eval shared_ext=\"$shrext_cmds\"
808688de56ccSmrg	eval library_names=\"$library_names_spec\"
808788de56ccSmrg	set dummy $library_names
808888de56ccSmrg	shift
808988de56ccSmrg	realname="$1"
809088de56ccSmrg	shift
80911ab64890Smrg
809288de56ccSmrg	if test -n "$soname_spec"; then
809388de56ccSmrg	  eval soname=\"$soname_spec\"
809488de56ccSmrg	else
809588de56ccSmrg	  soname="$realname"
809688de56ccSmrg	fi
809788de56ccSmrg	if test -z "$dlname"; then
809888de56ccSmrg	  dlname=$soname
809988de56ccSmrg	fi
81001ab64890Smrg
810188de56ccSmrg	lib="$output_objdir/$realname"
810288de56ccSmrg	linknames=
810388de56ccSmrg	for link
810488de56ccSmrg	do
8105e9fcaa8aSmrg	  func_append linknames " $link"
810688de56ccSmrg	done
81071ab64890Smrg
810888de56ccSmrg	# Use standard objects if they are pic
8109e9fcaa8aSmrg	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
811088de56ccSmrg	test "X$libobjs" = "X " && libobjs=
81111ab64890Smrg
811288de56ccSmrg	delfiles=
811388de56ccSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
811488de56ccSmrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
811588de56ccSmrg	  export_symbols="$output_objdir/$libname.uexp"
8116e9fcaa8aSmrg	  func_append delfiles " $export_symbols"
811788de56ccSmrg	fi
81181ab64890Smrg
811988de56ccSmrg	orig_export_symbols=
812088de56ccSmrg	case $host_os in
812188de56ccSmrg	cygwin* | mingw* | cegcc*)
812288de56ccSmrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
812388de56ccSmrg	    # exporting using user supplied symfile
812488de56ccSmrg	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
812588de56ccSmrg	      # and it's NOT already a .def file. Must figure out
812688de56ccSmrg	      # which of the given symbols are data symbols and tag
812788de56ccSmrg	      # them as such. So, trigger use of export_symbols_cmds.
812888de56ccSmrg	      # export_symbols gets reassigned inside the "prepare
812988de56ccSmrg	      # the list of exported symbols" if statement, so the
813088de56ccSmrg	      # include_expsyms logic still works.
813188de56ccSmrg	      orig_export_symbols="$export_symbols"
813288de56ccSmrg	      export_symbols=
813388de56ccSmrg	      always_export_symbols=yes
813488de56ccSmrg	    fi
813588de56ccSmrg	  fi
813688de56ccSmrg	  ;;
813788de56ccSmrg	esac
81381ab64890Smrg
813988de56ccSmrg	# Prepare the list of exported symbols
814088de56ccSmrg	if test -z "$export_symbols"; then
814188de56ccSmrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
814288de56ccSmrg	    func_verbose "generating symbol list for \`$libname.la'"
814388de56ccSmrg	    export_symbols="$output_objdir/$libname.exp"
814488de56ccSmrg	    $opt_dry_run || $RM $export_symbols
814588de56ccSmrg	    cmds=$export_symbols_cmds
814688de56ccSmrg	    save_ifs="$IFS"; IFS='~'
8147e9fcaa8aSmrg	    for cmd1 in $cmds; do
814888de56ccSmrg	      IFS="$save_ifs"
8149e9fcaa8aSmrg	      # Take the normal branch if the nm_file_list_spec branch
8150e9fcaa8aSmrg	      # doesn't work or if tool conversion is not needed.
8151e9fcaa8aSmrg	      case $nm_file_list_spec~$to_tool_file_cmd in
8152e9fcaa8aSmrg		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
8153e9fcaa8aSmrg		  try_normal_branch=yes
8154e9fcaa8aSmrg		  eval cmd=\"$cmd1\"
8155e9fcaa8aSmrg		  func_len " $cmd"
8156e9fcaa8aSmrg		  len=$func_len_result
8157e9fcaa8aSmrg		  ;;
8158e9fcaa8aSmrg		*)
8159e9fcaa8aSmrg		  try_normal_branch=no
8160e9fcaa8aSmrg		  ;;
8161e9fcaa8aSmrg	      esac
8162e9fcaa8aSmrg	      if test "$try_normal_branch" = yes \
8163e9fcaa8aSmrg		 && { test "$len" -lt "$max_cmd_len" \
8164e9fcaa8aSmrg		      || test "$max_cmd_len" -le -1; }
8165e9fcaa8aSmrg	      then
8166e9fcaa8aSmrg		func_show_eval "$cmd" 'exit $?'
8167e9fcaa8aSmrg		skipped_export=false
8168e9fcaa8aSmrg	      elif test -n "$nm_file_list_spec"; then
8169e9fcaa8aSmrg		func_basename "$output"
8170e9fcaa8aSmrg		output_la=$func_basename_result
8171e9fcaa8aSmrg		save_libobjs=$libobjs
8172e9fcaa8aSmrg		save_output=$output
8173e9fcaa8aSmrg		output=${output_objdir}/${output_la}.nm
8174e9fcaa8aSmrg		func_to_tool_file "$output"
8175e9fcaa8aSmrg		libobjs=$nm_file_list_spec$func_to_tool_file_result
8176e9fcaa8aSmrg		func_append delfiles " $output"
8177e9fcaa8aSmrg		func_verbose "creating $NM input file list: $output"
8178e9fcaa8aSmrg		for obj in $save_libobjs; do
8179e9fcaa8aSmrg		  func_to_tool_file "$obj"
8180e9fcaa8aSmrg		  $ECHO "$func_to_tool_file_result"
8181e9fcaa8aSmrg		done > "$output"
8182e9fcaa8aSmrg		eval cmd=\"$cmd1\"
818388de56ccSmrg		func_show_eval "$cmd" 'exit $?'
8184e9fcaa8aSmrg		output=$save_output
8185e9fcaa8aSmrg		libobjs=$save_libobjs
818688de56ccSmrg		skipped_export=false
818788de56ccSmrg	      else
818888de56ccSmrg		# The command line is too long to execute in one step.
818988de56ccSmrg		func_verbose "using reloadable object file for export list..."
819088de56ccSmrg		skipped_export=:
819188de56ccSmrg		# Break out early, otherwise skipped_export may be
819288de56ccSmrg		# set to false by a later but shorter cmd.
819388de56ccSmrg		break
819488de56ccSmrg	      fi
819588de56ccSmrg	    done
819688de56ccSmrg	    IFS="$save_ifs"
819788de56ccSmrg	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
819888de56ccSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
819988de56ccSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
820088de56ccSmrg	    fi
820188de56ccSmrg	  fi
82021ab64890Smrg	fi
82031ab64890Smrg
820488de56ccSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
820588de56ccSmrg	  tmp_export_symbols="$export_symbols"
820688de56ccSmrg	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
8207e9fcaa8aSmrg	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
820888de56ccSmrg	fi
82091ab64890Smrg
821088de56ccSmrg	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
821188de56ccSmrg	  # The given exports_symbols file has to be filtered, so filter it.
821288de56ccSmrg	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
821388de56ccSmrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
821488de56ccSmrg	  # 's' commands which not all seds can handle. GNU sed should be fine
821588de56ccSmrg	  # though. Also, the filter scales superlinearly with the number of
821688de56ccSmrg	  # global variables. join(1) would be nice here, but unfortunately
821788de56ccSmrg	  # isn't a blessed tool.
821888de56ccSmrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8219e9fcaa8aSmrg	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
822088de56ccSmrg	  export_symbols=$output_objdir/$libname.def
822188de56ccSmrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
822288de56ccSmrg	fi
82231ab64890Smrg
822488de56ccSmrg	tmp_deplibs=
822588de56ccSmrg	for test_deplib in $deplibs; do
822688de56ccSmrg	  case " $convenience " in
822788de56ccSmrg	  *" $test_deplib "*) ;;
822888de56ccSmrg	  *)
8229e9fcaa8aSmrg	    func_append tmp_deplibs " $test_deplib"
823088de56ccSmrg	    ;;
823188de56ccSmrg	  esac
823288de56ccSmrg	done
823388de56ccSmrg	deplibs="$tmp_deplibs"
82341ab64890Smrg
823588de56ccSmrg	if test -n "$convenience"; then
823688de56ccSmrg	  if test -n "$whole_archive_flag_spec" &&
823788de56ccSmrg	    test "$compiler_needs_object" = yes &&
823888de56ccSmrg	    test -z "$libobjs"; then
823988de56ccSmrg	    # extract the archives, so we have objects to list.
824088de56ccSmrg	    # TODO: could optimize this to just extract one archive.
824188de56ccSmrg	    whole_archive_flag_spec=
824288de56ccSmrg	  fi
824388de56ccSmrg	  if test -n "$whole_archive_flag_spec"; then
824488de56ccSmrg	    save_libobjs=$libobjs
824588de56ccSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
824688de56ccSmrg	    test "X$libobjs" = "X " && libobjs=
824788de56ccSmrg	  else
824888de56ccSmrg	    gentop="$output_objdir/${outputname}x"
8249e9fcaa8aSmrg	    func_append generated " $gentop"
82501ab64890Smrg
825188de56ccSmrg	    func_extract_archives $gentop $convenience
8252e9fcaa8aSmrg	    func_append libobjs " $func_extract_archives_result"
825388de56ccSmrg	    test "X$libobjs" = "X " && libobjs=
825488de56ccSmrg	  fi
8255b4ee4795Smrg	fi
82561ab64890Smrg
825788de56ccSmrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
825888de56ccSmrg	  eval flag=\"$thread_safe_flag_spec\"
8259e9fcaa8aSmrg	  func_append linker_flags " $flag"
8260b4ee4795Smrg	fi
82612e9c7c8cSmrg
826288de56ccSmrg	# Make a backup of the uninstalled library when relinking
8263e9fcaa8aSmrg	if test "$opt_mode" = relink; then
826488de56ccSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
826588de56ccSmrg	fi
82661ab64890Smrg
826788de56ccSmrg	# Do each of the archive commands.
826888de56ccSmrg	if test "$module" = yes && test -n "$module_cmds" ; then
826988de56ccSmrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
827088de56ccSmrg	    eval test_cmds=\"$module_expsym_cmds\"
827188de56ccSmrg	    cmds=$module_expsym_cmds
827288de56ccSmrg	  else
827388de56ccSmrg	    eval test_cmds=\"$module_cmds\"
827488de56ccSmrg	    cmds=$module_cmds
827588de56ccSmrg	  fi
8276b4ee4795Smrg	else
827788de56ccSmrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
827888de56ccSmrg	    eval test_cmds=\"$archive_expsym_cmds\"
827988de56ccSmrg	    cmds=$archive_expsym_cmds
828088de56ccSmrg	  else
828188de56ccSmrg	    eval test_cmds=\"$archive_cmds\"
828288de56ccSmrg	    cmds=$archive_cmds
828388de56ccSmrg	  fi
8284b4ee4795Smrg	fi
82851ab64890Smrg
828688de56ccSmrg	if test "X$skipped_export" != "X:" &&
828788de56ccSmrg	   func_len " $test_cmds" &&
828888de56ccSmrg	   len=$func_len_result &&
828988de56ccSmrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
829088de56ccSmrg	  :
829188de56ccSmrg	else
829288de56ccSmrg	  # The command line is too long to link in one step, link piecewise
829388de56ccSmrg	  # or, if using GNU ld and skipped_export is not :, use a linker
829488de56ccSmrg	  # script.
82951ab64890Smrg
829688de56ccSmrg	  # Save the value of $output and $libobjs because we want to
829788de56ccSmrg	  # use them later.  If we have whole_archive_flag_spec, we
829888de56ccSmrg	  # want to use save_libobjs as it was before
829988de56ccSmrg	  # whole_archive_flag_spec was expanded, because we can't
830088de56ccSmrg	  # assume the linker understands whole_archive_flag_spec.
830188de56ccSmrg	  # This may have to be revisited, in case too many
830288de56ccSmrg	  # convenience libraries get linked in and end up exceeding
830388de56ccSmrg	  # the spec.
830488de56ccSmrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
830588de56ccSmrg	    save_libobjs=$libobjs
830688de56ccSmrg	  fi
830788de56ccSmrg	  save_output=$output
8308e9fcaa8aSmrg	  func_basename "$output"
8309e9fcaa8aSmrg	  output_la=$func_basename_result
83101ab64890Smrg
831188de56ccSmrg	  # Clear the reloadable object creation command queue and
831288de56ccSmrg	  # initialize k to one.
831388de56ccSmrg	  test_cmds=
831488de56ccSmrg	  concat_cmds=
831588de56ccSmrg	  objlist=
831688de56ccSmrg	  last_robj=
831788de56ccSmrg	  k=1
831888de56ccSmrg
831988de56ccSmrg	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
832088de56ccSmrg	    output=${output_objdir}/${output_la}.lnkscript
832188de56ccSmrg	    func_verbose "creating GNU ld script: $output"
8322e9fcaa8aSmrg	    echo 'INPUT (' > $output
832388de56ccSmrg	    for obj in $save_libobjs
8324b4ee4795Smrg	    do
8325e9fcaa8aSmrg	      func_to_tool_file "$obj"
8326e9fcaa8aSmrg	      $ECHO "$func_to_tool_file_result" >> $output
832788de56ccSmrg	    done
8328e9fcaa8aSmrg	    echo ')' >> $output
8329e9fcaa8aSmrg	    func_append delfiles " $output"
8330e9fcaa8aSmrg	    func_to_tool_file "$output"
8331e9fcaa8aSmrg	    output=$func_to_tool_file_result
833288de56ccSmrg	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
833388de56ccSmrg	    output=${output_objdir}/${output_la}.lnk
833488de56ccSmrg	    func_verbose "creating linker input file list: $output"
833588de56ccSmrg	    : > $output
833688de56ccSmrg	    set x $save_libobjs
833788de56ccSmrg	    shift
833888de56ccSmrg	    firstobj=
833988de56ccSmrg	    if test "$compiler_needs_object" = yes; then
834088de56ccSmrg	      firstobj="$1 "
834188de56ccSmrg	      shift
834288de56ccSmrg	    fi
834388de56ccSmrg	    for obj
834488de56ccSmrg	    do
8345e9fcaa8aSmrg	      func_to_tool_file "$obj"
8346e9fcaa8aSmrg	      $ECHO "$func_to_tool_file_result" >> $output
834788de56ccSmrg	    done
8348e9fcaa8aSmrg	    func_append delfiles " $output"
8349e9fcaa8aSmrg	    func_to_tool_file "$output"
8350e9fcaa8aSmrg	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
835188de56ccSmrg	  else
835288de56ccSmrg	    if test -n "$save_libobjs"; then
835388de56ccSmrg	      func_verbose "creating reloadable object files..."
835488de56ccSmrg	      output=$output_objdir/$output_la-${k}.$objext
835588de56ccSmrg	      eval test_cmds=\"$reload_cmds\"
835688de56ccSmrg	      func_len " $test_cmds"
835788de56ccSmrg	      len0=$func_len_result
835888de56ccSmrg	      len=$len0
835988de56ccSmrg
836088de56ccSmrg	      # Loop over the list of objects to be linked.
836188de56ccSmrg	      for obj in $save_libobjs
836288de56ccSmrg	      do
836388de56ccSmrg		func_len " $obj"
836488de56ccSmrg		func_arith $len + $func_len_result
836588de56ccSmrg		len=$func_arith_result
836688de56ccSmrg		if test "X$objlist" = X ||
836788de56ccSmrg		   test "$len" -lt "$max_cmd_len"; then
836888de56ccSmrg		  func_append objlist " $obj"
836988de56ccSmrg		else
837088de56ccSmrg		  # The command $test_cmds is almost too long, add a
837188de56ccSmrg		  # command to the queue.
837288de56ccSmrg		  if test "$k" -eq 1 ; then
837388de56ccSmrg		    # The first file doesn't have a previous command to add.
8374e9fcaa8aSmrg		    reload_objs=$objlist
8375e9fcaa8aSmrg		    eval concat_cmds=\"$reload_cmds\"
837688de56ccSmrg		  else
837788de56ccSmrg		    # All subsequent reloadable object files will link in
837888de56ccSmrg		    # the last one created.
8379e9fcaa8aSmrg		    reload_objs="$objlist $last_robj"
8380e9fcaa8aSmrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
838188de56ccSmrg		  fi
838288de56ccSmrg		  last_robj=$output_objdir/$output_la-${k}.$objext
838388de56ccSmrg		  func_arith $k + 1
838488de56ccSmrg		  k=$func_arith_result
838588de56ccSmrg		  output=$output_objdir/$output_la-${k}.$objext
8386e9fcaa8aSmrg		  objlist=" $obj"
838788de56ccSmrg		  func_len " $last_robj"
838888de56ccSmrg		  func_arith $len0 + $func_len_result
838988de56ccSmrg		  len=$func_arith_result
839088de56ccSmrg		fi
839188de56ccSmrg	      done
839288de56ccSmrg	      # Handle the remaining objects by creating one last
839388de56ccSmrg	      # reloadable object file.  All subsequent reloadable object
839488de56ccSmrg	      # files will link in the last one created.
839588de56ccSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8396e9fcaa8aSmrg	      reload_objs="$objlist $last_robj"
8397e9fcaa8aSmrg	      eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
839888de56ccSmrg	      if test -n "$last_robj"; then
839988de56ccSmrg	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
840088de56ccSmrg	      fi
8401e9fcaa8aSmrg	      func_append delfiles " $output"
84021ab64890Smrg
840388de56ccSmrg	    else
840488de56ccSmrg	      output=
840588de56ccSmrg	    fi
84061ab64890Smrg
840788de56ccSmrg	    if ${skipped_export-false}; then
840888de56ccSmrg	      func_verbose "generating symbol list for \`$libname.la'"
840988de56ccSmrg	      export_symbols="$output_objdir/$libname.exp"
841088de56ccSmrg	      $opt_dry_run || $RM $export_symbols
841188de56ccSmrg	      libobjs=$output
841288de56ccSmrg	      # Append the command to create the export file.
841388de56ccSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
841488de56ccSmrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
841588de56ccSmrg	      if test -n "$last_robj"; then
841688de56ccSmrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
841788de56ccSmrg	      fi
84182e9c7c8cSmrg	    fi
84191ab64890Smrg
842088de56ccSmrg	    test -n "$save_libobjs" &&
842188de56ccSmrg	      func_verbose "creating a temporary reloadable object file: $output"
84221ab64890Smrg
842388de56ccSmrg	    # Loop through the commands generated above and execute them.
842488de56ccSmrg	    save_ifs="$IFS"; IFS='~'
842588de56ccSmrg	    for cmd in $concat_cmds; do
842688de56ccSmrg	      IFS="$save_ifs"
842788de56ccSmrg	      $opt_silent || {
842888de56ccSmrg		  func_quote_for_expand "$cmd"
842988de56ccSmrg		  eval "func_echo $func_quote_for_expand_result"
843088de56ccSmrg	      }
843188de56ccSmrg	      $opt_dry_run || eval "$cmd" || {
843288de56ccSmrg		lt_exit=$?
843388de56ccSmrg
843488de56ccSmrg		# Restore the uninstalled library and exit
8435e9fcaa8aSmrg		if test "$opt_mode" = relink; then
843688de56ccSmrg		  ( cd "$output_objdir" && \
843788de56ccSmrg		    $RM "${realname}T" && \
843888de56ccSmrg		    $MV "${realname}U" "$realname" )
843988de56ccSmrg		fi
84401ab64890Smrg
844188de56ccSmrg		exit $lt_exit
844288de56ccSmrg	      }
844388de56ccSmrg	    done
844488de56ccSmrg	    IFS="$save_ifs"
8445b4ee4795Smrg
844688de56ccSmrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
844788de56ccSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
844888de56ccSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
84491ab64890Smrg	    fi
84501ab64890Smrg	  fi
84511ab64890Smrg
845288de56ccSmrg          if ${skipped_export-false}; then
845388de56ccSmrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
845488de56ccSmrg	      tmp_export_symbols="$export_symbols"
845588de56ccSmrg	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
8456e9fcaa8aSmrg	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
845788de56ccSmrg	    fi
84582e9c7c8cSmrg
845988de56ccSmrg	    if test -n "$orig_export_symbols"; then
846088de56ccSmrg	      # The given exports_symbols file has to be filtered, so filter it.
846188de56ccSmrg	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
846288de56ccSmrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
846388de56ccSmrg	      # 's' commands which not all seds can handle. GNU sed should be fine
846488de56ccSmrg	      # though. Also, the filter scales superlinearly with the number of
846588de56ccSmrg	      # global variables. join(1) would be nice here, but unfortunately
846688de56ccSmrg	      # isn't a blessed tool.
846788de56ccSmrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8468e9fcaa8aSmrg	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
846988de56ccSmrg	      export_symbols=$output_objdir/$libname.def
847088de56ccSmrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
847188de56ccSmrg	    fi
847288de56ccSmrg	  fi
84731ab64890Smrg
847488de56ccSmrg	  libobjs=$output
847588de56ccSmrg	  # Restore the value of output.
847688de56ccSmrg	  output=$save_output
84771ab64890Smrg
847888de56ccSmrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
847988de56ccSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
848088de56ccSmrg	    test "X$libobjs" = "X " && libobjs=
848188de56ccSmrg	  fi
848288de56ccSmrg	  # Expand the library linking commands again to reset the
848388de56ccSmrg	  # value of $libobjs for piecewise linking.
84841ab64890Smrg
848588de56ccSmrg	  # Do each of the archive commands.
848688de56ccSmrg	  if test "$module" = yes && test -n "$module_cmds" ; then
848788de56ccSmrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
848888de56ccSmrg	      cmds=$module_expsym_cmds
848988de56ccSmrg	    else
849088de56ccSmrg	      cmds=$module_cmds
8491b4ee4795Smrg	    fi
8492b4ee4795Smrg	  else
849388de56ccSmrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
849488de56ccSmrg	      cmds=$archive_expsym_cmds
849588de56ccSmrg	    else
849688de56ccSmrg	      cmds=$archive_cmds
849788de56ccSmrg	    fi
8498b4ee4795Smrg	  fi
849988de56ccSmrg	fi
85001ab64890Smrg
850188de56ccSmrg	if test -n "$delfiles"; then
850288de56ccSmrg	  # Append the command to remove temporary files to $cmds.
850388de56ccSmrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
850488de56ccSmrg	fi
85051ab64890Smrg
850688de56ccSmrg	# Add any objects from preloaded convenience libraries
850788de56ccSmrg	if test -n "$dlprefiles"; then
850888de56ccSmrg	  gentop="$output_objdir/${outputname}x"
8509e9fcaa8aSmrg	  func_append generated " $gentop"
85101ab64890Smrg
851188de56ccSmrg	  func_extract_archives $gentop $dlprefiles
8512e9fcaa8aSmrg	  func_append libobjs " $func_extract_archives_result"
851388de56ccSmrg	  test "X$libobjs" = "X " && libobjs=
851488de56ccSmrg	fi
85151ab64890Smrg
851688de56ccSmrg	save_ifs="$IFS"; IFS='~'
851788de56ccSmrg	for cmd in $cmds; do
851888de56ccSmrg	  IFS="$save_ifs"
851988de56ccSmrg	  eval cmd=\"$cmd\"
852088de56ccSmrg	  $opt_silent || {
852188de56ccSmrg	    func_quote_for_expand "$cmd"
852288de56ccSmrg	    eval "func_echo $func_quote_for_expand_result"
852388de56ccSmrg	  }
852488de56ccSmrg	  $opt_dry_run || eval "$cmd" || {
852588de56ccSmrg	    lt_exit=$?
85262e9c7c8cSmrg
852788de56ccSmrg	    # Restore the uninstalled library and exit
8528e9fcaa8aSmrg	    if test "$opt_mode" = relink; then
852988de56ccSmrg	      ( cd "$output_objdir" && \
853088de56ccSmrg	        $RM "${realname}T" && \
853188de56ccSmrg		$MV "${realname}U" "$realname" )
853288de56ccSmrg	    fi
85332e9c7c8cSmrg
853488de56ccSmrg	    exit $lt_exit
853588de56ccSmrg	  }
853688de56ccSmrg	done
853788de56ccSmrg	IFS="$save_ifs"
85382e9c7c8cSmrg
853988de56ccSmrg	# Restore the uninstalled library and exit
8540e9fcaa8aSmrg	if test "$opt_mode" = relink; then
854188de56ccSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
85422e9c7c8cSmrg
854388de56ccSmrg	  if test -n "$convenience"; then
854488de56ccSmrg	    if test -z "$whole_archive_flag_spec"; then
854588de56ccSmrg	      func_show_eval '${RM}r "$gentop"'
854688de56ccSmrg	    fi
854788de56ccSmrg	  fi
85482e9c7c8cSmrg
854988de56ccSmrg	  exit $EXIT_SUCCESS
855088de56ccSmrg	fi
855188de56ccSmrg
855288de56ccSmrg	# Create links to the real library.
855388de56ccSmrg	for linkname in $linknames; do
855488de56ccSmrg	  if test "$realname" != "$linkname"; then
855588de56ccSmrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
8556b4ee4795Smrg	  fi
8557b4ee4795Smrg	done
85582e9c7c8cSmrg
855988de56ccSmrg	# If -module or -export-dynamic was specified, set the dlname.
856088de56ccSmrg	if test "$module" = yes || test "$export_dynamic" = yes; then
856188de56ccSmrg	  # On all known operating systems, these are identical.
856288de56ccSmrg	  dlname="$soname"
856388de56ccSmrg	fi
856488de56ccSmrg      fi
85651ab64890Smrg      ;;
85661ab64890Smrg
856788de56ccSmrg    obj)
856888de56ccSmrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
856988de56ccSmrg	func_warning "\`-dlopen' is ignored for objects"
857088de56ccSmrg      fi
8571b4ee4795Smrg
857288de56ccSmrg      case " $deplibs" in
857388de56ccSmrg      *\ -l* | *\ -L*)
857488de56ccSmrg	func_warning "\`-l' and \`-L' are ignored for objects" ;;
85752e9c7c8cSmrg      esac
85761ab64890Smrg
857788de56ccSmrg      test -n "$rpath" && \
857888de56ccSmrg	func_warning "\`-rpath' is ignored for objects"
857988de56ccSmrg
858088de56ccSmrg      test -n "$xrpath" && \
858188de56ccSmrg	func_warning "\`-R' is ignored for objects"
85821ab64890Smrg
858388de56ccSmrg      test -n "$vinfo" && \
858488de56ccSmrg	func_warning "\`-version-info' is ignored for objects"
85852e9c7c8cSmrg
858688de56ccSmrg      test -n "$release" && \
858788de56ccSmrg	func_warning "\`-release' is ignored for objects"
858888de56ccSmrg
858988de56ccSmrg      case $output in
859088de56ccSmrg      *.lo)
859188de56ccSmrg	test -n "$objs$old_deplibs" && \
859288de56ccSmrg	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
859388de56ccSmrg
859488de56ccSmrg	libobj=$output
859588de56ccSmrg	func_lo2o "$libobj"
859688de56ccSmrg	obj=$func_lo2o_result
8597b4ee4795Smrg	;;
8598b4ee4795Smrg      *)
859988de56ccSmrg	libobj=
860088de56ccSmrg	obj="$output"
86011ab64890Smrg	;;
86022e9c7c8cSmrg      esac
86031ab64890Smrg
860488de56ccSmrg      # Delete the old objects.
860588de56ccSmrg      $opt_dry_run || $RM $obj $libobj
86061ab64890Smrg
860788de56ccSmrg      # Objects from convenience libraries.  This assumes
860888de56ccSmrg      # single-version convenience libraries.  Whenever we create
860988de56ccSmrg      # different ones for PIC/non-PIC, this we'll have to duplicate
861088de56ccSmrg      # the extraction.
861188de56ccSmrg      reload_conv_objs=
861288de56ccSmrg      gentop=
861388de56ccSmrg      # reload_cmds runs $LD directly, so let us get rid of
861488de56ccSmrg      # -Wl from whole_archive_flag_spec and hope we can get by with
861588de56ccSmrg      # turning comma into space..
861688de56ccSmrg      wl=
86171ab64890Smrg
861888de56ccSmrg      if test -n "$convenience"; then
861988de56ccSmrg	if test -n "$whole_archive_flag_spec"; then
862088de56ccSmrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
8621e9fcaa8aSmrg	  reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
862288de56ccSmrg	else
862388de56ccSmrg	  gentop="$output_objdir/${obj}x"
8624e9fcaa8aSmrg	  func_append generated " $gentop"
8625b4ee4795Smrg
862688de56ccSmrg	  func_extract_archives $gentop $convenience
862788de56ccSmrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
862888de56ccSmrg	fi
8629b4ee4795Smrg      fi
8630b4ee4795Smrg
8631e9fcaa8aSmrg      # If we're not building shared, we need to use non_pic_objs
8632e9fcaa8aSmrg      test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
8633e9fcaa8aSmrg
863488de56ccSmrg      # Create the old-style object.
8635e9fcaa8aSmrg      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
8636b4ee4795Smrg
863788de56ccSmrg      output="$obj"
863888de56ccSmrg      func_execute_cmds "$reload_cmds" 'exit $?'
8639b4ee4795Smrg
864088de56ccSmrg      # Exit if we aren't doing a library object file.
864188de56ccSmrg      if test -z "$libobj"; then
864288de56ccSmrg	if test -n "$gentop"; then
864388de56ccSmrg	  func_show_eval '${RM}r "$gentop"'
864488de56ccSmrg	fi
864588de56ccSmrg
864688de56ccSmrg	exit $EXIT_SUCCESS
8647b4ee4795Smrg      fi
864888de56ccSmrg
864988de56ccSmrg      if test "$build_libtool_libs" != yes; then
865088de56ccSmrg	if test -n "$gentop"; then
865188de56ccSmrg	  func_show_eval '${RM}r "$gentop"'
865288de56ccSmrg	fi
865388de56ccSmrg
865488de56ccSmrg	# Create an invalid libtool object if no PIC, so that we don't
865588de56ccSmrg	# accidentally link it into a program.
865688de56ccSmrg	# $show "echo timestamp > $libobj"
865788de56ccSmrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
865888de56ccSmrg	exit $EXIT_SUCCESS
865988de56ccSmrg      fi
866088de56ccSmrg
866188de56ccSmrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
866288de56ccSmrg	# Only do commands if we really have different PIC objects.
866388de56ccSmrg	reload_objs="$libobjs $reload_conv_objs"
866488de56ccSmrg	output="$libobj"
866588de56ccSmrg	func_execute_cmds "$reload_cmds" 'exit $?'
866688de56ccSmrg      fi
866788de56ccSmrg
866888de56ccSmrg      if test -n "$gentop"; then
866988de56ccSmrg	func_show_eval '${RM}r "$gentop"'
867088de56ccSmrg      fi
867188de56ccSmrg
867288de56ccSmrg      exit $EXIT_SUCCESS
8673b4ee4795Smrg      ;;
86741ab64890Smrg
867588de56ccSmrg    prog)
867688de56ccSmrg      case $host in
867788de56ccSmrg	*cygwin*) func_stripname '' '.exe' "$output"
867888de56ccSmrg	          output=$func_stripname_result.exe;;
867988de56ccSmrg      esac
868088de56ccSmrg      test -n "$vinfo" && \
868188de56ccSmrg	func_warning "\`-version-info' is ignored for programs"
86821ab64890Smrg
868388de56ccSmrg      test -n "$release" && \
868488de56ccSmrg	func_warning "\`-release' is ignored for programs"
86851ab64890Smrg
868688de56ccSmrg      test "$preload" = yes \
868788de56ccSmrg        && test "$dlopen_support" = unknown \
868888de56ccSmrg	&& test "$dlopen_self" = unknown \
868988de56ccSmrg	&& test "$dlopen_self_static" = unknown && \
869088de56ccSmrg	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
869188de56ccSmrg
869288de56ccSmrg      case $host in
869388de56ccSmrg      *-*-rhapsody* | *-*-darwin1.[012])
869488de56ccSmrg	# On Rhapsody replace the C library is the System framework
8695e9fcaa8aSmrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
8696e9fcaa8aSmrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
8697b4ee4795Smrg	;;
869888de56ccSmrg      esac
8699b4ee4795Smrg
870088de56ccSmrg      case $host in
870188de56ccSmrg      *-*-darwin*)
870288de56ccSmrg	# Don't allow lazy linking, it breaks C++ global constructors
870388de56ccSmrg	# But is supposedly fixed on 10.4 or later (yay!).
870488de56ccSmrg	if test "$tagname" = CXX ; then
870588de56ccSmrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
870688de56ccSmrg	    10.[0123])
8707e9fcaa8aSmrg	      func_append compile_command " ${wl}-bind_at_load"
8708e9fcaa8aSmrg	      func_append finalize_command " ${wl}-bind_at_load"
870988de56ccSmrg	    ;;
871088de56ccSmrg	  esac
8711b4ee4795Smrg	fi
871288de56ccSmrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
8713e9fcaa8aSmrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8714e9fcaa8aSmrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
871588de56ccSmrg	;;
871688de56ccSmrg      esac
8717b4ee4795Smrg
8718b4ee4795Smrg
871988de56ccSmrg      # move library search paths that coincide with paths to not yet
872088de56ccSmrg      # installed libraries to the beginning of the library search list
872188de56ccSmrg      new_libs=
872288de56ccSmrg      for path in $notinst_path; do
872388de56ccSmrg	case " $new_libs " in
872488de56ccSmrg	*" -L$path/$objdir "*) ;;
872588de56ccSmrg	*)
872688de56ccSmrg	  case " $compile_deplibs " in
872788de56ccSmrg	  *" -L$path/$objdir "*)
8728e9fcaa8aSmrg	    func_append new_libs " -L$path/$objdir" ;;
87292e9c7c8cSmrg	  esac
873088de56ccSmrg	  ;;
873188de56ccSmrg	esac
873288de56ccSmrg      done
873388de56ccSmrg      for deplib in $compile_deplibs; do
873488de56ccSmrg	case $deplib in
873588de56ccSmrg	-L*)
873688de56ccSmrg	  case " $new_libs " in
873788de56ccSmrg	  *" $deplib "*) ;;
8738e9fcaa8aSmrg	  *) func_append new_libs " $deplib" ;;
87392e9c7c8cSmrg	  esac
874088de56ccSmrg	  ;;
8741e9fcaa8aSmrg	*) func_append new_libs " $deplib" ;;
874288de56ccSmrg	esac
874388de56ccSmrg      done
874488de56ccSmrg      compile_deplibs="$new_libs"
87451ab64890Smrg
8746b4ee4795Smrg
8747e9fcaa8aSmrg      func_append compile_command " $compile_deplibs"
8748e9fcaa8aSmrg      func_append finalize_command " $finalize_deplibs"
8749b4ee4795Smrg
875088de56ccSmrg      if test -n "$rpath$xrpath"; then
875188de56ccSmrg	# If the user specified any rpath flags, then add them.
875288de56ccSmrg	for libdir in $rpath $xrpath; do
875388de56ccSmrg	  # This is the magic to use -rpath.
875488de56ccSmrg	  case "$finalize_rpath " in
875588de56ccSmrg	  *" $libdir "*) ;;
8756e9fcaa8aSmrg	  *) func_append finalize_rpath " $libdir" ;;
875788de56ccSmrg	  esac
875888de56ccSmrg	done
875988de56ccSmrg      fi
8760b4ee4795Smrg
876188de56ccSmrg      # Now hardcode the library paths
876288de56ccSmrg      rpath=
876388de56ccSmrg      hardcode_libdirs=
876488de56ccSmrg      for libdir in $compile_rpath $finalize_rpath; do
876588de56ccSmrg	if test -n "$hardcode_libdir_flag_spec"; then
876688de56ccSmrg	  if test -n "$hardcode_libdir_separator"; then
876788de56ccSmrg	    if test -z "$hardcode_libdirs"; then
876888de56ccSmrg	      hardcode_libdirs="$libdir"
876988de56ccSmrg	    else
877088de56ccSmrg	      # Just accumulate the unique libdirs.
877188de56ccSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
877288de56ccSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
877388de56ccSmrg		;;
877488de56ccSmrg	      *)
8775e9fcaa8aSmrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
877688de56ccSmrg		;;
877788de56ccSmrg	      esac
877888de56ccSmrg	    fi
8779b4ee4795Smrg	  else
878088de56ccSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
8781e9fcaa8aSmrg	    func_append rpath " $flag"
8782b4ee4795Smrg	  fi
878388de56ccSmrg	elif test -n "$runpath_var"; then
878488de56ccSmrg	  case "$perm_rpath " in
878588de56ccSmrg	  *" $libdir "*) ;;
8786e9fcaa8aSmrg	  *) func_append perm_rpath " $libdir" ;;
878788de56ccSmrg	  esac
878888de56ccSmrg	fi
878988de56ccSmrg	case $host in
879088de56ccSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
879188de56ccSmrg	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
879288de56ccSmrg	  case :$dllsearchpath: in
879388de56ccSmrg	  *":$libdir:"*) ;;
879488de56ccSmrg	  ::) dllsearchpath=$libdir;;
8795e9fcaa8aSmrg	  *) func_append dllsearchpath ":$libdir";;
879688de56ccSmrg	  esac
879788de56ccSmrg	  case :$dllsearchpath: in
879888de56ccSmrg	  *":$testbindir:"*) ;;
879988de56ccSmrg	  ::) dllsearchpath=$testbindir;;
8800e9fcaa8aSmrg	  *) func_append dllsearchpath ":$testbindir";;
880188de56ccSmrg	  esac
880288de56ccSmrg	  ;;
880388de56ccSmrg	esac
880488de56ccSmrg      done
880588de56ccSmrg      # Substitute the hardcoded libdirs into the rpath.
880688de56ccSmrg      if test -n "$hardcode_libdir_separator" &&
880788de56ccSmrg	 test -n "$hardcode_libdirs"; then
880888de56ccSmrg	libdir="$hardcode_libdirs"
880988de56ccSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
881088de56ccSmrg      fi
881188de56ccSmrg      compile_rpath="$rpath"
8812b4ee4795Smrg
881388de56ccSmrg      rpath=
881488de56ccSmrg      hardcode_libdirs=
881588de56ccSmrg      for libdir in $finalize_rpath; do
881688de56ccSmrg	if test -n "$hardcode_libdir_flag_spec"; then
881788de56ccSmrg	  if test -n "$hardcode_libdir_separator"; then
881888de56ccSmrg	    if test -z "$hardcode_libdirs"; then
881988de56ccSmrg	      hardcode_libdirs="$libdir"
882088de56ccSmrg	    else
882188de56ccSmrg	      # Just accumulate the unique libdirs.
882288de56ccSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
882388de56ccSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
882488de56ccSmrg		;;
882588de56ccSmrg	      *)
8826e9fcaa8aSmrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
882788de56ccSmrg		;;
882888de56ccSmrg	      esac
882988de56ccSmrg	    fi
88301ab64890Smrg	  else
883188de56ccSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
8832e9fcaa8aSmrg	    func_append rpath " $flag"
88331ab64890Smrg	  fi
883488de56ccSmrg	elif test -n "$runpath_var"; then
883588de56ccSmrg	  case "$finalize_perm_rpath " in
883688de56ccSmrg	  *" $libdir "*) ;;
8837e9fcaa8aSmrg	  *) func_append finalize_perm_rpath " $libdir" ;;
883888de56ccSmrg	  esac
88391ab64890Smrg	fi
884088de56ccSmrg      done
884188de56ccSmrg      # Substitute the hardcoded libdirs into the rpath.
884288de56ccSmrg      if test -n "$hardcode_libdir_separator" &&
884388de56ccSmrg	 test -n "$hardcode_libdirs"; then
884488de56ccSmrg	libdir="$hardcode_libdirs"
884588de56ccSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
884688de56ccSmrg      fi
884788de56ccSmrg      finalize_rpath="$rpath"
88481ab64890Smrg
884988de56ccSmrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
885088de56ccSmrg	# Transform all the library objects into standard objects.
8851e9fcaa8aSmrg	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
8852e9fcaa8aSmrg	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
885388de56ccSmrg      fi
88541ab64890Smrg
885588de56ccSmrg      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
88561ab64890Smrg
885788de56ccSmrg      # template prelinking step
885888de56ccSmrg      if test -n "$prelink_cmds"; then
885988de56ccSmrg	func_execute_cmds "$prelink_cmds" 'exit $?'
886088de56ccSmrg      fi
88611ab64890Smrg
886288de56ccSmrg      wrappers_required=yes
886388de56ccSmrg      case $host in
8864e9fcaa8aSmrg      *cegcc* | *mingw32ce*)
8865e9fcaa8aSmrg        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
8866e9fcaa8aSmrg        wrappers_required=no
8867e9fcaa8aSmrg        ;;
886888de56ccSmrg      *cygwin* | *mingw* )
886988de56ccSmrg        if test "$build_libtool_libs" != yes; then
887088de56ccSmrg          wrappers_required=no
887188de56ccSmrg        fi
887288de56ccSmrg        ;;
887388de56ccSmrg      *)
887488de56ccSmrg        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
887588de56ccSmrg          wrappers_required=no
887688de56ccSmrg        fi
887788de56ccSmrg        ;;
887888de56ccSmrg      esac
887988de56ccSmrg      if test "$wrappers_required" = no; then
888088de56ccSmrg	# Replace the output file specification.
8881e9fcaa8aSmrg	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
888288de56ccSmrg	link_command="$compile_command$compile_rpath"
88831ab64890Smrg
888488de56ccSmrg	# We have no uninstalled library dependencies, so finalize right now.
888588de56ccSmrg	exit_status=0
888688de56ccSmrg	func_show_eval "$link_command" 'exit_status=$?'
88871ab64890Smrg
8888e9fcaa8aSmrg	if test -n "$postlink_cmds"; then
8889e9fcaa8aSmrg	  func_to_tool_file "$output"
8890e9fcaa8aSmrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8891e9fcaa8aSmrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
8892e9fcaa8aSmrg	fi
8893e9fcaa8aSmrg
889488de56ccSmrg	# Delete the generated files.
889588de56ccSmrg	if test -f "$output_objdir/${outputname}S.${objext}"; then
889688de56ccSmrg	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
88971ab64890Smrg	fi
88981ab64890Smrg
889988de56ccSmrg	exit $exit_status
890088de56ccSmrg      fi
89011ab64890Smrg
890288de56ccSmrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
890388de56ccSmrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
890488de56ccSmrg      fi
890588de56ccSmrg      if test -n "$finalize_shlibpath"; then
890688de56ccSmrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
890788de56ccSmrg      fi
8908b4ee4795Smrg
890988de56ccSmrg      compile_var=
891088de56ccSmrg      finalize_var=
891188de56ccSmrg      if test -n "$runpath_var"; then
891288de56ccSmrg	if test -n "$perm_rpath"; then
891388de56ccSmrg	  # We should set the runpath_var.
891488de56ccSmrg	  rpath=
891588de56ccSmrg	  for dir in $perm_rpath; do
8916e9fcaa8aSmrg	    func_append rpath "$dir:"
891788de56ccSmrg	  done
891888de56ccSmrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
89191ab64890Smrg	fi
892088de56ccSmrg	if test -n "$finalize_perm_rpath"; then
892188de56ccSmrg	  # We should set the runpath_var.
892288de56ccSmrg	  rpath=
892388de56ccSmrg	  for dir in $finalize_perm_rpath; do
8924e9fcaa8aSmrg	    func_append rpath "$dir:"
892588de56ccSmrg	  done
892688de56ccSmrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
89271ab64890Smrg	fi
892888de56ccSmrg      fi
89291ab64890Smrg
893088de56ccSmrg      if test "$no_install" = yes; then
893188de56ccSmrg	# We don't need to create a wrapper script.
893288de56ccSmrg	link_command="$compile_var$compile_command$compile_rpath"
893388de56ccSmrg	# Replace the output file specification.
8934e9fcaa8aSmrg	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
893588de56ccSmrg	# Delete the old output file.
893688de56ccSmrg	$opt_dry_run || $RM $output
893788de56ccSmrg	# Link the executable and exit
893888de56ccSmrg	func_show_eval "$link_command" 'exit $?'
8939e9fcaa8aSmrg
8940e9fcaa8aSmrg	if test -n "$postlink_cmds"; then
8941e9fcaa8aSmrg	  func_to_tool_file "$output"
8942e9fcaa8aSmrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8943e9fcaa8aSmrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
8944e9fcaa8aSmrg	fi
8945e9fcaa8aSmrg
8946b4ee4795Smrg	exit $EXIT_SUCCESS
894788de56ccSmrg      fi
89482e9c7c8cSmrg
894988de56ccSmrg      if test "$hardcode_action" = relink; then
895088de56ccSmrg	# Fast installation is not supported
895188de56ccSmrg	link_command="$compile_var$compile_command$compile_rpath"
895288de56ccSmrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
895388de56ccSmrg
895488de56ccSmrg	func_warning "this platform does not like uninstalled shared libraries"
895588de56ccSmrg	func_warning "\`$output' will be relinked during installation"
895688de56ccSmrg      else
895788de56ccSmrg	if test "$fast_install" != no; then
895888de56ccSmrg	  link_command="$finalize_var$compile_command$finalize_rpath"
895988de56ccSmrg	  if test "$fast_install" = yes; then
8960e9fcaa8aSmrg	    relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
896188de56ccSmrg	  else
896288de56ccSmrg	    # fast_install is set to needless
896388de56ccSmrg	    relink_command=
896488de56ccSmrg	  fi
89651ab64890Smrg	else
896688de56ccSmrg	  link_command="$compile_var$compile_command$compile_rpath"
896788de56ccSmrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
89681ab64890Smrg	fi
896988de56ccSmrg      fi
89701ab64890Smrg
897188de56ccSmrg      # Replace the output file specification.
8972e9fcaa8aSmrg      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
89731ab64890Smrg
897488de56ccSmrg      # Delete the old output files.
897588de56ccSmrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
89761ab64890Smrg
897788de56ccSmrg      func_show_eval "$link_command" 'exit $?'
8978b4ee4795Smrg
8979e9fcaa8aSmrg      if test -n "$postlink_cmds"; then
8980e9fcaa8aSmrg	func_to_tool_file "$output_objdir/$outputname"
8981e9fcaa8aSmrg	postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8982e9fcaa8aSmrg	func_execute_cmds "$postlink_cmds" 'exit $?'
8983e9fcaa8aSmrg      fi
8984e9fcaa8aSmrg
898588de56ccSmrg      # Now create the wrapper script.
898688de56ccSmrg      func_verbose "creating $output"
8987b4ee4795Smrg
898888de56ccSmrg      # Quote the relink command for shipping.
898988de56ccSmrg      if test -n "$relink_command"; then
899088de56ccSmrg	# Preserve any variables that may affect compiler behavior
899188de56ccSmrg	for var in $variables_saved_for_relink; do
899288de56ccSmrg	  if eval test -z \"\${$var+set}\"; then
899388de56ccSmrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
899488de56ccSmrg	  elif eval var_value=\$$var; test -z "$var_value"; then
899588de56ccSmrg	    relink_command="$var=; export $var; $relink_command"
89961ab64890Smrg	  else
899788de56ccSmrg	    func_quote_for_eval "$var_value"
899888de56ccSmrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
89991ab64890Smrg	  fi
900088de56ccSmrg	done
900188de56ccSmrg	relink_command="(cd `pwd`; $relink_command)"
9002e9fcaa8aSmrg	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
900388de56ccSmrg      fi
900488de56ccSmrg
900588de56ccSmrg      # Only actually do things if not in dry run mode.
900688de56ccSmrg      $opt_dry_run || {
900788de56ccSmrg	# win32 will think the script is a binary if it has
900888de56ccSmrg	# a .exe suffix, so we strip it off here.
900988de56ccSmrg	case $output in
901088de56ccSmrg	  *.exe) func_stripname '' '.exe' "$output"
901188de56ccSmrg	         output=$func_stripname_result ;;
901288de56ccSmrg	esac
901388de56ccSmrg	# test for cygwin because mv fails w/o .exe extensions
901488de56ccSmrg	case $host in
901588de56ccSmrg	  *cygwin*)
901688de56ccSmrg	    exeext=.exe
901788de56ccSmrg	    func_stripname '' '.exe' "$outputname"
901888de56ccSmrg	    outputname=$func_stripname_result ;;
901988de56ccSmrg	  *) exeext= ;;
90201ab64890Smrg	esac
902188de56ccSmrg	case $host in
902288de56ccSmrg	  *cygwin* | *mingw* )
902388de56ccSmrg	    func_dirname_and_basename "$output" "" "."
902488de56ccSmrg	    output_name=$func_basename_result
902588de56ccSmrg	    output_path=$func_dirname_result
902688de56ccSmrg	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
902788de56ccSmrg	    cwrapper="$output_path/$output_name.exe"
902888de56ccSmrg	    $RM $cwrappersource $cwrapper
902988de56ccSmrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
903088de56ccSmrg
903188de56ccSmrg	    func_emit_cwrapperexe_src > $cwrappersource
903288de56ccSmrg
903388de56ccSmrg	    # The wrapper executable is built using the $host compiler,
903488de56ccSmrg	    # because it contains $host paths and files. If cross-
903588de56ccSmrg	    # compiling, it, like the target executable, must be
903688de56ccSmrg	    # executed on the $host or under an emulation environment.
903788de56ccSmrg	    $opt_dry_run || {
903888de56ccSmrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
903988de56ccSmrg	      $STRIP $cwrapper
904088de56ccSmrg	    }
90411ab64890Smrg
904288de56ccSmrg	    # Now, create the wrapper script for func_source use:
904388de56ccSmrg	    func_ltwrapper_scriptname $cwrapper
904488de56ccSmrg	    $RM $func_ltwrapper_scriptname_result
904588de56ccSmrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
904688de56ccSmrg	    $opt_dry_run || {
904788de56ccSmrg	      # note: this script will not be executed, so do not chmod.
904888de56ccSmrg	      if test "x$build" = "x$host" ; then
904988de56ccSmrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
905088de56ccSmrg	      else
905188de56ccSmrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
905288de56ccSmrg	      fi
905388de56ccSmrg	    }
905488de56ccSmrg	  ;;
905588de56ccSmrg	  * )
905688de56ccSmrg	    $RM $output
905788de56ccSmrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
90581ab64890Smrg
905988de56ccSmrg	    func_emit_wrapper no > $output
906088de56ccSmrg	    chmod +x $output
906188de56ccSmrg	  ;;
906288de56ccSmrg	esac
906388de56ccSmrg      }
906488de56ccSmrg      exit $EXIT_SUCCESS
906588de56ccSmrg      ;;
906688de56ccSmrg    esac
90671ab64890Smrg
906888de56ccSmrg    # See if we need to build an old-fashioned archive.
906988de56ccSmrg    for oldlib in $oldlibs; do
90701ab64890Smrg
907188de56ccSmrg      if test "$build_libtool_libs" = convenience; then
907288de56ccSmrg	oldobjs="$libobjs_save $symfileobj"
907388de56ccSmrg	addlibs="$convenience"
907488de56ccSmrg	build_libtool_libs=no
907588de56ccSmrg      else
907688de56ccSmrg	if test "$build_libtool_libs" = module; then
907788de56ccSmrg	  oldobjs="$libobjs_save"
907888de56ccSmrg	  build_libtool_libs=no
907988de56ccSmrg	else
908088de56ccSmrg	  oldobjs="$old_deplibs $non_pic_objects"
908188de56ccSmrg	  if test "$preload" = yes && test -f "$symfileobj"; then
9082e9fcaa8aSmrg	    func_append oldobjs " $symfileobj"
908388de56ccSmrg	  fi
908488de56ccSmrg	fi
908588de56ccSmrg	addlibs="$old_convenience"
90861ab64890Smrg      fi
90871ab64890Smrg
908888de56ccSmrg      if test -n "$addlibs"; then
908988de56ccSmrg	gentop="$output_objdir/${outputname}x"
9090e9fcaa8aSmrg	func_append generated " $gentop"
90911ab64890Smrg
909288de56ccSmrg	func_extract_archives $gentop $addlibs
9093e9fcaa8aSmrg	func_append oldobjs " $func_extract_archives_result"
909488de56ccSmrg      fi
90951ab64890Smrg
909688de56ccSmrg      # Do each command in the archive commands.
909788de56ccSmrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
909888de56ccSmrg	cmds=$old_archive_from_new_cmds
909988de56ccSmrg      else
91001ab64890Smrg
910188de56ccSmrg	# Add any objects from preloaded convenience libraries
910288de56ccSmrg	if test -n "$dlprefiles"; then
910388de56ccSmrg	  gentop="$output_objdir/${outputname}x"
9104e9fcaa8aSmrg	  func_append generated " $gentop"
91051ab64890Smrg
910688de56ccSmrg	  func_extract_archives $gentop $dlprefiles
9107e9fcaa8aSmrg	  func_append oldobjs " $func_extract_archives_result"
910888de56ccSmrg	fi
91091ab64890Smrg
911088de56ccSmrg	# POSIX demands no paths to be encoded in archives.  We have
911188de56ccSmrg	# to avoid creating archives with duplicate basenames if we
911288de56ccSmrg	# might have to extract them afterwards, e.g., when creating a
911388de56ccSmrg	# static archive out of a convenience library, or when linking
911488de56ccSmrg	# the entirety of a libtool archive into another (currently
911588de56ccSmrg	# not supported by libtool).
911688de56ccSmrg	if (for obj in $oldobjs
911788de56ccSmrg	    do
911888de56ccSmrg	      func_basename "$obj"
911988de56ccSmrg	      $ECHO "$func_basename_result"
912088de56ccSmrg	    done | sort | sort -uc >/dev/null 2>&1); then
912188de56ccSmrg	  :
912288de56ccSmrg	else
9123e9fcaa8aSmrg	  echo "copying selected object files to avoid basename conflicts..."
912488de56ccSmrg	  gentop="$output_objdir/${outputname}x"
9125e9fcaa8aSmrg	  func_append generated " $gentop"
912688de56ccSmrg	  func_mkdir_p "$gentop"
912788de56ccSmrg	  save_oldobjs=$oldobjs
912888de56ccSmrg	  oldobjs=
912988de56ccSmrg	  counter=1
913088de56ccSmrg	  for obj in $save_oldobjs
913188de56ccSmrg	  do
913288de56ccSmrg	    func_basename "$obj"
913388de56ccSmrg	    objbase="$func_basename_result"
913488de56ccSmrg	    case " $oldobjs " in
913588de56ccSmrg	    " ") oldobjs=$obj ;;
913688de56ccSmrg	    *[\ /]"$objbase "*)
913788de56ccSmrg	      while :; do
913888de56ccSmrg		# Make sure we don't pick an alternate name that also
913988de56ccSmrg		# overlaps.
914088de56ccSmrg		newobj=lt$counter-$objbase
914188de56ccSmrg		func_arith $counter + 1
914288de56ccSmrg		counter=$func_arith_result
914388de56ccSmrg		case " $oldobjs " in
914488de56ccSmrg		*[\ /]"$newobj "*) ;;
914588de56ccSmrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
914688de56ccSmrg		esac
914788de56ccSmrg	      done
914888de56ccSmrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
9149e9fcaa8aSmrg	      func_append oldobjs " $gentop/$newobj"
915088de56ccSmrg	      ;;
9151e9fcaa8aSmrg	    *) func_append oldobjs " $obj" ;;
915288de56ccSmrg	    esac
91531ab64890Smrg	  done
91542e9c7c8cSmrg	fi
915588de56ccSmrg	eval cmds=\"$old_archive_cmds\"
9156b4ee4795Smrg
915788de56ccSmrg	func_len " $cmds"
915888de56ccSmrg	len=$func_len_result
915988de56ccSmrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
916088de56ccSmrg	  cmds=$old_archive_cmds
9161e9fcaa8aSmrg	elif test -n "$archiver_list_spec"; then
9162e9fcaa8aSmrg	  func_verbose "using command file archive linking..."
9163e9fcaa8aSmrg	  for obj in $oldobjs
9164e9fcaa8aSmrg	  do
9165e9fcaa8aSmrg	    func_to_tool_file "$obj"
9166e9fcaa8aSmrg	    $ECHO "$func_to_tool_file_result"
9167e9fcaa8aSmrg	  done > $output_objdir/$libname.libcmd
9168e9fcaa8aSmrg	  func_to_tool_file "$output_objdir/$libname.libcmd"
9169e9fcaa8aSmrg	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
9170e9fcaa8aSmrg	  cmds=$old_archive_cmds
917188de56ccSmrg	else
917288de56ccSmrg	  # the command line is too long to link in one step, link in parts
917388de56ccSmrg	  func_verbose "using piecewise archive linking..."
917488de56ccSmrg	  save_RANLIB=$RANLIB
917588de56ccSmrg	  RANLIB=:
917688de56ccSmrg	  objlist=
917788de56ccSmrg	  concat_cmds=
917888de56ccSmrg	  save_oldobjs=$oldobjs
917988de56ccSmrg	  oldobjs=
918088de56ccSmrg	  # Is there a better way of finding the last object in the list?
918188de56ccSmrg	  for obj in $save_oldobjs
918288de56ccSmrg	  do
918388de56ccSmrg	    last_oldobj=$obj
918488de56ccSmrg	  done
918588de56ccSmrg	  eval test_cmds=\"$old_archive_cmds\"
918688de56ccSmrg	  func_len " $test_cmds"
918788de56ccSmrg	  len0=$func_len_result
918888de56ccSmrg	  len=$len0
918988de56ccSmrg	  for obj in $save_oldobjs
919088de56ccSmrg	  do
919188de56ccSmrg	    func_len " $obj"
919288de56ccSmrg	    func_arith $len + $func_len_result
919388de56ccSmrg	    len=$func_arith_result
919488de56ccSmrg	    func_append objlist " $obj"
919588de56ccSmrg	    if test "$len" -lt "$max_cmd_len"; then
919688de56ccSmrg	      :
919788de56ccSmrg	    else
919888de56ccSmrg	      # the above command should be used before it gets too long
919988de56ccSmrg	      oldobjs=$objlist
920088de56ccSmrg	      if test "$obj" = "$last_oldobj" ; then
920188de56ccSmrg		RANLIB=$save_RANLIB
920288de56ccSmrg	      fi
920388de56ccSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
920488de56ccSmrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
920588de56ccSmrg	      objlist=
920688de56ccSmrg	      len=$len0
920788de56ccSmrg	    fi
920888de56ccSmrg	  done
920988de56ccSmrg	  RANLIB=$save_RANLIB
921088de56ccSmrg	  oldobjs=$objlist
921188de56ccSmrg	  if test "X$oldobjs" = "X" ; then
921288de56ccSmrg	    eval cmds=\"\$concat_cmds\"
921388de56ccSmrg	  else
921488de56ccSmrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
921588de56ccSmrg	  fi
921688de56ccSmrg	fi
921788de56ccSmrg      fi
921888de56ccSmrg      func_execute_cmds "$cmds" 'exit $?'
92191ab64890Smrg    done
92201ab64890Smrg
922188de56ccSmrg    test -n "$generated" && \
922288de56ccSmrg      func_show_eval "${RM}r$generated"
92231ab64890Smrg
922488de56ccSmrg    # Now create the libtool archive.
922588de56ccSmrg    case $output in
922688de56ccSmrg    *.la)
922788de56ccSmrg      old_library=
922888de56ccSmrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
922988de56ccSmrg      func_verbose "creating $output"
92302e9c7c8cSmrg
923188de56ccSmrg      # Preserve any variables that may affect compiler behavior
923288de56ccSmrg      for var in $variables_saved_for_relink; do
923388de56ccSmrg	if eval test -z \"\${$var+set}\"; then
923488de56ccSmrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
923588de56ccSmrg	elif eval var_value=\$$var; test -z "$var_value"; then
923688de56ccSmrg	  relink_command="$var=; export $var; $relink_command"
9237b4ee4795Smrg	else
923888de56ccSmrg	  func_quote_for_eval "$var_value"
923988de56ccSmrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9240b4ee4795Smrg	fi
924188de56ccSmrg      done
924288de56ccSmrg      # Quote the link command for shipping.
924388de56ccSmrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
9244e9fcaa8aSmrg      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
924588de56ccSmrg      if test "$hardcode_automatic" = yes ; then
924688de56ccSmrg	relink_command=
924788de56ccSmrg      fi
92481ab64890Smrg
924988de56ccSmrg      # Only create the output if not a dry run.
925088de56ccSmrg      $opt_dry_run || {
925188de56ccSmrg	for installed in no yes; do
925288de56ccSmrg	  if test "$installed" = yes; then
925388de56ccSmrg	    if test -z "$install_libdir"; then
925488de56ccSmrg	      break
925588de56ccSmrg	    fi
925688de56ccSmrg	    output="$output_objdir/$outputname"i
925788de56ccSmrg	    # Replace all uninstalled libtool libraries with the installed ones
925888de56ccSmrg	    newdependency_libs=
925988de56ccSmrg	    for deplib in $dependency_libs; do
926088de56ccSmrg	      case $deplib in
926188de56ccSmrg	      *.la)
926288de56ccSmrg		func_basename "$deplib"
926388de56ccSmrg		name="$func_basename_result"
926488de56ccSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
926588de56ccSmrg		test -z "$libdir" && \
926688de56ccSmrg		  func_fatal_error "\`$deplib' is not a valid libtool archive"
9267e9fcaa8aSmrg		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
9268e9fcaa8aSmrg		;;
9269e9fcaa8aSmrg	      -L*)
9270e9fcaa8aSmrg		func_stripname -L '' "$deplib"
9271e9fcaa8aSmrg		func_replace_sysroot "$func_stripname_result"
9272e9fcaa8aSmrg		func_append newdependency_libs " -L$func_replace_sysroot_result"
927388de56ccSmrg		;;
9274e9fcaa8aSmrg	      -R*)
9275e9fcaa8aSmrg		func_stripname -R '' "$deplib"
9276e9fcaa8aSmrg		func_replace_sysroot "$func_stripname_result"
9277e9fcaa8aSmrg		func_append newdependency_libs " -R$func_replace_sysroot_result"
9278e9fcaa8aSmrg		;;
9279e9fcaa8aSmrg	      *) func_append newdependency_libs " $deplib" ;;
928088de56ccSmrg	      esac
928188de56ccSmrg	    done
928288de56ccSmrg	    dependency_libs="$newdependency_libs"
928388de56ccSmrg	    newdlfiles=
928488de56ccSmrg
928588de56ccSmrg	    for lib in $dlfiles; do
928688de56ccSmrg	      case $lib in
928788de56ccSmrg	      *.la)
928888de56ccSmrg	        func_basename "$lib"
928988de56ccSmrg		name="$func_basename_result"
929088de56ccSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
929188de56ccSmrg		test -z "$libdir" && \
929288de56ccSmrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
9293e9fcaa8aSmrg		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
929488de56ccSmrg		;;
9295e9fcaa8aSmrg	      *) func_append newdlfiles " $lib" ;;
929688de56ccSmrg	      esac
929788de56ccSmrg	    done
929888de56ccSmrg	    dlfiles="$newdlfiles"
929988de56ccSmrg	    newdlprefiles=
930088de56ccSmrg	    for lib in $dlprefiles; do
930188de56ccSmrg	      case $lib in
930288de56ccSmrg	      *.la)
930388de56ccSmrg		# Only pass preopened files to the pseudo-archive (for
930488de56ccSmrg		# eventual linking with the app. that links it) if we
930588de56ccSmrg		# didn't already link the preopened objects directly into
930688de56ccSmrg		# the library:
930788de56ccSmrg		func_basename "$lib"
930888de56ccSmrg		name="$func_basename_result"
930988de56ccSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
931088de56ccSmrg		test -z "$libdir" && \
931188de56ccSmrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
9312e9fcaa8aSmrg		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
931388de56ccSmrg		;;
931488de56ccSmrg	      esac
931588de56ccSmrg	    done
931688de56ccSmrg	    dlprefiles="$newdlprefiles"
931788de56ccSmrg	  else
931888de56ccSmrg	    newdlfiles=
931988de56ccSmrg	    for lib in $dlfiles; do
932088de56ccSmrg	      case $lib in
932188de56ccSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
932288de56ccSmrg		*) abs=`pwd`"/$lib" ;;
932388de56ccSmrg	      esac
9324e9fcaa8aSmrg	      func_append newdlfiles " $abs"
932588de56ccSmrg	    done
932688de56ccSmrg	    dlfiles="$newdlfiles"
932788de56ccSmrg	    newdlprefiles=
932888de56ccSmrg	    for lib in $dlprefiles; do
932988de56ccSmrg	      case $lib in
933088de56ccSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
933188de56ccSmrg		*) abs=`pwd`"/$lib" ;;
933288de56ccSmrg	      esac
9333e9fcaa8aSmrg	      func_append newdlprefiles " $abs"
933488de56ccSmrg	    done
933588de56ccSmrg	    dlprefiles="$newdlprefiles"
933688de56ccSmrg	  fi
933788de56ccSmrg	  $RM $output
933888de56ccSmrg	  # place dlname in correct position for cygwin
9339e9fcaa8aSmrg	  # In fact, it would be nice if we could use this code for all target
9340e9fcaa8aSmrg	  # systems that can't hard-code library paths into their executables
9341e9fcaa8aSmrg	  # and that have no shared library path variable independent of PATH,
9342e9fcaa8aSmrg	  # but it turns out we can't easily determine that from inspecting
9343e9fcaa8aSmrg	  # libtool variables, so we have to hard-code the OSs to which it
9344e9fcaa8aSmrg	  # applies here; at the moment, that means platforms that use the PE
9345e9fcaa8aSmrg	  # object format with DLL files.  See the long comment at the top of
9346e9fcaa8aSmrg	  # tests/bindir.at for full details.
934788de56ccSmrg	  tdlname=$dlname
934888de56ccSmrg	  case $host,$output,$installed,$module,$dlname in
9349e9fcaa8aSmrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
9350e9fcaa8aSmrg	      # If a -bindir argument was supplied, place the dll there.
9351e9fcaa8aSmrg	      if test "x$bindir" != x ;
9352e9fcaa8aSmrg	      then
9353e9fcaa8aSmrg		func_relative_path "$install_libdir" "$bindir"
9354e9fcaa8aSmrg		tdlname=$func_relative_path_result$dlname
9355e9fcaa8aSmrg	      else
9356e9fcaa8aSmrg		# Otherwise fall back on heuristic.
9357e9fcaa8aSmrg		tdlname=../bin/$dlname
9358e9fcaa8aSmrg	      fi
9359e9fcaa8aSmrg	      ;;
936088de56ccSmrg	  esac
936188de56ccSmrg	  $ECHO > $output "\
936288de56ccSmrg# $outputname - a libtool library file
936388de56ccSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
936488de56ccSmrg#
936588de56ccSmrg# Please DO NOT delete this file!
936688de56ccSmrg# It is necessary for linking the library.
93671ab64890Smrg
936888de56ccSmrg# The name that we can dlopen(3).
936988de56ccSmrgdlname='$tdlname'
93701ab64890Smrg
937188de56ccSmrg# Names of this library.
937288de56ccSmrglibrary_names='$library_names'
93731ab64890Smrg
937488de56ccSmrg# The name of the static archive.
937588de56ccSmrgold_library='$old_library'
93761ab64890Smrg
937788de56ccSmrg# Linker flags that can not go in dependency_libs.
937888de56ccSmrginherited_linker_flags='$new_inherited_linker_flags'
93791ab64890Smrg
938088de56ccSmrg# Libraries that this one depends upon.
938188de56ccSmrgdependency_libs='$dependency_libs'
93821ab64890Smrg
938388de56ccSmrg# Names of additional weak libraries provided by this library
938488de56ccSmrgweak_library_names='$weak_libs'
93851ab64890Smrg
938688de56ccSmrg# Version information for $libname.
938788de56ccSmrgcurrent=$current
938888de56ccSmrgage=$age
938988de56ccSmrgrevision=$revision
93901ab64890Smrg
939188de56ccSmrg# Is this an already installed library?
939288de56ccSmrginstalled=$installed
93931ab64890Smrg
939488de56ccSmrg# Should we warn about portability when linking against -modules?
939588de56ccSmrgshouldnotlink=$module
93961ab64890Smrg
939788de56ccSmrg# Files to dlopen/dlpreopen
939888de56ccSmrgdlopen='$dlfiles'
939988de56ccSmrgdlpreopen='$dlprefiles'
94001ab64890Smrg
940188de56ccSmrg# Directory that this library needs to be installed in:
940288de56ccSmrglibdir='$install_libdir'"
940388de56ccSmrg	  if test "$installed" = no && test "$need_relink" = yes; then
940488de56ccSmrg	    $ECHO >> $output "\
940588de56ccSmrgrelink_command=\"$relink_command\""
940688de56ccSmrg	  fi
940788de56ccSmrg	done
940888de56ccSmrg      }
94091ab64890Smrg
941088de56ccSmrg      # Do a symbolic link so that the libtool archive can be found in
941188de56ccSmrg      # LD_LIBRARY_PATH before the program is installed.
941288de56ccSmrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
941388de56ccSmrg      ;;
941488de56ccSmrg    esac
941588de56ccSmrg    exit $EXIT_SUCCESS
941688de56ccSmrg}
9417b4ee4795Smrg
9418e9fcaa8aSmrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } &&
941988de56ccSmrg    func_mode_link ${1+"$@"}
94201ab64890Smrg
94211ab64890Smrg
942288de56ccSmrg# func_mode_uninstall arg...
942388de56ccSmrgfunc_mode_uninstall ()
942488de56ccSmrg{
942588de56ccSmrg    $opt_debug
942688de56ccSmrg    RM="$nonopt"
94271ab64890Smrg    files=
94281ab64890Smrg    rmforce=
94291ab64890Smrg    exit_status=0
94301ab64890Smrg
94311ab64890Smrg    # This variable tells wrapper scripts just to set variables rather
94321ab64890Smrg    # than running their programs.
94331ab64890Smrg    libtool_install_magic="$magic"
94341ab64890Smrg
94351ab64890Smrg    for arg
94361ab64890Smrg    do
94371ab64890Smrg      case $arg in
9438e9fcaa8aSmrg      -f) func_append RM " $arg"; rmforce=yes ;;
9439e9fcaa8aSmrg      -*) func_append RM " $arg" ;;
9440e9fcaa8aSmrg      *) func_append files " $arg" ;;
94411ab64890Smrg      esac
94421ab64890Smrg    done
94431ab64890Smrg
944488de56ccSmrg    test -z "$RM" && \
944588de56ccSmrg      func_fatal_help "you must specify an RM program"
94461ab64890Smrg
94471ab64890Smrg    rmdirs=
94481ab64890Smrg
94491ab64890Smrg    for file in $files; do
945088de56ccSmrg      func_dirname "$file" "" "."
945188de56ccSmrg      dir="$func_dirname_result"
945288de56ccSmrg      if test "X$dir" = X.; then
9453e9fcaa8aSmrg	odir="$objdir"
94541ab64890Smrg      else
9455e9fcaa8aSmrg	odir="$dir/$objdir"
94561ab64890Smrg      fi
945788de56ccSmrg      func_basename "$file"
945888de56ccSmrg      name="$func_basename_result"
9459e9fcaa8aSmrg      test "$opt_mode" = uninstall && odir="$dir"
94601ab64890Smrg
9461e9fcaa8aSmrg      # Remember odir for removal later, being careful to avoid duplicates
9462e9fcaa8aSmrg      if test "$opt_mode" = clean; then
94631ab64890Smrg	case " $rmdirs " in
9464e9fcaa8aSmrg	  *" $odir "*) ;;
9465e9fcaa8aSmrg	  *) func_append rmdirs " $odir" ;;
94661ab64890Smrg	esac
94671ab64890Smrg      fi
94681ab64890Smrg
94691ab64890Smrg      # Don't error if the file doesn't exist and rm -f was used.
947088de56ccSmrg      if { test -L "$file"; } >/dev/null 2>&1 ||
947188de56ccSmrg	 { test -h "$file"; } >/dev/null 2>&1 ||
947288de56ccSmrg	 test -f "$file"; then
94731ab64890Smrg	:
94741ab64890Smrg      elif test -d "$file"; then
94751ab64890Smrg	exit_status=1
94761ab64890Smrg	continue
94771ab64890Smrg      elif test "$rmforce" = yes; then
94781ab64890Smrg	continue
94791ab64890Smrg      fi
94801ab64890Smrg
94811ab64890Smrg      rmfiles="$file"
94821ab64890Smrg
94831ab64890Smrg      case $name in
94841ab64890Smrg      *.la)
94851ab64890Smrg	# Possibly a libtool archive, so verify it.
948688de56ccSmrg	if func_lalib_p "$file"; then
948788de56ccSmrg	  func_source $dir/$name
94881ab64890Smrg
94891ab64890Smrg	  # Delete the libtool libraries and symlinks.
94901ab64890Smrg	  for n in $library_names; do
9491e9fcaa8aSmrg	    func_append rmfiles " $odir/$n"
94921ab64890Smrg	  done
9493e9fcaa8aSmrg	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
94941ab64890Smrg
9495e9fcaa8aSmrg	  case "$opt_mode" in
94961ab64890Smrg	  clean)
9497e9fcaa8aSmrg	    case " $library_names " in
94981ab64890Smrg	    *" $dlname "*) ;;
9499e9fcaa8aSmrg	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
95001ab64890Smrg	    esac
9501e9fcaa8aSmrg	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
95021ab64890Smrg	    ;;
95031ab64890Smrg	  uninstall)
95041ab64890Smrg	    if test -n "$library_names"; then
95051ab64890Smrg	      # Do each command in the postuninstall commands.
950688de56ccSmrg	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
95071ab64890Smrg	    fi
95081ab64890Smrg
95091ab64890Smrg	    if test -n "$old_library"; then
95101ab64890Smrg	      # Do each command in the old_postuninstall commands.
951188de56ccSmrg	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
95121ab64890Smrg	    fi
95131ab64890Smrg	    # FIXME: should reinstall the best remaining shared library.
95141ab64890Smrg	    ;;
95151ab64890Smrg	  esac
95161ab64890Smrg	fi
95171ab64890Smrg	;;
95181ab64890Smrg
95191ab64890Smrg      *.lo)
95201ab64890Smrg	# Possibly a libtool object, so verify it.
952188de56ccSmrg	if func_lalib_p "$file"; then
95221ab64890Smrg
95231ab64890Smrg	  # Read the .lo file
952488de56ccSmrg	  func_source $dir/$name
95251ab64890Smrg
95261ab64890Smrg	  # Add PIC object to the list of files to remove.
952788de56ccSmrg	  if test -n "$pic_object" &&
952888de56ccSmrg	     test "$pic_object" != none; then
9529e9fcaa8aSmrg	    func_append rmfiles " $dir/$pic_object"
95301ab64890Smrg	  fi
95311ab64890Smrg
95321ab64890Smrg	  # Add non-PIC object to the list of files to remove.
953388de56ccSmrg	  if test -n "$non_pic_object" &&
953488de56ccSmrg	     test "$non_pic_object" != none; then
9535e9fcaa8aSmrg	    func_append rmfiles " $dir/$non_pic_object"
95361ab64890Smrg	  fi
95371ab64890Smrg	fi
95381ab64890Smrg	;;
95391ab64890Smrg
95401ab64890Smrg      *)
9541e9fcaa8aSmrg	if test "$opt_mode" = clean ; then
95421ab64890Smrg	  noexename=$name
95431ab64890Smrg	  case $file in
95441ab64890Smrg	  *.exe)
954588de56ccSmrg	    func_stripname '' '.exe' "$file"
954688de56ccSmrg	    file=$func_stripname_result
954788de56ccSmrg	    func_stripname '' '.exe' "$name"
954888de56ccSmrg	    noexename=$func_stripname_result
95491ab64890Smrg	    # $file with .exe has already been added to rmfiles,
95501ab64890Smrg	    # add $file without .exe
9551e9fcaa8aSmrg	    func_append rmfiles " $file"
95521ab64890Smrg	    ;;
95531ab64890Smrg	  esac
95541ab64890Smrg	  # Do a test to see if this is a libtool program.
955588de56ccSmrg	  if func_ltwrapper_p "$file"; then
955688de56ccSmrg	    if func_ltwrapper_executable_p "$file"; then
955788de56ccSmrg	      func_ltwrapper_scriptname "$file"
955888de56ccSmrg	      relink_command=
955988de56ccSmrg	      func_source $func_ltwrapper_scriptname_result
9560e9fcaa8aSmrg	      func_append rmfiles " $func_ltwrapper_scriptname_result"
956188de56ccSmrg	    else
956288de56ccSmrg	      relink_command=
956388de56ccSmrg	      func_source $dir/$noexename
956488de56ccSmrg	    fi
95651ab64890Smrg
95661ab64890Smrg	    # note $name still contains .exe if it was in $file originally
95671ab64890Smrg	    # as does the version of $file that was added into $rmfiles
9568e9fcaa8aSmrg	    func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
95691ab64890Smrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
9570e9fcaa8aSmrg	      func_append rmfiles " $odir/lt-$name"
95711ab64890Smrg	    fi
95721ab64890Smrg	    if test "X$noexename" != "X$name" ; then
9573e9fcaa8aSmrg	      func_append rmfiles " $odir/lt-${noexename}.c"
95741ab64890Smrg	    fi
95751ab64890Smrg	  fi
95761ab64890Smrg	fi
95771ab64890Smrg	;;
95781ab64890Smrg      esac
957988de56ccSmrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
95801ab64890Smrg    done
95811ab64890Smrg
95821ab64890Smrg    # Try to remove the ${objdir}s in the directories where we deleted files
95831ab64890Smrg    for dir in $rmdirs; do
95841ab64890Smrg      if test -d "$dir"; then
958588de56ccSmrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
95861ab64890Smrg      fi
95871ab64890Smrg    done
95881ab64890Smrg
95891ab64890Smrg    exit $exit_status
959088de56ccSmrg}
95911ab64890Smrg
9592e9fcaa8aSmrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
959388de56ccSmrg    func_mode_uninstall ${1+"$@"}
95942e9c7c8cSmrg
9595e9fcaa8aSmrgtest -z "$opt_mode" && {
959688de56ccSmrg  help="$generic_help"
959788de56ccSmrg  func_fatal_help "you must specify a MODE"
959888de56ccSmrg}
959988de56ccSmrg
960088de56ccSmrgtest -z "$exec_cmd" && \
9601e9fcaa8aSmrg  func_fatal_help "invalid operation mode \`$opt_mode'"
96021ab64890Smrg
96031ab64890Smrgif test -n "$exec_cmd"; then
960488de56ccSmrg  eval exec "$exec_cmd"
96051ab64890Smrg  exit $EXIT_FAILURE
96061ab64890Smrgfi
96071ab64890Smrg
960888de56ccSmrgexit $exit_status
96091ab64890Smrg
96101ab64890Smrg
96111ab64890Smrg# The TAGs below are defined such that we never get into a situation
96121ab64890Smrg# in which we disable both kinds of libraries.  Given conflicting
96131ab64890Smrg# choices, we go for a static library, that is the most portable,
96141ab64890Smrg# since we can't tell whether shared libraries were disabled because
96151ab64890Smrg# the user asked for that or because the platform doesn't support
96161ab64890Smrg# them.  This is particularly important on AIX, because we don't
96171ab64890Smrg# support having both static and shared libraries enabled at the same
96181ab64890Smrg# time on that platform, so we default to a shared-only configuration.
96191ab64890Smrg# If a disable-shared tag is given, we'll fallback to a static-only
96201ab64890Smrg# configuration.  But we'll never go from static-only to shared-only.
96211ab64890Smrg
96221ab64890Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
962388de56ccSmrgbuild_libtool_libs=no
962488de56ccSmrgbuild_old_libs=yes
96251ab64890Smrg# ### END LIBTOOL TAG CONFIG: disable-shared
96261ab64890Smrg
96271ab64890Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
962888de56ccSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
96291ab64890Smrg# ### END LIBTOOL TAG CONFIG: disable-static
96301ab64890Smrg
96311ab64890Smrg# Local Variables:
96321ab64890Smrg# mode:shell-script
96331ab64890Smrg# sh-indentation:2
96341ab64890Smrg# End:
963588de56ccSmrg# vi:sw=2
963688de56ccSmrg
9637