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