1b85037dbSmrg
228515619Smrg# libtool (GNU libtool) 2.4.2
3b85037dbSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
4b85037dbSmrg
5b85037dbSmrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
628515619Smrg# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
7b85037dbSmrg# This is free software; see the source for copying conditions.  There is NO
8b85037dbSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9b85037dbSmrg
10b85037dbSmrg# GNU Libtool is free software; you can redistribute it and/or modify
11b85037dbSmrg# it under the terms of the GNU General Public License as published by
12b85037dbSmrg# the Free Software Foundation; either version 2 of the License, or
13b85037dbSmrg# (at your option) any later version.
14b85037dbSmrg#
15b85037dbSmrg# As a special exception to the GNU General Public License,
16b85037dbSmrg# if you distribute this file as part of a program or library that
17b85037dbSmrg# is built using GNU Libtool, you may include this file under the
18b85037dbSmrg# same distribution terms that you use for the rest of that program.
19b85037dbSmrg#
20b85037dbSmrg# GNU Libtool is distributed in the hope that it will be useful, but
21b85037dbSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
22b85037dbSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23b85037dbSmrg# General Public License for more details.
24b85037dbSmrg#
25b85037dbSmrg# You should have received a copy of the GNU General Public License
26b85037dbSmrg# along with GNU Libtool; see the file COPYING.  If not, a copy
27b85037dbSmrg# can be downloaded from http://www.gnu.org/licenses/gpl.html,
28b85037dbSmrg# or obtained by writing to the Free Software Foundation, Inc.,
29b85037dbSmrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30b85037dbSmrg
31b85037dbSmrg# Usage: $progname [OPTION]... [MODE-ARG]...
32b85037dbSmrg#
33b85037dbSmrg# Provide generalized library-building support services.
34b85037dbSmrg#
35b85037dbSmrg#       --config             show all configuration variables
36b85037dbSmrg#       --debug              enable verbose shell tracing
37b85037dbSmrg#   -n, --dry-run            display commands without modifying any files
38b85037dbSmrg#       --features           display basic configuration information and exit
39b85037dbSmrg#       --mode=MODE          use operation mode MODE
40b85037dbSmrg#       --preserve-dup-deps  don't remove duplicate dependency libraries
41b85037dbSmrg#       --quiet, --silent    don't print informational messages
42b85037dbSmrg#       --no-quiet, --no-silent
43b85037dbSmrg#                            print informational messages (default)
4428515619Smrg#       --no-warn            don't display warning messages
45b85037dbSmrg#       --tag=TAG            use configuration variables from tag TAG
46b85037dbSmrg#   -v, --verbose            print more informational messages than default
47b85037dbSmrg#       --no-verbose         don't print the extra informational messages
48b85037dbSmrg#       --version            print version information
49b85037dbSmrg#   -h, --help, --help-all   print short, long, or detailed help message
50b85037dbSmrg#
51b85037dbSmrg# MODE must be one of the following:
52b85037dbSmrg#
53b85037dbSmrg#         clean              remove files from the build directory
54b85037dbSmrg#         compile            compile a source file into a libtool object
55b85037dbSmrg#         execute            automatically set library path, then run a program
56b85037dbSmrg#         finish             complete the installation of libtool libraries
57b85037dbSmrg#         install            install libraries or executables
58b85037dbSmrg#         link               create a library or an executable
59b85037dbSmrg#         uninstall          remove libraries from an installed directory
60b85037dbSmrg#
61b85037dbSmrg# MODE-ARGS vary depending on the MODE.  When passed as first option,
62b85037dbSmrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
63b85037dbSmrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
64b85037dbSmrg#
65b85037dbSmrg# When reporting a bug, please describe a test case to reproduce it and
66b85037dbSmrg# include the following information:
67b85037dbSmrg#
68b85037dbSmrg#         host-triplet:	$host
69b85037dbSmrg#         shell:		$SHELL
70b85037dbSmrg#         compiler:		$LTCC
71b85037dbSmrg#         compiler flags:		$LTCFLAGS
72b85037dbSmrg#         linker:		$LD (gnu? $with_gnu_ld)
7328515619Smrg#         $progname:	(GNU libtool) 2.4.2
74b85037dbSmrg#         automake:	$automake_version
75b85037dbSmrg#         autoconf:	$autoconf_version
76b85037dbSmrg#
77b85037dbSmrg# Report bugs to <bug-libtool@gnu.org>.
78302b15bdSmrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
79302b15bdSmrg# General help using GNU software: <http://www.gnu.org/gethelp/>.
80b85037dbSmrg
81b85037dbSmrgPROGRAM=libtool
82b85037dbSmrgPACKAGE=libtool
8328515619SmrgVERSION=2.4.2
84b85037dbSmrgTIMESTAMP=""
8528515619Smrgpackage_revision=1.3337
86b85037dbSmrg
87b85037dbSmrg# Be Bourne compatible
88b85037dbSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
89b85037dbSmrg  emulate sh
90b85037dbSmrg  NULLCMD=:
91b85037dbSmrg  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
92b85037dbSmrg  # is contrary to our usage.  Disable this feature.
93b85037dbSmrg  alias -g '${1+"$@"}'='"$@"'
94b85037dbSmrg  setopt NO_GLOB_SUBST
95b85037dbSmrgelse
96b85037dbSmrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
97b85037dbSmrgfi
98b85037dbSmrgBIN_SH=xpg4; export BIN_SH # for Tru64
99b85037dbSmrgDUALCASE=1; export DUALCASE # for MKS sh
100b85037dbSmrg
101b85037dbSmrg# A function that is used when there is no print builtin or printf.
102b85037dbSmrgfunc_fallback_echo ()
103b85037dbSmrg{
104b85037dbSmrg  eval 'cat <<_LTECHO_EOF
105b85037dbSmrg$1
106b85037dbSmrg_LTECHO_EOF'
107b85037dbSmrg}
108b85037dbSmrg
109b85037dbSmrg# NLS nuisances: We save the old values to restore during execute mode.
110b85037dbSmrglt_user_locale=
111b85037dbSmrglt_safe_locale=
112b85037dbSmrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
113b85037dbSmrgdo
114b85037dbSmrg  eval "if test \"\${$lt_var+set}\" = set; then
115b85037dbSmrg          save_$lt_var=\$$lt_var
116b85037dbSmrg          $lt_var=C
117b85037dbSmrg	  export $lt_var
118b85037dbSmrg	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
119b85037dbSmrg	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
120b85037dbSmrg	fi"
121b85037dbSmrgdone
122b85037dbSmrgLC_ALL=C
123b85037dbSmrgLANGUAGE=C
124b85037dbSmrgexport LANGUAGE LC_ALL
125b85037dbSmrg
126b85037dbSmrg$lt_unset CDPATH
127b85037dbSmrg
128b85037dbSmrg
129b85037dbSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
130b85037dbSmrg# is ksh but when the shell is invoked as "sh" and the current value of
131b85037dbSmrg# the _XPG environment variable is not equal to 1 (one), the special
132b85037dbSmrg# positional parameter $0, within a function call, is the name of the
133b85037dbSmrg# function.
134b85037dbSmrgprogpath="$0"
135b85037dbSmrg
136b85037dbSmrg
137b85037dbSmrg
138b85037dbSmrg: ${CP="cp -f"}
139b85037dbSmrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
140b85037dbSmrg: ${MAKE="make"}
141b85037dbSmrg: ${MKDIR="mkdir"}
142b85037dbSmrg: ${MV="mv -f"}
143b85037dbSmrg: ${RM="rm -f"}
144b85037dbSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
145b85037dbSmrg: ${Xsed="$SED -e 1s/^X//"}
146b85037dbSmrg
147b85037dbSmrg# Global variables:
148b85037dbSmrgEXIT_SUCCESS=0
149b85037dbSmrgEXIT_FAILURE=1
150b85037dbSmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
151b85037dbSmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
152b85037dbSmrg
153b85037dbSmrgexit_status=$EXIT_SUCCESS
154b85037dbSmrg
155b85037dbSmrg# Make sure IFS has a sensible default
156b85037dbSmrglt_nl='
157b85037dbSmrg'
158b85037dbSmrgIFS=" 	$lt_nl"
159b85037dbSmrg
160b85037dbSmrgdirname="s,/[^/]*$,,"
161b85037dbSmrgbasename="s,^.*/,,"
162b85037dbSmrg
163302b15bdSmrg# func_dirname file append nondir_replacement
164302b15bdSmrg# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
165302b15bdSmrg# otherwise set result to NONDIR_REPLACEMENT.
166302b15bdSmrgfunc_dirname ()
167302b15bdSmrg{
168302b15bdSmrg    func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
169302b15bdSmrg    if test "X$func_dirname_result" = "X${1}"; then
170302b15bdSmrg      func_dirname_result="${3}"
171302b15bdSmrg    else
172302b15bdSmrg      func_dirname_result="$func_dirname_result${2}"
173302b15bdSmrg    fi
174302b15bdSmrg} # func_dirname may be replaced by extended shell implementation
175302b15bdSmrg
176302b15bdSmrg
177302b15bdSmrg# func_basename file
178302b15bdSmrgfunc_basename ()
179302b15bdSmrg{
180302b15bdSmrg    func_basename_result=`$ECHO "${1}" | $SED "$basename"`
181302b15bdSmrg} # func_basename may be replaced by extended shell implementation
182302b15bdSmrg
183302b15bdSmrg
184b85037dbSmrg# func_dirname_and_basename file append nondir_replacement
185b85037dbSmrg# perform func_basename and func_dirname in a single function
186b85037dbSmrg# call:
187b85037dbSmrg#   dirname:  Compute the dirname of FILE.  If nonempty,
188b85037dbSmrg#             add APPEND to the result, otherwise set result
189b85037dbSmrg#             to NONDIR_REPLACEMENT.
190b85037dbSmrg#             value returned in "$func_dirname_result"
191b85037dbSmrg#   basename: Compute filename of FILE.
192b85037dbSmrg#             value retuned in "$func_basename_result"
193b85037dbSmrg# Implementation must be kept synchronized with func_dirname
194b85037dbSmrg# and func_basename. For efficiency, we do not delegate to
195b85037dbSmrg# those functions but instead duplicate the functionality here.
196b85037dbSmrgfunc_dirname_and_basename ()
197b85037dbSmrg{
198302b15bdSmrg    # Extract subdirectory from the argument.
199302b15bdSmrg    func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
200302b15bdSmrg    if test "X$func_dirname_result" = "X${1}"; then
201302b15bdSmrg      func_dirname_result="${3}"
202302b15bdSmrg    else
203302b15bdSmrg      func_dirname_result="$func_dirname_result${2}"
204302b15bdSmrg    fi
205302b15bdSmrg    func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
206302b15bdSmrg} # func_dirname_and_basename may be replaced by extended shell implementation
207302b15bdSmrg
208302b15bdSmrg
209302b15bdSmrg# func_stripname prefix suffix name
210302b15bdSmrg# strip PREFIX and SUFFIX off of NAME.
211302b15bdSmrg# PREFIX and SUFFIX must not contain globbing or regex special
212302b15bdSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading
213302b15bdSmrg# dot (in which case that matches only a dot).
214302b15bdSmrg# func_strip_suffix prefix name
215302b15bdSmrgfunc_stripname ()
216302b15bdSmrg{
217302b15bdSmrg    case ${2} in
218302b15bdSmrg      .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
219302b15bdSmrg      *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
220302b15bdSmrg    esac
221302b15bdSmrg} # func_stripname may be replaced by extended shell implementation
222b85037dbSmrg
223b85037dbSmrg
224b85037dbSmrg# These SED scripts presuppose an absolute path with a trailing slash.
225b85037dbSmrgpathcar='s,^/\([^/]*\).*$,\1,'
226b85037dbSmrgpathcdr='s,^/[^/]*,,'
227b85037dbSmrgremovedotparts=':dotsl
228b85037dbSmrg		s@/\./@/@g
229b85037dbSmrg		t dotsl
230b85037dbSmrg		s,/\.$,/,'
231b85037dbSmrgcollapseslashes='s@/\{1,\}@/@g'
232b85037dbSmrgfinalslash='s,/*$,/,'
233b85037dbSmrg
234b85037dbSmrg# func_normal_abspath PATH
235b85037dbSmrg# Remove doubled-up and trailing slashes, "." path components,
236b85037dbSmrg# and cancel out any ".." path components in PATH after making
237b85037dbSmrg# it an absolute path.
238b85037dbSmrg#             value returned in "$func_normal_abspath_result"
239b85037dbSmrgfunc_normal_abspath ()
240b85037dbSmrg{
241b85037dbSmrg  # Start from root dir and reassemble the path.
242b85037dbSmrg  func_normal_abspath_result=
243b85037dbSmrg  func_normal_abspath_tpath=$1
244b85037dbSmrg  func_normal_abspath_altnamespace=
245b85037dbSmrg  case $func_normal_abspath_tpath in
246b85037dbSmrg    "")
247b85037dbSmrg      # Empty path, that just means $cwd.
248b85037dbSmrg      func_stripname '' '/' "`pwd`"
249b85037dbSmrg      func_normal_abspath_result=$func_stripname_result
250b85037dbSmrg      return
251b85037dbSmrg    ;;
252b85037dbSmrg    # The next three entries are used to spot a run of precisely
253b85037dbSmrg    # two leading slashes without using negated character classes;
254b85037dbSmrg    # we take advantage of case's first-match behaviour.
255b85037dbSmrg    ///*)
256b85037dbSmrg      # Unusual form of absolute path, do nothing.
257b85037dbSmrg    ;;
258b85037dbSmrg    //*)
259b85037dbSmrg      # Not necessarily an ordinary path; POSIX reserves leading '//'
260b85037dbSmrg      # and for example Cygwin uses it to access remote file shares
261b85037dbSmrg      # over CIFS/SMB, so we conserve a leading double slash if found.
262b85037dbSmrg      func_normal_abspath_altnamespace=/
263b85037dbSmrg    ;;
264b85037dbSmrg    /*)
265b85037dbSmrg      # Absolute path, do nothing.
266b85037dbSmrg    ;;
267b85037dbSmrg    *)
268b85037dbSmrg      # Relative path, prepend $cwd.
269b85037dbSmrg      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
270b85037dbSmrg    ;;
271b85037dbSmrg  esac
272b85037dbSmrg  # Cancel out all the simple stuff to save iterations.  We also want
273b85037dbSmrg  # the path to end with a slash for ease of parsing, so make sure
274b85037dbSmrg  # there is one (and only one) here.
275b85037dbSmrg  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
276b85037dbSmrg        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
277b85037dbSmrg  while :; do
278b85037dbSmrg    # Processed it all yet?
279b85037dbSmrg    if test "$func_normal_abspath_tpath" = / ; then
280b85037dbSmrg      # If we ascended to the root using ".." the result may be empty now.
281b85037dbSmrg      if test -z "$func_normal_abspath_result" ; then
282b85037dbSmrg        func_normal_abspath_result=/
283b85037dbSmrg      fi
284b85037dbSmrg      break
285b85037dbSmrg    fi
286b85037dbSmrg    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
287b85037dbSmrg        -e "$pathcar"`
288b85037dbSmrg    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
289b85037dbSmrg        -e "$pathcdr"`
290b85037dbSmrg    # Figure out what to do with it
291b85037dbSmrg    case $func_normal_abspath_tcomponent in
292b85037dbSmrg      "")
293b85037dbSmrg        # Trailing empty path component, ignore it.
294b85037dbSmrg      ;;
295b85037dbSmrg      ..)
296b85037dbSmrg        # Parent dir; strip last assembled component from result.
297b85037dbSmrg        func_dirname "$func_normal_abspath_result"
298b85037dbSmrg        func_normal_abspath_result=$func_dirname_result
299b85037dbSmrg      ;;
300b85037dbSmrg      *)
301b85037dbSmrg        # Actual path component, append it.
302b85037dbSmrg        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
303b85037dbSmrg      ;;
304b85037dbSmrg    esac
305b85037dbSmrg  done
306b85037dbSmrg  # Restore leading double-slash if one was found on entry.
307b85037dbSmrg  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
308b85037dbSmrg}
309b85037dbSmrg
310b85037dbSmrg# func_relative_path SRCDIR DSTDIR
311b85037dbSmrg# generates a relative path from SRCDIR to DSTDIR, with a trailing
312b85037dbSmrg# slash if non-empty, suitable for immediately appending a filename
313b85037dbSmrg# without needing to append a separator.
314b85037dbSmrg#             value returned in "$func_relative_path_result"
315b85037dbSmrgfunc_relative_path ()
316b85037dbSmrg{
317b85037dbSmrg  func_relative_path_result=
318b85037dbSmrg  func_normal_abspath "$1"
319b85037dbSmrg  func_relative_path_tlibdir=$func_normal_abspath_result
320b85037dbSmrg  func_normal_abspath "$2"
321b85037dbSmrg  func_relative_path_tbindir=$func_normal_abspath_result
322b85037dbSmrg
323b85037dbSmrg  # Ascend the tree starting from libdir
324b85037dbSmrg  while :; do
325b85037dbSmrg    # check if we have found a prefix of bindir
326b85037dbSmrg    case $func_relative_path_tbindir in
327b85037dbSmrg      $func_relative_path_tlibdir)
328b85037dbSmrg        # found an exact match
329b85037dbSmrg        func_relative_path_tcancelled=
330b85037dbSmrg        break
331b85037dbSmrg        ;;
332b85037dbSmrg      $func_relative_path_tlibdir*)
333b85037dbSmrg        # found a matching prefix
334b85037dbSmrg        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
335b85037dbSmrg        func_relative_path_tcancelled=$func_stripname_result
336b85037dbSmrg        if test -z "$func_relative_path_result"; then
337b85037dbSmrg          func_relative_path_result=.
338b85037dbSmrg        fi
339b85037dbSmrg        break
340b85037dbSmrg        ;;
341b85037dbSmrg      *)
342b85037dbSmrg        func_dirname $func_relative_path_tlibdir
343b85037dbSmrg        func_relative_path_tlibdir=${func_dirname_result}
344b85037dbSmrg        if test "x$func_relative_path_tlibdir" = x ; then
345b85037dbSmrg          # Have to descend all the way to the root!
346b85037dbSmrg          func_relative_path_result=../$func_relative_path_result
347b85037dbSmrg          func_relative_path_tcancelled=$func_relative_path_tbindir
348b85037dbSmrg          break
349b85037dbSmrg        fi
350b85037dbSmrg        func_relative_path_result=../$func_relative_path_result
351b85037dbSmrg        ;;
352b85037dbSmrg    esac
353b85037dbSmrg  done
354b85037dbSmrg
355b85037dbSmrg  # Now calculate path; take care to avoid doubling-up slashes.
356b85037dbSmrg  func_stripname '' '/' "$func_relative_path_result"
357b85037dbSmrg  func_relative_path_result=$func_stripname_result
358b85037dbSmrg  func_stripname '/' '/' "$func_relative_path_tcancelled"
359b85037dbSmrg  if test "x$func_stripname_result" != x ; then
360b85037dbSmrg    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
361b85037dbSmrg  fi
362b85037dbSmrg
363b85037dbSmrg  # Normalisation. If bindir is libdir, return empty string,
364b85037dbSmrg  # else relative path ending with a slash; either way, target
365b85037dbSmrg  # file name can be directly appended.
366b85037dbSmrg  if test ! -z "$func_relative_path_result"; then
367b85037dbSmrg    func_stripname './' '' "$func_relative_path_result/"
368b85037dbSmrg    func_relative_path_result=$func_stripname_result
369b85037dbSmrg  fi
370b85037dbSmrg}
371b85037dbSmrg
372b85037dbSmrg# The name of this program:
373b85037dbSmrgfunc_dirname_and_basename "$progpath"
374b85037dbSmrgprogname=$func_basename_result
375b85037dbSmrg
376b85037dbSmrg# Make sure we have an absolute path for reexecution:
377b85037dbSmrgcase $progpath in
378b85037dbSmrg  [\\/]*|[A-Za-z]:\\*) ;;
379b85037dbSmrg  *[\\/]*)
380b85037dbSmrg     progdir=$func_dirname_result
381b85037dbSmrg     progdir=`cd "$progdir" && pwd`
382b85037dbSmrg     progpath="$progdir/$progname"
383b85037dbSmrg     ;;
384b85037dbSmrg  *)
385b85037dbSmrg     save_IFS="$IFS"
38628515619Smrg     IFS=${PATH_SEPARATOR-:}
387b85037dbSmrg     for progdir in $PATH; do
388b85037dbSmrg       IFS="$save_IFS"
389b85037dbSmrg       test -x "$progdir/$progname" && break
390b85037dbSmrg     done
391b85037dbSmrg     IFS="$save_IFS"
392b85037dbSmrg     test -n "$progdir" || progdir=`pwd`
393b85037dbSmrg     progpath="$progdir/$progname"
394b85037dbSmrg     ;;
395b85037dbSmrgesac
396b85037dbSmrg
397b85037dbSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
398b85037dbSmrg# metacharacters that are still active within double-quoted strings.
399b85037dbSmrgXsed="${SED}"' -e 1s/^X//'
400b85037dbSmrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g'
401b85037dbSmrg
402b85037dbSmrg# Same as above, but do not quote variable references.
403b85037dbSmrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g'
404b85037dbSmrg
405302b15bdSmrg# Sed substitution that turns a string into a regex matching for the
406302b15bdSmrg# string literally.
407302b15bdSmrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
408302b15bdSmrg
409302b15bdSmrg# Sed substitution that converts a w32 file name or path
410302b15bdSmrg# which contains forward slashes, into one that contains
411302b15bdSmrg# (escaped) backslashes.  A very naive implementation.
412302b15bdSmrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
413302b15bdSmrg
414b85037dbSmrg# Re-`\' parameter expansions in output of double_quote_subst that were
415b85037dbSmrg# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
416b85037dbSmrg# in input to double_quote_subst, that '$' was protected from expansion.
417b85037dbSmrg# Since each input `\' is now two `\'s, look for any number of runs of
418b85037dbSmrg# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
419b85037dbSmrgbs='\\'
420b85037dbSmrgbs2='\\\\'
421b85037dbSmrgbs4='\\\\\\\\'
422b85037dbSmrgdollar='\$'
423b85037dbSmrgsed_double_backslash="\
424b85037dbSmrg  s/$bs4/&\\
425b85037dbSmrg/g
426b85037dbSmrg  s/^$bs2$dollar/$bs&/
427b85037dbSmrg  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
428b85037dbSmrg  s/\n//g"
429b85037dbSmrg
430b85037dbSmrg# Standard options:
431b85037dbSmrgopt_dry_run=false
432b85037dbSmrgopt_help=false
433b85037dbSmrgopt_quiet=false
434b85037dbSmrgopt_verbose=false
435b85037dbSmrgopt_warning=:
436b85037dbSmrg
437b85037dbSmrg# func_echo arg...
438b85037dbSmrg# Echo program name prefixed message, along with the current mode
439b85037dbSmrg# name if it has been set yet.
440b85037dbSmrgfunc_echo ()
441b85037dbSmrg{
442302b15bdSmrg    $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
443b85037dbSmrg}
444b85037dbSmrg
445b85037dbSmrg# func_verbose arg...
446b85037dbSmrg# Echo program name prefixed message in verbose mode only.
447b85037dbSmrgfunc_verbose ()
448b85037dbSmrg{
449b85037dbSmrg    $opt_verbose && func_echo ${1+"$@"}
450b85037dbSmrg
451b85037dbSmrg    # A bug in bash halts the script if the last line of a function
452b85037dbSmrg    # fails when set -e is in force, so we need another command to
453b85037dbSmrg    # work around that:
454b85037dbSmrg    :
455b85037dbSmrg}
456b85037dbSmrg
457b85037dbSmrg# func_echo_all arg...
458b85037dbSmrg# Invoke $ECHO with all args, space-separated.
459b85037dbSmrgfunc_echo_all ()
460b85037dbSmrg{
461b85037dbSmrg    $ECHO "$*"
462b85037dbSmrg}
463b85037dbSmrg
464b85037dbSmrg# func_error arg...
465b85037dbSmrg# Echo program name prefixed message to standard error.
466b85037dbSmrgfunc_error ()
467b85037dbSmrg{
468302b15bdSmrg    $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
469b85037dbSmrg}
470b85037dbSmrg
471b85037dbSmrg# func_warning arg...
472b85037dbSmrg# Echo program name prefixed warning message to standard error.
473b85037dbSmrgfunc_warning ()
474b85037dbSmrg{
475302b15bdSmrg    $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
476b85037dbSmrg
477b85037dbSmrg    # bash bug again:
478b85037dbSmrg    :
479b85037dbSmrg}
480b85037dbSmrg
481b85037dbSmrg# func_fatal_error arg...
482b85037dbSmrg# Echo program name prefixed message to standard error, and exit.
483b85037dbSmrgfunc_fatal_error ()
484b85037dbSmrg{
485b85037dbSmrg    func_error ${1+"$@"}
486b85037dbSmrg    exit $EXIT_FAILURE
487b85037dbSmrg}
488b85037dbSmrg
489b85037dbSmrg# func_fatal_help arg...
490b85037dbSmrg# Echo program name prefixed message to standard error, followed by
491b85037dbSmrg# a help hint, and exit.
492b85037dbSmrgfunc_fatal_help ()
493b85037dbSmrg{
494b85037dbSmrg    func_error ${1+"$@"}
495b85037dbSmrg    func_fatal_error "$help"
496b85037dbSmrg}
497b85037dbSmrghelp="Try \`$progname --help' for more information."  ## default
498b85037dbSmrg
499b85037dbSmrg
500b85037dbSmrg# func_grep expression filename
501b85037dbSmrg# Check whether EXPRESSION matches any line of FILENAME, without output.
502b85037dbSmrgfunc_grep ()
503b85037dbSmrg{
504b85037dbSmrg    $GREP "$1" "$2" >/dev/null 2>&1
505b85037dbSmrg}
506b85037dbSmrg
507b85037dbSmrg
508b85037dbSmrg# func_mkdir_p directory-path
509b85037dbSmrg# Make sure the entire path to DIRECTORY-PATH is available.
510b85037dbSmrgfunc_mkdir_p ()
511b85037dbSmrg{
512b85037dbSmrg    my_directory_path="$1"
513b85037dbSmrg    my_dir_list=
514b85037dbSmrg
515b85037dbSmrg    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
516b85037dbSmrg
517b85037dbSmrg      # Protect directory names starting with `-'
518b85037dbSmrg      case $my_directory_path in
519b85037dbSmrg        -*) my_directory_path="./$my_directory_path" ;;
520b85037dbSmrg      esac
521b85037dbSmrg
522b85037dbSmrg      # While some portion of DIR does not yet exist...
523b85037dbSmrg      while test ! -d "$my_directory_path"; do
524b85037dbSmrg        # ...make a list in topmost first order.  Use a colon delimited
525b85037dbSmrg	# list incase some portion of path contains whitespace.
526b85037dbSmrg        my_dir_list="$my_directory_path:$my_dir_list"
527b85037dbSmrg
528b85037dbSmrg        # If the last portion added has no slash in it, the list is done
529b85037dbSmrg        case $my_directory_path in */*) ;; *) break ;; esac
530b85037dbSmrg
531b85037dbSmrg        # ...otherwise throw away the child directory and loop
532b85037dbSmrg        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
533b85037dbSmrg      done
534b85037dbSmrg      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
535b85037dbSmrg
536b85037dbSmrg      save_mkdir_p_IFS="$IFS"; IFS=':'
537b85037dbSmrg      for my_dir in $my_dir_list; do
538b85037dbSmrg	IFS="$save_mkdir_p_IFS"
539b85037dbSmrg        # mkdir can fail with a `File exist' error if two processes
540b85037dbSmrg        # try to create one of the directories concurrently.  Don't
541b85037dbSmrg        # stop in that case!
542b85037dbSmrg        $MKDIR "$my_dir" 2>/dev/null || :
543b85037dbSmrg      done
544b85037dbSmrg      IFS="$save_mkdir_p_IFS"
545b85037dbSmrg
546b85037dbSmrg      # Bail out if we (or some other process) failed to create a directory.
547b85037dbSmrg      test -d "$my_directory_path" || \
548b85037dbSmrg        func_fatal_error "Failed to create \`$1'"
549b85037dbSmrg    fi
550b85037dbSmrg}
551b85037dbSmrg
552b85037dbSmrg
553b85037dbSmrg# func_mktempdir [string]
554b85037dbSmrg# Make a temporary directory that won't clash with other running
555b85037dbSmrg# libtool processes, and avoids race conditions if possible.  If
556b85037dbSmrg# given, STRING is the basename for that directory.
557b85037dbSmrgfunc_mktempdir ()
558b85037dbSmrg{
559b85037dbSmrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
560b85037dbSmrg
561b85037dbSmrg    if test "$opt_dry_run" = ":"; then
562b85037dbSmrg      # Return a directory name, but don't create it in dry-run mode
563b85037dbSmrg      my_tmpdir="${my_template}-$$"
564b85037dbSmrg    else
565b85037dbSmrg
566b85037dbSmrg      # If mktemp works, use that first and foremost
567b85037dbSmrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
568b85037dbSmrg
569b85037dbSmrg      if test ! -d "$my_tmpdir"; then
570b85037dbSmrg        # Failing that, at least try and use $RANDOM to avoid a race
571b85037dbSmrg        my_tmpdir="${my_template}-${RANDOM-0}$$"
572b85037dbSmrg
573b85037dbSmrg        save_mktempdir_umask=`umask`
574b85037dbSmrg        umask 0077
575b85037dbSmrg        $MKDIR "$my_tmpdir"
576b85037dbSmrg        umask $save_mktempdir_umask
577b85037dbSmrg      fi
578b85037dbSmrg
579b85037dbSmrg      # If we're not in dry-run mode, bomb out on failure
580b85037dbSmrg      test -d "$my_tmpdir" || \
581b85037dbSmrg        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
582b85037dbSmrg    fi
583b85037dbSmrg
584b85037dbSmrg    $ECHO "$my_tmpdir"
585b85037dbSmrg}
586b85037dbSmrg
587b85037dbSmrg
588b85037dbSmrg# func_quote_for_eval arg
589b85037dbSmrg# Aesthetically quote ARG to be evaled later.
590b85037dbSmrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
591b85037dbSmrg# is double-quoted, suitable for a subsequent eval, whereas
592b85037dbSmrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
593b85037dbSmrg# which are still active within double quotes backslashified.
594b85037dbSmrgfunc_quote_for_eval ()
595b85037dbSmrg{
596b85037dbSmrg    case $1 in
597b85037dbSmrg      *[\\\`\"\$]*)
598b85037dbSmrg	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
599b85037dbSmrg      *)
600b85037dbSmrg        func_quote_for_eval_unquoted_result="$1" ;;
601b85037dbSmrg    esac
602b85037dbSmrg
603b85037dbSmrg    case $func_quote_for_eval_unquoted_result in
604b85037dbSmrg      # Double-quote args containing shell metacharacters to delay
605b85037dbSmrg      # word splitting, command substitution and and variable
606b85037dbSmrg      # expansion for a subsequent eval.
607b85037dbSmrg      # Many Bourne shells cannot handle close brackets correctly
608b85037dbSmrg      # in scan sets, so we specify it separately.
609b85037dbSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
610b85037dbSmrg        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
611b85037dbSmrg        ;;
612b85037dbSmrg      *)
613b85037dbSmrg        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
614b85037dbSmrg    esac
615b85037dbSmrg}
616b85037dbSmrg
617b85037dbSmrg
618b85037dbSmrg# func_quote_for_expand arg
619b85037dbSmrg# Aesthetically quote ARG to be evaled later; same as above,
620b85037dbSmrg# but do not quote variable references.
621b85037dbSmrgfunc_quote_for_expand ()
622b85037dbSmrg{
623b85037dbSmrg    case $1 in
624b85037dbSmrg      *[\\\`\"]*)
625b85037dbSmrg	my_arg=`$ECHO "$1" | $SED \
626b85037dbSmrg	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
627b85037dbSmrg      *)
628b85037dbSmrg        my_arg="$1" ;;
629b85037dbSmrg    esac
630b85037dbSmrg
631b85037dbSmrg    case $my_arg in
632b85037dbSmrg      # Double-quote args containing shell metacharacters to delay
633b85037dbSmrg      # word splitting and command substitution for a subsequent eval.
634b85037dbSmrg      # Many Bourne shells cannot handle close brackets correctly
635b85037dbSmrg      # in scan sets, so we specify it separately.
636b85037dbSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
637b85037dbSmrg        my_arg="\"$my_arg\""
638b85037dbSmrg        ;;
639b85037dbSmrg    esac
640b85037dbSmrg
641b85037dbSmrg    func_quote_for_expand_result="$my_arg"
642b85037dbSmrg}
643b85037dbSmrg
644b85037dbSmrg
645b85037dbSmrg# func_show_eval cmd [fail_exp]
646b85037dbSmrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
647b85037dbSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
648b85037dbSmrg# is given, then evaluate it.
649b85037dbSmrgfunc_show_eval ()
650b85037dbSmrg{
651b85037dbSmrg    my_cmd="$1"
652b85037dbSmrg    my_fail_exp="${2-:}"
653b85037dbSmrg
654b85037dbSmrg    ${opt_silent-false} || {
655b85037dbSmrg      func_quote_for_expand "$my_cmd"
656b85037dbSmrg      eval "func_echo $func_quote_for_expand_result"
657b85037dbSmrg    }
658b85037dbSmrg
659b85037dbSmrg    if ${opt_dry_run-false}; then :; else
660b85037dbSmrg      eval "$my_cmd"
661b85037dbSmrg      my_status=$?
662b85037dbSmrg      if test "$my_status" -eq 0; then :; else
663b85037dbSmrg	eval "(exit $my_status); $my_fail_exp"
664b85037dbSmrg      fi
665b85037dbSmrg    fi
666b85037dbSmrg}
667b85037dbSmrg
668b85037dbSmrg
669b85037dbSmrg# func_show_eval_locale cmd [fail_exp]
670b85037dbSmrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
671b85037dbSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
672b85037dbSmrg# is given, then evaluate it.  Use the saved locale for evaluation.
673b85037dbSmrgfunc_show_eval_locale ()
674b85037dbSmrg{
675b85037dbSmrg    my_cmd="$1"
676b85037dbSmrg    my_fail_exp="${2-:}"
677b85037dbSmrg
678b85037dbSmrg    ${opt_silent-false} || {
679b85037dbSmrg      func_quote_for_expand "$my_cmd"
680b85037dbSmrg      eval "func_echo $func_quote_for_expand_result"
681b85037dbSmrg    }
682b85037dbSmrg
683b85037dbSmrg    if ${opt_dry_run-false}; then :; else
684b85037dbSmrg      eval "$lt_user_locale
685b85037dbSmrg	    $my_cmd"
686b85037dbSmrg      my_status=$?
687b85037dbSmrg      eval "$lt_safe_locale"
688b85037dbSmrg      if test "$my_status" -eq 0; then :; else
689b85037dbSmrg	eval "(exit $my_status); $my_fail_exp"
690b85037dbSmrg      fi
691b85037dbSmrg    fi
692b85037dbSmrg}
693b85037dbSmrg
694302b15bdSmrg# func_tr_sh
695302b15bdSmrg# Turn $1 into a string suitable for a shell variable name.
696302b15bdSmrg# Result is stored in $func_tr_sh_result.  All characters
697302b15bdSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
698302b15bdSmrg# if $1 begins with a digit, a '_' is prepended as well.
699302b15bdSmrgfunc_tr_sh ()
700302b15bdSmrg{
701302b15bdSmrg  case $1 in
702302b15bdSmrg  [0-9]* | *[!a-zA-Z0-9_]*)
703302b15bdSmrg    func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
704302b15bdSmrg    ;;
705302b15bdSmrg  * )
706302b15bdSmrg    func_tr_sh_result=$1
707302b15bdSmrg    ;;
708302b15bdSmrg  esac
709302b15bdSmrg}
710302b15bdSmrg
711b85037dbSmrg
712b85037dbSmrg# func_version
713b85037dbSmrg# Echo version message to standard output and exit.
714b85037dbSmrgfunc_version ()
715b85037dbSmrg{
716302b15bdSmrg    $opt_debug
717302b15bdSmrg
718b85037dbSmrg    $SED -n '/(C)/!b go
719b85037dbSmrg	:more
720b85037dbSmrg	/\./!{
721b85037dbSmrg	  N
722b85037dbSmrg	  s/\n# / /
723b85037dbSmrg	  b more
724b85037dbSmrg	}
725b85037dbSmrg	:go
726b85037dbSmrg	/^# '$PROGRAM' (GNU /,/# warranty; / {
727b85037dbSmrg        s/^# //
728b85037dbSmrg	s/^# *$//
729b85037dbSmrg        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
730b85037dbSmrg        p
731b85037dbSmrg     }' < "$progpath"
732b85037dbSmrg     exit $?
733b85037dbSmrg}
734b85037dbSmrg
735b85037dbSmrg# func_usage
736b85037dbSmrg# Echo short help message to standard output and exit.
737b85037dbSmrgfunc_usage ()
738b85037dbSmrg{
739302b15bdSmrg    $opt_debug
740302b15bdSmrg
741b85037dbSmrg    $SED -n '/^# Usage:/,/^#  *.*--help/ {
742b85037dbSmrg        s/^# //
743b85037dbSmrg	s/^# *$//
744b85037dbSmrg	s/\$progname/'$progname'/
745b85037dbSmrg	p
746b85037dbSmrg    }' < "$progpath"
747b85037dbSmrg    echo
748b85037dbSmrg    $ECHO "run \`$progname --help | more' for full usage"
749b85037dbSmrg    exit $?
750b85037dbSmrg}
751b85037dbSmrg
752b85037dbSmrg# func_help [NOEXIT]
753b85037dbSmrg# Echo long help message to standard output and exit,
754b85037dbSmrg# unless 'noexit' is passed as argument.
755b85037dbSmrgfunc_help ()
756b85037dbSmrg{
757302b15bdSmrg    $opt_debug
758302b15bdSmrg
759b85037dbSmrg    $SED -n '/^# Usage:/,/# Report bugs to/ {
760302b15bdSmrg	:print
761b85037dbSmrg        s/^# //
762b85037dbSmrg	s/^# *$//
763b85037dbSmrg	s*\$progname*'$progname'*
764b85037dbSmrg	s*\$host*'"$host"'*
765b85037dbSmrg	s*\$SHELL*'"$SHELL"'*
766b85037dbSmrg	s*\$LTCC*'"$LTCC"'*
767b85037dbSmrg	s*\$LTCFLAGS*'"$LTCFLAGS"'*
768b85037dbSmrg	s*\$LD*'"$LD"'*
769b85037dbSmrg	s/\$with_gnu_ld/'"$with_gnu_ld"'/
77028515619Smrg	s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/
77128515619Smrg	s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/
772b85037dbSmrg	p
773302b15bdSmrg	d
774302b15bdSmrg     }
775302b15bdSmrg     /^# .* home page:/b print
776302b15bdSmrg     /^# General help using/b print
777302b15bdSmrg     ' < "$progpath"
778b85037dbSmrg    ret=$?
779b85037dbSmrg    if test -z "$1"; then
780b85037dbSmrg      exit $ret
781b85037dbSmrg    fi
782b85037dbSmrg}
783b85037dbSmrg
784b85037dbSmrg# func_missing_arg argname
785b85037dbSmrg# Echo program name prefixed message to standard error and set global
786b85037dbSmrg# exit_cmd.
787b85037dbSmrgfunc_missing_arg ()
788b85037dbSmrg{
789302b15bdSmrg    $opt_debug
790302b15bdSmrg
791b85037dbSmrg    func_error "missing argument for $1."
792b85037dbSmrg    exit_cmd=exit
793b85037dbSmrg}
794b85037dbSmrg
795b85037dbSmrg
796302b15bdSmrg# func_split_short_opt shortopt
797302b15bdSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell
798302b15bdSmrg# variables after splitting SHORTOPT after the 2nd character.
799302b15bdSmrgfunc_split_short_opt ()
800302b15bdSmrg{
801302b15bdSmrg    my_sed_short_opt='1s/^\(..\).*$/\1/;q'
802302b15bdSmrg    my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
803302b15bdSmrg
804302b15bdSmrg    func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
805302b15bdSmrg    func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
806302b15bdSmrg} # func_split_short_opt may be replaced by extended shell implementation
807302b15bdSmrg
808302b15bdSmrg
809302b15bdSmrg# func_split_long_opt longopt
810302b15bdSmrg# Set func_split_long_opt_name and func_split_long_opt_arg shell
811302b15bdSmrg# variables after splitting LONGOPT at the `=' sign.
812302b15bdSmrgfunc_split_long_opt ()
813302b15bdSmrg{
814302b15bdSmrg    my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
815302b15bdSmrg    my_sed_long_arg='1s/^--[^=]*=//'
816302b15bdSmrg
817302b15bdSmrg    func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
818302b15bdSmrg    func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
819302b15bdSmrg} # func_split_long_opt may be replaced by extended shell implementation
820302b15bdSmrg
821302b15bdSmrgexit_cmd=:
822b85037dbSmrg
823b85037dbSmrg
824b85037dbSmrg
825b85037dbSmrg
826b85037dbSmrg
827b85037dbSmrgmagic="%%%MAGIC variable%%%"
828b85037dbSmrgmagic_exe="%%%MAGIC EXE variable%%%"
829b85037dbSmrg
830b85037dbSmrg# Global variables.
831b85037dbSmrgnonopt=
832b85037dbSmrgpreserve_args=
833b85037dbSmrglo2o="s/\\.lo\$/.${objext}/"
834b85037dbSmrgo2lo="s/\\.${objext}\$/.lo/"
835b85037dbSmrgextracted_archives=
836b85037dbSmrgextracted_serial=0
837b85037dbSmrg
838b85037dbSmrg# If this variable is set in any of the actions, the command in it
839b85037dbSmrg# will be execed at the end.  This prevents here-documents from being
840b85037dbSmrg# left over by shells.
841b85037dbSmrgexec_cmd=
842b85037dbSmrg
843302b15bdSmrg# func_append var value
844302b15bdSmrg# Append VALUE to the end of shell variable VAR.
845302b15bdSmrgfunc_append ()
846302b15bdSmrg{
847302b15bdSmrg    eval "${1}=\$${1}\${2}"
848302b15bdSmrg} # func_append may be replaced by extended shell implementation
849302b15bdSmrg
850302b15bdSmrg# func_append_quoted var value
851302b15bdSmrg# Quote VALUE and append to the end of shell variable VAR, separated
852302b15bdSmrg# by a space.
853302b15bdSmrgfunc_append_quoted ()
854302b15bdSmrg{
855302b15bdSmrg    func_quote_for_eval "${2}"
856302b15bdSmrg    eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
857302b15bdSmrg} # func_append_quoted may be replaced by extended shell implementation
858302b15bdSmrg
859302b15bdSmrg
860302b15bdSmrg# func_arith arithmetic-term...
861302b15bdSmrgfunc_arith ()
862302b15bdSmrg{
863302b15bdSmrg    func_arith_result=`expr "${@}"`
864302b15bdSmrg} # func_arith may be replaced by extended shell implementation
865302b15bdSmrg
866302b15bdSmrg
867302b15bdSmrg# func_len string
868302b15bdSmrg# STRING may not start with a hyphen.
869302b15bdSmrgfunc_len ()
870302b15bdSmrg{
871302b15bdSmrg    func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
872302b15bdSmrg} # func_len may be replaced by extended shell implementation
873302b15bdSmrg
874302b15bdSmrg
875302b15bdSmrg# func_lo2o object
876302b15bdSmrgfunc_lo2o ()
877302b15bdSmrg{
878302b15bdSmrg    func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
879302b15bdSmrg} # func_lo2o may be replaced by extended shell implementation
880302b15bdSmrg
881302b15bdSmrg
882302b15bdSmrg# func_xform libobj-or-source
883302b15bdSmrgfunc_xform ()
884302b15bdSmrg{
885302b15bdSmrg    func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
886302b15bdSmrg} # func_xform may be replaced by extended shell implementation
887302b15bdSmrg
888302b15bdSmrg
889b85037dbSmrg# func_fatal_configuration arg...
890b85037dbSmrg# Echo program name prefixed message to standard error, followed by
891b85037dbSmrg# a configuration failure hint, and exit.
892b85037dbSmrgfunc_fatal_configuration ()
893b85037dbSmrg{
894b85037dbSmrg    func_error ${1+"$@"}
895b85037dbSmrg    func_error "See the $PACKAGE documentation for more information."
896b85037dbSmrg    func_fatal_error "Fatal configuration error."
897b85037dbSmrg}
898b85037dbSmrg
899b85037dbSmrg
900b85037dbSmrg# func_config
901b85037dbSmrg# Display the configuration for all the tags in this script.
902b85037dbSmrgfunc_config ()
903b85037dbSmrg{
904b85037dbSmrg    re_begincf='^# ### BEGIN LIBTOOL'
905b85037dbSmrg    re_endcf='^# ### END LIBTOOL'
906b85037dbSmrg
907b85037dbSmrg    # Default configuration.
908b85037dbSmrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
909b85037dbSmrg
910b85037dbSmrg    # Now print the configurations for the tags.
911b85037dbSmrg    for tagname in $taglist; do
912b85037dbSmrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
913b85037dbSmrg    done
914b85037dbSmrg
915b85037dbSmrg    exit $?
916b85037dbSmrg}
917b85037dbSmrg
918b85037dbSmrg# func_features
919b85037dbSmrg# Display the features supported by this script.
920b85037dbSmrgfunc_features ()
921b85037dbSmrg{
922b85037dbSmrg    echo "host: $host"
923b85037dbSmrg    if test "$build_libtool_libs" = yes; then
924b85037dbSmrg      echo "enable shared libraries"
925b85037dbSmrg    else
926b85037dbSmrg      echo "disable shared libraries"
927b85037dbSmrg    fi
928b85037dbSmrg    if test "$build_old_libs" = yes; then
929b85037dbSmrg      echo "enable static libraries"
930b85037dbSmrg    else
931b85037dbSmrg      echo "disable static libraries"
932b85037dbSmrg    fi
933b85037dbSmrg
934b85037dbSmrg    exit $?
935b85037dbSmrg}
936b85037dbSmrg
937b85037dbSmrg# func_enable_tag tagname
938b85037dbSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or
939b85037dbSmrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
940b85037dbSmrg# variable here.
941b85037dbSmrgfunc_enable_tag ()
942b85037dbSmrg{
943b85037dbSmrg  # Global variable:
944b85037dbSmrg  tagname="$1"
945b85037dbSmrg
946b85037dbSmrg  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
947b85037dbSmrg  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
948b85037dbSmrg  sed_extractcf="/$re_begincf/,/$re_endcf/p"
949b85037dbSmrg
950b85037dbSmrg  # Validate tagname.
951b85037dbSmrg  case $tagname in
952b85037dbSmrg    *[!-_A-Za-z0-9,/]*)
953b85037dbSmrg      func_fatal_error "invalid tag name: $tagname"
954b85037dbSmrg      ;;
955b85037dbSmrg  esac
956b85037dbSmrg
957b85037dbSmrg  # Don't test for the "default" C tag, as we know it's
958b85037dbSmrg  # there but not specially marked.
959b85037dbSmrg  case $tagname in
960b85037dbSmrg    CC) ;;
961b85037dbSmrg    *)
962b85037dbSmrg      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
963b85037dbSmrg	taglist="$taglist $tagname"
964b85037dbSmrg
965b85037dbSmrg	# Evaluate the configuration.  Be careful to quote the path
966b85037dbSmrg	# and the sed script, to avoid splitting on whitespace, but
967b85037dbSmrg	# also don't use non-portable quotes within backquotes within
968b85037dbSmrg	# quotes we have to do it in 2 steps:
969b85037dbSmrg	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
970b85037dbSmrg	eval "$extractedcf"
971b85037dbSmrg      else
972b85037dbSmrg	func_error "ignoring unknown tag $tagname"
973b85037dbSmrg      fi
974b85037dbSmrg      ;;
975b85037dbSmrg  esac
976b85037dbSmrg}
977b85037dbSmrg
978302b15bdSmrg# func_check_version_match
979302b15bdSmrg# Ensure that we are using m4 macros, and libtool script from the same
980302b15bdSmrg# release of libtool.
981302b15bdSmrgfunc_check_version_match ()
982b85037dbSmrg{
983302b15bdSmrg  if test "$package_revision" != "$macro_revision"; then
984302b15bdSmrg    if test "$VERSION" != "$macro_version"; then
985302b15bdSmrg      if test -z "$macro_version"; then
986302b15bdSmrg        cat >&2 <<_LT_EOF
987302b15bdSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
988302b15bdSmrg$progname: definition of this LT_INIT comes from an older release.
989302b15bdSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
990302b15bdSmrg$progname: and run autoconf again.
991302b15bdSmrg_LT_EOF
992302b15bdSmrg      else
993302b15bdSmrg        cat >&2 <<_LT_EOF
994302b15bdSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
995302b15bdSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
996302b15bdSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
997302b15bdSmrg$progname: and run autoconf again.
998302b15bdSmrg_LT_EOF
999302b15bdSmrg      fi
1000302b15bdSmrg    else
1001302b15bdSmrg      cat >&2 <<_LT_EOF
1002302b15bdSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
1003302b15bdSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
1004302b15bdSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
1005302b15bdSmrg$progname: of $PACKAGE $VERSION and run autoconf again.
1006302b15bdSmrg_LT_EOF
1007302b15bdSmrg    fi
1008b85037dbSmrg
1009302b15bdSmrg    exit $EXIT_MISMATCH
1010302b15bdSmrg  fi
1011302b15bdSmrg}
1012302b15bdSmrg
1013302b15bdSmrg
1014302b15bdSmrg# Shorthand for --mode=foo, only valid as the first argument
1015302b15bdSmrgcase $1 in
1016302b15bdSmrgclean|clea|cle|cl)
1017302b15bdSmrg  shift; set dummy --mode clean ${1+"$@"}; shift
1018302b15bdSmrg  ;;
1019302b15bdSmrgcompile|compil|compi|comp|com|co|c)
1020302b15bdSmrg  shift; set dummy --mode compile ${1+"$@"}; shift
1021302b15bdSmrg  ;;
1022302b15bdSmrgexecute|execut|execu|exec|exe|ex|e)
1023302b15bdSmrg  shift; set dummy --mode execute ${1+"$@"}; shift
1024302b15bdSmrg  ;;
1025302b15bdSmrgfinish|finis|fini|fin|fi|f)
1026302b15bdSmrg  shift; set dummy --mode finish ${1+"$@"}; shift
1027302b15bdSmrg  ;;
1028302b15bdSmrginstall|instal|insta|inst|ins|in|i)
1029302b15bdSmrg  shift; set dummy --mode install ${1+"$@"}; shift
1030302b15bdSmrg  ;;
1031302b15bdSmrglink|lin|li|l)
1032302b15bdSmrg  shift; set dummy --mode link ${1+"$@"}; shift
1033302b15bdSmrg  ;;
1034302b15bdSmrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
1035302b15bdSmrg  shift; set dummy --mode uninstall ${1+"$@"}; shift
1036302b15bdSmrg  ;;
1037302b15bdSmrgesac
1038b85037dbSmrg
1039302b15bdSmrg
1040302b15bdSmrg
1041302b15bdSmrg# Option defaults:
1042302b15bdSmrgopt_debug=:
1043302b15bdSmrgopt_dry_run=false
1044302b15bdSmrgopt_config=false
1045302b15bdSmrgopt_preserve_dup_deps=false
1046302b15bdSmrgopt_features=false
1047302b15bdSmrgopt_finish=false
1048302b15bdSmrgopt_help=false
1049302b15bdSmrgopt_help_all=false
1050302b15bdSmrgopt_silent=:
105128515619Smrgopt_warning=:
1052302b15bdSmrgopt_verbose=:
1053302b15bdSmrgopt_silent=false
1054302b15bdSmrgopt_verbose=false
1055302b15bdSmrg
1056302b15bdSmrg
1057302b15bdSmrg# Parse options once, thoroughly.  This comes as soon as possible in the
1058302b15bdSmrg# script to make things like `--version' happen as quickly as we can.
1059302b15bdSmrg{
1060302b15bdSmrg  # this just eases exit handling
1061302b15bdSmrg  while test $# -gt 0; do
1062b85037dbSmrg    opt="$1"
1063b85037dbSmrg    shift
1064b85037dbSmrg    case $opt in
1065302b15bdSmrg      --debug|-x)	opt_debug='set -x'
1066b85037dbSmrg			func_echo "enabling shell trace mode"
1067b85037dbSmrg			$opt_debug
1068b85037dbSmrg			;;
1069302b15bdSmrg      --dry-run|--dryrun|-n)
1070302b15bdSmrg			opt_dry_run=:
1071b85037dbSmrg			;;
1072302b15bdSmrg      --config)
1073302b15bdSmrg			opt_config=:
1074302b15bdSmrgfunc_config
1075302b15bdSmrg			;;
1076302b15bdSmrg      --dlopen|-dlopen)
1077302b15bdSmrg			optarg="$1"
1078302b15bdSmrg			opt_dlopen="${opt_dlopen+$opt_dlopen
1079302b15bdSmrg}$optarg"
1080b85037dbSmrg			shift
1081b85037dbSmrg			;;
1082b85037dbSmrg      --preserve-dup-deps)
1083302b15bdSmrg			opt_preserve_dup_deps=:
1084b85037dbSmrg			;;
1085302b15bdSmrg      --features)
1086302b15bdSmrg			opt_features=:
1087302b15bdSmrgfunc_features
1088b85037dbSmrg			;;
1089302b15bdSmrg      --finish)
1090302b15bdSmrg			opt_finish=:
1091302b15bdSmrgset dummy --mode finish ${1+"$@"}; shift
1092302b15bdSmrg			;;
1093302b15bdSmrg      --help)
1094302b15bdSmrg			opt_help=:
1095302b15bdSmrg			;;
1096302b15bdSmrg      --help-all)
1097302b15bdSmrg			opt_help_all=:
1098302b15bdSmrgopt_help=': help-all'
1099302b15bdSmrg			;;
1100302b15bdSmrg      --mode)
1101302b15bdSmrg			test $# = 0 && func_missing_arg $opt && break
1102302b15bdSmrg			optarg="$1"
1103302b15bdSmrg			opt_mode="$optarg"
1104302b15bdSmrgcase $optarg in
1105302b15bdSmrg  # Valid mode arguments:
1106302b15bdSmrg  clean|compile|execute|finish|install|link|relink|uninstall) ;;
1107302b15bdSmrg
1108302b15bdSmrg  # Catch anything else as an error
1109302b15bdSmrg  *) func_error "invalid argument for $opt"
1110302b15bdSmrg     exit_cmd=exit
1111302b15bdSmrg     break
1112302b15bdSmrg     ;;
1113302b15bdSmrgesac
1114302b15bdSmrg			shift
1115302b15bdSmrg			;;
1116302b15bdSmrg      --no-silent|--no-quiet)
1117b85037dbSmrg			opt_silent=false
111828515619Smrgfunc_append preserve_args " $opt"
111928515619Smrg			;;
112028515619Smrg      --no-warning|--no-warn)
112128515619Smrg			opt_warning=false
1122302b15bdSmrgfunc_append preserve_args " $opt"
1123b85037dbSmrg			;;
1124302b15bdSmrg      --no-verbose)
1125b85037dbSmrg			opt_verbose=false
1126302b15bdSmrgfunc_append preserve_args " $opt"
1127b85037dbSmrg			;;
1128302b15bdSmrg      --silent|--quiet)
1129302b15bdSmrg			opt_silent=:
1130302b15bdSmrgfunc_append preserve_args " $opt"
1131302b15bdSmrg        opt_verbose=false
1132302b15bdSmrg			;;
1133302b15bdSmrg      --verbose|-v)
1134302b15bdSmrg			opt_verbose=:
1135302b15bdSmrgfunc_append preserve_args " $opt"
1136302b15bdSmrgopt_silent=false
1137302b15bdSmrg			;;
1138302b15bdSmrg      --tag)
1139302b15bdSmrg			test $# = 0 && func_missing_arg $opt && break
1140302b15bdSmrg			optarg="$1"
1141302b15bdSmrg			opt_tag="$optarg"
1142302b15bdSmrgfunc_append preserve_args " $opt $optarg"
1143302b15bdSmrgfunc_enable_tag "$optarg"
1144b85037dbSmrg			shift
1145b85037dbSmrg			;;
1146b85037dbSmrg
1147302b15bdSmrg      -\?|-h)		func_usage				;;
1148302b15bdSmrg      --help)		func_help				;;
1149302b15bdSmrg      --version)	func_version				;;
1150302b15bdSmrg
1151b85037dbSmrg      # Separate optargs to long options:
1152302b15bdSmrg      --*=*)
1153302b15bdSmrg			func_split_long_opt "$opt"
1154302b15bdSmrg			set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
1155b85037dbSmrg			shift
1156b85037dbSmrg			;;
1157b85037dbSmrg
1158302b15bdSmrg      # Separate non-argument short options:
1159302b15bdSmrg      -\?*|-h*|-n*|-v*)
1160302b15bdSmrg			func_split_short_opt "$opt"
1161302b15bdSmrg			set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
1162302b15bdSmrg			shift
1163b85037dbSmrg			;;
1164302b15bdSmrg
1165302b15bdSmrg      --)		break					;;
1166302b15bdSmrg      -*)		func_fatal_help "unrecognized option \`$opt'" ;;
1167302b15bdSmrg      *)		set dummy "$opt" ${1+"$@"};	shift; break  ;;
1168b85037dbSmrg    esac
1169b85037dbSmrg  done
1170b85037dbSmrg
1171302b15bdSmrg  # Validate options:
1172302b15bdSmrg
1173302b15bdSmrg  # save first non-option argument
1174302b15bdSmrg  if test "$#" -gt 0; then
1175302b15bdSmrg    nonopt="$opt"
1176302b15bdSmrg    shift
1177302b15bdSmrg  fi
1178302b15bdSmrg
1179302b15bdSmrg  # preserve --debug
1180302b15bdSmrg  test "$opt_debug" = : || func_append preserve_args " --debug"
1181b85037dbSmrg
1182b85037dbSmrg  case $host in
1183b85037dbSmrg    *cygwin* | *mingw* | *pw32* | *cegcc*)
1184b85037dbSmrg      # don't eliminate duplications in $postdeps and $predeps
1185b85037dbSmrg      opt_duplicate_compiler_generated_deps=:
1186b85037dbSmrg      ;;
1187b85037dbSmrg    *)
1188302b15bdSmrg      opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
1189b85037dbSmrg      ;;
1190b85037dbSmrg  esac
1191b85037dbSmrg
1192302b15bdSmrg  $opt_help || {
1193302b15bdSmrg    # Sanity checks first:
1194302b15bdSmrg    func_check_version_match
1195b85037dbSmrg
1196302b15bdSmrg    if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
1197302b15bdSmrg      func_fatal_configuration "not configured to build any kind of library"
1198b85037dbSmrg    fi
1199b85037dbSmrg
1200302b15bdSmrg    # Darwin sucks
1201302b15bdSmrg    eval std_shrext=\"$shrext_cmds\"
1202b85037dbSmrg
1203302b15bdSmrg    # Only execute mode is allowed to have -dlopen flags.
1204302b15bdSmrg    if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
1205302b15bdSmrg      func_error "unrecognized option \`-dlopen'"
1206302b15bdSmrg      $ECHO "$help" 1>&2
1207302b15bdSmrg      exit $EXIT_FAILURE
1208302b15bdSmrg    fi
1209b85037dbSmrg
1210302b15bdSmrg    # Change the help message to a mode-specific one.
1211302b15bdSmrg    generic_help="$help"
1212302b15bdSmrg    help="Try \`$progname --help --mode=$opt_mode' for more information."
1213302b15bdSmrg  }
1214b85037dbSmrg
1215b85037dbSmrg
1216302b15bdSmrg  # Bail if the options were screwed
1217302b15bdSmrg  $exit_cmd $EXIT_FAILURE
1218302b15bdSmrg}
1219b85037dbSmrg
1220b85037dbSmrg
1221b85037dbSmrg
1222b85037dbSmrg
1223302b15bdSmrg## ----------- ##
1224302b15bdSmrg##    Main.    ##
1225302b15bdSmrg## ----------- ##
1226b85037dbSmrg
1227b85037dbSmrg# func_lalib_p file
1228b85037dbSmrg# True iff FILE is a libtool `.la' library or `.lo' object file.
1229b85037dbSmrg# This function is only a basic sanity check; it will hardly flush out
1230b85037dbSmrg# determined imposters.
1231b85037dbSmrgfunc_lalib_p ()
1232b85037dbSmrg{
1233b85037dbSmrg    test -f "$1" &&
1234b85037dbSmrg      $SED -e 4q "$1" 2>/dev/null \
1235b85037dbSmrg        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
1236b85037dbSmrg}
1237b85037dbSmrg
1238b85037dbSmrg# func_lalib_unsafe_p file
1239b85037dbSmrg# True iff FILE is a libtool `.la' library or `.lo' object file.
1240b85037dbSmrg# This function implements the same check as func_lalib_p without
1241b85037dbSmrg# resorting to external programs.  To this end, it redirects stdin and
1242b85037dbSmrg# closes it afterwards, without saving the original file descriptor.
1243b85037dbSmrg# As a safety measure, use it only where a negative result would be
1244b85037dbSmrg# fatal anyway.  Works if `file' does not exist.
1245b85037dbSmrgfunc_lalib_unsafe_p ()
1246b85037dbSmrg{
1247b85037dbSmrg    lalib_p=no
1248b85037dbSmrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
1249b85037dbSmrg	for lalib_p_l in 1 2 3 4
1250b85037dbSmrg	do
1251b85037dbSmrg	    read lalib_p_line
1252b85037dbSmrg	    case "$lalib_p_line" in
1253b85037dbSmrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
1254b85037dbSmrg	    esac
1255b85037dbSmrg	done
1256b85037dbSmrg	exec 0<&5 5<&-
1257b85037dbSmrg    fi
1258b85037dbSmrg    test "$lalib_p" = yes
1259b85037dbSmrg}
1260b85037dbSmrg
1261b85037dbSmrg# func_ltwrapper_script_p file
1262b85037dbSmrg# True iff FILE is a libtool wrapper script
1263b85037dbSmrg# This function is only a basic sanity check; it will hardly flush out
1264b85037dbSmrg# determined imposters.
1265b85037dbSmrgfunc_ltwrapper_script_p ()
1266b85037dbSmrg{
1267b85037dbSmrg    func_lalib_p "$1"
1268b85037dbSmrg}
1269b85037dbSmrg
1270b85037dbSmrg# func_ltwrapper_executable_p file
1271b85037dbSmrg# True iff FILE is a libtool wrapper executable
1272b85037dbSmrg# This function is only a basic sanity check; it will hardly flush out
1273b85037dbSmrg# determined imposters.
1274b85037dbSmrgfunc_ltwrapper_executable_p ()
1275b85037dbSmrg{
1276b85037dbSmrg    func_ltwrapper_exec_suffix=
1277b85037dbSmrg    case $1 in
1278b85037dbSmrg    *.exe) ;;
1279b85037dbSmrg    *) func_ltwrapper_exec_suffix=.exe ;;
1280b85037dbSmrg    esac
1281b85037dbSmrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
1282b85037dbSmrg}
1283b85037dbSmrg
1284b85037dbSmrg# func_ltwrapper_scriptname file
1285b85037dbSmrg# Assumes file is an ltwrapper_executable
1286b85037dbSmrg# uses $file to determine the appropriate filename for a
1287b85037dbSmrg# temporary ltwrapper_script.
1288b85037dbSmrgfunc_ltwrapper_scriptname ()
1289b85037dbSmrg{
1290302b15bdSmrg    func_dirname_and_basename "$1" "" "."
1291302b15bdSmrg    func_stripname '' '.exe' "$func_basename_result"
1292302b15bdSmrg    func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
1293b85037dbSmrg}
1294b85037dbSmrg
1295b85037dbSmrg# func_ltwrapper_p file
1296b85037dbSmrg# True iff FILE is a libtool wrapper script or wrapper executable
1297b85037dbSmrg# This function is only a basic sanity check; it will hardly flush out
1298b85037dbSmrg# determined imposters.
1299b85037dbSmrgfunc_ltwrapper_p ()
1300b85037dbSmrg{
1301b85037dbSmrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
1302b85037dbSmrg}
1303b85037dbSmrg
1304b85037dbSmrg
1305b85037dbSmrg# func_execute_cmds commands fail_cmd
1306b85037dbSmrg# Execute tilde-delimited COMMANDS.
1307b85037dbSmrg# If FAIL_CMD is given, eval that upon failure.
1308b85037dbSmrg# FAIL_CMD may read-access the current command in variable CMD!
1309b85037dbSmrgfunc_execute_cmds ()
1310b85037dbSmrg{
1311b85037dbSmrg    $opt_debug
1312b85037dbSmrg    save_ifs=$IFS; IFS='~'
1313b85037dbSmrg    for cmd in $1; do
1314b85037dbSmrg      IFS=$save_ifs
1315b85037dbSmrg      eval cmd=\"$cmd\"
1316b85037dbSmrg      func_show_eval "$cmd" "${2-:}"
1317b85037dbSmrg    done
1318b85037dbSmrg    IFS=$save_ifs
1319b85037dbSmrg}
1320b85037dbSmrg
1321b85037dbSmrg
1322b85037dbSmrg# func_source file
1323b85037dbSmrg# Source FILE, adding directory component if necessary.
1324b85037dbSmrg# Note that it is not necessary on cygwin/mingw to append a dot to
1325b85037dbSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
1326b85037dbSmrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
1327b85037dbSmrg# `FILE.' does not work on cygwin managed mounts.
1328b85037dbSmrgfunc_source ()
1329b85037dbSmrg{
1330b85037dbSmrg    $opt_debug
1331b85037dbSmrg    case $1 in
1332b85037dbSmrg    */* | *\\*)	. "$1" ;;
1333b85037dbSmrg    *)		. "./$1" ;;
1334b85037dbSmrg    esac
1335b85037dbSmrg}
1336b85037dbSmrg
1337b85037dbSmrg
1338302b15bdSmrg# func_resolve_sysroot PATH
1339302b15bdSmrg# Replace a leading = in PATH with a sysroot.  Store the result into
1340302b15bdSmrg# func_resolve_sysroot_result
1341302b15bdSmrgfunc_resolve_sysroot ()
1342302b15bdSmrg{
1343302b15bdSmrg  func_resolve_sysroot_result=$1
1344302b15bdSmrg  case $func_resolve_sysroot_result in
1345302b15bdSmrg  =*)
1346302b15bdSmrg    func_stripname '=' '' "$func_resolve_sysroot_result"
1347302b15bdSmrg    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
1348302b15bdSmrg    ;;
1349302b15bdSmrg  esac
1350302b15bdSmrg}
1351302b15bdSmrg
1352302b15bdSmrg# func_replace_sysroot PATH
1353302b15bdSmrg# If PATH begins with the sysroot, replace it with = and
1354302b15bdSmrg# store the result into func_replace_sysroot_result.
1355302b15bdSmrgfunc_replace_sysroot ()
1356302b15bdSmrg{
1357302b15bdSmrg  case "$lt_sysroot:$1" in
1358302b15bdSmrg  ?*:"$lt_sysroot"*)
1359302b15bdSmrg    func_stripname "$lt_sysroot" '' "$1"
1360302b15bdSmrg    func_replace_sysroot_result="=$func_stripname_result"
1361302b15bdSmrg    ;;
1362302b15bdSmrg  *)
1363302b15bdSmrg    # Including no sysroot.
1364302b15bdSmrg    func_replace_sysroot_result=$1
1365302b15bdSmrg    ;;
1366302b15bdSmrg  esac
1367302b15bdSmrg}
1368302b15bdSmrg
1369b85037dbSmrg# func_infer_tag arg
1370b85037dbSmrg# Infer tagged configuration to use if any are available and
1371b85037dbSmrg# if one wasn't chosen via the "--tag" command line option.
1372b85037dbSmrg# Only attempt this if the compiler in the base compile
1373b85037dbSmrg# command doesn't match the default compiler.
1374b85037dbSmrg# arg is usually of the form 'gcc ...'
1375b85037dbSmrgfunc_infer_tag ()
1376b85037dbSmrg{
1377b85037dbSmrg    $opt_debug
1378b85037dbSmrg    if test -n "$available_tags" && test -z "$tagname"; then
1379b85037dbSmrg      CC_quoted=
1380b85037dbSmrg      for arg in $CC; do
1381302b15bdSmrg	func_append_quoted CC_quoted "$arg"
1382b85037dbSmrg      done
1383b85037dbSmrg      CC_expanded=`func_echo_all $CC`
1384b85037dbSmrg      CC_quoted_expanded=`func_echo_all $CC_quoted`
1385b85037dbSmrg      case $@ in
1386b85037dbSmrg      # Blanks in the command may have been stripped by the calling shell,
1387b85037dbSmrg      # but not from the CC environment variable when configure was run.
1388b85037dbSmrg      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1389b85037dbSmrg      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
1390b85037dbSmrg      # Blanks at the start of $base_compile will cause this to fail
1391b85037dbSmrg      # if we don't check for them as well.
1392b85037dbSmrg      *)
1393b85037dbSmrg	for z in $available_tags; do
1394b85037dbSmrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
1395b85037dbSmrg	    # Evaluate the configuration.
1396b85037dbSmrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
1397b85037dbSmrg	    CC_quoted=
1398b85037dbSmrg	    for arg in $CC; do
1399b85037dbSmrg	      # Double-quote args containing other shell metacharacters.
1400302b15bdSmrg	      func_append_quoted CC_quoted "$arg"
1401b85037dbSmrg	    done
1402b85037dbSmrg	    CC_expanded=`func_echo_all $CC`
1403b85037dbSmrg	    CC_quoted_expanded=`func_echo_all $CC_quoted`
1404b85037dbSmrg	    case "$@ " in
1405b85037dbSmrg	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1406b85037dbSmrg	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
1407b85037dbSmrg	      # The compiler in the base compile command matches
1408b85037dbSmrg	      # the one in the tagged configuration.
1409b85037dbSmrg	      # Assume this is the tagged configuration we want.
1410b85037dbSmrg	      tagname=$z
1411b85037dbSmrg	      break
1412b85037dbSmrg	      ;;
1413b85037dbSmrg	    esac
1414b85037dbSmrg	  fi
1415b85037dbSmrg	done
1416b85037dbSmrg	# If $tagname still isn't set, then no tagged configuration
1417b85037dbSmrg	# was found and let the user know that the "--tag" command
1418b85037dbSmrg	# line option must be used.
1419b85037dbSmrg	if test -z "$tagname"; then
1420b85037dbSmrg	  func_echo "unable to infer tagged configuration"
1421b85037dbSmrg	  func_fatal_error "specify a tag with \`--tag'"
1422b85037dbSmrg#	else
1423b85037dbSmrg#	  func_verbose "using $tagname tagged configuration"
1424b85037dbSmrg	fi
1425b85037dbSmrg	;;
1426b85037dbSmrg      esac
1427b85037dbSmrg    fi
1428b85037dbSmrg}
1429b85037dbSmrg
1430b85037dbSmrg
1431b85037dbSmrg
1432302b15bdSmrg# func_write_libtool_object output_name pic_name nonpic_name
1433302b15bdSmrg# Create a libtool object file (analogous to a ".la" file),
1434302b15bdSmrg# but don't create it if we're doing a dry run.
1435302b15bdSmrgfunc_write_libtool_object ()
1436302b15bdSmrg{
1437302b15bdSmrg    write_libobj=${1}
1438302b15bdSmrg    if test "$build_libtool_libs" = yes; then
1439302b15bdSmrg      write_lobj=\'${2}\'
1440302b15bdSmrg    else
1441302b15bdSmrg      write_lobj=none
1442302b15bdSmrg    fi
1443302b15bdSmrg
1444302b15bdSmrg    if test "$build_old_libs" = yes; then
1445302b15bdSmrg      write_oldobj=\'${3}\'
1446302b15bdSmrg    else
1447302b15bdSmrg      write_oldobj=none
1448302b15bdSmrg    fi
1449302b15bdSmrg
1450302b15bdSmrg    $opt_dry_run || {
1451302b15bdSmrg      cat >${write_libobj}T <<EOF
1452302b15bdSmrg# $write_libobj - a libtool object file
1453302b15bdSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1454302b15bdSmrg#
1455302b15bdSmrg# Please DO NOT delete this file!
1456302b15bdSmrg# It is necessary for linking the library.
1457302b15bdSmrg
1458302b15bdSmrg# Name of the PIC object.
1459302b15bdSmrgpic_object=$write_lobj
1460302b15bdSmrg
1461302b15bdSmrg# Name of the non-PIC object
1462302b15bdSmrgnon_pic_object=$write_oldobj
1463302b15bdSmrg
1464302b15bdSmrgEOF
1465302b15bdSmrg      $MV "${write_libobj}T" "${write_libobj}"
1466302b15bdSmrg    }
1467302b15bdSmrg}
1468302b15bdSmrg
1469302b15bdSmrg
1470302b15bdSmrg##################################################
1471302b15bdSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
1472302b15bdSmrg##################################################
1473302b15bdSmrg
1474302b15bdSmrg# func_convert_core_file_wine_to_w32 ARG
1475302b15bdSmrg# Helper function used by file name conversion functions when $build is *nix,
1476302b15bdSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a
1477302b15bdSmrg# correctly configured wine environment available, with the winepath program
1478302b15bdSmrg# in $build's $PATH.
1479302b15bdSmrg#
1480302b15bdSmrg# ARG is the $build file name to be converted to w32 format.
1481302b15bdSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will
1482302b15bdSmrg# be empty on error (or when ARG is empty)
1483302b15bdSmrgfunc_convert_core_file_wine_to_w32 ()
1484302b15bdSmrg{
1485302b15bdSmrg  $opt_debug
1486302b15bdSmrg  func_convert_core_file_wine_to_w32_result="$1"
1487302b15bdSmrg  if test -n "$1"; then
1488302b15bdSmrg    # Unfortunately, winepath does not exit with a non-zero error code, so we
1489302b15bdSmrg    # are forced to check the contents of stdout. On the other hand, if the
1490302b15bdSmrg    # command is not found, the shell will set an exit code of 127 and print
1491302b15bdSmrg    # *an error message* to stdout. So we must check for both error code of
1492302b15bdSmrg    # zero AND non-empty stdout, which explains the odd construction:
1493302b15bdSmrg    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
1494302b15bdSmrg    if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
1495302b15bdSmrg      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
1496302b15bdSmrg        $SED -e "$lt_sed_naive_backslashify"`
1497302b15bdSmrg    else
1498302b15bdSmrg      func_convert_core_file_wine_to_w32_result=
1499302b15bdSmrg    fi
1500302b15bdSmrg  fi
1501302b15bdSmrg}
1502302b15bdSmrg# end: func_convert_core_file_wine_to_w32
1503302b15bdSmrg
1504302b15bdSmrg
1505302b15bdSmrg# func_convert_core_path_wine_to_w32 ARG
1506302b15bdSmrg# Helper function used by path conversion functions when $build is *nix, and
1507302b15bdSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
1508302b15bdSmrg# configured wine environment available, with the winepath program in $build's
1509302b15bdSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters.
1510302b15bdSmrg#
1511302b15bdSmrg# ARG is path to be converted from $build format to win32.
1512302b15bdSmrg# Result is available in $func_convert_core_path_wine_to_w32_result.
1513302b15bdSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names
1514302b15bdSmrg# are convertible, then the result may be empty.
1515302b15bdSmrgfunc_convert_core_path_wine_to_w32 ()
1516302b15bdSmrg{
1517302b15bdSmrg  $opt_debug
1518302b15bdSmrg  # unfortunately, winepath doesn't convert paths, only file names
1519302b15bdSmrg  func_convert_core_path_wine_to_w32_result=""
1520302b15bdSmrg  if test -n "$1"; then
1521302b15bdSmrg    oldIFS=$IFS
1522302b15bdSmrg    IFS=:
1523302b15bdSmrg    for func_convert_core_path_wine_to_w32_f in $1; do
1524302b15bdSmrg      IFS=$oldIFS
1525302b15bdSmrg      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
1526302b15bdSmrg      if test -n "$func_convert_core_file_wine_to_w32_result" ; then
1527302b15bdSmrg        if test -z "$func_convert_core_path_wine_to_w32_result"; then
1528302b15bdSmrg          func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
1529302b15bdSmrg        else
1530302b15bdSmrg          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
1531302b15bdSmrg        fi
1532302b15bdSmrg      fi
1533302b15bdSmrg    done
1534302b15bdSmrg    IFS=$oldIFS
1535302b15bdSmrg  fi
1536302b15bdSmrg}
1537302b15bdSmrg# end: func_convert_core_path_wine_to_w32
1538302b15bdSmrg
1539302b15bdSmrg
1540302b15bdSmrg# func_cygpath ARGS...
1541302b15bdSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
1542302b15bdSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
1543302b15bdSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
1544302b15bdSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input
1545302b15bdSmrg# file name or path is assumed to be in w32 format, as previously converted
1546302b15bdSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name
1547302b15bdSmrg# or path in func_cygpath_result (input file name or path is assumed to be in
1548302b15bdSmrg# Cygwin format). Returns an empty string on error.
1549302b15bdSmrg#
1550302b15bdSmrg# ARGS are passed to cygpath, with the last one being the file name or path to
1551302b15bdSmrg# be converted.
1552302b15bdSmrg#
1553302b15bdSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
1554302b15bdSmrg# environment variable; do not put it in $PATH.
1555302b15bdSmrgfunc_cygpath ()
1556302b15bdSmrg{
1557302b15bdSmrg  $opt_debug
1558302b15bdSmrg  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
1559302b15bdSmrg    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
1560302b15bdSmrg    if test "$?" -ne 0; then
1561302b15bdSmrg      # on failure, ensure result is empty
1562302b15bdSmrg      func_cygpath_result=
1563302b15bdSmrg    fi
1564302b15bdSmrg  else
1565302b15bdSmrg    func_cygpath_result=
1566302b15bdSmrg    func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
1567302b15bdSmrg  fi
1568302b15bdSmrg}
1569302b15bdSmrg#end: func_cygpath
1570302b15bdSmrg
1571302b15bdSmrg
1572302b15bdSmrg# func_convert_core_msys_to_w32 ARG
1573302b15bdSmrg# Convert file name or path ARG from MSYS format to w32 format.  Return
1574302b15bdSmrg# result in func_convert_core_msys_to_w32_result.
1575302b15bdSmrgfunc_convert_core_msys_to_w32 ()
1576302b15bdSmrg{
1577302b15bdSmrg  $opt_debug
1578302b15bdSmrg  # awkward: cmd appends spaces to result
1579302b15bdSmrg  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
1580302b15bdSmrg    $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
1581302b15bdSmrg}
1582302b15bdSmrg#end: func_convert_core_msys_to_w32
1583302b15bdSmrg
1584302b15bdSmrg
1585302b15bdSmrg# func_convert_file_check ARG1 ARG2
1586302b15bdSmrg# Verify that ARG1 (a file name in $build format) was converted to $host
1587302b15bdSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting
1588302b15bdSmrg# func_to_host_file_result to ARG1).
1589302b15bdSmrgfunc_convert_file_check ()
1590302b15bdSmrg{
1591302b15bdSmrg  $opt_debug
1592302b15bdSmrg  if test -z "$2" && test -n "$1" ; then
1593302b15bdSmrg    func_error "Could not determine host file name corresponding to"
1594302b15bdSmrg    func_error "  \`$1'"
1595302b15bdSmrg    func_error "Continuing, but uninstalled executables may not work."
1596302b15bdSmrg    # Fallback:
1597302b15bdSmrg    func_to_host_file_result="$1"
1598302b15bdSmrg  fi
1599302b15bdSmrg}
1600302b15bdSmrg# end func_convert_file_check
1601302b15bdSmrg
1602302b15bdSmrg
1603302b15bdSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
1604302b15bdSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host
1605302b15bdSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
1606302b15bdSmrg# func_to_host_file_result to a simplistic fallback value (see below).
1607302b15bdSmrgfunc_convert_path_check ()
1608302b15bdSmrg{
1609302b15bdSmrg  $opt_debug
1610302b15bdSmrg  if test -z "$4" && test -n "$3"; then
1611302b15bdSmrg    func_error "Could not determine the host path corresponding to"
1612302b15bdSmrg    func_error "  \`$3'"
1613302b15bdSmrg    func_error "Continuing, but uninstalled executables may not work."
1614302b15bdSmrg    # Fallback.  This is a deliberately simplistic "conversion" and
1615302b15bdSmrg    # should not be "improved".  See libtool.info.
1616302b15bdSmrg    if test "x$1" != "x$2"; then
1617302b15bdSmrg      lt_replace_pathsep_chars="s|$1|$2|g"
1618302b15bdSmrg      func_to_host_path_result=`echo "$3" |
1619302b15bdSmrg        $SED -e "$lt_replace_pathsep_chars"`
1620302b15bdSmrg    else
1621302b15bdSmrg      func_to_host_path_result="$3"
1622302b15bdSmrg    fi
1623302b15bdSmrg  fi
1624302b15bdSmrg}
1625302b15bdSmrg# end func_convert_path_check
1626302b15bdSmrg
1627302b15bdSmrg
1628302b15bdSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
1629302b15bdSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
1630302b15bdSmrg# and appending REPL if ORIG matches BACKPAT.
1631302b15bdSmrgfunc_convert_path_front_back_pathsep ()
1632302b15bdSmrg{
1633302b15bdSmrg  $opt_debug
1634302b15bdSmrg  case $4 in
1635302b15bdSmrg  $1 ) func_to_host_path_result="$3$func_to_host_path_result"
1636302b15bdSmrg    ;;
1637302b15bdSmrg  esac
1638302b15bdSmrg  case $4 in
1639302b15bdSmrg  $2 ) func_append func_to_host_path_result "$3"
1640302b15bdSmrg    ;;
1641302b15bdSmrg  esac
1642302b15bdSmrg}
1643302b15bdSmrg# end func_convert_path_front_back_pathsep
1644302b15bdSmrg
1645302b15bdSmrg
1646302b15bdSmrg##################################################
1647302b15bdSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS #
1648302b15bdSmrg##################################################
1649302b15bdSmrg# invoked via `$to_host_file_cmd ARG'
1650302b15bdSmrg#
1651302b15bdSmrg# In each case, ARG is the path to be converted from $build to $host format.
1652302b15bdSmrg# Result will be available in $func_to_host_file_result.
1653302b15bdSmrg
1654302b15bdSmrg
1655302b15bdSmrg# func_to_host_file ARG
1656302b15bdSmrg# Converts the file name ARG from $build format to $host format. Return result
1657302b15bdSmrg# in func_to_host_file_result.
1658302b15bdSmrgfunc_to_host_file ()
1659302b15bdSmrg{
1660302b15bdSmrg  $opt_debug
1661302b15bdSmrg  $to_host_file_cmd "$1"
1662302b15bdSmrg}
1663302b15bdSmrg# end func_to_host_file
1664302b15bdSmrg
1665302b15bdSmrg
1666302b15bdSmrg# func_to_tool_file ARG LAZY
1667302b15bdSmrg# converts the file name ARG from $build format to toolchain format. Return
1668302b15bdSmrg# result in func_to_tool_file_result.  If the conversion in use is listed
1669302b15bdSmrg# in (the comma separated) LAZY, no conversion takes place.
1670302b15bdSmrgfunc_to_tool_file ()
1671302b15bdSmrg{
1672302b15bdSmrg  $opt_debug
1673302b15bdSmrg  case ,$2, in
1674302b15bdSmrg    *,"$to_tool_file_cmd",*)
1675302b15bdSmrg      func_to_tool_file_result=$1
1676302b15bdSmrg      ;;
1677302b15bdSmrg    *)
1678302b15bdSmrg      $to_tool_file_cmd "$1"
1679302b15bdSmrg      func_to_tool_file_result=$func_to_host_file_result
1680302b15bdSmrg      ;;
1681302b15bdSmrg  esac
1682302b15bdSmrg}
1683302b15bdSmrg# end func_to_tool_file
1684302b15bdSmrg
1685302b15bdSmrg
1686302b15bdSmrg# func_convert_file_noop ARG
1687302b15bdSmrg# Copy ARG to func_to_host_file_result.
1688302b15bdSmrgfunc_convert_file_noop ()
1689302b15bdSmrg{
1690302b15bdSmrg  func_to_host_file_result="$1"
1691302b15bdSmrg}
1692302b15bdSmrg# end func_convert_file_noop
1693302b15bdSmrg
1694302b15bdSmrg
1695302b15bdSmrg# func_convert_file_msys_to_w32 ARG
1696302b15bdSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
1697302b15bdSmrg# conversion to w32 is not available inside the cwrapper.  Returns result in
1698302b15bdSmrg# func_to_host_file_result.
1699302b15bdSmrgfunc_convert_file_msys_to_w32 ()
1700302b15bdSmrg{
1701302b15bdSmrg  $opt_debug
1702302b15bdSmrg  func_to_host_file_result="$1"
1703302b15bdSmrg  if test -n "$1"; then
1704302b15bdSmrg    func_convert_core_msys_to_w32 "$1"
1705302b15bdSmrg    func_to_host_file_result="$func_convert_core_msys_to_w32_result"
1706302b15bdSmrg  fi
1707302b15bdSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1708302b15bdSmrg}
1709302b15bdSmrg# end func_convert_file_msys_to_w32
1710302b15bdSmrg
1711302b15bdSmrg
1712302b15bdSmrg# func_convert_file_cygwin_to_w32 ARG
1713302b15bdSmrg# Convert file name ARG from Cygwin to w32 format.  Returns result in
1714302b15bdSmrg# func_to_host_file_result.
1715302b15bdSmrgfunc_convert_file_cygwin_to_w32 ()
1716302b15bdSmrg{
1717302b15bdSmrg  $opt_debug
1718302b15bdSmrg  func_to_host_file_result="$1"
1719302b15bdSmrg  if test -n "$1"; then
1720302b15bdSmrg    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
1721302b15bdSmrg    # LT_CYGPATH in this case.
1722302b15bdSmrg    func_to_host_file_result=`cygpath -m "$1"`
1723302b15bdSmrg  fi
1724302b15bdSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1725302b15bdSmrg}
1726302b15bdSmrg# end func_convert_file_cygwin_to_w32
1727302b15bdSmrg
1728302b15bdSmrg
1729302b15bdSmrg# func_convert_file_nix_to_w32 ARG
1730302b15bdSmrg# Convert file name ARG from *nix to w32 format.  Requires a wine environment
1731302b15bdSmrg# and a working winepath. Returns result in func_to_host_file_result.
1732302b15bdSmrgfunc_convert_file_nix_to_w32 ()
1733302b15bdSmrg{
1734302b15bdSmrg  $opt_debug
1735302b15bdSmrg  func_to_host_file_result="$1"
1736302b15bdSmrg  if test -n "$1"; then
1737302b15bdSmrg    func_convert_core_file_wine_to_w32 "$1"
1738302b15bdSmrg    func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
1739302b15bdSmrg  fi
1740302b15bdSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1741302b15bdSmrg}
1742302b15bdSmrg# end func_convert_file_nix_to_w32
1743302b15bdSmrg
1744302b15bdSmrg
1745302b15bdSmrg# func_convert_file_msys_to_cygwin ARG
1746302b15bdSmrg# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
1747302b15bdSmrg# Returns result in func_to_host_file_result.
1748302b15bdSmrgfunc_convert_file_msys_to_cygwin ()
1749302b15bdSmrg{
1750302b15bdSmrg  $opt_debug
1751302b15bdSmrg  func_to_host_file_result="$1"
1752302b15bdSmrg  if test -n "$1"; then
1753302b15bdSmrg    func_convert_core_msys_to_w32 "$1"
1754302b15bdSmrg    func_cygpath -u "$func_convert_core_msys_to_w32_result"
1755302b15bdSmrg    func_to_host_file_result="$func_cygpath_result"
1756302b15bdSmrg  fi
1757302b15bdSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1758302b15bdSmrg}
1759302b15bdSmrg# end func_convert_file_msys_to_cygwin
1760302b15bdSmrg
1761302b15bdSmrg
1762302b15bdSmrg# func_convert_file_nix_to_cygwin ARG
1763302b15bdSmrg# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
1764302b15bdSmrg# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
1765302b15bdSmrg# in func_to_host_file_result.
1766302b15bdSmrgfunc_convert_file_nix_to_cygwin ()
1767302b15bdSmrg{
1768302b15bdSmrg  $opt_debug
1769302b15bdSmrg  func_to_host_file_result="$1"
1770302b15bdSmrg  if test -n "$1"; then
1771302b15bdSmrg    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
1772302b15bdSmrg    func_convert_core_file_wine_to_w32 "$1"
1773302b15bdSmrg    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
1774302b15bdSmrg    func_to_host_file_result="$func_cygpath_result"
1775302b15bdSmrg  fi
1776302b15bdSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1777302b15bdSmrg}
1778302b15bdSmrg# end func_convert_file_nix_to_cygwin
1779302b15bdSmrg
1780302b15bdSmrg
1781302b15bdSmrg#############################################
1782302b15bdSmrg# $build to $host PATH CONVERSION FUNCTIONS #
1783302b15bdSmrg#############################################
1784302b15bdSmrg# invoked via `$to_host_path_cmd ARG'
1785302b15bdSmrg#
1786302b15bdSmrg# In each case, ARG is the path to be converted from $build to $host format.
1787302b15bdSmrg# The result will be available in $func_to_host_path_result.
1788302b15bdSmrg#
1789302b15bdSmrg# Path separators are also converted from $build format to $host format.  If
1790302b15bdSmrg# ARG begins or ends with a path separator character, it is preserved (but
1791302b15bdSmrg# converted to $host format) on output.
1792302b15bdSmrg#
1793302b15bdSmrg# All path conversion functions are named using the following convention:
1794302b15bdSmrg#   file name conversion function    : func_convert_file_X_to_Y ()
1795302b15bdSmrg#   path conversion function         : func_convert_path_X_to_Y ()
1796302b15bdSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the
1797302b15bdSmrg# same.  If conversion functions are added for new $build/$host combinations,
1798302b15bdSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd
1799302b15bdSmrg# will break.
1800302b15bdSmrg
1801302b15bdSmrg
1802302b15bdSmrg# func_init_to_host_path_cmd
1803302b15bdSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the
1804302b15bdSmrg# appropriate value, based on the value of $to_host_file_cmd.
1805302b15bdSmrgto_host_path_cmd=
1806302b15bdSmrgfunc_init_to_host_path_cmd ()
1807302b15bdSmrg{
1808302b15bdSmrg  $opt_debug
1809302b15bdSmrg  if test -z "$to_host_path_cmd"; then
1810302b15bdSmrg    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
1811302b15bdSmrg    to_host_path_cmd="func_convert_path_${func_stripname_result}"
1812302b15bdSmrg  fi
1813302b15bdSmrg}
1814302b15bdSmrg
1815302b15bdSmrg
1816302b15bdSmrg# func_to_host_path ARG
1817302b15bdSmrg# Converts the path ARG from $build format to $host format. Return result
1818302b15bdSmrg# in func_to_host_path_result.
1819302b15bdSmrgfunc_to_host_path ()
1820302b15bdSmrg{
1821302b15bdSmrg  $opt_debug
1822302b15bdSmrg  func_init_to_host_path_cmd
1823302b15bdSmrg  $to_host_path_cmd "$1"
1824302b15bdSmrg}
1825302b15bdSmrg# end func_to_host_path
1826302b15bdSmrg
1827302b15bdSmrg
1828302b15bdSmrg# func_convert_path_noop ARG
1829302b15bdSmrg# Copy ARG to func_to_host_path_result.
1830302b15bdSmrgfunc_convert_path_noop ()
1831302b15bdSmrg{
1832302b15bdSmrg  func_to_host_path_result="$1"
1833302b15bdSmrg}
1834302b15bdSmrg# end func_convert_path_noop
1835302b15bdSmrg
1836302b15bdSmrg
1837302b15bdSmrg# func_convert_path_msys_to_w32 ARG
1838302b15bdSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
1839302b15bdSmrg# conversion to w32 is not available inside the cwrapper.  Returns result in
1840302b15bdSmrg# func_to_host_path_result.
1841302b15bdSmrgfunc_convert_path_msys_to_w32 ()
1842b85037dbSmrg{
1843302b15bdSmrg  $opt_debug
1844302b15bdSmrg  func_to_host_path_result="$1"
1845302b15bdSmrg  if test -n "$1"; then
1846302b15bdSmrg    # Remove leading and trailing path separator characters from ARG.  MSYS
1847302b15bdSmrg    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
1848302b15bdSmrg    # and winepath ignores them completely.
1849302b15bdSmrg    func_stripname : : "$1"
1850302b15bdSmrg    func_to_host_path_tmp1=$func_stripname_result
1851302b15bdSmrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1852302b15bdSmrg    func_to_host_path_result="$func_convert_core_msys_to_w32_result"
1853302b15bdSmrg    func_convert_path_check : ";" \
1854302b15bdSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1855302b15bdSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1856302b15bdSmrg  fi
1857302b15bdSmrg}
1858302b15bdSmrg# end func_convert_path_msys_to_w32
1859b85037dbSmrg
1860b85037dbSmrg
1861302b15bdSmrg# func_convert_path_cygwin_to_w32 ARG
1862302b15bdSmrg# Convert path ARG from Cygwin to w32 format.  Returns result in
1863302b15bdSmrg# func_to_host_file_result.
1864302b15bdSmrgfunc_convert_path_cygwin_to_w32 ()
1865302b15bdSmrg{
1866302b15bdSmrg  $opt_debug
1867302b15bdSmrg  func_to_host_path_result="$1"
1868302b15bdSmrg  if test -n "$1"; then
1869302b15bdSmrg    # See func_convert_path_msys_to_w32:
1870302b15bdSmrg    func_stripname : : "$1"
1871302b15bdSmrg    func_to_host_path_tmp1=$func_stripname_result
1872302b15bdSmrg    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
1873302b15bdSmrg    func_convert_path_check : ";" \
1874302b15bdSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1875302b15bdSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1876302b15bdSmrg  fi
1877302b15bdSmrg}
1878302b15bdSmrg# end func_convert_path_cygwin_to_w32
1879b85037dbSmrg
1880b85037dbSmrg
1881302b15bdSmrg# func_convert_path_nix_to_w32 ARG
1882302b15bdSmrg# Convert path ARG from *nix to w32 format.  Requires a wine environment and
1883302b15bdSmrg# a working winepath.  Returns result in func_to_host_file_result.
1884302b15bdSmrgfunc_convert_path_nix_to_w32 ()
1885302b15bdSmrg{
1886302b15bdSmrg  $opt_debug
1887302b15bdSmrg  func_to_host_path_result="$1"
1888302b15bdSmrg  if test -n "$1"; then
1889302b15bdSmrg    # See func_convert_path_msys_to_w32:
1890302b15bdSmrg    func_stripname : : "$1"
1891302b15bdSmrg    func_to_host_path_tmp1=$func_stripname_result
1892302b15bdSmrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1893302b15bdSmrg    func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
1894302b15bdSmrg    func_convert_path_check : ";" \
1895302b15bdSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1896302b15bdSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1897302b15bdSmrg  fi
1898302b15bdSmrg}
1899302b15bdSmrg# end func_convert_path_nix_to_w32
1900b85037dbSmrg
1901302b15bdSmrg
1902302b15bdSmrg# func_convert_path_msys_to_cygwin ARG
1903302b15bdSmrg# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
1904302b15bdSmrg# Returns result in func_to_host_file_result.
1905302b15bdSmrgfunc_convert_path_msys_to_cygwin ()
1906302b15bdSmrg{
1907302b15bdSmrg  $opt_debug
1908302b15bdSmrg  func_to_host_path_result="$1"
1909302b15bdSmrg  if test -n "$1"; then
1910302b15bdSmrg    # See func_convert_path_msys_to_w32:
1911302b15bdSmrg    func_stripname : : "$1"
1912302b15bdSmrg    func_to_host_path_tmp1=$func_stripname_result
1913302b15bdSmrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1914302b15bdSmrg    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
1915302b15bdSmrg    func_to_host_path_result="$func_cygpath_result"
1916302b15bdSmrg    func_convert_path_check : : \
1917302b15bdSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1918302b15bdSmrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1919302b15bdSmrg  fi
1920302b15bdSmrg}
1921302b15bdSmrg# end func_convert_path_msys_to_cygwin
1922302b15bdSmrg
1923302b15bdSmrg
1924302b15bdSmrg# func_convert_path_nix_to_cygwin ARG
1925302b15bdSmrg# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
1926302b15bdSmrg# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
1927302b15bdSmrg# func_to_host_file_result.
1928302b15bdSmrgfunc_convert_path_nix_to_cygwin ()
1929302b15bdSmrg{
1930302b15bdSmrg  $opt_debug
1931302b15bdSmrg  func_to_host_path_result="$1"
1932302b15bdSmrg  if test -n "$1"; then
1933302b15bdSmrg    # Remove leading and trailing path separator characters from
1934302b15bdSmrg    # ARG. msys behavior is inconsistent here, cygpath turns them
1935302b15bdSmrg    # into '.;' and ';.', and winepath ignores them completely.
1936302b15bdSmrg    func_stripname : : "$1"
1937302b15bdSmrg    func_to_host_path_tmp1=$func_stripname_result
1938302b15bdSmrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1939302b15bdSmrg    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
1940302b15bdSmrg    func_to_host_path_result="$func_cygpath_result"
1941302b15bdSmrg    func_convert_path_check : : \
1942302b15bdSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1943302b15bdSmrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1944302b15bdSmrg  fi
1945b85037dbSmrg}
1946302b15bdSmrg# end func_convert_path_nix_to_cygwin
1947302b15bdSmrg
1948b85037dbSmrg
1949b85037dbSmrg# func_mode_compile arg...
1950b85037dbSmrgfunc_mode_compile ()
1951b85037dbSmrg{
1952b85037dbSmrg    $opt_debug
1953b85037dbSmrg    # Get the compilation command and the source file.
1954b85037dbSmrg    base_compile=
1955b85037dbSmrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
1956b85037dbSmrg    suppress_opt=yes
1957b85037dbSmrg    suppress_output=
1958b85037dbSmrg    arg_mode=normal
1959b85037dbSmrg    libobj=
1960b85037dbSmrg    later=
1961b85037dbSmrg    pie_flag=
1962b85037dbSmrg
1963b85037dbSmrg    for arg
1964b85037dbSmrg    do
1965b85037dbSmrg      case $arg_mode in
1966b85037dbSmrg      arg  )
1967b85037dbSmrg	# do not "continue".  Instead, add this to base_compile
1968b85037dbSmrg	lastarg="$arg"
1969b85037dbSmrg	arg_mode=normal
1970b85037dbSmrg	;;
1971b85037dbSmrg
1972b85037dbSmrg      target )
1973b85037dbSmrg	libobj="$arg"
1974b85037dbSmrg	arg_mode=normal
1975b85037dbSmrg	continue
1976b85037dbSmrg	;;
1977b85037dbSmrg
1978b85037dbSmrg      normal )
1979b85037dbSmrg	# Accept any command-line options.
1980b85037dbSmrg	case $arg in
1981b85037dbSmrg	-o)
1982b85037dbSmrg	  test -n "$libobj" && \
1983b85037dbSmrg	    func_fatal_error "you cannot specify \`-o' more than once"
1984b85037dbSmrg	  arg_mode=target
1985b85037dbSmrg	  continue
1986b85037dbSmrg	  ;;
1987b85037dbSmrg
1988b85037dbSmrg	-pie | -fpie | -fPIE)
1989302b15bdSmrg          func_append pie_flag " $arg"
1990b85037dbSmrg	  continue
1991b85037dbSmrg	  ;;
1992b85037dbSmrg
1993b85037dbSmrg	-shared | -static | -prefer-pic | -prefer-non-pic)
1994302b15bdSmrg	  func_append later " $arg"
1995b85037dbSmrg	  continue
1996b85037dbSmrg	  ;;
1997b85037dbSmrg
1998b85037dbSmrg	-no-suppress)
1999b85037dbSmrg	  suppress_opt=no
2000b85037dbSmrg	  continue
2001b85037dbSmrg	  ;;
2002b85037dbSmrg
2003b85037dbSmrg	-Xcompiler)
2004b85037dbSmrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
2005b85037dbSmrg	  continue      #  The current "srcfile" will either be retained or
2006b85037dbSmrg	  ;;            #  replaced later.  I would guess that would be a bug.
2007b85037dbSmrg
2008b85037dbSmrg	-Wc,*)
2009b85037dbSmrg	  func_stripname '-Wc,' '' "$arg"
2010b85037dbSmrg	  args=$func_stripname_result
2011b85037dbSmrg	  lastarg=
2012b85037dbSmrg	  save_ifs="$IFS"; IFS=','
2013b85037dbSmrg	  for arg in $args; do
2014b85037dbSmrg	    IFS="$save_ifs"
2015302b15bdSmrg	    func_append_quoted lastarg "$arg"
2016b85037dbSmrg	  done
2017b85037dbSmrg	  IFS="$save_ifs"
2018b85037dbSmrg	  func_stripname ' ' '' "$lastarg"
2019b85037dbSmrg	  lastarg=$func_stripname_result
2020b85037dbSmrg
2021b85037dbSmrg	  # Add the arguments to base_compile.
2022302b15bdSmrg	  func_append base_compile " $lastarg"
2023b85037dbSmrg	  continue
2024b85037dbSmrg	  ;;
2025b85037dbSmrg
2026b85037dbSmrg	*)
2027b85037dbSmrg	  # Accept the current argument as the source file.
2028b85037dbSmrg	  # The previous "srcfile" becomes the current argument.
2029b85037dbSmrg	  #
2030b85037dbSmrg	  lastarg="$srcfile"
2031b85037dbSmrg	  srcfile="$arg"
2032b85037dbSmrg	  ;;
2033b85037dbSmrg	esac  #  case $arg
2034b85037dbSmrg	;;
2035b85037dbSmrg      esac    #  case $arg_mode
2036b85037dbSmrg
2037b85037dbSmrg      # Aesthetically quote the previous argument.
2038302b15bdSmrg      func_append_quoted base_compile "$lastarg"
2039b85037dbSmrg    done # for arg
2040b85037dbSmrg
2041b85037dbSmrg    case $arg_mode in
2042b85037dbSmrg    arg)
2043b85037dbSmrg      func_fatal_error "you must specify an argument for -Xcompile"
2044b85037dbSmrg      ;;
2045b85037dbSmrg    target)
2046b85037dbSmrg      func_fatal_error "you must specify a target with \`-o'"
2047b85037dbSmrg      ;;
2048b85037dbSmrg    *)
2049b85037dbSmrg      # Get the name of the library object.
2050b85037dbSmrg      test -z "$libobj" && {
2051b85037dbSmrg	func_basename "$srcfile"
2052b85037dbSmrg	libobj="$func_basename_result"
2053b85037dbSmrg      }
2054b85037dbSmrg      ;;
2055b85037dbSmrg    esac
2056b85037dbSmrg
2057b85037dbSmrg    # Recognize several different file suffixes.
2058b85037dbSmrg    # If the user specifies -o file.o, it is replaced with file.lo
2059b85037dbSmrg    case $libobj in
2060b85037dbSmrg    *.[cCFSifmso] | \
2061b85037dbSmrg    *.ada | *.adb | *.ads | *.asm | \
2062b85037dbSmrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
206328515619Smrg    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
2064b85037dbSmrg      func_xform "$libobj"
2065b85037dbSmrg      libobj=$func_xform_result
2066b85037dbSmrg      ;;
2067b85037dbSmrg    esac
2068b85037dbSmrg
2069b85037dbSmrg    case $libobj in
2070b85037dbSmrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
2071b85037dbSmrg    *)
2072b85037dbSmrg      func_fatal_error "cannot determine name of library object from \`$libobj'"
2073b85037dbSmrg      ;;
2074b85037dbSmrg    esac
2075b85037dbSmrg
2076b85037dbSmrg    func_infer_tag $base_compile
2077b85037dbSmrg
2078b85037dbSmrg    for arg in $later; do
2079b85037dbSmrg      case $arg in
2080b85037dbSmrg      -shared)
2081b85037dbSmrg	test "$build_libtool_libs" != yes && \
2082b85037dbSmrg	  func_fatal_configuration "can not build a shared library"
2083b85037dbSmrg	build_old_libs=no
2084b85037dbSmrg	continue
2085b85037dbSmrg	;;
2086b85037dbSmrg
2087b85037dbSmrg      -static)
2088b85037dbSmrg	build_libtool_libs=no
2089b85037dbSmrg	build_old_libs=yes
2090b85037dbSmrg	continue
2091b85037dbSmrg	;;
2092b85037dbSmrg
2093b85037dbSmrg      -prefer-pic)
2094b85037dbSmrg	pic_mode=yes
2095b85037dbSmrg	continue
2096b85037dbSmrg	;;
2097b85037dbSmrg
2098b85037dbSmrg      -prefer-non-pic)
2099b85037dbSmrg	pic_mode=no
2100b85037dbSmrg	continue
2101b85037dbSmrg	;;
2102b85037dbSmrg      esac
2103b85037dbSmrg    done
2104b85037dbSmrg
2105b85037dbSmrg    func_quote_for_eval "$libobj"
2106b85037dbSmrg    test "X$libobj" != "X$func_quote_for_eval_result" \
2107b85037dbSmrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
2108b85037dbSmrg      && func_warning "libobj name \`$libobj' may not contain shell special characters."
2109b85037dbSmrg    func_dirname_and_basename "$obj" "/" ""
2110b85037dbSmrg    objname="$func_basename_result"
2111b85037dbSmrg    xdir="$func_dirname_result"
2112b85037dbSmrg    lobj=${xdir}$objdir/$objname
2113b85037dbSmrg
2114b85037dbSmrg    test -z "$base_compile" && \
2115b85037dbSmrg      func_fatal_help "you must specify a compilation command"
2116b85037dbSmrg
2117b85037dbSmrg    # Delete any leftover library objects.
2118b85037dbSmrg    if test "$build_old_libs" = yes; then
2119b85037dbSmrg      removelist="$obj $lobj $libobj ${libobj}T"
2120b85037dbSmrg    else
2121b85037dbSmrg      removelist="$lobj $libobj ${libobj}T"
2122b85037dbSmrg    fi
2123b85037dbSmrg
2124b85037dbSmrg    # On Cygwin there's no "real" PIC flag so we must build both object types
2125b85037dbSmrg    case $host_os in
2126b85037dbSmrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
2127b85037dbSmrg      pic_mode=default
2128b85037dbSmrg      ;;
2129b85037dbSmrg    esac
2130b85037dbSmrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
2131b85037dbSmrg      # non-PIC code in shared libraries is not supported
2132b85037dbSmrg      pic_mode=default
2133b85037dbSmrg    fi
2134b85037dbSmrg
2135b85037dbSmrg    # Calculate the filename of the output object if compiler does
2136b85037dbSmrg    # not support -o with -c
2137b85037dbSmrg    if test "$compiler_c_o" = no; then
2138b85037dbSmrg      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
2139b85037dbSmrg      lockfile="$output_obj.lock"
2140b85037dbSmrg    else
2141b85037dbSmrg      output_obj=
2142b85037dbSmrg      need_locks=no
2143b85037dbSmrg      lockfile=
2144b85037dbSmrg    fi
2145b85037dbSmrg
2146b85037dbSmrg    # Lock this critical section if it is needed
2147b85037dbSmrg    # We use this script file to make the link, it avoids creating a new file
2148b85037dbSmrg    if test "$need_locks" = yes; then
2149b85037dbSmrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
2150b85037dbSmrg	func_echo "Waiting for $lockfile to be removed"
2151b85037dbSmrg	sleep 2
2152b85037dbSmrg      done
2153b85037dbSmrg    elif test "$need_locks" = warn; then
2154b85037dbSmrg      if test -f "$lockfile"; then
2155b85037dbSmrg	$ECHO "\
2156b85037dbSmrg*** ERROR, $lockfile exists and contains:
2157b85037dbSmrg`cat $lockfile 2>/dev/null`
2158b85037dbSmrg
2159b85037dbSmrgThis indicates that another process is trying to use the same
2160b85037dbSmrgtemporary object file, and libtool could not work around it because
2161b85037dbSmrgyour compiler does not support \`-c' and \`-o' together.  If you
2162b85037dbSmrgrepeat this compilation, it may succeed, by chance, but you had better
2163b85037dbSmrgavoid parallel builds (make -j) in this platform, or get a better
2164b85037dbSmrgcompiler."
2165b85037dbSmrg
2166b85037dbSmrg	$opt_dry_run || $RM $removelist
2167b85037dbSmrg	exit $EXIT_FAILURE
2168b85037dbSmrg      fi
2169302b15bdSmrg      func_append removelist " $output_obj"
2170b85037dbSmrg      $ECHO "$srcfile" > "$lockfile"
2171b85037dbSmrg    fi
2172b85037dbSmrg
2173b85037dbSmrg    $opt_dry_run || $RM $removelist
2174302b15bdSmrg    func_append removelist " $lockfile"
2175b85037dbSmrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
2176b85037dbSmrg
2177302b15bdSmrg    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
2178302b15bdSmrg    srcfile=$func_to_tool_file_result
2179b85037dbSmrg    func_quote_for_eval "$srcfile"
2180b85037dbSmrg    qsrcfile=$func_quote_for_eval_result
2181b85037dbSmrg
2182b85037dbSmrg    # Only build a PIC object if we are building libtool libraries.
2183b85037dbSmrg    if test "$build_libtool_libs" = yes; then
2184b85037dbSmrg      # Without this assignment, base_compile gets emptied.
2185b85037dbSmrg      fbsd_hideous_sh_bug=$base_compile
2186b85037dbSmrg
2187b85037dbSmrg      if test "$pic_mode" != no; then
2188b85037dbSmrg	command="$base_compile $qsrcfile $pic_flag"
2189b85037dbSmrg      else
2190b85037dbSmrg	# Don't build PIC code
2191b85037dbSmrg	command="$base_compile $qsrcfile"
2192b85037dbSmrg      fi
2193b85037dbSmrg
2194b85037dbSmrg      func_mkdir_p "$xdir$objdir"
2195b85037dbSmrg
2196b85037dbSmrg      if test -z "$output_obj"; then
2197b85037dbSmrg	# Place PIC objects in $objdir
2198302b15bdSmrg	func_append command " -o $lobj"
2199b85037dbSmrg      fi
2200b85037dbSmrg
2201b85037dbSmrg      func_show_eval_locale "$command"	\
2202b85037dbSmrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
2203b85037dbSmrg
2204b85037dbSmrg      if test "$need_locks" = warn &&
2205b85037dbSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2206b85037dbSmrg	$ECHO "\
2207b85037dbSmrg*** ERROR, $lockfile contains:
2208b85037dbSmrg`cat $lockfile 2>/dev/null`
2209b85037dbSmrg
2210b85037dbSmrgbut it should contain:
2211b85037dbSmrg$srcfile
2212b85037dbSmrg
2213b85037dbSmrgThis indicates that another process is trying to use the same
2214b85037dbSmrgtemporary object file, and libtool could not work around it because
2215b85037dbSmrgyour compiler does not support \`-c' and \`-o' together.  If you
2216b85037dbSmrgrepeat this compilation, it may succeed, by chance, but you had better
2217b85037dbSmrgavoid parallel builds (make -j) in this platform, or get a better
2218b85037dbSmrgcompiler."
2219b85037dbSmrg
2220b85037dbSmrg	$opt_dry_run || $RM $removelist
2221b85037dbSmrg	exit $EXIT_FAILURE
2222b85037dbSmrg      fi
2223b85037dbSmrg
2224b85037dbSmrg      # Just move the object if needed, then go on to compile the next one
2225b85037dbSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
2226b85037dbSmrg	func_show_eval '$MV "$output_obj" "$lobj"' \
2227b85037dbSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
2228b85037dbSmrg      fi
2229b85037dbSmrg
2230b85037dbSmrg      # Allow error messages only from the first compilation.
2231b85037dbSmrg      if test "$suppress_opt" = yes; then
2232b85037dbSmrg	suppress_output=' >/dev/null 2>&1'
2233b85037dbSmrg      fi
2234b85037dbSmrg    fi
2235b85037dbSmrg
2236b85037dbSmrg    # Only build a position-dependent object if we build old libraries.
2237b85037dbSmrg    if test "$build_old_libs" = yes; then
2238b85037dbSmrg      if test "$pic_mode" != yes; then
2239b85037dbSmrg	# Don't build PIC code
2240b85037dbSmrg	command="$base_compile $qsrcfile$pie_flag"
2241b85037dbSmrg      else
2242b85037dbSmrg	command="$base_compile $qsrcfile $pic_flag"
2243b85037dbSmrg      fi
2244b85037dbSmrg      if test "$compiler_c_o" = yes; then
2245302b15bdSmrg	func_append command " -o $obj"
2246b85037dbSmrg      fi
2247b85037dbSmrg
2248b85037dbSmrg      # Suppress compiler output if we already did a PIC compilation.
2249302b15bdSmrg      func_append command "$suppress_output"
2250b85037dbSmrg      func_show_eval_locale "$command" \
2251b85037dbSmrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
2252b85037dbSmrg
2253b85037dbSmrg      if test "$need_locks" = warn &&
2254b85037dbSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2255b85037dbSmrg	$ECHO "\
2256b85037dbSmrg*** ERROR, $lockfile contains:
2257b85037dbSmrg`cat $lockfile 2>/dev/null`
2258b85037dbSmrg
2259b85037dbSmrgbut it should contain:
2260b85037dbSmrg$srcfile
2261b85037dbSmrg
2262b85037dbSmrgThis indicates that another process is trying to use the same
2263b85037dbSmrgtemporary object file, and libtool could not work around it because
2264b85037dbSmrgyour compiler does not support \`-c' and \`-o' together.  If you
2265b85037dbSmrgrepeat this compilation, it may succeed, by chance, but you had better
2266b85037dbSmrgavoid parallel builds (make -j) in this platform, or get a better
2267b85037dbSmrgcompiler."
2268b85037dbSmrg
2269b85037dbSmrg	$opt_dry_run || $RM $removelist
2270b85037dbSmrg	exit $EXIT_FAILURE
2271b85037dbSmrg      fi
2272b85037dbSmrg
2273b85037dbSmrg      # Just move the object if needed
2274b85037dbSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
2275b85037dbSmrg	func_show_eval '$MV "$output_obj" "$obj"' \
2276b85037dbSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
2277b85037dbSmrg      fi
2278b85037dbSmrg    fi
2279b85037dbSmrg
2280b85037dbSmrg    $opt_dry_run || {
2281b85037dbSmrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
2282b85037dbSmrg
2283b85037dbSmrg      # Unlock the critical section if it was locked
2284b85037dbSmrg      if test "$need_locks" != no; then
2285b85037dbSmrg	removelist=$lockfile
2286b85037dbSmrg        $RM "$lockfile"
2287b85037dbSmrg      fi
2288b85037dbSmrg    }
2289b85037dbSmrg
2290b85037dbSmrg    exit $EXIT_SUCCESS
2291b85037dbSmrg}
2292b85037dbSmrg
2293b85037dbSmrg$opt_help || {
2294302b15bdSmrg  test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
2295b85037dbSmrg}
2296b85037dbSmrg
2297b85037dbSmrgfunc_mode_help ()
2298b85037dbSmrg{
2299b85037dbSmrg    # We need to display help for each of the modes.
2300302b15bdSmrg    case $opt_mode in
2301b85037dbSmrg      "")
2302b85037dbSmrg        # Generic help is extracted from the usage comments
2303b85037dbSmrg        # at the start of this file.
2304b85037dbSmrg        func_help
2305b85037dbSmrg        ;;
2306b85037dbSmrg
2307b85037dbSmrg      clean)
2308b85037dbSmrg        $ECHO \
2309b85037dbSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
2310b85037dbSmrg
2311b85037dbSmrgRemove files from the build directory.
2312b85037dbSmrg
2313b85037dbSmrgRM is the name of the program to use to delete files associated with each FILE
2314b85037dbSmrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
2315b85037dbSmrgto RM.
2316b85037dbSmrg
2317b85037dbSmrgIf FILE is a libtool library, object or program, all the files associated
2318b85037dbSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
2319b85037dbSmrg        ;;
2320b85037dbSmrg
2321b85037dbSmrg      compile)
2322b85037dbSmrg      $ECHO \
2323b85037dbSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
2324b85037dbSmrg
2325b85037dbSmrgCompile a source file into a libtool library object.
2326b85037dbSmrg
2327b85037dbSmrgThis mode accepts the following additional options:
2328b85037dbSmrg
2329b85037dbSmrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
2330b85037dbSmrg  -no-suppress      do not suppress compiler output for multiple passes
2331b85037dbSmrg  -prefer-pic       try to build PIC objects only
2332b85037dbSmrg  -prefer-non-pic   try to build non-PIC objects only
2333b85037dbSmrg  -shared           do not build a \`.o' file suitable for static linking
2334b85037dbSmrg  -static           only build a \`.o' file suitable for static linking
2335b85037dbSmrg  -Wc,FLAG          pass FLAG directly to the compiler
2336b85037dbSmrg
2337b85037dbSmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
2338b85037dbSmrgfrom the given SOURCEFILE.
2339b85037dbSmrg
2340b85037dbSmrgThe output file name is determined by removing the directory component from
2341b85037dbSmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
2342b85037dbSmrglibrary object suffix, \`.lo'."
2343b85037dbSmrg        ;;
2344b85037dbSmrg
2345b85037dbSmrg      execute)
2346b85037dbSmrg        $ECHO \
2347b85037dbSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
2348b85037dbSmrg
2349b85037dbSmrgAutomatically set library path, then run a program.
2350b85037dbSmrg
2351b85037dbSmrgThis mode accepts the following additional options:
2352b85037dbSmrg
2353b85037dbSmrg  -dlopen FILE      add the directory containing FILE to the library path
2354b85037dbSmrg
2355b85037dbSmrgThis mode sets the library path environment variable according to \`-dlopen'
2356b85037dbSmrgflags.
2357b85037dbSmrg
2358b85037dbSmrgIf any of the ARGS are libtool executable wrappers, then they are translated
2359b85037dbSmrginto their corresponding uninstalled binary, and any of their required library
2360b85037dbSmrgdirectories are added to the library path.
2361b85037dbSmrg
2362b85037dbSmrgThen, COMMAND is executed, with ARGS as arguments."
2363b85037dbSmrg        ;;
2364b85037dbSmrg
2365b85037dbSmrg      finish)
2366b85037dbSmrg        $ECHO \
2367b85037dbSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
2368b85037dbSmrg
2369b85037dbSmrgComplete the installation of libtool libraries.
2370b85037dbSmrg
2371b85037dbSmrgEach LIBDIR is a directory that contains libtool libraries.
2372b85037dbSmrg
2373b85037dbSmrgThe commands that this mode executes may require superuser privileges.  Use
2374b85037dbSmrgthe \`--dry-run' option if you just want to see what would be executed."
2375b85037dbSmrg        ;;
2376b85037dbSmrg
2377b85037dbSmrg      install)
2378b85037dbSmrg        $ECHO \
2379b85037dbSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
2380b85037dbSmrg
2381b85037dbSmrgInstall executables or libraries.
2382b85037dbSmrg
2383b85037dbSmrgINSTALL-COMMAND is the installation command.  The first component should be
2384b85037dbSmrgeither the \`install' or \`cp' program.
2385b85037dbSmrg
2386b85037dbSmrgThe following components of INSTALL-COMMAND are treated specially:
2387b85037dbSmrg
2388b85037dbSmrg  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
2389b85037dbSmrg
2390b85037dbSmrgThe rest of the components are interpreted as arguments to that command (only
2391b85037dbSmrgBSD-compatible install options are recognized)."
2392b85037dbSmrg        ;;
2393b85037dbSmrg
2394b85037dbSmrg      link)
2395b85037dbSmrg        $ECHO \
2396b85037dbSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
2397b85037dbSmrg
2398b85037dbSmrgLink object files or libraries together to form another library, or to
2399b85037dbSmrgcreate an executable program.
2400b85037dbSmrg
2401b85037dbSmrgLINK-COMMAND is a command using the C compiler that you would use to create
2402b85037dbSmrga program from several object files.
2403b85037dbSmrg
2404b85037dbSmrgThe following components of LINK-COMMAND are treated specially:
2405b85037dbSmrg
2406b85037dbSmrg  -all-static       do not do any dynamic linking at all
2407b85037dbSmrg  -avoid-version    do not add a version suffix if possible
2408b85037dbSmrg  -bindir BINDIR    specify path to binaries directory (for systems where
2409b85037dbSmrg                    libraries must be found in the PATH setting at runtime)
2410b85037dbSmrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
2411b85037dbSmrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
2412b85037dbSmrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
2413b85037dbSmrg  -export-symbols SYMFILE
2414b85037dbSmrg                    try to export only the symbols listed in SYMFILE
2415b85037dbSmrg  -export-symbols-regex REGEX
2416b85037dbSmrg                    try to export only the symbols matching REGEX
2417b85037dbSmrg  -LLIBDIR          search LIBDIR for required installed libraries
2418b85037dbSmrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
2419b85037dbSmrg  -module           build a library that can dlopened
2420b85037dbSmrg  -no-fast-install  disable the fast-install mode
2421b85037dbSmrg  -no-install       link a not-installable executable
2422b85037dbSmrg  -no-undefined     declare that a library does not refer to external symbols
2423b85037dbSmrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
2424b85037dbSmrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
2425b85037dbSmrg  -precious-files-regex REGEX
2426b85037dbSmrg                    don't remove output files matching REGEX
2427b85037dbSmrg  -release RELEASE  specify package release information
2428b85037dbSmrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
2429b85037dbSmrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
2430b85037dbSmrg  -shared           only do dynamic linking of libtool libraries
2431b85037dbSmrg  -shrext SUFFIX    override the standard shared library file extension
2432b85037dbSmrg  -static           do not do any dynamic linking of uninstalled libtool libraries
2433b85037dbSmrg  -static-libtool-libs
2434b85037dbSmrg                    do not do any dynamic linking of libtool libraries
2435b85037dbSmrg  -version-info CURRENT[:REVISION[:AGE]]
2436b85037dbSmrg                    specify library version info [each variable defaults to 0]
2437b85037dbSmrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
2438b85037dbSmrg  -Wc,FLAG
2439b85037dbSmrg  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
2440b85037dbSmrg  -Wl,FLAG
2441b85037dbSmrg  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
2442b85037dbSmrg  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
2443b85037dbSmrg
2444b85037dbSmrgAll other options (arguments beginning with \`-') are ignored.
2445b85037dbSmrg
2446b85037dbSmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
2447b85037dbSmrgtreated as uninstalled libtool libraries, other files are standard or library
2448b85037dbSmrgobject files.
2449b85037dbSmrg
2450b85037dbSmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
2451b85037dbSmrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
2452b85037dbSmrgrequired, except when creating a convenience library.
2453b85037dbSmrg
2454b85037dbSmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
2455b85037dbSmrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
2456b85037dbSmrg
2457b85037dbSmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
2458b85037dbSmrgis created, otherwise an executable program is created."
2459b85037dbSmrg        ;;
2460b85037dbSmrg
2461b85037dbSmrg      uninstall)
2462b85037dbSmrg        $ECHO \
2463b85037dbSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
2464b85037dbSmrg
2465b85037dbSmrgRemove libraries from an installation directory.
2466b85037dbSmrg
2467b85037dbSmrgRM is the name of the program to use to delete files associated with each FILE
2468b85037dbSmrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
2469b85037dbSmrgto RM.
2470b85037dbSmrg
2471b85037dbSmrgIf FILE is a libtool library, all the files associated with it are deleted.
2472b85037dbSmrgOtherwise, only FILE itself is deleted using RM."
2473b85037dbSmrg        ;;
2474b85037dbSmrg
2475b85037dbSmrg      *)
2476302b15bdSmrg        func_fatal_help "invalid operation mode \`$opt_mode'"
2477b85037dbSmrg        ;;
2478b85037dbSmrg    esac
2479b85037dbSmrg
2480b85037dbSmrg    echo
2481b85037dbSmrg    $ECHO "Try \`$progname --help' for more information about other modes."
2482b85037dbSmrg}
2483b85037dbSmrg
2484b85037dbSmrg# Now that we've collected a possible --mode arg, show help if necessary
2485b85037dbSmrgif $opt_help; then
2486b85037dbSmrg  if test "$opt_help" = :; then
2487b85037dbSmrg    func_mode_help
2488b85037dbSmrg  else
2489b85037dbSmrg    {
2490b85037dbSmrg      func_help noexit
2491302b15bdSmrg      for opt_mode in compile link execute install finish uninstall clean; do
2492b85037dbSmrg	func_mode_help
2493b85037dbSmrg      done
2494b85037dbSmrg    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
2495b85037dbSmrg    {
2496b85037dbSmrg      func_help noexit
2497302b15bdSmrg      for opt_mode in compile link execute install finish uninstall clean; do
2498b85037dbSmrg	echo
2499b85037dbSmrg	func_mode_help
2500b85037dbSmrg      done
2501b85037dbSmrg    } |
2502b85037dbSmrg    sed '1d
2503b85037dbSmrg      /^When reporting/,/^Report/{
2504b85037dbSmrg	H
2505b85037dbSmrg	d
2506b85037dbSmrg      }
2507b85037dbSmrg      $x
2508b85037dbSmrg      /information about other modes/d
2509b85037dbSmrg      /more detailed .*MODE/d
2510b85037dbSmrg      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
2511b85037dbSmrg  fi
2512b85037dbSmrg  exit $?
2513b85037dbSmrgfi
2514b85037dbSmrg
2515b85037dbSmrg
2516b85037dbSmrg# func_mode_execute arg...
2517b85037dbSmrgfunc_mode_execute ()
2518b85037dbSmrg{
2519b85037dbSmrg    $opt_debug
2520b85037dbSmrg    # The first argument is the command name.
2521b85037dbSmrg    cmd="$nonopt"
2522b85037dbSmrg    test -z "$cmd" && \
2523b85037dbSmrg      func_fatal_help "you must specify a COMMAND"
2524b85037dbSmrg
2525b85037dbSmrg    # Handle -dlopen flags immediately.
2526302b15bdSmrg    for file in $opt_dlopen; do
2527b85037dbSmrg      test -f "$file" \
2528b85037dbSmrg	|| func_fatal_help "\`$file' is not a file"
2529b85037dbSmrg
2530b85037dbSmrg      dir=
2531b85037dbSmrg      case $file in
2532b85037dbSmrg      *.la)
2533302b15bdSmrg	func_resolve_sysroot "$file"
2534302b15bdSmrg	file=$func_resolve_sysroot_result
2535302b15bdSmrg
2536b85037dbSmrg	# Check to see that this really is a libtool archive.
2537b85037dbSmrg	func_lalib_unsafe_p "$file" \
2538b85037dbSmrg	  || func_fatal_help "\`$lib' is not a valid libtool archive"
2539b85037dbSmrg
2540b85037dbSmrg	# Read the libtool library.
2541b85037dbSmrg	dlname=
2542b85037dbSmrg	library_names=
2543b85037dbSmrg	func_source "$file"
2544b85037dbSmrg
2545b85037dbSmrg	# Skip this library if it cannot be dlopened.
2546b85037dbSmrg	if test -z "$dlname"; then
2547b85037dbSmrg	  # Warn if it was a shared library.
2548b85037dbSmrg	  test -n "$library_names" && \
2549b85037dbSmrg	    func_warning "\`$file' was not linked with \`-export-dynamic'"
2550b85037dbSmrg	  continue
2551b85037dbSmrg	fi
2552b85037dbSmrg
2553b85037dbSmrg	func_dirname "$file" "" "."
2554b85037dbSmrg	dir="$func_dirname_result"
2555b85037dbSmrg
2556b85037dbSmrg	if test -f "$dir/$objdir/$dlname"; then
2557302b15bdSmrg	  func_append dir "/$objdir"
2558b85037dbSmrg	else
2559b85037dbSmrg	  if test ! -f "$dir/$dlname"; then
2560b85037dbSmrg	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
2561b85037dbSmrg	  fi
2562b85037dbSmrg	fi
2563b85037dbSmrg	;;
2564b85037dbSmrg
2565b85037dbSmrg      *.lo)
2566b85037dbSmrg	# Just add the directory containing the .lo file.
2567b85037dbSmrg	func_dirname "$file" "" "."
2568b85037dbSmrg	dir="$func_dirname_result"
2569b85037dbSmrg	;;
2570b85037dbSmrg
2571b85037dbSmrg      *)
2572b85037dbSmrg	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
2573b85037dbSmrg	continue
2574b85037dbSmrg	;;
2575b85037dbSmrg      esac
2576b85037dbSmrg
2577b85037dbSmrg      # Get the absolute pathname.
2578b85037dbSmrg      absdir=`cd "$dir" && pwd`
2579b85037dbSmrg      test -n "$absdir" && dir="$absdir"
2580b85037dbSmrg
2581b85037dbSmrg      # Now add the directory to shlibpath_var.
2582b85037dbSmrg      if eval "test -z \"\$$shlibpath_var\""; then
2583b85037dbSmrg	eval "$shlibpath_var=\"\$dir\""
2584b85037dbSmrg      else
2585b85037dbSmrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
2586b85037dbSmrg      fi
2587b85037dbSmrg    done
2588b85037dbSmrg
2589b85037dbSmrg    # This variable tells wrapper scripts just to set shlibpath_var
2590b85037dbSmrg    # rather than running their programs.
2591b85037dbSmrg    libtool_execute_magic="$magic"
2592b85037dbSmrg
2593b85037dbSmrg    # Check if any of the arguments is a wrapper script.
2594b85037dbSmrg    args=
2595b85037dbSmrg    for file
2596b85037dbSmrg    do
2597b85037dbSmrg      case $file in
2598b85037dbSmrg      -* | *.la | *.lo ) ;;
2599b85037dbSmrg      *)
2600b85037dbSmrg	# Do a test to see if this is really a libtool program.
2601b85037dbSmrg	if func_ltwrapper_script_p "$file"; then
2602b85037dbSmrg	  func_source "$file"
2603b85037dbSmrg	  # Transform arg to wrapped name.
2604b85037dbSmrg	  file="$progdir/$program"
2605b85037dbSmrg	elif func_ltwrapper_executable_p "$file"; then
2606b85037dbSmrg	  func_ltwrapper_scriptname "$file"
2607b85037dbSmrg	  func_source "$func_ltwrapper_scriptname_result"
2608b85037dbSmrg	  # Transform arg to wrapped name.
2609b85037dbSmrg	  file="$progdir/$program"
2610b85037dbSmrg	fi
2611b85037dbSmrg	;;
2612b85037dbSmrg      esac
2613b85037dbSmrg      # Quote arguments (to preserve shell metacharacters).
2614302b15bdSmrg      func_append_quoted args "$file"
2615b85037dbSmrg    done
2616b85037dbSmrg
2617b85037dbSmrg    if test "X$opt_dry_run" = Xfalse; then
2618b85037dbSmrg      if test -n "$shlibpath_var"; then
2619b85037dbSmrg	# Export the shlibpath_var.
2620b85037dbSmrg	eval "export $shlibpath_var"
2621b85037dbSmrg      fi
2622b85037dbSmrg
2623b85037dbSmrg      # Restore saved environment variables
2624b85037dbSmrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
2625b85037dbSmrg      do
2626b85037dbSmrg	eval "if test \"\${save_$lt_var+set}\" = set; then
2627b85037dbSmrg                $lt_var=\$save_$lt_var; export $lt_var
2628b85037dbSmrg	      else
2629b85037dbSmrg		$lt_unset $lt_var
2630b85037dbSmrg	      fi"
2631b85037dbSmrg      done
2632b85037dbSmrg
2633b85037dbSmrg      # Now prepare to actually exec the command.
2634b85037dbSmrg      exec_cmd="\$cmd$args"
2635b85037dbSmrg    else
2636b85037dbSmrg      # Display what would be done.
2637b85037dbSmrg      if test -n "$shlibpath_var"; then
2638b85037dbSmrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
2639b85037dbSmrg	echo "export $shlibpath_var"
2640b85037dbSmrg      fi
2641b85037dbSmrg      $ECHO "$cmd$args"
2642b85037dbSmrg      exit $EXIT_SUCCESS
2643b85037dbSmrg    fi
2644b85037dbSmrg}
2645b85037dbSmrg
2646302b15bdSmrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"}
2647b85037dbSmrg
2648b85037dbSmrg
2649b85037dbSmrg# func_mode_finish arg...
2650b85037dbSmrgfunc_mode_finish ()
2651b85037dbSmrg{
2652b85037dbSmrg    $opt_debug
2653302b15bdSmrg    libs=
2654302b15bdSmrg    libdirs=
2655b85037dbSmrg    admincmds=
2656b85037dbSmrg
2657302b15bdSmrg    for opt in "$nonopt" ${1+"$@"}
2658302b15bdSmrg    do
2659302b15bdSmrg      if test -d "$opt"; then
2660302b15bdSmrg	func_append libdirs " $opt"
2661302b15bdSmrg
2662302b15bdSmrg      elif test -f "$opt"; then
2663302b15bdSmrg	if func_lalib_unsafe_p "$opt"; then
2664302b15bdSmrg	  func_append libs " $opt"
2665302b15bdSmrg	else
2666302b15bdSmrg	  func_warning "\`$opt' is not a valid libtool archive"
2667302b15bdSmrg	fi
2668302b15bdSmrg
2669302b15bdSmrg      else
2670302b15bdSmrg	func_fatal_error "invalid argument \`$opt'"
2671302b15bdSmrg      fi
2672302b15bdSmrg    done
2673302b15bdSmrg
2674302b15bdSmrg    if test -n "$libs"; then
2675302b15bdSmrg      if test -n "$lt_sysroot"; then
2676302b15bdSmrg        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
2677302b15bdSmrg        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
2678302b15bdSmrg      else
2679302b15bdSmrg        sysroot_cmd=
2680302b15bdSmrg      fi
2681302b15bdSmrg
2682302b15bdSmrg      # Remove sysroot references
2683302b15bdSmrg      if $opt_dry_run; then
2684302b15bdSmrg        for lib in $libs; do
2685302b15bdSmrg          echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
2686302b15bdSmrg        done
2687302b15bdSmrg      else
2688302b15bdSmrg        tmpdir=`func_mktempdir`
2689302b15bdSmrg        for lib in $libs; do
2690302b15bdSmrg	  sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
2691302b15bdSmrg	    > $tmpdir/tmp-la
2692302b15bdSmrg	  mv -f $tmpdir/tmp-la $lib
2693302b15bdSmrg	done
2694302b15bdSmrg        ${RM}r "$tmpdir"
2695302b15bdSmrg      fi
2696302b15bdSmrg    fi
2697b85037dbSmrg
2698302b15bdSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2699b85037dbSmrg      for libdir in $libdirs; do
2700b85037dbSmrg	if test -n "$finish_cmds"; then
2701b85037dbSmrg	  # Do each command in the finish commands.
2702b85037dbSmrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
2703b85037dbSmrg'"$cmd"'"'
2704b85037dbSmrg	fi
2705b85037dbSmrg	if test -n "$finish_eval"; then
2706b85037dbSmrg	  # Do the single finish_eval.
2707b85037dbSmrg	  eval cmds=\"$finish_eval\"
2708302b15bdSmrg	  $opt_dry_run || eval "$cmds" || func_append admincmds "
2709b85037dbSmrg       $cmds"
2710b85037dbSmrg	fi
2711b85037dbSmrg      done
2712b85037dbSmrg    fi
2713b85037dbSmrg
2714b85037dbSmrg    # Exit here if they wanted silent mode.
2715b85037dbSmrg    $opt_silent && exit $EXIT_SUCCESS
2716b85037dbSmrg
2717302b15bdSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2718302b15bdSmrg      echo "----------------------------------------------------------------------"
2719302b15bdSmrg      echo "Libraries have been installed in:"
2720302b15bdSmrg      for libdir in $libdirs; do
2721302b15bdSmrg	$ECHO "   $libdir"
2722302b15bdSmrg      done
2723302b15bdSmrg      echo
2724302b15bdSmrg      echo "If you ever happen to want to link against installed libraries"
2725302b15bdSmrg      echo "in a given directory, LIBDIR, you must either use libtool, and"
2726302b15bdSmrg      echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
2727302b15bdSmrg      echo "flag during linking and do at least one of the following:"
2728302b15bdSmrg      if test -n "$shlibpath_var"; then
2729302b15bdSmrg	echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
2730302b15bdSmrg	echo "     during execution"
2731302b15bdSmrg      fi
2732302b15bdSmrg      if test -n "$runpath_var"; then
2733302b15bdSmrg	echo "   - add LIBDIR to the \`$runpath_var' environment variable"
2734302b15bdSmrg	echo "     during linking"
2735302b15bdSmrg      fi
2736302b15bdSmrg      if test -n "$hardcode_libdir_flag_spec"; then
2737302b15bdSmrg	libdir=LIBDIR
2738302b15bdSmrg	eval flag=\"$hardcode_libdir_flag_spec\"
2739b85037dbSmrg
2740302b15bdSmrg	$ECHO "   - use the \`$flag' linker flag"
2741302b15bdSmrg      fi
2742302b15bdSmrg      if test -n "$admincmds"; then
2743302b15bdSmrg	$ECHO "   - have your system administrator run these commands:$admincmds"
2744302b15bdSmrg      fi
2745302b15bdSmrg      if test -f /etc/ld.so.conf; then
2746302b15bdSmrg	echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
2747302b15bdSmrg      fi
2748302b15bdSmrg      echo
2749b85037dbSmrg
2750302b15bdSmrg      echo "See any operating system documentation about shared libraries for"
2751302b15bdSmrg      case $host in
2752302b15bdSmrg	solaris2.[6789]|solaris2.1[0-9])
2753302b15bdSmrg	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
2754302b15bdSmrg	  echo "pages."
2755302b15bdSmrg	  ;;
2756302b15bdSmrg	*)
2757302b15bdSmrg	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
2758302b15bdSmrg	  ;;
2759302b15bdSmrg      esac
2760302b15bdSmrg      echo "----------------------------------------------------------------------"
2761302b15bdSmrg    fi
2762b85037dbSmrg    exit $EXIT_SUCCESS
2763b85037dbSmrg}
2764b85037dbSmrg
2765302b15bdSmrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"}
2766b85037dbSmrg
2767b85037dbSmrg
2768b85037dbSmrg# func_mode_install arg...
2769b85037dbSmrgfunc_mode_install ()
2770b85037dbSmrg{
2771b85037dbSmrg    $opt_debug
2772b85037dbSmrg    # There may be an optional sh(1) argument at the beginning of
2773b85037dbSmrg    # install_prog (especially on Windows NT).
2774b85037dbSmrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
2775b85037dbSmrg       # Allow the use of GNU shtool's install command.
2776b85037dbSmrg       case $nonopt in *shtool*) :;; *) false;; esac; then
2777b85037dbSmrg      # Aesthetically quote it.
2778b85037dbSmrg      func_quote_for_eval "$nonopt"
2779b85037dbSmrg      install_prog="$func_quote_for_eval_result "
2780b85037dbSmrg      arg=$1
2781b85037dbSmrg      shift
2782b85037dbSmrg    else
2783b85037dbSmrg      install_prog=
2784b85037dbSmrg      arg=$nonopt
2785b85037dbSmrg    fi
2786b85037dbSmrg
2787b85037dbSmrg    # The real first argument should be the name of the installation program.
2788b85037dbSmrg    # Aesthetically quote it.
2789b85037dbSmrg    func_quote_for_eval "$arg"
2790302b15bdSmrg    func_append install_prog "$func_quote_for_eval_result"
2791b85037dbSmrg    install_shared_prog=$install_prog
2792b85037dbSmrg    case " $install_prog " in
2793b85037dbSmrg      *[\\\ /]cp\ *) install_cp=: ;;
2794b85037dbSmrg      *) install_cp=false ;;
2795b85037dbSmrg    esac
2796b85037dbSmrg
2797b85037dbSmrg    # We need to accept at least all the BSD install flags.
2798b85037dbSmrg    dest=
2799b85037dbSmrg    files=
2800b85037dbSmrg    opts=
2801b85037dbSmrg    prev=
2802b85037dbSmrg    install_type=
2803b85037dbSmrg    isdir=no
2804b85037dbSmrg    stripme=
2805b85037dbSmrg    no_mode=:
2806b85037dbSmrg    for arg
2807b85037dbSmrg    do
2808b85037dbSmrg      arg2=
2809b85037dbSmrg      if test -n "$dest"; then
2810302b15bdSmrg	func_append files " $dest"
2811b85037dbSmrg	dest=$arg
2812b85037dbSmrg	continue
2813b85037dbSmrg      fi
2814b85037dbSmrg
2815b85037dbSmrg      case $arg in
2816b85037dbSmrg      -d) isdir=yes ;;
2817b85037dbSmrg      -f)
2818b85037dbSmrg	if $install_cp; then :; else
2819b85037dbSmrg	  prev=$arg
2820b85037dbSmrg	fi
2821b85037dbSmrg	;;
2822b85037dbSmrg      -g | -m | -o)
2823b85037dbSmrg	prev=$arg
2824b85037dbSmrg	;;
2825b85037dbSmrg      -s)
2826b85037dbSmrg	stripme=" -s"
2827b85037dbSmrg	continue
2828b85037dbSmrg	;;
2829b85037dbSmrg      -*)
2830b85037dbSmrg	;;
2831b85037dbSmrg      *)
2832b85037dbSmrg	# If the previous option needed an argument, then skip it.
2833b85037dbSmrg	if test -n "$prev"; then
2834b85037dbSmrg	  if test "x$prev" = x-m && test -n "$install_override_mode"; then
2835b85037dbSmrg	    arg2=$install_override_mode
2836b85037dbSmrg	    no_mode=false
2837b85037dbSmrg	  fi
2838b85037dbSmrg	  prev=
2839b85037dbSmrg	else
2840b85037dbSmrg	  dest=$arg
2841b85037dbSmrg	  continue
2842b85037dbSmrg	fi
2843b85037dbSmrg	;;
2844b85037dbSmrg      esac
2845b85037dbSmrg
2846b85037dbSmrg      # Aesthetically quote the argument.
2847b85037dbSmrg      func_quote_for_eval "$arg"
2848302b15bdSmrg      func_append install_prog " $func_quote_for_eval_result"
2849b85037dbSmrg      if test -n "$arg2"; then
2850b85037dbSmrg	func_quote_for_eval "$arg2"
2851b85037dbSmrg      fi
2852302b15bdSmrg      func_append install_shared_prog " $func_quote_for_eval_result"
2853b85037dbSmrg    done
2854b85037dbSmrg
2855b85037dbSmrg    test -z "$install_prog" && \
2856b85037dbSmrg      func_fatal_help "you must specify an install program"
2857b85037dbSmrg
2858b85037dbSmrg    test -n "$prev" && \
2859b85037dbSmrg      func_fatal_help "the \`$prev' option requires an argument"
2860b85037dbSmrg
2861b85037dbSmrg    if test -n "$install_override_mode" && $no_mode; then
2862b85037dbSmrg      if $install_cp; then :; else
2863b85037dbSmrg	func_quote_for_eval "$install_override_mode"
2864302b15bdSmrg	func_append install_shared_prog " -m $func_quote_for_eval_result"
2865b85037dbSmrg      fi
2866b85037dbSmrg    fi
2867b85037dbSmrg
2868b85037dbSmrg    if test -z "$files"; then
2869b85037dbSmrg      if test -z "$dest"; then
2870b85037dbSmrg	func_fatal_help "no file or destination specified"
2871b85037dbSmrg      else
2872b85037dbSmrg	func_fatal_help "you must specify a destination"
2873b85037dbSmrg      fi
2874b85037dbSmrg    fi
2875b85037dbSmrg
2876b85037dbSmrg    # Strip any trailing slash from the destination.
2877b85037dbSmrg    func_stripname '' '/' "$dest"
2878b85037dbSmrg    dest=$func_stripname_result
2879b85037dbSmrg
2880b85037dbSmrg    # Check to see that the destination is a directory.
2881b85037dbSmrg    test -d "$dest" && isdir=yes
2882b85037dbSmrg    if test "$isdir" = yes; then
2883b85037dbSmrg      destdir="$dest"
2884b85037dbSmrg      destname=
2885b85037dbSmrg    else
2886b85037dbSmrg      func_dirname_and_basename "$dest" "" "."
2887b85037dbSmrg      destdir="$func_dirname_result"
2888b85037dbSmrg      destname="$func_basename_result"
2889b85037dbSmrg
2890b85037dbSmrg      # Not a directory, so check to see that there is only one file specified.
2891b85037dbSmrg      set dummy $files; shift
2892b85037dbSmrg      test "$#" -gt 1 && \
2893b85037dbSmrg	func_fatal_help "\`$dest' is not a directory"
2894b85037dbSmrg    fi
2895b85037dbSmrg    case $destdir in
2896b85037dbSmrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
2897b85037dbSmrg    *)
2898b85037dbSmrg      for file in $files; do
2899b85037dbSmrg	case $file in
2900b85037dbSmrg	*.lo) ;;
2901b85037dbSmrg	*)
2902b85037dbSmrg	  func_fatal_help "\`$destdir' must be an absolute directory name"
2903b85037dbSmrg	  ;;
2904b85037dbSmrg	esac
2905b85037dbSmrg      done
2906b85037dbSmrg      ;;
2907b85037dbSmrg    esac
2908b85037dbSmrg
2909b85037dbSmrg    # This variable tells wrapper scripts just to set variables rather
2910b85037dbSmrg    # than running their programs.
2911b85037dbSmrg    libtool_install_magic="$magic"
2912b85037dbSmrg
2913b85037dbSmrg    staticlibs=
2914b85037dbSmrg    future_libdirs=
2915b85037dbSmrg    current_libdirs=
2916b85037dbSmrg    for file in $files; do
2917b85037dbSmrg
2918b85037dbSmrg      # Do each installation.
2919b85037dbSmrg      case $file in
2920b85037dbSmrg      *.$libext)
2921b85037dbSmrg	# Do the static libraries later.
2922302b15bdSmrg	func_append staticlibs " $file"
2923b85037dbSmrg	;;
2924b85037dbSmrg
2925b85037dbSmrg      *.la)
2926302b15bdSmrg	func_resolve_sysroot "$file"
2927302b15bdSmrg	file=$func_resolve_sysroot_result
2928302b15bdSmrg
2929b85037dbSmrg	# Check to see that this really is a libtool archive.
2930b85037dbSmrg	func_lalib_unsafe_p "$file" \
2931b85037dbSmrg	  || func_fatal_help "\`$file' is not a valid libtool archive"
2932b85037dbSmrg
2933b85037dbSmrg	library_names=
2934b85037dbSmrg	old_library=
2935b85037dbSmrg	relink_command=
2936b85037dbSmrg	func_source "$file"
2937b85037dbSmrg
2938b85037dbSmrg	# Add the libdir to current_libdirs if it is the destination.
2939b85037dbSmrg	if test "X$destdir" = "X$libdir"; then
2940b85037dbSmrg	  case "$current_libdirs " in
2941b85037dbSmrg	  *" $libdir "*) ;;
2942302b15bdSmrg	  *) func_append current_libdirs " $libdir" ;;
2943b85037dbSmrg	  esac
2944b85037dbSmrg	else
2945b85037dbSmrg	  # Note the libdir as a future libdir.
2946b85037dbSmrg	  case "$future_libdirs " in
2947b85037dbSmrg	  *" $libdir "*) ;;
2948302b15bdSmrg	  *) func_append future_libdirs " $libdir" ;;
2949b85037dbSmrg	  esac
2950b85037dbSmrg	fi
2951b85037dbSmrg
2952b85037dbSmrg	func_dirname "$file" "/" ""
2953b85037dbSmrg	dir="$func_dirname_result"
2954302b15bdSmrg	func_append dir "$objdir"
2955b85037dbSmrg
2956b85037dbSmrg	if test -n "$relink_command"; then
2957b85037dbSmrg	  # Determine the prefix the user has applied to our future dir.
2958b85037dbSmrg	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
2959b85037dbSmrg
2960b85037dbSmrg	  # Don't allow the user to place us outside of our expected
2961b85037dbSmrg	  # location b/c this prevents finding dependent libraries that
2962b85037dbSmrg	  # are installed to the same prefix.
2963b85037dbSmrg	  # At present, this check doesn't affect windows .dll's that
2964b85037dbSmrg	  # are installed into $libdir/../bin (currently, that works fine)
2965b85037dbSmrg	  # but it's something to keep an eye on.
2966b85037dbSmrg	  test "$inst_prefix_dir" = "$destdir" && \
2967b85037dbSmrg	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
2968b85037dbSmrg
2969b85037dbSmrg	  if test -n "$inst_prefix_dir"; then
2970b85037dbSmrg	    # Stick the inst_prefix_dir data into the link command.
2971b85037dbSmrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
2972b85037dbSmrg	  else
2973b85037dbSmrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
2974b85037dbSmrg	  fi
2975b85037dbSmrg
2976b85037dbSmrg	  func_warning "relinking \`$file'"
2977b85037dbSmrg	  func_show_eval "$relink_command" \
2978b85037dbSmrg	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
2979b85037dbSmrg	fi
2980b85037dbSmrg
2981b85037dbSmrg	# See the names of the shared library.
2982b85037dbSmrg	set dummy $library_names; shift
2983b85037dbSmrg	if test -n "$1"; then
2984b85037dbSmrg	  realname="$1"
2985b85037dbSmrg	  shift
2986b85037dbSmrg
2987b85037dbSmrg	  srcname="$realname"
2988b85037dbSmrg	  test -n "$relink_command" && srcname="$realname"T
2989b85037dbSmrg
2990b85037dbSmrg	  # Install the shared library and build the symlinks.
2991b85037dbSmrg	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
2992b85037dbSmrg	      'exit $?'
2993b85037dbSmrg	  tstripme="$stripme"
2994b85037dbSmrg	  case $host_os in
2995b85037dbSmrg	  cygwin* | mingw* | pw32* | cegcc*)
2996b85037dbSmrg	    case $realname in
2997b85037dbSmrg	    *.dll.a)
2998b85037dbSmrg	      tstripme=""
2999b85037dbSmrg	      ;;
3000b85037dbSmrg	    esac
3001b85037dbSmrg	    ;;
3002b85037dbSmrg	  esac
3003b85037dbSmrg	  if test -n "$tstripme" && test -n "$striplib"; then
3004b85037dbSmrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
3005b85037dbSmrg	  fi
3006b85037dbSmrg
3007b85037dbSmrg	  if test "$#" -gt 0; then
3008b85037dbSmrg	    # Delete the old symlinks, and create new ones.
3009b85037dbSmrg	    # Try `ln -sf' first, because the `ln' binary might depend on
3010b85037dbSmrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
3011b85037dbSmrg	    # so we also need to try rm && ln -s.
3012b85037dbSmrg	    for linkname
3013b85037dbSmrg	    do
3014b85037dbSmrg	      test "$linkname" != "$realname" \
3015b85037dbSmrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
3016b85037dbSmrg	    done
3017b85037dbSmrg	  fi
3018b85037dbSmrg
3019b85037dbSmrg	  # Do each command in the postinstall commands.
3020b85037dbSmrg	  lib="$destdir/$realname"
3021b85037dbSmrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
3022b85037dbSmrg	fi
3023b85037dbSmrg
3024b85037dbSmrg	# Install the pseudo-library for information purposes.
3025b85037dbSmrg	func_basename "$file"
3026b85037dbSmrg	name="$func_basename_result"
3027b85037dbSmrg	instname="$dir/$name"i
3028b85037dbSmrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
3029b85037dbSmrg
3030b85037dbSmrg	# Maybe install the static library, too.
3031302b15bdSmrg	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
3032b85037dbSmrg	;;
3033b85037dbSmrg
3034b85037dbSmrg      *.lo)
3035b85037dbSmrg	# Install (i.e. copy) a libtool object.
3036b85037dbSmrg
3037b85037dbSmrg	# Figure out destination file name, if it wasn't already specified.
3038b85037dbSmrg	if test -n "$destname"; then
3039b85037dbSmrg	  destfile="$destdir/$destname"
3040b85037dbSmrg	else
3041b85037dbSmrg	  func_basename "$file"
3042b85037dbSmrg	  destfile="$func_basename_result"
3043b85037dbSmrg	  destfile="$destdir/$destfile"
3044b85037dbSmrg	fi
3045b85037dbSmrg
3046b85037dbSmrg	# Deduce the name of the destination old-style object file.
3047b85037dbSmrg	case $destfile in
3048b85037dbSmrg	*.lo)
3049b85037dbSmrg	  func_lo2o "$destfile"
3050b85037dbSmrg	  staticdest=$func_lo2o_result
3051b85037dbSmrg	  ;;
3052b85037dbSmrg	*.$objext)
3053b85037dbSmrg	  staticdest="$destfile"
3054b85037dbSmrg	  destfile=
3055b85037dbSmrg	  ;;
3056b85037dbSmrg	*)
3057b85037dbSmrg	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
3058b85037dbSmrg	  ;;
3059b85037dbSmrg	esac
3060b85037dbSmrg
3061b85037dbSmrg	# Install the libtool object if requested.
3062b85037dbSmrg	test -n "$destfile" && \
3063b85037dbSmrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
3064b85037dbSmrg
3065b85037dbSmrg	# Install the old object if enabled.
3066b85037dbSmrg	if test "$build_old_libs" = yes; then
3067b85037dbSmrg	  # Deduce the name of the old-style object file.
3068b85037dbSmrg	  func_lo2o "$file"
3069b85037dbSmrg	  staticobj=$func_lo2o_result
3070b85037dbSmrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
3071b85037dbSmrg	fi
3072b85037dbSmrg	exit $EXIT_SUCCESS
3073b85037dbSmrg	;;
3074b85037dbSmrg
3075b85037dbSmrg      *)
3076b85037dbSmrg	# Figure out destination file name, if it wasn't already specified.
3077b85037dbSmrg	if test -n "$destname"; then
3078b85037dbSmrg	  destfile="$destdir/$destname"
3079b85037dbSmrg	else
3080b85037dbSmrg	  func_basename "$file"
3081b85037dbSmrg	  destfile="$func_basename_result"
3082b85037dbSmrg	  destfile="$destdir/$destfile"
3083b85037dbSmrg	fi
3084b85037dbSmrg
3085b85037dbSmrg	# If the file is missing, and there is a .exe on the end, strip it
3086b85037dbSmrg	# because it is most likely a libtool script we actually want to
3087b85037dbSmrg	# install
3088b85037dbSmrg	stripped_ext=""
3089b85037dbSmrg	case $file in
3090b85037dbSmrg	  *.exe)
3091b85037dbSmrg	    if test ! -f "$file"; then
3092b85037dbSmrg	      func_stripname '' '.exe' "$file"
3093b85037dbSmrg	      file=$func_stripname_result
3094b85037dbSmrg	      stripped_ext=".exe"
3095b85037dbSmrg	    fi
3096b85037dbSmrg	    ;;
3097b85037dbSmrg	esac
3098b85037dbSmrg
3099b85037dbSmrg	# Do a test to see if this is really a libtool program.
3100b85037dbSmrg	case $host in
3101b85037dbSmrg	*cygwin* | *mingw*)
3102b85037dbSmrg	    if func_ltwrapper_executable_p "$file"; then
3103b85037dbSmrg	      func_ltwrapper_scriptname "$file"
3104b85037dbSmrg	      wrapper=$func_ltwrapper_scriptname_result
3105b85037dbSmrg	    else
3106b85037dbSmrg	      func_stripname '' '.exe' "$file"
3107b85037dbSmrg	      wrapper=$func_stripname_result
3108b85037dbSmrg	    fi
3109b85037dbSmrg	    ;;
3110b85037dbSmrg	*)
3111b85037dbSmrg	    wrapper=$file
3112b85037dbSmrg	    ;;
3113b85037dbSmrg	esac
3114b85037dbSmrg	if func_ltwrapper_script_p "$wrapper"; then
3115b85037dbSmrg	  notinst_deplibs=
3116b85037dbSmrg	  relink_command=
3117b85037dbSmrg
3118b85037dbSmrg	  func_source "$wrapper"
3119b85037dbSmrg
3120b85037dbSmrg	  # Check the variables that should have been set.
3121b85037dbSmrg	  test -z "$generated_by_libtool_version" && \
3122b85037dbSmrg	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
3123b85037dbSmrg
3124b85037dbSmrg	  finalize=yes
3125b85037dbSmrg	  for lib in $notinst_deplibs; do
3126b85037dbSmrg	    # Check to see that each library is installed.
3127b85037dbSmrg	    libdir=
3128b85037dbSmrg	    if test -f "$lib"; then
3129b85037dbSmrg	      func_source "$lib"
3130b85037dbSmrg	    fi
3131b85037dbSmrg	    libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
3132b85037dbSmrg	    if test -n "$libdir" && test ! -f "$libfile"; then
3133b85037dbSmrg	      func_warning "\`$lib' has not been installed in \`$libdir'"
3134b85037dbSmrg	      finalize=no
3135b85037dbSmrg	    fi
3136b85037dbSmrg	  done
3137b85037dbSmrg
3138b85037dbSmrg	  relink_command=
3139b85037dbSmrg	  func_source "$wrapper"
3140b85037dbSmrg
3141b85037dbSmrg	  outputname=
3142b85037dbSmrg	  if test "$fast_install" = no && test -n "$relink_command"; then
3143b85037dbSmrg	    $opt_dry_run || {
3144b85037dbSmrg	      if test "$finalize" = yes; then
3145b85037dbSmrg	        tmpdir=`func_mktempdir`
3146b85037dbSmrg		func_basename "$file$stripped_ext"
3147b85037dbSmrg		file="$func_basename_result"
3148b85037dbSmrg	        outputname="$tmpdir/$file"
3149b85037dbSmrg	        # Replace the output file specification.
3150b85037dbSmrg	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
3151b85037dbSmrg
3152b85037dbSmrg	        $opt_silent || {
3153b85037dbSmrg	          func_quote_for_expand "$relink_command"
3154b85037dbSmrg		  eval "func_echo $func_quote_for_expand_result"
3155b85037dbSmrg	        }
3156b85037dbSmrg	        if eval "$relink_command"; then :
3157b85037dbSmrg	          else
3158b85037dbSmrg		  func_error "error: relink \`$file' with the above command before installing it"
3159b85037dbSmrg		  $opt_dry_run || ${RM}r "$tmpdir"
3160b85037dbSmrg		  continue
3161b85037dbSmrg	        fi
3162b85037dbSmrg	        file="$outputname"
3163b85037dbSmrg	      else
3164b85037dbSmrg	        func_warning "cannot relink \`$file'"
3165b85037dbSmrg	      fi
3166b85037dbSmrg	    }
3167b85037dbSmrg	  else
3168b85037dbSmrg	    # Install the binary that we compiled earlier.
3169b85037dbSmrg	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
3170b85037dbSmrg	  fi
3171b85037dbSmrg	fi
3172b85037dbSmrg
3173b85037dbSmrg	# remove .exe since cygwin /usr/bin/install will append another
3174b85037dbSmrg	# one anyway
3175b85037dbSmrg	case $install_prog,$host in
3176b85037dbSmrg	*/usr/bin/install*,*cygwin*)
3177b85037dbSmrg	  case $file:$destfile in
3178b85037dbSmrg	  *.exe:*.exe)
3179b85037dbSmrg	    # this is ok
3180b85037dbSmrg	    ;;
3181b85037dbSmrg	  *.exe:*)
3182b85037dbSmrg	    destfile=$destfile.exe
3183b85037dbSmrg	    ;;
3184b85037dbSmrg	  *:*.exe)
3185b85037dbSmrg	    func_stripname '' '.exe' "$destfile"
3186b85037dbSmrg	    destfile=$func_stripname_result
3187b85037dbSmrg	    ;;
3188b85037dbSmrg	  esac
3189b85037dbSmrg	  ;;
3190b85037dbSmrg	esac
3191b85037dbSmrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
3192b85037dbSmrg	$opt_dry_run || if test -n "$outputname"; then
3193b85037dbSmrg	  ${RM}r "$tmpdir"
3194b85037dbSmrg	fi
3195b85037dbSmrg	;;
3196b85037dbSmrg      esac
3197b85037dbSmrg    done
3198b85037dbSmrg
3199b85037dbSmrg    for file in $staticlibs; do
3200b85037dbSmrg      func_basename "$file"
3201b85037dbSmrg      name="$func_basename_result"
3202b85037dbSmrg
3203b85037dbSmrg      # Set up the ranlib parameters.
3204b85037dbSmrg      oldlib="$destdir/$name"
320528515619Smrg      func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
320628515619Smrg      tool_oldlib=$func_to_tool_file_result
3207b85037dbSmrg
3208b85037dbSmrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
3209b85037dbSmrg
3210b85037dbSmrg      if test -n "$stripme" && test -n "$old_striplib"; then
321128515619Smrg	func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
3212b85037dbSmrg      fi
3213b85037dbSmrg
3214b85037dbSmrg      # Do each command in the postinstall commands.
3215b85037dbSmrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
3216b85037dbSmrg    done
3217b85037dbSmrg
3218b85037dbSmrg    test -n "$future_libdirs" && \
3219b85037dbSmrg      func_warning "remember to run \`$progname --finish$future_libdirs'"
3220b85037dbSmrg
3221b85037dbSmrg    if test -n "$current_libdirs"; then
3222b85037dbSmrg      # Maybe just do a dry run.
3223b85037dbSmrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
3224b85037dbSmrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
3225b85037dbSmrg    else
3226b85037dbSmrg      exit $EXIT_SUCCESS
3227b85037dbSmrg    fi
3228b85037dbSmrg}
3229b85037dbSmrg
3230302b15bdSmrgtest "$opt_mode" = install && func_mode_install ${1+"$@"}
3231b85037dbSmrg
3232b85037dbSmrg
3233b85037dbSmrg# func_generate_dlsyms outputname originator pic_p
3234b85037dbSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with
3235b85037dbSmrg# a dlpreopen symbol table.
3236b85037dbSmrgfunc_generate_dlsyms ()
3237b85037dbSmrg{
3238b85037dbSmrg    $opt_debug
3239b85037dbSmrg    my_outputname="$1"
3240b85037dbSmrg    my_originator="$2"
3241b85037dbSmrg    my_pic_p="${3-no}"
3242b85037dbSmrg    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
3243b85037dbSmrg    my_dlsyms=
3244b85037dbSmrg
3245b85037dbSmrg    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
3246b85037dbSmrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
3247b85037dbSmrg	my_dlsyms="${my_outputname}S.c"
3248b85037dbSmrg      else
3249b85037dbSmrg	func_error "not configured to extract global symbols from dlpreopened files"
3250b85037dbSmrg      fi
3251b85037dbSmrg    fi
3252b85037dbSmrg
3253b85037dbSmrg    if test -n "$my_dlsyms"; then
3254b85037dbSmrg      case $my_dlsyms in
3255b85037dbSmrg      "") ;;
3256b85037dbSmrg      *.c)
3257b85037dbSmrg	# Discover the nlist of each of the dlfiles.
3258b85037dbSmrg	nlist="$output_objdir/${my_outputname}.nm"
3259b85037dbSmrg
3260b85037dbSmrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
3261b85037dbSmrg
3262b85037dbSmrg	# Parse the name list into a source file.
3263b85037dbSmrg	func_verbose "creating $output_objdir/$my_dlsyms"
3264b85037dbSmrg
3265b85037dbSmrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
3266b85037dbSmrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
3267b85037dbSmrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
3268b85037dbSmrg
3269b85037dbSmrg#ifdef __cplusplus
3270b85037dbSmrgextern \"C\" {
3271b85037dbSmrg#endif
3272b85037dbSmrg
3273b85037dbSmrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
3274b85037dbSmrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
3275b85037dbSmrg#endif
3276b85037dbSmrg
3277302b15bdSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
3278302b15bdSmrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
3279302b15bdSmrg/* DATA imports from DLLs on WIN32 con't be const, because runtime
3280302b15bdSmrg   relocations are performed -- see ld's documentation on pseudo-relocs.  */
3281302b15bdSmrg# define LT_DLSYM_CONST
3282302b15bdSmrg#elif defined(__osf__)
3283302b15bdSmrg/* This system does not cope well with relocations in const data.  */
3284302b15bdSmrg# define LT_DLSYM_CONST
3285302b15bdSmrg#else
3286302b15bdSmrg# define LT_DLSYM_CONST const
3287302b15bdSmrg#endif
3288302b15bdSmrg
3289b85037dbSmrg/* External symbol declarations for the compiler. */\
3290b85037dbSmrg"
3291b85037dbSmrg
3292b85037dbSmrg	if test "$dlself" = yes; then
3293b85037dbSmrg	  func_verbose "generating symbol list for \`$output'"
3294b85037dbSmrg
3295b85037dbSmrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
3296b85037dbSmrg
3297b85037dbSmrg	  # Add our own program objects to the symbol list.
3298b85037dbSmrg	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
3299b85037dbSmrg	  for progfile in $progfiles; do
3300302b15bdSmrg	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
3301302b15bdSmrg	    func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
3302302b15bdSmrg	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
3303b85037dbSmrg	  done
3304b85037dbSmrg
3305b85037dbSmrg	  if test -n "$exclude_expsyms"; then
3306b85037dbSmrg	    $opt_dry_run || {
3307b85037dbSmrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
3308b85037dbSmrg	      eval '$MV "$nlist"T "$nlist"'
3309b85037dbSmrg	    }
3310b85037dbSmrg	  fi
3311b85037dbSmrg
3312b85037dbSmrg	  if test -n "$export_symbols_regex"; then
3313b85037dbSmrg	    $opt_dry_run || {
3314b85037dbSmrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
3315b85037dbSmrg	      eval '$MV "$nlist"T "$nlist"'
3316b85037dbSmrg	    }
3317b85037dbSmrg	  fi
3318b85037dbSmrg
3319b85037dbSmrg	  # Prepare the list of exported symbols
3320b85037dbSmrg	  if test -z "$export_symbols"; then
3321b85037dbSmrg	    export_symbols="$output_objdir/$outputname.exp"
3322b85037dbSmrg	    $opt_dry_run || {
3323b85037dbSmrg	      $RM $export_symbols
3324b85037dbSmrg	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
3325b85037dbSmrg	      case $host in
3326b85037dbSmrg	      *cygwin* | *mingw* | *cegcc* )
3327b85037dbSmrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3328b85037dbSmrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
3329b85037dbSmrg	        ;;
3330b85037dbSmrg	      esac
3331b85037dbSmrg	    }
3332b85037dbSmrg	  else
3333b85037dbSmrg	    $opt_dry_run || {
3334b85037dbSmrg	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
3335b85037dbSmrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
3336b85037dbSmrg	      eval '$MV "$nlist"T "$nlist"'
3337b85037dbSmrg	      case $host in
3338b85037dbSmrg	        *cygwin* | *mingw* | *cegcc* )
3339b85037dbSmrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3340b85037dbSmrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
3341b85037dbSmrg	          ;;
3342b85037dbSmrg	      esac
3343b85037dbSmrg	    }
3344b85037dbSmrg	  fi
3345b85037dbSmrg	fi
3346b85037dbSmrg
3347b85037dbSmrg	for dlprefile in $dlprefiles; do
3348b85037dbSmrg	  func_verbose "extracting global C symbols from \`$dlprefile'"
3349b85037dbSmrg	  func_basename "$dlprefile"
3350b85037dbSmrg	  name="$func_basename_result"
3351302b15bdSmrg          case $host in
3352302b15bdSmrg	    *cygwin* | *mingw* | *cegcc* )
3353302b15bdSmrg	      # if an import library, we need to obtain dlname
3354302b15bdSmrg	      if func_win32_import_lib_p "$dlprefile"; then
3355302b15bdSmrg	        func_tr_sh "$dlprefile"
3356302b15bdSmrg	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
3357302b15bdSmrg	        dlprefile_dlbasename=""
3358302b15bdSmrg	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
3359302b15bdSmrg	          # Use subshell, to avoid clobbering current variable values
3360302b15bdSmrg	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
3361302b15bdSmrg	          if test -n "$dlprefile_dlname" ; then
3362302b15bdSmrg	            func_basename "$dlprefile_dlname"
3363302b15bdSmrg	            dlprefile_dlbasename="$func_basename_result"
3364302b15bdSmrg	          else
3365302b15bdSmrg	            # no lafile. user explicitly requested -dlpreopen <import library>.
3366302b15bdSmrg	            $sharedlib_from_linklib_cmd "$dlprefile"
3367302b15bdSmrg	            dlprefile_dlbasename=$sharedlib_from_linklib_result
3368302b15bdSmrg	          fi
3369302b15bdSmrg	        fi
3370302b15bdSmrg	        $opt_dry_run || {
3371302b15bdSmrg	          if test -n "$dlprefile_dlbasename" ; then
3372302b15bdSmrg	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
3373302b15bdSmrg	          else
3374302b15bdSmrg	            func_warning "Could not compute DLL name from $name"
3375302b15bdSmrg	            eval '$ECHO ": $name " >> "$nlist"'
3376302b15bdSmrg	          fi
3377302b15bdSmrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3378302b15bdSmrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
3379302b15bdSmrg	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
3380302b15bdSmrg	        }
3381302b15bdSmrg	      else # not an import lib
3382302b15bdSmrg	        $opt_dry_run || {
3383302b15bdSmrg	          eval '$ECHO ": $name " >> "$nlist"'
3384302b15bdSmrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3385302b15bdSmrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3386302b15bdSmrg	        }
3387302b15bdSmrg	      fi
3388302b15bdSmrg	    ;;
3389302b15bdSmrg	    *)
3390302b15bdSmrg	      $opt_dry_run || {
3391302b15bdSmrg	        eval '$ECHO ": $name " >> "$nlist"'
3392302b15bdSmrg	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3393302b15bdSmrg	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3394302b15bdSmrg	      }
3395302b15bdSmrg	    ;;
3396302b15bdSmrg          esac
3397b85037dbSmrg	done
3398b85037dbSmrg
3399b85037dbSmrg	$opt_dry_run || {
3400b85037dbSmrg	  # Make sure we have at least an empty file.
3401b85037dbSmrg	  test -f "$nlist" || : > "$nlist"
3402b85037dbSmrg
3403b85037dbSmrg	  if test -n "$exclude_expsyms"; then
3404b85037dbSmrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
3405b85037dbSmrg	    $MV "$nlist"T "$nlist"
3406b85037dbSmrg	  fi
3407b85037dbSmrg
3408b85037dbSmrg	  # Try sorting and uniquifying the output.
3409b85037dbSmrg	  if $GREP -v "^: " < "$nlist" |
3410b85037dbSmrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
3411b85037dbSmrg		sort -k 3
3412b85037dbSmrg	      else
3413b85037dbSmrg		sort +2
3414b85037dbSmrg	      fi |
3415b85037dbSmrg	      uniq > "$nlist"S; then
3416b85037dbSmrg	    :
3417b85037dbSmrg	  else
3418b85037dbSmrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
3419b85037dbSmrg	  fi
3420b85037dbSmrg
3421b85037dbSmrg	  if test -f "$nlist"S; then
3422b85037dbSmrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
3423b85037dbSmrg	  else
3424b85037dbSmrg	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
3425b85037dbSmrg	  fi
3426b85037dbSmrg
3427b85037dbSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
3428b85037dbSmrg
3429b85037dbSmrg/* The mapping between symbol names and symbols.  */
3430b85037dbSmrgtypedef struct {
3431b85037dbSmrg  const char *name;
3432b85037dbSmrg  void *address;
3433b85037dbSmrg} lt_dlsymlist;
3434302b15bdSmrgextern LT_DLSYM_CONST lt_dlsymlist
3435b85037dbSmrglt_${my_prefix}_LTX_preloaded_symbols[];
3436302b15bdSmrgLT_DLSYM_CONST lt_dlsymlist
3437b85037dbSmrglt_${my_prefix}_LTX_preloaded_symbols[] =
3438b85037dbSmrg{\
3439b85037dbSmrg  { \"$my_originator\", (void *) 0 },"
3440b85037dbSmrg
3441b85037dbSmrg	  case $need_lib_prefix in
3442b85037dbSmrg	  no)
3443b85037dbSmrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
3444b85037dbSmrg	    ;;
3445b85037dbSmrg	  *)
3446b85037dbSmrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
3447b85037dbSmrg	    ;;
3448b85037dbSmrg	  esac
3449b85037dbSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
3450b85037dbSmrg  {0, (void *) 0}
3451b85037dbSmrg};
3452b85037dbSmrg
3453b85037dbSmrg/* This works around a problem in FreeBSD linker */
3454b85037dbSmrg#ifdef FREEBSD_WORKAROUND
3455b85037dbSmrgstatic const void *lt_preloaded_setup() {
3456b85037dbSmrg  return lt_${my_prefix}_LTX_preloaded_symbols;
3457b85037dbSmrg}
3458b85037dbSmrg#endif
3459b85037dbSmrg
3460b85037dbSmrg#ifdef __cplusplus
3461b85037dbSmrg}
3462b85037dbSmrg#endif\
3463b85037dbSmrg"
3464b85037dbSmrg	} # !$opt_dry_run
3465b85037dbSmrg
3466b85037dbSmrg	pic_flag_for_symtable=
3467b85037dbSmrg	case "$compile_command " in
3468b85037dbSmrg	*" -static "*) ;;
3469b85037dbSmrg	*)
3470b85037dbSmrg	  case $host in
3471b85037dbSmrg	  # compiling the symbol table file with pic_flag works around
3472b85037dbSmrg	  # a FreeBSD bug that causes programs to crash when -lm is
3473b85037dbSmrg	  # linked before any other PIC object.  But we must not use
3474b85037dbSmrg	  # pic_flag when linking with -static.  The problem exists in
3475b85037dbSmrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
347628515619Smrg	  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
3477b85037dbSmrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
3478b85037dbSmrg	  *-*-hpux*)
3479b85037dbSmrg	    pic_flag_for_symtable=" $pic_flag"  ;;
3480b85037dbSmrg	  *)
3481b85037dbSmrg	    if test "X$my_pic_p" != Xno; then
3482b85037dbSmrg	      pic_flag_for_symtable=" $pic_flag"
3483b85037dbSmrg	    fi
3484b85037dbSmrg	    ;;
3485b85037dbSmrg	  esac
3486b85037dbSmrg	  ;;
3487b85037dbSmrg	esac
3488b85037dbSmrg	symtab_cflags=
3489b85037dbSmrg	for arg in $LTCFLAGS; do
3490b85037dbSmrg	  case $arg in
3491b85037dbSmrg	  -pie | -fpie | -fPIE) ;;
3492302b15bdSmrg	  *) func_append symtab_cflags " $arg" ;;
3493b85037dbSmrg	  esac
3494b85037dbSmrg	done
3495b85037dbSmrg
3496b85037dbSmrg	# Now compile the dynamic symbol file.
3497b85037dbSmrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
3498b85037dbSmrg
3499b85037dbSmrg	# Clean up the generated files.
3500b85037dbSmrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
3501b85037dbSmrg
3502b85037dbSmrg	# Transform the symbol file into the correct name.
3503b85037dbSmrg	symfileobj="$output_objdir/${my_outputname}S.$objext"
3504b85037dbSmrg	case $host in
3505b85037dbSmrg	*cygwin* | *mingw* | *cegcc* )
3506b85037dbSmrg	  if test -f "$output_objdir/$my_outputname.def"; then
3507b85037dbSmrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3508b85037dbSmrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3509b85037dbSmrg	  else
3510b85037dbSmrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3511b85037dbSmrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3512b85037dbSmrg	  fi
3513b85037dbSmrg	  ;;
3514b85037dbSmrg	*)
3515b85037dbSmrg	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3516b85037dbSmrg	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3517b85037dbSmrg	  ;;
3518b85037dbSmrg	esac
3519b85037dbSmrg	;;
3520b85037dbSmrg      *)
3521b85037dbSmrg	func_fatal_error "unknown suffix for \`$my_dlsyms'"
3522b85037dbSmrg	;;
3523b85037dbSmrg      esac
3524b85037dbSmrg    else
3525b85037dbSmrg      # We keep going just in case the user didn't refer to
3526b85037dbSmrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
3527b85037dbSmrg      # really was required.
3528b85037dbSmrg
3529b85037dbSmrg      # Nullify the symbol file.
3530b85037dbSmrg      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
3531b85037dbSmrg      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
3532b85037dbSmrg    fi
3533b85037dbSmrg}
3534b85037dbSmrg
3535b85037dbSmrg# func_win32_libid arg
3536b85037dbSmrg# return the library type of file 'arg'
3537b85037dbSmrg#
3538b85037dbSmrg# Need a lot of goo to handle *both* DLLs and import libs
3539b85037dbSmrg# Has to be a shell function in order to 'eat' the argument
3540b85037dbSmrg# that is supplied when $file_magic_command is called.
3541b85037dbSmrg# Despite the name, also deal with 64 bit binaries.
3542b85037dbSmrgfunc_win32_libid ()
3543b85037dbSmrg{
3544b85037dbSmrg  $opt_debug
3545b85037dbSmrg  win32_libid_type="unknown"
3546b85037dbSmrg  win32_fileres=`file -L $1 2>/dev/null`
3547b85037dbSmrg  case $win32_fileres in
3548b85037dbSmrg  *ar\ archive\ import\ library*) # definitely import
3549b85037dbSmrg    win32_libid_type="x86 archive import"
3550b85037dbSmrg    ;;
3551b85037dbSmrg  *ar\ archive*) # could be an import, or static
3552b85037dbSmrg    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
3553b85037dbSmrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
3554b85037dbSmrg       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
3555302b15bdSmrg      func_to_tool_file "$1" func_convert_file_msys_to_w32
3556302b15bdSmrg      win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
3557b85037dbSmrg	$SED -n -e '
3558b85037dbSmrg	    1,100{
3559b85037dbSmrg		/ I /{
3560b85037dbSmrg		    s,.*,import,
3561b85037dbSmrg		    p
3562b85037dbSmrg		    q
3563b85037dbSmrg		}
3564b85037dbSmrg	    }'`
3565b85037dbSmrg      case $win32_nmres in
3566b85037dbSmrg      import*)  win32_libid_type="x86 archive import";;
3567b85037dbSmrg      *)        win32_libid_type="x86 archive static";;
3568b85037dbSmrg      esac
3569b85037dbSmrg    fi
3570b85037dbSmrg    ;;
3571b85037dbSmrg  *DLL*)
3572b85037dbSmrg    win32_libid_type="x86 DLL"
3573b85037dbSmrg    ;;
3574b85037dbSmrg  *executable*) # but shell scripts are "executable" too...
3575b85037dbSmrg    case $win32_fileres in
3576b85037dbSmrg    *MS\ Windows\ PE\ Intel*)
3577b85037dbSmrg      win32_libid_type="x86 DLL"
3578b85037dbSmrg      ;;
3579b85037dbSmrg    esac
3580b85037dbSmrg    ;;
3581b85037dbSmrg  esac
3582b85037dbSmrg  $ECHO "$win32_libid_type"
3583b85037dbSmrg}
3584b85037dbSmrg
3585302b15bdSmrg# func_cygming_dll_for_implib ARG
3586302b15bdSmrg#
3587302b15bdSmrg# Platform-specific function to extract the
3588302b15bdSmrg# name of the DLL associated with the specified
3589302b15bdSmrg# import library ARG.
3590302b15bdSmrg# Invoked by eval'ing the libtool variable
3591302b15bdSmrg#    $sharedlib_from_linklib_cmd
3592302b15bdSmrg# Result is available in the variable
3593302b15bdSmrg#    $sharedlib_from_linklib_result
3594302b15bdSmrgfunc_cygming_dll_for_implib ()
3595302b15bdSmrg{
3596302b15bdSmrg  $opt_debug
3597302b15bdSmrg  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
3598302b15bdSmrg}
3599302b15bdSmrg
3600302b15bdSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
3601302b15bdSmrg#
3602302b15bdSmrg# The is the core of a fallback implementation of a
3603302b15bdSmrg# platform-specific function to extract the name of the
3604302b15bdSmrg# DLL associated with the specified import library LIBNAME.
3605302b15bdSmrg#
3606302b15bdSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending
3607302b15bdSmrg# on the platform and compiler that created the implib.
3608302b15bdSmrg#
3609302b15bdSmrg# Echos the name of the DLL associated with the
3610302b15bdSmrg# specified import library.
3611302b15bdSmrgfunc_cygming_dll_for_implib_fallback_core ()
3612302b15bdSmrg{
3613302b15bdSmrg  $opt_debug
3614302b15bdSmrg  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
3615302b15bdSmrg  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
3616302b15bdSmrg    $SED '/^Contents of section '"$match_literal"':/{
3617302b15bdSmrg      # Place marker at beginning of archive member dllname section
3618302b15bdSmrg      s/.*/====MARK====/
3619302b15bdSmrg      p
3620302b15bdSmrg      d
3621302b15bdSmrg    }
3622302b15bdSmrg    # These lines can sometimes be longer than 43 characters, but
3623302b15bdSmrg    # are always uninteresting
3624302b15bdSmrg    /:[	 ]*file format pe[i]\{,1\}-/d
3625302b15bdSmrg    /^In archive [^:]*:/d
3626302b15bdSmrg    # Ensure marker is printed
3627302b15bdSmrg    /^====MARK====/p
3628302b15bdSmrg    # Remove all lines with less than 43 characters
3629302b15bdSmrg    /^.\{43\}/!d
3630302b15bdSmrg    # From remaining lines, remove first 43 characters
3631302b15bdSmrg    s/^.\{43\}//' |
3632302b15bdSmrg    $SED -n '
3633302b15bdSmrg      # Join marker and all lines until next marker into a single line
3634302b15bdSmrg      /^====MARK====/ b para
3635302b15bdSmrg      H
3636302b15bdSmrg      $ b para
3637302b15bdSmrg      b
3638302b15bdSmrg      :para
3639302b15bdSmrg      x
3640302b15bdSmrg      s/\n//g
3641302b15bdSmrg      # Remove the marker
3642302b15bdSmrg      s/^====MARK====//
3643302b15bdSmrg      # Remove trailing dots and whitespace
3644302b15bdSmrg      s/[\. \t]*$//
3645302b15bdSmrg      # Print
3646302b15bdSmrg      /./p' |
3647302b15bdSmrg    # we now have a list, one entry per line, of the stringified
3648302b15bdSmrg    # contents of the appropriate section of all members of the
3649302b15bdSmrg    # archive which possess that section. Heuristic: eliminate
3650302b15bdSmrg    # all those which have a first or second character that is
3651302b15bdSmrg    # a '.' (that is, objdump's representation of an unprintable
3652302b15bdSmrg    # character.) This should work for all archives with less than
3653302b15bdSmrg    # 0x302f exports -- but will fail for DLLs whose name actually
3654302b15bdSmrg    # begins with a literal '.' or a single character followed by
3655302b15bdSmrg    # a '.'.
3656302b15bdSmrg    #
3657302b15bdSmrg    # Of those that remain, print the first one.
3658302b15bdSmrg    $SED -e '/^\./d;/^.\./d;q'
3659302b15bdSmrg}
3660302b15bdSmrg
3661302b15bdSmrg# func_cygming_gnu_implib_p ARG
3662302b15bdSmrg# This predicate returns with zero status (TRUE) if
3663302b15bdSmrg# ARG is a GNU/binutils-style import library. Returns
3664302b15bdSmrg# with nonzero status (FALSE) otherwise.
3665302b15bdSmrgfunc_cygming_gnu_implib_p ()
3666302b15bdSmrg{
3667302b15bdSmrg  $opt_debug
3668302b15bdSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
3669302b15bdSmrg  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)$'`
3670302b15bdSmrg  test -n "$func_cygming_gnu_implib_tmp"
3671302b15bdSmrg}
3672302b15bdSmrg
3673302b15bdSmrg# func_cygming_ms_implib_p ARG
3674302b15bdSmrg# This predicate returns with zero status (TRUE) if
3675302b15bdSmrg# ARG is an MS-style import library. Returns
3676302b15bdSmrg# with nonzero status (FALSE) otherwise.
3677302b15bdSmrgfunc_cygming_ms_implib_p ()
3678302b15bdSmrg{
3679302b15bdSmrg  $opt_debug
3680302b15bdSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
3681302b15bdSmrg  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
3682302b15bdSmrg  test -n "$func_cygming_ms_implib_tmp"
3683302b15bdSmrg}
3684302b15bdSmrg
3685302b15bdSmrg# func_cygming_dll_for_implib_fallback ARG
3686302b15bdSmrg# Platform-specific function to extract the
3687302b15bdSmrg# name of the DLL associated with the specified
3688302b15bdSmrg# import library ARG.
3689302b15bdSmrg#
3690302b15bdSmrg# This fallback implementation is for use when $DLLTOOL
3691302b15bdSmrg# does not support the --identify-strict option.
3692302b15bdSmrg# Invoked by eval'ing the libtool variable
3693302b15bdSmrg#    $sharedlib_from_linklib_cmd
3694302b15bdSmrg# Result is available in the variable
3695302b15bdSmrg#    $sharedlib_from_linklib_result
3696302b15bdSmrgfunc_cygming_dll_for_implib_fallback ()
3697302b15bdSmrg{
3698302b15bdSmrg  $opt_debug
3699302b15bdSmrg  if func_cygming_gnu_implib_p "$1" ; then
3700302b15bdSmrg    # binutils import library
3701302b15bdSmrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
3702302b15bdSmrg  elif func_cygming_ms_implib_p "$1" ; then
3703302b15bdSmrg    # ms-generated import library
3704302b15bdSmrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
3705302b15bdSmrg  else
3706302b15bdSmrg    # unknown
3707302b15bdSmrg    sharedlib_from_linklib_result=""
3708302b15bdSmrg  fi
3709302b15bdSmrg}
3710b85037dbSmrg
3711b85037dbSmrg
3712b85037dbSmrg# func_extract_an_archive dir oldlib
3713b85037dbSmrgfunc_extract_an_archive ()
3714b85037dbSmrg{
3715b85037dbSmrg    $opt_debug
3716b85037dbSmrg    f_ex_an_ar_dir="$1"; shift
3717b85037dbSmrg    f_ex_an_ar_oldlib="$1"
3718b85037dbSmrg    if test "$lock_old_archive_extraction" = yes; then
3719b85037dbSmrg      lockfile=$f_ex_an_ar_oldlib.lock
3720b85037dbSmrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
3721b85037dbSmrg	func_echo "Waiting for $lockfile to be removed"
3722b85037dbSmrg	sleep 2
3723b85037dbSmrg      done
3724b85037dbSmrg    fi
3725b85037dbSmrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
3726b85037dbSmrg		   'stat=$?; rm -f "$lockfile"; exit $stat'
3727b85037dbSmrg    if test "$lock_old_archive_extraction" = yes; then
3728b85037dbSmrg      $opt_dry_run || rm -f "$lockfile"
3729b85037dbSmrg    fi
3730b85037dbSmrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
3731b85037dbSmrg     :
3732b85037dbSmrg    else
3733b85037dbSmrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
3734b85037dbSmrg    fi
3735b85037dbSmrg}
3736b85037dbSmrg
3737b85037dbSmrg
3738b85037dbSmrg# func_extract_archives gentop oldlib ...
3739b85037dbSmrgfunc_extract_archives ()
3740b85037dbSmrg{
3741b85037dbSmrg    $opt_debug
3742b85037dbSmrg    my_gentop="$1"; shift
3743b85037dbSmrg    my_oldlibs=${1+"$@"}
3744b85037dbSmrg    my_oldobjs=""
3745b85037dbSmrg    my_xlib=""
3746b85037dbSmrg    my_xabs=""
3747b85037dbSmrg    my_xdir=""
3748b85037dbSmrg
3749b85037dbSmrg    for my_xlib in $my_oldlibs; do
3750b85037dbSmrg      # Extract the objects.
3751b85037dbSmrg      case $my_xlib in
3752b85037dbSmrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
3753b85037dbSmrg	*) my_xabs=`pwd`"/$my_xlib" ;;
3754b85037dbSmrg      esac
3755b85037dbSmrg      func_basename "$my_xlib"
3756b85037dbSmrg      my_xlib="$func_basename_result"
3757b85037dbSmrg      my_xlib_u=$my_xlib
3758b85037dbSmrg      while :; do
3759b85037dbSmrg        case " $extracted_archives " in
3760b85037dbSmrg	*" $my_xlib_u "*)
3761b85037dbSmrg	  func_arith $extracted_serial + 1
3762b85037dbSmrg	  extracted_serial=$func_arith_result
3763b85037dbSmrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
3764b85037dbSmrg	*) break ;;
3765b85037dbSmrg	esac
3766b85037dbSmrg      done
3767b85037dbSmrg      extracted_archives="$extracted_archives $my_xlib_u"
3768b85037dbSmrg      my_xdir="$my_gentop/$my_xlib_u"
3769b85037dbSmrg
3770b85037dbSmrg      func_mkdir_p "$my_xdir"
3771b85037dbSmrg
3772b85037dbSmrg      case $host in
3773b85037dbSmrg      *-darwin*)
3774b85037dbSmrg	func_verbose "Extracting $my_xabs"
3775b85037dbSmrg	# Do not bother doing anything if just a dry run
3776b85037dbSmrg	$opt_dry_run || {
3777b85037dbSmrg	  darwin_orig_dir=`pwd`
3778b85037dbSmrg	  cd $my_xdir || exit $?
3779b85037dbSmrg	  darwin_archive=$my_xabs
3780b85037dbSmrg	  darwin_curdir=`pwd`
3781b85037dbSmrg	  darwin_base_archive=`basename "$darwin_archive"`
3782b85037dbSmrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
3783b85037dbSmrg	  if test -n "$darwin_arches"; then
3784b85037dbSmrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
3785b85037dbSmrg	    darwin_arch=
3786b85037dbSmrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
3787b85037dbSmrg	    for darwin_arch in  $darwin_arches ; do
3788b85037dbSmrg	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3789b85037dbSmrg	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
3790b85037dbSmrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3791b85037dbSmrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
3792b85037dbSmrg	      cd "$darwin_curdir"
3793b85037dbSmrg	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
3794b85037dbSmrg	    done # $darwin_arches
3795b85037dbSmrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
3796b85037dbSmrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
3797b85037dbSmrg	    darwin_file=
3798b85037dbSmrg	    darwin_files=
3799b85037dbSmrg	    for darwin_file in $darwin_filelist; do
3800b85037dbSmrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
3801b85037dbSmrg	      $LIPO -create -output "$darwin_file" $darwin_files
3802b85037dbSmrg	    done # $darwin_filelist
3803b85037dbSmrg	    $RM -rf unfat-$$
3804b85037dbSmrg	    cd "$darwin_orig_dir"
3805b85037dbSmrg	  else
3806b85037dbSmrg	    cd $darwin_orig_dir
3807b85037dbSmrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
3808b85037dbSmrg	  fi # $darwin_arches
3809b85037dbSmrg	} # !$opt_dry_run
3810b85037dbSmrg	;;
3811b85037dbSmrg      *)
3812b85037dbSmrg        func_extract_an_archive "$my_xdir" "$my_xabs"
3813b85037dbSmrg	;;
3814b85037dbSmrg      esac
3815b85037dbSmrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
3816b85037dbSmrg    done
3817b85037dbSmrg
3818b85037dbSmrg    func_extract_archives_result="$my_oldobjs"
3819b85037dbSmrg}
3820b85037dbSmrg
3821b85037dbSmrg
3822b85037dbSmrg# func_emit_wrapper [arg=no]
3823b85037dbSmrg#
3824b85037dbSmrg# Emit a libtool wrapper script on stdout.
3825b85037dbSmrg# Don't directly open a file because we may want to
3826b85037dbSmrg# incorporate the script contents within a cygwin/mingw
3827b85037dbSmrg# wrapper executable.  Must ONLY be called from within
3828b85037dbSmrg# func_mode_link because it depends on a number of variables
3829b85037dbSmrg# set therein.
3830b85037dbSmrg#
3831b85037dbSmrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
3832b85037dbSmrg# variable will take.  If 'yes', then the emitted script
3833b85037dbSmrg# will assume that the directory in which it is stored is
3834b85037dbSmrg# the $objdir directory.  This is a cygwin/mingw-specific
3835b85037dbSmrg# behavior.
3836b85037dbSmrgfunc_emit_wrapper ()
3837b85037dbSmrg{
3838b85037dbSmrg	func_emit_wrapper_arg1=${1-no}
3839b85037dbSmrg
3840b85037dbSmrg	$ECHO "\
3841b85037dbSmrg#! $SHELL
3842b85037dbSmrg
3843b85037dbSmrg# $output - temporary wrapper script for $objdir/$outputname
3844b85037dbSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
3845b85037dbSmrg#
3846b85037dbSmrg# The $output program cannot be directly executed until all the libtool
3847b85037dbSmrg# libraries that it depends on are installed.
3848b85037dbSmrg#
3849b85037dbSmrg# This wrapper script should never be moved out of the build directory.
3850b85037dbSmrg# If it is, it will not operate correctly.
3851b85037dbSmrg
3852b85037dbSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
3853b85037dbSmrg# metacharacters that are still active within double-quoted strings.
3854b85037dbSmrgsed_quote_subst='$sed_quote_subst'
3855b85037dbSmrg
3856b85037dbSmrg# Be Bourne compatible
3857b85037dbSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
3858b85037dbSmrg  emulate sh
3859b85037dbSmrg  NULLCMD=:
3860b85037dbSmrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
3861b85037dbSmrg  # is contrary to our usage.  Disable this feature.
3862b85037dbSmrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
3863b85037dbSmrg  setopt NO_GLOB_SUBST
3864b85037dbSmrgelse
3865b85037dbSmrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
3866b85037dbSmrgfi
3867b85037dbSmrgBIN_SH=xpg4; export BIN_SH # for Tru64
3868b85037dbSmrgDUALCASE=1; export DUALCASE # for MKS sh
3869b85037dbSmrg
3870b85037dbSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout
3871b85037dbSmrg# if CDPATH is set.
3872b85037dbSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
3873b85037dbSmrg
3874b85037dbSmrgrelink_command=\"$relink_command\"
3875b85037dbSmrg
3876b85037dbSmrg# This environment variable determines our operation mode.
3877b85037dbSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then
3878b85037dbSmrg  # install mode needs the following variables:
3879b85037dbSmrg  generated_by_libtool_version='$macro_version'
3880b85037dbSmrg  notinst_deplibs='$notinst_deplibs'
3881b85037dbSmrgelse
3882b85037dbSmrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
3883b85037dbSmrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
3884b85037dbSmrg    file=\"\$0\""
3885b85037dbSmrg
3886b85037dbSmrg    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
3887b85037dbSmrg    $ECHO "\
3888b85037dbSmrg
3889b85037dbSmrg# A function that is used when there is no print builtin or printf.
3890b85037dbSmrgfunc_fallback_echo ()
3891b85037dbSmrg{
3892b85037dbSmrg  eval 'cat <<_LTECHO_EOF
3893b85037dbSmrg\$1
3894b85037dbSmrg_LTECHO_EOF'
3895b85037dbSmrg}
3896b85037dbSmrg    ECHO=\"$qECHO\"
3897b85037dbSmrg  fi
3898b85037dbSmrg
3899b85037dbSmrg# Very basic option parsing. These options are (a) specific to
3900b85037dbSmrg# the libtool wrapper, (b) are identical between the wrapper
3901b85037dbSmrg# /script/ and the wrapper /executable/ which is used only on
3902b85037dbSmrg# windows platforms, and (c) all begin with the string "--lt-"
3903b85037dbSmrg# (application programs are unlikely to have options which match
3904b85037dbSmrg# this pattern).
3905b85037dbSmrg#
3906b85037dbSmrg# There are only two supported options: --lt-debug and
3907b85037dbSmrg# --lt-dump-script. There is, deliberately, no --lt-help.
3908b85037dbSmrg#
3909b85037dbSmrg# The first argument to this parsing function should be the
3910b85037dbSmrg# script's $0 value, followed by "$@".
3911b85037dbSmrglt_option_debug=
3912b85037dbSmrgfunc_parse_lt_options ()
3913b85037dbSmrg{
3914b85037dbSmrg  lt_script_arg0=\$0
3915b85037dbSmrg  shift
3916b85037dbSmrg  for lt_opt
3917b85037dbSmrg  do
3918b85037dbSmrg    case \"\$lt_opt\" in
3919b85037dbSmrg    --lt-debug) lt_option_debug=1 ;;
3920b85037dbSmrg    --lt-dump-script)
3921b85037dbSmrg        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
3922b85037dbSmrg        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
3923b85037dbSmrg        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
3924b85037dbSmrg        cat \"\$lt_dump_D/\$lt_dump_F\"
3925b85037dbSmrg        exit 0
3926b85037dbSmrg      ;;
3927b85037dbSmrg    --lt-*)
3928b85037dbSmrg        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
3929b85037dbSmrg        exit 1
3930b85037dbSmrg      ;;
3931b85037dbSmrg    esac
3932b85037dbSmrg  done
3933b85037dbSmrg
3934b85037dbSmrg  # Print the debug banner immediately:
3935b85037dbSmrg  if test -n \"\$lt_option_debug\"; then
3936b85037dbSmrg    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
3937b85037dbSmrg  fi
3938b85037dbSmrg}
3939b85037dbSmrg
3940b85037dbSmrg# Used when --lt-debug. Prints its arguments to stdout
3941b85037dbSmrg# (redirection is the responsibility of the caller)
3942b85037dbSmrgfunc_lt_dump_args ()
3943b85037dbSmrg{
3944b85037dbSmrg  lt_dump_args_N=1;
3945b85037dbSmrg  for lt_arg
3946b85037dbSmrg  do
3947b85037dbSmrg    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
3948b85037dbSmrg    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
3949b85037dbSmrg  done
3950b85037dbSmrg}
3951b85037dbSmrg
3952b85037dbSmrg# Core function for launching the target application
3953b85037dbSmrgfunc_exec_program_core ()
3954b85037dbSmrg{
3955b85037dbSmrg"
3956b85037dbSmrg  case $host in
3957b85037dbSmrg  # Backslashes separate directories on plain windows
3958b85037dbSmrg  *-*-mingw | *-*-os2* | *-cegcc*)
3959b85037dbSmrg    $ECHO "\
3960b85037dbSmrg      if test -n \"\$lt_option_debug\"; then
3961b85037dbSmrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
3962b85037dbSmrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
3963b85037dbSmrg      fi
3964b85037dbSmrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
3965b85037dbSmrg"
3966b85037dbSmrg    ;;
3967b85037dbSmrg
3968b85037dbSmrg  *)
3969b85037dbSmrg    $ECHO "\
3970b85037dbSmrg      if test -n \"\$lt_option_debug\"; then
3971b85037dbSmrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
3972b85037dbSmrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
3973b85037dbSmrg      fi
3974b85037dbSmrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
3975b85037dbSmrg"
3976b85037dbSmrg    ;;
3977b85037dbSmrg  esac
3978b85037dbSmrg  $ECHO "\
3979b85037dbSmrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
3980b85037dbSmrg      exit 1
3981b85037dbSmrg}
3982b85037dbSmrg
3983b85037dbSmrg# A function to encapsulate launching the target application
3984b85037dbSmrg# Strips options in the --lt-* namespace from \$@ and
3985b85037dbSmrg# launches target application with the remaining arguments.
3986b85037dbSmrgfunc_exec_program ()
3987b85037dbSmrg{
398828515619Smrg  case \" \$* \" in
398928515619Smrg  *\\ --lt-*)
399028515619Smrg    for lt_wr_arg
399128515619Smrg    do
399228515619Smrg      case \$lt_wr_arg in
399328515619Smrg      --lt-*) ;;
399428515619Smrg      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
399528515619Smrg      esac
399628515619Smrg      shift
399728515619Smrg    done ;;
399828515619Smrg  esac
3999b85037dbSmrg  func_exec_program_core \${1+\"\$@\"}
4000b85037dbSmrg}
4001b85037dbSmrg
4002b85037dbSmrg  # Parse options
4003b85037dbSmrg  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
4004b85037dbSmrg
4005b85037dbSmrg  # Find the directory that this script lives in.
4006b85037dbSmrg  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
4007b85037dbSmrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
4008b85037dbSmrg
4009b85037dbSmrg  # Follow symbolic links until we get to the real thisdir.
4010b85037dbSmrg  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
4011b85037dbSmrg  while test -n \"\$file\"; do
4012b85037dbSmrg    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
4013b85037dbSmrg
4014b85037dbSmrg    # If there was a directory component, then change thisdir.
4015b85037dbSmrg    if test \"x\$destdir\" != \"x\$file\"; then
4016b85037dbSmrg      case \"\$destdir\" in
4017b85037dbSmrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
4018b85037dbSmrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
4019b85037dbSmrg      esac
4020b85037dbSmrg    fi
4021b85037dbSmrg
4022b85037dbSmrg    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
4023b85037dbSmrg    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
4024b85037dbSmrg  done
4025b85037dbSmrg
4026b85037dbSmrg  # Usually 'no', except on cygwin/mingw when embedded into
4027b85037dbSmrg  # the cwrapper.
4028b85037dbSmrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
4029b85037dbSmrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
4030b85037dbSmrg    # special case for '.'
4031b85037dbSmrg    if test \"\$thisdir\" = \".\"; then
4032b85037dbSmrg      thisdir=\`pwd\`
4033b85037dbSmrg    fi
4034b85037dbSmrg    # remove .libs from thisdir
4035b85037dbSmrg    case \"\$thisdir\" in
4036b85037dbSmrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
4037b85037dbSmrg    $objdir )   thisdir=. ;;
4038b85037dbSmrg    esac
4039b85037dbSmrg  fi
4040b85037dbSmrg
4041b85037dbSmrg  # Try to get the absolute directory name.
4042b85037dbSmrg  absdir=\`cd \"\$thisdir\" && pwd\`
4043b85037dbSmrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
4044b85037dbSmrg"
4045b85037dbSmrg
4046b85037dbSmrg	if test "$fast_install" = yes; then
4047b85037dbSmrg	  $ECHO "\
4048b85037dbSmrg  program=lt-'$outputname'$exeext
4049b85037dbSmrg  progdir=\"\$thisdir/$objdir\"
4050b85037dbSmrg
4051b85037dbSmrg  if test ! -f \"\$progdir/\$program\" ||
4052b85037dbSmrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
4053b85037dbSmrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
4054b85037dbSmrg
4055b85037dbSmrg    file=\"\$\$-\$program\"
4056b85037dbSmrg
4057b85037dbSmrg    if test ! -d \"\$progdir\"; then
4058b85037dbSmrg      $MKDIR \"\$progdir\"
4059b85037dbSmrg    else
4060b85037dbSmrg      $RM \"\$progdir/\$file\"
4061b85037dbSmrg    fi"
4062b85037dbSmrg
4063b85037dbSmrg	  $ECHO "\
4064b85037dbSmrg
4065b85037dbSmrg    # relink executable if necessary
4066b85037dbSmrg    if test -n \"\$relink_command\"; then
4067b85037dbSmrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
4068b85037dbSmrg      else
4069b85037dbSmrg	$ECHO \"\$relink_command_output\" >&2
4070b85037dbSmrg	$RM \"\$progdir/\$file\"
4071b85037dbSmrg	exit 1
4072b85037dbSmrg      fi
4073b85037dbSmrg    fi
4074b85037dbSmrg
4075b85037dbSmrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
4076b85037dbSmrg    { $RM \"\$progdir/\$program\";
4077b85037dbSmrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
4078b85037dbSmrg    $RM \"\$progdir/\$file\"
4079b85037dbSmrg  fi"
4080b85037dbSmrg	else
4081b85037dbSmrg	  $ECHO "\
4082b85037dbSmrg  program='$outputname'
4083b85037dbSmrg  progdir=\"\$thisdir/$objdir\"
4084b85037dbSmrg"
4085b85037dbSmrg	fi
4086b85037dbSmrg
4087b85037dbSmrg	$ECHO "\
4088b85037dbSmrg
4089b85037dbSmrg  if test -f \"\$progdir/\$program\"; then"
4090b85037dbSmrg
4091302b15bdSmrg	# fixup the dll searchpath if we need to.
4092302b15bdSmrg	#
4093302b15bdSmrg	# Fix the DLL searchpath if we need to.  Do this before prepending
4094302b15bdSmrg	# to shlibpath, because on Windows, both are PATH and uninstalled
4095302b15bdSmrg	# libraries must come first.
4096302b15bdSmrg	if test -n "$dllsearchpath"; then
4097302b15bdSmrg	  $ECHO "\
4098302b15bdSmrg    # Add the dll search path components to the executable PATH
4099302b15bdSmrg    PATH=$dllsearchpath:\$PATH
4100302b15bdSmrg"
4101302b15bdSmrg	fi
4102302b15bdSmrg
4103b85037dbSmrg	# Export our shlibpath_var if we have one.
4104b85037dbSmrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4105b85037dbSmrg	  $ECHO "\
4106b85037dbSmrg    # Add our own library path to $shlibpath_var
4107b85037dbSmrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
4108b85037dbSmrg
4109b85037dbSmrg    # Some systems cannot cope with colon-terminated $shlibpath_var
4110b85037dbSmrg    # The second colon is a workaround for a bug in BeOS R4 sed
4111b85037dbSmrg    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
4112b85037dbSmrg
4113b85037dbSmrg    export $shlibpath_var
4114b85037dbSmrg"
4115b85037dbSmrg	fi
4116b85037dbSmrg
4117b85037dbSmrg	$ECHO "\
4118b85037dbSmrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
4119b85037dbSmrg      # Run the actual program with our arguments.
4120b85037dbSmrg      func_exec_program \${1+\"\$@\"}
4121b85037dbSmrg    fi
4122b85037dbSmrg  else
4123b85037dbSmrg    # The program doesn't exist.
4124b85037dbSmrg    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
4125b85037dbSmrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
4126b85037dbSmrg    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
4127b85037dbSmrg    exit 1
4128b85037dbSmrg  fi
4129b85037dbSmrgfi\
4130b85037dbSmrg"
4131b85037dbSmrg}
4132b85037dbSmrg
4133b85037dbSmrg
4134b85037dbSmrg# func_emit_cwrapperexe_src
4135b85037dbSmrg# emit the source code for a wrapper executable on stdout
4136b85037dbSmrg# Must ONLY be called from within func_mode_link because
4137b85037dbSmrg# it depends on a number of variable set therein.
4138b85037dbSmrgfunc_emit_cwrapperexe_src ()
4139b85037dbSmrg{
4140b85037dbSmrg	cat <<EOF
4141b85037dbSmrg
4142b85037dbSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
4143b85037dbSmrg   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
4144b85037dbSmrg
4145b85037dbSmrg   The $output program cannot be directly executed until all the libtool
4146b85037dbSmrg   libraries that it depends on are installed.
4147b85037dbSmrg
4148b85037dbSmrg   This wrapper executable should never be moved out of the build directory.
4149b85037dbSmrg   If it is, it will not operate correctly.
4150b85037dbSmrg*/
4151b85037dbSmrgEOF
4152b85037dbSmrg	    cat <<"EOF"
4153b85037dbSmrg#ifdef _MSC_VER
4154b85037dbSmrg# define _CRT_SECURE_NO_DEPRECATE 1
4155b85037dbSmrg#endif
4156b85037dbSmrg#include <stdio.h>
4157b85037dbSmrg#include <stdlib.h>
4158b85037dbSmrg#ifdef _MSC_VER
4159b85037dbSmrg# include <direct.h>
4160b85037dbSmrg# include <process.h>
4161b85037dbSmrg# include <io.h>
4162b85037dbSmrg#else
4163b85037dbSmrg# include <unistd.h>
4164b85037dbSmrg# include <stdint.h>
4165b85037dbSmrg# ifdef __CYGWIN__
4166b85037dbSmrg#  include <io.h>
4167b85037dbSmrg# endif
4168b85037dbSmrg#endif
4169b85037dbSmrg#include <malloc.h>
4170b85037dbSmrg#include <stdarg.h>
4171b85037dbSmrg#include <assert.h>
4172b85037dbSmrg#include <string.h>
4173b85037dbSmrg#include <ctype.h>
4174b85037dbSmrg#include <errno.h>
4175b85037dbSmrg#include <fcntl.h>
4176b85037dbSmrg#include <sys/stat.h>
4177b85037dbSmrg
4178b85037dbSmrg/* declarations of non-ANSI functions */
4179b85037dbSmrg#if defined(__MINGW32__)
4180b85037dbSmrg# ifdef __STRICT_ANSI__
4181b85037dbSmrgint _putenv (const char *);
4182b85037dbSmrg# endif
4183b85037dbSmrg#elif defined(__CYGWIN__)
4184b85037dbSmrg# ifdef __STRICT_ANSI__
4185b85037dbSmrgchar *realpath (const char *, char *);
4186b85037dbSmrgint putenv (char *);
4187b85037dbSmrgint setenv (const char *, const char *, int);
4188b85037dbSmrg# endif
4189b85037dbSmrg/* #elif defined (other platforms) ... */
4190b85037dbSmrg#endif
4191b85037dbSmrg
4192b85037dbSmrg/* portability defines, excluding path handling macros */
4193b85037dbSmrg#if defined(_MSC_VER)
4194b85037dbSmrg# define setmode _setmode
4195b85037dbSmrg# define stat    _stat
4196b85037dbSmrg# define chmod   _chmod
4197b85037dbSmrg# define getcwd  _getcwd
4198b85037dbSmrg# define putenv  _putenv
4199b85037dbSmrg# define S_IXUSR _S_IEXEC
4200b85037dbSmrg# ifndef _INTPTR_T_DEFINED
4201b85037dbSmrg#  define _INTPTR_T_DEFINED
4202b85037dbSmrg#  define intptr_t int
4203b85037dbSmrg# endif
4204b85037dbSmrg#elif defined(__MINGW32__)
4205b85037dbSmrg# define setmode _setmode
4206b85037dbSmrg# define stat    _stat
4207b85037dbSmrg# define chmod   _chmod
4208b85037dbSmrg# define getcwd  _getcwd
4209b85037dbSmrg# define putenv  _putenv
4210b85037dbSmrg#elif defined(__CYGWIN__)
4211b85037dbSmrg# define HAVE_SETENV
4212b85037dbSmrg# define FOPEN_WB "wb"
4213b85037dbSmrg/* #elif defined (other platforms) ... */
4214b85037dbSmrg#endif
4215b85037dbSmrg
4216b85037dbSmrg#if defined(PATH_MAX)
4217b85037dbSmrg# define LT_PATHMAX PATH_MAX
4218b85037dbSmrg#elif defined(MAXPATHLEN)
4219b85037dbSmrg# define LT_PATHMAX MAXPATHLEN
4220b85037dbSmrg#else
4221b85037dbSmrg# define LT_PATHMAX 1024
4222b85037dbSmrg#endif
4223b85037dbSmrg
4224b85037dbSmrg#ifndef S_IXOTH
4225b85037dbSmrg# define S_IXOTH 0
4226b85037dbSmrg#endif
4227b85037dbSmrg#ifndef S_IXGRP
4228b85037dbSmrg# define S_IXGRP 0
4229b85037dbSmrg#endif
4230b85037dbSmrg
4231b85037dbSmrg/* path handling portability macros */
4232b85037dbSmrg#ifndef DIR_SEPARATOR
4233b85037dbSmrg# define DIR_SEPARATOR '/'
4234b85037dbSmrg# define PATH_SEPARATOR ':'
4235b85037dbSmrg#endif
4236b85037dbSmrg
4237b85037dbSmrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
4238b85037dbSmrg  defined (__OS2__)
4239b85037dbSmrg# define HAVE_DOS_BASED_FILE_SYSTEM
4240b85037dbSmrg# define FOPEN_WB "wb"
4241b85037dbSmrg# ifndef DIR_SEPARATOR_2
4242b85037dbSmrg#  define DIR_SEPARATOR_2 '\\'
4243b85037dbSmrg# endif
4244b85037dbSmrg# ifndef PATH_SEPARATOR_2
4245b85037dbSmrg#  define PATH_SEPARATOR_2 ';'
4246b85037dbSmrg# endif
4247b85037dbSmrg#endif
4248b85037dbSmrg
4249b85037dbSmrg#ifndef DIR_SEPARATOR_2
4250b85037dbSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
4251b85037dbSmrg#else /* DIR_SEPARATOR_2 */
4252b85037dbSmrg# define IS_DIR_SEPARATOR(ch) \
4253b85037dbSmrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
4254b85037dbSmrg#endif /* DIR_SEPARATOR_2 */
4255b85037dbSmrg
4256b85037dbSmrg#ifndef PATH_SEPARATOR_2
4257b85037dbSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
4258b85037dbSmrg#else /* PATH_SEPARATOR_2 */
4259b85037dbSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
4260b85037dbSmrg#endif /* PATH_SEPARATOR_2 */
4261b85037dbSmrg
4262b85037dbSmrg#ifndef FOPEN_WB
4263b85037dbSmrg# define FOPEN_WB "w"
4264b85037dbSmrg#endif
4265b85037dbSmrg#ifndef _O_BINARY
4266b85037dbSmrg# define _O_BINARY 0
4267b85037dbSmrg#endif
4268b85037dbSmrg
4269b85037dbSmrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
4270b85037dbSmrg#define XFREE(stale) do { \
4271b85037dbSmrg  if (stale) { free ((void *) stale); stale = 0; } \
4272b85037dbSmrg} while (0)
4273b85037dbSmrg
4274b85037dbSmrg#if defined(LT_DEBUGWRAPPER)
4275b85037dbSmrgstatic int lt_debug = 1;
4276b85037dbSmrg#else
4277b85037dbSmrgstatic int lt_debug = 0;
4278b85037dbSmrg#endif
4279b85037dbSmrg
4280b85037dbSmrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
4281b85037dbSmrg
4282b85037dbSmrgvoid *xmalloc (size_t num);
4283b85037dbSmrgchar *xstrdup (const char *string);
4284b85037dbSmrgconst char *base_name (const char *name);
4285b85037dbSmrgchar *find_executable (const char *wrapper);
4286b85037dbSmrgchar *chase_symlinks (const char *pathspec);
4287b85037dbSmrgint make_executable (const char *path);
4288b85037dbSmrgint check_executable (const char *path);
4289b85037dbSmrgchar *strendzap (char *str, const char *pat);
4290b85037dbSmrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
4291b85037dbSmrgvoid lt_fatal (const char *file, int line, const char *message, ...);
4292b85037dbSmrgstatic const char *nonnull (const char *s);
4293b85037dbSmrgstatic const char *nonempty (const char *s);
4294b85037dbSmrgvoid lt_setenv (const char *name, const char *value);
4295b85037dbSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
4296b85037dbSmrgvoid lt_update_exe_path (const char *name, const char *value);
4297b85037dbSmrgvoid lt_update_lib_path (const char *name, const char *value);
4298b85037dbSmrgchar **prepare_spawn (char **argv);
4299b85037dbSmrgvoid lt_dump_script (FILE *f);
4300b85037dbSmrgEOF
4301b85037dbSmrg
4302b85037dbSmrg	    cat <<EOF
4303302b15bdSmrgvolatile const char * MAGIC_EXE = "$magic_exe";
4304b85037dbSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
4305b85037dbSmrgEOF
4306b85037dbSmrg
4307b85037dbSmrg	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4308302b15bdSmrg              func_to_host_path "$temp_rpath"
4309b85037dbSmrg	      cat <<EOF
4310302b15bdSmrgconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
4311b85037dbSmrgEOF
4312b85037dbSmrg	    else
4313b85037dbSmrg	      cat <<"EOF"
4314b85037dbSmrgconst char * LIB_PATH_VALUE   = "";
4315b85037dbSmrgEOF
4316b85037dbSmrg	    fi
4317b85037dbSmrg
4318b85037dbSmrg	    if test -n "$dllsearchpath"; then
4319302b15bdSmrg              func_to_host_path "$dllsearchpath:"
4320b85037dbSmrg	      cat <<EOF
4321b85037dbSmrgconst char * EXE_PATH_VARNAME = "PATH";
4322302b15bdSmrgconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
4323b85037dbSmrgEOF
4324b85037dbSmrg	    else
4325b85037dbSmrg	      cat <<"EOF"
4326b85037dbSmrgconst char * EXE_PATH_VARNAME = "";
4327b85037dbSmrgconst char * EXE_PATH_VALUE   = "";
4328b85037dbSmrgEOF
4329b85037dbSmrg	    fi
4330b85037dbSmrg
4331b85037dbSmrg	    if test "$fast_install" = yes; then
4332b85037dbSmrg	      cat <<EOF
4333b85037dbSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
4334b85037dbSmrgEOF
4335b85037dbSmrg	    else
4336b85037dbSmrg	      cat <<EOF
4337b85037dbSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
4338b85037dbSmrgEOF
4339b85037dbSmrg	    fi
4340b85037dbSmrg
4341b85037dbSmrg
4342b85037dbSmrg	    cat <<"EOF"
4343b85037dbSmrg
4344b85037dbSmrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
4345b85037dbSmrg
4346b85037dbSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
4347b85037dbSmrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
4348b85037dbSmrgstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
4349b85037dbSmrg
4350b85037dbSmrgint
4351b85037dbSmrgmain (int argc, char *argv[])
4352b85037dbSmrg{
4353b85037dbSmrg  char **newargz;
4354b85037dbSmrg  int  newargc;
4355b85037dbSmrg  char *tmp_pathspec;
4356b85037dbSmrg  char *actual_cwrapper_path;
4357b85037dbSmrg  char *actual_cwrapper_name;
4358b85037dbSmrg  char *target_name;
4359b85037dbSmrg  char *lt_argv_zero;
4360b85037dbSmrg  intptr_t rval = 127;
4361b85037dbSmrg
4362b85037dbSmrg  int i;
4363b85037dbSmrg
4364b85037dbSmrg  program_name = (char *) xstrdup (base_name (argv[0]));
4365b85037dbSmrg  newargz = XMALLOC (char *, argc + 1);
4366b85037dbSmrg
4367b85037dbSmrg  /* very simple arg parsing; don't want to rely on getopt
4368b85037dbSmrg   * also, copy all non cwrapper options to newargz, except
4369b85037dbSmrg   * argz[0], which is handled differently
4370b85037dbSmrg   */
4371b85037dbSmrg  newargc=0;
4372b85037dbSmrg  for (i = 1; i < argc; i++)
4373b85037dbSmrg    {
4374b85037dbSmrg      if (strcmp (argv[i], dumpscript_opt) == 0)
4375b85037dbSmrg	{
4376b85037dbSmrgEOF
4377b85037dbSmrg	    case "$host" in
4378b85037dbSmrg	      *mingw* | *cygwin* )
4379b85037dbSmrg		# make stdout use "unix" line endings
4380b85037dbSmrg		echo "          setmode(1,_O_BINARY);"
4381b85037dbSmrg		;;
4382b85037dbSmrg	      esac
4383b85037dbSmrg
4384b85037dbSmrg	    cat <<"EOF"
4385b85037dbSmrg	  lt_dump_script (stdout);
4386b85037dbSmrg	  return 0;
4387b85037dbSmrg	}
4388b85037dbSmrg      if (strcmp (argv[i], debug_opt) == 0)
4389b85037dbSmrg	{
4390b85037dbSmrg          lt_debug = 1;
4391b85037dbSmrg          continue;
4392b85037dbSmrg	}
4393b85037dbSmrg      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
4394b85037dbSmrg        {
4395b85037dbSmrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
4396b85037dbSmrg             namespace, but it is not one of the ones we know about and
4397b85037dbSmrg             have already dealt with, above (inluding dump-script), then
4398b85037dbSmrg             report an error. Otherwise, targets might begin to believe
4399b85037dbSmrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
4400b85037dbSmrg             namespace. The first time any user complains about this, we'll
4401b85037dbSmrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
4402b85037dbSmrg             or a configure.ac-settable value.
4403b85037dbSmrg           */
4404b85037dbSmrg          lt_fatal (__FILE__, __LINE__,
4405b85037dbSmrg		    "unrecognized %s option: '%s'",
4406b85037dbSmrg                    ltwrapper_option_prefix, argv[i]);
4407b85037dbSmrg        }
4408b85037dbSmrg      /* otherwise ... */
4409b85037dbSmrg      newargz[++newargc] = xstrdup (argv[i]);
4410b85037dbSmrg    }
4411b85037dbSmrg  newargz[++newargc] = NULL;
4412b85037dbSmrg
4413b85037dbSmrgEOF
4414b85037dbSmrg	    cat <<EOF
4415b85037dbSmrg  /* The GNU banner must be the first non-error debug message */
4416b85037dbSmrg  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
4417b85037dbSmrgEOF
4418b85037dbSmrg	    cat <<"EOF"
4419b85037dbSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
4420b85037dbSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
4421b85037dbSmrg
4422b85037dbSmrg  tmp_pathspec = find_executable (argv[0]);
4423b85037dbSmrg  if (tmp_pathspec == NULL)
4424b85037dbSmrg    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
4425b85037dbSmrg  lt_debugprintf (__FILE__, __LINE__,
4426b85037dbSmrg                  "(main) found exe (before symlink chase) at: %s\n",
4427b85037dbSmrg		  tmp_pathspec);
4428b85037dbSmrg
4429b85037dbSmrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
4430b85037dbSmrg  lt_debugprintf (__FILE__, __LINE__,
4431b85037dbSmrg                  "(main) found exe (after symlink chase) at: %s\n",
4432b85037dbSmrg		  actual_cwrapper_path);
4433b85037dbSmrg  XFREE (tmp_pathspec);
4434b85037dbSmrg
4435b85037dbSmrg  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
4436b85037dbSmrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
4437b85037dbSmrg
4438b85037dbSmrg  /* wrapper name transforms */
4439b85037dbSmrg  strendzap (actual_cwrapper_name, ".exe");
4440b85037dbSmrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
4441b85037dbSmrg  XFREE (actual_cwrapper_name);
4442b85037dbSmrg  actual_cwrapper_name = tmp_pathspec;
4443b85037dbSmrg  tmp_pathspec = 0;
4444b85037dbSmrg
4445b85037dbSmrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
4446b85037dbSmrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
4447b85037dbSmrg  strendzap (target_name, ".exe");
4448b85037dbSmrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
4449b85037dbSmrg  XFREE (target_name);
4450b85037dbSmrg  target_name = tmp_pathspec;
4451b85037dbSmrg  tmp_pathspec = 0;
4452b85037dbSmrg
4453b85037dbSmrg  lt_debugprintf (__FILE__, __LINE__,
4454b85037dbSmrg		  "(main) libtool target name: %s\n",
4455b85037dbSmrg		  target_name);
4456b85037dbSmrgEOF
4457b85037dbSmrg
4458b85037dbSmrg	    cat <<EOF
4459b85037dbSmrg  newargz[0] =
4460b85037dbSmrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
4461b85037dbSmrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
4462b85037dbSmrg  strcpy (newargz[0], actual_cwrapper_path);
4463b85037dbSmrg  strcat (newargz[0], "$objdir");
4464b85037dbSmrg  strcat (newargz[0], "/");
4465b85037dbSmrgEOF
4466b85037dbSmrg
4467b85037dbSmrg	    cat <<"EOF"
4468b85037dbSmrg  /* stop here, and copy so we don't have to do this twice */
4469b85037dbSmrg  tmp_pathspec = xstrdup (newargz[0]);
4470b85037dbSmrg
4471b85037dbSmrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
4472b85037dbSmrg  strcat (newargz[0], actual_cwrapper_name);
4473b85037dbSmrg
4474b85037dbSmrg  /* DO want the lt- prefix here if it exists, so use target_name */
4475b85037dbSmrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
4476b85037dbSmrg  XFREE (tmp_pathspec);
4477b85037dbSmrg  tmp_pathspec = NULL;
4478b85037dbSmrgEOF
4479b85037dbSmrg
4480b85037dbSmrg	    case $host_os in
4481b85037dbSmrg	      mingw*)
4482b85037dbSmrg	    cat <<"EOF"
4483b85037dbSmrg  {
4484b85037dbSmrg    char* p;
4485b85037dbSmrg    while ((p = strchr (newargz[0], '\\')) != NULL)
4486b85037dbSmrg      {
4487b85037dbSmrg	*p = '/';
4488b85037dbSmrg      }
4489b85037dbSmrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
4490b85037dbSmrg      {
4491b85037dbSmrg	*p = '/';
4492b85037dbSmrg      }
4493b85037dbSmrg  }
4494b85037dbSmrgEOF
4495b85037dbSmrg	    ;;
4496b85037dbSmrg	    esac
4497b85037dbSmrg
4498b85037dbSmrg	    cat <<"EOF"
4499b85037dbSmrg  XFREE (target_name);
4500b85037dbSmrg  XFREE (actual_cwrapper_path);
4501b85037dbSmrg  XFREE (actual_cwrapper_name);
4502b85037dbSmrg
4503b85037dbSmrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
4504b85037dbSmrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
4505302b15bdSmrg  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
4506302b15bdSmrg     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
4507302b15bdSmrg     because on Windows, both *_VARNAMEs are PATH but uninstalled
4508302b15bdSmrg     libraries must come first. */
4509b85037dbSmrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
4510302b15bdSmrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
4511b85037dbSmrg
4512b85037dbSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
4513b85037dbSmrg		  nonnull (lt_argv_zero));
4514b85037dbSmrg  for (i = 0; i < newargc; i++)
4515b85037dbSmrg    {
4516b85037dbSmrg      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
4517b85037dbSmrg		      i, nonnull (newargz[i]));
4518b85037dbSmrg    }
4519b85037dbSmrg
4520b85037dbSmrgEOF
4521b85037dbSmrg
4522b85037dbSmrg	    case $host_os in
4523b85037dbSmrg	      mingw*)
4524b85037dbSmrg		cat <<"EOF"
4525b85037dbSmrg  /* execv doesn't actually work on mingw as expected on unix */
4526b85037dbSmrg  newargz = prepare_spawn (newargz);
4527b85037dbSmrg  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
4528b85037dbSmrg  if (rval == -1)
4529b85037dbSmrg    {
4530b85037dbSmrg      /* failed to start process */
4531b85037dbSmrg      lt_debugprintf (__FILE__, __LINE__,
4532b85037dbSmrg		      "(main) failed to launch target \"%s\": %s\n",
4533b85037dbSmrg		      lt_argv_zero, nonnull (strerror (errno)));
4534b85037dbSmrg      return 127;
4535b85037dbSmrg    }
4536b85037dbSmrg  return rval;
4537b85037dbSmrgEOF
4538b85037dbSmrg		;;
4539b85037dbSmrg	      *)
4540b85037dbSmrg		cat <<"EOF"
4541b85037dbSmrg  execv (lt_argv_zero, newargz);
4542b85037dbSmrg  return rval; /* =127, but avoids unused variable warning */
4543b85037dbSmrgEOF
4544b85037dbSmrg		;;
4545b85037dbSmrg	    esac
4546b85037dbSmrg
4547b85037dbSmrg	    cat <<"EOF"
4548b85037dbSmrg}
4549b85037dbSmrg
4550b85037dbSmrgvoid *
4551b85037dbSmrgxmalloc (size_t num)
4552b85037dbSmrg{
4553b85037dbSmrg  void *p = (void *) malloc (num);
4554b85037dbSmrg  if (!p)
4555b85037dbSmrg    lt_fatal (__FILE__, __LINE__, "memory exhausted");
4556b85037dbSmrg
4557b85037dbSmrg  return p;
4558b85037dbSmrg}
4559b85037dbSmrg
4560b85037dbSmrgchar *
4561b85037dbSmrgxstrdup (const char *string)
4562b85037dbSmrg{
4563b85037dbSmrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
4564b85037dbSmrg			  string) : NULL;
4565b85037dbSmrg}
4566b85037dbSmrg
4567b85037dbSmrgconst char *
4568b85037dbSmrgbase_name (const char *name)
4569b85037dbSmrg{
4570b85037dbSmrg  const char *base;
4571b85037dbSmrg
4572b85037dbSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4573b85037dbSmrg  /* Skip over the disk name in MSDOS pathnames. */
4574b85037dbSmrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
4575b85037dbSmrg    name += 2;
4576b85037dbSmrg#endif
4577b85037dbSmrg
4578b85037dbSmrg  for (base = name; *name; name++)
4579b85037dbSmrg    if (IS_DIR_SEPARATOR (*name))
4580b85037dbSmrg      base = name + 1;
4581b85037dbSmrg  return base;
4582b85037dbSmrg}
4583b85037dbSmrg
4584b85037dbSmrgint
4585b85037dbSmrgcheck_executable (const char *path)
4586b85037dbSmrg{
4587b85037dbSmrg  struct stat st;
4588b85037dbSmrg
4589b85037dbSmrg  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
4590b85037dbSmrg                  nonempty (path));
4591b85037dbSmrg  if ((!path) || (!*path))
4592b85037dbSmrg    return 0;
4593b85037dbSmrg
4594b85037dbSmrg  if ((stat (path, &st) >= 0)
4595b85037dbSmrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
4596b85037dbSmrg    return 1;
4597b85037dbSmrg  else
4598b85037dbSmrg    return 0;
4599b85037dbSmrg}
4600b85037dbSmrg
4601b85037dbSmrgint
4602b85037dbSmrgmake_executable (const char *path)
4603b85037dbSmrg{
4604b85037dbSmrg  int rval = 0;
4605b85037dbSmrg  struct stat st;
4606b85037dbSmrg
4607b85037dbSmrg  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
4608b85037dbSmrg                  nonempty (path));
4609b85037dbSmrg  if ((!path) || (!*path))
4610b85037dbSmrg    return 0;
4611b85037dbSmrg
4612b85037dbSmrg  if (stat (path, &st) >= 0)
4613b85037dbSmrg    {
4614b85037dbSmrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
4615b85037dbSmrg    }
4616b85037dbSmrg  return rval;
4617b85037dbSmrg}
4618b85037dbSmrg
4619b85037dbSmrg/* Searches for the full path of the wrapper.  Returns
4620b85037dbSmrg   newly allocated full path name if found, NULL otherwise
4621b85037dbSmrg   Does not chase symlinks, even on platforms that support them.
4622b85037dbSmrg*/
4623b85037dbSmrgchar *
4624b85037dbSmrgfind_executable (const char *wrapper)
4625b85037dbSmrg{
4626b85037dbSmrg  int has_slash = 0;
4627b85037dbSmrg  const char *p;
4628b85037dbSmrg  const char *p_next;
4629b85037dbSmrg  /* static buffer for getcwd */
4630b85037dbSmrg  char tmp[LT_PATHMAX + 1];
4631b85037dbSmrg  int tmp_len;
4632b85037dbSmrg  char *concat_name;
4633b85037dbSmrg
4634b85037dbSmrg  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
4635b85037dbSmrg                  nonempty (wrapper));
4636b85037dbSmrg
4637b85037dbSmrg  if ((wrapper == NULL) || (*wrapper == '\0'))
4638b85037dbSmrg    return NULL;
4639b85037dbSmrg
4640b85037dbSmrg  /* Absolute path? */
4641b85037dbSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4642b85037dbSmrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
4643b85037dbSmrg    {
4644b85037dbSmrg      concat_name = xstrdup (wrapper);
4645b85037dbSmrg      if (check_executable (concat_name))
4646b85037dbSmrg	return concat_name;
4647b85037dbSmrg      XFREE (concat_name);
4648b85037dbSmrg    }
4649b85037dbSmrg  else
4650b85037dbSmrg    {
4651b85037dbSmrg#endif
4652b85037dbSmrg      if (IS_DIR_SEPARATOR (wrapper[0]))
4653b85037dbSmrg	{
4654b85037dbSmrg	  concat_name = xstrdup (wrapper);
4655b85037dbSmrg	  if (check_executable (concat_name))
4656b85037dbSmrg	    return concat_name;
4657b85037dbSmrg	  XFREE (concat_name);
4658b85037dbSmrg	}
4659b85037dbSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4660b85037dbSmrg    }
4661b85037dbSmrg#endif
4662b85037dbSmrg
4663b85037dbSmrg  for (p = wrapper; *p; p++)
4664b85037dbSmrg    if (*p == '/')
4665b85037dbSmrg      {
4666b85037dbSmrg	has_slash = 1;
4667b85037dbSmrg	break;
4668b85037dbSmrg      }
4669b85037dbSmrg  if (!has_slash)
4670b85037dbSmrg    {
4671b85037dbSmrg      /* no slashes; search PATH */
4672b85037dbSmrg      const char *path = getenv ("PATH");
4673b85037dbSmrg      if (path != NULL)
4674b85037dbSmrg	{
4675b85037dbSmrg	  for (p = path; *p; p = p_next)
4676b85037dbSmrg	    {
4677b85037dbSmrg	      const char *q;
4678b85037dbSmrg	      size_t p_len;
4679b85037dbSmrg	      for (q = p; *q; q++)
4680b85037dbSmrg		if (IS_PATH_SEPARATOR (*q))
4681b85037dbSmrg		  break;
4682b85037dbSmrg	      p_len = q - p;
4683b85037dbSmrg	      p_next = (*q == '\0' ? q : q + 1);
4684b85037dbSmrg	      if (p_len == 0)
4685b85037dbSmrg		{
4686b85037dbSmrg		  /* empty path: current directory */
4687b85037dbSmrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
4688b85037dbSmrg		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
4689b85037dbSmrg                              nonnull (strerror (errno)));
4690b85037dbSmrg		  tmp_len = strlen (tmp);
4691b85037dbSmrg		  concat_name =
4692b85037dbSmrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
4693b85037dbSmrg		  memcpy (concat_name, tmp, tmp_len);
4694b85037dbSmrg		  concat_name[tmp_len] = '/';
4695b85037dbSmrg		  strcpy (concat_name + tmp_len + 1, wrapper);
4696b85037dbSmrg		}
4697b85037dbSmrg	      else
4698b85037dbSmrg		{
4699b85037dbSmrg		  concat_name =
4700b85037dbSmrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
4701b85037dbSmrg		  memcpy (concat_name, p, p_len);
4702b85037dbSmrg		  concat_name[p_len] = '/';
4703b85037dbSmrg		  strcpy (concat_name + p_len + 1, wrapper);
4704b85037dbSmrg		}
4705b85037dbSmrg	      if (check_executable (concat_name))
4706b85037dbSmrg		return concat_name;
4707b85037dbSmrg	      XFREE (concat_name);
4708b85037dbSmrg	    }
4709b85037dbSmrg	}
4710b85037dbSmrg      /* not found in PATH; assume curdir */
4711b85037dbSmrg    }
4712b85037dbSmrg  /* Relative path | not found in path: prepend cwd */
4713b85037dbSmrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
4714b85037dbSmrg    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
4715b85037dbSmrg              nonnull (strerror (errno)));
4716b85037dbSmrg  tmp_len = strlen (tmp);
4717b85037dbSmrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
4718b85037dbSmrg  memcpy (concat_name, tmp, tmp_len);
4719b85037dbSmrg  concat_name[tmp_len] = '/';
4720b85037dbSmrg  strcpy (concat_name + tmp_len + 1, wrapper);
4721b85037dbSmrg
4722b85037dbSmrg  if (check_executable (concat_name))
4723b85037dbSmrg    return concat_name;
4724b85037dbSmrg  XFREE (concat_name);
4725b85037dbSmrg  return NULL;
4726b85037dbSmrg}
4727b85037dbSmrg
4728b85037dbSmrgchar *
4729b85037dbSmrgchase_symlinks (const char *pathspec)
4730b85037dbSmrg{
4731b85037dbSmrg#ifndef S_ISLNK
4732b85037dbSmrg  return xstrdup (pathspec);
4733b85037dbSmrg#else
4734b85037dbSmrg  char buf[LT_PATHMAX];
4735b85037dbSmrg  struct stat s;
4736b85037dbSmrg  char *tmp_pathspec = xstrdup (pathspec);
4737b85037dbSmrg  char *p;
4738b85037dbSmrg  int has_symlinks = 0;
4739b85037dbSmrg  while (strlen (tmp_pathspec) && !has_symlinks)
4740b85037dbSmrg    {
4741b85037dbSmrg      lt_debugprintf (__FILE__, __LINE__,
4742b85037dbSmrg		      "checking path component for symlinks: %s\n",
4743b85037dbSmrg		      tmp_pathspec);
4744b85037dbSmrg      if (lstat (tmp_pathspec, &s) == 0)
4745b85037dbSmrg	{
4746b85037dbSmrg	  if (S_ISLNK (s.st_mode) != 0)
4747b85037dbSmrg	    {
4748b85037dbSmrg	      has_symlinks = 1;
4749b85037dbSmrg	      break;
4750b85037dbSmrg	    }
4751b85037dbSmrg
4752b85037dbSmrg	  /* search backwards for last DIR_SEPARATOR */
4753b85037dbSmrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
4754b85037dbSmrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4755b85037dbSmrg	    p--;
4756b85037dbSmrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4757b85037dbSmrg	    {
4758b85037dbSmrg	      /* no more DIR_SEPARATORS left */
4759b85037dbSmrg	      break;
4760b85037dbSmrg	    }
4761b85037dbSmrg	  *p = '\0';
4762b85037dbSmrg	}
4763b85037dbSmrg      else
4764b85037dbSmrg	{
4765b85037dbSmrg	  lt_fatal (__FILE__, __LINE__,
4766b85037dbSmrg		    "error accessing file \"%s\": %s",
4767b85037dbSmrg		    tmp_pathspec, nonnull (strerror (errno)));
4768b85037dbSmrg	}
4769b85037dbSmrg    }
4770b85037dbSmrg  XFREE (tmp_pathspec);
4771b85037dbSmrg
4772b85037dbSmrg  if (!has_symlinks)
4773b85037dbSmrg    {
4774b85037dbSmrg      return xstrdup (pathspec);
4775b85037dbSmrg    }
4776b85037dbSmrg
4777b85037dbSmrg  tmp_pathspec = realpath (pathspec, buf);
4778b85037dbSmrg  if (tmp_pathspec == 0)
4779b85037dbSmrg    {
4780b85037dbSmrg      lt_fatal (__FILE__, __LINE__,
4781b85037dbSmrg		"could not follow symlinks for %s", pathspec);
4782b85037dbSmrg    }
4783b85037dbSmrg  return xstrdup (tmp_pathspec);
4784b85037dbSmrg#endif
4785b85037dbSmrg}
4786b85037dbSmrg
4787b85037dbSmrgchar *
4788b85037dbSmrgstrendzap (char *str, const char *pat)
4789b85037dbSmrg{
4790b85037dbSmrg  size_t len, patlen;
4791b85037dbSmrg
4792b85037dbSmrg  assert (str != NULL);
4793b85037dbSmrg  assert (pat != NULL);
4794b85037dbSmrg
4795b85037dbSmrg  len = strlen (str);
4796b85037dbSmrg  patlen = strlen (pat);
4797b85037dbSmrg
4798b85037dbSmrg  if (patlen <= len)
4799b85037dbSmrg    {
4800b85037dbSmrg      str += len - patlen;
4801b85037dbSmrg      if (strcmp (str, pat) == 0)
4802b85037dbSmrg	*str = '\0';
4803b85037dbSmrg    }
4804b85037dbSmrg  return str;
4805b85037dbSmrg}
4806b85037dbSmrg
4807b85037dbSmrgvoid
4808b85037dbSmrglt_debugprintf (const char *file, int line, const char *fmt, ...)
4809b85037dbSmrg{
4810b85037dbSmrg  va_list args;
4811b85037dbSmrg  if (lt_debug)
4812b85037dbSmrg    {
4813b85037dbSmrg      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
4814b85037dbSmrg      va_start (args, fmt);
4815b85037dbSmrg      (void) vfprintf (stderr, fmt, args);
4816b85037dbSmrg      va_end (args);
4817b85037dbSmrg    }
4818b85037dbSmrg}
4819b85037dbSmrg
4820b85037dbSmrgstatic void
4821b85037dbSmrglt_error_core (int exit_status, const char *file,
4822b85037dbSmrg	       int line, const char *mode,
4823b85037dbSmrg	       const char *message, va_list ap)
4824b85037dbSmrg{
4825b85037dbSmrg  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
4826b85037dbSmrg  vfprintf (stderr, message, ap);
4827b85037dbSmrg  fprintf (stderr, ".\n");
4828b85037dbSmrg
4829b85037dbSmrg  if (exit_status >= 0)
4830b85037dbSmrg    exit (exit_status);
4831b85037dbSmrg}
4832b85037dbSmrg
4833b85037dbSmrgvoid
4834b85037dbSmrglt_fatal (const char *file, int line, const char *message, ...)
4835b85037dbSmrg{
4836b85037dbSmrg  va_list ap;
4837b85037dbSmrg  va_start (ap, message);
4838b85037dbSmrg  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
4839b85037dbSmrg  va_end (ap);
4840b85037dbSmrg}
4841b85037dbSmrg
4842b85037dbSmrgstatic const char *
4843b85037dbSmrgnonnull (const char *s)
4844b85037dbSmrg{
4845b85037dbSmrg  return s ? s : "(null)";
4846b85037dbSmrg}
4847b85037dbSmrg
4848b85037dbSmrgstatic const char *
4849b85037dbSmrgnonempty (const char *s)
4850b85037dbSmrg{
4851b85037dbSmrg  return (s && !*s) ? "(empty)" : nonnull (s);
4852b85037dbSmrg}
4853b85037dbSmrg
4854b85037dbSmrgvoid
4855b85037dbSmrglt_setenv (const char *name, const char *value)
4856b85037dbSmrg{
4857b85037dbSmrg  lt_debugprintf (__FILE__, __LINE__,
4858b85037dbSmrg		  "(lt_setenv) setting '%s' to '%s'\n",
4859b85037dbSmrg                  nonnull (name), nonnull (value));
4860b85037dbSmrg  {
4861b85037dbSmrg#ifdef HAVE_SETENV
4862b85037dbSmrg    /* always make a copy, for consistency with !HAVE_SETENV */
4863b85037dbSmrg    char *str = xstrdup (value);
4864b85037dbSmrg    setenv (name, str, 1);
4865b85037dbSmrg#else
4866b85037dbSmrg    int len = strlen (name) + 1 + strlen (value) + 1;
4867b85037dbSmrg    char *str = XMALLOC (char, len);
4868b85037dbSmrg    sprintf (str, "%s=%s", name, value);
4869b85037dbSmrg    if (putenv (str) != EXIT_SUCCESS)
4870b85037dbSmrg      {
4871b85037dbSmrg        XFREE (str);
4872b85037dbSmrg      }
4873b85037dbSmrg#endif
4874b85037dbSmrg  }
4875b85037dbSmrg}
4876b85037dbSmrg
4877b85037dbSmrgchar *
4878b85037dbSmrglt_extend_str (const char *orig_value, const char *add, int to_end)
4879b85037dbSmrg{
4880b85037dbSmrg  char *new_value;
4881b85037dbSmrg  if (orig_value && *orig_value)
4882b85037dbSmrg    {
4883b85037dbSmrg      int orig_value_len = strlen (orig_value);
4884b85037dbSmrg      int add_len = strlen (add);
4885b85037dbSmrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
4886b85037dbSmrg      if (to_end)
4887b85037dbSmrg        {
4888b85037dbSmrg          strcpy (new_value, orig_value);
4889b85037dbSmrg          strcpy (new_value + orig_value_len, add);
4890b85037dbSmrg        }
4891b85037dbSmrg      else
4892b85037dbSmrg        {
4893b85037dbSmrg          strcpy (new_value, add);
4894b85037dbSmrg          strcpy (new_value + add_len, orig_value);
4895b85037dbSmrg        }
4896b85037dbSmrg    }
4897b85037dbSmrg  else
4898b85037dbSmrg    {
4899b85037dbSmrg      new_value = xstrdup (add);
4900b85037dbSmrg    }
4901b85037dbSmrg  return new_value;
4902b85037dbSmrg}
4903b85037dbSmrg
4904b85037dbSmrgvoid
4905b85037dbSmrglt_update_exe_path (const char *name, const char *value)
4906b85037dbSmrg{
4907b85037dbSmrg  lt_debugprintf (__FILE__, __LINE__,
4908b85037dbSmrg		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
4909b85037dbSmrg                  nonnull (name), nonnull (value));
4910b85037dbSmrg
4911b85037dbSmrg  if (name && *name && value && *value)
4912b85037dbSmrg    {
4913b85037dbSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
4914b85037dbSmrg      /* some systems can't cope with a ':'-terminated path #' */
4915b85037dbSmrg      int len = strlen (new_value);
4916b85037dbSmrg      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
4917b85037dbSmrg        {
4918b85037dbSmrg          new_value[len-1] = '\0';
4919b85037dbSmrg        }
4920b85037dbSmrg      lt_setenv (name, new_value);
4921b85037dbSmrg      XFREE (new_value);
4922b85037dbSmrg    }
4923b85037dbSmrg}
4924b85037dbSmrg
4925b85037dbSmrgvoid
4926b85037dbSmrglt_update_lib_path (const char *name, const char *value)
4927b85037dbSmrg{
4928b85037dbSmrg  lt_debugprintf (__FILE__, __LINE__,
4929b85037dbSmrg		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
4930b85037dbSmrg                  nonnull (name), nonnull (value));
4931b85037dbSmrg
4932b85037dbSmrg  if (name && *name && value && *value)
4933b85037dbSmrg    {
4934b85037dbSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
4935b85037dbSmrg      lt_setenv (name, new_value);
4936b85037dbSmrg      XFREE (new_value);
4937b85037dbSmrg    }
4938b85037dbSmrg}
4939b85037dbSmrg
4940b85037dbSmrgEOF
4941b85037dbSmrg	    case $host_os in
4942b85037dbSmrg	      mingw*)
4943b85037dbSmrg		cat <<"EOF"
4944b85037dbSmrg
4945b85037dbSmrg/* Prepares an argument vector before calling spawn().
4946b85037dbSmrg   Note that spawn() does not by itself call the command interpreter
4947b85037dbSmrg     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
4948b85037dbSmrg      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
4949b85037dbSmrg         GetVersionEx(&v);
4950b85037dbSmrg         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
4951b85037dbSmrg      }) ? "cmd.exe" : "command.com").
4952b85037dbSmrg   Instead it simply concatenates the arguments, separated by ' ', and calls
4953b85037dbSmrg   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
4954b85037dbSmrg   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
4955b85037dbSmrg   special way:
4956b85037dbSmrg   - Space and tab are interpreted as delimiters. They are not treated as
4957b85037dbSmrg     delimiters if they are surrounded by double quotes: "...".
4958b85037dbSmrg   - Unescaped double quotes are removed from the input. Their only effect is
4959b85037dbSmrg     that within double quotes, space and tab are treated like normal
4960b85037dbSmrg     characters.
4961b85037dbSmrg   - Backslashes not followed by double quotes are not special.
4962b85037dbSmrg   - But 2*n+1 backslashes followed by a double quote become
4963b85037dbSmrg     n backslashes followed by a double quote (n >= 0):
4964b85037dbSmrg       \" -> "
4965b85037dbSmrg       \\\" -> \"
4966b85037dbSmrg       \\\\\" -> \\"
4967b85037dbSmrg */
4968b85037dbSmrg#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"
4969b85037dbSmrg#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"
4970b85037dbSmrgchar **
4971b85037dbSmrgprepare_spawn (char **argv)
4972b85037dbSmrg{
4973b85037dbSmrg  size_t argc;
4974b85037dbSmrg  char **new_argv;
4975b85037dbSmrg  size_t i;
4976b85037dbSmrg
4977b85037dbSmrg  /* Count number of arguments.  */
4978b85037dbSmrg  for (argc = 0; argv[argc] != NULL; argc++)
4979b85037dbSmrg    ;
4980b85037dbSmrg
4981b85037dbSmrg  /* Allocate new argument vector.  */
4982b85037dbSmrg  new_argv = XMALLOC (char *, argc + 1);
4983b85037dbSmrg
4984b85037dbSmrg  /* Put quoted arguments into the new argument vector.  */
4985b85037dbSmrg  for (i = 0; i < argc; i++)
4986b85037dbSmrg    {
4987b85037dbSmrg      const char *string = argv[i];
4988b85037dbSmrg
4989b85037dbSmrg      if (string[0] == '\0')
4990b85037dbSmrg	new_argv[i] = xstrdup ("\"\"");
4991b85037dbSmrg      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
4992b85037dbSmrg	{
4993b85037dbSmrg	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
4994b85037dbSmrg	  size_t length;
4995b85037dbSmrg	  unsigned int backslashes;
4996b85037dbSmrg	  const char *s;
4997b85037dbSmrg	  char *quoted_string;
4998b85037dbSmrg	  char *p;
4999b85037dbSmrg
5000b85037dbSmrg	  length = 0;
5001b85037dbSmrg	  backslashes = 0;
5002b85037dbSmrg	  if (quote_around)
5003b85037dbSmrg	    length++;
5004b85037dbSmrg	  for (s = string; *s != '\0'; s++)
5005b85037dbSmrg	    {
5006b85037dbSmrg	      char c = *s;
5007b85037dbSmrg	      if (c == '"')
5008b85037dbSmrg		length += backslashes + 1;
5009b85037dbSmrg	      length++;
5010b85037dbSmrg	      if (c == '\\')
5011b85037dbSmrg		backslashes++;
5012b85037dbSmrg	      else
5013b85037dbSmrg		backslashes = 0;
5014b85037dbSmrg	    }
5015b85037dbSmrg	  if (quote_around)
5016b85037dbSmrg	    length += backslashes + 1;
5017b85037dbSmrg
5018b85037dbSmrg	  quoted_string = XMALLOC (char, length + 1);
5019b85037dbSmrg
5020b85037dbSmrg	  p = quoted_string;
5021b85037dbSmrg	  backslashes = 0;
5022b85037dbSmrg	  if (quote_around)
5023b85037dbSmrg	    *p++ = '"';
5024b85037dbSmrg	  for (s = string; *s != '\0'; s++)
5025b85037dbSmrg	    {
5026b85037dbSmrg	      char c = *s;
5027b85037dbSmrg	      if (c == '"')
5028b85037dbSmrg		{
5029b85037dbSmrg		  unsigned int j;
5030b85037dbSmrg		  for (j = backslashes + 1; j > 0; j--)
5031b85037dbSmrg		    *p++ = '\\';
5032b85037dbSmrg		}
5033b85037dbSmrg	      *p++ = c;
5034b85037dbSmrg	      if (c == '\\')
5035b85037dbSmrg		backslashes++;
5036b85037dbSmrg	      else
5037b85037dbSmrg		backslashes = 0;
5038b85037dbSmrg	    }
5039b85037dbSmrg	  if (quote_around)
5040b85037dbSmrg	    {
5041b85037dbSmrg	      unsigned int j;
5042b85037dbSmrg	      for (j = backslashes; j > 0; j--)
5043b85037dbSmrg		*p++ = '\\';
5044b85037dbSmrg	      *p++ = '"';
5045b85037dbSmrg	    }
5046b85037dbSmrg	  *p = '\0';
5047b85037dbSmrg
5048b85037dbSmrg	  new_argv[i] = quoted_string;
5049b85037dbSmrg	}
5050b85037dbSmrg      else
5051b85037dbSmrg	new_argv[i] = (char *) string;
5052b85037dbSmrg    }
5053b85037dbSmrg  new_argv[argc] = NULL;
5054b85037dbSmrg
5055b85037dbSmrg  return new_argv;
5056b85037dbSmrg}
5057b85037dbSmrgEOF
5058b85037dbSmrg		;;
5059b85037dbSmrg	    esac
5060b85037dbSmrg
5061b85037dbSmrg            cat <<"EOF"
5062b85037dbSmrgvoid lt_dump_script (FILE* f)
5063b85037dbSmrg{
5064b85037dbSmrgEOF
5065b85037dbSmrg	    func_emit_wrapper yes |
506628515619Smrg	      $SED -n -e '
506728515619Smrgs/^\(.\{79\}\)\(..*\)/\1\
506828515619Smrg\2/
506928515619Smrgh
507028515619Smrgs/\([\\"]\)/\\\1/g
507128515619Smrgs/$/\\n/
507228515619Smrgs/\([^\n]*\).*/  fputs ("\1", f);/p
507328515619Smrgg
507428515619SmrgD'
5075b85037dbSmrg            cat <<"EOF"
5076b85037dbSmrg}
5077b85037dbSmrgEOF
5078b85037dbSmrg}
5079b85037dbSmrg# end: func_emit_cwrapperexe_src
5080b85037dbSmrg
5081b85037dbSmrg# func_win32_import_lib_p ARG
5082b85037dbSmrg# True if ARG is an import lib, as indicated by $file_magic_cmd
5083b85037dbSmrgfunc_win32_import_lib_p ()
5084b85037dbSmrg{
5085b85037dbSmrg    $opt_debug
5086b85037dbSmrg    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
5087b85037dbSmrg    *import*) : ;;
5088b85037dbSmrg    *) false ;;
5089b85037dbSmrg    esac
5090b85037dbSmrg}
5091b85037dbSmrg
5092b85037dbSmrg# func_mode_link arg...
5093b85037dbSmrgfunc_mode_link ()
5094b85037dbSmrg{
5095b85037dbSmrg    $opt_debug
5096b85037dbSmrg    case $host in
5097b85037dbSmrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
5098b85037dbSmrg      # It is impossible to link a dll without this setting, and
5099b85037dbSmrg      # we shouldn't force the makefile maintainer to figure out
5100b85037dbSmrg      # which system we are compiling for in order to pass an extra
5101b85037dbSmrg      # flag for every libtool invocation.
5102b85037dbSmrg      # allow_undefined=no
5103b85037dbSmrg
5104b85037dbSmrg      # FIXME: Unfortunately, there are problems with the above when trying
5105b85037dbSmrg      # to make a dll which has undefined symbols, in which case not
5106b85037dbSmrg      # even a static library is built.  For now, we need to specify
5107b85037dbSmrg      # -no-undefined on the libtool link line when we can be certain
5108b85037dbSmrg      # that all symbols are satisfied, otherwise we get a static library.
5109b85037dbSmrg      allow_undefined=yes
5110b85037dbSmrg      ;;
5111b85037dbSmrg    *)
5112b85037dbSmrg      allow_undefined=yes
5113b85037dbSmrg      ;;
5114b85037dbSmrg    esac
5115b85037dbSmrg    libtool_args=$nonopt
5116b85037dbSmrg    base_compile="$nonopt $@"
5117b85037dbSmrg    compile_command=$nonopt
5118b85037dbSmrg    finalize_command=$nonopt
5119b85037dbSmrg
5120b85037dbSmrg    compile_rpath=
5121b85037dbSmrg    finalize_rpath=
5122b85037dbSmrg    compile_shlibpath=
5123b85037dbSmrg    finalize_shlibpath=
5124b85037dbSmrg    convenience=
5125b85037dbSmrg    old_convenience=
5126b85037dbSmrg    deplibs=
5127b85037dbSmrg    old_deplibs=
5128b85037dbSmrg    compiler_flags=
5129b85037dbSmrg    linker_flags=
5130b85037dbSmrg    dllsearchpath=
5131b85037dbSmrg    lib_search_path=`pwd`
5132b85037dbSmrg    inst_prefix_dir=
5133b85037dbSmrg    new_inherited_linker_flags=
5134b85037dbSmrg
5135b85037dbSmrg    avoid_version=no
5136b85037dbSmrg    bindir=
5137b85037dbSmrg    dlfiles=
5138b85037dbSmrg    dlprefiles=
5139b85037dbSmrg    dlself=no
5140b85037dbSmrg    export_dynamic=no
5141b85037dbSmrg    export_symbols=
5142b85037dbSmrg    export_symbols_regex=
5143b85037dbSmrg    generated=
5144b85037dbSmrg    libobjs=
5145b85037dbSmrg    ltlibs=
5146b85037dbSmrg    module=no
5147b85037dbSmrg    no_install=no
5148b85037dbSmrg    objs=
5149b85037dbSmrg    non_pic_objects=
5150b85037dbSmrg    precious_files_regex=
5151b85037dbSmrg    prefer_static_libs=no
5152b85037dbSmrg    preload=no
5153b85037dbSmrg    prev=
5154b85037dbSmrg    prevarg=
5155b85037dbSmrg    release=
5156b85037dbSmrg    rpath=
5157b85037dbSmrg    xrpath=
5158b85037dbSmrg    perm_rpath=
5159b85037dbSmrg    temp_rpath=
5160b85037dbSmrg    thread_safe=no
5161b85037dbSmrg    vinfo=
5162b85037dbSmrg    vinfo_number=no
5163b85037dbSmrg    weak_libs=
5164b85037dbSmrg    single_module="${wl}-single_module"
5165b85037dbSmrg    func_infer_tag $base_compile
5166b85037dbSmrg
5167b85037dbSmrg    # We need to know -static, to get the right output filenames.
5168b85037dbSmrg    for arg
5169b85037dbSmrg    do
5170b85037dbSmrg      case $arg in
5171b85037dbSmrg      -shared)
5172b85037dbSmrg	test "$build_libtool_libs" != yes && \
5173b85037dbSmrg	  func_fatal_configuration "can not build a shared library"
5174b85037dbSmrg	build_old_libs=no
5175b85037dbSmrg	break
5176b85037dbSmrg	;;
5177b85037dbSmrg      -all-static | -static | -static-libtool-libs)
5178b85037dbSmrg	case $arg in
5179b85037dbSmrg	-all-static)
5180b85037dbSmrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
5181b85037dbSmrg	    func_warning "complete static linking is impossible in this configuration"
5182b85037dbSmrg	  fi
5183b85037dbSmrg	  if test -n "$link_static_flag"; then
5184b85037dbSmrg	    dlopen_self=$dlopen_self_static
5185b85037dbSmrg	  fi
5186b85037dbSmrg	  prefer_static_libs=yes
5187b85037dbSmrg	  ;;
5188b85037dbSmrg	-static)
5189b85037dbSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
5190b85037dbSmrg	    dlopen_self=$dlopen_self_static
5191b85037dbSmrg	  fi
5192b85037dbSmrg	  prefer_static_libs=built
5193b85037dbSmrg	  ;;
5194b85037dbSmrg	-static-libtool-libs)
5195b85037dbSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
5196b85037dbSmrg	    dlopen_self=$dlopen_self_static
5197b85037dbSmrg	  fi
5198b85037dbSmrg	  prefer_static_libs=yes
5199b85037dbSmrg	  ;;
5200b85037dbSmrg	esac
5201b85037dbSmrg	build_libtool_libs=no
5202b85037dbSmrg	build_old_libs=yes
5203b85037dbSmrg	break
5204b85037dbSmrg	;;
5205b85037dbSmrg      esac
5206b85037dbSmrg    done
5207b85037dbSmrg
5208b85037dbSmrg    # See if our shared archives depend on static archives.
5209b85037dbSmrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
5210b85037dbSmrg
5211b85037dbSmrg    # Go through the arguments, transforming them on the way.
5212b85037dbSmrg    while test "$#" -gt 0; do
5213b85037dbSmrg      arg="$1"
5214b85037dbSmrg      shift
5215b85037dbSmrg      func_quote_for_eval "$arg"
5216b85037dbSmrg      qarg=$func_quote_for_eval_unquoted_result
5217b85037dbSmrg      func_append libtool_args " $func_quote_for_eval_result"
5218b85037dbSmrg
5219b85037dbSmrg      # If the previous option needs an argument, assign it.
5220b85037dbSmrg      if test -n "$prev"; then
5221b85037dbSmrg	case $prev in
5222b85037dbSmrg	output)
5223b85037dbSmrg	  func_append compile_command " @OUTPUT@"
5224b85037dbSmrg	  func_append finalize_command " @OUTPUT@"
5225b85037dbSmrg	  ;;
5226b85037dbSmrg	esac
5227b85037dbSmrg
5228b85037dbSmrg	case $prev in
5229b85037dbSmrg	bindir)
5230b85037dbSmrg	  bindir="$arg"
5231b85037dbSmrg	  prev=
5232b85037dbSmrg	  continue
5233b85037dbSmrg	  ;;
5234b85037dbSmrg	dlfiles|dlprefiles)
5235b85037dbSmrg	  if test "$preload" = no; then
5236b85037dbSmrg	    # Add the symbol object into the linking commands.
5237b85037dbSmrg	    func_append compile_command " @SYMFILE@"
5238b85037dbSmrg	    func_append finalize_command " @SYMFILE@"
5239b85037dbSmrg	    preload=yes
5240b85037dbSmrg	  fi
5241b85037dbSmrg	  case $arg in
5242b85037dbSmrg	  *.la | *.lo) ;;  # We handle these cases below.
5243b85037dbSmrg	  force)
5244b85037dbSmrg	    if test "$dlself" = no; then
5245b85037dbSmrg	      dlself=needless
5246b85037dbSmrg	      export_dynamic=yes
5247b85037dbSmrg	    fi
5248b85037dbSmrg	    prev=
5249b85037dbSmrg	    continue
5250b85037dbSmrg	    ;;
5251b85037dbSmrg	  self)
5252b85037dbSmrg	    if test "$prev" = dlprefiles; then
5253b85037dbSmrg	      dlself=yes
5254b85037dbSmrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
5255b85037dbSmrg	      dlself=yes
5256b85037dbSmrg	    else
5257b85037dbSmrg	      dlself=needless
5258b85037dbSmrg	      export_dynamic=yes
5259b85037dbSmrg	    fi
5260b85037dbSmrg	    prev=
5261b85037dbSmrg	    continue
5262b85037dbSmrg	    ;;
5263b85037dbSmrg	  *)
5264b85037dbSmrg	    if test "$prev" = dlfiles; then
5265302b15bdSmrg	      func_append dlfiles " $arg"
5266b85037dbSmrg	    else
5267302b15bdSmrg	      func_append dlprefiles " $arg"
5268b85037dbSmrg	    fi
5269b85037dbSmrg	    prev=
5270b85037dbSmrg	    continue
5271b85037dbSmrg	    ;;
5272b85037dbSmrg	  esac
5273b85037dbSmrg	  ;;
5274b85037dbSmrg	expsyms)
5275b85037dbSmrg	  export_symbols="$arg"
5276b85037dbSmrg	  test -f "$arg" \
5277b85037dbSmrg	    || func_fatal_error "symbol file \`$arg' does not exist"
5278b85037dbSmrg	  prev=
5279b85037dbSmrg	  continue
5280b85037dbSmrg	  ;;
5281b85037dbSmrg	expsyms_regex)
5282b85037dbSmrg	  export_symbols_regex="$arg"
5283b85037dbSmrg	  prev=
5284b85037dbSmrg	  continue
5285b85037dbSmrg	  ;;
5286b85037dbSmrg	framework)
5287b85037dbSmrg	  case $host in
5288b85037dbSmrg	    *-*-darwin*)
5289b85037dbSmrg	      case "$deplibs " in
5290b85037dbSmrg		*" $qarg.ltframework "*) ;;
5291302b15bdSmrg		*) func_append deplibs " $qarg.ltframework" # this is fixed later
5292b85037dbSmrg		   ;;
5293b85037dbSmrg	      esac
5294b85037dbSmrg	      ;;
5295b85037dbSmrg	  esac
5296b85037dbSmrg	  prev=
5297b85037dbSmrg	  continue
5298b85037dbSmrg	  ;;
5299b85037dbSmrg	inst_prefix)
5300b85037dbSmrg	  inst_prefix_dir="$arg"
5301b85037dbSmrg	  prev=
5302b85037dbSmrg	  continue
5303b85037dbSmrg	  ;;
5304b85037dbSmrg	objectlist)
5305b85037dbSmrg	  if test -f "$arg"; then
5306b85037dbSmrg	    save_arg=$arg
5307b85037dbSmrg	    moreargs=
5308b85037dbSmrg	    for fil in `cat "$save_arg"`
5309b85037dbSmrg	    do
5310302b15bdSmrg#	      func_append moreargs " $fil"
5311b85037dbSmrg	      arg=$fil
5312b85037dbSmrg	      # A libtool-controlled object.
5313b85037dbSmrg
5314b85037dbSmrg	      # Check to see that this really is a libtool object.
5315b85037dbSmrg	      if func_lalib_unsafe_p "$arg"; then
5316b85037dbSmrg		pic_object=
5317b85037dbSmrg		non_pic_object=
5318b85037dbSmrg
5319b85037dbSmrg		# Read the .lo file
5320b85037dbSmrg		func_source "$arg"
5321b85037dbSmrg
5322b85037dbSmrg		if test -z "$pic_object" ||
5323b85037dbSmrg		   test -z "$non_pic_object" ||
5324b85037dbSmrg		   test "$pic_object" = none &&
5325b85037dbSmrg		   test "$non_pic_object" = none; then
5326b85037dbSmrg		  func_fatal_error "cannot find name of object for \`$arg'"
5327b85037dbSmrg		fi
5328b85037dbSmrg
5329b85037dbSmrg		# Extract subdirectory from the argument.
5330b85037dbSmrg		func_dirname "$arg" "/" ""
5331b85037dbSmrg		xdir="$func_dirname_result"
5332b85037dbSmrg
5333b85037dbSmrg		if test "$pic_object" != none; then
5334b85037dbSmrg		  # Prepend the subdirectory the object is found in.
5335b85037dbSmrg		  pic_object="$xdir$pic_object"
5336b85037dbSmrg
5337b85037dbSmrg		  if test "$prev" = dlfiles; then
5338b85037dbSmrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5339302b15bdSmrg		      func_append dlfiles " $pic_object"
5340b85037dbSmrg		      prev=
5341b85037dbSmrg		      continue
5342b85037dbSmrg		    else
5343b85037dbSmrg		      # If libtool objects are unsupported, then we need to preload.
5344b85037dbSmrg		      prev=dlprefiles
5345b85037dbSmrg		    fi
5346b85037dbSmrg		  fi
5347b85037dbSmrg
5348b85037dbSmrg		  # CHECK ME:  I think I busted this.  -Ossama
5349b85037dbSmrg		  if test "$prev" = dlprefiles; then
5350b85037dbSmrg		    # Preload the old-style object.
5351302b15bdSmrg		    func_append dlprefiles " $pic_object"
5352b85037dbSmrg		    prev=
5353b85037dbSmrg		  fi
5354b85037dbSmrg
5355b85037dbSmrg		  # A PIC object.
5356b85037dbSmrg		  func_append libobjs " $pic_object"
5357b85037dbSmrg		  arg="$pic_object"
5358b85037dbSmrg		fi
5359b85037dbSmrg
5360b85037dbSmrg		# Non-PIC object.
5361b85037dbSmrg		if test "$non_pic_object" != none; then
5362b85037dbSmrg		  # Prepend the subdirectory the object is found in.
5363b85037dbSmrg		  non_pic_object="$xdir$non_pic_object"
5364b85037dbSmrg
5365b85037dbSmrg		  # A standard non-PIC object
5366b85037dbSmrg		  func_append non_pic_objects " $non_pic_object"
5367b85037dbSmrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
5368b85037dbSmrg		    arg="$non_pic_object"
5369b85037dbSmrg		  fi
5370b85037dbSmrg		else
5371b85037dbSmrg		  # If the PIC object exists, use it instead.
5372b85037dbSmrg		  # $xdir was prepended to $pic_object above.
5373b85037dbSmrg		  non_pic_object="$pic_object"
5374b85037dbSmrg		  func_append non_pic_objects " $non_pic_object"
5375b85037dbSmrg		fi
5376b85037dbSmrg	      else
5377b85037dbSmrg		# Only an error if not doing a dry-run.
5378b85037dbSmrg		if $opt_dry_run; then
5379b85037dbSmrg		  # Extract subdirectory from the argument.
5380b85037dbSmrg		  func_dirname "$arg" "/" ""
5381b85037dbSmrg		  xdir="$func_dirname_result"
5382b85037dbSmrg
5383b85037dbSmrg		  func_lo2o "$arg"
5384b85037dbSmrg		  pic_object=$xdir$objdir/$func_lo2o_result
5385b85037dbSmrg		  non_pic_object=$xdir$func_lo2o_result
5386b85037dbSmrg		  func_append libobjs " $pic_object"
5387b85037dbSmrg		  func_append non_pic_objects " $non_pic_object"
5388b85037dbSmrg	        else
5389b85037dbSmrg		  func_fatal_error "\`$arg' is not a valid libtool object"
5390b85037dbSmrg		fi
5391b85037dbSmrg	      fi
5392b85037dbSmrg	    done
5393b85037dbSmrg	  else
5394b85037dbSmrg	    func_fatal_error "link input file \`$arg' does not exist"
5395b85037dbSmrg	  fi
5396b85037dbSmrg	  arg=$save_arg
5397b85037dbSmrg	  prev=
5398b85037dbSmrg	  continue
5399b85037dbSmrg	  ;;
5400b85037dbSmrg	precious_regex)
5401b85037dbSmrg	  precious_files_regex="$arg"
5402b85037dbSmrg	  prev=
5403b85037dbSmrg	  continue
5404b85037dbSmrg	  ;;
5405b85037dbSmrg	release)
5406b85037dbSmrg	  release="-$arg"
5407b85037dbSmrg	  prev=
5408b85037dbSmrg	  continue
5409b85037dbSmrg	  ;;
5410b85037dbSmrg	rpath | xrpath)
5411b85037dbSmrg	  # We need an absolute path.
5412b85037dbSmrg	  case $arg in
5413b85037dbSmrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
5414b85037dbSmrg	  *)
5415b85037dbSmrg	    func_fatal_error "only absolute run-paths are allowed"
5416b85037dbSmrg	    ;;
5417b85037dbSmrg	  esac
5418b85037dbSmrg	  if test "$prev" = rpath; then
5419b85037dbSmrg	    case "$rpath " in
5420b85037dbSmrg	    *" $arg "*) ;;
5421302b15bdSmrg	    *) func_append rpath " $arg" ;;
5422b85037dbSmrg	    esac
5423b85037dbSmrg	  else
5424b85037dbSmrg	    case "$xrpath " in
5425b85037dbSmrg	    *" $arg "*) ;;
5426302b15bdSmrg	    *) func_append xrpath " $arg" ;;
5427b85037dbSmrg	    esac
5428b85037dbSmrg	  fi
5429b85037dbSmrg	  prev=
5430b85037dbSmrg	  continue
5431b85037dbSmrg	  ;;
5432b85037dbSmrg	shrext)
5433b85037dbSmrg	  shrext_cmds="$arg"
5434b85037dbSmrg	  prev=
5435b85037dbSmrg	  continue
5436b85037dbSmrg	  ;;
5437b85037dbSmrg	weak)
5438302b15bdSmrg	  func_append weak_libs " $arg"
5439b85037dbSmrg	  prev=
5440b85037dbSmrg	  continue
5441b85037dbSmrg	  ;;
5442b85037dbSmrg	xcclinker)
5443302b15bdSmrg	  func_append linker_flags " $qarg"
5444302b15bdSmrg	  func_append compiler_flags " $qarg"
5445b85037dbSmrg	  prev=
5446b85037dbSmrg	  func_append compile_command " $qarg"
5447b85037dbSmrg	  func_append finalize_command " $qarg"
5448b85037dbSmrg	  continue
5449b85037dbSmrg	  ;;
5450b85037dbSmrg	xcompiler)
5451302b15bdSmrg	  func_append compiler_flags " $qarg"
5452b85037dbSmrg	  prev=
5453b85037dbSmrg	  func_append compile_command " $qarg"
5454b85037dbSmrg	  func_append finalize_command " $qarg"
5455b85037dbSmrg	  continue
5456b85037dbSmrg	  ;;
5457b85037dbSmrg	xlinker)
5458302b15bdSmrg	  func_append linker_flags " $qarg"
5459302b15bdSmrg	  func_append compiler_flags " $wl$qarg"
5460b85037dbSmrg	  prev=
5461b85037dbSmrg	  func_append compile_command " $wl$qarg"
5462b85037dbSmrg	  func_append finalize_command " $wl$qarg"
5463b85037dbSmrg	  continue
5464b85037dbSmrg	  ;;
5465b85037dbSmrg	*)
5466b85037dbSmrg	  eval "$prev=\"\$arg\""
5467b85037dbSmrg	  prev=
5468b85037dbSmrg	  continue
5469b85037dbSmrg	  ;;
5470b85037dbSmrg	esac
5471b85037dbSmrg      fi # test -n "$prev"
5472b85037dbSmrg
5473b85037dbSmrg      prevarg="$arg"
5474b85037dbSmrg
5475b85037dbSmrg      case $arg in
5476b85037dbSmrg      -all-static)
5477b85037dbSmrg	if test -n "$link_static_flag"; then
5478b85037dbSmrg	  # See comment for -static flag below, for more details.
5479b85037dbSmrg	  func_append compile_command " $link_static_flag"
5480b85037dbSmrg	  func_append finalize_command " $link_static_flag"
5481b85037dbSmrg	fi
5482b85037dbSmrg	continue
5483b85037dbSmrg	;;
5484b85037dbSmrg
5485b85037dbSmrg      -allow-undefined)
5486b85037dbSmrg	# FIXME: remove this flag sometime in the future.
5487b85037dbSmrg	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
5488b85037dbSmrg	;;
5489b85037dbSmrg
5490b85037dbSmrg      -avoid-version)
5491b85037dbSmrg	avoid_version=yes
5492b85037dbSmrg	continue
5493b85037dbSmrg	;;
5494b85037dbSmrg
5495b85037dbSmrg      -bindir)
5496b85037dbSmrg	prev=bindir
5497b85037dbSmrg	continue
5498b85037dbSmrg	;;
5499b85037dbSmrg
5500b85037dbSmrg      -dlopen)
5501b85037dbSmrg	prev=dlfiles
5502b85037dbSmrg	continue
5503b85037dbSmrg	;;
5504b85037dbSmrg
5505b85037dbSmrg      -dlpreopen)
5506b85037dbSmrg	prev=dlprefiles
5507b85037dbSmrg	continue
5508b85037dbSmrg	;;
5509b85037dbSmrg
5510b85037dbSmrg      -export-dynamic)
5511b85037dbSmrg	export_dynamic=yes
5512b85037dbSmrg	continue
5513b85037dbSmrg	;;
5514b85037dbSmrg
5515b85037dbSmrg      -export-symbols | -export-symbols-regex)
5516b85037dbSmrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
5517b85037dbSmrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
5518b85037dbSmrg	fi
5519b85037dbSmrg	if test "X$arg" = "X-export-symbols"; then
5520b85037dbSmrg	  prev=expsyms
5521b85037dbSmrg	else
5522b85037dbSmrg	  prev=expsyms_regex
5523b85037dbSmrg	fi
5524b85037dbSmrg	continue
5525b85037dbSmrg	;;
5526b85037dbSmrg
5527b85037dbSmrg      -framework)
5528b85037dbSmrg	prev=framework
5529b85037dbSmrg	continue
5530b85037dbSmrg	;;
5531b85037dbSmrg
5532b85037dbSmrg      -inst-prefix-dir)
5533b85037dbSmrg	prev=inst_prefix
5534b85037dbSmrg	continue
5535b85037dbSmrg	;;
5536b85037dbSmrg
5537b85037dbSmrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
5538b85037dbSmrg      # so, if we see these flags be careful not to treat them like -L
5539b85037dbSmrg      -L[A-Z][A-Z]*:*)
5540b85037dbSmrg	case $with_gcc/$host in
5541b85037dbSmrg	no/*-*-irix* | /*-*-irix*)
5542b85037dbSmrg	  func_append compile_command " $arg"
5543b85037dbSmrg	  func_append finalize_command " $arg"
5544b85037dbSmrg	  ;;
5545b85037dbSmrg	esac
5546b85037dbSmrg	continue
5547b85037dbSmrg	;;
5548b85037dbSmrg
5549b85037dbSmrg      -L*)
5550302b15bdSmrg	func_stripname "-L" '' "$arg"
5551302b15bdSmrg	if test -z "$func_stripname_result"; then
5552b85037dbSmrg	  if test "$#" -gt 0; then
5553b85037dbSmrg	    func_fatal_error "require no space between \`-L' and \`$1'"
5554b85037dbSmrg	  else
5555b85037dbSmrg	    func_fatal_error "need path for \`-L' option"
5556b85037dbSmrg	  fi
5557b85037dbSmrg	fi
5558302b15bdSmrg	func_resolve_sysroot "$func_stripname_result"
5559302b15bdSmrg	dir=$func_resolve_sysroot_result
5560b85037dbSmrg	# We need an absolute path.
5561b85037dbSmrg	case $dir in
5562b85037dbSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
5563b85037dbSmrg	*)
5564b85037dbSmrg	  absdir=`cd "$dir" && pwd`
5565b85037dbSmrg	  test -z "$absdir" && \
5566b85037dbSmrg	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
5567b85037dbSmrg	  dir="$absdir"
5568b85037dbSmrg	  ;;
5569b85037dbSmrg	esac
5570b85037dbSmrg	case "$deplibs " in
5571302b15bdSmrg	*" -L$dir "* | *" $arg "*)
5572302b15bdSmrg	  # Will only happen for absolute or sysroot arguments
5573302b15bdSmrg	  ;;
5574b85037dbSmrg	*)
5575302b15bdSmrg	  # Preserve sysroot, but never include relative directories
5576302b15bdSmrg	  case $dir in
5577302b15bdSmrg	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
5578302b15bdSmrg	    *) func_append deplibs " -L$dir" ;;
5579302b15bdSmrg	  esac
5580302b15bdSmrg	  func_append lib_search_path " $dir"
5581b85037dbSmrg	  ;;
5582b85037dbSmrg	esac
5583b85037dbSmrg	case $host in
5584b85037dbSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
5585b85037dbSmrg	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
5586b85037dbSmrg	  case :$dllsearchpath: in
5587b85037dbSmrg	  *":$dir:"*) ;;
5588b85037dbSmrg	  ::) dllsearchpath=$dir;;
5589302b15bdSmrg	  *) func_append dllsearchpath ":$dir";;
5590b85037dbSmrg	  esac
5591b85037dbSmrg	  case :$dllsearchpath: in
5592b85037dbSmrg	  *":$testbindir:"*) ;;
5593b85037dbSmrg	  ::) dllsearchpath=$testbindir;;
5594302b15bdSmrg	  *) func_append dllsearchpath ":$testbindir";;
5595b85037dbSmrg	  esac
5596b85037dbSmrg	  ;;
5597b85037dbSmrg	esac
5598b85037dbSmrg	continue
5599b85037dbSmrg	;;
5600b85037dbSmrg
5601b85037dbSmrg      -l*)
5602b85037dbSmrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
5603b85037dbSmrg	  case $host in
5604b85037dbSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
5605b85037dbSmrg	    # These systems don't actually have a C or math library (as such)
5606b85037dbSmrg	    continue
5607b85037dbSmrg	    ;;
5608b85037dbSmrg	  *-*-os2*)
5609b85037dbSmrg	    # These systems don't actually have a C library (as such)
5610b85037dbSmrg	    test "X$arg" = "X-lc" && continue
5611b85037dbSmrg	    ;;
5612b85037dbSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5613b85037dbSmrg	    # Do not include libc due to us having libc/libc_r.
5614b85037dbSmrg	    test "X$arg" = "X-lc" && continue
5615b85037dbSmrg	    ;;
5616b85037dbSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
5617b85037dbSmrg	    # Rhapsody C and math libraries are in the System framework
5618302b15bdSmrg	    func_append deplibs " System.ltframework"
5619b85037dbSmrg	    continue
5620b85037dbSmrg	    ;;
5621b85037dbSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
5622b85037dbSmrg	    # Causes problems with __ctype
5623b85037dbSmrg	    test "X$arg" = "X-lc" && continue
5624b85037dbSmrg	    ;;
5625b85037dbSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
5626b85037dbSmrg	    # Compiler inserts libc in the correct place for threads to work
5627b85037dbSmrg	    test "X$arg" = "X-lc" && continue
5628b85037dbSmrg	    ;;
5629b85037dbSmrg	  esac
5630b85037dbSmrg	elif test "X$arg" = "X-lc_r"; then
5631b85037dbSmrg	 case $host in
5632b85037dbSmrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5633b85037dbSmrg	   # Do not include libc_r directly, use -pthread flag.
5634b85037dbSmrg	   continue
5635b85037dbSmrg	   ;;
5636b85037dbSmrg	 esac
5637b85037dbSmrg	fi
5638302b15bdSmrg	func_append deplibs " $arg"
5639b85037dbSmrg	continue
5640b85037dbSmrg	;;
5641b85037dbSmrg
5642b85037dbSmrg      -module)
5643b85037dbSmrg	module=yes
5644b85037dbSmrg	continue
5645b85037dbSmrg	;;
5646b85037dbSmrg
5647b85037dbSmrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
5648b85037dbSmrg      # classes, name mangling, and exception handling.
5649b85037dbSmrg      # Darwin uses the -arch flag to determine output architecture.
5650302b15bdSmrg      -model|-arch|-isysroot|--sysroot)
5651302b15bdSmrg	func_append compiler_flags " $arg"
5652b85037dbSmrg	func_append compile_command " $arg"
5653b85037dbSmrg	func_append finalize_command " $arg"
5654b85037dbSmrg	prev=xcompiler
5655b85037dbSmrg	continue
5656b85037dbSmrg	;;
5657b85037dbSmrg
565828515619Smrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
565928515619Smrg      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
5660302b15bdSmrg	func_append compiler_flags " $arg"
5661b85037dbSmrg	func_append compile_command " $arg"
5662b85037dbSmrg	func_append finalize_command " $arg"
5663b85037dbSmrg	case "$new_inherited_linker_flags " in
5664b85037dbSmrg	    *" $arg "*) ;;
5665302b15bdSmrg	    * ) func_append new_inherited_linker_flags " $arg" ;;
5666b85037dbSmrg	esac
5667b85037dbSmrg	continue
5668b85037dbSmrg	;;
5669b85037dbSmrg
5670b85037dbSmrg      -multi_module)
5671b85037dbSmrg	single_module="${wl}-multi_module"
5672b85037dbSmrg	continue
5673b85037dbSmrg	;;
5674b85037dbSmrg
5675b85037dbSmrg      -no-fast-install)
5676b85037dbSmrg	fast_install=no
5677b85037dbSmrg	continue
5678b85037dbSmrg	;;
5679b85037dbSmrg
5680b85037dbSmrg      -no-install)
5681b85037dbSmrg	case $host in
5682b85037dbSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
5683b85037dbSmrg	  # The PATH hackery in wrapper scripts is required on Windows
5684b85037dbSmrg	  # and Darwin in order for the loader to find any dlls it needs.
5685b85037dbSmrg	  func_warning "\`-no-install' is ignored for $host"
5686b85037dbSmrg	  func_warning "assuming \`-no-fast-install' instead"
5687b85037dbSmrg	  fast_install=no
5688b85037dbSmrg	  ;;
5689b85037dbSmrg	*) no_install=yes ;;
5690b85037dbSmrg	esac
5691b85037dbSmrg	continue
5692b85037dbSmrg	;;
5693b85037dbSmrg
5694b85037dbSmrg      -no-undefined)
5695b85037dbSmrg	allow_undefined=no
5696b85037dbSmrg	continue
5697b85037dbSmrg	;;
5698b85037dbSmrg
5699b85037dbSmrg      -objectlist)
5700b85037dbSmrg	prev=objectlist
5701b85037dbSmrg	continue
5702b85037dbSmrg	;;
5703b85037dbSmrg
5704b85037dbSmrg      -o) prev=output ;;
5705b85037dbSmrg
5706b85037dbSmrg      -precious-files-regex)
5707b85037dbSmrg	prev=precious_regex
5708b85037dbSmrg	continue
5709b85037dbSmrg	;;
5710b85037dbSmrg
5711b85037dbSmrg      -release)
5712b85037dbSmrg	prev=release
5713b85037dbSmrg	continue
5714b85037dbSmrg	;;
5715b85037dbSmrg
5716b85037dbSmrg      -rpath)
5717b85037dbSmrg	prev=rpath
5718b85037dbSmrg	continue
5719b85037dbSmrg	;;
5720b85037dbSmrg
5721b85037dbSmrg      -R)
5722b85037dbSmrg	prev=xrpath
5723b85037dbSmrg	continue
5724b85037dbSmrg	;;
5725b85037dbSmrg
5726b85037dbSmrg      -R*)
5727b85037dbSmrg	func_stripname '-R' '' "$arg"
5728b85037dbSmrg	dir=$func_stripname_result
5729b85037dbSmrg	# We need an absolute path.
5730b85037dbSmrg	case $dir in
5731b85037dbSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
5732302b15bdSmrg	=*)
5733302b15bdSmrg	  func_stripname '=' '' "$dir"
5734302b15bdSmrg	  dir=$lt_sysroot$func_stripname_result
5735302b15bdSmrg	  ;;
5736b85037dbSmrg	*)
5737b85037dbSmrg	  func_fatal_error "only absolute run-paths are allowed"
5738b85037dbSmrg	  ;;
5739b85037dbSmrg	esac
5740b85037dbSmrg	case "$xrpath " in
5741b85037dbSmrg	*" $dir "*) ;;
5742302b15bdSmrg	*) func_append xrpath " $dir" ;;
5743b85037dbSmrg	esac
5744b85037dbSmrg	continue
5745b85037dbSmrg	;;
5746b85037dbSmrg
5747b85037dbSmrg      -shared)
5748b85037dbSmrg	# The effects of -shared are defined in a previous loop.
5749b85037dbSmrg	continue
5750b85037dbSmrg	;;
5751b85037dbSmrg
5752b85037dbSmrg      -shrext)
5753b85037dbSmrg	prev=shrext
5754b85037dbSmrg	continue
5755b85037dbSmrg	;;
5756b85037dbSmrg
5757b85037dbSmrg      -static | -static-libtool-libs)
5758b85037dbSmrg	# The effects of -static are defined in a previous loop.
5759b85037dbSmrg	# We used to do the same as -all-static on platforms that
5760b85037dbSmrg	# didn't have a PIC flag, but the assumption that the effects
5761b85037dbSmrg	# would be equivalent was wrong.  It would break on at least
5762b85037dbSmrg	# Digital Unix and AIX.
5763b85037dbSmrg	continue
5764b85037dbSmrg	;;
5765b85037dbSmrg
5766b85037dbSmrg      -thread-safe)
5767b85037dbSmrg	thread_safe=yes
5768b85037dbSmrg	continue
5769b85037dbSmrg	;;
5770b85037dbSmrg
5771b85037dbSmrg      -version-info)
5772b85037dbSmrg	prev=vinfo
5773b85037dbSmrg	continue
5774b85037dbSmrg	;;
5775b85037dbSmrg
5776b85037dbSmrg      -version-number)
5777b85037dbSmrg	prev=vinfo
5778b85037dbSmrg	vinfo_number=yes
5779b85037dbSmrg	continue
5780b85037dbSmrg	;;
5781b85037dbSmrg
5782b85037dbSmrg      -weak)
5783b85037dbSmrg        prev=weak
5784b85037dbSmrg	continue
5785b85037dbSmrg	;;
5786b85037dbSmrg
5787b85037dbSmrg      -Wc,*)
5788b85037dbSmrg	func_stripname '-Wc,' '' "$arg"
5789b85037dbSmrg	args=$func_stripname_result
5790b85037dbSmrg	arg=
5791b85037dbSmrg	save_ifs="$IFS"; IFS=','
5792b85037dbSmrg	for flag in $args; do
5793b85037dbSmrg	  IFS="$save_ifs"
5794b85037dbSmrg          func_quote_for_eval "$flag"
5795302b15bdSmrg	  func_append arg " $func_quote_for_eval_result"
5796302b15bdSmrg	  func_append compiler_flags " $func_quote_for_eval_result"
5797b85037dbSmrg	done
5798b85037dbSmrg	IFS="$save_ifs"
5799b85037dbSmrg	func_stripname ' ' '' "$arg"
5800b85037dbSmrg	arg=$func_stripname_result
5801b85037dbSmrg	;;
5802b85037dbSmrg
5803b85037dbSmrg      -Wl,*)
5804b85037dbSmrg	func_stripname '-Wl,' '' "$arg"
5805b85037dbSmrg	args=$func_stripname_result
5806b85037dbSmrg	arg=
5807b85037dbSmrg	save_ifs="$IFS"; IFS=','
5808b85037dbSmrg	for flag in $args; do
5809b85037dbSmrg	  IFS="$save_ifs"
5810b85037dbSmrg          func_quote_for_eval "$flag"
5811302b15bdSmrg	  func_append arg " $wl$func_quote_for_eval_result"
5812302b15bdSmrg	  func_append compiler_flags " $wl$func_quote_for_eval_result"
5813302b15bdSmrg	  func_append linker_flags " $func_quote_for_eval_result"
5814b85037dbSmrg	done
5815b85037dbSmrg	IFS="$save_ifs"
5816b85037dbSmrg	func_stripname ' ' '' "$arg"
5817b85037dbSmrg	arg=$func_stripname_result
5818b85037dbSmrg	;;
5819b85037dbSmrg
5820b85037dbSmrg      -Xcompiler)
5821b85037dbSmrg	prev=xcompiler
5822b85037dbSmrg	continue
5823b85037dbSmrg	;;
5824b85037dbSmrg
5825b85037dbSmrg      -Xlinker)
5826b85037dbSmrg	prev=xlinker
5827b85037dbSmrg	continue
5828b85037dbSmrg	;;
5829b85037dbSmrg
5830b85037dbSmrg      -XCClinker)
5831b85037dbSmrg	prev=xcclinker
5832b85037dbSmrg	continue
5833b85037dbSmrg	;;
5834b85037dbSmrg
5835b85037dbSmrg      # -msg_* for osf cc
5836b85037dbSmrg      -msg_*)
5837b85037dbSmrg	func_quote_for_eval "$arg"
5838b85037dbSmrg	arg="$func_quote_for_eval_result"
5839b85037dbSmrg	;;
5840b85037dbSmrg
5841b85037dbSmrg      # Flags to be passed through unchanged, with rationale:
5842b85037dbSmrg      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
5843b85037dbSmrg      # -r[0-9][0-9]*        specify processor for the SGI compiler
5844b85037dbSmrg      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
5845b85037dbSmrg      # +DA*, +DD*           enable 64-bit mode for the HP compiler
5846b85037dbSmrg      # -q*                  compiler args for the IBM compiler
5847b85037dbSmrg      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
5848b85037dbSmrg      # -F/path              path to uninstalled frameworks, gcc on darwin
5849b85037dbSmrg      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
5850b85037dbSmrg      # @file                GCC response files
5851b85037dbSmrg      # -tp=*                Portland pgcc target processor selection
5852302b15bdSmrg      # --sysroot=*          for sysroot support
5853302b15bdSmrg      # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
5854b85037dbSmrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
5855302b15bdSmrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
5856302b15bdSmrg      -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
5857b85037dbSmrg        func_quote_for_eval "$arg"
5858b85037dbSmrg	arg="$func_quote_for_eval_result"
5859b85037dbSmrg        func_append compile_command " $arg"
5860b85037dbSmrg        func_append finalize_command " $arg"
5861302b15bdSmrg        func_append compiler_flags " $arg"
5862b85037dbSmrg        continue
5863b85037dbSmrg        ;;
5864b85037dbSmrg
5865b85037dbSmrg      # Some other compiler flag.
5866b85037dbSmrg      -* | +*)
5867b85037dbSmrg        func_quote_for_eval "$arg"
5868b85037dbSmrg	arg="$func_quote_for_eval_result"
5869b85037dbSmrg	;;
5870b85037dbSmrg
5871b85037dbSmrg      *.$objext)
5872b85037dbSmrg	# A standard object.
5873302b15bdSmrg	func_append objs " $arg"
5874b85037dbSmrg	;;
5875b85037dbSmrg
5876b85037dbSmrg      *.lo)
5877b85037dbSmrg	# A libtool-controlled object.
5878b85037dbSmrg
5879b85037dbSmrg	# Check to see that this really is a libtool object.
5880b85037dbSmrg	if func_lalib_unsafe_p "$arg"; then
5881b85037dbSmrg	  pic_object=
5882b85037dbSmrg	  non_pic_object=
5883b85037dbSmrg
5884b85037dbSmrg	  # Read the .lo file
5885b85037dbSmrg	  func_source "$arg"
5886b85037dbSmrg
5887b85037dbSmrg	  if test -z "$pic_object" ||
5888b85037dbSmrg	     test -z "$non_pic_object" ||
5889b85037dbSmrg	     test "$pic_object" = none &&
5890b85037dbSmrg	     test "$non_pic_object" = none; then
5891b85037dbSmrg	    func_fatal_error "cannot find name of object for \`$arg'"
5892b85037dbSmrg	  fi
5893b85037dbSmrg
5894b85037dbSmrg	  # Extract subdirectory from the argument.
5895b85037dbSmrg	  func_dirname "$arg" "/" ""
5896b85037dbSmrg	  xdir="$func_dirname_result"
5897b85037dbSmrg
5898b85037dbSmrg	  if test "$pic_object" != none; then
5899b85037dbSmrg	    # Prepend the subdirectory the object is found in.
5900b85037dbSmrg	    pic_object="$xdir$pic_object"
5901b85037dbSmrg
5902b85037dbSmrg	    if test "$prev" = dlfiles; then
5903b85037dbSmrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5904302b15bdSmrg		func_append dlfiles " $pic_object"
5905b85037dbSmrg		prev=
5906b85037dbSmrg		continue
5907b85037dbSmrg	      else
5908b85037dbSmrg		# If libtool objects are unsupported, then we need to preload.
5909b85037dbSmrg		prev=dlprefiles
5910b85037dbSmrg	      fi
5911b85037dbSmrg	    fi
5912b85037dbSmrg
5913b85037dbSmrg	    # CHECK ME:  I think I busted this.  -Ossama
5914b85037dbSmrg	    if test "$prev" = dlprefiles; then
5915b85037dbSmrg	      # Preload the old-style object.
5916302b15bdSmrg	      func_append dlprefiles " $pic_object"
5917b85037dbSmrg	      prev=
5918b85037dbSmrg	    fi
5919b85037dbSmrg
5920b85037dbSmrg	    # A PIC object.
5921b85037dbSmrg	    func_append libobjs " $pic_object"
5922b85037dbSmrg	    arg="$pic_object"
5923b85037dbSmrg	  fi
5924b85037dbSmrg
5925b85037dbSmrg	  # Non-PIC object.
5926b85037dbSmrg	  if test "$non_pic_object" != none; then
5927b85037dbSmrg	    # Prepend the subdirectory the object is found in.
5928b85037dbSmrg	    non_pic_object="$xdir$non_pic_object"
5929b85037dbSmrg
5930b85037dbSmrg	    # A standard non-PIC object
5931b85037dbSmrg	    func_append non_pic_objects " $non_pic_object"
5932b85037dbSmrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
5933b85037dbSmrg	      arg="$non_pic_object"
5934b85037dbSmrg	    fi
5935b85037dbSmrg	  else
5936b85037dbSmrg	    # If the PIC object exists, use it instead.
5937b85037dbSmrg	    # $xdir was prepended to $pic_object above.
5938b85037dbSmrg	    non_pic_object="$pic_object"
5939b85037dbSmrg	    func_append non_pic_objects " $non_pic_object"
5940b85037dbSmrg	  fi
5941b85037dbSmrg	else
5942b85037dbSmrg	  # Only an error if not doing a dry-run.
5943b85037dbSmrg	  if $opt_dry_run; then
5944b85037dbSmrg	    # Extract subdirectory from the argument.
5945b85037dbSmrg	    func_dirname "$arg" "/" ""
5946b85037dbSmrg	    xdir="$func_dirname_result"
5947b85037dbSmrg
5948b85037dbSmrg	    func_lo2o "$arg"
5949b85037dbSmrg	    pic_object=$xdir$objdir/$func_lo2o_result
5950b85037dbSmrg	    non_pic_object=$xdir$func_lo2o_result
5951b85037dbSmrg	    func_append libobjs " $pic_object"
5952b85037dbSmrg	    func_append non_pic_objects " $non_pic_object"
5953b85037dbSmrg	  else
5954b85037dbSmrg	    func_fatal_error "\`$arg' is not a valid libtool object"
5955b85037dbSmrg	  fi
5956b85037dbSmrg	fi
5957b85037dbSmrg	;;
5958b85037dbSmrg
5959b85037dbSmrg      *.$libext)
5960b85037dbSmrg	# An archive.
5961302b15bdSmrg	func_append deplibs " $arg"
5962302b15bdSmrg	func_append old_deplibs " $arg"
5963b85037dbSmrg	continue
5964b85037dbSmrg	;;
5965b85037dbSmrg
5966b85037dbSmrg      *.la)
5967b85037dbSmrg	# A libtool-controlled library.
5968b85037dbSmrg
5969302b15bdSmrg	func_resolve_sysroot "$arg"
5970b85037dbSmrg	if test "$prev" = dlfiles; then
5971b85037dbSmrg	  # This library was specified with -dlopen.
5972302b15bdSmrg	  func_append dlfiles " $func_resolve_sysroot_result"
5973b85037dbSmrg	  prev=
5974b85037dbSmrg	elif test "$prev" = dlprefiles; then
5975b85037dbSmrg	  # The library was specified with -dlpreopen.
5976302b15bdSmrg	  func_append dlprefiles " $func_resolve_sysroot_result"
5977b85037dbSmrg	  prev=
5978b85037dbSmrg	else
5979302b15bdSmrg	  func_append deplibs " $func_resolve_sysroot_result"
5980b85037dbSmrg	fi
5981b85037dbSmrg	continue
5982b85037dbSmrg	;;
5983b85037dbSmrg
5984b85037dbSmrg      # Some other compiler argument.
5985b85037dbSmrg      *)
5986b85037dbSmrg	# Unknown arguments in both finalize_command and compile_command need
5987b85037dbSmrg	# to be aesthetically quoted because they are evaled later.
5988b85037dbSmrg	func_quote_for_eval "$arg"
5989b85037dbSmrg	arg="$func_quote_for_eval_result"
5990b85037dbSmrg	;;
5991b85037dbSmrg      esac # arg
5992b85037dbSmrg
5993b85037dbSmrg      # Now actually substitute the argument into the commands.
5994b85037dbSmrg      if test -n "$arg"; then
5995b85037dbSmrg	func_append compile_command " $arg"
5996b85037dbSmrg	func_append finalize_command " $arg"
5997b85037dbSmrg      fi
5998b85037dbSmrg    done # argument parsing loop
5999b85037dbSmrg
6000b85037dbSmrg    test -n "$prev" && \
6001b85037dbSmrg      func_fatal_help "the \`$prevarg' option requires an argument"
6002b85037dbSmrg
6003b85037dbSmrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
6004b85037dbSmrg      eval arg=\"$export_dynamic_flag_spec\"
6005b85037dbSmrg      func_append compile_command " $arg"
6006b85037dbSmrg      func_append finalize_command " $arg"
6007b85037dbSmrg    fi
6008b85037dbSmrg
6009b85037dbSmrg    oldlibs=
6010b85037dbSmrg    # calculate the name of the file, without its directory
6011b85037dbSmrg    func_basename "$output"
6012b85037dbSmrg    outputname="$func_basename_result"
6013b85037dbSmrg    libobjs_save="$libobjs"
6014b85037dbSmrg
6015b85037dbSmrg    if test -n "$shlibpath_var"; then
6016b85037dbSmrg      # get the directories listed in $shlibpath_var
6017b85037dbSmrg      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
6018b85037dbSmrg    else
6019b85037dbSmrg      shlib_search_path=
6020b85037dbSmrg    fi
6021b85037dbSmrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
6022b85037dbSmrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
6023b85037dbSmrg
6024b85037dbSmrg    func_dirname "$output" "/" ""
6025b85037dbSmrg    output_objdir="$func_dirname_result$objdir"
6026302b15bdSmrg    func_to_tool_file "$output_objdir/"
6027302b15bdSmrg    tool_output_objdir=$func_to_tool_file_result
6028b85037dbSmrg    # Create the object directory.
6029b85037dbSmrg    func_mkdir_p "$output_objdir"
6030b85037dbSmrg
6031b85037dbSmrg    # Determine the type of output
6032b85037dbSmrg    case $output in
6033b85037dbSmrg    "")
6034b85037dbSmrg      func_fatal_help "you must specify an output file"
6035b85037dbSmrg      ;;
6036b85037dbSmrg    *.$libext) linkmode=oldlib ;;
6037b85037dbSmrg    *.lo | *.$objext) linkmode=obj ;;
6038b85037dbSmrg    *.la) linkmode=lib ;;
6039b85037dbSmrg    *) linkmode=prog ;; # Anything else should be a program.
6040b85037dbSmrg    esac
6041b85037dbSmrg
6042b85037dbSmrg    specialdeplibs=
6043b85037dbSmrg
6044b85037dbSmrg    libs=
6045b85037dbSmrg    # Find all interdependent deplibs by searching for libraries
6046b85037dbSmrg    # that are linked more than once (e.g. -la -lb -la)
6047b85037dbSmrg    for deplib in $deplibs; do
6048302b15bdSmrg      if $opt_preserve_dup_deps ; then
6049b85037dbSmrg	case "$libs " in
6050302b15bdSmrg	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
6051b85037dbSmrg	esac
6052b85037dbSmrg      fi
6053302b15bdSmrg      func_append libs " $deplib"
6054b85037dbSmrg    done
6055b85037dbSmrg
6056b85037dbSmrg    if test "$linkmode" = lib; then
6057b85037dbSmrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
6058b85037dbSmrg
6059b85037dbSmrg      # Compute libraries that are listed more than once in $predeps
6060b85037dbSmrg      # $postdeps and mark them as special (i.e., whose duplicates are
6061b85037dbSmrg      # not to be eliminated).
6062b85037dbSmrg      pre_post_deps=
6063b85037dbSmrg      if $opt_duplicate_compiler_generated_deps; then
6064b85037dbSmrg	for pre_post_dep in $predeps $postdeps; do
6065b85037dbSmrg	  case "$pre_post_deps " in
6066302b15bdSmrg	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
6067b85037dbSmrg	  esac
6068302b15bdSmrg	  func_append pre_post_deps " $pre_post_dep"
6069b85037dbSmrg	done
6070b85037dbSmrg      fi
6071b85037dbSmrg      pre_post_deps=
6072b85037dbSmrg    fi
6073b85037dbSmrg
6074b85037dbSmrg    deplibs=
6075b85037dbSmrg    newdependency_libs=
6076b85037dbSmrg    newlib_search_path=
6077b85037dbSmrg    need_relink=no # whether we're linking any uninstalled libtool libraries
6078b85037dbSmrg    notinst_deplibs= # not-installed libtool libraries
6079b85037dbSmrg    notinst_path= # paths that contain not-installed libtool libraries
6080b85037dbSmrg
6081b85037dbSmrg    case $linkmode in
6082b85037dbSmrg    lib)
6083b85037dbSmrg	passes="conv dlpreopen link"
6084b85037dbSmrg	for file in $dlfiles $dlprefiles; do
6085b85037dbSmrg	  case $file in
6086b85037dbSmrg	  *.la) ;;
6087b85037dbSmrg	  *)
6088b85037dbSmrg	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
6089b85037dbSmrg	    ;;
6090b85037dbSmrg	  esac
6091b85037dbSmrg	done
6092b85037dbSmrg	;;
6093b85037dbSmrg    prog)
6094b85037dbSmrg	compile_deplibs=
6095b85037dbSmrg	finalize_deplibs=
6096b85037dbSmrg	alldeplibs=no
6097b85037dbSmrg	newdlfiles=
6098b85037dbSmrg	newdlprefiles=
6099b85037dbSmrg	passes="conv scan dlopen dlpreopen link"
6100b85037dbSmrg	;;
6101b85037dbSmrg    *)  passes="conv"
6102b85037dbSmrg	;;
6103b85037dbSmrg    esac
6104b85037dbSmrg
6105b85037dbSmrg    for pass in $passes; do
6106b85037dbSmrg      # The preopen pass in lib mode reverses $deplibs; put it back here
6107b85037dbSmrg      # so that -L comes before libs that need it for instance...
6108b85037dbSmrg      if test "$linkmode,$pass" = "lib,link"; then
6109b85037dbSmrg	## FIXME: Find the place where the list is rebuilt in the wrong
6110b85037dbSmrg	##        order, and fix it there properly
6111b85037dbSmrg        tmp_deplibs=
6112b85037dbSmrg	for deplib in $deplibs; do
6113b85037dbSmrg	  tmp_deplibs="$deplib $tmp_deplibs"
6114b85037dbSmrg	done
6115b85037dbSmrg	deplibs="$tmp_deplibs"
6116b85037dbSmrg      fi
6117b85037dbSmrg
6118b85037dbSmrg      if test "$linkmode,$pass" = "lib,link" ||
6119b85037dbSmrg	 test "$linkmode,$pass" = "prog,scan"; then
6120b85037dbSmrg	libs="$deplibs"
6121b85037dbSmrg	deplibs=
6122b85037dbSmrg      fi
6123b85037dbSmrg      if test "$linkmode" = prog; then
6124b85037dbSmrg	case $pass in
6125b85037dbSmrg	dlopen) libs="$dlfiles" ;;
6126b85037dbSmrg	dlpreopen) libs="$dlprefiles" ;;
6127b85037dbSmrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
6128b85037dbSmrg	esac
6129b85037dbSmrg      fi
6130b85037dbSmrg      if test "$linkmode,$pass" = "lib,dlpreopen"; then
6131b85037dbSmrg	# Collect and forward deplibs of preopened libtool libs
6132b85037dbSmrg	for lib in $dlprefiles; do
6133b85037dbSmrg	  # Ignore non-libtool-libs
6134b85037dbSmrg	  dependency_libs=
6135302b15bdSmrg	  func_resolve_sysroot "$lib"
6136b85037dbSmrg	  case $lib in
6137302b15bdSmrg	  *.la)	func_source "$func_resolve_sysroot_result" ;;
6138b85037dbSmrg	  esac
6139b85037dbSmrg
6140b85037dbSmrg	  # Collect preopened libtool deplibs, except any this library
6141b85037dbSmrg	  # has declared as weak libs
6142b85037dbSmrg	  for deplib in $dependency_libs; do
6143b85037dbSmrg	    func_basename "$deplib"
6144b85037dbSmrg            deplib_base=$func_basename_result
6145b85037dbSmrg	    case " $weak_libs " in
6146b85037dbSmrg	    *" $deplib_base "*) ;;
6147302b15bdSmrg	    *) func_append deplibs " $deplib" ;;
6148b85037dbSmrg	    esac
6149b85037dbSmrg	  done
6150b85037dbSmrg	done
6151b85037dbSmrg	libs="$dlprefiles"
6152b85037dbSmrg      fi
6153b85037dbSmrg      if test "$pass" = dlopen; then
6154b85037dbSmrg	# Collect dlpreopened libraries
6155b85037dbSmrg	save_deplibs="$deplibs"
6156b85037dbSmrg	deplibs=
6157b85037dbSmrg      fi
6158b85037dbSmrg
6159b85037dbSmrg      for deplib in $libs; do
6160b85037dbSmrg	lib=
6161b85037dbSmrg	found=no
6162b85037dbSmrg	case $deplib in
616328515619Smrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
616428515619Smrg        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
6165b85037dbSmrg	  if test "$linkmode,$pass" = "prog,link"; then
6166b85037dbSmrg	    compile_deplibs="$deplib $compile_deplibs"
6167b85037dbSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
6168b85037dbSmrg	  else
6169302b15bdSmrg	    func_append compiler_flags " $deplib"
6170b85037dbSmrg	    if test "$linkmode" = lib ; then
6171b85037dbSmrg		case "$new_inherited_linker_flags " in
6172b85037dbSmrg		    *" $deplib "*) ;;
6173302b15bdSmrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
6174b85037dbSmrg		esac
6175b85037dbSmrg	    fi
6176b85037dbSmrg	  fi
6177b85037dbSmrg	  continue
6178b85037dbSmrg	  ;;
6179b85037dbSmrg	-l*)
6180b85037dbSmrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
6181b85037dbSmrg	    func_warning "\`-l' is ignored for archives/objects"
6182b85037dbSmrg	    continue
6183b85037dbSmrg	  fi
6184b85037dbSmrg	  func_stripname '-l' '' "$deplib"
6185b85037dbSmrg	  name=$func_stripname_result
6186b85037dbSmrg	  if test "$linkmode" = lib; then
6187b85037dbSmrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
6188b85037dbSmrg	  else
6189b85037dbSmrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
6190b85037dbSmrg	  fi
6191b85037dbSmrg	  for searchdir in $searchdirs; do
6192b85037dbSmrg	    for search_ext in .la $std_shrext .so .a; do
6193b85037dbSmrg	      # Search the libtool library
6194b85037dbSmrg	      lib="$searchdir/lib${name}${search_ext}"
6195b85037dbSmrg	      if test -f "$lib"; then
6196b85037dbSmrg		if test "$search_ext" = ".la"; then
6197b85037dbSmrg		  found=yes
6198b85037dbSmrg		else
6199b85037dbSmrg		  found=no
6200b85037dbSmrg		fi
6201b85037dbSmrg		break 2
6202b85037dbSmrg	      fi
6203b85037dbSmrg	    done
6204b85037dbSmrg	  done
6205b85037dbSmrg	  if test "$found" != yes; then
6206b85037dbSmrg	    # deplib doesn't seem to be a libtool library
6207b85037dbSmrg	    if test "$linkmode,$pass" = "prog,link"; then
6208b85037dbSmrg	      compile_deplibs="$deplib $compile_deplibs"
6209b85037dbSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
6210b85037dbSmrg	    else
6211b85037dbSmrg	      deplibs="$deplib $deplibs"
6212b85037dbSmrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6213b85037dbSmrg	    fi
6214b85037dbSmrg	    continue
6215b85037dbSmrg	  else # deplib is a libtool library
6216b85037dbSmrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
6217b85037dbSmrg	    # We need to do some special things here, and not later.
6218b85037dbSmrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6219b85037dbSmrg	      case " $predeps $postdeps " in
6220b85037dbSmrg	      *" $deplib "*)
6221b85037dbSmrg		if func_lalib_p "$lib"; then
6222b85037dbSmrg		  library_names=
6223b85037dbSmrg		  old_library=
6224b85037dbSmrg		  func_source "$lib"
6225b85037dbSmrg		  for l in $old_library $library_names; do
6226b85037dbSmrg		    ll="$l"
6227b85037dbSmrg		  done
6228b85037dbSmrg		  if test "X$ll" = "X$old_library" ; then # only static version available
6229b85037dbSmrg		    found=no
6230b85037dbSmrg		    func_dirname "$lib" "" "."
6231b85037dbSmrg		    ladir="$func_dirname_result"
6232b85037dbSmrg		    lib=$ladir/$old_library
6233b85037dbSmrg		    if test "$linkmode,$pass" = "prog,link"; then
6234b85037dbSmrg		      compile_deplibs="$deplib $compile_deplibs"
6235b85037dbSmrg		      finalize_deplibs="$deplib $finalize_deplibs"
6236b85037dbSmrg		    else
6237b85037dbSmrg		      deplibs="$deplib $deplibs"
6238b85037dbSmrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6239b85037dbSmrg		    fi
6240b85037dbSmrg		    continue
6241b85037dbSmrg		  fi
6242b85037dbSmrg		fi
6243b85037dbSmrg		;;
6244b85037dbSmrg	      *) ;;
6245b85037dbSmrg	      esac
6246b85037dbSmrg	    fi
6247b85037dbSmrg	  fi
6248b85037dbSmrg	  ;; # -l
6249b85037dbSmrg	*.ltframework)
6250b85037dbSmrg	  if test "$linkmode,$pass" = "prog,link"; then
6251b85037dbSmrg	    compile_deplibs="$deplib $compile_deplibs"
6252b85037dbSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
6253b85037dbSmrg	  else
6254b85037dbSmrg	    deplibs="$deplib $deplibs"
6255b85037dbSmrg	    if test "$linkmode" = lib ; then
6256b85037dbSmrg		case "$new_inherited_linker_flags " in
6257b85037dbSmrg		    *" $deplib "*) ;;
6258302b15bdSmrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
6259b85037dbSmrg		esac
6260b85037dbSmrg	    fi
6261b85037dbSmrg	  fi
6262b85037dbSmrg	  continue
6263b85037dbSmrg	  ;;
6264b85037dbSmrg	-L*)
6265b85037dbSmrg	  case $linkmode in
6266b85037dbSmrg	  lib)
6267b85037dbSmrg	    deplibs="$deplib $deplibs"
6268b85037dbSmrg	    test "$pass" = conv && continue
6269b85037dbSmrg	    newdependency_libs="$deplib $newdependency_libs"
6270b85037dbSmrg	    func_stripname '-L' '' "$deplib"
6271302b15bdSmrg	    func_resolve_sysroot "$func_stripname_result"
6272302b15bdSmrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
6273b85037dbSmrg	    ;;
6274b85037dbSmrg	  prog)
6275b85037dbSmrg	    if test "$pass" = conv; then
6276b85037dbSmrg	      deplibs="$deplib $deplibs"
6277b85037dbSmrg	      continue
6278b85037dbSmrg	    fi
6279b85037dbSmrg	    if test "$pass" = scan; then
6280b85037dbSmrg	      deplibs="$deplib $deplibs"
6281b85037dbSmrg	    else
6282b85037dbSmrg	      compile_deplibs="$deplib $compile_deplibs"
6283b85037dbSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
6284b85037dbSmrg	    fi
6285b85037dbSmrg	    func_stripname '-L' '' "$deplib"
6286302b15bdSmrg	    func_resolve_sysroot "$func_stripname_result"
6287302b15bdSmrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
6288b85037dbSmrg	    ;;
6289b85037dbSmrg	  *)
6290b85037dbSmrg	    func_warning "\`-L' is ignored for archives/objects"
6291b85037dbSmrg	    ;;
6292b85037dbSmrg	  esac # linkmode
6293b85037dbSmrg	  continue
6294b85037dbSmrg	  ;; # -L
6295b85037dbSmrg	-R*)
6296b85037dbSmrg	  if test "$pass" = link; then
6297b85037dbSmrg	    func_stripname '-R' '' "$deplib"
6298302b15bdSmrg	    func_resolve_sysroot "$func_stripname_result"
6299302b15bdSmrg	    dir=$func_resolve_sysroot_result
6300b85037dbSmrg	    # Make sure the xrpath contains only unique directories.
6301b85037dbSmrg	    case "$xrpath " in
6302b85037dbSmrg	    *" $dir "*) ;;
6303302b15bdSmrg	    *) func_append xrpath " $dir" ;;
6304b85037dbSmrg	    esac
6305b85037dbSmrg	  fi
6306b85037dbSmrg	  deplibs="$deplib $deplibs"
6307b85037dbSmrg	  continue
6308b85037dbSmrg	  ;;
6309302b15bdSmrg	*.la)
6310302b15bdSmrg	  func_resolve_sysroot "$deplib"
6311302b15bdSmrg	  lib=$func_resolve_sysroot_result
6312302b15bdSmrg	  ;;
6313b85037dbSmrg	*.$libext)
6314b85037dbSmrg	  if test "$pass" = conv; then
6315b85037dbSmrg	    deplibs="$deplib $deplibs"
6316b85037dbSmrg	    continue
6317b85037dbSmrg	  fi
6318b85037dbSmrg	  case $linkmode in
6319b85037dbSmrg	  lib)
6320b85037dbSmrg	    # Linking convenience modules into shared libraries is allowed,
6321b85037dbSmrg	    # but linking other static libraries is non-portable.
6322b85037dbSmrg	    case " $dlpreconveniencelibs " in
6323b85037dbSmrg	    *" $deplib "*) ;;
6324b85037dbSmrg	    *)
6325b85037dbSmrg	      valid_a_lib=no
6326b85037dbSmrg	      case $deplibs_check_method in
6327b85037dbSmrg		match_pattern*)
6328b85037dbSmrg		  set dummy $deplibs_check_method; shift
6329b85037dbSmrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6330b85037dbSmrg		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
6331b85037dbSmrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
6332b85037dbSmrg		    valid_a_lib=yes
6333b85037dbSmrg		  fi
6334b85037dbSmrg		;;
6335b85037dbSmrg		pass_all)
6336b85037dbSmrg		  valid_a_lib=yes
6337b85037dbSmrg		;;
6338b85037dbSmrg	      esac
6339b85037dbSmrg	      if test "$valid_a_lib" != yes; then
6340b85037dbSmrg		echo
6341b85037dbSmrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
6342b85037dbSmrg		echo "*** I have the capability to make that library automatically link in when"
6343b85037dbSmrg		echo "*** you link to this library.  But I can only do this if you have a"
6344b85037dbSmrg		echo "*** shared version of the library, which you do not appear to have"
6345b85037dbSmrg		echo "*** because the file extensions .$libext of this argument makes me believe"
6346b85037dbSmrg		echo "*** that it is just a static archive that I should not use here."
6347b85037dbSmrg	      else
6348b85037dbSmrg		echo
6349b85037dbSmrg		$ECHO "*** Warning: Linking the shared library $output against the"
6350b85037dbSmrg		$ECHO "*** static library $deplib is not portable!"
6351b85037dbSmrg		deplibs="$deplib $deplibs"
6352b85037dbSmrg	      fi
6353b85037dbSmrg	      ;;
6354b85037dbSmrg	    esac
6355b85037dbSmrg	    continue
6356b85037dbSmrg	    ;;
6357b85037dbSmrg	  prog)
6358b85037dbSmrg	    if test "$pass" != link; then
6359b85037dbSmrg	      deplibs="$deplib $deplibs"
6360b85037dbSmrg	    else
6361b85037dbSmrg	      compile_deplibs="$deplib $compile_deplibs"
6362b85037dbSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
6363b85037dbSmrg	    fi
6364b85037dbSmrg	    continue
6365b85037dbSmrg	    ;;
6366b85037dbSmrg	  esac # linkmode
6367b85037dbSmrg	  ;; # *.$libext
6368b85037dbSmrg	*.lo | *.$objext)
6369b85037dbSmrg	  if test "$pass" = conv; then
6370b85037dbSmrg	    deplibs="$deplib $deplibs"
6371b85037dbSmrg	  elif test "$linkmode" = prog; then
6372b85037dbSmrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
6373b85037dbSmrg	      # If there is no dlopen support or we're linking statically,
6374b85037dbSmrg	      # we need to preload.
6375302b15bdSmrg	      func_append newdlprefiles " $deplib"
6376b85037dbSmrg	      compile_deplibs="$deplib $compile_deplibs"
6377b85037dbSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
6378b85037dbSmrg	    else
6379302b15bdSmrg	      func_append newdlfiles " $deplib"
6380b85037dbSmrg	    fi
6381b85037dbSmrg	  fi
6382b85037dbSmrg	  continue
6383b85037dbSmrg	  ;;
6384b85037dbSmrg	%DEPLIBS%)
6385b85037dbSmrg	  alldeplibs=yes
6386b85037dbSmrg	  continue
6387b85037dbSmrg	  ;;
6388b85037dbSmrg	esac # case $deplib
6389b85037dbSmrg
6390b85037dbSmrg	if test "$found" = yes || test -f "$lib"; then :
6391b85037dbSmrg	else
6392b85037dbSmrg	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
6393b85037dbSmrg	fi
6394b85037dbSmrg
6395b85037dbSmrg	# Check to see that this really is a libtool archive.
6396b85037dbSmrg	func_lalib_unsafe_p "$lib" \
6397b85037dbSmrg	  || func_fatal_error "\`$lib' is not a valid libtool archive"
6398b85037dbSmrg
6399b85037dbSmrg	func_dirname "$lib" "" "."
6400b85037dbSmrg	ladir="$func_dirname_result"
6401b85037dbSmrg
6402b85037dbSmrg	dlname=
6403b85037dbSmrg	dlopen=
6404b85037dbSmrg	dlpreopen=
6405b85037dbSmrg	libdir=
6406b85037dbSmrg	library_names=
6407b85037dbSmrg	old_library=
6408b85037dbSmrg	inherited_linker_flags=
6409b85037dbSmrg	# If the library was installed with an old release of libtool,
6410b85037dbSmrg	# it will not redefine variables installed, or shouldnotlink
6411b85037dbSmrg	installed=yes
6412b85037dbSmrg	shouldnotlink=no
6413b85037dbSmrg	avoidtemprpath=
6414b85037dbSmrg
6415b85037dbSmrg
6416b85037dbSmrg	# Read the .la file
6417b85037dbSmrg	func_source "$lib"
6418b85037dbSmrg
6419b85037dbSmrg	# Convert "-framework foo" to "foo.ltframework"
6420b85037dbSmrg	if test -n "$inherited_linker_flags"; then
6421b85037dbSmrg	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
6422b85037dbSmrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
6423b85037dbSmrg	    case " $new_inherited_linker_flags " in
6424b85037dbSmrg	      *" $tmp_inherited_linker_flag "*) ;;
6425302b15bdSmrg	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
6426b85037dbSmrg	    esac
6427b85037dbSmrg	  done
6428b85037dbSmrg	fi
6429b85037dbSmrg	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
6430b85037dbSmrg	if test "$linkmode,$pass" = "lib,link" ||
6431b85037dbSmrg	   test "$linkmode,$pass" = "prog,scan" ||
6432b85037dbSmrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
6433302b15bdSmrg	  test -n "$dlopen" && func_append dlfiles " $dlopen"
6434302b15bdSmrg	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
6435b85037dbSmrg	fi
6436b85037dbSmrg
6437b85037dbSmrg	if test "$pass" = conv; then
6438b85037dbSmrg	  # Only check for convenience libraries
6439b85037dbSmrg	  deplibs="$lib $deplibs"
6440b85037dbSmrg	  if test -z "$libdir"; then
6441b85037dbSmrg	    if test -z "$old_library"; then
6442b85037dbSmrg	      func_fatal_error "cannot find name of link library for \`$lib'"
6443b85037dbSmrg	    fi
6444b85037dbSmrg	    # It is a libtool convenience library, so add in its objects.
6445302b15bdSmrg	    func_append convenience " $ladir/$objdir/$old_library"
6446302b15bdSmrg	    func_append old_convenience " $ladir/$objdir/$old_library"
6447b85037dbSmrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
6448b85037dbSmrg	    func_fatal_error "\`$lib' is not a convenience library"
6449b85037dbSmrg	  fi
6450b85037dbSmrg	  tmp_libs=
6451b85037dbSmrg	  for deplib in $dependency_libs; do
6452b85037dbSmrg	    deplibs="$deplib $deplibs"
6453302b15bdSmrg	    if $opt_preserve_dup_deps ; then
6454b85037dbSmrg	      case "$tmp_libs " in
6455302b15bdSmrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
6456b85037dbSmrg	      esac
6457b85037dbSmrg	    fi
6458302b15bdSmrg	    func_append tmp_libs " $deplib"
6459b85037dbSmrg	  done
6460b85037dbSmrg	  continue
6461b85037dbSmrg	fi # $pass = conv
6462b85037dbSmrg
6463b85037dbSmrg
6464b85037dbSmrg	# Get the name of the library we link against.
6465b85037dbSmrg	linklib=
6466302b15bdSmrg	if test -n "$old_library" &&
6467302b15bdSmrg	   { test "$prefer_static_libs" = yes ||
6468302b15bdSmrg	     test "$prefer_static_libs,$installed" = "built,no"; }; then
6469302b15bdSmrg	  linklib=$old_library
6470302b15bdSmrg	else
6471302b15bdSmrg	  for l in $old_library $library_names; do
6472302b15bdSmrg	    linklib="$l"
6473302b15bdSmrg	  done
6474302b15bdSmrg	fi
6475b85037dbSmrg	if test -z "$linklib"; then
6476b85037dbSmrg	  func_fatal_error "cannot find name of link library for \`$lib'"
6477b85037dbSmrg	fi
6478b85037dbSmrg
6479b85037dbSmrg	# This library was specified with -dlopen.
6480b85037dbSmrg	if test "$pass" = dlopen; then
6481b85037dbSmrg	  if test -z "$libdir"; then
6482b85037dbSmrg	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
6483b85037dbSmrg	  fi
6484b85037dbSmrg	  if test -z "$dlname" ||
6485b85037dbSmrg	     test "$dlopen_support" != yes ||
6486b85037dbSmrg	     test "$build_libtool_libs" = no; then
6487b85037dbSmrg	    # If there is no dlname, no dlopen support or we're linking
6488b85037dbSmrg	    # statically, we need to preload.  We also need to preload any
6489b85037dbSmrg	    # dependent libraries so libltdl's deplib preloader doesn't
6490b85037dbSmrg	    # bomb out in the load deplibs phase.
6491302b15bdSmrg	    func_append dlprefiles " $lib $dependency_libs"
6492b85037dbSmrg	  else
6493302b15bdSmrg	    func_append newdlfiles " $lib"
6494b85037dbSmrg	  fi
6495b85037dbSmrg	  continue
6496b85037dbSmrg	fi # $pass = dlopen
6497b85037dbSmrg
6498b85037dbSmrg	# We need an absolute path.
6499b85037dbSmrg	case $ladir in
6500b85037dbSmrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
6501b85037dbSmrg	*)
6502b85037dbSmrg	  abs_ladir=`cd "$ladir" && pwd`
6503b85037dbSmrg	  if test -z "$abs_ladir"; then
6504b85037dbSmrg	    func_warning "cannot determine absolute directory name of \`$ladir'"
6505b85037dbSmrg	    func_warning "passing it literally to the linker, although it might fail"
6506b85037dbSmrg	    abs_ladir="$ladir"
6507b85037dbSmrg	  fi
6508b85037dbSmrg	  ;;
6509b85037dbSmrg	esac
6510b85037dbSmrg	func_basename "$lib"
6511b85037dbSmrg	laname="$func_basename_result"
6512b85037dbSmrg
6513b85037dbSmrg	# Find the relevant object directory and library name.
6514b85037dbSmrg	if test "X$installed" = Xyes; then
6515302b15bdSmrg	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6516b85037dbSmrg	    func_warning "library \`$lib' was moved."
6517b85037dbSmrg	    dir="$ladir"
6518b85037dbSmrg	    absdir="$abs_ladir"
6519b85037dbSmrg	    libdir="$abs_ladir"
6520b85037dbSmrg	  else
6521302b15bdSmrg	    dir="$lt_sysroot$libdir"
6522302b15bdSmrg	    absdir="$lt_sysroot$libdir"
6523b85037dbSmrg	  fi
6524b85037dbSmrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
6525b85037dbSmrg	else
6526b85037dbSmrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6527b85037dbSmrg	    dir="$ladir"
6528b85037dbSmrg	    absdir="$abs_ladir"
6529b85037dbSmrg	    # Remove this search path later
6530302b15bdSmrg	    func_append notinst_path " $abs_ladir"
6531b85037dbSmrg	  else
6532b85037dbSmrg	    dir="$ladir/$objdir"
6533b85037dbSmrg	    absdir="$abs_ladir/$objdir"
6534b85037dbSmrg	    # Remove this search path later
6535302b15bdSmrg	    func_append notinst_path " $abs_ladir"
6536b85037dbSmrg	  fi
6537b85037dbSmrg	fi # $installed = yes
6538b85037dbSmrg	func_stripname 'lib' '.la' "$laname"
6539b85037dbSmrg	name=$func_stripname_result
6540b85037dbSmrg
6541b85037dbSmrg	# This library was specified with -dlpreopen.
6542b85037dbSmrg	if test "$pass" = dlpreopen; then
6543b85037dbSmrg	  if test -z "$libdir" && test "$linkmode" = prog; then
6544b85037dbSmrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
6545b85037dbSmrg	  fi
6546302b15bdSmrg	  case "$host" in
6547302b15bdSmrg	    # special handling for platforms with PE-DLLs.
6548302b15bdSmrg	    *cygwin* | *mingw* | *cegcc* )
6549302b15bdSmrg	      # Linker will automatically link against shared library if both
6550302b15bdSmrg	      # static and shared are present.  Therefore, ensure we extract
6551302b15bdSmrg	      # symbols from the import library if a shared library is present
6552302b15bdSmrg	      # (otherwise, the dlopen module name will be incorrect).  We do
6553302b15bdSmrg	      # this by putting the import library name into $newdlprefiles.
6554302b15bdSmrg	      # We recover the dlopen module name by 'saving' the la file
6555302b15bdSmrg	      # name in a special purpose variable, and (later) extracting the
6556302b15bdSmrg	      # dlname from the la file.
6557302b15bdSmrg	      if test -n "$dlname"; then
6558302b15bdSmrg	        func_tr_sh "$dir/$linklib"
6559302b15bdSmrg	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
6560302b15bdSmrg	        func_append newdlprefiles " $dir/$linklib"
6561302b15bdSmrg	      else
6562302b15bdSmrg	        func_append newdlprefiles " $dir/$old_library"
6563302b15bdSmrg	        # Keep a list of preopened convenience libraries to check
6564302b15bdSmrg	        # that they are being used correctly in the link pass.
6565302b15bdSmrg	        test -z "$libdir" && \
6566302b15bdSmrg	          func_append dlpreconveniencelibs " $dir/$old_library"
6567302b15bdSmrg	      fi
6568302b15bdSmrg	    ;;
6569302b15bdSmrg	    * )
6570302b15bdSmrg	      # Prefer using a static library (so that no silly _DYNAMIC symbols
6571302b15bdSmrg	      # are required to link).
6572302b15bdSmrg	      if test -n "$old_library"; then
6573302b15bdSmrg	        func_append newdlprefiles " $dir/$old_library"
6574302b15bdSmrg	        # Keep a list of preopened convenience libraries to check
6575302b15bdSmrg	        # that they are being used correctly in the link pass.
6576302b15bdSmrg	        test -z "$libdir" && \
6577302b15bdSmrg	          func_append dlpreconveniencelibs " $dir/$old_library"
6578302b15bdSmrg	      # Otherwise, use the dlname, so that lt_dlopen finds it.
6579302b15bdSmrg	      elif test -n "$dlname"; then
6580302b15bdSmrg	        func_append newdlprefiles " $dir/$dlname"
6581302b15bdSmrg	      else
6582302b15bdSmrg	        func_append newdlprefiles " $dir/$linklib"
6583302b15bdSmrg	      fi
6584302b15bdSmrg	    ;;
6585302b15bdSmrg	  esac
6586b85037dbSmrg	fi # $pass = dlpreopen
6587b85037dbSmrg
6588b85037dbSmrg	if test -z "$libdir"; then
6589b85037dbSmrg	  # Link the convenience library
6590b85037dbSmrg	  if test "$linkmode" = lib; then
6591b85037dbSmrg	    deplibs="$dir/$old_library $deplibs"
6592b85037dbSmrg	  elif test "$linkmode,$pass" = "prog,link"; then
6593b85037dbSmrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
6594b85037dbSmrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
6595b85037dbSmrg	  else
6596b85037dbSmrg	    deplibs="$lib $deplibs" # used for prog,scan pass
6597b85037dbSmrg	  fi
6598b85037dbSmrg	  continue
6599b85037dbSmrg	fi
6600b85037dbSmrg
6601b85037dbSmrg
6602b85037dbSmrg	if test "$linkmode" = prog && test "$pass" != link; then
6603302b15bdSmrg	  func_append newlib_search_path " $ladir"
6604b85037dbSmrg	  deplibs="$lib $deplibs"
6605b85037dbSmrg
6606b85037dbSmrg	  linkalldeplibs=no
6607b85037dbSmrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
6608b85037dbSmrg	     test "$build_libtool_libs" = no; then
6609b85037dbSmrg	    linkalldeplibs=yes
6610b85037dbSmrg	  fi
6611b85037dbSmrg
6612b85037dbSmrg	  tmp_libs=
6613b85037dbSmrg	  for deplib in $dependency_libs; do
6614b85037dbSmrg	    case $deplib in
6615b85037dbSmrg	    -L*) func_stripname '-L' '' "$deplib"
6616302b15bdSmrg	         func_resolve_sysroot "$func_stripname_result"
6617302b15bdSmrg	         func_append newlib_search_path " $func_resolve_sysroot_result"
6618b85037dbSmrg		 ;;
6619b85037dbSmrg	    esac
6620b85037dbSmrg	    # Need to link against all dependency_libs?
6621b85037dbSmrg	    if test "$linkalldeplibs" = yes; then
6622b85037dbSmrg	      deplibs="$deplib $deplibs"
6623b85037dbSmrg	    else
6624b85037dbSmrg	      # Need to hardcode shared library paths
6625b85037dbSmrg	      # or/and link against static libraries
6626b85037dbSmrg	      newdependency_libs="$deplib $newdependency_libs"
6627b85037dbSmrg	    fi
6628302b15bdSmrg	    if $opt_preserve_dup_deps ; then
6629b85037dbSmrg	      case "$tmp_libs " in
6630302b15bdSmrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
6631b85037dbSmrg	      esac
6632b85037dbSmrg	    fi
6633302b15bdSmrg	    func_append tmp_libs " $deplib"
6634b85037dbSmrg	  done # for deplib
6635b85037dbSmrg	  continue
6636b85037dbSmrg	fi # $linkmode = prog...
6637b85037dbSmrg
6638b85037dbSmrg	if test "$linkmode,$pass" = "prog,link"; then
6639b85037dbSmrg	  if test -n "$library_names" &&
6640b85037dbSmrg	     { { test "$prefer_static_libs" = no ||
6641b85037dbSmrg	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
6642b85037dbSmrg	       test -z "$old_library"; }; then
6643b85037dbSmrg	    # We need to hardcode the library path
6644b85037dbSmrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
6645b85037dbSmrg	      # Make sure the rpath contains only unique directories.
6646b85037dbSmrg	      case "$temp_rpath:" in
6647b85037dbSmrg	      *"$absdir:"*) ;;
6648302b15bdSmrg	      *) func_append temp_rpath "$absdir:" ;;
6649b85037dbSmrg	      esac
6650b85037dbSmrg	    fi
6651b85037dbSmrg
6652b85037dbSmrg	    # Hardcode the library path.
6653b85037dbSmrg	    # Skip directories that are in the system default run-time
6654b85037dbSmrg	    # search path.
6655b85037dbSmrg	    case " $sys_lib_dlsearch_path " in
6656b85037dbSmrg	    *" $absdir "*) ;;
6657b85037dbSmrg	    *)
6658b85037dbSmrg	      case "$compile_rpath " in
6659b85037dbSmrg	      *" $absdir "*) ;;
6660302b15bdSmrg	      *) func_append compile_rpath " $absdir" ;;
6661b85037dbSmrg	      esac
6662b85037dbSmrg	      ;;
6663b85037dbSmrg	    esac
6664b85037dbSmrg	    case " $sys_lib_dlsearch_path " in
6665b85037dbSmrg	    *" $libdir "*) ;;
6666b85037dbSmrg	    *)
6667b85037dbSmrg	      case "$finalize_rpath " in
6668b85037dbSmrg	      *" $libdir "*) ;;
6669302b15bdSmrg	      *) func_append finalize_rpath " $libdir" ;;
6670b85037dbSmrg	      esac
6671b85037dbSmrg	      ;;
6672b85037dbSmrg	    esac
6673b85037dbSmrg	  fi # $linkmode,$pass = prog,link...
6674b85037dbSmrg
6675b85037dbSmrg	  if test "$alldeplibs" = yes &&
6676b85037dbSmrg	     { test "$deplibs_check_method" = pass_all ||
6677b85037dbSmrg	       { test "$build_libtool_libs" = yes &&
6678b85037dbSmrg		 test -n "$library_names"; }; }; then
6679b85037dbSmrg	    # We only need to search for static libraries
6680b85037dbSmrg	    continue
6681b85037dbSmrg	  fi
6682b85037dbSmrg	fi
6683b85037dbSmrg
6684b85037dbSmrg	link_static=no # Whether the deplib will be linked statically
6685b85037dbSmrg	use_static_libs=$prefer_static_libs
6686b85037dbSmrg	if test "$use_static_libs" = built && test "$installed" = yes; then
6687b85037dbSmrg	  use_static_libs=no
6688b85037dbSmrg	fi
6689b85037dbSmrg	if test -n "$library_names" &&
6690b85037dbSmrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
6691b85037dbSmrg	  case $host in
6692b85037dbSmrg	  *cygwin* | *mingw* | *cegcc*)
6693b85037dbSmrg	      # No point in relinking DLLs because paths are not encoded
6694302b15bdSmrg	      func_append notinst_deplibs " $lib"
6695b85037dbSmrg	      need_relink=no
6696b85037dbSmrg	    ;;
6697b85037dbSmrg	  *)
6698b85037dbSmrg	    if test "$installed" = no; then
6699302b15bdSmrg	      func_append notinst_deplibs " $lib"
6700b85037dbSmrg	      need_relink=yes
6701b85037dbSmrg	    fi
6702b85037dbSmrg	    ;;
6703b85037dbSmrg	  esac
6704b85037dbSmrg	  # This is a shared library
6705b85037dbSmrg
6706b85037dbSmrg	  # Warn about portability, can't link against -module's on some
6707b85037dbSmrg	  # systems (darwin).  Don't bleat about dlopened modules though!
6708b85037dbSmrg	  dlopenmodule=""
6709b85037dbSmrg	  for dlpremoduletest in $dlprefiles; do
6710b85037dbSmrg	    if test "X$dlpremoduletest" = "X$lib"; then
6711b85037dbSmrg	      dlopenmodule="$dlpremoduletest"
6712b85037dbSmrg	      break
6713b85037dbSmrg	    fi
6714b85037dbSmrg	  done
6715b85037dbSmrg	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
6716b85037dbSmrg	    echo
6717b85037dbSmrg	    if test "$linkmode" = prog; then
6718b85037dbSmrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
6719b85037dbSmrg	    else
6720b85037dbSmrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
6721b85037dbSmrg	    fi
6722b85037dbSmrg	    $ECHO "*** $linklib is not portable!"
6723b85037dbSmrg	  fi
6724b85037dbSmrg	  if test "$linkmode" = lib &&
6725b85037dbSmrg	     test "$hardcode_into_libs" = yes; then
6726b85037dbSmrg	    # Hardcode the library path.
6727b85037dbSmrg	    # Skip directories that are in the system default run-time
6728b85037dbSmrg	    # search path.
6729b85037dbSmrg	    case " $sys_lib_dlsearch_path " in
6730b85037dbSmrg	    *" $absdir "*) ;;
6731b85037dbSmrg	    *)
6732b85037dbSmrg	      case "$compile_rpath " in
6733b85037dbSmrg	      *" $absdir "*) ;;
6734302b15bdSmrg	      *) func_append compile_rpath " $absdir" ;;
6735b85037dbSmrg	      esac
6736b85037dbSmrg	      ;;
6737b85037dbSmrg	    esac
6738b85037dbSmrg	    case " $sys_lib_dlsearch_path " in
6739b85037dbSmrg	    *" $libdir "*) ;;
6740b85037dbSmrg	    *)
6741b85037dbSmrg	      case "$finalize_rpath " in
6742b85037dbSmrg	      *" $libdir "*) ;;
6743302b15bdSmrg	      *) func_append finalize_rpath " $libdir" ;;
6744b85037dbSmrg	      esac
6745b85037dbSmrg	      ;;
6746b85037dbSmrg	    esac
6747b85037dbSmrg	  fi
6748b85037dbSmrg
6749b85037dbSmrg	  if test -n "$old_archive_from_expsyms_cmds"; then
6750b85037dbSmrg	    # figure out the soname
6751b85037dbSmrg	    set dummy $library_names
6752b85037dbSmrg	    shift
6753b85037dbSmrg	    realname="$1"
6754b85037dbSmrg	    shift
6755b85037dbSmrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
6756b85037dbSmrg	    # use dlname if we got it. it's perfectly good, no?
6757b85037dbSmrg	    if test -n "$dlname"; then
6758b85037dbSmrg	      soname="$dlname"
6759b85037dbSmrg	    elif test -n "$soname_spec"; then
6760b85037dbSmrg	      # bleh windows
6761b85037dbSmrg	      case $host in
6762b85037dbSmrg	      *cygwin* | mingw* | *cegcc*)
6763b85037dbSmrg	        func_arith $current - $age
6764b85037dbSmrg		major=$func_arith_result
6765b85037dbSmrg		versuffix="-$major"
6766b85037dbSmrg		;;
6767b85037dbSmrg	      esac
6768b85037dbSmrg	      eval soname=\"$soname_spec\"
6769b85037dbSmrg	    else
6770b85037dbSmrg	      soname="$realname"
6771b85037dbSmrg	    fi
6772b85037dbSmrg
6773b85037dbSmrg	    # Make a new name for the extract_expsyms_cmds to use
6774b85037dbSmrg	    soroot="$soname"
6775b85037dbSmrg	    func_basename "$soroot"
6776b85037dbSmrg	    soname="$func_basename_result"
6777b85037dbSmrg	    func_stripname 'lib' '.dll' "$soname"
6778b85037dbSmrg	    newlib=libimp-$func_stripname_result.a
6779b85037dbSmrg
6780b85037dbSmrg	    # If the library has no export list, then create one now
6781b85037dbSmrg	    if test -f "$output_objdir/$soname-def"; then :
6782b85037dbSmrg	    else
6783b85037dbSmrg	      func_verbose "extracting exported symbol list from \`$soname'"
6784b85037dbSmrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
6785b85037dbSmrg	    fi
6786b85037dbSmrg
6787b85037dbSmrg	    # Create $newlib
6788b85037dbSmrg	    if test -f "$output_objdir/$newlib"; then :; else
6789b85037dbSmrg	      func_verbose "generating import library for \`$soname'"
6790b85037dbSmrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
6791b85037dbSmrg	    fi
6792b85037dbSmrg	    # make sure the library variables are pointing to the new library
6793b85037dbSmrg	    dir=$output_objdir
6794b85037dbSmrg	    linklib=$newlib
6795b85037dbSmrg	  fi # test -n "$old_archive_from_expsyms_cmds"
6796b85037dbSmrg
6797302b15bdSmrg	  if test "$linkmode" = prog || test "$opt_mode" != relink; then
6798b85037dbSmrg	    add_shlibpath=
6799b85037dbSmrg	    add_dir=
6800b85037dbSmrg	    add=
6801b85037dbSmrg	    lib_linked=yes
6802b85037dbSmrg	    case $hardcode_action in
6803b85037dbSmrg	    immediate | unsupported)
6804b85037dbSmrg	      if test "$hardcode_direct" = no; then
6805b85037dbSmrg		add="$dir/$linklib"
6806b85037dbSmrg		case $host in
6807b85037dbSmrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
6808b85037dbSmrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
6809b85037dbSmrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
6810b85037dbSmrg		    *-*-unixware7*) add_dir="-L$dir" ;;
6811b85037dbSmrg		  *-*-darwin* )
6812b85037dbSmrg		    # if the lib is a (non-dlopened) module then we can not
6813b85037dbSmrg		    # link against it, someone is ignoring the earlier warnings
6814b85037dbSmrg		    if /usr/bin/file -L $add 2> /dev/null |
6815b85037dbSmrg			 $GREP ": [^:]* bundle" >/dev/null ; then
6816b85037dbSmrg		      if test "X$dlopenmodule" != "X$lib"; then
6817b85037dbSmrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
6818b85037dbSmrg			if test -z "$old_library" ; then
6819b85037dbSmrg			  echo
6820b85037dbSmrg			  echo "*** And there doesn't seem to be a static archive available"
6821b85037dbSmrg			  echo "*** The link will probably fail, sorry"
6822b85037dbSmrg			else
6823b85037dbSmrg			  add="$dir/$old_library"
6824b85037dbSmrg			fi
6825b85037dbSmrg		      elif test -n "$old_library"; then
6826b85037dbSmrg			add="$dir/$old_library"
6827b85037dbSmrg		      fi
6828b85037dbSmrg		    fi
6829b85037dbSmrg		esac
6830b85037dbSmrg	      elif test "$hardcode_minus_L" = no; then
6831b85037dbSmrg		case $host in
6832b85037dbSmrg		*-*-sunos*) add_shlibpath="$dir" ;;
6833b85037dbSmrg		esac
6834b85037dbSmrg		add_dir="-L$dir"
6835b85037dbSmrg		add="-l$name"
6836b85037dbSmrg	      elif test "$hardcode_shlibpath_var" = no; then
6837b85037dbSmrg		add_shlibpath="$dir"
6838b85037dbSmrg		add="-l$name"
6839b85037dbSmrg	      else
6840b85037dbSmrg		lib_linked=no
6841b85037dbSmrg	      fi
6842b85037dbSmrg	      ;;
6843b85037dbSmrg	    relink)
6844b85037dbSmrg	      if test "$hardcode_direct" = yes &&
6845b85037dbSmrg	         test "$hardcode_direct_absolute" = no; then
6846b85037dbSmrg		add="$dir/$linklib"
6847b85037dbSmrg	      elif test "$hardcode_minus_L" = yes; then
684828515619Smrg		add_dir="-L$absdir"
6849b85037dbSmrg		# Try looking first in the location we're being installed to.
6850b85037dbSmrg		if test -n "$inst_prefix_dir"; then
6851b85037dbSmrg		  case $libdir in
6852b85037dbSmrg		    [\\/]*)
6853302b15bdSmrg		      func_append add_dir " -L$inst_prefix_dir$libdir"
6854b85037dbSmrg		      ;;
6855b85037dbSmrg		  esac
6856b85037dbSmrg		fi
6857b85037dbSmrg		add="-l$name"
6858b85037dbSmrg	      elif test "$hardcode_shlibpath_var" = yes; then
6859b85037dbSmrg		add_shlibpath="$dir"
6860b85037dbSmrg		add="-l$name"
6861b85037dbSmrg	      else
6862b85037dbSmrg		lib_linked=no
6863b85037dbSmrg	      fi
6864b85037dbSmrg	      ;;
6865b85037dbSmrg	    *) lib_linked=no ;;
6866b85037dbSmrg	    esac
6867b85037dbSmrg
6868b85037dbSmrg	    if test "$lib_linked" != yes; then
6869b85037dbSmrg	      func_fatal_configuration "unsupported hardcode properties"
6870b85037dbSmrg	    fi
6871b85037dbSmrg
6872b85037dbSmrg	    if test -n "$add_shlibpath"; then
6873b85037dbSmrg	      case :$compile_shlibpath: in
6874b85037dbSmrg	      *":$add_shlibpath:"*) ;;
6875302b15bdSmrg	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
6876b85037dbSmrg	      esac
6877b85037dbSmrg	    fi
6878b85037dbSmrg	    if test "$linkmode" = prog; then
6879b85037dbSmrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
6880b85037dbSmrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
6881b85037dbSmrg	    else
6882b85037dbSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
6883b85037dbSmrg	      test -n "$add" && deplibs="$add $deplibs"
6884b85037dbSmrg	      if test "$hardcode_direct" != yes &&
6885b85037dbSmrg		 test "$hardcode_minus_L" != yes &&
6886b85037dbSmrg		 test "$hardcode_shlibpath_var" = yes; then
6887b85037dbSmrg		case :$finalize_shlibpath: in
6888b85037dbSmrg		*":$libdir:"*) ;;
6889302b15bdSmrg		*) func_append finalize_shlibpath "$libdir:" ;;
6890b85037dbSmrg		esac
6891b85037dbSmrg	      fi
6892b85037dbSmrg	    fi
6893b85037dbSmrg	  fi
6894b85037dbSmrg
6895302b15bdSmrg	  if test "$linkmode" = prog || test "$opt_mode" = relink; then
6896b85037dbSmrg	    add_shlibpath=
6897b85037dbSmrg	    add_dir=
6898b85037dbSmrg	    add=
6899b85037dbSmrg	    # Finalize command for both is simple: just hardcode it.
6900b85037dbSmrg	    if test "$hardcode_direct" = yes &&
6901b85037dbSmrg	       test "$hardcode_direct_absolute" = no; then
6902b85037dbSmrg	      add="$libdir/$linklib"
6903b85037dbSmrg	    elif test "$hardcode_minus_L" = yes; then
6904b85037dbSmrg	      add_dir="-L$libdir"
6905b85037dbSmrg	      add="-l$name"
6906b85037dbSmrg	    elif test "$hardcode_shlibpath_var" = yes; then
6907b85037dbSmrg	      case :$finalize_shlibpath: in
6908b85037dbSmrg	      *":$libdir:"*) ;;
6909302b15bdSmrg	      *) func_append finalize_shlibpath "$libdir:" ;;
6910b85037dbSmrg	      esac
6911b85037dbSmrg	      add="-l$name"
6912b85037dbSmrg	    elif test "$hardcode_automatic" = yes; then
6913b85037dbSmrg	      if test -n "$inst_prefix_dir" &&
6914b85037dbSmrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
6915b85037dbSmrg		add="$inst_prefix_dir$libdir/$linklib"
6916b85037dbSmrg	      else
6917b85037dbSmrg		add="$libdir/$linklib"
6918b85037dbSmrg	      fi
6919b85037dbSmrg	    else
6920b85037dbSmrg	      # We cannot seem to hardcode it, guess we'll fake it.
6921b85037dbSmrg	      add_dir="-L$libdir"
6922b85037dbSmrg	      # Try looking first in the location we're being installed to.
6923b85037dbSmrg	      if test -n "$inst_prefix_dir"; then
6924b85037dbSmrg		case $libdir in
6925b85037dbSmrg		  [\\/]*)
6926302b15bdSmrg		    func_append add_dir " -L$inst_prefix_dir$libdir"
6927b85037dbSmrg		    ;;
6928b85037dbSmrg		esac
6929b85037dbSmrg	      fi
6930b85037dbSmrg	      add="-l$name"
6931b85037dbSmrg	    fi
6932b85037dbSmrg
6933b85037dbSmrg	    if test "$linkmode" = prog; then
6934b85037dbSmrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
6935b85037dbSmrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
6936b85037dbSmrg	    else
6937b85037dbSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
6938b85037dbSmrg	      test -n "$add" && deplibs="$add $deplibs"
6939b85037dbSmrg	    fi
6940b85037dbSmrg	  fi
6941b85037dbSmrg	elif test "$linkmode" = prog; then
6942b85037dbSmrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
6943b85037dbSmrg	  # is not unsupported.  This is valid on all known static and
6944b85037dbSmrg	  # shared platforms.
6945b85037dbSmrg	  if test "$hardcode_direct" != unsupported; then
6946b85037dbSmrg	    test -n "$old_library" && linklib="$old_library"
6947b85037dbSmrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
6948b85037dbSmrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
6949b85037dbSmrg	  else
6950b85037dbSmrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
6951b85037dbSmrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
6952b85037dbSmrg	  fi
6953b85037dbSmrg	elif test "$build_libtool_libs" = yes; then
6954b85037dbSmrg	  # Not a shared library
6955b85037dbSmrg	  if test "$deplibs_check_method" != pass_all; then
6956b85037dbSmrg	    # We're trying link a shared library against a static one
6957b85037dbSmrg	    # but the system doesn't support it.
6958b85037dbSmrg
6959b85037dbSmrg	    # Just print a warning and add the library to dependency_libs so
6960b85037dbSmrg	    # that the program can be linked against the static library.
6961b85037dbSmrg	    echo
6962b85037dbSmrg	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
6963b85037dbSmrg	    echo "*** I have the capability to make that library automatically link in when"
6964b85037dbSmrg	    echo "*** you link to this library.  But I can only do this if you have a"
6965b85037dbSmrg	    echo "*** shared version of the library, which you do not appear to have."
6966b85037dbSmrg	    if test "$module" = yes; then
6967b85037dbSmrg	      echo "*** But as you try to build a module library, libtool will still create "
6968b85037dbSmrg	      echo "*** a static module, that should work as long as the dlopening application"
6969b85037dbSmrg	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
6970b85037dbSmrg	      if test -z "$global_symbol_pipe"; then
6971b85037dbSmrg		echo
6972b85037dbSmrg		echo "*** However, this would only work if libtool was able to extract symbol"
6973b85037dbSmrg		echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
6974b85037dbSmrg		echo "*** not find such a program.  So, this module is probably useless."
6975b85037dbSmrg		echo "*** \`nm' from GNU binutils and a full rebuild may help."
6976b85037dbSmrg	      fi
6977b85037dbSmrg	      if test "$build_old_libs" = no; then
6978b85037dbSmrg		build_libtool_libs=module
6979b85037dbSmrg		build_old_libs=yes
6980b85037dbSmrg	      else
6981b85037dbSmrg		build_libtool_libs=no
6982b85037dbSmrg	      fi
6983b85037dbSmrg	    fi
6984b85037dbSmrg	  else
6985b85037dbSmrg	    deplibs="$dir/$old_library $deplibs"
6986b85037dbSmrg	    link_static=yes
6987b85037dbSmrg	  fi
6988b85037dbSmrg	fi # link shared/static library?
6989b85037dbSmrg
6990b85037dbSmrg	if test "$linkmode" = lib; then
6991b85037dbSmrg	  if test -n "$dependency_libs" &&
6992b85037dbSmrg	     { test "$hardcode_into_libs" != yes ||
6993b85037dbSmrg	       test "$build_old_libs" = yes ||
6994b85037dbSmrg	       test "$link_static" = yes; }; then
6995b85037dbSmrg	    # Extract -R from dependency_libs
6996b85037dbSmrg	    temp_deplibs=
6997b85037dbSmrg	    for libdir in $dependency_libs; do
6998b85037dbSmrg	      case $libdir in
6999b85037dbSmrg	      -R*) func_stripname '-R' '' "$libdir"
7000b85037dbSmrg	           temp_xrpath=$func_stripname_result
7001b85037dbSmrg		   case " $xrpath " in
7002b85037dbSmrg		   *" $temp_xrpath "*) ;;
7003302b15bdSmrg		   *) func_append xrpath " $temp_xrpath";;
7004b85037dbSmrg		   esac;;
7005302b15bdSmrg	      *) func_append temp_deplibs " $libdir";;
7006b85037dbSmrg	      esac
7007b85037dbSmrg	    done
7008b85037dbSmrg	    dependency_libs="$temp_deplibs"
7009b85037dbSmrg	  fi
7010b85037dbSmrg
7011302b15bdSmrg	  func_append newlib_search_path " $absdir"
7012b85037dbSmrg	  # Link against this library
7013b85037dbSmrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
7014b85037dbSmrg	  # ... and its dependency_libs
7015b85037dbSmrg	  tmp_libs=
7016b85037dbSmrg	  for deplib in $dependency_libs; do
7017b85037dbSmrg	    newdependency_libs="$deplib $newdependency_libs"
7018302b15bdSmrg	    case $deplib in
7019302b15bdSmrg              -L*) func_stripname '-L' '' "$deplib"
7020302b15bdSmrg                   func_resolve_sysroot "$func_stripname_result";;
7021302b15bdSmrg              *) func_resolve_sysroot "$deplib" ;;
7022302b15bdSmrg            esac
7023302b15bdSmrg	    if $opt_preserve_dup_deps ; then
7024b85037dbSmrg	      case "$tmp_libs " in
7025302b15bdSmrg	      *" $func_resolve_sysroot_result "*)
7026302b15bdSmrg                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
7027b85037dbSmrg	      esac
7028b85037dbSmrg	    fi
7029302b15bdSmrg	    func_append tmp_libs " $func_resolve_sysroot_result"
7030b85037dbSmrg	  done
7031b85037dbSmrg
7032b85037dbSmrg	  if test "$link_all_deplibs" != no; then
7033b85037dbSmrg	    # Add the search paths of all dependency libraries
7034b85037dbSmrg	    for deplib in $dependency_libs; do
7035b85037dbSmrg	      path=
7036b85037dbSmrg	      case $deplib in
7037b85037dbSmrg	      -L*) path="$deplib" ;;
7038b85037dbSmrg	      *.la)
7039302b15bdSmrg	        func_resolve_sysroot "$deplib"
7040302b15bdSmrg	        deplib=$func_resolve_sysroot_result
7041b85037dbSmrg	        func_dirname "$deplib" "" "."
7042302b15bdSmrg		dir=$func_dirname_result
7043b85037dbSmrg		# We need an absolute path.
7044b85037dbSmrg		case $dir in
7045b85037dbSmrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
7046b85037dbSmrg		*)
7047b85037dbSmrg		  absdir=`cd "$dir" && pwd`
7048b85037dbSmrg		  if test -z "$absdir"; then
7049b85037dbSmrg		    func_warning "cannot determine absolute directory name of \`$dir'"
7050b85037dbSmrg		    absdir="$dir"
7051b85037dbSmrg		  fi
7052b85037dbSmrg		  ;;
7053b85037dbSmrg		esac
7054b85037dbSmrg		if $GREP "^installed=no" $deplib > /dev/null; then
7055b85037dbSmrg		case $host in
7056b85037dbSmrg		*-*-darwin*)
7057b85037dbSmrg		  depdepl=
7058b85037dbSmrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
7059b85037dbSmrg		  if test -n "$deplibrary_names" ; then
7060b85037dbSmrg		    for tmp in $deplibrary_names ; do
7061b85037dbSmrg		      depdepl=$tmp
7062b85037dbSmrg		    done
7063b85037dbSmrg		    if test -f "$absdir/$objdir/$depdepl" ; then
7064b85037dbSmrg		      depdepl="$absdir/$objdir/$depdepl"
7065b85037dbSmrg		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
7066b85037dbSmrg                      if test -z "$darwin_install_name"; then
7067b85037dbSmrg                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
7068b85037dbSmrg                      fi
7069302b15bdSmrg		      func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
7070302b15bdSmrg		      func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
7071b85037dbSmrg		      path=
7072b85037dbSmrg		    fi
7073b85037dbSmrg		  fi
7074b85037dbSmrg		  ;;
7075b85037dbSmrg		*)
7076b85037dbSmrg		  path="-L$absdir/$objdir"
7077b85037dbSmrg		  ;;
7078b85037dbSmrg		esac
7079b85037dbSmrg		else
7080b85037dbSmrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
7081b85037dbSmrg		  test -z "$libdir" && \
7082b85037dbSmrg		    func_fatal_error "\`$deplib' is not a valid libtool archive"
7083b85037dbSmrg		  test "$absdir" != "$libdir" && \
7084b85037dbSmrg		    func_warning "\`$deplib' seems to be moved"
7085b85037dbSmrg
7086b85037dbSmrg		  path="-L$absdir"
7087b85037dbSmrg		fi
7088b85037dbSmrg		;;
7089b85037dbSmrg	      esac
7090b85037dbSmrg	      case " $deplibs " in
7091b85037dbSmrg	      *" $path "*) ;;
7092b85037dbSmrg	      *) deplibs="$path $deplibs" ;;
7093b85037dbSmrg	      esac
7094b85037dbSmrg	    done
7095b85037dbSmrg	  fi # link_all_deplibs != no
7096b85037dbSmrg	fi # linkmode = lib
7097b85037dbSmrg      done # for deplib in $libs
7098b85037dbSmrg      if test "$pass" = link; then
7099b85037dbSmrg	if test "$linkmode" = "prog"; then
7100b85037dbSmrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
7101b85037dbSmrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
7102b85037dbSmrg	else
7103b85037dbSmrg	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7104b85037dbSmrg	fi
7105b85037dbSmrg      fi
7106b85037dbSmrg      dependency_libs="$newdependency_libs"
7107b85037dbSmrg      if test "$pass" = dlpreopen; then
7108b85037dbSmrg	# Link the dlpreopened libraries before other libraries
7109b85037dbSmrg	for deplib in $save_deplibs; do
7110b85037dbSmrg	  deplibs="$deplib $deplibs"
7111b85037dbSmrg	done
7112b85037dbSmrg      fi
7113b85037dbSmrg      if test "$pass" != dlopen; then
7114b85037dbSmrg	if test "$pass" != conv; then
7115b85037dbSmrg	  # Make sure lib_search_path contains only unique directories.
7116b85037dbSmrg	  lib_search_path=
7117b85037dbSmrg	  for dir in $newlib_search_path; do
7118b85037dbSmrg	    case "$lib_search_path " in
7119b85037dbSmrg	    *" $dir "*) ;;
7120302b15bdSmrg	    *) func_append lib_search_path " $dir" ;;
7121b85037dbSmrg	    esac
7122b85037dbSmrg	  done
7123b85037dbSmrg	  newlib_search_path=
7124b85037dbSmrg	fi
7125b85037dbSmrg
7126b85037dbSmrg	if test "$linkmode,$pass" != "prog,link"; then
7127b85037dbSmrg	  vars="deplibs"
7128b85037dbSmrg	else
7129b85037dbSmrg	  vars="compile_deplibs finalize_deplibs"
7130b85037dbSmrg	fi
7131b85037dbSmrg	for var in $vars dependency_libs; do
7132b85037dbSmrg	  # Add libraries to $var in reverse order
7133b85037dbSmrg	  eval tmp_libs=\"\$$var\"
7134b85037dbSmrg	  new_libs=
7135b85037dbSmrg	  for deplib in $tmp_libs; do
7136b85037dbSmrg	    # FIXME: Pedantically, this is the right thing to do, so
7137b85037dbSmrg	    #        that some nasty dependency loop isn't accidentally
7138b85037dbSmrg	    #        broken:
7139b85037dbSmrg	    #new_libs="$deplib $new_libs"
7140b85037dbSmrg	    # Pragmatically, this seems to cause very few problems in
7141b85037dbSmrg	    # practice:
7142b85037dbSmrg	    case $deplib in
7143b85037dbSmrg	    -L*) new_libs="$deplib $new_libs" ;;
7144b85037dbSmrg	    -R*) ;;
7145b85037dbSmrg	    *)
7146b85037dbSmrg	      # And here is the reason: when a library appears more
7147b85037dbSmrg	      # than once as an explicit dependence of a library, or
7148b85037dbSmrg	      # is implicitly linked in more than once by the
7149b85037dbSmrg	      # compiler, it is considered special, and multiple
7150b85037dbSmrg	      # occurrences thereof are not removed.  Compare this
7151b85037dbSmrg	      # with having the same library being listed as a
7152b85037dbSmrg	      # dependency of multiple other libraries: in this case,
7153b85037dbSmrg	      # we know (pedantically, we assume) the library does not
7154b85037dbSmrg	      # need to be listed more than once, so we keep only the
7155b85037dbSmrg	      # last copy.  This is not always right, but it is rare
7156b85037dbSmrg	      # enough that we require users that really mean to play
7157b85037dbSmrg	      # such unportable linking tricks to link the library
7158b85037dbSmrg	      # using -Wl,-lname, so that libtool does not consider it
7159b85037dbSmrg	      # for duplicate removal.
7160b85037dbSmrg	      case " $specialdeplibs " in
7161b85037dbSmrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
7162b85037dbSmrg	      *)
7163b85037dbSmrg		case " $new_libs " in
7164b85037dbSmrg		*" $deplib "*) ;;
7165b85037dbSmrg		*) new_libs="$deplib $new_libs" ;;
7166b85037dbSmrg		esac
7167b85037dbSmrg		;;
7168b85037dbSmrg	      esac
7169b85037dbSmrg	      ;;
7170b85037dbSmrg	    esac
7171b85037dbSmrg	  done
7172b85037dbSmrg	  tmp_libs=
7173b85037dbSmrg	  for deplib in $new_libs; do
7174b85037dbSmrg	    case $deplib in
7175b85037dbSmrg	    -L*)
7176b85037dbSmrg	      case " $tmp_libs " in
7177b85037dbSmrg	      *" $deplib "*) ;;
7178302b15bdSmrg	      *) func_append tmp_libs " $deplib" ;;
7179b85037dbSmrg	      esac
7180b85037dbSmrg	      ;;
7181302b15bdSmrg	    *) func_append tmp_libs " $deplib" ;;
7182b85037dbSmrg	    esac
7183b85037dbSmrg	  done
7184b85037dbSmrg	  eval $var=\"$tmp_libs\"
7185b85037dbSmrg	done # for var
7186b85037dbSmrg      fi
7187b85037dbSmrg      # Last step: remove runtime libs from dependency_libs
7188b85037dbSmrg      # (they stay in deplibs)
7189b85037dbSmrg      tmp_libs=
7190b85037dbSmrg      for i in $dependency_libs ; do
7191b85037dbSmrg	case " $predeps $postdeps $compiler_lib_search_path " in
7192b85037dbSmrg	*" $i "*)
7193b85037dbSmrg	  i=""
7194b85037dbSmrg	  ;;
7195b85037dbSmrg	esac
7196b85037dbSmrg	if test -n "$i" ; then
7197302b15bdSmrg	  func_append tmp_libs " $i"
7198b85037dbSmrg	fi
7199b85037dbSmrg      done
7200b85037dbSmrg      dependency_libs=$tmp_libs
7201b85037dbSmrg    done # for pass
7202b85037dbSmrg    if test "$linkmode" = prog; then
7203b85037dbSmrg      dlfiles="$newdlfiles"
7204b85037dbSmrg    fi
7205b85037dbSmrg    if test "$linkmode" = prog || test "$linkmode" = lib; then
7206b85037dbSmrg      dlprefiles="$newdlprefiles"
7207b85037dbSmrg    fi
7208b85037dbSmrg
7209b85037dbSmrg    case $linkmode in
7210b85037dbSmrg    oldlib)
7211b85037dbSmrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
7212b85037dbSmrg	func_warning "\`-dlopen' is ignored for archives"
7213b85037dbSmrg      fi
7214b85037dbSmrg
7215b85037dbSmrg      case " $deplibs" in
7216b85037dbSmrg      *\ -l* | *\ -L*)
7217b85037dbSmrg	func_warning "\`-l' and \`-L' are ignored for archives" ;;
7218b85037dbSmrg      esac
7219b85037dbSmrg
7220b85037dbSmrg      test -n "$rpath" && \
7221b85037dbSmrg	func_warning "\`-rpath' is ignored for archives"
7222b85037dbSmrg
7223b85037dbSmrg      test -n "$xrpath" && \
7224b85037dbSmrg	func_warning "\`-R' is ignored for archives"
7225b85037dbSmrg
7226b85037dbSmrg      test -n "$vinfo" && \
7227b85037dbSmrg	func_warning "\`-version-info/-version-number' is ignored for archives"
7228b85037dbSmrg
7229b85037dbSmrg      test -n "$release" && \
7230b85037dbSmrg	func_warning "\`-release' is ignored for archives"
7231b85037dbSmrg
7232b85037dbSmrg      test -n "$export_symbols$export_symbols_regex" && \
7233b85037dbSmrg	func_warning "\`-export-symbols' is ignored for archives"
7234b85037dbSmrg
7235b85037dbSmrg      # Now set the variables for building old libraries.
7236b85037dbSmrg      build_libtool_libs=no
7237b85037dbSmrg      oldlibs="$output"
7238302b15bdSmrg      func_append objs "$old_deplibs"
7239b85037dbSmrg      ;;
7240b85037dbSmrg
7241b85037dbSmrg    lib)
7242b85037dbSmrg      # Make sure we only generate libraries of the form `libNAME.la'.
7243b85037dbSmrg      case $outputname in
7244b85037dbSmrg      lib*)
7245b85037dbSmrg	func_stripname 'lib' '.la' "$outputname"
7246b85037dbSmrg	name=$func_stripname_result
7247b85037dbSmrg	eval shared_ext=\"$shrext_cmds\"
7248b85037dbSmrg	eval libname=\"$libname_spec\"
7249b85037dbSmrg	;;
7250b85037dbSmrg      *)
7251b85037dbSmrg	test "$module" = no && \
7252b85037dbSmrg	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
7253b85037dbSmrg
7254b85037dbSmrg	if test "$need_lib_prefix" != no; then
7255b85037dbSmrg	  # Add the "lib" prefix for modules if required
7256b85037dbSmrg	  func_stripname '' '.la' "$outputname"
7257b85037dbSmrg	  name=$func_stripname_result
7258b85037dbSmrg	  eval shared_ext=\"$shrext_cmds\"
7259b85037dbSmrg	  eval libname=\"$libname_spec\"
7260b85037dbSmrg	else
7261b85037dbSmrg	  func_stripname '' '.la' "$outputname"
7262b85037dbSmrg	  libname=$func_stripname_result
7263b85037dbSmrg	fi
7264b85037dbSmrg	;;
7265b85037dbSmrg      esac
7266b85037dbSmrg
7267b85037dbSmrg      if test -n "$objs"; then
7268b85037dbSmrg	if test "$deplibs_check_method" != pass_all; then
7269b85037dbSmrg	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
7270b85037dbSmrg	else
7271b85037dbSmrg	  echo
7272b85037dbSmrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
7273b85037dbSmrg	  $ECHO "*** objects $objs is not portable!"
7274302b15bdSmrg	  func_append libobjs " $objs"
7275b85037dbSmrg	fi
7276b85037dbSmrg      fi
7277b85037dbSmrg
7278b85037dbSmrg      test "$dlself" != no && \
7279b85037dbSmrg	func_warning "\`-dlopen self' is ignored for libtool libraries"
7280b85037dbSmrg
7281b85037dbSmrg      set dummy $rpath
7282b85037dbSmrg      shift
7283b85037dbSmrg      test "$#" -gt 1 && \
7284b85037dbSmrg	func_warning "ignoring multiple \`-rpath's for a libtool library"
7285b85037dbSmrg
7286b85037dbSmrg      install_libdir="$1"
7287b85037dbSmrg
7288b85037dbSmrg      oldlibs=
7289b85037dbSmrg      if test -z "$rpath"; then
7290b85037dbSmrg	if test "$build_libtool_libs" = yes; then
7291b85037dbSmrg	  # Building a libtool convenience library.
7292b85037dbSmrg	  # Some compilers have problems with a `.al' extension so
7293b85037dbSmrg	  # convenience libraries should have the same extension an
7294b85037dbSmrg	  # archive normally would.
7295b85037dbSmrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
7296b85037dbSmrg	  build_libtool_libs=convenience
7297b85037dbSmrg	  build_old_libs=yes
7298b85037dbSmrg	fi
7299b85037dbSmrg
7300b85037dbSmrg	test -n "$vinfo" && \
7301b85037dbSmrg	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
7302b85037dbSmrg
7303b85037dbSmrg	test -n "$release" && \
7304b85037dbSmrg	  func_warning "\`-release' is ignored for convenience libraries"
7305b85037dbSmrg      else
7306b85037dbSmrg
7307b85037dbSmrg	# Parse the version information argument.
7308b85037dbSmrg	save_ifs="$IFS"; IFS=':'
7309b85037dbSmrg	set dummy $vinfo 0 0 0
7310b85037dbSmrg	shift
7311b85037dbSmrg	IFS="$save_ifs"
7312b85037dbSmrg
7313b85037dbSmrg	test -n "$7" && \
7314b85037dbSmrg	  func_fatal_help "too many parameters to \`-version-info'"
7315b85037dbSmrg
7316b85037dbSmrg	# convert absolute version numbers to libtool ages
7317b85037dbSmrg	# this retains compatibility with .la files and attempts
7318b85037dbSmrg	# to make the code below a bit more comprehensible
7319b85037dbSmrg
7320b85037dbSmrg	case $vinfo_number in
7321b85037dbSmrg	yes)
7322b85037dbSmrg	  number_major="$1"
7323b85037dbSmrg	  number_minor="$2"
7324b85037dbSmrg	  number_revision="$3"
7325b85037dbSmrg	  #
7326b85037dbSmrg	  # There are really only two kinds -- those that
7327b85037dbSmrg	  # use the current revision as the major version
7328b85037dbSmrg	  # and those that subtract age and use age as
7329b85037dbSmrg	  # a minor version.  But, then there is irix
7330b85037dbSmrg	  # which has an extra 1 added just for fun
7331b85037dbSmrg	  #
7332b85037dbSmrg	  case $version_type in
733328515619Smrg	  # correct linux to gnu/linux during the next big refactor
7334b85037dbSmrg	  darwin|linux|osf|windows|none)
7335b85037dbSmrg	    func_arith $number_major + $number_minor
7336b85037dbSmrg	    current=$func_arith_result
7337b85037dbSmrg	    age="$number_minor"
7338b85037dbSmrg	    revision="$number_revision"
7339b85037dbSmrg	    ;;
7340b85037dbSmrg	  freebsd-aout|freebsd-elf|qnx|sunos)
7341b85037dbSmrg	    current="$number_major"
7342b85037dbSmrg	    revision="$number_minor"
7343b85037dbSmrg	    age="0"
7344b85037dbSmrg	    ;;
7345b85037dbSmrg	  irix|nonstopux)
7346b85037dbSmrg	    func_arith $number_major + $number_minor
7347b85037dbSmrg	    current=$func_arith_result
7348b85037dbSmrg	    age="$number_minor"
7349b85037dbSmrg	    revision="$number_minor"
7350b85037dbSmrg	    lt_irix_increment=no
7351b85037dbSmrg	    ;;
7352b85037dbSmrg	  esac
7353b85037dbSmrg	  ;;
7354b85037dbSmrg	no)
7355b85037dbSmrg	  current="$1"
7356b85037dbSmrg	  revision="$2"
7357b85037dbSmrg	  age="$3"
7358b85037dbSmrg	  ;;
7359b85037dbSmrg	esac
7360b85037dbSmrg
7361b85037dbSmrg	# Check that each of the things are valid numbers.
7362b85037dbSmrg	case $current in
7363b85037dbSmrg	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]) ;;
7364b85037dbSmrg	*)
7365b85037dbSmrg	  func_error "CURRENT \`$current' must be a nonnegative integer"
7366b85037dbSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
7367b85037dbSmrg	  ;;
7368b85037dbSmrg	esac
7369b85037dbSmrg
7370b85037dbSmrg	case $revision in
7371b85037dbSmrg	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]) ;;
7372b85037dbSmrg	*)
7373b85037dbSmrg	  func_error "REVISION \`$revision' must be a nonnegative integer"
7374b85037dbSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
7375b85037dbSmrg	  ;;
7376b85037dbSmrg	esac
7377b85037dbSmrg
7378b85037dbSmrg	case $age in
7379b85037dbSmrg	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]) ;;
7380b85037dbSmrg	*)
7381b85037dbSmrg	  func_error "AGE \`$age' must be a nonnegative integer"
7382b85037dbSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
7383b85037dbSmrg	  ;;
7384b85037dbSmrg	esac
7385b85037dbSmrg
7386b85037dbSmrg	if test "$age" -gt "$current"; then
7387b85037dbSmrg	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
7388b85037dbSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
7389b85037dbSmrg	fi
7390b85037dbSmrg
7391b85037dbSmrg	# Calculate the version variables.
7392b85037dbSmrg	major=
7393b85037dbSmrg	versuffix=
7394b85037dbSmrg	verstring=
7395b85037dbSmrg	case $version_type in
7396b85037dbSmrg	none) ;;
7397b85037dbSmrg
7398b85037dbSmrg	darwin)
7399b85037dbSmrg	  # Like Linux, but with the current version available in
7400b85037dbSmrg	  # verstring for coding it into the library header
7401b85037dbSmrg	  func_arith $current - $age
7402b85037dbSmrg	  major=.$func_arith_result
7403b85037dbSmrg	  versuffix="$major.$age.$revision"
7404b85037dbSmrg	  # Darwin ld doesn't like 0 for these options...
7405b85037dbSmrg	  func_arith $current + 1
7406b85037dbSmrg	  minor_current=$func_arith_result
7407b85037dbSmrg	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
7408b85037dbSmrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
7409b85037dbSmrg	  ;;
7410b85037dbSmrg
7411b85037dbSmrg	freebsd-aout)
7412b85037dbSmrg	  major=".$current"
7413b85037dbSmrg	  versuffix=".$current.$revision";
7414b85037dbSmrg	  ;;
7415b85037dbSmrg
7416b85037dbSmrg	freebsd-elf)
7417b85037dbSmrg	  major=".$current"
7418b85037dbSmrg	  versuffix=".$current"
7419b85037dbSmrg	  ;;
7420b85037dbSmrg
7421b85037dbSmrg	irix | nonstopux)
7422b85037dbSmrg	  if test "X$lt_irix_increment" = "Xno"; then
7423b85037dbSmrg	    func_arith $current - $age
7424b85037dbSmrg	  else
7425b85037dbSmrg	    func_arith $current - $age + 1
7426b85037dbSmrg	  fi
7427b85037dbSmrg	  major=$func_arith_result
7428b85037dbSmrg
7429b85037dbSmrg	  case $version_type in
7430b85037dbSmrg	    nonstopux) verstring_prefix=nonstopux ;;
7431b85037dbSmrg	    *)         verstring_prefix=sgi ;;
7432b85037dbSmrg	  esac
7433b85037dbSmrg	  verstring="$verstring_prefix$major.$revision"
7434b85037dbSmrg
7435b85037dbSmrg	  # Add in all the interfaces that we are compatible with.
7436b85037dbSmrg	  loop=$revision
7437b85037dbSmrg	  while test "$loop" -ne 0; do
7438b85037dbSmrg	    func_arith $revision - $loop
7439b85037dbSmrg	    iface=$func_arith_result
7440b85037dbSmrg	    func_arith $loop - 1
7441b85037dbSmrg	    loop=$func_arith_result
7442b85037dbSmrg	    verstring="$verstring_prefix$major.$iface:$verstring"
7443b85037dbSmrg	  done
7444b85037dbSmrg
7445b85037dbSmrg	  # Before this point, $major must not contain `.'.
7446b85037dbSmrg	  major=.$major
7447b85037dbSmrg	  versuffix="$major.$revision"
7448b85037dbSmrg	  ;;
7449b85037dbSmrg
745028515619Smrg	linux) # correct to gnu/linux during the next big refactor
7451b85037dbSmrg	  func_arith $current - $age
7452b85037dbSmrg	  major=.$func_arith_result
7453b85037dbSmrg	  versuffix="$major.$age.$revision"
7454b85037dbSmrg	  ;;
7455b85037dbSmrg
7456b85037dbSmrg	osf)
7457b85037dbSmrg	  func_arith $current - $age
7458b85037dbSmrg	  major=.$func_arith_result
7459b85037dbSmrg	  versuffix=".$current.$age.$revision"
7460b85037dbSmrg	  verstring="$current.$age.$revision"
7461b85037dbSmrg
7462b85037dbSmrg	  # Add in all the interfaces that we are compatible with.
7463b85037dbSmrg	  loop=$age
7464b85037dbSmrg	  while test "$loop" -ne 0; do
7465b85037dbSmrg	    func_arith $current - $loop
7466b85037dbSmrg	    iface=$func_arith_result
7467b85037dbSmrg	    func_arith $loop - 1
7468b85037dbSmrg	    loop=$func_arith_result
7469b85037dbSmrg	    verstring="$verstring:${iface}.0"
7470b85037dbSmrg	  done
7471b85037dbSmrg
7472b85037dbSmrg	  # Make executables depend on our current version.
7473302b15bdSmrg	  func_append verstring ":${current}.0"
7474b85037dbSmrg	  ;;
7475b85037dbSmrg
7476b85037dbSmrg	qnx)
7477b85037dbSmrg	  major=".$current"
7478b85037dbSmrg	  versuffix=".$current"
7479b85037dbSmrg	  ;;
7480b85037dbSmrg
7481b85037dbSmrg	sunos)
7482b85037dbSmrg	  major=".$current"
7483b85037dbSmrg	  versuffix=".$current.$revision"
7484b85037dbSmrg	  ;;
7485b85037dbSmrg
7486b85037dbSmrg	windows)
7487b85037dbSmrg	  # Use '-' rather than '.', since we only want one
7488b85037dbSmrg	  # extension on DOS 8.3 filesystems.
7489b85037dbSmrg	  func_arith $current - $age
7490b85037dbSmrg	  major=$func_arith_result
7491b85037dbSmrg	  versuffix="-$major"
7492b85037dbSmrg	  ;;
7493b85037dbSmrg
7494b85037dbSmrg	*)
7495b85037dbSmrg	  func_fatal_configuration "unknown library version type \`$version_type'"
7496b85037dbSmrg	  ;;
7497b85037dbSmrg	esac
7498b85037dbSmrg
7499b85037dbSmrg	# Clear the version info if we defaulted, and they specified a release.
7500b85037dbSmrg	if test -z "$vinfo" && test -n "$release"; then
7501b85037dbSmrg	  major=
7502b85037dbSmrg	  case $version_type in
7503b85037dbSmrg	  darwin)
7504b85037dbSmrg	    # we can't check for "0.0" in archive_cmds due to quoting
7505b85037dbSmrg	    # problems, so we reset it completely
7506b85037dbSmrg	    verstring=
7507b85037dbSmrg	    ;;
7508b85037dbSmrg	  *)
7509b85037dbSmrg	    verstring="0.0"
7510b85037dbSmrg	    ;;
7511b85037dbSmrg	  esac
7512b85037dbSmrg	  if test "$need_version" = no; then
7513b85037dbSmrg	    versuffix=
7514b85037dbSmrg	  else
7515b85037dbSmrg	    versuffix=".0.0"
7516b85037dbSmrg	  fi
7517b85037dbSmrg	fi
7518b85037dbSmrg
7519b85037dbSmrg	# Remove version info from name if versioning should be avoided
7520b85037dbSmrg	if test "$avoid_version" = yes && test "$need_version" = no; then
7521b85037dbSmrg	  major=
7522b85037dbSmrg	  versuffix=
7523b85037dbSmrg	  verstring=""
7524b85037dbSmrg	fi
7525b85037dbSmrg
7526b85037dbSmrg	# Check to see if the archive will have undefined symbols.
7527b85037dbSmrg	if test "$allow_undefined" = yes; then
7528b85037dbSmrg	  if test "$allow_undefined_flag" = unsupported; then
7529b85037dbSmrg	    func_warning "undefined symbols not allowed in $host shared libraries"
7530b85037dbSmrg	    build_libtool_libs=no
7531b85037dbSmrg	    build_old_libs=yes
7532b85037dbSmrg	  fi
7533b85037dbSmrg	else
7534b85037dbSmrg	  # Don't allow undefined symbols.
7535b85037dbSmrg	  allow_undefined_flag="$no_undefined_flag"
7536b85037dbSmrg	fi
7537b85037dbSmrg
7538b85037dbSmrg      fi
7539b85037dbSmrg
7540b85037dbSmrg      func_generate_dlsyms "$libname" "$libname" "yes"
7541302b15bdSmrg      func_append libobjs " $symfileobj"
7542b85037dbSmrg      test "X$libobjs" = "X " && libobjs=
7543b85037dbSmrg
7544302b15bdSmrg      if test "$opt_mode" != relink; then
7545b85037dbSmrg	# Remove our outputs, but don't remove object files since they
7546b85037dbSmrg	# may have been created when compiling PIC objects.
7547b85037dbSmrg	removelist=
7548b85037dbSmrg	tempremovelist=`$ECHO "$output_objdir/*"`
7549b85037dbSmrg	for p in $tempremovelist; do
7550b85037dbSmrg	  case $p in
7551b85037dbSmrg	    *.$objext | *.gcno)
7552b85037dbSmrg	       ;;
7553b85037dbSmrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
7554b85037dbSmrg	       if test "X$precious_files_regex" != "X"; then
7555b85037dbSmrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
7556b85037dbSmrg		 then
7557b85037dbSmrg		   continue
7558b85037dbSmrg		 fi
7559b85037dbSmrg	       fi
7560302b15bdSmrg	       func_append removelist " $p"
7561b85037dbSmrg	       ;;
7562b85037dbSmrg	    *) ;;
7563b85037dbSmrg	  esac
7564b85037dbSmrg	done
7565b85037dbSmrg	test -n "$removelist" && \
7566b85037dbSmrg	  func_show_eval "${RM}r \$removelist"
7567b85037dbSmrg      fi
7568b85037dbSmrg
7569b85037dbSmrg      # Now set the variables for building old libraries.
7570b85037dbSmrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
7571302b15bdSmrg	func_append oldlibs " $output_objdir/$libname.$libext"
7572b85037dbSmrg
7573b85037dbSmrg	# Transform .lo files to .o files.
7574b85037dbSmrg	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
7575b85037dbSmrg      fi
7576b85037dbSmrg
7577b85037dbSmrg      # Eliminate all temporary directories.
7578b85037dbSmrg      #for path in $notinst_path; do
7579b85037dbSmrg      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
7580b85037dbSmrg      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
7581b85037dbSmrg      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
7582b85037dbSmrg      #done
7583b85037dbSmrg
7584b85037dbSmrg      if test -n "$xrpath"; then
7585b85037dbSmrg	# If the user specified any rpath flags, then add them.
7586b85037dbSmrg	temp_xrpath=
7587b85037dbSmrg	for libdir in $xrpath; do
7588302b15bdSmrg	  func_replace_sysroot "$libdir"
7589302b15bdSmrg	  func_append temp_xrpath " -R$func_replace_sysroot_result"
7590b85037dbSmrg	  case "$finalize_rpath " in
7591b85037dbSmrg	  *" $libdir "*) ;;
7592302b15bdSmrg	  *) func_append finalize_rpath " $libdir" ;;
7593b85037dbSmrg	  esac
7594b85037dbSmrg	done
7595b85037dbSmrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
7596b85037dbSmrg	  dependency_libs="$temp_xrpath $dependency_libs"
7597b85037dbSmrg	fi
7598b85037dbSmrg      fi
7599b85037dbSmrg
7600b85037dbSmrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
7601b85037dbSmrg      old_dlfiles="$dlfiles"
7602b85037dbSmrg      dlfiles=
7603b85037dbSmrg      for lib in $old_dlfiles; do
7604b85037dbSmrg	case " $dlprefiles $dlfiles " in
7605b85037dbSmrg	*" $lib "*) ;;
7606302b15bdSmrg	*) func_append dlfiles " $lib" ;;
7607b85037dbSmrg	esac
7608b85037dbSmrg      done
7609b85037dbSmrg
7610b85037dbSmrg      # Make sure dlprefiles contains only unique files
7611b85037dbSmrg      old_dlprefiles="$dlprefiles"
7612b85037dbSmrg      dlprefiles=
7613b85037dbSmrg      for lib in $old_dlprefiles; do
7614b85037dbSmrg	case "$dlprefiles " in
7615b85037dbSmrg	*" $lib "*) ;;
7616302b15bdSmrg	*) func_append dlprefiles " $lib" ;;
7617b85037dbSmrg	esac
7618b85037dbSmrg      done
7619b85037dbSmrg
7620b85037dbSmrg      if test "$build_libtool_libs" = yes; then
7621b85037dbSmrg	if test -n "$rpath"; then
7622b85037dbSmrg	  case $host in
7623b85037dbSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
7624b85037dbSmrg	    # these systems don't actually have a c library (as such)!
7625b85037dbSmrg	    ;;
7626b85037dbSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
7627b85037dbSmrg	    # Rhapsody C library is in the System framework
7628302b15bdSmrg	    func_append deplibs " System.ltframework"
7629b85037dbSmrg	    ;;
7630b85037dbSmrg	  *-*-netbsd*)
7631b85037dbSmrg	    # Don't link with libc until the a.out ld.so is fixed.
7632b85037dbSmrg	    ;;
7633b85037dbSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
7634b85037dbSmrg	    # Do not include libc due to us having libc/libc_r.
7635b85037dbSmrg	    ;;
7636b85037dbSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
7637b85037dbSmrg	    # Causes problems with __ctype
7638b85037dbSmrg	    ;;
7639b85037dbSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
7640b85037dbSmrg	    # Compiler inserts libc in the correct place for threads to work
7641b85037dbSmrg	    ;;
7642b85037dbSmrg	  *)
7643b85037dbSmrg	    # Add libc to deplibs on all other systems if necessary.
7644b85037dbSmrg	    if test "$build_libtool_need_lc" = "yes"; then
7645302b15bdSmrg	      func_append deplibs " -lc"
7646b85037dbSmrg	    fi
7647b85037dbSmrg	    ;;
7648b85037dbSmrg	  esac
7649b85037dbSmrg	fi
7650b85037dbSmrg
7651b85037dbSmrg	# Transform deplibs into only deplibs that can be linked in shared.
7652b85037dbSmrg	name_save=$name
7653b85037dbSmrg	libname_save=$libname
7654b85037dbSmrg	release_save=$release
7655b85037dbSmrg	versuffix_save=$versuffix
7656b85037dbSmrg	major_save=$major
7657b85037dbSmrg	# I'm not sure if I'm treating the release correctly.  I think
7658b85037dbSmrg	# release should show up in the -l (ie -lgmp5) so we don't want to
7659b85037dbSmrg	# add it in twice.  Is that correct?
7660b85037dbSmrg	release=""
7661b85037dbSmrg	versuffix=""
7662b85037dbSmrg	major=""
7663b85037dbSmrg	newdeplibs=
7664b85037dbSmrg	droppeddeps=no
7665b85037dbSmrg	case $deplibs_check_method in
7666b85037dbSmrg	pass_all)
7667b85037dbSmrg	  # Don't check for shared/static.  Everything works.
7668b85037dbSmrg	  # This might be a little naive.  We might want to check
7669b85037dbSmrg	  # whether the library exists or not.  But this is on
7670b85037dbSmrg	  # osf3 & osf4 and I'm not really sure... Just
7671b85037dbSmrg	  # implementing what was already the behavior.
7672b85037dbSmrg	  newdeplibs=$deplibs
7673b85037dbSmrg	  ;;
7674b85037dbSmrg	test_compile)
7675b85037dbSmrg	  # This code stresses the "libraries are programs" paradigm to its
7676b85037dbSmrg	  # limits. Maybe even breaks it.  We compile a program, linking it
7677b85037dbSmrg	  # against the deplibs as a proxy for the library.  Then we can check
7678b85037dbSmrg	  # whether they linked in statically or dynamically with ldd.
7679b85037dbSmrg	  $opt_dry_run || $RM conftest.c
7680b85037dbSmrg	  cat > conftest.c <<EOF
7681b85037dbSmrg	  int main() { return 0; }
7682b85037dbSmrgEOF
7683b85037dbSmrg	  $opt_dry_run || $RM conftest
7684b85037dbSmrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
7685b85037dbSmrg	    ldd_output=`ldd conftest`
7686b85037dbSmrg	    for i in $deplibs; do
7687b85037dbSmrg	      case $i in
7688b85037dbSmrg	      -l*)
7689b85037dbSmrg		func_stripname -l '' "$i"
7690b85037dbSmrg		name=$func_stripname_result
7691b85037dbSmrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7692b85037dbSmrg		  case " $predeps $postdeps " in
7693b85037dbSmrg		  *" $i "*)
7694302b15bdSmrg		    func_append newdeplibs " $i"
7695b85037dbSmrg		    i=""
7696b85037dbSmrg		    ;;
7697b85037dbSmrg		  esac
7698b85037dbSmrg		fi
7699b85037dbSmrg		if test -n "$i" ; then
7700b85037dbSmrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
7701b85037dbSmrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
7702b85037dbSmrg		  set dummy $deplib_matches; shift
7703b85037dbSmrg		  deplib_match=$1
7704b85037dbSmrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7705302b15bdSmrg		    func_append newdeplibs " $i"
7706b85037dbSmrg		  else
7707b85037dbSmrg		    droppeddeps=yes
7708b85037dbSmrg		    echo
7709b85037dbSmrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
7710b85037dbSmrg		    echo "*** I have the capability to make that library automatically link in when"
7711b85037dbSmrg		    echo "*** you link to this library.  But I can only do this if you have a"
7712b85037dbSmrg		    echo "*** shared version of the library, which I believe you do not have"
7713b85037dbSmrg		    echo "*** because a test_compile did reveal that the linker did not use it for"
7714b85037dbSmrg		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
7715b85037dbSmrg		  fi
7716b85037dbSmrg		fi
7717b85037dbSmrg		;;
7718b85037dbSmrg	      *)
7719302b15bdSmrg		func_append newdeplibs " $i"
7720b85037dbSmrg		;;
7721b85037dbSmrg	      esac
7722b85037dbSmrg	    done
7723b85037dbSmrg	  else
7724b85037dbSmrg	    # Error occurred in the first compile.  Let's try to salvage
7725b85037dbSmrg	    # the situation: Compile a separate program for each library.
7726b85037dbSmrg	    for i in $deplibs; do
7727b85037dbSmrg	      case $i in
7728b85037dbSmrg	      -l*)
7729b85037dbSmrg		func_stripname -l '' "$i"
7730b85037dbSmrg		name=$func_stripname_result
7731b85037dbSmrg		$opt_dry_run || $RM conftest
7732b85037dbSmrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
7733b85037dbSmrg		  ldd_output=`ldd conftest`
7734b85037dbSmrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7735b85037dbSmrg		    case " $predeps $postdeps " in
7736b85037dbSmrg		    *" $i "*)
7737302b15bdSmrg		      func_append newdeplibs " $i"
7738b85037dbSmrg		      i=""
7739b85037dbSmrg		      ;;
7740b85037dbSmrg		    esac
7741b85037dbSmrg		  fi
7742b85037dbSmrg		  if test -n "$i" ; then
7743b85037dbSmrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
7744b85037dbSmrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
7745b85037dbSmrg		    set dummy $deplib_matches; shift
7746b85037dbSmrg		    deplib_match=$1
7747b85037dbSmrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7748302b15bdSmrg		      func_append newdeplibs " $i"
7749b85037dbSmrg		    else
7750b85037dbSmrg		      droppeddeps=yes
7751b85037dbSmrg		      echo
7752b85037dbSmrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
7753b85037dbSmrg		      echo "*** I have the capability to make that library automatically link in when"
7754b85037dbSmrg		      echo "*** you link to this library.  But I can only do this if you have a"
7755b85037dbSmrg		      echo "*** shared version of the library, which you do not appear to have"
7756b85037dbSmrg		      echo "*** because a test_compile did reveal that the linker did not use this one"
7757b85037dbSmrg		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
7758b85037dbSmrg		    fi
7759b85037dbSmrg		  fi
7760b85037dbSmrg		else
7761b85037dbSmrg		  droppeddeps=yes
7762b85037dbSmrg		  echo
7763b85037dbSmrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
7764b85037dbSmrg		  echo "*** make it link in!  You will probably need to install it or some"
7765b85037dbSmrg		  echo "*** library that it depends on before this library will be fully"
7766b85037dbSmrg		  echo "*** functional.  Installing it before continuing would be even better."
7767b85037dbSmrg		fi
7768b85037dbSmrg		;;
7769b85037dbSmrg	      *)
7770302b15bdSmrg		func_append newdeplibs " $i"
7771b85037dbSmrg		;;
7772b85037dbSmrg	      esac
7773b85037dbSmrg	    done
7774b85037dbSmrg	  fi
7775b85037dbSmrg	  ;;
7776b85037dbSmrg	file_magic*)
7777b85037dbSmrg	  set dummy $deplibs_check_method; shift
7778b85037dbSmrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7779b85037dbSmrg	  for a_deplib in $deplibs; do
7780b85037dbSmrg	    case $a_deplib in
7781b85037dbSmrg	    -l*)
7782b85037dbSmrg	      func_stripname -l '' "$a_deplib"
7783b85037dbSmrg	      name=$func_stripname_result
7784b85037dbSmrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7785b85037dbSmrg		case " $predeps $postdeps " in
7786b85037dbSmrg		*" $a_deplib "*)
7787302b15bdSmrg		  func_append newdeplibs " $a_deplib"
7788b85037dbSmrg		  a_deplib=""
7789b85037dbSmrg		  ;;
7790b85037dbSmrg		esac
7791b85037dbSmrg	      fi
7792b85037dbSmrg	      if test -n "$a_deplib" ; then
7793b85037dbSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
7794302b15bdSmrg		if test -n "$file_magic_glob"; then
7795302b15bdSmrg		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
7796302b15bdSmrg		else
7797302b15bdSmrg		  libnameglob=$libname
7798302b15bdSmrg		fi
7799302b15bdSmrg		test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
7800b85037dbSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7801302b15bdSmrg		  if test "$want_nocaseglob" = yes; then
7802302b15bdSmrg		    shopt -s nocaseglob
7803302b15bdSmrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7804302b15bdSmrg		    $nocaseglob
7805302b15bdSmrg		  else
7806302b15bdSmrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7807302b15bdSmrg		  fi
7808b85037dbSmrg		  for potent_lib in $potential_libs; do
7809b85037dbSmrg		      # Follow soft links.
7810b85037dbSmrg		      if ls -lLd "$potent_lib" 2>/dev/null |
7811b85037dbSmrg			 $GREP " -> " >/dev/null; then
7812b85037dbSmrg			continue
7813b85037dbSmrg		      fi
7814b85037dbSmrg		      # The statement above tries to avoid entering an
7815b85037dbSmrg		      # endless loop below, in case of cyclic links.
7816b85037dbSmrg		      # We might still enter an endless loop, since a link
7817b85037dbSmrg		      # loop can be closed while we follow links,
7818b85037dbSmrg		      # but so what?
7819b85037dbSmrg		      potlib="$potent_lib"
7820b85037dbSmrg		      while test -h "$potlib" 2>/dev/null; do
7821b85037dbSmrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
7822b85037dbSmrg			case $potliblink in
7823b85037dbSmrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
7824b85037dbSmrg			*) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
7825b85037dbSmrg			esac
7826b85037dbSmrg		      done
7827b85037dbSmrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
7828b85037dbSmrg			 $SED -e 10q |
7829b85037dbSmrg			 $EGREP "$file_magic_regex" > /dev/null; then
7830302b15bdSmrg			func_append newdeplibs " $a_deplib"
7831b85037dbSmrg			a_deplib=""
7832b85037dbSmrg			break 2
7833b85037dbSmrg		      fi
7834b85037dbSmrg		  done
7835b85037dbSmrg		done
7836b85037dbSmrg	      fi
7837b85037dbSmrg	      if test -n "$a_deplib" ; then
7838b85037dbSmrg		droppeddeps=yes
7839b85037dbSmrg		echo
7840b85037dbSmrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
7841b85037dbSmrg		echo "*** I have the capability to make that library automatically link in when"
7842b85037dbSmrg		echo "*** you link to this library.  But I can only do this if you have a"
7843b85037dbSmrg		echo "*** shared version of the library, which you do not appear to have"
7844b85037dbSmrg		echo "*** because I did check the linker path looking for a file starting"
7845b85037dbSmrg		if test -z "$potlib" ; then
7846b85037dbSmrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
7847b85037dbSmrg		else
7848b85037dbSmrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
7849b85037dbSmrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
7850b85037dbSmrg		fi
7851b85037dbSmrg	      fi
7852b85037dbSmrg	      ;;
7853b85037dbSmrg	    *)
7854b85037dbSmrg	      # Add a -L argument.
7855302b15bdSmrg	      func_append newdeplibs " $a_deplib"
7856b85037dbSmrg	      ;;
7857b85037dbSmrg	    esac
7858b85037dbSmrg	  done # Gone through all deplibs.
7859b85037dbSmrg	  ;;
7860b85037dbSmrg	match_pattern*)
7861b85037dbSmrg	  set dummy $deplibs_check_method; shift
7862b85037dbSmrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7863b85037dbSmrg	  for a_deplib in $deplibs; do
7864b85037dbSmrg	    case $a_deplib in
7865b85037dbSmrg	    -l*)
7866b85037dbSmrg	      func_stripname -l '' "$a_deplib"
7867b85037dbSmrg	      name=$func_stripname_result
7868b85037dbSmrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7869b85037dbSmrg		case " $predeps $postdeps " in
7870b85037dbSmrg		*" $a_deplib "*)
7871302b15bdSmrg		  func_append newdeplibs " $a_deplib"
7872b85037dbSmrg		  a_deplib=""
7873b85037dbSmrg		  ;;
7874b85037dbSmrg		esac
7875b85037dbSmrg	      fi
7876b85037dbSmrg	      if test -n "$a_deplib" ; then
7877b85037dbSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
7878b85037dbSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7879b85037dbSmrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
7880b85037dbSmrg		  for potent_lib in $potential_libs; do
7881b85037dbSmrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
7882b85037dbSmrg		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
7883b85037dbSmrg		       $EGREP "$match_pattern_regex" > /dev/null; then
7884302b15bdSmrg		      func_append newdeplibs " $a_deplib"
7885b85037dbSmrg		      a_deplib=""
7886b85037dbSmrg		      break 2
7887b85037dbSmrg		    fi
7888b85037dbSmrg		  done
7889b85037dbSmrg		done
7890b85037dbSmrg	      fi
7891b85037dbSmrg	      if test -n "$a_deplib" ; then
7892b85037dbSmrg		droppeddeps=yes
7893b85037dbSmrg		echo
7894b85037dbSmrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
7895b85037dbSmrg		echo "*** I have the capability to make that library automatically link in when"
7896b85037dbSmrg		echo "*** you link to this library.  But I can only do this if you have a"
7897b85037dbSmrg		echo "*** shared version of the library, which you do not appear to have"
7898b85037dbSmrg		echo "*** because I did check the linker path looking for a file starting"
7899b85037dbSmrg		if test -z "$potlib" ; then
7900b85037dbSmrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
7901b85037dbSmrg		else
7902b85037dbSmrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
7903b85037dbSmrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
7904b85037dbSmrg		fi
7905b85037dbSmrg	      fi
7906b85037dbSmrg	      ;;
7907b85037dbSmrg	    *)
7908b85037dbSmrg	      # Add a -L argument.
7909302b15bdSmrg	      func_append newdeplibs " $a_deplib"
7910b85037dbSmrg	      ;;
7911b85037dbSmrg	    esac
7912b85037dbSmrg	  done # Gone through all deplibs.
7913b85037dbSmrg	  ;;
7914b85037dbSmrg	none | unknown | *)
7915b85037dbSmrg	  newdeplibs=""
7916b85037dbSmrg	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
7917b85037dbSmrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7918b85037dbSmrg	    for i in $predeps $postdeps ; do
7919b85037dbSmrg	      # can't use Xsed below, because $i might contain '/'
7920b85037dbSmrg	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
7921b85037dbSmrg	    done
7922b85037dbSmrg	  fi
7923b85037dbSmrg	  case $tmp_deplibs in
7924b85037dbSmrg	  *[!\	\ ]*)
7925b85037dbSmrg	    echo
7926b85037dbSmrg	    if test "X$deplibs_check_method" = "Xnone"; then
7927b85037dbSmrg	      echo "*** Warning: inter-library dependencies are not supported in this platform."
7928b85037dbSmrg	    else
7929b85037dbSmrg	      echo "*** Warning: inter-library dependencies are not known to be supported."
7930b85037dbSmrg	    fi
7931b85037dbSmrg	    echo "*** All declared inter-library dependencies are being dropped."
7932b85037dbSmrg	    droppeddeps=yes
7933b85037dbSmrg	    ;;
7934b85037dbSmrg	  esac
7935b85037dbSmrg	  ;;
7936b85037dbSmrg	esac
7937b85037dbSmrg	versuffix=$versuffix_save
7938b85037dbSmrg	major=$major_save
7939b85037dbSmrg	release=$release_save
7940b85037dbSmrg	libname=$libname_save
7941b85037dbSmrg	name=$name_save
7942b85037dbSmrg
7943b85037dbSmrg	case $host in
7944b85037dbSmrg	*-*-rhapsody* | *-*-darwin1.[012])
7945b85037dbSmrg	  # On Rhapsody replace the C library with the System framework
7946b85037dbSmrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
7947b85037dbSmrg	  ;;
7948b85037dbSmrg	esac
7949b85037dbSmrg
7950b85037dbSmrg	if test "$droppeddeps" = yes; then
7951b85037dbSmrg	  if test "$module" = yes; then
7952b85037dbSmrg	    echo
7953b85037dbSmrg	    echo "*** Warning: libtool could not satisfy all declared inter-library"
7954b85037dbSmrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
7955b85037dbSmrg	    echo "*** a static module, that should work as long as the dlopening"
7956b85037dbSmrg	    echo "*** application is linked with the -dlopen flag."
7957b85037dbSmrg	    if test -z "$global_symbol_pipe"; then
7958b85037dbSmrg	      echo
7959b85037dbSmrg	      echo "*** However, this would only work if libtool was able to extract symbol"
7960b85037dbSmrg	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
7961b85037dbSmrg	      echo "*** not find such a program.  So, this module is probably useless."
7962b85037dbSmrg	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
7963b85037dbSmrg	    fi
7964b85037dbSmrg	    if test "$build_old_libs" = no; then
7965b85037dbSmrg	      oldlibs="$output_objdir/$libname.$libext"
7966b85037dbSmrg	      build_libtool_libs=module
7967b85037dbSmrg	      build_old_libs=yes
7968b85037dbSmrg	    else
7969b85037dbSmrg	      build_libtool_libs=no
7970b85037dbSmrg	    fi
7971b85037dbSmrg	  else
7972b85037dbSmrg	    echo "*** The inter-library dependencies that have been dropped here will be"
7973b85037dbSmrg	    echo "*** automatically added whenever a program is linked with this library"
7974b85037dbSmrg	    echo "*** or is declared to -dlopen it."
7975b85037dbSmrg
7976b85037dbSmrg	    if test "$allow_undefined" = no; then
7977b85037dbSmrg	      echo
7978b85037dbSmrg	      echo "*** Since this library must not contain undefined symbols,"
7979b85037dbSmrg	      echo "*** because either the platform does not support them or"
7980b85037dbSmrg	      echo "*** it was explicitly requested with -no-undefined,"
7981b85037dbSmrg	      echo "*** libtool will only create a static version of it."
7982b85037dbSmrg	      if test "$build_old_libs" = no; then
7983b85037dbSmrg		oldlibs="$output_objdir/$libname.$libext"
7984b85037dbSmrg		build_libtool_libs=module
7985b85037dbSmrg		build_old_libs=yes
7986b85037dbSmrg	      else
7987b85037dbSmrg		build_libtool_libs=no
7988b85037dbSmrg	      fi
7989b85037dbSmrg	    fi
7990b85037dbSmrg	  fi
7991b85037dbSmrg	fi
7992b85037dbSmrg	# Done checking deplibs!
7993b85037dbSmrg	deplibs=$newdeplibs
7994b85037dbSmrg      fi
7995b85037dbSmrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
7996b85037dbSmrg      case $host in
7997b85037dbSmrg	*-*-darwin*)
7998b85037dbSmrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7999b85037dbSmrg	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8000b85037dbSmrg	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8001b85037dbSmrg	  ;;
8002b85037dbSmrg      esac
8003b85037dbSmrg
8004b85037dbSmrg      # move library search paths that coincide with paths to not yet
8005b85037dbSmrg      # installed libraries to the beginning of the library search list
8006b85037dbSmrg      new_libs=
8007b85037dbSmrg      for path in $notinst_path; do
8008b85037dbSmrg	case " $new_libs " in
8009b85037dbSmrg	*" -L$path/$objdir "*) ;;
8010b85037dbSmrg	*)
8011b85037dbSmrg	  case " $deplibs " in
8012b85037dbSmrg	  *" -L$path/$objdir "*)
8013302b15bdSmrg	    func_append new_libs " -L$path/$objdir" ;;
8014b85037dbSmrg	  esac
8015b85037dbSmrg	  ;;
8016b85037dbSmrg	esac
8017b85037dbSmrg      done
8018b85037dbSmrg      for deplib in $deplibs; do
8019b85037dbSmrg	case $deplib in
8020b85037dbSmrg	-L*)
8021b85037dbSmrg	  case " $new_libs " in
8022b85037dbSmrg	  *" $deplib "*) ;;
8023302b15bdSmrg	  *) func_append new_libs " $deplib" ;;
8024b85037dbSmrg	  esac
8025b85037dbSmrg	  ;;
8026302b15bdSmrg	*) func_append new_libs " $deplib" ;;
8027b85037dbSmrg	esac
8028b85037dbSmrg      done
8029b85037dbSmrg      deplibs="$new_libs"
8030b85037dbSmrg
8031b85037dbSmrg      # All the library-specific variables (install_libdir is set above).
8032b85037dbSmrg      library_names=
8033b85037dbSmrg      old_library=
8034b85037dbSmrg      dlname=
8035b85037dbSmrg
8036b85037dbSmrg      # Test again, we may have decided not to build it any more
8037b85037dbSmrg      if test "$build_libtool_libs" = yes; then
803828515619Smrg	# Remove ${wl} instances when linking with ld.
803928515619Smrg	# FIXME: should test the right _cmds variable.
804028515619Smrg	case $archive_cmds in
804128515619Smrg	  *\$LD\ *) wl= ;;
804228515619Smrg        esac
8043b85037dbSmrg	if test "$hardcode_into_libs" = yes; then
8044b85037dbSmrg	  # Hardcode the library paths
8045b85037dbSmrg	  hardcode_libdirs=
8046b85037dbSmrg	  dep_rpath=
8047b85037dbSmrg	  rpath="$finalize_rpath"
8048302b15bdSmrg	  test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
8049b85037dbSmrg	  for libdir in $rpath; do
8050b85037dbSmrg	    if test -n "$hardcode_libdir_flag_spec"; then
8051b85037dbSmrg	      if test -n "$hardcode_libdir_separator"; then
8052302b15bdSmrg		func_replace_sysroot "$libdir"
8053302b15bdSmrg		libdir=$func_replace_sysroot_result
8054b85037dbSmrg		if test -z "$hardcode_libdirs"; then
8055b85037dbSmrg		  hardcode_libdirs="$libdir"
8056b85037dbSmrg		else
8057b85037dbSmrg		  # Just accumulate the unique libdirs.
8058b85037dbSmrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8059b85037dbSmrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8060b85037dbSmrg		    ;;
8061b85037dbSmrg		  *)
8062302b15bdSmrg		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8063b85037dbSmrg		    ;;
8064b85037dbSmrg		  esac
8065b85037dbSmrg		fi
8066b85037dbSmrg	      else
8067b85037dbSmrg		eval flag=\"$hardcode_libdir_flag_spec\"
8068302b15bdSmrg		func_append dep_rpath " $flag"
8069b85037dbSmrg	      fi
8070b85037dbSmrg	    elif test -n "$runpath_var"; then
8071b85037dbSmrg	      case "$perm_rpath " in
8072b85037dbSmrg	      *" $libdir "*) ;;
807328515619Smrg	      *) func_append perm_rpath " $libdir" ;;
8074b85037dbSmrg	      esac
8075b85037dbSmrg	    fi
8076b85037dbSmrg	  done
8077b85037dbSmrg	  # Substitute the hardcoded libdirs into the rpath.
8078b85037dbSmrg	  if test -n "$hardcode_libdir_separator" &&
8079b85037dbSmrg	     test -n "$hardcode_libdirs"; then
8080b85037dbSmrg	    libdir="$hardcode_libdirs"
808128515619Smrg	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
8082b85037dbSmrg	  fi
8083b85037dbSmrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
8084b85037dbSmrg	    # We should set the runpath_var.
8085b85037dbSmrg	    rpath=
8086b85037dbSmrg	    for dir in $perm_rpath; do
8087302b15bdSmrg	      func_append rpath "$dir:"
8088b85037dbSmrg	    done
8089b85037dbSmrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
8090b85037dbSmrg	  fi
8091b85037dbSmrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
8092b85037dbSmrg	fi
8093b85037dbSmrg
8094b85037dbSmrg	shlibpath="$finalize_shlibpath"
8095302b15bdSmrg	test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
8096b85037dbSmrg	if test -n "$shlibpath"; then
8097b85037dbSmrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
8098b85037dbSmrg	fi
8099b85037dbSmrg
8100b85037dbSmrg	# Get the real and link names of the library.
8101b85037dbSmrg	eval shared_ext=\"$shrext_cmds\"
8102b85037dbSmrg	eval library_names=\"$library_names_spec\"
8103b85037dbSmrg	set dummy $library_names
8104b85037dbSmrg	shift
8105b85037dbSmrg	realname="$1"
8106b85037dbSmrg	shift
8107b85037dbSmrg
8108b85037dbSmrg	if test -n "$soname_spec"; then
8109b85037dbSmrg	  eval soname=\"$soname_spec\"
8110b85037dbSmrg	else
8111b85037dbSmrg	  soname="$realname"
8112b85037dbSmrg	fi
8113b85037dbSmrg	if test -z "$dlname"; then
8114b85037dbSmrg	  dlname=$soname
8115b85037dbSmrg	fi
8116b85037dbSmrg
8117b85037dbSmrg	lib="$output_objdir/$realname"
8118b85037dbSmrg	linknames=
8119b85037dbSmrg	for link
8120b85037dbSmrg	do
8121302b15bdSmrg	  func_append linknames " $link"
8122b85037dbSmrg	done
8123b85037dbSmrg
8124b85037dbSmrg	# Use standard objects if they are pic
8125b85037dbSmrg	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
8126b85037dbSmrg	test "X$libobjs" = "X " && libobjs=
8127b85037dbSmrg
8128b85037dbSmrg	delfiles=
8129b85037dbSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
8130b85037dbSmrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
8131b85037dbSmrg	  export_symbols="$output_objdir/$libname.uexp"
8132302b15bdSmrg	  func_append delfiles " $export_symbols"
8133b85037dbSmrg	fi
8134b85037dbSmrg
8135b85037dbSmrg	orig_export_symbols=
8136b85037dbSmrg	case $host_os in
8137b85037dbSmrg	cygwin* | mingw* | cegcc*)
8138b85037dbSmrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
8139b85037dbSmrg	    # exporting using user supplied symfile
8140b85037dbSmrg	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
8141b85037dbSmrg	      # and it's NOT already a .def file. Must figure out
8142b85037dbSmrg	      # which of the given symbols are data symbols and tag
8143b85037dbSmrg	      # them as such. So, trigger use of export_symbols_cmds.
8144b85037dbSmrg	      # export_symbols gets reassigned inside the "prepare
8145b85037dbSmrg	      # the list of exported symbols" if statement, so the
8146b85037dbSmrg	      # include_expsyms logic still works.
8147b85037dbSmrg	      orig_export_symbols="$export_symbols"
8148b85037dbSmrg	      export_symbols=
8149b85037dbSmrg	      always_export_symbols=yes
8150b85037dbSmrg	    fi
8151b85037dbSmrg	  fi
8152b85037dbSmrg	  ;;
8153b85037dbSmrg	esac
8154b85037dbSmrg
8155b85037dbSmrg	# Prepare the list of exported symbols
8156b85037dbSmrg	if test -z "$export_symbols"; then
8157b85037dbSmrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
8158b85037dbSmrg	    func_verbose "generating symbol list for \`$libname.la'"
8159b85037dbSmrg	    export_symbols="$output_objdir/$libname.exp"
8160b85037dbSmrg	    $opt_dry_run || $RM $export_symbols
8161b85037dbSmrg	    cmds=$export_symbols_cmds
8162b85037dbSmrg	    save_ifs="$IFS"; IFS='~'
8163302b15bdSmrg	    for cmd1 in $cmds; do
8164b85037dbSmrg	      IFS="$save_ifs"
8165302b15bdSmrg	      # Take the normal branch if the nm_file_list_spec branch
8166302b15bdSmrg	      # doesn't work or if tool conversion is not needed.
8167302b15bdSmrg	      case $nm_file_list_spec~$to_tool_file_cmd in
8168302b15bdSmrg		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
8169302b15bdSmrg		  try_normal_branch=yes
8170302b15bdSmrg		  eval cmd=\"$cmd1\"
8171302b15bdSmrg		  func_len " $cmd"
8172302b15bdSmrg		  len=$func_len_result
8173302b15bdSmrg		  ;;
8174302b15bdSmrg		*)
8175302b15bdSmrg		  try_normal_branch=no
8176302b15bdSmrg		  ;;
8177302b15bdSmrg	      esac
8178302b15bdSmrg	      if test "$try_normal_branch" = yes \
8179302b15bdSmrg		 && { test "$len" -lt "$max_cmd_len" \
8180302b15bdSmrg		      || test "$max_cmd_len" -le -1; }
8181302b15bdSmrg	      then
8182302b15bdSmrg		func_show_eval "$cmd" 'exit $?'
8183302b15bdSmrg		skipped_export=false
8184302b15bdSmrg	      elif test -n "$nm_file_list_spec"; then
8185302b15bdSmrg		func_basename "$output"
8186302b15bdSmrg		output_la=$func_basename_result
8187302b15bdSmrg		save_libobjs=$libobjs
8188302b15bdSmrg		save_output=$output
8189302b15bdSmrg		output=${output_objdir}/${output_la}.nm
8190302b15bdSmrg		func_to_tool_file "$output"
8191302b15bdSmrg		libobjs=$nm_file_list_spec$func_to_tool_file_result
8192302b15bdSmrg		func_append delfiles " $output"
8193302b15bdSmrg		func_verbose "creating $NM input file list: $output"
8194302b15bdSmrg		for obj in $save_libobjs; do
8195302b15bdSmrg		  func_to_tool_file "$obj"
8196302b15bdSmrg		  $ECHO "$func_to_tool_file_result"
8197302b15bdSmrg		done > "$output"
8198302b15bdSmrg		eval cmd=\"$cmd1\"
8199b85037dbSmrg		func_show_eval "$cmd" 'exit $?'
8200302b15bdSmrg		output=$save_output
8201302b15bdSmrg		libobjs=$save_libobjs
8202b85037dbSmrg		skipped_export=false
8203b85037dbSmrg	      else
8204b85037dbSmrg		# The command line is too long to execute in one step.
8205b85037dbSmrg		func_verbose "using reloadable object file for export list..."
8206b85037dbSmrg		skipped_export=:
8207b85037dbSmrg		# Break out early, otherwise skipped_export may be
8208b85037dbSmrg		# set to false by a later but shorter cmd.
8209b85037dbSmrg		break
8210b85037dbSmrg	      fi
8211b85037dbSmrg	    done
8212b85037dbSmrg	    IFS="$save_ifs"
8213b85037dbSmrg	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
8214b85037dbSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8215b85037dbSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8216b85037dbSmrg	    fi
8217b85037dbSmrg	  fi
8218b85037dbSmrg	fi
8219b85037dbSmrg
8220b85037dbSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
8221b85037dbSmrg	  tmp_export_symbols="$export_symbols"
8222b85037dbSmrg	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
8223b85037dbSmrg	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8224b85037dbSmrg	fi
8225b85037dbSmrg
8226b85037dbSmrg	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
8227b85037dbSmrg	  # The given exports_symbols file has to be filtered, so filter it.
8228b85037dbSmrg	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8229b85037dbSmrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
8230b85037dbSmrg	  # 's' commands which not all seds can handle. GNU sed should be fine
8231b85037dbSmrg	  # though. Also, the filter scales superlinearly with the number of
8232b85037dbSmrg	  # global variables. join(1) would be nice here, but unfortunately
8233b85037dbSmrg	  # isn't a blessed tool.
8234b85037dbSmrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8235302b15bdSmrg	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
8236b85037dbSmrg	  export_symbols=$output_objdir/$libname.def
8237b85037dbSmrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
8238b85037dbSmrg	fi
8239b85037dbSmrg
8240b85037dbSmrg	tmp_deplibs=
8241b85037dbSmrg	for test_deplib in $deplibs; do
8242b85037dbSmrg	  case " $convenience " in
8243b85037dbSmrg	  *" $test_deplib "*) ;;
8244b85037dbSmrg	  *)
8245302b15bdSmrg	    func_append tmp_deplibs " $test_deplib"
8246b85037dbSmrg	    ;;
8247b85037dbSmrg	  esac
8248b85037dbSmrg	done
8249b85037dbSmrg	deplibs="$tmp_deplibs"
8250b85037dbSmrg
8251b85037dbSmrg	if test -n "$convenience"; then
8252b85037dbSmrg	  if test -n "$whole_archive_flag_spec" &&
8253b85037dbSmrg	    test "$compiler_needs_object" = yes &&
8254b85037dbSmrg	    test -z "$libobjs"; then
8255b85037dbSmrg	    # extract the archives, so we have objects to list.
8256b85037dbSmrg	    # TODO: could optimize this to just extract one archive.
8257b85037dbSmrg	    whole_archive_flag_spec=
8258b85037dbSmrg	  fi
8259b85037dbSmrg	  if test -n "$whole_archive_flag_spec"; then
8260b85037dbSmrg	    save_libobjs=$libobjs
8261b85037dbSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8262b85037dbSmrg	    test "X$libobjs" = "X " && libobjs=
8263b85037dbSmrg	  else
8264b85037dbSmrg	    gentop="$output_objdir/${outputname}x"
8265302b15bdSmrg	    func_append generated " $gentop"
8266b85037dbSmrg
8267b85037dbSmrg	    func_extract_archives $gentop $convenience
8268302b15bdSmrg	    func_append libobjs " $func_extract_archives_result"
8269b85037dbSmrg	    test "X$libobjs" = "X " && libobjs=
8270b85037dbSmrg	  fi
8271b85037dbSmrg	fi
8272b85037dbSmrg
8273b85037dbSmrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
8274b85037dbSmrg	  eval flag=\"$thread_safe_flag_spec\"
8275302b15bdSmrg	  func_append linker_flags " $flag"
8276b85037dbSmrg	fi
8277b85037dbSmrg
8278b85037dbSmrg	# Make a backup of the uninstalled library when relinking
8279302b15bdSmrg	if test "$opt_mode" = relink; then
8280b85037dbSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
8281b85037dbSmrg	fi
8282b85037dbSmrg
8283b85037dbSmrg	# Do each of the archive commands.
8284b85037dbSmrg	if test "$module" = yes && test -n "$module_cmds" ; then
8285b85037dbSmrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8286b85037dbSmrg	    eval test_cmds=\"$module_expsym_cmds\"
8287b85037dbSmrg	    cmds=$module_expsym_cmds
8288b85037dbSmrg	  else
8289b85037dbSmrg	    eval test_cmds=\"$module_cmds\"
8290b85037dbSmrg	    cmds=$module_cmds
8291b85037dbSmrg	  fi
8292b85037dbSmrg	else
8293b85037dbSmrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8294b85037dbSmrg	    eval test_cmds=\"$archive_expsym_cmds\"
8295b85037dbSmrg	    cmds=$archive_expsym_cmds
8296b85037dbSmrg	  else
8297b85037dbSmrg	    eval test_cmds=\"$archive_cmds\"
8298b85037dbSmrg	    cmds=$archive_cmds
8299b85037dbSmrg	  fi
8300b85037dbSmrg	fi
8301b85037dbSmrg
8302b85037dbSmrg	if test "X$skipped_export" != "X:" &&
8303b85037dbSmrg	   func_len " $test_cmds" &&
8304b85037dbSmrg	   len=$func_len_result &&
8305b85037dbSmrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
8306b85037dbSmrg	  :
8307b85037dbSmrg	else
8308b85037dbSmrg	  # The command line is too long to link in one step, link piecewise
8309b85037dbSmrg	  # or, if using GNU ld and skipped_export is not :, use a linker
8310b85037dbSmrg	  # script.
8311b85037dbSmrg
8312b85037dbSmrg	  # Save the value of $output and $libobjs because we want to
8313b85037dbSmrg	  # use them later.  If we have whole_archive_flag_spec, we
8314b85037dbSmrg	  # want to use save_libobjs as it was before
8315b85037dbSmrg	  # whole_archive_flag_spec was expanded, because we can't
8316b85037dbSmrg	  # assume the linker understands whole_archive_flag_spec.
8317b85037dbSmrg	  # This may have to be revisited, in case too many
8318b85037dbSmrg	  # convenience libraries get linked in and end up exceeding
8319b85037dbSmrg	  # the spec.
8320b85037dbSmrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
8321b85037dbSmrg	    save_libobjs=$libobjs
8322b85037dbSmrg	  fi
8323b85037dbSmrg	  save_output=$output
8324b85037dbSmrg	  func_basename "$output"
8325b85037dbSmrg	  output_la=$func_basename_result
8326b85037dbSmrg
8327b85037dbSmrg	  # Clear the reloadable object creation command queue and
8328b85037dbSmrg	  # initialize k to one.
8329b85037dbSmrg	  test_cmds=
8330b85037dbSmrg	  concat_cmds=
8331b85037dbSmrg	  objlist=
8332b85037dbSmrg	  last_robj=
8333b85037dbSmrg	  k=1
8334b85037dbSmrg
8335b85037dbSmrg	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
8336b85037dbSmrg	    output=${output_objdir}/${output_la}.lnkscript
8337b85037dbSmrg	    func_verbose "creating GNU ld script: $output"
8338b85037dbSmrg	    echo 'INPUT (' > $output
8339b85037dbSmrg	    for obj in $save_libobjs
8340b85037dbSmrg	    do
8341302b15bdSmrg	      func_to_tool_file "$obj"
8342302b15bdSmrg	      $ECHO "$func_to_tool_file_result" >> $output
8343b85037dbSmrg	    done
8344b85037dbSmrg	    echo ')' >> $output
8345302b15bdSmrg	    func_append delfiles " $output"
8346302b15bdSmrg	    func_to_tool_file "$output"
8347302b15bdSmrg	    output=$func_to_tool_file_result
8348b85037dbSmrg	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
8349b85037dbSmrg	    output=${output_objdir}/${output_la}.lnk
8350b85037dbSmrg	    func_verbose "creating linker input file list: $output"
8351b85037dbSmrg	    : > $output
8352b85037dbSmrg	    set x $save_libobjs
8353b85037dbSmrg	    shift
8354b85037dbSmrg	    firstobj=
8355b85037dbSmrg	    if test "$compiler_needs_object" = yes; then
8356b85037dbSmrg	      firstobj="$1 "
8357b85037dbSmrg	      shift
8358b85037dbSmrg	    fi
8359b85037dbSmrg	    for obj
8360b85037dbSmrg	    do
8361302b15bdSmrg	      func_to_tool_file "$obj"
8362302b15bdSmrg	      $ECHO "$func_to_tool_file_result" >> $output
8363b85037dbSmrg	    done
8364302b15bdSmrg	    func_append delfiles " $output"
8365302b15bdSmrg	    func_to_tool_file "$output"
8366302b15bdSmrg	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
8367b85037dbSmrg	  else
8368b85037dbSmrg	    if test -n "$save_libobjs"; then
8369b85037dbSmrg	      func_verbose "creating reloadable object files..."
8370b85037dbSmrg	      output=$output_objdir/$output_la-${k}.$objext
8371b85037dbSmrg	      eval test_cmds=\"$reload_cmds\"
8372b85037dbSmrg	      func_len " $test_cmds"
8373b85037dbSmrg	      len0=$func_len_result
8374b85037dbSmrg	      len=$len0
8375b85037dbSmrg
8376b85037dbSmrg	      # Loop over the list of objects to be linked.
8377b85037dbSmrg	      for obj in $save_libobjs
8378b85037dbSmrg	      do
8379b85037dbSmrg		func_len " $obj"
8380b85037dbSmrg		func_arith $len + $func_len_result
8381b85037dbSmrg		len=$func_arith_result
8382b85037dbSmrg		if test "X$objlist" = X ||
8383b85037dbSmrg		   test "$len" -lt "$max_cmd_len"; then
8384b85037dbSmrg		  func_append objlist " $obj"
8385b85037dbSmrg		else
8386b85037dbSmrg		  # The command $test_cmds is almost too long, add a
8387b85037dbSmrg		  # command to the queue.
8388b85037dbSmrg		  if test "$k" -eq 1 ; then
8389b85037dbSmrg		    # The first file doesn't have a previous command to add.
8390b85037dbSmrg		    reload_objs=$objlist
8391b85037dbSmrg		    eval concat_cmds=\"$reload_cmds\"
8392b85037dbSmrg		  else
8393b85037dbSmrg		    # All subsequent reloadable object files will link in
8394b85037dbSmrg		    # the last one created.
8395b85037dbSmrg		    reload_objs="$objlist $last_robj"
8396b85037dbSmrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
8397b85037dbSmrg		  fi
8398b85037dbSmrg		  last_robj=$output_objdir/$output_la-${k}.$objext
8399b85037dbSmrg		  func_arith $k + 1
8400b85037dbSmrg		  k=$func_arith_result
8401b85037dbSmrg		  output=$output_objdir/$output_la-${k}.$objext
8402b85037dbSmrg		  objlist=" $obj"
8403b85037dbSmrg		  func_len " $last_robj"
8404b85037dbSmrg		  func_arith $len0 + $func_len_result
8405b85037dbSmrg		  len=$func_arith_result
8406b85037dbSmrg		fi
8407b85037dbSmrg	      done
8408b85037dbSmrg	      # Handle the remaining objects by creating one last
8409b85037dbSmrg	      # reloadable object file.  All subsequent reloadable object
8410b85037dbSmrg	      # files will link in the last one created.
8411b85037dbSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8412b85037dbSmrg	      reload_objs="$objlist $last_robj"
8413b85037dbSmrg	      eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
8414b85037dbSmrg	      if test -n "$last_robj"; then
8415b85037dbSmrg	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
8416b85037dbSmrg	      fi
8417302b15bdSmrg	      func_append delfiles " $output"
8418b85037dbSmrg
8419b85037dbSmrg	    else
8420b85037dbSmrg	      output=
8421b85037dbSmrg	    fi
8422b85037dbSmrg
8423b85037dbSmrg	    if ${skipped_export-false}; then
8424b85037dbSmrg	      func_verbose "generating symbol list for \`$libname.la'"
8425b85037dbSmrg	      export_symbols="$output_objdir/$libname.exp"
8426b85037dbSmrg	      $opt_dry_run || $RM $export_symbols
8427b85037dbSmrg	      libobjs=$output
8428b85037dbSmrg	      # Append the command to create the export file.
8429b85037dbSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8430b85037dbSmrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
8431b85037dbSmrg	      if test -n "$last_robj"; then
8432b85037dbSmrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
8433b85037dbSmrg	      fi
8434b85037dbSmrg	    fi
8435b85037dbSmrg
8436b85037dbSmrg	    test -n "$save_libobjs" &&
8437b85037dbSmrg	      func_verbose "creating a temporary reloadable object file: $output"
8438b85037dbSmrg
8439b85037dbSmrg	    # Loop through the commands generated above and execute them.
8440b85037dbSmrg	    save_ifs="$IFS"; IFS='~'
8441b85037dbSmrg	    for cmd in $concat_cmds; do
8442b85037dbSmrg	      IFS="$save_ifs"
8443b85037dbSmrg	      $opt_silent || {
8444b85037dbSmrg		  func_quote_for_expand "$cmd"
8445b85037dbSmrg		  eval "func_echo $func_quote_for_expand_result"
8446b85037dbSmrg	      }
8447b85037dbSmrg	      $opt_dry_run || eval "$cmd" || {
8448b85037dbSmrg		lt_exit=$?
8449b85037dbSmrg
8450b85037dbSmrg		# Restore the uninstalled library and exit
8451302b15bdSmrg		if test "$opt_mode" = relink; then
8452b85037dbSmrg		  ( cd "$output_objdir" && \
8453b85037dbSmrg		    $RM "${realname}T" && \
8454b85037dbSmrg		    $MV "${realname}U" "$realname" )
8455b85037dbSmrg		fi
8456b85037dbSmrg
8457b85037dbSmrg		exit $lt_exit
8458b85037dbSmrg	      }
8459b85037dbSmrg	    done
8460b85037dbSmrg	    IFS="$save_ifs"
8461b85037dbSmrg
8462b85037dbSmrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
8463b85037dbSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8464b85037dbSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8465b85037dbSmrg	    fi
8466b85037dbSmrg	  fi
8467b85037dbSmrg
8468b85037dbSmrg          if ${skipped_export-false}; then
8469b85037dbSmrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
8470b85037dbSmrg	      tmp_export_symbols="$export_symbols"
8471b85037dbSmrg	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
8472b85037dbSmrg	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8473b85037dbSmrg	    fi
8474b85037dbSmrg
8475b85037dbSmrg	    if test -n "$orig_export_symbols"; then
8476b85037dbSmrg	      # The given exports_symbols file has to be filtered, so filter it.
8477b85037dbSmrg	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8478b85037dbSmrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
8479b85037dbSmrg	      # 's' commands which not all seds can handle. GNU sed should be fine
8480b85037dbSmrg	      # though. Also, the filter scales superlinearly with the number of
8481b85037dbSmrg	      # global variables. join(1) would be nice here, but unfortunately
8482b85037dbSmrg	      # isn't a blessed tool.
8483b85037dbSmrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8484302b15bdSmrg	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
8485b85037dbSmrg	      export_symbols=$output_objdir/$libname.def
8486b85037dbSmrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
8487b85037dbSmrg	    fi
8488b85037dbSmrg	  fi
8489b85037dbSmrg
8490b85037dbSmrg	  libobjs=$output
8491b85037dbSmrg	  # Restore the value of output.
8492b85037dbSmrg	  output=$save_output
8493b85037dbSmrg
8494b85037dbSmrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
8495b85037dbSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8496b85037dbSmrg	    test "X$libobjs" = "X " && libobjs=
8497b85037dbSmrg	  fi
8498b85037dbSmrg	  # Expand the library linking commands again to reset the
8499b85037dbSmrg	  # value of $libobjs for piecewise linking.
8500b85037dbSmrg
8501b85037dbSmrg	  # Do each of the archive commands.
8502b85037dbSmrg	  if test "$module" = yes && test -n "$module_cmds" ; then
8503b85037dbSmrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8504b85037dbSmrg	      cmds=$module_expsym_cmds
8505b85037dbSmrg	    else
8506b85037dbSmrg	      cmds=$module_cmds
8507b85037dbSmrg	    fi
8508b85037dbSmrg	  else
8509b85037dbSmrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8510b85037dbSmrg	      cmds=$archive_expsym_cmds
8511b85037dbSmrg	    else
8512b85037dbSmrg	      cmds=$archive_cmds
8513b85037dbSmrg	    fi
8514b85037dbSmrg	  fi
8515b85037dbSmrg	fi
8516b85037dbSmrg
8517b85037dbSmrg	if test -n "$delfiles"; then
8518b85037dbSmrg	  # Append the command to remove temporary files to $cmds.
8519b85037dbSmrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
8520b85037dbSmrg	fi
8521b85037dbSmrg
8522b85037dbSmrg	# Add any objects from preloaded convenience libraries
8523b85037dbSmrg	if test -n "$dlprefiles"; then
8524b85037dbSmrg	  gentop="$output_objdir/${outputname}x"
8525302b15bdSmrg	  func_append generated " $gentop"
8526b85037dbSmrg
8527b85037dbSmrg	  func_extract_archives $gentop $dlprefiles
8528302b15bdSmrg	  func_append libobjs " $func_extract_archives_result"
8529b85037dbSmrg	  test "X$libobjs" = "X " && libobjs=
8530b85037dbSmrg	fi
8531b85037dbSmrg
8532b85037dbSmrg	save_ifs="$IFS"; IFS='~'
8533b85037dbSmrg	for cmd in $cmds; do
8534b85037dbSmrg	  IFS="$save_ifs"
8535b85037dbSmrg	  eval cmd=\"$cmd\"
8536b85037dbSmrg	  $opt_silent || {
8537b85037dbSmrg	    func_quote_for_expand "$cmd"
8538b85037dbSmrg	    eval "func_echo $func_quote_for_expand_result"
8539b85037dbSmrg	  }
8540b85037dbSmrg	  $opt_dry_run || eval "$cmd" || {
8541b85037dbSmrg	    lt_exit=$?
8542b85037dbSmrg
8543b85037dbSmrg	    # Restore the uninstalled library and exit
8544302b15bdSmrg	    if test "$opt_mode" = relink; then
8545b85037dbSmrg	      ( cd "$output_objdir" && \
8546b85037dbSmrg	        $RM "${realname}T" && \
8547b85037dbSmrg		$MV "${realname}U" "$realname" )
8548b85037dbSmrg	    fi
8549b85037dbSmrg
8550b85037dbSmrg	    exit $lt_exit
8551b85037dbSmrg	  }
8552b85037dbSmrg	done
8553b85037dbSmrg	IFS="$save_ifs"
8554b85037dbSmrg
8555b85037dbSmrg	# Restore the uninstalled library and exit
8556302b15bdSmrg	if test "$opt_mode" = relink; then
8557b85037dbSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
8558b85037dbSmrg
8559b85037dbSmrg	  if test -n "$convenience"; then
8560b85037dbSmrg	    if test -z "$whole_archive_flag_spec"; then
8561b85037dbSmrg	      func_show_eval '${RM}r "$gentop"'
8562b85037dbSmrg	    fi
8563b85037dbSmrg	  fi
8564b85037dbSmrg
8565b85037dbSmrg	  exit $EXIT_SUCCESS
8566b85037dbSmrg	fi
8567b85037dbSmrg
8568b85037dbSmrg	# Create links to the real library.
8569b85037dbSmrg	for linkname in $linknames; do
8570b85037dbSmrg	  if test "$realname" != "$linkname"; then
8571b85037dbSmrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
8572b85037dbSmrg	  fi
8573b85037dbSmrg	done
8574b85037dbSmrg
8575b85037dbSmrg	# If -module or -export-dynamic was specified, set the dlname.
8576b85037dbSmrg	if test "$module" = yes || test "$export_dynamic" = yes; then
8577b85037dbSmrg	  # On all known operating systems, these are identical.
8578b85037dbSmrg	  dlname="$soname"
8579b85037dbSmrg	fi
8580b85037dbSmrg      fi
8581b85037dbSmrg      ;;
8582b85037dbSmrg
8583b85037dbSmrg    obj)
8584b85037dbSmrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
8585b85037dbSmrg	func_warning "\`-dlopen' is ignored for objects"
8586b85037dbSmrg      fi
8587b85037dbSmrg
8588b85037dbSmrg      case " $deplibs" in
8589b85037dbSmrg      *\ -l* | *\ -L*)
8590b85037dbSmrg	func_warning "\`-l' and \`-L' are ignored for objects" ;;
8591b85037dbSmrg      esac
8592b85037dbSmrg
8593b85037dbSmrg      test -n "$rpath" && \
8594b85037dbSmrg	func_warning "\`-rpath' is ignored for objects"
8595b85037dbSmrg
8596b85037dbSmrg      test -n "$xrpath" && \
8597b85037dbSmrg	func_warning "\`-R' is ignored for objects"
8598b85037dbSmrg
8599b85037dbSmrg      test -n "$vinfo" && \
8600b85037dbSmrg	func_warning "\`-version-info' is ignored for objects"
8601b85037dbSmrg
8602b85037dbSmrg      test -n "$release" && \
8603b85037dbSmrg	func_warning "\`-release' is ignored for objects"
8604b85037dbSmrg
8605b85037dbSmrg      case $output in
8606b85037dbSmrg      *.lo)
8607b85037dbSmrg	test -n "$objs$old_deplibs" && \
8608b85037dbSmrg	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
8609b85037dbSmrg
8610b85037dbSmrg	libobj=$output
8611b85037dbSmrg	func_lo2o "$libobj"
8612b85037dbSmrg	obj=$func_lo2o_result
8613b85037dbSmrg	;;
8614b85037dbSmrg      *)
8615b85037dbSmrg	libobj=
8616b85037dbSmrg	obj="$output"
8617b85037dbSmrg	;;
8618b85037dbSmrg      esac
8619b85037dbSmrg
8620b85037dbSmrg      # Delete the old objects.
8621b85037dbSmrg      $opt_dry_run || $RM $obj $libobj
8622b85037dbSmrg
8623b85037dbSmrg      # Objects from convenience libraries.  This assumes
8624b85037dbSmrg      # single-version convenience libraries.  Whenever we create
8625b85037dbSmrg      # different ones for PIC/non-PIC, this we'll have to duplicate
8626b85037dbSmrg      # the extraction.
8627b85037dbSmrg      reload_conv_objs=
8628b85037dbSmrg      gentop=
8629b85037dbSmrg      # reload_cmds runs $LD directly, so let us get rid of
8630b85037dbSmrg      # -Wl from whole_archive_flag_spec and hope we can get by with
8631b85037dbSmrg      # turning comma into space..
8632b85037dbSmrg      wl=
8633b85037dbSmrg
8634b85037dbSmrg      if test -n "$convenience"; then
8635b85037dbSmrg	if test -n "$whole_archive_flag_spec"; then
8636b85037dbSmrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
8637b85037dbSmrg	  reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
8638b85037dbSmrg	else
8639b85037dbSmrg	  gentop="$output_objdir/${obj}x"
8640302b15bdSmrg	  func_append generated " $gentop"
8641b85037dbSmrg
8642b85037dbSmrg	  func_extract_archives $gentop $convenience
8643b85037dbSmrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
8644b85037dbSmrg	fi
8645b85037dbSmrg      fi
8646b85037dbSmrg
8647302b15bdSmrg      # If we're not building shared, we need to use non_pic_objs
8648302b15bdSmrg      test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
8649302b15bdSmrg
8650b85037dbSmrg      # Create the old-style object.
8651b85037dbSmrg      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
8652b85037dbSmrg
8653b85037dbSmrg      output="$obj"
8654b85037dbSmrg      func_execute_cmds "$reload_cmds" 'exit $?'
8655b85037dbSmrg
8656b85037dbSmrg      # Exit if we aren't doing a library object file.
8657b85037dbSmrg      if test -z "$libobj"; then
8658b85037dbSmrg	if test -n "$gentop"; then
8659b85037dbSmrg	  func_show_eval '${RM}r "$gentop"'
8660b85037dbSmrg	fi
8661b85037dbSmrg
8662b85037dbSmrg	exit $EXIT_SUCCESS
8663b85037dbSmrg      fi
8664b85037dbSmrg
8665b85037dbSmrg      if test "$build_libtool_libs" != yes; then
8666b85037dbSmrg	if test -n "$gentop"; then
8667b85037dbSmrg	  func_show_eval '${RM}r "$gentop"'
8668b85037dbSmrg	fi
8669b85037dbSmrg
8670b85037dbSmrg	# Create an invalid libtool object if no PIC, so that we don't
8671b85037dbSmrg	# accidentally link it into a program.
8672b85037dbSmrg	# $show "echo timestamp > $libobj"
8673b85037dbSmrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
8674b85037dbSmrg	exit $EXIT_SUCCESS
8675b85037dbSmrg      fi
8676b85037dbSmrg
8677b85037dbSmrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
8678b85037dbSmrg	# Only do commands if we really have different PIC objects.
8679b85037dbSmrg	reload_objs="$libobjs $reload_conv_objs"
8680b85037dbSmrg	output="$libobj"
8681b85037dbSmrg	func_execute_cmds "$reload_cmds" 'exit $?'
8682b85037dbSmrg      fi
8683b85037dbSmrg
8684b85037dbSmrg      if test -n "$gentop"; then
8685b85037dbSmrg	func_show_eval '${RM}r "$gentop"'
8686b85037dbSmrg      fi
8687b85037dbSmrg
8688b85037dbSmrg      exit $EXIT_SUCCESS
8689b85037dbSmrg      ;;
8690b85037dbSmrg
8691b85037dbSmrg    prog)
8692b85037dbSmrg      case $host in
8693b85037dbSmrg	*cygwin*) func_stripname '' '.exe' "$output"
8694b85037dbSmrg	          output=$func_stripname_result.exe;;
8695b85037dbSmrg      esac
8696b85037dbSmrg      test -n "$vinfo" && \
8697b85037dbSmrg	func_warning "\`-version-info' is ignored for programs"
8698b85037dbSmrg
8699b85037dbSmrg      test -n "$release" && \
8700b85037dbSmrg	func_warning "\`-release' is ignored for programs"
8701b85037dbSmrg
8702b85037dbSmrg      test "$preload" = yes \
8703b85037dbSmrg        && test "$dlopen_support" = unknown \
8704b85037dbSmrg	&& test "$dlopen_self" = unknown \
8705b85037dbSmrg	&& test "$dlopen_self_static" = unknown && \
8706b85037dbSmrg	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
8707b85037dbSmrg
8708b85037dbSmrg      case $host in
8709b85037dbSmrg      *-*-rhapsody* | *-*-darwin1.[012])
8710b85037dbSmrg	# On Rhapsody replace the C library is the System framework
8711b85037dbSmrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
8712b85037dbSmrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
8713b85037dbSmrg	;;
8714b85037dbSmrg      esac
8715b85037dbSmrg
8716b85037dbSmrg      case $host in
8717b85037dbSmrg      *-*-darwin*)
8718b85037dbSmrg	# Don't allow lazy linking, it breaks C++ global constructors
8719b85037dbSmrg	# But is supposedly fixed on 10.4 or later (yay!).
8720b85037dbSmrg	if test "$tagname" = CXX ; then
8721b85037dbSmrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
8722b85037dbSmrg	    10.[0123])
8723302b15bdSmrg	      func_append compile_command " ${wl}-bind_at_load"
8724302b15bdSmrg	      func_append finalize_command " ${wl}-bind_at_load"
8725b85037dbSmrg	    ;;
8726b85037dbSmrg	  esac
8727b85037dbSmrg	fi
8728b85037dbSmrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
8729b85037dbSmrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8730b85037dbSmrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8731b85037dbSmrg	;;
8732b85037dbSmrg      esac
8733b85037dbSmrg
8734b85037dbSmrg
8735b85037dbSmrg      # move library search paths that coincide with paths to not yet
8736b85037dbSmrg      # installed libraries to the beginning of the library search list
8737b85037dbSmrg      new_libs=
8738b85037dbSmrg      for path in $notinst_path; do
8739b85037dbSmrg	case " $new_libs " in
8740b85037dbSmrg	*" -L$path/$objdir "*) ;;
8741b85037dbSmrg	*)
8742b85037dbSmrg	  case " $compile_deplibs " in
8743b85037dbSmrg	  *" -L$path/$objdir "*)
8744302b15bdSmrg	    func_append new_libs " -L$path/$objdir" ;;
8745b85037dbSmrg	  esac
8746b85037dbSmrg	  ;;
8747b85037dbSmrg	esac
8748b85037dbSmrg      done
8749b85037dbSmrg      for deplib in $compile_deplibs; do
8750b85037dbSmrg	case $deplib in
8751b85037dbSmrg	-L*)
8752b85037dbSmrg	  case " $new_libs " in
8753b85037dbSmrg	  *" $deplib "*) ;;
8754302b15bdSmrg	  *) func_append new_libs " $deplib" ;;
8755b85037dbSmrg	  esac
8756b85037dbSmrg	  ;;
8757302b15bdSmrg	*) func_append new_libs " $deplib" ;;
8758b85037dbSmrg	esac
8759b85037dbSmrg      done
8760b85037dbSmrg      compile_deplibs="$new_libs"
8761b85037dbSmrg
8762b85037dbSmrg
8763302b15bdSmrg      func_append compile_command " $compile_deplibs"
8764302b15bdSmrg      func_append finalize_command " $finalize_deplibs"
8765b85037dbSmrg
8766b85037dbSmrg      if test -n "$rpath$xrpath"; then
8767b85037dbSmrg	# If the user specified any rpath flags, then add them.
8768b85037dbSmrg	for libdir in $rpath $xrpath; do
8769b85037dbSmrg	  # This is the magic to use -rpath.
8770b85037dbSmrg	  case "$finalize_rpath " in
8771b85037dbSmrg	  *" $libdir "*) ;;
8772302b15bdSmrg	  *) func_append finalize_rpath " $libdir" ;;
8773b85037dbSmrg	  esac
8774b85037dbSmrg	done
8775b85037dbSmrg      fi
8776b85037dbSmrg
8777b85037dbSmrg      # Now hardcode the library paths
8778b85037dbSmrg      rpath=
8779b85037dbSmrg      hardcode_libdirs=
8780b85037dbSmrg      for libdir in $compile_rpath $finalize_rpath; do
8781b85037dbSmrg	if test -n "$hardcode_libdir_flag_spec"; then
8782b85037dbSmrg	  if test -n "$hardcode_libdir_separator"; then
8783b85037dbSmrg	    if test -z "$hardcode_libdirs"; then
8784b85037dbSmrg	      hardcode_libdirs="$libdir"
8785b85037dbSmrg	    else
8786b85037dbSmrg	      # Just accumulate the unique libdirs.
8787b85037dbSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8788b85037dbSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8789b85037dbSmrg		;;
8790b85037dbSmrg	      *)
8791302b15bdSmrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8792b85037dbSmrg		;;
8793b85037dbSmrg	      esac
8794b85037dbSmrg	    fi
8795b85037dbSmrg	  else
8796b85037dbSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
8797302b15bdSmrg	    func_append rpath " $flag"
8798b85037dbSmrg	  fi
8799b85037dbSmrg	elif test -n "$runpath_var"; then
8800b85037dbSmrg	  case "$perm_rpath " in
8801b85037dbSmrg	  *" $libdir "*) ;;
8802302b15bdSmrg	  *) func_append perm_rpath " $libdir" ;;
8803b85037dbSmrg	  esac
8804b85037dbSmrg	fi
8805b85037dbSmrg	case $host in
8806b85037dbSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
8807b85037dbSmrg	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
8808b85037dbSmrg	  case :$dllsearchpath: in
8809b85037dbSmrg	  *":$libdir:"*) ;;
8810b85037dbSmrg	  ::) dllsearchpath=$libdir;;
8811302b15bdSmrg	  *) func_append dllsearchpath ":$libdir";;
8812b85037dbSmrg	  esac
8813b85037dbSmrg	  case :$dllsearchpath: in
8814b85037dbSmrg	  *":$testbindir:"*) ;;
8815b85037dbSmrg	  ::) dllsearchpath=$testbindir;;
8816302b15bdSmrg	  *) func_append dllsearchpath ":$testbindir";;
8817b85037dbSmrg	  esac
8818b85037dbSmrg	  ;;
8819b85037dbSmrg	esac
8820b85037dbSmrg      done
8821b85037dbSmrg      # Substitute the hardcoded libdirs into the rpath.
8822b85037dbSmrg      if test -n "$hardcode_libdir_separator" &&
8823b85037dbSmrg	 test -n "$hardcode_libdirs"; then
8824b85037dbSmrg	libdir="$hardcode_libdirs"
8825b85037dbSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
8826b85037dbSmrg      fi
8827b85037dbSmrg      compile_rpath="$rpath"
8828b85037dbSmrg
8829b85037dbSmrg      rpath=
8830b85037dbSmrg      hardcode_libdirs=
8831b85037dbSmrg      for libdir in $finalize_rpath; do
8832b85037dbSmrg	if test -n "$hardcode_libdir_flag_spec"; then
8833b85037dbSmrg	  if test -n "$hardcode_libdir_separator"; then
8834b85037dbSmrg	    if test -z "$hardcode_libdirs"; then
8835b85037dbSmrg	      hardcode_libdirs="$libdir"
8836b85037dbSmrg	    else
8837b85037dbSmrg	      # Just accumulate the unique libdirs.
8838b85037dbSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8839b85037dbSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8840b85037dbSmrg		;;
8841b85037dbSmrg	      *)
8842302b15bdSmrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8843b85037dbSmrg		;;
8844b85037dbSmrg	      esac
8845b85037dbSmrg	    fi
8846b85037dbSmrg	  else
8847b85037dbSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
8848302b15bdSmrg	    func_append rpath " $flag"
8849b85037dbSmrg	  fi
8850b85037dbSmrg	elif test -n "$runpath_var"; then
8851b85037dbSmrg	  case "$finalize_perm_rpath " in
8852b85037dbSmrg	  *" $libdir "*) ;;
8853302b15bdSmrg	  *) func_append finalize_perm_rpath " $libdir" ;;
8854b85037dbSmrg	  esac
8855b85037dbSmrg	fi
8856b85037dbSmrg      done
8857b85037dbSmrg      # Substitute the hardcoded libdirs into the rpath.
8858b85037dbSmrg      if test -n "$hardcode_libdir_separator" &&
8859b85037dbSmrg	 test -n "$hardcode_libdirs"; then
8860b85037dbSmrg	libdir="$hardcode_libdirs"
8861b85037dbSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
8862b85037dbSmrg      fi
8863b85037dbSmrg      finalize_rpath="$rpath"
8864b85037dbSmrg
8865b85037dbSmrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
8866b85037dbSmrg	# Transform all the library objects into standard objects.
8867b85037dbSmrg	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
8868b85037dbSmrg	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
8869b85037dbSmrg      fi
8870b85037dbSmrg
8871b85037dbSmrg      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
8872b85037dbSmrg
8873b85037dbSmrg      # template prelinking step
8874b85037dbSmrg      if test -n "$prelink_cmds"; then
8875b85037dbSmrg	func_execute_cmds "$prelink_cmds" 'exit $?'
8876b85037dbSmrg      fi
8877b85037dbSmrg
8878b85037dbSmrg      wrappers_required=yes
8879b85037dbSmrg      case $host in
8880b85037dbSmrg      *cegcc* | *mingw32ce*)
8881b85037dbSmrg        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
8882b85037dbSmrg        wrappers_required=no
8883b85037dbSmrg        ;;
8884b85037dbSmrg      *cygwin* | *mingw* )
8885b85037dbSmrg        if test "$build_libtool_libs" != yes; then
8886b85037dbSmrg          wrappers_required=no
8887b85037dbSmrg        fi
8888b85037dbSmrg        ;;
8889b85037dbSmrg      *)
8890b85037dbSmrg        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
8891b85037dbSmrg          wrappers_required=no
8892b85037dbSmrg        fi
8893b85037dbSmrg        ;;
8894b85037dbSmrg      esac
8895b85037dbSmrg      if test "$wrappers_required" = no; then
8896b85037dbSmrg	# Replace the output file specification.
8897b85037dbSmrg	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
8898b85037dbSmrg	link_command="$compile_command$compile_rpath"
8899b85037dbSmrg
8900b85037dbSmrg	# We have no uninstalled library dependencies, so finalize right now.
8901b85037dbSmrg	exit_status=0
8902b85037dbSmrg	func_show_eval "$link_command" 'exit_status=$?'
8903b85037dbSmrg
8904302b15bdSmrg	if test -n "$postlink_cmds"; then
8905302b15bdSmrg	  func_to_tool_file "$output"
8906302b15bdSmrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8907302b15bdSmrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
8908302b15bdSmrg	fi
8909302b15bdSmrg
8910b85037dbSmrg	# Delete the generated files.
8911b85037dbSmrg	if test -f "$output_objdir/${outputname}S.${objext}"; then
8912b85037dbSmrg	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
8913b85037dbSmrg	fi
8914b85037dbSmrg
8915b85037dbSmrg	exit $exit_status
8916b85037dbSmrg      fi
8917b85037dbSmrg
8918b85037dbSmrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
8919b85037dbSmrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
8920b85037dbSmrg      fi
8921b85037dbSmrg      if test -n "$finalize_shlibpath"; then
8922b85037dbSmrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
8923b85037dbSmrg      fi
8924b85037dbSmrg
8925b85037dbSmrg      compile_var=
8926b85037dbSmrg      finalize_var=
8927b85037dbSmrg      if test -n "$runpath_var"; then
8928b85037dbSmrg	if test -n "$perm_rpath"; then
8929b85037dbSmrg	  # We should set the runpath_var.
8930b85037dbSmrg	  rpath=
8931b85037dbSmrg	  for dir in $perm_rpath; do
8932302b15bdSmrg	    func_append rpath "$dir:"
8933b85037dbSmrg	  done
8934b85037dbSmrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
8935b85037dbSmrg	fi
8936b85037dbSmrg	if test -n "$finalize_perm_rpath"; then
8937b85037dbSmrg	  # We should set the runpath_var.
8938b85037dbSmrg	  rpath=
8939b85037dbSmrg	  for dir in $finalize_perm_rpath; do
8940302b15bdSmrg	    func_append rpath "$dir:"
8941b85037dbSmrg	  done
8942b85037dbSmrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
8943b85037dbSmrg	fi
8944b85037dbSmrg      fi
8945b85037dbSmrg
8946b85037dbSmrg      if test "$no_install" = yes; then
8947b85037dbSmrg	# We don't need to create a wrapper script.
8948b85037dbSmrg	link_command="$compile_var$compile_command$compile_rpath"
8949b85037dbSmrg	# Replace the output file specification.
8950b85037dbSmrg	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
8951b85037dbSmrg	# Delete the old output file.
8952b85037dbSmrg	$opt_dry_run || $RM $output
8953b85037dbSmrg	# Link the executable and exit
8954b85037dbSmrg	func_show_eval "$link_command" 'exit $?'
8955302b15bdSmrg
8956302b15bdSmrg	if test -n "$postlink_cmds"; then
8957302b15bdSmrg	  func_to_tool_file "$output"
8958302b15bdSmrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8959302b15bdSmrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
8960302b15bdSmrg	fi
8961302b15bdSmrg
8962b85037dbSmrg	exit $EXIT_SUCCESS
8963b85037dbSmrg      fi
8964b85037dbSmrg
8965b85037dbSmrg      if test "$hardcode_action" = relink; then
8966b85037dbSmrg	# Fast installation is not supported
8967b85037dbSmrg	link_command="$compile_var$compile_command$compile_rpath"
8968b85037dbSmrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
8969b85037dbSmrg
8970b85037dbSmrg	func_warning "this platform does not like uninstalled shared libraries"
8971b85037dbSmrg	func_warning "\`$output' will be relinked during installation"
8972b85037dbSmrg      else
8973b85037dbSmrg	if test "$fast_install" != no; then
8974b85037dbSmrg	  link_command="$finalize_var$compile_command$finalize_rpath"
8975b85037dbSmrg	  if test "$fast_install" = yes; then
8976b85037dbSmrg	    relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
8977b85037dbSmrg	  else
8978b85037dbSmrg	    # fast_install is set to needless
8979b85037dbSmrg	    relink_command=
8980b85037dbSmrg	  fi
8981b85037dbSmrg	else
8982b85037dbSmrg	  link_command="$compile_var$compile_command$compile_rpath"
8983b85037dbSmrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
8984b85037dbSmrg	fi
8985b85037dbSmrg      fi
8986b85037dbSmrg
8987b85037dbSmrg      # Replace the output file specification.
8988b85037dbSmrg      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
8989b85037dbSmrg
8990b85037dbSmrg      # Delete the old output files.
8991b85037dbSmrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
8992b85037dbSmrg
8993b85037dbSmrg      func_show_eval "$link_command" 'exit $?'
8994b85037dbSmrg
8995302b15bdSmrg      if test -n "$postlink_cmds"; then
8996302b15bdSmrg	func_to_tool_file "$output_objdir/$outputname"
8997302b15bdSmrg	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'`
8998302b15bdSmrg	func_execute_cmds "$postlink_cmds" 'exit $?'
8999302b15bdSmrg      fi
9000302b15bdSmrg
9001b85037dbSmrg      # Now create the wrapper script.
9002b85037dbSmrg      func_verbose "creating $output"
9003b85037dbSmrg
9004b85037dbSmrg      # Quote the relink command for shipping.
9005b85037dbSmrg      if test -n "$relink_command"; then
9006b85037dbSmrg	# Preserve any variables that may affect compiler behavior
9007b85037dbSmrg	for var in $variables_saved_for_relink; do
9008b85037dbSmrg	  if eval test -z \"\${$var+set}\"; then
9009b85037dbSmrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
9010b85037dbSmrg	  elif eval var_value=\$$var; test -z "$var_value"; then
9011b85037dbSmrg	    relink_command="$var=; export $var; $relink_command"
9012b85037dbSmrg	  else
9013b85037dbSmrg	    func_quote_for_eval "$var_value"
9014b85037dbSmrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9015b85037dbSmrg	  fi
9016b85037dbSmrg	done
9017b85037dbSmrg	relink_command="(cd `pwd`; $relink_command)"
9018b85037dbSmrg	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9019b85037dbSmrg      fi
9020b85037dbSmrg
9021b85037dbSmrg      # Only actually do things if not in dry run mode.
9022b85037dbSmrg      $opt_dry_run || {
9023b85037dbSmrg	# win32 will think the script is a binary if it has
9024b85037dbSmrg	# a .exe suffix, so we strip it off here.
9025b85037dbSmrg	case $output in
9026b85037dbSmrg	  *.exe) func_stripname '' '.exe' "$output"
9027b85037dbSmrg	         output=$func_stripname_result ;;
9028b85037dbSmrg	esac
9029b85037dbSmrg	# test for cygwin because mv fails w/o .exe extensions
9030b85037dbSmrg	case $host in
9031b85037dbSmrg	  *cygwin*)
9032b85037dbSmrg	    exeext=.exe
9033b85037dbSmrg	    func_stripname '' '.exe' "$outputname"
9034b85037dbSmrg	    outputname=$func_stripname_result ;;
9035b85037dbSmrg	  *) exeext= ;;
9036b85037dbSmrg	esac
9037b85037dbSmrg	case $host in
9038b85037dbSmrg	  *cygwin* | *mingw* )
9039b85037dbSmrg	    func_dirname_and_basename "$output" "" "."
9040b85037dbSmrg	    output_name=$func_basename_result
9041b85037dbSmrg	    output_path=$func_dirname_result
9042b85037dbSmrg	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
9043b85037dbSmrg	    cwrapper="$output_path/$output_name.exe"
9044b85037dbSmrg	    $RM $cwrappersource $cwrapper
9045b85037dbSmrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
9046b85037dbSmrg
9047b85037dbSmrg	    func_emit_cwrapperexe_src > $cwrappersource
9048b85037dbSmrg
9049b85037dbSmrg	    # The wrapper executable is built using the $host compiler,
9050b85037dbSmrg	    # because it contains $host paths and files. If cross-
9051b85037dbSmrg	    # compiling, it, like the target executable, must be
9052b85037dbSmrg	    # executed on the $host or under an emulation environment.
9053b85037dbSmrg	    $opt_dry_run || {
9054b85037dbSmrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
9055b85037dbSmrg	      $STRIP $cwrapper
9056b85037dbSmrg	    }
9057b85037dbSmrg
9058b85037dbSmrg	    # Now, create the wrapper script for func_source use:
9059b85037dbSmrg	    func_ltwrapper_scriptname $cwrapper
9060b85037dbSmrg	    $RM $func_ltwrapper_scriptname_result
9061b85037dbSmrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
9062b85037dbSmrg	    $opt_dry_run || {
9063b85037dbSmrg	      # note: this script will not be executed, so do not chmod.
9064b85037dbSmrg	      if test "x$build" = "x$host" ; then
9065b85037dbSmrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
9066b85037dbSmrg	      else
9067b85037dbSmrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
9068b85037dbSmrg	      fi
9069b85037dbSmrg	    }
9070b85037dbSmrg	  ;;
9071b85037dbSmrg	  * )
9072b85037dbSmrg	    $RM $output
9073b85037dbSmrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
9074b85037dbSmrg
9075b85037dbSmrg	    func_emit_wrapper no > $output
9076b85037dbSmrg	    chmod +x $output
9077b85037dbSmrg	  ;;
9078b85037dbSmrg	esac
9079b85037dbSmrg      }
9080b85037dbSmrg      exit $EXIT_SUCCESS
9081b85037dbSmrg      ;;
9082b85037dbSmrg    esac
9083b85037dbSmrg
9084b85037dbSmrg    # See if we need to build an old-fashioned archive.
9085b85037dbSmrg    for oldlib in $oldlibs; do
9086b85037dbSmrg
9087b85037dbSmrg      if test "$build_libtool_libs" = convenience; then
9088b85037dbSmrg	oldobjs="$libobjs_save $symfileobj"
9089b85037dbSmrg	addlibs="$convenience"
9090b85037dbSmrg	build_libtool_libs=no
9091b85037dbSmrg      else
9092b85037dbSmrg	if test "$build_libtool_libs" = module; then
9093b85037dbSmrg	  oldobjs="$libobjs_save"
9094b85037dbSmrg	  build_libtool_libs=no
9095b85037dbSmrg	else
9096b85037dbSmrg	  oldobjs="$old_deplibs $non_pic_objects"
9097b85037dbSmrg	  if test "$preload" = yes && test -f "$symfileobj"; then
9098302b15bdSmrg	    func_append oldobjs " $symfileobj"
9099b85037dbSmrg	  fi
9100b85037dbSmrg	fi
9101b85037dbSmrg	addlibs="$old_convenience"
9102b85037dbSmrg      fi
9103b85037dbSmrg
9104b85037dbSmrg      if test -n "$addlibs"; then
9105b85037dbSmrg	gentop="$output_objdir/${outputname}x"
9106302b15bdSmrg	func_append generated " $gentop"
9107b85037dbSmrg
9108b85037dbSmrg	func_extract_archives $gentop $addlibs
9109302b15bdSmrg	func_append oldobjs " $func_extract_archives_result"
9110b85037dbSmrg      fi
9111b85037dbSmrg
9112b85037dbSmrg      # Do each command in the archive commands.
9113b85037dbSmrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
9114b85037dbSmrg	cmds=$old_archive_from_new_cmds
9115b85037dbSmrg      else
9116b85037dbSmrg
9117b85037dbSmrg	# Add any objects from preloaded convenience libraries
9118b85037dbSmrg	if test -n "$dlprefiles"; then
9119b85037dbSmrg	  gentop="$output_objdir/${outputname}x"
9120302b15bdSmrg	  func_append generated " $gentop"
9121b85037dbSmrg
9122b85037dbSmrg	  func_extract_archives $gentop $dlprefiles
9123302b15bdSmrg	  func_append oldobjs " $func_extract_archives_result"
9124b85037dbSmrg	fi
9125b85037dbSmrg
9126b85037dbSmrg	# POSIX demands no paths to be encoded in archives.  We have
9127b85037dbSmrg	# to avoid creating archives with duplicate basenames if we
9128b85037dbSmrg	# might have to extract them afterwards, e.g., when creating a
9129b85037dbSmrg	# static archive out of a convenience library, or when linking
9130b85037dbSmrg	# the entirety of a libtool archive into another (currently
9131b85037dbSmrg	# not supported by libtool).
9132b85037dbSmrg	if (for obj in $oldobjs
9133b85037dbSmrg	    do
9134b85037dbSmrg	      func_basename "$obj"
9135b85037dbSmrg	      $ECHO "$func_basename_result"
9136b85037dbSmrg	    done | sort | sort -uc >/dev/null 2>&1); then
9137b85037dbSmrg	  :
9138b85037dbSmrg	else
9139b85037dbSmrg	  echo "copying selected object files to avoid basename conflicts..."
9140b85037dbSmrg	  gentop="$output_objdir/${outputname}x"
9141302b15bdSmrg	  func_append generated " $gentop"
9142b85037dbSmrg	  func_mkdir_p "$gentop"
9143b85037dbSmrg	  save_oldobjs=$oldobjs
9144b85037dbSmrg	  oldobjs=
9145b85037dbSmrg	  counter=1
9146b85037dbSmrg	  for obj in $save_oldobjs
9147b85037dbSmrg	  do
9148b85037dbSmrg	    func_basename "$obj"
9149b85037dbSmrg	    objbase="$func_basename_result"
9150b85037dbSmrg	    case " $oldobjs " in
9151b85037dbSmrg	    " ") oldobjs=$obj ;;
9152b85037dbSmrg	    *[\ /]"$objbase "*)
9153b85037dbSmrg	      while :; do
9154b85037dbSmrg		# Make sure we don't pick an alternate name that also
9155b85037dbSmrg		# overlaps.
9156b85037dbSmrg		newobj=lt$counter-$objbase
9157b85037dbSmrg		func_arith $counter + 1
9158b85037dbSmrg		counter=$func_arith_result
9159b85037dbSmrg		case " $oldobjs " in
9160b85037dbSmrg		*[\ /]"$newobj "*) ;;
9161b85037dbSmrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
9162b85037dbSmrg		esac
9163b85037dbSmrg	      done
9164b85037dbSmrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
9165302b15bdSmrg	      func_append oldobjs " $gentop/$newobj"
9166b85037dbSmrg	      ;;
9167302b15bdSmrg	    *) func_append oldobjs " $obj" ;;
9168b85037dbSmrg	    esac
9169b85037dbSmrg	  done
9170b85037dbSmrg	fi
917128515619Smrg	func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
917228515619Smrg	tool_oldlib=$func_to_tool_file_result
9173b85037dbSmrg	eval cmds=\"$old_archive_cmds\"
9174b85037dbSmrg
9175b85037dbSmrg	func_len " $cmds"
9176b85037dbSmrg	len=$func_len_result
9177b85037dbSmrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
9178b85037dbSmrg	  cmds=$old_archive_cmds
9179302b15bdSmrg	elif test -n "$archiver_list_spec"; then
9180302b15bdSmrg	  func_verbose "using command file archive linking..."
9181302b15bdSmrg	  for obj in $oldobjs
9182302b15bdSmrg	  do
9183302b15bdSmrg	    func_to_tool_file "$obj"
9184302b15bdSmrg	    $ECHO "$func_to_tool_file_result"
9185302b15bdSmrg	  done > $output_objdir/$libname.libcmd
9186302b15bdSmrg	  func_to_tool_file "$output_objdir/$libname.libcmd"
9187302b15bdSmrg	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
9188302b15bdSmrg	  cmds=$old_archive_cmds
9189b85037dbSmrg	else
9190b85037dbSmrg	  # the command line is too long to link in one step, link in parts
9191b85037dbSmrg	  func_verbose "using piecewise archive linking..."
9192b85037dbSmrg	  save_RANLIB=$RANLIB
9193b85037dbSmrg	  RANLIB=:
9194b85037dbSmrg	  objlist=
9195b85037dbSmrg	  concat_cmds=
9196b85037dbSmrg	  save_oldobjs=$oldobjs
9197b85037dbSmrg	  oldobjs=
9198b85037dbSmrg	  # Is there a better way of finding the last object in the list?
9199b85037dbSmrg	  for obj in $save_oldobjs
9200b85037dbSmrg	  do
9201b85037dbSmrg	    last_oldobj=$obj
9202b85037dbSmrg	  done
9203b85037dbSmrg	  eval test_cmds=\"$old_archive_cmds\"
9204b85037dbSmrg	  func_len " $test_cmds"
9205b85037dbSmrg	  len0=$func_len_result
9206b85037dbSmrg	  len=$len0
9207b85037dbSmrg	  for obj in $save_oldobjs
9208b85037dbSmrg	  do
9209b85037dbSmrg	    func_len " $obj"
9210b85037dbSmrg	    func_arith $len + $func_len_result
9211b85037dbSmrg	    len=$func_arith_result
9212b85037dbSmrg	    func_append objlist " $obj"
9213b85037dbSmrg	    if test "$len" -lt "$max_cmd_len"; then
9214b85037dbSmrg	      :
9215b85037dbSmrg	    else
9216b85037dbSmrg	      # the above command should be used before it gets too long
9217b85037dbSmrg	      oldobjs=$objlist
9218b85037dbSmrg	      if test "$obj" = "$last_oldobj" ; then
9219b85037dbSmrg		RANLIB=$save_RANLIB
9220b85037dbSmrg	      fi
9221b85037dbSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9222b85037dbSmrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
9223b85037dbSmrg	      objlist=
9224b85037dbSmrg	      len=$len0
9225b85037dbSmrg	    fi
9226b85037dbSmrg	  done
9227b85037dbSmrg	  RANLIB=$save_RANLIB
9228b85037dbSmrg	  oldobjs=$objlist
9229b85037dbSmrg	  if test "X$oldobjs" = "X" ; then
9230b85037dbSmrg	    eval cmds=\"\$concat_cmds\"
9231b85037dbSmrg	  else
9232b85037dbSmrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
9233b85037dbSmrg	  fi
9234b85037dbSmrg	fi
9235b85037dbSmrg      fi
9236b85037dbSmrg      func_execute_cmds "$cmds" 'exit $?'
9237b85037dbSmrg    done
9238b85037dbSmrg
9239b85037dbSmrg    test -n "$generated" && \
9240b85037dbSmrg      func_show_eval "${RM}r$generated"
9241b85037dbSmrg
9242b85037dbSmrg    # Now create the libtool archive.
9243b85037dbSmrg    case $output in
9244b85037dbSmrg    *.la)
9245b85037dbSmrg      old_library=
9246b85037dbSmrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
9247b85037dbSmrg      func_verbose "creating $output"
9248b85037dbSmrg
9249b85037dbSmrg      # Preserve any variables that may affect compiler behavior
9250b85037dbSmrg      for var in $variables_saved_for_relink; do
9251b85037dbSmrg	if eval test -z \"\${$var+set}\"; then
9252b85037dbSmrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
9253b85037dbSmrg	elif eval var_value=\$$var; test -z "$var_value"; then
9254b85037dbSmrg	  relink_command="$var=; export $var; $relink_command"
9255b85037dbSmrg	else
9256b85037dbSmrg	  func_quote_for_eval "$var_value"
9257b85037dbSmrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9258b85037dbSmrg	fi
9259b85037dbSmrg      done
9260b85037dbSmrg      # Quote the link command for shipping.
9261b85037dbSmrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
9262b85037dbSmrg      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9263b85037dbSmrg      if test "$hardcode_automatic" = yes ; then
9264b85037dbSmrg	relink_command=
9265b85037dbSmrg      fi
9266b85037dbSmrg
9267b85037dbSmrg      # Only create the output if not a dry run.
9268b85037dbSmrg      $opt_dry_run || {
9269b85037dbSmrg	for installed in no yes; do
9270b85037dbSmrg	  if test "$installed" = yes; then
9271b85037dbSmrg	    if test -z "$install_libdir"; then
9272b85037dbSmrg	      break
9273b85037dbSmrg	    fi
9274b85037dbSmrg	    output="$output_objdir/$outputname"i
9275b85037dbSmrg	    # Replace all uninstalled libtool libraries with the installed ones
9276b85037dbSmrg	    newdependency_libs=
9277b85037dbSmrg	    for deplib in $dependency_libs; do
9278b85037dbSmrg	      case $deplib in
9279b85037dbSmrg	      *.la)
9280b85037dbSmrg		func_basename "$deplib"
9281b85037dbSmrg		name="$func_basename_result"
928228515619Smrg		func_resolve_sysroot "$deplib"
928328515619Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
9284b85037dbSmrg		test -z "$libdir" && \
9285b85037dbSmrg		  func_fatal_error "\`$deplib' is not a valid libtool archive"
9286302b15bdSmrg		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
9287302b15bdSmrg		;;
9288302b15bdSmrg	      -L*)
9289302b15bdSmrg		func_stripname -L '' "$deplib"
9290302b15bdSmrg		func_replace_sysroot "$func_stripname_result"
9291302b15bdSmrg		func_append newdependency_libs " -L$func_replace_sysroot_result"
9292302b15bdSmrg		;;
9293302b15bdSmrg	      -R*)
9294302b15bdSmrg		func_stripname -R '' "$deplib"
9295302b15bdSmrg		func_replace_sysroot "$func_stripname_result"
9296302b15bdSmrg		func_append newdependency_libs " -R$func_replace_sysroot_result"
9297b85037dbSmrg		;;
9298302b15bdSmrg	      *) func_append newdependency_libs " $deplib" ;;
9299b85037dbSmrg	      esac
9300b85037dbSmrg	    done
9301b85037dbSmrg	    dependency_libs="$newdependency_libs"
9302b85037dbSmrg	    newdlfiles=
9303b85037dbSmrg
9304b85037dbSmrg	    for lib in $dlfiles; do
9305b85037dbSmrg	      case $lib in
9306b85037dbSmrg	      *.la)
9307b85037dbSmrg	        func_basename "$lib"
9308b85037dbSmrg		name="$func_basename_result"
9309b85037dbSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9310b85037dbSmrg		test -z "$libdir" && \
9311b85037dbSmrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
9312302b15bdSmrg		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
9313b85037dbSmrg		;;
9314302b15bdSmrg	      *) func_append newdlfiles " $lib" ;;
9315b85037dbSmrg	      esac
9316b85037dbSmrg	    done
9317b85037dbSmrg	    dlfiles="$newdlfiles"
9318b85037dbSmrg	    newdlprefiles=
9319b85037dbSmrg	    for lib in $dlprefiles; do
9320b85037dbSmrg	      case $lib in
9321b85037dbSmrg	      *.la)
9322b85037dbSmrg		# Only pass preopened files to the pseudo-archive (for
9323b85037dbSmrg		# eventual linking with the app. that links it) if we
9324b85037dbSmrg		# didn't already link the preopened objects directly into
9325b85037dbSmrg		# the library:
9326b85037dbSmrg		func_basename "$lib"
9327b85037dbSmrg		name="$func_basename_result"
9328b85037dbSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9329b85037dbSmrg		test -z "$libdir" && \
9330b85037dbSmrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
9331302b15bdSmrg		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
9332b85037dbSmrg		;;
9333b85037dbSmrg	      esac
9334b85037dbSmrg	    done
9335b85037dbSmrg	    dlprefiles="$newdlprefiles"
9336b85037dbSmrg	  else
9337b85037dbSmrg	    newdlfiles=
9338b85037dbSmrg	    for lib in $dlfiles; do
9339b85037dbSmrg	      case $lib in
9340b85037dbSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9341b85037dbSmrg		*) abs=`pwd`"/$lib" ;;
9342b85037dbSmrg	      esac
9343302b15bdSmrg	      func_append newdlfiles " $abs"
9344b85037dbSmrg	    done
9345b85037dbSmrg	    dlfiles="$newdlfiles"
9346b85037dbSmrg	    newdlprefiles=
9347b85037dbSmrg	    for lib in $dlprefiles; do
9348b85037dbSmrg	      case $lib in
9349b85037dbSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9350b85037dbSmrg		*) abs=`pwd`"/$lib" ;;
9351b85037dbSmrg	      esac
9352302b15bdSmrg	      func_append newdlprefiles " $abs"
9353b85037dbSmrg	    done
9354b85037dbSmrg	    dlprefiles="$newdlprefiles"
9355b85037dbSmrg	  fi
9356b85037dbSmrg	  $RM $output
9357b85037dbSmrg	  # place dlname in correct position for cygwin
9358b85037dbSmrg	  # In fact, it would be nice if we could use this code for all target
9359b85037dbSmrg	  # systems that can't hard-code library paths into their executables
9360b85037dbSmrg	  # and that have no shared library path variable independent of PATH,
9361b85037dbSmrg	  # but it turns out we can't easily determine that from inspecting
9362b85037dbSmrg	  # libtool variables, so we have to hard-code the OSs to which it
9363b85037dbSmrg	  # applies here; at the moment, that means platforms that use the PE
9364b85037dbSmrg	  # object format with DLL files.  See the long comment at the top of
9365b85037dbSmrg	  # tests/bindir.at for full details.
9366b85037dbSmrg	  tdlname=$dlname
9367b85037dbSmrg	  case $host,$output,$installed,$module,$dlname in
9368b85037dbSmrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
9369b85037dbSmrg	      # If a -bindir argument was supplied, place the dll there.
9370b85037dbSmrg	      if test "x$bindir" != x ;
9371b85037dbSmrg	      then
9372b85037dbSmrg		func_relative_path "$install_libdir" "$bindir"
9373b85037dbSmrg		tdlname=$func_relative_path_result$dlname
9374b85037dbSmrg	      else
9375b85037dbSmrg		# Otherwise fall back on heuristic.
9376b85037dbSmrg		tdlname=../bin/$dlname
9377b85037dbSmrg	      fi
9378b85037dbSmrg	      ;;
9379b85037dbSmrg	  esac
9380b85037dbSmrg	  $ECHO > $output "\
9381b85037dbSmrg# $outputname - a libtool library file
9382b85037dbSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
9383b85037dbSmrg#
9384b85037dbSmrg# Please DO NOT delete this file!
9385b85037dbSmrg# It is necessary for linking the library.
9386b85037dbSmrg
9387b85037dbSmrg# The name that we can dlopen(3).
9388b85037dbSmrgdlname='$tdlname'
9389b85037dbSmrg
9390b85037dbSmrg# Names of this library.
9391b85037dbSmrglibrary_names='$library_names'
9392b85037dbSmrg
9393b85037dbSmrg# The name of the static archive.
9394b85037dbSmrgold_library='$old_library'
9395b85037dbSmrg
9396b85037dbSmrg# Linker flags that can not go in dependency_libs.
9397b85037dbSmrginherited_linker_flags='$new_inherited_linker_flags'
9398b85037dbSmrg
9399b85037dbSmrg# Libraries that this one depends upon.
9400b85037dbSmrgdependency_libs='$dependency_libs'
9401b85037dbSmrg
9402b85037dbSmrg# Names of additional weak libraries provided by this library
9403b85037dbSmrgweak_library_names='$weak_libs'
9404b85037dbSmrg
9405b85037dbSmrg# Version information for $libname.
9406b85037dbSmrgcurrent=$current
9407b85037dbSmrgage=$age
9408b85037dbSmrgrevision=$revision
9409b85037dbSmrg
9410b85037dbSmrg# Is this an already installed library?
9411b85037dbSmrginstalled=$installed
9412b85037dbSmrg
9413b85037dbSmrg# Should we warn about portability when linking against -modules?
9414b85037dbSmrgshouldnotlink=$module
9415b85037dbSmrg
9416b85037dbSmrg# Files to dlopen/dlpreopen
9417b85037dbSmrgdlopen='$dlfiles'
9418b85037dbSmrgdlpreopen='$dlprefiles'
9419b85037dbSmrg
9420b85037dbSmrg# Directory that this library needs to be installed in:
9421b85037dbSmrglibdir='$install_libdir'"
9422b85037dbSmrg	  if test "$installed" = no && test "$need_relink" = yes; then
9423b85037dbSmrg	    $ECHO >> $output "\
9424b85037dbSmrgrelink_command=\"$relink_command\""
9425b85037dbSmrg	  fi
9426b85037dbSmrg	done
9427b85037dbSmrg      }
9428b85037dbSmrg
9429b85037dbSmrg      # Do a symbolic link so that the libtool archive can be found in
9430b85037dbSmrg      # LD_LIBRARY_PATH before the program is installed.
9431b85037dbSmrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
9432b85037dbSmrg      ;;
9433b85037dbSmrg    esac
9434b85037dbSmrg    exit $EXIT_SUCCESS
9435b85037dbSmrg}
9436b85037dbSmrg
9437302b15bdSmrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } &&
9438b85037dbSmrg    func_mode_link ${1+"$@"}
9439b85037dbSmrg
9440b85037dbSmrg
9441b85037dbSmrg# func_mode_uninstall arg...
9442b85037dbSmrgfunc_mode_uninstall ()
9443b85037dbSmrg{
9444b85037dbSmrg    $opt_debug
9445b85037dbSmrg    RM="$nonopt"
9446b85037dbSmrg    files=
9447b85037dbSmrg    rmforce=
9448b85037dbSmrg    exit_status=0
9449b85037dbSmrg
9450b85037dbSmrg    # This variable tells wrapper scripts just to set variables rather
9451b85037dbSmrg    # than running their programs.
9452b85037dbSmrg    libtool_install_magic="$magic"
9453b85037dbSmrg
9454b85037dbSmrg    for arg
9455b85037dbSmrg    do
9456b85037dbSmrg      case $arg in
9457302b15bdSmrg      -f) func_append RM " $arg"; rmforce=yes ;;
9458302b15bdSmrg      -*) func_append RM " $arg" ;;
9459302b15bdSmrg      *) func_append files " $arg" ;;
9460b85037dbSmrg      esac
9461b85037dbSmrg    done
9462b85037dbSmrg
9463b85037dbSmrg    test -z "$RM" && \
9464b85037dbSmrg      func_fatal_help "you must specify an RM program"
9465b85037dbSmrg
9466b85037dbSmrg    rmdirs=
9467b85037dbSmrg
9468b85037dbSmrg    for file in $files; do
9469b85037dbSmrg      func_dirname "$file" "" "."
9470b85037dbSmrg      dir="$func_dirname_result"
9471b85037dbSmrg      if test "X$dir" = X.; then
9472302b15bdSmrg	odir="$objdir"
9473b85037dbSmrg      else
9474302b15bdSmrg	odir="$dir/$objdir"
9475b85037dbSmrg      fi
9476b85037dbSmrg      func_basename "$file"
9477b85037dbSmrg      name="$func_basename_result"
9478302b15bdSmrg      test "$opt_mode" = uninstall && odir="$dir"
9479b85037dbSmrg
9480302b15bdSmrg      # Remember odir for removal later, being careful to avoid duplicates
9481302b15bdSmrg      if test "$opt_mode" = clean; then
9482b85037dbSmrg	case " $rmdirs " in
9483302b15bdSmrg	  *" $odir "*) ;;
9484302b15bdSmrg	  *) func_append rmdirs " $odir" ;;
9485b85037dbSmrg	esac
9486b85037dbSmrg      fi
9487b85037dbSmrg
9488b85037dbSmrg      # Don't error if the file doesn't exist and rm -f was used.
9489b85037dbSmrg      if { test -L "$file"; } >/dev/null 2>&1 ||
9490b85037dbSmrg	 { test -h "$file"; } >/dev/null 2>&1 ||
9491b85037dbSmrg	 test -f "$file"; then
9492b85037dbSmrg	:
9493b85037dbSmrg      elif test -d "$file"; then
9494b85037dbSmrg	exit_status=1
9495b85037dbSmrg	continue
9496b85037dbSmrg      elif test "$rmforce" = yes; then
9497b85037dbSmrg	continue
9498b85037dbSmrg      fi
9499b85037dbSmrg
9500b85037dbSmrg      rmfiles="$file"
9501b85037dbSmrg
9502b85037dbSmrg      case $name in
9503b85037dbSmrg      *.la)
9504b85037dbSmrg	# Possibly a libtool archive, so verify it.
9505b85037dbSmrg	if func_lalib_p "$file"; then
9506b85037dbSmrg	  func_source $dir/$name
9507b85037dbSmrg
9508b85037dbSmrg	  # Delete the libtool libraries and symlinks.
9509b85037dbSmrg	  for n in $library_names; do
9510302b15bdSmrg	    func_append rmfiles " $odir/$n"
9511b85037dbSmrg	  done
9512302b15bdSmrg	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
9513b85037dbSmrg
9514302b15bdSmrg	  case "$opt_mode" in
9515b85037dbSmrg	  clean)
9516302b15bdSmrg	    case " $library_names " in
9517b85037dbSmrg	    *" $dlname "*) ;;
9518302b15bdSmrg	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
9519b85037dbSmrg	    esac
9520302b15bdSmrg	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
9521b85037dbSmrg	    ;;
9522b85037dbSmrg	  uninstall)
9523b85037dbSmrg	    if test -n "$library_names"; then
9524b85037dbSmrg	      # Do each command in the postuninstall commands.
9525b85037dbSmrg	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
9526b85037dbSmrg	    fi
9527b85037dbSmrg
9528b85037dbSmrg	    if test -n "$old_library"; then
9529b85037dbSmrg	      # Do each command in the old_postuninstall commands.
9530b85037dbSmrg	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
9531b85037dbSmrg	    fi
9532b85037dbSmrg	    # FIXME: should reinstall the best remaining shared library.
9533b85037dbSmrg	    ;;
9534b85037dbSmrg	  esac
9535b85037dbSmrg	fi
9536b85037dbSmrg	;;
9537b85037dbSmrg
9538b85037dbSmrg      *.lo)
9539b85037dbSmrg	# Possibly a libtool object, so verify it.
9540b85037dbSmrg	if func_lalib_p "$file"; then
9541b85037dbSmrg
9542b85037dbSmrg	  # Read the .lo file
9543b85037dbSmrg	  func_source $dir/$name
9544b85037dbSmrg
9545b85037dbSmrg	  # Add PIC object to the list of files to remove.
9546b85037dbSmrg	  if test -n "$pic_object" &&
9547b85037dbSmrg	     test "$pic_object" != none; then
9548302b15bdSmrg	    func_append rmfiles " $dir/$pic_object"
9549b85037dbSmrg	  fi
9550b85037dbSmrg
9551b85037dbSmrg	  # Add non-PIC object to the list of files to remove.
9552b85037dbSmrg	  if test -n "$non_pic_object" &&
9553b85037dbSmrg	     test "$non_pic_object" != none; then
9554302b15bdSmrg	    func_append rmfiles " $dir/$non_pic_object"
9555b85037dbSmrg	  fi
9556b85037dbSmrg	fi
9557b85037dbSmrg	;;
9558b85037dbSmrg
9559b85037dbSmrg      *)
9560302b15bdSmrg	if test "$opt_mode" = clean ; then
9561b85037dbSmrg	  noexename=$name
9562b85037dbSmrg	  case $file in
9563b85037dbSmrg	  *.exe)
9564b85037dbSmrg	    func_stripname '' '.exe' "$file"
9565b85037dbSmrg	    file=$func_stripname_result
9566b85037dbSmrg	    func_stripname '' '.exe' "$name"
9567b85037dbSmrg	    noexename=$func_stripname_result
9568b85037dbSmrg	    # $file with .exe has already been added to rmfiles,
9569b85037dbSmrg	    # add $file without .exe
9570302b15bdSmrg	    func_append rmfiles " $file"
9571b85037dbSmrg	    ;;
9572b85037dbSmrg	  esac
9573b85037dbSmrg	  # Do a test to see if this is a libtool program.
9574b85037dbSmrg	  if func_ltwrapper_p "$file"; then
9575b85037dbSmrg	    if func_ltwrapper_executable_p "$file"; then
9576b85037dbSmrg	      func_ltwrapper_scriptname "$file"
9577b85037dbSmrg	      relink_command=
9578b85037dbSmrg	      func_source $func_ltwrapper_scriptname_result
9579302b15bdSmrg	      func_append rmfiles " $func_ltwrapper_scriptname_result"
9580b85037dbSmrg	    else
9581b85037dbSmrg	      relink_command=
9582b85037dbSmrg	      func_source $dir/$noexename
9583b85037dbSmrg	    fi
9584b85037dbSmrg
9585b85037dbSmrg	    # note $name still contains .exe if it was in $file originally
9586b85037dbSmrg	    # as does the version of $file that was added into $rmfiles
9587302b15bdSmrg	    func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
9588b85037dbSmrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
9589302b15bdSmrg	      func_append rmfiles " $odir/lt-$name"
9590b85037dbSmrg	    fi
9591b85037dbSmrg	    if test "X$noexename" != "X$name" ; then
9592302b15bdSmrg	      func_append rmfiles " $odir/lt-${noexename}.c"
9593b85037dbSmrg	    fi
9594b85037dbSmrg	  fi
9595b85037dbSmrg	fi
9596b85037dbSmrg	;;
9597b85037dbSmrg      esac
9598b85037dbSmrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
9599b85037dbSmrg    done
9600b85037dbSmrg
9601b85037dbSmrg    # Try to remove the ${objdir}s in the directories where we deleted files
9602b85037dbSmrg    for dir in $rmdirs; do
9603b85037dbSmrg      if test -d "$dir"; then
9604b85037dbSmrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
9605b85037dbSmrg      fi
9606b85037dbSmrg    done
9607b85037dbSmrg
9608b85037dbSmrg    exit $exit_status
9609b85037dbSmrg}
9610b85037dbSmrg
9611302b15bdSmrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
9612b85037dbSmrg    func_mode_uninstall ${1+"$@"}
9613b85037dbSmrg
9614302b15bdSmrgtest -z "$opt_mode" && {
9615b85037dbSmrg  help="$generic_help"
9616b85037dbSmrg  func_fatal_help "you must specify a MODE"
9617b85037dbSmrg}
9618b85037dbSmrg
9619b85037dbSmrgtest -z "$exec_cmd" && \
9620302b15bdSmrg  func_fatal_help "invalid operation mode \`$opt_mode'"
9621b85037dbSmrg
9622b85037dbSmrgif test -n "$exec_cmd"; then
9623b85037dbSmrg  eval exec "$exec_cmd"
9624b85037dbSmrg  exit $EXIT_FAILURE
9625b85037dbSmrgfi
9626b85037dbSmrg
9627b85037dbSmrgexit $exit_status
9628b85037dbSmrg
9629b85037dbSmrg
9630b85037dbSmrg# The TAGs below are defined such that we never get into a situation
9631b85037dbSmrg# in which we disable both kinds of libraries.  Given conflicting
9632b85037dbSmrg# choices, we go for a static library, that is the most portable,
9633b85037dbSmrg# since we can't tell whether shared libraries were disabled because
9634b85037dbSmrg# the user asked for that or because the platform doesn't support
9635b85037dbSmrg# them.  This is particularly important on AIX, because we don't
9636b85037dbSmrg# support having both static and shared libraries enabled at the same
9637b85037dbSmrg# time on that platform, so we default to a shared-only configuration.
9638b85037dbSmrg# If a disable-shared tag is given, we'll fallback to a static-only
9639b85037dbSmrg# configuration.  But we'll never go from static-only to shared-only.
9640b85037dbSmrg
9641b85037dbSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
9642b85037dbSmrgbuild_libtool_libs=no
9643b85037dbSmrgbuild_old_libs=yes
9644b85037dbSmrg# ### END LIBTOOL TAG CONFIG: disable-shared
9645b85037dbSmrg
9646b85037dbSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
9647b85037dbSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
9648b85037dbSmrg# ### END LIBTOOL TAG CONFIG: disable-static
9649b85037dbSmrg
9650b85037dbSmrg# Local Variables:
9651b85037dbSmrg# mode:shell-script
9652b85037dbSmrg# sh-indentation:2
9653b85037dbSmrg# End:
9654b85037dbSmrg# vi:sw=2
9655b85037dbSmrg
9656