ltmain.sh revision eb411b4b
188de56ccSmrg
2eb411b4bSmrg# libtool (GNU libtool) 2.4.2
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,
6eb411b4bSmrg# 2007, 2008, 2009, 2010, 2011 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)
44eb411b4bSmrg#       --no-warn            don't display warning messages
45e9fcaa8aSmrg#       --tag=TAG            use configuration variables from tag TAG
46e9fcaa8aSmrg#   -v, --verbose            print more informational messages than default
47e9fcaa8aSmrg#       --no-verbose         don't print the extra informational messages
48e9fcaa8aSmrg#       --version            print version information
49e9fcaa8aSmrg#   -h, --help, --help-all   print short, long, or detailed help message
5088de56ccSmrg#
5188de56ccSmrg# MODE must be one of the following:
5288de56ccSmrg#
53e9fcaa8aSmrg#         clean              remove files from the build directory
54e9fcaa8aSmrg#         compile            compile a source file into a libtool object
55e9fcaa8aSmrg#         execute            automatically set library path, then run a program
56e9fcaa8aSmrg#         finish             complete the installation of libtool libraries
57e9fcaa8aSmrg#         install            install libraries or executables
58e9fcaa8aSmrg#         link               create a library or an executable
59e9fcaa8aSmrg#         uninstall          remove libraries from an installed directory
6088de56ccSmrg#
61e9fcaa8aSmrg# MODE-ARGS vary depending on the MODE.  When passed as first option,
62e9fcaa8aSmrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
6388de56ccSmrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
6488de56ccSmrg#
6588de56ccSmrg# When reporting a bug, please describe a test case to reproduce it and
6688de56ccSmrg# include the following information:
6788de56ccSmrg#
68e9fcaa8aSmrg#         host-triplet:	$host
69e9fcaa8aSmrg#         shell:		$SHELL
70e9fcaa8aSmrg#         compiler:		$LTCC
71e9fcaa8aSmrg#         compiler flags:		$LTCFLAGS
72e9fcaa8aSmrg#         linker:		$LD (gnu? $with_gnu_ld)
73eb411b4bSmrg#         $progname:	(GNU libtool) 2.4.2
74e9fcaa8aSmrg#         automake:	$automake_version
75e9fcaa8aSmrg#         autoconf:	$autoconf_version
7688de56ccSmrg#
7788de56ccSmrg# Report bugs to <bug-libtool@gnu.org>.
78e9fcaa8aSmrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
79e9fcaa8aSmrg# General help using GNU software: <http://www.gnu.org/gethelp/>.
801ab64890Smrg
81e9fcaa8aSmrgPROGRAM=libtool
821ab64890SmrgPACKAGE=libtool
83eb411b4bSmrgVERSION=2.4.2
8488de56ccSmrgTIMESTAMP=""
85eb411b4bSmrgpackage_revision=1.3337
861ab64890Smrg
8788de56ccSmrg# Be Bourne compatible
881ab64890Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
891ab64890Smrg  emulate sh
901ab64890Smrg  NULLCMD=:
911ab64890Smrg  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
921ab64890Smrg  # is contrary to our usage.  Disable this feature.
931ab64890Smrg  alias -g '${1+"$@"}'='"$@"'
941ab64890Smrg  setopt NO_GLOB_SUBST
951ab64890Smrgelse
961ab64890Smrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
971ab64890Smrgfi
981ab64890SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
991ab64890SmrgDUALCASE=1; export DUALCASE # for MKS sh
1001ab64890Smrg
101e9fcaa8aSmrg# A function that is used when there is no print builtin or printf.
102e9fcaa8aSmrgfunc_fallback_echo ()
103e9fcaa8aSmrg{
104e9fcaa8aSmrg  eval 'cat <<_LTECHO_EOF
105e9fcaa8aSmrg$1
106e9fcaa8aSmrg_LTECHO_EOF'
107e9fcaa8aSmrg}
108e9fcaa8aSmrg
10988de56ccSmrg# NLS nuisances: We save the old values to restore during execute mode.
11088de56ccSmrglt_user_locale=
11188de56ccSmrglt_safe_locale=
11261b2299dSmrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
1131ab64890Smrgdo
1141ab64890Smrg  eval "if test \"\${$lt_var+set}\" = set; then
11588de56ccSmrg          save_$lt_var=\$$lt_var
11688de56ccSmrg          $lt_var=C
1171ab64890Smrg	  export $lt_var
11888de56ccSmrg	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
11988de56ccSmrg	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
1201ab64890Smrg	fi"
1211ab64890Smrgdone
122e9fcaa8aSmrgLC_ALL=C
123e9fcaa8aSmrgLANGUAGE=C
124e9fcaa8aSmrgexport LANGUAGE LC_ALL
1251ab64890Smrg
12688de56ccSmrg$lt_unset CDPATH
12788de56ccSmrg
12888de56ccSmrg
129e9fcaa8aSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
130e9fcaa8aSmrg# is ksh but when the shell is invoked as "sh" and the current value of
131e9fcaa8aSmrg# the _XPG environment variable is not equal to 1 (one), the special
132e9fcaa8aSmrg# positional parameter $0, within a function call, is the name of the
133e9fcaa8aSmrg# function.
134e9fcaa8aSmrgprogpath="$0"
13588de56ccSmrg
13688de56ccSmrg
13788de56ccSmrg
13888de56ccSmrg: ${CP="cp -f"}
139e9fcaa8aSmrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
14088de56ccSmrg: ${MAKE="make"}
14188de56ccSmrg: ${MKDIR="mkdir"}
14288de56ccSmrg: ${MV="mv -f"}
14388de56ccSmrg: ${RM="rm -f"}
14488de56ccSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
14588de56ccSmrg: ${Xsed="$SED -e 1s/^X//"}
14688de56ccSmrg
14788de56ccSmrg# Global variables:
14888de56ccSmrgEXIT_SUCCESS=0
14988de56ccSmrgEXIT_FAILURE=1
15088de56ccSmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
15188de56ccSmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
15288de56ccSmrg
15388de56ccSmrgexit_status=$EXIT_SUCCESS
15461b2299dSmrg
1551ab64890Smrg# Make sure IFS has a sensible default
1561ab64890Smrglt_nl='
1571ab64890Smrg'
1581ab64890SmrgIFS=" 	$lt_nl"
1591ab64890Smrg
16088de56ccSmrgdirname="s,/[^/]*$,,"
16188de56ccSmrgbasename="s,^.*/,,"
16288de56ccSmrg
163e9fcaa8aSmrg# func_dirname file append nondir_replacement
164e9fcaa8aSmrg# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
165e9fcaa8aSmrg# otherwise set result to NONDIR_REPLACEMENT.
166e9fcaa8aSmrgfunc_dirname ()
167e9fcaa8aSmrg{
168e9fcaa8aSmrg    func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
169e9fcaa8aSmrg    if test "X$func_dirname_result" = "X${1}"; then
170e9fcaa8aSmrg      func_dirname_result="${3}"
171e9fcaa8aSmrg    else
172e9fcaa8aSmrg      func_dirname_result="$func_dirname_result${2}"
173e9fcaa8aSmrg    fi
174e9fcaa8aSmrg} # func_dirname may be replaced by extended shell implementation
175e9fcaa8aSmrg
176e9fcaa8aSmrg
177e9fcaa8aSmrg# func_basename file
178e9fcaa8aSmrgfunc_basename ()
179e9fcaa8aSmrg{
180e9fcaa8aSmrg    func_basename_result=`$ECHO "${1}" | $SED "$basename"`
181e9fcaa8aSmrg} # func_basename may be replaced by extended shell implementation
182e9fcaa8aSmrg
183e9fcaa8aSmrg
18488de56ccSmrg# func_dirname_and_basename file append nondir_replacement
18588de56ccSmrg# perform func_basename and func_dirname in a single function
18688de56ccSmrg# call:
18788de56ccSmrg#   dirname:  Compute the dirname of FILE.  If nonempty,
18888de56ccSmrg#             add APPEND to the result, otherwise set result
18988de56ccSmrg#             to NONDIR_REPLACEMENT.
19088de56ccSmrg#             value returned in "$func_dirname_result"
19188de56ccSmrg#   basename: Compute filename of FILE.
19288de56ccSmrg#             value retuned in "$func_basename_result"
19388de56ccSmrg# Implementation must be kept synchronized with func_dirname
19488de56ccSmrg# and func_basename. For efficiency, we do not delegate to
19588de56ccSmrg# those functions but instead duplicate the functionality here.
19688de56ccSmrgfunc_dirname_and_basename ()
19788de56ccSmrg{
198e9fcaa8aSmrg    # Extract subdirectory from the argument.
199e9fcaa8aSmrg    func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
200e9fcaa8aSmrg    if test "X$func_dirname_result" = "X${1}"; then
201e9fcaa8aSmrg      func_dirname_result="${3}"
202e9fcaa8aSmrg    else
203e9fcaa8aSmrg      func_dirname_result="$func_dirname_result${2}"
204e9fcaa8aSmrg    fi
205e9fcaa8aSmrg    func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
206e9fcaa8aSmrg} # func_dirname_and_basename may be replaced by extended shell implementation
207e9fcaa8aSmrg
208e9fcaa8aSmrg
209e9fcaa8aSmrg# func_stripname prefix suffix name
210e9fcaa8aSmrg# strip PREFIX and SUFFIX off of NAME.
211e9fcaa8aSmrg# PREFIX and SUFFIX must not contain globbing or regex special
212e9fcaa8aSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading
213e9fcaa8aSmrg# dot (in which case that matches only a dot).
214e9fcaa8aSmrg# func_strip_suffix prefix name
215e9fcaa8aSmrgfunc_stripname ()
216e9fcaa8aSmrg{
217e9fcaa8aSmrg    case ${2} in
218e9fcaa8aSmrg      .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
219e9fcaa8aSmrg      *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
220e9fcaa8aSmrg    esac
221e9fcaa8aSmrg} # func_stripname may be replaced by extended shell implementation
222e9fcaa8aSmrg
223e9fcaa8aSmrg
224e9fcaa8aSmrg# These SED scripts presuppose an absolute path with a trailing slash.
225e9fcaa8aSmrgpathcar='s,^/\([^/]*\).*$,\1,'
226e9fcaa8aSmrgpathcdr='s,^/[^/]*,,'
227e9fcaa8aSmrgremovedotparts=':dotsl
228e9fcaa8aSmrg		s@/\./@/@g
229e9fcaa8aSmrg		t dotsl
230e9fcaa8aSmrg		s,/\.$,/,'
231e9fcaa8aSmrgcollapseslashes='s@/\{1,\}@/@g'
232e9fcaa8aSmrgfinalslash='s,/*$,/,'
233e9fcaa8aSmrg
234e9fcaa8aSmrg# func_normal_abspath PATH
235e9fcaa8aSmrg# Remove doubled-up and trailing slashes, "." path components,
236e9fcaa8aSmrg# and cancel out any ".." path components in PATH after making
237e9fcaa8aSmrg# it an absolute path.
238e9fcaa8aSmrg#             value returned in "$func_normal_abspath_result"
239e9fcaa8aSmrgfunc_normal_abspath ()
240e9fcaa8aSmrg{
241e9fcaa8aSmrg  # Start from root dir and reassemble the path.
242e9fcaa8aSmrg  func_normal_abspath_result=
243e9fcaa8aSmrg  func_normal_abspath_tpath=$1
244e9fcaa8aSmrg  func_normal_abspath_altnamespace=
245e9fcaa8aSmrg  case $func_normal_abspath_tpath in
246e9fcaa8aSmrg    "")
247e9fcaa8aSmrg      # Empty path, that just means $cwd.
248e9fcaa8aSmrg      func_stripname '' '/' "`pwd`"
249e9fcaa8aSmrg      func_normal_abspath_result=$func_stripname_result
250e9fcaa8aSmrg      return
251e9fcaa8aSmrg    ;;
252e9fcaa8aSmrg    # The next three entries are used to spot a run of precisely
253e9fcaa8aSmrg    # two leading slashes without using negated character classes;
254e9fcaa8aSmrg    # we take advantage of case's first-match behaviour.
255e9fcaa8aSmrg    ///*)
256e9fcaa8aSmrg      # Unusual form of absolute path, do nothing.
257e9fcaa8aSmrg    ;;
258e9fcaa8aSmrg    //*)
259e9fcaa8aSmrg      # Not necessarily an ordinary path; POSIX reserves leading '//'
260e9fcaa8aSmrg      # and for example Cygwin uses it to access remote file shares
261e9fcaa8aSmrg      # over CIFS/SMB, so we conserve a leading double slash if found.
262e9fcaa8aSmrg      func_normal_abspath_altnamespace=/
263e9fcaa8aSmrg    ;;
264e9fcaa8aSmrg    /*)
265e9fcaa8aSmrg      # Absolute path, do nothing.
266e9fcaa8aSmrg    ;;
267e9fcaa8aSmrg    *)
268e9fcaa8aSmrg      # Relative path, prepend $cwd.
269e9fcaa8aSmrg      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
270e9fcaa8aSmrg    ;;
271e9fcaa8aSmrg  esac
272e9fcaa8aSmrg  # Cancel out all the simple stuff to save iterations.  We also want
273e9fcaa8aSmrg  # the path to end with a slash for ease of parsing, so make sure
274e9fcaa8aSmrg  # there is one (and only one) here.
275e9fcaa8aSmrg  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
276e9fcaa8aSmrg        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
277e9fcaa8aSmrg  while :; do
278e9fcaa8aSmrg    # Processed it all yet?
279e9fcaa8aSmrg    if test "$func_normal_abspath_tpath" = / ; then
280e9fcaa8aSmrg      # If we ascended to the root using ".." the result may be empty now.
281e9fcaa8aSmrg      if test -z "$func_normal_abspath_result" ; then
282e9fcaa8aSmrg        func_normal_abspath_result=/
283e9fcaa8aSmrg      fi
284e9fcaa8aSmrg      break
285e9fcaa8aSmrg    fi
286e9fcaa8aSmrg    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
287e9fcaa8aSmrg        -e "$pathcar"`
288e9fcaa8aSmrg    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
289e9fcaa8aSmrg        -e "$pathcdr"`
290e9fcaa8aSmrg    # Figure out what to do with it
291e9fcaa8aSmrg    case $func_normal_abspath_tcomponent in
292e9fcaa8aSmrg      "")
293e9fcaa8aSmrg        # Trailing empty path component, ignore it.
294e9fcaa8aSmrg      ;;
295e9fcaa8aSmrg      ..)
296e9fcaa8aSmrg        # Parent dir; strip last assembled component from result.
297e9fcaa8aSmrg        func_dirname "$func_normal_abspath_result"
298e9fcaa8aSmrg        func_normal_abspath_result=$func_dirname_result
299e9fcaa8aSmrg      ;;
300e9fcaa8aSmrg      *)
301e9fcaa8aSmrg        # Actual path component, append it.
302e9fcaa8aSmrg        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
303e9fcaa8aSmrg      ;;
304e9fcaa8aSmrg    esac
305e9fcaa8aSmrg  done
306e9fcaa8aSmrg  # Restore leading double-slash if one was found on entry.
307e9fcaa8aSmrg  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
30888de56ccSmrg}
3092e9c7c8cSmrg
310e9fcaa8aSmrg# func_relative_path SRCDIR DSTDIR
311e9fcaa8aSmrg# generates a relative path from SRCDIR to DSTDIR, with a trailing
312e9fcaa8aSmrg# slash if non-empty, suitable for immediately appending a filename
313e9fcaa8aSmrg# without needing to append a separator.
314e9fcaa8aSmrg#             value returned in "$func_relative_path_result"
315e9fcaa8aSmrgfunc_relative_path ()
316e9fcaa8aSmrg{
317e9fcaa8aSmrg  func_relative_path_result=
318e9fcaa8aSmrg  func_normal_abspath "$1"
319e9fcaa8aSmrg  func_relative_path_tlibdir=$func_normal_abspath_result
320e9fcaa8aSmrg  func_normal_abspath "$2"
321e9fcaa8aSmrg  func_relative_path_tbindir=$func_normal_abspath_result
322e9fcaa8aSmrg
323e9fcaa8aSmrg  # Ascend the tree starting from libdir
324e9fcaa8aSmrg  while :; do
325e9fcaa8aSmrg    # check if we have found a prefix of bindir
326e9fcaa8aSmrg    case $func_relative_path_tbindir in
327e9fcaa8aSmrg      $func_relative_path_tlibdir)
328e9fcaa8aSmrg        # found an exact match
329e9fcaa8aSmrg        func_relative_path_tcancelled=
330e9fcaa8aSmrg        break
331e9fcaa8aSmrg        ;;
332e9fcaa8aSmrg      $func_relative_path_tlibdir*)
333e9fcaa8aSmrg        # found a matching prefix
334e9fcaa8aSmrg        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
335e9fcaa8aSmrg        func_relative_path_tcancelled=$func_stripname_result
336e9fcaa8aSmrg        if test -z "$func_relative_path_result"; then
337e9fcaa8aSmrg          func_relative_path_result=.
338e9fcaa8aSmrg        fi
339e9fcaa8aSmrg        break
340e9fcaa8aSmrg        ;;
341e9fcaa8aSmrg      *)
342e9fcaa8aSmrg        func_dirname $func_relative_path_tlibdir
343e9fcaa8aSmrg        func_relative_path_tlibdir=${func_dirname_result}
344e9fcaa8aSmrg        if test "x$func_relative_path_tlibdir" = x ; then
345e9fcaa8aSmrg          # Have to descend all the way to the root!
346e9fcaa8aSmrg          func_relative_path_result=../$func_relative_path_result
347e9fcaa8aSmrg          func_relative_path_tcancelled=$func_relative_path_tbindir
348e9fcaa8aSmrg          break
349e9fcaa8aSmrg        fi
350e9fcaa8aSmrg        func_relative_path_result=../$func_relative_path_result
351e9fcaa8aSmrg        ;;
352e9fcaa8aSmrg    esac
353e9fcaa8aSmrg  done
35488de56ccSmrg
355e9fcaa8aSmrg  # Now calculate path; take care to avoid doubling-up slashes.
356e9fcaa8aSmrg  func_stripname '' '/' "$func_relative_path_result"
357e9fcaa8aSmrg  func_relative_path_result=$func_stripname_result
358e9fcaa8aSmrg  func_stripname '/' '/' "$func_relative_path_tcancelled"
359e9fcaa8aSmrg  if test "x$func_stripname_result" != x ; then
360e9fcaa8aSmrg    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
361e9fcaa8aSmrg  fi
362e9fcaa8aSmrg
363e9fcaa8aSmrg  # Normalisation. If bindir is libdir, return empty string,
364e9fcaa8aSmrg  # else relative path ending with a slash; either way, target
365e9fcaa8aSmrg  # file name can be directly appended.
366e9fcaa8aSmrg  if test ! -z "$func_relative_path_result"; then
367e9fcaa8aSmrg    func_stripname './' '' "$func_relative_path_result/"
368e9fcaa8aSmrg    func_relative_path_result=$func_stripname_result
369e9fcaa8aSmrg  fi
370e9fcaa8aSmrg}
37188de56ccSmrg
37288de56ccSmrg# The name of this program:
37388de56ccSmrgfunc_dirname_and_basename "$progpath"
37488de56ccSmrgprogname=$func_basename_result
37588de56ccSmrg
37688de56ccSmrg# Make sure we have an absolute path for reexecution:
37788de56ccSmrgcase $progpath in
37888de56ccSmrg  [\\/]*|[A-Za-z]:\\*) ;;
37988de56ccSmrg  *[\\/]*)
38088de56ccSmrg     progdir=$func_dirname_result
38188de56ccSmrg     progdir=`cd "$progdir" && pwd`
38288de56ccSmrg     progpath="$progdir/$progname"
38388de56ccSmrg     ;;
38488de56ccSmrg  *)
38588de56ccSmrg     save_IFS="$IFS"
386eb411b4bSmrg     IFS=${PATH_SEPARATOR-:}
38788de56ccSmrg     for progdir in $PATH; do
38888de56ccSmrg       IFS="$save_IFS"
38988de56ccSmrg       test -x "$progdir/$progname" && break
39088de56ccSmrg     done
39188de56ccSmrg     IFS="$save_IFS"
39288de56ccSmrg     test -n "$progdir" || progdir=`pwd`
39388de56ccSmrg     progpath="$progdir/$progname"
39488de56ccSmrg     ;;
39588de56ccSmrgesac
39688de56ccSmrg
39788de56ccSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
39888de56ccSmrg# metacharacters that are still active within double-quoted strings.
39988de56ccSmrgXsed="${SED}"' -e 1s/^X//'
40088de56ccSmrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g'
40188de56ccSmrg
40288de56ccSmrg# Same as above, but do not quote variable references.
40388de56ccSmrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g'
40488de56ccSmrg
405e9fcaa8aSmrg# Sed substitution that turns a string into a regex matching for the
406e9fcaa8aSmrg# string literally.
407e9fcaa8aSmrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
408e9fcaa8aSmrg
409e9fcaa8aSmrg# Sed substitution that converts a w32 file name or path
410e9fcaa8aSmrg# which contains forward slashes, into one that contains
411e9fcaa8aSmrg# (escaped) backslashes.  A very naive implementation.
412e9fcaa8aSmrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
413e9fcaa8aSmrg
41488de56ccSmrg# Re-`\' parameter expansions in output of double_quote_subst that were
41588de56ccSmrg# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
41688de56ccSmrg# in input to double_quote_subst, that '$' was protected from expansion.
41788de56ccSmrg# Since each input `\' is now two `\'s, look for any number of runs of
41888de56ccSmrg# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
41988de56ccSmrgbs='\\'
42088de56ccSmrgbs2='\\\\'
42188de56ccSmrgbs4='\\\\\\\\'
42288de56ccSmrgdollar='\$'
42388de56ccSmrgsed_double_backslash="\
42488de56ccSmrg  s/$bs4/&\\
42588de56ccSmrg/g
42688de56ccSmrg  s/^$bs2$dollar/$bs&/
42788de56ccSmrg  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
42888de56ccSmrg  s/\n//g"
42988de56ccSmrg
43088de56ccSmrg# Standard options:
43188de56ccSmrgopt_dry_run=false
43288de56ccSmrgopt_help=false
43388de56ccSmrgopt_quiet=false
43488de56ccSmrgopt_verbose=false
43588de56ccSmrgopt_warning=:
43688de56ccSmrg
43788de56ccSmrg# func_echo arg...
43888de56ccSmrg# Echo program name prefixed message, along with the current mode
43988de56ccSmrg# name if it has been set yet.
44088de56ccSmrgfunc_echo ()
44188de56ccSmrg{
442e9fcaa8aSmrg    $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
44388de56ccSmrg}
44488de56ccSmrg
44588de56ccSmrg# func_verbose arg...
44688de56ccSmrg# Echo program name prefixed message in verbose mode only.
44788de56ccSmrgfunc_verbose ()
44888de56ccSmrg{
44988de56ccSmrg    $opt_verbose && func_echo ${1+"$@"}
45088de56ccSmrg
45188de56ccSmrg    # A bug in bash halts the script if the last line of a function
45288de56ccSmrg    # fails when set -e is in force, so we need another command to
45388de56ccSmrg    # work around that:
45488de56ccSmrg    :
45588de56ccSmrg}
45688de56ccSmrg
457e9fcaa8aSmrg# func_echo_all arg...
458e9fcaa8aSmrg# Invoke $ECHO with all args, space-separated.
459e9fcaa8aSmrgfunc_echo_all ()
460e9fcaa8aSmrg{
461e9fcaa8aSmrg    $ECHO "$*"
462e9fcaa8aSmrg}
463e9fcaa8aSmrg
46488de56ccSmrg# func_error arg...
46588de56ccSmrg# Echo program name prefixed message to standard error.
46688de56ccSmrgfunc_error ()
46788de56ccSmrg{
468e9fcaa8aSmrg    $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
46988de56ccSmrg}
47088de56ccSmrg
47188de56ccSmrg# func_warning arg...
47288de56ccSmrg# Echo program name prefixed warning message to standard error.
47388de56ccSmrgfunc_warning ()
47488de56ccSmrg{
475e9fcaa8aSmrg    $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
47688de56ccSmrg
47788de56ccSmrg    # bash bug again:
47888de56ccSmrg    :
47988de56ccSmrg}
48088de56ccSmrg
48188de56ccSmrg# func_fatal_error arg...
48288de56ccSmrg# Echo program name prefixed message to standard error, and exit.
48388de56ccSmrgfunc_fatal_error ()
48488de56ccSmrg{
48588de56ccSmrg    func_error ${1+"$@"}
48688de56ccSmrg    exit $EXIT_FAILURE
48788de56ccSmrg}
48888de56ccSmrg
48988de56ccSmrg# func_fatal_help arg...
49088de56ccSmrg# Echo program name prefixed message to standard error, followed by
49188de56ccSmrg# a help hint, and exit.
49288de56ccSmrgfunc_fatal_help ()
49388de56ccSmrg{
49488de56ccSmrg    func_error ${1+"$@"}
49588de56ccSmrg    func_fatal_error "$help"
49688de56ccSmrg}
49788de56ccSmrghelp="Try \`$progname --help' for more information."  ## default
49888de56ccSmrg
49988de56ccSmrg
50088de56ccSmrg# func_grep expression filename
50188de56ccSmrg# Check whether EXPRESSION matches any line of FILENAME, without output.
50288de56ccSmrgfunc_grep ()
50388de56ccSmrg{
50488de56ccSmrg    $GREP "$1" "$2" >/dev/null 2>&1
50588de56ccSmrg}
50688de56ccSmrg
50788de56ccSmrg
50888de56ccSmrg# func_mkdir_p directory-path
50988de56ccSmrg# Make sure the entire path to DIRECTORY-PATH is available.
51088de56ccSmrgfunc_mkdir_p ()
51188de56ccSmrg{
51288de56ccSmrg    my_directory_path="$1"
51388de56ccSmrg    my_dir_list=
51488de56ccSmrg
51588de56ccSmrg    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
51688de56ccSmrg
51788de56ccSmrg      # Protect directory names starting with `-'
51888de56ccSmrg      case $my_directory_path in
51988de56ccSmrg        -*) my_directory_path="./$my_directory_path" ;;
52088de56ccSmrg      esac
52188de56ccSmrg
52288de56ccSmrg      # While some portion of DIR does not yet exist...
52388de56ccSmrg      while test ! -d "$my_directory_path"; do
52488de56ccSmrg        # ...make a list in topmost first order.  Use a colon delimited
52588de56ccSmrg	# list incase some portion of path contains whitespace.
52688de56ccSmrg        my_dir_list="$my_directory_path:$my_dir_list"
52788de56ccSmrg
52888de56ccSmrg        # If the last portion added has no slash in it, the list is done
52988de56ccSmrg        case $my_directory_path in */*) ;; *) break ;; esac
53088de56ccSmrg
53188de56ccSmrg        # ...otherwise throw away the child directory and loop
532e9fcaa8aSmrg        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
53388de56ccSmrg      done
534e9fcaa8aSmrg      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
53588de56ccSmrg
53688de56ccSmrg      save_mkdir_p_IFS="$IFS"; IFS=':'
53788de56ccSmrg      for my_dir in $my_dir_list; do
53888de56ccSmrg	IFS="$save_mkdir_p_IFS"
53988de56ccSmrg        # mkdir can fail with a `File exist' error if two processes
54088de56ccSmrg        # try to create one of the directories concurrently.  Don't
54188de56ccSmrg        # stop in that case!
54288de56ccSmrg        $MKDIR "$my_dir" 2>/dev/null || :
54388de56ccSmrg      done
54488de56ccSmrg      IFS="$save_mkdir_p_IFS"
54588de56ccSmrg
54688de56ccSmrg      # Bail out if we (or some other process) failed to create a directory.
54788de56ccSmrg      test -d "$my_directory_path" || \
54888de56ccSmrg        func_fatal_error "Failed to create \`$1'"
54988de56ccSmrg    fi
55088de56ccSmrg}
5511ab64890Smrg
5521ab64890Smrg
5531ab64890Smrg# func_mktempdir [string]
5541ab64890Smrg# Make a temporary directory that won't clash with other running
5551ab64890Smrg# libtool processes, and avoids race conditions if possible.  If
5561ab64890Smrg# given, STRING is the basename for that directory.
5571ab64890Smrgfunc_mktempdir ()
5581ab64890Smrg{
5591ab64890Smrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
5601ab64890Smrg
56188de56ccSmrg    if test "$opt_dry_run" = ":"; then
5621ab64890Smrg      # Return a directory name, but don't create it in dry-run mode
5631ab64890Smrg      my_tmpdir="${my_template}-$$"
5641ab64890Smrg    else
5651ab64890Smrg
5661ab64890Smrg      # If mktemp works, use that first and foremost
5671ab64890Smrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
5681ab64890Smrg
5691ab64890Smrg      if test ! -d "$my_tmpdir"; then
57088de56ccSmrg        # Failing that, at least try and use $RANDOM to avoid a race
57188de56ccSmrg        my_tmpdir="${my_template}-${RANDOM-0}$$"
5721ab64890Smrg
57388de56ccSmrg        save_mktempdir_umask=`umask`
57488de56ccSmrg        umask 0077
57588de56ccSmrg        $MKDIR "$my_tmpdir"
57688de56ccSmrg        umask $save_mktempdir_umask
5771ab64890Smrg      fi
5781ab64890Smrg
5791ab64890Smrg      # If we're not in dry-run mode, bomb out on failure
58088de56ccSmrg      test -d "$my_tmpdir" || \
58188de56ccSmrg        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
5821ab64890Smrg    fi
5831ab64890Smrg
584e9fcaa8aSmrg    $ECHO "$my_tmpdir"
5851ab64890Smrg}
5861ab64890Smrg
5871ab64890Smrg
58888de56ccSmrg# func_quote_for_eval arg
58988de56ccSmrg# Aesthetically quote ARG to be evaled later.
59088de56ccSmrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
59188de56ccSmrg# is double-quoted, suitable for a subsequent eval, whereas
59288de56ccSmrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
59388de56ccSmrg# which are still active within double quotes backslashified.
59488de56ccSmrgfunc_quote_for_eval ()
5951ab64890Smrg{
59688de56ccSmrg    case $1 in
59788de56ccSmrg      *[\\\`\"\$]*)
598e9fcaa8aSmrg	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
59988de56ccSmrg      *)
60088de56ccSmrg        func_quote_for_eval_unquoted_result="$1" ;;
60188de56ccSmrg    esac
60288de56ccSmrg
60388de56ccSmrg    case $func_quote_for_eval_unquoted_result in
60488de56ccSmrg      # Double-quote args containing shell metacharacters to delay
60588de56ccSmrg      # word splitting, command substitution and and variable
60688de56ccSmrg      # expansion for a subsequent eval.
60788de56ccSmrg      # Many Bourne shells cannot handle close brackets correctly
60888de56ccSmrg      # in scan sets, so we specify it separately.
60988de56ccSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
61088de56ccSmrg        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
61188de56ccSmrg        ;;
61288de56ccSmrg      *)
61388de56ccSmrg        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
6141ab64890Smrg    esac
6151ab64890Smrg}
6161ab64890Smrg
6171ab64890Smrg
61888de56ccSmrg# func_quote_for_expand arg
61988de56ccSmrg# Aesthetically quote ARG to be evaled later; same as above,
62088de56ccSmrg# but do not quote variable references.
62188de56ccSmrgfunc_quote_for_expand ()
6221ab64890Smrg{
62388de56ccSmrg    case $1 in
62488de56ccSmrg      *[\\\`\"]*)
625e9fcaa8aSmrg	my_arg=`$ECHO "$1" | $SED \
62688de56ccSmrg	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
6271ab64890Smrg      *)
62888de56ccSmrg        my_arg="$1" ;;
62988de56ccSmrg    esac
63088de56ccSmrg
63188de56ccSmrg    case $my_arg in
63288de56ccSmrg      # Double-quote args containing shell metacharacters to delay
63388de56ccSmrg      # word splitting and command substitution for a subsequent eval.
63488de56ccSmrg      # Many Bourne shells cannot handle close brackets correctly
63588de56ccSmrg      # in scan sets, so we specify it separately.
63688de56ccSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
63788de56ccSmrg        my_arg="\"$my_arg\""
63888de56ccSmrg        ;;
63988de56ccSmrg    esac
64088de56ccSmrg
64188de56ccSmrg    func_quote_for_expand_result="$my_arg"
6421ab64890Smrg}
6431ab64890Smrg
6441ab64890Smrg
64588de56ccSmrg# func_show_eval cmd [fail_exp]
64688de56ccSmrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
64788de56ccSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
64888de56ccSmrg# is given, then evaluate it.
64988de56ccSmrgfunc_show_eval ()
6501ab64890Smrg{
65188de56ccSmrg    my_cmd="$1"
65288de56ccSmrg    my_fail_exp="${2-:}"
6532e9c7c8cSmrg
65488de56ccSmrg    ${opt_silent-false} || {
65588de56ccSmrg      func_quote_for_expand "$my_cmd"
65688de56ccSmrg      eval "func_echo $func_quote_for_expand_result"
65788de56ccSmrg    }
65888de56ccSmrg
65988de56ccSmrg    if ${opt_dry_run-false}; then :; else
66088de56ccSmrg      eval "$my_cmd"
66188de56ccSmrg      my_status=$?
66288de56ccSmrg      if test "$my_status" -eq 0; then :; else
66388de56ccSmrg	eval "(exit $my_status); $my_fail_exp"
66488de56ccSmrg      fi
6651ab64890Smrg    fi
6661ab64890Smrg}
6671ab64890Smrg
66888de56ccSmrg
66988de56ccSmrg# func_show_eval_locale cmd [fail_exp]
67088de56ccSmrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
67188de56ccSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
67288de56ccSmrg# is given, then evaluate it.  Use the saved locale for evaluation.
67388de56ccSmrgfunc_show_eval_locale ()
6741ab64890Smrg{
67588de56ccSmrg    my_cmd="$1"
67688de56ccSmrg    my_fail_exp="${2-:}"
67788de56ccSmrg
67888de56ccSmrg    ${opt_silent-false} || {
67988de56ccSmrg      func_quote_for_expand "$my_cmd"
68088de56ccSmrg      eval "func_echo $func_quote_for_expand_result"
68188de56ccSmrg    }
68288de56ccSmrg
68388de56ccSmrg    if ${opt_dry_run-false}; then :; else
68488de56ccSmrg      eval "$lt_user_locale
68588de56ccSmrg	    $my_cmd"
68688de56ccSmrg      my_status=$?
68788de56ccSmrg      eval "$lt_safe_locale"
68888de56ccSmrg      if test "$my_status" -eq 0; then :; else
68988de56ccSmrg	eval "(exit $my_status); $my_fail_exp"
69088de56ccSmrg      fi
6911ab64890Smrg    fi
69288de56ccSmrg}
6931ab64890Smrg
694e9fcaa8aSmrg# func_tr_sh
695e9fcaa8aSmrg# Turn $1 into a string suitable for a shell variable name.
696e9fcaa8aSmrg# Result is stored in $func_tr_sh_result.  All characters
697e9fcaa8aSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
698e9fcaa8aSmrg# if $1 begins with a digit, a '_' is prepended as well.
699e9fcaa8aSmrgfunc_tr_sh ()
700e9fcaa8aSmrg{
701e9fcaa8aSmrg  case $1 in
702e9fcaa8aSmrg  [0-9]* | *[!a-zA-Z0-9_]*)
703e9fcaa8aSmrg    func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
704e9fcaa8aSmrg    ;;
705e9fcaa8aSmrg  * )
706e9fcaa8aSmrg    func_tr_sh_result=$1
707e9fcaa8aSmrg    ;;
708e9fcaa8aSmrg  esac
709e9fcaa8aSmrg}
71088de56ccSmrg
71188de56ccSmrg
71288de56ccSmrg# func_version
71388de56ccSmrg# Echo version message to standard output and exit.
71488de56ccSmrgfunc_version ()
71588de56ccSmrg{
716e9fcaa8aSmrg    $opt_debug
717e9fcaa8aSmrg
718e9fcaa8aSmrg    $SED -n '/(C)/!b go
719e9fcaa8aSmrg	:more
720e9fcaa8aSmrg	/\./!{
721e9fcaa8aSmrg	  N
722e9fcaa8aSmrg	  s/\n# / /
723e9fcaa8aSmrg	  b more
724e9fcaa8aSmrg	}
725e9fcaa8aSmrg	:go
726e9fcaa8aSmrg	/^# '$PROGRAM' (GNU /,/# warranty; / {
72788de56ccSmrg        s/^# //
72888de56ccSmrg	s/^# *$//
72988de56ccSmrg        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
73088de56ccSmrg        p
73188de56ccSmrg     }' < "$progpath"
73288de56ccSmrg     exit $?
73388de56ccSmrg}
73488de56ccSmrg
73588de56ccSmrg# func_usage
73688de56ccSmrg# Echo short help message to standard output and exit.
73788de56ccSmrgfunc_usage ()
73888de56ccSmrg{
739e9fcaa8aSmrg    $opt_debug
740e9fcaa8aSmrg
741e9fcaa8aSmrg    $SED -n '/^# Usage:/,/^#  *.*--help/ {
74288de56ccSmrg        s/^# //
74388de56ccSmrg	s/^# *$//
74488de56ccSmrg	s/\$progname/'$progname'/
74588de56ccSmrg	p
74688de56ccSmrg    }' < "$progpath"
747e9fcaa8aSmrg    echo
74888de56ccSmrg    $ECHO "run \`$progname --help | more' for full usage"
74988de56ccSmrg    exit $?
75088de56ccSmrg}
75188de56ccSmrg
752e9fcaa8aSmrg# func_help [NOEXIT]
753e9fcaa8aSmrg# Echo long help message to standard output and exit,
754e9fcaa8aSmrg# unless 'noexit' is passed as argument.
75588de56ccSmrgfunc_help ()
75688de56ccSmrg{
757e9fcaa8aSmrg    $opt_debug
758e9fcaa8aSmrg
75988de56ccSmrg    $SED -n '/^# Usage:/,/# Report bugs to/ {
760e9fcaa8aSmrg	:print
76188de56ccSmrg        s/^# //
76288de56ccSmrg	s/^# *$//
76388de56ccSmrg	s*\$progname*'$progname'*
76488de56ccSmrg	s*\$host*'"$host"'*
76588de56ccSmrg	s*\$SHELL*'"$SHELL"'*
76688de56ccSmrg	s*\$LTCC*'"$LTCC"'*
76788de56ccSmrg	s*\$LTCFLAGS*'"$LTCFLAGS"'*
76888de56ccSmrg	s*\$LD*'"$LD"'*
76988de56ccSmrg	s/\$with_gnu_ld/'"$with_gnu_ld"'/
770eb411b4bSmrg	s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/
771eb411b4bSmrg	s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/
77288de56ccSmrg	p
773e9fcaa8aSmrg	d
774e9fcaa8aSmrg     }
775e9fcaa8aSmrg     /^# .* home page:/b print
776e9fcaa8aSmrg     /^# General help using/b print
777e9fcaa8aSmrg     ' < "$progpath"
778e9fcaa8aSmrg    ret=$?
779e9fcaa8aSmrg    if test -z "$1"; then
780e9fcaa8aSmrg      exit $ret
781e9fcaa8aSmrg    fi
78288de56ccSmrg}
78388de56ccSmrg
78488de56ccSmrg# func_missing_arg argname
78588de56ccSmrg# Echo program name prefixed message to standard error and set global
78688de56ccSmrg# exit_cmd.
78788de56ccSmrgfunc_missing_arg ()
78888de56ccSmrg{
789e9fcaa8aSmrg    $opt_debug
790e9fcaa8aSmrg
791e9fcaa8aSmrg    func_error "missing argument for $1."
79288de56ccSmrg    exit_cmd=exit
7931ab64890Smrg}
7941ab64890Smrg
7952e9c7c8cSmrg
796e9fcaa8aSmrg# func_split_short_opt shortopt
797e9fcaa8aSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell
798e9fcaa8aSmrg# variables after splitting SHORTOPT after the 2nd character.
799e9fcaa8aSmrgfunc_split_short_opt ()
800e9fcaa8aSmrg{
801e9fcaa8aSmrg    my_sed_short_opt='1s/^\(..\).*$/\1/;q'
802e9fcaa8aSmrg    my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
803e9fcaa8aSmrg
804e9fcaa8aSmrg    func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
805e9fcaa8aSmrg    func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
806e9fcaa8aSmrg} # func_split_short_opt may be replaced by extended shell implementation
8072e9c7c8cSmrg
80888de56ccSmrg
809e9fcaa8aSmrg# func_split_long_opt longopt
810e9fcaa8aSmrg# Set func_split_long_opt_name and func_split_long_opt_arg shell
811e9fcaa8aSmrg# variables after splitting LONGOPT at the `=' sign.
812e9fcaa8aSmrgfunc_split_long_opt ()
813e9fcaa8aSmrg{
814e9fcaa8aSmrg    my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
815e9fcaa8aSmrg    my_sed_long_arg='1s/^--[^=]*=//'
816e9fcaa8aSmrg
817e9fcaa8aSmrg    func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
818e9fcaa8aSmrg    func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
819e9fcaa8aSmrg} # func_split_long_opt may be replaced by extended shell implementation
820e9fcaa8aSmrg
821e9fcaa8aSmrgexit_cmd=:
822e9fcaa8aSmrg
82388de56ccSmrg
82488de56ccSmrg
8251ab64890Smrg
8261ab64890Smrg
82788de56ccSmrgmagic="%%%MAGIC variable%%%"
82888de56ccSmrgmagic_exe="%%%MAGIC EXE variable%%%"
8291ab64890Smrg
83088de56ccSmrg# Global variables.
83188de56ccSmrgnonopt=
83288de56ccSmrgpreserve_args=
83388de56ccSmrglo2o="s/\\.lo\$/.${objext}/"
83488de56ccSmrgo2lo="s/\\.${objext}\$/.lo/"
83588de56ccSmrgextracted_archives=
83688de56ccSmrgextracted_serial=0
8372e9c7c8cSmrg
83888de56ccSmrg# If this variable is set in any of the actions, the command in it
83988de56ccSmrg# will be execed at the end.  This prevents here-documents from being
84088de56ccSmrg# left over by shells.
84188de56ccSmrgexec_cmd=
84288de56ccSmrg
843e9fcaa8aSmrg# func_append var value
844e9fcaa8aSmrg# Append VALUE to the end of shell variable VAR.
845e9fcaa8aSmrgfunc_append ()
846e9fcaa8aSmrg{
847e9fcaa8aSmrg    eval "${1}=\$${1}\${2}"
848e9fcaa8aSmrg} # func_append may be replaced by extended shell implementation
849e9fcaa8aSmrg
850e9fcaa8aSmrg# func_append_quoted var value
851e9fcaa8aSmrg# Quote VALUE and append to the end of shell variable VAR, separated
852e9fcaa8aSmrg# by a space.
853e9fcaa8aSmrgfunc_append_quoted ()
854e9fcaa8aSmrg{
855e9fcaa8aSmrg    func_quote_for_eval "${2}"
856e9fcaa8aSmrg    eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
857e9fcaa8aSmrg} # func_append_quoted may be replaced by extended shell implementation
858e9fcaa8aSmrg
859e9fcaa8aSmrg
860e9fcaa8aSmrg# func_arith arithmetic-term...
861e9fcaa8aSmrgfunc_arith ()
862e9fcaa8aSmrg{
863e9fcaa8aSmrg    func_arith_result=`expr "${@}"`
864e9fcaa8aSmrg} # func_arith may be replaced by extended shell implementation
865e9fcaa8aSmrg
866e9fcaa8aSmrg
867e9fcaa8aSmrg# func_len string
868e9fcaa8aSmrg# STRING may not start with a hyphen.
869e9fcaa8aSmrgfunc_len ()
870e9fcaa8aSmrg{
871e9fcaa8aSmrg    func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
872e9fcaa8aSmrg} # func_len may be replaced by extended shell implementation
873e9fcaa8aSmrg
874e9fcaa8aSmrg
875e9fcaa8aSmrg# func_lo2o object
876e9fcaa8aSmrgfunc_lo2o ()
877e9fcaa8aSmrg{
878e9fcaa8aSmrg    func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
879e9fcaa8aSmrg} # func_lo2o may be replaced by extended shell implementation
880e9fcaa8aSmrg
881e9fcaa8aSmrg
882e9fcaa8aSmrg# func_xform libobj-or-source
883e9fcaa8aSmrgfunc_xform ()
884e9fcaa8aSmrg{
885e9fcaa8aSmrg    func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
886e9fcaa8aSmrg} # func_xform may be replaced by extended shell implementation
887e9fcaa8aSmrg
888e9fcaa8aSmrg
88988de56ccSmrg# func_fatal_configuration arg...
89088de56ccSmrg# Echo program name prefixed message to standard error, followed by
89188de56ccSmrg# a configuration failure hint, and exit.
89288de56ccSmrgfunc_fatal_configuration ()
89388de56ccSmrg{
89488de56ccSmrg    func_error ${1+"$@"}
89588de56ccSmrg    func_error "See the $PACKAGE documentation for more information."
89688de56ccSmrg    func_fatal_error "Fatal configuration error."
89788de56ccSmrg}
8981ab64890Smrg
8992e9c7c8cSmrg
90088de56ccSmrg# func_config
90188de56ccSmrg# Display the configuration for all the tags in this script.
90288de56ccSmrgfunc_config ()
90388de56ccSmrg{
90488de56ccSmrg    re_begincf='^# ### BEGIN LIBTOOL'
90588de56ccSmrg    re_endcf='^# ### END LIBTOOL'
90688de56ccSmrg
90788de56ccSmrg    # Default configuration.
90888de56ccSmrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
9091ab64890Smrg
9101ab64890Smrg    # Now print the configurations for the tags.
9111ab64890Smrg    for tagname in $taglist; do
91288de56ccSmrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
9131ab64890Smrg    done
914b4ee4795Smrg
91588de56ccSmrg    exit $?
91688de56ccSmrg}
917b4ee4795Smrg
91888de56ccSmrg# func_features
91988de56ccSmrg# Display the features supported by this script.
92088de56ccSmrgfunc_features ()
92188de56ccSmrg{
922e9fcaa8aSmrg    echo "host: $host"
9231ab64890Smrg    if test "$build_libtool_libs" = yes; then
924e9fcaa8aSmrg      echo "enable shared libraries"
9251ab64890Smrg    else
926e9fcaa8aSmrg      echo "disable shared libraries"
9271ab64890Smrg    fi
9281ab64890Smrg    if test "$build_old_libs" = yes; then
929e9fcaa8aSmrg      echo "enable static libraries"
9301ab64890Smrg    else
931e9fcaa8aSmrg      echo "disable static libraries"
9321ab64890Smrg    fi
93388de56ccSmrg
9341ab64890Smrg    exit $?
93588de56ccSmrg}
9361ab64890Smrg
93788de56ccSmrg# func_enable_tag tagname
93888de56ccSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or
93988de56ccSmrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
94088de56ccSmrg# variable here.
94188de56ccSmrgfunc_enable_tag ()
94288de56ccSmrg{
94388de56ccSmrg  # Global variable:
94488de56ccSmrg  tagname="$1"
9451ab64890Smrg
94688de56ccSmrg  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
94788de56ccSmrg  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
94888de56ccSmrg  sed_extractcf="/$re_begincf/,/$re_endcf/p"
9492e9c7c8cSmrg
95088de56ccSmrg  # Validate tagname.
95188de56ccSmrg  case $tagname in
95288de56ccSmrg    *[!-_A-Za-z0-9,/]*)
95388de56ccSmrg      func_fatal_error "invalid tag name: $tagname"
95488de56ccSmrg      ;;
95588de56ccSmrg  esac
9561ab64890Smrg
95788de56ccSmrg  # Don't test for the "default" C tag, as we know it's
95888de56ccSmrg  # there but not specially marked.
95988de56ccSmrg  case $tagname in
96088de56ccSmrg    CC) ;;
96188de56ccSmrg    *)
96288de56ccSmrg      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
96388de56ccSmrg	taglist="$taglist $tagname"
96488de56ccSmrg
96588de56ccSmrg	# Evaluate the configuration.  Be careful to quote the path
96688de56ccSmrg	# and the sed script, to avoid splitting on whitespace, but
96788de56ccSmrg	# also don't use non-portable quotes within backquotes within
96888de56ccSmrg	# quotes we have to do it in 2 steps:
96988de56ccSmrg	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
97088de56ccSmrg	eval "$extractedcf"
97188de56ccSmrg      else
97288de56ccSmrg	func_error "ignoring unknown tag $tagname"
97388de56ccSmrg      fi
97488de56ccSmrg      ;;
97588de56ccSmrg  esac
97688de56ccSmrg}
97788de56ccSmrg
978e9fcaa8aSmrg# func_check_version_match
979e9fcaa8aSmrg# Ensure that we are using m4 macros, and libtool script from the same
980e9fcaa8aSmrg# release of libtool.
981e9fcaa8aSmrgfunc_check_version_match ()
98288de56ccSmrg{
983e9fcaa8aSmrg  if test "$package_revision" != "$macro_revision"; then
984e9fcaa8aSmrg    if test "$VERSION" != "$macro_version"; then
985e9fcaa8aSmrg      if test -z "$macro_version"; then
986e9fcaa8aSmrg        cat >&2 <<_LT_EOF
987e9fcaa8aSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
988e9fcaa8aSmrg$progname: definition of this LT_INIT comes from an older release.
989e9fcaa8aSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
990e9fcaa8aSmrg$progname: and run autoconf again.
991e9fcaa8aSmrg_LT_EOF
992e9fcaa8aSmrg      else
993e9fcaa8aSmrg        cat >&2 <<_LT_EOF
994e9fcaa8aSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
995e9fcaa8aSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
996e9fcaa8aSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
997e9fcaa8aSmrg$progname: and run autoconf again.
998e9fcaa8aSmrg_LT_EOF
999e9fcaa8aSmrg      fi
1000e9fcaa8aSmrg    else
1001e9fcaa8aSmrg      cat >&2 <<_LT_EOF
1002e9fcaa8aSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
1003e9fcaa8aSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
1004e9fcaa8aSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
1005e9fcaa8aSmrg$progname: of $PACKAGE $VERSION and run autoconf again.
1006e9fcaa8aSmrg_LT_EOF
1007e9fcaa8aSmrg    fi
1008e9fcaa8aSmrg
1009e9fcaa8aSmrg    exit $EXIT_MISMATCH
1010e9fcaa8aSmrg  fi
1011e9fcaa8aSmrg}
1012e9fcaa8aSmrg
1013e9fcaa8aSmrg
1014e9fcaa8aSmrg# Shorthand for --mode=foo, only valid as the first argument
1015e9fcaa8aSmrgcase $1 in
1016e9fcaa8aSmrgclean|clea|cle|cl)
1017e9fcaa8aSmrg  shift; set dummy --mode clean ${1+"$@"}; shift
1018e9fcaa8aSmrg  ;;
1019e9fcaa8aSmrgcompile|compil|compi|comp|com|co|c)
1020e9fcaa8aSmrg  shift; set dummy --mode compile ${1+"$@"}; shift
1021e9fcaa8aSmrg  ;;
1022e9fcaa8aSmrgexecute|execut|execu|exec|exe|ex|e)
1023e9fcaa8aSmrg  shift; set dummy --mode execute ${1+"$@"}; shift
1024e9fcaa8aSmrg  ;;
1025e9fcaa8aSmrgfinish|finis|fini|fin|fi|f)
1026e9fcaa8aSmrg  shift; set dummy --mode finish ${1+"$@"}; shift
1027e9fcaa8aSmrg  ;;
1028e9fcaa8aSmrginstall|instal|insta|inst|ins|in|i)
1029e9fcaa8aSmrg  shift; set dummy --mode install ${1+"$@"}; shift
1030e9fcaa8aSmrg  ;;
1031e9fcaa8aSmrglink|lin|li|l)
1032e9fcaa8aSmrg  shift; set dummy --mode link ${1+"$@"}; shift
1033e9fcaa8aSmrg  ;;
1034e9fcaa8aSmrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
1035e9fcaa8aSmrg  shift; set dummy --mode uninstall ${1+"$@"}; shift
1036e9fcaa8aSmrg  ;;
1037e9fcaa8aSmrgesac
1038b4ee4795Smrg
10391ab64890Smrg
1040e9fcaa8aSmrg
1041e9fcaa8aSmrg# Option defaults:
1042e9fcaa8aSmrgopt_debug=:
1043e9fcaa8aSmrgopt_dry_run=false
1044e9fcaa8aSmrgopt_config=false
1045e9fcaa8aSmrgopt_preserve_dup_deps=false
1046e9fcaa8aSmrgopt_features=false
1047e9fcaa8aSmrgopt_finish=false
1048e9fcaa8aSmrgopt_help=false
1049e9fcaa8aSmrgopt_help_all=false
1050e9fcaa8aSmrgopt_silent=:
1051eb411b4bSmrgopt_warning=:
1052e9fcaa8aSmrgopt_verbose=:
1053e9fcaa8aSmrgopt_silent=false
1054e9fcaa8aSmrgopt_verbose=false
1055e9fcaa8aSmrg
1056e9fcaa8aSmrg
1057e9fcaa8aSmrg# Parse options once, thoroughly.  This comes as soon as possible in the
1058e9fcaa8aSmrg# script to make things like `--version' happen as quickly as we can.
1059e9fcaa8aSmrg{
1060e9fcaa8aSmrg  # this just eases exit handling
1061e9fcaa8aSmrg  while test $# -gt 0; do
106288de56ccSmrg    opt="$1"
106388de56ccSmrg    shift
106488de56ccSmrg    case $opt in
1065e9fcaa8aSmrg      --debug|-x)	opt_debug='set -x'
106688de56ccSmrg			func_echo "enabling shell trace mode"
106788de56ccSmrg			$opt_debug
106888de56ccSmrg			;;
1069e9fcaa8aSmrg      --dry-run|--dryrun|-n)
1070e9fcaa8aSmrg			opt_dry_run=:
107188de56ccSmrg			;;
1072e9fcaa8aSmrg      --config)
1073e9fcaa8aSmrg			opt_config=:
1074e9fcaa8aSmrgfunc_config
1075e9fcaa8aSmrg			;;
1076e9fcaa8aSmrg      --dlopen|-dlopen)
1077e9fcaa8aSmrg			optarg="$1"
1078e9fcaa8aSmrg			opt_dlopen="${opt_dlopen+$opt_dlopen
1079e9fcaa8aSmrg}$optarg"
108088de56ccSmrg			shift
108188de56ccSmrg			;;
108288de56ccSmrg      --preserve-dup-deps)
1083e9fcaa8aSmrg			opt_preserve_dup_deps=:
108488de56ccSmrg			;;
1085e9fcaa8aSmrg      --features)
1086e9fcaa8aSmrg			opt_features=:
1087e9fcaa8aSmrgfunc_features
1088e9fcaa8aSmrg			;;
1089e9fcaa8aSmrg      --finish)
1090e9fcaa8aSmrg			opt_finish=:
1091e9fcaa8aSmrgset dummy --mode finish ${1+"$@"}; shift
1092e9fcaa8aSmrg			;;
1093e9fcaa8aSmrg      --help)
1094e9fcaa8aSmrg			opt_help=:
1095e9fcaa8aSmrg			;;
1096e9fcaa8aSmrg      --help-all)
1097e9fcaa8aSmrg			opt_help_all=:
1098e9fcaa8aSmrgopt_help=': help-all'
1099e9fcaa8aSmrg			;;
1100e9fcaa8aSmrg      --mode)
1101e9fcaa8aSmrg			test $# = 0 && func_missing_arg $opt && break
1102e9fcaa8aSmrg			optarg="$1"
1103e9fcaa8aSmrg			opt_mode="$optarg"
1104e9fcaa8aSmrgcase $optarg in
1105e9fcaa8aSmrg  # Valid mode arguments:
1106e9fcaa8aSmrg  clean|compile|execute|finish|install|link|relink|uninstall) ;;
1107e9fcaa8aSmrg
1108e9fcaa8aSmrg  # Catch anything else as an error
1109e9fcaa8aSmrg  *) func_error "invalid argument for $opt"
1110e9fcaa8aSmrg     exit_cmd=exit
1111e9fcaa8aSmrg     break
1112e9fcaa8aSmrg     ;;
1113e9fcaa8aSmrgesac
1114e9fcaa8aSmrg			shift
1115e9fcaa8aSmrg			;;
1116e9fcaa8aSmrg      --no-silent|--no-quiet)
111788de56ccSmrg			opt_silent=false
1118eb411b4bSmrgfunc_append preserve_args " $opt"
1119eb411b4bSmrg			;;
1120eb411b4bSmrg      --no-warning|--no-warn)
1121eb411b4bSmrg			opt_warning=false
1122e9fcaa8aSmrgfunc_append preserve_args " $opt"
112388de56ccSmrg			;;
1124e9fcaa8aSmrg      --no-verbose)
1125e9fcaa8aSmrg			opt_verbose=false
1126e9fcaa8aSmrgfunc_append preserve_args " $opt"
1127e9fcaa8aSmrg			;;
1128e9fcaa8aSmrg      --silent|--quiet)
1129e9fcaa8aSmrg			opt_silent=:
1130e9fcaa8aSmrgfunc_append preserve_args " $opt"
1131e9fcaa8aSmrg        opt_verbose=false
1132e9fcaa8aSmrg			;;
1133e9fcaa8aSmrg      --verbose|-v)
1134e9fcaa8aSmrg			opt_verbose=:
1135e9fcaa8aSmrgfunc_append preserve_args " $opt"
1136e9fcaa8aSmrgopt_silent=false
1137e9fcaa8aSmrg			;;
1138e9fcaa8aSmrg      --tag)
1139e9fcaa8aSmrg			test $# = 0 && func_missing_arg $opt && break
1140e9fcaa8aSmrg			optarg="$1"
1141e9fcaa8aSmrg			opt_tag="$optarg"
1142e9fcaa8aSmrgfunc_append preserve_args " $opt $optarg"
1143e9fcaa8aSmrgfunc_enable_tag "$optarg"
114488de56ccSmrg			shift
114588de56ccSmrg			;;
114688de56ccSmrg
1147e9fcaa8aSmrg      -\?|-h)		func_usage				;;
1148e9fcaa8aSmrg      --help)		func_help				;;
1149e9fcaa8aSmrg      --version)	func_version				;;
1150e9fcaa8aSmrg
115188de56ccSmrg      # Separate optargs to long options:
1152e9fcaa8aSmrg      --*=*)
1153e9fcaa8aSmrg			func_split_long_opt "$opt"
1154e9fcaa8aSmrg			set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
115588de56ccSmrg			shift
115688de56ccSmrg			;;
115788de56ccSmrg
1158e9fcaa8aSmrg      # Separate non-argument short options:
1159e9fcaa8aSmrg      -\?*|-h*|-n*|-v*)
1160e9fcaa8aSmrg			func_split_short_opt "$opt"
1161e9fcaa8aSmrg			set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
1162e9fcaa8aSmrg			shift
116388de56ccSmrg			;;
1164e9fcaa8aSmrg
1165e9fcaa8aSmrg      --)		break					;;
1166e9fcaa8aSmrg      -*)		func_fatal_help "unrecognized option \`$opt'" ;;
1167e9fcaa8aSmrg      *)		set dummy "$opt" ${1+"$@"};	shift; break  ;;
116888de56ccSmrg    esac
116988de56ccSmrg  done
117088de56ccSmrg
1171e9fcaa8aSmrg  # Validate options:
1172e9fcaa8aSmrg
1173e9fcaa8aSmrg  # save first non-option argument
1174e9fcaa8aSmrg  if test "$#" -gt 0; then
1175e9fcaa8aSmrg    nonopt="$opt"
1176e9fcaa8aSmrg    shift
1177e9fcaa8aSmrg  fi
1178e9fcaa8aSmrg
1179e9fcaa8aSmrg  # preserve --debug
1180e9fcaa8aSmrg  test "$opt_debug" = : || func_append preserve_args " --debug"
118188de56ccSmrg
118288de56ccSmrg  case $host in
118388de56ccSmrg    *cygwin* | *mingw* | *pw32* | *cegcc*)
118488de56ccSmrg      # don't eliminate duplications in $postdeps and $predeps
118588de56ccSmrg      opt_duplicate_compiler_generated_deps=:
1186b4ee4795Smrg      ;;
1187b4ee4795Smrg    *)
1188e9fcaa8aSmrg      opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
118988de56ccSmrg      ;;
119088de56ccSmrg  esac
11912e9c7c8cSmrg
1192e9fcaa8aSmrg  $opt_help || {
1193e9fcaa8aSmrg    # Sanity checks first:
1194e9fcaa8aSmrg    func_check_version_match
119588de56ccSmrg
1196e9fcaa8aSmrg    if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
1197e9fcaa8aSmrg      func_fatal_configuration "not configured to build any kind of library"
119888de56ccSmrg    fi
119988de56ccSmrg
1200e9fcaa8aSmrg    # Darwin sucks
1201e9fcaa8aSmrg    eval std_shrext=\"$shrext_cmds\"
120288de56ccSmrg
1203e9fcaa8aSmrg    # Only execute mode is allowed to have -dlopen flags.
1204e9fcaa8aSmrg    if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
1205e9fcaa8aSmrg      func_error "unrecognized option \`-dlopen'"
1206e9fcaa8aSmrg      $ECHO "$help" 1>&2
1207e9fcaa8aSmrg      exit $EXIT_FAILURE
1208e9fcaa8aSmrg    fi
12091ab64890Smrg
1210e9fcaa8aSmrg    # Change the help message to a mode-specific one.
1211e9fcaa8aSmrg    generic_help="$help"
1212e9fcaa8aSmrg    help="Try \`$progname --help --mode=$opt_mode' for more information."
1213e9fcaa8aSmrg  }
121488de56ccSmrg
121588de56ccSmrg
1216e9fcaa8aSmrg  # Bail if the options were screwed
1217e9fcaa8aSmrg  $exit_cmd $EXIT_FAILURE
1218e9fcaa8aSmrg}
121988de56ccSmrg
122088de56ccSmrg
12211ab64890Smrg
12221ab64890Smrg
1223e9fcaa8aSmrg## ----------- ##
1224e9fcaa8aSmrg##    Main.    ##
1225e9fcaa8aSmrg## ----------- ##
12261ab64890Smrg
122788de56ccSmrg# func_lalib_p file
122888de56ccSmrg# True iff FILE is a libtool `.la' library or `.lo' object file.
122988de56ccSmrg# This function is only a basic sanity check; it will hardly flush out
123088de56ccSmrg# determined imposters.
123188de56ccSmrgfunc_lalib_p ()
123288de56ccSmrg{
123388de56ccSmrg    test -f "$1" &&
123488de56ccSmrg      $SED -e 4q "$1" 2>/dev/null \
123588de56ccSmrg        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
123688de56ccSmrg}
12371ab64890Smrg
123888de56ccSmrg# func_lalib_unsafe_p file
123988de56ccSmrg# True iff FILE is a libtool `.la' library or `.lo' object file.
124088de56ccSmrg# This function implements the same check as func_lalib_p without
124188de56ccSmrg# resorting to external programs.  To this end, it redirects stdin and
124288de56ccSmrg# closes it afterwards, without saving the original file descriptor.
124388de56ccSmrg# As a safety measure, use it only where a negative result would be
124488de56ccSmrg# fatal anyway.  Works if `file' does not exist.
124588de56ccSmrgfunc_lalib_unsafe_p ()
124688de56ccSmrg{
124788de56ccSmrg    lalib_p=no
124888de56ccSmrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
124988de56ccSmrg	for lalib_p_l in 1 2 3 4
125088de56ccSmrg	do
125188de56ccSmrg	    read lalib_p_line
125288de56ccSmrg	    case "$lalib_p_line" in
125388de56ccSmrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
125488de56ccSmrg	    esac
125588de56ccSmrg	done
125688de56ccSmrg	exec 0<&5 5<&-
125788de56ccSmrg    fi
125888de56ccSmrg    test "$lalib_p" = yes
125988de56ccSmrg}
12601ab64890Smrg
126188de56ccSmrg# func_ltwrapper_script_p file
126288de56ccSmrg# True iff FILE is a libtool wrapper script
126388de56ccSmrg# This function is only a basic sanity check; it will hardly flush out
126488de56ccSmrg# determined imposters.
126588de56ccSmrgfunc_ltwrapper_script_p ()
126688de56ccSmrg{
126788de56ccSmrg    func_lalib_p "$1"
126888de56ccSmrg}
12691ab64890Smrg
127088de56ccSmrg# func_ltwrapper_executable_p file
127188de56ccSmrg# True iff FILE is a libtool wrapper executable
127288de56ccSmrg# This function is only a basic sanity check; it will hardly flush out
127388de56ccSmrg# determined imposters.
127488de56ccSmrgfunc_ltwrapper_executable_p ()
127588de56ccSmrg{
127688de56ccSmrg    func_ltwrapper_exec_suffix=
127788de56ccSmrg    case $1 in
127888de56ccSmrg    *.exe) ;;
127988de56ccSmrg    *) func_ltwrapper_exec_suffix=.exe ;;
128088de56ccSmrg    esac
128188de56ccSmrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
128288de56ccSmrg}
12832e9c7c8cSmrg
128488de56ccSmrg# func_ltwrapper_scriptname file
128588de56ccSmrg# Assumes file is an ltwrapper_executable
128688de56ccSmrg# uses $file to determine the appropriate filename for a
128788de56ccSmrg# temporary ltwrapper_script.
128888de56ccSmrgfunc_ltwrapper_scriptname ()
128988de56ccSmrg{
1290e9fcaa8aSmrg    func_dirname_and_basename "$1" "" "."
1291e9fcaa8aSmrg    func_stripname '' '.exe' "$func_basename_result"
1292e9fcaa8aSmrg    func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
129388de56ccSmrg}
129488de56ccSmrg
129588de56ccSmrg# func_ltwrapper_p file
129688de56ccSmrg# True iff FILE is a libtool wrapper script or wrapper executable
129788de56ccSmrg# This function is only a basic sanity check; it will hardly flush out
129888de56ccSmrg# determined imposters.
129988de56ccSmrgfunc_ltwrapper_p ()
130088de56ccSmrg{
130188de56ccSmrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
130288de56ccSmrg}
130388de56ccSmrg
130488de56ccSmrg
130588de56ccSmrg# func_execute_cmds commands fail_cmd
130688de56ccSmrg# Execute tilde-delimited COMMANDS.
130788de56ccSmrg# If FAIL_CMD is given, eval that upon failure.
130888de56ccSmrg# FAIL_CMD may read-access the current command in variable CMD!
130988de56ccSmrgfunc_execute_cmds ()
131088de56ccSmrg{
131188de56ccSmrg    $opt_debug
131288de56ccSmrg    save_ifs=$IFS; IFS='~'
131388de56ccSmrg    for cmd in $1; do
131488de56ccSmrg      IFS=$save_ifs
131588de56ccSmrg      eval cmd=\"$cmd\"
131688de56ccSmrg      func_show_eval "$cmd" "${2-:}"
131788de56ccSmrg    done
131888de56ccSmrg    IFS=$save_ifs
131988de56ccSmrg}
132088de56ccSmrg
132188de56ccSmrg
132288de56ccSmrg# func_source file
132388de56ccSmrg# Source FILE, adding directory component if necessary.
132488de56ccSmrg# Note that it is not necessary on cygwin/mingw to append a dot to
132588de56ccSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
132688de56ccSmrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
132788de56ccSmrg# `FILE.' does not work on cygwin managed mounts.
132888de56ccSmrgfunc_source ()
132988de56ccSmrg{
133088de56ccSmrg    $opt_debug
133188de56ccSmrg    case $1 in
133288de56ccSmrg    */* | *\\*)	. "$1" ;;
133388de56ccSmrg    *)		. "./$1" ;;
133488de56ccSmrg    esac
133588de56ccSmrg}
133688de56ccSmrg
133788de56ccSmrg
1338e9fcaa8aSmrg# func_resolve_sysroot PATH
1339e9fcaa8aSmrg# Replace a leading = in PATH with a sysroot.  Store the result into
1340e9fcaa8aSmrg# func_resolve_sysroot_result
1341e9fcaa8aSmrgfunc_resolve_sysroot ()
1342e9fcaa8aSmrg{
1343e9fcaa8aSmrg  func_resolve_sysroot_result=$1
1344e9fcaa8aSmrg  case $func_resolve_sysroot_result in
1345e9fcaa8aSmrg  =*)
1346e9fcaa8aSmrg    func_stripname '=' '' "$func_resolve_sysroot_result"
1347e9fcaa8aSmrg    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
1348e9fcaa8aSmrg    ;;
1349e9fcaa8aSmrg  esac
1350e9fcaa8aSmrg}
1351e9fcaa8aSmrg
1352e9fcaa8aSmrg# func_replace_sysroot PATH
1353e9fcaa8aSmrg# If PATH begins with the sysroot, replace it with = and
1354e9fcaa8aSmrg# store the result into func_replace_sysroot_result.
1355e9fcaa8aSmrgfunc_replace_sysroot ()
1356e9fcaa8aSmrg{
1357e9fcaa8aSmrg  case "$lt_sysroot:$1" in
1358e9fcaa8aSmrg  ?*:"$lt_sysroot"*)
1359e9fcaa8aSmrg    func_stripname "$lt_sysroot" '' "$1"
1360e9fcaa8aSmrg    func_replace_sysroot_result="=$func_stripname_result"
1361e9fcaa8aSmrg    ;;
1362e9fcaa8aSmrg  *)
1363e9fcaa8aSmrg    # Including no sysroot.
1364e9fcaa8aSmrg    func_replace_sysroot_result=$1
1365e9fcaa8aSmrg    ;;
1366e9fcaa8aSmrg  esac
1367e9fcaa8aSmrg}
1368e9fcaa8aSmrg
136988de56ccSmrg# func_infer_tag arg
137088de56ccSmrg# Infer tagged configuration to use if any are available and
137188de56ccSmrg# if one wasn't chosen via the "--tag" command line option.
137288de56ccSmrg# Only attempt this if the compiler in the base compile
137388de56ccSmrg# command doesn't match the default compiler.
137488de56ccSmrg# arg is usually of the form 'gcc ...'
137588de56ccSmrgfunc_infer_tag ()
137688de56ccSmrg{
137788de56ccSmrg    $opt_debug
137888de56ccSmrg    if test -n "$available_tags" && test -z "$tagname"; then
137988de56ccSmrg      CC_quoted=
138088de56ccSmrg      for arg in $CC; do
1381e9fcaa8aSmrg	func_append_quoted CC_quoted "$arg"
138288de56ccSmrg      done
1383e9fcaa8aSmrg      CC_expanded=`func_echo_all $CC`
1384e9fcaa8aSmrg      CC_quoted_expanded=`func_echo_all $CC_quoted`
138588de56ccSmrg      case $@ in
138688de56ccSmrg      # Blanks in the command may have been stripped by the calling shell,
138788de56ccSmrg      # but not from the CC environment variable when configure was run.
1388e9fcaa8aSmrg      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1389e9fcaa8aSmrg      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
139088de56ccSmrg      # Blanks at the start of $base_compile will cause this to fail
139188de56ccSmrg      # if we don't check for them as well.
139288de56ccSmrg      *)
139388de56ccSmrg	for z in $available_tags; do
139488de56ccSmrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
139588de56ccSmrg	    # Evaluate the configuration.
139688de56ccSmrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
139788de56ccSmrg	    CC_quoted=
139888de56ccSmrg	    for arg in $CC; do
139988de56ccSmrg	      # Double-quote args containing other shell metacharacters.
1400e9fcaa8aSmrg	      func_append_quoted CC_quoted "$arg"
140188de56ccSmrg	    done
1402e9fcaa8aSmrg	    CC_expanded=`func_echo_all $CC`
1403e9fcaa8aSmrg	    CC_quoted_expanded=`func_echo_all $CC_quoted`
140488de56ccSmrg	    case "$@ " in
1405e9fcaa8aSmrg	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1406e9fcaa8aSmrg	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
140788de56ccSmrg	      # The compiler in the base compile command matches
140888de56ccSmrg	      # the one in the tagged configuration.
140988de56ccSmrg	      # Assume this is the tagged configuration we want.
141088de56ccSmrg	      tagname=$z
141188de56ccSmrg	      break
141288de56ccSmrg	      ;;
141388de56ccSmrg	    esac
141488de56ccSmrg	  fi
141588de56ccSmrg	done
141688de56ccSmrg	# If $tagname still isn't set, then no tagged configuration
141788de56ccSmrg	# was found and let the user know that the "--tag" command
141888de56ccSmrg	# line option must be used.
141988de56ccSmrg	if test -z "$tagname"; then
142088de56ccSmrg	  func_echo "unable to infer tagged configuration"
142188de56ccSmrg	  func_fatal_error "specify a tag with \`--tag'"
142288de56ccSmrg#	else
142388de56ccSmrg#	  func_verbose "using $tagname tagged configuration"
142488de56ccSmrg	fi
142588de56ccSmrg	;;
142688de56ccSmrg      esac
142788de56ccSmrg    fi
142888de56ccSmrg}
142988de56ccSmrg
143088de56ccSmrg
143188de56ccSmrg
143288de56ccSmrg# func_write_libtool_object output_name pic_name nonpic_name
143388de56ccSmrg# Create a libtool object file (analogous to a ".la" file),
143488de56ccSmrg# but don't create it if we're doing a dry run.
143588de56ccSmrgfunc_write_libtool_object ()
143688de56ccSmrg{
143788de56ccSmrg    write_libobj=${1}
143888de56ccSmrg    if test "$build_libtool_libs" = yes; then
143988de56ccSmrg      write_lobj=\'${2}\'
144088de56ccSmrg    else
144188de56ccSmrg      write_lobj=none
144288de56ccSmrg    fi
144388de56ccSmrg
144488de56ccSmrg    if test "$build_old_libs" = yes; then
144588de56ccSmrg      write_oldobj=\'${3}\'
144688de56ccSmrg    else
144788de56ccSmrg      write_oldobj=none
144888de56ccSmrg    fi
144988de56ccSmrg
145088de56ccSmrg    $opt_dry_run || {
145188de56ccSmrg      cat >${write_libobj}T <<EOF
145288de56ccSmrg# $write_libobj - a libtool object file
145388de56ccSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
145488de56ccSmrg#
145588de56ccSmrg# Please DO NOT delete this file!
145688de56ccSmrg# It is necessary for linking the library.
145788de56ccSmrg
145888de56ccSmrg# Name of the PIC object.
145988de56ccSmrgpic_object=$write_lobj
146088de56ccSmrg
146188de56ccSmrg# Name of the non-PIC object
146288de56ccSmrgnon_pic_object=$write_oldobj
146388de56ccSmrg
146488de56ccSmrgEOF
146588de56ccSmrg      $MV "${write_libobj}T" "${write_libobj}"
146688de56ccSmrg    }
146788de56ccSmrg}
146888de56ccSmrg
1469e9fcaa8aSmrg
1470e9fcaa8aSmrg##################################################
1471e9fcaa8aSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
1472e9fcaa8aSmrg##################################################
1473e9fcaa8aSmrg
1474e9fcaa8aSmrg# func_convert_core_file_wine_to_w32 ARG
1475e9fcaa8aSmrg# Helper function used by file name conversion functions when $build is *nix,
1476e9fcaa8aSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a
1477e9fcaa8aSmrg# correctly configured wine environment available, with the winepath program
1478e9fcaa8aSmrg# in $build's $PATH.
1479e9fcaa8aSmrg#
1480e9fcaa8aSmrg# ARG is the $build file name to be converted to w32 format.
1481e9fcaa8aSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will
1482e9fcaa8aSmrg# be empty on error (or when ARG is empty)
1483e9fcaa8aSmrgfunc_convert_core_file_wine_to_w32 ()
1484e9fcaa8aSmrg{
1485e9fcaa8aSmrg  $opt_debug
1486e9fcaa8aSmrg  func_convert_core_file_wine_to_w32_result="$1"
1487e9fcaa8aSmrg  if test -n "$1"; then
1488e9fcaa8aSmrg    # Unfortunately, winepath does not exit with a non-zero error code, so we
1489e9fcaa8aSmrg    # are forced to check the contents of stdout. On the other hand, if the
1490e9fcaa8aSmrg    # command is not found, the shell will set an exit code of 127 and print
1491e9fcaa8aSmrg    # *an error message* to stdout. So we must check for both error code of
1492e9fcaa8aSmrg    # zero AND non-empty stdout, which explains the odd construction:
1493e9fcaa8aSmrg    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
1494e9fcaa8aSmrg    if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
1495e9fcaa8aSmrg      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
1496e9fcaa8aSmrg        $SED -e "$lt_sed_naive_backslashify"`
1497e9fcaa8aSmrg    else
1498e9fcaa8aSmrg      func_convert_core_file_wine_to_w32_result=
1499e9fcaa8aSmrg    fi
1500e9fcaa8aSmrg  fi
1501e9fcaa8aSmrg}
1502e9fcaa8aSmrg# end: func_convert_core_file_wine_to_w32
1503e9fcaa8aSmrg
1504e9fcaa8aSmrg
1505e9fcaa8aSmrg# func_convert_core_path_wine_to_w32 ARG
1506e9fcaa8aSmrg# Helper function used by path conversion functions when $build is *nix, and
1507e9fcaa8aSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
1508e9fcaa8aSmrg# configured wine environment available, with the winepath program in $build's
1509e9fcaa8aSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters.
1510e9fcaa8aSmrg#
1511e9fcaa8aSmrg# ARG is path to be converted from $build format to win32.
1512e9fcaa8aSmrg# Result is available in $func_convert_core_path_wine_to_w32_result.
1513e9fcaa8aSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names
1514e9fcaa8aSmrg# are convertible, then the result may be empty.
1515e9fcaa8aSmrgfunc_convert_core_path_wine_to_w32 ()
1516e9fcaa8aSmrg{
1517e9fcaa8aSmrg  $opt_debug
1518e9fcaa8aSmrg  # unfortunately, winepath doesn't convert paths, only file names
1519e9fcaa8aSmrg  func_convert_core_path_wine_to_w32_result=""
1520e9fcaa8aSmrg  if test -n "$1"; then
1521e9fcaa8aSmrg    oldIFS=$IFS
1522e9fcaa8aSmrg    IFS=:
1523e9fcaa8aSmrg    for func_convert_core_path_wine_to_w32_f in $1; do
1524e9fcaa8aSmrg      IFS=$oldIFS
1525e9fcaa8aSmrg      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
1526e9fcaa8aSmrg      if test -n "$func_convert_core_file_wine_to_w32_result" ; then
1527e9fcaa8aSmrg        if test -z "$func_convert_core_path_wine_to_w32_result"; then
1528e9fcaa8aSmrg          func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
1529e9fcaa8aSmrg        else
1530e9fcaa8aSmrg          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
1531e9fcaa8aSmrg        fi
1532e9fcaa8aSmrg      fi
1533e9fcaa8aSmrg    done
1534e9fcaa8aSmrg    IFS=$oldIFS
1535e9fcaa8aSmrg  fi
1536e9fcaa8aSmrg}
1537e9fcaa8aSmrg# end: func_convert_core_path_wine_to_w32
1538e9fcaa8aSmrg
1539e9fcaa8aSmrg
1540e9fcaa8aSmrg# func_cygpath ARGS...
1541e9fcaa8aSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
1542e9fcaa8aSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
1543e9fcaa8aSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
1544e9fcaa8aSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input
1545e9fcaa8aSmrg# file name or path is assumed to be in w32 format, as previously converted
1546e9fcaa8aSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name
1547e9fcaa8aSmrg# or path in func_cygpath_result (input file name or path is assumed to be in
1548e9fcaa8aSmrg# Cygwin format). Returns an empty string on error.
1549e9fcaa8aSmrg#
1550e9fcaa8aSmrg# ARGS are passed to cygpath, with the last one being the file name or path to
1551e9fcaa8aSmrg# be converted.
1552e9fcaa8aSmrg#
1553e9fcaa8aSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
1554e9fcaa8aSmrg# environment variable; do not put it in $PATH.
1555e9fcaa8aSmrgfunc_cygpath ()
1556e9fcaa8aSmrg{
1557e9fcaa8aSmrg  $opt_debug
1558e9fcaa8aSmrg  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
1559e9fcaa8aSmrg    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
1560e9fcaa8aSmrg    if test "$?" -ne 0; then
1561e9fcaa8aSmrg      # on failure, ensure result is empty
1562e9fcaa8aSmrg      func_cygpath_result=
1563e9fcaa8aSmrg    fi
1564e9fcaa8aSmrg  else
1565e9fcaa8aSmrg    func_cygpath_result=
1566e9fcaa8aSmrg    func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
1567e9fcaa8aSmrg  fi
1568e9fcaa8aSmrg}
1569e9fcaa8aSmrg#end: func_cygpath
1570e9fcaa8aSmrg
1571e9fcaa8aSmrg
1572e9fcaa8aSmrg# func_convert_core_msys_to_w32 ARG
1573e9fcaa8aSmrg# Convert file name or path ARG from MSYS format to w32 format.  Return
1574e9fcaa8aSmrg# result in func_convert_core_msys_to_w32_result.
1575e9fcaa8aSmrgfunc_convert_core_msys_to_w32 ()
1576e9fcaa8aSmrg{
1577e9fcaa8aSmrg  $opt_debug
1578e9fcaa8aSmrg  # awkward: cmd appends spaces to result
1579e9fcaa8aSmrg  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
1580e9fcaa8aSmrg    $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
1581e9fcaa8aSmrg}
1582e9fcaa8aSmrg#end: func_convert_core_msys_to_w32
1583e9fcaa8aSmrg
1584e9fcaa8aSmrg
1585e9fcaa8aSmrg# func_convert_file_check ARG1 ARG2
1586e9fcaa8aSmrg# Verify that ARG1 (a file name in $build format) was converted to $host
1587e9fcaa8aSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting
1588e9fcaa8aSmrg# func_to_host_file_result to ARG1).
1589e9fcaa8aSmrgfunc_convert_file_check ()
1590e9fcaa8aSmrg{
1591e9fcaa8aSmrg  $opt_debug
1592e9fcaa8aSmrg  if test -z "$2" && test -n "$1" ; then
1593e9fcaa8aSmrg    func_error "Could not determine host file name corresponding to"
1594e9fcaa8aSmrg    func_error "  \`$1'"
1595e9fcaa8aSmrg    func_error "Continuing, but uninstalled executables may not work."
1596e9fcaa8aSmrg    # Fallback:
1597e9fcaa8aSmrg    func_to_host_file_result="$1"
1598e9fcaa8aSmrg  fi
1599e9fcaa8aSmrg}
1600e9fcaa8aSmrg# end func_convert_file_check
1601e9fcaa8aSmrg
1602e9fcaa8aSmrg
1603e9fcaa8aSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
1604e9fcaa8aSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host
1605e9fcaa8aSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
1606e9fcaa8aSmrg# func_to_host_file_result to a simplistic fallback value (see below).
1607e9fcaa8aSmrgfunc_convert_path_check ()
1608e9fcaa8aSmrg{
1609e9fcaa8aSmrg  $opt_debug
1610e9fcaa8aSmrg  if test -z "$4" && test -n "$3"; then
1611e9fcaa8aSmrg    func_error "Could not determine the host path corresponding to"
1612e9fcaa8aSmrg    func_error "  \`$3'"
1613e9fcaa8aSmrg    func_error "Continuing, but uninstalled executables may not work."
1614e9fcaa8aSmrg    # Fallback.  This is a deliberately simplistic "conversion" and
1615e9fcaa8aSmrg    # should not be "improved".  See libtool.info.
1616e9fcaa8aSmrg    if test "x$1" != "x$2"; then
1617e9fcaa8aSmrg      lt_replace_pathsep_chars="s|$1|$2|g"
1618e9fcaa8aSmrg      func_to_host_path_result=`echo "$3" |
1619e9fcaa8aSmrg        $SED -e "$lt_replace_pathsep_chars"`
1620e9fcaa8aSmrg    else
1621e9fcaa8aSmrg      func_to_host_path_result="$3"
1622e9fcaa8aSmrg    fi
1623e9fcaa8aSmrg  fi
1624e9fcaa8aSmrg}
1625e9fcaa8aSmrg# end func_convert_path_check
1626e9fcaa8aSmrg
1627e9fcaa8aSmrg
1628e9fcaa8aSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
1629e9fcaa8aSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
1630e9fcaa8aSmrg# and appending REPL if ORIG matches BACKPAT.
1631e9fcaa8aSmrgfunc_convert_path_front_back_pathsep ()
1632e9fcaa8aSmrg{
1633e9fcaa8aSmrg  $opt_debug
1634e9fcaa8aSmrg  case $4 in
1635e9fcaa8aSmrg  $1 ) func_to_host_path_result="$3$func_to_host_path_result"
1636e9fcaa8aSmrg    ;;
1637e9fcaa8aSmrg  esac
1638e9fcaa8aSmrg  case $4 in
1639e9fcaa8aSmrg  $2 ) func_append func_to_host_path_result "$3"
1640e9fcaa8aSmrg    ;;
1641e9fcaa8aSmrg  esac
1642e9fcaa8aSmrg}
1643e9fcaa8aSmrg# end func_convert_path_front_back_pathsep
1644e9fcaa8aSmrg
1645e9fcaa8aSmrg
1646e9fcaa8aSmrg##################################################
1647e9fcaa8aSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS #
1648e9fcaa8aSmrg##################################################
1649e9fcaa8aSmrg# invoked via `$to_host_file_cmd ARG'
1650e9fcaa8aSmrg#
1651e9fcaa8aSmrg# In each case, ARG is the path to be converted from $build to $host format.
1652e9fcaa8aSmrg# Result will be available in $func_to_host_file_result.
1653e9fcaa8aSmrg
1654e9fcaa8aSmrg
1655e9fcaa8aSmrg# func_to_host_file ARG
1656e9fcaa8aSmrg# Converts the file name ARG from $build format to $host format. Return result
1657e9fcaa8aSmrg# in func_to_host_file_result.
1658e9fcaa8aSmrgfunc_to_host_file ()
1659e9fcaa8aSmrg{
1660e9fcaa8aSmrg  $opt_debug
1661e9fcaa8aSmrg  $to_host_file_cmd "$1"
1662e9fcaa8aSmrg}
1663e9fcaa8aSmrg# end func_to_host_file
1664e9fcaa8aSmrg
1665e9fcaa8aSmrg
1666e9fcaa8aSmrg# func_to_tool_file ARG LAZY
1667e9fcaa8aSmrg# converts the file name ARG from $build format to toolchain format. Return
1668e9fcaa8aSmrg# result in func_to_tool_file_result.  If the conversion in use is listed
1669e9fcaa8aSmrg# in (the comma separated) LAZY, no conversion takes place.
1670e9fcaa8aSmrgfunc_to_tool_file ()
1671e9fcaa8aSmrg{
1672e9fcaa8aSmrg  $opt_debug
1673e9fcaa8aSmrg  case ,$2, in
1674e9fcaa8aSmrg    *,"$to_tool_file_cmd",*)
1675e9fcaa8aSmrg      func_to_tool_file_result=$1
1676e9fcaa8aSmrg      ;;
1677e9fcaa8aSmrg    *)
1678e9fcaa8aSmrg      $to_tool_file_cmd "$1"
1679e9fcaa8aSmrg      func_to_tool_file_result=$func_to_host_file_result
1680e9fcaa8aSmrg      ;;
1681e9fcaa8aSmrg  esac
1682e9fcaa8aSmrg}
1683e9fcaa8aSmrg# end func_to_tool_file
1684e9fcaa8aSmrg
1685e9fcaa8aSmrg
1686e9fcaa8aSmrg# func_convert_file_noop ARG
1687e9fcaa8aSmrg# Copy ARG to func_to_host_file_result.
1688e9fcaa8aSmrgfunc_convert_file_noop ()
1689e9fcaa8aSmrg{
1690e9fcaa8aSmrg  func_to_host_file_result="$1"
1691e9fcaa8aSmrg}
1692e9fcaa8aSmrg# end func_convert_file_noop
1693e9fcaa8aSmrg
1694e9fcaa8aSmrg
1695e9fcaa8aSmrg# func_convert_file_msys_to_w32 ARG
1696e9fcaa8aSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
1697e9fcaa8aSmrg# conversion to w32 is not available inside the cwrapper.  Returns result in
1698e9fcaa8aSmrg# func_to_host_file_result.
1699e9fcaa8aSmrgfunc_convert_file_msys_to_w32 ()
1700e9fcaa8aSmrg{
1701e9fcaa8aSmrg  $opt_debug
1702e9fcaa8aSmrg  func_to_host_file_result="$1"
1703e9fcaa8aSmrg  if test -n "$1"; then
1704e9fcaa8aSmrg    func_convert_core_msys_to_w32 "$1"
1705e9fcaa8aSmrg    func_to_host_file_result="$func_convert_core_msys_to_w32_result"
1706e9fcaa8aSmrg  fi
1707e9fcaa8aSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1708e9fcaa8aSmrg}
1709e9fcaa8aSmrg# end func_convert_file_msys_to_w32
1710e9fcaa8aSmrg
1711e9fcaa8aSmrg
1712e9fcaa8aSmrg# func_convert_file_cygwin_to_w32 ARG
1713e9fcaa8aSmrg# Convert file name ARG from Cygwin to w32 format.  Returns result in
1714e9fcaa8aSmrg# func_to_host_file_result.
1715e9fcaa8aSmrgfunc_convert_file_cygwin_to_w32 ()
1716e9fcaa8aSmrg{
1717e9fcaa8aSmrg  $opt_debug
1718e9fcaa8aSmrg  func_to_host_file_result="$1"
1719e9fcaa8aSmrg  if test -n "$1"; then
1720e9fcaa8aSmrg    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
1721e9fcaa8aSmrg    # LT_CYGPATH in this case.
1722e9fcaa8aSmrg    func_to_host_file_result=`cygpath -m "$1"`
1723e9fcaa8aSmrg  fi
1724e9fcaa8aSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1725e9fcaa8aSmrg}
1726e9fcaa8aSmrg# end func_convert_file_cygwin_to_w32
1727e9fcaa8aSmrg
1728e9fcaa8aSmrg
1729e9fcaa8aSmrg# func_convert_file_nix_to_w32 ARG
1730e9fcaa8aSmrg# Convert file name ARG from *nix to w32 format.  Requires a wine environment
1731e9fcaa8aSmrg# and a working winepath. Returns result in func_to_host_file_result.
1732e9fcaa8aSmrgfunc_convert_file_nix_to_w32 ()
1733e9fcaa8aSmrg{
1734e9fcaa8aSmrg  $opt_debug
1735e9fcaa8aSmrg  func_to_host_file_result="$1"
1736e9fcaa8aSmrg  if test -n "$1"; then
1737e9fcaa8aSmrg    func_convert_core_file_wine_to_w32 "$1"
1738e9fcaa8aSmrg    func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
1739e9fcaa8aSmrg  fi
1740e9fcaa8aSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1741e9fcaa8aSmrg}
1742e9fcaa8aSmrg# end func_convert_file_nix_to_w32
1743e9fcaa8aSmrg
1744e9fcaa8aSmrg
1745e9fcaa8aSmrg# func_convert_file_msys_to_cygwin ARG
1746e9fcaa8aSmrg# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
1747e9fcaa8aSmrg# Returns result in func_to_host_file_result.
1748e9fcaa8aSmrgfunc_convert_file_msys_to_cygwin ()
1749e9fcaa8aSmrg{
1750e9fcaa8aSmrg  $opt_debug
1751e9fcaa8aSmrg  func_to_host_file_result="$1"
1752e9fcaa8aSmrg  if test -n "$1"; then
1753e9fcaa8aSmrg    func_convert_core_msys_to_w32 "$1"
1754e9fcaa8aSmrg    func_cygpath -u "$func_convert_core_msys_to_w32_result"
1755e9fcaa8aSmrg    func_to_host_file_result="$func_cygpath_result"
1756e9fcaa8aSmrg  fi
1757e9fcaa8aSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1758e9fcaa8aSmrg}
1759e9fcaa8aSmrg# end func_convert_file_msys_to_cygwin
1760e9fcaa8aSmrg
1761e9fcaa8aSmrg
1762e9fcaa8aSmrg# func_convert_file_nix_to_cygwin ARG
1763e9fcaa8aSmrg# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
1764e9fcaa8aSmrg# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
1765e9fcaa8aSmrg# in func_to_host_file_result.
1766e9fcaa8aSmrgfunc_convert_file_nix_to_cygwin ()
1767e9fcaa8aSmrg{
1768e9fcaa8aSmrg  $opt_debug
1769e9fcaa8aSmrg  func_to_host_file_result="$1"
1770e9fcaa8aSmrg  if test -n "$1"; then
1771e9fcaa8aSmrg    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
1772e9fcaa8aSmrg    func_convert_core_file_wine_to_w32 "$1"
1773e9fcaa8aSmrg    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
1774e9fcaa8aSmrg    func_to_host_file_result="$func_cygpath_result"
1775e9fcaa8aSmrg  fi
1776e9fcaa8aSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1777e9fcaa8aSmrg}
1778e9fcaa8aSmrg# end func_convert_file_nix_to_cygwin
1779e9fcaa8aSmrg
1780e9fcaa8aSmrg
1781e9fcaa8aSmrg#############################################
1782e9fcaa8aSmrg# $build to $host PATH CONVERSION FUNCTIONS #
1783e9fcaa8aSmrg#############################################
1784e9fcaa8aSmrg# invoked via `$to_host_path_cmd ARG'
1785e9fcaa8aSmrg#
1786e9fcaa8aSmrg# In each case, ARG is the path to be converted from $build to $host format.
1787e9fcaa8aSmrg# The result will be available in $func_to_host_path_result.
1788e9fcaa8aSmrg#
1789e9fcaa8aSmrg# Path separators are also converted from $build format to $host format.  If
1790e9fcaa8aSmrg# ARG begins or ends with a path separator character, it is preserved (but
1791e9fcaa8aSmrg# converted to $host format) on output.
1792e9fcaa8aSmrg#
1793e9fcaa8aSmrg# All path conversion functions are named using the following convention:
1794e9fcaa8aSmrg#   file name conversion function    : func_convert_file_X_to_Y ()
1795e9fcaa8aSmrg#   path conversion function         : func_convert_path_X_to_Y ()
1796e9fcaa8aSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the
1797e9fcaa8aSmrg# same.  If conversion functions are added for new $build/$host combinations,
1798e9fcaa8aSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd
1799e9fcaa8aSmrg# will break.
1800e9fcaa8aSmrg
1801e9fcaa8aSmrg
1802e9fcaa8aSmrg# func_init_to_host_path_cmd
1803e9fcaa8aSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the
1804e9fcaa8aSmrg# appropriate value, based on the value of $to_host_file_cmd.
1805e9fcaa8aSmrgto_host_path_cmd=
1806e9fcaa8aSmrgfunc_init_to_host_path_cmd ()
1807e9fcaa8aSmrg{
1808e9fcaa8aSmrg  $opt_debug
1809e9fcaa8aSmrg  if test -z "$to_host_path_cmd"; then
1810e9fcaa8aSmrg    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
1811e9fcaa8aSmrg    to_host_path_cmd="func_convert_path_${func_stripname_result}"
1812e9fcaa8aSmrg  fi
1813e9fcaa8aSmrg}
1814e9fcaa8aSmrg
1815e9fcaa8aSmrg
1816e9fcaa8aSmrg# func_to_host_path ARG
1817e9fcaa8aSmrg# Converts the path ARG from $build format to $host format. Return result
1818e9fcaa8aSmrg# in func_to_host_path_result.
1819e9fcaa8aSmrgfunc_to_host_path ()
1820e9fcaa8aSmrg{
1821e9fcaa8aSmrg  $opt_debug
1822e9fcaa8aSmrg  func_init_to_host_path_cmd
1823e9fcaa8aSmrg  $to_host_path_cmd "$1"
1824e9fcaa8aSmrg}
1825e9fcaa8aSmrg# end func_to_host_path
1826e9fcaa8aSmrg
1827e9fcaa8aSmrg
1828e9fcaa8aSmrg# func_convert_path_noop ARG
1829e9fcaa8aSmrg# Copy ARG to func_to_host_path_result.
1830e9fcaa8aSmrgfunc_convert_path_noop ()
1831e9fcaa8aSmrg{
1832e9fcaa8aSmrg  func_to_host_path_result="$1"
1833e9fcaa8aSmrg}
1834e9fcaa8aSmrg# end func_convert_path_noop
1835e9fcaa8aSmrg
1836e9fcaa8aSmrg
1837e9fcaa8aSmrg# func_convert_path_msys_to_w32 ARG
1838e9fcaa8aSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
1839e9fcaa8aSmrg# conversion to w32 is not available inside the cwrapper.  Returns result in
1840e9fcaa8aSmrg# func_to_host_path_result.
1841e9fcaa8aSmrgfunc_convert_path_msys_to_w32 ()
1842e9fcaa8aSmrg{
1843e9fcaa8aSmrg  $opt_debug
1844e9fcaa8aSmrg  func_to_host_path_result="$1"
1845e9fcaa8aSmrg  if test -n "$1"; then
1846e9fcaa8aSmrg    # Remove leading and trailing path separator characters from ARG.  MSYS
1847e9fcaa8aSmrg    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
1848e9fcaa8aSmrg    # and winepath ignores them completely.
1849e9fcaa8aSmrg    func_stripname : : "$1"
1850e9fcaa8aSmrg    func_to_host_path_tmp1=$func_stripname_result
1851e9fcaa8aSmrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1852e9fcaa8aSmrg    func_to_host_path_result="$func_convert_core_msys_to_w32_result"
1853e9fcaa8aSmrg    func_convert_path_check : ";" \
1854e9fcaa8aSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1855e9fcaa8aSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1856e9fcaa8aSmrg  fi
1857e9fcaa8aSmrg}
1858e9fcaa8aSmrg# end func_convert_path_msys_to_w32
1859e9fcaa8aSmrg
1860e9fcaa8aSmrg
1861e9fcaa8aSmrg# func_convert_path_cygwin_to_w32 ARG
1862e9fcaa8aSmrg# Convert path ARG from Cygwin to w32 format.  Returns result in
1863e9fcaa8aSmrg# func_to_host_file_result.
1864e9fcaa8aSmrgfunc_convert_path_cygwin_to_w32 ()
1865e9fcaa8aSmrg{
1866e9fcaa8aSmrg  $opt_debug
1867e9fcaa8aSmrg  func_to_host_path_result="$1"
1868e9fcaa8aSmrg  if test -n "$1"; then
1869e9fcaa8aSmrg    # See func_convert_path_msys_to_w32:
1870e9fcaa8aSmrg    func_stripname : : "$1"
1871e9fcaa8aSmrg    func_to_host_path_tmp1=$func_stripname_result
1872e9fcaa8aSmrg    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
1873e9fcaa8aSmrg    func_convert_path_check : ";" \
1874e9fcaa8aSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1875e9fcaa8aSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1876e9fcaa8aSmrg  fi
1877e9fcaa8aSmrg}
1878e9fcaa8aSmrg# end func_convert_path_cygwin_to_w32
1879e9fcaa8aSmrg
1880e9fcaa8aSmrg
1881e9fcaa8aSmrg# func_convert_path_nix_to_w32 ARG
1882e9fcaa8aSmrg# Convert path ARG from *nix to w32 format.  Requires a wine environment and
1883e9fcaa8aSmrg# a working winepath.  Returns result in func_to_host_file_result.
1884e9fcaa8aSmrgfunc_convert_path_nix_to_w32 ()
1885e9fcaa8aSmrg{
1886e9fcaa8aSmrg  $opt_debug
1887e9fcaa8aSmrg  func_to_host_path_result="$1"
1888e9fcaa8aSmrg  if test -n "$1"; then
1889e9fcaa8aSmrg    # See func_convert_path_msys_to_w32:
1890e9fcaa8aSmrg    func_stripname : : "$1"
1891e9fcaa8aSmrg    func_to_host_path_tmp1=$func_stripname_result
1892e9fcaa8aSmrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1893e9fcaa8aSmrg    func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
1894e9fcaa8aSmrg    func_convert_path_check : ";" \
1895e9fcaa8aSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1896e9fcaa8aSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1897e9fcaa8aSmrg  fi
1898e9fcaa8aSmrg}
1899e9fcaa8aSmrg# end func_convert_path_nix_to_w32
1900e9fcaa8aSmrg
1901e9fcaa8aSmrg
1902e9fcaa8aSmrg# func_convert_path_msys_to_cygwin ARG
1903e9fcaa8aSmrg# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
1904e9fcaa8aSmrg# Returns result in func_to_host_file_result.
1905e9fcaa8aSmrgfunc_convert_path_msys_to_cygwin ()
1906e9fcaa8aSmrg{
1907e9fcaa8aSmrg  $opt_debug
1908e9fcaa8aSmrg  func_to_host_path_result="$1"
1909e9fcaa8aSmrg  if test -n "$1"; then
1910e9fcaa8aSmrg    # See func_convert_path_msys_to_w32:
1911e9fcaa8aSmrg    func_stripname : : "$1"
1912e9fcaa8aSmrg    func_to_host_path_tmp1=$func_stripname_result
1913e9fcaa8aSmrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1914e9fcaa8aSmrg    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
1915e9fcaa8aSmrg    func_to_host_path_result="$func_cygpath_result"
1916e9fcaa8aSmrg    func_convert_path_check : : \
1917e9fcaa8aSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1918e9fcaa8aSmrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1919e9fcaa8aSmrg  fi
1920e9fcaa8aSmrg}
1921e9fcaa8aSmrg# end func_convert_path_msys_to_cygwin
1922e9fcaa8aSmrg
1923e9fcaa8aSmrg
1924e9fcaa8aSmrg# func_convert_path_nix_to_cygwin ARG
1925e9fcaa8aSmrg# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
1926e9fcaa8aSmrg# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
1927e9fcaa8aSmrg# func_to_host_file_result.
1928e9fcaa8aSmrgfunc_convert_path_nix_to_cygwin ()
1929e9fcaa8aSmrg{
1930e9fcaa8aSmrg  $opt_debug
1931e9fcaa8aSmrg  func_to_host_path_result="$1"
1932e9fcaa8aSmrg  if test -n "$1"; then
1933e9fcaa8aSmrg    # Remove leading and trailing path separator characters from
1934e9fcaa8aSmrg    # ARG. msys behavior is inconsistent here, cygpath turns them
1935e9fcaa8aSmrg    # into '.;' and ';.', and winepath ignores them completely.
1936e9fcaa8aSmrg    func_stripname : : "$1"
1937e9fcaa8aSmrg    func_to_host_path_tmp1=$func_stripname_result
1938e9fcaa8aSmrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1939e9fcaa8aSmrg    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
1940e9fcaa8aSmrg    func_to_host_path_result="$func_cygpath_result"
1941e9fcaa8aSmrg    func_convert_path_check : : \
1942e9fcaa8aSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1943e9fcaa8aSmrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1944e9fcaa8aSmrg  fi
1945e9fcaa8aSmrg}
1946e9fcaa8aSmrg# end func_convert_path_nix_to_cygwin
1947e9fcaa8aSmrg
1948e9fcaa8aSmrg
194988de56ccSmrg# func_mode_compile arg...
195088de56ccSmrgfunc_mode_compile ()
195188de56ccSmrg{
195288de56ccSmrg    $opt_debug
195388de56ccSmrg    # Get the compilation command and the source file.
195488de56ccSmrg    base_compile=
195588de56ccSmrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
195688de56ccSmrg    suppress_opt=yes
195788de56ccSmrg    suppress_output=
195888de56ccSmrg    arg_mode=normal
195988de56ccSmrg    libobj=
196088de56ccSmrg    later=
196188de56ccSmrg    pie_flag=
196288de56ccSmrg
196388de56ccSmrg    for arg
196488de56ccSmrg    do
196588de56ccSmrg      case $arg_mode in
196688de56ccSmrg      arg  )
196788de56ccSmrg	# do not "continue".  Instead, add this to base_compile
196888de56ccSmrg	lastarg="$arg"
196988de56ccSmrg	arg_mode=normal
197088de56ccSmrg	;;
197188de56ccSmrg
197288de56ccSmrg      target )
197388de56ccSmrg	libobj="$arg"
197488de56ccSmrg	arg_mode=normal
197588de56ccSmrg	continue
197688de56ccSmrg	;;
197788de56ccSmrg
197888de56ccSmrg      normal )
197988de56ccSmrg	# Accept any command-line options.
198088de56ccSmrg	case $arg in
198188de56ccSmrg	-o)
198288de56ccSmrg	  test -n "$libobj" && \
198388de56ccSmrg	    func_fatal_error "you cannot specify \`-o' more than once"
198488de56ccSmrg	  arg_mode=target
198588de56ccSmrg	  continue
198688de56ccSmrg	  ;;
198788de56ccSmrg
198888de56ccSmrg	-pie | -fpie | -fPIE)
1989e9fcaa8aSmrg          func_append pie_flag " $arg"
199088de56ccSmrg	  continue
199188de56ccSmrg	  ;;
199288de56ccSmrg
199388de56ccSmrg	-shared | -static | -prefer-pic | -prefer-non-pic)
1994e9fcaa8aSmrg	  func_append later " $arg"
199588de56ccSmrg	  continue
199688de56ccSmrg	  ;;
199788de56ccSmrg
199888de56ccSmrg	-no-suppress)
19991ab64890Smrg	  suppress_opt=no
20001ab64890Smrg	  continue
20011ab64890Smrg	  ;;
20021ab64890Smrg
20031ab64890Smrg	-Xcompiler)
20041ab64890Smrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
20051ab64890Smrg	  continue      #  The current "srcfile" will either be retained or
20061ab64890Smrg	  ;;            #  replaced later.  I would guess that would be a bug.
20071ab64890Smrg
20081ab64890Smrg	-Wc,*)
200988de56ccSmrg	  func_stripname '-Wc,' '' "$arg"
201088de56ccSmrg	  args=$func_stripname_result
20111ab64890Smrg	  lastarg=
20121ab64890Smrg	  save_ifs="$IFS"; IFS=','
201388de56ccSmrg	  for arg in $args; do
20141ab64890Smrg	    IFS="$save_ifs"
2015e9fcaa8aSmrg	    func_append_quoted lastarg "$arg"
20161ab64890Smrg	  done
20171ab64890Smrg	  IFS="$save_ifs"
201888de56ccSmrg	  func_stripname ' ' '' "$lastarg"
201988de56ccSmrg	  lastarg=$func_stripname_result
20201ab64890Smrg
20211ab64890Smrg	  # Add the arguments to base_compile.
2022e9fcaa8aSmrg	  func_append base_compile " $lastarg"
20231ab64890Smrg	  continue
20241ab64890Smrg	  ;;
20251ab64890Smrg
202688de56ccSmrg	*)
20271ab64890Smrg	  # Accept the current argument as the source file.
20281ab64890Smrg	  # The previous "srcfile" becomes the current argument.
20291ab64890Smrg	  #
20301ab64890Smrg	  lastarg="$srcfile"
20311ab64890Smrg	  srcfile="$arg"
20321ab64890Smrg	  ;;
20331ab64890Smrg	esac  #  case $arg
20341ab64890Smrg	;;
20351ab64890Smrg      esac    #  case $arg_mode
20361ab64890Smrg
20371ab64890Smrg      # Aesthetically quote the previous argument.
2038e9fcaa8aSmrg      func_append_quoted base_compile "$lastarg"
20391ab64890Smrg    done # for arg
20401ab64890Smrg
20411ab64890Smrg    case $arg_mode in
20421ab64890Smrg    arg)
204388de56ccSmrg      func_fatal_error "you must specify an argument for -Xcompile"
20441ab64890Smrg      ;;
20451ab64890Smrg    target)
204688de56ccSmrg      func_fatal_error "you must specify a target with \`-o'"
20471ab64890Smrg      ;;
20481ab64890Smrg    *)
20491ab64890Smrg      # Get the name of the library object.
205088de56ccSmrg      test -z "$libobj" && {
205188de56ccSmrg	func_basename "$srcfile"
205288de56ccSmrg	libobj="$func_basename_result"
205388de56ccSmrg      }
20541ab64890Smrg      ;;
20551ab64890Smrg    esac
20561ab64890Smrg
20571ab64890Smrg    # Recognize several different file suffixes.
20581ab64890Smrg    # If the user specifies -o file.o, it is replaced with file.lo
20591ab64890Smrg    case $libobj in
206088de56ccSmrg    *.[cCFSifmso] | \
206188de56ccSmrg    *.ada | *.adb | *.ads | *.asm | \
206288de56ccSmrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
2063eb411b4bSmrg    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
206488de56ccSmrg      func_xform "$libobj"
206588de56ccSmrg      libobj=$func_xform_result
206688de56ccSmrg      ;;
20671ab64890Smrg    esac
20681ab64890Smrg
20691ab64890Smrg    case $libobj in
207088de56ccSmrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
20711ab64890Smrg    *)
207288de56ccSmrg      func_fatal_error "cannot determine name of library object from \`$libobj'"
20731ab64890Smrg      ;;
20741ab64890Smrg    esac
20751ab64890Smrg
20761ab64890Smrg    func_infer_tag $base_compile
20771ab64890Smrg
20781ab64890Smrg    for arg in $later; do
20791ab64890Smrg      case $arg in
208088de56ccSmrg      -shared)
208188de56ccSmrg	test "$build_libtool_libs" != yes && \
208288de56ccSmrg	  func_fatal_configuration "can not build a shared library"
208388de56ccSmrg	build_old_libs=no
208488de56ccSmrg	continue
208588de56ccSmrg	;;
208688de56ccSmrg
20871ab64890Smrg      -static)
208888de56ccSmrg	build_libtool_libs=no
20891ab64890Smrg	build_old_libs=yes
20901ab64890Smrg	continue
20911ab64890Smrg	;;
20921ab64890Smrg
20931ab64890Smrg      -prefer-pic)
20941ab64890Smrg	pic_mode=yes
20951ab64890Smrg	continue
20961ab64890Smrg	;;
20971ab64890Smrg
20981ab64890Smrg      -prefer-non-pic)
20991ab64890Smrg	pic_mode=no
21001ab64890Smrg	continue
21011ab64890Smrg	;;
21021ab64890Smrg      esac
21031ab64890Smrg    done
21041ab64890Smrg
210588de56ccSmrg    func_quote_for_eval "$libobj"
210688de56ccSmrg    test "X$libobj" != "X$func_quote_for_eval_result" \
210788de56ccSmrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
210888de56ccSmrg      && func_warning "libobj name \`$libobj' may not contain shell special characters."
210988de56ccSmrg    func_dirname_and_basename "$obj" "/" ""
211088de56ccSmrg    objname="$func_basename_result"
211188de56ccSmrg    xdir="$func_dirname_result"
21121ab64890Smrg    lobj=${xdir}$objdir/$objname
21131ab64890Smrg
211488de56ccSmrg    test -z "$base_compile" && \
211588de56ccSmrg      func_fatal_help "you must specify a compilation command"
21161ab64890Smrg
21171ab64890Smrg    # Delete any leftover library objects.
21181ab64890Smrg    if test "$build_old_libs" = yes; then
21191ab64890Smrg      removelist="$obj $lobj $libobj ${libobj}T"
21201ab64890Smrg    else
21211ab64890Smrg      removelist="$lobj $libobj ${libobj}T"
21221ab64890Smrg    fi
21231ab64890Smrg
21241ab64890Smrg    # On Cygwin there's no "real" PIC flag so we must build both object types
21251ab64890Smrg    case $host_os in
212688de56ccSmrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
21271ab64890Smrg      pic_mode=default
21281ab64890Smrg      ;;
21291ab64890Smrg    esac
21301ab64890Smrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
21311ab64890Smrg      # non-PIC code in shared libraries is not supported
21321ab64890Smrg      pic_mode=default
21331ab64890Smrg    fi
21341ab64890Smrg
21351ab64890Smrg    # Calculate the filename of the output object if compiler does
21361ab64890Smrg    # not support -o with -c
21371ab64890Smrg    if test "$compiler_c_o" = no; then
2138e9fcaa8aSmrg      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
21391ab64890Smrg      lockfile="$output_obj.lock"
21401ab64890Smrg    else
21411ab64890Smrg      output_obj=
21421ab64890Smrg      need_locks=no
21431ab64890Smrg      lockfile=
21441ab64890Smrg    fi
21451ab64890Smrg
21461ab64890Smrg    # Lock this critical section if it is needed
21471ab64890Smrg    # We use this script file to make the link, it avoids creating a new file
21481ab64890Smrg    if test "$need_locks" = yes; then
214988de56ccSmrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
215088de56ccSmrg	func_echo "Waiting for $lockfile to be removed"
21511ab64890Smrg	sleep 2
21521ab64890Smrg      done
21531ab64890Smrg    elif test "$need_locks" = warn; then
21541ab64890Smrg      if test -f "$lockfile"; then
215588de56ccSmrg	$ECHO "\
21561ab64890Smrg*** ERROR, $lockfile exists and contains:
21571ab64890Smrg`cat $lockfile 2>/dev/null`
21581ab64890Smrg
21591ab64890SmrgThis indicates that another process is trying to use the same
21601ab64890Smrgtemporary object file, and libtool could not work around it because
21611ab64890Smrgyour compiler does not support \`-c' and \`-o' together.  If you
21621ab64890Smrgrepeat this compilation, it may succeed, by chance, but you had better
21631ab64890Smrgavoid parallel builds (make -j) in this platform, or get a better
21641ab64890Smrgcompiler."
21651ab64890Smrg
216688de56ccSmrg	$opt_dry_run || $RM $removelist
21671ab64890Smrg	exit $EXIT_FAILURE
21681ab64890Smrg      fi
2169e9fcaa8aSmrg      func_append removelist " $output_obj"
217088de56ccSmrg      $ECHO "$srcfile" > "$lockfile"
21711ab64890Smrg    fi
21721ab64890Smrg
217388de56ccSmrg    $opt_dry_run || $RM $removelist
2174e9fcaa8aSmrg    func_append removelist " $lockfile"
217588de56ccSmrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
217688de56ccSmrg
2177e9fcaa8aSmrg    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
2178e9fcaa8aSmrg    srcfile=$func_to_tool_file_result
217988de56ccSmrg    func_quote_for_eval "$srcfile"
218088de56ccSmrg    qsrcfile=$func_quote_for_eval_result
21811ab64890Smrg
21821ab64890Smrg    # Only build a PIC object if we are building libtool libraries.
21831ab64890Smrg    if test "$build_libtool_libs" = yes; then
21841ab64890Smrg      # Without this assignment, base_compile gets emptied.
21851ab64890Smrg      fbsd_hideous_sh_bug=$base_compile
21861ab64890Smrg
21871ab64890Smrg      if test "$pic_mode" != no; then
21881ab64890Smrg	command="$base_compile $qsrcfile $pic_flag"
21891ab64890Smrg      else
21901ab64890Smrg	# Don't build PIC code
21911ab64890Smrg	command="$base_compile $qsrcfile"
21921ab64890Smrg      fi
21931ab64890Smrg
219488de56ccSmrg      func_mkdir_p "$xdir$objdir"
21951ab64890Smrg
21961ab64890Smrg      if test -z "$output_obj"; then
21971ab64890Smrg	# Place PIC objects in $objdir
2198e9fcaa8aSmrg	func_append command " -o $lobj"
21991ab64890Smrg      fi
22001ab64890Smrg
220188de56ccSmrg      func_show_eval_locale "$command"	\
220288de56ccSmrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
22031ab64890Smrg
22041ab64890Smrg      if test "$need_locks" = warn &&
22051ab64890Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
220688de56ccSmrg	$ECHO "\
22071ab64890Smrg*** ERROR, $lockfile contains:
22081ab64890Smrg`cat $lockfile 2>/dev/null`
22091ab64890Smrg
22101ab64890Smrgbut it should contain:
22111ab64890Smrg$srcfile
22121ab64890Smrg
22131ab64890SmrgThis indicates that another process is trying to use the same
22141ab64890Smrgtemporary object file, and libtool could not work around it because
22151ab64890Smrgyour compiler does not support \`-c' and \`-o' together.  If you
22161ab64890Smrgrepeat this compilation, it may succeed, by chance, but you had better
22171ab64890Smrgavoid parallel builds (make -j) in this platform, or get a better
22181ab64890Smrgcompiler."
22191ab64890Smrg
222088de56ccSmrg	$opt_dry_run || $RM $removelist
22211ab64890Smrg	exit $EXIT_FAILURE
22221ab64890Smrg      fi
22231ab64890Smrg
22241ab64890Smrg      # Just move the object if needed, then go on to compile the next one
22251ab64890Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
222688de56ccSmrg	func_show_eval '$MV "$output_obj" "$lobj"' \
222788de56ccSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
22281ab64890Smrg      fi
22291ab64890Smrg
22301ab64890Smrg      # Allow error messages only from the first compilation.
22311ab64890Smrg      if test "$suppress_opt" = yes; then
223288de56ccSmrg	suppress_output=' >/dev/null 2>&1'
22331ab64890Smrg      fi
22341ab64890Smrg    fi
22351ab64890Smrg
22361ab64890Smrg    # Only build a position-dependent object if we build old libraries.
22371ab64890Smrg    if test "$build_old_libs" = yes; then
22381ab64890Smrg      if test "$pic_mode" != yes; then
22391ab64890Smrg	# Don't build PIC code
224088de56ccSmrg	command="$base_compile $qsrcfile$pie_flag"
22411ab64890Smrg      else
22421ab64890Smrg	command="$base_compile $qsrcfile $pic_flag"
22431ab64890Smrg      fi
22441ab64890Smrg      if test "$compiler_c_o" = yes; then
2245e9fcaa8aSmrg	func_append command " -o $obj"
22461ab64890Smrg      fi
22471ab64890Smrg
22481ab64890Smrg      # Suppress compiler output if we already did a PIC compilation.
2249e9fcaa8aSmrg      func_append command "$suppress_output"
225088de56ccSmrg      func_show_eval_locale "$command" \
225188de56ccSmrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
22521ab64890Smrg
22531ab64890Smrg      if test "$need_locks" = warn &&
22541ab64890Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
225588de56ccSmrg	$ECHO "\
22561ab64890Smrg*** ERROR, $lockfile contains:
22571ab64890Smrg`cat $lockfile 2>/dev/null`
22581ab64890Smrg
22591ab64890Smrgbut it should contain:
22601ab64890Smrg$srcfile
22611ab64890Smrg
22621ab64890SmrgThis indicates that another process is trying to use the same
22631ab64890Smrgtemporary object file, and libtool could not work around it because
22641ab64890Smrgyour compiler does not support \`-c' and \`-o' together.  If you
22651ab64890Smrgrepeat this compilation, it may succeed, by chance, but you had better
22661ab64890Smrgavoid parallel builds (make -j) in this platform, or get a better
22671ab64890Smrgcompiler."
22681ab64890Smrg
226988de56ccSmrg	$opt_dry_run || $RM $removelist
22701ab64890Smrg	exit $EXIT_FAILURE
22711ab64890Smrg      fi
22721ab64890Smrg
22731ab64890Smrg      # Just move the object if needed
22741ab64890Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
227588de56ccSmrg	func_show_eval '$MV "$output_obj" "$obj"' \
227688de56ccSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
22771ab64890Smrg      fi
22781ab64890Smrg    fi
22791ab64890Smrg
228088de56ccSmrg    $opt_dry_run || {
228188de56ccSmrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
22821ab64890Smrg
228388de56ccSmrg      # Unlock the critical section if it was locked
228488de56ccSmrg      if test "$need_locks" != no; then
228588de56ccSmrg	removelist=$lockfile
228688de56ccSmrg        $RM "$lockfile"
228788de56ccSmrg      fi
228888de56ccSmrg    }
22891ab64890Smrg
22901ab64890Smrg    exit $EXIT_SUCCESS
229188de56ccSmrg}
22921ab64890Smrg
229388de56ccSmrg$opt_help || {
2294e9fcaa8aSmrg  test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
229588de56ccSmrg}
22961ab64890Smrg
229788de56ccSmrgfunc_mode_help ()
229888de56ccSmrg{
229988de56ccSmrg    # We need to display help for each of the modes.
2300e9fcaa8aSmrg    case $opt_mode in
230188de56ccSmrg      "")
230288de56ccSmrg        # Generic help is extracted from the usage comments
230388de56ccSmrg        # at the start of this file.
230488de56ccSmrg        func_help
230588de56ccSmrg        ;;
23061ab64890Smrg
230788de56ccSmrg      clean)
230888de56ccSmrg        $ECHO \
230988de56ccSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
23101ab64890Smrg
231188de56ccSmrgRemove files from the build directory.
23121ab64890Smrg
231388de56ccSmrgRM is the name of the program to use to delete files associated with each FILE
231488de56ccSmrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
231588de56ccSmrgto RM.
23161ab64890Smrg
231788de56ccSmrgIf FILE is a libtool library, object or program, all the files associated
231888de56ccSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
231988de56ccSmrg        ;;
23201ab64890Smrg
232188de56ccSmrg      compile)
232288de56ccSmrg      $ECHO \
232388de56ccSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
23241ab64890Smrg
232588de56ccSmrgCompile a source file into a libtool library object.
23261ab64890Smrg
232788de56ccSmrgThis mode accepts the following additional options:
23281ab64890Smrg
232988de56ccSmrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
233088de56ccSmrg  -no-suppress      do not suppress compiler output for multiple passes
2331e9fcaa8aSmrg  -prefer-pic       try to build PIC objects only
2332e9fcaa8aSmrg  -prefer-non-pic   try to build non-PIC objects only
233388de56ccSmrg  -shared           do not build a \`.o' file suitable for static linking
233488de56ccSmrg  -static           only build a \`.o' file suitable for static linking
2335e9fcaa8aSmrg  -Wc,FLAG          pass FLAG directly to the compiler
23361ab64890Smrg
233788de56ccSmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
233888de56ccSmrgfrom the given SOURCEFILE.
23391ab64890Smrg
234088de56ccSmrgThe output file name is determined by removing the directory component from
234188de56ccSmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
234288de56ccSmrglibrary object suffix, \`.lo'."
234388de56ccSmrg        ;;
23441ab64890Smrg
234588de56ccSmrg      execute)
234688de56ccSmrg        $ECHO \
234788de56ccSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
23481ab64890Smrg
234988de56ccSmrgAutomatically set library path, then run a program.
23501ab64890Smrg
235188de56ccSmrgThis mode accepts the following additional options:
23521ab64890Smrg
235388de56ccSmrg  -dlopen FILE      add the directory containing FILE to the library path
23541ab64890Smrg
235588de56ccSmrgThis mode sets the library path environment variable according to \`-dlopen'
235688de56ccSmrgflags.
23571ab64890Smrg
235888de56ccSmrgIf any of the ARGS are libtool executable wrappers, then they are translated
235988de56ccSmrginto their corresponding uninstalled binary, and any of their required library
236088de56ccSmrgdirectories are added to the library path.
23611ab64890Smrg
236288de56ccSmrgThen, COMMAND is executed, with ARGS as arguments."
236388de56ccSmrg        ;;
23641ab64890Smrg
236588de56ccSmrg      finish)
236688de56ccSmrg        $ECHO \
236788de56ccSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
23681ab64890Smrg
236988de56ccSmrgComplete the installation of libtool libraries.
23701ab64890Smrg
237188de56ccSmrgEach LIBDIR is a directory that contains libtool libraries.
23721ab64890Smrg
237388de56ccSmrgThe commands that this mode executes may require superuser privileges.  Use
237488de56ccSmrgthe \`--dry-run' option if you just want to see what would be executed."
237588de56ccSmrg        ;;
23761ab64890Smrg
237788de56ccSmrg      install)
237888de56ccSmrg        $ECHO \
237988de56ccSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
23801ab64890Smrg
238188de56ccSmrgInstall executables or libraries.
23821ab64890Smrg
238388de56ccSmrgINSTALL-COMMAND is the installation command.  The first component should be
238488de56ccSmrgeither the \`install' or \`cp' program.
23851ab64890Smrg
238688de56ccSmrgThe following components of INSTALL-COMMAND are treated specially:
23871ab64890Smrg
2388e9fcaa8aSmrg  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
23891ab64890Smrg
239088de56ccSmrgThe rest of the components are interpreted as arguments to that command (only
239188de56ccSmrgBSD-compatible install options are recognized)."
239288de56ccSmrg        ;;
23931ab64890Smrg
239488de56ccSmrg      link)
239588de56ccSmrg        $ECHO \
239688de56ccSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
23971ab64890Smrg
239888de56ccSmrgLink object files or libraries together to form another library, or to
239988de56ccSmrgcreate an executable program.
24001ab64890Smrg
240188de56ccSmrgLINK-COMMAND is a command using the C compiler that you would use to create
240288de56ccSmrga program from several object files.
24031ab64890Smrg
240488de56ccSmrgThe following components of LINK-COMMAND are treated specially:
24051ab64890Smrg
240688de56ccSmrg  -all-static       do not do any dynamic linking at all
240788de56ccSmrg  -avoid-version    do not add a version suffix if possible
2408e9fcaa8aSmrg  -bindir BINDIR    specify path to binaries directory (for systems where
2409e9fcaa8aSmrg                    libraries must be found in the PATH setting at runtime)
241088de56ccSmrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
241188de56ccSmrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
241288de56ccSmrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
241388de56ccSmrg  -export-symbols SYMFILE
241488de56ccSmrg                    try to export only the symbols listed in SYMFILE
241588de56ccSmrg  -export-symbols-regex REGEX
241688de56ccSmrg                    try to export only the symbols matching REGEX
241788de56ccSmrg  -LLIBDIR          search LIBDIR for required installed libraries
241888de56ccSmrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
241988de56ccSmrg  -module           build a library that can dlopened
242088de56ccSmrg  -no-fast-install  disable the fast-install mode
242188de56ccSmrg  -no-install       link a not-installable executable
242288de56ccSmrg  -no-undefined     declare that a library does not refer to external symbols
242388de56ccSmrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
242488de56ccSmrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
242588de56ccSmrg  -precious-files-regex REGEX
242688de56ccSmrg                    don't remove output files matching REGEX
242788de56ccSmrg  -release RELEASE  specify package release information
242888de56ccSmrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
242988de56ccSmrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
243088de56ccSmrg  -shared           only do dynamic linking of libtool libraries
243188de56ccSmrg  -shrext SUFFIX    override the standard shared library file extension
243288de56ccSmrg  -static           do not do any dynamic linking of uninstalled libtool libraries
243388de56ccSmrg  -static-libtool-libs
243488de56ccSmrg                    do not do any dynamic linking of libtool libraries
243588de56ccSmrg  -version-info CURRENT[:REVISION[:AGE]]
243688de56ccSmrg                    specify library version info [each variable defaults to 0]
243788de56ccSmrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
2438e9fcaa8aSmrg  -Wc,FLAG
2439e9fcaa8aSmrg  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
2440e9fcaa8aSmrg  -Wl,FLAG
2441e9fcaa8aSmrg  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
2442e9fcaa8aSmrg  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
24431ab64890Smrg
244488de56ccSmrgAll other options (arguments beginning with \`-') are ignored.
24451ab64890Smrg
244688de56ccSmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
244788de56ccSmrgtreated as uninstalled libtool libraries, other files are standard or library
244888de56ccSmrgobject files.
24491ab64890Smrg
245088de56ccSmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
245188de56ccSmrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
245288de56ccSmrgrequired, except when creating a convenience library.
24531ab64890Smrg
245488de56ccSmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
245588de56ccSmrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
24561ab64890Smrg
245788de56ccSmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
245888de56ccSmrgis created, otherwise an executable program is created."
2459b4ee4795Smrg        ;;
24601ab64890Smrg
246188de56ccSmrg      uninstall)
246288de56ccSmrg        $ECHO \
246388de56ccSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
24641ab64890Smrg
246588de56ccSmrgRemove libraries from an installation directory.
24661ab64890Smrg
246788de56ccSmrgRM is the name of the program to use to delete files associated with each FILE
246888de56ccSmrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
246988de56ccSmrgto RM.
24702e9c7c8cSmrg
247188de56ccSmrgIf FILE is a libtool library, all the files associated with it are deleted.
247288de56ccSmrgOtherwise, only FILE itself is deleted using RM."
247388de56ccSmrg        ;;
24742e9c7c8cSmrg
247588de56ccSmrg      *)
2476e9fcaa8aSmrg        func_fatal_help "invalid operation mode \`$opt_mode'"
247788de56ccSmrg        ;;
247888de56ccSmrg    esac
24792e9c7c8cSmrg
2480e9fcaa8aSmrg    echo
248188de56ccSmrg    $ECHO "Try \`$progname --help' for more information about other modes."
248288de56ccSmrg}
24832e9c7c8cSmrg
2484e9fcaa8aSmrg# Now that we've collected a possible --mode arg, show help if necessary
2485e9fcaa8aSmrgif $opt_help; then
2486e9fcaa8aSmrg  if test "$opt_help" = :; then
2487e9fcaa8aSmrg    func_mode_help
2488e9fcaa8aSmrg  else
2489e9fcaa8aSmrg    {
2490e9fcaa8aSmrg      func_help noexit
2491e9fcaa8aSmrg      for opt_mode in compile link execute install finish uninstall clean; do
2492e9fcaa8aSmrg	func_mode_help
2493e9fcaa8aSmrg      done
2494e9fcaa8aSmrg    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
2495e9fcaa8aSmrg    {
2496e9fcaa8aSmrg      func_help noexit
2497e9fcaa8aSmrg      for opt_mode in compile link execute install finish uninstall clean; do
2498e9fcaa8aSmrg	echo
2499e9fcaa8aSmrg	func_mode_help
2500e9fcaa8aSmrg      done
2501e9fcaa8aSmrg    } |
2502e9fcaa8aSmrg    sed '1d
2503e9fcaa8aSmrg      /^When reporting/,/^Report/{
2504e9fcaa8aSmrg	H
2505e9fcaa8aSmrg	d
2506e9fcaa8aSmrg      }
2507e9fcaa8aSmrg      $x
2508e9fcaa8aSmrg      /information about other modes/d
2509e9fcaa8aSmrg      /more detailed .*MODE/d
2510e9fcaa8aSmrg      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
2511e9fcaa8aSmrg  fi
2512e9fcaa8aSmrg  exit $?
2513e9fcaa8aSmrgfi
25142e9c7c8cSmrg
25152e9c7c8cSmrg
251688de56ccSmrg# func_mode_execute arg...
251788de56ccSmrgfunc_mode_execute ()
251888de56ccSmrg{
251988de56ccSmrg    $opt_debug
252088de56ccSmrg    # The first argument is the command name.
252188de56ccSmrg    cmd="$nonopt"
252288de56ccSmrg    test -z "$cmd" && \
252388de56ccSmrg      func_fatal_help "you must specify a COMMAND"
2524b4ee4795Smrg
252588de56ccSmrg    # Handle -dlopen flags immediately.
2526e9fcaa8aSmrg    for file in $opt_dlopen; do
252788de56ccSmrg      test -f "$file" \
252888de56ccSmrg	|| func_fatal_help "\`$file' is not a file"
2529b4ee4795Smrg
253088de56ccSmrg      dir=
253188de56ccSmrg      case $file in
253288de56ccSmrg      *.la)
2533e9fcaa8aSmrg	func_resolve_sysroot "$file"
2534e9fcaa8aSmrg	file=$func_resolve_sysroot_result
2535e9fcaa8aSmrg
253688de56ccSmrg	# Check to see that this really is a libtool archive.
253788de56ccSmrg	func_lalib_unsafe_p "$file" \
253888de56ccSmrg	  || func_fatal_help "\`$lib' is not a valid libtool archive"
2539b4ee4795Smrg
254088de56ccSmrg	# Read the libtool library.
254188de56ccSmrg	dlname=
254288de56ccSmrg	library_names=
254388de56ccSmrg	func_source "$file"
25441ab64890Smrg
254588de56ccSmrg	# Skip this library if it cannot be dlopened.
254688de56ccSmrg	if test -z "$dlname"; then
254788de56ccSmrg	  # Warn if it was a shared library.
254888de56ccSmrg	  test -n "$library_names" && \
254988de56ccSmrg	    func_warning "\`$file' was not linked with \`-export-dynamic'"
255088de56ccSmrg	  continue
255188de56ccSmrg	fi
25521ab64890Smrg
255388de56ccSmrg	func_dirname "$file" "" "."
255488de56ccSmrg	dir="$func_dirname_result"
25551ab64890Smrg
255688de56ccSmrg	if test -f "$dir/$objdir/$dlname"; then
2557e9fcaa8aSmrg	  func_append dir "/$objdir"
255888de56ccSmrg	else
255988de56ccSmrg	  if test ! -f "$dir/$dlname"; then
256088de56ccSmrg	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
256188de56ccSmrg	  fi
256288de56ccSmrg	fi
2563b4ee4795Smrg	;;
25641ab64890Smrg
256588de56ccSmrg      *.lo)
256688de56ccSmrg	# Just add the directory containing the .lo file.
256788de56ccSmrg	func_dirname "$file" "" "."
256888de56ccSmrg	dir="$func_dirname_result"
2569b4ee4795Smrg	;;
25701ab64890Smrg
257188de56ccSmrg      *)
257288de56ccSmrg	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
2573b4ee4795Smrg	continue
2574b4ee4795Smrg	;;
257588de56ccSmrg      esac
25761ab64890Smrg
257788de56ccSmrg      # Get the absolute pathname.
257888de56ccSmrg      absdir=`cd "$dir" && pwd`
257988de56ccSmrg      test -n "$absdir" && dir="$absdir"
25802e9c7c8cSmrg
258188de56ccSmrg      # Now add the directory to shlibpath_var.
258288de56ccSmrg      if eval "test -z \"\$$shlibpath_var\""; then
258388de56ccSmrg	eval "$shlibpath_var=\"\$dir\""
258488de56ccSmrg      else
258588de56ccSmrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
258688de56ccSmrg      fi
258788de56ccSmrg    done
25882e9c7c8cSmrg
258988de56ccSmrg    # This variable tells wrapper scripts just to set shlibpath_var
259088de56ccSmrg    # rather than running their programs.
259188de56ccSmrg    libtool_execute_magic="$magic"
25922e9c7c8cSmrg
259388de56ccSmrg    # Check if any of the arguments is a wrapper script.
259488de56ccSmrg    args=
259588de56ccSmrg    for file
259688de56ccSmrg    do
259788de56ccSmrg      case $file in
2598e9fcaa8aSmrg      -* | *.la | *.lo ) ;;
259988de56ccSmrg      *)
260088de56ccSmrg	# Do a test to see if this is really a libtool program.
260188de56ccSmrg	if func_ltwrapper_script_p "$file"; then
260288de56ccSmrg	  func_source "$file"
260388de56ccSmrg	  # Transform arg to wrapped name.
260488de56ccSmrg	  file="$progdir/$program"
260588de56ccSmrg	elif func_ltwrapper_executable_p "$file"; then
260688de56ccSmrg	  func_ltwrapper_scriptname "$file"
260788de56ccSmrg	  func_source "$func_ltwrapper_scriptname_result"
260888de56ccSmrg	  # Transform arg to wrapped name.
260988de56ccSmrg	  file="$progdir/$program"
261088de56ccSmrg	fi
261188de56ccSmrg	;;
261288de56ccSmrg      esac
261388de56ccSmrg      # Quote arguments (to preserve shell metacharacters).
2614e9fcaa8aSmrg      func_append_quoted args "$file"
261588de56ccSmrg    done
26162e9c7c8cSmrg
261788de56ccSmrg    if test "X$opt_dry_run" = Xfalse; then
261888de56ccSmrg      if test -n "$shlibpath_var"; then
261988de56ccSmrg	# Export the shlibpath_var.
262088de56ccSmrg	eval "export $shlibpath_var"
262188de56ccSmrg      fi
26222e9c7c8cSmrg
262388de56ccSmrg      # Restore saved environment variables
262488de56ccSmrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
262588de56ccSmrg      do
262688de56ccSmrg	eval "if test \"\${save_$lt_var+set}\" = set; then
262788de56ccSmrg                $lt_var=\$save_$lt_var; export $lt_var
2628b4ee4795Smrg	      else
262988de56ccSmrg		$lt_unset $lt_var
263088de56ccSmrg	      fi"
263188de56ccSmrg      done
26322e9c7c8cSmrg
263388de56ccSmrg      # Now prepare to actually exec the command.
263488de56ccSmrg      exec_cmd="\$cmd$args"
263588de56ccSmrg    else
263688de56ccSmrg      # Display what would be done.
263788de56ccSmrg      if test -n "$shlibpath_var"; then
263888de56ccSmrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
2639e9fcaa8aSmrg	echo "export $shlibpath_var"
264088de56ccSmrg      fi
264188de56ccSmrg      $ECHO "$cmd$args"
264288de56ccSmrg      exit $EXIT_SUCCESS
264388de56ccSmrg    fi
264488de56ccSmrg}
26452e9c7c8cSmrg
2646e9fcaa8aSmrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"}
26472e9c7c8cSmrg
2648b4ee4795Smrg
264988de56ccSmrg# func_mode_finish arg...
265088de56ccSmrgfunc_mode_finish ()
265188de56ccSmrg{
265288de56ccSmrg    $opt_debug
2653e9fcaa8aSmrg    libs=
2654e9fcaa8aSmrg    libdirs=
265588de56ccSmrg    admincmds=
26561ab64890Smrg
2657e9fcaa8aSmrg    for opt in "$nonopt" ${1+"$@"}
2658e9fcaa8aSmrg    do
2659e9fcaa8aSmrg      if test -d "$opt"; then
2660e9fcaa8aSmrg	func_append libdirs " $opt"
2661e9fcaa8aSmrg
2662e9fcaa8aSmrg      elif test -f "$opt"; then
2663e9fcaa8aSmrg	if func_lalib_unsafe_p "$opt"; then
2664e9fcaa8aSmrg	  func_append libs " $opt"
2665e9fcaa8aSmrg	else
2666e9fcaa8aSmrg	  func_warning "\`$opt' is not a valid libtool archive"
2667e9fcaa8aSmrg	fi
2668e9fcaa8aSmrg
2669e9fcaa8aSmrg      else
2670e9fcaa8aSmrg	func_fatal_error "invalid argument \`$opt'"
2671e9fcaa8aSmrg      fi
2672e9fcaa8aSmrg    done
2673e9fcaa8aSmrg
2674e9fcaa8aSmrg    if test -n "$libs"; then
2675e9fcaa8aSmrg      if test -n "$lt_sysroot"; then
2676e9fcaa8aSmrg        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
2677e9fcaa8aSmrg        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
2678e9fcaa8aSmrg      else
2679e9fcaa8aSmrg        sysroot_cmd=
2680e9fcaa8aSmrg      fi
26811ab64890Smrg
2682e9fcaa8aSmrg      # Remove sysroot references
2683e9fcaa8aSmrg      if $opt_dry_run; then
2684e9fcaa8aSmrg        for lib in $libs; do
2685e9fcaa8aSmrg          echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
2686e9fcaa8aSmrg        done
2687e9fcaa8aSmrg      else
2688e9fcaa8aSmrg        tmpdir=`func_mktempdir`
2689e9fcaa8aSmrg        for lib in $libs; do
2690e9fcaa8aSmrg	  sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
2691e9fcaa8aSmrg	    > $tmpdir/tmp-la
2692e9fcaa8aSmrg	  mv -f $tmpdir/tmp-la $lib
2693e9fcaa8aSmrg	done
2694e9fcaa8aSmrg        ${RM}r "$tmpdir"
2695e9fcaa8aSmrg      fi
2696e9fcaa8aSmrg    fi
2697e9fcaa8aSmrg
2698e9fcaa8aSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
269988de56ccSmrg      for libdir in $libdirs; do
270088de56ccSmrg	if test -n "$finish_cmds"; then
270188de56ccSmrg	  # Do each command in the finish commands.
270288de56ccSmrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
270388de56ccSmrg'"$cmd"'"'
2704b4ee4795Smrg	fi
270588de56ccSmrg	if test -n "$finish_eval"; then
270688de56ccSmrg	  # Do the single finish_eval.
270788de56ccSmrg	  eval cmds=\"$finish_eval\"
2708e9fcaa8aSmrg	  $opt_dry_run || eval "$cmds" || func_append admincmds "
270988de56ccSmrg       $cmds"
271088de56ccSmrg	fi
271188de56ccSmrg      done
271288de56ccSmrg    fi
27131ab64890Smrg
271488de56ccSmrg    # Exit here if they wanted silent mode.
271588de56ccSmrg    $opt_silent && exit $EXIT_SUCCESS
27161ab64890Smrg
2717e9fcaa8aSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2718e9fcaa8aSmrg      echo "----------------------------------------------------------------------"
2719e9fcaa8aSmrg      echo "Libraries have been installed in:"
2720e9fcaa8aSmrg      for libdir in $libdirs; do
2721e9fcaa8aSmrg	$ECHO "   $libdir"
2722e9fcaa8aSmrg      done
2723e9fcaa8aSmrg      echo
2724e9fcaa8aSmrg      echo "If you ever happen to want to link against installed libraries"
2725e9fcaa8aSmrg      echo "in a given directory, LIBDIR, you must either use libtool, and"
2726e9fcaa8aSmrg      echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
2727e9fcaa8aSmrg      echo "flag during linking and do at least one of the following:"
2728e9fcaa8aSmrg      if test -n "$shlibpath_var"; then
2729e9fcaa8aSmrg	echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
2730e9fcaa8aSmrg	echo "     during execution"
2731e9fcaa8aSmrg      fi
2732e9fcaa8aSmrg      if test -n "$runpath_var"; then
2733e9fcaa8aSmrg	echo "   - add LIBDIR to the \`$runpath_var' environment variable"
2734e9fcaa8aSmrg	echo "     during linking"
2735e9fcaa8aSmrg      fi
2736e9fcaa8aSmrg      if test -n "$hardcode_libdir_flag_spec"; then
2737e9fcaa8aSmrg	libdir=LIBDIR
2738e9fcaa8aSmrg	eval flag=\"$hardcode_libdir_flag_spec\"
273988de56ccSmrg
2740e9fcaa8aSmrg	$ECHO "   - use the \`$flag' linker flag"
2741e9fcaa8aSmrg      fi
2742e9fcaa8aSmrg      if test -n "$admincmds"; then
2743e9fcaa8aSmrg	$ECHO "   - have your system administrator run these commands:$admincmds"
2744e9fcaa8aSmrg      fi
2745e9fcaa8aSmrg      if test -f /etc/ld.so.conf; then
2746e9fcaa8aSmrg	echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
2747e9fcaa8aSmrg      fi
2748e9fcaa8aSmrg      echo
274988de56ccSmrg
2750e9fcaa8aSmrg      echo "See any operating system documentation about shared libraries for"
2751e9fcaa8aSmrg      case $host in
2752e9fcaa8aSmrg	solaris2.[6789]|solaris2.1[0-9])
2753e9fcaa8aSmrg	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
2754e9fcaa8aSmrg	  echo "pages."
2755e9fcaa8aSmrg	  ;;
2756e9fcaa8aSmrg	*)
2757e9fcaa8aSmrg	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
2758e9fcaa8aSmrg	  ;;
2759e9fcaa8aSmrg      esac
2760e9fcaa8aSmrg      echo "----------------------------------------------------------------------"
2761e9fcaa8aSmrg    fi
276288de56ccSmrg    exit $EXIT_SUCCESS
276388de56ccSmrg}
276488de56ccSmrg
2765e9fcaa8aSmrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"}
276688de56ccSmrg
276788de56ccSmrg
276888de56ccSmrg# func_mode_install arg...
276988de56ccSmrgfunc_mode_install ()
277088de56ccSmrg{
277188de56ccSmrg    $opt_debug
277288de56ccSmrg    # There may be an optional sh(1) argument at the beginning of
277388de56ccSmrg    # install_prog (especially on Windows NT).
277488de56ccSmrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
277588de56ccSmrg       # Allow the use of GNU shtool's install command.
2776e9fcaa8aSmrg       case $nonopt in *shtool*) :;; *) false;; esac; then
277788de56ccSmrg      # Aesthetically quote it.
277888de56ccSmrg      func_quote_for_eval "$nonopt"
277988de56ccSmrg      install_prog="$func_quote_for_eval_result "
278088de56ccSmrg      arg=$1
278188de56ccSmrg      shift
278288de56ccSmrg    else
278388de56ccSmrg      install_prog=
278488de56ccSmrg      arg=$nonopt
278588de56ccSmrg    fi
278688de56ccSmrg
278788de56ccSmrg    # The real first argument should be the name of the installation program.
278888de56ccSmrg    # Aesthetically quote it.
278988de56ccSmrg    func_quote_for_eval "$arg"
2790e9fcaa8aSmrg    func_append install_prog "$func_quote_for_eval_result"
2791e9fcaa8aSmrg    install_shared_prog=$install_prog
2792e9fcaa8aSmrg    case " $install_prog " in
2793e9fcaa8aSmrg      *[\\\ /]cp\ *) install_cp=: ;;
2794e9fcaa8aSmrg      *) install_cp=false ;;
2795e9fcaa8aSmrg    esac
279688de56ccSmrg
279788de56ccSmrg    # We need to accept at least all the BSD install flags.
279888de56ccSmrg    dest=
279988de56ccSmrg    files=
280088de56ccSmrg    opts=
280188de56ccSmrg    prev=
280288de56ccSmrg    install_type=
280388de56ccSmrg    isdir=no
280488de56ccSmrg    stripme=
2805e9fcaa8aSmrg    no_mode=:
280688de56ccSmrg    for arg
280788de56ccSmrg    do
2808e9fcaa8aSmrg      arg2=
280988de56ccSmrg      if test -n "$dest"; then
2810e9fcaa8aSmrg	func_append files " $dest"
281188de56ccSmrg	dest=$arg
281288de56ccSmrg	continue
281388de56ccSmrg      fi
281488de56ccSmrg
281588de56ccSmrg      case $arg in
281688de56ccSmrg      -d) isdir=yes ;;
281788de56ccSmrg      -f)
2818e9fcaa8aSmrg	if $install_cp; then :; else
2819e9fcaa8aSmrg	  prev=$arg
2820e9fcaa8aSmrg	fi
282188de56ccSmrg	;;
282288de56ccSmrg      -g | -m | -o)
282388de56ccSmrg	prev=$arg
282488de56ccSmrg	;;
282588de56ccSmrg      -s)
282688de56ccSmrg	stripme=" -s"
282788de56ccSmrg	continue
282888de56ccSmrg	;;
282988de56ccSmrg      -*)
283088de56ccSmrg	;;
283188de56ccSmrg      *)
283288de56ccSmrg	# If the previous option needed an argument, then skip it.
283388de56ccSmrg	if test -n "$prev"; then
2834e9fcaa8aSmrg	  if test "x$prev" = x-m && test -n "$install_override_mode"; then
2835e9fcaa8aSmrg	    arg2=$install_override_mode
2836e9fcaa8aSmrg	    no_mode=false
2837e9fcaa8aSmrg	  fi
2838b4ee4795Smrg	  prev=
28392e9c7c8cSmrg	else
284088de56ccSmrg	  dest=$arg
284188de56ccSmrg	  continue
28421ab64890Smrg	fi
2843b4ee4795Smrg	;;
284488de56ccSmrg      esac
28451ab64890Smrg
284688de56ccSmrg      # Aesthetically quote the argument.
284788de56ccSmrg      func_quote_for_eval "$arg"
2848e9fcaa8aSmrg      func_append install_prog " $func_quote_for_eval_result"
2849e9fcaa8aSmrg      if test -n "$arg2"; then
2850e9fcaa8aSmrg	func_quote_for_eval "$arg2"
2851e9fcaa8aSmrg      fi
2852e9fcaa8aSmrg      func_append install_shared_prog " $func_quote_for_eval_result"
285388de56ccSmrg    done
28541ab64890Smrg
285588de56ccSmrg    test -z "$install_prog" && \
285688de56ccSmrg      func_fatal_help "you must specify an install program"
28571ab64890Smrg
285888de56ccSmrg    test -n "$prev" && \
285988de56ccSmrg      func_fatal_help "the \`$prev' option requires an argument"
28602e9c7c8cSmrg
2861e9fcaa8aSmrg    if test -n "$install_override_mode" && $no_mode; then
2862e9fcaa8aSmrg      if $install_cp; then :; else
2863e9fcaa8aSmrg	func_quote_for_eval "$install_override_mode"
2864e9fcaa8aSmrg	func_append install_shared_prog " -m $func_quote_for_eval_result"
2865e9fcaa8aSmrg      fi
2866e9fcaa8aSmrg    fi
2867e9fcaa8aSmrg
286888de56ccSmrg    if test -z "$files"; then
286988de56ccSmrg      if test -z "$dest"; then
287088de56ccSmrg	func_fatal_help "no file or destination specified"
287188de56ccSmrg      else
287288de56ccSmrg	func_fatal_help "you must specify a destination"
287388de56ccSmrg      fi
2874b4ee4795Smrg    fi
28752e9c7c8cSmrg
287688de56ccSmrg    # Strip any trailing slash from the destination.
287788de56ccSmrg    func_stripname '' '/' "$dest"
287888de56ccSmrg    dest=$func_stripname_result
28792e9c7c8cSmrg
288088de56ccSmrg    # Check to see that the destination is a directory.
288188de56ccSmrg    test -d "$dest" && isdir=yes
288288de56ccSmrg    if test "$isdir" = yes; then
288388de56ccSmrg      destdir="$dest"
288488de56ccSmrg      destname=
2885b4ee4795Smrg    else
288688de56ccSmrg      func_dirname_and_basename "$dest" "" "."
288788de56ccSmrg      destdir="$func_dirname_result"
288888de56ccSmrg      destname="$func_basename_result"
28892e9c7c8cSmrg
289088de56ccSmrg      # Not a directory, so check to see that there is only one file specified.
289188de56ccSmrg      set dummy $files; shift
289288de56ccSmrg      test "$#" -gt 1 && \
289388de56ccSmrg	func_fatal_help "\`$dest' is not a directory"
28942e9c7c8cSmrg    fi
289588de56ccSmrg    case $destdir in
289688de56ccSmrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
2897b4ee4795Smrg    *)
289888de56ccSmrg      for file in $files; do
289988de56ccSmrg	case $file in
290088de56ccSmrg	*.lo) ;;
290188de56ccSmrg	*)
290288de56ccSmrg	  func_fatal_help "\`$destdir' must be an absolute directory name"
290388de56ccSmrg	  ;;
290488de56ccSmrg	esac
290588de56ccSmrg      done
2906b4ee4795Smrg      ;;
2907b4ee4795Smrg    esac
29081ab64890Smrg
290988de56ccSmrg    # This variable tells wrapper scripts just to set variables rather
291088de56ccSmrg    # than running their programs.
291188de56ccSmrg    libtool_install_magic="$magic"
29121ab64890Smrg
291388de56ccSmrg    staticlibs=
291488de56ccSmrg    future_libdirs=
291588de56ccSmrg    current_libdirs=
291688de56ccSmrg    for file in $files; do
29171ab64890Smrg
291888de56ccSmrg      # Do each installation.
291988de56ccSmrg      case $file in
292088de56ccSmrg      *.$libext)
292188de56ccSmrg	# Do the static libraries later.
2922e9fcaa8aSmrg	func_append staticlibs " $file"
292388de56ccSmrg	;;
292488de56ccSmrg
292588de56ccSmrg      *.la)
2926e9fcaa8aSmrg	func_resolve_sysroot "$file"
2927e9fcaa8aSmrg	file=$func_resolve_sysroot_result
2928e9fcaa8aSmrg
292988de56ccSmrg	# Check to see that this really is a libtool archive.
293088de56ccSmrg	func_lalib_unsafe_p "$file" \
293188de56ccSmrg	  || func_fatal_help "\`$file' is not a valid libtool archive"
293288de56ccSmrg
293388de56ccSmrg	library_names=
293488de56ccSmrg	old_library=
293588de56ccSmrg	relink_command=
293688de56ccSmrg	func_source "$file"
293788de56ccSmrg
293888de56ccSmrg	# Add the libdir to current_libdirs if it is the destination.
293988de56ccSmrg	if test "X$destdir" = "X$libdir"; then
294088de56ccSmrg	  case "$current_libdirs " in
294188de56ccSmrg	  *" $libdir "*) ;;
2942e9fcaa8aSmrg	  *) func_append current_libdirs " $libdir" ;;
29432e9c7c8cSmrg	  esac
294488de56ccSmrg	else
294588de56ccSmrg	  # Note the libdir as a future libdir.
294688de56ccSmrg	  case "$future_libdirs " in
294788de56ccSmrg	  *" $libdir "*) ;;
2948e9fcaa8aSmrg	  *) func_append future_libdirs " $libdir" ;;
294988de56ccSmrg	  esac
295088de56ccSmrg	fi
29512e9c7c8cSmrg
295288de56ccSmrg	func_dirname "$file" "/" ""
295388de56ccSmrg	dir="$func_dirname_result"
2954e9fcaa8aSmrg	func_append dir "$objdir"
295588de56ccSmrg
295688de56ccSmrg	if test -n "$relink_command"; then
295788de56ccSmrg	  # Determine the prefix the user has applied to our future dir.
2958e9fcaa8aSmrg	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
295988de56ccSmrg
296088de56ccSmrg	  # Don't allow the user to place us outside of our expected
296188de56ccSmrg	  # location b/c this prevents finding dependent libraries that
296288de56ccSmrg	  # are installed to the same prefix.
296388de56ccSmrg	  # At present, this check doesn't affect windows .dll's that
296488de56ccSmrg	  # are installed into $libdir/../bin (currently, that works fine)
296588de56ccSmrg	  # but it's something to keep an eye on.
296688de56ccSmrg	  test "$inst_prefix_dir" = "$destdir" && \
296788de56ccSmrg	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
296888de56ccSmrg
296988de56ccSmrg	  if test -n "$inst_prefix_dir"; then
297088de56ccSmrg	    # Stick the inst_prefix_dir data into the link command.
2971e9fcaa8aSmrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
297288de56ccSmrg	  else
2973e9fcaa8aSmrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
297488de56ccSmrg	  fi
297588de56ccSmrg
297688de56ccSmrg	  func_warning "relinking \`$file'"
297788de56ccSmrg	  func_show_eval "$relink_command" \
297888de56ccSmrg	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
297988de56ccSmrg	fi
298088de56ccSmrg
298188de56ccSmrg	# See the names of the shared library.
298288de56ccSmrg	set dummy $library_names; shift
298388de56ccSmrg	if test -n "$1"; then
298488de56ccSmrg	  realname="$1"
298588de56ccSmrg	  shift
298688de56ccSmrg
298788de56ccSmrg	  srcname="$realname"
298888de56ccSmrg	  test -n "$relink_command" && srcname="$realname"T
298988de56ccSmrg
299088de56ccSmrg	  # Install the shared library and build the symlinks.
2991e9fcaa8aSmrg	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
299288de56ccSmrg	      'exit $?'
299388de56ccSmrg	  tstripme="$stripme"
299488de56ccSmrg	  case $host_os in
299588de56ccSmrg	  cygwin* | mingw* | pw32* | cegcc*)
299688de56ccSmrg	    case $realname in
299788de56ccSmrg	    *.dll.a)
299888de56ccSmrg	      tstripme=""
299988de56ccSmrg	      ;;
300088de56ccSmrg	    esac
30012e9c7c8cSmrg	    ;;
30022e9c7c8cSmrg	  esac
300388de56ccSmrg	  if test -n "$tstripme" && test -n "$striplib"; then
300488de56ccSmrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
3005b4ee4795Smrg	  fi
300688de56ccSmrg
300788de56ccSmrg	  if test "$#" -gt 0; then
300888de56ccSmrg	    # Delete the old symlinks, and create new ones.
300988de56ccSmrg	    # Try `ln -sf' first, because the `ln' binary might depend on
301088de56ccSmrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
301188de56ccSmrg	    # so we also need to try rm && ln -s.
301288de56ccSmrg	    for linkname
301388de56ccSmrg	    do
301488de56ccSmrg	      test "$linkname" != "$realname" \
301588de56ccSmrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
3016b4ee4795Smrg	    done
3017b4ee4795Smrg	  fi
30181ab64890Smrg
301988de56ccSmrg	  # Do each command in the postinstall commands.
302088de56ccSmrg	  lib="$destdir/$realname"
302188de56ccSmrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
3022b4ee4795Smrg	fi
30231ab64890Smrg
302488de56ccSmrg	# Install the pseudo-library for information purposes.
302588de56ccSmrg	func_basename "$file"
302688de56ccSmrg	name="$func_basename_result"
302788de56ccSmrg	instname="$dir/$name"i
302888de56ccSmrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
30291ab64890Smrg
303088de56ccSmrg	# Maybe install the static library, too.
3031e9fcaa8aSmrg	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
303288de56ccSmrg	;;
30331ab64890Smrg
303488de56ccSmrg      *.lo)
303588de56ccSmrg	# Install (i.e. copy) a libtool object.
30361ab64890Smrg
303788de56ccSmrg	# Figure out destination file name, if it wasn't already specified.
303888de56ccSmrg	if test -n "$destname"; then
303988de56ccSmrg	  destfile="$destdir/$destname"
304088de56ccSmrg	else
304188de56ccSmrg	  func_basename "$file"
304288de56ccSmrg	  destfile="$func_basename_result"
304388de56ccSmrg	  destfile="$destdir/$destfile"
3044b4ee4795Smrg	fi
30451ab64890Smrg
304688de56ccSmrg	# Deduce the name of the destination old-style object file.
304788de56ccSmrg	case $destfile in
304888de56ccSmrg	*.lo)
304988de56ccSmrg	  func_lo2o "$destfile"
305088de56ccSmrg	  staticdest=$func_lo2o_result
305188de56ccSmrg	  ;;
305288de56ccSmrg	*.$objext)
305388de56ccSmrg	  staticdest="$destfile"
305488de56ccSmrg	  destfile=
305588de56ccSmrg	  ;;
305688de56ccSmrg	*)
305788de56ccSmrg	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
305888de56ccSmrg	  ;;
305988de56ccSmrg	esac
30601ab64890Smrg
306188de56ccSmrg	# Install the libtool object if requested.
306288de56ccSmrg	test -n "$destfile" && \
306388de56ccSmrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
30641ab64890Smrg
306588de56ccSmrg	# Install the old object if enabled.
306688de56ccSmrg	if test "$build_old_libs" = yes; then
306788de56ccSmrg	  # Deduce the name of the old-style object file.
306888de56ccSmrg	  func_lo2o "$file"
306988de56ccSmrg	  staticobj=$func_lo2o_result
307088de56ccSmrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
30711ab64890Smrg	fi
307288de56ccSmrg	exit $EXIT_SUCCESS
307388de56ccSmrg	;;
30741ab64890Smrg
307588de56ccSmrg      *)
307688de56ccSmrg	# Figure out destination file name, if it wasn't already specified.
307788de56ccSmrg	if test -n "$destname"; then
307888de56ccSmrg	  destfile="$destdir/$destname"
307988de56ccSmrg	else
308088de56ccSmrg	  func_basename "$file"
308188de56ccSmrg	  destfile="$func_basename_result"
308288de56ccSmrg	  destfile="$destdir/$destfile"
308388de56ccSmrg	fi
30841ab64890Smrg
308588de56ccSmrg	# If the file is missing, and there is a .exe on the end, strip it
308688de56ccSmrg	# because it is most likely a libtool script we actually want to
308788de56ccSmrg	# install
308888de56ccSmrg	stripped_ext=""
308988de56ccSmrg	case $file in
309088de56ccSmrg	  *.exe)
309188de56ccSmrg	    if test ! -f "$file"; then
309288de56ccSmrg	      func_stripname '' '.exe' "$file"
309388de56ccSmrg	      file=$func_stripname_result
309488de56ccSmrg	      stripped_ext=".exe"
309588de56ccSmrg	    fi
309688de56ccSmrg	    ;;
309788de56ccSmrg	esac
309888de56ccSmrg
309988de56ccSmrg	# Do a test to see if this is really a libtool program.
310088de56ccSmrg	case $host in
310188de56ccSmrg	*cygwin* | *mingw*)
310288de56ccSmrg	    if func_ltwrapper_executable_p "$file"; then
310388de56ccSmrg	      func_ltwrapper_scriptname "$file"
310488de56ccSmrg	      wrapper=$func_ltwrapper_scriptname_result
310588de56ccSmrg	    else
310688de56ccSmrg	      func_stripname '' '.exe' "$file"
310788de56ccSmrg	      wrapper=$func_stripname_result
310888de56ccSmrg	    fi
310988de56ccSmrg	    ;;
3110b4ee4795Smrg	*)
311188de56ccSmrg	    wrapper=$file
311288de56ccSmrg	    ;;
311388de56ccSmrg	esac
311488de56ccSmrg	if func_ltwrapper_script_p "$wrapper"; then
311588de56ccSmrg	  notinst_deplibs=
311688de56ccSmrg	  relink_command=
311788de56ccSmrg
311888de56ccSmrg	  func_source "$wrapper"
311988de56ccSmrg
312088de56ccSmrg	  # Check the variables that should have been set.
312188de56ccSmrg	  test -z "$generated_by_libtool_version" && \
312288de56ccSmrg	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
312388de56ccSmrg
312488de56ccSmrg	  finalize=yes
312588de56ccSmrg	  for lib in $notinst_deplibs; do
312688de56ccSmrg	    # Check to see that each library is installed.
312788de56ccSmrg	    libdir=
312888de56ccSmrg	    if test -f "$lib"; then
312988de56ccSmrg	      func_source "$lib"
313088de56ccSmrg	    fi
3131e9fcaa8aSmrg	    libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
313288de56ccSmrg	    if test -n "$libdir" && test ! -f "$libfile"; then
313388de56ccSmrg	      func_warning "\`$lib' has not been installed in \`$libdir'"
313488de56ccSmrg	      finalize=no
313588de56ccSmrg	    fi
313688de56ccSmrg	  done
313788de56ccSmrg
313888de56ccSmrg	  relink_command=
313988de56ccSmrg	  func_source "$wrapper"
314088de56ccSmrg
314188de56ccSmrg	  outputname=
314288de56ccSmrg	  if test "$fast_install" = no && test -n "$relink_command"; then
314388de56ccSmrg	    $opt_dry_run || {
314488de56ccSmrg	      if test "$finalize" = yes; then
314588de56ccSmrg	        tmpdir=`func_mktempdir`
314688de56ccSmrg		func_basename "$file$stripped_ext"
314788de56ccSmrg		file="$func_basename_result"
314888de56ccSmrg	        outputname="$tmpdir/$file"
314988de56ccSmrg	        # Replace the output file specification.
3150e9fcaa8aSmrg	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
315188de56ccSmrg
315288de56ccSmrg	        $opt_silent || {
315388de56ccSmrg	          func_quote_for_expand "$relink_command"
315488de56ccSmrg		  eval "func_echo $func_quote_for_expand_result"
315588de56ccSmrg	        }
315688de56ccSmrg	        if eval "$relink_command"; then :
315788de56ccSmrg	          else
315888de56ccSmrg		  func_error "error: relink \`$file' with the above command before installing it"
315988de56ccSmrg		  $opt_dry_run || ${RM}r "$tmpdir"
316088de56ccSmrg		  continue
316188de56ccSmrg	        fi
316288de56ccSmrg	        file="$outputname"
316388de56ccSmrg	      else
316488de56ccSmrg	        func_warning "cannot relink \`$file'"
316588de56ccSmrg	      fi
316688de56ccSmrg	    }
316788de56ccSmrg	  else
316888de56ccSmrg	    # Install the binary that we compiled earlier.
3169e9fcaa8aSmrg	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
3170b4ee4795Smrg	  fi
317188de56ccSmrg	fi
317288de56ccSmrg
317388de56ccSmrg	# remove .exe since cygwin /usr/bin/install will append another
317488de56ccSmrg	# one anyway
317588de56ccSmrg	case $install_prog,$host in
317688de56ccSmrg	*/usr/bin/install*,*cygwin*)
317788de56ccSmrg	  case $file:$destfile in
317888de56ccSmrg	  *.exe:*.exe)
317988de56ccSmrg	    # this is ok
318088de56ccSmrg	    ;;
318188de56ccSmrg	  *.exe:*)
318288de56ccSmrg	    destfile=$destfile.exe
318388de56ccSmrg	    ;;
318488de56ccSmrg	  *:*.exe)
318588de56ccSmrg	    func_stripname '' '.exe' "$destfile"
318688de56ccSmrg	    destfile=$func_stripname_result
318788de56ccSmrg	    ;;
318888de56ccSmrg	  esac
3189b4ee4795Smrg	  ;;
3190b4ee4795Smrg	esac
319188de56ccSmrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
319288de56ccSmrg	$opt_dry_run || if test -n "$outputname"; then
319388de56ccSmrg	  ${RM}r "$tmpdir"
319488de56ccSmrg	fi
319588de56ccSmrg	;;
319688de56ccSmrg      esac
319788de56ccSmrg    done
31981ab64890Smrg
319988de56ccSmrg    for file in $staticlibs; do
320088de56ccSmrg      func_basename "$file"
320188de56ccSmrg      name="$func_basename_result"
320288de56ccSmrg
320388de56ccSmrg      # Set up the ranlib parameters.
320488de56ccSmrg      oldlib="$destdir/$name"
3205eb411b4bSmrg      func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
3206eb411b4bSmrg      tool_oldlib=$func_to_tool_file_result
320788de56ccSmrg
320888de56ccSmrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
320988de56ccSmrg
321088de56ccSmrg      if test -n "$stripme" && test -n "$old_striplib"; then
3211eb411b4bSmrg	func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
321288de56ccSmrg      fi
321388de56ccSmrg
321488de56ccSmrg      # Do each command in the postinstall commands.
321588de56ccSmrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
321688de56ccSmrg    done
321788de56ccSmrg
321888de56ccSmrg    test -n "$future_libdirs" && \
321988de56ccSmrg      func_warning "remember to run \`$progname --finish$future_libdirs'"
322088de56ccSmrg
322188de56ccSmrg    if test -n "$current_libdirs"; then
322288de56ccSmrg      # Maybe just do a dry run.
322388de56ccSmrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
322488de56ccSmrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
322588de56ccSmrg    else
322688de56ccSmrg      exit $EXIT_SUCCESS
322788de56ccSmrg    fi
322888de56ccSmrg}
322988de56ccSmrg
3230e9fcaa8aSmrgtest "$opt_mode" = install && func_mode_install ${1+"$@"}
323188de56ccSmrg
323288de56ccSmrg
323388de56ccSmrg# func_generate_dlsyms outputname originator pic_p
323488de56ccSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with
323588de56ccSmrg# a dlpreopen symbol table.
323688de56ccSmrgfunc_generate_dlsyms ()
323788de56ccSmrg{
323888de56ccSmrg    $opt_debug
323988de56ccSmrg    my_outputname="$1"
324088de56ccSmrg    my_originator="$2"
324188de56ccSmrg    my_pic_p="${3-no}"
324288de56ccSmrg    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
324388de56ccSmrg    my_dlsyms=
324488de56ccSmrg
324588de56ccSmrg    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
324688de56ccSmrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
324788de56ccSmrg	my_dlsyms="${my_outputname}S.c"
324888de56ccSmrg      else
324988de56ccSmrg	func_error "not configured to extract global symbols from dlpreopened files"
325088de56ccSmrg      fi
325188de56ccSmrg    fi
325288de56ccSmrg
325388de56ccSmrg    if test -n "$my_dlsyms"; then
325488de56ccSmrg      case $my_dlsyms in
325588de56ccSmrg      "") ;;
325688de56ccSmrg      *.c)
325788de56ccSmrg	# Discover the nlist of each of the dlfiles.
325888de56ccSmrg	nlist="$output_objdir/${my_outputname}.nm"
325988de56ccSmrg
326088de56ccSmrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
326188de56ccSmrg
326288de56ccSmrg	# Parse the name list into a source file.
326388de56ccSmrg	func_verbose "creating $output_objdir/$my_dlsyms"
326488de56ccSmrg
326588de56ccSmrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
326688de56ccSmrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
326788de56ccSmrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
326888de56ccSmrg
326988de56ccSmrg#ifdef __cplusplus
327088de56ccSmrgextern \"C\" {
327188de56ccSmrg#endif
327288de56ccSmrg
3273e9fcaa8aSmrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
3274e9fcaa8aSmrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
3275e9fcaa8aSmrg#endif
3276e9fcaa8aSmrg
3277e9fcaa8aSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
3278e9fcaa8aSmrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
3279e9fcaa8aSmrg/* DATA imports from DLLs on WIN32 con't be const, because runtime
3280e9fcaa8aSmrg   relocations are performed -- see ld's documentation on pseudo-relocs.  */
3281e9fcaa8aSmrg# define LT_DLSYM_CONST
3282e9fcaa8aSmrg#elif defined(__osf__)
3283e9fcaa8aSmrg/* This system does not cope well with relocations in const data.  */
3284e9fcaa8aSmrg# define LT_DLSYM_CONST
3285e9fcaa8aSmrg#else
3286e9fcaa8aSmrg# define LT_DLSYM_CONST const
3287e9fcaa8aSmrg#endif
3288e9fcaa8aSmrg
328988de56ccSmrg/* External symbol declarations for the compiler. */\
329088de56ccSmrg"
329188de56ccSmrg
329288de56ccSmrg	if test "$dlself" = yes; then
329388de56ccSmrg	  func_verbose "generating symbol list for \`$output'"
329488de56ccSmrg
329588de56ccSmrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
329688de56ccSmrg
329788de56ccSmrg	  # Add our own program objects to the symbol list.
3298e9fcaa8aSmrg	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
329988de56ccSmrg	  for progfile in $progfiles; do
3300e9fcaa8aSmrg	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
3301e9fcaa8aSmrg	    func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
3302e9fcaa8aSmrg	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
330388de56ccSmrg	  done
330488de56ccSmrg
330588de56ccSmrg	  if test -n "$exclude_expsyms"; then
330688de56ccSmrg	    $opt_dry_run || {
330788de56ccSmrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
330888de56ccSmrg	      eval '$MV "$nlist"T "$nlist"'
330988de56ccSmrg	    }
3310b4ee4795Smrg	  fi
331188de56ccSmrg
331288de56ccSmrg	  if test -n "$export_symbols_regex"; then
331388de56ccSmrg	    $opt_dry_run || {
331488de56ccSmrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
331588de56ccSmrg	      eval '$MV "$nlist"T "$nlist"'
331688de56ccSmrg	    }
331788de56ccSmrg	  fi
331888de56ccSmrg
331988de56ccSmrg	  # Prepare the list of exported symbols
332088de56ccSmrg	  if test -z "$export_symbols"; then
332188de56ccSmrg	    export_symbols="$output_objdir/$outputname.exp"
332288de56ccSmrg	    $opt_dry_run || {
332388de56ccSmrg	      $RM $export_symbols
332488de56ccSmrg	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
332588de56ccSmrg	      case $host in
332688de56ccSmrg	      *cygwin* | *mingw* | *cegcc* )
332788de56ccSmrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
332888de56ccSmrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
332988de56ccSmrg	        ;;
333088de56ccSmrg	      esac
333188de56ccSmrg	    }
3332b4ee4795Smrg	  else
333388de56ccSmrg	    $opt_dry_run || {
333488de56ccSmrg	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
333588de56ccSmrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
333688de56ccSmrg	      eval '$MV "$nlist"T "$nlist"'
333788de56ccSmrg	      case $host in
3338e9fcaa8aSmrg	        *cygwin* | *mingw* | *cegcc* )
333988de56ccSmrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
334088de56ccSmrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
334188de56ccSmrg	          ;;
334288de56ccSmrg	      esac
334388de56ccSmrg	    }
3344b4ee4795Smrg	  fi
334588de56ccSmrg	fi
33461ab64890Smrg
334788de56ccSmrg	for dlprefile in $dlprefiles; do
334888de56ccSmrg	  func_verbose "extracting global C symbols from \`$dlprefile'"
334988de56ccSmrg	  func_basename "$dlprefile"
335088de56ccSmrg	  name="$func_basename_result"
3351e9fcaa8aSmrg          case $host in
3352e9fcaa8aSmrg	    *cygwin* | *mingw* | *cegcc* )
3353e9fcaa8aSmrg	      # if an import library, we need to obtain dlname
3354e9fcaa8aSmrg	      if func_win32_import_lib_p "$dlprefile"; then
3355e9fcaa8aSmrg	        func_tr_sh "$dlprefile"
3356e9fcaa8aSmrg	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
3357e9fcaa8aSmrg	        dlprefile_dlbasename=""
3358e9fcaa8aSmrg	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
3359e9fcaa8aSmrg	          # Use subshell, to avoid clobbering current variable values
3360e9fcaa8aSmrg	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
3361e9fcaa8aSmrg	          if test -n "$dlprefile_dlname" ; then
3362e9fcaa8aSmrg	            func_basename "$dlprefile_dlname"
3363e9fcaa8aSmrg	            dlprefile_dlbasename="$func_basename_result"
3364e9fcaa8aSmrg	          else
3365e9fcaa8aSmrg	            # no lafile. user explicitly requested -dlpreopen <import library>.
3366e9fcaa8aSmrg	            $sharedlib_from_linklib_cmd "$dlprefile"
3367e9fcaa8aSmrg	            dlprefile_dlbasename=$sharedlib_from_linklib_result
3368e9fcaa8aSmrg	          fi
3369e9fcaa8aSmrg	        fi
3370e9fcaa8aSmrg	        $opt_dry_run || {
3371e9fcaa8aSmrg	          if test -n "$dlprefile_dlbasename" ; then
3372e9fcaa8aSmrg	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
3373e9fcaa8aSmrg	          else
3374e9fcaa8aSmrg	            func_warning "Could not compute DLL name from $name"
3375e9fcaa8aSmrg	            eval '$ECHO ": $name " >> "$nlist"'
3376e9fcaa8aSmrg	          fi
3377e9fcaa8aSmrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3378e9fcaa8aSmrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
3379e9fcaa8aSmrg	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
3380e9fcaa8aSmrg	        }
3381e9fcaa8aSmrg	      else # not an import lib
3382e9fcaa8aSmrg	        $opt_dry_run || {
3383e9fcaa8aSmrg	          eval '$ECHO ": $name " >> "$nlist"'
3384e9fcaa8aSmrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3385e9fcaa8aSmrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3386e9fcaa8aSmrg	        }
3387e9fcaa8aSmrg	      fi
3388e9fcaa8aSmrg	    ;;
3389e9fcaa8aSmrg	    *)
3390e9fcaa8aSmrg	      $opt_dry_run || {
3391e9fcaa8aSmrg	        eval '$ECHO ": $name " >> "$nlist"'
3392e9fcaa8aSmrg	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3393e9fcaa8aSmrg	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3394e9fcaa8aSmrg	      }
3395e9fcaa8aSmrg	    ;;
3396e9fcaa8aSmrg          esac
339788de56ccSmrg	done
339888de56ccSmrg
339988de56ccSmrg	$opt_dry_run || {
340088de56ccSmrg	  # Make sure we have at least an empty file.
340188de56ccSmrg	  test -f "$nlist" || : > "$nlist"
340288de56ccSmrg
340388de56ccSmrg	  if test -n "$exclude_expsyms"; then
340488de56ccSmrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
340588de56ccSmrg	    $MV "$nlist"T "$nlist"
3406b4ee4795Smrg	  fi
340788de56ccSmrg
340888de56ccSmrg	  # Try sorting and uniquifying the output.
340988de56ccSmrg	  if $GREP -v "^: " < "$nlist" |
341088de56ccSmrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
341188de56ccSmrg		sort -k 3
341288de56ccSmrg	      else
341388de56ccSmrg		sort +2
341488de56ccSmrg	      fi |
341588de56ccSmrg	      uniq > "$nlist"S; then
341688de56ccSmrg	    :
3417b4ee4795Smrg	  else
341888de56ccSmrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
3419b4ee4795Smrg	  fi
34201ab64890Smrg
342188de56ccSmrg	  if test -f "$nlist"S; then
342288de56ccSmrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
3423b4ee4795Smrg	  else
3424e9fcaa8aSmrg	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
3425b4ee4795Smrg	  fi
34261ab64890Smrg
3427e9fcaa8aSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
34281ab64890Smrg
342988de56ccSmrg/* The mapping between symbol names and symbols.  */
343088de56ccSmrgtypedef struct {
343188de56ccSmrg  const char *name;
343288de56ccSmrg  void *address;
343388de56ccSmrg} lt_dlsymlist;
3434e9fcaa8aSmrgextern LT_DLSYM_CONST lt_dlsymlist
343588de56ccSmrglt_${my_prefix}_LTX_preloaded_symbols[];
3436e9fcaa8aSmrgLT_DLSYM_CONST lt_dlsymlist
343788de56ccSmrglt_${my_prefix}_LTX_preloaded_symbols[] =
343888de56ccSmrg{\
343988de56ccSmrg  { \"$my_originator\", (void *) 0 },"
34401ab64890Smrg
344188de56ccSmrg	  case $need_lib_prefix in
344288de56ccSmrg	  no)
344388de56ccSmrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
344488de56ccSmrg	    ;;
344588de56ccSmrg	  *)
344688de56ccSmrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
344788de56ccSmrg	    ;;
344888de56ccSmrg	  esac
3449e9fcaa8aSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
345088de56ccSmrg  {0, (void *) 0}
345188de56ccSmrg};
34521ab64890Smrg
345388de56ccSmrg/* This works around a problem in FreeBSD linker */
345488de56ccSmrg#ifdef FREEBSD_WORKAROUND
345588de56ccSmrgstatic const void *lt_preloaded_setup() {
345688de56ccSmrg  return lt_${my_prefix}_LTX_preloaded_symbols;
345788de56ccSmrg}
345888de56ccSmrg#endif
345988de56ccSmrg
346088de56ccSmrg#ifdef __cplusplus
346188de56ccSmrg}
346288de56ccSmrg#endif\
346388de56ccSmrg"
346488de56ccSmrg	} # !$opt_dry_run
346588de56ccSmrg
346688de56ccSmrg	pic_flag_for_symtable=
346788de56ccSmrg	case "$compile_command " in
346888de56ccSmrg	*" -static "*) ;;
346988de56ccSmrg	*)
347088de56ccSmrg	  case $host in
347188de56ccSmrg	  # compiling the symbol table file with pic_flag works around
347288de56ccSmrg	  # a FreeBSD bug that causes programs to crash when -lm is
347388de56ccSmrg	  # linked before any other PIC object.  But we must not use
347488de56ccSmrg	  # pic_flag when linking with -static.  The problem exists in
347588de56ccSmrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
3476eb411b4bSmrg	  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
347788de56ccSmrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
347888de56ccSmrg	  *-*-hpux*)
347988de56ccSmrg	    pic_flag_for_symtable=" $pic_flag"  ;;
348088de56ccSmrg	  *)
348188de56ccSmrg	    if test "X$my_pic_p" != Xno; then
348288de56ccSmrg	      pic_flag_for_symtable=" $pic_flag"
3483b4ee4795Smrg	    fi
348488de56ccSmrg	    ;;
348588de56ccSmrg	  esac
348688de56ccSmrg	  ;;
348788de56ccSmrg	esac
348888de56ccSmrg	symtab_cflags=
348988de56ccSmrg	for arg in $LTCFLAGS; do
349088de56ccSmrg	  case $arg in
349188de56ccSmrg	  -pie | -fpie | -fPIE) ;;
3492e9fcaa8aSmrg	  *) func_append symtab_cflags " $arg" ;;
349388de56ccSmrg	  esac
349488de56ccSmrg	done
34951ab64890Smrg
349688de56ccSmrg	# Now compile the dynamic symbol file.
349788de56ccSmrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
34982e9c7c8cSmrg
349988de56ccSmrg	# Clean up the generated files.
350088de56ccSmrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
35011ab64890Smrg
350288de56ccSmrg	# Transform the symbol file into the correct name.
350388de56ccSmrg	symfileobj="$output_objdir/${my_outputname}S.$objext"
350488de56ccSmrg	case $host in
350588de56ccSmrg	*cygwin* | *mingw* | *cegcc* )
350688de56ccSmrg	  if test -f "$output_objdir/$my_outputname.def"; then
3507e9fcaa8aSmrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3508e9fcaa8aSmrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
350988de56ccSmrg	  else
3510e9fcaa8aSmrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3511e9fcaa8aSmrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3512b4ee4795Smrg	  fi
351388de56ccSmrg	  ;;
351488de56ccSmrg	*)
3515e9fcaa8aSmrg	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3516e9fcaa8aSmrg	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
351788de56ccSmrg	  ;;
351888de56ccSmrg	esac
351988de56ccSmrg	;;
352088de56ccSmrg      *)
352188de56ccSmrg	func_fatal_error "unknown suffix for \`$my_dlsyms'"
352288de56ccSmrg	;;
352388de56ccSmrg      esac
352488de56ccSmrg    else
352588de56ccSmrg      # We keep going just in case the user didn't refer to
352688de56ccSmrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
352788de56ccSmrg      # really was required.
35281ab64890Smrg
352988de56ccSmrg      # Nullify the symbol file.
3530e9fcaa8aSmrg      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
3531e9fcaa8aSmrg      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
353288de56ccSmrg    fi
353388de56ccSmrg}
35342e9c7c8cSmrg
353588de56ccSmrg# func_win32_libid arg
353688de56ccSmrg# return the library type of file 'arg'
353788de56ccSmrg#
353888de56ccSmrg# Need a lot of goo to handle *both* DLLs and import libs
353988de56ccSmrg# Has to be a shell function in order to 'eat' the argument
354088de56ccSmrg# that is supplied when $file_magic_command is called.
3541e9fcaa8aSmrg# Despite the name, also deal with 64 bit binaries.
354288de56ccSmrgfunc_win32_libid ()
354388de56ccSmrg{
354488de56ccSmrg  $opt_debug
354588de56ccSmrg  win32_libid_type="unknown"
354688de56ccSmrg  win32_fileres=`file -L $1 2>/dev/null`
354788de56ccSmrg  case $win32_fileres in
354888de56ccSmrg  *ar\ archive\ import\ library*) # definitely import
354988de56ccSmrg    win32_libid_type="x86 archive import"
355088de56ccSmrg    ;;
355188de56ccSmrg  *ar\ archive*) # could be an import, or static
3552e9fcaa8aSmrg    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
355388de56ccSmrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
3554e9fcaa8aSmrg       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
3555e9fcaa8aSmrg      func_to_tool_file "$1" func_convert_file_msys_to_w32
3556e9fcaa8aSmrg      win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
355788de56ccSmrg	$SED -n -e '
355888de56ccSmrg	    1,100{
355988de56ccSmrg		/ I /{
356088de56ccSmrg		    s,.*,import,
356188de56ccSmrg		    p
356288de56ccSmrg		    q
356388de56ccSmrg		}
356488de56ccSmrg	    }'`
356588de56ccSmrg      case $win32_nmres in
356688de56ccSmrg      import*)  win32_libid_type="x86 archive import";;
356788de56ccSmrg      *)        win32_libid_type="x86 archive static";;
356888de56ccSmrg      esac
356988de56ccSmrg    fi
357088de56ccSmrg    ;;
357188de56ccSmrg  *DLL*)
357288de56ccSmrg    win32_libid_type="x86 DLL"
357388de56ccSmrg    ;;
357488de56ccSmrg  *executable*) # but shell scripts are "executable" too...
357588de56ccSmrg    case $win32_fileres in
357688de56ccSmrg    *MS\ Windows\ PE\ Intel*)
357788de56ccSmrg      win32_libid_type="x86 DLL"
357888de56ccSmrg      ;;
357988de56ccSmrg    esac
358088de56ccSmrg    ;;
358188de56ccSmrg  esac
358288de56ccSmrg  $ECHO "$win32_libid_type"
358388de56ccSmrg}
35842e9c7c8cSmrg
3585e9fcaa8aSmrg# func_cygming_dll_for_implib ARG
3586e9fcaa8aSmrg#
3587e9fcaa8aSmrg# Platform-specific function to extract the
3588e9fcaa8aSmrg# name of the DLL associated with the specified
3589e9fcaa8aSmrg# import library ARG.
3590e9fcaa8aSmrg# Invoked by eval'ing the libtool variable
3591e9fcaa8aSmrg#    $sharedlib_from_linklib_cmd
3592e9fcaa8aSmrg# Result is available in the variable
3593e9fcaa8aSmrg#    $sharedlib_from_linklib_result
3594e9fcaa8aSmrgfunc_cygming_dll_for_implib ()
3595e9fcaa8aSmrg{
3596e9fcaa8aSmrg  $opt_debug
3597e9fcaa8aSmrg  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
3598e9fcaa8aSmrg}
3599e9fcaa8aSmrg
3600e9fcaa8aSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
3601e9fcaa8aSmrg#
3602e9fcaa8aSmrg# The is the core of a fallback implementation of a
3603e9fcaa8aSmrg# platform-specific function to extract the name of the
3604e9fcaa8aSmrg# DLL associated with the specified import library LIBNAME.
3605e9fcaa8aSmrg#
3606e9fcaa8aSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending
3607e9fcaa8aSmrg# on the platform and compiler that created the implib.
3608e9fcaa8aSmrg#
3609e9fcaa8aSmrg# Echos the name of the DLL associated with the
3610e9fcaa8aSmrg# specified import library.
3611e9fcaa8aSmrgfunc_cygming_dll_for_implib_fallback_core ()
3612e9fcaa8aSmrg{
3613e9fcaa8aSmrg  $opt_debug
3614e9fcaa8aSmrg  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
3615e9fcaa8aSmrg  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
3616e9fcaa8aSmrg    $SED '/^Contents of section '"$match_literal"':/{
3617e9fcaa8aSmrg      # Place marker at beginning of archive member dllname section
3618e9fcaa8aSmrg      s/.*/====MARK====/
3619e9fcaa8aSmrg      p
3620e9fcaa8aSmrg      d
3621e9fcaa8aSmrg    }
3622e9fcaa8aSmrg    # These lines can sometimes be longer than 43 characters, but
3623e9fcaa8aSmrg    # are always uninteresting
3624e9fcaa8aSmrg    /:[	 ]*file format pe[i]\{,1\}-/d
3625e9fcaa8aSmrg    /^In archive [^:]*:/d
3626e9fcaa8aSmrg    # Ensure marker is printed
3627e9fcaa8aSmrg    /^====MARK====/p
3628e9fcaa8aSmrg    # Remove all lines with less than 43 characters
3629e9fcaa8aSmrg    /^.\{43\}/!d
3630e9fcaa8aSmrg    # From remaining lines, remove first 43 characters
3631e9fcaa8aSmrg    s/^.\{43\}//' |
3632e9fcaa8aSmrg    $SED -n '
3633e9fcaa8aSmrg      # Join marker and all lines until next marker into a single line
3634e9fcaa8aSmrg      /^====MARK====/ b para
3635e9fcaa8aSmrg      H
3636e9fcaa8aSmrg      $ b para
3637e9fcaa8aSmrg      b
3638e9fcaa8aSmrg      :para
3639e9fcaa8aSmrg      x
3640e9fcaa8aSmrg      s/\n//g
3641e9fcaa8aSmrg      # Remove the marker
3642e9fcaa8aSmrg      s/^====MARK====//
3643e9fcaa8aSmrg      # Remove trailing dots and whitespace
3644e9fcaa8aSmrg      s/[\. \t]*$//
3645e9fcaa8aSmrg      # Print
3646e9fcaa8aSmrg      /./p' |
3647e9fcaa8aSmrg    # we now have a list, one entry per line, of the stringified
3648e9fcaa8aSmrg    # contents of the appropriate section of all members of the
3649e9fcaa8aSmrg    # archive which possess that section. Heuristic: eliminate
3650e9fcaa8aSmrg    # all those which have a first or second character that is
3651e9fcaa8aSmrg    # a '.' (that is, objdump's representation of an unprintable
3652e9fcaa8aSmrg    # character.) This should work for all archives with less than
3653e9fcaa8aSmrg    # 0x302f exports -- but will fail for DLLs whose name actually
3654e9fcaa8aSmrg    # begins with a literal '.' or a single character followed by
3655e9fcaa8aSmrg    # a '.'.
3656e9fcaa8aSmrg    #
3657e9fcaa8aSmrg    # Of those that remain, print the first one.
3658e9fcaa8aSmrg    $SED -e '/^\./d;/^.\./d;q'
3659e9fcaa8aSmrg}
3660e9fcaa8aSmrg
3661e9fcaa8aSmrg# func_cygming_gnu_implib_p ARG
3662e9fcaa8aSmrg# This predicate returns with zero status (TRUE) if
3663e9fcaa8aSmrg# ARG is a GNU/binutils-style import library. Returns
3664e9fcaa8aSmrg# with nonzero status (FALSE) otherwise.
3665e9fcaa8aSmrgfunc_cygming_gnu_implib_p ()
3666e9fcaa8aSmrg{
3667e9fcaa8aSmrg  $opt_debug
3668e9fcaa8aSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
3669e9fcaa8aSmrg  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)$'`
3670e9fcaa8aSmrg  test -n "$func_cygming_gnu_implib_tmp"
3671e9fcaa8aSmrg}
3672e9fcaa8aSmrg
3673e9fcaa8aSmrg# func_cygming_ms_implib_p ARG
3674e9fcaa8aSmrg# This predicate returns with zero status (TRUE) if
3675e9fcaa8aSmrg# ARG is an MS-style import library. Returns
3676e9fcaa8aSmrg# with nonzero status (FALSE) otherwise.
3677e9fcaa8aSmrgfunc_cygming_ms_implib_p ()
3678e9fcaa8aSmrg{
3679e9fcaa8aSmrg  $opt_debug
3680e9fcaa8aSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
3681e9fcaa8aSmrg  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
3682e9fcaa8aSmrg  test -n "$func_cygming_ms_implib_tmp"
3683e9fcaa8aSmrg}
3684e9fcaa8aSmrg
3685e9fcaa8aSmrg# func_cygming_dll_for_implib_fallback ARG
3686e9fcaa8aSmrg# Platform-specific function to extract the
3687e9fcaa8aSmrg# name of the DLL associated with the specified
3688e9fcaa8aSmrg# import library ARG.
3689e9fcaa8aSmrg#
3690e9fcaa8aSmrg# This fallback implementation is for use when $DLLTOOL
3691e9fcaa8aSmrg# does not support the --identify-strict option.
3692e9fcaa8aSmrg# Invoked by eval'ing the libtool variable
3693e9fcaa8aSmrg#    $sharedlib_from_linklib_cmd
3694e9fcaa8aSmrg# Result is available in the variable
3695e9fcaa8aSmrg#    $sharedlib_from_linklib_result
3696e9fcaa8aSmrgfunc_cygming_dll_for_implib_fallback ()
3697e9fcaa8aSmrg{
3698e9fcaa8aSmrg  $opt_debug
3699e9fcaa8aSmrg  if func_cygming_gnu_implib_p "$1" ; then
3700e9fcaa8aSmrg    # binutils import library
3701e9fcaa8aSmrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
3702e9fcaa8aSmrg  elif func_cygming_ms_implib_p "$1" ; then
3703e9fcaa8aSmrg    # ms-generated import library
3704e9fcaa8aSmrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
3705e9fcaa8aSmrg  else
3706e9fcaa8aSmrg    # unknown
3707e9fcaa8aSmrg    sharedlib_from_linklib_result=""
3708e9fcaa8aSmrg  fi
3709e9fcaa8aSmrg}
37102e9c7c8cSmrg
37112e9c7c8cSmrg
371288de56ccSmrg# func_extract_an_archive dir oldlib
371388de56ccSmrgfunc_extract_an_archive ()
371488de56ccSmrg{
371588de56ccSmrg    $opt_debug
371688de56ccSmrg    f_ex_an_ar_dir="$1"; shift
371788de56ccSmrg    f_ex_an_ar_oldlib="$1"
3718e9fcaa8aSmrg    if test "$lock_old_archive_extraction" = yes; then
3719e9fcaa8aSmrg      lockfile=$f_ex_an_ar_oldlib.lock
3720e9fcaa8aSmrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
3721e9fcaa8aSmrg	func_echo "Waiting for $lockfile to be removed"
3722e9fcaa8aSmrg	sleep 2
3723e9fcaa8aSmrg      done
3724e9fcaa8aSmrg    fi
3725e9fcaa8aSmrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
3726e9fcaa8aSmrg		   'stat=$?; rm -f "$lockfile"; exit $stat'
3727e9fcaa8aSmrg    if test "$lock_old_archive_extraction" = yes; then
3728e9fcaa8aSmrg      $opt_dry_run || rm -f "$lockfile"
3729e9fcaa8aSmrg    fi
373088de56ccSmrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
373188de56ccSmrg     :
373288de56ccSmrg    else
373388de56ccSmrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
373488de56ccSmrg    fi
373588de56ccSmrg}
37361ab64890Smrg
37371ab64890Smrg
373888de56ccSmrg# func_extract_archives gentop oldlib ...
373988de56ccSmrgfunc_extract_archives ()
374088de56ccSmrg{
374188de56ccSmrg    $opt_debug
374288de56ccSmrg    my_gentop="$1"; shift
374388de56ccSmrg    my_oldlibs=${1+"$@"}
374488de56ccSmrg    my_oldobjs=""
374588de56ccSmrg    my_xlib=""
374688de56ccSmrg    my_xabs=""
374788de56ccSmrg    my_xdir=""
37481ab64890Smrg
374988de56ccSmrg    for my_xlib in $my_oldlibs; do
375088de56ccSmrg      # Extract the objects.
375188de56ccSmrg      case $my_xlib in
375288de56ccSmrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
375388de56ccSmrg	*) my_xabs=`pwd`"/$my_xlib" ;;
375488de56ccSmrg      esac
375588de56ccSmrg      func_basename "$my_xlib"
375688de56ccSmrg      my_xlib="$func_basename_result"
375788de56ccSmrg      my_xlib_u=$my_xlib
375888de56ccSmrg      while :; do
375988de56ccSmrg        case " $extracted_archives " in
376088de56ccSmrg	*" $my_xlib_u "*)
376188de56ccSmrg	  func_arith $extracted_serial + 1
376288de56ccSmrg	  extracted_serial=$func_arith_result
376388de56ccSmrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
376488de56ccSmrg	*) break ;;
376588de56ccSmrg	esac
376688de56ccSmrg      done
376788de56ccSmrg      extracted_archives="$extracted_archives $my_xlib_u"
376888de56ccSmrg      my_xdir="$my_gentop/$my_xlib_u"
37691ab64890Smrg
377088de56ccSmrg      func_mkdir_p "$my_xdir"
37712e9c7c8cSmrg
377288de56ccSmrg      case $host in
377388de56ccSmrg      *-darwin*)
377488de56ccSmrg	func_verbose "Extracting $my_xabs"
377588de56ccSmrg	# Do not bother doing anything if just a dry run
377688de56ccSmrg	$opt_dry_run || {
377788de56ccSmrg	  darwin_orig_dir=`pwd`
377888de56ccSmrg	  cd $my_xdir || exit $?
377988de56ccSmrg	  darwin_archive=$my_xabs
378088de56ccSmrg	  darwin_curdir=`pwd`
378188de56ccSmrg	  darwin_base_archive=`basename "$darwin_archive"`
378288de56ccSmrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
378388de56ccSmrg	  if test -n "$darwin_arches"; then
378488de56ccSmrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
378588de56ccSmrg	    darwin_arch=
378688de56ccSmrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
378788de56ccSmrg	    for darwin_arch in  $darwin_arches ; do
378888de56ccSmrg	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
378988de56ccSmrg	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
379088de56ccSmrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
379188de56ccSmrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
379288de56ccSmrg	      cd "$darwin_curdir"
379388de56ccSmrg	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
379488de56ccSmrg	    done # $darwin_arches
379588de56ccSmrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
379688de56ccSmrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
379788de56ccSmrg	    darwin_file=
379888de56ccSmrg	    darwin_files=
379988de56ccSmrg	    for darwin_file in $darwin_filelist; do
3800e9fcaa8aSmrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
380188de56ccSmrg	      $LIPO -create -output "$darwin_file" $darwin_files
380288de56ccSmrg	    done # $darwin_filelist
380388de56ccSmrg	    $RM -rf unfat-$$
380488de56ccSmrg	    cd "$darwin_orig_dir"
3805b4ee4795Smrg	  else
380688de56ccSmrg	    cd $darwin_orig_dir
380788de56ccSmrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
380888de56ccSmrg	  fi # $darwin_arches
380988de56ccSmrg	} # !$opt_dry_run
381088de56ccSmrg	;;
381188de56ccSmrg      *)
381288de56ccSmrg        func_extract_an_archive "$my_xdir" "$my_xabs"
381388de56ccSmrg	;;
381488de56ccSmrg      esac
3815e9fcaa8aSmrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
381688de56ccSmrg    done
38171ab64890Smrg
381888de56ccSmrg    func_extract_archives_result="$my_oldobjs"
381988de56ccSmrg}
38201ab64890Smrg
38211ab64890Smrg
3822e9fcaa8aSmrg# func_emit_wrapper [arg=no]
3823e9fcaa8aSmrg#
3824e9fcaa8aSmrg# Emit a libtool wrapper script on stdout.
3825e9fcaa8aSmrg# Don't directly open a file because we may want to
3826e9fcaa8aSmrg# incorporate the script contents within a cygwin/mingw
3827e9fcaa8aSmrg# wrapper executable.  Must ONLY be called from within
3828e9fcaa8aSmrg# func_mode_link because it depends on a number of variables
3829e9fcaa8aSmrg# set therein.
383088de56ccSmrg#
3831e9fcaa8aSmrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
3832e9fcaa8aSmrg# variable will take.  If 'yes', then the emitted script
3833e9fcaa8aSmrg# will assume that the directory in which it is stored is
3834e9fcaa8aSmrg# the $objdir directory.  This is a cygwin/mingw-specific
3835e9fcaa8aSmrg# behavior.
3836e9fcaa8aSmrgfunc_emit_wrapper ()
383788de56ccSmrg{
3838e9fcaa8aSmrg	func_emit_wrapper_arg1=${1-no}
3839b4ee4795Smrg
384088de56ccSmrg	$ECHO "\
384188de56ccSmrg#! $SHELL
38421ab64890Smrg
384388de56ccSmrg# $output - temporary wrapper script for $objdir/$outputname
384488de56ccSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
384588de56ccSmrg#
384688de56ccSmrg# The $output program cannot be directly executed until all the libtool
384788de56ccSmrg# libraries that it depends on are installed.
384888de56ccSmrg#
384988de56ccSmrg# This wrapper script should never be moved out of the build directory.
385088de56ccSmrg# If it is, it will not operate correctly.
38511ab64890Smrg
385288de56ccSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
385388de56ccSmrg# metacharacters that are still active within double-quoted strings.
385488de56ccSmrgsed_quote_subst='$sed_quote_subst'
38551ab64890Smrg
385688de56ccSmrg# Be Bourne compatible
385788de56ccSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
385888de56ccSmrg  emulate sh
385988de56ccSmrg  NULLCMD=:
386088de56ccSmrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
386188de56ccSmrg  # is contrary to our usage.  Disable this feature.
386288de56ccSmrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
386388de56ccSmrg  setopt NO_GLOB_SUBST
386488de56ccSmrgelse
386588de56ccSmrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
386688de56ccSmrgfi
386788de56ccSmrgBIN_SH=xpg4; export BIN_SH # for Tru64
386888de56ccSmrgDUALCASE=1; export DUALCASE # for MKS sh
38691ab64890Smrg
387088de56ccSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout
387188de56ccSmrg# if CDPATH is set.
387288de56ccSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
38731ab64890Smrg
387488de56ccSmrgrelink_command=\"$relink_command\"
38751ab64890Smrg
387688de56ccSmrg# This environment variable determines our operation mode.
387788de56ccSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then
387888de56ccSmrg  # install mode needs the following variables:
387988de56ccSmrg  generated_by_libtool_version='$macro_version'
388088de56ccSmrg  notinst_deplibs='$notinst_deplibs'
388188de56ccSmrgelse
388288de56ccSmrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
388388de56ccSmrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
3884e9fcaa8aSmrg    file=\"\$0\""
3885e9fcaa8aSmrg
3886e9fcaa8aSmrg    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
3887e9fcaa8aSmrg    $ECHO "\
3888e9fcaa8aSmrg
3889e9fcaa8aSmrg# A function that is used when there is no print builtin or printf.
3890e9fcaa8aSmrgfunc_fallback_echo ()
3891e9fcaa8aSmrg{
3892e9fcaa8aSmrg  eval 'cat <<_LTECHO_EOF
3893e9fcaa8aSmrg\$1
3894e9fcaa8aSmrg_LTECHO_EOF'
3895e9fcaa8aSmrg}
3896e9fcaa8aSmrg    ECHO=\"$qECHO\"
3897e9fcaa8aSmrg  fi
3898e9fcaa8aSmrg
3899e9fcaa8aSmrg# Very basic option parsing. These options are (a) specific to
3900e9fcaa8aSmrg# the libtool wrapper, (b) are identical between the wrapper
3901e9fcaa8aSmrg# /script/ and the wrapper /executable/ which is used only on
3902e9fcaa8aSmrg# windows platforms, and (c) all begin with the string "--lt-"
3903e9fcaa8aSmrg# (application programs are unlikely to have options which match
3904e9fcaa8aSmrg# this pattern).
3905e9fcaa8aSmrg#
3906e9fcaa8aSmrg# There are only two supported options: --lt-debug and
3907e9fcaa8aSmrg# --lt-dump-script. There is, deliberately, no --lt-help.
3908e9fcaa8aSmrg#
3909e9fcaa8aSmrg# The first argument to this parsing function should be the
3910e9fcaa8aSmrg# script's $0 value, followed by "$@".
3911e9fcaa8aSmrglt_option_debug=
3912e9fcaa8aSmrgfunc_parse_lt_options ()
3913e9fcaa8aSmrg{
3914e9fcaa8aSmrg  lt_script_arg0=\$0
3915e9fcaa8aSmrg  shift
3916e9fcaa8aSmrg  for lt_opt
3917e9fcaa8aSmrg  do
3918e9fcaa8aSmrg    case \"\$lt_opt\" in
3919e9fcaa8aSmrg    --lt-debug) lt_option_debug=1 ;;
3920e9fcaa8aSmrg    --lt-dump-script)
3921e9fcaa8aSmrg        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
3922e9fcaa8aSmrg        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
3923e9fcaa8aSmrg        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
3924e9fcaa8aSmrg        cat \"\$lt_dump_D/\$lt_dump_F\"
3925e9fcaa8aSmrg        exit 0
3926e9fcaa8aSmrg      ;;
3927e9fcaa8aSmrg    --lt-*)
3928e9fcaa8aSmrg        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
3929e9fcaa8aSmrg        exit 1
3930e9fcaa8aSmrg      ;;
3931e9fcaa8aSmrg    esac
3932e9fcaa8aSmrg  done
3933e9fcaa8aSmrg
3934e9fcaa8aSmrg  # Print the debug banner immediately:
3935e9fcaa8aSmrg  if test -n \"\$lt_option_debug\"; then
3936e9fcaa8aSmrg    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
3937e9fcaa8aSmrg  fi
3938e9fcaa8aSmrg}
3939e9fcaa8aSmrg
3940e9fcaa8aSmrg# Used when --lt-debug. Prints its arguments to stdout
3941e9fcaa8aSmrg# (redirection is the responsibility of the caller)
3942e9fcaa8aSmrgfunc_lt_dump_args ()
3943e9fcaa8aSmrg{
3944e9fcaa8aSmrg  lt_dump_args_N=1;
3945e9fcaa8aSmrg  for lt_arg
3946e9fcaa8aSmrg  do
3947e9fcaa8aSmrg    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
3948e9fcaa8aSmrg    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
3949e9fcaa8aSmrg  done
3950e9fcaa8aSmrg}
3951e9fcaa8aSmrg
3952e9fcaa8aSmrg# Core function for launching the target application
3953e9fcaa8aSmrgfunc_exec_program_core ()
3954e9fcaa8aSmrg{
395588de56ccSmrg"
3956e9fcaa8aSmrg  case $host in
3957e9fcaa8aSmrg  # Backslashes separate directories on plain windows
3958e9fcaa8aSmrg  *-*-mingw | *-*-os2* | *-cegcc*)
3959e9fcaa8aSmrg    $ECHO "\
3960e9fcaa8aSmrg      if test -n \"\$lt_option_debug\"; then
3961e9fcaa8aSmrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
3962e9fcaa8aSmrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
3963e9fcaa8aSmrg      fi
3964e9fcaa8aSmrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
3965e9fcaa8aSmrg"
3966e9fcaa8aSmrg    ;;
3967e9fcaa8aSmrg
3968e9fcaa8aSmrg  *)
3969e9fcaa8aSmrg    $ECHO "\
3970e9fcaa8aSmrg      if test -n \"\$lt_option_debug\"; then
3971e9fcaa8aSmrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
3972e9fcaa8aSmrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
3973e9fcaa8aSmrg      fi
3974e9fcaa8aSmrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
3975e9fcaa8aSmrg"
3976e9fcaa8aSmrg    ;;
3977e9fcaa8aSmrg  esac
3978e9fcaa8aSmrg  $ECHO "\
3979e9fcaa8aSmrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
3980e9fcaa8aSmrg      exit 1
3981e9fcaa8aSmrg}
3982e9fcaa8aSmrg
3983e9fcaa8aSmrg# A function to encapsulate launching the target application
3984e9fcaa8aSmrg# Strips options in the --lt-* namespace from \$@ and
3985e9fcaa8aSmrg# launches target application with the remaining arguments.
3986e9fcaa8aSmrgfunc_exec_program ()
3987e9fcaa8aSmrg{
3988eb411b4bSmrg  case \" \$* \" in
3989eb411b4bSmrg  *\\ --lt-*)
3990eb411b4bSmrg    for lt_wr_arg
3991eb411b4bSmrg    do
3992eb411b4bSmrg      case \$lt_wr_arg in
3993eb411b4bSmrg      --lt-*) ;;
3994eb411b4bSmrg      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
3995eb411b4bSmrg      esac
3996eb411b4bSmrg      shift
3997eb411b4bSmrg    done ;;
3998eb411b4bSmrg  esac
3999e9fcaa8aSmrg  func_exec_program_core \${1+\"\$@\"}
4000e9fcaa8aSmrg}
4001e9fcaa8aSmrg
4002e9fcaa8aSmrg  # Parse options
4003e9fcaa8aSmrg  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
40041ab64890Smrg
400588de56ccSmrg  # Find the directory that this script lives in.
4006e9fcaa8aSmrg  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
400788de56ccSmrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
40081ab64890Smrg
400988de56ccSmrg  # Follow symbolic links until we get to the real thisdir.
4010e9fcaa8aSmrg  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
401188de56ccSmrg  while test -n \"\$file\"; do
4012e9fcaa8aSmrg    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
40131ab64890Smrg
401488de56ccSmrg    # If there was a directory component, then change thisdir.
401588de56ccSmrg    if test \"x\$destdir\" != \"x\$file\"; then
401688de56ccSmrg      case \"\$destdir\" in
401788de56ccSmrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
401888de56ccSmrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
4019b4ee4795Smrg      esac
402088de56ccSmrg    fi
40211ab64890Smrg
4022e9fcaa8aSmrg    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
4023e9fcaa8aSmrg    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
402488de56ccSmrg  done
40251ab64890Smrg
402688de56ccSmrg  # Usually 'no', except on cygwin/mingw when embedded into
402788de56ccSmrg  # the cwrapper.
4028e9fcaa8aSmrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
402988de56ccSmrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
403088de56ccSmrg    # special case for '.'
403188de56ccSmrg    if test \"\$thisdir\" = \".\"; then
403288de56ccSmrg      thisdir=\`pwd\`
403388de56ccSmrg    fi
403488de56ccSmrg    # remove .libs from thisdir
403588de56ccSmrg    case \"\$thisdir\" in
4036e9fcaa8aSmrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
403788de56ccSmrg    $objdir )   thisdir=. ;;
403888de56ccSmrg    esac
403988de56ccSmrg  fi
404088de56ccSmrg
404188de56ccSmrg  # Try to get the absolute directory name.
404288de56ccSmrg  absdir=\`cd \"\$thisdir\" && pwd\`
404388de56ccSmrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
404488de56ccSmrg"
404588de56ccSmrg
404688de56ccSmrg	if test "$fast_install" = yes; then
404788de56ccSmrg	  $ECHO "\
404888de56ccSmrg  program=lt-'$outputname'$exeext
404988de56ccSmrg  progdir=\"\$thisdir/$objdir\"
405088de56ccSmrg
405188de56ccSmrg  if test ! -f \"\$progdir/\$program\" ||
405288de56ccSmrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
405388de56ccSmrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
405488de56ccSmrg
405588de56ccSmrg    file=\"\$\$-\$program\"
405688de56ccSmrg
405788de56ccSmrg    if test ! -d \"\$progdir\"; then
405888de56ccSmrg      $MKDIR \"\$progdir\"
405988de56ccSmrg    else
406088de56ccSmrg      $RM \"\$progdir/\$file\"
406188de56ccSmrg    fi"
406288de56ccSmrg
406388de56ccSmrg	  $ECHO "\
406488de56ccSmrg
406588de56ccSmrg    # relink executable if necessary
406688de56ccSmrg    if test -n \"\$relink_command\"; then
406788de56ccSmrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
406888de56ccSmrg      else
406988de56ccSmrg	$ECHO \"\$relink_command_output\" >&2
407088de56ccSmrg	$RM \"\$progdir/\$file\"
407188de56ccSmrg	exit 1
4072b4ee4795Smrg      fi
407388de56ccSmrg    fi
40741ab64890Smrg
407588de56ccSmrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
407688de56ccSmrg    { $RM \"\$progdir/\$program\";
407788de56ccSmrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
407888de56ccSmrg    $RM \"\$progdir/\$file\"
407988de56ccSmrg  fi"
408088de56ccSmrg	else
408188de56ccSmrg	  $ECHO "\
408288de56ccSmrg  program='$outputname'
408388de56ccSmrg  progdir=\"\$thisdir/$objdir\"
408488de56ccSmrg"
4085b4ee4795Smrg	fi
40861ab64890Smrg
408788de56ccSmrg	$ECHO "\
40881ab64890Smrg
408988de56ccSmrg  if test -f \"\$progdir/\$program\"; then"
40901ab64890Smrg
4091e9fcaa8aSmrg	# fixup the dll searchpath if we need to.
4092e9fcaa8aSmrg	#
4093e9fcaa8aSmrg	# Fix the DLL searchpath if we need to.  Do this before prepending
4094e9fcaa8aSmrg	# to shlibpath, because on Windows, both are PATH and uninstalled
4095e9fcaa8aSmrg	# libraries must come first.
4096e9fcaa8aSmrg	if test -n "$dllsearchpath"; then
4097e9fcaa8aSmrg	  $ECHO "\
4098e9fcaa8aSmrg    # Add the dll search path components to the executable PATH
4099e9fcaa8aSmrg    PATH=$dllsearchpath:\$PATH
4100e9fcaa8aSmrg"
4101e9fcaa8aSmrg	fi
4102e9fcaa8aSmrg
410388de56ccSmrg	# Export our shlibpath_var if we have one.
410488de56ccSmrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
410588de56ccSmrg	  $ECHO "\
410688de56ccSmrg    # Add our own library path to $shlibpath_var
410788de56ccSmrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
410888de56ccSmrg
410988de56ccSmrg    # Some systems cannot cope with colon-terminated $shlibpath_var
411088de56ccSmrg    # The second colon is a workaround for a bug in BeOS R4 sed
4111e9fcaa8aSmrg    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
41121ab64890Smrg
411388de56ccSmrg    export $shlibpath_var
411488de56ccSmrg"
4115b4ee4795Smrg	fi
41161ab64890Smrg
411788de56ccSmrg	$ECHO "\
411888de56ccSmrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
411988de56ccSmrg      # Run the actual program with our arguments.
4120e9fcaa8aSmrg      func_exec_program \${1+\"\$@\"}
412188de56ccSmrg    fi
412288de56ccSmrg  else
412388de56ccSmrg    # The program doesn't exist.
412488de56ccSmrg    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
412588de56ccSmrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
4126e9fcaa8aSmrg    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
412788de56ccSmrg    exit 1
412888de56ccSmrg  fi
412988de56ccSmrgfi\
413088de56ccSmrg"
413188de56ccSmrg}
41321ab64890Smrg
41331ab64890Smrg
413488de56ccSmrg# func_emit_cwrapperexe_src
413588de56ccSmrg# emit the source code for a wrapper executable on stdout
413688de56ccSmrg# Must ONLY be called from within func_mode_link because
413788de56ccSmrg# it depends on a number of variable set therein.
413888de56ccSmrgfunc_emit_cwrapperexe_src ()
413988de56ccSmrg{
414088de56ccSmrg	cat <<EOF
41411ab64890Smrg
414288de56ccSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
414388de56ccSmrg   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
41441ab64890Smrg
414588de56ccSmrg   The $output program cannot be directly executed until all the libtool
414688de56ccSmrg   libraries that it depends on are installed.
41471ab64890Smrg
414888de56ccSmrg   This wrapper executable should never be moved out of the build directory.
414988de56ccSmrg   If it is, it will not operate correctly.
415088de56ccSmrg*/
415188de56ccSmrgEOF
415288de56ccSmrg	    cat <<"EOF"
4153e9fcaa8aSmrg#ifdef _MSC_VER
4154e9fcaa8aSmrg# define _CRT_SECURE_NO_DEPRECATE 1
4155e9fcaa8aSmrg#endif
415688de56ccSmrg#include <stdio.h>
415788de56ccSmrg#include <stdlib.h>
415888de56ccSmrg#ifdef _MSC_VER
415988de56ccSmrg# include <direct.h>
416088de56ccSmrg# include <process.h>
416188de56ccSmrg# include <io.h>
416288de56ccSmrg#else
416388de56ccSmrg# include <unistd.h>
416488de56ccSmrg# include <stdint.h>
416588de56ccSmrg# ifdef __CYGWIN__
416688de56ccSmrg#  include <io.h>
4167e9fcaa8aSmrg# endif
4168e9fcaa8aSmrg#endif
4169e9fcaa8aSmrg#include <malloc.h>
4170e9fcaa8aSmrg#include <stdarg.h>
4171e9fcaa8aSmrg#include <assert.h>
4172e9fcaa8aSmrg#include <string.h>
4173e9fcaa8aSmrg#include <ctype.h>
4174e9fcaa8aSmrg#include <errno.h>
4175e9fcaa8aSmrg#include <fcntl.h>
4176e9fcaa8aSmrg#include <sys/stat.h>
4177e9fcaa8aSmrg
4178e9fcaa8aSmrg/* declarations of non-ANSI functions */
4179e9fcaa8aSmrg#if defined(__MINGW32__)
4180e9fcaa8aSmrg# ifdef __STRICT_ANSI__
4181e9fcaa8aSmrgint _putenv (const char *);
4182e9fcaa8aSmrg# endif
4183e9fcaa8aSmrg#elif defined(__CYGWIN__)
4184e9fcaa8aSmrg# ifdef __STRICT_ANSI__
418588de56ccSmrgchar *realpath (const char *, char *);
418688de56ccSmrgint putenv (char *);
418788de56ccSmrgint setenv (const char *, const char *, int);
418888de56ccSmrg# endif
4189e9fcaa8aSmrg/* #elif defined (other platforms) ... */
4190e9fcaa8aSmrg#endif
4191e9fcaa8aSmrg
4192e9fcaa8aSmrg/* portability defines, excluding path handling macros */
4193e9fcaa8aSmrg#if defined(_MSC_VER)
4194e9fcaa8aSmrg# define setmode _setmode
4195e9fcaa8aSmrg# define stat    _stat
4196e9fcaa8aSmrg# define chmod   _chmod
4197e9fcaa8aSmrg# define getcwd  _getcwd
4198e9fcaa8aSmrg# define putenv  _putenv
4199e9fcaa8aSmrg# define S_IXUSR _S_IEXEC
4200e9fcaa8aSmrg# ifndef _INTPTR_T_DEFINED
4201e9fcaa8aSmrg#  define _INTPTR_T_DEFINED
4202e9fcaa8aSmrg#  define intptr_t int
4203e9fcaa8aSmrg# endif
4204e9fcaa8aSmrg#elif defined(__MINGW32__)
4205e9fcaa8aSmrg# define setmode _setmode
4206e9fcaa8aSmrg# define stat    _stat
4207e9fcaa8aSmrg# define chmod   _chmod
4208e9fcaa8aSmrg# define getcwd  _getcwd
4209e9fcaa8aSmrg# define putenv  _putenv
4210e9fcaa8aSmrg#elif defined(__CYGWIN__)
4211e9fcaa8aSmrg# define HAVE_SETENV
4212e9fcaa8aSmrg# define FOPEN_WB "wb"
4213e9fcaa8aSmrg/* #elif defined (other platforms) ... */
421488de56ccSmrg#endif
42151ab64890Smrg
421688de56ccSmrg#if defined(PATH_MAX)
421788de56ccSmrg# define LT_PATHMAX PATH_MAX
421888de56ccSmrg#elif defined(MAXPATHLEN)
421988de56ccSmrg# define LT_PATHMAX MAXPATHLEN
422088de56ccSmrg#else
422188de56ccSmrg# define LT_PATHMAX 1024
422288de56ccSmrg#endif
42231ab64890Smrg
422488de56ccSmrg#ifndef S_IXOTH
422588de56ccSmrg# define S_IXOTH 0
422688de56ccSmrg#endif
422788de56ccSmrg#ifndef S_IXGRP
422888de56ccSmrg# define S_IXGRP 0
422988de56ccSmrg#endif
42301ab64890Smrg
4231e9fcaa8aSmrg/* path handling portability macros */
423288de56ccSmrg#ifndef DIR_SEPARATOR
423388de56ccSmrg# define DIR_SEPARATOR '/'
423488de56ccSmrg# define PATH_SEPARATOR ':'
423588de56ccSmrg#endif
42361ab64890Smrg
423788de56ccSmrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
423888de56ccSmrg  defined (__OS2__)
423988de56ccSmrg# define HAVE_DOS_BASED_FILE_SYSTEM
424088de56ccSmrg# define FOPEN_WB "wb"
424188de56ccSmrg# ifndef DIR_SEPARATOR_2
424288de56ccSmrg#  define DIR_SEPARATOR_2 '\\'
424388de56ccSmrg# endif
424488de56ccSmrg# ifndef PATH_SEPARATOR_2
424588de56ccSmrg#  define PATH_SEPARATOR_2 ';'
424688de56ccSmrg# endif
424788de56ccSmrg#endif
42481ab64890Smrg
424988de56ccSmrg#ifndef DIR_SEPARATOR_2
425088de56ccSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
425188de56ccSmrg#else /* DIR_SEPARATOR_2 */
425288de56ccSmrg# define IS_DIR_SEPARATOR(ch) \
425388de56ccSmrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
425488de56ccSmrg#endif /* DIR_SEPARATOR_2 */
42551ab64890Smrg
425688de56ccSmrg#ifndef PATH_SEPARATOR_2
425788de56ccSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
425888de56ccSmrg#else /* PATH_SEPARATOR_2 */
425988de56ccSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
426088de56ccSmrg#endif /* PATH_SEPARATOR_2 */
42611ab64890Smrg
426288de56ccSmrg#ifndef FOPEN_WB
426388de56ccSmrg# define FOPEN_WB "w"
426488de56ccSmrg#endif
426588de56ccSmrg#ifndef _O_BINARY
426688de56ccSmrg# define _O_BINARY 0
426788de56ccSmrg#endif
42681ab64890Smrg
426988de56ccSmrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
427088de56ccSmrg#define XFREE(stale) do { \
427188de56ccSmrg  if (stale) { free ((void *) stale); stale = 0; } \
427288de56ccSmrg} while (0)
42731ab64890Smrg
4274e9fcaa8aSmrg#if defined(LT_DEBUGWRAPPER)
4275e9fcaa8aSmrgstatic int lt_debug = 1;
427688de56ccSmrg#else
4277e9fcaa8aSmrgstatic int lt_debug = 0;
427888de56ccSmrg#endif
42791ab64890Smrg
4280e9fcaa8aSmrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
42811ab64890Smrg
428288de56ccSmrgvoid *xmalloc (size_t num);
428388de56ccSmrgchar *xstrdup (const char *string);
428488de56ccSmrgconst char *base_name (const char *name);
428588de56ccSmrgchar *find_executable (const char *wrapper);
428688de56ccSmrgchar *chase_symlinks (const char *pathspec);
428788de56ccSmrgint make_executable (const char *path);
428888de56ccSmrgint check_executable (const char *path);
428988de56ccSmrgchar *strendzap (char *str, const char *pat);
4290e9fcaa8aSmrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
4291e9fcaa8aSmrgvoid lt_fatal (const char *file, int line, const char *message, ...);
4292e9fcaa8aSmrgstatic const char *nonnull (const char *s);
4293e9fcaa8aSmrgstatic const char *nonempty (const char *s);
429488de56ccSmrgvoid lt_setenv (const char *name, const char *value);
429588de56ccSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
429688de56ccSmrgvoid lt_update_exe_path (const char *name, const char *value);
429788de56ccSmrgvoid lt_update_lib_path (const char *name, const char *value);
4298e9fcaa8aSmrgchar **prepare_spawn (char **argv);
4299e9fcaa8aSmrgvoid lt_dump_script (FILE *f);
430088de56ccSmrgEOF
430188de56ccSmrg
430288de56ccSmrg	    cat <<EOF
4303e9fcaa8aSmrgvolatile const char * MAGIC_EXE = "$magic_exe";
430488de56ccSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
430588de56ccSmrgEOF
43061ab64890Smrg
430788de56ccSmrg	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4308e9fcaa8aSmrg              func_to_host_path "$temp_rpath"
430988de56ccSmrg	      cat <<EOF
4310e9fcaa8aSmrgconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
431188de56ccSmrgEOF
431288de56ccSmrg	    else
431388de56ccSmrg	      cat <<"EOF"
431488de56ccSmrgconst char * LIB_PATH_VALUE   = "";
431588de56ccSmrgEOF
4316b4ee4795Smrg	    fi
43171ab64890Smrg
431888de56ccSmrg	    if test -n "$dllsearchpath"; then
4319e9fcaa8aSmrg              func_to_host_path "$dllsearchpath:"
432088de56ccSmrg	      cat <<EOF
432188de56ccSmrgconst char * EXE_PATH_VARNAME = "PATH";
4322e9fcaa8aSmrgconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
4323b4ee4795SmrgEOF
4324b4ee4795Smrg	    else
432588de56ccSmrg	      cat <<"EOF"
432688de56ccSmrgconst char * EXE_PATH_VARNAME = "";
432788de56ccSmrgconst char * EXE_PATH_VALUE   = "";
432888de56ccSmrgEOF
4329b4ee4795Smrg	    fi
433088de56ccSmrg
433188de56ccSmrg	    if test "$fast_install" = yes; then
433288de56ccSmrg	      cat <<EOF
433388de56ccSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
433488de56ccSmrgEOF
4335b4ee4795Smrg	    else
433688de56ccSmrg	      cat <<EOF
433788de56ccSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
433888de56ccSmrgEOF
4339b4ee4795Smrg	    fi
43401ab64890Smrg
43411ab64890Smrg
434288de56ccSmrg	    cat <<"EOF"
43431ab64890Smrg
434488de56ccSmrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
43451ab64890Smrg
434688de56ccSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
434788de56ccSmrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
4348e9fcaa8aSmrgstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
43491ab64890Smrg
435088de56ccSmrgint
435188de56ccSmrgmain (int argc, char *argv[])
435288de56ccSmrg{
435388de56ccSmrg  char **newargz;
435488de56ccSmrg  int  newargc;
435588de56ccSmrg  char *tmp_pathspec;
435688de56ccSmrg  char *actual_cwrapper_path;
435788de56ccSmrg  char *actual_cwrapper_name;
435888de56ccSmrg  char *target_name;
435988de56ccSmrg  char *lt_argv_zero;
436088de56ccSmrg  intptr_t rval = 127;
43611ab64890Smrg
436288de56ccSmrg  int i;
43631ab64890Smrg
436488de56ccSmrg  program_name = (char *) xstrdup (base_name (argv[0]));
4365e9fcaa8aSmrg  newargz = XMALLOC (char *, argc + 1);
43661ab64890Smrg
4367e9fcaa8aSmrg  /* very simple arg parsing; don't want to rely on getopt
4368e9fcaa8aSmrg   * also, copy all non cwrapper options to newargz, except
4369e9fcaa8aSmrg   * argz[0], which is handled differently
4370e9fcaa8aSmrg   */
4371e9fcaa8aSmrg  newargc=0;
437288de56ccSmrg  for (i = 1; i < argc; i++)
437388de56ccSmrg    {
437488de56ccSmrg      if (strcmp (argv[i], dumpscript_opt) == 0)
437588de56ccSmrg	{
437688de56ccSmrgEOF
437788de56ccSmrg	    case "$host" in
437888de56ccSmrg	      *mingw* | *cygwin* )
437988de56ccSmrg		# make stdout use "unix" line endings
438088de56ccSmrg		echo "          setmode(1,_O_BINARY);"
438188de56ccSmrg		;;
438288de56ccSmrg	      esac
43831ab64890Smrg
438488de56ccSmrg	    cat <<"EOF"
4385e9fcaa8aSmrg	  lt_dump_script (stdout);
438688de56ccSmrg	  return 0;
438788de56ccSmrg	}
4388e9fcaa8aSmrg      if (strcmp (argv[i], debug_opt) == 0)
4389e9fcaa8aSmrg	{
4390e9fcaa8aSmrg          lt_debug = 1;
4391e9fcaa8aSmrg          continue;
4392e9fcaa8aSmrg	}
4393e9fcaa8aSmrg      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
4394e9fcaa8aSmrg        {
4395e9fcaa8aSmrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
4396e9fcaa8aSmrg             namespace, but it is not one of the ones we know about and
4397e9fcaa8aSmrg             have already dealt with, above (inluding dump-script), then
4398e9fcaa8aSmrg             report an error. Otherwise, targets might begin to believe
4399e9fcaa8aSmrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
4400e9fcaa8aSmrg             namespace. The first time any user complains about this, we'll
4401e9fcaa8aSmrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
4402e9fcaa8aSmrg             or a configure.ac-settable value.
4403e9fcaa8aSmrg           */
4404e9fcaa8aSmrg          lt_fatal (__FILE__, __LINE__,
4405e9fcaa8aSmrg		    "unrecognized %s option: '%s'",
4406e9fcaa8aSmrg                    ltwrapper_option_prefix, argv[i]);
4407e9fcaa8aSmrg        }
4408e9fcaa8aSmrg      /* otherwise ... */
4409e9fcaa8aSmrg      newargz[++newargc] = xstrdup (argv[i]);
441088de56ccSmrg    }
4411e9fcaa8aSmrg  newargz[++newargc] = NULL;
4412e9fcaa8aSmrg
4413e9fcaa8aSmrgEOF
4414e9fcaa8aSmrg	    cat <<EOF
4415e9fcaa8aSmrg  /* The GNU banner must be the first non-error debug message */
4416e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
4417e9fcaa8aSmrgEOF
4418e9fcaa8aSmrg	    cat <<"EOF"
4419e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
4420e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
44211ab64890Smrg
442288de56ccSmrg  tmp_pathspec = find_executable (argv[0]);
442388de56ccSmrg  if (tmp_pathspec == NULL)
4424e9fcaa8aSmrg    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
4425e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__,
4426e9fcaa8aSmrg                  "(main) found exe (before symlink chase) at: %s\n",
4427e9fcaa8aSmrg		  tmp_pathspec);
442888de56ccSmrg
442988de56ccSmrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
4430e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__,
4431e9fcaa8aSmrg                  "(main) found exe (after symlink chase) at: %s\n",
4432e9fcaa8aSmrg		  actual_cwrapper_path);
443388de56ccSmrg  XFREE (tmp_pathspec);
443488de56ccSmrg
4435e9fcaa8aSmrg  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
443688de56ccSmrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
443788de56ccSmrg
443888de56ccSmrg  /* wrapper name transforms */
443988de56ccSmrg  strendzap (actual_cwrapper_name, ".exe");
444088de56ccSmrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
444188de56ccSmrg  XFREE (actual_cwrapper_name);
444288de56ccSmrg  actual_cwrapper_name = tmp_pathspec;
444388de56ccSmrg  tmp_pathspec = 0;
444488de56ccSmrg
444588de56ccSmrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
444688de56ccSmrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
444788de56ccSmrg  strendzap (target_name, ".exe");
444888de56ccSmrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
444988de56ccSmrg  XFREE (target_name);
445088de56ccSmrg  target_name = tmp_pathspec;
445188de56ccSmrg  tmp_pathspec = 0;
445288de56ccSmrg
4453e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__,
4454e9fcaa8aSmrg		  "(main) libtool target name: %s\n",
4455e9fcaa8aSmrg		  target_name);
445688de56ccSmrgEOF
44571ab64890Smrg
445888de56ccSmrg	    cat <<EOF
445988de56ccSmrg  newargz[0] =
446088de56ccSmrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
446188de56ccSmrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
446288de56ccSmrg  strcpy (newargz[0], actual_cwrapper_path);
446388de56ccSmrg  strcat (newargz[0], "$objdir");
446488de56ccSmrg  strcat (newargz[0], "/");
446588de56ccSmrgEOF
44661ab64890Smrg
446788de56ccSmrg	    cat <<"EOF"
446888de56ccSmrg  /* stop here, and copy so we don't have to do this twice */
446988de56ccSmrg  tmp_pathspec = xstrdup (newargz[0]);
44701ab64890Smrg
447188de56ccSmrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
447288de56ccSmrg  strcat (newargz[0], actual_cwrapper_name);
44731ab64890Smrg
447488de56ccSmrg  /* DO want the lt- prefix here if it exists, so use target_name */
447588de56ccSmrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
447688de56ccSmrg  XFREE (tmp_pathspec);
447788de56ccSmrg  tmp_pathspec = NULL;
447888de56ccSmrgEOF
44791ab64890Smrg
448088de56ccSmrg	    case $host_os in
448188de56ccSmrg	      mingw*)
448288de56ccSmrg	    cat <<"EOF"
448388de56ccSmrg  {
448488de56ccSmrg    char* p;
448588de56ccSmrg    while ((p = strchr (newargz[0], '\\')) != NULL)
448688de56ccSmrg      {
448788de56ccSmrg	*p = '/';
448888de56ccSmrg      }
448988de56ccSmrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
449088de56ccSmrg      {
449188de56ccSmrg	*p = '/';
449288de56ccSmrg      }
449388de56ccSmrg  }
449488de56ccSmrgEOF
449588de56ccSmrg	    ;;
449688de56ccSmrg	    esac
44971ab64890Smrg
449888de56ccSmrg	    cat <<"EOF"
449988de56ccSmrg  XFREE (target_name);
450088de56ccSmrg  XFREE (actual_cwrapper_path);
450188de56ccSmrg  XFREE (actual_cwrapper_name);
45021ab64890Smrg
450388de56ccSmrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
450488de56ccSmrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
4505e9fcaa8aSmrg  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
4506e9fcaa8aSmrg     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
4507e9fcaa8aSmrg     because on Windows, both *_VARNAMEs are PATH but uninstalled
4508e9fcaa8aSmrg     libraries must come first. */
450988de56ccSmrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
4510e9fcaa8aSmrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
45111ab64890Smrg
4512e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
4513e9fcaa8aSmrg		  nonnull (lt_argv_zero));
451488de56ccSmrg  for (i = 0; i < newargc; i++)
451588de56ccSmrg    {
4516e9fcaa8aSmrg      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
4517e9fcaa8aSmrg		      i, nonnull (newargz[i]));
451888de56ccSmrg    }
45191ab64890Smrg
452088de56ccSmrgEOF
45211ab64890Smrg
452288de56ccSmrg	    case $host_os in
452388de56ccSmrg	      mingw*)
452488de56ccSmrg		cat <<"EOF"
452588de56ccSmrg  /* execv doesn't actually work on mingw as expected on unix */
4526e9fcaa8aSmrg  newargz = prepare_spawn (newargz);
452788de56ccSmrg  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
452888de56ccSmrg  if (rval == -1)
452988de56ccSmrg    {
453088de56ccSmrg      /* failed to start process */
4531e9fcaa8aSmrg      lt_debugprintf (__FILE__, __LINE__,
4532e9fcaa8aSmrg		      "(main) failed to launch target \"%s\": %s\n",
4533e9fcaa8aSmrg		      lt_argv_zero, nonnull (strerror (errno)));
453488de56ccSmrg      return 127;
453588de56ccSmrg    }
453688de56ccSmrg  return rval;
453788de56ccSmrgEOF
453888de56ccSmrg		;;
453988de56ccSmrg	      *)
454088de56ccSmrg		cat <<"EOF"
454188de56ccSmrg  execv (lt_argv_zero, newargz);
454288de56ccSmrg  return rval; /* =127, but avoids unused variable warning */
454388de56ccSmrgEOF
454488de56ccSmrg		;;
454588de56ccSmrg	    esac
45461ab64890Smrg
454788de56ccSmrg	    cat <<"EOF"
454888de56ccSmrg}
45491ab64890Smrg
455088de56ccSmrgvoid *
455188de56ccSmrgxmalloc (size_t num)
455288de56ccSmrg{
455388de56ccSmrg  void *p = (void *) malloc (num);
455488de56ccSmrg  if (!p)
4555e9fcaa8aSmrg    lt_fatal (__FILE__, __LINE__, "memory exhausted");
45561ab64890Smrg
455788de56ccSmrg  return p;
455888de56ccSmrg}
45591ab64890Smrg
456088de56ccSmrgchar *
456188de56ccSmrgxstrdup (const char *string)
456288de56ccSmrg{
456388de56ccSmrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
456488de56ccSmrg			  string) : NULL;
456588de56ccSmrg}
45661ab64890Smrg
456788de56ccSmrgconst char *
456888de56ccSmrgbase_name (const char *name)
456988de56ccSmrg{
457088de56ccSmrg  const char *base;
4571b4ee4795Smrg
457288de56ccSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
457388de56ccSmrg  /* Skip over the disk name in MSDOS pathnames. */
457488de56ccSmrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
457588de56ccSmrg    name += 2;
457688de56ccSmrg#endif
4577b4ee4795Smrg
457888de56ccSmrg  for (base = name; *name; name++)
457988de56ccSmrg    if (IS_DIR_SEPARATOR (*name))
458088de56ccSmrg      base = name + 1;
458188de56ccSmrg  return base;
458288de56ccSmrg}
4583b4ee4795Smrg
458488de56ccSmrgint
458588de56ccSmrgcheck_executable (const char *path)
458688de56ccSmrg{
458788de56ccSmrg  struct stat st;
4588b4ee4795Smrg
4589e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
4590e9fcaa8aSmrg                  nonempty (path));
459188de56ccSmrg  if ((!path) || (!*path))
459288de56ccSmrg    return 0;
4593b4ee4795Smrg
459488de56ccSmrg  if ((stat (path, &st) >= 0)
459588de56ccSmrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
459688de56ccSmrg    return 1;
459788de56ccSmrg  else
459888de56ccSmrg    return 0;
459988de56ccSmrg}
46001ab64890Smrg
460188de56ccSmrgint
460288de56ccSmrgmake_executable (const char *path)
460388de56ccSmrg{
460488de56ccSmrg  int rval = 0;
460588de56ccSmrg  struct stat st;
46061ab64890Smrg
4607e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
4608e9fcaa8aSmrg                  nonempty (path));
460988de56ccSmrg  if ((!path) || (!*path))
461088de56ccSmrg    return 0;
46111ab64890Smrg
461288de56ccSmrg  if (stat (path, &st) >= 0)
461388de56ccSmrg    {
461488de56ccSmrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
461588de56ccSmrg    }
461688de56ccSmrg  return rval;
461788de56ccSmrg}
4618b4ee4795Smrg
461988de56ccSmrg/* Searches for the full path of the wrapper.  Returns
462088de56ccSmrg   newly allocated full path name if found, NULL otherwise
462188de56ccSmrg   Does not chase symlinks, even on platforms that support them.
462288de56ccSmrg*/
462388de56ccSmrgchar *
462488de56ccSmrgfind_executable (const char *wrapper)
462588de56ccSmrg{
462688de56ccSmrg  int has_slash = 0;
462788de56ccSmrg  const char *p;
462888de56ccSmrg  const char *p_next;
462988de56ccSmrg  /* static buffer for getcwd */
463088de56ccSmrg  char tmp[LT_PATHMAX + 1];
463188de56ccSmrg  int tmp_len;
463288de56ccSmrg  char *concat_name;
4633b4ee4795Smrg
4634e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
4635e9fcaa8aSmrg                  nonempty (wrapper));
4636b4ee4795Smrg
463788de56ccSmrg  if ((wrapper == NULL) || (*wrapper == '\0'))
463888de56ccSmrg    return NULL;
4639b4ee4795Smrg
464088de56ccSmrg  /* Absolute path? */
464188de56ccSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
464288de56ccSmrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
464388de56ccSmrg    {
464488de56ccSmrg      concat_name = xstrdup (wrapper);
464588de56ccSmrg      if (check_executable (concat_name))
464688de56ccSmrg	return concat_name;
464788de56ccSmrg      XFREE (concat_name);
464888de56ccSmrg    }
464988de56ccSmrg  else
465088de56ccSmrg    {
465188de56ccSmrg#endif
465288de56ccSmrg      if (IS_DIR_SEPARATOR (wrapper[0]))
465388de56ccSmrg	{
465488de56ccSmrg	  concat_name = xstrdup (wrapper);
465588de56ccSmrg	  if (check_executable (concat_name))
465688de56ccSmrg	    return concat_name;
465788de56ccSmrg	  XFREE (concat_name);
465888de56ccSmrg	}
465988de56ccSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
466088de56ccSmrg    }
466188de56ccSmrg#endif
46621ab64890Smrg
466388de56ccSmrg  for (p = wrapper; *p; p++)
466488de56ccSmrg    if (*p == '/')
466588de56ccSmrg      {
466688de56ccSmrg	has_slash = 1;
466788de56ccSmrg	break;
466888de56ccSmrg      }
466988de56ccSmrg  if (!has_slash)
467088de56ccSmrg    {
467188de56ccSmrg      /* no slashes; search PATH */
467288de56ccSmrg      const char *path = getenv ("PATH");
467388de56ccSmrg      if (path != NULL)
467488de56ccSmrg	{
467588de56ccSmrg	  for (p = path; *p; p = p_next)
467688de56ccSmrg	    {
467788de56ccSmrg	      const char *q;
467888de56ccSmrg	      size_t p_len;
467988de56ccSmrg	      for (q = p; *q; q++)
468088de56ccSmrg		if (IS_PATH_SEPARATOR (*q))
468188de56ccSmrg		  break;
468288de56ccSmrg	      p_len = q - p;
468388de56ccSmrg	      p_next = (*q == '\0' ? q : q + 1);
468488de56ccSmrg	      if (p_len == 0)
468588de56ccSmrg		{
468688de56ccSmrg		  /* empty path: current directory */
468788de56ccSmrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
4688e9fcaa8aSmrg		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
4689e9fcaa8aSmrg                              nonnull (strerror (errno)));
469088de56ccSmrg		  tmp_len = strlen (tmp);
469188de56ccSmrg		  concat_name =
469288de56ccSmrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
469388de56ccSmrg		  memcpy (concat_name, tmp, tmp_len);
469488de56ccSmrg		  concat_name[tmp_len] = '/';
469588de56ccSmrg		  strcpy (concat_name + tmp_len + 1, wrapper);
469688de56ccSmrg		}
469788de56ccSmrg	      else
469888de56ccSmrg		{
469988de56ccSmrg		  concat_name =
470088de56ccSmrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
470188de56ccSmrg		  memcpy (concat_name, p, p_len);
470288de56ccSmrg		  concat_name[p_len] = '/';
470388de56ccSmrg		  strcpy (concat_name + p_len + 1, wrapper);
470488de56ccSmrg		}
470588de56ccSmrg	      if (check_executable (concat_name))
470688de56ccSmrg		return concat_name;
470788de56ccSmrg	      XFREE (concat_name);
470888de56ccSmrg	    }
470988de56ccSmrg	}
471088de56ccSmrg      /* not found in PATH; assume curdir */
471188de56ccSmrg    }
471288de56ccSmrg  /* Relative path | not found in path: prepend cwd */
471388de56ccSmrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
4714e9fcaa8aSmrg    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
4715e9fcaa8aSmrg              nonnull (strerror (errno)));
471688de56ccSmrg  tmp_len = strlen (tmp);
471788de56ccSmrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
471888de56ccSmrg  memcpy (concat_name, tmp, tmp_len);
471988de56ccSmrg  concat_name[tmp_len] = '/';
472088de56ccSmrg  strcpy (concat_name + tmp_len + 1, wrapper);
47211ab64890Smrg
472288de56ccSmrg  if (check_executable (concat_name))
472388de56ccSmrg    return concat_name;
472488de56ccSmrg  XFREE (concat_name);
472588de56ccSmrg  return NULL;
472688de56ccSmrg}
47271ab64890Smrg
472888de56ccSmrgchar *
472988de56ccSmrgchase_symlinks (const char *pathspec)
473088de56ccSmrg{
473188de56ccSmrg#ifndef S_ISLNK
473288de56ccSmrg  return xstrdup (pathspec);
473388de56ccSmrg#else
473488de56ccSmrg  char buf[LT_PATHMAX];
473588de56ccSmrg  struct stat s;
473688de56ccSmrg  char *tmp_pathspec = xstrdup (pathspec);
473788de56ccSmrg  char *p;
473888de56ccSmrg  int has_symlinks = 0;
473988de56ccSmrg  while (strlen (tmp_pathspec) && !has_symlinks)
474088de56ccSmrg    {
4741e9fcaa8aSmrg      lt_debugprintf (__FILE__, __LINE__,
4742e9fcaa8aSmrg		      "checking path component for symlinks: %s\n",
4743e9fcaa8aSmrg		      tmp_pathspec);
474488de56ccSmrg      if (lstat (tmp_pathspec, &s) == 0)
474588de56ccSmrg	{
474688de56ccSmrg	  if (S_ISLNK (s.st_mode) != 0)
474788de56ccSmrg	    {
474888de56ccSmrg	      has_symlinks = 1;
474988de56ccSmrg	      break;
475088de56ccSmrg	    }
47511ab64890Smrg
475288de56ccSmrg	  /* search backwards for last DIR_SEPARATOR */
475388de56ccSmrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
475488de56ccSmrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
475588de56ccSmrg	    p--;
475688de56ccSmrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
475788de56ccSmrg	    {
475888de56ccSmrg	      /* no more DIR_SEPARATORS left */
475988de56ccSmrg	      break;
476088de56ccSmrg	    }
476188de56ccSmrg	  *p = '\0';
476288de56ccSmrg	}
476388de56ccSmrg      else
476488de56ccSmrg	{
4765e9fcaa8aSmrg	  lt_fatal (__FILE__, __LINE__,
4766e9fcaa8aSmrg		    "error accessing file \"%s\": %s",
4767e9fcaa8aSmrg		    tmp_pathspec, nonnull (strerror (errno)));
476888de56ccSmrg	}
476988de56ccSmrg    }
477088de56ccSmrg  XFREE (tmp_pathspec);
47711ab64890Smrg
477288de56ccSmrg  if (!has_symlinks)
477388de56ccSmrg    {
477488de56ccSmrg      return xstrdup (pathspec);
477588de56ccSmrg    }
47761ab64890Smrg
477788de56ccSmrg  tmp_pathspec = realpath (pathspec, buf);
477888de56ccSmrg  if (tmp_pathspec == 0)
477988de56ccSmrg    {
4780e9fcaa8aSmrg      lt_fatal (__FILE__, __LINE__,
4781e9fcaa8aSmrg		"could not follow symlinks for %s", pathspec);
478288de56ccSmrg    }
478388de56ccSmrg  return xstrdup (tmp_pathspec);
478488de56ccSmrg#endif
478588de56ccSmrg}
47861ab64890Smrg
478788de56ccSmrgchar *
478888de56ccSmrgstrendzap (char *str, const char *pat)
478988de56ccSmrg{
479088de56ccSmrg  size_t len, patlen;
47911ab64890Smrg
479288de56ccSmrg  assert (str != NULL);
479388de56ccSmrg  assert (pat != NULL);
47941ab64890Smrg
479588de56ccSmrg  len = strlen (str);
479688de56ccSmrg  patlen = strlen (pat);
47971ab64890Smrg
479888de56ccSmrg  if (patlen <= len)
479988de56ccSmrg    {
480088de56ccSmrg      str += len - patlen;
480188de56ccSmrg      if (strcmp (str, pat) == 0)
480288de56ccSmrg	*str = '\0';
480388de56ccSmrg    }
480488de56ccSmrg  return str;
480588de56ccSmrg}
48061ab64890Smrg
4807e9fcaa8aSmrgvoid
4808e9fcaa8aSmrglt_debugprintf (const char *file, int line, const char *fmt, ...)
4809e9fcaa8aSmrg{
4810e9fcaa8aSmrg  va_list args;
4811e9fcaa8aSmrg  if (lt_debug)
4812e9fcaa8aSmrg    {
4813e9fcaa8aSmrg      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
4814e9fcaa8aSmrg      va_start (args, fmt);
4815e9fcaa8aSmrg      (void) vfprintf (stderr, fmt, args);
4816e9fcaa8aSmrg      va_end (args);
4817e9fcaa8aSmrg    }
4818e9fcaa8aSmrg}
4819e9fcaa8aSmrg
482088de56ccSmrgstatic void
4821e9fcaa8aSmrglt_error_core (int exit_status, const char *file,
4822e9fcaa8aSmrg	       int line, const char *mode,
482388de56ccSmrg	       const char *message, va_list ap)
482488de56ccSmrg{
4825e9fcaa8aSmrg  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
482688de56ccSmrg  vfprintf (stderr, message, ap);
482788de56ccSmrg  fprintf (stderr, ".\n");
48281ab64890Smrg
482988de56ccSmrg  if (exit_status >= 0)
483088de56ccSmrg    exit (exit_status);
483188de56ccSmrg}
48321ab64890Smrg
483388de56ccSmrgvoid
4834e9fcaa8aSmrglt_fatal (const char *file, int line, const char *message, ...)
483588de56ccSmrg{
483688de56ccSmrg  va_list ap;
483788de56ccSmrg  va_start (ap, message);
4838e9fcaa8aSmrg  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
483988de56ccSmrg  va_end (ap);
484088de56ccSmrg}
48412e9c7c8cSmrg
4842e9fcaa8aSmrgstatic const char *
4843e9fcaa8aSmrgnonnull (const char *s)
4844e9fcaa8aSmrg{
4845e9fcaa8aSmrg  return s ? s : "(null)";
4846e9fcaa8aSmrg}
4847e9fcaa8aSmrg
4848e9fcaa8aSmrgstatic const char *
4849e9fcaa8aSmrgnonempty (const char *s)
4850e9fcaa8aSmrg{
4851e9fcaa8aSmrg  return (s && !*s) ? "(empty)" : nonnull (s);
4852e9fcaa8aSmrg}
4853e9fcaa8aSmrg
485488de56ccSmrgvoid
485588de56ccSmrglt_setenv (const char *name, const char *value)
485688de56ccSmrg{
4857e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__,
4858e9fcaa8aSmrg		  "(lt_setenv) setting '%s' to '%s'\n",
4859e9fcaa8aSmrg                  nonnull (name), nonnull (value));
486088de56ccSmrg  {
486188de56ccSmrg#ifdef HAVE_SETENV
486288de56ccSmrg    /* always make a copy, for consistency with !HAVE_SETENV */
486388de56ccSmrg    char *str = xstrdup (value);
486488de56ccSmrg    setenv (name, str, 1);
486588de56ccSmrg#else
486688de56ccSmrg    int len = strlen (name) + 1 + strlen (value) + 1;
486788de56ccSmrg    char *str = XMALLOC (char, len);
486888de56ccSmrg    sprintf (str, "%s=%s", name, value);
486988de56ccSmrg    if (putenv (str) != EXIT_SUCCESS)
487088de56ccSmrg      {
487188de56ccSmrg        XFREE (str);
487288de56ccSmrg      }
487388de56ccSmrg#endif
487488de56ccSmrg  }
487588de56ccSmrg}
48761ab64890Smrg
487788de56ccSmrgchar *
487888de56ccSmrglt_extend_str (const char *orig_value, const char *add, int to_end)
487988de56ccSmrg{
488088de56ccSmrg  char *new_value;
488188de56ccSmrg  if (orig_value && *orig_value)
488288de56ccSmrg    {
488388de56ccSmrg      int orig_value_len = strlen (orig_value);
488488de56ccSmrg      int add_len = strlen (add);
488588de56ccSmrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
488688de56ccSmrg      if (to_end)
488788de56ccSmrg        {
488888de56ccSmrg          strcpy (new_value, orig_value);
488988de56ccSmrg          strcpy (new_value + orig_value_len, add);
489088de56ccSmrg        }
489188de56ccSmrg      else
489288de56ccSmrg        {
489388de56ccSmrg          strcpy (new_value, add);
489488de56ccSmrg          strcpy (new_value + add_len, orig_value);
489588de56ccSmrg        }
489688de56ccSmrg    }
489788de56ccSmrg  else
489888de56ccSmrg    {
489988de56ccSmrg      new_value = xstrdup (add);
490088de56ccSmrg    }
490188de56ccSmrg  return new_value;
490288de56ccSmrg}
49031ab64890Smrg
490488de56ccSmrgvoid
490588de56ccSmrglt_update_exe_path (const char *name, const char *value)
490688de56ccSmrg{
4907e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__,
4908e9fcaa8aSmrg		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
4909e9fcaa8aSmrg                  nonnull (name), nonnull (value));
49101ab64890Smrg
491188de56ccSmrg  if (name && *name && value && *value)
491288de56ccSmrg    {
491388de56ccSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
491488de56ccSmrg      /* some systems can't cope with a ':'-terminated path #' */
491588de56ccSmrg      int len = strlen (new_value);
491688de56ccSmrg      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
491788de56ccSmrg        {
491888de56ccSmrg          new_value[len-1] = '\0';
491988de56ccSmrg        }
492088de56ccSmrg      lt_setenv (name, new_value);
492188de56ccSmrg      XFREE (new_value);
492288de56ccSmrg    }
492388de56ccSmrg}
49241ab64890Smrg
492588de56ccSmrgvoid
492688de56ccSmrglt_update_lib_path (const char *name, const char *value)
492788de56ccSmrg{
4928e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__,
4929e9fcaa8aSmrg		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
4930e9fcaa8aSmrg                  nonnull (name), nonnull (value));
49311ab64890Smrg
493288de56ccSmrg  if (name && *name && value && *value)
493388de56ccSmrg    {
493488de56ccSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
493588de56ccSmrg      lt_setenv (name, new_value);
493688de56ccSmrg      XFREE (new_value);
493788de56ccSmrg    }
493888de56ccSmrg}
49391ab64890Smrg
4940e9fcaa8aSmrgEOF
4941e9fcaa8aSmrg	    case $host_os in
4942e9fcaa8aSmrg	      mingw*)
4943e9fcaa8aSmrg		cat <<"EOF"
4944e9fcaa8aSmrg
4945e9fcaa8aSmrg/* Prepares an argument vector before calling spawn().
4946e9fcaa8aSmrg   Note that spawn() does not by itself call the command interpreter
4947e9fcaa8aSmrg     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
4948e9fcaa8aSmrg      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
4949e9fcaa8aSmrg         GetVersionEx(&v);
4950e9fcaa8aSmrg         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
4951e9fcaa8aSmrg      }) ? "cmd.exe" : "command.com").
4952e9fcaa8aSmrg   Instead it simply concatenates the arguments, separated by ' ', and calls
4953e9fcaa8aSmrg   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
4954e9fcaa8aSmrg   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
4955e9fcaa8aSmrg   special way:
4956e9fcaa8aSmrg   - Space and tab are interpreted as delimiters. They are not treated as
4957e9fcaa8aSmrg     delimiters if they are surrounded by double quotes: "...".
4958e9fcaa8aSmrg   - Unescaped double quotes are removed from the input. Their only effect is
4959e9fcaa8aSmrg     that within double quotes, space and tab are treated like normal
4960e9fcaa8aSmrg     characters.
4961e9fcaa8aSmrg   - Backslashes not followed by double quotes are not special.
4962e9fcaa8aSmrg   - But 2*n+1 backslashes followed by a double quote become
4963e9fcaa8aSmrg     n backslashes followed by a double quote (n >= 0):
4964e9fcaa8aSmrg       \" -> "
4965e9fcaa8aSmrg       \\\" -> \"
4966e9fcaa8aSmrg       \\\\\" -> \\"
4967e9fcaa8aSmrg */
4968e9fcaa8aSmrg#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"
4969e9fcaa8aSmrg#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"
4970e9fcaa8aSmrgchar **
4971e9fcaa8aSmrgprepare_spawn (char **argv)
4972e9fcaa8aSmrg{
4973e9fcaa8aSmrg  size_t argc;
4974e9fcaa8aSmrg  char **new_argv;
4975e9fcaa8aSmrg  size_t i;
4976e9fcaa8aSmrg
4977e9fcaa8aSmrg  /* Count number of arguments.  */
4978e9fcaa8aSmrg  for (argc = 0; argv[argc] != NULL; argc++)
4979e9fcaa8aSmrg    ;
4980e9fcaa8aSmrg
4981e9fcaa8aSmrg  /* Allocate new argument vector.  */
4982e9fcaa8aSmrg  new_argv = XMALLOC (char *, argc + 1);
4983e9fcaa8aSmrg
4984e9fcaa8aSmrg  /* Put quoted arguments into the new argument vector.  */
4985e9fcaa8aSmrg  for (i = 0; i < argc; i++)
4986e9fcaa8aSmrg    {
4987e9fcaa8aSmrg      const char *string = argv[i];
4988e9fcaa8aSmrg
4989e9fcaa8aSmrg      if (string[0] == '\0')
4990e9fcaa8aSmrg	new_argv[i] = xstrdup ("\"\"");
4991e9fcaa8aSmrg      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
4992e9fcaa8aSmrg	{
4993e9fcaa8aSmrg	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
4994e9fcaa8aSmrg	  size_t length;
4995e9fcaa8aSmrg	  unsigned int backslashes;
4996e9fcaa8aSmrg	  const char *s;
4997e9fcaa8aSmrg	  char *quoted_string;
4998e9fcaa8aSmrg	  char *p;
4999e9fcaa8aSmrg
5000e9fcaa8aSmrg	  length = 0;
5001e9fcaa8aSmrg	  backslashes = 0;
5002e9fcaa8aSmrg	  if (quote_around)
5003e9fcaa8aSmrg	    length++;
5004e9fcaa8aSmrg	  for (s = string; *s != '\0'; s++)
5005e9fcaa8aSmrg	    {
5006e9fcaa8aSmrg	      char c = *s;
5007e9fcaa8aSmrg	      if (c == '"')
5008e9fcaa8aSmrg		length += backslashes + 1;
5009e9fcaa8aSmrg	      length++;
5010e9fcaa8aSmrg	      if (c == '\\')
5011e9fcaa8aSmrg		backslashes++;
5012e9fcaa8aSmrg	      else
5013e9fcaa8aSmrg		backslashes = 0;
5014e9fcaa8aSmrg	    }
5015e9fcaa8aSmrg	  if (quote_around)
5016e9fcaa8aSmrg	    length += backslashes + 1;
5017e9fcaa8aSmrg
5018e9fcaa8aSmrg	  quoted_string = XMALLOC (char, length + 1);
5019e9fcaa8aSmrg
5020e9fcaa8aSmrg	  p = quoted_string;
5021e9fcaa8aSmrg	  backslashes = 0;
5022e9fcaa8aSmrg	  if (quote_around)
5023e9fcaa8aSmrg	    *p++ = '"';
5024e9fcaa8aSmrg	  for (s = string; *s != '\0'; s++)
5025e9fcaa8aSmrg	    {
5026e9fcaa8aSmrg	      char c = *s;
5027e9fcaa8aSmrg	      if (c == '"')
5028e9fcaa8aSmrg		{
5029e9fcaa8aSmrg		  unsigned int j;
5030e9fcaa8aSmrg		  for (j = backslashes + 1; j > 0; j--)
5031e9fcaa8aSmrg		    *p++ = '\\';
5032e9fcaa8aSmrg		}
5033e9fcaa8aSmrg	      *p++ = c;
5034e9fcaa8aSmrg	      if (c == '\\')
5035e9fcaa8aSmrg		backslashes++;
5036e9fcaa8aSmrg	      else
5037e9fcaa8aSmrg		backslashes = 0;
5038e9fcaa8aSmrg	    }
5039e9fcaa8aSmrg	  if (quote_around)
5040e9fcaa8aSmrg	    {
5041e9fcaa8aSmrg	      unsigned int j;
5042e9fcaa8aSmrg	      for (j = backslashes; j > 0; j--)
5043e9fcaa8aSmrg		*p++ = '\\';
5044e9fcaa8aSmrg	      *p++ = '"';
5045e9fcaa8aSmrg	    }
5046e9fcaa8aSmrg	  *p = '\0';
5047e9fcaa8aSmrg
5048e9fcaa8aSmrg	  new_argv[i] = quoted_string;
5049e9fcaa8aSmrg	}
5050e9fcaa8aSmrg      else
5051e9fcaa8aSmrg	new_argv[i] = (char *) string;
5052e9fcaa8aSmrg    }
5053e9fcaa8aSmrg  new_argv[argc] = NULL;
5054e9fcaa8aSmrg
5055e9fcaa8aSmrg  return new_argv;
5056e9fcaa8aSmrg}
5057e9fcaa8aSmrgEOF
5058e9fcaa8aSmrg		;;
5059e9fcaa8aSmrg	    esac
5060e9fcaa8aSmrg
5061e9fcaa8aSmrg            cat <<"EOF"
5062e9fcaa8aSmrgvoid lt_dump_script (FILE* f)
5063e9fcaa8aSmrg{
5064e9fcaa8aSmrgEOF
5065e9fcaa8aSmrg	    func_emit_wrapper yes |
5066eb411b4bSmrg	      $SED -n -e '
5067eb411b4bSmrgs/^\(.\{79\}\)\(..*\)/\1\
5068eb411b4bSmrg\2/
5069eb411b4bSmrgh
5070eb411b4bSmrgs/\([\\"]\)/\\\1/g
5071eb411b4bSmrgs/$/\\n/
5072eb411b4bSmrgs/\([^\n]*\).*/  fputs ("\1", f);/p
5073eb411b4bSmrgg
5074eb411b4bSmrgD'
5075e9fcaa8aSmrg            cat <<"EOF"
5076e9fcaa8aSmrg}
507788de56ccSmrgEOF
507888de56ccSmrg}
507988de56ccSmrg# end: func_emit_cwrapperexe_src
50801ab64890Smrg
5081e9fcaa8aSmrg# func_win32_import_lib_p ARG
5082e9fcaa8aSmrg# True if ARG is an import lib, as indicated by $file_magic_cmd
5083e9fcaa8aSmrgfunc_win32_import_lib_p ()
5084e9fcaa8aSmrg{
5085e9fcaa8aSmrg    $opt_debug
5086e9fcaa8aSmrg    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
5087e9fcaa8aSmrg    *import*) : ;;
5088e9fcaa8aSmrg    *) false ;;
5089e9fcaa8aSmrg    esac
5090e9fcaa8aSmrg}
5091e9fcaa8aSmrg
509288de56ccSmrg# func_mode_link arg...
509388de56ccSmrgfunc_mode_link ()
509488de56ccSmrg{
509588de56ccSmrg    $opt_debug
509688de56ccSmrg    case $host in
509788de56ccSmrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
509888de56ccSmrg      # It is impossible to link a dll without this setting, and
509988de56ccSmrg      # we shouldn't force the makefile maintainer to figure out
510088de56ccSmrg      # which system we are compiling for in order to pass an extra
510188de56ccSmrg      # flag for every libtool invocation.
510288de56ccSmrg      # allow_undefined=no
51031ab64890Smrg
510488de56ccSmrg      # FIXME: Unfortunately, there are problems with the above when trying
510588de56ccSmrg      # to make a dll which has undefined symbols, in which case not
510688de56ccSmrg      # even a static library is built.  For now, we need to specify
510788de56ccSmrg      # -no-undefined on the libtool link line when we can be certain
510888de56ccSmrg      # that all symbols are satisfied, otherwise we get a static library.
510988de56ccSmrg      allow_undefined=yes
511088de56ccSmrg      ;;
511188de56ccSmrg    *)
511288de56ccSmrg      allow_undefined=yes
511388de56ccSmrg      ;;
511488de56ccSmrg    esac
511588de56ccSmrg    libtool_args=$nonopt
511688de56ccSmrg    base_compile="$nonopt $@"
511788de56ccSmrg    compile_command=$nonopt
511888de56ccSmrg    finalize_command=$nonopt
51191ab64890Smrg
512088de56ccSmrg    compile_rpath=
512188de56ccSmrg    finalize_rpath=
512288de56ccSmrg    compile_shlibpath=
512388de56ccSmrg    finalize_shlibpath=
512488de56ccSmrg    convenience=
512588de56ccSmrg    old_convenience=
512688de56ccSmrg    deplibs=
512788de56ccSmrg    old_deplibs=
512888de56ccSmrg    compiler_flags=
512988de56ccSmrg    linker_flags=
513088de56ccSmrg    dllsearchpath=
513188de56ccSmrg    lib_search_path=`pwd`
513288de56ccSmrg    inst_prefix_dir=
513388de56ccSmrg    new_inherited_linker_flags=
51341ab64890Smrg
513588de56ccSmrg    avoid_version=no
5136e9fcaa8aSmrg    bindir=
513788de56ccSmrg    dlfiles=
513888de56ccSmrg    dlprefiles=
513988de56ccSmrg    dlself=no
514088de56ccSmrg    export_dynamic=no
514188de56ccSmrg    export_symbols=
514288de56ccSmrg    export_symbols_regex=
514388de56ccSmrg    generated=
514488de56ccSmrg    libobjs=
514588de56ccSmrg    ltlibs=
514688de56ccSmrg    module=no
514788de56ccSmrg    no_install=no
514888de56ccSmrg    objs=
514988de56ccSmrg    non_pic_objects=
515088de56ccSmrg    precious_files_regex=
515188de56ccSmrg    prefer_static_libs=no
515288de56ccSmrg    preload=no
515388de56ccSmrg    prev=
515488de56ccSmrg    prevarg=
515588de56ccSmrg    release=
515688de56ccSmrg    rpath=
515788de56ccSmrg    xrpath=
515888de56ccSmrg    perm_rpath=
515988de56ccSmrg    temp_rpath=
516088de56ccSmrg    thread_safe=no
516188de56ccSmrg    vinfo=
516288de56ccSmrg    vinfo_number=no
516388de56ccSmrg    weak_libs=
516488de56ccSmrg    single_module="${wl}-single_module"
516588de56ccSmrg    func_infer_tag $base_compile
516688de56ccSmrg
516788de56ccSmrg    # We need to know -static, to get the right output filenames.
516888de56ccSmrg    for arg
516988de56ccSmrg    do
517088de56ccSmrg      case $arg in
517188de56ccSmrg      -shared)
517288de56ccSmrg	test "$build_libtool_libs" != yes && \
517388de56ccSmrg	  func_fatal_configuration "can not build a shared library"
517488de56ccSmrg	build_old_libs=no
517588de56ccSmrg	break
517688de56ccSmrg	;;
517788de56ccSmrg      -all-static | -static | -static-libtool-libs)
517888de56ccSmrg	case $arg in
517988de56ccSmrg	-all-static)
518088de56ccSmrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
518188de56ccSmrg	    func_warning "complete static linking is impossible in this configuration"
518288de56ccSmrg	  fi
518388de56ccSmrg	  if test -n "$link_static_flag"; then
518488de56ccSmrg	    dlopen_self=$dlopen_self_static
518588de56ccSmrg	  fi
518688de56ccSmrg	  prefer_static_libs=yes
518788de56ccSmrg	  ;;
518888de56ccSmrg	-static)
518988de56ccSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
519088de56ccSmrg	    dlopen_self=$dlopen_self_static
519188de56ccSmrg	  fi
519288de56ccSmrg	  prefer_static_libs=built
519388de56ccSmrg	  ;;
519488de56ccSmrg	-static-libtool-libs)
519588de56ccSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
519688de56ccSmrg	    dlopen_self=$dlopen_self_static
5197b4ee4795Smrg	  fi
519888de56ccSmrg	  prefer_static_libs=yes
519988de56ccSmrg	  ;;
520088de56ccSmrg	esac
520188de56ccSmrg	build_libtool_libs=no
520288de56ccSmrg	build_old_libs=yes
520388de56ccSmrg	break
520488de56ccSmrg	;;
520588de56ccSmrg      esac
520688de56ccSmrg    done
52071ab64890Smrg
520888de56ccSmrg    # See if our shared archives depend on static archives.
520988de56ccSmrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
52101ab64890Smrg
521188de56ccSmrg    # Go through the arguments, transforming them on the way.
521288de56ccSmrg    while test "$#" -gt 0; do
521388de56ccSmrg      arg="$1"
521488de56ccSmrg      shift
521588de56ccSmrg      func_quote_for_eval "$arg"
521688de56ccSmrg      qarg=$func_quote_for_eval_unquoted_result
521788de56ccSmrg      func_append libtool_args " $func_quote_for_eval_result"
52181ab64890Smrg
521988de56ccSmrg      # If the previous option needs an argument, assign it.
522088de56ccSmrg      if test -n "$prev"; then
522188de56ccSmrg	case $prev in
522288de56ccSmrg	output)
522388de56ccSmrg	  func_append compile_command " @OUTPUT@"
522488de56ccSmrg	  func_append finalize_command " @OUTPUT@"
522588de56ccSmrg	  ;;
522688de56ccSmrg	esac
52271ab64890Smrg
522888de56ccSmrg	case $prev in
5229e9fcaa8aSmrg	bindir)
5230e9fcaa8aSmrg	  bindir="$arg"
5231e9fcaa8aSmrg	  prev=
5232e9fcaa8aSmrg	  continue
5233e9fcaa8aSmrg	  ;;
523488de56ccSmrg	dlfiles|dlprefiles)
523588de56ccSmrg	  if test "$preload" = no; then
523688de56ccSmrg	    # Add the symbol object into the linking commands.
523788de56ccSmrg	    func_append compile_command " @SYMFILE@"
523888de56ccSmrg	    func_append finalize_command " @SYMFILE@"
523988de56ccSmrg	    preload=yes
524088de56ccSmrg	  fi
524188de56ccSmrg	  case $arg in
524288de56ccSmrg	  *.la | *.lo) ;;  # We handle these cases below.
524388de56ccSmrg	  force)
524488de56ccSmrg	    if test "$dlself" = no; then
524588de56ccSmrg	      dlself=needless
524688de56ccSmrg	      export_dynamic=yes
524788de56ccSmrg	    fi
524888de56ccSmrg	    prev=
524988de56ccSmrg	    continue
525088de56ccSmrg	    ;;
525188de56ccSmrg	  self)
525288de56ccSmrg	    if test "$prev" = dlprefiles; then
525388de56ccSmrg	      dlself=yes
525488de56ccSmrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
525588de56ccSmrg	      dlself=yes
5256b4ee4795Smrg	    else
525788de56ccSmrg	      dlself=needless
525888de56ccSmrg	      export_dynamic=yes
5259b4ee4795Smrg	    fi
526088de56ccSmrg	    prev=
526188de56ccSmrg	    continue
526288de56ccSmrg	    ;;
526388de56ccSmrg	  *)
526488de56ccSmrg	    if test "$prev" = dlfiles; then
5265e9fcaa8aSmrg	      func_append dlfiles " $arg"
5266b4ee4795Smrg	    else
5267e9fcaa8aSmrg	      func_append dlprefiles " $arg"
5268b4ee4795Smrg	    fi
526988de56ccSmrg	    prev=
527088de56ccSmrg	    continue
527188de56ccSmrg	    ;;
527288de56ccSmrg	  esac
527388de56ccSmrg	  ;;
527488de56ccSmrg	expsyms)
527588de56ccSmrg	  export_symbols="$arg"
527688de56ccSmrg	  test -f "$arg" \
527788de56ccSmrg	    || func_fatal_error "symbol file \`$arg' does not exist"
527888de56ccSmrg	  prev=
527988de56ccSmrg	  continue
528088de56ccSmrg	  ;;
528188de56ccSmrg	expsyms_regex)
528288de56ccSmrg	  export_symbols_regex="$arg"
528388de56ccSmrg	  prev=
528488de56ccSmrg	  continue
528588de56ccSmrg	  ;;
528688de56ccSmrg	framework)
5287b4ee4795Smrg	  case $host in
528888de56ccSmrg	    *-*-darwin*)
528988de56ccSmrg	      case "$deplibs " in
529088de56ccSmrg		*" $qarg.ltframework "*) ;;
5291e9fcaa8aSmrg		*) func_append deplibs " $qarg.ltframework" # this is fixed later
529288de56ccSmrg		   ;;
529388de56ccSmrg	      esac
529488de56ccSmrg	      ;;
5295b4ee4795Smrg	  esac
529688de56ccSmrg	  prev=
529788de56ccSmrg	  continue
5298b4ee4795Smrg	  ;;
529988de56ccSmrg	inst_prefix)
530088de56ccSmrg	  inst_prefix_dir="$arg"
530188de56ccSmrg	  prev=
530288de56ccSmrg	  continue
5303b4ee4795Smrg	  ;;
530488de56ccSmrg	objectlist)
530588de56ccSmrg	  if test -f "$arg"; then
530688de56ccSmrg	    save_arg=$arg
530788de56ccSmrg	    moreargs=
530888de56ccSmrg	    for fil in `cat "$save_arg"`
530988de56ccSmrg	    do
5310e9fcaa8aSmrg#	      func_append moreargs " $fil"
531188de56ccSmrg	      arg=$fil
531288de56ccSmrg	      # A libtool-controlled object.
53132e9c7c8cSmrg
531488de56ccSmrg	      # Check to see that this really is a libtool object.
531588de56ccSmrg	      if func_lalib_unsafe_p "$arg"; then
531688de56ccSmrg		pic_object=
531788de56ccSmrg		non_pic_object=
53182e9c7c8cSmrg
531988de56ccSmrg		# Read the .lo file
532088de56ccSmrg		func_source "$arg"
53212e9c7c8cSmrg
532288de56ccSmrg		if test -z "$pic_object" ||
532388de56ccSmrg		   test -z "$non_pic_object" ||
532488de56ccSmrg		   test "$pic_object" = none &&
532588de56ccSmrg		   test "$non_pic_object" = none; then
532688de56ccSmrg		  func_fatal_error "cannot find name of object for \`$arg'"
532788de56ccSmrg		fi
53282e9c7c8cSmrg
532988de56ccSmrg		# Extract subdirectory from the argument.
533088de56ccSmrg		func_dirname "$arg" "/" ""
533188de56ccSmrg		xdir="$func_dirname_result"
53322e9c7c8cSmrg
533388de56ccSmrg		if test "$pic_object" != none; then
533488de56ccSmrg		  # Prepend the subdirectory the object is found in.
533588de56ccSmrg		  pic_object="$xdir$pic_object"
53362e9c7c8cSmrg
533788de56ccSmrg		  if test "$prev" = dlfiles; then
533888de56ccSmrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5339e9fcaa8aSmrg		      func_append dlfiles " $pic_object"
534088de56ccSmrg		      prev=
534188de56ccSmrg		      continue
534288de56ccSmrg		    else
534388de56ccSmrg		      # If libtool objects are unsupported, then we need to preload.
534488de56ccSmrg		      prev=dlprefiles
534588de56ccSmrg		    fi
534688de56ccSmrg		  fi
53472e9c7c8cSmrg
534888de56ccSmrg		  # CHECK ME:  I think I busted this.  -Ossama
534988de56ccSmrg		  if test "$prev" = dlprefiles; then
535088de56ccSmrg		    # Preload the old-style object.
5351e9fcaa8aSmrg		    func_append dlprefiles " $pic_object"
535288de56ccSmrg		    prev=
535388de56ccSmrg		  fi
53542e9c7c8cSmrg
535588de56ccSmrg		  # A PIC object.
535688de56ccSmrg		  func_append libobjs " $pic_object"
535788de56ccSmrg		  arg="$pic_object"
535888de56ccSmrg		fi
53592e9c7c8cSmrg
536088de56ccSmrg		# Non-PIC object.
536188de56ccSmrg		if test "$non_pic_object" != none; then
536288de56ccSmrg		  # Prepend the subdirectory the object is found in.
536388de56ccSmrg		  non_pic_object="$xdir$non_pic_object"
53642e9c7c8cSmrg
536588de56ccSmrg		  # A standard non-PIC object
536688de56ccSmrg		  func_append non_pic_objects " $non_pic_object"
536788de56ccSmrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
536888de56ccSmrg		    arg="$non_pic_object"
536988de56ccSmrg		  fi
537088de56ccSmrg		else
537188de56ccSmrg		  # If the PIC object exists, use it instead.
537288de56ccSmrg		  # $xdir was prepended to $pic_object above.
537388de56ccSmrg		  non_pic_object="$pic_object"
537488de56ccSmrg		  func_append non_pic_objects " $non_pic_object"
537588de56ccSmrg		fi
537688de56ccSmrg	      else
537788de56ccSmrg		# Only an error if not doing a dry-run.
537888de56ccSmrg		if $opt_dry_run; then
537988de56ccSmrg		  # Extract subdirectory from the argument.
538088de56ccSmrg		  func_dirname "$arg" "/" ""
538188de56ccSmrg		  xdir="$func_dirname_result"
538288de56ccSmrg
538388de56ccSmrg		  func_lo2o "$arg"
538488de56ccSmrg		  pic_object=$xdir$objdir/$func_lo2o_result
538588de56ccSmrg		  non_pic_object=$xdir$func_lo2o_result
538688de56ccSmrg		  func_append libobjs " $pic_object"
538788de56ccSmrg		  func_append non_pic_objects " $non_pic_object"
538888de56ccSmrg	        else
538988de56ccSmrg		  func_fatal_error "\`$arg' is not a valid libtool object"
539088de56ccSmrg		fi
539188de56ccSmrg	      fi
539288de56ccSmrg	    done
5393b4ee4795Smrg	  else
539488de56ccSmrg	    func_fatal_error "link input file \`$arg' does not exist"
5395b4ee4795Smrg	  fi
539688de56ccSmrg	  arg=$save_arg
539788de56ccSmrg	  prev=
539888de56ccSmrg	  continue
539988de56ccSmrg	  ;;
540088de56ccSmrg	precious_regex)
540188de56ccSmrg	  precious_files_regex="$arg"
540288de56ccSmrg	  prev=
540388de56ccSmrg	  continue
540488de56ccSmrg	  ;;
540588de56ccSmrg	release)
540688de56ccSmrg	  release="-$arg"
540788de56ccSmrg	  prev=
540888de56ccSmrg	  continue
540988de56ccSmrg	  ;;
541088de56ccSmrg	rpath | xrpath)
541188de56ccSmrg	  # We need an absolute path.
541288de56ccSmrg	  case $arg in
541388de56ccSmrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
541488de56ccSmrg	  *)
541588de56ccSmrg	    func_fatal_error "only absolute run-paths are allowed"
541688de56ccSmrg	    ;;
541788de56ccSmrg	  esac
541888de56ccSmrg	  if test "$prev" = rpath; then
541988de56ccSmrg	    case "$rpath " in
542088de56ccSmrg	    *" $arg "*) ;;
5421e9fcaa8aSmrg	    *) func_append rpath " $arg" ;;
542288de56ccSmrg	    esac
5423b4ee4795Smrg	  else
542488de56ccSmrg	    case "$xrpath " in
542588de56ccSmrg	    *" $arg "*) ;;
5426e9fcaa8aSmrg	    *) func_append xrpath " $arg" ;;
542788de56ccSmrg	    esac
5428b4ee4795Smrg	  fi
542988de56ccSmrg	  prev=
543088de56ccSmrg	  continue
543188de56ccSmrg	  ;;
543288de56ccSmrg	shrext)
543388de56ccSmrg	  shrext_cmds="$arg"
543488de56ccSmrg	  prev=
543588de56ccSmrg	  continue
543688de56ccSmrg	  ;;
543788de56ccSmrg	weak)
5438e9fcaa8aSmrg	  func_append weak_libs " $arg"
543988de56ccSmrg	  prev=
544088de56ccSmrg	  continue
544188de56ccSmrg	  ;;
544288de56ccSmrg	xcclinker)
5443e9fcaa8aSmrg	  func_append linker_flags " $qarg"
5444e9fcaa8aSmrg	  func_append compiler_flags " $qarg"
544588de56ccSmrg	  prev=
544688de56ccSmrg	  func_append compile_command " $qarg"
544788de56ccSmrg	  func_append finalize_command " $qarg"
544888de56ccSmrg	  continue
544988de56ccSmrg	  ;;
545088de56ccSmrg	xcompiler)
5451e9fcaa8aSmrg	  func_append compiler_flags " $qarg"
545288de56ccSmrg	  prev=
545388de56ccSmrg	  func_append compile_command " $qarg"
545488de56ccSmrg	  func_append finalize_command " $qarg"
545588de56ccSmrg	  continue
545688de56ccSmrg	  ;;
545788de56ccSmrg	xlinker)
5458e9fcaa8aSmrg	  func_append linker_flags " $qarg"
5459e9fcaa8aSmrg	  func_append compiler_flags " $wl$qarg"
546088de56ccSmrg	  prev=
546188de56ccSmrg	  func_append compile_command " $wl$qarg"
546288de56ccSmrg	  func_append finalize_command " $wl$qarg"
546388de56ccSmrg	  continue
546488de56ccSmrg	  ;;
546588de56ccSmrg	*)
546688de56ccSmrg	  eval "$prev=\"\$arg\""
546788de56ccSmrg	  prev=
546888de56ccSmrg	  continue
546988de56ccSmrg	  ;;
54702e9c7c8cSmrg	esac
547188de56ccSmrg      fi # test -n "$prev"
54722e9c7c8cSmrg
547388de56ccSmrg      prevarg="$arg"
54742e9c7c8cSmrg
547588de56ccSmrg      case $arg in
547688de56ccSmrg      -all-static)
547788de56ccSmrg	if test -n "$link_static_flag"; then
547888de56ccSmrg	  # See comment for -static flag below, for more details.
547988de56ccSmrg	  func_append compile_command " $link_static_flag"
548088de56ccSmrg	  func_append finalize_command " $link_static_flag"
548188de56ccSmrg	fi
548288de56ccSmrg	continue
548388de56ccSmrg	;;
54842e9c7c8cSmrg
548588de56ccSmrg      -allow-undefined)
548688de56ccSmrg	# FIXME: remove this flag sometime in the future.
548788de56ccSmrg	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
548888de56ccSmrg	;;
54892e9c7c8cSmrg
549088de56ccSmrg      -avoid-version)
549188de56ccSmrg	avoid_version=yes
549288de56ccSmrg	continue
549388de56ccSmrg	;;
54942e9c7c8cSmrg
5495e9fcaa8aSmrg      -bindir)
5496e9fcaa8aSmrg	prev=bindir
5497e9fcaa8aSmrg	continue
5498e9fcaa8aSmrg	;;
5499e9fcaa8aSmrg
550088de56ccSmrg      -dlopen)
550188de56ccSmrg	prev=dlfiles
550288de56ccSmrg	continue
550388de56ccSmrg	;;
55042e9c7c8cSmrg
550588de56ccSmrg      -dlpreopen)
550688de56ccSmrg	prev=dlprefiles
550788de56ccSmrg	continue
550888de56ccSmrg	;;
55092e9c7c8cSmrg
551088de56ccSmrg      -export-dynamic)
551188de56ccSmrg	export_dynamic=yes
551288de56ccSmrg	continue
551388de56ccSmrg	;;
55142e9c7c8cSmrg
551588de56ccSmrg      -export-symbols | -export-symbols-regex)
551688de56ccSmrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
551788de56ccSmrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
551888de56ccSmrg	fi
551988de56ccSmrg	if test "X$arg" = "X-export-symbols"; then
552088de56ccSmrg	  prev=expsyms
552188de56ccSmrg	else
552288de56ccSmrg	  prev=expsyms_regex
552388de56ccSmrg	fi
552488de56ccSmrg	continue
552588de56ccSmrg	;;
55262e9c7c8cSmrg
552788de56ccSmrg      -framework)
552888de56ccSmrg	prev=framework
552988de56ccSmrg	continue
553088de56ccSmrg	;;
55312e9c7c8cSmrg
553288de56ccSmrg      -inst-prefix-dir)
553388de56ccSmrg	prev=inst_prefix
553488de56ccSmrg	continue
553588de56ccSmrg	;;
55362e9c7c8cSmrg
553788de56ccSmrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
553888de56ccSmrg      # so, if we see these flags be careful not to treat them like -L
553988de56ccSmrg      -L[A-Z][A-Z]*:*)
554088de56ccSmrg	case $with_gcc/$host in
554188de56ccSmrg	no/*-*-irix* | /*-*-irix*)
554288de56ccSmrg	  func_append compile_command " $arg"
554388de56ccSmrg	  func_append finalize_command " $arg"
554488de56ccSmrg	  ;;
554588de56ccSmrg	esac
554688de56ccSmrg	continue
554788de56ccSmrg	;;
55482e9c7c8cSmrg
554988de56ccSmrg      -L*)
5550e9fcaa8aSmrg	func_stripname "-L" '' "$arg"
5551e9fcaa8aSmrg	if test -z "$func_stripname_result"; then
555288de56ccSmrg	  if test "$#" -gt 0; then
555388de56ccSmrg	    func_fatal_error "require no space between \`-L' and \`$1'"
555488de56ccSmrg	  else
555588de56ccSmrg	    func_fatal_error "need path for \`-L' option"
555688de56ccSmrg	  fi
555788de56ccSmrg	fi
5558e9fcaa8aSmrg	func_resolve_sysroot "$func_stripname_result"
5559e9fcaa8aSmrg	dir=$func_resolve_sysroot_result
556088de56ccSmrg	# We need an absolute path.
556188de56ccSmrg	case $dir in
556288de56ccSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
556388de56ccSmrg	*)
556488de56ccSmrg	  absdir=`cd "$dir" && pwd`
556588de56ccSmrg	  test -z "$absdir" && \
556688de56ccSmrg	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
556788de56ccSmrg	  dir="$absdir"
556888de56ccSmrg	  ;;
556988de56ccSmrg	esac
557088de56ccSmrg	case "$deplibs " in
5571e9fcaa8aSmrg	*" -L$dir "* | *" $arg "*)
5572e9fcaa8aSmrg	  # Will only happen for absolute or sysroot arguments
5573e9fcaa8aSmrg	  ;;
557488de56ccSmrg	*)
5575e9fcaa8aSmrg	  # Preserve sysroot, but never include relative directories
5576e9fcaa8aSmrg	  case $dir in
5577e9fcaa8aSmrg	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
5578e9fcaa8aSmrg	    *) func_append deplibs " -L$dir" ;;
5579e9fcaa8aSmrg	  esac
5580e9fcaa8aSmrg	  func_append lib_search_path " $dir"
558188de56ccSmrg	  ;;
558288de56ccSmrg	esac
558388de56ccSmrg	case $host in
558488de56ccSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
5585e9fcaa8aSmrg	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
558688de56ccSmrg	  case :$dllsearchpath: in
558788de56ccSmrg	  *":$dir:"*) ;;
558888de56ccSmrg	  ::) dllsearchpath=$dir;;
5589e9fcaa8aSmrg	  *) func_append dllsearchpath ":$dir";;
559088de56ccSmrg	  esac
559188de56ccSmrg	  case :$dllsearchpath: in
559288de56ccSmrg	  *":$testbindir:"*) ;;
559388de56ccSmrg	  ::) dllsearchpath=$testbindir;;
5594e9fcaa8aSmrg	  *) func_append dllsearchpath ":$testbindir";;
559588de56ccSmrg	  esac
559688de56ccSmrg	  ;;
559788de56ccSmrg	esac
559888de56ccSmrg	continue
559988de56ccSmrg	;;
56002e9c7c8cSmrg
560188de56ccSmrg      -l*)
560288de56ccSmrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
560388de56ccSmrg	  case $host in
5604e9fcaa8aSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
560588de56ccSmrg	    # These systems don't actually have a C or math library (as such)
560688de56ccSmrg	    continue
560788de56ccSmrg	    ;;
560888de56ccSmrg	  *-*-os2*)
560988de56ccSmrg	    # These systems don't actually have a C library (as such)
561088de56ccSmrg	    test "X$arg" = "X-lc" && continue
561188de56ccSmrg	    ;;
561288de56ccSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
561388de56ccSmrg	    # Do not include libc due to us having libc/libc_r.
561488de56ccSmrg	    test "X$arg" = "X-lc" && continue
561588de56ccSmrg	    ;;
561688de56ccSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
561788de56ccSmrg	    # Rhapsody C and math libraries are in the System framework
5618e9fcaa8aSmrg	    func_append deplibs " System.ltframework"
561988de56ccSmrg	    continue
562088de56ccSmrg	    ;;
562188de56ccSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
562288de56ccSmrg	    # Causes problems with __ctype
562388de56ccSmrg	    test "X$arg" = "X-lc" && continue
562488de56ccSmrg	    ;;
562588de56ccSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
562688de56ccSmrg	    # Compiler inserts libc in the correct place for threads to work
562788de56ccSmrg	    test "X$arg" = "X-lc" && continue
562888de56ccSmrg	    ;;
562988de56ccSmrg	  esac
563088de56ccSmrg	elif test "X$arg" = "X-lc_r"; then
563188de56ccSmrg	 case $host in
563288de56ccSmrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
563388de56ccSmrg	   # Do not include libc_r directly, use -pthread flag.
563488de56ccSmrg	   continue
563588de56ccSmrg	   ;;
563688de56ccSmrg	 esac
563788de56ccSmrg	fi
5638e9fcaa8aSmrg	func_append deplibs " $arg"
563988de56ccSmrg	continue
564088de56ccSmrg	;;
56412e9c7c8cSmrg
564288de56ccSmrg      -module)
564388de56ccSmrg	module=yes
564488de56ccSmrg	continue
564588de56ccSmrg	;;
56462e9c7c8cSmrg
564788de56ccSmrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
564888de56ccSmrg      # classes, name mangling, and exception handling.
564988de56ccSmrg      # Darwin uses the -arch flag to determine output architecture.
5650e9fcaa8aSmrg      -model|-arch|-isysroot|--sysroot)
5651e9fcaa8aSmrg	func_append compiler_flags " $arg"
565288de56ccSmrg	func_append compile_command " $arg"
565388de56ccSmrg	func_append finalize_command " $arg"
565488de56ccSmrg	prev=xcompiler
565588de56ccSmrg	continue
565688de56ccSmrg	;;
56572e9c7c8cSmrg
5658eb411b4bSmrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
5659eb411b4bSmrg      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
5660e9fcaa8aSmrg	func_append compiler_flags " $arg"
566188de56ccSmrg	func_append compile_command " $arg"
566288de56ccSmrg	func_append finalize_command " $arg"
566388de56ccSmrg	case "$new_inherited_linker_flags " in
566488de56ccSmrg	    *" $arg "*) ;;
5665e9fcaa8aSmrg	    * ) func_append new_inherited_linker_flags " $arg" ;;
566688de56ccSmrg	esac
566788de56ccSmrg	continue
566888de56ccSmrg	;;
56692e9c7c8cSmrg
567088de56ccSmrg      -multi_module)
567188de56ccSmrg	single_module="${wl}-multi_module"
567288de56ccSmrg	continue
567388de56ccSmrg	;;
56742e9c7c8cSmrg
567588de56ccSmrg      -no-fast-install)
567688de56ccSmrg	fast_install=no
567788de56ccSmrg	continue
567888de56ccSmrg	;;
56792e9c7c8cSmrg
568088de56ccSmrg      -no-install)
568188de56ccSmrg	case $host in
568288de56ccSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
568388de56ccSmrg	  # The PATH hackery in wrapper scripts is required on Windows
568488de56ccSmrg	  # and Darwin in order for the loader to find any dlls it needs.
568588de56ccSmrg	  func_warning "\`-no-install' is ignored for $host"
568688de56ccSmrg	  func_warning "assuming \`-no-fast-install' instead"
568788de56ccSmrg	  fast_install=no
568888de56ccSmrg	  ;;
568988de56ccSmrg	*) no_install=yes ;;
569088de56ccSmrg	esac
569188de56ccSmrg	continue
569288de56ccSmrg	;;
56932e9c7c8cSmrg
569488de56ccSmrg      -no-undefined)
569588de56ccSmrg	allow_undefined=no
569688de56ccSmrg	continue
569788de56ccSmrg	;;
56982e9c7c8cSmrg
569988de56ccSmrg      -objectlist)
570088de56ccSmrg	prev=objectlist
570188de56ccSmrg	continue
570288de56ccSmrg	;;
57032e9c7c8cSmrg
570488de56ccSmrg      -o) prev=output ;;
57052e9c7c8cSmrg
570688de56ccSmrg      -precious-files-regex)
570788de56ccSmrg	prev=precious_regex
570888de56ccSmrg	continue
570988de56ccSmrg	;;
57102e9c7c8cSmrg
571188de56ccSmrg      -release)
571288de56ccSmrg	prev=release
571388de56ccSmrg	continue
571488de56ccSmrg	;;
57152e9c7c8cSmrg
571688de56ccSmrg      -rpath)
571788de56ccSmrg	prev=rpath
571888de56ccSmrg	continue
571988de56ccSmrg	;;
57202e9c7c8cSmrg
572188de56ccSmrg      -R)
572288de56ccSmrg	prev=xrpath
572388de56ccSmrg	continue
572488de56ccSmrg	;;
57252e9c7c8cSmrg
572688de56ccSmrg      -R*)
572788de56ccSmrg	func_stripname '-R' '' "$arg"
572888de56ccSmrg	dir=$func_stripname_result
572988de56ccSmrg	# We need an absolute path.
573088de56ccSmrg	case $dir in
573188de56ccSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
5732e9fcaa8aSmrg	=*)
5733e9fcaa8aSmrg	  func_stripname '=' '' "$dir"
5734e9fcaa8aSmrg	  dir=$lt_sysroot$func_stripname_result
5735e9fcaa8aSmrg	  ;;
573688de56ccSmrg	*)
573788de56ccSmrg	  func_fatal_error "only absolute run-paths are allowed"
573888de56ccSmrg	  ;;
573988de56ccSmrg	esac
574088de56ccSmrg	case "$xrpath " in
574188de56ccSmrg	*" $dir "*) ;;
5742e9fcaa8aSmrg	*) func_append xrpath " $dir" ;;
574388de56ccSmrg	esac
574488de56ccSmrg	continue
574588de56ccSmrg	;;
57462e9c7c8cSmrg
574788de56ccSmrg      -shared)
574888de56ccSmrg	# The effects of -shared are defined in a previous loop.
574988de56ccSmrg	continue
575088de56ccSmrg	;;
57512e9c7c8cSmrg
575288de56ccSmrg      -shrext)
575388de56ccSmrg	prev=shrext
575488de56ccSmrg	continue
575588de56ccSmrg	;;
57562e9c7c8cSmrg
575788de56ccSmrg      -static | -static-libtool-libs)
575888de56ccSmrg	# The effects of -static are defined in a previous loop.
575988de56ccSmrg	# We used to do the same as -all-static on platforms that
576088de56ccSmrg	# didn't have a PIC flag, but the assumption that the effects
576188de56ccSmrg	# would be equivalent was wrong.  It would break on at least
576288de56ccSmrg	# Digital Unix and AIX.
576388de56ccSmrg	continue
576488de56ccSmrg	;;
57652e9c7c8cSmrg
576688de56ccSmrg      -thread-safe)
576788de56ccSmrg	thread_safe=yes
576888de56ccSmrg	continue
576988de56ccSmrg	;;
57702e9c7c8cSmrg
577188de56ccSmrg      -version-info)
577288de56ccSmrg	prev=vinfo
577388de56ccSmrg	continue
577488de56ccSmrg	;;
57752e9c7c8cSmrg
577688de56ccSmrg      -version-number)
577788de56ccSmrg	prev=vinfo
577888de56ccSmrg	vinfo_number=yes
577988de56ccSmrg	continue
578088de56ccSmrg	;;
57812e9c7c8cSmrg
578288de56ccSmrg      -weak)
578388de56ccSmrg        prev=weak
578488de56ccSmrg	continue
578588de56ccSmrg	;;
57861ab64890Smrg
578788de56ccSmrg      -Wc,*)
578888de56ccSmrg	func_stripname '-Wc,' '' "$arg"
578988de56ccSmrg	args=$func_stripname_result
579088de56ccSmrg	arg=
579188de56ccSmrg	save_ifs="$IFS"; IFS=','
579288de56ccSmrg	for flag in $args; do
579388de56ccSmrg	  IFS="$save_ifs"
579488de56ccSmrg          func_quote_for_eval "$flag"
5795e9fcaa8aSmrg	  func_append arg " $func_quote_for_eval_result"
5796e9fcaa8aSmrg	  func_append compiler_flags " $func_quote_for_eval_result"
579788de56ccSmrg	done
579888de56ccSmrg	IFS="$save_ifs"
579988de56ccSmrg	func_stripname ' ' '' "$arg"
580088de56ccSmrg	arg=$func_stripname_result
580188de56ccSmrg	;;
5802b4ee4795Smrg
580388de56ccSmrg      -Wl,*)
580488de56ccSmrg	func_stripname '-Wl,' '' "$arg"
580588de56ccSmrg	args=$func_stripname_result
580688de56ccSmrg	arg=
580788de56ccSmrg	save_ifs="$IFS"; IFS=','
580888de56ccSmrg	for flag in $args; do
580988de56ccSmrg	  IFS="$save_ifs"
581088de56ccSmrg          func_quote_for_eval "$flag"
5811e9fcaa8aSmrg	  func_append arg " $wl$func_quote_for_eval_result"
5812e9fcaa8aSmrg	  func_append compiler_flags " $wl$func_quote_for_eval_result"
5813e9fcaa8aSmrg	  func_append linker_flags " $func_quote_for_eval_result"
581488de56ccSmrg	done
581588de56ccSmrg	IFS="$save_ifs"
581688de56ccSmrg	func_stripname ' ' '' "$arg"
581788de56ccSmrg	arg=$func_stripname_result
581888de56ccSmrg	;;
5819b4ee4795Smrg
582088de56ccSmrg      -Xcompiler)
582188de56ccSmrg	prev=xcompiler
582288de56ccSmrg	continue
582388de56ccSmrg	;;
5824b4ee4795Smrg
582588de56ccSmrg      -Xlinker)
582688de56ccSmrg	prev=xlinker
582788de56ccSmrg	continue
582888de56ccSmrg	;;
5829b4ee4795Smrg
583088de56ccSmrg      -XCClinker)
583188de56ccSmrg	prev=xcclinker
583288de56ccSmrg	continue
583388de56ccSmrg	;;
5834b4ee4795Smrg
583588de56ccSmrg      # -msg_* for osf cc
583688de56ccSmrg      -msg_*)
583788de56ccSmrg	func_quote_for_eval "$arg"
583888de56ccSmrg	arg="$func_quote_for_eval_result"
583988de56ccSmrg	;;
5840b4ee4795Smrg
5841e9fcaa8aSmrg      # Flags to be passed through unchanged, with rationale:
5842e9fcaa8aSmrg      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
5843e9fcaa8aSmrg      # -r[0-9][0-9]*        specify processor for the SGI compiler
5844e9fcaa8aSmrg      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
5845e9fcaa8aSmrg      # +DA*, +DD*           enable 64-bit mode for the HP compiler
5846e9fcaa8aSmrg      # -q*                  compiler args for the IBM compiler
5847e9fcaa8aSmrg      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
5848e9fcaa8aSmrg      # -F/path              path to uninstalled frameworks, gcc on darwin
5849e9fcaa8aSmrg      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
5850e9fcaa8aSmrg      # @file                GCC response files
5851e9fcaa8aSmrg      # -tp=*                Portland pgcc target processor selection
5852e9fcaa8aSmrg      # --sysroot=*          for sysroot support
5853e9fcaa8aSmrg      # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
585488de56ccSmrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
5855e9fcaa8aSmrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
5856e9fcaa8aSmrg      -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
585788de56ccSmrg        func_quote_for_eval "$arg"
585888de56ccSmrg	arg="$func_quote_for_eval_result"
585988de56ccSmrg        func_append compile_command " $arg"
586088de56ccSmrg        func_append finalize_command " $arg"
5861e9fcaa8aSmrg        func_append compiler_flags " $arg"
586288de56ccSmrg        continue
586388de56ccSmrg        ;;
5864b4ee4795Smrg
586588de56ccSmrg      # Some other compiler flag.
586688de56ccSmrg      -* | +*)
586788de56ccSmrg        func_quote_for_eval "$arg"
586888de56ccSmrg	arg="$func_quote_for_eval_result"
586988de56ccSmrg	;;
5870b4ee4795Smrg
587188de56ccSmrg      *.$objext)
587288de56ccSmrg	# A standard object.
5873e9fcaa8aSmrg	func_append objs " $arg"
587488de56ccSmrg	;;
5875b4ee4795Smrg
587688de56ccSmrg      *.lo)
587788de56ccSmrg	# A libtool-controlled object.
5878b4ee4795Smrg
587988de56ccSmrg	# Check to see that this really is a libtool object.
588088de56ccSmrg	if func_lalib_unsafe_p "$arg"; then
588188de56ccSmrg	  pic_object=
588288de56ccSmrg	  non_pic_object=
5883b4ee4795Smrg
588488de56ccSmrg	  # Read the .lo file
588588de56ccSmrg	  func_source "$arg"
5886b4ee4795Smrg
588788de56ccSmrg	  if test -z "$pic_object" ||
588888de56ccSmrg	     test -z "$non_pic_object" ||
588988de56ccSmrg	     test "$pic_object" = none &&
589088de56ccSmrg	     test "$non_pic_object" = none; then
589188de56ccSmrg	    func_fatal_error "cannot find name of object for \`$arg'"
589288de56ccSmrg	  fi
5893b4ee4795Smrg
589488de56ccSmrg	  # Extract subdirectory from the argument.
589588de56ccSmrg	  func_dirname "$arg" "/" ""
589688de56ccSmrg	  xdir="$func_dirname_result"
5897b4ee4795Smrg
589888de56ccSmrg	  if test "$pic_object" != none; then
589988de56ccSmrg	    # Prepend the subdirectory the object is found in.
590088de56ccSmrg	    pic_object="$xdir$pic_object"
5901b4ee4795Smrg
590288de56ccSmrg	    if test "$prev" = dlfiles; then
590388de56ccSmrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5904e9fcaa8aSmrg		func_append dlfiles " $pic_object"
590588de56ccSmrg		prev=
590688de56ccSmrg		continue
590788de56ccSmrg	      else
590888de56ccSmrg		# If libtool objects are unsupported, then we need to preload.
590988de56ccSmrg		prev=dlprefiles
591088de56ccSmrg	      fi
591188de56ccSmrg	    fi
5912b4ee4795Smrg
591388de56ccSmrg	    # CHECK ME:  I think I busted this.  -Ossama
591488de56ccSmrg	    if test "$prev" = dlprefiles; then
591588de56ccSmrg	      # Preload the old-style object.
5916e9fcaa8aSmrg	      func_append dlprefiles " $pic_object"
591788de56ccSmrg	      prev=
591888de56ccSmrg	    fi
59191ab64890Smrg
592088de56ccSmrg	    # A PIC object.
592188de56ccSmrg	    func_append libobjs " $pic_object"
592288de56ccSmrg	    arg="$pic_object"
592388de56ccSmrg	  fi
59241ab64890Smrg
592588de56ccSmrg	  # Non-PIC object.
592688de56ccSmrg	  if test "$non_pic_object" != none; then
592788de56ccSmrg	    # Prepend the subdirectory the object is found in.
592888de56ccSmrg	    non_pic_object="$xdir$non_pic_object"
59291ab64890Smrg
593088de56ccSmrg	    # A standard non-PIC object
593188de56ccSmrg	    func_append non_pic_objects " $non_pic_object"
593288de56ccSmrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
593388de56ccSmrg	      arg="$non_pic_object"
593488de56ccSmrg	    fi
593588de56ccSmrg	  else
593688de56ccSmrg	    # If the PIC object exists, use it instead.
593788de56ccSmrg	    # $xdir was prepended to $pic_object above.
593888de56ccSmrg	    non_pic_object="$pic_object"
593988de56ccSmrg	    func_append non_pic_objects " $non_pic_object"
594088de56ccSmrg	  fi
594188de56ccSmrg	else
594288de56ccSmrg	  # Only an error if not doing a dry-run.
594388de56ccSmrg	  if $opt_dry_run; then
594488de56ccSmrg	    # Extract subdirectory from the argument.
594588de56ccSmrg	    func_dirname "$arg" "/" ""
594688de56ccSmrg	    xdir="$func_dirname_result"
594788de56ccSmrg
594888de56ccSmrg	    func_lo2o "$arg"
594988de56ccSmrg	    pic_object=$xdir$objdir/$func_lo2o_result
595088de56ccSmrg	    non_pic_object=$xdir$func_lo2o_result
595188de56ccSmrg	    func_append libobjs " $pic_object"
595288de56ccSmrg	    func_append non_pic_objects " $non_pic_object"
595388de56ccSmrg	  else
595488de56ccSmrg	    func_fatal_error "\`$arg' is not a valid libtool object"
595588de56ccSmrg	  fi
595688de56ccSmrg	fi
595788de56ccSmrg	;;
59581ab64890Smrg
595988de56ccSmrg      *.$libext)
596088de56ccSmrg	# An archive.
5961e9fcaa8aSmrg	func_append deplibs " $arg"
5962e9fcaa8aSmrg	func_append old_deplibs " $arg"
596388de56ccSmrg	continue
596488de56ccSmrg	;;
596588de56ccSmrg
596688de56ccSmrg      *.la)
596788de56ccSmrg	# A libtool-controlled library.
596888de56ccSmrg
5969e9fcaa8aSmrg	func_resolve_sysroot "$arg"
597088de56ccSmrg	if test "$prev" = dlfiles; then
597188de56ccSmrg	  # This library was specified with -dlopen.
5972e9fcaa8aSmrg	  func_append dlfiles " $func_resolve_sysroot_result"
597388de56ccSmrg	  prev=
597488de56ccSmrg	elif test "$prev" = dlprefiles; then
597588de56ccSmrg	  # The library was specified with -dlpreopen.
5976e9fcaa8aSmrg	  func_append dlprefiles " $func_resolve_sysroot_result"
597788de56ccSmrg	  prev=
597888de56ccSmrg	else
5979e9fcaa8aSmrg	  func_append deplibs " $func_resolve_sysroot_result"
598088de56ccSmrg	fi
598188de56ccSmrg	continue
598288de56ccSmrg	;;
598388de56ccSmrg
598488de56ccSmrg      # Some other compiler argument.
598588de56ccSmrg      *)
598688de56ccSmrg	# Unknown arguments in both finalize_command and compile_command need
598788de56ccSmrg	# to be aesthetically quoted because they are evaled later.
598888de56ccSmrg	func_quote_for_eval "$arg"
598988de56ccSmrg	arg="$func_quote_for_eval_result"
599088de56ccSmrg	;;
599188de56ccSmrg      esac # arg
599288de56ccSmrg
599388de56ccSmrg      # Now actually substitute the argument into the commands.
599488de56ccSmrg      if test -n "$arg"; then
599588de56ccSmrg	func_append compile_command " $arg"
599688de56ccSmrg	func_append finalize_command " $arg"
599788de56ccSmrg      fi
599888de56ccSmrg    done # argument parsing loop
599988de56ccSmrg
600088de56ccSmrg    test -n "$prev" && \
600188de56ccSmrg      func_fatal_help "the \`$prevarg' option requires an argument"
600288de56ccSmrg
600388de56ccSmrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
600488de56ccSmrg      eval arg=\"$export_dynamic_flag_spec\"
600588de56ccSmrg      func_append compile_command " $arg"
600688de56ccSmrg      func_append finalize_command " $arg"
600788de56ccSmrg    fi
600888de56ccSmrg
600988de56ccSmrg    oldlibs=
601088de56ccSmrg    # calculate the name of the file, without its directory
601188de56ccSmrg    func_basename "$output"
601288de56ccSmrg    outputname="$func_basename_result"
601388de56ccSmrg    libobjs_save="$libobjs"
601488de56ccSmrg
601588de56ccSmrg    if test -n "$shlibpath_var"; then
601688de56ccSmrg      # get the directories listed in $shlibpath_var
6017e9fcaa8aSmrg      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
601888de56ccSmrg    else
601988de56ccSmrg      shlib_search_path=
602088de56ccSmrg    fi
602188de56ccSmrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
602288de56ccSmrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
602388de56ccSmrg
602488de56ccSmrg    func_dirname "$output" "/" ""
602588de56ccSmrg    output_objdir="$func_dirname_result$objdir"
6026e9fcaa8aSmrg    func_to_tool_file "$output_objdir/"
6027e9fcaa8aSmrg    tool_output_objdir=$func_to_tool_file_result
602888de56ccSmrg    # Create the object directory.
602988de56ccSmrg    func_mkdir_p "$output_objdir"
603088de56ccSmrg
603188de56ccSmrg    # Determine the type of output
603288de56ccSmrg    case $output in
603388de56ccSmrg    "")
603488de56ccSmrg      func_fatal_help "you must specify an output file"
603588de56ccSmrg      ;;
603688de56ccSmrg    *.$libext) linkmode=oldlib ;;
603788de56ccSmrg    *.lo | *.$objext) linkmode=obj ;;
603888de56ccSmrg    *.la) linkmode=lib ;;
603988de56ccSmrg    *) linkmode=prog ;; # Anything else should be a program.
604088de56ccSmrg    esac
604188de56ccSmrg
604288de56ccSmrg    specialdeplibs=
604388de56ccSmrg
604488de56ccSmrg    libs=
604588de56ccSmrg    # Find all interdependent deplibs by searching for libraries
604688de56ccSmrg    # that are linked more than once (e.g. -la -lb -la)
604788de56ccSmrg    for deplib in $deplibs; do
6048e9fcaa8aSmrg      if $opt_preserve_dup_deps ; then
604988de56ccSmrg	case "$libs " in
6050e9fcaa8aSmrg	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
605188de56ccSmrg	esac
605288de56ccSmrg      fi
6053e9fcaa8aSmrg      func_append libs " $deplib"
605488de56ccSmrg    done
605588de56ccSmrg
605688de56ccSmrg    if test "$linkmode" = lib; then
605788de56ccSmrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
605888de56ccSmrg
605988de56ccSmrg      # Compute libraries that are listed more than once in $predeps
606088de56ccSmrg      # $postdeps and mark them as special (i.e., whose duplicates are
606188de56ccSmrg      # not to be eliminated).
606288de56ccSmrg      pre_post_deps=
606388de56ccSmrg      if $opt_duplicate_compiler_generated_deps; then
606488de56ccSmrg	for pre_post_dep in $predeps $postdeps; do
606588de56ccSmrg	  case "$pre_post_deps " in
6066e9fcaa8aSmrg	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
606788de56ccSmrg	  esac
6068e9fcaa8aSmrg	  func_append pre_post_deps " $pre_post_dep"
606988de56ccSmrg	done
607088de56ccSmrg      fi
607188de56ccSmrg      pre_post_deps=
607288de56ccSmrg    fi
607388de56ccSmrg
607488de56ccSmrg    deplibs=
607588de56ccSmrg    newdependency_libs=
607688de56ccSmrg    newlib_search_path=
607788de56ccSmrg    need_relink=no # whether we're linking any uninstalled libtool libraries
607888de56ccSmrg    notinst_deplibs= # not-installed libtool libraries
607988de56ccSmrg    notinst_path= # paths that contain not-installed libtool libraries
608088de56ccSmrg
608188de56ccSmrg    case $linkmode in
608288de56ccSmrg    lib)
608388de56ccSmrg	passes="conv dlpreopen link"
608488de56ccSmrg	for file in $dlfiles $dlprefiles; do
608588de56ccSmrg	  case $file in
608688de56ccSmrg	  *.la) ;;
608788de56ccSmrg	  *)
608888de56ccSmrg	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
608988de56ccSmrg	    ;;
609088de56ccSmrg	  esac
609188de56ccSmrg	done
609288de56ccSmrg	;;
609388de56ccSmrg    prog)
609488de56ccSmrg	compile_deplibs=
609588de56ccSmrg	finalize_deplibs=
609688de56ccSmrg	alldeplibs=no
609788de56ccSmrg	newdlfiles=
609888de56ccSmrg	newdlprefiles=
609988de56ccSmrg	passes="conv scan dlopen dlpreopen link"
610088de56ccSmrg	;;
610188de56ccSmrg    *)  passes="conv"
610288de56ccSmrg	;;
610388de56ccSmrg    esac
610488de56ccSmrg
610588de56ccSmrg    for pass in $passes; do
610688de56ccSmrg      # The preopen pass in lib mode reverses $deplibs; put it back here
610788de56ccSmrg      # so that -L comes before libs that need it for instance...
610888de56ccSmrg      if test "$linkmode,$pass" = "lib,link"; then
610988de56ccSmrg	## FIXME: Find the place where the list is rebuilt in the wrong
611088de56ccSmrg	##        order, and fix it there properly
611188de56ccSmrg        tmp_deplibs=
611288de56ccSmrg	for deplib in $deplibs; do
611388de56ccSmrg	  tmp_deplibs="$deplib $tmp_deplibs"
611488de56ccSmrg	done
611588de56ccSmrg	deplibs="$tmp_deplibs"
611688de56ccSmrg      fi
611788de56ccSmrg
611888de56ccSmrg      if test "$linkmode,$pass" = "lib,link" ||
611988de56ccSmrg	 test "$linkmode,$pass" = "prog,scan"; then
612088de56ccSmrg	libs="$deplibs"
612188de56ccSmrg	deplibs=
612288de56ccSmrg      fi
612388de56ccSmrg      if test "$linkmode" = prog; then
612488de56ccSmrg	case $pass in
612588de56ccSmrg	dlopen) libs="$dlfiles" ;;
612688de56ccSmrg	dlpreopen) libs="$dlprefiles" ;;
6127e9fcaa8aSmrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
612888de56ccSmrg	esac
612988de56ccSmrg      fi
613088de56ccSmrg      if test "$linkmode,$pass" = "lib,dlpreopen"; then
613188de56ccSmrg	# Collect and forward deplibs of preopened libtool libs
613288de56ccSmrg	for lib in $dlprefiles; do
613388de56ccSmrg	  # Ignore non-libtool-libs
613488de56ccSmrg	  dependency_libs=
6135e9fcaa8aSmrg	  func_resolve_sysroot "$lib"
613688de56ccSmrg	  case $lib in
6137e9fcaa8aSmrg	  *.la)	func_source "$func_resolve_sysroot_result" ;;
613888de56ccSmrg	  esac
613988de56ccSmrg
614088de56ccSmrg	  # Collect preopened libtool deplibs, except any this library
614188de56ccSmrg	  # has declared as weak libs
614288de56ccSmrg	  for deplib in $dependency_libs; do
6143e9fcaa8aSmrg	    func_basename "$deplib"
6144e9fcaa8aSmrg            deplib_base=$func_basename_result
614588de56ccSmrg	    case " $weak_libs " in
614688de56ccSmrg	    *" $deplib_base "*) ;;
6147e9fcaa8aSmrg	    *) func_append deplibs " $deplib" ;;
614888de56ccSmrg	    esac
614988de56ccSmrg	  done
615088de56ccSmrg	done
615188de56ccSmrg	libs="$dlprefiles"
615288de56ccSmrg      fi
615388de56ccSmrg      if test "$pass" = dlopen; then
615488de56ccSmrg	# Collect dlpreopened libraries
615588de56ccSmrg	save_deplibs="$deplibs"
615688de56ccSmrg	deplibs=
615788de56ccSmrg      fi
615888de56ccSmrg
615988de56ccSmrg      for deplib in $libs; do
616088de56ccSmrg	lib=
616188de56ccSmrg	found=no
616288de56ccSmrg	case $deplib in
6163eb411b4bSmrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
6164eb411b4bSmrg        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
616588de56ccSmrg	  if test "$linkmode,$pass" = "prog,link"; then
616688de56ccSmrg	    compile_deplibs="$deplib $compile_deplibs"
616788de56ccSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
616888de56ccSmrg	  else
6169e9fcaa8aSmrg	    func_append compiler_flags " $deplib"
617088de56ccSmrg	    if test "$linkmode" = lib ; then
617188de56ccSmrg		case "$new_inherited_linker_flags " in
617288de56ccSmrg		    *" $deplib "*) ;;
6173e9fcaa8aSmrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
617488de56ccSmrg		esac
617588de56ccSmrg	    fi
617688de56ccSmrg	  fi
617788de56ccSmrg	  continue
617888de56ccSmrg	  ;;
617988de56ccSmrg	-l*)
618088de56ccSmrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
618188de56ccSmrg	    func_warning "\`-l' is ignored for archives/objects"
618288de56ccSmrg	    continue
618388de56ccSmrg	  fi
618488de56ccSmrg	  func_stripname '-l' '' "$deplib"
618588de56ccSmrg	  name=$func_stripname_result
618688de56ccSmrg	  if test "$linkmode" = lib; then
618788de56ccSmrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
618888de56ccSmrg	  else
618988de56ccSmrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
619088de56ccSmrg	  fi
619188de56ccSmrg	  for searchdir in $searchdirs; do
619288de56ccSmrg	    for search_ext in .la $std_shrext .so .a; do
619388de56ccSmrg	      # Search the libtool library
619488de56ccSmrg	      lib="$searchdir/lib${name}${search_ext}"
619588de56ccSmrg	      if test -f "$lib"; then
619688de56ccSmrg		if test "$search_ext" = ".la"; then
619788de56ccSmrg		  found=yes
619888de56ccSmrg		else
619988de56ccSmrg		  found=no
620088de56ccSmrg		fi
620188de56ccSmrg		break 2
620288de56ccSmrg	      fi
620388de56ccSmrg	    done
620488de56ccSmrg	  done
620588de56ccSmrg	  if test "$found" != yes; then
620688de56ccSmrg	    # deplib doesn't seem to be a libtool library
620788de56ccSmrg	    if test "$linkmode,$pass" = "prog,link"; then
620888de56ccSmrg	      compile_deplibs="$deplib $compile_deplibs"
620988de56ccSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
621088de56ccSmrg	    else
621188de56ccSmrg	      deplibs="$deplib $deplibs"
621288de56ccSmrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
621388de56ccSmrg	    fi
621488de56ccSmrg	    continue
621588de56ccSmrg	  else # deplib is a libtool library
621688de56ccSmrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
621788de56ccSmrg	    # We need to do some special things here, and not later.
621888de56ccSmrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
621988de56ccSmrg	      case " $predeps $postdeps " in
622088de56ccSmrg	      *" $deplib "*)
622188de56ccSmrg		if func_lalib_p "$lib"; then
622288de56ccSmrg		  library_names=
622388de56ccSmrg		  old_library=
622488de56ccSmrg		  func_source "$lib"
622588de56ccSmrg		  for l in $old_library $library_names; do
622688de56ccSmrg		    ll="$l"
622788de56ccSmrg		  done
622888de56ccSmrg		  if test "X$ll" = "X$old_library" ; then # only static version available
622988de56ccSmrg		    found=no
623088de56ccSmrg		    func_dirname "$lib" "" "."
623188de56ccSmrg		    ladir="$func_dirname_result"
623288de56ccSmrg		    lib=$ladir/$old_library
623388de56ccSmrg		    if test "$linkmode,$pass" = "prog,link"; then
623488de56ccSmrg		      compile_deplibs="$deplib $compile_deplibs"
623588de56ccSmrg		      finalize_deplibs="$deplib $finalize_deplibs"
623688de56ccSmrg		    else
623788de56ccSmrg		      deplibs="$deplib $deplibs"
623888de56ccSmrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
623988de56ccSmrg		    fi
624088de56ccSmrg		    continue
624188de56ccSmrg		  fi
624288de56ccSmrg		fi
624388de56ccSmrg		;;
624488de56ccSmrg	      *) ;;
624588de56ccSmrg	      esac
624688de56ccSmrg	    fi
624788de56ccSmrg	  fi
624888de56ccSmrg	  ;; # -l
624988de56ccSmrg	*.ltframework)
625088de56ccSmrg	  if test "$linkmode,$pass" = "prog,link"; then
625188de56ccSmrg	    compile_deplibs="$deplib $compile_deplibs"
625288de56ccSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
625388de56ccSmrg	  else
625488de56ccSmrg	    deplibs="$deplib $deplibs"
625588de56ccSmrg	    if test "$linkmode" = lib ; then
625688de56ccSmrg		case "$new_inherited_linker_flags " in
625788de56ccSmrg		    *" $deplib "*) ;;
6258e9fcaa8aSmrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
625988de56ccSmrg		esac
626088de56ccSmrg	    fi
626188de56ccSmrg	  fi
626288de56ccSmrg	  continue
626388de56ccSmrg	  ;;
626488de56ccSmrg	-L*)
626588de56ccSmrg	  case $linkmode in
626688de56ccSmrg	  lib)
626788de56ccSmrg	    deplibs="$deplib $deplibs"
626888de56ccSmrg	    test "$pass" = conv && continue
626988de56ccSmrg	    newdependency_libs="$deplib $newdependency_libs"
627088de56ccSmrg	    func_stripname '-L' '' "$deplib"
6271e9fcaa8aSmrg	    func_resolve_sysroot "$func_stripname_result"
6272e9fcaa8aSmrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
627388de56ccSmrg	    ;;
627488de56ccSmrg	  prog)
627588de56ccSmrg	    if test "$pass" = conv; then
627688de56ccSmrg	      deplibs="$deplib $deplibs"
627788de56ccSmrg	      continue
627888de56ccSmrg	    fi
627988de56ccSmrg	    if test "$pass" = scan; then
628088de56ccSmrg	      deplibs="$deplib $deplibs"
628188de56ccSmrg	    else
628288de56ccSmrg	      compile_deplibs="$deplib $compile_deplibs"
628388de56ccSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
628488de56ccSmrg	    fi
628588de56ccSmrg	    func_stripname '-L' '' "$deplib"
6286e9fcaa8aSmrg	    func_resolve_sysroot "$func_stripname_result"
6287e9fcaa8aSmrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
628888de56ccSmrg	    ;;
628988de56ccSmrg	  *)
629088de56ccSmrg	    func_warning "\`-L' is ignored for archives/objects"
629188de56ccSmrg	    ;;
629288de56ccSmrg	  esac # linkmode
629388de56ccSmrg	  continue
629488de56ccSmrg	  ;; # -L
629588de56ccSmrg	-R*)
629688de56ccSmrg	  if test "$pass" = link; then
629788de56ccSmrg	    func_stripname '-R' '' "$deplib"
6298e9fcaa8aSmrg	    func_resolve_sysroot "$func_stripname_result"
6299e9fcaa8aSmrg	    dir=$func_resolve_sysroot_result
630088de56ccSmrg	    # Make sure the xrpath contains only unique directories.
630188de56ccSmrg	    case "$xrpath " in
630288de56ccSmrg	    *" $dir "*) ;;
6303e9fcaa8aSmrg	    *) func_append xrpath " $dir" ;;
630488de56ccSmrg	    esac
630588de56ccSmrg	  fi
630688de56ccSmrg	  deplibs="$deplib $deplibs"
630788de56ccSmrg	  continue
630888de56ccSmrg	  ;;
6309e9fcaa8aSmrg	*.la)
6310e9fcaa8aSmrg	  func_resolve_sysroot "$deplib"
6311e9fcaa8aSmrg	  lib=$func_resolve_sysroot_result
6312e9fcaa8aSmrg	  ;;
631388de56ccSmrg	*.$libext)
631488de56ccSmrg	  if test "$pass" = conv; then
631588de56ccSmrg	    deplibs="$deplib $deplibs"
631688de56ccSmrg	    continue
631788de56ccSmrg	  fi
631888de56ccSmrg	  case $linkmode in
631988de56ccSmrg	  lib)
632088de56ccSmrg	    # Linking convenience modules into shared libraries is allowed,
632188de56ccSmrg	    # but linking other static libraries is non-portable.
632288de56ccSmrg	    case " $dlpreconveniencelibs " in
632388de56ccSmrg	    *" $deplib "*) ;;
632488de56ccSmrg	    *)
632588de56ccSmrg	      valid_a_lib=no
632688de56ccSmrg	      case $deplibs_check_method in
632788de56ccSmrg		match_pattern*)
632888de56ccSmrg		  set dummy $deplibs_check_method; shift
632988de56ccSmrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6330e9fcaa8aSmrg		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
633188de56ccSmrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
633288de56ccSmrg		    valid_a_lib=yes
633388de56ccSmrg		  fi
633488de56ccSmrg		;;
633588de56ccSmrg		pass_all)
633688de56ccSmrg		  valid_a_lib=yes
633788de56ccSmrg		;;
633888de56ccSmrg	      esac
633988de56ccSmrg	      if test "$valid_a_lib" != yes; then
6340e9fcaa8aSmrg		echo
634188de56ccSmrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
6342e9fcaa8aSmrg		echo "*** I have the capability to make that library automatically link in when"
6343e9fcaa8aSmrg		echo "*** you link to this library.  But I can only do this if you have a"
6344e9fcaa8aSmrg		echo "*** shared version of the library, which you do not appear to have"
6345e9fcaa8aSmrg		echo "*** because the file extensions .$libext of this argument makes me believe"
6346e9fcaa8aSmrg		echo "*** that it is just a static archive that I should not use here."
634788de56ccSmrg	      else
6348e9fcaa8aSmrg		echo
634988de56ccSmrg		$ECHO "*** Warning: Linking the shared library $output against the"
635088de56ccSmrg		$ECHO "*** static library $deplib is not portable!"
635188de56ccSmrg		deplibs="$deplib $deplibs"
635288de56ccSmrg	      fi
635388de56ccSmrg	      ;;
635488de56ccSmrg	    esac
635588de56ccSmrg	    continue
635688de56ccSmrg	    ;;
635788de56ccSmrg	  prog)
635888de56ccSmrg	    if test "$pass" != link; then
635988de56ccSmrg	      deplibs="$deplib $deplibs"
636088de56ccSmrg	    else
636188de56ccSmrg	      compile_deplibs="$deplib $compile_deplibs"
636288de56ccSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
636388de56ccSmrg	    fi
636488de56ccSmrg	    continue
636588de56ccSmrg	    ;;
636688de56ccSmrg	  esac # linkmode
636788de56ccSmrg	  ;; # *.$libext
636888de56ccSmrg	*.lo | *.$objext)
636988de56ccSmrg	  if test "$pass" = conv; then
637088de56ccSmrg	    deplibs="$deplib $deplibs"
637188de56ccSmrg	  elif test "$linkmode" = prog; then
637288de56ccSmrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
637388de56ccSmrg	      # If there is no dlopen support or we're linking statically,
637488de56ccSmrg	      # we need to preload.
6375e9fcaa8aSmrg	      func_append newdlprefiles " $deplib"
637688de56ccSmrg	      compile_deplibs="$deplib $compile_deplibs"
637788de56ccSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
637888de56ccSmrg	    else
6379e9fcaa8aSmrg	      func_append newdlfiles " $deplib"
638088de56ccSmrg	    fi
638188de56ccSmrg	  fi
638288de56ccSmrg	  continue
638388de56ccSmrg	  ;;
638488de56ccSmrg	%DEPLIBS%)
638588de56ccSmrg	  alldeplibs=yes
638688de56ccSmrg	  continue
638788de56ccSmrg	  ;;
638888de56ccSmrg	esac # case $deplib
638988de56ccSmrg
639088de56ccSmrg	if test "$found" = yes || test -f "$lib"; then :
639188de56ccSmrg	else
639288de56ccSmrg	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
639388de56ccSmrg	fi
639488de56ccSmrg
639588de56ccSmrg	# Check to see that this really is a libtool archive.
639688de56ccSmrg	func_lalib_unsafe_p "$lib" \
639788de56ccSmrg	  || func_fatal_error "\`$lib' is not a valid libtool archive"
639888de56ccSmrg
639988de56ccSmrg	func_dirname "$lib" "" "."
640088de56ccSmrg	ladir="$func_dirname_result"
640188de56ccSmrg
640288de56ccSmrg	dlname=
640388de56ccSmrg	dlopen=
640488de56ccSmrg	dlpreopen=
640588de56ccSmrg	libdir=
640688de56ccSmrg	library_names=
640788de56ccSmrg	old_library=
640888de56ccSmrg	inherited_linker_flags=
640988de56ccSmrg	# If the library was installed with an old release of libtool,
641088de56ccSmrg	# it will not redefine variables installed, or shouldnotlink
641188de56ccSmrg	installed=yes
641288de56ccSmrg	shouldnotlink=no
641388de56ccSmrg	avoidtemprpath=
641488de56ccSmrg
641588de56ccSmrg
641688de56ccSmrg	# Read the .la file
641788de56ccSmrg	func_source "$lib"
641888de56ccSmrg
641988de56ccSmrg	# Convert "-framework foo" to "foo.ltframework"
642088de56ccSmrg	if test -n "$inherited_linker_flags"; then
6421e9fcaa8aSmrg	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
642288de56ccSmrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
642388de56ccSmrg	    case " $new_inherited_linker_flags " in
642488de56ccSmrg	      *" $tmp_inherited_linker_flag "*) ;;
6425e9fcaa8aSmrg	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
642688de56ccSmrg	    esac
642788de56ccSmrg	  done
642888de56ccSmrg	fi
6429e9fcaa8aSmrg	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
643088de56ccSmrg	if test "$linkmode,$pass" = "lib,link" ||
643188de56ccSmrg	   test "$linkmode,$pass" = "prog,scan" ||
643288de56ccSmrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
6433e9fcaa8aSmrg	  test -n "$dlopen" && func_append dlfiles " $dlopen"
6434e9fcaa8aSmrg	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
643588de56ccSmrg	fi
643688de56ccSmrg
643788de56ccSmrg	if test "$pass" = conv; then
643888de56ccSmrg	  # Only check for convenience libraries
643988de56ccSmrg	  deplibs="$lib $deplibs"
644088de56ccSmrg	  if test -z "$libdir"; then
644188de56ccSmrg	    if test -z "$old_library"; then
644288de56ccSmrg	      func_fatal_error "cannot find name of link library for \`$lib'"
644388de56ccSmrg	    fi
644488de56ccSmrg	    # It is a libtool convenience library, so add in its objects.
6445e9fcaa8aSmrg	    func_append convenience " $ladir/$objdir/$old_library"
6446e9fcaa8aSmrg	    func_append old_convenience " $ladir/$objdir/$old_library"
644788de56ccSmrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
644888de56ccSmrg	    func_fatal_error "\`$lib' is not a convenience library"
644988de56ccSmrg	  fi
6450e9fcaa8aSmrg	  tmp_libs=
6451e9fcaa8aSmrg	  for deplib in $dependency_libs; do
6452e9fcaa8aSmrg	    deplibs="$deplib $deplibs"
6453e9fcaa8aSmrg	    if $opt_preserve_dup_deps ; then
6454e9fcaa8aSmrg	      case "$tmp_libs " in
6455e9fcaa8aSmrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
6456e9fcaa8aSmrg	      esac
6457e9fcaa8aSmrg	    fi
6458e9fcaa8aSmrg	    func_append tmp_libs " $deplib"
6459e9fcaa8aSmrg	  done
646088de56ccSmrg	  continue
646188de56ccSmrg	fi # $pass = conv
646288de56ccSmrg
646388de56ccSmrg
646488de56ccSmrg	# Get the name of the library we link against.
646588de56ccSmrg	linklib=
6466e9fcaa8aSmrg	if test -n "$old_library" &&
6467e9fcaa8aSmrg	   { test "$prefer_static_libs" = yes ||
6468e9fcaa8aSmrg	     test "$prefer_static_libs,$installed" = "built,no"; }; then
6469e9fcaa8aSmrg	  linklib=$old_library
6470e9fcaa8aSmrg	else
6471e9fcaa8aSmrg	  for l in $old_library $library_names; do
6472e9fcaa8aSmrg	    linklib="$l"
6473e9fcaa8aSmrg	  done
6474e9fcaa8aSmrg	fi
647588de56ccSmrg	if test -z "$linklib"; then
647688de56ccSmrg	  func_fatal_error "cannot find name of link library for \`$lib'"
647788de56ccSmrg	fi
647888de56ccSmrg
647988de56ccSmrg	# This library was specified with -dlopen.
648088de56ccSmrg	if test "$pass" = dlopen; then
648188de56ccSmrg	  if test -z "$libdir"; then
648288de56ccSmrg	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
648388de56ccSmrg	  fi
648488de56ccSmrg	  if test -z "$dlname" ||
648588de56ccSmrg	     test "$dlopen_support" != yes ||
648688de56ccSmrg	     test "$build_libtool_libs" = no; then
648788de56ccSmrg	    # If there is no dlname, no dlopen support or we're linking
648888de56ccSmrg	    # statically, we need to preload.  We also need to preload any
648988de56ccSmrg	    # dependent libraries so libltdl's deplib preloader doesn't
649088de56ccSmrg	    # bomb out in the load deplibs phase.
6491e9fcaa8aSmrg	    func_append dlprefiles " $lib $dependency_libs"
649288de56ccSmrg	  else
6493e9fcaa8aSmrg	    func_append newdlfiles " $lib"
649488de56ccSmrg	  fi
649588de56ccSmrg	  continue
649688de56ccSmrg	fi # $pass = dlopen
649788de56ccSmrg
649888de56ccSmrg	# We need an absolute path.
649988de56ccSmrg	case $ladir in
650088de56ccSmrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
650188de56ccSmrg	*)
650288de56ccSmrg	  abs_ladir=`cd "$ladir" && pwd`
650388de56ccSmrg	  if test -z "$abs_ladir"; then
650488de56ccSmrg	    func_warning "cannot determine absolute directory name of \`$ladir'"
650588de56ccSmrg	    func_warning "passing it literally to the linker, although it might fail"
650688de56ccSmrg	    abs_ladir="$ladir"
650788de56ccSmrg	  fi
650888de56ccSmrg	  ;;
650988de56ccSmrg	esac
651088de56ccSmrg	func_basename "$lib"
651188de56ccSmrg	laname="$func_basename_result"
651288de56ccSmrg
651388de56ccSmrg	# Find the relevant object directory and library name.
651488de56ccSmrg	if test "X$installed" = Xyes; then
6515e9fcaa8aSmrg	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
651688de56ccSmrg	    func_warning "library \`$lib' was moved."
651788de56ccSmrg	    dir="$ladir"
651888de56ccSmrg	    absdir="$abs_ladir"
651988de56ccSmrg	    libdir="$abs_ladir"
652088de56ccSmrg	  else
6521e9fcaa8aSmrg	    dir="$lt_sysroot$libdir"
6522e9fcaa8aSmrg	    absdir="$lt_sysroot$libdir"
652388de56ccSmrg	  fi
652488de56ccSmrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
652588de56ccSmrg	else
652688de56ccSmrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
652788de56ccSmrg	    dir="$ladir"
652888de56ccSmrg	    absdir="$abs_ladir"
652988de56ccSmrg	    # Remove this search path later
6530e9fcaa8aSmrg	    func_append notinst_path " $abs_ladir"
653188de56ccSmrg	  else
653288de56ccSmrg	    dir="$ladir/$objdir"
653388de56ccSmrg	    absdir="$abs_ladir/$objdir"
653488de56ccSmrg	    # Remove this search path later
6535e9fcaa8aSmrg	    func_append notinst_path " $abs_ladir"
653688de56ccSmrg	  fi
653788de56ccSmrg	fi # $installed = yes
653888de56ccSmrg	func_stripname 'lib' '.la' "$laname"
653988de56ccSmrg	name=$func_stripname_result
654088de56ccSmrg
654188de56ccSmrg	# This library was specified with -dlpreopen.
654288de56ccSmrg	if test "$pass" = dlpreopen; then
654388de56ccSmrg	  if test -z "$libdir" && test "$linkmode" = prog; then
654488de56ccSmrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
654588de56ccSmrg	  fi
6546e9fcaa8aSmrg	  case "$host" in
6547e9fcaa8aSmrg	    # special handling for platforms with PE-DLLs.
6548e9fcaa8aSmrg	    *cygwin* | *mingw* | *cegcc* )
6549e9fcaa8aSmrg	      # Linker will automatically link against shared library if both
6550e9fcaa8aSmrg	      # static and shared are present.  Therefore, ensure we extract
6551e9fcaa8aSmrg	      # symbols from the import library if a shared library is present
6552e9fcaa8aSmrg	      # (otherwise, the dlopen module name will be incorrect).  We do
6553e9fcaa8aSmrg	      # this by putting the import library name into $newdlprefiles.
6554e9fcaa8aSmrg	      # We recover the dlopen module name by 'saving' the la file
6555e9fcaa8aSmrg	      # name in a special purpose variable, and (later) extracting the
6556e9fcaa8aSmrg	      # dlname from the la file.
6557e9fcaa8aSmrg	      if test -n "$dlname"; then
6558e9fcaa8aSmrg	        func_tr_sh "$dir/$linklib"
6559e9fcaa8aSmrg	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
6560e9fcaa8aSmrg	        func_append newdlprefiles " $dir/$linklib"
6561e9fcaa8aSmrg	      else
6562e9fcaa8aSmrg	        func_append newdlprefiles " $dir/$old_library"
6563e9fcaa8aSmrg	        # Keep a list of preopened convenience libraries to check
6564e9fcaa8aSmrg	        # that they are being used correctly in the link pass.
6565e9fcaa8aSmrg	        test -z "$libdir" && \
6566e9fcaa8aSmrg	          func_append dlpreconveniencelibs " $dir/$old_library"
6567e9fcaa8aSmrg	      fi
6568e9fcaa8aSmrg	    ;;
6569e9fcaa8aSmrg	    * )
6570e9fcaa8aSmrg	      # Prefer using a static library (so that no silly _DYNAMIC symbols
6571e9fcaa8aSmrg	      # are required to link).
6572e9fcaa8aSmrg	      if test -n "$old_library"; then
6573e9fcaa8aSmrg	        func_append newdlprefiles " $dir/$old_library"
6574e9fcaa8aSmrg	        # Keep a list of preopened convenience libraries to check
6575e9fcaa8aSmrg	        # that they are being used correctly in the link pass.
6576e9fcaa8aSmrg	        test -z "$libdir" && \
6577e9fcaa8aSmrg	          func_append dlpreconveniencelibs " $dir/$old_library"
6578e9fcaa8aSmrg	      # Otherwise, use the dlname, so that lt_dlopen finds it.
6579e9fcaa8aSmrg	      elif test -n "$dlname"; then
6580e9fcaa8aSmrg	        func_append newdlprefiles " $dir/$dlname"
6581e9fcaa8aSmrg	      else
6582e9fcaa8aSmrg	        func_append newdlprefiles " $dir/$linklib"
6583e9fcaa8aSmrg	      fi
6584e9fcaa8aSmrg	    ;;
6585e9fcaa8aSmrg	  esac
658688de56ccSmrg	fi # $pass = dlpreopen
658788de56ccSmrg
658888de56ccSmrg	if test -z "$libdir"; then
658988de56ccSmrg	  # Link the convenience library
659088de56ccSmrg	  if test "$linkmode" = lib; then
659188de56ccSmrg	    deplibs="$dir/$old_library $deplibs"
659288de56ccSmrg	  elif test "$linkmode,$pass" = "prog,link"; then
659388de56ccSmrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
659488de56ccSmrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
659588de56ccSmrg	  else
659688de56ccSmrg	    deplibs="$lib $deplibs" # used for prog,scan pass
659788de56ccSmrg	  fi
659888de56ccSmrg	  continue
659988de56ccSmrg	fi
660088de56ccSmrg
660188de56ccSmrg
660288de56ccSmrg	if test "$linkmode" = prog && test "$pass" != link; then
6603e9fcaa8aSmrg	  func_append newlib_search_path " $ladir"
660488de56ccSmrg	  deplibs="$lib $deplibs"
660588de56ccSmrg
660688de56ccSmrg	  linkalldeplibs=no
660788de56ccSmrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
660888de56ccSmrg	     test "$build_libtool_libs" = no; then
660988de56ccSmrg	    linkalldeplibs=yes
661088de56ccSmrg	  fi
661188de56ccSmrg
661288de56ccSmrg	  tmp_libs=
661388de56ccSmrg	  for deplib in $dependency_libs; do
661488de56ccSmrg	    case $deplib in
661588de56ccSmrg	    -L*) func_stripname '-L' '' "$deplib"
6616e9fcaa8aSmrg	         func_resolve_sysroot "$func_stripname_result"
6617e9fcaa8aSmrg	         func_append newlib_search_path " $func_resolve_sysroot_result"
661888de56ccSmrg		 ;;
661988de56ccSmrg	    esac
662088de56ccSmrg	    # Need to link against all dependency_libs?
662188de56ccSmrg	    if test "$linkalldeplibs" = yes; then
662288de56ccSmrg	      deplibs="$deplib $deplibs"
662388de56ccSmrg	    else
662488de56ccSmrg	      # Need to hardcode shared library paths
662588de56ccSmrg	      # or/and link against static libraries
662688de56ccSmrg	      newdependency_libs="$deplib $newdependency_libs"
662788de56ccSmrg	    fi
6628e9fcaa8aSmrg	    if $opt_preserve_dup_deps ; then
662988de56ccSmrg	      case "$tmp_libs " in
6630e9fcaa8aSmrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
663188de56ccSmrg	      esac
663288de56ccSmrg	    fi
6633e9fcaa8aSmrg	    func_append tmp_libs " $deplib"
663488de56ccSmrg	  done # for deplib
663588de56ccSmrg	  continue
663688de56ccSmrg	fi # $linkmode = prog...
663788de56ccSmrg
663888de56ccSmrg	if test "$linkmode,$pass" = "prog,link"; then
663988de56ccSmrg	  if test -n "$library_names" &&
664088de56ccSmrg	     { { test "$prefer_static_libs" = no ||
664188de56ccSmrg	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
664288de56ccSmrg	       test -z "$old_library"; }; then
664388de56ccSmrg	    # We need to hardcode the library path
664488de56ccSmrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
664588de56ccSmrg	      # Make sure the rpath contains only unique directories.
664688de56ccSmrg	      case "$temp_rpath:" in
664788de56ccSmrg	      *"$absdir:"*) ;;
6648e9fcaa8aSmrg	      *) func_append temp_rpath "$absdir:" ;;
664988de56ccSmrg	      esac
665088de56ccSmrg	    fi
665188de56ccSmrg
665288de56ccSmrg	    # Hardcode the library path.
665388de56ccSmrg	    # Skip directories that are in the system default run-time
665488de56ccSmrg	    # search path.
665588de56ccSmrg	    case " $sys_lib_dlsearch_path " in
665688de56ccSmrg	    *" $absdir "*) ;;
665788de56ccSmrg	    *)
665888de56ccSmrg	      case "$compile_rpath " in
665988de56ccSmrg	      *" $absdir "*) ;;
6660e9fcaa8aSmrg	      *) func_append compile_rpath " $absdir" ;;
666188de56ccSmrg	      esac
666288de56ccSmrg	      ;;
666388de56ccSmrg	    esac
666488de56ccSmrg	    case " $sys_lib_dlsearch_path " in
666588de56ccSmrg	    *" $libdir "*) ;;
666688de56ccSmrg	    *)
666788de56ccSmrg	      case "$finalize_rpath " in
666888de56ccSmrg	      *" $libdir "*) ;;
6669e9fcaa8aSmrg	      *) func_append finalize_rpath " $libdir" ;;
667088de56ccSmrg	      esac
667188de56ccSmrg	      ;;
667288de56ccSmrg	    esac
667388de56ccSmrg	  fi # $linkmode,$pass = prog,link...
667488de56ccSmrg
667588de56ccSmrg	  if test "$alldeplibs" = yes &&
667688de56ccSmrg	     { test "$deplibs_check_method" = pass_all ||
667788de56ccSmrg	       { test "$build_libtool_libs" = yes &&
667888de56ccSmrg		 test -n "$library_names"; }; }; then
667988de56ccSmrg	    # We only need to search for static libraries
668088de56ccSmrg	    continue
668188de56ccSmrg	  fi
668288de56ccSmrg	fi
668388de56ccSmrg
668488de56ccSmrg	link_static=no # Whether the deplib will be linked statically
668588de56ccSmrg	use_static_libs=$prefer_static_libs
668688de56ccSmrg	if test "$use_static_libs" = built && test "$installed" = yes; then
668788de56ccSmrg	  use_static_libs=no
668888de56ccSmrg	fi
668988de56ccSmrg	if test -n "$library_names" &&
669088de56ccSmrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
669188de56ccSmrg	  case $host in
669288de56ccSmrg	  *cygwin* | *mingw* | *cegcc*)
669388de56ccSmrg	      # No point in relinking DLLs because paths are not encoded
6694e9fcaa8aSmrg	      func_append notinst_deplibs " $lib"
669588de56ccSmrg	      need_relink=no
669688de56ccSmrg	    ;;
669788de56ccSmrg	  *)
669888de56ccSmrg	    if test "$installed" = no; then
6699e9fcaa8aSmrg	      func_append notinst_deplibs " $lib"
670088de56ccSmrg	      need_relink=yes
670188de56ccSmrg	    fi
670288de56ccSmrg	    ;;
670388de56ccSmrg	  esac
670488de56ccSmrg	  # This is a shared library
670588de56ccSmrg
670688de56ccSmrg	  # Warn about portability, can't link against -module's on some
670788de56ccSmrg	  # systems (darwin).  Don't bleat about dlopened modules though!
670888de56ccSmrg	  dlopenmodule=""
670988de56ccSmrg	  for dlpremoduletest in $dlprefiles; do
671088de56ccSmrg	    if test "X$dlpremoduletest" = "X$lib"; then
671188de56ccSmrg	      dlopenmodule="$dlpremoduletest"
671288de56ccSmrg	      break
671388de56ccSmrg	    fi
671488de56ccSmrg	  done
671588de56ccSmrg	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
6716e9fcaa8aSmrg	    echo
671788de56ccSmrg	    if test "$linkmode" = prog; then
671888de56ccSmrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
671988de56ccSmrg	    else
672088de56ccSmrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
672188de56ccSmrg	    fi
672288de56ccSmrg	    $ECHO "*** $linklib is not portable!"
672388de56ccSmrg	  fi
672488de56ccSmrg	  if test "$linkmode" = lib &&
672588de56ccSmrg	     test "$hardcode_into_libs" = yes; then
672688de56ccSmrg	    # Hardcode the library path.
672788de56ccSmrg	    # Skip directories that are in the system default run-time
672888de56ccSmrg	    # search path.
672988de56ccSmrg	    case " $sys_lib_dlsearch_path " in
673088de56ccSmrg	    *" $absdir "*) ;;
673188de56ccSmrg	    *)
673288de56ccSmrg	      case "$compile_rpath " in
673388de56ccSmrg	      *" $absdir "*) ;;
6734e9fcaa8aSmrg	      *) func_append compile_rpath " $absdir" ;;
673588de56ccSmrg	      esac
673688de56ccSmrg	      ;;
673788de56ccSmrg	    esac
673888de56ccSmrg	    case " $sys_lib_dlsearch_path " in
673988de56ccSmrg	    *" $libdir "*) ;;
674088de56ccSmrg	    *)
674188de56ccSmrg	      case "$finalize_rpath " in
674288de56ccSmrg	      *" $libdir "*) ;;
6743e9fcaa8aSmrg	      *) func_append finalize_rpath " $libdir" ;;
674488de56ccSmrg	      esac
674588de56ccSmrg	      ;;
674688de56ccSmrg	    esac
674788de56ccSmrg	  fi
674888de56ccSmrg
674988de56ccSmrg	  if test -n "$old_archive_from_expsyms_cmds"; then
675088de56ccSmrg	    # figure out the soname
675188de56ccSmrg	    set dummy $library_names
675288de56ccSmrg	    shift
675388de56ccSmrg	    realname="$1"
675488de56ccSmrg	    shift
675588de56ccSmrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
675688de56ccSmrg	    # use dlname if we got it. it's perfectly good, no?
675788de56ccSmrg	    if test -n "$dlname"; then
675888de56ccSmrg	      soname="$dlname"
675988de56ccSmrg	    elif test -n "$soname_spec"; then
676088de56ccSmrg	      # bleh windows
676188de56ccSmrg	      case $host in
676288de56ccSmrg	      *cygwin* | mingw* | *cegcc*)
676388de56ccSmrg	        func_arith $current - $age
676488de56ccSmrg		major=$func_arith_result
676588de56ccSmrg		versuffix="-$major"
676688de56ccSmrg		;;
676788de56ccSmrg	      esac
676888de56ccSmrg	      eval soname=\"$soname_spec\"
676988de56ccSmrg	    else
677088de56ccSmrg	      soname="$realname"
677188de56ccSmrg	    fi
677288de56ccSmrg
677388de56ccSmrg	    # Make a new name for the extract_expsyms_cmds to use
677488de56ccSmrg	    soroot="$soname"
677588de56ccSmrg	    func_basename "$soroot"
677688de56ccSmrg	    soname="$func_basename_result"
677788de56ccSmrg	    func_stripname 'lib' '.dll' "$soname"
677888de56ccSmrg	    newlib=libimp-$func_stripname_result.a
677988de56ccSmrg
678088de56ccSmrg	    # If the library has no export list, then create one now
678188de56ccSmrg	    if test -f "$output_objdir/$soname-def"; then :
678288de56ccSmrg	    else
678388de56ccSmrg	      func_verbose "extracting exported symbol list from \`$soname'"
678488de56ccSmrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
678588de56ccSmrg	    fi
678688de56ccSmrg
678788de56ccSmrg	    # Create $newlib
678888de56ccSmrg	    if test -f "$output_objdir/$newlib"; then :; else
678988de56ccSmrg	      func_verbose "generating import library for \`$soname'"
679088de56ccSmrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
679188de56ccSmrg	    fi
679288de56ccSmrg	    # make sure the library variables are pointing to the new library
679388de56ccSmrg	    dir=$output_objdir
679488de56ccSmrg	    linklib=$newlib
679588de56ccSmrg	  fi # test -n "$old_archive_from_expsyms_cmds"
679688de56ccSmrg
6797e9fcaa8aSmrg	  if test "$linkmode" = prog || test "$opt_mode" != relink; then
679888de56ccSmrg	    add_shlibpath=
679988de56ccSmrg	    add_dir=
680088de56ccSmrg	    add=
680188de56ccSmrg	    lib_linked=yes
680288de56ccSmrg	    case $hardcode_action in
680388de56ccSmrg	    immediate | unsupported)
680488de56ccSmrg	      if test "$hardcode_direct" = no; then
680588de56ccSmrg		add="$dir/$linklib"
680688de56ccSmrg		case $host in
680788de56ccSmrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
680888de56ccSmrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
680988de56ccSmrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
681088de56ccSmrg		    *-*-unixware7*) add_dir="-L$dir" ;;
681188de56ccSmrg		  *-*-darwin* )
681288de56ccSmrg		    # if the lib is a (non-dlopened) module then we can not
681388de56ccSmrg		    # link against it, someone is ignoring the earlier warnings
681488de56ccSmrg		    if /usr/bin/file -L $add 2> /dev/null |
681588de56ccSmrg			 $GREP ": [^:]* bundle" >/dev/null ; then
681688de56ccSmrg		      if test "X$dlopenmodule" != "X$lib"; then
681788de56ccSmrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
681888de56ccSmrg			if test -z "$old_library" ; then
6819e9fcaa8aSmrg			  echo
6820e9fcaa8aSmrg			  echo "*** And there doesn't seem to be a static archive available"
6821e9fcaa8aSmrg			  echo "*** The link will probably fail, sorry"
682288de56ccSmrg			else
682388de56ccSmrg			  add="$dir/$old_library"
682488de56ccSmrg			fi
682588de56ccSmrg		      elif test -n "$old_library"; then
682688de56ccSmrg			add="$dir/$old_library"
682788de56ccSmrg		      fi
682888de56ccSmrg		    fi
682988de56ccSmrg		esac
683088de56ccSmrg	      elif test "$hardcode_minus_L" = no; then
683188de56ccSmrg		case $host in
683288de56ccSmrg		*-*-sunos*) add_shlibpath="$dir" ;;
683388de56ccSmrg		esac
683488de56ccSmrg		add_dir="-L$dir"
683588de56ccSmrg		add="-l$name"
683688de56ccSmrg	      elif test "$hardcode_shlibpath_var" = no; then
683788de56ccSmrg		add_shlibpath="$dir"
683888de56ccSmrg		add="-l$name"
683988de56ccSmrg	      else
684088de56ccSmrg		lib_linked=no
684188de56ccSmrg	      fi
684288de56ccSmrg	      ;;
684388de56ccSmrg	    relink)
684488de56ccSmrg	      if test "$hardcode_direct" = yes &&
684588de56ccSmrg	         test "$hardcode_direct_absolute" = no; then
684688de56ccSmrg		add="$dir/$linklib"
684788de56ccSmrg	      elif test "$hardcode_minus_L" = yes; then
6848eb411b4bSmrg		add_dir="-L$absdir"
684988de56ccSmrg		# Try looking first in the location we're being installed to.
685088de56ccSmrg		if test -n "$inst_prefix_dir"; then
685188de56ccSmrg		  case $libdir in
685288de56ccSmrg		    [\\/]*)
6853e9fcaa8aSmrg		      func_append add_dir " -L$inst_prefix_dir$libdir"
685488de56ccSmrg		      ;;
685588de56ccSmrg		  esac
685688de56ccSmrg		fi
685788de56ccSmrg		add="-l$name"
685888de56ccSmrg	      elif test "$hardcode_shlibpath_var" = yes; then
685988de56ccSmrg		add_shlibpath="$dir"
686088de56ccSmrg		add="-l$name"
686188de56ccSmrg	      else
686288de56ccSmrg		lib_linked=no
686388de56ccSmrg	      fi
686488de56ccSmrg	      ;;
686588de56ccSmrg	    *) lib_linked=no ;;
686688de56ccSmrg	    esac
686788de56ccSmrg
686888de56ccSmrg	    if test "$lib_linked" != yes; then
686988de56ccSmrg	      func_fatal_configuration "unsupported hardcode properties"
687088de56ccSmrg	    fi
687188de56ccSmrg
687288de56ccSmrg	    if test -n "$add_shlibpath"; then
687388de56ccSmrg	      case :$compile_shlibpath: in
687488de56ccSmrg	      *":$add_shlibpath:"*) ;;
6875e9fcaa8aSmrg	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
687688de56ccSmrg	      esac
687788de56ccSmrg	    fi
687888de56ccSmrg	    if test "$linkmode" = prog; then
687988de56ccSmrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
688088de56ccSmrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
688188de56ccSmrg	    else
688288de56ccSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
688388de56ccSmrg	      test -n "$add" && deplibs="$add $deplibs"
688488de56ccSmrg	      if test "$hardcode_direct" != yes &&
688588de56ccSmrg		 test "$hardcode_minus_L" != yes &&
688688de56ccSmrg		 test "$hardcode_shlibpath_var" = yes; then
688788de56ccSmrg		case :$finalize_shlibpath: in
688888de56ccSmrg		*":$libdir:"*) ;;
6889e9fcaa8aSmrg		*) func_append finalize_shlibpath "$libdir:" ;;
689088de56ccSmrg		esac
689188de56ccSmrg	      fi
689288de56ccSmrg	    fi
689388de56ccSmrg	  fi
689488de56ccSmrg
6895e9fcaa8aSmrg	  if test "$linkmode" = prog || test "$opt_mode" = relink; then
689688de56ccSmrg	    add_shlibpath=
689788de56ccSmrg	    add_dir=
689888de56ccSmrg	    add=
689988de56ccSmrg	    # Finalize command for both is simple: just hardcode it.
690088de56ccSmrg	    if test "$hardcode_direct" = yes &&
690188de56ccSmrg	       test "$hardcode_direct_absolute" = no; then
690288de56ccSmrg	      add="$libdir/$linklib"
690388de56ccSmrg	    elif test "$hardcode_minus_L" = yes; then
690488de56ccSmrg	      add_dir="-L$libdir"
690588de56ccSmrg	      add="-l$name"
690688de56ccSmrg	    elif test "$hardcode_shlibpath_var" = yes; then
690788de56ccSmrg	      case :$finalize_shlibpath: in
690888de56ccSmrg	      *":$libdir:"*) ;;
6909e9fcaa8aSmrg	      *) func_append finalize_shlibpath "$libdir:" ;;
691088de56ccSmrg	      esac
691188de56ccSmrg	      add="-l$name"
691288de56ccSmrg	    elif test "$hardcode_automatic" = yes; then
691388de56ccSmrg	      if test -n "$inst_prefix_dir" &&
691488de56ccSmrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
691588de56ccSmrg		add="$inst_prefix_dir$libdir/$linklib"
691688de56ccSmrg	      else
691788de56ccSmrg		add="$libdir/$linklib"
691888de56ccSmrg	      fi
691988de56ccSmrg	    else
692088de56ccSmrg	      # We cannot seem to hardcode it, guess we'll fake it.
692188de56ccSmrg	      add_dir="-L$libdir"
692288de56ccSmrg	      # Try looking first in the location we're being installed to.
692388de56ccSmrg	      if test -n "$inst_prefix_dir"; then
692488de56ccSmrg		case $libdir in
692588de56ccSmrg		  [\\/]*)
6926e9fcaa8aSmrg		    func_append add_dir " -L$inst_prefix_dir$libdir"
692788de56ccSmrg		    ;;
692888de56ccSmrg		esac
692988de56ccSmrg	      fi
693088de56ccSmrg	      add="-l$name"
693188de56ccSmrg	    fi
693288de56ccSmrg
693388de56ccSmrg	    if test "$linkmode" = prog; then
693488de56ccSmrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
693588de56ccSmrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
693688de56ccSmrg	    else
693788de56ccSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
693888de56ccSmrg	      test -n "$add" && deplibs="$add $deplibs"
693988de56ccSmrg	    fi
694088de56ccSmrg	  fi
694188de56ccSmrg	elif test "$linkmode" = prog; then
694288de56ccSmrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
694388de56ccSmrg	  # is not unsupported.  This is valid on all known static and
694488de56ccSmrg	  # shared platforms.
694588de56ccSmrg	  if test "$hardcode_direct" != unsupported; then
694688de56ccSmrg	    test -n "$old_library" && linklib="$old_library"
694788de56ccSmrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
694888de56ccSmrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
694988de56ccSmrg	  else
695088de56ccSmrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
695188de56ccSmrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
695288de56ccSmrg	  fi
695388de56ccSmrg	elif test "$build_libtool_libs" = yes; then
695488de56ccSmrg	  # Not a shared library
695588de56ccSmrg	  if test "$deplibs_check_method" != pass_all; then
695688de56ccSmrg	    # We're trying link a shared library against a static one
695788de56ccSmrg	    # but the system doesn't support it.
695888de56ccSmrg
695988de56ccSmrg	    # Just print a warning and add the library to dependency_libs so
696088de56ccSmrg	    # that the program can be linked against the static library.
6961e9fcaa8aSmrg	    echo
696288de56ccSmrg	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
6963e9fcaa8aSmrg	    echo "*** I have the capability to make that library automatically link in when"
6964e9fcaa8aSmrg	    echo "*** you link to this library.  But I can only do this if you have a"
6965e9fcaa8aSmrg	    echo "*** shared version of the library, which you do not appear to have."
696688de56ccSmrg	    if test "$module" = yes; then
6967e9fcaa8aSmrg	      echo "*** But as you try to build a module library, libtool will still create "
6968e9fcaa8aSmrg	      echo "*** a static module, that should work as long as the dlopening application"
6969e9fcaa8aSmrg	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
697088de56ccSmrg	      if test -z "$global_symbol_pipe"; then
6971e9fcaa8aSmrg		echo
6972e9fcaa8aSmrg		echo "*** However, this would only work if libtool was able to extract symbol"
6973e9fcaa8aSmrg		echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
6974e9fcaa8aSmrg		echo "*** not find such a program.  So, this module is probably useless."
6975e9fcaa8aSmrg		echo "*** \`nm' from GNU binutils and a full rebuild may help."
697688de56ccSmrg	      fi
697788de56ccSmrg	      if test "$build_old_libs" = no; then
697888de56ccSmrg		build_libtool_libs=module
697988de56ccSmrg		build_old_libs=yes
698088de56ccSmrg	      else
698188de56ccSmrg		build_libtool_libs=no
698288de56ccSmrg	      fi
698388de56ccSmrg	    fi
698488de56ccSmrg	  else
698588de56ccSmrg	    deplibs="$dir/$old_library $deplibs"
698688de56ccSmrg	    link_static=yes
698788de56ccSmrg	  fi
698888de56ccSmrg	fi # link shared/static library?
698988de56ccSmrg
699088de56ccSmrg	if test "$linkmode" = lib; then
699188de56ccSmrg	  if test -n "$dependency_libs" &&
699288de56ccSmrg	     { test "$hardcode_into_libs" != yes ||
699388de56ccSmrg	       test "$build_old_libs" = yes ||
699488de56ccSmrg	       test "$link_static" = yes; }; then
699588de56ccSmrg	    # Extract -R from dependency_libs
699688de56ccSmrg	    temp_deplibs=
699788de56ccSmrg	    for libdir in $dependency_libs; do
699888de56ccSmrg	      case $libdir in
699988de56ccSmrg	      -R*) func_stripname '-R' '' "$libdir"
700088de56ccSmrg	           temp_xrpath=$func_stripname_result
700188de56ccSmrg		   case " $xrpath " in
700288de56ccSmrg		   *" $temp_xrpath "*) ;;
7003e9fcaa8aSmrg		   *) func_append xrpath " $temp_xrpath";;
700488de56ccSmrg		   esac;;
7005e9fcaa8aSmrg	      *) func_append temp_deplibs " $libdir";;
700688de56ccSmrg	      esac
700788de56ccSmrg	    done
700888de56ccSmrg	    dependency_libs="$temp_deplibs"
700988de56ccSmrg	  fi
701088de56ccSmrg
7011e9fcaa8aSmrg	  func_append newlib_search_path " $absdir"
701288de56ccSmrg	  # Link against this library
701388de56ccSmrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
701488de56ccSmrg	  # ... and its dependency_libs
701588de56ccSmrg	  tmp_libs=
701688de56ccSmrg	  for deplib in $dependency_libs; do
701788de56ccSmrg	    newdependency_libs="$deplib $newdependency_libs"
7018e9fcaa8aSmrg	    case $deplib in
7019e9fcaa8aSmrg              -L*) func_stripname '-L' '' "$deplib"
7020e9fcaa8aSmrg                   func_resolve_sysroot "$func_stripname_result";;
7021e9fcaa8aSmrg              *) func_resolve_sysroot "$deplib" ;;
7022e9fcaa8aSmrg            esac
7023e9fcaa8aSmrg	    if $opt_preserve_dup_deps ; then
702488de56ccSmrg	      case "$tmp_libs " in
7025e9fcaa8aSmrg	      *" $func_resolve_sysroot_result "*)
7026e9fcaa8aSmrg                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
702788de56ccSmrg	      esac
702888de56ccSmrg	    fi
7029e9fcaa8aSmrg	    func_append tmp_libs " $func_resolve_sysroot_result"
703088de56ccSmrg	  done
703188de56ccSmrg
703288de56ccSmrg	  if test "$link_all_deplibs" != no; then
703388de56ccSmrg	    # Add the search paths of all dependency libraries
703488de56ccSmrg	    for deplib in $dependency_libs; do
703547f86ac1Smrg	      path=
703688de56ccSmrg	      case $deplib in
703788de56ccSmrg	      -L*) path="$deplib" ;;
703888de56ccSmrg	      *.la)
7039e9fcaa8aSmrg	        func_resolve_sysroot "$deplib"
7040e9fcaa8aSmrg	        deplib=$func_resolve_sysroot_result
704188de56ccSmrg	        func_dirname "$deplib" "" "."
7042e9fcaa8aSmrg		dir=$func_dirname_result
704388de56ccSmrg		# We need an absolute path.
704488de56ccSmrg		case $dir in
704588de56ccSmrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
704688de56ccSmrg		*)
704788de56ccSmrg		  absdir=`cd "$dir" && pwd`
704888de56ccSmrg		  if test -z "$absdir"; then
704988de56ccSmrg		    func_warning "cannot determine absolute directory name of \`$dir'"
705088de56ccSmrg		    absdir="$dir"
705188de56ccSmrg		  fi
705288de56ccSmrg		  ;;
705388de56ccSmrg		esac
705488de56ccSmrg		if $GREP "^installed=no" $deplib > /dev/null; then
705588de56ccSmrg		case $host in
705688de56ccSmrg		*-*-darwin*)
705788de56ccSmrg		  depdepl=
705888de56ccSmrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
705988de56ccSmrg		  if test -n "$deplibrary_names" ; then
706088de56ccSmrg		    for tmp in $deplibrary_names ; do
706188de56ccSmrg		      depdepl=$tmp
706288de56ccSmrg		    done
706388de56ccSmrg		    if test -f "$absdir/$objdir/$depdepl" ; then
706488de56ccSmrg		      depdepl="$absdir/$objdir/$depdepl"
706588de56ccSmrg		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
706688de56ccSmrg                      if test -z "$darwin_install_name"; then
706788de56ccSmrg                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
706888de56ccSmrg                      fi
7069e9fcaa8aSmrg		      func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
7070e9fcaa8aSmrg		      func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
707188de56ccSmrg		      path=
707288de56ccSmrg		    fi
707388de56ccSmrg		  fi
707488de56ccSmrg		  ;;
707588de56ccSmrg		*)
707688de56ccSmrg		  path="-L$absdir/$objdir"
707788de56ccSmrg		  ;;
707888de56ccSmrg		esac
707988de56ccSmrg		else
708088de56ccSmrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
708188de56ccSmrg		  test -z "$libdir" && \
708288de56ccSmrg		    func_fatal_error "\`$deplib' is not a valid libtool archive"
708388de56ccSmrg		  test "$absdir" != "$libdir" && \
708488de56ccSmrg		    func_warning "\`$deplib' seems to be moved"
708588de56ccSmrg
708688de56ccSmrg		  path="-L$absdir"
708788de56ccSmrg		fi
708888de56ccSmrg		;;
708988de56ccSmrg	      esac
709088de56ccSmrg	      case " $deplibs " in
709188de56ccSmrg	      *" $path "*) ;;
709288de56ccSmrg	      *) deplibs="$path $deplibs" ;;
709388de56ccSmrg	      esac
709488de56ccSmrg	    done
709588de56ccSmrg	  fi # link_all_deplibs != no
709688de56ccSmrg	fi # linkmode = lib
709788de56ccSmrg      done # for deplib in $libs
709888de56ccSmrg      if test "$pass" = link; then
709988de56ccSmrg	if test "$linkmode" = "prog"; then
710088de56ccSmrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
710188de56ccSmrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
710288de56ccSmrg	else
7103e9fcaa8aSmrg	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
710488de56ccSmrg	fi
710588de56ccSmrg      fi
710688de56ccSmrg      dependency_libs="$newdependency_libs"
710788de56ccSmrg      if test "$pass" = dlpreopen; then
710888de56ccSmrg	# Link the dlpreopened libraries before other libraries
710988de56ccSmrg	for deplib in $save_deplibs; do
711088de56ccSmrg	  deplibs="$deplib $deplibs"
711188de56ccSmrg	done
711288de56ccSmrg      fi
711388de56ccSmrg      if test "$pass" != dlopen; then
711488de56ccSmrg	if test "$pass" != conv; then
711588de56ccSmrg	  # Make sure lib_search_path contains only unique directories.
711688de56ccSmrg	  lib_search_path=
711788de56ccSmrg	  for dir in $newlib_search_path; do
711888de56ccSmrg	    case "$lib_search_path " in
711988de56ccSmrg	    *" $dir "*) ;;
7120e9fcaa8aSmrg	    *) func_append lib_search_path " $dir" ;;
712188de56ccSmrg	    esac
712288de56ccSmrg	  done
712388de56ccSmrg	  newlib_search_path=
712488de56ccSmrg	fi
712588de56ccSmrg
712688de56ccSmrg	if test "$linkmode,$pass" != "prog,link"; then
712788de56ccSmrg	  vars="deplibs"
712888de56ccSmrg	else
712988de56ccSmrg	  vars="compile_deplibs finalize_deplibs"
713088de56ccSmrg	fi
713188de56ccSmrg	for var in $vars dependency_libs; do
713288de56ccSmrg	  # Add libraries to $var in reverse order
713388de56ccSmrg	  eval tmp_libs=\"\$$var\"
713488de56ccSmrg	  new_libs=
713588de56ccSmrg	  for deplib in $tmp_libs; do
713688de56ccSmrg	    # FIXME: Pedantically, this is the right thing to do, so
713788de56ccSmrg	    #        that some nasty dependency loop isn't accidentally
713888de56ccSmrg	    #        broken:
713988de56ccSmrg	    #new_libs="$deplib $new_libs"
714088de56ccSmrg	    # Pragmatically, this seems to cause very few problems in
714188de56ccSmrg	    # practice:
714288de56ccSmrg	    case $deplib in
714388de56ccSmrg	    -L*) new_libs="$deplib $new_libs" ;;
714488de56ccSmrg	    -R*) ;;
714588de56ccSmrg	    *)
714688de56ccSmrg	      # And here is the reason: when a library appears more
714788de56ccSmrg	      # than once as an explicit dependence of a library, or
714888de56ccSmrg	      # is implicitly linked in more than once by the
714988de56ccSmrg	      # compiler, it is considered special, and multiple
715088de56ccSmrg	      # occurrences thereof are not removed.  Compare this
715188de56ccSmrg	      # with having the same library being listed as a
715288de56ccSmrg	      # dependency of multiple other libraries: in this case,
715388de56ccSmrg	      # we know (pedantically, we assume) the library does not
715488de56ccSmrg	      # need to be listed more than once, so we keep only the
715588de56ccSmrg	      # last copy.  This is not always right, but it is rare
715688de56ccSmrg	      # enough that we require users that really mean to play
715788de56ccSmrg	      # such unportable linking tricks to link the library
715888de56ccSmrg	      # using -Wl,-lname, so that libtool does not consider it
715988de56ccSmrg	      # for duplicate removal.
716088de56ccSmrg	      case " $specialdeplibs " in
716188de56ccSmrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
716288de56ccSmrg	      *)
716388de56ccSmrg		case " $new_libs " in
716488de56ccSmrg		*" $deplib "*) ;;
716588de56ccSmrg		*) new_libs="$deplib $new_libs" ;;
716688de56ccSmrg		esac
716788de56ccSmrg		;;
716888de56ccSmrg	      esac
716988de56ccSmrg	      ;;
717088de56ccSmrg	    esac
717188de56ccSmrg	  done
717288de56ccSmrg	  tmp_libs=
717388de56ccSmrg	  for deplib in $new_libs; do
717488de56ccSmrg	    case $deplib in
717588de56ccSmrg	    -L*)
717688de56ccSmrg	      case " $tmp_libs " in
717788de56ccSmrg	      *" $deplib "*) ;;
7178e9fcaa8aSmrg	      *) func_append tmp_libs " $deplib" ;;
717988de56ccSmrg	      esac
718088de56ccSmrg	      ;;
7181e9fcaa8aSmrg	    *) func_append tmp_libs " $deplib" ;;
718288de56ccSmrg	    esac
718388de56ccSmrg	  done
718488de56ccSmrg	  eval $var=\"$tmp_libs\"
718588de56ccSmrg	done # for var
718688de56ccSmrg      fi
718788de56ccSmrg      # Last step: remove runtime libs from dependency_libs
718888de56ccSmrg      # (they stay in deplibs)
718988de56ccSmrg      tmp_libs=
719088de56ccSmrg      for i in $dependency_libs ; do
719188de56ccSmrg	case " $predeps $postdeps $compiler_lib_search_path " in
719288de56ccSmrg	*" $i "*)
719388de56ccSmrg	  i=""
719488de56ccSmrg	  ;;
719588de56ccSmrg	esac
719688de56ccSmrg	if test -n "$i" ; then
7197e9fcaa8aSmrg	  func_append tmp_libs " $i"
719888de56ccSmrg	fi
719988de56ccSmrg      done
720088de56ccSmrg      dependency_libs=$tmp_libs
720188de56ccSmrg    done # for pass
720288de56ccSmrg    if test "$linkmode" = prog; then
720388de56ccSmrg      dlfiles="$newdlfiles"
720488de56ccSmrg    fi
720588de56ccSmrg    if test "$linkmode" = prog || test "$linkmode" = lib; then
720688de56ccSmrg      dlprefiles="$newdlprefiles"
720788de56ccSmrg    fi
720888de56ccSmrg
720988de56ccSmrg    case $linkmode in
721088de56ccSmrg    oldlib)
721188de56ccSmrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
721288de56ccSmrg	func_warning "\`-dlopen' is ignored for archives"
721388de56ccSmrg      fi
721488de56ccSmrg
721588de56ccSmrg      case " $deplibs" in
721688de56ccSmrg      *\ -l* | *\ -L*)
721788de56ccSmrg	func_warning "\`-l' and \`-L' are ignored for archives" ;;
721888de56ccSmrg      esac
721988de56ccSmrg
722088de56ccSmrg      test -n "$rpath" && \
722188de56ccSmrg	func_warning "\`-rpath' is ignored for archives"
722288de56ccSmrg
722388de56ccSmrg      test -n "$xrpath" && \
722488de56ccSmrg	func_warning "\`-R' is ignored for archives"
722588de56ccSmrg
722688de56ccSmrg      test -n "$vinfo" && \
722788de56ccSmrg	func_warning "\`-version-info/-version-number' is ignored for archives"
722888de56ccSmrg
722988de56ccSmrg      test -n "$release" && \
723088de56ccSmrg	func_warning "\`-release' is ignored for archives"
723188de56ccSmrg
723288de56ccSmrg      test -n "$export_symbols$export_symbols_regex" && \
723388de56ccSmrg	func_warning "\`-export-symbols' is ignored for archives"
723488de56ccSmrg
723588de56ccSmrg      # Now set the variables for building old libraries.
723688de56ccSmrg      build_libtool_libs=no
723788de56ccSmrg      oldlibs="$output"
7238e9fcaa8aSmrg      func_append objs "$old_deplibs"
723988de56ccSmrg      ;;
724088de56ccSmrg
724188de56ccSmrg    lib)
724288de56ccSmrg      # Make sure we only generate libraries of the form `libNAME.la'.
724388de56ccSmrg      case $outputname in
724488de56ccSmrg      lib*)
724588de56ccSmrg	func_stripname 'lib' '.la' "$outputname"
724688de56ccSmrg	name=$func_stripname_result
724788de56ccSmrg	eval shared_ext=\"$shrext_cmds\"
724888de56ccSmrg	eval libname=\"$libname_spec\"
724988de56ccSmrg	;;
725088de56ccSmrg      *)
725188de56ccSmrg	test "$module" = no && \
725288de56ccSmrg	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
725388de56ccSmrg
725488de56ccSmrg	if test "$need_lib_prefix" != no; then
725588de56ccSmrg	  # Add the "lib" prefix for modules if required
725688de56ccSmrg	  func_stripname '' '.la' "$outputname"
725788de56ccSmrg	  name=$func_stripname_result
725888de56ccSmrg	  eval shared_ext=\"$shrext_cmds\"
725988de56ccSmrg	  eval libname=\"$libname_spec\"
726088de56ccSmrg	else
726188de56ccSmrg	  func_stripname '' '.la' "$outputname"
726288de56ccSmrg	  libname=$func_stripname_result
726388de56ccSmrg	fi
726488de56ccSmrg	;;
726588de56ccSmrg      esac
726688de56ccSmrg
726788de56ccSmrg      if test -n "$objs"; then
726888de56ccSmrg	if test "$deplibs_check_method" != pass_all; then
726988de56ccSmrg	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
727088de56ccSmrg	else
7271e9fcaa8aSmrg	  echo
727288de56ccSmrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
727388de56ccSmrg	  $ECHO "*** objects $objs is not portable!"
7274e9fcaa8aSmrg	  func_append libobjs " $objs"
727588de56ccSmrg	fi
727688de56ccSmrg      fi
727788de56ccSmrg
727888de56ccSmrg      test "$dlself" != no && \
727988de56ccSmrg	func_warning "\`-dlopen self' is ignored for libtool libraries"
728088de56ccSmrg
728188de56ccSmrg      set dummy $rpath
728288de56ccSmrg      shift
728388de56ccSmrg      test "$#" -gt 1 && \
728488de56ccSmrg	func_warning "ignoring multiple \`-rpath's for a libtool library"
728588de56ccSmrg
728688de56ccSmrg      install_libdir="$1"
728788de56ccSmrg
728888de56ccSmrg      oldlibs=
728988de56ccSmrg      if test -z "$rpath"; then
729088de56ccSmrg	if test "$build_libtool_libs" = yes; then
729188de56ccSmrg	  # Building a libtool convenience library.
729288de56ccSmrg	  # Some compilers have problems with a `.al' extension so
729388de56ccSmrg	  # convenience libraries should have the same extension an
729488de56ccSmrg	  # archive normally would.
729588de56ccSmrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
729688de56ccSmrg	  build_libtool_libs=convenience
729788de56ccSmrg	  build_old_libs=yes
729888de56ccSmrg	fi
729988de56ccSmrg
730088de56ccSmrg	test -n "$vinfo" && \
730188de56ccSmrg	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
730288de56ccSmrg
730388de56ccSmrg	test -n "$release" && \
730488de56ccSmrg	  func_warning "\`-release' is ignored for convenience libraries"
730588de56ccSmrg      else
730688de56ccSmrg
730788de56ccSmrg	# Parse the version information argument.
730888de56ccSmrg	save_ifs="$IFS"; IFS=':'
730988de56ccSmrg	set dummy $vinfo 0 0 0
731088de56ccSmrg	shift
731188de56ccSmrg	IFS="$save_ifs"
731288de56ccSmrg
731388de56ccSmrg	test -n "$7" && \
731488de56ccSmrg	  func_fatal_help "too many parameters to \`-version-info'"
731588de56ccSmrg
731688de56ccSmrg	# convert absolute version numbers to libtool ages
731788de56ccSmrg	# this retains compatibility with .la files and attempts
731888de56ccSmrg	# to make the code below a bit more comprehensible
731988de56ccSmrg
732088de56ccSmrg	case $vinfo_number in
732188de56ccSmrg	yes)
732288de56ccSmrg	  number_major="$1"
732388de56ccSmrg	  number_minor="$2"
732488de56ccSmrg	  number_revision="$3"
732588de56ccSmrg	  #
732688de56ccSmrg	  # There are really only two kinds -- those that
732788de56ccSmrg	  # use the current revision as the major version
732888de56ccSmrg	  # and those that subtract age and use age as
732988de56ccSmrg	  # a minor version.  But, then there is irix
733088de56ccSmrg	  # which has an extra 1 added just for fun
733188de56ccSmrg	  #
733288de56ccSmrg	  case $version_type in
7333eb411b4bSmrg	  # correct linux to gnu/linux during the next big refactor
733488de56ccSmrg	  darwin|linux|osf|windows|none)
733588de56ccSmrg	    func_arith $number_major + $number_minor
733688de56ccSmrg	    current=$func_arith_result
733788de56ccSmrg	    age="$number_minor"
733888de56ccSmrg	    revision="$number_revision"
733988de56ccSmrg	    ;;
7340e9fcaa8aSmrg	  freebsd-aout|freebsd-elf|qnx|sunos)
734188de56ccSmrg	    current="$number_major"
734288de56ccSmrg	    revision="$number_minor"
734388de56ccSmrg	    age="0"
734488de56ccSmrg	    ;;
734588de56ccSmrg	  irix|nonstopux)
734688de56ccSmrg	    func_arith $number_major + $number_minor
734788de56ccSmrg	    current=$func_arith_result
734888de56ccSmrg	    age="$number_minor"
734988de56ccSmrg	    revision="$number_minor"
735088de56ccSmrg	    lt_irix_increment=no
735188de56ccSmrg	    ;;
735288de56ccSmrg	  esac
735388de56ccSmrg	  ;;
735488de56ccSmrg	no)
735588de56ccSmrg	  current="$1"
735688de56ccSmrg	  revision="$2"
735788de56ccSmrg	  age="$3"
735888de56ccSmrg	  ;;
735988de56ccSmrg	esac
736088de56ccSmrg
736188de56ccSmrg	# Check that each of the things are valid numbers.
736288de56ccSmrg	case $current in
736388de56ccSmrg	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]) ;;
736488de56ccSmrg	*)
736588de56ccSmrg	  func_error "CURRENT \`$current' must be a nonnegative integer"
736688de56ccSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
736788de56ccSmrg	  ;;
736888de56ccSmrg	esac
736988de56ccSmrg
737088de56ccSmrg	case $revision in
737188de56ccSmrg	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]) ;;
737288de56ccSmrg	*)
737388de56ccSmrg	  func_error "REVISION \`$revision' must be a nonnegative integer"
737488de56ccSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
737588de56ccSmrg	  ;;
737688de56ccSmrg	esac
737788de56ccSmrg
737888de56ccSmrg	case $age in
737988de56ccSmrg	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]) ;;
738088de56ccSmrg	*)
738188de56ccSmrg	  func_error "AGE \`$age' must be a nonnegative integer"
738288de56ccSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
738388de56ccSmrg	  ;;
738488de56ccSmrg	esac
738588de56ccSmrg
738688de56ccSmrg	if test "$age" -gt "$current"; then
738788de56ccSmrg	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
738888de56ccSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
738988de56ccSmrg	fi
739088de56ccSmrg
739188de56ccSmrg	# Calculate the version variables.
739288de56ccSmrg	major=
739388de56ccSmrg	versuffix=
739488de56ccSmrg	verstring=
739588de56ccSmrg	case $version_type in
739688de56ccSmrg	none) ;;
739788de56ccSmrg
739888de56ccSmrg	darwin)
739988de56ccSmrg	  # Like Linux, but with the current version available in
740088de56ccSmrg	  # verstring for coding it into the library header
740188de56ccSmrg	  func_arith $current - $age
740288de56ccSmrg	  major=.$func_arith_result
740388de56ccSmrg	  versuffix="$major.$age.$revision"
740488de56ccSmrg	  # Darwin ld doesn't like 0 for these options...
740588de56ccSmrg	  func_arith $current + 1
740688de56ccSmrg	  minor_current=$func_arith_result
740788de56ccSmrg	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
740888de56ccSmrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
740988de56ccSmrg	  ;;
741088de56ccSmrg
741188de56ccSmrg	freebsd-aout)
741288de56ccSmrg	  major=".$current"
741388de56ccSmrg	  versuffix=".$current.$revision";
741488de56ccSmrg	  ;;
741588de56ccSmrg
741688de56ccSmrg	freebsd-elf)
741788de56ccSmrg	  major=".$current"
741888de56ccSmrg	  versuffix=".$current"
741988de56ccSmrg	  ;;
742088de56ccSmrg
742188de56ccSmrg	irix | nonstopux)
742288de56ccSmrg	  if test "X$lt_irix_increment" = "Xno"; then
742388de56ccSmrg	    func_arith $current - $age
742488de56ccSmrg	  else
742588de56ccSmrg	    func_arith $current - $age + 1
742688de56ccSmrg	  fi
742788de56ccSmrg	  major=$func_arith_result
742888de56ccSmrg
742988de56ccSmrg	  case $version_type in
743088de56ccSmrg	    nonstopux) verstring_prefix=nonstopux ;;
743188de56ccSmrg	    *)         verstring_prefix=sgi ;;
743288de56ccSmrg	  esac
743388de56ccSmrg	  verstring="$verstring_prefix$major.$revision"
743488de56ccSmrg
743588de56ccSmrg	  # Add in all the interfaces that we are compatible with.
743688de56ccSmrg	  loop=$revision
743788de56ccSmrg	  while test "$loop" -ne 0; do
743888de56ccSmrg	    func_arith $revision - $loop
743988de56ccSmrg	    iface=$func_arith_result
744088de56ccSmrg	    func_arith $loop - 1
744188de56ccSmrg	    loop=$func_arith_result
744288de56ccSmrg	    verstring="$verstring_prefix$major.$iface:$verstring"
744388de56ccSmrg	  done
744488de56ccSmrg
744588de56ccSmrg	  # Before this point, $major must not contain `.'.
744688de56ccSmrg	  major=.$major
744788de56ccSmrg	  versuffix="$major.$revision"
744888de56ccSmrg	  ;;
744988de56ccSmrg
7450eb411b4bSmrg	linux) # correct to gnu/linux during the next big refactor
745188de56ccSmrg	  func_arith $current - $age
745288de56ccSmrg	  major=.$func_arith_result
745388de56ccSmrg	  versuffix="$major.$age.$revision"
745488de56ccSmrg	  ;;
745588de56ccSmrg
745688de56ccSmrg	osf)
745788de56ccSmrg	  func_arith $current - $age
745888de56ccSmrg	  major=.$func_arith_result
745988de56ccSmrg	  versuffix=".$current.$age.$revision"
746088de56ccSmrg	  verstring="$current.$age.$revision"
746188de56ccSmrg
746288de56ccSmrg	  # Add in all the interfaces that we are compatible with.
746388de56ccSmrg	  loop=$age
746488de56ccSmrg	  while test "$loop" -ne 0; do
746588de56ccSmrg	    func_arith $current - $loop
746688de56ccSmrg	    iface=$func_arith_result
746788de56ccSmrg	    func_arith $loop - 1
746888de56ccSmrg	    loop=$func_arith_result
746988de56ccSmrg	    verstring="$verstring:${iface}.0"
747088de56ccSmrg	  done
747188de56ccSmrg
747288de56ccSmrg	  # Make executables depend on our current version.
7473e9fcaa8aSmrg	  func_append verstring ":${current}.0"
747488de56ccSmrg	  ;;
747588de56ccSmrg
747688de56ccSmrg	qnx)
747788de56ccSmrg	  major=".$current"
747888de56ccSmrg	  versuffix=".$current"
747988de56ccSmrg	  ;;
748088de56ccSmrg
748188de56ccSmrg	sunos)
748288de56ccSmrg	  major=".$current"
748388de56ccSmrg	  versuffix=".$current.$revision"
748488de56ccSmrg	  ;;
748588de56ccSmrg
748688de56ccSmrg	windows)
748788de56ccSmrg	  # Use '-' rather than '.', since we only want one
748888de56ccSmrg	  # extension on DOS 8.3 filesystems.
748988de56ccSmrg	  func_arith $current - $age
749088de56ccSmrg	  major=$func_arith_result
749188de56ccSmrg	  versuffix="-$major"
749288de56ccSmrg	  ;;
749388de56ccSmrg
749488de56ccSmrg	*)
749588de56ccSmrg	  func_fatal_configuration "unknown library version type \`$version_type'"
749688de56ccSmrg	  ;;
749788de56ccSmrg	esac
749888de56ccSmrg
749988de56ccSmrg	# Clear the version info if we defaulted, and they specified a release.
750088de56ccSmrg	if test -z "$vinfo" && test -n "$release"; then
750188de56ccSmrg	  major=
750288de56ccSmrg	  case $version_type in
750388de56ccSmrg	  darwin)
750488de56ccSmrg	    # we can't check for "0.0" in archive_cmds due to quoting
750588de56ccSmrg	    # problems, so we reset it completely
750688de56ccSmrg	    verstring=
750788de56ccSmrg	    ;;
750888de56ccSmrg	  *)
750988de56ccSmrg	    verstring="0.0"
751088de56ccSmrg	    ;;
751188de56ccSmrg	  esac
751288de56ccSmrg	  if test "$need_version" = no; then
751388de56ccSmrg	    versuffix=
751488de56ccSmrg	  else
751588de56ccSmrg	    versuffix=".0.0"
751688de56ccSmrg	  fi
751788de56ccSmrg	fi
751888de56ccSmrg
751988de56ccSmrg	# Remove version info from name if versioning should be avoided
752088de56ccSmrg	if test "$avoid_version" = yes && test "$need_version" = no; then
752188de56ccSmrg	  major=
752288de56ccSmrg	  versuffix=
752388de56ccSmrg	  verstring=""
752488de56ccSmrg	fi
752588de56ccSmrg
752688de56ccSmrg	# Check to see if the archive will have undefined symbols.
752788de56ccSmrg	if test "$allow_undefined" = yes; then
752888de56ccSmrg	  if test "$allow_undefined_flag" = unsupported; then
752988de56ccSmrg	    func_warning "undefined symbols not allowed in $host shared libraries"
753088de56ccSmrg	    build_libtool_libs=no
753188de56ccSmrg	    build_old_libs=yes
753288de56ccSmrg	  fi
753388de56ccSmrg	else
753488de56ccSmrg	  # Don't allow undefined symbols.
753588de56ccSmrg	  allow_undefined_flag="$no_undefined_flag"
753688de56ccSmrg	fi
753788de56ccSmrg
753888de56ccSmrg      fi
753988de56ccSmrg
754088de56ccSmrg      func_generate_dlsyms "$libname" "$libname" "yes"
7541e9fcaa8aSmrg      func_append libobjs " $symfileobj"
754288de56ccSmrg      test "X$libobjs" = "X " && libobjs=
754388de56ccSmrg
7544e9fcaa8aSmrg      if test "$opt_mode" != relink; then
754588de56ccSmrg	# Remove our outputs, but don't remove object files since they
754688de56ccSmrg	# may have been created when compiling PIC objects.
754788de56ccSmrg	removelist=
754888de56ccSmrg	tempremovelist=`$ECHO "$output_objdir/*"`
754988de56ccSmrg	for p in $tempremovelist; do
755088de56ccSmrg	  case $p in
755188de56ccSmrg	    *.$objext | *.gcno)
755288de56ccSmrg	       ;;
755388de56ccSmrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
755488de56ccSmrg	       if test "X$precious_files_regex" != "X"; then
755588de56ccSmrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
755688de56ccSmrg		 then
755788de56ccSmrg		   continue
755888de56ccSmrg		 fi
755988de56ccSmrg	       fi
7560e9fcaa8aSmrg	       func_append removelist " $p"
756188de56ccSmrg	       ;;
756288de56ccSmrg	    *) ;;
756388de56ccSmrg	  esac
756488de56ccSmrg	done
756588de56ccSmrg	test -n "$removelist" && \
756688de56ccSmrg	  func_show_eval "${RM}r \$removelist"
756788de56ccSmrg      fi
756888de56ccSmrg
756988de56ccSmrg      # Now set the variables for building old libraries.
757088de56ccSmrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
7571e9fcaa8aSmrg	func_append oldlibs " $output_objdir/$libname.$libext"
757288de56ccSmrg
757388de56ccSmrg	# Transform .lo files to .o files.
7574e9fcaa8aSmrg	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
757588de56ccSmrg      fi
757688de56ccSmrg
757788de56ccSmrg      # Eliminate all temporary directories.
757888de56ccSmrg      #for path in $notinst_path; do
7579e9fcaa8aSmrg      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
7580e9fcaa8aSmrg      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
7581e9fcaa8aSmrg      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
758288de56ccSmrg      #done
758388de56ccSmrg
758488de56ccSmrg      if test -n "$xrpath"; then
758588de56ccSmrg	# If the user specified any rpath flags, then add them.
758688de56ccSmrg	temp_xrpath=
758788de56ccSmrg	for libdir in $xrpath; do
7588e9fcaa8aSmrg	  func_replace_sysroot "$libdir"
7589e9fcaa8aSmrg	  func_append temp_xrpath " -R$func_replace_sysroot_result"
759088de56ccSmrg	  case "$finalize_rpath " in
759188de56ccSmrg	  *" $libdir "*) ;;
7592e9fcaa8aSmrg	  *) func_append finalize_rpath " $libdir" ;;
759388de56ccSmrg	  esac
759488de56ccSmrg	done
759588de56ccSmrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
759688de56ccSmrg	  dependency_libs="$temp_xrpath $dependency_libs"
759788de56ccSmrg	fi
759888de56ccSmrg      fi
759988de56ccSmrg
760088de56ccSmrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
760188de56ccSmrg      old_dlfiles="$dlfiles"
760288de56ccSmrg      dlfiles=
760388de56ccSmrg      for lib in $old_dlfiles; do
760488de56ccSmrg	case " $dlprefiles $dlfiles " in
760588de56ccSmrg	*" $lib "*) ;;
7606e9fcaa8aSmrg	*) func_append dlfiles " $lib" ;;
760788de56ccSmrg	esac
760888de56ccSmrg      done
760988de56ccSmrg
761088de56ccSmrg      # Make sure dlprefiles contains only unique files
761188de56ccSmrg      old_dlprefiles="$dlprefiles"
761288de56ccSmrg      dlprefiles=
761388de56ccSmrg      for lib in $old_dlprefiles; do
761488de56ccSmrg	case "$dlprefiles " in
761588de56ccSmrg	*" $lib "*) ;;
7616e9fcaa8aSmrg	*) func_append dlprefiles " $lib" ;;
761788de56ccSmrg	esac
761888de56ccSmrg      done
761988de56ccSmrg
762088de56ccSmrg      if test "$build_libtool_libs" = yes; then
762188de56ccSmrg	if test -n "$rpath"; then
762288de56ccSmrg	  case $host in
7623e9fcaa8aSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
762488de56ccSmrg	    # these systems don't actually have a c library (as such)!
762588de56ccSmrg	    ;;
762688de56ccSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
762788de56ccSmrg	    # Rhapsody C library is in the System framework
7628e9fcaa8aSmrg	    func_append deplibs " System.ltframework"
762988de56ccSmrg	    ;;
763088de56ccSmrg	  *-*-netbsd*)
763188de56ccSmrg	    # Don't link with libc until the a.out ld.so is fixed.
763288de56ccSmrg	    ;;
763388de56ccSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
763488de56ccSmrg	    # Do not include libc due to us having libc/libc_r.
763588de56ccSmrg	    ;;
763688de56ccSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
763788de56ccSmrg	    # Causes problems with __ctype
763888de56ccSmrg	    ;;
763988de56ccSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
764088de56ccSmrg	    # Compiler inserts libc in the correct place for threads to work
764188de56ccSmrg	    ;;
764288de56ccSmrg	  *)
764388de56ccSmrg	    # Add libc to deplibs on all other systems if necessary.
764488de56ccSmrg	    if test "$build_libtool_need_lc" = "yes"; then
7645e9fcaa8aSmrg	      func_append deplibs " -lc"
764688de56ccSmrg	    fi
764788de56ccSmrg	    ;;
764888de56ccSmrg	  esac
764988de56ccSmrg	fi
765088de56ccSmrg
765188de56ccSmrg	# Transform deplibs into only deplibs that can be linked in shared.
765288de56ccSmrg	name_save=$name
765388de56ccSmrg	libname_save=$libname
765488de56ccSmrg	release_save=$release
765588de56ccSmrg	versuffix_save=$versuffix
765688de56ccSmrg	major_save=$major
765788de56ccSmrg	# I'm not sure if I'm treating the release correctly.  I think
765888de56ccSmrg	# release should show up in the -l (ie -lgmp5) so we don't want to
765988de56ccSmrg	# add it in twice.  Is that correct?
766088de56ccSmrg	release=""
766188de56ccSmrg	versuffix=""
766288de56ccSmrg	major=""
766388de56ccSmrg	newdeplibs=
766488de56ccSmrg	droppeddeps=no
766588de56ccSmrg	case $deplibs_check_method in
766688de56ccSmrg	pass_all)
766788de56ccSmrg	  # Don't check for shared/static.  Everything works.
766888de56ccSmrg	  # This might be a little naive.  We might want to check
766988de56ccSmrg	  # whether the library exists or not.  But this is on
767088de56ccSmrg	  # osf3 & osf4 and I'm not really sure... Just
767188de56ccSmrg	  # implementing what was already the behavior.
767288de56ccSmrg	  newdeplibs=$deplibs
767388de56ccSmrg	  ;;
767488de56ccSmrg	test_compile)
767588de56ccSmrg	  # This code stresses the "libraries are programs" paradigm to its
767688de56ccSmrg	  # limits. Maybe even breaks it.  We compile a program, linking it
767788de56ccSmrg	  # against the deplibs as a proxy for the library.  Then we can check
767888de56ccSmrg	  # whether they linked in statically or dynamically with ldd.
767988de56ccSmrg	  $opt_dry_run || $RM conftest.c
768088de56ccSmrg	  cat > conftest.c <<EOF
768188de56ccSmrg	  int main() { return 0; }
768288de56ccSmrgEOF
768388de56ccSmrg	  $opt_dry_run || $RM conftest
768488de56ccSmrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
768588de56ccSmrg	    ldd_output=`ldd conftest`
768688de56ccSmrg	    for i in $deplibs; do
768788de56ccSmrg	      case $i in
768888de56ccSmrg	      -l*)
768988de56ccSmrg		func_stripname -l '' "$i"
769088de56ccSmrg		name=$func_stripname_result
769188de56ccSmrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
769288de56ccSmrg		  case " $predeps $postdeps " in
769388de56ccSmrg		  *" $i "*)
7694e9fcaa8aSmrg		    func_append newdeplibs " $i"
769588de56ccSmrg		    i=""
769688de56ccSmrg		    ;;
769788de56ccSmrg		  esac
769888de56ccSmrg		fi
769988de56ccSmrg		if test -n "$i" ; then
770088de56ccSmrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
770188de56ccSmrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
770288de56ccSmrg		  set dummy $deplib_matches; shift
770388de56ccSmrg		  deplib_match=$1
770488de56ccSmrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7705e9fcaa8aSmrg		    func_append newdeplibs " $i"
770688de56ccSmrg		  else
770788de56ccSmrg		    droppeddeps=yes
7708e9fcaa8aSmrg		    echo
770988de56ccSmrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
7710e9fcaa8aSmrg		    echo "*** I have the capability to make that library automatically link in when"
7711e9fcaa8aSmrg		    echo "*** you link to this library.  But I can only do this if you have a"
7712e9fcaa8aSmrg		    echo "*** shared version of the library, which I believe you do not have"
7713e9fcaa8aSmrg		    echo "*** because a test_compile did reveal that the linker did not use it for"
7714e9fcaa8aSmrg		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
771588de56ccSmrg		  fi
771688de56ccSmrg		fi
771788de56ccSmrg		;;
771888de56ccSmrg	      *)
7719e9fcaa8aSmrg		func_append newdeplibs " $i"
772088de56ccSmrg		;;
772188de56ccSmrg	      esac
772288de56ccSmrg	    done
772388de56ccSmrg	  else
772488de56ccSmrg	    # Error occurred in the first compile.  Let's try to salvage
772588de56ccSmrg	    # the situation: Compile a separate program for each library.
772688de56ccSmrg	    for i in $deplibs; do
772788de56ccSmrg	      case $i in
772888de56ccSmrg	      -l*)
772988de56ccSmrg		func_stripname -l '' "$i"
773088de56ccSmrg		name=$func_stripname_result
773188de56ccSmrg		$opt_dry_run || $RM conftest
773288de56ccSmrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
773388de56ccSmrg		  ldd_output=`ldd conftest`
773488de56ccSmrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
773588de56ccSmrg		    case " $predeps $postdeps " in
773688de56ccSmrg		    *" $i "*)
7737e9fcaa8aSmrg		      func_append newdeplibs " $i"
773888de56ccSmrg		      i=""
773988de56ccSmrg		      ;;
774088de56ccSmrg		    esac
774188de56ccSmrg		  fi
774288de56ccSmrg		  if test -n "$i" ; then
774388de56ccSmrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
774488de56ccSmrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
774588de56ccSmrg		    set dummy $deplib_matches; shift
774688de56ccSmrg		    deplib_match=$1
774788de56ccSmrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7748e9fcaa8aSmrg		      func_append newdeplibs " $i"
774988de56ccSmrg		    else
775088de56ccSmrg		      droppeddeps=yes
7751e9fcaa8aSmrg		      echo
775288de56ccSmrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
7753e9fcaa8aSmrg		      echo "*** I have the capability to make that library automatically link in when"
7754e9fcaa8aSmrg		      echo "*** you link to this library.  But I can only do this if you have a"
7755e9fcaa8aSmrg		      echo "*** shared version of the library, which you do not appear to have"
7756e9fcaa8aSmrg		      echo "*** because a test_compile did reveal that the linker did not use this one"
7757e9fcaa8aSmrg		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
775888de56ccSmrg		    fi
775988de56ccSmrg		  fi
776088de56ccSmrg		else
776188de56ccSmrg		  droppeddeps=yes
7762e9fcaa8aSmrg		  echo
776388de56ccSmrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
7764e9fcaa8aSmrg		  echo "*** make it link in!  You will probably need to install it or some"
7765e9fcaa8aSmrg		  echo "*** library that it depends on before this library will be fully"
7766e9fcaa8aSmrg		  echo "*** functional.  Installing it before continuing would be even better."
776788de56ccSmrg		fi
776888de56ccSmrg		;;
776988de56ccSmrg	      *)
7770e9fcaa8aSmrg		func_append newdeplibs " $i"
777188de56ccSmrg		;;
777288de56ccSmrg	      esac
777388de56ccSmrg	    done
777488de56ccSmrg	  fi
777588de56ccSmrg	  ;;
777688de56ccSmrg	file_magic*)
777788de56ccSmrg	  set dummy $deplibs_check_method; shift
777888de56ccSmrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
777988de56ccSmrg	  for a_deplib in $deplibs; do
778088de56ccSmrg	    case $a_deplib in
778188de56ccSmrg	    -l*)
778288de56ccSmrg	      func_stripname -l '' "$a_deplib"
778388de56ccSmrg	      name=$func_stripname_result
778488de56ccSmrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
778588de56ccSmrg		case " $predeps $postdeps " in
778688de56ccSmrg		*" $a_deplib "*)
7787e9fcaa8aSmrg		  func_append newdeplibs " $a_deplib"
778888de56ccSmrg		  a_deplib=""
778988de56ccSmrg		  ;;
779088de56ccSmrg		esac
779188de56ccSmrg	      fi
779288de56ccSmrg	      if test -n "$a_deplib" ; then
779388de56ccSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
7794e9fcaa8aSmrg		if test -n "$file_magic_glob"; then
7795e9fcaa8aSmrg		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
7796e9fcaa8aSmrg		else
7797e9fcaa8aSmrg		  libnameglob=$libname
7798e9fcaa8aSmrg		fi
7799e9fcaa8aSmrg		test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
780088de56ccSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7801e9fcaa8aSmrg		  if test "$want_nocaseglob" = yes; then
7802e9fcaa8aSmrg		    shopt -s nocaseglob
7803e9fcaa8aSmrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7804e9fcaa8aSmrg		    $nocaseglob
7805e9fcaa8aSmrg		  else
7806e9fcaa8aSmrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7807e9fcaa8aSmrg		  fi
780888de56ccSmrg		  for potent_lib in $potential_libs; do
780988de56ccSmrg		      # Follow soft links.
781088de56ccSmrg		      if ls -lLd "$potent_lib" 2>/dev/null |
781188de56ccSmrg			 $GREP " -> " >/dev/null; then
781288de56ccSmrg			continue
781388de56ccSmrg		      fi
781488de56ccSmrg		      # The statement above tries to avoid entering an
781588de56ccSmrg		      # endless loop below, in case of cyclic links.
781688de56ccSmrg		      # We might still enter an endless loop, since a link
781788de56ccSmrg		      # loop can be closed while we follow links,
781888de56ccSmrg		      # but so what?
781988de56ccSmrg		      potlib="$potent_lib"
782088de56ccSmrg		      while test -h "$potlib" 2>/dev/null; do
782188de56ccSmrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
782288de56ccSmrg			case $potliblink in
782388de56ccSmrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
7824e9fcaa8aSmrg			*) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
782588de56ccSmrg			esac
782688de56ccSmrg		      done
782788de56ccSmrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
782888de56ccSmrg			 $SED -e 10q |
782988de56ccSmrg			 $EGREP "$file_magic_regex" > /dev/null; then
7830e9fcaa8aSmrg			func_append newdeplibs " $a_deplib"
783188de56ccSmrg			a_deplib=""
783288de56ccSmrg			break 2
783388de56ccSmrg		      fi
783488de56ccSmrg		  done
783588de56ccSmrg		done
783688de56ccSmrg	      fi
783788de56ccSmrg	      if test -n "$a_deplib" ; then
783888de56ccSmrg		droppeddeps=yes
7839e9fcaa8aSmrg		echo
784088de56ccSmrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
7841e9fcaa8aSmrg		echo "*** I have the capability to make that library automatically link in when"
7842e9fcaa8aSmrg		echo "*** you link to this library.  But I can only do this if you have a"
7843e9fcaa8aSmrg		echo "*** shared version of the library, which you do not appear to have"
7844e9fcaa8aSmrg		echo "*** because I did check the linker path looking for a file starting"
784588de56ccSmrg		if test -z "$potlib" ; then
784688de56ccSmrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
784788de56ccSmrg		else
784888de56ccSmrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
784988de56ccSmrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
785088de56ccSmrg		fi
785188de56ccSmrg	      fi
785288de56ccSmrg	      ;;
785388de56ccSmrg	    *)
785488de56ccSmrg	      # Add a -L argument.
7855e9fcaa8aSmrg	      func_append newdeplibs " $a_deplib"
785688de56ccSmrg	      ;;
785788de56ccSmrg	    esac
785888de56ccSmrg	  done # Gone through all deplibs.
785988de56ccSmrg	  ;;
786088de56ccSmrg	match_pattern*)
786188de56ccSmrg	  set dummy $deplibs_check_method; shift
786288de56ccSmrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
786388de56ccSmrg	  for a_deplib in $deplibs; do
786488de56ccSmrg	    case $a_deplib in
786588de56ccSmrg	    -l*)
786688de56ccSmrg	      func_stripname -l '' "$a_deplib"
786788de56ccSmrg	      name=$func_stripname_result
786888de56ccSmrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
786988de56ccSmrg		case " $predeps $postdeps " in
787088de56ccSmrg		*" $a_deplib "*)
7871e9fcaa8aSmrg		  func_append newdeplibs " $a_deplib"
787288de56ccSmrg		  a_deplib=""
787388de56ccSmrg		  ;;
787488de56ccSmrg		esac
787588de56ccSmrg	      fi
787688de56ccSmrg	      if test -n "$a_deplib" ; then
787788de56ccSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
787888de56ccSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
787988de56ccSmrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
788088de56ccSmrg		  for potent_lib in $potential_libs; do
788188de56ccSmrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
7882e9fcaa8aSmrg		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
788388de56ccSmrg		       $EGREP "$match_pattern_regex" > /dev/null; then
7884e9fcaa8aSmrg		      func_append newdeplibs " $a_deplib"
788588de56ccSmrg		      a_deplib=""
788688de56ccSmrg		      break 2
788788de56ccSmrg		    fi
788888de56ccSmrg		  done
788988de56ccSmrg		done
789088de56ccSmrg	      fi
789188de56ccSmrg	      if test -n "$a_deplib" ; then
789288de56ccSmrg		droppeddeps=yes
7893e9fcaa8aSmrg		echo
789488de56ccSmrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
7895e9fcaa8aSmrg		echo "*** I have the capability to make that library automatically link in when"
7896e9fcaa8aSmrg		echo "*** you link to this library.  But I can only do this if you have a"
7897e9fcaa8aSmrg		echo "*** shared version of the library, which you do not appear to have"
7898e9fcaa8aSmrg		echo "*** because I did check the linker path looking for a file starting"
789988de56ccSmrg		if test -z "$potlib" ; then
790088de56ccSmrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
790188de56ccSmrg		else
790288de56ccSmrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
790388de56ccSmrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
790488de56ccSmrg		fi
790588de56ccSmrg	      fi
790688de56ccSmrg	      ;;
790788de56ccSmrg	    *)
790888de56ccSmrg	      # Add a -L argument.
7909e9fcaa8aSmrg	      func_append newdeplibs " $a_deplib"
791088de56ccSmrg	      ;;
791188de56ccSmrg	    esac
791288de56ccSmrg	  done # Gone through all deplibs.
791388de56ccSmrg	  ;;
791488de56ccSmrg	none | unknown | *)
791588de56ccSmrg	  newdeplibs=""
7916e9fcaa8aSmrg	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
791788de56ccSmrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
791888de56ccSmrg	    for i in $predeps $postdeps ; do
791988de56ccSmrg	      # can't use Xsed below, because $i might contain '/'
7920e9fcaa8aSmrg	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
792188de56ccSmrg	    done
792288de56ccSmrg	  fi
7923e9fcaa8aSmrg	  case $tmp_deplibs in
7924e9fcaa8aSmrg	  *[!\	\ ]*)
7925e9fcaa8aSmrg	    echo
792688de56ccSmrg	    if test "X$deplibs_check_method" = "Xnone"; then
7927e9fcaa8aSmrg	      echo "*** Warning: inter-library dependencies are not supported in this platform."
792888de56ccSmrg	    else
7929e9fcaa8aSmrg	      echo "*** Warning: inter-library dependencies are not known to be supported."
793088de56ccSmrg	    fi
7931e9fcaa8aSmrg	    echo "*** All declared inter-library dependencies are being dropped."
793288de56ccSmrg	    droppeddeps=yes
7933e9fcaa8aSmrg	    ;;
7934e9fcaa8aSmrg	  esac
793588de56ccSmrg	  ;;
793688de56ccSmrg	esac
793788de56ccSmrg	versuffix=$versuffix_save
793888de56ccSmrg	major=$major_save
793988de56ccSmrg	release=$release_save
794088de56ccSmrg	libname=$libname_save
794188de56ccSmrg	name=$name_save
794288de56ccSmrg
794388de56ccSmrg	case $host in
794488de56ccSmrg	*-*-rhapsody* | *-*-darwin1.[012])
794588de56ccSmrg	  # On Rhapsody replace the C library with the System framework
7946e9fcaa8aSmrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
794788de56ccSmrg	  ;;
794888de56ccSmrg	esac
794988de56ccSmrg
795088de56ccSmrg	if test "$droppeddeps" = yes; then
795188de56ccSmrg	  if test "$module" = yes; then
7952e9fcaa8aSmrg	    echo
7953e9fcaa8aSmrg	    echo "*** Warning: libtool could not satisfy all declared inter-library"
795488de56ccSmrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
7955e9fcaa8aSmrg	    echo "*** a static module, that should work as long as the dlopening"
7956e9fcaa8aSmrg	    echo "*** application is linked with the -dlopen flag."
795788de56ccSmrg	    if test -z "$global_symbol_pipe"; then
7958e9fcaa8aSmrg	      echo
7959e9fcaa8aSmrg	      echo "*** However, this would only work if libtool was able to extract symbol"
7960e9fcaa8aSmrg	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
7961e9fcaa8aSmrg	      echo "*** not find such a program.  So, this module is probably useless."
7962e9fcaa8aSmrg	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
796388de56ccSmrg	    fi
796488de56ccSmrg	    if test "$build_old_libs" = no; then
796588de56ccSmrg	      oldlibs="$output_objdir/$libname.$libext"
796688de56ccSmrg	      build_libtool_libs=module
796788de56ccSmrg	      build_old_libs=yes
796888de56ccSmrg	    else
796988de56ccSmrg	      build_libtool_libs=no
797088de56ccSmrg	    fi
797188de56ccSmrg	  else
7972e9fcaa8aSmrg	    echo "*** The inter-library dependencies that have been dropped here will be"
7973e9fcaa8aSmrg	    echo "*** automatically added whenever a program is linked with this library"
7974e9fcaa8aSmrg	    echo "*** or is declared to -dlopen it."
797588de56ccSmrg
797688de56ccSmrg	    if test "$allow_undefined" = no; then
7977e9fcaa8aSmrg	      echo
7978e9fcaa8aSmrg	      echo "*** Since this library must not contain undefined symbols,"
7979e9fcaa8aSmrg	      echo "*** because either the platform does not support them or"
7980e9fcaa8aSmrg	      echo "*** it was explicitly requested with -no-undefined,"
7981e9fcaa8aSmrg	      echo "*** libtool will only create a static version of it."
798288de56ccSmrg	      if test "$build_old_libs" = no; then
798388de56ccSmrg		oldlibs="$output_objdir/$libname.$libext"
798488de56ccSmrg		build_libtool_libs=module
798588de56ccSmrg		build_old_libs=yes
798688de56ccSmrg	      else
798788de56ccSmrg		build_libtool_libs=no
798888de56ccSmrg	      fi
798988de56ccSmrg	    fi
799088de56ccSmrg	  fi
799188de56ccSmrg	fi
799288de56ccSmrg	# Done checking deplibs!
799388de56ccSmrg	deplibs=$newdeplibs
799488de56ccSmrg      fi
799588de56ccSmrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
799688de56ccSmrg      case $host in
799788de56ccSmrg	*-*-darwin*)
7998e9fcaa8aSmrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7999e9fcaa8aSmrg	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8000e9fcaa8aSmrg	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
800188de56ccSmrg	  ;;
800288de56ccSmrg      esac
800388de56ccSmrg
800488de56ccSmrg      # move library search paths that coincide with paths to not yet
800588de56ccSmrg      # installed libraries to the beginning of the library search list
800688de56ccSmrg      new_libs=
800788de56ccSmrg      for path in $notinst_path; do
800888de56ccSmrg	case " $new_libs " in
800988de56ccSmrg	*" -L$path/$objdir "*) ;;
801088de56ccSmrg	*)
801188de56ccSmrg	  case " $deplibs " in
801288de56ccSmrg	  *" -L$path/$objdir "*)
8013e9fcaa8aSmrg	    func_append new_libs " -L$path/$objdir" ;;
801488de56ccSmrg	  esac
801588de56ccSmrg	  ;;
801688de56ccSmrg	esac
801788de56ccSmrg      done
801888de56ccSmrg      for deplib in $deplibs; do
801988de56ccSmrg	case $deplib in
802088de56ccSmrg	-L*)
802188de56ccSmrg	  case " $new_libs " in
802288de56ccSmrg	  *" $deplib "*) ;;
8023e9fcaa8aSmrg	  *) func_append new_libs " $deplib" ;;
802488de56ccSmrg	  esac
802588de56ccSmrg	  ;;
8026e9fcaa8aSmrg	*) func_append new_libs " $deplib" ;;
802788de56ccSmrg	esac
802888de56ccSmrg      done
802988de56ccSmrg      deplibs="$new_libs"
803088de56ccSmrg
803188de56ccSmrg      # All the library-specific variables (install_libdir is set above).
803288de56ccSmrg      library_names=
803388de56ccSmrg      old_library=
803488de56ccSmrg      dlname=
803588de56ccSmrg
803688de56ccSmrg      # Test again, we may have decided not to build it any more
803788de56ccSmrg      if test "$build_libtool_libs" = yes; then
8038eb411b4bSmrg	# Remove ${wl} instances when linking with ld.
8039eb411b4bSmrg	# FIXME: should test the right _cmds variable.
8040eb411b4bSmrg	case $archive_cmds in
8041eb411b4bSmrg	  *\$LD\ *) wl= ;;
8042eb411b4bSmrg        esac
804388de56ccSmrg	if test "$hardcode_into_libs" = yes; then
804488de56ccSmrg	  # Hardcode the library paths
804588de56ccSmrg	  hardcode_libdirs=
804688de56ccSmrg	  dep_rpath=
804788de56ccSmrg	  rpath="$finalize_rpath"
8048e9fcaa8aSmrg	  test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
804988de56ccSmrg	  for libdir in $rpath; do
805088de56ccSmrg	    if test -n "$hardcode_libdir_flag_spec"; then
805188de56ccSmrg	      if test -n "$hardcode_libdir_separator"; then
8052e9fcaa8aSmrg		func_replace_sysroot "$libdir"
8053e9fcaa8aSmrg		libdir=$func_replace_sysroot_result
805488de56ccSmrg		if test -z "$hardcode_libdirs"; then
805588de56ccSmrg		  hardcode_libdirs="$libdir"
805688de56ccSmrg		else
805788de56ccSmrg		  # Just accumulate the unique libdirs.
805888de56ccSmrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
805988de56ccSmrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
806088de56ccSmrg		    ;;
806188de56ccSmrg		  *)
8062e9fcaa8aSmrg		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
806388de56ccSmrg		    ;;
806488de56ccSmrg		  esac
806588de56ccSmrg		fi
806688de56ccSmrg	      else
806788de56ccSmrg		eval flag=\"$hardcode_libdir_flag_spec\"
8068e9fcaa8aSmrg		func_append dep_rpath " $flag"
806988de56ccSmrg	      fi
807088de56ccSmrg	    elif test -n "$runpath_var"; then
807188de56ccSmrg	      case "$perm_rpath " in
807288de56ccSmrg	      *" $libdir "*) ;;
8073eb411b4bSmrg	      *) func_append perm_rpath " $libdir" ;;
807488de56ccSmrg	      esac
807588de56ccSmrg	    fi
807688de56ccSmrg	  done
807788de56ccSmrg	  # Substitute the hardcoded libdirs into the rpath.
807888de56ccSmrg	  if test -n "$hardcode_libdir_separator" &&
807988de56ccSmrg	     test -n "$hardcode_libdirs"; then
808088de56ccSmrg	    libdir="$hardcode_libdirs"
8081eb411b4bSmrg	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
808288de56ccSmrg	  fi
808388de56ccSmrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
808488de56ccSmrg	    # We should set the runpath_var.
808588de56ccSmrg	    rpath=
808688de56ccSmrg	    for dir in $perm_rpath; do
8087e9fcaa8aSmrg	      func_append rpath "$dir:"
808888de56ccSmrg	    done
808988de56ccSmrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
809088de56ccSmrg	  fi
809188de56ccSmrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
809288de56ccSmrg	fi
80931ab64890Smrg
809488de56ccSmrg	shlibpath="$finalize_shlibpath"
8095e9fcaa8aSmrg	test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
809688de56ccSmrg	if test -n "$shlibpath"; then
809788de56ccSmrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
809888de56ccSmrg	fi
80991ab64890Smrg
810088de56ccSmrg	# Get the real and link names of the library.
810188de56ccSmrg	eval shared_ext=\"$shrext_cmds\"
810288de56ccSmrg	eval library_names=\"$library_names_spec\"
810388de56ccSmrg	set dummy $library_names
810488de56ccSmrg	shift
810588de56ccSmrg	realname="$1"
810688de56ccSmrg	shift
81071ab64890Smrg
810888de56ccSmrg	if test -n "$soname_spec"; then
810988de56ccSmrg	  eval soname=\"$soname_spec\"
811088de56ccSmrg	else
811188de56ccSmrg	  soname="$realname"
811288de56ccSmrg	fi
811388de56ccSmrg	if test -z "$dlname"; then
811488de56ccSmrg	  dlname=$soname
811588de56ccSmrg	fi
81161ab64890Smrg
811788de56ccSmrg	lib="$output_objdir/$realname"
811888de56ccSmrg	linknames=
811988de56ccSmrg	for link
812088de56ccSmrg	do
8121e9fcaa8aSmrg	  func_append linknames " $link"
812288de56ccSmrg	done
81231ab64890Smrg
812488de56ccSmrg	# Use standard objects if they are pic
8125e9fcaa8aSmrg	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
812688de56ccSmrg	test "X$libobjs" = "X " && libobjs=
81271ab64890Smrg
812888de56ccSmrg	delfiles=
812988de56ccSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
813088de56ccSmrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
813188de56ccSmrg	  export_symbols="$output_objdir/$libname.uexp"
8132e9fcaa8aSmrg	  func_append delfiles " $export_symbols"
813388de56ccSmrg	fi
81341ab64890Smrg
813588de56ccSmrg	orig_export_symbols=
813688de56ccSmrg	case $host_os in
813788de56ccSmrg	cygwin* | mingw* | cegcc*)
813888de56ccSmrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
813988de56ccSmrg	    # exporting using user supplied symfile
814088de56ccSmrg	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
814188de56ccSmrg	      # and it's NOT already a .def file. Must figure out
814288de56ccSmrg	      # which of the given symbols are data symbols and tag
814388de56ccSmrg	      # them as such. So, trigger use of export_symbols_cmds.
814488de56ccSmrg	      # export_symbols gets reassigned inside the "prepare
814588de56ccSmrg	      # the list of exported symbols" if statement, so the
814688de56ccSmrg	      # include_expsyms logic still works.
814788de56ccSmrg	      orig_export_symbols="$export_symbols"
814888de56ccSmrg	      export_symbols=
814988de56ccSmrg	      always_export_symbols=yes
815088de56ccSmrg	    fi
815188de56ccSmrg	  fi
815288de56ccSmrg	  ;;
815388de56ccSmrg	esac
81541ab64890Smrg
815588de56ccSmrg	# Prepare the list of exported symbols
815688de56ccSmrg	if test -z "$export_symbols"; then
815788de56ccSmrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
815888de56ccSmrg	    func_verbose "generating symbol list for \`$libname.la'"
815988de56ccSmrg	    export_symbols="$output_objdir/$libname.exp"
816088de56ccSmrg	    $opt_dry_run || $RM $export_symbols
816188de56ccSmrg	    cmds=$export_symbols_cmds
816288de56ccSmrg	    save_ifs="$IFS"; IFS='~'
8163e9fcaa8aSmrg	    for cmd1 in $cmds; do
816488de56ccSmrg	      IFS="$save_ifs"
8165e9fcaa8aSmrg	      # Take the normal branch if the nm_file_list_spec branch
8166e9fcaa8aSmrg	      # doesn't work or if tool conversion is not needed.
8167e9fcaa8aSmrg	      case $nm_file_list_spec~$to_tool_file_cmd in
8168e9fcaa8aSmrg		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
8169e9fcaa8aSmrg		  try_normal_branch=yes
8170e9fcaa8aSmrg		  eval cmd=\"$cmd1\"
8171e9fcaa8aSmrg		  func_len " $cmd"
8172e9fcaa8aSmrg		  len=$func_len_result
8173e9fcaa8aSmrg		  ;;
8174e9fcaa8aSmrg		*)
8175e9fcaa8aSmrg		  try_normal_branch=no
8176e9fcaa8aSmrg		  ;;
8177e9fcaa8aSmrg	      esac
8178e9fcaa8aSmrg	      if test "$try_normal_branch" = yes \
8179e9fcaa8aSmrg		 && { test "$len" -lt "$max_cmd_len" \
8180e9fcaa8aSmrg		      || test "$max_cmd_len" -le -1; }
8181e9fcaa8aSmrg	      then
8182e9fcaa8aSmrg		func_show_eval "$cmd" 'exit $?'
8183e9fcaa8aSmrg		skipped_export=false
8184e9fcaa8aSmrg	      elif test -n "$nm_file_list_spec"; then
8185e9fcaa8aSmrg		func_basename "$output"
8186e9fcaa8aSmrg		output_la=$func_basename_result
8187e9fcaa8aSmrg		save_libobjs=$libobjs
8188e9fcaa8aSmrg		save_output=$output
8189e9fcaa8aSmrg		output=${output_objdir}/${output_la}.nm
8190e9fcaa8aSmrg		func_to_tool_file "$output"
8191e9fcaa8aSmrg		libobjs=$nm_file_list_spec$func_to_tool_file_result
8192e9fcaa8aSmrg		func_append delfiles " $output"
8193e9fcaa8aSmrg		func_verbose "creating $NM input file list: $output"
8194e9fcaa8aSmrg		for obj in $save_libobjs; do
8195e9fcaa8aSmrg		  func_to_tool_file "$obj"
8196e9fcaa8aSmrg		  $ECHO "$func_to_tool_file_result"
8197e9fcaa8aSmrg		done > "$output"
8198e9fcaa8aSmrg		eval cmd=\"$cmd1\"
819988de56ccSmrg		func_show_eval "$cmd" 'exit $?'
8200e9fcaa8aSmrg		output=$save_output
8201e9fcaa8aSmrg		libobjs=$save_libobjs
820288de56ccSmrg		skipped_export=false
820388de56ccSmrg	      else
820488de56ccSmrg		# The command line is too long to execute in one step.
820588de56ccSmrg		func_verbose "using reloadable object file for export list..."
820688de56ccSmrg		skipped_export=:
820788de56ccSmrg		# Break out early, otherwise skipped_export may be
820888de56ccSmrg		# set to false by a later but shorter cmd.
820988de56ccSmrg		break
821088de56ccSmrg	      fi
821188de56ccSmrg	    done
821288de56ccSmrg	    IFS="$save_ifs"
821388de56ccSmrg	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
821488de56ccSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
821588de56ccSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
821688de56ccSmrg	    fi
821788de56ccSmrg	  fi
82181ab64890Smrg	fi
82191ab64890Smrg
822088de56ccSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
822188de56ccSmrg	  tmp_export_symbols="$export_symbols"
822288de56ccSmrg	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
8223e9fcaa8aSmrg	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
822488de56ccSmrg	fi
82251ab64890Smrg
822688de56ccSmrg	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
822788de56ccSmrg	  # The given exports_symbols file has to be filtered, so filter it.
822888de56ccSmrg	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
822988de56ccSmrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
823088de56ccSmrg	  # 's' commands which not all seds can handle. GNU sed should be fine
823188de56ccSmrg	  # though. Also, the filter scales superlinearly with the number of
823288de56ccSmrg	  # global variables. join(1) would be nice here, but unfortunately
823388de56ccSmrg	  # isn't a blessed tool.
823488de56ccSmrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8235e9fcaa8aSmrg	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
823688de56ccSmrg	  export_symbols=$output_objdir/$libname.def
823788de56ccSmrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
823888de56ccSmrg	fi
82391ab64890Smrg
824088de56ccSmrg	tmp_deplibs=
824188de56ccSmrg	for test_deplib in $deplibs; do
824288de56ccSmrg	  case " $convenience " in
824388de56ccSmrg	  *" $test_deplib "*) ;;
824488de56ccSmrg	  *)
8245e9fcaa8aSmrg	    func_append tmp_deplibs " $test_deplib"
824688de56ccSmrg	    ;;
824788de56ccSmrg	  esac
824888de56ccSmrg	done
824988de56ccSmrg	deplibs="$tmp_deplibs"
82501ab64890Smrg
825188de56ccSmrg	if test -n "$convenience"; then
825288de56ccSmrg	  if test -n "$whole_archive_flag_spec" &&
825388de56ccSmrg	    test "$compiler_needs_object" = yes &&
825488de56ccSmrg	    test -z "$libobjs"; then
825588de56ccSmrg	    # extract the archives, so we have objects to list.
825688de56ccSmrg	    # TODO: could optimize this to just extract one archive.
825788de56ccSmrg	    whole_archive_flag_spec=
825888de56ccSmrg	  fi
825988de56ccSmrg	  if test -n "$whole_archive_flag_spec"; then
826088de56ccSmrg	    save_libobjs=$libobjs
826188de56ccSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
826288de56ccSmrg	    test "X$libobjs" = "X " && libobjs=
826388de56ccSmrg	  else
826488de56ccSmrg	    gentop="$output_objdir/${outputname}x"
8265e9fcaa8aSmrg	    func_append generated " $gentop"
82661ab64890Smrg
826788de56ccSmrg	    func_extract_archives $gentop $convenience
8268e9fcaa8aSmrg	    func_append libobjs " $func_extract_archives_result"
826988de56ccSmrg	    test "X$libobjs" = "X " && libobjs=
827088de56ccSmrg	  fi
8271b4ee4795Smrg	fi
82721ab64890Smrg
827388de56ccSmrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
827488de56ccSmrg	  eval flag=\"$thread_safe_flag_spec\"
8275e9fcaa8aSmrg	  func_append linker_flags " $flag"
8276b4ee4795Smrg	fi
82772e9c7c8cSmrg
827888de56ccSmrg	# Make a backup of the uninstalled library when relinking
8279e9fcaa8aSmrg	if test "$opt_mode" = relink; then
828088de56ccSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
828188de56ccSmrg	fi
82821ab64890Smrg
828388de56ccSmrg	# Do each of the archive commands.
828488de56ccSmrg	if test "$module" = yes && test -n "$module_cmds" ; then
828588de56ccSmrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
828688de56ccSmrg	    eval test_cmds=\"$module_expsym_cmds\"
828788de56ccSmrg	    cmds=$module_expsym_cmds
828888de56ccSmrg	  else
828988de56ccSmrg	    eval test_cmds=\"$module_cmds\"
829088de56ccSmrg	    cmds=$module_cmds
829188de56ccSmrg	  fi
8292b4ee4795Smrg	else
829388de56ccSmrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
829488de56ccSmrg	    eval test_cmds=\"$archive_expsym_cmds\"
829588de56ccSmrg	    cmds=$archive_expsym_cmds
829688de56ccSmrg	  else
829788de56ccSmrg	    eval test_cmds=\"$archive_cmds\"
829888de56ccSmrg	    cmds=$archive_cmds
829988de56ccSmrg	  fi
8300b4ee4795Smrg	fi
83011ab64890Smrg
830288de56ccSmrg	if test "X$skipped_export" != "X:" &&
830388de56ccSmrg	   func_len " $test_cmds" &&
830488de56ccSmrg	   len=$func_len_result &&
830588de56ccSmrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
830688de56ccSmrg	  :
830788de56ccSmrg	else
830888de56ccSmrg	  # The command line is too long to link in one step, link piecewise
830988de56ccSmrg	  # or, if using GNU ld and skipped_export is not :, use a linker
831088de56ccSmrg	  # script.
83111ab64890Smrg
831288de56ccSmrg	  # Save the value of $output and $libobjs because we want to
831388de56ccSmrg	  # use them later.  If we have whole_archive_flag_spec, we
831488de56ccSmrg	  # want to use save_libobjs as it was before
831588de56ccSmrg	  # whole_archive_flag_spec was expanded, because we can't
831688de56ccSmrg	  # assume the linker understands whole_archive_flag_spec.
831788de56ccSmrg	  # This may have to be revisited, in case too many
831888de56ccSmrg	  # convenience libraries get linked in and end up exceeding
831988de56ccSmrg	  # the spec.
832088de56ccSmrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
832188de56ccSmrg	    save_libobjs=$libobjs
832288de56ccSmrg	  fi
832388de56ccSmrg	  save_output=$output
8324e9fcaa8aSmrg	  func_basename "$output"
8325e9fcaa8aSmrg	  output_la=$func_basename_result
83261ab64890Smrg
832788de56ccSmrg	  # Clear the reloadable object creation command queue and
832888de56ccSmrg	  # initialize k to one.
832988de56ccSmrg	  test_cmds=
833088de56ccSmrg	  concat_cmds=
833188de56ccSmrg	  objlist=
833288de56ccSmrg	  last_robj=
833388de56ccSmrg	  k=1
833488de56ccSmrg
833588de56ccSmrg	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
833688de56ccSmrg	    output=${output_objdir}/${output_la}.lnkscript
833788de56ccSmrg	    func_verbose "creating GNU ld script: $output"
8338e9fcaa8aSmrg	    echo 'INPUT (' > $output
833988de56ccSmrg	    for obj in $save_libobjs
8340b4ee4795Smrg	    do
8341e9fcaa8aSmrg	      func_to_tool_file "$obj"
8342e9fcaa8aSmrg	      $ECHO "$func_to_tool_file_result" >> $output
834388de56ccSmrg	    done
8344e9fcaa8aSmrg	    echo ')' >> $output
8345e9fcaa8aSmrg	    func_append delfiles " $output"
8346e9fcaa8aSmrg	    func_to_tool_file "$output"
8347e9fcaa8aSmrg	    output=$func_to_tool_file_result
834888de56ccSmrg	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
834988de56ccSmrg	    output=${output_objdir}/${output_la}.lnk
835088de56ccSmrg	    func_verbose "creating linker input file list: $output"
835188de56ccSmrg	    : > $output
835288de56ccSmrg	    set x $save_libobjs
835388de56ccSmrg	    shift
835488de56ccSmrg	    firstobj=
835588de56ccSmrg	    if test "$compiler_needs_object" = yes; then
835688de56ccSmrg	      firstobj="$1 "
835788de56ccSmrg	      shift
835888de56ccSmrg	    fi
835988de56ccSmrg	    for obj
836088de56ccSmrg	    do
8361e9fcaa8aSmrg	      func_to_tool_file "$obj"
8362e9fcaa8aSmrg	      $ECHO "$func_to_tool_file_result" >> $output
836388de56ccSmrg	    done
8364e9fcaa8aSmrg	    func_append delfiles " $output"
8365e9fcaa8aSmrg	    func_to_tool_file "$output"
8366e9fcaa8aSmrg	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
836788de56ccSmrg	  else
836888de56ccSmrg	    if test -n "$save_libobjs"; then
836988de56ccSmrg	      func_verbose "creating reloadable object files..."
837088de56ccSmrg	      output=$output_objdir/$output_la-${k}.$objext
837188de56ccSmrg	      eval test_cmds=\"$reload_cmds\"
837288de56ccSmrg	      func_len " $test_cmds"
837388de56ccSmrg	      len0=$func_len_result
837488de56ccSmrg	      len=$len0
837588de56ccSmrg
837688de56ccSmrg	      # Loop over the list of objects to be linked.
837788de56ccSmrg	      for obj in $save_libobjs
837888de56ccSmrg	      do
837988de56ccSmrg		func_len " $obj"
838088de56ccSmrg		func_arith $len + $func_len_result
838188de56ccSmrg		len=$func_arith_result
838288de56ccSmrg		if test "X$objlist" = X ||
838388de56ccSmrg		   test "$len" -lt "$max_cmd_len"; then
838488de56ccSmrg		  func_append objlist " $obj"
838588de56ccSmrg		else
838688de56ccSmrg		  # The command $test_cmds is almost too long, add a
838788de56ccSmrg		  # command to the queue.
838888de56ccSmrg		  if test "$k" -eq 1 ; then
838988de56ccSmrg		    # The first file doesn't have a previous command to add.
8390e9fcaa8aSmrg		    reload_objs=$objlist
8391e9fcaa8aSmrg		    eval concat_cmds=\"$reload_cmds\"
839288de56ccSmrg		  else
839388de56ccSmrg		    # All subsequent reloadable object files will link in
839488de56ccSmrg		    # the last one created.
8395e9fcaa8aSmrg		    reload_objs="$objlist $last_robj"
8396e9fcaa8aSmrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
839788de56ccSmrg		  fi
839888de56ccSmrg		  last_robj=$output_objdir/$output_la-${k}.$objext
839988de56ccSmrg		  func_arith $k + 1
840088de56ccSmrg		  k=$func_arith_result
840188de56ccSmrg		  output=$output_objdir/$output_la-${k}.$objext
8402e9fcaa8aSmrg		  objlist=" $obj"
840388de56ccSmrg		  func_len " $last_robj"
840488de56ccSmrg		  func_arith $len0 + $func_len_result
840588de56ccSmrg		  len=$func_arith_result
840688de56ccSmrg		fi
840788de56ccSmrg	      done
840888de56ccSmrg	      # Handle the remaining objects by creating one last
840988de56ccSmrg	      # reloadable object file.  All subsequent reloadable object
841088de56ccSmrg	      # files will link in the last one created.
841188de56ccSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8412e9fcaa8aSmrg	      reload_objs="$objlist $last_robj"
8413e9fcaa8aSmrg	      eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
841488de56ccSmrg	      if test -n "$last_robj"; then
841588de56ccSmrg	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
841688de56ccSmrg	      fi
8417e9fcaa8aSmrg	      func_append delfiles " $output"
84181ab64890Smrg
841988de56ccSmrg	    else
842088de56ccSmrg	      output=
842188de56ccSmrg	    fi
84221ab64890Smrg
842388de56ccSmrg	    if ${skipped_export-false}; then
842488de56ccSmrg	      func_verbose "generating symbol list for \`$libname.la'"
842588de56ccSmrg	      export_symbols="$output_objdir/$libname.exp"
842688de56ccSmrg	      $opt_dry_run || $RM $export_symbols
842788de56ccSmrg	      libobjs=$output
842888de56ccSmrg	      # Append the command to create the export file.
842988de56ccSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
843088de56ccSmrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
843188de56ccSmrg	      if test -n "$last_robj"; then
843288de56ccSmrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
843388de56ccSmrg	      fi
84342e9c7c8cSmrg	    fi
84351ab64890Smrg
843688de56ccSmrg	    test -n "$save_libobjs" &&
843788de56ccSmrg	      func_verbose "creating a temporary reloadable object file: $output"
84381ab64890Smrg
843988de56ccSmrg	    # Loop through the commands generated above and execute them.
844088de56ccSmrg	    save_ifs="$IFS"; IFS='~'
844188de56ccSmrg	    for cmd in $concat_cmds; do
844288de56ccSmrg	      IFS="$save_ifs"
844388de56ccSmrg	      $opt_silent || {
844488de56ccSmrg		  func_quote_for_expand "$cmd"
844588de56ccSmrg		  eval "func_echo $func_quote_for_expand_result"
844688de56ccSmrg	      }
844788de56ccSmrg	      $opt_dry_run || eval "$cmd" || {
844888de56ccSmrg		lt_exit=$?
844988de56ccSmrg
845088de56ccSmrg		# Restore the uninstalled library and exit
8451e9fcaa8aSmrg		if test "$opt_mode" = relink; then
845288de56ccSmrg		  ( cd "$output_objdir" && \
845388de56ccSmrg		    $RM "${realname}T" && \
845488de56ccSmrg		    $MV "${realname}U" "$realname" )
845588de56ccSmrg		fi
84561ab64890Smrg
845788de56ccSmrg		exit $lt_exit
845888de56ccSmrg	      }
845988de56ccSmrg	    done
846088de56ccSmrg	    IFS="$save_ifs"
8461b4ee4795Smrg
846288de56ccSmrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
846388de56ccSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
846488de56ccSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
84651ab64890Smrg	    fi
84661ab64890Smrg	  fi
84671ab64890Smrg
846888de56ccSmrg          if ${skipped_export-false}; then
846988de56ccSmrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
847088de56ccSmrg	      tmp_export_symbols="$export_symbols"
847188de56ccSmrg	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
8472e9fcaa8aSmrg	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
847388de56ccSmrg	    fi
84742e9c7c8cSmrg
847588de56ccSmrg	    if test -n "$orig_export_symbols"; then
847688de56ccSmrg	      # The given exports_symbols file has to be filtered, so filter it.
847788de56ccSmrg	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
847888de56ccSmrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
847988de56ccSmrg	      # 's' commands which not all seds can handle. GNU sed should be fine
848088de56ccSmrg	      # though. Also, the filter scales superlinearly with the number of
848188de56ccSmrg	      # global variables. join(1) would be nice here, but unfortunately
848288de56ccSmrg	      # isn't a blessed tool.
848388de56ccSmrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8484e9fcaa8aSmrg	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
848588de56ccSmrg	      export_symbols=$output_objdir/$libname.def
848688de56ccSmrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
848788de56ccSmrg	    fi
848888de56ccSmrg	  fi
84891ab64890Smrg
849088de56ccSmrg	  libobjs=$output
849188de56ccSmrg	  # Restore the value of output.
849288de56ccSmrg	  output=$save_output
84931ab64890Smrg
849488de56ccSmrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
849588de56ccSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
849688de56ccSmrg	    test "X$libobjs" = "X " && libobjs=
849788de56ccSmrg	  fi
849888de56ccSmrg	  # Expand the library linking commands again to reset the
849988de56ccSmrg	  # value of $libobjs for piecewise linking.
85001ab64890Smrg
850188de56ccSmrg	  # Do each of the archive commands.
850288de56ccSmrg	  if test "$module" = yes && test -n "$module_cmds" ; then
850388de56ccSmrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
850488de56ccSmrg	      cmds=$module_expsym_cmds
850588de56ccSmrg	    else
850688de56ccSmrg	      cmds=$module_cmds
8507b4ee4795Smrg	    fi
8508b4ee4795Smrg	  else
850988de56ccSmrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
851088de56ccSmrg	      cmds=$archive_expsym_cmds
851188de56ccSmrg	    else
851288de56ccSmrg	      cmds=$archive_cmds
851388de56ccSmrg	    fi
8514b4ee4795Smrg	  fi
851588de56ccSmrg	fi
85161ab64890Smrg
851788de56ccSmrg	if test -n "$delfiles"; then
851888de56ccSmrg	  # Append the command to remove temporary files to $cmds.
851988de56ccSmrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
852088de56ccSmrg	fi
85211ab64890Smrg
852288de56ccSmrg	# Add any objects from preloaded convenience libraries
852388de56ccSmrg	if test -n "$dlprefiles"; then
852488de56ccSmrg	  gentop="$output_objdir/${outputname}x"
8525e9fcaa8aSmrg	  func_append generated " $gentop"
85261ab64890Smrg
852788de56ccSmrg	  func_extract_archives $gentop $dlprefiles
8528e9fcaa8aSmrg	  func_append libobjs " $func_extract_archives_result"
852988de56ccSmrg	  test "X$libobjs" = "X " && libobjs=
853088de56ccSmrg	fi
85311ab64890Smrg
853288de56ccSmrg	save_ifs="$IFS"; IFS='~'
853388de56ccSmrg	for cmd in $cmds; do
853488de56ccSmrg	  IFS="$save_ifs"
853588de56ccSmrg	  eval cmd=\"$cmd\"
853688de56ccSmrg	  $opt_silent || {
853788de56ccSmrg	    func_quote_for_expand "$cmd"
853888de56ccSmrg	    eval "func_echo $func_quote_for_expand_result"
853988de56ccSmrg	  }
854088de56ccSmrg	  $opt_dry_run || eval "$cmd" || {
854188de56ccSmrg	    lt_exit=$?
85422e9c7c8cSmrg
854388de56ccSmrg	    # Restore the uninstalled library and exit
8544e9fcaa8aSmrg	    if test "$opt_mode" = relink; then
854588de56ccSmrg	      ( cd "$output_objdir" && \
854688de56ccSmrg	        $RM "${realname}T" && \
854788de56ccSmrg		$MV "${realname}U" "$realname" )
854888de56ccSmrg	    fi
85492e9c7c8cSmrg
855088de56ccSmrg	    exit $lt_exit
855188de56ccSmrg	  }
855288de56ccSmrg	done
855388de56ccSmrg	IFS="$save_ifs"
85542e9c7c8cSmrg
855588de56ccSmrg	# Restore the uninstalled library and exit
8556e9fcaa8aSmrg	if test "$opt_mode" = relink; then
855788de56ccSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
85582e9c7c8cSmrg
855988de56ccSmrg	  if test -n "$convenience"; then
856088de56ccSmrg	    if test -z "$whole_archive_flag_spec"; then
856188de56ccSmrg	      func_show_eval '${RM}r "$gentop"'
856288de56ccSmrg	    fi
856388de56ccSmrg	  fi
85642e9c7c8cSmrg
856588de56ccSmrg	  exit $EXIT_SUCCESS
856688de56ccSmrg	fi
856788de56ccSmrg
856888de56ccSmrg	# Create links to the real library.
856988de56ccSmrg	for linkname in $linknames; do
857088de56ccSmrg	  if test "$realname" != "$linkname"; then
857188de56ccSmrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
8572b4ee4795Smrg	  fi
8573b4ee4795Smrg	done
85742e9c7c8cSmrg
857588de56ccSmrg	# If -module or -export-dynamic was specified, set the dlname.
857688de56ccSmrg	if test "$module" = yes || test "$export_dynamic" = yes; then
857788de56ccSmrg	  # On all known operating systems, these are identical.
857888de56ccSmrg	  dlname="$soname"
857988de56ccSmrg	fi
858088de56ccSmrg      fi
85811ab64890Smrg      ;;
85821ab64890Smrg
858388de56ccSmrg    obj)
858488de56ccSmrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
858588de56ccSmrg	func_warning "\`-dlopen' is ignored for objects"
858688de56ccSmrg      fi
8587b4ee4795Smrg
858888de56ccSmrg      case " $deplibs" in
858988de56ccSmrg      *\ -l* | *\ -L*)
859088de56ccSmrg	func_warning "\`-l' and \`-L' are ignored for objects" ;;
85912e9c7c8cSmrg      esac
85921ab64890Smrg
859388de56ccSmrg      test -n "$rpath" && \
859488de56ccSmrg	func_warning "\`-rpath' is ignored for objects"
859588de56ccSmrg
859688de56ccSmrg      test -n "$xrpath" && \
859788de56ccSmrg	func_warning "\`-R' is ignored for objects"
85981ab64890Smrg
859988de56ccSmrg      test -n "$vinfo" && \
860088de56ccSmrg	func_warning "\`-version-info' is ignored for objects"
86012e9c7c8cSmrg
860288de56ccSmrg      test -n "$release" && \
860388de56ccSmrg	func_warning "\`-release' is ignored for objects"
860488de56ccSmrg
860588de56ccSmrg      case $output in
860688de56ccSmrg      *.lo)
860788de56ccSmrg	test -n "$objs$old_deplibs" && \
860888de56ccSmrg	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
860988de56ccSmrg
861088de56ccSmrg	libobj=$output
861188de56ccSmrg	func_lo2o "$libobj"
861288de56ccSmrg	obj=$func_lo2o_result
8613b4ee4795Smrg	;;
8614b4ee4795Smrg      *)
861588de56ccSmrg	libobj=
861688de56ccSmrg	obj="$output"
86171ab64890Smrg	;;
86182e9c7c8cSmrg      esac
86191ab64890Smrg
862088de56ccSmrg      # Delete the old objects.
862188de56ccSmrg      $opt_dry_run || $RM $obj $libobj
86221ab64890Smrg
862388de56ccSmrg      # Objects from convenience libraries.  This assumes
862488de56ccSmrg      # single-version convenience libraries.  Whenever we create
862588de56ccSmrg      # different ones for PIC/non-PIC, this we'll have to duplicate
862688de56ccSmrg      # the extraction.
862788de56ccSmrg      reload_conv_objs=
862888de56ccSmrg      gentop=
862988de56ccSmrg      # reload_cmds runs $LD directly, so let us get rid of
863088de56ccSmrg      # -Wl from whole_archive_flag_spec and hope we can get by with
863188de56ccSmrg      # turning comma into space..
863288de56ccSmrg      wl=
86331ab64890Smrg
863488de56ccSmrg      if test -n "$convenience"; then
863588de56ccSmrg	if test -n "$whole_archive_flag_spec"; then
863688de56ccSmrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
8637e9fcaa8aSmrg	  reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
863888de56ccSmrg	else
863988de56ccSmrg	  gentop="$output_objdir/${obj}x"
8640e9fcaa8aSmrg	  func_append generated " $gentop"
8641b4ee4795Smrg
864288de56ccSmrg	  func_extract_archives $gentop $convenience
864388de56ccSmrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
864488de56ccSmrg	fi
8645b4ee4795Smrg      fi
8646b4ee4795Smrg
8647e9fcaa8aSmrg      # If we're not building shared, we need to use non_pic_objs
8648e9fcaa8aSmrg      test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
8649e9fcaa8aSmrg
865088de56ccSmrg      # Create the old-style object.
8651e9fcaa8aSmrg      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
8652b4ee4795Smrg
865388de56ccSmrg      output="$obj"
865488de56ccSmrg      func_execute_cmds "$reload_cmds" 'exit $?'
8655b4ee4795Smrg
865688de56ccSmrg      # Exit if we aren't doing a library object file.
865788de56ccSmrg      if test -z "$libobj"; then
865888de56ccSmrg	if test -n "$gentop"; then
865988de56ccSmrg	  func_show_eval '${RM}r "$gentop"'
866088de56ccSmrg	fi
866188de56ccSmrg
866288de56ccSmrg	exit $EXIT_SUCCESS
8663b4ee4795Smrg      fi
866488de56ccSmrg
866588de56ccSmrg      if test "$build_libtool_libs" != yes; then
866688de56ccSmrg	if test -n "$gentop"; then
866788de56ccSmrg	  func_show_eval '${RM}r "$gentop"'
866888de56ccSmrg	fi
866988de56ccSmrg
867088de56ccSmrg	# Create an invalid libtool object if no PIC, so that we don't
867188de56ccSmrg	# accidentally link it into a program.
867288de56ccSmrg	# $show "echo timestamp > $libobj"
867388de56ccSmrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
867488de56ccSmrg	exit $EXIT_SUCCESS
867588de56ccSmrg      fi
867688de56ccSmrg
867788de56ccSmrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
867888de56ccSmrg	# Only do commands if we really have different PIC objects.
867988de56ccSmrg	reload_objs="$libobjs $reload_conv_objs"
868088de56ccSmrg	output="$libobj"
868188de56ccSmrg	func_execute_cmds "$reload_cmds" 'exit $?'
868288de56ccSmrg      fi
868388de56ccSmrg
868488de56ccSmrg      if test -n "$gentop"; then
868588de56ccSmrg	func_show_eval '${RM}r "$gentop"'
868688de56ccSmrg      fi
868788de56ccSmrg
868888de56ccSmrg      exit $EXIT_SUCCESS
8689b4ee4795Smrg      ;;
86901ab64890Smrg
869188de56ccSmrg    prog)
869288de56ccSmrg      case $host in
869388de56ccSmrg	*cygwin*) func_stripname '' '.exe' "$output"
869488de56ccSmrg	          output=$func_stripname_result.exe;;
869588de56ccSmrg      esac
869688de56ccSmrg      test -n "$vinfo" && \
869788de56ccSmrg	func_warning "\`-version-info' is ignored for programs"
86981ab64890Smrg
869988de56ccSmrg      test -n "$release" && \
870088de56ccSmrg	func_warning "\`-release' is ignored for programs"
87011ab64890Smrg
870288de56ccSmrg      test "$preload" = yes \
870388de56ccSmrg        && test "$dlopen_support" = unknown \
870488de56ccSmrg	&& test "$dlopen_self" = unknown \
870588de56ccSmrg	&& test "$dlopen_self_static" = unknown && \
870688de56ccSmrg	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
870788de56ccSmrg
870888de56ccSmrg      case $host in
870988de56ccSmrg      *-*-rhapsody* | *-*-darwin1.[012])
871088de56ccSmrg	# On Rhapsody replace the C library is the System framework
8711e9fcaa8aSmrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
8712e9fcaa8aSmrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
8713b4ee4795Smrg	;;
871488de56ccSmrg      esac
8715b4ee4795Smrg
871688de56ccSmrg      case $host in
871788de56ccSmrg      *-*-darwin*)
871888de56ccSmrg	# Don't allow lazy linking, it breaks C++ global constructors
871988de56ccSmrg	# But is supposedly fixed on 10.4 or later (yay!).
872088de56ccSmrg	if test "$tagname" = CXX ; then
872188de56ccSmrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
872288de56ccSmrg	    10.[0123])
8723e9fcaa8aSmrg	      func_append compile_command " ${wl}-bind_at_load"
8724e9fcaa8aSmrg	      func_append finalize_command " ${wl}-bind_at_load"
872588de56ccSmrg	    ;;
872688de56ccSmrg	  esac
8727b4ee4795Smrg	fi
872888de56ccSmrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
8729e9fcaa8aSmrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8730e9fcaa8aSmrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
873188de56ccSmrg	;;
873288de56ccSmrg      esac
8733b4ee4795Smrg
8734b4ee4795Smrg
873588de56ccSmrg      # move library search paths that coincide with paths to not yet
873688de56ccSmrg      # installed libraries to the beginning of the library search list
873788de56ccSmrg      new_libs=
873888de56ccSmrg      for path in $notinst_path; do
873988de56ccSmrg	case " $new_libs " in
874088de56ccSmrg	*" -L$path/$objdir "*) ;;
874188de56ccSmrg	*)
874288de56ccSmrg	  case " $compile_deplibs " in
874388de56ccSmrg	  *" -L$path/$objdir "*)
8744e9fcaa8aSmrg	    func_append new_libs " -L$path/$objdir" ;;
87452e9c7c8cSmrg	  esac
874688de56ccSmrg	  ;;
874788de56ccSmrg	esac
874888de56ccSmrg      done
874988de56ccSmrg      for deplib in $compile_deplibs; do
875088de56ccSmrg	case $deplib in
875188de56ccSmrg	-L*)
875288de56ccSmrg	  case " $new_libs " in
875388de56ccSmrg	  *" $deplib "*) ;;
8754e9fcaa8aSmrg	  *) func_append new_libs " $deplib" ;;
87552e9c7c8cSmrg	  esac
875688de56ccSmrg	  ;;
8757e9fcaa8aSmrg	*) func_append new_libs " $deplib" ;;
875888de56ccSmrg	esac
875988de56ccSmrg      done
876088de56ccSmrg      compile_deplibs="$new_libs"
87611ab64890Smrg
8762b4ee4795Smrg
8763e9fcaa8aSmrg      func_append compile_command " $compile_deplibs"
8764e9fcaa8aSmrg      func_append finalize_command " $finalize_deplibs"
8765b4ee4795Smrg
876688de56ccSmrg      if test -n "$rpath$xrpath"; then
876788de56ccSmrg	# If the user specified any rpath flags, then add them.
876888de56ccSmrg	for libdir in $rpath $xrpath; do
876988de56ccSmrg	  # This is the magic to use -rpath.
877088de56ccSmrg	  case "$finalize_rpath " in
877188de56ccSmrg	  *" $libdir "*) ;;
8772e9fcaa8aSmrg	  *) func_append finalize_rpath " $libdir" ;;
877388de56ccSmrg	  esac
877488de56ccSmrg	done
877588de56ccSmrg      fi
8776b4ee4795Smrg
877788de56ccSmrg      # Now hardcode the library paths
877888de56ccSmrg      rpath=
877988de56ccSmrg      hardcode_libdirs=
878088de56ccSmrg      for libdir in $compile_rpath $finalize_rpath; do
878188de56ccSmrg	if test -n "$hardcode_libdir_flag_spec"; then
878288de56ccSmrg	  if test -n "$hardcode_libdir_separator"; then
878388de56ccSmrg	    if test -z "$hardcode_libdirs"; then
878488de56ccSmrg	      hardcode_libdirs="$libdir"
878588de56ccSmrg	    else
878688de56ccSmrg	      # Just accumulate the unique libdirs.
878788de56ccSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
878888de56ccSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
878988de56ccSmrg		;;
879088de56ccSmrg	      *)
8791e9fcaa8aSmrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
879288de56ccSmrg		;;
879388de56ccSmrg	      esac
879488de56ccSmrg	    fi
8795b4ee4795Smrg	  else
879688de56ccSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
8797e9fcaa8aSmrg	    func_append rpath " $flag"
8798b4ee4795Smrg	  fi
879988de56ccSmrg	elif test -n "$runpath_var"; then
880088de56ccSmrg	  case "$perm_rpath " in
880188de56ccSmrg	  *" $libdir "*) ;;
8802e9fcaa8aSmrg	  *) func_append perm_rpath " $libdir" ;;
880388de56ccSmrg	  esac
880488de56ccSmrg	fi
880588de56ccSmrg	case $host in
880688de56ccSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
880788de56ccSmrg	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
880888de56ccSmrg	  case :$dllsearchpath: in
880988de56ccSmrg	  *":$libdir:"*) ;;
881088de56ccSmrg	  ::) dllsearchpath=$libdir;;
8811e9fcaa8aSmrg	  *) func_append dllsearchpath ":$libdir";;
881288de56ccSmrg	  esac
881388de56ccSmrg	  case :$dllsearchpath: in
881488de56ccSmrg	  *":$testbindir:"*) ;;
881588de56ccSmrg	  ::) dllsearchpath=$testbindir;;
8816e9fcaa8aSmrg	  *) func_append dllsearchpath ":$testbindir";;
881788de56ccSmrg	  esac
881888de56ccSmrg	  ;;
881988de56ccSmrg	esac
882088de56ccSmrg      done
882188de56ccSmrg      # Substitute the hardcoded libdirs into the rpath.
882288de56ccSmrg      if test -n "$hardcode_libdir_separator" &&
882388de56ccSmrg	 test -n "$hardcode_libdirs"; then
882488de56ccSmrg	libdir="$hardcode_libdirs"
882588de56ccSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
882688de56ccSmrg      fi
882788de56ccSmrg      compile_rpath="$rpath"
8828b4ee4795Smrg
882988de56ccSmrg      rpath=
883088de56ccSmrg      hardcode_libdirs=
883188de56ccSmrg      for libdir in $finalize_rpath; do
883288de56ccSmrg	if test -n "$hardcode_libdir_flag_spec"; then
883388de56ccSmrg	  if test -n "$hardcode_libdir_separator"; then
883488de56ccSmrg	    if test -z "$hardcode_libdirs"; then
883588de56ccSmrg	      hardcode_libdirs="$libdir"
883688de56ccSmrg	    else
883788de56ccSmrg	      # Just accumulate the unique libdirs.
883888de56ccSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
883988de56ccSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
884088de56ccSmrg		;;
884188de56ccSmrg	      *)
8842e9fcaa8aSmrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
884388de56ccSmrg		;;
884488de56ccSmrg	      esac
884588de56ccSmrg	    fi
88461ab64890Smrg	  else
884788de56ccSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
8848e9fcaa8aSmrg	    func_append rpath " $flag"
88491ab64890Smrg	  fi
885088de56ccSmrg	elif test -n "$runpath_var"; then
885188de56ccSmrg	  case "$finalize_perm_rpath " in
885288de56ccSmrg	  *" $libdir "*) ;;
8853e9fcaa8aSmrg	  *) func_append finalize_perm_rpath " $libdir" ;;
885488de56ccSmrg	  esac
88551ab64890Smrg	fi
885688de56ccSmrg      done
885788de56ccSmrg      # Substitute the hardcoded libdirs into the rpath.
885888de56ccSmrg      if test -n "$hardcode_libdir_separator" &&
885988de56ccSmrg	 test -n "$hardcode_libdirs"; then
886088de56ccSmrg	libdir="$hardcode_libdirs"
886188de56ccSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
886288de56ccSmrg      fi
886388de56ccSmrg      finalize_rpath="$rpath"
88641ab64890Smrg
886588de56ccSmrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
886688de56ccSmrg	# Transform all the library objects into standard objects.
8867e9fcaa8aSmrg	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
8868e9fcaa8aSmrg	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
886988de56ccSmrg      fi
88701ab64890Smrg
887188de56ccSmrg      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
88721ab64890Smrg
887388de56ccSmrg      # template prelinking step
887488de56ccSmrg      if test -n "$prelink_cmds"; then
887588de56ccSmrg	func_execute_cmds "$prelink_cmds" 'exit $?'
887688de56ccSmrg      fi
88771ab64890Smrg
887888de56ccSmrg      wrappers_required=yes
887988de56ccSmrg      case $host in
8880e9fcaa8aSmrg      *cegcc* | *mingw32ce*)
8881e9fcaa8aSmrg        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
8882e9fcaa8aSmrg        wrappers_required=no
8883e9fcaa8aSmrg        ;;
888488de56ccSmrg      *cygwin* | *mingw* )
888588de56ccSmrg        if test "$build_libtool_libs" != yes; then
888688de56ccSmrg          wrappers_required=no
888788de56ccSmrg        fi
888888de56ccSmrg        ;;
888988de56ccSmrg      *)
889088de56ccSmrg        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
889188de56ccSmrg          wrappers_required=no
889288de56ccSmrg        fi
889388de56ccSmrg        ;;
889488de56ccSmrg      esac
889588de56ccSmrg      if test "$wrappers_required" = no; then
889688de56ccSmrg	# Replace the output file specification.
8897e9fcaa8aSmrg	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
889888de56ccSmrg	link_command="$compile_command$compile_rpath"
88991ab64890Smrg
890088de56ccSmrg	# We have no uninstalled library dependencies, so finalize right now.
890188de56ccSmrg	exit_status=0
890288de56ccSmrg	func_show_eval "$link_command" 'exit_status=$?'
89031ab64890Smrg
8904e9fcaa8aSmrg	if test -n "$postlink_cmds"; then
8905e9fcaa8aSmrg	  func_to_tool_file "$output"
8906e9fcaa8aSmrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8907e9fcaa8aSmrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
8908e9fcaa8aSmrg	fi
8909e9fcaa8aSmrg
891088de56ccSmrg	# Delete the generated files.
891188de56ccSmrg	if test -f "$output_objdir/${outputname}S.${objext}"; then
891288de56ccSmrg	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
89131ab64890Smrg	fi
89141ab64890Smrg
891588de56ccSmrg	exit $exit_status
891688de56ccSmrg      fi
89171ab64890Smrg
891888de56ccSmrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
891988de56ccSmrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
892088de56ccSmrg      fi
892188de56ccSmrg      if test -n "$finalize_shlibpath"; then
892288de56ccSmrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
892388de56ccSmrg      fi
8924b4ee4795Smrg
892588de56ccSmrg      compile_var=
892688de56ccSmrg      finalize_var=
892788de56ccSmrg      if test -n "$runpath_var"; then
892888de56ccSmrg	if test -n "$perm_rpath"; then
892988de56ccSmrg	  # We should set the runpath_var.
893088de56ccSmrg	  rpath=
893188de56ccSmrg	  for dir in $perm_rpath; do
8932e9fcaa8aSmrg	    func_append rpath "$dir:"
893388de56ccSmrg	  done
893488de56ccSmrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
89351ab64890Smrg	fi
893688de56ccSmrg	if test -n "$finalize_perm_rpath"; then
893788de56ccSmrg	  # We should set the runpath_var.
893888de56ccSmrg	  rpath=
893988de56ccSmrg	  for dir in $finalize_perm_rpath; do
8940e9fcaa8aSmrg	    func_append rpath "$dir:"
894188de56ccSmrg	  done
894288de56ccSmrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
89431ab64890Smrg	fi
894488de56ccSmrg      fi
89451ab64890Smrg
894688de56ccSmrg      if test "$no_install" = yes; then
894788de56ccSmrg	# We don't need to create a wrapper script.
894888de56ccSmrg	link_command="$compile_var$compile_command$compile_rpath"
894988de56ccSmrg	# Replace the output file specification.
8950e9fcaa8aSmrg	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
895188de56ccSmrg	# Delete the old output file.
895288de56ccSmrg	$opt_dry_run || $RM $output
895388de56ccSmrg	# Link the executable and exit
895488de56ccSmrg	func_show_eval "$link_command" 'exit $?'
8955e9fcaa8aSmrg
8956e9fcaa8aSmrg	if test -n "$postlink_cmds"; then
8957e9fcaa8aSmrg	  func_to_tool_file "$output"
8958e9fcaa8aSmrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8959e9fcaa8aSmrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
8960e9fcaa8aSmrg	fi
8961e9fcaa8aSmrg
8962b4ee4795Smrg	exit $EXIT_SUCCESS
896388de56ccSmrg      fi
89642e9c7c8cSmrg
896588de56ccSmrg      if test "$hardcode_action" = relink; then
896688de56ccSmrg	# Fast installation is not supported
896788de56ccSmrg	link_command="$compile_var$compile_command$compile_rpath"
896888de56ccSmrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
896988de56ccSmrg
897088de56ccSmrg	func_warning "this platform does not like uninstalled shared libraries"
897188de56ccSmrg	func_warning "\`$output' will be relinked during installation"
897288de56ccSmrg      else
897388de56ccSmrg	if test "$fast_install" != no; then
897488de56ccSmrg	  link_command="$finalize_var$compile_command$finalize_rpath"
897588de56ccSmrg	  if test "$fast_install" = yes; then
8976e9fcaa8aSmrg	    relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
897788de56ccSmrg	  else
897888de56ccSmrg	    # fast_install is set to needless
897988de56ccSmrg	    relink_command=
898088de56ccSmrg	  fi
89811ab64890Smrg	else
898288de56ccSmrg	  link_command="$compile_var$compile_command$compile_rpath"
898388de56ccSmrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
89841ab64890Smrg	fi
898588de56ccSmrg      fi
89861ab64890Smrg
898788de56ccSmrg      # Replace the output file specification.
8988e9fcaa8aSmrg      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
89891ab64890Smrg
899088de56ccSmrg      # Delete the old output files.
899188de56ccSmrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
89921ab64890Smrg
899388de56ccSmrg      func_show_eval "$link_command" 'exit $?'
8994b4ee4795Smrg
8995e9fcaa8aSmrg      if test -n "$postlink_cmds"; then
8996e9fcaa8aSmrg	func_to_tool_file "$output_objdir/$outputname"
8997e9fcaa8aSmrg	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'`
8998e9fcaa8aSmrg	func_execute_cmds "$postlink_cmds" 'exit $?'
8999e9fcaa8aSmrg      fi
9000e9fcaa8aSmrg
900188de56ccSmrg      # Now create the wrapper script.
900288de56ccSmrg      func_verbose "creating $output"
9003b4ee4795Smrg
900488de56ccSmrg      # Quote the relink command for shipping.
900588de56ccSmrg      if test -n "$relink_command"; then
900688de56ccSmrg	# Preserve any variables that may affect compiler behavior
900788de56ccSmrg	for var in $variables_saved_for_relink; do
900888de56ccSmrg	  if eval test -z \"\${$var+set}\"; then
900988de56ccSmrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
901088de56ccSmrg	  elif eval var_value=\$$var; test -z "$var_value"; then
901188de56ccSmrg	    relink_command="$var=; export $var; $relink_command"
90121ab64890Smrg	  else
901388de56ccSmrg	    func_quote_for_eval "$var_value"
901488de56ccSmrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
90151ab64890Smrg	  fi
901688de56ccSmrg	done
901788de56ccSmrg	relink_command="(cd `pwd`; $relink_command)"
9018e9fcaa8aSmrg	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
901988de56ccSmrg      fi
902088de56ccSmrg
902188de56ccSmrg      # Only actually do things if not in dry run mode.
902288de56ccSmrg      $opt_dry_run || {
902388de56ccSmrg	# win32 will think the script is a binary if it has
902488de56ccSmrg	# a .exe suffix, so we strip it off here.
902588de56ccSmrg	case $output in
902688de56ccSmrg	  *.exe) func_stripname '' '.exe' "$output"
902788de56ccSmrg	         output=$func_stripname_result ;;
902888de56ccSmrg	esac
902988de56ccSmrg	# test for cygwin because mv fails w/o .exe extensions
903088de56ccSmrg	case $host in
903188de56ccSmrg	  *cygwin*)
903288de56ccSmrg	    exeext=.exe
903388de56ccSmrg	    func_stripname '' '.exe' "$outputname"
903488de56ccSmrg	    outputname=$func_stripname_result ;;
903588de56ccSmrg	  *) exeext= ;;
90361ab64890Smrg	esac
903788de56ccSmrg	case $host in
903888de56ccSmrg	  *cygwin* | *mingw* )
903988de56ccSmrg	    func_dirname_and_basename "$output" "" "."
904088de56ccSmrg	    output_name=$func_basename_result
904188de56ccSmrg	    output_path=$func_dirname_result
904288de56ccSmrg	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
904388de56ccSmrg	    cwrapper="$output_path/$output_name.exe"
904488de56ccSmrg	    $RM $cwrappersource $cwrapper
904588de56ccSmrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
904688de56ccSmrg
904788de56ccSmrg	    func_emit_cwrapperexe_src > $cwrappersource
904888de56ccSmrg
904988de56ccSmrg	    # The wrapper executable is built using the $host compiler,
905088de56ccSmrg	    # because it contains $host paths and files. If cross-
905188de56ccSmrg	    # compiling, it, like the target executable, must be
905288de56ccSmrg	    # executed on the $host or under an emulation environment.
905388de56ccSmrg	    $opt_dry_run || {
905488de56ccSmrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
905588de56ccSmrg	      $STRIP $cwrapper
905688de56ccSmrg	    }
90571ab64890Smrg
905888de56ccSmrg	    # Now, create the wrapper script for func_source use:
905988de56ccSmrg	    func_ltwrapper_scriptname $cwrapper
906088de56ccSmrg	    $RM $func_ltwrapper_scriptname_result
906188de56ccSmrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
906288de56ccSmrg	    $opt_dry_run || {
906388de56ccSmrg	      # note: this script will not be executed, so do not chmod.
906488de56ccSmrg	      if test "x$build" = "x$host" ; then
906588de56ccSmrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
906688de56ccSmrg	      else
906788de56ccSmrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
906888de56ccSmrg	      fi
906988de56ccSmrg	    }
907088de56ccSmrg	  ;;
907188de56ccSmrg	  * )
907288de56ccSmrg	    $RM $output
907388de56ccSmrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
90741ab64890Smrg
907588de56ccSmrg	    func_emit_wrapper no > $output
907688de56ccSmrg	    chmod +x $output
907788de56ccSmrg	  ;;
907888de56ccSmrg	esac
907988de56ccSmrg      }
908088de56ccSmrg      exit $EXIT_SUCCESS
908188de56ccSmrg      ;;
908288de56ccSmrg    esac
90831ab64890Smrg
908488de56ccSmrg    # See if we need to build an old-fashioned archive.
908588de56ccSmrg    for oldlib in $oldlibs; do
90861ab64890Smrg
908788de56ccSmrg      if test "$build_libtool_libs" = convenience; then
908888de56ccSmrg	oldobjs="$libobjs_save $symfileobj"
908988de56ccSmrg	addlibs="$convenience"
909088de56ccSmrg	build_libtool_libs=no
909188de56ccSmrg      else
909288de56ccSmrg	if test "$build_libtool_libs" = module; then
909388de56ccSmrg	  oldobjs="$libobjs_save"
909488de56ccSmrg	  build_libtool_libs=no
909588de56ccSmrg	else
909688de56ccSmrg	  oldobjs="$old_deplibs $non_pic_objects"
909788de56ccSmrg	  if test "$preload" = yes && test -f "$symfileobj"; then
9098e9fcaa8aSmrg	    func_append oldobjs " $symfileobj"
909988de56ccSmrg	  fi
910088de56ccSmrg	fi
910188de56ccSmrg	addlibs="$old_convenience"
91021ab64890Smrg      fi
91031ab64890Smrg
910488de56ccSmrg      if test -n "$addlibs"; then
910588de56ccSmrg	gentop="$output_objdir/${outputname}x"
9106e9fcaa8aSmrg	func_append generated " $gentop"
91071ab64890Smrg
910888de56ccSmrg	func_extract_archives $gentop $addlibs
9109e9fcaa8aSmrg	func_append oldobjs " $func_extract_archives_result"
911088de56ccSmrg      fi
91111ab64890Smrg
911288de56ccSmrg      # Do each command in the archive commands.
911388de56ccSmrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
911488de56ccSmrg	cmds=$old_archive_from_new_cmds
911588de56ccSmrg      else
91161ab64890Smrg
911788de56ccSmrg	# Add any objects from preloaded convenience libraries
911888de56ccSmrg	if test -n "$dlprefiles"; then
911988de56ccSmrg	  gentop="$output_objdir/${outputname}x"
9120e9fcaa8aSmrg	  func_append generated " $gentop"
91211ab64890Smrg
912288de56ccSmrg	  func_extract_archives $gentop $dlprefiles
9123e9fcaa8aSmrg	  func_append oldobjs " $func_extract_archives_result"
912488de56ccSmrg	fi
91251ab64890Smrg
912688de56ccSmrg	# POSIX demands no paths to be encoded in archives.  We have
912788de56ccSmrg	# to avoid creating archives with duplicate basenames if we
912888de56ccSmrg	# might have to extract them afterwards, e.g., when creating a
912988de56ccSmrg	# static archive out of a convenience library, or when linking
913088de56ccSmrg	# the entirety of a libtool archive into another (currently
913188de56ccSmrg	# not supported by libtool).
913288de56ccSmrg	if (for obj in $oldobjs
913388de56ccSmrg	    do
913488de56ccSmrg	      func_basename "$obj"
913588de56ccSmrg	      $ECHO "$func_basename_result"
913688de56ccSmrg	    done | sort | sort -uc >/dev/null 2>&1); then
913788de56ccSmrg	  :
913888de56ccSmrg	else
9139e9fcaa8aSmrg	  echo "copying selected object files to avoid basename conflicts..."
914088de56ccSmrg	  gentop="$output_objdir/${outputname}x"
9141e9fcaa8aSmrg	  func_append generated " $gentop"
914288de56ccSmrg	  func_mkdir_p "$gentop"
914388de56ccSmrg	  save_oldobjs=$oldobjs
914488de56ccSmrg	  oldobjs=
914588de56ccSmrg	  counter=1
914688de56ccSmrg	  for obj in $save_oldobjs
914788de56ccSmrg	  do
914888de56ccSmrg	    func_basename "$obj"
914988de56ccSmrg	    objbase="$func_basename_result"
915088de56ccSmrg	    case " $oldobjs " in
915188de56ccSmrg	    " ") oldobjs=$obj ;;
915288de56ccSmrg	    *[\ /]"$objbase "*)
915388de56ccSmrg	      while :; do
915488de56ccSmrg		# Make sure we don't pick an alternate name that also
915588de56ccSmrg		# overlaps.
915688de56ccSmrg		newobj=lt$counter-$objbase
915788de56ccSmrg		func_arith $counter + 1
915888de56ccSmrg		counter=$func_arith_result
915988de56ccSmrg		case " $oldobjs " in
916088de56ccSmrg		*[\ /]"$newobj "*) ;;
916188de56ccSmrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
916288de56ccSmrg		esac
916388de56ccSmrg	      done
916488de56ccSmrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
9165e9fcaa8aSmrg	      func_append oldobjs " $gentop/$newobj"
916688de56ccSmrg	      ;;
9167e9fcaa8aSmrg	    *) func_append oldobjs " $obj" ;;
916888de56ccSmrg	    esac
91691ab64890Smrg	  done
91702e9c7c8cSmrg	fi
9171eb411b4bSmrg	func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
9172eb411b4bSmrg	tool_oldlib=$func_to_tool_file_result
917388de56ccSmrg	eval cmds=\"$old_archive_cmds\"
9174b4ee4795Smrg
917588de56ccSmrg	func_len " $cmds"
917688de56ccSmrg	len=$func_len_result
917788de56ccSmrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
917888de56ccSmrg	  cmds=$old_archive_cmds
9179e9fcaa8aSmrg	elif test -n "$archiver_list_spec"; then
9180e9fcaa8aSmrg	  func_verbose "using command file archive linking..."
9181e9fcaa8aSmrg	  for obj in $oldobjs
9182e9fcaa8aSmrg	  do
9183e9fcaa8aSmrg	    func_to_tool_file "$obj"
9184e9fcaa8aSmrg	    $ECHO "$func_to_tool_file_result"
9185e9fcaa8aSmrg	  done > $output_objdir/$libname.libcmd
9186e9fcaa8aSmrg	  func_to_tool_file "$output_objdir/$libname.libcmd"
9187e9fcaa8aSmrg	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
9188e9fcaa8aSmrg	  cmds=$old_archive_cmds
918988de56ccSmrg	else
919088de56ccSmrg	  # the command line is too long to link in one step, link in parts
919188de56ccSmrg	  func_verbose "using piecewise archive linking..."
919288de56ccSmrg	  save_RANLIB=$RANLIB
919388de56ccSmrg	  RANLIB=:
919488de56ccSmrg	  objlist=
919588de56ccSmrg	  concat_cmds=
919688de56ccSmrg	  save_oldobjs=$oldobjs
919788de56ccSmrg	  oldobjs=
919888de56ccSmrg	  # Is there a better way of finding the last object in the list?
919988de56ccSmrg	  for obj in $save_oldobjs
920088de56ccSmrg	  do
920188de56ccSmrg	    last_oldobj=$obj
920288de56ccSmrg	  done
920388de56ccSmrg	  eval test_cmds=\"$old_archive_cmds\"
920488de56ccSmrg	  func_len " $test_cmds"
920588de56ccSmrg	  len0=$func_len_result
920688de56ccSmrg	  len=$len0
920788de56ccSmrg	  for obj in $save_oldobjs
920888de56ccSmrg	  do
920988de56ccSmrg	    func_len " $obj"
921088de56ccSmrg	    func_arith $len + $func_len_result
921188de56ccSmrg	    len=$func_arith_result
921288de56ccSmrg	    func_append objlist " $obj"
921388de56ccSmrg	    if test "$len" -lt "$max_cmd_len"; then
921488de56ccSmrg	      :
921588de56ccSmrg	    else
921688de56ccSmrg	      # the above command should be used before it gets too long
921788de56ccSmrg	      oldobjs=$objlist
921888de56ccSmrg	      if test "$obj" = "$last_oldobj" ; then
921988de56ccSmrg		RANLIB=$save_RANLIB
922088de56ccSmrg	      fi
922188de56ccSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
922288de56ccSmrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
922388de56ccSmrg	      objlist=
922488de56ccSmrg	      len=$len0
922588de56ccSmrg	    fi
922688de56ccSmrg	  done
922788de56ccSmrg	  RANLIB=$save_RANLIB
922888de56ccSmrg	  oldobjs=$objlist
922988de56ccSmrg	  if test "X$oldobjs" = "X" ; then
923088de56ccSmrg	    eval cmds=\"\$concat_cmds\"
923188de56ccSmrg	  else
923288de56ccSmrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
923388de56ccSmrg	  fi
923488de56ccSmrg	fi
923588de56ccSmrg      fi
923688de56ccSmrg      func_execute_cmds "$cmds" 'exit $?'
92371ab64890Smrg    done
92381ab64890Smrg
923988de56ccSmrg    test -n "$generated" && \
924088de56ccSmrg      func_show_eval "${RM}r$generated"
92411ab64890Smrg
924288de56ccSmrg    # Now create the libtool archive.
924388de56ccSmrg    case $output in
924488de56ccSmrg    *.la)
924588de56ccSmrg      old_library=
924688de56ccSmrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
924788de56ccSmrg      func_verbose "creating $output"
92482e9c7c8cSmrg
924988de56ccSmrg      # Preserve any variables that may affect compiler behavior
925088de56ccSmrg      for var in $variables_saved_for_relink; do
925188de56ccSmrg	if eval test -z \"\${$var+set}\"; then
925288de56ccSmrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
925388de56ccSmrg	elif eval var_value=\$$var; test -z "$var_value"; then
925488de56ccSmrg	  relink_command="$var=; export $var; $relink_command"
9255b4ee4795Smrg	else
925688de56ccSmrg	  func_quote_for_eval "$var_value"
925788de56ccSmrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9258b4ee4795Smrg	fi
925988de56ccSmrg      done
926088de56ccSmrg      # Quote the link command for shipping.
926188de56ccSmrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
9262e9fcaa8aSmrg      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
926388de56ccSmrg      if test "$hardcode_automatic" = yes ; then
926488de56ccSmrg	relink_command=
926588de56ccSmrg      fi
92661ab64890Smrg
926788de56ccSmrg      # Only create the output if not a dry run.
926888de56ccSmrg      $opt_dry_run || {
926988de56ccSmrg	for installed in no yes; do
927088de56ccSmrg	  if test "$installed" = yes; then
927188de56ccSmrg	    if test -z "$install_libdir"; then
927288de56ccSmrg	      break
927388de56ccSmrg	    fi
927488de56ccSmrg	    output="$output_objdir/$outputname"i
927588de56ccSmrg	    # Replace all uninstalled libtool libraries with the installed ones
927688de56ccSmrg	    newdependency_libs=
927788de56ccSmrg	    for deplib in $dependency_libs; do
927888de56ccSmrg	      case $deplib in
927988de56ccSmrg	      *.la)
928088de56ccSmrg		func_basename "$deplib"
928188de56ccSmrg		name="$func_basename_result"
9282eb411b4bSmrg		func_resolve_sysroot "$deplib"
9283eb411b4bSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
928488de56ccSmrg		test -z "$libdir" && \
928588de56ccSmrg		  func_fatal_error "\`$deplib' is not a valid libtool archive"
9286e9fcaa8aSmrg		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
9287e9fcaa8aSmrg		;;
9288e9fcaa8aSmrg	      -L*)
9289e9fcaa8aSmrg		func_stripname -L '' "$deplib"
9290e9fcaa8aSmrg		func_replace_sysroot "$func_stripname_result"
9291e9fcaa8aSmrg		func_append newdependency_libs " -L$func_replace_sysroot_result"
929288de56ccSmrg		;;
9293e9fcaa8aSmrg	      -R*)
9294e9fcaa8aSmrg		func_stripname -R '' "$deplib"
9295e9fcaa8aSmrg		func_replace_sysroot "$func_stripname_result"
9296e9fcaa8aSmrg		func_append newdependency_libs " -R$func_replace_sysroot_result"
9297e9fcaa8aSmrg		;;
9298e9fcaa8aSmrg	      *) func_append newdependency_libs " $deplib" ;;
929988de56ccSmrg	      esac
930088de56ccSmrg	    done
930188de56ccSmrg	    dependency_libs="$newdependency_libs"
930288de56ccSmrg	    newdlfiles=
930388de56ccSmrg
930488de56ccSmrg	    for lib in $dlfiles; do
930588de56ccSmrg	      case $lib in
930688de56ccSmrg	      *.la)
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 newdlfiles " ${lt_sysroot:+=}$libdir/$name"
931388de56ccSmrg		;;
9314e9fcaa8aSmrg	      *) func_append newdlfiles " $lib" ;;
931588de56ccSmrg	      esac
931688de56ccSmrg	    done
931788de56ccSmrg	    dlfiles="$newdlfiles"
931888de56ccSmrg	    newdlprefiles=
931988de56ccSmrg	    for lib in $dlprefiles; do
932088de56ccSmrg	      case $lib in
932188de56ccSmrg	      *.la)
932288de56ccSmrg		# Only pass preopened files to the pseudo-archive (for
932388de56ccSmrg		# eventual linking with the app. that links it) if we
932488de56ccSmrg		# didn't already link the preopened objects directly into
932588de56ccSmrg		# the library:
932688de56ccSmrg		func_basename "$lib"
932788de56ccSmrg		name="$func_basename_result"
932888de56ccSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
932988de56ccSmrg		test -z "$libdir" && \
933088de56ccSmrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
9331e9fcaa8aSmrg		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
933288de56ccSmrg		;;
933388de56ccSmrg	      esac
933488de56ccSmrg	    done
933588de56ccSmrg	    dlprefiles="$newdlprefiles"
933688de56ccSmrg	  else
933788de56ccSmrg	    newdlfiles=
933888de56ccSmrg	    for lib in $dlfiles; do
933988de56ccSmrg	      case $lib in
934088de56ccSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
934188de56ccSmrg		*) abs=`pwd`"/$lib" ;;
934288de56ccSmrg	      esac
9343e9fcaa8aSmrg	      func_append newdlfiles " $abs"
934488de56ccSmrg	    done
934588de56ccSmrg	    dlfiles="$newdlfiles"
934688de56ccSmrg	    newdlprefiles=
934788de56ccSmrg	    for lib in $dlprefiles; do
934888de56ccSmrg	      case $lib in
934988de56ccSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
935088de56ccSmrg		*) abs=`pwd`"/$lib" ;;
935188de56ccSmrg	      esac
9352e9fcaa8aSmrg	      func_append newdlprefiles " $abs"
935388de56ccSmrg	    done
935488de56ccSmrg	    dlprefiles="$newdlprefiles"
935588de56ccSmrg	  fi
935688de56ccSmrg	  $RM $output
935788de56ccSmrg	  # place dlname in correct position for cygwin
9358e9fcaa8aSmrg	  # In fact, it would be nice if we could use this code for all target
9359e9fcaa8aSmrg	  # systems that can't hard-code library paths into their executables
9360e9fcaa8aSmrg	  # and that have no shared library path variable independent of PATH,
9361e9fcaa8aSmrg	  # but it turns out we can't easily determine that from inspecting
9362e9fcaa8aSmrg	  # libtool variables, so we have to hard-code the OSs to which it
9363e9fcaa8aSmrg	  # applies here; at the moment, that means platforms that use the PE
9364e9fcaa8aSmrg	  # object format with DLL files.  See the long comment at the top of
9365e9fcaa8aSmrg	  # tests/bindir.at for full details.
936688de56ccSmrg	  tdlname=$dlname
936788de56ccSmrg	  case $host,$output,$installed,$module,$dlname in
9368e9fcaa8aSmrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
9369e9fcaa8aSmrg	      # If a -bindir argument was supplied, place the dll there.
9370e9fcaa8aSmrg	      if test "x$bindir" != x ;
9371e9fcaa8aSmrg	      then
9372e9fcaa8aSmrg		func_relative_path "$install_libdir" "$bindir"
9373e9fcaa8aSmrg		tdlname=$func_relative_path_result$dlname
9374e9fcaa8aSmrg	      else
9375e9fcaa8aSmrg		# Otherwise fall back on heuristic.
9376e9fcaa8aSmrg		tdlname=../bin/$dlname
9377e9fcaa8aSmrg	      fi
9378e9fcaa8aSmrg	      ;;
937988de56ccSmrg	  esac
938088de56ccSmrg	  $ECHO > $output "\
938188de56ccSmrg# $outputname - a libtool library file
938288de56ccSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
938388de56ccSmrg#
938488de56ccSmrg# Please DO NOT delete this file!
938588de56ccSmrg# It is necessary for linking the library.
93861ab64890Smrg
938788de56ccSmrg# The name that we can dlopen(3).
938888de56ccSmrgdlname='$tdlname'
93891ab64890Smrg
939088de56ccSmrg# Names of this library.
939188de56ccSmrglibrary_names='$library_names'
93921ab64890Smrg
939388de56ccSmrg# The name of the static archive.
939488de56ccSmrgold_library='$old_library'
93951ab64890Smrg
939688de56ccSmrg# Linker flags that can not go in dependency_libs.
939788de56ccSmrginherited_linker_flags='$new_inherited_linker_flags'
93981ab64890Smrg
939988de56ccSmrg# Libraries that this one depends upon.
940088de56ccSmrgdependency_libs='$dependency_libs'
94011ab64890Smrg
940288de56ccSmrg# Names of additional weak libraries provided by this library
940388de56ccSmrgweak_library_names='$weak_libs'
94041ab64890Smrg
940588de56ccSmrg# Version information for $libname.
940688de56ccSmrgcurrent=$current
940788de56ccSmrgage=$age
940888de56ccSmrgrevision=$revision
94091ab64890Smrg
941088de56ccSmrg# Is this an already installed library?
941188de56ccSmrginstalled=$installed
94121ab64890Smrg
941388de56ccSmrg# Should we warn about portability when linking against -modules?
941488de56ccSmrgshouldnotlink=$module
94151ab64890Smrg
941688de56ccSmrg# Files to dlopen/dlpreopen
941788de56ccSmrgdlopen='$dlfiles'
941888de56ccSmrgdlpreopen='$dlprefiles'
94191ab64890Smrg
942088de56ccSmrg# Directory that this library needs to be installed in:
942188de56ccSmrglibdir='$install_libdir'"
942288de56ccSmrg	  if test "$installed" = no && test "$need_relink" = yes; then
942388de56ccSmrg	    $ECHO >> $output "\
942488de56ccSmrgrelink_command=\"$relink_command\""
942588de56ccSmrg	  fi
942688de56ccSmrg	done
942788de56ccSmrg      }
94281ab64890Smrg
942988de56ccSmrg      # Do a symbolic link so that the libtool archive can be found in
943088de56ccSmrg      # LD_LIBRARY_PATH before the program is installed.
943188de56ccSmrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
943288de56ccSmrg      ;;
943388de56ccSmrg    esac
943488de56ccSmrg    exit $EXIT_SUCCESS
943588de56ccSmrg}
9436b4ee4795Smrg
9437e9fcaa8aSmrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } &&
943888de56ccSmrg    func_mode_link ${1+"$@"}
94391ab64890Smrg
94401ab64890Smrg
944188de56ccSmrg# func_mode_uninstall arg...
944288de56ccSmrgfunc_mode_uninstall ()
944388de56ccSmrg{
944488de56ccSmrg    $opt_debug
944588de56ccSmrg    RM="$nonopt"
94461ab64890Smrg    files=
94471ab64890Smrg    rmforce=
94481ab64890Smrg    exit_status=0
94491ab64890Smrg
94501ab64890Smrg    # This variable tells wrapper scripts just to set variables rather
94511ab64890Smrg    # than running their programs.
94521ab64890Smrg    libtool_install_magic="$magic"
94531ab64890Smrg
94541ab64890Smrg    for arg
94551ab64890Smrg    do
94561ab64890Smrg      case $arg in
9457e9fcaa8aSmrg      -f) func_append RM " $arg"; rmforce=yes ;;
9458e9fcaa8aSmrg      -*) func_append RM " $arg" ;;
9459e9fcaa8aSmrg      *) func_append files " $arg" ;;
94601ab64890Smrg      esac
94611ab64890Smrg    done
94621ab64890Smrg
946388de56ccSmrg    test -z "$RM" && \
946488de56ccSmrg      func_fatal_help "you must specify an RM program"
94651ab64890Smrg
94661ab64890Smrg    rmdirs=
94671ab64890Smrg
94681ab64890Smrg    for file in $files; do
946988de56ccSmrg      func_dirname "$file" "" "."
947088de56ccSmrg      dir="$func_dirname_result"
947188de56ccSmrg      if test "X$dir" = X.; then
9472e9fcaa8aSmrg	odir="$objdir"
94731ab64890Smrg      else
9474e9fcaa8aSmrg	odir="$dir/$objdir"
94751ab64890Smrg      fi
947688de56ccSmrg      func_basename "$file"
947788de56ccSmrg      name="$func_basename_result"
9478e9fcaa8aSmrg      test "$opt_mode" = uninstall && odir="$dir"
94791ab64890Smrg
9480e9fcaa8aSmrg      # Remember odir for removal later, being careful to avoid duplicates
9481e9fcaa8aSmrg      if test "$opt_mode" = clean; then
94821ab64890Smrg	case " $rmdirs " in
9483e9fcaa8aSmrg	  *" $odir "*) ;;
9484e9fcaa8aSmrg	  *) func_append rmdirs " $odir" ;;
94851ab64890Smrg	esac
94861ab64890Smrg      fi
94871ab64890Smrg
94881ab64890Smrg      # Don't error if the file doesn't exist and rm -f was used.
948988de56ccSmrg      if { test -L "$file"; } >/dev/null 2>&1 ||
949088de56ccSmrg	 { test -h "$file"; } >/dev/null 2>&1 ||
949188de56ccSmrg	 test -f "$file"; then
94921ab64890Smrg	:
94931ab64890Smrg      elif test -d "$file"; then
94941ab64890Smrg	exit_status=1
94951ab64890Smrg	continue
94961ab64890Smrg      elif test "$rmforce" = yes; then
94971ab64890Smrg	continue
94981ab64890Smrg      fi
94991ab64890Smrg
95001ab64890Smrg      rmfiles="$file"
95011ab64890Smrg
95021ab64890Smrg      case $name in
95031ab64890Smrg      *.la)
95041ab64890Smrg	# Possibly a libtool archive, so verify it.
950588de56ccSmrg	if func_lalib_p "$file"; then
950688de56ccSmrg	  func_source $dir/$name
95071ab64890Smrg
95081ab64890Smrg	  # Delete the libtool libraries and symlinks.
95091ab64890Smrg	  for n in $library_names; do
9510e9fcaa8aSmrg	    func_append rmfiles " $odir/$n"
95111ab64890Smrg	  done
9512e9fcaa8aSmrg	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
95131ab64890Smrg
9514e9fcaa8aSmrg	  case "$opt_mode" in
95151ab64890Smrg	  clean)
9516e9fcaa8aSmrg	    case " $library_names " in
95171ab64890Smrg	    *" $dlname "*) ;;
9518e9fcaa8aSmrg	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
95191ab64890Smrg	    esac
9520e9fcaa8aSmrg	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
95211ab64890Smrg	    ;;
95221ab64890Smrg	  uninstall)
95231ab64890Smrg	    if test -n "$library_names"; then
95241ab64890Smrg	      # Do each command in the postuninstall commands.
952588de56ccSmrg	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
95261ab64890Smrg	    fi
95271ab64890Smrg
95281ab64890Smrg	    if test -n "$old_library"; then
95291ab64890Smrg	      # Do each command in the old_postuninstall commands.
953088de56ccSmrg	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
95311ab64890Smrg	    fi
95321ab64890Smrg	    # FIXME: should reinstall the best remaining shared library.
95331ab64890Smrg	    ;;
95341ab64890Smrg	  esac
95351ab64890Smrg	fi
95361ab64890Smrg	;;
95371ab64890Smrg
95381ab64890Smrg      *.lo)
95391ab64890Smrg	# Possibly a libtool object, so verify it.
954088de56ccSmrg	if func_lalib_p "$file"; then
95411ab64890Smrg
95421ab64890Smrg	  # Read the .lo file
954388de56ccSmrg	  func_source $dir/$name
95441ab64890Smrg
95451ab64890Smrg	  # Add PIC object to the list of files to remove.
954688de56ccSmrg	  if test -n "$pic_object" &&
954788de56ccSmrg	     test "$pic_object" != none; then
9548e9fcaa8aSmrg	    func_append rmfiles " $dir/$pic_object"
95491ab64890Smrg	  fi
95501ab64890Smrg
95511ab64890Smrg	  # Add non-PIC object to the list of files to remove.
955288de56ccSmrg	  if test -n "$non_pic_object" &&
955388de56ccSmrg	     test "$non_pic_object" != none; then
9554e9fcaa8aSmrg	    func_append rmfiles " $dir/$non_pic_object"
95551ab64890Smrg	  fi
95561ab64890Smrg	fi
95571ab64890Smrg	;;
95581ab64890Smrg
95591ab64890Smrg      *)
9560e9fcaa8aSmrg	if test "$opt_mode" = clean ; then
95611ab64890Smrg	  noexename=$name
95621ab64890Smrg	  case $file in
95631ab64890Smrg	  *.exe)
956488de56ccSmrg	    func_stripname '' '.exe' "$file"
956588de56ccSmrg	    file=$func_stripname_result
956688de56ccSmrg	    func_stripname '' '.exe' "$name"
956788de56ccSmrg	    noexename=$func_stripname_result
95681ab64890Smrg	    # $file with .exe has already been added to rmfiles,
95691ab64890Smrg	    # add $file without .exe
9570e9fcaa8aSmrg	    func_append rmfiles " $file"
95711ab64890Smrg	    ;;
95721ab64890Smrg	  esac
95731ab64890Smrg	  # Do a test to see if this is a libtool program.
957488de56ccSmrg	  if func_ltwrapper_p "$file"; then
957588de56ccSmrg	    if func_ltwrapper_executable_p "$file"; then
957688de56ccSmrg	      func_ltwrapper_scriptname "$file"
957788de56ccSmrg	      relink_command=
957888de56ccSmrg	      func_source $func_ltwrapper_scriptname_result
9579e9fcaa8aSmrg	      func_append rmfiles " $func_ltwrapper_scriptname_result"
958088de56ccSmrg	    else
958188de56ccSmrg	      relink_command=
958288de56ccSmrg	      func_source $dir/$noexename
958388de56ccSmrg	    fi
95841ab64890Smrg
95851ab64890Smrg	    # note $name still contains .exe if it was in $file originally
95861ab64890Smrg	    # as does the version of $file that was added into $rmfiles
9587e9fcaa8aSmrg	    func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
95881ab64890Smrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
9589e9fcaa8aSmrg	      func_append rmfiles " $odir/lt-$name"
95901ab64890Smrg	    fi
95911ab64890Smrg	    if test "X$noexename" != "X$name" ; then
9592e9fcaa8aSmrg	      func_append rmfiles " $odir/lt-${noexename}.c"
95931ab64890Smrg	    fi
95941ab64890Smrg	  fi
95951ab64890Smrg	fi
95961ab64890Smrg	;;
95971ab64890Smrg      esac
959888de56ccSmrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
95991ab64890Smrg    done
96001ab64890Smrg
96011ab64890Smrg    # Try to remove the ${objdir}s in the directories where we deleted files
96021ab64890Smrg    for dir in $rmdirs; do
96031ab64890Smrg      if test -d "$dir"; then
960488de56ccSmrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
96051ab64890Smrg      fi
96061ab64890Smrg    done
96071ab64890Smrg
96081ab64890Smrg    exit $exit_status
960988de56ccSmrg}
96101ab64890Smrg
9611e9fcaa8aSmrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
961288de56ccSmrg    func_mode_uninstall ${1+"$@"}
96132e9c7c8cSmrg
9614e9fcaa8aSmrgtest -z "$opt_mode" && {
961588de56ccSmrg  help="$generic_help"
961688de56ccSmrg  func_fatal_help "you must specify a MODE"
961788de56ccSmrg}
961888de56ccSmrg
961988de56ccSmrgtest -z "$exec_cmd" && \
9620e9fcaa8aSmrg  func_fatal_help "invalid operation mode \`$opt_mode'"
96211ab64890Smrg
96221ab64890Smrgif test -n "$exec_cmd"; then
962388de56ccSmrg  eval exec "$exec_cmd"
96241ab64890Smrg  exit $EXIT_FAILURE
96251ab64890Smrgfi
96261ab64890Smrg
962788de56ccSmrgexit $exit_status
96281ab64890Smrg
96291ab64890Smrg
96301ab64890Smrg# The TAGs below are defined such that we never get into a situation
96311ab64890Smrg# in which we disable both kinds of libraries.  Given conflicting
96321ab64890Smrg# choices, we go for a static library, that is the most portable,
96331ab64890Smrg# since we can't tell whether shared libraries were disabled because
96341ab64890Smrg# the user asked for that or because the platform doesn't support
96351ab64890Smrg# them.  This is particularly important on AIX, because we don't
96361ab64890Smrg# support having both static and shared libraries enabled at the same
96371ab64890Smrg# time on that platform, so we default to a shared-only configuration.
96381ab64890Smrg# If a disable-shared tag is given, we'll fallback to a static-only
96391ab64890Smrg# configuration.  But we'll never go from static-only to shared-only.
96401ab64890Smrg
96411ab64890Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
964288de56ccSmrgbuild_libtool_libs=no
964388de56ccSmrgbuild_old_libs=yes
96441ab64890Smrg# ### END LIBTOOL TAG CONFIG: disable-shared
96451ab64890Smrg
96461ab64890Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
964788de56ccSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
96481ab64890Smrg# ### END LIBTOOL TAG CONFIG: disable-static
96491ab64890Smrg
96501ab64890Smrg# Local Variables:
96511ab64890Smrg# mode:shell-script
96521ab64890Smrg# sh-indentation:2
96531ab64890Smrg# End:
965488de56ccSmrg# vi:sw=2
965588de56ccSmrg
9656